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