devices.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version 2
  18. * of the License, or (at your option) any later version.
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  27. * MA 02110-1301, USA.
  28. */
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/init.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/gpio.h>
  34. #include <mach/irqs.h>
  35. #include <mach/hardware.h>
  36. #include <mach/common.h>
  37. #include <mach/mmc.h>
  38. #include "devices.h"
  39. /*
  40. * SPI master controller
  41. *
  42. * - i.MX1: 2 channel (slighly different register setting)
  43. * - i.MX21: 2 channel
  44. * - i.MX27: 3 channel
  45. */
  46. static struct resource mxc_spi_resources0[] = {
  47. {
  48. .start = CSPI1_BASE_ADDR,
  49. .end = CSPI1_BASE_ADDR + SZ_4K - 1,
  50. .flags = IORESOURCE_MEM,
  51. }, {
  52. .start = MXC_INT_CSPI1,
  53. .end = MXC_INT_CSPI1,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. };
  57. static struct resource mxc_spi_resources1[] = {
  58. {
  59. .start = CSPI2_BASE_ADDR,
  60. .end = CSPI2_BASE_ADDR + SZ_4K - 1,
  61. .flags = IORESOURCE_MEM,
  62. }, {
  63. .start = MXC_INT_CSPI2,
  64. .end = MXC_INT_CSPI2,
  65. .flags = IORESOURCE_IRQ,
  66. },
  67. };
  68. #ifdef CONFIG_MACH_MX27
  69. static struct resource mxc_spi_resources2[] = {
  70. {
  71. .start = CSPI3_BASE_ADDR,
  72. .end = CSPI3_BASE_ADDR + SZ_4K - 1,
  73. .flags = IORESOURCE_MEM,
  74. }, {
  75. .start = MXC_INT_CSPI3,
  76. .end = MXC_INT_CSPI3,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. #endif
  81. struct platform_device mxc_spi_device0 = {
  82. .name = "spi_imx",
  83. .id = 0,
  84. .num_resources = ARRAY_SIZE(mxc_spi_resources0),
  85. .resource = mxc_spi_resources0,
  86. };
  87. struct platform_device mxc_spi_device1 = {
  88. .name = "spi_imx",
  89. .id = 1,
  90. .num_resources = ARRAY_SIZE(mxc_spi_resources1),
  91. .resource = mxc_spi_resources1,
  92. };
  93. #ifdef CONFIG_MACH_MX27
  94. struct platform_device mxc_spi_device2 = {
  95. .name = "spi_imx",
  96. .id = 2,
  97. .num_resources = ARRAY_SIZE(mxc_spi_resources2),
  98. .resource = mxc_spi_resources2,
  99. };
  100. #endif
  101. /*
  102. * General Purpose Timer
  103. * - i.MX21: 3 timers
  104. * - i.MX27: 6 timers
  105. */
  106. /* We use gpt0 as system timer, so do not add a device for this one */
  107. static struct resource timer1_resources[] = {
  108. {
  109. .start = GPT2_BASE_ADDR,
  110. .end = GPT2_BASE_ADDR + 0x17,
  111. .flags = IORESOURCE_MEM,
  112. }, {
  113. .start = MXC_INT_GPT2,
  114. .end = MXC_INT_GPT2,
  115. .flags = IORESOURCE_IRQ,
  116. }
  117. };
  118. struct platform_device mxc_gpt1 = {
  119. .name = "imx_gpt",
  120. .id = 1,
  121. .num_resources = ARRAY_SIZE(timer1_resources),
  122. .resource = timer1_resources,
  123. };
  124. static struct resource timer2_resources[] = {
  125. {
  126. .start = GPT3_BASE_ADDR,
  127. .end = GPT3_BASE_ADDR + 0x17,
  128. .flags = IORESOURCE_MEM,
  129. }, {
  130. .start = MXC_INT_GPT3,
  131. .end = MXC_INT_GPT3,
  132. .flags = IORESOURCE_IRQ,
  133. }
  134. };
  135. struct platform_device mxc_gpt2 = {
  136. .name = "imx_gpt",
  137. .id = 2,
  138. .num_resources = ARRAY_SIZE(timer2_resources),
  139. .resource = timer2_resources,
  140. };
  141. #ifdef CONFIG_MACH_MX27
  142. static struct resource timer3_resources[] = {
  143. {
  144. .start = GPT4_BASE_ADDR,
  145. .end = GPT4_BASE_ADDR + 0x17,
  146. .flags = IORESOURCE_MEM,
  147. }, {
  148. .start = MXC_INT_GPT4,
  149. .end = MXC_INT_GPT4,
  150. .flags = IORESOURCE_IRQ,
  151. }
  152. };
  153. struct platform_device mxc_gpt3 = {
  154. .name = "imx_gpt",
  155. .id = 3,
  156. .num_resources = ARRAY_SIZE(timer3_resources),
  157. .resource = timer3_resources,
  158. };
  159. static struct resource timer4_resources[] = {
  160. {
  161. .start = GPT5_BASE_ADDR,
  162. .end = GPT5_BASE_ADDR + 0x17,
  163. .flags = IORESOURCE_MEM,
  164. }, {
  165. .start = MXC_INT_GPT5,
  166. .end = MXC_INT_GPT5,
  167. .flags = IORESOURCE_IRQ,
  168. }
  169. };
  170. struct platform_device mxc_gpt4 = {
  171. .name = "imx_gpt",
  172. .id = 4,
  173. .num_resources = ARRAY_SIZE(timer4_resources),
  174. .resource = timer4_resources,
  175. };
  176. static struct resource timer5_resources[] = {
  177. {
  178. .start = GPT6_BASE_ADDR,
  179. .end = GPT6_BASE_ADDR + 0x17,
  180. .flags = IORESOURCE_MEM,
  181. }, {
  182. .start = MXC_INT_GPT6,
  183. .end = MXC_INT_GPT6,
  184. .flags = IORESOURCE_IRQ,
  185. }
  186. };
  187. struct platform_device mxc_gpt5 = {
  188. .name = "imx_gpt",
  189. .id = 5,
  190. .num_resources = ARRAY_SIZE(timer5_resources),
  191. .resource = timer5_resources,
  192. };
  193. #endif
  194. /*
  195. * Watchdog:
  196. * - i.MX1
  197. * - i.MX21
  198. * - i.MX27
  199. */
  200. static struct resource mxc_wdt_resources[] = {
  201. {
  202. .start = WDOG_BASE_ADDR,
  203. .end = WDOG_BASE_ADDR + 0x30,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. };
  207. struct platform_device mxc_wdt = {
  208. .name = "mxc_wdt",
  209. .id = 0,
  210. .num_resources = ARRAY_SIZE(mxc_wdt_resources),
  211. .resource = mxc_wdt_resources,
  212. };
  213. static struct resource mxc_w1_master_resources[] = {
  214. {
  215. .start = OWIRE_BASE_ADDR,
  216. .end = OWIRE_BASE_ADDR + SZ_4K - 1,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. };
  220. struct platform_device mxc_w1_master_device = {
  221. .name = "mxc_w1",
  222. .id = 0,
  223. .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
  224. .resource = mxc_w1_master_resources,
  225. };
  226. static struct resource mxc_nand_resources[] = {
  227. {
  228. .start = NFC_BASE_ADDR,
  229. .end = NFC_BASE_ADDR + 0xfff,
  230. .flags = IORESOURCE_MEM,
  231. }, {
  232. .start = MXC_INT_NANDFC,
  233. .end = MXC_INT_NANDFC,
  234. .flags = IORESOURCE_IRQ,
  235. },
  236. };
  237. struct platform_device mxc_nand_device = {
  238. .name = "mxc_nand",
  239. .id = 0,
  240. .num_resources = ARRAY_SIZE(mxc_nand_resources),
  241. .resource = mxc_nand_resources,
  242. };
  243. /*
  244. * lcdc:
  245. * - i.MX1: the basic controller
  246. * - i.MX21: to be checked
  247. * - i.MX27: like i.MX1, with slightly variations
  248. */
  249. static struct resource mxc_fb[] = {
  250. {
  251. .start = LCDC_BASE_ADDR,
  252. .end = LCDC_BASE_ADDR + 0xFFF,
  253. .flags = IORESOURCE_MEM,
  254. }, {
  255. .start = MXC_INT_LCDC,
  256. .end = MXC_INT_LCDC,
  257. .flags = IORESOURCE_IRQ,
  258. }
  259. };
  260. /* mxc lcd driver */
  261. struct platform_device mxc_fb_device = {
  262. .name = "imx-fb",
  263. .id = 0,
  264. .num_resources = ARRAY_SIZE(mxc_fb),
  265. .resource = mxc_fb,
  266. .dev = {
  267. .coherent_dma_mask = 0xFFFFFFFF,
  268. },
  269. };
  270. #ifdef CONFIG_MACH_MX27
  271. static struct resource mxc_fec_resources[] = {
  272. {
  273. .start = FEC_BASE_ADDR,
  274. .end = FEC_BASE_ADDR + 0xfff,
  275. .flags = IORESOURCE_MEM,
  276. }, {
  277. .start = MXC_INT_FEC,
  278. .end = MXC_INT_FEC,
  279. .flags = IORESOURCE_IRQ,
  280. },
  281. };
  282. struct platform_device mxc_fec_device = {
  283. .name = "fec",
  284. .id = 0,
  285. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  286. .resource = mxc_fec_resources,
  287. };
  288. #endif
  289. static struct resource mxc_i2c_1_resources[] = {
  290. {
  291. .start = I2C_BASE_ADDR,
  292. .end = I2C_BASE_ADDR + 0x0fff,
  293. .flags = IORESOURCE_MEM,
  294. }, {
  295. .start = MXC_INT_I2C,
  296. .end = MXC_INT_I2C,
  297. .flags = IORESOURCE_IRQ,
  298. }
  299. };
  300. struct platform_device mxc_i2c_device0 = {
  301. .name = "imx-i2c",
  302. .id = 0,
  303. .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
  304. .resource = mxc_i2c_1_resources,
  305. };
  306. #ifdef CONFIG_MACH_MX27
  307. static struct resource mxc_i2c_2_resources[] = {
  308. {
  309. .start = I2C2_BASE_ADDR,
  310. .end = I2C2_BASE_ADDR + 0x0fff,
  311. .flags = IORESOURCE_MEM,
  312. }, {
  313. .start = MXC_INT_I2C2,
  314. .end = MXC_INT_I2C2,
  315. .flags = IORESOURCE_IRQ,
  316. }
  317. };
  318. struct platform_device mxc_i2c_device1 = {
  319. .name = "imx-i2c",
  320. .id = 1,
  321. .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
  322. .resource = mxc_i2c_2_resources,
  323. };
  324. #endif
  325. static struct resource mxc_pwm_resources[] = {
  326. {
  327. .start = PWM_BASE_ADDR,
  328. .end = PWM_BASE_ADDR + 0x0fff,
  329. .flags = IORESOURCE_MEM,
  330. }, {
  331. .start = MXC_INT_PWM,
  332. .end = MXC_INT_PWM,
  333. .flags = IORESOURCE_IRQ,
  334. }
  335. };
  336. struct platform_device mxc_pwm_device = {
  337. .name = "mxc_pwm",
  338. .id = 0,
  339. .num_resources = ARRAY_SIZE(mxc_pwm_resources),
  340. .resource = mxc_pwm_resources,
  341. };
  342. /*
  343. * Resource definition for the MXC SDHC
  344. */
  345. static struct resource mxc_sdhc1_resources[] = {
  346. {
  347. .start = SDHC1_BASE_ADDR,
  348. .end = SDHC1_BASE_ADDR + SZ_4K - 1,
  349. .flags = IORESOURCE_MEM,
  350. }, {
  351. .start = MXC_INT_SDHC1,
  352. .end = MXC_INT_SDHC1,
  353. .flags = IORESOURCE_IRQ,
  354. }, {
  355. .start = DMA_REQ_SDHC1,
  356. .end = DMA_REQ_SDHC1,
  357. .flags = IORESOURCE_DMA,
  358. },
  359. };
  360. static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
  361. struct platform_device mxc_sdhc_device0 = {
  362. .name = "mxc-mmc",
  363. .id = 0,
  364. .dev = {
  365. .dma_mask = &mxc_sdhc1_dmamask,
  366. .coherent_dma_mask = 0xffffffff,
  367. },
  368. .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
  369. .resource = mxc_sdhc1_resources,
  370. };
  371. static struct resource mxc_sdhc2_resources[] = {
  372. {
  373. .start = SDHC2_BASE_ADDR,
  374. .end = SDHC2_BASE_ADDR + SZ_4K - 1,
  375. .flags = IORESOURCE_MEM,
  376. }, {
  377. .start = MXC_INT_SDHC2,
  378. .end = MXC_INT_SDHC2,
  379. .flags = IORESOURCE_IRQ,
  380. }, {
  381. .start = DMA_REQ_SDHC2,
  382. .end = DMA_REQ_SDHC2,
  383. .flags = IORESOURCE_DMA,
  384. },
  385. };
  386. static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
  387. struct platform_device mxc_sdhc_device1 = {
  388. .name = "mxc-mmc",
  389. .id = 1,
  390. .dev = {
  391. .dma_mask = &mxc_sdhc2_dmamask,
  392. .coherent_dma_mask = 0xffffffff,
  393. },
  394. .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
  395. .resource = mxc_sdhc2_resources,
  396. };
  397. #ifdef CONFIG_MACH_MX27
  398. static struct resource otg_resources[] = {
  399. {
  400. .start = OTG_BASE_ADDR,
  401. .end = OTG_BASE_ADDR + 0x1ff,
  402. .flags = IORESOURCE_MEM,
  403. }, {
  404. .start = MXC_INT_USB3,
  405. .end = MXC_INT_USB3,
  406. .flags = IORESOURCE_IRQ,
  407. },
  408. };
  409. static u64 otg_dmamask = 0xffffffffUL;
  410. /* OTG gadget device */
  411. struct platform_device mxc_otg_udc_device = {
  412. .name = "fsl-usb2-udc",
  413. .id = -1,
  414. .dev = {
  415. .dma_mask = &otg_dmamask,
  416. .coherent_dma_mask = 0xffffffffUL,
  417. },
  418. .resource = otg_resources,
  419. .num_resources = ARRAY_SIZE(otg_resources),
  420. };
  421. /* OTG host */
  422. struct platform_device mxc_otg_host = {
  423. .name = "mxc-ehci",
  424. .id = 0,
  425. .dev = {
  426. .coherent_dma_mask = 0xffffffff,
  427. .dma_mask = &otg_dmamask,
  428. },
  429. .resource = otg_resources,
  430. .num_resources = ARRAY_SIZE(otg_resources),
  431. };
  432. /* USB host 1 */
  433. static u64 usbh1_dmamask = 0xffffffffUL;
  434. static struct resource mxc_usbh1_resources[] = {
  435. {
  436. .start = OTG_BASE_ADDR + 0x200,
  437. .end = OTG_BASE_ADDR + 0x3ff,
  438. .flags = IORESOURCE_MEM,
  439. }, {
  440. .start = MXC_INT_USB1,
  441. .end = MXC_INT_USB1,
  442. .flags = IORESOURCE_IRQ,
  443. },
  444. };
  445. struct platform_device mxc_usbh1 = {
  446. .name = "mxc-ehci",
  447. .id = 1,
  448. .dev = {
  449. .coherent_dma_mask = 0xffffffff,
  450. .dma_mask = &usbh1_dmamask,
  451. },
  452. .resource = mxc_usbh1_resources,
  453. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  454. };
  455. /* USB host 2 */
  456. static u64 usbh2_dmamask = 0xffffffffUL;
  457. static struct resource mxc_usbh2_resources[] = {
  458. {
  459. .start = OTG_BASE_ADDR + 0x400,
  460. .end = OTG_BASE_ADDR + 0x5ff,
  461. .flags = IORESOURCE_MEM,
  462. }, {
  463. .start = MXC_INT_USB2,
  464. .end = MXC_INT_USB2,
  465. .flags = IORESOURCE_IRQ,
  466. },
  467. };
  468. struct platform_device mxc_usbh2 = {
  469. .name = "mxc-ehci",
  470. .id = 2,
  471. .dev = {
  472. .coherent_dma_mask = 0xffffffff,
  473. .dma_mask = &usbh2_dmamask,
  474. },
  475. .resource = mxc_usbh2_resources,
  476. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  477. };
  478. #endif
  479. /* GPIO port description */
  480. static struct mxc_gpio_port imx_gpio_ports[] = {
  481. {
  482. .chip.label = "gpio-0",
  483. .irq = MXC_INT_GPIO,
  484. .base = IO_ADDRESS(GPIO_BASE_ADDR),
  485. .virtual_irq_start = MXC_GPIO_IRQ_START,
  486. }, {
  487. .chip.label = "gpio-1",
  488. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
  489. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  490. }, {
  491. .chip.label = "gpio-2",
  492. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
  493. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  494. }, {
  495. .chip.label = "gpio-3",
  496. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
  497. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  498. }, {
  499. .chip.label = "gpio-4",
  500. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
  501. .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
  502. }, {
  503. .chip.label = "gpio-5",
  504. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
  505. .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
  506. }
  507. };
  508. int __init mxc_register_gpios(void)
  509. {
  510. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  511. }