2 * linux/arch/arm/mach-sa1100/graphicsclient.c
4 * Author: Nicolas Pitre
6 * Pieces specific to the GraphicsClient board
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/ptrace.h>
16 #include <asm/hardware.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>
24 #include <linux/serial_core.h>
30 * Handlers for GraphicsClient's external IRQ logic
34 gc_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
38 while ((mask = ADS_INT_ST1 | (ADS_INT_ST2 << 8))) {
39 /* clear the parent IRQ */
43 desc = irq_desc + irq;
47 desc->handle(irq, desc, regs);
55 static void gc_mask_irq1(unsigned int irq)
57 int mask = (1 << (irq - ADS_EXT_IRQ(0)));
62 static void gc_unmask_irq1(unsigned int irq)
64 ADS_INT_EN1 |= (1 << (irq - ADS_EXT_IRQ(0)));
67 static struct irqchip gc_irq1_chip = {
70 .unmask = gc_unmask_irq1,
73 static void gc_mask_irq2(unsigned int irq)
75 int mask = (1 << (irq - ADS_EXT_IRQ(8)));
80 static void gc_unmask_irq2(unsigned int irq)
82 ADS_INT_EN2 |= (1 << (irq - ADS_EXT_IRQ(8)));
85 static struct irqchip gc_irq2_chip = {
88 .unmask = gc_unmask_irq2,
91 static void __init graphicsclient_init_irq(void)
95 /* First the standard SA1100 IRQs */
98 /* disable all IRQs */
106 for (irq = ADS_EXT_IRQ(0); irq <= ADS_EXT_IRQ(7); irq++) {
107 set_irq_chip(irq, &gc_irq1_chip);
108 set_irq_handler(irq, do_level_IRQ);
109 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
111 for (irq = ADS_EXT_IRQ(8); irq <= ADS_EXT_IRQ(15); irq++) {
112 set_irq_chip(irq, &gc_irq2_chip);
113 set_irq_handler(irq, do_level_IRQ);
114 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
116 set_irq_type(IRQ_GPIO0, IRQT_FALLING);
117 set_irq_chained_handler(IRQ_GPIO0, gc_irq_handler);
121 static struct map_desc graphicsclient_io_desc[] __initdata = {
122 /* virtual physical length type */
123 { 0xf0000000, 0x10000000, 0x00400000, MT_DEVICE }, /* CPLD */
124 { 0xf1000000, 0x18000000, 0x00400000, MT_DEVICE } /* CAN */
127 static u_int graphicsclient_get_mctrl(struct uart_port *port)
129 u_int result = TIOCM_CD | TIOCM_DSR;
131 if (port->mapbase == _Ser1UTCR0) {
132 if (!(GPLR & GPIO_GC_UART0_CTS))
134 } else if (port->mapbase == _Ser2UTCR0) {
135 if (!(GPLR & GPIO_GC_UART1_CTS))
137 } else if (port->mapbase == _Ser3UTCR0) {
138 if (!(GPLR & GPIO_GC_UART2_CTS))
147 static void graphicsclient_set_mctrl(struct uart_port *port, u_int mctrl)
149 if (port->mapbase == _Ser1UTCR0) {
150 if (mctrl & TIOCM_RTS)
151 GPCR = GPIO_GC_UART0_RTS;
153 GPSR = GPIO_GC_UART0_RTS;
154 } else if (port->mapbase == _Ser2UTCR0) {
155 if (mctrl & TIOCM_RTS)
156 GPCR = GPIO_GC_UART1_RTS;
158 GPSR = GPIO_GC_UART1_RTS;
159 } else if (port->mapbase == _Ser3UTCR0) {
160 if (mctrl & TIOCM_RTS)
161 GPCR = GPIO_GC_UART2_RTS;
163 GPSR = GPIO_GC_UART2_RTS;
168 graphicsclient_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
171 /* make serial ports work ... */
174 Ser1SDCR0 |= SDCR0_UART;
178 static struct sa1100_port_fns graphicsclient_port_fns __initdata = {
179 .get_mctrl = graphicsclient_get_mctrl,
180 .set_mctrl = graphicsclient_set_mctrl,
181 .pm = graphicsclient_uart_pm,
184 static void __init graphicsclient_map_io(void)
187 iotable_init(graphicsclient_io_desc, ARRAY_SIZE(graphicsclient_io_desc));
189 sa1100_register_uart_fns(&graphicsclient_port_fns);
190 sa1100_register_uart(0, 3);
191 sa1100_register_uart(1, 1);
192 sa1100_register_uart(2, 2);
193 GPDR |= GPIO_GC_UART0_RTS | GPIO_GC_UART1_RTS | GPIO_GC_UART2_RTS;
194 GPDR &= ~(GPIO_GC_UART0_CTS | GPIO_GC_UART1_RTS | GPIO_GC_UART2_RTS);
197 MACHINE_START(GRAPHICSCLIENT, "ADS GraphicsClient")
198 BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
199 MAPIO(graphicsclient_map_io)
200 INITIRQ(graphicsclient_init_irq)
201 INITTIME(sa1100_init_time)