devices.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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_1,
  150. .flags = IORESOURCE_IRQ,
  151. },
  152. {
  153. .start = 8,
  154. .end = 8,
  155. .flags = IORESOURCE_DMA,
  156. },
  157. };
  158. static struct resource resources_sdc2[] = {
  159. {
  160. .start = MSM_SDC2_PHYS,
  161. .end = MSM_SDC2_PHYS + MSM_SDC2_SIZE - 1,
  162. .flags = IORESOURCE_MEM,
  163. },
  164. {
  165. .start = INT_SDC2_0,
  166. .end = INT_SDC2_1,
  167. .flags = IORESOURCE_IRQ,
  168. },
  169. {
  170. .start = 8,
  171. .end = 8,
  172. .flags = IORESOURCE_DMA,
  173. },
  174. };
  175. static struct resource resources_sdc3[] = {
  176. {
  177. .start = MSM_SDC3_PHYS,
  178. .end = MSM_SDC3_PHYS + MSM_SDC3_SIZE - 1,
  179. .flags = IORESOURCE_MEM,
  180. },
  181. {
  182. .start = INT_SDC3_0,
  183. .end = INT_SDC3_1,
  184. .flags = IORESOURCE_IRQ,
  185. },
  186. {
  187. .start = 8,
  188. .end = 8,
  189. .flags = IORESOURCE_DMA,
  190. },
  191. };
  192. static struct resource resources_sdc4[] = {
  193. {
  194. .start = MSM_SDC4_PHYS,
  195. .end = MSM_SDC4_PHYS + MSM_SDC4_SIZE - 1,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. {
  199. .start = INT_SDC4_0,
  200. .end = INT_SDC4_1,
  201. .flags = IORESOURCE_IRQ,
  202. },
  203. {
  204. .start = 8,
  205. .end = 8,
  206. .flags = IORESOURCE_DMA,
  207. },
  208. };
  209. struct platform_device msm_device_sdc1 = {
  210. .name = "msm_sdcc",
  211. .id = 1,
  212. .num_resources = ARRAY_SIZE(resources_sdc1),
  213. .resource = resources_sdc1,
  214. .dev = {
  215. .coherent_dma_mask = 0xffffffff,
  216. },
  217. };
  218. struct platform_device msm_device_sdc2 = {
  219. .name = "msm_sdcc",
  220. .id = 2,
  221. .num_resources = ARRAY_SIZE(resources_sdc2),
  222. .resource = resources_sdc2,
  223. .dev = {
  224. .coherent_dma_mask = 0xffffffff,
  225. },
  226. };
  227. struct platform_device msm_device_sdc3 = {
  228. .name = "msm_sdcc",
  229. .id = 3,
  230. .num_resources = ARRAY_SIZE(resources_sdc3),
  231. .resource = resources_sdc3,
  232. .dev = {
  233. .coherent_dma_mask = 0xffffffff,
  234. },
  235. };
  236. struct platform_device msm_device_sdc4 = {
  237. .name = "msm_sdcc",
  238. .id = 4,
  239. .num_resources = ARRAY_SIZE(resources_sdc4),
  240. .resource = resources_sdc4,
  241. .dev = {
  242. .coherent_dma_mask = 0xffffffff,
  243. },
  244. };
  245. static struct platform_device *msm_sdcc_devices[] __initdata = {
  246. &msm_device_sdc1,
  247. &msm_device_sdc2,
  248. &msm_device_sdc3,
  249. &msm_device_sdc4,
  250. };
  251. int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat)
  252. {
  253. struct platform_device *pdev;
  254. if (controller < 1 || controller > 4)
  255. return -EINVAL;
  256. pdev = msm_sdcc_devices[controller-1];
  257. pdev->dev.platform_data = plat;
  258. return platform_device_register(pdev);
  259. }