aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-kirkwood
diff options
context:
space:
mode:
authorSimon Guinot <sguinot@lacie.com>2010-09-19 09:33:58 -0400
committerNicolas Pitre <nico@fluxnic.net>2010-09-19 22:43:44 -0400
commit84712e9aa43862ded44e47acfaa93612a7eeaf7c (patch)
treea2083ba1ec4e71b075ae4ab4f37110b3595bfae4 /arch/arm/mach-kirkwood
parent709406494c0ed7da843bad624f6b16f9a2df4a6c (diff)
[ARM] Kirkwood: add LaCie d2 Network v2 support
Signed-off-by: Simon Guinot <sguinot@lacie.com> Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Diffstat (limited to 'arch/arm/mach-kirkwood')
-rw-r--r--arch/arm/mach-kirkwood/Kconfig6
-rw-r--r--arch/arm/mach-kirkwood/Makefile1
-rw-r--r--arch/arm/mach-kirkwood/d2net_v2-setup.c323
3 files changed, 330 insertions, 0 deletions
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 3d5d66e7aaa0..34106335c728 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -106,6 +106,12 @@ config MACH_NETSPACE_MAX_V2
106 Say 'Y' here if you want your kernel to support the 106 Say 'Y' here if you want your kernel to support the
107 LaCie Network Space Max v2 NAS. 107 LaCie Network Space Max v2 NAS.
108 108
109config MACH_D2NET_V2
110 bool "LaCie d2 Network v2 NAS Board"
111 help
112 Say 'Y' here if you want your kernel to support the
113 LaCie d2 Network v2 NAS.
114
109config MACH_NET2BIG_V2 115config MACH_NET2BIG_V2
110 bool "LaCie 2Big Network v2 NAS Board" 116 bool "LaCie 2Big Network v2 NAS Board"
111 help 117 help
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index 9e43e953226e..b84de6a576db 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o
14obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o 14obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o
15obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o 15obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o
16obj-$(CONFIG_MACH_NETSPACE_MAX_V2) += netspace_v2-setup.o 16obj-$(CONFIG_MACH_NETSPACE_MAX_V2) += netspace_v2-setup.o
17obj-$(CONFIG_MACH_D2NET_V2) += d2net_v2-setup.o
17obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o 18obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o
18obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o 19obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o
19obj-$(CONFIG_MACH_T5325) += t5325-setup.o 20obj-$(CONFIG_MACH_T5325) += t5325-setup.o
diff --git a/arch/arm/mach-kirkwood/d2net_v2-setup.c b/arch/arm/mach-kirkwood/d2net_v2-setup.c
new file mode 100644
index 000000000000..310c6a0331f6
--- /dev/null
+++ b/arch/arm/mach-kirkwood/d2net_v2-setup.c
@@ -0,0 +1,323 @@
1/*
2 * arch/arm/mach-kirkwood/d2net_v2-setup.c
3 *
4 * LaCie d2 Network Space v2 Board Setup
5 *
6 * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
7 *
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.
12 *
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.
17 *
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
21 */
22
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>
43#include "common.h"
44#include "mpp.h"
45
46/*****************************************************************************
47 * 512KB SPI Flash on Boot Device
48 ****************************************************************************/
49
50static struct mtd_partition d2net_v2_flash_parts[] = {
51 {
52 .name = "u-boot",
53 .size = MTDPART_SIZ_FULL,
54 .offset = 0,
55 .mask_flags = MTD_WRITEABLE,
56 },
57};
58
59static const struct flash_platform_data d2net_v2_flash = {
60 .type = "mx25l4005a",
61 .name = "spi_flash",
62 .parts = d2net_v2_flash_parts,
63 .nr_parts = ARRAY_SIZE(d2net_v2_flash_parts),
64};
65
66static struct spi_board_info __initdata d2net_v2_spi_slave_info[] = {
67 {
68 .modalias = "m25p80",
69 .platform_data = &d2net_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 d2net_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 d2net_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 d2net_v2_sata_data = {
111 .n_ports = 2,
112};
113
114#define D2NET_V2_GPIO_SATA0_POWER 16
115
116static void __init d2net_v2_sata_power_init(void)
117{
118 int err;
119
120 err = gpio_request(D2NET_V2_GPIO_SATA0_POWER, "SATA0 power");
121 if (err == 0) {
122 err = gpio_direction_output(D2NET_V2_GPIO_SATA0_POWER, 1);
123 if (err)
124 gpio_free(D2NET_V2_GPIO_SATA0_POWER);
125 }
126 if (err)
127 pr_err("d2net_v2: failed to configure SATA0 power GPIO\n");
128}
129
130/*****************************************************************************
131 * GPIO keys
132 ****************************************************************************/
133
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
137
138#define D2NET_V2_SWITCH_POWER_ON 0x1
139#define D2NET_V2_SWITCH_POWER_OFF 0x2
140
141static struct gpio_keys_button d2net_v2_buttons[] = {
142 [0] = {
143 .type = EV_SW,
144 .code = D2NET_V2_SWITCH_POWER_ON,
145 .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON,
146 .desc = "Back power switch (on|auto)",
147 .active_low = 0,
148 },
149 [1] = {
150 .type = EV_SW,
151 .code = D2NET_V2_SWITCH_POWER_OFF,
152 .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF,
153 .desc = "Back power switch (auto|off)",
154 .active_low = 0,
155 },
156 [2] = {
157 .code = KEY_POWER,
158 .gpio = D2NET_V2_GPIO_PUSH_BUTTON,
159 .desc = "Front Push Button",
160 .active_low = 1,
161 },
162};
163
164static struct gpio_keys_platform_data d2net_v2_button_data = {
165 .buttons = d2net_v2_buttons,
166 .nbuttons = ARRAY_SIZE(d2net_v2_buttons),
167};
168
169static struct platform_device d2net_v2_gpio_buttons = {
170 .name = "gpio-keys",
171 .id = -1,
172 .dev = {
173 .platform_data = &d2net_v2_button_data,
174 },
175};
176
177/*****************************************************************************
178 * GPIO LEDs
179 ****************************************************************************/
180
181#define D2NET_V2_GPIO_RED_LED 12
182
183static struct gpio_led d2net_v2_gpio_led_pins[] = {
184 {
185 .name = "d2net_v2:red:fail",
186 .gpio = D2NET_V2_GPIO_RED_LED,
187 },
188};
189
190static 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,
193};
194
195static struct platform_device d2net_v2_gpio_leds = {
196 .name = "leds-gpio",
197 .id = -1,
198 .dev = {
199 .platform_data = &d2net_v2_gpio_leds_data,
200 },
201};
202
203/*****************************************************************************
204 * Dual-GPIO CPLD LEDs
205 ****************************************************************************/
206
207#define D2NET_V2_GPIO_BLUE_LED_SLOW 29
208#define D2NET_V2_GPIO_BLUE_LED_CMD 30
209
210static struct ns2_led d2net_v2_led_pins[] = {
211 {
212 .name = "d2net_v2:blue:sata",
213 .cmd = D2NET_V2_GPIO_BLUE_LED_CMD,
214 .slow = D2NET_V2_GPIO_BLUE_LED_SLOW,
215 },
216};
217
218static struct ns2_led_platform_data d2net_v2_leds_data = {
219 .num_leds = ARRAY_SIZE(d2net_v2_led_pins),
220 .leds = d2net_v2_led_pins,
221};
222
223static struct platform_device d2net_v2_leds = {
224 .name = "leds-ns2",
225 .id = -1,
226 .dev = {
227 .platform_data = &d2net_v2_leds_data,
228 },
229};
230
231/*****************************************************************************
232 * Timer
233 ****************************************************************************/
234
235static void d2net_v2_timer_init(void)
236{
237 kirkwood_tclk = 166666667;
238 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
239}
240
241struct sys_timer d2net_v2_timer = {
242 .init = d2net_v2_timer_init,
243};
244
245/*****************************************************************************
246 * General Setup
247 ****************************************************************************/
248
249static unsigned int d2net_v2_mpp_config[] __initdata = {
250 MPP0_SPI_SCn,
251 MPP1_SPI_MOSI,
252 MPP2_SPI_SCK,
253 MPP3_SPI_MISO,
254 MPP6_SYSRST_OUTn,
255 MPP7_GPO, /* Request power-off */
256 MPP8_TW0_SDA,
257 MPP9_TW0_SCK,
258 MPP10_UART0_TXD,
259 MPP11_UART0_RXD,
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 */
265 MPP21_SATA0_ACTn,
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 */
273 0
274};
275
276#define D2NET_V2_GPIO_POWER_OFF 7
277
278static void d2net_v2_power_off(void)
279{
280 gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1);
281}
282
283static void __init d2net_v2_init(void)
284{
285 /*
286 * Basic setup. Needs to be called early.
287 */
288 kirkwood_init();
289 kirkwood_mpp_conf(d2net_v2_mpp_config);
290
291 d2net_v2_sata_power_init();
292
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));
299 kirkwood_spi_init();
300 kirkwood_i2c_init();
301 i2c_register_board_info(0, d2net_v2_i2c_info,
302 ARRAY_SIZE(d2net_v2_i2c_info));
303
304 platform_device_register(&d2net_v2_leds);
305 platform_device_register(&d2net_v2_gpio_leds);
306 platform_device_register(&d2net_v2_gpio_buttons);
307
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;
311 else
312 pr_err("d2net_v2: failed to configure power-off GPIO\n");
313}
314
315MACHINE_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,
323MACHINE_END