Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 1 | /* |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 2 | * arch/arm/mach-orion5x/rd88f5182-setup.c |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 3 | * |
| 4 | * Marvell Orion-NAS Reference Design Setup |
| 5 | * |
| 6 | * Maintainer: Ronen Shitrit <rshitrit@marvell.com> |
| 7 | * |
Lennert Buytenhek | 159ffb3 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 8 | * This file is licensed under the terms of the GNU General Public |
| 9 | * License version 2. This program is licensed "as is" without any |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 10 | * warranty of any kind, whether express or implied. |
| 11 | */ |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 12 | #include <linux/gpio.h> |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/pci.h> |
| 17 | #include <linux/irq.h> |
| 18 | #include <linux/mtd/physmap.h> |
| 19 | #include <linux/mv643xx_eth.h> |
Saeed Bishara | f244baa | 2008-01-29 11:33:32 -1100 | [diff] [blame] | 20 | #include <linux/ata_platform.h> |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 21 | #include <linux/i2c.h> |
| 22 | #include <asm/mach-types.h> |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 23 | #include <asm/leds.h> |
| 24 | #include <asm/mach/arch.h> |
| 25 | #include <asm/mach/pci.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/orion5x.h> |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 27 | #include "common.h" |
Lennert Buytenhek | 19cfd5c | 2008-05-10 23:25:46 +0200 | [diff] [blame] | 28 | #include "mpp.h" |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 29 | |
| 30 | /***************************************************************************** |
| 31 | * RD-88F5182 Info |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | /* |
| 35 | * 512K NOR flash Device bus boot chip select |
| 36 | */ |
| 37 | |
| 38 | #define RD88F5182_NOR_BOOT_BASE 0xf4000000 |
| 39 | #define RD88F5182_NOR_BOOT_SIZE SZ_512K |
| 40 | |
| 41 | /* |
| 42 | * 16M NOR flash on Device bus chip select 1 |
| 43 | */ |
| 44 | |
| 45 | #define RD88F5182_NOR_BASE 0xfc000000 |
| 46 | #define RD88F5182_NOR_SIZE SZ_16M |
| 47 | |
| 48 | /* |
| 49 | * PCI |
| 50 | */ |
| 51 | |
| 52 | #define RD88F5182_PCI_SLOT0_OFFS 7 |
| 53 | #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7 |
| 54 | #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6 |
| 55 | |
| 56 | /* |
| 57 | * GPIO Debug LED |
| 58 | */ |
| 59 | |
| 60 | #define RD88F5182_GPIO_DBG_LED 0 |
| 61 | |
| 62 | /***************************************************************************** |
| 63 | * 16M NOR Flash on Device bus CS1 |
| 64 | ****************************************************************************/ |
| 65 | |
| 66 | static struct physmap_flash_data rd88f5182_nor_flash_data = { |
| 67 | .width = 1, |
| 68 | }; |
| 69 | |
| 70 | static struct resource rd88f5182_nor_flash_resource = { |
| 71 | .flags = IORESOURCE_MEM, |
| 72 | .start = RD88F5182_NOR_BASE, |
| 73 | .end = RD88F5182_NOR_BASE + RD88F5182_NOR_SIZE - 1, |
| 74 | }; |
| 75 | |
| 76 | static struct platform_device rd88f5182_nor_flash = { |
| 77 | .name = "physmap-flash", |
| 78 | .id = 0, |
| 79 | .dev = { |
| 80 | .platform_data = &rd88f5182_nor_flash_data, |
| 81 | }, |
| 82 | .num_resources = 1, |
| 83 | .resource = &rd88f5182_nor_flash_resource, |
| 84 | }; |
| 85 | |
| 86 | #ifdef CONFIG_LEDS |
| 87 | |
| 88 | /***************************************************************************** |
| 89 | * Use GPIO debug led as CPU active indication |
| 90 | ****************************************************************************/ |
| 91 | |
| 92 | static void rd88f5182_dbgled_event(led_event_t evt) |
| 93 | { |
| 94 | int val; |
| 95 | |
| 96 | if (evt == led_idle_end) |
| 97 | val = 1; |
| 98 | else if (evt == led_idle_start) |
| 99 | val = 0; |
| 100 | else |
| 101 | return; |
| 102 | |
| 103 | gpio_set_value(RD88F5182_GPIO_DBG_LED, val); |
| 104 | } |
| 105 | |
| 106 | static int __init rd88f5182_dbgled_init(void) |
| 107 | { |
| 108 | int pin; |
| 109 | |
| 110 | if (machine_is_rd88f5182()) { |
| 111 | pin = RD88F5182_GPIO_DBG_LED; |
| 112 | |
| 113 | if (gpio_request(pin, "DBGLED") == 0) { |
| 114 | if (gpio_direction_output(pin, 0) != 0) { |
| 115 | printk(KERN_ERR "rd88f5182_dbgled_init failed " |
| 116 | "to set output pin %d\n", pin); |
| 117 | gpio_free(pin); |
| 118 | return 0; |
| 119 | } |
| 120 | } else { |
| 121 | printk(KERN_ERR "rd88f5182_dbgled_init failed " |
| 122 | "to request gpio %d\n", pin); |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | leds_event = rd88f5182_dbgled_event; |
| 127 | } |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 128 | |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | __initcall(rd88f5182_dbgled_init); |
| 133 | |
| 134 | #endif |
| 135 | |
| 136 | /***************************************************************************** |
| 137 | * PCI |
| 138 | ****************************************************************************/ |
| 139 | |
| 140 | void __init rd88f5182_pci_preinit(void) |
| 141 | { |
| 142 | int pin; |
| 143 | |
| 144 | /* |
| 145 | * Configure PCI GPIO IRQ pins |
| 146 | */ |
| 147 | pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN; |
| 148 | if (gpio_request(pin, "PCI IntA") == 0) { |
| 149 | if (gpio_direction_input(pin) == 0) { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 150 | irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW); |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 151 | } else { |
Masanari Iida | f8fcf53 | 2012-02-13 23:29:56 +0900 | [diff] [blame] | 152 | printk(KERN_ERR "rd88f5182_pci_preinit failed to " |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 153 | "set_irq_type pin %d\n", pin); |
| 154 | gpio_free(pin); |
| 155 | } |
| 156 | } else { |
| 157 | printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin); |
| 158 | } |
| 159 | |
| 160 | pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN; |
| 161 | if (gpio_request(pin, "PCI IntB") == 0) { |
| 162 | if (gpio_direction_input(pin) == 0) { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 163 | irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW); |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 164 | } else { |
Masanari Iida | f8fcf53 | 2012-02-13 23:29:56 +0900 | [diff] [blame] | 165 | printk(KERN_ERR "rd88f5182_pci_preinit failed to " |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 166 | "set_irq_type pin %d\n", pin); |
| 167 | gpio_free(pin); |
| 168 | } |
| 169 | } else { |
| 170 | printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin); |
| 171 | } |
| 172 | } |
| 173 | |
Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 174 | static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot, |
| 175 | u8 pin) |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 176 | { |
Lennert Buytenhek | 92b913b | 2008-04-25 16:28:33 -0400 | [diff] [blame] | 177 | int irq; |
| 178 | |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 179 | /* |
Lennert Buytenhek | 92b913b | 2008-04-25 16:28:33 -0400 | [diff] [blame] | 180 | * Check for devices with hard-wired IRQs. |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 181 | */ |
Lennert Buytenhek | 92b913b | 2008-04-25 16:28:33 -0400 | [diff] [blame] | 182 | irq = orion5x_pci_map_irq(dev, slot, pin); |
| 183 | if (irq != -1) |
| 184 | return irq; |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 185 | |
| 186 | /* |
| 187 | * PCI IRQs are connected via GPIOs |
| 188 | */ |
| 189 | switch (slot - RD88F5182_PCI_SLOT0_OFFS) { |
| 190 | case 0: |
| 191 | if (pin == 1) |
| 192 | return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN); |
| 193 | else |
| 194 | return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN); |
| 195 | default: |
| 196 | return -1; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | static struct hw_pci rd88f5182_pci __initdata = { |
| 201 | .nr_controllers = 2, |
| 202 | .preinit = rd88f5182_pci_preinit, |
| 203 | .swizzle = pci_std_swizzle, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 204 | .setup = orion5x_pci_sys_setup, |
| 205 | .scan = orion5x_pci_sys_scan_bus, |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 206 | .map_irq = rd88f5182_pci_map_irq, |
| 207 | }; |
| 208 | |
| 209 | static int __init rd88f5182_pci_init(void) |
| 210 | { |
| 211 | if (machine_is_rd88f5182()) |
| 212 | pci_common_init(&rd88f5182_pci); |
| 213 | |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | subsys_initcall(rd88f5182_pci_init); |
| 218 | |
| 219 | /***************************************************************************** |
| 220 | * Ethernet |
| 221 | ****************************************************************************/ |
| 222 | |
| 223 | static struct mv643xx_eth_platform_data rd88f5182_eth_data = { |
Lennert Buytenhek | ac840605 | 2008-08-26 14:06:47 +0200 | [diff] [blame] | 224 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | /***************************************************************************** |
| 228 | * RTC DS1338 on I2C bus |
| 229 | ****************************************************************************/ |
| 230 | static struct i2c_board_info __initdata rd88f5182_i2c_rtc = { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 231 | I2C_BOARD_INFO("ds1338", 0x68), |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | /***************************************************************************** |
Saeed Bishara | f244baa | 2008-01-29 11:33:32 -1100 | [diff] [blame] | 235 | * Sata |
| 236 | ****************************************************************************/ |
| 237 | static struct mv_sata_platform_data rd88f5182_sata_data = { |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 238 | .n_ports = 2, |
Saeed Bishara | f244baa | 2008-01-29 11:33:32 -1100 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | /***************************************************************************** |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 242 | * General Setup |
| 243 | ****************************************************************************/ |
Andrew Lunn | 554cdae | 2011-05-15 13:32:53 +0200 | [diff] [blame] | 244 | static unsigned int rd88f5182_mpp_modes[] __initdata = { |
| 245 | MPP0_GPIO, /* Debug Led */ |
| 246 | MPP1_GPIO, /* Reset Switch */ |
| 247 | MPP2_UNUSED, |
| 248 | MPP3_GPIO, /* RTC Int */ |
| 249 | MPP4_GPIO, |
| 250 | MPP5_GPIO, |
| 251 | MPP6_GPIO, /* PCI_intA */ |
| 252 | MPP7_GPIO, /* PCI_intB */ |
| 253 | MPP8_UNUSED, |
| 254 | MPP9_UNUSED, |
| 255 | MPP10_UNUSED, |
| 256 | MPP11_UNUSED, |
| 257 | MPP12_SATA_LED, /* SATA 0 presence */ |
| 258 | MPP13_SATA_LED, /* SATA 1 presence */ |
| 259 | MPP14_SATA_LED, /* SATA 0 active */ |
| 260 | MPP15_SATA_LED, /* SATA 1 active */ |
| 261 | MPP16_UNUSED, |
| 262 | MPP17_UNUSED, |
| 263 | MPP18_UNUSED, |
| 264 | MPP19_UNUSED, |
| 265 | 0, |
Lennert Buytenhek | 19cfd5c | 2008-05-10 23:25:46 +0200 | [diff] [blame] | 266 | }; |
| 267 | |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 268 | static void __init rd88f5182_init(void) |
| 269 | { |
| 270 | /* |
| 271 | * Setup basic Orion functions. Need to be called early. |
| 272 | */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 273 | orion5x_init(); |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 274 | |
Lennert Buytenhek | 19cfd5c | 2008-05-10 23:25:46 +0200 | [diff] [blame] | 275 | orion5x_mpp_conf(rd88f5182_mpp_modes); |
| 276 | |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 277 | /* |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 278 | * MPP[20] PCI Clock to MV88F5182 |
| 279 | * MPP[21] PCI Clock to mini PCI CON11 |
| 280 | * MPP[22] USB 0 over current indication |
| 281 | * MPP[23] USB 1 over current indication |
| 282 | * MPP[24] USB 1 over current enable |
| 283 | * MPP[25] USB 0 over current enable |
| 284 | */ |
| 285 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 286 | /* |
| 287 | * Configure peripherals. |
| 288 | */ |
| 289 | orion5x_ehci0_init(); |
| 290 | orion5x_ehci1_init(); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 291 | orion5x_eth_init(&rd88f5182_eth_data); |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 292 | orion5x_i2c_init(); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 293 | orion5x_sata_init(&rd88f5182_sata_data); |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 294 | orion5x_uart0_init(); |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 295 | orion5x_xor_init(); |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 296 | |
| 297 | orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE, |
| 298 | RD88F5182_NOR_BOOT_SIZE); |
| 299 | |
| 300 | orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE); |
| 301 | platform_device_register(&rd88f5182_nor_flash); |
| 302 | |
| 303 | i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1); |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design") |
| 307 | /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */ |
Nicolas Pitre | 65aa1b1 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 308 | .atag_offset = 0x100, |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 309 | .init_machine = rd88f5182_init, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 310 | .map_io = orion5x_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 311 | .init_early = orion5x_init_early, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 312 | .init_irq = orion5x_init_irq, |
| 313 | .timer = &orion5x_timer, |
Russell King | 764cbcc2 | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 314 | .restart = orion5x_restart, |
Ronen Shitrit | 817eb21 | 2007-10-17 14:51:34 -0400 | [diff] [blame] | 315 | MACHINE_END |