Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | /* * linux/arch/arm/mach-sa1100/sa1111.c * * SA1111 support * * Original code by John Dorsey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This file contains all generic SA1111 support, except for DMA which is * provided separately in dma-sa1111.c. * * All initialization functions provided here are intended to be called * from machine specific code with proper arguments when required. */ #include <linux/init.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/sched.h> #include <linux/interrupt.h> #include <linux/ptrace.h> #include <linux/errno.h> #include <linux/pci.h> #include <linux/mm.h> #include <asm/hardware.h> #include <asm/irq.h> #include <asm/mach/irq.h> #include <asm/arch/irq.h> #include "sa1111.h" static int sa1111_ohci_hcd_init(void); /* * SA1111 initialization */ int __init sa1111_init(void) { unsigned long id = SKID; if((id & SKID_ID_MASK) == SKID_SA1111_ID) printk( KERN_INFO "SA-1111 Microprocessor Companion Chip: " "silicon revision %lx, metal revision %lx\n", (id & SKID_SIREV_MASK)>>4, (id & SKID_MTREV_MASK)); else { printk(KERN_ERR "Could not detect SA-1111!\n"); return -EINVAL; } /* * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111: * (SA-1110 Developer's Manual, section 9.1.2.1) */ GAFR |= GPIO_32_768kHz; GPDR |= GPIO_32_768kHz; TUCR = TUCR_3_6864MHz; /* Now, set up the PLL and RCLK in the SA-1111: */ SKCR = SKCR_PLL_BYPASS | SKCR_RDYEN | SKCR_OE_EN; udelay(100); SKCR = SKCR_PLL_BYPASS | SKCR_RCLKEN | SKCR_RDYEN | SKCR_OE_EN; /* * SA-1111 Register Access Bus should now be available. Clocks for * any other SA-1111 functional blocks must be enabled separately * using the SKPCR. */ /* * If the system is going to use the SA-1111 DMA engines, set up * the memory bus request/grant pins. Also configure the shared * memory controller on the SA-1111 (SA-1111 Developer's Manual, * section 3.2.3) and power up the DMA bus clock: */ GAFR |= (GPIO_MBGNT | GPIO_MBREQ); GPDR |= GPIO_MBGNT; GPDR &= ~GPIO_MBREQ; TUCR |= TUCR_MR; #ifdef CONFIG_USB_OHCI /* setup up sa1111 usb host controller h/w */ sa1111_ohci_hcd_init(); #endif return 0; } /* * SA1111 Interrupt support */ void sa1111_IRQ_demux( int irq, void *dev_id, struct pt_regs *regs ) { int i; unsigned long stat0, stat1; for(;;) { stat0 = INTSTATCLR0, stat1 = INTSTATCLR1; if( !stat0 && !stat1 ) break; if( stat0 ) for( i = 0; i < 32; i++ ) if( stat0 & (1<<i) ) do_IRQ( SA1111_IRQ(i), regs ); if( stat1 ) for( i = 32; i < 55; i++ ) if( stat1 & (1<<(i-32)) ) do_IRQ( SA1111_IRQ(i), regs ); } } static struct irqaction sa1111_irq = { name: "SA1111", handler: sa1111_IRQ_demux, flags: SA_INTERRUPT }; static void sa1111_mask_and_ack_lowirq(unsigned int irq) { unsigned int mask = 1 << (irq - SA1111_IRQ(0)); // broken hardware: interrupt events are lost if they occur // while the interrupts are disabled. //INTEN0 &= ~mask; INTSTATCLR0 = mask; } static void sa1111_mask_and_ack_highirq(unsigned int irq) { unsigned int mask = 1 << (irq - SA1111_IRQ(32)); //INTEN1 &= ~mask; INTSTATCLR1 = mask; } static void sa1111_mask_lowirq(unsigned int irq) { //INTEN0 &= ~(1 << (irq - SA1111_IRQ(0))); } static void sa1111_mask_highirq(unsigned int irq) { //INTEN1 &= ~(1 << (irq - SA1111_IRQ(32))); } static void sa1111_unmask_lowirq(unsigned int irq) { INTEN0 |= 1 << (irq - SA1111_IRQ(0)); } static void sa1111_unmask_highirq(unsigned int irq) { INTEN1 |= 1 << ((irq - SA1111_IRQ(32))); } void __init sa1111_init_irq(int gpio_nr) { int irq; /* disable all IRQs */ INTEN0 = 0; INTEN1 = 0; /* * detect on rising edge. Note: Feb 2001 Errata for SA1111 * specifies that S0ReadyInt and S1ReadyInt should be '1'. */ INTPOL0 = 0; INTPOL1 = 1 << (S0_READY_NINT - SA1111_IRQ(32)) | 1 << (S1_READY_NINT - SA1111_IRQ(32)); /* clear all IRQs */ INTSTATCLR0 = -1; INTSTATCLR1 = -1; for (irq = SA1111_IRQ(0); irq <= SA1111_IRQ(26); irq++) { irq_desc[irq].valid = 1; irq_desc[irq].probe_ok = 1; irq_desc[irq].mask_ack = sa1111_mask_and_ack_lowirq; irq_desc[irq].mask = sa1111_mask_lowirq; irq_desc[irq].unmask = sa1111_unmask_lowirq; } for (irq = SA1111_IRQ(32); irq <= SA1111_IRQ(54); irq++) { irq_desc[irq].valid = 1; irq_desc[irq].probe_ok = 1; irq_desc[irq].mask_ack = sa1111_mask_and_ack_highirq; irq_desc[irq].mask = sa1111_mask_highirq; irq_desc[irq].unmask = sa1111_unmask_highirq; } /* Not every machines has the SA1111 interrupt routed to a GPIO */ if (gpio_nr >= 0) { set_GPIO_IRQ_edge (GPIO_GPIO(gpio_nr), GPIO_RISING_EDGE); setup_arm_irq (SA1100_GPIO_TO_IRQ(gpio_nr), &sa1111_irq); } } /* ----------------- */ #ifdef CONFIG_USB_OHCI #if defined(CONFIG_SA1100_XP860) || defined(CONFIG_ASSABET_NEPONSET) || defined(CONFIG_SA1100_PFS168) #define PwrSensePolLow 1 #define PwrCtrlPolLow 1 #else #define PwrSensePolLow 0 #define PwrCtrlPolLow 0 #endif /* * The SA-1111 errata says that the DMA hardware needs to be exercised * before the clocks are turned on to work properly. This code does * a tiny dma transfer to prime to hardware. */ static void __init sa1111_dma_setup(void) { dma_addr_t vbuf; void * pbuf; /* DMA init & setup */ /* WARNING: The SA-1111 L3 function is used as part of this * SA-1111 DMA errata workaround. * * N.B., When the L3 function is enabled, it uses GPIO_B<4:5> * and takes precedence over the PS/2 mouse and GPIO_B * functions. Refer to "Intel StrongARM SA-1111 Microprocessor * Companion Chip, Sect 10.2" for details. So this "fix" may * "break" support of either PS/2 mouse or GPIO_B if * precautions are not taken to avoid collisions in * configuration and use of these pins. AFAIK, no precautions * are taken at this time. So it is likely that the action * taken here may cause problems in PS/2 mouse and/or GPIO_B * pin use elsewhere. * * But wait, there's more... What we're doing here is * obviously altogether a bad idea. We're indiscrimanately bit * flipping config for a few different functions here which * are "owned" by other drivers. This needs to be handled * better than it is being done here at this time. */ /* prime the dma engine with a tiny dma */ SKPCR |= SKPCR_I2SCLKEN; SKAUD |= SKPCR_L3CLKEN | SKPCR_SCLKEN; SACR0 |= 0x00003305; SACR1 = 0x00000000; /* we need memory below 1mb */ pbuf = consistent_alloc(GFP_KERNEL | GFP_DMA, 4, &vbuf); SADTSA = (unsigned long)pbuf; SADTCA = 4; SADTCS |= 0x00000011; SKPCR |= SKPCR_DCLKEN; /* wait */ udelay(100); SACR0 &= ~(0x00000002); SACR0 &= ~(0x00000001); /* */ SACR0 |= 0x00000004; SACR0 &= ~(0x00000004); SKAUD &= ~(SKPCR_L3CLKEN | SKPCR_SCLKEN); SKPCR &= ~SKPCR_I2SCLKEN; consistent_free(pbuf, 4, vbuf); } #ifdef CONFIG_USB_OHCI /* * reset the SA-1111 usb controller and turn on it's clocks */ static int __init sa1111_ohci_hcd_init(void) { volatile unsigned long *Reset = (void *)SA1111_p2v(_SA1111(0x051c)); volatile unsigned long *Status = (void *)SA1111_p2v(_SA1111(0x0518)); /* turn on clocks */ SKPCR |= SKPCR_UCLKEN; udelay(100); /* force a reset */ *Reset = 0x01; *Reset |= 0x02; udelay(100); *Reset = 0; /* take out of reset */ /* set power sense and control lines (this from the diags code) */ *Reset = ( PwrSensePolLow << 6 ) | ( PwrCtrlPolLow << 7 ); *Status = 0; udelay(10); /* compensate for dma bug */ sa1111_dma_setup(); return 0; } void sa1111_ohci_hcd_cleanup(void) { /* turn the USB clock off */ SKPCR &= ~SKPCR_UCLKEN; } #endif #endif /* CONFIG_USB_OHCI */ |