diff options
Diffstat (limited to 'arch/arm/plat-iop')
-rw-r--r-- | arch/arm/plat-iop/time.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/arch/arm/plat-iop/time.c b/arch/arm/plat-iop/time.c index 558cdfaf76b6..07f23bb42bed 100644 --- a/arch/arm/plat-iop/time.c +++ b/arch/arm/plat-iop/time.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/time.h> | 18 | #include <linux/time.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/sched.h> | ||
20 | #include <linux/timex.h> | 21 | #include <linux/timex.h> |
21 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
22 | #include <linux/io.h> | 23 | #include <linux/io.h> |
@@ -24,6 +25,7 @@ | |||
24 | #include <linux/clockchips.h> | 25 | #include <linux/clockchips.h> |
25 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
26 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
28 | #include <asm/sched_clock.h> | ||
27 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
28 | #include <asm/mach/irq.h> | 30 | #include <asm/mach/irq.h> |
29 | #include <asm/mach/time.h> | 31 | #include <asm/mach/time.h> |
@@ -50,15 +52,21 @@ static struct clocksource iop_clocksource = { | |||
50 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 52 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
51 | }; | 53 | }; |
52 | 54 | ||
55 | static DEFINE_CLOCK_DATA(cd); | ||
56 | |||
53 | /* | 57 | /* |
54 | * IOP sched_clock() implementation via its clocksource. | 58 | * IOP sched_clock() implementation via its clocksource. |
55 | */ | 59 | */ |
56 | unsigned long long sched_clock(void) | 60 | unsigned long long notrace sched_clock(void) |
57 | { | 61 | { |
58 | cycle_t cyc = iop_clocksource_read(NULL); | 62 | u32 cyc = 0xffffffffu - read_tcr1(); |
59 | struct clocksource *cs = &iop_clocksource; | 63 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); |
64 | } | ||
60 | 65 | ||
61 | return clocksource_cyc2ns(cyc, cs->mult, cs->shift); | 66 | static void notrace iop_update_sched_clock(void) |
67 | { | ||
68 | u32 cyc = 0xffffffffu - read_tcr1(); | ||
69 | update_sched_clock(&cd, cyc, (u32)~0); | ||
62 | } | 70 | } |
63 | 71 | ||
64 | /* | 72 | /* |
@@ -88,6 +96,7 @@ static void iop_set_mode(enum clock_event_mode mode, | |||
88 | case CLOCK_EVT_MODE_PERIODIC: | 96 | case CLOCK_EVT_MODE_PERIODIC: |
89 | write_tmr0(tmr & ~IOP_TMR_EN); | 97 | write_tmr0(tmr & ~IOP_TMR_EN); |
90 | write_tcr0(ticks_per_jiffy - 1); | 98 | write_tcr0(ticks_per_jiffy - 1); |
99 | write_trr0(ticks_per_jiffy - 1); | ||
91 | tmr |= (IOP_TMR_RELOAD | IOP_TMR_EN); | 100 | tmr |= (IOP_TMR_RELOAD | IOP_TMR_EN); |
92 | break; | 101 | break; |
93 | case CLOCK_EVT_MODE_ONESHOT: | 102 | case CLOCK_EVT_MODE_ONESHOT: |
@@ -143,6 +152,8 @@ void __init iop_init_time(unsigned long tick_rate) | |||
143 | { | 152 | { |
144 | u32 timer_ctl; | 153 | u32 timer_ctl; |
145 | 154 | ||
155 | init_sched_clock(&cd, iop_update_sched_clock, 32, tick_rate); | ||
156 | |||
146 | ticks_per_jiffy = DIV_ROUND_CLOSEST(tick_rate, HZ); | 157 | ticks_per_jiffy = DIV_ROUND_CLOSEST(tick_rate, HZ); |
147 | iop_tick_rate = tick_rate; | 158 | iop_tick_rate = tick_rate; |
148 | 159 | ||
@@ -153,6 +164,7 @@ void __init iop_init_time(unsigned long tick_rate) | |||
153 | * Set up interrupting clockevent timer 0. | 164 | * Set up interrupting clockevent timer 0. |
154 | */ | 165 | */ |
155 | write_tmr0(timer_ctl & ~IOP_TMR_EN); | 166 | write_tmr0(timer_ctl & ~IOP_TMR_EN); |
167 | write_tisr(1); | ||
156 | setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq); | 168 | setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq); |
157 | clockevents_calc_mult_shift(&iop_clockevent, | 169 | clockevents_calc_mult_shift(&iop_clockevent, |
158 | tick_rate, IOP_MIN_RANGE); | 170 | tick_rate, IOP_MIN_RANGE); |
@@ -162,9 +174,6 @@ void __init iop_init_time(unsigned long tick_rate) | |||
162 | clockevent_delta2ns(0xf, &iop_clockevent); | 174 | clockevent_delta2ns(0xf, &iop_clockevent); |
163 | iop_clockevent.cpumask = cpumask_of(0); | 175 | iop_clockevent.cpumask = cpumask_of(0); |
164 | clockevents_register_device(&iop_clockevent); | 176 | clockevents_register_device(&iop_clockevent); |
165 | write_trr0(ticks_per_jiffy - 1); | ||
166 | write_tcr0(ticks_per_jiffy - 1); | ||
167 | write_tmr0(timer_ctl); | ||
168 | 177 | ||
169 | /* | 178 | /* |
170 | * Set up free-running clocksource timer 1. | 179 | * Set up free-running clocksource timer 1. |
@@ -172,7 +181,5 @@ void __init iop_init_time(unsigned long tick_rate) | |||
172 | write_trr1(0xffffffff); | 181 | write_trr1(0xffffffff); |
173 | write_tcr1(0xffffffff); | 182 | write_tcr1(0xffffffff); |
174 | write_tmr1(timer_ctl); | 183 | write_tmr1(timer_ctl); |
175 | clocksource_calc_mult_shift(&iop_clocksource, tick_rate, | 184 | clocksource_register_hz(&iop_clocksource, tick_rate); |
176 | IOP_MIN_RANGE); | ||
177 | clocksource_register(&iop_clocksource); | ||
178 | } | 185 | } |