diff options
Diffstat (limited to 'arch/arm/mach-omap1/board-voiceblue.c')
-rw-r--r-- | arch/arm/mach-omap1/board-voiceblue.c | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c new file mode 100644 index 000000000000..d882f43658a0 --- /dev/null +++ b/arch/arm/mach-omap1/board-voiceblue.c | |||
@@ -0,0 +1,258 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-omap1/board-voiceblue.c | ||
3 | * | ||
4 | * Modified from board-generic.c | ||
5 | * | ||
6 | * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz> | ||
7 | * | ||
8 | * Code for OMAP5910 based VoiceBlue board (VoIP to GSM gateway). | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/delay.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/notifier.h> | ||
21 | #include <linux/reboot.h> | ||
22 | #include <linux/serial_8250.h> | ||
23 | #include <linux/serial_reg.h> | ||
24 | |||
25 | #include <asm/hardware.h> | ||
26 | #include <asm/mach-types.h> | ||
27 | #include <asm/mach/arch.h> | ||
28 | #include <asm/mach/map.h> | ||
29 | |||
30 | #include <asm/arch/gpio.h> | ||
31 | #include <asm/arch/tc.h> | ||
32 | #include <asm/arch/mux.h> | ||
33 | #include <asm/arch/usb.h> | ||
34 | |||
35 | #include "common.h" | ||
36 | |||
37 | extern void omap_init_time(void); | ||
38 | extern int omap_gpio_init(void); | ||
39 | |||
40 | static struct plat_serial8250_port voiceblue_ports[] = { | ||
41 | { | ||
42 | .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x40000), | ||
43 | .irq = OMAP_GPIO_IRQ(12), | ||
44 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, | ||
45 | .iotype = UPIO_MEM, | ||
46 | .regshift = 1, | ||
47 | .uartclk = 3686400, | ||
48 | }, | ||
49 | { | ||
50 | .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x50000), | ||
51 | .irq = OMAP_GPIO_IRQ(13), | ||
52 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, | ||
53 | .iotype = UPIO_MEM, | ||
54 | .regshift = 1, | ||
55 | .uartclk = 3686400, | ||
56 | }, | ||
57 | { | ||
58 | .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x60000), | ||
59 | .irq = OMAP_GPIO_IRQ(14), | ||
60 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, | ||
61 | .iotype = UPIO_MEM, | ||
62 | .regshift = 1, | ||
63 | .uartclk = 3686400, | ||
64 | }, | ||
65 | { | ||
66 | .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x70000), | ||
67 | .irq = OMAP_GPIO_IRQ(15), | ||
68 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, | ||
69 | .iotype = UPIO_MEM, | ||
70 | .regshift = 1, | ||
71 | .uartclk = 3686400, | ||
72 | }, | ||
73 | { }, | ||
74 | }; | ||
75 | |||
76 | static struct platform_device serial_device = { | ||
77 | .name = "serial8250", | ||
78 | .id = 1, | ||
79 | .dev = { | ||
80 | .platform_data = voiceblue_ports, | ||
81 | }, | ||
82 | }; | ||
83 | |||
84 | static int __init ext_uart_init(void) | ||
85 | { | ||
86 | return platform_device_register(&serial_device); | ||
87 | } | ||
88 | arch_initcall(ext_uart_init); | ||
89 | |||
90 | static struct resource voiceblue_smc91x_resources[] = { | ||
91 | [0] = { | ||
92 | .start = OMAP_CS2_PHYS + 0x300, | ||
93 | .end = OMAP_CS2_PHYS + 0x300 + 16, | ||
94 | .flags = IORESOURCE_MEM, | ||
95 | }, | ||
96 | [1] = { | ||
97 | .start = OMAP_GPIO_IRQ(8), | ||
98 | .end = OMAP_GPIO_IRQ(8), | ||
99 | .flags = IORESOURCE_IRQ, | ||
100 | }, | ||
101 | }; | ||
102 | |||
103 | static struct platform_device voiceblue_smc91x_device = { | ||
104 | .name = "smc91x", | ||
105 | .id = 0, | ||
106 | .num_resources = ARRAY_SIZE(voiceblue_smc91x_resources), | ||
107 | .resource = voiceblue_smc91x_resources, | ||
108 | }; | ||
109 | |||
110 | static struct platform_device *voiceblue_devices[] __initdata = { | ||
111 | &voiceblue_smc91x_device, | ||
112 | }; | ||
113 | |||
114 | static struct omap_usb_config voiceblue_usb_config __initdata = { | ||
115 | .hmc_mode = 3, | ||
116 | .register_host = 1, | ||
117 | .register_dev = 1, | ||
118 | .pins[0] = 2, | ||
119 | .pins[1] = 6, | ||
120 | .pins[2] = 6, | ||
121 | }; | ||
122 | |||
123 | static struct omap_board_config_kernel voiceblue_config[] = { | ||
124 | { OMAP_TAG_USB, &voiceblue_usb_config }, | ||
125 | }; | ||
126 | |||
127 | static void __init voiceblue_init_irq(void) | ||
128 | { | ||
129 | omap_init_irq(); | ||
130 | omap_gpio_init(); | ||
131 | } | ||
132 | |||
133 | static void __init voiceblue_init(void) | ||
134 | { | ||
135 | /* There is a good chance board is going up, so enable Power LED | ||
136 | * (it is connected through invertor) */ | ||
137 | omap_writeb(0x00, OMAP_LPG1_LCR); | ||
138 | /* Watchdog */ | ||
139 | omap_request_gpio(0); | ||
140 | /* smc91x reset */ | ||
141 | omap_request_gpio(7); | ||
142 | omap_set_gpio_direction(7, 0); | ||
143 | omap_set_gpio_dataout(7, 1); | ||
144 | udelay(2); /* wait at least 100ns */ | ||
145 | omap_set_gpio_dataout(7, 0); | ||
146 | mdelay(50); /* 50ms until PHY ready */ | ||
147 | /* smc91x interrupt pin */ | ||
148 | omap_request_gpio(8); | ||
149 | omap_set_gpio_edge_ctrl(8, OMAP_GPIO_RISING_EDGE); | ||
150 | /* 16C554 reset*/ | ||
151 | omap_request_gpio(6); | ||
152 | omap_set_gpio_direction(6, 0); | ||
153 | omap_set_gpio_dataout(6, 0); | ||
154 | /* 16C554 interrupt pins */ | ||
155 | omap_request_gpio(12); | ||
156 | omap_request_gpio(13); | ||
157 | omap_request_gpio(14); | ||
158 | omap_request_gpio(15); | ||
159 | omap_set_gpio_edge_ctrl(12, OMAP_GPIO_RISING_EDGE); | ||
160 | omap_set_gpio_edge_ctrl(13, OMAP_GPIO_RISING_EDGE); | ||
161 | omap_set_gpio_edge_ctrl(14, OMAP_GPIO_RISING_EDGE); | ||
162 | omap_set_gpio_edge_ctrl(15, OMAP_GPIO_RISING_EDGE); | ||
163 | |||
164 | platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices)); | ||
165 | omap_board_config = voiceblue_config; | ||
166 | omap_board_config_size = ARRAY_SIZE(voiceblue_config); | ||
167 | } | ||
168 | |||
169 | static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1}; | ||
170 | |||
171 | static void __init voiceblue_map_io(void) | ||
172 | { | ||
173 | omap_map_io(); | ||
174 | omap_serial_init(omap_serial_ports); | ||
175 | } | ||
176 | |||
177 | #define MACHINE_PANICED 1 | ||
178 | #define MACHINE_REBOOTING 2 | ||
179 | #define MACHINE_REBOOT 4 | ||
180 | static unsigned long machine_state; | ||
181 | |||
182 | static int panic_event(struct notifier_block *this, unsigned long event, | ||
183 | void *ptr) | ||
184 | { | ||
185 | if (test_and_set_bit(MACHINE_PANICED, &machine_state)) | ||
186 | return NOTIFY_DONE; | ||
187 | |||
188 | /* Flash Power LED | ||
189 | * (TODO: Enable clock right way (enabled in bootloader already)) */ | ||
190 | omap_writeb(0x78, OMAP_LPG1_LCR); | ||
191 | |||
192 | return NOTIFY_DONE; | ||
193 | } | ||
194 | |||
195 | static struct notifier_block panic_block = { | ||
196 | .notifier_call = panic_event, | ||
197 | }; | ||
198 | |||
199 | static int __init setup_notifier(void) | ||
200 | { | ||
201 | /* Setup panic notifier */ | ||
202 | notifier_chain_register(&panic_notifier_list, &panic_block); | ||
203 | |||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | postcore_initcall(setup_notifier); | ||
208 | |||
209 | static int wdt_gpio_state; | ||
210 | |||
211 | void voiceblue_wdt_enable(void) | ||
212 | { | ||
213 | omap_set_gpio_direction(0, 0); | ||
214 | omap_set_gpio_dataout(0, 0); | ||
215 | omap_set_gpio_dataout(0, 1); | ||
216 | omap_set_gpio_dataout(0, 0); | ||
217 | wdt_gpio_state = 0; | ||
218 | } | ||
219 | |||
220 | void voiceblue_wdt_disable(void) | ||
221 | { | ||
222 | omap_set_gpio_dataout(0, 0); | ||
223 | omap_set_gpio_dataout(0, 1); | ||
224 | omap_set_gpio_dataout(0, 0); | ||
225 | omap_set_gpio_direction(0, 1); | ||
226 | } | ||
227 | |||
228 | void voiceblue_wdt_ping(void) | ||
229 | { | ||
230 | if (test_bit(MACHINE_REBOOT, &machine_state)) | ||
231 | return; | ||
232 | |||
233 | wdt_gpio_state = !wdt_gpio_state; | ||
234 | omap_set_gpio_dataout(0, wdt_gpio_state); | ||
235 | } | ||
236 | |||
237 | void voiceblue_reset(void) | ||
238 | { | ||
239 | set_bit(MACHINE_REBOOT, &machine_state); | ||
240 | voiceblue_wdt_enable(); | ||
241 | while (1) ; | ||
242 | } | ||
243 | |||
244 | EXPORT_SYMBOL(voiceblue_wdt_enable); | ||
245 | EXPORT_SYMBOL(voiceblue_wdt_disable); | ||
246 | EXPORT_SYMBOL(voiceblue_wdt_ping); | ||
247 | |||
248 | MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910") | ||
249 | /* Maintainer: Ladislav Michl <michl@2n.cz> */ | ||
250 | .phys_ram = 0x10000000, | ||
251 | .phys_io = 0xfff00000, | ||
252 | .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc, | ||
253 | .boot_params = 0x10000100, | ||
254 | .map_io = voiceblue_map_io, | ||
255 | .init_irq = voiceblue_init_irq, | ||
256 | .init_machine = voiceblue_init, | ||
257 | .timer = &omap_timer, | ||
258 | MACHINE_END | ||