platform.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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/nand.h>
  34. #include <linux/mtd/partitions.h>
  35. #ifdef CONFIG_I2C_PNX0105
  36. /* Until i2c driver available in kernel.*/
  37. #include <linux/i2c-pnx0105.h>
  38. #endif
  39. #include <irq.h>
  40. #include <irq-mapping.h>
  41. #include <pnx833x.h>
  42. static u64 uart_dmamask = DMA_BIT_MASK(32);
  43. static struct resource pnx833x_uart_resources[] = {
  44. [0] = {
  45. .start = PNX833X_UART0_PORTS_START,
  46. .end = PNX833X_UART0_PORTS_END,
  47. .flags = IORESOURCE_MEM,
  48. },
  49. [1] = {
  50. .start = PNX833X_PIC_UART0_INT,
  51. .end = PNX833X_PIC_UART0_INT,
  52. .flags = IORESOURCE_IRQ,
  53. },
  54. [2] = {
  55. .start = PNX833X_UART1_PORTS_START,
  56. .end = PNX833X_UART1_PORTS_END,
  57. .flags = IORESOURCE_MEM,
  58. },
  59. [3] = {
  60. .start = PNX833X_PIC_UART1_INT,
  61. .end = PNX833X_PIC_UART1_INT,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. };
  65. struct pnx8xxx_port pnx8xxx_ports[] = {
  66. [0] = {
  67. .port = {
  68. .type = PORT_PNX8XXX,
  69. .iotype = UPIO_MEM,
  70. .membase = (void __iomem *)PNX833X_UART0_PORTS_START,
  71. .mapbase = PNX833X_UART0_PORTS_START,
  72. .irq = PNX833X_PIC_UART0_INT,
  73. .uartclk = 3692300,
  74. .fifosize = 16,
  75. .flags = UPF_BOOT_AUTOCONF,
  76. .line = 0,
  77. },
  78. },
  79. [1] = {
  80. .port = {
  81. .type = PORT_PNX8XXX,
  82. .iotype = UPIO_MEM,
  83. .membase = (void __iomem *)PNX833X_UART1_PORTS_START,
  84. .mapbase = PNX833X_UART1_PORTS_START,
  85. .irq = PNX833X_PIC_UART1_INT,
  86. .uartclk = 3692300,
  87. .fifosize = 16,
  88. .flags = UPF_BOOT_AUTOCONF,
  89. .line = 1,
  90. },
  91. },
  92. };
  93. static struct platform_device pnx833x_uart_device = {
  94. .name = "pnx8xxx-uart",
  95. .id = -1,
  96. .dev = {
  97. .dma_mask = &uart_dmamask,
  98. .coherent_dma_mask = DMA_BIT_MASK(32),
  99. .platform_data = pnx8xxx_ports,
  100. },
  101. .num_resources = ARRAY_SIZE(pnx833x_uart_resources),
  102. .resource = pnx833x_uart_resources,
  103. };
  104. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  105. static struct resource pnx833x_usb_ehci_resources[] = {
  106. [0] = {
  107. .start = PNX833X_USB_PORTS_START,
  108. .end = PNX833X_USB_PORTS_END,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. [1] = {
  112. .start = PNX833X_PIC_USB_INT,
  113. .end = PNX833X_PIC_USB_INT,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device pnx833x_usb_ehci_device = {
  118. .name = "pnx833x-ehci",
  119. .id = -1,
  120. .dev = {
  121. .dma_mask = &ehci_dmamask,
  122. .coherent_dma_mask = DMA_BIT_MASK(32),
  123. },
  124. .num_resources = ARRAY_SIZE(pnx833x_usb_ehci_resources),
  125. .resource = pnx833x_usb_ehci_resources,
  126. };
  127. #ifdef CONFIG_I2C_PNX0105
  128. static struct resource pnx833x_i2c0_resources[] = {
  129. {
  130. .start = PNX833X_I2C0_PORTS_START,
  131. .end = PNX833X_I2C0_PORTS_END,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. {
  135. .start = PNX833X_PIC_I2C0_INT,
  136. .end = PNX833X_PIC_I2C0_INT,
  137. .flags = IORESOURCE_IRQ,
  138. },
  139. };
  140. static struct resource pnx833x_i2c1_resources[] = {
  141. {
  142. .start = PNX833X_I2C1_PORTS_START,
  143. .end = PNX833X_I2C1_PORTS_END,
  144. .flags = IORESOURCE_MEM,
  145. },
  146. {
  147. .start = PNX833X_PIC_I2C1_INT,
  148. .end = PNX833X_PIC_I2C1_INT,
  149. .flags = IORESOURCE_IRQ,
  150. },
  151. };
  152. static struct i2c_pnx0105_dev pnx833x_i2c_dev[] = {
  153. {
  154. .base = PNX833X_I2C0_PORTS_START,
  155. .irq = -1, /* should be PNX833X_PIC_I2C0_INT but polling is faster */
  156. .clock = 6, /* 0 == 400 kHz, 4 == 100 kHz(Maximum HDMI), 6 = 50kHz(Preferred HDCP) */
  157. .bus_addr = 0, /* no slave support */
  158. },
  159. {
  160. .base = PNX833X_I2C1_PORTS_START,
  161. .irq = -1, /* on high freq, polling is faster */
  162. /*.irq = PNX833X_PIC_I2C1_INT,*/
  163. .clock = 4, /* 0 == 400 kHz, 4 == 100 kHz. 100 kHz seems a safe default for now */
  164. .bus_addr = 0, /* no slave support */
  165. },
  166. };
  167. static struct platform_device pnx833x_i2c0_device = {
  168. .name = "i2c-pnx0105",
  169. .id = 0,
  170. .dev = {
  171. .platform_data = &pnx833x_i2c_dev[0],
  172. },
  173. .num_resources = ARRAY_SIZE(pnx833x_i2c0_resources),
  174. .resource = pnx833x_i2c0_resources,
  175. };
  176. static struct platform_device pnx833x_i2c1_device = {
  177. .name = "i2c-pnx0105",
  178. .id = 1,
  179. .dev = {
  180. .platform_data = &pnx833x_i2c_dev[1],
  181. },
  182. .num_resources = ARRAY_SIZE(pnx833x_i2c1_resources),
  183. .resource = pnx833x_i2c1_resources,
  184. };
  185. #endif
  186. static u64 ethernet_dmamask = DMA_BIT_MASK(32);
  187. static struct resource pnx833x_ethernet_resources[] = {
  188. [0] = {
  189. .start = PNX8335_IP3902_PORTS_START,
  190. .end = PNX8335_IP3902_PORTS_END,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. [1] = {
  194. .start = PNX8335_PIC_ETHERNET_INT,
  195. .end = PNX8335_PIC_ETHERNET_INT,
  196. .flags = IORESOURCE_IRQ,
  197. },
  198. };
  199. static struct platform_device pnx833x_ethernet_device = {
  200. .name = "ip3902-eth",
  201. .id = -1,
  202. .dev = {
  203. .dma_mask = &ethernet_dmamask,
  204. .coherent_dma_mask = DMA_BIT_MASK(32),
  205. },
  206. .num_resources = ARRAY_SIZE(pnx833x_ethernet_resources),
  207. .resource = pnx833x_ethernet_resources,
  208. };
  209. static struct resource pnx833x_sata_resources[] = {
  210. [0] = {
  211. .start = PNX8335_SATA_PORTS_START,
  212. .end = PNX8335_SATA_PORTS_END,
  213. .flags = IORESOURCE_MEM,
  214. },
  215. [1] = {
  216. .start = PNX8335_PIC_SATA_INT,
  217. .end = PNX8335_PIC_SATA_INT,
  218. .flags = IORESOURCE_IRQ,
  219. },
  220. };
  221. static struct platform_device pnx833x_sata_device = {
  222. .name = "pnx833x-sata",
  223. .id = -1,
  224. .num_resources = ARRAY_SIZE(pnx833x_sata_resources),
  225. .resource = pnx833x_sata_resources,
  226. };
  227. static const char *part_probes[] = {
  228. "cmdlinepart",
  229. NULL
  230. };
  231. static void
  232. pnx833x_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  233. {
  234. struct nand_chip *this = mtd->priv;
  235. unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
  236. if (cmd == NAND_CMD_NONE)
  237. return;
  238. if (ctrl & NAND_CLE)
  239. writeb(cmd, (void __iomem *)(nandaddr + PNX8335_NAND_CLE_MASK));
  240. else
  241. writeb(cmd, (void __iomem *)(nandaddr + PNX8335_NAND_ALE_MASK));
  242. }
  243. static struct platform_nand_data pnx833x_flash_nand_data = {
  244. .chip = {
  245. .nr_chips = 1,
  246. .chip_delay = 25,
  247. .part_probe_types = part_probes,
  248. },
  249. .ctrl = {
  250. .cmd_ctrl = pnx833x_flash_nand_cmd_ctrl
  251. }
  252. };
  253. /*
  254. * Set start to be the correct address (PNX8335_NAND_BASE with no 0xb!!),
  255. * 12 bytes more seems to be the standard that allows for NAND access.
  256. */
  257. static struct resource pnx833x_flash_nand_resource = {
  258. .start = PNX8335_NAND_BASE,
  259. .end = PNX8335_NAND_BASE + 12,
  260. .flags = IORESOURCE_MEM,
  261. };
  262. static struct platform_device pnx833x_flash_nand = {
  263. .name = "gen_nand",
  264. .id = -1,
  265. .num_resources = 1,
  266. .resource = &pnx833x_flash_nand_resource,
  267. .dev = {
  268. .platform_data = &pnx833x_flash_nand_data,
  269. },
  270. };
  271. static struct platform_device *pnx833x_platform_devices[] __initdata = {
  272. &pnx833x_uart_device,
  273. &pnx833x_usb_ehci_device,
  274. #ifdef CONFIG_I2C_PNX0105
  275. &pnx833x_i2c0_device,
  276. &pnx833x_i2c1_device,
  277. #endif
  278. &pnx833x_ethernet_device,
  279. &pnx833x_sata_device,
  280. &pnx833x_flash_nand,
  281. };
  282. static int __init pnx833x_platform_init(void)
  283. {
  284. int res;
  285. res = platform_add_devices(pnx833x_platform_devices,
  286. ARRAY_SIZE(pnx833x_platform_devices));
  287. return res;
  288. }
  289. arch_initcall(pnx833x_platform_init);