1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2ab06aaf6SAndres Salomon /*
3ab06aaf6SAndres Salomon * Copyright (C) 2008 Andres Salomon <dilinger@debian.org>
4ab06aaf6SAndres Salomon *
5d1b4cc3eSAndres Salomon * Geode GX2 header information
6ab06aaf6SAndres Salomon */
7ab06aaf6SAndres Salomon #ifndef _GXFB_H_
8ab06aaf6SAndres Salomon #define _GXFB_H_
9ab06aaf6SAndres Salomon
10ab06aaf6SAndres Salomon #include <linux/io.h>
11ab06aaf6SAndres Salomon
1246fb6f11SAndres Salomon #define GP_REG_COUNT (0x50 / 4)
1346fb6f11SAndres Salomon #define DC_REG_COUNT (0x90 / 4)
1446fb6f11SAndres Salomon #define VP_REG_COUNT (0x138 / 8)
1546fb6f11SAndres Salomon #define FP_REG_COUNT (0x68 / 8)
1646fb6f11SAndres Salomon
1746fb6f11SAndres Salomon #define DC_PAL_COUNT 0x104
1846fb6f11SAndres Salomon
19d1b4cc3eSAndres Salomon struct gxfb_par {
20d1b4cc3eSAndres Salomon int enable_crt;
21d1b4cc3eSAndres Salomon void __iomem *dc_regs;
22d1b4cc3eSAndres Salomon void __iomem *vid_regs;
2346fb6f11SAndres Salomon void __iomem *gp_regs;
2446fb6f11SAndres Salomon int powered_down;
2546fb6f11SAndres Salomon
2646fb6f11SAndres Salomon /* register state, for power management functionality */
2746fb6f11SAndres Salomon struct {
2846fb6f11SAndres Salomon uint64_t padsel;
2946fb6f11SAndres Salomon uint64_t dotpll;
3046fb6f11SAndres Salomon } msr;
3146fb6f11SAndres Salomon
3246fb6f11SAndres Salomon uint32_t gp[GP_REG_COUNT];
3346fb6f11SAndres Salomon uint32_t dc[DC_REG_COUNT];
3446fb6f11SAndres Salomon uint64_t vp[VP_REG_COUNT];
3546fb6f11SAndres Salomon uint64_t fp[FP_REG_COUNT];
3646fb6f11SAndres Salomon
3746fb6f11SAndres Salomon uint32_t pal[DC_PAL_COUNT];
38d1b4cc3eSAndres Salomon };
39d1b4cc3eSAndres Salomon
40d1b4cc3eSAndres Salomon unsigned int gx_frame_buffer_size(void);
41d1b4cc3eSAndres Salomon int gx_line_delta(int xres, int bpp);
42d1b4cc3eSAndres Salomon void gx_set_mode(struct fb_info *info);
43d1b4cc3eSAndres Salomon void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno,
44d1b4cc3eSAndres Salomon unsigned red, unsigned green, unsigned blue);
45d1b4cc3eSAndres Salomon
46d1b4cc3eSAndres Salomon void gx_set_dclk_frequency(struct fb_info *info);
47d1b4cc3eSAndres Salomon void gx_configure_display(struct fb_info *info);
48d1b4cc3eSAndres Salomon int gx_blank_display(struct fb_info *info, int blank_mode);
49d1b4cc3eSAndres Salomon
5046fb6f11SAndres Salomon int gx_powerdown(struct fb_info *info);
5146fb6f11SAndres Salomon int gx_powerup(struct fb_info *info);
5246fb6f11SAndres Salomon
5346fb6f11SAndres Salomon /* Graphics Processor registers (table 6-23 from the data book) */
5446fb6f11SAndres Salomon enum gp_registers {
5546fb6f11SAndres Salomon GP_DST_OFFSET = 0,
5646fb6f11SAndres Salomon GP_SRC_OFFSET,
5746fb6f11SAndres Salomon GP_STRIDE,
5846fb6f11SAndres Salomon GP_WID_HEIGHT,
5946fb6f11SAndres Salomon
6046fb6f11SAndres Salomon GP_SRC_COLOR_FG,
6146fb6f11SAndres Salomon GP_SRC_COLOR_BG,
6246fb6f11SAndres Salomon GP_PAT_COLOR_0,
6346fb6f11SAndres Salomon GP_PAT_COLOR_1,
6446fb6f11SAndres Salomon
6546fb6f11SAndres Salomon GP_PAT_COLOR_2,
6646fb6f11SAndres Salomon GP_PAT_COLOR_3,
6746fb6f11SAndres Salomon GP_PAT_COLOR_4,
6846fb6f11SAndres Salomon GP_PAT_COLOR_5,
6946fb6f11SAndres Salomon
7046fb6f11SAndres Salomon GP_PAT_DATA_0,
7146fb6f11SAndres Salomon GP_PAT_DATA_1,
7246fb6f11SAndres Salomon GP_RASTER_MODE,
7346fb6f11SAndres Salomon GP_VECTOR_MODE,
7446fb6f11SAndres Salomon
7546fb6f11SAndres Salomon GP_BLT_MODE,
7646fb6f11SAndres Salomon GP_BLT_STATUS,
7746fb6f11SAndres Salomon GP_HST_SRC,
7846fb6f11SAndres Salomon GP_BASE_OFFSET, /* 0x4c */
7946fb6f11SAndres Salomon };
8046fb6f11SAndres Salomon
8146fb6f11SAndres Salomon #define GP_BLT_STATUS_BLT_PENDING (1 << 2)
8246fb6f11SAndres Salomon #define GP_BLT_STATUS_BLT_BUSY (1 << 0)
8346fb6f11SAndres Salomon
84d1b4cc3eSAndres Salomon
85d255114fSAndres Salomon /* Display Controller registers (table 6-38 from the data book) */
86d255114fSAndres Salomon enum dc_registers {
87d255114fSAndres Salomon DC_UNLOCK = 0,
88d255114fSAndres Salomon DC_GENERAL_CFG,
89d255114fSAndres Salomon DC_DISPLAY_CFG,
90d255114fSAndres Salomon DC_RSVD_0,
91d255114fSAndres Salomon
92d255114fSAndres Salomon DC_FB_ST_OFFSET,
93d255114fSAndres Salomon DC_CB_ST_OFFSET,
94d255114fSAndres Salomon DC_CURS_ST_OFFSET,
95d255114fSAndres Salomon DC_ICON_ST_OFFSET,
96d255114fSAndres Salomon
97d255114fSAndres Salomon DC_VID_Y_ST_OFFSET,
98d255114fSAndres Salomon DC_VID_U_ST_OFFSET,
99d255114fSAndres Salomon DC_VID_V_ST_OFFSET,
100d255114fSAndres Salomon DC_RSVD_1,
101d255114fSAndres Salomon
102d255114fSAndres Salomon DC_LINE_SIZE,
103d255114fSAndres Salomon DC_GFX_PITCH,
104d255114fSAndres Salomon DC_VID_YUV_PITCH,
105d255114fSAndres Salomon DC_RSVD_2,
106d255114fSAndres Salomon
107d255114fSAndres Salomon DC_H_ACTIVE_TIMING,
108d255114fSAndres Salomon DC_H_BLANK_TIMING,
109d255114fSAndres Salomon DC_H_SYNC_TIMING,
110d255114fSAndres Salomon DC_RSVD_3,
111d255114fSAndres Salomon
112d255114fSAndres Salomon DC_V_ACTIVE_TIMING,
113d255114fSAndres Salomon DC_V_BLANK_TIMING,
114d255114fSAndres Salomon DC_V_SYNC_TIMING,
115d255114fSAndres Salomon DC_RSVD_4,
116d255114fSAndres Salomon
117d255114fSAndres Salomon DC_CURSOR_X,
118d255114fSAndres Salomon DC_CURSOR_Y,
119d255114fSAndres Salomon DC_ICON_X,
120d255114fSAndres Salomon DC_LINE_CNT,
121d255114fSAndres Salomon
122d255114fSAndres Salomon DC_PAL_ADDRESS,
123d255114fSAndres Salomon DC_PAL_DATA,
124d255114fSAndres Salomon DC_DFIFO_DIAG,
125d255114fSAndres Salomon DC_CFIFO_DIAG,
126d255114fSAndres Salomon
127d255114fSAndres Salomon DC_VID_DS_DELTA,
128d255114fSAndres Salomon DC_GLIU0_MEM_OFFSET,
129d255114fSAndres Salomon DC_RSVD_5,
130d255114fSAndres Salomon DC_DV_ACC, /* 0x8c */
131d255114fSAndres Salomon };
132d255114fSAndres Salomon
133d255114fSAndres Salomon #define DC_UNLOCK_LOCK 0x00000000
134d255114fSAndres Salomon #define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
135d255114fSAndres Salomon
136d255114fSAndres Salomon #define DC_GENERAL_CFG_YUVM (1 << 20)
137d255114fSAndres Salomon #define DC_GENERAL_CFG_VDSE (1 << 19)
138d255114fSAndres Salomon #define DC_GENERAL_CFG_DFHPEL_SHIFT 12
139d255114fSAndres Salomon #define DC_GENERAL_CFG_DFHPSL_SHIFT 8
140d255114fSAndres Salomon #define DC_GENERAL_CFG_DECE (1 << 6)
141d255114fSAndres Salomon #define DC_GENERAL_CFG_CMPE (1 << 5)
142d255114fSAndres Salomon #define DC_GENERAL_CFG_VIDE (1 << 3)
143d255114fSAndres Salomon #define DC_GENERAL_CFG_ICNE (1 << 2)
144d255114fSAndres Salomon #define DC_GENERAL_CFG_CURE (1 << 1)
145d255114fSAndres Salomon #define DC_GENERAL_CFG_DFLE (1 << 0)
146d255114fSAndres Salomon
147d255114fSAndres Salomon #define DC_DISPLAY_CFG_A20M (1 << 31)
148d255114fSAndres Salomon #define DC_DISPLAY_CFG_A18M (1 << 30)
149d255114fSAndres Salomon #define DC_DISPLAY_CFG_PALB (1 << 25)
150d255114fSAndres Salomon #define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
151d255114fSAndres Salomon #define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
152d255114fSAndres Salomon #define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
153d255114fSAndres Salomon #define DC_DISPLAY_CFG_VDEN (1 << 4)
154d255114fSAndres Salomon #define DC_DISPLAY_CFG_GDEN (1 << 3)
155d255114fSAndres Salomon #define DC_DISPLAY_CFG_TGEN (1 << 0)
156d255114fSAndres Salomon
157d255114fSAndres Salomon
158d255114fSAndres Salomon /*
159d255114fSAndres Salomon * Video Processor registers (table 6-54).
160d255114fSAndres Salomon * There is space for 64 bit values, but we never use more than the
161d255114fSAndres Salomon * lower 32 bits. The actual register save/restore code only bothers
162d255114fSAndres Salomon * to restore those 32 bits.
163d255114fSAndres Salomon */
164d255114fSAndres Salomon enum vp_registers {
165d255114fSAndres Salomon VP_VCFG = 0,
166d255114fSAndres Salomon VP_DCFG,
167d255114fSAndres Salomon
168d255114fSAndres Salomon VP_VX,
169d255114fSAndres Salomon VP_VY,
170d255114fSAndres Salomon
171d255114fSAndres Salomon VP_VS,
172d255114fSAndres Salomon VP_VCK,
173d255114fSAndres Salomon
174d255114fSAndres Salomon VP_VCM,
175d255114fSAndres Salomon VP_GAR,
176d255114fSAndres Salomon
177d255114fSAndres Salomon VP_GDR,
178d255114fSAndres Salomon VP_RSVD_0,
179d255114fSAndres Salomon
180d255114fSAndres Salomon VP_MISC,
181d255114fSAndres Salomon VP_CCS,
182d255114fSAndres Salomon
183d255114fSAndres Salomon VP_RSVD_1,
184d255114fSAndres Salomon VP_RSVD_2,
185d255114fSAndres Salomon
186d255114fSAndres Salomon VP_RSVD_3,
187d255114fSAndres Salomon VP_VDC,
188d255114fSAndres Salomon
189d255114fSAndres Salomon VP_VCO,
190d255114fSAndres Salomon VP_CRC,
191d255114fSAndres Salomon
192d255114fSAndres Salomon VP_CRC32,
193d255114fSAndres Salomon VP_VDE,
194d255114fSAndres Salomon
195d255114fSAndres Salomon VP_CCK,
196d255114fSAndres Salomon VP_CCM,
197d255114fSAndres Salomon
198d255114fSAndres Salomon VP_CC1,
199d255114fSAndres Salomon VP_CC2,
200d255114fSAndres Salomon
201d255114fSAndres Salomon VP_A1X,
202d255114fSAndres Salomon VP_A1Y,
203d255114fSAndres Salomon
204d255114fSAndres Salomon VP_A1C,
205d255114fSAndres Salomon VP_A1T,
206d255114fSAndres Salomon
207d255114fSAndres Salomon VP_A2X,
208d255114fSAndres Salomon VP_A2Y,
209d255114fSAndres Salomon
210d255114fSAndres Salomon VP_A2C,
211d255114fSAndres Salomon VP_A2T,
212d255114fSAndres Salomon
213d255114fSAndres Salomon VP_A3X,
214d255114fSAndres Salomon VP_A3Y,
215d255114fSAndres Salomon
216d255114fSAndres Salomon VP_A3C,
217d255114fSAndres Salomon VP_A3T,
218d255114fSAndres Salomon
219d255114fSAndres Salomon VP_VRR,
220d255114fSAndres Salomon VP_AWT,
221d255114fSAndres Salomon
222d255114fSAndres Salomon VP_VTM, /* 0x130 */
223d255114fSAndres Salomon };
224d255114fSAndres Salomon
225d255114fSAndres Salomon #define VP_VCFG_VID_EN (1 << 0)
226d255114fSAndres Salomon
227d255114fSAndres Salomon #define VP_DCFG_DAC_VREF (1 << 26)
228d255114fSAndres Salomon #define VP_DCFG_GV_GAM (1 << 21)
229d255114fSAndres Salomon #define VP_DCFG_VG_CK (1 << 20)
230d255114fSAndres Salomon #define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
231d255114fSAndres Salomon #define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
232d255114fSAndres Salomon #define VP_DCFG_CRT_VSYNC_POL (1 << 9)
233d255114fSAndres Salomon #define VP_DCFG_CRT_HSYNC_POL (1 << 8)
234d255114fSAndres Salomon #define VP_DCFG_FP_DATA_EN (1 << 7) /* undocumented */
235d255114fSAndres Salomon #define VP_DCFG_FP_PWR_EN (1 << 6) /* undocumented */
236d255114fSAndres Salomon #define VP_DCFG_DAC_BL_EN (1 << 3)
237d255114fSAndres Salomon #define VP_DCFG_VSYNC_EN (1 << 2)
238d255114fSAndres Salomon #define VP_DCFG_HSYNC_EN (1 << 1)
239d255114fSAndres Salomon #define VP_DCFG_CRT_EN (1 << 0)
240d255114fSAndres Salomon
241d255114fSAndres Salomon #define VP_MISC_GAM_EN (1 << 0)
242d255114fSAndres Salomon #define VP_MISC_DACPWRDN (1 << 10)
243d255114fSAndres Salomon #define VP_MISC_APWRDN (1 << 11)
244d255114fSAndres Salomon
245d255114fSAndres Salomon
246d255114fSAndres Salomon /*
247d255114fSAndres Salomon * Flat Panel registers (table 6-55).
248d255114fSAndres Salomon * Also 64 bit registers; see above note about 32-bit handling.
249d255114fSAndres Salomon */
250d255114fSAndres Salomon
251d255114fSAndres Salomon /* we're actually in the VP register space, starting at address 0x400 */
252d255114fSAndres Salomon #define VP_FP_START 0x400
253d255114fSAndres Salomon
254d255114fSAndres Salomon enum fp_registers {
255d255114fSAndres Salomon FP_PT1 = 0,
256d255114fSAndres Salomon FP_PT2,
257d255114fSAndres Salomon
258d255114fSAndres Salomon FP_PM,
259d255114fSAndres Salomon FP_DFC,
260d255114fSAndres Salomon
261d255114fSAndres Salomon FP_BLFSR,
262d255114fSAndres Salomon FP_RLFSR,
263d255114fSAndres Salomon
264d255114fSAndres Salomon FP_FMI,
265d255114fSAndres Salomon FP_FMD,
266d255114fSAndres Salomon
267d255114fSAndres Salomon FP_RSVD_0,
268d255114fSAndres Salomon FP_DCA,
269d255114fSAndres Salomon
270d255114fSAndres Salomon FP_DMD,
271d255114fSAndres Salomon FP_CRC,
272d255114fSAndres Salomon
273d255114fSAndres Salomon FP_FBB, /* 0x460 */
274d255114fSAndres Salomon };
275d255114fSAndres Salomon
276d255114fSAndres Salomon #define FP_PT1_VSIZE_SHIFT 16 /* undocumented? */
277d255114fSAndres Salomon #define FP_PT1_VSIZE_MASK 0x7FF0000 /* undocumented? */
278d255114fSAndres Salomon
279d255114fSAndres Salomon #define FP_PT2_HSP (1 << 22)
280d255114fSAndres Salomon #define FP_PT2_VSP (1 << 23)
281d255114fSAndres Salomon
282d255114fSAndres Salomon #define FP_PM_P (1 << 24) /* panel power on */
283d255114fSAndres Salomon #define FP_PM_PANEL_PWR_UP (1 << 3) /* r/o */
284d255114fSAndres Salomon #define FP_PM_PANEL_PWR_DOWN (1 << 2) /* r/o */
285d255114fSAndres Salomon #define FP_PM_PANEL_OFF (1 << 1) /* r/o */
286d255114fSAndres Salomon #define FP_PM_PANEL_ON (1 << 0) /* r/o */
287d255114fSAndres Salomon
288d255114fSAndres Salomon #define FP_DFC_NFI ((1 << 4) | (1 << 5) | (1 << 6))
289d255114fSAndres Salomon
290d255114fSAndres Salomon
291d255114fSAndres Salomon /* register access functions */
292d255114fSAndres Salomon
read_gp(struct gxfb_par * par,int reg)29346fb6f11SAndres Salomon static inline uint32_t read_gp(struct gxfb_par *par, int reg)
29446fb6f11SAndres Salomon {
29546fb6f11SAndres Salomon return readl(par->gp_regs + 4*reg);
29646fb6f11SAndres Salomon }
29746fb6f11SAndres Salomon
write_gp(struct gxfb_par * par,int reg,uint32_t val)29846fb6f11SAndres Salomon static inline void write_gp(struct gxfb_par *par, int reg, uint32_t val)
29946fb6f11SAndres Salomon {
30046fb6f11SAndres Salomon writel(val, par->gp_regs + 4*reg);
30146fb6f11SAndres Salomon }
30246fb6f11SAndres Salomon
read_dc(struct gxfb_par * par,int reg)303d1b4cc3eSAndres Salomon static inline uint32_t read_dc(struct gxfb_par *par, int reg)
304ab06aaf6SAndres Salomon {
305d255114fSAndres Salomon return readl(par->dc_regs + 4*reg);
306ab06aaf6SAndres Salomon }
307ab06aaf6SAndres Salomon
write_dc(struct gxfb_par * par,int reg,uint32_t val)308d1b4cc3eSAndres Salomon static inline void write_dc(struct gxfb_par *par, int reg, uint32_t val)
309ab06aaf6SAndres Salomon {
310d255114fSAndres Salomon writel(val, par->dc_regs + 4*reg);
311ab06aaf6SAndres Salomon }
312ab06aaf6SAndres Salomon
read_vp(struct gxfb_par * par,int reg)313d1b4cc3eSAndres Salomon static inline uint32_t read_vp(struct gxfb_par *par, int reg)
314ab06aaf6SAndres Salomon {
315d255114fSAndres Salomon return readl(par->vid_regs + 8*reg);
316ab06aaf6SAndres Salomon }
317ab06aaf6SAndres Salomon
write_vp(struct gxfb_par * par,int reg,uint32_t val)318d1b4cc3eSAndres Salomon static inline void write_vp(struct gxfb_par *par, int reg, uint32_t val)
319ab06aaf6SAndres Salomon {
320d255114fSAndres Salomon writel(val, par->vid_regs + 8*reg);
321ab06aaf6SAndres Salomon }
322ab06aaf6SAndres Salomon
read_fp(struct gxfb_par * par,int reg)323d1b4cc3eSAndres Salomon static inline uint32_t read_fp(struct gxfb_par *par, int reg)
324ab06aaf6SAndres Salomon {
325d255114fSAndres Salomon return readl(par->vid_regs + 8*reg + VP_FP_START);
326ab06aaf6SAndres Salomon }
327ab06aaf6SAndres Salomon
write_fp(struct gxfb_par * par,int reg,uint32_t val)328d1b4cc3eSAndres Salomon static inline void write_fp(struct gxfb_par *par, int reg, uint32_t val)
329ab06aaf6SAndres Salomon {
330d255114fSAndres Salomon writel(val, par->vid_regs + 8*reg + VP_FP_START);
331ab06aaf6SAndres Salomon }
332ab06aaf6SAndres Salomon
3339f1277bdSAndres Salomon
334f3a57a60SAndres Salomon /* MSRs are defined in linux/cs5535.h; their bitfields are here */
3359f1277bdSAndres Salomon
3369f1277bdSAndres Salomon #define MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 (1 << 3)
3379f1277bdSAndres Salomon #define MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 (1 << 2)
3389f1277bdSAndres Salomon #define MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 (1 << 1)
3399f1277bdSAndres Salomon
3409f1277bdSAndres Salomon #define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
3419f1277bdSAndres Salomon #define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
3429f1277bdSAndres Salomon #define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
3439f1277bdSAndres Salomon
3449f1277bdSAndres Salomon #define MSR_GX_MSR_PADSEL_MASK 0x3FFFFFFF /* undocumented? */
3459f1277bdSAndres Salomon #define MSR_GX_MSR_PADSEL_TFT 0x1FFFFFFF /* undocumented? */
3469f1277bdSAndres Salomon
3479f1277bdSAndres Salomon #define MSR_GX_GLD_MSR_CONFIG_FP (1 << 3)
3489f1277bdSAndres Salomon
349ab06aaf6SAndres Salomon #endif
350