1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <linux/platform_device.h>
27#include <linux/ata_platform.h>
28#include <linux/mv643xx_eth.h>
29#include <linux/input.h>
30#include <linux/gpio.h>
31#include <linux/gpio_keys.h>
32#include <linux/leds.h>
33#include <linux/gpio-fan.h>
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <mach/kirkwood.h>
37#include <mach/leds-ns2.h>
38#include "common.h"
39#include "mpp.h"
40#include "lacie_v2-common.h"
41
42
43
44
45
46static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
47 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
48};
49
50
51
52
53
54static struct mv_sata_platform_data netspace_v2_sata_data = {
55 .n_ports = 2,
56};
57
58
59
60
61
62#define NETSPACE_V2_PUSH_BUTTON 32
63
64static struct gpio_keys_button netspace_v2_buttons[] = {
65 [0] = {
66 .code = KEY_POWER,
67 .gpio = NETSPACE_V2_PUSH_BUTTON,
68 .desc = "Power push button",
69 .active_low = 0,
70 },
71};
72
73static struct gpio_keys_platform_data netspace_v2_button_data = {
74 .buttons = netspace_v2_buttons,
75 .nbuttons = ARRAY_SIZE(netspace_v2_buttons),
76};
77
78static struct platform_device netspace_v2_gpio_buttons = {
79 .name = "gpio-keys",
80 .id = -1,
81 .dev = {
82 .platform_data = &netspace_v2_button_data,
83 },
84};
85
86
87
88
89
90#define NETSPACE_V2_GPIO_RED_LED 12
91
92static struct gpio_led netspace_v2_gpio_led_pins[] = {
93 {
94 .name = "ns_v2:red:fail",
95 .gpio = NETSPACE_V2_GPIO_RED_LED,
96 },
97};
98
99static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {
100 .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins),
101 .leds = netspace_v2_gpio_led_pins,
102};
103
104static struct platform_device netspace_v2_gpio_leds = {
105 .name = "leds-gpio",
106 .id = -1,
107 .dev = {
108 .platform_data = &netspace_v2_gpio_leds_data,
109 },
110};
111
112
113
114
115
116#define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
117#define NETSPACE_V2_GPIO_BLUE_LED_CMD 30
118
119static struct ns2_led netspace_v2_led_pins[] = {
120 {
121 .name = "ns_v2:blue:sata",
122 .cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD,
123 .slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW,
124 },
125};
126
127static struct ns2_led_platform_data netspace_v2_leds_data = {
128 .num_leds = ARRAY_SIZE(netspace_v2_led_pins),
129 .leds = netspace_v2_led_pins,
130};
131
132static struct platform_device netspace_v2_leds = {
133 .name = "leds-ns2",
134 .id = -1,
135 .dev = {
136 .platform_data = &netspace_v2_leds_data,
137 },
138};
139
140
141
142
143
144
145static struct gpio_fan_speed netspace_max_v2_fan_speed[] = {
146 { 0, 0 },
147 { 1500, 15 },
148 { 1700, 14 },
149 { 1800, 13 },
150 { 2100, 12 },
151 { 3100, 11 },
152 { 3300, 10 },
153 { 4300, 9 },
154 { 5500, 8 },
155};
156
157static unsigned netspace_max_v2_fan_ctrl[] = { 22, 7, 33, 23 };
158
159static struct gpio_fan_alarm netspace_max_v2_fan_alarm = {
160 .gpio = 25,
161 .active_low = 1,
162};
163
164static struct gpio_fan_platform_data netspace_max_v2_fan_data = {
165 .num_ctrl = ARRAY_SIZE(netspace_max_v2_fan_ctrl),
166 .ctrl = netspace_max_v2_fan_ctrl,
167 .alarm = &netspace_max_v2_fan_alarm,
168 .num_speed = ARRAY_SIZE(netspace_max_v2_fan_speed),
169 .speed = netspace_max_v2_fan_speed,
170};
171
172static struct platform_device netspace_max_v2_gpio_fan = {
173 .name = "gpio-fan",
174 .id = -1,
175 .dev = {
176 .platform_data = &netspace_max_v2_fan_data,
177 },
178};
179
180
181
182
183
184static unsigned int netspace_v2_mpp_config[] __initdata = {
185 MPP0_SPI_SCn,
186 MPP1_SPI_MOSI,
187 MPP2_SPI_SCK,
188 MPP3_SPI_MISO,
189 MPP4_NF_IO6,
190 MPP5_NF_IO7,
191 MPP6_SYSRST_OUTn,
192 MPP7_GPO,
193 MPP8_TW0_SDA,
194 MPP9_TW0_SCK,
195 MPP10_UART0_TXD,
196 MPP11_UART0_RXD,
197 MPP12_GPO,
198 MPP14_GPIO,
199 MPP16_GPIO,
200 MPP17_GPIO,
201 MPP18_NF_IO0,
202 MPP19_NF_IO1,
203 MPP20_SATA1_ACTn,
204 MPP21_SATA0_ACTn,
205 MPP22_GPIO,
206 MPP23_GPIO,
207 MPP24_GPIO,
208 MPP25_GPIO,
209 MPP26_GPIO,
210 MPP28_GPIO,
211 MPP29_GPIO,
212 MPP30_GPIO,
213 MPP31_GPIO,
214 MPP32_GPIO,
215 MPP33_GPO,
216 0
217};
218
219#define NETSPACE_V2_GPIO_POWER_OFF 31
220
221static void netspace_v2_power_off(void)
222{
223 gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);
224}
225
226static void __init netspace_v2_init(void)
227{
228
229
230
231 kirkwood_init();
232 kirkwood_mpp_conf(netspace_v2_mpp_config);
233
234 if (machine_is_netspace_max_v2())
235 lacie_v2_hdd_power_init(2);
236 else
237 lacie_v2_hdd_power_init(1);
238
239 kirkwood_ehci_init();
240 kirkwood_ge00_init(&netspace_v2_ge00_data);
241 kirkwood_sata_init(&netspace_v2_sata_data);
242 kirkwood_uart0_init();
243 lacie_v2_register_flash();
244 lacie_v2_register_i2c_devices();
245
246 platform_device_register(&netspace_v2_leds);
247 platform_device_register(&netspace_v2_gpio_leds);
248 platform_device_register(&netspace_v2_gpio_buttons);
249 if (machine_is_netspace_max_v2())
250 platform_device_register(&netspace_max_v2_gpio_fan);
251
252 if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
253 gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
254 pm_power_off = netspace_v2_power_off;
255 else
256 pr_err("netspace_v2: failed to configure power-off GPIO\n");
257}
258
259#ifdef CONFIG_MACH_NETSPACE_V2
260MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
261 .atag_offset = 0x100,
262 .init_machine = netspace_v2_init,
263 .map_io = kirkwood_map_io,
264 .init_early = kirkwood_init_early,
265 .init_irq = kirkwood_init_irq,
266 .timer = &kirkwood_timer,
267 .restart = kirkwood_restart,
268MACHINE_END
269#endif
270
271#ifdef CONFIG_MACH_INETSPACE_V2
272MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
273 .atag_offset = 0x100,
274 .init_machine = netspace_v2_init,
275 .map_io = kirkwood_map_io,
276 .init_early = kirkwood_init_early,
277 .init_irq = kirkwood_init_irq,
278 .timer = &kirkwood_timer,
279 .restart = kirkwood_restart,
280MACHINE_END
281#endif
282
283#ifdef CONFIG_MACH_NETSPACE_MAX_V2
284MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
285 .atag_offset = 0x100,
286 .init_machine = netspace_v2_init,
287 .map_io = kirkwood_map_io,
288 .init_early = kirkwood_init_early,
289 .init_irq = kirkwood_init_irq,
290 .timer = &kirkwood_timer,
291 .restart = kirkwood_restart,
292MACHINE_END
293#endif
294