blob: 6eb6ec62a000202d54ab77bf9550f81e7b218876 [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
25#include <plat/display.h>
26#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 {
33 enum dss_feat_reg_field id;
34 u8 start, end;
35};
36
37struct omap_dss_features {
38 const struct dss_reg_field *reg_fields;
39 const int num_reg_fields;
40
41 const u32 has_feature;
42
43 const int num_mgrs;
44 const int num_ovls;
Archit Taneja819d8072011-03-01 11:54:00 +053045 const unsigned long max_dss_fck;
Archit Tanejae1ef4d22010-09-15 18:47:29 +053046 const enum omap_display_type *supported_displays;
47 const enum omap_color_mode *supported_color_modes;
Archit Taneja067a57e2011-03-02 11:57:25 +053048 const struct dss_clk_source_name *clksrc_names;
Archit Tanejae1ef4d22010-09-15 18:47:29 +053049};
50
51/* This struct is assigned to one of the below during initialization */
52static struct omap_dss_features *omap_current_dss_features;
53
54static const struct dss_reg_field omap2_dss_reg_fields[] = {
55 { FEAT_REG_FIRHINC, 11, 0 },
56 { FEAT_REG_FIRVINC, 27, 16 },
57 { FEAT_REG_FIFOLOWTHRESHOLD, 8, 0 },
58 { FEAT_REG_FIFOHIGHTHRESHOLD, 24, 16 },
59 { FEAT_REG_FIFOSIZE, 8, 0 },
Archit Taneja87a74842011-03-02 11:19:50 +053060 { FEAT_REG_HORIZONTALACCU, 9, 0 },
61 { FEAT_REG_VERTICALACCU, 25, 16 },
Taneja, Architea751592011-03-08 05:50:35 -060062 { FEAT_REG_DISPC_CLK_SWITCH, 0, 0 },
Archit Tanejae1ef4d22010-09-15 18:47:29 +053063};
64
65static const struct dss_reg_field omap3_dss_reg_fields[] = {
66 { FEAT_REG_FIRHINC, 12, 0 },
67 { FEAT_REG_FIRVINC, 28, 16 },
68 { FEAT_REG_FIFOLOWTHRESHOLD, 11, 0 },
69 { FEAT_REG_FIFOHIGHTHRESHOLD, 27, 16 },
70 { FEAT_REG_FIFOSIZE, 10, 0 },
Archit Taneja87a74842011-03-02 11:19:50 +053071 { FEAT_REG_HORIZONTALACCU, 9, 0 },
72 { FEAT_REG_VERTICALACCU, 25, 16 },
Taneja, Architea751592011-03-08 05:50:35 -060073 { FEAT_REG_DISPC_CLK_SWITCH, 0, 0 },
Archit Taneja87a74842011-03-02 11:19:50 +053074};
75
76static const struct dss_reg_field omap4_dss_reg_fields[] = {
77 { FEAT_REG_FIRHINC, 12, 0 },
78 { FEAT_REG_FIRVINC, 28, 16 },
79 { FEAT_REG_FIFOLOWTHRESHOLD, 15, 0 },
80 { FEAT_REG_FIFOHIGHTHRESHOLD, 31, 16 },
81 { FEAT_REG_FIFOSIZE, 15, 0 },
82 { FEAT_REG_HORIZONTALACCU, 10, 0 },
83 { FEAT_REG_VERTICALACCU, 26, 16 },
Taneja, Architea751592011-03-08 05:50:35 -060084 { FEAT_REG_DISPC_CLK_SWITCH, 9, 8 },
Archit Tanejae1ef4d22010-09-15 18:47:29 +053085};
86
87static const enum omap_display_type omap2_dss_supported_displays[] = {
88 /* OMAP_DSS_CHANNEL_LCD */
Tomi Valkeinenf8df01f2011-02-24 14:21:25 +020089 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
Archit Tanejae1ef4d22010-09-15 18:47:29 +053090
91 /* OMAP_DSS_CHANNEL_DIGIT */
92 OMAP_DISPLAY_TYPE_VENC,
93};
94
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +020095static const enum omap_display_type omap3430_dss_supported_displays[] = {
Archit Tanejae1ef4d22010-09-15 18:47:29 +053096 /* OMAP_DSS_CHANNEL_LCD */
97 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
98 OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
99
100 /* OMAP_DSS_CHANNEL_DIGIT */
101 OMAP_DISPLAY_TYPE_VENC,
102};
103
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200104static const enum omap_display_type omap3630_dss_supported_displays[] = {
105 /* OMAP_DSS_CHANNEL_LCD */
106 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
107 OMAP_DISPLAY_TYPE_DSI,
108
109 /* OMAP_DSS_CHANNEL_DIGIT */
110 OMAP_DISPLAY_TYPE_VENC,
111};
112
Archit Tanejad50cd032010-12-02 11:27:08 +0000113static const enum omap_display_type omap4_dss_supported_displays[] = {
114 /* OMAP_DSS_CHANNEL_LCD */
115 OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
116
117 /* OMAP_DSS_CHANNEL_DIGIT */
118 OMAP_DISPLAY_TYPE_VENC,
119
120 /* OMAP_DSS_CHANNEL_LCD2 */
121 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
122 OMAP_DISPLAY_TYPE_DSI,
123};
124
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530125static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
126 /* OMAP_DSS_GFX */
127 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
128 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
129 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
130 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
131
132 /* OMAP_DSS_VIDEO1 */
133 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
134 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
135 OMAP_DSS_COLOR_UYVY,
136
137 /* OMAP_DSS_VIDEO2 */
138 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
139 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
140 OMAP_DSS_COLOR_UYVY,
141};
142
143static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
144 /* OMAP_DSS_GFX */
145 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
146 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
147 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
148 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
149 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
150 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
151
152 /* OMAP_DSS_VIDEO1 */
153 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
154 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
155 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
156
157 /* OMAP_DSS_VIDEO2 */
158 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
159 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
160 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
161 OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
162 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
163};
164
Archit Taneja067a57e2011-03-02 11:57:25 +0530165static const struct dss_clk_source_name omap2_dss_clk_source_names[] = {
166 { DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, "N/A" },
167 { DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, "N/A" },
168 { DSS_CLK_SRC_FCK, "DSS_FCLK1" },
169};
170
171static const struct dss_clk_source_name omap3_dss_clk_source_names[] = {
172 { DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, "DSI1_PLL_FCLK" },
173 { DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, "DSI2_PLL_FCLK" },
174 { DSS_CLK_SRC_FCK, "DSS1_ALWON_FCLK" },
175};
176
Taneja, Architea751592011-03-08 05:50:35 -0600177static const struct dss_clk_source_name omap4_dss_clk_source_names[] = {
178 { DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, "PLL1_CLK1" },
179 { DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, "PLL1_CLK2" },
180 { DSS_CLK_SRC_FCK, "DSS_FCLK" },
181};
182
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530183/* OMAP2 DSS Features */
184static struct omap_dss_features omap2_dss_features = {
185 .reg_fields = omap2_dss_reg_fields,
186 .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
187
Archit Tanejad50cd032010-12-02 11:27:08 +0000188 .has_feature =
189 FEAT_LCDENABLEPOL | FEAT_LCDENABLESIGNAL |
Archit Taneja87a74842011-03-02 11:19:50 +0530190 FEAT_PCKFREEENABLE | FEAT_FUNCGATED |
191 FEAT_ROWREPEATENABLE | FEAT_RESIZECONF,
Archit Tanejad50cd032010-12-02 11:27:08 +0000192
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530193 .num_mgrs = 2,
194 .num_ovls = 3,
Archit Taneja819d8072011-03-01 11:54:00 +0530195 .max_dss_fck = 173000000,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530196 .supported_displays = omap2_dss_supported_displays,
197 .supported_color_modes = omap2_dss_supported_color_modes,
Archit Taneja067a57e2011-03-02 11:57:25 +0530198 .clksrc_names = omap2_dss_clk_source_names,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530199};
200
201/* OMAP3 DSS Features */
Samreen8fbde102010-11-04 12:28:41 +0100202static struct omap_dss_features omap3430_dss_features = {
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530203 .reg_fields = omap3_dss_reg_fields,
204 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
205
Archit Tanejad50cd032010-12-02 11:27:08 +0000206 .has_feature =
207 FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
208 FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
Archit Taneja87a74842011-03-02 11:19:50 +0530209 FEAT_FUNCGATED | FEAT_ROWREPEATENABLE |
210 FEAT_LINEBUFFERSPLIT | FEAT_RESIZECONF,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530211
212 .num_mgrs = 2,
213 .num_ovls = 3,
Archit Taneja819d8072011-03-01 11:54:00 +0530214 .max_dss_fck = 173000000,
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200215 .supported_displays = omap3430_dss_supported_displays,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530216 .supported_color_modes = omap3_dss_supported_color_modes,
Archit Taneja067a57e2011-03-02 11:57:25 +0530217 .clksrc_names = omap3_dss_clk_source_names,
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530218};
219
Samreen8fbde102010-11-04 12:28:41 +0100220static struct omap_dss_features omap3630_dss_features = {
221 .reg_fields = omap3_dss_reg_fields,
222 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
223
Archit Tanejad50cd032010-12-02 11:27:08 +0000224 .has_feature =
225 FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
226 FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
Archit Taneja87a74842011-03-02 11:19:50 +0530227 FEAT_PRE_MULT_ALPHA | FEAT_FUNCGATED |
228 FEAT_ROWREPEATENABLE | FEAT_LINEBUFFERSPLIT |
229 FEAT_RESIZECONF,
Samreen8fbde102010-11-04 12:28:41 +0100230
231 .num_mgrs = 2,
232 .num_ovls = 3,
Archit Taneja819d8072011-03-01 11:54:00 +0530233 .max_dss_fck = 173000000,
Tomi Valkeinen4e777dd2011-02-24 14:20:31 +0200234 .supported_displays = omap3630_dss_supported_displays,
Samreen8fbde102010-11-04 12:28:41 +0100235 .supported_color_modes = omap3_dss_supported_color_modes,
Archit Taneja067a57e2011-03-02 11:57:25 +0530236 .clksrc_names = omap3_dss_clk_source_names,
Samreen8fbde102010-11-04 12:28:41 +0100237};
238
Archit Tanejad50cd032010-12-02 11:27:08 +0000239/* OMAP4 DSS Features */
240static struct omap_dss_features omap4_dss_features = {
Archit Taneja87a74842011-03-02 11:19:50 +0530241 .reg_fields = omap4_dss_reg_fields,
242 .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
Archit Tanejad50cd032010-12-02 11:27:08 +0000243
244 .has_feature =
245 FEAT_GLOBAL_ALPHA | FEAT_PRE_MULT_ALPHA |
Murthy, Raghuveer5c6366e2011-03-03 09:27:58 -0600246 FEAT_MGR_LCD2 | FEAT_GLOBAL_ALPHA_VID1 |
Taneja, Architea751592011-03-08 05:50:35 -0600247 FEAT_CORE_CLK_DIV | FEAT_LCD_CLK_SRC,
Archit Tanejad50cd032010-12-02 11:27:08 +0000248
249 .num_mgrs = 3,
250 .num_ovls = 3,
Archit Taneja819d8072011-03-01 11:54:00 +0530251 .max_dss_fck = 186000000,
Archit Tanejad50cd032010-12-02 11:27:08 +0000252 .supported_displays = omap4_dss_supported_displays,
253 .supported_color_modes = omap3_dss_supported_color_modes,
Taneja, Architea751592011-03-08 05:50:35 -0600254 .clksrc_names = omap4_dss_clk_source_names,
Archit Tanejad50cd032010-12-02 11:27:08 +0000255};
256
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530257/* Functions returning values related to a DSS feature */
258int dss_feat_get_num_mgrs(void)
259{
260 return omap_current_dss_features->num_mgrs;
261}
262
263int dss_feat_get_num_ovls(void)
264{
265 return omap_current_dss_features->num_ovls;
266}
267
Archit Taneja819d8072011-03-01 11:54:00 +0530268/* Max supported DSS FCK in Hz */
269unsigned long dss_feat_get_max_dss_fck(void)
270{
271 return omap_current_dss_features->max_dss_fck;
272}
273
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530274enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
275{
276 return omap_current_dss_features->supported_displays[channel];
277}
278
279enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
280{
281 return omap_current_dss_features->supported_color_modes[plane];
282}
283
Archit Taneja8dad2ab2010-11-25 17:58:10 +0530284bool dss_feat_color_mode_supported(enum omap_plane plane,
285 enum omap_color_mode color_mode)
286{
287 return omap_current_dss_features->supported_color_modes[plane] &
288 color_mode;
289}
290
Archit Taneja067a57e2011-03-02 11:57:25 +0530291const char *dss_feat_get_clk_source_name(enum dss_clk_source id)
292{
293 return omap_current_dss_features->clksrc_names[id].clksrc_name;
294}
295
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530296/* DSS has_feature check */
297bool dss_has_feature(enum dss_feat_id id)
298{
299 return omap_current_dss_features->has_feature & id;
300}
301
302void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
303{
304 if (id >= omap_current_dss_features->num_reg_fields)
305 BUG();
306
307 *start = omap_current_dss_features->reg_fields[id].start;
308 *end = omap_current_dss_features->reg_fields[id].end;
309}
310
311void dss_features_init(void)
312{
313 if (cpu_is_omap24xx())
314 omap_current_dss_features = &omap2_dss_features;
Samreen8fbde102010-11-04 12:28:41 +0100315 else if (cpu_is_omap3630())
316 omap_current_dss_features = &omap3630_dss_features;
317 else if (cpu_is_omap34xx())
318 omap_current_dss_features = &omap3430_dss_features;
Archit Tanejad50cd032010-12-02 11:27:08 +0000319 else
320 omap_current_dss_features = &omap4_dss_features;
Archit Tanejae1ef4d22010-09-15 18:47:29 +0530321}