3 * ATI Frame Buffer Device Driver Core Definitions
13 #define readb(addr) (*(volatile unsigned char *) (addr))
14 #define readw(addr) (*(volatile unsigned short *) (addr))
15 #define readl(addr) (*(volatile unsigned int *) (addr))
17 #define writeb(b,addr) (*(volatile unsigned char *) (addr) = (b))
18 #define writew(b,addr) (*(volatile unsigned short *) (addr) = (b))
19 #define writel(b,addr) (*(volatile unsigned int *) (addr) = (b))
22 #define max(x,y) (x>=y)?x:y
24 #if CONFIG_CONSOLE_BTEXT==1
26 * Elements of the hardware specific atyfb_par structure
40 u32 dp_pix_width; /* acceleration */
41 u32 dp_chain_mask; /* acceleration */
43 #endif /* CONFIG_CONSOLE_BTEXT */
62 u8 mclk_fb_mult; /* 2 or 4 */
69 u32 dsp_config; /* Mach64 GTB DSP */
70 u32 dsp_on_off; /* Mach64 GTB DSP */
71 u8 mclk_post_div_real;
72 u8 xclk_post_div_real;
73 u8 vclk_post_div_real;
79 struct pll_514 ibm514;
80 struct pll_18818 ics2595;
86 * The hardware parameters for each card
89 #if CONFIG_CONSOLE_BTEXT==1
109 struct timer_list *timer;
113 #if CONFIG_CONSOLE_BTEXT==1
114 #if PLL_CRTC_DECODE==1
115 struct fb_info fb_info;
119 struct fb_info_aty *next;
120 unsigned long ati_regbase_phys;
122 unsigned long ati_regbase;
124 unsigned long frame_buffer_phys;
126 unsigned long frame_buffer;
127 unsigned long clk_wr_offset;
129 struct pci_mmap_map *mmap_map;
130 struct aty_cursor *cursor;
132 struct aty_cmap_regs *aty_cmap_regs;
134 struct { u8 red, green, blue, pad; } palette[256];
136 struct atyfb_par default_par;
137 #if PLL_CRTC_DECODE==1
138 struct atyfb_par current_par;
151 struct aty_dac_ops *dac_ops;
152 struct aty_pll_ops *pll_ops;
154 struct display_switch dispsw;
159 #ifdef FBCON_HAS_CFB16
162 #ifdef FBCON_HAS_CFB24
165 #ifdef FBCON_HAS_CFB32
170 u8 blitter_may_be_busy;
178 #ifdef CONFIG_PMAC_PBOOK
179 unsigned char *save_framebuffer;
180 unsigned long save_pll[64];
187 * ATI Mach64 features
190 #define M64_HAS(feature) ((info)->features & (M64F_##feature))
192 #define M64F_RESET_3D 0x00000001
193 #define M64F_MAGIC_FIFO 0x00000002
194 #define M64F_GTB_DSP 0x00000004
195 #define M64F_FIFO_24 0x00000008
196 #define M64F_SDRAM_MAGIC_PLL 0x00000010
197 #define M64F_MAGIC_POSTDIV 0x00000020
198 #define M64F_INTEGRATED 0x00000040
199 #define M64F_CT_BUS 0x00000080
200 #define M64F_VT_BUS 0x00000100
201 #define M64F_MOBIL_BUS 0x00000200
202 #define M64F_GX 0x00000400
203 #define M64F_CT 0x00000800
204 #define M64F_VT 0x00001000
205 #define M64F_GT 0x00002000
206 #define M64F_MAGIC_VRAM_SIZE 0x00004000
207 #define M64F_G3_PB_1_1 0x00008000
208 #define M64F_G3_PB_1024x768 0x00010000
209 #define M64F_EXTRA_BRIGHT 0x00020000
210 #define M64F_LT_SLEEP 0x00040000
211 #define M64F_XL_DLL 0x00080000
212 #define M64F_MFB_TIMES_4 0x00100000
219 static inline u32 aty_ld_le32(int regindex,
220 const struct fb_info_aty *info)
222 /* Hack for bloc 1, should be cleanly optimized by compiler */
223 if (regindex >= 0x400)
227 return in_le32((volatile u32 *)(info->ati_regbase+regindex));
229 return readl (info->ati_regbase + regindex);
233 static inline void aty_st_le32(int regindex, u32 val,
234 const struct fb_info_aty *info)
236 /* Hack for bloc 1, should be cleanly optimized by compiler */
237 if (regindex >= 0x400)
241 out_le32 (info->ati_regbase+regindex, val);
243 writel (val, info->ati_regbase + regindex);
247 static inline u16 aty_ld_le16(int regindex,
248 const struct fb_info_aty *info)
250 /* Hack for bloc 1, should be cleanly optimized by compiler */
251 if (regindex >= 0x400)
254 #if defined(__mc68000__)
255 return le16_to_cpu(*((volatile u16 *)(info->ati_regbase+regindex)));
257 return readw (info->ati_regbase + regindex);
261 static inline void aty_st_le16(int regindex, u16 val,
262 const struct fb_info_aty *info)
264 /* Hack for bloc 1, should be cleanly optimized by compiler */
265 if (regindex >= 0x400)
268 #if defined(__mc68000__)
269 *((volatile u16 *)(info->ati_regbase+regindex)) = cpu_to_le16(val);
271 writew (val, info->ati_regbase + regindex);
275 static inline u8 aty_ld_8(int regindex,
276 const struct fb_info_aty *info)
278 /* Hack for bloc 1, should be cleanly optimized by compiler */
279 if (regindex >= 0x400)
283 return in_8 (info->ati_regbase + regindex);
285 return readb (info->ati_regbase + regindex);
289 static inline void aty_st_8(int regindex, u8 val,
290 const struct fb_info_aty *info)
292 /* Hack for bloc 1, should be cleanly optimized by compiler */
293 if (regindex >= 0x400)
297 out_8 (info->ati_regbase + regindex, val);
299 writeb (val, info->ati_regbase + regindex);
303 static inline u8 aty_ld_pll(int offset, const struct fb_info_aty *info)
307 /* write addr byte */
308 aty_st_8(CLOCK_CNTL + 1, (offset << 2), info);
309 /* read the register value */
310 res = aty_ld_8(CLOCK_CNTL + 2, info);
317 static inline void aty_st_pll(int offset, u8 val,
318 const struct fb_info_aty *info)
320 /* write addr byte */
321 aty_st_8(CLOCK_CNTL + 1, (offset << 2) | PLL_WR_EN, info);
322 /* write the register value */
323 aty_st_8(CLOCK_CNTL + 2, val, info);
324 aty_st_8(CLOCK_CNTL + 1, (offset << 2) & ~PLL_WR_EN, info);
335 int (*set_dac)(const struct fb_info_aty *info, const union aty_pll *pll,
338 extern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */
339 extern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */
340 extern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */
341 extern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */
342 static struct aty_dac_ops aty_dac_ct; /* Integrated */
352 int (*var_to_pll)(const struct fb_info_aty *info, u32 vclk_per, u8 bpp,
355 u32 (*pll_to_var)(const struct fb_info_aty *info,
356 const union aty_pll *pll);
357 void (*set_pll)(const struct fb_info_aty *info, const union aty_pll *pll);
364 extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
365 extern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */
366 extern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */
367 extern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */
368 extern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */
369 extern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */
372 static struct aty_pll_ops aty_pll_ct; /* Integrated */
374 static void aty_set_pll_ct(const struct fb_info_aty *info,
375 const union aty_pll *pll);
377 static void aty_calc_pll_ct(const struct fb_info_aty *info,
382 * Hardware cursor support
384 extern struct aty_cursor *aty_init_cursor(struct fb_info_aty *fb);
385 extern void atyfb_cursor(struct display *p, int mode, int x, int y);
386 extern void aty_set_cursor_color(struct fb_info_aty *fb);
387 extern void aty_set_cursor_shape(struct fb_info_aty *fb);
388 extern int atyfb_set_font(struct display *d, int width, int height);
391 * Hardware acceleration
394 static inline void wait_for_fifo(u16 entries, const struct fb_info_aty *info)
396 while ((aty_ld_le32(FIFO_STAT, info) & 0xffff) >
397 ((u32)(0x8000 >> entries)));
400 static inline void wait_for_idle(struct fb_info_aty *info)
402 wait_for_fifo(16, info);
403 while ((aty_ld_le32(GUI_STAT, info) & 1)!= 0);
404 info->blitter_may_be_busy = 0;
407 extern void aty_reset_engine(const struct fb_info_aty *info);
408 extern void aty_init_engine(const struct atyfb_par *par,
409 struct fb_info_aty *info);
410 extern void aty_rectfill(int dstx, int dsty, u_int width, u_int height,
411 u_int color, struct fb_info_aty *info);
415 * Text console acceleration
418 extern const struct display_switch fbcon_aty8;
419 extern const struct display_switch fbcon_aty16;
420 extern const struct display_switch fbcon_aty24;
421 extern const struct display_switch fbcon_aty32;