]> err.no Git - linux-2.6/blob - drivers/video/geode/lxfb.h
lxfb: rearrange/rename MSR bitfields
[linux-2.6] / drivers / video / geode / lxfb.h
1 #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
9 struct lxfb_par {
10         int output;
11
12         void __iomem *gp_regs;
13         void __iomem *dc_regs;
14         void __iomem *vp_regs;
15 };
16
17 static inline unsigned int lx_get_pitch(unsigned int xres, int bpp)
18 {
19         return (((xres * (bpp >> 3)) + 7) & ~7);
20 }
21
22 void lx_set_mode(struct fb_info *);
23 void lx_get_gamma(struct fb_info *, unsigned int *, int);
24 void lx_set_gamma(struct fb_info *, unsigned int *, int);
25 unsigned int lx_framebuffer_size(void);
26 int lx_blank_display(struct fb_info *, int);
27 void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
28                         unsigned int, unsigned int);
29
30
31 /* Graphics Processor registers (table 6-29 from the data book) */
32 enum gp_registers {
33         GP_DST_OFFSET = 0,
34         GP_SRC_OFFSET,
35         GP_STRIDE,
36         GP_WID_HEIGHT,
37
38         GP_SRC_COLOR_FG,
39         GP_SRC_COLOR_BG,
40         GP_PAT_COLOR_0,
41         GP_PAT_COLOR_1,
42
43         GP_PAT_COLOR_2,
44         GP_PAT_COLOR_3,
45         GP_PAT_COLOR_4,
46         GP_PAT_COLOR_5,
47
48         GP_PAT_DATA_0,
49         GP_PAT_DATA_1,
50         GP_RASTER_MODE,
51         GP_VECTOR_MODE,
52
53         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 */
75
76
77 /* Display Controller registers (table 6-47 from the data book) */
78 enum dc_registers {
79         DC_UNLOCK = 0,
80         DC_GENERAL_CFG,
81         DC_DISPLAY_CFG,
82         DC_ARB_CFG,
83
84         DC_FB_ST_OFFSET,
85         DC_CB_ST_OFFSET,
86         DC_CURS_ST_OFFSET,
87         DC_RSVD_0,
88
89         DC_VID_Y_ST_OFFSET,
90         DC_VID_U_ST_OFFSET,
91         DC_VID_V_ST_OFFSET,
92         DC_DV_TOP,
93
94         DC_LINE_SIZE,
95         DC_GFX_PITCH,
96         DC_VID_YUV_PITCH,
97         DC_RSVD_1,
98
99         DC_H_ACTIVE_TIMING,
100         DC_H_BLANK_TIMING,
101         DC_H_SYNC_TIMING,
102         DC_RSVD_2,
103
104         DC_V_ACTIVE_TIMING,
105         DC_V_BLANK_TIMING,
106         DC_V_SYNC_TIMING,
107         DC_FB_ACTIVE,
108
109         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)
197
198
199 /*
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  */
205 enum 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)
289
290
291 /*
292  * Flat Panel registers (table 6-71).
293  * Also 64 bit registers; see above note about 32-bit handling.
294  */
295
296 /* we're actually in the VP register space, starting at address 0x400 */
297 #define VP_FP_START     0x400
298
299 enum fp_registers {
300         FP_PT1 = 0,
301         FP_PT2,
302
303         FP_PM,
304         FP_DFC,
305
306         FP_RSVD_0,
307         FP_RSVD_1,
308
309         FP_RSVD_2,
310         FP_RSVD_3,
311
312         FP_RSVD_4,
313         FP_DCA,
314
315         FP_DMD,
316         FP_CRC, /* 0x458 */
317 };
318
319 #define FP_PT2_SCRC                     (1 << 27)       /* shfclk free */
320
321 #define FP_PM_P                         (1 << 24)       /* panel power ctl */
322
323 #define FP_DFC_BC                       ((1 << 4) | (1 << 5) | (1 << 6))
324
325
326 /* register access functions */
327
328 static inline uint32_t read_gp(struct lxfb_par *par, int reg)
329 {
330         return readl(par->gp_regs + 4*reg);
331 }
332
333 static inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
334 {
335         writel(val, par->gp_regs + 4*reg);
336 }
337
338 static inline uint32_t read_dc(struct lxfb_par *par, int reg)
339 {
340         return readl(par->dc_regs + 4*reg);
341 }
342
343 static inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
344 {
345         writel(val, par->dc_regs + 4*reg);
346 }
347
348 static inline uint32_t read_vp(struct lxfb_par *par, int reg)
349 {
350         return readl(par->vp_regs + 8*reg);
351 }
352
353 static inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
354 {
355         writel(val, par->vp_regs + 8*reg);
356 }
357
358 static inline uint32_t read_fp(struct lxfb_par *par, int reg)
359 {
360         return readl(par->vp_regs + 8*reg + VP_FP_START);
361 }
362
363 static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
364 {
365         writel(val, par->vp_regs + 8*reg + VP_FP_START);
366 }
367
368
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
395 #endif