blob: 9f20c8d3e18bf3803f6b0215a5be109c3a11d694 [file] [log] [blame]
Simon Guinot1cb9f9b2009-12-09 01:43:49 +01001/*
2 * arch/arm/mach-kirkwood/netspace_v2-setup.c
3 *
4 * LaCie Network Space v2 board setup
5 *
6 * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
7 * Copyright (C) 2009 Benoît Canet <benoit.canet@gmail.com>
8 *
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.
13 *
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.
18 *
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
22 */
23
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"
45
46/*****************************************************************************
47 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
48 ****************************************************************************/
49
50static struct mtd_partition netspace_v2_flash_parts[] = {
51 {
52 .name = "u-boot",
53 .size = MTDPART_SIZ_FULL,
54 .offset = 0,
55 .mask_flags = MTD_WRITEABLE, /* force read-only */
56 },
57};
58
59static 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),
64};
65
66static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = {
67 {
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,
74 },
75};
76
77/*****************************************************************************
78 * Ethernet
79 ****************************************************************************/
80
81static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
82 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
83};
84
85/*****************************************************************************
86 * I2C devices
87 ****************************************************************************/
88
89static struct at24_platform_data at24c04 = {
90 .byte_len = SZ_4K / 8,
91 .page_size = 16,
92};
93
94/*
95 * i2c addr | chip | description
96 * 0x50 | HT24LC04 | eeprom (512B)
97 */
98
99static struct i2c_board_info __initdata netspace_v2_i2c_info[] = {
100 {
101 I2C_BOARD_INFO("24c04", 0x50),
102 .platform_data = &at24c04,
103 }
104};
105
106/*****************************************************************************
107 * SATA
108 ****************************************************************************/
109
110static struct mv_sata_platform_data netspace_v2_sata_data = {
111 .n_ports = 2,
112};
113
114#define NETSPACE_V2_GPIO_SATA0_POWER 16
115#define NETSPACE_V2_GPIO_SATA1_POWER 17
116
117static void __init netspace_v2_sata_power_init(void)
118{
119 int err;
120
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);
126 }
127 if (err)
128 pr_err("netspace_v2: failed to setup SATA0 power\n");
Simon Guinotb6a044f2010-07-05 12:31:04 +0200129
130 if (machine_is_netspace_max_v2()) {
131 err = gpio_request(NETSPACE_V2_GPIO_SATA1_POWER, "SATA1 power");
132 if (err == 0) {
133 err = gpio_direction_output(
134 NETSPACE_V2_GPIO_SATA1_POWER, 1);
135 if (err)
136 gpio_free(NETSPACE_V2_GPIO_SATA1_POWER);
137 }
138 if (err)
139 pr_err("netspace_v2: failed to setup SATA1 power\n");
140 }
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100141}
142
143/*****************************************************************************
144 * GPIO keys
145 ****************************************************************************/
146
147#define NETSPACE_V2_PUSH_BUTTON 32
148
149static struct gpio_keys_button netspace_v2_buttons[] = {
150 [0] = {
151 .code = KEY_POWER,
152 .gpio = NETSPACE_V2_PUSH_BUTTON,
153 .desc = "Power push button",
154 .active_low = 0,
155 },
156};
157
158static struct gpio_keys_platform_data netspace_v2_button_data = {
159 .buttons = netspace_v2_buttons,
160 .nbuttons = ARRAY_SIZE(netspace_v2_buttons),
161};
162
163static struct platform_device netspace_v2_gpio_buttons = {
164 .name = "gpio-keys",
165 .id = -1,
166 .dev = {
167 .platform_data = &netspace_v2_button_data,
168 },
169};
170
171/*****************************************************************************
172 * GPIO LEDs
173 ****************************************************************************/
174
175/*
176 * The blue front LED is wired to a CPLD and can blink in relation with the
177 * SATA activity.
178 *
179 * The following array detail the different LED registers and the combination
180 * of their possible values:
181 *
182 * cmd_led | slow_led | /SATA active | LED state
183 * | | |
184 * 1 | 0 | x | off
185 * - | 1 | x | on
186 * 0 | 0 | 1 | on
187 * 0 | 0 | 0 | blink (rate 300ms)
188 */
189
190#define NETSPACE_V2_GPIO_RED_LED 12
191#define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
192#define NETSPACE_V2_GPIO_BLUE_LED_CMD 30
193
194
195static struct gpio_led netspace_v2_gpio_led_pins[] = {
196 {
Simon Guinot1afeea82010-02-09 21:20:56 +0100197 .name = "ns_v2:blue:sata",
198 .default_trigger = "default-on",
199 .gpio = NETSPACE_V2_GPIO_BLUE_LED_CMD,
200 .active_low = 1,
201 },
202 {
203 .name = "ns_v2:red:fail",
204 .gpio = NETSPACE_V2_GPIO_RED_LED,
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100205 },
206};
207
208static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {
209 .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins),
210 .leds = netspace_v2_gpio_led_pins,
211};
212
213static struct platform_device netspace_v2_gpio_leds = {
214 .name = "leds-gpio",
215 .id = -1,
216 .dev = {
217 .platform_data = &netspace_v2_gpio_leds_data,
218 },
219};
220
221static void __init netspace_v2_gpio_leds_init(void)
222{
Simon Guinot1afeea82010-02-09 21:20:56 +0100223 int err;
224
225 /* Configure register slow_led to allow SATA activity LED blinking */
226 err = gpio_request(NETSPACE_V2_GPIO_BLUE_LED_SLOW, "blue LED slow");
227 if (err == 0) {
228 err = gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_SLOW, 0);
229 if (err)
230 gpio_free(NETSPACE_V2_GPIO_BLUE_LED_SLOW);
231 }
232 if (err)
233 pr_err("netspace_v2: failed to configure blue LED slow GPIO\n");
234
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100235 platform_device_register(&netspace_v2_gpio_leds);
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100236}
237
238/*****************************************************************************
239 * Timer
240 ****************************************************************************/
241
242static void netspace_v2_timer_init(void)
243{
244 kirkwood_tclk = 166666667;
245 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
246}
247
248struct sys_timer netspace_v2_timer = {
249 .init = netspace_v2_timer_init,
250};
251
252/*****************************************************************************
253 * General Setup
254 ****************************************************************************/
255
256static unsigned int netspace_v2_mpp_config[] __initdata = {
257 MPP0_SPI_SCn,
258 MPP1_SPI_MOSI,
259 MPP2_SPI_SCK,
260 MPP3_SPI_MISO,
261 MPP4_NF_IO6,
262 MPP5_NF_IO7,
263 MPP6_SYSRST_OUTn,
Simon Guinotb6a044f2010-07-05 12:31:04 +0200264 MPP7_GPO, /* Fan speed (bit 1) */
Benjamin Zores266a2452010-06-08 10:00:22 +0200265 MPP8_TW0_SDA,
266 MPP9_TW0_SCK,
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100267 MPP10_UART0_TXD,
268 MPP11_UART0_RXD,
269 MPP12_GPO, /* Red led */
270 MPP14_GPIO, /* USB fuse */
271 MPP16_GPIO, /* SATA 0 power */
Simon Guinotb6a044f2010-07-05 12:31:04 +0200272 MPP17_GPIO, /* SATA 1 power */
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100273 MPP18_NF_IO0,
274 MPP19_NF_IO1,
275 MPP20_SATA1_ACTn,
276 MPP21_SATA0_ACTn,
Simon Guinotb6a044f2010-07-05 12:31:04 +0200277 MPP22_GPIO, /* Fan speed (bit 0) */
278 MPP23_GPIO, /* Fan power */
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100279 MPP24_GPIO, /* USB mode select */
280 MPP25_GPIO, /* Fan rotation fail */
281 MPP26_GPIO, /* USB device vbus */
282 MPP28_GPIO, /* USB enable host vbus */
283 MPP29_GPIO, /* Blue led (slow register) */
284 MPP30_GPIO, /* Blue led (command register) */
285 MPP31_GPIO, /* Board power off */
286 MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */
Simon Guinotb6a044f2010-07-05 12:31:04 +0200287 MPP33_GPO, /* Fan speed (bit 2) */
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100288 0
289};
290
291#define NETSPACE_V2_GPIO_POWER_OFF 31
292
293static void netspace_v2_power_off(void)
294{
295 gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);
296}
297
298static void __init netspace_v2_init(void)
299{
300 /*
301 * Basic setup. Needs to be called early.
302 */
303 kirkwood_init();
304 kirkwood_mpp_conf(netspace_v2_mpp_config);
305
306 netspace_v2_sata_power_init();
307
308 kirkwood_ehci_init();
309 kirkwood_ge00_init(&netspace_v2_ge00_data);
310 kirkwood_sata_init(&netspace_v2_sata_data);
311 kirkwood_uart0_init();
312 spi_register_board_info(netspace_v2_spi_slave_info,
313 ARRAY_SIZE(netspace_v2_spi_slave_info));
314 kirkwood_spi_init();
315 kirkwood_i2c_init();
316 i2c_register_board_info(0, netspace_v2_i2c_info,
317 ARRAY_SIZE(netspace_v2_i2c_info));
318
319 netspace_v2_gpio_leds_init();
320 platform_device_register(&netspace_v2_gpio_buttons);
321
322 if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
323 gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
324 pm_power_off = netspace_v2_power_off;
325 else
326 pr_err("netspace_v2: failed to configure power-off GPIO\n");
327}
328
Simon Guinotca9cea92010-02-09 21:20:55 +0100329#ifdef CONFIG_MACH_NETSPACE_V2
Simon Guinot1cb9f9b2009-12-09 01:43:49 +0100330MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
331 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
332 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
333 .boot_params = 0x00000100,
334 .init_machine = netspace_v2_init,
335 .map_io = kirkwood_map_io,
336 .init_irq = kirkwood_init_irq,
337 .timer = &netspace_v2_timer,
338MACHINE_END
Simon Guinotca9cea92010-02-09 21:20:55 +0100339#endif
340
341#ifdef CONFIG_MACH_INETSPACE_V2
342MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
343 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
344 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
345 .boot_params = 0x00000100,
346 .init_machine = netspace_v2_init,
347 .map_io = kirkwood_map_io,
348 .init_irq = kirkwood_init_irq,
349 .timer = &netspace_v2_timer,
350MACHINE_END
351#endif
Simon Guinotb6a044f2010-07-05 12:31:04 +0200352
353#ifdef CONFIG_MACH_NETSPACE_MAX_V2
354MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
355 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
356 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
357 .boot_params = 0x00000100,
358 .init_machine = netspace_v2_init,
359 .map_io = kirkwood_map_io,
360 .init_irq = kirkwood_init_irq,
361 .timer = &netspace_v2_timer,
362MACHINE_END
363#endif