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 <mach/mmc.h>
  34. #include "devices.h"
  35. extern struct sys_timer msm_timer;
  36. static const resource_size_t qsd8x50_surf_smc91x_base __initdata = 0x70000300;
  37. static const unsigned qsd8x50_surf_smc91x_gpio __initdata = 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_device_uart3,
  82. &msm_device_smd,
  83. &msm_device_otg,
  84. &msm_device_hsusb,
  85. &msm_device_hsusb_host,
  86. };
  87. static struct msm_mmc_gpio sdc1_gpio_cfg[] = {
  88. {51, "sdc1_dat_3"},
  89. {52, "sdc1_dat_2"},
  90. {53, "sdc1_dat_1"},
  91. {54, "sdc1_dat_0"},
  92. {55, "sdc1_cmd"},
  93. {56, "sdc1_clk"}
  94. };
  95. static struct vreg *vreg_mmc;
  96. static unsigned long vreg_sts;
  97. static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
  98. {
  99. int rc = 0;
  100. struct platform_device *pdev;
  101. pdev = container_of(dv, struct platform_device, dev);
  102. if (vdd == 0) {
  103. if (!vreg_sts)
  104. return 0;
  105. clear_bit(pdev->id, &vreg_sts);
  106. if (!vreg_sts) {
  107. rc = vreg_disable(vreg_mmc);
  108. if (rc)
  109. pr_err("vreg_mmc disable failed for slot "
  110. "%d: %d\n", pdev->id, rc);
  111. }
  112. return 0;
  113. }
  114. if (!vreg_sts) {
  115. rc = vreg_set_level(vreg_mmc, 2900);
  116. if (rc)
  117. pr_err("vreg_mmc set level failed for slot %d: %d\n",
  118. pdev->id, rc);
  119. rc = vreg_enable(vreg_mmc);
  120. if (rc)
  121. pr_err("vreg_mmc enable failed for slot %d: %d\n",
  122. pdev->id, rc);
  123. }
  124. set_bit(pdev->id, &vreg_sts);
  125. return 0;
  126. }
  127. static struct msm_mmc_gpio_data sdc1_gpio = {
  128. .gpio = sdc1_gpio_cfg,
  129. .size = ARRAY_SIZE(sdc1_gpio_cfg),
  130. };
  131. static struct msm_mmc_platform_data qsd8x50_sdc1_data = {
  132. .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  133. .translate_vdd = msm_sdcc_setup_power,
  134. .gpio_data = &sdc1_gpio,
  135. };
  136. static void __init qsd8x50_init_mmc(void)
  137. {
  138. vreg_mmc = vreg_get(NULL, "gp5");
  139. if (IS_ERR(vreg_mmc)) {
  140. pr_err("vreg get for vreg_mmc failed (%ld)\n",
  141. PTR_ERR(vreg_mmc));
  142. return;
  143. }
  144. msm_add_sdcc(1, &qsd8x50_sdc1_data, 0, 0);
  145. }
  146. static void __init qsd8x50_map_io(void)
  147. {
  148. msm_map_qsd8x50_io();
  149. msm_clock_init(msm_clocks_8x50, msm_num_clocks_8x50);
  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. .timer = &msm_timer,
  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. .timer = &msm_timer,
  183. MACHINE_END