Christopher Moore | 0eb6697 | 2008-07-18 00:25:10 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-orion5x/edmini_v2-setup.c |
| 3 | * |
| 4 | * LaCie Ethernet Disk mini V2 Setup |
| 5 | * |
| 6 | * Copyright (C) 2008 Christopher Moore <moore@free.fr> |
| 7 | * Copyright (C) 2008 Albert Aribaud <albert.aribaud@free.fr> |
| 8 | * |
| 9 | * This file is licensed under the terms of the GNU General Public |
| 10 | * License version 2. This program is licensed "as is" without any |
| 11 | * warranty of any kind, whether express or implied. |
| 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * TODO: add Orion USB device port init when kernel.org support is added. |
| 16 | * TODO: add flash write support: see below. |
| 17 | * TODO: add power-off support. |
| 18 | * TODO: add I2C EEPROM support. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/pci.h> |
| 25 | #include <linux/irq.h> |
| 26 | #include <linux/mtd/physmap.h> |
| 27 | #include <linux/mv643xx_eth.h> |
Albert Aribaud | 3d014b0 | 2008-09-19 21:06:25 +0200 | [diff] [blame] | 28 | #include <linux/leds.h> |
| 29 | #include <linux/gpio_keys.h> |
| 30 | #include <linux/input.h> |
Christopher Moore | 0eb6697 | 2008-07-18 00:25:10 +0200 | [diff] [blame] | 31 | #include <linux/i2c.h> |
| 32 | #include <linux/ata_platform.h> |
| 33 | #include <linux/gpio.h> |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/pci.h> |
| 37 | #include <mach/orion5x.h> |
| 38 | #include "common.h" |
| 39 | #include "mpp.h" |
| 40 | |
| 41 | /***************************************************************************** |
| 42 | * EDMINI_V2 Info |
| 43 | ****************************************************************************/ |
| 44 | |
| 45 | /* |
| 46 | * 512KB NOR flash Device bus boot chip select |
| 47 | */ |
| 48 | |
| 49 | #define EDMINI_V2_NOR_BOOT_BASE 0xfff80000 |
| 50 | #define EDMINI_V2_NOR_BOOT_SIZE SZ_512K |
| 51 | |
| 52 | /***************************************************************************** |
| 53 | * 512KB NOR Flash on BOOT Device |
| 54 | ****************************************************************************/ |
| 55 | |
| 56 | /* |
| 57 | * Currently the MTD code does not recognize the MX29LV400CBCT as a bottom |
| 58 | * -type device. This could cause risks of accidentally erasing critical |
| 59 | * flash sectors. We thus define a single, write-protected partition covering |
| 60 | * the whole flash. |
| 61 | * TODO: once the flash part TOP/BOTTOM detection issue is sorted out in the MTD |
| 62 | * code, break this into at least three partitions: 'u-boot code', 'u-boot |
| 63 | * environment' and 'whatever is left'. |
| 64 | */ |
| 65 | |
| 66 | static struct mtd_partition edmini_v2_partitions[] = { |
| 67 | { |
| 68 | .name = "Full512kb", |
| 69 | .size = 0x00080000, |
| 70 | .offset = 0x00000000, |
| 71 | .mask_flags = MTD_WRITEABLE, |
| 72 | }, |
| 73 | }; |
| 74 | |
| 75 | static struct physmap_flash_data edmini_v2_nor_flash_data = { |
| 76 | .width = 1, |
| 77 | .parts = edmini_v2_partitions, |
| 78 | .nr_parts = ARRAY_SIZE(edmini_v2_partitions), |
| 79 | }; |
| 80 | |
| 81 | static struct resource edmini_v2_nor_flash_resource = { |
| 82 | .flags = IORESOURCE_MEM, |
| 83 | .start = EDMINI_V2_NOR_BOOT_BASE, |
| 84 | .end = EDMINI_V2_NOR_BOOT_BASE |
| 85 | + EDMINI_V2_NOR_BOOT_SIZE - 1, |
| 86 | }; |
| 87 | |
| 88 | static struct platform_device edmini_v2_nor_flash = { |
| 89 | .name = "physmap-flash", |
| 90 | .id = 0, |
| 91 | .dev = { |
| 92 | .platform_data = &edmini_v2_nor_flash_data, |
| 93 | }, |
| 94 | .num_resources = 1, |
| 95 | .resource = &edmini_v2_nor_flash_resource, |
| 96 | }; |
| 97 | |
| 98 | /***************************************************************************** |
| 99 | * Ethernet |
| 100 | ****************************************************************************/ |
| 101 | |
| 102 | static struct mv643xx_eth_platform_data edmini_v2_eth_data = { |
| 103 | .phy_addr = 8, |
| 104 | }; |
| 105 | |
| 106 | /***************************************************************************** |
| 107 | * RTC 5C372a on I2C bus |
| 108 | ****************************************************************************/ |
| 109 | |
| 110 | #define EDMINIV2_RTC_GPIO 3 |
| 111 | |
| 112 | static struct i2c_board_info __initdata edmini_v2_i2c_rtc = { |
| 113 | I2C_BOARD_INFO("rs5c372a", 0x32), |
| 114 | .irq = 0, |
| 115 | }; |
| 116 | |
| 117 | /***************************************************************************** |
| 118 | * Sata |
| 119 | ****************************************************************************/ |
| 120 | |
| 121 | static struct mv_sata_platform_data edmini_v2_sata_data = { |
| 122 | .n_ports = 2, |
| 123 | }; |
| 124 | |
| 125 | /***************************************************************************** |
Albert Aribaud | 3d014b0 | 2008-09-19 21:06:25 +0200 | [diff] [blame] | 126 | * GPIO LED (simple - doesn't use hardware blinking support) |
| 127 | ****************************************************************************/ |
| 128 | |
| 129 | #define EDMINI_V2_GPIO_LED_POWER 16 |
| 130 | |
| 131 | static struct gpio_led edmini_v2_leds[] = { |
| 132 | { |
| 133 | .name = "power:blue", |
| 134 | .gpio = EDMINI_V2_GPIO_LED_POWER, |
| 135 | .active_low = 1, |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | static struct gpio_led_platform_data edmini_v2_led_data = { |
| 140 | .num_leds = ARRAY_SIZE(edmini_v2_leds), |
| 141 | .leds = edmini_v2_leds, |
| 142 | }; |
| 143 | |
| 144 | static struct platform_device edmini_v2_gpio_leds = { |
| 145 | .name = "leds-gpio", |
| 146 | .id = -1, |
| 147 | .dev = { |
| 148 | .platform_data = &edmini_v2_led_data, |
| 149 | }, |
| 150 | }; |
| 151 | |
| 152 | /**************************************************************************** |
| 153 | * GPIO key |
| 154 | ****************************************************************************/ |
| 155 | |
| 156 | #define EDMINI_V2_GPIO_KEY_POWER 18 |
| 157 | |
| 158 | static struct gpio_keys_button edmini_v2_buttons[] = { |
| 159 | { |
| 160 | .code = KEY_POWER, |
| 161 | .gpio = EDMINI_V2_GPIO_KEY_POWER, |
| 162 | .desc = "Power Button", |
| 163 | .active_low = 0, |
| 164 | }, |
| 165 | }; |
| 166 | |
| 167 | static struct gpio_keys_platform_data edmini_v2_button_data = { |
| 168 | .buttons = edmini_v2_buttons, |
| 169 | .nbuttons = ARRAY_SIZE(edmini_v2_buttons), |
| 170 | }; |
| 171 | |
| 172 | static struct platform_device edmini_v2_gpio_buttons = { |
| 173 | .name = "gpio-keys", |
| 174 | .id = -1, |
| 175 | .dev = { |
| 176 | .platform_data = &edmini_v2_button_data, |
| 177 | }, |
| 178 | }; |
| 179 | |
| 180 | /***************************************************************************** |
Christopher Moore | 0eb6697 | 2008-07-18 00:25:10 +0200 | [diff] [blame] | 181 | * General Setup |
| 182 | ****************************************************************************/ |
| 183 | static struct orion5x_mpp_mode edminiv2_mpp_modes[] __initdata = { |
| 184 | { 0, MPP_UNUSED }, |
| 185 | { 1, MPP_UNUSED }, |
| 186 | { 2, MPP_UNUSED }, |
| 187 | { 3, MPP_GPIO }, /* RTC interrupt */ |
| 188 | { 4, MPP_UNUSED }, |
| 189 | { 5, MPP_UNUSED }, |
| 190 | { 6, MPP_UNUSED }, |
| 191 | { 7, MPP_UNUSED }, |
| 192 | { 8, MPP_UNUSED }, |
| 193 | { 9, MPP_UNUSED }, |
| 194 | { 10, MPP_UNUSED }, |
| 195 | { 11, MPP_UNUSED }, |
| 196 | { 12, MPP_SATA_LED }, /* SATA 0 presence */ |
| 197 | { 13, MPP_SATA_LED }, /* SATA 1 presence */ |
| 198 | { 14, MPP_SATA_LED }, /* SATA 0 active */ |
| 199 | { 15, MPP_SATA_LED }, /* SATA 1 active */ |
| 200 | /* 16: Power LED control (0 = On, 1 = Off) */ |
| 201 | { 16, MPP_GPIO }, |
| 202 | /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */ |
| 203 | { 17, MPP_GPIO }, |
| 204 | /* 18: Power button status (0 = Released, 1 = Pressed) */ |
| 205 | { 18, MPP_GPIO }, |
| 206 | { 19, MPP_UNUSED }, |
| 207 | { -1 } |
| 208 | }; |
| 209 | |
| 210 | static void __init edmini_v2_init(void) |
| 211 | { |
| 212 | /* |
| 213 | * Setup basic Orion functions. Need to be called early. |
| 214 | */ |
| 215 | orion5x_init(); |
| 216 | |
| 217 | orion5x_mpp_conf(edminiv2_mpp_modes); |
| 218 | |
| 219 | /* |
| 220 | * Configure peripherals. |
| 221 | */ |
| 222 | orion5x_ehci0_init(); |
| 223 | orion5x_eth_init(&edmini_v2_eth_data); |
| 224 | orion5x_i2c_init(); |
| 225 | orion5x_sata_init(&edmini_v2_sata_data); |
| 226 | orion5x_uart0_init(); |
| 227 | |
| 228 | orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE, |
| 229 | EDMINI_V2_NOR_BOOT_SIZE); |
| 230 | platform_device_register(&edmini_v2_nor_flash); |
Albert Aribaud | 3d014b0 | 2008-09-19 21:06:25 +0200 | [diff] [blame] | 231 | platform_device_register(&edmini_v2_gpio_leds); |
| 232 | platform_device_register(&edmini_v2_gpio_buttons); |
Christopher Moore | 0eb6697 | 2008-07-18 00:25:10 +0200 | [diff] [blame] | 233 | |
| 234 | pr_notice("edmini_v2: USB device port, flash write and power-off " |
| 235 | "are not yet supported.\n"); |
| 236 | |
| 237 | /* Get RTC IRQ and register the chip */ |
| 238 | if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) { |
| 239 | if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0) |
| 240 | edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO); |
| 241 | else |
| 242 | gpio_free(EDMINIV2_RTC_GPIO); |
| 243 | } |
| 244 | |
| 245 | if (edmini_v2_i2c_rtc.irq == 0) |
| 246 | pr_warning("edmini_v2: failed to get RTC IRQ\n"); |
| 247 | |
| 248 | i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1); |
| 249 | } |
| 250 | |
| 251 | /* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */ |
| 252 | MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2") |
| 253 | /* Maintainer: Christopher Moore <moore@free.fr> */ |
Christopher Moore | 0eb6697 | 2008-07-18 00:25:10 +0200 | [diff] [blame] | 254 | .boot_params = 0x00000100, |
| 255 | .init_machine = edmini_v2_init, |
| 256 | .map_io = orion5x_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame^] | 257 | .init_early = orion5x_init_early, |
Christopher Moore | 0eb6697 | 2008-07-18 00:25:10 +0200 | [diff] [blame] | 258 | .init_irq = orion5x_init_irq, |
| 259 | .timer = &orion5x_timer, |
| 260 | .fixup = tag_fixup_mem32, |
| 261 | MACHINE_END |