board-qsd8x50.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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/board.h>
  30. #include <mach/irqs.h>
  31. #include <mach/sirc.h>
  32. #include <mach/vreg.h>
  33. #include <linux/platform_data/mmc-msm_sdcc.h>
  34. #include "devices.h"
  35. #include "common.h"
  36. static const resource_size_t qsd8x50_surf_smc91x_base __initconst = 0x70000300;
  37. static const unsigned qsd8x50_surf_smc91x_gpio __initconst = 156;
  38. /* Leave smc91x resources empty here, as we'll fill them in
  39. * at run-time: they vary from board to board, and the true
  40. * configuration won't be known until boot.
  41. */
  42. static struct resource smc91x_resources[] = {
  43. [0] = {
  44. .flags = IORESOURCE_MEM,
  45. },
  46. [1] = {
  47. .flags = IORESOURCE_IRQ,
  48. },
  49. };
  50. static struct platform_device smc91x_device = {
  51. .name = "smc91x",
  52. .id = 0,
  53. .num_resources = ARRAY_SIZE(smc91x_resources),
  54. .resource = smc91x_resources,
  55. };
  56. static int __init msm_init_smc91x(void)
  57. {
  58. if (machine_is_qsd8x50_surf()) {
  59. smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
  60. smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
  61. smc91x_resources[1].start =
  62. gpio_to_irq(qsd8x50_surf_smc91x_gpio);
  63. smc91x_resources[1].end =
  64. gpio_to_irq(qsd8x50_surf_smc91x_gpio);
  65. platform_device_register(&smc91x_device);
  66. }
  67. return 0;
  68. }
  69. module_init(msm_init_smc91x);
  70. static int hsusb_phy_init_seq[] = {
  71. 0x08, 0x31, /* Increase HS Driver Amplitude */
  72. 0x20, 0x32, /* Enable and set Pre-Emphasis Depth to 10% */
  73. -1
  74. };
  75. static struct msm_otg_platform_data msm_otg_pdata = {
  76. .phy_init_seq = hsusb_phy_init_seq,
  77. .mode = USB_PERIPHERAL,
  78. .otg_control = OTG_PHY_CONTROL,
  79. };
  80. static struct platform_device *devices[] __initdata = {
  81. &msm_clock_8x50,
  82. &msm_device_gpio_8x50,
  83. &msm_device_uart3,
  84. &msm_device_smd,
  85. &msm_device_otg,
  86. &msm_device_hsusb,
  87. &msm_device_hsusb_host,
  88. };
  89. static struct msm_mmc_gpio sdc1_gpio_cfg[] = {
  90. {51, "sdc1_dat_3"},
  91. {52, "sdc1_dat_2"},
  92. {53, "sdc1_dat_1"},
  93. {54, "sdc1_dat_0"},
  94. {55, "sdc1_cmd"},
  95. {56, "sdc1_clk"}
  96. };
  97. static struct vreg *vreg_mmc;
  98. static unsigned long vreg_sts;
  99. static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
  100. {
  101. int rc = 0;
  102. struct platform_device *pdev;
  103. pdev = container_of(dv, struct platform_device, dev);
  104. if (vdd == 0) {
  105. if (!vreg_sts)
  106. return 0;
  107. clear_bit(pdev->id, &vreg_sts);
  108. if (!vreg_sts) {
  109. rc = vreg_disable(vreg_mmc);
  110. if (rc)
  111. pr_err("vreg_mmc disable failed for slot "
  112. "%d: %d\n", pdev->id, rc);
  113. }
  114. return 0;
  115. }
  116. if (!vreg_sts) {
  117. rc = vreg_set_level(vreg_mmc, 2900);
  118. if (rc)
  119. pr_err("vreg_mmc set level failed for slot %d: %d\n",
  120. pdev->id, rc);
  121. rc = vreg_enable(vreg_mmc);
  122. if (rc)
  123. pr_err("vreg_mmc enable failed for slot %d: %d\n",
  124. pdev->id, rc);
  125. }
  126. set_bit(pdev->id, &vreg_sts);
  127. return 0;
  128. }
  129. static struct msm_mmc_gpio_data sdc1_gpio = {
  130. .gpio = sdc1_gpio_cfg,
  131. .size = ARRAY_SIZE(sdc1_gpio_cfg),
  132. };
  133. static struct msm_mmc_platform_data qsd8x50_sdc1_data = {
  134. .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  135. .translate_vdd = msm_sdcc_setup_power,
  136. .gpio_data = &sdc1_gpio,
  137. };
  138. static void __init qsd8x50_init_mmc(void)
  139. {
  140. vreg_mmc = vreg_get(NULL, "gp5");
  141. if (IS_ERR(vreg_mmc)) {
  142. pr_err("vreg get for vreg_mmc failed (%ld)\n",
  143. PTR_ERR(vreg_mmc));
  144. return;
  145. }
  146. msm_add_sdcc(1, &qsd8x50_sdc1_data, 0, 0);
  147. }
  148. static void __init qsd8x50_map_io(void)
  149. {
  150. msm_map_qsd8x50_io();
  151. }
  152. static void __init qsd8x50_init_irq(void)
  153. {
  154. msm_init_irq();
  155. msm_init_sirc();
  156. }
  157. static void __init qsd8x50_init(void)
  158. {
  159. msm_device_otg.dev.platform_data = &msm_otg_pdata;
  160. msm_device_hsusb.dev.parent = &msm_device_otg.dev;
  161. msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
  162. platform_add_devices(devices, ARRAY_SIZE(devices));
  163. qsd8x50_init_mmc();
  164. }
  165. static void __init qsd8x50_init_late(void)
  166. {
  167. smd_debugfs_init();
  168. }
  169. MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
  170. .atag_offset = 0x100,
  171. .map_io = qsd8x50_map_io,
  172. .init_irq = qsd8x50_init_irq,
  173. .init_machine = qsd8x50_init,
  174. .init_late = qsd8x50_init_late,
  175. .init_time = qsd8x50_timer_init,
  176. MACHINE_END
  177. MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
  178. .atag_offset = 0x100,
  179. .map_io = qsd8x50_map_io,
  180. .init_irq = qsd8x50_init_irq,
  181. .init_machine = qsd8x50_init,
  182. .init_late = qsd8x50_init_late,
  183. .init_time = qsd8x50_timer_init,
  184. MACHINE_END