devices.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /*
  2. * Author: MontaVista Software, Inc.
  3. * <source@mvista.com>
  4. *
  5. * Based on the OMAP devices.c
  6. *
  7. * 2005 (c) MontaVista Software, Inc. This file is licensed under the
  8. * terms of the GNU General Public License version 2. This program is
  9. * licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. *
  12. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  13. * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
  14. * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
  15. * Copyright (c) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  16. * Copyright (c) 2008 Darius Augulis <darius.augulis@teltonika.lt>
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License
  20. * as published by the Free Software Foundation; either version 2
  21. * of the License, or (at your option) any later version.
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  30. * MA 02110-1301, USA.
  31. */
  32. #include <linux/module.h>
  33. #include <linux/kernel.h>
  34. #include <linux/init.h>
  35. #include <linux/platform_device.h>
  36. #include <linux/gpio.h>
  37. #include <linux/dma-mapping.h>
  38. #include <linux/serial.h>
  39. #include <mach/irqs.h>
  40. #include <mach/hardware.h>
  41. #include <mach/common.h>
  42. #include <mach/mmc.h>
  43. #include "devices.h"
  44. #if defined(CONFIG_ARCH_MX1)
  45. static struct resource imx1_camera_resources[] = {
  46. {
  47. .start = 0x00224000,
  48. .end = 0x00224010,
  49. .flags = IORESOURCE_MEM,
  50. }, {
  51. .start = MX1_CSI_INT,
  52. .end = MX1_CSI_INT,
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. };
  56. static u64 imx1_camera_dmamask = DMA_BIT_MASK(32);
  57. struct platform_device imx1_camera_device = {
  58. .name = "mx1-camera",
  59. .id = 0, /* This is used to put cameras on this interface */
  60. .dev = {
  61. .dma_mask = &imx1_camera_dmamask,
  62. .coherent_dma_mask = DMA_BIT_MASK(32),
  63. },
  64. .resource = imx1_camera_resources,
  65. .num_resources = ARRAY_SIZE(imx1_camera_resources),
  66. };
  67. static struct resource imx_i2c_resources[] = {
  68. {
  69. .start = 0x00217000,
  70. .end = 0x00217010,
  71. .flags = IORESOURCE_MEM,
  72. }, {
  73. .start = MX1_I2C_INT,
  74. .end = MX1_I2C_INT,
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. struct platform_device imx_i2c_device0 = {
  79. .name = "imx-i2c",
  80. .id = 0,
  81. .resource = imx_i2c_resources,
  82. .num_resources = ARRAY_SIZE(imx_i2c_resources),
  83. };
  84. #define DEFINE_IMX1_UART_DEVICE(n, baseaddr, irqrx, irqtx, irqrts) \
  85. static struct resource imx1_uart_resources ## n[] = { \
  86. { \
  87. .start = baseaddr, \
  88. .end = baseaddr + 0xd0, \
  89. .flags = IORESOURCE_MEM, \
  90. }, { \
  91. .start = irqrx, \
  92. .end = irqrx, \
  93. .flags = IORESOURCE_IRQ, \
  94. }, { \
  95. .start = irqtx, \
  96. .end = irqtx, \
  97. .flags = IORESOURCE_IRQ, \
  98. }, { \
  99. .start = irqrts, \
  100. .end = irqrts, \
  101. .flags = IORESOURCE_IRQ, \
  102. }, \
  103. }; \
  104. \
  105. struct platform_device imx1_uart_device ## n = { \
  106. .name = "imx-uart", \
  107. .id = n, \
  108. .num_resources = ARRAY_SIZE(imx1_uart_resources ## n), \
  109. .resource = imx1_uart_resources ## n, \
  110. }
  111. DEFINE_IMX1_UART_DEVICE(0, MX1_UART1_BASE_ADDR, MX1_UART1_MINT_RX, MX1_UART1_MINT_TX, MX1_UART1_MINT_RTS);
  112. DEFINE_IMX1_UART_DEVICE(1, MX1_UART2_BASE_ADDR, MX1_UART2_MINT_RX, MX1_UART2_MINT_TX, MX1_UART2_MINT_RTS);
  113. static struct resource imx_rtc_resources[] = {
  114. {
  115. .start = 0x00204000,
  116. .end = 0x00204024,
  117. .flags = IORESOURCE_MEM,
  118. }, {
  119. .start = MX1_RTC_INT,
  120. .end = MX1_RTC_INT,
  121. .flags = IORESOURCE_IRQ,
  122. }, {
  123. .start = MX1_RTC_SAMINT,
  124. .end = MX1_RTC_SAMINT,
  125. .flags = IORESOURCE_IRQ,
  126. },
  127. };
  128. struct platform_device imx_rtc_device = {
  129. .name = "rtc-imx",
  130. .id = 0,
  131. .resource = imx_rtc_resources,
  132. .num_resources = ARRAY_SIZE(imx_rtc_resources),
  133. };
  134. static struct resource imx_wdt_resources[] = {
  135. {
  136. .start = 0x00201000,
  137. .end = 0x00201008,
  138. .flags = IORESOURCE_MEM,
  139. }, {
  140. .start = MX1_WDT_INT,
  141. .end = MX1_WDT_INT,
  142. .flags = IORESOURCE_IRQ,
  143. },
  144. };
  145. struct platform_device imx_wdt_device = {
  146. .name = "imx-wdt",
  147. .id = 0,
  148. .resource = imx_wdt_resources,
  149. .num_resources = ARRAY_SIZE(imx_wdt_resources),
  150. };
  151. static struct resource imx_usb_resources[] = {
  152. {
  153. .start = 0x00212000,
  154. .end = 0x00212148,
  155. .flags = IORESOURCE_MEM,
  156. }, {
  157. .start = MX1_USBD_INT0,
  158. .end = MX1_USBD_INT0,
  159. .flags = IORESOURCE_IRQ,
  160. }, {
  161. .start = MX1_USBD_INT1,
  162. .end = MX1_USBD_INT1,
  163. .flags = IORESOURCE_IRQ,
  164. }, {
  165. .start = MX1_USBD_INT2,
  166. .end = MX1_USBD_INT2,
  167. .flags = IORESOURCE_IRQ,
  168. }, {
  169. .start = MX1_USBD_INT3,
  170. .end = MX1_USBD_INT3,
  171. .flags = IORESOURCE_IRQ,
  172. }, {
  173. .start = MX1_USBD_INT4,
  174. .end = MX1_USBD_INT4,
  175. .flags = IORESOURCE_IRQ,
  176. }, {
  177. .start = MX1_USBD_INT5,
  178. .end = MX1_USBD_INT5,
  179. .flags = IORESOURCE_IRQ,
  180. }, {
  181. .start = MX1_USBD_INT6,
  182. .end = MX1_USBD_INT6,
  183. .flags = IORESOURCE_IRQ,
  184. },
  185. };
  186. struct platform_device imx_usb_device = {
  187. .name = "imx_udc",
  188. .id = 0,
  189. .num_resources = ARRAY_SIZE(imx_usb_resources),
  190. .resource = imx_usb_resources,
  191. };
  192. /* GPIO port description */
  193. static struct mxc_gpio_port imx_gpio_ports[] = {
  194. {
  195. .chip.label = "gpio-0",
  196. .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
  197. .irq = MX1_GPIO_INT_PORTA,
  198. .virtual_irq_start = MXC_GPIO_IRQ_START,
  199. }, {
  200. .chip.label = "gpio-1",
  201. .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
  202. .irq = MX1_GPIO_INT_PORTB,
  203. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  204. }, {
  205. .chip.label = "gpio-2",
  206. .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
  207. .irq = MX1_GPIO_INT_PORTC,
  208. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  209. }, {
  210. .chip.label = "gpio-3",
  211. .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
  212. .irq = MX1_GPIO_INT_PORTD,
  213. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  214. }
  215. };
  216. int __init imx1_register_gpios(void)
  217. {
  218. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  219. }
  220. #endif
  221. #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
  222. /*
  223. * SPI master controller
  224. *
  225. * - i.MX1: 2 channel (slighly different register setting)
  226. * - i.MX21: 2 channel
  227. * - i.MX27: 3 channel
  228. */
  229. #define DEFINE_IMX_SPI_DEVICE(n, baseaddr, irq) \
  230. static struct resource mxc_spi_resources ## n[] = { \
  231. { \
  232. .start = baseaddr, \
  233. .end = baseaddr + SZ_4K - 1, \
  234. .flags = IORESOURCE_MEM, \
  235. }, { \
  236. .start = irq, \
  237. .end = irq, \
  238. .flags = IORESOURCE_IRQ, \
  239. }, \
  240. }; \
  241. \
  242. struct platform_device mxc_spi_device ## n = { \
  243. .name = "spi_imx", \
  244. .id = n, \
  245. .num_resources = ARRAY_SIZE(mxc_spi_resources ## n), \
  246. .resource = mxc_spi_resources ## n, \
  247. }
  248. DEFINE_IMX_SPI_DEVICE(0, MX2x_CSPI1_BASE_ADDR, MX2x_INT_CSPI1);
  249. DEFINE_IMX_SPI_DEVICE(1, MX2x_CSPI2_BASE_ADDR, MX2x_INT_CSPI2);
  250. #ifdef CONFIG_MACH_MX27
  251. DEFINE_IMX_SPI_DEVICE(2, MX27_CSPI3_BASE_ADDR, MX27_INT_CSPI3);
  252. #endif
  253. /*
  254. * General Purpose Timer
  255. * - i.MX21: 3 timers
  256. * - i.MX27: 6 timers
  257. */
  258. #define DEFINE_IMX_GPT_DEVICE(n, baseaddr, irq) \
  259. static struct resource timer ## n ##_resources[] = { \
  260. { \
  261. .start = baseaddr, \
  262. .end = baseaddr + SZ_4K - 1, \
  263. .flags = IORESOURCE_MEM, \
  264. }, { \
  265. .start = irq, \
  266. .end = irq, \
  267. .flags = IORESOURCE_IRQ, \
  268. } \
  269. }; \
  270. \
  271. struct platform_device mxc_gpt ## n = { \
  272. .name = "imx_gpt", \
  273. .id = n, \
  274. .num_resources = ARRAY_SIZE(timer ## n ## _resources), \
  275. .resource = timer ## n ## _resources, \
  276. }
  277. /* We use gpt1 as system timer, so do not add a device for this one */
  278. DEFINE_IMX_GPT_DEVICE(1, MX2x_GPT2_BASE_ADDR, MX2x_INT_GPT2);
  279. DEFINE_IMX_GPT_DEVICE(2, MX2x_GPT3_BASE_ADDR, MX2x_INT_GPT3);
  280. #ifdef CONFIG_MACH_MX27
  281. DEFINE_IMX_GPT_DEVICE(3, MX27_GPT4_BASE_ADDR, MX27_INT_GPT4);
  282. DEFINE_IMX_GPT_DEVICE(4, MX27_GPT5_BASE_ADDR, MX27_INT_GPT5);
  283. DEFINE_IMX_GPT_DEVICE(5, MX27_GPT6_BASE_ADDR, MX27_INT_GPT6);
  284. #endif
  285. /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
  286. static struct resource mxc_wdt_resources[] = {
  287. {
  288. .start = MX2x_WDOG_BASE_ADDR,
  289. .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
  290. .flags = IORESOURCE_MEM,
  291. },
  292. };
  293. struct platform_device mxc_wdt = {
  294. .name = "imx2-wdt",
  295. .id = 0,
  296. .num_resources = ARRAY_SIZE(mxc_wdt_resources),
  297. .resource = mxc_wdt_resources,
  298. };
  299. static struct resource mxc_w1_master_resources[] = {
  300. {
  301. .start = MX2x_OWIRE_BASE_ADDR,
  302. .end = MX2x_OWIRE_BASE_ADDR + SZ_4K - 1,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. };
  306. struct platform_device mxc_w1_master_device = {
  307. .name = "mxc_w1",
  308. .id = 0,
  309. .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
  310. .resource = mxc_w1_master_resources,
  311. };
  312. #define DEFINE_MXC_NAND_DEVICE(pfx, baseaddr, irq) \
  313. static struct resource pfx ## _nand_resources[] = { \
  314. { \
  315. .start = baseaddr, \
  316. .end = baseaddr + SZ_4K - 1, \
  317. .flags = IORESOURCE_MEM, \
  318. }, { \
  319. .start = irq, \
  320. .end = irq, \
  321. .flags = IORESOURCE_IRQ, \
  322. }, \
  323. }; \
  324. \
  325. struct platform_device pfx ## _nand_device = { \
  326. .name = "mxc_nand", \
  327. .id = 0, \
  328. .num_resources = ARRAY_SIZE(pfx ## _nand_resources), \
  329. .resource = pfx ## _nand_resources, \
  330. }
  331. #ifdef CONFIG_MACH_MX21
  332. DEFINE_MXC_NAND_DEVICE(imx21, MX21_NFC_BASE_ADDR, MX21_INT_NANDFC);
  333. #endif
  334. #ifdef CONFIG_MACH_MX27
  335. DEFINE_MXC_NAND_DEVICE(imx27, MX27_NFC_BASE_ADDR, MX27_INT_NANDFC);
  336. #endif
  337. /*
  338. * lcdc:
  339. * - i.MX1: the basic controller
  340. * - i.MX21: to be checked
  341. * - i.MX27: like i.MX1, with slightly variations
  342. */
  343. static struct resource mxc_fb[] = {
  344. {
  345. .start = MX2x_LCDC_BASE_ADDR,
  346. .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
  347. .flags = IORESOURCE_MEM,
  348. }, {
  349. .start = MX2x_INT_LCDC,
  350. .end = MX2x_INT_LCDC,
  351. .flags = IORESOURCE_IRQ,
  352. }
  353. };
  354. /* mxc lcd driver */
  355. struct platform_device mxc_fb_device = {
  356. .name = "imx-fb",
  357. .id = 0,
  358. .num_resources = ARRAY_SIZE(mxc_fb),
  359. .resource = mxc_fb,
  360. .dev = {
  361. .coherent_dma_mask = DMA_BIT_MASK(32),
  362. },
  363. };
  364. #ifdef CONFIG_MACH_MX27
  365. static struct resource mxc_fec_resources[] = {
  366. {
  367. .start = MX27_FEC_BASE_ADDR,
  368. .end = MX27_FEC_BASE_ADDR + SZ_4K - 1,
  369. .flags = IORESOURCE_MEM,
  370. }, {
  371. .start = MX27_INT_FEC,
  372. .end = MX27_INT_FEC,
  373. .flags = IORESOURCE_IRQ,
  374. },
  375. };
  376. struct platform_device mxc_fec_device = {
  377. .name = "fec",
  378. .id = 0,
  379. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  380. .resource = mxc_fec_resources,
  381. };
  382. #endif
  383. #define DEFINE_IMX_I2C_DEVICE(n, baseaddr, irq) \
  384. static struct resource mxc_i2c_resources ## n[] = { \
  385. { \
  386. .start = baseaddr, \
  387. .end = baseaddr + SZ_4K - 1, \
  388. .flags = IORESOURCE_MEM, \
  389. }, { \
  390. .start = irq, \
  391. .end = irq, \
  392. .flags = IORESOURCE_IRQ, \
  393. } \
  394. }; \
  395. \
  396. struct platform_device mxc_i2c_device ## n = { \
  397. .name = "imx-i2c", \
  398. .id = n, \
  399. .num_resources = ARRAY_SIZE(mxc_i2c_resources ## n), \
  400. .resource = mxc_i2c_resources ## n, \
  401. }
  402. DEFINE_IMX_I2C_DEVICE(0, MX2x_I2C_BASE_ADDR, MX2x_INT_I2C);
  403. #ifdef CONFIG_MACH_MX27
  404. DEFINE_IMX_I2C_DEVICE(1, MX27_I2C2_BASE_ADDR, MX27_INT_I2C2);
  405. #endif
  406. static struct resource mxc_pwm_resources[] = {
  407. {
  408. .start = MX2x_PWM_BASE_ADDR,
  409. .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
  410. .flags = IORESOURCE_MEM,
  411. }, {
  412. .start = MX2x_INT_PWM,
  413. .end = MX2x_INT_PWM,
  414. .flags = IORESOURCE_IRQ,
  415. }
  416. };
  417. struct platform_device mxc_pwm_device = {
  418. .name = "mxc_pwm",
  419. .id = 0,
  420. .num_resources = ARRAY_SIZE(mxc_pwm_resources),
  421. .resource = mxc_pwm_resources,
  422. };
  423. #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
  424. static struct resource mxc_sdhc_resources ## n[] = { \
  425. { \
  426. .start = baseaddr, \
  427. .end = baseaddr + SZ_4K - 1, \
  428. .flags = IORESOURCE_MEM, \
  429. }, { \
  430. .start = irq, \
  431. .end = irq, \
  432. .flags = IORESOURCE_IRQ, \
  433. }, { \
  434. .start = dmareq, \
  435. .end = dmareq, \
  436. .flags = IORESOURCE_DMA, \
  437. }, \
  438. }; \
  439. \
  440. static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
  441. \
  442. struct platform_device mxc_sdhc_device ## n = { \
  443. .name = "mxc-mmc", \
  444. .id = n, \
  445. .dev = { \
  446. .dma_mask = &mxc_sdhc ## n ## _dmamask, \
  447. .coherent_dma_mask = DMA_BIT_MASK(32), \
  448. }, \
  449. .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
  450. .resource = mxc_sdhc_resources ## n, \
  451. }
  452. DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
  453. DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
  454. #ifdef CONFIG_MACH_MX27
  455. static struct resource otg_resources[] = {
  456. {
  457. .start = MX27_USBOTG_BASE_ADDR,
  458. .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
  459. .flags = IORESOURCE_MEM,
  460. }, {
  461. .start = MX27_INT_USB3,
  462. .end = MX27_INT_USB3,
  463. .flags = IORESOURCE_IRQ,
  464. },
  465. };
  466. static u64 otg_dmamask = DMA_BIT_MASK(32);
  467. /* OTG gadget device */
  468. struct platform_device mxc_otg_udc_device = {
  469. .name = "fsl-usb2-udc",
  470. .id = -1,
  471. .dev = {
  472. .dma_mask = &otg_dmamask,
  473. .coherent_dma_mask = DMA_BIT_MASK(32),
  474. },
  475. .resource = otg_resources,
  476. .num_resources = ARRAY_SIZE(otg_resources),
  477. };
  478. /* OTG host */
  479. struct platform_device mxc_otg_host = {
  480. .name = "mxc-ehci",
  481. .id = 0,
  482. .dev = {
  483. .coherent_dma_mask = DMA_BIT_MASK(32),
  484. .dma_mask = &otg_dmamask,
  485. },
  486. .resource = otg_resources,
  487. .num_resources = ARRAY_SIZE(otg_resources),
  488. };
  489. /* USB host 1 */
  490. static u64 usbh1_dmamask = DMA_BIT_MASK(32);
  491. static struct resource mxc_usbh1_resources[] = {
  492. {
  493. .start = MX27_USBOTG_BASE_ADDR + 0x200,
  494. .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
  495. .flags = IORESOURCE_MEM,
  496. }, {
  497. .start = MX27_INT_USB1,
  498. .end = MX27_INT_USB1,
  499. .flags = IORESOURCE_IRQ,
  500. },
  501. };
  502. struct platform_device mxc_usbh1 = {
  503. .name = "mxc-ehci",
  504. .id = 1,
  505. .dev = {
  506. .coherent_dma_mask = DMA_BIT_MASK(32),
  507. .dma_mask = &usbh1_dmamask,
  508. },
  509. .resource = mxc_usbh1_resources,
  510. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  511. };
  512. /* USB host 2 */
  513. static u64 usbh2_dmamask = DMA_BIT_MASK(32);
  514. static struct resource mxc_usbh2_resources[] = {
  515. {
  516. .start = MX27_USBOTG_BASE_ADDR + 0x400,
  517. .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
  518. .flags = IORESOURCE_MEM,
  519. }, {
  520. .start = MX27_INT_USB2,
  521. .end = MX27_INT_USB2,
  522. .flags = IORESOURCE_IRQ,
  523. },
  524. };
  525. struct platform_device mxc_usbh2 = {
  526. .name = "mxc-ehci",
  527. .id = 2,
  528. .dev = {
  529. .coherent_dma_mask = DMA_BIT_MASK(32),
  530. .dma_mask = &usbh2_dmamask,
  531. },
  532. .resource = mxc_usbh2_resources,
  533. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  534. };
  535. #endif
  536. #define DEFINE_IMX_SSI_DMARES(_name, ssin, suffix) \
  537. { \
  538. .name = _name, \
  539. .start = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \
  540. .end = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \
  541. .flags = IORESOURCE_DMA, \
  542. }
  543. #define DEFINE_IMX_SSI_DEVICE(n, ssin, baseaddr, irq) \
  544. static struct resource imx_ssi_resources ## n[] = { \
  545. { \
  546. .start = MX2x_SSI ## ssin ## _BASE_ADDR, \
  547. .end = MX2x_SSI ## ssin ## _BASE_ADDR + 0x6f, \
  548. .flags = IORESOURCE_MEM, \
  549. }, { \
  550. .start = MX2x_INT_SSI1, \
  551. .end = MX2x_INT_SSI1, \
  552. .flags = IORESOURCE_IRQ, \
  553. }, \
  554. DEFINE_IMX_SSI_DMARES("tx0", ssin, TX0), \
  555. DEFINE_IMX_SSI_DMARES("rx0", ssin, RX0), \
  556. DEFINE_IMX_SSI_DMARES("tx1", ssin, TX1), \
  557. DEFINE_IMX_SSI_DMARES("rx1", ssin, RX1), \
  558. }; \
  559. \
  560. struct platform_device imx_ssi_device ## n = { \
  561. .name = "imx-ssi", \
  562. .id = n, \
  563. .num_resources = ARRAY_SIZE(imx_ssi_resources ## n), \
  564. .resource = imx_ssi_resources ## n, \
  565. }
  566. DEFINE_IMX_SSI_DEVICE(0, 1, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
  567. DEFINE_IMX_SSI_DEVICE(1, 2, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
  568. #define DEFINE_IMX2x_UART_DEVICE(n, baseaddr, irq) \
  569. static struct resource imx2x_uart_resources ## n[] = { \
  570. { \
  571. .start = baseaddr, \
  572. .end = baseaddr + 0xb5, \
  573. .flags = IORESOURCE_MEM, \
  574. }, { \
  575. .start = irq, \
  576. .end = irq, \
  577. .flags = IORESOURCE_IRQ, \
  578. }, \
  579. }; \
  580. \
  581. struct platform_device imx2x_uart_device ## n = { \
  582. .name = "imx-uart", \
  583. .id = n, \
  584. .num_resources = ARRAY_SIZE(imx2x_uart_resources ## n), \
  585. .resource = imx2x_uart_resources ## n, \
  586. }
  587. DEFINE_IMX2x_UART_DEVICE(0, MX2x_UART1_BASE_ADDR, MX2x_INT_UART1);
  588. DEFINE_IMX2x_UART_DEVICE(1, MX2x_UART2_BASE_ADDR, MX2x_INT_UART2);
  589. DEFINE_IMX2x_UART_DEVICE(2, MX2x_UART3_BASE_ADDR, MX2x_INT_UART3);
  590. DEFINE_IMX2x_UART_DEVICE(3, MX2x_UART4_BASE_ADDR, MX2x_INT_UART4);
  591. #ifdef CONFIG_MACH_MX27
  592. DEFINE_IMX2x_UART_DEVICE(4, MX27_UART5_BASE_ADDR, MX27_INT_UART5);
  593. DEFINE_IMX2x_UART_DEVICE(5, MX27_UART6_BASE_ADDR, MX27_INT_UART6);
  594. #endif
  595. /* GPIO port description */
  596. #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
  597. { \
  598. .chip.label = "gpio-" #n, \
  599. .irq = _irq, \
  600. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  601. n * 0x100), \
  602. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  603. }
  604. #define DEFINE_MXC_GPIO_PORT(SOC, n) \
  605. { \
  606. .chip.label = "gpio-" #n, \
  607. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  608. n * 0x100), \
  609. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  610. }
  611. #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
  612. static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
  613. DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
  614. DEFINE_MXC_GPIO_PORT(SOC, 1), \
  615. DEFINE_MXC_GPIO_PORT(SOC, 2), \
  616. DEFINE_MXC_GPIO_PORT(SOC, 3), \
  617. DEFINE_MXC_GPIO_PORT(SOC, 4), \
  618. DEFINE_MXC_GPIO_PORT(SOC, 5), \
  619. }
  620. #ifdef CONFIG_MACH_MX21
  621. DEFINE_MXC_GPIO_PORTS(MX21, imx21);
  622. int __init imx21_register_gpios(void)
  623. {
  624. return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
  625. }
  626. #endif
  627. #ifdef CONFIG_MACH_MX27
  628. DEFINE_MXC_GPIO_PORTS(MX27, imx27);
  629. int __init imx27_register_gpios(void)
  630. {
  631. return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
  632. }
  633. #endif
  634. #ifdef CONFIG_MACH_MX21
  635. static struct resource mx21_usbhc_resources[] = {
  636. {
  637. .start = MX21_USBOTG_BASE_ADDR,
  638. .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
  639. .flags = IORESOURCE_MEM,
  640. },
  641. {
  642. .start = MX21_INT_USBHOST,
  643. .end = MX21_INT_USBHOST,
  644. .flags = IORESOURCE_IRQ,
  645. },
  646. };
  647. struct platform_device mx21_usbhc_device = {
  648. .name = "imx21-hcd",
  649. .id = 0,
  650. .dev = {
  651. .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
  652. .coherent_dma_mask = DMA_BIT_MASK(32),
  653. },
  654. .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
  655. .resource = mx21_usbhc_resources,
  656. };
  657. #endif
  658. #endif