diff options
author | Jerome Glisse <jglisse@redhat.com> | 2009-10-01 03:39:24 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-10-01 18:51:50 -0400 |
commit | 3bc6853593bd4fba357dc252b3cf60cd86a1d2ec (patch) | |
tree | f60509478804b0087bef653dc6c10578deeb40e9 /drivers/gpu/drm/radeon/rs690.c | |
parent | d4550907157d8b3d5286157c15f1200c44842269 (diff) |
drm/radeon/kms: Convert RS690/RS740 to new init path (V2).
Also cleanup register specific to RS690/RS740. Version 2 add
missing header file for register, remove unecessary call to AGP
function and fix an indentation bug.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/rs690.c')
-rw-r--r-- | drivers/gpu/drm/radeon/rs690.c | 356 |
1 files changed, 226 insertions, 130 deletions
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c index 7a0098ddf977..0028db51ae75 100644 --- a/drivers/gpu/drm/radeon/rs690.c +++ b/drivers/gpu/drm/radeon/rs690.c | |||
@@ -26,105 +26,29 @@ | |||
26 | * Jerome Glisse | 26 | * Jerome Glisse |
27 | */ | 27 | */ |
28 | #include "drmP.h" | 28 | #include "drmP.h" |
29 | #include "radeon_reg.h" | ||
30 | #include "radeon.h" | 29 | #include "radeon.h" |
31 | #include "rs690r.h" | ||
32 | #include "atom.h" | 30 | #include "atom.h" |
33 | #include "atom-bits.h" | 31 | #include "rs690d.h" |
34 | |||
35 | /* rs690,rs740 depends on : */ | ||
36 | void r100_hdp_reset(struct radeon_device *rdev); | ||
37 | int r300_mc_wait_for_idle(struct radeon_device *rdev); | ||
38 | void r420_pipes_init(struct radeon_device *rdev); | ||
39 | void rs400_gart_disable(struct radeon_device *rdev); | ||
40 | int rs400_gart_enable(struct radeon_device *rdev); | ||
41 | void rs400_gart_adjust_size(struct radeon_device *rdev); | ||
42 | void rs600_mc_disable_clients(struct radeon_device *rdev); | ||
43 | |||
44 | /* This files gather functions specifics to : | ||
45 | * rs690,rs740 | ||
46 | * | ||
47 | * Some of these functions might be used by newer ASICs. | ||
48 | */ | ||
49 | void rs690_gpu_init(struct radeon_device *rdev); | ||
50 | int rs690_mc_wait_for_idle(struct radeon_device *rdev); | ||
51 | |||
52 | |||
53 | /* | ||
54 | * MC functions. | ||
55 | */ | ||
56 | int rs690_mc_init(struct radeon_device *rdev) | ||
57 | { | ||
58 | uint32_t tmp; | ||
59 | int r; | ||
60 | |||
61 | if (r100_debugfs_rbbm_init(rdev)) { | ||
62 | DRM_ERROR("Failed to register debugfs file for RBBM !\n"); | ||
63 | } | ||
64 | |||
65 | rs690_gpu_init(rdev); | ||
66 | rs400_gart_disable(rdev); | ||
67 | |||
68 | /* Setup GPU memory space */ | ||
69 | rdev->mc.gtt_location = rdev->mc.mc_vram_size; | ||
70 | rdev->mc.gtt_location += (rdev->mc.gtt_size - 1); | ||
71 | rdev->mc.gtt_location &= ~(rdev->mc.gtt_size - 1); | ||
72 | rdev->mc.vram_location = 0xFFFFFFFFUL; | ||
73 | r = radeon_mc_setup(rdev); | ||
74 | if (r) { | ||
75 | return r; | ||
76 | } | ||
77 | |||
78 | /* Program GPU memory space */ | ||
79 | rs600_mc_disable_clients(rdev); | ||
80 | if (rs690_mc_wait_for_idle(rdev)) { | ||
81 | printk(KERN_WARNING "Failed to wait MC idle while " | ||
82 | "programming pipes. Bad things might happen.\n"); | ||
83 | } | ||
84 | tmp = rdev->mc.vram_location + rdev->mc.mc_vram_size - 1; | ||
85 | tmp = REG_SET(RS690_MC_FB_TOP, tmp >> 16); | ||
86 | tmp |= REG_SET(RS690_MC_FB_START, rdev->mc.vram_location >> 16); | ||
87 | WREG32_MC(RS690_MCCFG_FB_LOCATION, tmp); | ||
88 | /* FIXME: Does this reg exist on RS480,RS740 ? */ | ||
89 | WREG32(0x310, rdev->mc.vram_location); | ||
90 | WREG32(RS690_HDP_FB_LOCATION, rdev->mc.vram_location >> 16); | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | void rs690_mc_fini(struct radeon_device *rdev) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | 32 | ||
99 | /* | 33 | static int rs690_mc_wait_for_idle(struct radeon_device *rdev) |
100 | * Global GPU functions | ||
101 | */ | ||
102 | int rs690_mc_wait_for_idle(struct radeon_device *rdev) | ||
103 | { | 34 | { |
104 | unsigned i; | 35 | unsigned i; |
105 | uint32_t tmp; | 36 | uint32_t tmp; |
106 | 37 | ||
107 | for (i = 0; i < rdev->usec_timeout; i++) { | 38 | for (i = 0; i < rdev->usec_timeout; i++) { |
108 | /* read MC_STATUS */ | 39 | /* read MC_STATUS */ |
109 | tmp = RREG32_MC(RS690_MC_STATUS); | 40 | tmp = RREG32_MC(R_000090_MC_SYSTEM_STATUS); |
110 | if (tmp & RS690_MC_STATUS_IDLE) { | 41 | if (G_000090_MC_SYSTEM_IDLE(tmp)) |
111 | return 0; | 42 | return 0; |
112 | } | 43 | udelay(1); |
113 | DRM_UDELAY(1); | ||
114 | } | 44 | } |
115 | return -1; | 45 | return -1; |
116 | } | 46 | } |
117 | 47 | ||
118 | void rs690_errata(struct radeon_device *rdev) | 48 | static void rs690_gpu_init(struct radeon_device *rdev) |
119 | { | ||
120 | rdev->pll_errata = 0; | ||
121 | } | ||
122 | |||
123 | void rs690_gpu_init(struct radeon_device *rdev) | ||
124 | { | 49 | { |
125 | /* FIXME: HDP same place on rs690 ? */ | 50 | /* FIXME: HDP same place on rs690 ? */ |
126 | r100_hdp_reset(rdev); | 51 | r100_hdp_reset(rdev); |
127 | rv515_vga_render_disable(rdev); | ||
128 | /* FIXME: is this correct ? */ | 52 | /* FIXME: is this correct ? */ |
129 | r420_pipes_init(rdev); | 53 | r420_pipes_init(rdev); |
130 | if (rs690_mc_wait_for_idle(rdev)) { | 54 | if (rs690_mc_wait_for_idle(rdev)) { |
@@ -133,10 +57,6 @@ void rs690_gpu_init(struct radeon_device *rdev) | |||
133 | } | 57 | } |
134 | } | 58 | } |
135 | 59 | ||
136 | |||
137 | /* | ||
138 | * VRAM info. | ||
139 | */ | ||
140 | void rs690_pm_info(struct radeon_device *rdev) | 60 | void rs690_pm_info(struct radeon_device *rdev) |
141 | { | 61 | { |
142 | int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); | 62 | int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); |
@@ -250,39 +170,39 @@ void rs690_line_buffer_adjust(struct radeon_device *rdev, | |||
250 | /* | 170 | /* |
251 | * Line Buffer Setup | 171 | * Line Buffer Setup |
252 | * There is a single line buffer shared by both display controllers. | 172 | * There is a single line buffer shared by both display controllers. |
253 | * DC_LB_MEMORY_SPLIT controls how that line buffer is shared between | 173 | * R_006520_DC_LB_MEMORY_SPLIT controls how that line buffer is shared between |
254 | * the display controllers. The paritioning can either be done | 174 | * the display controllers. The paritioning can either be done |
255 | * manually or via one of four preset allocations specified in bits 1:0: | 175 | * manually or via one of four preset allocations specified in bits 1:0: |
256 | * 0 - line buffer is divided in half and shared between crtc | 176 | * 0 - line buffer is divided in half and shared between crtc |
257 | * 1 - D1 gets 3/4 of the line buffer, D2 gets 1/4 | 177 | * 1 - D1 gets 3/4 of the line buffer, D2 gets 1/4 |
258 | * 2 - D1 gets the whole buffer | 178 | * 2 - D1 gets the whole buffer |
259 | * 3 - D1 gets 1/4 of the line buffer, D2 gets 3/4 | 179 | * 3 - D1 gets 1/4 of the line buffer, D2 gets 3/4 |
260 | * Setting bit 2 of DC_LB_MEMORY_SPLIT controls switches to manual | 180 | * Setting bit 2 of R_006520_DC_LB_MEMORY_SPLIT controls switches to manual |
261 | * allocation mode. In manual allocation mode, D1 always starts at 0, | 181 | * allocation mode. In manual allocation mode, D1 always starts at 0, |
262 | * D1 end/2 is specified in bits 14:4; D2 allocation follows D1. | 182 | * D1 end/2 is specified in bits 14:4; D2 allocation follows D1. |
263 | */ | 183 | */ |
264 | tmp = RREG32(DC_LB_MEMORY_SPLIT) & ~DC_LB_MEMORY_SPLIT_MASK; | 184 | tmp = RREG32(R_006520_DC_LB_MEMORY_SPLIT) & C_006520_DC_LB_MEMORY_SPLIT; |
265 | tmp &= ~DC_LB_MEMORY_SPLIT_SHIFT_MODE; | 185 | tmp &= ~C_006520_DC_LB_MEMORY_SPLIT_MODE; |
266 | /* auto */ | 186 | /* auto */ |
267 | if (mode1 && mode2) { | 187 | if (mode1 && mode2) { |
268 | if (mode1->hdisplay > mode2->hdisplay) { | 188 | if (mode1->hdisplay > mode2->hdisplay) { |
269 | if (mode1->hdisplay > 2560) | 189 | if (mode1->hdisplay > 2560) |
270 | tmp |= DC_LB_MEMORY_SPLIT_D1_3Q_D2_1Q; | 190 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1_3Q_D2_1Q; |
271 | else | 191 | else |
272 | tmp |= DC_LB_MEMORY_SPLIT_D1HALF_D2HALF; | 192 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1HALF_D2HALF; |
273 | } else if (mode2->hdisplay > mode1->hdisplay) { | 193 | } else if (mode2->hdisplay > mode1->hdisplay) { |
274 | if (mode2->hdisplay > 2560) | 194 | if (mode2->hdisplay > 2560) |
275 | tmp |= DC_LB_MEMORY_SPLIT_D1_1Q_D2_3Q; | 195 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1_1Q_D2_3Q; |
276 | else | 196 | else |
277 | tmp |= DC_LB_MEMORY_SPLIT_D1HALF_D2HALF; | 197 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1HALF_D2HALF; |
278 | } else | 198 | } else |
279 | tmp |= AVIVO_DC_LB_MEMORY_SPLIT_D1HALF_D2HALF; | 199 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1HALF_D2HALF; |
280 | } else if (mode1) { | 200 | } else if (mode1) { |
281 | tmp |= DC_LB_MEMORY_SPLIT_D1_ONLY; | 201 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1_ONLY; |
282 | } else if (mode2) { | 202 | } else if (mode2) { |
283 | tmp |= DC_LB_MEMORY_SPLIT_D1_1Q_D2_3Q; | 203 | tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1_1Q_D2_3Q; |
284 | } | 204 | } |
285 | WREG32(DC_LB_MEMORY_SPLIT, tmp); | 205 | WREG32(R_006520_DC_LB_MEMORY_SPLIT, tmp); |
286 | } | 206 | } |
287 | 207 | ||
288 | struct rs690_watermark { | 208 | struct rs690_watermark { |
@@ -487,28 +407,28 @@ void rs690_bandwidth_update(struct radeon_device *rdev) | |||
487 | * option. | 407 | * option. |
488 | */ | 408 | */ |
489 | if (rdev->disp_priority == 2) { | 409 | if (rdev->disp_priority == 2) { |
490 | tmp = RREG32_MC(MC_INIT_MISC_LAT_TIMER); | 410 | tmp = RREG32_MC(R_000104_MC_INIT_MISC_LAT_TIMER); |
491 | tmp &= ~MC_DISP1R_INIT_LAT_MASK; | 411 | tmp &= C_000104_MC_DISP0R_INIT_LAT; |
492 | tmp &= ~MC_DISP0R_INIT_LAT_MASK; | 412 | tmp &= C_000104_MC_DISP1R_INIT_LAT; |
493 | if (mode1) | ||
494 | tmp |= (1 << MC_DISP1R_INIT_LAT_SHIFT); | ||
495 | if (mode0) | 413 | if (mode0) |
496 | tmp |= (1 << MC_DISP0R_INIT_LAT_SHIFT); | 414 | tmp |= S_000104_MC_DISP0R_INIT_LAT(1); |
497 | WREG32_MC(MC_INIT_MISC_LAT_TIMER, tmp); | 415 | if (mode1) |
416 | tmp |= S_000104_MC_DISP1R_INIT_LAT(1); | ||
417 | WREG32_MC(R_000104_MC_INIT_MISC_LAT_TIMER, tmp); | ||
498 | } | 418 | } |
499 | rs690_line_buffer_adjust(rdev, mode0, mode1); | 419 | rs690_line_buffer_adjust(rdev, mode0, mode1); |
500 | 420 | ||
501 | if ((rdev->family == CHIP_RS690) || (rdev->family == CHIP_RS740)) | 421 | if ((rdev->family == CHIP_RS690) || (rdev->family == CHIP_RS740)) |
502 | WREG32(DCP_CONTROL, 0); | 422 | WREG32(R_006C9C_DCP_CONTROL, 0); |
503 | if ((rdev->family == CHIP_RS780) || (rdev->family == CHIP_RS880)) | 423 | if ((rdev->family == CHIP_RS780) || (rdev->family == CHIP_RS880)) |
504 | WREG32(DCP_CONTROL, 2); | 424 | WREG32(R_006C9C_DCP_CONTROL, 2); |
505 | 425 | ||
506 | rs690_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[0], &wm0); | 426 | rs690_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[0], &wm0); |
507 | rs690_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[1], &wm1); | 427 | rs690_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[1], &wm1); |
508 | 428 | ||
509 | tmp = (wm0.lb_request_fifo_depth - 1); | 429 | tmp = (wm0.lb_request_fifo_depth - 1); |
510 | tmp |= (wm1.lb_request_fifo_depth - 1) << 16; | 430 | tmp |= (wm1.lb_request_fifo_depth - 1) << 16; |
511 | WREG32(LB_MAX_REQ_OUTSTANDING, tmp); | 431 | WREG32(R_006D58_LB_MAX_REQ_OUTSTANDING, tmp); |
512 | 432 | ||
513 | if (mode0 && mode1) { | 433 | if (mode0 && mode1) { |
514 | if (rfixed_trunc(wm0.dbpp) > 64) | 434 | if (rfixed_trunc(wm0.dbpp) > 64) |
@@ -561,10 +481,10 @@ void rs690_bandwidth_update(struct radeon_device *rdev) | |||
561 | priority_mark12.full = 0; | 481 | priority_mark12.full = 0; |
562 | if (wm1.priority_mark_max.full > priority_mark12.full) | 482 | if (wm1.priority_mark_max.full > priority_mark12.full) |
563 | priority_mark12.full = wm1.priority_mark_max.full; | 483 | priority_mark12.full = wm1.priority_mark_max.full; |
564 | WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); | 484 | WREG32(R_006548_D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); |
565 | WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); | 485 | WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); |
566 | WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); | 486 | WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); |
567 | WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); | 487 | WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); |
568 | } else if (mode0) { | 488 | } else if (mode0) { |
569 | if (rfixed_trunc(wm0.dbpp) > 64) | 489 | if (rfixed_trunc(wm0.dbpp) > 64) |
570 | a.full = rfixed_mul(wm0.dbpp, wm0.num_line_pair); | 490 | a.full = rfixed_mul(wm0.dbpp, wm0.num_line_pair); |
@@ -591,10 +511,12 @@ void rs690_bandwidth_update(struct radeon_device *rdev) | |||
591 | priority_mark02.full = 0; | 511 | priority_mark02.full = 0; |
592 | if (wm0.priority_mark_max.full > priority_mark02.full) | 512 | if (wm0.priority_mark_max.full > priority_mark02.full) |
593 | priority_mark02.full = wm0.priority_mark_max.full; | 513 | priority_mark02.full = wm0.priority_mark_max.full; |
594 | WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); | 514 | WREG32(R_006548_D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); |
595 | WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); | 515 | WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); |
596 | WREG32(D2MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF); | 516 | WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, |
597 | WREG32(D2MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF); | 517 | S_006D48_D2MODE_PRIORITY_A_OFF(1)); |
518 | WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, | ||
519 | S_006D4C_D2MODE_PRIORITY_B_OFF(1)); | ||
598 | } else { | 520 | } else { |
599 | if (rfixed_trunc(wm1.dbpp) > 64) | 521 | if (rfixed_trunc(wm1.dbpp) > 64) |
600 | a.full = rfixed_mul(wm1.dbpp, wm1.num_line_pair); | 522 | a.full = rfixed_mul(wm1.dbpp, wm1.num_line_pair); |
@@ -621,30 +543,204 @@ void rs690_bandwidth_update(struct radeon_device *rdev) | |||
621 | priority_mark12.full = 0; | 543 | priority_mark12.full = 0; |
622 | if (wm1.priority_mark_max.full > priority_mark12.full) | 544 | if (wm1.priority_mark_max.full > priority_mark12.full) |
623 | priority_mark12.full = wm1.priority_mark_max.full; | 545 | priority_mark12.full = wm1.priority_mark_max.full; |
624 | WREG32(D1MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF); | 546 | WREG32(R_006548_D1MODE_PRIORITY_A_CNT, |
625 | WREG32(D1MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF); | 547 | S_006548_D1MODE_PRIORITY_A_OFF(1)); |
626 | WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); | 548 | WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, |
627 | WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); | 549 | S_00654C_D1MODE_PRIORITY_B_OFF(1)); |
550 | WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); | ||
551 | WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); | ||
628 | } | 552 | } |
629 | } | 553 | } |
630 | 554 | ||
631 | /* | ||
632 | * Indirect registers accessor | ||
633 | */ | ||
634 | uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 555 | uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
635 | { | 556 | { |
636 | uint32_t r; | 557 | uint32_t r; |
637 | 558 | ||
638 | WREG32(RS690_MC_INDEX, (reg & RS690_MC_INDEX_MASK)); | 559 | WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg)); |
639 | r = RREG32(RS690_MC_DATA); | 560 | r = RREG32(R_00007C_MC_DATA); |
640 | WREG32(RS690_MC_INDEX, RS690_MC_INDEX_MASK); | 561 | WREG32(R_000078_MC_INDEX, ~C_000078_MC_IND_ADDR); |
641 | return r; | 562 | return r; |
642 | } | 563 | } |
643 | 564 | ||
644 | void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 565 | void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
645 | { | 566 | { |
646 | WREG32(RS690_MC_INDEX, | 567 | WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg) | |
647 | RS690_MC_INDEX_WR_EN | ((reg) & RS690_MC_INDEX_MASK)); | 568 | S_000078_MC_IND_WR_EN(1)); |
648 | WREG32(RS690_MC_DATA, v); | 569 | WREG32(R_00007C_MC_DATA, v); |
649 | WREG32(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK); | 570 | WREG32(R_000078_MC_INDEX, 0x7F); |
571 | } | ||
572 | |||
573 | void rs690_mc_program(struct radeon_device *rdev) | ||
574 | { | ||
575 | struct rv515_mc_save save; | ||
576 | |||
577 | /* Stops all mc clients */ | ||
578 | rv515_mc_stop(rdev, &save); | ||
579 | |||
580 | /* Wait for mc idle */ | ||
581 | if (rs690_mc_wait_for_idle(rdev)) | ||
582 | dev_warn(rdev->dev, "Wait MC idle timeout before updating MC.\n"); | ||
583 | /* Program MC, should be a 32bits limited address space */ | ||
584 | WREG32_MC(R_000100_MCCFG_FB_LOCATION, | ||
585 | S_000100_MC_FB_START(rdev->mc.vram_start >> 16) | | ||
586 | S_000100_MC_FB_TOP(rdev->mc.vram_end >> 16)); | ||
587 | WREG32(R_000134_HDP_FB_LOCATION, | ||
588 | S_000134_HDP_FB_START(rdev->mc.vram_start >> 16)); | ||
589 | |||
590 | rv515_mc_resume(rdev, &save); | ||
591 | } | ||
592 | |||
593 | static int rs690_startup(struct radeon_device *rdev) | ||
594 | { | ||
595 | int r; | ||
596 | |||
597 | rs690_mc_program(rdev); | ||
598 | /* Resume clock */ | ||
599 | rv515_clock_startup(rdev); | ||
600 | /* Initialize GPU configuration (# pipes, ...) */ | ||
601 | rs690_gpu_init(rdev); | ||
602 | /* Initialize GART (initialize after TTM so we can allocate | ||
603 | * memory through TTM but finalize after TTM) */ | ||
604 | r = rs400_gart_enable(rdev); | ||
605 | if (r) | ||
606 | return r; | ||
607 | /* Enable IRQ */ | ||
608 | rdev->irq.sw_int = true; | ||
609 | r100_irq_set(rdev); | ||
610 | /* 1M ring buffer */ | ||
611 | r = r100_cp_init(rdev, 1024 * 1024); | ||
612 | if (r) { | ||
613 | dev_err(rdev->dev, "failled initializing CP (%d).\n", r); | ||
614 | return r; | ||
615 | } | ||
616 | r = r100_wb_init(rdev); | ||
617 | if (r) | ||
618 | dev_err(rdev->dev, "failled initializing WB (%d).\n", r); | ||
619 | r = r100_ib_init(rdev); | ||
620 | if (r) { | ||
621 | dev_err(rdev->dev, "failled initializing IB (%d).\n", r); | ||
622 | return r; | ||
623 | } | ||
624 | return 0; | ||
625 | } | ||
626 | |||
627 | int rs690_resume(struct radeon_device *rdev) | ||
628 | { | ||
629 | /* Make sur GART are not working */ | ||
630 | rs400_gart_disable(rdev); | ||
631 | /* Resume clock before doing reset */ | ||
632 | rv515_clock_startup(rdev); | ||
633 | /* Reset gpu before posting otherwise ATOM will enter infinite loop */ | ||
634 | if (radeon_gpu_reset(rdev)) { | ||
635 | dev_warn(rdev->dev, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", | ||
636 | RREG32(R_000E40_RBBM_STATUS), | ||
637 | RREG32(R_0007C0_CP_STAT)); | ||
638 | } | ||
639 | /* post */ | ||
640 | atom_asic_init(rdev->mode_info.atom_context); | ||
641 | /* Resume clock after posting */ | ||
642 | rv515_clock_startup(rdev); | ||
643 | return rs690_startup(rdev); | ||
644 | } | ||
645 | |||
646 | int rs690_suspend(struct radeon_device *rdev) | ||
647 | { | ||
648 | r100_cp_disable(rdev); | ||
649 | r100_wb_disable(rdev); | ||
650 | r100_irq_disable(rdev); | ||
651 | rs400_gart_disable(rdev); | ||
652 | return 0; | ||
653 | } | ||
654 | |||
655 | void rs690_fini(struct radeon_device *rdev) | ||
656 | { | ||
657 | rs690_suspend(rdev); | ||
658 | r100_cp_fini(rdev); | ||
659 | r100_wb_fini(rdev); | ||
660 | r100_ib_fini(rdev); | ||
661 | radeon_gem_fini(rdev); | ||
662 | rs400_gart_fini(rdev); | ||
663 | radeon_irq_kms_fini(rdev); | ||
664 | radeon_fence_driver_fini(rdev); | ||
665 | radeon_object_fini(rdev); | ||
666 | radeon_atombios_fini(rdev); | ||
667 | kfree(rdev->bios); | ||
668 | rdev->bios = NULL; | ||
669 | } | ||
670 | |||
671 | int rs690_init(struct radeon_device *rdev) | ||
672 | { | ||
673 | int r; | ||
674 | |||
675 | rdev->new_init_path = true; | ||
676 | /* Disable VGA */ | ||
677 | rv515_vga_render_disable(rdev); | ||
678 | /* Initialize scratch registers */ | ||
679 | radeon_scratch_init(rdev); | ||
680 | /* Initialize surface registers */ | ||
681 | radeon_surface_init(rdev); | ||
682 | /* TODO: disable VGA need to use VGA request */ | ||
683 | /* BIOS*/ | ||
684 | if (!radeon_get_bios(rdev)) { | ||
685 | if (ASIC_IS_AVIVO(rdev)) | ||
686 | return -EINVAL; | ||
687 | } | ||
688 | if (rdev->is_atom_bios) { | ||
689 | r = radeon_atombios_init(rdev); | ||
690 | if (r) | ||
691 | return r; | ||
692 | } else { | ||
693 | dev_err(rdev->dev, "Expecting atombios for RV515 GPU\n"); | ||
694 | return -EINVAL; | ||
695 | } | ||
696 | /* Reset gpu before posting otherwise ATOM will enter infinite loop */ | ||
697 | if (radeon_gpu_reset(rdev)) { | ||
698 | dev_warn(rdev->dev, | ||
699 | "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", | ||
700 | RREG32(R_000E40_RBBM_STATUS), | ||
701 | RREG32(R_0007C0_CP_STAT)); | ||
702 | } | ||
703 | /* check if cards are posted or not */ | ||
704 | if (!radeon_card_posted(rdev) && rdev->bios) { | ||
705 | DRM_INFO("GPU not posted. posting now...\n"); | ||
706 | atom_asic_init(rdev->mode_info.atom_context); | ||
707 | } | ||
708 | /* Initialize clocks */ | ||
709 | radeon_get_clock_info(rdev->ddev); | ||
710 | /* Get vram informations */ | ||
711 | rs690_vram_info(rdev); | ||
712 | /* Initialize memory controller (also test AGP) */ | ||
713 | r = r420_mc_init(rdev); | ||
714 | if (r) | ||
715 | return r; | ||
716 | rv515_debugfs(rdev); | ||
717 | /* Fence driver */ | ||
718 | r = radeon_fence_driver_init(rdev); | ||
719 | if (r) | ||
720 | return r; | ||
721 | r = radeon_irq_kms_init(rdev); | ||
722 | if (r) | ||
723 | return r; | ||
724 | /* Memory manager */ | ||
725 | r = radeon_object_init(rdev); | ||
726 | if (r) | ||
727 | return r; | ||
728 | r = rs400_gart_init(rdev); | ||
729 | if (r) | ||
730 | return r; | ||
731 | rs600_set_safe_registers(rdev); | ||
732 | rdev->accel_working = true; | ||
733 | r = rs690_startup(rdev); | ||
734 | if (r) { | ||
735 | /* Somethings want wront with the accel init stop accel */ | ||
736 | dev_err(rdev->dev, "Disabling GPU acceleration\n"); | ||
737 | rs690_suspend(rdev); | ||
738 | r100_cp_fini(rdev); | ||
739 | r100_wb_fini(rdev); | ||
740 | r100_ib_fini(rdev); | ||
741 | rs400_gart_fini(rdev); | ||
742 | radeon_irq_kms_fini(rdev); | ||
743 | rdev->accel_working = false; | ||
744 | } | ||
745 | return 0; | ||
650 | } | 746 | } |