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 C43CBECAAD4 for ; Tue, 30 Aug 2022 11:54:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C393849B4; Tue, 30 Aug 2022 13:53:36 +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=1661860416; bh=pBL5hzlDXTnghDQdnR5vxRGJI+5IO9JeeP10rFhExjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EEW9YdPzTOLrPZe+mnDpSpcLhP85v36i+7c7PKo0lTY7Lrk66wqrjyfaQE1ncmGbe PDWiVVx1hzbUhpFERAuZM0QA+fwFucT77eRwjQEcxalQUzmLK/IGMvkXcqFOpT224m BF7ztMzXIw4dp2E7VuUJqsFk2M2mGBjHy+Ih49zgNmFhOUX2GuBKBcrlzjn0xNxFgo Ll+gUXFK91ZUSJYpMcMHoss0XicqALcFnMOr2eVwAiU80yNtwntGBGWFxMeZwcLZLk oKLvE3qCprLOWfh3mOK+kqidASoaR+q3Be5pUcVithIvFECK2CysAQLWV2wW93cKH2 VIYSxxbIdZigw== Received: by phobos.denx.de (Postfix, from userid 109) id BC7538499C; Tue, 30 Aug 2022 13:53:25 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [80.241.59.207]) (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 27E1984993 for ; Tue, 30 Aug 2022 13:53:21 +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 smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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 4MH5Kq1xB0z9sRB; Tue, 30 Aug 2022 13:53:19 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: pali@kernel.org, mibodhi@gmail.com, michael@walle.cc Subject: [PATCH 2/6] timer: orion-timer: Add timer_get_boot_us() for BOOTSTAGE support Date: Tue, 30 Aug 2022 13:53:13 +0200 Message-Id: <20220830115317.410812-3-sr@denx.de> In-Reply-To: <20220830115317.410812-1-sr@denx.de> References: <20220830115317.410812-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 Add timer_get_boot_us() to support boards, that have CONFIG_BOOTSTAGE enabled, like pogo_v4. Signed-off-by: Stefan Roese --- drivers/timer/orion-timer.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c index 02ed138642b8..7e920eaeaa40 100644 --- a/drivers/timer/orion-timer.c +++ b/drivers/timer/orion-timer.c @@ -41,6 +41,28 @@ u64 notrace timer_early_get_count(void) } #endif +#if CONFIG_IS_ENABLED(BOOTSTAGE) +ulong timer_get_boot_us(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; +} +#endif + static uint64_t orion_timer_get_count(struct udevice *dev) { struct orion_timer_priv *priv = dev_get_priv(dev); -- 2.37.2