From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D6F5C32771 for ; Wed, 21 Sep 2022 14:07:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4401184CB1; Wed, 21 Sep 2022 16:06:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1663769207; bh=VuzHV6s5P1mzuBFv9QE1+Z0NtoHLiKfz8L3RPYFc/OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NKp0akwnG3Zbc3vODKpK1YtcdiPo5kky8s7PiPawnGwrvmS7QCvqed7sb39weR2x1 O63W+wbeFQwqmR6EkFzZ6GbfB10KjHhpgPamzYrNvs0dLGjYzadhxasLxkOCNmvpnM UkgW8qslBgrK79ToS/qWCJk0iEfsvlYzUSVTpZ9zaYEYWoSktWKIGson1ZZTfla30u Z6ajH6OZSq5pUly8oWsNHZ+t/QYYIPItI8tCtUQRtMINf0IMUnayo5LDkPqyXgL22v j5SiNQXNjPK0xbfaEbIsp3O9Cb89F5Y/D3+czjeoAfIcRog92y4knPtCwn3EKehHll LEA2c5xOKvrtw== Received: by phobos.denx.de (Postfix, from userid 109) id 4FFF984C9C; Wed, 21 Sep 2022 16:06:35 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:101:465::107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 61AAC84C9D for ; Wed, 21 Sep 2022 16:06:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4MXgFJ3ptKz9skM; Wed, 21 Sep 2022 16:06:28 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: sjg@chromium.org, trini@konsulko.com, Michal Simek Subject: [PATCH 04/10] timer: cadence-ttc: Add timer_early functions Date: Wed, 21 Sep 2022 16:06:19 +0200 Message-Id: <20220921140625.999002-5-sr@denx.de> In-Reply-To: <20220921140625.999002-1-sr@denx.de> References: <20220921140625.999002-1-sr@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Currently this timer driver provides timer_get_boot_us() to support the BOOTSTAGE functionality. This patch adds the timer_early functions so that the "normal" timer functions can be used, when CONFIG_TIMER_EARLY is enabled. timer_get_boot_us() will get removed in a follow-up patch, once the BOOTSTAGE interface is migrated to timer_get_us(). Signed-off-by: Stefan Roese Cc: Michal Simek --- drivers/timer/cadence-ttc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/timer/cadence-ttc.c b/drivers/timer/cadence-ttc.c index 2eff45060ad6..e26c7923a140 100644 --- a/drivers/timer/cadence-ttc.c +++ b/drivers/timer/cadence-ttc.c @@ -58,6 +58,31 @@ ulong timer_get_boot_us(void) } #endif +unsigned long notrace timer_early_get_rate(void) +{ + return 1; +} + +u64 notrace timer_early_get_count(void) +{ + u64 ticks = 0; + u32 rate = 1; + u64 us; + int ret; + + ret = dm_timer_init(); + if (!ret) { + /* The timer is available */ + rate = timer_get_rate(gd->timer); + timer_get_count(gd->timer, &ticks); + } else { + return 0; + } + + us = (ticks * 1000) / rate; + return us; +} + static u64 cadence_ttc_get_count(struct udevice *dev) { struct cadence_ttc_priv *priv = dev_get_priv(dev); -- 2.37.3