blob: df8dd3dd443a93776912091a405150fcca5402ca [file] [log] [blame]
Stefan Reinauer35902422004-04-13 09:44:37 +00001/*
2 * ATI Frame Buffer Device Driver Core Definitions
3 */
Stefan Reinauer14e22772010-04-27 06:56:47 +00004
Stefan Reinauer467a0652010-04-25 14:37:18 +00005#define PLL_CRTC_DECODE 0
Stefan Reinauer35902422004-04-13 09:44:37 +00006
7#define EINVAL -1
8
Patrick Georgie1667822012-05-05 15:29:32 +02009#if CONFIG_CONSOLE_BTEXT
Stefan Reinauer35902422004-04-13 09:44:37 +000010 /*
11 * Elements of the hardware specific atyfb_par structure
12 */
Stefan Reinauer35902422004-04-13 09:44:37 +000013struct crtc {
14 u32 vxres;
15 u32 vyres;
16 u32 xoffset;
17 u32 yoffset;
18 u32 bpp;
19 u32 h_tot_disp;
20 u32 h_sync_strt_wid;
21 u32 v_tot_disp;
22 u32 v_sync_strt_wid;
23 u32 off_pitch;
24 u32 gen_cntl;
25 u32 dp_pix_width; /* acceleration */
26 u32 dp_chain_mask; /* acceleration */
27};
Yinghai Lu97c49472004-04-28 05:37:36 +000028#endif /* CONFIG_CONSOLE_BTEXT */
Stefan Reinauer234454d2004-04-24 23:10:51 +000029#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +000030struct pll_514 {
31 u8 m;
32 u8 n;
33};
34
35struct pll_18818
36{
37 u32 program_bits;
38 u32 locationAddr;
39 u32 period_in_ps;
40 u32 post_divider;
41};
42#endif
43struct pll_ct {
44 u8 pll_ref_div;
45 u8 pll_gen_cntl;
46 u8 mclk_fb_div;
47 u8 mclk_fb_mult; /* 2 or 4 */
48 u8 sclk_fb_div;
49 u8 pll_vclk_cntl;
50 u8 vclk_post_div;
51 u8 vclk_fb_div;
52 u8 pll_ext_cntl;
53 u8 spll_cntl2;
54 u32 dsp_config; /* Mach64 GTB DSP */
55 u32 dsp_on_off; /* Mach64 GTB DSP */
56 u8 mclk_post_div_real;
57 u8 xclk_post_div_real;
58 u8 vclk_post_div_real;
59};
60
61union aty_pll {
62 struct pll_ct ct;
63#if 0
64 struct pll_514 ibm514;
65 struct pll_18818 ics2595;
66#endif
67};
68
69
70 /*
71 * The hardware parameters for each card
72 */
Stefan Reinauer35902422004-04-13 09:44:37 +000073struct atyfb_par {
Patrick Georgie1667822012-05-05 15:29:32 +020074#if CONFIG_CONSOLE_BTEXT
Stefan Reinauer35902422004-04-13 09:44:37 +000075 struct crtc crtc;
Yinghai Lu97c49472004-04-28 05:37:36 +000076#endif
Stefan Reinauer35902422004-04-13 09:44:37 +000077 union aty_pll pll;
78 u32 accel_flags;
79};
Stefan Reinauer234454d2004-04-24 23:10:51 +000080#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +000081struct aty_cursor {
82 int enable;
83 int on;
84 int vbl_cnt;
85 int blink_rate;
86 u32 offset;
87 struct {
88 u16 x, y;
89 } pos, hot, size;
90 u32 color[2];
91 u8 bits[8][64];
92 u8 mask[8][64];
93 u8 *ram;
94 struct timer_list *timer;
95};
96#endif
97struct fb_info_aty {
Patrick Georgie1667822012-05-05 15:29:32 +020098#if CONFIG_CONSOLE_BTEXT
Yinghai Lu97c49472004-04-28 05:37:36 +000099#if PLL_CRTC_DECODE==1
Stefan Reinauer35902422004-04-13 09:44:37 +0000100 struct fb_info fb_info;
Yinghai Lu97c49472004-04-28 05:37:36 +0000101#endif
102#endif
Stefan Reinauer234454d2004-04-24 23:10:51 +0000103#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +0000104 struct fb_info_aty *next;
105 unsigned long ati_regbase_phys;
106#endif
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800107 u8 *ati_regbase;
Stefan Reinauer35902422004-04-13 09:44:37 +0000108#if 0
109 unsigned long frame_buffer_phys;
Stefan Reinauer234454d2004-04-24 23:10:51 +0000110#endif
Stefan Reinauer35902422004-04-13 09:44:37 +0000111 unsigned long frame_buffer;
112 unsigned long clk_wr_offset;
Stefan Reinauer234454d2004-04-24 23:10:51 +0000113#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +0000114 struct pci_mmap_map *mmap_map;
115 struct aty_cursor *cursor;
Stefan Reinauer234454d2004-04-24 23:10:51 +0000116#endif
Stefan Reinauer35902422004-04-13 09:44:37 +0000117 struct aty_cmap_regs *aty_cmap_regs;
Stefan Reinauer234454d2004-04-24 23:10:51 +0000118#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +0000119 struct { u8 red, green, blue, pad; } palette[256];
Stefan Reinauer234454d2004-04-24 23:10:51 +0000120#endif
Stefan Reinauer35902422004-04-13 09:44:37 +0000121 struct atyfb_par default_par;
Yinghai Lu97c49472004-04-28 05:37:36 +0000122#if PLL_CRTC_DECODE==1
Stefan Reinauer35902422004-04-13 09:44:37 +0000123 struct atyfb_par current_par;
124#endif
Stefan Reinauer234454d2004-04-24 23:10:51 +0000125
Stefan Reinauer35902422004-04-13 09:44:37 +0000126 u32 features;
127 u32 total_vram;
128 u32 ref_clk_per;
129 u32 pll_per;
130 u32 mclk_per;
131 u32 xclk_per;
132 u8 bus_type;
133 u8 ram_type;
Stefan Reinauer35902422004-04-13 09:44:37 +0000134 u8 mem_refresh_rate;
Stefan Reinauer35902422004-04-13 09:44:37 +0000135#if 0
136 struct aty_dac_ops *dac_ops;
137 struct aty_pll_ops *pll_ops;
Stefan Reinauer35902422004-04-13 09:44:37 +0000138 struct display disp;
139 struct display_switch dispsw;
140#endif
141
142#if 0
143 union {
144#ifdef FBCON_HAS_CFB16
145 u16 cfb16[16];
146#endif
147#ifdef FBCON_HAS_CFB24
148 u32 cfb24[16];
149#endif
150#ifdef FBCON_HAS_CFB32
151 u32 cfb32[16];
152#endif
153 } fbcon_cmap;
Stefan Reinauer234454d2004-04-24 23:10:51 +0000154#endif
Stefan Reinauer35902422004-04-13 09:44:37 +0000155 u8 blitter_may_be_busy;
Stefan Reinauer234454d2004-04-24 23:10:51 +0000156#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +0000157#ifdef __sparc__
158 u8 mmaped;
159 int open;
160 int vtconsole;
161 int consolecnt;
162#endif
163#ifdef CONFIG_PMAC_PBOOK
164 unsigned char *save_framebuffer;
165 unsigned long save_pll[64];
166#endif
167#endif
168};
169
170
171 /*
172 * ATI Mach64 features
173 */
174
175#define M64_HAS(feature) ((info)->features & (M64F_##feature))
176
177#define M64F_RESET_3D 0x00000001
178#define M64F_MAGIC_FIFO 0x00000002
179#define M64F_GTB_DSP 0x00000004
180#define M64F_FIFO_24 0x00000008
181#define M64F_SDRAM_MAGIC_PLL 0x00000010
182#define M64F_MAGIC_POSTDIV 0x00000020
183#define M64F_INTEGRATED 0x00000040
184#define M64F_CT_BUS 0x00000080
185#define M64F_VT_BUS 0x00000100
186#define M64F_MOBIL_BUS 0x00000200
187#define M64F_GX 0x00000400
188#define M64F_CT 0x00000800
189#define M64F_VT 0x00001000
190#define M64F_GT 0x00002000
191#define M64F_MAGIC_VRAM_SIZE 0x00004000
192#define M64F_G3_PB_1_1 0x00008000
193#define M64F_G3_PB_1024x768 0x00010000
194#define M64F_EXTRA_BRIGHT 0x00020000
195#define M64F_LT_SLEEP 0x00040000
196#define M64F_XL_DLL 0x00080000
197#define M64F_MFB_TIMES_4 0x00100000
198
199
200 /*
201 * Register access
202 */
203
204static inline u32 aty_ld_le32(int regindex,
205 const struct fb_info_aty *info)
206{
207 /* Hack for bloc 1, should be cleanly optimized by compiler */
208 if (regindex >= 0x400)
209 regindex -= 0x800;
210
Myles Watson0bc61542009-10-17 13:25:07 +0000211#ifdef ATARI
Stefan Reinauer35902422004-04-13 09:44:37 +0000212 return in_le32((volatile u32 *)(info->ati_regbase+regindex));
213#else
Stefan Reinauer467a0652010-04-25 14:37:18 +0000214 return read32 (info->ati_regbase + regindex);
Stefan Reinauer35902422004-04-13 09:44:37 +0000215#endif
216}
217
218static inline void aty_st_le32(int regindex, u32 val,
219 const struct fb_info_aty *info)
220{
221 /* Hack for bloc 1, should be cleanly optimized by compiler */
222 if (regindex >= 0x400)
223 regindex -= 0x800;
224
Myles Watson0bc61542009-10-17 13:25:07 +0000225#ifdef ATARI
Stefan Reinauer35902422004-04-13 09:44:37 +0000226 out_le32 (info->ati_regbase+regindex, val);
227#else
Stefan Reinauer467a0652010-04-25 14:37:18 +0000228 write32 (info->ati_regbase + regindex, val);
Stefan Reinauer35902422004-04-13 09:44:37 +0000229#endif
230}
231
232static inline u16 aty_ld_le16(int regindex,
233 const struct fb_info_aty *info)
234{
235 /* Hack for bloc 1, should be cleanly optimized by compiler */
236 if (regindex >= 0x400)
237 regindex -= 0x800;
238
239#if defined(__mc68000__)
240 return le16_to_cpu(*((volatile u16 *)(info->ati_regbase+regindex)));
241#else
Stefan Reinauer467a0652010-04-25 14:37:18 +0000242 return read16 (info->ati_regbase + regindex);
Stefan Reinauer35902422004-04-13 09:44:37 +0000243#endif
244}
245
246static inline void aty_st_le16(int regindex, u16 val,
247 const struct fb_info_aty *info)
248{
249 /* Hack for bloc 1, should be cleanly optimized by compiler */
250 if (regindex >= 0x400)
251 regindex -= 0x800;
252
253#if defined(__mc68000__)
254 *((volatile u16 *)(info->ati_regbase+regindex)) = cpu_to_le16(val);
255#else
Stefan Reinauer467a0652010-04-25 14:37:18 +0000256 write16 (info->ati_regbase + regindex, val);
Stefan Reinauer35902422004-04-13 09:44:37 +0000257#endif
258}
259
260static inline u8 aty_ld_8(int regindex,
261 const struct fb_info_aty *info)
262{
263 /* Hack for bloc 1, should be cleanly optimized by compiler */
264 if (regindex >= 0x400)
265 regindex -= 0x800;
266
Myles Watson0bc61542009-10-17 13:25:07 +0000267#ifdef ATARI
Stefan Reinauer35902422004-04-13 09:44:37 +0000268 return in_8 (info->ati_regbase + regindex);
269#else
Stefan Reinauer467a0652010-04-25 14:37:18 +0000270 return read8 (info->ati_regbase + regindex);
Stefan Reinauer35902422004-04-13 09:44:37 +0000271#endif
272}
273
274static inline void aty_st_8(int regindex, u8 val,
275 const struct fb_info_aty *info)
276{
277 /* Hack for bloc 1, should be cleanly optimized by compiler */
278 if (regindex >= 0x400)
279 regindex -= 0x800;
280
Myles Watson0bc61542009-10-17 13:25:07 +0000281#ifdef ATARI
Stefan Reinauer35902422004-04-13 09:44:37 +0000282 out_8 (info->ati_regbase + regindex, val);
283#else
Stefan Reinauer467a0652010-04-25 14:37:18 +0000284 write8 (info->ati_regbase + regindex, val);
Stefan Reinauer35902422004-04-13 09:44:37 +0000285#endif
286}
287
288static inline u8 aty_ld_pll(int offset, const struct fb_info_aty *info)
289{
290 u8 res;
291
292 /* write addr byte */
293 aty_st_8(CLOCK_CNTL + 1, (offset << 2), info);
294 /* read the register value */
295 res = aty_ld_8(CLOCK_CNTL + 2, info);
296 return res;
297}
298
299/*
300 * CT family only.
301 */
302static inline void aty_st_pll(int offset, u8 val,
303 const struct fb_info_aty *info)
304{
305 /* write addr byte */
306 aty_st_8(CLOCK_CNTL + 1, (offset << 2) | PLL_WR_EN, info);
307 /* write the register value */
308 aty_st_8(CLOCK_CNTL + 2, val, info);
309 aty_st_8(CLOCK_CNTL + 1, (offset << 2) & ~PLL_WR_EN, info);
310}
311
312
313 /*
314 * DAC operations
315 */
316
317#if 0
318
319struct aty_dac_ops {
320 int (*set_dac)(const struct fb_info_aty *info, const union aty_pll *pll,
321 u32 bpp, u32 accel);
322};
323extern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */
324extern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */
325extern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */
326extern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */
327static struct aty_dac_ops aty_dac_ct; /* Integrated */
328
329#endif
330
331 /*
332 * Clock operations
333 */
334
335#if 0
336struct aty_pll_ops {
337 int (*var_to_pll)(const struct fb_info_aty *info, u32 vclk_per, u8 bpp,
338 union aty_pll *pll);
339#if 0
340 u32 (*pll_to_var)(const struct fb_info_aty *info,
341 const union aty_pll *pll);
342 void (*set_pll)(const struct fb_info_aty *info, const union aty_pll *pll);
343#endif
344};
345
346#endif
347
348#if 0
349extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
350extern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */
351extern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */
352extern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */
353extern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */
354extern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */
Stefan Reinauer234454d2004-04-24 23:10:51 +0000355#endif
356#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +0000357static struct aty_pll_ops aty_pll_ct; /* Integrated */
358
359static void aty_set_pll_ct(const struct fb_info_aty *info,
360 const union aty_pll *pll);
361
362static void aty_calc_pll_ct(const struct fb_info_aty *info,
363 struct pll_ct *pll);
364#endif
Stefan Reinauer35902422004-04-13 09:44:37 +0000365#if 0
366 /*
367 * Hardware cursor support
368 */
369extern struct aty_cursor *aty_init_cursor(struct fb_info_aty *fb);
370extern void atyfb_cursor(struct display *p, int mode, int x, int y);
371extern void aty_set_cursor_color(struct fb_info_aty *fb);
372extern void aty_set_cursor_shape(struct fb_info_aty *fb);
373extern int atyfb_set_font(struct display *d, int width, int height);
Stefan Reinauer234454d2004-04-24 23:10:51 +0000374#endif
Stefan Reinauer35902422004-04-13 09:44:37 +0000375 /*
376 * Hardware acceleration
377 */
378
379static inline void wait_for_fifo(u16 entries, const struct fb_info_aty *info)
380{
381 while ((aty_ld_le32(FIFO_STAT, info) & 0xffff) >
382 ((u32)(0x8000 >> entries)));
383}
384
385static inline void wait_for_idle(struct fb_info_aty *info)
386{
387 wait_for_fifo(16, info);
388 while ((aty_ld_le32(GUI_STAT, info) & 1)!= 0);
389 info->blitter_may_be_busy = 0;
390}
Stefan Reinauer234454d2004-04-24 23:10:51 +0000391#if 0
Stefan Reinauer35902422004-04-13 09:44:37 +0000392extern void aty_reset_engine(const struct fb_info_aty *info);
393extern void aty_init_engine(const struct atyfb_par *par,
394 struct fb_info_aty *info);
Stefan Reinauer467a0652010-04-25 14:37:18 +0000395extern void aty_rectfill(int dstx, int dsty, u32 width, u32 height,
396 u32 color, struct fb_info_aty *info);
Stefan Reinauer35902422004-04-13 09:44:37 +0000397
398
399 /*
400 * Text console acceleration
401 */
402
403extern const struct display_switch fbcon_aty8;
404extern const struct display_switch fbcon_aty16;
405extern const struct display_switch fbcon_aty24;
406extern const struct display_switch fbcon_aty32;
407#endif