devices.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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. #ifdef CONFIG_FB_IMX
  210. /*
  211. * lcdc:
  212. * - i.MX1: the basic controller
  213. * - i.MX21: to be checked
  214. * - i.MX27: like i.MX1, with slightly variations
  215. */
  216. static struct resource mxc_fb[] = {
  217. {
  218. .start = LCDC_BASE_ADDR,
  219. .end = LCDC_BASE_ADDR + 0xFFF,
  220. .flags = IORESOURCE_MEM,
  221. },
  222. {
  223. .start = MXC_INT_LCDC,
  224. .end = MXC_INT_LCDC,
  225. .flags = IORESOURCE_IRQ,
  226. }
  227. };
  228. /* mxc lcd driver */
  229. struct platform_device mxc_fb_device = {
  230. .name = "imx-fb",
  231. .id = 0,
  232. .num_resources = ARRAY_SIZE(mxc_fb),
  233. .resource = mxc_fb,
  234. .dev = {
  235. .coherent_dma_mask = 0xFFFFFFFF,
  236. },
  237. };
  238. #endif
  239. #ifdef CONFIG_MACH_MX27
  240. static struct resource mxc_fec_resources[] = {
  241. {
  242. .start = FEC_BASE_ADDR,
  243. .end = FEC_BASE_ADDR + 0xfff,
  244. .flags = IORESOURCE_MEM
  245. }, {
  246. .start = MXC_INT_FEC,
  247. .end = MXC_INT_FEC,
  248. .flags = IORESOURCE_IRQ
  249. },
  250. };
  251. struct platform_device mxc_fec_device = {
  252. .name = "fec",
  253. .id = 0,
  254. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  255. .resource = mxc_fec_resources,
  256. };
  257. #endif
  258. static struct resource mxc_i2c_1_resources[] = {
  259. [0] = {
  260. .start = I2C_BASE_ADDR,
  261. .end = I2C_BASE_ADDR + 0x0fff,
  262. .flags = IORESOURCE_MEM
  263. },
  264. [1] = {
  265. .start = MXC_INT_I2C,
  266. .end = MXC_INT_I2C,
  267. .flags = IORESOURCE_IRQ
  268. }
  269. };
  270. struct platform_device mxc_i2c_device0 = {
  271. .name = "imx-i2c",
  272. .id = 0,
  273. .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
  274. .resource = mxc_i2c_1_resources
  275. };
  276. #ifdef CONFIG_MACH_MX27
  277. static struct resource mxc_i2c_2_resources[] = {
  278. [0] = {
  279. .start = I2C2_BASE_ADDR,
  280. .end = I2C2_BASE_ADDR + 0x0fff,
  281. .flags = IORESOURCE_MEM
  282. },
  283. [1] = {
  284. .start = MXC_INT_I2C2,
  285. .end = MXC_INT_I2C2,
  286. .flags = IORESOURCE_IRQ
  287. }
  288. };
  289. struct platform_device mxc_i2c_device1 = {
  290. .name = "imx-i2c",
  291. .id = 1,
  292. .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
  293. .resource = mxc_i2c_2_resources
  294. };
  295. #endif
  296. static struct resource mxc_pwm_resources[] = {
  297. [0] = {
  298. .start = PWM_BASE_ADDR,
  299. .end = PWM_BASE_ADDR + 0x0fff,
  300. .flags = IORESOURCE_MEM
  301. },
  302. [1] = {
  303. .start = MXC_INT_PWM,
  304. .end = MXC_INT_PWM,
  305. .flags = IORESOURCE_IRQ,
  306. }
  307. };
  308. struct platform_device mxc_pwm_device = {
  309. .name = "mxc_pwm",
  310. .id = 0,
  311. .num_resources = ARRAY_SIZE(mxc_pwm_resources),
  312. .resource = mxc_pwm_resources
  313. };
  314. /*
  315. * Resource definition for the MXC SDHC
  316. */
  317. static struct resource mxc_sdhc1_resources[] = {
  318. [0] = {
  319. .start = SDHC1_BASE_ADDR,
  320. .end = SDHC1_BASE_ADDR + SZ_4K - 1,
  321. .flags = IORESOURCE_MEM,
  322. },
  323. [1] = {
  324. .start = MXC_INT_SDHC1,
  325. .end = MXC_INT_SDHC1,
  326. .flags = IORESOURCE_IRQ,
  327. },
  328. [2] = {
  329. .start = DMA_REQ_SDHC1,
  330. .end = DMA_REQ_SDHC1,
  331. .flags = IORESOURCE_DMA
  332. },
  333. };
  334. static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
  335. struct platform_device mxc_sdhc_device0 = {
  336. .name = "mxc-mmc",
  337. .id = 0,
  338. .dev = {
  339. .dma_mask = &mxc_sdhc1_dmamask,
  340. .coherent_dma_mask = 0xffffffff,
  341. },
  342. .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
  343. .resource = mxc_sdhc1_resources,
  344. };
  345. static struct resource mxc_sdhc2_resources[] = {
  346. [0] = {
  347. .start = SDHC2_BASE_ADDR,
  348. .end = SDHC2_BASE_ADDR + SZ_4K - 1,
  349. .flags = IORESOURCE_MEM,
  350. },
  351. [1] = {
  352. .start = MXC_INT_SDHC2,
  353. .end = MXC_INT_SDHC2,
  354. .flags = IORESOURCE_IRQ,
  355. },
  356. [2] = {
  357. .start = DMA_REQ_SDHC2,
  358. .end = DMA_REQ_SDHC2,
  359. .flags = IORESOURCE_DMA
  360. },
  361. };
  362. static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
  363. struct platform_device mxc_sdhc_device1 = {
  364. .name = "mxc-mmc",
  365. .id = 1,
  366. .dev = {
  367. .dma_mask = &mxc_sdhc2_dmamask,
  368. .coherent_dma_mask = 0xffffffff,
  369. },
  370. .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
  371. .resource = mxc_sdhc2_resources,
  372. };
  373. /* GPIO port description */
  374. static struct mxc_gpio_port imx_gpio_ports[] = {
  375. [0] = {
  376. .chip.label = "gpio-0",
  377. .irq = MXC_INT_GPIO,
  378. .base = IO_ADDRESS(GPIO_BASE_ADDR),
  379. .virtual_irq_start = MXC_GPIO_IRQ_START,
  380. },
  381. [1] = {
  382. .chip.label = "gpio-1",
  383. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
  384. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  385. },
  386. [2] = {
  387. .chip.label = "gpio-2",
  388. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
  389. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  390. },
  391. [3] = {
  392. .chip.label = "gpio-3",
  393. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
  394. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  395. },
  396. [4] = {
  397. .chip.label = "gpio-4",
  398. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
  399. .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
  400. },
  401. [5] = {
  402. .chip.label = "gpio-5",
  403. .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
  404. .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
  405. }
  406. };
  407. int __init mxc_register_gpios(void)
  408. {
  409. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  410. }