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 F0FD7C32771 for ; Wed, 21 Sep 2022 14:07:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2798884CBD; Wed, 21 Sep 2022 16:06:55 +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=1663769215; bh=uxS0mr/h2akL0I4D2VILkvw+6uJalDQjrOXf99HgUTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XaoGr6d+BHw463thS7QFFYv7SH2JjsKt41WFxbeU8L4ekwn21TvuOuJBVEJDqCfH6 s8jXvM6/v4svj9Bhaa108EfxMLErB1Wa58mtEWyCUaRHJVLJde4QgyHr8YM0YLDbai YvBfP242EnNLKCZxeKbPvknMV5O7wfY6fdF5fnJMUCNKsFlgwnfouvXVQkbG+cgizM fao36D9F9h+YEtnpVW79wOJVPCMPfAP4YxbFsfoO76C8kRrB1fGjQOr/eE/d3n5Eno p6c5QphF1oYy7NYMbXjnhz77Qdir8F4eFQ6NTltPuDW8O1WZDi80PieCTmQD5HIvgo QGnxRdEeOsvOw== Received: by phobos.denx.de (Postfix, from userid 109) id 901B384C9B; Wed, 21 Sep 2022 16:06:37 +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 B38D684C9F 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 [IPv6:2001:67c:2050:b231:465::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 4MXgFJ6XTsz9skY; 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, Christian Gmeiner , Dario Binacchi Subject: [PATCH 05/10] timer: omap-timer: Add timer_early functions Date: Wed, 21 Sep 2022 16:06:20 +0200 Message-Id: <20220921140625.999002-6-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-Rspamd-Queue-Id: 4MXgFJ6XTsz9skY 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: Christian Gmeiner Cc: Dario Binacchi --- drivers/timer/omap-timer.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index aa2e4360c1bb..315dbb634aa7 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -106,6 +106,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 const struct timer_ops omap_timer_ops = { .get_count = omap_timer_get_count, }; -- 2.37.3