Rev 1129 | Rev 1221 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1129 | Rev 1179 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | * |
23 | * |
24 | * Authors: Dave Airlie |
24 | * Authors: Dave Airlie |
25 | * Alex Deucher |
25 | * Alex Deucher |
26 | * Jerome Glisse |
26 | * Jerome Glisse |
27 | */ |
27 | */ |
28 | //#include |
28 | #include |
29 | #include |
29 | #include |
30 | #include "radeon_reg.h" |
30 | #include "radeon_reg.h" |
31 | #include "radeon.h" |
31 | #include "radeon.h" |
Line 32... | Line 32... | ||
32 | 32 | ||
33 | /* rs400,rs480 depends on : */ |
33 | /* rs400,rs480 depends on : */ |
Line 60... | Line 60... | ||
60 | case 1024: |
60 | case 1024: |
61 | case 2048: |
61 | case 2048: |
62 | break; |
62 | break; |
63 | default: |
63 | default: |
64 | DRM_ERROR("Unable to use IGP GART size %uM\n", |
64 | DRM_ERROR("Unable to use IGP GART size %uM\n", |
65 | rdev->mc.gtt_size >> 20); |
65 | (unsigned)(rdev->mc.gtt_size >> 20)); |
66 | DRM_ERROR("Valid GART size for IGP are 32M,64M,128M,256M,512M,1G,2G\n"); |
66 | DRM_ERROR("Valid GART size for IGP are 32M,64M,128M,256M,512M,1G,2G\n"); |
67 | DRM_ERROR("Forcing to 32M GART size\n"); |
67 | DRM_ERROR("Forcing to 32M GART size\n"); |
68 | rdev->mc.gtt_size = 32 * 1024 * 1024; |
68 | rdev->mc.gtt_size = 32 * 1024 * 1024; |
69 | return; |
69 | return; |
70 | } |
70 | } |
Line 90... | Line 90... | ||
90 | timeout--; |
90 | timeout--; |
91 | } while (timeout > 0); |
91 | } while (timeout > 0); |
92 | WREG32_MC(RS480_GART_CACHE_CNTRL, 0); |
92 | WREG32_MC(RS480_GART_CACHE_CNTRL, 0); |
93 | } |
93 | } |
Line 94... | Line 94... | ||
94 | 94 | ||
95 | int rs400_gart_enable(struct radeon_device *rdev) |
95 | int rs400_gart_init(struct radeon_device *rdev) |
96 | { |
- | |
97 | uint32_t size_reg; |
- | |
98 | uint32_t tmp; |
96 | { |
Line -... | Line 97... | ||
- | 97 | int r; |
|
- | 98 | ||
- | 99 | if (rdev->gart.table.ram.ptr) { |
|
- | 100 | WARN(1, "RS400 GART already initialized.\n"); |
|
- | 101 | return 0; |
|
- | 102 | } |
|
- | 103 | /* Check gart size */ |
|
- | 104 | switch(rdev->mc.gtt_size / (1024 * 1024)) { |
|
- | 105 | case 32: |
|
- | 106 | case 64: |
|
- | 107 | case 128: |
|
- | 108 | case 256: |
|
- | 109 | case 512: |
|
- | 110 | case 1024: |
|
- | 111 | case 2048: |
|
- | 112 | break; |
|
- | 113 | default: |
|
99 | int r; |
114 | return -EINVAL; |
100 | 115 | } |
|
101 | /* Initialize common gart structure */ |
116 | /* Initialize common gart structure */ |
102 | r = radeon_gart_init(rdev); |
117 | r = radeon_gart_init(rdev); |
103 | if (r) { |
- | |
104 | return r; |
118 | if (r) |
105 | } |
119 | return r; |
- | 120 | if (rs400_debugfs_pcie_gart_info_init(rdev)) |
|
- | 121 | DRM_ERROR("Failed to register debugfs file for RS400 GART !\n"); |
|
106 | if (rs400_debugfs_pcie_gart_info_init(rdev)) { |
122 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; |
Line -... | Line 123... | ||
- | 123 | return radeon_gart_table_ram_alloc(rdev); |
|
- | 124 | } |
|
- | 125 | ||
- | 126 | int rs400_gart_enable(struct radeon_device *rdev) |
|
- | 127 | { |
|
107 | DRM_ERROR("Failed to register debugfs file for RS400 GART !\n"); |
128 | uint32_t size_reg; |
108 | } |
129 | uint32_t tmp; |
109 | 130 | ||
110 | tmp = RREG32_MC(RS690_AIC_CTRL_SCRATCH); |
131 | tmp = RREG32_MC(RS690_AIC_CTRL_SCRATCH); |
111 | tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; |
132 | tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; |
Line 134... | Line 155... | ||
134 | size_reg = RS480_VA_SIZE_2GB; |
155 | size_reg = RS480_VA_SIZE_2GB; |
135 | break; |
156 | break; |
136 | default: |
157 | default: |
137 | return -EINVAL; |
158 | return -EINVAL; |
138 | } |
159 | } |
139 | if (rdev->gart.table.ram.ptr == NULL) { |
- | |
140 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; |
- | |
141 | r = radeon_gart_table_ram_alloc(rdev); |
- | |
142 | if (r) { |
- | |
143 | return r; |
- | |
144 | } |
- | |
145 | } |
- | |
146 | /* It should be fine to program it to max value */ |
160 | /* It should be fine to program it to max value */ |
147 | if (rdev->family == CHIP_RS690 || (rdev->family == CHIP_RS740)) { |
161 | if (rdev->family == CHIP_RS690 || (rdev->family == CHIP_RS740)) { |
148 | WREG32_MC(RS690_MCCFG_AGP_BASE, 0xFFFFFFFF); |
162 | WREG32_MC(RS690_MCCFG_AGP_BASE, 0xFFFFFFFF); |
149 | WREG32_MC(RS690_MCCFG_AGP_BASE_2, 0); |
163 | WREG32_MC(RS690_MCCFG_AGP_BASE_2, 0); |
150 | } else { |
164 | } else { |
Line 162... | Line 176... | ||
162 | WREG32(RADEON_MC_AGP_LOCATION, tmp); |
176 | WREG32(RADEON_MC_AGP_LOCATION, tmp); |
163 | tmp = RREG32(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; |
177 | tmp = RREG32(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; |
164 | WREG32(RADEON_BUS_CNTL, tmp); |
178 | WREG32(RADEON_BUS_CNTL, tmp); |
165 | } |
179 | } |
166 | /* Table should be in 32bits address space so ignore bits above. */ |
180 | /* Table should be in 32bits address space so ignore bits above. */ |
167 | tmp = rdev->gart.table_addr & 0xfffff000; |
181 | tmp = (u32)rdev->gart.table_addr & 0xfffff000; |
- | 182 | tmp |= (upper_32_bits(rdev->gart.table_addr) & 0xff) << 4; |
|
- | 183 | ||
168 | WREG32_MC(RS480_GART_BASE, tmp); |
184 | WREG32_MC(RS480_GART_BASE, tmp); |
169 | /* TODO: more tweaking here */ |
185 | /* TODO: more tweaking here */ |
170 | WREG32_MC(RS480_GART_FEATURE_ID, |
186 | WREG32_MC(RS480_GART_FEATURE_ID, |
171 | (RS480_TLB_ENABLE | |
187 | (RS480_TLB_ENABLE | |
172 | RS480_GTW_LAC_EN | RS480_1LEVEL_GART)); |
188 | RS480_GTW_LAC_EN | RS480_1LEVEL_GART)); |
Line 197... | Line 213... | ||
197 | tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; |
213 | tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; |
198 | WREG32_MC(RS690_AIC_CTRL_SCRATCH, tmp); |
214 | WREG32_MC(RS690_AIC_CTRL_SCRATCH, tmp); |
199 | WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0); |
215 | WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0); |
200 | } |
216 | } |
Line -... | Line 217... | ||
- | 217 | ||
- | 218 | void rs400_gart_fini(struct radeon_device *rdev) |
|
- | 219 | { |
|
- | 220 | rs400_gart_disable(rdev); |
|
- | 221 | radeon_gart_table_ram_free(rdev); |
|
- | 222 | radeon_gart_fini(rdev); |
|
- | 223 | } |
|
201 | 224 | ||
202 | int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) |
225 | int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) |
- | 226 | { |
|
- | 227 | uint32_t entry; |
|
203 | { |
228 | |
204 | if (i < 0 || i > rdev->gart.num_gpu_pages) { |
229 | if (i < 0 || i > rdev->gart.num_gpu_pages) { |
205 | return -EINVAL; |
230 | return -EINVAL; |
- | 231 | } |
|
- | 232 | ||
- | 233 | entry = (lower_32_bits(addr) & PAGE_MASK) | |
|
- | 234 | ((upper_32_bits(addr) & 0xff) << 4) | |
|
- | 235 | 0xc; |
|
206 | } |
236 | entry = cpu_to_le32(entry); |
207 | rdev->gart.table.ram.ptr[i] = cpu_to_le32(((uint32_t)addr) | 0xC); |
237 | rdev->gart.table.ram.ptr[i] = entry; |
208 | return 0; |
238 | return 0; |
Line 209... | Line 239... | ||
209 | } |
239 | } |
Line 221... | Line 251... | ||
221 | DRM_ERROR("Failed to register debugfs file for RBBM !\n"); |
251 | DRM_ERROR("Failed to register debugfs file for RBBM !\n"); |
222 | } |
252 | } |
Line 223... | Line 253... | ||
223 | 253 | ||
224 | rs400_gpu_init(rdev); |
254 | rs400_gpu_init(rdev); |
225 | rs400_gart_disable(rdev); |
255 | rs400_gart_disable(rdev); |
226 | rdev->mc.gtt_location = rdev->mc.vram_size; |
256 | rdev->mc.gtt_location = rdev->mc.mc_vram_size; |
227 | rdev->mc.gtt_location += (rdev->mc.gtt_size - 1); |
257 | rdev->mc.gtt_location += (rdev->mc.gtt_size - 1); |
228 | rdev->mc.gtt_location &= ~(rdev->mc.gtt_size - 1); |
- | |
229 | rdev->mc.vram_location = 0xFFFFFFFFUL; |
258 | rdev->mc.gtt_location &= ~(rdev->mc.gtt_size - 1); |
230 | r = radeon_mc_setup(rdev); |
259 | r = radeon_mc_setup(rdev); |
231 | if (r) { |
260 | if (r) { |
232 | return r; |
261 | return r; |
Line 236... | Line 265... | ||
236 | if (r300_mc_wait_for_idle(rdev)) { |
265 | if (r300_mc_wait_for_idle(rdev)) { |
237 | printk(KERN_WARNING "Failed to wait MC idle while " |
266 | printk(KERN_WARNING "Failed to wait MC idle while " |
238 | "programming pipes. Bad things might happen.\n"); |
267 | "programming pipes. Bad things might happen.\n"); |
239 | } |
268 | } |
Line 240... | Line 269... | ||
240 | 269 | ||
241 | tmp = rdev->mc.vram_location + rdev->mc.vram_size - 1; |
270 | tmp = rdev->mc.vram_location + rdev->mc.mc_vram_size - 1; |
242 | tmp = REG_SET(RADEON_MC_FB_TOP, tmp >> 16); |
271 | tmp = REG_SET(RADEON_MC_FB_TOP, tmp >> 16); |
243 | tmp |= REG_SET(RADEON_MC_FB_START, rdev->mc.vram_location >> 16); |
272 | tmp |= REG_SET(RADEON_MC_FB_START, rdev->mc.vram_location >> 16); |
244 | WREG32(RADEON_MC_FB_LOCATION, tmp); |
273 | WREG32(RADEON_MC_FB_LOCATION, tmp); |
245 | tmp = RREG32(RADEON_HOST_PATH_CNTL) | RADEON_HP_LIN_RD_CACHE_DIS; |
274 | tmp = RREG32(RADEON_HOST_PATH_CNTL) | RADEON_HP_LIN_RD_CACHE_DIS; |
246 | WREG32(RADEON_HOST_PATH_CNTL, tmp | RADEON_HDP_SOFT_RESET | RADEON_HDP_READ_BUFFER_INVALIDATE); |
275 | WREG32(RADEON_HOST_PATH_CNTL, tmp | RADEON_HDP_SOFT_RESET | RADEON_HDP_READ_BUFFER_INVALIDATE); |
247 | (void)RREG32(RADEON_HOST_PATH_CNTL); |
276 | (void)RREG32(RADEON_HOST_PATH_CNTL); |
248 | WREG32(RADEON_HOST_PATH_CNTL, tmp); |
277 | WREG32(RADEON_HOST_PATH_CNTL, tmp); |
- | 278 | (void)RREG32(RADEON_HOST_PATH_CNTL); |
|
249 | (void)RREG32(RADEON_HOST_PATH_CNTL); |
279 | |
250 | return 0; |
280 | return 0; |
Line 251... | Line 281... | ||
251 | } |
281 | } |
252 | 282 | ||
253 | void rs400_mc_fini(struct radeon_device *rdev) |
- | |
254 | { |
- | |
255 | rs400_gart_disable(rdev); |
- | |
256 | radeon_gart_table_ram_free(rdev); |
283 | void rs400_mc_fini(struct radeon_device *rdev) |
Line 257... | Line 284... | ||
257 | radeon_gart_fini(rdev); |
284 | { |
258 | } |
285 | } |
Line 282... | Line 309... | ||
282 | /* |
309 | /* |
283 | * VRAM info. |
310 | * VRAM info. |
284 | */ |
311 | */ |
285 | void rs400_vram_info(struct radeon_device *rdev) |
312 | void rs400_vram_info(struct radeon_device *rdev) |
286 | { |
313 | { |
287 | uint32_t tom; |
- | |
288 | - | ||
289 | rs400_gart_adjust_size(rdev); |
314 | rs400_gart_adjust_size(rdev); |
290 | /* DDR for all card after R300 & IGP */ |
315 | /* DDR for all card after R300 & IGP */ |
291 | rdev->mc.vram_is_ddr = true; |
316 | rdev->mc.vram_is_ddr = true; |
292 | rdev->mc.vram_width = 128; |
317 | rdev->mc.vram_width = 128; |
Line 293... | Line -... | ||
293 | - | ||
294 | /* read NB_TOM to get the amount of ram stolen for the GPU */ |
318 | |
295 | tom = RREG32(RADEON_NB_TOM); |
- | |
296 | rdev->mc.vram_size = (((tom >> 16) - (tom & 0xffff) + 1) << 16); |
- | |
297 | WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.vram_size); |
- | |
298 | - | ||
299 | /* Could aper size report 0 ? */ |
- | |
300 | rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); |
- | |
301 | rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); |
319 | r100_vram_init_sizes(rdev); |
Line 302... | Line 320... | ||
302 | } |
320 | } |
303 | 321 |