Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-kirkwood/d2net_v2-setup.c |
| 3 | * |
| 4 | * LaCie d2 Network Space v2 Board Setup |
| 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 | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 26 | #include <linux/ata_platform.h> |
| 27 | #include <linux/mv643xx_eth.h> |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [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 | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 34 | #include <mach/kirkwood.h> |
Arnd Bergmann | c02cecb | 2012-08-24 15:21:54 +0200 | [diff] [blame] | 35 | #include <linux/platform_data/leds-kirkwood-ns2.h> |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 36 | #include "common.h" |
| 37 | #include "mpp.h" |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 38 | #include "lacie_v2-common.h" |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 39 | |
| 40 | /***************************************************************************** |
| 41 | * Ethernet |
| 42 | ****************************************************************************/ |
| 43 | |
| 44 | static struct mv643xx_eth_platform_data d2net_v2_ge00_data = { |
| 45 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 46 | }; |
| 47 | |
| 48 | /***************************************************************************** |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 49 | * SATA |
| 50 | ****************************************************************************/ |
| 51 | |
| 52 | static struct mv_sata_platform_data d2net_v2_sata_data = { |
| 53 | .n_ports = 2, |
| 54 | }; |
| 55 | |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 56 | /***************************************************************************** |
| 57 | * GPIO keys |
| 58 | ****************************************************************************/ |
| 59 | |
| 60 | #define D2NET_V2_GPIO_PUSH_BUTTON 34 |
| 61 | #define D2NET_V2_GPIO_POWER_SWITCH_ON 13 |
| 62 | #define D2NET_V2_GPIO_POWER_SWITCH_OFF 15 |
| 63 | |
| 64 | #define D2NET_V2_SWITCH_POWER_ON 0x1 |
| 65 | #define D2NET_V2_SWITCH_POWER_OFF 0x2 |
| 66 | |
| 67 | static struct gpio_keys_button d2net_v2_buttons[] = { |
| 68 | [0] = { |
| 69 | .type = EV_SW, |
| 70 | .code = D2NET_V2_SWITCH_POWER_ON, |
| 71 | .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON, |
| 72 | .desc = "Back power switch (on|auto)", |
| 73 | .active_low = 0, |
| 74 | }, |
| 75 | [1] = { |
| 76 | .type = EV_SW, |
| 77 | .code = D2NET_V2_SWITCH_POWER_OFF, |
| 78 | .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF, |
| 79 | .desc = "Back power switch (auto|off)", |
| 80 | .active_low = 0, |
| 81 | }, |
| 82 | [2] = { |
| 83 | .code = KEY_POWER, |
| 84 | .gpio = D2NET_V2_GPIO_PUSH_BUTTON, |
| 85 | .desc = "Front Push Button", |
| 86 | .active_low = 1, |
| 87 | }, |
| 88 | }; |
| 89 | |
| 90 | static struct gpio_keys_platform_data d2net_v2_button_data = { |
| 91 | .buttons = d2net_v2_buttons, |
| 92 | .nbuttons = ARRAY_SIZE(d2net_v2_buttons), |
| 93 | }; |
| 94 | |
| 95 | static struct platform_device d2net_v2_gpio_buttons = { |
| 96 | .name = "gpio-keys", |
| 97 | .id = -1, |
| 98 | .dev = { |
| 99 | .platform_data = &d2net_v2_button_data, |
| 100 | }, |
| 101 | }; |
| 102 | |
| 103 | /***************************************************************************** |
| 104 | * GPIO LEDs |
| 105 | ****************************************************************************/ |
| 106 | |
| 107 | #define D2NET_V2_GPIO_RED_LED 12 |
| 108 | |
| 109 | static struct gpio_led d2net_v2_gpio_led_pins[] = { |
| 110 | { |
| 111 | .name = "d2net_v2:red:fail", |
| 112 | .gpio = D2NET_V2_GPIO_RED_LED, |
| 113 | }, |
| 114 | }; |
| 115 | |
| 116 | static struct gpio_led_platform_data d2net_v2_gpio_leds_data = { |
| 117 | .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins), |
| 118 | .leds = d2net_v2_gpio_led_pins, |
| 119 | }; |
| 120 | |
| 121 | static struct platform_device d2net_v2_gpio_leds = { |
| 122 | .name = "leds-gpio", |
| 123 | .id = -1, |
| 124 | .dev = { |
| 125 | .platform_data = &d2net_v2_gpio_leds_data, |
| 126 | }, |
| 127 | }; |
| 128 | |
| 129 | /***************************************************************************** |
| 130 | * Dual-GPIO CPLD LEDs |
| 131 | ****************************************************************************/ |
| 132 | |
| 133 | #define D2NET_V2_GPIO_BLUE_LED_SLOW 29 |
| 134 | #define D2NET_V2_GPIO_BLUE_LED_CMD 30 |
| 135 | |
| 136 | static struct ns2_led d2net_v2_led_pins[] = { |
| 137 | { |
| 138 | .name = "d2net_v2:blue:sata", |
| 139 | .cmd = D2NET_V2_GPIO_BLUE_LED_CMD, |
| 140 | .slow = D2NET_V2_GPIO_BLUE_LED_SLOW, |
| 141 | }, |
| 142 | }; |
| 143 | |
| 144 | static struct ns2_led_platform_data d2net_v2_leds_data = { |
| 145 | .num_leds = ARRAY_SIZE(d2net_v2_led_pins), |
| 146 | .leds = d2net_v2_led_pins, |
| 147 | }; |
| 148 | |
| 149 | static struct platform_device d2net_v2_leds = { |
| 150 | .name = "leds-ns2", |
| 151 | .id = -1, |
| 152 | .dev = { |
| 153 | .platform_data = &d2net_v2_leds_data, |
| 154 | }, |
| 155 | }; |
| 156 | |
| 157 | /***************************************************************************** |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 158 | * General Setup |
| 159 | ****************************************************************************/ |
| 160 | |
| 161 | static unsigned int d2net_v2_mpp_config[] __initdata = { |
| 162 | MPP0_SPI_SCn, |
| 163 | MPP1_SPI_MOSI, |
| 164 | MPP2_SPI_SCK, |
| 165 | MPP3_SPI_MISO, |
| 166 | MPP6_SYSRST_OUTn, |
| 167 | MPP7_GPO, /* Request power-off */ |
| 168 | MPP8_TW0_SDA, |
| 169 | MPP9_TW0_SCK, |
| 170 | MPP10_UART0_TXD, |
| 171 | MPP11_UART0_RXD, |
| 172 | MPP12_GPO, /* Red led */ |
| 173 | MPP13_GPIO, /* Rear power switch (on|auto) */ |
| 174 | MPP14_GPIO, /* USB fuse */ |
| 175 | MPP15_GPIO, /* Rear power switch (auto|off) */ |
| 176 | MPP16_GPIO, /* SATA 0 power */ |
| 177 | MPP21_SATA0_ACTn, |
| 178 | MPP24_GPIO, /* USB mode select */ |
| 179 | MPP26_GPIO, /* USB device vbus */ |
| 180 | MPP28_GPIO, /* USB enable host vbus */ |
| 181 | MPP29_GPIO, /* Blue led (slow register) */ |
| 182 | MPP30_GPIO, /* Blue led (command register) */ |
| 183 | MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */ |
| 184 | MPP35_GPIO, /* Inhibit power-off */ |
| 185 | 0 |
| 186 | }; |
| 187 | |
| 188 | #define D2NET_V2_GPIO_POWER_OFF 7 |
| 189 | |
| 190 | static void d2net_v2_power_off(void) |
| 191 | { |
| 192 | gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1); |
| 193 | } |
| 194 | |
| 195 | static void __init d2net_v2_init(void) |
| 196 | { |
| 197 | /* |
| 198 | * Basic setup. Needs to be called early. |
| 199 | */ |
| 200 | kirkwood_init(); |
| 201 | kirkwood_mpp_conf(d2net_v2_mpp_config); |
| 202 | |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 203 | lacie_v2_hdd_power_init(1); |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 204 | |
| 205 | kirkwood_ehci_init(); |
| 206 | kirkwood_ge00_init(&d2net_v2_ge00_data); |
| 207 | kirkwood_sata_init(&d2net_v2_sata_data); |
| 208 | kirkwood_uart0_init(); |
Simon Guinot | b51d92d | 2010-09-19 15:33:59 +0200 | [diff] [blame] | 209 | lacie_v2_register_flash(); |
| 210 | lacie_v2_register_i2c_devices(); |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 211 | |
| 212 | platform_device_register(&d2net_v2_leds); |
| 213 | platform_device_register(&d2net_v2_gpio_leds); |
| 214 | platform_device_register(&d2net_v2_gpio_buttons); |
| 215 | |
| 216 | if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 && |
| 217 | gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0) |
| 218 | pm_power_off = d2net_v2_power_off; |
| 219 | else |
| 220 | pr_err("d2net_v2: failed to configure power-off GPIO\n"); |
| 221 | } |
| 222 | |
| 223 | MACHINE_START(D2NET_V2, "LaCie d2 Network v2") |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 224 | .atag_offset = 0x100, |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 225 | .init_machine = d2net_v2_init, |
| 226 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 227 | .init_early = kirkwood_init_early, |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 228 | .init_irq = kirkwood_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 229 | .init_time = kirkwood_timer_init, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 230 | .restart = kirkwood_restart, |
Simon Guinot | 84712e9 | 2010-09-19 15:33:58 +0200 | [diff] [blame] | 231 | MACHINE_END |