hdmi_phy_8x74.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. struct hdmi_phy_8x74 {
  19. struct hdmi_phy base;
  20. void __iomem *mmio;
  21. };
  22. #define to_hdmi_phy_8x74(x) container_of(x, struct hdmi_phy_8x74, base)
  23. static void phy_write(struct hdmi_phy_8x74 *phy, u32 reg, u32 data)
  24. {
  25. msm_writel(data, phy->mmio + reg);
  26. }
  27. //static u32 phy_read(struct hdmi_phy_8x74 *phy, u32 reg)
  28. //{
  29. // return msm_readl(phy->mmio + reg);
  30. //}
  31. static void hdmi_phy_8x74_destroy(struct hdmi_phy *phy)
  32. {
  33. struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
  34. kfree(phy_8x74);
  35. }
  36. static void hdmi_phy_8x74_powerup(struct hdmi_phy *phy,
  37. unsigned long int pixclock)
  38. {
  39. struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
  40. phy_write(phy_8x74, REG_HDMI_8x74_ANA_CFG0, 0x1b);
  41. phy_write(phy_8x74, REG_HDMI_8x74_ANA_CFG1, 0xf2);
  42. phy_write(phy_8x74, REG_HDMI_8x74_BIST_CFG0, 0x0);
  43. phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN0, 0x0);
  44. phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN1, 0x0);
  45. phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN2, 0x0);
  46. phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN3, 0x0);
  47. phy_write(phy_8x74, REG_HDMI_8x74_PD_CTRL1, 0x20);
  48. }
  49. static void hdmi_phy_8x74_powerdown(struct hdmi_phy *phy)
  50. {
  51. struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
  52. phy_write(phy_8x74, REG_HDMI_8x74_PD_CTRL0, 0x7f);
  53. }
  54. static const struct hdmi_phy_funcs hdmi_phy_8x74_funcs = {
  55. .destroy = hdmi_phy_8x74_destroy,
  56. .powerup = hdmi_phy_8x74_powerup,
  57. .powerdown = hdmi_phy_8x74_powerdown,
  58. };
  59. struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi)
  60. {
  61. struct hdmi_phy_8x74 *phy_8x74;
  62. struct hdmi_phy *phy = NULL;
  63. int ret;
  64. phy_8x74 = kzalloc(sizeof(*phy_8x74), GFP_KERNEL);
  65. if (!phy_8x74) {
  66. ret = -ENOMEM;
  67. goto fail;
  68. }
  69. phy = &phy_8x74->base;
  70. phy->funcs = &hdmi_phy_8x74_funcs;
  71. /* for 8x74, the phy mmio is mapped separately: */
  72. phy_8x74->mmio = msm_ioremap(hdmi->pdev,
  73. "phy_physical", "HDMI_8x74");
  74. if (IS_ERR(phy_8x74->mmio)) {
  75. ret = PTR_ERR(phy_8x74->mmio);
  76. goto fail;
  77. }
  78. return phy;
  79. fail:
  80. if (phy)
  81. hdmi_phy_8x74_destroy(phy);
  82. return ERR_PTR(ret);
  83. }