2 * ATI Frame Buffer Device Driver Core Definitions
5 #define PLL_CRTC_DECODE 0
9 #define max(x,y) (x>=y)?x:y
11 #if CONFIG_CONSOLE_BTEXT==1
13 * Elements of the hardware specific atyfb_par structure
27 u32 dp_pix_width; /* acceleration */
28 u32 dp_chain_mask; /* acceleration */
30 #endif /* CONFIG_CONSOLE_BTEXT */
49 u8 mclk_fb_mult; /* 2 or 4 */
56 u32 dsp_config; /* Mach64 GTB DSP */
57 u32 dsp_on_off; /* Mach64 GTB DSP */
58 u8 mclk_post_div_real;
59 u8 xclk_post_div_real;
60 u8 vclk_post_div_real;
66 struct pll_514 ibm514;
67 struct pll_18818 ics2595;
73 * The hardware parameters for each card
76 #if CONFIG_CONSOLE_BTEXT==1
96 struct timer_list *timer;
100 #if CONFIG_CONSOLE_BTEXT==1
101 #if PLL_CRTC_DECODE==1
102 struct fb_info fb_info;
106 struct fb_info_aty *next;
107 unsigned long ati_regbase_phys;
109 unsigned long ati_regbase;
111 unsigned long frame_buffer_phys;
113 unsigned long frame_buffer;
114 unsigned long clk_wr_offset;
116 struct pci_mmap_map *mmap_map;
117 struct aty_cursor *cursor;
119 struct aty_cmap_regs *aty_cmap_regs;
121 struct { u8 red, green, blue, pad; } palette[256];
123 struct atyfb_par default_par;
124 #if PLL_CRTC_DECODE==1
125 struct atyfb_par current_par;
138 struct aty_dac_ops *dac_ops;
139 struct aty_pll_ops *pll_ops;
141 struct display_switch dispsw;
146 #ifdef FBCON_HAS_CFB16
149 #ifdef FBCON_HAS_CFB24
152 #ifdef FBCON_HAS_CFB32
157 u8 blitter_may_be_busy;
165 #ifdef CONFIG_PMAC_PBOOK
166 unsigned char *save_framebuffer;
167 unsigned long save_pll[64];
174 * ATI Mach64 features
177 #define M64_HAS(feature) ((info)->features & (M64F_##feature))
179 #define M64F_RESET_3D 0x00000001
180 #define M64F_MAGIC_FIFO 0x00000002
181 #define M64F_GTB_DSP 0x00000004
182 #define M64F_FIFO_24 0x00000008
183 #define M64F_SDRAM_MAGIC_PLL 0x00000010
184 #define M64F_MAGIC_POSTDIV 0x00000020
185 #define M64F_INTEGRATED 0x00000040
186 #define M64F_CT_BUS 0x00000080
187 #define M64F_VT_BUS 0x00000100
188 #define M64F_MOBIL_BUS 0x00000200
189 #define M64F_GX 0x00000400
190 #define M64F_CT 0x00000800
191 #define M64F_VT 0x00001000
192 #define M64F_GT 0x00002000
193 #define M64F_MAGIC_VRAM_SIZE 0x00004000
194 #define M64F_G3_PB_1_1 0x00008000
195 #define M64F_G3_PB_1024x768 0x00010000
196 #define M64F_EXTRA_BRIGHT 0x00020000
197 #define M64F_LT_SLEEP 0x00040000
198 #define M64F_XL_DLL 0x00080000
199 #define M64F_MFB_TIMES_4 0x00100000
206 static inline u32 aty_ld_le32(int regindex,
207 const struct fb_info_aty *info)
209 /* Hack for bloc 1, should be cleanly optimized by compiler */
210 if (regindex >= 0x400)
214 return in_le32((volatile u32 *)(info->ati_regbase+regindex));
216 return read32 (info->ati_regbase + regindex);
220 static inline void aty_st_le32(int regindex, u32 val,
221 const struct fb_info_aty *info)
223 /* Hack for bloc 1, should be cleanly optimized by compiler */
224 if (regindex >= 0x400)
228 out_le32 (info->ati_regbase+regindex, val);
230 write32 (info->ati_regbase + regindex, val);
234 static inline u16 aty_ld_le16(int regindex,
235 const struct fb_info_aty *info)
237 /* Hack for bloc 1, should be cleanly optimized by compiler */
238 if (regindex >= 0x400)
241 #if defined(__mc68000__)
242 return le16_to_cpu(*((volatile u16 *)(info->ati_regbase+regindex)));
244 return read16 (info->ati_regbase + regindex);
248 static inline void aty_st_le16(int regindex, u16 val,
249 const struct fb_info_aty *info)
251 /* Hack for bloc 1, should be cleanly optimized by compiler */
252 if (regindex >= 0x400)
255 #if defined(__mc68000__)
256 *((volatile u16 *)(info->ati_regbase+regindex)) = cpu_to_le16(val);
258 write16 (info->ati_regbase + regindex, val);
262 static inline u8 aty_ld_8(int regindex,
263 const struct fb_info_aty *info)
265 /* Hack for bloc 1, should be cleanly optimized by compiler */
266 if (regindex >= 0x400)
270 return in_8 (info->ati_regbase + regindex);
272 return read8 (info->ati_regbase + regindex);
276 static inline void aty_st_8(int regindex, u8 val,
277 const struct fb_info_aty *info)
279 /* Hack for bloc 1, should be cleanly optimized by compiler */
280 if (regindex >= 0x400)
284 out_8 (info->ati_regbase + regindex, val);
286 write8 (info->ati_regbase + regindex, val);
290 static inline u8 aty_ld_pll(int offset, const struct fb_info_aty *info)
294 /* write addr byte */
295 aty_st_8(CLOCK_CNTL + 1, (offset << 2), info);
296 /* read the register value */
297 res = aty_ld_8(CLOCK_CNTL + 2, info);
304 static inline void aty_st_pll(int offset, u8 val,
305 const struct fb_info_aty *info)
307 /* write addr byte */
308 aty_st_8(CLOCK_CNTL + 1, (offset << 2) | PLL_WR_EN, info);
309 /* write the register value */
310 aty_st_8(CLOCK_CNTL + 2, val, info);
311 aty_st_8(CLOCK_CNTL + 1, (offset << 2) & ~PLL_WR_EN, info);
322 int (*set_dac)(const struct fb_info_aty *info, const union aty_pll *pll,
325 extern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */
326 extern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */
327 extern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */
328 extern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */
329 static struct aty_dac_ops aty_dac_ct; /* Integrated */
339 int (*var_to_pll)(const struct fb_info_aty *info, u32 vclk_per, u8 bpp,
342 u32 (*pll_to_var)(const struct fb_info_aty *info,
343 const union aty_pll *pll);
344 void (*set_pll)(const struct fb_info_aty *info, const union aty_pll *pll);
351 extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
352 extern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */
353 extern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */
354 extern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */
355 extern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */
356 extern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */
359 static struct aty_pll_ops aty_pll_ct; /* Integrated */
361 static void aty_set_pll_ct(const struct fb_info_aty *info,
362 const union aty_pll *pll);
364 static void aty_calc_pll_ct(const struct fb_info_aty *info,
369 * Hardware cursor support
371 extern struct aty_cursor *aty_init_cursor(struct fb_info_aty *fb);
372 extern void atyfb_cursor(struct display *p, int mode, int x, int y);
373 extern void aty_set_cursor_color(struct fb_info_aty *fb);
374 extern void aty_set_cursor_shape(struct fb_info_aty *fb);
375 extern int atyfb_set_font(struct display *d, int width, int height);
378 * Hardware acceleration
381 static inline void wait_for_fifo(u16 entries, const struct fb_info_aty *info)
383 while ((aty_ld_le32(FIFO_STAT, info) & 0xffff) >
384 ((u32)(0x8000 >> entries)));
387 static inline void wait_for_idle(struct fb_info_aty *info)
389 wait_for_fifo(16, info);
390 while ((aty_ld_le32(GUI_STAT, info) & 1)!= 0);
391 info->blitter_may_be_busy = 0;
394 extern void aty_reset_engine(const struct fb_info_aty *info);
395 extern void aty_init_engine(const struct atyfb_par *par,
396 struct fb_info_aty *info);
397 extern void aty_rectfill(int dstx, int dsty, u32 width, u32 height,
398 u32 color, struct fb_info_aty *info);
402 * Text console acceleration
405 extern const struct display_switch fbcon_aty8;
406 extern const struct display_switch fbcon_aty16;
407 extern const struct display_switch fbcon_aty24;
408 extern const struct display_switch fbcon_aty32;