hdmi.h 2.7 KB

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