board-qsd8x50.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. * 02110-1301, USA.
  16. */
  17. #include <linux/gpio.h>
  18. #include <linux/kernel.h>
  19. #include <linux/irq.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/delay.h>
  22. #include <linux/usb/msm_hsusb.h>
  23. #include <linux/err.h>
  24. #include <linux/clkdev.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/io.h>
  28. #include <asm/setup.h>
  29. #include <mach/irqs.h>
  30. #include <mach/sirc.h>
  31. #include <mach/vreg.h>
  32. #include <linux/platform_data/mmc-msm_sdcc.h>
  33. #include "devices.h"
  34. #include "common.h"
  35. static const resource_size_t qsd8x50_surf_smc91x_base __initconst = 0x70000300;
  36. static const unsigned qsd8x50_surf_smc91x_gpio __initconst = 156;
  37. /* Leave smc91x resources empty here, as we'll fill them in
  38. * at run-time: they vary from board to board, and the true
  39. * configuration won't be known until boot.
  40. */
  41. static struct resource smc91x_resources[] = {
  42. [0] = {
  43. .flags = IORESOURCE_MEM,
  44. },
  45. [1] = {
  46. .flags = IORESOURCE_IRQ,
  47. },
  48. };
  49. static struct platform_device smc91x_device = {
  50. .name = "smc91x",
  51. .id = 0,
  52. .num_resources = ARRAY_SIZE(smc91x_resources),
  53. .resource = smc91x_resources,
  54. };
  55. static int __init msm_init_smc91x(void)
  56. {
  57. if (machine_is_qsd8x50_surf()) {
  58. smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
  59. smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
  60. smc91x_resources[1].start =
  61. gpio_to_irq(qsd8x50_surf_smc91x_gpio);
  62. smc91x_resources[1].end =
  63. gpio_to_irq(qsd8x50_surf_smc91x_gpio);
  64. platform_device_register(&smc91x_device);
  65. }
  66. return 0;
  67. }
  68. module_init(msm_init_smc91x);
  69. static int hsusb_phy_init_seq[] = {
  70. 0x08, 0x31, /* Increase HS Driver Amplitude */
  71. 0x20, 0x32, /* Enable and set Pre-Emphasis Depth to 10% */
  72. -1
  73. };
  74. static struct msm_otg_platform_data msm_otg_pdata = {
  75. .phy_init_seq = hsusb_phy_init_seq,
  76. .mode = USB_PERIPHERAL,
  77. .otg_control = OTG_PHY_CONTROL,
  78. };
  79. static struct platform_device *devices[] __initdata = {
  80. &msm_clock_8x50,
  81. &msm_device_gpio_8x50,
  82. &msm_device_uart3,
  83. &msm_device_smd,
  84. &msm_device_otg,
  85. &msm_device_hsusb,
  86. &msm_device_hsusb_host,
  87. };
  88. static struct msm_mmc_gpio sdc1_gpio_cfg[] = {
  89. {51, "sdc1_dat_3"},
  90. {52, "sdc1_dat_2"},
  91. {53, "sdc1_dat_1"},
  92. {54, "sdc1_dat_0"},
  93. {55, "sdc1_cmd"},
  94. {56, "sdc1_clk"}
  95. };
  96. static struct vreg *vreg_mmc;
  97. static unsigned long vreg_sts;
  98. static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
  99. {
  100. int rc = 0;
  101. struct platform_device *pdev;
  102. pdev = container_of(dv, struct platform_device, dev);
  103. if (vdd == 0) {
  104. if (!vreg_sts)
  105. return 0;
  106. clear_bit(pdev->id, &vreg_sts);
  107. if (!vreg_sts) {
  108. rc = vreg_disable(vreg_mmc);
  109. if (rc)
  110. pr_err("vreg_mmc disable failed for slot "
  111. "%d: %d\n", pdev->id, rc);
  112. }
  113. return 0;
  114. }
  115. if (!vreg_sts) {
  116. rc = vreg_set_level(vreg_mmc, 2900);
  117. if (rc)
  118. pr_err("vreg_mmc set level failed for slot %d: %d\n",
  119. pdev->id, rc);
  120. rc = vreg_enable(vreg_mmc);
  121. if (rc)
  122. pr_err("vreg_mmc enable failed for slot %d: %d\n",
  123. pdev->id, rc);
  124. }
  125. set_bit(pdev->id, &vreg_sts);
  126. return 0;
  127. }
  128. static struct msm_mmc_gpio_data sdc1_gpio = {
  129. .gpio = sdc1_gpio_cfg,
  130. .size = ARRAY_SIZE(sdc1_gpio_cfg),
  131. };
  132. static struct msm_mmc_platform_data qsd8x50_sdc1_data = {
  133. .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  134. .translate_vdd = msm_sdcc_setup_power,
  135. .gpio_data = &sdc1_gpio,
  136. };
  137. static void __init qsd8x50_init_mmc(void)
  138. {
  139. vreg_mmc = vreg_get(NULL, "gp5");
  140. if (IS_ERR(vreg_mmc)) {
  141. pr_err("vreg get for vreg_mmc failed (%ld)\n",
  142. PTR_ERR(vreg_mmc));
  143. return;
  144. }
  145. msm_add_sdcc(1, &qsd8x50_sdc1_data, 0, 0);
  146. }
  147. static void __init qsd8x50_map_io(void)
  148. {
  149. msm_map_qsd8x50_io();
  150. }
  151. static void __init qsd8x50_init_irq(void)
  152. {
  153. msm_init_irq();
  154. msm_init_sirc();
  155. }
  156. static void __init qsd8x50_init(void)
  157. {
  158. msm_device_otg.dev.platform_data = &msm_otg_pdata;
  159. msm_device_hsusb.dev.parent = &msm_device_otg.dev;
  160. msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
  161. platform_add_devices(devices, ARRAY_SIZE(devices));
  162. qsd8x50_init_mmc();
  163. }
  164. static void __init qsd8x50_init_late(void)
  165. {
  166. smd_debugfs_init();
  167. }
  168. MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
  169. .atag_offset = 0x100,
  170. .map_io = qsd8x50_map_io,
  171. .init_irq = qsd8x50_init_irq,
  172. .init_machine = qsd8x50_init,
  173. .init_late = qsd8x50_init_late,
  174. .init_time = qsd8x50_timer_init,
  175. MACHINE_END
  176. MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
  177. .atag_offset = 0x100,
  178. .map_io = qsd8x50_map_io,
  179. .init_irq = qsd8x50_init_irq,
  180. .init_machine = qsd8x50_init,
  181. .init_late = qsd8x50_init_late,
  182. .init_time = qsd8x50_timer_init,
  183. MACHINE_END