diff options
author | Simon Guinot <sguinot@lacie.com> | 2010-01-04 14:20:07 -0500 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2010-05-03 17:02:42 -0400 |
commit | 3e05ec1b93cd839fa1d1a9961b155b0dbc9a4055 (patch) | |
tree | b1f08eff3b5d18320488649a01dea8236e0aba81 /arch/arm | |
parent | 2a49456fdae0cc9e4286de38b8fcb85f9c7c7559 (diff) |
[ARM] Kirkwood: add LaCie 5Big Network v2 support
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-kirkwood/Kconfig | 6 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/net5big_v2-setup.c | 355 |
3 files changed, 362 insertions, 0 deletions
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index 953681ae69ea..29b2163b1fe3 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig | |||
@@ -93,6 +93,12 @@ config MACH_NET2BIG_V2 | |||
93 | Say 'Y' here if you want your kernel to support the | 93 | Say 'Y' here if you want your kernel to support the |
94 | LaCie 2Big Network v2 NAS. | 94 | LaCie 2Big Network v2 NAS. |
95 | 95 | ||
96 | config MACH_NET5BIG_V2 | ||
97 | bool "LaCie 5Big Network v2 NAS Board" | ||
98 | help | ||
99 | Say 'Y' here if you want your kernel to support the | ||
100 | LaCie 5Big Network v2 NAS. | ||
101 | |||
96 | endmenu | 102 | endmenu |
97 | 103 | ||
98 | endif | 104 | endif |
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index 3697d8e59687..bbb8dd3fa211 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile | |||
@@ -13,5 +13,6 @@ obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o | |||
13 | obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o | 13 | obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o |
14 | obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o | 14 | obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o |
15 | obj-$(CONFIG_MACH_NET2BIG_V2) += net2big_v2-setup.o | 15 | obj-$(CONFIG_MACH_NET2BIG_V2) += net2big_v2-setup.o |
16 | obj-$(CONFIG_MACH_NET5BIG_V2) += net5big_v2-setup.o | ||
16 | 17 | ||
17 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | 18 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o |
diff --git a/arch/arm/mach-kirkwood/net5big_v2-setup.c b/arch/arm/mach-kirkwood/net5big_v2-setup.c new file mode 100644 index 000000000000..f0617ecc8a29 --- /dev/null +++ b/arch/arm/mach-kirkwood/net5big_v2-setup.c | |||
@@ -0,0 +1,355 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/net5big_v2-setup.c | ||
3 | * | ||
4 | * LaCie 5Big Network 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 <plat/time.h> | ||
42 | #include "common.h" | ||
43 | #include "mpp.h" | ||
44 | |||
45 | /***************************************************************************** | ||
46 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) | ||
47 | ****************************************************************************/ | ||
48 | |||
49 | static struct mtd_partition net5big_v2_flash_parts[] = { | ||
50 | { | ||
51 | .name = "u-boot", | ||
52 | .size = MTDPART_SIZ_FULL, | ||
53 | .offset = 0, | ||
54 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
55 | }, | ||
56 | }; | ||
57 | |||
58 | static const struct flash_platform_data net5big_v2_flash = { | ||
59 | .type = "mx25l4005a", | ||
60 | .name = "spi_flash", | ||
61 | .parts = net5big_v2_flash_parts, | ||
62 | .nr_parts = ARRAY_SIZE(net5big_v2_flash_parts), | ||
63 | }; | ||
64 | |||
65 | static struct spi_board_info __initdata net5big_v2_spi_slave_info[] = { | ||
66 | { | ||
67 | .modalias = "m25p80", | ||
68 | .platform_data = &net5big_v2_flash, | ||
69 | .irq = -1, | ||
70 | .max_speed_hz = 20000000, | ||
71 | .bus_num = 0, | ||
72 | .chip_select = 0, | ||
73 | }, | ||
74 | }; | ||
75 | |||
76 | /***************************************************************************** | ||
77 | * Ethernet | ||
78 | ****************************************************************************/ | ||
79 | |||
80 | static struct mv643xx_eth_platform_data net5big_v2_ge00_data = { | ||
81 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), | ||
82 | }; | ||
83 | |||
84 | static struct mv643xx_eth_platform_data net5big_v2_ge01_data = { | ||
85 | .phy_addr = MV643XX_ETH_PHY_ADDR(0), | ||
86 | }; | ||
87 | |||
88 | /***************************************************************************** | ||
89 | * I2C devices | ||
90 | ****************************************************************************/ | ||
91 | |||
92 | static struct at24_platform_data at24c04 = { | ||
93 | .byte_len = SZ_4K / 8, | ||
94 | .page_size = 16, | ||
95 | }; | ||
96 | |||
97 | /* | ||
98 | * i2c addr | chip | description | ||
99 | * 0x50 | HT24LC04 | eeprom (512B) | ||
100 | */ | ||
101 | |||
102 | static struct i2c_board_info __initdata net5big_v2_i2c_info[] = { | ||
103 | { | ||
104 | I2C_BOARD_INFO("24c04", 0x50), | ||
105 | .platform_data = &at24c04, | ||
106 | } | ||
107 | }; | ||
108 | |||
109 | /***************************************************************************** | ||
110 | * SATA | ||
111 | ****************************************************************************/ | ||
112 | |||
113 | static struct mv_sata_platform_data net5big_v2_sata_data = { | ||
114 | .n_ports = 2, | ||
115 | }; | ||
116 | |||
117 | static int __initdata net5big_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 }; | ||
118 | |||
119 | static void __init net5big_v2_sata_power_init(void) | ||
120 | { | ||
121 | int i; | ||
122 | int err; | ||
123 | |||
124 | /* Power up all hard disks. */ | ||
125 | for (i = 0; i < ARRAY_SIZE(net5big_v2_gpio_hdd_power); i++) { | ||
126 | err = gpio_request(net5big_v2_gpio_hdd_power[i], NULL); | ||
127 | if (err == 0) { | ||
128 | err = gpio_direction_output( | ||
129 | net5big_v2_gpio_hdd_power[i], 1); | ||
130 | /* Free the HDD power GPIOs. This allow user-space to | ||
131 | * configure them via the gpiolib sysfs interface. */ | ||
132 | gpio_free(net5big_v2_gpio_hdd_power[i]); | ||
133 | } | ||
134 | if (err) | ||
135 | pr_err("net5big_v2: failed to power up HDD%d\n", i + 1); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /***************************************************************************** | ||
140 | * GPIO keys | ||
141 | ****************************************************************************/ | ||
142 | |||
143 | #define NET5BIG_V2_GPIO_SWITCH_POWER_ON 13 | ||
144 | #define NET5BIG_V2_GPIO_SWITCH_POWER_OFF 15 | ||
145 | #define NET5BIG_V2_GPIO_FUNC_BUTTON 34 | ||
146 | |||
147 | #define NET5BIG_V2_SWITCH_POWER_ON 0x1 | ||
148 | #define NET5BIG_V2_SWITCH_POWER_OFF 0x2 | ||
149 | |||
150 | static struct gpio_keys_button net5big_v2_buttons[] = { | ||
151 | [0] = { | ||
152 | .type = EV_SW, | ||
153 | .code = NET5BIG_V2_SWITCH_POWER_ON, | ||
154 | .gpio = NET5BIG_V2_GPIO_SWITCH_POWER_ON, | ||
155 | .desc = "Back power switch (on|auto)", | ||
156 | .active_low = 1, | ||
157 | }, | ||
158 | [1] = { | ||
159 | .type = EV_SW, | ||
160 | .code = NET5BIG_V2_SWITCH_POWER_OFF, | ||
161 | .gpio = NET5BIG_V2_GPIO_SWITCH_POWER_OFF, | ||
162 | .desc = "Back power switch (auto|off)", | ||
163 | .active_low = 1, | ||
164 | }, | ||
165 | [2] = { | ||
166 | .code = KEY_OPTION, | ||
167 | .gpio = NET5BIG_V2_GPIO_FUNC_BUTTON, | ||
168 | .desc = "Function button", | ||
169 | .active_low = 1, | ||
170 | }, | ||
171 | }; | ||
172 | |||
173 | static struct gpio_keys_platform_data net5big_v2_button_data = { | ||
174 | .buttons = net5big_v2_buttons, | ||
175 | .nbuttons = ARRAY_SIZE(net5big_v2_buttons), | ||
176 | }; | ||
177 | |||
178 | static struct platform_device net5big_v2_gpio_buttons = { | ||
179 | .name = "gpio-keys", | ||
180 | .id = -1, | ||
181 | .dev = { | ||
182 | .platform_data = &net5big_v2_button_data, | ||
183 | }, | ||
184 | }; | ||
185 | |||
186 | /***************************************************************************** | ||
187 | * GPIO LEDs | ||
188 | ****************************************************************************/ | ||
189 | |||
190 | /* | ||
191 | * The LEDs are controlled by a CPLD and can be configured through a GPIO | ||
192 | * extension bus: | ||
193 | * | ||
194 | * - address register : bit [0-2] -> GPIO [47-49] | ||
195 | * - data register : bit [0-2] -> GPIO [44-46] | ||
196 | * - enable register : GPIO 29 | ||
197 | * | ||
198 | * Address register selection: | ||
199 | * | ||
200 | * addr | register | ||
201 | * ---------------------------- | ||
202 | * 0 | front LED | ||
203 | * 1 | front LED brightness | ||
204 | * 2 | HDD LED brightness | ||
205 | * 3 | HDD1 LED | ||
206 | * 4 | HDD2 LED | ||
207 | * 5 | HDD3 LED | ||
208 | * 6 | HDD4 LED | ||
209 | * 7 | HDD5 LED | ||
210 | * | ||
211 | * Data register configuration: | ||
212 | * | ||
213 | * data | LED brightness | ||
214 | * ------------------------------------------------- | ||
215 | * 0 | min (off) | ||
216 | * - | - | ||
217 | * 7 | max | ||
218 | * | ||
219 | * data | front LED mode | ||
220 | * ------------------------------------------------- | ||
221 | * 0 | fix off | ||
222 | * 1 | fix blue on | ||
223 | * 2 | fix red on | ||
224 | * 3 | blink blue on=1 sec and blue off=1 sec | ||
225 | * 4 | blink red on=1 sec and red off=1 sec | ||
226 | * 5 | blink blue on=2.5 sec and red on=0.5 sec | ||
227 | * 6 | blink blue on=1 sec and red on=1 sec | ||
228 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec | ||
229 | * | ||
230 | * data | HDD LED mode | ||
231 | * ------------------------------------------------- | ||
232 | * 0 | fix blue on | ||
233 | * 1 | SATA activity blink | ||
234 | * 2 | fix red on | ||
235 | * 3 | blink blue on=1 sec and blue off=1 sec | ||
236 | * 4 | blink red on=1 sec and red off=1 sec | ||
237 | * 5 | blink blue on=2.5 sec and red on=0.5 sec | ||
238 | * 6 | blink blue on=1 sec and red on=1 sec | ||
239 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec | ||
240 | */ | ||
241 | |||
242 | /***************************************************************************** | ||
243 | * Timer | ||
244 | ****************************************************************************/ | ||
245 | |||
246 | static void net5big_v2_timer_init(void) | ||
247 | { | ||
248 | kirkwood_tclk = 166666667; | ||
249 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | ||
250 | } | ||
251 | |||
252 | struct sys_timer net5big_v2_timer = { | ||
253 | .init = net5big_v2_timer_init, | ||
254 | }; | ||
255 | |||
256 | /***************************************************************************** | ||
257 | * General Setup | ||
258 | ****************************************************************************/ | ||
259 | |||
260 | static unsigned int net5big_v2_mpp_config[] __initdata = { | ||
261 | MPP0_SPI_SCn, | ||
262 | MPP1_SPI_MOSI, | ||
263 | MPP2_SPI_SCK, | ||
264 | MPP3_SPI_MISO, | ||
265 | MPP6_SYSRST_OUTn, | ||
266 | MPP7_GPO, /* Request power-off */ | ||
267 | MPP8_TW_SDA, | ||
268 | MPP9_TW_SCK, | ||
269 | MPP10_UART0_TXD, | ||
270 | MPP11_UART0_RXD, | ||
271 | MPP13_GPIO, /* Rear power switch (on|auto) */ | ||
272 | MPP14_GPIO, /* USB fuse alarm */ | ||
273 | MPP15_GPIO, /* Rear power switch (auto|off) */ | ||
274 | MPP16_GPIO, /* SATA HDD1 power */ | ||
275 | MPP17_GPIO, /* SATA HDD2 power */ | ||
276 | MPP20_GE1_0, | ||
277 | MPP21_GE1_1, | ||
278 | MPP22_GE1_2, | ||
279 | MPP23_GE1_3, | ||
280 | MPP24_GE1_4, | ||
281 | MPP25_GE1_5, | ||
282 | MPP26_GE1_6, | ||
283 | MPP27_GE1_7, | ||
284 | MPP28_GPIO, /* USB enable host vbus */ | ||
285 | MPP29_GPIO, /* CPLD extension ALE */ | ||
286 | MPP30_GE1_10, | ||
287 | MPP31_GE1_11, | ||
288 | MPP32_GE1_12, | ||
289 | MPP33_GE1_13, | ||
290 | MPP34_GPIO, /* Rear Push button */ | ||
291 | MPP35_GPIO, /* Inhibit switch power-off */ | ||
292 | MPP36_GPIO, /* SATA HDD1 presence */ | ||
293 | MPP37_GPIO, /* SATA HDD2 presence */ | ||
294 | MPP38_GPIO, /* SATA HDD3 presence */ | ||
295 | MPP39_GPIO, /* SATA HDD4 presence */ | ||
296 | MPP40_GPIO, /* SATA HDD5 presence */ | ||
297 | MPP41_GPIO, /* SATA HDD3 power */ | ||
298 | MPP42_GPIO, /* SATA HDD4 power */ | ||
299 | MPP43_GPIO, /* SATA HDD5 power */ | ||
300 | MPP44_GPIO, /* CPLD extension (data 0) */ | ||
301 | MPP45_GPIO, /* CPLD extension (data 1) */ | ||
302 | MPP46_GPIO, /* CPLD extension (data 2) */ | ||
303 | MPP47_GPIO, /* CPLD extension (addr 0) */ | ||
304 | MPP48_GPIO, /* CPLD extension (addr 1) */ | ||
305 | MPP49_GPIO, /* CPLD extension (addr 2) */ | ||
306 | 0 | ||
307 | }; | ||
308 | |||
309 | #define NET5BIG_V2_GPIO_POWER_OFF 7 | ||
310 | |||
311 | static void net5big_v2_power_off(void) | ||
312 | { | ||
313 | gpio_set_value(NET5BIG_V2_GPIO_POWER_OFF, 1); | ||
314 | } | ||
315 | |||
316 | static void __init net5big_v2_init(void) | ||
317 | { | ||
318 | /* | ||
319 | * Basic setup. Needs to be called early. | ||
320 | */ | ||
321 | kirkwood_init(); | ||
322 | kirkwood_mpp_conf(net5big_v2_mpp_config); | ||
323 | |||
324 | net5big_v2_sata_power_init(); | ||
325 | |||
326 | kirkwood_ehci_init(); | ||
327 | kirkwood_ge00_init(&net5big_v2_ge00_data); | ||
328 | kirkwood_ge01_init(&net5big_v2_ge01_data); | ||
329 | kirkwood_sata_init(&net5big_v2_sata_data); | ||
330 | kirkwood_uart0_init(); | ||
331 | spi_register_board_info(net5big_v2_spi_slave_info, | ||
332 | ARRAY_SIZE(net5big_v2_spi_slave_info)); | ||
333 | kirkwood_spi_init(); | ||
334 | kirkwood_i2c_init(); | ||
335 | i2c_register_board_info(0, net5big_v2_i2c_info, | ||
336 | ARRAY_SIZE(net5big_v2_i2c_info)); | ||
337 | |||
338 | platform_device_register(&net5big_v2_gpio_buttons); | ||
339 | |||
340 | if (gpio_request(NET5BIG_V2_GPIO_POWER_OFF, "power-off") == 0 && | ||
341 | gpio_direction_output(NET5BIG_V2_GPIO_POWER_OFF, 0) == 0) | ||
342 | pm_power_off = net5big_v2_power_off; | ||
343 | else | ||
344 | pr_err("net5big_v2: failed to configure power-off GPIO\n"); | ||
345 | } | ||
346 | |||
347 | MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2") | ||
348 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, | ||
349 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, | ||
350 | .boot_params = 0x00000100, | ||
351 | .init_machine = net5big_v2_init, | ||
352 | .map_io = kirkwood_map_io, | ||
353 | .init_irq = kirkwood_init_irq, | ||
354 | .timer = &net5big_v2_timer, | ||
355 | MACHINE_END | ||