blob: b3fbc56ccbd7ae5f81b6e29f04526dba56ef6185 [file] [log] [blame]
Jordan Crouse3968cb42007-07-31 00:37:40 -07001#ifndef _LXFB_H_
2#define _LXFB_H_
3
4#include <linux/fb.h>
5
6#define OUTPUT_CRT 0x01
7#define OUTPUT_PANEL 0x02
8
9struct lxfb_par {
10 int output;
Jordan Crouse3968cb42007-07-31 00:37:40 -070011
12 void __iomem *gp_regs;
13 void __iomem *dc_regs;
Andres Salomon31f51fa2008-04-28 02:15:25 -070014 void __iomem *vp_regs;
Jordan Crouse3968cb42007-07-31 00:37:40 -070015};
16
17static inline unsigned int lx_get_pitch(unsigned int xres, int bpp)
18{
19 return (((xres * (bpp >> 3)) + 7) & ~7);
20}
21
22void lx_set_mode(struct fb_info *);
23void lx_get_gamma(struct fb_info *, unsigned int *, int);
24void lx_set_gamma(struct fb_info *, unsigned int *, int);
25unsigned int lx_framebuffer_size(void);
26int lx_blank_display(struct fb_info *, int);
27void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
28 unsigned int, unsigned int);
29
Jordan Crouse3968cb42007-07-31 00:37:40 -070030
Andres Salomonf5c90e82008-04-28 02:15:24 -070031/* Graphics Processor registers (table 6-29 from the data book) */
32enum gp_registers {
33 GP_DST_OFFSET = 0,
34 GP_SRC_OFFSET,
35 GP_STRIDE,
36 GP_WID_HEIGHT,
Jordan Crouse3968cb42007-07-31 00:37:40 -070037
Andres Salomonf5c90e82008-04-28 02:15:24 -070038 GP_SRC_COLOR_FG,
39 GP_SRC_COLOR_BG,
40 GP_PAT_COLOR_0,
41 GP_PAT_COLOR_1,
Jordan Crouse3968cb42007-07-31 00:37:40 -070042
Andres Salomonf5c90e82008-04-28 02:15:24 -070043 GP_PAT_COLOR_2,
44 GP_PAT_COLOR_3,
45 GP_PAT_COLOR_4,
46 GP_PAT_COLOR_5,
Jordan Crouse3968cb42007-07-31 00:37:40 -070047
Andres Salomonf5c90e82008-04-28 02:15:24 -070048 GP_PAT_DATA_0,
49 GP_PAT_DATA_1,
50 GP_RASTER_MODE,
51 GP_VECTOR_MODE,
Jordan Crouse3968cb42007-07-31 00:37:40 -070052
Andres Salomonf5c90e82008-04-28 02:15:24 -070053 GP_BLT_MODE,
54 GP_BLT_STATUS,
55 GP_HST_SRC,
56 GP_BASE_OFFSET,
57
58 GP_CMD_TOP,
59 GP_CMD_BOT,
60 GP_CMD_READ,
61 GP_CMD_WRITE,
62
63 GP_CH3_OFFSET,
64 GP_CH3_MODE_STR,
65 GP_CH3_WIDHI,
66 GP_CH3_HSRC,
67
68 GP_LUT_INDEX,
69 GP_LUT_DATA,
70 GP_INT_CNTRL, /* 0x78 */
71};
72
73#define GP_BLT_STATUS_CE (1 << 4) /* cmd buf empty */
74#define GP_BLT_STATUS_PB (1 << 0) /* primative busy */
Jordan Crouse3968cb42007-07-31 00:37:40 -070075
76
Andres Salomonf5c90e82008-04-28 02:15:24 -070077/* Display Controller registers (table 6-47 from the data book) */
78enum dc_registers {
79 DC_UNLOCK = 0,
80 DC_GENERAL_CFG,
81 DC_DISPLAY_CFG,
82 DC_ARB_CFG,
Jordan Crouse3968cb42007-07-31 00:37:40 -070083
Andres Salomonf5c90e82008-04-28 02:15:24 -070084 DC_FB_ST_OFFSET,
85 DC_CB_ST_OFFSET,
86 DC_CURS_ST_OFFSET,
87 DC_RSVD_0,
Jordan Crouse3968cb42007-07-31 00:37:40 -070088
Andres Salomonf5c90e82008-04-28 02:15:24 -070089 DC_VID_Y_ST_OFFSET,
90 DC_VID_U_ST_OFFSET,
91 DC_VID_V_ST_OFFSET,
92 DC_DV_TOP,
Jordan Crouse3968cb42007-07-31 00:37:40 -070093
Andres Salomonf5c90e82008-04-28 02:15:24 -070094 DC_LINE_SIZE,
95 DC_GFX_PITCH,
96 DC_VID_YUV_PITCH,
97 DC_RSVD_1,
Jordan Crouse3968cb42007-07-31 00:37:40 -070098
Andres Salomonf5c90e82008-04-28 02:15:24 -070099 DC_H_ACTIVE_TIMING,
100 DC_H_BLANK_TIMING,
101 DC_H_SYNC_TIMING,
102 DC_RSVD_2,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700103
Andres Salomonf5c90e82008-04-28 02:15:24 -0700104 DC_V_ACTIVE_TIMING,
105 DC_V_BLANK_TIMING,
106 DC_V_SYNC_TIMING,
107 DC_FB_ACTIVE,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700108
Andres Salomonf5c90e82008-04-28 02:15:24 -0700109 DC_CURSOR_X,
110 DC_CURSOR_Y,
111 DC_RSVD_3,
112 DC_LINE_CNT,
113
114 DC_PAL_ADDRESS,
115 DC_PAL_DATA,
116 DC_DFIFO_DIAG,
117 DC_CFIFO_DIAG,
118
119 DC_VID_DS_DELTA,
120 DC_GLIU0_MEM_OFFSET,
121 DC_DV_CTL,
122 DC_DV_ACCESS,
123
124 DC_GFX_SCALE,
125 DC_IRQ_FILT_CTL,
126 DC_FILT_COEFF1,
127 DC_FILT_COEFF2,
128
129 DC_VBI_EVEN_CTL,
130 DC_VBI_ODD_CTL,
131 DC_VBI_HOR,
132 DC_VBI_LN_ODD,
133
134 DC_VBI_LN_EVEN,
135 DC_VBI_PITCH,
136 DC_CLR_KEY,
137 DC_CLR_KEY_MASK,
138
139 DC_CLR_KEY_X,
140 DC_CLR_KEY_Y,
141 DC_IRQ,
142 DC_RSVD_4,
143
144 DC_RSVD_5,
145 DC_GENLK_CTL,
146 DC_VID_EVEN_Y_ST_OFFSET,
147 DC_VID_EVEN_U_ST_OFFSET,
148
149 DC_VID_EVEN_V_ST_OFFSET,
150 DC_V_ACTIVE_EVEN_TIMING,
151 DC_V_BLANK_EVEN_TIMING,
152 DC_V_SYNC_EVEN_TIMING, /* 0xec */
153};
154
155#define DC_UNLOCK_LOCK 0x00000000
156#define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
157
158#define DC_GENERAL_CFG_FDTY (1 << 17)
159#define DC_GENERAL_CFG_DFHPEL_SHIFT (12)
160#define DC_GENERAL_CFG_DFHPSL_SHIFT (8)
161#define DC_GENERAL_CFG_VGAE (1 << 7)
162#define DC_GENERAL_CFG_DECE (1 << 6)
163#define DC_GENERAL_CFG_CMPE (1 << 5)
164#define DC_GENERAL_CFG_VIDE (1 << 3)
165#define DC_GENERAL_CFG_DFLE (1 << 0)
166
167#define DC_DISPLAY_CFG_VISL (1 << 27)
168#define DC_DISPLAY_CFG_PALB (1 << 25)
169#define DC_DISPLAY_CFG_DCEN (1 << 24)
170#define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
171#define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
172#define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
173#define DC_DISPLAY_CFG_TRUP (1 << 6)
174#define DC_DISPLAY_CFG_VDEN (1 << 4)
175#define DC_DISPLAY_CFG_GDEN (1 << 3)
176#define DC_DISPLAY_CFG_TGEN (1 << 0)
177
178#define DC_DV_TOP_DV_TOP_EN (1 << 0)
179
180#define DC_DV_CTL_DV_LINE_SIZE ((1 << 10) | (1 << 11))
181#define DC_DV_CTL_DV_LINE_SIZE_1K (0)
182#define DC_DV_CTL_DV_LINE_SIZE_2K (1 << 10)
183#define DC_DV_CTL_DV_LINE_SIZE_4K (1 << 11)
184#define DC_DV_CTL_DV_LINE_SIZE_8K ((1 << 10) | (1 << 11))
185
186#define DC_CLR_KEY_CLR_KEY_EN (1 << 24)
187
188#define DC_IRQ_VIP_VSYNC_IRQ_STATUS (1 << 21) /* undocumented? */
189#define DC_IRQ_STATUS (1 << 20) /* undocumented? */
190#define DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK (1 << 1)
191#define DC_IRQ_MASK (1 << 0)
192
193#define DC_GENLK_CTL_FLICK_SEL_MASK (0x0F << 28)
194#define DC_GENLK_CTL_ALPHA_FLICK_EN (1 << 25)
195#define DC_GENLK_CTL_FLICK_EN (1 << 24)
196#define DC_GENLK_CTL_GENLK_EN (1 << 18)
Jordan Crouse3968cb42007-07-31 00:37:40 -0700197
198
Andres Salomonf5c90e82008-04-28 02:15:24 -0700199/*
200 * Video Processor registers (table 6-71).
201 * There is space for 64 bit values, but we never use more than the
202 * lower 32 bits. The actual register save/restore code only bothers
203 * to restore those 32 bits.
204 */
205enum vp_registers {
206 VP_VCFG = 0,
207 VP_DCFG,
208
209 VP_VX,
210 VP_VY,
211
212 VP_SCL,
213 VP_VCK,
214
215 VP_VCM,
216 VP_PAR,
217
218 VP_PDR,
219 VP_SLR,
220
221 VP_MISC,
222 VP_CCS,
223
224 VP_VYS,
225 VP_VXS,
226
227 VP_RSVD_0,
228 VP_VDC,
229
230 VP_RSVD_1,
231 VP_CRC,
232
233 VP_CRC32,
234 VP_VDE,
235
236 VP_CCK,
237 VP_CCM,
238
239 VP_CC1,
240 VP_CC2,
241
242 VP_A1X,
243 VP_A1Y,
244
245 VP_A1C,
246 VP_A1T,
247
248 VP_A2X,
249 VP_A2Y,
250
251 VP_A2C,
252 VP_A2T,
253
254 VP_A3X,
255 VP_A3Y,
256
257 VP_A3C,
258 VP_A3T,
259
260 VP_VRR,
261 VP_AWT,
262
263 VP_VTM,
264 VP_VYE,
265
266 VP_A1YE,
267 VP_A2YE,
268
269 VP_A3YE, /* 0x150 */
270};
271
272#define VP_VCFG_VID_EN (1 << 0)
273
274#define VP_DCFG_GV_GAM (1 << 21)
275#define VP_DCFG_PWR_SEQ_DELAY ((1 << 17) | (1 << 18) | (1 << 19))
276#define VP_DCFG_PWR_SEQ_DELAY_DEFAULT (1 << 19) /* undocumented */
277#define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
278#define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
279#define VP_DCFG_CRT_VSYNC_POL (1 << 9)
280#define VP_DCFG_CRT_HSYNC_POL (1 << 8)
281#define VP_DCFG_DAC_BL_EN (1 << 3)
282#define VP_DCFG_VSYNC_EN (1 << 2)
283#define VP_DCFG_HSYNC_EN (1 << 1)
284#define VP_DCFG_CRT_EN (1 << 0)
285
286#define VP_MISC_APWRDN (1 << 11)
287#define VP_MISC_DACPWRDN (1 << 10)
288#define VP_MISC_BYP_BOTH (1 << 0)
Jordan Crouse3968cb42007-07-31 00:37:40 -0700289
290
Andres Salomonf5c90e82008-04-28 02:15:24 -0700291/*
292 * Flat Panel registers (table 6-71).
293 * Also 64 bit registers; see above note about 32-bit handling.
294 */
Jordan Crouse3968cb42007-07-31 00:37:40 -0700295
Andres Salomonf5c90e82008-04-28 02:15:24 -0700296/* we're actually in the VP register space, starting at address 0x400 */
297#define VP_FP_START 0x400
Jordan Crouse3968cb42007-07-31 00:37:40 -0700298
Andres Salomonf5c90e82008-04-28 02:15:24 -0700299enum fp_registers {
300 FP_PT1 = 0,
301 FP_PT2,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700302
Andres Salomonf5c90e82008-04-28 02:15:24 -0700303 FP_PM,
304 FP_DFC,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700305
Andres Salomonf5c90e82008-04-28 02:15:24 -0700306 FP_RSVD_0,
307 FP_RSVD_1,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700308
Andres Salomonf5c90e82008-04-28 02:15:24 -0700309 FP_RSVD_2,
310 FP_RSVD_3,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700311
Andres Salomonf5c90e82008-04-28 02:15:24 -0700312 FP_RSVD_4,
313 FP_DCA,
Jordan Crouse3968cb42007-07-31 00:37:40 -0700314
Andres Salomonf5c90e82008-04-28 02:15:24 -0700315 FP_DMD,
316 FP_CRC, /* 0x458 */
317};
Jordan Crouse3968cb42007-07-31 00:37:40 -0700318
Andres Salomonf5c90e82008-04-28 02:15:24 -0700319#define FP_PT2_SCRC (1 << 27) /* shfclk free */
Jordan Crouse3968cb42007-07-31 00:37:40 -0700320
Andres Salomonf5c90e82008-04-28 02:15:24 -0700321#define FP_PM_P (1 << 24) /* panel power ctl */
Jordan Crouse3968cb42007-07-31 00:37:40 -0700322
Andres Salomonf5c90e82008-04-28 02:15:24 -0700323#define FP_DFC_BC ((1 << 4) | (1 << 5) | (1 << 6))
Jordan Crouse3968cb42007-07-31 00:37:40 -0700324
Andres Salomon92863612008-04-28 02:15:24 -0700325
326/* register access functions */
327
328static inline uint32_t read_gp(struct lxfb_par *par, int reg)
329{
Andres Salomonf5c90e82008-04-28 02:15:24 -0700330 return readl(par->gp_regs + 4*reg);
Andres Salomon92863612008-04-28 02:15:24 -0700331}
332
333static inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
334{
Andres Salomonf5c90e82008-04-28 02:15:24 -0700335 writel(val, par->gp_regs + 4*reg);
Andres Salomon92863612008-04-28 02:15:24 -0700336}
337
338static inline uint32_t read_dc(struct lxfb_par *par, int reg)
339{
Andres Salomonf5c90e82008-04-28 02:15:24 -0700340 return readl(par->dc_regs + 4*reg);
Andres Salomon92863612008-04-28 02:15:24 -0700341}
342
343static inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
344{
Andres Salomonf5c90e82008-04-28 02:15:24 -0700345 writel(val, par->dc_regs + 4*reg);
Andres Salomon92863612008-04-28 02:15:24 -0700346}
347
348static inline uint32_t read_vp(struct lxfb_par *par, int reg)
349{
Andres Salomon31f51fa2008-04-28 02:15:25 -0700350 return readl(par->vp_regs + 8*reg);
Andres Salomon92863612008-04-28 02:15:24 -0700351}
352
353static inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
354{
Andres Salomon31f51fa2008-04-28 02:15:25 -0700355 writel(val, par->vp_regs + 8*reg);
Andres Salomon92863612008-04-28 02:15:24 -0700356}
357
358static inline uint32_t read_fp(struct lxfb_par *par, int reg)
359{
Andres Salomon31f51fa2008-04-28 02:15:25 -0700360 return readl(par->vp_regs + 8*reg + VP_FP_START);
Andres Salomon92863612008-04-28 02:15:24 -0700361}
362
363static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
364{
Andres Salomon31f51fa2008-04-28 02:15:25 -0700365 writel(val, par->vp_regs + 8*reg + VP_FP_START);
Andres Salomon92863612008-04-28 02:15:24 -0700366}
367
Andres Salomonaec40532008-04-28 02:15:26 -0700368
369/* MSRs are defined in asm/geode.h; their bitfields are here */
370
371#define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
372#define MSR_GLCP_DOTPLL_HALFPIX (1 << 24)
373#define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
374#define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
375
376/* note: this is actually the VP's GLD_MSR_CONFIG */
377#define MSR_LX_GLD_MSR_CONFIG_FMT ((1 << 3) | (1 << 4) | (1 << 5))
378#define MSR_LX_GLD_MSR_CONFIG_FMT_FP (1 << 3)
379#define MSR_LX_GLD_MSR_CONFIG_FMT_CRT (0)
380#define MSR_LX_GLD_MSR_CONFIG_FPC (1 << 15) /* FP *and* CRT */
381
382#define MSR_LX_MSR_PADSEL_TFT_SEL_LOW 0xDFFFFFFF /* ??? */
383#define MSR_LX_MSR_PADSEL_TFT_SEL_HIGH 0x0000003F /* ??? */
384
385#define MSR_LX_SPARE_MSR_DIS_CFIFO_HGO (1 << 11) /* undocumented */
386#define MSR_LX_SPARE_MSR_VFIFO_ARB_SEL (1 << 10) /* undocumented */
387#define MSR_LX_SPARE_MSR_WM_LPEN_OVRD (1 << 9) /* undocumented */
388#define MSR_LX_SPARE_MSR_LOAD_WM_LPEN_M (1 << 8) /* undocumented */
389#define MSR_LX_SPARE_MSR_DIS_INIT_V_PRI (1 << 7) /* undocumented */
390#define MSR_LX_SPARE_MSR_DIS_VIFO_WM (1 << 6)
391#define MSR_LX_SPARE_MSR_DIS_CWD_CHECK (1 << 5) /* undocumented */
392#define MSR_LX_SPARE_MSR_PIX8_PAN_FIX (1 << 4) /* undocumented */
393#define MSR_LX_SPARE_MSR_FIRST_REQ_MASK (1 << 1) /* undocumented */
394
Jordan Crouse3968cb42007-07-31 00:37:40 -0700395#endif