diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2013-05-12 15:09:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-05-15 07:39:27 +0200 |
commit | 98a8c2f28bf93bcdf410bc4e560c4690f9994f93 (patch) | |
tree | 68099b9be65086ec49fee8f4288cf9dd46352310 /drivers/clocksource | |
parent | 87f486c7f1878cdd9de45c4e7962e3009092d270 (diff) | |
download | barebox-98a8c2f28bf93bcdf410bc4e560c4690f9994f93.tar.gz barebox-98a8c2f28bf93bcdf410bc4e560c4690f9994f93.tar.xz |
arm: initial support for Marvell Dove SoCs
This commit adds minimal support for the Marvell Dove SoC (88AP510) as
first SoC of the Marvell Orion family. Orion SoCs have a different timer,
therefore current mach-mvebu and Armada 370/XP Kconfig and Makefiles are
slightly modified and a new clocksource drivers is added.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/Kconfig | 4 | ||||
-rw-r--r-- | drivers/clocksource/Makefile | 1 | ||||
-rw-r--r-- | drivers/clocksource/orion.c | 76 |
3 files changed, 81 insertions, 0 deletions
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index dfc89ddea8..4ef25ec45b 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -21,3 +21,7 @@ config CLOCKSOURCE_MVEBU config CLOCKSOURCE_NOMADIK bool depends on ARM + +config CLOCKSOURCE_ORION + bool + depends on ARCH_MVEBU diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 0b42ce48d6..25b7f460da 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CLOCKSOURCE_BCM2835) += bcm2835.o obj-$(CONFIG_CLOCKSOURCE_CLPS711X) += clps711x.o obj-$(CONFIG_CLOCKSOURCE_MVEBU) += mvebu.o obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o +obj-$(CONFIG_CLOCKSOURCE_ORION) += orion.o diff --git a/drivers/clocksource/orion.c b/drivers/clocksource/orion.c new file mode 100644 index 0000000000..604b414742 --- /dev/null +++ b/drivers/clocksource/orion.c @@ -0,0 +1,76 @@ +/* + * Copyright + * (C) 2013 Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <common.h> +#include <init.h> +#include <clock.h> +#include <linux/clk.h> +#include <io.h> + +#define TIMER_CTRL 0x00 +#define TIMER0_EN BIT(0) +#define TIMER0_RELOAD_EN BIT(1) +#define TIMER1_EN BIT(2) +#define TIMER1_RELOAD_EN BIT(3) +#define TIMER0_RELOAD 0x10 +#define TIMER0_VAL 0x14 +#define TIMER1_RELOAD 0x18 +#define TIMER1_VAL 0x1c + +static __iomem void *timer_base; + +static uint64_t orion_clocksource_read(void) +{ + return __raw_readl(timer_base + TIMER0_VAL); +} + +static struct clocksource clksrc = { + .read = orion_clocksource_read, + .mask = CLOCKSOURCE_MASK(32), + .shift = 10, +}; + +static int orion_timer_probe(struct device_d *dev) +{ + struct clk *tclk; + uint32_t val; + + timer_base = dev_request_mem_region(dev, 0); + tclk = clk_get(dev, "tclk"); + + /* setup TIMER0 as free-running clock source */ + __raw_writel(~0, timer_base + TIMER0_VAL); + __raw_writel(~0, timer_base + TIMER0_RELOAD); + val = __raw_readl(timer_base + TIMER_CTRL); + __raw_writel(val | TIMER0_EN | TIMER0_RELOAD_EN, + timer_base + TIMER_CTRL); + + clksrc.mult = clocksource_hz2mult(clk_get_rate(tclk), clksrc.shift); + init_clock(&clksrc); + + return 0; +} + +static struct driver_d orion_timer_driver = { + .name = "orion-timer", + .probe = orion_timer_probe, +}; + +static int orion_timer_init(void) +{ + return platform_driver_register(&orion_timer_driver); +} +postcore_initcall(orion_timer_init); |