2 * linux/arch/arm/mach-omap1/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>
34 #include <asm/arch/common.h>
36 extern void omap_init_time(void);
37 extern int omap_gpio_init(void);
39 static struct plat_serial8250_port voiceblue_ports
[] = {
41 .mapbase
= (unsigned long)(OMAP_CS1_PHYS
+ 0x40000),
42 .irq
= OMAP_GPIO_IRQ(12),
43 .flags
= UPF_BOOT_AUTOCONF
| UPF_IOREMAP
,
49 .mapbase
= (unsigned long)(OMAP_CS1_PHYS
+ 0x50000),
50 .irq
= OMAP_GPIO_IRQ(13),
51 .flags
= UPF_BOOT_AUTOCONF
| UPF_IOREMAP
,
57 .mapbase
= (unsigned long)(OMAP_CS1_PHYS
+ 0x60000),
58 .irq
= OMAP_GPIO_IRQ(14),
59 .flags
= UPF_BOOT_AUTOCONF
| UPF_IOREMAP
,
65 .mapbase
= (unsigned long)(OMAP_CS1_PHYS
+ 0x70000),
66 .irq
= OMAP_GPIO_IRQ(15),
67 .flags
= UPF_BOOT_AUTOCONF
| UPF_IOREMAP
,
75 static struct platform_device serial_device
= {
79 .platform_data
= voiceblue_ports
,
83 static int __init
ext_uart_init(void)
85 return platform_device_register(&serial_device
);
87 arch_initcall(ext_uart_init
);
89 static struct resource voiceblue_smc91x_resources
[] = {
91 .start
= OMAP_CS2_PHYS
+ 0x300,
92 .end
= OMAP_CS2_PHYS
+ 0x300 + 16,
93 .flags
= IORESOURCE_MEM
,
96 .start
= OMAP_GPIO_IRQ(8),
97 .end
= OMAP_GPIO_IRQ(8),
98 .flags
= IORESOURCE_IRQ
,
102 static struct platform_device voiceblue_smc91x_device
= {
105 .num_resources
= ARRAY_SIZE(voiceblue_smc91x_resources
),
106 .resource
= voiceblue_smc91x_resources
,
109 static struct platform_device
*voiceblue_devices
[] __initdata
= {
110 &voiceblue_smc91x_device
,
113 static struct omap_usb_config voiceblue_usb_config __initdata
= {
122 static struct omap_board_config_kernel voiceblue_config
[] = {
123 { OMAP_TAG_USB
, &voiceblue_usb_config
},
126 static void __init
voiceblue_init_irq(void)
132 static void __init
voiceblue_init(void)
134 /* There is a good chance board is going up, so enable Power LED
135 * (it is connected through invertor) */
136 omap_writeb(0x00, OMAP_LPG1_LCR
);
138 omap_request_gpio(0);
140 omap_request_gpio(7);
141 omap_set_gpio_direction(7, 0);
142 omap_set_gpio_dataout(7, 1);
143 udelay(2); /* wait at least 100ns */
144 omap_set_gpio_dataout(7, 0);
145 mdelay(50); /* 50ms until PHY ready */
146 /* smc91x interrupt pin */
147 omap_request_gpio(8);
148 omap_set_gpio_edge_ctrl(8, OMAP_GPIO_RISING_EDGE
);
150 omap_request_gpio(6);
151 omap_set_gpio_direction(6, 0);
152 omap_set_gpio_dataout(6, 0);
153 /* 16C554 interrupt pins */
154 omap_request_gpio(12);
155 omap_request_gpio(13);
156 omap_request_gpio(14);
157 omap_request_gpio(15);
158 omap_set_gpio_edge_ctrl(12, OMAP_GPIO_RISING_EDGE
);
159 omap_set_gpio_edge_ctrl(13, OMAP_GPIO_RISING_EDGE
);
160 omap_set_gpio_edge_ctrl(14, OMAP_GPIO_RISING_EDGE
);
161 omap_set_gpio_edge_ctrl(15, OMAP_GPIO_RISING_EDGE
);
163 platform_add_devices(voiceblue_devices
, ARRAY_SIZE(voiceblue_devices
));
164 omap_board_config
= voiceblue_config
;
165 omap_board_config_size
= ARRAY_SIZE(voiceblue_config
);
168 static int __initdata omap_serial_ports
[OMAP_MAX_NR_PORTS
] = {1, 1, 1};
170 static void __init
voiceblue_map_io(void)
172 omap_map_common_io();
173 omap_serial_init(omap_serial_ports
);
176 #define MACHINE_PANICED 1
177 #define MACHINE_REBOOTING 2
178 #define MACHINE_REBOOT 4
179 static unsigned long machine_state
;
181 static int panic_event(struct notifier_block
*this, unsigned long event
,
184 if (test_and_set_bit(MACHINE_PANICED
, &machine_state
))
188 * (TODO: Enable clock right way (enabled in bootloader already)) */
189 omap_writeb(0x78, OMAP_LPG1_LCR
);
194 static struct notifier_block panic_block
= {
195 .notifier_call
= panic_event
,
198 static int __init
setup_notifier(void)
200 /* Setup panic notifier */
201 notifier_chain_register(&panic_notifier_list
, &panic_block
);
206 postcore_initcall(setup_notifier
);
208 static int wdt_gpio_state
;
210 void voiceblue_wdt_enable(void)
212 omap_set_gpio_direction(0, 0);
213 omap_set_gpio_dataout(0, 0);
214 omap_set_gpio_dataout(0, 1);
215 omap_set_gpio_dataout(0, 0);
219 void voiceblue_wdt_disable(void)
221 omap_set_gpio_dataout(0, 0);
222 omap_set_gpio_dataout(0, 1);
223 omap_set_gpio_dataout(0, 0);
224 omap_set_gpio_direction(0, 1);
227 void voiceblue_wdt_ping(void)
229 if (test_bit(MACHINE_REBOOT
, &machine_state
))
232 wdt_gpio_state
= !wdt_gpio_state
;
233 omap_set_gpio_dataout(0, wdt_gpio_state
);
236 void voiceblue_reset(void)
238 set_bit(MACHINE_REBOOT
, &machine_state
);
239 voiceblue_wdt_enable();
243 EXPORT_SYMBOL(voiceblue_wdt_enable
);
244 EXPORT_SYMBOL(voiceblue_wdt_disable
);
245 EXPORT_SYMBOL(voiceblue_wdt_ping
);
247 MACHINE_START(VOICEBLUE
, "VoiceBlue OMAP5910")
248 /* Maintainer: Ladislav Michl <michl@2n.cz> */
249 .phys_ram
= 0x10000000,
250 .phys_io
= 0xfff00000,
251 .io_pg_offst
= ((0xfef00000) >> 18) & 0xfffc,
252 .boot_params
= 0x10000100,
253 .map_io
= voiceblue_map_io
,
254 .init_irq
= voiceblue_init_irq
,
255 .init_machine
= voiceblue_init
,
256 .timer
= &omap_timer
,