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