platform.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Platform device support for NXP PNX8550 SoCs
  3. *
  4. * Copyright 2005, Embedded Alley Solutions, Inc
  5. *
  6. * Based on arch/mips/au1000/common/platform.c
  7. * Platform device support for Au1x00 SoCs.
  8. *
  9. * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
  10. *
  11. * This file is licensed under the terms of the GNU General Public
  12. * License version 2. This program is licensed "as is" without any
  13. * warranty of any kind, whether express or implied.
  14. */
  15. #include <linux/device.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/resource.h>
  20. #include <linux/serial.h>
  21. #include <linux/serial_pnx8xxx.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/usb/ohci_pdriver.h>
  24. #include <int.h>
  25. #include <usb.h>
  26. #include <uart.h>
  27. static struct resource pnx8550_usb_ohci_resources[] = {
  28. [0] = {
  29. .start = PNX8550_USB_OHCI_OP_BASE,
  30. .end = PNX8550_USB_OHCI_OP_BASE +
  31. PNX8550_USB_OHCI_OP_LEN,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = {
  35. .start = PNX8550_INT_USB,
  36. .end = PNX8550_INT_USB,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. };
  40. static struct resource pnx8550_uart_resources[] = {
  41. [0] = {
  42. .start = PNX8550_UART_PORT0,
  43. .end = PNX8550_UART_PORT0 + 0xfff,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. [1] = {
  47. .start = PNX8550_UART_INT(0),
  48. .end = PNX8550_UART_INT(0),
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. [2] = {
  52. .start = PNX8550_UART_PORT1,
  53. .end = PNX8550_UART_PORT1 + 0xfff,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [3] = {
  57. .start = PNX8550_UART_INT(1),
  58. .end = PNX8550_UART_INT(1),
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. struct pnx8xxx_port pnx8xxx_ports[] = {
  63. [0] = {
  64. .port = {
  65. .type = PORT_PNX8XXX,
  66. .iotype = UPIO_MEM,
  67. .membase = (void __iomem *)PNX8550_UART_PORT0,
  68. .mapbase = PNX8550_UART_PORT0,
  69. .irq = PNX8550_UART_INT(0),
  70. .uartclk = 3692300,
  71. .fifosize = 16,
  72. .flags = UPF_BOOT_AUTOCONF,
  73. .line = 0,
  74. },
  75. },
  76. [1] = {
  77. .port = {
  78. .type = PORT_PNX8XXX,
  79. .iotype = UPIO_MEM,
  80. .membase = (void __iomem *)PNX8550_UART_PORT1,
  81. .mapbase = PNX8550_UART_PORT1,
  82. .irq = PNX8550_UART_INT(1),
  83. .uartclk = 3692300,
  84. .fifosize = 16,
  85. .flags = UPF_BOOT_AUTOCONF,
  86. .line = 1,
  87. },
  88. },
  89. };
  90. /* The dmamask must be set for OHCI to work */
  91. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  92. static u64 uart_dmamask = DMA_BIT_MASK(32);
  93. static int pnx8550_usb_ohci_power_on(struct platform_device *pdev)
  94. {
  95. /*
  96. * Set register CLK48CTL to enable and 48MHz
  97. */
  98. outl(0x00000003, PCI_BASE | 0x0004770c);
  99. /*
  100. * Set register CLK12CTL to enable and 48MHz
  101. */
  102. outl(0x00000003, PCI_BASE | 0x00047710);
  103. udelay(100);
  104. return 0;
  105. }
  106. static void pnx8550_usb_ohci_power_off(struct platform_device *pdev)
  107. {
  108. udelay(10);
  109. }
  110. static struct usb_ohci_pdata pnx8550_usb_ohci_pdata = {
  111. .power_on = pnx8550_usb_ohci_power_on,
  112. .power_off = pnx8550_usb_ohci_power_off,
  113. };
  114. static struct platform_device pnx8550_usb_ohci_device = {
  115. .name = "ohci-platform",
  116. .id = -1,
  117. .dev = {
  118. .dma_mask = &ohci_dmamask,
  119. .coherent_dma_mask = DMA_BIT_MASK(32),
  120. .platform_data = &pnx8550_usb_ohci_pdata,
  121. },
  122. .num_resources = ARRAY_SIZE(pnx8550_usb_ohci_resources),
  123. .resource = pnx8550_usb_ohci_resources,
  124. };
  125. static struct platform_device pnx8550_uart_device = {
  126. .name = "pnx8xxx-uart",
  127. .id = -1,
  128. .dev = {
  129. .dma_mask = &uart_dmamask,
  130. .coherent_dma_mask = DMA_BIT_MASK(32),
  131. .platform_data = pnx8xxx_ports,
  132. },
  133. .num_resources = ARRAY_SIZE(pnx8550_uart_resources),
  134. .resource = pnx8550_uart_resources,
  135. };
  136. static struct platform_device *pnx8550_platform_devices[] __initdata = {
  137. &pnx8550_usb_ohci_device,
  138. &pnx8550_uart_device,
  139. };
  140. static int __init pnx8550_platform_init(void)
  141. {
  142. return platform_add_devices(pnx8550_platform_devices,
  143. ARRAY_SIZE(pnx8550_platform_devices));
  144. }
  145. arch_initcall(pnx8550_platform_init);