aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon.h')
-rw-r--r--drivers/gpu/drm/radeon/radeon.h142
1 files changed, 129 insertions, 13 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index d61f2fc61df5..b519fb2fecbb 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -64,6 +64,7 @@ extern int radeon_agpmode;
64extern int radeon_vram_limit; 64extern int radeon_vram_limit;
65extern int radeon_gart_size; 65extern int radeon_gart_size;
66extern int radeon_benchmarking; 66extern int radeon_benchmarking;
67extern int radeon_testing;
67extern int radeon_connector_table; 68extern int radeon_connector_table;
68 69
69/* 70/*
@@ -113,6 +114,7 @@ enum radeon_family {
113 CHIP_RV770, 114 CHIP_RV770,
114 CHIP_RV730, 115 CHIP_RV730,
115 CHIP_RV710, 116 CHIP_RV710,
117 CHIP_RS880,
116 CHIP_LAST, 118 CHIP_LAST,
117}; 119};
118 120
@@ -201,6 +203,14 @@ int radeon_fence_wait_last(struct radeon_device *rdev);
201struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence); 203struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
202void radeon_fence_unref(struct radeon_fence **fence); 204void radeon_fence_unref(struct radeon_fence **fence);
203 205
206/*
207 * Tiling registers
208 */
209struct radeon_surface_reg {
210 struct radeon_object *robj;
211};
212
213#define RADEON_GEM_MAX_SURFACES 8
204 214
205/* 215/*
206 * Radeon buffer. 216 * Radeon buffer.
@@ -213,6 +223,7 @@ struct radeon_object_list {
213 uint64_t gpu_offset; 223 uint64_t gpu_offset;
214 unsigned rdomain; 224 unsigned rdomain;
215 unsigned wdomain; 225 unsigned wdomain;
226 uint32_t tiling_flags;
216}; 227};
217 228
218int radeon_object_init(struct radeon_device *rdev); 229int radeon_object_init(struct radeon_device *rdev);
@@ -231,6 +242,7 @@ int radeon_object_pin(struct radeon_object *robj, uint32_t domain,
231 uint64_t *gpu_addr); 242 uint64_t *gpu_addr);
232void radeon_object_unpin(struct radeon_object *robj); 243void radeon_object_unpin(struct radeon_object *robj);
233int radeon_object_wait(struct radeon_object *robj); 244int radeon_object_wait(struct radeon_object *robj);
245int radeon_object_busy_domain(struct radeon_object *robj, uint32_t *cur_placement);
234int radeon_object_evict_vram(struct radeon_device *rdev); 246int radeon_object_evict_vram(struct radeon_device *rdev);
235int radeon_object_mmap(struct radeon_object *robj, uint64_t *offset); 247int radeon_object_mmap(struct radeon_object *robj, uint64_t *offset);
236void radeon_object_force_delete(struct radeon_device *rdev); 248void radeon_object_force_delete(struct radeon_device *rdev);
@@ -242,8 +254,15 @@ void radeon_object_list_clean(struct list_head *head);
242int radeon_object_fbdev_mmap(struct radeon_object *robj, 254int radeon_object_fbdev_mmap(struct radeon_object *robj,
243 struct vm_area_struct *vma); 255 struct vm_area_struct *vma);
244unsigned long radeon_object_size(struct radeon_object *robj); 256unsigned long radeon_object_size(struct radeon_object *robj);
245 257void radeon_object_clear_surface_reg(struct radeon_object *robj);
246 258int radeon_object_check_tiling(struct radeon_object *robj, bool has_moved,
259 bool force_drop);
260void radeon_object_set_tiling_flags(struct radeon_object *robj,
261 uint32_t tiling_flags, uint32_t pitch);
262void radeon_object_get_tiling_flags(struct radeon_object *robj, uint32_t *tiling_flags, uint32_t *pitch);
263void radeon_bo_move_notify(struct ttm_buffer_object *bo,
264 struct ttm_mem_reg *mem);
265void radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
247/* 266/*
248 * GEM objects. 267 * GEM objects.
249 */ 268 */
@@ -315,8 +334,11 @@ struct radeon_mc {
315 unsigned gtt_location; 334 unsigned gtt_location;
316 unsigned gtt_size; 335 unsigned gtt_size;
317 unsigned vram_location; 336 unsigned vram_location;
318 unsigned vram_size; 337 /* for some chips with <= 32MB we need to lie
338 * about vram size near mc fb location */
339 unsigned mc_vram_size;
319 unsigned vram_width; 340 unsigned vram_width;
341 unsigned real_vram_size;
320 int vram_mtrr; 342 int vram_mtrr;
321 bool vram_is_ddr; 343 bool vram_is_ddr;
322}; 344};
@@ -474,6 +496,39 @@ struct radeon_wb {
474 uint64_t gpu_addr; 496 uint64_t gpu_addr;
475}; 497};
476 498
499/**
500 * struct radeon_pm - power management datas
501 * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
502 * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
503 * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
504 * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
505 * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
506 * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
507 * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
508 * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
509 * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
510 * @sclk: GPU clock Mhz (core bandwith depends of this clock)
511 * @needed_bandwidth: current bandwidth needs
512 *
513 * It keeps track of various data needed to take powermanagement decision.
514 * Bandwith need is used to determine minimun clock of the GPU and memory.
515 * Equation between gpu/memory clock and available bandwidth is hw dependent
516 * (type of memory, bus size, efficiency, ...)
517 */
518struct radeon_pm {
519 fixed20_12 max_bandwidth;
520 fixed20_12 igp_sideport_mclk;
521 fixed20_12 igp_system_mclk;
522 fixed20_12 igp_ht_link_clk;
523 fixed20_12 igp_ht_link_width;
524 fixed20_12 k8_bandwidth;
525 fixed20_12 sideport_bandwidth;
526 fixed20_12 ht_bandwidth;
527 fixed20_12 core_bandwidth;
528 fixed20_12 sclk;
529 fixed20_12 needed_bandwidth;
530};
531
477 532
478/* 533/*
479 * Benchmarking 534 * Benchmarking
@@ -482,6 +537,12 @@ void radeon_benchmark(struct radeon_device *rdev);
482 537
483 538
484/* 539/*
540 * Testing
541 */
542void radeon_test_moves(struct radeon_device *rdev);
543
544
545/*
485 * Debugfs 546 * Debugfs
486 */ 547 */
487int radeon_debugfs_add_files(struct radeon_device *rdev, 548int radeon_debugfs_add_files(struct radeon_device *rdev,
@@ -514,6 +575,7 @@ struct radeon_asic {
514 void (*ring_start)(struct radeon_device *rdev); 575 void (*ring_start)(struct radeon_device *rdev);
515 int (*irq_set)(struct radeon_device *rdev); 576 int (*irq_set)(struct radeon_device *rdev);
516 int (*irq_process)(struct radeon_device *rdev); 577 int (*irq_process)(struct radeon_device *rdev);
578 u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
517 void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence); 579 void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence);
518 int (*cs_parse)(struct radeon_cs_parser *p); 580 int (*cs_parse)(struct radeon_cs_parser *p);
519 int (*copy_blit)(struct radeon_device *rdev, 581 int (*copy_blit)(struct radeon_device *rdev,
@@ -535,6 +597,11 @@ struct radeon_asic {
535 void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock); 597 void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
536 void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes); 598 void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
537 void (*set_clock_gating)(struct radeon_device *rdev, int enable); 599 void (*set_clock_gating)(struct radeon_device *rdev, int enable);
600 int (*set_surface_reg)(struct radeon_device *rdev, int reg,
601 uint32_t tiling_flags, uint32_t pitch,
602 uint32_t offset, uint32_t obj_size);
603 int (*clear_surface_reg)(struct radeon_device *rdev, int reg);
604 void (*bandwidth_update)(struct radeon_device *rdev);
538}; 605};
539 606
540union radeon_asic_config { 607union radeon_asic_config {
@@ -566,6 +633,10 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
566int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, 633int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
567 struct drm_file *filp); 634 struct drm_file *filp);
568int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp); 635int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
636int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
637 struct drm_file *filp);
638int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
639 struct drm_file *filp);
569 640
570 641
571/* 642/*
@@ -584,6 +655,7 @@ struct radeon_device {
584 int usec_timeout; 655 int usec_timeout;
585 enum radeon_pll_errata pll_errata; 656 enum radeon_pll_errata pll_errata;
586 int num_gb_pipes; 657 int num_gb_pipes;
658 int num_z_pipes;
587 int disp_priority; 659 int disp_priority;
588 /* BIOS */ 660 /* BIOS */
589 uint8_t *bios; 661 uint8_t *bios;
@@ -594,17 +666,14 @@ struct radeon_device {
594 struct radeon_object *fbdev_robj; 666 struct radeon_object *fbdev_robj;
595 struct radeon_framebuffer *fbdev_rfb; 667 struct radeon_framebuffer *fbdev_rfb;
596 /* Register mmio */ 668 /* Register mmio */
597 unsigned long rmmio_base; 669 resource_size_t rmmio_base;
598 unsigned long rmmio_size; 670 resource_size_t rmmio_size;
599 void *rmmio; 671 void *rmmio;
600 radeon_rreg_t mm_rreg;
601 radeon_wreg_t mm_wreg;
602 radeon_rreg_t mc_rreg; 672 radeon_rreg_t mc_rreg;
603 radeon_wreg_t mc_wreg; 673 radeon_wreg_t mc_wreg;
604 radeon_rreg_t pll_rreg; 674 radeon_rreg_t pll_rreg;
605 radeon_wreg_t pll_wreg; 675 radeon_wreg_t pll_wreg;
606 radeon_rreg_t pcie_rreg; 676 uint32_t pcie_reg_mask;
607 radeon_wreg_t pcie_wreg;
608 radeon_rreg_t pciep_rreg; 677 radeon_rreg_t pciep_rreg;
609 radeon_wreg_t pciep_wreg; 678 radeon_wreg_t pciep_wreg;
610 struct radeon_clock clock; 679 struct radeon_clock clock;
@@ -619,11 +688,14 @@ struct radeon_device {
619 struct radeon_irq irq; 688 struct radeon_irq irq;
620 struct radeon_asic *asic; 689 struct radeon_asic *asic;
621 struct radeon_gem gem; 690 struct radeon_gem gem;
691 struct radeon_pm pm;
622 struct mutex cs_mutex; 692 struct mutex cs_mutex;
623 struct radeon_wb wb; 693 struct radeon_wb wb;
624 bool gpu_lockup; 694 bool gpu_lockup;
625 bool shutdown; 695 bool shutdown;
626 bool suspend; 696 bool suspend;
697 bool need_dma32;
698 struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
627}; 699};
628 700
629int radeon_device_init(struct radeon_device *rdev, 701int radeon_device_init(struct radeon_device *rdev,
@@ -633,22 +705,42 @@ int radeon_device_init(struct radeon_device *rdev,
633void radeon_device_fini(struct radeon_device *rdev); 705void radeon_device_fini(struct radeon_device *rdev);
634int radeon_gpu_wait_for_idle(struct radeon_device *rdev); 706int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
635 707
708static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg)
709{
710 if (reg < 0x10000)
711 return readl(((void __iomem *)rdev->rmmio) + reg);
712 else {
713 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
714 return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
715 }
716}
717
718static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
719{
720 if (reg < 0x10000)
721 writel(v, ((void __iomem *)rdev->rmmio) + reg);
722 else {
723 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
724 writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
725 }
726}
727
636 728
637/* 729/*
638 * Registers read & write functions. 730 * Registers read & write functions.
639 */ 731 */
640#define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) 732#define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg))
641#define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) 733#define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg))
642#define RREG32(reg) rdev->mm_rreg(rdev, (reg)) 734#define RREG32(reg) r100_mm_rreg(rdev, (reg))
643#define WREG32(reg, v) rdev->mm_wreg(rdev, (reg), (v)) 735#define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
644#define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) 736#define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
645#define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) 737#define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
646#define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg)) 738#define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
647#define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v)) 739#define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
648#define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg)) 740#define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
649#define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v)) 741#define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
650#define RREG32_PCIE(reg) rdev->pcie_rreg(rdev, (reg)) 742#define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
651#define WREG32_PCIE(reg, v) rdev->pcie_wreg(rdev, (reg), (v)) 743#define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
652#define WREG32_P(reg, val, mask) \ 744#define WREG32_P(reg, val, mask) \
653 do { \ 745 do { \
654 uint32_t tmp_ = RREG32(reg); \ 746 uint32_t tmp_ = RREG32(reg); \
@@ -664,12 +756,32 @@ int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
664 WREG32_PLL(reg, tmp_); \ 756 WREG32_PLL(reg, tmp_); \
665 } while (0) 757 } while (0)
666 758
759/*
760 * Indirect registers accessor
761 */
762static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
763{
764 uint32_t r;
765
766 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
767 r = RREG32(RADEON_PCIE_DATA);
768 return r;
769}
770
771static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
772{
773 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
774 WREG32(RADEON_PCIE_DATA, (v));
775}
776
667void r100_pll_errata_after_index(struct radeon_device *rdev); 777void r100_pll_errata_after_index(struct radeon_device *rdev);
668 778
669 779
670/* 780/*
671 * ASICs helpers. 781 * ASICs helpers.
672 */ 782 */
783#define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
784 (rdev->pdev->device == 0x5969))
673#define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \ 785#define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
674 (rdev->family == CHIP_RV200) || \ 786 (rdev->family == CHIP_RV200) || \
675 (rdev->family == CHIP_RS100) || \ 787 (rdev->family == CHIP_RS100) || \
@@ -788,6 +900,7 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
788#define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) 900#define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
789#define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) 901#define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
790#define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) 902#define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
903#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
791#define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence)) 904#define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence))
792#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f)) 905#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
793#define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f)) 906#define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
@@ -796,5 +909,8 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
796#define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e)) 909#define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
797#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l)) 910#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
798#define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e)) 911#define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
912#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
913#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
914#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
799 915
800#endif 916#endif