2 * linux/arch/arm/mach-sa1100/graphicsmaster.c
4 * Pieces specific to the GraphicsMaster board
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/ptrace.h>
13 #include <linux/ioport.h>
15 #include <asm/hardware.h>
16 #include <asm/mach-types.h>
17 #include <asm/setup.h>
20 #include <asm/mach/irq.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach/map.h>
23 #include <asm/mach/serial_sa1100.h>
27 static struct resource sa1111_resources[] = {
31 .flags = IORESOURCE_MEM,
34 .start = ADS_EXT_IRQ(0),
35 .end = ADS_EXT_IRQ(0),
36 .flags = IORESOURCE_IRQ,
40 static u64 sa1111_dmamask = 0xffffffffUL;
42 static struct platform_device sa1111_device = {
46 .dma_mask = &sa1111_dmamask,
47 .coherent_dma_mask = 0xffffffff,
49 .num_resources = ARRAY_SIZE(sa1111_resources),
50 .resource = sa1111_resources,
53 static struct platform_device *devices[] __initdata = {
57 static int __init graphicsmaster_init(void)
61 if (!machine_is_graphicsmaster())
65 * Ensure that the memory bus request/grant signals are setup,
66 * and the grant is held in its inactive state
73 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
78 * Enable PWM control for LCD
80 sa1111_enable_device(SKPCR_PWMCLKEN);
83 SKPWM1 = 0x01; // Backlight
89 arch_initcall(graphicsmaster_init);
92 * Handlers for GraphicsMaster's external IRQ logic
96 gm_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
100 while ((mask = ADS_INT_ST1 | (ADS_INT_ST2 << 8))) {
101 /* clear the parent IRQ */
104 irq = ADS_EXT_IRQ(0);
105 desc = irq_desc + irq;
109 desc->handle(irq, desc, regs);
117 static void gm_mask_irq1(unsigned int irq)
119 int mask = (1 << (irq - ADS_EXT_IRQ(0)));
120 ADS_INT_EN1 &= ~mask;
124 static void gm_unmask_irq1(unsigned int irq)
126 ADS_INT_EN1 |= (1 << (irq - ADS_EXT_IRQ(0)));
129 static struct irqchip gm_irq1_chip = {
131 .mask = gm_mask_irq1,
132 .unmask = gm_unmask_irq1,
135 static void gm_mask_irq2(unsigned int irq)
137 int mask = (1 << (irq - ADS_EXT_IRQ(8)));
138 ADS_INT_EN2 &= ~mask;
142 static void gm_unmask_irq2(unsigned int irq)
144 ADS_INT_EN2 |= (1 << (irq - ADS_EXT_IRQ(8)));
147 static struct irqchip gm_irq2_chip = {
149 .mask = gm_mask_irq2,
150 .unmask = gm_unmask_irq2,
153 static void __init graphicsmaster_init_irq(void)
157 /* First the standard SA1100 IRQs */
160 /* disable all IRQs */
168 for (irq = ADS_EXT_IRQ(0); irq <= ADS_EXT_IRQ(7); irq++) {
169 set_irq_chip(irq, &gm_irq1_chip);
170 set_irq_handler(irq, do_level_IRQ);
171 set_irq_flags(irq, IRQF_PROBE | IRQF_VALID);
173 for (irq = ADS_EXT_IRQ(8); irq <= ADS_EXT_IRQ(15); irq++) {
174 set_irq_chip(irq, &gm_irq2_chip);
175 set_irq_handler(irq, do_level_IRQ);
176 set_irq_flags(irq, IRQF_PROBE | IRQF_VALID);
178 set_irq_type(IRQ_GPIO0, IRQT_FALLING);
179 set_irq_chained_handler(IRQ_GPIO0, gm_irq_handler);
183 static struct map_desc graphicsmaster_io_desc[] __initdata = {
184 /* virtual physical length type */
185 { 0xf0000000, 0x10000000, 0x00400000, MT_DEVICE }, /* CPLD */
186 { 0xf1000000, 0x40000000, 0x00400000, MT_DEVICE }, /* CAN */
187 { 0xf4000000, 0x18000000, 0x00800000, MT_DEVICE } /* SA-1111 */
190 #error Old code. Someone needs to decide what to do about this.
192 static int graphicsmaster_uart_open(struct uart_port *port, struct uart_info *info)
196 if (port->mapbase == _Ser1UTCR0) {
197 Ser1SDCR0 |= SDCR0_UART;
201 else if (port->mapbase == _Ser2UTCR0) {
202 Ser2UTCR4 = Ser2HSCR0 = 0;
206 else if (port->mapbase == _Ser3UTCR0) {
214 static u_int graphicsmaster_get_mctrl(struct uart_port *port)
216 u_int result = TIOCM_CD | TIOCM_DSR;
218 if (port->mapbase == _Ser1UTCR0) {
219 if (!(GPLR & GPIO_GPIO14))
221 } else if (port->mapbase == _Ser2UTCR0) {
222 if (!(GPLR & GPIO_GPIO16))
224 } else if (port->mapbase == _Ser3UTCR0) {
225 if (!(GPLR & GPIO_GPIO17))
234 static void graphicsmaster_set_mctrl(struct uart_port *port, u_int mctrl)
236 if (port->mapbase == _Ser1UTCR0) {
237 if (mctrl & TIOCM_RTS)
241 } else if (port->mapbase == _Ser2UTCR0) {
242 if (mctrl & TIOCM_RTS)
246 } else if (port->mapbase == _Ser3UTCR0) {
247 if (mctrl & TIOCM_RTS)
255 graphicsmaster_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
258 /* make serial ports work ... */
261 Ser1SDCR0 |= SDCR0_UART;
265 static struct sa1100_port_fns graphicsmaster_port_fns __initdata = {
266 .get_mctrl = graphicsmaster_get_mctrl,
267 .set_mctrl = graphicsmaster_set_mctrl,
268 .pm = graphicsmaster_uart_pm,
271 static void __init graphicsmaster_map_io(void)
274 iotable_init(graphicsmaster_io_desc, ARRAY_SIZE(graphicsmaster_io_desc));
276 sa1100_register_uart_fns(&graphicsmaster_port_fns);
277 sa1100_register_uart(0, 3);
278 sa1100_register_uart(1, 1);
279 sa1100_register_uart(2, 2);
282 GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
283 GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18);
286 MACHINE_START(GRAPHICSMASTER, "ADS GraphicsMaster")
287 BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
288 MAPIO(graphicsmaster_map_io)
289 INITIRQ(graphicsmaster_init_irq)
290 INITTIME(sa1100_init_time)