hdmi.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. #ifndef __HDMI_CONNECTOR_H__
  18. #define __HDMI_CONNECTOR_H__
  19. #include <linux/i2c.h>
  20. #include <linux/clk.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/regulator/consumer.h>
  23. #include "msm_drv.h"
  24. #include "hdmi.xml.h"
  25. struct hdmi_phy;
  26. struct hdmi_platform_config;
  27. struct hdmi {
  28. struct kref refcount;
  29. struct drm_device *dev;
  30. struct platform_device *pdev;
  31. const struct hdmi_platform_config *config;
  32. void __iomem *mmio;
  33. struct regulator *hpd_regs[2];
  34. struct regulator *pwr_regs[2];
  35. struct clk *hpd_clks[3];
  36. struct clk *pwr_clks[2];
  37. struct hdmi_phy *phy;
  38. struct i2c_adapter *i2c;
  39. struct drm_connector *connector;
  40. struct drm_bridge *bridge;
  41. /* the encoder we are hooked to (outside of hdmi block) */
  42. struct drm_encoder *encoder;
  43. bool hdmi_mode; /* are we in hdmi mode? */
  44. int irq;
  45. };
  46. /* platform config data (ie. from DT, or pdata) */
  47. struct hdmi_platform_config {
  48. struct hdmi_phy *(*phy_init)(struct hdmi *hdmi);
  49. const char *mmio_name;
  50. /* regulators that need to be on for hpd: */
  51. const char **hpd_reg_names;
  52. int hpd_reg_cnt;
  53. /* regulators that need to be on for screen pwr: */
  54. const char **pwr_reg_names;
  55. int pwr_reg_cnt;
  56. /* clks that need to be on for hpd: */
  57. const char **hpd_clk_names;
  58. int hpd_clk_cnt;
  59. /* clks that need to be on for screen pwr (ie pixel clk): */
  60. const char **pwr_clk_names;
  61. int pwr_clk_cnt;
  62. /* gpio's: */
  63. int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
  64. /* older devices had their own irq, mdp5+ it is shared w/ mdp: */
  65. bool shared_irq;
  66. };
  67. void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
  68. void hdmi_destroy(struct kref *kref);
  69. static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
  70. {
  71. msm_writel(data, hdmi->mmio + reg);
  72. }
  73. static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg)
  74. {
  75. return msm_readl(hdmi->mmio + reg);
  76. }
  77. static inline struct hdmi * hdmi_reference(struct hdmi *hdmi)
  78. {
  79. kref_get(&hdmi->refcount);
  80. return hdmi;
  81. }
  82. static inline void hdmi_unreference(struct hdmi *hdmi)
  83. {
  84. kref_put(&hdmi->refcount, hdmi_destroy);
  85. }
  86. /*
  87. * The phy appears to be different, for example between 8960 and 8x60,
  88. * so split the phy related functions out and load the correct one at
  89. * runtime:
  90. */
  91. struct hdmi_phy_funcs {
  92. void (*destroy)(struct hdmi_phy *phy);
  93. void (*reset)(struct hdmi_phy *phy);
  94. void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock);
  95. void (*powerdown)(struct hdmi_phy *phy);
  96. };
  97. struct hdmi_phy {
  98. const struct hdmi_phy_funcs *funcs;
  99. };
  100. struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
  101. struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
  102. struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi);
  103. /*
  104. * hdmi bridge:
  105. */
  106. struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
  107. /*
  108. * hdmi connector:
  109. */
  110. void hdmi_connector_irq(struct drm_connector *connector);
  111. struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
  112. /*
  113. * i2c adapter for ddc:
  114. */
  115. void hdmi_i2c_irq(struct i2c_adapter *i2c);
  116. void hdmi_i2c_destroy(struct i2c_adapter *i2c);
  117. struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi);
  118. #endif /* __HDMI_CONNECTOR_H__ */