Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 1 | /* |
| 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> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 27 | #include <linux/ata_platform.h> |
| 28 | #include <linux/mv643xx_eth.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 29 | #include <linux/input.h> |
| 30 | #include <linux/gpio.h> |
| 31 | #include <linux/gpio_keys.h> |
| 32 | #include <linux/leds.h> |
Simon Guinot | 0ab83a7 | 2010-10-22 05:29:18 -0400 | [diff] [blame] | 33 | #include <linux/gpio-fan.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 36 | #include <mach/kirkwood.h> |
Arnd Bergmann | c02cecb | 2012-08-24 15:21:54 +0200 | [diff] [blame] | 37 | #include <linux/platform_data/leds-kirkwood-ns2.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 38 | #include "common.h" |
| 39 | #include "mpp.h" |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 40 | #include "lacie_v2-common.h" |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 41 | |
| 42 | /***************************************************************************** |
| 43 | * Ethernet |
| 44 | ****************************************************************************/ |
| 45 | |
| 46 | static struct mv643xx_eth_platform_data netspace_v2_ge00_data = { |
| 47 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 48 | }; |
| 49 | |
| 50 | /***************************************************************************** |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 51 | * SATA |
| 52 | ****************************************************************************/ |
| 53 | |
| 54 | static struct mv_sata_platform_data netspace_v2_sata_data = { |
| 55 | .n_ports = 2, |
| 56 | }; |
| 57 | |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 58 | /***************************************************************************** |
| 59 | * GPIO keys |
| 60 | ****************************************************************************/ |
| 61 | |
| 62 | #define NETSPACE_V2_PUSH_BUTTON 32 |
| 63 | |
| 64 | static struct gpio_keys_button netspace_v2_buttons[] = { |
| 65 | [0] = { |
| 66 | .code = KEY_POWER, |
| 67 | .gpio = NETSPACE_V2_PUSH_BUTTON, |
| 68 | .desc = "Power push button", |
| 69 | .active_low = 0, |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | static struct gpio_keys_platform_data netspace_v2_button_data = { |
| 74 | .buttons = netspace_v2_buttons, |
| 75 | .nbuttons = ARRAY_SIZE(netspace_v2_buttons), |
| 76 | }; |
| 77 | |
| 78 | static struct platform_device netspace_v2_gpio_buttons = { |
| 79 | .name = "gpio-keys", |
| 80 | .id = -1, |
| 81 | .dev = { |
| 82 | .platform_data = &netspace_v2_button_data, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | /***************************************************************************** |
| 87 | * GPIO LEDs |
| 88 | ****************************************************************************/ |
| 89 | |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 90 | #define NETSPACE_V2_GPIO_RED_LED 12 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 91 | |
| 92 | static struct gpio_led netspace_v2_gpio_led_pins[] = { |
| 93 | { |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 94 | .name = "ns_v2:red:fail", |
| 95 | .gpio = NETSPACE_V2_GPIO_RED_LED, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 96 | }, |
| 97 | }; |
| 98 | |
| 99 | static struct gpio_led_platform_data netspace_v2_gpio_leds_data = { |
| 100 | .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins), |
| 101 | .leds = netspace_v2_gpio_led_pins, |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device netspace_v2_gpio_leds = { |
| 105 | .name = "leds-gpio", |
| 106 | .id = -1, |
| 107 | .dev = { |
| 108 | .platform_data = &netspace_v2_gpio_leds_data, |
| 109 | }, |
| 110 | }; |
| 111 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 112 | /***************************************************************************** |
| 113 | * Dual-GPIO CPLD LEDs |
| 114 | ****************************************************************************/ |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 115 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 116 | #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29 |
| 117 | #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30 |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 118 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 119 | static struct ns2_led netspace_v2_led_pins[] = { |
| 120 | { |
| 121 | .name = "ns_v2:blue:sata", |
| 122 | .cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD, |
| 123 | .slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW, |
| 124 | }, |
| 125 | }; |
| 126 | |
| 127 | static struct ns2_led_platform_data netspace_v2_leds_data = { |
| 128 | .num_leds = ARRAY_SIZE(netspace_v2_led_pins), |
| 129 | .leds = netspace_v2_led_pins, |
| 130 | }; |
| 131 | |
| 132 | static struct platform_device netspace_v2_leds = { |
| 133 | .name = "leds-ns2", |
| 134 | .id = -1, |
| 135 | .dev = { |
| 136 | .platform_data = &netspace_v2_leds_data, |
| 137 | }, |
| 138 | }; |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 139 | |
| 140 | /***************************************************************************** |
Simon Guinot | 0ab83a7 | 2010-10-22 05:29:18 -0400 | [diff] [blame] | 141 | * GPIO fan |
| 142 | ****************************************************************************/ |
| 143 | |
| 144 | /* Designed for fan 40x40x16: ADDA AD0412LB-D50 6000rpm@12v */ |
| 145 | static struct gpio_fan_speed netspace_max_v2_fan_speed[] = { |
| 146 | { 0, 0 }, |
| 147 | { 1500, 15 }, |
| 148 | { 1700, 14 }, |
| 149 | { 1800, 13 }, |
| 150 | { 2100, 12 }, |
| 151 | { 3100, 11 }, |
| 152 | { 3300, 10 }, |
| 153 | { 4300, 9 }, |
| 154 | { 5500, 8 }, |
| 155 | }; |
| 156 | |
| 157 | static unsigned netspace_max_v2_fan_ctrl[] = { 22, 7, 33, 23 }; |
| 158 | |
| 159 | static struct gpio_fan_alarm netspace_max_v2_fan_alarm = { |
| 160 | .gpio = 25, |
| 161 | .active_low = 1, |
| 162 | }; |
| 163 | |
| 164 | static struct gpio_fan_platform_data netspace_max_v2_fan_data = { |
| 165 | .num_ctrl = ARRAY_SIZE(netspace_max_v2_fan_ctrl), |
| 166 | .ctrl = netspace_max_v2_fan_ctrl, |
| 167 | .alarm = &netspace_max_v2_fan_alarm, |
| 168 | .num_speed = ARRAY_SIZE(netspace_max_v2_fan_speed), |
| 169 | .speed = netspace_max_v2_fan_speed, |
| 170 | }; |
| 171 | |
| 172 | static struct platform_device netspace_max_v2_gpio_fan = { |
| 173 | .name = "gpio-fan", |
| 174 | .id = -1, |
| 175 | .dev = { |
| 176 | .platform_data = &netspace_max_v2_fan_data, |
| 177 | }, |
| 178 | }; |
| 179 | |
| 180 | /***************************************************************************** |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 181 | * General Setup |
| 182 | ****************************************************************************/ |
| 183 | |
| 184 | static unsigned int netspace_v2_mpp_config[] __initdata = { |
| 185 | MPP0_SPI_SCn, |
| 186 | MPP1_SPI_MOSI, |
| 187 | MPP2_SPI_SCK, |
| 188 | MPP3_SPI_MISO, |
| 189 | MPP4_NF_IO6, |
| 190 | MPP5_NF_IO7, |
| 191 | MPP6_SYSRST_OUTn, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 192 | MPP7_GPO, /* Fan speed (bit 1) */ |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 193 | MPP8_TW0_SDA, |
| 194 | MPP9_TW0_SCK, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 195 | MPP10_UART0_TXD, |
| 196 | MPP11_UART0_RXD, |
| 197 | MPP12_GPO, /* Red led */ |
| 198 | MPP14_GPIO, /* USB fuse */ |
| 199 | MPP16_GPIO, /* SATA 0 power */ |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 200 | MPP17_GPIO, /* SATA 1 power */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 201 | MPP18_NF_IO0, |
| 202 | MPP19_NF_IO1, |
| 203 | MPP20_SATA1_ACTn, |
| 204 | MPP21_SATA0_ACTn, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 205 | MPP22_GPIO, /* Fan speed (bit 0) */ |
| 206 | MPP23_GPIO, /* Fan power */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 207 | MPP24_GPIO, /* USB mode select */ |
| 208 | MPP25_GPIO, /* Fan rotation fail */ |
| 209 | MPP26_GPIO, /* USB device vbus */ |
| 210 | MPP28_GPIO, /* USB enable host vbus */ |
| 211 | MPP29_GPIO, /* Blue led (slow register) */ |
| 212 | MPP30_GPIO, /* Blue led (command register) */ |
| 213 | MPP31_GPIO, /* Board power off */ |
| 214 | MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */ |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 215 | MPP33_GPO, /* Fan speed (bit 2) */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 216 | 0 |
| 217 | }; |
| 218 | |
| 219 | #define NETSPACE_V2_GPIO_POWER_OFF 31 |
| 220 | |
| 221 | static void netspace_v2_power_off(void) |
| 222 | { |
| 223 | gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1); |
| 224 | } |
| 225 | |
| 226 | static void __init netspace_v2_init(void) |
| 227 | { |
| 228 | /* |
| 229 | * Basic setup. Needs to be called early. |
| 230 | */ |
| 231 | kirkwood_init(); |
| 232 | kirkwood_mpp_conf(netspace_v2_mpp_config); |
| 233 | |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 234 | if (machine_is_netspace_max_v2()) |
| 235 | lacie_v2_hdd_power_init(2); |
| 236 | else |
| 237 | lacie_v2_hdd_power_init(1); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 238 | |
| 239 | kirkwood_ehci_init(); |
| 240 | kirkwood_ge00_init(&netspace_v2_ge00_data); |
| 241 | kirkwood_sata_init(&netspace_v2_sata_data); |
| 242 | kirkwood_uart0_init(); |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 243 | lacie_v2_register_flash(); |
| 244 | lacie_v2_register_i2c_devices(); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 245 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 246 | platform_device_register(&netspace_v2_leds); |
| 247 | platform_device_register(&netspace_v2_gpio_leds); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 248 | platform_device_register(&netspace_v2_gpio_buttons); |
Simon Guinot | 0ab83a7 | 2010-10-22 05:29:18 -0400 | [diff] [blame] | 249 | if (machine_is_netspace_max_v2()) |
| 250 | platform_device_register(&netspace_max_v2_gpio_fan); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 251 | |
| 252 | if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 && |
| 253 | gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0) |
| 254 | pm_power_off = netspace_v2_power_off; |
| 255 | else |
| 256 | pr_err("netspace_v2: failed to configure power-off GPIO\n"); |
| 257 | } |
| 258 | |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 259 | #ifdef CONFIG_MACH_NETSPACE_V2 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 260 | MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 261 | .atag_offset = 0x100, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 262 | .init_machine = netspace_v2_init, |
| 263 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 264 | .init_early = kirkwood_init_early, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 265 | .init_irq = kirkwood_init_irq, |
Simon Guinot | d349182 | 2010-10-21 11:42:29 +0200 | [diff] [blame] | 266 | .timer = &kirkwood_timer, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 267 | .restart = kirkwood_restart, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 268 | MACHINE_END |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 269 | #endif |
| 270 | |
| 271 | #ifdef CONFIG_MACH_INETSPACE_V2 |
| 272 | MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2") |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 273 | .atag_offset = 0x100, |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 274 | .init_machine = netspace_v2_init, |
| 275 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 276 | .init_early = kirkwood_init_early, |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 277 | .init_irq = kirkwood_init_irq, |
Simon Guinot | d349182 | 2010-10-21 11:42:29 +0200 | [diff] [blame] | 278 | .timer = &kirkwood_timer, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 279 | .restart = kirkwood_restart, |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 280 | MACHINE_END |
| 281 | #endif |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 282 | |
| 283 | #ifdef CONFIG_MACH_NETSPACE_MAX_V2 |
| 284 | MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2") |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 285 | .atag_offset = 0x100, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 286 | .init_machine = netspace_v2_init, |
| 287 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 288 | .init_early = kirkwood_init_early, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 289 | .init_irq = kirkwood_init_irq, |
Simon Guinot | d349182 | 2010-10-21 11:42:29 +0200 | [diff] [blame] | 290 | .timer = &kirkwood_timer, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 291 | .restart = kirkwood_restart, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 292 | MACHINE_END |
| 293 | #endif |