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> |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/mach/arch.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 35 | #include <mach/kirkwood.h> |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 36 | #include <mach/leds-ns2.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 37 | #include "common.h" |
| 38 | #include "mpp.h" |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 39 | #include "lacie_v2-common.h" |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 40 | |
| 41 | /***************************************************************************** |
| 42 | * Ethernet |
| 43 | ****************************************************************************/ |
| 44 | |
| 45 | static struct mv643xx_eth_platform_data netspace_v2_ge00_data = { |
| 46 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 47 | }; |
| 48 | |
| 49 | /***************************************************************************** |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 50 | * SATA |
| 51 | ****************************************************************************/ |
| 52 | |
| 53 | static struct mv_sata_platform_data netspace_v2_sata_data = { |
| 54 | .n_ports = 2, |
| 55 | }; |
| 56 | |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 57 | /***************************************************************************** |
| 58 | * GPIO keys |
| 59 | ****************************************************************************/ |
| 60 | |
| 61 | #define NETSPACE_V2_PUSH_BUTTON 32 |
| 62 | |
| 63 | static struct gpio_keys_button netspace_v2_buttons[] = { |
| 64 | [0] = { |
| 65 | .code = KEY_POWER, |
| 66 | .gpio = NETSPACE_V2_PUSH_BUTTON, |
| 67 | .desc = "Power push button", |
| 68 | .active_low = 0, |
| 69 | }, |
| 70 | }; |
| 71 | |
| 72 | static struct gpio_keys_platform_data netspace_v2_button_data = { |
| 73 | .buttons = netspace_v2_buttons, |
| 74 | .nbuttons = ARRAY_SIZE(netspace_v2_buttons), |
| 75 | }; |
| 76 | |
| 77 | static struct platform_device netspace_v2_gpio_buttons = { |
| 78 | .name = "gpio-keys", |
| 79 | .id = -1, |
| 80 | .dev = { |
| 81 | .platform_data = &netspace_v2_button_data, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | /***************************************************************************** |
| 86 | * GPIO LEDs |
| 87 | ****************************************************************************/ |
| 88 | |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 89 | #define NETSPACE_V2_GPIO_RED_LED 12 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 90 | |
| 91 | static struct gpio_led netspace_v2_gpio_led_pins[] = { |
| 92 | { |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 93 | .name = "ns_v2:red:fail", |
| 94 | .gpio = NETSPACE_V2_GPIO_RED_LED, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 95 | }, |
| 96 | }; |
| 97 | |
| 98 | static struct gpio_led_platform_data netspace_v2_gpio_leds_data = { |
| 99 | .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins), |
| 100 | .leds = netspace_v2_gpio_led_pins, |
| 101 | }; |
| 102 | |
| 103 | static struct platform_device netspace_v2_gpio_leds = { |
| 104 | .name = "leds-gpio", |
| 105 | .id = -1, |
| 106 | .dev = { |
| 107 | .platform_data = &netspace_v2_gpio_leds_data, |
| 108 | }, |
| 109 | }; |
| 110 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 111 | /***************************************************************************** |
| 112 | * Dual-GPIO CPLD LEDs |
| 113 | ****************************************************************************/ |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 114 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 115 | #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29 |
| 116 | #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30 |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 117 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 118 | static struct ns2_led netspace_v2_led_pins[] = { |
| 119 | { |
| 120 | .name = "ns_v2:blue:sata", |
| 121 | .cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD, |
| 122 | .slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW, |
| 123 | }, |
| 124 | }; |
| 125 | |
| 126 | static struct ns2_led_platform_data netspace_v2_leds_data = { |
| 127 | .num_leds = ARRAY_SIZE(netspace_v2_led_pins), |
| 128 | .leds = netspace_v2_led_pins, |
| 129 | }; |
| 130 | |
| 131 | static struct platform_device netspace_v2_leds = { |
| 132 | .name = "leds-ns2", |
| 133 | .id = -1, |
| 134 | .dev = { |
| 135 | .platform_data = &netspace_v2_leds_data, |
| 136 | }, |
| 137 | }; |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 138 | |
| 139 | /***************************************************************************** |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 140 | * General Setup |
| 141 | ****************************************************************************/ |
| 142 | |
| 143 | static unsigned int netspace_v2_mpp_config[] __initdata = { |
| 144 | MPP0_SPI_SCn, |
| 145 | MPP1_SPI_MOSI, |
| 146 | MPP2_SPI_SCK, |
| 147 | MPP3_SPI_MISO, |
| 148 | MPP4_NF_IO6, |
| 149 | MPP5_NF_IO7, |
| 150 | MPP6_SYSRST_OUTn, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 151 | MPP7_GPO, /* Fan speed (bit 1) */ |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 152 | MPP8_TW0_SDA, |
| 153 | MPP9_TW0_SCK, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 154 | MPP10_UART0_TXD, |
| 155 | MPP11_UART0_RXD, |
| 156 | MPP12_GPO, /* Red led */ |
| 157 | MPP14_GPIO, /* USB fuse */ |
| 158 | MPP16_GPIO, /* SATA 0 power */ |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 159 | MPP17_GPIO, /* SATA 1 power */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 160 | MPP18_NF_IO0, |
| 161 | MPP19_NF_IO1, |
| 162 | MPP20_SATA1_ACTn, |
| 163 | MPP21_SATA0_ACTn, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 164 | MPP22_GPIO, /* Fan speed (bit 0) */ |
| 165 | MPP23_GPIO, /* Fan power */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 166 | MPP24_GPIO, /* USB mode select */ |
| 167 | MPP25_GPIO, /* Fan rotation fail */ |
| 168 | MPP26_GPIO, /* USB device vbus */ |
| 169 | MPP28_GPIO, /* USB enable host vbus */ |
| 170 | MPP29_GPIO, /* Blue led (slow register) */ |
| 171 | MPP30_GPIO, /* Blue led (command register) */ |
| 172 | MPP31_GPIO, /* Board power off */ |
| 173 | MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */ |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 174 | MPP33_GPO, /* Fan speed (bit 2) */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 175 | 0 |
| 176 | }; |
| 177 | |
| 178 | #define NETSPACE_V2_GPIO_POWER_OFF 31 |
| 179 | |
| 180 | static void netspace_v2_power_off(void) |
| 181 | { |
| 182 | gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1); |
| 183 | } |
| 184 | |
| 185 | static void __init netspace_v2_init(void) |
| 186 | { |
| 187 | /* |
| 188 | * Basic setup. Needs to be called early. |
| 189 | */ |
| 190 | kirkwood_init(); |
| 191 | kirkwood_mpp_conf(netspace_v2_mpp_config); |
| 192 | |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 193 | if (machine_is_netspace_max_v2()) |
| 194 | lacie_v2_hdd_power_init(2); |
| 195 | else |
| 196 | lacie_v2_hdd_power_init(1); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 197 | |
| 198 | kirkwood_ehci_init(); |
| 199 | kirkwood_ge00_init(&netspace_v2_ge00_data); |
| 200 | kirkwood_sata_init(&netspace_v2_sata_data); |
| 201 | kirkwood_uart0_init(); |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 202 | lacie_v2_register_flash(); |
| 203 | lacie_v2_register_i2c_devices(); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 204 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame] | 205 | platform_device_register(&netspace_v2_leds); |
| 206 | platform_device_register(&netspace_v2_gpio_leds); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 207 | platform_device_register(&netspace_v2_gpio_buttons); |
| 208 | |
| 209 | if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 && |
| 210 | gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0) |
| 211 | pm_power_off = netspace_v2_power_off; |
| 212 | else |
| 213 | pr_err("netspace_v2: failed to configure power-off GPIO\n"); |
| 214 | } |
| 215 | |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 216 | #ifdef CONFIG_MACH_NETSPACE_V2 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 217 | MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") |
| 218 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 219 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 220 | .boot_params = 0x00000100, |
| 221 | .init_machine = netspace_v2_init, |
| 222 | .map_io = kirkwood_map_io, |
| 223 | .init_irq = kirkwood_init_irq, |
Simon Guinot | d349182 | 2010-10-21 11:42:29 +0200 | [diff] [blame^] | 224 | .timer = &kirkwood_timer, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 225 | MACHINE_END |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 226 | #endif |
| 227 | |
| 228 | #ifdef CONFIG_MACH_INETSPACE_V2 |
| 229 | MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2") |
| 230 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 231 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 232 | .boot_params = 0x00000100, |
| 233 | .init_machine = netspace_v2_init, |
| 234 | .map_io = kirkwood_map_io, |
| 235 | .init_irq = kirkwood_init_irq, |
Simon Guinot | d349182 | 2010-10-21 11:42:29 +0200 | [diff] [blame^] | 236 | .timer = &kirkwood_timer, |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 237 | MACHINE_END |
| 238 | #endif |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 239 | |
| 240 | #ifdef CONFIG_MACH_NETSPACE_MAX_V2 |
| 241 | MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2") |
| 242 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 243 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 244 | .boot_params = 0x00000100, |
| 245 | .init_machine = netspace_v2_init, |
| 246 | .map_io = kirkwood_map_io, |
| 247 | .init_irq = kirkwood_init_irq, |
Simon Guinot | d349182 | 2010-10-21 11:42:29 +0200 | [diff] [blame^] | 248 | .timer = &kirkwood_timer, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 249 | MACHINE_END |
| 250 | #endif |