[ARM] Kirkwood: Add LaCie Network Space v2 support
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-kirkwood / netspace_v2-setup.c
blob9a064065bebe912cbcc059238e9d660478dd4ed0
1 /*
2 * arch/arm/mach-kirkwood/netspace_v2-setup.c
4 * LaCie Network Space v2 board setup
6 * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
7 * Copyright (C) 2009 Benoît Canet <benoit.canet@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/kernel.h>
25 #include <linux/init.h>
26 #include <linux/platform_device.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/spi/flash.h>
29 #include <linux/spi/spi.h>
30 #include <linux/ata_platform.h>
31 #include <linux/mv643xx_eth.h>
32 #include <linux/i2c.h>
33 #include <linux/i2c/at24.h>
34 #include <linux/input.h>
35 #include <linux/gpio.h>
36 #include <linux/gpio_keys.h>
37 #include <linux/leds.h>
38 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/time.h>
41 #include <mach/kirkwood.h>
42 #include <plat/time.h>
43 #include "common.h"
44 #include "mpp.h"
46 /*****************************************************************************
47 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
48 ****************************************************************************/
50 static struct mtd_partition netspace_v2_flash_parts[] = {
52 .name = "u-boot",
53 .size = MTDPART_SIZ_FULL,
54 .offset = 0,
55 .mask_flags = MTD_WRITEABLE, /* force read-only */
59 static const struct flash_platform_data netspace_v2_flash = {
60 .type = "mx25l4005a",
61 .name = "spi_flash",
62 .parts = netspace_v2_flash_parts,
63 .nr_parts = ARRAY_SIZE(netspace_v2_flash_parts),
66 static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = {
68 .modalias = "m25p80",
69 .platform_data = &netspace_v2_flash,
70 .irq = -1,
71 .max_speed_hz = 20000000,
72 .bus_num = 0,
73 .chip_select = 0,
77 /*****************************************************************************
78 * Ethernet
79 ****************************************************************************/
81 static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
82 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
85 /*****************************************************************************
86 * I2C devices
87 ****************************************************************************/
89 static struct at24_platform_data at24c04 = {
90 .byte_len = SZ_4K / 8,
91 .page_size = 16,
95 * i2c addr | chip | description
96 * 0x50 | HT24LC04 | eeprom (512B)
99 static struct i2c_board_info __initdata netspace_v2_i2c_info[] = {
101 I2C_BOARD_INFO("24c04", 0x50),
102 .platform_data = &at24c04,
106 /*****************************************************************************
107 * SATA
108 ****************************************************************************/
110 static struct mv_sata_platform_data netspace_v2_sata_data = {
111 .n_ports = 2,
114 #define NETSPACE_V2_GPIO_SATA0_POWER 16
115 #define NETSPACE_V2_GPIO_SATA1_POWER 17
117 static void __init netspace_v2_sata_power_init(void)
119 int err;
121 err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power");
122 if (err == 0) {
123 err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1);
124 if (err)
125 gpio_free(NETSPACE_V2_GPIO_SATA0_POWER);
127 if (err)
128 pr_err("netspace_v2: failed to setup SATA0 power\n");
131 /*****************************************************************************
132 * GPIO keys
133 ****************************************************************************/
135 #define NETSPACE_V2_PUSH_BUTTON 32
137 static struct gpio_keys_button netspace_v2_buttons[] = {
138 [0] = {
139 .code = KEY_POWER,
140 .gpio = NETSPACE_V2_PUSH_BUTTON,
141 .desc = "Power push button",
142 .active_low = 0,
146 static struct gpio_keys_platform_data netspace_v2_button_data = {
147 .buttons = netspace_v2_buttons,
148 .nbuttons = ARRAY_SIZE(netspace_v2_buttons),
151 static struct platform_device netspace_v2_gpio_buttons = {
152 .name = "gpio-keys",
153 .id = -1,
154 .dev = {
155 .platform_data = &netspace_v2_button_data,
159 /*****************************************************************************
160 * GPIO LEDs
161 ****************************************************************************/
164 * The blue front LED is wired to a CPLD and can blink in relation with the
165 * SATA activity.
167 * The following array detail the different LED registers and the combination
168 * of their possible values:
170 * cmd_led | slow_led | /SATA active | LED state
171 * | | |
172 * 1 | 0 | x | off
173 * - | 1 | x | on
174 * 0 | 0 | 1 | on
175 * 0 | 0 | 0 | blink (rate 300ms)
178 #define NETSPACE_V2_GPIO_RED_LED 12
179 #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
180 #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30
183 static struct gpio_led netspace_v2_gpio_led_pins[] = {
185 .name = "ns_v2:red:fail",
186 .gpio = NETSPACE_V2_GPIO_RED_LED,
190 static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {
191 .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins),
192 .leds = netspace_v2_gpio_led_pins,
195 static struct platform_device netspace_v2_gpio_leds = {
196 .name = "leds-gpio",
197 .id = -1,
198 .dev = {
199 .platform_data = &netspace_v2_gpio_leds_data,
203 static void __init netspace_v2_gpio_leds_init(void)
205 platform_device_register(&netspace_v2_gpio_leds);
208 * Configure the front blue LED to blink in relation with the SATA
209 * activity.
211 if (gpio_request(NETSPACE_V2_GPIO_BLUE_LED_SLOW,
212 "SATA blue LED slow") != 0)
213 return;
214 if (gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_SLOW, 0) != 0)
215 goto err_free_1;
216 if (gpio_request(NETSPACE_V2_GPIO_BLUE_LED_CMD,
217 "SATA blue LED command") != 0)
218 goto err_free_1;
219 if (gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_CMD, 0) != 0)
220 goto err_free_2;
222 return;
224 err_free_2:
225 gpio_free(NETSPACE_V2_GPIO_BLUE_LED_CMD);
226 err_free_1:
227 gpio_free(NETSPACE_V2_GPIO_BLUE_LED_SLOW);
228 pr_err("netspace_v2: failed to configure SATA blue LED\n");
231 /*****************************************************************************
232 * Timer
233 ****************************************************************************/
235 static void netspace_v2_timer_init(void)
237 kirkwood_tclk = 166666667;
238 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
241 struct sys_timer netspace_v2_timer = {
242 .init = netspace_v2_timer_init,
245 /*****************************************************************************
246 * General Setup
247 ****************************************************************************/
249 static unsigned int netspace_v2_mpp_config[] __initdata = {
250 MPP0_SPI_SCn,
251 MPP1_SPI_MOSI,
252 MPP2_SPI_SCK,
253 MPP3_SPI_MISO,
254 MPP4_NF_IO6,
255 MPP5_NF_IO7,
256 MPP6_SYSRST_OUTn,
257 MPP8_TW_SDA,
258 MPP9_TW_SCK,
259 MPP10_UART0_TXD,
260 MPP11_UART0_RXD,
261 MPP12_GPO, /* Red led */
262 MPP14_GPIO, /* USB fuse */
263 MPP16_GPIO, /* SATA 0 power */
264 MPP18_NF_IO0,
265 MPP19_NF_IO1,
266 MPP20_SATA1_ACTn,
267 MPP21_SATA0_ACTn,
268 MPP24_GPIO, /* USB mode select */
269 MPP25_GPIO, /* Fan rotation fail */
270 MPP26_GPIO, /* USB device vbus */
271 MPP28_GPIO, /* USB enable host vbus */
272 MPP29_GPIO, /* Blue led (slow register) */
273 MPP30_GPIO, /* Blue led (command register) */
274 MPP31_GPIO, /* Board power off */
275 MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */
279 #define NETSPACE_V2_GPIO_POWER_OFF 31
281 static void netspace_v2_power_off(void)
283 gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);
286 static void __init netspace_v2_init(void)
289 * Basic setup. Needs to be called early.
291 kirkwood_init();
292 kirkwood_mpp_conf(netspace_v2_mpp_config);
294 netspace_v2_sata_power_init();
296 kirkwood_ehci_init();
297 kirkwood_ge00_init(&netspace_v2_ge00_data);
298 kirkwood_sata_init(&netspace_v2_sata_data);
299 kirkwood_uart0_init();
300 spi_register_board_info(netspace_v2_spi_slave_info,
301 ARRAY_SIZE(netspace_v2_spi_slave_info));
302 kirkwood_spi_init();
303 kirkwood_i2c_init();
304 i2c_register_board_info(0, netspace_v2_i2c_info,
305 ARRAY_SIZE(netspace_v2_i2c_info));
307 netspace_v2_gpio_leds_init();
308 platform_device_register(&netspace_v2_gpio_buttons);
310 if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
311 gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
312 pm_power_off = netspace_v2_power_off;
313 else
314 pr_err("netspace_v2: failed to configure power-off GPIO\n");
317 MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
318 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
319 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
320 .boot_params = 0x00000100,
321 .init_machine = netspace_v2_init,
322 .map_io = kirkwood_map_io,
323 .init_irq = kirkwood_init_irq,
324 .timer = &netspace_v2_timer,
325 MACHINE_END