blob: 2627441731b10b22fae734442d399fd18e0995a1 [file] [log] [blame]
Archit Tanejae1ef4d22010-09-15 18:47:29 +05301/*
2 * linux/drivers/video/omap2/dss/dss_features.c
3 *
4 * Copyright (C) 2010 Texas Instruments
5 * Author: Archit Taneja <archit@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#include <linux/kernel.h>
21#include <linux/types.h>
22#include <linux/err.h>
23#include <linux/slab.h>
24
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030025#include <video/omapdss.h>
Archit Tanejae1ef4d22010-09-15 18:47:29 +053026#include <plat/cpu.h>
27
Archit Taneja067a57e2011-03-02 11:57:25 +053028#include "dss.h"
Archit Tanejae1ef4d22010-09-15 18:47:29 +053029#include "dss_features.h"
30
31/* Defines a generic omap register field */
32struct dss_reg_field {
Archit Tanejae1ef4d22010-09-15 18:47:29 +053033 u8 start, end;
34};
35
Taneja, Archit31ef8232011-03-14 23:28:22 -050036struct dss_param_range {
37 int min, max;
38};
39
Archit Tanejae1ef4d22010-09-15 18:47:29 +053040struct omap_dss_features {
41 const struct dss_reg_field *reg_fields;
42 const int num_reg_fields;
43
Archit Tanejac124f232012-01-30 10:52:39 +053044 const enum dss_feat_id *features;
45 const int num_features;
Archit Tanejae1ef4d22010-09-15 18:47:29 +053046
47 const int num_mgrs;
48 const int num_ovls;
49 const enum omap_display_type *supported_displays;
50 const enum omap_color_mode *supported_color_modes;
Tomi Valkeinen67019db2011-08-15 15:18:15 +030051 const enum omap_overlay_caps *overlay_caps;
Taneja, Archit235e7db2011-03-14 23:28:21 -050052 const char * const *clksrc_names;
Taneja, Archit31ef8232011-03-14 23:28:22 -050053 const struct dss_param_range *dss_params;
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +030054
55 const u32 buffer_size_unit;
56 const u32 burst_size_unit;
Archit Tanejae1ef4d22010-09-15 18:47:29 +053057};
58
59/* This struct is assigned to one of the below during initialization */
Tomi Valkeinenea290332011-04-20 10:09:36 +030060static const struct omap_dss_features *omap_current_dss_features;
Archit Tanejae1ef4d22010-09-15 18:47:29 +053061
62static const struct dss_reg_field omap2_dss_reg_fields[] = {
Taneja, Archit49641112011-03-14 23:28:23 -050063 [FEAT_REG_FIRHINC] = { 11, 0 },
64 [FEAT_REG_FIRVINC] = { 27, 16 },
65 [FEAT_REG_FIFOLOWTHRESHOLD] = { 8, 0 },
66 [FEAT_REG_FIFOHIGHTHRESHOLD] = { 24, 16 },
67 [FEAT_REG_FIFOSIZE] = { 8, 0 },
68 [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
69 [FEAT_REG_VERTICALACCU] = { 25, 16 },
70 [FEAT_REG_DISPC_CLK_SWITCH] = { 0, 0 },
71 [FEAT_REG_DSIPLL_REGN] = { 0, 0 },
72 [FEAT_REG_DSIPLL_REGM] = { 0, 0 },
73 [FEAT_REG_DSIPLL_REGM_DISPC] = { 0, 0 },
74 [FEAT_REG_DSIPLL_REGM_DSI] = { 0, 0 },
Archit Tanejae1ef4d22010-09-15 18:47:29 +053075};
76
77static const struct dss_reg_field omap3_dss_reg_fields[] = {
Taneja, Archit49641112011-03-14 23:28:23 -050078 [FEAT_REG_FIRHINC] = { 12, 0 },
79 [FEAT_REG_FIRVINC] = { 28, 16 },
80 [FEAT_REG_FIFOLOWTHRESHOLD] = { 11, 0 },
81 [FEAT_REG_FIFOHIGHTHRESHOLD] = { 27, 16 },
82 [FEAT_REG_FIFOSIZE] = { 10, 0 },
83 [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
84 [FEAT_REG_VERTICALACCU] = { 25, 16 },
85 [FEAT_REG_DISPC_CLK_SWITCH] = { 0, 0 },
86 [FEAT_REG_DSIPLL_REGN] = { 7, 1 },
87 [FEAT_REG_DSIPLL_REGM] = { 18, 8 },
88 [FEAT_REG_DSIPLL_REGM_DISPC] = { 22, 19 },
89 [FEAT_REG_DSIPLL_REGM_DSI] = { 26, 23 },
Archit Taneja87a74842011-03-02 11:19:50 +053090};
91
92static const struct dss_reg_field omap4_dss_reg_fields[] = {
Taneja, Archit49641112011-03-14 23:28:23 -050093 [FEAT_REG_FIRHINC] = { 12, 0 },
94 [FEAT_REG_FIRVINC] = { 28, 16 },
95 [FEAT_REG_FIFOLOWTHRESHOLD] = { 15, 0 },
96 [FEAT_REG_FIFOHIGHTHRESHOLD] = { 31, 16 },
97 [FEAT_REG_FIFOSIZE] = { 15, 0 },
98 [FEAT_REG_HORIZONTALACCU] = { 10, 0 },
99 [FEAT_REG_VERTICALACCU] = { 26, 16 },
100 [FEAT_REG_DISPC_CLK_SWITCH] = { 9, 8 },
101 [FEAT_REG_DSIPLL_REGN] = { 8, 1 },
102 [FEAT_REG_DSIPLL_REGM] = { 20, 9 },
103 [FEAT_REG_DSIPLL_REGM_DISPC] = { 25, 21 },
104 [FEAT_REG_DSIPLL_REGM_DSI] = { 30, 26 },
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530105};
106
107static const enum omap_display_type omap2_dss_supported_displays[] = {
108 /* OMAP_DSS_CHANNEL_LCD */
Tomi Valkeinenf8df01f2011-02-24 14:21:25 +0200109 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530110
111 /* OMAP_DSS_CHANNEL_DIGIT */
112 OMAP_DISPLAY_TYPE_VENC,
113};
114
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200115static const enum omap_display_type omap3430_dss_supported_displays[] = {
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530116 /* OMAP_DSS_CHANNEL_LCD */
117 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
118 OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
119
120 /* OMAP_DSS_CHANNEL_DIGIT */
121 OMAP_DISPLAY_TYPE_VENC,
122};
123
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200124static const enum omap_display_type omap3630_dss_supported_displays[] = {
125 /* OMAP_DSS_CHANNEL_LCD */
126 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
127 OMAP_DISPLAY_TYPE_DSI,
128
129 /* OMAP_DSS_CHANNEL_DIGIT */
130 OMAP_DISPLAY_TYPE_VENC,
131};
132
Archit Tanejad50cd032010-12-02 11:27:08 +0000133static const enum omap_display_type omap4_dss_supported_displays[] = {
134 /* OMAP_DSS_CHANNEL_LCD */
135 OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
136
137 /* OMAP_DSS_CHANNEL_DIGIT */
Mythri P Kb1196012011-03-08 17:15:54 +0530138 OMAP_DISPLAY_TYPE_VENC | OMAP_DISPLAY_TYPE_HDMI,
Archit Tanejad50cd032010-12-02 11:27:08 +0000139
140 /* OMAP_DSS_CHANNEL_LCD2 */
141 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
142 OMAP_DISPLAY_TYPE_DSI,
143};
144
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530145static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
146 /* OMAP_DSS_GFX */
147 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
148 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
149 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
150 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
151
152 /* OMAP_DSS_VIDEO1 */
153 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
154 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
155 OMAP_DSS_COLOR_UYVY,
156
157 /* OMAP_DSS_VIDEO2 */
158 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
159 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
160 OMAP_DSS_COLOR_UYVY,
161};
162
163static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
164 /* OMAP_DSS_GFX */
165 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
166 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
167 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
168 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
169 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
170 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
171
172 /* OMAP_DSS_VIDEO1 */
173 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
174 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
175 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
176
177 /* OMAP_DSS_VIDEO2 */
178 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
179 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
180 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
181 OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
182 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
183};
184
Amber Jainf20e4222011-05-19 19:47:50 +0530185static const enum omap_color_mode omap4_dss_supported_color_modes[] = {
186 /* OMAP_DSS_GFX */
187 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
188 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
189 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
190 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
191 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
192 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32 |
Lajos Molnar08f32672012-02-21 19:36:30 +0530193 OMAP_DSS_COLOR_ARGB16_1555 | OMAP_DSS_COLOR_RGBX16 |
194 OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_XRGB16_1555,
Amber Jainf20e4222011-05-19 19:47:50 +0530195
196 /* OMAP_DSS_VIDEO1 */
197 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
198 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
199 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
200 OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
201 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
202 OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
203 OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
204 OMAP_DSS_COLOR_RGBX32,
205
206 /* OMAP_DSS_VIDEO2 */
207 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
208 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
209 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
210 OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
211 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
212 OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
213 OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
214 OMAP_DSS_COLOR_RGBX32,
Archit Tanejab8c095b2011-09-13 18:20:33 +0530215
216 /* OMAP_DSS_VIDEO3 */
217 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
218 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
219 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
220 OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
221 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
222 OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
223 OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
224 OMAP_DSS_COLOR_RGBX32,
Amber Jainf20e4222011-05-19 19:47:50 +0530225};
226
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300227static const enum omap_overlay_caps omap2_dss_overlay_caps[] = {
228 /* OMAP_DSS_GFX */
229 0,
230
231 /* OMAP_DSS_VIDEO1 */
232 OMAP_DSS_OVL_CAP_SCALE,
233
234 /* OMAP_DSS_VIDEO2 */
235 OMAP_DSS_OVL_CAP_SCALE,
236};
237
238static const enum omap_overlay_caps omap3430_dss_overlay_caps[] = {
239 /* OMAP_DSS_GFX */
Tomi Valkeinenf6dc8152011-08-15 15:18:20 +0300240 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300241
242 /* OMAP_DSS_VIDEO1 */
243 OMAP_DSS_OVL_CAP_SCALE,
244
245 /* OMAP_DSS_VIDEO2 */
Tomi Valkeinenf6dc8152011-08-15 15:18:20 +0300246 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300247};
248
249static const enum omap_overlay_caps omap3630_dss_overlay_caps[] = {
250 /* OMAP_DSS_GFX */
Tomi Valkeinenf6dc8152011-08-15 15:18:20 +0300251 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300252
253 /* OMAP_DSS_VIDEO1 */
254 OMAP_DSS_OVL_CAP_SCALE,
255
256 /* OMAP_DSS_VIDEO2 */
Tomi Valkeinenf6dc8152011-08-15 15:18:20 +0300257 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
258 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300259};
260
261static const enum omap_overlay_caps omap4_dss_overlay_caps[] = {
262 /* OMAP_DSS_GFX */
Archit Taneja11354dd2011-09-26 11:47:29 +0530263 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
264 OMAP_DSS_OVL_CAP_ZORDER,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300265
266 /* OMAP_DSS_VIDEO1 */
Tomi Valkeinenf6dc8152011-08-15 15:18:20 +0300267 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
Archit Taneja11354dd2011-09-26 11:47:29 +0530268 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300269
270 /* OMAP_DSS_VIDEO2 */
Tomi Valkeinenf6dc8152011-08-15 15:18:20 +0300271 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
Archit Taneja11354dd2011-09-26 11:47:29 +0530272 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER,
Archit Tanejab8c095b2011-09-13 18:20:33 +0530273
274 /* OMAP_DSS_VIDEO3 */
275 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
276 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300277};
278
Taneja, Archit235e7db2011-03-14 23:28:21 -0500279static const char * const omap2_dss_clk_source_names[] = {
Archit Taneja89a35e52011-04-12 13:52:23 +0530280 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC] = "N/A",
281 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI] = "N/A",
282 [OMAP_DSS_CLK_SRC_FCK] = "DSS_FCLK1",
Archit Taneja067a57e2011-03-02 11:57:25 +0530283};
284
Taneja, Archit235e7db2011-03-14 23:28:21 -0500285static const char * const omap3_dss_clk_source_names[] = {
Archit Taneja89a35e52011-04-12 13:52:23 +0530286 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC] = "DSI1_PLL_FCLK",
287 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI] = "DSI2_PLL_FCLK",
288 [OMAP_DSS_CLK_SRC_FCK] = "DSS1_ALWON_FCLK",
Archit Taneja067a57e2011-03-02 11:57:25 +0530289};
290
Taneja, Archit235e7db2011-03-14 23:28:21 -0500291static const char * const omap4_dss_clk_source_names[] = {
Archit Taneja89a35e52011-04-12 13:52:23 +0530292 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC] = "PLL1_CLK1",
293 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI] = "PLL1_CLK2",
294 [OMAP_DSS_CLK_SRC_FCK] = "DSS_FCLK",
Archit Taneja5a8b5722011-05-12 17:26:29 +0530295 [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC] = "PLL2_CLK1",
296 [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI] = "PLL2_CLK2",
Taneja, Architea751592011-03-08 05:50:35 -0600297};
298
Taneja, Archit31ef8232011-03-14 23:28:22 -0500299static const struct dss_param_range omap2_dss_param_range[] = {
Taneja, Archit49641112011-03-14 23:28:23 -0500300 [FEAT_PARAM_DSS_FCK] = { 0, 173000000 },
Tomi Valkeinen9eaaf202011-08-29 15:56:04 +0300301 [FEAT_PARAM_DSS_PCD] = { 2, 255 },
Taneja, Archit49641112011-03-14 23:28:23 -0500302 [FEAT_PARAM_DSIPLL_REGN] = { 0, 0 },
303 [FEAT_PARAM_DSIPLL_REGM] = { 0, 0 },
304 [FEAT_PARAM_DSIPLL_REGM_DISPC] = { 0, 0 },
305 [FEAT_PARAM_DSIPLL_REGM_DSI] = { 0, 0 },
306 [FEAT_PARAM_DSIPLL_FINT] = { 0, 0 },
307 [FEAT_PARAM_DSIPLL_LPDIV] = { 0, 0 },
Archit Taneja0373cac2011-09-08 13:25:17 +0530308 [FEAT_PARAM_DOWNSCALE] = { 1, 2 },
Chandrabhanu Mahapatra7282f1b2011-12-19 14:03:56 +0530309 /*
310 * Assuming the line width buffer to be 768 pixels as OMAP2 DISPC
311 * scaler cannot scale a image with width more than 768.
312 */
313 [FEAT_PARAM_LINEWIDTH] = { 1, 768 },
Archit Taneja8f366162012-04-16 12:53:44 +0530314 [FEAT_PARAM_MGR_WIDTH] = { 1, 2048 },
315 [FEAT_PARAM_MGR_HEIGHT] = { 1, 2048 },
Taneja, Archit31ef8232011-03-14 23:28:22 -0500316};
317
318static const struct dss_param_range omap3_dss_param_range[] = {
Taneja, Archit49641112011-03-14 23:28:23 -0500319 [FEAT_PARAM_DSS_FCK] = { 0, 173000000 },
Tomi Valkeinen9eaaf202011-08-29 15:56:04 +0300320 [FEAT_PARAM_DSS_PCD] = { 1, 255 },
Taneja, Archit49641112011-03-14 23:28:23 -0500321 [FEAT_PARAM_DSIPLL_REGN] = { 0, (1 << 7) - 1 },
322 [FEAT_PARAM_DSIPLL_REGM] = { 0, (1 << 11) - 1 },
323 [FEAT_PARAM_DSIPLL_REGM_DISPC] = { 0, (1 << 4) - 1 },
324 [FEAT_PARAM_DSIPLL_REGM_DSI] = { 0, (1 << 4) - 1 },
325 [FEAT_PARAM_DSIPLL_FINT] = { 750000, 2100000 },
326 [FEAT_PARAM_DSIPLL_LPDIV] = { 1, (1 << 13) - 1},
Archit Taneja0373cac2011-09-08 13:25:17 +0530327 [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
Chandrabhanu Mahapatra7282f1b2011-12-19 14:03:56 +0530328 [FEAT_PARAM_LINEWIDTH] = { 1, 1024 },
Archit Taneja8f366162012-04-16 12:53:44 +0530329 [FEAT_PARAM_MGR_WIDTH] = { 1, 2048 },
330 [FEAT_PARAM_MGR_HEIGHT] = { 1, 2048 },
Taneja, Archit31ef8232011-03-14 23:28:22 -0500331};
332
333static const struct dss_param_range omap4_dss_param_range[] = {
Taneja, Archit49641112011-03-14 23:28:23 -0500334 [FEAT_PARAM_DSS_FCK] = { 0, 186000000 },
Tomi Valkeinen9eaaf202011-08-29 15:56:04 +0300335 [FEAT_PARAM_DSS_PCD] = { 1, 255 },
Taneja, Archit49641112011-03-14 23:28:23 -0500336 [FEAT_PARAM_DSIPLL_REGN] = { 0, (1 << 8) - 1 },
337 [FEAT_PARAM_DSIPLL_REGM] = { 0, (1 << 12) - 1 },
338 [FEAT_PARAM_DSIPLL_REGM_DISPC] = { 0, (1 << 5) - 1 },
339 [FEAT_PARAM_DSIPLL_REGM_DSI] = { 0, (1 << 5) - 1 },
340 [FEAT_PARAM_DSIPLL_FINT] = { 500000, 2500000 },
341 [FEAT_PARAM_DSIPLL_LPDIV] = { 0, (1 << 13) - 1 },
Archit Taneja0373cac2011-09-08 13:25:17 +0530342 [FEAT_PARAM_DOWNSCALE] = { 1, 4 },
Chandrabhanu Mahapatra7282f1b2011-12-19 14:03:56 +0530343 [FEAT_PARAM_LINEWIDTH] = { 1, 2048 },
Archit Taneja8f366162012-04-16 12:53:44 +0530344 [FEAT_PARAM_MGR_WIDTH] = { 1, 2048 },
345 [FEAT_PARAM_MGR_HEIGHT] = { 1, 2048 },
Taneja, Archit31ef8232011-03-14 23:28:22 -0500346};
347
Archit Tanejac124f232012-01-30 10:52:39 +0530348static const enum dss_feat_id omap2_dss_feat_list[] = {
349 FEAT_LCDENABLEPOL,
350 FEAT_LCDENABLESIGNAL,
351 FEAT_PCKFREEENABLE,
352 FEAT_FUNCGATED,
353 FEAT_ROWREPEATENABLE,
354 FEAT_RESIZECONF,
355};
356
357static const enum dss_feat_id omap3430_dss_feat_list[] = {
358 FEAT_LCDENABLEPOL,
359 FEAT_LCDENABLESIGNAL,
360 FEAT_PCKFREEENABLE,
361 FEAT_FUNCGATED,
362 FEAT_LINEBUFFERSPLIT,
363 FEAT_ROWREPEATENABLE,
364 FEAT_RESIZECONF,
365 FEAT_DSI_PLL_FREQSEL,
366 FEAT_DSI_REVERSE_TXCLKESC,
367 FEAT_VENC_REQUIRES_TV_DAC_CLK,
368 FEAT_CPR,
369 FEAT_PRELOAD,
370 FEAT_FIR_COEF_V,
371 FEAT_ALPHA_FIXED_ZORDER,
372 FEAT_FIFO_MERGE,
373 FEAT_OMAP3_DSI_FIFO_BUG,
374};
375
376static const enum dss_feat_id omap3630_dss_feat_list[] = {
377 FEAT_LCDENABLEPOL,
378 FEAT_LCDENABLESIGNAL,
379 FEAT_PCKFREEENABLE,
380 FEAT_FUNCGATED,
381 FEAT_LINEBUFFERSPLIT,
382 FEAT_ROWREPEATENABLE,
383 FEAT_RESIZECONF,
384 FEAT_DSI_PLL_PWR_BUG,
385 FEAT_DSI_PLL_FREQSEL,
386 FEAT_CPR,
387 FEAT_PRELOAD,
388 FEAT_FIR_COEF_V,
389 FEAT_ALPHA_FIXED_ZORDER,
390 FEAT_FIFO_MERGE,
391 FEAT_OMAP3_DSI_FIFO_BUG,
392};
393
394static const enum dss_feat_id omap4430_es1_0_dss_feat_list[] = {
395 FEAT_MGR_LCD2,
396 FEAT_CORE_CLK_DIV,
397 FEAT_LCD_CLK_SRC,
398 FEAT_DSI_DCS_CMD_CONFIG_VC,
399 FEAT_DSI_VC_OCP_WIDTH,
400 FEAT_DSI_GNQ,
401 FEAT_HANDLE_UV_SEPARATE,
402 FEAT_ATTR2,
403 FEAT_CPR,
404 FEAT_PRELOAD,
405 FEAT_FIR_COEF_V,
406 FEAT_ALPHA_FREE_ZORDER,
407 FEAT_FIFO_MERGE,
408};
409
Ricardo Neri70988192012-02-16 09:20:57 -0600410static const enum dss_feat_id omap4430_es2_0_1_2_dss_feat_list[] = {
411 FEAT_MGR_LCD2,
412 FEAT_CORE_CLK_DIV,
413 FEAT_LCD_CLK_SRC,
414 FEAT_DSI_DCS_CMD_CONFIG_VC,
415 FEAT_DSI_VC_OCP_WIDTH,
416 FEAT_DSI_GNQ,
417 FEAT_HDMI_CTS_SWMODE,
418 FEAT_HANDLE_UV_SEPARATE,
419 FEAT_ATTR2,
420 FEAT_CPR,
421 FEAT_PRELOAD,
422 FEAT_FIR_COEF_V,
423 FEAT_ALPHA_FREE_ZORDER,
424 FEAT_FIFO_MERGE,
425};
426
Archit Tanejac124f232012-01-30 10:52:39 +0530427static const enum dss_feat_id omap4_dss_feat_list[] = {
428 FEAT_MGR_LCD2,
429 FEAT_CORE_CLK_DIV,
430 FEAT_LCD_CLK_SRC,
431 FEAT_DSI_DCS_CMD_CONFIG_VC,
432 FEAT_DSI_VC_OCP_WIDTH,
433 FEAT_DSI_GNQ,
434 FEAT_HDMI_CTS_SWMODE,
Ricardo Neri70988192012-02-16 09:20:57 -0600435 FEAT_HDMI_AUDIO_USE_MCLK,
Archit Tanejac124f232012-01-30 10:52:39 +0530436 FEAT_HANDLE_UV_SEPARATE,
437 FEAT_ATTR2,
438 FEAT_CPR,
439 FEAT_PRELOAD,
440 FEAT_FIR_COEF_V,
441 FEAT_ALPHA_FREE_ZORDER,
442 FEAT_FIFO_MERGE,
443};
444
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530445/* OMAP2 DSS Features */
Tomi Valkeinenea290332011-04-20 10:09:36 +0300446static const struct omap_dss_features omap2_dss_features = {
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530447 .reg_fields = omap2_dss_reg_fields,
448 .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
449
Archit Tanejac124f232012-01-30 10:52:39 +0530450 .features = omap2_dss_feat_list,
451 .num_features = ARRAY_SIZE(omap2_dss_feat_list),
Archit Tanejad50cd032010-12-02 11:27:08 +0000452
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530453 .num_mgrs = 2,
454 .num_ovls = 3,
455 .supported_displays = omap2_dss_supported_displays,
456 .supported_color_modes = omap2_dss_supported_color_modes,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300457 .overlay_caps = omap2_dss_overlay_caps,
Archit Taneja067a57e2011-03-02 11:57:25 +0530458 .clksrc_names = omap2_dss_clk_source_names,
Taneja, Archit31ef8232011-03-14 23:28:22 -0500459 .dss_params = omap2_dss_param_range,
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +0300460 .buffer_size_unit = 1,
461 .burst_size_unit = 8,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530462};
463
464/* OMAP3 DSS Features */
Tomi Valkeinenea290332011-04-20 10:09:36 +0300465static const struct omap_dss_features omap3430_dss_features = {
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530466 .reg_fields = omap3_dss_reg_fields,
467 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
468
Archit Tanejac124f232012-01-30 10:52:39 +0530469 .features = omap3430_dss_feat_list,
470 .num_features = ARRAY_SIZE(omap3430_dss_feat_list),
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530471
472 .num_mgrs = 2,
473 .num_ovls = 3,
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200474 .supported_displays = omap3430_dss_supported_displays,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530475 .supported_color_modes = omap3_dss_supported_color_modes,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300476 .overlay_caps = omap3430_dss_overlay_caps,
Archit Taneja067a57e2011-03-02 11:57:25 +0530477 .clksrc_names = omap3_dss_clk_source_names,
Taneja, Archit31ef8232011-03-14 23:28:22 -0500478 .dss_params = omap3_dss_param_range,
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +0300479 .buffer_size_unit = 1,
480 .burst_size_unit = 8,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530481};
482
Tomi Valkeinenea290332011-04-20 10:09:36 +0300483static const struct omap_dss_features omap3630_dss_features = {
Samreen8fbde102010-11-04 12:28:41 +0100484 .reg_fields = omap3_dss_reg_fields,
485 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
486
Archit Tanejac124f232012-01-30 10:52:39 +0530487 .features = omap3630_dss_feat_list,
488 .num_features = ARRAY_SIZE(omap3630_dss_feat_list),
Samreen8fbde102010-11-04 12:28:41 +0100489
490 .num_mgrs = 2,
491 .num_ovls = 3,
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200492 .supported_displays = omap3630_dss_supported_displays,
Samreen8fbde102010-11-04 12:28:41 +0100493 .supported_color_modes = omap3_dss_supported_color_modes,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300494 .overlay_caps = omap3630_dss_overlay_caps,
Archit Taneja067a57e2011-03-02 11:57:25 +0530495 .clksrc_names = omap3_dss_clk_source_names,
Taneja, Archit31ef8232011-03-14 23:28:22 -0500496 .dss_params = omap3_dss_param_range,
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +0300497 .buffer_size_unit = 1,
498 .burst_size_unit = 8,
Samreen8fbde102010-11-04 12:28:41 +0100499};
500
Archit Tanejad50cd032010-12-02 11:27:08 +0000501/* OMAP4 DSS Features */
Ricardo Neri6ff70842011-05-18 22:23:33 -0500502/* For OMAP4430 ES 1.0 revision */
503static const struct omap_dss_features omap4430_es1_0_dss_features = {
504 .reg_fields = omap4_dss_reg_fields,
505 .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
506
Archit Tanejac124f232012-01-30 10:52:39 +0530507 .features = omap4430_es1_0_dss_feat_list,
508 .num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
Ricardo Neri6ff70842011-05-18 22:23:33 -0500509
510 .num_mgrs = 3,
Archit Tanejab8c095b2011-09-13 18:20:33 +0530511 .num_ovls = 4,
Ricardo Neri6ff70842011-05-18 22:23:33 -0500512 .supported_displays = omap4_dss_supported_displays,
Amber Jainf20e4222011-05-19 19:47:50 +0530513 .supported_color_modes = omap4_dss_supported_color_modes,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300514 .overlay_caps = omap4_dss_overlay_caps,
Ricardo Neri6ff70842011-05-18 22:23:33 -0500515 .clksrc_names = omap4_dss_clk_source_names,
516 .dss_params = omap4_dss_param_range,
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +0300517 .buffer_size_unit = 16,
518 .burst_size_unit = 16,
Ricardo Neri6ff70842011-05-18 22:23:33 -0500519};
520
Ricardo Neri70988192012-02-16 09:20:57 -0600521/* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
522static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
523 .reg_fields = omap4_dss_reg_fields,
524 .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
525
526 .features = omap4430_es2_0_1_2_dss_feat_list,
527 .num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),
528
529 .num_mgrs = 3,
530 .num_ovls = 4,
531 .supported_displays = omap4_dss_supported_displays,
532 .supported_color_modes = omap4_dss_supported_color_modes,
533 .overlay_caps = omap4_dss_overlay_caps,
534 .clksrc_names = omap4_dss_clk_source_names,
535 .dss_params = omap4_dss_param_range,
536 .buffer_size_unit = 16,
537 .burst_size_unit = 16,
538};
539
Ricardo Neri6ff70842011-05-18 22:23:33 -0500540/* For all the other OMAP4 versions */
Tomi Valkeinenea290332011-04-20 10:09:36 +0300541static const struct omap_dss_features omap4_dss_features = {
Archit Taneja87a74842011-03-02 11:19:50 +0530542 .reg_fields = omap4_dss_reg_fields,
543 .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
Archit Tanejad50cd032010-12-02 11:27:08 +0000544
Archit Tanejac124f232012-01-30 10:52:39 +0530545 .features = omap4_dss_feat_list,
546 .num_features = ARRAY_SIZE(omap4_dss_feat_list),
Archit Tanejad50cd032010-12-02 11:27:08 +0000547
548 .num_mgrs = 3,
Archit Tanejab8c095b2011-09-13 18:20:33 +0530549 .num_ovls = 4,
Archit Tanejad50cd032010-12-02 11:27:08 +0000550 .supported_displays = omap4_dss_supported_displays,
Amber Jainf20e4222011-05-19 19:47:50 +0530551 .supported_color_modes = omap4_dss_supported_color_modes,
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300552 .overlay_caps = omap4_dss_overlay_caps,
Taneja, Architea751592011-03-08 05:50:35 -0600553 .clksrc_names = omap4_dss_clk_source_names,
Taneja, Archit31ef8232011-03-14 23:28:22 -0500554 .dss_params = omap4_dss_param_range,
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +0300555 .buffer_size_unit = 16,
556 .burst_size_unit = 16,
Archit Tanejad50cd032010-12-02 11:27:08 +0000557};
558
Mythri P K60634a22011-09-08 19:06:26 +0530559#if defined(CONFIG_OMAP4_DSS_HDMI)
560/* HDMI OMAP4 Functions*/
561static const struct ti_hdmi_ip_ops omap4_hdmi_functions = {
562
563 .video_configure = ti_hdmi_4xxx_basic_configure,
564 .phy_enable = ti_hdmi_4xxx_phy_enable,
565 .phy_disable = ti_hdmi_4xxx_phy_disable,
566 .read_edid = ti_hdmi_4xxx_read_edid,
Tomi Valkeinen759593f2011-08-29 18:10:20 +0300567 .detect = ti_hdmi_4xxx_detect,
Mythri P K60634a22011-09-08 19:06:26 +0530568 .pll_enable = ti_hdmi_4xxx_pll_enable,
569 .pll_disable = ti_hdmi_4xxx_pll_disable,
570 .video_enable = ti_hdmi_4xxx_wp_video_start,
Ricardo Neric0456be2012-04-27 13:48:45 -0500571 .video_disable = ti_hdmi_4xxx_wp_video_stop,
Mythri P K162874d2011-09-22 13:37:45 +0530572 .dump_wrapper = ti_hdmi_4xxx_wp_dump,
573 .dump_core = ti_hdmi_4xxx_core_dump,
574 .dump_pll = ti_hdmi_4xxx_pll_dump,
575 .dump_phy = ti_hdmi_4xxx_phy_dump,
Ricardo Neri7e151f72012-03-15 14:08:03 -0600576#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
Ricardo Neri80a48592011-11-27 16:09:58 -0600577 .audio_enable = ti_hdmi_4xxx_wp_audio_enable,
Ricardo Neri027bdc82012-04-20 17:17:46 -0500578 .audio_disable = ti_hdmi_4xxx_wp_audio_disable,
Axel Castaneda Gonzalez3df9fb52012-05-03 09:00:21 -0500579 .audio_start = ti_hdmi_4xxx_audio_start,
580 .audio_stop = ti_hdmi_4xxx_audio_stop,
Ricardo Neri6ec355d2012-03-21 12:38:15 -0600581 .audio_config = ti_hdmi_4xxx_audio_config,
Ricardo Neri80a48592011-11-27 16:09:58 -0600582#endif
Mythri P K162874d2011-09-22 13:37:45 +0530583
Mythri P K60634a22011-09-08 19:06:26 +0530584};
585
586void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data)
587{
588 if (cpu_is_omap44xx())
589 ip_data->ops = &omap4_hdmi_functions;
590}
591#endif
592
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530593/* Functions returning values related to a DSS feature */
594int dss_feat_get_num_mgrs(void)
595{
596 return omap_current_dss_features->num_mgrs;
597}
598
599int dss_feat_get_num_ovls(void)
600{
601 return omap_current_dss_features->num_ovls;
602}
603
Taneja, Archit31ef8232011-03-14 23:28:22 -0500604unsigned long dss_feat_get_param_min(enum dss_range_param param)
Archit Taneja819d8072011-03-01 11:54:00 +0530605{
Taneja, Archit31ef8232011-03-14 23:28:22 -0500606 return omap_current_dss_features->dss_params[param].min;
607}
608
609unsigned long dss_feat_get_param_max(enum dss_range_param param)
610{
611 return omap_current_dss_features->dss_params[param].max;
Archit Taneja819d8072011-03-01 11:54:00 +0530612}
613
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530614enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
615{
616 return omap_current_dss_features->supported_displays[channel];
617}
618
619enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
620{
621 return omap_current_dss_features->supported_color_modes[plane];
622}
623
Tomi Valkeinen67019db2011-08-15 15:18:15 +0300624enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane plane)
625{
626 return omap_current_dss_features->overlay_caps[plane];
627}
628
Archit Taneja8dad2ab2010-11-25 17:58:10 +0530629bool dss_feat_color_mode_supported(enum omap_plane plane,
630 enum omap_color_mode color_mode)
631{
632 return omap_current_dss_features->supported_color_modes[plane] &
633 color_mode;
634}
635
Archit Taneja89a35e52011-04-12 13:52:23 +0530636const char *dss_feat_get_clk_source_name(enum omap_dss_clk_source id)
Archit Taneja067a57e2011-03-02 11:57:25 +0530637{
Taneja, Archit235e7db2011-03-14 23:28:21 -0500638 return omap_current_dss_features->clksrc_names[id];
Archit Taneja067a57e2011-03-02 11:57:25 +0530639}
640
Tomi Valkeinen5ed8cf52011-06-21 09:35:36 +0300641u32 dss_feat_get_buffer_size_unit(void)
642{
643 return omap_current_dss_features->buffer_size_unit;
644}
645
646u32 dss_feat_get_burst_size_unit(void)
647{
648 return omap_current_dss_features->burst_size_unit;
649}
650
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530651/* DSS has_feature check */
652bool dss_has_feature(enum dss_feat_id id)
653{
Archit Tanejac124f232012-01-30 10:52:39 +0530654 int i;
655 const enum dss_feat_id *features = omap_current_dss_features->features;
656 const int num_features = omap_current_dss_features->num_features;
657
658 for (i = 0; i < num_features; i++) {
659 if (features[i] == id)
660 return true;
661 }
662
663 return false;
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530664}
665
666void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
667{
668 if (id >= omap_current_dss_features->num_reg_fields)
669 BUG();
670
671 *start = omap_current_dss_features->reg_fields[id].start;
672 *end = omap_current_dss_features->reg_fields[id].end;
673}
674
675void dss_features_init(void)
676{
677 if (cpu_is_omap24xx())
678 omap_current_dss_features = &omap2_dss_features;
Samreen8fbde102010-11-04 12:28:41 +0100679 else if (cpu_is_omap3630())
680 omap_current_dss_features = &omap3630_dss_features;
681 else if (cpu_is_omap34xx())
682 omap_current_dss_features = &omap3430_dss_features;
Ricardo Neri6ff70842011-05-18 22:23:33 -0500683 else if (omap_rev() == OMAP4430_REV_ES1_0)
684 omap_current_dss_features = &omap4430_es1_0_dss_features;
Ricardo Neri70988192012-02-16 09:20:57 -0600685 else if (omap_rev() == OMAP4430_REV_ES2_0 ||
686 omap_rev() == OMAP4430_REV_ES2_1 ||
687 omap_rev() == OMAP4430_REV_ES2_2)
688 omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
Ricardo Neri6ff70842011-05-18 22:23:33 -0500689 else if (cpu_is_omap44xx())
Archit Tanejad50cd032010-12-02 11:27:08 +0000690 omap_current_dss_features = &omap4_dss_features;
Ricardo Neri6ff70842011-05-18 22:23:33 -0500691 else
692 DSSWARN("Unsupported OMAP version");
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530693}