diff options
author | Tom Rini <trini@konsulko.com> | 2022-08-23 15:44:54 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-08-23 15:44:54 -0400 |
commit | aea087a665c447dfb89bf2113cad74ad53fa17a0 (patch) | |
tree | fbb710bb7a66da927c142b8710cf4564b5652ced /drivers/timer/orion-timer.c | |
parent | 1247c35c80cb0f6f17c88d54c6575d6d1f50c608 (diff) | |
parent | 560a5c3bb3bedac7d1da93362401a1d926214660 (diff) |
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
- kirkwood: pogo_v4 & nsa310s: Add distro boot (Tony)
- kirkwood: add DM timer support and use it on lsxl boards (Michael)
- kirkwood: convert the Buffalo Linkstation LS-CHLv2 and XHL boards
to DM (Michael)
- mvebu: turris_mox/omnia: misc improments (Pali)
- mvebu: mbus: Fix mbus driver to work also after U-Boot relocation (Pali)
Diffstat (limited to 'drivers/timer/orion-timer.c')
-rw-r--r-- | drivers/timer/orion-timer.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c new file mode 100644 index 0000000000..fd30e1bf03 --- /dev/null +++ b/drivers/timer/orion-timer.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <asm/io.h> +#include <common.h> +#include <dm/device.h> +#include <dm/fdtaddr.h> +#include <timer.h> + +#define TIMER_CTRL 0x00 +#define TIMER0_EN BIT(0) +#define TIMER0_RELOAD_EN BIT(1) +#define TIMER0_RELOAD 0x10 +#define TIMER0_VAL 0x14 + +struct orion_timer_priv { + void *base; +}; + +static uint64_t orion_timer_get_count(struct udevice *dev) +{ + struct orion_timer_priv *priv = dev_get_priv(dev); + + return ~readl(priv->base + TIMER0_VAL); +} + +static int orion_timer_probe(struct udevice *dev) +{ + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + struct orion_timer_priv *priv = dev_get_priv(dev); + + priv->base = devfdt_remap_addr_index(dev, 0); + if (!priv->base) { + debug("unable to map registers\n"); + return -ENOMEM; + } + + uc_priv->clock_rate = CONFIG_SYS_TCLK; + + writel(~0, priv->base + TIMER0_VAL); + writel(~0, priv->base + TIMER0_RELOAD); + + /* enable timer */ + setbits_le32(priv->base + TIMER_CTRL, TIMER0_EN | TIMER0_RELOAD_EN); + + return 0; +} + +static const struct timer_ops orion_timer_ops = { + .get_count = orion_timer_get_count, +}; + +static const struct udevice_id orion_timer_ids[] = { + { .compatible = "marvell,orion-timer" }, + {} +}; + +U_BOOT_DRIVER(orion_timer) = { + .name = "orion_timer", + .id = UCLASS_TIMER, + .of_match = orion_timer_ids, + .probe = orion_timer_probe, + .ops = &orion_timer_ops, + .priv_auto = sizeof(struct orion_timer_priv), +}; |