lxfb: clean up final bits of df_regs
[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 /* MSRS */
31
32 #define GLCP_DOTPLL_RESET    (1 << 0)
33 #define GLCP_DOTPLL_BYPASS   (1 << 15)
34 #define GLCP_DOTPLL_HALFPIX  (1 << 24)
35 #define GLCP_DOTPLL_LOCK     (1 << 25)
36
37 #define DF_CONFIG_OUTPUT_MASK       0x38
38 #define DF_OUTPUT_PANEL             0x08
39 #define DF_OUTPUT_CRT               0x00
40 #define DF_SIMULTANEOUS_CRT_AND_FP  (1 << 15)
41
42 #define DF_DEFAULT_TFT_PAD_SEL_LOW  0xDFFFFFFF
43 #define DF_DEFAULT_TFT_PAD_SEL_HIGH 0x0000003F
44
45 #define DC_SPARE_DISABLE_CFIFO_HGO         0x00000800
46 #define DC_SPARE_VFIFO_ARB_SELECT          0x00000400
47 #define DC_SPARE_WM_LPEN_OVRD              0x00000200
48 #define DC_SPARE_LOAD_WM_LPEN_MASK         0x00000100
49 #define DC_SPARE_DISABLE_INIT_VID_PRI      0x00000080
50 #define DC_SPARE_DISABLE_VFIFO_WM          0x00000040
51 #define DC_SPARE_DISABLE_CWD_CHECK         0x00000020
52 #define DC_SPARE_PIX8_PAN_FIX              0x00000010
53 #define DC_SPARE_FIRST_REQ_MASK            0x00000002
54
55
56 /* Graphics Processor registers (table 6-29 from the data book) */
57 enum gp_registers {
58         GP_DST_OFFSET = 0,
59         GP_SRC_OFFSET,
60         GP_STRIDE,
61         GP_WID_HEIGHT,
62
63         GP_SRC_COLOR_FG,
64         GP_SRC_COLOR_BG,
65         GP_PAT_COLOR_0,
66         GP_PAT_COLOR_1,
67
68         GP_PAT_COLOR_2,
69         GP_PAT_COLOR_3,
70         GP_PAT_COLOR_4,
71         GP_PAT_COLOR_5,
72
73         GP_PAT_DATA_0,
74         GP_PAT_DATA_1,
75         GP_RASTER_MODE,
76         GP_VECTOR_MODE,
77
78         GP_BLT_MODE,
79         GP_BLT_STATUS,
80         GP_HST_SRC,
81         GP_BASE_OFFSET,
82
83         GP_CMD_TOP,
84         GP_CMD_BOT,
85         GP_CMD_READ,
86         GP_CMD_WRITE,
87
88         GP_CH3_OFFSET,
89         GP_CH3_MODE_STR,
90         GP_CH3_WIDHI,
91         GP_CH3_HSRC,
92
93         GP_LUT_INDEX,
94         GP_LUT_DATA,
95         GP_INT_CNTRL, /* 0x78 */
96 };
97
98 #define GP_BLT_STATUS_CE                (1 << 4)        /* cmd buf empty */
99 #define GP_BLT_STATUS_PB                (1 << 0)        /* primative busy */
100
101
102 /* Display Controller registers (table 6-47 from the data book) */
103 enum dc_registers {
104         DC_UNLOCK = 0,
105         DC_GENERAL_CFG,
106         DC_DISPLAY_CFG,
107         DC_ARB_CFG,
108
109         DC_FB_ST_OFFSET,
110         DC_CB_ST_OFFSET,
111         DC_CURS_ST_OFFSET,
112         DC_RSVD_0,
113
114         DC_VID_Y_ST_OFFSET,
115         DC_VID_U_ST_OFFSET,
116         DC_VID_V_ST_OFFSET,
117         DC_DV_TOP,
118
119         DC_LINE_SIZE,
120         DC_GFX_PITCH,
121         DC_VID_YUV_PITCH,
122         DC_RSVD_1,
123
124         DC_H_ACTIVE_TIMING,
125         DC_H_BLANK_TIMING,
126         DC_H_SYNC_TIMING,
127         DC_RSVD_2,
128
129         DC_V_ACTIVE_TIMING,
130         DC_V_BLANK_TIMING,
131         DC_V_SYNC_TIMING,
132         DC_FB_ACTIVE,
133
134         DC_CURSOR_X,
135         DC_CURSOR_Y,
136         DC_RSVD_3,
137         DC_LINE_CNT,
138
139         DC_PAL_ADDRESS,
140         DC_PAL_DATA,
141         DC_DFIFO_DIAG,
142         DC_CFIFO_DIAG,
143
144         DC_VID_DS_DELTA,
145         DC_GLIU0_MEM_OFFSET,
146         DC_DV_CTL,
147         DC_DV_ACCESS,
148
149         DC_GFX_SCALE,
150         DC_IRQ_FILT_CTL,
151         DC_FILT_COEFF1,
152         DC_FILT_COEFF2,
153
154         DC_VBI_EVEN_CTL,
155         DC_VBI_ODD_CTL,
156         DC_VBI_HOR,
157         DC_VBI_LN_ODD,
158
159         DC_VBI_LN_EVEN,
160         DC_VBI_PITCH,
161         DC_CLR_KEY,
162         DC_CLR_KEY_MASK,
163
164         DC_CLR_KEY_X,
165         DC_CLR_KEY_Y,
166         DC_IRQ,
167         DC_RSVD_4,
168
169         DC_RSVD_5,
170         DC_GENLK_CTL,
171         DC_VID_EVEN_Y_ST_OFFSET,
172         DC_VID_EVEN_U_ST_OFFSET,
173
174         DC_VID_EVEN_V_ST_OFFSET,
175         DC_V_ACTIVE_EVEN_TIMING,
176         DC_V_BLANK_EVEN_TIMING,
177         DC_V_SYNC_EVEN_TIMING,  /* 0xec */
178 };
179
180 #define DC_UNLOCK_LOCK                  0x00000000
181 #define DC_UNLOCK_UNLOCK                0x00004758      /* magic value */
182
183 #define DC_GENERAL_CFG_FDTY             (1 << 17)
184 #define DC_GENERAL_CFG_DFHPEL_SHIFT     (12)
185 #define DC_GENERAL_CFG_DFHPSL_SHIFT     (8)
186 #define DC_GENERAL_CFG_VGAE             (1 << 7)
187 #define DC_GENERAL_CFG_DECE             (1 << 6)
188 #define DC_GENERAL_CFG_CMPE             (1 << 5)
189 #define DC_GENERAL_CFG_VIDE             (1 << 3)
190 #define DC_GENERAL_CFG_DFLE             (1 << 0)
191
192 #define DC_DISPLAY_CFG_VISL             (1 << 27)
193 #define DC_DISPLAY_CFG_PALB             (1 << 25)
194 #define DC_DISPLAY_CFG_DCEN             (1 << 24)
195 #define DC_DISPLAY_CFG_DISP_MODE_24BPP  (1 << 9)
196 #define DC_DISPLAY_CFG_DISP_MODE_16BPP  (1 << 8)
197 #define DC_DISPLAY_CFG_DISP_MODE_8BPP   (0)
198 #define DC_DISPLAY_CFG_TRUP             (1 << 6)
199 #define DC_DISPLAY_CFG_VDEN             (1 << 4)
200 #define DC_DISPLAY_CFG_GDEN             (1 << 3)
201 #define DC_DISPLAY_CFG_TGEN             (1 << 0)
202
203 #define DC_DV_TOP_DV_TOP_EN             (1 << 0)
204
205 #define DC_DV_CTL_DV_LINE_SIZE          ((1 << 10) | (1 << 11))
206 #define DC_DV_CTL_DV_LINE_SIZE_1K       (0)
207 #define DC_DV_CTL_DV_LINE_SIZE_2K       (1 << 10)
208 #define DC_DV_CTL_DV_LINE_SIZE_4K       (1 << 11)
209 #define DC_DV_CTL_DV_LINE_SIZE_8K       ((1 << 10) | (1 << 11))
210
211 #define DC_CLR_KEY_CLR_KEY_EN           (1 << 24)
212
213 #define DC_IRQ_VIP_VSYNC_IRQ_STATUS     (1 << 21)       /* undocumented? */
214 #define DC_IRQ_STATUS                   (1 << 20)       /* undocumented? */
215 #define DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK  (1 << 1)
216 #define DC_IRQ_MASK                     (1 << 0)
217
218 #define DC_GENLK_CTL_FLICK_SEL_MASK     (0x0F << 28)
219 #define DC_GENLK_CTL_ALPHA_FLICK_EN     (1 << 25)
220 #define DC_GENLK_CTL_FLICK_EN           (1 << 24)
221 #define DC_GENLK_CTL_GENLK_EN           (1 << 18)
222
223
224 /*
225  * Video Processor registers (table 6-71).
226  * There is space for 64 bit values, but we never use more than the
227  * lower 32 bits.  The actual register save/restore code only bothers
228  * to restore those 32 bits.
229  */
230 enum vp_registers {
231         VP_VCFG = 0,
232         VP_DCFG,
233
234         VP_VX,
235         VP_VY,
236
237         VP_SCL,
238         VP_VCK,
239
240         VP_VCM,
241         VP_PAR,
242
243         VP_PDR,
244         VP_SLR,
245
246         VP_MISC,
247         VP_CCS,
248
249         VP_VYS,
250         VP_VXS,
251
252         VP_RSVD_0,
253         VP_VDC,
254
255         VP_RSVD_1,
256         VP_CRC,
257
258         VP_CRC32,
259         VP_VDE,
260
261         VP_CCK,
262         VP_CCM,
263
264         VP_CC1,
265         VP_CC2,
266
267         VP_A1X,
268         VP_A1Y,
269
270         VP_A1C,
271         VP_A1T,
272
273         VP_A2X,
274         VP_A2Y,
275
276         VP_A2C,
277         VP_A2T,
278
279         VP_A3X,
280         VP_A3Y,
281
282         VP_A3C,
283         VP_A3T,
284
285         VP_VRR,
286         VP_AWT,
287
288         VP_VTM,
289         VP_VYE,
290
291         VP_A1YE,
292         VP_A2YE,
293
294         VP_A3YE,        /* 0x150 */
295 };
296
297 #define VP_VCFG_VID_EN                  (1 << 0)
298
299 #define VP_DCFG_GV_GAM                  (1 << 21)
300 #define VP_DCFG_PWR_SEQ_DELAY           ((1 << 17) | (1 << 18) | (1 << 19))
301 #define VP_DCFG_PWR_SEQ_DELAY_DEFAULT   (1 << 19)       /* undocumented */
302 #define VP_DCFG_CRT_SYNC_SKW            ((1 << 14) | (1 << 15) | (1 << 16))
303 #define VP_DCFG_CRT_SYNC_SKW_DEFAULT    (1 << 16)
304 #define VP_DCFG_CRT_VSYNC_POL           (1 << 9)
305 #define VP_DCFG_CRT_HSYNC_POL           (1 << 8)
306 #define VP_DCFG_DAC_BL_EN               (1 << 3)
307 #define VP_DCFG_VSYNC_EN                (1 << 2)
308 #define VP_DCFG_HSYNC_EN                (1 << 1)
309 #define VP_DCFG_CRT_EN                  (1 << 0)
310
311 #define VP_MISC_APWRDN                  (1 << 11)
312 #define VP_MISC_DACPWRDN                (1 << 10)
313 #define VP_MISC_BYP_BOTH                (1 << 0)
314
315
316 /*
317  * Flat Panel registers (table 6-71).
318  * Also 64 bit registers; see above note about 32-bit handling.
319  */
320
321 /* we're actually in the VP register space, starting at address 0x400 */
322 #define VP_FP_START     0x400
323
324 enum fp_registers {
325         FP_PT1 = 0,
326         FP_PT2,
327
328         FP_PM,
329         FP_DFC,
330
331         FP_RSVD_0,
332         FP_RSVD_1,
333
334         FP_RSVD_2,
335         FP_RSVD_3,
336
337         FP_RSVD_4,
338         FP_DCA,
339
340         FP_DMD,
341         FP_CRC, /* 0x458 */
342 };
343
344 #define FP_PT2_SCRC                     (1 << 27)       /* shfclk free */
345
346 #define FP_PM_P                         (1 << 24)       /* panel power ctl */
347
348 #define FP_DFC_BC                       ((1 << 4) | (1 << 5) | (1 << 6))
349
350
351 /* register access functions */
352
353 static inline uint32_t read_gp(struct lxfb_par *par, int reg)
354 {
355         return readl(par->gp_regs + 4*reg);
356 }
357
358 static inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
359 {
360         writel(val, par->gp_regs + 4*reg);
361 }
362
363 static inline uint32_t read_dc(struct lxfb_par *par, int reg)
364 {
365         return readl(par->dc_regs + 4*reg);
366 }
367
368 static inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
369 {
370         writel(val, par->dc_regs + 4*reg);
371 }
372
373 static inline uint32_t read_vp(struct lxfb_par *par, int reg)
374 {
375         return readl(par->vp_regs + 8*reg);
376 }
377
378 static inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
379 {
380         writel(val, par->vp_regs + 8*reg);
381 }
382
383 static inline uint32_t read_fp(struct lxfb_par *par, int reg)
384 {
385         return readl(par->vp_regs + 8*reg + VP_FP_START);
386 }
387
388 static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
389 {
390         writel(val, par->vp_regs + 8*reg + VP_FP_START);
391 }
392
393 #endif