1 /* $Id: creatorfb.c,v 1.32 2000/07/26 23:02:51 davem Exp $
2 * creatorfb.c: Creator/Creator3D frame buffer driver
3 *
4 * Copyright (C) 1997,1998,1999 Jakub Jelinek (jj@ultra.linux.cz)
5 */
6
7 #include <linux/module.h>
8 #include <linux/sched.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/string.h>
12 #include <linux/mm.h>
13 #include <linux/tty.h>
14 #include <linux/malloc.h>
15 #include <linux/vmalloc.h>
16 #include <linux/delay.h>
17 #include <linux/interrupt.h>
18 #include <linux/fb.h>
19 #include <linux/init.h>
20 #include <linux/selection.h>
21
22 #include <video/sbusfb.h>
23
24 #include <asm/upa.h>
25
26 #define FFB_SFB8R_VOFF 0x00000000
27 #define FFB_SFB8G_VOFF 0x00400000
28 #define FFB_SFB8B_VOFF 0x00800000
29 #define FFB_SFB8X_VOFF 0x00c00000
30 #define FFB_SFB32_VOFF 0x01000000
31 #define FFB_SFB64_VOFF 0x02000000
32 #define FFB_FBC_REGS_VOFF 0x04000000
33 #define FFB_BM_FBC_REGS_VOFF 0x04002000
34 #define FFB_DFB8R_VOFF 0x04004000
35 #define FFB_DFB8G_VOFF 0x04404000
36 #define FFB_DFB8B_VOFF 0x04804000
37 #define FFB_DFB8X_VOFF 0x04c04000
38 #define FFB_DFB24_VOFF 0x05004000
39 #define FFB_DFB32_VOFF 0x06004000
40 #define FFB_DFB422A_VOFF 0x07004000 /* DFB 422 mode write to A */
41 #define FFB_DFB422AD_VOFF 0x07804000 /* DFB 422 mode with line doubling */
42 #define FFB_DFB24B_VOFF 0x08004000 /* DFB 24bit mode write to B */
43 #define FFB_DFB422B_VOFF 0x09004000 /* DFB 422 mode write to B */
44 #define FFB_DFB422BD_VOFF 0x09804000 /* DFB 422 mode with line doubling */
45 #define FFB_SFB16Z_VOFF 0x0a004000 /* 16bit mode Z planes */
46 #define FFB_SFB8Z_VOFF 0x0a404000 /* 8bit mode Z planes */
47 #define FFB_SFB422_VOFF 0x0ac04000 /* SFB 422 mode write to A/B */
48 #define FFB_SFB422D_VOFF 0x0b404000 /* SFB 422 mode with line doubling */
49 #define FFB_FBC_KREGS_VOFF 0x0bc04000
50 #define FFB_DAC_VOFF 0x0bc06000
51 #define FFB_PROM_VOFF 0x0bc08000
52 #define FFB_EXP_VOFF 0x0bc18000
53
54 #define FFB_SFB8R_POFF 0x04000000UL
55 #define FFB_SFB8G_POFF 0x04400000UL
56 #define FFB_SFB8B_POFF 0x04800000UL
57 #define FFB_SFB8X_POFF 0x04c00000UL
58 #define FFB_SFB32_POFF 0x05000000UL
59 #define FFB_SFB64_POFF 0x06000000UL
60 #define FFB_FBC_REGS_POFF 0x00600000UL
61 #define FFB_BM_FBC_REGS_POFF 0x00600000UL
62 #define FFB_DFB8R_POFF 0x01000000UL
63 #define FFB_DFB8G_POFF 0x01400000UL
64 #define FFB_DFB8B_POFF 0x01800000UL
65 #define FFB_DFB8X_POFF 0x01c00000UL
66 #define FFB_DFB24_POFF 0x02000000UL
67 #define FFB_DFB32_POFF 0x03000000UL
68 #define FFB_FBC_KREGS_POFF 0x00610000UL
69 #define FFB_DAC_POFF 0x00400000UL
70 #define FFB_PROM_POFF 0x00000000UL
71 #define FFB_EXP_POFF 0x00200000UL
72
73 /* Draw operations */
74 #define FFB_DRAWOP_DOT 0x00
75 #define FFB_DRAWOP_AADOT 0x01
76 #define FFB_DRAWOP_BRLINECAP 0x02
77 #define FFB_DRAWOP_BRLINEOPEN 0x03
78 #define FFB_DRAWOP_DDLINE 0x04
79 #define FFB_DRAWOP_AALINE 0x05
80 #define FFB_DRAWOP_TRIANGLE 0x06
81 #define FFB_DRAWOP_POLYGON 0x07
82 #define FFB_DRAWOP_RECTANGLE 0x08
83 #define FFB_DRAWOP_FASTFILL 0x09
84 #define FFB_DRAWOP_BCOPY 0x0a
85 #define FFB_DRAWOP_VSCROLL 0x0b
86
87 /* Pixel processor control */
88 /* Force WID */
89 #define FFB_PPC_FW_DISABLE 0x800000
90 #define FFB_PPC_FW_ENABLE 0xc00000
91 /* Auxiliary clip */
92 #define FFB_PPC_ACE_DISABLE 0x040000
93 #define FFB_PPC_ACE_AUX_SUB 0x080000
94 #define FFB_PPC_ACE_AUX_ADD 0x0c0000
95 /* Depth cue */
96 #define FFB_PPC_DCE_DISABLE 0x020000
97 #define FFB_PPC_DCE_ENABLE 0x030000
98 /* Alpha blend */
99 #define FFB_PPC_ABE_DISABLE 0x008000
100 #define FFB_PPC_ABE_ENABLE 0x00c000
101 /* View clip */
102 #define FFB_PPC_VCE_DISABLE 0x001000
103 #define FFB_PPC_VCE_2D 0x002000
104 #define FFB_PPC_VCE_3D 0x003000
105 /* Area pattern */
106 #define FFB_PPC_APE_DISABLE 0x000800
107 #define FFB_PPC_APE_ENABLE 0x000c00
108 /* Transparent background */
109 #define FFB_PPC_TBE_OPAQUE 0x000200
110 #define FFB_PPC_TBE_TRANSPARENT 0x000300
111 /* Z source */
112 #define FFB_PPC_ZS_VAR 0x000080
113 #define FFB_PPC_ZS_CONST 0x0000c0
114 /* Y source */
115 #define FFB_PPC_YS_VAR 0x000020
116 #define FFB_PPC_YS_CONST 0x000030
117 /* X source */
118 #define FFB_PPC_XS_WID 0x000004
119 #define FFB_PPC_XS_VAR 0x000008
120 #define FFB_PPC_XS_CONST 0x00000c
121 /* Color (BGR) source */
122 #define FFB_PPC_CS_VAR 0x000002
123 #define FFB_PPC_CS_CONST 0x000003
124
125 #define FFB_ROP_NEW 0x83
126
127 #define FFB_UCSR_FIFO_MASK 0x00000fff
128 #define FFB_UCSR_FB_BUSY 0x01000000
129 #define FFB_UCSR_RP_BUSY 0x02000000
130 #define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY)
131 #define FFB_UCSR_READ_ERR 0x40000000
132 #define FFB_UCSR_FIFO_OVFL 0x80000000
133 #define FFB_UCSR_ALL_ERRORS (FFB_UCSR_READ_ERR|FFB_UCSR_FIFO_OVFL)
134
135 struct ffb_fbc {
136 /* Next vertex registers */
137 u32 xxx1[3];
138 volatile u32 alpha;
139 volatile u32 red;
140 volatile u32 green;
141 volatile u32 blue;
142 volatile u32 depth;
143 volatile u32 y;
144 volatile u32 x;
145 u32 xxx2[2];
146 volatile u32 ryf;
147 volatile u32 rxf;
148 u32 xxx3[2];
149
150 volatile u32 dmyf;
151 volatile u32 dmxf;
152 u32 xxx4[2];
153 volatile u32 ebyi;
154 volatile u32 ebxi;
155 u32 xxx5[2];
156 volatile u32 by;
157 volatile u32 bx;
158 u32 dy;
159 u32 dx;
160 volatile u32 bh;
161 volatile u32 bw;
162 u32 xxx6[2];
163
164 u32 xxx7[32];
165
166 /* Setup unit vertex state register */
167 volatile u32 suvtx;
168 u32 xxx8[63];
169
170 /* Control registers */
171 volatile u32 ppc;
172 volatile u32 wid;
173 volatile u32 fg;
174 volatile u32 bg;
175 volatile u32 consty;
176 volatile u32 constz;
177 volatile u32 xclip;
178 volatile u32 dcss;
179 volatile u32 vclipmin;
180 volatile u32 vclipmax;
181 volatile u32 vclipzmin;
182 volatile u32 vclipzmax;
183 volatile u32 dcsf;
184 volatile u32 dcsb;
185 volatile u32 dczf;
186 volatile u32 dczb;
187
188 u32 xxx9;
189 volatile u32 blendc;
190 volatile u32 blendc1;
191 volatile u32 blendc2;
192 volatile u32 fbramitc;
193 volatile u32 fbc;
194 volatile u32 rop;
195 volatile u32 cmp;
196 volatile u32 matchab;
197 volatile u32 matchc;
198 volatile u32 magnab;
199 volatile u32 magnc;
200 volatile u32 fbcfg0;
201 volatile u32 fbcfg1;
202 volatile u32 fbcfg2;
203 volatile u32 fbcfg3;
204
205 u32 ppcfg;
206 volatile u32 pick;
207 volatile u32 fillmode;
208 volatile u32 fbramwac;
209 volatile u32 pmask;
210 volatile u32 xpmask;
211 volatile u32 ypmask;
212 volatile u32 zpmask;
213 volatile u32 clip0min;
214 volatile u32 clip0max;
215 volatile u32 clip1min;
216 volatile u32 clip1max;
217 volatile u32 clip2min;
218 volatile u32 clip2max;
219 volatile u32 clip3min;
220 volatile u32 clip3max;
221
222 /* New 3dRAM III support regs */