diff options
author | Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> | 2012-08-21 13:14:46 +0900 |
---|---|---|
committer | Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> | 2012-08-21 15:00:33 +0900 |
commit | 73f35e0b156c771333d449ca86b99600d094d37f (patch) | |
tree | c6a12e577144fc1d888684730774910147346e7e /arch/sh/lib/time.c | |
parent | e66443fdb5355e68cfdbbdd37248c4b7eb4968f5 (diff) |
sh: tmu: Changed TMU driver using array of structures
This changed into access using array of structure from access to the register
using the definition of the register by macro.
And removed white space.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Diffstat (limited to 'arch/sh/lib/time.c')
-rw-r--r-- | arch/sh/lib/time.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index a01596cace..48404727c3 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -2,7 +2,7 @@ * (C) Copyright 2009 * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> * - * (C) Copyright 2007-2010 + * (C) Copyright 2007-2012 * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org> * * (C) Copyright 2003 @@ -32,6 +32,9 @@ #include <asm/processor.h> #include <asm/clk.h> #include <asm/io.h> +#include <sh_tmu.h> + +static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE; #define TMU_MAX_COUNTER (~0UL) @@ -55,21 +58,21 @@ static inline unsigned long long usec_to_tick(unsigned long long usec) return usec; } -static void tmu_timer_start (unsigned int timer) +static void tmu_timer_start(unsigned int timer) { if (timer > 2) return; - writeb(readb(TSTR) | (1 << timer), TSTR); + writeb(readb(&tmu->tstr) | (1 << timer), &tmu->tstr); } -static void tmu_timer_stop (unsigned int timer) +static void tmu_timer_stop(unsigned int timer) { if (timer > 2) return; - writeb(readb(TSTR) & ~(1 << timer), TSTR); + writeb(readb(&tmu->tstr) & ~(1 << timer), &tmu->tstr); } -int timer_init (void) +int timer_init(void) { /* Divide clock by CONFIG_SYS_TMU_CLK_DIV */ u16 bit = 0; @@ -91,7 +94,7 @@ int timer_init (void) default: break; } - writew(readw(TCR0) | bit, TCR0); + writew(readw(&tmu->tcr0) | bit, &tmu->tcr0); /* Calc clock rate */ timer_freq = get_tmu0_clk_rate() >> ((bit + 1) * 2); @@ -105,9 +108,9 @@ int timer_init (void) return 0; } -unsigned long long get_ticks (void) +unsigned long long get_ticks(void) { - unsigned long tcnt = 0 - readl(TCNT0); + unsigned long tcnt = 0 - readl(&tmu->tcnt0); if (last_tcnt > tcnt) /* overflow */ overflow_ticks++; @@ -116,7 +119,7 @@ unsigned long long get_ticks (void) return (overflow_ticks << 32) | tcnt; } -void __udelay (unsigned long usec) +void __udelay(unsigned long usec) { unsigned long long tmp; ulong tmo; @@ -128,13 +131,13 @@ void __udelay (unsigned long usec) /*NOP*/; } -unsigned long get_timer (unsigned long base) +unsigned long get_timer(unsigned long base) { /* return msec */ return tick_to_time(get_ticks()) - base; } -unsigned long get_tbclk (void) +unsigned long get_tbclk(void) { return timer_freq; } |