Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-kirkwood/common.c |
| 3 | * |
| 4 | * Core functions for Marvell Kirkwood SoCs |
| 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/serial_8250.h> |
| 15 | #include <linux/mbus.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 16 | #include <linux/ata_platform.h> |
Nicolas Pitre | fb7b2d3 | 2009-06-01 15:36:36 -0400 | [diff] [blame] | 17 | #include <linux/mtd/nand.h> |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame^] | 18 | #include <linux/dma-mapping.h> |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 19 | #include <net/dsa.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 20 | #include <asm/page.h> |
| 21 | #include <asm/timex.h> |
Eric Cooper | 9c15364 | 2011-02-02 17:16:11 -0500 | [diff] [blame] | 22 | #include <asm/kexec.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 23 | #include <asm/mach/map.h> |
| 24 | #include <asm/mach/time.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 25 | #include <mach/kirkwood.h> |
Nicolas Pitre | fdd8b07 | 2009-04-22 20:08:17 +0100 | [diff] [blame] | 26 | #include <mach/bridge-regs.h> |
apatard@mandriva.com | 49106c7 | 2010-05-31 13:49:12 +0200 | [diff] [blame] | 27 | #include <plat/audio.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 28 | #include <plat/cache-feroceon-l2.h> |
| 29 | #include <plat/ehci-orion.h> |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 30 | #include <plat/mvsdio.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 31 | #include <plat/orion_nand.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 32 | #include <plat/common.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 33 | #include <plat/time.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 34 | #include "common.h" |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * I/O Address Mapping |
| 38 | ****************************************************************************/ |
| 39 | static struct map_desc kirkwood_io_desc[] __initdata = { |
| 40 | { |
| 41 | .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE, |
| 42 | .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE), |
| 43 | .length = KIRKWOOD_PCIE_IO_SIZE, |
| 44 | .type = MT_DEVICE, |
| 45 | }, { |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 46 | .virtual = KIRKWOOD_PCIE1_IO_VIRT_BASE, |
| 47 | .pfn = __phys_to_pfn(KIRKWOOD_PCIE1_IO_PHYS_BASE), |
| 48 | .length = KIRKWOOD_PCIE1_IO_SIZE, |
| 49 | .type = MT_DEVICE, |
| 50 | }, { |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 51 | .virtual = KIRKWOOD_REGS_VIRT_BASE, |
| 52 | .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE), |
| 53 | .length = KIRKWOOD_REGS_SIZE, |
| 54 | .type = MT_DEVICE, |
| 55 | }, |
| 56 | }; |
| 57 | |
| 58 | void __init kirkwood_map_io(void) |
| 59 | { |
| 60 | iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc)); |
| 61 | } |
| 62 | |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 63 | /* |
| 64 | * Default clock control bits. Any bit _not_ set in this variable |
| 65 | * will be cleared from the hardware after platform devices have been |
| 66 | * registered. Some reserved bits must be set to 1. |
| 67 | */ |
| 68 | unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED; |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 69 | |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 70 | |
| 71 | /***************************************************************************** |
| 72 | * EHCI |
| 73 | ****************************************************************************/ |
| 74 | static struct orion_ehci_data kirkwood_ehci_data = { |
| 75 | .dram = &kirkwood_mbus_dram_info, |
Ronen Shitrit | fb6f552 | 2008-09-17 10:08:05 +0300 | [diff] [blame] | 76 | .phy_version = EHCI_PHY_NA, |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 79 | static u64 ehci_dmamask = DMA_BIT_MASK(32); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 80 | |
| 81 | |
| 82 | /***************************************************************************** |
| 83 | * EHCI0 |
| 84 | ****************************************************************************/ |
| 85 | static struct resource kirkwood_ehci_resources[] = { |
| 86 | { |
| 87 | .start = USB_PHYS_BASE, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 88 | .end = USB_PHYS_BASE + SZ_4K - 1, |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 89 | .flags = IORESOURCE_MEM, |
| 90 | }, { |
| 91 | .start = IRQ_KIRKWOOD_USB, |
| 92 | .end = IRQ_KIRKWOOD_USB, |
| 93 | .flags = IORESOURCE_IRQ, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct platform_device kirkwood_ehci = { |
| 98 | .name = "orion-ehci", |
| 99 | .id = 0, |
| 100 | .dev = { |
| 101 | .dma_mask = &ehci_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 102 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 103 | .platform_data = &kirkwood_ehci_data, |
| 104 | }, |
| 105 | .resource = kirkwood_ehci_resources, |
| 106 | .num_resources = ARRAY_SIZE(kirkwood_ehci_resources), |
| 107 | }; |
| 108 | |
| 109 | void __init kirkwood_ehci_init(void) |
| 110 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 111 | kirkwood_clk_ctrl |= CGC_USB0; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 112 | platform_device_register(&kirkwood_ehci); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | /***************************************************************************** |
| 117 | * GE00 |
| 118 | ****************************************************************************/ |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 119 | void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data) |
| 120 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 121 | kirkwood_clk_ctrl |= CGC_GE0; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 122 | |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 123 | orion_ge00_init(eth_data, &kirkwood_mbus_dram_info, |
| 124 | GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM, |
| 125 | IRQ_KIRKWOOD_GE00_ERR, kirkwood_tclk); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
| 129 | /***************************************************************************** |
Ronen Shitrit | d15fb9e | 2008-10-19 23:10:14 +0200 | [diff] [blame] | 130 | * GE01 |
| 131 | ****************************************************************************/ |
Ronen Shitrit | d15fb9e | 2008-10-19 23:10:14 +0200 | [diff] [blame] | 132 | void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data) |
| 133 | { |
Ronen Shitrit | d15fb9e | 2008-10-19 23:10:14 +0200 | [diff] [blame] | 134 | |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 135 | kirkwood_clk_ctrl |= CGC_GE1; |
| 136 | |
| 137 | orion_ge01_init(eth_data, &kirkwood_mbus_dram_info, |
| 138 | GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM, |
| 139 | IRQ_KIRKWOOD_GE01_ERR, kirkwood_tclk); |
Ronen Shitrit | d15fb9e | 2008-10-19 23:10:14 +0200 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | |
| 143 | /***************************************************************************** |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 144 | * Ethernet switch |
| 145 | ****************************************************************************/ |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 146 | void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq) |
| 147 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 148 | orion_ge00_switch_init(d, irq); |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | |
| 152 | /***************************************************************************** |
Nicolas Pitre | fb7b2d3 | 2009-06-01 15:36:36 -0400 | [diff] [blame] | 153 | * NAND flash |
| 154 | ****************************************************************************/ |
| 155 | static struct resource kirkwood_nand_resource = { |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | .start = KIRKWOOD_NAND_MEM_PHYS_BASE, |
| 158 | .end = KIRKWOOD_NAND_MEM_PHYS_BASE + |
| 159 | KIRKWOOD_NAND_MEM_SIZE - 1, |
| 160 | }; |
| 161 | |
| 162 | static struct orion_nand_data kirkwood_nand_data = { |
| 163 | .cle = 0, |
| 164 | .ale = 1, |
| 165 | .width = 8, |
| 166 | }; |
| 167 | |
| 168 | static struct platform_device kirkwood_nand_flash = { |
| 169 | .name = "orion_nand", |
| 170 | .id = -1, |
| 171 | .dev = { |
| 172 | .platform_data = &kirkwood_nand_data, |
| 173 | }, |
| 174 | .resource = &kirkwood_nand_resource, |
| 175 | .num_resources = 1, |
| 176 | }; |
| 177 | |
| 178 | void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts, |
| 179 | int chip_delay) |
| 180 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 181 | kirkwood_clk_ctrl |= CGC_RUNIT; |
Nicolas Pitre | fb7b2d3 | 2009-06-01 15:36:36 -0400 | [diff] [blame] | 182 | kirkwood_nand_data.parts = parts; |
| 183 | kirkwood_nand_data.nr_parts = nr_parts; |
| 184 | kirkwood_nand_data.chip_delay = chip_delay; |
| 185 | platform_device_register(&kirkwood_nand_flash); |
| 186 | } |
| 187 | |
Ben Dooks | 010937e | 2010-04-20 10:26:19 +0100 | [diff] [blame] | 188 | void __init kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts, |
| 189 | int (*dev_ready)(struct mtd_info *)) |
| 190 | { |
| 191 | kirkwood_clk_ctrl |= CGC_RUNIT; |
| 192 | kirkwood_nand_data.parts = parts; |
| 193 | kirkwood_nand_data.nr_parts = nr_parts; |
| 194 | kirkwood_nand_data.dev_ready = dev_ready; |
| 195 | platform_device_register(&kirkwood_nand_flash); |
| 196 | } |
Nicolas Pitre | fb7b2d3 | 2009-06-01 15:36:36 -0400 | [diff] [blame] | 197 | |
| 198 | /***************************************************************************** |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 199 | * SoC RTC |
| 200 | ****************************************************************************/ |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 201 | static void __init kirkwood_rtc_init(void) |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 202 | { |
Andrew Lunn | 4748058 | 2011-05-15 13:32:43 +0200 | [diff] [blame] | 203 | orion_rtc_init(RTC_PHYS_BASE, IRQ_KIRKWOOD_RTC); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | |
| 207 | /***************************************************************************** |
| 208 | * SATA |
| 209 | ****************************************************************************/ |
| 210 | static struct resource kirkwood_sata_resources[] = { |
| 211 | { |
| 212 | .name = "sata base", |
| 213 | .start = SATA_PHYS_BASE, |
| 214 | .end = SATA_PHYS_BASE + 0x5000 - 1, |
| 215 | .flags = IORESOURCE_MEM, |
| 216 | }, { |
| 217 | .name = "sata irq", |
| 218 | .start = IRQ_KIRKWOOD_SATA, |
| 219 | .end = IRQ_KIRKWOOD_SATA, |
| 220 | .flags = IORESOURCE_IRQ, |
| 221 | }, |
| 222 | }; |
| 223 | |
| 224 | static struct platform_device kirkwood_sata = { |
| 225 | .name = "sata_mv", |
| 226 | .id = 0, |
| 227 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 228 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 229 | }, |
| 230 | .num_resources = ARRAY_SIZE(kirkwood_sata_resources), |
| 231 | .resource = kirkwood_sata_resources, |
| 232 | }; |
| 233 | |
| 234 | void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data) |
| 235 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 236 | kirkwood_clk_ctrl |= CGC_SATA0; |
| 237 | if (sata_data->n_ports > 1) |
| 238 | kirkwood_clk_ctrl |= CGC_SATA1; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 239 | sata_data->dram = &kirkwood_mbus_dram_info; |
| 240 | kirkwood_sata.dev.platform_data = sata_data; |
| 241 | platform_device_register(&kirkwood_sata); |
| 242 | } |
| 243 | |
| 244 | |
| 245 | /***************************************************************************** |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 246 | * SD/SDIO/MMC |
| 247 | ****************************************************************************/ |
| 248 | static struct resource mvsdio_resources[] = { |
| 249 | [0] = { |
| 250 | .start = SDIO_PHYS_BASE, |
| 251 | .end = SDIO_PHYS_BASE + SZ_1K - 1, |
| 252 | .flags = IORESOURCE_MEM, |
| 253 | }, |
| 254 | [1] = { |
| 255 | .start = IRQ_KIRKWOOD_SDIO, |
| 256 | .end = IRQ_KIRKWOOD_SDIO, |
| 257 | .flags = IORESOURCE_IRQ, |
| 258 | }, |
| 259 | }; |
| 260 | |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 261 | static u64 mvsdio_dmamask = DMA_BIT_MASK(32); |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 262 | |
| 263 | static struct platform_device kirkwood_sdio = { |
| 264 | .name = "mvsdio", |
| 265 | .id = -1, |
| 266 | .dev = { |
| 267 | .dma_mask = &mvsdio_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 268 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 269 | }, |
| 270 | .num_resources = ARRAY_SIZE(mvsdio_resources), |
| 271 | .resource = mvsdio_resources, |
| 272 | }; |
| 273 | |
| 274 | void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data) |
| 275 | { |
| 276 | u32 dev, rev; |
| 277 | |
| 278 | kirkwood_pcie_id(&dev, &rev); |
Saeed Bishara | 1e4d2d3 | 2010-06-01 18:09:27 +0300 | [diff] [blame] | 279 | if (rev == 0 && dev != MV88F6282_DEV_ID) /* catch all Kirkwood Z0's */ |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 280 | mvsdio_data->clock = 100000000; |
| 281 | else |
| 282 | mvsdio_data->clock = 200000000; |
| 283 | mvsdio_data->dram = &kirkwood_mbus_dram_info; |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 284 | kirkwood_clk_ctrl |= CGC_SDIO; |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 285 | kirkwood_sdio.dev.platform_data = mvsdio_data; |
| 286 | platform_device_register(&kirkwood_sdio); |
| 287 | } |
| 288 | |
| 289 | |
| 290 | /***************************************************************************** |
Lennert Buytenhek | 18365d1 | 2008-08-09 15:38:18 +0200 | [diff] [blame] | 291 | * SPI |
| 292 | ****************************************************************************/ |
Lennert Buytenhek | 18365d1 | 2008-08-09 15:38:18 +0200 | [diff] [blame] | 293 | void __init kirkwood_spi_init() |
| 294 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 295 | kirkwood_clk_ctrl |= CGC_RUNIT; |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 296 | orion_spi_init(SPI_PHYS_BASE, kirkwood_tclk); |
Lennert Buytenhek | 18365d1 | 2008-08-09 15:38:18 +0200 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | |
| 300 | /***************************************************************************** |
Martin Michlmayr | 6574e00 | 2009-03-23 19:13:21 +0100 | [diff] [blame] | 301 | * I2C |
| 302 | ****************************************************************************/ |
Martin Michlmayr | 6574e00 | 2009-03-23 19:13:21 +0100 | [diff] [blame] | 303 | void __init kirkwood_i2c_init(void) |
| 304 | { |
Andrew Lunn | aac7ffa | 2011-05-15 13:32:45 +0200 | [diff] [blame] | 305 | orion_i2c_init(I2C_PHYS_BASE, IRQ_KIRKWOOD_TWSI, 8); |
Martin Michlmayr | 6574e00 | 2009-03-23 19:13:21 +0100 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | |
| 309 | /***************************************************************************** |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 310 | * UART0 |
| 311 | ****************************************************************************/ |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 312 | |
| 313 | void __init kirkwood_uart0_init(void) |
| 314 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 315 | orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, |
| 316 | IRQ_KIRKWOOD_UART_0, kirkwood_tclk); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | |
| 320 | /***************************************************************************** |
| 321 | * UART1 |
| 322 | ****************************************************************************/ |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 323 | void __init kirkwood_uart1_init(void) |
| 324 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 325 | orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, |
| 326 | IRQ_KIRKWOOD_UART_1, kirkwood_tclk); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 327 | } |
| 328 | |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 329 | /***************************************************************************** |
Nicolas Pitre | ae5c8c8 | 2009-06-03 15:24:36 -0400 | [diff] [blame] | 330 | * Cryptographic Engines and Security Accelerator (CESA) |
| 331 | ****************************************************************************/ |
| 332 | |
| 333 | static struct resource kirkwood_crypto_res[] = { |
| 334 | { |
| 335 | .name = "regs", |
| 336 | .start = CRYPTO_PHYS_BASE, |
| 337 | .end = CRYPTO_PHYS_BASE + 0xffff, |
| 338 | .flags = IORESOURCE_MEM, |
| 339 | }, { |
| 340 | .name = "sram", |
| 341 | .start = KIRKWOOD_SRAM_PHYS_BASE, |
| 342 | .end = KIRKWOOD_SRAM_PHYS_BASE + KIRKWOOD_SRAM_SIZE - 1, |
| 343 | .flags = IORESOURCE_MEM, |
| 344 | }, { |
| 345 | .name = "crypto interrupt", |
| 346 | .start = IRQ_KIRKWOOD_CRYPTO, |
| 347 | .end = IRQ_KIRKWOOD_CRYPTO, |
| 348 | .flags = IORESOURCE_IRQ, |
| 349 | }, |
| 350 | }; |
| 351 | |
| 352 | static struct platform_device kirkwood_crypto_device = { |
| 353 | .name = "mv_crypto", |
| 354 | .id = -1, |
| 355 | .num_resources = ARRAY_SIZE(kirkwood_crypto_res), |
| 356 | .resource = kirkwood_crypto_res, |
| 357 | }; |
| 358 | |
| 359 | void __init kirkwood_crypto_init(void) |
| 360 | { |
| 361 | kirkwood_clk_ctrl |= CGC_CRYPTO; |
| 362 | platform_device_register(&kirkwood_crypto_device); |
| 363 | } |
| 364 | |
| 365 | |
| 366 | /***************************************************************************** |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 367 | * XOR0 |
| 368 | ****************************************************************************/ |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 369 | static void __init kirkwood_xor0_init(void) |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 370 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 371 | kirkwood_clk_ctrl |= CGC_XOR0; |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 372 | |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame^] | 373 | orion_xor0_init(&kirkwood_mbus_dram_info, |
| 374 | XOR0_PHYS_BASE, XOR0_HIGH_PHYS_BASE, |
| 375 | IRQ_KIRKWOOD_XOR_00, IRQ_KIRKWOOD_XOR_01); |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | |
| 379 | /***************************************************************************** |
| 380 | * XOR1 |
| 381 | ****************************************************************************/ |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 382 | static void __init kirkwood_xor1_init(void) |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 383 | { |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 384 | kirkwood_clk_ctrl |= CGC_XOR1; |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 385 | |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame^] | 386 | orion_xor1_init(XOR1_PHYS_BASE, XOR1_HIGH_PHYS_BASE, |
| 387 | IRQ_KIRKWOOD_XOR_10, IRQ_KIRKWOOD_XOR_11); |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | |
| 391 | /***************************************************************************** |
Thomas Reitmayr | 054bd3f0 | 2009-06-01 13:38:34 +0200 | [diff] [blame] | 392 | * Watchdog |
| 393 | ****************************************************************************/ |
Thomas Reitmayr | 054bd3f0 | 2009-06-01 13:38:34 +0200 | [diff] [blame] | 394 | static void __init kirkwood_wdt_init(void) |
| 395 | { |
Andrew Lunn | 5e00d37 | 2011-05-15 13:32:47 +0200 | [diff] [blame] | 396 | orion_wdt_init(kirkwood_tclk); |
Thomas Reitmayr | 054bd3f0 | 2009-06-01 13:38:34 +0200 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | |
| 400 | /***************************************************************************** |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 401 | * Time handling |
| 402 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 403 | void __init kirkwood_init_early(void) |
| 404 | { |
| 405 | orion_time_set_base(TIMER_VIRT_BASE); |
| 406 | } |
| 407 | |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 408 | int kirkwood_tclk; |
| 409 | |
Nicolas Pitre | 9b8ebfe | 2011-03-03 15:08:53 -0500 | [diff] [blame] | 410 | static int __init kirkwood_find_tclk(void) |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 411 | { |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 412 | u32 dev, rev; |
| 413 | |
| 414 | kirkwood_pcie_id(&dev, &rev); |
Saeed Bishara | 1e4d2d3 | 2010-06-01 18:09:27 +0300 | [diff] [blame] | 415 | |
Simon Guinot | 2fa0f93 | 2010-10-21 11:42:28 +0200 | [diff] [blame] | 416 | if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID) |
| 417 | if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0) |
| 418 | return 200000000; |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 419 | |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 420 | return 166666667; |
| 421 | } |
| 422 | |
Li Jie | 6de95c1 | 2009-11-05 07:29:54 -0800 | [diff] [blame] | 423 | static void __init kirkwood_timer_init(void) |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 424 | { |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 425 | kirkwood_tclk = kirkwood_find_tclk(); |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 426 | |
| 427 | orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 428 | IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | struct sys_timer kirkwood_timer = { |
| 432 | .init = kirkwood_timer_init, |
| 433 | }; |
| 434 | |
apatard@mandriva.com | 49106c7 | 2010-05-31 13:49:12 +0200 | [diff] [blame] | 435 | /***************************************************************************** |
| 436 | * Audio |
| 437 | ****************************************************************************/ |
| 438 | static struct resource kirkwood_i2s_resources[] = { |
| 439 | [0] = { |
| 440 | .start = AUDIO_PHYS_BASE, |
| 441 | .end = AUDIO_PHYS_BASE + SZ_16K - 1, |
| 442 | .flags = IORESOURCE_MEM, |
| 443 | }, |
| 444 | [1] = { |
| 445 | .start = IRQ_KIRKWOOD_I2S, |
| 446 | .end = IRQ_KIRKWOOD_I2S, |
| 447 | .flags = IORESOURCE_IRQ, |
| 448 | }, |
| 449 | }; |
| 450 | |
| 451 | static struct kirkwood_asoc_platform_data kirkwood_i2s_data = { |
| 452 | .dram = &kirkwood_mbus_dram_info, |
| 453 | .burst = 128, |
| 454 | }; |
| 455 | |
| 456 | static struct platform_device kirkwood_i2s_device = { |
| 457 | .name = "kirkwood-i2s", |
| 458 | .id = -1, |
| 459 | .num_resources = ARRAY_SIZE(kirkwood_i2s_resources), |
| 460 | .resource = kirkwood_i2s_resources, |
| 461 | .dev = { |
| 462 | .platform_data = &kirkwood_i2s_data, |
| 463 | }, |
| 464 | }; |
| 465 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 466 | static struct platform_device kirkwood_pcm_device = { |
Arnaud Patard (Rtp) | c88e7b9 | 2010-08-30 16:00:05 +0200 | [diff] [blame] | 467 | .name = "kirkwood-pcm-audio", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 468 | .id = -1, |
| 469 | }; |
| 470 | |
apatard@mandriva.com | 49106c7 | 2010-05-31 13:49:12 +0200 | [diff] [blame] | 471 | void __init kirkwood_audio_init(void) |
| 472 | { |
| 473 | kirkwood_clk_ctrl |= CGC_AUDIO; |
| 474 | platform_device_register(&kirkwood_i2s_device); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 475 | platform_device_register(&kirkwood_pcm_device); |
apatard@mandriva.com | 49106c7 | 2010-05-31 13:49:12 +0200 | [diff] [blame] | 476 | } |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 477 | |
| 478 | /***************************************************************************** |
| 479 | * General |
| 480 | ****************************************************************************/ |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 481 | /* |
| 482 | * Identify device ID and revision. |
| 483 | */ |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 484 | static char * __init kirkwood_id(void) |
| 485 | { |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 486 | u32 dev, rev; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 487 | |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 488 | kirkwood_pcie_id(&dev, &rev); |
| 489 | |
| 490 | if (dev == MV88F6281_DEV_ID) { |
| 491 | if (rev == MV88F6281_REV_Z0) |
| 492 | return "MV88F6281-Z0"; |
| 493 | else if (rev == MV88F6281_REV_A0) |
| 494 | return "MV88F6281-A0"; |
Siddarth Gore | aec1bad | 2009-06-09 14:41:02 +0530 | [diff] [blame] | 495 | else if (rev == MV88F6281_REV_A1) |
| 496 | return "MV88F6281-A1"; |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 497 | else |
| 498 | return "MV88F6281-Rev-Unsupported"; |
| 499 | } else if (dev == MV88F6192_DEV_ID) { |
| 500 | if (rev == MV88F6192_REV_Z0) |
| 501 | return "MV88F6192-Z0"; |
| 502 | else if (rev == MV88F6192_REV_A0) |
| 503 | return "MV88F6192-A0"; |
Saeed Bishara | 1c2003a | 2010-06-01 18:09:26 +0300 | [diff] [blame] | 504 | else if (rev == MV88F6192_REV_A1) |
| 505 | return "MV88F6192-A1"; |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 506 | else |
| 507 | return "MV88F6192-Rev-Unsupported"; |
| 508 | } else if (dev == MV88F6180_DEV_ID) { |
| 509 | if (rev == MV88F6180_REV_A0) |
| 510 | return "MV88F6180-Rev-A0"; |
Saeed Bishara | 1c2003a | 2010-06-01 18:09:26 +0300 | [diff] [blame] | 511 | else if (rev == MV88F6180_REV_A1) |
| 512 | return "MV88F6180-Rev-A1"; |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 513 | else |
| 514 | return "MV88F6180-Rev-Unsupported"; |
Saeed Bishara | 1e4d2d3 | 2010-06-01 18:09:27 +0300 | [diff] [blame] | 515 | } else if (dev == MV88F6282_DEV_ID) { |
| 516 | if (rev == MV88F6282_REV_A0) |
| 517 | return "MV88F6282-Rev-A0"; |
| 518 | else |
| 519 | return "MV88F6282-Rev-Unsupported"; |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 520 | } else { |
| 521 | return "Device-Unknown"; |
| 522 | } |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 523 | } |
| 524 | |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 525 | static void __init kirkwood_l2_init(void) |
Saeed Bishara | 1338760 | 2008-06-23 01:05:08 -1100 | [diff] [blame] | 526 | { |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 527 | #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH |
| 528 | writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG); |
| 529 | feroceon_l2_init(1); |
| 530 | #else |
| 531 | writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG); |
| 532 | feroceon_l2_init(0); |
| 533 | #endif |
Saeed Bishara | 1338760 | 2008-06-23 01:05:08 -1100 | [diff] [blame] | 534 | } |
| 535 | |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 536 | void __init kirkwood_init(void) |
| 537 | { |
| 538 | printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 539 | kirkwood_id(), kirkwood_tclk); |
apatard@mandriva.com | 49106c7 | 2010-05-31 13:49:12 +0200 | [diff] [blame] | 540 | kirkwood_i2s_data.tclk = kirkwood_tclk; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 541 | |
Lennert Buytenhek | 2bf3010 | 2009-11-12 20:31:14 +0100 | [diff] [blame] | 542 | /* |
| 543 | * Disable propagation of mbus errors to the CPU local bus, |
| 544 | * as this causes mbus errors (which can occur for example |
| 545 | * for PCI aborts) to throw CPU aborts, which we're not set |
| 546 | * up to deal with. |
| 547 | */ |
| 548 | writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG); |
| 549 | |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 550 | kirkwood_setup_cpu_mbus(); |
| 551 | |
| 552 | #ifdef CONFIG_CACHE_FEROCEON_L2 |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 553 | kirkwood_l2_init(); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 554 | #endif |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 555 | |
| 556 | /* internal devices that every board has */ |
| 557 | kirkwood_rtc_init(); |
Thomas Reitmayr | 054bd3f0 | 2009-06-01 13:38:34 +0200 | [diff] [blame] | 558 | kirkwood_wdt_init(); |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 559 | kirkwood_xor0_init(); |
| 560 | kirkwood_xor1_init(); |
Nicolas Pitre | ae5c8c8 | 2009-06-03 15:24:36 -0400 | [diff] [blame] | 561 | kirkwood_crypto_init(); |
Eric Cooper | 9c15364 | 2011-02-02 17:16:11 -0500 | [diff] [blame] | 562 | |
| 563 | #ifdef CONFIG_KEXEC |
| 564 | kexec_reinit = kirkwood_enable_pcie; |
| 565 | #endif |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 566 | } |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 567 | |
| 568 | static int __init kirkwood_clock_gate(void) |
| 569 | { |
| 570 | unsigned int curr = readl(CLOCK_GATING_CTRL); |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 571 | u32 dev, rev; |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 572 | |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 573 | kirkwood_pcie_id(&dev, &rev); |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 574 | printk(KERN_DEBUG "Gating clock of unused units\n"); |
| 575 | printk(KERN_DEBUG "before: 0x%08x\n", curr); |
| 576 | |
| 577 | /* Make sure those units are accessible */ |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 578 | writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL); |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 579 | |
| 580 | /* For SATA: first shutdown the phy */ |
| 581 | if (!(kirkwood_clk_ctrl & CGC_SATA0)) { |
| 582 | /* Disable PLL and IVREF */ |
| 583 | writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2); |
| 584 | /* Disable PHY */ |
| 585 | writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL); |
| 586 | } |
| 587 | if (!(kirkwood_clk_ctrl & CGC_SATA1)) { |
| 588 | /* Disable PLL and IVREF */ |
| 589 | writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2); |
| 590 | /* Disable PHY */ |
| 591 | writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL); |
| 592 | } |
| 593 | |
| 594 | /* For PCIe: first shutdown the phy */ |
| 595 | if (!(kirkwood_clk_ctrl & CGC_PEX0)) { |
| 596 | writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL); |
| 597 | while (1) |
| 598 | if (readl(PCIE_STATUS) & 0x1) |
| 599 | break; |
| 600 | writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL); |
| 601 | } |
| 602 | |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 603 | /* For PCIe 1: first shutdown the phy */ |
| 604 | if (dev == MV88F6282_DEV_ID) { |
| 605 | if (!(kirkwood_clk_ctrl & CGC_PEX1)) { |
| 606 | writel(readl(PCIE1_LINK_CTRL) | 0x10, PCIE1_LINK_CTRL); |
| 607 | while (1) |
| 608 | if (readl(PCIE1_STATUS) & 0x1) |
| 609 | break; |
| 610 | writel(readl(PCIE1_LINK_CTRL) & ~0x10, PCIE1_LINK_CTRL); |
| 611 | } |
| 612 | } else /* keep this bit set for devices that don't have PCIe1 */ |
| 613 | kirkwood_clk_ctrl |= CGC_PEX1; |
| 614 | |
Rabeeh Khoury | e8b2b7b | 2009-03-22 17:30:32 +0200 | [diff] [blame] | 615 | /* Now gate clock the required units */ |
| 616 | writel(kirkwood_clk_ctrl, CLOCK_GATING_CTRL); |
| 617 | printk(KERN_DEBUG " after: 0x%08x\n", readl(CLOCK_GATING_CTRL)); |
| 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | late_initcall(kirkwood_clock_gate); |