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> |
| 42 | #include <plat/time.h> |
| 43 | #include "common.h" |
| 44 | #include "mpp.h" |
| 45 | |
| 46 | /***************************************************************************** |
| 47 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) |
| 48 | ****************************************************************************/ |
| 49 | |
| 50 | static struct mtd_partition netspace_v2_flash_parts[] = { |
| 51 | { |
| 52 | .name = "u-boot", |
| 53 | .size = MTDPART_SIZ_FULL, |
| 54 | .offset = 0, |
| 55 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | static const struct flash_platform_data netspace_v2_flash = { |
| 60 | .type = "mx25l4005a", |
| 61 | .name = "spi_flash", |
| 62 | .parts = netspace_v2_flash_parts, |
| 63 | .nr_parts = ARRAY_SIZE(netspace_v2_flash_parts), |
| 64 | }; |
| 65 | |
| 66 | static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = { |
| 67 | { |
| 68 | .modalias = "m25p80", |
| 69 | .platform_data = &netspace_v2_flash, |
| 70 | .irq = -1, |
| 71 | .max_speed_hz = 20000000, |
| 72 | .bus_num = 0, |
| 73 | .chip_select = 0, |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | /***************************************************************************** |
| 78 | * Ethernet |
| 79 | ****************************************************************************/ |
| 80 | |
| 81 | static struct mv643xx_eth_platform_data netspace_v2_ge00_data = { |
| 82 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 83 | }; |
| 84 | |
| 85 | /***************************************************************************** |
| 86 | * I2C devices |
| 87 | ****************************************************************************/ |
| 88 | |
| 89 | static struct at24_platform_data at24c04 = { |
| 90 | .byte_len = SZ_4K / 8, |
| 91 | .page_size = 16, |
| 92 | }; |
| 93 | |
| 94 | /* |
| 95 | * i2c addr | chip | description |
| 96 | * 0x50 | HT24LC04 | eeprom (512B) |
| 97 | */ |
| 98 | |
| 99 | static struct i2c_board_info __initdata netspace_v2_i2c_info[] = { |
| 100 | { |
| 101 | I2C_BOARD_INFO("24c04", 0x50), |
| 102 | .platform_data = &at24c04, |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | /***************************************************************************** |
| 107 | * SATA |
| 108 | ****************************************************************************/ |
| 109 | |
| 110 | static struct mv_sata_platform_data netspace_v2_sata_data = { |
| 111 | .n_ports = 2, |
| 112 | }; |
| 113 | |
| 114 | #define NETSPACE_V2_GPIO_SATA0_POWER 16 |
| 115 | #define NETSPACE_V2_GPIO_SATA1_POWER 17 |
| 116 | |
| 117 | static void __init netspace_v2_sata_power_init(void) |
| 118 | { |
| 119 | int err; |
| 120 | |
| 121 | err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power"); |
| 122 | if (err == 0) { |
| 123 | err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1); |
| 124 | if (err) |
| 125 | gpio_free(NETSPACE_V2_GPIO_SATA0_POWER); |
| 126 | } |
| 127 | if (err) |
| 128 | pr_err("netspace_v2: failed to setup SATA0 power\n"); |
| 129 | } |
| 130 | |
| 131 | /***************************************************************************** |
| 132 | * GPIO keys |
| 133 | ****************************************************************************/ |
| 134 | |
| 135 | #define NETSPACE_V2_PUSH_BUTTON 32 |
| 136 | |
| 137 | static struct gpio_keys_button netspace_v2_buttons[] = { |
| 138 | [0] = { |
| 139 | .code = KEY_POWER, |
| 140 | .gpio = NETSPACE_V2_PUSH_BUTTON, |
| 141 | .desc = "Power push button", |
| 142 | .active_low = 0, |
| 143 | }, |
| 144 | }; |
| 145 | |
| 146 | static struct gpio_keys_platform_data netspace_v2_button_data = { |
| 147 | .buttons = netspace_v2_buttons, |
| 148 | .nbuttons = ARRAY_SIZE(netspace_v2_buttons), |
| 149 | }; |
| 150 | |
| 151 | static struct platform_device netspace_v2_gpio_buttons = { |
| 152 | .name = "gpio-keys", |
| 153 | .id = -1, |
| 154 | .dev = { |
| 155 | .platform_data = &netspace_v2_button_data, |
| 156 | }, |
| 157 | }; |
| 158 | |
| 159 | /***************************************************************************** |
| 160 | * GPIO LEDs |
| 161 | ****************************************************************************/ |
| 162 | |
| 163 | /* |
| 164 | * The blue front LED is wired to a CPLD and can blink in relation with the |
| 165 | * SATA activity. |
| 166 | * |
| 167 | * The following array detail the different LED registers and the combination |
| 168 | * of their possible values: |
| 169 | * |
| 170 | * cmd_led | slow_led | /SATA active | LED state |
| 171 | * | | | |
| 172 | * 1 | 0 | x | off |
| 173 | * - | 1 | x | on |
| 174 | * 0 | 0 | 1 | on |
| 175 | * 0 | 0 | 0 | blink (rate 300ms) |
| 176 | */ |
| 177 | |
| 178 | #define NETSPACE_V2_GPIO_RED_LED 12 |
| 179 | #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29 |
| 180 | #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30 |
| 181 | |
| 182 | |
| 183 | static struct gpio_led netspace_v2_gpio_led_pins[] = { |
| 184 | { |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 185 | .name = "ns_v2:blue:sata", |
| 186 | .default_trigger = "default-on", |
| 187 | .gpio = NETSPACE_V2_GPIO_BLUE_LED_CMD, |
| 188 | .active_low = 1, |
| 189 | }, |
| 190 | { |
| 191 | .name = "ns_v2:red:fail", |
| 192 | .gpio = NETSPACE_V2_GPIO_RED_LED, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 193 | }, |
| 194 | }; |
| 195 | |
| 196 | static struct gpio_led_platform_data netspace_v2_gpio_leds_data = { |
| 197 | .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins), |
| 198 | .leds = netspace_v2_gpio_led_pins, |
| 199 | }; |
| 200 | |
| 201 | static struct platform_device netspace_v2_gpio_leds = { |
| 202 | .name = "leds-gpio", |
| 203 | .id = -1, |
| 204 | .dev = { |
| 205 | .platform_data = &netspace_v2_gpio_leds_data, |
| 206 | }, |
| 207 | }; |
| 208 | |
| 209 | static void __init netspace_v2_gpio_leds_init(void) |
| 210 | { |
Simon Guinot | 1afeea8 | 2010-02-09 21:20:56 +0100 | [diff] [blame] | 211 | int err; |
| 212 | |
| 213 | /* Configure register slow_led to allow SATA activity LED blinking */ |
| 214 | err = gpio_request(NETSPACE_V2_GPIO_BLUE_LED_SLOW, "blue LED slow"); |
| 215 | if (err == 0) { |
| 216 | err = gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_SLOW, 0); |
| 217 | if (err) |
| 218 | gpio_free(NETSPACE_V2_GPIO_BLUE_LED_SLOW); |
| 219 | } |
| 220 | if (err) |
| 221 | pr_err("netspace_v2: failed to configure blue LED slow GPIO\n"); |
| 222 | |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 223 | platform_device_register(&netspace_v2_gpio_leds); |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 224 | } |
| 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, |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame^] | 252 | MPP8_TW0_SDA, |
| 253 | MPP9_TW0_SCK, |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 254 | MPP10_UART0_TXD, |
| 255 | MPP11_UART0_RXD, |
| 256 | MPP12_GPO, /* Red led */ |
| 257 | MPP14_GPIO, /* USB fuse */ |
| 258 | MPP16_GPIO, /* SATA 0 power */ |
| 259 | MPP18_NF_IO0, |
| 260 | MPP19_NF_IO1, |
| 261 | MPP20_SATA1_ACTn, |
| 262 | MPP21_SATA0_ACTn, |
| 263 | MPP24_GPIO, /* USB mode select */ |
| 264 | MPP25_GPIO, /* Fan rotation fail */ |
| 265 | MPP26_GPIO, /* USB device vbus */ |
| 266 | MPP28_GPIO, /* USB enable host vbus */ |
| 267 | MPP29_GPIO, /* Blue led (slow register) */ |
| 268 | MPP30_GPIO, /* Blue led (command register) */ |
| 269 | MPP31_GPIO, /* Board power off */ |
| 270 | MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */ |
| 271 | 0 |
| 272 | }; |
| 273 | |
| 274 | #define NETSPACE_V2_GPIO_POWER_OFF 31 |
| 275 | |
| 276 | static void netspace_v2_power_off(void) |
| 277 | { |
| 278 | gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1); |
| 279 | } |
| 280 | |
| 281 | static void __init netspace_v2_init(void) |
| 282 | { |
| 283 | /* |
| 284 | * Basic setup. Needs to be called early. |
| 285 | */ |
| 286 | kirkwood_init(); |
| 287 | kirkwood_mpp_conf(netspace_v2_mpp_config); |
| 288 | |
| 289 | netspace_v2_sata_power_init(); |
| 290 | |
| 291 | kirkwood_ehci_init(); |
| 292 | kirkwood_ge00_init(&netspace_v2_ge00_data); |
| 293 | kirkwood_sata_init(&netspace_v2_sata_data); |
| 294 | kirkwood_uart0_init(); |
| 295 | spi_register_board_info(netspace_v2_spi_slave_info, |
| 296 | ARRAY_SIZE(netspace_v2_spi_slave_info)); |
| 297 | kirkwood_spi_init(); |
| 298 | kirkwood_i2c_init(); |
| 299 | i2c_register_board_info(0, netspace_v2_i2c_info, |
| 300 | ARRAY_SIZE(netspace_v2_i2c_info)); |
| 301 | |
| 302 | netspace_v2_gpio_leds_init(); |
| 303 | platform_device_register(&netspace_v2_gpio_buttons); |
| 304 | |
| 305 | if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 && |
| 306 | gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0) |
| 307 | pm_power_off = netspace_v2_power_off; |
| 308 | else |
| 309 | pr_err("netspace_v2: failed to configure power-off GPIO\n"); |
| 310 | } |
| 311 | |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 312 | #ifdef CONFIG_MACH_NETSPACE_V2 |
Simon Guinot | 1cb9f9b | 2009-12-09 01:43:49 +0100 | [diff] [blame] | 313 | MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") |
| 314 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 315 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 316 | .boot_params = 0x00000100, |
| 317 | .init_machine = netspace_v2_init, |
| 318 | .map_io = kirkwood_map_io, |
| 319 | .init_irq = kirkwood_init_irq, |
| 320 | .timer = &netspace_v2_timer, |
| 321 | MACHINE_END |
Simon Guinot | ca9cea9 | 2010-02-09 21:20:55 +0100 | [diff] [blame] | 322 | #endif |
| 323 | |
| 324 | #ifdef CONFIG_MACH_INETSPACE_V2 |
| 325 | MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2") |
| 326 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, |
| 327 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, |
| 328 | .boot_params = 0x00000100, |
| 329 | .init_machine = netspace_v2_init, |
| 330 | .map_io = kirkwood_map_io, |
| 331 | .init_irq = kirkwood_init_irq, |
| 332 | .timer = &netspace_v2_timer, |
| 333 | MACHINE_END |
| 334 | #endif |