Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-orion5x/lsmini-setup.c |
| 3 | * |
| 4 | * Maintainer: Alexey Kopytko <alexey@kopytko.ru> |
| 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> |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 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/input.h> |
| 19 | #include <linux/i2c.h> |
| 20 | #include <linux/ata_platform.h> |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 21 | #include <linux/gpio.h> |
Nicolas Pitre | 1961528 | 2010-02-05 00:20:24 -0500 | [diff] [blame] | 22 | #include <asm/mach-types.h> |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 23 | #include <asm/mach/arch.h> |
Nicolas Pitre | 1961528 | 2010-02-05 00:20:24 -0500 | [diff] [blame] | 24 | #include <asm/system.h> |
| 25 | #include <mach/orion5x.h> |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 26 | #include "common.h" |
| 27 | #include "mpp.h" |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 28 | |
| 29 | /***************************************************************************** |
| 30 | * Linkstation Mini Info |
| 31 | ****************************************************************************/ |
| 32 | |
| 33 | /* |
| 34 | * 256K NOR flash Device bus boot chip select |
| 35 | */ |
| 36 | |
| 37 | #define LSMINI_NOR_BOOT_BASE 0xf4000000 |
| 38 | #define LSMINI_NOR_BOOT_SIZE SZ_256K |
| 39 | |
| 40 | /***************************************************************************** |
| 41 | * 256KB NOR Flash on BOOT Device |
| 42 | ****************************************************************************/ |
| 43 | |
| 44 | static struct physmap_flash_data lsmini_nor_flash_data = { |
| 45 | .width = 1, |
| 46 | }; |
| 47 | |
| 48 | static struct resource lsmini_nor_flash_resource = { |
| 49 | .flags = IORESOURCE_MEM, |
| 50 | .start = LSMINI_NOR_BOOT_BASE, |
| 51 | .end = LSMINI_NOR_BOOT_BASE + LSMINI_NOR_BOOT_SIZE - 1, |
| 52 | }; |
| 53 | |
| 54 | static struct platform_device lsmini_nor_flash = { |
| 55 | .name = "physmap-flash", |
| 56 | .id = 0, |
| 57 | .dev = { |
| 58 | .platform_data = &lsmini_nor_flash_data, |
| 59 | }, |
| 60 | .num_resources = 1, |
| 61 | .resource = &lsmini_nor_flash_resource, |
| 62 | }; |
| 63 | |
| 64 | /***************************************************************************** |
| 65 | * Ethernet |
| 66 | ****************************************************************************/ |
| 67 | |
| 68 | static struct mv643xx_eth_platform_data lsmini_eth_data = { |
| 69 | .phy_addr = 8, |
| 70 | }; |
| 71 | |
| 72 | /***************************************************************************** |
| 73 | * RTC 5C372a on I2C bus |
| 74 | ****************************************************************************/ |
| 75 | |
| 76 | static struct i2c_board_info __initdata lsmini_i2c_rtc = { |
| 77 | I2C_BOARD_INFO("rs5c372a", 0x32), |
| 78 | }; |
| 79 | |
| 80 | /***************************************************************************** |
| 81 | * LEDs attached to GPIO |
| 82 | ****************************************************************************/ |
| 83 | |
| 84 | #define LSMINI_GPIO_LED_ALARM 2 |
| 85 | #define LSMINI_GPIO_LED_INFO 3 |
| 86 | #define LSMINI_GPIO_LED_FUNC 9 |
| 87 | #define LSMINI_GPIO_LED_PWR 14 |
| 88 | |
| 89 | static struct gpio_led lsmini_led_pins[] = { |
| 90 | { |
| 91 | .name = "alarm:red", |
| 92 | .gpio = LSMINI_GPIO_LED_ALARM, |
| 93 | .active_low = 1, |
| 94 | }, { |
| 95 | .name = "info:amber", |
| 96 | .gpio = LSMINI_GPIO_LED_INFO, |
| 97 | .active_low = 1, |
| 98 | }, { |
| 99 | .name = "func:blue:top", |
| 100 | .gpio = LSMINI_GPIO_LED_FUNC, |
| 101 | .active_low = 1, |
| 102 | }, { |
| 103 | .name = "power:blue:bottom", |
| 104 | .gpio = LSMINI_GPIO_LED_PWR, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct gpio_led_platform_data lsmini_led_data = { |
| 109 | .leds = lsmini_led_pins, |
| 110 | .num_leds = ARRAY_SIZE(lsmini_led_pins), |
| 111 | }; |
| 112 | |
| 113 | static struct platform_device lsmini_leds = { |
| 114 | .name = "leds-gpio", |
| 115 | .id = -1, |
| 116 | .dev = { |
| 117 | .platform_data = &lsmini_led_data, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | /**************************************************************************** |
| 122 | * GPIO Attached Keys |
| 123 | ****************************************************************************/ |
| 124 | |
| 125 | #define LSMINI_GPIO_KEY_FUNC 15 |
| 126 | #define LSMINI_GPIO_KEY_POWER 18 |
| 127 | #define LSMINI_GPIO_KEY_AUTOPOWER 17 |
| 128 | |
| 129 | #define LSMINI_SW_POWER 0x00 |
| 130 | #define LSMINI_SW_AUTOPOWER 0x01 |
| 131 | |
| 132 | static struct gpio_keys_button lsmini_buttons[] = { |
| 133 | { |
| 134 | .code = KEY_OPTION, |
| 135 | .gpio = LSMINI_GPIO_KEY_FUNC, |
| 136 | .desc = "Function Button", |
| 137 | .active_low = 1, |
| 138 | }, { |
| 139 | .type = EV_SW, |
| 140 | .code = LSMINI_SW_POWER, |
| 141 | .gpio = LSMINI_GPIO_KEY_POWER, |
| 142 | .desc = "Power-on Switch", |
| 143 | .active_low = 1, |
| 144 | }, { |
| 145 | .type = EV_SW, |
| 146 | .code = LSMINI_SW_AUTOPOWER, |
| 147 | .gpio = LSMINI_GPIO_KEY_AUTOPOWER, |
| 148 | .desc = "Power-auto Switch", |
| 149 | .active_low = 1, |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | static struct gpio_keys_platform_data lsmini_button_data = { |
| 154 | .buttons = lsmini_buttons, |
| 155 | .nbuttons = ARRAY_SIZE(lsmini_buttons), |
| 156 | }; |
| 157 | |
| 158 | static struct platform_device lsmini_button_device = { |
| 159 | .name = "gpio-keys", |
| 160 | .id = -1, |
| 161 | .num_resources = 0, |
| 162 | .dev = { |
| 163 | .platform_data = &lsmini_button_data, |
| 164 | }, |
| 165 | }; |
| 166 | |
| 167 | |
| 168 | /***************************************************************************** |
| 169 | * SATA |
| 170 | ****************************************************************************/ |
| 171 | static struct mv_sata_platform_data lsmini_sata_data = { |
| 172 | .n_ports = 2, |
| 173 | }; |
| 174 | |
| 175 | |
| 176 | /***************************************************************************** |
Alexey Kopytko | 92a5de8 | 2008-09-26 11:13:39 +0900 | [diff] [blame] | 177 | * Linkstation Mini specific power off method: reboot |
| 178 | ****************************************************************************/ |
| 179 | /* |
| 180 | * On the Linkstation Mini, the shutdown process is following: |
| 181 | * - Userland monitors key events until the power switch goes to off position |
| 182 | * - The board reboots |
| 183 | * - U-boot starts and goes into an idle mode waiting for the user |
| 184 | * to move the switch to ON position |
| 185 | */ |
| 186 | |
| 187 | static void lsmini_power_off(void) |
| 188 | { |
Russell King | 764cbcc | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 189 | orion5x_restart('h', NULL); |
Alexey Kopytko | 92a5de8 | 2008-09-26 11:13:39 +0900 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | |
| 193 | /***************************************************************************** |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 194 | * General Setup |
| 195 | ****************************************************************************/ |
| 196 | |
| 197 | #define LSMINI_GPIO_USB_POWER 16 |
| 198 | #define LSMINI_GPIO_AUTO_POWER 17 |
| 199 | #define LSMINI_GPIO_POWER 18 |
| 200 | |
| 201 | #define LSMINI_GPIO_HDD_POWER0 1 |
| 202 | #define LSMINI_GPIO_HDD_POWER1 19 |
| 203 | |
Andrew Lunn | 554cdae | 2011-05-15 13:32:53 +0200 | [diff] [blame] | 204 | static unsigned int lsmini_mpp_modes[] __initdata = { |
| 205 | MPP0_UNUSED, /* LED_RESERVE1 (unused) */ |
| 206 | MPP1_GPIO, /* HDD_PWR */ |
| 207 | MPP2_GPIO, /* LED_ALARM */ |
| 208 | MPP3_GPIO, /* LED_INFO */ |
| 209 | MPP4_UNUSED, |
| 210 | MPP5_UNUSED, |
| 211 | MPP6_UNUSED, |
| 212 | MPP7_UNUSED, |
| 213 | MPP8_UNUSED, |
| 214 | MPP9_GPIO, /* LED_FUNC */ |
| 215 | MPP10_UNUSED, |
| 216 | MPP11_UNUSED, /* LED_ETH (dummy) */ |
| 217 | MPP12_UNUSED, |
| 218 | MPP13_UNUSED, |
| 219 | MPP14_GPIO, /* LED_PWR */ |
| 220 | MPP15_GPIO, /* FUNC */ |
| 221 | MPP16_GPIO, /* USB_PWR */ |
| 222 | MPP17_GPIO, /* AUTO_POWER */ |
| 223 | MPP18_GPIO, /* POWER */ |
| 224 | MPP19_GPIO, /* HDD_PWR1 */ |
| 225 | 0, |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 226 | }; |
| 227 | |
| 228 | static void __init lsmini_init(void) |
| 229 | { |
| 230 | /* |
| 231 | * Setup basic Orion functions. Need to be called early. |
| 232 | */ |
| 233 | orion5x_init(); |
| 234 | |
| 235 | orion5x_mpp_conf(lsmini_mpp_modes); |
| 236 | |
| 237 | /* |
| 238 | * Configure peripherals. |
| 239 | */ |
| 240 | orion5x_ehci0_init(); |
| 241 | orion5x_ehci1_init(); |
| 242 | orion5x_eth_init(&lsmini_eth_data); |
| 243 | orion5x_i2c_init(); |
| 244 | orion5x_sata_init(&lsmini_sata_data); |
| 245 | orion5x_uart0_init(); |
| 246 | orion5x_xor_init(); |
| 247 | |
| 248 | orion5x_setup_dev_boot_win(LSMINI_NOR_BOOT_BASE, |
| 249 | LSMINI_NOR_BOOT_SIZE); |
| 250 | platform_device_register(&lsmini_nor_flash); |
| 251 | |
| 252 | platform_device_register(&lsmini_button_device); |
| 253 | |
| 254 | platform_device_register(&lsmini_leds); |
| 255 | |
| 256 | i2c_register_board_info(0, &lsmini_i2c_rtc, 1); |
| 257 | |
| 258 | /* enable USB power */ |
| 259 | gpio_set_value(LSMINI_GPIO_USB_POWER, 1); |
| 260 | |
Alexey Kopytko | 92a5de8 | 2008-09-26 11:13:39 +0900 | [diff] [blame] | 261 | /* register power-off method */ |
| 262 | pm_power_off = lsmini_power_off; |
| 263 | |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 264 | pr_info("%s: finished\n", __func__); |
| 265 | } |
| 266 | |
| 267 | #ifdef CONFIG_MACH_LINKSTATION_MINI |
| 268 | MACHINE_START(LINKSTATION_MINI, "Buffalo Linkstation Mini") |
| 269 | /* Maintainer: Alexey Kopytko <alexey@kopytko.ru> */ |
Nicolas Pitre | 65aa1b1 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 270 | .atag_offset = 0x100, |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 271 | .init_machine = lsmini_init, |
| 272 | .map_io = orion5x_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 273 | .init_early = orion5x_init_early, |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 274 | .init_irq = orion5x_init_irq, |
| 275 | .timer = &orion5x_timer, |
| 276 | .fixup = tag_fixup_mem32, |
Russell King | 764cbcc | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 277 | .restart = orion5x_restart, |
Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 278 | MACHINE_END |
| 279 | #endif |