devices-qsd8x50.c 9.1 KB

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