Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1 | /* |
Archit Taneja | ef26958 | 2013-09-12 17:45:57 +0530 | [diff] [blame] | 2 | * HDMI interface DSS driver for TI's OMAP4 family of SoCs. |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 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> |
Tomi Valkeinen | 24e6289 | 2011-05-23 11:51:18 +0300 | [diff] [blame] | 30 | #include <linux/platform_device.h> |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 31 | #include <linux/pm_runtime.h> |
| 32 | #include <linux/clk.h> |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 33 | #include <linux/gpio.h> |
Tomi Valkeinen | 1748694 | 2012-08-15 15:55:04 +0300 | [diff] [blame] | 34 | #include <linux/regulator/consumer.h> |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 35 | #include <video/omapdss.h> |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 36 | |
Archit Taneja | ef26958 | 2013-09-12 17:45:57 +0530 | [diff] [blame] | 37 | #include "hdmi4_core.h" |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 38 | #include "dss.h" |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 39 | #include "dss_features.h" |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 40 | |
| 41 | static struct { |
| 42 | struct mutex lock; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 43 | struct platform_device *pdev; |
Ricardo Neri | 66a06b0 | 2012-11-06 00:19:14 -0600 | [diff] [blame] | 44 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 45 | struct hdmi_wp_data wp; |
| 46 | struct hdmi_pll_data pll; |
| 47 | struct hdmi_phy_data phy; |
| 48 | struct hdmi_core_data core; |
| 49 | |
| 50 | struct hdmi_config cfg; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 51 | |
| 52 | struct clk *sys_clk; |
Tomi Valkeinen | 1748694 | 2012-08-15 15:55:04 +0300 | [diff] [blame] | 53 | struct regulator *vdda_hdmi_dac_reg; |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 54 | |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 55 | bool core_enabled; |
| 56 | |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 57 | struct omap_dss_device output; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 58 | } hdmi; |
| 59 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 60 | static int hdmi_runtime_get(void) |
| 61 | { |
| 62 | int r; |
| 63 | |
| 64 | DSSDBG("hdmi_runtime_get\n"); |
| 65 | |
| 66 | r = pm_runtime_get_sync(&hdmi.pdev->dev); |
| 67 | WARN_ON(r < 0); |
Archit Taneja | a247ce78 | 2012-02-10 11:45:52 +0530 | [diff] [blame] | 68 | if (r < 0) |
Tomi Valkeinen | 852f083 | 2012-02-17 17:58:04 +0200 | [diff] [blame] | 69 | return r; |
Archit Taneja | a247ce78 | 2012-02-10 11:45:52 +0530 | [diff] [blame] | 70 | |
| 71 | return 0; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static void hdmi_runtime_put(void) |
| 75 | { |
| 76 | int r; |
| 77 | |
| 78 | DSSDBG("hdmi_runtime_put\n"); |
| 79 | |
Tomi Valkeinen | 0eaf9f5 | 2012-01-23 13:23:08 +0200 | [diff] [blame] | 80 | r = pm_runtime_put_sync(&hdmi.pdev->dev); |
Tomi Valkeinen | 5be3aeb | 2012-06-27 16:37:18 +0300 | [diff] [blame] | 81 | WARN_ON(r < 0 && r != -ENOSYS); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 82 | } |
| 83 | |
Tomi Valkeinen | e25001d | 2013-05-10 15:20:52 +0300 | [diff] [blame] | 84 | static int hdmi_init_regulator(void) |
| 85 | { |
| 86 | struct regulator *reg; |
| 87 | |
| 88 | if (hdmi.vdda_hdmi_dac_reg != NULL) |
| 89 | return 0; |
| 90 | |
Tomi Valkeinen | 931d4bd | 2013-06-10 14:05:10 +0300 | [diff] [blame] | 91 | reg = devm_regulator_get(&hdmi.pdev->dev, "vdda"); |
Tomi Valkeinen | e25001d | 2013-05-10 15:20:52 +0300 | [diff] [blame] | 92 | |
| 93 | if (IS_ERR(reg)) { |
Tomi Valkeinen | 40359a9 | 2013-12-19 16:15:34 +0200 | [diff] [blame] | 94 | if (PTR_ERR(reg) != -EPROBE_DEFER) |
Tomi Valkeinen | 931d4bd | 2013-06-10 14:05:10 +0300 | [diff] [blame] | 95 | DSSERR("can't get VDDA regulator\n"); |
Tomi Valkeinen | e25001d | 2013-05-10 15:20:52 +0300 | [diff] [blame] | 96 | return PTR_ERR(reg); |
| 97 | } |
| 98 | |
| 99 | hdmi.vdda_hdmi_dac_reg = reg; |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 104 | static int hdmi_power_on_core(struct omap_dss_device *dssdev) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 105 | { |
Mythri P K | 46095b2 | 2012-01-06 17:52:09 +0530 | [diff] [blame] | 106 | int r; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 107 | |
Tomi Valkeinen | 1748694 | 2012-08-15 15:55:04 +0300 | [diff] [blame] | 108 | r = regulator_enable(hdmi.vdda_hdmi_dac_reg); |
| 109 | if (r) |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 110 | return r; |
Tomi Valkeinen | 1748694 | 2012-08-15 15:55:04 +0300 | [diff] [blame] | 111 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 112 | r = hdmi_runtime_get(); |
| 113 | if (r) |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 114 | goto err_runtime_get; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 115 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 116 | /* Make selection of HDMI in DSS */ |
| 117 | dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK); |
| 118 | |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 119 | hdmi.core_enabled = true; |
| 120 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 121 | return 0; |
| 122 | |
| 123 | err_runtime_get: |
| 124 | regulator_disable(hdmi.vdda_hdmi_dac_reg); |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 125 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 126 | return r; |
| 127 | } |
| 128 | |
| 129 | static void hdmi_power_off_core(struct omap_dss_device *dssdev) |
| 130 | { |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 131 | hdmi.core_enabled = false; |
| 132 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 133 | hdmi_runtime_put(); |
| 134 | regulator_disable(hdmi.vdda_hdmi_dac_reg); |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | static int hdmi_power_on_full(struct omap_dss_device *dssdev) |
| 138 | { |
| 139 | int r; |
| 140 | struct omap_video_timings *p; |
Tomi Valkeinen | 7ae9a71 | 2013-05-10 15:27:07 +0300 | [diff] [blame] | 141 | struct omap_overlay_manager *mgr = hdmi.output.manager; |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 142 | unsigned long phy; |
| 143 | |
| 144 | r = hdmi_power_on_core(dssdev); |
| 145 | if (r) |
| 146 | return r; |
| 147 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 148 | p = &hdmi.cfg.timings; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 149 | |
Archit Taneja | 7849398 | 2012-08-08 16:50:42 +0530 | [diff] [blame] | 150 | DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 151 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 152 | /* the functions below use kHz pixel clock. TODO: change to Hz */ |
| 153 | phy = p->pixelclock / 1000; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 154 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 155 | hdmi_pll_compute(&hdmi.pll, clk_get_rate(hdmi.sys_clk), phy); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 156 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 157 | /* config the PLL and PHY hdmi_set_pll_pwrfirst */ |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 158 | r = hdmi_pll_enable(&hdmi.pll, &hdmi.wp); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 159 | if (r) { |
| 160 | DSSDBG("Failed to lock PLL\n"); |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 161 | goto err_pll_enable; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 162 | } |
| 163 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 164 | r = hdmi_phy_enable(&hdmi.phy, &hdmi.wp, &hdmi.cfg); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 165 | if (r) { |
| 166 | DSSDBG("Failed to start PHY\n"); |
Ricardo Neri | d3b4aa5 | 2012-07-30 19:12:02 -0500 | [diff] [blame] | 167 | goto err_phy_enable; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 168 | } |
| 169 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 170 | hdmi4_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 171 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 172 | /* bypass TV gamma table */ |
| 173 | dispc_enable_gamma_table(0); |
| 174 | |
| 175 | /* tv size */ |
Archit Taneja | cea87b9 | 2012-09-07 17:56:20 +0530 | [diff] [blame] | 176 | dss_mgr_set_timings(mgr, p); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 177 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 178 | r = hdmi_wp_video_start(&hdmi.wp); |
Ricardo Neri | c0456be | 2012-04-27 13:48:45 -0500 | [diff] [blame] | 179 | if (r) |
| 180 | goto err_vid_enable; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 181 | |
Archit Taneja | cea87b9 | 2012-09-07 17:56:20 +0530 | [diff] [blame] | 182 | r = dss_mgr_enable(mgr); |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 183 | if (r) |
| 184 | goto err_mgr_enable; |
Tomi Valkeinen | 3870c90 | 2011-08-31 14:47:11 +0300 | [diff] [blame] | 185 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 186 | return 0; |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 187 | |
| 188 | err_mgr_enable: |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 189 | hdmi_wp_video_stop(&hdmi.wp); |
Ricardo Neri | c0456be | 2012-04-27 13:48:45 -0500 | [diff] [blame] | 190 | err_vid_enable: |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 191 | hdmi_phy_disable(&hdmi.phy, &hdmi.wp); |
Ricardo Neri | d3b4aa5 | 2012-07-30 19:12:02 -0500 | [diff] [blame] | 192 | err_phy_enable: |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 193 | hdmi_pll_disable(&hdmi.pll, &hdmi.wp); |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 194 | err_pll_enable: |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 195 | hdmi_power_off_core(dssdev); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 196 | return -EIO; |
| 197 | } |
| 198 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 199 | static void hdmi_power_off_full(struct omap_dss_device *dssdev) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 200 | { |
Tomi Valkeinen | 7ae9a71 | 2013-05-10 15:27:07 +0300 | [diff] [blame] | 201 | struct omap_overlay_manager *mgr = hdmi.output.manager; |
Archit Taneja | cea87b9 | 2012-09-07 17:56:20 +0530 | [diff] [blame] | 202 | |
| 203 | dss_mgr_disable(mgr); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 204 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 205 | hdmi_wp_video_stop(&hdmi.wp); |
| 206 | hdmi_phy_disable(&hdmi.phy, &hdmi.wp); |
| 207 | hdmi_pll_disable(&hdmi.pll, &hdmi.wp); |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 208 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 209 | hdmi_power_off_core(dssdev); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 210 | } |
| 211 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 212 | static int hdmi_display_check_timing(struct omap_dss_device *dssdev, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 213 | struct omap_video_timings *timings) |
| 214 | { |
Archit Taneja | 1e67624 | 2013-12-09 19:39:08 +0530 | [diff] [blame] | 215 | struct omap_dss_device *out = &hdmi.output; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 216 | |
Archit Taneja | 1e67624 | 2013-12-09 19:39:08 +0530 | [diff] [blame] | 217 | if (!dispc_mgr_timings_ok(out->dispc_channel, timings)) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 218 | return -EINVAL; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 219 | |
| 220 | return 0; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 221 | } |
| 222 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 223 | static void hdmi_display_set_timing(struct omap_dss_device *dssdev, |
Archit Taneja | 7849398 | 2012-08-08 16:50:42 +0530 | [diff] [blame] | 224 | struct omap_video_timings *timings) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 225 | { |
| 226 | struct hdmi_cm cm; |
Archit Taneja | 7849398 | 2012-08-08 16:50:42 +0530 | [diff] [blame] | 227 | const struct hdmi_config *t; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 228 | |
Archit Taneja | ed1aa90 | 2012-08-15 00:40:31 +0530 | [diff] [blame] | 229 | mutex_lock(&hdmi.lock); |
| 230 | |
Archit Taneja | 7849398 | 2012-08-08 16:50:42 +0530 | [diff] [blame] | 231 | cm = hdmi_get_code(timings); |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 232 | hdmi.cfg.cm = cm; |
Archit Taneja | 7849398 | 2012-08-08 16:50:42 +0530 | [diff] [blame] | 233 | |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 234 | t = hdmi_get_timings(cm.mode, cm.code); |
Tomi Valkeinen | db680c6 | 2013-08-27 14:11:48 +0300 | [diff] [blame] | 235 | if (t != NULL) { |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 236 | hdmi.cfg = *t; |
Tomi Valkeinen | fa70dc5 | 2011-08-22 14:57:33 +0300 | [diff] [blame] | 237 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 238 | dispc_set_tv_pclk(t->timings.pixelclock); |
Archit Taneja | 1e67624 | 2013-12-09 19:39:08 +0530 | [diff] [blame] | 239 | } else { |
| 240 | hdmi.cfg.timings = *timings; |
| 241 | hdmi.cfg.cm.code = 0; |
| 242 | hdmi.cfg.cm.mode = HDMI_DVI; |
| 243 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 244 | dispc_set_tv_pclk(timings->pixelclock); |
Tomi Valkeinen | db680c6 | 2013-08-27 14:11:48 +0300 | [diff] [blame] | 245 | } |
Tomi Valkeinen | 5391e87 | 2013-05-16 10:44:13 +0300 | [diff] [blame] | 246 | |
Archit Taneja | 1e67624 | 2013-12-09 19:39:08 +0530 | [diff] [blame] | 247 | DSSDBG("using mode: %s, code %d\n", hdmi.cfg.cm.mode == HDMI_DVI ? |
| 248 | "DVI" : "HDMI", hdmi.cfg.cm.code); |
| 249 | |
Archit Taneja | ed1aa90 | 2012-08-15 00:40:31 +0530 | [diff] [blame] | 250 | mutex_unlock(&hdmi.lock); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 251 | } |
| 252 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 253 | static void hdmi_display_get_timings(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 254 | struct omap_video_timings *timings) |
| 255 | { |
| 256 | const struct hdmi_config *cfg; |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 257 | struct hdmi_cm cm = hdmi.cfg.cm; |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 258 | |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 259 | cfg = hdmi_get_timings(cm.mode, cm.code); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 260 | if (cfg == NULL) |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 261 | cfg = hdmi_default_timing(); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 262 | |
| 263 | memcpy(timings, &cfg->timings, sizeof(cfg->timings)); |
| 264 | } |
| 265 | |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 266 | static void hdmi_dump_regs(struct seq_file *s) |
Mythri P K | 162874d | 2011-09-22 13:37:45 +0530 | [diff] [blame] | 267 | { |
| 268 | mutex_lock(&hdmi.lock); |
| 269 | |
Wei Yongjun | f8fb7d7 | 2012-10-21 20:54:26 +0800 | [diff] [blame] | 270 | if (hdmi_runtime_get()) { |
| 271 | mutex_unlock(&hdmi.lock); |
Mythri P K | 162874d | 2011-09-22 13:37:45 +0530 | [diff] [blame] | 272 | return; |
Wei Yongjun | f8fb7d7 | 2012-10-21 20:54:26 +0800 | [diff] [blame] | 273 | } |
Mythri P K | 162874d | 2011-09-22 13:37:45 +0530 | [diff] [blame] | 274 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 275 | hdmi_wp_dump(&hdmi.wp, s); |
| 276 | hdmi_pll_dump(&hdmi.pll, s); |
| 277 | hdmi_phy_dump(&hdmi.phy, s); |
| 278 | hdmi4_core_dump(&hdmi.core, s); |
Mythri P K | 162874d | 2011-09-22 13:37:45 +0530 | [diff] [blame] | 279 | |
| 280 | hdmi_runtime_put(); |
| 281 | mutex_unlock(&hdmi.lock); |
| 282 | } |
| 283 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 284 | static int read_edid(u8 *buf, int len) |
Tomi Valkeinen | 4702456 | 2011-08-25 17:12:56 +0300 | [diff] [blame] | 285 | { |
| 286 | int r; |
| 287 | |
| 288 | mutex_lock(&hdmi.lock); |
| 289 | |
| 290 | r = hdmi_runtime_get(); |
| 291 | BUG_ON(r); |
| 292 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 293 | r = hdmi4_read_edid(&hdmi.core, buf, len); |
Tomi Valkeinen | 4702456 | 2011-08-25 17:12:56 +0300 | [diff] [blame] | 294 | |
| 295 | hdmi_runtime_put(); |
| 296 | mutex_unlock(&hdmi.lock); |
| 297 | |
| 298 | return r; |
| 299 | } |
| 300 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 301 | static int hdmi_display_enable(struct omap_dss_device *dssdev) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 302 | { |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 303 | struct omap_dss_device *out = &hdmi.output; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 304 | int r = 0; |
| 305 | |
| 306 | DSSDBG("ENTER hdmi_display_enable\n"); |
| 307 | |
| 308 | mutex_lock(&hdmi.lock); |
| 309 | |
Archit Taneja | cea87b9 | 2012-09-07 17:56:20 +0530 | [diff] [blame] | 310 | if (out == NULL || out->manager == NULL) { |
| 311 | DSSERR("failed to enable display: no output/manager\n"); |
Tomi Valkeinen | 05e1d60 | 2011-06-23 16:38:21 +0300 | [diff] [blame] | 312 | r = -ENODEV; |
| 313 | goto err0; |
| 314 | } |
| 315 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 316 | r = hdmi_power_on_full(dssdev); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 317 | if (r) { |
| 318 | DSSERR("failed to power on device\n"); |
Tomi Valkeinen | d392393 | 2013-04-25 13:12:07 +0300 | [diff] [blame] | 319 | goto err0; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | mutex_unlock(&hdmi.lock); |
| 323 | return 0; |
| 324 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 325 | err0: |
| 326 | mutex_unlock(&hdmi.lock); |
| 327 | return r; |
| 328 | } |
| 329 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 330 | static void hdmi_display_disable(struct omap_dss_device *dssdev) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 331 | { |
| 332 | DSSDBG("Enter hdmi_display_disable\n"); |
| 333 | |
| 334 | mutex_lock(&hdmi.lock); |
| 335 | |
Tomi Valkeinen | bb426fc9 | 2012-10-19 17:42:10 +0300 | [diff] [blame] | 336 | hdmi_power_off_full(dssdev); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 337 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 338 | mutex_unlock(&hdmi.lock); |
| 339 | } |
| 340 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 341 | static int hdmi_core_enable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 4489823 | 2012-10-19 17:42:27 +0300 | [diff] [blame] | 342 | { |
| 343 | int r = 0; |
| 344 | |
| 345 | DSSDBG("ENTER omapdss_hdmi_core_enable\n"); |
| 346 | |
| 347 | mutex_lock(&hdmi.lock); |
| 348 | |
Tomi Valkeinen | 4489823 | 2012-10-19 17:42:27 +0300 | [diff] [blame] | 349 | r = hdmi_power_on_core(dssdev); |
| 350 | if (r) { |
| 351 | DSSERR("failed to power on device\n"); |
| 352 | goto err0; |
| 353 | } |
| 354 | |
| 355 | mutex_unlock(&hdmi.lock); |
| 356 | return 0; |
| 357 | |
| 358 | err0: |
| 359 | mutex_unlock(&hdmi.lock); |
| 360 | return r; |
| 361 | } |
| 362 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 363 | static void hdmi_core_disable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 4489823 | 2012-10-19 17:42:27 +0300 | [diff] [blame] | 364 | { |
| 365 | DSSDBG("Enter omapdss_hdmi_core_disable\n"); |
| 366 | |
| 367 | mutex_lock(&hdmi.lock); |
| 368 | |
| 369 | hdmi_power_off_core(dssdev); |
| 370 | |
| 371 | mutex_unlock(&hdmi.lock); |
| 372 | } |
| 373 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 374 | static int hdmi_get_clocks(struct platform_device *pdev) |
| 375 | { |
| 376 | struct clk *clk; |
| 377 | |
Archit Taneja | b2c9c8e | 2013-04-08 11:55:00 +0300 | [diff] [blame] | 378 | clk = devm_clk_get(&pdev->dev, "sys_clk"); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 379 | if (IS_ERR(clk)) { |
| 380 | DSSERR("can't get sys_clk\n"); |
| 381 | return PTR_ERR(clk); |
| 382 | } |
| 383 | |
| 384 | hdmi.sys_clk = clk; |
| 385 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 386 | return 0; |
| 387 | } |
| 388 | |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 389 | static int hdmi_connect(struct omap_dss_device *dssdev, |
| 390 | struct omap_dss_device *dst) |
| 391 | { |
| 392 | struct omap_overlay_manager *mgr; |
| 393 | int r; |
| 394 | |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 395 | r = hdmi_init_regulator(); |
| 396 | if (r) |
| 397 | return r; |
| 398 | |
| 399 | mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel); |
| 400 | if (!mgr) |
| 401 | return -ENODEV; |
| 402 | |
| 403 | r = dss_mgr_connect(mgr, dssdev); |
| 404 | if (r) |
| 405 | return r; |
| 406 | |
| 407 | r = omapdss_output_set_device(dssdev, dst); |
| 408 | if (r) { |
| 409 | DSSERR("failed to connect output to new device: %s\n", |
| 410 | dst->name); |
| 411 | dss_mgr_disconnect(mgr, dssdev); |
| 412 | return r; |
| 413 | } |
| 414 | |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | static void hdmi_disconnect(struct omap_dss_device *dssdev, |
| 419 | struct omap_dss_device *dst) |
| 420 | { |
Tomi Valkeinen | 9560dc10 | 2013-07-24 13:06:54 +0300 | [diff] [blame] | 421 | WARN_ON(dst != dssdev->dst); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 422 | |
Tomi Valkeinen | 9560dc10 | 2013-07-24 13:06:54 +0300 | [diff] [blame] | 423 | if (dst != dssdev->dst) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 424 | return; |
| 425 | |
| 426 | omapdss_output_unset_device(dssdev); |
| 427 | |
| 428 | if (dssdev->manager) |
| 429 | dss_mgr_disconnect(dssdev->manager, dssdev); |
| 430 | } |
| 431 | |
| 432 | static int hdmi_read_edid(struct omap_dss_device *dssdev, |
| 433 | u8 *edid, int len) |
| 434 | { |
| 435 | bool need_enable; |
| 436 | int r; |
| 437 | |
| 438 | need_enable = hdmi.core_enabled == false; |
| 439 | |
| 440 | if (need_enable) { |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 441 | r = hdmi_core_enable(dssdev); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 442 | if (r) |
| 443 | return r; |
| 444 | } |
| 445 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 446 | r = read_edid(edid, len); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 447 | |
| 448 | if (need_enable) |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 449 | hdmi_core_disable(dssdev); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 450 | |
| 451 | return r; |
| 452 | } |
| 453 | |
| 454 | #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO) |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 455 | static int hdmi_audio_enable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 456 | { |
| 457 | int r; |
| 458 | |
| 459 | mutex_lock(&hdmi.lock); |
| 460 | |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 461 | if (!hdmi_mode_has_audio(hdmi.cfg.cm.mode)) { |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 462 | r = -EPERM; |
| 463 | goto err; |
| 464 | } |
| 465 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 466 | r = hdmi_wp_audio_enable(&hdmi.wp, true); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 467 | if (r) |
| 468 | goto err; |
| 469 | |
| 470 | mutex_unlock(&hdmi.lock); |
| 471 | return 0; |
| 472 | |
| 473 | err: |
| 474 | mutex_unlock(&hdmi.lock); |
| 475 | return r; |
| 476 | } |
| 477 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 478 | static void hdmi_audio_disable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 479 | { |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 480 | hdmi_wp_audio_enable(&hdmi.wp, false); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 481 | } |
| 482 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 483 | static int hdmi_audio_start(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 484 | { |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 485 | return hdmi4_audio_start(&hdmi.core, &hdmi.wp); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 486 | } |
| 487 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 488 | static void hdmi_audio_stop(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 489 | { |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 490 | hdmi4_audio_stop(&hdmi.core, &hdmi.wp); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 491 | } |
| 492 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 493 | static bool hdmi_audio_supported(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 494 | { |
| 495 | bool r; |
| 496 | |
| 497 | mutex_lock(&hdmi.lock); |
| 498 | |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 499 | r = hdmi_mode_has_audio(hdmi.cfg.cm.mode); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 500 | |
| 501 | mutex_unlock(&hdmi.lock); |
| 502 | return r; |
| 503 | } |
| 504 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 505 | static int hdmi_audio_config(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 506 | struct omap_dss_audio *audio) |
| 507 | { |
| 508 | int r; |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 509 | u32 pclk = hdmi.cfg.timings.pixelclock; |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 510 | |
| 511 | mutex_lock(&hdmi.lock); |
| 512 | |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 513 | if (!hdmi_mode_has_audio(hdmi.cfg.cm.mode)) { |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 514 | r = -EPERM; |
| 515 | goto err; |
| 516 | } |
| 517 | |
Archit Taneja | 08d83e4e | 2013-09-17 11:43:15 +0530 | [diff] [blame] | 518 | r = hdmi4_audio_config(&hdmi.core, &hdmi.wp, audio, pclk); |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 519 | if (r) |
| 520 | goto err; |
| 521 | |
| 522 | mutex_unlock(&hdmi.lock); |
| 523 | return 0; |
| 524 | |
| 525 | err: |
| 526 | mutex_unlock(&hdmi.lock); |
| 527 | return r; |
| 528 | } |
| 529 | #else |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 530 | static int hdmi_audio_enable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 531 | { |
| 532 | return -EPERM; |
| 533 | } |
| 534 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 535 | static void hdmi_audio_disable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 536 | { |
| 537 | } |
| 538 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 539 | static int hdmi_audio_start(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 540 | { |
| 541 | return -EPERM; |
| 542 | } |
| 543 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 544 | static void hdmi_audio_stop(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 545 | { |
| 546 | } |
| 547 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 548 | static bool hdmi_audio_supported(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 549 | { |
| 550 | return false; |
| 551 | } |
| 552 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 553 | static int hdmi_audio_config(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 554 | struct omap_dss_audio *audio) |
| 555 | { |
| 556 | return -EPERM; |
| 557 | } |
| 558 | #endif |
| 559 | |
| 560 | static const struct omapdss_hdmi_ops hdmi_ops = { |
| 561 | .connect = hdmi_connect, |
| 562 | .disconnect = hdmi_disconnect, |
| 563 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 564 | .enable = hdmi_display_enable, |
| 565 | .disable = hdmi_display_disable, |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 566 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 567 | .check_timings = hdmi_display_check_timing, |
| 568 | .set_timings = hdmi_display_set_timing, |
| 569 | .get_timings = hdmi_display_get_timings, |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 570 | |
| 571 | .read_edid = hdmi_read_edid, |
| 572 | |
Tomi Valkeinen | 164ebdd | 2013-05-15 10:48:45 +0300 | [diff] [blame] | 573 | .audio_enable = hdmi_audio_enable, |
| 574 | .audio_disable = hdmi_audio_disable, |
| 575 | .audio_start = hdmi_audio_start, |
| 576 | .audio_stop = hdmi_audio_stop, |
| 577 | .audio_supported = hdmi_audio_supported, |
| 578 | .audio_config = hdmi_audio_config, |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 579 | }; |
| 580 | |
Tomi Valkeinen | 17ae4e8 | 2013-04-26 14:48:43 +0300 | [diff] [blame] | 581 | static void hdmi_init_output(struct platform_device *pdev) |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 582 | { |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 583 | struct omap_dss_device *out = &hdmi.output; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 584 | |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 585 | out->dev = &pdev->dev; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 586 | out->id = OMAP_DSS_OUTPUT_HDMI; |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 587 | out->output_type = OMAP_DISPLAY_TYPE_HDMI; |
Tomi Valkeinen | 7286a08 | 2013-02-18 13:06:01 +0200 | [diff] [blame] | 588 | out->name = "hdmi.0"; |
Tomi Valkeinen | 2eea5ae | 2013-02-13 11:23:54 +0200 | [diff] [blame] | 589 | out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT; |
Tomi Valkeinen | 0b450c3 | 2013-05-24 13:20:17 +0300 | [diff] [blame] | 590 | out->ops.hdmi = &hdmi_ops; |
Tomi Valkeinen | b7328e1 | 2013-05-03 11:42:18 +0300 | [diff] [blame] | 591 | out->owner = THIS_MODULE; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 592 | |
Tomi Valkeinen | 5d47dbc | 2013-04-24 13:32:51 +0300 | [diff] [blame] | 593 | omapdss_register_output(out); |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | static void __exit hdmi_uninit_output(struct platform_device *pdev) |
| 597 | { |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 598 | struct omap_dss_device *out = &hdmi.output; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 599 | |
Tomi Valkeinen | 5d47dbc | 2013-04-24 13:32:51 +0300 | [diff] [blame] | 600 | omapdss_unregister_output(out); |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 601 | } |
| 602 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 603 | /* HDMI HW IP initialisation */ |
Tomi Valkeinen | 17ae4e8 | 2013-04-26 14:48:43 +0300 | [diff] [blame] | 604 | static int omapdss_hdmihw_probe(struct platform_device *pdev) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 605 | { |
Tomi Valkeinen | 38f3daf | 2012-05-02 14:55:12 +0300 | [diff] [blame] | 606 | int r; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 607 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 608 | hdmi.pdev = pdev; |
| 609 | |
| 610 | mutex_init(&hdmi.lock); |
| 611 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 612 | r = hdmi_wp_init(pdev, &hdmi.wp); |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame] | 613 | if (r) |
| 614 | return r; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 615 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 616 | r = hdmi_pll_init(pdev, &hdmi.pll); |
Archit Taneja | c1577c1 | 2013-10-08 12:55:26 +0530 | [diff] [blame] | 617 | if (r) |
| 618 | return r; |
| 619 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 620 | r = hdmi_phy_init(pdev, &hdmi.phy); |
Archit Taneja | 5cac5ae | 2013-10-08 13:07:00 +0530 | [diff] [blame] | 621 | if (r) |
| 622 | return r; |
Tomi Valkeinen | ddb1d5c | 2013-06-06 13:08:35 +0300 | [diff] [blame] | 623 | |
Archit Taneja | 275cfa1 | 2013-10-08 14:22:03 +0530 | [diff] [blame] | 624 | r = hdmi4_core_init(pdev, &hdmi.core); |
Archit Taneja | 425f02f | 2013-10-08 14:16:05 +0530 | [diff] [blame] | 625 | if (r) |
| 626 | return r; |
| 627 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 628 | r = hdmi_get_clocks(pdev); |
| 629 | if (r) { |
Ricardo Neri | 47e443b | 2012-11-06 00:19:12 -0600 | [diff] [blame] | 630 | DSSERR("can't get clocks\n"); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 631 | return r; |
| 632 | } |
| 633 | |
| 634 | pm_runtime_enable(&pdev->dev); |
| 635 | |
Tomi Valkeinen | 002d368 | 2013-02-13 12:17:43 +0200 | [diff] [blame] | 636 | hdmi_init_output(pdev); |
| 637 | |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 638 | dss_debugfs_create_file("hdmi", hdmi_dump_regs); |
| 639 | |
Tomi Valkeinen | cca3501 | 2012-04-26 14:48:32 +0300 | [diff] [blame] | 640 | return 0; |
| 641 | } |
| 642 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 643 | static int __exit omapdss_hdmihw_remove(struct platform_device *pdev) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 644 | { |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 645 | hdmi_uninit_output(pdev); |
| 646 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 647 | pm_runtime_disable(&pdev->dev); |
| 648 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 649 | return 0; |
| 650 | } |
| 651 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 652 | static int hdmi_runtime_suspend(struct device *dev) |
| 653 | { |
Rajendra Nayak | f11766d | 2012-06-27 14:21:26 +0530 | [diff] [blame] | 654 | clk_disable_unprepare(hdmi.sys_clk); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 655 | |
| 656 | dispc_runtime_put(); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 657 | |
| 658 | return 0; |
| 659 | } |
| 660 | |
| 661 | static int hdmi_runtime_resume(struct device *dev) |
| 662 | { |
| 663 | int r; |
| 664 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 665 | r = dispc_runtime_get(); |
| 666 | if (r < 0) |
Tomi Valkeinen | 852f083 | 2012-02-17 17:58:04 +0200 | [diff] [blame] | 667 | return r; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 668 | |
Rajendra Nayak | f11766d | 2012-06-27 14:21:26 +0530 | [diff] [blame] | 669 | clk_prepare_enable(hdmi.sys_clk); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 670 | |
| 671 | return 0; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | static const struct dev_pm_ops hdmi_pm_ops = { |
| 675 | .runtime_suspend = hdmi_runtime_suspend, |
| 676 | .runtime_resume = hdmi_runtime_resume, |
| 677 | }; |
| 678 | |
Tomi Valkeinen | 0465616 | 2013-12-16 15:14:04 +0200 | [diff] [blame] | 679 | static const struct of_device_id hdmi_of_match[] = { |
| 680 | { .compatible = "ti,omap4-hdmi", }, |
| 681 | {}, |
| 682 | }; |
| 683 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 684 | static struct platform_driver omapdss_hdmihw_driver = { |
Tomi Valkeinen | 17ae4e8 | 2013-04-26 14:48:43 +0300 | [diff] [blame] | 685 | .probe = omapdss_hdmihw_probe, |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 686 | .remove = __exit_p(omapdss_hdmihw_remove), |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 687 | .driver = { |
| 688 | .name = "omapdss_hdmi", |
| 689 | .owner = THIS_MODULE, |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 690 | .pm = &hdmi_pm_ops, |
Tomi Valkeinen | 0465616 | 2013-12-16 15:14:04 +0200 | [diff] [blame] | 691 | .of_match_table = hdmi_of_match, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 692 | }, |
| 693 | }; |
| 694 | |
Archit Taneja | ef26958 | 2013-09-12 17:45:57 +0530 | [diff] [blame] | 695 | int __init hdmi4_init_platform_driver(void) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 696 | { |
Tomi Valkeinen | 17ae4e8 | 2013-04-26 14:48:43 +0300 | [diff] [blame] | 697 | return platform_driver_register(&omapdss_hdmihw_driver); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 698 | } |
| 699 | |
Archit Taneja | ef26958 | 2013-09-12 17:45:57 +0530 | [diff] [blame] | 700 | void __exit hdmi4_uninit_platform_driver(void) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 701 | { |
Tomi Valkeinen | 04c742c | 2012-02-23 15:32:37 +0200 | [diff] [blame] | 702 | platform_driver_unregister(&omapdss_hdmihw_driver); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 703 | } |