aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-06-15 16:54:46 -0400
committerMike Frysinger <vapier@gentoo.org>2011-07-23 01:18:21 -0400
commit997f95e1908d1b1e750a3a0695d31dbefd0c6c19 (patch)
tree486681de0f6532dcf1154c1a148bf54450c7da57 /arch/blackfin/kernel
parent24a6b91f69047072b3708248d0612ddef825dab7 (diff)
Blackfin: gptimers: use bfin read/write helpers
Use proper helper macros for reading/writing the MMRs rather than volatile markings on the struct. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r--arch/blackfin/kernel/gptimers.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/arch/blackfin/kernel/gptimers.c b/arch/blackfin/kernel/gptimers.c
index 64ef2ebbc22f..06459f4bf43a 100644
--- a/arch/blackfin/kernel/gptimers.c
+++ b/arch/blackfin/kernel/gptimers.c
@@ -124,7 +124,7 @@ static uint32_t const timil_mask[MAX_BLACKFIN_GPTIMERS] =
124void set_gptimer_pwidth(unsigned int timer_id, uint32_t value) 124void set_gptimer_pwidth(unsigned int timer_id, uint32_t value)
125{ 125{
126 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 126 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
127 timer_regs[timer_id]->width = value; 127 bfin_write(&timer_regs[timer_id]->width, value);
128 SSYNC(); 128 SSYNC();
129} 129}
130EXPORT_SYMBOL(set_gptimer_pwidth); 130EXPORT_SYMBOL(set_gptimer_pwidth);
@@ -132,14 +132,14 @@ EXPORT_SYMBOL(set_gptimer_pwidth);
132uint32_t get_gptimer_pwidth(unsigned int timer_id) 132uint32_t get_gptimer_pwidth(unsigned int timer_id)
133{ 133{
134 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 134 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
135 return timer_regs[timer_id]->width; 135 return bfin_read(&timer_regs[timer_id]->width);
136} 136}
137EXPORT_SYMBOL(get_gptimer_pwidth); 137EXPORT_SYMBOL(get_gptimer_pwidth);
138 138
139void set_gptimer_period(unsigned int timer_id, uint32_t period) 139void set_gptimer_period(unsigned int timer_id, uint32_t period)
140{ 140{
141 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 141 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
142 timer_regs[timer_id]->period = period; 142 bfin_write(&timer_regs[timer_id]->period, period);
143 SSYNC(); 143 SSYNC();
144} 144}
145EXPORT_SYMBOL(set_gptimer_period); 145EXPORT_SYMBOL(set_gptimer_period);
@@ -147,71 +147,76 @@ EXPORT_SYMBOL(set_gptimer_period);
147uint32_t get_gptimer_period(unsigned int timer_id) 147uint32_t get_gptimer_period(unsigned int timer_id)
148{ 148{
149 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 149 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
150 return timer_regs[timer_id]->period; 150 return bfin_read(&timer_regs[timer_id]->period);
151} 151}
152EXPORT_SYMBOL(get_gptimer_period); 152EXPORT_SYMBOL(get_gptimer_period);
153 153
154uint32_t get_gptimer_count(unsigned int timer_id) 154uint32_t get_gptimer_count(unsigned int timer_id)
155{ 155{
156 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 156 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
157 return timer_regs[timer_id]->counter; 157 return bfin_read(&timer_regs[timer_id]->counter);
158} 158}
159EXPORT_SYMBOL(get_gptimer_count); 159EXPORT_SYMBOL(get_gptimer_count);
160 160
161uint32_t get_gptimer_status(unsigned int group) 161uint32_t get_gptimer_status(unsigned int group)
162{ 162{
163 tassert(group < BFIN_TIMER_NUM_GROUP); 163 tassert(group < BFIN_TIMER_NUM_GROUP);
164 return group_regs[group]->status; 164 return bfin_read(&group_regs[group]->status);
165} 165}
166EXPORT_SYMBOL(get_gptimer_status); 166EXPORT_SYMBOL(get_gptimer_status);
167 167
168void set_gptimer_status(unsigned int group, uint32_t value) 168void set_gptimer_status(unsigned int group, uint32_t value)
169{ 169{
170 tassert(group < BFIN_TIMER_NUM_GROUP); 170 tassert(group < BFIN_TIMER_NUM_GROUP);
171 group_regs[group]->status = value; 171 bfin_write(&group_regs[group]->status, value);
172 SSYNC(); 172 SSYNC();
173} 173}
174EXPORT_SYMBOL(set_gptimer_status); 174EXPORT_SYMBOL(set_gptimer_status);
175 175
176static uint32_t read_gptimer_status(unsigned int timer_id)
177{
178 return bfin_read(&group_regs[BFIN_TIMER_OCTET(timer_id)]->status);
179}
180
176int get_gptimer_intr(unsigned int timer_id) 181int get_gptimer_intr(unsigned int timer_id)
177{ 182{
178 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 183 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
179 return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]); 184 return !!(read_gptimer_status(timer_id) & timil_mask[timer_id]);
180} 185}
181EXPORT_SYMBOL(get_gptimer_intr); 186EXPORT_SYMBOL(get_gptimer_intr);
182 187
183void clear_gptimer_intr(unsigned int timer_id) 188void clear_gptimer_intr(unsigned int timer_id)
184{ 189{
185 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 190 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
186 group_regs[BFIN_TIMER_OCTET(timer_id)]->status = timil_mask[timer_id]; 191 bfin_write(&group_regs[BFIN_TIMER_OCTET(timer_id)]->status, timil_mask[timer_id]);
187} 192}
188EXPORT_SYMBOL(clear_gptimer_intr); 193EXPORT_SYMBOL(clear_gptimer_intr);
189 194
190int get_gptimer_over(unsigned int timer_id) 195int get_gptimer_over(unsigned int timer_id)
191{ 196{
192 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 197 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
193 return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]); 198 return !!(read_gptimer_status(timer_id) & tovf_mask[timer_id]);
194} 199}
195EXPORT_SYMBOL(get_gptimer_over); 200EXPORT_SYMBOL(get_gptimer_over);
196 201
197void clear_gptimer_over(unsigned int timer_id) 202void clear_gptimer_over(unsigned int timer_id)
198{ 203{
199 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 204 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
200 group_regs[BFIN_TIMER_OCTET(timer_id)]->status = tovf_mask[timer_id]; 205 bfin_write(&group_regs[BFIN_TIMER_OCTET(timer_id)]->status, tovf_mask[timer_id]);
201} 206}
202EXPORT_SYMBOL(clear_gptimer_over); 207EXPORT_SYMBOL(clear_gptimer_over);
203 208
204int get_gptimer_run(unsigned int timer_id) 209int get_gptimer_run(unsigned int timer_id)
205{ 210{
206 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 211 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
207 return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & trun_mask[timer_id]); 212 return !!(read_gptimer_status(timer_id) & trun_mask[timer_id]);
208} 213}
209EXPORT_SYMBOL(get_gptimer_run); 214EXPORT_SYMBOL(get_gptimer_run);
210 215
211void set_gptimer_config(unsigned int timer_id, uint16_t config) 216void set_gptimer_config(unsigned int timer_id, uint16_t config)
212{ 217{
213 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 218 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
214 timer_regs[timer_id]->config = config; 219 bfin_write(&timer_regs[timer_id]->config, config);
215 SSYNC(); 220 SSYNC();
216} 221}
217EXPORT_SYMBOL(set_gptimer_config); 222EXPORT_SYMBOL(set_gptimer_config);
@@ -219,7 +224,7 @@ EXPORT_SYMBOL(set_gptimer_config);
219uint16_t get_gptimer_config(unsigned int timer_id) 224uint16_t get_gptimer_config(unsigned int timer_id)
220{ 225{
221 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 226 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
222 return timer_regs[timer_id]->config; 227 return bfin_read(&timer_regs[timer_id]->config);
223} 228}
224EXPORT_SYMBOL(get_gptimer_config); 229EXPORT_SYMBOL(get_gptimer_config);
225 230
@@ -228,7 +233,7 @@ void enable_gptimers(uint16_t mask)
228 int i; 233 int i;
229 tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0); 234 tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0);
230 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) { 235 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) {
231 group_regs[i]->enable = mask & 0xFF; 236 bfin_write(&group_regs[i]->enable, mask & 0xFF);
232 mask >>= 8; 237 mask >>= 8;
233 } 238 }
234 SSYNC(); 239 SSYNC();
@@ -241,7 +246,7 @@ static void _disable_gptimers(uint16_t mask)
241 uint16_t m = mask; 246 uint16_t m = mask;
242 tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0); 247 tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0);
243 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) { 248 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) {
244 group_regs[i]->disable = m & 0xFF; 249 bfin_write(&group_regs[i]->disable, m & 0xFF);
245 m >>= 8; 250 m >>= 8;
246 } 251 }
247} 252}
@@ -252,7 +257,7 @@ void disable_gptimers(uint16_t mask)
252 _disable_gptimers(mask); 257 _disable_gptimers(mask);
253 for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i) 258 for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i)
254 if (mask & (1 << i)) 259 if (mask & (1 << i))
255 group_regs[BFIN_TIMER_OCTET(i)]->status = trun_mask[i]; 260 bfin_write(&group_regs[BFIN_TIMER_OCTET(i)]->status, trun_mask[i]);
256 SSYNC(); 261 SSYNC();
257} 262}
258EXPORT_SYMBOL(disable_gptimers); 263EXPORT_SYMBOL(disable_gptimers);
@@ -267,7 +272,7 @@ EXPORT_SYMBOL(disable_gptimers_sync);
267void set_gptimer_pulse_hi(unsigned int timer_id) 272void set_gptimer_pulse_hi(unsigned int timer_id)
268{ 273{
269 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 274 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
270 timer_regs[timer_id]->config |= TIMER_PULSE_HI; 275 bfin_write_or(&timer_regs[timer_id]->config, TIMER_PULSE_HI);
271 SSYNC(); 276 SSYNC();
272} 277}
273EXPORT_SYMBOL(set_gptimer_pulse_hi); 278EXPORT_SYMBOL(set_gptimer_pulse_hi);
@@ -275,7 +280,7 @@ EXPORT_SYMBOL(set_gptimer_pulse_hi);
275void clear_gptimer_pulse_hi(unsigned int timer_id) 280void clear_gptimer_pulse_hi(unsigned int timer_id)
276{ 281{
277 tassert(timer_id < MAX_BLACKFIN_GPTIMERS); 282 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
278 timer_regs[timer_id]->config &= ~TIMER_PULSE_HI; 283 bfin_write_and(&timer_regs[timer_id]->config, ~TIMER_PULSE_HI);
279 SSYNC(); 284 SSYNC();
280} 285}
281EXPORT_SYMBOL(clear_gptimer_pulse_hi); 286EXPORT_SYMBOL(clear_gptimer_pulse_hi);
@@ -285,7 +290,7 @@ uint16_t get_enabled_gptimers(void)
285 int i; 290 int i;
286 uint16_t result = 0; 291 uint16_t result = 0;
287 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) 292 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i)
288 result |= (group_regs[i]->enable << (i << 3)); 293 result |= (bfin_read(&group_regs[i]->enable) << (i << 3));
289 return result; 294 return result;
290} 295}
291EXPORT_SYMBOL(get_enabled_gptimers); 296EXPORT_SYMBOL(get_enabled_gptimers);