]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/gpu/drm/omapdrm/dss/hdmi4.c
drm/omap: convert dss_mgr_connect to accept omap_channel
[mirror_ubuntu-artful-kernel.git] / drivers / gpu / drm / omapdrm / dss / hdmi4.c
1 /*
2 * HDMI interface DSS driver for TI's OMAP4 family of SoCs.
3 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
4 * Authors: Yong Zhi
5 * Mythri pk <mythripk@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #define DSS_SUBSYS_NAME "HDMI"
21
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/err.h>
25 #include <linux/io.h>
26 #include <linux/interrupt.h>
27 #include <linux/mutex.h>
28 #include <linux/delay.h>
29 #include <linux/string.h>
30 #include <linux/platform_device.h>
31 #include <linux/pm_runtime.h>
32 #include <linux/clk.h>
33 #include <linux/gpio.h>
34 #include <linux/regulator/consumer.h>
35 #include <linux/component.h>
36 #include <video/omapdss.h>
37 #include <sound/omap-hdmi-audio.h>
38
39 #include "hdmi4_core.h"
40 #include "dss.h"
41 #include "dss_features.h"
42 #include "hdmi.h"
43
44 static struct omap_hdmi hdmi;
45
46 static int hdmi_runtime_get(void)
47 {
48 int r;
49
50 DSSDBG("hdmi_runtime_get\n");
51
52 r = pm_runtime_get_sync(&hdmi.pdev->dev);
53 WARN_ON(r < 0);
54 if (r < 0)
55 return r;
56
57 return 0;
58 }
59
60 static void hdmi_runtime_put(void)
61 {
62 int r;
63
64 DSSDBG("hdmi_runtime_put\n");
65
66 r = pm_runtime_put_sync(&hdmi.pdev->dev);
67 WARN_ON(r < 0 && r != -ENOSYS);
68 }
69
70 static irqreturn_t hdmi_irq_handler(int irq, void *data)
71 {
72 struct hdmi_wp_data *wp = data;
73 u32 irqstatus;
74
75 irqstatus = hdmi_wp_get_irqstatus(wp);
76 hdmi_wp_set_irqstatus(wp, irqstatus);
77
78 if ((irqstatus & HDMI_IRQ_LINK_CONNECT) &&
79 irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
80 /*
81 * If we get both connect and disconnect interrupts at the same
82 * time, turn off the PHY, clear interrupts, and restart, which
83 * raises connect interrupt if a cable is connected, or nothing
84 * if cable is not connected.
85 */
86 hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_OFF);
87
88 hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT |
89 HDMI_IRQ_LINK_DISCONNECT);
90
91 hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
92 } else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
93 hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON);
94 } else if (irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
95 hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
96 }
97
98 return IRQ_HANDLED;
99 }
100
101 static int hdmi_init_regulator(void)
102 {
103 int r;
104 struct regulator *reg;
105
106 if (hdmi.vdda_reg != NULL)
107 return 0;
108
109 reg = devm_regulator_get(&hdmi.pdev->dev, "vdda");
110
111 if (IS_ERR(reg)) {
112 if (PTR_ERR(reg) != -EPROBE_DEFER)
113 DSSERR("can't get VDDA regulator\n");
114 return PTR_ERR(reg);
115 }
116
117 if (regulator_can_change_voltage(reg)) {
118 r = regulator_set_voltage(reg, 1800000, 1800000);
119 if (r) {
120 devm_regulator_put(reg);
121 DSSWARN("can't set the regulator voltage\n");
122 return r;
123 }
124 }
125
126 hdmi.vdda_reg = reg;
127
128 return 0;
129 }
130
131 static int hdmi_power_on_core(struct omap_dss_device *dssdev)
132 {
133 int r;
134
135 r = regulator_enable(hdmi.vdda_reg);
136 if (r)
137 return r;
138
139 r = hdmi_runtime_get();
140 if (r)
141 goto err_runtime_get;
142
143 /* Make selection of HDMI in DSS */
144 dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
145
146 hdmi.core_enabled = true;
147
148 return 0;
149
150 err_runtime_get:
151 regulator_disable(hdmi.vdda_reg);
152
153 return r;
154 }
155
156 static void hdmi_power_off_core(struct omap_dss_device *dssdev)
157 {
158 hdmi.core_enabled = false;
159
160 hdmi_runtime_put();
161 regulator_disable(hdmi.vdda_reg);
162 }
163
164 static int hdmi_power_on_full(struct omap_dss_device *dssdev)
165 {
166 int r;
167 struct omap_video_timings *p;
168 struct omap_overlay_manager *mgr = hdmi.output.manager;
169 struct hdmi_wp_data *wp = &hdmi.wp;
170 struct dss_pll_clock_info hdmi_cinfo = { 0 };
171 unsigned pc;
172
173 r = hdmi_power_on_core(dssdev);
174 if (r)
175 return r;
176
177 /* disable and clear irqs */
178 hdmi_wp_clear_irqenable(wp, 0xffffffff);
179 hdmi_wp_set_irqstatus(wp, 0xffffffff);
180
181 p = &hdmi.cfg.timings;
182
183 DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
184
185 pc = p->pixelclock;
186 if (p->double_pixel)
187 pc *= 2;
188
189 hdmi_pll_compute(&hdmi.pll, pc, &hdmi_cinfo);
190
191 r = dss_pll_enable(&hdmi.pll.pll);
192 if (r) {
193 DSSERR("Failed to enable PLL\n");
194 goto err_pll_enable;
195 }
196
197 r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo);
198 if (r) {
199 DSSERR("Failed to configure PLL\n");
200 goto err_pll_cfg;
201 }
202
203 r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco,
204 hdmi_cinfo.clkout[0]);
205 if (r) {
206 DSSDBG("Failed to configure PHY\n");
207 goto err_phy_cfg;
208 }
209
210 r = hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
211 if (r)
212 goto err_phy_pwr;
213
214 hdmi4_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
215
216 /* bypass TV gamma table */
217 dispc_enable_gamma_table(0);
218
219 /* tv size */
220 dss_mgr_set_timings(mgr, p);
221
222 r = dss_mgr_enable(mgr);
223 if (r)
224 goto err_mgr_enable;
225
226 r = hdmi_wp_video_start(&hdmi.wp);
227 if (r)
228 goto err_vid_enable;
229
230 hdmi_wp_set_irqenable(wp,
231 HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
232
233 return 0;
234
235 err_vid_enable:
236 dss_mgr_disable(mgr);
237 err_mgr_enable:
238 hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
239 err_phy_pwr:
240 err_phy_cfg:
241 err_pll_cfg:
242 dss_pll_disable(&hdmi.pll.pll);
243 err_pll_enable:
244 hdmi_power_off_core(dssdev);
245 return -EIO;
246 }
247
248 static void hdmi_power_off_full(struct omap_dss_device *dssdev)
249 {
250 struct omap_overlay_manager *mgr = hdmi.output.manager;
251
252 hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
253
254 hdmi_wp_video_stop(&hdmi.wp);
255
256 dss_mgr_disable(mgr);
257
258 hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
259
260 dss_pll_disable(&hdmi.pll.pll);
261
262 hdmi_power_off_core(dssdev);
263 }
264
265 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
266 struct omap_video_timings *timings)
267 {
268 struct omap_dss_device *out = &hdmi.output;
269
270 if (!dispc_mgr_timings_ok(out->dispc_channel, timings))
271 return -EINVAL;
272
273 return 0;
274 }
275
276 static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
277 struct omap_video_timings *timings)
278 {
279 mutex_lock(&hdmi.lock);
280
281 hdmi.cfg.timings = *timings;
282
283 dispc_set_tv_pclk(timings->pixelclock);
284
285 mutex_unlock(&hdmi.lock);
286 }
287
288 static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
289 struct omap_video_timings *timings)
290 {
291 *timings = hdmi.cfg.timings;
292 }
293
294 static void hdmi_dump_regs(struct seq_file *s)
295 {
296 mutex_lock(&hdmi.lock);
297
298 if (hdmi_runtime_get()) {
299 mutex_unlock(&hdmi.lock);
300 return;
301 }
302
303 hdmi_wp_dump(&hdmi.wp, s);
304 hdmi_pll_dump(&hdmi.pll, s);
305 hdmi_phy_dump(&hdmi.phy, s);
306 hdmi4_core_dump(&hdmi.core, s);
307
308 hdmi_runtime_put();
309 mutex_unlock(&hdmi.lock);
310 }
311
312 static int read_edid(u8 *buf, int len)
313 {
314 int r;
315
316 mutex_lock(&hdmi.lock);
317
318 r = hdmi_runtime_get();
319 BUG_ON(r);
320
321 r = hdmi4_read_edid(&hdmi.core, buf, len);
322
323 hdmi_runtime_put();
324 mutex_unlock(&hdmi.lock);
325
326 return r;
327 }
328
329 static void hdmi_start_audio_stream(struct omap_hdmi *hd)
330 {
331 hdmi_wp_audio_enable(&hd->wp, true);
332 hdmi4_audio_start(&hd->core, &hd->wp);
333 }
334
335 static void hdmi_stop_audio_stream(struct omap_hdmi *hd)
336 {
337 hdmi4_audio_stop(&hd->core, &hd->wp);
338 hdmi_wp_audio_enable(&hd->wp, false);
339 }
340
341 static int hdmi_display_enable(struct omap_dss_device *dssdev)
342 {
343 struct omap_dss_device *out = &hdmi.output;
344 unsigned long flags;
345 int r = 0;
346
347 DSSDBG("ENTER hdmi_display_enable\n");
348
349 mutex_lock(&hdmi.lock);
350
351 if (!out->dispc_channel_connected) {
352 DSSERR("failed to enable display: no output/manager\n");
353 r = -ENODEV;
354 goto err0;
355 }
356
357 r = hdmi_power_on_full(dssdev);
358 if (r) {
359 DSSERR("failed to power on device\n");
360 goto err0;
361 }
362
363 if (hdmi.audio_configured) {
364 r = hdmi4_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config,
365 hdmi.cfg.timings.pixelclock);
366 if (r) {
367 DSSERR("Error restoring audio configuration: %d", r);
368 hdmi.audio_abort_cb(&hdmi.pdev->dev);
369 hdmi.audio_configured = false;
370 }
371 }
372
373 spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
374 if (hdmi.audio_configured && hdmi.audio_playing)
375 hdmi_start_audio_stream(&hdmi);
376 hdmi.display_enabled = true;
377 spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
378
379 mutex_unlock(&hdmi.lock);
380 return 0;
381
382 err0:
383 mutex_unlock(&hdmi.lock);
384 return r;
385 }
386
387 static void hdmi_display_disable(struct omap_dss_device *dssdev)
388 {
389 unsigned long flags;
390
391 DSSDBG("Enter hdmi_display_disable\n");
392
393 mutex_lock(&hdmi.lock);
394
395 spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
396 hdmi_stop_audio_stream(&hdmi);
397 hdmi.display_enabled = false;
398 spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
399
400 hdmi_power_off_full(dssdev);
401
402 mutex_unlock(&hdmi.lock);
403 }
404
405 static int hdmi_core_enable(struct omap_dss_device *dssdev)
406 {
407 int r = 0;
408
409 DSSDBG("ENTER omapdss_hdmi_core_enable\n");
410
411 mutex_lock(&hdmi.lock);
412
413 r = hdmi_power_on_core(dssdev);
414 if (r) {
415 DSSERR("failed to power on device\n");
416 goto err0;
417 }
418
419 mutex_unlock(&hdmi.lock);
420 return 0;
421
422 err0:
423 mutex_unlock(&hdmi.lock);
424 return r;
425 }
426
427 static void hdmi_core_disable(struct omap_dss_device *dssdev)
428 {
429 DSSDBG("Enter omapdss_hdmi_core_disable\n");
430
431 mutex_lock(&hdmi.lock);
432
433 hdmi_power_off_core(dssdev);
434
435 mutex_unlock(&hdmi.lock);
436 }
437
438 static int hdmi_connect(struct omap_dss_device *dssdev,
439 struct omap_dss_device *dst)
440 {
441 struct omap_overlay_manager *mgr;
442 int r;
443
444 r = hdmi_init_regulator();
445 if (r)
446 return r;
447
448 mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
449 if (!mgr)
450 return -ENODEV;
451
452 r = dss_mgr_connect(mgr->id, dssdev);
453 if (r)
454 return r;
455
456 r = omapdss_output_set_device(dssdev, dst);
457 if (r) {
458 DSSERR("failed to connect output to new device: %s\n",
459 dst->name);
460 dss_mgr_disconnect(mgr, dssdev);
461 return r;
462 }
463
464 return 0;
465 }
466
467 static void hdmi_disconnect(struct omap_dss_device *dssdev,
468 struct omap_dss_device *dst)
469 {
470 WARN_ON(dst != dssdev->dst);
471
472 if (dst != dssdev->dst)
473 return;
474
475 omapdss_output_unset_device(dssdev);
476
477 if (dssdev->manager)
478 dss_mgr_disconnect(dssdev->manager, dssdev);
479 }
480
481 static int hdmi_read_edid(struct omap_dss_device *dssdev,
482 u8 *edid, int len)
483 {
484 bool need_enable;
485 int r;
486
487 need_enable = hdmi.core_enabled == false;
488
489 if (need_enable) {
490 r = hdmi_core_enable(dssdev);
491 if (r)
492 return r;
493 }
494
495 r = read_edid(edid, len);
496
497 if (need_enable)
498 hdmi_core_disable(dssdev);
499
500 return r;
501 }
502
503 static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
504 const struct hdmi_avi_infoframe *avi)
505 {
506 hdmi.cfg.infoframe = *avi;
507 return 0;
508 }
509
510 static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
511 bool hdmi_mode)
512 {
513 hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
514 return 0;
515 }
516
517 static const struct omapdss_hdmi_ops hdmi_ops = {
518 .connect = hdmi_connect,
519 .disconnect = hdmi_disconnect,
520
521 .enable = hdmi_display_enable,
522 .disable = hdmi_display_disable,
523
524 .check_timings = hdmi_display_check_timing,
525 .set_timings = hdmi_display_set_timing,
526 .get_timings = hdmi_display_get_timings,
527
528 .read_edid = hdmi_read_edid,
529 .set_infoframe = hdmi_set_infoframe,
530 .set_hdmi_mode = hdmi_set_hdmi_mode,
531 };
532
533 static void hdmi_init_output(struct platform_device *pdev)
534 {
535 struct omap_dss_device *out = &hdmi.output;
536
537 out->dev = &pdev->dev;
538 out->id = OMAP_DSS_OUTPUT_HDMI;
539 out->output_type = OMAP_DISPLAY_TYPE_HDMI;
540 out->name = "hdmi.0";
541 out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
542 out->ops.hdmi = &hdmi_ops;
543 out->owner = THIS_MODULE;
544
545 omapdss_register_output(out);
546 }
547
548 static void hdmi_uninit_output(struct platform_device *pdev)
549 {
550 struct omap_dss_device *out = &hdmi.output;
551
552 omapdss_unregister_output(out);
553 }
554
555 static int hdmi_probe_of(struct platform_device *pdev)
556 {
557 struct device_node *node = pdev->dev.of_node;
558 struct device_node *ep;
559 int r;
560
561 ep = omapdss_of_get_first_endpoint(node);
562 if (!ep)
563 return 0;
564
565 r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy);
566 if (r)
567 goto err;
568
569 of_node_put(ep);
570 return 0;
571
572 err:
573 of_node_put(ep);
574 return r;
575 }
576
577 /* Audio callbacks */
578 static int hdmi_audio_startup(struct device *dev,
579 void (*abort_cb)(struct device *dev))
580 {
581 struct omap_hdmi *hd = dev_get_drvdata(dev);
582 int ret = 0;
583
584 mutex_lock(&hd->lock);
585
586 if (!hdmi_mode_has_audio(&hd->cfg) || !hd->display_enabled) {
587 ret = -EPERM;
588 goto out;
589 }
590
591 hd->audio_abort_cb = abort_cb;
592
593 out:
594 mutex_unlock(&hd->lock);
595
596 return ret;
597 }
598
599 static int hdmi_audio_shutdown(struct device *dev)
600 {
601 struct omap_hdmi *hd = dev_get_drvdata(dev);
602
603 mutex_lock(&hd->lock);
604 hd->audio_abort_cb = NULL;
605 hd->audio_configured = false;
606 hd->audio_playing = false;
607 mutex_unlock(&hd->lock);
608
609 return 0;
610 }
611
612 static int hdmi_audio_start(struct device *dev)
613 {
614 struct omap_hdmi *hd = dev_get_drvdata(dev);
615 unsigned long flags;
616
617 WARN_ON(!hdmi_mode_has_audio(&hd->cfg));
618
619 spin_lock_irqsave(&hd->audio_playing_lock, flags);
620
621 if (hd->display_enabled)
622 hdmi_start_audio_stream(hd);
623 hd->audio_playing = true;
624
625 spin_unlock_irqrestore(&hd->audio_playing_lock, flags);
626 return 0;
627 }
628
629 static void hdmi_audio_stop(struct device *dev)
630 {
631 struct omap_hdmi *hd = dev_get_drvdata(dev);
632 unsigned long flags;
633
634 WARN_ON(!hdmi_mode_has_audio(&hd->cfg));
635
636 spin_lock_irqsave(&hd->audio_playing_lock, flags);
637
638 if (hd->display_enabled)
639 hdmi_stop_audio_stream(hd);
640 hd->audio_playing = false;
641
642 spin_unlock_irqrestore(&hd->audio_playing_lock, flags);
643 }
644
645 static int hdmi_audio_config(struct device *dev,
646 struct omap_dss_audio *dss_audio)
647 {
648 struct omap_hdmi *hd = dev_get_drvdata(dev);
649 int ret;
650
651 mutex_lock(&hd->lock);
652
653 if (!hdmi_mode_has_audio(&hd->cfg) || !hd->display_enabled) {
654 ret = -EPERM;
655 goto out;
656 }
657
658 ret = hdmi4_audio_config(&hd->core, &hd->wp, dss_audio,
659 hd->cfg.timings.pixelclock);
660 if (!ret) {
661 hd->audio_configured = true;
662 hd->audio_config = *dss_audio;
663 }
664 out:
665 mutex_unlock(&hd->lock);
666
667 return ret;
668 }
669
670 static const struct omap_hdmi_audio_ops hdmi_audio_ops = {
671 .audio_startup = hdmi_audio_startup,
672 .audio_shutdown = hdmi_audio_shutdown,
673 .audio_start = hdmi_audio_start,
674 .audio_stop = hdmi_audio_stop,
675 .audio_config = hdmi_audio_config,
676 };
677
678 static int hdmi_audio_register(struct device *dev)
679 {
680 struct omap_hdmi_audio_pdata pdata = {
681 .dev = dev,
682 .dss_version = omapdss_get_version(),
683 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp),
684 .ops = &hdmi_audio_ops,
685 };
686
687 hdmi.audio_pdev = platform_device_register_data(
688 dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
689 &pdata, sizeof(pdata));
690
691 if (IS_ERR(hdmi.audio_pdev))
692 return PTR_ERR(hdmi.audio_pdev);
693
694 return 0;
695 }
696
697 /* HDMI HW IP initialisation */
698 static int hdmi4_bind(struct device *dev, struct device *master, void *data)
699 {
700 struct platform_device *pdev = to_platform_device(dev);
701 int r;
702 int irq;
703
704 hdmi.pdev = pdev;
705 dev_set_drvdata(&pdev->dev, &hdmi);
706
707 mutex_init(&hdmi.lock);
708 spin_lock_init(&hdmi.audio_playing_lock);
709
710 if (pdev->dev.of_node) {
711 r = hdmi_probe_of(pdev);
712 if (r)
713 return r;
714 }
715
716 r = hdmi_wp_init(pdev, &hdmi.wp);
717 if (r)
718 return r;
719
720 r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
721 if (r)
722 return r;
723
724 r = hdmi_phy_init(pdev, &hdmi.phy);
725 if (r)
726 goto err;
727
728 r = hdmi4_core_init(pdev, &hdmi.core);
729 if (r)
730 goto err;
731
732 irq = platform_get_irq(pdev, 0);
733 if (irq < 0) {
734 DSSERR("platform_get_irq failed\n");
735 r = -ENODEV;
736 goto err;
737 }
738
739 r = devm_request_threaded_irq(&pdev->dev, irq,
740 NULL, hdmi_irq_handler,
741 IRQF_ONESHOT, "OMAP HDMI", &hdmi.wp);
742 if (r) {
743 DSSERR("HDMI IRQ request failed\n");
744 goto err;
745 }
746
747 pm_runtime_enable(&pdev->dev);
748
749 hdmi_init_output(pdev);
750
751 r = hdmi_audio_register(&pdev->dev);
752 if (r) {
753 DSSERR("Registering HDMI audio failed\n");
754 hdmi_uninit_output(pdev);
755 pm_runtime_disable(&pdev->dev);
756 return r;
757 }
758
759 dss_debugfs_create_file("hdmi", hdmi_dump_regs);
760
761 return 0;
762 err:
763 hdmi_pll_uninit(&hdmi.pll);
764 return r;
765 }
766
767 static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
768 {
769 struct platform_device *pdev = to_platform_device(dev);
770
771 if (hdmi.audio_pdev)
772 platform_device_unregister(hdmi.audio_pdev);
773
774 hdmi_uninit_output(pdev);
775
776 hdmi_pll_uninit(&hdmi.pll);
777
778 pm_runtime_disable(&pdev->dev);
779 }
780
781 static const struct component_ops hdmi4_component_ops = {
782 .bind = hdmi4_bind,
783 .unbind = hdmi4_unbind,
784 };
785
786 static int hdmi4_probe(struct platform_device *pdev)
787 {
788 return component_add(&pdev->dev, &hdmi4_component_ops);
789 }
790
791 static int hdmi4_remove(struct platform_device *pdev)
792 {
793 component_del(&pdev->dev, &hdmi4_component_ops);
794 return 0;
795 }
796
797 static int hdmi_runtime_suspend(struct device *dev)
798 {
799 dispc_runtime_put();
800
801 return 0;
802 }
803
804 static int hdmi_runtime_resume(struct device *dev)
805 {
806 int r;
807
808 r = dispc_runtime_get();
809 if (r < 0)
810 return r;
811
812 return 0;
813 }
814
815 static const struct dev_pm_ops hdmi_pm_ops = {
816 .runtime_suspend = hdmi_runtime_suspend,
817 .runtime_resume = hdmi_runtime_resume,
818 };
819
820 static const struct of_device_id hdmi_of_match[] = {
821 { .compatible = "ti,omap4-hdmi", },
822 {},
823 };
824
825 static struct platform_driver omapdss_hdmihw_driver = {
826 .probe = hdmi4_probe,
827 .remove = hdmi4_remove,
828 .driver = {
829 .name = "omapdss_hdmi",
830 .pm = &hdmi_pm_ops,
831 .of_match_table = hdmi_of_match,
832 .suppress_bind_attrs = true,
833 },
834 };
835
836 int __init hdmi4_init_platform_driver(void)
837 {
838 return platform_driver_register(&omapdss_hdmihw_driver);
839 }
840
841 void hdmi4_uninit_platform_driver(void)
842 {
843 platform_driver_unregister(&omapdss_hdmihw_driver);
844 }