Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Modified from board-generic.c | |
3 | * | |
4 | * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz> | |
5 | * | |
6 | * Code for Netstar OMAP board. | |
7 | * | |
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. | |
11 | */ | |
12 | ||
13 | #include <linux/delay.h> | |
14 | #include <linux/device.h> | |
15 | #include <linux/interrupt.h> | |
16 | #include <linux/init.h> | |
17 | #include <linux/kernel.h> | |
18 | #include <linux/notifier.h> | |
19 | #include <linux/reboot.h> | |
20 | ||
21 | #include <asm/hardware.h> | |
22 | #include <asm/mach-types.h> | |
23 | #include <asm/mach/arch.h> | |
24 | #include <asm/mach/map.h> | |
25 | ||
26 | #include <asm/arch/gpio.h> | |
27 | #include <asm/arch/mux.h> | |
28 | #include <asm/arch/usb.h> | |
d48af15e | 29 | #include <asm/arch/common.h> |
1da177e4 LT |
30 | |
31 | extern void __init omap_init_time(void); | |
32 | extern int omap_gpio_init(void); | |
33 | ||
34 | static struct resource netstar_smc91x_resources[] = { | |
35 | [0] = { | |
36 | .start = OMAP_CS1_PHYS + 0x300, | |
37 | .end = OMAP_CS1_PHYS + 0x300 + 16, | |
38 | .flags = IORESOURCE_MEM, | |
39 | }, | |
40 | [1] = { | |
41 | .start = OMAP_GPIO_IRQ(8), | |
42 | .end = OMAP_GPIO_IRQ(8), | |
43 | .flags = IORESOURCE_IRQ, | |
44 | }, | |
45 | }; | |
46 | ||
47 | static struct platform_device netstar_smc91x_device = { | |
48 | .name = "smc91x", | |
49 | .id = 0, | |
50 | .num_resources = ARRAY_SIZE(netstar_smc91x_resources), | |
51 | .resource = netstar_smc91x_resources, | |
52 | }; | |
53 | ||
54 | static struct platform_device *netstar_devices[] __initdata = { | |
55 | &netstar_smc91x_device, | |
56 | }; | |
57 | ||
58 | static void __init netstar_init_irq(void) | |
59 | { | |
60 | omap_init_irq(); | |
61 | omap_gpio_init(); | |
62 | } | |
63 | ||
64 | static void __init netstar_init(void) | |
65 | { | |
66 | /* green LED */ | |
67 | omap_request_gpio(4); | |
68 | omap_set_gpio_direction(4, 0); | |
69 | /* smc91x reset */ | |
70 | omap_request_gpio(7); | |
71 | omap_set_gpio_direction(7, 0); | |
72 | omap_set_gpio_dataout(7, 1); | |
73 | udelay(2); /* wait at least 100ns */ | |
74 | omap_set_gpio_dataout(7, 0); | |
75 | mdelay(50); /* 50ms until PHY ready */ | |
76 | /* smc91x interrupt pin */ | |
77 | omap_request_gpio(8); | |
1da177e4 LT |
78 | |
79 | omap_request_gpio(12); | |
80 | omap_request_gpio(13); | |
81 | omap_request_gpio(14); | |
82 | omap_request_gpio(15); | |
7c38cf02 TL |
83 | set_irq_type(OMAP_GPIO_IRQ(12), IRQT_FALLING); |
84 | set_irq_type(OMAP_GPIO_IRQ(13), IRQT_FALLING); | |
85 | set_irq_type(OMAP_GPIO_IRQ(14), IRQT_FALLING); | |
86 | set_irq_type(OMAP_GPIO_IRQ(15), IRQT_FALLING); | |
1da177e4 LT |
87 | |
88 | platform_add_devices(netstar_devices, ARRAY_SIZE(netstar_devices)); | |
89 | ||
90 | /* Switch on green LED */ | |
91 | omap_set_gpio_dataout(4, 0); | |
92 | /* Switch off red LED */ | |
93 | omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */ | |
94 | omap_writeb(0x80, OMAP_LPG1_LCR); | |
95 | } | |
96 | ||
97 | static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1}; | |
98 | ||
99 | static void __init netstar_map_io(void) | |
100 | { | |
d48af15e | 101 | omap_map_common_io(); |
1da177e4 LT |
102 | omap_serial_init(omap_serial_ports); |
103 | } | |
104 | ||
105 | #define MACHINE_PANICED 1 | |
106 | #define MACHINE_REBOOTING 2 | |
107 | #define MACHINE_REBOOT 4 | |
108 | static unsigned long machine_state; | |
109 | ||
110 | static int panic_event(struct notifier_block *this, unsigned long event, | |
111 | void *ptr) | |
112 | { | |
113 | if (test_and_set_bit(MACHINE_PANICED, &machine_state)) | |
114 | return NOTIFY_DONE; | |
115 | ||
116 | /* Switch off green LED */ | |
117 | omap_set_gpio_dataout(4, 1); | |
118 | /* Flash red LED */ | |
119 | omap_writeb(0x78, OMAP_LPG1_LCR); | |
120 | omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */ | |
121 | ||
122 | return NOTIFY_DONE; | |
123 | } | |
124 | ||
125 | static struct notifier_block panic_block = { | |
126 | .notifier_call = panic_event, | |
127 | }; | |
128 | ||
129 | static int __init netstar_late_init(void) | |
130 | { | |
131 | /* TODO: Setup front panel switch here */ | |
132 | ||
133 | /* Setup panic notifier */ | |
134 | notifier_chain_register(&panic_notifier_list, &panic_block); | |
135 | ||
136 | return 0; | |
137 | } | |
138 | ||
139 | postcore_initcall(netstar_late_init); | |
140 | ||
141 | MACHINE_START(NETSTAR, "NetStar OMAP5910") | |
e9dea0c6 RK |
142 | /* Maintainer: Ladislav Michl <michl@2n.cz> */ |
143 | .phys_ram = 0x10000000, | |
144 | .phys_io = 0xfff00000, | |
145 | .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc, | |
146 | .boot_params = 0x10000100, | |
147 | .map_io = netstar_map_io, | |
148 | .init_irq = netstar_init_irq, | |
149 | .init_machine = netstar_init, | |
150 | .timer = &omap_timer, | |
1da177e4 | 151 | MACHINE_END |