1
2
3
4
5
6
7
8
9
10
11
12
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>
21
22#include <asm/hardware.h>
23#include <asm/hardware/sa1111.h>
24#include <asm/setup.h>
25#include <asm/irq.h>
26
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>
31
32#include <asm/arch/irq.h>
33
34#include "generic.h"
35#include "sa1111.h"
36
37
38static int __init adsbitsy_init(void)
39{
40 int ret;
41
42 if (!machine_is_adsbitsy())
43 return -ENODEV;
44
45
46
47
48
49 sa1110_mb_disable();
50
51
52
53
54
55
56 PPAR |= PPAR_SSPGPIO;
57
58
59
60
61 GPCR |= GPIO_GPIO26;
62 udelay(1000);
63 GPSR |= GPIO_GPIO26;
64
65
66#ifndef CONFIG_LEDS_TIMER
67
68 PGSR |= GPIO_GPIO15 | GPIO_GPIO20;
69#else
70
71
72 PGSR |= GPIO_GPIO15;
73#endif
74
75
76 PGSR |= GPIO_GPIO19;
77
78
79
80
81 ret = sa1111_probe(ADSBITSY_SA1111_BASE);
82 if (ret < 0)
83 return ret;
84
85
86
87
88 sa1111_wake();
89
90
91
92
93
94
95
96
97 sa1111_configure_smc(1,
98 FExtr(MDCNFG, MDCNFG_SA1110_DRAC0),
99 FExtr(MDCNFG, MDCNFG_SA1110_TDL0));
100
101
102
103
104
105 SKPCR |= SKPCR_DCLKEN;
106
107
108
109
110 sa1110_mb_enable();
111
112 set_GPIO_IRQ_edge(GPIO_GPIO0, GPIO_RISING_EDGE);
113 sa1111_init_irq(IRQ_GPIO0);
114
115 return 0;
116}
117
118__initcall(adsbitsy_init);
119
120static void __init adsbitsy_init_irq(void)
121{
122
123 sa1100_init_irq();
124}
125
126
127static struct map_desc adsbitsy_io_desc[] __initdata = {
128
129 { 0xe8000000, 0x08000000, 0x02000000, DOMAIN_IO, 0, 1, 0, 0 },
130 { 0xf0000000, 0x3C000000, 0x00004000, DOMAIN_IO, 0, 1, 0, 0 },
131 { 0xf4000000, 0x18000000, 0x00800000, DOMAIN_IO, 0, 1, 0, 0 },
132 LAST_DESC
133};
134
135
136
137
138
139static int uart_wake_count[3] = {1, 1, 1};
140
141enum {UART_SHUTDOWN, UART_WAKEUP};
142
143static void update_uart_counts(int line, int state)
144{
145 switch (state) {
146 case UART_WAKEUP:
147 uart_wake_count[line]++;
148 break;
149 case UART_SHUTDOWN:
150 uart_wake_count[line]--;
151 break;
152 }
153}
154
155static int adsbitsy_uart_open(struct uart_port *port, struct uart_info *info)
156{
157 if (port->mapbase == _Ser1UTCR0) {
158 Ser1SDCR0 |= SDCR0_UART;
159 } else if (port->mapbase == _Ser2UTCR0) {
160 Ser2UTCR4 = Ser2HSCR0 = 0;
161 }
162 return 0;
163}
164
165void adsbitsy_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
166{
167
168
169
170 if (port->mapbase == _Ser1UTCR0) {
171 if (state) {
172 update_uart_counts(1, UART_SHUTDOWN);
173
174 Ser1UTCR3 = 0;
175 }
176 else {
177 update_uart_counts(1, UART_WAKEUP);
178 }
179 }
180 else if (port->mapbase == _Ser2UTCR0) {
181 if (state) {
182 update_uart_counts(2, UART_SHUTDOWN);
183
184 Ser2UTCR3 = 0;
185 Ser2HSCR0 = 0;
186 }
187 else {
188 update_uart_counts(2, UART_WAKEUP);
189 }
190 }
191 else if (port->mapbase == _Ser3UTCR0) {
192 if (state) {
193 update_uart_counts(0, UART_SHUTDOWN);
194
195 Ser3UTCR3 = 0;
196 }
197 else {
198 update_uart_counts(0, UART_WAKEUP);
199 }
200 }
201}
202
203static void adsbitsy_set_mctrl(struct uart_port *port, u_int mctrl)
204{
205
206 if (port->mapbase == _Ser1UTCR0) {
207 if (mctrl & TIOCM_RTS)
208
209 GPCR = GPIO_GPIO15;
210 else
211
212 GPSR = GPIO_GPIO15;
213 if (mctrl & TIOCM_DTR)
214
215 GPCR = GPIO_GPIO20;
216 else
217
218 GPSR = GPIO_GPIO20;
219 } else if (port->mapbase == _Ser3UTCR0) {
220 if (mctrl & TIOCM_RTS)
221
222 GPCR = GPIO_GPIO19;
223 else
224
225 GPSR = GPIO_GPIO19;
226 }
227}
228
229static u_int adsbitsy_get_mctrl(struct uart_port *port)
230{
231 u_int ret = 0;
232
233
234 if (port->mapbase == _Ser1UTCR0) {
235 if (!(GPLR & GPIO_GPIO14))
236 ret |= TIOCM_CTS;
237 if (!(GPLR & GPIO_GPIO24))
238 ret |= TIOCM_DSR;
239 if (!(GPLR & GPIO_GPIO16))
240 ret |= TIOCM_RI;
241 if (!(GPLR & GPIO_GPIO17))
242 ret |= TIOCM_CD;
243 } else if (port->mapbase == _Ser3UTCR0) {
244 if (!(GPLR & GPIO_GPIO18))
245 ret |= TIOCM_CTS;
246 }
247
248 return ret;
249}
250
251static 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,
256};
257
258static void __init adsbitsy_map_io(void)
259{
260 sa1100_map_io();
261 iotable_init(adsbitsy_io_desc);
262
263 sa1100_register_uart_fns(&adsbitsy_port_fns);
264 sa1100_register_uart(0, 3);
265 sa1100_register_uart(1, 1);
266
267
268#ifndef CONFIG_SA1100_FIR
269 sa1100_register_uart(2, 2);
270#endif
271
272
273 GPDR |= GPIO_GPIO15 | GPIO_GPIO20;
274
275 GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO24 | GPIO_GPIO16 | GPIO_GPIO17);
276
277
278 GPDR |= GPIO_GPIO19;
279
280 GPDR &= ~GPIO_GPIO18;
281}
282
283
284MACHINE_START(ADSBITSY, "ADS Bitsy")
285 BOOT_PARAMS(0xc000003c)
286 BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
287 MAPIO(adsbitsy_map_io)
288 INITIRQ(adsbitsy_init_irq)
289MACHINE_END
290