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