Lines Matching +full:hdmi +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
18 #include "hdmi.h"
20 void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on)
25 spin_lock_irqsave(&hdmi->reg_lock, flags);
28 if (!hdmi->connector->display_info.is_hdmi) {
30 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
39 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
40 spin_unlock_irqrestore(&hdmi->reg_lock, flags);
41 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x",
47 struct hdmi *hdmi = dev_id;
50 msm_hdmi_hpd_irq(hdmi->bridge);
53 msm_hdmi_i2c_irq(hdmi->i2c);
56 if (hdmi->hdcp_ctrl)
57 msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl);
64 static void msm_hdmi_destroy(struct hdmi *hdmi)
70 if (hdmi->workq)
71 destroy_workqueue(hdmi->workq);
72 msm_hdmi_hdcp_destroy(hdmi);
74 if (hdmi->i2c)
75 msm_hdmi_i2c_destroy(hdmi->i2c);
78 static void msm_hdmi_put_phy(struct hdmi *hdmi)
80 if (hdmi->phy_dev) {
81 put_device(hdmi->phy_dev);
82 hdmi->phy = NULL;
83 hdmi->phy_dev = NULL;
87 static int msm_hdmi_get_phy(struct hdmi *hdmi)
89 struct platform_device *pdev = hdmi->pdev;
93 phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0);
95 DRM_DEV_ERROR(&pdev->dev, "cannot find phy device\n");
96 return -ENXIO;
103 return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n");
105 hdmi->phy = platform_get_drvdata(phy_pdev);
106 if (!hdmi->phy) {
107 put_device(&phy_pdev->dev);
108 return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n");
111 hdmi->phy_dev = &phy_pdev->dev;
116 /* construct hdmi at bind/probe time, grab all the resources. If
120 static int msm_hdmi_init(struct hdmi *hdmi)
122 struct platform_device *pdev = hdmi->pdev;
125 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0);
126 if (!hdmi->workq) {
127 ret = -ENOMEM;
131 hdmi->i2c = msm_hdmi_i2c_init(hdmi);
132 if (IS_ERR(hdmi->i2c)) {
133 ret = PTR_ERR(hdmi->i2c);
134 DRM_DEV_ERROR(&pdev->dev, "failed to get i2c: %d\n", ret);
135 hdmi->i2c = NULL;
139 hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi);
140 if (IS_ERR(hdmi->hdcp_ctrl)) {
141 dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
142 hdmi->hdcp_ctrl = NULL;
148 msm_hdmi_destroy(hdmi);
155 * driver (not hdmi sub-device's probe/bind!)
159 * hdmi sub-device's probe.
161 int msm_hdmi_modeset_init(struct hdmi *hdmi,
166 hdmi->dev = dev;
167 hdmi->encoder = encoder;
169 ret = msm_hdmi_bridge_init(hdmi);
171 DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret);
175 if (hdmi->next_bridge) {
176 ret = drm_bridge_attach(hdmi->encoder, hdmi->next_bridge, hdmi->bridge,
179 DRM_DEV_ERROR(dev->dev, "failed to attach next HDMI bridge: %d\n", ret);
184 hdmi->connector = drm_bridge_connector_init(hdmi->dev, encoder);
185 if (IS_ERR(hdmi->connector)) {
186 ret = PTR_ERR(hdmi->connector);
187 DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret);
188 hdmi->connector = NULL;
192 drm_connector_attach_encoder(hdmi->connector, hdmi->encoder);
194 ret = devm_request_irq(dev->dev, hdmi->irq,
196 "hdmi_isr", hdmi);
198 DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n",
199 hdmi->irq, ret);
206 if (hdmi->connector) {
207 hdmi->connector->funcs->destroy(hdmi->connector);
208 hdmi->connector = NULL;
215 * The hdmi device:
218 static const char * const pwr_reg_names_8960[] = {"core-vdda"};
228 static const char * const pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
241 struct hdmi *hdmi = dev_get_drvdata(dev);
244 err = msm_hdmi_init(hdmi);
247 priv->hdmi = hdmi;
257 if (priv->hdmi) {
258 msm_hdmi_destroy(priv->hdmi);
259 priv->hdmi = NULL;
271 struct device *dev = &pdev->dev;
272 struct hdmi *hdmi;
278 return -EINVAL;
280 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
281 if (!hdmi)
282 return -ENOMEM;
284 hdmi->pdev = pdev;
285 hdmi->config = config;
286 spin_lock_init(&hdmi->reg_lock);
287 mutex_init(&hdmi->state_mutex);
289 ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge);
290 if (ret && ret != -ENODEV)
293 hdmi->mmio = msm_ioremap(pdev, "core_physical");
294 if (IS_ERR(hdmi->mmio))
295 return PTR_ERR(hdmi->mmio);
297 /* HDCP needs physical address of hdmi register */
301 return -EINVAL;
302 hdmi->mmio_phy_addr = res->start;
304 hdmi->qfprom_mmio = msm_ioremap(pdev, "qfprom_physical");
305 if (IS_ERR(hdmi->qfprom_mmio)) {
306 DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n");
307 hdmi->qfprom_mmio = NULL;
310 hdmi->irq = platform_get_irq(pdev, 0);
311 if (hdmi->irq < 0)
312 return hdmi->irq;
314 hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
315 config->pwr_reg_cnt,
316 sizeof(hdmi->pwr_regs[0]),
318 if (!hdmi->pwr_regs)
319 return -ENOMEM;
321 for (i = 0; i < config->pwr_reg_cnt; i++)
322 hdmi->pwr_regs[i].supply = config->pwr_reg_names[i];
324 ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs);
328 hdmi->pwr_clks = devm_kcalloc(&pdev->dev,
329 config->pwr_clk_cnt,
330 sizeof(hdmi->pwr_clks[0]),
332 if (!hdmi->pwr_clks)
333 return -ENOMEM;
335 for (i = 0; i < config->pwr_clk_cnt; i++)
336 hdmi->pwr_clks[i].id = config->pwr_clk_names[i];
338 ret = devm_clk_bulk_get(&pdev->dev, config->pwr_clk_cnt, hdmi->pwr_clks);
342 hdmi->extp_clk = devm_clk_get_optional(&pdev->dev, "extp");
343 if (IS_ERR(hdmi->extp_clk))
344 return dev_err_probe(dev, PTR_ERR(hdmi->extp_clk),
347 hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN);
348 /* This will catch e.g. -EPROBE_DEFER */
349 if (IS_ERR(hdmi->hpd_gpiod))
350 return dev_err_probe(dev, PTR_ERR(hdmi->hpd_gpiod),
353 if (!hdmi->hpd_gpiod)
356 if (hdmi->hpd_gpiod)
357 gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD");
359 ret = msm_hdmi_get_phy(hdmi);
361 DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n");
365 ret = devm_pm_runtime_enable(&pdev->dev);
369 platform_set_drvdata(pdev, hdmi);
371 ret = component_add(&pdev->dev, &msm_hdmi_ops);
378 msm_hdmi_put_phy(hdmi);
384 struct hdmi *hdmi = dev_get_drvdata(&pdev->dev);
386 component_del(&pdev->dev, &msm_hdmi_ops);
388 msm_hdmi_put_phy(hdmi);
393 struct hdmi *hdmi = dev_get_drvdata(dev);
394 const struct hdmi_platform_config *config = hdmi->config;
396 clk_bulk_disable_unprepare(config->pwr_clk_cnt, hdmi->pwr_clks);
400 regulator_bulk_disable(config->pwr_reg_cnt, hdmi->pwr_regs);
407 struct hdmi *hdmi = dev_get_drvdata(dev);
408 const struct hdmi_platform_config *config = hdmi->config;
411 ret = regulator_bulk_enable(config->pwr_reg_cnt, hdmi->pwr_regs);
419 ret = clk_bulk_prepare_enable(config->pwr_clk_cnt, hdmi->pwr_clks);
434 { .compatible = "qcom,hdmi-tx-8998", .data = &hdmi_tx_8974_config },
435 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8974_config },
436 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8974_config },
437 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8974_config },
438 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
439 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
440 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8960_config },