devices.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /* linux/arch/arm/mach-msm/devices.c
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/platform_device.h>
  17. #include <mach/irqs.h>
  18. #include <mach/msm_iomap.h>
  19. #include "devices.h"
  20. #include <asm/mach/flash.h>
  21. #include <linux/mtd/nand.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <mach/mmc.h>
  24. static struct resource resources_uart1[] = {
  25. {
  26. .start = INT_UART1,
  27. .end = INT_UART1,
  28. .flags = IORESOURCE_IRQ,
  29. },
  30. {
  31. .start = MSM_UART1_PHYS,
  32. .end = MSM_UART1_PHYS + MSM_UART1_SIZE - 1,
  33. .flags = IORESOURCE_MEM,
  34. },
  35. };
  36. static struct resource resources_uart2[] = {
  37. {
  38. .start = INT_UART2,
  39. .end = INT_UART2,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. {
  43. .start = MSM_UART2_PHYS,
  44. .end = MSM_UART2_PHYS + MSM_UART2_SIZE - 1,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. };
  48. static struct resource resources_uart3[] = {
  49. {
  50. .start = INT_UART3,
  51. .end = INT_UART3,
  52. .flags = IORESOURCE_IRQ,
  53. },
  54. {
  55. .start = MSM_UART3_PHYS,
  56. .end = MSM_UART3_PHYS + MSM_UART3_SIZE - 1,
  57. .flags = IORESOURCE_MEM,
  58. },
  59. };
  60. struct platform_device msm_device_uart1 = {
  61. .name = "msm_serial",
  62. .id = 0,
  63. .num_resources = ARRAY_SIZE(resources_uart1),
  64. .resource = resources_uart1,
  65. };
  66. struct platform_device msm_device_uart2 = {
  67. .name = "msm_serial",
  68. .id = 1,
  69. .num_resources = ARRAY_SIZE(resources_uart2),
  70. .resource = resources_uart2,
  71. };
  72. struct platform_device msm_device_uart3 = {
  73. .name = "msm_serial",
  74. .id = 2,
  75. .num_resources = ARRAY_SIZE(resources_uart3),
  76. .resource = resources_uart3,
  77. };
  78. static struct resource resources_i2c[] = {
  79. {
  80. .start = MSM_I2C_PHYS,
  81. .end = MSM_I2C_PHYS + MSM_I2C_SIZE - 1,
  82. .flags = IORESOURCE_MEM,
  83. },
  84. {
  85. .start = INT_PWB_I2C,
  86. .end = INT_PWB_I2C,
  87. .flags = IORESOURCE_IRQ,
  88. },
  89. };
  90. struct platform_device msm_device_i2c = {
  91. .name = "msm_i2c",
  92. .id = 0,
  93. .num_resources = ARRAY_SIZE(resources_i2c),
  94. .resource = resources_i2c,
  95. };
  96. static struct resource resources_hsusb[] = {
  97. {
  98. .start = MSM_HSUSB_PHYS,
  99. .end = MSM_HSUSB_PHYS + MSM_HSUSB_SIZE,
  100. .flags = IORESOURCE_MEM,
  101. },
  102. {
  103. .start = INT_USB_HS,
  104. .end = INT_USB_HS,
  105. .flags = IORESOURCE_IRQ,
  106. },
  107. };
  108. struct platform_device msm_device_hsusb = {
  109. .name = "msm_hsusb",
  110. .id = -1,
  111. .num_resources = ARRAY_SIZE(resources_hsusb),
  112. .resource = resources_hsusb,
  113. .dev = {
  114. .coherent_dma_mask = 0xffffffff,
  115. },
  116. };
  117. struct flash_platform_data msm_nand_data = {
  118. .parts = NULL,
  119. .nr_parts = 0,
  120. };
  121. static struct resource resources_nand[] = {
  122. [0] = {
  123. .start = 7,
  124. .end = 7,
  125. .flags = IORESOURCE_DMA,
  126. },
  127. };
  128. struct platform_device msm_device_nand = {
  129. .name = "msm_nand",
  130. .id = -1,
  131. .num_resources = ARRAY_SIZE(resources_nand),
  132. .resource = resources_nand,
  133. .dev = {
  134. .platform_data = &msm_nand_data,
  135. },
  136. };
  137. struct platform_device msm_device_smd = {
  138. .name = "msm_smd",
  139. .id = -1,
  140. };
  141. static struct resource resources_sdc1[] = {
  142. {
  143. .start = MSM_SDC1_PHYS,
  144. .end = MSM_SDC1_PHYS + MSM_SDC1_SIZE - 1,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. {
  148. .start = INT_SDC1_0,
  149. .end = INT_SDC1_0,
  150. .flags = IORESOURCE_IRQ,
  151. .name = "cmd_irq",
  152. },
  153. {
  154. .start = INT_SDC1_1,
  155. .end = INT_SDC1_1,
  156. .flags = IORESOURCE_IRQ,
  157. .name = "pio_irq",
  158. },
  159. {
  160. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  161. .name = "status_irq"
  162. },
  163. {
  164. .start = 8,
  165. .end = 8,
  166. .flags = IORESOURCE_DMA,
  167. },
  168. };
  169. static struct resource resources_sdc2[] = {
  170. {
  171. .start = MSM_SDC2_PHYS,
  172. .end = MSM_SDC2_PHYS + MSM_SDC2_SIZE - 1,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. {
  176. .start = INT_SDC2_0,
  177. .end = INT_SDC2_0,
  178. .flags = IORESOURCE_IRQ,
  179. .name = "cmd_irq",
  180. },
  181. {
  182. .start = INT_SDC2_1,
  183. .end = INT_SDC2_1,
  184. .flags = IORESOURCE_IRQ,
  185. .name = "pio_irq",
  186. },
  187. {
  188. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  189. .name = "status_irq"
  190. },
  191. {
  192. .start = 8,
  193. .end = 8,
  194. .flags = IORESOURCE_DMA,
  195. },
  196. };
  197. static struct resource resources_sdc3[] = {
  198. {
  199. .start = MSM_SDC3_PHYS,
  200. .end = MSM_SDC3_PHYS + MSM_SDC3_SIZE - 1,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. {
  204. .start = INT_SDC3_0,
  205. .end = INT_SDC3_0,
  206. .flags = IORESOURCE_IRQ,
  207. .name = "cmd_irq",
  208. },
  209. {
  210. .start = INT_SDC3_1,
  211. .end = INT_SDC3_1,
  212. .flags = IORESOURCE_IRQ,
  213. .name = "pio_irq",
  214. },
  215. {
  216. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  217. .name = "status_irq"
  218. },
  219. {
  220. .start = 8,
  221. .end = 8,
  222. .flags = IORESOURCE_DMA,
  223. },
  224. };
  225. static struct resource resources_sdc4[] = {
  226. {
  227. .start = MSM_SDC4_PHYS,
  228. .end = MSM_SDC4_PHYS + MSM_SDC4_SIZE - 1,
  229. .flags = IORESOURCE_MEM,
  230. },
  231. {
  232. .start = INT_SDC4_0,
  233. .end = INT_SDC4_0,
  234. .flags = IORESOURCE_IRQ,
  235. .name = "cmd_irq",
  236. },
  237. {
  238. .start = INT_SDC4_1,
  239. .end = INT_SDC4_1,
  240. .flags = IORESOURCE_IRQ,
  241. .name = "pio_irq",
  242. },
  243. {
  244. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  245. .name = "status_irq"
  246. },
  247. {
  248. .start = 8,
  249. .end = 8,
  250. .flags = IORESOURCE_DMA,
  251. },
  252. };
  253. struct platform_device msm_device_sdc1 = {
  254. .name = "msm_sdcc",
  255. .id = 1,
  256. .num_resources = ARRAY_SIZE(resources_sdc1),
  257. .resource = resources_sdc1,
  258. .dev = {
  259. .coherent_dma_mask = 0xffffffff,
  260. },
  261. };
  262. struct platform_device msm_device_sdc2 = {
  263. .name = "msm_sdcc",
  264. .id = 2,
  265. .num_resources = ARRAY_SIZE(resources_sdc2),
  266. .resource = resources_sdc2,
  267. .dev = {
  268. .coherent_dma_mask = 0xffffffff,
  269. },
  270. };
  271. struct platform_device msm_device_sdc3 = {
  272. .name = "msm_sdcc",
  273. .id = 3,
  274. .num_resources = ARRAY_SIZE(resources_sdc3),
  275. .resource = resources_sdc3,
  276. .dev = {
  277. .coherent_dma_mask = 0xffffffff,
  278. },
  279. };
  280. struct platform_device msm_device_sdc4 = {
  281. .name = "msm_sdcc",
  282. .id = 4,
  283. .num_resources = ARRAY_SIZE(resources_sdc4),
  284. .resource = resources_sdc4,
  285. .dev = {
  286. .coherent_dma_mask = 0xffffffff,
  287. },
  288. };
  289. static struct platform_device *msm_sdcc_devices[] __initdata = {
  290. &msm_device_sdc1,
  291. &msm_device_sdc2,
  292. &msm_device_sdc3,
  293. &msm_device_sdc4,
  294. };
  295. int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat,
  296. unsigned int stat_irq, unsigned long stat_irq_flags)
  297. {
  298. struct platform_device *pdev;
  299. struct resource *res;
  300. if (controller < 1 || controller > 4)
  301. return -EINVAL;
  302. pdev = msm_sdcc_devices[controller-1];
  303. pdev->dev.platform_data = plat;
  304. res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "status_irq");
  305. if (!res)
  306. return -EINVAL;
  307. else if (stat_irq) {
  308. res->start = res->end = stat_irq;
  309. res->flags &= ~IORESOURCE_DISABLED;
  310. res->flags |= stat_irq_flags;
  311. }
  312. return platform_device_register(pdev);
  313. }