Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap / board-voiceblue.c
blobf1a5bffac6668e0d506af379c81e497caddc4596
1 /*
2 * linux/arch/arm/mach-omap/board-voiceblue.c
4 * Modified from board-generic.c
6 * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz>
8 * Code for OMAP5910 based VoiceBlue board (VoIP to GSM gateway).
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.
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>
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/tc.h>
32 #include <asm/arch/mux.h>
33 #include <asm/arch/usb.h>
35 #include "common.h"
37 extern void omap_init_time(void);
38 extern int omap_gpio_init(void);
40 static struct plat_serial8250_port voiceblue_ports[] = {
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,
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,
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,
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,
73 { },
76 static struct platform_device serial_device = {
77 .name = "serial8250",
78 .id = 1,
79 .dev = {
80 .platform_data = voiceblue_ports,
84 static int __init ext_uart_init(void)
86 return platform_device_register(&serial_device);
88 arch_initcall(ext_uart_init);
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,
96 [1] = {
97 .start = OMAP_GPIO_IRQ(8),
98 .end = OMAP_GPIO_IRQ(8),
99 .flags = IORESOURCE_IRQ,
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,
110 static struct platform_device *voiceblue_devices[] __initdata = {
111 &voiceblue_smc91x_device,
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,
123 static struct omap_board_config_kernel voiceblue_config[] = {
124 { OMAP_TAG_USB, &voiceblue_usb_config },
127 static void __init voiceblue_init_irq(void)
129 omap_init_irq();
130 omap_gpio_init();
133 static void __init voiceblue_init(void)
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);
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);
169 static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
171 static void __init voiceblue_map_io(void)
173 omap_map_io();
174 omap_serial_init(omap_serial_ports);
177 #define MACHINE_PANICED 1
178 #define MACHINE_REBOOTING 2
179 #define MACHINE_REBOOT 4
180 static unsigned long machine_state;
182 static int panic_event(struct notifier_block *this, unsigned long event,
183 void *ptr)
185 if (test_and_set_bit(MACHINE_PANICED, &machine_state))
186 return NOTIFY_DONE;
188 /* Flash Power LED
189 * (TODO: Enable clock right way (enabled in bootloader already)) */
190 omap_writeb(0x78, OMAP_LPG1_LCR);
192 return NOTIFY_DONE;
195 static struct notifier_block panic_block = {
196 .notifier_call = panic_event,
199 static int __init setup_notifier(void)
201 /* Setup panic notifier */
202 notifier_chain_register(&panic_notifier_list, &panic_block);
204 return 0;
207 postcore_initcall(setup_notifier);
209 static int wdt_gpio_state;
211 void voiceblue_wdt_enable(void)
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;
220 void voiceblue_wdt_disable(void)
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);
228 void voiceblue_wdt_ping(void)
230 if (test_bit(MACHINE_REBOOT, &machine_state))
231 return;
233 wdt_gpio_state = !wdt_gpio_state;
234 omap_set_gpio_dataout(0, wdt_gpio_state);
237 void voiceblue_reset(void)
239 set_bit(MACHINE_REBOOT, &machine_state);
240 voiceblue_wdt_enable();
241 while (1) ;
244 EXPORT_SYMBOL(voiceblue_wdt_enable);
245 EXPORT_SYMBOL(voiceblue_wdt_disable);
246 EXPORT_SYMBOL(voiceblue_wdt_ping);
248 MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
249 MAINTAINER("Ladislav Michl <michl@2n.cz>")
250 BOOT_MEM(0x10000000, 0xfff00000, 0xfef00000)
251 BOOT_PARAMS(0x10000100)
252 MAPIO(voiceblue_map_io)
253 INITIRQ(voiceblue_init_irq)
254 INIT_MACHINE(voiceblue_init)
255 .timer = &omap_timer,
256 MACHINE_END