diff options
Diffstat (limited to 'arch/arm/plat-mxc/time.c')
-rw-r--r-- | arch/arm/plat-mxc/time.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c index 2237ff8b434f..4b0fe285e83c 100644 --- a/arch/arm/plat-mxc/time.c +++ b/arch/arm/plat-mxc/time.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #define MX2_TSTAT_CAPT (1 << 1) | 54 | #define MX2_TSTAT_CAPT (1 << 1) |
55 | #define MX2_TSTAT_COMP (1 << 0) | 55 | #define MX2_TSTAT_COMP (1 << 0) |
56 | 56 | ||
57 | /* MX31, MX35, MX25, MXC91231, MX5 */ | 57 | /* MX31, MX35, MX25, MX5 */ |
58 | #define V2_TCTL_WAITEN (1 << 3) /* Wait enable mode */ | 58 | #define V2_TCTL_WAITEN (1 << 3) /* Wait enable mode */ |
59 | #define V2_TCTL_CLK_IPG (1 << 6) | 59 | #define V2_TCTL_CLK_IPG (1 << 6) |
60 | #define V2_TCTL_FRR (1 << 9) | 60 | #define V2_TCTL_FRR (1 << 9) |
@@ -106,56 +106,32 @@ static void gpt_irq_acknowledge(void) | |||
106 | __raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT); | 106 | __raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT); |
107 | } | 107 | } |
108 | 108 | ||
109 | static cycle_t dummy_get_cycles(struct clocksource *cs) | 109 | static void __iomem *sched_clock_reg; |
110 | { | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static cycle_t mx1_2_get_cycles(struct clocksource *cs) | ||
115 | { | ||
116 | return __raw_readl(timer_base + MX1_2_TCN); | ||
117 | } | ||
118 | |||
119 | static cycle_t v2_get_cycles(struct clocksource *cs) | ||
120 | { | ||
121 | return __raw_readl(timer_base + V2_TCN); | ||
122 | } | ||
123 | |||
124 | static struct clocksource clocksource_mxc = { | ||
125 | .name = "mxc_timer1", | ||
126 | .rating = 200, | ||
127 | .read = dummy_get_cycles, | ||
128 | .mask = CLOCKSOURCE_MASK(32), | ||
129 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
130 | }; | ||
131 | 110 | ||
132 | static DEFINE_CLOCK_DATA(cd); | 111 | static DEFINE_CLOCK_DATA(cd); |
133 | unsigned long long notrace sched_clock(void) | 112 | unsigned long long notrace sched_clock(void) |
134 | { | 113 | { |
135 | cycle_t cyc = clocksource_mxc.read(&clocksource_mxc); | 114 | cycle_t cyc = sched_clock_reg ? __raw_readl(sched_clock_reg) : 0; |
136 | 115 | ||
137 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); | 116 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); |
138 | } | 117 | } |
139 | 118 | ||
140 | static void notrace mxc_update_sched_clock(void) | 119 | static void notrace mxc_update_sched_clock(void) |
141 | { | 120 | { |
142 | cycle_t cyc = clocksource_mxc.read(&clocksource_mxc); | 121 | cycle_t cyc = sched_clock_reg ? __raw_readl(sched_clock_reg) : 0; |
143 | update_sched_clock(&cd, cyc, (u32)~0); | 122 | update_sched_clock(&cd, cyc, (u32)~0); |
144 | } | 123 | } |
145 | 124 | ||
146 | static int __init mxc_clocksource_init(struct clk *timer_clk) | 125 | static int __init mxc_clocksource_init(struct clk *timer_clk) |
147 | { | 126 | { |
148 | unsigned int c = clk_get_rate(timer_clk); | 127 | unsigned int c = clk_get_rate(timer_clk); |
128 | void __iomem *reg = timer_base + (timer_is_v2() ? V2_TCN : MX1_2_TCN); | ||
149 | 129 | ||
150 | if (timer_is_v2()) | 130 | sched_clock_reg = reg; |
151 | clocksource_mxc.read = v2_get_cycles; | ||
152 | else | ||
153 | clocksource_mxc.read = mx1_2_get_cycles; | ||
154 | 131 | ||
155 | init_sched_clock(&cd, mxc_update_sched_clock, 32, c); | 132 | init_sched_clock(&cd, mxc_update_sched_clock, 32, c); |
156 | clocksource_register_hz(&clocksource_mxc, c); | 133 | return clocksource_mmio_init(reg, "mxc_timer1", c, 200, 32, |
157 | 134 | clocksource_mmio_readl_up); | |
158 | return 0; | ||
159 | } | 135 | } |
160 | 136 | ||
161 | /* clock event */ | 137 | /* clock event */ |