devices-qsd8x50.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*
  2. * Copyright (C) 2008 Google, Inc.
  3. * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
  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 <linux/clkdev.h>
  18. #include <linux/dma-mapping.h>
  19. #include <mach/irqs.h>
  20. #include <mach/msm_iomap.h>
  21. #include <mach/dma.h>
  22. #include <mach/board.h>
  23. #include "devices.h"
  24. #include <asm/mach/flash.h>
  25. #include <linux/platform_data/mmc-msm_sdcc.h>
  26. #include "clock-pcom.h"
  27. static struct resource msm_gpio_resources[] = {
  28. {
  29. .start = 64 + 165 + 9,
  30. .end = 64 + 165 + 9,
  31. .flags = IORESOURCE_IRQ,
  32. },
  33. {
  34. .start = 64 + 165 + 10,
  35. .end = 64 + 165 + 10,
  36. .flags = IORESOURCE_IRQ,
  37. },
  38. {
  39. .start = 0xa9000800,
  40. .end = 0xa9000800 + SZ_4K - 1,
  41. .flags = IORESOURCE_MEM,
  42. .name = "gpio1"
  43. },
  44. {
  45. .start = 0xa9100C00,
  46. .end = 0xa9100C00 + SZ_4K - 1,
  47. .flags = IORESOURCE_MEM,
  48. .name = "gpio2"
  49. },
  50. };
  51. struct platform_device msm_device_gpio_8x50 = {
  52. .name = "gpio-msm-8x50",
  53. .num_resources = ARRAY_SIZE(msm_gpio_resources),
  54. .resource = msm_gpio_resources,
  55. };
  56. static struct resource resources_uart3[] = {
  57. {
  58. .start = INT_UART3,
  59. .end = INT_UART3,
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. {
  63. .start = MSM_UART3_PHYS,
  64. .end = MSM_UART3_PHYS + MSM_UART3_SIZE - 1,
  65. .flags = IORESOURCE_MEM,
  66. .name = "uart_resource"
  67. },
  68. };
  69. struct platform_device msm_device_uart3 = {
  70. .name = "msm_serial",
  71. .id = 2,
  72. .num_resources = ARRAY_SIZE(resources_uart3),
  73. .resource = resources_uart3,
  74. };
  75. struct platform_device msm_device_smd = {
  76. .name = "msm_smd",
  77. .id = -1,
  78. };
  79. static struct resource resources_otg[] = {
  80. {
  81. .start = MSM_HSUSB_PHYS,
  82. .end = MSM_HSUSB_PHYS + MSM_HSUSB_SIZE,
  83. .flags = IORESOURCE_MEM,
  84. },
  85. {
  86. .start = INT_USB_HS,
  87. .end = INT_USB_HS,
  88. .flags = IORESOURCE_IRQ,
  89. },
  90. };
  91. struct platform_device msm_device_otg = {
  92. .name = "msm_otg",
  93. .id = -1,
  94. .num_resources = ARRAY_SIZE(resources_otg),
  95. .resource = resources_otg,
  96. .dev = {
  97. .coherent_dma_mask = 0xffffffff,
  98. },
  99. };
  100. static struct resource resources_hsusb[] = {
  101. {
  102. .start = MSM_HSUSB_PHYS,
  103. .end = MSM_HSUSB_PHYS + MSM_HSUSB_SIZE,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. {
  107. .start = INT_USB_HS,
  108. .end = INT_USB_HS,
  109. .flags = IORESOURCE_IRQ,
  110. },
  111. };
  112. struct platform_device msm_device_hsusb = {
  113. .name = "msm_hsusb",
  114. .id = -1,
  115. .num_resources = ARRAY_SIZE(resources_hsusb),
  116. .resource = resources_hsusb,
  117. .dev = {
  118. .coherent_dma_mask = 0xffffffff,
  119. },
  120. };
  121. static u64 dma_mask = 0xffffffffULL;
  122. static struct resource resources_hsusb_host[] = {
  123. {
  124. .start = MSM_HSUSB_PHYS,
  125. .end = MSM_HSUSB_PHYS + MSM_HSUSB_SIZE,
  126. .flags = IORESOURCE_MEM,
  127. },
  128. {
  129. .start = INT_USB_HS,
  130. .end = INT_USB_HS,
  131. .flags = IORESOURCE_IRQ,
  132. },
  133. };
  134. struct platform_device msm_device_hsusb_host = {
  135. .name = "msm_hsusb_host",
  136. .id = -1,
  137. .num_resources = ARRAY_SIZE(resources_hsusb_host),
  138. .resource = resources_hsusb_host,
  139. .dev = {
  140. .dma_mask = &dma_mask,
  141. .coherent_dma_mask = 0xffffffffULL,
  142. },
  143. };
  144. static struct resource resources_sdc1[] = {
  145. {
  146. .start = MSM_SDC1_PHYS,
  147. .end = MSM_SDC1_PHYS + MSM_SDC1_SIZE - 1,
  148. .flags = IORESOURCE_MEM,
  149. },
  150. {
  151. .start = INT_SDC1_0,
  152. .end = INT_SDC1_0,
  153. .flags = IORESOURCE_IRQ,
  154. .name = "cmd_irq",
  155. },
  156. {
  157. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  158. .name = "status_irq"
  159. },
  160. {
  161. .start = 8,
  162. .end = 8,
  163. .flags = IORESOURCE_DMA,
  164. },
  165. };
  166. static struct resource resources_sdc2[] = {
  167. {
  168. .start = MSM_SDC2_PHYS,
  169. .end = MSM_SDC2_PHYS + MSM_SDC2_SIZE - 1,
  170. .flags = IORESOURCE_MEM,
  171. },
  172. {
  173. .start = INT_SDC2_0,
  174. .end = INT_SDC2_0,
  175. .flags = IORESOURCE_IRQ,
  176. .name = "cmd_irq",
  177. },
  178. {
  179. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  180. .name = "status_irq"
  181. },
  182. {
  183. .start = 8,
  184. .end = 8,
  185. .flags = IORESOURCE_DMA,
  186. },
  187. };
  188. static struct resource resources_sdc3[] = {
  189. {
  190. .start = MSM_SDC3_PHYS,
  191. .end = MSM_SDC3_PHYS + MSM_SDC3_SIZE - 1,
  192. .flags = IORESOURCE_MEM,
  193. },
  194. {
  195. .start = INT_SDC3_0,
  196. .end = INT_SDC3_0,
  197. .flags = IORESOURCE_IRQ,
  198. .name = "cmd_irq",
  199. },
  200. {
  201. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  202. .name = "status_irq"
  203. },
  204. {
  205. .start = 8,
  206. .end = 8,
  207. .flags = IORESOURCE_DMA,
  208. },
  209. };
  210. static struct resource resources_sdc4[] = {
  211. {
  212. .start = MSM_SDC4_PHYS,
  213. .end = MSM_SDC4_PHYS + MSM_SDC4_SIZE - 1,
  214. .flags = IORESOURCE_MEM,
  215. },
  216. {
  217. .start = INT_SDC4_0,
  218. .end = INT_SDC4_0,
  219. .flags = IORESOURCE_IRQ,
  220. .name = "cmd_irq",
  221. },
  222. {
  223. .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
  224. .name = "status_irq"
  225. },
  226. {
  227. .start = 8,
  228. .end = 8,
  229. .flags = IORESOURCE_DMA,
  230. },
  231. };
  232. struct platform_device msm_device_sdc1 = {
  233. .name = "msm_sdcc",
  234. .id = 1,
  235. .num_resources = ARRAY_SIZE(resources_sdc1),
  236. .resource = resources_sdc1,
  237. .dev = {
  238. .coherent_dma_mask = 0xffffffff,
  239. },
  240. };
  241. struct platform_device msm_device_sdc2 = {
  242. .name = "msm_sdcc",
  243. .id = 2,
  244. .num_resources = ARRAY_SIZE(resources_sdc2),
  245. .resource = resources_sdc2,
  246. .dev = {
  247. .coherent_dma_mask = 0xffffffff,
  248. },
  249. };
  250. struct platform_device msm_device_sdc3 = {
  251. .name = "msm_sdcc",
  252. .id = 3,
  253. .num_resources = ARRAY_SIZE(resources_sdc3),
  254. .resource = resources_sdc3,
  255. .dev = {
  256. .coherent_dma_mask = 0xffffffff,
  257. },
  258. };
  259. struct platform_device msm_device_sdc4 = {
  260. .name = "msm_sdcc",
  261. .id = 4,
  262. .num_resources = ARRAY_SIZE(resources_sdc4),
  263. .resource = resources_sdc4,
  264. .dev = {
  265. .coherent_dma_mask = 0xffffffff,
  266. },
  267. };
  268. static struct platform_device *msm_sdcc_devices[] __initdata = {
  269. &msm_device_sdc1,
  270. &msm_device_sdc2,
  271. &msm_device_sdc3,
  272. &msm_device_sdc4,
  273. };
  274. int __init msm_add_sdcc(unsigned int controller,
  275. struct msm_mmc_platform_data *plat,
  276. unsigned int stat_irq, unsigned long stat_irq_flags)
  277. {
  278. struct platform_device *pdev;
  279. struct resource *res;
  280. if (controller < 1 || controller > 4)
  281. return -EINVAL;
  282. pdev = msm_sdcc_devices[controller-1];
  283. pdev->dev.platform_data = plat;
  284. res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "status_irq");
  285. if (!res)
  286. return -EINVAL;
  287. else if (stat_irq) {
  288. res->start = res->end = stat_irq;
  289. res->flags &= ~IORESOURCE_DISABLED;
  290. res->flags |= stat_irq_flags;
  291. }
  292. return platform_device_register(pdev);
  293. }
  294. struct clk_lookup msm_clocks_8x50[] = {
  295. CLK_PCOM("adm_clk", ADM_CLK, NULL, 0),
  296. CLK_PCOM("ce_clk", CE_CLK, NULL, 0),
  297. CLK_PCOM("ebi1_clk", EBI1_CLK, NULL, CLK_MIN),
  298. CLK_PCOM("ebi2_clk", EBI2_CLK, NULL, 0),
  299. CLK_PCOM("ecodec_clk", ECODEC_CLK, NULL, 0),
  300. CLK_PCOM("emdh_clk", EMDH_CLK, NULL, OFF | CLK_MINMAX),
  301. CLK_PCOM("gp_clk", GP_CLK, NULL, 0),
  302. CLK_PCOM("grp_clk", GRP_3D_CLK, NULL, 0),
  303. CLK_PCOM("i2c_clk", I2C_CLK, NULL, 0),
  304. CLK_PCOM("icodec_rx_clk", ICODEC_RX_CLK, NULL, 0),
  305. CLK_PCOM("icodec_tx_clk", ICODEC_TX_CLK, NULL, 0),
  306. CLK_PCOM("imem_clk", IMEM_CLK, NULL, OFF),
  307. CLK_PCOM("mdc_clk", MDC_CLK, NULL, 0),
  308. CLK_PCOM("mddi_clk", PMDH_CLK, NULL, OFF | CLK_MINMAX),
  309. CLK_PCOM("mdp_clk", MDP_CLK, NULL, OFF),
  310. CLK_PCOM("mdp_lcdc_pclk_clk", MDP_LCDC_PCLK_CLK, NULL, 0),
  311. CLK_PCOM("mdp_lcdc_pad_pclk_clk", MDP_LCDC_PAD_PCLK_CLK, NULL, 0),
  312. CLK_PCOM("mdp_vsync_clk", MDP_VSYNC_CLK, NULL, 0),
  313. CLK_PCOM("pbus_clk", PBUS_CLK, NULL, CLK_MIN),
  314. CLK_PCOM("pcm_clk", PCM_CLK, NULL, 0),
  315. CLK_PCOM("sdac_clk", SDAC_CLK, NULL, OFF),
  316. CLK_PCOM("sdc_clk", SDC1_CLK, "msm_sdcc.1", OFF),
  317. CLK_PCOM("sdc_pclk", SDC1_P_CLK, "msm_sdcc.1", OFF),
  318. CLK_PCOM("sdc_clk", SDC2_CLK, "msm_sdcc.2", OFF),
  319. CLK_PCOM("sdc_pclk", SDC2_P_CLK, "msm_sdcc.2", OFF),
  320. CLK_PCOM("sdc_clk", SDC3_CLK, "msm_sdcc.3", OFF),
  321. CLK_PCOM("sdc_pclk", SDC3_P_CLK, "msm_sdcc.3", OFF),
  322. CLK_PCOM("sdc_clk", SDC4_CLK, "msm_sdcc.4", OFF),
  323. CLK_PCOM("sdc_pclk", SDC4_P_CLK, "msm_sdcc.4", OFF),
  324. CLK_PCOM("spi_clk", SPI_CLK, NULL, 0),
  325. CLK_PCOM("tsif_clk", TSIF_CLK, NULL, 0),
  326. CLK_PCOM("tsif_ref_clk", TSIF_REF_CLK, NULL, 0),
  327. CLK_PCOM("tv_dac_clk", TV_DAC_CLK, NULL, 0),
  328. CLK_PCOM("tv_enc_clk", TV_ENC_CLK, NULL, 0),
  329. CLK_PCOM("uart_clk", UART1_CLK, NULL, OFF),
  330. CLK_PCOM("uart_clk", UART2_CLK, NULL, 0),
  331. CLK_PCOM("uart_clk", UART3_CLK, "msm_serial.2", OFF),
  332. CLK_PCOM("uartdm_clk", UART1DM_CLK, NULL, OFF),
  333. CLK_PCOM("uartdm_clk", UART2DM_CLK, NULL, 0),
  334. CLK_PCOM("usb_hs_clk", USB_HS_CLK, NULL, OFF),
  335. CLK_PCOM("usb_hs_pclk", USB_HS_P_CLK, NULL, OFF),
  336. CLK_PCOM("usb_otg_clk", USB_OTG_CLK, NULL, 0),
  337. CLK_PCOM("vdc_clk", VDC_CLK, NULL, OFF | CLK_MIN),
  338. CLK_PCOM("vfe_clk", VFE_CLK, NULL, OFF),
  339. CLK_PCOM("vfe_mdc_clk", VFE_MDC_CLK, NULL, OFF),
  340. CLK_PCOM("vfe_axi_clk", VFE_AXI_CLK, NULL, OFF),
  341. CLK_PCOM("usb_hs2_clk", USB_HS2_CLK, NULL, OFF),
  342. CLK_PCOM("usb_hs2_pclk", USB_HS2_P_CLK, NULL, OFF),
  343. CLK_PCOM("usb_hs3_clk", USB_HS3_CLK, NULL, OFF),
  344. CLK_PCOM("usb_hs3_pclk", USB_HS3_P_CLK, NULL, OFF),
  345. CLK_PCOM("usb_phy_clk", USB_PHY_CLK, NULL, 0),
  346. };
  347. unsigned msm_num_clocks_8x50 = ARRAY_SIZE(msm_clocks_8x50);