hdmi.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 {
  27. struct kref refcount;
  28. struct drm_device *dev;
  29. struct platform_device *pdev;
  30. void __iomem *mmio;
  31. struct regulator *mvs; /* HDMI_5V */
  32. struct regulator *mpp0; /* External 5V */
  33. struct clk *clk;
  34. struct clk *m_pclk;
  35. struct clk *s_pclk;
  36. struct hdmi_phy *phy;
  37. struct i2c_adapter *i2c;
  38. struct drm_connector *connector;
  39. struct drm_bridge *bridge;
  40. /* the encoder we are hooked to (outside of hdmi block) */
  41. struct drm_encoder *encoder;
  42. bool hdmi_mode; /* are we in hdmi mode? */
  43. int irq;
  44. };
  45. /* platform config data (ie. from DT, or pdata) */
  46. struct hdmi_platform_config {
  47. struct hdmi_phy *(*phy_init)(struct hdmi *hdmi);
  48. int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, pmic_gpio;
  49. };
  50. void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
  51. void hdmi_destroy(struct kref *kref);
  52. static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
  53. {
  54. msm_writel(data, hdmi->mmio + reg);
  55. }
  56. static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg)
  57. {
  58. return msm_readl(hdmi->mmio + reg);
  59. }
  60. static inline struct hdmi * hdmi_reference(struct hdmi *hdmi)
  61. {
  62. kref_get(&hdmi->refcount);
  63. return hdmi;
  64. }
  65. static inline void hdmi_unreference(struct hdmi *hdmi)
  66. {
  67. kref_put(&hdmi->refcount, hdmi_destroy);
  68. }
  69. /*
  70. * The phy appears to be different, for example between 8960 and 8x60,
  71. * so split the phy related functions out and load the correct one at
  72. * runtime:
  73. */
  74. struct hdmi_phy_funcs {
  75. void (*destroy)(struct hdmi_phy *phy);
  76. void (*reset)(struct hdmi_phy *phy);
  77. void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock);
  78. void (*powerdown)(struct hdmi_phy *phy);
  79. };
  80. struct hdmi_phy {
  81. const struct hdmi_phy_funcs *funcs;
  82. };
  83. struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
  84. struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
  85. /*
  86. * hdmi bridge:
  87. */
  88. struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
  89. /*
  90. * hdmi connector:
  91. */
  92. void hdmi_connector_irq(struct drm_connector *connector);
  93. struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
  94. /*
  95. * i2c adapter for ddc:
  96. */
  97. void hdmi_i2c_irq(struct i2c_adapter *i2c);
  98. void hdmi_i2c_destroy(struct i2c_adapter *i2c);
  99. struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi);
  100. #endif /* __HDMI_CONNECTOR_H__ */