Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 1 | /* |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 2 | * arch/arm/mach-kirkwood/netxbig_v2-setup.c |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 3 | * |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 4 | * LaCie 2Big and 5Big Network v2 board setup |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 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> |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 26 | #include <linux/ata_platform.h> |
| 27 | #include <linux/mv643xx_eth.h> |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 28 | #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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 34 | #include <mach/kirkwood.h> |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 35 | #include "common.h" |
| 36 | #include "mpp.h" |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame^] | 37 | #include "lacie_v2-common.h" |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 38 | |
| 39 | /***************************************************************************** |
| 40 | * Ethernet |
| 41 | ****************************************************************************/ |
| 42 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 43 | static struct mv643xx_eth_platform_data netxbig_v2_ge00_data = { |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 44 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 45 | }; |
| 46 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 47 | static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = { |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 48 | .phy_addr = MV643XX_ETH_PHY_ADDR(0), |
| 49 | }; |
| 50 | |
| 51 | /***************************************************************************** |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 52 | * SATA |
| 53 | ****************************************************************************/ |
| 54 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 55 | static struct mv_sata_platform_data netxbig_v2_sata_data = { |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 56 | .n_ports = 2, |
| 57 | }; |
| 58 | |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 59 | /***************************************************************************** |
| 60 | * GPIO keys |
| 61 | ****************************************************************************/ |
| 62 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 63 | #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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 66 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 67 | #define NETXBIG_V2_SWITCH_POWER_ON 0x1 |
| 68 | #define NETXBIG_V2_SWITCH_POWER_OFF 0x2 |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 69 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 70 | static struct gpio_keys_button netxbig_v2_buttons[] = { |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 71 | [0] = { |
| 72 | .type = EV_SW, |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 73 | .code = NETXBIG_V2_SWITCH_POWER_ON, |
| 74 | .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_ON, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 75 | .desc = "Back power switch (on|auto)", |
| 76 | .active_low = 1, |
| 77 | }, |
| 78 | [1] = { |
| 79 | .type = EV_SW, |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 80 | .code = NETXBIG_V2_SWITCH_POWER_OFF, |
| 81 | .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_OFF, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 82 | .desc = "Back power switch (auto|off)", |
| 83 | .active_low = 1, |
| 84 | }, |
| 85 | [2] = { |
| 86 | .code = KEY_OPTION, |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 87 | .gpio = NETXBIG_V2_GPIO_FUNC_BUTTON, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 88 | .desc = "Function button", |
| 89 | .active_low = 1, |
| 90 | }, |
| 91 | }; |
| 92 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 93 | static struct gpio_keys_platform_data netxbig_v2_button_data = { |
| 94 | .buttons = netxbig_v2_buttons, |
| 95 | .nbuttons = ARRAY_SIZE(netxbig_v2_buttons), |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 98 | static struct platform_device netxbig_v2_gpio_buttons = { |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 99 | .name = "gpio-keys", |
| 100 | .id = -1, |
| 101 | .dev = { |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 102 | .platform_data = &netxbig_v2_button_data, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 103 | }, |
| 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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 163 | * General Setup |
| 164 | ****************************************************************************/ |
| 165 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 166 | static 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 Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 173 | MPP8_TW0_SDA, |
| 174 | MPP9_TW0_SCK, |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 175 | 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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 202 | static 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 Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 209 | MPP8_TW0_SDA, |
| 210 | MPP9_TW0_SCK, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 211 | 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 Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 218 | 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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 226 | MPP28_GPIO, /* USB enable host vbus */ |
| 227 | MPP29_GPIO, /* CPLD extension ALE */ |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 228 | MPP30_GE1_RXCTL, |
| 229 | MPP31_GE1_RXCLK, |
| 230 | MPP32_GE1_TCLKOUT, |
| 231 | MPP33_GE1_TXCTL, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 232 | 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 Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 251 | #define NETXBIG_V2_GPIO_POWER_OFF 7 |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 252 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 253 | static void netxbig_v2_power_off(void) |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 254 | { |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 255 | gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF, 1); |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 256 | } |
| 257 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 258 | static void __init netxbig_v2_init(void) |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 259 | { |
| 260 | /* |
| 261 | * Basic setup. Needs to be called early. |
| 262 | */ |
| 263 | kirkwood_init(); |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 264 | if (machine_is_net2big_v2()) |
| 265 | kirkwood_mpp_conf(net2big_v2_mpp_config); |
| 266 | else |
| 267 | kirkwood_mpp_conf(net5big_v2_mpp_config); |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 268 | |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame^] | 269 | if (machine_is_net2big_v2()) |
| 270 | lacie_v2_hdd_power_init(2); |
| 271 | else |
| 272 | lacie_v2_hdd_power_init(5); |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 273 | |
| 274 | kirkwood_ehci_init(); |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 275 | 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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 279 | kirkwood_uart0_init(); |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame^] | 280 | lacie_v2_register_flash(); |
| 281 | lacie_v2_register_i2c_devices(); |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 282 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 283 | platform_device_register(&netxbig_v2_gpio_buttons); |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 284 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 285 | 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 Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 288 | else |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 289 | pr_err("netxbig_v2: failed to configure power-off GPIO\n"); |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 290 | } |
| 291 | |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 292 | #ifdef CONFIG_MACH_NET2BIG_V2 |
| 293 | MACHINE_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 Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame^] | 300 | .timer = &lacie_v2_timer, |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 301 | MACHINE_END |
| 302 | #endif |
| 303 | |
| 304 | #ifdef CONFIG_MACH_NET5BIG_V2 |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 305 | MACHINE_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 Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 309 | .init_machine = netxbig_v2_init, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 310 | .map_io = kirkwood_map_io, |
| 311 | .init_irq = kirkwood_init_irq, |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame^] | 312 | .timer = &lacie_v2_timer, |
Simon Guinot | 3e05ec1 | 2010-01-04 20:20:07 +0100 | [diff] [blame] | 313 | MACHINE_END |
Simon Guinot | 57475b1 | 2010-02-08 19:08:34 +0100 | [diff] [blame] | 314 | #endif |