Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org> |
| 3 | * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Lesser General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of the |
| 8 | * License, or (at your option) any later version. |
| 9 | */ |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 10 | #include <linux/gpio.h> |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/irq.h> |
| 15 | #include <linux/mtd/physmap.h> |
| 16 | #include <linux/mv643xx_eth.h> |
| 17 | #include <linux/leds.h> |
| 18 | #include <linux/gpio_keys.h> |
| 19 | #include <linux/input.h> |
| 20 | #include <linux/i2c.h> |
| 21 | #include <linux/ata_platform.h> |
| 22 | #include <asm/mach-types.h> |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 23 | #include <asm/mach/arch.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/orion5x.h> |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 25 | #include "common.h" |
| 26 | #include "mpp.h" |
| 27 | |
| 28 | #define MV2120_NOR_BOOT_BASE 0xf4000000 |
| 29 | #define MV2120_NOR_BOOT_SIZE SZ_512K |
| 30 | |
| 31 | #define MV2120_GPIO_RTC_IRQ 3 |
| 32 | #define MV2120_GPIO_KEY_RESET 17 |
| 33 | #define MV2120_GPIO_KEY_POWER 18 |
| 34 | #define MV2120_GPIO_POWER_OFF 19 |
| 35 | |
| 36 | |
| 37 | /***************************************************************************** |
| 38 | * Ethernet |
| 39 | ****************************************************************************/ |
| 40 | static struct mv643xx_eth_platform_data mv2120_eth_data = { |
Lennert Buytenhek | ac840605 | 2008-08-26 14:06:47 +0200 | [diff] [blame] | 41 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | static struct mv_sata_platform_data mv2120_sata_data = { |
| 45 | .n_ports = 2, |
| 46 | }; |
| 47 | |
| 48 | static struct mtd_partition mv2120_partitions[] = { |
| 49 | { |
| 50 | .name = "firmware", |
| 51 | .size = 0x00080000, |
| 52 | .offset = 0, |
| 53 | }, |
| 54 | }; |
| 55 | |
| 56 | static struct physmap_flash_data mv2120_nor_flash_data = { |
| 57 | .width = 1, |
| 58 | .parts = mv2120_partitions, |
| 59 | .nr_parts = ARRAY_SIZE(mv2120_partitions) |
| 60 | }; |
| 61 | |
| 62 | static struct resource mv2120_nor_flash_resource = { |
| 63 | .flags = IORESOURCE_MEM, |
| 64 | .start = MV2120_NOR_BOOT_BASE, |
| 65 | .end = MV2120_NOR_BOOT_BASE + MV2120_NOR_BOOT_SIZE - 1, |
| 66 | }; |
| 67 | |
| 68 | static struct platform_device mv2120_nor_flash = { |
| 69 | .name = "physmap-flash", |
| 70 | .id = 0, |
| 71 | .dev = { |
| 72 | .platform_data = &mv2120_nor_flash_data, |
| 73 | }, |
| 74 | .resource = &mv2120_nor_flash_resource, |
| 75 | .num_resources = 1, |
| 76 | }; |
| 77 | |
| 78 | static struct gpio_keys_button mv2120_buttons[] = { |
| 79 | { |
| 80 | .code = KEY_RESTART, |
| 81 | .gpio = MV2120_GPIO_KEY_RESET, |
| 82 | .desc = "reset", |
| 83 | .active_low = 1, |
| 84 | }, { |
| 85 | .code = KEY_POWER, |
| 86 | .gpio = MV2120_GPIO_KEY_POWER, |
| 87 | .desc = "power", |
| 88 | .active_low = 1, |
| 89 | }, |
| 90 | }; |
| 91 | |
| 92 | static struct gpio_keys_platform_data mv2120_button_data = { |
| 93 | .buttons = mv2120_buttons, |
| 94 | .nbuttons = ARRAY_SIZE(mv2120_buttons), |
| 95 | }; |
| 96 | |
| 97 | static struct platform_device mv2120_button_device = { |
| 98 | .name = "gpio-keys", |
| 99 | .id = -1, |
| 100 | .num_resources = 0, |
| 101 | .dev = { |
| 102 | .platform_data = &mv2120_button_data, |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | |
| 107 | /**************************************************************************** |
| 108 | * General Setup |
| 109 | ****************************************************************************/ |
Andrew Lunn | 554cdae | 2011-05-15 13:32:53 +0200 | [diff] [blame] | 110 | static unsigned int mv2120_mpp_modes[] __initdata = { |
| 111 | MPP0_GPIO, /* Sys status LED */ |
| 112 | MPP1_GPIO, /* Sys error LED */ |
| 113 | MPP2_GPIO, /* OverTemp interrupt */ |
| 114 | MPP3_GPIO, /* RTC interrupt */ |
| 115 | MPP4_GPIO, /* V_LED 5V */ |
| 116 | MPP5_GPIO, /* V_LED 3.3V */ |
| 117 | MPP6_UNUSED, |
| 118 | MPP7_UNUSED, |
| 119 | MPP8_GPIO, /* SATA 0 fail LED */ |
| 120 | MPP9_GPIO, /* SATA 1 fail LED */ |
| 121 | MPP10_UNUSED, |
| 122 | MPP11_UNUSED, |
| 123 | MPP12_SATA_LED, /* SATA 0 presence */ |
| 124 | MPP13_SATA_LED, /* SATA 1 presence */ |
| 125 | MPP14_SATA_LED, /* SATA 0 active */ |
| 126 | MPP15_SATA_LED, /* SATA 1 active */ |
| 127 | MPP16_UNUSED, |
| 128 | MPP17_GPIO, /* Reset button */ |
| 129 | MPP18_GPIO, /* Power button */ |
| 130 | MPP19_GPIO, /* Power off */ |
| 131 | 0, |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | static struct i2c_board_info __initdata mv2120_i2c_rtc = { |
Martin Michlmayr | cdd3c5e | 2008-06-28 12:56:49 +0200 | [diff] [blame] | 135 | I2C_BOARD_INFO("pcf8563", 0x51), |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 136 | .irq = 0, |
| 137 | }; |
| 138 | |
Martin Michlmayr | 2e1117d | 2008-07-07 21:23:09 +0300 | [diff] [blame] | 139 | static struct gpio_led mv2120_led_pins[] = { |
| 140 | { |
| 141 | .name = "mv2120:blue:health", |
| 142 | .gpio = 0, |
| 143 | }, |
| 144 | { |
| 145 | .name = "mv2120:red:health", |
| 146 | .gpio = 1, |
| 147 | }, |
| 148 | { |
| 149 | .name = "mv2120:led:bright", |
| 150 | .gpio = 4, |
| 151 | .default_trigger = "default-on", |
| 152 | }, |
| 153 | { |
| 154 | .name = "mv2120:led:dimmed", |
| 155 | .gpio = 5, |
| 156 | }, |
| 157 | { |
| 158 | .name = "mv2120:red:sata0", |
| 159 | .gpio = 8, |
| 160 | .active_low = 1, |
| 161 | }, |
| 162 | { |
| 163 | .name = "mv2120:red:sata1", |
| 164 | .gpio = 9, |
| 165 | .active_low = 1, |
| 166 | }, |
| 167 | |
| 168 | }; |
| 169 | |
| 170 | static struct gpio_led_platform_data mv2120_led_data = { |
| 171 | .leds = mv2120_led_pins, |
| 172 | .num_leds = ARRAY_SIZE(mv2120_led_pins), |
| 173 | }; |
| 174 | |
| 175 | static struct platform_device mv2120_leds = { |
| 176 | .name = "leds-gpio", |
| 177 | .id = -1, |
| 178 | .dev = { |
| 179 | .platform_data = &mv2120_led_data, |
| 180 | } |
| 181 | }; |
| 182 | |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 183 | static void mv2120_power_off(void) |
| 184 | { |
| 185 | pr_info("%s: triggering power-off...\n", __func__); |
| 186 | gpio_set_value(MV2120_GPIO_POWER_OFF, 0); |
| 187 | } |
| 188 | |
| 189 | static void __init mv2120_init(void) |
| 190 | { |
| 191 | /* Setup basic Orion functions. Need to be called early. */ |
| 192 | orion5x_init(); |
| 193 | |
| 194 | orion5x_mpp_conf(mv2120_mpp_modes); |
| 195 | |
| 196 | /* |
| 197 | * Configure peripherals. |
| 198 | */ |
| 199 | orion5x_ehci0_init(); |
| 200 | orion5x_ehci1_init(); |
| 201 | orion5x_eth_init(&mv2120_eth_data); |
| 202 | orion5x_i2c_init(); |
| 203 | orion5x_sata_init(&mv2120_sata_data); |
| 204 | orion5x_uart0_init(); |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 205 | orion5x_xor_init(); |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 206 | |
| 207 | orion5x_setup_dev_boot_win(MV2120_NOR_BOOT_BASE, MV2120_NOR_BOOT_SIZE); |
| 208 | platform_device_register(&mv2120_nor_flash); |
| 209 | |
| 210 | platform_device_register(&mv2120_button_device); |
| 211 | |
| 212 | if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) { |
| 213 | if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0) |
| 214 | mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ); |
| 215 | else |
| 216 | gpio_free(MV2120_GPIO_RTC_IRQ); |
| 217 | } |
| 218 | i2c_register_board_info(0, &mv2120_i2c_rtc, 1); |
Martin Michlmayr | 2e1117d | 2008-07-07 21:23:09 +0300 | [diff] [blame] | 219 | platform_device_register(&mv2120_leds); |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 220 | |
| 221 | /* register mv2120 specific power-off method */ |
| 222 | if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 || |
| 223 | gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0) |
| 224 | pr_err("mv2120: failed to setup power-off GPIO\n"); |
| 225 | pm_power_off = mv2120_power_off; |
| 226 | } |
| 227 | |
| 228 | /* Warning: HP uses a wrong mach-type (=526) in their bootloader */ |
| 229 | MACHINE_START(MV2120, "HP Media Vault mv2120") |
| 230 | /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ |
Nicolas Pitre | 65aa1b1 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 231 | .atag_offset = 0x100, |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 232 | .init_machine = mv2120_init, |
| 233 | .map_io = orion5x_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 234 | .init_early = orion5x_init_early, |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 235 | .init_irq = orion5x_init_irq, |
| 236 | .timer = &orion5x_timer, |
Russell King | 764cbcc2 | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 237 | .fixup = tag_fixup_mem32, |
| 238 | .restart = orion5x_restart, |
Martin Michlmayr | b08d5af | 2008-04-06 14:08:17 +0200 | [diff] [blame] | 239 | MACHINE_END |