Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/plat-orion/common.c |
| 3 | * |
| 4 | * Marvell Orion SoC common setup code used by multiple mach-/common.c |
| 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> |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 14 | #include <linux/dma-mapping.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 15 | #include <linux/serial_8250.h> |
Andrew Lunn | 9e613f8 | 2011-05-15 13:32:50 +0200 | [diff] [blame] | 16 | #include <linux/ata_platform.h> |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 17 | #include <linux/mv643xx_eth.h> |
Andrew Lunn | aac7ffa | 2011-05-15 13:32:45 +0200 | [diff] [blame] | 18 | #include <linux/mv643xx_i2c.h> |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 19 | #include <net/dsa.h> |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 20 | #include <linux/spi/orion_spi.h> |
Andrew Lunn | 5e00d37 | 2011-05-15 13:32:47 +0200 | [diff] [blame] | 21 | #include <plat/orion_wdt.h> |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 22 | #include <plat/mv_xor.h> |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 23 | #include <plat/ehci-orion.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 24 | |
| 25 | /* Fill in the resources structure and link it into the platform |
| 26 | device structure. There is always a memory region, and nearly |
| 27 | always an interrupt.*/ |
| 28 | static void fill_resources(struct platform_device *device, |
| 29 | struct resource *resources, |
| 30 | resource_size_t mapbase, |
| 31 | resource_size_t size, |
| 32 | unsigned int irq) |
| 33 | { |
| 34 | device->resource = resources; |
| 35 | device->num_resources = 1; |
| 36 | resources[0].flags = IORESOURCE_MEM; |
| 37 | resources[0].start = mapbase; |
| 38 | resources[0].end = mapbase + size; |
| 39 | |
| 40 | if (irq != NO_IRQ) { |
| 41 | device->num_resources++; |
| 42 | resources[1].flags = IORESOURCE_IRQ; |
| 43 | resources[1].start = irq; |
| 44 | resources[1].end = irq; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /***************************************************************************** |
| 49 | * UART |
| 50 | ****************************************************************************/ |
| 51 | static void __init uart_complete( |
| 52 | struct platform_device *orion_uart, |
| 53 | struct plat_serial8250_port *data, |
| 54 | struct resource *resources, |
| 55 | unsigned int membase, |
| 56 | resource_size_t mapbase, |
| 57 | unsigned int irq, |
| 58 | unsigned int uartclk) |
| 59 | { |
| 60 | data->mapbase = mapbase; |
| 61 | data->membase = (void __iomem *)membase; |
| 62 | data->irq = irq; |
| 63 | data->uartclk = uartclk; |
| 64 | orion_uart->dev.platform_data = data; |
| 65 | |
| 66 | fill_resources(orion_uart, resources, mapbase, 0xff, irq); |
| 67 | platform_device_register(orion_uart); |
| 68 | } |
| 69 | |
| 70 | /***************************************************************************** |
| 71 | * UART0 |
| 72 | ****************************************************************************/ |
| 73 | static struct plat_serial8250_port orion_uart0_data[] = { |
| 74 | { |
| 75 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 76 | .iotype = UPIO_MEM, |
| 77 | .regshift = 2, |
| 78 | }, { |
| 79 | }, |
| 80 | }; |
| 81 | |
| 82 | static struct resource orion_uart0_resources[2]; |
| 83 | |
| 84 | static struct platform_device orion_uart0 = { |
| 85 | .name = "serial8250", |
| 86 | .id = PLAT8250_DEV_PLATFORM, |
| 87 | }; |
| 88 | |
| 89 | void __init orion_uart0_init(unsigned int membase, |
| 90 | resource_size_t mapbase, |
| 91 | unsigned int irq, |
| 92 | unsigned int uartclk) |
| 93 | { |
| 94 | uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources, |
| 95 | membase, mapbase, irq, uartclk); |
| 96 | } |
| 97 | |
| 98 | /***************************************************************************** |
| 99 | * UART1 |
| 100 | ****************************************************************************/ |
| 101 | static struct plat_serial8250_port orion_uart1_data[] = { |
| 102 | { |
| 103 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 104 | .iotype = UPIO_MEM, |
| 105 | .regshift = 2, |
| 106 | }, { |
| 107 | }, |
| 108 | }; |
| 109 | |
| 110 | static struct resource orion_uart1_resources[2]; |
| 111 | |
| 112 | static struct platform_device orion_uart1 = { |
| 113 | .name = "serial8250", |
| 114 | .id = PLAT8250_DEV_PLATFORM1, |
| 115 | }; |
| 116 | |
| 117 | void __init orion_uart1_init(unsigned int membase, |
| 118 | resource_size_t mapbase, |
| 119 | unsigned int irq, |
| 120 | unsigned int uartclk) |
| 121 | { |
| 122 | uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources, |
| 123 | membase, mapbase, irq, uartclk); |
| 124 | } |
| 125 | |
| 126 | /***************************************************************************** |
| 127 | * UART2 |
| 128 | ****************************************************************************/ |
| 129 | static struct plat_serial8250_port orion_uart2_data[] = { |
| 130 | { |
| 131 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 132 | .iotype = UPIO_MEM, |
| 133 | .regshift = 2, |
| 134 | }, { |
| 135 | }, |
| 136 | }; |
| 137 | |
| 138 | static struct resource orion_uart2_resources[2]; |
| 139 | |
| 140 | static struct platform_device orion_uart2 = { |
| 141 | .name = "serial8250", |
| 142 | .id = PLAT8250_DEV_PLATFORM2, |
| 143 | }; |
| 144 | |
| 145 | void __init orion_uart2_init(unsigned int membase, |
| 146 | resource_size_t mapbase, |
| 147 | unsigned int irq, |
| 148 | unsigned int uartclk) |
| 149 | { |
| 150 | uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources, |
| 151 | membase, mapbase, irq, uartclk); |
| 152 | } |
| 153 | |
| 154 | /***************************************************************************** |
| 155 | * UART3 |
| 156 | ****************************************************************************/ |
| 157 | static struct plat_serial8250_port orion_uart3_data[] = { |
| 158 | { |
| 159 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 160 | .iotype = UPIO_MEM, |
| 161 | .regshift = 2, |
| 162 | }, { |
| 163 | }, |
| 164 | }; |
| 165 | |
| 166 | static struct resource orion_uart3_resources[2]; |
| 167 | |
| 168 | static struct platform_device orion_uart3 = { |
| 169 | .name = "serial8250", |
| 170 | .id = 3, |
| 171 | }; |
| 172 | |
| 173 | void __init orion_uart3_init(unsigned int membase, |
| 174 | resource_size_t mapbase, |
| 175 | unsigned int irq, |
| 176 | unsigned int uartclk) |
| 177 | { |
| 178 | uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources, |
| 179 | membase, mapbase, irq, uartclk); |
| 180 | } |
Andrew Lunn | f6eaccb | 2011-05-15 13:32:42 +0200 | [diff] [blame] | 181 | |
| 182 | /***************************************************************************** |
| 183 | * SoC RTC |
| 184 | ****************************************************************************/ |
| 185 | static struct resource orion_rtc_resource[2]; |
| 186 | |
| 187 | void __init orion_rtc_init(unsigned long mapbase, |
| 188 | unsigned long irq) |
| 189 | { |
| 190 | orion_rtc_resource[0].start = mapbase; |
| 191 | orion_rtc_resource[0].end = mapbase + SZ_32 - 1; |
| 192 | orion_rtc_resource[0].flags = IORESOURCE_MEM; |
| 193 | orion_rtc_resource[1].start = irq; |
| 194 | orion_rtc_resource[1].end = irq; |
| 195 | orion_rtc_resource[1].flags = IORESOURCE_IRQ; |
| 196 | |
| 197 | platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2); |
| 198 | } |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 199 | |
| 200 | /***************************************************************************** |
| 201 | * GE |
| 202 | ****************************************************************************/ |
| 203 | static __init void ge_complete( |
| 204 | struct mv643xx_eth_shared_platform_data *orion_ge_shared_data, |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 205 | int tclk, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 206 | struct resource *orion_ge_resource, unsigned long irq, |
| 207 | struct platform_device *orion_ge_shared, |
| 208 | struct mv643xx_eth_platform_data *eth_data, |
| 209 | struct platform_device *orion_ge) |
| 210 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 211 | orion_ge_shared_data->t_clk = tclk; |
| 212 | orion_ge_resource->start = irq; |
| 213 | orion_ge_resource->end = irq; |
| 214 | eth_data->shared = orion_ge_shared; |
| 215 | orion_ge->dev.platform_data = eth_data; |
| 216 | |
| 217 | platform_device_register(orion_ge_shared); |
| 218 | platform_device_register(orion_ge); |
| 219 | } |
| 220 | |
| 221 | /***************************************************************************** |
| 222 | * GE00 |
| 223 | ****************************************************************************/ |
| 224 | struct mv643xx_eth_shared_platform_data orion_ge00_shared_data; |
| 225 | |
| 226 | static struct resource orion_ge00_shared_resources[] = { |
| 227 | { |
| 228 | .name = "ge00 base", |
| 229 | }, { |
| 230 | .name = "ge00 err irq", |
| 231 | }, |
| 232 | }; |
| 233 | |
| 234 | static struct platform_device orion_ge00_shared = { |
| 235 | .name = MV643XX_ETH_SHARED_NAME, |
| 236 | .id = 0, |
| 237 | .dev = { |
| 238 | .platform_data = &orion_ge00_shared_data, |
| 239 | }, |
| 240 | }; |
| 241 | |
| 242 | static struct resource orion_ge00_resources[] = { |
| 243 | { |
| 244 | .name = "ge00 irq", |
| 245 | .flags = IORESOURCE_IRQ, |
| 246 | }, |
| 247 | }; |
| 248 | |
| 249 | static struct platform_device orion_ge00 = { |
| 250 | .name = MV643XX_ETH_NAME, |
| 251 | .id = 0, |
| 252 | .num_resources = 1, |
| 253 | .resource = orion_ge00_resources, |
| 254 | .dev = { |
| 255 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 256 | }, |
| 257 | }; |
| 258 | |
| 259 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 260 | unsigned long mapbase, |
| 261 | unsigned long irq, |
| 262 | unsigned long irq_err, |
| 263 | int tclk) |
| 264 | { |
| 265 | fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, |
| 266 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 267 | ge_complete(&orion_ge00_shared_data, tclk, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 268 | orion_ge00_resources, irq, &orion_ge00_shared, |
| 269 | eth_data, &orion_ge00); |
| 270 | } |
| 271 | |
| 272 | /***************************************************************************** |
| 273 | * GE01 |
| 274 | ****************************************************************************/ |
| 275 | struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = { |
| 276 | .shared_smi = &orion_ge00_shared, |
| 277 | }; |
| 278 | |
| 279 | static struct resource orion_ge01_shared_resources[] = { |
| 280 | { |
| 281 | .name = "ge01 base", |
| 282 | }, { |
| 283 | .name = "ge01 err irq", |
| 284 | }, |
| 285 | }; |
| 286 | |
| 287 | static struct platform_device orion_ge01_shared = { |
| 288 | .name = MV643XX_ETH_SHARED_NAME, |
| 289 | .id = 1, |
| 290 | .dev = { |
| 291 | .platform_data = &orion_ge01_shared_data, |
| 292 | }, |
| 293 | }; |
| 294 | |
| 295 | static struct resource orion_ge01_resources[] = { |
| 296 | { |
| 297 | .name = "ge01 irq", |
| 298 | .flags = IORESOURCE_IRQ, |
| 299 | }, |
| 300 | }; |
| 301 | |
| 302 | static struct platform_device orion_ge01 = { |
| 303 | .name = MV643XX_ETH_NAME, |
| 304 | .id = 1, |
| 305 | .num_resources = 1, |
| 306 | .resource = orion_ge01_resources, |
| 307 | .dev = { |
| 308 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 313 | unsigned long mapbase, |
| 314 | unsigned long irq, |
| 315 | unsigned long irq_err, |
| 316 | int tclk) |
| 317 | { |
| 318 | fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, |
| 319 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 320 | ge_complete(&orion_ge01_shared_data, tclk, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 321 | orion_ge01_resources, irq, &orion_ge01_shared, |
| 322 | eth_data, &orion_ge01); |
| 323 | } |
| 324 | |
| 325 | /***************************************************************************** |
| 326 | * GE10 |
| 327 | ****************************************************************************/ |
| 328 | struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = { |
| 329 | .shared_smi = &orion_ge00_shared, |
| 330 | }; |
| 331 | |
| 332 | static struct resource orion_ge10_shared_resources[] = { |
| 333 | { |
| 334 | .name = "ge10 base", |
| 335 | }, { |
| 336 | .name = "ge10 err irq", |
| 337 | }, |
| 338 | }; |
| 339 | |
| 340 | static struct platform_device orion_ge10_shared = { |
| 341 | .name = MV643XX_ETH_SHARED_NAME, |
| 342 | .id = 1, |
| 343 | .dev = { |
| 344 | .platform_data = &orion_ge10_shared_data, |
| 345 | }, |
| 346 | }; |
| 347 | |
| 348 | static struct resource orion_ge10_resources[] = { |
| 349 | { |
| 350 | .name = "ge10 irq", |
| 351 | .flags = IORESOURCE_IRQ, |
| 352 | }, |
| 353 | }; |
| 354 | |
| 355 | static struct platform_device orion_ge10 = { |
| 356 | .name = MV643XX_ETH_NAME, |
| 357 | .id = 1, |
| 358 | .num_resources = 2, |
| 359 | .resource = orion_ge10_resources, |
| 360 | .dev = { |
| 361 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 362 | }, |
| 363 | }; |
| 364 | |
| 365 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 366 | unsigned long mapbase, |
| 367 | unsigned long irq, |
| 368 | unsigned long irq_err, |
| 369 | int tclk) |
| 370 | { |
| 371 | fill_resources(&orion_ge10_shared, orion_ge10_shared_resources, |
| 372 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 373 | ge_complete(&orion_ge10_shared_data, tclk, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 374 | orion_ge10_resources, irq, &orion_ge10_shared, |
| 375 | eth_data, &orion_ge10); |
| 376 | } |
| 377 | |
| 378 | /***************************************************************************** |
| 379 | * GE11 |
| 380 | ****************************************************************************/ |
| 381 | struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = { |
| 382 | .shared_smi = &orion_ge00_shared, |
| 383 | }; |
| 384 | |
| 385 | static struct resource orion_ge11_shared_resources[] = { |
| 386 | { |
| 387 | .name = "ge11 base", |
| 388 | }, { |
| 389 | .name = "ge11 err irq", |
| 390 | }, |
| 391 | }; |
| 392 | |
| 393 | static struct platform_device orion_ge11_shared = { |
| 394 | .name = MV643XX_ETH_SHARED_NAME, |
| 395 | .id = 1, |
| 396 | .dev = { |
| 397 | .platform_data = &orion_ge11_shared_data, |
| 398 | }, |
| 399 | }; |
| 400 | |
| 401 | static struct resource orion_ge11_resources[] = { |
| 402 | { |
| 403 | .name = "ge11 irq", |
| 404 | .flags = IORESOURCE_IRQ, |
| 405 | }, |
| 406 | }; |
| 407 | |
| 408 | static struct platform_device orion_ge11 = { |
| 409 | .name = MV643XX_ETH_NAME, |
| 410 | .id = 1, |
| 411 | .num_resources = 2, |
| 412 | .resource = orion_ge11_resources, |
| 413 | .dev = { |
| 414 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 415 | }, |
| 416 | }; |
| 417 | |
| 418 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 419 | unsigned long mapbase, |
| 420 | unsigned long irq, |
| 421 | unsigned long irq_err, |
| 422 | int tclk) |
| 423 | { |
| 424 | fill_resources(&orion_ge11_shared, orion_ge11_shared_resources, |
| 425 | mapbase + 0x2000, SZ_16K - 1, irq_err); |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 426 | ge_complete(&orion_ge11_shared_data, tclk, |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 427 | orion_ge11_resources, irq, &orion_ge11_shared, |
| 428 | eth_data, &orion_ge11); |
| 429 | } |
| 430 | |
| 431 | /***************************************************************************** |
| 432 | * Ethernet switch |
| 433 | ****************************************************************************/ |
| 434 | static struct resource orion_switch_resources[] = { |
| 435 | { |
| 436 | .start = 0, |
| 437 | .end = 0, |
| 438 | .flags = IORESOURCE_IRQ, |
| 439 | }, |
| 440 | }; |
| 441 | |
| 442 | static struct platform_device orion_switch_device = { |
| 443 | .name = "dsa", |
| 444 | .id = 0, |
| 445 | .num_resources = 0, |
| 446 | .resource = orion_switch_resources, |
| 447 | }; |
| 448 | |
| 449 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq) |
| 450 | { |
| 451 | int i; |
| 452 | |
| 453 | if (irq != NO_IRQ) { |
| 454 | orion_switch_resources[0].start = irq; |
| 455 | orion_switch_resources[0].end = irq; |
| 456 | orion_switch_device.num_resources = 1; |
| 457 | } |
| 458 | |
| 459 | d->netdev = &orion_ge00.dev; |
| 460 | for (i = 0; i < d->nr_chips; i++) |
| 461 | d->chip[i].mii_bus = &orion_ge00_shared.dev; |
| 462 | orion_switch_device.dev.platform_data = d; |
| 463 | |
| 464 | platform_device_register(&orion_switch_device); |
| 465 | } |
Andrew Lunn | aac7ffa | 2011-05-15 13:32:45 +0200 | [diff] [blame] | 466 | |
| 467 | /***************************************************************************** |
| 468 | * I2C |
| 469 | ****************************************************************************/ |
| 470 | static struct mv64xxx_i2c_pdata orion_i2c_pdata = { |
| 471 | .freq_n = 3, |
| 472 | .timeout = 1000, /* Default timeout of 1 second */ |
| 473 | }; |
| 474 | |
| 475 | static struct resource orion_i2c_resources[2]; |
| 476 | |
| 477 | static struct platform_device orion_i2c = { |
| 478 | .name = MV64XXX_I2C_CTLR_NAME, |
| 479 | .id = 0, |
| 480 | .dev = { |
| 481 | .platform_data = &orion_i2c_pdata, |
| 482 | }, |
| 483 | }; |
| 484 | |
| 485 | static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = { |
| 486 | .freq_n = 3, |
| 487 | .timeout = 1000, /* Default timeout of 1 second */ |
| 488 | }; |
| 489 | |
| 490 | static struct resource orion_i2c_1_resources[2]; |
| 491 | |
| 492 | static struct platform_device orion_i2c_1 = { |
| 493 | .name = MV64XXX_I2C_CTLR_NAME, |
| 494 | .id = 1, |
| 495 | .dev = { |
| 496 | .platform_data = &orion_i2c_1_pdata, |
| 497 | }, |
| 498 | }; |
| 499 | |
| 500 | void __init orion_i2c_init(unsigned long mapbase, |
| 501 | unsigned long irq, |
| 502 | unsigned long freq_m) |
| 503 | { |
| 504 | orion_i2c_pdata.freq_m = freq_m; |
| 505 | fill_resources(&orion_i2c, orion_i2c_resources, mapbase, |
| 506 | SZ_32 - 1, irq); |
| 507 | platform_device_register(&orion_i2c); |
| 508 | } |
| 509 | |
| 510 | void __init orion_i2c_1_init(unsigned long mapbase, |
| 511 | unsigned long irq, |
| 512 | unsigned long freq_m) |
| 513 | { |
| 514 | orion_i2c_1_pdata.freq_m = freq_m; |
| 515 | fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase, |
| 516 | SZ_32 - 1, irq); |
| 517 | platform_device_register(&orion_i2c_1); |
| 518 | } |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 519 | |
| 520 | /***************************************************************************** |
| 521 | * SPI |
| 522 | ****************************************************************************/ |
| 523 | static struct orion_spi_info orion_spi_plat_data; |
| 524 | static struct resource orion_spi_resources; |
| 525 | |
| 526 | static struct platform_device orion_spi = { |
| 527 | .name = "orion_spi", |
| 528 | .id = 0, |
| 529 | .dev = { |
| 530 | .platform_data = &orion_spi_plat_data, |
| 531 | }, |
| 532 | }; |
| 533 | |
| 534 | static struct orion_spi_info orion_spi_1_plat_data; |
| 535 | static struct resource orion_spi_1_resources; |
| 536 | |
| 537 | static struct platform_device orion_spi_1 = { |
| 538 | .name = "orion_spi", |
| 539 | .id = 1, |
| 540 | .dev = { |
| 541 | .platform_data = &orion_spi_1_plat_data, |
| 542 | }, |
| 543 | }; |
| 544 | |
| 545 | /* Note: The SPI silicon core does have interrupts. However the |
| 546 | * current Linux software driver does not use interrupts. */ |
| 547 | |
| 548 | void __init orion_spi_init(unsigned long mapbase, |
| 549 | unsigned long tclk) |
| 550 | { |
| 551 | orion_spi_plat_data.tclk = tclk; |
| 552 | fill_resources(&orion_spi, &orion_spi_resources, |
| 553 | mapbase, SZ_512 - 1, NO_IRQ); |
| 554 | platform_device_register(&orion_spi); |
| 555 | } |
| 556 | |
| 557 | void __init orion_spi_1_init(unsigned long mapbase, |
| 558 | unsigned long tclk) |
| 559 | { |
| 560 | orion_spi_1_plat_data.tclk = tclk; |
| 561 | fill_resources(&orion_spi_1, &orion_spi_1_resources, |
| 562 | mapbase, SZ_512 - 1, NO_IRQ); |
| 563 | platform_device_register(&orion_spi_1); |
| 564 | } |
Andrew Lunn | 5e00d37 | 2011-05-15 13:32:47 +0200 | [diff] [blame] | 565 | |
| 566 | /***************************************************************************** |
| 567 | * Watchdog |
| 568 | ****************************************************************************/ |
| 569 | static struct orion_wdt_platform_data orion_wdt_data; |
| 570 | |
| 571 | static struct platform_device orion_wdt_device = { |
| 572 | .name = "orion_wdt", |
| 573 | .id = -1, |
| 574 | .dev = { |
| 575 | .platform_data = &orion_wdt_data, |
| 576 | }, |
| 577 | .num_resources = 0, |
| 578 | }; |
| 579 | |
| 580 | void __init orion_wdt_init(unsigned long tclk) |
| 581 | { |
| 582 | orion_wdt_data.tclk = tclk; |
| 583 | platform_device_register(&orion_wdt_device); |
| 584 | } |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 585 | |
| 586 | /***************************************************************************** |
| 587 | * XOR |
| 588 | ****************************************************************************/ |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 589 | static u64 orion_xor_dmamask = DMA_BIT_MASK(32); |
| 590 | |
| 591 | void __init orion_xor_init_channels( |
| 592 | struct mv_xor_platform_data *orion_xor0_data, |
| 593 | struct platform_device *orion_xor0_channel, |
| 594 | struct mv_xor_platform_data *orion_xor1_data, |
| 595 | struct platform_device *orion_xor1_channel) |
| 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, orion_xor0_data->cap_mask); |
| 602 | dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask); |
| 603 | platform_device_register(orion_xor0_channel); |
| 604 | |
| 605 | dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask); |
| 606 | dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask); |
| 607 | dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask); |
| 608 | platform_device_register(orion_xor1_channel); |
| 609 | } |
| 610 | |
| 611 | /***************************************************************************** |
| 612 | * XOR0 |
| 613 | ****************************************************************************/ |
| 614 | static struct resource orion_xor0_shared_resources[] = { |
| 615 | { |
| 616 | .name = "xor 0 low", |
| 617 | .flags = IORESOURCE_MEM, |
| 618 | }, { |
| 619 | .name = "xor 0 high", |
| 620 | .flags = IORESOURCE_MEM, |
| 621 | }, |
| 622 | }; |
| 623 | |
| 624 | static struct platform_device orion_xor0_shared = { |
| 625 | .name = MV_XOR_SHARED_NAME, |
| 626 | .id = 0, |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 627 | .num_resources = ARRAY_SIZE(orion_xor0_shared_resources), |
| 628 | .resource = orion_xor0_shared_resources, |
| 629 | }; |
| 630 | |
| 631 | static struct resource orion_xor00_resources[] = { |
| 632 | [0] = { |
| 633 | .flags = IORESOURCE_IRQ, |
| 634 | }, |
| 635 | }; |
| 636 | |
| 637 | static struct mv_xor_platform_data orion_xor00_data = { |
| 638 | .shared = &orion_xor0_shared, |
| 639 | .hw_id = 0, |
| 640 | .pool_size = PAGE_SIZE, |
| 641 | }; |
| 642 | |
| 643 | static struct platform_device orion_xor00_channel = { |
| 644 | .name = MV_XOR_NAME, |
| 645 | .id = 0, |
| 646 | .num_resources = ARRAY_SIZE(orion_xor00_resources), |
| 647 | .resource = orion_xor00_resources, |
| 648 | .dev = { |
| 649 | .dma_mask = &orion_xor_dmamask, |
| 650 | .coherent_dma_mask = DMA_BIT_MASK(64), |
| 651 | .platform_data = &orion_xor00_data, |
| 652 | }, |
| 653 | }; |
| 654 | |
| 655 | static struct resource orion_xor01_resources[] = { |
| 656 | [0] = { |
| 657 | .flags = IORESOURCE_IRQ, |
| 658 | }, |
| 659 | }; |
| 660 | |
| 661 | static struct mv_xor_platform_data orion_xor01_data = { |
| 662 | .shared = &orion_xor0_shared, |
| 663 | .hw_id = 1, |
| 664 | .pool_size = PAGE_SIZE, |
| 665 | }; |
| 666 | |
| 667 | static struct platform_device orion_xor01_channel = { |
| 668 | .name = MV_XOR_NAME, |
| 669 | .id = 1, |
| 670 | .num_resources = ARRAY_SIZE(orion_xor01_resources), |
| 671 | .resource = orion_xor01_resources, |
| 672 | .dev = { |
| 673 | .dma_mask = &orion_xor_dmamask, |
| 674 | .coherent_dma_mask = DMA_BIT_MASK(64), |
| 675 | .platform_data = &orion_xor01_data, |
| 676 | }, |
| 677 | }; |
| 678 | |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 679 | void __init orion_xor0_init(unsigned long mapbase_low, |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 680 | unsigned long mapbase_high, |
| 681 | unsigned long irq_0, |
| 682 | unsigned long irq_1) |
| 683 | { |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 684 | orion_xor0_shared_resources[0].start = mapbase_low; |
| 685 | orion_xor0_shared_resources[0].end = mapbase_low + 0xff; |
| 686 | orion_xor0_shared_resources[1].start = mapbase_high; |
| 687 | orion_xor0_shared_resources[1].end = mapbase_high + 0xff; |
| 688 | |
| 689 | orion_xor00_resources[0].start = irq_0; |
| 690 | orion_xor00_resources[0].end = irq_0; |
| 691 | orion_xor01_resources[0].start = irq_1; |
| 692 | orion_xor01_resources[0].end = irq_1; |
| 693 | |
| 694 | platform_device_register(&orion_xor0_shared); |
| 695 | |
| 696 | orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel, |
| 697 | &orion_xor01_data, &orion_xor01_channel); |
| 698 | } |
| 699 | |
| 700 | /***************************************************************************** |
| 701 | * XOR1 |
| 702 | ****************************************************************************/ |
| 703 | static struct resource orion_xor1_shared_resources[] = { |
| 704 | { |
| 705 | .name = "xor 1 low", |
| 706 | .flags = IORESOURCE_MEM, |
| 707 | }, { |
| 708 | .name = "xor 1 high", |
| 709 | .flags = IORESOURCE_MEM, |
| 710 | }, |
| 711 | }; |
| 712 | |
| 713 | static struct platform_device orion_xor1_shared = { |
| 714 | .name = MV_XOR_SHARED_NAME, |
| 715 | .id = 1, |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 716 | .num_resources = ARRAY_SIZE(orion_xor1_shared_resources), |
| 717 | .resource = orion_xor1_shared_resources, |
| 718 | }; |
| 719 | |
| 720 | static struct resource orion_xor10_resources[] = { |
| 721 | [0] = { |
| 722 | .flags = IORESOURCE_IRQ, |
| 723 | }, |
| 724 | }; |
| 725 | |
| 726 | static struct mv_xor_platform_data orion_xor10_data = { |
| 727 | .shared = &orion_xor1_shared, |
| 728 | .hw_id = 0, |
| 729 | .pool_size = PAGE_SIZE, |
| 730 | }; |
| 731 | |
| 732 | static struct platform_device orion_xor10_channel = { |
| 733 | .name = MV_XOR_NAME, |
| 734 | .id = 2, |
| 735 | .num_resources = ARRAY_SIZE(orion_xor10_resources), |
| 736 | .resource = orion_xor10_resources, |
| 737 | .dev = { |
| 738 | .dma_mask = &orion_xor_dmamask, |
| 739 | .coherent_dma_mask = DMA_BIT_MASK(64), |
| 740 | .platform_data = &orion_xor10_data, |
| 741 | }, |
| 742 | }; |
| 743 | |
| 744 | static struct resource orion_xor11_resources[] = { |
| 745 | [0] = { |
| 746 | .flags = IORESOURCE_IRQ, |
| 747 | }, |
| 748 | }; |
| 749 | |
| 750 | static struct mv_xor_platform_data orion_xor11_data = { |
| 751 | .shared = &orion_xor1_shared, |
| 752 | .hw_id = 1, |
| 753 | .pool_size = PAGE_SIZE, |
| 754 | }; |
| 755 | |
| 756 | static struct platform_device orion_xor11_channel = { |
| 757 | .name = MV_XOR_NAME, |
| 758 | .id = 3, |
| 759 | .num_resources = ARRAY_SIZE(orion_xor11_resources), |
| 760 | .resource = orion_xor11_resources, |
| 761 | .dev = { |
| 762 | .dma_mask = &orion_xor_dmamask, |
| 763 | .coherent_dma_mask = DMA_BIT_MASK(64), |
| 764 | .platform_data = &orion_xor11_data, |
| 765 | }, |
| 766 | }; |
| 767 | |
| 768 | void __init orion_xor1_init(unsigned long mapbase_low, |
| 769 | unsigned long mapbase_high, |
| 770 | unsigned long irq_0, |
| 771 | unsigned long irq_1) |
| 772 | { |
| 773 | orion_xor1_shared_resources[0].start = mapbase_low; |
| 774 | orion_xor1_shared_resources[0].end = mapbase_low + 0xff; |
| 775 | orion_xor1_shared_resources[1].start = mapbase_high; |
| 776 | orion_xor1_shared_resources[1].end = mapbase_high + 0xff; |
| 777 | |
| 778 | orion_xor10_resources[0].start = irq_0; |
| 779 | orion_xor10_resources[0].end = irq_0; |
| 780 | orion_xor11_resources[0].start = irq_1; |
| 781 | orion_xor11_resources[0].end = irq_1; |
| 782 | |
| 783 | platform_device_register(&orion_xor1_shared); |
| 784 | |
| 785 | orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel, |
| 786 | &orion_xor11_data, &orion_xor11_channel); |
| 787 | } |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 788 | |
| 789 | /***************************************************************************** |
| 790 | * EHCI |
| 791 | ****************************************************************************/ |
| 792 | static struct orion_ehci_data orion_ehci_data = { |
| 793 | .phy_version = EHCI_PHY_NA, |
| 794 | }; |
| 795 | |
| 796 | static u64 ehci_dmamask = DMA_BIT_MASK(32); |
| 797 | |
| 798 | |
| 799 | /***************************************************************************** |
| 800 | * EHCI0 |
| 801 | ****************************************************************************/ |
| 802 | static struct resource orion_ehci_resources[2]; |
| 803 | |
| 804 | static struct platform_device orion_ehci = { |
| 805 | .name = "orion-ehci", |
| 806 | .id = 0, |
| 807 | .dev = { |
| 808 | .dma_mask = &ehci_dmamask, |
| 809 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 810 | .platform_data = &orion_ehci_data, |
| 811 | }, |
| 812 | }; |
| 813 | |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 814 | void __init orion_ehci_init(unsigned long mapbase, |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 815 | unsigned long irq) |
| 816 | { |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 817 | fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1, |
| 818 | irq); |
| 819 | |
| 820 | platform_device_register(&orion_ehci); |
| 821 | } |
| 822 | |
| 823 | /***************************************************************************** |
| 824 | * EHCI1 |
| 825 | ****************************************************************************/ |
| 826 | static struct resource orion_ehci_1_resources[2]; |
| 827 | |
| 828 | static struct platform_device orion_ehci_1 = { |
| 829 | .name = "orion-ehci", |
| 830 | .id = 1, |
| 831 | .dev = { |
| 832 | .dma_mask = &ehci_dmamask, |
| 833 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 834 | .platform_data = &orion_ehci_data, |
| 835 | }, |
| 836 | }; |
| 837 | |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 838 | void __init orion_ehci_1_init(unsigned long mapbase, |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 839 | unsigned long irq) |
| 840 | { |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 841 | fill_resources(&orion_ehci_1, orion_ehci_1_resources, |
| 842 | mapbase, SZ_4K - 1, irq); |
| 843 | |
| 844 | platform_device_register(&orion_ehci_1); |
| 845 | } |
| 846 | |
| 847 | /***************************************************************************** |
| 848 | * EHCI2 |
| 849 | ****************************************************************************/ |
| 850 | static struct resource orion_ehci_2_resources[2]; |
| 851 | |
| 852 | static struct platform_device orion_ehci_2 = { |
| 853 | .name = "orion-ehci", |
| 854 | .id = 2, |
| 855 | .dev = { |
| 856 | .dma_mask = &ehci_dmamask, |
| 857 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 858 | .platform_data = &orion_ehci_data, |
| 859 | }, |
| 860 | }; |
| 861 | |
Andrew Lunn | db33f4d | 2011-12-07 21:48:08 +0100 | [diff] [blame] | 862 | void __init orion_ehci_2_init(unsigned long mapbase, |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 863 | unsigned long irq) |
| 864 | { |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 865 | fill_resources(&orion_ehci_2, orion_ehci_2_resources, |
| 866 | mapbase, SZ_4K - 1, irq); |
| 867 | |
| 868 | platform_device_register(&orion_ehci_2); |
| 869 | } |
Andrew Lunn | 9e613f8 | 2011-05-15 13:32:50 +0200 | [diff] [blame] | 870 | |
| 871 | /***************************************************************************** |
| 872 | * SATA |
| 873 | ****************************************************************************/ |
| 874 | static struct resource orion_sata_resources[2] = { |
| 875 | { |
| 876 | .name = "sata base", |
| 877 | }, { |
| 878 | .name = "sata irq", |
| 879 | }, |
| 880 | }; |
| 881 | |
| 882 | static struct platform_device orion_sata = { |
| 883 | .name = "sata_mv", |
| 884 | .id = 0, |
| 885 | .dev = { |
| 886 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 887 | }, |
| 888 | }; |
| 889 | |
| 890 | void __init orion_sata_init(struct mv_sata_platform_data *sata_data, |
Andrew Lunn | 9e613f8 | 2011-05-15 13:32:50 +0200 | [diff] [blame] | 891 | unsigned long mapbase, |
| 892 | unsigned long irq) |
| 893 | { |
Andrew Lunn | 9e613f8 | 2011-05-15 13:32:50 +0200 | [diff] [blame] | 894 | orion_sata.dev.platform_data = sata_data; |
| 895 | fill_resources(&orion_sata, orion_sata_resources, |
| 896 | mapbase, 0x5000 - 1, irq); |
| 897 | |
| 898 | platform_device_register(&orion_sata); |
| 899 | } |
| 900 | |
Andrew Lunn | 4435006 | 2011-05-15 13:32:51 +0200 | [diff] [blame] | 901 | /***************************************************************************** |
| 902 | * Cryptographic Engines and Security Accelerator (CESA) |
| 903 | ****************************************************************************/ |
| 904 | static struct resource orion_crypto_resources[] = { |
| 905 | { |
| 906 | .name = "regs", |
| 907 | }, { |
| 908 | .name = "crypto interrupt", |
| 909 | }, { |
| 910 | .name = "sram", |
| 911 | .flags = IORESOURCE_MEM, |
| 912 | }, |
| 913 | }; |
Andrew Lunn | 9e613f8 | 2011-05-15 13:32:50 +0200 | [diff] [blame] | 914 | |
Andrew Lunn | 4435006 | 2011-05-15 13:32:51 +0200 | [diff] [blame] | 915 | static struct platform_device orion_crypto = { |
| 916 | .name = "mv_crypto", |
| 917 | .id = -1, |
| 918 | }; |
| 919 | |
| 920 | void __init orion_crypto_init(unsigned long mapbase, |
| 921 | unsigned long srambase, |
| 922 | unsigned long sram_size, |
| 923 | unsigned long irq) |
| 924 | { |
| 925 | fill_resources(&orion_crypto, orion_crypto_resources, |
| 926 | mapbase, 0xffff, irq); |
| 927 | orion_crypto.num_resources = 3; |
| 928 | orion_crypto_resources[2].start = srambase; |
| 929 | orion_crypto_resources[2].end = srambase + sram_size - 1; |
| 930 | |
| 931 | platform_device_register(&orion_crypto); |
| 932 | } |