Lines Matching +full:hdmi +full:- +full:bridge
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include "hdmi.h"
14 static void msm_hdmi_phy_reset(struct hdmi *hdmi) in msm_hdmi_phy_reset() argument
18 val = hdmi_read(hdmi, REG_HDMI_PHY_CTRL); in msm_hdmi_phy_reset()
22 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
26 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
32 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
36 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
44 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
48 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
54 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
58 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
63 static void enable_hpd_clocks(struct hdmi *hdmi, bool enable) in enable_hpd_clocks() argument
65 const struct hdmi_platform_config *config = hdmi->config; in enable_hpd_clocks()
66 struct device *dev = &hdmi->pdev->dev; in enable_hpd_clocks()
70 for (i = 0; i < config->hpd_clk_cnt; i++) { in enable_hpd_clocks()
71 if (config->hpd_freq && config->hpd_freq[i]) { in enable_hpd_clocks()
72 ret = clk_set_rate(hdmi->hpd_clks[i], in enable_hpd_clocks()
73 config->hpd_freq[i]); in enable_hpd_clocks()
77 config->hpd_clk_names[i], ret); in enable_hpd_clocks()
80 ret = clk_prepare_enable(hdmi->hpd_clks[i]); in enable_hpd_clocks()
84 config->hpd_clk_names[i], ret); in enable_hpd_clocks()
88 for (i = config->hpd_clk_cnt - 1; i >= 0; i--) in enable_hpd_clocks()
89 clk_disable_unprepare(hdmi->hpd_clks[i]); in enable_hpd_clocks()
93 int msm_hdmi_hpd_enable(struct drm_bridge *bridge) in msm_hdmi_hpd_enable() argument
95 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_hpd_enable()
96 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_hpd_enable() local
97 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_hpd_enable()
98 struct device *dev = &hdmi->pdev->dev; in msm_hdmi_hpd_enable()
103 ret = regulator_bulk_enable(config->hpd_reg_cnt, hdmi->hpd_regs); in msm_hdmi_hpd_enable()
115 if (hdmi->hpd_gpiod) in msm_hdmi_hpd_enable()
116 gpiod_set_value_cansleep(hdmi->hpd_gpiod, 1); in msm_hdmi_hpd_enable()
119 enable_hpd_clocks(hdmi, true); in msm_hdmi_hpd_enable()
121 msm_hdmi_set_mode(hdmi, false); in msm_hdmi_hpd_enable()
122 msm_hdmi_phy_reset(hdmi); in msm_hdmi_hpd_enable()
123 msm_hdmi_set_mode(hdmi, true); in msm_hdmi_hpd_enable()
125 hdmi_write(hdmi, REG_HDMI_USEC_REFTIMER, 0x0001001b); in msm_hdmi_hpd_enable()
128 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, in msm_hdmi_hpd_enable()
133 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hpd_enable()
134 hpd_ctrl = hdmi_read(hdmi, REG_HDMI_HPD_CTRL); in msm_hdmi_hpd_enable()
138 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, in msm_hdmi_hpd_enable()
140 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, in msm_hdmi_hpd_enable()
142 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hpd_enable()
150 void msm_hdmi_hpd_disable(struct hdmi *hdmi) in msm_hdmi_hpd_disable() argument
152 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_hpd_disable()
153 struct device *dev = &hdmi->pdev->dev; in msm_hdmi_hpd_disable()
157 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0); in msm_hdmi_hpd_disable()
159 msm_hdmi_set_mode(hdmi, false); in msm_hdmi_hpd_disable()
161 enable_hpd_clocks(hdmi, false); in msm_hdmi_hpd_disable()
168 ret = regulator_bulk_disable(config->hpd_reg_cnt, hdmi->hpd_regs); in msm_hdmi_hpd_disable()
173 void msm_hdmi_hpd_irq(struct drm_bridge *bridge) in msm_hdmi_hpd_irq() argument
175 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_hpd_irq()
176 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_hpd_irq() local
180 hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS); in msm_hdmi_hpd_irq()
181 hpd_int_ctrl = hdmi_read(hdmi, REG_HDMI_HPD_INT_CTRL); in msm_hdmi_hpd_irq()
188 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, in msm_hdmi_hpd_irq()
197 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, hpd_int_ctrl); in msm_hdmi_hpd_irq()
199 queue_work(hdmi->workq, &hdmi_bridge->hpd_work); in msm_hdmi_hpd_irq()
203 static enum drm_connector_status detect_reg(struct hdmi *hdmi) in detect_reg() argument
207 pm_runtime_get_sync(&hdmi->pdev->dev); in detect_reg()
208 enable_hpd_clocks(hdmi, true); in detect_reg()
210 hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS); in detect_reg()
212 enable_hpd_clocks(hdmi, false); in detect_reg()
213 pm_runtime_put(&hdmi->pdev->dev); in detect_reg()
220 static enum drm_connector_status detect_gpio(struct hdmi *hdmi) in detect_gpio() argument
222 return gpiod_get_value(hdmi->hpd_gpiod) ? in detect_gpio()
228 struct drm_bridge *bridge) in msm_hdmi_bridge_detect() argument
230 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_bridge_detect()
231 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_detect() local
239 if (!hdmi->hpd_gpiod) in msm_hdmi_bridge_detect()
240 return detect_reg(hdmi); in msm_hdmi_bridge_detect()
243 stat_gpio = detect_gpio(hdmi); in msm_hdmi_bridge_detect()
244 stat_reg = detect_reg(hdmi); in msm_hdmi_bridge_detect()
250 } while (--retry); in msm_hdmi_bridge_detect()
253 * so trust that one the most if we didn't manage to get hdmi and in msm_hdmi_bridge_detect()