aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/r100.c
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2009-09-11 09:35:22 -0400
committerDave Airlie <airlied@redhat.com>2009-09-14 02:09:59 -0400
commit9f022ddfb23793b475ff7e57ac08a766dd5d31bd (patch)
treeb90a004e7eaf6f79f52ac112abbe44abec141613 /drivers/gpu/drm/radeon/r100.c
parentd42571efe33552cd519b7f3800a788b5f2d51798 (diff)
drm/radeon/kms: convert r4xx to new init path
This convert r4xx to new init path it also fix few bugs. Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/r100.c')
-rw-r--r--drivers/gpu/drm/radeon/r100.c114
1 files changed, 108 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 4dd5ca50c0c5..47263d3ede98 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -299,6 +299,17 @@ int r100_irq_set(struct radeon_device *rdev)
299 return 0; 299 return 0;
300} 300}
301 301
302void r100_irq_disable(struct radeon_device *rdev)
303{
304 u32 tmp;
305
306 WREG32(R_000040_GEN_INT_CNTL, 0);
307 /* Wait and acknowledge irq */
308 mdelay(1);
309 tmp = RREG32(R_000044_GEN_INT_STATUS);
310 WREG32(R_000044_GEN_INT_STATUS, tmp);
311}
312
302static inline uint32_t r100_irq_ack(struct radeon_device *rdev) 313static inline uint32_t r100_irq_ack(struct radeon_device *rdev)
303{ 314{
304 uint32_t irqs = RREG32(RADEON_GEN_INT_STATUS); 315 uint32_t irqs = RREG32(RADEON_GEN_INT_STATUS);
@@ -396,14 +407,21 @@ int r100_wb_init(struct radeon_device *rdev)
396 return r; 407 return r;
397 } 408 }
398 } 409 }
399 WREG32(RADEON_SCRATCH_ADDR, rdev->wb.gpu_addr); 410 WREG32(R_000774_SCRATCH_ADDR, rdev->wb.gpu_addr);
400 WREG32(RADEON_CP_RB_RPTR_ADDR, rdev->wb.gpu_addr + 1024); 411 WREG32(R_00070C_CP_RB_RPTR_ADDR,
401 WREG32(RADEON_SCRATCH_UMSK, 0xff); 412 S_00070C_RB_RPTR_ADDR((rdev->wb.gpu_addr + 1024) >> 2));
413 WREG32(R_000770_SCRATCH_UMSK, 0xff);
402 return 0; 414 return 0;
403} 415}
404 416
417void r100_wb_disable(struct radeon_device *rdev)
418{
419 WREG32(R_000770_SCRATCH_UMSK, 0);
420}
421
405void r100_wb_fini(struct radeon_device *rdev) 422void r100_wb_fini(struct radeon_device *rdev)
406{ 423{
424 r100_wb_disable(rdev);
407 if (rdev->wb.wb_obj) { 425 if (rdev->wb.wb_obj) {
408 radeon_object_kunmap(rdev->wb.wb_obj); 426 radeon_object_kunmap(rdev->wb.wb_obj);
409 radeon_object_unpin(rdev->wb.wb_obj); 427 radeon_object_unpin(rdev->wb.wb_obj);
@@ -1581,11 +1599,12 @@ static int r100_packet3_check(struct radeon_cs_parser *p,
1581int r100_cs_parse(struct radeon_cs_parser *p) 1599int r100_cs_parse(struct radeon_cs_parser *p)
1582{ 1600{
1583 struct radeon_cs_packet pkt; 1601 struct radeon_cs_packet pkt;
1584 struct r100_cs_track track; 1602 struct r100_cs_track *track;
1585 int r; 1603 int r;
1586 1604
1587 r100_cs_track_clear(p->rdev, &track); 1605 track = kzalloc(sizeof(*track), GFP_KERNEL);
1588 p->track = &track; 1606 r100_cs_track_clear(p->rdev, track);
1607 p->track = track;
1589 do { 1608 do {
1590 r = r100_cs_packet_parse(p, &pkt, p->idx); 1609 r = r100_cs_packet_parse(p, &pkt, p->idx);
1591 if (r) { 1610 if (r) {
@@ -3085,3 +3104,86 @@ int r100_ib_test(struct radeon_device *rdev)
3085 radeon_ib_free(rdev, &ib); 3104 radeon_ib_free(rdev, &ib);
3086 return r; 3105 return r;
3087} 3106}
3107
3108void r100_ib_fini(struct radeon_device *rdev)
3109{
3110 radeon_ib_pool_fini(rdev);
3111}
3112
3113int r100_ib_init(struct radeon_device *rdev)
3114{
3115 int r;
3116
3117 r = radeon_ib_pool_init(rdev);
3118 if (r) {
3119 dev_err(rdev->dev, "failled initializing IB pool (%d).\n", r);
3120 r100_ib_fini(rdev);
3121 return r;
3122 }
3123 r = r100_ib_test(rdev);
3124 if (r) {
3125 dev_err(rdev->dev, "failled testing IB (%d).\n", r);
3126 r100_ib_fini(rdev);
3127 return r;
3128 }
3129 return 0;
3130}
3131
3132void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save)
3133{
3134 /* Shutdown CP we shouldn't need to do that but better be safe than
3135 * sorry
3136 */
3137 rdev->cp.ready = false;
3138 WREG32(R_000740_CP_CSQ_CNTL, 0);
3139
3140 /* Save few CRTC registers */
3141 save->GENMO_WT = RREG32(R_0003C0_GENMO_WT);
3142 save->CRTC_EXT_CNTL = RREG32(R_000054_CRTC_EXT_CNTL);
3143 save->CRTC_GEN_CNTL = RREG32(R_000050_CRTC_GEN_CNTL);
3144 save->CUR_OFFSET = RREG32(R_000260_CUR_OFFSET);
3145 if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
3146 save->CRTC2_GEN_CNTL = RREG32(R_0003F8_CRTC2_GEN_CNTL);
3147 save->CUR2_OFFSET = RREG32(R_000360_CUR2_OFFSET);
3148 }
3149
3150 /* Disable VGA aperture access */
3151 WREG32(R_0003C0_GENMO_WT, C_0003C0_VGA_RAM_EN & save->GENMO_WT);
3152 /* Disable cursor, overlay, crtc */
3153 WREG32(R_000260_CUR_OFFSET, save->CUR_OFFSET | S_000260_CUR_LOCK(1));
3154 WREG32(R_000054_CRTC_EXT_CNTL, save->CRTC_EXT_CNTL |
3155 S_000054_CRTC_DISPLAY_DIS(1));
3156 WREG32(R_000050_CRTC_GEN_CNTL,
3157 (C_000050_CRTC_CUR_EN & save->CRTC_GEN_CNTL) |
3158 S_000050_CRTC_DISP_REQ_EN_B(1));
3159 WREG32(R_000420_OV0_SCALE_CNTL,
3160 C_000420_OV0_OVERLAY_EN & RREG32(R_000420_OV0_SCALE_CNTL));
3161 WREG32(R_000260_CUR_OFFSET, C_000260_CUR_LOCK & save->CUR_OFFSET);
3162 if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
3163 WREG32(R_000360_CUR2_OFFSET, save->CUR2_OFFSET |
3164 S_000360_CUR2_LOCK(1));
3165 WREG32(R_0003F8_CRTC2_GEN_CNTL,
3166 (C_0003F8_CRTC2_CUR_EN & save->CRTC2_GEN_CNTL) |
3167 S_0003F8_CRTC2_DISPLAY_DIS(1) |
3168 S_0003F8_CRTC2_DISP_REQ_EN_B(1));
3169 WREG32(R_000360_CUR2_OFFSET,
3170 C_000360_CUR2_LOCK & save->CUR2_OFFSET);
3171 }
3172}
3173
3174void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save)
3175{
3176 /* Update base address for crtc */
3177 WREG32(R_00023C_DISPLAY_BASE_ADDR, rdev->mc.vram_location);
3178 if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
3179 WREG32(R_00033C_CRTC2_DISPLAY_BASE_ADDR,
3180 rdev->mc.vram_location);
3181 }
3182 /* Restore CRTC registers */
3183 WREG32(R_0003C0_GENMO_WT, save->GENMO_WT);
3184 WREG32(R_000054_CRTC_EXT_CNTL, save->CRTC_EXT_CNTL);
3185 WREG32(R_000050_CRTC_GEN_CNTL, save->CRTC_GEN_CNTL);
3186 if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
3187 WREG32(R_0003F8_CRTC2_GEN_CNTL, save->CRTC2_GEN_CNTL);
3188 }
3189}