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 02C80ECAAA1 for ; Tue, 30 Aug 2022 12:00:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6487984984; Tue, 30 Aug 2022 14:00:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=walle.cc header.i=@walle.cc header.b="JbrBjLlF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 957ED84984; Tue, 30 Aug 2022 14:00:14 +0200 (CEST) Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) (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 1E76484984 for ; Tue, 30 Aug 2022 14:00:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@walle.cc Received: from 3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 2C7367F2C; Tue, 30 Aug 2022 14:00:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1661860811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v4+MEiYZM4rxEyKGN5u5bQ+chljpRXtL3YFkCw+W0Z8=; b=JbrBjLlFsABpu1NFeAEkCyPWXVYZWIsBn5IlojDta2A2YC8wjVdwIbXXbtdYt8Q2U6GJPi 0i6p2RaCZUsMu4YfmbfbqwfeiafLrx/PsGEOnWVyUM/zaKUz/lobEXEUjTJvovkXtQwOzh HNvPwk8R4wd1y+K/mGG/VXODkySz915E9UEbjm5xhTsnBkIqGFVcF6sgWK4LRk6v1McuBZ 6EPigMiaMqLXT6LupO9/5zNlqcmeCavg7JZ9Wiqxh5aqWQEvUAMnAG+QcoTpax3f1E3xBb VfWLleSEUyTDmZwEz5X8eDyeNRfazKUMqeFuVXcYq144kLHa0KEtKR2MC1qyJQ== MIME-Version: 1.0 Date: Tue, 30 Aug 2022 14:00:10 +0200 From: Michael Walle To: Stefan Roese Cc: u-boot@lists.denx.de, pali@kernel.org, mibodhi@gmail.com Subject: Re: [PATCH 2/6] timer: orion-timer: Add timer_get_boot_us() for BOOTSTAGE support In-Reply-To: <20220830115317.410812-3-sr@denx.de> References: <20220830115317.410812-1-sr@denx.de> <20220830115317.410812-3-sr@denx.de> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <092fe47f6dee523cb4cdbb81abc0cd40@walle.cc> X-Sender: michael@walle.cc Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit 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 Am 2022-08-30 13:53, schrieb Stefan Roese: > 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 This is duplicate code in almost all the timer drivers, shouldn't this be a (weak) default implementation in timer-uclass.c? Also, do you need to guard it with CONFIG_IS_ENABLED(BOOTSTAGE), aren't unused functions discarded anyway? -michael