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> |
| 16 | #include <linux/mv643xx_eth.h> |
Martin Michlmayr | 6574e00 | 2009-03-23 19:13:21 +0100 | [diff] [blame] | 17 | #include <linux/mv643xx_i2c.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 18 | #include <linux/ata_platform.h> |
Lennert Buytenhek | 18365d1 | 2008-08-09 15:38:18 +0200 | [diff] [blame] | 19 | #include <linux/spi/orion_spi.h> |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 20 | #include <net/dsa.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 21 | #include <asm/page.h> |
| 22 | #include <asm/timex.h> |
| 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> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 26 | #include <plat/cache-feroceon-l2.h> |
| 27 | #include <plat/ehci-orion.h> |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 28 | #include <plat/mvsdio.h> |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 29 | #include <plat/mv_xor.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 30 | #include <plat/orion_nand.h> |
| 31 | #include <plat/time.h> |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 32 | #include "common.h" |
| 33 | |
| 34 | /***************************************************************************** |
| 35 | * I/O Address Mapping |
| 36 | ****************************************************************************/ |
| 37 | static struct map_desc kirkwood_io_desc[] __initdata = { |
| 38 | { |
| 39 | .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE, |
| 40 | .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE), |
| 41 | .length = KIRKWOOD_PCIE_IO_SIZE, |
| 42 | .type = MT_DEVICE, |
| 43 | }, { |
| 44 | .virtual = KIRKWOOD_REGS_VIRT_BASE, |
| 45 | .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE), |
| 46 | .length = KIRKWOOD_REGS_SIZE, |
| 47 | .type = MT_DEVICE, |
| 48 | }, |
| 49 | }; |
| 50 | |
| 51 | void __init kirkwood_map_io(void) |
| 52 | { |
| 53 | iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc)); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /***************************************************************************** |
| 58 | * EHCI |
| 59 | ****************************************************************************/ |
| 60 | static struct orion_ehci_data kirkwood_ehci_data = { |
| 61 | .dram = &kirkwood_mbus_dram_info, |
Ronen Shitrit | fb6f552 | 2008-09-17 10:08:05 +0300 | [diff] [blame] | 62 | .phy_version = EHCI_PHY_NA, |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | static u64 ehci_dmamask = 0xffffffffUL; |
| 66 | |
| 67 | |
| 68 | /***************************************************************************** |
| 69 | * EHCI0 |
| 70 | ****************************************************************************/ |
| 71 | static struct resource kirkwood_ehci_resources[] = { |
| 72 | { |
| 73 | .start = USB_PHYS_BASE, |
| 74 | .end = USB_PHYS_BASE + 0x0fff, |
| 75 | .flags = IORESOURCE_MEM, |
| 76 | }, { |
| 77 | .start = IRQ_KIRKWOOD_USB, |
| 78 | .end = IRQ_KIRKWOOD_USB, |
| 79 | .flags = IORESOURCE_IRQ, |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | static struct platform_device kirkwood_ehci = { |
| 84 | .name = "orion-ehci", |
| 85 | .id = 0, |
| 86 | .dev = { |
| 87 | .dma_mask = &ehci_dmamask, |
| 88 | .coherent_dma_mask = 0xffffffff, |
| 89 | .platform_data = &kirkwood_ehci_data, |
| 90 | }, |
| 91 | .resource = kirkwood_ehci_resources, |
| 92 | .num_resources = ARRAY_SIZE(kirkwood_ehci_resources), |
| 93 | }; |
| 94 | |
| 95 | void __init kirkwood_ehci_init(void) |
| 96 | { |
| 97 | platform_device_register(&kirkwood_ehci); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | /***************************************************************************** |
| 102 | * GE00 |
| 103 | ****************************************************************************/ |
| 104 | struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = { |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 105 | .dram = &kirkwood_mbus_dram_info, |
| 106 | }; |
| 107 | |
| 108 | static struct resource kirkwood_ge00_shared_resources[] = { |
| 109 | { |
| 110 | .name = "ge00 base", |
| 111 | .start = GE00_PHYS_BASE + 0x2000, |
| 112 | .end = GE00_PHYS_BASE + 0x3fff, |
| 113 | .flags = IORESOURCE_MEM, |
Lennert Buytenhek | 144f814 | 2008-08-26 16:04:05 +0200 | [diff] [blame] | 114 | }, { |
| 115 | .name = "ge00 err irq", |
| 116 | .start = IRQ_KIRKWOOD_GE00_ERR, |
| 117 | .end = IRQ_KIRKWOOD_GE00_ERR, |
| 118 | .flags = IORESOURCE_IRQ, |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 119 | }, |
| 120 | }; |
| 121 | |
| 122 | static struct platform_device kirkwood_ge00_shared = { |
| 123 | .name = MV643XX_ETH_SHARED_NAME, |
| 124 | .id = 0, |
| 125 | .dev = { |
| 126 | .platform_data = &kirkwood_ge00_shared_data, |
| 127 | }, |
Lennert Buytenhek | 144f814 | 2008-08-26 16:04:05 +0200 | [diff] [blame] | 128 | .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources), |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 129 | .resource = kirkwood_ge00_shared_resources, |
| 130 | }; |
| 131 | |
| 132 | static struct resource kirkwood_ge00_resources[] = { |
| 133 | { |
| 134 | .name = "ge00 irq", |
| 135 | .start = IRQ_KIRKWOOD_GE00_SUM, |
| 136 | .end = IRQ_KIRKWOOD_GE00_SUM, |
| 137 | .flags = IORESOURCE_IRQ, |
| 138 | }, |
| 139 | }; |
| 140 | |
| 141 | static struct platform_device kirkwood_ge00 = { |
| 142 | .name = MV643XX_ETH_NAME, |
| 143 | .id = 0, |
| 144 | .num_resources = 1, |
| 145 | .resource = kirkwood_ge00_resources, |
| 146 | }; |
| 147 | |
| 148 | void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data) |
| 149 | { |
| 150 | eth_data->shared = &kirkwood_ge00_shared; |
| 151 | kirkwood_ge00.dev.platform_data = eth_data; |
| 152 | |
| 153 | platform_device_register(&kirkwood_ge00_shared); |
| 154 | platform_device_register(&kirkwood_ge00); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | /***************************************************************************** |
Ronen Shitrit | d15fb9e | 2008-10-19 23:10:14 +0200 | [diff] [blame] | 159 | * GE01 |
| 160 | ****************************************************************************/ |
| 161 | struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = { |
| 162 | .dram = &kirkwood_mbus_dram_info, |
| 163 | .shared_smi = &kirkwood_ge00_shared, |
| 164 | }; |
| 165 | |
| 166 | static struct resource kirkwood_ge01_shared_resources[] = { |
| 167 | { |
| 168 | .name = "ge01 base", |
| 169 | .start = GE01_PHYS_BASE + 0x2000, |
| 170 | .end = GE01_PHYS_BASE + 0x3fff, |
| 171 | .flags = IORESOURCE_MEM, |
| 172 | }, { |
| 173 | .name = "ge01 err irq", |
| 174 | .start = IRQ_KIRKWOOD_GE01_ERR, |
| 175 | .end = IRQ_KIRKWOOD_GE01_ERR, |
| 176 | .flags = IORESOURCE_IRQ, |
| 177 | }, |
| 178 | }; |
| 179 | |
| 180 | static struct platform_device kirkwood_ge01_shared = { |
| 181 | .name = MV643XX_ETH_SHARED_NAME, |
| 182 | .id = 1, |
| 183 | .dev = { |
| 184 | .platform_data = &kirkwood_ge01_shared_data, |
| 185 | }, |
| 186 | .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources), |
| 187 | .resource = kirkwood_ge01_shared_resources, |
| 188 | }; |
| 189 | |
| 190 | static struct resource kirkwood_ge01_resources[] = { |
| 191 | { |
| 192 | .name = "ge01 irq", |
| 193 | .start = IRQ_KIRKWOOD_GE01_SUM, |
| 194 | .end = IRQ_KIRKWOOD_GE01_SUM, |
| 195 | .flags = IORESOURCE_IRQ, |
| 196 | }, |
| 197 | }; |
| 198 | |
| 199 | static struct platform_device kirkwood_ge01 = { |
| 200 | .name = MV643XX_ETH_NAME, |
| 201 | .id = 1, |
| 202 | .num_resources = 1, |
| 203 | .resource = kirkwood_ge01_resources, |
| 204 | }; |
| 205 | |
| 206 | void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data) |
| 207 | { |
| 208 | eth_data->shared = &kirkwood_ge01_shared; |
| 209 | kirkwood_ge01.dev.platform_data = eth_data; |
| 210 | |
| 211 | platform_device_register(&kirkwood_ge01_shared); |
| 212 | platform_device_register(&kirkwood_ge01); |
| 213 | } |
| 214 | |
| 215 | |
| 216 | /***************************************************************************** |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 217 | * Ethernet switch |
| 218 | ****************************************************************************/ |
| 219 | static struct resource kirkwood_switch_resources[] = { |
| 220 | { |
| 221 | .start = 0, |
| 222 | .end = 0, |
| 223 | .flags = IORESOURCE_IRQ, |
| 224 | }, |
| 225 | }; |
| 226 | |
| 227 | static struct platform_device kirkwood_switch_device = { |
| 228 | .name = "dsa", |
| 229 | .id = 0, |
| 230 | .num_resources = 0, |
| 231 | .resource = kirkwood_switch_resources, |
| 232 | }; |
| 233 | |
| 234 | void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq) |
| 235 | { |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 236 | int i; |
| 237 | |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 238 | if (irq != NO_IRQ) { |
| 239 | kirkwood_switch_resources[0].start = irq; |
| 240 | kirkwood_switch_resources[0].end = irq; |
| 241 | kirkwood_switch_device.num_resources = 1; |
| 242 | } |
| 243 | |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 244 | d->netdev = &kirkwood_ge00.dev; |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 245 | for (i = 0; i < d->nr_chips; i++) |
| 246 | d->chip[i].mii_bus = &kirkwood_ge00_shared.dev; |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 247 | kirkwood_switch_device.dev.platform_data = d; |
| 248 | |
| 249 | platform_device_register(&kirkwood_switch_device); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | /***************************************************************************** |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 254 | * SoC RTC |
| 255 | ****************************************************************************/ |
| 256 | static struct resource kirkwood_rtc_resource = { |
| 257 | .start = RTC_PHYS_BASE, |
| 258 | .end = RTC_PHYS_BASE + SZ_16 - 1, |
| 259 | .flags = IORESOURCE_MEM, |
| 260 | }; |
| 261 | |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 262 | static void __init kirkwood_rtc_init(void) |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 263 | { |
| 264 | platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1); |
| 265 | } |
| 266 | |
| 267 | |
| 268 | /***************************************************************************** |
| 269 | * SATA |
| 270 | ****************************************************************************/ |
| 271 | static struct resource kirkwood_sata_resources[] = { |
| 272 | { |
| 273 | .name = "sata base", |
| 274 | .start = SATA_PHYS_BASE, |
| 275 | .end = SATA_PHYS_BASE + 0x5000 - 1, |
| 276 | .flags = IORESOURCE_MEM, |
| 277 | }, { |
| 278 | .name = "sata irq", |
| 279 | .start = IRQ_KIRKWOOD_SATA, |
| 280 | .end = IRQ_KIRKWOOD_SATA, |
| 281 | .flags = IORESOURCE_IRQ, |
| 282 | }, |
| 283 | }; |
| 284 | |
| 285 | static struct platform_device kirkwood_sata = { |
| 286 | .name = "sata_mv", |
| 287 | .id = 0, |
| 288 | .dev = { |
| 289 | .coherent_dma_mask = 0xffffffff, |
| 290 | }, |
| 291 | .num_resources = ARRAY_SIZE(kirkwood_sata_resources), |
| 292 | .resource = kirkwood_sata_resources, |
| 293 | }; |
| 294 | |
| 295 | void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data) |
| 296 | { |
| 297 | sata_data->dram = &kirkwood_mbus_dram_info; |
| 298 | kirkwood_sata.dev.platform_data = sata_data; |
| 299 | platform_device_register(&kirkwood_sata); |
| 300 | } |
| 301 | |
| 302 | |
| 303 | /***************************************************************************** |
Nicolas Pitre | 8235ee0 | 2009-02-14 03:15:55 -0500 | [diff] [blame] | 304 | * SD/SDIO/MMC |
| 305 | ****************************************************************************/ |
| 306 | static struct resource mvsdio_resources[] = { |
| 307 | [0] = { |
| 308 | .start = SDIO_PHYS_BASE, |
| 309 | .end = SDIO_PHYS_BASE + SZ_1K - 1, |
| 310 | .flags = IORESOURCE_MEM, |
| 311 | }, |
| 312 | [1] = { |
| 313 | .start = IRQ_KIRKWOOD_SDIO, |
| 314 | .end = IRQ_KIRKWOOD_SDIO, |
| 315 | .flags = IORESOURCE_IRQ, |
| 316 | }, |
| 317 | }; |
| 318 | |
| 319 | static u64 mvsdio_dmamask = 0xffffffffUL; |
| 320 | |
| 321 | static struct platform_device kirkwood_sdio = { |
| 322 | .name = "mvsdio", |
| 323 | .id = -1, |
| 324 | .dev = { |
| 325 | .dma_mask = &mvsdio_dmamask, |
| 326 | .coherent_dma_mask = 0xffffffff, |
| 327 | }, |
| 328 | .num_resources = ARRAY_SIZE(mvsdio_resources), |
| 329 | .resource = mvsdio_resources, |
| 330 | }; |
| 331 | |
| 332 | void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data) |
| 333 | { |
| 334 | u32 dev, rev; |
| 335 | |
| 336 | kirkwood_pcie_id(&dev, &rev); |
| 337 | if (rev == 0) /* catch all Kirkwood Z0's */ |
| 338 | mvsdio_data->clock = 100000000; |
| 339 | else |
| 340 | mvsdio_data->clock = 200000000; |
| 341 | mvsdio_data->dram = &kirkwood_mbus_dram_info; |
| 342 | kirkwood_sdio.dev.platform_data = mvsdio_data; |
| 343 | platform_device_register(&kirkwood_sdio); |
| 344 | } |
| 345 | |
| 346 | |
| 347 | /***************************************************************************** |
Lennert Buytenhek | 18365d1 | 2008-08-09 15:38:18 +0200 | [diff] [blame] | 348 | * SPI |
| 349 | ****************************************************************************/ |
| 350 | static struct orion_spi_info kirkwood_spi_plat_data = { |
Lennert Buytenhek | 18365d1 | 2008-08-09 15:38:18 +0200 | [diff] [blame] | 351 | }; |
| 352 | |
| 353 | static struct resource kirkwood_spi_resources[] = { |
| 354 | { |
| 355 | .start = SPI_PHYS_BASE, |
| 356 | .end = SPI_PHYS_BASE + SZ_512 - 1, |
| 357 | .flags = IORESOURCE_MEM, |
| 358 | }, |
| 359 | }; |
| 360 | |
| 361 | static struct platform_device kirkwood_spi = { |
| 362 | .name = "orion_spi", |
| 363 | .id = 0, |
| 364 | .resource = kirkwood_spi_resources, |
| 365 | .dev = { |
| 366 | .platform_data = &kirkwood_spi_plat_data, |
| 367 | }, |
| 368 | .num_resources = ARRAY_SIZE(kirkwood_spi_resources), |
| 369 | }; |
| 370 | |
| 371 | void __init kirkwood_spi_init() |
| 372 | { |
| 373 | platform_device_register(&kirkwood_spi); |
| 374 | } |
| 375 | |
| 376 | |
| 377 | /***************************************************************************** |
Martin Michlmayr | 6574e00 | 2009-03-23 19:13:21 +0100 | [diff] [blame] | 378 | * I2C |
| 379 | ****************************************************************************/ |
| 380 | static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = { |
| 381 | .freq_m = 8, /* assumes 166 MHz TCLK */ |
| 382 | .freq_n = 3, |
| 383 | .timeout = 1000, /* Default timeout of 1 second */ |
| 384 | }; |
| 385 | |
| 386 | static struct resource kirkwood_i2c_resources[] = { |
| 387 | { |
| 388 | .name = "i2c", |
| 389 | .start = I2C_PHYS_BASE, |
| 390 | .end = I2C_PHYS_BASE + 0x1f, |
| 391 | .flags = IORESOURCE_MEM, |
| 392 | }, { |
| 393 | .name = "i2c", |
| 394 | .start = IRQ_KIRKWOOD_TWSI, |
| 395 | .end = IRQ_KIRKWOOD_TWSI, |
| 396 | .flags = IORESOURCE_IRQ, |
| 397 | }, |
| 398 | }; |
| 399 | |
| 400 | static struct platform_device kirkwood_i2c = { |
| 401 | .name = MV64XXX_I2C_CTLR_NAME, |
| 402 | .id = 0, |
| 403 | .num_resources = ARRAY_SIZE(kirkwood_i2c_resources), |
| 404 | .resource = kirkwood_i2c_resources, |
| 405 | .dev = { |
| 406 | .platform_data = &kirkwood_i2c_pdata, |
| 407 | }, |
| 408 | }; |
| 409 | |
| 410 | void __init kirkwood_i2c_init(void) |
| 411 | { |
| 412 | platform_device_register(&kirkwood_i2c); |
| 413 | } |
| 414 | |
| 415 | |
| 416 | /***************************************************************************** |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 417 | * UART0 |
| 418 | ****************************************************************************/ |
| 419 | static struct plat_serial8250_port kirkwood_uart0_data[] = { |
| 420 | { |
| 421 | .mapbase = UART0_PHYS_BASE, |
| 422 | .membase = (char *)UART0_VIRT_BASE, |
| 423 | .irq = IRQ_KIRKWOOD_UART_0, |
| 424 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 425 | .iotype = UPIO_MEM, |
| 426 | .regshift = 2, |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 427 | .uartclk = 0, |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 428 | }, { |
| 429 | }, |
| 430 | }; |
| 431 | |
| 432 | static struct resource kirkwood_uart0_resources[] = { |
| 433 | { |
| 434 | .start = UART0_PHYS_BASE, |
| 435 | .end = UART0_PHYS_BASE + 0xff, |
| 436 | .flags = IORESOURCE_MEM, |
| 437 | }, { |
| 438 | .start = IRQ_KIRKWOOD_UART_0, |
| 439 | .end = IRQ_KIRKWOOD_UART_0, |
| 440 | .flags = IORESOURCE_IRQ, |
| 441 | }, |
| 442 | }; |
| 443 | |
| 444 | static struct platform_device kirkwood_uart0 = { |
| 445 | .name = "serial8250", |
| 446 | .id = 0, |
| 447 | .dev = { |
| 448 | .platform_data = kirkwood_uart0_data, |
| 449 | }, |
| 450 | .resource = kirkwood_uart0_resources, |
| 451 | .num_resources = ARRAY_SIZE(kirkwood_uart0_resources), |
| 452 | }; |
| 453 | |
| 454 | void __init kirkwood_uart0_init(void) |
| 455 | { |
| 456 | platform_device_register(&kirkwood_uart0); |
| 457 | } |
| 458 | |
| 459 | |
| 460 | /***************************************************************************** |
| 461 | * UART1 |
| 462 | ****************************************************************************/ |
| 463 | static struct plat_serial8250_port kirkwood_uart1_data[] = { |
| 464 | { |
| 465 | .mapbase = UART1_PHYS_BASE, |
| 466 | .membase = (char *)UART1_VIRT_BASE, |
| 467 | .irq = IRQ_KIRKWOOD_UART_1, |
| 468 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 469 | .iotype = UPIO_MEM, |
| 470 | .regshift = 2, |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 471 | .uartclk = 0, |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 472 | }, { |
| 473 | }, |
| 474 | }; |
| 475 | |
| 476 | static struct resource kirkwood_uart1_resources[] = { |
| 477 | { |
| 478 | .start = UART1_PHYS_BASE, |
| 479 | .end = UART1_PHYS_BASE + 0xff, |
| 480 | .flags = IORESOURCE_MEM, |
| 481 | }, { |
| 482 | .start = IRQ_KIRKWOOD_UART_1, |
| 483 | .end = IRQ_KIRKWOOD_UART_1, |
| 484 | .flags = IORESOURCE_IRQ, |
| 485 | }, |
| 486 | }; |
| 487 | |
| 488 | static struct platform_device kirkwood_uart1 = { |
| 489 | .name = "serial8250", |
| 490 | .id = 1, |
| 491 | .dev = { |
| 492 | .platform_data = kirkwood_uart1_data, |
| 493 | }, |
| 494 | .resource = kirkwood_uart1_resources, |
| 495 | .num_resources = ARRAY_SIZE(kirkwood_uart1_resources), |
| 496 | }; |
| 497 | |
| 498 | void __init kirkwood_uart1_init(void) |
| 499 | { |
| 500 | platform_device_register(&kirkwood_uart1); |
| 501 | } |
| 502 | |
| 503 | |
| 504 | /***************************************************************************** |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 505 | * XOR |
| 506 | ****************************************************************************/ |
| 507 | static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = { |
| 508 | .dram = &kirkwood_mbus_dram_info, |
| 509 | }; |
| 510 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 511 | static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32); |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 512 | |
| 513 | |
| 514 | /***************************************************************************** |
| 515 | * XOR0 |
| 516 | ****************************************************************************/ |
| 517 | static struct resource kirkwood_xor0_shared_resources[] = { |
| 518 | { |
| 519 | .name = "xor 0 low", |
| 520 | .start = XOR0_PHYS_BASE, |
| 521 | .end = XOR0_PHYS_BASE + 0xff, |
| 522 | .flags = IORESOURCE_MEM, |
| 523 | }, { |
| 524 | .name = "xor 0 high", |
| 525 | .start = XOR0_HIGH_PHYS_BASE, |
| 526 | .end = XOR0_HIGH_PHYS_BASE + 0xff, |
| 527 | .flags = IORESOURCE_MEM, |
| 528 | }, |
| 529 | }; |
| 530 | |
| 531 | static struct platform_device kirkwood_xor0_shared = { |
| 532 | .name = MV_XOR_SHARED_NAME, |
| 533 | .id = 0, |
| 534 | .dev = { |
| 535 | .platform_data = &kirkwood_xor_shared_data, |
| 536 | }, |
| 537 | .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources), |
| 538 | .resource = kirkwood_xor0_shared_resources, |
| 539 | }; |
| 540 | |
| 541 | static struct resource kirkwood_xor00_resources[] = { |
| 542 | [0] = { |
| 543 | .start = IRQ_KIRKWOOD_XOR_00, |
| 544 | .end = IRQ_KIRKWOOD_XOR_00, |
| 545 | .flags = IORESOURCE_IRQ, |
| 546 | }, |
| 547 | }; |
| 548 | |
| 549 | static struct mv_xor_platform_data kirkwood_xor00_data = { |
| 550 | .shared = &kirkwood_xor0_shared, |
| 551 | .hw_id = 0, |
| 552 | .pool_size = PAGE_SIZE, |
| 553 | }; |
| 554 | |
| 555 | static struct platform_device kirkwood_xor00_channel = { |
| 556 | .name = MV_XOR_NAME, |
| 557 | .id = 0, |
| 558 | .num_resources = ARRAY_SIZE(kirkwood_xor00_resources), |
| 559 | .resource = kirkwood_xor00_resources, |
| 560 | .dev = { |
| 561 | .dma_mask = &kirkwood_xor_dmamask, |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 562 | .coherent_dma_mask = DMA_BIT_MASK(64), |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 563 | .platform_data = (void *)&kirkwood_xor00_data, |
| 564 | }, |
| 565 | }; |
| 566 | |
| 567 | static struct resource kirkwood_xor01_resources[] = { |
| 568 | [0] = { |
| 569 | .start = IRQ_KIRKWOOD_XOR_01, |
| 570 | .end = IRQ_KIRKWOOD_XOR_01, |
| 571 | .flags = IORESOURCE_IRQ, |
| 572 | }, |
| 573 | }; |
| 574 | |
| 575 | static struct mv_xor_platform_data kirkwood_xor01_data = { |
| 576 | .shared = &kirkwood_xor0_shared, |
| 577 | .hw_id = 1, |
| 578 | .pool_size = PAGE_SIZE, |
| 579 | }; |
| 580 | |
| 581 | static struct platform_device kirkwood_xor01_channel = { |
| 582 | .name = MV_XOR_NAME, |
| 583 | .id = 1, |
| 584 | .num_resources = ARRAY_SIZE(kirkwood_xor01_resources), |
| 585 | .resource = kirkwood_xor01_resources, |
| 586 | .dev = { |
| 587 | .dma_mask = &kirkwood_xor_dmamask, |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 588 | .coherent_dma_mask = DMA_BIT_MASK(64), |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 589 | .platform_data = (void *)&kirkwood_xor01_data, |
| 590 | }, |
| 591 | }; |
| 592 | |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 593 | static void __init kirkwood_xor0_init(void) |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 594 | { |
| 595 | platform_device_register(&kirkwood_xor0_shared); |
| 596 | |
| 597 | /* |
| 598 | * two engines can't do memset simultaneously, this limitation |
| 599 | * satisfied by removing memset support from one of the engines. |
| 600 | */ |
| 601 | dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask); |
| 602 | dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask); |
| 603 | platform_device_register(&kirkwood_xor00_channel); |
| 604 | |
| 605 | dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask); |
| 606 | dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask); |
| 607 | dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask); |
| 608 | platform_device_register(&kirkwood_xor01_channel); |
| 609 | } |
| 610 | |
| 611 | |
| 612 | /***************************************************************************** |
| 613 | * XOR1 |
| 614 | ****************************************************************************/ |
| 615 | static struct resource kirkwood_xor1_shared_resources[] = { |
| 616 | { |
| 617 | .name = "xor 1 low", |
| 618 | .start = XOR1_PHYS_BASE, |
| 619 | .end = XOR1_PHYS_BASE + 0xff, |
| 620 | .flags = IORESOURCE_MEM, |
| 621 | }, { |
| 622 | .name = "xor 1 high", |
| 623 | .start = XOR1_HIGH_PHYS_BASE, |
| 624 | .end = XOR1_HIGH_PHYS_BASE + 0xff, |
| 625 | .flags = IORESOURCE_MEM, |
| 626 | }, |
| 627 | }; |
| 628 | |
| 629 | static struct platform_device kirkwood_xor1_shared = { |
| 630 | .name = MV_XOR_SHARED_NAME, |
| 631 | .id = 1, |
| 632 | .dev = { |
| 633 | .platform_data = &kirkwood_xor_shared_data, |
| 634 | }, |
| 635 | .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources), |
| 636 | .resource = kirkwood_xor1_shared_resources, |
| 637 | }; |
| 638 | |
| 639 | static struct resource kirkwood_xor10_resources[] = { |
| 640 | [0] = { |
| 641 | .start = IRQ_KIRKWOOD_XOR_10, |
| 642 | .end = IRQ_KIRKWOOD_XOR_10, |
| 643 | .flags = IORESOURCE_IRQ, |
| 644 | }, |
| 645 | }; |
| 646 | |
| 647 | static struct mv_xor_platform_data kirkwood_xor10_data = { |
| 648 | .shared = &kirkwood_xor1_shared, |
| 649 | .hw_id = 0, |
| 650 | .pool_size = PAGE_SIZE, |
| 651 | }; |
| 652 | |
| 653 | static struct platform_device kirkwood_xor10_channel = { |
| 654 | .name = MV_XOR_NAME, |
| 655 | .id = 2, |
| 656 | .num_resources = ARRAY_SIZE(kirkwood_xor10_resources), |
| 657 | .resource = kirkwood_xor10_resources, |
| 658 | .dev = { |
| 659 | .dma_mask = &kirkwood_xor_dmamask, |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 660 | .coherent_dma_mask = DMA_BIT_MASK(64), |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 661 | .platform_data = (void *)&kirkwood_xor10_data, |
| 662 | }, |
| 663 | }; |
| 664 | |
| 665 | static struct resource kirkwood_xor11_resources[] = { |
| 666 | [0] = { |
| 667 | .start = IRQ_KIRKWOOD_XOR_11, |
| 668 | .end = IRQ_KIRKWOOD_XOR_11, |
| 669 | .flags = IORESOURCE_IRQ, |
| 670 | }, |
| 671 | }; |
| 672 | |
| 673 | static struct mv_xor_platform_data kirkwood_xor11_data = { |
| 674 | .shared = &kirkwood_xor1_shared, |
| 675 | .hw_id = 1, |
| 676 | .pool_size = PAGE_SIZE, |
| 677 | }; |
| 678 | |
| 679 | static struct platform_device kirkwood_xor11_channel = { |
| 680 | .name = MV_XOR_NAME, |
| 681 | .id = 3, |
| 682 | .num_resources = ARRAY_SIZE(kirkwood_xor11_resources), |
| 683 | .resource = kirkwood_xor11_resources, |
| 684 | .dev = { |
| 685 | .dma_mask = &kirkwood_xor_dmamask, |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 686 | .coherent_dma_mask = DMA_BIT_MASK(64), |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 687 | .platform_data = (void *)&kirkwood_xor11_data, |
| 688 | }, |
| 689 | }; |
| 690 | |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 691 | static void __init kirkwood_xor1_init(void) |
Saeed Bishara | 09c0ed2 | 2008-06-23 04:26:07 -1100 | [diff] [blame] | 692 | { |
| 693 | platform_device_register(&kirkwood_xor1_shared); |
| 694 | |
| 695 | /* |
| 696 | * two engines can't do memset simultaneously, this limitation |
| 697 | * satisfied by removing memset support from one of the engines. |
| 698 | */ |
| 699 | dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask); |
| 700 | dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask); |
| 701 | platform_device_register(&kirkwood_xor10_channel); |
| 702 | |
| 703 | dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask); |
| 704 | dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask); |
| 705 | dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask); |
| 706 | platform_device_register(&kirkwood_xor11_channel); |
| 707 | } |
| 708 | |
| 709 | |
| 710 | /***************************************************************************** |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 711 | * Time handling |
| 712 | ****************************************************************************/ |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 713 | int kirkwood_tclk; |
| 714 | |
| 715 | int __init kirkwood_find_tclk(void) |
| 716 | { |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 717 | u32 dev, rev; |
| 718 | |
| 719 | kirkwood_pcie_id(&dev, &rev); |
| 720 | if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0) |
| 721 | return 200000000; |
| 722 | |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 723 | return 166666667; |
| 724 | } |
| 725 | |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 726 | static void kirkwood_timer_init(void) |
| 727 | { |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 728 | kirkwood_tclk = kirkwood_find_tclk(); |
| 729 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | struct sys_timer kirkwood_timer = { |
| 733 | .init = kirkwood_timer_init, |
| 734 | }; |
| 735 | |
| 736 | |
| 737 | /***************************************************************************** |
| 738 | * General |
| 739 | ****************************************************************************/ |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 740 | /* |
| 741 | * Identify device ID and revision. |
| 742 | */ |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 743 | static char * __init kirkwood_id(void) |
| 744 | { |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 745 | u32 dev, rev; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 746 | |
Ronen Shitrit | b2b3dc2 | 2008-09-15 10:40:35 +0300 | [diff] [blame] | 747 | kirkwood_pcie_id(&dev, &rev); |
| 748 | |
| 749 | if (dev == MV88F6281_DEV_ID) { |
| 750 | if (rev == MV88F6281_REV_Z0) |
| 751 | return "MV88F6281-Z0"; |
| 752 | else if (rev == MV88F6281_REV_A0) |
| 753 | return "MV88F6281-A0"; |
| 754 | else |
| 755 | return "MV88F6281-Rev-Unsupported"; |
| 756 | } else if (dev == MV88F6192_DEV_ID) { |
| 757 | if (rev == MV88F6192_REV_Z0) |
| 758 | return "MV88F6192-Z0"; |
| 759 | else if (rev == MV88F6192_REV_A0) |
| 760 | return "MV88F6192-A0"; |
| 761 | else |
| 762 | return "MV88F6192-Rev-Unsupported"; |
| 763 | } else if (dev == MV88F6180_DEV_ID) { |
| 764 | if (rev == MV88F6180_REV_A0) |
| 765 | return "MV88F6180-Rev-A0"; |
| 766 | else |
| 767 | return "MV88F6180-Rev-Unsupported"; |
| 768 | } else { |
| 769 | return "Device-Unknown"; |
| 770 | } |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 771 | } |
| 772 | |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 773 | static void __init kirkwood_l2_init(void) |
Saeed Bishara | 1338760 | 2008-06-23 01:05:08 -1100 | [diff] [blame] | 774 | { |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 775 | #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH |
| 776 | writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG); |
| 777 | feroceon_l2_init(1); |
| 778 | #else |
| 779 | writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG); |
| 780 | feroceon_l2_init(0); |
| 781 | #endif |
Saeed Bishara | 1338760 | 2008-06-23 01:05:08 -1100 | [diff] [blame] | 782 | } |
| 783 | |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 784 | void __init kirkwood_init(void) |
| 785 | { |
| 786 | printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 787 | kirkwood_id(), kirkwood_tclk); |
| 788 | kirkwood_ge00_shared_data.t_clk = kirkwood_tclk; |
Nicolas Pitre | 13731d1 | 2009-01-06 23:02:08 +0100 | [diff] [blame] | 789 | kirkwood_ge01_shared_data.t_clk = kirkwood_tclk; |
Ronen Shitrit | 79d4dd7 | 2008-09-15 00:56:38 +0200 | [diff] [blame] | 790 | kirkwood_spi_plat_data.tclk = kirkwood_tclk; |
| 791 | kirkwood_uart0_data[0].uartclk = kirkwood_tclk; |
| 792 | kirkwood_uart1_data[0].uartclk = kirkwood_tclk; |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 793 | |
| 794 | kirkwood_setup_cpu_mbus(); |
| 795 | |
| 796 | #ifdef CONFIG_CACHE_FEROCEON_L2 |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 797 | kirkwood_l2_init(); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 798 | #endif |
Nicolas Pitre | 5b99d53 | 2009-02-26 22:55:59 -0500 | [diff] [blame] | 799 | |
| 800 | /* internal devices that every board has */ |
| 801 | kirkwood_rtc_init(); |
| 802 | kirkwood_xor0_init(); |
| 803 | kirkwood_xor1_init(); |
Saeed Bishara | 651c74c | 2008-06-22 22:45:06 +0200 | [diff] [blame] | 804 | } |