1/*
2 * GX and Turbo GX framebuffer - hardware registers.
3 *
4 * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef CG6_REGS_H
25#define CG6_REGS_H
26
27/* FHC definitions */
28#define CG6_FHC_FBID_SHIFT           24
29#define CG6_FHC_FBID_MASK            255
30#define CG6_FHC_REV_SHIFT            20
31#define CG6_FHC_REV_MASK             15
32#define CG6_FHC_FROP_DISABLE         (1 << 19)
33#define CG6_FHC_ROW_DISABLE          (1 << 18)
34#define CG6_FHC_SRC_DISABLE          (1 << 17)
35#define CG6_FHC_DST_DISABLE          (1 << 16)
36#define CG6_FHC_RESET                (1 << 15)
37#define CG6_FHC_LITTLE_ENDIAN        (1 << 13)
38#define CG6_FHC_RES_MASK             (3 << 11)
39#define CG6_FHC_1024                 (0 << 11)
40#define CG6_FHC_1152                 (1 << 11)
41#define CG6_FHC_1280                 (2 << 11)
42#define CG6_FHC_1600                 (3 << 11)
43#define CG6_FHC_CPU_MASK             (3 << 9)
44#define CG6_FHC_CPU_SPARC            (0 << 9)
45#define CG6_FHC_CPU_68020            (1 << 9)
46#define CG6_FHC_CPU_386              (2 << 9)
47#define CG6_FHC_TEST		     (1 << 8)
48#define CG6_FHC_TEST_X_SHIFT	     4
49#define CG6_FHC_TEST_X_MASK	     15
50#define CG6_FHC_TEST_Y_SHIFT	     0
51#define CG6_FHC_TEST_Y_MASK	     15
52
53/* FBC mode definitions */
54#define CG6_FBC_BLIT_IGNORE		0x00000000
55#define CG6_FBC_BLIT_NOSRC		0x00100000
56#define CG6_FBC_BLIT_SRC		0x00200000
57#define CG6_FBC_BLIT_ILLEGAL		0x00300000
58#define CG6_FBC_BLIT_MASK		0x00300000
59
60#define CG6_FBC_VBLANK			0x00080000
61
62#define CG6_FBC_MODE_IGNORE		0x00000000
63#define CG6_FBC_MODE_COLOR8		0x00020000
64#define CG6_FBC_MODE_COLOR1		0x00040000
65#define CG6_FBC_MODE_HRMONO		0x00060000
66#define CG6_FBC_MODE_MASK		0x00060000
67
68#define CG6_FBC_DRAW_IGNORE		0x00000000
69#define CG6_FBC_DRAW_RENDER		0x00008000
70#define CG6_FBC_DRAW_PICK		0x00010000
71#define CG6_FBC_DRAW_ILLEGAL		0x00018000
72#define CG6_FBC_DRAW_MASK		0x00018000
73
74#define CG6_FBC_BWRITE0_IGNORE		0x00000000
75#define CG6_FBC_BWRITE0_ENABLE		0x00002000
76#define CG6_FBC_BWRITE0_DISABLE		0x00004000
77#define CG6_FBC_BWRITE0_ILLEGAL		0x00006000
78#define CG6_FBC_BWRITE0_MASK		0x00006000
79
80#define CG6_FBC_BWRITE1_IGNORE		0x00000000
81#define CG6_FBC_BWRITE1_ENABLE		0x00000800
82#define CG6_FBC_BWRITE1_DISABLE		0x00001000
83#define CG6_FBC_BWRITE1_ILLEGAL		0x00001800
84#define CG6_FBC_BWRITE1_MASK		0x00001800
85
86#define CG6_FBC_BREAD_IGNORE		0x00000000
87#define CG6_FBC_BREAD_0			0x00000200
88#define CG6_FBC_BREAD_1			0x00000400
89#define CG6_FBC_BREAD_ILLEGAL		0x00000600
90#define CG6_FBC_BREAD_MASK		0x00000600
91
92#define CG6_FBC_BDISP_IGNORE		0x00000000
93#define CG6_FBC_BDISP_0			0x00000080
94#define CG6_FBC_BDISP_1			0x00000100
95#define CG6_FBC_BDISP_ILLEGAL		0x00000180
96#define CG6_FBC_BDISP_MASK		0x00000180
97
98#define CG6_FBC_INDEX_MOD		0x00000040
99#define CG6_FBC_INDEX_MASK		0x00000030
100
101/* THC definitions */
102#define CG6_THC_MISC_REV_SHIFT       16
103#define CG6_THC_MISC_REV_MASK        15
104#define CG6_THC_MISC_RESET           (1 << 12)
105#define CG6_THC_MISC_VIDEO           (1 << 10)
106#define CG6_THC_MISC_SYNC            (1 << 9)
107#define CG6_THC_MISC_VSYNC           (1 << 8)
108#define CG6_THC_MISC_SYNC_ENAB       (1 << 7)
109#define CG6_THC_MISC_CURS_RES        (1 << 6)
110#define CG6_THC_MISC_INT_ENAB        (1 << 5)
111#define CG6_THC_MISC_INT             (1 << 4)
112#define CG6_THC_MISC_INIT            0x9f
113
114/* rasterops */
115#define GX_ROP_CLEAR        0x0
116#define GX_ROP_INVERT       0x1
117#define GX_ROP_NOOP         0x2
118#define GX_ROP_SET          0x3
119
120#define GX_ROP_00_0(rop)    ((rop) << 0)
121#define GX_ROP_00_1(rop)    ((rop) << 2)
122#define GX_ROP_01_0(rop)    ((rop) << 4)
123#define GX_ROP_01_1(rop)    ((rop) << 6)
124#define GX_ROP_10_0(rop)    ((rop) << 8)
125#define GX_ROP_10_1(rop)    ((rop) << 10)
126#define GX_ROP_11_0(rop)    ((rop) << 12)
127#define GX_ROP_11_1(rop)    ((rop) << 14)
128#define GX_PLOT_PLOT        0x00000000
129#define GX_PLOT_UNPLOT      0x00020000
130#define GX_RAST_BOOL        0x00000000
131#define GX_RAST_LINEAR      0x00040000
132#define GX_ATTR_UNSUPP      0x00400000
133#define GX_ATTR_SUPP        0x00800000
134#define GX_POLYG_OVERLAP    0x01000000
135#define GX_POLYG_NONOVERLAP 0x02000000
136#define GX_PATTERN_ZEROS    0x04000000
137#define GX_PATTERN_ONES     0x08000000
138#define GX_PATTERN_MASK     0x0c000000
139#define GX_PIXEL_ZEROS      0x10000000
140#define GX_PIXEL_ONES       0x20000000
141#define GX_PIXEL_MASK       0x30000000
142#define GX_PLANE_ZEROS      0x40000000
143#define GX_PLANE_ONES       0x80000000
144#define GX_PLANE_MASK       0xc0000000
145/* rops for bit blit / copy area
146   with:
147       Plane Mask - use plane mask reg.
148       Pixel Mask - use all ones.
149       Patt  Mask - use all ones.
150*/
151
152#define POLY_O          GX_POLYG_OVERLAP
153#define POLY_N          GX_POLYG_NONOVERLAP
154
155#define ROP_STANDARD    (GX_PLANE_MASK |\
156                        GX_PIXEL_ONES |\
157                        GX_ATTR_SUPP |\
158                        GX_RAST_BOOL |\
159                        GX_PLOT_PLOT)
160
161/* fg = don't care  bg = don't care */
162
163#define ROP_BLIT(O,I)   (ROP_STANDARD | \
164                        GX_PATTERN_ONES |\
165                        GX_ROP_11_1(I) |\
166                        GX_ROP_11_0(O) |\
167                        GX_ROP_10_1(I) |\
168                        GX_ROP_10_0(O) |\
169                        GX_ROP_01_1(I) |\
170                        GX_ROP_01_0(O) |\
171                        GX_ROP_00_1(I) |\
172                        GX_ROP_00_0(O))
173
174/* fg = fgPixel     bg = don't care */
175
176#define ROP_FILL(O,I)   (ROP_STANDARD | \
177                        GX_PATTERN_ONES |\
178                        GX_ROP_11_1(I) |\
179                        GX_ROP_11_0(I) |\
180                        GX_ROP_10_1(I) |\
181                        GX_ROP_10_0(I) | \
182                        GX_ROP_01_1(O) |\
183                        GX_ROP_01_0(O) |\
184                        GX_ROP_00_1(O) |\
185                        GX_ROP_00_0(O))
186
187/* fg = fgPixel     bg = don't care */
188
189#define ROP_STIP(O,I)   (ROP_STANDARD |\
190                        GX_ROP_11_1(I) |\
191                        GX_ROP_11_0(GX_ROP_NOOP) |\
192                        GX_ROP_10_1(I) |\
193                        GX_ROP_10_0(GX_ROP_NOOP) | \
194                        GX_ROP_01_1(O) |\
195                        GX_ROP_01_0(GX_ROP_NOOP) |\
196                        GX_ROP_00_1(O) |\
197                        GX_ROP_00_0(GX_ROP_NOOP))
198
199/* fg = fgPixel     bg = bgPixel */
200
201#define ROP_OSTP(O,I)   (ROP_STANDARD |\
202                        GX_ROP_11_1(I) |\
203                        GX_ROP_11_0(I) |\
204                        GX_ROP_10_1(I) |\
205                        GX_ROP_10_0(O) |\
206                        GX_ROP_01_1(O) |\
207                        GX_ROP_01_0(I) |\
208                        GX_ROP_00_1(O) |\
209                        GX_ROP_00_0(O))
210
211#define GX_ROP_USE_PIXELMASK    0x30000000
212
213#define GX_BLT_INPROGRESS       0x20000000
214
215#define GX_INPROGRESS           0x10000000
216#define GX_FULL                 0x20000000
217
218/* modes */
219#define GX_INDEX(n)         ((n) << 4)
220#define GX_INDEX_ALL        0x00000030
221#define GX_INDEX_MOD        0x00000040
222#define GX_BDISP_0          0x00000080
223#define GX_BDISP_1          0x00000100
224#define GX_BDISP_ALL        0x00000180
225#define GX_BREAD_0          0x00000200
226#define GX_BREAD_1          0x00000400
227#define GX_BREAD_ALL        0x00000600
228#define GX_BWRITE1_ENABLE   0x00000800
229#define GX_BWRITE1_DISABLE  0x00001000
230#define GX_BWRITE1_ALL      0x00001800
231#define GX_BWRITE0_ENABLE   0x00002000
232#define GX_BWRITE0_DISABLE  0x00004000
233#define GX_BWRITE0_ALL      0x00006000
234#define GX_DRAW_RENDER      0x00008000
235#define GX_DRAW_PICK        0x00010000
236#define GX_DRAW_ALL         0x00018000
237#define GX_MODE_COLOR8      0x00020000
238#define GX_MODE_COLOR1      0x00040000
239#define GX_MODE_HRMONO      0x00060000
240#define GX_MODE_ALL         0x00060000
241#define GX_VBLANK           0x00080000
242#define GX_BLIT_NOSRC       0x00100000
243#define GX_BLIT_SRC         0x00200000
244#define GX_BLIT_ALL         0x00300000
245
246typedef struct cg6_tec {
247	volatile unsigned int	tec_matrix;
248	volatile unsigned int	tec_clip;
249	volatile unsigned int	tec_vdc;
250} Cg6Tec, *Cg6TecPtr;
251
252typedef struct cg6_thc {
253        unsigned int		thc_pad0[512];
254	volatile unsigned int	thc_hs;		/* hsync timing */
255	volatile unsigned int	thc_hsdvs;
256	volatile unsigned int	thc_hd;
257	volatile unsigned int	thc_vs;		/* vsync timing */
258	volatile unsigned int	thc_vd;
259	volatile unsigned int	thc_refresh;
260	volatile unsigned int	thc_misc;
261	unsigned int		thc_pad1[56];
262	volatile unsigned int	thc_cursxy;	/* cursor x,y position (16 bits each) */
263	volatile unsigned int	thc_cursmask[32];/* cursor mask bits */
264	volatile unsigned int	thc_cursbits[32];/* what to show where mask enabled */
265} Cg6Thc, *Cg6ThcPtr;
266
267typedef struct cg6_fbc {
268	unsigned int		xxx0[1];
269	volatile unsigned int	mode;
270	volatile unsigned int	clip;
271	unsigned int		xxx1[1];
272	volatile unsigned int	s;
273	volatile unsigned int	draw;
274	volatile unsigned int	blit;
275	volatile unsigned int	font;
276	unsigned int		xxx2[24];
277	volatile unsigned int	x0, y0, z0, color0;
278	volatile unsigned int	x1, y1, z1, color1;
279	volatile unsigned int	x2, y2, z2, color2;
280	volatile unsigned int	x3, y3, z3, color3;
281	volatile unsigned int	offx, offy;
282	unsigned int		xxx3[2];
283	volatile unsigned int	incx, incy;
284	unsigned int		xxx4[2];
285	volatile unsigned int	clipminx, clipminy;
286	unsigned int		xxx5[2];
287	volatile unsigned int	clipmaxx, clipmaxy;
288	unsigned int		xxx6[2];
289	volatile unsigned int	fg;
290	volatile unsigned int	bg;
291	volatile unsigned int	alu;
292	volatile unsigned int	pm;
293	volatile unsigned int	pixelm;
294	unsigned int		xxx7[2];
295	volatile unsigned int	patalign;
296	volatile unsigned int	pattern[8];
297	unsigned int		xxx8[432];
298	volatile unsigned int	apointx, apointy, apointz;
299	unsigned int		xxx9[1];
300	volatile unsigned int	rpointx, rpointy, rpointz;
301	unsigned int		xxx10[5];
302	volatile unsigned int	pointr, pointg, pointb, pointa;
303	volatile unsigned int	alinex, aliney, alinez;
304	unsigned int		xxx11[1];
305	volatile unsigned int	rlinex, rliney, rlinez;
306	unsigned int		xxx12[5];
307	volatile unsigned int	liner, lineg, lineb, linea;
308	volatile unsigned int	atrix, atriy, atriz;
309	unsigned int		xxx13[1];
310	volatile unsigned int	rtrix, rtriy, rtriz;
311	unsigned int		xxx14[5];
312	volatile unsigned int	trir, trig, trib, tria;
313	volatile unsigned int	aquadx, aquady, aquadz;
314	unsigned int		xxx15[1];
315	volatile unsigned int	rquadx, rquady, rquadz;
316	unsigned int		xxx16[5];
317	volatile unsigned int	quadr, quadg, quadb, quada;
318	volatile unsigned int	arectx, arecty, arectz;
319	unsigned int		xxx17[1];
320	volatile unsigned int	rrectx, rrecty, rrectz;
321	unsigned int		xxx18[5];
322	volatile unsigned int	rectr, rectg, rectb, recta;
323} Cg6Fbc, *Cg6FbcPtr;
324
325#endif /* CG6_REGS_H */
326