blob: 929ceb3ddd9d5657385dad02e29b8158f9b2e16f [file] [log] [blame]
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +03001/*
2 * linux/drivers/video/omap2/dss/sdi.c
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.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 "SDI"
21
22#include <linux/kernel.h>
23#include <linux/clk.h>
24#include <linux/delay.h>
25#include <linux/err.h>
26
27#include <plat/display.h>
28#include "dss.h"
29
30static struct {
31 bool skip_init;
32 bool update_enabled;
33} sdi;
34
35static void sdi_basic_init(void)
36{
37 dispc_set_parallel_interface_mode(OMAP_DSS_PARALLELMODE_BYPASS);
38
39 dispc_set_lcd_display_type(OMAP_DSS_LCD_DISPLAY_TFT);
40 dispc_set_tft_data_lines(24);
41 dispc_lcd_enable_signal_polarity(1);
42}
43
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020044int omapdss_sdi_display_enable(struct omap_dss_device *dssdev)
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030045{
46 struct omap_video_timings *t = &dssdev->panel.timings;
47 struct dss_clock_info dss_cinfo;
48 struct dispc_clock_info dispc_cinfo;
49 u16 lck_div, pck_div;
50 unsigned long fck;
51 unsigned long pck;
52 int r;
53
54 r = omap_dss_start_device(dssdev);
55 if (r) {
56 DSSERR("failed to start device\n");
57 goto err0;
58 }
59
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030060 /* In case of skip_init sdi_init has already enabled the clocks */
61 if (!sdi.skip_init)
62 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
63
64 sdi_basic_init();
65
66 /* 15.5.9.1.2 */
67 dssdev->panel.config |= OMAP_DSS_LCD_RF | OMAP_DSS_LCD_ONOFF;
68
69 dispc_set_pol_freq(dssdev->panel.config, dssdev->panel.acbi,
70 dssdev->panel.acb);
71
72 if (!sdi.skip_init) {
73 r = dss_calc_clock_div(1, t->pixel_clock * 1000,
74 &dss_cinfo, &dispc_cinfo);
75 } else {
76 r = dss_get_clock_div(&dss_cinfo);
77 r = dispc_get_clock_div(&dispc_cinfo);
78 }
79
80 if (r)
81 goto err2;
82
83 fck = dss_cinfo.fck;
84 lck_div = dispc_cinfo.lck_div;
85 pck_div = dispc_cinfo.pck_div;
86
87 pck = fck / lck_div / pck_div / 1000;
88
89 if (pck != t->pixel_clock) {
90 DSSWARN("Could not find exact pixel clock. Requested %d kHz, "
91 "got %lu kHz\n",
92 t->pixel_clock, pck);
93
94 t->pixel_clock = pck;
95 }
96
97
98 dispc_set_lcd_timings(t);
99
100 r = dss_set_clock_div(&dss_cinfo);
101 if (r)
102 goto err2;
103
104 r = dispc_set_clock_div(&dispc_cinfo);
105 if (r)
106 goto err2;
107
108 if (!sdi.skip_init) {
109 dss_sdi_init(dssdev->phy.sdi.datapairs);
110 r = dss_sdi_enable();
111 if (r)
112 goto err1;
113 mdelay(2);
114 }
115
Tomi Valkeinena2faee82010-01-08 17:14:53 +0200116 dssdev->manager->enable(dssdev->manager);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300117
118 if (dssdev->driver->enable) {
119 r = dssdev->driver->enable(dssdev);
120 if (r)
121 goto err3;
122 }
123
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300124 sdi.skip_init = 0;
125
126 return 0;
127err3:
Tomi Valkeinena2faee82010-01-08 17:14:53 +0200128 dssdev->manager->disable(dssdev->manager);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300129err2:
130 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
131err1:
132 omap_dss_stop_device(dssdev);
133err0:
134 return r;
135}
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200136EXPORT_SYMBOL(omapdss_sdi_display_enable);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300137
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200138void omapdss_sdi_display_disable(struct omap_dss_device *dssdev)
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300139{
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300140 if (dssdev->driver->disable)
141 dssdev->driver->disable(dssdev);
142
Tomi Valkeinena2faee82010-01-08 17:14:53 +0200143 dssdev->manager->disable(dssdev->manager);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300144
145 dss_sdi_disable();
146
147 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
148
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300149 omap_dss_stop_device(dssdev);
150}
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200151EXPORT_SYMBOL(omapdss_sdi_display_disable);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300152
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300153static void sdi_get_timings(struct omap_dss_device *dssdev,
154 struct omap_video_timings *timings)
155{
156 *timings = dssdev->panel.timings;
157}
158
159int sdi_init_display(struct omap_dss_device *dssdev)
160{
161 DSSDBG("SDI init\n");
162
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300163 dssdev->get_timings = sdi_get_timings;
164
165 return 0;
166}
167
168int sdi_init(bool skip_init)
169{
170 /* we store this for first display enable, then clear it */
171 sdi.skip_init = skip_init;
172
173 /*
174 * Enable clocks already here, otherwise there would be a toggle
175 * of them until sdi_display_enable is called.
176 */
177 if (skip_init)
178 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
179 return 0;
180}
181
182void sdi_exit(void)
183{
184}