diff options
author | Marcelo Tosatti <marcelo.tosatti@cyclades.com> | 2005-10-28 20:46:10 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-28 23:55:27 -0400 |
commit | e37b0c9670fed2264661ade1beb5c228dec29c96 (patch) | |
tree | 4f23bc5ea578db11de39222aa046804ed9286782 /arch/ppc/syslib/m8xx_setup.c | |
parent | 9e3699ea7b8d63eabde7fefa9892e3a258c9c27d (diff) |
[PATCH] ppc32 8xx: use io accessor macros instead of direct memory reference
Convert core 8xx drivers to use in_xxxbe/in_xxx macros instead of direct
memory references.
Other than making IO accesses explicit (which is a plus for readability), a
common set of macros provides a unified place for the volatile flag to
constraint compiler code reordering.
There are several unlucky places at the moment which lack the volatile
flag.
Signed-off-by: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc/syslib/m8xx_setup.c')
-rw-r--r-- | arch/ppc/syslib/m8xx_setup.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c index c88e2d4dceb7..a192719929d3 100644 --- a/arch/ppc/syslib/m8xx_setup.c +++ b/arch/ppc/syslib/m8xx_setup.c | |||
@@ -144,12 +144,12 @@ void __init m8xx_calibrate_decr(void) | |||
144 | int freq, fp, divisor; | 144 | int freq, fp, divisor; |
145 | 145 | ||
146 | /* Unlock the SCCR. */ | 146 | /* Unlock the SCCR. */ |
147 | ((volatile immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk = ~KAPWR_KEY; | 147 | out_be32(&((immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk, ~KAPWR_KEY); |
148 | ((volatile immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk = KAPWR_KEY; | 148 | out_be32(&((immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk, KAPWR_KEY); |
149 | 149 | ||
150 | /* Force all 8xx processors to use divide by 16 processor clock. */ | 150 | /* Force all 8xx processors to use divide by 16 processor clock. */ |
151 | ((volatile immap_t *)IMAP_ADDR)->im_clkrst.car_sccr |= 0x02000000; | 151 | out_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr, |
152 | 152 | in_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr)|0x02000000); | |
153 | /* Processor frequency is MHz. | 153 | /* Processor frequency is MHz. |
154 | * The value 'fp' is the number of decrementer ticks per second. | 154 | * The value 'fp' is the number of decrementer ticks per second. |
155 | */ | 155 | */ |
@@ -175,28 +175,24 @@ void __init m8xx_calibrate_decr(void) | |||
175 | * we guarantee the registers are locked, then we unlock them | 175 | * we guarantee the registers are locked, then we unlock them |
176 | * for our use. | 176 | * for our use. |
177 | */ | 177 | */ |
178 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk = ~KAPWR_KEY; | 178 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk, ~KAPWR_KEY); |
179 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck = ~KAPWR_KEY; | 179 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck, ~KAPWR_KEY); |
180 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk = ~KAPWR_KEY; | 180 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk, ~KAPWR_KEY); |
181 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk = KAPWR_KEY; | 181 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk, KAPWR_KEY); |
182 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck = KAPWR_KEY; | 182 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck, KAPWR_KEY); |
183 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk = KAPWR_KEY; | 183 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk, KAPWR_KEY); |
184 | 184 | ||
185 | /* Disable the RTC one second and alarm interrupts. */ | 185 | /* Disable the RTC one second and alarm interrupts. */ |
186 | ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc &= | 186 | out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, in_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc) & ~(RTCSC_SIE | RTCSC_ALE)); |
187 | ~(RTCSC_SIE | RTCSC_ALE); | ||
188 | /* Enable the RTC */ | 187 | /* Enable the RTC */ |
189 | ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc |= | 188 | out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, in_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc) | (RTCSC_RTF | RTCSC_RTE)); |
190 | (RTCSC_RTF | RTCSC_RTE); | ||
191 | 189 | ||
192 | /* Enabling the decrementer also enables the timebase interrupts | 190 | /* Enabling the decrementer also enables the timebase interrupts |
193 | * (or from the other point of view, to get decrementer interrupts | 191 | * (or from the other point of view, to get decrementer interrupts |
194 | * we have to enable the timebase). The decrementer interrupt | 192 | * we have to enable the timebase). The decrementer interrupt |
195 | * is wired into the vector table, nothing to do here for that. | 193 | * is wired into the vector table, nothing to do here for that. |
196 | */ | 194 | */ |
197 | ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_tbscr = | 195 | out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_tbscr, (mk_int_int_mask(DEC_INTERRUPT) << 8) | (TBSCR_TBF | TBSCR_TBE)); |
198 | ((mk_int_int_mask(DEC_INTERRUPT) << 8) | | ||
199 | (TBSCR_TBF | TBSCR_TBE)); | ||
200 | 196 | ||
201 | if (setup_irq(DEC_INTERRUPT, &tbint_irqaction)) | 197 | if (setup_irq(DEC_INTERRUPT, &tbint_irqaction)) |
202 | panic("Could not allocate timer IRQ!"); | 198 | panic("Could not allocate timer IRQ!"); |
@@ -216,9 +212,9 @@ void __init m8xx_calibrate_decr(void) | |||
216 | static int | 212 | static int |
217 | m8xx_set_rtc_time(unsigned long time) | 213 | m8xx_set_rtc_time(unsigned long time) |
218 | { | 214 | { |
219 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = KAPWR_KEY; | 215 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck, KAPWR_KEY); |
220 | ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtc = time; | 216 | out_be32(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtc, time); |
221 | ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = ~KAPWR_KEY; | 217 | out_be32(&((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck, ~KAPWR_KEY); |
222 | return(0); | 218 | return(0); |
223 | } | 219 | } |
224 | 220 | ||
@@ -226,7 +222,7 @@ static unsigned long | |||
226 | m8xx_get_rtc_time(void) | 222 | m8xx_get_rtc_time(void) |
227 | { | 223 | { |
228 | /* Get time from the RTC. */ | 224 | /* Get time from the RTC. */ |
229 | return((unsigned long)(((immap_t *)IMAP_ADDR)->im_sit.sit_rtc)); | 225 | return (unsigned long) in_be32(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtc); |
230 | } | 226 | } |
231 | 227 | ||
232 | static void | 228 | static void |
@@ -235,13 +231,13 @@ m8xx_restart(char *cmd) | |||
235 | __volatile__ unsigned char dummy; | 231 | __volatile__ unsigned char dummy; |
236 | 232 | ||
237 | local_irq_disable(); | 233 | local_irq_disable(); |
238 | ((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr |= 0x00000080; | 234 | out_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr, in_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr) | 0x00000080); |
239 | 235 | ||
240 | /* Clear the ME bit in MSR to cause checkstop on machine check | 236 | /* Clear the ME bit in MSR to cause checkstop on machine check |
241 | */ | 237 | */ |
242 | mtmsr(mfmsr() & ~0x1000); | 238 | mtmsr(mfmsr() & ~0x1000); |
243 | 239 | ||
244 | dummy = ((immap_t *)IMAP_ADDR)->im_clkrst.res[0]; | 240 | dummy = in_8(&((immap_t *)IMAP_ADDR)->im_clkrst.res[0]); |
245 | printk("Restart failed\n"); | 241 | printk("Restart failed\n"); |
246 | while(1); | 242 | while(1); |
247 | } | 243 | } |
@@ -306,8 +302,7 @@ m8xx_init_IRQ(void) | |||
306 | i8259_init(0); | 302 | i8259_init(0); |
307 | 303 | ||
308 | /* The i8259 cascade interrupt must be level sensitive. */ | 304 | /* The i8259 cascade interrupt must be level sensitive. */ |
309 | ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel &= | 305 | out_be32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel, in_be32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel & ~(0x80000000 >> ISA_BRIDGE_INT))); |
310 | ~(0x80000000 >> ISA_BRIDGE_INT); | ||
311 | 306 | ||
312 | if (setup_irq(ISA_BRIDGE_INT, &mbx_i8259_irqaction)) | 307 | if (setup_irq(ISA_BRIDGE_INT, &mbx_i8259_irqaction)) |
313 | enable_irq(ISA_BRIDGE_INT); | 308 | enable_irq(ISA_BRIDGE_INT); |