devices.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #include <linux/dma-mapping.h>
  20. #include <linux/module.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/serial.h>
  23. #include <linux/gpio.h>
  24. #include <mach/hardware.h>
  25. #include <mach/irqs.h>
  26. #include <mach/common.h>
  27. #include <mach/imx-uart.h>
  28. #include <mach/mx3_camera.h>
  29. #include "devices.h"
  30. static struct resource uart0[] = {
  31. {
  32. .start = UART1_BASE_ADDR,
  33. .end = UART1_BASE_ADDR + 0x0B5,
  34. .flags = IORESOURCE_MEM,
  35. }, {
  36. .start = MXC_INT_UART1,
  37. .end = MXC_INT_UART1,
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. struct platform_device mxc_uart_device0 = {
  42. .name = "imx-uart",
  43. .id = 0,
  44. .resource = uart0,
  45. .num_resources = ARRAY_SIZE(uart0),
  46. };
  47. static struct resource uart1[] = {
  48. {
  49. .start = UART2_BASE_ADDR,
  50. .end = UART2_BASE_ADDR + 0x0B5,
  51. .flags = IORESOURCE_MEM,
  52. }, {
  53. .start = MXC_INT_UART2,
  54. .end = MXC_INT_UART2,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. struct platform_device mxc_uart_device1 = {
  59. .name = "imx-uart",
  60. .id = 1,
  61. .resource = uart1,
  62. .num_resources = ARRAY_SIZE(uart1),
  63. };
  64. static struct resource uart2[] = {
  65. {
  66. .start = UART3_BASE_ADDR,
  67. .end = UART3_BASE_ADDR + 0x0B5,
  68. .flags = IORESOURCE_MEM,
  69. }, {
  70. .start = MXC_INT_UART3,
  71. .end = MXC_INT_UART3,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. struct platform_device mxc_uart_device2 = {
  76. .name = "imx-uart",
  77. .id = 2,
  78. .resource = uart2,
  79. .num_resources = ARRAY_SIZE(uart2),
  80. };
  81. #ifdef CONFIG_ARCH_MX31
  82. static struct resource uart3[] = {
  83. {
  84. .start = UART4_BASE_ADDR,
  85. .end = UART4_BASE_ADDR + 0x0B5,
  86. .flags = IORESOURCE_MEM,
  87. }, {
  88. .start = MXC_INT_UART4,
  89. .end = MXC_INT_UART4,
  90. .flags = IORESOURCE_IRQ,
  91. },
  92. };
  93. struct platform_device mxc_uart_device3 = {
  94. .name = "imx-uart",
  95. .id = 3,
  96. .resource = uart3,
  97. .num_resources = ARRAY_SIZE(uart3),
  98. };
  99. static struct resource uart4[] = {
  100. {
  101. .start = UART5_BASE_ADDR,
  102. .end = UART5_BASE_ADDR + 0x0B5,
  103. .flags = IORESOURCE_MEM,
  104. }, {
  105. .start = MXC_INT_UART5,
  106. .end = MXC_INT_UART5,
  107. .flags = IORESOURCE_IRQ,
  108. },
  109. };
  110. struct platform_device mxc_uart_device4 = {
  111. .name = "imx-uart",
  112. .id = 4,
  113. .resource = uart4,
  114. .num_resources = ARRAY_SIZE(uart4),
  115. };
  116. #endif /* CONFIG_ARCH_MX31 */
  117. /* GPIO port description */
  118. static struct mxc_gpio_port imx_gpio_ports[] = {
  119. {
  120. .chip.label = "gpio-0",
  121. .base = IO_ADDRESS(GPIO1_BASE_ADDR),
  122. .irq = MXC_INT_GPIO1,
  123. .virtual_irq_start = MXC_GPIO_IRQ_START,
  124. }, {
  125. .chip.label = "gpio-1",
  126. .base = IO_ADDRESS(GPIO2_BASE_ADDR),
  127. .irq = MXC_INT_GPIO2,
  128. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  129. }, {
  130. .chip.label = "gpio-2",
  131. .base = IO_ADDRESS(GPIO3_BASE_ADDR),
  132. .irq = MXC_INT_GPIO3,
  133. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  134. }
  135. };
  136. int __init mxc_register_gpios(void)
  137. {
  138. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  139. }
  140. static struct resource mxc_w1_master_resources[] = {
  141. {
  142. .start = OWIRE_BASE_ADDR,
  143. .end = OWIRE_BASE_ADDR + SZ_4K - 1,
  144. .flags = IORESOURCE_MEM,
  145. },
  146. };
  147. struct platform_device mxc_w1_master_device = {
  148. .name = "mxc_w1",
  149. .id = 0,
  150. .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
  151. .resource = mxc_w1_master_resources,
  152. };
  153. static struct resource mxc_nand_resources[] = {
  154. {
  155. .start = 0, /* runtime dependent */
  156. .end = 0,
  157. .flags = IORESOURCE_MEM,
  158. }, {
  159. .start = MXC_INT_NANDFC,
  160. .end = MXC_INT_NANDFC,
  161. .flags = IORESOURCE_IRQ,
  162. },
  163. };
  164. struct platform_device mxc_nand_device = {
  165. .name = "mxc_nand",
  166. .id = 0,
  167. .num_resources = ARRAY_SIZE(mxc_nand_resources),
  168. .resource = mxc_nand_resources,
  169. };
  170. static struct resource mxc_i2c0_resources[] = {
  171. {
  172. .start = I2C_BASE_ADDR,
  173. .end = I2C_BASE_ADDR + SZ_4K - 1,
  174. .flags = IORESOURCE_MEM,
  175. }, {
  176. .start = MXC_INT_I2C,
  177. .end = MXC_INT_I2C,
  178. .flags = IORESOURCE_IRQ,
  179. },
  180. };
  181. struct platform_device mxc_i2c_device0 = {
  182. .name = "imx-i2c",
  183. .id = 0,
  184. .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
  185. .resource = mxc_i2c0_resources,
  186. };
  187. static struct resource mxc_i2c1_resources[] = {
  188. {
  189. .start = I2C2_BASE_ADDR,
  190. .end = I2C2_BASE_ADDR + SZ_4K - 1,
  191. .flags = IORESOURCE_MEM,
  192. }, {
  193. .start = MXC_INT_I2C2,
  194. .end = MXC_INT_I2C2,
  195. .flags = IORESOURCE_IRQ,
  196. },
  197. };
  198. struct platform_device mxc_i2c_device1 = {
  199. .name = "imx-i2c",
  200. .id = 1,
  201. .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
  202. .resource = mxc_i2c1_resources,
  203. };
  204. static struct resource mxc_i2c2_resources[] = {
  205. {
  206. .start = I2C3_BASE_ADDR,
  207. .end = I2C3_BASE_ADDR + SZ_4K - 1,
  208. .flags = IORESOURCE_MEM,
  209. }, {
  210. .start = MXC_INT_I2C3,
  211. .end = MXC_INT_I2C3,
  212. .flags = IORESOURCE_IRQ,
  213. },
  214. };
  215. struct platform_device mxc_i2c_device2 = {
  216. .name = "imx-i2c",
  217. .id = 2,
  218. .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
  219. .resource = mxc_i2c2_resources,
  220. };
  221. #ifdef CONFIG_ARCH_MX31
  222. static struct resource mxcsdhc0_resources[] = {
  223. {
  224. .start = MMC_SDHC1_BASE_ADDR,
  225. .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
  226. .flags = IORESOURCE_MEM,
  227. }, {
  228. .start = MXC_INT_MMC_SDHC1,
  229. .end = MXC_INT_MMC_SDHC1,
  230. .flags = IORESOURCE_IRQ,
  231. },
  232. };
  233. static struct resource mxcsdhc1_resources[] = {
  234. {
  235. .start = MMC_SDHC2_BASE_ADDR,
  236. .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
  237. .flags = IORESOURCE_MEM,
  238. }, {
  239. .start = MXC_INT_MMC_SDHC2,
  240. .end = MXC_INT_MMC_SDHC2,
  241. .flags = IORESOURCE_IRQ,
  242. },
  243. };
  244. struct platform_device mxcsdhc_device0 = {
  245. .name = "mxc-mmc",
  246. .id = 0,
  247. .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
  248. .resource = mxcsdhc0_resources,
  249. };
  250. struct platform_device mxcsdhc_device1 = {
  251. .name = "mxc-mmc",
  252. .id = 1,
  253. .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
  254. .resource = mxcsdhc1_resources,
  255. };
  256. static struct resource rnga_resources[] = {
  257. {
  258. .start = RNGA_BASE_ADDR,
  259. .end = RNGA_BASE_ADDR + 0x28,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. };
  263. struct platform_device mxc_rnga_device = {
  264. .name = "mxc_rnga",
  265. .id = -1,
  266. .num_resources = 1,
  267. .resource = rnga_resources,
  268. };
  269. #endif /* CONFIG_ARCH_MX31 */
  270. /* i.MX31 Image Processing Unit */
  271. /* The resource order is important! */
  272. static struct resource mx3_ipu_rsrc[] = {
  273. {
  274. .start = IPU_CTRL_BASE_ADDR,
  275. .end = IPU_CTRL_BASE_ADDR + 0x5F,
  276. .flags = IORESOURCE_MEM,
  277. }, {
  278. .start = IPU_CTRL_BASE_ADDR + 0x88,
  279. .end = IPU_CTRL_BASE_ADDR + 0xB3,
  280. .flags = IORESOURCE_MEM,
  281. }, {
  282. .start = MXC_INT_IPU_SYN,
  283. .end = MXC_INT_IPU_SYN,
  284. .flags = IORESOURCE_IRQ,
  285. }, {
  286. .start = MXC_INT_IPU_ERR,
  287. .end = MXC_INT_IPU_ERR,
  288. .flags = IORESOURCE_IRQ,
  289. },
  290. };
  291. struct platform_device mx3_ipu = {
  292. .name = "ipu-core",
  293. .id = -1,
  294. .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
  295. .resource = mx3_ipu_rsrc,
  296. };
  297. static struct resource fb_resources[] = {
  298. {
  299. .start = IPU_CTRL_BASE_ADDR + 0xB4,
  300. .end = IPU_CTRL_BASE_ADDR + 0x1BF,
  301. .flags = IORESOURCE_MEM,
  302. },
  303. };
  304. struct platform_device mx3_fb = {
  305. .name = "mx3_sdc_fb",
  306. .id = -1,
  307. .num_resources = ARRAY_SIZE(fb_resources),
  308. .resource = fb_resources,
  309. .dev = {
  310. .coherent_dma_mask = DMA_BIT_MASK(32),
  311. },
  312. };
  313. static struct resource camera_resources[] = {
  314. {
  315. .start = IPU_CTRL_BASE_ADDR + 0x60,
  316. .end = IPU_CTRL_BASE_ADDR + 0x87,
  317. .flags = IORESOURCE_MEM,
  318. },
  319. };
  320. struct platform_device mx3_camera = {
  321. .name = "mx3-camera",
  322. .id = 0,
  323. .num_resources = ARRAY_SIZE(camera_resources),
  324. .resource = camera_resources,
  325. .dev = {
  326. .coherent_dma_mask = DMA_BIT_MASK(32),
  327. },
  328. };
  329. static struct resource otg_resources[] = {
  330. {
  331. .start = MX31_OTG_BASE_ADDR,
  332. .end = MX31_OTG_BASE_ADDR + 0x1ff,
  333. .flags = IORESOURCE_MEM,
  334. }, {
  335. .start = MXC_INT_USB3,
  336. .end = MXC_INT_USB3,
  337. .flags = IORESOURCE_IRQ,
  338. },
  339. };
  340. static u64 otg_dmamask = DMA_BIT_MASK(32);
  341. /* OTG gadget device */
  342. struct platform_device mxc_otg_udc_device = {
  343. .name = "fsl-usb2-udc",
  344. .id = -1,
  345. .dev = {
  346. .dma_mask = &otg_dmamask,
  347. .coherent_dma_mask = DMA_BIT_MASK(32),
  348. },
  349. .resource = otg_resources,
  350. .num_resources = ARRAY_SIZE(otg_resources),
  351. };
  352. /* OTG host */
  353. struct platform_device mxc_otg_host = {
  354. .name = "mxc-ehci",
  355. .id = 0,
  356. .dev = {
  357. .coherent_dma_mask = 0xffffffff,
  358. .dma_mask = &otg_dmamask,
  359. },
  360. .resource = otg_resources,
  361. .num_resources = ARRAY_SIZE(otg_resources),
  362. };
  363. /* USB host 1 */
  364. static u64 usbh1_dmamask = ~(u32)0;
  365. static struct resource mxc_usbh1_resources[] = {
  366. {
  367. .start = MX31_OTG_BASE_ADDR + 0x200,
  368. .end = MX31_OTG_BASE_ADDR + 0x3ff,
  369. .flags = IORESOURCE_MEM,
  370. }, {
  371. .start = MXC_INT_USB1,
  372. .end = MXC_INT_USB1,
  373. .flags = IORESOURCE_IRQ,
  374. },
  375. };
  376. struct platform_device mxc_usbh1 = {
  377. .name = "mxc-ehci",
  378. .id = 1,
  379. .dev = {
  380. .coherent_dma_mask = 0xffffffff,
  381. .dma_mask = &usbh1_dmamask,
  382. },
  383. .resource = mxc_usbh1_resources,
  384. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  385. };
  386. /* USB host 2 */
  387. static u64 usbh2_dmamask = ~(u32)0;
  388. static struct resource mxc_usbh2_resources[] = {
  389. {
  390. .start = MX31_OTG_BASE_ADDR + 0x400,
  391. .end = MX31_OTG_BASE_ADDR + 0x5ff,
  392. .flags = IORESOURCE_MEM,
  393. }, {
  394. .start = MXC_INT_USB2,
  395. .end = MXC_INT_USB2,
  396. .flags = IORESOURCE_IRQ,
  397. },
  398. };
  399. struct platform_device mxc_usbh2 = {
  400. .name = "mxc-ehci",
  401. .id = 2,
  402. .dev = {
  403. .coherent_dma_mask = 0xffffffff,
  404. .dma_mask = &usbh2_dmamask,
  405. },
  406. .resource = mxc_usbh2_resources,
  407. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  408. };
  409. /*
  410. * SPI master controller
  411. * 3 channels
  412. */
  413. static struct resource mxc_spi_0_resources[] = {
  414. {
  415. .start = CSPI1_BASE_ADDR,
  416. .end = CSPI1_BASE_ADDR + SZ_4K - 1,
  417. .flags = IORESOURCE_MEM,
  418. }, {
  419. .start = MXC_INT_CSPI1,
  420. .end = MXC_INT_CSPI1,
  421. .flags = IORESOURCE_IRQ,
  422. },
  423. };
  424. static struct resource mxc_spi_1_resources[] = {
  425. {
  426. .start = CSPI2_BASE_ADDR,
  427. .end = CSPI2_BASE_ADDR + SZ_4K - 1,
  428. .flags = IORESOURCE_MEM,
  429. }, {
  430. .start = MXC_INT_CSPI2,
  431. .end = MXC_INT_CSPI2,
  432. .flags = IORESOURCE_IRQ,
  433. },
  434. };
  435. static struct resource mxc_spi_2_resources[] = {
  436. {
  437. .start = CSPI3_BASE_ADDR,
  438. .end = CSPI3_BASE_ADDR + SZ_4K - 1,
  439. .flags = IORESOURCE_MEM,
  440. }, {
  441. .start = MXC_INT_CSPI3,
  442. .end = MXC_INT_CSPI3,
  443. .flags = IORESOURCE_IRQ,
  444. },
  445. };
  446. struct platform_device mxc_spi_device0 = {
  447. .name = "spi_imx",
  448. .id = 0,
  449. .num_resources = ARRAY_SIZE(mxc_spi_0_resources),
  450. .resource = mxc_spi_0_resources,
  451. };
  452. struct platform_device mxc_spi_device1 = {
  453. .name = "spi_imx",
  454. .id = 1,
  455. .num_resources = ARRAY_SIZE(mxc_spi_1_resources),
  456. .resource = mxc_spi_1_resources,
  457. };
  458. struct platform_device mxc_spi_device2 = {
  459. .name = "spi_imx",
  460. .id = 2,
  461. .num_resources = ARRAY_SIZE(mxc_spi_2_resources),
  462. .resource = mxc_spi_2_resources,
  463. };
  464. #ifdef CONFIG_ARCH_MX35
  465. static struct resource mxc_fec_resources[] = {
  466. {
  467. .start = MXC_FEC_BASE_ADDR,
  468. .end = MXC_FEC_BASE_ADDR + 0xfff,
  469. .flags = IORESOURCE_MEM,
  470. }, {
  471. .start = MXC_INT_FEC,
  472. .end = MXC_INT_FEC,
  473. .flags = IORESOURCE_IRQ,
  474. },
  475. };
  476. struct platform_device mxc_fec_device = {
  477. .name = "fec",
  478. .id = 0,
  479. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  480. .resource = mxc_fec_resources,
  481. };
  482. #endif
  483. static int mx3_devices_init(void)
  484. {
  485. if (cpu_is_mx31()) {
  486. mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
  487. mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
  488. mxc_register_device(&mxc_rnga_device, NULL);
  489. }
  490. if (cpu_is_mx35()) {
  491. mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
  492. mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
  493. otg_resources[0].start = MX35_OTG_BASE_ADDR;
  494. otg_resources[0].end = MX35_OTG_BASE_ADDR + 0x1ff;
  495. otg_resources[1].start = MXC_INT_USBOTG;
  496. otg_resources[1].end = MXC_INT_USBOTG;
  497. mxc_usbh1_resources[0].start = MX35_OTG_BASE_ADDR + 0x400;
  498. mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff;
  499. mxc_usbh1_resources[1].start = MXC_INT_USBHS;
  500. mxc_usbh1_resources[1].end = MXC_INT_USBHS;
  501. }
  502. return 0;
  503. }
  504. subsys_initcall(mx3_devices_init);