blob: b8db7f82646c085fdae54d1f93b589e66976e875 [file] [log] [blame]
Andres Salomonab06aaf2008-04-28 02:14:58 -07001/*
2 * Copyright (C) 2008 Andres Salomon <dilinger@debian.org>
3 *
Andres Salomond1b4cc32008-04-28 02:15:01 -07004 * Geode GX2 header information
Andres Salomonab06aaf2008-04-28 02:14:58 -07005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef _GXFB_H_
12#define _GXFB_H_
13
14#include <linux/io.h>
15
Andres Salomond1b4cc32008-04-28 02:15:01 -070016struct gxfb_par {
17 int enable_crt;
18 void __iomem *dc_regs;
19 void __iomem *vid_regs;
20};
21
22unsigned int gx_frame_buffer_size(void);
23int gx_line_delta(int xres, int bpp);
24void gx_set_mode(struct fb_info *info);
25void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno,
26 unsigned red, unsigned green, unsigned blue);
27
28void gx_set_dclk_frequency(struct fb_info *info);
29void gx_configure_display(struct fb_info *info);
30int gx_blank_display(struct fb_info *info, int blank_mode);
31
32
Andres Salomond2551142008-04-28 02:14:59 -070033/* Display Controller registers (table 6-38 from the data book) */
34enum dc_registers {
35 DC_UNLOCK = 0,
36 DC_GENERAL_CFG,
37 DC_DISPLAY_CFG,
38 DC_RSVD_0,
39
40 DC_FB_ST_OFFSET,
41 DC_CB_ST_OFFSET,
42 DC_CURS_ST_OFFSET,
43 DC_ICON_ST_OFFSET,
44
45 DC_VID_Y_ST_OFFSET,
46 DC_VID_U_ST_OFFSET,
47 DC_VID_V_ST_OFFSET,
48 DC_RSVD_1,
49
50 DC_LINE_SIZE,
51 DC_GFX_PITCH,
52 DC_VID_YUV_PITCH,
53 DC_RSVD_2,
54
55 DC_H_ACTIVE_TIMING,
56 DC_H_BLANK_TIMING,
57 DC_H_SYNC_TIMING,
58 DC_RSVD_3,
59
60 DC_V_ACTIVE_TIMING,
61 DC_V_BLANK_TIMING,
62 DC_V_SYNC_TIMING,
63 DC_RSVD_4,
64
65 DC_CURSOR_X,
66 DC_CURSOR_Y,
67 DC_ICON_X,
68 DC_LINE_CNT,
69
70 DC_PAL_ADDRESS,
71 DC_PAL_DATA,
72 DC_DFIFO_DIAG,
73 DC_CFIFO_DIAG,
74
75 DC_VID_DS_DELTA,
76 DC_GLIU0_MEM_OFFSET,
77 DC_RSVD_5,
78 DC_DV_ACC, /* 0x8c */
79};
80
81#define DC_UNLOCK_LOCK 0x00000000
82#define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
83
84#define DC_GENERAL_CFG_YUVM (1 << 20)
85#define DC_GENERAL_CFG_VDSE (1 << 19)
86#define DC_GENERAL_CFG_DFHPEL_SHIFT 12
87#define DC_GENERAL_CFG_DFHPSL_SHIFT 8
88#define DC_GENERAL_CFG_DECE (1 << 6)
89#define DC_GENERAL_CFG_CMPE (1 << 5)
90#define DC_GENERAL_CFG_VIDE (1 << 3)
91#define DC_GENERAL_CFG_ICNE (1 << 2)
92#define DC_GENERAL_CFG_CURE (1 << 1)
93#define DC_GENERAL_CFG_DFLE (1 << 0)
94
95#define DC_DISPLAY_CFG_A20M (1 << 31)
96#define DC_DISPLAY_CFG_A18M (1 << 30)
97#define DC_DISPLAY_CFG_PALB (1 << 25)
98#define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
99#define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
100#define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
101#define DC_DISPLAY_CFG_VDEN (1 << 4)
102#define DC_DISPLAY_CFG_GDEN (1 << 3)
103#define DC_DISPLAY_CFG_TGEN (1 << 0)
104
105
106/*
107 * Video Processor registers (table 6-54).
108 * There is space for 64 bit values, but we never use more than the
109 * lower 32 bits. The actual register save/restore code only bothers
110 * to restore those 32 bits.
111 */
112enum vp_registers {
113 VP_VCFG = 0,
114 VP_DCFG,
115
116 VP_VX,
117 VP_VY,
118
119 VP_VS,
120 VP_VCK,
121
122 VP_VCM,
123 VP_GAR,
124
125 VP_GDR,
126 VP_RSVD_0,
127
128 VP_MISC,
129 VP_CCS,
130
131 VP_RSVD_1,
132 VP_RSVD_2,
133
134 VP_RSVD_3,
135 VP_VDC,
136
137 VP_VCO,
138 VP_CRC,
139
140 VP_CRC32,
141 VP_VDE,
142
143 VP_CCK,
144 VP_CCM,
145
146 VP_CC1,
147 VP_CC2,
148
149 VP_A1X,
150 VP_A1Y,
151
152 VP_A1C,
153 VP_A1T,
154
155 VP_A2X,
156 VP_A2Y,
157
158 VP_A2C,
159 VP_A2T,
160
161 VP_A3X,
162 VP_A3Y,
163
164 VP_A3C,
165 VP_A3T,
166
167 VP_VRR,
168 VP_AWT,
169
170 VP_VTM, /* 0x130 */
171};
172
173#define VP_VCFG_VID_EN (1 << 0)
174
175#define VP_DCFG_DAC_VREF (1 << 26)
176#define VP_DCFG_GV_GAM (1 << 21)
177#define VP_DCFG_VG_CK (1 << 20)
178#define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
179#define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
180#define VP_DCFG_CRT_VSYNC_POL (1 << 9)
181#define VP_DCFG_CRT_HSYNC_POL (1 << 8)
182#define VP_DCFG_FP_DATA_EN (1 << 7) /* undocumented */
183#define VP_DCFG_FP_PWR_EN (1 << 6) /* undocumented */
184#define VP_DCFG_DAC_BL_EN (1 << 3)
185#define VP_DCFG_VSYNC_EN (1 << 2)
186#define VP_DCFG_HSYNC_EN (1 << 1)
187#define VP_DCFG_CRT_EN (1 << 0)
188
189#define VP_MISC_GAM_EN (1 << 0)
190#define VP_MISC_DACPWRDN (1 << 10)
191#define VP_MISC_APWRDN (1 << 11)
192
193
194/*
195 * Flat Panel registers (table 6-55).
196 * Also 64 bit registers; see above note about 32-bit handling.
197 */
198
199/* we're actually in the VP register space, starting at address 0x400 */
200#define VP_FP_START 0x400
201
202enum fp_registers {
203 FP_PT1 = 0,
204 FP_PT2,
205
206 FP_PM,
207 FP_DFC,
208
209 FP_BLFSR,
210 FP_RLFSR,
211
212 FP_FMI,
213 FP_FMD,
214
215 FP_RSVD_0,
216 FP_DCA,
217
218 FP_DMD,
219 FP_CRC,
220
221 FP_FBB, /* 0x460 */
222};
223
224#define FP_PT1_VSIZE_SHIFT 16 /* undocumented? */
225#define FP_PT1_VSIZE_MASK 0x7FF0000 /* undocumented? */
226
227#define FP_PT2_HSP (1 << 22)
228#define FP_PT2_VSP (1 << 23)
229
230#define FP_PM_P (1 << 24) /* panel power on */
231#define FP_PM_PANEL_PWR_UP (1 << 3) /* r/o */
232#define FP_PM_PANEL_PWR_DOWN (1 << 2) /* r/o */
233#define FP_PM_PANEL_OFF (1 << 1) /* r/o */
234#define FP_PM_PANEL_ON (1 << 0) /* r/o */
235
236#define FP_DFC_NFI ((1 << 4) | (1 << 5) | (1 << 6))
237
238
239/* register access functions */
240
Andres Salomond1b4cc32008-04-28 02:15:01 -0700241static inline uint32_t read_dc(struct gxfb_par *par, int reg)
Andres Salomonab06aaf2008-04-28 02:14:58 -0700242{
Andres Salomond2551142008-04-28 02:14:59 -0700243 return readl(par->dc_regs + 4*reg);
Andres Salomonab06aaf2008-04-28 02:14:58 -0700244}
245
Andres Salomond1b4cc32008-04-28 02:15:01 -0700246static inline void write_dc(struct gxfb_par *par, int reg, uint32_t val)
Andres Salomonab06aaf2008-04-28 02:14:58 -0700247{
Andres Salomond2551142008-04-28 02:14:59 -0700248 writel(val, par->dc_regs + 4*reg);
Andres Salomonab06aaf2008-04-28 02:14:58 -0700249}
250
Andres Salomond2551142008-04-28 02:14:59 -0700251
Andres Salomond1b4cc32008-04-28 02:15:01 -0700252static inline uint32_t read_vp(struct gxfb_par *par, int reg)
Andres Salomonab06aaf2008-04-28 02:14:58 -0700253{
Andres Salomond2551142008-04-28 02:14:59 -0700254 return readl(par->vid_regs + 8*reg);
Andres Salomonab06aaf2008-04-28 02:14:58 -0700255}
256
Andres Salomond1b4cc32008-04-28 02:15:01 -0700257static inline void write_vp(struct gxfb_par *par, int reg, uint32_t val)
Andres Salomonab06aaf2008-04-28 02:14:58 -0700258{
Andres Salomond2551142008-04-28 02:14:59 -0700259 writel(val, par->vid_regs + 8*reg);
Andres Salomonab06aaf2008-04-28 02:14:58 -0700260}
261
Andres Salomond1b4cc32008-04-28 02:15:01 -0700262static inline uint32_t read_fp(struct gxfb_par *par, int reg)
Andres Salomonab06aaf2008-04-28 02:14:58 -0700263{
Andres Salomond2551142008-04-28 02:14:59 -0700264 return readl(par->vid_regs + 8*reg + VP_FP_START);
Andres Salomonab06aaf2008-04-28 02:14:58 -0700265}
266
Andres Salomond1b4cc32008-04-28 02:15:01 -0700267static inline void write_fp(struct gxfb_par *par, int reg, uint32_t val)
Andres Salomonab06aaf2008-04-28 02:14:58 -0700268{
Andres Salomond2551142008-04-28 02:14:59 -0700269 writel(val, par->vid_regs + 8*reg + VP_FP_START);
Andres Salomonab06aaf2008-04-28 02:14:58 -0700270}
271
Andres Salomon9f1277b2008-04-28 02:15:00 -0700272
273/* MSRs are defined in asm/geode.h; their bitfields are here */
274
275#define MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 (1 << 3)
276#define MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 (1 << 2)
277#define MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 (1 << 1)
278
279#define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
280#define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
281#define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
282
283#define MSR_GX_MSR_PADSEL_MASK 0x3FFFFFFF /* undocumented? */
284#define MSR_GX_MSR_PADSEL_TFT 0x1FFFFFFF /* undocumented? */
285
286#define MSR_GX_GLD_MSR_CONFIG_FP (1 << 3)
287
Andres Salomonab06aaf2008-04-28 02:14:58 -0700288#endif