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 29E64C54EBE for ; Mon, 16 Jan 2023 15:34:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB9A28547B; Mon, 16 Jan 2023 16:34:56 +0100 (CET) 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=1673883297; bh=fJsy14HTt5hkzIlt2Z1GdbHS27eXKG8TBfsEuWyP8T0=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=BEc0NkK62Bf/DXDO5E/uAYpRyxUPoMOnH64qvd4zXBWbVsa/2ejSiu9U3fFc9uqmG 492rrMoMhDuNO1oXXdajE8/s+Fm0TLZkITUZz7j/03J/40rQLRWfBsgu99vb9L0eJO TvmHViVxkNZFiksOklu+3fwHfcrsKEvVuiZWMN1+4aiIbeBKwEHOT5rIi0SmwhrHRr OqLFcA0BGWAYGGZ7q7QRKB3SBDYa4hLJe/gx/C+7sSwzlgRSYIiKRtLPuIVOzgqaCo 9L0WJclGNnKeSPm1qhK3QM7M+xCrEeBT17jQWW75nqnTybGX0T504gKLMflvAiGZJo AhAmFwoQ7a+pg== Received: by phobos.denx.de (Postfix, from userid 109) id DE55C8555D; Mon, 16 Jan 2023 16:34:54 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [80.241.59.204]) (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 A4AD58535B for ; Mon, 16 Jan 2023 16:34:52 +0100 (CET) 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-204.mailbox.org (Postfix) with ESMTPS id 4NwbgB2SFXz9sSB; Mon, 16 Jan 2023 16:34:46 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Cc: Martin Rowe , Tony Dinh , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Michael Walle Subject: [PATCH] timer: orion-timer: Fix problem in early_init_done() Date: Mon, 16 Jan 2023 16:34:45 +0100 Message-Id: <20230116153445.145580-1-sr@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 It was noticed that Clearfog is currently broken with this newly introduced early_init_done() function. Apparently the timer is enabled here when U-Boot is run but not configured - at least not correctly. Resulting in a hangup in the timer reading functions. To fix this, also read the value of the reload register and check it's value with the one written to by U-Boot. Only if this matches, the init has already been done. Signed-off-by: Stefan Roese Cc: Martin Rowe Cc: Tony Dinh Cc: Pali Rohár Cc: Michael Walle --- drivers/timer/orion-timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c index 810a03d54960..9cab27f2e48b 100644 --- a/drivers/timer/orion-timer.c +++ b/drivers/timer/orion-timer.c @@ -25,7 +25,8 @@ struct orion_timer_priv { static bool early_init_done(void *base) { - if (readl(base + TIMER_CTRL) & TIMER0_EN) + if ((readl(base + TIMER_CTRL) & TIMER0_EN) && + (readl(base + TIMER0_RELOAD) == ~0)) return true; return false; } -- 2.39.0