4 * HDMI interface DSS driver setting for TI's OMAP4 family of processor.
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
7 * Mythri pk <mythripk@ti.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published by
11 * the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
22 #define DSS_SUBSYS_NAME "HDMI"
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/err.h>
28 #include <linux/interrupt.h>
29 #include <linux/mutex.h>
30 #include <linux/delay.h>
31 #include <linux/string.h>
32 #include <linux/platform_device.h>
33 #include <linux/pm_runtime.h>
34 #include <linux/clk.h>
35 #include <linux/gpio.h>
36 #include <linux/regulator/consumer.h>
37 #include <video/omapdss.h>
41 #include "dss_features.h"
44 #define HDMI_CORE_SYS 0x400
45 #define HDMI_CORE_AV 0x900
46 #define HDMI_PLLCTRL 0x200
47 #define HDMI_PHY 0x300
49 /* HDMI EDID Length move this */
50 #define HDMI_EDID_MAX_LENGTH 256
51 #define EDID_TIMING_DESCRIPTOR_SIZE 0x12
52 #define EDID_DESCRIPTOR_BLOCK0_ADDRESS 0x36
53 #define EDID_DESCRIPTOR_BLOCK1_ADDRESS 0x80
54 #define EDID_SIZE_BLOCK0_TIMING_DESCRIPTOR 4
55 #define EDID_SIZE_BLOCK1_TIMING_DESCRIPTOR 4
57 #define HDMI_DEFAULT_REGN 16
58 #define HDMI_DEFAULT_REGM2 1
62 struct platform_device *pdev;
64 struct hdmi_ip_data ip_data;
67 struct regulator *vdda_hdmi_dac_reg;
71 struct omap_dss_device output;
75 * Logic for the below structure :
76 * user enters the CEA or VESA timings by specifying the HDMI/DVI code.
77 * There is a correspondence between CEA/VESA timing and code, please
78 * refer to section 6.3 in HDMI 1.3 specification for timing code.
80 * In the below structure, cea_vesa_timings corresponds to all OMAP4
81 * supported CEA and VESA timing values.code_cea corresponds to the CEA
82 * code, It is used to get the timing from cea_vesa_timing array.Similarly
83 * with code_vesa. Code_index is used for back mapping, that is once EDID
84 * is read from the TV, EDID is parsed to find the timing values and then
85 * map it to corresponding CEA or VESA index.
88 static const struct hdmi_config cea_timings[] = {
90 { 640, 480, 25200, 96, 16, 48, 2, 10, 33,
91 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
96 { 720, 480, 27027, 62, 16, 60, 6, 9, 30,
97 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
102 { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
103 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
108 { 1920, 540, 74250, 44, 88, 148, 5, 2, 15,
109 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
114 { 1440, 240, 27027, 124, 38, 114, 3, 4, 15,
115 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
120 { 1920, 1080, 148500, 44, 88, 148, 5, 4, 36,
121 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
126 { 720, 576, 27000, 64, 12, 68, 5, 5, 39,
127 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
132 { 1280, 720, 74250, 40, 440, 220, 5, 5, 20,
133 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
138 { 1920, 540, 74250, 44, 528, 148, 5, 2, 15,
139 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
144 { 1440, 288, 27000, 126, 24, 138, 3, 2, 19,
145 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
150 { 1440, 576, 54000, 128, 24, 136, 5, 5, 39,
151 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
156 { 1920, 1080, 148500, 44, 528, 148, 5, 4, 36,
157 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
162 { 1920, 1080, 74250, 44, 638, 148, 5, 4, 36,
163 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
168 { 2880, 480, 108108, 248, 64, 240, 6, 9, 30,
169 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
174 { 2880, 576, 108000, 256, 48, 272, 5, 5, 39,
175 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
181 static const struct hdmi_config vesa_timings[] = {
184 { 640, 480, 25175, 96, 16, 48, 2, 11, 31,
185 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
190 { 800, 600, 40000, 128, 40, 88, 4, 1, 23,
191 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
196 { 848, 480, 33750, 112, 16, 112, 8, 6, 23,
197 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
202 { 1280, 768, 79500, 128, 64, 192, 7, 3, 20,
203 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
208 { 1280, 800, 83500, 128, 72, 200, 6, 3, 22,
209 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
214 { 1360, 768, 85500, 112, 64, 256, 6, 3, 18,
215 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
220 { 1280, 960, 108000, 112, 96, 312, 3, 1, 36,
221 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
226 { 1280, 1024, 108000, 112, 48, 248, 3, 1, 38,
227 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
232 { 1024, 768, 65000, 136, 24, 160, 6, 3, 29,
233 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
238 { 1400, 1050, 121750, 144, 88, 232, 4, 3, 32,
239 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
244 { 1440, 900, 106500, 152, 80, 232, 6, 3, 25,
245 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
250 { 1680, 1050, 146250, 176 , 104, 280, 6, 3, 30,
251 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
256 { 1366, 768, 85500, 143, 70, 213, 3, 3, 24,
257 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
262 { 1920, 1080, 148500, 44, 148, 80, 5, 4, 36,
263 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
268 { 1280, 768, 68250, 32, 48, 80, 7, 3, 12,
269 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
274 { 1400, 1050, 101000, 32, 48, 80, 4, 3, 23,
275 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
280 { 1680, 1050, 119000, 32, 48, 80, 6, 3, 21,
281 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
286 { 1280, 800, 79500, 32, 48, 80, 6, 3, 14,
287 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
292 { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
293 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
298 { 1920, 1200, 154000, 32, 48, 80, 6, 3, 26,
299 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
305 static int hdmi_runtime_get(void)
309 DSSDBG("hdmi_runtime_get\n");
311 r = pm_runtime_get_sync(&hdmi.pdev->dev);
319 static void hdmi_runtime_put(void)
323 DSSDBG("hdmi_runtime_put\n");
325 r = pm_runtime_put_sync(&hdmi.pdev->dev);
326 WARN_ON(r < 0 && r != -ENOSYS);
329 static int hdmi_init_regulator(void)
331 struct regulator *reg;
333 if (hdmi.vdda_hdmi_dac_reg != NULL)
336 reg = devm_regulator_get(&hdmi.pdev->dev, "vdda_hdmi_dac");
338 /* DT HACK: try VDAC to make omapdss work for o4 sdp/panda */
340 reg = devm_regulator_get(&hdmi.pdev->dev, "VDAC");
343 DSSERR("can't get VDDA_HDMI_DAC regulator\n");
347 hdmi.vdda_hdmi_dac_reg = reg;
352 static const struct hdmi_config *hdmi_find_timing(
353 const struct hdmi_config *timings_arr,
358 for (i = 0; i < len; i++) {
359 if (timings_arr[i].cm.code == hdmi.ip_data.cfg.cm.code)
360 return &timings_arr[i];
365 static const struct hdmi_config *hdmi_get_timings(void)
367 const struct hdmi_config *arr;
370 if (hdmi.ip_data.cfg.cm.mode == HDMI_DVI) {
372 len = ARRAY_SIZE(vesa_timings);
375 len = ARRAY_SIZE(cea_timings);
378 return hdmi_find_timing(arr, len);
381 static bool hdmi_timings_compare(struct omap_video_timings *timing1,
382 const struct omap_video_timings *timing2)
384 int timing1_vsync, timing1_hsync, timing2_vsync, timing2_hsync;
386 if ((DIV_ROUND_CLOSEST(timing2->pixel_clock, 1000) ==
387 DIV_ROUND_CLOSEST(timing1->pixel_clock, 1000)) &&
388 (timing2->x_res == timing1->x_res) &&
389 (timing2->y_res == timing1->y_res)) {
391 timing2_hsync = timing2->hfp + timing2->hsw + timing2->hbp;
392 timing1_hsync = timing1->hfp + timing1->hsw + timing1->hbp;
393 timing2_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
394 timing1_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
396 DSSDBG("timing1_hsync = %d timing1_vsync = %d"\
397 "timing2_hsync = %d timing2_vsync = %d\n",
398 timing1_hsync, timing1_vsync,
399 timing2_hsync, timing2_vsync);
401 if ((timing1_hsync == timing2_hsync) &&
402 (timing1_vsync == timing2_vsync)) {
409 static struct hdmi_cm hdmi_get_code(struct omap_video_timings *timing)
412 struct hdmi_cm cm = {-1};
413 DSSDBG("hdmi_get_code\n");
415 for (i = 0; i < ARRAY_SIZE(cea_timings); i++) {
416 if (hdmi_timings_compare(timing, &cea_timings[i].timings)) {
417 cm = cea_timings[i].cm;
421 for (i = 0; i < ARRAY_SIZE(vesa_timings); i++) {
422 if (hdmi_timings_compare(timing, &vesa_timings[i].timings)) {
423 cm = vesa_timings[i].cm;
432 static void hdmi_compute_pll(struct omap_dss_device *dssdev, int phy,
433 struct hdmi_pll_info *pi)
435 unsigned long clkin, refclk;
438 clkin = clk_get_rate(hdmi.sys_clk) / 10000;
440 * Input clock is predivided by N + 1
441 * out put of which is reference clk
444 pi->regn = HDMI_DEFAULT_REGN;
446 refclk = clkin / pi->regn;
448 pi->regm2 = HDMI_DEFAULT_REGM2;
451 * multiplier is pixel_clk/ref_clk
452 * Multiplying by 100 to avoid fractional part removal
454 pi->regm = phy * pi->regm2 / refclk;
457 * fractional multiplier is remainder of the difference between
458 * multiplier and actual phy(required pixel clock thus should be
459 * multiplied by 2^18(262144) divided by the reference clock
461 mf = (phy - pi->regm / pi->regm2 * refclk) * 262144;
462 pi->regmf = pi->regm2 * mf / refclk;
465 * Dcofreq should be set to 1 if required pixel clock
466 * is greater than 1000MHz
468 pi->dcofreq = phy > 1000 * 100;
469 pi->regsd = ((pi->regm * clkin / 10) / (pi->regn * 250) + 5) / 10;
471 /* Set the reference clock to sysclk reference */
472 pi->refsel = HDMI_REFSEL_SYSCLK;
474 DSSDBG("M = %d Mf = %d\n", pi->regm, pi->regmf);
475 DSSDBG("range = %d sd = %d\n", pi->dcofreq, pi->regsd);
478 static int hdmi_power_on_core(struct omap_dss_device *dssdev)
482 r = regulator_enable(hdmi.vdda_hdmi_dac_reg);
486 r = hdmi_runtime_get();
488 goto err_runtime_get;
490 /* Make selection of HDMI in DSS */
491 dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
493 hdmi.core_enabled = true;
498 regulator_disable(hdmi.vdda_hdmi_dac_reg);
503 static void hdmi_power_off_core(struct omap_dss_device *dssdev)
505 hdmi.core_enabled = false;
508 regulator_disable(hdmi.vdda_hdmi_dac_reg);
511 static int hdmi_power_on_full(struct omap_dss_device *dssdev)
514 struct omap_video_timings *p;
515 struct omap_overlay_manager *mgr = hdmi.output.manager;
518 r = hdmi_power_on_core(dssdev);
522 dss_mgr_disable(mgr);
524 p = &hdmi.ip_data.cfg.timings;
526 DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
528 phy = p->pixel_clock;
530 hdmi_compute_pll(dssdev, phy, &hdmi.ip_data.pll_data);
532 hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
534 /* config the PLL and PHY hdmi_set_pll_pwrfirst */
535 r = hdmi.ip_data.ops->pll_enable(&hdmi.ip_data);
537 DSSDBG("Failed to lock PLL\n");
541 r = hdmi.ip_data.ops->phy_enable(&hdmi.ip_data);
543 DSSDBG("Failed to start PHY\n");
547 hdmi.ip_data.ops->video_configure(&hdmi.ip_data);
549 /* bypass TV gamma table */
550 dispc_enable_gamma_table(0);
553 dss_mgr_set_timings(mgr, p);
555 r = hdmi.ip_data.ops->video_enable(&hdmi.ip_data);
559 r = dss_mgr_enable(mgr);
566 hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
568 hdmi.ip_data.ops->phy_disable(&hdmi.ip_data);
570 hdmi.ip_data.ops->pll_disable(&hdmi.ip_data);
572 hdmi_power_off_core(dssdev);
576 static void hdmi_power_off_full(struct omap_dss_device *dssdev)
578 struct omap_overlay_manager *mgr = hdmi.output.manager;
580 dss_mgr_disable(mgr);
582 hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
583 hdmi.ip_data.ops->phy_disable(&hdmi.ip_data);
584 hdmi.ip_data.ops->pll_disable(&hdmi.ip_data);
586 hdmi_power_off_core(dssdev);
589 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
590 struct omap_video_timings *timings)
594 cm = hdmi_get_code(timings);
603 static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
604 struct omap_video_timings *timings)
607 const struct hdmi_config *t;
609 mutex_lock(&hdmi.lock);
611 cm = hdmi_get_code(timings);
612 hdmi.ip_data.cfg.cm = cm;
614 t = hdmi_get_timings();
616 hdmi.ip_data.cfg = *t;
618 dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
621 mutex_unlock(&hdmi.lock);
624 static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
625 struct omap_video_timings *timings)
627 const struct hdmi_config *cfg;
629 cfg = hdmi_get_timings();
631 cfg = &vesa_timings[0];
633 memcpy(timings, &cfg->timings, sizeof(cfg->timings));
636 static void hdmi_dump_regs(struct seq_file *s)
638 mutex_lock(&hdmi.lock);
640 if (hdmi_runtime_get()) {
641 mutex_unlock(&hdmi.lock);
645 hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s);
646 hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s);
647 hdmi.ip_data.ops->dump_phy(&hdmi.ip_data, s);
648 hdmi.ip_data.ops->dump_core(&hdmi.ip_data, s);
651 mutex_unlock(&hdmi.lock);
654 static int read_edid(u8 *buf, int len)
658 mutex_lock(&hdmi.lock);
660 r = hdmi_runtime_get();
663 r = hdmi.ip_data.ops->read_edid(&hdmi.ip_data, buf, len);
666 mutex_unlock(&hdmi.lock);
671 static int hdmi_display_enable(struct omap_dss_device *dssdev)
673 struct omap_dss_device *out = &hdmi.output;
676 DSSDBG("ENTER hdmi_display_enable\n");
678 mutex_lock(&hdmi.lock);
680 if (out == NULL || out->manager == NULL) {
681 DSSERR("failed to enable display: no output/manager\n");
686 r = hdmi_power_on_full(dssdev);
688 DSSERR("failed to power on device\n");
692 mutex_unlock(&hdmi.lock);
696 mutex_unlock(&hdmi.lock);
700 static void hdmi_display_disable(struct omap_dss_device *dssdev)
702 DSSDBG("Enter hdmi_display_disable\n");
704 mutex_lock(&hdmi.lock);
706 hdmi_power_off_full(dssdev);
708 mutex_unlock(&hdmi.lock);
711 static int hdmi_core_enable(struct omap_dss_device *dssdev)
715 DSSDBG("ENTER omapdss_hdmi_core_enable\n");
717 mutex_lock(&hdmi.lock);
719 r = hdmi_power_on_core(dssdev);
721 DSSERR("failed to power on device\n");
725 mutex_unlock(&hdmi.lock);
729 mutex_unlock(&hdmi.lock);
733 static void hdmi_core_disable(struct omap_dss_device *dssdev)
735 DSSDBG("Enter omapdss_hdmi_core_disable\n");
737 mutex_lock(&hdmi.lock);
739 hdmi_power_off_core(dssdev);
741 mutex_unlock(&hdmi.lock);
744 static int hdmi_get_clocks(struct platform_device *pdev)
748 clk = devm_clk_get(&pdev->dev, "sys_clk");
750 DSSERR("can't get sys_clk\n");
759 #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
760 int hdmi_compute_acr(u32 sample_freq, u32 *n, u32 *cts)
763 bool deep_color_correct = false;
764 u32 pclk = hdmi.ip_data.cfg.timings.pixel_clock;
766 if (n == NULL || cts == NULL)
769 /* TODO: When implemented, query deep color mode here. */
773 * When using deep color, the default N value (as in the HDMI
774 * specification) yields to an non-integer CTS. Hence, we
775 * modify it while keeping the restrictions described in
776 * section 7.2.1 of the HDMI 1.4a specification.
778 switch (sample_freq) {
783 if (deep_color == 125)
784 if (pclk == 27027 || pclk == 74250)
785 deep_color_correct = true;
786 if (deep_color == 150)
788 deep_color_correct = true;
793 if (deep_color == 125)
795 deep_color_correct = true;
801 if (deep_color_correct) {
802 switch (sample_freq) {
828 switch (sample_freq) {
854 /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */
855 *cts = pclk * (*n / 128) * deep_color / (sample_freq / 10);
860 static bool hdmi_mode_has_audio(void)
862 if (hdmi.ip_data.cfg.cm.mode == HDMI_HDMI)
870 static int hdmi_connect(struct omap_dss_device *dssdev,
871 struct omap_dss_device *dst)
873 struct omap_overlay_manager *mgr;
876 dss_init_hdmi_ip_ops(&hdmi.ip_data, omapdss_get_version());
878 r = hdmi_init_regulator();
882 mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
886 r = dss_mgr_connect(mgr, dssdev);
890 r = omapdss_output_set_device(dssdev, dst);
892 DSSERR("failed to connect output to new device: %s\n",
894 dss_mgr_disconnect(mgr, dssdev);
901 static void hdmi_disconnect(struct omap_dss_device *dssdev,
902 struct omap_dss_device *dst)
904 WARN_ON(dst != dssdev->dst);
906 if (dst != dssdev->dst)
909 omapdss_output_unset_device(dssdev);
912 dss_mgr_disconnect(dssdev->manager, dssdev);
915 static int hdmi_read_edid(struct omap_dss_device *dssdev,
921 need_enable = hdmi.core_enabled == false;
924 r = hdmi_core_enable(dssdev);
929 r = read_edid(edid, len);
932 hdmi_core_disable(dssdev);
937 #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
938 static int hdmi_audio_enable(struct omap_dss_device *dssdev)
942 mutex_lock(&hdmi.lock);
944 if (!hdmi_mode_has_audio()) {
950 r = hdmi.ip_data.ops->audio_enable(&hdmi.ip_data);
954 mutex_unlock(&hdmi.lock);
958 mutex_unlock(&hdmi.lock);
962 static void hdmi_audio_disable(struct omap_dss_device *dssdev)
964 hdmi.ip_data.ops->audio_disable(&hdmi.ip_data);
967 static int hdmi_audio_start(struct omap_dss_device *dssdev)
969 return hdmi.ip_data.ops->audio_start(&hdmi.ip_data);
972 static void hdmi_audio_stop(struct omap_dss_device *dssdev)
974 hdmi.ip_data.ops->audio_stop(&hdmi.ip_data);
977 static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
981 mutex_lock(&hdmi.lock);
983 r = hdmi_mode_has_audio();
985 mutex_unlock(&hdmi.lock);
989 static int hdmi_audio_config(struct omap_dss_device *dssdev,
990 struct omap_dss_audio *audio)
994 mutex_lock(&hdmi.lock);
996 if (!hdmi_mode_has_audio()) {
1001 r = hdmi.ip_data.ops->audio_config(&hdmi.ip_data, audio);
1005 mutex_unlock(&hdmi.lock);
1009 mutex_unlock(&hdmi.lock);
1013 static int hdmi_audio_enable(struct omap_dss_device *dssdev)
1018 static void hdmi_audio_disable(struct omap_dss_device *dssdev)
1022 static int hdmi_audio_start(struct omap_dss_device *dssdev)
1027 static void hdmi_audio_stop(struct omap_dss_device *dssdev)
1031 static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
1036 static int hdmi_audio_config(struct omap_dss_device *dssdev,
1037 struct omap_dss_audio *audio)
1043 static const struct omapdss_hdmi_ops hdmi_ops = {
1044 .connect = hdmi_connect,
1045 .disconnect = hdmi_disconnect,
1047 .enable = hdmi_display_enable,
1048 .disable = hdmi_display_disable,
1050 .check_timings = hdmi_display_check_timing,
1051 .set_timings = hdmi_display_set_timing,
1052 .get_timings = hdmi_display_get_timings,
1054 .read_edid = hdmi_read_edid,
1056 .audio_enable = hdmi_audio_enable,
1057 .audio_disable = hdmi_audio_disable,
1058 .audio_start = hdmi_audio_start,
1059 .audio_stop = hdmi_audio_stop,
1060 .audio_supported = hdmi_audio_supported,
1061 .audio_config = hdmi_audio_config,
1064 static void hdmi_init_output(struct platform_device *pdev)
1066 struct omap_dss_device *out = &hdmi.output;
1068 out->dev = &pdev->dev;
1069 out->id = OMAP_DSS_OUTPUT_HDMI;
1070 out->output_type = OMAP_DISPLAY_TYPE_HDMI;
1071 out->name = "hdmi.0";
1072 out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
1073 out->ops.hdmi = &hdmi_ops;
1074 out->owner = THIS_MODULE;
1076 omapdss_register_output(out);
1079 static void __exit hdmi_uninit_output(struct platform_device *pdev)
1081 struct omap_dss_device *out = &hdmi.output;
1083 omapdss_unregister_output(out);
1086 /* HDMI HW IP initialisation */
1087 static int omapdss_hdmihw_probe(struct platform_device *pdev)
1089 struct resource *res;
1094 mutex_init(&hdmi.lock);
1095 mutex_init(&hdmi.ip_data.lock);
1097 res = platform_get_resource(hdmi.pdev, IORESOURCE_MEM, 0);
1099 /* Base address taken from platform */
1100 hdmi.ip_data.base_wp = devm_ioremap_resource(&pdev->dev, res);
1101 if (IS_ERR(hdmi.ip_data.base_wp))
1102 return PTR_ERR(hdmi.ip_data.base_wp);
1104 hdmi.ip_data.irq = platform_get_irq(pdev, 0);
1105 if (hdmi.ip_data.irq < 0) {
1106 DSSERR("platform_get_irq failed\n");
1110 r = hdmi_get_clocks(pdev);
1112 DSSERR("can't get clocks\n");
1116 pm_runtime_enable(&pdev->dev);
1118 hdmi.ip_data.core_sys_offset = HDMI_CORE_SYS;
1119 hdmi.ip_data.core_av_offset = HDMI_CORE_AV;
1120 hdmi.ip_data.pll_offset = HDMI_PLLCTRL;
1121 hdmi.ip_data.phy_offset = HDMI_PHY;
1123 hdmi_init_output(pdev);
1125 dss_debugfs_create_file("hdmi", hdmi_dump_regs);
1130 static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
1132 hdmi_uninit_output(pdev);
1134 pm_runtime_disable(&pdev->dev);
1139 static int hdmi_runtime_suspend(struct device *dev)
1141 clk_disable_unprepare(hdmi.sys_clk);
1143 dispc_runtime_put();
1148 static int hdmi_runtime_resume(struct device *dev)
1152 r = dispc_runtime_get();
1156 clk_prepare_enable(hdmi.sys_clk);
1161 static const struct dev_pm_ops hdmi_pm_ops = {
1162 .runtime_suspend = hdmi_runtime_suspend,
1163 .runtime_resume = hdmi_runtime_resume,
1166 static struct platform_driver omapdss_hdmihw_driver = {
1167 .probe = omapdss_hdmihw_probe,
1168 .remove = __exit_p(omapdss_hdmihw_remove),
1170 .name = "omapdss_hdmi",
1171 .owner = THIS_MODULE,
1176 int __init hdmi_init_platform_driver(void)
1178 return platform_driver_register(&omapdss_hdmihw_driver);
1181 void __exit hdmi_uninit_platform_driver(void)
1183 platform_driver_unregister(&omapdss_hdmihw_driver);