hdmi_phy_8x60.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "hdmi.h"
  18. static void hdmi_phy_8x60_powerup(struct hdmi_phy *phy,
  19. unsigned long int pixclock)
  20. {
  21. /* De-serializer delay D/C for non-lbk mode: */
  22. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG0,
  23. HDMI_8x60_PHY_REG0_DESER_DEL_CTRL(3));
  24. if (pixclock == 27000000) {
  25. /* video_format == HDMI_VFRMT_720x480p60_16_9 */
  26. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG1,
  27. HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(5) |
  28. HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(3));
  29. } else {
  30. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG1,
  31. HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(5) |
  32. HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(4));
  33. }
  34. /* No matter what, start from the power down mode: */
  35. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  36. HDMI_8x60_PHY_REG2_PD_PWRGEN |
  37. HDMI_8x60_PHY_REG2_PD_PLL |
  38. HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
  39. HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
  40. HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
  41. HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
  42. HDMI_8x60_PHY_REG2_PD_DESER);
  43. /* Turn PowerGen on: */
  44. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  45. HDMI_8x60_PHY_REG2_PD_PLL |
  46. HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
  47. HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
  48. HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
  49. HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
  50. HDMI_8x60_PHY_REG2_PD_DESER);
  51. /* Turn PLL power on: */
  52. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  53. HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
  54. HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
  55. HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
  56. HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
  57. HDMI_8x60_PHY_REG2_PD_DESER);
  58. /* Write to HIGH after PLL power down de-assert: */
  59. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG3,
  60. HDMI_8x60_PHY_REG3_PLL_ENABLE);
  61. /* ASIC power on; PHY REG9 = 0 */
  62. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG9, 0);
  63. /* Enable PLL lock detect, PLL lock det will go high after lock
  64. * Enable the re-time logic
  65. */
  66. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG12,
  67. HDMI_8x60_PHY_REG12_RETIMING_EN |
  68. HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN);
  69. /* Drivers are on: */
  70. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  71. HDMI_8x60_PHY_REG2_PD_DESER);
  72. /* If the RX detector is needed: */
  73. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  74. HDMI_8x60_PHY_REG2_RCV_SENSE_EN |
  75. HDMI_8x60_PHY_REG2_PD_DESER);
  76. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG4, 0);
  77. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG5, 0);
  78. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG6, 0);
  79. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG7, 0);
  80. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG8, 0);
  81. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG9, 0);
  82. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG10, 0);
  83. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG11, 0);
  84. /* If we want to use lock enable based on counting: */
  85. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG12,
  86. HDMI_8x60_PHY_REG12_RETIMING_EN |
  87. HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN |
  88. HDMI_8x60_PHY_REG12_FORCE_LOCK);
  89. }
  90. static void hdmi_phy_8x60_powerdown(struct hdmi_phy *phy)
  91. {
  92. /* Assert RESET PHY from controller */
  93. hdmi_phy_write(phy, REG_HDMI_PHY_CTRL,
  94. HDMI_PHY_CTRL_SW_RESET);
  95. udelay(10);
  96. /* De-assert RESET PHY from controller */
  97. hdmi_phy_write(phy, REG_HDMI_PHY_CTRL, 0);
  98. /* Turn off Driver */
  99. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  100. HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
  101. HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
  102. HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
  103. HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
  104. HDMI_8x60_PHY_REG2_PD_DESER);
  105. udelay(10);
  106. /* Disable PLL */
  107. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG3, 0);
  108. /* Power down PHY, but keep RX-sense: */
  109. hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
  110. HDMI_8x60_PHY_REG2_RCV_SENSE_EN |
  111. HDMI_8x60_PHY_REG2_PD_PWRGEN |
  112. HDMI_8x60_PHY_REG2_PD_PLL |
  113. HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
  114. HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
  115. HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
  116. HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
  117. HDMI_8x60_PHY_REG2_PD_DESER);
  118. }
  119. const struct hdmi_phy_cfg msm_hdmi_phy_8x60_cfg = {
  120. .type = MSM_HDMI_PHY_8x60,
  121. .powerup = hdmi_phy_8x60_powerup,
  122. .powerdown = hdmi_phy_8x60_powerdown,
  123. };