Merge remote-tracking branch 'leds/for-mm'
[linux-2.6/next.git] / arch / arm / mach-kirkwood / d2net_v2-setup.c
blob043cfd5e140b5d52823c5d429eec5591c3c24742
1 /*
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/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-ns2.h>
36 #include "common.h"
37 #include "mpp.h"
38 #include "lacie_v2-common.h"
40 /*****************************************************************************
41 * Ethernet
42 ****************************************************************************/
44 static struct mv643xx_eth_platform_data d2net_v2_ge00_data = {
45 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
48 /*****************************************************************************
49 * SATA
50 ****************************************************************************/
52 static struct mv_sata_platform_data d2net_v2_sata_data = {
53 .n_ports = 2,
56 /*****************************************************************************
57 * GPIO keys
58 ****************************************************************************/
60 #define D2NET_V2_GPIO_PUSH_BUTTON 34
61 #define D2NET_V2_GPIO_POWER_SWITCH_ON 13
62 #define D2NET_V2_GPIO_POWER_SWITCH_OFF 15
64 #define D2NET_V2_SWITCH_POWER_ON 0x1
65 #define D2NET_V2_SWITCH_POWER_OFF 0x2
67 static struct gpio_keys_button d2net_v2_buttons[] = {
68 [0] = {
69 .type = EV_SW,
70 .code = D2NET_V2_SWITCH_POWER_ON,
71 .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON,
72 .desc = "Back power switch (on|auto)",
73 .active_low = 0,
75 [1] = {
76 .type = EV_SW,
77 .code = D2NET_V2_SWITCH_POWER_OFF,
78 .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF,
79 .desc = "Back power switch (auto|off)",
80 .active_low = 0,
82 [2] = {
83 .code = KEY_POWER,
84 .gpio = D2NET_V2_GPIO_PUSH_BUTTON,
85 .desc = "Front Push Button",
86 .active_low = 1,
90 static struct gpio_keys_platform_data d2net_v2_button_data = {
91 .buttons = d2net_v2_buttons,
92 .nbuttons = ARRAY_SIZE(d2net_v2_buttons),
95 static struct platform_device d2net_v2_gpio_buttons = {
96 .name = "gpio-keys",
97 .id = -1,
98 .dev = {
99 .platform_data = &d2net_v2_button_data,
103 /*****************************************************************************
104 * GPIO LEDs
105 ****************************************************************************/
107 #define D2NET_V2_GPIO_RED_LED 12
109 static struct gpio_led d2net_v2_gpio_led_pins[] = {
111 .name = "d2net_v2:red:fail",
112 .gpio = D2NET_V2_GPIO_RED_LED,
116 static struct gpio_led_platform_data d2net_v2_gpio_leds_data = {
117 .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins),
118 .leds = d2net_v2_gpio_led_pins,
121 static struct platform_device d2net_v2_gpio_leds = {
122 .name = "leds-gpio",
123 .id = -1,
124 .dev = {
125 .platform_data = &d2net_v2_gpio_leds_data,
129 /*****************************************************************************
130 * Dual-GPIO CPLD LEDs
131 ****************************************************************************/
133 #define D2NET_V2_GPIO_BLUE_LED_SLOW 29
134 #define D2NET_V2_GPIO_BLUE_LED_CMD 30
136 static struct ns2_led d2net_v2_led_pins[] = {
138 .name = "d2net_v2:blue:sata",
139 .cmd = D2NET_V2_GPIO_BLUE_LED_CMD,
140 .slow = D2NET_V2_GPIO_BLUE_LED_SLOW,
144 static struct ns2_led_platform_data d2net_v2_leds_data = {
145 .num_leds = ARRAY_SIZE(d2net_v2_led_pins),
146 .leds = d2net_v2_led_pins,
149 static struct platform_device d2net_v2_leds = {
150 .name = "leds-ns2",
151 .id = -1,
152 .dev = {
153 .platform_data = &d2net_v2_leds_data,
157 /*****************************************************************************
158 * General Setup
159 ****************************************************************************/
161 static unsigned int d2net_v2_mpp_config[] __initdata = {
162 MPP0_SPI_SCn,
163 MPP1_SPI_MOSI,
164 MPP2_SPI_SCK,
165 MPP3_SPI_MISO,
166 MPP6_SYSRST_OUTn,
167 MPP7_GPO, /* Request power-off */
168 MPP8_TW0_SDA,
169 MPP9_TW0_SCK,
170 MPP10_UART0_TXD,
171 MPP11_UART0_RXD,
172 MPP12_GPO, /* Red led */
173 MPP13_GPIO, /* Rear power switch (on|auto) */
174 MPP14_GPIO, /* USB fuse */
175 MPP15_GPIO, /* Rear power switch (auto|off) */
176 MPP16_GPIO, /* SATA 0 power */
177 MPP21_SATA0_ACTn,
178 MPP24_GPIO, /* USB mode select */
179 MPP26_GPIO, /* USB device vbus */
180 MPP28_GPIO, /* USB enable host vbus */
181 MPP29_GPIO, /* Blue led (slow register) */
182 MPP30_GPIO, /* Blue led (command register) */
183 MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */
184 MPP35_GPIO, /* Inhibit power-off */
188 #define D2NET_V2_GPIO_POWER_OFF 7
190 static void d2net_v2_power_off(void)
192 gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1);
195 static void __init d2net_v2_init(void)
198 * Basic setup. Needs to be called early.
200 kirkwood_init();
201 kirkwood_mpp_conf(d2net_v2_mpp_config);
203 lacie_v2_hdd_power_init(1);
205 kirkwood_ehci_init();
206 kirkwood_ge00_init(&d2net_v2_ge00_data);
207 kirkwood_sata_init(&d2net_v2_sata_data);
208 kirkwood_uart0_init();
209 lacie_v2_register_flash();
210 lacie_v2_register_i2c_devices();
212 platform_device_register(&d2net_v2_leds);
213 platform_device_register(&d2net_v2_gpio_leds);
214 platform_device_register(&d2net_v2_gpio_buttons);
216 if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 &&
217 gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0)
218 pm_power_off = d2net_v2_power_off;
219 else
220 pr_err("d2net_v2: failed to configure power-off GPIO\n");
223 MACHINE_START(D2NET_V2, "LaCie d2 Network v2")
224 .boot_params = 0x00000100,
225 .init_machine = d2net_v2_init,
226 .map_io = kirkwood_map_io,
227 .init_early = kirkwood_init_early,
228 .init_irq = kirkwood_init_irq,
229 .timer = &kirkwood_timer,
230 MACHINE_END