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> |
| 27 | #include <linux/mtd/physmap.h> |
| 28 | #include <linux/spi/flash.h> |
| 29 | #include <linux/spi/spi.h> |
| 30 | #include <linux/ata_platform.h> |
| 31 | #include <linux/mv643xx_eth.h> |
| 32 | #include <linux/i2c.h> |
| 33 | #include <linux/i2c/at24.h> |
| 34 | #include <linux/input.h> |
| 35 | #include <linux/gpio.h> |
| 36 | #include <linux/gpio_keys.h> |
| 37 | #include <linux/leds.h> |
| 38 | #include <asm/mach-types.h> |
| 39 | #include <asm/mach/arch.h> |
| 40 | #include <asm/mach/time.h> |
| 41 | #include <mach/kirkwood.h> |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame^] | 42 | #include <mach/leds-ns2.h> |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 43 | #include <plat/time.h> |
| 44 | #include "common.h" |
| 45 | #include "mpp.h" |
| 46 | |
| 47 | /***************************************************************************** |
| 48 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) |
| 49 | ****************************************************************************/ |
| 50 | |
| 51 | static struct mtd_partition netspace_v2_flash_parts[] = { |
| 52 | { |
| 53 | .name = "u-boot", |
| 54 | .size = MTDPART_SIZ_FULL, |
| 55 | .offset = 0, |
| 56 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | static const struct flash_platform_data netspace_v2_flash = { |
| 61 | .type = "mx25l4005a", |
| 62 | .name = "spi_flash", |
| 63 | .parts = netspace_v2_flash_parts, |
| 64 | .nr_parts = ARRAY_SIZE(netspace_v2_flash_parts), |
| 65 | }; |
| 66 | |
| 67 | static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = { |
| 68 | { |
| 69 | .modalias = "m25p80", |
| 70 | .platform_data = &netspace_v2_flash, |
| 71 | .irq = -1, |
| 72 | .max_speed_hz = 20000000, |
| 73 | .bus_num = 0, |
| 74 | .chip_select = 0, |
| 75 | }, |
| 76 | }; |
| 77 | |
| 78 | /***************************************************************************** |
| 79 | * Ethernet |
| 80 | ****************************************************************************/ |
| 81 | |
| 82 | static struct mv643xx_eth_platform_data netspace_v2_ge00_data = { |
| 83 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 84 | }; |
| 85 | |
| 86 | /***************************************************************************** |
| 87 | * I2C devices |
| 88 | ****************************************************************************/ |
| 89 | |
| 90 | static struct at24_platform_data at24c04 = { |
| 91 | .byte_len = SZ_4K / 8, |
| 92 | .page_size = 16, |
| 93 | }; |
| 94 | |
| 95 | /* |
| 96 | * i2c addr | chip | description |
| 97 | * 0x50 | HT24LC04 | eeprom (512B) |
| 98 | */ |
| 99 | |
| 100 | static struct i2c_board_info __initdata netspace_v2_i2c_info[] = { |
| 101 | { |
| 102 | I2C_BOARD_INFO("24c04", 0x50), |
| 103 | .platform_data = &at24c04, |
| 104 | } |
| 105 | }; |
| 106 | |
| 107 | /***************************************************************************** |
| 108 | * SATA |
| 109 | ****************************************************************************/ |
| 110 | |
| 111 | static struct mv_sata_platform_data netspace_v2_sata_data = { |
| 112 | .n_ports = 2, |
| 113 | }; |
| 114 | |
| 115 | #define NETSPACE_V2_GPIO_SATA0_POWER 16 |
| 116 | #define NETSPACE_V2_GPIO_SATA1_POWER 17 |
| 117 | |
| 118 | static void __init netspace_v2_sata_power_init(void) |
| 119 | { |
| 120 | int err; |
| 121 | |
| 122 | err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power"); |
| 123 | if (err == 0) { |
| 124 | err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1); |
| 125 | if (err) |
| 126 | gpio_free(NETSPACE_V2_GPIO_SATA0_POWER); |
| 127 | } |
| 128 | if (err) |
| 129 | pr_err("netspace_v2: failed to setup SATA0 power\n"); |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 130 | |
| 131 | if (machine_is_netspace_max_v2()) { |
| 132 | err = gpio_request(NETSPACE_V2_GPIO_SATA1_POWER, "SATA1 power"); |
| 133 | if (err == 0) { |
| 134 | err = gpio_direction_output( |
| 135 | NETSPACE_V2_GPIO_SATA1_POWER, 1); |
| 136 | if (err) |
| 137 | gpio_free(NETSPACE_V2_GPIO_SATA1_POWER); |
| 138 | } |
| 139 | if (err) |
| 140 | pr_err("netspace_v2: failed to setup SATA1 power\n"); |
| 141 | } |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /***************************************************************************** |
| 145 | * GPIO keys |
| 146 | ****************************************************************************/ |
| 147 | |
| 148 | #define NETSPACE_V2_PUSH_BUTTON 32 |
| 149 | |
| 150 | static struct gpio_keys_button netspace_v2_buttons[] = { |
| 151 | [0] = { |
| 152 | .code = KEY_POWER, |
| 153 | .gpio = NETSPACE_V2_PUSH_BUTTON, |
| 154 | .desc = "Power push button", |
| 155 | .active_low = 0, |
| 156 | }, |
| 157 | }; |
| 158 | |
| 159 | static struct gpio_keys_platform_data netspace_v2_button_data = { |
| 160 | .buttons = netspace_v2_buttons, |
| 161 | .nbuttons = ARRAY_SIZE(netspace_v2_buttons), |
| 162 | }; |
| 163 | |
| 164 | static struct platform_device netspace_v2_gpio_buttons = { |
| 165 | .name = "gpio-keys", |
| 166 | .id = -1, |
| 167 | .dev = { |
| 168 | .platform_data = &netspace_v2_button_data, |
| 169 | }, |
| 170 | }; |
| 171 | |
| 172 | /***************************************************************************** |
| 173 | * GPIO LEDs |
| 174 | ****************************************************************************/ |
| 175 | |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 176 | #define NETSPACE_V2_GPIO_RED_LED 12 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 177 | |
| 178 | static struct gpio_led netspace_v2_gpio_led_pins[] = { |
| 179 | { |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame^] | 180 | .name = "ns_v2:red:fail", |
| 181 | .gpio = NETSPACE_V2_GPIO_RED_LED, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 182 | }, |
| 183 | }; |
| 184 | |
| 185 | static struct gpio_led_platform_data netspace_v2_gpio_leds_data = { |
| 186 | .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins), |
| 187 | .leds = netspace_v2_gpio_led_pins, |
| 188 | }; |
| 189 | |
| 190 | static struct platform_device netspace_v2_gpio_leds = { |
| 191 | .name = "leds-gpio", |
| 192 | .id = -1, |
| 193 | .dev = { |
| 194 | .platform_data = &netspace_v2_gpio_leds_data, |
| 195 | }, |
| 196 | }; |
| 197 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame^] | 198 | /***************************************************************************** |
| 199 | * Dual-GPIO CPLD LEDs |
| 200 | ****************************************************************************/ |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 201 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame^] | 202 | #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29 |
| 203 | #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30 |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 204 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame^] | 205 | static struct ns2_led netspace_v2_led_pins[] = { |
| 206 | { |
| 207 | .name = "ns_v2:blue:sata", |
| 208 | .cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD, |
| 209 | .slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW, |
| 210 | }, |
| 211 | }; |
| 212 | |
| 213 | static struct ns2_led_platform_data netspace_v2_leds_data = { |
| 214 | .num_leds = ARRAY_SIZE(netspace_v2_led_pins), |
| 215 | .leds = netspace_v2_led_pins, |
| 216 | }; |
| 217 | |
| 218 | static struct platform_device netspace_v2_leds = { |
| 219 | .name = "leds-ns2", |
| 220 | .id = -1, |
| 221 | .dev = { |
| 222 | .platform_data = &netspace_v2_leds_data, |
| 223 | }, |
| 224 | }; |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 225 | |
| 226 | /***************************************************************************** |
| 227 | * Timer |
| 228 | ****************************************************************************/ |
| 229 | |
| 230 | static void netspace_v2_timer_init(void) |
| 231 | { |
| 232 | kirkwood_tclk = 166666667; |
| 233 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); |
| 234 | } |
| 235 | |
| 236 | struct sys_timer netspace_v2_timer = { |
| 237 | .init = netspace_v2_timer_init, |
| 238 | }; |
| 239 | |
| 240 | /***************************************************************************** |
| 241 | * General Setup |
| 242 | ****************************************************************************/ |
| 243 | |
| 244 | static unsigned int netspace_v2_mpp_config[] __initdata = { |
| 245 | MPP0_SPI_SCn, |
| 246 | MPP1_SPI_MOSI, |
| 247 | MPP2_SPI_SCK, |
| 248 | MPP3_SPI_MISO, |
| 249 | MPP4_NF_IO6, |
| 250 | MPP5_NF_IO7, |
| 251 | MPP6_SYSRST_OUTn, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 252 | MPP7_GPO, /* Fan speed (bit 1) */ |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 253 | MPP8_TW0_SDA, |
| 254 | MPP9_TW0_SCK, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 255 | MPP10_UART0_TXD, |
| 256 | MPP11_UART0_RXD, |
| 257 | MPP12_GPO, /* Red led */ |
| 258 | MPP14_GPIO, /* USB fuse */ |
| 259 | MPP16_GPIO, /* SATA 0 power */ |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 260 | MPP17_GPIO, /* SATA 1 power */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 261 | MPP18_NF_IO0, |
| 262 | MPP19_NF_IO1, |
| 263 | MPP20_SATA1_ACTn, |
| 264 | MPP21_SATA0_ACTn, |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 265 | MPP22_GPIO, /* Fan speed (bit 0) */ |
| 266 | MPP23_GPIO, /* Fan power */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 267 | MPP24_GPIO, /* USB mode select */ |
| 268 | MPP25_GPIO, /* Fan rotation fail */ |
| 269 | MPP26_GPIO, /* USB device vbus */ |
| 270 | MPP28_GPIO, /* USB enable host vbus */ |
| 271 | MPP29_GPIO, /* Blue led (slow register) */ |
| 272 | MPP30_GPIO, /* Blue led (command register) */ |
| 273 | MPP31_GPIO, /* Board power off */ |
| 274 | MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */ |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 275 | MPP33_GPO, /* Fan speed (bit 2) */ |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 276 | 0 |
| 277 | }; |
| 278 | |
| 279 | #define NETSPACE_V2_GPIO_POWER_OFF 31 |
| 280 | |
| 281 | static void netspace_v2_power_off(void) |
| 282 | { |
| 283 | gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1); |
| 284 | } |
| 285 | |
| 286 | static void __init netspace_v2_init(void) |
| 287 | { |
| 288 | /* |
| 289 | * Basic setup. Needs to be called early. |
| 290 | */ |
| 291 | kirkwood_init(); |
| 292 | kirkwood_mpp_conf(netspace_v2_mpp_config); |
| 293 | |
| 294 | netspace_v2_sata_power_init(); |
| 295 | |
| 296 | kirkwood_ehci_init(); |
| 297 | kirkwood_ge00_init(&netspace_v2_ge00_data); |
| 298 | kirkwood_sata_init(&netspace_v2_sata_data); |
| 299 | kirkwood_uart0_init(); |
| 300 | spi_register_board_info(netspace_v2_spi_slave_info, |
| 301 | ARRAY_SIZE(netspace_v2_spi_slave_info)); |
| 302 | kirkwood_spi_init(); |
| 303 | kirkwood_i2c_init(); |
| 304 | i2c_register_board_info(0, netspace_v2_i2c_info, |
| 305 | ARRAY_SIZE(netspace_v2_i2c_info)); |
| 306 | |
Simon Guinot | 2641375 | 2010-07-06 16:08:47 +0200 | [diff] [blame^] | 307 | platform_device_register(&netspace_v2_leds); |
| 308 | platform_device_register(&netspace_v2_gpio_leds); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 309 | platform_device_register(&netspace_v2_gpio_buttons); |
| 310 | |
| 311 | if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 && |
| 312 | gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0) |
| 313 | pm_power_off = netspace_v2_power_off; |
| 314 | else |
| 315 | pr_err("netspace_v2: failed to configure power-off GPIO\n"); |
| 316 | } |
| 317 | |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 318 | #ifdef CONFIG_MACH_NETSPACE_V2 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 319 | MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") |
| 320 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 321 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 322 | .boot_params = 0x00000100, |
| 323 | .init_machine = netspace_v2_init, |
| 324 | .map_io = kirkwood_map_io, |
| 325 | .init_irq = kirkwood_init_irq, |
| 326 | .timer = &netspace_v2_timer, |
| 327 | MACHINE_END |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 328 | #endif |
| 329 | |
| 330 | #ifdef CONFIG_MACH_INETSPACE_V2 |
| 331 | MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2") |
| 332 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 333 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 334 | .boot_params = 0x00000100, |
| 335 | .init_machine = netspace_v2_init, |
| 336 | .map_io = kirkwood_map_io, |
| 337 | .init_irq = kirkwood_init_irq, |
| 338 | .timer = &netspace_v2_timer, |
| 339 | MACHINE_END |
| 340 | #endif |
Simon Guinot | b6a044f | 2010-07-05 12:31:04 +0200 | [diff] [blame] | 341 | |
| 342 | #ifdef CONFIG_MACH_NETSPACE_MAX_V2 |
| 343 | MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2") |
| 344 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 345 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 346 | .boot_params = 0x00000100, |
| 347 | .init_machine = netspace_v2_init, |
| 348 | .map_io = kirkwood_map_io, |
| 349 | .init_irq = kirkwood_init_irq, |
| 350 | .timer = &netspace_v2_timer, |
| 351 | MACHINE_END |
| 352 | #endif |