1 #ifndef __ATI_RADEON_FB_H
2 #define __ATI_RADEON_FB_H
4 /***************************************************************
5 * Most of the definitions here are adapted right from XFree86 *
6 ***************************************************************/
10 * Chip families. Must fit in the low 16 bits of a long word
17 CHIP_FAMILY_RS100, /* U1 (IGP320M) or A3 (IGP320)*/
19 CHIP_FAMILY_RS200, /* U2 (IGP330M/340M/350M) or A4 (IGP330/340/345/350),
23 CHIP_FAMILY_RS300, /* Radeon 9000 IGP */
28 CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */
29 CHIP_FAMILY_R420, /* R420/R423/M18 */
33 #define IS_RV100_VARIANT(rinfo) (((rinfo)->family == CHIP_FAMILY_RV100) || \
34 ((rinfo)->family == CHIP_FAMILY_RV200) || \
35 ((rinfo)->family == CHIP_FAMILY_RS100) || \
36 ((rinfo)->family == CHIP_FAMILY_RS200) || \
37 ((rinfo)->family == CHIP_FAMILY_RV250) || \
38 ((rinfo)->family == CHIP_FAMILY_RV280) || \
39 ((rinfo)->family == CHIP_FAMILY_RS300))
42 #define IS_R300_VARIANT(rinfo) (((rinfo)->family == CHIP_FAMILY_R300) || \
43 ((rinfo)->family == CHIP_FAMILY_RV350) || \
44 ((rinfo)->family == CHIP_FAMILY_R350) || \
45 ((rinfo)->family == CHIP_FAMILY_RV380) || \
46 ((rinfo)->family == CHIP_FAMILY_R420))
49 struct radeonfb_info {
52 struct pci_device_id pdev;
69 #define INREG8(addr) readb((rinfo->mmio_base)+addr)
70 #define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr)
71 #define INREG16(addr) readw((rinfo->mmio_base)+addr)
72 #define OUTREG16(addr,val) writew(val, (rinfo->mmio_base)+addr)
73 #define INREG(addr) readl((rinfo->mmio_base)+addr)
74 #define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr)
76 static inline void _OUTREGP(struct radeonfb_info *rinfo, u32 addr,
87 #define OUTREGP(addr,val,mask) _OUTREGP(rinfo, addr, val,mask)
91 * 2D Engine helper routines
93 static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
98 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
101 for (i=0; i < 2000000; i++) {
102 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
106 printf("radeonfb: Flush Timeout !\n");
110 static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
114 for (i=0; i<2000000; i++) {
115 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
119 printf("radeonfb: FIFO Timeout !\n");
123 static inline void _radeon_engine_idle(struct radeonfb_info *rinfo)
127 /* ensure FIFO is empty before waiting for idle */
128 _radeon_fifo_wait (rinfo, 64);
130 for (i=0; i<2000000; i++) {
131 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) {
132 radeon_engine_flush (rinfo);
137 printf("radeonfb: Idle Timeout !\n");
141 #define radeon_engine_idle() _radeon_engine_idle(rinfo)
142 #define radeon_fifo_wait(entries) _radeon_fifo_wait(rinfo,entries)
143 #define radeon_msleep(ms) _radeon_msleep(rinfo,ms)
146 * This structure contains the various registers manipulated by this
147 * driver for setting or restoring a mode. It's mostly copied from
148 * XFree's RADEONSaveRec structure. A few chip settings might still be
149 * tweaked without beeing reflected or saved in these registers though
152 /* Common registers */
154 u32 ovr_wid_left_right;
155 u32 ovr_wid_top_bottom;
169 /* Other registers to save for VT switches or driver load/unload */
172 u32 clock_cntl_index;
176 /* Surface/tiling registers */
177 u32 surf_lower_bound[8];
178 u32 surf_upper_bound[8];
185 u32 crtc_h_total_disp;
186 u32 crtc_h_sync_strt_wid;
187 u32 crtc_v_total_disp;
188 u32 crtc_v_sync_strt_wid;
190 u32 crtc_offset_cntl;
193 u32 grph_buffer_cntl;
196 /* CRTC2 registers */
199 u32 disp_output_cntl;
201 u32 disp2_merge_cntl;
202 u32 grph2_buffer_cntl;
203 u32 crtc2_h_total_disp;
204 u32 crtc2_h_sync_strt_wid;
205 u32 crtc2_v_total_disp;
206 u32 crtc2_v_sync_strt_wid;
208 u32 crtc2_offset_cntl;
211 /* Flat panel regs */
212 u32 fp_crtc_h_total_disp;
213 u32 fp_crtc_v_total_disp;
216 u32 fp_h_sync_strt_wid;
217 u32 fp2_h_sync_strt_wid;
220 u32 fp_v_sync_strt_wid;
221 u32 fp2_v_sync_strt_wid;
226 u32 tmds_transmitter_cntl;
228 /* Computed values for PLL */
239 /* Computed values for PLL2 */
240 u32 dot_clock_freq_2;
253 static inline u32 __INPLL(struct radeonfb_info *rinfo, u32 addr)
257 OUTREG8(CLOCK_CNTL_INDEX, addr & 0x0000003f);
258 //radeon_pll_errata_after_index(rinfo);
259 data = INREG(CLOCK_CNTL_DATA);
260 //radeon_pll_errata_after_data(rinfo);
264 static inline void __OUTPLL(struct radeonfb_info *rinfo, unsigned int index,
268 OUTREG8(CLOCK_CNTL_INDEX, (index & 0x0000003f) | 0x00000080);
269 //radeon_pll_errata_after_index(rinfo);
270 OUTREG(CLOCK_CNTL_DATA, val);
271 //radeon_pll_errata_after_data(rinfo);
275 static inline void __OUTPLLP(struct radeonfb_info *rinfo, unsigned int index,
280 tmp = __INPLL(rinfo, index);
283 __OUTPLL(rinfo, index, tmp);
287 #define INPLL(addr) __INPLL(rinfo, addr)
288 #define OUTPLL(index, val) __OUTPLL(rinfo, index, val)
289 #define OUTPLLP(index, val, mask) __OUTPLLP(rinfo, index, val, mask)