diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-12-28 20:16:03 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-07 18:33:19 +0100 |
commit | 22b1b8fff71757f3d8f07d0c2e2c225c52c01d8c (patch) | |
tree | ac7e2fd5f867323e4c0b4f93fcdad33a90f84fc3 /arch/arm/mach-at91/at91sam926x_time.c | |
parent | 7200ef1dbad412f81acf16a29501272ccbe989a8 (diff) | |
download | barebox-22b1b8fff71757f3d8f07d0c2e2c225c52c01d8c.tar.gz barebox-22b1b8fff71757f3d8f07d0c2e2c225c52c01d8c.tar.xz |
at91: enable clock via clock framework
fix at91sam926x timer and dss11
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-at91/at91sam926x_time.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam926x_time.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c index 7425e0a107..e854dc3b38 100644 --- a/arch/arm/mach-at91/at91sam926x_time.c +++ b/arch/arm/mach-at91/at91sam926x_time.c @@ -30,11 +30,11 @@ #include <clock.h> #include <asm/hardware.h> #include <mach/at91_pit.h> -#include <mach/at91_pmc.h> #include <mach/at91_rstc.h> #include <mach/io.h> #include <io.h> #include <linux/clk.h> +#include <linux/err.h> uint64_t at91sam9_clocksource_read(void) { @@ -49,15 +49,25 @@ static struct clocksource cs = { static int clocksource_init (void) { + struct clk *clk; u32 pit_rate; + int ret; - /* - * Enable PITC Clock - * The clock is already enabled for system controller in boot - */ - at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS); + clk = clk_get(NULL, "mck"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + pr_err("clock not found: %d\n", ret); + return ret; + } - pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16; + ret = clk_enable(clk); + if (ret < 0) { + pr_err("clock failed to enable: %d\n", ret); + clk_put(clk); + return ret; + } + + pit_rate = clk_get_rate(clk) / 16; /* Enable PITC */ at91_sys_write(AT91_PIT_MR, 0xfffff | AT91_PIT_PITEN); |