board-qsd8x50.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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/kernel.h>
  18. #include <linux/irq.h>
  19. #include <linux/gpio.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/gpio.h>
  33. #include <mach/vreg.h>
  34. #include <mach/mmc.h>
  35. #include "devices.h"
  36. extern struct sys_timer msm_timer;
  37. static const resource_size_t qsd8x50_surf_smc91x_base __initdata = 0x70000300;
  38. static const unsigned qsd8x50_surf_smc91x_gpio __initdata = 156;
  39. /* Leave smc91x resources empty here, as we'll fill them in
  40. * at run-time: they vary from board to board, and the true
  41. * configuration won't be known until boot.
  42. */
  43. static struct resource smc91x_resources[] = {
  44. [0] = {
  45. .flags = IORESOURCE_MEM,
  46. },
  47. [1] = {
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. };
  51. static struct platform_device smc91x_device = {
  52. .name = "smc91x",
  53. .id = 0,
  54. .num_resources = ARRAY_SIZE(smc91x_resources),
  55. .resource = smc91x_resources,
  56. };
  57. static int __init msm_init_smc91x(void)
  58. {
  59. if (machine_is_qsd8x50_surf()) {
  60. smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
  61. smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
  62. smc91x_resources[1].start =
  63. gpio_to_irq(qsd8x50_surf_smc91x_gpio);
  64. smc91x_resources[1].end =
  65. gpio_to_irq(qsd8x50_surf_smc91x_gpio);
  66. platform_device_register(&smc91x_device);
  67. }
  68. return 0;
  69. }
  70. module_init(msm_init_smc91x);
  71. static int hsusb_phy_init_seq[] = {
  72. 0x08, 0x31, /* Increase HS Driver Amplitude */
  73. 0x20, 0x32, /* Enable and set Pre-Emphasis Depth to 10% */
  74. -1
  75. };
  76. static struct msm_otg_platform_data msm_otg_pdata = {
  77. .phy_init_seq = hsusb_phy_init_seq,
  78. .mode = USB_PERIPHERAL,
  79. .otg_control = OTG_PHY_CONTROL,
  80. };
  81. static struct platform_device *devices[] __initdata = {
  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. msm_clock_init(msm_clocks_8x50, msm_num_clocks_8x50);
  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. MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
  166. .boot_params = PLAT_PHYS_OFFSET + 0x100,
  167. .map_io = qsd8x50_map_io,
  168. .init_irq = qsd8x50_init_irq,
  169. .init_machine = qsd8x50_init,
  170. .timer = &msm_timer,
  171. MACHINE_END
  172. MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
  173. .boot_params = PLAT_PHYS_OFFSET + 0x100,
  174. .map_io = qsd8x50_map_io,
  175. .init_irq = qsd8x50_init_irq,
  176. .init_machine = qsd8x50_init,
  177. .timer = &msm_timer,
  178. MACHINE_END