atyfb.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. /*
  2. * ATI Frame Buffer Device Driver Core Definitions
  3. */
  4. #include <linux/spinlock.h>
  5. #include <linux/wait.h>
  6. /*
  7. * Elements of the hardware specific atyfb_par structure
  8. */
  9. struct crtc {
  10. u32 vxres;
  11. u32 vyres;
  12. u32 xoffset;
  13. u32 yoffset;
  14. u32 bpp;
  15. u32 h_tot_disp;
  16. u32 h_sync_strt_wid;
  17. u32 v_tot_disp;
  18. u32 v_sync_strt_wid;
  19. u32 vline_crnt_vline;
  20. u32 off_pitch;
  21. u32 gen_cntl;
  22. u32 dp_pix_width; /* acceleration */
  23. u32 dp_chain_mask; /* acceleration */
  24. #ifdef CONFIG_FB_ATY_GENERIC_LCD
  25. u32 horz_stretching;
  26. u32 vert_stretching;
  27. u32 ext_vert_stretch;
  28. u32 shadow_h_tot_disp;
  29. u32 shadow_h_sync_strt_wid;
  30. u32 shadow_v_tot_disp;
  31. u32 shadow_v_sync_strt_wid;
  32. u32 lcd_gen_cntl;
  33. u32 lcd_config_panel;
  34. u32 lcd_index;
  35. #endif
  36. };
  37. struct aty_interrupt {
  38. wait_queue_head_t wait;
  39. unsigned int count;
  40. int pan_display;
  41. };
  42. struct pll_info {
  43. int pll_max;
  44. int pll_min;
  45. int sclk, mclk, mclk_pm, xclk;
  46. int ref_div;
  47. int ref_clk;
  48. int ecp_max;
  49. };
  50. typedef struct {
  51. u16 unknown1;
  52. u16 PCLK_min_freq;
  53. u16 PCLK_max_freq;
  54. u16 unknown2;
  55. u16 ref_freq;
  56. u16 ref_divider;
  57. u16 unknown3;
  58. u16 MCLK_pwd;
  59. u16 MCLK_max_freq;
  60. u16 XCLK_max_freq;
  61. u16 SCLK_freq;
  62. } __attribute__ ((packed)) PLL_BLOCK_MACH64;
  63. struct pll_514 {
  64. u8 m;
  65. u8 n;
  66. };
  67. struct pll_18818 {
  68. u32 program_bits;
  69. u32 locationAddr;
  70. u32 period_in_ps;
  71. u32 post_divider;
  72. };
  73. struct pll_ct {
  74. u8 pll_ref_div;
  75. u8 pll_gen_cntl;
  76. u8 mclk_fb_div;
  77. u8 mclk_fb_mult; /* 2 ro 4 */
  78. u8 sclk_fb_div;
  79. u8 pll_vclk_cntl;
  80. u8 vclk_post_div;
  81. u8 vclk_fb_div;
  82. u8 pll_ext_cntl;
  83. u8 ext_vpll_cntl;
  84. u8 spll_cntl2;
  85. u32 dsp_config; /* Mach64 GTB DSP */
  86. u32 dsp_on_off; /* Mach64 GTB DSP */
  87. u32 dsp_loop_latency;
  88. u32 fifo_size;
  89. u32 xclkpagefaultdelay;
  90. u32 xclkmaxrasdelay;
  91. u8 xclk_ref_div;
  92. u8 xclk_post_div;
  93. u8 mclk_post_div_real;
  94. u8 xclk_post_div_real;
  95. u8 vclk_post_div_real;
  96. u8 features;
  97. #ifdef CONFIG_FB_ATY_GENERIC_LCD
  98. u32 xres; /* use for LCD stretching/scaling */
  99. #endif
  100. };
  101. /*
  102. for pll_ct.features
  103. */
  104. #define DONT_USE_SPLL 0x1
  105. #define DONT_USE_XDLL 0x2
  106. #define USE_CPUCLK 0x4
  107. #define POWERDOWN_PLL 0x8
  108. union aty_pll {
  109. struct pll_ct ct;
  110. struct pll_514 ibm514;
  111. struct pll_18818 ics2595;
  112. };
  113. /*
  114. * The hardware parameters for each card
  115. */
  116. struct atyfb_par {
  117. struct { u8 red, green, blue; } palette[256];
  118. const struct aty_dac_ops *dac_ops;
  119. const struct aty_pll_ops *pll_ops;
  120. void __iomem *ati_regbase;
  121. unsigned long clk_wr_offset; /* meaning overloaded, clock id by CT */
  122. struct crtc crtc;
  123. union aty_pll pll;
  124. struct pll_info pll_limits;
  125. u32 features;
  126. u32 ref_clk_per;
  127. u32 pll_per;
  128. u32 mclk_per;
  129. u32 xclk_per;
  130. u8 bus_type;
  131. u8 ram_type;
  132. u8 mem_refresh_rate;
  133. u16 pci_id;
  134. u32 accel_flags;
  135. int blitter_may_be_busy;
  136. int asleep;
  137. int lock_blank;
  138. unsigned long res_start;
  139. unsigned long res_size;
  140. struct pci_dev *pdev;
  141. #ifdef __sparc__
  142. struct pci_mmap_map *mmap_map;
  143. u8 mmaped;
  144. #endif
  145. int open;
  146. #ifdef CONFIG_FB_ATY_GENERIC_LCD
  147. unsigned long bios_base_phys;
  148. unsigned long bios_base;
  149. unsigned long lcd_table;
  150. u16 lcd_width;
  151. u16 lcd_height;
  152. u32 lcd_pixclock;
  153. u16 lcd_refreshrate;
  154. u16 lcd_htotal;
  155. u16 lcd_hdisp;
  156. u16 lcd_hsync_dly;
  157. u16 lcd_hsync_len;
  158. u16 lcd_vtotal;
  159. u16 lcd_vdisp;
  160. u16 lcd_vsync_len;
  161. u16 lcd_right_margin;
  162. u16 lcd_lower_margin;
  163. u16 lcd_hblank_len;
  164. u16 lcd_vblank_len;
  165. #endif
  166. unsigned long aux_start; /* auxiliary aperture */
  167. unsigned long aux_size;
  168. struct aty_interrupt vblank;
  169. unsigned long irq_flags;
  170. unsigned int irq;
  171. spinlock_t int_lock;
  172. #ifdef CONFIG_MTRR
  173. int mtrr_aper;
  174. int mtrr_reg;
  175. #endif
  176. u32 mem_cntl;
  177. };
  178. /*
  179. * ATI Mach64 features
  180. */
  181. #define M64_HAS(feature) ((par)->features & (M64F_##feature))
  182. #define M64F_RESET_3D 0x00000001
  183. #define M64F_MAGIC_FIFO 0x00000002
  184. #define M64F_GTB_DSP 0x00000004
  185. #define M64F_FIFO_32 0x00000008
  186. #define M64F_SDRAM_MAGIC_PLL 0x00000010
  187. #define M64F_MAGIC_POSTDIV 0x00000020
  188. #define M64F_INTEGRATED 0x00000040
  189. #define M64F_CT_BUS 0x00000080
  190. #define M64F_VT_BUS 0x00000100
  191. #define M64F_MOBIL_BUS 0x00000200
  192. #define M64F_GX 0x00000400
  193. #define M64F_CT 0x00000800
  194. #define M64F_VT 0x00001000
  195. #define M64F_GT 0x00002000
  196. #define M64F_MAGIC_VRAM_SIZE 0x00004000
  197. #define M64F_G3_PB_1_1 0x00008000
  198. #define M64F_G3_PB_1024x768 0x00010000
  199. #define M64F_EXTRA_BRIGHT 0x00020000
  200. #define M64F_LT_LCD_REGS 0x00040000
  201. #define M64F_XL_DLL 0x00080000
  202. #define M64F_MFB_FORCE_4 0x00100000
  203. #define M64F_HW_TRIPLE 0x00200000
  204. /*
  205. * Register access
  206. */
  207. static inline u32 aty_ld_le32(int regindex, const struct atyfb_par *par)
  208. {
  209. /* Hack for bloc 1, should be cleanly optimized by compiler */
  210. if (regindex >= 0x400)
  211. regindex -= 0x800;
  212. #ifdef CONFIG_ATARI
  213. return in_le32(par->ati_regbase + regindex);
  214. #else
  215. return readl(par->ati_regbase + regindex);
  216. #endif
  217. }
  218. static inline void aty_st_le32(int regindex, u32 val, const struct atyfb_par *par)
  219. {
  220. /* Hack for bloc 1, should be cleanly optimized by compiler */
  221. if (regindex >= 0x400)
  222. regindex -= 0x800;
  223. #ifdef CONFIG_ATARI
  224. out_le32(par->ati_regbase + regindex, val);
  225. #else
  226. writel(val, par->ati_regbase + regindex);
  227. #endif
  228. }
  229. static inline void aty_st_le16(int regindex, u16 val,
  230. const struct atyfb_par *par)
  231. {
  232. /* Hack for bloc 1, should be cleanly optimized by compiler */
  233. if (regindex >= 0x400)
  234. regindex -= 0x800;
  235. #ifdef CONFIG_ATARI
  236. out_le16(par->ati_regbase + regindex, val);
  237. #else
  238. writel(val, par->ati_regbase + regindex);
  239. #endif
  240. }
  241. static inline u8 aty_ld_8(int regindex, const struct atyfb_par *par)
  242. {
  243. /* Hack for bloc 1, should be cleanly optimized by compiler */
  244. if (regindex >= 0x400)
  245. regindex -= 0x800;
  246. #ifdef CONFIG_ATARI
  247. return in_8(par->ati_regbase + regindex);
  248. #else
  249. return readb(par->ati_regbase + regindex);
  250. #endif
  251. }
  252. static inline void aty_st_8(int regindex, u8 val, const struct atyfb_par *par)
  253. {
  254. /* Hack for bloc 1, should be cleanly optimized by compiler */
  255. if (regindex >= 0x400)
  256. regindex -= 0x800;
  257. #ifdef CONFIG_ATARI
  258. out_8(par->ati_regbase + regindex, val);
  259. #else
  260. writeb(val, par->ati_regbase + regindex);
  261. #endif
  262. }
  263. #if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \
  264. defined (CONFIG_FB_ATY_GENERIC_LCD) || defined (CONFIG_FB_ATY_BACKLIGHT)
  265. extern void aty_st_lcd(int index, u32 val, const struct atyfb_par *par);
  266. extern u32 aty_ld_lcd(int index, const struct atyfb_par *par);
  267. #endif
  268. /*
  269. * DAC operations
  270. */
  271. struct aty_dac_ops {
  272. int (*set_dac) (const struct fb_info * info,
  273. const union aty_pll * pll, u32 bpp, u32 accel);
  274. };
  275. extern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */
  276. extern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */
  277. extern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */
  278. extern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */
  279. extern const struct aty_dac_ops aty_dac_ct; /* Integrated */
  280. /*
  281. * Clock operations
  282. */
  283. struct aty_pll_ops {
  284. int (*var_to_pll) (const struct fb_info * info, u32 vclk_per, u32 bpp, union aty_pll * pll);
  285. u32 (*pll_to_var) (const struct fb_info * info, const union aty_pll * pll);
  286. void (*set_pll) (const struct fb_info * info, const union aty_pll * pll);
  287. void (*get_pll) (const struct fb_info *info, union aty_pll * pll);
  288. int (*init_pll) (const struct fb_info * info, union aty_pll * pll);
  289. void (*resume_pll)(const struct fb_info *info, union aty_pll *pll);
  290. };
  291. extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
  292. extern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */
  293. extern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */
  294. extern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */
  295. extern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */
  296. extern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */
  297. extern const struct aty_pll_ops aty_pll_ct; /* Integrated */
  298. extern void aty_set_pll_ct(const struct fb_info *info, const union aty_pll *pll);
  299. extern u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par);
  300. /*
  301. * Hardware cursor support
  302. */
  303. extern int aty_init_cursor(struct fb_info *info);
  304. /*
  305. * Hardware acceleration
  306. */
  307. static inline void wait_for_fifo(u16 entries, const struct atyfb_par *par)
  308. {
  309. while ((aty_ld_le32(FIFO_STAT, par) & 0xffff) >
  310. ((u32) (0x8000 >> entries)));
  311. }
  312. static inline void wait_for_idle(struct atyfb_par *par)
  313. {
  314. wait_for_fifo(16, par);
  315. while ((aty_ld_le32(GUI_STAT, par) & 1) != 0);
  316. par->blitter_may_be_busy = 0;
  317. }
  318. extern void aty_reset_engine(const struct atyfb_par *par);
  319. extern void aty_init_engine(struct atyfb_par *par, struct fb_info *info);
  320. extern u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par);
  321. void atyfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
  322. void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
  323. void atyfb_imageblit(struct fb_info *info, const struct fb_image *image);