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 576BCC433F5 for ; Thu, 10 Mar 2022 18:46:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4025283AE2; Thu, 10 Mar 2022 19:46:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ivWFlnA9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A07083AB6; Thu, 10 Mar 2022 19:46:11 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0926A83AD1 for ; Thu, 10 Mar 2022 19:46:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=krjdev@gmail.com Received: by mail-wr1-x436.google.com with SMTP id r10so9434819wrp.3 for ; Thu, 10 Mar 2022 10:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=/8rckCrwZ5iqTRgmtJfWFf2J4bawIrLhdlBez5B+sl4=; b=ivWFlnA9S0DRfkFTV+XWctbQWgJFoiCmEaWVdWfLvvANQeZdAOz6yb1r2mMU7uoiMZ QRnABXOxgZrFLdNtNY4//39tX4TU2iKGNQK3g7xgvwYN739npiYrxH0Al3A+JZI+bJyO V8Jzh9duMi2tHs8l349YkgIFKj2LSdwAqg4nChwMe0iRQAh+c4OL6ZfT+UOR3z9T7b9Z d4U64bv2+CEa4GNCkbZ1tuYyxQAyie78Velt+trCN0BdsPF0s9ewHcUfCfWyU7kWhGjx Hzcpts8gSTPMwQLrYUaQlARCjuDaBEua+tAMJluMRFjEAdD514cdJMFldl2s1BrCa9hd xtyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=/8rckCrwZ5iqTRgmtJfWFf2J4bawIrLhdlBez5B+sl4=; b=QHmLQRoMXIVlShy9ySqKqdLL1ECfrgG51BXO12svQDoopnqMy7TUXOTZhg2YcGIFr8 JfjGkt2WL3KpVO2iEhL6FrnuKXHM/h7IEMezbj8pas85JQlPu8cYHvy2uQ9aeQqPcfbo L+qYtHOmctYM3CyLITl0TydasZaNk5Y9MyjJBBdWmD4tEKw5u3fSO2zM+TfB4GkvRWpX Jqk+39JAk0ODYYyOwpZ2877ucsIRQSknQyVqpsd0mHE1p+sPwBUgNazanpggqDoVrSZg 7kGNEpdH6apkSMkpulcIkKv0tBqio6b1PAdYhVUsvNGSRovysJg6M/ZIUu5tdAU4dMH8 mfgA== X-Gm-Message-State: AOAM530UYKRVl7BNJrIS+NoeZbc5E6Eounto0v9BIqsqLzqw+AJaXYJQ tim/mWx/kwuTQvJJArkk0bnFD5LTnA8= X-Google-Smtp-Source: ABdhPJwH3NXs+id8+xRhEk0xXhehrBKvPmSxnnNlj829BUV9z3ahNrk/F9dqy2LUH8FFefkMR25m3Q== X-Received: by 2002:adf:efc6:0:b0:1f1:e397:44b with SMTP id i6-20020adfefc6000000b001f1e397044bmr4685267wrp.298.1646937964397; Thu, 10 Mar 2022 10:46:04 -0800 (PST) Received: from matrix42.lan (212-197-176-189.adsl.highway.telekom.at. [212.197.176.189]) by smtp.gmail.com with ESMTPSA id e4-20020adffc44000000b001f1dba38a65sm4775742wrs.105.2022.03.10.10.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 10:46:04 -0800 (PST) From: Johannes Krottmayer To: u-boot@lists.denx.de, trini@konsulko.com Cc: Johannes Krottmayer Subject: [PATCH 2/2] lib: time.c: Try also DM timer, when CONFIG_TIMER_EARLY is selected Date: Thu, 10 Mar 2022 19:45:49 +0100 Message-Id: <20220310184549.1883-3-krjdev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220310184549.1883-1-krjdev@gmail.com> References: <20220310184549.1883-1-krjdev@gmail.com> 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: , Reply-To: krjdev@gnail.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Description: When CONFIG_TIMER_EARLY is selected only the timer_early_* functions will be called. With this patch first gd->timer will be checked, if the DM timer is available, it uses the DM timer. When gd->timer is empty, the timer_early_* functions will be called. Signed-off-by: Johannes Krottmayer Cc: Tom Rini --- lib/time.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/lib/time.c b/lib/time.c index 96074b84af..85803d8ff5 100644 --- a/lib/time.c +++ b/lib/time.c @@ -5,7 +5,6 @@ */ #include -#include #include #include #include @@ -66,17 +65,22 @@ extern unsigned long __weak timer_read_counter(void); #if CONFIG_IS_ENABLED(TIMER) ulong notrace get_tbclk(void) { - if (!gd->timer) { + int ret; + #ifdef CONFIG_TIMER_EARLY + if (!gd->timer) return timer_early_get_rate(); + + ret = dm_timer_init(); + + if (ret) + return ret; #else - int ret; + ret = dm_timer_init(); - ret = dm_timer_init(); - if (ret) - return ret; + if (ret) + return ret; #endif - } return timer_get_rate(gd->timer); } @@ -86,19 +90,32 @@ uint64_t notrace get_ticks(void) u64 count; int ret; - if (!gd->timer) { #ifdef CONFIG_TIMER_EARLY + if (!gd->timer) return timer_early_get_count(); -#else - int ret; - ret = dm_timer_init(); - if (ret) - panic("Could not initialize timer (err %d)\n", ret); -#endif + ret = dm_timer_init(); + + if (ret) + panic("Could not initialize timer (err %d)\n", ret); + + ret = timer_get_count(gd->timer, &count); + + if (ret) { + if (spl_phase() > PHASE_TPL) + panic("Could not read count from timer (err %d)\n", + ret); + else + panic("no timer (err %d)\n", ret); } +#else + ret = dm_timer_init(); + + if (ret) + panic("Could not initialize timer (err %d)\n", ret); ret = timer_get_count(gd->timer, &count); + if (ret) { if (spl_phase() > PHASE_TPL) panic("Could not read count from timer (err %d)\n", @@ -106,6 +123,7 @@ uint64_t notrace get_ticks(void) else panic("no timer (err %d)\n", ret); } +#endif return count; } -- 2.34.1