1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/platform_device.h>
26#include <linux/ata_platform.h>
27#include <linux/mv643xx_eth.h>
28#include <linux/input.h>
29#include <linux/gpio.h>
30#include <linux/gpio_keys.h>
31#include <linux/leds.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <mach/kirkwood.h>
35#include <mach/leds-netxbig.h>
36#include "common.h"
37#include "mpp.h"
38#include "lacie_v2-common.h"
39
40
41
42
43
44static struct mv643xx_eth_platform_data netxbig_v2_ge00_data = {
45 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
46};
47
48static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = {
49 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
50};
51
52
53
54
55
56static struct mv_sata_platform_data netxbig_v2_sata_data = {
57 .n_ports = 2,
58};
59
60
61
62
63
64#define NETXBIG_V2_GPIO_SWITCH_POWER_ON 13
65#define NETXBIG_V2_GPIO_SWITCH_POWER_OFF 15
66#define NETXBIG_V2_GPIO_FUNC_BUTTON 34
67
68#define NETXBIG_V2_SWITCH_POWER_ON 0x1
69#define NETXBIG_V2_SWITCH_POWER_OFF 0x2
70
71static struct gpio_keys_button netxbig_v2_buttons[] = {
72 [0] = {
73 .type = EV_SW,
74 .code = NETXBIG_V2_SWITCH_POWER_ON,
75 .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_ON,
76 .desc = "Back power switch (on|auto)",
77 .active_low = 1,
78 },
79 [1] = {
80 .type = EV_SW,
81 .code = NETXBIG_V2_SWITCH_POWER_OFF,
82 .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_OFF,
83 .desc = "Back power switch (auto|off)",
84 .active_low = 1,
85 },
86 [2] = {
87 .code = KEY_OPTION,
88 .gpio = NETXBIG_V2_GPIO_FUNC_BUTTON,
89 .desc = "Function button",
90 .active_low = 1,
91 },
92};
93
94static struct gpio_keys_platform_data netxbig_v2_button_data = {
95 .buttons = netxbig_v2_buttons,
96 .nbuttons = ARRAY_SIZE(netxbig_v2_buttons),
97};
98
99static struct platform_device netxbig_v2_gpio_buttons = {
100 .name = "gpio-keys",
101 .id = -1,
102 .dev = {
103 .platform_data = &netxbig_v2_button_data,
104 },
105};
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120static int netxbig_v2_gpio_ext_addr[] = { 47, 48, 49 };
121static int netxbig_v2_gpio_ext_data[] = { 44, 45, 46 };
122
123static struct netxbig_gpio_ext netxbig_v2_gpio_ext = {
124 .addr = netxbig_v2_gpio_ext_addr,
125 .num_addr = ARRAY_SIZE(netxbig_v2_gpio_ext_addr),
126 .data = netxbig_v2_gpio_ext_data,
127 .num_data = ARRAY_SIZE(netxbig_v2_gpio_ext_data),
128 .enable = 29,
129};
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM] = {
177 [NETXBIG_LED_OFF] = 0,
178 [NETXBIG_LED_ON] = 2,
179 [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,
180 [NETXBIG_LED_TIMER1] = 4,
181 [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,
182};
183
184static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM] = {
185 [NETXBIG_LED_OFF] = 0,
186 [NETXBIG_LED_ON] = 1,
187 [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,
188 [NETXBIG_LED_TIMER1] = 3,
189 [NETXBIG_LED_TIMER2] = 7,
190};
191
192static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM] = {
193 [NETXBIG_LED_OFF] = 0,
194 [NETXBIG_LED_ON] = 7,
195 [NETXBIG_LED_SATA] = 1,
196 [NETXBIG_LED_TIMER1] = 3,
197 [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,
198};
199
200static struct netxbig_led_timer netxbig_v2_led_timer[] = {
201 [0] = {
202 .delay_on = 500,
203 .delay_off = 500,
204 .mode = NETXBIG_LED_TIMER1,
205 },
206 [1] = {
207 .delay_on = 500,
208 .delay_off = 1000,
209 .mode = NETXBIG_LED_TIMER2,
210 },
211};
212
213#define NETXBIG_LED(_name, maddr, mval, baddr) \
214 { .name = _name, \
215 .mode_addr = maddr, \
216 .mode_val = mval, \
217 .bright_addr = baddr }
218
219static struct netxbig_led net2big_v2_leds_ctrl[] = {
220 NETXBIG_LED("net2big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),
221 NETXBIG_LED("net2big-v2:red:power", 0, netxbig_v2_red_mled, 1),
222 NETXBIG_LED("net2big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),
223 NETXBIG_LED("net2big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),
224 NETXBIG_LED("net2big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),
225 NETXBIG_LED("net2big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),
226};
227
228static struct netxbig_led_platform_data net2big_v2_leds_data = {
229 .gpio_ext = &netxbig_v2_gpio_ext,
230 .timer = netxbig_v2_led_timer,
231 .num_timer = ARRAY_SIZE(netxbig_v2_led_timer),
232 .leds = net2big_v2_leds_ctrl,
233 .num_leds = ARRAY_SIZE(net2big_v2_leds_ctrl),
234};
235
236static struct netxbig_led net5big_v2_leds_ctrl[] = {
237 NETXBIG_LED("net5big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),
238 NETXBIG_LED("net5big-v2:red:power", 0, netxbig_v2_red_mled, 1),
239 NETXBIG_LED("net5big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),
240 NETXBIG_LED("net5big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),
241 NETXBIG_LED("net5big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),
242 NETXBIG_LED("net5big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),
243 NETXBIG_LED("net5big-v2:blue:sata2", 5, netxbig_v2_blue_sata_mled, 2),
244 NETXBIG_LED("net5big-v2:red:sata2", 5, netxbig_v2_red_mled, 2),
245 NETXBIG_LED("net5big-v2:blue:sata3", 6, netxbig_v2_blue_sata_mled, 2),
246 NETXBIG_LED("net5big-v2:red:sata3", 6, netxbig_v2_red_mled, 2),
247 NETXBIG_LED("net5big-v2:blue:sata4", 7, netxbig_v2_blue_sata_mled, 2),
248 NETXBIG_LED("net5big-v2:red:sata5", 7, netxbig_v2_red_mled, 2),
249};
250
251static struct netxbig_led_platform_data net5big_v2_leds_data = {
252 .gpio_ext = &netxbig_v2_gpio_ext,
253 .timer = netxbig_v2_led_timer,
254 .num_timer = ARRAY_SIZE(netxbig_v2_led_timer),
255 .leds = net5big_v2_leds_ctrl,
256 .num_leds = ARRAY_SIZE(net5big_v2_leds_ctrl),
257};
258
259static struct platform_device netxbig_v2_leds = {
260 .name = "leds-netxbig",
261 .id = -1,
262 .dev = {
263 .platform_data = &net2big_v2_leds_data,
264 },
265};
266
267
268
269
270
271static unsigned int net2big_v2_mpp_config[] __initdata = {
272 MPP0_SPI_SCn,
273 MPP1_SPI_MOSI,
274 MPP2_SPI_SCK,
275 MPP3_SPI_MISO,
276 MPP6_SYSRST_OUTn,
277 MPP7_GPO,
278 MPP8_TW0_SDA,
279 MPP9_TW0_SCK,
280 MPP10_UART0_TXD,
281 MPP11_UART0_RXD,
282 MPP13_GPIO,
283 MPP14_GPIO,
284 MPP15_GPIO,
285 MPP16_GPIO,
286 MPP17_GPIO,
287 MPP20_SATA1_ACTn,
288 MPP21_SATA0_ACTn,
289 MPP24_GPIO,
290 MPP26_GPIO,
291 MPP28_GPIO,
292 MPP29_GPIO,
293 MPP34_GPIO,
294 MPP35_GPIO,
295 MPP36_GPIO,
296 MPP37_GPIO,
297 MPP40_GPIO,
298 MPP44_GPIO,
299 MPP45_GPIO,
300 MPP46_GPIO,
301 MPP47_GPIO,
302 MPP48_GPIO,
303 MPP49_GPIO,
304 0
305};
306
307static unsigned int net5big_v2_mpp_config[] __initdata = {
308 MPP0_SPI_SCn,
309 MPP1_SPI_MOSI,
310 MPP2_SPI_SCK,
311 MPP3_SPI_MISO,
312 MPP6_SYSRST_OUTn,
313 MPP7_GPO,
314 MPP8_TW0_SDA,
315 MPP9_TW0_SCK,
316 MPP10_UART0_TXD,
317 MPP11_UART0_RXD,
318 MPP13_GPIO,
319 MPP14_GPIO,
320 MPP15_GPIO,
321 MPP16_GPIO,
322 MPP17_GPIO,
323 MPP20_GE1_TXD0,
324 MPP21_GE1_TXD1,
325 MPP22_GE1_TXD2,
326 MPP23_GE1_TXD3,
327 MPP24_GE1_RXD0,
328 MPP25_GE1_RXD1,
329 MPP26_GE1_RXD2,
330 MPP27_GE1_RXD3,
331 MPP28_GPIO,
332 MPP29_GPIO,
333 MPP30_GE1_RXCTL,
334 MPP31_GE1_RXCLK,
335 MPP32_GE1_TCLKOUT,
336 MPP33_GE1_TXCTL,
337 MPP34_GPIO,
338 MPP35_GPIO,
339 MPP36_GPIO,
340 MPP37_GPIO,
341 MPP38_GPIO,
342 MPP39_GPIO,
343 MPP40_GPIO,
344 MPP41_GPIO,
345 MPP42_GPIO,
346 MPP43_GPIO,
347 MPP44_GPIO,
348 MPP45_GPIO,
349 MPP46_GPIO,
350 MPP47_GPIO,
351 MPP48_GPIO,
352 MPP49_GPIO,
353 0
354};
355
356#define NETXBIG_V2_GPIO_POWER_OFF 7
357
358static void netxbig_v2_power_off(void)
359{
360 gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF, 1);
361}
362
363static void __init netxbig_v2_init(void)
364{
365
366
367
368 kirkwood_init();
369 if (machine_is_net2big_v2())
370 kirkwood_mpp_conf(net2big_v2_mpp_config);
371 else
372 kirkwood_mpp_conf(net5big_v2_mpp_config);
373
374 if (machine_is_net2big_v2())
375 lacie_v2_hdd_power_init(2);
376 else
377 lacie_v2_hdd_power_init(5);
378
379 kirkwood_ehci_init();
380 kirkwood_ge00_init(&netxbig_v2_ge00_data);
381 if (machine_is_net5big_v2())
382 kirkwood_ge01_init(&netxbig_v2_ge01_data);
383 kirkwood_sata_init(&netxbig_v2_sata_data);
384 kirkwood_uart0_init();
385 lacie_v2_register_flash();
386 lacie_v2_register_i2c_devices();
387
388 if (machine_is_net5big_v2())
389 netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data;
390 platform_device_register(&netxbig_v2_leds);
391 platform_device_register(&netxbig_v2_gpio_buttons);
392
393 if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&
394 gpio_direction_output(NETXBIG_V2_GPIO_POWER_OFF, 0) == 0)
395 pm_power_off = netxbig_v2_power_off;
396 else
397 pr_err("netxbig_v2: failed to configure power-off GPIO\n");
398}
399
400#ifdef CONFIG_MACH_NET2BIG_V2
401MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")
402 .boot_params = 0x00000100,
403 .init_machine = netxbig_v2_init,
404 .map_io = kirkwood_map_io,
405 .init_irq = kirkwood_init_irq,
406 .timer = &kirkwood_timer,
407MACHINE_END
408#endif
409
410#ifdef CONFIG_MACH_NET5BIG_V2
411MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")
412 .boot_params = 0x00000100,
413 .init_machine = netxbig_v2_init,
414 .map_io = kirkwood_map_io,
415 .init_irq = kirkwood_init_irq,
416 .timer = &kirkwood_timer,
417MACHINE_END
418#endif
419