devices.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. * Resource definition for the MXC IrDA
  41. */
  42. static struct resource mxc_irda_resources[] = {
  43. [0] = {
  44. .start = UART3_BASE_ADDR,
  45. .end = UART3_BASE_ADDR + SZ_4K - 1,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. [1] = {
  49. .start = MXC_INT_UART3,
  50. .end = MXC_INT_UART3,
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. };
  54. /* Platform Data for MXC IrDA */
  55. struct platform_device mxc_irda_device = {
  56. .name = "mxc_irda",
  57. .id = 0,
  58. .num_resources = ARRAY_SIZE(mxc_irda_resources),
  59. .resource = mxc_irda_resources,
  60. };
  61. /*
  62. * General Purpose Timer
  63. * - i.MX1: 2 timer (slighly different register handling)
  64. * - i.MX21: 3 timer
  65. * - i.MX27: 6 timer
  66. */
  67. /* We use gpt0 as system timer, so do not add a device for this one */
  68. static struct resource timer1_resources[] = {
  69. [0] = {
  70. .start = GPT2_BASE_ADDR,
  71. .end = GPT2_BASE_ADDR + 0x17,
  72. .flags = IORESOURCE_MEM
  73. },
  74. [1] = {
  75. .start = MXC_INT_GPT2,
  76. .end = MXC_INT_GPT2,
  77. .flags = IORESOURCE_IRQ,
  78. }
  79. };
  80. struct platform_device mxc_gpt1 = {
  81. .name = "imx_gpt",
  82. .id = 1,
  83. .num_resources = ARRAY_SIZE(timer1_resources),
  84. .resource = timer1_resources
  85. };
  86. static struct resource timer2_resources[] = {
  87. [0] = {
  88. .start = GPT3_BASE_ADDR,
  89. .end = GPT3_BASE_ADDR + 0x17,
  90. .flags = IORESOURCE_MEM
  91. },
  92. [1] = {
  93. .start = MXC_INT_GPT3,
  94. .end = MXC_INT_GPT3,
  95. .flags = IORESOURCE_IRQ,
  96. }
  97. };
  98. struct platform_device mxc_gpt2 = {
  99. .name = "imx_gpt",
  100. .id = 2,
  101. .num_resources = ARRAY_SIZE(timer2_resources),
  102. .resource = timer2_resources
  103. };
  104. #ifdef CONFIG_MACH_MX27
  105. static struct resource timer3_resources[] = {
  106. [0] = {
  107. .start = GPT4_BASE_ADDR,
  108. .end = GPT4_BASE_ADDR + 0x17,
  109. .flags = IORESOURCE_MEM
  110. },
  111. [1] = {
  112. .start = MXC_INT_GPT4,
  113. .end = MXC_INT_GPT4,
  114. .flags = IORESOURCE_IRQ,
  115. }
  116. };
  117. struct platform_device mxc_gpt3 = {
  118. .name = "imx_gpt",
  119. .id = 3,
  120. .num_resources = ARRAY_SIZE(timer3_resources),
  121. .resource = timer3_resources
  122. };
  123. static struct resource timer4_resources[] = {
  124. [0] = {
  125. .start = GPT5_BASE_ADDR,
  126. .end = GPT5_BASE_ADDR + 0x17,
  127. .flags = IORESOURCE_MEM
  128. },
  129. [1] = {
  130. .start = MXC_INT_GPT5,
  131. .end = MXC_INT_GPT5,
  132. .flags = IORESOURCE_IRQ,
  133. }
  134. };
  135. struct platform_device mxc_gpt4 = {
  136. .name = "imx_gpt",
  137. .id = 4,
  138. .num_resources = ARRAY_SIZE(timer4_resources),
  139. .resource = timer4_resources
  140. };
  141. static struct resource timer5_resources[] = {
  142. [0] = {
  143. .start = GPT6_BASE_ADDR,
  144. .end = GPT6_BASE_ADDR + 0x17,
  145. .flags = IORESOURCE_MEM
  146. },
  147. [1] = {
  148. .start = MXC_INT_GPT6,
  149. .end = MXC_INT_GPT6,
  150. .flags = IORESOURCE_IRQ,
  151. }
  152. };
  153. struct platform_device mxc_gpt5 = {
  154. .name = "imx_gpt",
  155. .id = 5,
  156. .num_resources = ARRAY_SIZE(timer5_resources),
  157. .resource = timer5_resources
  158. };
  159. #endif
  160. /*
  161. * Watchdog:
  162. * - i.MX1
  163. * - i.MX21
  164. * - i.MX27
  165. */
  166. static struct resource mxc_wdt_resources[] = {
  167. {
  168. .start = WDOG_BASE_ADDR,
  169. .end = WDOG_BASE_ADDR + 0x30,
  170. .flags = IORESOURCE_MEM,
  171. },
  172. };
  173. struct platform_device mxc_wdt = {
  174. .name = "mxc_wdt",
  175. .id = 0,
  176. .num_resources = ARRAY_SIZE(mxc_wdt_resources),
  177. .resource = mxc_wdt_resources,
  178. };
  179. static struct resource mxc_w1_master_resources[] = {
  180. {
  181. .start = OWIRE_BASE_ADDR,
  182. .end = OWIRE_BASE_ADDR + SZ_4K - 1,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. };
  186. struct platform_device mxc_w1_master_device = {
  187. .name = "mxc_w1",
  188. .id = 0,
  189. .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
  190. .resource = mxc_w1_master_resources,
  191. };
  192. static struct resource mxc_nand_resources[] = {
  193. {
  194. .start = NFC_BASE_ADDR,
  195. .end = NFC_BASE_ADDR + 0xfff,
  196. .flags = IORESOURCE_MEM
  197. }, {
  198. .start = MXC_INT_NANDFC,
  199. .end = MXC_INT_NANDFC,
  200. .flags = IORESOURCE_IRQ
  201. },
  202. };
  203. struct platform_device mxc_nand_device = {
  204. .name = "mxc_nand",
  205. .id = 0,
  206. .num_resources = ARRAY_SIZE(mxc_nand_resources),
  207. .resource = mxc_nand_resources,
  208. };
  209. /*
  210. * lcdc:
  211. * - i.MX1: the basic controller
  212. * - i.MX21: to be checked
  213. * - i.MX27: like i.MX1, with slightly variations
  214. */
  215. static struct resource mxc_fb[] = {
  216. {
  217. .start = LCDC_BASE_ADDR,
  218. .end = LCDC_BASE_ADDR + 0xFFF,
  219. .flags = IORESOURCE_MEM,
  220. },
  221. {
  222. .start = MXC_INT_LCDC,
  223. .end = MXC_INT_LCDC,
  224. .flags = IORESOURCE_IRQ,
  225. }
  226. };
  227. /* mxc lcd driver */
  228. struct platform_device mxc_fb_device = {
  229. .name = "imx-fb",
  230. .id = 0,
  231. .num_resources = ARRAY_SIZE(mxc_fb),
  232. .resource = mxc_fb,
  233. .dev = {
  234. .coherent_dma_mask = 0xFFFFFFFF,
  235. },
  236. };
  237. #ifdef CONFIG_MACH_MX27
  238. static struct resource mxc_fec_resources[] = {
  239. {
  240. .start = FEC_BASE_ADDR,
  241. .end = FEC_BASE_ADDR + 0xfff,
  242. .flags = IORESOURCE_MEM
  243. }, {
  244. .start = MXC_INT_FEC,
  245. .end = MXC_INT_FEC,
  246. .flags = IORESOURCE_IRQ
  247. },
  248. };
  249. struct platform_device mxc_fec_device = {
  250. .name = "fec",
  251. .id = 0,
  252. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  253. .resource = mxc_fec_resources,
  254. };
  255. #endif
  256. static struct resource mxc_i2c_1_resources[] = {
  257. [0] = {
  258. .start = I2C_BASE_ADDR,
  259. .end = I2C_BASE_ADDR + 0x0fff,
  260. .flags = IORESOURCE_MEM
  261. },
  262. [1] = {
  263. .start = MXC_INT_I2C,
  264. .end = MXC_INT_I2C,
  265. .flags = IORESOURCE_IRQ
  266. }
  267. };
  268. struct platform_device mxc_i2c_device0 = {
  269. .name = "imx-i2c",
  270. .id = 0,
  271. .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
  272. .resource = mxc_i2c_1_resources
  273. };
  274. #ifdef CONFIG_MACH_MX27
  275. static struct resource mxc_i2c_2_resources[] = {
  276. [0] = {
  277. .start = I2C2_BASE_ADDR,
  278. .end = I2C2_BASE_ADDR + 0x0fff,
  279. .flags = IORESOURCE_MEM
  280. },
  281. [1] = {
  282. .start = MXC_INT_I2C2,
  283. .end = MXC_INT_I2C2,
  284. .flags = IORESOURCE_IRQ
  285. }
  286. };
  287. struct platform_device mxc_i2c_device1 = {
  288. .name = "imx-i2c",
  289. .id = 1,
  290. .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
  291. .resource = mxc_i2c_2_resources
  292. };
  293. #endif
  294. static struct resource mxc_pwm_resources[] = {
  295. [0] = {
  296. .start = PWM_BASE_ADDR,
  297. .end = PWM_BASE_ADDR + 0x0fff,
  298. .flags = IORESOURCE_MEM
  299. },
  300. [1] = {
  301. .start = MXC_INT_PWM,
  302. .end = MXC_INT_PWM,
  303. .flags = IORESOURCE_IRQ,
  304. }
  305. };
  306. struct platform_device mxc_pwm_device = {
  307. .name = "mxc_pwm",
  308. .id = 0,
  309. .num_resources = ARRAY_SIZE(mxc_pwm_resources),
  310. .resource = mxc_pwm_resources
  311. };
  312. /*
  313. * Resource definition for the MXC SDHC
  314. */
  315. static struct resource mxc_sdhc1_resources[] = {
  316. [0] = {
  317. .start = SDHC1_BASE_ADDR,
  318. .end = SDHC1_BASE_ADDR + SZ_4K - 1,
  319. .flags = IORESOURCE_MEM,
  320. },
  321. [1] = {
  322. .start = MXC_INT_SDHC1,
  323. .end = MXC_INT_SDHC1,
  324. .flags = IORESOURCE_IRQ,
  325. },
  326. [2] = {
  327. .start = DMA_REQ_SDHC1,
  328. .end = DMA_REQ_SDHC1,
  329. .flags = IORESOURCE_DMA
  330. },
  331. };
  332. static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
  333. struct platform_device mxc_sdhc_device0 = {
  334. .name = "mxc-mmc",
  335. .id = 0,
  336. .dev = {
  337. .dma_mask = &mxc_sdhc1_dmamask,
  338. .coherent_dma_mask = 0xffffffff,
  339. },
  340. .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
  341. .resource = mxc_sdhc1_resources,
  342. };
  343. static struct resource mxc_sdhc2_resources[] = {
  344. [0] = {
  345. .start = SDHC2_BASE_ADDR,
  346. .end = SDHC2_BASE_ADDR + SZ_4K - 1,
  347. .flags = IORESOURCE_MEM,
  348. },
  349. [1] = {
  350. .start = MXC_INT_SDHC2,
  351. .end = MXC_INT_SDHC2,
  352. .flags = IORESOURCE_IRQ,
  353. },
  354. [2] = {
  355. .start = DMA_REQ_SDHC2,
  356. .end = DMA_REQ_SDHC2,
  357. .flags = IORESOURCE_DMA
  358. },
  359. };
  360. static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
  361. struct platform_device mxc_sdhc_device1 = {
  362. .name = "mxc-mmc",
  363. .id = 1,
  364. .dev = {
  365. .dma_mask = &mxc_sdhc2_dmamask,
  366. .coherent_dma_mask = 0xffffffff,
  367. },
  368. .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
  369. .resource = mxc_sdhc2_resources,
  370. };
  371. /* GPIO port description */
  372. static struct mxc_gpio_port imx_gpio_ports[] = {
  373. [0] = {
  374. .chip.label = "gpio-0",
  375. .irq = MXC_INT_GPIO,
  376. .base = IO_ADDRESS(GPIO_BASE_ADDR),
  377. .virtual_irq_start = MXC_GPIO_IRQ_START,
  378. },
  379. [1] = {
  380. .chip.label = "gpio-1",
  381. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
  382. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  383. },
  384. [2] = {
  385. .chip.label = "gpio-2",
  386. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
  387. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  388. },
  389. [3] = {
  390. .chip.label = "gpio-3",
  391. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
  392. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  393. },
  394. [4] = {
  395. .chip.label = "gpio-4",
  396. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
  397. .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
  398. },
  399. [5] = {
  400. .chip.label = "gpio-5",
  401. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
  402. .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
  403. }
  404. };
  405. int __init mxc_register_gpios(void)
  406. {
  407. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  408. }