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 | /* * linux/arch/arm/mach-sa1100/graphicsmaster.c * * Pieces specific to the GraphicsMaster board * * 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. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/ptrace.h> #include <linux/ioport.h> #include <asm/hardware.h> #include <asm/mach-types.h> #include <asm/setup.h> #include <asm/irq.h> #include <asm/mach/irq.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/mach/serial_sa1100.h> #include "generic.h" static struct resource sa1111_resources[] = { [0] = { .start = 0x18000000, .end = 0x18001fff, .flags = IORESOURCE_MEM, }, [1] = { .start = ADS_EXT_IRQ(0), .end = ADS_EXT_IRQ(0), .flags = IORESOURCE_IRQ, }, }; static u64 sa1111_dmamask = 0xffffffffUL; static struct platform_device sa1111_device = { .name = "sa1111", .id = 0, .dev = { .dma_mask = &sa1111_dmamask, }, .num_resources = ARRAY_SIZE(sa1111_resources), .resource = sa1111_resources, }; static struct platform_device *devices[] __initdata = { &sa1111_device, }; static int __init graphicsmaster_init(void) { int ret; if (!machine_is_graphicsmaster()) return -ENODEV; /* * Ensure that the memory bus request/grant signals are setup, * and the grant is held in its inactive state */ sa1110_mb_disable(); /* * Probe for SA1111. */ ret = platform_add_devices(devices, ARRAY_SIZE(devices)); if (ret < 0) return ret; /* * Enable PWM control for LCD */ sa1111_enable_device(SKPCR_PWMCLKEN); SKPWM0 = 0x7F; // VEE SKPEN0 = 1; SKPWM1 = 0x01; // Backlight SKPEN1 = 1; return 0; } arch_initcall(graphicsmaster_init); /* * Handlers for GraphicsMaster's external IRQ logic */ static void gm_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs) { unsigned int mask; while ((mask = ADS_INT_ST1 | (ADS_INT_ST2 << 8))) { /* clear the parent IRQ */ GEDR = GPIO_GPIO0; irq = ADS_EXT_IRQ(0); desc = irq_desc + irq; do { if (mask & 1) desc->handle(irq, desc, regs); mask >>= 1; irq++; desc++; } while (mask); } } static void gm_mask_irq1(unsigned int irq) { int mask = (1 << (irq - ADS_EXT_IRQ(0))); ADS_INT_EN1 &= ~mask; ADS_INT_ST1 = mask; } static void gm_unmask_irq1(unsigned int irq) { ADS_INT_EN1 |= (1 << (irq - ADS_EXT_IRQ(0))); } static struct irqchip gm_irq1_chip = { .ack = gm_mask_irq1, .mask = gm_mask_irq1, .unmask = gm_unmask_irq1, }; static void gm_mask_irq2(unsigned int irq) { int mask = (1 << (irq - ADS_EXT_IRQ(8))); ADS_INT_EN2 &= ~mask; ADS_INT_ST2 = mask; } static void gm_unmask_irq2(unsigned int irq) { ADS_INT_EN2 |= (1 << (irq - ADS_EXT_IRQ(8))); } static struct irqchip gm_irq2_chip = { .ack = gm_mask_irq2, .mask = gm_mask_irq2, .unmask = gm_unmask_irq2, }; static void __init graphicsmaster_init_irq(void) { unsigned int irq; /* First the standard SA1100 IRQs */ sa1100_init_irq(); /* disable all IRQs */ ADS_INT_EN1 = 0; ADS_INT_EN2 = 0; /* clear all IRQs */ ADS_INT_ST1 = 0xff; ADS_INT_ST2 = 0xff; for (irq = ADS_EXT_IRQ(0); irq <= ADS_EXT_IRQ(7); irq++) { set_irq_chip(irq, &gm_irq1_chip); set_irq_handler(irq, do_level_IRQ); set_irq_flags(irq, IRQF_PROBE | IRQF_VALID); } for (irq = ADS_EXT_IRQ(8); irq <= ADS_EXT_IRQ(15); irq++) { set_irq_chip(irq, &gm_irq2_chip); set_irq_handler(irq, do_level_IRQ); set_irq_flags(irq, IRQF_PROBE | IRQF_VALID); } set_irq_type(IRQ_GPIO0, IRQT_FALLING); set_irq_chained_handler(IRQ_GPIO0, gm_irq_handler); } static struct map_desc graphicsmaster_io_desc[] __initdata = { /* virtual physical length type */ { 0xf0000000, 0x10000000, 0x00400000, MT_DEVICE }, /* CPLD */ { 0xf1000000, 0x40000000, 0x00400000, MT_DEVICE }, /* CAN */ { 0xf4000000, 0x18000000, 0x00800000, MT_DEVICE } /* SA-1111 */ }; #error Old code. Someone needs to decide what to do about this. #if 0 static int graphicsmaster_uart_open(struct uart_port *port, struct uart_info *info) { int ret = 0; if (port->mapbase == _Ser1UTCR0) { Ser1SDCR0 |= SDCR0_UART; /* Set RTS Output */ GPSR = GPIO_GPIO15; } else if (port->mapbase == _Ser2UTCR0) { Ser2UTCR4 = Ser2HSCR0 = 0; /* Set RTS Output */ GPSR = GPIO_GPIO17; } else if (port->mapbase == _Ser3UTCR0) { /* Set RTS Output */ GPSR = GPIO_GPIO19; } return ret; } #endif static u_int graphicsmaster_get_mctrl(struct uart_port *port) { u_int result = TIOCM_CD | TIOCM_DSR; if (port->mapbase == _Ser1UTCR0) { if (!(GPLR & GPIO_GPIO14)) result |= TIOCM_CTS; } else if (port->mapbase == _Ser2UTCR0) { if (!(GPLR & GPIO_GPIO16)) result |= TIOCM_CTS; } else if (port->mapbase == _Ser3UTCR0) { if (!(GPLR & GPIO_GPIO17)) result |= TIOCM_CTS; } else { result = TIOCM_CTS; } return result; } static void graphicsmaster_set_mctrl(struct uart_port *port, u_int mctrl) { if (port->mapbase == _Ser1UTCR0) { if (mctrl & TIOCM_RTS) GPCR = GPIO_GPIO15; else GPSR = GPIO_GPIO15; } else if (port->mapbase == _Ser2UTCR0) { if (mctrl & TIOCM_RTS) GPCR = GPIO_GPIO17; else GPSR = GPIO_GPIO17; } else if (port->mapbase == _Ser3UTCR0) { if (mctrl & TIOCM_RTS) GPCR = GPIO_GPIO19; else GPSR = GPIO_GPIO19; } } static void graphicsmaster_uart_pm(struct uart_port *port, u_int state, u_int oldstate) { if (!state) { /* make serial ports work ... */ Ser2UTCR4 = 0; Ser2HSCR0 = 0; Ser1SDCR0 |= SDCR0_UART; } } static struct sa1100_port_fns graphicsmaster_port_fns __initdata = { .get_mctrl = graphicsmaster_get_mctrl, .set_mctrl = graphicsmaster_set_mctrl, .pm = graphicsmaster_uart_pm, }; static void __init graphicsmaster_map_io(void) { sa1100_map_io(); iotable_init(graphicsmaster_io_desc, ARRAY_SIZE(graphicsmaster_io_desc)); sa1100_register_uart_fns(&graphicsmaster_port_fns); sa1100_register_uart(0, 3); sa1100_register_uart(1, 1); sa1100_register_uart(2, 2); /* set GPDR now */ GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19; GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18); } MACHINE_START(GRAPHICSMASTER, "ADS GraphicsMaster") BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000) MAPIO(graphicsmaster_map_io) INITIRQ(graphicsmaster_init_irq) MACHINE_END |