devices.c 9.0 KB

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