2 * arch/arm/mach-kirkwood/netxbig_v2-setup.c
4 * LaCie 2Big and 5Big Network v2 board setup
6 * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25 #include <linux/platform_device.h>
26 #include <linux/mtd/physmap.h>
27 #include <linux/spi/flash.h>
28 #include <linux/spi/spi.h>
29 #include <linux/ata_platform.h>
30 #include <linux/mv643xx_eth.h>
31 #include <linux/i2c.h>
32 #include <linux/i2c/at24.h>
33 #include <linux/input.h>
34 #include <linux/gpio.h>
35 #include <linux/gpio_keys.h>
36 #include <linux/leds.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/time.h>
40 #include <mach/kirkwood.h>
41 #include <plat/time.h>
45 /*****************************************************************************
46 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
47 ****************************************************************************/
49 static struct mtd_partition netxbig_v2_flash_parts
[] = {
52 .size
= MTDPART_SIZ_FULL
,
54 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
58 static const struct flash_platform_data netxbig_v2_flash
= {
61 .parts
= netxbig_v2_flash_parts
,
62 .nr_parts
= ARRAY_SIZE(netxbig_v2_flash_parts
),
65 static struct spi_board_info __initdata netxbig_v2_spi_slave_info
[] = {
68 .platform_data
= &netxbig_v2_flash
,
70 .max_speed_hz
= 20000000,
76 /*****************************************************************************
78 ****************************************************************************/
80 static struct mv643xx_eth_platform_data netxbig_v2_ge00_data
= {
81 .phy_addr
= MV643XX_ETH_PHY_ADDR(8),
84 static struct mv643xx_eth_platform_data netxbig_v2_ge01_data
= {
85 .phy_addr
= MV643XX_ETH_PHY_ADDR(0),
88 /*****************************************************************************
90 ****************************************************************************/
92 static struct at24_platform_data at24c04
= {
93 .byte_len
= SZ_4K
/ 8,
98 * i2c addr | chip | description
99 * 0x50 | HT24LC04 | eeprom (512B)
102 static struct i2c_board_info __initdata netxbig_v2_i2c_info
[] = {
104 I2C_BOARD_INFO("24c04", 0x50),
105 .platform_data
= &at24c04
,
109 /*****************************************************************************
111 ****************************************************************************/
113 static struct mv_sata_platform_data netxbig_v2_sata_data
= {
117 static int __initdata netxbig_v2_gpio_hdd_power
[] = { 16, 17, 41, 42, 43 };
119 static void __init
netxbig_v2_sata_power_init(void)
125 if (machine_is_net2big_v2())
130 /* Power up all hard disks. */
131 for (i
= 0; i
< hdd_nb
; i
++) {
132 err
= gpio_request(netxbig_v2_gpio_hdd_power
[i
], NULL
);
134 err
= gpio_direction_output(
135 netxbig_v2_gpio_hdd_power
[i
], 1);
136 /* Free the HDD power GPIOs. This allow user-space to
137 * configure them via the gpiolib sysfs interface. */
138 gpio_free(netxbig_v2_gpio_hdd_power
[i
]);
141 pr_err("netxbig_v2: failed to power up HDD%d\n", i
+ 1);
145 /*****************************************************************************
147 ****************************************************************************/
149 #define NETXBIG_V2_GPIO_SWITCH_POWER_ON 13
150 #define NETXBIG_V2_GPIO_SWITCH_POWER_OFF 15
151 #define NETXBIG_V2_GPIO_FUNC_BUTTON 34
153 #define NETXBIG_V2_SWITCH_POWER_ON 0x1
154 #define NETXBIG_V2_SWITCH_POWER_OFF 0x2
156 static struct gpio_keys_button netxbig_v2_buttons
[] = {
159 .code
= NETXBIG_V2_SWITCH_POWER_ON
,
160 .gpio
= NETXBIG_V2_GPIO_SWITCH_POWER_ON
,
161 .desc
= "Back power switch (on|auto)",
166 .code
= NETXBIG_V2_SWITCH_POWER_OFF
,
167 .gpio
= NETXBIG_V2_GPIO_SWITCH_POWER_OFF
,
168 .desc
= "Back power switch (auto|off)",
173 .gpio
= NETXBIG_V2_GPIO_FUNC_BUTTON
,
174 .desc
= "Function button",
179 static struct gpio_keys_platform_data netxbig_v2_button_data
= {
180 .buttons
= netxbig_v2_buttons
,
181 .nbuttons
= ARRAY_SIZE(netxbig_v2_buttons
),
184 static struct platform_device netxbig_v2_gpio_buttons
= {
188 .platform_data
= &netxbig_v2_button_data
,
192 /*****************************************************************************
194 ****************************************************************************/
197 * The LEDs are controlled by a CPLD and can be configured through a GPIO
200 * - address register : bit [0-2] -> GPIO [47-49]
201 * - data register : bit [0-2] -> GPIO [44-46]
202 * - enable register : GPIO 29
204 * Address register selection:
207 * ----------------------------
209 * 1 | front LED brightness
210 * 2 | HDD LED brightness
217 * Data register configuration:
219 * data | LED brightness
220 * -------------------------------------------------
225 * data | front LED mode
226 * -------------------------------------------------
230 * 3 | blink blue on=1 sec and blue off=1 sec
231 * 4 | blink red on=1 sec and red off=1 sec
232 * 5 | blink blue on=2.5 sec and red on=0.5 sec
233 * 6 | blink blue on=1 sec and red on=1 sec
234 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
236 * data | HDD LED mode
237 * -------------------------------------------------
239 * 1 | SATA activity blink
241 * 3 | blink blue on=1 sec and blue off=1 sec
242 * 4 | blink red on=1 sec and red off=1 sec
243 * 5 | blink blue on=2.5 sec and red on=0.5 sec
244 * 6 | blink blue on=1 sec and red on=1 sec
245 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
248 /*****************************************************************************
250 ****************************************************************************/
252 static void netxbig_v2_timer_init(void)
254 kirkwood_tclk
= 166666667;
255 orion_time_init(IRQ_KIRKWOOD_BRIDGE
, kirkwood_tclk
);
258 struct sys_timer netxbig_v2_timer
= {
259 .init
= netxbig_v2_timer_init
,
262 /*****************************************************************************
264 ****************************************************************************/
266 static unsigned int net2big_v2_mpp_config
[] __initdata
= {
272 MPP7_GPO
, /* Request power-off */
277 MPP13_GPIO
, /* Rear power switch (on|auto) */
278 MPP14_GPIO
, /* USB fuse alarm */
279 MPP15_GPIO
, /* Rear power switch (auto|off) */
280 MPP16_GPIO
, /* SATA HDD1 power */
281 MPP17_GPIO
, /* SATA HDD2 power */
284 MPP24_GPIO
, /* USB mode select */
285 MPP26_GPIO
, /* USB device vbus */
286 MPP28_GPIO
, /* USB enable host vbus */
287 MPP29_GPIO
, /* CPLD extension ALE */
288 MPP34_GPIO
, /* Rear Push button */
289 MPP35_GPIO
, /* Inhibit switch power-off */
290 MPP36_GPIO
, /* SATA HDD1 presence */
291 MPP37_GPIO
, /* SATA HDD2 presence */
292 MPP40_GPIO
, /* eSATA presence */
293 MPP44_GPIO
, /* CPLD extension (data 0) */
294 MPP45_GPIO
, /* CPLD extension (data 1) */
295 MPP46_GPIO
, /* CPLD extension (data 2) */
296 MPP47_GPIO
, /* CPLD extension (addr 0) */
297 MPP48_GPIO
, /* CPLD extension (addr 1) */
298 MPP49_GPIO
, /* CPLD extension (addr 2) */
302 static unsigned int net5big_v2_mpp_config
[] __initdata
= {
308 MPP7_GPO
, /* Request power-off */
313 MPP13_GPIO
, /* Rear power switch (on|auto) */
314 MPP14_GPIO
, /* USB fuse alarm */
315 MPP15_GPIO
, /* Rear power switch (auto|off) */
316 MPP16_GPIO
, /* SATA HDD1 power */
317 MPP17_GPIO
, /* SATA HDD2 power */
326 MPP28_GPIO
, /* USB enable host vbus */
327 MPP29_GPIO
, /* CPLD extension ALE */
332 MPP34_GPIO
, /* Rear Push button */
333 MPP35_GPIO
, /* Inhibit switch power-off */
334 MPP36_GPIO
, /* SATA HDD1 presence */
335 MPP37_GPIO
, /* SATA HDD2 presence */
336 MPP38_GPIO
, /* SATA HDD3 presence */
337 MPP39_GPIO
, /* SATA HDD4 presence */
338 MPP40_GPIO
, /* SATA HDD5 presence */
339 MPP41_GPIO
, /* SATA HDD3 power */
340 MPP42_GPIO
, /* SATA HDD4 power */
341 MPP43_GPIO
, /* SATA HDD5 power */
342 MPP44_GPIO
, /* CPLD extension (data 0) */
343 MPP45_GPIO
, /* CPLD extension (data 1) */
344 MPP46_GPIO
, /* CPLD extension (data 2) */
345 MPP47_GPIO
, /* CPLD extension (addr 0) */
346 MPP48_GPIO
, /* CPLD extension (addr 1) */
347 MPP49_GPIO
, /* CPLD extension (addr 2) */
351 #define NETXBIG_V2_GPIO_POWER_OFF 7
353 static void netxbig_v2_power_off(void)
355 gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF
, 1);
358 static void __init
netxbig_v2_init(void)
361 * Basic setup. Needs to be called early.
364 if (machine_is_net2big_v2())
365 kirkwood_mpp_conf(net2big_v2_mpp_config
);
367 kirkwood_mpp_conf(net5big_v2_mpp_config
);
369 netxbig_v2_sata_power_init();
371 kirkwood_ehci_init();
372 kirkwood_ge00_init(&netxbig_v2_ge00_data
);
373 if (machine_is_net5big_v2())
374 kirkwood_ge01_init(&netxbig_v2_ge01_data
);
375 kirkwood_sata_init(&netxbig_v2_sata_data
);
376 kirkwood_uart0_init();
377 spi_register_board_info(netxbig_v2_spi_slave_info
,
378 ARRAY_SIZE(netxbig_v2_spi_slave_info
));
381 i2c_register_board_info(0, netxbig_v2_i2c_info
,
382 ARRAY_SIZE(netxbig_v2_i2c_info
));
384 platform_device_register(&netxbig_v2_gpio_buttons
);
386 if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF
, "power-off") == 0 &&
387 gpio_direction_output(NETXBIG_V2_GPIO_POWER_OFF
, 0) == 0)
388 pm_power_off
= netxbig_v2_power_off
;
390 pr_err("netxbig_v2: failed to configure power-off GPIO\n");
393 #ifdef CONFIG_MACH_NET2BIG_V2
394 MACHINE_START(NET2BIG_V2
, "LaCie 2Big Network v2")
395 .phys_io
= KIRKWOOD_REGS_PHYS_BASE
,
396 .io_pg_offst
= ((KIRKWOOD_REGS_VIRT_BASE
) >> 18) & 0xfffc,
397 .boot_params
= 0x00000100,
398 .init_machine
= netxbig_v2_init
,
399 .map_io
= kirkwood_map_io
,
400 .init_irq
= kirkwood_init_irq
,
401 .timer
= &netxbig_v2_timer
,
405 #ifdef CONFIG_MACH_NET5BIG_V2
406 MACHINE_START(NET5BIG_V2
, "LaCie 5Big Network v2")
407 .phys_io
= KIRKWOOD_REGS_PHYS_BASE
,
408 .io_pg_offst
= ((KIRKWOOD_REGS_VIRT_BASE
) >> 18) & 0xfffc,
409 .boot_params
= 0x00000100,
410 .init_machine
= netxbig_v2_init
,
411 .map_io
= kirkwood_map_io
,
412 .init_irq
= kirkwood_init_irq
,
413 .timer
= &netxbig_v2_timer
,