1 // SPDX-License-Identifier: GPL-2.0 2 #include <linux/module.h> 3 #include <linux/kernel.h> 4 #include <linux/init.h> 5 #include <linux/platform_device.h> 6 #include <linux/clkdev.h> 7 #include <linux/clk-provider.h> 8 #include <linux/dma-mapping.h> 9 #include <linux/dmaengine.h> 10 #include <linux/gpio-pxa.h> 11 #include <linux/platform_data/i2c-pxa.h> 12 #include <linux/soc/pxa/cpu.h> 13 14 #include <linux/platform_data/video-pxafb.h> 15 #include <linux/platform_data/mmc-pxamci.h> 16 #include "irqs.h" 17 #include <linux/platform_data/usb-ohci-pxa27x.h> 18 #include <linux/platform_data/mmp_dma.h> 19 20 #include "mfp-pxa2xx.h" 21 #include "regs-ost.h" 22 #include "reset.h" 23 #include "devices.h" 24 #include "generic.h" 25 26 void __init pxa_register_device(struct platform_device *dev, void *data) 27 { 28 int ret; 29 30 dev->dev.platform_data = data; 31 32 ret = platform_device_register(dev); 33 if (ret) 34 dev_err(&dev->dev, "unable to register device: %d\n", ret); 35 } 36 37 static struct resource pxa_resource_pmu = { 38 .start = IRQ_PMU, 39 .end = IRQ_PMU, 40 .flags = IORESOURCE_IRQ, 41 }; 42 43 struct platform_device pxa_device_pmu = { 44 .name = "xscale-pmu", 45 .id = -1, 46 .resource = &pxa_resource_pmu, 47 .num_resources = 1, 48 }; 49 50 static const struct resource pxamci_resources[] = { 51 [0] = { 52 .start = 0x41100000, 53 .end = 0x41100fff, 54 .flags = IORESOURCE_MEM, 55 }, 56 [1] = { 57 .start = IRQ_MMC, 58 .end = IRQ_MMC, 59 .flags = IORESOURCE_IRQ, 60 }, 61 }; 62 63 void __init pxa_set_mci_info(const struct pxamci_platform_data *info, 64 const struct property_entry *props) 65 { 66 const struct platform_device_info mci_info = { 67 .name = "pxa2xx-mci", 68 .id = 0, 69 .res = pxamci_resources, 70 .num_res = ARRAY_SIZE(pxamci_resources), 71 .data = info, 72 .size_data = sizeof(*info), 73 .dma_mask = 0xffffffffUL, 74 .properties = props, 75 }; 76 struct platform_device *mci_dev; 77 int err; 78 79 mci_dev = platform_device_register_full(&mci_info); 80 err = PTR_ERR_OR_ZERO(mci_dev); 81 if (err) 82 pr_err("Unable to create mci device: %d\n", err); 83 } 84 85 static struct resource pxa2xx_udc_resources[] = { 86 [0] = { 87 .start = 0x40600000, 88 .end = 0x4060ffff, 89 .flags = IORESOURCE_MEM, 90 }, 91 [1] = { 92 .start = IRQ_USB, 93 .end = IRQ_USB, 94 .flags = IORESOURCE_IRQ, 95 }, 96 }; 97 98 static u64 udc_dma_mask = ~(u32)0; 99 100 struct platform_device pxa25x_device_udc = { 101 .name = "pxa25x-udc", 102 .id = -1, 103 .resource = pxa2xx_udc_resources, 104 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), 105 .dev = { 106 .dma_mask = &udc_dma_mask, 107 } 108 }; 109 110 struct platform_device pxa27x_device_udc = { 111 .name = "pxa27x-udc", 112 .id = -1, 113 .resource = pxa2xx_udc_resources, 114 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), 115 .dev = { 116 .dma_mask = &udc_dma_mask, 117 } 118 }; 119 120 static struct resource pxafb_resources[] = { 121 [0] = { 122 .start = 0x44000000, 123 .end = 0x4400ffff, 124 .flags = IORESOURCE_MEM, 125 }, 126 [1] = { 127 .start = IRQ_LCD, 128 .end = IRQ_LCD, 129 .flags = IORESOURCE_IRQ, 130 }, 131 }; 132 133 static u64 fb_dma_mask = ~(u64)0; 134 135 struct platform_device pxa_device_fb = { 136 .name = "pxa2xx-fb", 137 .id = -1, 138 .dev = { 139 .dma_mask = &fb_dma_mask, 140 .coherent_dma_mask = 0xffffffff, 141 }, 142 .num_resources = ARRAY_SIZE(pxafb_resources), 143 .resource = pxafb_resources, 144 }; 145 146 void __init pxa_set_fb_info(struct device *parent, struct pxafb_mach_info *info) 147 { 148 pxa_device_fb.dev.parent = parent; 149 pxa_register_device(&pxa_device_fb, info); 150 } 151 152 static struct resource pxa_resource_ffuart[] = { 153 { 154 .start = 0x40100000, 155 .end = 0x40100023, 156 .flags = IORESOURCE_MEM, 157 }, { 158 .start = IRQ_FFUART, 159 .end = IRQ_FFUART, 160 .flags = IORESOURCE_IRQ, 161 } 162 }; 163 164 struct platform_device pxa_device_ffuart = { 165 .name = "pxa2xx-uart", 166 .id = 0, 167 .resource = pxa_resource_ffuart, 168 .num_resources = ARRAY_SIZE(pxa_resource_ffuart), 169 }; 170 171 void __init pxa_set_ffuart_info(void *info) 172 { 173 pxa_register_device(&pxa_device_ffuart, info); 174 } 175 176 static struct resource pxa_resource_btuart[] = { 177 { 178 .start = 0x40200000, 179 .end = 0x40200023, 180 .flags = IORESOURCE_MEM, 181 }, { 182 .start = IRQ_BTUART, 183 .end = IRQ_BTUART, 184 .flags = IORESOURCE_IRQ, 185 } 186 }; 187 188 struct platform_device pxa_device_btuart = { 189 .name = "pxa2xx-uart", 190 .id = 1, 191 .resource = pxa_resource_btuart, 192 .num_resources = ARRAY_SIZE(pxa_resource_btuart), 193 }; 194 195 void __init pxa_set_btuart_info(void *info) 196 { 197 pxa_register_device(&pxa_device_btuart, info); 198 } 199 200 static struct resource pxa_resource_stuart[] = { 201 { 202 .start = 0x40700000, 203 .end = 0x40700023, 204 .flags = IORESOURCE_MEM, 205 }, { 206 .start = IRQ_STUART, 207 .end = IRQ_STUART, 208 .flags = IORESOURCE_IRQ, 209 } 210 }; 211 212 struct platform_device pxa_device_stuart = { 213 .name = "pxa2xx-uart", 214 .id = 2, 215 .resource = pxa_resource_stuart, 216 .num_resources = ARRAY_SIZE(pxa_resource_stuart), 217 }; 218 219 void __init pxa_set_stuart_info(void *info) 220 { 221 pxa_register_device(&pxa_device_stuart, info); 222 } 223 224 static struct resource pxa_resource_hwuart[] = { 225 { 226 .start = 0x41600000, 227 .end = 0x4160002F, 228 .flags = IORESOURCE_MEM, 229 }, { 230 .start = IRQ_HWUART, 231 .end = IRQ_HWUART, 232 .flags = IORESOURCE_IRQ, 233 } 234 }; 235 236 struct platform_device pxa_device_hwuart = { 237 .name = "pxa2xx-uart", 238 .id = 3, 239 .resource = pxa_resource_hwuart, 240 .num_resources = ARRAY_SIZE(pxa_resource_hwuart), 241 }; 242 243 void __init pxa_set_hwuart_info(void *info) 244 { 245 if (cpu_is_pxa255()) 246 pxa_register_device(&pxa_device_hwuart, info); 247 else 248 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware"); 249 } 250 251 static struct resource pxai2c_resources[] = { 252 { 253 .start = 0x40301680, 254 .end = 0x403016a3, 255 .flags = IORESOURCE_MEM, 256 }, { 257 .start = IRQ_I2C, 258 .end = IRQ_I2C, 259 .flags = IORESOURCE_IRQ, 260 }, 261 }; 262 263 struct platform_device pxa_device_i2c = { 264 .name = "pxa2xx-i2c", 265 .id = 0, 266 .resource = pxai2c_resources, 267 .num_resources = ARRAY_SIZE(pxai2c_resources), 268 }; 269 270 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info) 271 { 272 pxa_register_device(&pxa_device_i2c, info); 273 } 274 275 #ifdef CONFIG_PXA27x 276 static struct resource pxa27x_resources_i2c_power[] = { 277 { 278 .start = 0x40f00180, 279 .end = 0x40f001a3, 280 .flags = IORESOURCE_MEM, 281 }, { 282 .start = IRQ_PWRI2C, 283 .end = IRQ_PWRI2C, 284 .flags = IORESOURCE_IRQ, 285 }, 286 }; 287 288 struct platform_device pxa27x_device_i2c_power = { 289 .name = "pxa2xx-i2c", 290 .id = 1, 291 .resource = pxa27x_resources_i2c_power, 292 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power), 293 }; 294 #endif 295 296 static struct resource pxai2s_resources[] = { 297 { 298 .start = 0x40400000, 299 .end = 0x40400083, 300 .flags = IORESOURCE_MEM, 301 }, { 302 .start = IRQ_I2S, 303 .end = IRQ_I2S, 304 .flags = IORESOURCE_IRQ, 305 }, 306 }; 307 308 struct platform_device pxa_device_i2s = { 309 .name = "pxa2xx-i2s", 310 .id = -1, 311 .resource = pxai2s_resources, 312 .num_resources = ARRAY_SIZE(pxai2s_resources), 313 }; 314 315 struct platform_device pxa_device_asoc_ssp1 = { 316 .name = "pxa-ssp-dai", 317 .id = 0, 318 }; 319 320 struct platform_device pxa_device_asoc_ssp2= { 321 .name = "pxa-ssp-dai", 322 .id = 1, 323 }; 324 325 struct platform_device pxa_device_asoc_ssp3 = { 326 .name = "pxa-ssp-dai", 327 .id = 2, 328 }; 329 330 struct platform_device pxa_device_asoc_ssp4 = { 331 .name = "pxa-ssp-dai", 332 .id = 3, 333 }; 334 335 struct platform_device pxa_device_asoc_platform = { 336 .name = "pxa-pcm-audio", 337 .id = -1, 338 }; 339 340 static struct resource pxa_rtc_resources[] = { 341 [0] = { 342 .start = 0x40900000, 343 .end = 0x40900000 + 0x3b, 344 .flags = IORESOURCE_MEM, 345 }, 346 [1] = { 347 .start = IRQ_RTC1Hz, 348 .end = IRQ_RTC1Hz, 349 .name = "rtc 1Hz", 350 .flags = IORESOURCE_IRQ, 351 }, 352 [2] = { 353 .start = IRQ_RTCAlrm, 354 .end = IRQ_RTCAlrm, 355 .name = "rtc alarm", 356 .flags = IORESOURCE_IRQ, 357 }, 358 }; 359 360 struct platform_device pxa_device_rtc = { 361 .name = "pxa-rtc", 362 .id = -1, 363 .num_resources = ARRAY_SIZE(pxa_rtc_resources), 364 .resource = pxa_rtc_resources, 365 }; 366 367 struct platform_device sa1100_device_rtc = { 368 .name = "sa1100-rtc", 369 .id = -1, 370 .num_resources = ARRAY_SIZE(pxa_rtc_resources), 371 .resource = pxa_rtc_resources, 372 }; 373 374 #ifdef CONFIG_PXA25x 375 376 static struct resource pxa25x_resource_pwm0[] = { 377 [0] = { 378 .start = 0x40b00000, 379 .end = 0x40b0000f, 380 .flags = IORESOURCE_MEM, 381 }, 382 }; 383 384 struct platform_device pxa25x_device_pwm0 = { 385 .name = "pxa25x-pwm", 386 .id = 0, 387 .resource = pxa25x_resource_pwm0, 388 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0), 389 }; 390 391 static struct resource pxa25x_resource_pwm1[] = { 392 [0] = { 393 .start = 0x40c00000, 394 .end = 0x40c0000f, 395 .flags = IORESOURCE_MEM, 396 }, 397 }; 398 399 struct platform_device pxa25x_device_pwm1 = { 400 .name = "pxa25x-pwm", 401 .id = 1, 402 .resource = pxa25x_resource_pwm1, 403 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1), 404 }; 405 406 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32); 407 408 static struct resource pxa25x_resource_ssp[] = { 409 [0] = { 410 .start = 0x41000000, 411 .end = 0x4100001f, 412 .flags = IORESOURCE_MEM, 413 }, 414 [1] = { 415 .start = IRQ_SSP, 416 .end = IRQ_SSP, 417 .flags = IORESOURCE_IRQ, 418 }, 419 }; 420 421 struct platform_device pxa25x_device_ssp = { 422 .name = "pxa25x-ssp", 423 .id = 0, 424 .dev = { 425 .dma_mask = &pxa25x_ssp_dma_mask, 426 .coherent_dma_mask = DMA_BIT_MASK(32), 427 }, 428 .resource = pxa25x_resource_ssp, 429 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp), 430 }; 431 432 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32); 433 434 static struct resource pxa25x_resource_nssp[] = { 435 [0] = { 436 .start = 0x41400000, 437 .end = 0x4140002f, 438 .flags = IORESOURCE_MEM, 439 }, 440 [1] = { 441 .start = IRQ_NSSP, 442 .end = IRQ_NSSP, 443 .flags = IORESOURCE_IRQ, 444 }, 445 }; 446 447 struct platform_device pxa25x_device_nssp = { 448 .name = "pxa25x-nssp", 449 .id = 1, 450 .dev = { 451 .dma_mask = &pxa25x_nssp_dma_mask, 452 .coherent_dma_mask = DMA_BIT_MASK(32), 453 }, 454 .resource = pxa25x_resource_nssp, 455 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp), 456 }; 457 458 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32); 459 460 static struct resource pxa25x_resource_assp[] = { 461 [0] = { 462 .start = 0x41500000, 463 .end = 0x4150002f, 464 .flags = IORESOURCE_MEM, 465 }, 466 [1] = { 467 .start = IRQ_ASSP, 468 .end = IRQ_ASSP, 469 .flags = IORESOURCE_IRQ, 470 }, 471 }; 472 473 struct platform_device pxa25x_device_assp = { 474 /* ASSP is basically equivalent to NSSP */ 475 .name = "pxa25x-nssp", 476 .id = 2, 477 .dev = { 478 .dma_mask = &pxa25x_assp_dma_mask, 479 .coherent_dma_mask = DMA_BIT_MASK(32), 480 }, 481 .resource = pxa25x_resource_assp, 482 .num_resources = ARRAY_SIZE(pxa25x_resource_assp), 483 }; 484 #endif /* CONFIG_PXA25x */ 485 486 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 487 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32); 488 489 static struct resource pxa27x_resource_ohci[] = { 490 [0] = { 491 .start = 0x4C000000, 492 .end = 0x4C00ff6f, 493 .flags = IORESOURCE_MEM, 494 }, 495 [1] = { 496 .start = IRQ_USBH1, 497 .end = IRQ_USBH1, 498 .flags = IORESOURCE_IRQ, 499 }, 500 }; 501 502 struct platform_device pxa27x_device_ohci = { 503 .name = "pxa27x-ohci", 504 .id = -1, 505 .dev = { 506 .dma_mask = &pxa27x_ohci_dma_mask, 507 .coherent_dma_mask = DMA_BIT_MASK(32), 508 }, 509 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci), 510 .resource = pxa27x_resource_ohci, 511 }; 512 513 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info) 514 { 515 pxa_register_device(&pxa27x_device_ohci, info); 516 } 517 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */ 518 519 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 520 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32); 521 522 static struct resource pxa27x_resource_ssp1[] = { 523 [0] = { 524 .start = 0x41000000, 525 .end = 0x4100003f, 526 .flags = IORESOURCE_MEM, 527 }, 528 [1] = { 529 .start = IRQ_SSP, 530 .end = IRQ_SSP, 531 .flags = IORESOURCE_IRQ, 532 }, 533 }; 534 535 struct platform_device pxa27x_device_ssp1 = { 536 .name = "pxa27x-ssp", 537 .id = 0, 538 .dev = { 539 .dma_mask = &pxa27x_ssp1_dma_mask, 540 .coherent_dma_mask = DMA_BIT_MASK(32), 541 }, 542 .resource = pxa27x_resource_ssp1, 543 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1), 544 }; 545 546 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32); 547 548 static struct resource pxa27x_resource_ssp2[] = { 549 [0] = { 550 .start = 0x41700000, 551 .end = 0x4170003f, 552 .flags = IORESOURCE_MEM, 553 }, 554 [1] = { 555 .start = IRQ_SSP2, 556 .end = IRQ_SSP2, 557 .flags = IORESOURCE_IRQ, 558 }, 559 }; 560 561 struct platform_device pxa27x_device_ssp2 = { 562 .name = "pxa27x-ssp", 563 .id = 1, 564 .dev = { 565 .dma_mask = &pxa27x_ssp2_dma_mask, 566 .coherent_dma_mask = DMA_BIT_MASK(32), 567 }, 568 .resource = pxa27x_resource_ssp2, 569 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2), 570 }; 571 572 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32); 573 574 static struct resource pxa27x_resource_ssp3[] = { 575 [0] = { 576 .start = 0x41900000, 577 .end = 0x4190003f, 578 .flags = IORESOURCE_MEM, 579 }, 580 [1] = { 581 .start = IRQ_SSP3, 582 .end = IRQ_SSP3, 583 .flags = IORESOURCE_IRQ, 584 }, 585 }; 586 587 struct platform_device pxa27x_device_ssp3 = { 588 .name = "pxa27x-ssp", 589 .id = 2, 590 .dev = { 591 .dma_mask = &pxa27x_ssp3_dma_mask, 592 .coherent_dma_mask = DMA_BIT_MASK(32), 593 }, 594 .resource = pxa27x_resource_ssp3, 595 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3), 596 }; 597 598 static struct resource pxa27x_resource_pwm0[] = { 599 [0] = { 600 .start = 0x40b00000, 601 .end = 0x40b0001f, 602 .flags = IORESOURCE_MEM, 603 }, 604 }; 605 606 struct platform_device pxa27x_device_pwm0 = { 607 .name = "pxa27x-pwm", 608 .id = 0, 609 .resource = pxa27x_resource_pwm0, 610 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0), 611 }; 612 613 static struct resource pxa27x_resource_pwm1[] = { 614 [0] = { 615 .start = 0x40c00000, 616 .end = 0x40c0001f, 617 .flags = IORESOURCE_MEM, 618 }, 619 }; 620 621 struct platform_device pxa27x_device_pwm1 = { 622 .name = "pxa27x-pwm", 623 .id = 1, 624 .resource = pxa27x_resource_pwm1, 625 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1), 626 }; 627 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */ 628 629 #if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x) 630 const struct software_node pxa2xx_gpiochip_node = { 631 .name = "gpio-pxa", 632 }; 633 634 struct resource pxa_resource_gpio[] = { 635 { 636 .start = 0x40e00000, 637 .end = 0x40e0ffff, 638 .flags = IORESOURCE_MEM, 639 }, { 640 .start = IRQ_GPIO0, 641 .end = IRQ_GPIO0, 642 .name = "gpio0", 643 .flags = IORESOURCE_IRQ, 644 }, { 645 .start = IRQ_GPIO1, 646 .end = IRQ_GPIO1, 647 .name = "gpio1", 648 .flags = IORESOURCE_IRQ, 649 }, { 650 .start = IRQ_GPIO_2_x, 651 .end = IRQ_GPIO_2_x, 652 .name = "gpio_mux", 653 .flags = IORESOURCE_IRQ, 654 }, 655 }; 656 657 static struct pxa_gpio_platform_data pxa2xx_gpio_info = { 658 .irq_base = PXA_GPIO_TO_IRQ(0), 659 .gpio_set_wake = gpio_set_wake, 660 }; 661 662 struct platform_device pxa25x_device_gpio = { 663 .name = "pxa25x-gpio", 664 .id = -1, 665 .num_resources = ARRAY_SIZE(pxa_resource_gpio), 666 .resource = pxa_resource_gpio, 667 .dev = { 668 .platform_data = &pxa2xx_gpio_info, 669 }, 670 }; 671 672 struct platform_device pxa27x_device_gpio = { 673 .name = "pxa27x-gpio", 674 .id = -1, 675 .num_resources = ARRAY_SIZE(pxa_resource_gpio), 676 .resource = pxa_resource_gpio, 677 .dev = { 678 .platform_data = &pxa2xx_gpio_info, 679 }, 680 }; 681 #endif /* CONFIG_PXA25x || CONFIG_PXA27x */ 682 683 static struct resource pxa_dma_resource[] = { 684 [0] = { 685 .start = 0x40000000, 686 .end = 0x4000ffff, 687 .flags = IORESOURCE_MEM, 688 }, 689 [1] = { 690 .start = IRQ_DMA, 691 .end = IRQ_DMA, 692 .flags = IORESOURCE_IRQ, 693 }, 694 }; 695 696 static u64 pxadma_dmamask = 0xffffffffUL; 697 698 static struct platform_device pxa2xx_pxa_dma = { 699 .name = "pxa-dma", 700 .id = 0, 701 .dev = { 702 .dma_mask = &pxadma_dmamask, 703 .coherent_dma_mask = 0xffffffff, 704 }, 705 .num_resources = ARRAY_SIZE(pxa_dma_resource), 706 .resource = pxa_dma_resource, 707 }; 708 709 void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata) 710 { 711 pxa_register_device(&pxa2xx_pxa_dma, dma_pdata); 712 } 713 714 void __init pxa_register_wdt(unsigned int reset_status) 715 { 716 struct resource res = DEFINE_RES_MEM(OST_PHYS, OST_LEN); 717 718 reset_status &= RESET_STATUS_WATCHDOG; 719 platform_device_register_resndata(NULL, "sa1100_wdt", -1, &res, 1, 720 &reset_status, sizeof(reset_status)); 721 } 722