1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* Geode LX framebuffer driver
4 * Copyright (C) 2006-2007, Advanced Micro Devices,Inc.
5 * Copyright (c) 2008 Andres Salomon <dilinger@debian.org>
12 #define GP_REG_COUNT (0x7c / 4)
13 #define DC_REG_COUNT (0xf0 / 4)
14 #define VP_REG_COUNT (0x158 / 8)
15 #define FP_REG_COUNT (0x60 / 8)
17 #define DC_PAL_COUNT 0x104
18 #define DC_HFILT_COUNT 0x100
19 #define DC_VFILT_COUNT 0x100
20 #define VP_COEFF_SIZE 0x1000
21 #define VP_PAL_COUNT 0x100
23 #define OUTPUT_CRT 0x01
24 #define OUTPUT_PANEL 0x02
29 void __iomem
*gp_regs
;
30 void __iomem
*dc_regs
;
31 void __iomem
*vp_regs
;
34 /* register state, for power mgmt functionality */
42 uint32_t gp
[GP_REG_COUNT
];
43 uint32_t dc
[DC_REG_COUNT
];
44 uint64_t vp
[VP_REG_COUNT
];
45 uint64_t fp
[FP_REG_COUNT
];
47 uint32_t dc_pal
[DC_PAL_COUNT
];
48 uint32_t vp_pal
[VP_PAL_COUNT
];
49 uint32_t hcoeff
[DC_HFILT_COUNT
* 2];
50 uint32_t vcoeff
[DC_VFILT_COUNT
];
51 uint32_t vp_coeff
[VP_COEFF_SIZE
/ 4];
54 static inline unsigned int lx_get_pitch(unsigned int xres
, int bpp
)
56 return (((xres
* (bpp
>> 3)) + 7) & ~7);
59 void lx_set_mode(struct fb_info
*);
60 unsigned int lx_framebuffer_size(void);
61 int lx_blank_display(struct fb_info
*, int);
62 void lx_set_palette_reg(struct fb_info
*, unsigned int, unsigned int,
63 unsigned int, unsigned int);
65 int lx_powerdown(struct fb_info
*info
);
66 int lx_powerup(struct fb_info
*info
);
68 /* Graphics Processor registers (table 6-29 from the data book) */
107 GP_INT_CNTRL
, /* 0x78 */
110 #define GP_BLT_STATUS_CE (1 << 4) /* cmd buf empty */
111 #define GP_BLT_STATUS_PB (1 << 0) /* primitive busy */
114 /* Display Controller registers (table 6-47 from the data book) */
183 DC_VID_EVEN_Y_ST_OFFSET
,
184 DC_VID_EVEN_U_ST_OFFSET
,
186 DC_VID_EVEN_V_ST_OFFSET
,
187 DC_V_ACTIVE_EVEN_TIMING
,
188 DC_V_BLANK_EVEN_TIMING
,
189 DC_V_SYNC_EVEN_TIMING
, /* 0xec */
192 #define DC_UNLOCK_LOCK 0x00000000
193 #define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
195 #define DC_GENERAL_CFG_FDTY (1 << 17)
196 #define DC_GENERAL_CFG_DFHPEL_SHIFT (12)
197 #define DC_GENERAL_CFG_DFHPSL_SHIFT (8)
198 #define DC_GENERAL_CFG_VGAE (1 << 7)
199 #define DC_GENERAL_CFG_DECE (1 << 6)
200 #define DC_GENERAL_CFG_CMPE (1 << 5)
201 #define DC_GENERAL_CFG_VIDE (1 << 3)
202 #define DC_GENERAL_CFG_DFLE (1 << 0)
204 #define DC_DISPLAY_CFG_VISL (1 << 27)
205 #define DC_DISPLAY_CFG_PALB (1 << 25)
206 #define DC_DISPLAY_CFG_DCEN (1 << 24)
207 #define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
208 #define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
209 #define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
210 #define DC_DISPLAY_CFG_TRUP (1 << 6)
211 #define DC_DISPLAY_CFG_VDEN (1 << 4)
212 #define DC_DISPLAY_CFG_GDEN (1 << 3)
213 #define DC_DISPLAY_CFG_TGEN (1 << 0)
215 #define DC_DV_TOP_DV_TOP_EN (1 << 0)
217 #define DC_DV_CTL_DV_LINE_SIZE ((1 << 10) | (1 << 11))
218 #define DC_DV_CTL_DV_LINE_SIZE_1K (0)
219 #define DC_DV_CTL_DV_LINE_SIZE_2K (1 << 10)
220 #define DC_DV_CTL_DV_LINE_SIZE_4K (1 << 11)
221 #define DC_DV_CTL_DV_LINE_SIZE_8K ((1 << 10) | (1 << 11))
222 #define DC_DV_CTL_CLEAR_DV_RAM (1 << 0)
224 #define DC_IRQ_FILT_CTL_H_FILT_SEL (1 << 10)
226 #define DC_CLR_KEY_CLR_KEY_EN (1 << 24)
228 #define DC_IRQ_VIP_VSYNC_IRQ_STATUS (1 << 21) /* undocumented? */
229 #define DC_IRQ_STATUS (1 << 20) /* undocumented? */
230 #define DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK (1 << 1)
231 #define DC_IRQ_MASK (1 << 0)
233 #define DC_GENLK_CTL_FLICK_SEL_MASK (0x0F << 28)
234 #define DC_GENLK_CTL_ALPHA_FLICK_EN (1 << 25)
235 #define DC_GENLK_CTL_FLICK_EN (1 << 24)
236 #define DC_GENLK_CTL_GENLK_EN (1 << 18)
240 * Video Processor registers (table 6-71).
241 * There is space for 64 bit values, but we never use more than the
242 * lower 32 bits. The actual register save/restore code only bothers
243 * to restore those 32 bits.
311 VP_VCR
= 0x1000, /* 0x1000 - 0x1fff */
314 #define VP_VCFG_VID_EN (1 << 0)
316 #define VP_DCFG_GV_GAM (1 << 21)
317 #define VP_DCFG_PWR_SEQ_DELAY ((1 << 17) | (1 << 18) | (1 << 19))
318 #define VP_DCFG_PWR_SEQ_DELAY_DEFAULT (1 << 19) /* undocumented */
319 #define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
320 #define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
321 #define VP_DCFG_CRT_VSYNC_POL (1 << 9)
322 #define VP_DCFG_CRT_HSYNC_POL (1 << 8)
323 #define VP_DCFG_DAC_BL_EN (1 << 3)
324 #define VP_DCFG_VSYNC_EN (1 << 2)
325 #define VP_DCFG_HSYNC_EN (1 << 1)
326 #define VP_DCFG_CRT_EN (1 << 0)
328 #define VP_MISC_APWRDN (1 << 11)
329 #define VP_MISC_DACPWRDN (1 << 10)
330 #define VP_MISC_BYP_BOTH (1 << 0)
334 * Flat Panel registers (table 6-71).
335 * Also 64 bit registers; see above note about 32-bit handling.
338 /* we're actually in the VP register space, starting at address 0x400 */
339 #define VP_FP_START 0x400
361 #define FP_PT2_HSP (1 << 22)
362 #define FP_PT2_VSP (1 << 23)
363 #define FP_PT2_SCRC (1 << 27) /* shfclk free */
365 #define FP_PM_P (1 << 24) /* panel power ctl */
366 #define FP_PM_PANEL_PWR_UP (1 << 3) /* r/o */
367 #define FP_PM_PANEL_PWR_DOWN (1 << 2) /* r/o */
368 #define FP_PM_PANEL_OFF (1 << 1) /* r/o */
369 #define FP_PM_PANEL_ON (1 << 0) /* r/o */
371 #define FP_DFC_BC ((1 << 4) | (1 << 5) | (1 << 6))
374 /* register access functions */
376 static inline uint32_t read_gp(struct lxfb_par
*par
, int reg
)
378 return readl(par
->gp_regs
+ 4*reg
);
381 static inline void write_gp(struct lxfb_par
*par
, int reg
, uint32_t val
)
383 writel(val
, par
->gp_regs
+ 4*reg
);
386 static inline uint32_t read_dc(struct lxfb_par
*par
, int reg
)
388 return readl(par
->dc_regs
+ 4*reg
);
391 static inline void write_dc(struct lxfb_par
*par
, int reg
, uint32_t val
)
393 writel(val
, par
->dc_regs
+ 4*reg
);
396 static inline uint32_t read_vp(struct lxfb_par
*par
, int reg
)
398 return readl(par
->vp_regs
+ 8*reg
);
401 static inline void write_vp(struct lxfb_par
*par
, int reg
, uint32_t val
)
403 writel(val
, par
->vp_regs
+ 8*reg
);
406 static inline uint32_t read_fp(struct lxfb_par
*par
, int reg
)
408 return readl(par
->vp_regs
+ 8*reg
+ VP_FP_START
);
411 static inline void write_fp(struct lxfb_par
*par
, int reg
, uint32_t val
)
413 writel(val
, par
->vp_regs
+ 8*reg
+ VP_FP_START
);
417 /* MSRs are defined in linux/cs5535.h; their bitfields are here */
419 #define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
420 #define MSR_GLCP_DOTPLL_HALFPIX (1 << 24)
421 #define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
422 #define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
424 /* note: this is actually the VP's GLD_MSR_CONFIG */
425 #define MSR_LX_GLD_MSR_CONFIG_FMT ((1 << 3) | (1 << 4) | (1 << 5))
426 #define MSR_LX_GLD_MSR_CONFIG_FMT_FP (1 << 3)
427 #define MSR_LX_GLD_MSR_CONFIG_FMT_CRT (0)
428 #define MSR_LX_GLD_MSR_CONFIG_FPC (1 << 15) /* FP *and* CRT */
430 #define MSR_LX_MSR_PADSEL_TFT_SEL_LOW 0xDFFFFFFF /* ??? */
431 #define MSR_LX_MSR_PADSEL_TFT_SEL_HIGH 0x0000003F /* ??? */
433 #define MSR_LX_SPARE_MSR_DIS_CFIFO_HGO (1 << 11) /* undocumented */
434 #define MSR_LX_SPARE_MSR_VFIFO_ARB_SEL (1 << 10) /* undocumented */
435 #define MSR_LX_SPARE_MSR_WM_LPEN_OVRD (1 << 9) /* undocumented */
436 #define MSR_LX_SPARE_MSR_LOAD_WM_LPEN_M (1 << 8) /* undocumented */
437 #define MSR_LX_SPARE_MSR_DIS_INIT_V_PRI (1 << 7) /* undocumented */
438 #define MSR_LX_SPARE_MSR_DIS_VIFO_WM (1 << 6)
439 #define MSR_LX_SPARE_MSR_DIS_CWD_CHECK (1 << 5) /* undocumented */
440 #define MSR_LX_SPARE_MSR_PIX8_PAN_FIX (1 << 4) /* undocumented */
441 #define MSR_LX_SPARE_MSR_FIRST_REQ_MASK (1 << 1) /* undocumented */