blob: 4fbe27191de5ba8214ea676fae00cd2f9371d3eb [file] [log] [blame]
Mythri P Kc3198a52011-03-12 12:04:27 +05301/*
2 * hdmi.c
3 *
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/
6 * Authors: Yong Zhi
7 * Mythri pk <mythripk@ti.com>
8 *
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.
12 *
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
16 * more details.
17 *
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/>.
20 */
21
22#define DSS_SUBSYS_NAME "HDMI"
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/err.h>
27#include <linux/io.h>
28#include <linux/interrupt.h>
29#include <linux/mutex.h>
30#include <linux/delay.h>
31#include <linux/string.h>
Tomi Valkeinen24e62892011-05-23 11:51:18 +030032#include <linux/platform_device.h>
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +030033#include <linux/pm_runtime.h>
34#include <linux/clk.h>
Tomi Valkeinencca35012012-04-26 14:48:32 +030035#include <linux/gpio.h>
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030036#include <video/omapdss.h>
Mythri P Kc3198a52011-03-12 12:04:27 +053037
Mythri P K94c52982011-09-08 19:06:21 +053038#include "ti_hdmi.h"
Mythri P Kc3198a52011-03-12 12:04:27 +053039#include "dss.h"
Ricardo Neriad44cc32011-05-18 22:31:56 -050040#include "dss_features.h"
Mythri P Kc3198a52011-03-12 12:04:27 +053041
Mythri P K95a8aeb2011-09-08 19:06:18 +053042#define HDMI_WP 0x0
43#define HDMI_CORE_SYS 0x400
44#define HDMI_CORE_AV 0x900
45#define HDMI_PLLCTRL 0x200
46#define HDMI_PHY 0x300
47
Mythri P K7c1f1ec2011-09-08 19:06:22 +053048/* HDMI EDID Length move this */
49#define HDMI_EDID_MAX_LENGTH 256
50#define EDID_TIMING_DESCRIPTOR_SIZE 0x12
51#define EDID_DESCRIPTOR_BLOCK0_ADDRESS 0x36
52#define EDID_DESCRIPTOR_BLOCK1_ADDRESS 0x80
53#define EDID_SIZE_BLOCK0_TIMING_DESCRIPTOR 4
54#define EDID_SIZE_BLOCK1_TIMING_DESCRIPTOR 4
55
Tomi Valkeinenb44e4582011-08-22 13:16:24 +030056#define HDMI_DEFAULT_REGN 16
Tomi Valkeinen8d88767a2011-08-22 13:02:52 +030057#define HDMI_DEFAULT_REGM2 1
58
Mythri P Kc3198a52011-03-12 12:04:27 +053059static struct {
60 struct mutex lock;
Mythri P Kc3198a52011-03-12 12:04:27 +053061 struct platform_device *pdev;
Mythri P K95a8aeb2011-09-08 19:06:18 +053062 struct hdmi_ip_data ip_data;
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +030063
64 struct clk *sys_clk;
Tomi Valkeinencca35012012-04-26 14:48:32 +030065
66 int ct_cp_hpd_gpio;
67 int ls_oe_gpio;
68 int hpd_gpio;
Mythri P Kc3198a52011-03-12 12:04:27 +053069} hdmi;
70
71/*
72 * Logic for the below structure :
73 * user enters the CEA or VESA timings by specifying the HDMI/DVI code.
74 * There is a correspondence between CEA/VESA timing and code, please
75 * refer to section 6.3 in HDMI 1.3 specification for timing code.
76 *
77 * In the below structure, cea_vesa_timings corresponds to all OMAP4
78 * supported CEA and VESA timing values.code_cea corresponds to the CEA
79 * code, It is used to get the timing from cea_vesa_timing array.Similarly
80 * with code_vesa. Code_index is used for back mapping, that is once EDID
81 * is read from the TV, EDID is parsed to find the timing values and then
82 * map it to corresponding CEA or VESA index.
83 */
84
Mythri P K46095b22012-01-06 17:52:09 +053085static const struct hdmi_config cea_timings[] = {
Archit Tanejacc937e52012-06-24 13:08:10 +053086 {
87 { 640, 480, 25200, 96, 16, 48, 2, 10, 33,
88 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
89 false, },
90 { 1, HDMI_HDMI },
91 },
92 {
93 { 720, 480, 27027, 62, 16, 60, 6, 9, 30,
94 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
95 false, },
96 { 2, HDMI_HDMI },
97 },
98 {
99 { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
100 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
101 false, },
102 { 4, HDMI_HDMI },
103 },
104 {
105 { 1920, 540, 74250, 44, 88, 148, 5, 2, 15,
106 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
107 true, },
108 { 5, HDMI_HDMI },
109 },
110 {
111 { 1440, 240, 27027, 124, 38, 114, 3, 4, 15,
112 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
113 true, },
114 { 6, HDMI_HDMI },
115 },
116 {
117 { 1920, 1080, 148500, 44, 88, 148, 5, 4, 36,
118 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
119 false, },
120 { 16, HDMI_HDMI },
121 },
122 {
123 { 720, 576, 27000, 64, 12, 68, 5, 5, 39,
124 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
125 false, },
126 { 17, HDMI_HDMI },
127 },
128 {
129 { 1280, 720, 74250, 40, 440, 220, 5, 5, 20,
130 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
131 false, },
132 { 19, HDMI_HDMI },
133 },
134 {
135 { 1920, 540, 74250, 44, 528, 148, 5, 2, 15,
136 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
137 true, },
138 { 20, HDMI_HDMI },
139 },
140 {
141 { 1440, 288, 27000, 126, 24, 138, 3, 2, 19,
142 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
143 true, },
144 { 21, HDMI_HDMI },
145 },
146 {
147 { 1440, 576, 54000, 128, 24, 136, 5, 5, 39,
148 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
149 false, },
150 { 29, HDMI_HDMI },
151 },
152 {
153 { 1920, 1080, 148500, 44, 528, 148, 5, 4, 36,
154 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
155 false, },
156 { 31, HDMI_HDMI },
157 },
158 {
159 { 1920, 1080, 74250, 44, 638, 148, 5, 4, 36,
160 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
161 false, },
162 { 32, HDMI_HDMI },
163 },
164 {
165 { 2880, 480, 108108, 248, 64, 240, 6, 9, 30,
166 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
167 false, },
168 { 35, HDMI_HDMI },
169 },
170 {
171 { 2880, 576, 108000, 256, 48, 272, 5, 5, 39,
172 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
173 false, },
174 { 37, HDMI_HDMI },
175 },
Mythri P K46095b22012-01-06 17:52:09 +0530176};
Archit Tanejacc937e52012-06-24 13:08:10 +0530177
Mythri P K46095b22012-01-06 17:52:09 +0530178static const struct hdmi_config vesa_timings[] = {
Mythri P Ka05ce782012-01-06 17:52:08 +0530179/* VESA From Here */
Archit Tanejacc937e52012-06-24 13:08:10 +0530180 {
181 { 640, 480, 25175, 96, 16, 48, 2, 11, 31,
182 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
183 false, },
184 { 4, HDMI_DVI },
185 },
186 {
187 { 800, 600, 40000, 128, 40, 88, 4, 1, 23,
188 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
189 false, },
190 { 9, HDMI_DVI },
191 },
192 {
193 { 848, 480, 33750, 112, 16, 112, 8, 6, 23,
194 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
195 false, },
196 { 0xE, HDMI_DVI },
197 },
198 {
199 { 1280, 768, 79500, 128, 64, 192, 7, 3, 20,
200 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
201 false, },
202 { 0x17, HDMI_DVI },
203 },
204 {
205 { 1280, 800, 83500, 128, 72, 200, 6, 3, 22,
206 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
207 false, },
208 { 0x1C, HDMI_DVI },
209 },
210 {
211 { 1360, 768, 85500, 112, 64, 256, 6, 3, 18,
212 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
213 false, },
214 { 0x27, HDMI_DVI },
215 },
216 {
217 { 1280, 960, 108000, 112, 96, 312, 3, 1, 36,
218 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
219 false, },
220 { 0x20, HDMI_DVI },
221 },
222 {
223 { 1280, 1024, 108000, 112, 48, 248, 3, 1, 38,
224 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
225 false, },
226 { 0x23, HDMI_DVI },
227 },
228 {
229 { 1024, 768, 65000, 136, 24, 160, 6, 3, 29,
230 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
231 false, },
232 { 0x10, HDMI_DVI },
233 },
234 {
235 { 1400, 1050, 121750, 144, 88, 232, 4, 3, 32,
236 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
237 false, },
238 { 0x2A, HDMI_DVI },
239 },
240 {
241 { 1440, 900, 106500, 152, 80, 232, 6, 3, 25,
242 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
243 false, },
244 { 0x2F, HDMI_DVI },
245 },
246 {
247 { 1680, 1050, 146250, 176 , 104, 280, 6, 3, 30,
248 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
249 false, },
250 { 0x3A, HDMI_DVI },
251 },
252 {
253 { 1366, 768, 85500, 143, 70, 213, 3, 3, 24,
254 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
255 false, },
256 { 0x51, HDMI_DVI },
257 },
258 {
259 { 1920, 1080, 148500, 44, 148, 80, 5, 4, 36,
260 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
261 false, },
262 { 0x52, HDMI_DVI },
263 },
264 {
265 { 1280, 768, 68250, 32, 48, 80, 7, 3, 12,
266 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
267 false, },
268 { 0x16, HDMI_DVI },
269 },
270 {
271 { 1400, 1050, 101000, 32, 48, 80, 4, 3, 23,
272 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
273 false, },
274 { 0x29, HDMI_DVI },
275 },
276 {
277 { 1680, 1050, 119000, 32, 48, 80, 6, 3, 21,
278 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
279 false, },
280 { 0x39, HDMI_DVI },
281 },
282 {
283 { 1280, 800, 79500, 32, 48, 80, 6, 3, 14,
284 OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
285 false, },
286 { 0x1B, HDMI_DVI },
287 },
288 {
289 { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
290 OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
291 false, },
292 { 0x55, HDMI_DVI },
293 },
Mythri P Kc3198a52011-03-12 12:04:27 +0530294};
295
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300296static int hdmi_runtime_get(void)
297{
298 int r;
299
300 DSSDBG("hdmi_runtime_get\n");
301
302 r = pm_runtime_get_sync(&hdmi.pdev->dev);
303 WARN_ON(r < 0);
Archit Tanejaa247ce782012-02-10 11:45:52 +0530304 if (r < 0)
Tomi Valkeinen852f0832012-02-17 17:58:04 +0200305 return r;
Archit Tanejaa247ce782012-02-10 11:45:52 +0530306
307 return 0;
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300308}
309
310static void hdmi_runtime_put(void)
311{
312 int r;
313
314 DSSDBG("hdmi_runtime_put\n");
315
Tomi Valkeinen0eaf9f52012-01-23 13:23:08 +0200316 r = pm_runtime_put_sync(&hdmi.pdev->dev);
Tomi Valkeinen5be3aeb2012-06-27 16:37:18 +0300317 WARN_ON(r < 0 && r != -ENOSYS);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300318}
319
Tomi Valkeinen9d8232a2012-03-01 16:58:39 +0200320static int __init hdmi_init_display(struct omap_dss_device *dssdev)
Mythri P Kc3198a52011-03-12 12:04:27 +0530321{
Tomi Valkeinencca35012012-04-26 14:48:32 +0300322 int r;
323
324 struct gpio gpios[] = {
325 { hdmi.ct_cp_hpd_gpio, GPIOF_OUT_INIT_LOW, "hdmi_ct_cp_hpd" },
326 { hdmi.ls_oe_gpio, GPIOF_OUT_INIT_LOW, "hdmi_ls_oe" },
327 { hdmi.hpd_gpio, GPIOF_DIR_IN, "hdmi_hpd" },
328 };
329
Mythri P Kc3198a52011-03-12 12:04:27 +0530330 DSSDBG("init_display\n");
331
Mythri P K60634a22011-09-08 19:06:26 +0530332 dss_init_hdmi_ip_ops(&hdmi.ip_data);
Tomi Valkeinencca35012012-04-26 14:48:32 +0300333
334 r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
335 if (r)
336 return r;
337
Mythri P Kc3198a52011-03-12 12:04:27 +0530338 return 0;
339}
340
Tomi Valkeinencca35012012-04-26 14:48:32 +0300341static void __exit hdmi_uninit_display(struct omap_dss_device *dssdev)
342{
343 DSSDBG("uninit_display\n");
344
345 gpio_free(hdmi.ct_cp_hpd_gpio);
346 gpio_free(hdmi.ls_oe_gpio);
347 gpio_free(hdmi.hpd_gpio);
348}
349
Mythri P K46095b22012-01-06 17:52:09 +0530350static const struct hdmi_config *hdmi_find_timing(
351 const struct hdmi_config *timings_arr,
352 int len)
Mythri P Kc3198a52011-03-12 12:04:27 +0530353{
Mythri P K46095b22012-01-06 17:52:09 +0530354 int i;
Mythri P Kc3198a52011-03-12 12:04:27 +0530355
Mythri P K46095b22012-01-06 17:52:09 +0530356 for (i = 0; i < len; i++) {
Mythri P K9e4ed602012-01-06 17:52:10 +0530357 if (timings_arr[i].cm.code == hdmi.ip_data.cfg.cm.code)
Mythri P K46095b22012-01-06 17:52:09 +0530358 return &timings_arr[i];
Mythri P Kc3198a52011-03-12 12:04:27 +0530359 }
Mythri P K46095b22012-01-06 17:52:09 +0530360 return NULL;
361}
362
363static const struct hdmi_config *hdmi_get_timings(void)
364{
365 const struct hdmi_config *arr;
366 int len;
367
Mythri P K9e4ed602012-01-06 17:52:10 +0530368 if (hdmi.ip_data.cfg.cm.mode == HDMI_DVI) {
Mythri P K46095b22012-01-06 17:52:09 +0530369 arr = vesa_timings;
370 len = ARRAY_SIZE(vesa_timings);
371 } else {
372 arr = cea_timings;
373 len = ARRAY_SIZE(cea_timings);
374 }
375
376 return hdmi_find_timing(arr, len);
377}
378
379static bool hdmi_timings_compare(struct omap_video_timings *timing1,
Archit Tanejacc937e52012-06-24 13:08:10 +0530380 const struct omap_video_timings *timing2)
Mythri P K46095b22012-01-06 17:52:09 +0530381{
382 int timing1_vsync, timing1_hsync, timing2_vsync, timing2_hsync;
383
384 if ((timing2->pixel_clock == timing1->pixel_clock) &&
385 (timing2->x_res == timing1->x_res) &&
386 (timing2->y_res == timing1->y_res)) {
387
388 timing2_hsync = timing2->hfp + timing2->hsw + timing2->hbp;
389 timing1_hsync = timing1->hfp + timing1->hsw + timing1->hbp;
390 timing2_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
391 timing1_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
392
393 DSSDBG("timing1_hsync = %d timing1_vsync = %d"\
394 "timing2_hsync = %d timing2_vsync = %d\n",
395 timing1_hsync, timing1_vsync,
396 timing2_hsync, timing2_vsync);
397
398 if ((timing1_hsync == timing2_hsync) &&
399 (timing1_vsync == timing2_vsync)) {
400 return true;
401 }
402 }
403 return false;
Mythri P Kc3198a52011-03-12 12:04:27 +0530404}
405
406static struct hdmi_cm hdmi_get_code(struct omap_video_timings *timing)
407{
Mythri P K46095b22012-01-06 17:52:09 +0530408 int i;
Mythri P Kc3198a52011-03-12 12:04:27 +0530409 struct hdmi_cm cm = {-1};
410 DSSDBG("hdmi_get_code\n");
411
Mythri P K46095b22012-01-06 17:52:09 +0530412 for (i = 0; i < ARRAY_SIZE(cea_timings); i++) {
413 if (hdmi_timings_compare(timing, &cea_timings[i].timings)) {
414 cm = cea_timings[i].cm;
415 goto end;
416 }
417 }
418 for (i = 0; i < ARRAY_SIZE(vesa_timings); i++) {
419 if (hdmi_timings_compare(timing, &vesa_timings[i].timings)) {
420 cm = vesa_timings[i].cm;
421 goto end;
Mythri P Kc3198a52011-03-12 12:04:27 +0530422 }
423 }
424
Mythri P K46095b22012-01-06 17:52:09 +0530425end: return cm;
Mythri P Kc3198a52011-03-12 12:04:27 +0530426
Mythri P Kc3198a52011-03-12 12:04:27 +0530427}
428
Archit Tanejac3dc6a72011-09-13 18:28:41 +0530429unsigned long hdmi_get_pixel_clock(void)
430{
431 /* HDMI Pixel Clock in Mhz */
Mythri P Ka05ce782012-01-06 17:52:08 +0530432 return hdmi.ip_data.cfg.timings.pixel_clock * 1000;
Archit Tanejac3dc6a72011-09-13 18:28:41 +0530433}
434
Archit Taneja6cb07b22011-04-12 13:52:25 +0530435static void hdmi_compute_pll(struct omap_dss_device *dssdev, int phy,
436 struct hdmi_pll_info *pi)
Mythri P Kc3198a52011-03-12 12:04:27 +0530437{
Archit Taneja6cb07b22011-04-12 13:52:25 +0530438 unsigned long clkin, refclk;
Mythri P Kc3198a52011-03-12 12:04:27 +0530439 u32 mf;
440
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300441 clkin = clk_get_rate(hdmi.sys_clk) / 10000;
Mythri P Kc3198a52011-03-12 12:04:27 +0530442 /*
443 * Input clock is predivided by N + 1
444 * out put of which is reference clk
445 */
Tomi Valkeinen8d88767a2011-08-22 13:02:52 +0300446 if (dssdev->clocks.hdmi.regn == 0)
447 pi->regn = HDMI_DEFAULT_REGN;
448 else
449 pi->regn = dssdev->clocks.hdmi.regn;
450
Tomi Valkeinenb44e4582011-08-22 13:16:24 +0300451 refclk = clkin / pi->regn;
Mythri P Kc3198a52011-03-12 12:04:27 +0530452
Tomi Valkeinen8d88767a2011-08-22 13:02:52 +0300453 if (dssdev->clocks.hdmi.regm2 == 0)
454 pi->regm2 = HDMI_DEFAULT_REGM2;
455 else
456 pi->regm2 = dssdev->clocks.hdmi.regm2;
Mythri P Kc3198a52011-03-12 12:04:27 +0530457
458 /*
Mythri P Kdd2116a2012-02-21 12:10:58 +0530459 * multiplier is pixel_clk/ref_clk
460 * Multiplying by 100 to avoid fractional part removal
461 */
462 pi->regm = phy * pi->regm2 / refclk;
463
464 /*
Mythri P Kc3198a52011-03-12 12:04:27 +0530465 * fractional multiplier is remainder of the difference between
466 * multiplier and actual phy(required pixel clock thus should be
467 * multiplied by 2^18(262144) divided by the reference clock
468 */
Mythri P Kdd2116a2012-02-21 12:10:58 +0530469 mf = (phy - pi->regm / pi->regm2 * refclk) * 262144;
470 pi->regmf = pi->regm2 * mf / refclk;
Mythri P Kc3198a52011-03-12 12:04:27 +0530471
472 /*
473 * Dcofreq should be set to 1 if required pixel clock
474 * is greater than 1000MHz
475 */
476 pi->dcofreq = phy > 1000 * 100;
Tomi Valkeinenb44e4582011-08-22 13:16:24 +0300477 pi->regsd = ((pi->regm * clkin / 10) / (pi->regn * 250) + 5) / 10;
Mythri P Kc3198a52011-03-12 12:04:27 +0530478
Mythri P K7b27da52011-09-08 19:06:19 +0530479 /* Set the reference clock to sysclk reference */
480 pi->refsel = HDMI_REFSEL_SYSCLK;
481
Mythri P Kc3198a52011-03-12 12:04:27 +0530482 DSSDBG("M = %d Mf = %d\n", pi->regm, pi->regmf);
483 DSSDBG("range = %d sd = %d\n", pi->dcofreq, pi->regsd);
484}
485
Mythri P Kc3198a52011-03-12 12:04:27 +0530486static int hdmi_power_on(struct omap_dss_device *dssdev)
487{
Mythri P K46095b22012-01-06 17:52:09 +0530488 int r;
Mythri P Kc3198a52011-03-12 12:04:27 +0530489 struct omap_video_timings *p;
Archit Taneja6cb07b22011-04-12 13:52:25 +0530490 unsigned long phy;
Mythri P Kc3198a52011-03-12 12:04:27 +0530491
Tomi Valkeinencca35012012-04-26 14:48:32 +0300492 gpio_set_value(hdmi.ct_cp_hpd_gpio, 1);
493 gpio_set_value(hdmi.ls_oe_gpio, 1);
494
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300495 r = hdmi_runtime_get();
496 if (r)
Tomi Valkeinencca35012012-04-26 14:48:32 +0300497 goto err_runtime_get;
Mythri P Kc3198a52011-03-12 12:04:27 +0530498
Tomi Valkeinen7797c6d2011-11-04 10:22:46 +0200499 dss_mgr_disable(dssdev->manager);
Mythri P Kc3198a52011-03-12 12:04:27 +0530500
Archit Taneja78493982012-08-08 16:50:42 +0530501 p = &hdmi.ip_data.cfg.timings;
Mythri P Kc3198a52011-03-12 12:04:27 +0530502
Archit Taneja78493982012-08-08 16:50:42 +0530503 DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
Mythri P Kc3198a52011-03-12 12:04:27 +0530504
Mythri P Kc3198a52011-03-12 12:04:27 +0530505 phy = p->pixel_clock;
506
Mythri P K7b27da52011-09-08 19:06:19 +0530507 hdmi_compute_pll(dssdev, phy, &hdmi.ip_data.pll_data);
Mythri P Kc3198a52011-03-12 12:04:27 +0530508
Ricardo Neric0456be2012-04-27 13:48:45 -0500509 hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
Mythri P Kc3198a52011-03-12 12:04:27 +0530510
Mythri P K95a8aeb2011-09-08 19:06:18 +0530511 /* config the PLL and PHY hdmi_set_pll_pwrfirst */
Mythri P K60634a22011-09-08 19:06:26 +0530512 r = hdmi.ip_data.ops->pll_enable(&hdmi.ip_data);
Mythri P Kc3198a52011-03-12 12:04:27 +0530513 if (r) {
514 DSSDBG("Failed to lock PLL\n");
Tomi Valkeinencca35012012-04-26 14:48:32 +0300515 goto err_pll_enable;
Mythri P Kc3198a52011-03-12 12:04:27 +0530516 }
517
Mythri P K60634a22011-09-08 19:06:26 +0530518 r = hdmi.ip_data.ops->phy_enable(&hdmi.ip_data);
Mythri P Kc3198a52011-03-12 12:04:27 +0530519 if (r) {
520 DSSDBG("Failed to start PHY\n");
Ricardo Nerid3b4aa52012-07-30 19:12:02 -0500521 goto err_phy_enable;
Mythri P Kc3198a52011-03-12 12:04:27 +0530522 }
523
Mythri P K60634a22011-09-08 19:06:26 +0530524 hdmi.ip_data.ops->video_configure(&hdmi.ip_data);
Mythri P Kc3198a52011-03-12 12:04:27 +0530525
526 /* Make selection of HDMI in DSS */
527 dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
528
529 /* Select the dispc clock source as PRCM clock, to ensure that it is not
530 * DSI PLL source as the clock selected by DSI PLL might not be
531 * sufficient for the resolution selected / that can be changed
532 * dynamically by user. This can be moved to single location , say
533 * Boardfile.
534 */
Archit Taneja6cb07b22011-04-12 13:52:25 +0530535 dss_select_dispc_clk_source(dssdev->clocks.dispc.dispc_fclk_src);
Mythri P Kc3198a52011-03-12 12:04:27 +0530536
537 /* bypass TV gamma table */
538 dispc_enable_gamma_table(0);
539
540 /* tv size */
Archit Taneja78493982012-08-08 16:50:42 +0530541 dss_mgr_set_timings(dssdev->manager, p);
Mythri P Kc3198a52011-03-12 12:04:27 +0530542
Ricardo Neric0456be2012-04-27 13:48:45 -0500543 r = hdmi.ip_data.ops->video_enable(&hdmi.ip_data);
544 if (r)
545 goto err_vid_enable;
Mythri P Kc3198a52011-03-12 12:04:27 +0530546
Tomi Valkeinen33ca2372011-11-21 13:42:58 +0200547 r = dss_mgr_enable(dssdev->manager);
548 if (r)
549 goto err_mgr_enable;
Tomi Valkeinen3870c902011-08-31 14:47:11 +0300550
Mythri P Kc3198a52011-03-12 12:04:27 +0530551 return 0;
Tomi Valkeinen33ca2372011-11-21 13:42:58 +0200552
553err_mgr_enable:
Ricardo Neric0456be2012-04-27 13:48:45 -0500554 hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
555err_vid_enable:
Tomi Valkeinen33ca2372011-11-21 13:42:58 +0200556 hdmi.ip_data.ops->phy_disable(&hdmi.ip_data);
Ricardo Nerid3b4aa52012-07-30 19:12:02 -0500557err_phy_enable:
Tomi Valkeinen33ca2372011-11-21 13:42:58 +0200558 hdmi.ip_data.ops->pll_disable(&hdmi.ip_data);
Tomi Valkeinencca35012012-04-26 14:48:32 +0300559err_pll_enable:
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300560 hdmi_runtime_put();
Tomi Valkeinencca35012012-04-26 14:48:32 +0300561err_runtime_get:
562 gpio_set_value(hdmi.ct_cp_hpd_gpio, 0);
563 gpio_set_value(hdmi.ls_oe_gpio, 0);
Mythri P Kc3198a52011-03-12 12:04:27 +0530564 return -EIO;
565}
566
567static void hdmi_power_off(struct omap_dss_device *dssdev)
568{
Tomi Valkeinen7797c6d2011-11-04 10:22:46 +0200569 dss_mgr_disable(dssdev->manager);
Mythri P Kc3198a52011-03-12 12:04:27 +0530570
Ricardo Neric0456be2012-04-27 13:48:45 -0500571 hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
Mythri P K60634a22011-09-08 19:06:26 +0530572 hdmi.ip_data.ops->phy_disable(&hdmi.ip_data);
573 hdmi.ip_data.ops->pll_disable(&hdmi.ip_data);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300574 hdmi_runtime_put();
Tomi Valkeinencca35012012-04-26 14:48:32 +0300575
576 gpio_set_value(hdmi.ct_cp_hpd_gpio, 0);
577 gpio_set_value(hdmi.ls_oe_gpio, 0);
Mythri P Kc3198a52011-03-12 12:04:27 +0530578}
579
580int omapdss_hdmi_display_check_timing(struct omap_dss_device *dssdev,
581 struct omap_video_timings *timings)
582{
583 struct hdmi_cm cm;
584
585 cm = hdmi_get_code(timings);
586 if (cm.code == -1) {
Mythri P Kc3198a52011-03-12 12:04:27 +0530587 return -EINVAL;
588 }
589
590 return 0;
591
592}
593
Archit Taneja78493982012-08-08 16:50:42 +0530594void omapdss_hdmi_display_set_timing(struct omap_dss_device *dssdev,
595 struct omap_video_timings *timings)
Mythri P Kc3198a52011-03-12 12:04:27 +0530596{
597 struct hdmi_cm cm;
Archit Taneja78493982012-08-08 16:50:42 +0530598 const struct hdmi_config *t;
Mythri P Kc3198a52011-03-12 12:04:27 +0530599
Archit Tanejaed1aa902012-08-15 00:40:31 +0530600 mutex_lock(&hdmi.lock);
601
Archit Taneja78493982012-08-08 16:50:42 +0530602 cm = hdmi_get_code(timings);
603 hdmi.ip_data.cfg.cm = cm;
604
605 t = hdmi_get_timings();
606 if (t != NULL)
607 hdmi.ip_data.cfg = *t;
Tomi Valkeinenfa70dc52011-08-22 14:57:33 +0300608
609 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
610 int r;
611
612 hdmi_power_off(dssdev);
613
614 r = hdmi_power_on(dssdev);
615 if (r)
616 DSSERR("failed to power on device\n");
Archit Tanejafcc36612012-05-03 20:03:11 +0530617 } else {
Archit Taneja78493982012-08-08 16:50:42 +0530618 dss_mgr_set_timings(dssdev->manager, &t->timings);
Tomi Valkeinenfa70dc52011-08-22 14:57:33 +0300619 }
Archit Tanejaed1aa902012-08-15 00:40:31 +0530620
621 mutex_unlock(&hdmi.lock);
Mythri P Kc3198a52011-03-12 12:04:27 +0530622}
623
Tomi Valkeinene40402c2012-03-02 18:01:07 +0200624static void hdmi_dump_regs(struct seq_file *s)
Mythri P K162874d2011-09-22 13:37:45 +0530625{
626 mutex_lock(&hdmi.lock);
627
628 if (hdmi_runtime_get())
629 return;
630
631 hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s);
632 hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s);
633 hdmi.ip_data.ops->dump_phy(&hdmi.ip_data, s);
634 hdmi.ip_data.ops->dump_core(&hdmi.ip_data, s);
635
636 hdmi_runtime_put();
637 mutex_unlock(&hdmi.lock);
638}
639
Tomi Valkeinen47024562011-08-25 17:12:56 +0300640int omapdss_hdmi_read_edid(u8 *buf, int len)
641{
642 int r;
643
644 mutex_lock(&hdmi.lock);
645
646 r = hdmi_runtime_get();
647 BUG_ON(r);
648
649 r = hdmi.ip_data.ops->read_edid(&hdmi.ip_data, buf, len);
650
651 hdmi_runtime_put();
652 mutex_unlock(&hdmi.lock);
653
654 return r;
655}
656
Tomi Valkeinen759593f2011-08-29 18:10:20 +0300657bool omapdss_hdmi_detect(void)
658{
659 int r;
660
661 mutex_lock(&hdmi.lock);
662
663 r = hdmi_runtime_get();
664 BUG_ON(r);
665
666 r = hdmi.ip_data.ops->detect(&hdmi.ip_data);
667
668 hdmi_runtime_put();
669 mutex_unlock(&hdmi.lock);
670
671 return r == 1;
672}
673
Mythri P Kc3198a52011-03-12 12:04:27 +0530674int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev)
675{
676 int r = 0;
677
678 DSSDBG("ENTER hdmi_display_enable\n");
679
680 mutex_lock(&hdmi.lock);
681
Tomi Valkeinen05e1d602011-06-23 16:38:21 +0300682 if (dssdev->manager == NULL) {
683 DSSERR("failed to enable display: no manager\n");
684 r = -ENODEV;
685 goto err0;
686 }
687
Tomi Valkeinencca35012012-04-26 14:48:32 +0300688 hdmi.ip_data.hpd_gpio = hdmi.hpd_gpio;
Tomi Valkeinenc49d0052012-01-17 11:09:57 +0200689
Mythri P Kc3198a52011-03-12 12:04:27 +0530690 r = omap_dss_start_device(dssdev);
691 if (r) {
692 DSSERR("failed to start device\n");
693 goto err0;
694 }
695
Mythri P Kc3198a52011-03-12 12:04:27 +0530696 r = hdmi_power_on(dssdev);
697 if (r) {
698 DSSERR("failed to power on device\n");
Tomi Valkeinencca35012012-04-26 14:48:32 +0300699 goto err1;
Mythri P Kc3198a52011-03-12 12:04:27 +0530700 }
701
702 mutex_unlock(&hdmi.lock);
703 return 0;
704
Mythri P Kc3198a52011-03-12 12:04:27 +0530705err1:
706 omap_dss_stop_device(dssdev);
707err0:
708 mutex_unlock(&hdmi.lock);
709 return r;
710}
711
712void omapdss_hdmi_display_disable(struct omap_dss_device *dssdev)
713{
714 DSSDBG("Enter hdmi_display_disable\n");
715
716 mutex_lock(&hdmi.lock);
717
718 hdmi_power_off(dssdev);
719
Mythri P Kc3198a52011-03-12 12:04:27 +0530720 omap_dss_stop_device(dssdev);
721
722 mutex_unlock(&hdmi.lock);
723}
724
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300725static int hdmi_get_clocks(struct platform_device *pdev)
726{
727 struct clk *clk;
728
729 clk = clk_get(&pdev->dev, "sys_clk");
730 if (IS_ERR(clk)) {
731 DSSERR("can't get sys_clk\n");
732 return PTR_ERR(clk);
733 }
734
735 hdmi.sys_clk = clk;
736
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300737 return 0;
738}
739
740static void hdmi_put_clocks(void)
741{
742 if (hdmi.sys_clk)
743 clk_put(hdmi.sys_clk);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300744}
745
Ricardo Neri35547622012-03-20 21:02:01 -0600746#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
747int hdmi_compute_acr(u32 sample_freq, u32 *n, u32 *cts)
748{
749 u32 deep_color;
Ricardo Neri25a65352012-03-23 15:49:02 -0600750 bool deep_color_correct = false;
Ricardo Neri35547622012-03-20 21:02:01 -0600751 u32 pclk = hdmi.ip_data.cfg.timings.pixel_clock;
752
753 if (n == NULL || cts == NULL)
754 return -EINVAL;
755
756 /* TODO: When implemented, query deep color mode here. */
757 deep_color = 100;
758
Ricardo Neri25a65352012-03-23 15:49:02 -0600759 /*
760 * When using deep color, the default N value (as in the HDMI
761 * specification) yields to an non-integer CTS. Hence, we
762 * modify it while keeping the restrictions described in
763 * section 7.2.1 of the HDMI 1.4a specification.
764 */
Ricardo Neri35547622012-03-20 21:02:01 -0600765 switch (sample_freq) {
766 case 32000:
Ricardo Neri25a65352012-03-23 15:49:02 -0600767 case 48000:
768 case 96000:
769 case 192000:
770 if (deep_color == 125)
771 if (pclk == 27027 || pclk == 74250)
772 deep_color_correct = true;
773 if (deep_color == 150)
774 if (pclk == 27027)
775 deep_color_correct = true;
Ricardo Neri35547622012-03-20 21:02:01 -0600776 break;
777 case 44100:
Ricardo Neri25a65352012-03-23 15:49:02 -0600778 case 88200:
779 case 176400:
780 if (deep_color == 125)
781 if (pclk == 27027)
782 deep_color_correct = true;
Ricardo Neri35547622012-03-20 21:02:01 -0600783 break;
784 default:
Ricardo Neri35547622012-03-20 21:02:01 -0600785 return -EINVAL;
786 }
787
Ricardo Neri25a65352012-03-23 15:49:02 -0600788 if (deep_color_correct) {
789 switch (sample_freq) {
790 case 32000:
791 *n = 8192;
792 break;
793 case 44100:
794 *n = 12544;
795 break;
796 case 48000:
797 *n = 8192;
798 break;
799 case 88200:
800 *n = 25088;
801 break;
802 case 96000:
803 *n = 16384;
804 break;
805 case 176400:
806 *n = 50176;
807 break;
808 case 192000:
809 *n = 32768;
810 break;
811 default:
812 return -EINVAL;
813 }
814 } else {
815 switch (sample_freq) {
816 case 32000:
817 *n = 4096;
818 break;
819 case 44100:
820 *n = 6272;
821 break;
822 case 48000:
823 *n = 6144;
824 break;
825 case 88200:
826 *n = 12544;
827 break;
828 case 96000:
829 *n = 12288;
830 break;
831 case 176400:
832 *n = 25088;
833 break;
834 case 192000:
835 *n = 24576;
836 break;
837 default:
838 return -EINVAL;
839 }
840 }
Ricardo Neri35547622012-03-20 21:02:01 -0600841 /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */
842 *cts = pclk * (*n / 128) * deep_color / (sample_freq / 10);
843
844 return 0;
845}
Ricardo Nerif3a974912012-05-09 21:09:50 -0500846
847int hdmi_audio_enable(void)
848{
849 DSSDBG("audio_enable\n");
850
851 return hdmi.ip_data.ops->audio_enable(&hdmi.ip_data);
852}
853
854void hdmi_audio_disable(void)
855{
856 DSSDBG("audio_disable\n");
857
858 hdmi.ip_data.ops->audio_disable(&hdmi.ip_data);
859}
860
861int hdmi_audio_start(void)
862{
863 DSSDBG("audio_start\n");
864
865 return hdmi.ip_data.ops->audio_start(&hdmi.ip_data);
866}
867
868void hdmi_audio_stop(void)
869{
870 DSSDBG("audio_stop\n");
871
872 hdmi.ip_data.ops->audio_stop(&hdmi.ip_data);
873}
874
875bool hdmi_mode_has_audio(void)
876{
877 if (hdmi.ip_data.cfg.cm.mode == HDMI_HDMI)
878 return true;
879 else
880 return false;
881}
882
883int hdmi_audio_config(struct omap_dss_audio *audio)
884{
885 return hdmi.ip_data.ops->audio_config(&hdmi.ip_data, audio);
886}
887
Ricardo Neri35547622012-03-20 21:02:01 -0600888#endif
889
Tomi Valkeinen38f3daf2012-05-02 14:55:12 +0300890static void __init hdmi_probe_pdata(struct platform_device *pdev)
891{
892 struct omap_dss_board_info *pdata = pdev->dev.platform_data;
893 int r, i;
894
895 for (i = 0; i < pdata->num_devices; ++i) {
896 struct omap_dss_device *dssdev = pdata->devices[i];
Tomi Valkeinencca35012012-04-26 14:48:32 +0300897 struct omap_dss_hdmi_data *priv = dssdev->data;
Tomi Valkeinen38f3daf2012-05-02 14:55:12 +0300898
899 if (dssdev->type != OMAP_DISPLAY_TYPE_HDMI)
900 continue;
901
Tomi Valkeinencca35012012-04-26 14:48:32 +0300902 hdmi.ct_cp_hpd_gpio = priv->ct_cp_hpd_gpio;
903 hdmi.ls_oe_gpio = priv->ls_oe_gpio;
904 hdmi.hpd_gpio = priv->hpd_gpio;
905
Tomi Valkeinen38f3daf2012-05-02 14:55:12 +0300906 r = hdmi_init_display(dssdev);
907 if (r) {
908 DSSERR("device %s init failed: %d\n", dssdev->name, r);
909 continue;
910 }
911
912 r = omap_dss_register_device(dssdev, &pdev->dev, i);
913 if (r)
914 DSSERR("device %s register failed: %d\n",
915 dssdev->name, r);
916 }
917}
918
Mythri P Kc3198a52011-03-12 12:04:27 +0530919/* HDMI HW IP initialisation */
Tomi Valkeinen6e7e8f02012-02-17 17:41:13 +0200920static int __init omapdss_hdmihw_probe(struct platform_device *pdev)
Mythri P Kc3198a52011-03-12 12:04:27 +0530921{
922 struct resource *hdmi_mem;
Tomi Valkeinen38f3daf2012-05-02 14:55:12 +0300923 int r;
Mythri P Kc3198a52011-03-12 12:04:27 +0530924
Mythri P Kc3198a52011-03-12 12:04:27 +0530925 hdmi.pdev = pdev;
926
927 mutex_init(&hdmi.lock);
928
929 hdmi_mem = platform_get_resource(hdmi.pdev, IORESOURCE_MEM, 0);
930 if (!hdmi_mem) {
931 DSSERR("can't get IORESOURCE_MEM HDMI\n");
932 return -EINVAL;
933 }
934
935 /* Base address taken from platform */
Mythri P K95a8aeb2011-09-08 19:06:18 +0530936 hdmi.ip_data.base_wp = ioremap(hdmi_mem->start,
937 resource_size(hdmi_mem));
938 if (!hdmi.ip_data.base_wp) {
Mythri P Kc3198a52011-03-12 12:04:27 +0530939 DSSERR("can't ioremap WP\n");
940 return -ENOMEM;
941 }
942
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300943 r = hdmi_get_clocks(pdev);
944 if (r) {
Mythri P K95a8aeb2011-09-08 19:06:18 +0530945 iounmap(hdmi.ip_data.base_wp);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300946 return r;
947 }
948
949 pm_runtime_enable(&pdev->dev);
950
Mythri P K95a8aeb2011-09-08 19:06:18 +0530951 hdmi.ip_data.core_sys_offset = HDMI_CORE_SYS;
952 hdmi.ip_data.core_av_offset = HDMI_CORE_AV;
953 hdmi.ip_data.pll_offset = HDMI_PLLCTRL;
954 hdmi.ip_data.phy_offset = HDMI_PHY;
Archit Taneja78493982012-08-08 16:50:42 +0530955
Jassi Brar3a5383a2012-06-27 19:34:56 +0530956 mutex_init(&hdmi.ip_data.lock);
Mythri P K95a8aeb2011-09-08 19:06:18 +0530957
Mythri P Kc3198a52011-03-12 12:04:27 +0530958 hdmi_panel_init();
959
Tomi Valkeinene40402c2012-03-02 18:01:07 +0200960 dss_debugfs_create_file("hdmi", hdmi_dump_regs);
961
Tomi Valkeinen38f3daf2012-05-02 14:55:12 +0300962 hdmi_probe_pdata(pdev);
Tomi Valkeinen35deca32012-03-01 15:45:53 +0200963
Mythri P Kc3198a52011-03-12 12:04:27 +0530964 return 0;
965}
966
Tomi Valkeinencca35012012-04-26 14:48:32 +0300967static int __exit hdmi_remove_child(struct device *dev, void *data)
968{
969 struct omap_dss_device *dssdev = to_dss_device(dev);
970 hdmi_uninit_display(dssdev);
971 return 0;
972}
973
Tomi Valkeinen6e7e8f02012-02-17 17:41:13 +0200974static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
Mythri P Kc3198a52011-03-12 12:04:27 +0530975{
Tomi Valkeinencca35012012-04-26 14:48:32 +0300976 device_for_each_child(&pdev->dev, NULL, hdmi_remove_child);
977
Tomi Valkeinen35deca32012-03-01 15:45:53 +0200978 omap_dss_unregister_child_devices(&pdev->dev);
979
Mythri P Kc3198a52011-03-12 12:04:27 +0530980 hdmi_panel_exit();
981
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300982 pm_runtime_disable(&pdev->dev);
983
984 hdmi_put_clocks();
985
Mythri P K95a8aeb2011-09-08 19:06:18 +0530986 iounmap(hdmi.ip_data.base_wp);
Mythri P Kc3198a52011-03-12 12:04:27 +0530987
988 return 0;
989}
990
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300991static int hdmi_runtime_suspend(struct device *dev)
992{
Rajendra Nayakf11766d2012-06-27 14:21:26 +0530993 clk_disable_unprepare(hdmi.sys_clk);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300994
995 dispc_runtime_put();
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300996
997 return 0;
998}
999
1000static int hdmi_runtime_resume(struct device *dev)
1001{
1002 int r;
1003
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +03001004 r = dispc_runtime_get();
1005 if (r < 0)
Tomi Valkeinen852f0832012-02-17 17:58:04 +02001006 return r;
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +03001007
Rajendra Nayakf11766d2012-06-27 14:21:26 +05301008 clk_prepare_enable(hdmi.sys_clk);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +03001009
1010 return 0;
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +03001011}
1012
1013static const struct dev_pm_ops hdmi_pm_ops = {
1014 .runtime_suspend = hdmi_runtime_suspend,
1015 .runtime_resume = hdmi_runtime_resume,
1016};
1017
Mythri P Kc3198a52011-03-12 12:04:27 +05301018static struct platform_driver omapdss_hdmihw_driver = {
Tomi Valkeinen6e7e8f02012-02-17 17:41:13 +02001019 .remove = __exit_p(omapdss_hdmihw_remove),
Mythri P Kc3198a52011-03-12 12:04:27 +05301020 .driver = {
1021 .name = "omapdss_hdmi",
1022 .owner = THIS_MODULE,
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +03001023 .pm = &hdmi_pm_ops,
Mythri P Kc3198a52011-03-12 12:04:27 +05301024 },
1025};
1026
Tomi Valkeinen6e7e8f02012-02-17 17:41:13 +02001027int __init hdmi_init_platform_driver(void)
Mythri P Kc3198a52011-03-12 12:04:27 +05301028{
Tomi Valkeinen61055d42012-03-07 12:53:38 +02001029 return platform_driver_probe(&omapdss_hdmihw_driver, omapdss_hdmihw_probe);
Mythri P Kc3198a52011-03-12 12:04:27 +05301030}
1031
Tomi Valkeinen6e7e8f02012-02-17 17:41:13 +02001032void __exit hdmi_uninit_platform_driver(void)
Mythri P Kc3198a52011-03-12 12:04:27 +05301033{
Tomi Valkeinen04c742c2012-02-23 15:32:37 +02001034 platform_driver_unregister(&omapdss_hdmihw_driver);
Mythri P Kc3198a52011-03-12 12:04:27 +05301035}