2 * linux/arch/arm/mach-sa1100/adsbitsy.c
6 * Pieces specific to the ADS Bitsy
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/delay.h>
18 #include <linux/serial_core.h>
19 #include <linux/list.h>
20 #include <linux/timer.h>
22 #include <asm/hardware.h>
23 #include <asm/hardware/sa1111.h>
24 #include <asm/setup.h>
27 #include <asm/mach/irq.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/serial_sa1100.h>
32 #include <asm/arch/irq.h>
38 static int __init adsbitsy_init(void)
42 if (!machine_is_adsbitsy())
46 * Ensure that the memory bus request/grant signals are setup,
47 * and the grant is held in its inactive state
51 /* Bitsy uses GPIO pins for SPI interface to AVR
52 * Bitsy Plus uses the standard pins instead.
53 * it also needs to reset the AVR when booting
66 #ifndef CONFIG_LEDS_TIMER
67 // Set Serial port 1 RTS and DTR Low during sleep
68 PGSR |= GPIO_GPIO15 | GPIO_GPIO20;
70 // only RTS (because DTR is also the LED
71 // which should be off during sleep);
75 // Set Serial port 3RTS Low during sleep
81 ret = sa1111_probe(ADSBITSY_SA1111_BASE);
86 * We found it. Wake the chip up.
91 * The SDRAM configuration of the SA1110 and the SA1111 must
92 * match. This is very important to ensure that SA1111 accesses
93 * don't corrupt the SDRAM. Note that this ungates the SA1111's
94 * MBGNT signal, so we must have called sa1110_mb_disable()
97 sa1111_configure_smc(1,
98 FExtr(MDCNFG, MDCNFG_SA1110_DRAC0),
99 FExtr(MDCNFG, MDCNFG_SA1110_TDL0));
102 * We only need to turn on DCLK whenever we want to use the
103 * DMA. It can otherwise be held firmly in the off position.
105 SKPCR |= SKPCR_DCLKEN;
108 * Enable the SA1110 memory bus request and grant signals.
112 set_GPIO_IRQ_edge(GPIO_GPIO0, GPIO_RISING_EDGE);
113 sa1111_init_irq(IRQ_GPIO0);
118 __initcall(adsbitsy_init);
120 static void __init adsbitsy_init_irq(void)
122 /* First the standard SA1100 IRQs */
127 static struct map_desc adsbitsy_io_desc[] __initdata = {
128 /* virtual physical length domain r w c b */
129 { 0xe8000000, 0x08000000, 0x02000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash bank 1 */
130 { 0xf0000000, 0x3C000000, 0x00004000, DOMAIN_IO, 0, 1, 0, 0 }, /* 91C1111 */
131 { 0xf4000000, 0x18000000, 0x00800000, DOMAIN_IO, 0, 1, 0, 0 }, /* SA1111 */
135 /* Use this to see when all uarts are shutdown. Or all are closed.
136 * We can only turn off RS232 chip if either of these are true.
139 static int uart_wake_count[3] = {1, 1, 1};
141 enum {UART_SHUTDOWN, UART_WAKEUP};
143 static void update_uart_counts(int line, int state)
147 uart_wake_count[line]++;
150 uart_wake_count[line]--;
155 static int adsbitsy_uart_open(struct uart_port *port, struct uart_info *info)
157 if (port->mapbase == _Ser1UTCR0) {
158 Ser1SDCR0 |= SDCR0_UART;
159 } else if (port->mapbase == _Ser2UTCR0) {
160 Ser2UTCR4 = Ser2HSCR0 = 0;
165 void adsbitsy_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
167 // state has ACPI D0-D3
168 // ACPI D0 : resume from suspend
169 // ACPI D1-D3 : enter to a suspend state
170 if (port->mapbase == _Ser1UTCR0) {
172 update_uart_counts(1, UART_SHUTDOWN);
177 update_uart_counts(1, UART_WAKEUP);
180 else if (port->mapbase == _Ser2UTCR0) {
182 update_uart_counts(2, UART_SHUTDOWN);
188 update_uart_counts(2, UART_WAKEUP);
191 else if (port->mapbase == _Ser3UTCR0) {
193 update_uart_counts(0, UART_SHUTDOWN);
198 update_uart_counts(0, UART_WAKEUP);
203 static void adsbitsy_set_mctrl(struct uart_port *port, u_int mctrl)
205 // note: only ports 1 and 3 have modem control
206 if (port->mapbase == _Ser1UTCR0) {
207 if (mctrl & TIOCM_RTS)
213 if (mctrl & TIOCM_DTR)
219 } else if (port->mapbase == _Ser3UTCR0) {
220 if (mctrl & TIOCM_RTS)
229 static u_int adsbitsy_get_mctrl(struct uart_port *port)
233 // note: only ports 1 and 3 have modem control
234 if (port->mapbase == _Ser1UTCR0) {
235 if (!(GPLR & GPIO_GPIO14))
237 if (!(GPLR & GPIO_GPIO24))
239 if (!(GPLR & GPIO_GPIO16))
241 if (!(GPLR & GPIO_GPIO17))
243 } else if (port->mapbase == _Ser3UTCR0) {
244 if (!(GPLR & GPIO_GPIO18))
251 static struct sa1100_port_fns adsbitsy_port_fns __initdata = {
252 .set_mctrl = adsbitsy_set_mctrl,
253 .get_mctrl = adsbitsy_get_mctrl,
254 .open = adsbitsy_uart_open,
255 .pm = adsbitsy_uart_pm,
258 static void __init adsbitsy_map_io(void)
261 iotable_init(adsbitsy_io_desc);
263 sa1100_register_uart_fns(&adsbitsy_port_fns);
264 sa1100_register_uart(0, 3);
265 sa1100_register_uart(1, 1);
267 // don't register if you want to use IRDA
268 #ifndef CONFIG_SA1100_FIR
269 sa1100_register_uart(2, 2);
272 // COM1 Set RTS and DTR Output
273 GPDR |= GPIO_GPIO15 | GPIO_GPIO20;
274 // Set CTS, DSR, RI and CD Input
275 GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO24 | GPIO_GPIO16 | GPIO_GPIO17);
277 // COM3 Set RTS Output
280 GPDR &= ~GPIO_GPIO18;
284 MACHINE_START(ADSBITSY, "ADS Bitsy")
285 BOOT_PARAMS(0xc000003c)
286 BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
287 MAPIO(adsbitsy_map_io)
288 INITIRQ(adsbitsy_init_irq)