1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
4 * Copyright (C) 2013 Red Hat
5 * Author: Rob Clark <robdclark@gmail.com>
6 */
7
8 #include <linux/of_irq.h>
9 #include <linux/of_gpio.h>
10
11 #include <sound/hdmi-codec.h>
12 #include "hdmi.h"
13
msm_hdmi_set_mode(struct hdmi * hdmi,bool power_on)14 void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on)
15 {
16 uint32_t ctrl = 0;
17 unsigned long flags;
18
19 spin_lock_irqsave(&hdmi->reg_lock, flags);
20 if (power_on) {
21 ctrl |= HDMI_CTRL_ENABLE;
22 if (!hdmi->hdmi_mode) {
23 ctrl |= HDMI_CTRL_HDMI;
24 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
25 ctrl &= ~HDMI_CTRL_HDMI;
26 } else {
27 ctrl |= HDMI_CTRL_HDMI;
28 }
29 } else {
30 ctrl = HDMI_CTRL_HDMI;
31 }
32
33 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
34 spin_unlock_irqrestore(&hdmi->reg_lock, flags);
35 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x",
36 power_on ? "Enable" : "Disable", ctrl);
37 }
38
msm_hdmi_irq(int irq,void * dev_id)39 static irqreturn_t msm_hdmi_irq(int irq, void *dev_id)
40 {
41 struct hdmi *hdmi = dev_id;
42
43 /* Process HPD: */
44 msm_hdmi_connector_irq(hdmi->connector);
45
46 /* Process DDC: */
47 msm_hdmi_i2c_irq(hdmi->i2c);
48
49 /* Process HDCP: */
50 if (hdmi->hdcp_ctrl)
51 msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl);
52
53 /* TODO audio.. */
54
55 return IRQ_HANDLED;
56 }
57
msm_hdmi_destroy(struct hdmi * hdmi)58 static void msm_hdmi_destroy(struct hdmi *hdmi)
59 {
60 /*
61 * at this point, hpd has been disabled,
62 * after flush workq, it's safe to deinit hdcp
63 */
64 if (hdmi->workq) {
65 flush_workqueue(hdmi->workq);
66 destroy_workqueue(hdmi->workq);
67 }
68 msm_hdmi_hdcp_destroy(hdmi);
69
70 if (hdmi->phy_dev) {
71 put_device(hdmi->phy_dev);
72 hdmi->phy = NULL;
73 hdmi->phy_dev = NULL;
74 }
75
76 if (hdmi->i2c)
77 msm_hdmi_i2c_destroy(hdmi->i2c);
78
79 platform_set_drvdata(hdmi->pdev, NULL);
80 }
81
msm_hdmi_get_phy(struct hdmi * hdmi)82 static int msm_hdmi_get_phy(struct hdmi *hdmi)
83 {
84 struct platform_device *pdev = hdmi->pdev;
85 struct platform_device *phy_pdev;
86 struct device_node *phy_node;
87
88 phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0);
89 if (!phy_node) {
90 DRM_DEV_ERROR(&pdev->dev, "cannot find phy device\n");
91 return -ENXIO;
92 }
93
94 phy_pdev = of_find_device_by_node(phy_node);
95 if (phy_pdev)
96 hdmi->phy = platform_get_drvdata(phy_pdev);
97
98 of_node_put(phy_node);
99
100 if (!phy_pdev) {
101 DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
102 return -EPROBE_DEFER;
103 }
104 if (!hdmi->phy) {
105 DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
106 put_device(&phy_pdev->dev);
107 return -EPROBE_DEFER;
108 }
109
110 hdmi->phy_dev = get_device(&phy_pdev->dev);
111
112 return 0;
113 }
114
115 /* construct hdmi at bind/probe time, grab all the resources. If
116 * we are to EPROBE_DEFER we want to do it here, rather than later
117 * at modeset_init() time
118 */
msm_hdmi_init(struct platform_device * pdev)119 static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
120 {
121 struct hdmi_platform_config *config = pdev->dev.platform_data;
122 struct hdmi *hdmi = NULL;
123 struct resource *res;
124 int i, ret;
125
126 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
127 if (!hdmi) {
128 ret = -ENOMEM;
129 goto fail;
130 }
131
132 hdmi->pdev = pdev;
133 hdmi->config = config;
134 spin_lock_init(&hdmi->reg_lock);
135
136 hdmi->mmio = msm_ioremap(pdev, config->mmio_name, "HDMI");
137 if (IS_ERR(hdmi->mmio)) {
138 ret = PTR_ERR(hdmi->mmio);
139 goto fail;
140 }
141
142 /* HDCP needs physical address of hdmi register */
143 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
144 config->mmio_name);
145 if (!res) {
146 ret = -EINVAL;
147 goto fail;
148 }
149 hdmi->mmio_phy_addr = res->start;
150
151 hdmi->qfprom_mmio = msm_ioremap(pdev,
152 config->qfprom_mmio_name, "HDMI_QFPROM");
153 if (IS_ERR(hdmi->qfprom_mmio)) {
154 DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n");
155 hdmi->qfprom_mmio = NULL;
156 }
157
158 hdmi->hpd_regs = devm_kcalloc(&pdev->dev,
159 config->hpd_reg_cnt,
160 sizeof(hdmi->hpd_regs[0]),
161 GFP_KERNEL);
162 if (!hdmi->hpd_regs) {
163 ret = -ENOMEM;
164 goto fail;
165 }
166 for (i = 0; i < config->hpd_reg_cnt; i++) {
167 struct regulator *reg;
168
169 reg = devm_regulator_get(&pdev->dev,
170 config->hpd_reg_names[i]);
171 if (IS_ERR(reg)) {
172 ret = PTR_ERR(reg);
173 DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %s (%d)\n",
174 config->hpd_reg_names[i], ret);
175 goto fail;
176 }
177
178 hdmi->hpd_regs[i] = reg;
179 }
180
181 hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
182 config->pwr_reg_cnt,
183 sizeof(hdmi->pwr_regs[0]),
184 GFP_KERNEL);
185 if (!hdmi->pwr_regs) {
186 ret = -ENOMEM;
187 goto fail;
188 }
189 for (i = 0; i < config->pwr_reg_cnt; i++) {
190 struct regulator *reg;
191
192 reg = devm_regulator_get(&pdev->dev,
193 config->pwr_reg_names[i]);
194 if (IS_ERR(reg)) {
195 ret = PTR_ERR(reg);
196 DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %s (%d)\n",
197 config->pwr_reg_names[i], ret);
198 goto fail;
199 }
200
201 hdmi->pwr_regs[i] = reg;
202 }
203
204 hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
205 config->hpd_clk_cnt,
206 sizeof(hdmi->hpd_clks[0]),
207 GFP_KERNEL);
208 if (!hdmi->hpd_clks) {
209 ret = -ENOMEM;
210 goto fail;
211 }
212 for (i = 0; i < config->hpd_clk_cnt; i++) {
213 struct clk *clk;
214
215 clk = msm_clk_get(pdev, config->hpd_clk_names[i]);
216 if (IS_ERR(clk)) {
217 ret = PTR_ERR(clk);
218 DRM_DEV_ERROR(&pdev->dev, "failed to get hpd clk: %s (%d)\n",
219 config->hpd_clk_names[i], ret);
220 goto fail;
221 }
222
223 hdmi->hpd_clks[i] = clk;
224 }
225
226 hdmi->pwr_clks = devm_kcalloc(&pdev->dev,
227 config->pwr_clk_cnt,
228 sizeof(hdmi->pwr_clks[0]),
229 GFP_KERNEL);
230 if (!hdmi->pwr_clks) {
231 ret = -ENOMEM;
232 goto fail;
233 }
234 for (i = 0; i < config->pwr_clk_cnt; i++) {
235 struct clk *clk;
236
237 clk = msm_clk_get(pdev, config->pwr_clk_names[i]);
238 if (IS_ERR(clk)) {
239 ret = PTR_ERR(clk);
240 DRM_DEV_ERROR(&pdev->dev, "failed to get pwr clk: %s (%d)\n",
241 config->pwr_clk_names[i], ret);
242 goto fail;
243 }
244
245 hdmi->pwr_clks[i] = clk;
246 }
247
248 pm_runtime_enable(&pdev->dev);
249
250 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0);
251
252 hdmi->i2c = msm_hdmi_i2c_init(hdmi);
253 if (IS_ERR(hdmi->i2c)) {
254 ret = PTR_ERR(hdmi->i2c);
255 DRM_DEV_ERROR(&pdev->dev, "failed to get i2c: %d\n", ret);
256 hdmi->i2c = NULL;
257 goto fail;
258 }
259
260 ret = msm_hdmi_get_phy(hdmi);
261 if (ret) {
262 DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n");
263 goto fail;
264 }
265
266 hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi);
267 if (IS_ERR(hdmi->hdcp_ctrl)) {
268 dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
269 hdmi->hdcp_ctrl = NULL;
270 }
271
272 return hdmi;
273
274 fail:
275 if (hdmi)
276 msm_hdmi_destroy(hdmi);
277
278 return ERR_PTR(ret);
279 }
280
281 /* Second part of initialization, the drm/kms level modeset_init,
282 * constructs/initializes mode objects, etc, is called from master
283 * driver (not hdmi sub-device's probe/bind!)
284 *
285 * Any resource (regulator/clk/etc) which could be missing at boot
286 * should be handled in msm_hdmi_init() so that failure happens from
287 * hdmi sub-device's probe.
288 */
msm_hdmi_modeset_init(struct hdmi * hdmi,struct drm_device * dev,struct drm_encoder * encoder)289 int msm_hdmi_modeset_init(struct hdmi *hdmi,
290 struct drm_device *dev, struct drm_encoder *encoder)
291 {
292 struct msm_drm_private *priv = dev->dev_private;
293 struct platform_device *pdev = hdmi->pdev;
294 int ret;
295
296 if (priv->num_bridges == ARRAY_SIZE(priv->bridges)) {
297 DRM_DEV_ERROR(dev->dev, "too many bridges\n");
298 return -ENOSPC;
299 }
300
301 hdmi->dev = dev;
302 hdmi->encoder = encoder;
303
304 hdmi_audio_infoframe_init(&hdmi->audio.infoframe);
305
306 hdmi->bridge = msm_hdmi_bridge_init(hdmi);
307 if (IS_ERR(hdmi->bridge)) {
308 ret = PTR_ERR(hdmi->bridge);
309 DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret);
310 hdmi->bridge = NULL;
311 goto fail;
312 }
313
314 hdmi->connector = msm_hdmi_connector_init(hdmi);
315 if (IS_ERR(hdmi->connector)) {
316 ret = PTR_ERR(hdmi->connector);
317 DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret);
318 hdmi->connector = NULL;
319 goto fail;
320 }
321
322 hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
323 if (!hdmi->irq) {
324 ret = -EINVAL;
325 DRM_DEV_ERROR(dev->dev, "failed to get irq\n");
326 goto fail;
327 }
328
329 ret = devm_request_irq(dev->dev, hdmi->irq,
330 msm_hdmi_irq, IRQF_TRIGGER_HIGH,
331 "hdmi_isr", hdmi);
332 if (ret < 0) {
333 DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n",
334 hdmi->irq, ret);
335 goto fail;
336 }
337
338 ret = msm_hdmi_hpd_enable(hdmi->connector);
339 if (ret < 0) {
340 DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to enable HPD: %d\n", ret);
341 goto fail;
342 }
343
344 priv->bridges[priv->num_bridges++] = hdmi->bridge;
345 priv->connectors[priv->num_connectors++] = hdmi->connector;
346
347 platform_set_drvdata(pdev, hdmi);
348
349 return 0;
350
351 fail:
352 /* bridge is normally destroyed by drm: */
353 if (hdmi->bridge) {
354 msm_hdmi_bridge_destroy(hdmi->bridge);
355 hdmi->bridge = NULL;
356 }
357 if (hdmi->connector) {
358 hdmi->connector->funcs->destroy(hdmi->connector);
359 hdmi->connector = NULL;
360 }
361
362 return ret;
363 }
364
365 /*
366 * The hdmi device:
367 */
368
369 #define HDMI_CFG(item, entry) \
370 .item ## _names = item ##_names_ ## entry, \
371 .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry)
372
373 static const char *pwr_reg_names_none[] = {};
374 static const char *hpd_reg_names_none[] = {};
375
376 static struct hdmi_platform_config hdmi_tx_8660_config;
377
378 static const char *hpd_reg_names_8960[] = {"core-vdda", "hdmi-mux"};
379 static const char *hpd_clk_names_8960[] = {"core", "master_iface", "slave_iface"};
380
381 static struct hdmi_platform_config hdmi_tx_8960_config = {
382 HDMI_CFG(hpd_reg, 8960),
383 HDMI_CFG(hpd_clk, 8960),
384 };
385
386 static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
387 static const char *hpd_reg_names_8x74[] = {"hpd-gdsc", "hpd-5v"};
388 static const char *pwr_clk_names_8x74[] = {"extp", "alt_iface"};
389 static const char *hpd_clk_names_8x74[] = {"iface", "core", "mdp_core"};
390 static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0};
391
392 static struct hdmi_platform_config hdmi_tx_8974_config = {
393 HDMI_CFG(pwr_reg, 8x74),
394 HDMI_CFG(hpd_reg, 8x74),
395 HDMI_CFG(pwr_clk, 8x74),
396 HDMI_CFG(hpd_clk, 8x74),
397 .hpd_freq = hpd_clk_freq_8x74,
398 };
399
400 static const char *hpd_reg_names_8084[] = {"hpd-gdsc", "hpd-5v", "hpd-5v-en"};
401
402 static struct hdmi_platform_config hdmi_tx_8084_config = {
403 HDMI_CFG(pwr_reg, 8x74),
404 HDMI_CFG(hpd_reg, 8084),
405 HDMI_CFG(pwr_clk, 8x74),
406 HDMI_CFG(hpd_clk, 8x74),
407 .hpd_freq = hpd_clk_freq_8x74,
408 };
409
410 static struct hdmi_platform_config hdmi_tx_8994_config = {
411 HDMI_CFG(pwr_reg, 8x74),
412 HDMI_CFG(hpd_reg, none),
413 HDMI_CFG(pwr_clk, 8x74),
414 HDMI_CFG(hpd_clk, 8x74),
415 .hpd_freq = hpd_clk_freq_8x74,
416 };
417
418 static struct hdmi_platform_config hdmi_tx_8996_config = {
419 HDMI_CFG(pwr_reg, none),
420 HDMI_CFG(hpd_reg, none),
421 HDMI_CFG(pwr_clk, 8x74),
422 HDMI_CFG(hpd_clk, 8x74),
423 .hpd_freq = hpd_clk_freq_8x74,
424 };
425
426 static const struct {
427 const char *name;
428 const bool output;
429 const int value;
430 const char *label;
431 } msm_hdmi_gpio_pdata[] = {
432 { "qcom,hdmi-tx-ddc-clk", true, 1, "HDMI_DDC_CLK" },
433 { "qcom,hdmi-tx-ddc-data", true, 1, "HDMI_DDC_DATA" },
434 { "qcom,hdmi-tx-hpd", false, 1, "HDMI_HPD" },
435 { "qcom,hdmi-tx-mux-en", true, 1, "HDMI_MUX_EN" },
436 { "qcom,hdmi-tx-mux-sel", true, 0, "HDMI_MUX_SEL" },
437 { "qcom,hdmi-tx-mux-lpm", true, 1, "HDMI_MUX_LPM" },
438 };
439
440 /*
441 * HDMI audio codec callbacks
442 */
msm_hdmi_audio_hw_params(struct device * dev,void * data,struct hdmi_codec_daifmt * daifmt,struct hdmi_codec_params * params)443 static int msm_hdmi_audio_hw_params(struct device *dev, void *data,
444 struct hdmi_codec_daifmt *daifmt,
445 struct hdmi_codec_params *params)
446 {
447 struct hdmi *hdmi = dev_get_drvdata(dev);
448 unsigned int chan;
449 unsigned int channel_allocation = 0;
450 unsigned int rate;
451 unsigned int level_shift = 0; /* 0dB */
452 bool down_mix = false;
453
454 DRM_DEV_DEBUG(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate,
455 params->sample_width, params->cea.channels);
456
457 switch (params->cea.channels) {
458 case 2:
459 /* FR and FL speakers */
460 channel_allocation = 0;
461 chan = MSM_HDMI_AUDIO_CHANNEL_2;
462 break;
463 case 4:
464 /* FC, LFE, FR and FL speakers */
465 channel_allocation = 0x3;
466 chan = MSM_HDMI_AUDIO_CHANNEL_4;
467 break;
468 case 6:
469 /* RR, RL, FC, LFE, FR and FL speakers */
470 channel_allocation = 0x0B;
471 chan = MSM_HDMI_AUDIO_CHANNEL_6;
472 break;
473 case 8:
474 /* FRC, FLC, RR, RL, FC, LFE, FR and FL speakers */
475 channel_allocation = 0x1F;
476 chan = MSM_HDMI_AUDIO_CHANNEL_8;
477 break;
478 default:
479 return -EINVAL;
480 }
481
482 switch (params->sample_rate) {
483 case 32000:
484 rate = HDMI_SAMPLE_RATE_32KHZ;
485 break;
486 case 44100:
487 rate = HDMI_SAMPLE_RATE_44_1KHZ;
488 break;
489 case 48000:
490 rate = HDMI_SAMPLE_RATE_48KHZ;
491 break;
492 case 88200:
493 rate = HDMI_SAMPLE_RATE_88_2KHZ;
494 break;
495 case 96000:
496 rate = HDMI_SAMPLE_RATE_96KHZ;
497 break;
498 case 176400:
499 rate = HDMI_SAMPLE_RATE_176_4KHZ;
500 break;
501 case 192000:
502 rate = HDMI_SAMPLE_RATE_192KHZ;
503 break;
504 default:
505 DRM_DEV_ERROR(dev, "rate[%d] not supported!\n",
506 params->sample_rate);
507 return -EINVAL;
508 }
509
510 msm_hdmi_audio_set_sample_rate(hdmi, rate);
511 msm_hdmi_audio_info_setup(hdmi, 1, chan, channel_allocation,
512 level_shift, down_mix);
513
514 return 0;
515 }
516
msm_hdmi_audio_shutdown(struct device * dev,void * data)517 static void msm_hdmi_audio_shutdown(struct device *dev, void *data)
518 {
519 struct hdmi *hdmi = dev_get_drvdata(dev);
520
521 msm_hdmi_audio_info_setup(hdmi, 0, 0, 0, 0, 0);
522 }
523
524 static const struct hdmi_codec_ops msm_hdmi_audio_codec_ops = {
525 .hw_params = msm_hdmi_audio_hw_params,
526 .audio_shutdown = msm_hdmi_audio_shutdown,
527 };
528
529 static struct hdmi_codec_pdata codec_data = {
530 .ops = &msm_hdmi_audio_codec_ops,
531 .max_i2s_channels = 8,
532 .i2s = 1,
533 };
534
msm_hdmi_register_audio_driver(struct hdmi * hdmi,struct device * dev)535 static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev)
536 {
537 hdmi->audio_pdev = platform_device_register_data(dev,
538 HDMI_CODEC_DRV_NAME,
539 PLATFORM_DEVID_AUTO,
540 &codec_data,
541 sizeof(codec_data));
542 return PTR_ERR_OR_ZERO(hdmi->audio_pdev);
543 }
544
msm_hdmi_bind(struct device * dev,struct device * master,void * data)545 static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
546 {
547 struct drm_device *drm = dev_get_drvdata(master);
548 struct msm_drm_private *priv = drm->dev_private;
549 struct hdmi_platform_config *hdmi_cfg;
550 struct hdmi *hdmi;
551 struct device_node *of_node = dev->of_node;
552 int i, err;
553
554 hdmi_cfg = (struct hdmi_platform_config *)
555 of_device_get_match_data(dev);
556 if (!hdmi_cfg) {
557 DRM_DEV_ERROR(dev, "unknown hdmi_cfg: %pOFn\n", of_node);
558 return -ENXIO;
559 }
560
561 hdmi_cfg->mmio_name = "core_physical";
562 hdmi_cfg->qfprom_mmio_name = "qfprom_physical";
563
564 for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
565 const char *name = msm_hdmi_gpio_pdata[i].name;
566 struct gpio_desc *gpiod;
567
568 /*
569 * We are fetching the GPIO lines "as is" since the connector
570 * code is enabling and disabling the lines. Until that point
571 * the power-on default value will be kept.
572 */
573 gpiod = devm_gpiod_get_optional(dev, name, GPIOD_ASIS);
574 /* This will catch e.g. -PROBE_DEFER */
575 if (IS_ERR(gpiod))
576 return PTR_ERR(gpiod);
577 if (!gpiod) {
578 /* Try a second time, stripping down the name */
579 char name3[32];
580
581 /*
582 * Try again after stripping out the "qcom,hdmi-tx"
583 * prefix. This is mainly to match "hpd-gpios" used
584 * in the upstream bindings.
585 */
586 if (sscanf(name, "qcom,hdmi-tx-%s", name3))
587 gpiod = devm_gpiod_get_optional(dev, name3, GPIOD_ASIS);
588 if (IS_ERR(gpiod))
589 return PTR_ERR(gpiod);
590 if (!gpiod)
591 DBG("failed to get gpio: %s", name);
592 }
593 hdmi_cfg->gpios[i].gpiod = gpiod;
594 if (gpiod)
595 gpiod_set_consumer_name(gpiod, msm_hdmi_gpio_pdata[i].label);
596 hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output;
597 hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value;
598 }
599
600 dev->platform_data = hdmi_cfg;
601
602 hdmi = msm_hdmi_init(to_platform_device(dev));
603 if (IS_ERR(hdmi))
604 return PTR_ERR(hdmi);
605 priv->hdmi = hdmi;
606
607 err = msm_hdmi_register_audio_driver(hdmi, dev);
608 if (err) {
609 DRM_ERROR("Failed to attach an audio codec %d\n", err);
610 hdmi->audio_pdev = NULL;
611 }
612
613 return 0;
614 }
615
msm_hdmi_unbind(struct device * dev,struct device * master,void * data)616 static void msm_hdmi_unbind(struct device *dev, struct device *master,
617 void *data)
618 {
619 struct drm_device *drm = dev_get_drvdata(master);
620 struct msm_drm_private *priv = drm->dev_private;
621 if (priv->hdmi) {
622 if (priv->hdmi->audio_pdev)
623 platform_device_unregister(priv->hdmi->audio_pdev);
624
625 msm_hdmi_destroy(priv->hdmi);
626 priv->hdmi = NULL;
627 }
628 }
629
630 static const struct component_ops msm_hdmi_ops = {
631 .bind = msm_hdmi_bind,
632 .unbind = msm_hdmi_unbind,
633 };
634
msm_hdmi_dev_probe(struct platform_device * pdev)635 static int msm_hdmi_dev_probe(struct platform_device *pdev)
636 {
637 return component_add(&pdev->dev, &msm_hdmi_ops);
638 }
639
msm_hdmi_dev_remove(struct platform_device * pdev)640 static int msm_hdmi_dev_remove(struct platform_device *pdev)
641 {
642 component_del(&pdev->dev, &msm_hdmi_ops);
643 return 0;
644 }
645
646 static const struct of_device_id msm_hdmi_dt_match[] = {
647 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8996_config },
648 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8994_config },
649 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8084_config },
650 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
651 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
652 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8660_config },
653 {}
654 };
655
656 static struct platform_driver msm_hdmi_driver = {
657 .probe = msm_hdmi_dev_probe,
658 .remove = msm_hdmi_dev_remove,
659 .driver = {
660 .name = "hdmi_msm",
661 .of_match_table = msm_hdmi_dt_match,
662 },
663 };
664
msm_hdmi_register(void)665 void __init msm_hdmi_register(void)
666 {
667 msm_hdmi_phy_driver_register();
668 platform_driver_register(&msm_hdmi_driver);
669 }
670
msm_hdmi_unregister(void)671 void __exit msm_hdmi_unregister(void)
672 {
673 platform_driver_unregister(&msm_hdmi_driver);
674 msm_hdmi_phy_driver_unregister();
675 }
676