From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Cc: pali@kernel.org, mibodhi@gmail.com, michael@walle.cc
Subject: [PATCH 1/6] timer: orion-timer: Add support for other Armada SoC's
Date: Tue, 30 Aug 2022 13:53:12 +0200 [thread overview]
Message-ID: <20220830115317.410812-2-sr@denx.de> (raw)
In-Reply-To: <20220830115317.410812-1-sr@denx.de>
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 <sr@denx.de>
---
drivers/timer/Kconfig | 5 ++++-
drivers/timer/orion-timer.c | 44 ++++++++++++++++++++++++++++++++++---
2 files changed, 45 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 fd30e1bf036c..02ed138642b8 100644
--- a/drivers/timer/orion-timer.c
+++ b/drivers/timer/orion-timer.c
@@ -11,10 +11,36 @@
#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
+
+#if defined(CONFIG_ARCH_MVEBU) && IS_ENABLED(CONFIG_TIMER_EARLY)
+/**
+ * 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 ~readl(MVEBU_TIMER_BASE + TIMER0_VAL);
+}
+#endif
+
static uint64_t orion_timer_get_count(struct udevice *dev)
{
struct orion_timer_priv *priv = dev_get_priv(dev);
@@ -25,6 +51,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 +60,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 +85,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.2
next prev parent reply other threads:[~2022-08-30 11:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 11:53 [PATCH 0/6] Enable CONFIG_TIMER for all Kirwood / MVEBU boards Stefan Roese
2022-08-30 11:53 ` Stefan Roese [this message]
2022-08-30 11:53 ` [PATCH 2/6] timer: orion-timer: Add timer_get_boot_us() for BOOTSTAGE support Stefan Roese
2022-08-30 12:00 ` Michael Walle
2022-08-30 12:08 ` Stefan Roese
2022-08-30 15:56 ` Simon Glass
2022-08-31 5:57 ` Stefan Roese
2022-08-31 17:44 ` Simon Glass
2022-09-01 5:33 ` Stefan Roese
2022-08-30 11:53 ` [PATCH 3/6] arm: mvebu: Use CONFIG_TIMER on all MVEBU & KIRKWOOD platforms Stefan Roese
2022-08-30 12:04 ` Michael Walle
2022-08-30 12:11 ` Stefan Roese
2022-08-30 11:53 ` [PATCH 4/6] arm: mvebu: dts: Makefile: Compile Armada 375 dtb in a separate step Stefan Roese
2022-08-30 11:53 ` [PATCH 5/6] arm: mvebu: dts: armada-375.dtsi: Add timer0 & timer1 Stefan Roese
2022-08-30 11:53 ` [PATCH 6/6] arm: mvebu: dts: mvebu-u-boot.dtsi: Add "u-boot, dm-pre-reloc" to timer DT node Stefan Roese
2022-08-30 22:15 ` [PATCH 0/6] Enable CONFIG_TIMER for all Kirwood / MVEBU boards Tony Dinh
2022-08-31 5:02 ` Stefan Roese
2022-08-31 5:08 ` Stefan Roese
2022-08-31 6:12 ` Stefan Roese
2022-08-31 6:45 ` Tony Dinh
2022-08-31 6:30 ` Tony Dinh
2022-08-31 7:22 ` Stefan Roese
2022-08-31 15:08 ` Tony Dinh
2022-08-31 21:53 ` Tony Dinh
2022-09-01 1:38 ` Tony Dinh
2022-09-01 2:27 ` Simon Glass
2022-09-01 7:39 ` Tony Dinh
2022-09-01 9:27 ` Stefan Roese
2022-09-01 11:52 ` Stefan Herbrechtsmeier
2022-09-02 5:38 ` Stefan Roese
2022-09-01 14:34 ` Simon Glass
2022-09-01 23:46 ` Tony Dinh
2022-09-02 2:51 ` Tony Dinh
2022-09-02 3:49 ` Tony Dinh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220830115317.410812-2-sr@denx.de \
--to=sr@denx.de \
--cc=mibodhi@gmail.com \
--cc=michael@walle.cc \
--cc=pali@kernel.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox