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 F3B2AC54EE9 for ; Fri, 2 Sep 2022 06:26:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0EB8D84A50; Fri, 2 Sep 2022 08:26:11 +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=1662099971; bh=kgfAGeHc4l1zvTgjGbYbaGe7BQayZCqQdCCcD67qFvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JAPvjbgpIXHUZFt7S1ubn591UJCAgmGsefhiI5ooDShSUStcVdYthlzr7H9i9K5w5 Y2FjAdJHqX8e9cmXKK1Y5vMj6rHfgHkaBJP6x3UaJWUReIF0Sgw9c6SkTnV01K+Fy5 2mTyN/PyqXbwgtoUSpe1COmgux6urhfLkcBqSqt5rUlx4GNqjw2oKLXPiGCeIzwFKq zt74JwpjhZBwznfzEFObhX9WsVgNJUEBaQDZSx8QZfGf6cGiyiNQ+TFE6+GxgIA58/ y27OilU/hXgA2poSo54aB9E4VWojDEBWJDiqQQ+pqeKgMRb7v9+Vp+x9EqBKAaa0WL Ayyu6jr5IUBeg== Received: by phobos.denx.de (Postfix, from userid 109) id 289BB840B1; Fri, 2 Sep 2022 08:26:02 +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 86AC184A30 for ; Fri, 2 Sep 2022 08:25:58 +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 smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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 4MJnwh4Mqdz9sR4; Fri, 2 Sep 2022 08:25:56 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: pali@kernel.org, mibodhi@gmail.com, michael@walle.cc, sjg@chromium.org Subject: [PATCH v2 2/8] timer: orion-timer: Add support for other Armada SoC's Date: Fri, 2 Sep 2022 08:25:48 +0200 Message-Id: <20220902062554.1197435-3-sr@denx.de> In-Reply-To: <20220902062554.1197435-1-sr@denx.de> References: <20220902062554.1197435-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 This patch adds support for other Marvell Armada SoC's, supporting the 25MHz fixed clock operation, like the Armada XP etc. Signed-off-by: Stefan Roese --- v2: - Use timer_conv_64() in timer_early_get_count() drivers/timer/Kconfig | 5 ++++- drivers/timer/orion-timer.c | 42 ++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 404929014810..b0814acca3fb 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -197,8 +197,11 @@ config OMAP_TIMER config ORION_TIMER bool "Orion timer support" depends on TIMER + default y if ARCH_KIRKWOOD || (ARCH_MVEBU && ARMADA_32BIT) + select TIMER_EARLY if ARCH_MVEBU help - Select this to enable an timer for Orion devices. + Select this to enable an timer for Orion and Armada devices + like Armada XP etc. config RISCV_TIMER bool "RISC-V timer support" diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c index d7d1a1b24462..14f318e57d4d 100644 --- a/drivers/timer/orion-timer.c +++ b/drivers/timer/orion-timer.c @@ -11,10 +11,34 @@ #define TIMER0_RELOAD 0x10 #define TIMER0_VAL 0x14 +enum input_clock_type { + INPUT_CLOCK_NON_FIXED, + INPUT_CLOCK_25MHZ, /* input clock rate is fixed to 25MHz */ +}; + struct orion_timer_priv { void *base; }; +#define MVEBU_TIMER_FIXED_RATE_25MHZ 25000000 + +/** + * timer_early_get_rate() - Get the timer rate before driver model + */ +unsigned long notrace timer_early_get_rate(void) +{ + return MVEBU_TIMER_FIXED_RATE_25MHZ; +} + +/** + * timer_early_get_count() - Get the timer count before driver model + * + */ +u64 notrace timer_early_get_count(void) +{ + return timer_conv_64(~readl(MVEBU_TIMER_BASE + TIMER0_VAL)); +} + static uint64_t orion_timer_get_count(struct udevice *dev) { struct orion_timer_priv *priv = dev_get_priv(dev); @@ -25,6 +49,7 @@ static uint64_t orion_timer_get_count(struct udevice *dev) static int orion_timer_probe(struct udevice *dev) { struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + enum input_clock_type type = dev_get_driver_data(dev); struct orion_timer_priv *priv = dev_get_priv(dev); priv->base = devfdt_remap_addr_index(dev, 0); @@ -33,11 +58,20 @@ static int orion_timer_probe(struct udevice *dev) return -ENOMEM; } - uc_priv->clock_rate = CONFIG_SYS_TCLK; - writel(~0, priv->base + TIMER0_VAL); writel(~0, priv->base + TIMER0_RELOAD); + if (type == INPUT_CLOCK_25MHZ) { + /* + * On Armada XP / 38x ..., the 25MHz clock source needs to + * be enabled + */ + setbits_le32(priv->base + TIMER_CTRL, BIT(11)); + uc_priv->clock_rate = MVEBU_TIMER_FIXED_RATE_25MHZ; + } else { + uc_priv->clock_rate = CONFIG_SYS_TCLK; + } + /* enable timer */ setbits_le32(priv->base + TIMER_CTRL, TIMER0_EN | TIMER0_RELOAD_EN); @@ -49,7 +83,9 @@ static const struct timer_ops orion_timer_ops = { }; static const struct udevice_id orion_timer_ids[] = { - { .compatible = "marvell,orion-timer" }, + { .compatible = "marvell,orion-timer", .data = INPUT_CLOCK_NON_FIXED }, + { .compatible = "marvell,armada-370-timer", .data = INPUT_CLOCK_25MHZ }, + { .compatible = "marvell,armada-xp-timer", .data = INPUT_CLOCK_25MHZ }, {} }; -- 2.37.3