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