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.
11 #include <linux/init.h>
12 #include <linux/sched.h>
13 #include <linux/interrupt.h>
14 #include <linux/ptrace.h>
15 #include <linux/serial_core.h>
16 #include <linux/delay.h>
17 #include <linux/list.h>
18 #include <linux/timer.h>
20 #include <asm/hardware.h>
21 #include <asm/hardware/sa1111.h>
22 #include <asm/setup.h>
25 #include <asm/mach/irq.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/serial_sa1100.h>
30 #include <asm/arch/irq.h>
35 static int __init graphicsmaster_init(void)
39 if (!machine_is_graphicsmaster())
43 * Ensure that the memory bus request/grant signals are setup,
44 * and the grant is held in its inactive state
48 /* GraphicsMaster uses GPIO pins for SPI interface to AVR
51 /* use the alternate SSP pins */
54 // Set RTS low during sleep
55 PGSR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
60 ret = sa1111_probe(ADS_SA1111_BASE);
65 * We found it. Wake the chip up.
70 * The SDRAM configuration of the SA1110 and the SA1111 must
71 * match. This is very important to ensure that SA1111 accesses
72 * don't corrupt the SDRAM. Note that this ungates the SA1111's
73 * MBGNT signal, so we must have called sa1110_mb_disable()
76 sa1111_configure_smc(1,
77 FExtr(MDCNFG, MDCNFG_SA1110_DRAC0),
78 FExtr(MDCNFG, MDCNFG_SA1110_TDL0));
81 * Enable PWM control for LCD
83 SKPCR |= SKPCR_PWMCLKEN;
85 ADS_DCR |= DCR_BACKLITE_ON;
86 SKPWM0 = 0x01; // Backlight
92 * We only need to turn on DCLK whenever we want to use the
93 * DMA. It can otherwise be held firmly in the off position.
95 SKPCR |= SKPCR_DCLKEN;
98 * Enable the SA1110 memory bus request and grant signals.
102 sa1111_init_irq(IRQ_GRAPHICSMASTER_SA1111);
107 __initcall(graphicsmaster_init);
110 * Handlers for GraphicsMaster's external IRQ logic
113 #define GRAPHICSMASTER_N_IRQ (IRQ_GRAPHICSMASTER_END - IRQ_GRAPHICSMASTER_START)
115 static void ADS_IRQ_demux( int irq, void *dev_id, struct pt_regs *regs )
119 while( (irq = ADS_INT_ST1 | (ADS_INT_ST2 << 8)) ){
120 for( i = 0; i < GRAPHICSMASTER_N_IRQ; i++ )
122 do_IRQ( IRQ_GRAPHICSMASTER_START + i, regs );
127 static struct irqaction ADS_ext_irq = {
128 .name = "ADS_ext_IRQ",
129 .handler = ADS_IRQ_demux,
130 .flags = SA_INTERRUPT
133 static void ADS_mask_and_ack_irq0(unsigned int irq)
135 int mask = (1 << (irq - IRQ_GRAPHICSMASTER_START));
136 ADS_INT_EN1 &= ~mask;
140 static void ADS_mask_irq0(unsigned int irq)
142 ADS_INT_ST1 = (1 << (irq - IRQ_GRAPHICSMASTER_START));
145 static void ADS_unmask_irq0(unsigned int irq)
147 ADS_INT_EN1 |= (1 << (irq - IRQ_GRAPHICSMASTER_START));
150 static void ADS_mask_and_ack_irq1(unsigned int irq)
152 int mask = (1 << (irq - (IRQ_GRAPHICSMASTER_UCB1200)));
153 ADS_INT_EN2 &= ~mask;
157 static void ADS_mask_irq1(unsigned int irq)
159 ADS_INT_ST2 = (1 << (irq - (IRQ_GRAPHICSMASTER_UCB1200)));
162 static void ADS_unmask_irq1(unsigned int irq)
164 ADS_INT_EN2 |= (1 << (irq - (IRQ_GRAPHICSMASTER_UCB1200)));
167 static void __init graphicsmaster_init_irq(void)
171 /* First the standard SA1100 IRQs */
174 /* disable all IRQs */
181 for (irq = IRQ_GRAPHICSMASTER_START; irq < IRQ_GRAPHICSMASTER_UCB1200; irq++) {
182 irq_desc[irq].valid = 1;
183 irq_desc[irq].probe_ok = 1;
184 irq_desc[irq].mask_ack = ADS_mask_and_ack_irq0;
185 irq_desc[irq].mask = ADS_mask_irq0;
186 irq_desc[irq].unmask = ADS_unmask_irq0;
188 for (irq = IRQ_GRAPHICSMASTER_UCB1200; irq < IRQ_GRAPHICSMASTER_END; irq++) {
189 irq_desc[irq].valid = 1;
190 irq_desc[irq].probe_ok = 1;
191 irq_desc[irq].mask_ack = ADS_mask_and_ack_irq1;
192 irq_desc[irq].mask = ADS_mask_irq1;
193 irq_desc[irq].unmask = ADS_unmask_irq1;
197 set_GPIO_IRQ_edge(GPIO_GPIO0, GPIO_FALLING_EDGE);
198 setup_arm_irq( IRQ_GPIO0, &ADS_ext_irq );
202 static struct map_desc graphicsmaster_io_desc[] __initdata = {
203 /* virtual physical length domain r w c b */
204 { 0xe8000000, 0x08000000, 0x02000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash bank 1 */
205 { 0xf0000000, 0x10000000, 0x00400000, DOMAIN_IO, 0, 1, 0, 0 }, /* CPLD */
206 { 0xf1000000, 0x40000000, 0x00400000, DOMAIN_IO, 0, 1, 0, 0 }, /* CAN */
207 { 0xf4000000, 0x18000000, 0x00800000, DOMAIN_IO, 0, 1, 0, 0 }, /* SA-1111 */
211 static int graphicsmaster_uart_open(struct uart_port *port, struct uart_info *info)
215 if (port->mapbase == _Ser1UTCR0) {
216 Ser1SDCR0 |= SDCR0_UART;
218 else if (port->mapbase == _Ser2UTCR0) {
219 Ser2UTCR4 = Ser2HSCR0 = 0;
224 static u_int graphicsmaster_get_mctrl(struct uart_port *port)
226 u_int result = TIOCM_CD | TIOCM_DSR;
228 if (port->mapbase == _Ser1UTCR0) {
229 if (!(GPLR & GPIO_GPIO14))
231 } else if (port->mapbase == _Ser2UTCR0) {
232 if (!(GPLR & GPIO_GPIO16))
234 } else if (port->mapbase == _Ser3UTCR0) {
235 if (!(GPLR & GPIO_GPIO18))
244 static void graphicsmaster_set_mctrl(struct uart_port *port, u_int mctrl)
246 if (port->mapbase == _Ser1UTCR0) {
247 if (mctrl & TIOCM_RTS)
251 } else if (port->mapbase == _Ser2UTCR0) {
252 if (mctrl & TIOCM_RTS)
256 } else if (port->mapbase == _Ser3UTCR0) {
257 if (mctrl & TIOCM_RTS)
265 graphicsmaster_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
267 // state has ACPI D0-D3
268 // ACPI D0 : resume from suspend
269 // ACPI D1-D3 : enter to a suspend state
270 if (port->mapbase == _Ser1UTCR0) {
276 else if (port->mapbase == _Ser2UTCR0) {
283 else if (port->mapbase == _Ser3UTCR0) {
291 static struct sa1100_port_fns graphicsmaster_port_fns __initdata = {
292 .open = graphicsmaster_uart_open,
293 .get_mctrl = graphicsmaster_get_mctrl,
294 .set_mctrl = graphicsmaster_set_mctrl,
295 .pm = graphicsmaster_uart_pm,
298 static void __init graphicsmaster_map_io(void)
301 iotable_init(graphicsmaster_io_desc);
303 sa1100_register_uart_fns(&graphicsmaster_port_fns);
304 sa1100_register_uart(0, 3);
305 sa1100_register_uart(1, 1);
306 // don't register if you want to use IRDA
307 #ifndef CONFIG_SA1100_FIR
308 sa1100_register_uart(2, 2);
312 GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
313 GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18);
316 MACHINE_START(GRAPHICSMASTER, "ADS GraphicsMaster")
317 BOOT_PARAMS(0xc000003c)
318 BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
319 MAPIO(graphicsmaster_map_io)
320 INITIRQ(graphicsmaster_init_irq)