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.
13 #include <linux/init.h>
14 #include <linux/sched.h>
15 #include <linux/interrupt.h>
16 #include <linux/ptrace.h>
17 #include <linux/list.h>
18 #include <linux/timer.h>
20 #include <asm/hardware.h>
21 #include <asm/setup.h>
24 #include <asm/mach/irq.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/serial_sa1100.h>
28 #include <linux/serial_core.h>
30 #include <asm/arch/irq.h>
36 * Handlers for GraphicsClient's external IRQ logic
39 #define GRAPHICSCLIENT_N_IRQ (IRQ_GRAPHICSCLIENT_END - IRQ_GRAPHICSCLIENT_START)
40 #define GRAPHICSCLIENT_FIRST_IRQ (IRQ_GRAPHICSCLIENT_CAN - IRQ_GRAPHICSCLIENT_START)
42 static void ADS_IRQ_demux( int irq, void *dev_id, struct pt_regs *regs )
46 while( (irq = ADS_INT_ST1 | (ADS_INT_ST2 << 8)) ){
47 for( i = GRAPHICSCLIENT_FIRST_IRQ; i < GRAPHICSCLIENT_N_IRQ; i++ )
49 do_IRQ( IRQ_GRAPHICSCLIENT_START + i, regs );
53 static struct irqaction ADS_ext_irq = {
54 .name = "ADS_ext_IRQ",
55 .handler = ADS_IRQ_demux,
59 static void ADS_mask_and_ack_irq0(unsigned int irq)
61 int mask = (1 << (irq - IRQ_GRAPHICSCLIENT_START));
66 static void ADS_mask_irq0(unsigned int irq)
68 ADS_INT_ST1 = (1 << (irq - IRQ_GRAPHICSCLIENT_START));
71 static void ADS_unmask_irq0(unsigned int irq)
73 ADS_INT_EN1 |= (1 << (irq - IRQ_GRAPHICSCLIENT_START));
76 static void ADS_mask_and_ack_irq1(unsigned int irq)
78 int mask = (1 << (irq - (IRQ_GRAPHICSCLIENT_UCB1200)));
83 static void ADS_mask_irq1(unsigned int irq)
85 ADS_INT_ST2 = (1 << (irq - (IRQ_GRAPHICSCLIENT_UCB1200)));
88 static void ADS_unmask_irq1(unsigned int irq)
90 ADS_INT_EN2 |= (1 << (irq - (IRQ_GRAPHICSCLIENT_UCB1200)));
93 static void __init graphicsclient_init_irq(void)
97 /* First the standard SA1100 IRQs */
100 /* disable all IRQs */
107 // Set RTS low during sleep
108 PGSR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
110 for (irq = IRQ_GRAPHICSCLIENT_START; irq < IRQ_GRAPHICSCLIENT_UCB1200; irq++) {
111 irq_desc[irq].valid = 1;
112 irq_desc[irq].probe_ok = 1;
113 irq_desc[irq].mask_ack = ADS_mask_and_ack_irq0;
114 irq_desc[irq].mask = ADS_mask_irq0;
115 irq_desc[irq].unmask = ADS_unmask_irq0;
117 for (irq = IRQ_GRAPHICSCLIENT_UCB1200; irq < IRQ_GRAPHICSCLIENT_END; irq++) {
118 irq_desc[irq].valid = 1;
119 irq_desc[irq].probe_ok = 1;
120 irq_desc[irq].mask_ack = ADS_mask_and_ack_irq1;
121 irq_desc[irq].mask = ADS_mask_irq1;
122 irq_desc[irq].unmask = ADS_unmask_irq1;
124 set_GPIO_IRQ_edge(GPIO_GPIO0, GPIO_FALLING_EDGE);
125 setup_arm_irq( IRQ_GPIO0, &ADS_ext_irq );
128 static struct map_desc graphicsclient_io_desc[] __initdata = {
129 /* virtual physical length domain r w c b */
130 { 0xe8000000, 0x08000000, 0x02000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash bank 1 */
131 { 0xf0000000, 0x10000000, 0x00400000, DOMAIN_IO, 0, 1, 0, 0 }, /* CPLD */
132 { 0xf1000000, 0x18000000, 0x00400000, DOMAIN_IO, 0, 1, 0, 0 }, /* CAN */
136 static int graphicsclient_uart_open(struct uart_port *port, struct uart_info *info)
140 if (port->mapbase == _Ser1UTCR0) {
141 Ser1SDCR0 |= SDCR0_UART;
143 else if (port->mapbase == _Ser2UTCR0) {
144 Ser2UTCR4 = Ser2HSCR0 = 0;
149 static u_int graphicsclient_get_mctrl(struct uart_port *port)
151 u_int result = TIOCM_CD | TIOCM_DSR;
153 if (port->mapbase == _Ser1UTCR0) {
154 if (!(GPLR & GPIO_GPIO14))
156 } else if (port->mapbase == _Ser2UTCR0) {
157 if (!(GPLR & GPIO_GPIO16))
159 } else if (port->mapbase == _Ser3UTCR0) {
160 if (!(GPLR & GPIO_GPIO18))
169 static void graphicsclient_set_mctrl(struct uart_port *port, u_int mctrl)
171 if (port->mapbase == _Ser1UTCR0) {
172 if (mctrl & TIOCM_RTS)
176 } else if (port->mapbase == _Ser2UTCR0) {
177 if (mctrl & TIOCM_RTS)
181 } else if (port->mapbase == _Ser3UTCR0) {
182 if (mctrl & TIOCM_RTS)
190 graphicsclient_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
192 // state has ACPI D0-D3
193 // ACPI D0 : resume from suspend
194 // ACPI D1-D3 : enter to a suspend state
195 if (port->mapbase == _Ser1UTCR0) {
201 else if (port->mapbase == _Ser2UTCR0) {
208 else if (port->mapbase == _Ser3UTCR0) {
216 static struct sa1100_port_fns graphicsclient_port_fns __initdata = {
217 .open = graphicsclient_uart_open,
218 .get_mctrl = graphicsclient_get_mctrl,
219 .set_mctrl = graphicsclient_set_mctrl,
220 .pm = graphicsclient_uart_pm,
223 static void __init graphicsclient_map_io(void)
226 iotable_init(graphicsclient_io_desc);
228 sa1100_register_uart_fns(&graphicsclient_port_fns);
229 sa1100_register_uart(0, 3);
230 sa1100_register_uart(1, 1);
232 // don't register if you want to use IRDA
233 #ifndef CONFIG_SA1100_FIR
234 sa1100_register_uart(2, 2);
238 GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
239 GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18);
242 MACHINE_START(GRAPHICSCLIENT, "ADS GraphicsClient")
243 BOOT_PARAMS(0xc000003c)
244 BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
245 MAPIO(graphicsclient_map_io)
246 INITIRQ(graphicsclient_init_irq)