blob: aec528d6081f478898d58601c70e2a692f17e4c9 [file] [log] [blame]
Simon Guinot3e05ec12010-01-04 20:20:07 +01001/*
Simon Guinot57475b12010-02-08 19:08:34 +01002 * arch/arm/mach-kirkwood/netxbig_v2-setup.c
Simon Guinot3e05ec12010-01-04 20:20:07 +01003 *
Simon Guinot57475b12010-02-08 19:08:34 +01004 * LaCie 2Big and 5Big Network v2 board setup
Simon Guinot3e05ec12010-01-04 20:20:07 +01005 *
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>
Simon Guinot3e05ec12010-01-04 20:20:07 +010026#include <linux/ata_platform.h>
27#include <linux/mv643xx_eth.h>
Simon Guinot3e05ec12010-01-04 20:20:07 +010028#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>
Simon Guinot3e05ec12010-01-04 20:20:07 +010034#include <mach/kirkwood.h>
Simon Guinot3e05ec12010-01-04 20:20:07 +010035#include "common.h"
36#include "mpp.h"
Simon Guinotb51d92d2010-09-19 15:33:59 +020037#include "lacie_v2-common.h"
Simon Guinot3e05ec12010-01-04 20:20:07 +010038
39/*****************************************************************************
40 * Ethernet
41 ****************************************************************************/
42
Simon Guinot57475b12010-02-08 19:08:34 +010043static struct mv643xx_eth_platform_data netxbig_v2_ge00_data = {
Simon Guinot3e05ec12010-01-04 20:20:07 +010044 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
45};
46
Simon Guinot57475b12010-02-08 19:08:34 +010047static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = {
Simon Guinot3e05ec12010-01-04 20:20:07 +010048 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
49};
50
51/*****************************************************************************
Simon Guinot3e05ec12010-01-04 20:20:07 +010052 * SATA
53 ****************************************************************************/
54
Simon Guinot57475b12010-02-08 19:08:34 +010055static struct mv_sata_platform_data netxbig_v2_sata_data = {
Simon Guinot3e05ec12010-01-04 20:20:07 +010056 .n_ports = 2,
57};
58
Simon Guinot3e05ec12010-01-04 20:20:07 +010059/*****************************************************************************
60 * GPIO keys
61 ****************************************************************************/
62
Simon Guinot57475b12010-02-08 19:08:34 +010063#define NETXBIG_V2_GPIO_SWITCH_POWER_ON 13
64#define NETXBIG_V2_GPIO_SWITCH_POWER_OFF 15
65#define NETXBIG_V2_GPIO_FUNC_BUTTON 34
Simon Guinot3e05ec12010-01-04 20:20:07 +010066
Simon Guinot57475b12010-02-08 19:08:34 +010067#define NETXBIG_V2_SWITCH_POWER_ON 0x1
68#define NETXBIG_V2_SWITCH_POWER_OFF 0x2
Simon Guinot3e05ec12010-01-04 20:20:07 +010069
Simon Guinot57475b12010-02-08 19:08:34 +010070static struct gpio_keys_button netxbig_v2_buttons[] = {
Simon Guinot3e05ec12010-01-04 20:20:07 +010071 [0] = {
72 .type = EV_SW,
Simon Guinot57475b12010-02-08 19:08:34 +010073 .code = NETXBIG_V2_SWITCH_POWER_ON,
74 .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_ON,
Simon Guinot3e05ec12010-01-04 20:20:07 +010075 .desc = "Back power switch (on|auto)",
76 .active_low = 1,
77 },
78 [1] = {
79 .type = EV_SW,
Simon Guinot57475b12010-02-08 19:08:34 +010080 .code = NETXBIG_V2_SWITCH_POWER_OFF,
81 .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_OFF,
Simon Guinot3e05ec12010-01-04 20:20:07 +010082 .desc = "Back power switch (auto|off)",
83 .active_low = 1,
84 },
85 [2] = {
86 .code = KEY_OPTION,
Simon Guinot57475b12010-02-08 19:08:34 +010087 .gpio = NETXBIG_V2_GPIO_FUNC_BUTTON,
Simon Guinot3e05ec12010-01-04 20:20:07 +010088 .desc = "Function button",
89 .active_low = 1,
90 },
91};
92
Simon Guinot57475b12010-02-08 19:08:34 +010093static struct gpio_keys_platform_data netxbig_v2_button_data = {
94 .buttons = netxbig_v2_buttons,
95 .nbuttons = ARRAY_SIZE(netxbig_v2_buttons),
Simon Guinot3e05ec12010-01-04 20:20:07 +010096};
97
Simon Guinot57475b12010-02-08 19:08:34 +010098static struct platform_device netxbig_v2_gpio_buttons = {
Simon Guinot3e05ec12010-01-04 20:20:07 +010099 .name = "gpio-keys",
100 .id = -1,
101 .dev = {
Simon Guinot57475b12010-02-08 19:08:34 +0100102 .platform_data = &netxbig_v2_button_data,
Simon Guinot3e05ec12010-01-04 20:20:07 +0100103 },
104};
105
106/*****************************************************************************
107 * GPIO LEDs
108 ****************************************************************************/
109
110/*
111 * The LEDs are controlled by a CPLD and can be configured through a GPIO
112 * extension bus:
113 *
114 * - address register : bit [0-2] -> GPIO [47-49]
115 * - data register : bit [0-2] -> GPIO [44-46]
116 * - enable register : GPIO 29
117 *
118 * Address register selection:
119 *
120 * addr | register
121 * ----------------------------
122 * 0 | front LED
123 * 1 | front LED brightness
124 * 2 | HDD LED brightness
125 * 3 | HDD1 LED
126 * 4 | HDD2 LED
127 * 5 | HDD3 LED
128 * 6 | HDD4 LED
129 * 7 | HDD5 LED
130 *
131 * Data register configuration:
132 *
133 * data | LED brightness
134 * -------------------------------------------------
135 * 0 | min (off)
136 * - | -
137 * 7 | max
138 *
139 * data | front LED mode
140 * -------------------------------------------------
141 * 0 | fix off
142 * 1 | fix blue on
143 * 2 | fix red on
144 * 3 | blink blue on=1 sec and blue off=1 sec
145 * 4 | blink red on=1 sec and red off=1 sec
146 * 5 | blink blue on=2.5 sec and red on=0.5 sec
147 * 6 | blink blue on=1 sec and red on=1 sec
148 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
149 *
150 * data | HDD LED mode
151 * -------------------------------------------------
152 * 0 | fix blue on
153 * 1 | SATA activity blink
154 * 2 | fix red on
155 * 3 | blink blue on=1 sec and blue off=1 sec
156 * 4 | blink red on=1 sec and red off=1 sec
157 * 5 | blink blue on=2.5 sec and red on=0.5 sec
158 * 6 | blink blue on=1 sec and red on=1 sec
159 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
160 */
161
162/*****************************************************************************
Simon Guinot3e05ec12010-01-04 20:20:07 +0100163 * General Setup
164 ****************************************************************************/
165
Simon Guinot57475b12010-02-08 19:08:34 +0100166static unsigned int net2big_v2_mpp_config[] __initdata = {
167 MPP0_SPI_SCn,
168 MPP1_SPI_MOSI,
169 MPP2_SPI_SCK,
170 MPP3_SPI_MISO,
171 MPP6_SYSRST_OUTn,
172 MPP7_GPO, /* Request power-off */
Benjamin Zores266a2452010-06-08 10:00:22 +0200173 MPP8_TW0_SDA,
174 MPP9_TW0_SCK,
Simon Guinot57475b12010-02-08 19:08:34 +0100175 MPP10_UART0_TXD,
176 MPP11_UART0_RXD,
177 MPP13_GPIO, /* Rear power switch (on|auto) */
178 MPP14_GPIO, /* USB fuse alarm */
179 MPP15_GPIO, /* Rear power switch (auto|off) */
180 MPP16_GPIO, /* SATA HDD1 power */
181 MPP17_GPIO, /* SATA HDD2 power */
182 MPP20_SATA1_ACTn,
183 MPP21_SATA0_ACTn,
184 MPP24_GPIO, /* USB mode select */
185 MPP26_GPIO, /* USB device vbus */
186 MPP28_GPIO, /* USB enable host vbus */
187 MPP29_GPIO, /* CPLD extension ALE */
188 MPP34_GPIO, /* Rear Push button */
189 MPP35_GPIO, /* Inhibit switch power-off */
190 MPP36_GPIO, /* SATA HDD1 presence */
191 MPP37_GPIO, /* SATA HDD2 presence */
192 MPP40_GPIO, /* eSATA presence */
193 MPP44_GPIO, /* CPLD extension (data 0) */
194 MPP45_GPIO, /* CPLD extension (data 1) */
195 MPP46_GPIO, /* CPLD extension (data 2) */
196 MPP47_GPIO, /* CPLD extension (addr 0) */
197 MPP48_GPIO, /* CPLD extension (addr 1) */
198 MPP49_GPIO, /* CPLD extension (addr 2) */
199 0
200};
201
Simon Guinot3e05ec12010-01-04 20:20:07 +0100202static unsigned int net5big_v2_mpp_config[] __initdata = {
203 MPP0_SPI_SCn,
204 MPP1_SPI_MOSI,
205 MPP2_SPI_SCK,
206 MPP3_SPI_MISO,
207 MPP6_SYSRST_OUTn,
208 MPP7_GPO, /* Request power-off */
Benjamin Zores266a2452010-06-08 10:00:22 +0200209 MPP8_TW0_SDA,
210 MPP9_TW0_SCK,
Simon Guinot3e05ec12010-01-04 20:20:07 +0100211 MPP10_UART0_TXD,
212 MPP11_UART0_RXD,
213 MPP13_GPIO, /* Rear power switch (on|auto) */
214 MPP14_GPIO, /* USB fuse alarm */
215 MPP15_GPIO, /* Rear power switch (auto|off) */
216 MPP16_GPIO, /* SATA HDD1 power */
217 MPP17_GPIO, /* SATA HDD2 power */
Benjamin Zores266a2452010-06-08 10:00:22 +0200218 MPP20_GE1_TXD0,
219 MPP21_GE1_TXD1,
220 MPP22_GE1_TXD2,
221 MPP23_GE1_TXD3,
222 MPP24_GE1_RXD0,
223 MPP25_GE1_RXD1,
224 MPP26_GE1_RXD2,
225 MPP27_GE1_RXD3,
Simon Guinot3e05ec12010-01-04 20:20:07 +0100226 MPP28_GPIO, /* USB enable host vbus */
227 MPP29_GPIO, /* CPLD extension ALE */
Benjamin Zores266a2452010-06-08 10:00:22 +0200228 MPP30_GE1_RXCTL,
229 MPP31_GE1_RXCLK,
230 MPP32_GE1_TCLKOUT,
231 MPP33_GE1_TXCTL,
Simon Guinot3e05ec12010-01-04 20:20:07 +0100232 MPP34_GPIO, /* Rear Push button */
233 MPP35_GPIO, /* Inhibit switch power-off */
234 MPP36_GPIO, /* SATA HDD1 presence */
235 MPP37_GPIO, /* SATA HDD2 presence */
236 MPP38_GPIO, /* SATA HDD3 presence */
237 MPP39_GPIO, /* SATA HDD4 presence */
238 MPP40_GPIO, /* SATA HDD5 presence */
239 MPP41_GPIO, /* SATA HDD3 power */
240 MPP42_GPIO, /* SATA HDD4 power */
241 MPP43_GPIO, /* SATA HDD5 power */
242 MPP44_GPIO, /* CPLD extension (data 0) */
243 MPP45_GPIO, /* CPLD extension (data 1) */
244 MPP46_GPIO, /* CPLD extension (data 2) */
245 MPP47_GPIO, /* CPLD extension (addr 0) */
246 MPP48_GPIO, /* CPLD extension (addr 1) */
247 MPP49_GPIO, /* CPLD extension (addr 2) */
248 0
249};
250
Simon Guinot57475b12010-02-08 19:08:34 +0100251#define NETXBIG_V2_GPIO_POWER_OFF 7
Simon Guinot3e05ec12010-01-04 20:20:07 +0100252
Simon Guinot57475b12010-02-08 19:08:34 +0100253static void netxbig_v2_power_off(void)
Simon Guinot3e05ec12010-01-04 20:20:07 +0100254{
Simon Guinot57475b12010-02-08 19:08:34 +0100255 gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF, 1);
Simon Guinot3e05ec12010-01-04 20:20:07 +0100256}
257
Simon Guinot57475b12010-02-08 19:08:34 +0100258static void __init netxbig_v2_init(void)
Simon Guinot3e05ec12010-01-04 20:20:07 +0100259{
260 /*
261 * Basic setup. Needs to be called early.
262 */
263 kirkwood_init();
Simon Guinot57475b12010-02-08 19:08:34 +0100264 if (machine_is_net2big_v2())
265 kirkwood_mpp_conf(net2big_v2_mpp_config);
266 else
267 kirkwood_mpp_conf(net5big_v2_mpp_config);
Simon Guinot3e05ec12010-01-04 20:20:07 +0100268
Simon Guinotb51d92d2010-09-19 15:33:59 +0200269 if (machine_is_net2big_v2())
270 lacie_v2_hdd_power_init(2);
271 else
272 lacie_v2_hdd_power_init(5);
Simon Guinot3e05ec12010-01-04 20:20:07 +0100273
274 kirkwood_ehci_init();
Simon Guinot57475b12010-02-08 19:08:34 +0100275 kirkwood_ge00_init(&netxbig_v2_ge00_data);
276 if (machine_is_net5big_v2())
277 kirkwood_ge01_init(&netxbig_v2_ge01_data);
278 kirkwood_sata_init(&netxbig_v2_sata_data);
Simon Guinot3e05ec12010-01-04 20:20:07 +0100279 kirkwood_uart0_init();
Simon Guinotb51d92d2010-09-19 15:33:59 +0200280 lacie_v2_register_flash();
281 lacie_v2_register_i2c_devices();
Simon Guinot3e05ec12010-01-04 20:20:07 +0100282
Simon Guinot57475b12010-02-08 19:08:34 +0100283 platform_device_register(&netxbig_v2_gpio_buttons);
Simon Guinot3e05ec12010-01-04 20:20:07 +0100284
Simon Guinot57475b12010-02-08 19:08:34 +0100285 if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&
286 gpio_direction_output(NETXBIG_V2_GPIO_POWER_OFF, 0) == 0)
287 pm_power_off = netxbig_v2_power_off;
Simon Guinot3e05ec12010-01-04 20:20:07 +0100288 else
Simon Guinot57475b12010-02-08 19:08:34 +0100289 pr_err("netxbig_v2: failed to configure power-off GPIO\n");
Simon Guinot3e05ec12010-01-04 20:20:07 +0100290}
291
Simon Guinot57475b12010-02-08 19:08:34 +0100292#ifdef CONFIG_MACH_NET2BIG_V2
293MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")
294 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
295 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
296 .boot_params = 0x00000100,
297 .init_machine = netxbig_v2_init,
298 .map_io = kirkwood_map_io,
299 .init_irq = kirkwood_init_irq,
Simon Guinotb51d92d2010-09-19 15:33:59 +0200300 .timer = &lacie_v2_timer,
Simon Guinot57475b12010-02-08 19:08:34 +0100301MACHINE_END
302#endif
303
304#ifdef CONFIG_MACH_NET5BIG_V2
Simon Guinot3e05ec12010-01-04 20:20:07 +0100305MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")
306 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
307 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
308 .boot_params = 0x00000100,
Simon Guinot57475b12010-02-08 19:08:34 +0100309 .init_machine = netxbig_v2_init,
Simon Guinot3e05ec12010-01-04 20:20:07 +0100310 .map_io = kirkwood_map_io,
311 .init_irq = kirkwood_init_irq,
Simon Guinotb51d92d2010-09-19 15:33:59 +0200312 .timer = &lacie_v2_timer,
Simon Guinot3e05ec12010-01-04 20:20:07 +0100313MACHINE_END
Simon Guinot57475b12010-02-08 19:08:34 +0100314#endif