Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-orion5x/ls-chl-setup.c |
| 3 | * |
| 4 | * Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk> |
| 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public |
| 7 | * License version 2. This program is licensed "as is" without any |
| 8 | * warranty of any kind, whether express or implied. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/mtd/physmap.h> |
| 15 | #include <linux/mv643xx_eth.h> |
| 16 | #include <linux/leds.h> |
| 17 | #include <linux/gpio_keys.h> |
| 18 | #include <linux/gpio-fan.h> |
| 19 | #include <linux/input.h> |
| 20 | #include <linux/i2c.h> |
| 21 | #include <linux/ata_platform.h> |
| 22 | #include <linux/gpio.h> |
| 23 | #include <asm/mach-types.h> |
| 24 | #include <asm/mach/arch.h> |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 25 | #include <mach/orion5x.h> |
| 26 | #include "common.h" |
| 27 | #include "mpp.h" |
| 28 | |
| 29 | /***************************************************************************** |
| 30 | * Linkstation LS-CHL Info |
| 31 | ****************************************************************************/ |
| 32 | |
| 33 | /* |
| 34 | * 256K NOR flash Device bus boot chip select |
| 35 | */ |
| 36 | |
| 37 | #define LSCHL_NOR_BOOT_BASE 0xf4000000 |
| 38 | #define LSCHL_NOR_BOOT_SIZE SZ_256K |
| 39 | |
| 40 | /***************************************************************************** |
| 41 | * 256KB NOR Flash on BOOT Device |
| 42 | ****************************************************************************/ |
| 43 | |
| 44 | static struct physmap_flash_data lschl_nor_flash_data = { |
| 45 | .width = 1, |
| 46 | }; |
| 47 | |
| 48 | static struct resource lschl_nor_flash_resource = { |
| 49 | .flags = IORESOURCE_MEM, |
| 50 | .start = LSCHL_NOR_BOOT_BASE, |
| 51 | .end = LSCHL_NOR_BOOT_BASE + LSCHL_NOR_BOOT_SIZE - 1, |
| 52 | }; |
| 53 | |
| 54 | static struct platform_device lschl_nor_flash = { |
| 55 | .name = "physmap-flash", |
| 56 | .id = 0, |
| 57 | .dev = { |
| 58 | .platform_data = &lschl_nor_flash_data, |
| 59 | }, |
| 60 | .num_resources = 1, |
| 61 | .resource = &lschl_nor_flash_resource, |
| 62 | }; |
| 63 | |
| 64 | /***************************************************************************** |
| 65 | * Ethernet |
| 66 | ****************************************************************************/ |
| 67 | |
| 68 | static struct mv643xx_eth_platform_data lschl_eth_data = { |
| 69 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 70 | }; |
| 71 | |
| 72 | /***************************************************************************** |
| 73 | * RTC 5C372a on I2C bus |
| 74 | ****************************************************************************/ |
| 75 | |
| 76 | static struct i2c_board_info __initdata lschl_i2c_rtc = { |
| 77 | I2C_BOARD_INFO("rs5c372a", 0x32), |
| 78 | }; |
| 79 | |
| 80 | /***************************************************************************** |
| 81 | * LEDs attached to GPIO |
| 82 | ****************************************************************************/ |
| 83 | |
| 84 | #define LSCHL_GPIO_LED_ALARM 2 |
| 85 | #define LSCHL_GPIO_LED_INFO 3 |
| 86 | #define LSCHL_GPIO_LED_FUNC 17 |
| 87 | #define LSCHL_GPIO_LED_PWR 0 |
| 88 | |
| 89 | static struct gpio_led lschl_led_pins[] = { |
| 90 | { |
| 91 | .name = "alarm:red", |
| 92 | .gpio = LSCHL_GPIO_LED_ALARM, |
| 93 | .active_low = 1, |
| 94 | }, { |
| 95 | .name = "info:amber", |
| 96 | .gpio = LSCHL_GPIO_LED_INFO, |
| 97 | .active_low = 1, |
| 98 | }, { |
| 99 | .name = "func:blue:top", |
| 100 | .gpio = LSCHL_GPIO_LED_FUNC, |
| 101 | .active_low = 1, |
| 102 | }, { |
| 103 | .name = "power:blue:bottom", |
| 104 | .gpio = LSCHL_GPIO_LED_PWR, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct gpio_led_platform_data lschl_led_data = { |
| 109 | .leds = lschl_led_pins, |
| 110 | .num_leds = ARRAY_SIZE(lschl_led_pins), |
| 111 | }; |
| 112 | |
| 113 | static struct platform_device lschl_leds = { |
| 114 | .name = "leds-gpio", |
| 115 | .id = -1, |
| 116 | .dev = { |
| 117 | .platform_data = &lschl_led_data, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | /***************************************************************************** |
| 122 | * SATA |
| 123 | ****************************************************************************/ |
| 124 | static struct mv_sata_platform_data lschl_sata_data = { |
| 125 | .n_ports = 2, |
| 126 | }; |
| 127 | |
| 128 | /***************************************************************************** |
| 129 | * LS-CHL specific power off method: reboot |
| 130 | ****************************************************************************/ |
| 131 | /* |
| 132 | * On the LS-CHL, the shutdown process is following: |
| 133 | * - Userland monitors key events until the power switch goes to off position |
| 134 | * - The board reboots |
| 135 | * - U-boot starts and goes into an idle mode waiting for the user |
| 136 | * to move the switch to ON position |
| 137 | * |
| 138 | */ |
| 139 | |
| 140 | static void lschl_power_off(void) |
| 141 | { |
Russell King | 764cbcc2 | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 142 | orion5x_restart('h', NULL); |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /***************************************************************************** |
| 146 | * General Setup |
| 147 | ****************************************************************************/ |
| 148 | #define LSCHL_GPIO_USB_POWER 9 |
| 149 | #define LSCHL_GPIO_AUTO_POWER 17 |
| 150 | #define LSCHL_GPIO_POWER 18 |
| 151 | |
| 152 | /**************************************************************************** |
| 153 | * GPIO Attached Keys |
| 154 | ****************************************************************************/ |
| 155 | #define LSCHL_GPIO_KEY_FUNC 15 |
| 156 | #define LSCHL_GPIO_KEY_POWER 8 |
| 157 | #define LSCHL_GPIO_KEY_AUTOPOWER 10 |
| 158 | #define LSCHL_SW_POWER 0x00 |
| 159 | #define LSCHL_SW_AUTOPOWER 0x01 |
| 160 | #define LSCHL_SW_FUNC 0x02 |
| 161 | |
| 162 | static struct gpio_keys_button lschl_buttons[] = { |
| 163 | { |
| 164 | .type = EV_SW, |
| 165 | .code = LSCHL_SW_POWER, |
| 166 | .gpio = LSCHL_GPIO_KEY_POWER, |
| 167 | .desc = "Power-on Switch", |
| 168 | .active_low = 1, |
| 169 | }, { |
| 170 | .type = EV_SW, |
| 171 | .code = LSCHL_SW_AUTOPOWER, |
| 172 | .gpio = LSCHL_GPIO_KEY_AUTOPOWER, |
| 173 | .desc = "Power-auto Switch", |
| 174 | .active_low = 1, |
| 175 | }, { |
| 176 | .type = EV_SW, |
| 177 | .code = LSCHL_SW_FUNC, |
| 178 | .gpio = LSCHL_GPIO_KEY_FUNC, |
| 179 | .desc = "Function Switch", |
| 180 | .active_low = 1, |
| 181 | }, |
| 182 | }; |
| 183 | |
| 184 | static struct gpio_keys_platform_data lschl_button_data = { |
| 185 | .buttons = lschl_buttons, |
| 186 | .nbuttons = ARRAY_SIZE(lschl_buttons), |
| 187 | }; |
| 188 | |
| 189 | static struct platform_device lschl_button_device = { |
| 190 | .name = "gpio-keys", |
| 191 | .id = -1, |
| 192 | .num_resources = 0, |
| 193 | .dev = { |
| 194 | .platform_data = &lschl_button_data, |
| 195 | }, |
| 196 | }; |
| 197 | |
| 198 | #define LSCHL_GPIO_HDD_POWER 1 |
| 199 | |
| 200 | /**************************************************************************** |
| 201 | * GPIO Fan |
| 202 | ****************************************************************************/ |
| 203 | |
| 204 | #define LSCHL_GPIO_FAN_LOW 16 |
| 205 | #define LSCHL_GPIO_FAN_HIGH 14 |
| 206 | #define LSCHL_GPIO_FAN_LOCK 6 |
| 207 | |
| 208 | static struct gpio_fan_alarm lschl_alarm = { |
| 209 | .gpio = LSCHL_GPIO_FAN_LOCK, |
| 210 | }; |
| 211 | |
| 212 | static struct gpio_fan_speed lschl_speeds[] = { |
| 213 | { |
| 214 | .rpm = 0, |
| 215 | .ctrl_val = 3, |
| 216 | }, { |
| 217 | .rpm = 1500, |
| 218 | .ctrl_val = 2, |
| 219 | }, { |
| 220 | .rpm = 3250, |
| 221 | .ctrl_val = 1, |
| 222 | }, { |
| 223 | .rpm = 5000, |
| 224 | .ctrl_val = 0, |
| 225 | }, |
| 226 | }; |
| 227 | |
| 228 | static int lschl_gpio_list[] = { |
| 229 | LSCHL_GPIO_FAN_HIGH, LSCHL_GPIO_FAN_LOW, |
| 230 | }; |
| 231 | |
| 232 | static struct gpio_fan_platform_data lschl_fan_data = { |
| 233 | .num_ctrl = ARRAY_SIZE(lschl_gpio_list), |
| 234 | .ctrl = lschl_gpio_list, |
| 235 | .alarm = &lschl_alarm, |
| 236 | .num_speed = ARRAY_SIZE(lschl_speeds), |
| 237 | .speed = lschl_speeds, |
| 238 | }; |
| 239 | |
| 240 | static struct platform_device lschl_fan_device = { |
| 241 | .name = "gpio-fan", |
| 242 | .id = -1, |
| 243 | .num_resources = 0, |
| 244 | .dev = { |
| 245 | .platform_data = &lschl_fan_data, |
| 246 | }, |
| 247 | }; |
| 248 | |
| 249 | /**************************************************************************** |
| 250 | * GPIO Data |
| 251 | ****************************************************************************/ |
| 252 | |
Andrew Lunn | 554cdae | 2011-05-15 13:32:53 +0200 | [diff] [blame] | 253 | static unsigned int lschl_mpp_modes[] __initdata = { |
| 254 | MPP0_GPIO, /* LED POWER */ |
| 255 | MPP1_GPIO, /* HDD POWER */ |
| 256 | MPP2_GPIO, /* LED ALARM */ |
| 257 | MPP3_GPIO, /* LED INFO */ |
| 258 | MPP4_UNUSED, |
| 259 | MPP5_UNUSED, |
| 260 | MPP6_GPIO, /* FAN LOCK */ |
| 261 | MPP7_GPIO, /* SW INIT */ |
| 262 | MPP8_GPIO, /* SW POWER */ |
| 263 | MPP9_GPIO, /* USB POWER */ |
| 264 | MPP10_GPIO, /* SW AUTO POWER */ |
| 265 | MPP11_UNUSED, |
| 266 | MPP12_UNUSED, |
| 267 | MPP13_UNUSED, |
| 268 | MPP14_GPIO, /* FAN HIGH */ |
| 269 | MPP15_GPIO, /* SW FUNC */ |
| 270 | MPP16_GPIO, /* FAN LOW */ |
| 271 | MPP17_GPIO, /* LED FUNC */ |
| 272 | MPP18_UNUSED, |
| 273 | MPP19_UNUSED, |
| 274 | 0, |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | static void __init lschl_init(void) |
| 278 | { |
| 279 | /* |
| 280 | * Setup basic Orion functions. Needs to be called early. |
| 281 | */ |
| 282 | orion5x_init(); |
| 283 | |
| 284 | orion5x_mpp_conf(lschl_mpp_modes); |
| 285 | |
| 286 | /* |
| 287 | * Configure peripherals. |
| 288 | */ |
| 289 | orion5x_ehci0_init(); |
| 290 | orion5x_ehci1_init(); |
| 291 | orion5x_eth_init(&lschl_eth_data); |
| 292 | orion5x_i2c_init(); |
| 293 | orion5x_sata_init(&lschl_sata_data); |
| 294 | orion5x_uart0_init(); |
| 295 | orion5x_xor_init(); |
| 296 | |
Thomas Petazzoni | 5d1190e | 2013-03-21 17:59:18 +0100 | [diff] [blame] | 297 | mvebu_mbus_add_window("devbus-boot", LSCHL_NOR_BOOT_BASE, |
| 298 | LSCHL_NOR_BOOT_SIZE); |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 299 | platform_device_register(&lschl_nor_flash); |
| 300 | |
| 301 | platform_device_register(&lschl_leds); |
| 302 | |
| 303 | platform_device_register(&lschl_button_device); |
| 304 | |
| 305 | platform_device_register(&lschl_fan_device); |
| 306 | |
| 307 | i2c_register_board_info(0, &lschl_i2c_rtc, 1); |
| 308 | |
| 309 | /* usb power on */ |
| 310 | gpio_set_value(LSCHL_GPIO_USB_POWER, 1); |
| 311 | |
| 312 | /* register power-off method */ |
| 313 | pm_power_off = lschl_power_off; |
| 314 | |
| 315 | pr_info("%s: finished\n", __func__); |
| 316 | } |
| 317 | |
| 318 | MACHINE_START(LINKSTATION_LSCHL, "Buffalo Linkstation LiveV3 (LS-CHL)") |
| 319 | /* Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk> */ |
Nicolas Pitre | 65aa1b1 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 320 | .atag_offset = 0x100, |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 321 | .init_machine = lschl_init, |
| 322 | .map_io = orion5x_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 323 | .init_early = orion5x_init_early, |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 324 | .init_irq = orion5x_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 325 | .init_time = orion5x_timer_init, |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 326 | .fixup = tag_fixup_mem32, |
Russell King | 764cbcc2 | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 327 | .restart = orion5x_restart, |
Ash Hughes | 4bba1c3 | 2010-11-30 21:53:09 +0000 | [diff] [blame] | 328 | MACHINE_END |