Rev 1877 | Rev 1986 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1877 | Rev 1963 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | #include |
30 | #include |
31 | #include |
31 | #include |
32 | #include |
32 | #include |
33 | #include "radeon_reg.h" |
33 | #include "radeon_reg.h" |
34 | #include "radeon.h" |
34 | #include "radeon.h" |
35 | #include "radeon_asic.h" |
- | |
36 | #include "atom.h" |
35 | #include "atom.h" |
37 | #include "display.h" |
36 | #include "display.h" |
Line 38... | Line 37... | ||
38 | 37 | ||
Line 51... | Line 50... | ||
51 | int radeon_connector_table = 0; |
50 | int radeon_connector_table = 0; |
52 | int radeon_tv = 1; |
51 | int radeon_tv = 1; |
53 | int radeon_new_pll = -1; |
52 | int radeon_new_pll = -1; |
54 | int radeon_dynpm = -1; |
53 | int radeon_dynpm = -1; |
55 | int radeon_audio = 1; |
54 | int radeon_audio = 1; |
- | 55 | int radeon_hw_i2c = 0; |
|
- | 56 | int radeon_pcie_gen2 = 0; |
|
- | 57 | int radeon_disp_priority = 0; |
|
- | 58 | ||
Line 56... | Line 59... | ||
56 | 59 | ||
Line 57... | Line 60... | ||
57 | 60 | ||
Line 74... | Line 77... | ||
74 | /* Non-legacy access */ |
77 | /* Non-legacy access */ |
75 | #define VGA_RSRC_NORMAL_IO 0x04 |
78 | #define VGA_RSRC_NORMAL_IO 0x04 |
76 | #define VGA_RSRC_NORMAL_MEM 0x08 |
79 | #define VGA_RSRC_NORMAL_MEM 0x08 |
Line -... | Line 80... | ||
- | 80 | ||
- | 81 | ||
- | 82 | static const char radeon_family_name[][16] = { |
|
- | 83 | "R100", |
|
- | 84 | "RV100", |
|
- | 85 | "RS100", |
|
- | 86 | "RV200", |
|
- | 87 | "RS200", |
|
- | 88 | "R200", |
|
- | 89 | "RV250", |
|
- | 90 | "RS300", |
|
- | 91 | "RV280", |
|
- | 92 | "R300", |
|
- | 93 | "R350", |
|
- | 94 | "RV350", |
|
- | 95 | "RV380", |
|
- | 96 | "R420", |
|
- | 97 | "R423", |
|
- | 98 | "RV410", |
|
- | 99 | "RS400", |
|
- | 100 | "RS480", |
|
- | 101 | "RS600", |
|
- | 102 | "RS690", |
|
- | 103 | "RS740", |
|
- | 104 | "RV515", |
|
- | 105 | "R520", |
|
- | 106 | "RV530", |
|
- | 107 | "RV560", |
|
- | 108 | "RV570", |
|
- | 109 | "R580", |
|
- | 110 | "R600", |
|
- | 111 | "RV610", |
|
- | 112 | "RV630", |
|
- | 113 | "RV670", |
|
- | 114 | "RV620", |
|
- | 115 | "RV635", |
|
- | 116 | "RS780", |
|
- | 117 | "RS880", |
|
- | 118 | "RV770", |
|
- | 119 | "RV730", |
|
- | 120 | "RV710", |
|
- | 121 | "RV740", |
|
- | 122 | "CEDAR", |
|
- | 123 | "REDWOOD", |
|
- | 124 | "JUNIPER", |
|
- | 125 | "CYPRESS", |
|
- | 126 | "HEMLOCK", |
|
- | 127 | "PALM", |
|
- | 128 | "BARTS", |
|
- | 129 | "TURKS", |
|
- | 130 | "CAICOS", |
|
- | 131 | "CAYMAN", |
|
Line 77... | Line 132... | ||
77 | 132 | "LAST", |
|
78 | 133 | }; |
|
79 | 134 | ||
80 | /* |
135 | /* |
Line 105... | Line 160... | ||
105 | if (rdev->family < CHIP_R300) { |
160 | if (rdev->family < CHIP_R300) { |
106 | rdev->scratch.num_reg = 5; |
161 | rdev->scratch.num_reg = 5; |
107 | } else { |
162 | } else { |
108 | rdev->scratch.num_reg = 7; |
163 | rdev->scratch.num_reg = 7; |
109 | } |
164 | } |
- | 165 | rdev->scratch.reg_base = RADEON_SCRATCH_REG0; |
|
110 | for (i = 0; i < rdev->scratch.num_reg; i++) { |
166 | for (i = 0; i < rdev->scratch.num_reg; i++) { |
111 | rdev->scratch.free[i] = true; |
167 | rdev->scratch.free[i] = true; |
112 | rdev->scratch.reg[i] = RADEON_SCRATCH_REG0 + (i * 4); |
168 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); |
113 | } |
169 | } |
114 | } |
170 | } |
Line 115... | Line 171... | ||
115 | 171 | ||
116 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg) |
172 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg) |
Line 159... | Line 215... | ||
159 | * This function will never fails, worst case are limiting VRAM. |
215 | * This function will never fails, worst case are limiting VRAM. |
160 | * |
216 | * |
161 | * Note: GTT start, end, size should be initialized before calling this |
217 | * Note: GTT start, end, size should be initialized before calling this |
162 | * function on AGP platform. |
218 | * function on AGP platform. |
163 | * |
219 | * |
164 | * Note: We don't explictly enforce VRAM start to be aligned on VRAM size, |
220 | * Note: We don't explicitly enforce VRAM start to be aligned on VRAM size, |
165 | * this shouldn't be a problem as we are using the PCI aperture as a reference. |
221 | * this shouldn't be a problem as we are using the PCI aperture as a reference. |
166 | * Otherwise this would be needed for rv280, all r3xx, and all r4xx, but |
222 | * Otherwise this would be needed for rv280, all r3xx, and all r4xx, but |
167 | * not IGP. |
223 | * not IGP. |
168 | * |
224 | * |
169 | * Note: we use mc_vram_size as on some board we need to program the mc to |
225 | * Note: we use mc_vram_size as on some board we need to program the mc to |
Line 187... | Line 243... | ||
187 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
243 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
188 | mc->real_vram_size = mc->aper_size; |
244 | mc->real_vram_size = mc->aper_size; |
189 | mc->mc_vram_size = mc->aper_size; |
245 | mc->mc_vram_size = mc->aper_size; |
190 | } |
246 | } |
191 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
247 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
192 | if (rdev->flags & RADEON_IS_AGP && mc->vram_end > mc->gtt_start && mc->vram_end <= mc->gtt_end) { |
248 | if (rdev->flags & RADEON_IS_AGP && mc->vram_end > mc->gtt_start && mc->vram_start <= mc->gtt_end) { |
193 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
249 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
194 | mc->real_vram_size = mc->aper_size; |
250 | mc->real_vram_size = mc->aper_size; |
195 | mc->mc_vram_size = mc->aper_size; |
251 | mc->mc_vram_size = mc->aper_size; |
196 | } |
252 | } |
197 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
253 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
198 | dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n", |
254 | dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n", |
199 | mc->mc_vram_size >> 20, mc->vram_start, |
255 | mc->mc_vram_size >> 20, mc->vram_start, |
200 | mc->vram_end, mc->real_vram_size >> 20); |
256 | mc->vram_end, mc->real_vram_size >> 20); |
201 | } |
257 | } |
Line 202... | Line 258... | ||
202 | 258 | ||
Line 214... | Line 270... | ||
214 | */ |
270 | */ |
215 | void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) |
271 | void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) |
216 | { |
272 | { |
217 | u64 size_af, size_bf; |
273 | u64 size_af, size_bf; |
Line 218... | Line 274... | ||
218 | 274 | ||
219 | size_af = 0xFFFFFFFF - mc->vram_end; |
275 | size_af = ((0xFFFFFFFF - mc->vram_end) + mc->gtt_base_align) & ~mc->gtt_base_align; |
220 | size_bf = mc->vram_start; |
276 | size_bf = mc->vram_start & ~mc->gtt_base_align; |
221 | if (size_bf > size_af) { |
277 | if (size_bf > size_af) { |
222 | if (mc->gtt_size > size_bf) { |
278 | if (mc->gtt_size > size_bf) { |
223 | dev_warn(rdev->dev, "limiting GTT\n"); |
279 | dev_warn(rdev->dev, "limiting GTT\n"); |
224 | mc->gtt_size = size_bf; |
280 | mc->gtt_size = size_bf; |
225 | } |
281 | } |
226 | mc->gtt_start = mc->vram_start - mc->gtt_size; |
282 | mc->gtt_start = (mc->vram_start & ~mc->gtt_base_align) - mc->gtt_size; |
227 | } else { |
283 | } else { |
228 | if (mc->gtt_size > size_af) { |
284 | if (mc->gtt_size > size_af) { |
229 | dev_warn(rdev->dev, "limiting GTT\n"); |
285 | dev_warn(rdev->dev, "limiting GTT\n"); |
230 | mc->gtt_size = size_af; |
286 | mc->gtt_size = size_af; |
231 | } |
287 | } |
232 | mc->gtt_start = mc->vram_end + 1; |
288 | mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align; |
233 | } |
289 | } |
234 | mc->gtt_end = mc->gtt_start + mc->gtt_size - 1; |
290 | mc->gtt_end = mc->gtt_start + mc->gtt_size - 1; |
235 | dev_info(rdev->dev, "GTT: %lluM 0x%08llX - 0x%08llX\n", |
291 | dev_info(rdev->dev, "GTT: %lluM 0x%016llX - 0x%016llX\n", |
236 | mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end); |
292 | mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end); |
Line 237... | Line 293... | ||
237 | } |
293 | } |
238 | 294 | ||
Line 242... | Line 298... | ||
242 | bool radeon_card_posted(struct radeon_device *rdev) |
298 | bool radeon_card_posted(struct radeon_device *rdev) |
243 | { |
299 | { |
244 | uint32_t reg; |
300 | uint32_t reg; |
Line 245... | Line 301... | ||
245 | 301 | ||
246 | /* first check CRTCs */ |
302 | /* first check CRTCs */ |
- | 303 | if (ASIC_IS_DCE41(rdev)) { |
|
- | 304 | reg = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET) | |
|
- | 305 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET); |
|
- | 306 | if (reg & EVERGREEN_CRTC_MASTER_EN) |
|
- | 307 | return true; |
|
247 | if (ASIC_IS_DCE4(rdev)) { |
308 | } else if (ASIC_IS_DCE4(rdev)) { |
248 | reg = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET) | |
309 | reg = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET) | |
249 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET) | |
310 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET) | |
250 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET) | |
311 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET) | |
251 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET) | |
312 | RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET) | |
Line 278... | Line 339... | ||
278 | 339 | ||
Line 279... | Line 340... | ||
279 | return false; |
340 | return false; |
Line -... | Line 341... | ||
- | 341 | ||
- | 342 | } |
|
- | 343 | ||
- | 344 | void radeon_update_bandwidth_info(struct radeon_device *rdev) |
|
- | 345 | { |
|
- | 346 | fixed20_12 a; |
|
- | 347 | u32 sclk = rdev->pm.current_sclk; |
|
- | 348 | u32 mclk = rdev->pm.current_mclk; |
|
- | 349 | ||
- | 350 | /* sclk/mclk in Mhz */ |
|
- | 351 | a.full = dfixed_const(100); |
|
- | 352 | rdev->pm.sclk.full = dfixed_const(sclk); |
|
- | 353 | rdev->pm.sclk.full = dfixed_div(rdev->pm.sclk, a); |
|
- | 354 | rdev->pm.mclk.full = dfixed_const(mclk); |
|
- | 355 | rdev->pm.mclk.full = dfixed_div(rdev->pm.mclk, a); |
|
- | 356 | ||
- | 357 | if (rdev->flags & RADEON_IS_IGP) { |
|
- | 358 | a.full = dfixed_const(16); |
|
- | 359 | /* core_bandwidth = sclk(Mhz) * 16 */ |
|
- | 360 | rdev->pm.core_bandwidth.full = dfixed_div(rdev->pm.sclk, a); |
|
280 | 361 | } |
|
281 | } |
362 | } |
282 | 363 | ||
283 | bool radeon_boot_test_post_card(struct radeon_device *rdev) |
364 | bool radeon_boot_test_post_card(struct radeon_device *rdev) |
Line 321... | Line 402... | ||
321 | KernelFree(rdev->dummy_page.addr); |
402 | KernelFree(rdev->dummy_page.addr); |
322 | rdev->dummy_page.page = NULL; |
403 | rdev->dummy_page.page = NULL; |
323 | } |
404 | } |
Line 324... | Line -... | ||
324 | - | ||
325 | - | ||
326 | /* |
- | |
327 | * Registers accessors functions. |
- | |
328 | */ |
- | |
329 | uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg) |
- | |
330 | { |
- | |
331 | DRM_ERROR("Invalid callback to read register 0x%04X\n", reg); |
- | |
332 | BUG_ON(1); |
- | |
333 | return 0; |
- | |
334 | } |
- | |
335 | - | ||
336 | void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
- | |
337 | { |
- | |
338 | DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n", |
- | |
339 | reg, v); |
- | |
340 | BUG_ON(1); |
- | |
341 | } |
- | |
342 | - | ||
343 | void radeon_register_accessor_init(struct radeon_device *rdev) |
- | |
344 | { |
- | |
345 | rdev->mc_rreg = &radeon_invalid_rreg; |
- | |
346 | rdev->mc_wreg = &radeon_invalid_wreg; |
- | |
347 | rdev->pll_rreg = &radeon_invalid_rreg; |
- | |
348 | rdev->pll_wreg = &radeon_invalid_wreg; |
- | |
349 | rdev->pciep_rreg = &radeon_invalid_rreg; |
- | |
350 | rdev->pciep_wreg = &radeon_invalid_wreg; |
- | |
351 | - | ||
352 | /* Don't change order as we are overridding accessor. */ |
- | |
353 | if (rdev->family < CHIP_RV515) { |
- | |
354 | rdev->pcie_reg_mask = 0xff; |
- | |
355 | } else { |
- | |
356 | rdev->pcie_reg_mask = 0x7ff; |
- | |
357 | } |
- | |
358 | /* FIXME: not sure here */ |
- | |
359 | if (rdev->family <= CHIP_R580) { |
- | |
360 | rdev->pll_rreg = &r100_pll_rreg; |
- | |
361 | rdev->pll_wreg = &r100_pll_wreg; |
- | |
362 | } |
- | |
363 | if (rdev->family >= CHIP_R420) { |
- | |
364 | rdev->mc_rreg = &r420_mc_rreg; |
- | |
365 | rdev->mc_wreg = &r420_mc_wreg; |
- | |
366 | } |
- | |
367 | if (rdev->family >= CHIP_RV515) { |
- | |
368 | rdev->mc_rreg = &rv515_mc_rreg; |
- | |
369 | rdev->mc_wreg = &rv515_mc_wreg; |
- | |
370 | } |
- | |
371 | if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) { |
- | |
372 | rdev->mc_rreg = &rs400_mc_rreg; |
- | |
373 | rdev->mc_wreg = &rs400_mc_wreg; |
- | |
374 | } |
- | |
375 | if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) { |
- | |
376 | rdev->mc_rreg = &rs690_mc_rreg; |
- | |
377 | rdev->mc_wreg = &rs690_mc_wreg; |
- | |
378 | } |
- | |
379 | if (rdev->family == CHIP_RS600) { |
- | |
380 | rdev->mc_rreg = &rs600_mc_rreg; |
- | |
381 | rdev->mc_wreg = &rs600_mc_wreg; |
- | |
382 | } |
- | |
383 | if ((rdev->family >= CHIP_R600) && (rdev->family <= CHIP_RV740)) { |
- | |
384 | rdev->pciep_rreg = &r600_pciep_rreg; |
- | |
385 | rdev->pciep_wreg = &r600_pciep_wreg; |
- | |
386 | } |
- | |
387 | } |
- | |
388 | - | ||
389 | - | ||
390 | /* |
- | |
391 | * ASIC |
- | |
392 | */ |
- | |
393 | int radeon_asic_init(struct radeon_device *rdev) |
- | |
394 | { |
- | |
395 | radeon_register_accessor_init(rdev); |
- | |
396 | switch (rdev->family) { |
- | |
397 | case CHIP_R100: |
- | |
398 | case CHIP_RV100: |
- | |
399 | case CHIP_RS100: |
- | |
400 | case CHIP_RV200: |
- | |
401 | case CHIP_RS200: |
- | |
402 | rdev->asic = &r100_asic; |
- | |
403 | break; |
- | |
404 | case CHIP_R200: |
- | |
405 | case CHIP_RV250: |
- | |
406 | case CHIP_RS300: |
- | |
407 | case CHIP_RV280: |
- | |
408 | rdev->asic = &r200_asic; |
- | |
409 | break; |
- | |
410 | case CHIP_R300: |
- | |
411 | case CHIP_R350: |
- | |
412 | case CHIP_RV350: |
- | |
413 | case CHIP_RV380: |
- | |
414 | if (rdev->flags & RADEON_IS_PCIE) |
- | |
415 | rdev->asic = &r300_asic_pcie; |
- | |
416 | else |
- | |
417 | rdev->asic = &r300_asic; |
- | |
418 | break; |
- | |
419 | case CHIP_R420: |
- | |
420 | case CHIP_R423: |
- | |
421 | case CHIP_RV410: |
- | |
422 | rdev->asic = &r420_asic; |
- | |
423 | break; |
- | |
424 | case CHIP_RS400: |
- | |
425 | case CHIP_RS480: |
- | |
426 | rdev->asic = &rs400_asic; |
- | |
427 | break; |
- | |
428 | case CHIP_RS600: |
- | |
429 | rdev->asic = &rs600_asic; |
- | |
430 | break; |
- | |
431 | case CHIP_RS690: |
- | |
432 | case CHIP_RS740: |
- | |
433 | rdev->asic = &rs690_asic; |
- | |
434 | break; |
- | |
435 | case CHIP_RV515: |
- | |
436 | rdev->asic = &rv515_asic; |
- | |
437 | break; |
- | |
438 | case CHIP_R520: |
- | |
439 | case CHIP_RV530: |
- | |
440 | case CHIP_RV560: |
- | |
441 | case CHIP_RV570: |
- | |
442 | case CHIP_R580: |
- | |
443 | rdev->asic = &r520_asic; |
- | |
444 | break; |
- | |
445 | case CHIP_R600: |
- | |
446 | case CHIP_RV610: |
- | |
447 | case CHIP_RV630: |
- | |
448 | case CHIP_RV620: |
- | |
449 | case CHIP_RV635: |
- | |
450 | case CHIP_RV670: |
- | |
451 | case CHIP_RS780: |
- | |
452 | case CHIP_RS880: |
- | |
453 | rdev->asic = &r600_asic; |
- | |
454 | break; |
- | |
455 | case CHIP_RV770: |
- | |
456 | case CHIP_RV730: |
- | |
457 | case CHIP_RV710: |
- | |
458 | case CHIP_RV740: |
- | |
459 | rdev->asic = &rv770_asic; |
- | |
460 | break; |
- | |
461 | case CHIP_CEDAR: |
- | |
462 | case CHIP_REDWOOD: |
- | |
463 | case CHIP_JUNIPER: |
- | |
464 | case CHIP_CYPRESS: |
- | |
465 | case CHIP_HEMLOCK: |
- | |
466 | rdev->asic = &evergreen_asic; |
- | |
467 | break; |
- | |
468 | default: |
- | |
469 | /* FIXME: not supported yet */ |
- | |
470 | return -EINVAL; |
- | |
471 | } |
- | |
472 | - | ||
473 | if (rdev->flags & RADEON_IS_IGP) { |
- | |
474 | rdev->asic->get_memory_clock = NULL; |
- | |
475 | rdev->asic->set_memory_clock = NULL; |
- | |
476 | } |
- | |
477 | - | ||
478 | return 0; |
- | |
479 | } |
- | |
480 | - | ||
481 | - | ||
482 | /* |
- | |
483 | * Wrapper around modesetting bits. |
- | |
484 | */ |
- | |
485 | int radeon_clocks_init(struct radeon_device *rdev) |
- | |
486 | { |
- | |
487 | int r; |
- | |
488 | - | ||
489 | r = radeon_static_clocks_init(rdev->ddev); |
- | |
490 | if (r) { |
- | |
491 | return r; |
- | |
492 | } |
- | |
493 | DRM_INFO("Clocks initialized !\n"); |
- | |
494 | return 0; |
- | |
495 | } |
- | |
496 | - | ||
497 | void radeon_clocks_fini(struct radeon_device *rdev) |
- | |
498 | { |
- | |
499 | } |
405 | |
500 | 406 | ||
501 | /* ATOM accessor methods */ |
407 | /* ATOM accessor methods */ |
502 | static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) |
408 | static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) |
503 | { |
409 | { |
Line 545... | Line 451... | ||
545 | 451 | ||
546 | r = RREG32(reg*4); |
452 | r = RREG32(reg*4); |
547 | return r; |
453 | return r; |
Line -... | Line 454... | ||
- | 454 | } |
|
- | 455 | ||
- | 456 | static void cail_ioreg_write(struct card_info *info, uint32_t reg, uint32_t val) |
|
- | 457 | { |
|
- | 458 | struct radeon_device *rdev = info->dev->dev_private; |
|
- | 459 | ||
- | 460 | WREG32_IO(reg*4, val); |
|
- | 461 | } |
|
- | 462 | ||
- | 463 | static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg) |
|
- | 464 | { |
|
- | 465 | struct radeon_device *rdev = info->dev->dev_private; |
|
- | 466 | uint32_t r; |
|
- | 467 | ||
- | 468 | r = RREG32_IO(reg*4); |
|
- | 469 | return r; |
|
548 | } |
470 | } |
549 | 471 | ||
550 | int radeon_atombios_init(struct radeon_device *rdev) |
472 | int radeon_atombios_init(struct radeon_device *rdev) |
551 | { |
473 | { |
Line 557... | Line 479... | ||
557 | 479 | ||
558 | rdev->mode_info.atom_card_info = atom_card_info; |
480 | rdev->mode_info.atom_card_info = atom_card_info; |
559 | atom_card_info->dev = rdev->ddev; |
481 | atom_card_info->dev = rdev->ddev; |
560 | atom_card_info->reg_read = cail_reg_read; |
482 | atom_card_info->reg_read = cail_reg_read; |
- | 483 | atom_card_info->reg_write = cail_reg_write; |
|
- | 484 | /* needed for iio ops */ |
|
- | 485 | if (rdev->rio_mem) { |
|
- | 486 | atom_card_info->ioreg_read = cail_ioreg_read; |
|
- | 487 | atom_card_info->ioreg_write = cail_ioreg_write; |
|
- | 488 | } else { |
|
- | 489 | DRM_ERROR("Unable to find PCI I/O BAR; using MMIO for ATOM IIO\n"); |
|
- | 490 | atom_card_info->ioreg_read = cail_reg_read; |
|
- | 491 | atom_card_info->ioreg_write = cail_reg_write; |
|
561 | atom_card_info->reg_write = cail_reg_write; |
492 | } |
562 | atom_card_info->mc_read = cail_mc_read; |
493 | atom_card_info->mc_read = cail_mc_read; |
563 | atom_card_info->mc_write = cail_mc_write; |
494 | atom_card_info->mc_write = cail_mc_write; |
564 | atom_card_info->pll_read = cail_pll_read; |
495 | atom_card_info->pll_read = cail_pll_read; |
Line 600... | Line 531... | ||
600 | VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
531 | VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
601 | else |
532 | else |
602 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
533 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
603 | } |
534 | } |
Line 604... | Line -... | ||
604 | - | ||
605 | void radeon_agp_disable(struct radeon_device *rdev) |
- | |
606 | { |
- | |
607 | rdev->flags &= ~RADEON_IS_AGP; |
- | |
608 | if (rdev->family >= CHIP_R600) { |
- | |
609 | DRM_INFO("Forcing AGP to PCIE mode\n"); |
- | |
610 | rdev->flags |= RADEON_IS_PCIE; |
- | |
611 | } else if (rdev->family >= CHIP_RV515 || |
- | |
612 | rdev->family == CHIP_RV380 || |
- | |
613 | rdev->family == CHIP_RV410 || |
- | |
614 | rdev->family == CHIP_R423) { |
- | |
615 | DRM_INFO("Forcing AGP to PCIE mode\n"); |
- | |
616 | rdev->flags |= RADEON_IS_PCIE; |
- | |
617 | rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush; |
- | |
618 | rdev->asic->gart_set_page = &rv370_pcie_gart_set_page; |
- | |
619 | } else { |
- | |
620 | DRM_INFO("Forcing AGP to PCI mode\n"); |
- | |
621 | rdev->flags |= RADEON_IS_PCI; |
- | |
622 | rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush; |
- | |
623 | rdev->asic->gart_set_page = &r100_pci_gart_set_page; |
- | |
624 | } |
- | |
625 | rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; |
- | |
626 | } |
- | |
627 | 535 | ||
628 | void radeon_check_arguments(struct radeon_device *rdev) |
536 | void radeon_check_arguments(struct radeon_device *rdev) |
629 | { |
537 | { |
630 | /* vramlimit must be a power of two */ |
538 | /* vramlimit must be a power of two */ |
631 | switch (radeon_vram_limit) { |
539 | switch (radeon_vram_limit) { |
Line 694... | Line 602... | ||
694 | int radeon_device_init(struct radeon_device *rdev, |
602 | int radeon_device_init(struct radeon_device *rdev, |
695 | struct drm_device *ddev, |
603 | struct drm_device *ddev, |
696 | struct pci_dev *pdev, |
604 | struct pci_dev *pdev, |
697 | uint32_t flags) |
605 | uint32_t flags) |
698 | { |
606 | { |
699 | int r; |
607 | int r, i; |
700 | int dma_bits; |
608 | int dma_bits; |
Line 701... | Line -... | ||
701 | - | ||
702 | DRM_INFO("radeon: Initializing kernel modesetting.\n"); |
609 | |
703 | rdev->shutdown = false; |
610 | rdev->shutdown = false; |
704 | rdev->ddev = ddev; |
611 | rdev->ddev = ddev; |
705 | rdev->pdev = pdev; |
612 | rdev->pdev = pdev; |
706 | rdev->flags = flags; |
613 | rdev->flags = flags; |
707 | rdev->family = flags & RADEON_FAMILY_MASK; |
614 | rdev->family = flags & RADEON_FAMILY_MASK; |
708 | rdev->is_atom_bios = false; |
615 | rdev->is_atom_bios = false; |
709 | rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT; |
616 | rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT; |
710 | rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; |
617 | rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; |
711 | rdev->gpu_lockup = false; |
618 | rdev->gpu_lockup = false; |
- | 619 | rdev->accel_working = false; |
|
- | 620 | ||
- | 621 | DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X).\n", |
|
- | 622 | radeon_family_name[rdev->family], pdev->vendor, pdev->device); |
|
712 | rdev->accel_working = false; |
623 | |
713 | /* mutex initialization are all done here so we |
624 | /* mutex initialization are all done here so we |
714 | * can recall function without having locking issues */ |
625 | * can recall function without having locking issues */ |
715 | mutex_init(&rdev->cs_mutex); |
626 | mutex_init(&rdev->cs_mutex); |
716 | mutex_init(&rdev->ib_pool.mutex); |
627 | mutex_init(&rdev->ib_pool.mutex); |
717 | mutex_init(&rdev->cp.mutex); |
628 | mutex_init(&rdev->cp.mutex); |
- | 629 | mutex_init(&rdev->dc_hw_i2c_mutex); |
|
- | 630 | // if (rdev->family >= CHIP_R600) |
|
718 | mutex_init(&rdev->dc_hw_i2c_mutex); |
631 | // spin_lock_init(&rdev->ih.lock); |
719 | mutex_init(&rdev->gem.mutex); |
632 | mutex_init(&rdev->gem.mutex); |
- | 633 | mutex_init(&rdev->pm.mutex); |
|
720 | mutex_init(&rdev->pm.mutex); |
634 | mutex_init(&rdev->vram_mutex); |
- | 635 | // rwlock_init(&rdev->fence_drv.lock); |
|
Line 721... | Line 636... | ||
721 | // rwlock_init(&rdev->fence_drv.lock); |
636 | INIT_LIST_HEAD(&rdev->gem.objects); |
722 | 637 | ||
723 | /* Set asic functions */ |
638 | /* Set asic functions */ |
724 | r = radeon_asic_init(rdev); |
639 | r = radeon_asic_init(rdev); |
725 | if (r) |
640 | if (r) |
Line -... | Line 641... | ||
- | 641 | return r; |
|
- | 642 | radeon_check_arguments(rdev); |
|
- | 643 | ||
- | 644 | /* all of the newer IGP chips have an internal gart |
|
- | 645 | * However some rs4xx report as AGP, so remove that here. |
|
- | 646 | */ |
|
- | 647 | if ((rdev->family >= CHIP_RS400) && |
|
- | 648 | (rdev->flags & RADEON_IS_IGP)) { |
|
726 | return r; |
649 | rdev->flags &= ~RADEON_IS_AGP; |
727 | radeon_check_arguments(rdev); |
650 | } |
728 | 651 | ||
Line 729... | Line 652... | ||
729 | if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) { |
652 | if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) { |
Line 749... | Line 672... | ||
749 | } |
672 | } |
Line 750... | Line 673... | ||
750 | 673 | ||
751 | /* Registers mapping */ |
674 | /* Registers mapping */ |
752 | /* TODO: block userspace mapping of io register */ |
675 | /* TODO: block userspace mapping of io register */ |
753 | rdev->rmmio_base = pci_resource_start(rdev->pdev, 2); |
- | |
754 | 676 | rdev->rmmio_base = pci_resource_start(rdev->pdev, 2); |
|
Line 755... | Line 677... | ||
755 | rdev->rmmio_size = pci_resource_len(rdev->pdev, 2); |
677 | rdev->rmmio_size = pci_resource_len(rdev->pdev, 2); |
756 | 678 | ||
Line 769... | Line 691... | ||
769 | 691 | ||
770 | if (rdev->flags & RADEON_IS_AGP && !rdev->accel_working) { |
692 | if (rdev->flags & RADEON_IS_AGP && !rdev->accel_working) { |
771 | /* Acceleration not working on AGP card try again |
693 | /* Acceleration not working on AGP card try again |
772 | * with fallback to PCI or PCIE GART |
694 | * with fallback to PCI or PCIE GART |
773 | */ |
695 | */ |
774 | radeon_gpu_reset(rdev); |
696 | radeon_asic_reset(rdev); |
775 | radeon_fini(rdev); |
697 | radeon_fini(rdev); |
776 | radeon_agp_disable(rdev); |
698 | radeon_agp_disable(rdev); |
777 | r = radeon_init(rdev); |
699 | r = radeon_init(rdev); |
778 | if (r) |
700 | if (r) |
Line 872... | Line 794... | ||
872 | INIT_LIST_HEAD(&dev->ctxlist); |
794 | INIT_LIST_HEAD(&dev->ctxlist); |
873 | INIT_LIST_HEAD(&dev->vmalist); |
795 | INIT_LIST_HEAD(&dev->vmalist); |
874 | INIT_LIST_HEAD(&dev->maplist); |
796 | INIT_LIST_HEAD(&dev->maplist); |
Line 875... | Line 797... | ||
875 | 797 | ||
876 | spin_lock_init(&dev->count_lock); |
- | |
877 | spin_lock_init(&dev->drw_lock); |
798 | spin_lock_init(&dev->count_lock); |
878 | mutex_init(&dev->struct_mutex); |
799 | mutex_init(&dev->struct_mutex); |
Line 879... | Line 800... | ||
879 | mutex_init(&dev->ctxlist_mutex); |
800 | mutex_init(&dev->ctxlist_mutex); |
880 | 801 | ||
881 | 802 | ||
Line 882... | Line 803... | ||
882 | ret = radeon_driver_load_kms(dev, ent->driver_data ); |
803 | ret = radeon_driver_load_kms(dev, ent->driver_data ); |
883 | if (ret) |
804 | if (ret) |
884 | goto err_g4; |
805 | goto err_g4; |
885 | 806 | ||
Line 886... | Line 807... | ||
886 | if( radeon_modeset ) |
807 | // if( radeon_modeset ) |
Line 887... | Line 808... | ||
887 | init_display_kms(dev->dev_private, &usermode); |
808 | // init_display_kms(dev->dev_private, &usermode); |
Line 1011... | Line 932... | ||
1011 | } |
932 | } |
Line 1012... | Line 933... | ||
1012 | 933 | ||
1013 | static char log[256]; |
934 | static char log[256]; |
Line 1014... | Line -... | ||
1014 | static pci_dev_t device; |
- | |
1015 | - | ||
1016 | u32_t |
- | |
1017 | #if defined(__GNUC__) && __GNUC__ >= 4 |
- | |
1018 | // has sense only if -fwhole-program is used, like Makefile.lto |
- | |
1019 | __attribute__((externally_visible)) |
935 | static pci_dev_t device; |
1020 | #endif |
936 | |
1021 | drvEntry(int action, char *cmdline) |
937 | u32_t drvEntry(int action, char *cmdline) |
Line 1022... | Line 938... | ||
1022 | { |
938 | { |
Line 1036... | Line 952... | ||
1036 | if( cmdline && *cmdline ) |
952 | if( cmdline && *cmdline ) |
1037 | parse_cmdline(cmdline, &usermode, log, &radeon_modeset); |
953 | parse_cmdline(cmdline, &usermode, log, &radeon_modeset); |
Line 1038... | Line 954... | ||
1038 | 954 | ||
1039 | if(!dbg_open(log)) |
955 | if(!dbg_open(log)) |
1040 | { |
956 | { |
Line 1041... | Line 957... | ||
1041 | strcpy(log, "/rd/1/drivers/atikms.log"); |
957 | strcpy(log, "/hd2/1/atikms.log"); |
1042 | 958 | ||
1043 | if(!dbg_open(log)) |
959 | if(!dbg_open(log)) |
1044 | { |
960 | { |
1045 | printf("Can't open %s\nExit\n", log); |
961 | printf("Can't open %s\nExit\n", log); |
1046 | return 0; |
962 | return 0; |
1047 | }; |
963 | }; |
Line 1048... | Line 964... | ||
1048 | } |
964 | } |
- | 965 | dbgprintf("Radeon RC11 cmdline %s\n", cmdline); |
|
1049 | dbgprintf("Radeon RC10 cmdline %s\n", cmdline); |
966 | |
Line 1050... | Line 967... | ||
1050 | 967 | enum_pci_devices(); |
|
1051 | enum_pci_devices(); |
968 | |
1052 | ent = find_pci_device(&device, pciidlist); |
969 | ent = find_pci_device(&device, pciidlist); |
Line 1062... | Line 979... | ||
1062 | 979 | ||
Line 1063... | Line 980... | ||
1063 | err = drm_get_dev(&device.pci_dev, ent); |
980 | err = drm_get_dev(&device.pci_dev, ent); |
Line 1064... | Line 981... | ||
1064 | 981 | ||
1065 | rdev = rdisplay->ddev->dev_private; |
982 | rdev = rdisplay->ddev->dev_private; |
1066 | 983 | ||
1067 | if( (rdev->asic == &r600_asic) || |
984 | // if( (rdev->asic == &r600_asic) || |
1068 | (rdev->asic == &rv770_asic)) |
985 | // (rdev->asic == &rv770_asic)) |
Line 1069... | Line 986... | ||
1069 | r600_2D_test(rdev); |
986 | // r600_2D_test(rdev); |
Line 1070... | Line 987... | ||
1070 | else if (rdev->asic != &evergreen_asic) |
987 | // else if (rdev->asic != &evergreen_asic) |
1071 | r100_2D_test(rdev); |
988 | // r100_2D_test(rdev); |