devices.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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 imx3x_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. #ifdef CONFIG_ARCH_MX31
  154. static struct resource mxcsdhc0_resources[] = {
  155. {
  156. .start = MMC_SDHC1_BASE_ADDR,
  157. .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
  158. .flags = IORESOURCE_MEM,
  159. }, {
  160. .start = MXC_INT_MMC_SDHC1,
  161. .end = MXC_INT_MMC_SDHC1,
  162. .flags = IORESOURCE_IRQ,
  163. },
  164. };
  165. static struct resource mxcsdhc1_resources[] = {
  166. {
  167. .start = MMC_SDHC2_BASE_ADDR,
  168. .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
  169. .flags = IORESOURCE_MEM,
  170. }, {
  171. .start = MXC_INT_MMC_SDHC2,
  172. .end = MXC_INT_MMC_SDHC2,
  173. .flags = IORESOURCE_IRQ,
  174. },
  175. };
  176. struct platform_device mxcsdhc_device0 = {
  177. .name = "mxc-mmc",
  178. .id = 0,
  179. .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
  180. .resource = mxcsdhc0_resources,
  181. };
  182. struct platform_device mxcsdhc_device1 = {
  183. .name = "mxc-mmc",
  184. .id = 1,
  185. .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
  186. .resource = mxcsdhc1_resources,
  187. };
  188. static struct resource rnga_resources[] = {
  189. {
  190. .start = RNGA_BASE_ADDR,
  191. .end = RNGA_BASE_ADDR + 0x28,
  192. .flags = IORESOURCE_MEM,
  193. },
  194. };
  195. struct platform_device mxc_rnga_device = {
  196. .name = "mxc_rnga",
  197. .id = -1,
  198. .num_resources = 1,
  199. .resource = rnga_resources,
  200. };
  201. #endif /* CONFIG_ARCH_MX31 */
  202. /* i.MX31 Image Processing Unit */
  203. /* The resource order is important! */
  204. static struct resource mx3_ipu_rsrc[] = {
  205. {
  206. .start = IPU_CTRL_BASE_ADDR,
  207. .end = IPU_CTRL_BASE_ADDR + 0x5F,
  208. .flags = IORESOURCE_MEM,
  209. }, {
  210. .start = IPU_CTRL_BASE_ADDR + 0x88,
  211. .end = IPU_CTRL_BASE_ADDR + 0xB3,
  212. .flags = IORESOURCE_MEM,
  213. }, {
  214. .start = MXC_INT_IPU_SYN,
  215. .end = MXC_INT_IPU_SYN,
  216. .flags = IORESOURCE_IRQ,
  217. }, {
  218. .start = MXC_INT_IPU_ERR,
  219. .end = MXC_INT_IPU_ERR,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. };
  223. struct platform_device mx3_ipu = {
  224. .name = "ipu-core",
  225. .id = -1,
  226. .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
  227. .resource = mx3_ipu_rsrc,
  228. };
  229. static struct resource fb_resources[] = {
  230. {
  231. .start = IPU_CTRL_BASE_ADDR + 0xB4,
  232. .end = IPU_CTRL_BASE_ADDR + 0x1BF,
  233. .flags = IORESOURCE_MEM,
  234. },
  235. };
  236. struct platform_device mx3_fb = {
  237. .name = "mx3_sdc_fb",
  238. .id = -1,
  239. .num_resources = ARRAY_SIZE(fb_resources),
  240. .resource = fb_resources,
  241. .dev = {
  242. .coherent_dma_mask = DMA_BIT_MASK(32),
  243. },
  244. };
  245. static struct resource camera_resources[] = {
  246. {
  247. .start = IPU_CTRL_BASE_ADDR + 0x60,
  248. .end = IPU_CTRL_BASE_ADDR + 0x87,
  249. .flags = IORESOURCE_MEM,
  250. },
  251. };
  252. struct platform_device mx3_camera = {
  253. .name = "mx3-camera",
  254. .id = 0,
  255. .num_resources = ARRAY_SIZE(camera_resources),
  256. .resource = camera_resources,
  257. .dev = {
  258. .coherent_dma_mask = DMA_BIT_MASK(32),
  259. },
  260. };
  261. static struct resource otg_resources[] = {
  262. {
  263. .start = MX31_OTG_BASE_ADDR,
  264. .end = MX31_OTG_BASE_ADDR + 0x1ff,
  265. .flags = IORESOURCE_MEM,
  266. }, {
  267. .start = MXC_INT_USB3,
  268. .end = MXC_INT_USB3,
  269. .flags = IORESOURCE_IRQ,
  270. },
  271. };
  272. static u64 otg_dmamask = DMA_BIT_MASK(32);
  273. /* OTG gadget device */
  274. struct platform_device mxc_otg_udc_device = {
  275. .name = "fsl-usb2-udc",
  276. .id = -1,
  277. .dev = {
  278. .dma_mask = &otg_dmamask,
  279. .coherent_dma_mask = DMA_BIT_MASK(32),
  280. },
  281. .resource = otg_resources,
  282. .num_resources = ARRAY_SIZE(otg_resources),
  283. };
  284. /* OTG host */
  285. struct platform_device mxc_otg_host = {
  286. .name = "mxc-ehci",
  287. .id = 0,
  288. .dev = {
  289. .coherent_dma_mask = 0xffffffff,
  290. .dma_mask = &otg_dmamask,
  291. },
  292. .resource = otg_resources,
  293. .num_resources = ARRAY_SIZE(otg_resources),
  294. };
  295. /* USB host 1 */
  296. static u64 usbh1_dmamask = ~(u32)0;
  297. static struct resource mxc_usbh1_resources[] = {
  298. {
  299. .start = MX31_OTG_BASE_ADDR + 0x200,
  300. .end = MX31_OTG_BASE_ADDR + 0x3ff,
  301. .flags = IORESOURCE_MEM,
  302. }, {
  303. .start = MXC_INT_USB1,
  304. .end = MXC_INT_USB1,
  305. .flags = IORESOURCE_IRQ,
  306. },
  307. };
  308. struct platform_device mxc_usbh1 = {
  309. .name = "mxc-ehci",
  310. .id = 1,
  311. .dev = {
  312. .coherent_dma_mask = 0xffffffff,
  313. .dma_mask = &usbh1_dmamask,
  314. },
  315. .resource = mxc_usbh1_resources,
  316. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  317. };
  318. /* USB host 2 */
  319. static u64 usbh2_dmamask = ~(u32)0;
  320. static struct resource mxc_usbh2_resources[] = {
  321. {
  322. .start = MX31_OTG_BASE_ADDR + 0x400,
  323. .end = MX31_OTG_BASE_ADDR + 0x5ff,
  324. .flags = IORESOURCE_MEM,
  325. }, {
  326. .start = MXC_INT_USB2,
  327. .end = MXC_INT_USB2,
  328. .flags = IORESOURCE_IRQ,
  329. },
  330. };
  331. struct platform_device mxc_usbh2 = {
  332. .name = "mxc-ehci",
  333. .id = 2,
  334. .dev = {
  335. .coherent_dma_mask = 0xffffffff,
  336. .dma_mask = &usbh2_dmamask,
  337. },
  338. .resource = mxc_usbh2_resources,
  339. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  340. };
  341. #if defined(CONFIG_ARCH_MX35)
  342. /*
  343. * SPI master controller
  344. * 3 channels
  345. */
  346. static struct resource mxc_spi_0_resources[] = {
  347. {
  348. .start = CSPI1_BASE_ADDR,
  349. .end = CSPI1_BASE_ADDR + SZ_4K - 1,
  350. .flags = IORESOURCE_MEM,
  351. }, {
  352. .start = MXC_INT_CSPI1,
  353. .end = MXC_INT_CSPI1,
  354. .flags = IORESOURCE_IRQ,
  355. },
  356. };
  357. static struct resource mxc_spi_1_resources[] = {
  358. {
  359. .start = CSPI2_BASE_ADDR,
  360. .end = CSPI2_BASE_ADDR + SZ_4K - 1,
  361. .flags = IORESOURCE_MEM,
  362. }, {
  363. .start = MXC_INT_CSPI2,
  364. .end = MXC_INT_CSPI2,
  365. .flags = IORESOURCE_IRQ,
  366. },
  367. };
  368. static struct resource mxc_spi_2_resources[] = {
  369. {
  370. .start = CSPI3_BASE_ADDR,
  371. .end = CSPI3_BASE_ADDR + SZ_4K - 1,
  372. .flags = IORESOURCE_MEM,
  373. }, {
  374. .start = MXC_INT_CSPI3,
  375. .end = MXC_INT_CSPI3,
  376. .flags = IORESOURCE_IRQ,
  377. },
  378. };
  379. struct platform_device mxc_spi_device0 = {
  380. .name = "spi_imx",
  381. .id = 0,
  382. .num_resources = ARRAY_SIZE(mxc_spi_0_resources),
  383. .resource = mxc_spi_0_resources,
  384. };
  385. struct platform_device mxc_spi_device1 = {
  386. .name = "spi_imx",
  387. .id = 1,
  388. .num_resources = ARRAY_SIZE(mxc_spi_1_resources),
  389. .resource = mxc_spi_1_resources,
  390. };
  391. struct platform_device mxc_spi_device2 = {
  392. .name = "spi_imx",
  393. .id = 2,
  394. .num_resources = ARRAY_SIZE(mxc_spi_2_resources),
  395. .resource = mxc_spi_2_resources,
  396. };
  397. static struct resource mxc_fec_resources[] = {
  398. {
  399. .start = MXC_FEC_BASE_ADDR,
  400. .end = MXC_FEC_BASE_ADDR + 0xfff,
  401. .flags = IORESOURCE_MEM,
  402. }, {
  403. .start = MXC_INT_FEC,
  404. .end = MXC_INT_FEC,
  405. .flags = IORESOURCE_IRQ,
  406. },
  407. };
  408. struct platform_device mxc_fec_device = {
  409. .name = "fec",
  410. .id = 0,
  411. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  412. .resource = mxc_fec_resources,
  413. };
  414. #endif
  415. static struct resource imx_ssi_resources0[] = {
  416. {
  417. .start = SSI1_BASE_ADDR,
  418. .end = SSI1_BASE_ADDR + 0xfff,
  419. .flags = IORESOURCE_MEM,
  420. }, {
  421. .start = MX31_INT_SSI1,
  422. .end = MX31_INT_SSI1,
  423. .flags = IORESOURCE_IRQ,
  424. },
  425. };
  426. static struct resource imx_ssi_resources1[] = {
  427. {
  428. .start = SSI2_BASE_ADDR,
  429. .end = SSI2_BASE_ADDR + 0xfff,
  430. .flags = IORESOURCE_MEM
  431. }, {
  432. .start = MX31_INT_SSI2,
  433. .end = MX31_INT_SSI2,
  434. .flags = IORESOURCE_IRQ,
  435. },
  436. };
  437. struct platform_device imx_ssi_device0 = {
  438. .name = "imx-ssi",
  439. .id = 0,
  440. .num_resources = ARRAY_SIZE(imx_ssi_resources0),
  441. .resource = imx_ssi_resources0,
  442. };
  443. struct platform_device imx_ssi_device1 = {
  444. .name = "imx-ssi",
  445. .id = 1,
  446. .num_resources = ARRAY_SIZE(imx_ssi_resources1),
  447. .resource = imx_ssi_resources1,
  448. };
  449. static struct resource imx_wdt_resources[] = {
  450. {
  451. .flags = IORESOURCE_MEM,
  452. },
  453. };
  454. struct platform_device imx_wdt_device0 = {
  455. .name = "imx2-wdt",
  456. .id = 0,
  457. .num_resources = ARRAY_SIZE(imx_wdt_resources),
  458. .resource = imx_wdt_resources,
  459. };
  460. static struct resource imx_rtc_resources[] = {
  461. {
  462. .start = MX31_RTC_BASE_ADDR,
  463. .end = MX31_RTC_BASE_ADDR + 0x3fff,
  464. .flags = IORESOURCE_MEM,
  465. },
  466. {
  467. .start = MX31_INT_RTC,
  468. .flags = IORESOURCE_IRQ,
  469. },
  470. };
  471. struct platform_device imx_rtc_device0 = {
  472. .name = "mxc_rtc",
  473. .id = -1,
  474. .num_resources = ARRAY_SIZE(imx_rtc_resources),
  475. .resource = imx_rtc_resources,
  476. };
  477. static struct resource imx_kpp_resources[] = {
  478. {
  479. .start = MX3x_KPP_BASE_ADDR,
  480. .end = MX3x_KPP_BASE_ADDR + 0xf,
  481. .flags = IORESOURCE_MEM
  482. }, {
  483. .start = MX3x_INT_KPP,
  484. .end = MX3x_INT_KPP,
  485. .flags = IORESOURCE_IRQ,
  486. },
  487. };
  488. struct platform_device imx_kpp_device = {
  489. .name = "imx-keypad",
  490. .id = -1,
  491. .num_resources = ARRAY_SIZE(imx_kpp_resources),
  492. .resource = imx_kpp_resources,
  493. };
  494. static int __init mx3_devices_init(void)
  495. {
  496. #if defined(CONFIG_ARCH_MX31)
  497. if (cpu_is_mx31()) {
  498. imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
  499. imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
  500. mxc_register_device(&mxc_rnga_device, NULL);
  501. }
  502. #endif
  503. #if defined(CONFIG_ARCH_MX35)
  504. if (cpu_is_mx35()) {
  505. otg_resources[0].start = MX35_OTG_BASE_ADDR;
  506. otg_resources[0].end = MX35_OTG_BASE_ADDR + 0x1ff;
  507. otg_resources[1].start = MXC_INT_USBOTG;
  508. otg_resources[1].end = MXC_INT_USBOTG;
  509. mxc_usbh1_resources[0].start = MX35_OTG_BASE_ADDR + 0x400;
  510. mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff;
  511. mxc_usbh1_resources[1].start = MXC_INT_USBHS;
  512. mxc_usbh1_resources[1].end = MXC_INT_USBHS;
  513. imx_ssi_resources0[1].start = MX35_INT_SSI1;
  514. imx_ssi_resources0[1].end = MX35_INT_SSI1;
  515. imx_ssi_resources1[1].start = MX35_INT_SSI2;
  516. imx_ssi_resources1[1].end = MX35_INT_SSI2;
  517. imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
  518. imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
  519. }
  520. #endif
  521. return 0;
  522. }
  523. subsys_initcall(mx3_devices_init);