2 * arch/arm/mach-kirkwood/d2net_v2-setup.c
4 * LaCie d2 Network Space 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 <mach/leds-ns2.h>
42 #include <plat/time.h>
46 /*****************************************************************************
47 * 512KB SPI Flash on Boot Device
48 ****************************************************************************/
50 static struct mtd_partition d2net_v2_flash_parts[] = {
53 .size = MTDPART_SIZ_FULL,
55 .mask_flags = MTD_WRITEABLE,
59 static const struct flash_platform_data d2net_v2_flash = {
62 .parts = d2net_v2_flash_parts,
63 .nr_parts = ARRAY_SIZE(d2net_v2_flash_parts),
66 static struct spi_board_info __initdata d2net_v2_spi_slave_info[] = {
69 .platform_data = &d2net_v2_flash,
71 .max_speed_hz = 20000000,
77 /*****************************************************************************
79 ****************************************************************************/
81 static struct mv643xx_eth_platform_data d2net_v2_ge00_data = {
82 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
85 /*****************************************************************************
87 ****************************************************************************/
89 static struct at24_platform_data at24c04 = {
90 .byte_len = SZ_4K / 8,
95 * i2c addr | chip | description
96 * 0x50 | HT24LC04 | eeprom (512B)
99 static struct i2c_board_info __initdata d2net_v2_i2c_info[] = {
101 I2C_BOARD_INFO("24c04", 0x50),
102 .platform_data = &at24c04,
106 /*****************************************************************************
108 ****************************************************************************/
110 static struct mv_sata_platform_data d2net_v2_sata_data = {
114 #define D2NET_V2_GPIO_SATA0_POWER 16
116 static void __init d2net_v2_sata_power_init(void)
120 err = gpio_request(D2NET_V2_GPIO_SATA0_POWER, "SATA0 power");
122 err = gpio_direction_output(D2NET_V2_GPIO_SATA0_POWER, 1);
124 gpio_free(D2NET_V2_GPIO_SATA0_POWER);
127 pr_err("d2net_v2: failed to configure SATA0 power GPIO\n");
130 /*****************************************************************************
132 ****************************************************************************/
134 #define D2NET_V2_GPIO_PUSH_BUTTON 34
135 #define D2NET_V2_GPIO_POWER_SWITCH_ON 13
136 #define D2NET_V2_GPIO_POWER_SWITCH_OFF 15
138 #define D2NET_V2_SWITCH_POWER_ON 0x1
139 #define D2NET_V2_SWITCH_POWER_OFF 0x2
141 static struct gpio_keys_button d2net_v2_buttons[] = {
144 .code = D2NET_V2_SWITCH_POWER_ON,
145 .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON,
146 .desc = "Back power switch (on|auto)",
151 .code = D2NET_V2_SWITCH_POWER_OFF,
152 .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF,
153 .desc = "Back power switch (auto|off)",
158 .gpio = D2NET_V2_GPIO_PUSH_BUTTON,
159 .desc = "Front Push Button",
164 static struct gpio_keys_platform_data d2net_v2_button_data = {
165 .buttons = d2net_v2_buttons,
166 .nbuttons = ARRAY_SIZE(d2net_v2_buttons),
169 static struct platform_device d2net_v2_gpio_buttons = {
173 .platform_data = &d2net_v2_button_data,
177 /*****************************************************************************
179 ****************************************************************************/
181 #define D2NET_V2_GPIO_RED_LED 12
183 static struct gpio_led d2net_v2_gpio_led_pins[] = {
185 .name = "d2net_v2:red:fail",
186 .gpio = D2NET_V2_GPIO_RED_LED,
190 static struct gpio_led_platform_data d2net_v2_gpio_leds_data = {
191 .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins),
192 .leds = d2net_v2_gpio_led_pins,
195 static struct platform_device d2net_v2_gpio_leds = {
199 .platform_data = &d2net_v2_gpio_leds_data,
203 /*****************************************************************************
204 * Dual-GPIO CPLD LEDs
205 ****************************************************************************/
207 #define D2NET_V2_GPIO_BLUE_LED_SLOW 29
208 #define D2NET_V2_GPIO_BLUE_LED_CMD 30
210 static struct ns2_led d2net_v2_led_pins[] = {
212 .name = "d2net_v2:blue:sata",
213 .cmd = D2NET_V2_GPIO_BLUE_LED_CMD,
214 .slow = D2NET_V2_GPIO_BLUE_LED_SLOW,
218 static struct ns2_led_platform_data d2net_v2_leds_data = {
219 .num_leds = ARRAY_SIZE(d2net_v2_led_pins),
220 .leds = d2net_v2_led_pins,
223 static struct platform_device d2net_v2_leds = {
227 .platform_data = &d2net_v2_leds_data,
231 /*****************************************************************************
233 ****************************************************************************/
235 static void d2net_v2_timer_init(void)
237 kirkwood_tclk = 166666667;
238 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
241 struct sys_timer d2net_v2_timer = {
242 .init = d2net_v2_timer_init,
245 /*****************************************************************************
247 ****************************************************************************/
249 static unsigned int d2net_v2_mpp_config[] __initdata = {
255 MPP7_GPO, /* Request power-off */
260 MPP12_GPO, /* Red led */
261 MPP13_GPIO, /* Rear power switch (on|auto) */
262 MPP14_GPIO, /* USB fuse */
263 MPP15_GPIO, /* Rear power switch (auto|off) */
264 MPP16_GPIO, /* SATA 0 power */
266 MPP24_GPIO, /* USB mode select */
267 MPP26_GPIO, /* USB device vbus */
268 MPP28_GPIO, /* USB enable host vbus */
269 MPP29_GPIO, /* Blue led (slow register) */
270 MPP30_GPIO, /* Blue led (command register) */
271 MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */
272 MPP35_GPIO, /* Inhibit power-off */
276 #define D2NET_V2_GPIO_POWER_OFF 7
278 static void d2net_v2_power_off(void)
280 gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1);
283 static void __init d2net_v2_init(void)
286 * Basic setup. Needs to be called early.
289 kirkwood_mpp_conf(d2net_v2_mpp_config);
291 d2net_v2_sata_power_init();
293 kirkwood_ehci_init();
294 kirkwood_ge00_init(&d2net_v2_ge00_data);
295 kirkwood_sata_init(&d2net_v2_sata_data);
296 kirkwood_uart0_init();
297 spi_register_board_info(d2net_v2_spi_slave_info,
298 ARRAY_SIZE(d2net_v2_spi_slave_info));
301 i2c_register_board_info(0, d2net_v2_i2c_info,
302 ARRAY_SIZE(d2net_v2_i2c_info));
304 platform_device_register(&d2net_v2_leds);
305 platform_device_register(&d2net_v2_gpio_leds);
306 platform_device_register(&d2net_v2_gpio_buttons);
308 if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 &&
309 gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0)
310 pm_power_off = d2net_v2_power_off;
312 pr_err("d2net_v2: failed to configure power-off GPIO\n");
315 MACHINE_START(D2NET_V2, "LaCie d2 Network v2")
316 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
317 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
318 .boot_params = 0x00000100,
319 .init_machine = d2net_v2_init,
320 .map_io = kirkwood_map_io,
321 .init_irq = kirkwood_init_irq,
322 .timer = &d2net_v2_timer,