2 * Copyright (C) 2013 Red Hat
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.
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
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/>.
18 #ifndef __HDMI_CONNECTOR_H__
19 #define __HDMI_CONNECTOR_H__
21 #include <linux/i2c.h>
22 #include <linux/clk.h>
23 #include <linux/platform_device.h>
24 #include <linux/regulator/consumer.h>
25 #include <linux/hdmi.h>
32 struct hdmi_platform_config;
36 struct hdmi_audio_infoframe infoframe;
40 struct hdmi_hdcp_ctrl;
43 struct drm_device *dev;
44 struct platform_device *pdev;
46 const struct hdmi_platform_config *config;
49 struct hdmi_audio audio;
53 unsigned long int pixclock;
56 void __iomem *qfprom_mmio;
57 phys_addr_t mmio_phy_addr;
59 struct regulator **hpd_regs;
60 struct regulator **pwr_regs;
61 struct clk **hpd_clks;
62 struct clk **pwr_clks;
65 struct i2c_adapter *i2c;
66 struct drm_connector *connector;
67 struct drm_bridge *bridge;
69 /* the encoder we are hooked to (outside of hdmi block) */
70 struct drm_encoder *encoder;
72 bool hdmi_mode; /* are we in hdmi mode? */
75 struct workqueue_struct *workq;
77 struct hdmi_hdcp_ctrl *hdcp_ctrl;
80 * spinlock to protect registers shared by different execution
82 * REG_HDMI_DDC_ARBITRATION
83 * REG_HDMI_HDCP_INT_CTRL
89 /* platform config data (ie. from DT, or pdata) */
90 struct hdmi_platform_config {
91 struct hdmi_phy *(*phy_init)(struct hdmi *hdmi);
92 const char *mmio_name;
93 const char *qfprom_mmio_name;
95 /* regulators that need to be on for hpd: */
96 const char **hpd_reg_names;
99 /* regulators that need to be on for screen pwr: */
100 const char **pwr_reg_names;
103 /* clks that need to be on for hpd: */
104 const char **hpd_clk_names;
105 const long unsigned *hpd_freq;
108 /* clks that need to be on for screen pwr (ie pixel clk): */
109 const char **pwr_clk_names;
113 int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
117 void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
119 static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
121 msm_writel(data, hdmi->mmio + reg);
124 static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg)
126 return msm_readl(hdmi->mmio + reg);
129 static inline u32 hdmi_qfprom_read(struct hdmi *hdmi, u32 reg)
131 return msm_readl(hdmi->qfprom_mmio + reg);
135 * The phy appears to be different, for example between 8960 and 8x60,
136 * so split the phy related functions out and load the correct one at
140 struct hdmi_phy_funcs {
141 void (*destroy)(struct hdmi_phy *phy);
142 void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock);
143 void (*powerdown)(struct hdmi_phy *phy);
147 const struct hdmi_phy_funcs *funcs;
150 struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
151 struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
152 struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi);
158 int hdmi_audio_update(struct hdmi *hdmi);
159 int hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
160 uint32_t num_of_channels, uint32_t channel_allocation,
161 uint32_t level_shift, bool down_mix);
162 void hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate);
169 struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
170 void hdmi_bridge_destroy(struct drm_bridge *bridge);
176 void hdmi_connector_irq(struct drm_connector *connector);
177 struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
180 * i2c adapter for ddc:
183 void hdmi_i2c_irq(struct i2c_adapter *i2c);
184 void hdmi_i2c_destroy(struct i2c_adapter *i2c);
185 struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi);
190 struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi);
191 void hdmi_hdcp_destroy(struct hdmi *hdmi);
192 void hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl);
193 void hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl);
194 void hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl);
196 #endif /* __HDMI_CONNECTOR_H__ */