platform.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * platform.c: platform support for PNX833X.
  3. *
  4. * Copyright 2008 NXP Semiconductors
  5. * Chris Steel <chris.steel@nxp.com>
  6. * Daniel Laird <daniel.j.laird@nxp.com>
  7. *
  8. * Based on software written by:
  9. * Nikita Youshchenko <yoush@debian.org>, based on PNX8550 code.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <linux/device.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/kernel.h>
  29. #include <linux/init.h>
  30. #include <linux/resource.h>
  31. #include <linux/serial.h>
  32. #include <linux/serial_pnx8xxx.h>
  33. #include <linux/mtd/rawnand.h>
  34. #include <linux/mtd/partitions.h>
  35. #include <irq.h>
  36. #include <irq-mapping.h>
  37. #include <pnx833x.h>
  38. static u64 uart_dmamask = DMA_BIT_MASK(32);
  39. static struct resource pnx833x_uart_resources[] = {
  40. [0] = {
  41. .start = PNX833X_UART0_PORTS_START,
  42. .end = PNX833X_UART0_PORTS_END,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. [1] = {
  46. .start = PNX833X_PIC_UART0_INT,
  47. .end = PNX833X_PIC_UART0_INT,
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. [2] = {
  51. .start = PNX833X_UART1_PORTS_START,
  52. .end = PNX833X_UART1_PORTS_END,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. [3] = {
  56. .start = PNX833X_PIC_UART1_INT,
  57. .end = PNX833X_PIC_UART1_INT,
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. };
  61. struct pnx8xxx_port pnx8xxx_ports[] = {
  62. [0] = {
  63. .port = {
  64. .type = PORT_PNX8XXX,
  65. .iotype = UPIO_MEM,
  66. .membase = (void __iomem *)PNX833X_UART0_PORTS_START,
  67. .mapbase = PNX833X_UART0_PORTS_START,
  68. .irq = PNX833X_PIC_UART0_INT,
  69. .uartclk = 3692300,
  70. .fifosize = 16,
  71. .flags = UPF_BOOT_AUTOCONF,
  72. .line = 0,
  73. },
  74. },
  75. [1] = {
  76. .port = {
  77. .type = PORT_PNX8XXX,
  78. .iotype = UPIO_MEM,
  79. .membase = (void __iomem *)PNX833X_UART1_PORTS_START,
  80. .mapbase = PNX833X_UART1_PORTS_START,
  81. .irq = PNX833X_PIC_UART1_INT,
  82. .uartclk = 3692300,
  83. .fifosize = 16,
  84. .flags = UPF_BOOT_AUTOCONF,
  85. .line = 1,
  86. },
  87. },
  88. };
  89. static struct platform_device pnx833x_uart_device = {
  90. .name = "pnx8xxx-uart",
  91. .id = -1,
  92. .dev = {
  93. .dma_mask = &uart_dmamask,
  94. .coherent_dma_mask = DMA_BIT_MASK(32),
  95. .platform_data = pnx8xxx_ports,
  96. },
  97. .num_resources = ARRAY_SIZE(pnx833x_uart_resources),
  98. .resource = pnx833x_uart_resources,
  99. };
  100. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  101. static struct resource pnx833x_usb_ehci_resources[] = {
  102. [0] = {
  103. .start = PNX833X_USB_PORTS_START,
  104. .end = PNX833X_USB_PORTS_END,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. [1] = {
  108. .start = PNX833X_PIC_USB_INT,
  109. .end = PNX833X_PIC_USB_INT,
  110. .flags = IORESOURCE_IRQ,
  111. },
  112. };
  113. static struct platform_device pnx833x_usb_ehci_device = {
  114. .name = "pnx833x-ehci",
  115. .id = -1,
  116. .dev = {
  117. .dma_mask = &ehci_dmamask,
  118. .coherent_dma_mask = DMA_BIT_MASK(32),
  119. },
  120. .num_resources = ARRAY_SIZE(pnx833x_usb_ehci_resources),
  121. .resource = pnx833x_usb_ehci_resources,
  122. };
  123. static u64 ethernet_dmamask = DMA_BIT_MASK(32);
  124. static struct resource pnx833x_ethernet_resources[] = {
  125. [0] = {
  126. .start = PNX8335_IP3902_PORTS_START,
  127. .end = PNX8335_IP3902_PORTS_END,
  128. .flags = IORESOURCE_MEM,
  129. },
  130. #ifdef CONFIG_SOC_PNX8335
  131. [1] = {
  132. .start = PNX8335_PIC_ETHERNET_INT,
  133. .end = PNX8335_PIC_ETHERNET_INT,
  134. .flags = IORESOURCE_IRQ,
  135. },
  136. #endif
  137. };
  138. static struct platform_device pnx833x_ethernet_device = {
  139. .name = "ip3902-eth",
  140. .id = -1,
  141. .dev = {
  142. .dma_mask = &ethernet_dmamask,
  143. .coherent_dma_mask = DMA_BIT_MASK(32),
  144. },
  145. .num_resources = ARRAY_SIZE(pnx833x_ethernet_resources),
  146. .resource = pnx833x_ethernet_resources,
  147. };
  148. static struct resource pnx833x_sata_resources[] = {
  149. [0] = {
  150. .start = PNX8335_SATA_PORTS_START,
  151. .end = PNX8335_SATA_PORTS_END,
  152. .flags = IORESOURCE_MEM,
  153. },
  154. [1] = {
  155. .start = PNX8335_PIC_SATA_INT,
  156. .end = PNX8335_PIC_SATA_INT,
  157. .flags = IORESOURCE_IRQ,
  158. },
  159. };
  160. static struct platform_device pnx833x_sata_device = {
  161. .name = "pnx833x-sata",
  162. .id = -1,
  163. .num_resources = ARRAY_SIZE(pnx833x_sata_resources),
  164. .resource = pnx833x_sata_resources,
  165. };
  166. static void
  167. pnx833x_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  168. {
  169. struct nand_chip *this = mtd_to_nand(mtd);
  170. unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
  171. if (cmd == NAND_CMD_NONE)
  172. return;
  173. if (ctrl & NAND_CLE)
  174. writeb(cmd, (void __iomem *)(nandaddr + PNX8335_NAND_CLE_MASK));
  175. else
  176. writeb(cmd, (void __iomem *)(nandaddr + PNX8335_NAND_ALE_MASK));
  177. }
  178. static struct platform_nand_data pnx833x_flash_nand_data = {
  179. .chip = {
  180. .nr_chips = 1,
  181. .chip_delay = 25,
  182. },
  183. .ctrl = {
  184. .cmd_ctrl = pnx833x_flash_nand_cmd_ctrl
  185. }
  186. };
  187. /*
  188. * Set start to be the correct address (PNX8335_NAND_BASE with no 0xb!!),
  189. * 12 bytes more seems to be the standard that allows for NAND access.
  190. */
  191. static struct resource pnx833x_flash_nand_resource = {
  192. .start = PNX8335_NAND_BASE,
  193. .end = PNX8335_NAND_BASE + 12,
  194. .flags = IORESOURCE_MEM,
  195. };
  196. static struct platform_device pnx833x_flash_nand = {
  197. .name = "gen_nand",
  198. .id = -1,
  199. .num_resources = 1,
  200. .resource = &pnx833x_flash_nand_resource,
  201. .dev = {
  202. .platform_data = &pnx833x_flash_nand_data,
  203. },
  204. };
  205. static struct platform_device *pnx833x_platform_devices[] __initdata = {
  206. &pnx833x_uart_device,
  207. &pnx833x_usb_ehci_device,
  208. &pnx833x_ethernet_device,
  209. &pnx833x_sata_device,
  210. &pnx833x_flash_nand,
  211. };
  212. static int __init pnx833x_platform_init(void)
  213. {
  214. return platform_add_devices(pnx833x_platform_devices,
  215. ARRAY_SIZE(pnx833x_platform_devices));
  216. }
  217. arch_initcall(pnx833x_platform_init);