diff options
author | Dave Airlie <airlied@redhat.com> | 2016-09-19 16:17:38 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-09-19 16:17:38 -0400 |
commit | bd4a68da1989a3735b9c183422effc177e2d5ae8 (patch) | |
tree | a7ad047fc3ecebdeb2f671c6d0710b44155e21b9 | |
parent | 9f8cf165c62913244479832f04c44cd77ffc9293 (diff) | |
parent | af1f85ddecfa341e684db950c34a1813d36750db (diff) |
Merge branch 'drm-next-4.9' of git://people.freedesktop.org/~agd5f/linux into drm-next
More radeon and amdgpu changes for 4.9. Highlights:
- Initial SI support for amdgpu (controlled by a Kconfig option)
- misc ttm cleanups
- runtimepm fixes
- S3/S4 fixes
- power improvements
- lots of code cleanups and optimizations
* 'drm-next-4.9' of git://people.freedesktop.org/~agd5f/linux: (151 commits)
drm/ttm: remove cpu_address member from ttm_tt
drm/radeon/radeon_device: remove unused function
drm/amdgpu: clean function declarations in amdgpu_ttm.c up
drm/amdgpu: use the new ring ib and dma frame size callbacks (v2)
drm/amdgpu/vce3: add ring callbacks for ib and dma frame size
drm/amdgpu/vce2: add ring callbacks for ib and dma frame size
drm/amdgpu/vce: add common ring callbacks for ib and dma frame size
drm/amdgpu/uvd6: add ring callbacks for ib and dma frame size
drm/amdgpu/uvd5: add ring callbacks for ib and dma frame size
drm/amdgpu/uvd4.2: add ring callbacks for ib and dma frame size
drm/amdgpu/sdma3: add ring callbacks for ib and dma frame size
drm/amdgpu/sdma2.4: add ring callbacks for ib and dma frame size
drm/amdgpu/cik_sdma: add ring callbacks for ib and dma frame size
drm/amdgpu/si_dma: add ring callbacks for ib and dma frame size
drm/amdgpu/gfx8: add ring callbacks for ib and dma frame size
drm/amdgpu/gfx7: add ring callbacks for ib and dma frame size
drm/amdgpu/gfx6: add ring callbacks for ib and dma frame size
drm/amdgpu/ring: add an interface to get dma frame and ib size
drm/amdgpu/sdma3: drop unused functions
drm/amdgpu/gfx6: drop gds_switch callback
...
111 files changed, 26351 insertions, 842 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig index f3cb69de0c44..53cf3971dfc3 100644 --- a/drivers/gpu/drm/amd/amdgpu/Kconfig +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig | |||
@@ -1,3 +1,10 @@ | |||
1 | config DRM_AMDGPU_SI | ||
2 | bool "Enable amdgpu support for SI parts" | ||
3 | depends on DRM_AMDGPU | ||
4 | help | ||
5 | Choose this option if you want to enable experimental support | ||
6 | for SI asics. | ||
7 | |||
1 | config DRM_AMDGPU_CIK | 8 | config DRM_AMDGPU_CIK |
2 | bool "Enable amdgpu support for CIK parts" | 9 | bool "Enable amdgpu support for CIK parts" |
3 | depends on DRM_AMDGPU | 10 | depends on DRM_AMDGPU |
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 21dd7c00da15..dc6df075bafc 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -30,6 +30,8 @@ amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | |||
30 | ci_smc.o ci_dpm.o dce_v8_0.o gfx_v7_0.o cik_sdma.o uvd_v4_2.o vce_v2_0.o \ | 30 | ci_smc.o ci_dpm.o dce_v8_0.o gfx_v7_0.o cik_sdma.o uvd_v4_2.o vce_v2_0.o \ |
31 | amdgpu_amdkfd_gfx_v7.o | 31 | amdgpu_amdkfd_gfx_v7.o |
32 | 32 | ||
33 | amdgpu-$(CONFIG_DRM_AMDGPU_SI)+= si.o gmc_v6_0.o gfx_v6_0.o si_ih.o si_dma.o dce_v6_0.o si_dpm.o si_smc.o | ||
34 | |||
33 | amdgpu-y += \ | 35 | amdgpu-y += \ |
34 | vi.o | 36 | vi.o |
35 | 37 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 3cc2629eb158..ee45d9f7f3dc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -64,6 +64,7 @@ | |||
64 | extern int amdgpu_modeset; | 64 | extern int amdgpu_modeset; |
65 | extern int amdgpu_vram_limit; | 65 | extern int amdgpu_vram_limit; |
66 | extern int amdgpu_gart_size; | 66 | extern int amdgpu_gart_size; |
67 | extern int amdgpu_moverate; | ||
67 | extern int amdgpu_benchmarking; | 68 | extern int amdgpu_benchmarking; |
68 | extern int amdgpu_testing; | 69 | extern int amdgpu_testing; |
69 | extern int amdgpu_audio; | 70 | extern int amdgpu_audio; |
@@ -94,6 +95,7 @@ extern unsigned amdgpu_pg_mask; | |||
94 | extern char *amdgpu_disable_cu; | 95 | extern char *amdgpu_disable_cu; |
95 | extern int amdgpu_sclk_deep_sleep_en; | 96 | extern int amdgpu_sclk_deep_sleep_en; |
96 | extern char *amdgpu_virtual_display; | 97 | extern char *amdgpu_virtual_display; |
98 | extern unsigned amdgpu_pp_feature_mask; | ||
97 | 99 | ||
98 | #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 | 100 | #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 |
99 | #define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */ | 101 | #define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
@@ -108,7 +110,7 @@ extern char *amdgpu_virtual_display; | |||
108 | #define AMDGPU_MAX_RINGS 16 | 110 | #define AMDGPU_MAX_RINGS 16 |
109 | #define AMDGPU_MAX_GFX_RINGS 1 | 111 | #define AMDGPU_MAX_GFX_RINGS 1 |
110 | #define AMDGPU_MAX_COMPUTE_RINGS 8 | 112 | #define AMDGPU_MAX_COMPUTE_RINGS 8 |
111 | #define AMDGPU_MAX_VCE_RINGS 2 | 113 | #define AMDGPU_MAX_VCE_RINGS 3 |
112 | 114 | ||
113 | /* max number of IP instances */ | 115 | /* max number of IP instances */ |
114 | #define AMDGPU_MAX_SDMA_INSTANCES 2 | 116 | #define AMDGPU_MAX_SDMA_INSTANCES 2 |
@@ -318,6 +320,10 @@ struct amdgpu_ring_funcs { | |||
318 | /* note usage for clock and power gating */ | 320 | /* note usage for clock and power gating */ |
319 | void (*begin_use)(struct amdgpu_ring *ring); | 321 | void (*begin_use)(struct amdgpu_ring *ring); |
320 | void (*end_use)(struct amdgpu_ring *ring); | 322 | void (*end_use)(struct amdgpu_ring *ring); |
323 | void (*emit_switch_buffer) (struct amdgpu_ring *ring); | ||
324 | void (*emit_cntxcntl) (struct amdgpu_ring *ring, uint32_t flags); | ||
325 | unsigned (*get_emit_ib_size) (struct amdgpu_ring *ring); | ||
326 | unsigned (*get_dma_frame_size) (struct amdgpu_ring *ring); | ||
321 | }; | 327 | }; |
322 | 328 | ||
323 | /* | 329 | /* |
@@ -618,6 +624,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset, | |||
618 | int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, | 624 | int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, |
619 | int pages, struct page **pagelist, | 625 | int pages, struct page **pagelist, |
620 | dma_addr_t *dma_addr, uint32_t flags); | 626 | dma_addr_t *dma_addr, uint32_t flags); |
627 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev); | ||
621 | 628 | ||
622 | /* | 629 | /* |
623 | * GPU MC structures, functions & helpers | 630 | * GPU MC structures, functions & helpers |
@@ -963,6 +970,7 @@ struct amdgpu_ctx { | |||
963 | spinlock_t ring_lock; | 970 | spinlock_t ring_lock; |
964 | struct fence **fences; | 971 | struct fence **fences; |
965 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; | 972 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; |
973 | bool preamble_presented; | ||
966 | }; | 974 | }; |
967 | 975 | ||
968 | struct amdgpu_ctx_mgr { | 976 | struct amdgpu_ctx_mgr { |
@@ -1222,11 +1230,16 @@ struct amdgpu_cs_parser { | |||
1222 | struct fence *fence; | 1230 | struct fence *fence; |
1223 | uint64_t bytes_moved_threshold; | 1231 | uint64_t bytes_moved_threshold; |
1224 | uint64_t bytes_moved; | 1232 | uint64_t bytes_moved; |
1233 | struct amdgpu_bo_list_entry *evictable; | ||
1225 | 1234 | ||
1226 | /* user fence */ | 1235 | /* user fence */ |
1227 | struct amdgpu_bo_list_entry uf_entry; | 1236 | struct amdgpu_bo_list_entry uf_entry; |
1228 | }; | 1237 | }; |
1229 | 1238 | ||
1239 | #define AMDGPU_PREAMBLE_IB_PRESENT (1 << 0) /* bit set means command submit involves a preamble IB */ | ||
1240 | #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST (1 << 1) /* bit set means preamble IB is first presented in belonging context */ | ||
1241 | #define AMDGPU_HAVE_CTX_SWITCH (1 << 2) /* bit set means context switch occured */ | ||
1242 | |||
1230 | struct amdgpu_job { | 1243 | struct amdgpu_job { |
1231 | struct amd_sched_job base; | 1244 | struct amd_sched_job base; |
1232 | struct amdgpu_device *adev; | 1245 | struct amdgpu_device *adev; |
@@ -1235,9 +1248,10 @@ struct amdgpu_job { | |||
1235 | struct amdgpu_sync sync; | 1248 | struct amdgpu_sync sync; |
1236 | struct amdgpu_ib *ibs; | 1249 | struct amdgpu_ib *ibs; |
1237 | struct fence *fence; /* the hw fence */ | 1250 | struct fence *fence; /* the hw fence */ |
1251 | uint32_t preamble_status; | ||
1238 | uint32_t num_ibs; | 1252 | uint32_t num_ibs; |
1239 | void *owner; | 1253 | void *owner; |
1240 | uint64_t ctx; | 1254 | uint64_t fence_ctx; /* the fence_context this job uses */ |
1241 | bool vm_needs_flush; | 1255 | bool vm_needs_flush; |
1242 | unsigned vm_id; | 1256 | unsigned vm_id; |
1243 | uint64_t vm_pd_addr; | 1257 | uint64_t vm_pd_addr; |
@@ -1686,6 +1700,7 @@ struct amdgpu_vce { | |||
1686 | unsigned harvest_config; | 1700 | unsigned harvest_config; |
1687 | struct amd_sched_entity entity; | 1701 | struct amd_sched_entity entity; |
1688 | uint32_t srbm_soft_reset; | 1702 | uint32_t srbm_soft_reset; |
1703 | unsigned num_rings; | ||
1689 | }; | 1704 | }; |
1690 | 1705 | ||
1691 | /* | 1706 | /* |
@@ -1703,6 +1718,10 @@ struct amdgpu_sdma_instance { | |||
1703 | 1718 | ||
1704 | struct amdgpu_sdma { | 1719 | struct amdgpu_sdma { |
1705 | struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES]; | 1720 | struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES]; |
1721 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
1722 | //SI DMA has a difference trap irq number for the second engine | ||
1723 | struct amdgpu_irq_src trap_irq_1; | ||
1724 | #endif | ||
1706 | struct amdgpu_irq_src trap_irq; | 1725 | struct amdgpu_irq_src trap_irq; |
1707 | struct amdgpu_irq_src illegal_inst_irq; | 1726 | struct amdgpu_irq_src illegal_inst_irq; |
1708 | int num_instances; | 1727 | int num_instances; |
@@ -1819,6 +1838,9 @@ struct amdgpu_asic_funcs { | |||
1819 | int (*set_vce_clocks)(struct amdgpu_device *adev, u32 evclk, u32 ecclk); | 1838 | int (*set_vce_clocks)(struct amdgpu_device *adev, u32 evclk, u32 ecclk); |
1820 | /* query virtual capabilities */ | 1839 | /* query virtual capabilities */ |
1821 | u32 (*get_virtual_caps)(struct amdgpu_device *adev); | 1840 | u32 (*get_virtual_caps)(struct amdgpu_device *adev); |
1841 | /* static power management */ | ||
1842 | int (*get_pcie_lanes)(struct amdgpu_device *adev); | ||
1843 | void (*set_pcie_lanes)(struct amdgpu_device *adev, int lanes); | ||
1822 | }; | 1844 | }; |
1823 | 1845 | ||
1824 | /* | 1846 | /* |
@@ -1993,6 +2015,8 @@ struct amdgpu_device { | |||
1993 | spinlock_t pcie_idx_lock; | 2015 | spinlock_t pcie_idx_lock; |
1994 | amdgpu_rreg_t pcie_rreg; | 2016 | amdgpu_rreg_t pcie_rreg; |
1995 | amdgpu_wreg_t pcie_wreg; | 2017 | amdgpu_wreg_t pcie_wreg; |
2018 | amdgpu_rreg_t pciep_rreg; | ||
2019 | amdgpu_wreg_t pciep_wreg; | ||
1996 | /* protects concurrent UVD register access */ | 2020 | /* protects concurrent UVD register access */ |
1997 | spinlock_t uvd_ctx_idx_lock; | 2021 | spinlock_t uvd_ctx_idx_lock; |
1998 | amdgpu_rreg_t uvd_ctx_rreg; | 2022 | amdgpu_rreg_t uvd_ctx_rreg; |
@@ -2033,6 +2057,14 @@ struct amdgpu_device { | |||
2033 | atomic64_t num_evictions; | 2057 | atomic64_t num_evictions; |
2034 | atomic_t gpu_reset_counter; | 2058 | atomic_t gpu_reset_counter; |
2035 | 2059 | ||
2060 | /* data for buffer migration throttling */ | ||
2061 | struct { | ||
2062 | spinlock_t lock; | ||
2063 | s64 last_update_us; | ||
2064 | s64 accum_us; /* accumulated microseconds */ | ||
2065 | u32 log2_max_MBps; | ||
2066 | } mm_stats; | ||
2067 | |||
2036 | /* display */ | 2068 | /* display */ |
2037 | bool enable_virtual_display; | 2069 | bool enable_virtual_display; |
2038 | struct amdgpu_mode_info mode_info; | 2070 | struct amdgpu_mode_info mode_info; |
@@ -2101,6 +2133,10 @@ struct amdgpu_device { | |||
2101 | /* link all shadow bo */ | 2133 | /* link all shadow bo */ |
2102 | struct list_head shadow_list; | 2134 | struct list_head shadow_list; |
2103 | struct mutex shadow_list_lock; | 2135 | struct mutex shadow_list_lock; |
2136 | /* link all gtt */ | ||
2137 | spinlock_t gtt_list_lock; | ||
2138 | struct list_head gtt_list; | ||
2139 | |||
2104 | }; | 2140 | }; |
2105 | 2141 | ||
2106 | bool amdgpu_device_is_px(struct drm_device *dev); | 2142 | bool amdgpu_device_is_px(struct drm_device *dev); |
@@ -2133,6 +2169,8 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v); | |||
2133 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) | 2169 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
2134 | #define RREG32_PCIE(reg) adev->pcie_rreg(adev, (reg)) | 2170 | #define RREG32_PCIE(reg) adev->pcie_rreg(adev, (reg)) |
2135 | #define WREG32_PCIE(reg, v) adev->pcie_wreg(adev, (reg), (v)) | 2171 | #define WREG32_PCIE(reg, v) adev->pcie_wreg(adev, (reg), (v)) |
2172 | #define RREG32_PCIE_PORT(reg) adev->pciep_rreg(adev, (reg)) | ||
2173 | #define WREG32_PCIE_PORT(reg, v) adev->pciep_wreg(adev, (reg), (v)) | ||
2136 | #define RREG32_SMC(reg) adev->smc_rreg(adev, (reg)) | 2174 | #define RREG32_SMC(reg) adev->smc_rreg(adev, (reg)) |
2137 | #define WREG32_SMC(reg, v) adev->smc_wreg(adev, (reg), (v)) | 2175 | #define WREG32_SMC(reg, v) adev->smc_wreg(adev, (reg), (v)) |
2138 | #define RREG32_UVD_CTX(reg) adev->uvd_ctx_rreg(adev, (reg)) | 2176 | #define RREG32_UVD_CTX(reg) adev->uvd_ctx_rreg(adev, (reg)) |
@@ -2223,6 +2261,9 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
2223 | #define amdgpu_asic_set_uvd_clocks(adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) | 2261 | #define amdgpu_asic_set_uvd_clocks(adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d)) |
2224 | #define amdgpu_asic_set_vce_clocks(adev, ev, ec) (adev)->asic_funcs->set_vce_clocks((adev), (ev), (ec)) | 2262 | #define amdgpu_asic_set_vce_clocks(adev, ev, ec) (adev)->asic_funcs->set_vce_clocks((adev), (ev), (ec)) |
2225 | #define amdgpu_asic_get_virtual_caps(adev) ((adev)->asic_funcs->get_virtual_caps((adev))) | 2263 | #define amdgpu_asic_get_virtual_caps(adev) ((adev)->asic_funcs->get_virtual_caps((adev))) |
2264 | #define amdgpu_get_pcie_lanes(adev) (adev)->asic_funcs->get_pcie_lanes((adev)) | ||
2265 | #define amdgpu_set_pcie_lanes(adev, l) (adev)->asic_funcs->set_pcie_lanes((adev), (l)) | ||
2266 | #define amdgpu_asic_get_gpu_clock_counter(adev) (adev)->asic_funcs->get_gpu_clock_counter((adev)) | ||
2226 | #define amdgpu_asic_read_disabled_bios(adev) (adev)->asic_funcs->read_disabled_bios((adev)) | 2267 | #define amdgpu_asic_read_disabled_bios(adev) (adev)->asic_funcs->read_disabled_bios((adev)) |
2227 | #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) | 2268 | #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) |
2228 | #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) | 2269 | #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) |
@@ -2244,9 +2285,13 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
2244 | #define amdgpu_ring_emit_gds_switch(r, v, db, ds, wb, ws, ab, as) (r)->funcs->emit_gds_switch((r), (v), (db), (ds), (wb), (ws), (ab), (as)) | 2285 | #define amdgpu_ring_emit_gds_switch(r, v, db, ds, wb, ws, ab, as) (r)->funcs->emit_gds_switch((r), (v), (db), (ds), (wb), (ws), (ab), (as)) |
2245 | #define amdgpu_ring_emit_hdp_flush(r) (r)->funcs->emit_hdp_flush((r)) | 2286 | #define amdgpu_ring_emit_hdp_flush(r) (r)->funcs->emit_hdp_flush((r)) |
2246 | #define amdgpu_ring_emit_hdp_invalidate(r) (r)->funcs->emit_hdp_invalidate((r)) | 2287 | #define amdgpu_ring_emit_hdp_invalidate(r) (r)->funcs->emit_hdp_invalidate((r)) |
2288 | #define amdgpu_ring_emit_switch_buffer(r) (r)->funcs->emit_switch_buffer((r)) | ||
2289 | #define amdgpu_ring_emit_cntxcntl(r, d) (r)->funcs->emit_cntxcntl((r), (d)) | ||
2247 | #define amdgpu_ring_pad_ib(r, ib) ((r)->funcs->pad_ib((r), (ib))) | 2290 | #define amdgpu_ring_pad_ib(r, ib) ((r)->funcs->pad_ib((r), (ib))) |
2248 | #define amdgpu_ring_init_cond_exec(r) (r)->funcs->init_cond_exec((r)) | 2291 | #define amdgpu_ring_init_cond_exec(r) (r)->funcs->init_cond_exec((r)) |
2249 | #define amdgpu_ring_patch_cond_exec(r,o) (r)->funcs->patch_cond_exec((r),(o)) | 2292 | #define amdgpu_ring_patch_cond_exec(r,o) (r)->funcs->patch_cond_exec((r),(o)) |
2293 | #define amdgpu_ring_get_emit_ib_size(r) (r)->funcs->get_emit_ib_size((r)) | ||
2294 | #define amdgpu_ring_get_dma_frame_size(r) (r)->funcs->get_dma_frame_size((r)) | ||
2250 | #define amdgpu_ih_get_wptr(adev) (adev)->irq.ih_funcs->get_wptr((adev)) | 2295 | #define amdgpu_ih_get_wptr(adev) (adev)->irq.ih_funcs->get_wptr((adev)) |
2251 | #define amdgpu_ih_decode_iv(adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) | 2296 | #define amdgpu_ih_decode_iv(adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) |
2252 | #define amdgpu_ih_set_rptr(adev) (adev)->irq.ih_funcs->set_rptr((adev)) | 2297 | #define amdgpu_ih_set_rptr(adev) (adev)->irq.ih_funcs->set_rptr((adev)) |
@@ -2402,6 +2447,8 @@ void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); | |||
2402 | void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); | 2447 | void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); |
2403 | u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev); | 2448 | u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev); |
2404 | int amdgpu_ttm_global_init(struct amdgpu_device *adev); | 2449 | int amdgpu_ttm_global_init(struct amdgpu_device *adev); |
2450 | int amdgpu_ttm_init(struct amdgpu_device *adev); | ||
2451 | void amdgpu_ttm_fini(struct amdgpu_device *adev); | ||
2405 | void amdgpu_program_register_sequence(struct amdgpu_device *adev, | 2452 | void amdgpu_program_register_sequence(struct amdgpu_device *adev, |
2406 | const u32 *registers, | 2453 | const u32 *registers, |
2407 | const u32 array_size); | 2454 | const u32 array_size); |
@@ -2434,8 +2481,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
2434 | struct drm_file *file_priv); | 2481 | struct drm_file *file_priv); |
2435 | void amdgpu_driver_preclose_kms(struct drm_device *dev, | 2482 | void amdgpu_driver_preclose_kms(struct drm_device *dev, |
2436 | struct drm_file *file_priv); | 2483 | struct drm_file *file_priv); |
2437 | int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon); | 2484 | int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon); |
2438 | int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon); | 2485 | int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon); |
2439 | u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe); | 2486 | u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe); |
2440 | int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe); | 2487 | int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe); |
2441 | void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe); | 2488 | void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe); |
@@ -2481,6 +2528,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { } | |||
2481 | struct amdgpu_bo_va_mapping * | 2528 | struct amdgpu_bo_va_mapping * |
2482 | amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, | 2529 | amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, |
2483 | uint64_t addr, struct amdgpu_bo **bo); | 2530 | uint64_t addr, struct amdgpu_bo **bo); |
2531 | int amdgpu_cs_sysvm_access_required(struct amdgpu_cs_parser *parser); | ||
2484 | 2532 | ||
2485 | #include "amdgpu_object.h" | 2533 | #include "amdgpu_object.h" |
2486 | #endif | 2534 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 1b621160b52e..59961db9c390 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | |||
@@ -978,6 +978,48 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev, | |||
978 | return -EINVAL; | 978 | return -EINVAL; |
979 | 979 | ||
980 | switch (crev) { | 980 | switch (crev) { |
981 | case 2: | ||
982 | case 3: | ||
983 | case 5: | ||
984 | /* r6xx, r7xx, evergreen, ni, si. | ||
985 | * TODO: add support for asic_type <= CHIP_RV770*/ | ||
986 | if (clock_type == COMPUTE_ENGINE_PLL_PARAM) { | ||
987 | args.v3.ulClockParams = cpu_to_le32((clock_type << 24) | clock); | ||
988 | |||
989 | amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args); | ||
990 | |||
991 | dividers->post_div = args.v3.ucPostDiv; | ||
992 | dividers->enable_post_div = (args.v3.ucCntlFlag & | ||
993 | ATOM_PLL_CNTL_FLAG_PLL_POST_DIV_EN) ? true : false; | ||
994 | dividers->enable_dithen = (args.v3.ucCntlFlag & | ||
995 | ATOM_PLL_CNTL_FLAG_FRACTION_DISABLE) ? false : true; | ||
996 | dividers->whole_fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDiv); | ||
997 | dividers->frac_fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDivFrac); | ||
998 | dividers->ref_div = args.v3.ucRefDiv; | ||
999 | dividers->vco_mode = (args.v3.ucCntlFlag & | ||
1000 | ATOM_PLL_CNTL_FLAG_MPLL_VCO_MODE) ? 1 : 0; | ||
1001 | } else { | ||
1002 | /* for SI we use ComputeMemoryClockParam for memory plls */ | ||
1003 | if (adev->asic_type >= CHIP_TAHITI) | ||
1004 | return -EINVAL; | ||
1005 | args.v5.ulClockParams = cpu_to_le32((clock_type << 24) | clock); | ||
1006 | if (strobe_mode) | ||
1007 | args.v5.ucInputFlag = ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN; | ||
1008 | |||
1009 | amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args); | ||
1010 | |||
1011 | dividers->post_div = args.v5.ucPostDiv; | ||
1012 | dividers->enable_post_div = (args.v5.ucCntlFlag & | ||
1013 | ATOM_PLL_CNTL_FLAG_PLL_POST_DIV_EN) ? true : false; | ||
1014 | dividers->enable_dithen = (args.v5.ucCntlFlag & | ||
1015 | ATOM_PLL_CNTL_FLAG_FRACTION_DISABLE) ? false : true; | ||
1016 | dividers->whole_fb_div = le16_to_cpu(args.v5.ulFbDiv.usFbDiv); | ||
1017 | dividers->frac_fb_div = le16_to_cpu(args.v5.ulFbDiv.usFbDivFrac); | ||
1018 | dividers->ref_div = args.v5.ucRefDiv; | ||
1019 | dividers->vco_mode = (args.v5.ucCntlFlag & | ||
1020 | ATOM_PLL_CNTL_FLAG_MPLL_VCO_MODE) ? 1 : 0; | ||
1021 | } | ||
1022 | break; | ||
981 | case 4: | 1023 | case 4: |
982 | /* fusion */ | 1024 | /* fusion */ |
983 | args.v4.ulClock = cpu_to_le32(clock); /* 10 khz */ | 1025 | args.v4.ulClock = cpu_to_le32(clock); /* 10 khz */ |
@@ -1122,6 +1164,32 @@ void amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev, | |||
1122 | amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args); | 1164 | amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args); |
1123 | } | 1165 | } |
1124 | 1166 | ||
1167 | void amdgpu_atombios_get_default_voltages(struct amdgpu_device *adev, | ||
1168 | u16 *vddc, u16 *vddci, u16 *mvdd) | ||
1169 | { | ||
1170 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | ||
1171 | int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); | ||
1172 | u8 frev, crev; | ||
1173 | u16 data_offset; | ||
1174 | union firmware_info *firmware_info; | ||
1175 | |||
1176 | *vddc = 0; | ||
1177 | *vddci = 0; | ||
1178 | *mvdd = 0; | ||
1179 | |||
1180 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
1181 | &frev, &crev, &data_offset)) { | ||
1182 | firmware_info = | ||
1183 | (union firmware_info *)(mode_info->atom_context->bios + | ||
1184 | data_offset); | ||
1185 | *vddc = le16_to_cpu(firmware_info->info_14.usBootUpVDDCVoltage); | ||
1186 | if ((frev == 2) && (crev >= 2)) { | ||
1187 | *vddci = le16_to_cpu(firmware_info->info_22.usBootUpVDDCIVoltage); | ||
1188 | *mvdd = le16_to_cpu(firmware_info->info_22.usBootUpMVDDCVoltage); | ||
1189 | } | ||
1190 | } | ||
1191 | } | ||
1192 | |||
1125 | union set_voltage { | 1193 | union set_voltage { |
1126 | struct _SET_VOLTAGE_PS_ALLOCATION alloc; | 1194 | struct _SET_VOLTAGE_PS_ALLOCATION alloc; |
1127 | struct _SET_VOLTAGE_PARAMETERS v1; | 1195 | struct _SET_VOLTAGE_PARAMETERS v1; |
@@ -1129,6 +1197,52 @@ union set_voltage { | |||
1129 | struct _SET_VOLTAGE_PARAMETERS_V1_3 v3; | 1197 | struct _SET_VOLTAGE_PARAMETERS_V1_3 v3; |
1130 | }; | 1198 | }; |
1131 | 1199 | ||
1200 | int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, | ||
1201 | u16 voltage_id, u16 *voltage) | ||
1202 | { | ||
1203 | union set_voltage args; | ||
1204 | int index = GetIndexIntoMasterTable(COMMAND, SetVoltage); | ||
1205 | u8 frev, crev; | ||
1206 | |||
1207 | if (!amdgpu_atom_parse_cmd_header(adev->mode_info.atom_context, index, &frev, &crev)) | ||
1208 | return -EINVAL; | ||
1209 | |||
1210 | switch (crev) { | ||
1211 | case 1: | ||
1212 | return -EINVAL; | ||
1213 | case 2: | ||
1214 | args.v2.ucVoltageType = SET_VOLTAGE_GET_MAX_VOLTAGE; | ||
1215 | args.v2.ucVoltageMode = 0; | ||
1216 | args.v2.usVoltageLevel = 0; | ||
1217 | |||
1218 | amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args); | ||
1219 | |||
1220 | *voltage = le16_to_cpu(args.v2.usVoltageLevel); | ||
1221 | break; | ||
1222 | case 3: | ||
1223 | args.v3.ucVoltageType = voltage_type; | ||
1224 | args.v3.ucVoltageMode = ATOM_GET_VOLTAGE_LEVEL; | ||
1225 | args.v3.usVoltageLevel = cpu_to_le16(voltage_id); | ||
1226 | |||
1227 | amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args); | ||
1228 | |||
1229 | *voltage = le16_to_cpu(args.v3.usVoltageLevel); | ||
1230 | break; | ||
1231 | default: | ||
1232 | DRM_ERROR("Unknown table version %d, %d\n", frev, crev); | ||
1233 | return -EINVAL; | ||
1234 | } | ||
1235 | |||
1236 | return 0; | ||
1237 | } | ||
1238 | |||
1239 | int amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(struct amdgpu_device *adev, | ||
1240 | u16 *voltage, | ||
1241 | u16 leakage_idx) | ||
1242 | { | ||
1243 | return amdgpu_atombios_get_max_vddc(adev, VOLTAGE_TYPE_VDDC, leakage_idx, voltage); | ||
1244 | } | ||
1245 | |||
1132 | void amdgpu_atombios_set_voltage(struct amdgpu_device *adev, | 1246 | void amdgpu_atombios_set_voltage(struct amdgpu_device *adev, |
1133 | u16 voltage_level, | 1247 | u16 voltage_level, |
1134 | u8 voltage_type) | 1248 | u8 voltage_type) |
@@ -1349,6 +1463,50 @@ static ATOM_VOLTAGE_OBJECT_V3 *amdgpu_atombios_lookup_voltage_object_v3(ATOM_VOL | |||
1349 | return NULL; | 1463 | return NULL; |
1350 | } | 1464 | } |
1351 | 1465 | ||
1466 | int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev, | ||
1467 | u8 voltage_type, | ||
1468 | u8 *svd_gpio_id, u8 *svc_gpio_id) | ||
1469 | { | ||
1470 | int index = GetIndexIntoMasterTable(DATA, VoltageObjectInfo); | ||
1471 | u8 frev, crev; | ||
1472 | u16 data_offset, size; | ||
1473 | union voltage_object_info *voltage_info; | ||
1474 | union voltage_object *voltage_object = NULL; | ||
1475 | |||
1476 | if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, &size, | ||
1477 | &frev, &crev, &data_offset)) { | ||
1478 | voltage_info = (union voltage_object_info *) | ||
1479 | (adev->mode_info.atom_context->bios + data_offset); | ||
1480 | |||
1481 | switch (frev) { | ||
1482 | case 3: | ||
1483 | switch (crev) { | ||
1484 | case 1: | ||
1485 | voltage_object = (union voltage_object *) | ||
1486 | amdgpu_atombios_lookup_voltage_object_v3(&voltage_info->v3, | ||
1487 | voltage_type, | ||
1488 | VOLTAGE_OBJ_SVID2); | ||
1489 | if (voltage_object) { | ||
1490 | *svd_gpio_id = voltage_object->v3.asSVID2Obj.ucSVDGpioId; | ||
1491 | *svc_gpio_id = voltage_object->v3.asSVID2Obj.ucSVCGpioId; | ||
1492 | } else { | ||
1493 | return -EINVAL; | ||
1494 | } | ||
1495 | break; | ||
1496 | default: | ||
1497 | DRM_ERROR("unknown voltage object table\n"); | ||
1498 | return -EINVAL; | ||
1499 | } | ||
1500 | break; | ||
1501 | default: | ||
1502 | DRM_ERROR("unknown voltage object table\n"); | ||
1503 | return -EINVAL; | ||
1504 | } | ||
1505 | |||
1506 | } | ||
1507 | return 0; | ||
1508 | } | ||
1509 | |||
1352 | bool | 1510 | bool |
1353 | amdgpu_atombios_is_voltage_gpio(struct amdgpu_device *adev, | 1511 | amdgpu_atombios_is_voltage_gpio(struct amdgpu_device *adev, |
1354 | u8 voltage_type, u8 voltage_mode) | 1512 | u8 voltage_type, u8 voltage_mode) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h index 15dd43ec38bb..17356151db38 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h | |||
@@ -208,5 +208,19 @@ void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev); | |||
208 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); | 208 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); |
209 | 209 | ||
210 | void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); | 210 | void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); |
211 | 211 | int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, | |
212 | u16 voltage_id, u16 *voltage); | ||
213 | int amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(struct amdgpu_device *adev, | ||
214 | u16 *voltage, | ||
215 | u16 leakage_idx); | ||
216 | void amdgpu_atombios_get_default_voltages(struct amdgpu_device *adev, | ||
217 | u16 *vddc, u16 *vddci, u16 *mvdd); | ||
218 | int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev, | ||
219 | u8 clock_type, | ||
220 | u32 clock, | ||
221 | bool strobe_mode, | ||
222 | struct atom_clock_dividers *dividers); | ||
223 | int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev, | ||
224 | u8 voltage_type, | ||
225 | u8 *svd_gpio_id, u8 *svc_gpio_id); | ||
212 | #endif | 226 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index bc0440f7a31d..f1c53a2b09c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -616,7 +616,7 @@ static int amdgpu_cgs_irq_put(struct cgs_device *cgs_device, unsigned src_id, un | |||
616 | return amdgpu_irq_put(adev, adev->irq.sources[src_id], type); | 616 | return amdgpu_irq_put(adev, adev->irq.sources[src_id], type); |
617 | } | 617 | } |
618 | 618 | ||
619 | int amdgpu_cgs_set_clockgating_state(struct cgs_device *cgs_device, | 619 | static int amdgpu_cgs_set_clockgating_state(struct cgs_device *cgs_device, |
620 | enum amd_ip_block_type block_type, | 620 | enum amd_ip_block_type block_type, |
621 | enum amd_clockgating_state state) | 621 | enum amd_clockgating_state state) |
622 | { | 622 | { |
@@ -637,7 +637,7 @@ int amdgpu_cgs_set_clockgating_state(struct cgs_device *cgs_device, | |||
637 | return r; | 637 | return r; |
638 | } | 638 | } |
639 | 639 | ||
640 | int amdgpu_cgs_set_powergating_state(struct cgs_device *cgs_device, | 640 | static int amdgpu_cgs_set_powergating_state(struct cgs_device *cgs_device, |
641 | enum amd_ip_block_type block_type, | 641 | enum amd_ip_block_type block_type, |
642 | enum amd_powergating_state state) | 642 | enum amd_powergating_state state) |
643 | { | 643 | { |
@@ -848,6 +848,12 @@ static int amdgpu_cgs_query_system_info(struct cgs_device *cgs_device, | |||
848 | case CGS_SYSTEM_INFO_GFX_SE_INFO: | 848 | case CGS_SYSTEM_INFO_GFX_SE_INFO: |
849 | sys_info->value = adev->gfx.config.max_shader_engines; | 849 | sys_info->value = adev->gfx.config.max_shader_engines; |
850 | break; | 850 | break; |
851 | case CGS_SYSTEM_INFO_PCIE_SUB_SYS_ID: | ||
852 | sys_info->value = adev->pdev->subsystem_device; | ||
853 | break; | ||
854 | case CGS_SYSTEM_INFO_PCIE_SUB_SYS_VENDOR_ID: | ||
855 | sys_info->value = adev->pdev->subsystem_vendor; | ||
856 | break; | ||
851 | default: | 857 | default: |
852 | return -ENODEV; | 858 | return -ENODEV; |
853 | } | 859 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index d80e5d3a4add..b8412bcbad2a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -91,6 +91,7 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |||
91 | uint32_t *offset) | 91 | uint32_t *offset) |
92 | { | 92 | { |
93 | struct drm_gem_object *gobj; | 93 | struct drm_gem_object *gobj; |
94 | unsigned long size; | ||
94 | 95 | ||
95 | gobj = drm_gem_object_lookup(p->filp, data->handle); | 96 | gobj = drm_gem_object_lookup(p->filp, data->handle); |
96 | if (gobj == NULL) | 97 | if (gobj == NULL) |
@@ -101,6 +102,11 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |||
101 | p->uf_entry.tv.bo = &p->uf_entry.robj->tbo; | 102 | p->uf_entry.tv.bo = &p->uf_entry.robj->tbo; |
102 | p->uf_entry.tv.shared = true; | 103 | p->uf_entry.tv.shared = true; |
103 | p->uf_entry.user_pages = NULL; | 104 | p->uf_entry.user_pages = NULL; |
105 | |||
106 | size = amdgpu_bo_size(p->uf_entry.robj); | ||
107 | if (size != PAGE_SIZE || (data->offset + 8) > size) | ||
108 | return -EINVAL; | ||
109 | |||
104 | *offset = data->offset; | 110 | *offset = data->offset; |
105 | 111 | ||
106 | drm_gem_object_unreference_unlocked(gobj); | 112 | drm_gem_object_unreference_unlocked(gobj); |
@@ -235,56 +241,115 @@ free_chunk: | |||
235 | return ret; | 241 | return ret; |
236 | } | 242 | } |
237 | 243 | ||
238 | /* Returns how many bytes TTM can move per IB. | 244 | /* Convert microseconds to bytes. */ |
245 | static u64 us_to_bytes(struct amdgpu_device *adev, s64 us) | ||
246 | { | ||
247 | if (us <= 0 || !adev->mm_stats.log2_max_MBps) | ||
248 | return 0; | ||
249 | |||
250 | /* Since accum_us is incremented by a million per second, just | ||
251 | * multiply it by the number of MB/s to get the number of bytes. | ||
252 | */ | ||
253 | return us << adev->mm_stats.log2_max_MBps; | ||
254 | } | ||
255 | |||
256 | static s64 bytes_to_us(struct amdgpu_device *adev, u64 bytes) | ||
257 | { | ||
258 | if (!adev->mm_stats.log2_max_MBps) | ||
259 | return 0; | ||
260 | |||
261 | return bytes >> adev->mm_stats.log2_max_MBps; | ||
262 | } | ||
263 | |||
264 | /* Returns how many bytes TTM can move right now. If no bytes can be moved, | ||
265 | * it returns 0. If it returns non-zero, it's OK to move at least one buffer, | ||
266 | * which means it can go over the threshold once. If that happens, the driver | ||
267 | * will be in debt and no other buffer migrations can be done until that debt | ||
268 | * is repaid. | ||
269 | * | ||
270 | * This approach allows moving a buffer of any size (it's important to allow | ||
271 | * that). | ||
272 | * | ||
273 | * The currency is simply time in microseconds and it increases as the clock | ||
274 | * ticks. The accumulated microseconds (us) are converted to bytes and | ||
275 | * returned. | ||
239 | */ | 276 | */ |
240 | static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) | 277 | static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) |
241 | { | 278 | { |
242 | u64 real_vram_size = adev->mc.real_vram_size; | 279 | s64 time_us, increment_us; |
243 | u64 vram_usage = atomic64_read(&adev->vram_usage); | 280 | u64 max_bytes; |
281 | u64 free_vram, total_vram, used_vram; | ||
244 | 282 | ||
245 | /* This function is based on the current VRAM usage. | 283 | /* Allow a maximum of 200 accumulated ms. This is basically per-IB |
284 | * throttling. | ||
246 | * | 285 | * |
247 | * - If all of VRAM is free, allow relocating the number of bytes that | 286 | * It means that in order to get full max MBps, at least 5 IBs per |
248 | * is equal to 1/4 of the size of VRAM for this IB. | 287 | * second must be submitted and not more than 200ms apart from each |
288 | * other. | ||
289 | */ | ||
290 | const s64 us_upper_bound = 200000; | ||
249 | 291 | ||
250 | * - If more than one half of VRAM is occupied, only allow relocating | 292 | if (!adev->mm_stats.log2_max_MBps) |
251 | * 1 MB of data for this IB. | 293 | return 0; |
252 | * | 294 | |
253 | * - From 0 to one half of used VRAM, the threshold decreases | 295 | total_vram = adev->mc.real_vram_size - adev->vram_pin_size; |
254 | * linearly. | 296 | used_vram = atomic64_read(&adev->vram_usage); |
255 | * __________________ | 297 | free_vram = used_vram >= total_vram ? 0 : total_vram - used_vram; |
256 | * 1/4 of -|\ | | 298 | |
257 | * VRAM | \ | | 299 | spin_lock(&adev->mm_stats.lock); |
258 | * | \ | | 300 | |
259 | * | \ | | 301 | /* Increase the amount of accumulated us. */ |
260 | * | \ | | 302 | time_us = ktime_to_us(ktime_get()); |
261 | * | \ | | 303 | increment_us = time_us - adev->mm_stats.last_update_us; |
262 | * | \ | | 304 | adev->mm_stats.last_update_us = time_us; |
263 | * | \________|1 MB | 305 | adev->mm_stats.accum_us = min(adev->mm_stats.accum_us + increment_us, |
264 | * |----------------| | 306 | us_upper_bound); |
265 | * VRAM 0 % 100 % | 307 | |
266 | * used used | 308 | /* This prevents the short period of low performance when the VRAM |
267 | * | 309 | * usage is low and the driver is in debt or doesn't have enough |
268 | * Note: It's a threshold, not a limit. The threshold must be crossed | 310 | * accumulated us to fill VRAM quickly. |
269 | * for buffer relocations to stop, so any buffer of an arbitrary size | ||
270 | * can be moved as long as the threshold isn't crossed before | ||
271 | * the relocation takes place. We don't want to disable buffer | ||
272 | * relocations completely. | ||
273 | * | 311 | * |
274 | * The idea is that buffers should be placed in VRAM at creation time | 312 | * The situation can occur in these cases: |
275 | * and TTM should only do a minimum number of relocations during | 313 | * - a lot of VRAM is freed by userspace |
276 | * command submission. In practice, you need to submit at least | 314 | * - the presence of a big buffer causes a lot of evictions |
277 | * a dozen IBs to move all buffers to VRAM if they are in GTT. | 315 | * (solution: split buffers into smaller ones) |
278 | * | 316 | * |
279 | * Also, things can get pretty crazy under memory pressure and actual | 317 | * If 128 MB or 1/8th of VRAM is free, start filling it now by setting |
280 | * VRAM usage can change a lot, so playing safe even at 50% does | 318 | * accum_us to a positive number. |
281 | * consistently increase performance. | 319 | */ |
320 | if (free_vram >= 128 * 1024 * 1024 || free_vram >= total_vram / 8) { | ||
321 | s64 min_us; | ||
322 | |||
323 | /* Be more aggresive on dGPUs. Try to fill a portion of free | ||
324 | * VRAM now. | ||
325 | */ | ||
326 | if (!(adev->flags & AMD_IS_APU)) | ||
327 | min_us = bytes_to_us(adev, free_vram / 4); | ||
328 | else | ||
329 | min_us = 0; /* Reset accum_us on APUs. */ | ||
330 | |||
331 | adev->mm_stats.accum_us = max(min_us, adev->mm_stats.accum_us); | ||
332 | } | ||
333 | |||
334 | /* This returns 0 if the driver is in debt to disallow (optional) | ||
335 | * buffer moves. | ||
282 | */ | 336 | */ |
337 | max_bytes = us_to_bytes(adev, adev->mm_stats.accum_us); | ||
283 | 338 | ||
284 | u64 half_vram = real_vram_size >> 1; | 339 | spin_unlock(&adev->mm_stats.lock); |
285 | u64 half_free_vram = vram_usage >= half_vram ? 0 : half_vram - vram_usage; | 340 | return max_bytes; |
286 | u64 bytes_moved_threshold = half_free_vram >> 1; | 341 | } |
287 | return max(bytes_moved_threshold, 1024*1024ull); | 342 | |
343 | /* Report how many bytes have really been moved for the last command | ||
344 | * submission. This can result in a debt that can stop buffer migrations | ||
345 | * temporarily. | ||
346 | */ | ||
347 | static void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, | ||
348 | u64 num_bytes) | ||
349 | { | ||
350 | spin_lock(&adev->mm_stats.lock); | ||
351 | adev->mm_stats.accum_us -= bytes_to_us(adev, num_bytes); | ||
352 | spin_unlock(&adev->mm_stats.lock); | ||
288 | } | 353 | } |
289 | 354 | ||
290 | static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | 355 | static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, |
@@ -297,15 +362,10 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
297 | if (bo->pin_count) | 362 | if (bo->pin_count) |
298 | return 0; | 363 | return 0; |
299 | 364 | ||
300 | /* Avoid moving this one if we have moved too many buffers | 365 | /* Don't move this buffer if we have depleted our allowance |
301 | * for this IB already. | 366 | * to move it. Don't move anything if the threshold is zero. |
302 | * | ||
303 | * Note that this allows moving at least one buffer of | ||
304 | * any size, because it doesn't take the current "bo" | ||
305 | * into account. We don't want to disallow buffer moves | ||
306 | * completely. | ||
307 | */ | 367 | */ |
308 | if (p->bytes_moved <= p->bytes_moved_threshold) | 368 | if (p->bytes_moved < p->bytes_moved_threshold) |
309 | domain = bo->prefered_domains; | 369 | domain = bo->prefered_domains; |
310 | else | 370 | else |
311 | domain = bo->allowed_domains; | 371 | domain = bo->allowed_domains; |
@@ -317,17 +377,67 @@ retry: | |||
317 | p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) - | 377 | p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) - |
318 | initial_bytes_moved; | 378 | initial_bytes_moved; |
319 | 379 | ||
320 | if (unlikely(r)) { | 380 | if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { |
321 | if (r != -ERESTARTSYS && domain != bo->allowed_domains) { | 381 | domain = bo->allowed_domains; |
322 | domain = bo->allowed_domains; | 382 | goto retry; |
323 | goto retry; | ||
324 | } | ||
325 | } | 383 | } |
326 | 384 | ||
327 | return r; | 385 | return r; |
328 | } | 386 | } |
329 | 387 | ||
330 | int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, | 388 | /* Last resort, try to evict something from the current working set */ |
389 | static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, | ||
390 | struct amdgpu_bo_list_entry *lobj) | ||
391 | { | ||
392 | uint32_t domain = lobj->robj->allowed_domains; | ||
393 | int r; | ||
394 | |||
395 | if (!p->evictable) | ||
396 | return false; | ||
397 | |||
398 | for (;&p->evictable->tv.head != &p->validated; | ||
399 | p->evictable = list_prev_entry(p->evictable, tv.head)) { | ||
400 | |||
401 | struct amdgpu_bo_list_entry *candidate = p->evictable; | ||
402 | struct amdgpu_bo *bo = candidate->robj; | ||
403 | u64 initial_bytes_moved; | ||
404 | uint32_t other; | ||
405 | |||
406 | /* If we reached our current BO we can forget it */ | ||
407 | if (candidate == lobj) | ||
408 | break; | ||
409 | |||
410 | other = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); | ||
411 | |||
412 | /* Check if this BO is in one of the domains we need space for */ | ||
413 | if (!(other & domain)) | ||
414 | continue; | ||
415 | |||
416 | /* Check if we can move this BO somewhere else */ | ||
417 | other = bo->allowed_domains & ~domain; | ||
418 | if (!other) | ||
419 | continue; | ||
420 | |||
421 | /* Good we can try to move this BO somewhere else */ | ||
422 | amdgpu_ttm_placement_from_domain(bo, other); | ||
423 | initial_bytes_moved = atomic64_read(&bo->adev->num_bytes_moved); | ||
424 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); | ||
425 | p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) - | ||
426 | initial_bytes_moved; | ||
427 | |||
428 | if (unlikely(r)) | ||
429 | break; | ||
430 | |||
431 | p->evictable = list_prev_entry(p->evictable, tv.head); | ||
432 | list_move(&candidate->tv.head, &p->validated); | ||
433 | |||
434 | return true; | ||
435 | } | ||
436 | |||
437 | return false; | ||
438 | } | ||
439 | |||
440 | static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, | ||
331 | struct list_head *validated) | 441 | struct list_head *validated) |
332 | { | 442 | { |
333 | struct amdgpu_bo_list_entry *lobj; | 443 | struct amdgpu_bo_list_entry *lobj; |
@@ -351,9 +461,15 @@ int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, | |||
351 | binding_userptr = true; | 461 | binding_userptr = true; |
352 | } | 462 | } |
353 | 463 | ||
354 | r = amdgpu_cs_bo_validate(p, bo); | 464 | if (p->evictable == lobj) |
465 | p->evictable = NULL; | ||
466 | |||
467 | do { | ||
468 | r = amdgpu_cs_bo_validate(p, bo); | ||
469 | } while (r == -ENOMEM && amdgpu_cs_try_evict(p, lobj)); | ||
355 | if (r) | 470 | if (r) |
356 | return r; | 471 | return r; |
472 | |||
357 | if (bo->shadow) { | 473 | if (bo->shadow) { |
358 | r = amdgpu_cs_bo_validate(p, bo); | 474 | r = amdgpu_cs_bo_validate(p, bo); |
359 | if (r) | 475 | if (r) |
@@ -481,6 +597,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
481 | 597 | ||
482 | p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); | 598 | p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); |
483 | p->bytes_moved = 0; | 599 | p->bytes_moved = 0; |
600 | p->evictable = list_last_entry(&p->validated, | ||
601 | struct amdgpu_bo_list_entry, | ||
602 | tv.head); | ||
484 | 603 | ||
485 | r = amdgpu_cs_list_validate(p, &duplicates); | 604 | r = amdgpu_cs_list_validate(p, &duplicates); |
486 | if (r) { | 605 | if (r) { |
@@ -494,6 +613,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
494 | goto error_validate; | 613 | goto error_validate; |
495 | } | 614 | } |
496 | 615 | ||
616 | amdgpu_cs_report_moved_bytes(p->adev, p->bytes_moved); | ||
617 | |||
497 | fpriv->vm.last_eviction_counter = | 618 | fpriv->vm.last_eviction_counter = |
498 | atomic64_read(&p->adev->num_evictions); | 619 | atomic64_read(&p->adev->num_evictions); |
499 | 620 | ||
@@ -524,8 +645,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
524 | } | 645 | } |
525 | } | 646 | } |
526 | 647 | ||
527 | if (p->uf_entry.robj) | 648 | if (!r && p->uf_entry.robj) { |
528 | p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj); | 649 | struct amdgpu_bo *uf = p->uf_entry.robj; |
650 | |||
651 | r = amdgpu_ttm_bind(uf->tbo.ttm, &uf->tbo.mem); | ||
652 | p->job->uf_addr += amdgpu_bo_gpu_offset(uf); | ||
653 | } | ||
529 | 654 | ||
530 | error_validate: | 655 | error_validate: |
531 | if (r) { | 656 | if (r) { |
@@ -735,6 +860,14 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, | |||
735 | if (r) | 860 | if (r) |
736 | return r; | 861 | return r; |
737 | 862 | ||
863 | if (ib->flags & AMDGPU_IB_FLAG_PREAMBLE) { | ||
864 | parser->job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT; | ||
865 | if (!parser->ctx->preamble_presented) { | ||
866 | parser->job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT_FIRST; | ||
867 | parser->ctx->preamble_presented = true; | ||
868 | } | ||
869 | } | ||
870 | |||
738 | if (parser->job->ring && parser->job->ring != ring) | 871 | if (parser->job->ring && parser->job->ring != ring) |
739 | return -EINVAL; | 872 | return -EINVAL; |
740 | 873 | ||
@@ -874,7 +1007,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
874 | } | 1007 | } |
875 | 1008 | ||
876 | job->owner = p->filp; | 1009 | job->owner = p->filp; |
877 | job->ctx = entity->fence_context; | 1010 | job->fence_ctx = entity->fence_context; |
878 | p->fence = fence_get(&job->base.s_fence->finished); | 1011 | p->fence = fence_get(&job->base.s_fence->finished); |
879 | cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence); | 1012 | cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence); |
880 | job->uf_sequence = cs->out.handle; | 1013 | job->uf_sequence = cs->out.handle; |
@@ -1040,3 +1173,29 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, | |||
1040 | 1173 | ||
1041 | return NULL; | 1174 | return NULL; |
1042 | } | 1175 | } |
1176 | |||
1177 | /** | ||
1178 | * amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM | ||
1179 | * | ||
1180 | * @parser: command submission parser context | ||
1181 | * | ||
1182 | * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM. | ||
1183 | */ | ||
1184 | int amdgpu_cs_sysvm_access_required(struct amdgpu_cs_parser *parser) | ||
1185 | { | ||
1186 | unsigned i; | ||
1187 | int r; | ||
1188 | |||
1189 | if (!parser->bo_list) | ||
1190 | return 0; | ||
1191 | |||
1192 | for (i = 0; i < parser->bo_list->num_entries; i++) { | ||
1193 | struct amdgpu_bo *bo = parser->bo_list->array[i].robj; | ||
1194 | |||
1195 | r = amdgpu_ttm_bind(bo->tbo.ttm, &bo->tbo.mem); | ||
1196 | if (unlikely(r)) | ||
1197 | return r; | ||
1198 | } | ||
1199 | |||
1200 | return 0; | ||
1201 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index c38dc47cd767..3ddae5ff41bb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -41,6 +41,9 @@ | |||
41 | #include "atom.h" | 41 | #include "atom.h" |
42 | #include "amdgpu_atombios.h" | 42 | #include "amdgpu_atombios.h" |
43 | #include "amd_pcie.h" | 43 | #include "amd_pcie.h" |
44 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
45 | #include "si.h" | ||
46 | #endif | ||
44 | #ifdef CONFIG_DRM_AMDGPU_CIK | 47 | #ifdef CONFIG_DRM_AMDGPU_CIK |
45 | #include "cik.h" | 48 | #include "cik.h" |
46 | #endif | 49 | #endif |
@@ -52,6 +55,11 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); | |||
52 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); | 55 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); |
53 | 56 | ||
54 | static const char *amdgpu_asic_name[] = { | 57 | static const char *amdgpu_asic_name[] = { |
58 | "TAHITI", | ||
59 | "PITCAIRN", | ||
60 | "VERDE", | ||
61 | "OLAND", | ||
62 | "HAINAN", | ||
55 | "BONAIRE", | 63 | "BONAIRE", |
56 | "KAVERI", | 64 | "KAVERI", |
57 | "KABINI", | 65 | "KABINI", |
@@ -1027,7 +1035,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero | |||
1027 | /* don't suspend or resume card normally */ | 1035 | /* don't suspend or resume card normally */ |
1028 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; | 1036 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; |
1029 | 1037 | ||
1030 | amdgpu_resume_kms(dev, true, true); | 1038 | amdgpu_device_resume(dev, true, true); |
1031 | 1039 | ||
1032 | dev->pdev->d3_delay = d3_delay; | 1040 | dev->pdev->d3_delay = d3_delay; |
1033 | 1041 | ||
@@ -1037,7 +1045,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero | |||
1037 | printk(KERN_INFO "amdgpu: switched off\n"); | 1045 | printk(KERN_INFO "amdgpu: switched off\n"); |
1038 | drm_kms_helper_poll_disable(dev); | 1046 | drm_kms_helper_poll_disable(dev); |
1039 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; | 1047 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; |
1040 | amdgpu_suspend_kms(dev, true, true); | 1048 | amdgpu_device_suspend(dev, true, true); |
1041 | dev->switch_power_state = DRM_SWITCH_POWER_OFF; | 1049 | dev->switch_power_state = DRM_SWITCH_POWER_OFF; |
1042 | } | 1050 | } |
1043 | } | 1051 | } |
@@ -1231,6 +1239,18 @@ static int amdgpu_early_init(struct amdgpu_device *adev) | |||
1231 | if (r) | 1239 | if (r) |
1232 | return r; | 1240 | return r; |
1233 | break; | 1241 | break; |
1242 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
1243 | case CHIP_VERDE: | ||
1244 | case CHIP_TAHITI: | ||
1245 | case CHIP_PITCAIRN: | ||
1246 | case CHIP_OLAND: | ||
1247 | case CHIP_HAINAN: | ||
1248 | adev->family = AMDGPU_FAMILY_SI; | ||
1249 | r = si_set_ip_blocks(adev); | ||
1250 | if (r) | ||
1251 | return r; | ||
1252 | break; | ||
1253 | #endif | ||
1234 | #ifdef CONFIG_DRM_AMDGPU_CIK | 1254 | #ifdef CONFIG_DRM_AMDGPU_CIK |
1235 | case CHIP_BONAIRE: | 1255 | case CHIP_BONAIRE: |
1236 | case CHIP_HAWAII: | 1256 | case CHIP_HAWAII: |
@@ -1347,6 +1367,9 @@ static int amdgpu_late_init(struct amdgpu_device *adev) | |||
1347 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1367 | for (i = 0; i < adev->num_ip_blocks; i++) { |
1348 | if (!adev->ip_block_status[i].valid) | 1368 | if (!adev->ip_block_status[i].valid) |
1349 | continue; | 1369 | continue; |
1370 | if (adev->ip_blocks[i].type == AMD_IP_BLOCK_TYPE_UVD || | ||
1371 | adev->ip_blocks[i].type == AMD_IP_BLOCK_TYPE_VCE) | ||
1372 | continue; | ||
1350 | /* enable clockgating to save power */ | 1373 | /* enable clockgating to save power */ |
1351 | r = adev->ip_blocks[i].funcs->set_clockgating_state((void *)adev, | 1374 | r = adev->ip_blocks[i].funcs->set_clockgating_state((void *)adev, |
1352 | AMD_CG_STATE_GATE); | 1375 | AMD_CG_STATE_GATE); |
@@ -1490,6 +1513,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1490 | { | 1513 | { |
1491 | int r, i; | 1514 | int r, i; |
1492 | bool runtime = false; | 1515 | bool runtime = false; |
1516 | u32 max_MBps; | ||
1493 | 1517 | ||
1494 | adev->shutdown = false; | 1518 | adev->shutdown = false; |
1495 | adev->dev = &pdev->dev; | 1519 | adev->dev = &pdev->dev; |
@@ -1513,6 +1537,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1513 | adev->smc_wreg = &amdgpu_invalid_wreg; | 1537 | adev->smc_wreg = &amdgpu_invalid_wreg; |
1514 | adev->pcie_rreg = &amdgpu_invalid_rreg; | 1538 | adev->pcie_rreg = &amdgpu_invalid_rreg; |
1515 | adev->pcie_wreg = &amdgpu_invalid_wreg; | 1539 | adev->pcie_wreg = &amdgpu_invalid_wreg; |
1540 | adev->pciep_rreg = &amdgpu_invalid_rreg; | ||
1541 | adev->pciep_wreg = &amdgpu_invalid_wreg; | ||
1516 | adev->uvd_ctx_rreg = &amdgpu_invalid_rreg; | 1542 | adev->uvd_ctx_rreg = &amdgpu_invalid_rreg; |
1517 | adev->uvd_ctx_wreg = &amdgpu_invalid_wreg; | 1543 | adev->uvd_ctx_wreg = &amdgpu_invalid_wreg; |
1518 | adev->didt_rreg = &amdgpu_invalid_rreg; | 1544 | adev->didt_rreg = &amdgpu_invalid_rreg; |
@@ -1549,12 +1575,22 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1549 | spin_lock_init(&adev->didt_idx_lock); | 1575 | spin_lock_init(&adev->didt_idx_lock); |
1550 | spin_lock_init(&adev->gc_cac_idx_lock); | 1576 | spin_lock_init(&adev->gc_cac_idx_lock); |
1551 | spin_lock_init(&adev->audio_endpt_idx_lock); | 1577 | spin_lock_init(&adev->audio_endpt_idx_lock); |
1578 | spin_lock_init(&adev->mm_stats.lock); | ||
1552 | 1579 | ||
1553 | INIT_LIST_HEAD(&adev->shadow_list); | 1580 | INIT_LIST_HEAD(&adev->shadow_list); |
1554 | mutex_init(&adev->shadow_list_lock); | 1581 | mutex_init(&adev->shadow_list_lock); |
1555 | 1582 | ||
1556 | adev->rmmio_base = pci_resource_start(adev->pdev, 5); | 1583 | INIT_LIST_HEAD(&adev->gtt_list); |
1557 | adev->rmmio_size = pci_resource_len(adev->pdev, 5); | 1584 | spin_lock_init(&adev->gtt_list_lock); |
1585 | |||
1586 | if (adev->asic_type >= CHIP_BONAIRE) { | ||
1587 | adev->rmmio_base = pci_resource_start(adev->pdev, 5); | ||
1588 | adev->rmmio_size = pci_resource_len(adev->pdev, 5); | ||
1589 | } else { | ||
1590 | adev->rmmio_base = pci_resource_start(adev->pdev, 2); | ||
1591 | adev->rmmio_size = pci_resource_len(adev->pdev, 2); | ||
1592 | } | ||
1593 | |||
1558 | adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); | 1594 | adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); |
1559 | if (adev->rmmio == NULL) { | 1595 | if (adev->rmmio == NULL) { |
1560 | return -ENOMEM; | 1596 | return -ENOMEM; |
@@ -1562,8 +1598,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1562 | DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)adev->rmmio_base); | 1598 | DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)adev->rmmio_base); |
1563 | DRM_INFO("register mmio size: %u\n", (unsigned)adev->rmmio_size); | 1599 | DRM_INFO("register mmio size: %u\n", (unsigned)adev->rmmio_size); |
1564 | 1600 | ||
1565 | /* doorbell bar mapping */ | 1601 | if (adev->asic_type >= CHIP_BONAIRE) |
1566 | amdgpu_doorbell_init(adev); | 1602 | /* doorbell bar mapping */ |
1603 | amdgpu_doorbell_init(adev); | ||
1567 | 1604 | ||
1568 | /* io port mapping */ | 1605 | /* io port mapping */ |
1569 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 1606 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
@@ -1660,6 +1697,14 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1660 | 1697 | ||
1661 | adev->accel_working = true; | 1698 | adev->accel_working = true; |
1662 | 1699 | ||
1700 | /* Initialize the buffer migration limit. */ | ||
1701 | if (amdgpu_moverate >= 0) | ||
1702 | max_MBps = amdgpu_moverate; | ||
1703 | else | ||
1704 | max_MBps = 8; /* Allow 8 MB/s. */ | ||
1705 | /* Get a log2 for easy divisions. */ | ||
1706 | adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps)); | ||
1707 | |||
1663 | amdgpu_fbdev_init(adev); | 1708 | amdgpu_fbdev_init(adev); |
1664 | 1709 | ||
1665 | r = amdgpu_ib_pool_init(adev); | 1710 | r = amdgpu_ib_pool_init(adev); |
@@ -1764,7 +1809,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev) | |||
1764 | adev->rio_mem = NULL; | 1809 | adev->rio_mem = NULL; |
1765 | iounmap(adev->rmmio); | 1810 | iounmap(adev->rmmio); |
1766 | adev->rmmio = NULL; | 1811 | adev->rmmio = NULL; |
1767 | amdgpu_doorbell_fini(adev); | 1812 | if (adev->asic_type >= CHIP_BONAIRE) |
1813 | amdgpu_doorbell_fini(adev); | ||
1768 | amdgpu_debugfs_regs_cleanup(adev); | 1814 | amdgpu_debugfs_regs_cleanup(adev); |
1769 | amdgpu_debugfs_remove_files(adev); | 1815 | amdgpu_debugfs_remove_files(adev); |
1770 | } | 1816 | } |
@@ -1774,7 +1820,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) | |||
1774 | * Suspend & resume. | 1820 | * Suspend & resume. |
1775 | */ | 1821 | */ |
1776 | /** | 1822 | /** |
1777 | * amdgpu_suspend_kms - initiate device suspend | 1823 | * amdgpu_device_suspend - initiate device suspend |
1778 | * | 1824 | * |
1779 | * @pdev: drm dev pointer | 1825 | * @pdev: drm dev pointer |
1780 | * @state: suspend state | 1826 | * @state: suspend state |
@@ -1783,7 +1829,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) | |||
1783 | * Returns 0 for success or an error on failure. | 1829 | * Returns 0 for success or an error on failure. |
1784 | * Called at driver suspend. | 1830 | * Called at driver suspend. |
1785 | */ | 1831 | */ |
1786 | int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) | 1832 | int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) |
1787 | { | 1833 | { |
1788 | struct amdgpu_device *adev; | 1834 | struct amdgpu_device *adev; |
1789 | struct drm_crtc *crtc; | 1835 | struct drm_crtc *crtc; |
@@ -1796,7 +1842,8 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) | |||
1796 | 1842 | ||
1797 | adev = dev->dev_private; | 1843 | adev = dev->dev_private; |
1798 | 1844 | ||
1799 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) | 1845 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF || |
1846 | dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) | ||
1800 | return 0; | 1847 | return 0; |
1801 | 1848 | ||
1802 | drm_kms_helper_poll_disable(dev); | 1849 | drm_kms_helper_poll_disable(dev); |
@@ -1851,6 +1898,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) | |||
1851 | /* Shut down the device */ | 1898 | /* Shut down the device */ |
1852 | pci_disable_device(dev->pdev); | 1899 | pci_disable_device(dev->pdev); |
1853 | pci_set_power_state(dev->pdev, PCI_D3hot); | 1900 | pci_set_power_state(dev->pdev, PCI_D3hot); |
1901 | } else { | ||
1902 | r = amdgpu_asic_reset(adev); | ||
1903 | if (r) | ||
1904 | DRM_ERROR("amdgpu asic reset failed\n"); | ||
1854 | } | 1905 | } |
1855 | 1906 | ||
1856 | if (fbcon) { | 1907 | if (fbcon) { |
@@ -1862,7 +1913,7 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) | |||
1862 | } | 1913 | } |
1863 | 1914 | ||
1864 | /** | 1915 | /** |
1865 | * amdgpu_resume_kms - initiate device resume | 1916 | * amdgpu_device_resume - initiate device resume |
1866 | * | 1917 | * |
1867 | * @pdev: drm dev pointer | 1918 | * @pdev: drm dev pointer |
1868 | * | 1919 | * |
@@ -1870,32 +1921,37 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) | |||
1870 | * Returns 0 for success or an error on failure. | 1921 | * Returns 0 for success or an error on failure. |
1871 | * Called at driver resume. | 1922 | * Called at driver resume. |
1872 | */ | 1923 | */ |
1873 | int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon) | 1924 | int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) |
1874 | { | 1925 | { |
1875 | struct drm_connector *connector; | 1926 | struct drm_connector *connector; |
1876 | struct amdgpu_device *adev = dev->dev_private; | 1927 | struct amdgpu_device *adev = dev->dev_private; |
1877 | struct drm_crtc *crtc; | 1928 | struct drm_crtc *crtc; |
1878 | int r; | 1929 | int r; |
1879 | 1930 | ||
1880 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) | 1931 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF || |
1932 | dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) | ||
1881 | return 0; | 1933 | return 0; |
1882 | 1934 | ||
1883 | if (fbcon) { | 1935 | if (fbcon) |
1884 | console_lock(); | 1936 | console_lock(); |
1885 | } | 1937 | |
1886 | if (resume) { | 1938 | if (resume) { |
1887 | pci_set_power_state(dev->pdev, PCI_D0); | 1939 | pci_set_power_state(dev->pdev, PCI_D0); |
1888 | pci_restore_state(dev->pdev); | 1940 | pci_restore_state(dev->pdev); |
1889 | if (pci_enable_device(dev->pdev)) { | 1941 | r = pci_enable_device(dev->pdev); |
1942 | if (r) { | ||
1890 | if (fbcon) | 1943 | if (fbcon) |
1891 | console_unlock(); | 1944 | console_unlock(); |
1892 | return -1; | 1945 | return r; |
1893 | } | 1946 | } |
1894 | } | 1947 | } |
1895 | 1948 | ||
1896 | /* post card */ | 1949 | /* post card */ |
1897 | if (!amdgpu_card_posted(adev)) | 1950 | if (!amdgpu_card_posted(adev) || !resume) { |
1898 | amdgpu_atom_asic_init(adev->mode_info.atom_context); | 1951 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); |
1952 | if (r) | ||
1953 | DRM_ERROR("amdgpu asic init failed\n"); | ||
1954 | } | ||
1899 | 1955 | ||
1900 | r = amdgpu_resume(adev); | 1956 | r = amdgpu_resume(adev); |
1901 | if (r) | 1957 | if (r) |
@@ -2163,6 +2219,11 @@ retry: | |||
2163 | } | 2219 | } |
2164 | if (!r) { | 2220 | if (!r) { |
2165 | amdgpu_irq_gpu_reset_resume_helper(adev); | 2221 | amdgpu_irq_gpu_reset_resume_helper(adev); |
2222 | if (need_full_reset && amdgpu_need_backup(adev)) { | ||
2223 | r = amdgpu_ttm_recover_gart(adev); | ||
2224 | if (r) | ||
2225 | DRM_ERROR("gart recovery failed!!!\n"); | ||
2226 | } | ||
2166 | r = amdgpu_ib_ring_tests(adev); | 2227 | r = amdgpu_ib_ring_tests(adev); |
2167 | if (r) { | 2228 | if (r) { |
2168 | dev_err(adev->dev, "ib ring test failed (%d).\n", r); | 2229 | dev_err(adev->dev, "ib ring test failed (%d).\n", r); |
@@ -2600,7 +2661,7 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf, | |||
2600 | while (size) { | 2661 | while (size) { |
2601 | uint32_t value; | 2662 | uint32_t value; |
2602 | 2663 | ||
2603 | value = RREG32_SMC(*pos >> 2); | 2664 | value = RREG32_SMC(*pos); |
2604 | r = put_user(value, (uint32_t *)buf); | 2665 | r = put_user(value, (uint32_t *)buf); |
2605 | if (r) | 2666 | if (r) |
2606 | return r; | 2667 | return r; |
@@ -2631,7 +2692,7 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user * | |||
2631 | if (r) | 2692 | if (r) |
2632 | return r; | 2693 | return r; |
2633 | 2694 | ||
2634 | WREG32_SMC(*pos >> 2, value); | 2695 | WREG32_SMC(*pos, value); |
2635 | 2696 | ||
2636 | result += 4; | 2697 | result += 4; |
2637 | buf += 4; | 2698 | buf += 4; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 7c911d0be2b3..596362624610 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -55,13 +55,15 @@ | |||
55 | * - 3.3.0 - Add VM support for UVD on supported hardware. | 55 | * - 3.3.0 - Add VM support for UVD on supported hardware. |
56 | * - 3.4.0 - Add AMDGPU_INFO_NUM_EVICTIONS. | 56 | * - 3.4.0 - Add AMDGPU_INFO_NUM_EVICTIONS. |
57 | * - 3.5.0 - Add support for new UVD_NO_OP register. | 57 | * - 3.5.0 - Add support for new UVD_NO_OP register. |
58 | * - 3.6.0 - kmd involves use CONTEXT_CONTROL in ring buffer. | ||
58 | */ | 59 | */ |
59 | #define KMS_DRIVER_MAJOR 3 | 60 | #define KMS_DRIVER_MAJOR 3 |
60 | #define KMS_DRIVER_MINOR 5 | 61 | #define KMS_DRIVER_MINOR 6 |
61 | #define KMS_DRIVER_PATCHLEVEL 0 | 62 | #define KMS_DRIVER_PATCHLEVEL 0 |
62 | 63 | ||
63 | int amdgpu_vram_limit = 0; | 64 | int amdgpu_vram_limit = 0; |
64 | int amdgpu_gart_size = -1; /* auto */ | 65 | int amdgpu_gart_size = -1; /* auto */ |
66 | int amdgpu_moverate = -1; /* auto */ | ||
65 | int amdgpu_benchmarking = 0; | 67 | int amdgpu_benchmarking = 0; |
66 | int amdgpu_testing = 0; | 68 | int amdgpu_testing = 0; |
67 | int amdgpu_audio = -1; | 69 | int amdgpu_audio = -1; |
@@ -93,6 +95,7 @@ unsigned amdgpu_cg_mask = 0xffffffff; | |||
93 | unsigned amdgpu_pg_mask = 0xffffffff; | 95 | unsigned amdgpu_pg_mask = 0xffffffff; |
94 | char *amdgpu_disable_cu = NULL; | 96 | char *amdgpu_disable_cu = NULL; |
95 | char *amdgpu_virtual_display = NULL; | 97 | char *amdgpu_virtual_display = NULL; |
98 | unsigned amdgpu_pp_feature_mask = 0xffffffff; | ||
96 | 99 | ||
97 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); | 100 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); |
98 | module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); | 101 | module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); |
@@ -100,6 +103,9 @@ module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); | |||
100 | MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc., -1 = auto)"); | 103 | MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc., -1 = auto)"); |
101 | module_param_named(gartsize, amdgpu_gart_size, int, 0600); | 104 | module_param_named(gartsize, amdgpu_gart_size, int, 0600); |
102 | 105 | ||
106 | MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)"); | ||
107 | module_param_named(moverate, amdgpu_moverate, int, 0600); | ||
108 | |||
103 | MODULE_PARM_DESC(benchmark, "Run benchmark"); | 109 | MODULE_PARM_DESC(benchmark, "Run benchmark"); |
104 | module_param_named(benchmark, amdgpu_benchmarking, int, 0444); | 110 | module_param_named(benchmark, amdgpu_benchmarking, int, 0444); |
105 | 111 | ||
@@ -172,6 +178,9 @@ module_param_named(powerplay, amdgpu_powerplay, int, 0444); | |||
172 | 178 | ||
173 | MODULE_PARM_DESC(powercontainment, "Power Containment (1 = enable (default), 0 = disable)"); | 179 | MODULE_PARM_DESC(powercontainment, "Power Containment (1 = enable (default), 0 = disable)"); |
174 | module_param_named(powercontainment, amdgpu_powercontainment, int, 0444); | 180 | module_param_named(powercontainment, amdgpu_powercontainment, int, 0444); |
181 | |||
182 | MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))"); | ||
183 | module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, int, 0444); | ||
175 | #endif | 184 | #endif |
176 | 185 | ||
177 | MODULE_PARM_DESC(sclkdeepsleep, "SCLK Deep Sleep (1 = enable (default), 0 = disable)"); | 186 | MODULE_PARM_DESC(sclkdeepsleep, "SCLK Deep Sleep (1 = enable (default), 0 = disable)"); |
@@ -196,6 +205,80 @@ MODULE_PARM_DESC(virtual_display, "Enable virtual display feature (the virtual_d | |||
196 | module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444); | 205 | module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444); |
197 | 206 | ||
198 | static const struct pci_device_id pciidlist[] = { | 207 | static const struct pci_device_id pciidlist[] = { |
208 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
209 | {0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
210 | {0x1002, 0x6784, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
211 | {0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
212 | {0x1002, 0x678A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
213 | {0x1002, 0x6790, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
214 | {0x1002, 0x6791, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
215 | {0x1002, 0x6792, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
216 | {0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
217 | {0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
218 | {0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
219 | {0x1002, 0x679B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
220 | {0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
221 | {0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, | ||
222 | {0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY}, | ||
223 | {0x1002, 0x6801, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY}, | ||
224 | {0x1002, 0x6802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY}, | ||
225 | {0x1002, 0x6806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
226 | {0x1002, 0x6808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
227 | {0x1002, 0x6809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
228 | {0x1002, 0x6810, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
229 | {0x1002, 0x6811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
230 | {0x1002, 0x6816, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
231 | {0x1002, 0x6817, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
232 | {0x1002, 0x6818, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
233 | {0x1002, 0x6819, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN}, | ||
234 | {0x1002, 0x6600, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
235 | {0x1002, 0x6601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
236 | {0x1002, 0x6602, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
237 | {0x1002, 0x6603, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
238 | {0x1002, 0x6604, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
239 | {0x1002, 0x6605, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
240 | {0x1002, 0x6606, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
241 | {0x1002, 0x6607, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
242 | {0x1002, 0x6608, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND}, | ||
243 | {0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND}, | ||
244 | {0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND}, | ||
245 | {0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND}, | ||
246 | {0x1002, 0x6617, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
247 | {0x1002, 0x6620, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
248 | {0x1002, 0x6621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
249 | {0x1002, 0x6623, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY}, | ||
250 | {0x1002, 0x6631, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND}, | ||
251 | {0x1002, 0x6820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
252 | {0x1002, 0x6821, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
253 | {0x1002, 0x6822, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
254 | {0x1002, 0x6823, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
255 | {0x1002, 0x6824, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
256 | {0x1002, 0x6825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
257 | {0x1002, 0x6826, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
258 | {0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
259 | {0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
260 | {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
261 | {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
262 | {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
263 | {0x1002, 0x682C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
264 | {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
265 | {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
266 | {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
267 | {0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY}, | ||
268 | {0x1002, 0x6835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
269 | {0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
270 | {0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
271 | {0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
272 | {0x1002, 0x683B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
273 | {0x1002, 0x683D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
274 | {0x1002, 0x683F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE}, | ||
275 | {0x1002, 0x6660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, | ||
276 | {0x1002, 0x6663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, | ||
277 | {0x1002, 0x6664, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, | ||
278 | {0x1002, 0x6665, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, | ||
279 | {0x1002, 0x6667, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, | ||
280 | {0x1002, 0x666F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY}, | ||
281 | #endif | ||
199 | #ifdef CONFIG_DRM_AMDGPU_CIK | 282 | #ifdef CONFIG_DRM_AMDGPU_CIK |
200 | /* Kaveri */ | 283 | /* Kaveri */ |
201 | {0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU}, | 284 | {0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU}, |
@@ -393,32 +476,72 @@ amdgpu_pci_remove(struct pci_dev *pdev) | |||
393 | drm_put_dev(dev); | 476 | drm_put_dev(dev); |
394 | } | 477 | } |
395 | 478 | ||
479 | static void | ||
480 | amdgpu_pci_shutdown(struct pci_dev *pdev) | ||
481 | { | ||
482 | struct drm_device *dev = pci_get_drvdata(pdev); | ||
483 | struct amdgpu_device *adev = dev->dev_private; | ||
484 | |||
485 | /* if we are running in a VM, make sure the device | ||
486 | * torn down properly on reboot/shutdown | ||
487 | */ | ||
488 | if (adev->virtualization.is_virtual) | ||
489 | amdgpu_pci_remove(pdev); | ||
490 | } | ||
491 | |||
396 | static int amdgpu_pmops_suspend(struct device *dev) | 492 | static int amdgpu_pmops_suspend(struct device *dev) |
397 | { | 493 | { |
398 | struct pci_dev *pdev = to_pci_dev(dev); | 494 | struct pci_dev *pdev = to_pci_dev(dev); |
495 | |||
399 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | 496 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
400 | return amdgpu_suspend_kms(drm_dev, true, true); | 497 | return amdgpu_device_suspend(drm_dev, true, true); |
401 | } | 498 | } |
402 | 499 | ||
403 | static int amdgpu_pmops_resume(struct device *dev) | 500 | static int amdgpu_pmops_resume(struct device *dev) |
404 | { | 501 | { |
405 | struct pci_dev *pdev = to_pci_dev(dev); | 502 | struct pci_dev *pdev = to_pci_dev(dev); |
406 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | 503 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
407 | return amdgpu_resume_kms(drm_dev, true, true); | 504 | |
505 | /* GPU comes up enabled by the bios on resume */ | ||
506 | if (amdgpu_device_is_px(drm_dev)) { | ||
507 | pm_runtime_disable(dev); | ||
508 | pm_runtime_set_active(dev); | ||
509 | pm_runtime_enable(dev); | ||
510 | } | ||
511 | |||
512 | return amdgpu_device_resume(drm_dev, true, true); | ||
408 | } | 513 | } |
409 | 514 | ||
410 | static int amdgpu_pmops_freeze(struct device *dev) | 515 | static int amdgpu_pmops_freeze(struct device *dev) |
411 | { | 516 | { |
412 | struct pci_dev *pdev = to_pci_dev(dev); | 517 | struct pci_dev *pdev = to_pci_dev(dev); |
518 | |||
413 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | 519 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
414 | return amdgpu_suspend_kms(drm_dev, false, true); | 520 | return amdgpu_device_suspend(drm_dev, false, true); |
415 | } | 521 | } |
416 | 522 | ||
417 | static int amdgpu_pmops_thaw(struct device *dev) | 523 | static int amdgpu_pmops_thaw(struct device *dev) |
418 | { | 524 | { |
419 | struct pci_dev *pdev = to_pci_dev(dev); | 525 | struct pci_dev *pdev = to_pci_dev(dev); |
526 | |||
527 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
528 | return amdgpu_device_resume(drm_dev, false, true); | ||
529 | } | ||
530 | |||
531 | static int amdgpu_pmops_poweroff(struct device *dev) | ||
532 | { | ||
533 | struct pci_dev *pdev = to_pci_dev(dev); | ||
534 | |||
535 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
536 | return amdgpu_device_suspend(drm_dev, true, true); | ||
537 | } | ||
538 | |||
539 | static int amdgpu_pmops_restore(struct device *dev) | ||
540 | { | ||
541 | struct pci_dev *pdev = to_pci_dev(dev); | ||
542 | |||
420 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | 543 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
421 | return amdgpu_resume_kms(drm_dev, false, true); | 544 | return amdgpu_device_resume(drm_dev, false, true); |
422 | } | 545 | } |
423 | 546 | ||
424 | static int amdgpu_pmops_runtime_suspend(struct device *dev) | 547 | static int amdgpu_pmops_runtime_suspend(struct device *dev) |
@@ -436,7 +559,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) | |||
436 | drm_kms_helper_poll_disable(drm_dev); | 559 | drm_kms_helper_poll_disable(drm_dev); |
437 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF); | 560 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF); |
438 | 561 | ||
439 | ret = amdgpu_suspend_kms(drm_dev, false, false); | 562 | ret = amdgpu_device_suspend(drm_dev, false, false); |
440 | pci_save_state(pdev); | 563 | pci_save_state(pdev); |
441 | pci_disable_device(pdev); | 564 | pci_disable_device(pdev); |
442 | pci_ignore_hotplug(pdev); | 565 | pci_ignore_hotplug(pdev); |
@@ -469,7 +592,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) | |||
469 | return ret; | 592 | return ret; |
470 | pci_set_master(pdev); | 593 | pci_set_master(pdev); |
471 | 594 | ||
472 | ret = amdgpu_resume_kms(drm_dev, false, false); | 595 | ret = amdgpu_device_resume(drm_dev, false, false); |
473 | drm_kms_helper_poll_enable(drm_dev); | 596 | drm_kms_helper_poll_enable(drm_dev); |
474 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON); | 597 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON); |
475 | drm_dev->switch_power_state = DRM_SWITCH_POWER_ON; | 598 | drm_dev->switch_power_state = DRM_SWITCH_POWER_ON; |
@@ -523,8 +646,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = { | |||
523 | .resume = amdgpu_pmops_resume, | 646 | .resume = amdgpu_pmops_resume, |
524 | .freeze = amdgpu_pmops_freeze, | 647 | .freeze = amdgpu_pmops_freeze, |
525 | .thaw = amdgpu_pmops_thaw, | 648 | .thaw = amdgpu_pmops_thaw, |
526 | .poweroff = amdgpu_pmops_freeze, | 649 | .poweroff = amdgpu_pmops_poweroff, |
527 | .restore = amdgpu_pmops_resume, | 650 | .restore = amdgpu_pmops_restore, |
528 | .runtime_suspend = amdgpu_pmops_runtime_suspend, | 651 | .runtime_suspend = amdgpu_pmops_runtime_suspend, |
529 | .runtime_resume = amdgpu_pmops_runtime_resume, | 652 | .runtime_resume = amdgpu_pmops_runtime_resume, |
530 | .runtime_idle = amdgpu_pmops_runtime_idle, | 653 | .runtime_idle = amdgpu_pmops_runtime_idle, |
@@ -606,6 +729,7 @@ static struct pci_driver amdgpu_kms_pci_driver = { | |||
606 | .id_table = pciidlist, | 729 | .id_table = pciidlist, |
607 | .probe = amdgpu_pci_probe, | 730 | .probe = amdgpu_pci_probe, |
608 | .remove = amdgpu_pci_remove, | 731 | .remove = amdgpu_pci_remove, |
732 | .shutdown = amdgpu_pci_shutdown, | ||
609 | .driver.pm = &amdgpu_pm_ops, | 733 | .driver.pm = &amdgpu_pm_ops, |
610 | }; | 734 | }; |
611 | 735 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c index bf033b58056c..107fbb2d2847 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/pm_runtime.h> | ||
28 | 29 | ||
29 | #include <drm/drmP.h> | 30 | #include <drm/drmP.h> |
30 | #include <drm/drm_crtc.h> | 31 | #include <drm/drm_crtc.h> |
@@ -47,8 +48,35 @@ struct amdgpu_fbdev { | |||
47 | struct amdgpu_device *adev; | 48 | struct amdgpu_device *adev; |
48 | }; | 49 | }; |
49 | 50 | ||
51 | static int | ||
52 | amdgpufb_open(struct fb_info *info, int user) | ||
53 | { | ||
54 | struct amdgpu_fbdev *rfbdev = info->par; | ||
55 | struct amdgpu_device *adev = rfbdev->adev; | ||
56 | int ret = pm_runtime_get_sync(adev->ddev->dev); | ||
57 | if (ret < 0 && ret != -EACCES) { | ||
58 | pm_runtime_mark_last_busy(adev->ddev->dev); | ||
59 | pm_runtime_put_autosuspend(adev->ddev->dev); | ||
60 | return ret; | ||
61 | } | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int | ||
66 | amdgpufb_release(struct fb_info *info, int user) | ||
67 | { | ||
68 | struct amdgpu_fbdev *rfbdev = info->par; | ||
69 | struct amdgpu_device *adev = rfbdev->adev; | ||
70 | |||
71 | pm_runtime_mark_last_busy(adev->ddev->dev); | ||
72 | pm_runtime_put_autosuspend(adev->ddev->dev); | ||
73 | return 0; | ||
74 | } | ||
75 | |||
50 | static struct fb_ops amdgpufb_ops = { | 76 | static struct fb_ops amdgpufb_ops = { |
51 | .owner = THIS_MODULE, | 77 | .owner = THIS_MODULE, |
78 | .fb_open = amdgpufb_open, | ||
79 | .fb_release = amdgpufb_release, | ||
52 | .fb_check_var = drm_fb_helper_check_var, | 80 | .fb_check_var = drm_fb_helper_check_var, |
53 | .fb_set_par = drm_fb_helper_set_par, | 81 | .fb_set_par = drm_fb_helper_set_par, |
54 | .fb_fillrect = drm_fb_helper_cfb_fillrect, | 82 | .fb_fillrect = drm_fb_helper_cfb_fillrect, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index f5810f700668..4127e7ceace0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | |||
@@ -124,7 +124,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
124 | bool skip_preamble, need_ctx_switch; | 124 | bool skip_preamble, need_ctx_switch; |
125 | unsigned patch_offset = ~0; | 125 | unsigned patch_offset = ~0; |
126 | struct amdgpu_vm *vm; | 126 | struct amdgpu_vm *vm; |
127 | uint64_t ctx; | 127 | uint64_t fence_ctx; |
128 | uint32_t status = 0, alloc_size; | ||
128 | 129 | ||
129 | unsigned i; | 130 | unsigned i; |
130 | int r = 0; | 131 | int r = 0; |
@@ -135,10 +136,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
135 | /* ring tests don't use a job */ | 136 | /* ring tests don't use a job */ |
136 | if (job) { | 137 | if (job) { |
137 | vm = job->vm; | 138 | vm = job->vm; |
138 | ctx = job->ctx; | 139 | fence_ctx = job->fence_ctx; |
139 | } else { | 140 | } else { |
140 | vm = NULL; | 141 | vm = NULL; |
141 | ctx = 0; | 142 | fence_ctx = 0; |
142 | } | 143 | } |
143 | 144 | ||
144 | if (!ring->ready) { | 145 | if (!ring->ready) { |
@@ -151,7 +152,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
151 | return -EINVAL; | 152 | return -EINVAL; |
152 | } | 153 | } |
153 | 154 | ||
154 | r = amdgpu_ring_alloc(ring, 256 * num_ibs); | 155 | alloc_size = amdgpu_ring_get_dma_frame_size(ring) + |
156 | num_ibs * amdgpu_ring_get_emit_ib_size(ring); | ||
157 | |||
158 | r = amdgpu_ring_alloc(ring, alloc_size); | ||
155 | if (r) { | 159 | if (r) { |
156 | dev_err(adev->dev, "scheduling IB failed (%d).\n", r); | 160 | dev_err(adev->dev, "scheduling IB failed (%d).\n", r); |
157 | return r; | 161 | return r; |
@@ -174,13 +178,22 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
174 | /* always set cond_exec_polling to CONTINUE */ | 178 | /* always set cond_exec_polling to CONTINUE */ |
175 | *ring->cond_exe_cpu_addr = 1; | 179 | *ring->cond_exe_cpu_addr = 1; |
176 | 180 | ||
177 | skip_preamble = ring->current_ctx == ctx; | 181 | skip_preamble = ring->current_ctx == fence_ctx; |
178 | need_ctx_switch = ring->current_ctx != ctx; | 182 | need_ctx_switch = ring->current_ctx != fence_ctx; |
183 | if (job && ring->funcs->emit_cntxcntl) { | ||
184 | if (need_ctx_switch) | ||
185 | status |= AMDGPU_HAVE_CTX_SWITCH; | ||
186 | status |= job->preamble_status; | ||
187 | amdgpu_ring_emit_cntxcntl(ring, status); | ||
188 | } | ||
189 | |||
179 | for (i = 0; i < num_ibs; ++i) { | 190 | for (i = 0; i < num_ibs; ++i) { |
180 | ib = &ibs[i]; | 191 | ib = &ibs[i]; |
181 | 192 | ||
182 | /* drop preamble IBs if we don't have a context switch */ | 193 | /* drop preamble IBs if we don't have a context switch */ |
183 | if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && skip_preamble) | 194 | if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && |
195 | skip_preamble && | ||
196 | !(status & AMDGPU_PREAMBLE_IB_PRESENT_FIRST)) | ||
184 | continue; | 197 | continue; |
185 | 198 | ||
186 | amdgpu_ring_emit_ib(ring, ib, job ? job->vm_id : 0, | 199 | amdgpu_ring_emit_ib(ring, ib, job ? job->vm_id : 0, |
@@ -209,7 +222,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
209 | if (patch_offset != ~0 && ring->funcs->patch_cond_exec) | 222 | if (patch_offset != ~0 && ring->funcs->patch_cond_exec) |
210 | amdgpu_ring_patch_cond_exec(ring, patch_offset); | 223 | amdgpu_ring_patch_cond_exec(ring, patch_offset); |
211 | 224 | ||
212 | ring->current_ctx = ctx; | 225 | ring->current_ctx = fence_ctx; |
226 | if (ring->funcs->emit_switch_buffer) | ||
227 | amdgpu_ring_emit_switch_buffer(ring); | ||
213 | amdgpu_ring_commit(ring); | 228 | amdgpu_ring_commit(ring); |
214 | return 0; | 229 | return 0; |
215 | } | 230 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c index 5ebb3f43feb6..3ab4c65ecc8b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |||
@@ -119,8 +119,6 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size, | |||
119 | */ | 119 | */ |
120 | void amdgpu_ih_ring_fini(struct amdgpu_device *adev) | 120 | void amdgpu_ih_ring_fini(struct amdgpu_device *adev) |
121 | { | 121 | { |
122 | int r; | ||
123 | |||
124 | if (adev->irq.ih.use_bus_addr) { | 122 | if (adev->irq.ih.use_bus_addr) { |
125 | if (adev->irq.ih.ring) { | 123 | if (adev->irq.ih.ring) { |
126 | /* add 8 bytes for the rptr/wptr shadows and | 124 | /* add 8 bytes for the rptr/wptr shadows and |
@@ -132,17 +130,9 @@ void amdgpu_ih_ring_fini(struct amdgpu_device *adev) | |||
132 | adev->irq.ih.ring = NULL; | 130 | adev->irq.ih.ring = NULL; |
133 | } | 131 | } |
134 | } else { | 132 | } else { |
135 | if (adev->irq.ih.ring_obj) { | 133 | amdgpu_bo_free_kernel(&adev->irq.ih.ring_obj, |
136 | r = amdgpu_bo_reserve(adev->irq.ih.ring_obj, false); | 134 | &adev->irq.ih.gpu_addr, |
137 | if (likely(r == 0)) { | 135 | (void **)&adev->irq.ih.ring); |
138 | amdgpu_bo_kunmap(adev->irq.ih.ring_obj); | ||
139 | amdgpu_bo_unpin(adev->irq.ih.ring_obj); | ||
140 | amdgpu_bo_unreserve(adev->irq.ih.ring_obj); | ||
141 | } | ||
142 | amdgpu_bo_unref(&adev->irq.ih.ring_obj); | ||
143 | adev->irq.ih.ring = NULL; | ||
144 | adev->irq.ih.ring_obj = NULL; | ||
145 | } | ||
146 | amdgpu_wb_free(adev, adev->irq.ih.wptr_offs); | 136 | amdgpu_wb_free(adev, adev->irq.ih.wptr_offs); |
147 | amdgpu_wb_free(adev, adev->irq.ih.rptr_offs); | 137 | amdgpu_wb_free(adev, adev->irq.ih.rptr_offs); |
148 | } | 138 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 6674d40eb3ab..8c5807994073 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | |||
@@ -91,7 +91,7 @@ void amdgpu_job_free_resources(struct amdgpu_job *job) | |||
91 | amdgpu_ib_free(job->adev, &job->ibs[i], f); | 91 | amdgpu_ib_free(job->adev, &job->ibs[i], f); |
92 | } | 92 | } |
93 | 93 | ||
94 | void amdgpu_job_free_cb(struct amd_sched_job *s_job) | 94 | static void amdgpu_job_free_cb(struct amd_sched_job *s_job) |
95 | { | 95 | { |
96 | struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); | 96 | struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); |
97 | 97 | ||
@@ -124,7 +124,7 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, | |||
124 | return r; | 124 | return r; |
125 | 125 | ||
126 | job->owner = owner; | 126 | job->owner = owner; |
127 | job->ctx = entity->fence_context; | 127 | job->fence_ctx = entity->fence_context; |
128 | *f = fence_get(&job->base.s_fence->finished); | 128 | *f = fence_get(&job->base.s_fence->finished); |
129 | amdgpu_job_free_resources(job); | 129 | amdgpu_job_free_resources(job); |
130 | amd_sched_entity_push_job(&job->base); | 130 | amd_sched_entity_push_job(&job->base); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index b78e74048f3d..c2c7fb140338 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -296,7 +296,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
296 | break; | 296 | break; |
297 | case AMDGPU_HW_IP_VCE: | 297 | case AMDGPU_HW_IP_VCE: |
298 | type = AMD_IP_BLOCK_TYPE_VCE; | 298 | type = AMD_IP_BLOCK_TYPE_VCE; |
299 | for (i = 0; i < AMDGPU_MAX_VCE_RINGS; i++) | 299 | for (i = 0; i < adev->vce.num_rings; i++) |
300 | ring_mask |= ((adev->vce.ring[i].ready ? 1 : 0) << i); | 300 | ring_mask |= ((adev->vce.ring[i].ready ? 1 : 0) << i); |
301 | ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; | 301 | ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; |
302 | ib_size_alignment = 1; | 302 | ib_size_alignment = 1; |
@@ -542,12 +542,16 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
542 | return r; | 542 | return r; |
543 | 543 | ||
544 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); | 544 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); |
545 | if (unlikely(!fpriv)) | 545 | if (unlikely(!fpriv)) { |
546 | return -ENOMEM; | 546 | r = -ENOMEM; |
547 | goto out_suspend; | ||
548 | } | ||
547 | 549 | ||
548 | r = amdgpu_vm_init(adev, &fpriv->vm); | 550 | r = amdgpu_vm_init(adev, &fpriv->vm); |
549 | if (r) | 551 | if (r) { |
550 | goto error_free; | 552 | kfree(fpriv); |
553 | goto out_suspend; | ||
554 | } | ||
551 | 555 | ||
552 | mutex_init(&fpriv->bo_list_lock); | 556 | mutex_init(&fpriv->bo_list_lock); |
553 | idr_init(&fpriv->bo_list_handles); | 557 | idr_init(&fpriv->bo_list_handles); |
@@ -556,12 +560,9 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
556 | 560 | ||
557 | file_priv->driver_priv = fpriv; | 561 | file_priv->driver_priv = fpriv; |
558 | 562 | ||
563 | out_suspend: | ||
559 | pm_runtime_mark_last_busy(dev->dev); | 564 | pm_runtime_mark_last_busy(dev->dev); |
560 | pm_runtime_put_autosuspend(dev->dev); | 565 | pm_runtime_put_autosuspend(dev->dev); |
561 | return 0; | ||
562 | |||
563 | error_free: | ||
564 | kfree(fpriv); | ||
565 | 566 | ||
566 | return r; | 567 | return r; |
567 | } | 568 | } |
@@ -600,6 +601,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
600 | 601 | ||
601 | kfree(fpriv); | 602 | kfree(fpriv); |
602 | file_priv->driver_priv = NULL; | 603 | file_priv->driver_priv = NULL; |
604 | |||
605 | pm_runtime_mark_last_busy(dev->dev); | ||
606 | pm_runtime_put_autosuspend(dev->dev); | ||
603 | } | 607 | } |
604 | 608 | ||
605 | /** | 609 | /** |
@@ -614,6 +618,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
614 | void amdgpu_driver_preclose_kms(struct drm_device *dev, | 618 | void amdgpu_driver_preclose_kms(struct drm_device *dev, |
615 | struct drm_file *file_priv) | 619 | struct drm_file *file_priv) |
616 | { | 620 | { |
621 | pm_runtime_get_sync(dev->dev); | ||
617 | } | 622 | } |
618 | 623 | ||
619 | /* | 624 | /* |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index b17734e0ecc8..428aa00025e4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -38,8 +38,6 @@ | |||
38 | #include "amdgpu_trace.h" | 38 | #include "amdgpu_trace.h" |
39 | 39 | ||
40 | 40 | ||
41 | int amdgpu_ttm_init(struct amdgpu_device *adev); | ||
42 | void amdgpu_ttm_fini(struct amdgpu_device *adev); | ||
43 | 41 | ||
44 | static u64 amdgpu_get_vis_part_size(struct amdgpu_device *adev, | 42 | static u64 amdgpu_get_vis_part_size(struct amdgpu_device *adev, |
45 | struct ttm_mem_reg *mem) | 43 | struct ttm_mem_reg *mem) |
@@ -287,6 +285,35 @@ error_free: | |||
287 | return r; | 285 | return r; |
288 | } | 286 | } |
289 | 287 | ||
288 | /** | ||
289 | * amdgpu_bo_free_kernel - free BO for kernel use | ||
290 | * | ||
291 | * @bo: amdgpu BO to free | ||
292 | * | ||
293 | * unmaps and unpin a BO for kernel internal use. | ||
294 | */ | ||
295 | void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr, | ||
296 | void **cpu_addr) | ||
297 | { | ||
298 | if (*bo == NULL) | ||
299 | return; | ||
300 | |||
301 | if (likely(amdgpu_bo_reserve(*bo, false) == 0)) { | ||
302 | if (cpu_addr) | ||
303 | amdgpu_bo_kunmap(*bo); | ||
304 | |||
305 | amdgpu_bo_unpin(*bo); | ||
306 | amdgpu_bo_unreserve(*bo); | ||
307 | } | ||
308 | amdgpu_bo_unref(bo); | ||
309 | |||
310 | if (gpu_addr) | ||
311 | *gpu_addr = 0; | ||
312 | |||
313 | if (cpu_addr) | ||
314 | *cpu_addr = NULL; | ||
315 | } | ||
316 | |||
290 | int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | 317 | int amdgpu_bo_create_restricted(struct amdgpu_device *adev, |
291 | unsigned long size, int byte_align, | 318 | unsigned long size, int byte_align, |
292 | bool kernel, u32 domain, u64 flags, | 319 | bool kernel, u32 domain, u64 flags, |
@@ -646,6 +673,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, | |||
646 | dev_err(bo->adev->dev, "%p pin failed\n", bo); | 673 | dev_err(bo->adev->dev, "%p pin failed\n", bo); |
647 | goto error; | 674 | goto error; |
648 | } | 675 | } |
676 | r = amdgpu_ttm_bind(bo->tbo.ttm, &bo->tbo.mem); | ||
677 | if (unlikely(r)) { | ||
678 | dev_err(bo->adev->dev, "%p bind failed\n", bo); | ||
679 | goto error; | ||
680 | } | ||
649 | 681 | ||
650 | bo->pin_count = 1; | 682 | bo->pin_count = 1; |
651 | if (gpu_addr != NULL) | 683 | if (gpu_addr != NULL) |
@@ -692,7 +724,7 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo) | |||
692 | bo->adev->vram_pin_size -= amdgpu_bo_size(bo); | 724 | bo->adev->vram_pin_size -= amdgpu_bo_size(bo); |
693 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) | 725 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) |
694 | bo->adev->invisible_pin_size -= amdgpu_bo_size(bo); | 726 | bo->adev->invisible_pin_size -= amdgpu_bo_size(bo); |
695 | } else { | 727 | } else if (bo->tbo.mem.mem_type == TTM_PL_TT) { |
696 | bo->adev->gart_pin_size -= amdgpu_bo_size(bo); | 728 | bo->adev->gart_pin_size -= amdgpu_bo_size(bo); |
697 | } | 729 | } |
698 | 730 | ||
@@ -918,8 +950,11 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence, | |||
918 | u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) | 950 | u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) |
919 | { | 951 | { |
920 | WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); | 952 | WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); |
953 | WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_TT && | ||
954 | !amdgpu_ttm_is_bound(bo->tbo.ttm)); | ||
921 | WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) && | 955 | WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) && |
922 | !bo->pin_count); | 956 | !bo->pin_count); |
957 | WARN_ON_ONCE(bo->tbo.mem.start == AMDGPU_BO_INVALID_OFFSET); | ||
923 | 958 | ||
924 | return bo->tbo.offset; | 959 | return bo->tbo.offset; |
925 | } | 960 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index b6a27390ef88..8255034d73eb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <drm/amdgpu_drm.h> | 31 | #include <drm/amdgpu_drm.h> |
32 | #include "amdgpu.h" | 32 | #include "amdgpu.h" |
33 | 33 | ||
34 | #define AMDGPU_BO_INVALID_OFFSET LONG_MAX | ||
35 | |||
34 | /** | 36 | /** |
35 | * amdgpu_mem_type_to_domain - return domain corresponding to mem_type | 37 | * amdgpu_mem_type_to_domain - return domain corresponding to mem_type |
36 | * @mem_type: ttm memory type | 38 | * @mem_type: ttm memory type |
@@ -128,6 +130,8 @@ int amdgpu_bo_create_kernel(struct amdgpu_device *adev, | |||
128 | unsigned long size, int align, | 130 | unsigned long size, int align, |
129 | u32 domain, struct amdgpu_bo **bo_ptr, | 131 | u32 domain, struct amdgpu_bo **bo_ptr, |
130 | u64 *gpu_addr, void **cpu_addr); | 132 | u64 *gpu_addr, void **cpu_addr); |
133 | void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr, | ||
134 | void **cpu_addr); | ||
131 | int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr); | 135 | int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr); |
132 | void amdgpu_bo_kunmap(struct amdgpu_bo *bo); | 136 | void amdgpu_bo_kunmap(struct amdgpu_bo *bo); |
133 | struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo); | 137 | struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c index d15314957732..8e67c1210d7c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "amdgpu.h" | 25 | #include "amdgpu.h" |
26 | #include "atom.h" | 26 | #include "atom.h" |
27 | #include "atombios_encoders.h" | 27 | #include "atombios_encoders.h" |
28 | #include "amdgpu_pll.h" | ||
28 | #include <asm/div64.h> | 29 | #include <asm/div64.h> |
29 | #include <linux/gcd.h> | 30 | #include <linux/gcd.h> |
30 | 31 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c index 545074479e1f..1e7f160f23d8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "amdgpu_pm.h" | 30 | #include "amdgpu_pm.h" |
31 | #include <drm/amdgpu_drm.h> | 31 | #include <drm/amdgpu_drm.h> |
32 | #include "amdgpu_powerplay.h" | 32 | #include "amdgpu_powerplay.h" |
33 | #include "si_dpm.h" | ||
33 | #include "cik_dpm.h" | 34 | #include "cik_dpm.h" |
34 | #include "vi_dpm.h" | 35 | #include "vi_dpm.h" |
35 | 36 | ||
@@ -52,10 +53,6 @@ static int amdgpu_powerplay_init(struct amdgpu_device *adev) | |||
52 | pp_init->chip_family = adev->family; | 53 | pp_init->chip_family = adev->family; |
53 | pp_init->chip_id = adev->asic_type; | 54 | pp_init->chip_id = adev->asic_type; |
54 | pp_init->device = amdgpu_cgs_create_device(adev); | 55 | pp_init->device = amdgpu_cgs_create_device(adev); |
55 | pp_init->rev_id = adev->pdev->revision; | ||
56 | pp_init->sub_sys_id = adev->pdev->subsystem_device; | ||
57 | pp_init->sub_vendor_id = adev->pdev->subsystem_vendor; | ||
58 | |||
59 | ret = amd_powerplay_init(pp_init, amd_pp); | 56 | ret = amd_powerplay_init(pp_init, amd_pp); |
60 | kfree(pp_init); | 57 | kfree(pp_init); |
61 | #endif | 58 | #endif |
@@ -63,6 +60,15 @@ static int amdgpu_powerplay_init(struct amdgpu_device *adev) | |||
63 | amd_pp->pp_handle = (void *)adev; | 60 | amd_pp->pp_handle = (void *)adev; |
64 | 61 | ||
65 | switch (adev->asic_type) { | 62 | switch (adev->asic_type) { |
63 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
64 | case CHIP_TAHITI: | ||
65 | case CHIP_PITCAIRN: | ||
66 | case CHIP_VERDE: | ||
67 | case CHIP_OLAND: | ||
68 | case CHIP_HAINAN: | ||
69 | amd_pp->ip_funcs = &si_dpm_ip_funcs; | ||
70 | break; | ||
71 | #endif | ||
66 | #ifdef CONFIG_DRM_AMDGPU_CIK | 72 | #ifdef CONFIG_DRM_AMDGPU_CIK |
67 | case CHIP_BONAIRE: | 73 | case CHIP_BONAIRE: |
68 | case CHIP_HAWAII: | 74 | case CHIP_HAWAII: |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 242ba04bfde6..777f11b63b4c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -252,28 +252,17 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
252 | */ | 252 | */ |
253 | void amdgpu_ring_fini(struct amdgpu_ring *ring) | 253 | void amdgpu_ring_fini(struct amdgpu_ring *ring) |
254 | { | 254 | { |
255 | int r; | ||
256 | struct amdgpu_bo *ring_obj; | ||
257 | |||
258 | ring_obj = ring->ring_obj; | ||
259 | ring->ready = false; | 255 | ring->ready = false; |
260 | ring->ring = NULL; | ||
261 | ring->ring_obj = NULL; | ||
262 | 256 | ||
263 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); | 257 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); |
264 | amdgpu_wb_free(ring->adev, ring->fence_offs); | 258 | amdgpu_wb_free(ring->adev, ring->fence_offs); |
265 | amdgpu_wb_free(ring->adev, ring->rptr_offs); | 259 | amdgpu_wb_free(ring->adev, ring->rptr_offs); |
266 | amdgpu_wb_free(ring->adev, ring->wptr_offs); | 260 | amdgpu_wb_free(ring->adev, ring->wptr_offs); |
267 | 261 | ||
268 | if (ring_obj) { | 262 | amdgpu_bo_free_kernel(&ring->ring_obj, |
269 | r = amdgpu_bo_reserve(ring_obj, false); | 263 | &ring->gpu_addr, |
270 | if (likely(r == 0)) { | 264 | (void **)&ring->ring); |
271 | amdgpu_bo_kunmap(ring_obj); | 265 | |
272 | amdgpu_bo_unpin(ring_obj); | ||
273 | amdgpu_bo_unreserve(ring_obj); | ||
274 | } | ||
275 | amdgpu_bo_unref(&ring_obj); | ||
276 | } | ||
277 | amdgpu_debugfs_ring_fini(ring); | 266 | amdgpu_debugfs_ring_fini(ring); |
278 | } | 267 | } |
279 | 268 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 5447973483ec..dfb12237a6b0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -89,10 +89,10 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
89 | global_ref->init = &amdgpu_ttm_mem_global_init; | 89 | global_ref->init = &amdgpu_ttm_mem_global_init; |
90 | global_ref->release = &amdgpu_ttm_mem_global_release; | 90 | global_ref->release = &amdgpu_ttm_mem_global_release; |
91 | r = drm_global_item_ref(global_ref); | 91 | r = drm_global_item_ref(global_ref); |
92 | if (r != 0) { | 92 | if (r) { |
93 | DRM_ERROR("Failed setting up TTM memory accounting " | 93 | DRM_ERROR("Failed setting up TTM memory accounting " |
94 | "subsystem.\n"); | 94 | "subsystem.\n"); |
95 | return r; | 95 | goto error_mem; |
96 | } | 96 | } |
97 | 97 | ||
98 | adev->mman.bo_global_ref.mem_glob = | 98 | adev->mman.bo_global_ref.mem_glob = |
@@ -103,26 +103,30 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
103 | global_ref->init = &ttm_bo_global_init; | 103 | global_ref->init = &ttm_bo_global_init; |
104 | global_ref->release = &ttm_bo_global_release; | 104 | global_ref->release = &ttm_bo_global_release; |
105 | r = drm_global_item_ref(global_ref); | 105 | r = drm_global_item_ref(global_ref); |
106 | if (r != 0) { | 106 | if (r) { |
107 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); | 107 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); |
108 | drm_global_item_unref(&adev->mman.mem_global_ref); | 108 | goto error_bo; |
109 | return r; | ||
110 | } | 109 | } |
111 | 110 | ||
112 | ring = adev->mman.buffer_funcs_ring; | 111 | ring = adev->mman.buffer_funcs_ring; |
113 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL]; | 112 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL]; |
114 | r = amd_sched_entity_init(&ring->sched, &adev->mman.entity, | 113 | r = amd_sched_entity_init(&ring->sched, &adev->mman.entity, |
115 | rq, amdgpu_sched_jobs); | 114 | rq, amdgpu_sched_jobs); |
116 | if (r != 0) { | 115 | if (r) { |
117 | DRM_ERROR("Failed setting up TTM BO move run queue.\n"); | 116 | DRM_ERROR("Failed setting up TTM BO move run queue.\n"); |
118 | drm_global_item_unref(&adev->mman.mem_global_ref); | 117 | goto error_entity; |
119 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); | ||
120 | return r; | ||
121 | } | 118 | } |
122 | 119 | ||
123 | adev->mman.mem_global_referenced = true; | 120 | adev->mman.mem_global_referenced = true; |
124 | 121 | ||
125 | return 0; | 122 | return 0; |
123 | |||
124 | error_entity: | ||
125 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); | ||
126 | error_bo: | ||
127 | drm_global_item_unref(&adev->mman.mem_global_ref); | ||
128 | error_mem: | ||
129 | return r; | ||
126 | } | 130 | } |
127 | 131 | ||
128 | static void amdgpu_ttm_global_fini(struct amdgpu_device *adev) | 132 | static void amdgpu_ttm_global_fini(struct amdgpu_device *adev) |
@@ -197,6 +201,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
197 | .lpfn = 0, | 201 | .lpfn = 0, |
198 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | 202 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM |
199 | }; | 203 | }; |
204 | unsigned i; | ||
200 | 205 | ||
201 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) { | 206 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) { |
202 | placement->placement = &placements; | 207 | placement->placement = &placements; |
@@ -208,10 +213,25 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
208 | rbo = container_of(bo, struct amdgpu_bo, tbo); | 213 | rbo = container_of(bo, struct amdgpu_bo, tbo); |
209 | switch (bo->mem.mem_type) { | 214 | switch (bo->mem.mem_type) { |
210 | case TTM_PL_VRAM: | 215 | case TTM_PL_VRAM: |
211 | if (rbo->adev->mman.buffer_funcs_ring->ready == false) | 216 | if (rbo->adev->mman.buffer_funcs_ring->ready == false) { |
212 | amdgpu_ttm_placement_from_domain(rbo, AMDGPU_GEM_DOMAIN_CPU); | 217 | amdgpu_ttm_placement_from_domain(rbo, AMDGPU_GEM_DOMAIN_CPU); |
213 | else | 218 | } else { |
214 | amdgpu_ttm_placement_from_domain(rbo, AMDGPU_GEM_DOMAIN_GTT); | 219 | amdgpu_ttm_placement_from_domain(rbo, AMDGPU_GEM_DOMAIN_GTT); |
220 | for (i = 0; i < rbo->placement.num_placement; ++i) { | ||
221 | if (!(rbo->placements[i].flags & | ||
222 | TTM_PL_FLAG_TT)) | ||
223 | continue; | ||
224 | |||
225 | if (rbo->placements[i].lpfn) | ||
226 | continue; | ||
227 | |||
228 | /* set an upper limit to force directly | ||
229 | * allocating address space for the BO. | ||
230 | */ | ||
231 | rbo->placements[i].lpfn = | ||
232 | rbo->adev->mc.gtt_size >> PAGE_SHIFT; | ||
233 | } | ||
234 | } | ||
215 | break; | 235 | break; |
216 | case TTM_PL_TT: | 236 | case TTM_PL_TT: |
217 | default: | 237 | default: |
@@ -256,8 +276,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, | |||
256 | new_start = new_mem->start << PAGE_SHIFT; | 276 | new_start = new_mem->start << PAGE_SHIFT; |
257 | 277 | ||
258 | switch (old_mem->mem_type) { | 278 | switch (old_mem->mem_type) { |
259 | case TTM_PL_VRAM: | ||
260 | case TTM_PL_TT: | 279 | case TTM_PL_TT: |
280 | r = amdgpu_ttm_bind(bo->ttm, old_mem); | ||
281 | if (r) | ||
282 | return r; | ||
283 | |||
284 | case TTM_PL_VRAM: | ||
261 | old_start += bo->bdev->man[old_mem->mem_type].gpu_offset; | 285 | old_start += bo->bdev->man[old_mem->mem_type].gpu_offset; |
262 | break; | 286 | break; |
263 | default: | 287 | default: |
@@ -265,8 +289,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, | |||
265 | return -EINVAL; | 289 | return -EINVAL; |
266 | } | 290 | } |
267 | switch (new_mem->mem_type) { | 291 | switch (new_mem->mem_type) { |
268 | case TTM_PL_VRAM: | ||
269 | case TTM_PL_TT: | 292 | case TTM_PL_TT: |
293 | r = amdgpu_ttm_bind(bo->ttm, new_mem); | ||
294 | if (r) | ||
295 | return r; | ||
296 | |||
297 | case TTM_PL_VRAM: | ||
270 | new_start += bo->bdev->man[new_mem->mem_type].gpu_offset; | 298 | new_start += bo->bdev->man[new_mem->mem_type].gpu_offset; |
271 | break; | 299 | break; |
272 | default: | 300 | default: |
@@ -311,7 +339,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, | |||
311 | placement.num_busy_placement = 1; | 339 | placement.num_busy_placement = 1; |
312 | placement.busy_placement = &placements; | 340 | placement.busy_placement = &placements; |
313 | placements.fpfn = 0; | 341 | placements.fpfn = 0; |
314 | placements.lpfn = 0; | 342 | placements.lpfn = adev->mc.gtt_size >> PAGE_SHIFT; |
315 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; | 343 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; |
316 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, | 344 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, |
317 | interruptible, no_wait_gpu); | 345 | interruptible, no_wait_gpu); |
@@ -358,7 +386,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, | |||
358 | placement.num_busy_placement = 1; | 386 | placement.num_busy_placement = 1; |
359 | placement.busy_placement = &placements; | 387 | placement.busy_placement = &placements; |
360 | placements.fpfn = 0; | 388 | placements.fpfn = 0; |
361 | placements.lpfn = 0; | 389 | placements.lpfn = adev->mc.gtt_size >> PAGE_SHIFT; |
362 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; | 390 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; |
363 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, | 391 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, |
364 | interruptible, no_wait_gpu); | 392 | interruptible, no_wait_gpu); |
@@ -520,6 +548,7 @@ struct amdgpu_ttm_tt { | |||
520 | spinlock_t guptasklock; | 548 | spinlock_t guptasklock; |
521 | struct list_head guptasks; | 549 | struct list_head guptasks; |
522 | atomic_t mmu_invalidations; | 550 | atomic_t mmu_invalidations; |
551 | struct list_head list; | ||
523 | }; | 552 | }; |
524 | 553 | ||
525 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) | 554 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) |
@@ -637,7 +666,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
637 | struct ttm_mem_reg *bo_mem) | 666 | struct ttm_mem_reg *bo_mem) |
638 | { | 667 | { |
639 | struct amdgpu_ttm_tt *gtt = (void*)ttm; | 668 | struct amdgpu_ttm_tt *gtt = (void*)ttm; |
640 | uint32_t flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, bo_mem); | ||
641 | int r; | 669 | int r; |
642 | 670 | ||
643 | if (gtt->userptr) { | 671 | if (gtt->userptr) { |
@@ -647,7 +675,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
647 | return r; | 675 | return r; |
648 | } | 676 | } |
649 | } | 677 | } |
650 | gtt->offset = (unsigned long)(bo_mem->start << PAGE_SHIFT); | 678 | gtt->offset = (u64)bo_mem->start << PAGE_SHIFT; |
651 | if (!ttm->num_pages) { | 679 | if (!ttm->num_pages) { |
652 | WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n", | 680 | WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n", |
653 | ttm->num_pages, bo_mem, ttm); | 681 | ttm->num_pages, bo_mem, ttm); |
@@ -658,14 +686,62 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
658 | bo_mem->mem_type == AMDGPU_PL_OA) | 686 | bo_mem->mem_type == AMDGPU_PL_OA) |
659 | return -EINVAL; | 687 | return -EINVAL; |
660 | 688 | ||
689 | return 0; | ||
690 | } | ||
691 | |||
692 | bool amdgpu_ttm_is_bound(struct ttm_tt *ttm) | ||
693 | { | ||
694 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | ||
695 | |||
696 | return gtt && !list_empty(>t->list); | ||
697 | } | ||
698 | |||
699 | int amdgpu_ttm_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) | ||
700 | { | ||
701 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | ||
702 | uint32_t flags; | ||
703 | int r; | ||
704 | |||
705 | if (!ttm || amdgpu_ttm_is_bound(ttm)) | ||
706 | return 0; | ||
707 | |||
708 | flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, bo_mem); | ||
661 | r = amdgpu_gart_bind(gtt->adev, gtt->offset, ttm->num_pages, | 709 | r = amdgpu_gart_bind(gtt->adev, gtt->offset, ttm->num_pages, |
662 | ttm->pages, gtt->ttm.dma_address, flags); | 710 | ttm->pages, gtt->ttm.dma_address, flags); |
663 | 711 | ||
664 | if (r) { | 712 | if (r) { |
665 | DRM_ERROR("failed to bind %lu pages at 0x%08X\n", | 713 | DRM_ERROR("failed to bind %lu pages at 0x%08llX\n", |
666 | ttm->num_pages, (unsigned)gtt->offset); | 714 | ttm->num_pages, gtt->offset); |
667 | return r; | 715 | return r; |
668 | } | 716 | } |
717 | spin_lock(>t->adev->gtt_list_lock); | ||
718 | list_add_tail(>t->list, >t->adev->gtt_list); | ||
719 | spin_unlock(>t->adev->gtt_list_lock); | ||
720 | return 0; | ||
721 | } | ||
722 | |||
723 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev) | ||
724 | { | ||
725 | struct amdgpu_ttm_tt *gtt, *tmp; | ||
726 | struct ttm_mem_reg bo_mem; | ||
727 | uint32_t flags; | ||
728 | int r; | ||
729 | |||
730 | bo_mem.mem_type = TTM_PL_TT; | ||
731 | spin_lock(&adev->gtt_list_lock); | ||
732 | list_for_each_entry_safe(gtt, tmp, &adev->gtt_list, list) { | ||
733 | flags = amdgpu_ttm_tt_pte_flags(gtt->adev, >t->ttm.ttm, &bo_mem); | ||
734 | r = amdgpu_gart_bind(adev, gtt->offset, gtt->ttm.ttm.num_pages, | ||
735 | gtt->ttm.ttm.pages, gtt->ttm.dma_address, | ||
736 | flags); | ||
737 | if (r) { | ||
738 | spin_unlock(&adev->gtt_list_lock); | ||
739 | DRM_ERROR("failed to bind %lu pages at 0x%08llX\n", | ||
740 | gtt->ttm.ttm.num_pages, gtt->offset); | ||
741 | return r; | ||
742 | } | ||
743 | } | ||
744 | spin_unlock(&adev->gtt_list_lock); | ||
669 | return 0; | 745 | return 0; |
670 | } | 746 | } |
671 | 747 | ||
@@ -673,6 +749,9 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm) | |||
673 | { | 749 | { |
674 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 750 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
675 | 751 | ||
752 | if (!amdgpu_ttm_is_bound(ttm)) | ||
753 | return 0; | ||
754 | |||
676 | /* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */ | 755 | /* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */ |
677 | if (gtt->adev->gart.ready) | 756 | if (gtt->adev->gart.ready) |
678 | amdgpu_gart_unbind(gtt->adev, gtt->offset, ttm->num_pages); | 757 | amdgpu_gart_unbind(gtt->adev, gtt->offset, ttm->num_pages); |
@@ -680,6 +759,10 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm) | |||
680 | if (gtt->userptr) | 759 | if (gtt->userptr) |
681 | amdgpu_ttm_tt_unpin_userptr(ttm); | 760 | amdgpu_ttm_tt_unpin_userptr(ttm); |
682 | 761 | ||
762 | spin_lock(>t->adev->gtt_list_lock); | ||
763 | list_del_init(>t->list); | ||
764 | spin_unlock(>t->adev->gtt_list_lock); | ||
765 | |||
683 | return 0; | 766 | return 0; |
684 | } | 767 | } |
685 | 768 | ||
@@ -716,6 +799,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev, | |||
716 | kfree(gtt); | 799 | kfree(gtt); |
717 | return NULL; | 800 | return NULL; |
718 | } | 801 | } |
802 | INIT_LIST_HEAD(>t->list); | ||
719 | return >t->ttm.ttm; | 803 | return >t->ttm.ttm; |
720 | } | 804 | } |
721 | 805 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 72f6bfc15d8f..3ee825f4de28 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | |||
@@ -26,13 +26,13 @@ | |||
26 | 26 | ||
27 | #include "gpu_scheduler.h" | 27 | #include "gpu_scheduler.h" |
28 | 28 | ||
29 | #define AMDGPU_PL_GDS TTM_PL_PRIV0 | 29 | #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) |
30 | #define AMDGPU_PL_GWS TTM_PL_PRIV1 | 30 | #define AMDGPU_PL_GWS (TTM_PL_PRIV + 1) |
31 | #define AMDGPU_PL_OA TTM_PL_PRIV2 | 31 | #define AMDGPU_PL_OA (TTM_PL_PRIV + 2) |
32 | 32 | ||
33 | #define AMDGPU_PL_FLAG_GDS TTM_PL_FLAG_PRIV0 | 33 | #define AMDGPU_PL_FLAG_GDS (TTM_PL_FLAG_PRIV << 0) |
34 | #define AMDGPU_PL_FLAG_GWS TTM_PL_FLAG_PRIV1 | 34 | #define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) |
35 | #define AMDGPU_PL_FLAG_OA TTM_PL_FLAG_PRIV2 | 35 | #define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) |
36 | 36 | ||
37 | #define AMDGPU_TTM_LRU_SIZE 20 | 37 | #define AMDGPU_TTM_LRU_SIZE 20 |
38 | 38 | ||
@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, | |||
77 | struct fence **fence); | 77 | struct fence **fence); |
78 | 78 | ||
79 | int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma); | 79 | int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma); |
80 | bool amdgpu_ttm_is_bound(struct ttm_tt *ttm); | ||
81 | int amdgpu_ttm_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem); | ||
82 | |||
80 | #endif | 83 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c index 5cc95f1a7dab..7a05f79818f1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | |||
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) | |||
247 | const struct common_firmware_header *header = NULL; | 247 | const struct common_firmware_header *header = NULL; |
248 | 248 | ||
249 | err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true, | 249 | err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true, |
250 | AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo); | 250 | AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo); |
251 | if (err) { | 251 | if (err) { |
252 | dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err); | 252 | dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err); |
253 | err = -ENOMEM; | ||
254 | goto failed; | 253 | goto failed; |
255 | } | 254 | } |
256 | 255 | ||
257 | err = amdgpu_bo_reserve(*bo, false); | 256 | err = amdgpu_bo_reserve(*bo, false); |
258 | if (err) { | 257 | if (err) { |
259 | amdgpu_bo_unref(bo); | ||
260 | dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err); | 258 | dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err); |
261 | goto failed; | 259 | goto failed_reserve; |
262 | } | 260 | } |
263 | 261 | ||
264 | err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr); | 262 | err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr); |
265 | if (err) { | 263 | if (err) { |
266 | amdgpu_bo_unreserve(*bo); | ||
267 | amdgpu_bo_unref(bo); | ||
268 | dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err); | 264 | dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err); |
269 | goto failed; | 265 | goto failed_pin; |
270 | } | 266 | } |
271 | 267 | ||
272 | err = amdgpu_bo_kmap(*bo, &fw_buf_ptr); | 268 | err = amdgpu_bo_kmap(*bo, &fw_buf_ptr); |
273 | if (err) { | 269 | if (err) { |
274 | dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err); | 270 | dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err); |
275 | amdgpu_bo_unpin(*bo); | 271 | goto failed_kmap; |
276 | amdgpu_bo_unreserve(*bo); | ||
277 | amdgpu_bo_unref(bo); | ||
278 | goto failed; | ||
279 | } | 272 | } |
280 | 273 | ||
281 | amdgpu_bo_unreserve(*bo); | 274 | amdgpu_bo_unreserve(*bo); |
@@ -290,10 +283,16 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) | |||
290 | fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 283 | fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); |
291 | } | 284 | } |
292 | } | 285 | } |
286 | return 0; | ||
293 | 287 | ||
288 | failed_kmap: | ||
289 | amdgpu_bo_unpin(*bo); | ||
290 | failed_pin: | ||
291 | amdgpu_bo_unreserve(*bo); | ||
292 | failed_reserve: | ||
293 | amdgpu_bo_unref(bo); | ||
294 | failed: | 294 | failed: |
295 | if (err) | 295 | adev->firmware.smu_load = false; |
296 | adev->firmware.smu_load = false; | ||
297 | 296 | ||
298 | return err; | 297 | return err; |
299 | } | 298 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index cc766cc53a87..25dd58a65905 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | |||
@@ -249,22 +249,13 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
249 | 249 | ||
250 | int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) | 250 | int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) |
251 | { | 251 | { |
252 | int r; | ||
253 | |||
254 | kfree(adev->uvd.saved_bo); | 252 | kfree(adev->uvd.saved_bo); |
255 | 253 | ||
256 | amd_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity); | 254 | amd_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity); |
257 | 255 | ||
258 | if (adev->uvd.vcpu_bo) { | 256 | amdgpu_bo_free_kernel(&adev->uvd.vcpu_bo, |
259 | r = amdgpu_bo_reserve(adev->uvd.vcpu_bo, false); | 257 | &adev->uvd.gpu_addr, |
260 | if (!r) { | 258 | (void **)&adev->uvd.cpu_addr); |
261 | amdgpu_bo_kunmap(adev->uvd.vcpu_bo); | ||
262 | amdgpu_bo_unpin(adev->uvd.vcpu_bo); | ||
263 | amdgpu_bo_unreserve(adev->uvd.vcpu_bo); | ||
264 | } | ||
265 | |||
266 | amdgpu_bo_unref(&adev->uvd.vcpu_bo); | ||
267 | } | ||
268 | 259 | ||
269 | amdgpu_ring_fini(&adev->uvd.ring); | 260 | amdgpu_ring_fini(&adev->uvd.ring); |
270 | 261 | ||
@@ -891,6 +882,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) | |||
891 | return -EINVAL; | 882 | return -EINVAL; |
892 | } | 883 | } |
893 | 884 | ||
885 | r = amdgpu_cs_sysvm_access_required(parser); | ||
886 | if (r) | ||
887 | return r; | ||
888 | |||
894 | ctx.parser = parser; | 889 | ctx.parser = parser; |
895 | ctx.buf_sizes = buf_sizes; | 890 | ctx.buf_sizes = buf_sizes; |
896 | ctx.ib_idx = ib_idx; | 891 | ctx.ib_idx = ib_idx; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c index da52af2a935a..2c9ea9b50f48 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | |||
@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) | |||
634 | uint32_t allocated = 0; | 634 | uint32_t allocated = 0; |
635 | uint32_t tmp, handle = 0; | 635 | uint32_t tmp, handle = 0; |
636 | uint32_t *size = &tmp; | 636 | uint32_t *size = &tmp; |
637 | int i, r = 0, idx = 0; | 637 | int i, r, idx = 0; |
638 | |||
639 | r = amdgpu_cs_sysvm_access_required(p); | ||
640 | if (r) | ||
641 | return r; | ||
638 | 642 | ||
639 | while (idx < ib->length_dw) { | 643 | while (idx < ib->length_dw) { |
640 | uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); | 644 | uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); |
@@ -799,6 +803,18 @@ void amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, | |||
799 | amdgpu_ring_write(ring, VCE_CMD_END); | 803 | amdgpu_ring_write(ring, VCE_CMD_END); |
800 | } | 804 | } |
801 | 805 | ||
806 | unsigned amdgpu_vce_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
807 | { | ||
808 | return | ||
809 | 4; /* amdgpu_vce_ring_emit_ib */ | ||
810 | } | ||
811 | |||
812 | unsigned amdgpu_vce_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
813 | { | ||
814 | return | ||
815 | 6; /* amdgpu_vce_ring_emit_fence x1 no user fence */ | ||
816 | } | ||
817 | |||
802 | /** | 818 | /** |
803 | * amdgpu_vce_ring_test_ring - test if VCE ring is working | 819 | * amdgpu_vce_ring_test_ring - test if VCE ring is working |
804 | * | 820 | * |
@@ -850,8 +866,8 @@ int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
850 | struct fence *fence = NULL; | 866 | struct fence *fence = NULL; |
851 | long r; | 867 | long r; |
852 | 868 | ||
853 | /* skip vce ring1 ib test for now, since it's not reliable */ | 869 | /* skip vce ring1/2 ib test for now, since it's not reliable */ |
854 | if (ring == &ring->adev->vce.ring[1]) | 870 | if (ring != &ring->adev->vce.ring[0]) |
855 | return 0; | 871 | return 0; |
856 | 872 | ||
857 | r = amdgpu_vce_get_create_msg(ring, 1, NULL); | 873 | r = amdgpu_vce_get_create_msg(ring, 1, NULL); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h index 63f83d0d985c..12729d2852df 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | |||
@@ -42,5 +42,7 @@ int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring); | |||
42 | int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout); | 42 | int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout); |
43 | void amdgpu_vce_ring_begin_use(struct amdgpu_ring *ring); | 43 | void amdgpu_vce_ring_begin_use(struct amdgpu_ring *ring); |
44 | void amdgpu_vce_ring_end_use(struct amdgpu_ring *ring); | 44 | void amdgpu_vce_ring_end_use(struct amdgpu_ring *ring); |
45 | unsigned amdgpu_vce_ring_get_emit_ib_size(struct amdgpu_ring *ring); | ||
46 | unsigned amdgpu_vce_ring_get_dma_frame_size(struct amdgpu_ring *ring); | ||
45 | 47 | ||
46 | #endif | 48 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index bf56f1814437..bd5af328154f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -1163,7 +1163,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, | |||
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | flags = amdgpu_ttm_tt_pte_flags(adev, bo_va->bo->tbo.ttm, mem); | 1165 | flags = amdgpu_ttm_tt_pte_flags(adev, bo_va->bo->tbo.ttm, mem); |
1166 | gtt_flags = (adev == bo_va->bo->adev) ? flags : 0; | 1166 | gtt_flags = (amdgpu_ttm_is_bound(bo_va->bo->tbo.ttm) && |
1167 | adev == bo_va->bo->adev) ? flags : 0; | ||
1167 | 1168 | ||
1168 | spin_lock(&vm->status_lock); | 1169 | spin_lock(&vm->status_lock); |
1169 | if (!list_empty(&bo_va->vm_status)) | 1170 | if (!list_empty(&bo_va->vm_status)) |
diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c b/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c index 49a39b1a0a96..f7d236f95e74 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c | |||
@@ -497,7 +497,13 @@ void amdgpu_atombios_crtc_set_disp_eng_pll(struct amdgpu_device *adev, | |||
497 | * SetPixelClock provides the dividers | 497 | * SetPixelClock provides the dividers |
498 | */ | 498 | */ |
499 | args.v6.ulDispEngClkFreq = cpu_to_le32(dispclk); | 499 | args.v6.ulDispEngClkFreq = cpu_to_le32(dispclk); |
500 | args.v6.ucPpll = ATOM_EXT_PLL1; | 500 | if (adev->asic_type == CHIP_TAHITI || |
501 | adev->asic_type == CHIP_PITCAIRN || | ||
502 | adev->asic_type == CHIP_VERDE || | ||
503 | adev->asic_type == CHIP_OLAND) | ||
504 | args.v6.ucPpll = ATOM_PPLL0; | ||
505 | else | ||
506 | args.v6.ucPpll = ATOM_EXT_PLL1; | ||
501 | break; | 507 | break; |
502 | default: | 508 | default: |
503 | DRM_ERROR("Unknown table version %d %d\n", frev, crev); | 509 | DRM_ERROR("Unknown table version %d %d\n", frev, crev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c b/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c index bc56c8a181e6..b374653bd6cf 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "amdgpu.h" | 27 | #include "amdgpu.h" |
28 | #include "atom.h" | 28 | #include "atom.h" |
29 | #include "amdgpu_atombios.h" | 29 | #include "amdgpu_atombios.h" |
30 | #include "atombios_i2c.h" | ||
30 | 31 | ||
31 | #define TARGET_HW_I2C_CLOCK 50 | 32 | #define TARGET_HW_I2C_CLOCK 50 |
32 | 33 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index a0d63a293bb0..1d8c375a3561 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
@@ -5396,7 +5396,7 @@ static void ci_dpm_disable(struct amdgpu_device *adev) | |||
5396 | amdgpu_irq_put(adev, &adev->pm.dpm.thermal.irq, | 5396 | amdgpu_irq_put(adev, &adev->pm.dpm.thermal.irq, |
5397 | AMDGPU_THERMAL_IRQ_HIGH_TO_LOW); | 5397 | AMDGPU_THERMAL_IRQ_HIGH_TO_LOW); |
5398 | 5398 | ||
5399 | ci_dpm_powergate_uvd(adev, false); | 5399 | ci_dpm_powergate_uvd(adev, true); |
5400 | 5400 | ||
5401 | if (!amdgpu_ci_is_smc_running(adev)) | 5401 | if (!amdgpu_ci_is_smc_running(adev)) |
5402 | return; | 5402 | return; |
@@ -6036,7 +6036,7 @@ static int ci_dpm_init(struct amdgpu_device *adev) | |||
6036 | 6036 | ||
6037 | pi->caps_dynamic_ac_timing = true; | 6037 | pi->caps_dynamic_ac_timing = true; |
6038 | 6038 | ||
6039 | pi->uvd_power_gated = false; | 6039 | pi->uvd_power_gated = true; |
6040 | 6040 | ||
6041 | /* make sure dc limits are valid */ | 6041 | /* make sure dc limits are valid */ |
6042 | if ((adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) || | 6042 | if ((adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) || |
@@ -6179,8 +6179,6 @@ static int ci_dpm_late_init(void *handle) | |||
6179 | if (ret) | 6179 | if (ret) |
6180 | return ret; | 6180 | return ret; |
6181 | 6181 | ||
6182 | ci_dpm_powergate_uvd(adev, true); | ||
6183 | |||
6184 | return 0; | 6182 | return 0; |
6185 | } | 6183 | } |
6186 | 6184 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c index e71cd12104b3..e6d7bf9520a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c | |||
@@ -847,6 +847,22 @@ static void cik_sdma_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
847 | amdgpu_ring_write(ring, (0xfff << 16) | 10); /* retry count, poll interval */ | 847 | amdgpu_ring_write(ring, (0xfff << 16) | 10); /* retry count, poll interval */ |
848 | } | 848 | } |
849 | 849 | ||
850 | static unsigned cik_sdma_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
851 | { | ||
852 | return | ||
853 | 7 + 4; /* cik_sdma_ring_emit_ib */ | ||
854 | } | ||
855 | |||
856 | static unsigned cik_sdma_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
857 | { | ||
858 | return | ||
859 | 6 + /* cik_sdma_ring_emit_hdp_flush */ | ||
860 | 3 + /* cik_sdma_ring_emit_hdp_invalidate */ | ||
861 | 6 + /* cik_sdma_ring_emit_pipeline_sync */ | ||
862 | 12 + /* cik_sdma_ring_emit_vm_flush */ | ||
863 | 9 + 9 + 9; /* cik_sdma_ring_emit_fence x3 for user fence, vm fence */ | ||
864 | } | ||
865 | |||
850 | static void cik_enable_sdma_mgcg(struct amdgpu_device *adev, | 866 | static void cik_enable_sdma_mgcg(struct amdgpu_device *adev, |
851 | bool enable) | 867 | bool enable) |
852 | { | 868 | { |
@@ -1220,6 +1236,8 @@ static const struct amdgpu_ring_funcs cik_sdma_ring_funcs = { | |||
1220 | .test_ib = cik_sdma_ring_test_ib, | 1236 | .test_ib = cik_sdma_ring_test_ib, |
1221 | .insert_nop = cik_sdma_ring_insert_nop, | 1237 | .insert_nop = cik_sdma_ring_insert_nop, |
1222 | .pad_ib = cik_sdma_ring_pad_ib, | 1238 | .pad_ib = cik_sdma_ring_pad_ib, |
1239 | .get_emit_ib_size = cik_sdma_ring_get_emit_ib_size, | ||
1240 | .get_dma_frame_size = cik_sdma_ring_get_dma_frame_size, | ||
1223 | }; | 1241 | }; |
1224 | 1242 | ||
1225 | static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev) | 1243 | static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c index 794c5f36ca68..f80a0834e889 100644 --- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c | |||
@@ -44,6 +44,7 @@ | |||
44 | 44 | ||
45 | static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate); | 45 | static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate); |
46 | static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate); | 46 | static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate); |
47 | static void cz_dpm_fini(struct amdgpu_device *adev); | ||
47 | 48 | ||
48 | static struct cz_ps *cz_get_ps(struct amdgpu_ps *rps) | 49 | static struct cz_ps *cz_get_ps(struct amdgpu_ps *rps) |
49 | { | 50 | { |
@@ -350,6 +351,8 @@ static int cz_parse_power_table(struct amdgpu_device *adev) | |||
350 | 351 | ||
351 | ps = kzalloc(sizeof(struct cz_ps), GFP_KERNEL); | 352 | ps = kzalloc(sizeof(struct cz_ps), GFP_KERNEL); |
352 | if (ps == NULL) { | 353 | if (ps == NULL) { |
354 | for (j = 0; j < i; j++) | ||
355 | kfree(adev->pm.dpm.ps[j].ps_priv); | ||
353 | kfree(adev->pm.dpm.ps); | 356 | kfree(adev->pm.dpm.ps); |
354 | return -ENOMEM; | 357 | return -ENOMEM; |
355 | } | 358 | } |
@@ -409,11 +412,11 @@ static int cz_dpm_init(struct amdgpu_device *adev) | |||
409 | 412 | ||
410 | ret = amdgpu_get_platform_caps(adev); | 413 | ret = amdgpu_get_platform_caps(adev); |
411 | if (ret) | 414 | if (ret) |
412 | return ret; | 415 | goto err; |
413 | 416 | ||
414 | ret = amdgpu_parse_extended_power_table(adev); | 417 | ret = amdgpu_parse_extended_power_table(adev); |
415 | if (ret) | 418 | if (ret) |
416 | return ret; | 419 | goto err; |
417 | 420 | ||
418 | pi->sram_end = SMC_RAM_END; | 421 | pi->sram_end = SMC_RAM_END; |
419 | 422 | ||
@@ -467,23 +470,26 @@ static int cz_dpm_init(struct amdgpu_device *adev) | |||
467 | 470 | ||
468 | ret = cz_parse_sys_info_table(adev); | 471 | ret = cz_parse_sys_info_table(adev); |
469 | if (ret) | 472 | if (ret) |
470 | return ret; | 473 | goto err; |
471 | 474 | ||
472 | cz_patch_voltage_values(adev); | 475 | cz_patch_voltage_values(adev); |
473 | cz_construct_boot_state(adev); | 476 | cz_construct_boot_state(adev); |
474 | 477 | ||
475 | ret = cz_parse_power_table(adev); | 478 | ret = cz_parse_power_table(adev); |
476 | if (ret) | 479 | if (ret) |
477 | return ret; | 480 | goto err; |
478 | 481 | ||
479 | ret = cz_process_firmware_header(adev); | 482 | ret = cz_process_firmware_header(adev); |
480 | if (ret) | 483 | if (ret) |
481 | return ret; | 484 | goto err; |
482 | 485 | ||
483 | pi->dpm_enabled = true; | 486 | pi->dpm_enabled = true; |
484 | pi->uvd_dynamic_pg = false; | 487 | pi->uvd_dynamic_pg = false; |
485 | 488 | ||
486 | return 0; | 489 | return 0; |
490 | err: | ||
491 | cz_dpm_fini(adev); | ||
492 | return ret; | ||
487 | } | 493 | } |
488 | 494 | ||
489 | static void cz_dpm_fini(struct amdgpu_device *adev) | 495 | static void cz_dpm_fini(struct amdgpu_device *adev) |
@@ -672,17 +678,12 @@ static void cz_reset_ap_mask(struct amdgpu_device *adev) | |||
672 | struct cz_power_info *pi = cz_get_pi(adev); | 678 | struct cz_power_info *pi = cz_get_pi(adev); |
673 | 679 | ||
674 | pi->active_process_mask = 0; | 680 | pi->active_process_mask = 0; |
675 | |||
676 | } | 681 | } |
677 | 682 | ||
678 | static int cz_dpm_download_pptable_from_smu(struct amdgpu_device *adev, | 683 | static int cz_dpm_download_pptable_from_smu(struct amdgpu_device *adev, |
679 | void **table) | 684 | void **table) |
680 | { | 685 | { |
681 | int ret = 0; | 686 | return cz_smu_download_pptable(adev, table); |
682 | |||
683 | ret = cz_smu_download_pptable(adev, table); | ||
684 | |||
685 | return ret; | ||
686 | } | 687 | } |
687 | 688 | ||
688 | static int cz_dpm_upload_pptable_to_smu(struct amdgpu_device *adev) | 689 | static int cz_dpm_upload_pptable_to_smu(struct amdgpu_device *adev) |
@@ -822,9 +823,9 @@ static void cz_init_sclk_limit(struct amdgpu_device *adev) | |||
822 | pi->sclk_dpm.hard_min_clk = 0; | 823 | pi->sclk_dpm.hard_min_clk = 0; |
823 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxSclkLevel); | 824 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxSclkLevel); |
824 | level = cz_get_argument(adev); | 825 | level = cz_get_argument(adev); |
825 | if (level < table->count) | 826 | if (level < table->count) { |
826 | clock = table->entries[level].clk; | 827 | clock = table->entries[level].clk; |
827 | else { | 828 | } else { |
828 | DRM_ERROR("Invalid SLCK Voltage Dependency table entry.\n"); | 829 | DRM_ERROR("Invalid SLCK Voltage Dependency table entry.\n"); |
829 | clock = table->entries[table->count - 1].clk; | 830 | clock = table->entries[table->count - 1].clk; |
830 | } | 831 | } |
@@ -850,9 +851,9 @@ static void cz_init_uvd_limit(struct amdgpu_device *adev) | |||
850 | pi->uvd_dpm.hard_min_clk = 0; | 851 | pi->uvd_dpm.hard_min_clk = 0; |
851 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxUvdLevel); | 852 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxUvdLevel); |
852 | level = cz_get_argument(adev); | 853 | level = cz_get_argument(adev); |
853 | if (level < table->count) | 854 | if (level < table->count) { |
854 | clock = table->entries[level].vclk; | 855 | clock = table->entries[level].vclk; |
855 | else { | 856 | } else { |
856 | DRM_ERROR("Invalid UVD Voltage Dependency table entry.\n"); | 857 | DRM_ERROR("Invalid UVD Voltage Dependency table entry.\n"); |
857 | clock = table->entries[table->count - 1].vclk; | 858 | clock = table->entries[table->count - 1].vclk; |
858 | } | 859 | } |
@@ -878,9 +879,9 @@ static void cz_init_vce_limit(struct amdgpu_device *adev) | |||
878 | pi->vce_dpm.hard_min_clk = table->entries[0].ecclk; | 879 | pi->vce_dpm.hard_min_clk = table->entries[0].ecclk; |
879 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxEclkLevel); | 880 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxEclkLevel); |
880 | level = cz_get_argument(adev); | 881 | level = cz_get_argument(adev); |
881 | if (level < table->count) | 882 | if (level < table->count) { |
882 | clock = table->entries[level].ecclk; | 883 | clock = table->entries[level].ecclk; |
883 | else { | 884 | } else { |
884 | /* future BIOS would fix this error */ | 885 | /* future BIOS would fix this error */ |
885 | DRM_ERROR("Invalid VCE Voltage Dependency table entry.\n"); | 886 | DRM_ERROR("Invalid VCE Voltage Dependency table entry.\n"); |
886 | clock = table->entries[table->count - 1].ecclk; | 887 | clock = table->entries[table->count - 1].ecclk; |
@@ -907,9 +908,9 @@ static void cz_init_acp_limit(struct amdgpu_device *adev) | |||
907 | pi->acp_dpm.hard_min_clk = 0; | 908 | pi->acp_dpm.hard_min_clk = 0; |
908 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxAclkLevel); | 909 | cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxAclkLevel); |
909 | level = cz_get_argument(adev); | 910 | level = cz_get_argument(adev); |
910 | if (level < table->count) | 911 | if (level < table->count) { |
911 | clock = table->entries[level].clk; | 912 | clock = table->entries[level].clk; |
912 | else { | 913 | } else { |
913 | DRM_ERROR("Invalid ACP Voltage Dependency table entry.\n"); | 914 | DRM_ERROR("Invalid ACP Voltage Dependency table entry.\n"); |
914 | clock = table->entries[table->count - 1].clk; | 915 | clock = table->entries[table->count - 1].clk; |
915 | } | 916 | } |
@@ -934,7 +935,6 @@ static void cz_init_sclk_threshold(struct amdgpu_device *adev) | |||
934 | struct cz_power_info *pi = cz_get_pi(adev); | 935 | struct cz_power_info *pi = cz_get_pi(adev); |
935 | 936 | ||
936 | pi->low_sclk_interrupt_threshold = 0; | 937 | pi->low_sclk_interrupt_threshold = 0; |
937 | |||
938 | } | 938 | } |
939 | 939 | ||
940 | static void cz_dpm_setup_asic(struct amdgpu_device *adev) | 940 | static void cz_dpm_setup_asic(struct amdgpu_device *adev) |
@@ -1207,7 +1207,7 @@ static int cz_enable_didt(struct amdgpu_device *adev, bool enable) | |||
1207 | int ret; | 1207 | int ret; |
1208 | 1208 | ||
1209 | if (pi->caps_sq_ramping || pi->caps_db_ramping || | 1209 | if (pi->caps_sq_ramping || pi->caps_db_ramping || |
1210 | pi->caps_td_ramping || pi->caps_tcp_ramping) { | 1210 | pi->caps_td_ramping || pi->caps_tcp_ramping) { |
1211 | if (adev->gfx.gfx_current_status != AMDGPU_GFX_SAFE_MODE) { | 1211 | if (adev->gfx.gfx_current_status != AMDGPU_GFX_SAFE_MODE) { |
1212 | ret = cz_disable_cgpg(adev); | 1212 | ret = cz_disable_cgpg(adev); |
1213 | if (ret) { | 1213 | if (ret) { |
@@ -1281,7 +1281,7 @@ static void cz_apply_state_adjust_rules(struct amdgpu_device *adev, | |||
1281 | ps->force_high = false; | 1281 | ps->force_high = false; |
1282 | ps->need_dfs_bypass = true; | 1282 | ps->need_dfs_bypass = true; |
1283 | pi->video_start = new_rps->dclk || new_rps->vclk || | 1283 | pi->video_start = new_rps->dclk || new_rps->vclk || |
1284 | new_rps->evclk || new_rps->ecclk; | 1284 | new_rps->evclk || new_rps->ecclk; |
1285 | 1285 | ||
1286 | if ((new_rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | 1286 | if ((new_rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == |
1287 | ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) | 1287 | ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) |
@@ -1339,7 +1339,6 @@ static int cz_dpm_enable(struct amdgpu_device *adev) | |||
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | cz_reset_acp_boot_level(adev); | 1341 | cz_reset_acp_boot_level(adev); |
1342 | |||
1343 | cz_update_current_ps(adev, adev->pm.dpm.boot_ps); | 1342 | cz_update_current_ps(adev, adev->pm.dpm.boot_ps); |
1344 | 1343 | ||
1345 | return 0; | 1344 | return 0; |
@@ -1669,7 +1668,6 @@ static void cz_dpm_post_set_power_state(struct amdgpu_device *adev) | |||
1669 | struct amdgpu_ps *ps = &pi->requested_rps; | 1668 | struct amdgpu_ps *ps = &pi->requested_rps; |
1670 | 1669 | ||
1671 | cz_update_current_ps(adev, ps); | 1670 | cz_update_current_ps(adev, ps); |
1672 | |||
1673 | } | 1671 | } |
1674 | 1672 | ||
1675 | static int cz_dpm_force_highest(struct amdgpu_device *adev) | 1673 | static int cz_dpm_force_highest(struct amdgpu_device *adev) |
@@ -2201,7 +2199,6 @@ static int cz_update_vce_dpm(struct amdgpu_device *adev) | |||
2201 | /* Stable Pstate is enabled and we need to set the VCE DPM to highest level */ | 2199 | /* Stable Pstate is enabled and we need to set the VCE DPM to highest level */ |
2202 | if (pi->caps_stable_power_state) { | 2200 | if (pi->caps_stable_power_state) { |
2203 | pi->vce_dpm.hard_min_clk = table->entries[table->count-1].ecclk; | 2201 | pi->vce_dpm.hard_min_clk = table->entries[table->count-1].ecclk; |
2204 | |||
2205 | } else { /* non-stable p-state cases. without vce.Arbiter.EcclkHardMin */ | 2202 | } else { /* non-stable p-state cases. without vce.Arbiter.EcclkHardMin */ |
2206 | /* leave it as set by user */ | 2203 | /* leave it as set by user */ |
2207 | /*pi->vce_dpm.hard_min_clk = table->entries[0].ecclk;*/ | 2204 | /*pi->vce_dpm.hard_min_clk = table->entries[0].ecclk;*/ |
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_smc.c b/drivers/gpu/drm/amd/amdgpu/cz_smc.c index ac7fee7b7eca..95887e484c51 100644 --- a/drivers/gpu/drm/amd/amdgpu/cz_smc.c +++ b/drivers/gpu/drm/amd/amdgpu/cz_smc.c | |||
@@ -29,6 +29,8 @@ | |||
29 | #include "cz_smumgr.h" | 29 | #include "cz_smumgr.h" |
30 | #include "smu_ucode_xfer_cz.h" | 30 | #include "smu_ucode_xfer_cz.h" |
31 | #include "amdgpu_ucode.h" | 31 | #include "amdgpu_ucode.h" |
32 | #include "cz_dpm.h" | ||
33 | #include "vi_dpm.h" | ||
32 | 34 | ||
33 | #include "smu/smu_8_0_d.h" | 35 | #include "smu/smu_8_0_d.h" |
34 | #include "smu/smu_8_0_sh_mask.h" | 36 | #include "smu/smu_8_0_sh_mask.h" |
@@ -48,7 +50,7 @@ static struct cz_smu_private_data *cz_smu_get_priv(struct amdgpu_device *adev) | |||
48 | return priv; | 50 | return priv; |
49 | } | 51 | } |
50 | 52 | ||
51 | int cz_send_msg_to_smc_async(struct amdgpu_device *adev, u16 msg) | 53 | static int cz_send_msg_to_smc_async(struct amdgpu_device *adev, u16 msg) |
52 | { | 54 | { |
53 | int i; | 55 | int i; |
54 | u32 content = 0, tmp; | 56 | u32 content = 0, tmp; |
@@ -140,7 +142,7 @@ int cz_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | |||
140 | return 0; | 142 | return 0; |
141 | } | 143 | } |
142 | 144 | ||
143 | int cz_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | 145 | static int cz_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, |
144 | u32 value, u32 limit) | 146 | u32 value, u32 limit) |
145 | { | 147 | { |
146 | int ret; | 148 | int ret; |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c new file mode 100644 index 000000000000..d3512f381e53 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | |||
@@ -0,0 +1,3160 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #include "drmP.h" | ||
24 | #include "amdgpu.h" | ||
25 | #include "amdgpu_pm.h" | ||
26 | #include "amdgpu_i2c.h" | ||
27 | #include "atom.h" | ||
28 | #include "amdgpu_atombios.h" | ||
29 | #include "atombios_crtc.h" | ||
30 | #include "atombios_encoders.h" | ||
31 | #include "amdgpu_pll.h" | ||
32 | #include "amdgpu_connectors.h" | ||
33 | #include "si/si_reg.h" | ||
34 | #include "si/sid.h" | ||
35 | |||
36 | static void dce_v6_0_set_display_funcs(struct amdgpu_device *adev); | ||
37 | static void dce_v6_0_set_irq_funcs(struct amdgpu_device *adev); | ||
38 | |||
39 | static const u32 crtc_offsets[6] = | ||
40 | { | ||
41 | SI_CRTC0_REGISTER_OFFSET, | ||
42 | SI_CRTC1_REGISTER_OFFSET, | ||
43 | SI_CRTC2_REGISTER_OFFSET, | ||
44 | SI_CRTC3_REGISTER_OFFSET, | ||
45 | SI_CRTC4_REGISTER_OFFSET, | ||
46 | SI_CRTC5_REGISTER_OFFSET | ||
47 | }; | ||
48 | |||
49 | static const uint32_t dig_offsets[] = { | ||
50 | SI_CRTC0_REGISTER_OFFSET, | ||
51 | SI_CRTC1_REGISTER_OFFSET, | ||
52 | SI_CRTC2_REGISTER_OFFSET, | ||
53 | SI_CRTC3_REGISTER_OFFSET, | ||
54 | SI_CRTC4_REGISTER_OFFSET, | ||
55 | SI_CRTC5_REGISTER_OFFSET, | ||
56 | (0x13830 - 0x7030) >> 2, | ||
57 | }; | ||
58 | |||
59 | static const struct { | ||
60 | uint32_t reg; | ||
61 | uint32_t vblank; | ||
62 | uint32_t vline; | ||
63 | uint32_t hpd; | ||
64 | |||
65 | } interrupt_status_offsets[6] = { { | ||
66 | .reg = DISP_INTERRUPT_STATUS, | ||
67 | .vblank = DISP_INTERRUPT_STATUS__LB_D1_VBLANK_INTERRUPT_MASK, | ||
68 | .vline = DISP_INTERRUPT_STATUS__LB_D1_VLINE_INTERRUPT_MASK, | ||
69 | .hpd = DISP_INTERRUPT_STATUS__DC_HPD1_INTERRUPT_MASK | ||
70 | }, { | ||
71 | .reg = DISP_INTERRUPT_STATUS_CONTINUE, | ||
72 | .vblank = DISP_INTERRUPT_STATUS_CONTINUE__LB_D2_VBLANK_INTERRUPT_MASK, | ||
73 | .vline = DISP_INTERRUPT_STATUS_CONTINUE__LB_D2_VLINE_INTERRUPT_MASK, | ||
74 | .hpd = DISP_INTERRUPT_STATUS_CONTINUE__DC_HPD2_INTERRUPT_MASK | ||
75 | }, { | ||
76 | .reg = DISP_INTERRUPT_STATUS_CONTINUE2, | ||
77 | .vblank = DISP_INTERRUPT_STATUS_CONTINUE2__LB_D3_VBLANK_INTERRUPT_MASK, | ||
78 | .vline = DISP_INTERRUPT_STATUS_CONTINUE2__LB_D3_VLINE_INTERRUPT_MASK, | ||
79 | .hpd = DISP_INTERRUPT_STATUS_CONTINUE2__DC_HPD3_INTERRUPT_MASK | ||
80 | }, { | ||
81 | .reg = DISP_INTERRUPT_STATUS_CONTINUE3, | ||
82 | .vblank = DISP_INTERRUPT_STATUS_CONTINUE3__LB_D4_VBLANK_INTERRUPT_MASK, | ||
83 | .vline = DISP_INTERRUPT_STATUS_CONTINUE3__LB_D4_VLINE_INTERRUPT_MASK, | ||
84 | .hpd = DISP_INTERRUPT_STATUS_CONTINUE3__DC_HPD4_INTERRUPT_MASK | ||
85 | }, { | ||
86 | .reg = DISP_INTERRUPT_STATUS_CONTINUE4, | ||
87 | .vblank = DISP_INTERRUPT_STATUS_CONTINUE4__LB_D5_VBLANK_INTERRUPT_MASK, | ||
88 | .vline = DISP_INTERRUPT_STATUS_CONTINUE4__LB_D5_VLINE_INTERRUPT_MASK, | ||
89 | .hpd = DISP_INTERRUPT_STATUS_CONTINUE4__DC_HPD5_INTERRUPT_MASK | ||
90 | }, { | ||
91 | .reg = DISP_INTERRUPT_STATUS_CONTINUE5, | ||
92 | .vblank = DISP_INTERRUPT_STATUS_CONTINUE5__LB_D6_VBLANK_INTERRUPT_MASK, | ||
93 | .vline = DISP_INTERRUPT_STATUS_CONTINUE5__LB_D6_VLINE_INTERRUPT_MASK, | ||
94 | .hpd = DISP_INTERRUPT_STATUS_CONTINUE5__DC_HPD6_INTERRUPT_MASK | ||
95 | } }; | ||
96 | |||
97 | static const uint32_t hpd_int_control_offsets[6] = { | ||
98 | DC_HPD1_INT_CONTROL, | ||
99 | DC_HPD2_INT_CONTROL, | ||
100 | DC_HPD3_INT_CONTROL, | ||
101 | DC_HPD4_INT_CONTROL, | ||
102 | DC_HPD5_INT_CONTROL, | ||
103 | DC_HPD6_INT_CONTROL, | ||
104 | }; | ||
105 | |||
106 | static u32 dce_v6_0_audio_endpt_rreg(struct amdgpu_device *adev, | ||
107 | u32 block_offset, u32 reg) | ||
108 | { | ||
109 | DRM_INFO("xxxx: dce_v6_0_audio_endpt_rreg ----no impl!!!!\n"); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static void dce_v6_0_audio_endpt_wreg(struct amdgpu_device *adev, | ||
114 | u32 block_offset, u32 reg, u32 v) | ||
115 | { | ||
116 | DRM_INFO("xxxx: dce_v6_0_audio_endpt_wreg ----no impl!!!!\n"); | ||
117 | } | ||
118 | |||
119 | static bool dce_v6_0_is_in_vblank(struct amdgpu_device *adev, int crtc) | ||
120 | { | ||
121 | if (RREG32(EVERGREEN_CRTC_STATUS + crtc_offsets[crtc]) & EVERGREEN_CRTC_V_BLANK) | ||
122 | return true; | ||
123 | else | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | static bool dce_v6_0_is_counter_moving(struct amdgpu_device *adev, int crtc) | ||
128 | { | ||
129 | u32 pos1, pos2; | ||
130 | |||
131 | pos1 = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]); | ||
132 | pos2 = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]); | ||
133 | |||
134 | if (pos1 != pos2) | ||
135 | return true; | ||
136 | else | ||
137 | return false; | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * dce_v6_0_wait_for_vblank - vblank wait asic callback. | ||
142 | * | ||
143 | * @crtc: crtc to wait for vblank on | ||
144 | * | ||
145 | * Wait for vblank on the requested crtc (evergreen+). | ||
146 | */ | ||
147 | static void dce_v6_0_vblank_wait(struct amdgpu_device *adev, int crtc) | ||
148 | { | ||
149 | unsigned i = 0; | ||
150 | |||
151 | if (crtc >= adev->mode_info.num_crtc) | ||
152 | return; | ||
153 | |||
154 | if (!(RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[crtc]) & EVERGREEN_CRTC_MASTER_EN)) | ||
155 | return; | ||
156 | |||
157 | /* depending on when we hit vblank, we may be close to active; if so, | ||
158 | * wait for another frame. | ||
159 | */ | ||
160 | while (dce_v6_0_is_in_vblank(adev, crtc)) { | ||
161 | if (i++ % 100 == 0) { | ||
162 | if (!dce_v6_0_is_counter_moving(adev, crtc)) | ||
163 | break; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | while (!dce_v6_0_is_in_vblank(adev, crtc)) { | ||
168 | if (i++ % 100 == 0) { | ||
169 | if (!dce_v6_0_is_counter_moving(adev, crtc)) | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | |||
175 | static u32 dce_v6_0_vblank_get_counter(struct amdgpu_device *adev, int crtc) | ||
176 | { | ||
177 | if (crtc >= adev->mode_info.num_crtc) | ||
178 | return 0; | ||
179 | else | ||
180 | return RREG32(CRTC_STATUS_FRAME_COUNT + crtc_offsets[crtc]); | ||
181 | } | ||
182 | |||
183 | static void dce_v6_0_pageflip_interrupt_init(struct amdgpu_device *adev) | ||
184 | { | ||
185 | unsigned i; | ||
186 | |||
187 | /* Enable pflip interrupts */ | ||
188 | for (i = 0; i <= adev->mode_info.num_crtc; i++) | ||
189 | amdgpu_irq_get(adev, &adev->pageflip_irq, i); | ||
190 | } | ||
191 | |||
192 | static void dce_v6_0_pageflip_interrupt_fini(struct amdgpu_device *adev) | ||
193 | { | ||
194 | unsigned i; | ||
195 | |||
196 | /* Disable pflip interrupts */ | ||
197 | for (i = 0; i <= adev->mode_info.num_crtc; i++) | ||
198 | amdgpu_irq_put(adev, &adev->pageflip_irq, i); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * dce_v6_0_page_flip - pageflip callback. | ||
203 | * | ||
204 | * @adev: amdgpu_device pointer | ||
205 | * @crtc_id: crtc to cleanup pageflip on | ||
206 | * @crtc_base: new address of the crtc (GPU MC address) | ||
207 | * | ||
208 | * Does the actual pageflip (evergreen+). | ||
209 | * During vblank we take the crtc lock and wait for the update_pending | ||
210 | * bit to go high, when it does, we release the lock, and allow the | ||
211 | * double buffered update to take place. | ||
212 | * Returns the current update pending status. | ||
213 | */ | ||
214 | static void dce_v6_0_page_flip(struct amdgpu_device *adev, | ||
215 | int crtc_id, u64 crtc_base, bool async) | ||
216 | { | ||
217 | struct amdgpu_crtc *amdgpu_crtc = adev->mode_info.crtcs[crtc_id]; | ||
218 | |||
219 | /* flip at hsync for async, default is vsync */ | ||
220 | WREG32(EVERGREEN_GRPH_FLIP_CONTROL + amdgpu_crtc->crtc_offset, async ? | ||
221 | EVERGREEN_GRPH_SURFACE_UPDATE_H_RETRACE_EN : 0); | ||
222 | /* update the scanout addresses */ | ||
223 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
224 | upper_32_bits(crtc_base)); | ||
225 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
226 | (u32)crtc_base); | ||
227 | |||
228 | /* post the write */ | ||
229 | RREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset); | ||
230 | } | ||
231 | |||
232 | static int dce_v6_0_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc, | ||
233 | u32 *vbl, u32 *position) | ||
234 | { | ||
235 | if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc)) | ||
236 | return -EINVAL; | ||
237 | *vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END + crtc_offsets[crtc]); | ||
238 | *position = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]); | ||
239 | |||
240 | return 0; | ||
241 | |||
242 | } | ||
243 | |||
244 | /** | ||
245 | * dce_v6_0_hpd_sense - hpd sense callback. | ||
246 | * | ||
247 | * @adev: amdgpu_device pointer | ||
248 | * @hpd: hpd (hotplug detect) pin | ||
249 | * | ||
250 | * Checks if a digital monitor is connected (evergreen+). | ||
251 | * Returns true if connected, false if not connected. | ||
252 | */ | ||
253 | static bool dce_v6_0_hpd_sense(struct amdgpu_device *adev, | ||
254 | enum amdgpu_hpd_id hpd) | ||
255 | { | ||
256 | bool connected = false; | ||
257 | |||
258 | switch (hpd) { | ||
259 | case AMDGPU_HPD_1: | ||
260 | if (RREG32(DC_HPD1_INT_STATUS) & DC_HPDx_SENSE) | ||
261 | connected = true; | ||
262 | break; | ||
263 | case AMDGPU_HPD_2: | ||
264 | if (RREG32(DC_HPD2_INT_STATUS) & DC_HPDx_SENSE) | ||
265 | connected = true; | ||
266 | break; | ||
267 | case AMDGPU_HPD_3: | ||
268 | if (RREG32(DC_HPD3_INT_STATUS) & DC_HPDx_SENSE) | ||
269 | connected = true; | ||
270 | break; | ||
271 | case AMDGPU_HPD_4: | ||
272 | if (RREG32(DC_HPD4_INT_STATUS) & DC_HPDx_SENSE) | ||
273 | connected = true; | ||
274 | break; | ||
275 | case AMDGPU_HPD_5: | ||
276 | if (RREG32(DC_HPD5_INT_STATUS) & DC_HPDx_SENSE) | ||
277 | connected = true; | ||
278 | break; | ||
279 | case AMDGPU_HPD_6: | ||
280 | if (RREG32(DC_HPD6_INT_STATUS) & DC_HPDx_SENSE) | ||
281 | connected = true; | ||
282 | break; | ||
283 | default: | ||
284 | break; | ||
285 | } | ||
286 | |||
287 | return connected; | ||
288 | } | ||
289 | |||
290 | /** | ||
291 | * dce_v6_0_hpd_set_polarity - hpd set polarity callback. | ||
292 | * | ||
293 | * @adev: amdgpu_device pointer | ||
294 | * @hpd: hpd (hotplug detect) pin | ||
295 | * | ||
296 | * Set the polarity of the hpd pin (evergreen+). | ||
297 | */ | ||
298 | static void dce_v6_0_hpd_set_polarity(struct amdgpu_device *adev, | ||
299 | enum amdgpu_hpd_id hpd) | ||
300 | { | ||
301 | u32 tmp; | ||
302 | bool connected = dce_v6_0_hpd_sense(adev, hpd); | ||
303 | |||
304 | switch (hpd) { | ||
305 | case AMDGPU_HPD_1: | ||
306 | tmp = RREG32(DC_HPD1_INT_CONTROL); | ||
307 | if (connected) | ||
308 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
309 | else | ||
310 | tmp |= DC_HPDx_INT_POLARITY; | ||
311 | WREG32(DC_HPD1_INT_CONTROL, tmp); | ||
312 | break; | ||
313 | case AMDGPU_HPD_2: | ||
314 | tmp = RREG32(DC_HPD2_INT_CONTROL); | ||
315 | if (connected) | ||
316 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
317 | else | ||
318 | tmp |= DC_HPDx_INT_POLARITY; | ||
319 | WREG32(DC_HPD2_INT_CONTROL, tmp); | ||
320 | break; | ||
321 | case AMDGPU_HPD_3: | ||
322 | tmp = RREG32(DC_HPD3_INT_CONTROL); | ||
323 | if (connected) | ||
324 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
325 | else | ||
326 | tmp |= DC_HPDx_INT_POLARITY; | ||
327 | WREG32(DC_HPD3_INT_CONTROL, tmp); | ||
328 | break; | ||
329 | case AMDGPU_HPD_4: | ||
330 | tmp = RREG32(DC_HPD4_INT_CONTROL); | ||
331 | if (connected) | ||
332 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
333 | else | ||
334 | tmp |= DC_HPDx_INT_POLARITY; | ||
335 | WREG32(DC_HPD4_INT_CONTROL, tmp); | ||
336 | break; | ||
337 | case AMDGPU_HPD_5: | ||
338 | tmp = RREG32(DC_HPD5_INT_CONTROL); | ||
339 | if (connected) | ||
340 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
341 | else | ||
342 | tmp |= DC_HPDx_INT_POLARITY; | ||
343 | WREG32(DC_HPD5_INT_CONTROL, tmp); | ||
344 | break; | ||
345 | case AMDGPU_HPD_6: | ||
346 | tmp = RREG32(DC_HPD6_INT_CONTROL); | ||
347 | if (connected) | ||
348 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
349 | else | ||
350 | tmp |= DC_HPDx_INT_POLARITY; | ||
351 | WREG32(DC_HPD6_INT_CONTROL, tmp); | ||
352 | break; | ||
353 | default: | ||
354 | break; | ||
355 | } | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * dce_v6_0_hpd_init - hpd setup callback. | ||
360 | * | ||
361 | * @adev: amdgpu_device pointer | ||
362 | * | ||
363 | * Setup the hpd pins used by the card (evergreen+). | ||
364 | * Enable the pin, set the polarity, and enable the hpd interrupts. | ||
365 | */ | ||
366 | static void dce_v6_0_hpd_init(struct amdgpu_device *adev) | ||
367 | { | ||
368 | struct drm_device *dev = adev->ddev; | ||
369 | struct drm_connector *connector; | ||
370 | u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | | ||
371 | DC_HPDx_RX_INT_TIMER(0xfa) | DC_HPDx_EN; | ||
372 | |||
373 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | ||
374 | struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); | ||
375 | |||
376 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || | ||
377 | connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { | ||
378 | /* don't try to enable hpd on eDP or LVDS avoid breaking the | ||
379 | * aux dp channel on imac and help (but not completely fix) | ||
380 | * https://bugzilla.redhat.com/show_bug.cgi?id=726143 | ||
381 | * also avoid interrupt storms during dpms. | ||
382 | */ | ||
383 | continue; | ||
384 | } | ||
385 | switch (amdgpu_connector->hpd.hpd) { | ||
386 | case AMDGPU_HPD_1: | ||
387 | WREG32(DC_HPD1_CONTROL, tmp); | ||
388 | break; | ||
389 | case AMDGPU_HPD_2: | ||
390 | WREG32(DC_HPD2_CONTROL, tmp); | ||
391 | break; | ||
392 | case AMDGPU_HPD_3: | ||
393 | WREG32(DC_HPD3_CONTROL, tmp); | ||
394 | break; | ||
395 | case AMDGPU_HPD_4: | ||
396 | WREG32(DC_HPD4_CONTROL, tmp); | ||
397 | break; | ||
398 | case AMDGPU_HPD_5: | ||
399 | WREG32(DC_HPD5_CONTROL, tmp); | ||
400 | break; | ||
401 | case AMDGPU_HPD_6: | ||
402 | WREG32(DC_HPD6_CONTROL, tmp); | ||
403 | break; | ||
404 | default: | ||
405 | break; | ||
406 | } | ||
407 | dce_v6_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd); | ||
408 | amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); | ||
409 | } | ||
410 | |||
411 | } | ||
412 | |||
413 | /** | ||
414 | * dce_v6_0_hpd_fini - hpd tear down callback. | ||
415 | * | ||
416 | * @adev: amdgpu_device pointer | ||
417 | * | ||
418 | * Tear down the hpd pins used by the card (evergreen+). | ||
419 | * Disable the hpd interrupts. | ||
420 | */ | ||
421 | static void dce_v6_0_hpd_fini(struct amdgpu_device *adev) | ||
422 | { | ||
423 | struct drm_device *dev = adev->ddev; | ||
424 | struct drm_connector *connector; | ||
425 | |||
426 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | ||
427 | struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); | ||
428 | |||
429 | switch (amdgpu_connector->hpd.hpd) { | ||
430 | case AMDGPU_HPD_1: | ||
431 | WREG32(DC_HPD1_CONTROL, 0); | ||
432 | break; | ||
433 | case AMDGPU_HPD_2: | ||
434 | WREG32(DC_HPD2_CONTROL, 0); | ||
435 | break; | ||
436 | case AMDGPU_HPD_3: | ||
437 | WREG32(DC_HPD3_CONTROL, 0); | ||
438 | break; | ||
439 | case AMDGPU_HPD_4: | ||
440 | WREG32(DC_HPD4_CONTROL, 0); | ||
441 | break; | ||
442 | case AMDGPU_HPD_5: | ||
443 | WREG32(DC_HPD5_CONTROL, 0); | ||
444 | break; | ||
445 | case AMDGPU_HPD_6: | ||
446 | WREG32(DC_HPD6_CONTROL, 0); | ||
447 | break; | ||
448 | default: | ||
449 | break; | ||
450 | } | ||
451 | amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); | ||
452 | } | ||
453 | } | ||
454 | |||
455 | static u32 dce_v6_0_hpd_get_gpio_reg(struct amdgpu_device *adev) | ||
456 | { | ||
457 | return SI_DC_GPIO_HPD_A; | ||
458 | } | ||
459 | |||
460 | static bool dce_v6_0_is_display_hung(struct amdgpu_device *adev) | ||
461 | { | ||
462 | DRM_INFO("xxxx: dce_v6_0_is_display_hung ----no imp!!!!!\n"); | ||
463 | |||
464 | return true; | ||
465 | } | ||
466 | |||
467 | static u32 evergreen_get_vblank_counter(struct amdgpu_device* adev, int crtc) | ||
468 | { | ||
469 | if (crtc >= adev->mode_info.num_crtc) | ||
470 | return 0; | ||
471 | else | ||
472 | return RREG32(CRTC_STATUS_FRAME_COUNT + crtc_offsets[crtc]); | ||
473 | } | ||
474 | |||
475 | static void dce_v6_0_stop_mc_access(struct amdgpu_device *adev, | ||
476 | struct amdgpu_mode_mc_save *save) | ||
477 | { | ||
478 | u32 crtc_enabled, tmp, frame_count; | ||
479 | int i, j; | ||
480 | |||
481 | save->vga_render_control = RREG32(VGA_RENDER_CONTROL); | ||
482 | save->vga_hdp_control = RREG32(VGA_HDP_CONTROL); | ||
483 | |||
484 | /* disable VGA render */ | ||
485 | WREG32(VGA_RENDER_CONTROL, 0); | ||
486 | |||
487 | /* blank the display controllers */ | ||
488 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
489 | crtc_enabled = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]) & EVERGREEN_CRTC_MASTER_EN; | ||
490 | if (crtc_enabled) { | ||
491 | save->crtc_enabled[i] = true; | ||
492 | tmp = RREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
493 | |||
494 | if (!(tmp & EVERGREEN_CRTC_BLANK_DATA_EN)) { | ||
495 | dce_v6_0_vblank_wait(adev, i); | ||
496 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
497 | tmp |= EVERGREEN_CRTC_BLANK_DATA_EN; | ||
498 | WREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
499 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
500 | } | ||
501 | /* wait for the next frame */ | ||
502 | frame_count = evergreen_get_vblank_counter(adev, i); | ||
503 | for (j = 0; j < adev->usec_timeout; j++) { | ||
504 | if (evergreen_get_vblank_counter(adev, i) != frame_count) | ||
505 | break; | ||
506 | udelay(1); | ||
507 | } | ||
508 | |||
509 | /* XXX this is a hack to avoid strange behavior with EFI on certain systems */ | ||
510 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
511 | tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]); | ||
512 | tmp &= ~EVERGREEN_CRTC_MASTER_EN; | ||
513 | WREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i], tmp); | ||
514 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
515 | save->crtc_enabled[i] = false; | ||
516 | /* ***** */ | ||
517 | } else { | ||
518 | save->crtc_enabled[i] = false; | ||
519 | } | ||
520 | } | ||
521 | } | ||
522 | |||
523 | static void dce_v6_0_resume_mc_access(struct amdgpu_device *adev, | ||
524 | struct amdgpu_mode_mc_save *save) | ||
525 | { | ||
526 | u32 tmp; | ||
527 | int i, j; | ||
528 | |||
529 | /* update crtc base addresses */ | ||
530 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
531 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
532 | upper_32_bits(adev->mc.vram_start)); | ||
533 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
534 | upper_32_bits(adev->mc.vram_start)); | ||
535 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
536 | (u32)adev->mc.vram_start); | ||
537 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
538 | (u32)adev->mc.vram_start); | ||
539 | } | ||
540 | |||
541 | WREG32(EVERGREEN_VGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(adev->mc.vram_start)); | ||
542 | WREG32(EVERGREEN_VGA_MEMORY_BASE_ADDRESS, (u32)adev->mc.vram_start); | ||
543 | |||
544 | /* unlock regs and wait for update */ | ||
545 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
546 | if (save->crtc_enabled[i]) { | ||
547 | tmp = RREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i]); | ||
548 | if ((tmp & 0x7) != 3) { | ||
549 | tmp &= ~0x7; | ||
550 | tmp |= 0x3; | ||
551 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i], tmp); | ||
552 | } | ||
553 | tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]); | ||
554 | if (tmp & EVERGREEN_GRPH_UPDATE_LOCK) { | ||
555 | tmp &= ~EVERGREEN_GRPH_UPDATE_LOCK; | ||
556 | WREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i], tmp); | ||
557 | } | ||
558 | tmp = RREG32(EVERGREEN_MASTER_UPDATE_LOCK + crtc_offsets[i]); | ||
559 | if (tmp & 1) { | ||
560 | tmp &= ~1; | ||
561 | WREG32(EVERGREEN_MASTER_UPDATE_LOCK + crtc_offsets[i], tmp); | ||
562 | } | ||
563 | for (j = 0; j < adev->usec_timeout; j++) { | ||
564 | tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]); | ||
565 | if ((tmp & EVERGREEN_GRPH_SURFACE_UPDATE_PENDING) == 0) | ||
566 | break; | ||
567 | udelay(1); | ||
568 | } | ||
569 | } | ||
570 | } | ||
571 | |||
572 | /* Unlock vga access */ | ||
573 | WREG32(VGA_HDP_CONTROL, save->vga_hdp_control); | ||
574 | mdelay(1); | ||
575 | WREG32(VGA_RENDER_CONTROL, save->vga_render_control); | ||
576 | |||
577 | } | ||
578 | |||
579 | static void dce_v6_0_set_vga_render_state(struct amdgpu_device *adev, | ||
580 | bool render) | ||
581 | { | ||
582 | if (!render) | ||
583 | WREG32(R_000300_VGA_RENDER_CONTROL, | ||
584 | RREG32(R_000300_VGA_RENDER_CONTROL) & C_000300_VGA_VSTATUS_CNTL); | ||
585 | |||
586 | } | ||
587 | |||
588 | static void dce_v6_0_program_fmt(struct drm_encoder *encoder) | ||
589 | { | ||
590 | |||
591 | struct drm_device *dev = encoder->dev; | ||
592 | struct amdgpu_device *adev = dev->dev_private; | ||
593 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
594 | struct drm_connector *connector = amdgpu_get_connector_for_encoder(encoder); | ||
595 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(encoder->crtc); | ||
596 | int bpc = 0; | ||
597 | u32 tmp = 0; | ||
598 | enum amdgpu_connector_dither dither = AMDGPU_FMT_DITHER_DISABLE; | ||
599 | |||
600 | if (connector) { | ||
601 | struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); | ||
602 | bpc = amdgpu_connector_get_monitor_bpc(connector); | ||
603 | dither = amdgpu_connector->dither; | ||
604 | } | ||
605 | |||
606 | /* LVDS FMT is set up by atom */ | ||
607 | if (amdgpu_encoder->devices & ATOM_DEVICE_LCD_SUPPORT) | ||
608 | return; | ||
609 | |||
610 | if (bpc == 0) | ||
611 | return; | ||
612 | |||
613 | |||
614 | switch (bpc) { | ||
615 | case 6: | ||
616 | if (dither == AMDGPU_FMT_DITHER_ENABLE) | ||
617 | /* XXX sort out optimal dither settings */ | ||
618 | tmp |= (FMT_FRAME_RANDOM_ENABLE | FMT_HIGHPASS_RANDOM_ENABLE | | ||
619 | FMT_SPATIAL_DITHER_EN); | ||
620 | else | ||
621 | tmp |= FMT_TRUNCATE_EN; | ||
622 | break; | ||
623 | case 8: | ||
624 | if (dither == AMDGPU_FMT_DITHER_ENABLE) | ||
625 | /* XXX sort out optimal dither settings */ | ||
626 | tmp |= (FMT_FRAME_RANDOM_ENABLE | FMT_HIGHPASS_RANDOM_ENABLE | | ||
627 | FMT_RGB_RANDOM_ENABLE | | ||
628 | FMT_SPATIAL_DITHER_EN | FMT_SPATIAL_DITHER_DEPTH); | ||
629 | else | ||
630 | tmp |= (FMT_TRUNCATE_EN | FMT_TRUNCATE_DEPTH); | ||
631 | break; | ||
632 | case 10: | ||
633 | default: | ||
634 | /* not needed */ | ||
635 | break; | ||
636 | } | ||
637 | |||
638 | WREG32(FMT_BIT_DEPTH_CONTROL + amdgpu_crtc->crtc_offset, tmp); | ||
639 | } | ||
640 | |||
641 | /** | ||
642 | * cik_get_number_of_dram_channels - get the number of dram channels | ||
643 | * | ||
644 | * @adev: amdgpu_device pointer | ||
645 | * | ||
646 | * Look up the number of video ram channels (CIK). | ||
647 | * Used for display watermark bandwidth calculations | ||
648 | * Returns the number of dram channels | ||
649 | */ | ||
650 | static u32 si_get_number_of_dram_channels(struct amdgpu_device *adev) | ||
651 | { | ||
652 | u32 tmp = RREG32(MC_SHARED_CHMAP); | ||
653 | |||
654 | switch ((tmp & MC_SHARED_CHMAP__NOOFCHAN_MASK) >> MC_SHARED_CHMAP__NOOFCHAN__SHIFT) { | ||
655 | case 0: | ||
656 | default: | ||
657 | return 1; | ||
658 | case 1: | ||
659 | return 2; | ||
660 | case 2: | ||
661 | return 4; | ||
662 | case 3: | ||
663 | return 8; | ||
664 | case 4: | ||
665 | return 3; | ||
666 | case 5: | ||
667 | return 6; | ||
668 | case 6: | ||
669 | return 10; | ||
670 | case 7: | ||
671 | return 12; | ||
672 | case 8: | ||
673 | return 16; | ||
674 | } | ||
675 | } | ||
676 | |||
677 | struct dce6_wm_params { | ||
678 | u32 dram_channels; /* number of dram channels */ | ||
679 | u32 yclk; /* bandwidth per dram data pin in kHz */ | ||
680 | u32 sclk; /* engine clock in kHz */ | ||
681 | u32 disp_clk; /* display clock in kHz */ | ||
682 | u32 src_width; /* viewport width */ | ||
683 | u32 active_time; /* active display time in ns */ | ||
684 | u32 blank_time; /* blank time in ns */ | ||
685 | bool interlaced; /* mode is interlaced */ | ||
686 | fixed20_12 vsc; /* vertical scale ratio */ | ||
687 | u32 num_heads; /* number of active crtcs */ | ||
688 | u32 bytes_per_pixel; /* bytes per pixel display + overlay */ | ||
689 | u32 lb_size; /* line buffer allocated to pipe */ | ||
690 | u32 vtaps; /* vertical scaler taps */ | ||
691 | }; | ||
692 | |||
693 | /** | ||
694 | * dce_v6_0_dram_bandwidth - get the dram bandwidth | ||
695 | * | ||
696 | * @wm: watermark calculation data | ||
697 | * | ||
698 | * Calculate the raw dram bandwidth (CIK). | ||
699 | * Used for display watermark bandwidth calculations | ||
700 | * Returns the dram bandwidth in MBytes/s | ||
701 | */ | ||
702 | static u32 dce_v6_0_dram_bandwidth(struct dce6_wm_params *wm) | ||
703 | { | ||
704 | /* Calculate raw DRAM Bandwidth */ | ||
705 | fixed20_12 dram_efficiency; /* 0.7 */ | ||
706 | fixed20_12 yclk, dram_channels, bandwidth; | ||
707 | fixed20_12 a; | ||
708 | |||
709 | a.full = dfixed_const(1000); | ||
710 | yclk.full = dfixed_const(wm->yclk); | ||
711 | yclk.full = dfixed_div(yclk, a); | ||
712 | dram_channels.full = dfixed_const(wm->dram_channels * 4); | ||
713 | a.full = dfixed_const(10); | ||
714 | dram_efficiency.full = dfixed_const(7); | ||
715 | dram_efficiency.full = dfixed_div(dram_efficiency, a); | ||
716 | bandwidth.full = dfixed_mul(dram_channels, yclk); | ||
717 | bandwidth.full = dfixed_mul(bandwidth, dram_efficiency); | ||
718 | |||
719 | return dfixed_trunc(bandwidth); | ||
720 | } | ||
721 | |||
722 | /** | ||
723 | * dce_v6_0_dram_bandwidth_for_display - get the dram bandwidth for display | ||
724 | * | ||
725 | * @wm: watermark calculation data | ||
726 | * | ||
727 | * Calculate the dram bandwidth used for display (CIK). | ||
728 | * Used for display watermark bandwidth calculations | ||
729 | * Returns the dram bandwidth for display in MBytes/s | ||
730 | */ | ||
731 | static u32 dce_v6_0_dram_bandwidth_for_display(struct dce6_wm_params *wm) | ||
732 | { | ||
733 | /* Calculate DRAM Bandwidth and the part allocated to display. */ | ||
734 | fixed20_12 disp_dram_allocation; /* 0.3 to 0.7 */ | ||
735 | fixed20_12 yclk, dram_channels, bandwidth; | ||
736 | fixed20_12 a; | ||
737 | |||
738 | a.full = dfixed_const(1000); | ||
739 | yclk.full = dfixed_const(wm->yclk); | ||
740 | yclk.full = dfixed_div(yclk, a); | ||
741 | dram_channels.full = dfixed_const(wm->dram_channels * 4); | ||
742 | a.full = dfixed_const(10); | ||
743 | disp_dram_allocation.full = dfixed_const(3); /* XXX worse case value 0.3 */ | ||
744 | disp_dram_allocation.full = dfixed_div(disp_dram_allocation, a); | ||
745 | bandwidth.full = dfixed_mul(dram_channels, yclk); | ||
746 | bandwidth.full = dfixed_mul(bandwidth, disp_dram_allocation); | ||
747 | |||
748 | return dfixed_trunc(bandwidth); | ||
749 | } | ||
750 | |||
751 | /** | ||
752 | * dce_v6_0_data_return_bandwidth - get the data return bandwidth | ||
753 | * | ||
754 | * @wm: watermark calculation data | ||
755 | * | ||
756 | * Calculate the data return bandwidth used for display (CIK). | ||
757 | * Used for display watermark bandwidth calculations | ||
758 | * Returns the data return bandwidth in MBytes/s | ||
759 | */ | ||
760 | static u32 dce_v6_0_data_return_bandwidth(struct dce6_wm_params *wm) | ||
761 | { | ||
762 | /* Calculate the display Data return Bandwidth */ | ||
763 | fixed20_12 return_efficiency; /* 0.8 */ | ||
764 | fixed20_12 sclk, bandwidth; | ||
765 | fixed20_12 a; | ||
766 | |||
767 | a.full = dfixed_const(1000); | ||
768 | sclk.full = dfixed_const(wm->sclk); | ||
769 | sclk.full = dfixed_div(sclk, a); | ||
770 | a.full = dfixed_const(10); | ||
771 | return_efficiency.full = dfixed_const(8); | ||
772 | return_efficiency.full = dfixed_div(return_efficiency, a); | ||
773 | a.full = dfixed_const(32); | ||
774 | bandwidth.full = dfixed_mul(a, sclk); | ||
775 | bandwidth.full = dfixed_mul(bandwidth, return_efficiency); | ||
776 | |||
777 | return dfixed_trunc(bandwidth); | ||
778 | } | ||
779 | |||
780 | /** | ||
781 | * dce_v6_0_dmif_request_bandwidth - get the dmif bandwidth | ||
782 | * | ||
783 | * @wm: watermark calculation data | ||
784 | * | ||
785 | * Calculate the dmif bandwidth used for display (CIK). | ||
786 | * Used for display watermark bandwidth calculations | ||
787 | * Returns the dmif bandwidth in MBytes/s | ||
788 | */ | ||
789 | static u32 dce_v6_0_dmif_request_bandwidth(struct dce6_wm_params *wm) | ||
790 | { | ||
791 | /* Calculate the DMIF Request Bandwidth */ | ||
792 | fixed20_12 disp_clk_request_efficiency; /* 0.8 */ | ||
793 | fixed20_12 disp_clk, bandwidth; | ||
794 | fixed20_12 a, b; | ||
795 | |||
796 | a.full = dfixed_const(1000); | ||
797 | disp_clk.full = dfixed_const(wm->disp_clk); | ||
798 | disp_clk.full = dfixed_div(disp_clk, a); | ||
799 | a.full = dfixed_const(32); | ||
800 | b.full = dfixed_mul(a, disp_clk); | ||
801 | |||
802 | a.full = dfixed_const(10); | ||
803 | disp_clk_request_efficiency.full = dfixed_const(8); | ||
804 | disp_clk_request_efficiency.full = dfixed_div(disp_clk_request_efficiency, a); | ||
805 | |||
806 | bandwidth.full = dfixed_mul(b, disp_clk_request_efficiency); | ||
807 | |||
808 | return dfixed_trunc(bandwidth); | ||
809 | } | ||
810 | |||
811 | /** | ||
812 | * dce_v6_0_available_bandwidth - get the min available bandwidth | ||
813 | * | ||
814 | * @wm: watermark calculation data | ||
815 | * | ||
816 | * Calculate the min available bandwidth used for display (CIK). | ||
817 | * Used for display watermark bandwidth calculations | ||
818 | * Returns the min available bandwidth in MBytes/s | ||
819 | */ | ||
820 | static u32 dce_v6_0_available_bandwidth(struct dce6_wm_params *wm) | ||
821 | { | ||
822 | /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */ | ||
823 | u32 dram_bandwidth = dce_v6_0_dram_bandwidth(wm); | ||
824 | u32 data_return_bandwidth = dce_v6_0_data_return_bandwidth(wm); | ||
825 | u32 dmif_req_bandwidth = dce_v6_0_dmif_request_bandwidth(wm); | ||
826 | |||
827 | return min(dram_bandwidth, min(data_return_bandwidth, dmif_req_bandwidth)); | ||
828 | } | ||
829 | |||
830 | /** | ||
831 | * dce_v6_0_average_bandwidth - get the average available bandwidth | ||
832 | * | ||
833 | * @wm: watermark calculation data | ||
834 | * | ||
835 | * Calculate the average available bandwidth used for display (CIK). | ||
836 | * Used for display watermark bandwidth calculations | ||
837 | * Returns the average available bandwidth in MBytes/s | ||
838 | */ | ||
839 | static u32 dce_v6_0_average_bandwidth(struct dce6_wm_params *wm) | ||
840 | { | ||
841 | /* Calculate the display mode Average Bandwidth | ||
842 | * DisplayMode should contain the source and destination dimensions, | ||
843 | * timing, etc. | ||
844 | */ | ||
845 | fixed20_12 bpp; | ||
846 | fixed20_12 line_time; | ||
847 | fixed20_12 src_width; | ||
848 | fixed20_12 bandwidth; | ||
849 | fixed20_12 a; | ||
850 | |||
851 | a.full = dfixed_const(1000); | ||
852 | line_time.full = dfixed_const(wm->active_time + wm->blank_time); | ||
853 | line_time.full = dfixed_div(line_time, a); | ||
854 | bpp.full = dfixed_const(wm->bytes_per_pixel); | ||
855 | src_width.full = dfixed_const(wm->src_width); | ||
856 | bandwidth.full = dfixed_mul(src_width, bpp); | ||
857 | bandwidth.full = dfixed_mul(bandwidth, wm->vsc); | ||
858 | bandwidth.full = dfixed_div(bandwidth, line_time); | ||
859 | |||
860 | return dfixed_trunc(bandwidth); | ||
861 | } | ||
862 | |||
863 | /** | ||
864 | * dce_v6_0_latency_watermark - get the latency watermark | ||
865 | * | ||
866 | * @wm: watermark calculation data | ||
867 | * | ||
868 | * Calculate the latency watermark (CIK). | ||
869 | * Used for display watermark bandwidth calculations | ||
870 | * Returns the latency watermark in ns | ||
871 | */ | ||
872 | static u32 dce_v6_0_latency_watermark(struct dce6_wm_params *wm) | ||
873 | { | ||
874 | /* First calculate the latency in ns */ | ||
875 | u32 mc_latency = 2000; /* 2000 ns. */ | ||
876 | u32 available_bandwidth = dce_v6_0_available_bandwidth(wm); | ||
877 | u32 worst_chunk_return_time = (512 * 8 * 1000) / available_bandwidth; | ||
878 | u32 cursor_line_pair_return_time = (128 * 4 * 1000) / available_bandwidth; | ||
879 | u32 dc_latency = 40000000 / wm->disp_clk; /* dc pipe latency */ | ||
880 | u32 other_heads_data_return_time = ((wm->num_heads + 1) * worst_chunk_return_time) + | ||
881 | (wm->num_heads * cursor_line_pair_return_time); | ||
882 | u32 latency = mc_latency + other_heads_data_return_time + dc_latency; | ||
883 | u32 max_src_lines_per_dst_line, lb_fill_bw, line_fill_time; | ||
884 | u32 tmp, dmif_size = 12288; | ||
885 | fixed20_12 a, b, c; | ||
886 | |||
887 | if (wm->num_heads == 0) | ||
888 | return 0; | ||
889 | |||
890 | a.full = dfixed_const(2); | ||
891 | b.full = dfixed_const(1); | ||
892 | if ((wm->vsc.full > a.full) || | ||
893 | ((wm->vsc.full > b.full) && (wm->vtaps >= 3)) || | ||
894 | (wm->vtaps >= 5) || | ||
895 | ((wm->vsc.full >= a.full) && wm->interlaced)) | ||
896 | max_src_lines_per_dst_line = 4; | ||
897 | else | ||
898 | max_src_lines_per_dst_line = 2; | ||
899 | |||
900 | a.full = dfixed_const(available_bandwidth); | ||
901 | b.full = dfixed_const(wm->num_heads); | ||
902 | a.full = dfixed_div(a, b); | ||
903 | |||
904 | b.full = dfixed_const(mc_latency + 512); | ||
905 | c.full = dfixed_const(wm->disp_clk); | ||
906 | b.full = dfixed_div(b, c); | ||
907 | |||
908 | c.full = dfixed_const(dmif_size); | ||
909 | b.full = dfixed_div(c, b); | ||
910 | |||
911 | tmp = min(dfixed_trunc(a), dfixed_trunc(b)); | ||
912 | |||
913 | b.full = dfixed_const(1000); | ||
914 | c.full = dfixed_const(wm->disp_clk); | ||
915 | b.full = dfixed_div(c, b); | ||
916 | c.full = dfixed_const(wm->bytes_per_pixel); | ||
917 | b.full = dfixed_mul(b, c); | ||
918 | |||
919 | lb_fill_bw = min(tmp, dfixed_trunc(b)); | ||
920 | |||
921 | a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); | ||
922 | b.full = dfixed_const(1000); | ||
923 | c.full = dfixed_const(lb_fill_bw); | ||
924 | b.full = dfixed_div(c, b); | ||
925 | a.full = dfixed_div(a, b); | ||
926 | line_fill_time = dfixed_trunc(a); | ||
927 | |||
928 | if (line_fill_time < wm->active_time) | ||
929 | return latency; | ||
930 | else | ||
931 | return latency + (line_fill_time - wm->active_time); | ||
932 | |||
933 | } | ||
934 | |||
935 | /** | ||
936 | * dce_v6_0_average_bandwidth_vs_dram_bandwidth_for_display - check | ||
937 | * average and available dram bandwidth | ||
938 | * | ||
939 | * @wm: watermark calculation data | ||
940 | * | ||
941 | * Check if the display average bandwidth fits in the display | ||
942 | * dram bandwidth (CIK). | ||
943 | * Used for display watermark bandwidth calculations | ||
944 | * Returns true if the display fits, false if not. | ||
945 | */ | ||
946 | static bool dce_v6_0_average_bandwidth_vs_dram_bandwidth_for_display(struct dce6_wm_params *wm) | ||
947 | { | ||
948 | if (dce_v6_0_average_bandwidth(wm) <= | ||
949 | (dce_v6_0_dram_bandwidth_for_display(wm) / wm->num_heads)) | ||
950 | return true; | ||
951 | else | ||
952 | return false; | ||
953 | } | ||
954 | |||
955 | /** | ||
956 | * dce_v6_0_average_bandwidth_vs_available_bandwidth - check | ||
957 | * average and available bandwidth | ||
958 | * | ||
959 | * @wm: watermark calculation data | ||
960 | * | ||
961 | * Check if the display average bandwidth fits in the display | ||
962 | * available bandwidth (CIK). | ||
963 | * Used for display watermark bandwidth calculations | ||
964 | * Returns true if the display fits, false if not. | ||
965 | */ | ||
966 | static bool dce_v6_0_average_bandwidth_vs_available_bandwidth(struct dce6_wm_params *wm) | ||
967 | { | ||
968 | if (dce_v6_0_average_bandwidth(wm) <= | ||
969 | (dce_v6_0_available_bandwidth(wm) / wm->num_heads)) | ||
970 | return true; | ||
971 | else | ||
972 | return false; | ||
973 | } | ||
974 | |||
975 | /** | ||
976 | * dce_v6_0_check_latency_hiding - check latency hiding | ||
977 | * | ||
978 | * @wm: watermark calculation data | ||
979 | * | ||
980 | * Check latency hiding (CIK). | ||
981 | * Used for display watermark bandwidth calculations | ||
982 | * Returns true if the display fits, false if not. | ||
983 | */ | ||
984 | static bool dce_v6_0_check_latency_hiding(struct dce6_wm_params *wm) | ||
985 | { | ||
986 | u32 lb_partitions = wm->lb_size / wm->src_width; | ||
987 | u32 line_time = wm->active_time + wm->blank_time; | ||
988 | u32 latency_tolerant_lines; | ||
989 | u32 latency_hiding; | ||
990 | fixed20_12 a; | ||
991 | |||
992 | a.full = dfixed_const(1); | ||
993 | if (wm->vsc.full > a.full) | ||
994 | latency_tolerant_lines = 1; | ||
995 | else { | ||
996 | if (lb_partitions <= (wm->vtaps + 1)) | ||
997 | latency_tolerant_lines = 1; | ||
998 | else | ||
999 | latency_tolerant_lines = 2; | ||
1000 | } | ||
1001 | |||
1002 | latency_hiding = (latency_tolerant_lines * line_time + wm->blank_time); | ||
1003 | |||
1004 | if (dce_v6_0_latency_watermark(wm) <= latency_hiding) | ||
1005 | return true; | ||
1006 | else | ||
1007 | return false; | ||
1008 | } | ||
1009 | |||
1010 | /** | ||
1011 | * dce_v6_0_program_watermarks - program display watermarks | ||
1012 | * | ||
1013 | * @adev: amdgpu_device pointer | ||
1014 | * @amdgpu_crtc: the selected display controller | ||
1015 | * @lb_size: line buffer size | ||
1016 | * @num_heads: number of display controllers in use | ||
1017 | * | ||
1018 | * Calculate and program the display watermarks for the | ||
1019 | * selected display controller (CIK). | ||
1020 | */ | ||
1021 | static void dce_v6_0_program_watermarks(struct amdgpu_device *adev, | ||
1022 | struct amdgpu_crtc *amdgpu_crtc, | ||
1023 | u32 lb_size, u32 num_heads) | ||
1024 | { | ||
1025 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; | ||
1026 | struct dce6_wm_params wm_low, wm_high; | ||
1027 | u32 dram_channels; | ||
1028 | u32 pixel_period; | ||
1029 | u32 line_time = 0; | ||
1030 | u32 latency_watermark_a = 0, latency_watermark_b = 0; | ||
1031 | u32 priority_a_mark = 0, priority_b_mark = 0; | ||
1032 | u32 priority_a_cnt = PRIORITY_OFF; | ||
1033 | u32 priority_b_cnt = PRIORITY_OFF; | ||
1034 | u32 tmp, arb_control3; | ||
1035 | fixed20_12 a, b, c; | ||
1036 | |||
1037 | if (amdgpu_crtc->base.enabled && num_heads && mode) { | ||
1038 | pixel_period = 1000000 / (u32)mode->clock; | ||
1039 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); | ||
1040 | priority_a_cnt = 0; | ||
1041 | priority_b_cnt = 0; | ||
1042 | |||
1043 | dram_channels = si_get_number_of_dram_channels(adev); | ||
1044 | |||
1045 | /* watermark for high clocks */ | ||
1046 | if (adev->pm.dpm_enabled) { | ||
1047 | wm_high.yclk = | ||
1048 | amdgpu_dpm_get_mclk(adev, false) * 10; | ||
1049 | wm_high.sclk = | ||
1050 | amdgpu_dpm_get_sclk(adev, false) * 10; | ||
1051 | } else { | ||
1052 | wm_high.yclk = adev->pm.current_mclk * 10; | ||
1053 | wm_high.sclk = adev->pm.current_sclk * 10; | ||
1054 | } | ||
1055 | |||
1056 | wm_high.disp_clk = mode->clock; | ||
1057 | wm_high.src_width = mode->crtc_hdisplay; | ||
1058 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; | ||
1059 | wm_high.blank_time = line_time - wm_high.active_time; | ||
1060 | wm_high.interlaced = false; | ||
1061 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | ||
1062 | wm_high.interlaced = true; | ||
1063 | wm_high.vsc = amdgpu_crtc->vsc; | ||
1064 | wm_high.vtaps = 1; | ||
1065 | if (amdgpu_crtc->rmx_type != RMX_OFF) | ||
1066 | wm_high.vtaps = 2; | ||
1067 | wm_high.bytes_per_pixel = 4; /* XXX: get this from fb config */ | ||
1068 | wm_high.lb_size = lb_size; | ||
1069 | wm_high.dram_channels = dram_channels; | ||
1070 | wm_high.num_heads = num_heads; | ||
1071 | |||
1072 | if (adev->pm.dpm_enabled) { | ||
1073 | /* watermark for low clocks */ | ||
1074 | wm_low.yclk = | ||
1075 | amdgpu_dpm_get_mclk(adev, true) * 10; | ||
1076 | wm_low.sclk = | ||
1077 | amdgpu_dpm_get_sclk(adev, true) * 10; | ||
1078 | } else { | ||
1079 | wm_low.yclk = adev->pm.current_mclk * 10; | ||
1080 | wm_low.sclk = adev->pm.current_sclk * 10; | ||
1081 | } | ||
1082 | |||
1083 | wm_low.disp_clk = mode->clock; | ||
1084 | wm_low.src_width = mode->crtc_hdisplay; | ||
1085 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; | ||
1086 | wm_low.blank_time = line_time - wm_low.active_time; | ||
1087 | wm_low.interlaced = false; | ||
1088 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | ||
1089 | wm_low.interlaced = true; | ||
1090 | wm_low.vsc = amdgpu_crtc->vsc; | ||
1091 | wm_low.vtaps = 1; | ||
1092 | if (amdgpu_crtc->rmx_type != RMX_OFF) | ||
1093 | wm_low.vtaps = 2; | ||
1094 | wm_low.bytes_per_pixel = 4; /* XXX: get this from fb config */ | ||
1095 | wm_low.lb_size = lb_size; | ||
1096 | wm_low.dram_channels = dram_channels; | ||
1097 | wm_low.num_heads = num_heads; | ||
1098 | |||
1099 | /* set for high clocks */ | ||
1100 | latency_watermark_a = min(dce_v6_0_latency_watermark(&wm_high), (u32)65535); | ||
1101 | /* set for low clocks */ | ||
1102 | latency_watermark_b = min(dce_v6_0_latency_watermark(&wm_low), (u32)65535); | ||
1103 | |||
1104 | /* possibly force display priority to high */ | ||
1105 | /* should really do this at mode validation time... */ | ||
1106 | if (!dce_v6_0_average_bandwidth_vs_dram_bandwidth_for_display(&wm_high) || | ||
1107 | !dce_v6_0_average_bandwidth_vs_available_bandwidth(&wm_high) || | ||
1108 | !dce_v6_0_check_latency_hiding(&wm_high) || | ||
1109 | (adev->mode_info.disp_priority == 2)) { | ||
1110 | DRM_DEBUG_KMS("force priority to high\n"); | ||
1111 | priority_a_cnt |= PRIORITY_ALWAYS_ON; | ||
1112 | priority_b_cnt |= PRIORITY_ALWAYS_ON; | ||
1113 | } | ||
1114 | if (!dce_v6_0_average_bandwidth_vs_dram_bandwidth_for_display(&wm_low) || | ||
1115 | !dce_v6_0_average_bandwidth_vs_available_bandwidth(&wm_low) || | ||
1116 | !dce_v6_0_check_latency_hiding(&wm_low) || | ||
1117 | (adev->mode_info.disp_priority == 2)) { | ||
1118 | DRM_DEBUG_KMS("force priority to high\n"); | ||
1119 | priority_a_cnt |= PRIORITY_ALWAYS_ON; | ||
1120 | priority_b_cnt |= PRIORITY_ALWAYS_ON; | ||
1121 | } | ||
1122 | |||
1123 | a.full = dfixed_const(1000); | ||
1124 | b.full = dfixed_const(mode->clock); | ||
1125 | b.full = dfixed_div(b, a); | ||
1126 | c.full = dfixed_const(latency_watermark_a); | ||
1127 | c.full = dfixed_mul(c, b); | ||
1128 | c.full = dfixed_mul(c, amdgpu_crtc->hsc); | ||
1129 | c.full = dfixed_div(c, a); | ||
1130 | a.full = dfixed_const(16); | ||
1131 | c.full = dfixed_div(c, a); | ||
1132 | priority_a_mark = dfixed_trunc(c); | ||
1133 | priority_a_cnt |= priority_a_mark & PRIORITY_MARK_MASK; | ||
1134 | |||
1135 | a.full = dfixed_const(1000); | ||
1136 | b.full = dfixed_const(mode->clock); | ||
1137 | b.full = dfixed_div(b, a); | ||
1138 | c.full = dfixed_const(latency_watermark_b); | ||
1139 | c.full = dfixed_mul(c, b); | ||
1140 | c.full = dfixed_mul(c, amdgpu_crtc->hsc); | ||
1141 | c.full = dfixed_div(c, a); | ||
1142 | a.full = dfixed_const(16); | ||
1143 | c.full = dfixed_div(c, a); | ||
1144 | priority_b_mark = dfixed_trunc(c); | ||
1145 | priority_b_cnt |= priority_b_mark & PRIORITY_MARK_MASK; | ||
1146 | } | ||
1147 | |||
1148 | /* select wm A */ | ||
1149 | arb_control3 = RREG32(DPG_PIPE_ARBITRATION_CONTROL3 + amdgpu_crtc->crtc_offset); | ||
1150 | tmp = arb_control3; | ||
1151 | tmp &= ~LATENCY_WATERMARK_MASK(3); | ||
1152 | tmp |= LATENCY_WATERMARK_MASK(1); | ||
1153 | WREG32(DPG_PIPE_ARBITRATION_CONTROL3 + amdgpu_crtc->crtc_offset, tmp); | ||
1154 | WREG32(DPG_PIPE_LATENCY_CONTROL + amdgpu_crtc->crtc_offset, | ||
1155 | (LATENCY_LOW_WATERMARK(latency_watermark_a) | | ||
1156 | LATENCY_HIGH_WATERMARK(line_time))); | ||
1157 | /* select wm B */ | ||
1158 | tmp = RREG32(DPG_PIPE_ARBITRATION_CONTROL3 + amdgpu_crtc->crtc_offset); | ||
1159 | tmp &= ~LATENCY_WATERMARK_MASK(3); | ||
1160 | tmp |= LATENCY_WATERMARK_MASK(2); | ||
1161 | WREG32(DPG_PIPE_ARBITRATION_CONTROL3 + amdgpu_crtc->crtc_offset, tmp); | ||
1162 | WREG32(DPG_PIPE_LATENCY_CONTROL + amdgpu_crtc->crtc_offset, | ||
1163 | (LATENCY_LOW_WATERMARK(latency_watermark_b) | | ||
1164 | LATENCY_HIGH_WATERMARK(line_time))); | ||
1165 | /* restore original selection */ | ||
1166 | WREG32(DPG_PIPE_ARBITRATION_CONTROL3 + amdgpu_crtc->crtc_offset, arb_control3); | ||
1167 | |||
1168 | /* write the priority marks */ | ||
1169 | WREG32(PRIORITY_A_CNT + amdgpu_crtc->crtc_offset, priority_a_cnt); | ||
1170 | WREG32(PRIORITY_B_CNT + amdgpu_crtc->crtc_offset, priority_b_cnt); | ||
1171 | |||
1172 | /* save values for DPM */ | ||
1173 | amdgpu_crtc->line_time = line_time; | ||
1174 | amdgpu_crtc->wm_high = latency_watermark_a; | ||
1175 | } | ||
1176 | |||
1177 | /* watermark setup */ | ||
1178 | static u32 dce_v6_0_line_buffer_adjust(struct amdgpu_device *adev, | ||
1179 | struct amdgpu_crtc *amdgpu_crtc, | ||
1180 | struct drm_display_mode *mode, | ||
1181 | struct drm_display_mode *other_mode) | ||
1182 | { | ||
1183 | u32 tmp, buffer_alloc, i; | ||
1184 | u32 pipe_offset = amdgpu_crtc->crtc_id * 0x8; | ||
1185 | /* | ||
1186 | * Line Buffer Setup | ||
1187 | * There are 3 line buffers, each one shared by 2 display controllers. | ||
1188 | * DC_LB_MEMORY_SPLIT controls how that line buffer is shared between | ||
1189 | * the display controllers. The paritioning is done via one of four | ||
1190 | * preset allocations specified in bits 21:20: | ||
1191 | * 0 - half lb | ||
1192 | * 2 - whole lb, other crtc must be disabled | ||
1193 | */ | ||
1194 | /* this can get tricky if we have two large displays on a paired group | ||
1195 | * of crtcs. Ideally for multiple large displays we'd assign them to | ||
1196 | * non-linked crtcs for maximum line buffer allocation. | ||
1197 | */ | ||
1198 | if (amdgpu_crtc->base.enabled && mode) { | ||
1199 | if (other_mode) { | ||
1200 | tmp = 0; /* 1/2 */ | ||
1201 | buffer_alloc = 1; | ||
1202 | } else { | ||
1203 | tmp = 2; /* whole */ | ||
1204 | buffer_alloc = 2; | ||
1205 | } | ||
1206 | } else { | ||
1207 | tmp = 0; | ||
1208 | buffer_alloc = 0; | ||
1209 | } | ||
1210 | |||
1211 | WREG32(DC_LB_MEMORY_SPLIT + amdgpu_crtc->crtc_offset, | ||
1212 | DC_LB_MEMORY_CONFIG(tmp)); | ||
1213 | |||
1214 | WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset, | ||
1215 | DMIF_BUFFERS_ALLOCATED(buffer_alloc)); | ||
1216 | for (i = 0; i < adev->usec_timeout; i++) { | ||
1217 | if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) & | ||
1218 | DMIF_BUFFERS_ALLOCATED_COMPLETED) | ||
1219 | break; | ||
1220 | udelay(1); | ||
1221 | } | ||
1222 | |||
1223 | if (amdgpu_crtc->base.enabled && mode) { | ||
1224 | switch (tmp) { | ||
1225 | case 0: | ||
1226 | default: | ||
1227 | return 4096 * 2; | ||
1228 | case 2: | ||
1229 | return 8192 * 2; | ||
1230 | } | ||
1231 | } | ||
1232 | |||
1233 | /* controller not enabled, so no lb used */ | ||
1234 | return 0; | ||
1235 | } | ||
1236 | |||
1237 | |||
1238 | /** | ||
1239 | * | ||
1240 | * dce_v6_0_bandwidth_update - program display watermarks | ||
1241 | * | ||
1242 | * @adev: amdgpu_device pointer | ||
1243 | * | ||
1244 | * Calculate and program the display watermarks and line | ||
1245 | * buffer allocation (CIK). | ||
1246 | */ | ||
1247 | static void dce_v6_0_bandwidth_update(struct amdgpu_device *adev) | ||
1248 | { | ||
1249 | struct drm_display_mode *mode0 = NULL; | ||
1250 | struct drm_display_mode *mode1 = NULL; | ||
1251 | u32 num_heads = 0, lb_size; | ||
1252 | int i; | ||
1253 | |||
1254 | if (!adev->mode_info.mode_config_initialized) | ||
1255 | return; | ||
1256 | |||
1257 | amdgpu_update_display_priority(adev); | ||
1258 | |||
1259 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
1260 | if (adev->mode_info.crtcs[i]->base.enabled) | ||
1261 | num_heads++; | ||
1262 | } | ||
1263 | for (i = 0; i < adev->mode_info.num_crtc; i += 2) { | ||
1264 | mode0 = &adev->mode_info.crtcs[i]->base.mode; | ||
1265 | mode1 = &adev->mode_info.crtcs[i+1]->base.mode; | ||
1266 | lb_size = dce_v6_0_line_buffer_adjust(adev, adev->mode_info.crtcs[i], mode0, mode1); | ||
1267 | dce_v6_0_program_watermarks(adev, adev->mode_info.crtcs[i], lb_size, num_heads); | ||
1268 | lb_size = dce_v6_0_line_buffer_adjust(adev, adev->mode_info.crtcs[i+1], mode1, mode0); | ||
1269 | dce_v6_0_program_watermarks(adev, adev->mode_info.crtcs[i+1], lb_size, num_heads); | ||
1270 | } | ||
1271 | } | ||
1272 | /* | ||
1273 | static void dce_v6_0_audio_get_connected_pins(struct amdgpu_device *adev) | ||
1274 | { | ||
1275 | int i; | ||
1276 | u32 offset, tmp; | ||
1277 | |||
1278 | for (i = 0; i < adev->mode_info.audio.num_pins; i++) { | ||
1279 | offset = adev->mode_info.audio.pin[i].offset; | ||
1280 | tmp = RREG32_AUDIO_ENDPT(offset, | ||
1281 | AZ_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT); | ||
1282 | if (((tmp & PORT_CONNECTIVITY_MASK) >> PORT_CONNECTIVITY_SHIFT) == 1) | ||
1283 | adev->mode_info.audio.pin[i].connected = false; | ||
1284 | else | ||
1285 | adev->mode_info.audio.pin[i].connected = true; | ||
1286 | } | ||
1287 | |||
1288 | } | ||
1289 | |||
1290 | static struct amdgpu_audio_pin *dce_v6_0_audio_get_pin(struct amdgpu_device *adev) | ||
1291 | { | ||
1292 | int i; | ||
1293 | |||
1294 | dce_v6_0_audio_get_connected_pins(adev); | ||
1295 | |||
1296 | for (i = 0; i < adev->mode_info.audio.num_pins; i++) { | ||
1297 | if (adev->mode_info.audio.pin[i].connected) | ||
1298 | return &adev->mode_info.audio.pin[i]; | ||
1299 | } | ||
1300 | DRM_ERROR("No connected audio pins found!\n"); | ||
1301 | return NULL; | ||
1302 | } | ||
1303 | |||
1304 | static void dce_v6_0_afmt_audio_select_pin(struct drm_encoder *encoder) | ||
1305 | { | ||
1306 | struct amdgpu_device *adev = encoder->dev->dev_private; | ||
1307 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
1308 | struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; | ||
1309 | u32 offset; | ||
1310 | |||
1311 | if (!dig || !dig->afmt || !dig->afmt->pin) | ||
1312 | return; | ||
1313 | |||
1314 | offset = dig->afmt->offset; | ||
1315 | |||
1316 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, | ||
1317 | AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); | ||
1318 | |||
1319 | } | ||
1320 | |||
1321 | static void dce_v6_0_audio_write_latency_fields(struct drm_encoder *encoder, | ||
1322 | struct drm_display_mode *mode) | ||
1323 | { | ||
1324 | DRM_INFO("xxxx: dce_v6_0_audio_write_latency_fields---no imp!!!!!\n"); | ||
1325 | } | ||
1326 | |||
1327 | static void dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder) | ||
1328 | { | ||
1329 | DRM_INFO("xxxx: dce_v6_0_audio_write_speaker_allocation---no imp!!!!!\n"); | ||
1330 | } | ||
1331 | |||
1332 | static void dce_v6_0_audio_write_sad_regs(struct drm_encoder *encoder) | ||
1333 | { | ||
1334 | DRM_INFO("xxxx: dce_v6_0_audio_write_sad_regs---no imp!!!!!\n"); | ||
1335 | |||
1336 | } | ||
1337 | */ | ||
1338 | static void dce_v6_0_audio_enable(struct amdgpu_device *adev, | ||
1339 | struct amdgpu_audio_pin *pin, | ||
1340 | bool enable) | ||
1341 | { | ||
1342 | DRM_INFO("xxxx: dce_v6_0_audio_enable---no imp!!!!!\n"); | ||
1343 | } | ||
1344 | |||
1345 | static const u32 pin_offsets[7] = | ||
1346 | { | ||
1347 | (0x1780 - 0x1780), | ||
1348 | (0x1786 - 0x1780), | ||
1349 | (0x178c - 0x1780), | ||
1350 | (0x1792 - 0x1780), | ||
1351 | (0x1798 - 0x1780), | ||
1352 | (0x179d - 0x1780), | ||
1353 | (0x17a4 - 0x1780), | ||
1354 | }; | ||
1355 | |||
1356 | static int dce_v6_0_audio_init(struct amdgpu_device *adev) | ||
1357 | { | ||
1358 | return 0; | ||
1359 | } | ||
1360 | |||
1361 | static void dce_v6_0_audio_fini(struct amdgpu_device *adev) | ||
1362 | { | ||
1363 | |||
1364 | } | ||
1365 | |||
1366 | /* | ||
1367 | static void dce_v6_0_afmt_update_ACR(struct drm_encoder *encoder, uint32_t clock) | ||
1368 | { | ||
1369 | DRM_INFO("xxxx: dce_v6_0_afmt_update_ACR---no imp!!!!!\n"); | ||
1370 | } | ||
1371 | */ | ||
1372 | /* | ||
1373 | * build a HDMI Video Info Frame | ||
1374 | */ | ||
1375 | /* | ||
1376 | static void dce_v6_0_afmt_update_avi_infoframe(struct drm_encoder *encoder, | ||
1377 | void *buffer, size_t size) | ||
1378 | { | ||
1379 | DRM_INFO("xxxx: dce_v6_0_afmt_update_avi_infoframe---no imp!!!!!\n"); | ||
1380 | } | ||
1381 | |||
1382 | static void dce_v6_0_audio_set_dto(struct drm_encoder *encoder, u32 clock) | ||
1383 | { | ||
1384 | DRM_INFO("xxxx: dce_v6_0_audio_set_dto---no imp!!!!!\n"); | ||
1385 | } | ||
1386 | */ | ||
1387 | /* | ||
1388 | * update the info frames with the data from the current display mode | ||
1389 | */ | ||
1390 | static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder, | ||
1391 | struct drm_display_mode *mode) | ||
1392 | { | ||
1393 | DRM_INFO("xxxx: dce_v6_0_afmt_setmode ----no impl !!!!!!!!\n"); | ||
1394 | } | ||
1395 | |||
1396 | static void dce_v6_0_afmt_enable(struct drm_encoder *encoder, bool enable) | ||
1397 | { | ||
1398 | struct drm_device *dev = encoder->dev; | ||
1399 | struct amdgpu_device *adev = dev->dev_private; | ||
1400 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
1401 | struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; | ||
1402 | |||
1403 | if (!dig || !dig->afmt) | ||
1404 | return; | ||
1405 | |||
1406 | /* Silent, r600_hdmi_enable will raise WARN for us */ | ||
1407 | if (enable && dig->afmt->enabled) | ||
1408 | return; | ||
1409 | if (!enable && !dig->afmt->enabled) | ||
1410 | return; | ||
1411 | |||
1412 | if (!enable && dig->afmt->pin) { | ||
1413 | dce_v6_0_audio_enable(adev, dig->afmt->pin, false); | ||
1414 | dig->afmt->pin = NULL; | ||
1415 | } | ||
1416 | |||
1417 | dig->afmt->enabled = enable; | ||
1418 | |||
1419 | DRM_DEBUG("%sabling AFMT interface @ 0x%04X for encoder 0x%x\n", | ||
1420 | enable ? "En" : "Dis", dig->afmt->offset, amdgpu_encoder->encoder_id); | ||
1421 | } | ||
1422 | |||
1423 | static void dce_v6_0_afmt_init(struct amdgpu_device *adev) | ||
1424 | { | ||
1425 | int i; | ||
1426 | |||
1427 | for (i = 0; i < adev->mode_info.num_dig; i++) | ||
1428 | adev->mode_info.afmt[i] = NULL; | ||
1429 | |||
1430 | /* DCE8 has audio blocks tied to DIG encoders */ | ||
1431 | for (i = 0; i < adev->mode_info.num_dig; i++) { | ||
1432 | adev->mode_info.afmt[i] = kzalloc(sizeof(struct amdgpu_afmt), GFP_KERNEL); | ||
1433 | if (adev->mode_info.afmt[i]) { | ||
1434 | adev->mode_info.afmt[i]->offset = dig_offsets[i]; | ||
1435 | adev->mode_info.afmt[i]->id = i; | ||
1436 | } | ||
1437 | } | ||
1438 | } | ||
1439 | |||
1440 | static void dce_v6_0_afmt_fini(struct amdgpu_device *adev) | ||
1441 | { | ||
1442 | int i; | ||
1443 | |||
1444 | for (i = 0; i < adev->mode_info.num_dig; i++) { | ||
1445 | kfree(adev->mode_info.afmt[i]); | ||
1446 | adev->mode_info.afmt[i] = NULL; | ||
1447 | } | ||
1448 | } | ||
1449 | |||
1450 | static const u32 vga_control_regs[6] = | ||
1451 | { | ||
1452 | AVIVO_D1VGA_CONTROL, | ||
1453 | AVIVO_D2VGA_CONTROL, | ||
1454 | EVERGREEN_D3VGA_CONTROL, | ||
1455 | EVERGREEN_D4VGA_CONTROL, | ||
1456 | EVERGREEN_D5VGA_CONTROL, | ||
1457 | EVERGREEN_D6VGA_CONTROL, | ||
1458 | }; | ||
1459 | |||
1460 | static void dce_v6_0_vga_enable(struct drm_crtc *crtc, bool enable) | ||
1461 | { | ||
1462 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1463 | struct drm_device *dev = crtc->dev; | ||
1464 | struct amdgpu_device *adev = dev->dev_private; | ||
1465 | u32 vga_control; | ||
1466 | |||
1467 | vga_control = RREG32(vga_control_regs[amdgpu_crtc->crtc_id]) & ~1; | ||
1468 | if (enable) | ||
1469 | WREG32(vga_control_regs[amdgpu_crtc->crtc_id], vga_control | 1); | ||
1470 | else | ||
1471 | WREG32(vga_control_regs[amdgpu_crtc->crtc_id], vga_control); | ||
1472 | } | ||
1473 | |||
1474 | static void dce_v6_0_grph_enable(struct drm_crtc *crtc, bool enable) | ||
1475 | { | ||
1476 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1477 | struct drm_device *dev = crtc->dev; | ||
1478 | struct amdgpu_device *adev = dev->dev_private; | ||
1479 | |||
1480 | if (enable) | ||
1481 | WREG32(EVERGREEN_GRPH_ENABLE + amdgpu_crtc->crtc_offset, 1); | ||
1482 | else | ||
1483 | WREG32(EVERGREEN_GRPH_ENABLE + amdgpu_crtc->crtc_offset, 0); | ||
1484 | } | ||
1485 | |||
1486 | static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc, | ||
1487 | struct drm_framebuffer *fb, | ||
1488 | int x, int y, int atomic) | ||
1489 | { | ||
1490 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1491 | struct drm_device *dev = crtc->dev; | ||
1492 | struct amdgpu_device *adev = dev->dev_private; | ||
1493 | struct amdgpu_framebuffer *amdgpu_fb; | ||
1494 | struct drm_framebuffer *target_fb; | ||
1495 | struct drm_gem_object *obj; | ||
1496 | struct amdgpu_bo *rbo; | ||
1497 | uint64_t fb_location, tiling_flags; | ||
1498 | uint32_t fb_format, fb_pitch_pixels, pipe_config; | ||
1499 | u32 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_NONE); | ||
1500 | u32 viewport_w, viewport_h; | ||
1501 | int r; | ||
1502 | bool bypass_lut = false; | ||
1503 | |||
1504 | /* no fb bound */ | ||
1505 | if (!atomic && !crtc->primary->fb) { | ||
1506 | DRM_DEBUG_KMS("No FB bound\n"); | ||
1507 | return 0; | ||
1508 | } | ||
1509 | |||
1510 | if (atomic) { | ||
1511 | amdgpu_fb = to_amdgpu_framebuffer(fb); | ||
1512 | target_fb = fb; | ||
1513 | } | ||
1514 | else { | ||
1515 | amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb); | ||
1516 | target_fb = crtc->primary->fb; | ||
1517 | } | ||
1518 | |||
1519 | /* If atomic, assume fb object is pinned & idle & fenced and | ||
1520 | * just update base pointers | ||
1521 | */ | ||
1522 | obj = amdgpu_fb->obj; | ||
1523 | rbo = gem_to_amdgpu_bo(obj); | ||
1524 | r = amdgpu_bo_reserve(rbo, false); | ||
1525 | if (unlikely(r != 0)) | ||
1526 | return r; | ||
1527 | |||
1528 | if (atomic) | ||
1529 | fb_location = amdgpu_bo_gpu_offset(rbo); | ||
1530 | else { | ||
1531 | r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &fb_location); | ||
1532 | if (unlikely(r != 0)) { | ||
1533 | amdgpu_bo_unreserve(rbo); | ||
1534 | return -EINVAL; | ||
1535 | } | ||
1536 | } | ||
1537 | |||
1538 | amdgpu_bo_get_tiling_flags(rbo, &tiling_flags); | ||
1539 | amdgpu_bo_unreserve(rbo); | ||
1540 | |||
1541 | switch (target_fb->pixel_format) { | ||
1542 | case DRM_FORMAT_C8: | ||
1543 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) | | ||
1544 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED)); | ||
1545 | break; | ||
1546 | case DRM_FORMAT_XRGB4444: | ||
1547 | case DRM_FORMAT_ARGB4444: | ||
1548 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | | ||
1549 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB4444)); | ||
1550 | #ifdef __BIG_ENDIAN | ||
1551 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16); | ||
1552 | #endif | ||
1553 | break; | ||
1554 | case DRM_FORMAT_XRGB1555: | ||
1555 | case DRM_FORMAT_ARGB1555: | ||
1556 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | | ||
1557 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB1555)); | ||
1558 | #ifdef __BIG_ENDIAN | ||
1559 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16); | ||
1560 | #endif | ||
1561 | break; | ||
1562 | case DRM_FORMAT_BGRX5551: | ||
1563 | case DRM_FORMAT_BGRA5551: | ||
1564 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | | ||
1565 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_BGRA5551)); | ||
1566 | #ifdef __BIG_ENDIAN | ||
1567 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16); | ||
1568 | #endif | ||
1569 | break; | ||
1570 | case DRM_FORMAT_RGB565: | ||
1571 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | | ||
1572 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565)); | ||
1573 | #ifdef __BIG_ENDIAN | ||
1574 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16); | ||
1575 | #endif | ||
1576 | break; | ||
1577 | case DRM_FORMAT_XRGB8888: | ||
1578 | case DRM_FORMAT_ARGB8888: | ||
1579 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | | ||
1580 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888)); | ||
1581 | #ifdef __BIG_ENDIAN | ||
1582 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32); | ||
1583 | #endif | ||
1584 | break; | ||
1585 | case DRM_FORMAT_XRGB2101010: | ||
1586 | case DRM_FORMAT_ARGB2101010: | ||
1587 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | | ||
1588 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB2101010)); | ||
1589 | #ifdef __BIG_ENDIAN | ||
1590 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32); | ||
1591 | #endif | ||
1592 | /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ | ||
1593 | bypass_lut = true; | ||
1594 | break; | ||
1595 | case DRM_FORMAT_BGRX1010102: | ||
1596 | case DRM_FORMAT_BGRA1010102: | ||
1597 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | | ||
1598 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_BGRA1010102)); | ||
1599 | #ifdef __BIG_ENDIAN | ||
1600 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32); | ||
1601 | #endif | ||
1602 | /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ | ||
1603 | bypass_lut = true; | ||
1604 | break; | ||
1605 | default: | ||
1606 | DRM_ERROR("Unsupported screen format %s\n", | ||
1607 | drm_get_format_name(target_fb->pixel_format)); | ||
1608 | return -EINVAL; | ||
1609 | } | ||
1610 | |||
1611 | if (AMDGPU_TILING_GET(tiling_flags, ARRAY_MODE) == ARRAY_2D_TILED_THIN1) { | ||
1612 | unsigned bankw, bankh, mtaspect, tile_split, num_banks; | ||
1613 | |||
1614 | bankw = AMDGPU_TILING_GET(tiling_flags, BANK_WIDTH); | ||
1615 | bankh = AMDGPU_TILING_GET(tiling_flags, BANK_HEIGHT); | ||
1616 | mtaspect = AMDGPU_TILING_GET(tiling_flags, MACRO_TILE_ASPECT); | ||
1617 | tile_split = AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT); | ||
1618 | num_banks = AMDGPU_TILING_GET(tiling_flags, NUM_BANKS); | ||
1619 | |||
1620 | fb_format |= EVERGREEN_GRPH_NUM_BANKS(num_banks); | ||
1621 | fb_format |= EVERGREEN_GRPH_ARRAY_MODE(EVERGREEN_GRPH_ARRAY_2D_TILED_THIN1); | ||
1622 | fb_format |= EVERGREEN_GRPH_TILE_SPLIT(tile_split); | ||
1623 | fb_format |= EVERGREEN_GRPH_BANK_WIDTH(bankw); | ||
1624 | fb_format |= EVERGREEN_GRPH_BANK_HEIGHT(bankh); | ||
1625 | fb_format |= EVERGREEN_GRPH_MACRO_TILE_ASPECT(mtaspect); | ||
1626 | } else if (AMDGPU_TILING_GET(tiling_flags, ARRAY_MODE) == ARRAY_1D_TILED_THIN1) | ||
1627 | fb_format |= EVERGREEN_GRPH_ARRAY_MODE(EVERGREEN_GRPH_ARRAY_1D_TILED_THIN1); | ||
1628 | |||
1629 | pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG); | ||
1630 | fb_format |= SI_GRPH_PIPE_CONFIG(pipe_config); | ||
1631 | |||
1632 | dce_v6_0_vga_enable(crtc, false); | ||
1633 | |||
1634 | /* Make sure surface address is updated at vertical blank rather than | ||
1635 | * horizontal blank | ||
1636 | */ | ||
1637 | WREG32(EVERGREEN_GRPH_FLIP_CONTROL + amdgpu_crtc->crtc_offset, 0); | ||
1638 | |||
1639 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
1640 | upper_32_bits(fb_location)); | ||
1641 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
1642 | upper_32_bits(fb_location)); | ||
1643 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
1644 | (u32)fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); | ||
1645 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
1646 | (u32) fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); | ||
1647 | WREG32(EVERGREEN_GRPH_CONTROL + amdgpu_crtc->crtc_offset, fb_format); | ||
1648 | WREG32(EVERGREEN_GRPH_SWAP_CONTROL + amdgpu_crtc->crtc_offset, fb_swap); | ||
1649 | |||
1650 | /* | ||
1651 | * The LUT only has 256 slots for indexing by a 8 bpc fb. Bypass the LUT | ||
1652 | * for > 8 bpc scanout to avoid truncation of fb indices to 8 msb's, to | ||
1653 | * retain the full precision throughout the pipeline. | ||
1654 | */ | ||
1655 | WREG32_P(EVERGREEN_GRPH_LUT_10BIT_BYPASS_CONTROL + amdgpu_crtc->crtc_offset, | ||
1656 | (bypass_lut ? EVERGREEN_LUT_10BIT_BYPASS_EN : 0), | ||
1657 | ~EVERGREEN_LUT_10BIT_BYPASS_EN); | ||
1658 | |||
1659 | if (bypass_lut) | ||
1660 | DRM_DEBUG_KMS("Bypassing hardware LUT due to 10 bit fb scanout.\n"); | ||
1661 | |||
1662 | WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + amdgpu_crtc->crtc_offset, 0); | ||
1663 | WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + amdgpu_crtc->crtc_offset, 0); | ||
1664 | WREG32(EVERGREEN_GRPH_X_START + amdgpu_crtc->crtc_offset, 0); | ||
1665 | WREG32(EVERGREEN_GRPH_Y_START + amdgpu_crtc->crtc_offset, 0); | ||
1666 | WREG32(EVERGREEN_GRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width); | ||
1667 | WREG32(EVERGREEN_GRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height); | ||
1668 | |||
1669 | fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8); | ||
1670 | WREG32(EVERGREEN_GRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels); | ||
1671 | |||
1672 | dce_v6_0_grph_enable(crtc, true); | ||
1673 | |||
1674 | WREG32(EVERGREEN_DESKTOP_HEIGHT + amdgpu_crtc->crtc_offset, | ||
1675 | target_fb->height); | ||
1676 | x &= ~3; | ||
1677 | y &= ~1; | ||
1678 | WREG32(EVERGREEN_VIEWPORT_START + amdgpu_crtc->crtc_offset, | ||
1679 | (x << 16) | y); | ||
1680 | viewport_w = crtc->mode.hdisplay; | ||
1681 | viewport_h = (crtc->mode.vdisplay + 1) & ~1; | ||
1682 | |||
1683 | WREG32(EVERGREEN_VIEWPORT_SIZE + amdgpu_crtc->crtc_offset, | ||
1684 | (viewport_w << 16) | viewport_h); | ||
1685 | |||
1686 | /* set pageflip to happen anywhere in vblank interval */ | ||
1687 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0); | ||
1688 | |||
1689 | if (!atomic && fb && fb != crtc->primary->fb) { | ||
1690 | amdgpu_fb = to_amdgpu_framebuffer(fb); | ||
1691 | rbo = gem_to_amdgpu_bo(amdgpu_fb->obj); | ||
1692 | r = amdgpu_bo_reserve(rbo, false); | ||
1693 | if (unlikely(r != 0)) | ||
1694 | return r; | ||
1695 | amdgpu_bo_unpin(rbo); | ||
1696 | amdgpu_bo_unreserve(rbo); | ||
1697 | } | ||
1698 | |||
1699 | /* Bytes per pixel may have changed */ | ||
1700 | dce_v6_0_bandwidth_update(adev); | ||
1701 | |||
1702 | return 0; | ||
1703 | |||
1704 | } | ||
1705 | |||
1706 | static void dce_v6_0_set_interleave(struct drm_crtc *crtc, | ||
1707 | struct drm_display_mode *mode) | ||
1708 | { | ||
1709 | struct drm_device *dev = crtc->dev; | ||
1710 | struct amdgpu_device *adev = dev->dev_private; | ||
1711 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1712 | |||
1713 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | ||
1714 | WREG32(EVERGREEN_DATA_FORMAT + amdgpu_crtc->crtc_offset, | ||
1715 | EVERGREEN_INTERLEAVE_EN); | ||
1716 | else | ||
1717 | WREG32(EVERGREEN_DATA_FORMAT + amdgpu_crtc->crtc_offset, 0); | ||
1718 | } | ||
1719 | |||
1720 | static void dce_v6_0_crtc_load_lut(struct drm_crtc *crtc) | ||
1721 | { | ||
1722 | |||
1723 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1724 | struct drm_device *dev = crtc->dev; | ||
1725 | struct amdgpu_device *adev = dev->dev_private; | ||
1726 | int i; | ||
1727 | |||
1728 | DRM_DEBUG_KMS("%d\n", amdgpu_crtc->crtc_id); | ||
1729 | |||
1730 | WREG32(NI_INPUT_CSC_CONTROL + amdgpu_crtc->crtc_offset, | ||
1731 | (NI_INPUT_CSC_GRPH_MODE(NI_INPUT_CSC_BYPASS) | | ||
1732 | NI_INPUT_CSC_OVL_MODE(NI_INPUT_CSC_BYPASS))); | ||
1733 | WREG32(NI_PRESCALE_GRPH_CONTROL + amdgpu_crtc->crtc_offset, | ||
1734 | NI_GRPH_PRESCALE_BYPASS); | ||
1735 | WREG32(NI_PRESCALE_OVL_CONTROL + amdgpu_crtc->crtc_offset, | ||
1736 | NI_OVL_PRESCALE_BYPASS); | ||
1737 | WREG32(NI_INPUT_GAMMA_CONTROL + amdgpu_crtc->crtc_offset, | ||
1738 | (NI_GRPH_INPUT_GAMMA_MODE(NI_INPUT_GAMMA_USE_LUT) | | ||
1739 | NI_OVL_INPUT_GAMMA_MODE(NI_INPUT_GAMMA_USE_LUT))); | ||
1740 | |||
1741 | |||
1742 | |||
1743 | WREG32(EVERGREEN_DC_LUT_CONTROL + amdgpu_crtc->crtc_offset, 0); | ||
1744 | |||
1745 | WREG32(EVERGREEN_DC_LUT_BLACK_OFFSET_BLUE + amdgpu_crtc->crtc_offset, 0); | ||
1746 | WREG32(EVERGREEN_DC_LUT_BLACK_OFFSET_GREEN + amdgpu_crtc->crtc_offset, 0); | ||
1747 | WREG32(EVERGREEN_DC_LUT_BLACK_OFFSET_RED + amdgpu_crtc->crtc_offset, 0); | ||
1748 | |||
1749 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_BLUE + amdgpu_crtc->crtc_offset, 0xffff); | ||
1750 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN + amdgpu_crtc->crtc_offset, 0xffff); | ||
1751 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_RED + amdgpu_crtc->crtc_offset, 0xffff); | ||
1752 | |||
1753 | WREG32(EVERGREEN_DC_LUT_RW_MODE + amdgpu_crtc->crtc_offset, 0); | ||
1754 | WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x00000007); | ||
1755 | |||
1756 | WREG32(EVERGREEN_DC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0); | ||
1757 | for (i = 0; i < 256; i++) { | ||
1758 | WREG32(EVERGREEN_DC_LUT_30_COLOR + amdgpu_crtc->crtc_offset, | ||
1759 | (amdgpu_crtc->lut_r[i] << 20) | | ||
1760 | (amdgpu_crtc->lut_g[i] << 10) | | ||
1761 | (amdgpu_crtc->lut_b[i] << 0)); | ||
1762 | } | ||
1763 | |||
1764 | WREG32(NI_DEGAMMA_CONTROL + amdgpu_crtc->crtc_offset, | ||
1765 | (NI_GRPH_DEGAMMA_MODE(NI_DEGAMMA_BYPASS) | | ||
1766 | NI_OVL_DEGAMMA_MODE(NI_DEGAMMA_BYPASS) | | ||
1767 | NI_ICON_DEGAMMA_MODE(NI_DEGAMMA_BYPASS) | | ||
1768 | NI_CURSOR_DEGAMMA_MODE(NI_DEGAMMA_BYPASS))); | ||
1769 | WREG32(NI_GAMUT_REMAP_CONTROL + amdgpu_crtc->crtc_offset, | ||
1770 | (NI_GRPH_GAMUT_REMAP_MODE(NI_GAMUT_REMAP_BYPASS) | | ||
1771 | NI_OVL_GAMUT_REMAP_MODE(NI_GAMUT_REMAP_BYPASS))); | ||
1772 | WREG32(NI_REGAMMA_CONTROL + amdgpu_crtc->crtc_offset, | ||
1773 | (NI_GRPH_REGAMMA_MODE(NI_REGAMMA_BYPASS) | | ||
1774 | NI_OVL_REGAMMA_MODE(NI_REGAMMA_BYPASS))); | ||
1775 | WREG32(NI_OUTPUT_CSC_CONTROL + amdgpu_crtc->crtc_offset, | ||
1776 | (NI_OUTPUT_CSC_GRPH_MODE(0) | | ||
1777 | NI_OUTPUT_CSC_OVL_MODE(NI_OUTPUT_CSC_BYPASS))); | ||
1778 | /* XXX match this to the depth of the crtc fmt block, move to modeset? */ | ||
1779 | WREG32(0x1a50 + amdgpu_crtc->crtc_offset, 0); | ||
1780 | |||
1781 | |||
1782 | } | ||
1783 | |||
1784 | static int dce_v6_0_pick_dig_encoder(struct drm_encoder *encoder) | ||
1785 | { | ||
1786 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
1787 | struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; | ||
1788 | |||
1789 | switch (amdgpu_encoder->encoder_id) { | ||
1790 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: | ||
1791 | if (dig->linkb) | ||
1792 | return 1; | ||
1793 | else | ||
1794 | return 0; | ||
1795 | break; | ||
1796 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: | ||
1797 | if (dig->linkb) | ||
1798 | return 3; | ||
1799 | else | ||
1800 | return 2; | ||
1801 | break; | ||
1802 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: | ||
1803 | if (dig->linkb) | ||
1804 | return 5; | ||
1805 | else | ||
1806 | return 4; | ||
1807 | break; | ||
1808 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3: | ||
1809 | return 6; | ||
1810 | break; | ||
1811 | default: | ||
1812 | DRM_ERROR("invalid encoder_id: 0x%x\n", amdgpu_encoder->encoder_id); | ||
1813 | return 0; | ||
1814 | } | ||
1815 | } | ||
1816 | |||
1817 | /** | ||
1818 | * dce_v6_0_pick_pll - Allocate a PPLL for use by the crtc. | ||
1819 | * | ||
1820 | * @crtc: drm crtc | ||
1821 | * | ||
1822 | * Returns the PPLL (Pixel PLL) to be used by the crtc. For DP monitors | ||
1823 | * a single PPLL can be used for all DP crtcs/encoders. For non-DP | ||
1824 | * monitors a dedicated PPLL must be used. If a particular board has | ||
1825 | * an external DP PLL, return ATOM_PPLL_INVALID to skip PLL programming | ||
1826 | * as there is no need to program the PLL itself. If we are not able to | ||
1827 | * allocate a PLL, return ATOM_PPLL_INVALID to skip PLL programming to | ||
1828 | * avoid messing up an existing monitor. | ||
1829 | * | ||
1830 | * | ||
1831 | */ | ||
1832 | static u32 dce_v6_0_pick_pll(struct drm_crtc *crtc) | ||
1833 | { | ||
1834 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1835 | struct drm_device *dev = crtc->dev; | ||
1836 | struct amdgpu_device *adev = dev->dev_private; | ||
1837 | u32 pll_in_use; | ||
1838 | int pll; | ||
1839 | |||
1840 | if (ENCODER_MODE_IS_DP(amdgpu_atombios_encoder_get_encoder_mode(amdgpu_crtc->encoder))) { | ||
1841 | if (adev->clock.dp_extclk) | ||
1842 | /* skip PPLL programming if using ext clock */ | ||
1843 | return ATOM_PPLL_INVALID; | ||
1844 | else | ||
1845 | return ATOM_PPLL0; | ||
1846 | } else { | ||
1847 | /* use the same PPLL for all monitors with the same clock */ | ||
1848 | pll = amdgpu_pll_get_shared_nondp_ppll(crtc); | ||
1849 | if (pll != ATOM_PPLL_INVALID) | ||
1850 | return pll; | ||
1851 | } | ||
1852 | |||
1853 | /* PPLL1, and PPLL2 */ | ||
1854 | pll_in_use = amdgpu_pll_get_use_mask(crtc); | ||
1855 | if (!(pll_in_use & (1 << ATOM_PPLL2))) | ||
1856 | return ATOM_PPLL2; | ||
1857 | if (!(pll_in_use & (1 << ATOM_PPLL1))) | ||
1858 | return ATOM_PPLL1; | ||
1859 | DRM_ERROR("unable to allocate a PPLL\n"); | ||
1860 | return ATOM_PPLL_INVALID; | ||
1861 | } | ||
1862 | |||
1863 | static void dce_v6_0_lock_cursor(struct drm_crtc *crtc, bool lock) | ||
1864 | { | ||
1865 | struct amdgpu_device *adev = crtc->dev->dev_private; | ||
1866 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1867 | uint32_t cur_lock; | ||
1868 | |||
1869 | cur_lock = RREG32(EVERGREEN_CUR_UPDATE + amdgpu_crtc->crtc_offset); | ||
1870 | if (lock) | ||
1871 | cur_lock |= EVERGREEN_CURSOR_UPDATE_LOCK; | ||
1872 | else | ||
1873 | cur_lock &= ~EVERGREEN_CURSOR_UPDATE_LOCK; | ||
1874 | WREG32(EVERGREEN_CUR_UPDATE + amdgpu_crtc->crtc_offset, cur_lock); | ||
1875 | } | ||
1876 | |||
1877 | static void dce_v6_0_hide_cursor(struct drm_crtc *crtc) | ||
1878 | { | ||
1879 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1880 | struct amdgpu_device *adev = crtc->dev->dev_private; | ||
1881 | |||
1882 | WREG32_IDX(EVERGREEN_CUR_CONTROL + amdgpu_crtc->crtc_offset, | ||
1883 | EVERGREEN_CURSOR_MODE(EVERGREEN_CURSOR_24_8_PRE_MULT) | | ||
1884 | EVERGREEN_CURSOR_URGENT_CONTROL(EVERGREEN_CURSOR_URGENT_1_2)); | ||
1885 | |||
1886 | |||
1887 | } | ||
1888 | |||
1889 | static void dce_v6_0_show_cursor(struct drm_crtc *crtc) | ||
1890 | { | ||
1891 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1892 | struct amdgpu_device *adev = crtc->dev->dev_private; | ||
1893 | |||
1894 | WREG32(EVERGREEN_CUR_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
1895 | upper_32_bits(amdgpu_crtc->cursor_addr)); | ||
1896 | WREG32(EVERGREEN_CUR_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
1897 | lower_32_bits(amdgpu_crtc->cursor_addr)); | ||
1898 | |||
1899 | WREG32_IDX(EVERGREEN_CUR_CONTROL + amdgpu_crtc->crtc_offset, | ||
1900 | EVERGREEN_CURSOR_EN | | ||
1901 | EVERGREEN_CURSOR_MODE(EVERGREEN_CURSOR_24_8_PRE_MULT) | | ||
1902 | EVERGREEN_CURSOR_URGENT_CONTROL(EVERGREEN_CURSOR_URGENT_1_2)); | ||
1903 | |||
1904 | } | ||
1905 | |||
1906 | static int dce_v6_0_cursor_move_locked(struct drm_crtc *crtc, | ||
1907 | int x, int y) | ||
1908 | { | ||
1909 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1910 | struct amdgpu_device *adev = crtc->dev->dev_private; | ||
1911 | int xorigin = 0, yorigin = 0; | ||
1912 | |||
1913 | int w = amdgpu_crtc->cursor_width; | ||
1914 | |||
1915 | /* avivo cursor are offset into the total surface */ | ||
1916 | x += crtc->x; | ||
1917 | y += crtc->y; | ||
1918 | DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y); | ||
1919 | |||
1920 | if (x < 0) { | ||
1921 | xorigin = min(-x, amdgpu_crtc->max_cursor_width - 1); | ||
1922 | x = 0; | ||
1923 | } | ||
1924 | if (y < 0) { | ||
1925 | yorigin = min(-y, amdgpu_crtc->max_cursor_height - 1); | ||
1926 | y = 0; | ||
1927 | } | ||
1928 | |||
1929 | WREG32(EVERGREEN_CUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); | ||
1930 | WREG32(EVERGREEN_CUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); | ||
1931 | WREG32(EVERGREEN_CUR_SIZE + amdgpu_crtc->crtc_offset, | ||
1932 | ((w - 1) << 16) | (amdgpu_crtc->cursor_height - 1)); | ||
1933 | |||
1934 | amdgpu_crtc->cursor_x = x; | ||
1935 | amdgpu_crtc->cursor_y = y; | ||
1936 | return 0; | ||
1937 | } | ||
1938 | |||
1939 | static int dce_v6_0_crtc_cursor_move(struct drm_crtc *crtc, | ||
1940 | int x, int y) | ||
1941 | { | ||
1942 | int ret; | ||
1943 | |||
1944 | dce_v6_0_lock_cursor(crtc, true); | ||
1945 | ret = dce_v6_0_cursor_move_locked(crtc, x, y); | ||
1946 | dce_v6_0_lock_cursor(crtc, false); | ||
1947 | |||
1948 | return ret; | ||
1949 | } | ||
1950 | |||
1951 | static int dce_v6_0_crtc_cursor_set2(struct drm_crtc *crtc, | ||
1952 | struct drm_file *file_priv, | ||
1953 | uint32_t handle, | ||
1954 | uint32_t width, | ||
1955 | uint32_t height, | ||
1956 | int32_t hot_x, | ||
1957 | int32_t hot_y) | ||
1958 | { | ||
1959 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
1960 | struct drm_gem_object *obj; | ||
1961 | struct amdgpu_bo *aobj; | ||
1962 | int ret; | ||
1963 | |||
1964 | if (!handle) { | ||
1965 | /* turn off cursor */ | ||
1966 | dce_v6_0_hide_cursor(crtc); | ||
1967 | obj = NULL; | ||
1968 | goto unpin; | ||
1969 | } | ||
1970 | |||
1971 | if ((width > amdgpu_crtc->max_cursor_width) || | ||
1972 | (height > amdgpu_crtc->max_cursor_height)) { | ||
1973 | DRM_ERROR("bad cursor width or height %d x %d\n", width, height); | ||
1974 | return -EINVAL; | ||
1975 | } | ||
1976 | |||
1977 | obj = drm_gem_object_lookup(file_priv, handle); | ||
1978 | if (!obj) { | ||
1979 | DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id); | ||
1980 | return -ENOENT; | ||
1981 | } | ||
1982 | |||
1983 | aobj = gem_to_amdgpu_bo(obj); | ||
1984 | ret = amdgpu_bo_reserve(aobj, false); | ||
1985 | if (ret != 0) { | ||
1986 | drm_gem_object_unreference_unlocked(obj); | ||
1987 | return ret; | ||
1988 | } | ||
1989 | |||
1990 | ret = amdgpu_bo_pin(aobj, AMDGPU_GEM_DOMAIN_VRAM, &amdgpu_crtc->cursor_addr); | ||
1991 | amdgpu_bo_unreserve(aobj); | ||
1992 | if (ret) { | ||
1993 | DRM_ERROR("Failed to pin new cursor BO (%d)\n", ret); | ||
1994 | drm_gem_object_unreference_unlocked(obj); | ||
1995 | return ret; | ||
1996 | } | ||
1997 | |||
1998 | amdgpu_crtc->cursor_width = width; | ||
1999 | amdgpu_crtc->cursor_height = height; | ||
2000 | |||
2001 | dce_v6_0_lock_cursor(crtc, true); | ||
2002 | |||
2003 | if (hot_x != amdgpu_crtc->cursor_hot_x || | ||
2004 | hot_y != amdgpu_crtc->cursor_hot_y) { | ||
2005 | int x, y; | ||
2006 | |||
2007 | x = amdgpu_crtc->cursor_x + amdgpu_crtc->cursor_hot_x - hot_x; | ||
2008 | y = amdgpu_crtc->cursor_y + amdgpu_crtc->cursor_hot_y - hot_y; | ||
2009 | |||
2010 | dce_v6_0_cursor_move_locked(crtc, x, y); | ||
2011 | |||
2012 | amdgpu_crtc->cursor_hot_x = hot_x; | ||
2013 | amdgpu_crtc->cursor_hot_y = hot_y; | ||
2014 | } | ||
2015 | |||
2016 | dce_v6_0_show_cursor(crtc); | ||
2017 | dce_v6_0_lock_cursor(crtc, false); | ||
2018 | |||
2019 | unpin: | ||
2020 | if (amdgpu_crtc->cursor_bo) { | ||
2021 | struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); | ||
2022 | ret = amdgpu_bo_reserve(aobj, false); | ||
2023 | if (likely(ret == 0)) { | ||
2024 | amdgpu_bo_unpin(aobj); | ||
2025 | amdgpu_bo_unreserve(aobj); | ||
2026 | } | ||
2027 | drm_gem_object_unreference_unlocked(amdgpu_crtc->cursor_bo); | ||
2028 | } | ||
2029 | |||
2030 | amdgpu_crtc->cursor_bo = obj; | ||
2031 | return 0; | ||
2032 | } | ||
2033 | |||
2034 | static void dce_v6_0_cursor_reset(struct drm_crtc *crtc) | ||
2035 | { | ||
2036 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2037 | |||
2038 | if (amdgpu_crtc->cursor_bo) { | ||
2039 | dce_v6_0_lock_cursor(crtc, true); | ||
2040 | |||
2041 | dce_v6_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x, | ||
2042 | amdgpu_crtc->cursor_y); | ||
2043 | |||
2044 | dce_v6_0_show_cursor(crtc); | ||
2045 | |||
2046 | dce_v6_0_lock_cursor(crtc, false); | ||
2047 | } | ||
2048 | } | ||
2049 | |||
2050 | static int dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | ||
2051 | u16 *blue, uint32_t size) | ||
2052 | { | ||
2053 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2054 | int i; | ||
2055 | |||
2056 | /* userspace palettes are always correct as is */ | ||
2057 | for (i = 0; i < size; i++) { | ||
2058 | amdgpu_crtc->lut_r[i] = red[i] >> 6; | ||
2059 | amdgpu_crtc->lut_g[i] = green[i] >> 6; | ||
2060 | amdgpu_crtc->lut_b[i] = blue[i] >> 6; | ||
2061 | } | ||
2062 | dce_v6_0_crtc_load_lut(crtc); | ||
2063 | |||
2064 | return 0; | ||
2065 | } | ||
2066 | |||
2067 | static void dce_v6_0_crtc_destroy(struct drm_crtc *crtc) | ||
2068 | { | ||
2069 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2070 | |||
2071 | drm_crtc_cleanup(crtc); | ||
2072 | kfree(amdgpu_crtc); | ||
2073 | } | ||
2074 | |||
2075 | static const struct drm_crtc_funcs dce_v6_0_crtc_funcs = { | ||
2076 | .cursor_set2 = dce_v6_0_crtc_cursor_set2, | ||
2077 | .cursor_move = dce_v6_0_crtc_cursor_move, | ||
2078 | .gamma_set = dce_v6_0_crtc_gamma_set, | ||
2079 | .set_config = amdgpu_crtc_set_config, | ||
2080 | .destroy = dce_v6_0_crtc_destroy, | ||
2081 | .page_flip_target = amdgpu_crtc_page_flip_target, | ||
2082 | }; | ||
2083 | |||
2084 | static void dce_v6_0_crtc_dpms(struct drm_crtc *crtc, int mode) | ||
2085 | { | ||
2086 | struct drm_device *dev = crtc->dev; | ||
2087 | struct amdgpu_device *adev = dev->dev_private; | ||
2088 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2089 | unsigned type; | ||
2090 | |||
2091 | switch (mode) { | ||
2092 | case DRM_MODE_DPMS_ON: | ||
2093 | amdgpu_crtc->enabled = true; | ||
2094 | amdgpu_atombios_crtc_enable(crtc, ATOM_ENABLE); | ||
2095 | amdgpu_atombios_crtc_blank(crtc, ATOM_DISABLE); | ||
2096 | /* Make sure VBLANK and PFLIP interrupts are still enabled */ | ||
2097 | type = amdgpu_crtc_idx_to_irq_type(adev, amdgpu_crtc->crtc_id); | ||
2098 | amdgpu_irq_update(adev, &adev->crtc_irq, type); | ||
2099 | amdgpu_irq_update(adev, &adev->pageflip_irq, type); | ||
2100 | drm_vblank_post_modeset(dev, amdgpu_crtc->crtc_id); | ||
2101 | dce_v6_0_crtc_load_lut(crtc); | ||
2102 | break; | ||
2103 | case DRM_MODE_DPMS_STANDBY: | ||
2104 | case DRM_MODE_DPMS_SUSPEND: | ||
2105 | case DRM_MODE_DPMS_OFF: | ||
2106 | drm_vblank_pre_modeset(dev, amdgpu_crtc->crtc_id); | ||
2107 | if (amdgpu_crtc->enabled) | ||
2108 | amdgpu_atombios_crtc_blank(crtc, ATOM_ENABLE); | ||
2109 | amdgpu_atombios_crtc_enable(crtc, ATOM_DISABLE); | ||
2110 | amdgpu_crtc->enabled = false; | ||
2111 | break; | ||
2112 | } | ||
2113 | /* adjust pm to dpms */ | ||
2114 | amdgpu_pm_compute_clocks(adev); | ||
2115 | } | ||
2116 | |||
2117 | static void dce_v6_0_crtc_prepare(struct drm_crtc *crtc) | ||
2118 | { | ||
2119 | /* disable crtc pair power gating before programming */ | ||
2120 | amdgpu_atombios_crtc_powergate(crtc, ATOM_DISABLE); | ||
2121 | amdgpu_atombios_crtc_lock(crtc, ATOM_ENABLE); | ||
2122 | dce_v6_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); | ||
2123 | } | ||
2124 | |||
2125 | static void dce_v6_0_crtc_commit(struct drm_crtc *crtc) | ||
2126 | { | ||
2127 | dce_v6_0_crtc_dpms(crtc, DRM_MODE_DPMS_ON); | ||
2128 | amdgpu_atombios_crtc_lock(crtc, ATOM_DISABLE); | ||
2129 | } | ||
2130 | |||
2131 | static void dce_v6_0_crtc_disable(struct drm_crtc *crtc) | ||
2132 | { | ||
2133 | |||
2134 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2135 | struct drm_device *dev = crtc->dev; | ||
2136 | struct amdgpu_device *adev = dev->dev_private; | ||
2137 | struct amdgpu_atom_ss ss; | ||
2138 | int i; | ||
2139 | |||
2140 | dce_v6_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); | ||
2141 | if (crtc->primary->fb) { | ||
2142 | int r; | ||
2143 | struct amdgpu_framebuffer *amdgpu_fb; | ||
2144 | struct amdgpu_bo *rbo; | ||
2145 | |||
2146 | amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb); | ||
2147 | rbo = gem_to_amdgpu_bo(amdgpu_fb->obj); | ||
2148 | r = amdgpu_bo_reserve(rbo, false); | ||
2149 | if (unlikely(r)) | ||
2150 | DRM_ERROR("failed to reserve rbo before unpin\n"); | ||
2151 | else { | ||
2152 | amdgpu_bo_unpin(rbo); | ||
2153 | amdgpu_bo_unreserve(rbo); | ||
2154 | } | ||
2155 | } | ||
2156 | /* disable the GRPH */ | ||
2157 | dce_v6_0_grph_enable(crtc, false); | ||
2158 | |||
2159 | amdgpu_atombios_crtc_powergate(crtc, ATOM_ENABLE); | ||
2160 | |||
2161 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
2162 | if (adev->mode_info.crtcs[i] && | ||
2163 | adev->mode_info.crtcs[i]->enabled && | ||
2164 | i != amdgpu_crtc->crtc_id && | ||
2165 | amdgpu_crtc->pll_id == adev->mode_info.crtcs[i]->pll_id) { | ||
2166 | /* one other crtc is using this pll don't turn | ||
2167 | * off the pll | ||
2168 | */ | ||
2169 | goto done; | ||
2170 | } | ||
2171 | } | ||
2172 | |||
2173 | switch (amdgpu_crtc->pll_id) { | ||
2174 | case ATOM_PPLL1: | ||
2175 | case ATOM_PPLL2: | ||
2176 | /* disable the ppll */ | ||
2177 | amdgpu_atombios_crtc_program_pll(crtc, amdgpu_crtc->crtc_id, amdgpu_crtc->pll_id, | ||
2178 | 0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss); | ||
2179 | break; | ||
2180 | default: | ||
2181 | break; | ||
2182 | } | ||
2183 | done: | ||
2184 | amdgpu_crtc->pll_id = ATOM_PPLL_INVALID; | ||
2185 | amdgpu_crtc->adjusted_clock = 0; | ||
2186 | amdgpu_crtc->encoder = NULL; | ||
2187 | amdgpu_crtc->connector = NULL; | ||
2188 | } | ||
2189 | |||
2190 | static int dce_v6_0_crtc_mode_set(struct drm_crtc *crtc, | ||
2191 | struct drm_display_mode *mode, | ||
2192 | struct drm_display_mode *adjusted_mode, | ||
2193 | int x, int y, struct drm_framebuffer *old_fb) | ||
2194 | { | ||
2195 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2196 | |||
2197 | if (!amdgpu_crtc->adjusted_clock) | ||
2198 | return -EINVAL; | ||
2199 | |||
2200 | amdgpu_atombios_crtc_set_pll(crtc, adjusted_mode); | ||
2201 | amdgpu_atombios_crtc_set_dtd_timing(crtc, adjusted_mode); | ||
2202 | dce_v6_0_crtc_do_set_base(crtc, old_fb, x, y, 0); | ||
2203 | amdgpu_atombios_crtc_overscan_setup(crtc, mode, adjusted_mode); | ||
2204 | amdgpu_atombios_crtc_scaler_setup(crtc); | ||
2205 | dce_v6_0_cursor_reset(crtc); | ||
2206 | /* update the hw version fpr dpm */ | ||
2207 | amdgpu_crtc->hw_mode = *adjusted_mode; | ||
2208 | |||
2209 | return 0; | ||
2210 | } | ||
2211 | |||
2212 | static bool dce_v6_0_crtc_mode_fixup(struct drm_crtc *crtc, | ||
2213 | const struct drm_display_mode *mode, | ||
2214 | struct drm_display_mode *adjusted_mode) | ||
2215 | { | ||
2216 | |||
2217 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2218 | struct drm_device *dev = crtc->dev; | ||
2219 | struct drm_encoder *encoder; | ||
2220 | |||
2221 | /* assign the encoder to the amdgpu crtc to avoid repeated lookups later */ | ||
2222 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | ||
2223 | if (encoder->crtc == crtc) { | ||
2224 | amdgpu_crtc->encoder = encoder; | ||
2225 | amdgpu_crtc->connector = amdgpu_get_connector_for_encoder(encoder); | ||
2226 | break; | ||
2227 | } | ||
2228 | } | ||
2229 | if ((amdgpu_crtc->encoder == NULL) || (amdgpu_crtc->connector == NULL)) { | ||
2230 | amdgpu_crtc->encoder = NULL; | ||
2231 | amdgpu_crtc->connector = NULL; | ||
2232 | return false; | ||
2233 | } | ||
2234 | if (!amdgpu_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode)) | ||
2235 | return false; | ||
2236 | if (amdgpu_atombios_crtc_prepare_pll(crtc, adjusted_mode)) | ||
2237 | return false; | ||
2238 | /* pick pll */ | ||
2239 | amdgpu_crtc->pll_id = dce_v6_0_pick_pll(crtc); | ||
2240 | /* if we can't get a PPLL for a non-DP encoder, fail */ | ||
2241 | if ((amdgpu_crtc->pll_id == ATOM_PPLL_INVALID) && | ||
2242 | !ENCODER_MODE_IS_DP(amdgpu_atombios_encoder_get_encoder_mode(amdgpu_crtc->encoder))) | ||
2243 | return false; | ||
2244 | |||
2245 | return true; | ||
2246 | } | ||
2247 | |||
2248 | static int dce_v6_0_crtc_set_base(struct drm_crtc *crtc, int x, int y, | ||
2249 | struct drm_framebuffer *old_fb) | ||
2250 | { | ||
2251 | return dce_v6_0_crtc_do_set_base(crtc, old_fb, x, y, 0); | ||
2252 | } | ||
2253 | |||
2254 | static int dce_v6_0_crtc_set_base_atomic(struct drm_crtc *crtc, | ||
2255 | struct drm_framebuffer *fb, | ||
2256 | int x, int y, enum mode_set_atomic state) | ||
2257 | { | ||
2258 | return dce_v6_0_crtc_do_set_base(crtc, fb, x, y, 1); | ||
2259 | } | ||
2260 | |||
2261 | static const struct drm_crtc_helper_funcs dce_v6_0_crtc_helper_funcs = { | ||
2262 | .dpms = dce_v6_0_crtc_dpms, | ||
2263 | .mode_fixup = dce_v6_0_crtc_mode_fixup, | ||
2264 | .mode_set = dce_v6_0_crtc_mode_set, | ||
2265 | .mode_set_base = dce_v6_0_crtc_set_base, | ||
2266 | .mode_set_base_atomic = dce_v6_0_crtc_set_base_atomic, | ||
2267 | .prepare = dce_v6_0_crtc_prepare, | ||
2268 | .commit = dce_v6_0_crtc_commit, | ||
2269 | .load_lut = dce_v6_0_crtc_load_lut, | ||
2270 | .disable = dce_v6_0_crtc_disable, | ||
2271 | }; | ||
2272 | |||
2273 | static int dce_v6_0_crtc_init(struct amdgpu_device *adev, int index) | ||
2274 | { | ||
2275 | struct amdgpu_crtc *amdgpu_crtc; | ||
2276 | int i; | ||
2277 | |||
2278 | amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) + | ||
2279 | (AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL); | ||
2280 | if (amdgpu_crtc == NULL) | ||
2281 | return -ENOMEM; | ||
2282 | |||
2283 | drm_crtc_init(adev->ddev, &amdgpu_crtc->base, &dce_v6_0_crtc_funcs); | ||
2284 | |||
2285 | drm_mode_crtc_set_gamma_size(&amdgpu_crtc->base, 256); | ||
2286 | amdgpu_crtc->crtc_id = index; | ||
2287 | adev->mode_info.crtcs[index] = amdgpu_crtc; | ||
2288 | |||
2289 | amdgpu_crtc->max_cursor_width = CURSOR_WIDTH; | ||
2290 | amdgpu_crtc->max_cursor_height = CURSOR_HEIGHT; | ||
2291 | adev->ddev->mode_config.cursor_width = amdgpu_crtc->max_cursor_width; | ||
2292 | adev->ddev->mode_config.cursor_height = amdgpu_crtc->max_cursor_height; | ||
2293 | |||
2294 | for (i = 0; i < 256; i++) { | ||
2295 | amdgpu_crtc->lut_r[i] = i << 2; | ||
2296 | amdgpu_crtc->lut_g[i] = i << 2; | ||
2297 | amdgpu_crtc->lut_b[i] = i << 2; | ||
2298 | } | ||
2299 | |||
2300 | amdgpu_crtc->crtc_offset = crtc_offsets[amdgpu_crtc->crtc_id]; | ||
2301 | |||
2302 | amdgpu_crtc->pll_id = ATOM_PPLL_INVALID; | ||
2303 | amdgpu_crtc->adjusted_clock = 0; | ||
2304 | amdgpu_crtc->encoder = NULL; | ||
2305 | amdgpu_crtc->connector = NULL; | ||
2306 | drm_crtc_helper_add(&amdgpu_crtc->base, &dce_v6_0_crtc_helper_funcs); | ||
2307 | |||
2308 | return 0; | ||
2309 | } | ||
2310 | |||
2311 | static int dce_v6_0_early_init(void *handle) | ||
2312 | { | ||
2313 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2314 | |||
2315 | adev->audio_endpt_rreg = &dce_v6_0_audio_endpt_rreg; | ||
2316 | adev->audio_endpt_wreg = &dce_v6_0_audio_endpt_wreg; | ||
2317 | |||
2318 | dce_v6_0_set_display_funcs(adev); | ||
2319 | dce_v6_0_set_irq_funcs(adev); | ||
2320 | |||
2321 | switch (adev->asic_type) { | ||
2322 | case CHIP_TAHITI: | ||
2323 | case CHIP_PITCAIRN: | ||
2324 | case CHIP_VERDE: | ||
2325 | adev->mode_info.num_crtc = 6; | ||
2326 | adev->mode_info.num_hpd = 6; | ||
2327 | adev->mode_info.num_dig = 6; | ||
2328 | break; | ||
2329 | case CHIP_OLAND: | ||
2330 | adev->mode_info.num_crtc = 2; | ||
2331 | adev->mode_info.num_hpd = 2; | ||
2332 | adev->mode_info.num_dig = 2; | ||
2333 | break; | ||
2334 | default: | ||
2335 | /* FIXME: not supported yet */ | ||
2336 | return -EINVAL; | ||
2337 | } | ||
2338 | |||
2339 | return 0; | ||
2340 | } | ||
2341 | |||
2342 | static int dce_v6_0_sw_init(void *handle) | ||
2343 | { | ||
2344 | int r, i; | ||
2345 | bool ret; | ||
2346 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2347 | |||
2348 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
2349 | r = amdgpu_irq_add_id(adev, i + 1, &adev->crtc_irq); | ||
2350 | if (r) | ||
2351 | return r; | ||
2352 | } | ||
2353 | |||
2354 | for (i = 8; i < 20; i += 2) { | ||
2355 | r = amdgpu_irq_add_id(adev, i, &adev->pageflip_irq); | ||
2356 | if (r) | ||
2357 | return r; | ||
2358 | } | ||
2359 | |||
2360 | /* HPD hotplug */ | ||
2361 | r = amdgpu_irq_add_id(adev, 42, &adev->hpd_irq); | ||
2362 | if (r) | ||
2363 | return r; | ||
2364 | |||
2365 | adev->mode_info.mode_config_initialized = true; | ||
2366 | |||
2367 | adev->ddev->mode_config.funcs = &amdgpu_mode_funcs; | ||
2368 | |||
2369 | adev->ddev->mode_config.async_page_flip = true; | ||
2370 | |||
2371 | adev->ddev->mode_config.max_width = 16384; | ||
2372 | adev->ddev->mode_config.max_height = 16384; | ||
2373 | |||
2374 | adev->ddev->mode_config.preferred_depth = 24; | ||
2375 | adev->ddev->mode_config.prefer_shadow = 1; | ||
2376 | |||
2377 | adev->ddev->mode_config.fb_base = adev->mc.aper_base; | ||
2378 | |||
2379 | r = amdgpu_modeset_create_props(adev); | ||
2380 | if (r) | ||
2381 | return r; | ||
2382 | |||
2383 | adev->ddev->mode_config.max_width = 16384; | ||
2384 | adev->ddev->mode_config.max_height = 16384; | ||
2385 | |||
2386 | /* allocate crtcs */ | ||
2387 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
2388 | r = dce_v6_0_crtc_init(adev, i); | ||
2389 | if (r) | ||
2390 | return r; | ||
2391 | } | ||
2392 | |||
2393 | ret = amdgpu_atombios_get_connector_info_from_object_table(adev); | ||
2394 | if (ret) | ||
2395 | amdgpu_print_display_setup(adev->ddev); | ||
2396 | else | ||
2397 | return -EINVAL; | ||
2398 | |||
2399 | /* setup afmt */ | ||
2400 | dce_v6_0_afmt_init(adev); | ||
2401 | |||
2402 | r = dce_v6_0_audio_init(adev); | ||
2403 | if (r) | ||
2404 | return r; | ||
2405 | |||
2406 | drm_kms_helper_poll_init(adev->ddev); | ||
2407 | |||
2408 | return r; | ||
2409 | } | ||
2410 | |||
2411 | static int dce_v6_0_sw_fini(void *handle) | ||
2412 | { | ||
2413 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2414 | |||
2415 | kfree(adev->mode_info.bios_hardcoded_edid); | ||
2416 | |||
2417 | drm_kms_helper_poll_fini(adev->ddev); | ||
2418 | |||
2419 | dce_v6_0_audio_fini(adev); | ||
2420 | |||
2421 | dce_v6_0_afmt_fini(adev); | ||
2422 | |||
2423 | drm_mode_config_cleanup(adev->ddev); | ||
2424 | adev->mode_info.mode_config_initialized = false; | ||
2425 | |||
2426 | return 0; | ||
2427 | } | ||
2428 | |||
2429 | static int dce_v6_0_hw_init(void *handle) | ||
2430 | { | ||
2431 | int i; | ||
2432 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2433 | |||
2434 | /* init dig PHYs, disp eng pll */ | ||
2435 | amdgpu_atombios_encoder_init_dig(adev); | ||
2436 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); | ||
2437 | |||
2438 | /* initialize hpd */ | ||
2439 | dce_v6_0_hpd_init(adev); | ||
2440 | |||
2441 | for (i = 0; i < adev->mode_info.audio.num_pins; i++) { | ||
2442 | dce_v6_0_audio_enable(adev, &adev->mode_info.audio.pin[i], false); | ||
2443 | } | ||
2444 | |||
2445 | dce_v6_0_pageflip_interrupt_init(adev); | ||
2446 | |||
2447 | return 0; | ||
2448 | } | ||
2449 | |||
2450 | static int dce_v6_0_hw_fini(void *handle) | ||
2451 | { | ||
2452 | int i; | ||
2453 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2454 | |||
2455 | dce_v6_0_hpd_fini(adev); | ||
2456 | |||
2457 | for (i = 0; i < adev->mode_info.audio.num_pins; i++) { | ||
2458 | dce_v6_0_audio_enable(adev, &adev->mode_info.audio.pin[i], false); | ||
2459 | } | ||
2460 | |||
2461 | dce_v6_0_pageflip_interrupt_fini(adev); | ||
2462 | |||
2463 | return 0; | ||
2464 | } | ||
2465 | |||
2466 | static int dce_v6_0_suspend(void *handle) | ||
2467 | { | ||
2468 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2469 | |||
2470 | amdgpu_atombios_scratch_regs_save(adev); | ||
2471 | |||
2472 | return dce_v6_0_hw_fini(handle); | ||
2473 | } | ||
2474 | |||
2475 | static int dce_v6_0_resume(void *handle) | ||
2476 | { | ||
2477 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2478 | int ret; | ||
2479 | |||
2480 | ret = dce_v6_0_hw_init(handle); | ||
2481 | |||
2482 | amdgpu_atombios_scratch_regs_restore(adev); | ||
2483 | |||
2484 | /* turn on the BL */ | ||
2485 | if (adev->mode_info.bl_encoder) { | ||
2486 | u8 bl_level = amdgpu_display_backlight_get_level(adev, | ||
2487 | adev->mode_info.bl_encoder); | ||
2488 | amdgpu_display_backlight_set_level(adev, adev->mode_info.bl_encoder, | ||
2489 | bl_level); | ||
2490 | } | ||
2491 | |||
2492 | return ret; | ||
2493 | } | ||
2494 | |||
2495 | static bool dce_v6_0_is_idle(void *handle) | ||
2496 | { | ||
2497 | return true; | ||
2498 | } | ||
2499 | |||
2500 | static int dce_v6_0_wait_for_idle(void *handle) | ||
2501 | { | ||
2502 | return 0; | ||
2503 | } | ||
2504 | |||
2505 | static int dce_v6_0_soft_reset(void *handle) | ||
2506 | { | ||
2507 | DRM_INFO("xxxx: dce_v6_0_soft_reset --- no impl!!\n"); | ||
2508 | return 0; | ||
2509 | } | ||
2510 | |||
2511 | static void dce_v6_0_set_crtc_vblank_interrupt_state(struct amdgpu_device *adev, | ||
2512 | int crtc, | ||
2513 | enum amdgpu_interrupt_state state) | ||
2514 | { | ||
2515 | u32 reg_block, interrupt_mask; | ||
2516 | |||
2517 | if (crtc >= adev->mode_info.num_crtc) { | ||
2518 | DRM_DEBUG("invalid crtc %d\n", crtc); | ||
2519 | return; | ||
2520 | } | ||
2521 | |||
2522 | switch (crtc) { | ||
2523 | case 0: | ||
2524 | reg_block = SI_CRTC0_REGISTER_OFFSET; | ||
2525 | break; | ||
2526 | case 1: | ||
2527 | reg_block = SI_CRTC1_REGISTER_OFFSET; | ||
2528 | break; | ||
2529 | case 2: | ||
2530 | reg_block = SI_CRTC2_REGISTER_OFFSET; | ||
2531 | break; | ||
2532 | case 3: | ||
2533 | reg_block = SI_CRTC3_REGISTER_OFFSET; | ||
2534 | break; | ||
2535 | case 4: | ||
2536 | reg_block = SI_CRTC4_REGISTER_OFFSET; | ||
2537 | break; | ||
2538 | case 5: | ||
2539 | reg_block = SI_CRTC5_REGISTER_OFFSET; | ||
2540 | break; | ||
2541 | default: | ||
2542 | DRM_DEBUG("invalid crtc %d\n", crtc); | ||
2543 | return; | ||
2544 | } | ||
2545 | |||
2546 | switch (state) { | ||
2547 | case AMDGPU_IRQ_STATE_DISABLE: | ||
2548 | interrupt_mask = RREG32(INT_MASK + reg_block); | ||
2549 | interrupt_mask &= ~VBLANK_INT_MASK; | ||
2550 | WREG32(INT_MASK + reg_block, interrupt_mask); | ||
2551 | break; | ||
2552 | case AMDGPU_IRQ_STATE_ENABLE: | ||
2553 | interrupt_mask = RREG32(INT_MASK + reg_block); | ||
2554 | interrupt_mask |= VBLANK_INT_MASK; | ||
2555 | WREG32(INT_MASK + reg_block, interrupt_mask); | ||
2556 | break; | ||
2557 | default: | ||
2558 | break; | ||
2559 | } | ||
2560 | } | ||
2561 | |||
2562 | static void dce_v6_0_set_crtc_vline_interrupt_state(struct amdgpu_device *adev, | ||
2563 | int crtc, | ||
2564 | enum amdgpu_interrupt_state state) | ||
2565 | { | ||
2566 | |||
2567 | } | ||
2568 | |||
2569 | static int dce_v6_0_set_hpd_interrupt_state(struct amdgpu_device *adev, | ||
2570 | struct amdgpu_irq_src *src, | ||
2571 | unsigned type, | ||
2572 | enum amdgpu_interrupt_state state) | ||
2573 | { | ||
2574 | u32 dc_hpd_int_cntl_reg, dc_hpd_int_cntl; | ||
2575 | |||
2576 | switch (type) { | ||
2577 | case AMDGPU_HPD_1: | ||
2578 | dc_hpd_int_cntl_reg = DC_HPD1_INT_CONTROL; | ||
2579 | break; | ||
2580 | case AMDGPU_HPD_2: | ||
2581 | dc_hpd_int_cntl_reg = DC_HPD2_INT_CONTROL; | ||
2582 | break; | ||
2583 | case AMDGPU_HPD_3: | ||
2584 | dc_hpd_int_cntl_reg = DC_HPD3_INT_CONTROL; | ||
2585 | break; | ||
2586 | case AMDGPU_HPD_4: | ||
2587 | dc_hpd_int_cntl_reg = DC_HPD4_INT_CONTROL; | ||
2588 | break; | ||
2589 | case AMDGPU_HPD_5: | ||
2590 | dc_hpd_int_cntl_reg = DC_HPD5_INT_CONTROL; | ||
2591 | break; | ||
2592 | case AMDGPU_HPD_6: | ||
2593 | dc_hpd_int_cntl_reg = DC_HPD6_INT_CONTROL; | ||
2594 | break; | ||
2595 | default: | ||
2596 | DRM_DEBUG("invalid hdp %d\n", type); | ||
2597 | return 0; | ||
2598 | } | ||
2599 | |||
2600 | switch (state) { | ||
2601 | case AMDGPU_IRQ_STATE_DISABLE: | ||
2602 | dc_hpd_int_cntl = RREG32(dc_hpd_int_cntl_reg); | ||
2603 | dc_hpd_int_cntl &= ~(DC_HPDx_INT_EN | DC_HPDx_RX_INT_EN); | ||
2604 | WREG32(dc_hpd_int_cntl_reg, dc_hpd_int_cntl); | ||
2605 | break; | ||
2606 | case AMDGPU_IRQ_STATE_ENABLE: | ||
2607 | dc_hpd_int_cntl = RREG32(dc_hpd_int_cntl_reg); | ||
2608 | dc_hpd_int_cntl |= (DC_HPDx_INT_EN | DC_HPDx_RX_INT_EN); | ||
2609 | WREG32(dc_hpd_int_cntl_reg, dc_hpd_int_cntl); | ||
2610 | break; | ||
2611 | default: | ||
2612 | break; | ||
2613 | } | ||
2614 | |||
2615 | return 0; | ||
2616 | } | ||
2617 | |||
2618 | static int dce_v6_0_set_crtc_interrupt_state(struct amdgpu_device *adev, | ||
2619 | struct amdgpu_irq_src *src, | ||
2620 | unsigned type, | ||
2621 | enum amdgpu_interrupt_state state) | ||
2622 | { | ||
2623 | switch (type) { | ||
2624 | case AMDGPU_CRTC_IRQ_VBLANK1: | ||
2625 | dce_v6_0_set_crtc_vblank_interrupt_state(adev, 0, state); | ||
2626 | break; | ||
2627 | case AMDGPU_CRTC_IRQ_VBLANK2: | ||
2628 | dce_v6_0_set_crtc_vblank_interrupt_state(adev, 1, state); | ||
2629 | break; | ||
2630 | case AMDGPU_CRTC_IRQ_VBLANK3: | ||
2631 | dce_v6_0_set_crtc_vblank_interrupt_state(adev, 2, state); | ||
2632 | break; | ||
2633 | case AMDGPU_CRTC_IRQ_VBLANK4: | ||
2634 | dce_v6_0_set_crtc_vblank_interrupt_state(adev, 3, state); | ||
2635 | break; | ||
2636 | case AMDGPU_CRTC_IRQ_VBLANK5: | ||
2637 | dce_v6_0_set_crtc_vblank_interrupt_state(adev, 4, state); | ||
2638 | break; | ||
2639 | case AMDGPU_CRTC_IRQ_VBLANK6: | ||
2640 | dce_v6_0_set_crtc_vblank_interrupt_state(adev, 5, state); | ||
2641 | break; | ||
2642 | case AMDGPU_CRTC_IRQ_VLINE1: | ||
2643 | dce_v6_0_set_crtc_vline_interrupt_state(adev, 0, state); | ||
2644 | break; | ||
2645 | case AMDGPU_CRTC_IRQ_VLINE2: | ||
2646 | dce_v6_0_set_crtc_vline_interrupt_state(adev, 1, state); | ||
2647 | break; | ||
2648 | case AMDGPU_CRTC_IRQ_VLINE3: | ||
2649 | dce_v6_0_set_crtc_vline_interrupt_state(adev, 2, state); | ||
2650 | break; | ||
2651 | case AMDGPU_CRTC_IRQ_VLINE4: | ||
2652 | dce_v6_0_set_crtc_vline_interrupt_state(adev, 3, state); | ||
2653 | break; | ||
2654 | case AMDGPU_CRTC_IRQ_VLINE5: | ||
2655 | dce_v6_0_set_crtc_vline_interrupt_state(adev, 4, state); | ||
2656 | break; | ||
2657 | case AMDGPU_CRTC_IRQ_VLINE6: | ||
2658 | dce_v6_0_set_crtc_vline_interrupt_state(adev, 5, state); | ||
2659 | break; | ||
2660 | default: | ||
2661 | break; | ||
2662 | } | ||
2663 | return 0; | ||
2664 | } | ||
2665 | |||
2666 | static int dce_v6_0_crtc_irq(struct amdgpu_device *adev, | ||
2667 | struct amdgpu_irq_src *source, | ||
2668 | struct amdgpu_iv_entry *entry) | ||
2669 | { | ||
2670 | unsigned crtc = entry->src_id - 1; | ||
2671 | uint32_t disp_int = RREG32(interrupt_status_offsets[crtc].reg); | ||
2672 | unsigned irq_type = amdgpu_crtc_idx_to_irq_type(adev, crtc); | ||
2673 | |||
2674 | switch (entry->src_data) { | ||
2675 | case 0: /* vblank */ | ||
2676 | if (disp_int & interrupt_status_offsets[crtc].vblank) | ||
2677 | WREG32(VBLANK_STATUS + crtc_offsets[crtc], VBLANK_ACK); | ||
2678 | else | ||
2679 | DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); | ||
2680 | |||
2681 | if (amdgpu_irq_enabled(adev, source, irq_type)) { | ||
2682 | drm_handle_vblank(adev->ddev, crtc); | ||
2683 | } | ||
2684 | DRM_DEBUG("IH: D%d vblank\n", crtc + 1); | ||
2685 | break; | ||
2686 | case 1: /* vline */ | ||
2687 | if (disp_int & interrupt_status_offsets[crtc].vline) | ||
2688 | WREG32(VLINE_STATUS + crtc_offsets[crtc], VLINE_ACK); | ||
2689 | else | ||
2690 | DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); | ||
2691 | |||
2692 | DRM_DEBUG("IH: D%d vline\n", crtc + 1); | ||
2693 | break; | ||
2694 | default: | ||
2695 | DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data); | ||
2696 | break; | ||
2697 | } | ||
2698 | |||
2699 | return 0; | ||
2700 | } | ||
2701 | |||
2702 | static int dce_v6_0_set_pageflip_interrupt_state(struct amdgpu_device *adev, | ||
2703 | struct amdgpu_irq_src *src, | ||
2704 | unsigned type, | ||
2705 | enum amdgpu_interrupt_state state) | ||
2706 | { | ||
2707 | u32 reg; | ||
2708 | |||
2709 | if (type >= adev->mode_info.num_crtc) { | ||
2710 | DRM_ERROR("invalid pageflip crtc %d\n", type); | ||
2711 | return -EINVAL; | ||
2712 | } | ||
2713 | |||
2714 | reg = RREG32(GRPH_INT_CONTROL + crtc_offsets[type]); | ||
2715 | if (state == AMDGPU_IRQ_STATE_DISABLE) | ||
2716 | WREG32(GRPH_INT_CONTROL + crtc_offsets[type], | ||
2717 | reg & ~GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK); | ||
2718 | else | ||
2719 | WREG32(GRPH_INT_CONTROL + crtc_offsets[type], | ||
2720 | reg | GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK); | ||
2721 | |||
2722 | return 0; | ||
2723 | } | ||
2724 | |||
2725 | static int dce_v6_0_pageflip_irq(struct amdgpu_device *adev, | ||
2726 | struct amdgpu_irq_src *source, | ||
2727 | struct amdgpu_iv_entry *entry) | ||
2728 | { | ||
2729 | unsigned long flags; | ||
2730 | unsigned crtc_id; | ||
2731 | struct amdgpu_crtc *amdgpu_crtc; | ||
2732 | struct amdgpu_flip_work *works; | ||
2733 | |||
2734 | crtc_id = (entry->src_id - 8) >> 1; | ||
2735 | amdgpu_crtc = adev->mode_info.crtcs[crtc_id]; | ||
2736 | |||
2737 | if (crtc_id >= adev->mode_info.num_crtc) { | ||
2738 | DRM_ERROR("invalid pageflip crtc %d\n", crtc_id); | ||
2739 | return -EINVAL; | ||
2740 | } | ||
2741 | |||
2742 | if (RREG32(GRPH_INT_STATUS + crtc_offsets[crtc_id]) & | ||
2743 | GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_OCCURRED_MASK) | ||
2744 | WREG32(GRPH_INT_STATUS + crtc_offsets[crtc_id], | ||
2745 | GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK); | ||
2746 | |||
2747 | /* IRQ could occur when in initial stage */ | ||
2748 | if (amdgpu_crtc == NULL) | ||
2749 | return 0; | ||
2750 | |||
2751 | spin_lock_irqsave(&adev->ddev->event_lock, flags); | ||
2752 | works = amdgpu_crtc->pflip_works; | ||
2753 | if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_SUBMITTED){ | ||
2754 | DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d != " | ||
2755 | "AMDGPU_FLIP_SUBMITTED(%d)\n", | ||
2756 | amdgpu_crtc->pflip_status, | ||
2757 | AMDGPU_FLIP_SUBMITTED); | ||
2758 | spin_unlock_irqrestore(&adev->ddev->event_lock, flags); | ||
2759 | return 0; | ||
2760 | } | ||
2761 | |||
2762 | /* page flip completed. clean up */ | ||
2763 | amdgpu_crtc->pflip_status = AMDGPU_FLIP_NONE; | ||
2764 | amdgpu_crtc->pflip_works = NULL; | ||
2765 | |||
2766 | /* wakeup usersapce */ | ||
2767 | if (works->event) | ||
2768 | drm_crtc_send_vblank_event(&amdgpu_crtc->base, works->event); | ||
2769 | |||
2770 | spin_unlock_irqrestore(&adev->ddev->event_lock, flags); | ||
2771 | |||
2772 | drm_crtc_vblank_put(&amdgpu_crtc->base); | ||
2773 | schedule_work(&works->unpin_work); | ||
2774 | |||
2775 | return 0; | ||
2776 | } | ||
2777 | |||
2778 | static int dce_v6_0_hpd_irq(struct amdgpu_device *adev, | ||
2779 | struct amdgpu_irq_src *source, | ||
2780 | struct amdgpu_iv_entry *entry) | ||
2781 | { | ||
2782 | uint32_t disp_int, mask, int_control, tmp; | ||
2783 | unsigned hpd; | ||
2784 | |||
2785 | if (entry->src_data > 6) { | ||
2786 | DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data); | ||
2787 | return 0; | ||
2788 | } | ||
2789 | |||
2790 | hpd = entry->src_data; | ||
2791 | disp_int = RREG32(interrupt_status_offsets[hpd].reg); | ||
2792 | mask = interrupt_status_offsets[hpd].hpd; | ||
2793 | int_control = hpd_int_control_offsets[hpd]; | ||
2794 | |||
2795 | if (disp_int & mask) { | ||
2796 | tmp = RREG32(int_control); | ||
2797 | tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK; | ||
2798 | WREG32(int_control, tmp); | ||
2799 | schedule_work(&adev->hotplug_work); | ||
2800 | DRM_INFO("IH: HPD%d\n", hpd + 1); | ||
2801 | } | ||
2802 | |||
2803 | return 0; | ||
2804 | |||
2805 | } | ||
2806 | |||
2807 | static int dce_v6_0_set_clockgating_state(void *handle, | ||
2808 | enum amd_clockgating_state state) | ||
2809 | { | ||
2810 | return 0; | ||
2811 | } | ||
2812 | |||
2813 | static int dce_v6_0_set_powergating_state(void *handle, | ||
2814 | enum amd_powergating_state state) | ||
2815 | { | ||
2816 | return 0; | ||
2817 | } | ||
2818 | |||
2819 | const struct amd_ip_funcs dce_v6_0_ip_funcs = { | ||
2820 | .name = "dce_v6_0", | ||
2821 | .early_init = dce_v6_0_early_init, | ||
2822 | .late_init = NULL, | ||
2823 | .sw_init = dce_v6_0_sw_init, | ||
2824 | .sw_fini = dce_v6_0_sw_fini, | ||
2825 | .hw_init = dce_v6_0_hw_init, | ||
2826 | .hw_fini = dce_v6_0_hw_fini, | ||
2827 | .suspend = dce_v6_0_suspend, | ||
2828 | .resume = dce_v6_0_resume, | ||
2829 | .is_idle = dce_v6_0_is_idle, | ||
2830 | .wait_for_idle = dce_v6_0_wait_for_idle, | ||
2831 | .soft_reset = dce_v6_0_soft_reset, | ||
2832 | .set_clockgating_state = dce_v6_0_set_clockgating_state, | ||
2833 | .set_powergating_state = dce_v6_0_set_powergating_state, | ||
2834 | }; | ||
2835 | |||
2836 | static void | ||
2837 | dce_v6_0_encoder_mode_set(struct drm_encoder *encoder, | ||
2838 | struct drm_display_mode *mode, | ||
2839 | struct drm_display_mode *adjusted_mode) | ||
2840 | { | ||
2841 | |||
2842 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
2843 | |||
2844 | amdgpu_encoder->pixel_clock = adjusted_mode->clock; | ||
2845 | |||
2846 | /* need to call this here rather than in prepare() since we need some crtc info */ | ||
2847 | amdgpu_atombios_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); | ||
2848 | |||
2849 | /* set scaler clears this on some chips */ | ||
2850 | dce_v6_0_set_interleave(encoder->crtc, mode); | ||
2851 | |||
2852 | if (amdgpu_atombios_encoder_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) { | ||
2853 | dce_v6_0_afmt_enable(encoder, true); | ||
2854 | dce_v6_0_afmt_setmode(encoder, adjusted_mode); | ||
2855 | } | ||
2856 | } | ||
2857 | |||
2858 | static void dce_v6_0_encoder_prepare(struct drm_encoder *encoder) | ||
2859 | { | ||
2860 | |||
2861 | struct amdgpu_device *adev = encoder->dev->dev_private; | ||
2862 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
2863 | struct drm_connector *connector = amdgpu_get_connector_for_encoder(encoder); | ||
2864 | |||
2865 | if ((amdgpu_encoder->active_device & | ||
2866 | (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) || | ||
2867 | (amdgpu_encoder_get_dp_bridge_encoder_id(encoder) != | ||
2868 | ENCODER_OBJECT_ID_NONE)) { | ||
2869 | struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; | ||
2870 | if (dig) { | ||
2871 | dig->dig_encoder = dce_v6_0_pick_dig_encoder(encoder); | ||
2872 | if (amdgpu_encoder->active_device & ATOM_DEVICE_DFP_SUPPORT) | ||
2873 | dig->afmt = adev->mode_info.afmt[dig->dig_encoder]; | ||
2874 | } | ||
2875 | } | ||
2876 | |||
2877 | amdgpu_atombios_scratch_regs_lock(adev, true); | ||
2878 | |||
2879 | if (connector) { | ||
2880 | struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); | ||
2881 | |||
2882 | /* select the clock/data port if it uses a router */ | ||
2883 | if (amdgpu_connector->router.cd_valid) | ||
2884 | amdgpu_i2c_router_select_cd_port(amdgpu_connector); | ||
2885 | |||
2886 | /* turn eDP panel on for mode set */ | ||
2887 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) | ||
2888 | amdgpu_atombios_encoder_set_edp_panel_power(connector, | ||
2889 | ATOM_TRANSMITTER_ACTION_POWER_ON); | ||
2890 | } | ||
2891 | |||
2892 | /* this is needed for the pll/ss setup to work correctly in some cases */ | ||
2893 | amdgpu_atombios_encoder_set_crtc_source(encoder); | ||
2894 | /* set up the FMT blocks */ | ||
2895 | dce_v6_0_program_fmt(encoder); | ||
2896 | } | ||
2897 | |||
2898 | static void dce_v6_0_encoder_commit(struct drm_encoder *encoder) | ||
2899 | { | ||
2900 | |||
2901 | struct drm_device *dev = encoder->dev; | ||
2902 | struct amdgpu_device *adev = dev->dev_private; | ||
2903 | |||
2904 | /* need to call this here as we need the crtc set up */ | ||
2905 | amdgpu_atombios_encoder_dpms(encoder, DRM_MODE_DPMS_ON); | ||
2906 | amdgpu_atombios_scratch_regs_lock(adev, false); | ||
2907 | } | ||
2908 | |||
2909 | static void dce_v6_0_encoder_disable(struct drm_encoder *encoder) | ||
2910 | { | ||
2911 | |||
2912 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
2913 | struct amdgpu_encoder_atom_dig *dig; | ||
2914 | |||
2915 | amdgpu_atombios_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); | ||
2916 | |||
2917 | if (amdgpu_atombios_encoder_is_digital(encoder)) { | ||
2918 | if (amdgpu_atombios_encoder_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) | ||
2919 | dce_v6_0_afmt_enable(encoder, false); | ||
2920 | dig = amdgpu_encoder->enc_priv; | ||
2921 | dig->dig_encoder = -1; | ||
2922 | } | ||
2923 | amdgpu_encoder->active_device = 0; | ||
2924 | } | ||
2925 | |||
2926 | /* these are handled by the primary encoders */ | ||
2927 | static void dce_v6_0_ext_prepare(struct drm_encoder *encoder) | ||
2928 | { | ||
2929 | |||
2930 | } | ||
2931 | |||
2932 | static void dce_v6_0_ext_commit(struct drm_encoder *encoder) | ||
2933 | { | ||
2934 | |||
2935 | } | ||
2936 | |||
2937 | static void | ||
2938 | dce_v6_0_ext_mode_set(struct drm_encoder *encoder, | ||
2939 | struct drm_display_mode *mode, | ||
2940 | struct drm_display_mode *adjusted_mode) | ||
2941 | { | ||
2942 | |||
2943 | } | ||
2944 | |||
2945 | static void dce_v6_0_ext_disable(struct drm_encoder *encoder) | ||
2946 | { | ||
2947 | |||
2948 | } | ||
2949 | |||
2950 | static void | ||
2951 | dce_v6_0_ext_dpms(struct drm_encoder *encoder, int mode) | ||
2952 | { | ||
2953 | |||
2954 | } | ||
2955 | |||
2956 | static bool dce_v6_0_ext_mode_fixup(struct drm_encoder *encoder, | ||
2957 | const struct drm_display_mode *mode, | ||
2958 | struct drm_display_mode *adjusted_mode) | ||
2959 | { | ||
2960 | return true; | ||
2961 | } | ||
2962 | |||
2963 | static const struct drm_encoder_helper_funcs dce_v6_0_ext_helper_funcs = { | ||
2964 | .dpms = dce_v6_0_ext_dpms, | ||
2965 | .mode_fixup = dce_v6_0_ext_mode_fixup, | ||
2966 | .prepare = dce_v6_0_ext_prepare, | ||
2967 | .mode_set = dce_v6_0_ext_mode_set, | ||
2968 | .commit = dce_v6_0_ext_commit, | ||
2969 | .disable = dce_v6_0_ext_disable, | ||
2970 | /* no detect for TMDS/LVDS yet */ | ||
2971 | }; | ||
2972 | |||
2973 | static const struct drm_encoder_helper_funcs dce_v6_0_dig_helper_funcs = { | ||
2974 | .dpms = amdgpu_atombios_encoder_dpms, | ||
2975 | .mode_fixup = amdgpu_atombios_encoder_mode_fixup, | ||
2976 | .prepare = dce_v6_0_encoder_prepare, | ||
2977 | .mode_set = dce_v6_0_encoder_mode_set, | ||
2978 | .commit = dce_v6_0_encoder_commit, | ||
2979 | .disable = dce_v6_0_encoder_disable, | ||
2980 | .detect = amdgpu_atombios_encoder_dig_detect, | ||
2981 | }; | ||
2982 | |||
2983 | static const struct drm_encoder_helper_funcs dce_v6_0_dac_helper_funcs = { | ||
2984 | .dpms = amdgpu_atombios_encoder_dpms, | ||
2985 | .mode_fixup = amdgpu_atombios_encoder_mode_fixup, | ||
2986 | .prepare = dce_v6_0_encoder_prepare, | ||
2987 | .mode_set = dce_v6_0_encoder_mode_set, | ||
2988 | .commit = dce_v6_0_encoder_commit, | ||
2989 | .detect = amdgpu_atombios_encoder_dac_detect, | ||
2990 | }; | ||
2991 | |||
2992 | static void dce_v6_0_encoder_destroy(struct drm_encoder *encoder) | ||
2993 | { | ||
2994 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
2995 | if (amdgpu_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) | ||
2996 | amdgpu_atombios_encoder_fini_backlight(amdgpu_encoder); | ||
2997 | kfree(amdgpu_encoder->enc_priv); | ||
2998 | drm_encoder_cleanup(encoder); | ||
2999 | kfree(amdgpu_encoder); | ||
3000 | } | ||
3001 | |||
3002 | static const struct drm_encoder_funcs dce_v6_0_encoder_funcs = { | ||
3003 | .destroy = dce_v6_0_encoder_destroy, | ||
3004 | }; | ||
3005 | |||
3006 | static void dce_v6_0_encoder_add(struct amdgpu_device *adev, | ||
3007 | uint32_t encoder_enum, | ||
3008 | uint32_t supported_device, | ||
3009 | u16 caps) | ||
3010 | { | ||
3011 | struct drm_device *dev = adev->ddev; | ||
3012 | struct drm_encoder *encoder; | ||
3013 | struct amdgpu_encoder *amdgpu_encoder; | ||
3014 | |||
3015 | /* see if we already added it */ | ||
3016 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | ||
3017 | amdgpu_encoder = to_amdgpu_encoder(encoder); | ||
3018 | if (amdgpu_encoder->encoder_enum == encoder_enum) { | ||
3019 | amdgpu_encoder->devices |= supported_device; | ||
3020 | return; | ||
3021 | } | ||
3022 | |||
3023 | } | ||
3024 | |||
3025 | /* add a new one */ | ||
3026 | amdgpu_encoder = kzalloc(sizeof(struct amdgpu_encoder), GFP_KERNEL); | ||
3027 | if (!amdgpu_encoder) | ||
3028 | return; | ||
3029 | |||
3030 | encoder = &amdgpu_encoder->base; | ||
3031 | switch (adev->mode_info.num_crtc) { | ||
3032 | case 1: | ||
3033 | encoder->possible_crtcs = 0x1; | ||
3034 | break; | ||
3035 | case 2: | ||
3036 | default: | ||
3037 | encoder->possible_crtcs = 0x3; | ||
3038 | break; | ||
3039 | case 4: | ||
3040 | encoder->possible_crtcs = 0xf; | ||
3041 | break; | ||
3042 | case 6: | ||
3043 | encoder->possible_crtcs = 0x3f; | ||
3044 | break; | ||
3045 | } | ||
3046 | |||
3047 | amdgpu_encoder->enc_priv = NULL; | ||
3048 | |||
3049 | amdgpu_encoder->encoder_enum = encoder_enum; | ||
3050 | amdgpu_encoder->encoder_id = (encoder_enum & OBJECT_ID_MASK) >> OBJECT_ID_SHIFT; | ||
3051 | amdgpu_encoder->devices = supported_device; | ||
3052 | amdgpu_encoder->rmx_type = RMX_OFF; | ||
3053 | amdgpu_encoder->underscan_type = UNDERSCAN_OFF; | ||
3054 | amdgpu_encoder->is_ext_encoder = false; | ||
3055 | amdgpu_encoder->caps = caps; | ||
3056 | |||
3057 | switch (amdgpu_encoder->encoder_id) { | ||
3058 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: | ||
3059 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: | ||
3060 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3061 | DRM_MODE_ENCODER_DAC, NULL); | ||
3062 | drm_encoder_helper_add(encoder, &dce_v6_0_dac_helper_funcs); | ||
3063 | break; | ||
3064 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: | ||
3065 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: | ||
3066 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: | ||
3067 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: | ||
3068 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3: | ||
3069 | if (amdgpu_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { | ||
3070 | amdgpu_encoder->rmx_type = RMX_FULL; | ||
3071 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3072 | DRM_MODE_ENCODER_LVDS, NULL); | ||
3073 | amdgpu_encoder->enc_priv = amdgpu_atombios_encoder_get_lcd_info(amdgpu_encoder); | ||
3074 | } else if (amdgpu_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) { | ||
3075 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3076 | DRM_MODE_ENCODER_DAC, NULL); | ||
3077 | amdgpu_encoder->enc_priv = amdgpu_atombios_encoder_get_dig_info(amdgpu_encoder); | ||
3078 | } else { | ||
3079 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3080 | DRM_MODE_ENCODER_TMDS, NULL); | ||
3081 | amdgpu_encoder->enc_priv = amdgpu_atombios_encoder_get_dig_info(amdgpu_encoder); | ||
3082 | } | ||
3083 | drm_encoder_helper_add(encoder, &dce_v6_0_dig_helper_funcs); | ||
3084 | break; | ||
3085 | case ENCODER_OBJECT_ID_SI170B: | ||
3086 | case ENCODER_OBJECT_ID_CH7303: | ||
3087 | case ENCODER_OBJECT_ID_EXTERNAL_SDVOA: | ||
3088 | case ENCODER_OBJECT_ID_EXTERNAL_SDVOB: | ||
3089 | case ENCODER_OBJECT_ID_TITFP513: | ||
3090 | case ENCODER_OBJECT_ID_VT1623: | ||
3091 | case ENCODER_OBJECT_ID_HDMI_SI1930: | ||
3092 | case ENCODER_OBJECT_ID_TRAVIS: | ||
3093 | case ENCODER_OBJECT_ID_NUTMEG: | ||
3094 | /* these are handled by the primary encoders */ | ||
3095 | amdgpu_encoder->is_ext_encoder = true; | ||
3096 | if (amdgpu_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) | ||
3097 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3098 | DRM_MODE_ENCODER_LVDS, NULL); | ||
3099 | else if (amdgpu_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) | ||
3100 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3101 | DRM_MODE_ENCODER_DAC, NULL); | ||
3102 | else | ||
3103 | drm_encoder_init(dev, encoder, &dce_v6_0_encoder_funcs, | ||
3104 | DRM_MODE_ENCODER_TMDS, NULL); | ||
3105 | drm_encoder_helper_add(encoder, &dce_v6_0_ext_helper_funcs); | ||
3106 | break; | ||
3107 | } | ||
3108 | } | ||
3109 | |||
3110 | static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { | ||
3111 | .set_vga_render_state = &dce_v6_0_set_vga_render_state, | ||
3112 | .bandwidth_update = &dce_v6_0_bandwidth_update, | ||
3113 | .vblank_get_counter = &dce_v6_0_vblank_get_counter, | ||
3114 | .vblank_wait = &dce_v6_0_vblank_wait, | ||
3115 | .is_display_hung = &dce_v6_0_is_display_hung, | ||
3116 | .backlight_set_level = &amdgpu_atombios_encoder_set_backlight_level, | ||
3117 | .backlight_get_level = &amdgpu_atombios_encoder_get_backlight_level, | ||
3118 | .hpd_sense = &dce_v6_0_hpd_sense, | ||
3119 | .hpd_set_polarity = &dce_v6_0_hpd_set_polarity, | ||
3120 | .hpd_get_gpio_reg = &dce_v6_0_hpd_get_gpio_reg, | ||
3121 | .page_flip = &dce_v6_0_page_flip, | ||
3122 | .page_flip_get_scanoutpos = &dce_v6_0_crtc_get_scanoutpos, | ||
3123 | .add_encoder = &dce_v6_0_encoder_add, | ||
3124 | .add_connector = &amdgpu_connector_add, | ||
3125 | .stop_mc_access = &dce_v6_0_stop_mc_access, | ||
3126 | .resume_mc_access = &dce_v6_0_resume_mc_access, | ||
3127 | }; | ||
3128 | |||
3129 | static void dce_v6_0_set_display_funcs(struct amdgpu_device *adev) | ||
3130 | { | ||
3131 | if (adev->mode_info.funcs == NULL) | ||
3132 | adev->mode_info.funcs = &dce_v6_0_display_funcs; | ||
3133 | } | ||
3134 | |||
3135 | static const struct amdgpu_irq_src_funcs dce_v6_0_crtc_irq_funcs = { | ||
3136 | .set = dce_v6_0_set_crtc_interrupt_state, | ||
3137 | .process = dce_v6_0_crtc_irq, | ||
3138 | }; | ||
3139 | |||
3140 | static const struct amdgpu_irq_src_funcs dce_v6_0_pageflip_irq_funcs = { | ||
3141 | .set = dce_v6_0_set_pageflip_interrupt_state, | ||
3142 | .process = dce_v6_0_pageflip_irq, | ||
3143 | }; | ||
3144 | |||
3145 | static const struct amdgpu_irq_src_funcs dce_v6_0_hpd_irq_funcs = { | ||
3146 | .set = dce_v6_0_set_hpd_interrupt_state, | ||
3147 | .process = dce_v6_0_hpd_irq, | ||
3148 | }; | ||
3149 | |||
3150 | static void dce_v6_0_set_irq_funcs(struct amdgpu_device *adev) | ||
3151 | { | ||
3152 | adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_LAST; | ||
3153 | adev->crtc_irq.funcs = &dce_v6_0_crtc_irq_funcs; | ||
3154 | |||
3155 | adev->pageflip_irq.num_types = AMDGPU_PAGEFLIP_IRQ_LAST; | ||
3156 | adev->pageflip_irq.funcs = &dce_v6_0_pageflip_irq_funcs; | ||
3157 | |||
3158 | adev->hpd_irq.num_types = AMDGPU_HPD_LAST; | ||
3159 | adev->hpd_irq.funcs = &dce_v6_0_hpd_irq_funcs; | ||
3160 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.h b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.h new file mode 100644 index 000000000000..6a5528105bb6 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __DCE_V6_0_H__ | ||
25 | #define __DCE_V6_0_H__ | ||
26 | |||
27 | extern const struct amd_ip_funcs dce_v6_0_ip_funcs; | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c new file mode 100644 index 000000000000..410b29c05671 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | |||
@@ -0,0 +1,3233 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #include <linux/firmware.h> | ||
24 | #include "amdgpu.h" | ||
25 | #include "amdgpu_ih.h" | ||
26 | #include "amdgpu_gfx.h" | ||
27 | #include "amdgpu_ucode.h" | ||
28 | #include "si/clearstate_si.h" | ||
29 | #include "si/sid.h" | ||
30 | |||
31 | #define GFX6_NUM_GFX_RINGS 1 | ||
32 | #define GFX6_NUM_COMPUTE_RINGS 2 | ||
33 | #define STATIC_PER_CU_PG_ENABLE (1 << 3) | ||
34 | #define DYN_PER_CU_PG_ENABLE (1 << 2) | ||
35 | #define RLC_SAVE_AND_RESTORE_STARTING_OFFSET 0x90 | ||
36 | #define RLC_CLEAR_STATE_DESCRIPTOR_OFFSET 0x3D | ||
37 | |||
38 | |||
39 | static void gfx_v6_0_set_ring_funcs(struct amdgpu_device *adev); | ||
40 | static void gfx_v6_0_set_irq_funcs(struct amdgpu_device *adev); | ||
41 | static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev); | ||
42 | |||
43 | MODULE_FIRMWARE("radeon/tahiti_pfp.bin"); | ||
44 | MODULE_FIRMWARE("radeon/tahiti_me.bin"); | ||
45 | MODULE_FIRMWARE("radeon/tahiti_ce.bin"); | ||
46 | MODULE_FIRMWARE("radeon/tahiti_rlc.bin"); | ||
47 | |||
48 | MODULE_FIRMWARE("radeon/pitcairn_pfp.bin"); | ||
49 | MODULE_FIRMWARE("radeon/pitcairn_me.bin"); | ||
50 | MODULE_FIRMWARE("radeon/pitcairn_ce.bin"); | ||
51 | MODULE_FIRMWARE("radeon/pitcairn_rlc.bin"); | ||
52 | |||
53 | MODULE_FIRMWARE("radeon/verde_pfp.bin"); | ||
54 | MODULE_FIRMWARE("radeon/verde_me.bin"); | ||
55 | MODULE_FIRMWARE("radeon/verde_ce.bin"); | ||
56 | MODULE_FIRMWARE("radeon/verde_rlc.bin"); | ||
57 | |||
58 | MODULE_FIRMWARE("radeon/oland_pfp.bin"); | ||
59 | MODULE_FIRMWARE("radeon/oland_me.bin"); | ||
60 | MODULE_FIRMWARE("radeon/oland_ce.bin"); | ||
61 | MODULE_FIRMWARE("radeon/oland_rlc.bin"); | ||
62 | |||
63 | MODULE_FIRMWARE("radeon/hainan_pfp.bin"); | ||
64 | MODULE_FIRMWARE("radeon/hainan_me.bin"); | ||
65 | MODULE_FIRMWARE("radeon/hainan_ce.bin"); | ||
66 | MODULE_FIRMWARE("radeon/hainan_rlc.bin"); | ||
67 | |||
68 | static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev); | ||
69 | static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev, volatile u32 *buffer); | ||
70 | //static void gfx_v6_0_init_cp_pg_table(struct amdgpu_device *adev); | ||
71 | static void gfx_v6_0_init_pg(struct amdgpu_device *adev); | ||
72 | |||
73 | |||
74 | static const u32 verde_rlc_save_restore_register_list[] = | ||
75 | { | ||
76 | (0x8000 << 16) | (0x98f4 >> 2), | ||
77 | 0x00000000, | ||
78 | (0x8040 << 16) | (0x98f4 >> 2), | ||
79 | 0x00000000, | ||
80 | (0x8000 << 16) | (0xe80 >> 2), | ||
81 | 0x00000000, | ||
82 | (0x8040 << 16) | (0xe80 >> 2), | ||
83 | 0x00000000, | ||
84 | (0x8000 << 16) | (0x89bc >> 2), | ||
85 | 0x00000000, | ||
86 | (0x8040 << 16) | (0x89bc >> 2), | ||
87 | 0x00000000, | ||
88 | (0x8000 << 16) | (0x8c1c >> 2), | ||
89 | 0x00000000, | ||
90 | (0x8040 << 16) | (0x8c1c >> 2), | ||
91 | 0x00000000, | ||
92 | (0x9c00 << 16) | (0x98f0 >> 2), | ||
93 | 0x00000000, | ||
94 | (0x9c00 << 16) | (0xe7c >> 2), | ||
95 | 0x00000000, | ||
96 | (0x8000 << 16) | (0x9148 >> 2), | ||
97 | 0x00000000, | ||
98 | (0x8040 << 16) | (0x9148 >> 2), | ||
99 | 0x00000000, | ||
100 | (0x9c00 << 16) | (0x9150 >> 2), | ||
101 | 0x00000000, | ||
102 | (0x9c00 << 16) | (0x897c >> 2), | ||
103 | 0x00000000, | ||
104 | (0x9c00 << 16) | (0x8d8c >> 2), | ||
105 | 0x00000000, | ||
106 | (0x9c00 << 16) | (0xac54 >> 2), | ||
107 | 0X00000000, | ||
108 | 0x3, | ||
109 | (0x9c00 << 16) | (0x98f8 >> 2), | ||
110 | 0x00000000, | ||
111 | (0x9c00 << 16) | (0x9910 >> 2), | ||
112 | 0x00000000, | ||
113 | (0x9c00 << 16) | (0x9914 >> 2), | ||
114 | 0x00000000, | ||
115 | (0x9c00 << 16) | (0x9918 >> 2), | ||
116 | 0x00000000, | ||
117 | (0x9c00 << 16) | (0x991c >> 2), | ||
118 | 0x00000000, | ||
119 | (0x9c00 << 16) | (0x9920 >> 2), | ||
120 | 0x00000000, | ||
121 | (0x9c00 << 16) | (0x9924 >> 2), | ||
122 | 0x00000000, | ||
123 | (0x9c00 << 16) | (0x9928 >> 2), | ||
124 | 0x00000000, | ||
125 | (0x9c00 << 16) | (0x992c >> 2), | ||
126 | 0x00000000, | ||
127 | (0x9c00 << 16) | (0x9930 >> 2), | ||
128 | 0x00000000, | ||
129 | (0x9c00 << 16) | (0x9934 >> 2), | ||
130 | 0x00000000, | ||
131 | (0x9c00 << 16) | (0x9938 >> 2), | ||
132 | 0x00000000, | ||
133 | (0x9c00 << 16) | (0x993c >> 2), | ||
134 | 0x00000000, | ||
135 | (0x9c00 << 16) | (0x9940 >> 2), | ||
136 | 0x00000000, | ||
137 | (0x9c00 << 16) | (0x9944 >> 2), | ||
138 | 0x00000000, | ||
139 | (0x9c00 << 16) | (0x9948 >> 2), | ||
140 | 0x00000000, | ||
141 | (0x9c00 << 16) | (0x994c >> 2), | ||
142 | 0x00000000, | ||
143 | (0x9c00 << 16) | (0x9950 >> 2), | ||
144 | 0x00000000, | ||
145 | (0x9c00 << 16) | (0x9954 >> 2), | ||
146 | 0x00000000, | ||
147 | (0x9c00 << 16) | (0x9958 >> 2), | ||
148 | 0x00000000, | ||
149 | (0x9c00 << 16) | (0x995c >> 2), | ||
150 | 0x00000000, | ||
151 | (0x9c00 << 16) | (0x9960 >> 2), | ||
152 | 0x00000000, | ||
153 | (0x9c00 << 16) | (0x9964 >> 2), | ||
154 | 0x00000000, | ||
155 | (0x9c00 << 16) | (0x9968 >> 2), | ||
156 | 0x00000000, | ||
157 | (0x9c00 << 16) | (0x996c >> 2), | ||
158 | 0x00000000, | ||
159 | (0x9c00 << 16) | (0x9970 >> 2), | ||
160 | 0x00000000, | ||
161 | (0x9c00 << 16) | (0x9974 >> 2), | ||
162 | 0x00000000, | ||
163 | (0x9c00 << 16) | (0x9978 >> 2), | ||
164 | 0x00000000, | ||
165 | (0x9c00 << 16) | (0x997c >> 2), | ||
166 | 0x00000000, | ||
167 | (0x9c00 << 16) | (0x9980 >> 2), | ||
168 | 0x00000000, | ||
169 | (0x9c00 << 16) | (0x9984 >> 2), | ||
170 | 0x00000000, | ||
171 | (0x9c00 << 16) | (0x9988 >> 2), | ||
172 | 0x00000000, | ||
173 | (0x9c00 << 16) | (0x998c >> 2), | ||
174 | 0x00000000, | ||
175 | (0x9c00 << 16) | (0x8c00 >> 2), | ||
176 | 0x00000000, | ||
177 | (0x9c00 << 16) | (0x8c14 >> 2), | ||
178 | 0x00000000, | ||
179 | (0x9c00 << 16) | (0x8c04 >> 2), | ||
180 | 0x00000000, | ||
181 | (0x9c00 << 16) | (0x8c08 >> 2), | ||
182 | 0x00000000, | ||
183 | (0x8000 << 16) | (0x9b7c >> 2), | ||
184 | 0x00000000, | ||
185 | (0x8040 << 16) | (0x9b7c >> 2), | ||
186 | 0x00000000, | ||
187 | (0x8000 << 16) | (0xe84 >> 2), | ||
188 | 0x00000000, | ||
189 | (0x8040 << 16) | (0xe84 >> 2), | ||
190 | 0x00000000, | ||
191 | (0x8000 << 16) | (0x89c0 >> 2), | ||
192 | 0x00000000, | ||
193 | (0x8040 << 16) | (0x89c0 >> 2), | ||
194 | 0x00000000, | ||
195 | (0x8000 << 16) | (0x914c >> 2), | ||
196 | 0x00000000, | ||
197 | (0x8040 << 16) | (0x914c >> 2), | ||
198 | 0x00000000, | ||
199 | (0x8000 << 16) | (0x8c20 >> 2), | ||
200 | 0x00000000, | ||
201 | (0x8040 << 16) | (0x8c20 >> 2), | ||
202 | 0x00000000, | ||
203 | (0x8000 << 16) | (0x9354 >> 2), | ||
204 | 0x00000000, | ||
205 | (0x8040 << 16) | (0x9354 >> 2), | ||
206 | 0x00000000, | ||
207 | (0x9c00 << 16) | (0x9060 >> 2), | ||
208 | 0x00000000, | ||
209 | (0x9c00 << 16) | (0x9364 >> 2), | ||
210 | 0x00000000, | ||
211 | (0x9c00 << 16) | (0x9100 >> 2), | ||
212 | 0x00000000, | ||
213 | (0x9c00 << 16) | (0x913c >> 2), | ||
214 | 0x00000000, | ||
215 | (0x8000 << 16) | (0x90e0 >> 2), | ||
216 | 0x00000000, | ||
217 | (0x8000 << 16) | (0x90e4 >> 2), | ||
218 | 0x00000000, | ||
219 | (0x8000 << 16) | (0x90e8 >> 2), | ||
220 | 0x00000000, | ||
221 | (0x8040 << 16) | (0x90e0 >> 2), | ||
222 | 0x00000000, | ||
223 | (0x8040 << 16) | (0x90e4 >> 2), | ||
224 | 0x00000000, | ||
225 | (0x8040 << 16) | (0x90e8 >> 2), | ||
226 | 0x00000000, | ||
227 | (0x9c00 << 16) | (0x8bcc >> 2), | ||
228 | 0x00000000, | ||
229 | (0x9c00 << 16) | (0x8b24 >> 2), | ||
230 | 0x00000000, | ||
231 | (0x9c00 << 16) | (0x88c4 >> 2), | ||
232 | 0x00000000, | ||
233 | (0x9c00 << 16) | (0x8e50 >> 2), | ||
234 | 0x00000000, | ||
235 | (0x9c00 << 16) | (0x8c0c >> 2), | ||
236 | 0x00000000, | ||
237 | (0x9c00 << 16) | (0x8e58 >> 2), | ||
238 | 0x00000000, | ||
239 | (0x9c00 << 16) | (0x8e5c >> 2), | ||
240 | 0x00000000, | ||
241 | (0x9c00 << 16) | (0x9508 >> 2), | ||
242 | 0x00000000, | ||
243 | (0x9c00 << 16) | (0x950c >> 2), | ||
244 | 0x00000000, | ||
245 | (0x9c00 << 16) | (0x9494 >> 2), | ||
246 | 0x00000000, | ||
247 | (0x9c00 << 16) | (0xac0c >> 2), | ||
248 | 0x00000000, | ||
249 | (0x9c00 << 16) | (0xac10 >> 2), | ||
250 | 0x00000000, | ||
251 | (0x9c00 << 16) | (0xac14 >> 2), | ||
252 | 0x00000000, | ||
253 | (0x9c00 << 16) | (0xae00 >> 2), | ||
254 | 0x00000000, | ||
255 | (0x9c00 << 16) | (0xac08 >> 2), | ||
256 | 0x00000000, | ||
257 | (0x9c00 << 16) | (0x88d4 >> 2), | ||
258 | 0x00000000, | ||
259 | (0x9c00 << 16) | (0x88c8 >> 2), | ||
260 | 0x00000000, | ||
261 | (0x9c00 << 16) | (0x88cc >> 2), | ||
262 | 0x00000000, | ||
263 | (0x9c00 << 16) | (0x89b0 >> 2), | ||
264 | 0x00000000, | ||
265 | (0x9c00 << 16) | (0x8b10 >> 2), | ||
266 | 0x00000000, | ||
267 | (0x9c00 << 16) | (0x8a14 >> 2), | ||
268 | 0x00000000, | ||
269 | (0x9c00 << 16) | (0x9830 >> 2), | ||
270 | 0x00000000, | ||
271 | (0x9c00 << 16) | (0x9834 >> 2), | ||
272 | 0x00000000, | ||
273 | (0x9c00 << 16) | (0x9838 >> 2), | ||
274 | 0x00000000, | ||
275 | (0x9c00 << 16) | (0x9a10 >> 2), | ||
276 | 0x00000000, | ||
277 | (0x8000 << 16) | (0x9870 >> 2), | ||
278 | 0x00000000, | ||
279 | (0x8000 << 16) | (0x9874 >> 2), | ||
280 | 0x00000000, | ||
281 | (0x8001 << 16) | (0x9870 >> 2), | ||
282 | 0x00000000, | ||
283 | (0x8001 << 16) | (0x9874 >> 2), | ||
284 | 0x00000000, | ||
285 | (0x8040 << 16) | (0x9870 >> 2), | ||
286 | 0x00000000, | ||
287 | (0x8040 << 16) | (0x9874 >> 2), | ||
288 | 0x00000000, | ||
289 | (0x8041 << 16) | (0x9870 >> 2), | ||
290 | 0x00000000, | ||
291 | (0x8041 << 16) | (0x9874 >> 2), | ||
292 | 0x00000000, | ||
293 | 0x00000000 | ||
294 | }; | ||
295 | |||
296 | static int gfx_v6_0_init_microcode(struct amdgpu_device *adev) | ||
297 | { | ||
298 | const char *chip_name; | ||
299 | char fw_name[30]; | ||
300 | int err; | ||
301 | const struct gfx_firmware_header_v1_0 *cp_hdr; | ||
302 | const struct rlc_firmware_header_v1_0 *rlc_hdr; | ||
303 | |||
304 | DRM_DEBUG("\n"); | ||
305 | |||
306 | switch (adev->asic_type) { | ||
307 | case CHIP_TAHITI: | ||
308 | chip_name = "tahiti"; | ||
309 | break; | ||
310 | case CHIP_PITCAIRN: | ||
311 | chip_name = "pitcairn"; | ||
312 | break; | ||
313 | case CHIP_VERDE: | ||
314 | chip_name = "verde"; | ||
315 | break; | ||
316 | case CHIP_OLAND: | ||
317 | chip_name = "oland"; | ||
318 | break; | ||
319 | case CHIP_HAINAN: | ||
320 | chip_name = "hainan"; | ||
321 | break; | ||
322 | default: BUG(); | ||
323 | } | ||
324 | |||
325 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); | ||
326 | err = request_firmware(&adev->gfx.pfp_fw, fw_name, adev->dev); | ||
327 | if (err) | ||
328 | goto out; | ||
329 | err = amdgpu_ucode_validate(adev->gfx.pfp_fw); | ||
330 | if (err) | ||
331 | goto out; | ||
332 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | ||
333 | adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | ||
334 | adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | ||
335 | |||
336 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); | ||
337 | err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev); | ||
338 | if (err) | ||
339 | goto out; | ||
340 | err = amdgpu_ucode_validate(adev->gfx.me_fw); | ||
341 | if (err) | ||
342 | goto out; | ||
343 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | ||
344 | adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | ||
345 | adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | ||
346 | |||
347 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); | ||
348 | err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev); | ||
349 | if (err) | ||
350 | goto out; | ||
351 | err = amdgpu_ucode_validate(adev->gfx.ce_fw); | ||
352 | if (err) | ||
353 | goto out; | ||
354 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | ||
355 | adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | ||
356 | adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | ||
357 | |||
358 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name); | ||
359 | err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev); | ||
360 | if (err) | ||
361 | goto out; | ||
362 | err = amdgpu_ucode_validate(adev->gfx.rlc_fw); | ||
363 | rlc_hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data; | ||
364 | adev->gfx.rlc_fw_version = le32_to_cpu(rlc_hdr->header.ucode_version); | ||
365 | adev->gfx.rlc_feature_version = le32_to_cpu(rlc_hdr->ucode_feature_version); | ||
366 | |||
367 | out: | ||
368 | if (err) { | ||
369 | printk(KERN_ERR | ||
370 | "gfx6: Failed to load firmware \"%s\"\n", | ||
371 | fw_name); | ||
372 | release_firmware(adev->gfx.pfp_fw); | ||
373 | adev->gfx.pfp_fw = NULL; | ||
374 | release_firmware(adev->gfx.me_fw); | ||
375 | adev->gfx.me_fw = NULL; | ||
376 | release_firmware(adev->gfx.ce_fw); | ||
377 | adev->gfx.ce_fw = NULL; | ||
378 | release_firmware(adev->gfx.rlc_fw); | ||
379 | adev->gfx.rlc_fw = NULL; | ||
380 | } | ||
381 | return err; | ||
382 | } | ||
383 | |||
384 | static void gfx_v6_0_tiling_mode_table_init(struct amdgpu_device *adev) | ||
385 | { | ||
386 | const u32 num_tile_mode_states = 32; | ||
387 | u32 reg_offset, gb_tile_moden, split_equal_to_row_size; | ||
388 | |||
389 | switch (adev->gfx.config.mem_row_size_in_kb) { | ||
390 | case 1: | ||
391 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB; | ||
392 | break; | ||
393 | case 2: | ||
394 | default: | ||
395 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB; | ||
396 | break; | ||
397 | case 4: | ||
398 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB; | ||
399 | break; | ||
400 | } | ||
401 | |||
402 | if (adev->asic_type == CHIP_VERDE || | ||
403 | adev->asic_type == CHIP_OLAND || | ||
404 | adev->asic_type == CHIP_HAINAN) { | ||
405 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { | ||
406 | switch (reg_offset) { | ||
407 | case 0: | ||
408 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
409 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
410 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
411 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
412 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
413 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
414 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
415 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
416 | break; | ||
417 | case 1: | ||
418 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
419 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
420 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
421 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | | ||
422 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
423 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
424 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
425 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
426 | break; | ||
427 | case 2: | ||
428 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
429 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
430 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
431 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
432 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
433 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
434 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
435 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
436 | break; | ||
437 | case 3: | ||
438 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
439 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
440 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
441 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | | ||
442 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
443 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
444 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
445 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
446 | break; | ||
447 | case 4: | ||
448 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | ||
449 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
450 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
451 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
452 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
453 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
454 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
455 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
456 | break; | ||
457 | case 5: | ||
458 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
459 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
460 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
461 | TILE_SPLIT(split_equal_to_row_size) | | ||
462 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
463 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
464 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
465 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
466 | break; | ||
467 | case 6: | ||
468 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
469 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
470 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
471 | TILE_SPLIT(split_equal_to_row_size) | | ||
472 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
473 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
474 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
475 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
476 | break; | ||
477 | case 7: | ||
478 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
479 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
480 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
481 | TILE_SPLIT(split_equal_to_row_size) | | ||
482 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
483 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
484 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
485 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
486 | break; | ||
487 | case 8: | ||
488 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | | ||
489 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
490 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
491 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
492 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
493 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
494 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
495 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
496 | break; | ||
497 | case 9: | ||
498 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | ||
499 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
500 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
501 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
502 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
503 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
504 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
505 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
506 | break; | ||
507 | case 10: | ||
508 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
509 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
510 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
511 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
512 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
513 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
514 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
515 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
516 | break; | ||
517 | case 11: | ||
518 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
519 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
520 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
521 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
522 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
523 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
524 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
525 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
526 | break; | ||
527 | case 12: | ||
528 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
529 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
530 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
531 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | ||
532 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
533 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
534 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
535 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
536 | break; | ||
537 | case 13: | ||
538 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | ||
539 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
540 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
541 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
542 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
543 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
544 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
545 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
546 | break; | ||
547 | case 14: | ||
548 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
549 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
550 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
551 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
552 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
553 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
554 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
555 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
556 | break; | ||
557 | case 15: | ||
558 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
559 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
560 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
561 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
562 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
563 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
564 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
565 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
566 | break; | ||
567 | case 16: | ||
568 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
569 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
570 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
571 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | ||
572 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
573 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
574 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
575 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
576 | break; | ||
577 | case 17: | ||
578 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
579 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
580 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | | ||
581 | TILE_SPLIT(split_equal_to_row_size) | | ||
582 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
583 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
584 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
585 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
586 | break; | ||
587 | case 21: | ||
588 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
589 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
590 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
591 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
592 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
593 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | | ||
594 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
595 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
596 | break; | ||
597 | case 22: | ||
598 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
599 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
600 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
601 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
602 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
603 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
604 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
605 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
606 | break; | ||
607 | case 23: | ||
608 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
609 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
610 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
611 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
612 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
613 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
614 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
615 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
616 | break; | ||
617 | case 24: | ||
618 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
619 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
620 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
621 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | ||
622 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
623 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
624 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
625 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
626 | break; | ||
627 | case 25: | ||
628 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
629 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
630 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
631 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | ||
632 | NUM_BANKS(ADDR_SURF_8_BANK) | | ||
633 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
634 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
635 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
636 | break; | ||
637 | default: | ||
638 | gb_tile_moden = 0; | ||
639 | break; | ||
640 | } | ||
641 | adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden; | ||
642 | WREG32(GB_TILE_MODE0 + reg_offset, gb_tile_moden); | ||
643 | } | ||
644 | } else if ((adev->asic_type == CHIP_TAHITI) || (adev->asic_type == CHIP_PITCAIRN)) { | ||
645 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { | ||
646 | switch (reg_offset) { | ||
647 | case 0: /* non-AA compressed depth or any compressed stencil */ | ||
648 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
649 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
650 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
651 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
652 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
653 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
654 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
655 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
656 | break; | ||
657 | case 1: /* 2xAA/4xAA compressed depth only */ | ||
658 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
659 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
660 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
661 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | | ||
662 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
663 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
664 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
665 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
666 | break; | ||
667 | case 2: /* 8xAA compressed depth only */ | ||
668 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
669 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
670 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
671 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
672 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
673 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
674 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
675 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
676 | break; | ||
677 | case 3: /* 2xAA/4xAA compressed depth with stencil (for depth buffer) */ | ||
678 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
679 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
680 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
681 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) | | ||
682 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
683 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
684 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
685 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
686 | break; | ||
687 | case 4: /* Maps w/ a dimension less than the 2D macro-tile dimensions (for mipmapped depth textures) */ | ||
688 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | ||
689 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
690 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
691 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
692 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
693 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
694 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
695 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
696 | break; | ||
697 | case 5: /* Uncompressed 16bpp depth - and stencil buffer allocated with it */ | ||
698 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
699 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
700 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
701 | TILE_SPLIT(split_equal_to_row_size) | | ||
702 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
703 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
704 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
705 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
706 | break; | ||
707 | case 6: /* Uncompressed 32bpp depth - and stencil buffer allocated with it */ | ||
708 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
709 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
710 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
711 | TILE_SPLIT(split_equal_to_row_size) | | ||
712 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
713 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
714 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
715 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
716 | break; | ||
717 | case 7: /* Uncompressed 8bpp stencil without depth (drivers typically do not use) */ | ||
718 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
719 | MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) | | ||
720 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
721 | TILE_SPLIT(split_equal_to_row_size) | | ||
722 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
723 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
724 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
725 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
726 | break; | ||
727 | case 8: /* 1D and 1D Array Surfaces */ | ||
728 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | | ||
729 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
730 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
731 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
732 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
733 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
734 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
735 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
736 | break; | ||
737 | case 9: /* Displayable maps. */ | ||
738 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | ||
739 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
740 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
741 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
742 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
743 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
744 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
745 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
746 | break; | ||
747 | case 10: /* Display 8bpp. */ | ||
748 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
749 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
750 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
751 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
752 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
753 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
754 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
755 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
756 | break; | ||
757 | case 11: /* Display 16bpp. */ | ||
758 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
759 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
760 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
761 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
762 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
763 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
764 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
765 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
766 | break; | ||
767 | case 12: /* Display 32bpp. */ | ||
768 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
769 | MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) | | ||
770 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
771 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | ||
772 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
773 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
774 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
775 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
776 | break; | ||
777 | case 13: /* Thin. */ | ||
778 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | | ||
779 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
780 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
781 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | | ||
782 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
783 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
784 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
785 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
786 | break; | ||
787 | case 14: /* Thin 8 bpp. */ | ||
788 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
789 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
790 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
791 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
792 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
793 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
794 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
795 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
796 | break; | ||
797 | case 15: /* Thin 16 bpp. */ | ||
798 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
799 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
800 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
801 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
802 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
803 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
804 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
805 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
806 | break; | ||
807 | case 16: /* Thin 32 bpp. */ | ||
808 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
809 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
810 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
811 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | ||
812 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
813 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
814 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
815 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
816 | break; | ||
817 | case 17: /* Thin 64 bpp. */ | ||
818 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
819 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
820 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
821 | TILE_SPLIT(split_equal_to_row_size) | | ||
822 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
823 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
824 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
825 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
826 | break; | ||
827 | case 21: /* 8 bpp PRT. */ | ||
828 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
829 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
830 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
831 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
832 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
833 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | | ||
834 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
835 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
836 | break; | ||
837 | case 22: /* 16 bpp PRT */ | ||
838 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
839 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
840 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
841 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
842 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
843 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
844 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | | ||
845 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4)); | ||
846 | break; | ||
847 | case 23: /* 32 bpp PRT */ | ||
848 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
849 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
850 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
851 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) | | ||
852 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
853 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
854 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | | ||
855 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
856 | break; | ||
857 | case 24: /* 64 bpp PRT */ | ||
858 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
859 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
860 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
861 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) | | ||
862 | NUM_BANKS(ADDR_SURF_16_BANK) | | ||
863 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
864 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
865 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2)); | ||
866 | break; | ||
867 | case 25: /* 128 bpp PRT */ | ||
868 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | | ||
869 | MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) | | ||
870 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | | ||
871 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) | | ||
872 | NUM_BANKS(ADDR_SURF_8_BANK) | | ||
873 | BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | | ||
874 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | | ||
875 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1)); | ||
876 | break; | ||
877 | default: | ||
878 | gb_tile_moden = 0; | ||
879 | break; | ||
880 | } | ||
881 | adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden; | ||
882 | WREG32(GB_TILE_MODE0 + reg_offset, gb_tile_moden); | ||
883 | } | ||
884 | } else{ | ||
885 | |||
886 | DRM_ERROR("unknown asic: 0x%x\n", adev->asic_type); | ||
887 | } | ||
888 | |||
889 | } | ||
890 | |||
891 | static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, | ||
892 | u32 sh_num, u32 instance) | ||
893 | { | ||
894 | u32 data; | ||
895 | |||
896 | if (instance == 0xffffffff) | ||
897 | data = INSTANCE_BROADCAST_WRITES; | ||
898 | else | ||
899 | data = INSTANCE_INDEX(instance); | ||
900 | |||
901 | if ((se_num == 0xffffffff) && (sh_num == 0xffffffff)) | ||
902 | data |= SH_BROADCAST_WRITES | SE_BROADCAST_WRITES; | ||
903 | else if (se_num == 0xffffffff) | ||
904 | data |= SE_BROADCAST_WRITES | SH_INDEX(sh_num); | ||
905 | else if (sh_num == 0xffffffff) | ||
906 | data |= SH_BROADCAST_WRITES | SE_INDEX(se_num); | ||
907 | else | ||
908 | data |= SH_INDEX(sh_num) | SE_INDEX(se_num); | ||
909 | WREG32(GRBM_GFX_INDEX, data); | ||
910 | } | ||
911 | |||
912 | static u32 gfx_v6_0_create_bitmask(u32 bit_width) | ||
913 | { | ||
914 | return (u32)(((u64)1 << bit_width) - 1); | ||
915 | } | ||
916 | |||
917 | static u32 gfx_v6_0_get_rb_disabled(struct amdgpu_device *adev, | ||
918 | u32 max_rb_num_per_se, | ||
919 | u32 sh_per_se) | ||
920 | { | ||
921 | u32 data, mask; | ||
922 | |||
923 | data = RREG32(CC_RB_BACKEND_DISABLE); | ||
924 | data &= BACKEND_DISABLE_MASK; | ||
925 | data |= RREG32(GC_USER_RB_BACKEND_DISABLE); | ||
926 | |||
927 | data >>= BACKEND_DISABLE_SHIFT; | ||
928 | |||
929 | mask = gfx_v6_0_create_bitmask(max_rb_num_per_se / sh_per_se); | ||
930 | |||
931 | return data & mask; | ||
932 | } | ||
933 | |||
934 | static void gfx_v6_0_setup_rb(struct amdgpu_device *adev, | ||
935 | u32 se_num, u32 sh_per_se, | ||
936 | u32 max_rb_num_per_se) | ||
937 | { | ||
938 | int i, j; | ||
939 | u32 data, mask; | ||
940 | u32 disabled_rbs = 0; | ||
941 | u32 enabled_rbs = 0; | ||
942 | |||
943 | mutex_lock(&adev->grbm_idx_mutex); | ||
944 | for (i = 0; i < se_num; i++) { | ||
945 | for (j = 0; j < sh_per_se; j++) { | ||
946 | gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff); | ||
947 | data = gfx_v6_0_get_rb_disabled(adev, max_rb_num_per_se, sh_per_se); | ||
948 | disabled_rbs |= data << ((i * sh_per_se + j) * TAHITI_RB_BITMAP_WIDTH_PER_SH); | ||
949 | } | ||
950 | } | ||
951 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
952 | mutex_unlock(&adev->grbm_idx_mutex); | ||
953 | |||
954 | mask = 1; | ||
955 | for (i = 0; i < max_rb_num_per_se * se_num; i++) { | ||
956 | if (!(disabled_rbs & mask)) | ||
957 | enabled_rbs |= mask; | ||
958 | mask <<= 1; | ||
959 | } | ||
960 | |||
961 | adev->gfx.config.backend_enable_mask = enabled_rbs; | ||
962 | adev->gfx.config.num_rbs = hweight32(enabled_rbs); | ||
963 | |||
964 | mutex_lock(&adev->grbm_idx_mutex); | ||
965 | for (i = 0; i < se_num; i++) { | ||
966 | gfx_v6_0_select_se_sh(adev, i, 0xffffffff, 0xffffffff); | ||
967 | data = 0; | ||
968 | for (j = 0; j < sh_per_se; j++) { | ||
969 | switch (enabled_rbs & 3) { | ||
970 | case 1: | ||
971 | data |= (RASTER_CONFIG_RB_MAP_0 << (i * sh_per_se + j) * 2); | ||
972 | break; | ||
973 | case 2: | ||
974 | data |= (RASTER_CONFIG_RB_MAP_3 << (i * sh_per_se + j) * 2); | ||
975 | break; | ||
976 | case 3: | ||
977 | default: | ||
978 | data |= (RASTER_CONFIG_RB_MAP_2 << (i * sh_per_se + j) * 2); | ||
979 | break; | ||
980 | } | ||
981 | enabled_rbs >>= 2; | ||
982 | } | ||
983 | WREG32(PA_SC_RASTER_CONFIG, data); | ||
984 | } | ||
985 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
986 | mutex_unlock(&adev->grbm_idx_mutex); | ||
987 | } | ||
988 | /* | ||
989 | static void gmc_v6_0_init_compute_vmid(struct amdgpu_device *adev) | ||
990 | { | ||
991 | } | ||
992 | */ | ||
993 | |||
994 | static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev, u32 cu_per_sh) | ||
995 | { | ||
996 | u32 data, mask; | ||
997 | |||
998 | data = RREG32(CC_GC_SHADER_ARRAY_CONFIG); | ||
999 | data &= INACTIVE_CUS_MASK; | ||
1000 | data |= RREG32(GC_USER_SHADER_ARRAY_CONFIG); | ||
1001 | |||
1002 | data >>= INACTIVE_CUS_SHIFT; | ||
1003 | |||
1004 | mask = gfx_v6_0_create_bitmask(cu_per_sh); | ||
1005 | |||
1006 | return ~data & mask; | ||
1007 | } | ||
1008 | |||
1009 | |||
1010 | static void gfx_v6_0_setup_spi(struct amdgpu_device *adev, | ||
1011 | u32 se_num, u32 sh_per_se, | ||
1012 | u32 cu_per_sh) | ||
1013 | { | ||
1014 | int i, j, k; | ||
1015 | u32 data, mask; | ||
1016 | u32 active_cu = 0; | ||
1017 | |||
1018 | mutex_lock(&adev->grbm_idx_mutex); | ||
1019 | for (i = 0; i < se_num; i++) { | ||
1020 | for (j = 0; j < sh_per_se; j++) { | ||
1021 | gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff); | ||
1022 | data = RREG32(SPI_STATIC_THREAD_MGMT_3); | ||
1023 | active_cu = gfx_v6_0_get_cu_enabled(adev, cu_per_sh); | ||
1024 | |||
1025 | mask = 1; | ||
1026 | for (k = 0; k < 16; k++) { | ||
1027 | mask <<= k; | ||
1028 | if (active_cu & mask) { | ||
1029 | data &= ~mask; | ||
1030 | WREG32(SPI_STATIC_THREAD_MGMT_3, data); | ||
1031 | break; | ||
1032 | } | ||
1033 | } | ||
1034 | } | ||
1035 | } | ||
1036 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
1037 | mutex_unlock(&adev->grbm_idx_mutex); | ||
1038 | } | ||
1039 | |||
1040 | static void gfx_v6_0_gpu_init(struct amdgpu_device *adev) | ||
1041 | { | ||
1042 | u32 gb_addr_config = 0; | ||
1043 | u32 mc_shared_chmap, mc_arb_ramcfg; | ||
1044 | u32 sx_debug_1; | ||
1045 | u32 hdp_host_path_cntl; | ||
1046 | u32 tmp; | ||
1047 | |||
1048 | switch (adev->asic_type) { | ||
1049 | case CHIP_TAHITI: | ||
1050 | adev->gfx.config.max_shader_engines = 2; | ||
1051 | adev->gfx.config.max_tile_pipes = 12; | ||
1052 | adev->gfx.config.max_cu_per_sh = 8; | ||
1053 | adev->gfx.config.max_sh_per_se = 2; | ||
1054 | adev->gfx.config.max_backends_per_se = 4; | ||
1055 | adev->gfx.config.max_texture_channel_caches = 12; | ||
1056 | adev->gfx.config.max_gprs = 256; | ||
1057 | adev->gfx.config.max_gs_threads = 32; | ||
1058 | adev->gfx.config.max_hw_contexts = 8; | ||
1059 | |||
1060 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | ||
1061 | adev->gfx.config.sc_prim_fifo_size_backend = 0x100; | ||
1062 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | ||
1063 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | ||
1064 | gb_addr_config = TAHITI_GB_ADDR_CONFIG_GOLDEN; | ||
1065 | break; | ||
1066 | case CHIP_PITCAIRN: | ||
1067 | adev->gfx.config.max_shader_engines = 2; | ||
1068 | adev->gfx.config.max_tile_pipes = 8; | ||
1069 | adev->gfx.config.max_cu_per_sh = 5; | ||
1070 | adev->gfx.config.max_sh_per_se = 2; | ||
1071 | adev->gfx.config.max_backends_per_se = 4; | ||
1072 | adev->gfx.config.max_texture_channel_caches = 8; | ||
1073 | adev->gfx.config.max_gprs = 256; | ||
1074 | adev->gfx.config.max_gs_threads = 32; | ||
1075 | adev->gfx.config.max_hw_contexts = 8; | ||
1076 | |||
1077 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | ||
1078 | adev->gfx.config.sc_prim_fifo_size_backend = 0x100; | ||
1079 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | ||
1080 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | ||
1081 | gb_addr_config = TAHITI_GB_ADDR_CONFIG_GOLDEN; | ||
1082 | break; | ||
1083 | |||
1084 | case CHIP_VERDE: | ||
1085 | adev->gfx.config.max_shader_engines = 1; | ||
1086 | adev->gfx.config.max_tile_pipes = 4; | ||
1087 | adev->gfx.config.max_cu_per_sh = 5; | ||
1088 | adev->gfx.config.max_sh_per_se = 2; | ||
1089 | adev->gfx.config.max_backends_per_se = 4; | ||
1090 | adev->gfx.config.max_texture_channel_caches = 4; | ||
1091 | adev->gfx.config.max_gprs = 256; | ||
1092 | adev->gfx.config.max_gs_threads = 32; | ||
1093 | adev->gfx.config.max_hw_contexts = 8; | ||
1094 | |||
1095 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | ||
1096 | adev->gfx.config.sc_prim_fifo_size_backend = 0x40; | ||
1097 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | ||
1098 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | ||
1099 | gb_addr_config = VERDE_GB_ADDR_CONFIG_GOLDEN; | ||
1100 | break; | ||
1101 | case CHIP_OLAND: | ||
1102 | adev->gfx.config.max_shader_engines = 1; | ||
1103 | adev->gfx.config.max_tile_pipes = 4; | ||
1104 | adev->gfx.config.max_cu_per_sh = 6; | ||
1105 | adev->gfx.config.max_sh_per_se = 1; | ||
1106 | adev->gfx.config.max_backends_per_se = 2; | ||
1107 | adev->gfx.config.max_texture_channel_caches = 4; | ||
1108 | adev->gfx.config.max_gprs = 256; | ||
1109 | adev->gfx.config.max_gs_threads = 16; | ||
1110 | adev->gfx.config.max_hw_contexts = 8; | ||
1111 | |||
1112 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | ||
1113 | adev->gfx.config.sc_prim_fifo_size_backend = 0x40; | ||
1114 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | ||
1115 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | ||
1116 | gb_addr_config = VERDE_GB_ADDR_CONFIG_GOLDEN; | ||
1117 | break; | ||
1118 | case CHIP_HAINAN: | ||
1119 | adev->gfx.config.max_shader_engines = 1; | ||
1120 | adev->gfx.config.max_tile_pipes = 4; | ||
1121 | adev->gfx.config.max_cu_per_sh = 5; | ||
1122 | adev->gfx.config.max_sh_per_se = 1; | ||
1123 | adev->gfx.config.max_backends_per_se = 1; | ||
1124 | adev->gfx.config.max_texture_channel_caches = 2; | ||
1125 | adev->gfx.config.max_gprs = 256; | ||
1126 | adev->gfx.config.max_gs_threads = 16; | ||
1127 | adev->gfx.config.max_hw_contexts = 8; | ||
1128 | |||
1129 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | ||
1130 | adev->gfx.config.sc_prim_fifo_size_backend = 0x40; | ||
1131 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | ||
1132 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130; | ||
1133 | gb_addr_config = HAINAN_GB_ADDR_CONFIG_GOLDEN; | ||
1134 | break; | ||
1135 | default: | ||
1136 | BUG(); | ||
1137 | break; | ||
1138 | } | ||
1139 | |||
1140 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); | ||
1141 | WREG32(SRBM_INT_CNTL, 1); | ||
1142 | WREG32(SRBM_INT_ACK, 1); | ||
1143 | |||
1144 | WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN); | ||
1145 | |||
1146 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); | ||
1147 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); | ||
1148 | |||
1149 | adev->gfx.config.num_tile_pipes = adev->gfx.config.max_tile_pipes; | ||
1150 | adev->gfx.config.mem_max_burst_length_bytes = 256; | ||
1151 | tmp = (mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT; | ||
1152 | adev->gfx.config.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024; | ||
1153 | if (adev->gfx.config.mem_row_size_in_kb > 4) | ||
1154 | adev->gfx.config.mem_row_size_in_kb = 4; | ||
1155 | adev->gfx.config.shader_engine_tile_size = 32; | ||
1156 | adev->gfx.config.num_gpus = 1; | ||
1157 | adev->gfx.config.multi_gpu_tile_size = 64; | ||
1158 | |||
1159 | gb_addr_config &= ~ROW_SIZE_MASK; | ||
1160 | switch (adev->gfx.config.mem_row_size_in_kb) { | ||
1161 | case 1: | ||
1162 | default: | ||
1163 | gb_addr_config |= ROW_SIZE(0); | ||
1164 | break; | ||
1165 | case 2: | ||
1166 | gb_addr_config |= ROW_SIZE(1); | ||
1167 | break; | ||
1168 | case 4: | ||
1169 | gb_addr_config |= ROW_SIZE(2); | ||
1170 | break; | ||
1171 | } | ||
1172 | adev->gfx.config.gb_addr_config = gb_addr_config; | ||
1173 | |||
1174 | WREG32(GB_ADDR_CONFIG, gb_addr_config); | ||
1175 | WREG32(DMIF_ADDR_CONFIG, gb_addr_config); | ||
1176 | WREG32(DMIF_ADDR_CALC, gb_addr_config); | ||
1177 | WREG32(HDP_ADDR_CONFIG, gb_addr_config); | ||
1178 | WREG32(DMA_TILING_CONFIG + DMA0_REGISTER_OFFSET, gb_addr_config); | ||
1179 | WREG32(DMA_TILING_CONFIG + DMA1_REGISTER_OFFSET, gb_addr_config); | ||
1180 | #if 0 | ||
1181 | if (adev->has_uvd) { | ||
1182 | WREG32(UVD_UDEC_ADDR_CONFIG, gb_addr_config); | ||
1183 | WREG32(UVD_UDEC_DB_ADDR_CONFIG, gb_addr_config); | ||
1184 | WREG32(UVD_UDEC_DBW_ADDR_CONFIG, gb_addr_config); | ||
1185 | } | ||
1186 | #endif | ||
1187 | gfx_v6_0_tiling_mode_table_init(adev); | ||
1188 | |||
1189 | gfx_v6_0_setup_rb(adev, adev->gfx.config.max_shader_engines, | ||
1190 | adev->gfx.config.max_sh_per_se, | ||
1191 | adev->gfx.config.max_backends_per_se); | ||
1192 | |||
1193 | gfx_v6_0_setup_spi(adev, adev->gfx.config.max_shader_engines, | ||
1194 | adev->gfx.config.max_sh_per_se, | ||
1195 | adev->gfx.config.max_cu_per_sh); | ||
1196 | |||
1197 | gfx_v6_0_get_cu_info(adev); | ||
1198 | |||
1199 | WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | | ||
1200 | ROQ_IB2_START(0x2b))); | ||
1201 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); | ||
1202 | |||
1203 | sx_debug_1 = RREG32(SX_DEBUG_1); | ||
1204 | WREG32(SX_DEBUG_1, sx_debug_1); | ||
1205 | |||
1206 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4)); | ||
1207 | |||
1208 | WREG32(PA_SC_FIFO_SIZE, (SC_FRONTEND_PRIM_FIFO_SIZE(adev->gfx.config.sc_prim_fifo_size_frontend) | | ||
1209 | SC_BACKEND_PRIM_FIFO_SIZE(adev->gfx.config.sc_prim_fifo_size_backend) | | ||
1210 | SC_HIZ_TILE_FIFO_SIZE(adev->gfx.config.sc_hiz_tile_fifo_size) | | ||
1211 | SC_EARLYZ_TILE_FIFO_SIZE(adev->gfx.config.sc_earlyz_tile_fifo_size))); | ||
1212 | |||
1213 | WREG32(VGT_NUM_INSTANCES, 1); | ||
1214 | WREG32(CP_PERFMON_CNTL, 0); | ||
1215 | WREG32(SQ_CONFIG, 0); | ||
1216 | WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) | | ||
1217 | FORCE_EOV_MAX_REZ_CNT(255))); | ||
1218 | |||
1219 | WREG32(VGT_CACHE_INVALIDATION, CACHE_INVALIDATION(VC_AND_TC) | | ||
1220 | AUTO_INVLD_EN(ES_AND_GS_AUTO)); | ||
1221 | |||
1222 | WREG32(VGT_GS_VERTEX_REUSE, 16); | ||
1223 | WREG32(PA_SC_LINE_STIPPLE_STATE, 0); | ||
1224 | |||
1225 | WREG32(CB_PERFCOUNTER0_SELECT0, 0); | ||
1226 | WREG32(CB_PERFCOUNTER0_SELECT1, 0); | ||
1227 | WREG32(CB_PERFCOUNTER1_SELECT0, 0); | ||
1228 | WREG32(CB_PERFCOUNTER1_SELECT1, 0); | ||
1229 | WREG32(CB_PERFCOUNTER2_SELECT0, 0); | ||
1230 | WREG32(CB_PERFCOUNTER2_SELECT1, 0); | ||
1231 | WREG32(CB_PERFCOUNTER3_SELECT0, 0); | ||
1232 | WREG32(CB_PERFCOUNTER3_SELECT1, 0); | ||
1233 | |||
1234 | hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); | ||
1235 | WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); | ||
1236 | |||
1237 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); | ||
1238 | |||
1239 | udelay(50); | ||
1240 | } | ||
1241 | |||
1242 | |||
1243 | static void gfx_v6_0_scratch_init(struct amdgpu_device *adev) | ||
1244 | { | ||
1245 | int i; | ||
1246 | |||
1247 | adev->gfx.scratch.num_reg = 7; | ||
1248 | adev->gfx.scratch.reg_base = SCRATCH_REG0; | ||
1249 | for (i = 0; i < adev->gfx.scratch.num_reg; i++) { | ||
1250 | adev->gfx.scratch.free[i] = true; | ||
1251 | adev->gfx.scratch.reg[i] = adev->gfx.scratch.reg_base + i; | ||
1252 | } | ||
1253 | } | ||
1254 | |||
1255 | static int gfx_v6_0_ring_test_ring(struct amdgpu_ring *ring) | ||
1256 | { | ||
1257 | struct amdgpu_device *adev = ring->adev; | ||
1258 | uint32_t scratch; | ||
1259 | uint32_t tmp = 0; | ||
1260 | unsigned i; | ||
1261 | int r; | ||
1262 | |||
1263 | r = amdgpu_gfx_scratch_get(adev, &scratch); | ||
1264 | if (r) { | ||
1265 | DRM_ERROR("amdgpu: cp failed to get scratch reg (%d).\n", r); | ||
1266 | return r; | ||
1267 | } | ||
1268 | WREG32(scratch, 0xCAFEDEAD); | ||
1269 | |||
1270 | r = amdgpu_ring_alloc(ring, 3); | ||
1271 | if (r) { | ||
1272 | DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", ring->idx, r); | ||
1273 | amdgpu_gfx_scratch_free(adev, scratch); | ||
1274 | return r; | ||
1275 | } | ||
1276 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | ||
1277 | amdgpu_ring_write(ring, (scratch - PACKET3_SET_CONFIG_REG_START)); | ||
1278 | amdgpu_ring_write(ring, 0xDEADBEEF); | ||
1279 | amdgpu_ring_commit(ring); | ||
1280 | |||
1281 | for (i = 0; i < adev->usec_timeout; i++) { | ||
1282 | tmp = RREG32(scratch); | ||
1283 | if (tmp == 0xDEADBEEF) | ||
1284 | break; | ||
1285 | DRM_UDELAY(1); | ||
1286 | } | ||
1287 | if (i < adev->usec_timeout) { | ||
1288 | DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i); | ||
1289 | } else { | ||
1290 | DRM_ERROR("amdgpu: ring %d test failed (scratch(0x%04X)=0x%08X)\n", | ||
1291 | ring->idx, scratch, tmp); | ||
1292 | r = -EINVAL; | ||
1293 | } | ||
1294 | amdgpu_gfx_scratch_free(adev, scratch); | ||
1295 | return r; | ||
1296 | } | ||
1297 | |||
1298 | static void gfx_v6_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | ||
1299 | { | ||
1300 | /* flush hdp cache */ | ||
1301 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | ||
1302 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | ||
1303 | WRITE_DATA_DST_SEL(0))); | ||
1304 | amdgpu_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL); | ||
1305 | amdgpu_ring_write(ring, 0); | ||
1306 | amdgpu_ring_write(ring, 0x1); | ||
1307 | } | ||
1308 | |||
1309 | /** | ||
1310 | * gfx_v6_0_ring_emit_hdp_invalidate - emit an hdp invalidate on the cp | ||
1311 | * | ||
1312 | * @adev: amdgpu_device pointer | ||
1313 | * @ridx: amdgpu ring index | ||
1314 | * | ||
1315 | * Emits an hdp invalidate on the cp. | ||
1316 | */ | ||
1317 | static void gfx_v6_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | ||
1318 | { | ||
1319 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | ||
1320 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | ||
1321 | WRITE_DATA_DST_SEL(0))); | ||
1322 | amdgpu_ring_write(ring, HDP_DEBUG0); | ||
1323 | amdgpu_ring_write(ring, 0); | ||
1324 | amdgpu_ring_write(ring, 0x1); | ||
1325 | } | ||
1326 | |||
1327 | static void gfx_v6_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, | ||
1328 | u64 seq, unsigned flags) | ||
1329 | { | ||
1330 | bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT; | ||
1331 | bool int_sel = flags & AMDGPU_FENCE_FLAG_INT; | ||
1332 | /* flush read cache over gart */ | ||
1333 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | ||
1334 | amdgpu_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START)); | ||
1335 | amdgpu_ring_write(ring, 0); | ||
1336 | amdgpu_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3)); | ||
1337 | amdgpu_ring_write(ring, PACKET3_TCL1_ACTION_ENA | | ||
1338 | PACKET3_TC_ACTION_ENA | | ||
1339 | PACKET3_SH_KCACHE_ACTION_ENA | | ||
1340 | PACKET3_SH_ICACHE_ACTION_ENA); | ||
1341 | amdgpu_ring_write(ring, 0xFFFFFFFF); | ||
1342 | amdgpu_ring_write(ring, 0); | ||
1343 | amdgpu_ring_write(ring, 10); /* poll interval */ | ||
1344 | /* EVENT_WRITE_EOP - flush caches, send int */ | ||
1345 | amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); | ||
1346 | amdgpu_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5)); | ||
1347 | amdgpu_ring_write(ring, addr & 0xfffffffc); | ||
1348 | amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xffff) | | ||
1349 | DATA_SEL(write64bit ? 2 : 1) | INT_SEL(int_sel ? 2 : 0)); | ||
1350 | amdgpu_ring_write(ring, lower_32_bits(seq)); | ||
1351 | amdgpu_ring_write(ring, upper_32_bits(seq)); | ||
1352 | } | ||
1353 | |||
1354 | static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring, | ||
1355 | struct amdgpu_ib *ib, | ||
1356 | unsigned vm_id, bool ctx_switch) | ||
1357 | { | ||
1358 | u32 header, control = 0; | ||
1359 | |||
1360 | /* insert SWITCH_BUFFER packet before first IB in the ring frame */ | ||
1361 | if (ctx_switch) { | ||
1362 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
1363 | amdgpu_ring_write(ring, 0); | ||
1364 | } | ||
1365 | |||
1366 | if (ib->flags & AMDGPU_IB_FLAG_CE) | ||
1367 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); | ||
1368 | else | ||
1369 | header = PACKET3(PACKET3_INDIRECT_BUFFER, 2); | ||
1370 | |||
1371 | control |= ib->length_dw | (vm_id << 24); | ||
1372 | |||
1373 | amdgpu_ring_write(ring, header); | ||
1374 | amdgpu_ring_write(ring, | ||
1375 | #ifdef __BIG_ENDIAN | ||
1376 | (2 << 0) | | ||
1377 | #endif | ||
1378 | (ib->gpu_addr & 0xFFFFFFFC)); | ||
1379 | amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF); | ||
1380 | amdgpu_ring_write(ring, control); | ||
1381 | } | ||
1382 | |||
1383 | /** | ||
1384 | * gfx_v6_0_ring_test_ib - basic ring IB test | ||
1385 | * | ||
1386 | * @ring: amdgpu_ring structure holding ring information | ||
1387 | * | ||
1388 | * Allocate an IB and execute it on the gfx ring (SI). | ||
1389 | * Provides a basic gfx ring test to verify that IBs are working. | ||
1390 | * Returns 0 on success, error on failure. | ||
1391 | */ | ||
1392 | static int gfx_v6_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) | ||
1393 | { | ||
1394 | struct amdgpu_device *adev = ring->adev; | ||
1395 | struct amdgpu_ib ib; | ||
1396 | struct fence *f = NULL; | ||
1397 | uint32_t scratch; | ||
1398 | uint32_t tmp = 0; | ||
1399 | long r; | ||
1400 | |||
1401 | r = amdgpu_gfx_scratch_get(adev, &scratch); | ||
1402 | if (r) { | ||
1403 | DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r); | ||
1404 | return r; | ||
1405 | } | ||
1406 | WREG32(scratch, 0xCAFEDEAD); | ||
1407 | memset(&ib, 0, sizeof(ib)); | ||
1408 | r = amdgpu_ib_get(adev, NULL, 256, &ib); | ||
1409 | if (r) { | ||
1410 | DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r); | ||
1411 | goto err1; | ||
1412 | } | ||
1413 | ib.ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1); | ||
1414 | ib.ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_START)); | ||
1415 | ib.ptr[2] = 0xDEADBEEF; | ||
1416 | ib.length_dw = 3; | ||
1417 | |||
1418 | r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | ||
1419 | if (r) | ||
1420 | goto err2; | ||
1421 | |||
1422 | r = fence_wait_timeout(f, false, timeout); | ||
1423 | if (r == 0) { | ||
1424 | DRM_ERROR("amdgpu: IB test timed out\n"); | ||
1425 | r = -ETIMEDOUT; | ||
1426 | goto err2; | ||
1427 | } else if (r < 0) { | ||
1428 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); | ||
1429 | goto err2; | ||
1430 | } | ||
1431 | tmp = RREG32(scratch); | ||
1432 | if (tmp == 0xDEADBEEF) { | ||
1433 | DRM_INFO("ib test on ring %d succeeded\n", ring->idx); | ||
1434 | r = 0; | ||
1435 | } else { | ||
1436 | DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n", | ||
1437 | scratch, tmp); | ||
1438 | r = -EINVAL; | ||
1439 | } | ||
1440 | |||
1441 | err2: | ||
1442 | amdgpu_ib_free(adev, &ib, NULL); | ||
1443 | fence_put(f); | ||
1444 | err1: | ||
1445 | amdgpu_gfx_scratch_free(adev, scratch); | ||
1446 | return r; | ||
1447 | } | ||
1448 | |||
1449 | static void gfx_v6_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable) | ||
1450 | { | ||
1451 | int i; | ||
1452 | if (enable) | ||
1453 | WREG32(CP_ME_CNTL, 0); | ||
1454 | else { | ||
1455 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT)); | ||
1456 | WREG32(SCRATCH_UMSK, 0); | ||
1457 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | ||
1458 | adev->gfx.gfx_ring[i].ready = false; | ||
1459 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | ||
1460 | adev->gfx.compute_ring[i].ready = false; | ||
1461 | } | ||
1462 | udelay(50); | ||
1463 | } | ||
1464 | |||
1465 | static int gfx_v6_0_cp_gfx_load_microcode(struct amdgpu_device *adev) | ||
1466 | { | ||
1467 | unsigned i; | ||
1468 | const struct gfx_firmware_header_v1_0 *pfp_hdr; | ||
1469 | const struct gfx_firmware_header_v1_0 *ce_hdr; | ||
1470 | const struct gfx_firmware_header_v1_0 *me_hdr; | ||
1471 | const __le32 *fw_data; | ||
1472 | u32 fw_size; | ||
1473 | |||
1474 | if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw) | ||
1475 | return -EINVAL; | ||
1476 | |||
1477 | gfx_v6_0_cp_gfx_enable(adev, false); | ||
1478 | pfp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | ||
1479 | ce_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | ||
1480 | me_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | ||
1481 | |||
1482 | amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header); | ||
1483 | amdgpu_ucode_print_gfx_hdr(&ce_hdr->header); | ||
1484 | amdgpu_ucode_print_gfx_hdr(&me_hdr->header); | ||
1485 | |||
1486 | /* PFP */ | ||
1487 | fw_data = (const __le32 *) | ||
1488 | (adev->gfx.pfp_fw->data + le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes)); | ||
1489 | fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4; | ||
1490 | WREG32(CP_PFP_UCODE_ADDR, 0); | ||
1491 | for (i = 0; i < fw_size; i++) | ||
1492 | WREG32(CP_PFP_UCODE_DATA, le32_to_cpup(fw_data++)); | ||
1493 | WREG32(CP_PFP_UCODE_ADDR, 0); | ||
1494 | |||
1495 | /* CE */ | ||
1496 | fw_data = (const __le32 *) | ||
1497 | (adev->gfx.ce_fw->data + le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes)); | ||
1498 | fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4; | ||
1499 | WREG32(CP_CE_UCODE_ADDR, 0); | ||
1500 | for (i = 0; i < fw_size; i++) | ||
1501 | WREG32(CP_CE_UCODE_DATA, le32_to_cpup(fw_data++)); | ||
1502 | WREG32(CP_CE_UCODE_ADDR, 0); | ||
1503 | |||
1504 | /* ME */ | ||
1505 | fw_data = (const __be32 *) | ||
1506 | (adev->gfx.me_fw->data + le32_to_cpu(me_hdr->header.ucode_array_offset_bytes)); | ||
1507 | fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4; | ||
1508 | WREG32(CP_ME_RAM_WADDR, 0); | ||
1509 | for (i = 0; i < fw_size; i++) | ||
1510 | WREG32(CP_ME_RAM_DATA, le32_to_cpup(fw_data++)); | ||
1511 | WREG32(CP_ME_RAM_WADDR, 0); | ||
1512 | |||
1513 | |||
1514 | WREG32(CP_PFP_UCODE_ADDR, 0); | ||
1515 | WREG32(CP_CE_UCODE_ADDR, 0); | ||
1516 | WREG32(CP_ME_RAM_WADDR, 0); | ||
1517 | WREG32(CP_ME_RAM_RADDR, 0); | ||
1518 | return 0; | ||
1519 | } | ||
1520 | |||
1521 | static int gfx_v6_0_cp_gfx_start(struct amdgpu_device *adev) | ||
1522 | { | ||
1523 | const struct cs_section_def *sect = NULL; | ||
1524 | const struct cs_extent_def *ext = NULL; | ||
1525 | struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0]; | ||
1526 | int r, i; | ||
1527 | |||
1528 | r = amdgpu_ring_alloc(ring, 7 + 4); | ||
1529 | if (r) { | ||
1530 | DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r); | ||
1531 | return r; | ||
1532 | } | ||
1533 | amdgpu_ring_write(ring, PACKET3(PACKET3_ME_INITIALIZE, 5)); | ||
1534 | amdgpu_ring_write(ring, 0x1); | ||
1535 | amdgpu_ring_write(ring, 0x0); | ||
1536 | amdgpu_ring_write(ring, adev->gfx.config.max_hw_contexts - 1); | ||
1537 | amdgpu_ring_write(ring, PACKET3_ME_INITIALIZE_DEVICE_ID(1)); | ||
1538 | amdgpu_ring_write(ring, 0); | ||
1539 | amdgpu_ring_write(ring, 0); | ||
1540 | |||
1541 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2)); | ||
1542 | amdgpu_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE)); | ||
1543 | amdgpu_ring_write(ring, 0xc000); | ||
1544 | amdgpu_ring_write(ring, 0xe000); | ||
1545 | amdgpu_ring_commit(ring); | ||
1546 | |||
1547 | gfx_v6_0_cp_gfx_enable(adev, true); | ||
1548 | |||
1549 | r = amdgpu_ring_alloc(ring, gfx_v6_0_get_csb_size(adev) + 10); | ||
1550 | if (r) { | ||
1551 | DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r); | ||
1552 | return r; | ||
1553 | } | ||
1554 | |||
1555 | amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | ||
1556 | amdgpu_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); | ||
1557 | |||
1558 | for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { | ||
1559 | for (ext = sect->section; ext->extent != NULL; ++ext) { | ||
1560 | if (sect->id == SECT_CONTEXT) { | ||
1561 | amdgpu_ring_write(ring, | ||
1562 | PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); | ||
1563 | amdgpu_ring_write(ring, ext->reg_index - PACKET3_SET_CONTEXT_REG_START); | ||
1564 | for (i = 0; i < ext->reg_count; i++) | ||
1565 | amdgpu_ring_write(ring, ext->extent[i]); | ||
1566 | } | ||
1567 | } | ||
1568 | } | ||
1569 | |||
1570 | amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | ||
1571 | amdgpu_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE); | ||
1572 | |||
1573 | amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0)); | ||
1574 | amdgpu_ring_write(ring, 0); | ||
1575 | |||
1576 | amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2)); | ||
1577 | amdgpu_ring_write(ring, 0x00000316); | ||
1578 | amdgpu_ring_write(ring, 0x0000000e); | ||
1579 | amdgpu_ring_write(ring, 0x00000010); | ||
1580 | |||
1581 | amdgpu_ring_commit(ring); | ||
1582 | |||
1583 | return 0; | ||
1584 | } | ||
1585 | |||
1586 | static int gfx_v6_0_cp_gfx_resume(struct amdgpu_device *adev) | ||
1587 | { | ||
1588 | struct amdgpu_ring *ring; | ||
1589 | u32 tmp; | ||
1590 | u32 rb_bufsz; | ||
1591 | int r; | ||
1592 | u64 rptr_addr; | ||
1593 | |||
1594 | WREG32(CP_SEM_WAIT_TIMER, 0x0); | ||
1595 | WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); | ||
1596 | |||
1597 | /* Set the write pointer delay */ | ||
1598 | WREG32(CP_RB_WPTR_DELAY, 0); | ||
1599 | |||
1600 | WREG32(CP_DEBUG, 0); | ||
1601 | WREG32(SCRATCH_ADDR, 0); | ||
1602 | |||
1603 | /* ring 0 - compute and gfx */ | ||
1604 | /* Set ring buffer size */ | ||
1605 | ring = &adev->gfx.gfx_ring[0]; | ||
1606 | rb_bufsz = order_base_2(ring->ring_size / 8); | ||
1607 | tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | ||
1608 | |||
1609 | #ifdef __BIG_ENDIAN | ||
1610 | tmp |= BUF_SWAP_32BIT; | ||
1611 | #endif | ||
1612 | WREG32(CP_RB0_CNTL, tmp); | ||
1613 | |||
1614 | /* Initialize the ring buffer's read and write pointers */ | ||
1615 | WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA); | ||
1616 | ring->wptr = 0; | ||
1617 | WREG32(CP_RB0_WPTR, ring->wptr); | ||
1618 | |||
1619 | /* set the wb address whether it's enabled or not */ | ||
1620 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); | ||
1621 | WREG32(CP_RB0_RPTR_ADDR, lower_32_bits(rptr_addr)); | ||
1622 | WREG32(CP_RB0_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF); | ||
1623 | |||
1624 | WREG32(SCRATCH_UMSK, 0); | ||
1625 | |||
1626 | mdelay(1); | ||
1627 | WREG32(CP_RB0_CNTL, tmp); | ||
1628 | |||
1629 | WREG32(CP_RB0_BASE, ring->gpu_addr >> 8); | ||
1630 | |||
1631 | /* start the rings */ | ||
1632 | gfx_v6_0_cp_gfx_start(adev); | ||
1633 | ring->ready = true; | ||
1634 | r = amdgpu_ring_test_ring(ring); | ||
1635 | if (r) { | ||
1636 | ring->ready = false; | ||
1637 | return r; | ||
1638 | } | ||
1639 | |||
1640 | return 0; | ||
1641 | } | ||
1642 | |||
1643 | static u32 gfx_v6_0_ring_get_rptr(struct amdgpu_ring *ring) | ||
1644 | { | ||
1645 | return ring->adev->wb.wb[ring->rptr_offs]; | ||
1646 | } | ||
1647 | |||
1648 | static u32 gfx_v6_0_ring_get_wptr(struct amdgpu_ring *ring) | ||
1649 | { | ||
1650 | struct amdgpu_device *adev = ring->adev; | ||
1651 | |||
1652 | if (ring == &adev->gfx.gfx_ring[0]) | ||
1653 | return RREG32(CP_RB0_WPTR); | ||
1654 | else if (ring == &adev->gfx.compute_ring[0]) | ||
1655 | return RREG32(CP_RB1_WPTR); | ||
1656 | else if (ring == &adev->gfx.compute_ring[1]) | ||
1657 | return RREG32(CP_RB2_WPTR); | ||
1658 | else | ||
1659 | BUG(); | ||
1660 | } | ||
1661 | |||
1662 | static void gfx_v6_0_ring_set_wptr_gfx(struct amdgpu_ring *ring) | ||
1663 | { | ||
1664 | struct amdgpu_device *adev = ring->adev; | ||
1665 | |||
1666 | WREG32(CP_RB0_WPTR, ring->wptr); | ||
1667 | (void)RREG32(CP_RB0_WPTR); | ||
1668 | } | ||
1669 | |||
1670 | static void gfx_v6_0_ring_set_wptr_compute(struct amdgpu_ring *ring) | ||
1671 | { | ||
1672 | struct amdgpu_device *adev = ring->adev; | ||
1673 | |||
1674 | if (ring == &adev->gfx.compute_ring[0]) { | ||
1675 | WREG32(CP_RB1_WPTR, ring->wptr); | ||
1676 | (void)RREG32(CP_RB1_WPTR); | ||
1677 | } else if (ring == &adev->gfx.compute_ring[1]) { | ||
1678 | WREG32(CP_RB2_WPTR, ring->wptr); | ||
1679 | (void)RREG32(CP_RB2_WPTR); | ||
1680 | } else { | ||
1681 | BUG(); | ||
1682 | } | ||
1683 | |||
1684 | } | ||
1685 | |||
1686 | static int gfx_v6_0_cp_compute_resume(struct amdgpu_device *adev) | ||
1687 | { | ||
1688 | struct amdgpu_ring *ring; | ||
1689 | u32 tmp; | ||
1690 | u32 rb_bufsz; | ||
1691 | int r; | ||
1692 | u64 rptr_addr; | ||
1693 | |||
1694 | /* ring1 - compute only */ | ||
1695 | /* Set ring buffer size */ | ||
1696 | |||
1697 | ring = &adev->gfx.compute_ring[0]; | ||
1698 | rb_bufsz = order_base_2(ring->ring_size / 8); | ||
1699 | tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | ||
1700 | #ifdef __BIG_ENDIAN | ||
1701 | tmp |= BUF_SWAP_32BIT; | ||
1702 | #endif | ||
1703 | WREG32(CP_RB1_CNTL, tmp); | ||
1704 | |||
1705 | WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA); | ||
1706 | ring->wptr = 0; | ||
1707 | WREG32(CP_RB1_WPTR, ring->wptr); | ||
1708 | |||
1709 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); | ||
1710 | WREG32(CP_RB1_RPTR_ADDR, lower_32_bits(rptr_addr)); | ||
1711 | WREG32(CP_RB1_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF); | ||
1712 | |||
1713 | mdelay(1); | ||
1714 | WREG32(CP_RB1_CNTL, tmp); | ||
1715 | WREG32(CP_RB1_BASE, ring->gpu_addr >> 8); | ||
1716 | |||
1717 | ring = &adev->gfx.compute_ring[1]; | ||
1718 | rb_bufsz = order_base_2(ring->ring_size / 8); | ||
1719 | tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | ||
1720 | #ifdef __BIG_ENDIAN | ||
1721 | tmp |= BUF_SWAP_32BIT; | ||
1722 | #endif | ||
1723 | WREG32(CP_RB2_CNTL, tmp); | ||
1724 | |||
1725 | WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA); | ||
1726 | ring->wptr = 0; | ||
1727 | WREG32(CP_RB2_WPTR, ring->wptr); | ||
1728 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); | ||
1729 | WREG32(CP_RB2_RPTR_ADDR, lower_32_bits(rptr_addr)); | ||
1730 | WREG32(CP_RB2_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF); | ||
1731 | |||
1732 | mdelay(1); | ||
1733 | WREG32(CP_RB2_CNTL, tmp); | ||
1734 | WREG32(CP_RB2_BASE, ring->gpu_addr >> 8); | ||
1735 | |||
1736 | adev->gfx.compute_ring[0].ready = true; | ||
1737 | adev->gfx.compute_ring[1].ready = true; | ||
1738 | |||
1739 | r = amdgpu_ring_test_ring(&adev->gfx.compute_ring[0]); | ||
1740 | if (r) { | ||
1741 | adev->gfx.compute_ring[0].ready = false; | ||
1742 | return r; | ||
1743 | } | ||
1744 | |||
1745 | r = amdgpu_ring_test_ring(&adev->gfx.compute_ring[1]); | ||
1746 | if (r) { | ||
1747 | adev->gfx.compute_ring[1].ready = false; | ||
1748 | return r; | ||
1749 | } | ||
1750 | |||
1751 | return 0; | ||
1752 | } | ||
1753 | |||
1754 | static void gfx_v6_0_cp_enable(struct amdgpu_device *adev, bool enable) | ||
1755 | { | ||
1756 | gfx_v6_0_cp_gfx_enable(adev, enable); | ||
1757 | } | ||
1758 | |||
1759 | static int gfx_v6_0_cp_load_microcode(struct amdgpu_device *adev) | ||
1760 | { | ||
1761 | return gfx_v6_0_cp_gfx_load_microcode(adev); | ||
1762 | } | ||
1763 | |||
1764 | static void gfx_v6_0_enable_gui_idle_interrupt(struct amdgpu_device *adev, | ||
1765 | bool enable) | ||
1766 | { | ||
1767 | u32 tmp = RREG32(CP_INT_CNTL_RING0); | ||
1768 | u32 mask; | ||
1769 | int i; | ||
1770 | |||
1771 | if (enable) | ||
1772 | tmp |= (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | ||
1773 | else | ||
1774 | tmp &= ~(CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); | ||
1775 | WREG32(CP_INT_CNTL_RING0, tmp); | ||
1776 | |||
1777 | if (!enable) { | ||
1778 | /* read a gfx register */ | ||
1779 | tmp = RREG32(DB_DEPTH_INFO); | ||
1780 | |||
1781 | mask = RLC_BUSY_STATUS | GFX_POWER_STATUS | GFX_CLOCK_STATUS | GFX_LS_STATUS; | ||
1782 | for (i = 0; i < adev->usec_timeout; i++) { | ||
1783 | if ((RREG32(RLC_STAT) & mask) == (GFX_CLOCK_STATUS | GFX_POWER_STATUS)) | ||
1784 | break; | ||
1785 | udelay(1); | ||
1786 | } | ||
1787 | } | ||
1788 | } | ||
1789 | |||
1790 | static int gfx_v6_0_cp_resume(struct amdgpu_device *adev) | ||
1791 | { | ||
1792 | int r; | ||
1793 | |||
1794 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | ||
1795 | |||
1796 | r = gfx_v6_0_cp_load_microcode(adev); | ||
1797 | if (r) | ||
1798 | return r; | ||
1799 | |||
1800 | r = gfx_v6_0_cp_gfx_resume(adev); | ||
1801 | if (r) | ||
1802 | return r; | ||
1803 | r = gfx_v6_0_cp_compute_resume(adev); | ||
1804 | if (r) | ||
1805 | return r; | ||
1806 | |||
1807 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | ||
1808 | |||
1809 | return 0; | ||
1810 | } | ||
1811 | |||
1812 | static void gfx_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | ||
1813 | { | ||
1814 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | ||
1815 | uint32_t seq = ring->fence_drv.sync_seq; | ||
1816 | uint64_t addr = ring->fence_drv.gpu_addr; | ||
1817 | |||
1818 | amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5)); | ||
1819 | amdgpu_ring_write(ring, (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */ | ||
1820 | WAIT_REG_MEM_FUNCTION(3) | /* equal */ | ||
1821 | WAIT_REG_MEM_ENGINE(usepfp))); /* pfp or me */ | ||
1822 | amdgpu_ring_write(ring, addr & 0xfffffffc); | ||
1823 | amdgpu_ring_write(ring, upper_32_bits(addr) & 0xffffffff); | ||
1824 | amdgpu_ring_write(ring, seq); | ||
1825 | amdgpu_ring_write(ring, 0xffffffff); | ||
1826 | amdgpu_ring_write(ring, 4); /* poll interval */ | ||
1827 | |||
1828 | if (usepfp) { | ||
1829 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | ||
1830 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
1831 | amdgpu_ring_write(ring, 0); | ||
1832 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
1833 | amdgpu_ring_write(ring, 0); | ||
1834 | } | ||
1835 | } | ||
1836 | |||
1837 | static void gfx_v6_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | ||
1838 | unsigned vm_id, uint64_t pd_addr) | ||
1839 | { | ||
1840 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | ||
1841 | |||
1842 | /* write new base address */ | ||
1843 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | ||
1844 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | ||
1845 | WRITE_DATA_DST_SEL(0))); | ||
1846 | if (vm_id < 8) { | ||
1847 | amdgpu_ring_write(ring, (VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + vm_id )); | ||
1848 | } else { | ||
1849 | amdgpu_ring_write(ring, (VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + (vm_id - 8))); | ||
1850 | } | ||
1851 | amdgpu_ring_write(ring, 0); | ||
1852 | amdgpu_ring_write(ring, pd_addr >> 12); | ||
1853 | |||
1854 | /* bits 0-15 are the VM contexts0-15 */ | ||
1855 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | ||
1856 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | ||
1857 | WRITE_DATA_DST_SEL(0))); | ||
1858 | amdgpu_ring_write(ring, VM_INVALIDATE_REQUEST); | ||
1859 | amdgpu_ring_write(ring, 0); | ||
1860 | amdgpu_ring_write(ring, 1 << vm_id); | ||
1861 | |||
1862 | /* wait for the invalidate to complete */ | ||
1863 | amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5)); | ||
1864 | amdgpu_ring_write(ring, (WAIT_REG_MEM_FUNCTION(0) | /* always */ | ||
1865 | WAIT_REG_MEM_ENGINE(0))); /* me */ | ||
1866 | amdgpu_ring_write(ring, VM_INVALIDATE_REQUEST); | ||
1867 | amdgpu_ring_write(ring, 0); | ||
1868 | amdgpu_ring_write(ring, 0); /* ref */ | ||
1869 | amdgpu_ring_write(ring, 0); /* mask */ | ||
1870 | amdgpu_ring_write(ring, 0x20); /* poll interval */ | ||
1871 | |||
1872 | if (usepfp) { | ||
1873 | /* sync PFP to ME, otherwise we might get invalid PFP reads */ | ||
1874 | amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0)); | ||
1875 | amdgpu_ring_write(ring, 0x0); | ||
1876 | |||
1877 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | ||
1878 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
1879 | amdgpu_ring_write(ring, 0); | ||
1880 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
1881 | amdgpu_ring_write(ring, 0); | ||
1882 | } | ||
1883 | } | ||
1884 | |||
1885 | |||
1886 | static void gfx_v6_0_rlc_fini(struct amdgpu_device *adev) | ||
1887 | { | ||
1888 | int r; | ||
1889 | |||
1890 | if (adev->gfx.rlc.save_restore_obj) { | ||
1891 | r = amdgpu_bo_reserve(adev->gfx.rlc.save_restore_obj, false); | ||
1892 | if (unlikely(r != 0)) | ||
1893 | dev_warn(adev->dev, "(%d) reserve RLC sr bo failed\n", r); | ||
1894 | amdgpu_bo_unpin(adev->gfx.rlc.save_restore_obj); | ||
1895 | amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj); | ||
1896 | |||
1897 | amdgpu_bo_unref(&adev->gfx.rlc.save_restore_obj); | ||
1898 | adev->gfx.rlc.save_restore_obj = NULL; | ||
1899 | } | ||
1900 | |||
1901 | if (adev->gfx.rlc.clear_state_obj) { | ||
1902 | r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false); | ||
1903 | if (unlikely(r != 0)) | ||
1904 | dev_warn(adev->dev, "(%d) reserve RLC c bo failed\n", r); | ||
1905 | amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj); | ||
1906 | amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj); | ||
1907 | |||
1908 | amdgpu_bo_unref(&adev->gfx.rlc.clear_state_obj); | ||
1909 | adev->gfx.rlc.clear_state_obj = NULL; | ||
1910 | } | ||
1911 | |||
1912 | if (adev->gfx.rlc.cp_table_obj) { | ||
1913 | r = amdgpu_bo_reserve(adev->gfx.rlc.cp_table_obj, false); | ||
1914 | if (unlikely(r != 0)) | ||
1915 | dev_warn(adev->dev, "(%d) reserve RLC cp table bo failed\n", r); | ||
1916 | amdgpu_bo_unpin(adev->gfx.rlc.cp_table_obj); | ||
1917 | amdgpu_bo_unreserve(adev->gfx.rlc.cp_table_obj); | ||
1918 | |||
1919 | amdgpu_bo_unref(&adev->gfx.rlc.cp_table_obj); | ||
1920 | adev->gfx.rlc.cp_table_obj = NULL; | ||
1921 | } | ||
1922 | } | ||
1923 | |||
1924 | static int gfx_v6_0_rlc_init(struct amdgpu_device *adev) | ||
1925 | { | ||
1926 | const u32 *src_ptr; | ||
1927 | volatile u32 *dst_ptr; | ||
1928 | u32 dws, i; | ||
1929 | u64 reg_list_mc_addr; | ||
1930 | const struct cs_section_def *cs_data; | ||
1931 | int r; | ||
1932 | |||
1933 | adev->gfx.rlc.reg_list = verde_rlc_save_restore_register_list; | ||
1934 | adev->gfx.rlc.reg_list_size = | ||
1935 | (u32)ARRAY_SIZE(verde_rlc_save_restore_register_list); | ||
1936 | |||
1937 | adev->gfx.rlc.cs_data = si_cs_data; | ||
1938 | src_ptr = adev->gfx.rlc.reg_list; | ||
1939 | dws = adev->gfx.rlc.reg_list_size; | ||
1940 | cs_data = adev->gfx.rlc.cs_data; | ||
1941 | |||
1942 | if (src_ptr) { | ||
1943 | /* save restore block */ | ||
1944 | if (adev->gfx.rlc.save_restore_obj == NULL) { | ||
1945 | |||
1946 | r = amdgpu_bo_create(adev, dws * 4, PAGE_SIZE, true, | ||
1947 | AMDGPU_GEM_DOMAIN_VRAM, | ||
1948 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, | ||
1949 | NULL, NULL, | ||
1950 | &adev->gfx.rlc.save_restore_obj); | ||
1951 | |||
1952 | if (r) { | ||
1953 | dev_warn(adev->dev, "(%d) create RLC sr bo failed\n", r); | ||
1954 | return r; | ||
1955 | } | ||
1956 | } | ||
1957 | |||
1958 | r = amdgpu_bo_reserve(adev->gfx.rlc.save_restore_obj, false); | ||
1959 | if (unlikely(r != 0)) { | ||
1960 | gfx_v6_0_rlc_fini(adev); | ||
1961 | return r; | ||
1962 | } | ||
1963 | r = amdgpu_bo_pin(adev->gfx.rlc.save_restore_obj, AMDGPU_GEM_DOMAIN_VRAM, | ||
1964 | &adev->gfx.rlc.save_restore_gpu_addr); | ||
1965 | if (r) { | ||
1966 | amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj); | ||
1967 | dev_warn(adev->dev, "(%d) pin RLC sr bo failed\n", r); | ||
1968 | gfx_v6_0_rlc_fini(adev); | ||
1969 | return r; | ||
1970 | } | ||
1971 | |||
1972 | r = amdgpu_bo_kmap(adev->gfx.rlc.save_restore_obj, (void **)&adev->gfx.rlc.sr_ptr); | ||
1973 | if (r) { | ||
1974 | dev_warn(adev->dev, "(%d) map RLC sr bo failed\n", r); | ||
1975 | gfx_v6_0_rlc_fini(adev); | ||
1976 | return r; | ||
1977 | } | ||
1978 | /* write the sr buffer */ | ||
1979 | dst_ptr = adev->gfx.rlc.sr_ptr; | ||
1980 | for (i = 0; i < adev->gfx.rlc.reg_list_size; i++) | ||
1981 | dst_ptr[i] = cpu_to_le32(src_ptr[i]); | ||
1982 | amdgpu_bo_kunmap(adev->gfx.rlc.save_restore_obj); | ||
1983 | amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj); | ||
1984 | } | ||
1985 | |||
1986 | if (cs_data) { | ||
1987 | /* clear state block */ | ||
1988 | adev->gfx.rlc.clear_state_size = gfx_v6_0_get_csb_size(adev); | ||
1989 | dws = adev->gfx.rlc.clear_state_size + (256 / 4); | ||
1990 | |||
1991 | if (adev->gfx.rlc.clear_state_obj == NULL) { | ||
1992 | r = amdgpu_bo_create(adev, dws * 4, PAGE_SIZE, true, | ||
1993 | AMDGPU_GEM_DOMAIN_VRAM, | ||
1994 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, | ||
1995 | NULL, NULL, | ||
1996 | &adev->gfx.rlc.clear_state_obj); | ||
1997 | |||
1998 | if (r) { | ||
1999 | dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r); | ||
2000 | gfx_v6_0_rlc_fini(adev); | ||
2001 | return r; | ||
2002 | } | ||
2003 | } | ||
2004 | r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false); | ||
2005 | if (unlikely(r != 0)) { | ||
2006 | gfx_v6_0_rlc_fini(adev); | ||
2007 | return r; | ||
2008 | } | ||
2009 | r = amdgpu_bo_pin(adev->gfx.rlc.clear_state_obj, AMDGPU_GEM_DOMAIN_VRAM, | ||
2010 | &adev->gfx.rlc.clear_state_gpu_addr); | ||
2011 | if (r) { | ||
2012 | amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj); | ||
2013 | dev_warn(adev->dev, "(%d) pin RLC c bo failed\n", r); | ||
2014 | gfx_v6_0_rlc_fini(adev); | ||
2015 | return r; | ||
2016 | } | ||
2017 | |||
2018 | r = amdgpu_bo_kmap(adev->gfx.rlc.clear_state_obj, (void **)&adev->gfx.rlc.cs_ptr); | ||
2019 | if (r) { | ||
2020 | dev_warn(adev->dev, "(%d) map RLC c bo failed\n", r); | ||
2021 | gfx_v6_0_rlc_fini(adev); | ||
2022 | return r; | ||
2023 | } | ||
2024 | /* set up the cs buffer */ | ||
2025 | dst_ptr = adev->gfx.rlc.cs_ptr; | ||
2026 | reg_list_mc_addr = adev->gfx.rlc.clear_state_gpu_addr + 256; | ||
2027 | dst_ptr[0] = cpu_to_le32(upper_32_bits(reg_list_mc_addr)); | ||
2028 | dst_ptr[1] = cpu_to_le32(lower_32_bits(reg_list_mc_addr)); | ||
2029 | dst_ptr[2] = cpu_to_le32(adev->gfx.rlc.clear_state_size); | ||
2030 | gfx_v6_0_get_csb_buffer(adev, &dst_ptr[(256/4)]); | ||
2031 | amdgpu_bo_kunmap(adev->gfx.rlc.clear_state_obj); | ||
2032 | amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj); | ||
2033 | } | ||
2034 | |||
2035 | return 0; | ||
2036 | } | ||
2037 | |||
2038 | static void gfx_v6_0_enable_lbpw(struct amdgpu_device *adev, bool enable) | ||
2039 | { | ||
2040 | u32 tmp; | ||
2041 | |||
2042 | tmp = RREG32(RLC_LB_CNTL); | ||
2043 | if (enable) | ||
2044 | tmp |= LOAD_BALANCE_ENABLE; | ||
2045 | else | ||
2046 | tmp &= ~LOAD_BALANCE_ENABLE; | ||
2047 | WREG32(RLC_LB_CNTL, tmp); | ||
2048 | |||
2049 | if (!enable) { | ||
2050 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
2051 | WREG32(SPI_LB_CU_MASK, 0x00ff); | ||
2052 | } | ||
2053 | |||
2054 | } | ||
2055 | |||
2056 | static void gfx_v6_0_wait_for_rlc_serdes(struct amdgpu_device *adev) | ||
2057 | { | ||
2058 | int i; | ||
2059 | |||
2060 | for (i = 0; i < adev->usec_timeout; i++) { | ||
2061 | if (RREG32(RLC_SERDES_MASTER_BUSY_0) == 0) | ||
2062 | break; | ||
2063 | udelay(1); | ||
2064 | } | ||
2065 | |||
2066 | for (i = 0; i < adev->usec_timeout; i++) { | ||
2067 | if (RREG32(RLC_SERDES_MASTER_BUSY_1) == 0) | ||
2068 | break; | ||
2069 | udelay(1); | ||
2070 | } | ||
2071 | } | ||
2072 | |||
2073 | static void gfx_v6_0_update_rlc(struct amdgpu_device *adev, u32 rlc) | ||
2074 | { | ||
2075 | u32 tmp; | ||
2076 | |||
2077 | tmp = RREG32(RLC_CNTL); | ||
2078 | if (tmp != rlc) | ||
2079 | WREG32(RLC_CNTL, rlc); | ||
2080 | } | ||
2081 | |||
2082 | static u32 gfx_v6_0_halt_rlc(struct amdgpu_device *adev) | ||
2083 | { | ||
2084 | u32 data, orig; | ||
2085 | |||
2086 | orig = data = RREG32(RLC_CNTL); | ||
2087 | |||
2088 | if (data & RLC_ENABLE) { | ||
2089 | data &= ~RLC_ENABLE; | ||
2090 | WREG32(RLC_CNTL, data); | ||
2091 | |||
2092 | gfx_v6_0_wait_for_rlc_serdes(adev); | ||
2093 | } | ||
2094 | |||
2095 | return orig; | ||
2096 | } | ||
2097 | |||
2098 | static void gfx_v6_0_rlc_stop(struct amdgpu_device *adev) | ||
2099 | { | ||
2100 | WREG32(RLC_CNTL, 0); | ||
2101 | |||
2102 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | ||
2103 | gfx_v6_0_wait_for_rlc_serdes(adev); | ||
2104 | } | ||
2105 | |||
2106 | static void gfx_v6_0_rlc_start(struct amdgpu_device *adev) | ||
2107 | { | ||
2108 | WREG32(RLC_CNTL, RLC_ENABLE); | ||
2109 | |||
2110 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | ||
2111 | |||
2112 | udelay(50); | ||
2113 | } | ||
2114 | |||
2115 | static void gfx_v6_0_rlc_reset(struct amdgpu_device *adev) | ||
2116 | { | ||
2117 | u32 tmp = RREG32(GRBM_SOFT_RESET); | ||
2118 | |||
2119 | tmp |= SOFT_RESET_RLC; | ||
2120 | WREG32(GRBM_SOFT_RESET, tmp); | ||
2121 | udelay(50); | ||
2122 | tmp &= ~SOFT_RESET_RLC; | ||
2123 | WREG32(GRBM_SOFT_RESET, tmp); | ||
2124 | udelay(50); | ||
2125 | } | ||
2126 | |||
2127 | static bool gfx_v6_0_lbpw_supported(struct amdgpu_device *adev) | ||
2128 | { | ||
2129 | u32 tmp; | ||
2130 | |||
2131 | /* Enable LBPW only for DDR3 */ | ||
2132 | tmp = RREG32(MC_SEQ_MISC0); | ||
2133 | if ((tmp & 0xF0000000) == 0xB0000000) | ||
2134 | return true; | ||
2135 | return false; | ||
2136 | } | ||
2137 | static void gfx_v6_0_init_cg(struct amdgpu_device *adev) | ||
2138 | { | ||
2139 | } | ||
2140 | |||
2141 | static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev) | ||
2142 | { | ||
2143 | u32 i; | ||
2144 | const struct rlc_firmware_header_v1_0 *hdr; | ||
2145 | const __le32 *fw_data; | ||
2146 | u32 fw_size; | ||
2147 | |||
2148 | |||
2149 | if (!adev->gfx.rlc_fw) | ||
2150 | return -EINVAL; | ||
2151 | |||
2152 | gfx_v6_0_rlc_stop(adev); | ||
2153 | gfx_v6_0_rlc_reset(adev); | ||
2154 | gfx_v6_0_init_pg(adev); | ||
2155 | gfx_v6_0_init_cg(adev); | ||
2156 | |||
2157 | WREG32(RLC_RL_BASE, 0); | ||
2158 | WREG32(RLC_RL_SIZE, 0); | ||
2159 | WREG32(RLC_LB_CNTL, 0); | ||
2160 | WREG32(RLC_LB_CNTR_MAX, 0xffffffff); | ||
2161 | WREG32(RLC_LB_CNTR_INIT, 0); | ||
2162 | WREG32(RLC_LB_INIT_CU_MASK, 0xffffffff); | ||
2163 | |||
2164 | WREG32(RLC_MC_CNTL, 0); | ||
2165 | WREG32(RLC_UCODE_CNTL, 0); | ||
2166 | |||
2167 | hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data; | ||
2168 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; | ||
2169 | fw_data = (const __le32 *) | ||
2170 | (adev->gfx.rlc_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
2171 | |||
2172 | amdgpu_ucode_print_rlc_hdr(&hdr->header); | ||
2173 | |||
2174 | for (i = 0; i < fw_size; i++) { | ||
2175 | WREG32(RLC_UCODE_ADDR, i); | ||
2176 | WREG32(RLC_UCODE_DATA, le32_to_cpup(fw_data++)); | ||
2177 | } | ||
2178 | WREG32(RLC_UCODE_ADDR, 0); | ||
2179 | |||
2180 | gfx_v6_0_enable_lbpw(adev, gfx_v6_0_lbpw_supported(adev)); | ||
2181 | gfx_v6_0_rlc_start(adev); | ||
2182 | |||
2183 | return 0; | ||
2184 | } | ||
2185 | |||
2186 | static void gfx_v6_0_enable_cgcg(struct amdgpu_device *adev, bool enable) | ||
2187 | { | ||
2188 | u32 data, orig, tmp; | ||
2189 | |||
2190 | orig = data = RREG32(RLC_CGCG_CGLS_CTRL); | ||
2191 | |||
2192 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGCG)) { | ||
2193 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | ||
2194 | |||
2195 | WREG32(RLC_GCPM_GENERAL_3, 0x00000080); | ||
2196 | |||
2197 | tmp = gfx_v6_0_halt_rlc(adev); | ||
2198 | |||
2199 | WREG32(RLC_SERDES_WR_MASTER_MASK_0, 0xffffffff); | ||
2200 | WREG32(RLC_SERDES_WR_MASTER_MASK_1, 0xffffffff); | ||
2201 | WREG32(RLC_SERDES_WR_CTRL, 0x00b000ff); | ||
2202 | |||
2203 | gfx_v6_0_wait_for_rlc_serdes(adev); | ||
2204 | gfx_v6_0_update_rlc(adev, tmp); | ||
2205 | |||
2206 | WREG32(RLC_SERDES_WR_CTRL, 0x007000ff); | ||
2207 | |||
2208 | data |= CGCG_EN | CGLS_EN; | ||
2209 | } else { | ||
2210 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | ||
2211 | |||
2212 | RREG32(CB_CGTT_SCLK_CTRL); | ||
2213 | RREG32(CB_CGTT_SCLK_CTRL); | ||
2214 | RREG32(CB_CGTT_SCLK_CTRL); | ||
2215 | RREG32(CB_CGTT_SCLK_CTRL); | ||
2216 | |||
2217 | data &= ~(CGCG_EN | CGLS_EN); | ||
2218 | } | ||
2219 | |||
2220 | if (orig != data) | ||
2221 | WREG32(RLC_CGCG_CGLS_CTRL, data); | ||
2222 | |||
2223 | } | ||
2224 | |||
2225 | static void gfx_v6_0_enable_mgcg(struct amdgpu_device *adev, bool enable) | ||
2226 | { | ||
2227 | |||
2228 | u32 data, orig, tmp = 0; | ||
2229 | |||
2230 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) { | ||
2231 | orig = data = RREG32(CGTS_SM_CTRL_REG); | ||
2232 | data = 0x96940200; | ||
2233 | if (orig != data) | ||
2234 | WREG32(CGTS_SM_CTRL_REG, data); | ||
2235 | |||
2236 | if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CP_LS) { | ||
2237 | orig = data = RREG32(CP_MEM_SLP_CNTL); | ||
2238 | data |= CP_MEM_LS_EN; | ||
2239 | if (orig != data) | ||
2240 | WREG32(CP_MEM_SLP_CNTL, data); | ||
2241 | } | ||
2242 | |||
2243 | orig = data = RREG32(RLC_CGTT_MGCG_OVERRIDE); | ||
2244 | data &= 0xffffffc0; | ||
2245 | if (orig != data) | ||
2246 | WREG32(RLC_CGTT_MGCG_OVERRIDE, data); | ||
2247 | |||
2248 | tmp = gfx_v6_0_halt_rlc(adev); | ||
2249 | |||
2250 | WREG32(RLC_SERDES_WR_MASTER_MASK_0, 0xffffffff); | ||
2251 | WREG32(RLC_SERDES_WR_MASTER_MASK_1, 0xffffffff); | ||
2252 | WREG32(RLC_SERDES_WR_CTRL, 0x00d000ff); | ||
2253 | |||
2254 | gfx_v6_0_update_rlc(adev, tmp); | ||
2255 | } else { | ||
2256 | orig = data = RREG32(RLC_CGTT_MGCG_OVERRIDE); | ||
2257 | data |= 0x00000003; | ||
2258 | if (orig != data) | ||
2259 | WREG32(RLC_CGTT_MGCG_OVERRIDE, data); | ||
2260 | |||
2261 | data = RREG32(CP_MEM_SLP_CNTL); | ||
2262 | if (data & CP_MEM_LS_EN) { | ||
2263 | data &= ~CP_MEM_LS_EN; | ||
2264 | WREG32(CP_MEM_SLP_CNTL, data); | ||
2265 | } | ||
2266 | orig = data = RREG32(CGTS_SM_CTRL_REG); | ||
2267 | data |= LS_OVERRIDE | OVERRIDE; | ||
2268 | if (orig != data) | ||
2269 | WREG32(CGTS_SM_CTRL_REG, data); | ||
2270 | |||
2271 | tmp = gfx_v6_0_halt_rlc(adev); | ||
2272 | |||
2273 | WREG32(RLC_SERDES_WR_MASTER_MASK_0, 0xffffffff); | ||
2274 | WREG32(RLC_SERDES_WR_MASTER_MASK_1, 0xffffffff); | ||
2275 | WREG32(RLC_SERDES_WR_CTRL, 0x00e000ff); | ||
2276 | |||
2277 | gfx_v6_0_update_rlc(adev, tmp); | ||
2278 | } | ||
2279 | } | ||
2280 | /* | ||
2281 | static void gfx_v6_0_update_cg(struct amdgpu_device *adev, | ||
2282 | bool enable) | ||
2283 | { | ||
2284 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | ||
2285 | if (enable) { | ||
2286 | gfx_v6_0_enable_mgcg(adev, true); | ||
2287 | gfx_v6_0_enable_cgcg(adev, true); | ||
2288 | } else { | ||
2289 | gfx_v6_0_enable_cgcg(adev, false); | ||
2290 | gfx_v6_0_enable_mgcg(adev, false); | ||
2291 | } | ||
2292 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | ||
2293 | } | ||
2294 | */ | ||
2295 | static void gfx_v6_0_enable_sclk_slowdown_on_pu(struct amdgpu_device *adev, | ||
2296 | bool enable) | ||
2297 | { | ||
2298 | } | ||
2299 | |||
2300 | static void gfx_v6_0_enable_sclk_slowdown_on_pd(struct amdgpu_device *adev, | ||
2301 | bool enable) | ||
2302 | { | ||
2303 | } | ||
2304 | |||
2305 | static void gfx_v6_0_enable_cp_pg(struct amdgpu_device *adev, bool enable) | ||
2306 | { | ||
2307 | u32 data, orig; | ||
2308 | |||
2309 | orig = data = RREG32(RLC_PG_CNTL); | ||
2310 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_CP)) | ||
2311 | data &= ~0x8000; | ||
2312 | else | ||
2313 | data |= 0x8000; | ||
2314 | if (orig != data) | ||
2315 | WREG32(RLC_PG_CNTL, data); | ||
2316 | } | ||
2317 | |||
2318 | static void gfx_v6_0_enable_gds_pg(struct amdgpu_device *adev, bool enable) | ||
2319 | { | ||
2320 | } | ||
2321 | /* | ||
2322 | static void gfx_v6_0_init_cp_pg_table(struct amdgpu_device *adev) | ||
2323 | { | ||
2324 | const __le32 *fw_data; | ||
2325 | volatile u32 *dst_ptr; | ||
2326 | int me, i, max_me = 4; | ||
2327 | u32 bo_offset = 0; | ||
2328 | u32 table_offset, table_size; | ||
2329 | |||
2330 | if (adev->asic_type == CHIP_KAVERI) | ||
2331 | max_me = 5; | ||
2332 | |||
2333 | if (adev->gfx.rlc.cp_table_ptr == NULL) | ||
2334 | return; | ||
2335 | |||
2336 | dst_ptr = adev->gfx.rlc.cp_table_ptr; | ||
2337 | for (me = 0; me < max_me; me++) { | ||
2338 | if (me == 0) { | ||
2339 | const struct gfx_firmware_header_v1_0 *hdr = | ||
2340 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | ||
2341 | fw_data = (const __le32 *) | ||
2342 | (adev->gfx.ce_fw->data + | ||
2343 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
2344 | table_offset = le32_to_cpu(hdr->jt_offset); | ||
2345 | table_size = le32_to_cpu(hdr->jt_size); | ||
2346 | } else if (me == 1) { | ||
2347 | const struct gfx_firmware_header_v1_0 *hdr = | ||
2348 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | ||
2349 | fw_data = (const __le32 *) | ||
2350 | (adev->gfx.pfp_fw->data + | ||
2351 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
2352 | table_offset = le32_to_cpu(hdr->jt_offset); | ||
2353 | table_size = le32_to_cpu(hdr->jt_size); | ||
2354 | } else if (me == 2) { | ||
2355 | const struct gfx_firmware_header_v1_0 *hdr = | ||
2356 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | ||
2357 | fw_data = (const __le32 *) | ||
2358 | (adev->gfx.me_fw->data + | ||
2359 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
2360 | table_offset = le32_to_cpu(hdr->jt_offset); | ||
2361 | table_size = le32_to_cpu(hdr->jt_size); | ||
2362 | } else if (me == 3) { | ||
2363 | const struct gfx_firmware_header_v1_0 *hdr = | ||
2364 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; | ||
2365 | fw_data = (const __le32 *) | ||
2366 | (adev->gfx.mec_fw->data + | ||
2367 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
2368 | table_offset = le32_to_cpu(hdr->jt_offset); | ||
2369 | table_size = le32_to_cpu(hdr->jt_size); | ||
2370 | } else { | ||
2371 | const struct gfx_firmware_header_v1_0 *hdr = | ||
2372 | (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data; | ||
2373 | fw_data = (const __le32 *) | ||
2374 | (adev->gfx.mec2_fw->data + | ||
2375 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
2376 | table_offset = le32_to_cpu(hdr->jt_offset); | ||
2377 | table_size = le32_to_cpu(hdr->jt_size); | ||
2378 | } | ||
2379 | |||
2380 | for (i = 0; i < table_size; i ++) { | ||
2381 | dst_ptr[bo_offset + i] = | ||
2382 | cpu_to_le32(le32_to_cpu(fw_data[table_offset + i])); | ||
2383 | } | ||
2384 | |||
2385 | bo_offset += table_size; | ||
2386 | } | ||
2387 | } | ||
2388 | */ | ||
2389 | static void gfx_v6_0_enable_gfx_cgpg(struct amdgpu_device *adev, | ||
2390 | bool enable) | ||
2391 | { | ||
2392 | |||
2393 | u32 tmp; | ||
2394 | |||
2395 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) { | ||
2396 | tmp = RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10); | ||
2397 | WREG32(RLC_TTOP_D, tmp); | ||
2398 | |||
2399 | tmp = RREG32(RLC_PG_CNTL); | ||
2400 | tmp |= GFX_PG_ENABLE; | ||
2401 | WREG32(RLC_PG_CNTL, tmp); | ||
2402 | |||
2403 | tmp = RREG32(RLC_AUTO_PG_CTRL); | ||
2404 | tmp |= AUTO_PG_EN; | ||
2405 | WREG32(RLC_AUTO_PG_CTRL, tmp); | ||
2406 | } else { | ||
2407 | tmp = RREG32(RLC_AUTO_PG_CTRL); | ||
2408 | tmp &= ~AUTO_PG_EN; | ||
2409 | WREG32(RLC_AUTO_PG_CTRL, tmp); | ||
2410 | |||
2411 | tmp = RREG32(DB_RENDER_CONTROL); | ||
2412 | } | ||
2413 | } | ||
2414 | |||
2415 | static u32 gfx_v6_0_get_cu_active_bitmap(struct amdgpu_device *adev, | ||
2416 | u32 se, u32 sh) | ||
2417 | { | ||
2418 | |||
2419 | u32 mask = 0, tmp, tmp1; | ||
2420 | int i; | ||
2421 | |||
2422 | mutex_lock(&adev->grbm_idx_mutex); | ||
2423 | gfx_v6_0_select_se_sh(adev, se, sh, 0xffffffff); | ||
2424 | tmp = RREG32(CC_GC_SHADER_ARRAY_CONFIG); | ||
2425 | tmp1 = RREG32(GC_USER_SHADER_ARRAY_CONFIG); | ||
2426 | gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
2427 | mutex_unlock(&adev->grbm_idx_mutex); | ||
2428 | |||
2429 | tmp &= 0xffff0000; | ||
2430 | |||
2431 | tmp |= tmp1; | ||
2432 | tmp >>= 16; | ||
2433 | |||
2434 | for (i = 0; i < adev->gfx.config.max_cu_per_sh; i ++) { | ||
2435 | mask <<= 1; | ||
2436 | mask |= 1; | ||
2437 | } | ||
2438 | |||
2439 | return (~tmp) & mask; | ||
2440 | } | ||
2441 | |||
2442 | static void gfx_v6_0_init_ao_cu_mask(struct amdgpu_device *adev) | ||
2443 | { | ||
2444 | u32 i, j, k, active_cu_number = 0; | ||
2445 | |||
2446 | u32 mask, counter, cu_bitmap; | ||
2447 | u32 tmp = 0; | ||
2448 | |||
2449 | for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { | ||
2450 | for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { | ||
2451 | mask = 1; | ||
2452 | cu_bitmap = 0; | ||
2453 | counter = 0; | ||
2454 | for (k = 0; k < adev->gfx.config.max_cu_per_sh; k++) { | ||
2455 | if (gfx_v6_0_get_cu_active_bitmap(adev, i, j) & mask) { | ||
2456 | if (counter < 2) | ||
2457 | cu_bitmap |= mask; | ||
2458 | counter++; | ||
2459 | } | ||
2460 | mask <<= 1; | ||
2461 | } | ||
2462 | |||
2463 | active_cu_number += counter; | ||
2464 | tmp |= (cu_bitmap << (i * 16 + j * 8)); | ||
2465 | } | ||
2466 | } | ||
2467 | |||
2468 | WREG32(RLC_PG_AO_CU_MASK, tmp); | ||
2469 | |||
2470 | tmp = RREG32(RLC_MAX_PG_CU); | ||
2471 | tmp &= ~MAX_PU_CU_MASK; | ||
2472 | tmp |= MAX_PU_CU(active_cu_number); | ||
2473 | WREG32(RLC_MAX_PG_CU, tmp); | ||
2474 | } | ||
2475 | |||
2476 | static void gfx_v6_0_enable_gfx_static_mgpg(struct amdgpu_device *adev, | ||
2477 | bool enable) | ||
2478 | { | ||
2479 | u32 data, orig; | ||
2480 | |||
2481 | orig = data = RREG32(RLC_PG_CNTL); | ||
2482 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG)) | ||
2483 | data |= STATIC_PER_CU_PG_ENABLE; | ||
2484 | else | ||
2485 | data &= ~STATIC_PER_CU_PG_ENABLE; | ||
2486 | if (orig != data) | ||
2487 | WREG32(RLC_PG_CNTL, data); | ||
2488 | } | ||
2489 | |||
2490 | static void gfx_v6_0_enable_gfx_dynamic_mgpg(struct amdgpu_device *adev, | ||
2491 | bool enable) | ||
2492 | { | ||
2493 | u32 data, orig; | ||
2494 | |||
2495 | orig = data = RREG32(RLC_PG_CNTL); | ||
2496 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_DMG)) | ||
2497 | data |= DYN_PER_CU_PG_ENABLE; | ||
2498 | else | ||
2499 | data &= ~DYN_PER_CU_PG_ENABLE; | ||
2500 | if (orig != data) | ||
2501 | WREG32(RLC_PG_CNTL, data); | ||
2502 | } | ||
2503 | |||
2504 | static void gfx_v6_0_init_gfx_cgpg(struct amdgpu_device *adev) | ||
2505 | { | ||
2506 | u32 tmp; | ||
2507 | |||
2508 | WREG32(RLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8); | ||
2509 | |||
2510 | tmp = RREG32(RLC_PG_CNTL); | ||
2511 | tmp |= GFX_PG_SRC; | ||
2512 | WREG32(RLC_PG_CNTL, tmp); | ||
2513 | |||
2514 | WREG32(RLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8); | ||
2515 | |||
2516 | tmp = RREG32(RLC_AUTO_PG_CTRL); | ||
2517 | |||
2518 | tmp &= ~GRBM_REG_SGIT_MASK; | ||
2519 | tmp |= GRBM_REG_SGIT(0x700); | ||
2520 | tmp &= ~PG_AFTER_GRBM_REG_ST_MASK; | ||
2521 | WREG32(RLC_AUTO_PG_CTRL, tmp); | ||
2522 | } | ||
2523 | |||
2524 | static void gfx_v6_0_update_gfx_pg(struct amdgpu_device *adev, bool enable) | ||
2525 | { | ||
2526 | gfx_v6_0_enable_gfx_cgpg(adev, enable); | ||
2527 | gfx_v6_0_enable_gfx_static_mgpg(adev, enable); | ||
2528 | gfx_v6_0_enable_gfx_dynamic_mgpg(adev, enable); | ||
2529 | } | ||
2530 | |||
2531 | static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev) | ||
2532 | { | ||
2533 | u32 count = 0; | ||
2534 | const struct cs_section_def *sect = NULL; | ||
2535 | const struct cs_extent_def *ext = NULL; | ||
2536 | |||
2537 | if (adev->gfx.rlc.cs_data == NULL) | ||
2538 | return 0; | ||
2539 | |||
2540 | /* begin clear state */ | ||
2541 | count += 2; | ||
2542 | /* context control state */ | ||
2543 | count += 3; | ||
2544 | |||
2545 | for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { | ||
2546 | for (ext = sect->section; ext->extent != NULL; ++ext) { | ||
2547 | if (sect->id == SECT_CONTEXT) | ||
2548 | count += 2 + ext->reg_count; | ||
2549 | else | ||
2550 | return 0; | ||
2551 | } | ||
2552 | } | ||
2553 | /* pa_sc_raster_config */ | ||
2554 | count += 3; | ||
2555 | /* end clear state */ | ||
2556 | count += 2; | ||
2557 | /* clear state */ | ||
2558 | count += 2; | ||
2559 | |||
2560 | return count; | ||
2561 | } | ||
2562 | |||
2563 | static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev, | ||
2564 | volatile u32 *buffer) | ||
2565 | { | ||
2566 | u32 count = 0, i; | ||
2567 | const struct cs_section_def *sect = NULL; | ||
2568 | const struct cs_extent_def *ext = NULL; | ||
2569 | |||
2570 | if (adev->gfx.rlc.cs_data == NULL) | ||
2571 | return; | ||
2572 | if (buffer == NULL) | ||
2573 | return; | ||
2574 | |||
2575 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | ||
2576 | buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); | ||
2577 | |||
2578 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL, 1)); | ||
2579 | buffer[count++] = cpu_to_le32(0x80000000); | ||
2580 | buffer[count++] = cpu_to_le32(0x80000000); | ||
2581 | |||
2582 | for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { | ||
2583 | for (ext = sect->section; ext->extent != NULL; ++ext) { | ||
2584 | if (sect->id == SECT_CONTEXT) { | ||
2585 | buffer[count++] = | ||
2586 | cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); | ||
2587 | buffer[count++] = cpu_to_le32(ext->reg_index - 0xa000); | ||
2588 | for (i = 0; i < ext->reg_count; i++) | ||
2589 | buffer[count++] = cpu_to_le32(ext->extent[i]); | ||
2590 | } else { | ||
2591 | return; | ||
2592 | } | ||
2593 | } | ||
2594 | } | ||
2595 | |||
2596 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, 1)); | ||
2597 | buffer[count++] = cpu_to_le32(PA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START); | ||
2598 | |||
2599 | switch (adev->asic_type) { | ||
2600 | case CHIP_TAHITI: | ||
2601 | case CHIP_PITCAIRN: | ||
2602 | buffer[count++] = cpu_to_le32(0x2a00126a); | ||
2603 | break; | ||
2604 | case CHIP_VERDE: | ||
2605 | buffer[count++] = cpu_to_le32(0x0000124a); | ||
2606 | break; | ||
2607 | case CHIP_OLAND: | ||
2608 | buffer[count++] = cpu_to_le32(0x00000082); | ||
2609 | break; | ||
2610 | case CHIP_HAINAN: | ||
2611 | buffer[count++] = cpu_to_le32(0x00000000); | ||
2612 | break; | ||
2613 | default: | ||
2614 | buffer[count++] = cpu_to_le32(0x00000000); | ||
2615 | break; | ||
2616 | } | ||
2617 | |||
2618 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); | ||
2619 | buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE); | ||
2620 | |||
2621 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0)); | ||
2622 | buffer[count++] = cpu_to_le32(0); | ||
2623 | } | ||
2624 | |||
2625 | static void gfx_v6_0_init_pg(struct amdgpu_device *adev) | ||
2626 | { | ||
2627 | if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | | ||
2628 | AMD_PG_SUPPORT_GFX_SMG | | ||
2629 | AMD_PG_SUPPORT_GFX_DMG | | ||
2630 | AMD_PG_SUPPORT_CP | | ||
2631 | AMD_PG_SUPPORT_GDS | | ||
2632 | AMD_PG_SUPPORT_RLC_SMU_HS)) { | ||
2633 | gfx_v6_0_enable_sclk_slowdown_on_pu(adev, true); | ||
2634 | gfx_v6_0_enable_sclk_slowdown_on_pd(adev, true); | ||
2635 | if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) { | ||
2636 | gfx_v6_0_init_gfx_cgpg(adev); | ||
2637 | gfx_v6_0_enable_cp_pg(adev, true); | ||
2638 | gfx_v6_0_enable_gds_pg(adev, true); | ||
2639 | } else { | ||
2640 | WREG32(RLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8); | ||
2641 | WREG32(RLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8); | ||
2642 | |||
2643 | } | ||
2644 | gfx_v6_0_init_ao_cu_mask(adev); | ||
2645 | gfx_v6_0_update_gfx_pg(adev, true); | ||
2646 | } else { | ||
2647 | |||
2648 | WREG32(RLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8); | ||
2649 | WREG32(RLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8); | ||
2650 | } | ||
2651 | } | ||
2652 | |||
2653 | static void gfx_v6_0_fini_pg(struct amdgpu_device *adev) | ||
2654 | { | ||
2655 | if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | | ||
2656 | AMD_PG_SUPPORT_GFX_SMG | | ||
2657 | AMD_PG_SUPPORT_GFX_DMG | | ||
2658 | AMD_PG_SUPPORT_CP | | ||
2659 | AMD_PG_SUPPORT_GDS | | ||
2660 | AMD_PG_SUPPORT_RLC_SMU_HS)) { | ||
2661 | gfx_v6_0_update_gfx_pg(adev, false); | ||
2662 | if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) { | ||
2663 | gfx_v6_0_enable_cp_pg(adev, false); | ||
2664 | gfx_v6_0_enable_gds_pg(adev, false); | ||
2665 | } | ||
2666 | } | ||
2667 | } | ||
2668 | |||
2669 | static uint64_t gfx_v6_0_get_gpu_clock_counter(struct amdgpu_device *adev) | ||
2670 | { | ||
2671 | uint64_t clock; | ||
2672 | |||
2673 | mutex_lock(&adev->gfx.gpu_clock_mutex); | ||
2674 | WREG32(RLC_CAPTURE_GPU_CLOCK_COUNT, 1); | ||
2675 | clock = (uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_LSB) | | ||
2676 | ((uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_MSB) << 32ULL); | ||
2677 | mutex_unlock(&adev->gfx.gpu_clock_mutex); | ||
2678 | return clock; | ||
2679 | } | ||
2680 | |||
2681 | static void gfx_v6_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) | ||
2682 | { | ||
2683 | amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); | ||
2684 | amdgpu_ring_write(ring, 0x80000000); | ||
2685 | amdgpu_ring_write(ring, 0); | ||
2686 | } | ||
2687 | |||
2688 | static unsigned gfx_v6_0_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
2689 | { | ||
2690 | return | ||
2691 | 6; /* gfx_v6_0_ring_emit_ib */ | ||
2692 | } | ||
2693 | |||
2694 | static unsigned gfx_v6_0_ring_get_dma_frame_size_gfx(struct amdgpu_ring *ring) | ||
2695 | { | ||
2696 | return | ||
2697 | 5 + /* gfx_v6_0_ring_emit_hdp_flush */ | ||
2698 | 5 + /* gfx_v6_0_ring_emit_hdp_invalidate */ | ||
2699 | 14 + 14 + 14 + /* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ | ||
2700 | 7 + 4 + /* gfx_v6_0_ring_emit_pipeline_sync */ | ||
2701 | 17 + 6 + /* gfx_v6_0_ring_emit_vm_flush */ | ||
2702 | 3; /* gfx_v6_ring_emit_cntxcntl */ | ||
2703 | } | ||
2704 | |||
2705 | static unsigned gfx_v6_0_ring_get_dma_frame_size_compute(struct amdgpu_ring *ring) | ||
2706 | { | ||
2707 | return | ||
2708 | 5 + /* gfx_v6_0_ring_emit_hdp_flush */ | ||
2709 | 5 + /* gfx_v6_0_ring_emit_hdp_invalidate */ | ||
2710 | 7 + /* gfx_v6_0_ring_emit_pipeline_sync */ | ||
2711 | 17 + /* gfx_v6_0_ring_emit_vm_flush */ | ||
2712 | 14 + 14 + 14; /* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ | ||
2713 | } | ||
2714 | |||
2715 | static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs = { | ||
2716 | .get_gpu_clock_counter = &gfx_v6_0_get_gpu_clock_counter, | ||
2717 | .select_se_sh = &gfx_v6_0_select_se_sh, | ||
2718 | }; | ||
2719 | |||
2720 | static int gfx_v6_0_early_init(void *handle) | ||
2721 | { | ||
2722 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2723 | |||
2724 | adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS; | ||
2725 | adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS; | ||
2726 | adev->gfx.funcs = &gfx_v6_0_gfx_funcs; | ||
2727 | gfx_v6_0_set_ring_funcs(adev); | ||
2728 | gfx_v6_0_set_irq_funcs(adev); | ||
2729 | |||
2730 | return 0; | ||
2731 | } | ||
2732 | |||
2733 | static int gfx_v6_0_sw_init(void *handle) | ||
2734 | { | ||
2735 | struct amdgpu_ring *ring; | ||
2736 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2737 | int i, r; | ||
2738 | |||
2739 | r = amdgpu_irq_add_id(adev, 181, &adev->gfx.eop_irq); | ||
2740 | if (r) | ||
2741 | return r; | ||
2742 | |||
2743 | r = amdgpu_irq_add_id(adev, 184, &adev->gfx.priv_reg_irq); | ||
2744 | if (r) | ||
2745 | return r; | ||
2746 | |||
2747 | r = amdgpu_irq_add_id(adev, 185, &adev->gfx.priv_inst_irq); | ||
2748 | if (r) | ||
2749 | return r; | ||
2750 | |||
2751 | gfx_v6_0_scratch_init(adev); | ||
2752 | |||
2753 | r = gfx_v6_0_init_microcode(adev); | ||
2754 | if (r) { | ||
2755 | DRM_ERROR("Failed to load gfx firmware!\n"); | ||
2756 | return r; | ||
2757 | } | ||
2758 | |||
2759 | r = gfx_v6_0_rlc_init(adev); | ||
2760 | if (r) { | ||
2761 | DRM_ERROR("Failed to init rlc BOs!\n"); | ||
2762 | return r; | ||
2763 | } | ||
2764 | |||
2765 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) { | ||
2766 | ring = &adev->gfx.gfx_ring[i]; | ||
2767 | ring->ring_obj = NULL; | ||
2768 | sprintf(ring->name, "gfx"); | ||
2769 | r = amdgpu_ring_init(adev, ring, 1024, | ||
2770 | 0x80000000, 0xf, | ||
2771 | &adev->gfx.eop_irq, AMDGPU_CP_IRQ_GFX_EOP, | ||
2772 | AMDGPU_RING_TYPE_GFX); | ||
2773 | if (r) | ||
2774 | return r; | ||
2775 | } | ||
2776 | |||
2777 | for (i = 0; i < adev->gfx.num_compute_rings; i++) { | ||
2778 | unsigned irq_type; | ||
2779 | |||
2780 | if ((i >= 32) || (i >= AMDGPU_MAX_COMPUTE_RINGS)) { | ||
2781 | DRM_ERROR("Too many (%d) compute rings!\n", i); | ||
2782 | break; | ||
2783 | } | ||
2784 | ring = &adev->gfx.compute_ring[i]; | ||
2785 | ring->ring_obj = NULL; | ||
2786 | ring->use_doorbell = false; | ||
2787 | ring->doorbell_index = 0; | ||
2788 | ring->me = 1; | ||
2789 | ring->pipe = i; | ||
2790 | ring->queue = i; | ||
2791 | sprintf(ring->name, "comp %d.%d.%d", ring->me, ring->pipe, ring->queue); | ||
2792 | irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + ring->pipe; | ||
2793 | r = amdgpu_ring_init(adev, ring, 1024, | ||
2794 | 0x80000000, 0xf, | ||
2795 | &adev->gfx.eop_irq, irq_type, | ||
2796 | AMDGPU_RING_TYPE_COMPUTE); | ||
2797 | if (r) | ||
2798 | return r; | ||
2799 | } | ||
2800 | |||
2801 | return r; | ||
2802 | } | ||
2803 | |||
2804 | static int gfx_v6_0_sw_fini(void *handle) | ||
2805 | { | ||
2806 | int i; | ||
2807 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2808 | |||
2809 | amdgpu_bo_unref(&adev->gds.oa_gfx_bo); | ||
2810 | amdgpu_bo_unref(&adev->gds.gws_gfx_bo); | ||
2811 | amdgpu_bo_unref(&adev->gds.gds_gfx_bo); | ||
2812 | |||
2813 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | ||
2814 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); | ||
2815 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | ||
2816 | amdgpu_ring_fini(&adev->gfx.compute_ring[i]); | ||
2817 | |||
2818 | gfx_v6_0_rlc_fini(adev); | ||
2819 | |||
2820 | return 0; | ||
2821 | } | ||
2822 | |||
2823 | static int gfx_v6_0_hw_init(void *handle) | ||
2824 | { | ||
2825 | int r; | ||
2826 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2827 | |||
2828 | gfx_v6_0_gpu_init(adev); | ||
2829 | |||
2830 | r = gfx_v6_0_rlc_resume(adev); | ||
2831 | if (r) | ||
2832 | return r; | ||
2833 | |||
2834 | r = gfx_v6_0_cp_resume(adev); | ||
2835 | if (r) | ||
2836 | return r; | ||
2837 | |||
2838 | adev->gfx.ce_ram_size = 0x8000; | ||
2839 | |||
2840 | return r; | ||
2841 | } | ||
2842 | |||
2843 | static int gfx_v6_0_hw_fini(void *handle) | ||
2844 | { | ||
2845 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2846 | |||
2847 | gfx_v6_0_cp_enable(adev, false); | ||
2848 | gfx_v6_0_rlc_stop(adev); | ||
2849 | gfx_v6_0_fini_pg(adev); | ||
2850 | |||
2851 | return 0; | ||
2852 | } | ||
2853 | |||
2854 | static int gfx_v6_0_suspend(void *handle) | ||
2855 | { | ||
2856 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2857 | |||
2858 | return gfx_v6_0_hw_fini(adev); | ||
2859 | } | ||
2860 | |||
2861 | static int gfx_v6_0_resume(void *handle) | ||
2862 | { | ||
2863 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2864 | |||
2865 | return gfx_v6_0_hw_init(adev); | ||
2866 | } | ||
2867 | |||
2868 | static bool gfx_v6_0_is_idle(void *handle) | ||
2869 | { | ||
2870 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2871 | |||
2872 | if (RREG32(GRBM_STATUS) & GRBM_STATUS__GUI_ACTIVE_MASK) | ||
2873 | return false; | ||
2874 | else | ||
2875 | return true; | ||
2876 | } | ||
2877 | |||
2878 | static int gfx_v6_0_wait_for_idle(void *handle) | ||
2879 | { | ||
2880 | unsigned i; | ||
2881 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2882 | |||
2883 | for (i = 0; i < adev->usec_timeout; i++) { | ||
2884 | if (gfx_v6_0_is_idle(handle)) | ||
2885 | return 0; | ||
2886 | udelay(1); | ||
2887 | } | ||
2888 | return -ETIMEDOUT; | ||
2889 | } | ||
2890 | |||
2891 | static int gfx_v6_0_soft_reset(void *handle) | ||
2892 | { | ||
2893 | return 0; | ||
2894 | } | ||
2895 | |||
2896 | static void gfx_v6_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, | ||
2897 | enum amdgpu_interrupt_state state) | ||
2898 | { | ||
2899 | u32 cp_int_cntl; | ||
2900 | |||
2901 | switch (state) { | ||
2902 | case AMDGPU_IRQ_STATE_DISABLE: | ||
2903 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0); | ||
2904 | cp_int_cntl &= ~CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK; | ||
2905 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); | ||
2906 | break; | ||
2907 | case AMDGPU_IRQ_STATE_ENABLE: | ||
2908 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0); | ||
2909 | cp_int_cntl |= CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK; | ||
2910 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); | ||
2911 | break; | ||
2912 | default: | ||
2913 | break; | ||
2914 | } | ||
2915 | } | ||
2916 | |||
2917 | static void gfx_v6_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev, | ||
2918 | int ring, | ||
2919 | enum amdgpu_interrupt_state state) | ||
2920 | { | ||
2921 | u32 cp_int_cntl; | ||
2922 | switch (state){ | ||
2923 | case AMDGPU_IRQ_STATE_DISABLE: | ||
2924 | if (ring == 0) { | ||
2925 | cp_int_cntl = RREG32(CP_INT_CNTL_RING1); | ||
2926 | cp_int_cntl &= ~CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK; | ||
2927 | WREG32(CP_INT_CNTL_RING1, cp_int_cntl); | ||
2928 | break; | ||
2929 | } else { | ||
2930 | cp_int_cntl = RREG32(CP_INT_CNTL_RING2); | ||
2931 | cp_int_cntl &= ~CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK; | ||
2932 | WREG32(CP_INT_CNTL_RING2, cp_int_cntl); | ||
2933 | break; | ||
2934 | |||
2935 | } | ||
2936 | case AMDGPU_IRQ_STATE_ENABLE: | ||
2937 | if (ring == 0) { | ||
2938 | cp_int_cntl = RREG32(CP_INT_CNTL_RING1); | ||
2939 | cp_int_cntl |= CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK; | ||
2940 | WREG32(CP_INT_CNTL_RING1, cp_int_cntl); | ||
2941 | break; | ||
2942 | } else { | ||
2943 | cp_int_cntl = RREG32(CP_INT_CNTL_RING2); | ||
2944 | cp_int_cntl |= CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK; | ||
2945 | WREG32(CP_INT_CNTL_RING2, cp_int_cntl); | ||
2946 | break; | ||
2947 | |||
2948 | } | ||
2949 | |||
2950 | default: | ||
2951 | BUG(); | ||
2952 | break; | ||
2953 | |||
2954 | } | ||
2955 | } | ||
2956 | |||
2957 | static int gfx_v6_0_set_priv_reg_fault_state(struct amdgpu_device *adev, | ||
2958 | struct amdgpu_irq_src *src, | ||
2959 | unsigned type, | ||
2960 | enum amdgpu_interrupt_state state) | ||
2961 | { | ||
2962 | u32 cp_int_cntl; | ||
2963 | |||
2964 | switch (state) { | ||
2965 | case AMDGPU_IRQ_STATE_DISABLE: | ||
2966 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0); | ||
2967 | cp_int_cntl &= ~CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK; | ||
2968 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); | ||
2969 | break; | ||
2970 | case AMDGPU_IRQ_STATE_ENABLE: | ||
2971 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0); | ||
2972 | cp_int_cntl |= CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK; | ||
2973 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); | ||
2974 | break; | ||
2975 | default: | ||
2976 | break; | ||
2977 | } | ||
2978 | |||
2979 | return 0; | ||
2980 | } | ||
2981 | |||
2982 | static int gfx_v6_0_set_priv_inst_fault_state(struct amdgpu_device *adev, | ||
2983 | struct amdgpu_irq_src *src, | ||
2984 | unsigned type, | ||
2985 | enum amdgpu_interrupt_state state) | ||
2986 | { | ||
2987 | u32 cp_int_cntl; | ||
2988 | |||
2989 | switch (state) { | ||
2990 | case AMDGPU_IRQ_STATE_DISABLE: | ||
2991 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0); | ||
2992 | cp_int_cntl &= ~CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK; | ||
2993 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); | ||
2994 | break; | ||
2995 | case AMDGPU_IRQ_STATE_ENABLE: | ||
2996 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0); | ||
2997 | cp_int_cntl |= CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK; | ||
2998 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); | ||
2999 | break; | ||
3000 | default: | ||
3001 | break; | ||
3002 | } | ||
3003 | |||
3004 | return 0; | ||
3005 | } | ||
3006 | |||
3007 | static int gfx_v6_0_set_eop_interrupt_state(struct amdgpu_device *adev, | ||
3008 | struct amdgpu_irq_src *src, | ||
3009 | unsigned type, | ||
3010 | enum amdgpu_interrupt_state state) | ||
3011 | { | ||
3012 | switch (type) { | ||
3013 | case AMDGPU_CP_IRQ_GFX_EOP: | ||
3014 | gfx_v6_0_set_gfx_eop_interrupt_state(adev, state); | ||
3015 | break; | ||
3016 | case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP: | ||
3017 | gfx_v6_0_set_compute_eop_interrupt_state(adev, 0, state); | ||
3018 | break; | ||
3019 | case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE1_EOP: | ||
3020 | gfx_v6_0_set_compute_eop_interrupt_state(adev, 1, state); | ||
3021 | break; | ||
3022 | default: | ||
3023 | break; | ||
3024 | } | ||
3025 | return 0; | ||
3026 | } | ||
3027 | |||
3028 | static int gfx_v6_0_eop_irq(struct amdgpu_device *adev, | ||
3029 | struct amdgpu_irq_src *source, | ||
3030 | struct amdgpu_iv_entry *entry) | ||
3031 | { | ||
3032 | switch (entry->ring_id) { | ||
3033 | case 0: | ||
3034 | amdgpu_fence_process(&adev->gfx.gfx_ring[0]); | ||
3035 | break; | ||
3036 | case 1: | ||
3037 | case 2: | ||
3038 | amdgpu_fence_process(&adev->gfx.compute_ring[entry->ring_id -1]); | ||
3039 | break; | ||
3040 | default: | ||
3041 | break; | ||
3042 | } | ||
3043 | return 0; | ||
3044 | } | ||
3045 | |||
3046 | static int gfx_v6_0_priv_reg_irq(struct amdgpu_device *adev, | ||
3047 | struct amdgpu_irq_src *source, | ||
3048 | struct amdgpu_iv_entry *entry) | ||
3049 | { | ||
3050 | DRM_ERROR("Illegal register access in command stream\n"); | ||
3051 | schedule_work(&adev->reset_work); | ||
3052 | return 0; | ||
3053 | } | ||
3054 | |||
3055 | static int gfx_v6_0_priv_inst_irq(struct amdgpu_device *adev, | ||
3056 | struct amdgpu_irq_src *source, | ||
3057 | struct amdgpu_iv_entry *entry) | ||
3058 | { | ||
3059 | DRM_ERROR("Illegal instruction in command stream\n"); | ||
3060 | schedule_work(&adev->reset_work); | ||
3061 | return 0; | ||
3062 | } | ||
3063 | |||
3064 | static int gfx_v6_0_set_clockgating_state(void *handle, | ||
3065 | enum amd_clockgating_state state) | ||
3066 | { | ||
3067 | bool gate = false; | ||
3068 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
3069 | |||
3070 | if (state == AMD_CG_STATE_GATE) | ||
3071 | gate = true; | ||
3072 | |||
3073 | gfx_v6_0_enable_gui_idle_interrupt(adev, false); | ||
3074 | if (gate) { | ||
3075 | gfx_v6_0_enable_mgcg(adev, true); | ||
3076 | gfx_v6_0_enable_cgcg(adev, true); | ||
3077 | } else { | ||
3078 | gfx_v6_0_enable_cgcg(adev, false); | ||
3079 | gfx_v6_0_enable_mgcg(adev, false); | ||
3080 | } | ||
3081 | gfx_v6_0_enable_gui_idle_interrupt(adev, true); | ||
3082 | |||
3083 | return 0; | ||
3084 | } | ||
3085 | |||
3086 | static int gfx_v6_0_set_powergating_state(void *handle, | ||
3087 | enum amd_powergating_state state) | ||
3088 | { | ||
3089 | bool gate = false; | ||
3090 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
3091 | |||
3092 | if (state == AMD_PG_STATE_GATE) | ||
3093 | gate = true; | ||
3094 | |||
3095 | if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | | ||
3096 | AMD_PG_SUPPORT_GFX_SMG | | ||
3097 | AMD_PG_SUPPORT_GFX_DMG | | ||
3098 | AMD_PG_SUPPORT_CP | | ||
3099 | AMD_PG_SUPPORT_GDS | | ||
3100 | AMD_PG_SUPPORT_RLC_SMU_HS)) { | ||
3101 | gfx_v6_0_update_gfx_pg(adev, gate); | ||
3102 | if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) { | ||
3103 | gfx_v6_0_enable_cp_pg(adev, gate); | ||
3104 | gfx_v6_0_enable_gds_pg(adev, gate); | ||
3105 | } | ||
3106 | } | ||
3107 | |||
3108 | return 0; | ||
3109 | } | ||
3110 | |||
3111 | const struct amd_ip_funcs gfx_v6_0_ip_funcs = { | ||
3112 | .name = "gfx_v6_0", | ||
3113 | .early_init = gfx_v6_0_early_init, | ||
3114 | .late_init = NULL, | ||
3115 | .sw_init = gfx_v6_0_sw_init, | ||
3116 | .sw_fini = gfx_v6_0_sw_fini, | ||
3117 | .hw_init = gfx_v6_0_hw_init, | ||
3118 | .hw_fini = gfx_v6_0_hw_fini, | ||
3119 | .suspend = gfx_v6_0_suspend, | ||
3120 | .resume = gfx_v6_0_resume, | ||
3121 | .is_idle = gfx_v6_0_is_idle, | ||
3122 | .wait_for_idle = gfx_v6_0_wait_for_idle, | ||
3123 | .soft_reset = gfx_v6_0_soft_reset, | ||
3124 | .set_clockgating_state = gfx_v6_0_set_clockgating_state, | ||
3125 | .set_powergating_state = gfx_v6_0_set_powergating_state, | ||
3126 | }; | ||
3127 | |||
3128 | static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = { | ||
3129 | .get_rptr = gfx_v6_0_ring_get_rptr, | ||
3130 | .get_wptr = gfx_v6_0_ring_get_wptr, | ||
3131 | .set_wptr = gfx_v6_0_ring_set_wptr_gfx, | ||
3132 | .parse_cs = NULL, | ||
3133 | .emit_ib = gfx_v6_0_ring_emit_ib, | ||
3134 | .emit_fence = gfx_v6_0_ring_emit_fence, | ||
3135 | .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync, | ||
3136 | .emit_vm_flush = gfx_v6_0_ring_emit_vm_flush, | ||
3137 | .emit_hdp_flush = gfx_v6_0_ring_emit_hdp_flush, | ||
3138 | .emit_hdp_invalidate = gfx_v6_0_ring_emit_hdp_invalidate, | ||
3139 | .test_ring = gfx_v6_0_ring_test_ring, | ||
3140 | .test_ib = gfx_v6_0_ring_test_ib, | ||
3141 | .insert_nop = amdgpu_ring_insert_nop, | ||
3142 | .emit_cntxcntl = gfx_v6_ring_emit_cntxcntl, | ||
3143 | .get_emit_ib_size = gfx_v6_0_ring_get_emit_ib_size, | ||
3144 | .get_dma_frame_size = gfx_v6_0_ring_get_dma_frame_size_gfx, | ||
3145 | }; | ||
3146 | |||
3147 | static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_compute = { | ||
3148 | .get_rptr = gfx_v6_0_ring_get_rptr, | ||
3149 | .get_wptr = gfx_v6_0_ring_get_wptr, | ||
3150 | .set_wptr = gfx_v6_0_ring_set_wptr_compute, | ||
3151 | .parse_cs = NULL, | ||
3152 | .emit_ib = gfx_v6_0_ring_emit_ib, | ||
3153 | .emit_fence = gfx_v6_0_ring_emit_fence, | ||
3154 | .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync, | ||
3155 | .emit_vm_flush = gfx_v6_0_ring_emit_vm_flush, | ||
3156 | .emit_hdp_flush = gfx_v6_0_ring_emit_hdp_flush, | ||
3157 | .emit_hdp_invalidate = gfx_v6_0_ring_emit_hdp_invalidate, | ||
3158 | .test_ring = gfx_v6_0_ring_test_ring, | ||
3159 | .test_ib = gfx_v6_0_ring_test_ib, | ||
3160 | .insert_nop = amdgpu_ring_insert_nop, | ||
3161 | .get_emit_ib_size = gfx_v6_0_ring_get_emit_ib_size, | ||
3162 | .get_dma_frame_size = gfx_v6_0_ring_get_dma_frame_size_compute, | ||
3163 | }; | ||
3164 | |||
3165 | static void gfx_v6_0_set_ring_funcs(struct amdgpu_device *adev) | ||
3166 | { | ||
3167 | int i; | ||
3168 | |||
3169 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | ||
3170 | adev->gfx.gfx_ring[i].funcs = &gfx_v6_0_ring_funcs_gfx; | ||
3171 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | ||
3172 | adev->gfx.compute_ring[i].funcs = &gfx_v6_0_ring_funcs_compute; | ||
3173 | } | ||
3174 | |||
3175 | static const struct amdgpu_irq_src_funcs gfx_v6_0_eop_irq_funcs = { | ||
3176 | .set = gfx_v6_0_set_eop_interrupt_state, | ||
3177 | .process = gfx_v6_0_eop_irq, | ||
3178 | }; | ||
3179 | |||
3180 | static const struct amdgpu_irq_src_funcs gfx_v6_0_priv_reg_irq_funcs = { | ||
3181 | .set = gfx_v6_0_set_priv_reg_fault_state, | ||
3182 | .process = gfx_v6_0_priv_reg_irq, | ||
3183 | }; | ||
3184 | |||
3185 | static const struct amdgpu_irq_src_funcs gfx_v6_0_priv_inst_irq_funcs = { | ||
3186 | .set = gfx_v6_0_set_priv_inst_fault_state, | ||
3187 | .process = gfx_v6_0_priv_inst_irq, | ||
3188 | }; | ||
3189 | |||
3190 | static void gfx_v6_0_set_irq_funcs(struct amdgpu_device *adev) | ||
3191 | { | ||
3192 | adev->gfx.eop_irq.num_types = AMDGPU_CP_IRQ_LAST; | ||
3193 | adev->gfx.eop_irq.funcs = &gfx_v6_0_eop_irq_funcs; | ||
3194 | |||
3195 | adev->gfx.priv_reg_irq.num_types = 1; | ||
3196 | adev->gfx.priv_reg_irq.funcs = &gfx_v6_0_priv_reg_irq_funcs; | ||
3197 | |||
3198 | adev->gfx.priv_inst_irq.num_types = 1; | ||
3199 | adev->gfx.priv_inst_irq.funcs = &gfx_v6_0_priv_inst_irq_funcs; | ||
3200 | } | ||
3201 | |||
3202 | static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev) | ||
3203 | { | ||
3204 | int i, j, k, counter, active_cu_number = 0; | ||
3205 | u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0; | ||
3206 | struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info; | ||
3207 | |||
3208 | memset(cu_info, 0, sizeof(*cu_info)); | ||
3209 | |||
3210 | for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { | ||
3211 | for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { | ||
3212 | mask = 1; | ||
3213 | ao_bitmap = 0; | ||
3214 | counter = 0; | ||
3215 | bitmap = gfx_v6_0_get_cu_active_bitmap(adev, i, j); | ||
3216 | cu_info->bitmap[i][j] = bitmap; | ||
3217 | |||
3218 | for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) { | ||
3219 | if (bitmap & mask) { | ||
3220 | if (counter < 2) | ||
3221 | ao_bitmap |= mask; | ||
3222 | counter ++; | ||
3223 | } | ||
3224 | mask <<= 1; | ||
3225 | } | ||
3226 | active_cu_number += counter; | ||
3227 | ao_cu_mask |= (ao_bitmap << (i * 16 + j * 8)); | ||
3228 | } | ||
3229 | } | ||
3230 | |||
3231 | cu_info->number = active_cu_number; | ||
3232 | cu_info->ao_cu_mask = ao_cu_mask; | ||
3233 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.h b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.h new file mode 100644 index 000000000000..b9657e72b248 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __GFX_V6_0_H__ | ||
25 | #define __GFX_V6_0_H__ | ||
26 | |||
27 | extern const struct amd_ip_funcs gfx_v6_0_ip_funcs; | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index f4fbec3e224e..90102f123bb8 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
@@ -2096,6 +2096,25 @@ static void gfx_v7_0_ring_emit_ib_compute(struct amdgpu_ring *ring, | |||
2096 | amdgpu_ring_write(ring, control); | 2096 | amdgpu_ring_write(ring, control); |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | static void gfx_v7_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) | ||
2100 | { | ||
2101 | uint32_t dw2 = 0; | ||
2102 | |||
2103 | dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */ | ||
2104 | if (flags & AMDGPU_HAVE_CTX_SWITCH) { | ||
2105 | /* set load_global_config & load_global_uconfig */ | ||
2106 | dw2 |= 0x8001; | ||
2107 | /* set load_cs_sh_regs */ | ||
2108 | dw2 |= 0x01000000; | ||
2109 | /* set load_per_context_state & load_gfx_sh_regs */ | ||
2110 | dw2 |= 0x10002; | ||
2111 | } | ||
2112 | |||
2113 | amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); | ||
2114 | amdgpu_ring_write(ring, dw2); | ||
2115 | amdgpu_ring_write(ring, 0); | ||
2116 | } | ||
2117 | |||
2099 | /** | 2118 | /** |
2100 | * gfx_v7_0_ring_test_ib - basic ring IB test | 2119 | * gfx_v7_0_ring_test_ib - basic ring IB test |
2101 | * | 2120 | * |
@@ -2443,7 +2462,7 @@ static int gfx_v7_0_cp_gfx_resume(struct amdgpu_device *adev) | |||
2443 | return 0; | 2462 | return 0; |
2444 | } | 2463 | } |
2445 | 2464 | ||
2446 | static u32 gfx_v7_0_ring_get_rptr_gfx(struct amdgpu_ring *ring) | 2465 | static u32 gfx_v7_0_ring_get_rptr(struct amdgpu_ring *ring) |
2447 | { | 2466 | { |
2448 | return ring->adev->wb.wb[ring->rptr_offs]; | 2467 | return ring->adev->wb.wb[ring->rptr_offs]; |
2449 | } | 2468 | } |
@@ -2463,11 +2482,6 @@ static void gfx_v7_0_ring_set_wptr_gfx(struct amdgpu_ring *ring) | |||
2463 | (void)RREG32(mmCP_RB0_WPTR); | 2482 | (void)RREG32(mmCP_RB0_WPTR); |
2464 | } | 2483 | } |
2465 | 2484 | ||
2466 | static u32 gfx_v7_0_ring_get_rptr_compute(struct amdgpu_ring *ring) | ||
2467 | { | ||
2468 | return ring->adev->wb.wb[ring->rptr_offs]; | ||
2469 | } | ||
2470 | |||
2471 | static u32 gfx_v7_0_ring_get_wptr_compute(struct amdgpu_ring *ring) | 2485 | static u32 gfx_v7_0_ring_get_wptr_compute(struct amdgpu_ring *ring) |
2472 | { | 2486 | { |
2473 | /* XXX check if swapping is necessary on BE */ | 2487 | /* XXX check if swapping is necessary on BE */ |
@@ -4176,6 +4190,41 @@ static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring, | |||
4176 | amdgpu_ring_write(ring, (1 << (oa_size + oa_base)) - (1 << oa_base)); | 4190 | amdgpu_ring_write(ring, (1 << (oa_size + oa_base)) - (1 << oa_base)); |
4177 | } | 4191 | } |
4178 | 4192 | ||
4193 | static unsigned gfx_v7_0_ring_get_emit_ib_size_gfx(struct amdgpu_ring *ring) | ||
4194 | { | ||
4195 | return | ||
4196 | 4; /* gfx_v7_0_ring_emit_ib_gfx */ | ||
4197 | } | ||
4198 | |||
4199 | static unsigned gfx_v7_0_ring_get_dma_frame_size_gfx(struct amdgpu_ring *ring) | ||
4200 | { | ||
4201 | return | ||
4202 | 20 + /* gfx_v7_0_ring_emit_gds_switch */ | ||
4203 | 7 + /* gfx_v7_0_ring_emit_hdp_flush */ | ||
4204 | 5 + /* gfx_v7_0_ring_emit_hdp_invalidate */ | ||
4205 | 12 + 12 + 12 + /* gfx_v7_0_ring_emit_fence_gfx x3 for user fence, vm fence */ | ||
4206 | 7 + 4 + /* gfx_v7_0_ring_emit_pipeline_sync */ | ||
4207 | 17 + 6 + /* gfx_v7_0_ring_emit_vm_flush */ | ||
4208 | 3; /* gfx_v7_ring_emit_cntxcntl */ | ||
4209 | } | ||
4210 | |||
4211 | static unsigned gfx_v7_0_ring_get_emit_ib_size_compute(struct amdgpu_ring *ring) | ||
4212 | { | ||
4213 | return | ||
4214 | 4; /* gfx_v7_0_ring_emit_ib_compute */ | ||
4215 | } | ||
4216 | |||
4217 | static unsigned gfx_v7_0_ring_get_dma_frame_size_compute(struct amdgpu_ring *ring) | ||
4218 | { | ||
4219 | return | ||
4220 | 20 + /* gfx_v7_0_ring_emit_gds_switch */ | ||
4221 | 7 + /* gfx_v7_0_ring_emit_hdp_flush */ | ||
4222 | 5 + /* gfx_v7_0_ring_emit_hdp_invalidate */ | ||
4223 | 7 + /* gfx_v7_0_ring_emit_pipeline_sync */ | ||
4224 | 17 + /* gfx_v7_0_ring_emit_vm_flush */ | ||
4225 | 7 + 7 + 7; /* gfx_v7_0_ring_emit_fence_compute x3 for user fence, vm fence */ | ||
4226 | } | ||
4227 | |||
4179 | static const struct amdgpu_gfx_funcs gfx_v7_0_gfx_funcs = { | 4228 | static const struct amdgpu_gfx_funcs gfx_v7_0_gfx_funcs = { |
4180 | .get_gpu_clock_counter = &gfx_v7_0_get_gpu_clock_counter, | 4229 | .get_gpu_clock_counter = &gfx_v7_0_get_gpu_clock_counter, |
4181 | .select_se_sh = &gfx_v7_0_select_se_sh, | 4230 | .select_se_sh = &gfx_v7_0_select_se_sh, |
@@ -4495,9 +4544,9 @@ static int gfx_v7_0_sw_fini(void *handle) | |||
4495 | int i; | 4544 | int i; |
4496 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 4545 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
4497 | 4546 | ||
4498 | amdgpu_bo_unref(&adev->gds.oa_gfx_bo); | 4547 | amdgpu_bo_free_kernel(&adev->gds.oa_gfx_bo, NULL, NULL); |
4499 | amdgpu_bo_unref(&adev->gds.gws_gfx_bo); | 4548 | amdgpu_bo_free_kernel(&adev->gds.gws_gfx_bo, NULL, NULL); |
4500 | amdgpu_bo_unref(&adev->gds.gds_gfx_bo); | 4549 | amdgpu_bo_free_kernel(&adev->gds.gds_gfx_bo, NULL, NULL); |
4501 | 4550 | ||
4502 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | 4551 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) |
4503 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); | 4552 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); |
@@ -4928,7 +4977,7 @@ const struct amd_ip_funcs gfx_v7_0_ip_funcs = { | |||
4928 | }; | 4977 | }; |
4929 | 4978 | ||
4930 | static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { | 4979 | static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { |
4931 | .get_rptr = gfx_v7_0_ring_get_rptr_gfx, | 4980 | .get_rptr = gfx_v7_0_ring_get_rptr, |
4932 | .get_wptr = gfx_v7_0_ring_get_wptr_gfx, | 4981 | .get_wptr = gfx_v7_0_ring_get_wptr_gfx, |
4933 | .set_wptr = gfx_v7_0_ring_set_wptr_gfx, | 4982 | .set_wptr = gfx_v7_0_ring_set_wptr_gfx, |
4934 | .parse_cs = NULL, | 4983 | .parse_cs = NULL, |
@@ -4943,10 +4992,13 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { | |||
4943 | .test_ib = gfx_v7_0_ring_test_ib, | 4992 | .test_ib = gfx_v7_0_ring_test_ib, |
4944 | .insert_nop = amdgpu_ring_insert_nop, | 4993 | .insert_nop = amdgpu_ring_insert_nop, |
4945 | .pad_ib = amdgpu_ring_generic_pad_ib, | 4994 | .pad_ib = amdgpu_ring_generic_pad_ib, |
4995 | .emit_cntxcntl = gfx_v7_ring_emit_cntxcntl, | ||
4996 | .get_emit_ib_size = gfx_v7_0_ring_get_emit_ib_size_gfx, | ||
4997 | .get_dma_frame_size = gfx_v7_0_ring_get_dma_frame_size_gfx, | ||
4946 | }; | 4998 | }; |
4947 | 4999 | ||
4948 | static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { | 5000 | static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { |
4949 | .get_rptr = gfx_v7_0_ring_get_rptr_compute, | 5001 | .get_rptr = gfx_v7_0_ring_get_rptr, |
4950 | .get_wptr = gfx_v7_0_ring_get_wptr_compute, | 5002 | .get_wptr = gfx_v7_0_ring_get_wptr_compute, |
4951 | .set_wptr = gfx_v7_0_ring_set_wptr_compute, | 5003 | .set_wptr = gfx_v7_0_ring_set_wptr_compute, |
4952 | .parse_cs = NULL, | 5004 | .parse_cs = NULL, |
@@ -4961,6 +5013,8 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { | |||
4961 | .test_ib = gfx_v7_0_ring_test_ib, | 5013 | .test_ib = gfx_v7_0_ring_test_ib, |
4962 | .insert_nop = amdgpu_ring_insert_nop, | 5014 | .insert_nop = amdgpu_ring_insert_nop, |
4963 | .pad_ib = amdgpu_ring_generic_pad_ib, | 5015 | .pad_ib = amdgpu_ring_generic_pad_ib, |
5016 | .get_emit_ib_size = gfx_v7_0_ring_get_emit_ib_size_compute, | ||
5017 | .get_dma_frame_size = gfx_v7_0_ring_get_dma_frame_size_compute, | ||
4964 | }; | 5018 | }; |
4965 | 5019 | ||
4966 | static void gfx_v7_0_set_ring_funcs(struct amdgpu_device *adev) | 5020 | static void gfx_v7_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index c6a63c2f91e3..47e270ad4fe3 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -2113,9 +2113,9 @@ static int gfx_v8_0_sw_fini(void *handle) | |||
2113 | int i; | 2113 | int i; |
2114 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2114 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2115 | 2115 | ||
2116 | amdgpu_bo_unref(&adev->gds.oa_gfx_bo); | 2116 | amdgpu_bo_free_kernel(&adev->gds.oa_gfx_bo, NULL, NULL); |
2117 | amdgpu_bo_unref(&adev->gds.gws_gfx_bo); | 2117 | amdgpu_bo_free_kernel(&adev->gds.gws_gfx_bo, NULL, NULL); |
2118 | amdgpu_bo_unref(&adev->gds.gds_gfx_bo); | 2118 | amdgpu_bo_free_kernel(&adev->gds.gds_gfx_bo, NULL, NULL); |
2119 | 2119 | ||
2120 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) | 2120 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) |
2121 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); | 2121 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); |
@@ -3866,7 +3866,7 @@ static void gfx_v8_0_init_pg(struct amdgpu_device *adev) | |||
3866 | } | 3866 | } |
3867 | } | 3867 | } |
3868 | 3868 | ||
3869 | void gfx_v8_0_rlc_stop(struct amdgpu_device *adev) | 3869 | static void gfx_v8_0_rlc_stop(struct amdgpu_device *adev) |
3870 | { | 3870 | { |
3871 | WREG32_FIELD(RLC_CNTL, RLC_ENABLE_F32, 0); | 3871 | WREG32_FIELD(RLC_CNTL, RLC_ENABLE_F32, 0); |
3872 | 3872 | ||
@@ -5835,7 +5835,7 @@ static int gfx_v8_0_set_clockgating_state(void *handle, | |||
5835 | return 0; | 5835 | return 0; |
5836 | } | 5836 | } |
5837 | 5837 | ||
5838 | static u32 gfx_v8_0_ring_get_rptr_gfx(struct amdgpu_ring *ring) | 5838 | static u32 gfx_v8_0_ring_get_rptr(struct amdgpu_ring *ring) |
5839 | { | 5839 | { |
5840 | return ring->adev->wb.wb[ring->rptr_offs]; | 5840 | return ring->adev->wb.wb[ring->rptr_offs]; |
5841 | } | 5841 | } |
@@ -5915,12 +5915,6 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, | |||
5915 | { | 5915 | { |
5916 | u32 header, control = 0; | 5916 | u32 header, control = 0; |
5917 | 5917 | ||
5918 | /* insert SWITCH_BUFFER packet before first IB in the ring frame */ | ||
5919 | if (ctx_switch) { | ||
5920 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
5921 | amdgpu_ring_write(ring, 0); | ||
5922 | } | ||
5923 | |||
5924 | if (ib->flags & AMDGPU_IB_FLAG_CE) | 5918 | if (ib->flags & AMDGPU_IB_FLAG_CE) |
5925 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); | 5919 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); |
5926 | else | 5920 | else |
@@ -5990,14 +5984,6 @@ static void gfx_v8_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | |||
5990 | amdgpu_ring_write(ring, seq); | 5984 | amdgpu_ring_write(ring, seq); |
5991 | amdgpu_ring_write(ring, 0xffffffff); | 5985 | amdgpu_ring_write(ring, 0xffffffff); |
5992 | amdgpu_ring_write(ring, 4); /* poll interval */ | 5986 | amdgpu_ring_write(ring, 4); /* poll interval */ |
5993 | |||
5994 | if (usepfp) { | ||
5995 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | ||
5996 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
5997 | amdgpu_ring_write(ring, 0); | ||
5998 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
5999 | amdgpu_ring_write(ring, 0); | ||
6000 | } | ||
6001 | } | 5987 | } |
6002 | 5988 | ||
6003 | static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | 5989 | static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, |
@@ -6005,6 +5991,10 @@ static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
6005 | { | 5991 | { |
6006 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | 5992 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); |
6007 | 5993 | ||
5994 | /* GFX8 emits 128 dw nop to prevent DE do vm_flush before CE finish CEIB */ | ||
5995 | if (usepfp) | ||
5996 | amdgpu_ring_insert_nop(ring, 128); | ||
5997 | |||
6008 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | 5998 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
6009 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) | | 5999 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) | |
6010 | WRITE_DATA_DST_SEL(0)) | | 6000 | WRITE_DATA_DST_SEL(0)) | |
@@ -6044,18 +6034,11 @@ static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
6044 | /* sync PFP to ME, otherwise we might get invalid PFP reads */ | 6034 | /* sync PFP to ME, otherwise we might get invalid PFP reads */ |
6045 | amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0)); | 6035 | amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0)); |
6046 | amdgpu_ring_write(ring, 0x0); | 6036 | amdgpu_ring_write(ring, 0x0); |
6047 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | 6037 | /* GFX8 emits 128 dw nop to prevent CE access VM before vm_flush finish */ |
6048 | amdgpu_ring_write(ring, 0); | 6038 | amdgpu_ring_insert_nop(ring, 128); |
6049 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
6050 | amdgpu_ring_write(ring, 0); | ||
6051 | } | 6039 | } |
6052 | } | 6040 | } |
6053 | 6041 | ||
6054 | static u32 gfx_v8_0_ring_get_rptr_compute(struct amdgpu_ring *ring) | ||
6055 | { | ||
6056 | return ring->adev->wb.wb[ring->rptr_offs]; | ||
6057 | } | ||
6058 | |||
6059 | static u32 gfx_v8_0_ring_get_wptr_compute(struct amdgpu_ring *ring) | 6042 | static u32 gfx_v8_0_ring_get_wptr_compute(struct amdgpu_ring *ring) |
6060 | { | 6043 | { |
6061 | return ring->adev->wb.wb[ring->wptr_offs]; | 6044 | return ring->adev->wb.wb[ring->wptr_offs]; |
@@ -6091,6 +6074,77 @@ static void gfx_v8_0_ring_emit_fence_compute(struct amdgpu_ring *ring, | |||
6091 | amdgpu_ring_write(ring, upper_32_bits(seq)); | 6074 | amdgpu_ring_write(ring, upper_32_bits(seq)); |
6092 | } | 6075 | } |
6093 | 6076 | ||
6077 | static void gfx_v8_ring_emit_sb(struct amdgpu_ring *ring) | ||
6078 | { | ||
6079 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
6080 | amdgpu_ring_write(ring, 0); | ||
6081 | } | ||
6082 | |||
6083 | static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) | ||
6084 | { | ||
6085 | uint32_t dw2 = 0; | ||
6086 | |||
6087 | dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */ | ||
6088 | if (flags & AMDGPU_HAVE_CTX_SWITCH) { | ||
6089 | /* set load_global_config & load_global_uconfig */ | ||
6090 | dw2 |= 0x8001; | ||
6091 | /* set load_cs_sh_regs */ | ||
6092 | dw2 |= 0x01000000; | ||
6093 | /* set load_per_context_state & load_gfx_sh_regs for GFX */ | ||
6094 | dw2 |= 0x10002; | ||
6095 | |||
6096 | /* set load_ce_ram if preamble presented */ | ||
6097 | if (AMDGPU_PREAMBLE_IB_PRESENT & flags) | ||
6098 | dw2 |= 0x10000000; | ||
6099 | } else { | ||
6100 | /* still load_ce_ram if this is the first time preamble presented | ||
6101 | * although there is no context switch happens. | ||
6102 | */ | ||
6103 | if (AMDGPU_PREAMBLE_IB_PRESENT_FIRST & flags) | ||
6104 | dw2 |= 0x10000000; | ||
6105 | } | ||
6106 | |||
6107 | amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); | ||
6108 | amdgpu_ring_write(ring, dw2); | ||
6109 | amdgpu_ring_write(ring, 0); | ||
6110 | } | ||
6111 | |||
6112 | static unsigned gfx_v8_0_ring_get_emit_ib_size_gfx(struct amdgpu_ring *ring) | ||
6113 | { | ||
6114 | return | ||
6115 | 4; /* gfx_v8_0_ring_emit_ib_gfx */ | ||
6116 | } | ||
6117 | |||
6118 | static unsigned gfx_v8_0_ring_get_dma_frame_size_gfx(struct amdgpu_ring *ring) | ||
6119 | { | ||
6120 | return | ||
6121 | 20 + /* gfx_v8_0_ring_emit_gds_switch */ | ||
6122 | 7 + /* gfx_v8_0_ring_emit_hdp_flush */ | ||
6123 | 5 + /* gfx_v8_0_ring_emit_hdp_invalidate */ | ||
6124 | 6 + 6 + 6 +/* gfx_v8_0_ring_emit_fence_gfx x3 for user fence, vm fence */ | ||
6125 | 7 + /* gfx_v8_0_ring_emit_pipeline_sync */ | ||
6126 | 256 + 19 + /* gfx_v8_0_ring_emit_vm_flush */ | ||
6127 | 2 + /* gfx_v8_ring_emit_sb */ | ||
6128 | 3; /* gfx_v8_ring_emit_cntxcntl */ | ||
6129 | } | ||
6130 | |||
6131 | static unsigned gfx_v8_0_ring_get_emit_ib_size_compute(struct amdgpu_ring *ring) | ||
6132 | { | ||
6133 | return | ||
6134 | 4; /* gfx_v8_0_ring_emit_ib_compute */ | ||
6135 | } | ||
6136 | |||
6137 | static unsigned gfx_v8_0_ring_get_dma_frame_size_compute(struct amdgpu_ring *ring) | ||
6138 | { | ||
6139 | return | ||
6140 | 20 + /* gfx_v8_0_ring_emit_gds_switch */ | ||
6141 | 7 + /* gfx_v8_0_ring_emit_hdp_flush */ | ||
6142 | 5 + /* gfx_v8_0_ring_emit_hdp_invalidate */ | ||
6143 | 7 + /* gfx_v8_0_ring_emit_pipeline_sync */ | ||
6144 | 17 + /* gfx_v8_0_ring_emit_vm_flush */ | ||
6145 | 7 + 7 + 7; /* gfx_v8_0_ring_emit_fence_compute x3 for user fence, vm fence */ | ||
6146 | } | ||
6147 | |||
6094 | static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, | 6148 | static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, |
6095 | enum amdgpu_interrupt_state state) | 6149 | enum amdgpu_interrupt_state state) |
6096 | { | 6150 | { |
@@ -6257,7 +6311,7 @@ const struct amd_ip_funcs gfx_v8_0_ip_funcs = { | |||
6257 | }; | 6311 | }; |
6258 | 6312 | ||
6259 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { | 6313 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { |
6260 | .get_rptr = gfx_v8_0_ring_get_rptr_gfx, | 6314 | .get_rptr = gfx_v8_0_ring_get_rptr, |
6261 | .get_wptr = gfx_v8_0_ring_get_wptr_gfx, | 6315 | .get_wptr = gfx_v8_0_ring_get_wptr_gfx, |
6262 | .set_wptr = gfx_v8_0_ring_set_wptr_gfx, | 6316 | .set_wptr = gfx_v8_0_ring_set_wptr_gfx, |
6263 | .parse_cs = NULL, | 6317 | .parse_cs = NULL, |
@@ -6272,10 +6326,14 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { | |||
6272 | .test_ib = gfx_v8_0_ring_test_ib, | 6326 | .test_ib = gfx_v8_0_ring_test_ib, |
6273 | .insert_nop = amdgpu_ring_insert_nop, | 6327 | .insert_nop = amdgpu_ring_insert_nop, |
6274 | .pad_ib = amdgpu_ring_generic_pad_ib, | 6328 | .pad_ib = amdgpu_ring_generic_pad_ib, |
6329 | .emit_switch_buffer = gfx_v8_ring_emit_sb, | ||
6330 | .emit_cntxcntl = gfx_v8_ring_emit_cntxcntl, | ||
6331 | .get_emit_ib_size = gfx_v8_0_ring_get_emit_ib_size_gfx, | ||
6332 | .get_dma_frame_size = gfx_v8_0_ring_get_dma_frame_size_gfx, | ||
6275 | }; | 6333 | }; |
6276 | 6334 | ||
6277 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { | 6335 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { |
6278 | .get_rptr = gfx_v8_0_ring_get_rptr_compute, | 6336 | .get_rptr = gfx_v8_0_ring_get_rptr, |
6279 | .get_wptr = gfx_v8_0_ring_get_wptr_compute, | 6337 | .get_wptr = gfx_v8_0_ring_get_wptr_compute, |
6280 | .set_wptr = gfx_v8_0_ring_set_wptr_compute, | 6338 | .set_wptr = gfx_v8_0_ring_set_wptr_compute, |
6281 | .parse_cs = NULL, | 6339 | .parse_cs = NULL, |
@@ -6290,6 +6348,8 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { | |||
6290 | .test_ib = gfx_v8_0_ring_test_ib, | 6348 | .test_ib = gfx_v8_0_ring_test_ib, |
6291 | .insert_nop = amdgpu_ring_insert_nop, | 6349 | .insert_nop = amdgpu_ring_insert_nop, |
6292 | .pad_ib = amdgpu_ring_generic_pad_ib, | 6350 | .pad_ib = amdgpu_ring_generic_pad_ib, |
6351 | .get_emit_ib_size = gfx_v8_0_ring_get_emit_ib_size_compute, | ||
6352 | .get_dma_frame_size = gfx_v8_0_ring_get_dma_frame_size_compute, | ||
6293 | }; | 6353 | }; |
6294 | 6354 | ||
6295 | static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev) | 6355 | static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c new file mode 100644 index 000000000000..b13c8aaec078 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | |||
@@ -0,0 +1,1071 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright 2014 Advanced Micro Devices, Inc. | ||
4 | * | ||
5 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
6 | * copy of this software and associated documentation files (the "Software"), | ||
7 | * to deal in the Software without restriction, including without limitation | ||
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
9 | * and/or sell copies of the Software, and to permit persons to whom the | ||
10 | * Software is furnished to do so, subject to the following conditions: | ||
11 | * | ||
12 | * The above copyright notice and this permission notice shall be included in | ||
13 | * all copies or substantial portions of the Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
21 | * OTHER DEALINGS IN THE SOFTWARE. | ||
22 | * | ||
23 | */ | ||
24 | #include <linux/firmware.h> | ||
25 | #include "drmP.h" | ||
26 | #include "amdgpu.h" | ||
27 | #include "gmc_v6_0.h" | ||
28 | #include "amdgpu_ucode.h" | ||
29 | #include "si/sid.h" | ||
30 | |||
31 | static void gmc_v6_0_set_gart_funcs(struct amdgpu_device *adev); | ||
32 | static void gmc_v6_0_set_irq_funcs(struct amdgpu_device *adev); | ||
33 | static int gmc_v6_0_wait_for_idle(void *handle); | ||
34 | |||
35 | MODULE_FIRMWARE("radeon/tahiti_mc.bin"); | ||
36 | MODULE_FIRMWARE("radeon/pitcairn_mc.bin"); | ||
37 | MODULE_FIRMWARE("radeon/verde_mc.bin"); | ||
38 | MODULE_FIRMWARE("radeon/oland_mc.bin"); | ||
39 | |||
40 | static const u32 crtc_offsets[6] = | ||
41 | { | ||
42 | SI_CRTC0_REGISTER_OFFSET, | ||
43 | SI_CRTC1_REGISTER_OFFSET, | ||
44 | SI_CRTC2_REGISTER_OFFSET, | ||
45 | SI_CRTC3_REGISTER_OFFSET, | ||
46 | SI_CRTC4_REGISTER_OFFSET, | ||
47 | SI_CRTC5_REGISTER_OFFSET | ||
48 | }; | ||
49 | |||
50 | static void gmc_v6_0_mc_stop(struct amdgpu_device *adev, | ||
51 | struct amdgpu_mode_mc_save *save) | ||
52 | { | ||
53 | u32 blackout; | ||
54 | |||
55 | if (adev->mode_info.num_crtc) | ||
56 | amdgpu_display_stop_mc_access(adev, save); | ||
57 | |||
58 | gmc_v6_0_wait_for_idle((void *)adev); | ||
59 | |||
60 | blackout = RREG32(MC_SHARED_BLACKOUT_CNTL); | ||
61 | if (REG_GET_FIELD(blackout, mmMC_SHARED_BLACKOUT_CNTL, xxBLACKOUT_MODE) != 1) { | ||
62 | /* Block CPU access */ | ||
63 | WREG32(BIF_FB_EN, 0); | ||
64 | /* blackout the MC */ | ||
65 | blackout = REG_SET_FIELD(blackout, | ||
66 | mmMC_SHARED_BLACKOUT_CNTL, xxBLACKOUT_MODE, 0); | ||
67 | WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1); | ||
68 | } | ||
69 | /* wait for the MC to settle */ | ||
70 | udelay(100); | ||
71 | |||
72 | } | ||
73 | |||
74 | static void gmc_v6_0_mc_resume(struct amdgpu_device *adev, | ||
75 | struct amdgpu_mode_mc_save *save) | ||
76 | { | ||
77 | u32 tmp; | ||
78 | |||
79 | /* unblackout the MC */ | ||
80 | tmp = RREG32(MC_SHARED_BLACKOUT_CNTL); | ||
81 | tmp = REG_SET_FIELD(tmp, mmMC_SHARED_BLACKOUT_CNTL, xxBLACKOUT_MODE, 0); | ||
82 | WREG32(MC_SHARED_BLACKOUT_CNTL, tmp); | ||
83 | /* allow CPU access */ | ||
84 | tmp = REG_SET_FIELD(0, mmBIF_FB_EN, xxFB_READ_EN, 1); | ||
85 | tmp = REG_SET_FIELD(tmp, mmBIF_FB_EN, xxFB_WRITE_EN, 1); | ||
86 | WREG32(BIF_FB_EN, tmp); | ||
87 | |||
88 | if (adev->mode_info.num_crtc) | ||
89 | amdgpu_display_resume_mc_access(adev, save); | ||
90 | |||
91 | } | ||
92 | |||
93 | static int gmc_v6_0_init_microcode(struct amdgpu_device *adev) | ||
94 | { | ||
95 | const char *chip_name; | ||
96 | char fw_name[30]; | ||
97 | int err; | ||
98 | |||
99 | DRM_DEBUG("\n"); | ||
100 | |||
101 | switch (adev->asic_type) { | ||
102 | case CHIP_TAHITI: | ||
103 | chip_name = "tahiti"; | ||
104 | break; | ||
105 | case CHIP_PITCAIRN: | ||
106 | chip_name = "pitcairn"; | ||
107 | break; | ||
108 | case CHIP_VERDE: | ||
109 | chip_name = "verde"; | ||
110 | break; | ||
111 | case CHIP_OLAND: | ||
112 | chip_name = "oland"; | ||
113 | break; | ||
114 | case CHIP_HAINAN: | ||
115 | chip_name = "hainan"; | ||
116 | break; | ||
117 | default: BUG(); | ||
118 | } | ||
119 | |||
120 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); | ||
121 | err = request_firmware(&adev->mc.fw, fw_name, adev->dev); | ||
122 | if (err) | ||
123 | goto out; | ||
124 | |||
125 | err = amdgpu_ucode_validate(adev->mc.fw); | ||
126 | |||
127 | out: | ||
128 | if (err) { | ||
129 | dev_err(adev->dev, | ||
130 | "si_mc: Failed to load firmware \"%s\"\n", | ||
131 | fw_name); | ||
132 | release_firmware(adev->mc.fw); | ||
133 | adev->mc.fw = NULL; | ||
134 | } | ||
135 | return err; | ||
136 | } | ||
137 | |||
138 | static int gmc_v6_0_mc_load_microcode(struct amdgpu_device *adev) | ||
139 | { | ||
140 | const __le32 *new_fw_data = NULL; | ||
141 | u32 running; | ||
142 | const __le32 *new_io_mc_regs = NULL; | ||
143 | int i, regs_size, ucode_size; | ||
144 | const struct mc_firmware_header_v1_0 *hdr; | ||
145 | |||
146 | if (!adev->mc.fw) | ||
147 | return -EINVAL; | ||
148 | |||
149 | hdr = (const struct mc_firmware_header_v1_0 *)adev->mc.fw->data; | ||
150 | |||
151 | amdgpu_ucode_print_mc_hdr(&hdr->header); | ||
152 | |||
153 | adev->mc.fw_version = le32_to_cpu(hdr->header.ucode_version); | ||
154 | regs_size = le32_to_cpu(hdr->io_debug_size_bytes) / (4 * 2); | ||
155 | new_io_mc_regs = (const __le32 *) | ||
156 | (adev->mc.fw->data + le32_to_cpu(hdr->io_debug_array_offset_bytes)); | ||
157 | ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; | ||
158 | new_fw_data = (const __le32 *) | ||
159 | (adev->mc.fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
160 | |||
161 | running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK; | ||
162 | |||
163 | if (running == 0) { | ||
164 | |||
165 | /* reset the engine and set to writable */ | ||
166 | WREG32(MC_SEQ_SUP_CNTL, 0x00000008); | ||
167 | WREG32(MC_SEQ_SUP_CNTL, 0x00000010); | ||
168 | |||
169 | /* load mc io regs */ | ||
170 | for (i = 0; i < regs_size; i++) { | ||
171 | WREG32(MC_SEQ_IO_DEBUG_INDEX, le32_to_cpup(new_io_mc_regs++)); | ||
172 | WREG32(MC_SEQ_IO_DEBUG_DATA, le32_to_cpup(new_io_mc_regs++)); | ||
173 | } | ||
174 | /* load the MC ucode */ | ||
175 | for (i = 0; i < ucode_size; i++) { | ||
176 | WREG32(MC_SEQ_SUP_PGM, le32_to_cpup(new_fw_data++)); | ||
177 | } | ||
178 | |||
179 | /* put the engine back into the active state */ | ||
180 | WREG32(MC_SEQ_SUP_CNTL, 0x00000008); | ||
181 | WREG32(MC_SEQ_SUP_CNTL, 0x00000004); | ||
182 | WREG32(MC_SEQ_SUP_CNTL, 0x00000001); | ||
183 | |||
184 | /* wait for training to complete */ | ||
185 | for (i = 0; i < adev->usec_timeout; i++) { | ||
186 | if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D0) | ||
187 | break; | ||
188 | udelay(1); | ||
189 | } | ||
190 | for (i = 0; i < adev->usec_timeout; i++) { | ||
191 | if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D1) | ||
192 | break; | ||
193 | udelay(1); | ||
194 | } | ||
195 | |||
196 | } | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, | ||
202 | struct amdgpu_mc *mc) | ||
203 | { | ||
204 | if (mc->mc_vram_size > 0xFFC0000000ULL) { | ||
205 | dev_warn(adev->dev, "limiting VRAM\n"); | ||
206 | mc->real_vram_size = 0xFFC0000000ULL; | ||
207 | mc->mc_vram_size = 0xFFC0000000ULL; | ||
208 | } | ||
209 | amdgpu_vram_location(adev, &adev->mc, 0); | ||
210 | adev->mc.gtt_base_align = 0; | ||
211 | amdgpu_gtt_location(adev, mc); | ||
212 | } | ||
213 | |||
214 | static void gmc_v6_0_mc_program(struct amdgpu_device *adev) | ||
215 | { | ||
216 | struct amdgpu_mode_mc_save save; | ||
217 | u32 tmp; | ||
218 | int i, j; | ||
219 | |||
220 | /* Initialize HDP */ | ||
221 | for (i = 0, j = 0; i < 32; i++, j += 0x6) { | ||
222 | WREG32((0xb05 + j), 0x00000000); | ||
223 | WREG32((0xb06 + j), 0x00000000); | ||
224 | WREG32((0xb07 + j), 0x00000000); | ||
225 | WREG32((0xb08 + j), 0x00000000); | ||
226 | WREG32((0xb09 + j), 0x00000000); | ||
227 | } | ||
228 | WREG32(HDP_REG_COHERENCY_FLUSH_CNTL, 0); | ||
229 | |||
230 | gmc_v6_0_mc_stop(adev, &save); | ||
231 | |||
232 | if (gmc_v6_0_wait_for_idle((void *)adev)) { | ||
233 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | ||
234 | } | ||
235 | |||
236 | WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE); | ||
237 | /* Update configuration */ | ||
238 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, | ||
239 | adev->mc.vram_start >> 12); | ||
240 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, | ||
241 | adev->mc.vram_end >> 12); | ||
242 | WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, | ||
243 | adev->vram_scratch.gpu_addr >> 12); | ||
244 | tmp = ((adev->mc.vram_end >> 24) & 0xFFFF) << 16; | ||
245 | tmp |= ((adev->mc.vram_start >> 24) & 0xFFFF); | ||
246 | WREG32(MC_VM_FB_LOCATION, tmp); | ||
247 | /* XXX double check these! */ | ||
248 | WREG32(HDP_NONSURFACE_BASE, (adev->mc.vram_start >> 8)); | ||
249 | WREG32(HDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); | ||
250 | WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF); | ||
251 | WREG32(MC_VM_AGP_BASE, 0); | ||
252 | WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF); | ||
253 | WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF); | ||
254 | |||
255 | if (gmc_v6_0_wait_for_idle((void *)adev)) { | ||
256 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | ||
257 | } | ||
258 | gmc_v6_0_mc_resume(adev, &save); | ||
259 | amdgpu_display_set_vga_render_state(adev, false); | ||
260 | } | ||
261 | |||
262 | static int gmc_v6_0_mc_init(struct amdgpu_device *adev) | ||
263 | { | ||
264 | |||
265 | u32 tmp; | ||
266 | int chansize, numchan; | ||
267 | |||
268 | tmp = RREG32(MC_ARB_RAMCFG); | ||
269 | if (tmp & CHANSIZE_OVERRIDE) { | ||
270 | chansize = 16; | ||
271 | } else if (tmp & CHANSIZE_MASK) { | ||
272 | chansize = 64; | ||
273 | } else { | ||
274 | chansize = 32; | ||
275 | } | ||
276 | tmp = RREG32(MC_SHARED_CHMAP); | ||
277 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { | ||
278 | case 0: | ||
279 | default: | ||
280 | numchan = 1; | ||
281 | break; | ||
282 | case 1: | ||
283 | numchan = 2; | ||
284 | break; | ||
285 | case 2: | ||
286 | numchan = 4; | ||
287 | break; | ||
288 | case 3: | ||
289 | numchan = 8; | ||
290 | break; | ||
291 | case 4: | ||
292 | numchan = 3; | ||
293 | break; | ||
294 | case 5: | ||
295 | numchan = 6; | ||
296 | break; | ||
297 | case 6: | ||
298 | numchan = 10; | ||
299 | break; | ||
300 | case 7: | ||
301 | numchan = 12; | ||
302 | break; | ||
303 | case 8: | ||
304 | numchan = 16; | ||
305 | break; | ||
306 | } | ||
307 | adev->mc.vram_width = numchan * chansize; | ||
308 | /* Could aper size report 0 ? */ | ||
309 | adev->mc.aper_base = pci_resource_start(adev->pdev, 0); | ||
310 | adev->mc.aper_size = pci_resource_len(adev->pdev, 0); | ||
311 | /* size in MB on si */ | ||
312 | adev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; | ||
313 | adev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; | ||
314 | adev->mc.visible_vram_size = adev->mc.aper_size; | ||
315 | |||
316 | /* unless the user had overridden it, set the gart | ||
317 | * size equal to the 1024 or vram, whichever is larger. | ||
318 | */ | ||
319 | if (amdgpu_gart_size == -1) | ||
320 | adev->mc.gtt_size = amdgpu_ttm_get_gtt_mem_size(adev); | ||
321 | else | ||
322 | adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; | ||
323 | |||
324 | gmc_v6_0_vram_gtt_location(adev, &adev->mc); | ||
325 | |||
326 | return 0; | ||
327 | } | ||
328 | |||
329 | static void gmc_v6_0_gart_flush_gpu_tlb(struct amdgpu_device *adev, | ||
330 | uint32_t vmid) | ||
331 | { | ||
332 | WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0); | ||
333 | |||
334 | WREG32(VM_INVALIDATE_REQUEST, 1 << vmid); | ||
335 | } | ||
336 | |||
337 | static int gmc_v6_0_gart_set_pte_pde(struct amdgpu_device *adev, | ||
338 | void *cpu_pt_addr, | ||
339 | uint32_t gpu_page_idx, | ||
340 | uint64_t addr, | ||
341 | uint32_t flags) | ||
342 | { | ||
343 | void __iomem *ptr = (void *)cpu_pt_addr; | ||
344 | uint64_t value; | ||
345 | |||
346 | value = addr & 0xFFFFFFFFFFFFF000ULL; | ||
347 | value |= flags; | ||
348 | writeq(value, ptr + (gpu_page_idx * 8)); | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev, | ||
354 | bool value) | ||
355 | { | ||
356 | u32 tmp; | ||
357 | |||
358 | tmp = RREG32(VM_CONTEXT1_CNTL); | ||
359 | tmp = REG_SET_FIELD(tmp, mmVM_CONTEXT1_CNTL, | ||
360 | xxRANGE_PROTECTION_FAULT_ENABLE_DEFAULT, value); | ||
361 | tmp = REG_SET_FIELD(tmp, mmVM_CONTEXT1_CNTL, | ||
362 | xxDUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, value); | ||
363 | tmp = REG_SET_FIELD(tmp, mmVM_CONTEXT1_CNTL, | ||
364 | xxPDE0_PROTECTION_FAULT_ENABLE_DEFAULT, value); | ||
365 | tmp = REG_SET_FIELD(tmp, mmVM_CONTEXT1_CNTL, | ||
366 | xxVALID_PROTECTION_FAULT_ENABLE_DEFAULT, value); | ||
367 | tmp = REG_SET_FIELD(tmp, mmVM_CONTEXT1_CNTL, | ||
368 | xxREAD_PROTECTION_FAULT_ENABLE_DEFAULT, value); | ||
369 | tmp = REG_SET_FIELD(tmp, mmVM_CONTEXT1_CNTL, | ||
370 | xxWRITE_PROTECTION_FAULT_ENABLE_DEFAULT, value); | ||
371 | WREG32(VM_CONTEXT1_CNTL, tmp); | ||
372 | } | ||
373 | |||
374 | static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) | ||
375 | { | ||
376 | int r, i; | ||
377 | |||
378 | if (adev->gart.robj == NULL) { | ||
379 | dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); | ||
380 | return -EINVAL; | ||
381 | } | ||
382 | r = amdgpu_gart_table_vram_pin(adev); | ||
383 | if (r) | ||
384 | return r; | ||
385 | /* Setup TLB control */ | ||
386 | WREG32(MC_VM_MX_L1_TLB_CNTL, | ||
387 | (0xA << 7) | | ||
388 | ENABLE_L1_TLB | | ||
389 | ENABLE_L1_FRAGMENT_PROCESSING | | ||
390 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | | ||
391 | ENABLE_ADVANCED_DRIVER_MODEL | | ||
392 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU); | ||
393 | /* Setup L2 cache */ | ||
394 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | | ||
395 | ENABLE_L2_FRAGMENT_PROCESSING | | ||
396 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | | ||
397 | ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE | | ||
398 | EFFECTIVE_L2_QUEUE_SIZE(7) | | ||
399 | CONTEXT1_IDENTITY_ACCESS_MODE(1)); | ||
400 | WREG32(VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS | INVALIDATE_L2_CACHE); | ||
401 | WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY | | ||
402 | BANK_SELECT(4) | | ||
403 | L2_CACHE_BIGK_FRAGMENT_SIZE(4)); | ||
404 | /* setup context0 */ | ||
405 | WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gtt_start >> 12); | ||
406 | WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gtt_end >> 12); | ||
407 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); | ||
408 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, | ||
409 | (u32)(adev->dummy_page.addr >> 12)); | ||
410 | WREG32(VM_CONTEXT0_CNTL2, 0); | ||
411 | WREG32(VM_CONTEXT0_CNTL, (ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) | | ||
412 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT)); | ||
413 | |||
414 | WREG32(0x575, 0); | ||
415 | WREG32(0x576, 0); | ||
416 | WREG32(0x577, 0); | ||
417 | |||
418 | /* empty context1-15 */ | ||
419 | /* set vm size, must be a multiple of 4 */ | ||
420 | WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); | ||
421 | WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, adev->vm_manager.max_pfn - 1); | ||
422 | /* Assign the pt base to something valid for now; the pts used for | ||
423 | * the VMs are determined by the application and setup and assigned | ||
424 | * on the fly in the vm part of radeon_gart.c | ||
425 | */ | ||
426 | for (i = 1; i < 16; i++) { | ||
427 | if (i < 8) | ||
428 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + i, | ||
429 | adev->gart.table_addr >> 12); | ||
430 | else | ||
431 | WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + i - 8, | ||
432 | adev->gart.table_addr >> 12); | ||
433 | } | ||
434 | |||
435 | /* enable context1-15 */ | ||
436 | WREG32(VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR, | ||
437 | (u32)(adev->dummy_page.addr >> 12)); | ||
438 | WREG32(VM_CONTEXT1_CNTL2, 4); | ||
439 | WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(1) | | ||
440 | PAGE_TABLE_BLOCK_SIZE(amdgpu_vm_block_size - 9) | | ||
441 | RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT | | ||
442 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT | | ||
443 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT | | ||
444 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT | | ||
445 | PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT | | ||
446 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT | | ||
447 | VALID_PROTECTION_FAULT_ENABLE_INTERRUPT | | ||
448 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT | | ||
449 | READ_PROTECTION_FAULT_ENABLE_INTERRUPT | | ||
450 | READ_PROTECTION_FAULT_ENABLE_DEFAULT | | ||
451 | WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT | | ||
452 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT); | ||
453 | |||
454 | gmc_v6_0_gart_flush_gpu_tlb(adev, 0); | ||
455 | dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", | ||
456 | (unsigned)(adev->mc.gtt_size >> 20), | ||
457 | (unsigned long long)adev->gart.table_addr); | ||
458 | adev->gart.ready = true; | ||
459 | return 0; | ||
460 | } | ||
461 | |||
462 | static int gmc_v6_0_gart_init(struct amdgpu_device *adev) | ||
463 | { | ||
464 | int r; | ||
465 | |||
466 | if (adev->gart.robj) { | ||
467 | dev_warn(adev->dev, "gmc_v6_0 PCIE GART already initialized\n"); | ||
468 | return 0; | ||
469 | } | ||
470 | r = amdgpu_gart_init(adev); | ||
471 | if (r) | ||
472 | return r; | ||
473 | adev->gart.table_size = adev->gart.num_gpu_pages * 8; | ||
474 | return amdgpu_gart_table_vram_alloc(adev); | ||
475 | } | ||
476 | |||
477 | static void gmc_v6_0_gart_disable(struct amdgpu_device *adev) | ||
478 | { | ||
479 | /*unsigned i; | ||
480 | |||
481 | for (i = 1; i < 16; ++i) { | ||
482 | uint32_t reg; | ||
483 | if (i < 8) | ||
484 | reg = VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + i ; | ||
485 | else | ||
486 | reg = VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + (i - 8); | ||
487 | adev->vm_manager.saved_table_addr[i] = RREG32(reg); | ||
488 | }*/ | ||
489 | |||
490 | /* Disable all tables */ | ||
491 | WREG32(VM_CONTEXT0_CNTL, 0); | ||
492 | WREG32(VM_CONTEXT1_CNTL, 0); | ||
493 | /* Setup TLB control */ | ||
494 | WREG32(MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE_NOT_IN_SYS | | ||
495 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU); | ||
496 | /* Setup L2 cache */ | ||
497 | WREG32(VM_L2_CNTL, ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | | ||
498 | ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE | | ||
499 | EFFECTIVE_L2_QUEUE_SIZE(7) | | ||
500 | CONTEXT1_IDENTITY_ACCESS_MODE(1)); | ||
501 | WREG32(VM_L2_CNTL2, 0); | ||
502 | WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY | | ||
503 | L2_CACHE_BIGK_FRAGMENT_SIZE(0)); | ||
504 | amdgpu_gart_table_vram_unpin(adev); | ||
505 | } | ||
506 | |||
507 | static void gmc_v6_0_gart_fini(struct amdgpu_device *adev) | ||
508 | { | ||
509 | amdgpu_gart_table_vram_free(adev); | ||
510 | amdgpu_gart_fini(adev); | ||
511 | } | ||
512 | |||
513 | static int gmc_v6_0_vm_init(struct amdgpu_device *adev) | ||
514 | { | ||
515 | /* | ||
516 | * number of VMs | ||
517 | * VMID 0 is reserved for System | ||
518 | * amdgpu graphics/compute will use VMIDs 1-7 | ||
519 | * amdkfd will use VMIDs 8-15 | ||
520 | */ | ||
521 | adev->vm_manager.num_ids = AMDGPU_NUM_OF_VMIDS; | ||
522 | amdgpu_vm_manager_init(adev); | ||
523 | |||
524 | /* base offset of vram pages */ | ||
525 | if (adev->flags & AMD_IS_APU) { | ||
526 | u64 tmp = RREG32(MC_VM_FB_OFFSET); | ||
527 | tmp <<= 22; | ||
528 | adev->vm_manager.vram_base_offset = tmp; | ||
529 | } else | ||
530 | adev->vm_manager.vram_base_offset = 0; | ||
531 | |||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | static void gmc_v6_0_vm_fini(struct amdgpu_device *adev) | ||
536 | { | ||
537 | } | ||
538 | |||
539 | static void gmc_v6_0_vm_decode_fault(struct amdgpu_device *adev, | ||
540 | u32 status, u32 addr, u32 mc_client) | ||
541 | { | ||
542 | u32 mc_id; | ||
543 | u32 vmid = REG_GET_FIELD(status, mmVM_CONTEXT1_PROTECTION_FAULT_STATUS, xxVMID); | ||
544 | u32 protections = REG_GET_FIELD(status, mmVM_CONTEXT1_PROTECTION_FAULT_STATUS, | ||
545 | xxPROTECTIONS); | ||
546 | char block[5] = { mc_client >> 24, (mc_client >> 16) & 0xff, | ||
547 | (mc_client >> 8) & 0xff, mc_client & 0xff, 0 }; | ||
548 | |||
549 | mc_id = REG_GET_FIELD(status, mmVM_CONTEXT1_PROTECTION_FAULT_STATUS, | ||
550 | xxMEMORY_CLIENT_ID); | ||
551 | |||
552 | dev_err(adev->dev, "VM fault (0x%02x, vmid %d) at page %u, %s from '%s' (0x%08x) (%d)\n", | ||
553 | protections, vmid, addr, | ||
554 | REG_GET_FIELD(status, mmVM_CONTEXT1_PROTECTION_FAULT_STATUS, | ||
555 | xxMEMORY_CLIENT_RW) ? | ||
556 | "write" : "read", block, mc_client, mc_id); | ||
557 | } | ||
558 | |||
559 | /* | ||
560 | static const u32 mc_cg_registers[] = { | ||
561 | MC_HUB_MISC_HUB_CG, | ||
562 | MC_HUB_MISC_SIP_CG, | ||
563 | MC_HUB_MISC_VM_CG, | ||
564 | MC_XPB_CLK_GAT, | ||
565 | ATC_MISC_CG, | ||
566 | MC_CITF_MISC_WR_CG, | ||
567 | MC_CITF_MISC_RD_CG, | ||
568 | MC_CITF_MISC_VM_CG, | ||
569 | VM_L2_CG, | ||
570 | }; | ||
571 | |||
572 | static const u32 mc_cg_ls_en[] = { | ||
573 | MC_HUB_MISC_HUB_CG__MEM_LS_ENABLE_MASK, | ||
574 | MC_HUB_MISC_SIP_CG__MEM_LS_ENABLE_MASK, | ||
575 | MC_HUB_MISC_VM_CG__MEM_LS_ENABLE_MASK, | ||
576 | MC_XPB_CLK_GAT__MEM_LS_ENABLE_MASK, | ||
577 | ATC_MISC_CG__MEM_LS_ENABLE_MASK, | ||
578 | MC_CITF_MISC_WR_CG__MEM_LS_ENABLE_MASK, | ||
579 | MC_CITF_MISC_RD_CG__MEM_LS_ENABLE_MASK, | ||
580 | MC_CITF_MISC_VM_CG__MEM_LS_ENABLE_MASK, | ||
581 | VM_L2_CG__MEM_LS_ENABLE_MASK, | ||
582 | }; | ||
583 | |||
584 | static const u32 mc_cg_en[] = { | ||
585 | MC_HUB_MISC_HUB_CG__ENABLE_MASK, | ||
586 | MC_HUB_MISC_SIP_CG__ENABLE_MASK, | ||
587 | MC_HUB_MISC_VM_CG__ENABLE_MASK, | ||
588 | MC_XPB_CLK_GAT__ENABLE_MASK, | ||
589 | ATC_MISC_CG__ENABLE_MASK, | ||
590 | MC_CITF_MISC_WR_CG__ENABLE_MASK, | ||
591 | MC_CITF_MISC_RD_CG__ENABLE_MASK, | ||
592 | MC_CITF_MISC_VM_CG__ENABLE_MASK, | ||
593 | VM_L2_CG__ENABLE_MASK, | ||
594 | }; | ||
595 | |||
596 | static void gmc_v6_0_enable_mc_ls(struct amdgpu_device *adev, | ||
597 | bool enable) | ||
598 | { | ||
599 | int i; | ||
600 | u32 orig, data; | ||
601 | |||
602 | for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) { | ||
603 | orig = data = RREG32(mc_cg_registers[i]); | ||
604 | if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_MC_LS)) | ||
605 | data |= mc_cg_ls_en[i]; | ||
606 | else | ||
607 | data &= ~mc_cg_ls_en[i]; | ||
608 | if (data != orig) | ||
609 | WREG32(mc_cg_registers[i], data); | ||
610 | } | ||
611 | } | ||
612 | |||
613 | static void gmc_v6_0_enable_mc_mgcg(struct amdgpu_device *adev, | ||
614 | bool enable) | ||
615 | { | ||
616 | int i; | ||
617 | u32 orig, data; | ||
618 | |||
619 | for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) { | ||
620 | orig = data = RREG32(mc_cg_registers[i]); | ||
621 | if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_MC_MGCG)) | ||
622 | data |= mc_cg_en[i]; | ||
623 | else | ||
624 | data &= ~mc_cg_en[i]; | ||
625 | if (data != orig) | ||
626 | WREG32(mc_cg_registers[i], data); | ||
627 | } | ||
628 | } | ||
629 | |||
630 | static void gmc_v6_0_enable_bif_mgls(struct amdgpu_device *adev, | ||
631 | bool enable) | ||
632 | { | ||
633 | u32 orig, data; | ||
634 | |||
635 | orig = data = RREG32_PCIE(ixPCIE_CNTL2); | ||
636 | |||
637 | if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_BIF_LS)) { | ||
638 | data = REG_SET_FIELD(data, PCIE_CNTL2, SLV_MEM_LS_EN, 1); | ||
639 | data = REG_SET_FIELD(data, PCIE_CNTL2, MST_MEM_LS_EN, 1); | ||
640 | data = REG_SET_FIELD(data, PCIE_CNTL2, REPLAY_MEM_LS_EN, 1); | ||
641 | data = REG_SET_FIELD(data, PCIE_CNTL2, SLV_MEM_AGGRESSIVE_LS_EN, 1); | ||
642 | } else { | ||
643 | data = REG_SET_FIELD(data, PCIE_CNTL2, SLV_MEM_LS_EN, 0); | ||
644 | data = REG_SET_FIELD(data, PCIE_CNTL2, MST_MEM_LS_EN, 0); | ||
645 | data = REG_SET_FIELD(data, PCIE_CNTL2, REPLAY_MEM_LS_EN, 0); | ||
646 | data = REG_SET_FIELD(data, PCIE_CNTL2, SLV_MEM_AGGRESSIVE_LS_EN, 0); | ||
647 | } | ||
648 | |||
649 | if (orig != data) | ||
650 | WREG32_PCIE(ixPCIE_CNTL2, data); | ||
651 | } | ||
652 | |||
653 | static void gmc_v6_0_enable_hdp_mgcg(struct amdgpu_device *adev, | ||
654 | bool enable) | ||
655 | { | ||
656 | u32 orig, data; | ||
657 | |||
658 | orig = data = RREG32(HDP_HOST_PATH_CNTL); | ||
659 | |||
660 | if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_HDP_MGCG)) | ||
661 | data = REG_SET_FIELD(data, HDP_HOST_PATH_CNTL, CLOCK_GATING_DIS, 0); | ||
662 | else | ||
663 | data = REG_SET_FIELD(data, HDP_HOST_PATH_CNTL, CLOCK_GATING_DIS, 1); | ||
664 | |||
665 | if (orig != data) | ||
666 | WREG32(HDP_HOST_PATH_CNTL, data); | ||
667 | } | ||
668 | |||
669 | static void gmc_v6_0_enable_hdp_ls(struct amdgpu_device *adev, | ||
670 | bool enable) | ||
671 | { | ||
672 | u32 orig, data; | ||
673 | |||
674 | orig = data = RREG32(HDP_MEM_POWER_LS); | ||
675 | |||
676 | if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_HDP_LS)) | ||
677 | data = REG_SET_FIELD(data, HDP_MEM_POWER_LS, LS_ENABLE, 1); | ||
678 | else | ||
679 | data = REG_SET_FIELD(data, HDP_MEM_POWER_LS, LS_ENABLE, 0); | ||
680 | |||
681 | if (orig != data) | ||
682 | WREG32(HDP_MEM_POWER_LS, data); | ||
683 | } | ||
684 | */ | ||
685 | |||
686 | static int gmc_v6_0_convert_vram_type(int mc_seq_vram_type) | ||
687 | { | ||
688 | switch (mc_seq_vram_type) { | ||
689 | case MC_SEQ_MISC0__MT__GDDR1: | ||
690 | return AMDGPU_VRAM_TYPE_GDDR1; | ||
691 | case MC_SEQ_MISC0__MT__DDR2: | ||
692 | return AMDGPU_VRAM_TYPE_DDR2; | ||
693 | case MC_SEQ_MISC0__MT__GDDR3: | ||
694 | return AMDGPU_VRAM_TYPE_GDDR3; | ||
695 | case MC_SEQ_MISC0__MT__GDDR4: | ||
696 | return AMDGPU_VRAM_TYPE_GDDR4; | ||
697 | case MC_SEQ_MISC0__MT__GDDR5: | ||
698 | return AMDGPU_VRAM_TYPE_GDDR5; | ||
699 | case MC_SEQ_MISC0__MT__DDR3: | ||
700 | return AMDGPU_VRAM_TYPE_DDR3; | ||
701 | default: | ||
702 | return AMDGPU_VRAM_TYPE_UNKNOWN; | ||
703 | } | ||
704 | } | ||
705 | |||
706 | static int gmc_v6_0_early_init(void *handle) | ||
707 | { | ||
708 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
709 | |||
710 | gmc_v6_0_set_gart_funcs(adev); | ||
711 | gmc_v6_0_set_irq_funcs(adev); | ||
712 | |||
713 | if (adev->flags & AMD_IS_APU) { | ||
714 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | ||
715 | } else { | ||
716 | u32 tmp = RREG32(MC_SEQ_MISC0); | ||
717 | tmp &= MC_SEQ_MISC0__MT__MASK; | ||
718 | adev->mc.vram_type = gmc_v6_0_convert_vram_type(tmp); | ||
719 | } | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | static int gmc_v6_0_late_init(void *handle) | ||
725 | { | ||
726 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
727 | |||
728 | return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0); | ||
729 | } | ||
730 | |||
731 | static int gmc_v6_0_sw_init(void *handle) | ||
732 | { | ||
733 | int r; | ||
734 | int dma_bits; | ||
735 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
736 | |||
737 | r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); | ||
738 | if (r) | ||
739 | return r; | ||
740 | |||
741 | r = amdgpu_irq_add_id(adev, 147, &adev->mc.vm_fault); | ||
742 | if (r) | ||
743 | return r; | ||
744 | |||
745 | adev->vm_manager.max_pfn = amdgpu_vm_size << 18; | ||
746 | |||
747 | adev->mc.mc_mask = 0xffffffffffULL; | ||
748 | |||
749 | adev->need_dma32 = false; | ||
750 | dma_bits = adev->need_dma32 ? 32 : 40; | ||
751 | r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); | ||
752 | if (r) { | ||
753 | adev->need_dma32 = true; | ||
754 | dma_bits = 32; | ||
755 | dev_warn(adev->dev, "amdgpu: No suitable DMA available.\n"); | ||
756 | } | ||
757 | r = pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); | ||
758 | if (r) { | ||
759 | pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(32)); | ||
760 | dev_warn(adev->dev, "amdgpu: No coherent DMA available.\n"); | ||
761 | } | ||
762 | |||
763 | r = gmc_v6_0_init_microcode(adev); | ||
764 | if (r) { | ||
765 | dev_err(adev->dev, "Failed to load mc firmware!\n"); | ||
766 | return r; | ||
767 | } | ||
768 | |||
769 | r = amdgpu_ttm_global_init(adev); | ||
770 | if (r) { | ||
771 | return r; | ||
772 | } | ||
773 | |||
774 | r = gmc_v6_0_mc_init(adev); | ||
775 | if (r) | ||
776 | return r; | ||
777 | |||
778 | r = amdgpu_bo_init(adev); | ||
779 | if (r) | ||
780 | return r; | ||
781 | |||
782 | r = gmc_v6_0_gart_init(adev); | ||
783 | if (r) | ||
784 | return r; | ||
785 | |||
786 | if (!adev->vm_manager.enabled) { | ||
787 | r = gmc_v6_0_vm_init(adev); | ||
788 | if (r) { | ||
789 | dev_err(adev->dev, "vm manager initialization failed (%d).\n", r); | ||
790 | return r; | ||
791 | } | ||
792 | adev->vm_manager.enabled = true; | ||
793 | } | ||
794 | |||
795 | return r; | ||
796 | } | ||
797 | |||
798 | static int gmc_v6_0_sw_fini(void *handle) | ||
799 | { | ||
800 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
801 | |||
802 | if (adev->vm_manager.enabled) { | ||
803 | gmc_v6_0_vm_fini(adev); | ||
804 | adev->vm_manager.enabled = false; | ||
805 | } | ||
806 | gmc_v6_0_gart_fini(adev); | ||
807 | amdgpu_gem_force_release(adev); | ||
808 | amdgpu_bo_fini(adev); | ||
809 | |||
810 | return 0; | ||
811 | } | ||
812 | |||
813 | static int gmc_v6_0_hw_init(void *handle) | ||
814 | { | ||
815 | int r; | ||
816 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
817 | |||
818 | gmc_v6_0_mc_program(adev); | ||
819 | |||
820 | if (!(adev->flags & AMD_IS_APU)) { | ||
821 | r = gmc_v6_0_mc_load_microcode(adev); | ||
822 | if (r) { | ||
823 | dev_err(adev->dev, "Failed to load MC firmware!\n"); | ||
824 | return r; | ||
825 | } | ||
826 | } | ||
827 | |||
828 | r = gmc_v6_0_gart_enable(adev); | ||
829 | if (r) | ||
830 | return r; | ||
831 | |||
832 | return r; | ||
833 | } | ||
834 | |||
835 | static int gmc_v6_0_hw_fini(void *handle) | ||
836 | { | ||
837 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
838 | |||
839 | amdgpu_irq_put(adev, &adev->mc.vm_fault, 0); | ||
840 | gmc_v6_0_gart_disable(adev); | ||
841 | |||
842 | return 0; | ||
843 | } | ||
844 | |||
845 | static int gmc_v6_0_suspend(void *handle) | ||
846 | { | ||
847 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
848 | |||
849 | if (adev->vm_manager.enabled) { | ||
850 | gmc_v6_0_vm_fini(adev); | ||
851 | adev->vm_manager.enabled = false; | ||
852 | } | ||
853 | gmc_v6_0_hw_fini(adev); | ||
854 | |||
855 | return 0; | ||
856 | } | ||
857 | |||
858 | static int gmc_v6_0_resume(void *handle) | ||
859 | { | ||
860 | int r; | ||
861 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
862 | |||
863 | r = gmc_v6_0_hw_init(adev); | ||
864 | if (r) | ||
865 | return r; | ||
866 | |||
867 | if (!adev->vm_manager.enabled) { | ||
868 | r = gmc_v6_0_vm_init(adev); | ||
869 | if (r) { | ||
870 | dev_err(adev->dev, "vm manager initialization failed (%d).\n", r); | ||
871 | return r; | ||
872 | } | ||
873 | adev->vm_manager.enabled = true; | ||
874 | } | ||
875 | |||
876 | return r; | ||
877 | } | ||
878 | |||
879 | static bool gmc_v6_0_is_idle(void *handle) | ||
880 | { | ||
881 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
882 | u32 tmp = RREG32(SRBM_STATUS); | ||
883 | |||
884 | if (tmp & (SRBM_STATUS__MCB_BUSY_MASK | SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK | | ||
885 | SRBM_STATUS__MCC_BUSY_MASK | SRBM_STATUS__MCD_BUSY_MASK | SRBM_STATUS__VMC_BUSY_MASK)) | ||
886 | return false; | ||
887 | |||
888 | return true; | ||
889 | } | ||
890 | |||
891 | static int gmc_v6_0_wait_for_idle(void *handle) | ||
892 | { | ||
893 | unsigned i; | ||
894 | u32 tmp; | ||
895 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
896 | |||
897 | for (i = 0; i < adev->usec_timeout; i++) { | ||
898 | tmp = RREG32(SRBM_STATUS) & (SRBM_STATUS__MCB_BUSY_MASK | | ||
899 | SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK | | ||
900 | SRBM_STATUS__MCC_BUSY_MASK | | ||
901 | SRBM_STATUS__MCD_BUSY_MASK | | ||
902 | SRBM_STATUS__VMC_BUSY_MASK); | ||
903 | if (!tmp) | ||
904 | return 0; | ||
905 | udelay(1); | ||
906 | } | ||
907 | return -ETIMEDOUT; | ||
908 | |||
909 | } | ||
910 | |||
911 | static int gmc_v6_0_soft_reset(void *handle) | ||
912 | { | ||
913 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
914 | struct amdgpu_mode_mc_save save; | ||
915 | u32 srbm_soft_reset = 0; | ||
916 | u32 tmp = RREG32(SRBM_STATUS); | ||
917 | |||
918 | if (tmp & SRBM_STATUS__VMC_BUSY_MASK) | ||
919 | srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, | ||
920 | mmSRBM_SOFT_RESET, xxSOFT_RESET_VMC, 1); | ||
921 | |||
922 | if (tmp & (SRBM_STATUS__MCB_BUSY_MASK | SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK | | ||
923 | SRBM_STATUS__MCC_BUSY_MASK | SRBM_STATUS__MCD_BUSY_MASK)) { | ||
924 | if (!(adev->flags & AMD_IS_APU)) | ||
925 | srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, | ||
926 | mmSRBM_SOFT_RESET, xxSOFT_RESET_MC, 1); | ||
927 | } | ||
928 | |||
929 | if (srbm_soft_reset) { | ||
930 | gmc_v6_0_mc_stop(adev, &save); | ||
931 | if (gmc_v6_0_wait_for_idle(adev)) { | ||
932 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); | ||
933 | } | ||
934 | |||
935 | |||
936 | tmp = RREG32(SRBM_SOFT_RESET); | ||
937 | tmp |= srbm_soft_reset; | ||
938 | dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp); | ||
939 | WREG32(SRBM_SOFT_RESET, tmp); | ||
940 | tmp = RREG32(SRBM_SOFT_RESET); | ||
941 | |||
942 | udelay(50); | ||
943 | |||
944 | tmp &= ~srbm_soft_reset; | ||
945 | WREG32(SRBM_SOFT_RESET, tmp); | ||
946 | tmp = RREG32(SRBM_SOFT_RESET); | ||
947 | |||
948 | udelay(50); | ||
949 | |||
950 | gmc_v6_0_mc_resume(adev, &save); | ||
951 | udelay(50); | ||
952 | } | ||
953 | |||
954 | return 0; | ||
955 | } | ||
956 | |||
957 | static int gmc_v6_0_vm_fault_interrupt_state(struct amdgpu_device *adev, | ||
958 | struct amdgpu_irq_src *src, | ||
959 | unsigned type, | ||
960 | enum amdgpu_interrupt_state state) | ||
961 | { | ||
962 | u32 tmp; | ||
963 | u32 bits = (VM_CONTEXT1_CNTL__RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | | ||
964 | VM_CONTEXT1_CNTL__DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | | ||
965 | VM_CONTEXT1_CNTL__PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | | ||
966 | VM_CONTEXT1_CNTL__VALID_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | | ||
967 | VM_CONTEXT1_CNTL__READ_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | | ||
968 | VM_CONTEXT1_CNTL__WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK); | ||
969 | |||
970 | switch (state) { | ||
971 | case AMDGPU_IRQ_STATE_DISABLE: | ||
972 | tmp = RREG32(VM_CONTEXT0_CNTL); | ||
973 | tmp &= ~bits; | ||
974 | WREG32(VM_CONTEXT0_CNTL, tmp); | ||
975 | tmp = RREG32(VM_CONTEXT1_CNTL); | ||
976 | tmp &= ~bits; | ||
977 | WREG32(VM_CONTEXT1_CNTL, tmp); | ||
978 | break; | ||
979 | case AMDGPU_IRQ_STATE_ENABLE: | ||
980 | tmp = RREG32(VM_CONTEXT0_CNTL); | ||
981 | tmp |= bits; | ||
982 | WREG32(VM_CONTEXT0_CNTL, tmp); | ||
983 | tmp = RREG32(VM_CONTEXT1_CNTL); | ||
984 | tmp |= bits; | ||
985 | WREG32(VM_CONTEXT1_CNTL, tmp); | ||
986 | break; | ||
987 | default: | ||
988 | break; | ||
989 | } | ||
990 | |||
991 | return 0; | ||
992 | } | ||
993 | |||
994 | static int gmc_v6_0_process_interrupt(struct amdgpu_device *adev, | ||
995 | struct amdgpu_irq_src *source, | ||
996 | struct amdgpu_iv_entry *entry) | ||
997 | { | ||
998 | u32 addr, status; | ||
999 | |||
1000 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); | ||
1001 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); | ||
1002 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
1003 | |||
1004 | if (!addr && !status) | ||
1005 | return 0; | ||
1006 | |||
1007 | if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_FIRST) | ||
1008 | gmc_v6_0_set_fault_enable_default(adev, false); | ||
1009 | |||
1010 | dev_err(adev->dev, "GPU fault detected: %d 0x%08x\n", | ||
1011 | entry->src_id, entry->src_data); | ||
1012 | dev_err(adev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", | ||
1013 | addr); | ||
1014 | dev_err(adev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", | ||
1015 | status); | ||
1016 | gmc_v6_0_vm_decode_fault(adev, status, addr, 0); | ||
1017 | |||
1018 | return 0; | ||
1019 | } | ||
1020 | |||
1021 | static int gmc_v6_0_set_clockgating_state(void *handle, | ||
1022 | enum amd_clockgating_state state) | ||
1023 | { | ||
1024 | return 0; | ||
1025 | } | ||
1026 | |||
1027 | static int gmc_v6_0_set_powergating_state(void *handle, | ||
1028 | enum amd_powergating_state state) | ||
1029 | { | ||
1030 | return 0; | ||
1031 | } | ||
1032 | |||
1033 | const struct amd_ip_funcs gmc_v6_0_ip_funcs = { | ||
1034 | .name = "gmc_v6_0", | ||
1035 | .early_init = gmc_v6_0_early_init, | ||
1036 | .late_init = gmc_v6_0_late_init, | ||
1037 | .sw_init = gmc_v6_0_sw_init, | ||
1038 | .sw_fini = gmc_v6_0_sw_fini, | ||
1039 | .hw_init = gmc_v6_0_hw_init, | ||
1040 | .hw_fini = gmc_v6_0_hw_fini, | ||
1041 | .suspend = gmc_v6_0_suspend, | ||
1042 | .resume = gmc_v6_0_resume, | ||
1043 | .is_idle = gmc_v6_0_is_idle, | ||
1044 | .wait_for_idle = gmc_v6_0_wait_for_idle, | ||
1045 | .soft_reset = gmc_v6_0_soft_reset, | ||
1046 | .set_clockgating_state = gmc_v6_0_set_clockgating_state, | ||
1047 | .set_powergating_state = gmc_v6_0_set_powergating_state, | ||
1048 | }; | ||
1049 | |||
1050 | static const struct amdgpu_gart_funcs gmc_v6_0_gart_funcs = { | ||
1051 | .flush_gpu_tlb = gmc_v6_0_gart_flush_gpu_tlb, | ||
1052 | .set_pte_pde = gmc_v6_0_gart_set_pte_pde, | ||
1053 | }; | ||
1054 | |||
1055 | static const struct amdgpu_irq_src_funcs gmc_v6_0_irq_funcs = { | ||
1056 | .set = gmc_v6_0_vm_fault_interrupt_state, | ||
1057 | .process = gmc_v6_0_process_interrupt, | ||
1058 | }; | ||
1059 | |||
1060 | static void gmc_v6_0_set_gart_funcs(struct amdgpu_device *adev) | ||
1061 | { | ||
1062 | if (adev->gart.gart_funcs == NULL) | ||
1063 | adev->gart.gart_funcs = &gmc_v6_0_gart_funcs; | ||
1064 | } | ||
1065 | |||
1066 | static void gmc_v6_0_set_irq_funcs(struct amdgpu_device *adev) | ||
1067 | { | ||
1068 | adev->mc.vm_fault.num_types = 1; | ||
1069 | adev->mc.vm_fault.funcs = &gmc_v6_0_irq_funcs; | ||
1070 | } | ||
1071 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.h b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.h new file mode 100644 index 000000000000..42c4fc676cd4 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __GMC_V6_0_H__ | ||
25 | #define __GMC_V6_0_H__ | ||
26 | |||
27 | extern const struct amd_ip_funcs gmc_v6_0_ip_funcs; | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_smc.c b/drivers/gpu/drm/amd/amdgpu/iceland_smc.c index 211839913728..ef7c27d7356a 100644 --- a/drivers/gpu/drm/amd/amdgpu/iceland_smc.c +++ b/drivers/gpu/drm/amd/amdgpu/iceland_smc.c | |||
@@ -121,7 +121,7 @@ out: | |||
121 | return result; | 121 | return result; |
122 | } | 122 | } |
123 | 123 | ||
124 | void iceland_start_smc(struct amdgpu_device *adev) | 124 | static void iceland_start_smc(struct amdgpu_device *adev) |
125 | { | 125 | { |
126 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_RESET_CNTL); | 126 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_RESET_CNTL); |
127 | 127 | ||
@@ -129,7 +129,7 @@ void iceland_start_smc(struct amdgpu_device *adev) | |||
129 | WREG32_SMC(ixSMC_SYSCON_RESET_CNTL, val); | 129 | WREG32_SMC(ixSMC_SYSCON_RESET_CNTL, val); |
130 | } | 130 | } |
131 | 131 | ||
132 | void iceland_reset_smc(struct amdgpu_device *adev) | 132 | static void iceland_reset_smc(struct amdgpu_device *adev) |
133 | { | 133 | { |
134 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_RESET_CNTL); | 134 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_RESET_CNTL); |
135 | 135 | ||
@@ -145,7 +145,7 @@ static int iceland_program_jump_on_start(struct amdgpu_device *adev) | |||
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | void iceland_stop_smc_clock(struct amdgpu_device *adev) | 148 | static void iceland_stop_smc_clock(struct amdgpu_device *adev) |
149 | { | 149 | { |
150 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0); | 150 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0); |
151 | 151 | ||
@@ -153,7 +153,7 @@ void iceland_stop_smc_clock(struct amdgpu_device *adev) | |||
153 | WREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0, val); | 153 | WREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0, val); |
154 | } | 154 | } |
155 | 155 | ||
156 | void iceland_start_smc_clock(struct amdgpu_device *adev) | 156 | static void iceland_start_smc_clock(struct amdgpu_device *adev) |
157 | { | 157 | { |
158 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0); | 158 | uint32_t val = RREG32_SMC(ixSMC_SYSCON_CLOCK_CNTL_0); |
159 | 159 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/r600_dpm.h b/drivers/gpu/drm/amd/amdgpu/r600_dpm.h new file mode 100644 index 000000000000..055321f61ca7 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/r600_dpm.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #ifndef __R600_DPM_H__ | ||
24 | #define __R600_DPM_H__ | ||
25 | |||
26 | #define R600_ASI_DFLT 10000 | ||
27 | #define R600_BSP_DFLT 0x41EB | ||
28 | #define R600_BSU_DFLT 0x2 | ||
29 | #define R600_AH_DFLT 5 | ||
30 | #define R600_RLP_DFLT 25 | ||
31 | #define R600_RMP_DFLT 65 | ||
32 | #define R600_LHP_DFLT 40 | ||
33 | #define R600_LMP_DFLT 15 | ||
34 | #define R600_TD_DFLT 0 | ||
35 | #define R600_UTC_DFLT_00 0x24 | ||
36 | #define R600_UTC_DFLT_01 0x22 | ||
37 | #define R600_UTC_DFLT_02 0x22 | ||
38 | #define R600_UTC_DFLT_03 0x22 | ||
39 | #define R600_UTC_DFLT_04 0x22 | ||
40 | #define R600_UTC_DFLT_05 0x22 | ||
41 | #define R600_UTC_DFLT_06 0x22 | ||
42 | #define R600_UTC_DFLT_07 0x22 | ||
43 | #define R600_UTC_DFLT_08 0x22 | ||
44 | #define R600_UTC_DFLT_09 0x22 | ||
45 | #define R600_UTC_DFLT_10 0x22 | ||
46 | #define R600_UTC_DFLT_11 0x22 | ||
47 | #define R600_UTC_DFLT_12 0x22 | ||
48 | #define R600_UTC_DFLT_13 0x22 | ||
49 | #define R600_UTC_DFLT_14 0x22 | ||
50 | #define R600_DTC_DFLT_00 0x24 | ||
51 | #define R600_DTC_DFLT_01 0x22 | ||
52 | #define R600_DTC_DFLT_02 0x22 | ||
53 | #define R600_DTC_DFLT_03 0x22 | ||
54 | #define R600_DTC_DFLT_04 0x22 | ||
55 | #define R600_DTC_DFLT_05 0x22 | ||
56 | #define R600_DTC_DFLT_06 0x22 | ||
57 | #define R600_DTC_DFLT_07 0x22 | ||
58 | #define R600_DTC_DFLT_08 0x22 | ||
59 | #define R600_DTC_DFLT_09 0x22 | ||
60 | #define R600_DTC_DFLT_10 0x22 | ||
61 | #define R600_DTC_DFLT_11 0x22 | ||
62 | #define R600_DTC_DFLT_12 0x22 | ||
63 | #define R600_DTC_DFLT_13 0x22 | ||
64 | #define R600_DTC_DFLT_14 0x22 | ||
65 | #define R600_VRC_DFLT 0x0000C003 | ||
66 | #define R600_VOLTAGERESPONSETIME_DFLT 1000 | ||
67 | #define R600_BACKBIASRESPONSETIME_DFLT 1000 | ||
68 | #define R600_VRU_DFLT 0x3 | ||
69 | #define R600_SPLLSTEPTIME_DFLT 0x1000 | ||
70 | #define R600_SPLLSTEPUNIT_DFLT 0x3 | ||
71 | #define R600_TPU_DFLT 0 | ||
72 | #define R600_TPC_DFLT 0x200 | ||
73 | #define R600_SSTU_DFLT 0 | ||
74 | #define R600_SST_DFLT 0x00C8 | ||
75 | #define R600_GICST_DFLT 0x200 | ||
76 | #define R600_FCT_DFLT 0x0400 | ||
77 | #define R600_FCTU_DFLT 0 | ||
78 | #define R600_CTXCGTT3DRPHC_DFLT 0x20 | ||
79 | #define R600_CTXCGTT3DRSDC_DFLT 0x40 | ||
80 | #define R600_VDDC3DOORPHC_DFLT 0x100 | ||
81 | #define R600_VDDC3DOORSDC_DFLT 0x7 | ||
82 | #define R600_VDDC3DOORSU_DFLT 0 | ||
83 | #define R600_MPLLLOCKTIME_DFLT 100 | ||
84 | #define R600_MPLLRESETTIME_DFLT 150 | ||
85 | #define R600_VCOSTEPPCT_DFLT 20 | ||
86 | #define R600_ENDINGVCOSTEPPCT_DFLT 5 | ||
87 | #define R600_REFERENCEDIVIDER_DFLT 4 | ||
88 | |||
89 | #define R600_PM_NUMBER_OF_TC 15 | ||
90 | #define R600_PM_NUMBER_OF_SCLKS 20 | ||
91 | #define R600_PM_NUMBER_OF_MCLKS 4 | ||
92 | #define R600_PM_NUMBER_OF_VOLTAGE_LEVELS 4 | ||
93 | #define R600_PM_NUMBER_OF_ACTIVITY_LEVELS 3 | ||
94 | |||
95 | /* XXX are these ok? */ | ||
96 | #define R600_TEMP_RANGE_MIN (90 * 1000) | ||
97 | #define R600_TEMP_RANGE_MAX (120 * 1000) | ||
98 | |||
99 | #define FDO_PWM_MODE_STATIC 1 | ||
100 | #define FDO_PWM_MODE_STATIC_RPM 5 | ||
101 | |||
102 | enum r600_power_level { | ||
103 | R600_POWER_LEVEL_LOW = 0, | ||
104 | R600_POWER_LEVEL_MEDIUM = 1, | ||
105 | R600_POWER_LEVEL_HIGH = 2, | ||
106 | R600_POWER_LEVEL_CTXSW = 3, | ||
107 | }; | ||
108 | |||
109 | enum r600_td { | ||
110 | R600_TD_AUTO, | ||
111 | R600_TD_UP, | ||
112 | R600_TD_DOWN, | ||
113 | }; | ||
114 | |||
115 | enum r600_display_watermark { | ||
116 | R600_DISPLAY_WATERMARK_LOW = 0, | ||
117 | R600_DISPLAY_WATERMARK_HIGH = 1, | ||
118 | }; | ||
119 | |||
120 | enum r600_display_gap | ||
121 | { | ||
122 | R600_PM_DISPLAY_GAP_VBLANK_OR_WM = 0, | ||
123 | R600_PM_DISPLAY_GAP_VBLANK = 1, | ||
124 | R600_PM_DISPLAY_GAP_WATERMARK = 2, | ||
125 | R600_PM_DISPLAY_GAP_IGNORE = 3, | ||
126 | }; | ||
127 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c index 9d02ba27bb87..9ae307505190 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | |||
@@ -902,6 +902,22 @@ static void sdma_v2_4_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
902 | SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); /* retry count, poll interval */ | 902 | SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); /* retry count, poll interval */ |
903 | } | 903 | } |
904 | 904 | ||
905 | static unsigned sdma_v2_4_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
906 | { | ||
907 | return | ||
908 | 7 + 6; /* sdma_v2_4_ring_emit_ib */ | ||
909 | } | ||
910 | |||
911 | static unsigned sdma_v2_4_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
912 | { | ||
913 | return | ||
914 | 6 + /* sdma_v2_4_ring_emit_hdp_flush */ | ||
915 | 3 + /* sdma_v2_4_ring_emit_hdp_invalidate */ | ||
916 | 6 + /* sdma_v2_4_ring_emit_pipeline_sync */ | ||
917 | 12 + /* sdma_v2_4_ring_emit_vm_flush */ | ||
918 | 10 + 10 + 10; /* sdma_v2_4_ring_emit_fence x3 for user fence, vm fence */ | ||
919 | } | ||
920 | |||
905 | static int sdma_v2_4_early_init(void *handle) | 921 | static int sdma_v2_4_early_init(void *handle) |
906 | { | 922 | { |
907 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 923 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
@@ -1220,6 +1236,8 @@ static const struct amdgpu_ring_funcs sdma_v2_4_ring_funcs = { | |||
1220 | .test_ib = sdma_v2_4_ring_test_ib, | 1236 | .test_ib = sdma_v2_4_ring_test_ib, |
1221 | .insert_nop = sdma_v2_4_ring_insert_nop, | 1237 | .insert_nop = sdma_v2_4_ring_insert_nop, |
1222 | .pad_ib = sdma_v2_4_ring_pad_ib, | 1238 | .pad_ib = sdma_v2_4_ring_pad_ib, |
1239 | .get_emit_ib_size = sdma_v2_4_ring_get_emit_ib_size, | ||
1240 | .get_dma_frame_size = sdma_v2_4_ring_get_dma_frame_size, | ||
1223 | }; | 1241 | }; |
1224 | 1242 | ||
1225 | static void sdma_v2_4_set_ring_funcs(struct amdgpu_device *adev) | 1243 | static void sdma_v2_4_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index ddb8081f78ac..f325fd86430b 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
@@ -495,31 +495,6 @@ static void sdma_v3_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se | |||
495 | amdgpu_ring_write(ring, SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT(0)); | 495 | amdgpu_ring_write(ring, SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT(0)); |
496 | } | 496 | } |
497 | 497 | ||
498 | unsigned init_cond_exec(struct amdgpu_ring *ring) | ||
499 | { | ||
500 | unsigned ret; | ||
501 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_COND_EXE)); | ||
502 | amdgpu_ring_write(ring, lower_32_bits(ring->cond_exe_gpu_addr)); | ||
503 | amdgpu_ring_write(ring, upper_32_bits(ring->cond_exe_gpu_addr)); | ||
504 | amdgpu_ring_write(ring, 1); | ||
505 | ret = ring->wptr;/* this is the offset we need patch later */ | ||
506 | amdgpu_ring_write(ring, 0x55aa55aa);/* insert dummy here and patch it later */ | ||
507 | return ret; | ||
508 | } | ||
509 | |||
510 | void patch_cond_exec(struct amdgpu_ring *ring, unsigned offset) | ||
511 | { | ||
512 | unsigned cur; | ||
513 | BUG_ON(ring->ring[offset] != 0x55aa55aa); | ||
514 | |||
515 | cur = ring->wptr - 1; | ||
516 | if (likely(cur > offset)) | ||
517 | ring->ring[offset] = cur - offset; | ||
518 | else | ||
519 | ring->ring[offset] = (ring->ring_size>>2) - offset + cur; | ||
520 | } | ||
521 | |||
522 | |||
523 | /** | 498 | /** |
524 | * sdma_v3_0_gfx_stop - stop the gfx async dma engines | 499 | * sdma_v3_0_gfx_stop - stop the gfx async dma engines |
525 | * | 500 | * |
@@ -1129,6 +1104,22 @@ static void sdma_v3_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1129 | SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); /* retry count, poll interval */ | 1104 | SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); /* retry count, poll interval */ |
1130 | } | 1105 | } |
1131 | 1106 | ||
1107 | static unsigned sdma_v3_0_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
1108 | { | ||
1109 | return | ||
1110 | 7 + 6; /* sdma_v3_0_ring_emit_ib */ | ||
1111 | } | ||
1112 | |||
1113 | static unsigned sdma_v3_0_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
1114 | { | ||
1115 | return | ||
1116 | 6 + /* sdma_v3_0_ring_emit_hdp_flush */ | ||
1117 | 3 + /* sdma_v3_0_ring_emit_hdp_invalidate */ | ||
1118 | 6 + /* sdma_v3_0_ring_emit_pipeline_sync */ | ||
1119 | 12 + /* sdma_v3_0_ring_emit_vm_flush */ | ||
1120 | 10 + 10 + 10; /* sdma_v3_0_ring_emit_fence x3 for user fence, vm fence */ | ||
1121 | } | ||
1122 | |||
1132 | static int sdma_v3_0_early_init(void *handle) | 1123 | static int sdma_v3_0_early_init(void *handle) |
1133 | { | 1124 | { |
1134 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1125 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
@@ -1590,6 +1581,8 @@ static const struct amdgpu_ring_funcs sdma_v3_0_ring_funcs = { | |||
1590 | .test_ib = sdma_v3_0_ring_test_ib, | 1581 | .test_ib = sdma_v3_0_ring_test_ib, |
1591 | .insert_nop = sdma_v3_0_ring_insert_nop, | 1582 | .insert_nop = sdma_v3_0_ring_insert_nop, |
1592 | .pad_ib = sdma_v3_0_ring_pad_ib, | 1583 | .pad_ib = sdma_v3_0_ring_pad_ib, |
1584 | .get_emit_ib_size = sdma_v3_0_ring_get_emit_ib_size, | ||
1585 | .get_dma_frame_size = sdma_v3_0_ring_get_dma_frame_size, | ||
1593 | }; | 1586 | }; |
1594 | 1587 | ||
1595 | static void sdma_v3_0_set_ring_funcs(struct amdgpu_device *adev) | 1588 | static void sdma_v3_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c new file mode 100644 index 000000000000..fee76b8a536f --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -0,0 +1,1965 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/firmware.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/module.h> | ||
27 | #include "drmP.h" | ||
28 | #include "amdgpu.h" | ||
29 | #include "amdgpu_atombios.h" | ||
30 | #include "amdgpu_ih.h" | ||
31 | #include "amdgpu_uvd.h" | ||
32 | #include "amdgpu_vce.h" | ||
33 | #include "atom.h" | ||
34 | #include "amdgpu_powerplay.h" | ||
35 | #include "si/sid.h" | ||
36 | #include "si_ih.h" | ||
37 | #include "gfx_v6_0.h" | ||
38 | #include "gmc_v6_0.h" | ||
39 | #include "si_dma.h" | ||
40 | #include "dce_v6_0.h" | ||
41 | #include "si.h" | ||
42 | |||
43 | static const u32 tahiti_golden_registers[] = | ||
44 | { | ||
45 | 0x2684, 0x00010000, 0x00018208, | ||
46 | 0x260c, 0xffffffff, 0x00000000, | ||
47 | 0x260d, 0xf00fffff, 0x00000400, | ||
48 | 0x260e, 0x0002021c, 0x00020200, | ||
49 | 0x031e, 0x00000080, 0x00000000, | ||
50 | 0x340c, 0x000300c0, 0x00800040, | ||
51 | 0x360c, 0x000300c0, 0x00800040, | ||
52 | 0x16ec, 0x000000f0, 0x00000070, | ||
53 | 0x16f0, 0x00200000, 0x50100000, | ||
54 | 0x1c0c, 0x31000311, 0x00000011, | ||
55 | 0x09df, 0x00000003, 0x000007ff, | ||
56 | 0x0903, 0x000007ff, 0x00000000, | ||
57 | 0x2285, 0xf000001f, 0x00000007, | ||
58 | 0x22c9, 0xffffffff, 0x00ffffff, | ||
59 | 0x22c4, 0x0000ff0f, 0x00000000, | ||
60 | 0xa293, 0x07ffffff, 0x4e000000, | ||
61 | 0xa0d4, 0x3f3f3fff, 0x2a00126a, | ||
62 | 0x000c, 0x000000ff, 0x0040, | ||
63 | 0x000d, 0x00000040, 0x00004040, | ||
64 | 0x2440, 0x07ffffff, 0x03000000, | ||
65 | 0x23a2, 0x01ff1f3f, 0x00000000, | ||
66 | 0x23a1, 0x01ff1f3f, 0x00000000, | ||
67 | 0x2418, 0x0000007f, 0x00000020, | ||
68 | 0x2542, 0x00010000, 0x00010000, | ||
69 | 0x2b05, 0x00000200, 0x000002fb, | ||
70 | 0x2b04, 0xffffffff, 0x0000543b, | ||
71 | 0x2b03, 0xffffffff, 0xa9210876, | ||
72 | 0x2234, 0xffffffff, 0x000fff40, | ||
73 | 0x2235, 0x0000001f, 0x00000010, | ||
74 | 0x0504, 0x20000000, 0x20fffed8, | ||
75 | 0x0570, 0x000c0fc0, 0x000c0400 | ||
76 | }; | ||
77 | |||
78 | static const u32 tahiti_golden_registers2[] = | ||
79 | { | ||
80 | 0x0319, 0x00000001, 0x00000001 | ||
81 | }; | ||
82 | |||
83 | static const u32 tahiti_golden_rlc_registers[] = | ||
84 | { | ||
85 | 0x3109, 0xffffffff, 0x00601005, | ||
86 | 0x311f, 0xffffffff, 0x10104040, | ||
87 | 0x3122, 0xffffffff, 0x0100000a, | ||
88 | 0x30c5, 0xffffffff, 0x00000800, | ||
89 | 0x30c3, 0xffffffff, 0x800000f4, | ||
90 | 0x3d2a, 0xffffffff, 0x00000000 | ||
91 | }; | ||
92 | |||
93 | static const u32 pitcairn_golden_registers[] = | ||
94 | { | ||
95 | 0x2684, 0x00010000, 0x00018208, | ||
96 | 0x260c, 0xffffffff, 0x00000000, | ||
97 | 0x260d, 0xf00fffff, 0x00000400, | ||
98 | 0x260e, 0x0002021c, 0x00020200, | ||
99 | 0x031e, 0x00000080, 0x00000000, | ||
100 | 0x340c, 0x000300c0, 0x00800040, | ||
101 | 0x360c, 0x000300c0, 0x00800040, | ||
102 | 0x16ec, 0x000000f0, 0x00000070, | ||
103 | 0x16f0, 0x00200000, 0x50100000, | ||
104 | 0x1c0c, 0x31000311, 0x00000011, | ||
105 | 0x0ab9, 0x00073ffe, 0x000022a2, | ||
106 | 0x0903, 0x000007ff, 0x00000000, | ||
107 | 0x2285, 0xf000001f, 0x00000007, | ||
108 | 0x22c9, 0xffffffff, 0x00ffffff, | ||
109 | 0x22c4, 0x0000ff0f, 0x00000000, | ||
110 | 0xa293, 0x07ffffff, 0x4e000000, | ||
111 | 0xa0d4, 0x3f3f3fff, 0x2a00126a, | ||
112 | 0x000c, 0x000000ff, 0x0040, | ||
113 | 0x000d, 0x00000040, 0x00004040, | ||
114 | 0x2440, 0x07ffffff, 0x03000000, | ||
115 | 0x2418, 0x0000007f, 0x00000020, | ||
116 | 0x2542, 0x00010000, 0x00010000, | ||
117 | 0x2b05, 0x000003ff, 0x000000f7, | ||
118 | 0x2b04, 0xffffffff, 0x00000000, | ||
119 | 0x2b03, 0xffffffff, 0x32761054, | ||
120 | 0x2235, 0x0000001f, 0x00000010, | ||
121 | 0x0570, 0x000c0fc0, 0x000c0400 | ||
122 | }; | ||
123 | |||
124 | static const u32 pitcairn_golden_rlc_registers[] = | ||
125 | { | ||
126 | 0x3109, 0xffffffff, 0x00601004, | ||
127 | 0x311f, 0xffffffff, 0x10102020, | ||
128 | 0x3122, 0xffffffff, 0x01000020, | ||
129 | 0x30c5, 0xffffffff, 0x00000800, | ||
130 | 0x30c3, 0xffffffff, 0x800000a4 | ||
131 | }; | ||
132 | |||
133 | static const u32 verde_pg_init[] = | ||
134 | { | ||
135 | 0xd4f, 0xffffffff, 0x40000, | ||
136 | 0xd4e, 0xffffffff, 0x200010ff, | ||
137 | 0xd4f, 0xffffffff, 0x0, | ||
138 | 0xd4f, 0xffffffff, 0x0, | ||
139 | 0xd4f, 0xffffffff, 0x0, | ||
140 | 0xd4f, 0xffffffff, 0x0, | ||
141 | 0xd4f, 0xffffffff, 0x0, | ||
142 | 0xd4f, 0xffffffff, 0x7007, | ||
143 | 0xd4e, 0xffffffff, 0x300010ff, | ||
144 | 0xd4f, 0xffffffff, 0x0, | ||
145 | 0xd4f, 0xffffffff, 0x0, | ||
146 | 0xd4f, 0xffffffff, 0x0, | ||
147 | 0xd4f, 0xffffffff, 0x0, | ||
148 | 0xd4f, 0xffffffff, 0x0, | ||
149 | 0xd4f, 0xffffffff, 0x400000, | ||
150 | 0xd4e, 0xffffffff, 0x100010ff, | ||
151 | 0xd4f, 0xffffffff, 0x0, | ||
152 | 0xd4f, 0xffffffff, 0x0, | ||
153 | 0xd4f, 0xffffffff, 0x0, | ||
154 | 0xd4f, 0xffffffff, 0x0, | ||
155 | 0xd4f, 0xffffffff, 0x0, | ||
156 | 0xd4f, 0xffffffff, 0x120200, | ||
157 | 0xd4e, 0xffffffff, 0x500010ff, | ||
158 | 0xd4f, 0xffffffff, 0x0, | ||
159 | 0xd4f, 0xffffffff, 0x0, | ||
160 | 0xd4f, 0xffffffff, 0x0, | ||
161 | 0xd4f, 0xffffffff, 0x0, | ||
162 | 0xd4f, 0xffffffff, 0x0, | ||
163 | 0xd4f, 0xffffffff, 0x1e1e16, | ||
164 | 0xd4e, 0xffffffff, 0x600010ff, | ||
165 | 0xd4f, 0xffffffff, 0x0, | ||
166 | 0xd4f, 0xffffffff, 0x0, | ||
167 | 0xd4f, 0xffffffff, 0x0, | ||
168 | 0xd4f, 0xffffffff, 0x0, | ||
169 | 0xd4f, 0xffffffff, 0x0, | ||
170 | 0xd4f, 0xffffffff, 0x171f1e, | ||
171 | 0xd4e, 0xffffffff, 0x700010ff, | ||
172 | 0xd4f, 0xffffffff, 0x0, | ||
173 | 0xd4f, 0xffffffff, 0x0, | ||
174 | 0xd4f, 0xffffffff, 0x0, | ||
175 | 0xd4f, 0xffffffff, 0x0, | ||
176 | 0xd4f, 0xffffffff, 0x0, | ||
177 | 0xd4f, 0xffffffff, 0x0, | ||
178 | 0xd4e, 0xffffffff, 0x9ff, | ||
179 | 0xd40, 0xffffffff, 0x0, | ||
180 | 0xd41, 0xffffffff, 0x10000800, | ||
181 | 0xd41, 0xffffffff, 0xf, | ||
182 | 0xd41, 0xffffffff, 0xf, | ||
183 | 0xd40, 0xffffffff, 0x4, | ||
184 | 0xd41, 0xffffffff, 0x1000051e, | ||
185 | 0xd41, 0xffffffff, 0xffff, | ||
186 | 0xd41, 0xffffffff, 0xffff, | ||
187 | 0xd40, 0xffffffff, 0x8, | ||
188 | 0xd41, 0xffffffff, 0x80500, | ||
189 | 0xd40, 0xffffffff, 0x12, | ||
190 | 0xd41, 0xffffffff, 0x9050c, | ||
191 | 0xd40, 0xffffffff, 0x1d, | ||
192 | 0xd41, 0xffffffff, 0xb052c, | ||
193 | 0xd40, 0xffffffff, 0x2a, | ||
194 | 0xd41, 0xffffffff, 0x1053e, | ||
195 | 0xd40, 0xffffffff, 0x2d, | ||
196 | 0xd41, 0xffffffff, 0x10546, | ||
197 | 0xd40, 0xffffffff, 0x30, | ||
198 | 0xd41, 0xffffffff, 0xa054e, | ||
199 | 0xd40, 0xffffffff, 0x3c, | ||
200 | 0xd41, 0xffffffff, 0x1055f, | ||
201 | 0xd40, 0xffffffff, 0x3f, | ||
202 | 0xd41, 0xffffffff, 0x10567, | ||
203 | 0xd40, 0xffffffff, 0x42, | ||
204 | 0xd41, 0xffffffff, 0x1056f, | ||
205 | 0xd40, 0xffffffff, 0x45, | ||
206 | 0xd41, 0xffffffff, 0x10572, | ||
207 | 0xd40, 0xffffffff, 0x48, | ||
208 | 0xd41, 0xffffffff, 0x20575, | ||
209 | 0xd40, 0xffffffff, 0x4c, | ||
210 | 0xd41, 0xffffffff, 0x190801, | ||
211 | 0xd40, 0xffffffff, 0x67, | ||
212 | 0xd41, 0xffffffff, 0x1082a, | ||
213 | 0xd40, 0xffffffff, 0x6a, | ||
214 | 0xd41, 0xffffffff, 0x1b082d, | ||
215 | 0xd40, 0xffffffff, 0x87, | ||
216 | 0xd41, 0xffffffff, 0x310851, | ||
217 | 0xd40, 0xffffffff, 0xba, | ||
218 | 0xd41, 0xffffffff, 0x891, | ||
219 | 0xd40, 0xffffffff, 0xbc, | ||
220 | 0xd41, 0xffffffff, 0x893, | ||
221 | 0xd40, 0xffffffff, 0xbe, | ||
222 | 0xd41, 0xffffffff, 0x20895, | ||
223 | 0xd40, 0xffffffff, 0xc2, | ||
224 | 0xd41, 0xffffffff, 0x20899, | ||
225 | 0xd40, 0xffffffff, 0xc6, | ||
226 | 0xd41, 0xffffffff, 0x2089d, | ||
227 | 0xd40, 0xffffffff, 0xca, | ||
228 | 0xd41, 0xffffffff, 0x8a1, | ||
229 | 0xd40, 0xffffffff, 0xcc, | ||
230 | 0xd41, 0xffffffff, 0x8a3, | ||
231 | 0xd40, 0xffffffff, 0xce, | ||
232 | 0xd41, 0xffffffff, 0x308a5, | ||
233 | 0xd40, 0xffffffff, 0xd3, | ||
234 | 0xd41, 0xffffffff, 0x6d08cd, | ||
235 | 0xd40, 0xffffffff, 0x142, | ||
236 | 0xd41, 0xffffffff, 0x2000095a, | ||
237 | 0xd41, 0xffffffff, 0x1, | ||
238 | 0xd40, 0xffffffff, 0x144, | ||
239 | 0xd41, 0xffffffff, 0x301f095b, | ||
240 | 0xd40, 0xffffffff, 0x165, | ||
241 | 0xd41, 0xffffffff, 0xc094d, | ||
242 | 0xd40, 0xffffffff, 0x173, | ||
243 | 0xd41, 0xffffffff, 0xf096d, | ||
244 | 0xd40, 0xffffffff, 0x184, | ||
245 | 0xd41, 0xffffffff, 0x15097f, | ||
246 | 0xd40, 0xffffffff, 0x19b, | ||
247 | 0xd41, 0xffffffff, 0xc0998, | ||
248 | 0xd40, 0xffffffff, 0x1a9, | ||
249 | 0xd41, 0xffffffff, 0x409a7, | ||
250 | 0xd40, 0xffffffff, 0x1af, | ||
251 | 0xd41, 0xffffffff, 0xcdc, | ||
252 | 0xd40, 0xffffffff, 0x1b1, | ||
253 | 0xd41, 0xffffffff, 0x800, | ||
254 | 0xd42, 0xffffffff, 0x6c9b2000, | ||
255 | 0xd44, 0xfc00, 0x2000, | ||
256 | 0xd51, 0xffffffff, 0xfc0, | ||
257 | 0xa35, 0x00000100, 0x100 | ||
258 | }; | ||
259 | |||
260 | static const u32 verde_golden_rlc_registers[] = | ||
261 | { | ||
262 | 0x3109, 0xffffffff, 0x033f1005, | ||
263 | 0x311f, 0xffffffff, 0x10808020, | ||
264 | 0x3122, 0xffffffff, 0x00800008, | ||
265 | 0x30c5, 0xffffffff, 0x00001000, | ||
266 | 0x30c3, 0xffffffff, 0x80010014 | ||
267 | }; | ||
268 | |||
269 | static const u32 verde_golden_registers[] = | ||
270 | { | ||
271 | 0x2684, 0x00010000, 0x00018208, | ||
272 | 0x260c, 0xffffffff, 0x00000000, | ||
273 | 0x260d, 0xf00fffff, 0x00000400, | ||
274 | 0x260e, 0x0002021c, 0x00020200, | ||
275 | 0x031e, 0x00000080, 0x00000000, | ||
276 | 0x340c, 0x000300c0, 0x00800040, | ||
277 | 0x340c, 0x000300c0, 0x00800040, | ||
278 | 0x360c, 0x000300c0, 0x00800040, | ||
279 | 0x360c, 0x000300c0, 0x00800040, | ||
280 | 0x16ec, 0x000000f0, 0x00000070, | ||
281 | 0x16f0, 0x00200000, 0x50100000, | ||
282 | |||
283 | 0x1c0c, 0x31000311, 0x00000011, | ||
284 | 0x0ab9, 0x00073ffe, 0x000022a2, | ||
285 | 0x0ab9, 0x00073ffe, 0x000022a2, | ||
286 | 0x0ab9, 0x00073ffe, 0x000022a2, | ||
287 | 0x0903, 0x000007ff, 0x00000000, | ||
288 | 0x0903, 0x000007ff, 0x00000000, | ||
289 | 0x0903, 0x000007ff, 0x00000000, | ||
290 | 0x2285, 0xf000001f, 0x00000007, | ||
291 | 0x2285, 0xf000001f, 0x00000007, | ||
292 | 0x2285, 0xf000001f, 0x00000007, | ||
293 | 0x2285, 0xffffffff, 0x00ffffff, | ||
294 | 0x22c4, 0x0000ff0f, 0x00000000, | ||
295 | |||
296 | 0xa293, 0x07ffffff, 0x4e000000, | ||
297 | 0xa0d4, 0x3f3f3fff, 0x0000124a, | ||
298 | 0xa0d4, 0x3f3f3fff, 0x0000124a, | ||
299 | 0xa0d4, 0x3f3f3fff, 0x0000124a, | ||
300 | 0x000c, 0x000000ff, 0x0040, | ||
301 | 0x000d, 0x00000040, 0x00004040, | ||
302 | 0x2440, 0x07ffffff, 0x03000000, | ||
303 | 0x2440, 0x07ffffff, 0x03000000, | ||
304 | 0x23a2, 0x01ff1f3f, 0x00000000, | ||
305 | 0x23a3, 0x01ff1f3f, 0x00000000, | ||
306 | 0x23a2, 0x01ff1f3f, 0x00000000, | ||
307 | 0x23a1, 0x01ff1f3f, 0x00000000, | ||
308 | 0x23a1, 0x01ff1f3f, 0x00000000, | ||
309 | |||
310 | 0x23a1, 0x01ff1f3f, 0x00000000, | ||
311 | 0x2418, 0x0000007f, 0x00000020, | ||
312 | 0x2542, 0x00010000, 0x00010000, | ||
313 | 0x2b01, 0x000003ff, 0x00000003, | ||
314 | 0x2b05, 0x000003ff, 0x00000003, | ||
315 | 0x2b05, 0x000003ff, 0x00000003, | ||
316 | 0x2b04, 0xffffffff, 0x00000000, | ||
317 | 0x2b04, 0xffffffff, 0x00000000, | ||
318 | 0x2b04, 0xffffffff, 0x00000000, | ||
319 | 0x2b03, 0xffffffff, 0x00001032, | ||
320 | 0x2b03, 0xffffffff, 0x00001032, | ||
321 | 0x2b03, 0xffffffff, 0x00001032, | ||
322 | 0x2235, 0x0000001f, 0x00000010, | ||
323 | 0x2235, 0x0000001f, 0x00000010, | ||
324 | 0x2235, 0x0000001f, 0x00000010, | ||
325 | 0x0570, 0x000c0fc0, 0x000c0400 | ||
326 | }; | ||
327 | |||
328 | static const u32 oland_golden_registers[] = | ||
329 | { | ||
330 | 0x2684, 0x00010000, 0x00018208, | ||
331 | 0x260c, 0xffffffff, 0x00000000, | ||
332 | 0x260d, 0xf00fffff, 0x00000400, | ||
333 | 0x260e, 0x0002021c, 0x00020200, | ||
334 | 0x031e, 0x00000080, 0x00000000, | ||
335 | 0x340c, 0x000300c0, 0x00800040, | ||
336 | 0x360c, 0x000300c0, 0x00800040, | ||
337 | 0x16ec, 0x000000f0, 0x00000070, | ||
338 | 0x16f9, 0x00200000, 0x50100000, | ||
339 | 0x1c0c, 0x31000311, 0x00000011, | ||
340 | 0x0ab9, 0x00073ffe, 0x000022a2, | ||
341 | 0x0903, 0x000007ff, 0x00000000, | ||
342 | 0x2285, 0xf000001f, 0x00000007, | ||
343 | 0x22c9, 0xffffffff, 0x00ffffff, | ||
344 | 0x22c4, 0x0000ff0f, 0x00000000, | ||
345 | 0xa293, 0x07ffffff, 0x4e000000, | ||
346 | 0xa0d4, 0x3f3f3fff, 0x00000082, | ||
347 | 0x000c, 0x000000ff, 0x0040, | ||
348 | 0x000d, 0x00000040, 0x00004040, | ||
349 | 0x2440, 0x07ffffff, 0x03000000, | ||
350 | 0x2418, 0x0000007f, 0x00000020, | ||
351 | 0x2542, 0x00010000, 0x00010000, | ||
352 | 0x2b05, 0x000003ff, 0x000000f3, | ||
353 | 0x2b04, 0xffffffff, 0x00000000, | ||
354 | 0x2b03, 0xffffffff, 0x00003210, | ||
355 | 0x2235, 0x0000001f, 0x00000010, | ||
356 | 0x0570, 0x000c0fc0, 0x000c0400 | ||
357 | }; | ||
358 | |||
359 | static const u32 oland_golden_rlc_registers[] = | ||
360 | { | ||
361 | 0x3109, 0xffffffff, 0x00601005, | ||
362 | 0x311f, 0xffffffff, 0x10104040, | ||
363 | 0x3122, 0xffffffff, 0x0100000a, | ||
364 | 0x30c5, 0xffffffff, 0x00000800, | ||
365 | 0x30c3, 0xffffffff, 0x800000f4 | ||
366 | }; | ||
367 | |||
368 | static const u32 hainan_golden_registers[] = | ||
369 | { | ||
370 | 0x2684, 0x00010000, 0x00018208, | ||
371 | 0x260c, 0xffffffff, 0x00000000, | ||
372 | 0x260d, 0xf00fffff, 0x00000400, | ||
373 | 0x260e, 0x0002021c, 0x00020200, | ||
374 | 0x4595, 0xff000fff, 0x00000100, | ||
375 | 0x340c, 0x000300c0, 0x00800040, | ||
376 | 0x3630, 0xff000fff, 0x00000100, | ||
377 | 0x360c, 0x000300c0, 0x00800040, | ||
378 | 0x0ab9, 0x00073ffe, 0x000022a2, | ||
379 | 0x0903, 0x000007ff, 0x00000000, | ||
380 | 0x2285, 0xf000001f, 0x00000007, | ||
381 | 0x22c9, 0xffffffff, 0x00ffffff, | ||
382 | 0x22c4, 0x0000ff0f, 0x00000000, | ||
383 | 0xa393, 0x07ffffff, 0x4e000000, | ||
384 | 0xa0d4, 0x3f3f3fff, 0x00000000, | ||
385 | 0x000c, 0x000000ff, 0x0040, | ||
386 | 0x000d, 0x00000040, 0x00004040, | ||
387 | 0x2440, 0x03e00000, 0x03600000, | ||
388 | 0x2418, 0x0000007f, 0x00000020, | ||
389 | 0x2542, 0x00010000, 0x00010000, | ||
390 | 0x2b05, 0x000003ff, 0x000000f1, | ||
391 | 0x2b04, 0xffffffff, 0x00000000, | ||
392 | 0x2b03, 0xffffffff, 0x00003210, | ||
393 | 0x2235, 0x0000001f, 0x00000010, | ||
394 | 0x0570, 0x000c0fc0, 0x000c0400 | ||
395 | }; | ||
396 | |||
397 | static const u32 hainan_golden_registers2[] = | ||
398 | { | ||
399 | 0x263e, 0xffffffff, 0x02010001 | ||
400 | }; | ||
401 | |||
402 | static const u32 tahiti_mgcg_cgcg_init[] = | ||
403 | { | ||
404 | 0x3100, 0xffffffff, 0xfffffffc, | ||
405 | 0x200b, 0xffffffff, 0xe0000000, | ||
406 | 0x2698, 0xffffffff, 0x00000100, | ||
407 | 0x24a9, 0xffffffff, 0x00000100, | ||
408 | 0x3059, 0xffffffff, 0x00000100, | ||
409 | 0x25dd, 0xffffffff, 0x00000100, | ||
410 | 0x2261, 0xffffffff, 0x06000100, | ||
411 | 0x2286, 0xffffffff, 0x00000100, | ||
412 | 0x24a8, 0xffffffff, 0x00000100, | ||
413 | 0x30e0, 0xffffffff, 0x00000100, | ||
414 | 0x22ca, 0xffffffff, 0x00000100, | ||
415 | 0x2451, 0xffffffff, 0x00000100, | ||
416 | 0x2362, 0xffffffff, 0x00000100, | ||
417 | 0x2363, 0xffffffff, 0x00000100, | ||
418 | 0x240c, 0xffffffff, 0x00000100, | ||
419 | 0x240d, 0xffffffff, 0x00000100, | ||
420 | 0x240e, 0xffffffff, 0x00000100, | ||
421 | 0x240f, 0xffffffff, 0x00000100, | ||
422 | 0x2b60, 0xffffffff, 0x00000100, | ||
423 | 0x2b15, 0xffffffff, 0x00000100, | ||
424 | 0x225f, 0xffffffff, 0x06000100, | ||
425 | 0x261a, 0xffffffff, 0x00000100, | ||
426 | 0x2544, 0xffffffff, 0x00000100, | ||
427 | 0x2bc1, 0xffffffff, 0x00000100, | ||
428 | 0x2b81, 0xffffffff, 0x00000100, | ||
429 | 0x2527, 0xffffffff, 0x00000100, | ||
430 | 0x200b, 0xffffffff, 0xe0000000, | ||
431 | 0x2458, 0xffffffff, 0x00010000, | ||
432 | 0x2459, 0xffffffff, 0x00030002, | ||
433 | 0x245a, 0xffffffff, 0x00040007, | ||
434 | 0x245b, 0xffffffff, 0x00060005, | ||
435 | 0x245c, 0xffffffff, 0x00090008, | ||
436 | 0x245d, 0xffffffff, 0x00020001, | ||
437 | 0x245e, 0xffffffff, 0x00040003, | ||
438 | 0x245f, 0xffffffff, 0x00000007, | ||
439 | 0x2460, 0xffffffff, 0x00060005, | ||
440 | 0x2461, 0xffffffff, 0x00090008, | ||
441 | 0x2462, 0xffffffff, 0x00030002, | ||
442 | 0x2463, 0xffffffff, 0x00050004, | ||
443 | 0x2464, 0xffffffff, 0x00000008, | ||
444 | 0x2465, 0xffffffff, 0x00070006, | ||
445 | 0x2466, 0xffffffff, 0x000a0009, | ||
446 | 0x2467, 0xffffffff, 0x00040003, | ||
447 | 0x2468, 0xffffffff, 0x00060005, | ||
448 | 0x2469, 0xffffffff, 0x00000009, | ||
449 | 0x246a, 0xffffffff, 0x00080007, | ||
450 | 0x246b, 0xffffffff, 0x000b000a, | ||
451 | 0x246c, 0xffffffff, 0x00050004, | ||
452 | 0x246d, 0xffffffff, 0x00070006, | ||
453 | 0x246e, 0xffffffff, 0x0008000b, | ||
454 | 0x246f, 0xffffffff, 0x000a0009, | ||
455 | 0x2470, 0xffffffff, 0x000d000c, | ||
456 | 0x2471, 0xffffffff, 0x00060005, | ||
457 | 0x2472, 0xffffffff, 0x00080007, | ||
458 | 0x2473, 0xffffffff, 0x0000000b, | ||
459 | 0x2474, 0xffffffff, 0x000a0009, | ||
460 | 0x2475, 0xffffffff, 0x000d000c, | ||
461 | 0x2476, 0xffffffff, 0x00070006, | ||
462 | 0x2477, 0xffffffff, 0x00090008, | ||
463 | 0x2478, 0xffffffff, 0x0000000c, | ||
464 | 0x2479, 0xffffffff, 0x000b000a, | ||
465 | 0x247a, 0xffffffff, 0x000e000d, | ||
466 | 0x247b, 0xffffffff, 0x00080007, | ||
467 | 0x247c, 0xffffffff, 0x000a0009, | ||
468 | 0x247d, 0xffffffff, 0x0000000d, | ||
469 | 0x247e, 0xffffffff, 0x000c000b, | ||
470 | 0x247f, 0xffffffff, 0x000f000e, | ||
471 | 0x2480, 0xffffffff, 0x00090008, | ||
472 | 0x2481, 0xffffffff, 0x000b000a, | ||
473 | 0x2482, 0xffffffff, 0x000c000f, | ||
474 | 0x2483, 0xffffffff, 0x000e000d, | ||
475 | 0x2484, 0xffffffff, 0x00110010, | ||
476 | 0x2485, 0xffffffff, 0x000a0009, | ||
477 | 0x2486, 0xffffffff, 0x000c000b, | ||
478 | 0x2487, 0xffffffff, 0x0000000f, | ||
479 | 0x2488, 0xffffffff, 0x000e000d, | ||
480 | 0x2489, 0xffffffff, 0x00110010, | ||
481 | 0x248a, 0xffffffff, 0x000b000a, | ||
482 | 0x248b, 0xffffffff, 0x000d000c, | ||
483 | 0x248c, 0xffffffff, 0x00000010, | ||
484 | 0x248d, 0xffffffff, 0x000f000e, | ||
485 | 0x248e, 0xffffffff, 0x00120011, | ||
486 | 0x248f, 0xffffffff, 0x000c000b, | ||
487 | 0x2490, 0xffffffff, 0x000e000d, | ||
488 | 0x2491, 0xffffffff, 0x00000011, | ||
489 | 0x2492, 0xffffffff, 0x0010000f, | ||
490 | 0x2493, 0xffffffff, 0x00130012, | ||
491 | 0x2494, 0xffffffff, 0x000d000c, | ||
492 | 0x2495, 0xffffffff, 0x000f000e, | ||
493 | 0x2496, 0xffffffff, 0x00100013, | ||
494 | 0x2497, 0xffffffff, 0x00120011, | ||
495 | 0x2498, 0xffffffff, 0x00150014, | ||
496 | 0x2499, 0xffffffff, 0x000e000d, | ||
497 | 0x249a, 0xffffffff, 0x0010000f, | ||
498 | 0x249b, 0xffffffff, 0x00000013, | ||
499 | 0x249c, 0xffffffff, 0x00120011, | ||
500 | 0x249d, 0xffffffff, 0x00150014, | ||
501 | 0x249e, 0xffffffff, 0x000f000e, | ||
502 | 0x249f, 0xffffffff, 0x00110010, | ||
503 | 0x24a0, 0xffffffff, 0x00000014, | ||
504 | 0x24a1, 0xffffffff, 0x00130012, | ||
505 | 0x24a2, 0xffffffff, 0x00160015, | ||
506 | 0x24a3, 0xffffffff, 0x0010000f, | ||
507 | 0x24a4, 0xffffffff, 0x00120011, | ||
508 | 0x24a5, 0xffffffff, 0x00000015, | ||
509 | 0x24a6, 0xffffffff, 0x00140013, | ||
510 | 0x24a7, 0xffffffff, 0x00170016, | ||
511 | 0x2454, 0xffffffff, 0x96940200, | ||
512 | 0x21c2, 0xffffffff, 0x00900100, | ||
513 | 0x311e, 0xffffffff, 0x00000080, | ||
514 | 0x3101, 0xffffffff, 0x0020003f, | ||
515 | 0xc, 0xffffffff, 0x0000001c, | ||
516 | 0xd, 0x000f0000, 0x000f0000, | ||
517 | 0x583, 0xffffffff, 0x00000100, | ||
518 | 0x409, 0xffffffff, 0x00000100, | ||
519 | 0x40b, 0x00000101, 0x00000000, | ||
520 | 0x82a, 0xffffffff, 0x00000104, | ||
521 | 0x993, 0x000c0000, 0x000c0000, | ||
522 | 0x992, 0x000c0000, 0x000c0000, | ||
523 | 0x1579, 0xff000fff, 0x00000100, | ||
524 | 0x157a, 0x00000001, 0x00000001, | ||
525 | 0xbd4, 0x00000001, 0x00000001, | ||
526 | 0xc33, 0xc0000fff, 0x00000104, | ||
527 | 0x3079, 0x00000001, 0x00000001, | ||
528 | 0x3430, 0xfffffff0, 0x00000100, | ||
529 | 0x3630, 0xfffffff0, 0x00000100 | ||
530 | }; | ||
531 | static const u32 pitcairn_mgcg_cgcg_init[] = | ||
532 | { | ||
533 | 0x3100, 0xffffffff, 0xfffffffc, | ||
534 | 0x200b, 0xffffffff, 0xe0000000, | ||
535 | 0x2698, 0xffffffff, 0x00000100, | ||
536 | 0x24a9, 0xffffffff, 0x00000100, | ||
537 | 0x3059, 0xffffffff, 0x00000100, | ||
538 | 0x25dd, 0xffffffff, 0x00000100, | ||
539 | 0x2261, 0xffffffff, 0x06000100, | ||
540 | 0x2286, 0xffffffff, 0x00000100, | ||
541 | 0x24a8, 0xffffffff, 0x00000100, | ||
542 | 0x30e0, 0xffffffff, 0x00000100, | ||
543 | 0x22ca, 0xffffffff, 0x00000100, | ||
544 | 0x2451, 0xffffffff, 0x00000100, | ||
545 | 0x2362, 0xffffffff, 0x00000100, | ||
546 | 0x2363, 0xffffffff, 0x00000100, | ||
547 | 0x240c, 0xffffffff, 0x00000100, | ||
548 | 0x240d, 0xffffffff, 0x00000100, | ||
549 | 0x240e, 0xffffffff, 0x00000100, | ||
550 | 0x240f, 0xffffffff, 0x00000100, | ||
551 | 0x2b60, 0xffffffff, 0x00000100, | ||
552 | 0x2b15, 0xffffffff, 0x00000100, | ||
553 | 0x225f, 0xffffffff, 0x06000100, | ||
554 | 0x261a, 0xffffffff, 0x00000100, | ||
555 | 0x2544, 0xffffffff, 0x00000100, | ||
556 | 0x2bc1, 0xffffffff, 0x00000100, | ||
557 | 0x2b81, 0xffffffff, 0x00000100, | ||
558 | 0x2527, 0xffffffff, 0x00000100, | ||
559 | 0x200b, 0xffffffff, 0xe0000000, | ||
560 | 0x2458, 0xffffffff, 0x00010000, | ||
561 | 0x2459, 0xffffffff, 0x00030002, | ||
562 | 0x245a, 0xffffffff, 0x00040007, | ||
563 | 0x245b, 0xffffffff, 0x00060005, | ||
564 | 0x245c, 0xffffffff, 0x00090008, | ||
565 | 0x245d, 0xffffffff, 0x00020001, | ||
566 | 0x245e, 0xffffffff, 0x00040003, | ||
567 | 0x245f, 0xffffffff, 0x00000007, | ||
568 | 0x2460, 0xffffffff, 0x00060005, | ||
569 | 0x2461, 0xffffffff, 0x00090008, | ||
570 | 0x2462, 0xffffffff, 0x00030002, | ||
571 | 0x2463, 0xffffffff, 0x00050004, | ||
572 | 0x2464, 0xffffffff, 0x00000008, | ||
573 | 0x2465, 0xffffffff, 0x00070006, | ||
574 | 0x2466, 0xffffffff, 0x000a0009, | ||
575 | 0x2467, 0xffffffff, 0x00040003, | ||
576 | 0x2468, 0xffffffff, 0x00060005, | ||
577 | 0x2469, 0xffffffff, 0x00000009, | ||
578 | 0x246a, 0xffffffff, 0x00080007, | ||
579 | 0x246b, 0xffffffff, 0x000b000a, | ||
580 | 0x246c, 0xffffffff, 0x00050004, | ||
581 | 0x246d, 0xffffffff, 0x00070006, | ||
582 | 0x246e, 0xffffffff, 0x0008000b, | ||
583 | 0x246f, 0xffffffff, 0x000a0009, | ||
584 | 0x2470, 0xffffffff, 0x000d000c, | ||
585 | 0x2480, 0xffffffff, 0x00090008, | ||
586 | 0x2481, 0xffffffff, 0x000b000a, | ||
587 | 0x2482, 0xffffffff, 0x000c000f, | ||
588 | 0x2483, 0xffffffff, 0x000e000d, | ||
589 | 0x2484, 0xffffffff, 0x00110010, | ||
590 | 0x2485, 0xffffffff, 0x000a0009, | ||
591 | 0x2486, 0xffffffff, 0x000c000b, | ||
592 | 0x2487, 0xffffffff, 0x0000000f, | ||
593 | 0x2488, 0xffffffff, 0x000e000d, | ||
594 | 0x2489, 0xffffffff, 0x00110010, | ||
595 | 0x248a, 0xffffffff, 0x000b000a, | ||
596 | 0x248b, 0xffffffff, 0x000d000c, | ||
597 | 0x248c, 0xffffffff, 0x00000010, | ||
598 | 0x248d, 0xffffffff, 0x000f000e, | ||
599 | 0x248e, 0xffffffff, 0x00120011, | ||
600 | 0x248f, 0xffffffff, 0x000c000b, | ||
601 | 0x2490, 0xffffffff, 0x000e000d, | ||
602 | 0x2491, 0xffffffff, 0x00000011, | ||
603 | 0x2492, 0xffffffff, 0x0010000f, | ||
604 | 0x2493, 0xffffffff, 0x00130012, | ||
605 | 0x2494, 0xffffffff, 0x000d000c, | ||
606 | 0x2495, 0xffffffff, 0x000f000e, | ||
607 | 0x2496, 0xffffffff, 0x00100013, | ||
608 | 0x2497, 0xffffffff, 0x00120011, | ||
609 | 0x2498, 0xffffffff, 0x00150014, | ||
610 | 0x2454, 0xffffffff, 0x96940200, | ||
611 | 0x21c2, 0xffffffff, 0x00900100, | ||
612 | 0x311e, 0xffffffff, 0x00000080, | ||
613 | 0x3101, 0xffffffff, 0x0020003f, | ||
614 | 0xc, 0xffffffff, 0x0000001c, | ||
615 | 0xd, 0x000f0000, 0x000f0000, | ||
616 | 0x583, 0xffffffff, 0x00000100, | ||
617 | 0x409, 0xffffffff, 0x00000100, | ||
618 | 0x40b, 0x00000101, 0x00000000, | ||
619 | 0x82a, 0xffffffff, 0x00000104, | ||
620 | 0x1579, 0xff000fff, 0x00000100, | ||
621 | 0x157a, 0x00000001, 0x00000001, | ||
622 | 0xbd4, 0x00000001, 0x00000001, | ||
623 | 0xc33, 0xc0000fff, 0x00000104, | ||
624 | 0x3079, 0x00000001, 0x00000001, | ||
625 | 0x3430, 0xfffffff0, 0x00000100, | ||
626 | 0x3630, 0xfffffff0, 0x00000100 | ||
627 | }; | ||
628 | static const u32 verde_mgcg_cgcg_init[] = | ||
629 | { | ||
630 | 0x3100, 0xffffffff, 0xfffffffc, | ||
631 | 0x200b, 0xffffffff, 0xe0000000, | ||
632 | 0x2698, 0xffffffff, 0x00000100, | ||
633 | 0x24a9, 0xffffffff, 0x00000100, | ||
634 | 0x3059, 0xffffffff, 0x00000100, | ||
635 | 0x25dd, 0xffffffff, 0x00000100, | ||
636 | 0x2261, 0xffffffff, 0x06000100, | ||
637 | 0x2286, 0xffffffff, 0x00000100, | ||
638 | 0x24a8, 0xffffffff, 0x00000100, | ||
639 | 0x30e0, 0xffffffff, 0x00000100, | ||
640 | 0x22ca, 0xffffffff, 0x00000100, | ||
641 | 0x2451, 0xffffffff, 0x00000100, | ||
642 | 0x2362, 0xffffffff, 0x00000100, | ||
643 | 0x2363, 0xffffffff, 0x00000100, | ||
644 | 0x240c, 0xffffffff, 0x00000100, | ||
645 | 0x240d, 0xffffffff, 0x00000100, | ||
646 | 0x240e, 0xffffffff, 0x00000100, | ||
647 | 0x240f, 0xffffffff, 0x00000100, | ||
648 | 0x2b60, 0xffffffff, 0x00000100, | ||
649 | 0x2b15, 0xffffffff, 0x00000100, | ||
650 | 0x225f, 0xffffffff, 0x06000100, | ||
651 | 0x261a, 0xffffffff, 0x00000100, | ||
652 | 0x2544, 0xffffffff, 0x00000100, | ||
653 | 0x2bc1, 0xffffffff, 0x00000100, | ||
654 | 0x2b81, 0xffffffff, 0x00000100, | ||
655 | 0x2527, 0xffffffff, 0x00000100, | ||
656 | 0x200b, 0xffffffff, 0xe0000000, | ||
657 | 0x2458, 0xffffffff, 0x00010000, | ||
658 | 0x2459, 0xffffffff, 0x00030002, | ||
659 | 0x245a, 0xffffffff, 0x00040007, | ||
660 | 0x245b, 0xffffffff, 0x00060005, | ||
661 | 0x245c, 0xffffffff, 0x00090008, | ||
662 | 0x245d, 0xffffffff, 0x00020001, | ||
663 | 0x245e, 0xffffffff, 0x00040003, | ||
664 | 0x245f, 0xffffffff, 0x00000007, | ||
665 | 0x2460, 0xffffffff, 0x00060005, | ||
666 | 0x2461, 0xffffffff, 0x00090008, | ||
667 | 0x2462, 0xffffffff, 0x00030002, | ||
668 | 0x2463, 0xffffffff, 0x00050004, | ||
669 | 0x2464, 0xffffffff, 0x00000008, | ||
670 | 0x2465, 0xffffffff, 0x00070006, | ||
671 | 0x2466, 0xffffffff, 0x000a0009, | ||
672 | 0x2467, 0xffffffff, 0x00040003, | ||
673 | 0x2468, 0xffffffff, 0x00060005, | ||
674 | 0x2469, 0xffffffff, 0x00000009, | ||
675 | 0x246a, 0xffffffff, 0x00080007, | ||
676 | 0x246b, 0xffffffff, 0x000b000a, | ||
677 | 0x246c, 0xffffffff, 0x00050004, | ||
678 | 0x246d, 0xffffffff, 0x00070006, | ||
679 | 0x246e, 0xffffffff, 0x0008000b, | ||
680 | 0x246f, 0xffffffff, 0x000a0009, | ||
681 | 0x2470, 0xffffffff, 0x000d000c, | ||
682 | 0x2480, 0xffffffff, 0x00090008, | ||
683 | 0x2481, 0xffffffff, 0x000b000a, | ||
684 | 0x2482, 0xffffffff, 0x000c000f, | ||
685 | 0x2483, 0xffffffff, 0x000e000d, | ||
686 | 0x2484, 0xffffffff, 0x00110010, | ||
687 | 0x2485, 0xffffffff, 0x000a0009, | ||
688 | 0x2486, 0xffffffff, 0x000c000b, | ||
689 | 0x2487, 0xffffffff, 0x0000000f, | ||
690 | 0x2488, 0xffffffff, 0x000e000d, | ||
691 | 0x2489, 0xffffffff, 0x00110010, | ||
692 | 0x248a, 0xffffffff, 0x000b000a, | ||
693 | 0x248b, 0xffffffff, 0x000d000c, | ||
694 | 0x248c, 0xffffffff, 0x00000010, | ||
695 | 0x248d, 0xffffffff, 0x000f000e, | ||
696 | 0x248e, 0xffffffff, 0x00120011, | ||
697 | 0x248f, 0xffffffff, 0x000c000b, | ||
698 | 0x2490, 0xffffffff, 0x000e000d, | ||
699 | 0x2491, 0xffffffff, 0x00000011, | ||
700 | 0x2492, 0xffffffff, 0x0010000f, | ||
701 | 0x2493, 0xffffffff, 0x00130012, | ||
702 | 0x2494, 0xffffffff, 0x000d000c, | ||
703 | 0x2495, 0xffffffff, 0x000f000e, | ||
704 | 0x2496, 0xffffffff, 0x00100013, | ||
705 | 0x2497, 0xffffffff, 0x00120011, | ||
706 | 0x2498, 0xffffffff, 0x00150014, | ||
707 | 0x2454, 0xffffffff, 0x96940200, | ||
708 | 0x21c2, 0xffffffff, 0x00900100, | ||
709 | 0x311e, 0xffffffff, 0x00000080, | ||
710 | 0x3101, 0xffffffff, 0x0020003f, | ||
711 | 0xc, 0xffffffff, 0x0000001c, | ||
712 | 0xd, 0x000f0000, 0x000f0000, | ||
713 | 0x583, 0xffffffff, 0x00000100, | ||
714 | 0x409, 0xffffffff, 0x00000100, | ||
715 | 0x40b, 0x00000101, 0x00000000, | ||
716 | 0x82a, 0xffffffff, 0x00000104, | ||
717 | 0x993, 0x000c0000, 0x000c0000, | ||
718 | 0x992, 0x000c0000, 0x000c0000, | ||
719 | 0x1579, 0xff000fff, 0x00000100, | ||
720 | 0x157a, 0x00000001, 0x00000001, | ||
721 | 0xbd4, 0x00000001, 0x00000001, | ||
722 | 0xc33, 0xc0000fff, 0x00000104, | ||
723 | 0x3079, 0x00000001, 0x00000001, | ||
724 | 0x3430, 0xfffffff0, 0x00000100, | ||
725 | 0x3630, 0xfffffff0, 0x00000100 | ||
726 | }; | ||
727 | static const u32 oland_mgcg_cgcg_init[] = | ||
728 | { | ||
729 | 0x3100, 0xffffffff, 0xfffffffc, | ||
730 | 0x200b, 0xffffffff, 0xe0000000, | ||
731 | 0x2698, 0xffffffff, 0x00000100, | ||
732 | 0x24a9, 0xffffffff, 0x00000100, | ||
733 | 0x3059, 0xffffffff, 0x00000100, | ||
734 | 0x25dd, 0xffffffff, 0x00000100, | ||
735 | 0x2261, 0xffffffff, 0x06000100, | ||
736 | 0x2286, 0xffffffff, 0x00000100, | ||
737 | 0x24a8, 0xffffffff, 0x00000100, | ||
738 | 0x30e0, 0xffffffff, 0x00000100, | ||
739 | 0x22ca, 0xffffffff, 0x00000100, | ||
740 | 0x2451, 0xffffffff, 0x00000100, | ||
741 | 0x2362, 0xffffffff, 0x00000100, | ||
742 | 0x2363, 0xffffffff, 0x00000100, | ||
743 | 0x240c, 0xffffffff, 0x00000100, | ||
744 | 0x240d, 0xffffffff, 0x00000100, | ||
745 | 0x240e, 0xffffffff, 0x00000100, | ||
746 | 0x240f, 0xffffffff, 0x00000100, | ||
747 | 0x2b60, 0xffffffff, 0x00000100, | ||
748 | 0x2b15, 0xffffffff, 0x00000100, | ||
749 | 0x225f, 0xffffffff, 0x06000100, | ||
750 | 0x261a, 0xffffffff, 0x00000100, | ||
751 | 0x2544, 0xffffffff, 0x00000100, | ||
752 | 0x2bc1, 0xffffffff, 0x00000100, | ||
753 | 0x2b81, 0xffffffff, 0x00000100, | ||
754 | 0x2527, 0xffffffff, 0x00000100, | ||
755 | 0x200b, 0xffffffff, 0xe0000000, | ||
756 | 0x2458, 0xffffffff, 0x00010000, | ||
757 | 0x2459, 0xffffffff, 0x00030002, | ||
758 | 0x245a, 0xffffffff, 0x00040007, | ||
759 | 0x245b, 0xffffffff, 0x00060005, | ||
760 | 0x245c, 0xffffffff, 0x00090008, | ||
761 | 0x245d, 0xffffffff, 0x00020001, | ||
762 | 0x245e, 0xffffffff, 0x00040003, | ||
763 | 0x245f, 0xffffffff, 0x00000007, | ||
764 | 0x2460, 0xffffffff, 0x00060005, | ||
765 | 0x2461, 0xffffffff, 0x00090008, | ||
766 | 0x2462, 0xffffffff, 0x00030002, | ||
767 | 0x2463, 0xffffffff, 0x00050004, | ||
768 | 0x2464, 0xffffffff, 0x00000008, | ||
769 | 0x2465, 0xffffffff, 0x00070006, | ||
770 | 0x2466, 0xffffffff, 0x000a0009, | ||
771 | 0x2467, 0xffffffff, 0x00040003, | ||
772 | 0x2468, 0xffffffff, 0x00060005, | ||
773 | 0x2469, 0xffffffff, 0x00000009, | ||
774 | 0x246a, 0xffffffff, 0x00080007, | ||
775 | 0x246b, 0xffffffff, 0x000b000a, | ||
776 | 0x246c, 0xffffffff, 0x00050004, | ||
777 | 0x246d, 0xffffffff, 0x00070006, | ||
778 | 0x246e, 0xffffffff, 0x0008000b, | ||
779 | 0x246f, 0xffffffff, 0x000a0009, | ||
780 | 0x2470, 0xffffffff, 0x000d000c, | ||
781 | 0x2471, 0xffffffff, 0x00060005, | ||
782 | 0x2472, 0xffffffff, 0x00080007, | ||
783 | 0x2473, 0xffffffff, 0x0000000b, | ||
784 | 0x2474, 0xffffffff, 0x000a0009, | ||
785 | 0x2475, 0xffffffff, 0x000d000c, | ||
786 | 0x2454, 0xffffffff, 0x96940200, | ||
787 | 0x21c2, 0xffffffff, 0x00900100, | ||
788 | 0x311e, 0xffffffff, 0x00000080, | ||
789 | 0x3101, 0xffffffff, 0x0020003f, | ||
790 | 0xc, 0xffffffff, 0x0000001c, | ||
791 | 0xd, 0x000f0000, 0x000f0000, | ||
792 | 0x583, 0xffffffff, 0x00000100, | ||
793 | 0x409, 0xffffffff, 0x00000100, | ||
794 | 0x40b, 0x00000101, 0x00000000, | ||
795 | 0x82a, 0xffffffff, 0x00000104, | ||
796 | 0x993, 0x000c0000, 0x000c0000, | ||
797 | 0x992, 0x000c0000, 0x000c0000, | ||
798 | 0x1579, 0xff000fff, 0x00000100, | ||
799 | 0x157a, 0x00000001, 0x00000001, | ||
800 | 0xbd4, 0x00000001, 0x00000001, | ||
801 | 0xc33, 0xc0000fff, 0x00000104, | ||
802 | 0x3079, 0x00000001, 0x00000001, | ||
803 | 0x3430, 0xfffffff0, 0x00000100, | ||
804 | 0x3630, 0xfffffff0, 0x00000100 | ||
805 | }; | ||
806 | static const u32 hainan_mgcg_cgcg_init[] = | ||
807 | { | ||
808 | 0x3100, 0xffffffff, 0xfffffffc, | ||
809 | 0x200b, 0xffffffff, 0xe0000000, | ||
810 | 0x2698, 0xffffffff, 0x00000100, | ||
811 | 0x24a9, 0xffffffff, 0x00000100, | ||
812 | 0x3059, 0xffffffff, 0x00000100, | ||
813 | 0x25dd, 0xffffffff, 0x00000100, | ||
814 | 0x2261, 0xffffffff, 0x06000100, | ||
815 | 0x2286, 0xffffffff, 0x00000100, | ||
816 | 0x24a8, 0xffffffff, 0x00000100, | ||
817 | 0x30e0, 0xffffffff, 0x00000100, | ||
818 | 0x22ca, 0xffffffff, 0x00000100, | ||
819 | 0x2451, 0xffffffff, 0x00000100, | ||
820 | 0x2362, 0xffffffff, 0x00000100, | ||
821 | 0x2363, 0xffffffff, 0x00000100, | ||
822 | 0x240c, 0xffffffff, 0x00000100, | ||
823 | 0x240d, 0xffffffff, 0x00000100, | ||
824 | 0x240e, 0xffffffff, 0x00000100, | ||
825 | 0x240f, 0xffffffff, 0x00000100, | ||
826 | 0x2b60, 0xffffffff, 0x00000100, | ||
827 | 0x2b15, 0xffffffff, 0x00000100, | ||
828 | 0x225f, 0xffffffff, 0x06000100, | ||
829 | 0x261a, 0xffffffff, 0x00000100, | ||
830 | 0x2544, 0xffffffff, 0x00000100, | ||
831 | 0x2bc1, 0xffffffff, 0x00000100, | ||
832 | 0x2b81, 0xffffffff, 0x00000100, | ||
833 | 0x2527, 0xffffffff, 0x00000100, | ||
834 | 0x200b, 0xffffffff, 0xe0000000, | ||
835 | 0x2458, 0xffffffff, 0x00010000, | ||
836 | 0x2459, 0xffffffff, 0x00030002, | ||
837 | 0x245a, 0xffffffff, 0x00040007, | ||
838 | 0x245b, 0xffffffff, 0x00060005, | ||
839 | 0x245c, 0xffffffff, 0x00090008, | ||
840 | 0x245d, 0xffffffff, 0x00020001, | ||
841 | 0x245e, 0xffffffff, 0x00040003, | ||
842 | 0x245f, 0xffffffff, 0x00000007, | ||
843 | 0x2460, 0xffffffff, 0x00060005, | ||
844 | 0x2461, 0xffffffff, 0x00090008, | ||
845 | 0x2462, 0xffffffff, 0x00030002, | ||
846 | 0x2463, 0xffffffff, 0x00050004, | ||
847 | 0x2464, 0xffffffff, 0x00000008, | ||
848 | 0x2465, 0xffffffff, 0x00070006, | ||
849 | 0x2466, 0xffffffff, 0x000a0009, | ||
850 | 0x2467, 0xffffffff, 0x00040003, | ||
851 | 0x2468, 0xffffffff, 0x00060005, | ||
852 | 0x2469, 0xffffffff, 0x00000009, | ||
853 | 0x246a, 0xffffffff, 0x00080007, | ||
854 | 0x246b, 0xffffffff, 0x000b000a, | ||
855 | 0x246c, 0xffffffff, 0x00050004, | ||
856 | 0x246d, 0xffffffff, 0x00070006, | ||
857 | 0x246e, 0xffffffff, 0x0008000b, | ||
858 | 0x246f, 0xffffffff, 0x000a0009, | ||
859 | 0x2470, 0xffffffff, 0x000d000c, | ||
860 | 0x2471, 0xffffffff, 0x00060005, | ||
861 | 0x2472, 0xffffffff, 0x00080007, | ||
862 | 0x2473, 0xffffffff, 0x0000000b, | ||
863 | 0x2474, 0xffffffff, 0x000a0009, | ||
864 | 0x2475, 0xffffffff, 0x000d000c, | ||
865 | 0x2454, 0xffffffff, 0x96940200, | ||
866 | 0x21c2, 0xffffffff, 0x00900100, | ||
867 | 0x311e, 0xffffffff, 0x00000080, | ||
868 | 0x3101, 0xffffffff, 0x0020003f, | ||
869 | 0xc, 0xffffffff, 0x0000001c, | ||
870 | 0xd, 0x000f0000, 0x000f0000, | ||
871 | 0x583, 0xffffffff, 0x00000100, | ||
872 | 0x409, 0xffffffff, 0x00000100, | ||
873 | 0x82a, 0xffffffff, 0x00000104, | ||
874 | 0x993, 0x000c0000, 0x000c0000, | ||
875 | 0x992, 0x000c0000, 0x000c0000, | ||
876 | 0xbd4, 0x00000001, 0x00000001, | ||
877 | 0xc33, 0xc0000fff, 0x00000104, | ||
878 | 0x3079, 0x00000001, 0x00000001, | ||
879 | 0x3430, 0xfffffff0, 0x00000100, | ||
880 | 0x3630, 0xfffffff0, 0x00000100 | ||
881 | }; | ||
882 | |||
883 | static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg) | ||
884 | { | ||
885 | unsigned long flags; | ||
886 | u32 r; | ||
887 | |||
888 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
889 | WREG32(AMDGPU_PCIE_INDEX, reg); | ||
890 | (void)RREG32(AMDGPU_PCIE_INDEX); | ||
891 | r = RREG32(AMDGPU_PCIE_DATA); | ||
892 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
893 | return r; | ||
894 | } | ||
895 | |||
896 | static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
897 | { | ||
898 | unsigned long flags; | ||
899 | |||
900 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
901 | WREG32(AMDGPU_PCIE_INDEX, reg); | ||
902 | (void)RREG32(AMDGPU_PCIE_INDEX); | ||
903 | WREG32(AMDGPU_PCIE_DATA, v); | ||
904 | (void)RREG32(AMDGPU_PCIE_DATA); | ||
905 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
906 | } | ||
907 | |||
908 | u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) | ||
909 | { | ||
910 | unsigned long flags; | ||
911 | u32 r; | ||
912 | |||
913 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
914 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | ||
915 | (void)RREG32(PCIE_PORT_INDEX); | ||
916 | r = RREG32(PCIE_PORT_DATA); | ||
917 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
918 | return r; | ||
919 | } | ||
920 | |||
921 | void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
922 | { | ||
923 | unsigned long flags; | ||
924 | |||
925 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
926 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | ||
927 | (void)RREG32(PCIE_PORT_INDEX); | ||
928 | WREG32(PCIE_PORT_DATA, (v)); | ||
929 | (void)RREG32(PCIE_PORT_DATA); | ||
930 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
931 | } | ||
932 | |||
933 | static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) | ||
934 | { | ||
935 | unsigned long flags; | ||
936 | u32 r; | ||
937 | |||
938 | spin_lock_irqsave(&adev->smc_idx_lock, flags); | ||
939 | WREG32(SMC_IND_INDEX_0, (reg)); | ||
940 | r = RREG32(SMC_IND_DATA_0); | ||
941 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | ||
942 | return r; | ||
943 | } | ||
944 | |||
945 | static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
946 | { | ||
947 | unsigned long flags; | ||
948 | |||
949 | spin_lock_irqsave(&adev->smc_idx_lock, flags); | ||
950 | WREG32(SMC_IND_INDEX_0, (reg)); | ||
951 | WREG32(SMC_IND_DATA_0, (v)); | ||
952 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | ||
953 | } | ||
954 | |||
955 | static u32 si_get_virtual_caps(struct amdgpu_device *adev) | ||
956 | { | ||
957 | /* SI does not support SR-IOV */ | ||
958 | return 0; | ||
959 | } | ||
960 | |||
961 | static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { | ||
962 | {GRBM_STATUS, false}, | ||
963 | {GB_ADDR_CONFIG, false}, | ||
964 | {MC_ARB_RAMCFG, false}, | ||
965 | {GB_TILE_MODE0, false}, | ||
966 | {GB_TILE_MODE1, false}, | ||
967 | {GB_TILE_MODE2, false}, | ||
968 | {GB_TILE_MODE3, false}, | ||
969 | {GB_TILE_MODE4, false}, | ||
970 | {GB_TILE_MODE5, false}, | ||
971 | {GB_TILE_MODE6, false}, | ||
972 | {GB_TILE_MODE7, false}, | ||
973 | {GB_TILE_MODE8, false}, | ||
974 | {GB_TILE_MODE9, false}, | ||
975 | {GB_TILE_MODE10, false}, | ||
976 | {GB_TILE_MODE11, false}, | ||
977 | {GB_TILE_MODE12, false}, | ||
978 | {GB_TILE_MODE13, false}, | ||
979 | {GB_TILE_MODE14, false}, | ||
980 | {GB_TILE_MODE15, false}, | ||
981 | {GB_TILE_MODE16, false}, | ||
982 | {GB_TILE_MODE17, false}, | ||
983 | {GB_TILE_MODE18, false}, | ||
984 | {GB_TILE_MODE19, false}, | ||
985 | {GB_TILE_MODE20, false}, | ||
986 | {GB_TILE_MODE21, false}, | ||
987 | {GB_TILE_MODE22, false}, | ||
988 | {GB_TILE_MODE23, false}, | ||
989 | {GB_TILE_MODE24, false}, | ||
990 | {GB_TILE_MODE25, false}, | ||
991 | {GB_TILE_MODE26, false}, | ||
992 | {GB_TILE_MODE27, false}, | ||
993 | {GB_TILE_MODE28, false}, | ||
994 | {GB_TILE_MODE29, false}, | ||
995 | {GB_TILE_MODE30, false}, | ||
996 | {GB_TILE_MODE31, false}, | ||
997 | {CC_RB_BACKEND_DISABLE, false, true}, | ||
998 | {GC_USER_RB_BACKEND_DISABLE, false, true}, | ||
999 | {PA_SC_RASTER_CONFIG, false, true}, | ||
1000 | }; | ||
1001 | |||
1002 | static uint32_t si_read_indexed_register(struct amdgpu_device *adev, | ||
1003 | u32 se_num, u32 sh_num, | ||
1004 | u32 reg_offset) | ||
1005 | { | ||
1006 | uint32_t val; | ||
1007 | |||
1008 | mutex_lock(&adev->grbm_idx_mutex); | ||
1009 | if (se_num != 0xffffffff || sh_num != 0xffffffff) | ||
1010 | amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff); | ||
1011 | |||
1012 | val = RREG32(reg_offset); | ||
1013 | |||
1014 | if (se_num != 0xffffffff || sh_num != 0xffffffff) | ||
1015 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
1016 | mutex_unlock(&adev->grbm_idx_mutex); | ||
1017 | return val; | ||
1018 | } | ||
1019 | |||
1020 | static int si_read_register(struct amdgpu_device *adev, u32 se_num, | ||
1021 | u32 sh_num, u32 reg_offset, u32 *value) | ||
1022 | { | ||
1023 | uint32_t i; | ||
1024 | |||
1025 | *value = 0; | ||
1026 | for (i = 0; i < ARRAY_SIZE(si_allowed_read_registers); i++) { | ||
1027 | if (reg_offset != si_allowed_read_registers[i].reg_offset) | ||
1028 | continue; | ||
1029 | |||
1030 | if (!si_allowed_read_registers[i].untouched) | ||
1031 | *value = si_allowed_read_registers[i].grbm_indexed ? | ||
1032 | si_read_indexed_register(adev, se_num, | ||
1033 | sh_num, reg_offset) : | ||
1034 | RREG32(reg_offset); | ||
1035 | return 0; | ||
1036 | } | ||
1037 | return -EINVAL; | ||
1038 | } | ||
1039 | |||
1040 | static bool si_read_disabled_bios(struct amdgpu_device *adev) | ||
1041 | { | ||
1042 | u32 bus_cntl; | ||
1043 | u32 d1vga_control = 0; | ||
1044 | u32 d2vga_control = 0; | ||
1045 | u32 vga_render_control = 0; | ||
1046 | u32 rom_cntl; | ||
1047 | bool r; | ||
1048 | |||
1049 | bus_cntl = RREG32(R600_BUS_CNTL); | ||
1050 | if (adev->mode_info.num_crtc) { | ||
1051 | d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); | ||
1052 | d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); | ||
1053 | vga_render_control = RREG32(VGA_RENDER_CONTROL); | ||
1054 | } | ||
1055 | rom_cntl = RREG32(R600_ROM_CNTL); | ||
1056 | |||
1057 | /* enable the rom */ | ||
1058 | WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS)); | ||
1059 | if (adev->mode_info.num_crtc) { | ||
1060 | /* Disable VGA mode */ | ||
1061 | WREG32(AVIVO_D1VGA_CONTROL, | ||
1062 | (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | | ||
1063 | AVIVO_DVGA_CONTROL_TIMING_SELECT))); | ||
1064 | WREG32(AVIVO_D2VGA_CONTROL, | ||
1065 | (d2vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | | ||
1066 | AVIVO_DVGA_CONTROL_TIMING_SELECT))); | ||
1067 | WREG32(VGA_RENDER_CONTROL, | ||
1068 | (vga_render_control & C_000300_VGA_VSTATUS_CNTL)); | ||
1069 | } | ||
1070 | WREG32(R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE); | ||
1071 | |||
1072 | r = amdgpu_read_bios(adev); | ||
1073 | |||
1074 | /* restore regs */ | ||
1075 | WREG32(R600_BUS_CNTL, bus_cntl); | ||
1076 | if (adev->mode_info.num_crtc) { | ||
1077 | WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); | ||
1078 | WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); | ||
1079 | WREG32(VGA_RENDER_CONTROL, vga_render_control); | ||
1080 | } | ||
1081 | WREG32(R600_ROM_CNTL, rom_cntl); | ||
1082 | return r; | ||
1083 | } | ||
1084 | |||
1085 | //xxx: not implemented | ||
1086 | static int si_asic_reset(struct amdgpu_device *adev) | ||
1087 | { | ||
1088 | return 0; | ||
1089 | } | ||
1090 | |||
1091 | static void si_vga_set_state(struct amdgpu_device *adev, bool state) | ||
1092 | { | ||
1093 | uint32_t temp; | ||
1094 | |||
1095 | temp = RREG32(CONFIG_CNTL); | ||
1096 | if (state == false) { | ||
1097 | temp &= ~(1<<0); | ||
1098 | temp |= (1<<1); | ||
1099 | } else { | ||
1100 | temp &= ~(1<<1); | ||
1101 | } | ||
1102 | WREG32(CONFIG_CNTL, temp); | ||
1103 | } | ||
1104 | |||
1105 | static u32 si_get_xclk(struct amdgpu_device *adev) | ||
1106 | { | ||
1107 | u32 reference_clock = adev->clock.spll.reference_freq; | ||
1108 | u32 tmp; | ||
1109 | |||
1110 | tmp = RREG32(CG_CLKPIN_CNTL_2); | ||
1111 | if (tmp & MUX_TCLK_TO_XCLK) | ||
1112 | return TCLK; | ||
1113 | |||
1114 | tmp = RREG32(CG_CLKPIN_CNTL); | ||
1115 | if (tmp & XTALIN_DIVIDE) | ||
1116 | return reference_clock / 4; | ||
1117 | |||
1118 | return reference_clock; | ||
1119 | } | ||
1120 | |||
1121 | //xxx:not implemented | ||
1122 | static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) | ||
1123 | { | ||
1124 | return 0; | ||
1125 | } | ||
1126 | |||
1127 | static const struct amdgpu_asic_funcs si_asic_funcs = | ||
1128 | { | ||
1129 | .read_disabled_bios = &si_read_disabled_bios, | ||
1130 | .read_register = &si_read_register, | ||
1131 | .reset = &si_asic_reset, | ||
1132 | .set_vga_state = &si_vga_set_state, | ||
1133 | .get_xclk = &si_get_xclk, | ||
1134 | .set_uvd_clocks = &si_set_uvd_clocks, | ||
1135 | .set_vce_clocks = NULL, | ||
1136 | .get_virtual_caps = &si_get_virtual_caps, | ||
1137 | }; | ||
1138 | |||
1139 | static uint32_t si_get_rev_id(struct amdgpu_device *adev) | ||
1140 | { | ||
1141 | return (RREG32(CC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK) | ||
1142 | >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; | ||
1143 | } | ||
1144 | |||
1145 | static int si_common_early_init(void *handle) | ||
1146 | { | ||
1147 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
1148 | |||
1149 | adev->smc_rreg = &si_smc_rreg; | ||
1150 | adev->smc_wreg = &si_smc_wreg; | ||
1151 | adev->pcie_rreg = &si_pcie_rreg; | ||
1152 | adev->pcie_wreg = &si_pcie_wreg; | ||
1153 | adev->pciep_rreg = &si_pciep_rreg; | ||
1154 | adev->pciep_wreg = &si_pciep_wreg; | ||
1155 | adev->uvd_ctx_rreg = NULL; | ||
1156 | adev->uvd_ctx_wreg = NULL; | ||
1157 | adev->didt_rreg = NULL; | ||
1158 | adev->didt_wreg = NULL; | ||
1159 | |||
1160 | adev->asic_funcs = &si_asic_funcs; | ||
1161 | |||
1162 | adev->rev_id = si_get_rev_id(adev); | ||
1163 | adev->external_rev_id = 0xFF; | ||
1164 | switch (adev->asic_type) { | ||
1165 | case CHIP_TAHITI: | ||
1166 | adev->cg_flags = | ||
1167 | AMD_CG_SUPPORT_GFX_MGCG | | ||
1168 | AMD_CG_SUPPORT_GFX_MGLS | | ||
1169 | /*AMD_CG_SUPPORT_GFX_CGCG |*/ | ||
1170 | AMD_CG_SUPPORT_GFX_CGLS | | ||
1171 | AMD_CG_SUPPORT_GFX_CGTS | | ||
1172 | AMD_CG_SUPPORT_GFX_CP_LS | | ||
1173 | AMD_CG_SUPPORT_MC_MGCG | | ||
1174 | AMD_CG_SUPPORT_SDMA_MGCG | | ||
1175 | AMD_CG_SUPPORT_BIF_LS | | ||
1176 | AMD_CG_SUPPORT_VCE_MGCG | | ||
1177 | AMD_CG_SUPPORT_UVD_MGCG | | ||
1178 | AMD_CG_SUPPORT_HDP_LS | | ||
1179 | AMD_CG_SUPPORT_HDP_MGCG; | ||
1180 | adev->pg_flags = 0; | ||
1181 | break; | ||
1182 | case CHIP_PITCAIRN: | ||
1183 | adev->cg_flags = | ||
1184 | AMD_CG_SUPPORT_GFX_MGCG | | ||
1185 | AMD_CG_SUPPORT_GFX_MGLS | | ||
1186 | /*AMD_CG_SUPPORT_GFX_CGCG |*/ | ||
1187 | AMD_CG_SUPPORT_GFX_CGLS | | ||
1188 | AMD_CG_SUPPORT_GFX_CGTS | | ||
1189 | AMD_CG_SUPPORT_GFX_CP_LS | | ||
1190 | AMD_CG_SUPPORT_GFX_RLC_LS | | ||
1191 | AMD_CG_SUPPORT_MC_LS | | ||
1192 | AMD_CG_SUPPORT_MC_MGCG | | ||
1193 | AMD_CG_SUPPORT_SDMA_MGCG | | ||
1194 | AMD_CG_SUPPORT_BIF_LS | | ||
1195 | AMD_CG_SUPPORT_VCE_MGCG | | ||
1196 | AMD_CG_SUPPORT_UVD_MGCG | | ||
1197 | AMD_CG_SUPPORT_HDP_LS | | ||
1198 | AMD_CG_SUPPORT_HDP_MGCG; | ||
1199 | adev->pg_flags = 0; | ||
1200 | break; | ||
1201 | |||
1202 | case CHIP_VERDE: | ||
1203 | adev->cg_flags = | ||
1204 | AMD_CG_SUPPORT_GFX_MGCG | | ||
1205 | AMD_CG_SUPPORT_GFX_MGLS | | ||
1206 | AMD_CG_SUPPORT_GFX_CGLS | | ||
1207 | AMD_CG_SUPPORT_GFX_CGTS | | ||
1208 | AMD_CG_SUPPORT_GFX_CGTS_LS | | ||
1209 | AMD_CG_SUPPORT_GFX_CP_LS | | ||
1210 | AMD_CG_SUPPORT_MC_LS | | ||
1211 | AMD_CG_SUPPORT_MC_MGCG | | ||
1212 | AMD_CG_SUPPORT_SDMA_MGCG | | ||
1213 | AMD_CG_SUPPORT_SDMA_LS | | ||
1214 | AMD_CG_SUPPORT_BIF_LS | | ||
1215 | AMD_CG_SUPPORT_VCE_MGCG | | ||
1216 | AMD_CG_SUPPORT_UVD_MGCG | | ||
1217 | AMD_CG_SUPPORT_HDP_LS | | ||
1218 | AMD_CG_SUPPORT_HDP_MGCG; | ||
1219 | adev->pg_flags = 0; | ||
1220 | //??? | ||
1221 | adev->external_rev_id = adev->rev_id + 0x14; | ||
1222 | break; | ||
1223 | case CHIP_OLAND: | ||
1224 | adev->cg_flags = | ||
1225 | AMD_CG_SUPPORT_GFX_MGCG | | ||
1226 | AMD_CG_SUPPORT_GFX_MGLS | | ||
1227 | /*AMD_CG_SUPPORT_GFX_CGCG |*/ | ||
1228 | AMD_CG_SUPPORT_GFX_CGLS | | ||
1229 | AMD_CG_SUPPORT_GFX_CGTS | | ||
1230 | AMD_CG_SUPPORT_GFX_CP_LS | | ||
1231 | AMD_CG_SUPPORT_GFX_RLC_LS | | ||
1232 | AMD_CG_SUPPORT_MC_LS | | ||
1233 | AMD_CG_SUPPORT_MC_MGCG | | ||
1234 | AMD_CG_SUPPORT_SDMA_MGCG | | ||
1235 | AMD_CG_SUPPORT_BIF_LS | | ||
1236 | AMD_CG_SUPPORT_UVD_MGCG | | ||
1237 | AMD_CG_SUPPORT_HDP_LS | | ||
1238 | AMD_CG_SUPPORT_HDP_MGCG; | ||
1239 | adev->pg_flags = 0; | ||
1240 | break; | ||
1241 | case CHIP_HAINAN: | ||
1242 | adev->cg_flags = | ||
1243 | AMD_CG_SUPPORT_GFX_MGCG | | ||
1244 | AMD_CG_SUPPORT_GFX_MGLS | | ||
1245 | /*AMD_CG_SUPPORT_GFX_CGCG |*/ | ||
1246 | AMD_CG_SUPPORT_GFX_CGLS | | ||
1247 | AMD_CG_SUPPORT_GFX_CGTS | | ||
1248 | AMD_CG_SUPPORT_GFX_CP_LS | | ||
1249 | AMD_CG_SUPPORT_GFX_RLC_LS | | ||
1250 | AMD_CG_SUPPORT_MC_LS | | ||
1251 | AMD_CG_SUPPORT_MC_MGCG | | ||
1252 | AMD_CG_SUPPORT_SDMA_MGCG | | ||
1253 | AMD_CG_SUPPORT_BIF_LS | | ||
1254 | AMD_CG_SUPPORT_HDP_LS | | ||
1255 | AMD_CG_SUPPORT_HDP_MGCG; | ||
1256 | adev->pg_flags = 0; | ||
1257 | break; | ||
1258 | |||
1259 | default: | ||
1260 | return -EINVAL; | ||
1261 | } | ||
1262 | |||
1263 | return 0; | ||
1264 | } | ||
1265 | |||
1266 | static int si_common_sw_init(void *handle) | ||
1267 | { | ||
1268 | return 0; | ||
1269 | } | ||
1270 | |||
1271 | static int si_common_sw_fini(void *handle) | ||
1272 | { | ||
1273 | return 0; | ||
1274 | } | ||
1275 | |||
1276 | |||
1277 | static void si_init_golden_registers(struct amdgpu_device *adev) | ||
1278 | { | ||
1279 | switch (adev->asic_type) { | ||
1280 | case CHIP_TAHITI: | ||
1281 | amdgpu_program_register_sequence(adev, | ||
1282 | tahiti_golden_registers, | ||
1283 | (const u32)ARRAY_SIZE(tahiti_golden_registers)); | ||
1284 | amdgpu_program_register_sequence(adev, | ||
1285 | tahiti_golden_rlc_registers, | ||
1286 | (const u32)ARRAY_SIZE(tahiti_golden_rlc_registers)); | ||
1287 | amdgpu_program_register_sequence(adev, | ||
1288 | tahiti_mgcg_cgcg_init, | ||
1289 | (const u32)ARRAY_SIZE(tahiti_mgcg_cgcg_init)); | ||
1290 | amdgpu_program_register_sequence(adev, | ||
1291 | tahiti_golden_registers2, | ||
1292 | (const u32)ARRAY_SIZE(tahiti_golden_registers2)); | ||
1293 | break; | ||
1294 | case CHIP_PITCAIRN: | ||
1295 | amdgpu_program_register_sequence(adev, | ||
1296 | pitcairn_golden_registers, | ||
1297 | (const u32)ARRAY_SIZE(pitcairn_golden_registers)); | ||
1298 | amdgpu_program_register_sequence(adev, | ||
1299 | pitcairn_golden_rlc_registers, | ||
1300 | (const u32)ARRAY_SIZE(pitcairn_golden_rlc_registers)); | ||
1301 | amdgpu_program_register_sequence(adev, | ||
1302 | pitcairn_mgcg_cgcg_init, | ||
1303 | (const u32)ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); | ||
1304 | case CHIP_VERDE: | ||
1305 | amdgpu_program_register_sequence(adev, | ||
1306 | verde_golden_registers, | ||
1307 | (const u32)ARRAY_SIZE(verde_golden_registers)); | ||
1308 | amdgpu_program_register_sequence(adev, | ||
1309 | verde_golden_rlc_registers, | ||
1310 | (const u32)ARRAY_SIZE(verde_golden_rlc_registers)); | ||
1311 | amdgpu_program_register_sequence(adev, | ||
1312 | verde_mgcg_cgcg_init, | ||
1313 | (const u32)ARRAY_SIZE(verde_mgcg_cgcg_init)); | ||
1314 | amdgpu_program_register_sequence(adev, | ||
1315 | verde_pg_init, | ||
1316 | (const u32)ARRAY_SIZE(verde_pg_init)); | ||
1317 | break; | ||
1318 | case CHIP_OLAND: | ||
1319 | amdgpu_program_register_sequence(adev, | ||
1320 | oland_golden_registers, | ||
1321 | (const u32)ARRAY_SIZE(oland_golden_registers)); | ||
1322 | amdgpu_program_register_sequence(adev, | ||
1323 | oland_golden_rlc_registers, | ||
1324 | (const u32)ARRAY_SIZE(oland_golden_rlc_registers)); | ||
1325 | amdgpu_program_register_sequence(adev, | ||
1326 | oland_mgcg_cgcg_init, | ||
1327 | (const u32)ARRAY_SIZE(oland_mgcg_cgcg_init)); | ||
1328 | case CHIP_HAINAN: | ||
1329 | amdgpu_program_register_sequence(adev, | ||
1330 | hainan_golden_registers, | ||
1331 | (const u32)ARRAY_SIZE(hainan_golden_registers)); | ||
1332 | amdgpu_program_register_sequence(adev, | ||
1333 | hainan_golden_registers2, | ||
1334 | (const u32)ARRAY_SIZE(hainan_golden_registers2)); | ||
1335 | amdgpu_program_register_sequence(adev, | ||
1336 | hainan_mgcg_cgcg_init, | ||
1337 | (const u32)ARRAY_SIZE(hainan_mgcg_cgcg_init)); | ||
1338 | break; | ||
1339 | |||
1340 | |||
1341 | default: | ||
1342 | BUG(); | ||
1343 | } | ||
1344 | } | ||
1345 | |||
1346 | static void si_pcie_gen3_enable(struct amdgpu_device *adev) | ||
1347 | { | ||
1348 | struct pci_dev *root = adev->pdev->bus->self; | ||
1349 | int bridge_pos, gpu_pos; | ||
1350 | u32 speed_cntl, mask, current_data_rate; | ||
1351 | int ret, i; | ||
1352 | u16 tmp16; | ||
1353 | |||
1354 | if (pci_is_root_bus(adev->pdev->bus)) | ||
1355 | return; | ||
1356 | |||
1357 | if (amdgpu_pcie_gen2 == 0) | ||
1358 | return; | ||
1359 | |||
1360 | if (adev->flags & AMD_IS_APU) | ||
1361 | return; | ||
1362 | |||
1363 | ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); | ||
1364 | if (ret != 0) | ||
1365 | return; | ||
1366 | |||
1367 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) | ||
1368 | return; | ||
1369 | |||
1370 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | ||
1371 | current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> | ||
1372 | LC_CURRENT_DATA_RATE_SHIFT; | ||
1373 | if (mask & DRM_PCIE_SPEED_80) { | ||
1374 | if (current_data_rate == 2) { | ||
1375 | DRM_INFO("PCIE gen 3 link speeds already enabled\n"); | ||
1376 | return; | ||
1377 | } | ||
1378 | DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); | ||
1379 | } else if (mask & DRM_PCIE_SPEED_50) { | ||
1380 | if (current_data_rate == 1) { | ||
1381 | DRM_INFO("PCIE gen 2 link speeds already enabled\n"); | ||
1382 | return; | ||
1383 | } | ||
1384 | DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n"); | ||
1385 | } | ||
1386 | |||
1387 | bridge_pos = pci_pcie_cap(root); | ||
1388 | if (!bridge_pos) | ||
1389 | return; | ||
1390 | |||
1391 | gpu_pos = pci_pcie_cap(adev->pdev); | ||
1392 | if (!gpu_pos) | ||
1393 | return; | ||
1394 | |||
1395 | if (mask & DRM_PCIE_SPEED_80) { | ||
1396 | if (current_data_rate != 2) { | ||
1397 | u16 bridge_cfg, gpu_cfg; | ||
1398 | u16 bridge_cfg2, gpu_cfg2; | ||
1399 | u32 max_lw, current_lw, tmp; | ||
1400 | |||
1401 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); | ||
1402 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); | ||
1403 | |||
1404 | tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD; | ||
1405 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); | ||
1406 | |||
1407 | tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD; | ||
1408 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); | ||
1409 | |||
1410 | tmp = RREG32_PCIE(PCIE_LC_STATUS1); | ||
1411 | max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; | ||
1412 | current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; | ||
1413 | |||
1414 | if (current_lw < max_lw) { | ||
1415 | tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); | ||
1416 | if (tmp & LC_RENEGOTIATION_SUPPORT) { | ||
1417 | tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); | ||
1418 | tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); | ||
1419 | tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; | ||
1420 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); | ||
1421 | } | ||
1422 | } | ||
1423 | |||
1424 | for (i = 0; i < 10; i++) { | ||
1425 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16); | ||
1426 | if (tmp16 & PCI_EXP_DEVSTA_TRPND) | ||
1427 | break; | ||
1428 | |||
1429 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); | ||
1430 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); | ||
1431 | |||
1432 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); | ||
1433 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); | ||
1434 | |||
1435 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); | ||
1436 | tmp |= LC_SET_QUIESCE; | ||
1437 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); | ||
1438 | |||
1439 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); | ||
1440 | tmp |= LC_REDO_EQ; | ||
1441 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); | ||
1442 | |||
1443 | mdelay(100); | ||
1444 | |||
1445 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16); | ||
1446 | tmp16 &= ~PCI_EXP_LNKCTL_HAWD; | ||
1447 | tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD); | ||
1448 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); | ||
1449 | |||
1450 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16); | ||
1451 | tmp16 &= ~PCI_EXP_LNKCTL_HAWD; | ||
1452 | tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD); | ||
1453 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); | ||
1454 | |||
1455 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16); | ||
1456 | tmp16 &= ~((1 << 4) | (7 << 9)); | ||
1457 | tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9))); | ||
1458 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16); | ||
1459 | |||
1460 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); | ||
1461 | tmp16 &= ~((1 << 4) | (7 << 9)); | ||
1462 | tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); | ||
1463 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); | ||
1464 | |||
1465 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); | ||
1466 | tmp &= ~LC_SET_QUIESCE; | ||
1467 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); | ||
1468 | } | ||
1469 | } | ||
1470 | } | ||
1471 | |||
1472 | speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; | ||
1473 | speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; | ||
1474 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); | ||
1475 | |||
1476 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); | ||
1477 | tmp16 &= ~0xf; | ||
1478 | if (mask & DRM_PCIE_SPEED_80) | ||
1479 | tmp16 |= 3; | ||
1480 | else if (mask & DRM_PCIE_SPEED_50) | ||
1481 | tmp16 |= 2; | ||
1482 | else | ||
1483 | tmp16 |= 1; | ||
1484 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); | ||
1485 | |||
1486 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | ||
1487 | speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; | ||
1488 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); | ||
1489 | |||
1490 | for (i = 0; i < adev->usec_timeout; i++) { | ||
1491 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | ||
1492 | if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) | ||
1493 | break; | ||
1494 | udelay(1); | ||
1495 | } | ||
1496 | } | ||
1497 | |||
1498 | static inline u32 si_pif_phy0_rreg(struct amdgpu_device *adev, u32 reg) | ||
1499 | { | ||
1500 | unsigned long flags; | ||
1501 | u32 r; | ||
1502 | |||
1503 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
1504 | WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); | ||
1505 | r = RREG32(EVERGREEN_PIF_PHY0_DATA); | ||
1506 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
1507 | return r; | ||
1508 | } | ||
1509 | |||
1510 | static inline void si_pif_phy0_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
1511 | { | ||
1512 | unsigned long flags; | ||
1513 | |||
1514 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
1515 | WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); | ||
1516 | WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); | ||
1517 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
1518 | } | ||
1519 | |||
1520 | static inline u32 si_pif_phy1_rreg(struct amdgpu_device *adev, u32 reg) | ||
1521 | { | ||
1522 | unsigned long flags; | ||
1523 | u32 r; | ||
1524 | |||
1525 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
1526 | WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); | ||
1527 | r = RREG32(EVERGREEN_PIF_PHY1_DATA); | ||
1528 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
1529 | return r; | ||
1530 | } | ||
1531 | |||
1532 | static inline void si_pif_phy1_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
1533 | { | ||
1534 | unsigned long flags; | ||
1535 | |||
1536 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
1537 | WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); | ||
1538 | WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); | ||
1539 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
1540 | } | ||
1541 | static void si_program_aspm(struct amdgpu_device *adev) | ||
1542 | { | ||
1543 | u32 data, orig; | ||
1544 | bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; | ||
1545 | bool disable_clkreq = false; | ||
1546 | |||
1547 | if (amdgpu_aspm == 0) | ||
1548 | return; | ||
1549 | |||
1550 | if (adev->flags & AMD_IS_APU) | ||
1551 | return; | ||
1552 | orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); | ||
1553 | data &= ~LC_XMIT_N_FTS_MASK; | ||
1554 | data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; | ||
1555 | if (orig != data) | ||
1556 | WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); | ||
1557 | |||
1558 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); | ||
1559 | data |= LC_GO_TO_RECOVERY; | ||
1560 | if (orig != data) | ||
1561 | WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); | ||
1562 | |||
1563 | orig = data = RREG32_PCIE(PCIE_P_CNTL); | ||
1564 | data |= P_IGNORE_EDB_ERR; | ||
1565 | if (orig != data) | ||
1566 | WREG32_PCIE(PCIE_P_CNTL, data); | ||
1567 | |||
1568 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); | ||
1569 | data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); | ||
1570 | data |= LC_PMI_TO_L1_DIS; | ||
1571 | if (!disable_l0s) | ||
1572 | data |= LC_L0S_INACTIVITY(7); | ||
1573 | |||
1574 | if (!disable_l1) { | ||
1575 | data |= LC_L1_INACTIVITY(7); | ||
1576 | data &= ~LC_PMI_TO_L1_DIS; | ||
1577 | if (orig != data) | ||
1578 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); | ||
1579 | |||
1580 | if (!disable_plloff_in_l1) { | ||
1581 | bool clk_req_support; | ||
1582 | |||
1583 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); | ||
1584 | data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); | ||
1585 | data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); | ||
1586 | if (orig != data) | ||
1587 | si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); | ||
1588 | |||
1589 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); | ||
1590 | data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); | ||
1591 | data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); | ||
1592 | if (orig != data) | ||
1593 | si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); | ||
1594 | |||
1595 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); | ||
1596 | data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); | ||
1597 | data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); | ||
1598 | if (orig != data) | ||
1599 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); | ||
1600 | |||
1601 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); | ||
1602 | data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); | ||
1603 | data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); | ||
1604 | if (orig != data) | ||
1605 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); | ||
1606 | |||
1607 | if ((adev->family != CHIP_OLAND) && (adev->family != CHIP_HAINAN)) { | ||
1608 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); | ||
1609 | data &= ~PLL_RAMP_UP_TIME_0_MASK; | ||
1610 | if (orig != data) | ||
1611 | si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); | ||
1612 | |||
1613 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); | ||
1614 | data &= ~PLL_RAMP_UP_TIME_1_MASK; | ||
1615 | if (orig != data) | ||
1616 | si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); | ||
1617 | |||
1618 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_2); | ||
1619 | data &= ~PLL_RAMP_UP_TIME_2_MASK; | ||
1620 | if (orig != data) | ||
1621 | si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_2, data); | ||
1622 | |||
1623 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_3); | ||
1624 | data &= ~PLL_RAMP_UP_TIME_3_MASK; | ||
1625 | if (orig != data) | ||
1626 | si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_3, data); | ||
1627 | |||
1628 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); | ||
1629 | data &= ~PLL_RAMP_UP_TIME_0_MASK; | ||
1630 | if (orig != data) | ||
1631 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); | ||
1632 | |||
1633 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); | ||
1634 | data &= ~PLL_RAMP_UP_TIME_1_MASK; | ||
1635 | if (orig != data) | ||
1636 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); | ||
1637 | |||
1638 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_2); | ||
1639 | data &= ~PLL_RAMP_UP_TIME_2_MASK; | ||
1640 | if (orig != data) | ||
1641 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_2, data); | ||
1642 | |||
1643 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_3); | ||
1644 | data &= ~PLL_RAMP_UP_TIME_3_MASK; | ||
1645 | if (orig != data) | ||
1646 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); | ||
1647 | } | ||
1648 | orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); | ||
1649 | data &= ~LC_DYN_LANES_PWR_STATE_MASK; | ||
1650 | data |= LC_DYN_LANES_PWR_STATE(3); | ||
1651 | if (orig != data) | ||
1652 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); | ||
1653 | |||
1654 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); | ||
1655 | data &= ~LS2_EXIT_TIME_MASK; | ||
1656 | if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN)) | ||
1657 | data |= LS2_EXIT_TIME(5); | ||
1658 | if (orig != data) | ||
1659 | si_pif_phy0_wreg(adev,PB0_PIF_CNTL, data); | ||
1660 | |||
1661 | orig = data = si_pif_phy1_rreg(adev,PB1_PIF_CNTL); | ||
1662 | data &= ~LS2_EXIT_TIME_MASK; | ||
1663 | if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN)) | ||
1664 | data |= LS2_EXIT_TIME(5); | ||
1665 | if (orig != data) | ||
1666 | si_pif_phy1_wreg(adev,PB1_PIF_CNTL, data); | ||
1667 | |||
1668 | if (!disable_clkreq && | ||
1669 | !pci_is_root_bus(adev->pdev->bus)) { | ||
1670 | struct pci_dev *root = adev->pdev->bus->self; | ||
1671 | u32 lnkcap; | ||
1672 | |||
1673 | clk_req_support = false; | ||
1674 | pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); | ||
1675 | if (lnkcap & PCI_EXP_LNKCAP_CLKPM) | ||
1676 | clk_req_support = true; | ||
1677 | } else { | ||
1678 | clk_req_support = false; | ||
1679 | } | ||
1680 | |||
1681 | if (clk_req_support) { | ||
1682 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); | ||
1683 | data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; | ||
1684 | if (orig != data) | ||
1685 | WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); | ||
1686 | |||
1687 | orig = data = RREG32(THM_CLK_CNTL); | ||
1688 | data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); | ||
1689 | data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); | ||
1690 | if (orig != data) | ||
1691 | WREG32(THM_CLK_CNTL, data); | ||
1692 | |||
1693 | orig = data = RREG32(MISC_CLK_CNTL); | ||
1694 | data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); | ||
1695 | data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); | ||
1696 | if (orig != data) | ||
1697 | WREG32(MISC_CLK_CNTL, data); | ||
1698 | |||
1699 | orig = data = RREG32(CG_CLKPIN_CNTL); | ||
1700 | data &= ~BCLK_AS_XCLK; | ||
1701 | if (orig != data) | ||
1702 | WREG32(CG_CLKPIN_CNTL, data); | ||
1703 | |||
1704 | orig = data = RREG32(CG_CLKPIN_CNTL_2); | ||
1705 | data &= ~FORCE_BIF_REFCLK_EN; | ||
1706 | if (orig != data) | ||
1707 | WREG32(CG_CLKPIN_CNTL_2, data); | ||
1708 | |||
1709 | orig = data = RREG32(MPLL_BYPASSCLK_SEL); | ||
1710 | data &= ~MPLL_CLKOUT_SEL_MASK; | ||
1711 | data |= MPLL_CLKOUT_SEL(4); | ||
1712 | if (orig != data) | ||
1713 | WREG32(MPLL_BYPASSCLK_SEL, data); | ||
1714 | |||
1715 | orig = data = RREG32(SPLL_CNTL_MODE); | ||
1716 | data &= ~SPLL_REFCLK_SEL_MASK; | ||
1717 | if (orig != data) | ||
1718 | WREG32(SPLL_CNTL_MODE, data); | ||
1719 | } | ||
1720 | } | ||
1721 | } else { | ||
1722 | if (orig != data) | ||
1723 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); | ||
1724 | } | ||
1725 | |||
1726 | orig = data = RREG32_PCIE(PCIE_CNTL2); | ||
1727 | data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; | ||
1728 | if (orig != data) | ||
1729 | WREG32_PCIE(PCIE_CNTL2, data); | ||
1730 | |||
1731 | if (!disable_l0s) { | ||
1732 | data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); | ||
1733 | if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { | ||
1734 | data = RREG32_PCIE(PCIE_LC_STATUS1); | ||
1735 | if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { | ||
1736 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); | ||
1737 | data &= ~LC_L0S_INACTIVITY_MASK; | ||
1738 | if (orig != data) | ||
1739 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); | ||
1740 | } | ||
1741 | } | ||
1742 | } | ||
1743 | } | ||
1744 | |||
1745 | static void si_fix_pci_max_read_req_size(struct amdgpu_device *adev) | ||
1746 | { | ||
1747 | int readrq; | ||
1748 | u16 v; | ||
1749 | |||
1750 | readrq = pcie_get_readrq(adev->pdev); | ||
1751 | v = ffs(readrq) - 8; | ||
1752 | if ((v == 0) || (v == 6) || (v == 7)) | ||
1753 | pcie_set_readrq(adev->pdev, 512); | ||
1754 | } | ||
1755 | |||
1756 | static int si_common_hw_init(void *handle) | ||
1757 | { | ||
1758 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
1759 | |||
1760 | si_fix_pci_max_read_req_size(adev); | ||
1761 | si_init_golden_registers(adev); | ||
1762 | si_pcie_gen3_enable(adev); | ||
1763 | si_program_aspm(adev); | ||
1764 | |||
1765 | return 0; | ||
1766 | } | ||
1767 | |||
1768 | static int si_common_hw_fini(void *handle) | ||
1769 | { | ||
1770 | return 0; | ||
1771 | } | ||
1772 | |||
1773 | static int si_common_suspend(void *handle) | ||
1774 | { | ||
1775 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
1776 | |||
1777 | return si_common_hw_fini(adev); | ||
1778 | } | ||
1779 | |||
1780 | static int si_common_resume(void *handle) | ||
1781 | { | ||
1782 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
1783 | |||
1784 | return si_common_hw_init(adev); | ||
1785 | } | ||
1786 | |||
1787 | static bool si_common_is_idle(void *handle) | ||
1788 | { | ||
1789 | return true; | ||
1790 | } | ||
1791 | |||
1792 | static int si_common_wait_for_idle(void *handle) | ||
1793 | { | ||
1794 | return 0; | ||
1795 | } | ||
1796 | |||
1797 | static int si_common_soft_reset(void *handle) | ||
1798 | { | ||
1799 | return 0; | ||
1800 | } | ||
1801 | |||
1802 | static int si_common_set_clockgating_state(void *handle, | ||
1803 | enum amd_clockgating_state state) | ||
1804 | { | ||
1805 | return 0; | ||
1806 | } | ||
1807 | |||
1808 | static int si_common_set_powergating_state(void *handle, | ||
1809 | enum amd_powergating_state state) | ||
1810 | { | ||
1811 | return 0; | ||
1812 | } | ||
1813 | |||
1814 | const struct amd_ip_funcs si_common_ip_funcs = { | ||
1815 | .name = "si_common", | ||
1816 | .early_init = si_common_early_init, | ||
1817 | .late_init = NULL, | ||
1818 | .sw_init = si_common_sw_init, | ||
1819 | .sw_fini = si_common_sw_fini, | ||
1820 | .hw_init = si_common_hw_init, | ||
1821 | .hw_fini = si_common_hw_fini, | ||
1822 | .suspend = si_common_suspend, | ||
1823 | .resume = si_common_resume, | ||
1824 | .is_idle = si_common_is_idle, | ||
1825 | .wait_for_idle = si_common_wait_for_idle, | ||
1826 | .soft_reset = si_common_soft_reset, | ||
1827 | .set_clockgating_state = si_common_set_clockgating_state, | ||
1828 | .set_powergating_state = si_common_set_powergating_state, | ||
1829 | }; | ||
1830 | |||
1831 | static const struct amdgpu_ip_block_version verde_ip_blocks[] = | ||
1832 | { | ||
1833 | { | ||
1834 | .type = AMD_IP_BLOCK_TYPE_COMMON, | ||
1835 | .major = 1, | ||
1836 | .minor = 0, | ||
1837 | .rev = 0, | ||
1838 | .funcs = &si_common_ip_funcs, | ||
1839 | }, | ||
1840 | { | ||
1841 | .type = AMD_IP_BLOCK_TYPE_GMC, | ||
1842 | .major = 6, | ||
1843 | .minor = 0, | ||
1844 | .rev = 0, | ||
1845 | .funcs = &gmc_v6_0_ip_funcs, | ||
1846 | }, | ||
1847 | { | ||
1848 | .type = AMD_IP_BLOCK_TYPE_IH, | ||
1849 | .major = 1, | ||
1850 | .minor = 0, | ||
1851 | .rev = 0, | ||
1852 | .funcs = &si_ih_ip_funcs, | ||
1853 | }, | ||
1854 | { | ||
1855 | .type = AMD_IP_BLOCK_TYPE_SMC, | ||
1856 | .major = 6, | ||
1857 | .minor = 0, | ||
1858 | .rev = 0, | ||
1859 | .funcs = &amdgpu_pp_ip_funcs, | ||
1860 | }, | ||
1861 | { | ||
1862 | .type = AMD_IP_BLOCK_TYPE_DCE, | ||
1863 | .major = 6, | ||
1864 | .minor = 0, | ||
1865 | .rev = 0, | ||
1866 | .funcs = &dce_v6_0_ip_funcs, | ||
1867 | }, | ||
1868 | { | ||
1869 | .type = AMD_IP_BLOCK_TYPE_GFX, | ||
1870 | .major = 6, | ||
1871 | .minor = 0, | ||
1872 | .rev = 0, | ||
1873 | .funcs = &gfx_v6_0_ip_funcs, | ||
1874 | }, | ||
1875 | { | ||
1876 | .type = AMD_IP_BLOCK_TYPE_SDMA, | ||
1877 | .major = 1, | ||
1878 | .minor = 0, | ||
1879 | .rev = 0, | ||
1880 | .funcs = &si_dma_ip_funcs, | ||
1881 | }, | ||
1882 | /* { | ||
1883 | .type = AMD_IP_BLOCK_TYPE_UVD, | ||
1884 | .major = 3, | ||
1885 | .minor = 1, | ||
1886 | .rev = 0, | ||
1887 | .funcs = &si_null_ip_funcs, | ||
1888 | }, | ||
1889 | { | ||
1890 | .type = AMD_IP_BLOCK_TYPE_VCE, | ||
1891 | .major = 1, | ||
1892 | .minor = 0, | ||
1893 | .rev = 0, | ||
1894 | .funcs = &si_null_ip_funcs, | ||
1895 | }, | ||
1896 | */ | ||
1897 | }; | ||
1898 | |||
1899 | |||
1900 | static const struct amdgpu_ip_block_version hainan_ip_blocks[] = | ||
1901 | { | ||
1902 | { | ||
1903 | .type = AMD_IP_BLOCK_TYPE_COMMON, | ||
1904 | .major = 1, | ||
1905 | .minor = 0, | ||
1906 | .rev = 0, | ||
1907 | .funcs = &si_common_ip_funcs, | ||
1908 | }, | ||
1909 | { | ||
1910 | .type = AMD_IP_BLOCK_TYPE_GMC, | ||
1911 | .major = 6, | ||
1912 | .minor = 0, | ||
1913 | .rev = 0, | ||
1914 | .funcs = &gmc_v6_0_ip_funcs, | ||
1915 | }, | ||
1916 | { | ||
1917 | .type = AMD_IP_BLOCK_TYPE_IH, | ||
1918 | .major = 1, | ||
1919 | .minor = 0, | ||
1920 | .rev = 0, | ||
1921 | .funcs = &si_ih_ip_funcs, | ||
1922 | }, | ||
1923 | { | ||
1924 | .type = AMD_IP_BLOCK_TYPE_SMC, | ||
1925 | .major = 6, | ||
1926 | .minor = 0, | ||
1927 | .rev = 0, | ||
1928 | .funcs = &amdgpu_pp_ip_funcs, | ||
1929 | }, | ||
1930 | { | ||
1931 | .type = AMD_IP_BLOCK_TYPE_GFX, | ||
1932 | .major = 6, | ||
1933 | .minor = 0, | ||
1934 | .rev = 0, | ||
1935 | .funcs = &gfx_v6_0_ip_funcs, | ||
1936 | }, | ||
1937 | { | ||
1938 | .type = AMD_IP_BLOCK_TYPE_SDMA, | ||
1939 | .major = 1, | ||
1940 | .minor = 0, | ||
1941 | .rev = 0, | ||
1942 | .funcs = &si_dma_ip_funcs, | ||
1943 | }, | ||
1944 | }; | ||
1945 | |||
1946 | int si_set_ip_blocks(struct amdgpu_device *adev) | ||
1947 | { | ||
1948 | switch (adev->asic_type) { | ||
1949 | case CHIP_VERDE: | ||
1950 | case CHIP_TAHITI: | ||
1951 | case CHIP_PITCAIRN: | ||
1952 | case CHIP_OLAND: | ||
1953 | adev->ip_blocks = verde_ip_blocks; | ||
1954 | adev->num_ip_blocks = ARRAY_SIZE(verde_ip_blocks); | ||
1955 | break; | ||
1956 | case CHIP_HAINAN: | ||
1957 | adev->ip_blocks = hainan_ip_blocks; | ||
1958 | adev->num_ip_blocks = ARRAY_SIZE(hainan_ip_blocks); | ||
1959 | break; | ||
1960 | default: | ||
1961 | BUG(); | ||
1962 | } | ||
1963 | return 0; | ||
1964 | } | ||
1965 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/si.h b/drivers/gpu/drm/amd/amdgpu/si.h new file mode 100644 index 000000000000..959d7b63e0e5 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __SI_H__ | ||
25 | #define __SI_H__ | ||
26 | |||
27 | extern const struct amd_ip_funcs si_common_ip_funcs; | ||
28 | |||
29 | void si_srbm_select(struct amdgpu_device *adev, | ||
30 | u32 me, u32 pipe, u32 queue, u32 vmid); | ||
31 | int si_set_ip_blocks(struct amdgpu_device *adev); | ||
32 | |||
33 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c new file mode 100644 index 000000000000..de358193a8f9 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_dma.c | |||
@@ -0,0 +1,915 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Alex Deucher | ||
23 | */ | ||
24 | #include <drm/drmP.h> | ||
25 | #include "amdgpu.h" | ||
26 | #include "amdgpu_trace.h" | ||
27 | #include "si/sid.h" | ||
28 | |||
29 | const u32 sdma_offsets[SDMA_MAX_INSTANCE] = | ||
30 | { | ||
31 | DMA0_REGISTER_OFFSET, | ||
32 | DMA1_REGISTER_OFFSET | ||
33 | }; | ||
34 | |||
35 | static void si_dma_set_ring_funcs(struct amdgpu_device *adev); | ||
36 | static void si_dma_set_buffer_funcs(struct amdgpu_device *adev); | ||
37 | static void si_dma_set_vm_pte_funcs(struct amdgpu_device *adev); | ||
38 | static void si_dma_set_irq_funcs(struct amdgpu_device *adev); | ||
39 | |||
40 | static uint32_t si_dma_ring_get_rptr(struct amdgpu_ring *ring) | ||
41 | { | ||
42 | return ring->adev->wb.wb[ring->rptr_offs>>2]; | ||
43 | } | ||
44 | |||
45 | static uint32_t si_dma_ring_get_wptr(struct amdgpu_ring *ring) | ||
46 | { | ||
47 | struct amdgpu_device *adev = ring->adev; | ||
48 | u32 me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1; | ||
49 | |||
50 | return (RREG32(DMA_RB_WPTR + sdma_offsets[me]) & 0x3fffc) >> 2; | ||
51 | } | ||
52 | |||
53 | static void si_dma_ring_set_wptr(struct amdgpu_ring *ring) | ||
54 | { | ||
55 | struct amdgpu_device *adev = ring->adev; | ||
56 | u32 me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1; | ||
57 | |||
58 | WREG32(DMA_RB_WPTR + sdma_offsets[me], (ring->wptr << 2) & 0x3fffc); | ||
59 | } | ||
60 | |||
61 | static void si_dma_ring_emit_ib(struct amdgpu_ring *ring, | ||
62 | struct amdgpu_ib *ib, | ||
63 | unsigned vm_id, bool ctx_switch) | ||
64 | { | ||
65 | /* The indirect buffer packet must end on an 8 DW boundary in the DMA ring. | ||
66 | * Pad as necessary with NOPs. | ||
67 | */ | ||
68 | while ((ring->wptr & 7) != 5) | ||
69 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0, 0)); | ||
70 | amdgpu_ring_write(ring, DMA_IB_PACKET(DMA_PACKET_INDIRECT_BUFFER, vm_id, 0)); | ||
71 | amdgpu_ring_write(ring, (ib->gpu_addr & 0xFFFFFFE0)); | ||
72 | amdgpu_ring_write(ring, (ib->length_dw << 12) | (upper_32_bits(ib->gpu_addr) & 0xFF)); | ||
73 | |||
74 | } | ||
75 | |||
76 | static void si_dma_ring_emit_hdp_flush(struct amdgpu_ring *ring) | ||
77 | { | ||
78 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_SRBM_WRITE, 0, 0, 0, 0)); | ||
79 | amdgpu_ring_write(ring, (0xf << 16) | (HDP_MEM_COHERENCY_FLUSH_CNTL)); | ||
80 | amdgpu_ring_write(ring, 1); | ||
81 | } | ||
82 | |||
83 | static void si_dma_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | ||
84 | { | ||
85 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_SRBM_WRITE, 0, 0, 0, 0)); | ||
86 | amdgpu_ring_write(ring, (0xf << 16) | (HDP_DEBUG0)); | ||
87 | amdgpu_ring_write(ring, 1); | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * si_dma_ring_emit_fence - emit a fence on the DMA ring | ||
92 | * | ||
93 | * @ring: amdgpu ring pointer | ||
94 | * @fence: amdgpu fence object | ||
95 | * | ||
96 | * Add a DMA fence packet to the ring to write | ||
97 | * the fence seq number and DMA trap packet to generate | ||
98 | * an interrupt if needed (VI). | ||
99 | */ | ||
100 | static void si_dma_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, | ||
101 | unsigned flags) | ||
102 | { | ||
103 | |||
104 | bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT; | ||
105 | /* write the fence */ | ||
106 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_FENCE, 0, 0, 0, 0)); | ||
107 | amdgpu_ring_write(ring, addr & 0xfffffffc); | ||
108 | amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xff)); | ||
109 | amdgpu_ring_write(ring, seq); | ||
110 | /* optionally write high bits as well */ | ||
111 | if (write64bit) { | ||
112 | addr += 4; | ||
113 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_FENCE, 0, 0, 0, 0)); | ||
114 | amdgpu_ring_write(ring, addr & 0xfffffffc); | ||
115 | amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xff)); | ||
116 | amdgpu_ring_write(ring, upper_32_bits(seq)); | ||
117 | } | ||
118 | /* generate an interrupt */ | ||
119 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_TRAP, 0, 0, 0, 0)); | ||
120 | } | ||
121 | |||
122 | static void si_dma_stop(struct amdgpu_device *adev) | ||
123 | { | ||
124 | struct amdgpu_ring *ring; | ||
125 | u32 rb_cntl; | ||
126 | unsigned i; | ||
127 | |||
128 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
129 | ring = &adev->sdma.instance[i].ring; | ||
130 | /* dma0 */ | ||
131 | rb_cntl = RREG32(DMA_RB_CNTL + sdma_offsets[i]); | ||
132 | rb_cntl &= ~DMA_RB_ENABLE; | ||
133 | WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl); | ||
134 | |||
135 | if (adev->mman.buffer_funcs_ring == ring) | ||
136 | amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size); | ||
137 | ring->ready = false; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | static int si_dma_start(struct amdgpu_device *adev) | ||
142 | { | ||
143 | struct amdgpu_ring *ring; | ||
144 | u32 rb_cntl, dma_cntl, ib_cntl, rb_bufsz; | ||
145 | int i, r; | ||
146 | uint64_t rptr_addr; | ||
147 | |||
148 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
149 | ring = &adev->sdma.instance[i].ring; | ||
150 | |||
151 | WREG32(DMA_SEM_INCOMPLETE_TIMER_CNTL + sdma_offsets[i], 0); | ||
152 | WREG32(DMA_SEM_WAIT_FAIL_TIMER_CNTL + sdma_offsets[i], 0); | ||
153 | |||
154 | /* Set ring buffer size in dwords */ | ||
155 | rb_bufsz = order_base_2(ring->ring_size / 4); | ||
156 | rb_cntl = rb_bufsz << 1; | ||
157 | #ifdef __BIG_ENDIAN | ||
158 | rb_cntl |= DMA_RB_SWAP_ENABLE | DMA_RPTR_WRITEBACK_SWAP_ENABLE; | ||
159 | #endif | ||
160 | WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl); | ||
161 | |||
162 | /* Initialize the ring buffer's read and write pointers */ | ||
163 | WREG32(DMA_RB_RPTR + sdma_offsets[i], 0); | ||
164 | WREG32(DMA_RB_WPTR + sdma_offsets[i], 0); | ||
165 | |||
166 | rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); | ||
167 | |||
168 | WREG32(DMA_RB_RPTR_ADDR_LO + sdma_offsets[i], lower_32_bits(rptr_addr)); | ||
169 | WREG32(DMA_RB_RPTR_ADDR_HI + sdma_offsets[i], upper_32_bits(rptr_addr) & 0xFF); | ||
170 | |||
171 | rb_cntl |= DMA_RPTR_WRITEBACK_ENABLE; | ||
172 | |||
173 | WREG32(DMA_RB_BASE + sdma_offsets[i], ring->gpu_addr >> 8); | ||
174 | |||
175 | /* enable DMA IBs */ | ||
176 | ib_cntl = DMA_IB_ENABLE | CMD_VMID_FORCE; | ||
177 | #ifdef __BIG_ENDIAN | ||
178 | ib_cntl |= DMA_IB_SWAP_ENABLE; | ||
179 | #endif | ||
180 | WREG32(DMA_IB_CNTL + sdma_offsets[i], ib_cntl); | ||
181 | |||
182 | dma_cntl = RREG32(DMA_CNTL + sdma_offsets[i]); | ||
183 | dma_cntl &= ~CTXEMPTY_INT_ENABLE; | ||
184 | WREG32(DMA_CNTL + sdma_offsets[i], dma_cntl); | ||
185 | |||
186 | ring->wptr = 0; | ||
187 | WREG32(DMA_RB_WPTR + sdma_offsets[i], ring->wptr << 2); | ||
188 | WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl | DMA_RB_ENABLE); | ||
189 | |||
190 | ring->ready = true; | ||
191 | |||
192 | r = amdgpu_ring_test_ring(ring); | ||
193 | if (r) { | ||
194 | ring->ready = false; | ||
195 | return r; | ||
196 | } | ||
197 | |||
198 | if (adev->mman.buffer_funcs_ring == ring) | ||
199 | amdgpu_ttm_set_active_vram_size(adev, adev->mc.real_vram_size); | ||
200 | } | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * si_dma_ring_test_ring - simple async dma engine test | ||
207 | * | ||
208 | * @ring: amdgpu_ring structure holding ring information | ||
209 | * | ||
210 | * Test the DMA engine by writing using it to write an | ||
211 | * value to memory. (VI). | ||
212 | * Returns 0 for success, error for failure. | ||
213 | */ | ||
214 | static int si_dma_ring_test_ring(struct amdgpu_ring *ring) | ||
215 | { | ||
216 | struct amdgpu_device *adev = ring->adev; | ||
217 | unsigned i; | ||
218 | unsigned index; | ||
219 | int r; | ||
220 | u32 tmp; | ||
221 | u64 gpu_addr; | ||
222 | |||
223 | r = amdgpu_wb_get(adev, &index); | ||
224 | if (r) { | ||
225 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); | ||
226 | return r; | ||
227 | } | ||
228 | |||
229 | gpu_addr = adev->wb.gpu_addr + (index * 4); | ||
230 | tmp = 0xCAFEDEAD; | ||
231 | adev->wb.wb[index] = cpu_to_le32(tmp); | ||
232 | |||
233 | r = amdgpu_ring_alloc(ring, 4); | ||
234 | if (r) { | ||
235 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); | ||
236 | amdgpu_wb_free(adev, index); | ||
237 | return r; | ||
238 | } | ||
239 | |||
240 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 0, 1)); | ||
241 | amdgpu_ring_write(ring, lower_32_bits(gpu_addr)); | ||
242 | amdgpu_ring_write(ring, upper_32_bits(gpu_addr) & 0xff); | ||
243 | amdgpu_ring_write(ring, 0xDEADBEEF); | ||
244 | amdgpu_ring_commit(ring); | ||
245 | |||
246 | for (i = 0; i < adev->usec_timeout; i++) { | ||
247 | tmp = le32_to_cpu(adev->wb.wb[index]); | ||
248 | if (tmp == 0xDEADBEEF) | ||
249 | break; | ||
250 | DRM_UDELAY(1); | ||
251 | } | ||
252 | |||
253 | if (i < adev->usec_timeout) { | ||
254 | DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i); | ||
255 | } else { | ||
256 | DRM_ERROR("amdgpu: ring %d test failed (0x%08X)\n", | ||
257 | ring->idx, tmp); | ||
258 | r = -EINVAL; | ||
259 | } | ||
260 | amdgpu_wb_free(adev, index); | ||
261 | |||
262 | return r; | ||
263 | } | ||
264 | |||
265 | /** | ||
266 | * si_dma_ring_test_ib - test an IB on the DMA engine | ||
267 | * | ||
268 | * @ring: amdgpu_ring structure holding ring information | ||
269 | * | ||
270 | * Test a simple IB in the DMA ring (VI). | ||
271 | * Returns 0 on success, error on failure. | ||
272 | */ | ||
273 | static int si_dma_ring_test_ib(struct amdgpu_ring *ring, long timeout) | ||
274 | { | ||
275 | struct amdgpu_device *adev = ring->adev; | ||
276 | struct amdgpu_ib ib; | ||
277 | struct fence *f = NULL; | ||
278 | unsigned index; | ||
279 | u32 tmp = 0; | ||
280 | u64 gpu_addr; | ||
281 | long r; | ||
282 | |||
283 | r = amdgpu_wb_get(adev, &index); | ||
284 | if (r) { | ||
285 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); | ||
286 | return r; | ||
287 | } | ||
288 | |||
289 | gpu_addr = adev->wb.gpu_addr + (index * 4); | ||
290 | tmp = 0xCAFEDEAD; | ||
291 | adev->wb.wb[index] = cpu_to_le32(tmp); | ||
292 | memset(&ib, 0, sizeof(ib)); | ||
293 | r = amdgpu_ib_get(adev, NULL, 256, &ib); | ||
294 | if (r) { | ||
295 | DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r); | ||
296 | goto err0; | ||
297 | } | ||
298 | |||
299 | ib.ptr[0] = DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 0, 1); | ||
300 | ib.ptr[1] = lower_32_bits(gpu_addr); | ||
301 | ib.ptr[2] = upper_32_bits(gpu_addr) & 0xff; | ||
302 | ib.ptr[3] = 0xDEADBEEF; | ||
303 | ib.length_dw = 4; | ||
304 | r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | ||
305 | if (r) | ||
306 | goto err1; | ||
307 | |||
308 | r = fence_wait_timeout(f, false, timeout); | ||
309 | if (r == 0) { | ||
310 | DRM_ERROR("amdgpu: IB test timed out\n"); | ||
311 | r = -ETIMEDOUT; | ||
312 | goto err1; | ||
313 | } else if (r < 0) { | ||
314 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); | ||
315 | goto err1; | ||
316 | } | ||
317 | tmp = le32_to_cpu(adev->wb.wb[index]); | ||
318 | if (tmp == 0xDEADBEEF) { | ||
319 | DRM_INFO("ib test on ring %d succeeded\n", ring->idx); | ||
320 | r = 0; | ||
321 | } else { | ||
322 | DRM_ERROR("amdgpu: ib test failed (0x%08X)\n", tmp); | ||
323 | r = -EINVAL; | ||
324 | } | ||
325 | |||
326 | err1: | ||
327 | amdgpu_ib_free(adev, &ib, NULL); | ||
328 | fence_put(f); | ||
329 | err0: | ||
330 | amdgpu_wb_free(adev, index); | ||
331 | return r; | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * cik_dma_vm_copy_pte - update PTEs by copying them from the GART | ||
336 | * | ||
337 | * @ib: indirect buffer to fill with commands | ||
338 | * @pe: addr of the page entry | ||
339 | * @src: src addr to copy from | ||
340 | * @count: number of page entries to update | ||
341 | * | ||
342 | * Update PTEs by copying them from the GART using DMA (SI). | ||
343 | */ | ||
344 | static void si_dma_vm_copy_pte(struct amdgpu_ib *ib, | ||
345 | uint64_t pe, uint64_t src, | ||
346 | unsigned count) | ||
347 | { | ||
348 | unsigned bytes = count * 8; | ||
349 | |||
350 | ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_COPY, | ||
351 | 1, 0, 0, bytes); | ||
352 | ib->ptr[ib->length_dw++] = lower_32_bits(pe); | ||
353 | ib->ptr[ib->length_dw++] = lower_32_bits(src); | ||
354 | ib->ptr[ib->length_dw++] = upper_32_bits(pe) & 0xff; | ||
355 | ib->ptr[ib->length_dw++] = upper_32_bits(src) & 0xff; | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * si_dma_vm_write_pte - update PTEs by writing them manually | ||
360 | * | ||
361 | * @ib: indirect buffer to fill with commands | ||
362 | * @pe: addr of the page entry | ||
363 | * @value: dst addr to write into pe | ||
364 | * @count: number of page entries to update | ||
365 | * @incr: increase next addr by incr bytes | ||
366 | * | ||
367 | * Update PTEs by writing them manually using DMA (SI). | ||
368 | */ | ||
369 | static void si_dma_vm_write_pte(struct amdgpu_ib *ib, uint64_t pe, | ||
370 | uint64_t value, unsigned count, | ||
371 | uint32_t incr) | ||
372 | { | ||
373 | unsigned ndw = count * 2; | ||
374 | |||
375 | ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 0, ndw); | ||
376 | ib->ptr[ib->length_dw++] = lower_32_bits(pe); | ||
377 | ib->ptr[ib->length_dw++] = upper_32_bits(pe); | ||
378 | for (; ndw > 0; ndw -= 2) { | ||
379 | ib->ptr[ib->length_dw++] = lower_32_bits(value); | ||
380 | ib->ptr[ib->length_dw++] = upper_32_bits(value); | ||
381 | value += incr; | ||
382 | } | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * si_dma_vm_set_pte_pde - update the page tables using sDMA | ||
387 | * | ||
388 | * @ib: indirect buffer to fill with commands | ||
389 | * @pe: addr of the page entry | ||
390 | * @addr: dst addr to write into pe | ||
391 | * @count: number of page entries to update | ||
392 | * @incr: increase next addr by incr bytes | ||
393 | * @flags: access flags | ||
394 | * | ||
395 | * Update the page tables using sDMA (CIK). | ||
396 | */ | ||
397 | static void si_dma_vm_set_pte_pde(struct amdgpu_ib *ib, | ||
398 | uint64_t pe, | ||
399 | uint64_t addr, unsigned count, | ||
400 | uint32_t incr, uint32_t flags) | ||
401 | { | ||
402 | uint64_t value; | ||
403 | unsigned ndw; | ||
404 | |||
405 | while (count) { | ||
406 | ndw = count * 2; | ||
407 | if (ndw > 0xFFFFE) | ||
408 | ndw = 0xFFFFE; | ||
409 | |||
410 | if (flags & AMDGPU_PTE_VALID) | ||
411 | value = addr; | ||
412 | else | ||
413 | value = 0; | ||
414 | |||
415 | /* for physically contiguous pages (vram) */ | ||
416 | ib->ptr[ib->length_dw++] = DMA_PTE_PDE_PACKET(ndw); | ||
417 | ib->ptr[ib->length_dw++] = pe; /* dst addr */ | ||
418 | ib->ptr[ib->length_dw++] = upper_32_bits(pe) & 0xff; | ||
419 | ib->ptr[ib->length_dw++] = flags; /* mask */ | ||
420 | ib->ptr[ib->length_dw++] = 0; | ||
421 | ib->ptr[ib->length_dw++] = value; /* value */ | ||
422 | ib->ptr[ib->length_dw++] = upper_32_bits(value); | ||
423 | ib->ptr[ib->length_dw++] = incr; /* increment size */ | ||
424 | ib->ptr[ib->length_dw++] = 0; | ||
425 | pe += ndw * 4; | ||
426 | addr += (ndw / 2) * incr; | ||
427 | count -= ndw / 2; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * si_dma_pad_ib - pad the IB to the required number of dw | ||
433 | * | ||
434 | * @ib: indirect buffer to fill with padding | ||
435 | * | ||
436 | */ | ||
437 | static void si_dma_ring_pad_ib(struct amdgpu_ring *ring, struct amdgpu_ib *ib) | ||
438 | { | ||
439 | while (ib->length_dw & 0x7) | ||
440 | ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0, 0); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * cik_sdma_ring_emit_pipeline_sync - sync the pipeline | ||
445 | * | ||
446 | * @ring: amdgpu_ring pointer | ||
447 | * | ||
448 | * Make sure all previous operations are completed (CIK). | ||
449 | */ | ||
450 | static void si_dma_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | ||
451 | { | ||
452 | uint32_t seq = ring->fence_drv.sync_seq; | ||
453 | uint64_t addr = ring->fence_drv.gpu_addr; | ||
454 | |||
455 | /* wait for idle */ | ||
456 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_POLL_REG_MEM, 0, 0, 0, 0) | | ||
457 | (1 << 27)); /* Poll memory */ | ||
458 | amdgpu_ring_write(ring, lower_32_bits(addr)); | ||
459 | amdgpu_ring_write(ring, (0xff << 16) | upper_32_bits(addr)); /* retry, addr_hi */ | ||
460 | amdgpu_ring_write(ring, 0xffffffff); /* mask */ | ||
461 | amdgpu_ring_write(ring, seq); /* value */ | ||
462 | amdgpu_ring_write(ring, (3 << 28) | 0x20); /* func(equal) | poll interval */ | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * si_dma_ring_emit_vm_flush - cik vm flush using sDMA | ||
467 | * | ||
468 | * @ring: amdgpu_ring pointer | ||
469 | * @vm: amdgpu_vm pointer | ||
470 | * | ||
471 | * Update the page table base and flush the VM TLB | ||
472 | * using sDMA (VI). | ||
473 | */ | ||
474 | static void si_dma_ring_emit_vm_flush(struct amdgpu_ring *ring, | ||
475 | unsigned vm_id, uint64_t pd_addr) | ||
476 | { | ||
477 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_SRBM_WRITE, 0, 0, 0, 0)); | ||
478 | if (vm_id < 8) | ||
479 | amdgpu_ring_write(ring, (0xf << 16) | (VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + vm_id)); | ||
480 | else | ||
481 | amdgpu_ring_write(ring, (0xf << 16) | (VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + (vm_id - 8))); | ||
482 | amdgpu_ring_write(ring, pd_addr >> 12); | ||
483 | |||
484 | /* bits 0-7 are the VM contexts0-7 */ | ||
485 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_SRBM_WRITE, 0, 0, 0, 0)); | ||
486 | amdgpu_ring_write(ring, (0xf << 16) | (VM_INVALIDATE_REQUEST)); | ||
487 | amdgpu_ring_write(ring, 1 << vm_id); | ||
488 | |||
489 | /* wait for invalidate to complete */ | ||
490 | amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_POLL_REG_MEM, 0, 0, 0, 0)); | ||
491 | amdgpu_ring_write(ring, VM_INVALIDATE_REQUEST); | ||
492 | amdgpu_ring_write(ring, 0xff << 16); /* retry */ | ||
493 | amdgpu_ring_write(ring, 1 << vm_id); /* mask */ | ||
494 | amdgpu_ring_write(ring, 0); /* value */ | ||
495 | amdgpu_ring_write(ring, (0 << 28) | 0x20); /* func(always) | poll interval */ | ||
496 | } | ||
497 | |||
498 | static unsigned si_dma_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
499 | { | ||
500 | return | ||
501 | 7 + 3; /* si_dma_ring_emit_ib */ | ||
502 | } | ||
503 | |||
504 | static unsigned si_dma_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
505 | { | ||
506 | return | ||
507 | 3 + /* si_dma_ring_emit_hdp_flush */ | ||
508 | 3 + /* si_dma_ring_emit_hdp_invalidate */ | ||
509 | 6 + /* si_dma_ring_emit_pipeline_sync */ | ||
510 | 12 + /* si_dma_ring_emit_vm_flush */ | ||
511 | 9 + 9 + 9; /* si_dma_ring_emit_fence x3 for user fence, vm fence */ | ||
512 | } | ||
513 | |||
514 | static int si_dma_early_init(void *handle) | ||
515 | { | ||
516 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
517 | |||
518 | adev->sdma.num_instances = 2; | ||
519 | |||
520 | si_dma_set_ring_funcs(adev); | ||
521 | si_dma_set_buffer_funcs(adev); | ||
522 | si_dma_set_vm_pte_funcs(adev); | ||
523 | si_dma_set_irq_funcs(adev); | ||
524 | |||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static int si_dma_sw_init(void *handle) | ||
529 | { | ||
530 | struct amdgpu_ring *ring; | ||
531 | int r, i; | ||
532 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
533 | |||
534 | /* DMA0 trap event */ | ||
535 | r = amdgpu_irq_add_id(adev, 224, &adev->sdma.trap_irq); | ||
536 | if (r) | ||
537 | return r; | ||
538 | |||
539 | /* DMA1 trap event */ | ||
540 | r = amdgpu_irq_add_id(adev, 244, &adev->sdma.trap_irq_1); | ||
541 | if (r) | ||
542 | return r; | ||
543 | |||
544 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
545 | ring = &adev->sdma.instance[i].ring; | ||
546 | ring->ring_obj = NULL; | ||
547 | ring->use_doorbell = false; | ||
548 | sprintf(ring->name, "sdma%d", i); | ||
549 | r = amdgpu_ring_init(adev, ring, 1024, | ||
550 | DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0, 0), 0xf, | ||
551 | &adev->sdma.trap_irq, | ||
552 | (i == 0) ? | ||
553 | AMDGPU_SDMA_IRQ_TRAP0 : AMDGPU_SDMA_IRQ_TRAP1, | ||
554 | AMDGPU_RING_TYPE_SDMA); | ||
555 | if (r) | ||
556 | return r; | ||
557 | } | ||
558 | |||
559 | return r; | ||
560 | } | ||
561 | |||
562 | static int si_dma_sw_fini(void *handle) | ||
563 | { | ||
564 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
565 | int i; | ||
566 | |||
567 | for (i = 0; i < adev->sdma.num_instances; i++) | ||
568 | amdgpu_ring_fini(&adev->sdma.instance[i].ring); | ||
569 | |||
570 | return 0; | ||
571 | } | ||
572 | |||
573 | static int si_dma_hw_init(void *handle) | ||
574 | { | ||
575 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
576 | |||
577 | return si_dma_start(adev); | ||
578 | } | ||
579 | |||
580 | static int si_dma_hw_fini(void *handle) | ||
581 | { | ||
582 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
583 | |||
584 | si_dma_stop(adev); | ||
585 | |||
586 | return 0; | ||
587 | } | ||
588 | |||
589 | static int si_dma_suspend(void *handle) | ||
590 | { | ||
591 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
592 | |||
593 | return si_dma_hw_fini(adev); | ||
594 | } | ||
595 | |||
596 | static int si_dma_resume(void *handle) | ||
597 | { | ||
598 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
599 | |||
600 | return si_dma_hw_init(adev); | ||
601 | } | ||
602 | |||
603 | static bool si_dma_is_idle(void *handle) | ||
604 | { | ||
605 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
606 | u32 tmp = RREG32(SRBM_STATUS2); | ||
607 | |||
608 | if (tmp & (DMA_BUSY_MASK | DMA1_BUSY_MASK)) | ||
609 | return false; | ||
610 | |||
611 | return true; | ||
612 | } | ||
613 | |||
614 | static int si_dma_wait_for_idle(void *handle) | ||
615 | { | ||
616 | unsigned i; | ||
617 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
618 | |||
619 | for (i = 0; i < adev->usec_timeout; i++) { | ||
620 | if (si_dma_is_idle(handle)) | ||
621 | return 0; | ||
622 | udelay(1); | ||
623 | } | ||
624 | return -ETIMEDOUT; | ||
625 | } | ||
626 | |||
627 | static int si_dma_soft_reset(void *handle) | ||
628 | { | ||
629 | DRM_INFO("si_dma_soft_reset --- not implemented !!!!!!!\n"); | ||
630 | return 0; | ||
631 | } | ||
632 | |||
633 | static int si_dma_set_trap_irq_state(struct amdgpu_device *adev, | ||
634 | struct amdgpu_irq_src *src, | ||
635 | unsigned type, | ||
636 | enum amdgpu_interrupt_state state) | ||
637 | { | ||
638 | u32 sdma_cntl; | ||
639 | |||
640 | switch (type) { | ||
641 | case AMDGPU_SDMA_IRQ_TRAP0: | ||
642 | switch (state) { | ||
643 | case AMDGPU_IRQ_STATE_DISABLE: | ||
644 | sdma_cntl = RREG32(DMA_CNTL + DMA0_REGISTER_OFFSET); | ||
645 | sdma_cntl &= ~TRAP_ENABLE; | ||
646 | WREG32(DMA_CNTL + DMA0_REGISTER_OFFSET, sdma_cntl); | ||
647 | break; | ||
648 | case AMDGPU_IRQ_STATE_ENABLE: | ||
649 | sdma_cntl = RREG32(DMA_CNTL + DMA0_REGISTER_OFFSET); | ||
650 | sdma_cntl |= TRAP_ENABLE; | ||
651 | WREG32(DMA_CNTL + DMA0_REGISTER_OFFSET, sdma_cntl); | ||
652 | break; | ||
653 | default: | ||
654 | break; | ||
655 | } | ||
656 | break; | ||
657 | case AMDGPU_SDMA_IRQ_TRAP1: | ||
658 | switch (state) { | ||
659 | case AMDGPU_IRQ_STATE_DISABLE: | ||
660 | sdma_cntl = RREG32(DMA_CNTL + DMA1_REGISTER_OFFSET); | ||
661 | sdma_cntl &= ~TRAP_ENABLE; | ||
662 | WREG32(DMA_CNTL + DMA1_REGISTER_OFFSET, sdma_cntl); | ||
663 | break; | ||
664 | case AMDGPU_IRQ_STATE_ENABLE: | ||
665 | sdma_cntl = RREG32(DMA_CNTL + DMA1_REGISTER_OFFSET); | ||
666 | sdma_cntl |= TRAP_ENABLE; | ||
667 | WREG32(DMA_CNTL + DMA1_REGISTER_OFFSET, sdma_cntl); | ||
668 | break; | ||
669 | default: | ||
670 | break; | ||
671 | } | ||
672 | break; | ||
673 | default: | ||
674 | break; | ||
675 | } | ||
676 | return 0; | ||
677 | } | ||
678 | |||
679 | static int si_dma_process_trap_irq(struct amdgpu_device *adev, | ||
680 | struct amdgpu_irq_src *source, | ||
681 | struct amdgpu_iv_entry *entry) | ||
682 | { | ||
683 | amdgpu_fence_process(&adev->sdma.instance[0].ring); | ||
684 | |||
685 | return 0; | ||
686 | } | ||
687 | |||
688 | static int si_dma_process_trap_irq_1(struct amdgpu_device *adev, | ||
689 | struct amdgpu_irq_src *source, | ||
690 | struct amdgpu_iv_entry *entry) | ||
691 | { | ||
692 | amdgpu_fence_process(&adev->sdma.instance[1].ring); | ||
693 | |||
694 | return 0; | ||
695 | } | ||
696 | |||
697 | static int si_dma_process_illegal_inst_irq(struct amdgpu_device *adev, | ||
698 | struct amdgpu_irq_src *source, | ||
699 | struct amdgpu_iv_entry *entry) | ||
700 | { | ||
701 | DRM_ERROR("Illegal instruction in SDMA command stream\n"); | ||
702 | schedule_work(&adev->reset_work); | ||
703 | return 0; | ||
704 | } | ||
705 | |||
706 | static int si_dma_set_clockgating_state(void *handle, | ||
707 | enum amd_clockgating_state state) | ||
708 | { | ||
709 | u32 orig, data, offset; | ||
710 | int i; | ||
711 | bool enable; | ||
712 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
713 | |||
714 | enable = (state == AMD_CG_STATE_GATE) ? true : false; | ||
715 | |||
716 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_SDMA_MGCG)) { | ||
717 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
718 | if (i == 0) | ||
719 | offset = DMA0_REGISTER_OFFSET; | ||
720 | else | ||
721 | offset = DMA1_REGISTER_OFFSET; | ||
722 | orig = data = RREG32(DMA_POWER_CNTL + offset); | ||
723 | data &= ~MEM_POWER_OVERRIDE; | ||
724 | if (data != orig) | ||
725 | WREG32(DMA_POWER_CNTL + offset, data); | ||
726 | WREG32(DMA_CLK_CTRL + offset, 0x00000100); | ||
727 | } | ||
728 | } else { | ||
729 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
730 | if (i == 0) | ||
731 | offset = DMA0_REGISTER_OFFSET; | ||
732 | else | ||
733 | offset = DMA1_REGISTER_OFFSET; | ||
734 | orig = data = RREG32(DMA_POWER_CNTL + offset); | ||
735 | data |= MEM_POWER_OVERRIDE; | ||
736 | if (data != orig) | ||
737 | WREG32(DMA_POWER_CNTL + offset, data); | ||
738 | |||
739 | orig = data = RREG32(DMA_CLK_CTRL + offset); | ||
740 | data = 0xff000000; | ||
741 | if (data != orig) | ||
742 | WREG32(DMA_CLK_CTRL + offset, data); | ||
743 | } | ||
744 | } | ||
745 | |||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | static int si_dma_set_powergating_state(void *handle, | ||
750 | enum amd_powergating_state state) | ||
751 | { | ||
752 | u32 tmp; | ||
753 | |||
754 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
755 | |||
756 | WREG32(DMA_PGFSM_WRITE, 0x00002000); | ||
757 | WREG32(DMA_PGFSM_CONFIG, 0x100010ff); | ||
758 | |||
759 | for (tmp = 0; tmp < 5; tmp++) | ||
760 | WREG32(DMA_PGFSM_WRITE, 0); | ||
761 | |||
762 | return 0; | ||
763 | } | ||
764 | |||
765 | const struct amd_ip_funcs si_dma_ip_funcs = { | ||
766 | .name = "si_dma", | ||
767 | .early_init = si_dma_early_init, | ||
768 | .late_init = NULL, | ||
769 | .sw_init = si_dma_sw_init, | ||
770 | .sw_fini = si_dma_sw_fini, | ||
771 | .hw_init = si_dma_hw_init, | ||
772 | .hw_fini = si_dma_hw_fini, | ||
773 | .suspend = si_dma_suspend, | ||
774 | .resume = si_dma_resume, | ||
775 | .is_idle = si_dma_is_idle, | ||
776 | .wait_for_idle = si_dma_wait_for_idle, | ||
777 | .soft_reset = si_dma_soft_reset, | ||
778 | .set_clockgating_state = si_dma_set_clockgating_state, | ||
779 | .set_powergating_state = si_dma_set_powergating_state, | ||
780 | }; | ||
781 | |||
782 | static const struct amdgpu_ring_funcs si_dma_ring_funcs = { | ||
783 | .get_rptr = si_dma_ring_get_rptr, | ||
784 | .get_wptr = si_dma_ring_get_wptr, | ||
785 | .set_wptr = si_dma_ring_set_wptr, | ||
786 | .parse_cs = NULL, | ||
787 | .emit_ib = si_dma_ring_emit_ib, | ||
788 | .emit_fence = si_dma_ring_emit_fence, | ||
789 | .emit_pipeline_sync = si_dma_ring_emit_pipeline_sync, | ||
790 | .emit_vm_flush = si_dma_ring_emit_vm_flush, | ||
791 | .emit_hdp_flush = si_dma_ring_emit_hdp_flush, | ||
792 | .emit_hdp_invalidate = si_dma_ring_emit_hdp_invalidate, | ||
793 | .test_ring = si_dma_ring_test_ring, | ||
794 | .test_ib = si_dma_ring_test_ib, | ||
795 | .insert_nop = amdgpu_ring_insert_nop, | ||
796 | .pad_ib = si_dma_ring_pad_ib, | ||
797 | .get_emit_ib_size = si_dma_ring_get_emit_ib_size, | ||
798 | .get_dma_frame_size = si_dma_ring_get_dma_frame_size, | ||
799 | }; | ||
800 | |||
801 | static void si_dma_set_ring_funcs(struct amdgpu_device *adev) | ||
802 | { | ||
803 | int i; | ||
804 | |||
805 | for (i = 0; i < adev->sdma.num_instances; i++) | ||
806 | adev->sdma.instance[i].ring.funcs = &si_dma_ring_funcs; | ||
807 | } | ||
808 | |||
809 | static const struct amdgpu_irq_src_funcs si_dma_trap_irq_funcs = { | ||
810 | .set = si_dma_set_trap_irq_state, | ||
811 | .process = si_dma_process_trap_irq, | ||
812 | }; | ||
813 | |||
814 | static const struct amdgpu_irq_src_funcs si_dma_trap_irq_funcs_1 = { | ||
815 | .set = si_dma_set_trap_irq_state, | ||
816 | .process = si_dma_process_trap_irq_1, | ||
817 | }; | ||
818 | |||
819 | static const struct amdgpu_irq_src_funcs si_dma_illegal_inst_irq_funcs = { | ||
820 | .process = si_dma_process_illegal_inst_irq, | ||
821 | }; | ||
822 | |||
823 | static void si_dma_set_irq_funcs(struct amdgpu_device *adev) | ||
824 | { | ||
825 | adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_LAST; | ||
826 | adev->sdma.trap_irq.funcs = &si_dma_trap_irq_funcs; | ||
827 | adev->sdma.trap_irq_1.funcs = &si_dma_trap_irq_funcs_1; | ||
828 | adev->sdma.illegal_inst_irq.funcs = &si_dma_illegal_inst_irq_funcs; | ||
829 | } | ||
830 | |||
831 | /** | ||
832 | * si_dma_emit_copy_buffer - copy buffer using the sDMA engine | ||
833 | * | ||
834 | * @ring: amdgpu_ring structure holding ring information | ||
835 | * @src_offset: src GPU address | ||
836 | * @dst_offset: dst GPU address | ||
837 | * @byte_count: number of bytes to xfer | ||
838 | * | ||
839 | * Copy GPU buffers using the DMA engine (VI). | ||
840 | * Used by the amdgpu ttm implementation to move pages if | ||
841 | * registered as the asic copy callback. | ||
842 | */ | ||
843 | static void si_dma_emit_copy_buffer(struct amdgpu_ib *ib, | ||
844 | uint64_t src_offset, | ||
845 | uint64_t dst_offset, | ||
846 | uint32_t byte_count) | ||
847 | { | ||
848 | ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_COPY, | ||
849 | 1, 0, 0, byte_count); | ||
850 | ib->ptr[ib->length_dw++] = lower_32_bits(dst_offset); | ||
851 | ib->ptr[ib->length_dw++] = lower_32_bits(src_offset); | ||
852 | ib->ptr[ib->length_dw++] = upper_32_bits(dst_offset) & 0xff; | ||
853 | ib->ptr[ib->length_dw++] = upper_32_bits(src_offset) & 0xff; | ||
854 | } | ||
855 | |||
856 | /** | ||
857 | * si_dma_emit_fill_buffer - fill buffer using the sDMA engine | ||
858 | * | ||
859 | * @ring: amdgpu_ring structure holding ring information | ||
860 | * @src_data: value to write to buffer | ||
861 | * @dst_offset: dst GPU address | ||
862 | * @byte_count: number of bytes to xfer | ||
863 | * | ||
864 | * Fill GPU buffers using the DMA engine (VI). | ||
865 | */ | ||
866 | static void si_dma_emit_fill_buffer(struct amdgpu_ib *ib, | ||
867 | uint32_t src_data, | ||
868 | uint64_t dst_offset, | ||
869 | uint32_t byte_count) | ||
870 | { | ||
871 | ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_CONSTANT_FILL, | ||
872 | 0, 0, 0, byte_count / 4); | ||
873 | ib->ptr[ib->length_dw++] = lower_32_bits(dst_offset); | ||
874 | ib->ptr[ib->length_dw++] = src_data; | ||
875 | ib->ptr[ib->length_dw++] = upper_32_bits(dst_offset) << 16; | ||
876 | } | ||
877 | |||
878 | |||
879 | static const struct amdgpu_buffer_funcs si_dma_buffer_funcs = { | ||
880 | .copy_max_bytes = 0xffff8, | ||
881 | .copy_num_dw = 5, | ||
882 | .emit_copy_buffer = si_dma_emit_copy_buffer, | ||
883 | |||
884 | .fill_max_bytes = 0xffff8, | ||
885 | .fill_num_dw = 4, | ||
886 | .emit_fill_buffer = si_dma_emit_fill_buffer, | ||
887 | }; | ||
888 | |||
889 | static void si_dma_set_buffer_funcs(struct amdgpu_device *adev) | ||
890 | { | ||
891 | if (adev->mman.buffer_funcs == NULL) { | ||
892 | adev->mman.buffer_funcs = &si_dma_buffer_funcs; | ||
893 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; | ||
894 | } | ||
895 | } | ||
896 | |||
897 | static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = { | ||
898 | .copy_pte = si_dma_vm_copy_pte, | ||
899 | .write_pte = si_dma_vm_write_pte, | ||
900 | .set_pte_pde = si_dma_vm_set_pte_pde, | ||
901 | }; | ||
902 | |||
903 | static void si_dma_set_vm_pte_funcs(struct amdgpu_device *adev) | ||
904 | { | ||
905 | unsigned i; | ||
906 | |||
907 | if (adev->vm_manager.vm_pte_funcs == NULL) { | ||
908 | adev->vm_manager.vm_pte_funcs = &si_dma_vm_pte_funcs; | ||
909 | for (i = 0; i < adev->sdma.num_instances; i++) | ||
910 | adev->vm_manager.vm_pte_rings[i] = | ||
911 | &adev->sdma.instance[i].ring; | ||
912 | |||
913 | adev->vm_manager.vm_pte_num_rings = adev->sdma.num_instances; | ||
914 | } | ||
915 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.h b/drivers/gpu/drm/amd/amdgpu/si_dma.h new file mode 100644 index 000000000000..3a3e0c78a54b --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_dma.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __SI_DMA_H__ | ||
25 | #define __SI_DMA_H__ | ||
26 | |||
27 | extern const struct amd_ip_funcs si_dma_ip_funcs; | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c new file mode 100644 index 000000000000..e2db4a734676 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c | |||
@@ -0,0 +1,7993 @@ | |||
1 | /* | ||
2 | * Copyright 2013 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "drmP.h" | ||
25 | #include "amdgpu.h" | ||
26 | #include "amdgpu_pm.h" | ||
27 | #include "amdgpu_dpm.h" | ||
28 | #include "amdgpu_atombios.h" | ||
29 | #include "si/sid.h" | ||
30 | #include "r600_dpm.h" | ||
31 | #include "si_dpm.h" | ||
32 | #include "atom.h" | ||
33 | #include "../include/pptable.h" | ||
34 | #include <linux/math64.h> | ||
35 | #include <linux/seq_file.h> | ||
36 | #include <linux/firmware.h> | ||
37 | |||
38 | #define MC_CG_ARB_FREQ_F0 0x0a | ||
39 | #define MC_CG_ARB_FREQ_F1 0x0b | ||
40 | #define MC_CG_ARB_FREQ_F2 0x0c | ||
41 | #define MC_CG_ARB_FREQ_F3 0x0d | ||
42 | |||
43 | #define SMC_RAM_END 0x20000 | ||
44 | |||
45 | #define SCLK_MIN_DEEPSLEEP_FREQ 1350 | ||
46 | |||
47 | |||
48 | /* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */ | ||
49 | #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12 | ||
50 | #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14 | ||
51 | #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16 | ||
52 | #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18 | ||
53 | #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20 | ||
54 | #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22 | ||
55 | |||
56 | #define BIOS_SCRATCH_4 0x5cd | ||
57 | |||
58 | MODULE_FIRMWARE("radeon/tahiti_smc.bin"); | ||
59 | MODULE_FIRMWARE("radeon/tahiti_k_smc.bin"); | ||
60 | MODULE_FIRMWARE("radeon/pitcairn_smc.bin"); | ||
61 | MODULE_FIRMWARE("radeon/pitcairn_k_smc.bin"); | ||
62 | MODULE_FIRMWARE("radeon/verde_smc.bin"); | ||
63 | MODULE_FIRMWARE("radeon/verde_k_smc.bin"); | ||
64 | MODULE_FIRMWARE("radeon/oland_smc.bin"); | ||
65 | MODULE_FIRMWARE("radeon/oland_k_smc.bin"); | ||
66 | MODULE_FIRMWARE("radeon/hainan_smc.bin"); | ||
67 | MODULE_FIRMWARE("radeon/hainan_k_smc.bin"); | ||
68 | |||
69 | union power_info { | ||
70 | struct _ATOM_POWERPLAY_INFO info; | ||
71 | struct _ATOM_POWERPLAY_INFO_V2 info_2; | ||
72 | struct _ATOM_POWERPLAY_INFO_V3 info_3; | ||
73 | struct _ATOM_PPLIB_POWERPLAYTABLE pplib; | ||
74 | struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2; | ||
75 | struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3; | ||
76 | struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4; | ||
77 | struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5; | ||
78 | }; | ||
79 | |||
80 | union fan_info { | ||
81 | struct _ATOM_PPLIB_FANTABLE fan; | ||
82 | struct _ATOM_PPLIB_FANTABLE2 fan2; | ||
83 | struct _ATOM_PPLIB_FANTABLE3 fan3; | ||
84 | }; | ||
85 | |||
86 | union pplib_clock_info { | ||
87 | struct _ATOM_PPLIB_R600_CLOCK_INFO r600; | ||
88 | struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780; | ||
89 | struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen; | ||
90 | struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo; | ||
91 | struct _ATOM_PPLIB_SI_CLOCK_INFO si; | ||
92 | }; | ||
93 | |||
94 | static const u32 r600_utc[R600_PM_NUMBER_OF_TC] = | ||
95 | { | ||
96 | R600_UTC_DFLT_00, | ||
97 | R600_UTC_DFLT_01, | ||
98 | R600_UTC_DFLT_02, | ||
99 | R600_UTC_DFLT_03, | ||
100 | R600_UTC_DFLT_04, | ||
101 | R600_UTC_DFLT_05, | ||
102 | R600_UTC_DFLT_06, | ||
103 | R600_UTC_DFLT_07, | ||
104 | R600_UTC_DFLT_08, | ||
105 | R600_UTC_DFLT_09, | ||
106 | R600_UTC_DFLT_10, | ||
107 | R600_UTC_DFLT_11, | ||
108 | R600_UTC_DFLT_12, | ||
109 | R600_UTC_DFLT_13, | ||
110 | R600_UTC_DFLT_14, | ||
111 | }; | ||
112 | |||
113 | static const u32 r600_dtc[R600_PM_NUMBER_OF_TC] = | ||
114 | { | ||
115 | R600_DTC_DFLT_00, | ||
116 | R600_DTC_DFLT_01, | ||
117 | R600_DTC_DFLT_02, | ||
118 | R600_DTC_DFLT_03, | ||
119 | R600_DTC_DFLT_04, | ||
120 | R600_DTC_DFLT_05, | ||
121 | R600_DTC_DFLT_06, | ||
122 | R600_DTC_DFLT_07, | ||
123 | R600_DTC_DFLT_08, | ||
124 | R600_DTC_DFLT_09, | ||
125 | R600_DTC_DFLT_10, | ||
126 | R600_DTC_DFLT_11, | ||
127 | R600_DTC_DFLT_12, | ||
128 | R600_DTC_DFLT_13, | ||
129 | R600_DTC_DFLT_14, | ||
130 | }; | ||
131 | |||
132 | static const struct si_cac_config_reg cac_weights_tahiti[] = | ||
133 | { | ||
134 | { 0x0, 0x0000ffff, 0, 0xc, SISLANDS_CACCONFIG_CGIND }, | ||
135 | { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
136 | { 0x1, 0x0000ffff, 0, 0x101, SISLANDS_CACCONFIG_CGIND }, | ||
137 | { 0x1, 0xffff0000, 16, 0xc, SISLANDS_CACCONFIG_CGIND }, | ||
138 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
139 | { 0x3, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
140 | { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
141 | { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
142 | { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
143 | { 0x5, 0x0000ffff, 0, 0x8fc, SISLANDS_CACCONFIG_CGIND }, | ||
144 | { 0x5, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
145 | { 0x6, 0x0000ffff, 0, 0x95, SISLANDS_CACCONFIG_CGIND }, | ||
146 | { 0x6, 0xffff0000, 16, 0x34e, SISLANDS_CACCONFIG_CGIND }, | ||
147 | { 0x18f, 0x0000ffff, 0, 0x1a1, SISLANDS_CACCONFIG_CGIND }, | ||
148 | { 0x7, 0x0000ffff, 0, 0xda, SISLANDS_CACCONFIG_CGIND }, | ||
149 | { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
150 | { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
151 | { 0x8, 0xffff0000, 16, 0x46, SISLANDS_CACCONFIG_CGIND }, | ||
152 | { 0x9, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
153 | { 0xa, 0x0000ffff, 0, 0x208, SISLANDS_CACCONFIG_CGIND }, | ||
154 | { 0xb, 0x0000ffff, 0, 0xe7, SISLANDS_CACCONFIG_CGIND }, | ||
155 | { 0xb, 0xffff0000, 16, 0x948, SISLANDS_CACCONFIG_CGIND }, | ||
156 | { 0xc, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
157 | { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
158 | { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
159 | { 0xe, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
160 | { 0xf, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
161 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
162 | { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
163 | { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
164 | { 0x11, 0x0000ffff, 0, 0x167, SISLANDS_CACCONFIG_CGIND }, | ||
165 | { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
166 | { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
167 | { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
168 | { 0x13, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
169 | { 0x14, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
170 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
171 | { 0x15, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
172 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
173 | { 0x16, 0x0000ffff, 0, 0x31, SISLANDS_CACCONFIG_CGIND }, | ||
174 | { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
175 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
176 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
177 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
178 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
179 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
180 | { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
181 | { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
182 | { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
183 | { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
184 | { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
185 | { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
186 | { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
187 | { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
188 | { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
189 | { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
190 | { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
191 | { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
192 | { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
193 | { 0x6d, 0x0000ffff, 0, 0x18e, SISLANDS_CACCONFIG_CGIND }, | ||
194 | { 0xFFFFFFFF } | ||
195 | }; | ||
196 | |||
197 | static const struct si_cac_config_reg lcac_tahiti[] = | ||
198 | { | ||
199 | { 0x143, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
200 | { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
201 | { 0x146, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
202 | { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
203 | { 0x149, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
204 | { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
205 | { 0x14c, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
206 | { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
207 | { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
208 | { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
209 | { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
210 | { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
211 | { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
212 | { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
213 | { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
214 | { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
215 | { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
216 | { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
217 | { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
218 | { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
219 | { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
220 | { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
221 | { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
222 | { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
223 | { 0x8c, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
224 | { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
225 | { 0x8f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
226 | { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
227 | { 0x92, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
228 | { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
229 | { 0x95, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
230 | { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
231 | { 0x14f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
232 | { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
233 | { 0x152, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
234 | { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
235 | { 0x155, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
236 | { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
237 | { 0x158, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
238 | { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
239 | { 0x110, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
240 | { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
241 | { 0x113, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
242 | { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
243 | { 0x116, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
244 | { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
245 | { 0x119, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND }, | ||
246 | { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
247 | { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
248 | { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
249 | { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
250 | { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
251 | { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
252 | { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
253 | { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
254 | { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
255 | { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
256 | { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
257 | { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
258 | { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
259 | { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
260 | { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
261 | { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
262 | { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
263 | { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
264 | { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
265 | { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
266 | { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
267 | { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
268 | { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
269 | { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
270 | { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
271 | { 0x16d, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
272 | { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
273 | { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
274 | { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
275 | { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
276 | { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
277 | { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
278 | { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
279 | { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
280 | { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
281 | { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
282 | { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
283 | { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
284 | { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
285 | { 0xFFFFFFFF } | ||
286 | |||
287 | }; | ||
288 | |||
289 | static const struct si_cac_config_reg cac_override_tahiti[] = | ||
290 | { | ||
291 | { 0xFFFFFFFF } | ||
292 | }; | ||
293 | |||
294 | static const struct si_powertune_data powertune_data_tahiti = | ||
295 | { | ||
296 | ((1 << 16) | 27027), | ||
297 | 6, | ||
298 | 0, | ||
299 | 4, | ||
300 | 95, | ||
301 | { | ||
302 | 0UL, | ||
303 | 0UL, | ||
304 | 4521550UL, | ||
305 | 309631529UL, | ||
306 | -1270850L, | ||
307 | 4513710L, | ||
308 | 40 | ||
309 | }, | ||
310 | 595000000UL, | ||
311 | 12, | ||
312 | { | ||
313 | 0, | ||
314 | 0, | ||
315 | 0, | ||
316 | 0, | ||
317 | 0, | ||
318 | 0, | ||
319 | 0, | ||
320 | 0 | ||
321 | }, | ||
322 | true | ||
323 | }; | ||
324 | |||
325 | static const struct si_dte_data dte_data_tahiti = | ||
326 | { | ||
327 | { 1159409, 0, 0, 0, 0 }, | ||
328 | { 777, 0, 0, 0, 0 }, | ||
329 | 2, | ||
330 | 54000, | ||
331 | 127000, | ||
332 | 25, | ||
333 | 2, | ||
334 | 10, | ||
335 | 13, | ||
336 | { 27, 31, 35, 39, 43, 47, 54, 61, 67, 74, 81, 88, 95, 0, 0, 0 }, | ||
337 | { 240888759, 221057860, 235370597, 162287531, 158510299, 131423027, 116673180, 103067515, 87941937, 76209048, 68209175, 64090048, 58301890, 0, 0, 0 }, | ||
338 | { 12024, 11189, 11451, 8411, 7939, 6666, 5681, 4905, 4241, 3720, 3354, 3122, 2890, 0, 0, 0 }, | ||
339 | 85, | ||
340 | false | ||
341 | }; | ||
342 | |||
343 | #if 0 | ||
344 | static const struct si_dte_data dte_data_tahiti_le = | ||
345 | { | ||
346 | { 0x1E8480, 0x7A1200, 0x2160EC0, 0x3938700, 0 }, | ||
347 | { 0x7D, 0x7D, 0x4E4, 0xB00, 0 }, | ||
348 | 0x5, | ||
349 | 0xAFC8, | ||
350 | 0x64, | ||
351 | 0x32, | ||
352 | 1, | ||
353 | 0, | ||
354 | 0x10, | ||
355 | { 0x78, 0x7C, 0x82, 0x88, 0x8E, 0x94, 0x9A, 0xA0, 0xA6, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC, 0xC0, 0xC4 }, | ||
356 | { 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700 }, | ||
357 | { 0x2AF8, 0x2AF8, 0x29BB, 0x27F9, 0x2637, 0x2475, 0x22B3, 0x20F1, 0x1F2F, 0x1D6D, 0x1734, 0x1414, 0x10F4, 0xDD4, 0xAB4, 0x794 }, | ||
358 | 85, | ||
359 | true | ||
360 | }; | ||
361 | #endif | ||
362 | |||
363 | static const struct si_dte_data dte_data_tahiti_pro = | ||
364 | { | ||
365 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
366 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
367 | 5, | ||
368 | 45000, | ||
369 | 100, | ||
370 | 0xA, | ||
371 | 1, | ||
372 | 0, | ||
373 | 0x10, | ||
374 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
375 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
376 | { 0x7D0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
377 | 90, | ||
378 | true | ||
379 | }; | ||
380 | |||
381 | static const struct si_dte_data dte_data_new_zealand = | ||
382 | { | ||
383 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0 }, | ||
384 | { 0x29B, 0x3E9, 0x537, 0x7D2, 0 }, | ||
385 | 0x5, | ||
386 | 0xAFC8, | ||
387 | 0x69, | ||
388 | 0x32, | ||
389 | 1, | ||
390 | 0, | ||
391 | 0x10, | ||
392 | { 0x82, 0xA0, 0xB4, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE }, | ||
393 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
394 | { 0xDAC, 0x1388, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685 }, | ||
395 | 85, | ||
396 | true | ||
397 | }; | ||
398 | |||
399 | static const struct si_dte_data dte_data_aruba_pro = | ||
400 | { | ||
401 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
402 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
403 | 5, | ||
404 | 45000, | ||
405 | 100, | ||
406 | 0xA, | ||
407 | 1, | ||
408 | 0, | ||
409 | 0x10, | ||
410 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
411 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
412 | { 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
413 | 90, | ||
414 | true | ||
415 | }; | ||
416 | |||
417 | static const struct si_dte_data dte_data_malta = | ||
418 | { | ||
419 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
420 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
421 | 5, | ||
422 | 45000, | ||
423 | 100, | ||
424 | 0xA, | ||
425 | 1, | ||
426 | 0, | ||
427 | 0x10, | ||
428 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
429 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
430 | { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
431 | 90, | ||
432 | true | ||
433 | }; | ||
434 | |||
435 | static const struct si_cac_config_reg cac_weights_pitcairn[] = | ||
436 | { | ||
437 | { 0x0, 0x0000ffff, 0, 0x8a, SISLANDS_CACCONFIG_CGIND }, | ||
438 | { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
439 | { 0x1, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
440 | { 0x1, 0xffff0000, 16, 0x24d, SISLANDS_CACCONFIG_CGIND }, | ||
441 | { 0x2, 0x0000ffff, 0, 0x19, SISLANDS_CACCONFIG_CGIND }, | ||
442 | { 0x3, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
443 | { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
444 | { 0x4, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND }, | ||
445 | { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
446 | { 0x5, 0x0000ffff, 0, 0xc11, SISLANDS_CACCONFIG_CGIND }, | ||
447 | { 0x5, 0xffff0000, 16, 0x7f3, SISLANDS_CACCONFIG_CGIND }, | ||
448 | { 0x6, 0x0000ffff, 0, 0x403, SISLANDS_CACCONFIG_CGIND }, | ||
449 | { 0x6, 0xffff0000, 16, 0x367, SISLANDS_CACCONFIG_CGIND }, | ||
450 | { 0x18f, 0x0000ffff, 0, 0x4c9, SISLANDS_CACCONFIG_CGIND }, | ||
451 | { 0x7, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
452 | { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
453 | { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
454 | { 0x8, 0xffff0000, 16, 0x45d, SISLANDS_CACCONFIG_CGIND }, | ||
455 | { 0x9, 0x0000ffff, 0, 0x36d, SISLANDS_CACCONFIG_CGIND }, | ||
456 | { 0xa, 0x0000ffff, 0, 0x534, SISLANDS_CACCONFIG_CGIND }, | ||
457 | { 0xb, 0x0000ffff, 0, 0x5da, SISLANDS_CACCONFIG_CGIND }, | ||
458 | { 0xb, 0xffff0000, 16, 0x880, SISLANDS_CACCONFIG_CGIND }, | ||
459 | { 0xc, 0x0000ffff, 0, 0x201, SISLANDS_CACCONFIG_CGIND }, | ||
460 | { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
461 | { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
462 | { 0xe, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND }, | ||
463 | { 0xf, 0x0000ffff, 0, 0x1f, SISLANDS_CACCONFIG_CGIND }, | ||
464 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
465 | { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
466 | { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
467 | { 0x11, 0x0000ffff, 0, 0x5de, SISLANDS_CACCONFIG_CGIND }, | ||
468 | { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
469 | { 0x12, 0x0000ffff, 0, 0x7b, SISLANDS_CACCONFIG_CGIND }, | ||
470 | { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
471 | { 0x13, 0xffff0000, 16, 0x13, SISLANDS_CACCONFIG_CGIND }, | ||
472 | { 0x14, 0x0000ffff, 0, 0xf9, SISLANDS_CACCONFIG_CGIND }, | ||
473 | { 0x15, 0x0000ffff, 0, 0x66, SISLANDS_CACCONFIG_CGIND }, | ||
474 | { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
475 | { 0x4e, 0x0000ffff, 0, 0x13, SISLANDS_CACCONFIG_CGIND }, | ||
476 | { 0x16, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
477 | { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
478 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
479 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
480 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
481 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
482 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
483 | { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
484 | { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
485 | { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
486 | { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
487 | { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
488 | { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
489 | { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
490 | { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
491 | { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
492 | { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
493 | { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
494 | { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
495 | { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
496 | { 0x6d, 0x0000ffff, 0, 0x186, SISLANDS_CACCONFIG_CGIND }, | ||
497 | { 0xFFFFFFFF } | ||
498 | }; | ||
499 | |||
500 | static const struct si_cac_config_reg lcac_pitcairn[] = | ||
501 | { | ||
502 | { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
503 | { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
504 | { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
505 | { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
506 | { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
507 | { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
508 | { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
509 | { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
510 | { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
511 | { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
512 | { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
513 | { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
514 | { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
515 | { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
516 | { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
517 | { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
518 | { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
519 | { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
520 | { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
521 | { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
522 | { 0x8f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
523 | { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
524 | { 0x146, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
525 | { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
526 | { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
527 | { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
528 | { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
529 | { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
530 | { 0x116, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
531 | { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
532 | { 0x155, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
533 | { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
534 | { 0x92, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
535 | { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
536 | { 0x149, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
537 | { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
538 | { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
539 | { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
540 | { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
541 | { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
542 | { 0x119, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
543 | { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
544 | { 0x158, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
545 | { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
546 | { 0x95, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
547 | { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
548 | { 0x14c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
549 | { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
550 | { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
551 | { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
552 | { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
553 | { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
554 | { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
555 | { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
556 | { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
557 | { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
558 | { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
559 | { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
560 | { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
561 | { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
562 | { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
563 | { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
564 | { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
565 | { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
566 | { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
567 | { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
568 | { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
569 | { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
570 | { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
571 | { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
572 | { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
573 | { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
574 | { 0x16d, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
575 | { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
576 | { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
577 | { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
578 | { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
579 | { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
580 | { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
581 | { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
582 | { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
583 | { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
584 | { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
585 | { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
586 | { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
587 | { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
588 | { 0xFFFFFFFF } | ||
589 | }; | ||
590 | |||
591 | static const struct si_cac_config_reg cac_override_pitcairn[] = | ||
592 | { | ||
593 | { 0xFFFFFFFF } | ||
594 | }; | ||
595 | |||
596 | static const struct si_powertune_data powertune_data_pitcairn = | ||
597 | { | ||
598 | ((1 << 16) | 27027), | ||
599 | 5, | ||
600 | 0, | ||
601 | 6, | ||
602 | 100, | ||
603 | { | ||
604 | 51600000UL, | ||
605 | 1800000UL, | ||
606 | 7194395UL, | ||
607 | 309631529UL, | ||
608 | -1270850L, | ||
609 | 4513710L, | ||
610 | 100 | ||
611 | }, | ||
612 | 117830498UL, | ||
613 | 12, | ||
614 | { | ||
615 | 0, | ||
616 | 0, | ||
617 | 0, | ||
618 | 0, | ||
619 | 0, | ||
620 | 0, | ||
621 | 0, | ||
622 | 0 | ||
623 | }, | ||
624 | true | ||
625 | }; | ||
626 | |||
627 | static const struct si_dte_data dte_data_pitcairn = | ||
628 | { | ||
629 | { 0, 0, 0, 0, 0 }, | ||
630 | { 0, 0, 0, 0, 0 }, | ||
631 | 0, | ||
632 | 0, | ||
633 | 0, | ||
634 | 0, | ||
635 | 0, | ||
636 | 0, | ||
637 | 0, | ||
638 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
639 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
640 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
641 | 0, | ||
642 | false | ||
643 | }; | ||
644 | |||
645 | static const struct si_dte_data dte_data_curacao_xt = | ||
646 | { | ||
647 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
648 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
649 | 5, | ||
650 | 45000, | ||
651 | 100, | ||
652 | 0xA, | ||
653 | 1, | ||
654 | 0, | ||
655 | 0x10, | ||
656 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
657 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
658 | { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
659 | 90, | ||
660 | true | ||
661 | }; | ||
662 | |||
663 | static const struct si_dte_data dte_data_curacao_pro = | ||
664 | { | ||
665 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
666 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
667 | 5, | ||
668 | 45000, | ||
669 | 100, | ||
670 | 0xA, | ||
671 | 1, | ||
672 | 0, | ||
673 | 0x10, | ||
674 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
675 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
676 | { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
677 | 90, | ||
678 | true | ||
679 | }; | ||
680 | |||
681 | static const struct si_dte_data dte_data_neptune_xt = | ||
682 | { | ||
683 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
684 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
685 | 5, | ||
686 | 45000, | ||
687 | 100, | ||
688 | 0xA, | ||
689 | 1, | ||
690 | 0, | ||
691 | 0x10, | ||
692 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
693 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
694 | { 0x3A2F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
695 | 90, | ||
696 | true | ||
697 | }; | ||
698 | |||
699 | static const struct si_cac_config_reg cac_weights_chelsea_pro[] = | ||
700 | { | ||
701 | { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND }, | ||
702 | { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
703 | { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND }, | ||
704 | { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND }, | ||
705 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
706 | { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
707 | { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
708 | { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
709 | { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND }, | ||
710 | { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
711 | { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND }, | ||
712 | { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND }, | ||
713 | { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND }, | ||
714 | { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
715 | { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND }, | ||
716 | { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND }, | ||
717 | { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND }, | ||
718 | { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
719 | { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND }, | ||
720 | { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND }, | ||
721 | { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND }, | ||
722 | { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND }, | ||
723 | { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND }, | ||
724 | { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
725 | { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
726 | { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
727 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
728 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
729 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
730 | { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
731 | { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
732 | { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
733 | { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND }, | ||
734 | { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
735 | { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
736 | { 0x14, 0x0000ffff, 0, 0x2BD, SISLANDS_CACCONFIG_CGIND }, | ||
737 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
738 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
739 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
740 | { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
741 | { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND }, | ||
742 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
743 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
744 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
745 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
746 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
747 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
748 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
749 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
750 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
751 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
752 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
753 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
754 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
755 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
756 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
757 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
758 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
759 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
760 | { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND }, | ||
761 | { 0xFFFFFFFF } | ||
762 | }; | ||
763 | |||
764 | static const struct si_cac_config_reg cac_weights_chelsea_xt[] = | ||
765 | { | ||
766 | { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND }, | ||
767 | { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
768 | { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND }, | ||
769 | { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND }, | ||
770 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
771 | { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
772 | { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
773 | { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
774 | { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND }, | ||
775 | { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
776 | { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND }, | ||
777 | { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND }, | ||
778 | { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND }, | ||
779 | { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
780 | { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND }, | ||
781 | { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND }, | ||
782 | { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND }, | ||
783 | { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
784 | { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND }, | ||
785 | { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND }, | ||
786 | { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND }, | ||
787 | { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND }, | ||
788 | { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND }, | ||
789 | { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
790 | { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
791 | { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
792 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
793 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
794 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
795 | { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
796 | { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
797 | { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
798 | { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND }, | ||
799 | { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
800 | { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
801 | { 0x14, 0x0000ffff, 0, 0x30A, SISLANDS_CACCONFIG_CGIND }, | ||
802 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
803 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
804 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
805 | { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
806 | { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND }, | ||
807 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
808 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
809 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
810 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
811 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
812 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
813 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
814 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
815 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
816 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
817 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
818 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
819 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
820 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
821 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
822 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
823 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
824 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
825 | { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND }, | ||
826 | { 0xFFFFFFFF } | ||
827 | }; | ||
828 | |||
829 | static const struct si_cac_config_reg cac_weights_heathrow[] = | ||
830 | { | ||
831 | { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND }, | ||
832 | { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
833 | { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND }, | ||
834 | { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND }, | ||
835 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
836 | { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
837 | { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
838 | { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
839 | { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND }, | ||
840 | { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
841 | { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND }, | ||
842 | { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND }, | ||
843 | { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND }, | ||
844 | { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
845 | { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND }, | ||
846 | { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND }, | ||
847 | { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND }, | ||
848 | { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
849 | { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND }, | ||
850 | { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND }, | ||
851 | { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND }, | ||
852 | { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND }, | ||
853 | { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND }, | ||
854 | { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
855 | { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
856 | { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
857 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
858 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
859 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
860 | { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
861 | { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
862 | { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
863 | { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND }, | ||
864 | { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
865 | { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
866 | { 0x14, 0x0000ffff, 0, 0x362, SISLANDS_CACCONFIG_CGIND }, | ||
867 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
868 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
869 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
870 | { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
871 | { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND }, | ||
872 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
873 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
874 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
875 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
876 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
877 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
878 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
879 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
880 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
881 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
882 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
883 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
884 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
885 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
886 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
887 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
888 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
889 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
890 | { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND }, | ||
891 | { 0xFFFFFFFF } | ||
892 | }; | ||
893 | |||
894 | static const struct si_cac_config_reg cac_weights_cape_verde_pro[] = | ||
895 | { | ||
896 | { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND }, | ||
897 | { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
898 | { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND }, | ||
899 | { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND }, | ||
900 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
901 | { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
902 | { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
903 | { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
904 | { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND }, | ||
905 | { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
906 | { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND }, | ||
907 | { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND }, | ||
908 | { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND }, | ||
909 | { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
910 | { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND }, | ||
911 | { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND }, | ||
912 | { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND }, | ||
913 | { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
914 | { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND }, | ||
915 | { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND }, | ||
916 | { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND }, | ||
917 | { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND }, | ||
918 | { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND }, | ||
919 | { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
920 | { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
921 | { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
922 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
923 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
924 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
925 | { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
926 | { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
927 | { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
928 | { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND }, | ||
929 | { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
930 | { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
931 | { 0x14, 0x0000ffff, 0, 0x315, SISLANDS_CACCONFIG_CGIND }, | ||
932 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
933 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
934 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
935 | { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
936 | { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND }, | ||
937 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
938 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
939 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
940 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
941 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
942 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
943 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
944 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
945 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
946 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
947 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
948 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
949 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
950 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
951 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
952 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
953 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
954 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
955 | { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND }, | ||
956 | { 0xFFFFFFFF } | ||
957 | }; | ||
958 | |||
959 | static const struct si_cac_config_reg cac_weights_cape_verde[] = | ||
960 | { | ||
961 | { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND }, | ||
962 | { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
963 | { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND }, | ||
964 | { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND }, | ||
965 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
966 | { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
967 | { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
968 | { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
969 | { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND }, | ||
970 | { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
971 | { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND }, | ||
972 | { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND }, | ||
973 | { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND }, | ||
974 | { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
975 | { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND }, | ||
976 | { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND }, | ||
977 | { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND }, | ||
978 | { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
979 | { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND }, | ||
980 | { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND }, | ||
981 | { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND }, | ||
982 | { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND }, | ||
983 | { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND }, | ||
984 | { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
985 | { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
986 | { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
987 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
988 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
989 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
990 | { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
991 | { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
992 | { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
993 | { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND }, | ||
994 | { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
995 | { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
996 | { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND }, | ||
997 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
998 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
999 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1000 | { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
1001 | { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND }, | ||
1002 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1003 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1004 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1005 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1006 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1007 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1008 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1009 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1010 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1011 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1012 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1013 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1014 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1015 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1016 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1017 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1018 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1019 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1020 | { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND }, | ||
1021 | { 0xFFFFFFFF } | ||
1022 | }; | ||
1023 | |||
1024 | static const struct si_cac_config_reg lcac_cape_verde[] = | ||
1025 | { | ||
1026 | { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1027 | { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1028 | { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1029 | { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1030 | { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1031 | { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1032 | { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1033 | { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1034 | { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1035 | { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1036 | { 0x143, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1037 | { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1038 | { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1039 | { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1040 | { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1041 | { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1042 | { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1043 | { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1044 | { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1045 | { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1046 | { 0x8f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1047 | { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1048 | { 0x146, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1049 | { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1050 | { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1051 | { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1052 | { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1053 | { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1054 | { 0x164, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1055 | { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1056 | { 0x167, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1057 | { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1058 | { 0x16a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1059 | { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1060 | { 0x15e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1061 | { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1062 | { 0x161, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1063 | { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1064 | { 0x15b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1065 | { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1066 | { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1067 | { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1068 | { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1069 | { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1070 | { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1071 | { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1072 | { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1073 | { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1074 | { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1075 | { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1076 | { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1077 | { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1078 | { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1079 | { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1080 | { 0xFFFFFFFF } | ||
1081 | }; | ||
1082 | |||
1083 | static const struct si_cac_config_reg cac_override_cape_verde[] = | ||
1084 | { | ||
1085 | { 0xFFFFFFFF } | ||
1086 | }; | ||
1087 | |||
1088 | static const struct si_powertune_data powertune_data_cape_verde = | ||
1089 | { | ||
1090 | ((1 << 16) | 0x6993), | ||
1091 | 5, | ||
1092 | 0, | ||
1093 | 7, | ||
1094 | 105, | ||
1095 | { | ||
1096 | 0UL, | ||
1097 | 0UL, | ||
1098 | 7194395UL, | ||
1099 | 309631529UL, | ||
1100 | -1270850L, | ||
1101 | 4513710L, | ||
1102 | 100 | ||
1103 | }, | ||
1104 | 117830498UL, | ||
1105 | 12, | ||
1106 | { | ||
1107 | 0, | ||
1108 | 0, | ||
1109 | 0, | ||
1110 | 0, | ||
1111 | 0, | ||
1112 | 0, | ||
1113 | 0, | ||
1114 | 0 | ||
1115 | }, | ||
1116 | true | ||
1117 | }; | ||
1118 | |||
1119 | static const struct si_dte_data dte_data_cape_verde = | ||
1120 | { | ||
1121 | { 0, 0, 0, 0, 0 }, | ||
1122 | { 0, 0, 0, 0, 0 }, | ||
1123 | 0, | ||
1124 | 0, | ||
1125 | 0, | ||
1126 | 0, | ||
1127 | 0, | ||
1128 | 0, | ||
1129 | 0, | ||
1130 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
1131 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
1132 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
1133 | 0, | ||
1134 | false | ||
1135 | }; | ||
1136 | |||
1137 | static const struct si_dte_data dte_data_venus_xtx = | ||
1138 | { | ||
1139 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
1140 | { 0x71C, 0xAAB, 0xE39, 0x11C7, 0x0 }, | ||
1141 | 5, | ||
1142 | 55000, | ||
1143 | 0x69, | ||
1144 | 0xA, | ||
1145 | 1, | ||
1146 | 0, | ||
1147 | 0x3, | ||
1148 | { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1149 | { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1150 | { 0xD6D8, 0x88B8, 0x1555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1151 | 90, | ||
1152 | true | ||
1153 | }; | ||
1154 | |||
1155 | static const struct si_dte_data dte_data_venus_xt = | ||
1156 | { | ||
1157 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
1158 | { 0xBDA, 0x11C7, 0x17B4, 0x1DA1, 0x0 }, | ||
1159 | 5, | ||
1160 | 55000, | ||
1161 | 0x69, | ||
1162 | 0xA, | ||
1163 | 1, | ||
1164 | 0, | ||
1165 | 0x3, | ||
1166 | { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1167 | { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1168 | { 0xAFC8, 0x88B8, 0x238E, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1169 | 90, | ||
1170 | true | ||
1171 | }; | ||
1172 | |||
1173 | static const struct si_dte_data dte_data_venus_pro = | ||
1174 | { | ||
1175 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
1176 | { 0x11C7, 0x1AAB, 0x238E, 0x2C72, 0x0 }, | ||
1177 | 5, | ||
1178 | 55000, | ||
1179 | 0x69, | ||
1180 | 0xA, | ||
1181 | 1, | ||
1182 | 0, | ||
1183 | 0x3, | ||
1184 | { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1185 | { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1186 | { 0x88B8, 0x88B8, 0x3555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1187 | 90, | ||
1188 | true | ||
1189 | }; | ||
1190 | |||
1191 | static const struct si_cac_config_reg cac_weights_oland[] = | ||
1192 | { | ||
1193 | { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND }, | ||
1194 | { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
1195 | { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND }, | ||
1196 | { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND }, | ||
1197 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1198 | { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
1199 | { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND }, | ||
1200 | { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND }, | ||
1201 | { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND }, | ||
1202 | { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND }, | ||
1203 | { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND }, | ||
1204 | { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND }, | ||
1205 | { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND }, | ||
1206 | { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
1207 | { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND }, | ||
1208 | { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND }, | ||
1209 | { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND }, | ||
1210 | { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND }, | ||
1211 | { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND }, | ||
1212 | { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND }, | ||
1213 | { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND }, | ||
1214 | { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND }, | ||
1215 | { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND }, | ||
1216 | { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
1217 | { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND }, | ||
1218 | { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1219 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
1220 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1221 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1222 | { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1223 | { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1224 | { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
1225 | { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND }, | ||
1226 | { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1227 | { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1228 | { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND }, | ||
1229 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1230 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1231 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1232 | { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND }, | ||
1233 | { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND }, | ||
1234 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1235 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1236 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1237 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1238 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1239 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1240 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1241 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1242 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1243 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1244 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1245 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1246 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1247 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1248 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1249 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1250 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1251 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1252 | { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND }, | ||
1253 | { 0xFFFFFFFF } | ||
1254 | }; | ||
1255 | |||
1256 | static const struct si_cac_config_reg cac_weights_mars_pro[] = | ||
1257 | { | ||
1258 | { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND }, | ||
1259 | { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1260 | { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND }, | ||
1261 | { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND }, | ||
1262 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1263 | { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1264 | { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1265 | { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1266 | { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND }, | ||
1267 | { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND }, | ||
1268 | { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND }, | ||
1269 | { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND }, | ||
1270 | { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND }, | ||
1271 | { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND }, | ||
1272 | { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND }, | ||
1273 | { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND }, | ||
1274 | { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND }, | ||
1275 | { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1276 | { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND }, | ||
1277 | { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND }, | ||
1278 | { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND }, | ||
1279 | { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND }, | ||
1280 | { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND }, | ||
1281 | { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1282 | { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1283 | { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND }, | ||
1284 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
1285 | { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1286 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1287 | { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1288 | { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
1289 | { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1290 | { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1291 | { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1292 | { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1293 | { 0x14, 0x0000ffff, 0, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1294 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1295 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1296 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1297 | { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND }, | ||
1298 | { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND }, | ||
1299 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1300 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1301 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1302 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1303 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1304 | { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND }, | ||
1305 | { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1306 | { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1307 | { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1308 | { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND }, | ||
1309 | { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND }, | ||
1310 | { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1311 | { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1312 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1313 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1314 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1315 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1316 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1317 | { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND }, | ||
1318 | { 0xFFFFFFFF } | ||
1319 | }; | ||
1320 | |||
1321 | static const struct si_cac_config_reg cac_weights_mars_xt[] = | ||
1322 | { | ||
1323 | { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND }, | ||
1324 | { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1325 | { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND }, | ||
1326 | { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND }, | ||
1327 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1328 | { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1329 | { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1330 | { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1331 | { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND }, | ||
1332 | { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND }, | ||
1333 | { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND }, | ||
1334 | { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND }, | ||
1335 | { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND }, | ||
1336 | { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND }, | ||
1337 | { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND }, | ||
1338 | { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND }, | ||
1339 | { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND }, | ||
1340 | { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1341 | { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND }, | ||
1342 | { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND }, | ||
1343 | { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND }, | ||
1344 | { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND }, | ||
1345 | { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND }, | ||
1346 | { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1347 | { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1348 | { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND }, | ||
1349 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
1350 | { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1351 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1352 | { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1353 | { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
1354 | { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1355 | { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1356 | { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1357 | { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1358 | { 0x14, 0x0000ffff, 0, 0x60, SISLANDS_CACCONFIG_CGIND }, | ||
1359 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1360 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1361 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1362 | { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND }, | ||
1363 | { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND }, | ||
1364 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1365 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1366 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1367 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1368 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1369 | { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND }, | ||
1370 | { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1371 | { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1372 | { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1373 | { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND }, | ||
1374 | { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND }, | ||
1375 | { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1376 | { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1377 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1378 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1379 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1380 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1381 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1382 | { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND }, | ||
1383 | { 0xFFFFFFFF } | ||
1384 | }; | ||
1385 | |||
1386 | static const struct si_cac_config_reg cac_weights_oland_pro[] = | ||
1387 | { | ||
1388 | { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND }, | ||
1389 | { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1390 | { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND }, | ||
1391 | { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND }, | ||
1392 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1393 | { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1394 | { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1395 | { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1396 | { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND }, | ||
1397 | { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND }, | ||
1398 | { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND }, | ||
1399 | { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND }, | ||
1400 | { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND }, | ||
1401 | { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND }, | ||
1402 | { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND }, | ||
1403 | { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND }, | ||
1404 | { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND }, | ||
1405 | { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1406 | { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND }, | ||
1407 | { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND }, | ||
1408 | { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND }, | ||
1409 | { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND }, | ||
1410 | { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND }, | ||
1411 | { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1412 | { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1413 | { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND }, | ||
1414 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
1415 | { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1416 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1417 | { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1418 | { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
1419 | { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1420 | { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1421 | { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1422 | { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1423 | { 0x14, 0x0000ffff, 0, 0x90, SISLANDS_CACCONFIG_CGIND }, | ||
1424 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1425 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1426 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1427 | { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND }, | ||
1428 | { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND }, | ||
1429 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1430 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1431 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1432 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1433 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1434 | { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND }, | ||
1435 | { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1436 | { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1437 | { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1438 | { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND }, | ||
1439 | { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND }, | ||
1440 | { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1441 | { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1442 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1443 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1444 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1445 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1446 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1447 | { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND }, | ||
1448 | { 0xFFFFFFFF } | ||
1449 | }; | ||
1450 | |||
1451 | static const struct si_cac_config_reg cac_weights_oland_xt[] = | ||
1452 | { | ||
1453 | { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND }, | ||
1454 | { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1455 | { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND }, | ||
1456 | { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND }, | ||
1457 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1458 | { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1459 | { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND }, | ||
1460 | { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND }, | ||
1461 | { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND }, | ||
1462 | { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND }, | ||
1463 | { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND }, | ||
1464 | { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND }, | ||
1465 | { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND }, | ||
1466 | { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND }, | ||
1467 | { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND }, | ||
1468 | { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND }, | ||
1469 | { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND }, | ||
1470 | { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1471 | { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND }, | ||
1472 | { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND }, | ||
1473 | { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND }, | ||
1474 | { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND }, | ||
1475 | { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND }, | ||
1476 | { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1477 | { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND }, | ||
1478 | { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND }, | ||
1479 | { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND }, | ||
1480 | { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1481 | { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1482 | { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1483 | { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND }, | ||
1484 | { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1485 | { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND }, | ||
1486 | { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1487 | { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND }, | ||
1488 | { 0x14, 0x0000ffff, 0, 0x120, SISLANDS_CACCONFIG_CGIND }, | ||
1489 | { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1490 | { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1491 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1492 | { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND }, | ||
1493 | { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND }, | ||
1494 | { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1495 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1496 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1497 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1498 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1499 | { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND }, | ||
1500 | { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND }, | ||
1501 | { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1502 | { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1503 | { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND }, | ||
1504 | { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND }, | ||
1505 | { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1506 | { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1507 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1508 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1509 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1510 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1511 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1512 | { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND }, | ||
1513 | { 0xFFFFFFFF } | ||
1514 | }; | ||
1515 | |||
1516 | static const struct si_cac_config_reg lcac_oland[] = | ||
1517 | { | ||
1518 | { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1519 | { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1520 | { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1521 | { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1522 | { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1523 | { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1524 | { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1525 | { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1526 | { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1527 | { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1528 | { 0x143, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND }, | ||
1529 | { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1530 | { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1531 | { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1532 | { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1533 | { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1534 | { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1535 | { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1536 | { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1537 | { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1538 | { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1539 | { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1540 | { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1541 | { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1542 | { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1543 | { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1544 | { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1545 | { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1546 | { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1547 | { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1548 | { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1549 | { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1550 | { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1551 | { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1552 | { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1553 | { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1554 | { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1555 | { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1556 | { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1557 | { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1558 | { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1559 | { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1560 | { 0xFFFFFFFF } | ||
1561 | }; | ||
1562 | |||
1563 | static const struct si_cac_config_reg lcac_mars_pro[] = | ||
1564 | { | ||
1565 | { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1566 | { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1567 | { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1568 | { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1569 | { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1570 | { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1571 | { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1572 | { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1573 | { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND }, | ||
1574 | { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1575 | { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1576 | { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1577 | { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1578 | { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1579 | { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1580 | { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1581 | { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1582 | { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1583 | { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1584 | { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1585 | { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1586 | { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1587 | { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1588 | { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1589 | { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1590 | { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1591 | { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1592 | { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1593 | { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND }, | ||
1594 | { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1595 | { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1596 | { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1597 | { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1598 | { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1599 | { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1600 | { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1601 | { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1602 | { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1603 | { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1604 | { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1605 | { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1606 | { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND }, | ||
1607 | { 0xFFFFFFFF } | ||
1608 | }; | ||
1609 | |||
1610 | static const struct si_cac_config_reg cac_override_oland[] = | ||
1611 | { | ||
1612 | { 0xFFFFFFFF } | ||
1613 | }; | ||
1614 | |||
1615 | static const struct si_powertune_data powertune_data_oland = | ||
1616 | { | ||
1617 | ((1 << 16) | 0x6993), | ||
1618 | 5, | ||
1619 | 0, | ||
1620 | 7, | ||
1621 | 105, | ||
1622 | { | ||
1623 | 0UL, | ||
1624 | 0UL, | ||
1625 | 7194395UL, | ||
1626 | 309631529UL, | ||
1627 | -1270850L, | ||
1628 | 4513710L, | ||
1629 | 100 | ||
1630 | }, | ||
1631 | 117830498UL, | ||
1632 | 12, | ||
1633 | { | ||
1634 | 0, | ||
1635 | 0, | ||
1636 | 0, | ||
1637 | 0, | ||
1638 | 0, | ||
1639 | 0, | ||
1640 | 0, | ||
1641 | 0 | ||
1642 | }, | ||
1643 | true | ||
1644 | }; | ||
1645 | |||
1646 | static const struct si_powertune_data powertune_data_mars_pro = | ||
1647 | { | ||
1648 | ((1 << 16) | 0x6993), | ||
1649 | 5, | ||
1650 | 0, | ||
1651 | 7, | ||
1652 | 105, | ||
1653 | { | ||
1654 | 0UL, | ||
1655 | 0UL, | ||
1656 | 7194395UL, | ||
1657 | 309631529UL, | ||
1658 | -1270850L, | ||
1659 | 4513710L, | ||
1660 | 100 | ||
1661 | }, | ||
1662 | 117830498UL, | ||
1663 | 12, | ||
1664 | { | ||
1665 | 0, | ||
1666 | 0, | ||
1667 | 0, | ||
1668 | 0, | ||
1669 | 0, | ||
1670 | 0, | ||
1671 | 0, | ||
1672 | 0 | ||
1673 | }, | ||
1674 | true | ||
1675 | }; | ||
1676 | |||
1677 | static const struct si_dte_data dte_data_oland = | ||
1678 | { | ||
1679 | { 0, 0, 0, 0, 0 }, | ||
1680 | { 0, 0, 0, 0, 0 }, | ||
1681 | 0, | ||
1682 | 0, | ||
1683 | 0, | ||
1684 | 0, | ||
1685 | 0, | ||
1686 | 0, | ||
1687 | 0, | ||
1688 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
1689 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
1690 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
1691 | 0, | ||
1692 | false | ||
1693 | }; | ||
1694 | |||
1695 | static const struct si_dte_data dte_data_mars_pro = | ||
1696 | { | ||
1697 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
1698 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1699 | 5, | ||
1700 | 55000, | ||
1701 | 105, | ||
1702 | 0xA, | ||
1703 | 1, | ||
1704 | 0, | ||
1705 | 0x10, | ||
1706 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
1707 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
1708 | { 0xF627, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1709 | 90, | ||
1710 | true | ||
1711 | }; | ||
1712 | |||
1713 | static const struct si_dte_data dte_data_sun_xt = | ||
1714 | { | ||
1715 | { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 }, | ||
1716 | { 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1717 | 5, | ||
1718 | 55000, | ||
1719 | 105, | ||
1720 | 0xA, | ||
1721 | 1, | ||
1722 | 0, | ||
1723 | 0x10, | ||
1724 | { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, | ||
1725 | { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 }, | ||
1726 | { 0xD555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, | ||
1727 | 90, | ||
1728 | true | ||
1729 | }; | ||
1730 | |||
1731 | |||
1732 | static const struct si_cac_config_reg cac_weights_hainan[] = | ||
1733 | { | ||
1734 | { 0x0, 0x0000ffff, 0, 0x2d9, SISLANDS_CACCONFIG_CGIND }, | ||
1735 | { 0x0, 0xffff0000, 16, 0x22b, SISLANDS_CACCONFIG_CGIND }, | ||
1736 | { 0x1, 0x0000ffff, 0, 0x21c, SISLANDS_CACCONFIG_CGIND }, | ||
1737 | { 0x1, 0xffff0000, 16, 0x1dc, SISLANDS_CACCONFIG_CGIND }, | ||
1738 | { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1739 | { 0x3, 0x0000ffff, 0, 0x24e, SISLANDS_CACCONFIG_CGIND }, | ||
1740 | { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1741 | { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1742 | { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1743 | { 0x5, 0x0000ffff, 0, 0x35e, SISLANDS_CACCONFIG_CGIND }, | ||
1744 | { 0x5, 0xffff0000, 16, 0x1143, SISLANDS_CACCONFIG_CGIND }, | ||
1745 | { 0x6, 0x0000ffff, 0, 0xe17, SISLANDS_CACCONFIG_CGIND }, | ||
1746 | { 0x6, 0xffff0000, 16, 0x441, SISLANDS_CACCONFIG_CGIND }, | ||
1747 | { 0x18f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1748 | { 0x7, 0x0000ffff, 0, 0x28b, SISLANDS_CACCONFIG_CGIND }, | ||
1749 | { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1750 | { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1751 | { 0x8, 0xffff0000, 16, 0xabe, SISLANDS_CACCONFIG_CGIND }, | ||
1752 | { 0x9, 0x0000ffff, 0, 0xf11, SISLANDS_CACCONFIG_CGIND }, | ||
1753 | { 0xa, 0x0000ffff, 0, 0x907, SISLANDS_CACCONFIG_CGIND }, | ||
1754 | { 0xb, 0x0000ffff, 0, 0xb45, SISLANDS_CACCONFIG_CGIND }, | ||
1755 | { 0xb, 0xffff0000, 16, 0xd1e, SISLANDS_CACCONFIG_CGIND }, | ||
1756 | { 0xc, 0x0000ffff, 0, 0xa2c, SISLANDS_CACCONFIG_CGIND }, | ||
1757 | { 0xd, 0x0000ffff, 0, 0x62, SISLANDS_CACCONFIG_CGIND }, | ||
1758 | { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1759 | { 0xe, 0x0000ffff, 0, 0x1f3, SISLANDS_CACCONFIG_CGIND }, | ||
1760 | { 0xf, 0x0000ffff, 0, 0x42, SISLANDS_CACCONFIG_CGIND }, | ||
1761 | { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1762 | { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1763 | { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1764 | { 0x11, 0x0000ffff, 0, 0x709, SISLANDS_CACCONFIG_CGIND }, | ||
1765 | { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1766 | { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1767 | { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1768 | { 0x13, 0xffff0000, 16, 0x3a, SISLANDS_CACCONFIG_CGIND }, | ||
1769 | { 0x14, 0x0000ffff, 0, 0x357, SISLANDS_CACCONFIG_CGIND }, | ||
1770 | { 0x15, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND }, | ||
1771 | { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1772 | { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1773 | { 0x16, 0x0000ffff, 0, 0x314, SISLANDS_CACCONFIG_CGIND }, | ||
1774 | { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1775 | { 0x17, 0x0000ffff, 0, 0x6d, SISLANDS_CACCONFIG_CGIND }, | ||
1776 | { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1777 | { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1778 | { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1779 | { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND }, | ||
1780 | { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1781 | { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1782 | { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1783 | { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1784 | { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1785 | { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1786 | { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1787 | { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1788 | { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1789 | { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1790 | { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1791 | { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1792 | { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND }, | ||
1793 | { 0x6d, 0x0000ffff, 0, 0x1b9, SISLANDS_CACCONFIG_CGIND }, | ||
1794 | { 0xFFFFFFFF } | ||
1795 | }; | ||
1796 | |||
1797 | static const struct si_powertune_data powertune_data_hainan = | ||
1798 | { | ||
1799 | ((1 << 16) | 0x6993), | ||
1800 | 5, | ||
1801 | 0, | ||
1802 | 9, | ||
1803 | 105, | ||
1804 | { | ||
1805 | 0UL, | ||
1806 | 0UL, | ||
1807 | 7194395UL, | ||
1808 | 309631529UL, | ||
1809 | -1270850L, | ||
1810 | 4513710L, | ||
1811 | 100 | ||
1812 | }, | ||
1813 | 117830498UL, | ||
1814 | 12, | ||
1815 | { | ||
1816 | 0, | ||
1817 | 0, | ||
1818 | 0, | ||
1819 | 0, | ||
1820 | 0, | ||
1821 | 0, | ||
1822 | 0, | ||
1823 | 0 | ||
1824 | }, | ||
1825 | true | ||
1826 | }; | ||
1827 | |||
1828 | static struct rv7xx_power_info *rv770_get_pi(struct amdgpu_device *adev); | ||
1829 | static struct evergreen_power_info *evergreen_get_pi(struct amdgpu_device *adev); | ||
1830 | static struct ni_power_info *ni_get_pi(struct amdgpu_device *adev); | ||
1831 | static struct si_ps *si_get_ps(struct amdgpu_ps *rps); | ||
1832 | |||
1833 | static int si_populate_voltage_value(struct amdgpu_device *adev, | ||
1834 | const struct atom_voltage_table *table, | ||
1835 | u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage); | ||
1836 | static int si_get_std_voltage_value(struct amdgpu_device *adev, | ||
1837 | SISLANDS_SMC_VOLTAGE_VALUE *voltage, | ||
1838 | u16 *std_voltage); | ||
1839 | static int si_write_smc_soft_register(struct amdgpu_device *adev, | ||
1840 | u16 reg_offset, u32 value); | ||
1841 | static int si_convert_power_level_to_smc(struct amdgpu_device *adev, | ||
1842 | struct rv7xx_pl *pl, | ||
1843 | SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level); | ||
1844 | static int si_calculate_sclk_params(struct amdgpu_device *adev, | ||
1845 | u32 engine_clock, | ||
1846 | SISLANDS_SMC_SCLK_VALUE *sclk); | ||
1847 | |||
1848 | static void si_thermal_start_smc_fan_control(struct amdgpu_device *adev); | ||
1849 | static void si_fan_ctrl_set_default_mode(struct amdgpu_device *adev); | ||
1850 | static void si_dpm_set_dpm_funcs(struct amdgpu_device *adev); | ||
1851 | static void si_dpm_set_irq_funcs(struct amdgpu_device *adev); | ||
1852 | |||
1853 | static struct si_power_info *si_get_pi(struct amdgpu_device *adev) | ||
1854 | { | ||
1855 | struct si_power_info *pi = adev->pm.dpm.priv; | ||
1856 | return pi; | ||
1857 | } | ||
1858 | |||
1859 | static void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients *coeff, | ||
1860 | u16 v, s32 t, u32 ileakage, u32 *leakage) | ||
1861 | { | ||
1862 | s64 kt, kv, leakage_w, i_leakage, vddc; | ||
1863 | s64 temperature, t_slope, t_intercept, av, bv, t_ref; | ||
1864 | s64 tmp; | ||
1865 | |||
1866 | i_leakage = div64_s64(drm_int2fixp(ileakage), 100); | ||
1867 | vddc = div64_s64(drm_int2fixp(v), 1000); | ||
1868 | temperature = div64_s64(drm_int2fixp(t), 1000); | ||
1869 | |||
1870 | t_slope = div64_s64(drm_int2fixp(coeff->t_slope), 100000000); | ||
1871 | t_intercept = div64_s64(drm_int2fixp(coeff->t_intercept), 100000000); | ||
1872 | av = div64_s64(drm_int2fixp(coeff->av), 100000000); | ||
1873 | bv = div64_s64(drm_int2fixp(coeff->bv), 100000000); | ||
1874 | t_ref = drm_int2fixp(coeff->t_ref); | ||
1875 | |||
1876 | tmp = drm_fixp_mul(t_slope, vddc) + t_intercept; | ||
1877 | kt = drm_fixp_exp(drm_fixp_mul(tmp, temperature)); | ||
1878 | kt = drm_fixp_div(kt, drm_fixp_exp(drm_fixp_mul(tmp, t_ref))); | ||
1879 | kv = drm_fixp_mul(av, drm_fixp_exp(drm_fixp_mul(bv, vddc))); | ||
1880 | |||
1881 | leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc); | ||
1882 | |||
1883 | *leakage = drm_fixp2int(leakage_w * 1000); | ||
1884 | } | ||
1885 | |||
1886 | static void si_calculate_leakage_for_v_and_t(struct amdgpu_device *adev, | ||
1887 | const struct ni_leakage_coeffients *coeff, | ||
1888 | u16 v, | ||
1889 | s32 t, | ||
1890 | u32 i_leakage, | ||
1891 | u32 *leakage) | ||
1892 | { | ||
1893 | si_calculate_leakage_for_v_and_t_formula(coeff, v, t, i_leakage, leakage); | ||
1894 | } | ||
1895 | |||
1896 | static void si_calculate_leakage_for_v_formula(const struct ni_leakage_coeffients *coeff, | ||
1897 | const u32 fixed_kt, u16 v, | ||
1898 | u32 ileakage, u32 *leakage) | ||
1899 | { | ||
1900 | s64 kt, kv, leakage_w, i_leakage, vddc; | ||
1901 | |||
1902 | i_leakage = div64_s64(drm_int2fixp(ileakage), 100); | ||
1903 | vddc = div64_s64(drm_int2fixp(v), 1000); | ||
1904 | |||
1905 | kt = div64_s64(drm_int2fixp(fixed_kt), 100000000); | ||
1906 | kv = drm_fixp_mul(div64_s64(drm_int2fixp(coeff->av), 100000000), | ||
1907 | drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff->bv), 100000000), vddc))); | ||
1908 | |||
1909 | leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc); | ||
1910 | |||
1911 | *leakage = drm_fixp2int(leakage_w * 1000); | ||
1912 | } | ||
1913 | |||
1914 | static void si_calculate_leakage_for_v(struct amdgpu_device *adev, | ||
1915 | const struct ni_leakage_coeffients *coeff, | ||
1916 | const u32 fixed_kt, | ||
1917 | u16 v, | ||
1918 | u32 i_leakage, | ||
1919 | u32 *leakage) | ||
1920 | { | ||
1921 | si_calculate_leakage_for_v_formula(coeff, fixed_kt, v, i_leakage, leakage); | ||
1922 | } | ||
1923 | |||
1924 | |||
1925 | static void si_update_dte_from_pl2(struct amdgpu_device *adev, | ||
1926 | struct si_dte_data *dte_data) | ||
1927 | { | ||
1928 | u32 p_limit1 = adev->pm.dpm.tdp_limit; | ||
1929 | u32 p_limit2 = adev->pm.dpm.near_tdp_limit; | ||
1930 | u32 k = dte_data->k; | ||
1931 | u32 t_max = dte_data->max_t; | ||
1932 | u32 t_split[5] = { 10, 15, 20, 25, 30 }; | ||
1933 | u32 t_0 = dte_data->t0; | ||
1934 | u32 i; | ||
1935 | |||
1936 | if (p_limit2 != 0 && p_limit2 <= p_limit1) { | ||
1937 | dte_data->tdep_count = 3; | ||
1938 | |||
1939 | for (i = 0; i < k; i++) { | ||
1940 | dte_data->r[i] = | ||
1941 | (t_split[i] * (t_max - t_0/(u32)1000) * (1 << 14)) / | ||
1942 | (p_limit2 * (u32)100); | ||
1943 | } | ||
1944 | |||
1945 | dte_data->tdep_r[1] = dte_data->r[4] * 2; | ||
1946 | |||
1947 | for (i = 2; i < SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE; i++) { | ||
1948 | dte_data->tdep_r[i] = dte_data->r[4]; | ||
1949 | } | ||
1950 | } else { | ||
1951 | DRM_ERROR("Invalid PL2! DTE will not be updated.\n"); | ||
1952 | } | ||
1953 | } | ||
1954 | |||
1955 | static struct rv7xx_power_info *rv770_get_pi(struct amdgpu_device *adev) | ||
1956 | { | ||
1957 | struct rv7xx_power_info *pi = adev->pm.dpm.priv; | ||
1958 | |||
1959 | return pi; | ||
1960 | } | ||
1961 | |||
1962 | static struct ni_power_info *ni_get_pi(struct amdgpu_device *adev) | ||
1963 | { | ||
1964 | struct ni_power_info *pi = adev->pm.dpm.priv; | ||
1965 | |||
1966 | return pi; | ||
1967 | } | ||
1968 | |||
1969 | static struct si_ps *si_get_ps(struct amdgpu_ps *aps) | ||
1970 | { | ||
1971 | struct si_ps *ps = aps->ps_priv; | ||
1972 | |||
1973 | return ps; | ||
1974 | } | ||
1975 | |||
1976 | static void si_initialize_powertune_defaults(struct amdgpu_device *adev) | ||
1977 | { | ||
1978 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
1979 | struct si_power_info *si_pi = si_get_pi(adev); | ||
1980 | bool update_dte_from_pl2 = false; | ||
1981 | |||
1982 | if (adev->asic_type == CHIP_TAHITI) { | ||
1983 | si_pi->cac_weights = cac_weights_tahiti; | ||
1984 | si_pi->lcac_config = lcac_tahiti; | ||
1985 | si_pi->cac_override = cac_override_tahiti; | ||
1986 | si_pi->powertune_data = &powertune_data_tahiti; | ||
1987 | si_pi->dte_data = dte_data_tahiti; | ||
1988 | |||
1989 | switch (adev->pdev->device) { | ||
1990 | case 0x6798: | ||
1991 | si_pi->dte_data.enable_dte_by_default = true; | ||
1992 | break; | ||
1993 | case 0x6799: | ||
1994 | si_pi->dte_data = dte_data_new_zealand; | ||
1995 | break; | ||
1996 | case 0x6790: | ||
1997 | case 0x6791: | ||
1998 | case 0x6792: | ||
1999 | case 0x679E: | ||
2000 | si_pi->dte_data = dte_data_aruba_pro; | ||
2001 | update_dte_from_pl2 = true; | ||
2002 | break; | ||
2003 | case 0x679B: | ||
2004 | si_pi->dte_data = dte_data_malta; | ||
2005 | update_dte_from_pl2 = true; | ||
2006 | break; | ||
2007 | case 0x679A: | ||
2008 | si_pi->dte_data = dte_data_tahiti_pro; | ||
2009 | update_dte_from_pl2 = true; | ||
2010 | break; | ||
2011 | default: | ||
2012 | if (si_pi->dte_data.enable_dte_by_default == true) | ||
2013 | DRM_ERROR("DTE is not enabled!\n"); | ||
2014 | break; | ||
2015 | } | ||
2016 | } else if (adev->asic_type == CHIP_PITCAIRN) { | ||
2017 | si_pi->cac_weights = cac_weights_pitcairn; | ||
2018 | si_pi->lcac_config = lcac_pitcairn; | ||
2019 | si_pi->cac_override = cac_override_pitcairn; | ||
2020 | si_pi->powertune_data = &powertune_data_pitcairn; | ||
2021 | |||
2022 | switch (adev->pdev->device) { | ||
2023 | case 0x6810: | ||
2024 | case 0x6818: | ||
2025 | si_pi->dte_data = dte_data_curacao_xt; | ||
2026 | update_dte_from_pl2 = true; | ||
2027 | break; | ||
2028 | case 0x6819: | ||
2029 | case 0x6811: | ||
2030 | si_pi->dte_data = dte_data_curacao_pro; | ||
2031 | update_dte_from_pl2 = true; | ||
2032 | break; | ||
2033 | case 0x6800: | ||
2034 | case 0x6806: | ||
2035 | si_pi->dte_data = dte_data_neptune_xt; | ||
2036 | update_dte_from_pl2 = true; | ||
2037 | break; | ||
2038 | default: | ||
2039 | si_pi->dte_data = dte_data_pitcairn; | ||
2040 | break; | ||
2041 | } | ||
2042 | } else if (adev->asic_type == CHIP_VERDE) { | ||
2043 | si_pi->lcac_config = lcac_cape_verde; | ||
2044 | si_pi->cac_override = cac_override_cape_verde; | ||
2045 | si_pi->powertune_data = &powertune_data_cape_verde; | ||
2046 | |||
2047 | switch (adev->pdev->device) { | ||
2048 | case 0x683B: | ||
2049 | case 0x683F: | ||
2050 | case 0x6829: | ||
2051 | case 0x6835: | ||
2052 | si_pi->cac_weights = cac_weights_cape_verde_pro; | ||
2053 | si_pi->dte_data = dte_data_cape_verde; | ||
2054 | break; | ||
2055 | case 0x682C: | ||
2056 | si_pi->cac_weights = cac_weights_cape_verde_pro; | ||
2057 | si_pi->dte_data = dte_data_sun_xt; | ||
2058 | break; | ||
2059 | case 0x6825: | ||
2060 | case 0x6827: | ||
2061 | si_pi->cac_weights = cac_weights_heathrow; | ||
2062 | si_pi->dte_data = dte_data_cape_verde; | ||
2063 | break; | ||
2064 | case 0x6824: | ||
2065 | case 0x682D: | ||
2066 | si_pi->cac_weights = cac_weights_chelsea_xt; | ||
2067 | si_pi->dte_data = dte_data_cape_verde; | ||
2068 | break; | ||
2069 | case 0x682F: | ||
2070 | si_pi->cac_weights = cac_weights_chelsea_pro; | ||
2071 | si_pi->dte_data = dte_data_cape_verde; | ||
2072 | break; | ||
2073 | case 0x6820: | ||
2074 | si_pi->cac_weights = cac_weights_heathrow; | ||
2075 | si_pi->dte_data = dte_data_venus_xtx; | ||
2076 | break; | ||
2077 | case 0x6821: | ||
2078 | si_pi->cac_weights = cac_weights_heathrow; | ||
2079 | si_pi->dte_data = dte_data_venus_xt; | ||
2080 | break; | ||
2081 | case 0x6823: | ||
2082 | case 0x682B: | ||
2083 | case 0x6822: | ||
2084 | case 0x682A: | ||
2085 | si_pi->cac_weights = cac_weights_chelsea_pro; | ||
2086 | si_pi->dte_data = dte_data_venus_pro; | ||
2087 | break; | ||
2088 | default: | ||
2089 | si_pi->cac_weights = cac_weights_cape_verde; | ||
2090 | si_pi->dte_data = dte_data_cape_verde; | ||
2091 | break; | ||
2092 | } | ||
2093 | } else if (adev->asic_type == CHIP_OLAND) { | ||
2094 | si_pi->lcac_config = lcac_mars_pro; | ||
2095 | si_pi->cac_override = cac_override_oland; | ||
2096 | si_pi->powertune_data = &powertune_data_mars_pro; | ||
2097 | si_pi->dte_data = dte_data_mars_pro; | ||
2098 | |||
2099 | switch (adev->pdev->device) { | ||
2100 | case 0x6601: | ||
2101 | case 0x6621: | ||
2102 | case 0x6603: | ||
2103 | case 0x6605: | ||
2104 | si_pi->cac_weights = cac_weights_mars_pro; | ||
2105 | update_dte_from_pl2 = true; | ||
2106 | break; | ||
2107 | case 0x6600: | ||
2108 | case 0x6606: | ||
2109 | case 0x6620: | ||
2110 | case 0x6604: | ||
2111 | si_pi->cac_weights = cac_weights_mars_xt; | ||
2112 | update_dte_from_pl2 = true; | ||
2113 | break; | ||
2114 | case 0x6611: | ||
2115 | case 0x6613: | ||
2116 | case 0x6608: | ||
2117 | si_pi->cac_weights = cac_weights_oland_pro; | ||
2118 | update_dte_from_pl2 = true; | ||
2119 | break; | ||
2120 | case 0x6610: | ||
2121 | si_pi->cac_weights = cac_weights_oland_xt; | ||
2122 | update_dte_from_pl2 = true; | ||
2123 | break; | ||
2124 | default: | ||
2125 | si_pi->cac_weights = cac_weights_oland; | ||
2126 | si_pi->lcac_config = lcac_oland; | ||
2127 | si_pi->cac_override = cac_override_oland; | ||
2128 | si_pi->powertune_data = &powertune_data_oland; | ||
2129 | si_pi->dte_data = dte_data_oland; | ||
2130 | break; | ||
2131 | } | ||
2132 | } else if (adev->asic_type == CHIP_HAINAN) { | ||
2133 | si_pi->cac_weights = cac_weights_hainan; | ||
2134 | si_pi->lcac_config = lcac_oland; | ||
2135 | si_pi->cac_override = cac_override_oland; | ||
2136 | si_pi->powertune_data = &powertune_data_hainan; | ||
2137 | si_pi->dte_data = dte_data_sun_xt; | ||
2138 | update_dte_from_pl2 = true; | ||
2139 | } else { | ||
2140 | DRM_ERROR("Unknown SI asic revision, failed to initialize PowerTune!\n"); | ||
2141 | return; | ||
2142 | } | ||
2143 | |||
2144 | ni_pi->enable_power_containment = false; | ||
2145 | ni_pi->enable_cac = false; | ||
2146 | ni_pi->enable_sq_ramping = false; | ||
2147 | si_pi->enable_dte = false; | ||
2148 | |||
2149 | if (si_pi->powertune_data->enable_powertune_by_default) { | ||
2150 | ni_pi->enable_power_containment = true; | ||
2151 | ni_pi->enable_cac = true; | ||
2152 | if (si_pi->dte_data.enable_dte_by_default) { | ||
2153 | si_pi->enable_dte = true; | ||
2154 | if (update_dte_from_pl2) | ||
2155 | si_update_dte_from_pl2(adev, &si_pi->dte_data); | ||
2156 | |||
2157 | } | ||
2158 | ni_pi->enable_sq_ramping = true; | ||
2159 | } | ||
2160 | |||
2161 | ni_pi->driver_calculate_cac_leakage = true; | ||
2162 | ni_pi->cac_configuration_required = true; | ||
2163 | |||
2164 | if (ni_pi->cac_configuration_required) { | ||
2165 | ni_pi->support_cac_long_term_average = true; | ||
2166 | si_pi->dyn_powertune_data.l2_lta_window_size = | ||
2167 | si_pi->powertune_data->l2_lta_window_size_default; | ||
2168 | si_pi->dyn_powertune_data.lts_truncate = | ||
2169 | si_pi->powertune_data->lts_truncate_default; | ||
2170 | } else { | ||
2171 | ni_pi->support_cac_long_term_average = false; | ||
2172 | si_pi->dyn_powertune_data.l2_lta_window_size = 0; | ||
2173 | si_pi->dyn_powertune_data.lts_truncate = 0; | ||
2174 | } | ||
2175 | |||
2176 | si_pi->dyn_powertune_data.disable_uvd_powertune = false; | ||
2177 | } | ||
2178 | |||
2179 | static u32 si_get_smc_power_scaling_factor(struct amdgpu_device *adev) | ||
2180 | { | ||
2181 | return 1; | ||
2182 | } | ||
2183 | |||
2184 | static u32 si_calculate_cac_wintime(struct amdgpu_device *adev) | ||
2185 | { | ||
2186 | u32 xclk; | ||
2187 | u32 wintime; | ||
2188 | u32 cac_window; | ||
2189 | u32 cac_window_size; | ||
2190 | |||
2191 | xclk = amdgpu_asic_get_xclk(adev); | ||
2192 | |||
2193 | if (xclk == 0) | ||
2194 | return 0; | ||
2195 | |||
2196 | cac_window = RREG32(CG_CAC_CTRL) & CAC_WINDOW_MASK; | ||
2197 | cac_window_size = ((cac_window & 0xFFFF0000) >> 16) * (cac_window & 0x0000FFFF); | ||
2198 | |||
2199 | wintime = (cac_window_size * 100) / xclk; | ||
2200 | |||
2201 | return wintime; | ||
2202 | } | ||
2203 | |||
2204 | static u32 si_scale_power_for_smc(u32 power_in_watts, u32 scaling_factor) | ||
2205 | { | ||
2206 | return power_in_watts; | ||
2207 | } | ||
2208 | |||
2209 | static int si_calculate_adjusted_tdp_limits(struct amdgpu_device *adev, | ||
2210 | bool adjust_polarity, | ||
2211 | u32 tdp_adjustment, | ||
2212 | u32 *tdp_limit, | ||
2213 | u32 *near_tdp_limit) | ||
2214 | { | ||
2215 | u32 adjustment_delta, max_tdp_limit; | ||
2216 | |||
2217 | if (tdp_adjustment > (u32)adev->pm.dpm.tdp_od_limit) | ||
2218 | return -EINVAL; | ||
2219 | |||
2220 | max_tdp_limit = ((100 + 100) * adev->pm.dpm.tdp_limit) / 100; | ||
2221 | |||
2222 | if (adjust_polarity) { | ||
2223 | *tdp_limit = ((100 + tdp_adjustment) * adev->pm.dpm.tdp_limit) / 100; | ||
2224 | *near_tdp_limit = adev->pm.dpm.near_tdp_limit_adjusted + (*tdp_limit - adev->pm.dpm.tdp_limit); | ||
2225 | } else { | ||
2226 | *tdp_limit = ((100 - tdp_adjustment) * adev->pm.dpm.tdp_limit) / 100; | ||
2227 | adjustment_delta = adev->pm.dpm.tdp_limit - *tdp_limit; | ||
2228 | if (adjustment_delta < adev->pm.dpm.near_tdp_limit_adjusted) | ||
2229 | *near_tdp_limit = adev->pm.dpm.near_tdp_limit_adjusted - adjustment_delta; | ||
2230 | else | ||
2231 | *near_tdp_limit = 0; | ||
2232 | } | ||
2233 | |||
2234 | if ((*tdp_limit <= 0) || (*tdp_limit > max_tdp_limit)) | ||
2235 | return -EINVAL; | ||
2236 | if ((*near_tdp_limit <= 0) || (*near_tdp_limit > *tdp_limit)) | ||
2237 | return -EINVAL; | ||
2238 | |||
2239 | return 0; | ||
2240 | } | ||
2241 | |||
2242 | static int si_populate_smc_tdp_limits(struct amdgpu_device *adev, | ||
2243 | struct amdgpu_ps *amdgpu_state) | ||
2244 | { | ||
2245 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2246 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2247 | |||
2248 | if (ni_pi->enable_power_containment) { | ||
2249 | SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable; | ||
2250 | PP_SIslands_PAPMParameters *papm_parm; | ||
2251 | struct amdgpu_ppm_table *ppm = adev->pm.dpm.dyn_state.ppm_table; | ||
2252 | u32 scaling_factor = si_get_smc_power_scaling_factor(adev); | ||
2253 | u32 tdp_limit; | ||
2254 | u32 near_tdp_limit; | ||
2255 | int ret; | ||
2256 | |||
2257 | if (scaling_factor == 0) | ||
2258 | return -EINVAL; | ||
2259 | |||
2260 | memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE)); | ||
2261 | |||
2262 | ret = si_calculate_adjusted_tdp_limits(adev, | ||
2263 | false, /* ??? */ | ||
2264 | adev->pm.dpm.tdp_adjustment, | ||
2265 | &tdp_limit, | ||
2266 | &near_tdp_limit); | ||
2267 | if (ret) | ||
2268 | return ret; | ||
2269 | |||
2270 | smc_table->dpm2Params.TDPLimit = | ||
2271 | cpu_to_be32(si_scale_power_for_smc(tdp_limit, scaling_factor) * 1000); | ||
2272 | smc_table->dpm2Params.NearTDPLimit = | ||
2273 | cpu_to_be32(si_scale_power_for_smc(near_tdp_limit, scaling_factor) * 1000); | ||
2274 | smc_table->dpm2Params.SafePowerLimit = | ||
2275 | cpu_to_be32(si_scale_power_for_smc((near_tdp_limit * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000); | ||
2276 | |||
2277 | ret = amdgpu_si_copy_bytes_to_smc(adev, | ||
2278 | (si_pi->state_table_start + offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) + | ||
2279 | offsetof(PP_SIslands_DPM2Parameters, TDPLimit)), | ||
2280 | (u8 *)(&(smc_table->dpm2Params.TDPLimit)), | ||
2281 | sizeof(u32) * 3, | ||
2282 | si_pi->sram_end); | ||
2283 | if (ret) | ||
2284 | return ret; | ||
2285 | |||
2286 | if (si_pi->enable_ppm) { | ||
2287 | papm_parm = &si_pi->papm_parm; | ||
2288 | memset(papm_parm, 0, sizeof(PP_SIslands_PAPMParameters)); | ||
2289 | papm_parm->NearTDPLimitTherm = cpu_to_be32(ppm->dgpu_tdp); | ||
2290 | papm_parm->dGPU_T_Limit = cpu_to_be32(ppm->tj_max); | ||
2291 | papm_parm->dGPU_T_Warning = cpu_to_be32(95); | ||
2292 | papm_parm->dGPU_T_Hysteresis = cpu_to_be32(5); | ||
2293 | papm_parm->PlatformPowerLimit = 0xffffffff; | ||
2294 | papm_parm->NearTDPLimitPAPM = 0xffffffff; | ||
2295 | |||
2296 | ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->papm_cfg_table_start, | ||
2297 | (u8 *)papm_parm, | ||
2298 | sizeof(PP_SIslands_PAPMParameters), | ||
2299 | si_pi->sram_end); | ||
2300 | if (ret) | ||
2301 | return ret; | ||
2302 | } | ||
2303 | } | ||
2304 | return 0; | ||
2305 | } | ||
2306 | |||
2307 | static int si_populate_smc_tdp_limits_2(struct amdgpu_device *adev, | ||
2308 | struct amdgpu_ps *amdgpu_state) | ||
2309 | { | ||
2310 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2311 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2312 | |||
2313 | if (ni_pi->enable_power_containment) { | ||
2314 | SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable; | ||
2315 | u32 scaling_factor = si_get_smc_power_scaling_factor(adev); | ||
2316 | int ret; | ||
2317 | |||
2318 | memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE)); | ||
2319 | |||
2320 | smc_table->dpm2Params.NearTDPLimit = | ||
2321 | cpu_to_be32(si_scale_power_for_smc(adev->pm.dpm.near_tdp_limit_adjusted, scaling_factor) * 1000); | ||
2322 | smc_table->dpm2Params.SafePowerLimit = | ||
2323 | cpu_to_be32(si_scale_power_for_smc((adev->pm.dpm.near_tdp_limit_adjusted * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000); | ||
2324 | |||
2325 | ret = amdgpu_si_copy_bytes_to_smc(adev, | ||
2326 | (si_pi->state_table_start + | ||
2327 | offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) + | ||
2328 | offsetof(PP_SIslands_DPM2Parameters, NearTDPLimit)), | ||
2329 | (u8 *)(&(smc_table->dpm2Params.NearTDPLimit)), | ||
2330 | sizeof(u32) * 2, | ||
2331 | si_pi->sram_end); | ||
2332 | if (ret) | ||
2333 | return ret; | ||
2334 | } | ||
2335 | |||
2336 | return 0; | ||
2337 | } | ||
2338 | |||
2339 | static u16 si_calculate_power_efficiency_ratio(struct amdgpu_device *adev, | ||
2340 | const u16 prev_std_vddc, | ||
2341 | const u16 curr_std_vddc) | ||
2342 | { | ||
2343 | u64 margin = (u64)SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN; | ||
2344 | u64 prev_vddc = (u64)prev_std_vddc; | ||
2345 | u64 curr_vddc = (u64)curr_std_vddc; | ||
2346 | u64 pwr_efficiency_ratio, n, d; | ||
2347 | |||
2348 | if ((prev_vddc == 0) || (curr_vddc == 0)) | ||
2349 | return 0; | ||
2350 | |||
2351 | n = div64_u64((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin), (u64)1000); | ||
2352 | d = prev_vddc * prev_vddc; | ||
2353 | pwr_efficiency_ratio = div64_u64(n, d); | ||
2354 | |||
2355 | if (pwr_efficiency_ratio > (u64)0xFFFF) | ||
2356 | return 0; | ||
2357 | |||
2358 | return (u16)pwr_efficiency_ratio; | ||
2359 | } | ||
2360 | |||
2361 | static bool si_should_disable_uvd_powertune(struct amdgpu_device *adev, | ||
2362 | struct amdgpu_ps *amdgpu_state) | ||
2363 | { | ||
2364 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2365 | |||
2366 | if (si_pi->dyn_powertune_data.disable_uvd_powertune && | ||
2367 | amdgpu_state->vclk && amdgpu_state->dclk) | ||
2368 | return true; | ||
2369 | |||
2370 | return false; | ||
2371 | } | ||
2372 | |||
2373 | struct evergreen_power_info *evergreen_get_pi(struct amdgpu_device *adev) | ||
2374 | { | ||
2375 | struct evergreen_power_info *pi = adev->pm.dpm.priv; | ||
2376 | |||
2377 | return pi; | ||
2378 | } | ||
2379 | |||
2380 | static int si_populate_power_containment_values(struct amdgpu_device *adev, | ||
2381 | struct amdgpu_ps *amdgpu_state, | ||
2382 | SISLANDS_SMC_SWSTATE *smc_state) | ||
2383 | { | ||
2384 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
2385 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2386 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
2387 | SISLANDS_SMC_VOLTAGE_VALUE vddc; | ||
2388 | u32 prev_sclk; | ||
2389 | u32 max_sclk; | ||
2390 | u32 min_sclk; | ||
2391 | u16 prev_std_vddc; | ||
2392 | u16 curr_std_vddc; | ||
2393 | int i; | ||
2394 | u16 pwr_efficiency_ratio; | ||
2395 | u8 max_ps_percent; | ||
2396 | bool disable_uvd_power_tune; | ||
2397 | int ret; | ||
2398 | |||
2399 | if (ni_pi->enable_power_containment == false) | ||
2400 | return 0; | ||
2401 | |||
2402 | if (state->performance_level_count == 0) | ||
2403 | return -EINVAL; | ||
2404 | |||
2405 | if (smc_state->levelCount != state->performance_level_count) | ||
2406 | return -EINVAL; | ||
2407 | |||
2408 | disable_uvd_power_tune = si_should_disable_uvd_powertune(adev, amdgpu_state); | ||
2409 | |||
2410 | smc_state->levels[0].dpm2.MaxPS = 0; | ||
2411 | smc_state->levels[0].dpm2.NearTDPDec = 0; | ||
2412 | smc_state->levels[0].dpm2.AboveSafeInc = 0; | ||
2413 | smc_state->levels[0].dpm2.BelowSafeInc = 0; | ||
2414 | smc_state->levels[0].dpm2.PwrEfficiencyRatio = 0; | ||
2415 | |||
2416 | for (i = 1; i < state->performance_level_count; i++) { | ||
2417 | prev_sclk = state->performance_levels[i-1].sclk; | ||
2418 | max_sclk = state->performance_levels[i].sclk; | ||
2419 | if (i == 1) | ||
2420 | max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_M; | ||
2421 | else | ||
2422 | max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_H; | ||
2423 | |||
2424 | if (prev_sclk > max_sclk) | ||
2425 | return -EINVAL; | ||
2426 | |||
2427 | if ((max_ps_percent == 0) || | ||
2428 | (prev_sclk == max_sclk) || | ||
2429 | disable_uvd_power_tune) | ||
2430 | min_sclk = max_sclk; | ||
2431 | else if (i == 1) | ||
2432 | min_sclk = prev_sclk; | ||
2433 | else | ||
2434 | min_sclk = (prev_sclk * (u32)max_ps_percent) / 100; | ||
2435 | |||
2436 | if (min_sclk < state->performance_levels[0].sclk) | ||
2437 | min_sclk = state->performance_levels[0].sclk; | ||
2438 | |||
2439 | if (min_sclk == 0) | ||
2440 | return -EINVAL; | ||
2441 | |||
2442 | ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table, | ||
2443 | state->performance_levels[i-1].vddc, &vddc); | ||
2444 | if (ret) | ||
2445 | return ret; | ||
2446 | |||
2447 | ret = si_get_std_voltage_value(adev, &vddc, &prev_std_vddc); | ||
2448 | if (ret) | ||
2449 | return ret; | ||
2450 | |||
2451 | ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table, | ||
2452 | state->performance_levels[i].vddc, &vddc); | ||
2453 | if (ret) | ||
2454 | return ret; | ||
2455 | |||
2456 | ret = si_get_std_voltage_value(adev, &vddc, &curr_std_vddc); | ||
2457 | if (ret) | ||
2458 | return ret; | ||
2459 | |||
2460 | pwr_efficiency_ratio = si_calculate_power_efficiency_ratio(adev, | ||
2461 | prev_std_vddc, curr_std_vddc); | ||
2462 | |||
2463 | smc_state->levels[i].dpm2.MaxPS = (u8)((SISLANDS_DPM2_MAX_PULSE_SKIP * (max_sclk - min_sclk)) / max_sclk); | ||
2464 | smc_state->levels[i].dpm2.NearTDPDec = SISLANDS_DPM2_NEAR_TDP_DEC; | ||
2465 | smc_state->levels[i].dpm2.AboveSafeInc = SISLANDS_DPM2_ABOVE_SAFE_INC; | ||
2466 | smc_state->levels[i].dpm2.BelowSafeInc = SISLANDS_DPM2_BELOW_SAFE_INC; | ||
2467 | smc_state->levels[i].dpm2.PwrEfficiencyRatio = cpu_to_be16(pwr_efficiency_ratio); | ||
2468 | } | ||
2469 | |||
2470 | return 0; | ||
2471 | } | ||
2472 | |||
2473 | static int si_populate_sq_ramping_values(struct amdgpu_device *adev, | ||
2474 | struct amdgpu_ps *amdgpu_state, | ||
2475 | SISLANDS_SMC_SWSTATE *smc_state) | ||
2476 | { | ||
2477 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2478 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
2479 | u32 sq_power_throttle, sq_power_throttle2; | ||
2480 | bool enable_sq_ramping = ni_pi->enable_sq_ramping; | ||
2481 | int i; | ||
2482 | |||
2483 | if (state->performance_level_count == 0) | ||
2484 | return -EINVAL; | ||
2485 | |||
2486 | if (smc_state->levelCount != state->performance_level_count) | ||
2487 | return -EINVAL; | ||
2488 | |||
2489 | if (adev->pm.dpm.sq_ramping_threshold == 0) | ||
2490 | return -EINVAL; | ||
2491 | |||
2492 | if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER > (MAX_POWER_MASK >> MAX_POWER_SHIFT)) | ||
2493 | enable_sq_ramping = false; | ||
2494 | |||
2495 | if (SISLANDS_DPM2_SQ_RAMP_MIN_POWER > (MIN_POWER_MASK >> MIN_POWER_SHIFT)) | ||
2496 | enable_sq_ramping = false; | ||
2497 | |||
2498 | if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA > (MAX_POWER_DELTA_MASK >> MAX_POWER_DELTA_SHIFT)) | ||
2499 | enable_sq_ramping = false; | ||
2500 | |||
2501 | if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT)) | ||
2502 | enable_sq_ramping = false; | ||
2503 | |||
2504 | if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT)) | ||
2505 | enable_sq_ramping = false; | ||
2506 | |||
2507 | for (i = 0; i < state->performance_level_count; i++) { | ||
2508 | sq_power_throttle = 0; | ||
2509 | sq_power_throttle2 = 0; | ||
2510 | |||
2511 | if ((state->performance_levels[i].sclk >= adev->pm.dpm.sq_ramping_threshold) && | ||
2512 | enable_sq_ramping) { | ||
2513 | sq_power_throttle |= MAX_POWER(SISLANDS_DPM2_SQ_RAMP_MAX_POWER); | ||
2514 | sq_power_throttle |= MIN_POWER(SISLANDS_DPM2_SQ_RAMP_MIN_POWER); | ||
2515 | sq_power_throttle2 |= MAX_POWER_DELTA(SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA); | ||
2516 | sq_power_throttle2 |= STI_SIZE(SISLANDS_DPM2_SQ_RAMP_STI_SIZE); | ||
2517 | sq_power_throttle2 |= LTI_RATIO(SISLANDS_DPM2_SQ_RAMP_LTI_RATIO); | ||
2518 | } else { | ||
2519 | sq_power_throttle |= MAX_POWER_MASK | MIN_POWER_MASK; | ||
2520 | sq_power_throttle2 |= MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK; | ||
2521 | } | ||
2522 | |||
2523 | smc_state->levels[i].SQPowerThrottle = cpu_to_be32(sq_power_throttle); | ||
2524 | smc_state->levels[i].SQPowerThrottle_2 = cpu_to_be32(sq_power_throttle2); | ||
2525 | } | ||
2526 | |||
2527 | return 0; | ||
2528 | } | ||
2529 | |||
2530 | static int si_enable_power_containment(struct amdgpu_device *adev, | ||
2531 | struct amdgpu_ps *amdgpu_new_state, | ||
2532 | bool enable) | ||
2533 | { | ||
2534 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2535 | PPSMC_Result smc_result; | ||
2536 | int ret = 0; | ||
2537 | |||
2538 | if (ni_pi->enable_power_containment) { | ||
2539 | if (enable) { | ||
2540 | if (!si_should_disable_uvd_powertune(adev, amdgpu_new_state)) { | ||
2541 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_TDPClampingActive); | ||
2542 | if (smc_result != PPSMC_Result_OK) { | ||
2543 | ret = -EINVAL; | ||
2544 | ni_pi->pc_enabled = false; | ||
2545 | } else { | ||
2546 | ni_pi->pc_enabled = true; | ||
2547 | } | ||
2548 | } | ||
2549 | } else { | ||
2550 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_TDPClampingInactive); | ||
2551 | if (smc_result != PPSMC_Result_OK) | ||
2552 | ret = -EINVAL; | ||
2553 | ni_pi->pc_enabled = false; | ||
2554 | } | ||
2555 | } | ||
2556 | |||
2557 | return ret; | ||
2558 | } | ||
2559 | |||
2560 | static int si_initialize_smc_dte_tables(struct amdgpu_device *adev) | ||
2561 | { | ||
2562 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2563 | int ret = 0; | ||
2564 | struct si_dte_data *dte_data = &si_pi->dte_data; | ||
2565 | Smc_SIslands_DTE_Configuration *dte_tables = NULL; | ||
2566 | u32 table_size; | ||
2567 | u8 tdep_count; | ||
2568 | u32 i; | ||
2569 | |||
2570 | if (dte_data == NULL) | ||
2571 | si_pi->enable_dte = false; | ||
2572 | |||
2573 | if (si_pi->enable_dte == false) | ||
2574 | return 0; | ||
2575 | |||
2576 | if (dte_data->k <= 0) | ||
2577 | return -EINVAL; | ||
2578 | |||
2579 | dte_tables = kzalloc(sizeof(Smc_SIslands_DTE_Configuration), GFP_KERNEL); | ||
2580 | if (dte_tables == NULL) { | ||
2581 | si_pi->enable_dte = false; | ||
2582 | return -ENOMEM; | ||
2583 | } | ||
2584 | |||
2585 | table_size = dte_data->k; | ||
2586 | |||
2587 | if (table_size > SMC_SISLANDS_DTE_MAX_FILTER_STAGES) | ||
2588 | table_size = SMC_SISLANDS_DTE_MAX_FILTER_STAGES; | ||
2589 | |||
2590 | tdep_count = dte_data->tdep_count; | ||
2591 | if (tdep_count > SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE) | ||
2592 | tdep_count = SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE; | ||
2593 | |||
2594 | dte_tables->K = cpu_to_be32(table_size); | ||
2595 | dte_tables->T0 = cpu_to_be32(dte_data->t0); | ||
2596 | dte_tables->MaxT = cpu_to_be32(dte_data->max_t); | ||
2597 | dte_tables->WindowSize = dte_data->window_size; | ||
2598 | dte_tables->temp_select = dte_data->temp_select; | ||
2599 | dte_tables->DTE_mode = dte_data->dte_mode; | ||
2600 | dte_tables->Tthreshold = cpu_to_be32(dte_data->t_threshold); | ||
2601 | |||
2602 | if (tdep_count > 0) | ||
2603 | table_size--; | ||
2604 | |||
2605 | for (i = 0; i < table_size; i++) { | ||
2606 | dte_tables->tau[i] = cpu_to_be32(dte_data->tau[i]); | ||
2607 | dte_tables->R[i] = cpu_to_be32(dte_data->r[i]); | ||
2608 | } | ||
2609 | |||
2610 | dte_tables->Tdep_count = tdep_count; | ||
2611 | |||
2612 | for (i = 0; i < (u32)tdep_count; i++) { | ||
2613 | dte_tables->T_limits[i] = dte_data->t_limits[i]; | ||
2614 | dte_tables->Tdep_tau[i] = cpu_to_be32(dte_data->tdep_tau[i]); | ||
2615 | dte_tables->Tdep_R[i] = cpu_to_be32(dte_data->tdep_r[i]); | ||
2616 | } | ||
2617 | |||
2618 | ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->dte_table_start, | ||
2619 | (u8 *)dte_tables, | ||
2620 | sizeof(Smc_SIslands_DTE_Configuration), | ||
2621 | si_pi->sram_end); | ||
2622 | kfree(dte_tables); | ||
2623 | |||
2624 | return ret; | ||
2625 | } | ||
2626 | |||
2627 | static int si_get_cac_std_voltage_max_min(struct amdgpu_device *adev, | ||
2628 | u16 *max, u16 *min) | ||
2629 | { | ||
2630 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2631 | struct amdgpu_cac_leakage_table *table = | ||
2632 | &adev->pm.dpm.dyn_state.cac_leakage_table; | ||
2633 | u32 i; | ||
2634 | u32 v0_loadline; | ||
2635 | |||
2636 | if (table == NULL) | ||
2637 | return -EINVAL; | ||
2638 | |||
2639 | *max = 0; | ||
2640 | *min = 0xFFFF; | ||
2641 | |||
2642 | for (i = 0; i < table->count; i++) { | ||
2643 | if (table->entries[i].vddc > *max) | ||
2644 | *max = table->entries[i].vddc; | ||
2645 | if (table->entries[i].vddc < *min) | ||
2646 | *min = table->entries[i].vddc; | ||
2647 | } | ||
2648 | |||
2649 | if (si_pi->powertune_data->lkge_lut_v0_percent > 100) | ||
2650 | return -EINVAL; | ||
2651 | |||
2652 | v0_loadline = (*min) * (100 - si_pi->powertune_data->lkge_lut_v0_percent) / 100; | ||
2653 | |||
2654 | if (v0_loadline > 0xFFFFUL) | ||
2655 | return -EINVAL; | ||
2656 | |||
2657 | *min = (u16)v0_loadline; | ||
2658 | |||
2659 | if ((*min > *max) || (*max == 0) || (*min == 0)) | ||
2660 | return -EINVAL; | ||
2661 | |||
2662 | return 0; | ||
2663 | } | ||
2664 | |||
2665 | static u16 si_get_cac_std_voltage_step(u16 max, u16 min) | ||
2666 | { | ||
2667 | return ((max - min) + (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1)) / | ||
2668 | SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; | ||
2669 | } | ||
2670 | |||
2671 | static int si_init_dte_leakage_table(struct amdgpu_device *adev, | ||
2672 | PP_SIslands_CacConfig *cac_tables, | ||
2673 | u16 vddc_max, u16 vddc_min, u16 vddc_step, | ||
2674 | u16 t0, u16 t_step) | ||
2675 | { | ||
2676 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2677 | u32 leakage; | ||
2678 | unsigned int i, j; | ||
2679 | s32 t; | ||
2680 | u32 smc_leakage; | ||
2681 | u32 scaling_factor; | ||
2682 | u16 voltage; | ||
2683 | |||
2684 | scaling_factor = si_get_smc_power_scaling_factor(adev); | ||
2685 | |||
2686 | for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++) { | ||
2687 | t = (1000 * (i * t_step + t0)); | ||
2688 | |||
2689 | for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) { | ||
2690 | voltage = vddc_max - (vddc_step * j); | ||
2691 | |||
2692 | si_calculate_leakage_for_v_and_t(adev, | ||
2693 | &si_pi->powertune_data->leakage_coefficients, | ||
2694 | voltage, | ||
2695 | t, | ||
2696 | si_pi->dyn_powertune_data.cac_leakage, | ||
2697 | &leakage); | ||
2698 | |||
2699 | smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4; | ||
2700 | |||
2701 | if (smc_leakage > 0xFFFF) | ||
2702 | smc_leakage = 0xFFFF; | ||
2703 | |||
2704 | cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] = | ||
2705 | cpu_to_be16((u16)smc_leakage); | ||
2706 | } | ||
2707 | } | ||
2708 | return 0; | ||
2709 | } | ||
2710 | |||
2711 | static int si_init_simplified_leakage_table(struct amdgpu_device *adev, | ||
2712 | PP_SIslands_CacConfig *cac_tables, | ||
2713 | u16 vddc_max, u16 vddc_min, u16 vddc_step) | ||
2714 | { | ||
2715 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2716 | u32 leakage; | ||
2717 | unsigned int i, j; | ||
2718 | u32 smc_leakage; | ||
2719 | u32 scaling_factor; | ||
2720 | u16 voltage; | ||
2721 | |||
2722 | scaling_factor = si_get_smc_power_scaling_factor(adev); | ||
2723 | |||
2724 | for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) { | ||
2725 | voltage = vddc_max - (vddc_step * j); | ||
2726 | |||
2727 | si_calculate_leakage_for_v(adev, | ||
2728 | &si_pi->powertune_data->leakage_coefficients, | ||
2729 | si_pi->powertune_data->fixed_kt, | ||
2730 | voltage, | ||
2731 | si_pi->dyn_powertune_data.cac_leakage, | ||
2732 | &leakage); | ||
2733 | |||
2734 | smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4; | ||
2735 | |||
2736 | if (smc_leakage > 0xFFFF) | ||
2737 | smc_leakage = 0xFFFF; | ||
2738 | |||
2739 | for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++) | ||
2740 | cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] = | ||
2741 | cpu_to_be16((u16)smc_leakage); | ||
2742 | } | ||
2743 | return 0; | ||
2744 | } | ||
2745 | |||
2746 | static int si_initialize_smc_cac_tables(struct amdgpu_device *adev) | ||
2747 | { | ||
2748 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2749 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2750 | PP_SIslands_CacConfig *cac_tables = NULL; | ||
2751 | u16 vddc_max, vddc_min, vddc_step; | ||
2752 | u16 t0, t_step; | ||
2753 | u32 load_line_slope, reg; | ||
2754 | int ret = 0; | ||
2755 | u32 ticks_per_us = amdgpu_asic_get_xclk(adev) / 100; | ||
2756 | |||
2757 | if (ni_pi->enable_cac == false) | ||
2758 | return 0; | ||
2759 | |||
2760 | cac_tables = kzalloc(sizeof(PP_SIslands_CacConfig), GFP_KERNEL); | ||
2761 | if (!cac_tables) | ||
2762 | return -ENOMEM; | ||
2763 | |||
2764 | reg = RREG32(CG_CAC_CTRL) & ~CAC_WINDOW_MASK; | ||
2765 | reg |= CAC_WINDOW(si_pi->powertune_data->cac_window); | ||
2766 | WREG32(CG_CAC_CTRL, reg); | ||
2767 | |||
2768 | si_pi->dyn_powertune_data.cac_leakage = adev->pm.dpm.cac_leakage; | ||
2769 | si_pi->dyn_powertune_data.dc_pwr_value = | ||
2770 | si_pi->powertune_data->dc_cac[NISLANDS_DCCAC_LEVEL_0]; | ||
2771 | si_pi->dyn_powertune_data.wintime = si_calculate_cac_wintime(adev); | ||
2772 | si_pi->dyn_powertune_data.shift_n = si_pi->powertune_data->shift_n_default; | ||
2773 | |||
2774 | si_pi->dyn_powertune_data.leakage_minimum_temperature = 80 * 1000; | ||
2775 | |||
2776 | ret = si_get_cac_std_voltage_max_min(adev, &vddc_max, &vddc_min); | ||
2777 | if (ret) | ||
2778 | goto done_free; | ||
2779 | |||
2780 | vddc_step = si_get_cac_std_voltage_step(vddc_max, vddc_min); | ||
2781 | vddc_min = vddc_max - (vddc_step * (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1)); | ||
2782 | t_step = 4; | ||
2783 | t0 = 60; | ||
2784 | |||
2785 | if (si_pi->enable_dte || ni_pi->driver_calculate_cac_leakage) | ||
2786 | ret = si_init_dte_leakage_table(adev, cac_tables, | ||
2787 | vddc_max, vddc_min, vddc_step, | ||
2788 | t0, t_step); | ||
2789 | else | ||
2790 | ret = si_init_simplified_leakage_table(adev, cac_tables, | ||
2791 | vddc_max, vddc_min, vddc_step); | ||
2792 | if (ret) | ||
2793 | goto done_free; | ||
2794 | |||
2795 | load_line_slope = ((u32)adev->pm.dpm.load_line_slope << SMC_SISLANDS_SCALE_R) / 100; | ||
2796 | |||
2797 | cac_tables->l2numWin_TDP = cpu_to_be32(si_pi->dyn_powertune_data.l2_lta_window_size); | ||
2798 | cac_tables->lts_truncate_n = si_pi->dyn_powertune_data.lts_truncate; | ||
2799 | cac_tables->SHIFT_N = si_pi->dyn_powertune_data.shift_n; | ||
2800 | cac_tables->lkge_lut_V0 = cpu_to_be32((u32)vddc_min); | ||
2801 | cac_tables->lkge_lut_Vstep = cpu_to_be32((u32)vddc_step); | ||
2802 | cac_tables->R_LL = cpu_to_be32(load_line_slope); | ||
2803 | cac_tables->WinTime = cpu_to_be32(si_pi->dyn_powertune_data.wintime); | ||
2804 | cac_tables->calculation_repeats = cpu_to_be32(2); | ||
2805 | cac_tables->dc_cac = cpu_to_be32(0); | ||
2806 | cac_tables->log2_PG_LKG_SCALE = 12; | ||
2807 | cac_tables->cac_temp = si_pi->powertune_data->operating_temp; | ||
2808 | cac_tables->lkge_lut_T0 = cpu_to_be32((u32)t0); | ||
2809 | cac_tables->lkge_lut_Tstep = cpu_to_be32((u32)t_step); | ||
2810 | |||
2811 | ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->cac_table_start, | ||
2812 | (u8 *)cac_tables, | ||
2813 | sizeof(PP_SIslands_CacConfig), | ||
2814 | si_pi->sram_end); | ||
2815 | |||
2816 | if (ret) | ||
2817 | goto done_free; | ||
2818 | |||
2819 | ret = si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_ticks_per_us, ticks_per_us); | ||
2820 | |||
2821 | done_free: | ||
2822 | if (ret) { | ||
2823 | ni_pi->enable_cac = false; | ||
2824 | ni_pi->enable_power_containment = false; | ||
2825 | } | ||
2826 | |||
2827 | kfree(cac_tables); | ||
2828 | |||
2829 | return ret; | ||
2830 | } | ||
2831 | |||
2832 | static int si_program_cac_config_registers(struct amdgpu_device *adev, | ||
2833 | const struct si_cac_config_reg *cac_config_regs) | ||
2834 | { | ||
2835 | const struct si_cac_config_reg *config_regs = cac_config_regs; | ||
2836 | u32 data = 0, offset; | ||
2837 | |||
2838 | if (!config_regs) | ||
2839 | return -EINVAL; | ||
2840 | |||
2841 | while (config_regs->offset != 0xFFFFFFFF) { | ||
2842 | switch (config_regs->type) { | ||
2843 | case SISLANDS_CACCONFIG_CGIND: | ||
2844 | offset = SMC_CG_IND_START + config_regs->offset; | ||
2845 | if (offset < SMC_CG_IND_END) | ||
2846 | data = RREG32_SMC(offset); | ||
2847 | break; | ||
2848 | default: | ||
2849 | data = RREG32(config_regs->offset); | ||
2850 | break; | ||
2851 | } | ||
2852 | |||
2853 | data &= ~config_regs->mask; | ||
2854 | data |= ((config_regs->value << config_regs->shift) & config_regs->mask); | ||
2855 | |||
2856 | switch (config_regs->type) { | ||
2857 | case SISLANDS_CACCONFIG_CGIND: | ||
2858 | offset = SMC_CG_IND_START + config_regs->offset; | ||
2859 | if (offset < SMC_CG_IND_END) | ||
2860 | WREG32_SMC(offset, data); | ||
2861 | break; | ||
2862 | default: | ||
2863 | WREG32(config_regs->offset, data); | ||
2864 | break; | ||
2865 | } | ||
2866 | config_regs++; | ||
2867 | } | ||
2868 | return 0; | ||
2869 | } | ||
2870 | |||
2871 | static int si_initialize_hardware_cac_manager(struct amdgpu_device *adev) | ||
2872 | { | ||
2873 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2874 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2875 | int ret; | ||
2876 | |||
2877 | if ((ni_pi->enable_cac == false) || | ||
2878 | (ni_pi->cac_configuration_required == false)) | ||
2879 | return 0; | ||
2880 | |||
2881 | ret = si_program_cac_config_registers(adev, si_pi->lcac_config); | ||
2882 | if (ret) | ||
2883 | return ret; | ||
2884 | ret = si_program_cac_config_registers(adev, si_pi->cac_override); | ||
2885 | if (ret) | ||
2886 | return ret; | ||
2887 | ret = si_program_cac_config_registers(adev, si_pi->cac_weights); | ||
2888 | if (ret) | ||
2889 | return ret; | ||
2890 | |||
2891 | return 0; | ||
2892 | } | ||
2893 | |||
2894 | static int si_enable_smc_cac(struct amdgpu_device *adev, | ||
2895 | struct amdgpu_ps *amdgpu_new_state, | ||
2896 | bool enable) | ||
2897 | { | ||
2898 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2899 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2900 | PPSMC_Result smc_result; | ||
2901 | int ret = 0; | ||
2902 | |||
2903 | if (ni_pi->enable_cac) { | ||
2904 | if (enable) { | ||
2905 | if (!si_should_disable_uvd_powertune(adev, amdgpu_new_state)) { | ||
2906 | if (ni_pi->support_cac_long_term_average) { | ||
2907 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_CACLongTermAvgEnable); | ||
2908 | if (smc_result != PPSMC_Result_OK) | ||
2909 | ni_pi->support_cac_long_term_average = false; | ||
2910 | } | ||
2911 | |||
2912 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableCac); | ||
2913 | if (smc_result != PPSMC_Result_OK) { | ||
2914 | ret = -EINVAL; | ||
2915 | ni_pi->cac_enabled = false; | ||
2916 | } else { | ||
2917 | ni_pi->cac_enabled = true; | ||
2918 | } | ||
2919 | |||
2920 | if (si_pi->enable_dte) { | ||
2921 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableDTE); | ||
2922 | if (smc_result != PPSMC_Result_OK) | ||
2923 | ret = -EINVAL; | ||
2924 | } | ||
2925 | } | ||
2926 | } else if (ni_pi->cac_enabled) { | ||
2927 | if (si_pi->enable_dte) | ||
2928 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableDTE); | ||
2929 | |||
2930 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableCac); | ||
2931 | |||
2932 | ni_pi->cac_enabled = false; | ||
2933 | |||
2934 | if (ni_pi->support_cac_long_term_average) | ||
2935 | smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_CACLongTermAvgDisable); | ||
2936 | } | ||
2937 | } | ||
2938 | return ret; | ||
2939 | } | ||
2940 | |||
2941 | static int si_init_smc_spll_table(struct amdgpu_device *adev) | ||
2942 | { | ||
2943 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
2944 | struct si_power_info *si_pi = si_get_pi(adev); | ||
2945 | SMC_SISLANDS_SPLL_DIV_TABLE *spll_table; | ||
2946 | SISLANDS_SMC_SCLK_VALUE sclk_params; | ||
2947 | u32 fb_div, p_div; | ||
2948 | u32 clk_s, clk_v; | ||
2949 | u32 sclk = 0; | ||
2950 | int ret = 0; | ||
2951 | u32 tmp; | ||
2952 | int i; | ||
2953 | |||
2954 | if (si_pi->spll_table_start == 0) | ||
2955 | return -EINVAL; | ||
2956 | |||
2957 | spll_table = kzalloc(sizeof(SMC_SISLANDS_SPLL_DIV_TABLE), GFP_KERNEL); | ||
2958 | if (spll_table == NULL) | ||
2959 | return -ENOMEM; | ||
2960 | |||
2961 | for (i = 0; i < 256; i++) { | ||
2962 | ret = si_calculate_sclk_params(adev, sclk, &sclk_params); | ||
2963 | if (ret) | ||
2964 | break; | ||
2965 | p_div = (sclk_params.vCG_SPLL_FUNC_CNTL & SPLL_PDIV_A_MASK) >> SPLL_PDIV_A_SHIFT; | ||
2966 | fb_div = (sclk_params.vCG_SPLL_FUNC_CNTL_3 & SPLL_FB_DIV_MASK) >> SPLL_FB_DIV_SHIFT; | ||
2967 | clk_s = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM & CLK_S_MASK) >> CLK_S_SHIFT; | ||
2968 | clk_v = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM_2 & CLK_V_MASK) >> CLK_V_SHIFT; | ||
2969 | |||
2970 | fb_div &= ~0x00001FFF; | ||
2971 | fb_div >>= 1; | ||
2972 | clk_v >>= 6; | ||
2973 | |||
2974 | if (p_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT)) | ||
2975 | ret = -EINVAL; | ||
2976 | if (fb_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT)) | ||
2977 | ret = -EINVAL; | ||
2978 | if (clk_s & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT)) | ||
2979 | ret = -EINVAL; | ||
2980 | if (clk_v & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT)) | ||
2981 | ret = -EINVAL; | ||
2982 | |||
2983 | if (ret) | ||
2984 | break; | ||
2985 | |||
2986 | tmp = ((fb_div << SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK) | | ||
2987 | ((p_div << SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK); | ||
2988 | spll_table->freq[i] = cpu_to_be32(tmp); | ||
2989 | |||
2990 | tmp = ((clk_v << SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK) | | ||
2991 | ((clk_s << SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK); | ||
2992 | spll_table->ss[i] = cpu_to_be32(tmp); | ||
2993 | |||
2994 | sclk += 512; | ||
2995 | } | ||
2996 | |||
2997 | |||
2998 | if (!ret) | ||
2999 | ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->spll_table_start, | ||
3000 | (u8 *)spll_table, | ||
3001 | sizeof(SMC_SISLANDS_SPLL_DIV_TABLE), | ||
3002 | si_pi->sram_end); | ||
3003 | |||
3004 | if (ret) | ||
3005 | ni_pi->enable_power_containment = false; | ||
3006 | |||
3007 | kfree(spll_table); | ||
3008 | |||
3009 | return ret; | ||
3010 | } | ||
3011 | |||
3012 | struct si_dpm_quirk { | ||
3013 | u32 chip_vendor; | ||
3014 | u32 chip_device; | ||
3015 | u32 subsys_vendor; | ||
3016 | u32 subsys_device; | ||
3017 | u32 max_sclk; | ||
3018 | u32 max_mclk; | ||
3019 | }; | ||
3020 | |||
3021 | /* cards with dpm stability problems */ | ||
3022 | static struct si_dpm_quirk si_dpm_quirk_list[] = { | ||
3023 | /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */ | ||
3024 | { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 }, | ||
3025 | { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 }, | ||
3026 | { PCI_VENDOR_ID_ATI, 0x6810, 0x174b, 0xe271, 85000, 90000 }, | ||
3027 | { PCI_VENDOR_ID_ATI, 0x6811, 0x1462, 0x2015, 0, 120000 }, | ||
3028 | { PCI_VENDOR_ID_ATI, 0x6811, 0x1043, 0x2015, 0, 120000 }, | ||
3029 | { 0, 0, 0, 0 }, | ||
3030 | }; | ||
3031 | |||
3032 | static u16 si_get_lower_of_leakage_and_vce_voltage(struct amdgpu_device *adev, | ||
3033 | u16 vce_voltage) | ||
3034 | { | ||
3035 | u16 highest_leakage = 0; | ||
3036 | struct si_power_info *si_pi = si_get_pi(adev); | ||
3037 | int i; | ||
3038 | |||
3039 | for (i = 0; i < si_pi->leakage_voltage.count; i++){ | ||
3040 | if (highest_leakage < si_pi->leakage_voltage.entries[i].voltage) | ||
3041 | highest_leakage = si_pi->leakage_voltage.entries[i].voltage; | ||
3042 | } | ||
3043 | |||
3044 | if (si_pi->leakage_voltage.count && (highest_leakage < vce_voltage)) | ||
3045 | return highest_leakage; | ||
3046 | |||
3047 | return vce_voltage; | ||
3048 | } | ||
3049 | |||
3050 | static int si_get_vce_clock_voltage(struct amdgpu_device *adev, | ||
3051 | u32 evclk, u32 ecclk, u16 *voltage) | ||
3052 | { | ||
3053 | u32 i; | ||
3054 | int ret = -EINVAL; | ||
3055 | struct amdgpu_vce_clock_voltage_dependency_table *table = | ||
3056 | &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | ||
3057 | |||
3058 | if (((evclk == 0) && (ecclk == 0)) || | ||
3059 | (table && (table->count == 0))) { | ||
3060 | *voltage = 0; | ||
3061 | return 0; | ||
3062 | } | ||
3063 | |||
3064 | for (i = 0; i < table->count; i++) { | ||
3065 | if ((evclk <= table->entries[i].evclk) && | ||
3066 | (ecclk <= table->entries[i].ecclk)) { | ||
3067 | *voltage = table->entries[i].v; | ||
3068 | ret = 0; | ||
3069 | break; | ||
3070 | } | ||
3071 | } | ||
3072 | |||
3073 | /* if no match return the highest voltage */ | ||
3074 | if (ret) | ||
3075 | *voltage = table->entries[table->count - 1].v; | ||
3076 | |||
3077 | *voltage = si_get_lower_of_leakage_and_vce_voltage(adev, *voltage); | ||
3078 | |||
3079 | return ret; | ||
3080 | } | ||
3081 | |||
3082 | static bool si_dpm_vblank_too_short(struct amdgpu_device *adev) | ||
3083 | { | ||
3084 | |||
3085 | u32 vblank_time = amdgpu_dpm_get_vblank_time(adev); | ||
3086 | /* we never hit the non-gddr5 limit so disable it */ | ||
3087 | u32 switch_limit = adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5 ? 450 : 0; | ||
3088 | |||
3089 | if (vblank_time < switch_limit) | ||
3090 | return true; | ||
3091 | else | ||
3092 | return false; | ||
3093 | |||
3094 | } | ||
3095 | |||
3096 | static int ni_copy_and_switch_arb_sets(struct amdgpu_device *adev, | ||
3097 | u32 arb_freq_src, u32 arb_freq_dest) | ||
3098 | { | ||
3099 | u32 mc_arb_dram_timing; | ||
3100 | u32 mc_arb_dram_timing2; | ||
3101 | u32 burst_time; | ||
3102 | u32 mc_cg_config; | ||
3103 | |||
3104 | switch (arb_freq_src) { | ||
3105 | case MC_CG_ARB_FREQ_F0: | ||
3106 | mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING); | ||
3107 | mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2); | ||
3108 | burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE0_MASK) >> STATE0_SHIFT; | ||
3109 | break; | ||
3110 | case MC_CG_ARB_FREQ_F1: | ||
3111 | mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_1); | ||
3112 | mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_1); | ||
3113 | burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE1_MASK) >> STATE1_SHIFT; | ||
3114 | break; | ||
3115 | case MC_CG_ARB_FREQ_F2: | ||
3116 | mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_2); | ||
3117 | mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_2); | ||
3118 | burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE2_MASK) >> STATE2_SHIFT; | ||
3119 | break; | ||
3120 | case MC_CG_ARB_FREQ_F3: | ||
3121 | mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_3); | ||
3122 | mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_3); | ||
3123 | burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE3_MASK) >> STATE3_SHIFT; | ||
3124 | break; | ||
3125 | default: | ||
3126 | return -EINVAL; | ||
3127 | } | ||
3128 | |||
3129 | switch (arb_freq_dest) { | ||
3130 | case MC_CG_ARB_FREQ_F0: | ||
3131 | WREG32(MC_ARB_DRAM_TIMING, mc_arb_dram_timing); | ||
3132 | WREG32(MC_ARB_DRAM_TIMING2, mc_arb_dram_timing2); | ||
3133 | WREG32_P(MC_ARB_BURST_TIME, STATE0(burst_time), ~STATE0_MASK); | ||
3134 | break; | ||
3135 | case MC_CG_ARB_FREQ_F1: | ||
3136 | WREG32(MC_ARB_DRAM_TIMING_1, mc_arb_dram_timing); | ||
3137 | WREG32(MC_ARB_DRAM_TIMING2_1, mc_arb_dram_timing2); | ||
3138 | WREG32_P(MC_ARB_BURST_TIME, STATE1(burst_time), ~STATE1_MASK); | ||
3139 | break; | ||
3140 | case MC_CG_ARB_FREQ_F2: | ||
3141 | WREG32(MC_ARB_DRAM_TIMING_2, mc_arb_dram_timing); | ||
3142 | WREG32(MC_ARB_DRAM_TIMING2_2, mc_arb_dram_timing2); | ||
3143 | WREG32_P(MC_ARB_BURST_TIME, STATE2(burst_time), ~STATE2_MASK); | ||
3144 | break; | ||
3145 | case MC_CG_ARB_FREQ_F3: | ||
3146 | WREG32(MC_ARB_DRAM_TIMING_3, mc_arb_dram_timing); | ||
3147 | WREG32(MC_ARB_DRAM_TIMING2_3, mc_arb_dram_timing2); | ||
3148 | WREG32_P(MC_ARB_BURST_TIME, STATE3(burst_time), ~STATE3_MASK); | ||
3149 | break; | ||
3150 | default: | ||
3151 | return -EINVAL; | ||
3152 | } | ||
3153 | |||
3154 | mc_cg_config = RREG32(MC_CG_CONFIG) | 0x0000000F; | ||
3155 | WREG32(MC_CG_CONFIG, mc_cg_config); | ||
3156 | WREG32_P(MC_ARB_CG, CG_ARB_REQ(arb_freq_dest), ~CG_ARB_REQ_MASK); | ||
3157 | |||
3158 | return 0; | ||
3159 | } | ||
3160 | |||
3161 | static void ni_update_current_ps(struct amdgpu_device *adev, | ||
3162 | struct amdgpu_ps *rps) | ||
3163 | { | ||
3164 | struct si_ps *new_ps = si_get_ps(rps); | ||
3165 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
3166 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
3167 | |||
3168 | eg_pi->current_rps = *rps; | ||
3169 | ni_pi->current_ps = *new_ps; | ||
3170 | eg_pi->current_rps.ps_priv = &ni_pi->current_ps; | ||
3171 | } | ||
3172 | |||
3173 | static void ni_update_requested_ps(struct amdgpu_device *adev, | ||
3174 | struct amdgpu_ps *rps) | ||
3175 | { | ||
3176 | struct si_ps *new_ps = si_get_ps(rps); | ||
3177 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
3178 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
3179 | |||
3180 | eg_pi->requested_rps = *rps; | ||
3181 | ni_pi->requested_ps = *new_ps; | ||
3182 | eg_pi->requested_rps.ps_priv = &ni_pi->requested_ps; | ||
3183 | } | ||
3184 | |||
3185 | static void ni_set_uvd_clock_before_set_eng_clock(struct amdgpu_device *adev, | ||
3186 | struct amdgpu_ps *new_ps, | ||
3187 | struct amdgpu_ps *old_ps) | ||
3188 | { | ||
3189 | struct si_ps *new_state = si_get_ps(new_ps); | ||
3190 | struct si_ps *current_state = si_get_ps(old_ps); | ||
3191 | |||
3192 | if ((new_ps->vclk == old_ps->vclk) && | ||
3193 | (new_ps->dclk == old_ps->dclk)) | ||
3194 | return; | ||
3195 | |||
3196 | if (new_state->performance_levels[new_state->performance_level_count - 1].sclk >= | ||
3197 | current_state->performance_levels[current_state->performance_level_count - 1].sclk) | ||
3198 | return; | ||
3199 | |||
3200 | amdgpu_asic_set_uvd_clocks(adev, new_ps->vclk, new_ps->dclk); | ||
3201 | } | ||
3202 | |||
3203 | static void ni_set_uvd_clock_after_set_eng_clock(struct amdgpu_device *adev, | ||
3204 | struct amdgpu_ps *new_ps, | ||
3205 | struct amdgpu_ps *old_ps) | ||
3206 | { | ||
3207 | struct si_ps *new_state = si_get_ps(new_ps); | ||
3208 | struct si_ps *current_state = si_get_ps(old_ps); | ||
3209 | |||
3210 | if ((new_ps->vclk == old_ps->vclk) && | ||
3211 | (new_ps->dclk == old_ps->dclk)) | ||
3212 | return; | ||
3213 | |||
3214 | if (new_state->performance_levels[new_state->performance_level_count - 1].sclk < | ||
3215 | current_state->performance_levels[current_state->performance_level_count - 1].sclk) | ||
3216 | return; | ||
3217 | |||
3218 | amdgpu_asic_set_uvd_clocks(adev, new_ps->vclk, new_ps->dclk); | ||
3219 | } | ||
3220 | |||
3221 | static u16 btc_find_voltage(struct atom_voltage_table *table, u16 voltage) | ||
3222 | { | ||
3223 | unsigned int i; | ||
3224 | |||
3225 | for (i = 0; i < table->count; i++) | ||
3226 | if (voltage <= table->entries[i].value) | ||
3227 | return table->entries[i].value; | ||
3228 | |||
3229 | return table->entries[table->count - 1].value; | ||
3230 | } | ||
3231 | |||
3232 | static u32 btc_find_valid_clock(struct amdgpu_clock_array *clocks, | ||
3233 | u32 max_clock, u32 requested_clock) | ||
3234 | { | ||
3235 | unsigned int i; | ||
3236 | |||
3237 | if ((clocks == NULL) || (clocks->count == 0)) | ||
3238 | return (requested_clock < max_clock) ? requested_clock : max_clock; | ||
3239 | |||
3240 | for (i = 0; i < clocks->count; i++) { | ||
3241 | if (clocks->values[i] >= requested_clock) | ||
3242 | return (clocks->values[i] < max_clock) ? clocks->values[i] : max_clock; | ||
3243 | } | ||
3244 | |||
3245 | return (clocks->values[clocks->count - 1] < max_clock) ? | ||
3246 | clocks->values[clocks->count - 1] : max_clock; | ||
3247 | } | ||
3248 | |||
3249 | static u32 btc_get_valid_mclk(struct amdgpu_device *adev, | ||
3250 | u32 max_mclk, u32 requested_mclk) | ||
3251 | { | ||
3252 | return btc_find_valid_clock(&adev->pm.dpm.dyn_state.valid_mclk_values, | ||
3253 | max_mclk, requested_mclk); | ||
3254 | } | ||
3255 | |||
3256 | static u32 btc_get_valid_sclk(struct amdgpu_device *adev, | ||
3257 | u32 max_sclk, u32 requested_sclk) | ||
3258 | { | ||
3259 | return btc_find_valid_clock(&adev->pm.dpm.dyn_state.valid_sclk_values, | ||
3260 | max_sclk, requested_sclk); | ||
3261 | } | ||
3262 | |||
3263 | static void btc_get_max_clock_from_voltage_dependency_table(struct amdgpu_clock_voltage_dependency_table *table, | ||
3264 | u32 *max_clock) | ||
3265 | { | ||
3266 | u32 i, clock = 0; | ||
3267 | |||
3268 | if ((table == NULL) || (table->count == 0)) { | ||
3269 | *max_clock = clock; | ||
3270 | return; | ||
3271 | } | ||
3272 | |||
3273 | for (i = 0; i < table->count; i++) { | ||
3274 | if (clock < table->entries[i].clk) | ||
3275 | clock = table->entries[i].clk; | ||
3276 | } | ||
3277 | *max_clock = clock; | ||
3278 | } | ||
3279 | |||
3280 | static void btc_apply_voltage_dependency_rules(struct amdgpu_clock_voltage_dependency_table *table, | ||
3281 | u32 clock, u16 max_voltage, u16 *voltage) | ||
3282 | { | ||
3283 | u32 i; | ||
3284 | |||
3285 | if ((table == NULL) || (table->count == 0)) | ||
3286 | return; | ||
3287 | |||
3288 | for (i= 0; i < table->count; i++) { | ||
3289 | if (clock <= table->entries[i].clk) { | ||
3290 | if (*voltage < table->entries[i].v) | ||
3291 | *voltage = (u16)((table->entries[i].v < max_voltage) ? | ||
3292 | table->entries[i].v : max_voltage); | ||
3293 | return; | ||
3294 | } | ||
3295 | } | ||
3296 | |||
3297 | *voltage = (*voltage > max_voltage) ? *voltage : max_voltage; | ||
3298 | } | ||
3299 | |||
3300 | static void btc_adjust_clock_combinations(struct amdgpu_device *adev, | ||
3301 | const struct amdgpu_clock_and_voltage_limits *max_limits, | ||
3302 | struct rv7xx_pl *pl) | ||
3303 | { | ||
3304 | |||
3305 | if ((pl->mclk == 0) || (pl->sclk == 0)) | ||
3306 | return; | ||
3307 | |||
3308 | if (pl->mclk == pl->sclk) | ||
3309 | return; | ||
3310 | |||
3311 | if (pl->mclk > pl->sclk) { | ||
3312 | if (((pl->mclk + (pl->sclk - 1)) / pl->sclk) > adev->pm.dpm.dyn_state.mclk_sclk_ratio) | ||
3313 | pl->sclk = btc_get_valid_sclk(adev, | ||
3314 | max_limits->sclk, | ||
3315 | (pl->mclk + | ||
3316 | (adev->pm.dpm.dyn_state.mclk_sclk_ratio - 1)) / | ||
3317 | adev->pm.dpm.dyn_state.mclk_sclk_ratio); | ||
3318 | } else { | ||
3319 | if ((pl->sclk - pl->mclk) > adev->pm.dpm.dyn_state.sclk_mclk_delta) | ||
3320 | pl->mclk = btc_get_valid_mclk(adev, | ||
3321 | max_limits->mclk, | ||
3322 | pl->sclk - | ||
3323 | adev->pm.dpm.dyn_state.sclk_mclk_delta); | ||
3324 | } | ||
3325 | } | ||
3326 | |||
3327 | static void btc_apply_voltage_delta_rules(struct amdgpu_device *adev, | ||
3328 | u16 max_vddc, u16 max_vddci, | ||
3329 | u16 *vddc, u16 *vddci) | ||
3330 | { | ||
3331 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
3332 | u16 new_voltage; | ||
3333 | |||
3334 | if ((0 == *vddc) || (0 == *vddci)) | ||
3335 | return; | ||
3336 | |||
3337 | if (*vddc > *vddci) { | ||
3338 | if ((*vddc - *vddci) > adev->pm.dpm.dyn_state.vddc_vddci_delta) { | ||
3339 | new_voltage = btc_find_voltage(&eg_pi->vddci_voltage_table, | ||
3340 | (*vddc - adev->pm.dpm.dyn_state.vddc_vddci_delta)); | ||
3341 | *vddci = (new_voltage < max_vddci) ? new_voltage : max_vddci; | ||
3342 | } | ||
3343 | } else { | ||
3344 | if ((*vddci - *vddc) > adev->pm.dpm.dyn_state.vddc_vddci_delta) { | ||
3345 | new_voltage = btc_find_voltage(&eg_pi->vddc_voltage_table, | ||
3346 | (*vddci - adev->pm.dpm.dyn_state.vddc_vddci_delta)); | ||
3347 | *vddc = (new_voltage < max_vddc) ? new_voltage : max_vddc; | ||
3348 | } | ||
3349 | } | ||
3350 | } | ||
3351 | |||
3352 | static enum amdgpu_pcie_gen r600_get_pcie_gen_support(struct amdgpu_device *adev, | ||
3353 | u32 sys_mask, | ||
3354 | enum amdgpu_pcie_gen asic_gen, | ||
3355 | enum amdgpu_pcie_gen default_gen) | ||
3356 | { | ||
3357 | switch (asic_gen) { | ||
3358 | case AMDGPU_PCIE_GEN1: | ||
3359 | return AMDGPU_PCIE_GEN1; | ||
3360 | case AMDGPU_PCIE_GEN2: | ||
3361 | return AMDGPU_PCIE_GEN2; | ||
3362 | case AMDGPU_PCIE_GEN3: | ||
3363 | return AMDGPU_PCIE_GEN3; | ||
3364 | default: | ||
3365 | if ((sys_mask & DRM_PCIE_SPEED_80) && (default_gen == AMDGPU_PCIE_GEN3)) | ||
3366 | return AMDGPU_PCIE_GEN3; | ||
3367 | else if ((sys_mask & DRM_PCIE_SPEED_50) && (default_gen == AMDGPU_PCIE_GEN2)) | ||
3368 | return AMDGPU_PCIE_GEN2; | ||
3369 | else | ||
3370 | return AMDGPU_PCIE_GEN1; | ||
3371 | } | ||
3372 | return AMDGPU_PCIE_GEN1; | ||
3373 | } | ||
3374 | |||
3375 | static void r600_calculate_u_and_p(u32 i, u32 r_c, u32 p_b, | ||
3376 | u32 *p, u32 *u) | ||
3377 | { | ||
3378 | u32 b_c = 0; | ||
3379 | u32 i_c; | ||
3380 | u32 tmp; | ||
3381 | |||
3382 | i_c = (i * r_c) / 100; | ||
3383 | tmp = i_c >> p_b; | ||
3384 | |||
3385 | while (tmp) { | ||
3386 | b_c++; | ||
3387 | tmp >>= 1; | ||
3388 | } | ||
3389 | |||
3390 | *u = (b_c + 1) / 2; | ||
3391 | *p = i_c / (1 << (2 * (*u))); | ||
3392 | } | ||
3393 | |||
3394 | static int r600_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th) | ||
3395 | { | ||
3396 | u32 k, a, ah, al; | ||
3397 | u32 t1; | ||
3398 | |||
3399 | if ((fl == 0) || (fh == 0) || (fl > fh)) | ||
3400 | return -EINVAL; | ||
3401 | |||
3402 | k = (100 * fh) / fl; | ||
3403 | t1 = (t * (k - 100)); | ||
3404 | a = (1000 * (100 * h + t1)) / (10000 + (t1 / 100)); | ||
3405 | a = (a + 5) / 10; | ||
3406 | ah = ((a * t) + 5000) / 10000; | ||
3407 | al = a - ah; | ||
3408 | |||
3409 | *th = t - ah; | ||
3410 | *tl = t + al; | ||
3411 | |||
3412 | return 0; | ||
3413 | } | ||
3414 | |||
3415 | static bool r600_is_uvd_state(u32 class, u32 class2) | ||
3416 | { | ||
3417 | if (class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) | ||
3418 | return true; | ||
3419 | if (class & ATOM_PPLIB_CLASSIFICATION_HD2STATE) | ||
3420 | return true; | ||
3421 | if (class & ATOM_PPLIB_CLASSIFICATION_HDSTATE) | ||
3422 | return true; | ||
3423 | if (class & ATOM_PPLIB_CLASSIFICATION_SDSTATE) | ||
3424 | return true; | ||
3425 | if (class2 & ATOM_PPLIB_CLASSIFICATION2_MVC) | ||
3426 | return true; | ||
3427 | return false; | ||
3428 | } | ||
3429 | |||
3430 | static u8 rv770_get_memory_module_index(struct amdgpu_device *adev) | ||
3431 | { | ||
3432 | return (u8) ((RREG32(BIOS_SCRATCH_4) >> 16) & 0xff); | ||
3433 | } | ||
3434 | |||
3435 | static void rv770_get_max_vddc(struct amdgpu_device *adev) | ||
3436 | { | ||
3437 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
3438 | u16 vddc; | ||
3439 | |||
3440 | if (amdgpu_atombios_get_max_vddc(adev, 0, 0, &vddc)) | ||
3441 | pi->max_vddc = 0; | ||
3442 | else | ||
3443 | pi->max_vddc = vddc; | ||
3444 | } | ||
3445 | |||
3446 | static void rv770_get_engine_memory_ss(struct amdgpu_device *adev) | ||
3447 | { | ||
3448 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
3449 | struct amdgpu_atom_ss ss; | ||
3450 | |||
3451 | pi->sclk_ss = amdgpu_atombios_get_asic_ss_info(adev, &ss, | ||
3452 | ASIC_INTERNAL_ENGINE_SS, 0); | ||
3453 | pi->mclk_ss = amdgpu_atombios_get_asic_ss_info(adev, &ss, | ||
3454 | ASIC_INTERNAL_MEMORY_SS, 0); | ||
3455 | |||
3456 | if (pi->sclk_ss || pi->mclk_ss) | ||
3457 | pi->dynamic_ss = true; | ||
3458 | else | ||
3459 | pi->dynamic_ss = false; | ||
3460 | } | ||
3461 | |||
3462 | |||
3463 | static void si_apply_state_adjust_rules(struct amdgpu_device *adev, | ||
3464 | struct amdgpu_ps *rps) | ||
3465 | { | ||
3466 | struct si_ps *ps = si_get_ps(rps); | ||
3467 | struct amdgpu_clock_and_voltage_limits *max_limits; | ||
3468 | bool disable_mclk_switching = false; | ||
3469 | bool disable_sclk_switching = false; | ||
3470 | u32 mclk, sclk; | ||
3471 | u16 vddc, vddci, min_vce_voltage = 0; | ||
3472 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; | ||
3473 | u32 max_sclk = 0, max_mclk = 0; | ||
3474 | int i; | ||
3475 | struct si_dpm_quirk *p = si_dpm_quirk_list; | ||
3476 | |||
3477 | /* Apply dpm quirks */ | ||
3478 | while (p && p->chip_device != 0) { | ||
3479 | if (adev->pdev->vendor == p->chip_vendor && | ||
3480 | adev->pdev->device == p->chip_device && | ||
3481 | adev->pdev->subsystem_vendor == p->subsys_vendor && | ||
3482 | adev->pdev->subsystem_device == p->subsys_device) { | ||
3483 | max_sclk = p->max_sclk; | ||
3484 | max_mclk = p->max_mclk; | ||
3485 | break; | ||
3486 | } | ||
3487 | ++p; | ||
3488 | } | ||
3489 | |||
3490 | if (rps->vce_active) { | ||
3491 | rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk; | ||
3492 | rps->ecclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].ecclk; | ||
3493 | si_get_vce_clock_voltage(adev, rps->evclk, rps->ecclk, | ||
3494 | &min_vce_voltage); | ||
3495 | } else { | ||
3496 | rps->evclk = 0; | ||
3497 | rps->ecclk = 0; | ||
3498 | } | ||
3499 | |||
3500 | if ((adev->pm.dpm.new_active_crtc_count > 1) || | ||
3501 | si_dpm_vblank_too_short(adev)) | ||
3502 | disable_mclk_switching = true; | ||
3503 | |||
3504 | if (rps->vclk || rps->dclk) { | ||
3505 | disable_mclk_switching = true; | ||
3506 | disable_sclk_switching = true; | ||
3507 | } | ||
3508 | |||
3509 | if (adev->pm.dpm.ac_power) | ||
3510 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | ||
3511 | else | ||
3512 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | ||
3513 | |||
3514 | for (i = ps->performance_level_count - 2; i >= 0; i--) { | ||
3515 | if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc) | ||
3516 | ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc; | ||
3517 | } | ||
3518 | if (adev->pm.dpm.ac_power == false) { | ||
3519 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3520 | if (ps->performance_levels[i].mclk > max_limits->mclk) | ||
3521 | ps->performance_levels[i].mclk = max_limits->mclk; | ||
3522 | if (ps->performance_levels[i].sclk > max_limits->sclk) | ||
3523 | ps->performance_levels[i].sclk = max_limits->sclk; | ||
3524 | if (ps->performance_levels[i].vddc > max_limits->vddc) | ||
3525 | ps->performance_levels[i].vddc = max_limits->vddc; | ||
3526 | if (ps->performance_levels[i].vddci > max_limits->vddci) | ||
3527 | ps->performance_levels[i].vddci = max_limits->vddci; | ||
3528 | } | ||
3529 | } | ||
3530 | |||
3531 | /* limit clocks to max supported clocks based on voltage dependency tables */ | ||
3532 | btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk, | ||
3533 | &max_sclk_vddc); | ||
3534 | btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk, | ||
3535 | &max_mclk_vddci); | ||
3536 | btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk, | ||
3537 | &max_mclk_vddc); | ||
3538 | |||
3539 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3540 | if (max_sclk_vddc) { | ||
3541 | if (ps->performance_levels[i].sclk > max_sclk_vddc) | ||
3542 | ps->performance_levels[i].sclk = max_sclk_vddc; | ||
3543 | } | ||
3544 | if (max_mclk_vddci) { | ||
3545 | if (ps->performance_levels[i].mclk > max_mclk_vddci) | ||
3546 | ps->performance_levels[i].mclk = max_mclk_vddci; | ||
3547 | } | ||
3548 | if (max_mclk_vddc) { | ||
3549 | if (ps->performance_levels[i].mclk > max_mclk_vddc) | ||
3550 | ps->performance_levels[i].mclk = max_mclk_vddc; | ||
3551 | } | ||
3552 | if (max_mclk) { | ||
3553 | if (ps->performance_levels[i].mclk > max_mclk) | ||
3554 | ps->performance_levels[i].mclk = max_mclk; | ||
3555 | } | ||
3556 | if (max_sclk) { | ||
3557 | if (ps->performance_levels[i].sclk > max_sclk) | ||
3558 | ps->performance_levels[i].sclk = max_sclk; | ||
3559 | } | ||
3560 | } | ||
3561 | |||
3562 | /* XXX validate the min clocks required for display */ | ||
3563 | |||
3564 | if (disable_mclk_switching) { | ||
3565 | mclk = ps->performance_levels[ps->performance_level_count - 1].mclk; | ||
3566 | vddci = ps->performance_levels[ps->performance_level_count - 1].vddci; | ||
3567 | } else { | ||
3568 | mclk = ps->performance_levels[0].mclk; | ||
3569 | vddci = ps->performance_levels[0].vddci; | ||
3570 | } | ||
3571 | |||
3572 | if (disable_sclk_switching) { | ||
3573 | sclk = ps->performance_levels[ps->performance_level_count - 1].sclk; | ||
3574 | vddc = ps->performance_levels[ps->performance_level_count - 1].vddc; | ||
3575 | } else { | ||
3576 | sclk = ps->performance_levels[0].sclk; | ||
3577 | vddc = ps->performance_levels[0].vddc; | ||
3578 | } | ||
3579 | |||
3580 | if (rps->vce_active) { | ||
3581 | if (sclk < adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].sclk) | ||
3582 | sclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].sclk; | ||
3583 | if (mclk < adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].mclk) | ||
3584 | mclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].mclk; | ||
3585 | } | ||
3586 | |||
3587 | /* adjusted low state */ | ||
3588 | ps->performance_levels[0].sclk = sclk; | ||
3589 | ps->performance_levels[0].mclk = mclk; | ||
3590 | ps->performance_levels[0].vddc = vddc; | ||
3591 | ps->performance_levels[0].vddci = vddci; | ||
3592 | |||
3593 | if (disable_sclk_switching) { | ||
3594 | sclk = ps->performance_levels[0].sclk; | ||
3595 | for (i = 1; i < ps->performance_level_count; i++) { | ||
3596 | if (sclk < ps->performance_levels[i].sclk) | ||
3597 | sclk = ps->performance_levels[i].sclk; | ||
3598 | } | ||
3599 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3600 | ps->performance_levels[i].sclk = sclk; | ||
3601 | ps->performance_levels[i].vddc = vddc; | ||
3602 | } | ||
3603 | } else { | ||
3604 | for (i = 1; i < ps->performance_level_count; i++) { | ||
3605 | if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk) | ||
3606 | ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk; | ||
3607 | if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc) | ||
3608 | ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc; | ||
3609 | } | ||
3610 | } | ||
3611 | |||
3612 | if (disable_mclk_switching) { | ||
3613 | mclk = ps->performance_levels[0].mclk; | ||
3614 | for (i = 1; i < ps->performance_level_count; i++) { | ||
3615 | if (mclk < ps->performance_levels[i].mclk) | ||
3616 | mclk = ps->performance_levels[i].mclk; | ||
3617 | } | ||
3618 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3619 | ps->performance_levels[i].mclk = mclk; | ||
3620 | ps->performance_levels[i].vddci = vddci; | ||
3621 | } | ||
3622 | } else { | ||
3623 | for (i = 1; i < ps->performance_level_count; i++) { | ||
3624 | if (ps->performance_levels[i].mclk < ps->performance_levels[i - 1].mclk) | ||
3625 | ps->performance_levels[i].mclk = ps->performance_levels[i - 1].mclk; | ||
3626 | if (ps->performance_levels[i].vddci < ps->performance_levels[i - 1].vddci) | ||
3627 | ps->performance_levels[i].vddci = ps->performance_levels[i - 1].vddci; | ||
3628 | } | ||
3629 | } | ||
3630 | |||
3631 | for (i = 0; i < ps->performance_level_count; i++) | ||
3632 | btc_adjust_clock_combinations(adev, max_limits, | ||
3633 | &ps->performance_levels[i]); | ||
3634 | |||
3635 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3636 | if (ps->performance_levels[i].vddc < min_vce_voltage) | ||
3637 | ps->performance_levels[i].vddc = min_vce_voltage; | ||
3638 | btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk, | ||
3639 | ps->performance_levels[i].sclk, | ||
3640 | max_limits->vddc, &ps->performance_levels[i].vddc); | ||
3641 | btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk, | ||
3642 | ps->performance_levels[i].mclk, | ||
3643 | max_limits->vddci, &ps->performance_levels[i].vddci); | ||
3644 | btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk, | ||
3645 | ps->performance_levels[i].mclk, | ||
3646 | max_limits->vddc, &ps->performance_levels[i].vddc); | ||
3647 | btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk, | ||
3648 | adev->clock.current_dispclk, | ||
3649 | max_limits->vddc, &ps->performance_levels[i].vddc); | ||
3650 | } | ||
3651 | |||
3652 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3653 | btc_apply_voltage_delta_rules(adev, | ||
3654 | max_limits->vddc, max_limits->vddci, | ||
3655 | &ps->performance_levels[i].vddc, | ||
3656 | &ps->performance_levels[i].vddci); | ||
3657 | } | ||
3658 | |||
3659 | ps->dc_compatible = true; | ||
3660 | for (i = 0; i < ps->performance_level_count; i++) { | ||
3661 | if (ps->performance_levels[i].vddc > adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) | ||
3662 | ps->dc_compatible = false; | ||
3663 | } | ||
3664 | } | ||
3665 | |||
3666 | #if 0 | ||
3667 | static int si_read_smc_soft_register(struct amdgpu_device *adev, | ||
3668 | u16 reg_offset, u32 *value) | ||
3669 | { | ||
3670 | struct si_power_info *si_pi = si_get_pi(adev); | ||
3671 | |||
3672 | return amdgpu_si_read_smc_sram_dword(adev, | ||
3673 | si_pi->soft_regs_start + reg_offset, value, | ||
3674 | si_pi->sram_end); | ||
3675 | } | ||
3676 | #endif | ||
3677 | |||
3678 | static int si_write_smc_soft_register(struct amdgpu_device *adev, | ||
3679 | u16 reg_offset, u32 value) | ||
3680 | { | ||
3681 | struct si_power_info *si_pi = si_get_pi(adev); | ||
3682 | |||
3683 | return amdgpu_si_write_smc_sram_dword(adev, | ||
3684 | si_pi->soft_regs_start + reg_offset, | ||
3685 | value, si_pi->sram_end); | ||
3686 | } | ||
3687 | |||
3688 | static bool si_is_special_1gb_platform(struct amdgpu_device *adev) | ||
3689 | { | ||
3690 | bool ret = false; | ||
3691 | u32 tmp, width, row, column, bank, density; | ||
3692 | bool is_memory_gddr5, is_special; | ||
3693 | |||
3694 | tmp = RREG32(MC_SEQ_MISC0); | ||
3695 | is_memory_gddr5 = (MC_SEQ_MISC0_GDDR5_VALUE == ((tmp & MC_SEQ_MISC0_GDDR5_MASK) >> MC_SEQ_MISC0_GDDR5_SHIFT)); | ||
3696 | is_special = (MC_SEQ_MISC0_REV_ID_VALUE == ((tmp & MC_SEQ_MISC0_REV_ID_MASK) >> MC_SEQ_MISC0_REV_ID_SHIFT)) | ||
3697 | & (MC_SEQ_MISC0_VEN_ID_VALUE == ((tmp & MC_SEQ_MISC0_VEN_ID_MASK) >> MC_SEQ_MISC0_VEN_ID_SHIFT)); | ||
3698 | |||
3699 | WREG32(MC_SEQ_IO_DEBUG_INDEX, 0xb); | ||
3700 | width = ((RREG32(MC_SEQ_IO_DEBUG_DATA) >> 1) & 1) ? 16 : 32; | ||
3701 | |||
3702 | tmp = RREG32(MC_ARB_RAMCFG); | ||
3703 | row = ((tmp & NOOFROWS_MASK) >> NOOFROWS_SHIFT) + 10; | ||
3704 | column = ((tmp & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) + 8; | ||
3705 | bank = ((tmp & NOOFBANK_MASK) >> NOOFBANK_SHIFT) + 2; | ||
3706 | |||
3707 | density = (1 << (row + column - 20 + bank)) * width; | ||
3708 | |||
3709 | if ((adev->pdev->device == 0x6819) && | ||
3710 | is_memory_gddr5 && is_special && (density == 0x400)) | ||
3711 | ret = true; | ||
3712 | |||
3713 | return ret; | ||
3714 | } | ||
3715 | |||
3716 | static void si_get_leakage_vddc(struct amdgpu_device *adev) | ||
3717 | { | ||
3718 | struct si_power_info *si_pi = si_get_pi(adev); | ||
3719 | u16 vddc, count = 0; | ||
3720 | int i, ret; | ||
3721 | |||
3722 | for (i = 0; i < SISLANDS_MAX_LEAKAGE_COUNT; i++) { | ||
3723 | ret = amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(adev, &vddc, SISLANDS_LEAKAGE_INDEX0 + i); | ||
3724 | |||
3725 | if (!ret && (vddc > 0) && (vddc != (SISLANDS_LEAKAGE_INDEX0 + i))) { | ||
3726 | si_pi->leakage_voltage.entries[count].voltage = vddc; | ||
3727 | si_pi->leakage_voltage.entries[count].leakage_index = | ||
3728 | SISLANDS_LEAKAGE_INDEX0 + i; | ||
3729 | count++; | ||
3730 | } | ||
3731 | } | ||
3732 | si_pi->leakage_voltage.count = count; | ||
3733 | } | ||
3734 | |||
3735 | static int si_get_leakage_voltage_from_leakage_index(struct amdgpu_device *adev, | ||
3736 | u32 index, u16 *leakage_voltage) | ||
3737 | { | ||
3738 | struct si_power_info *si_pi = si_get_pi(adev); | ||
3739 | int i; | ||
3740 | |||
3741 | if (leakage_voltage == NULL) | ||
3742 | return -EINVAL; | ||
3743 | |||
3744 | if ((index & 0xff00) != 0xff00) | ||
3745 | return -EINVAL; | ||
3746 | |||
3747 | if ((index & 0xff) > SISLANDS_MAX_LEAKAGE_COUNT + 1) | ||
3748 | return -EINVAL; | ||
3749 | |||
3750 | if (index < SISLANDS_LEAKAGE_INDEX0) | ||
3751 | return -EINVAL; | ||
3752 | |||
3753 | for (i = 0; i < si_pi->leakage_voltage.count; i++) { | ||
3754 | if (si_pi->leakage_voltage.entries[i].leakage_index == index) { | ||
3755 | *leakage_voltage = si_pi->leakage_voltage.entries[i].voltage; | ||
3756 | return 0; | ||
3757 | } | ||
3758 | } | ||
3759 | return -EAGAIN; | ||
3760 | } | ||
3761 | |||
3762 | static void si_set_dpm_event_sources(struct amdgpu_device *adev, u32 sources) | ||
3763 | { | ||
3764 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
3765 | bool want_thermal_protection; | ||
3766 | enum amdgpu_dpm_event_src dpm_event_src; | ||
3767 | |||
3768 | switch (sources) { | ||
3769 | case 0: | ||
3770 | default: | ||
3771 | want_thermal_protection = false; | ||
3772 | break; | ||
3773 | case (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL): | ||
3774 | want_thermal_protection = true; | ||
3775 | dpm_event_src = AMDGPU_DPM_EVENT_SRC_DIGITAL; | ||
3776 | break; | ||
3777 | case (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL): | ||
3778 | want_thermal_protection = true; | ||
3779 | dpm_event_src = AMDGPU_DPM_EVENT_SRC_EXTERNAL; | ||
3780 | break; | ||
3781 | case ((1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL) | | ||
3782 | (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL)): | ||
3783 | want_thermal_protection = true; | ||
3784 | dpm_event_src = AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL; | ||
3785 | break; | ||
3786 | } | ||
3787 | |||
3788 | if (want_thermal_protection) { | ||
3789 | WREG32_P(CG_THERMAL_CTRL, DPM_EVENT_SRC(dpm_event_src), ~DPM_EVENT_SRC_MASK); | ||
3790 | if (pi->thermal_protection) | ||
3791 | WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS); | ||
3792 | } else { | ||
3793 | WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS); | ||
3794 | } | ||
3795 | } | ||
3796 | |||
3797 | static void si_enable_auto_throttle_source(struct amdgpu_device *adev, | ||
3798 | enum amdgpu_dpm_auto_throttle_src source, | ||
3799 | bool enable) | ||
3800 | { | ||
3801 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
3802 | |||
3803 | if (enable) { | ||
3804 | if (!(pi->active_auto_throttle_sources & (1 << source))) { | ||
3805 | pi->active_auto_throttle_sources |= 1 << source; | ||
3806 | si_set_dpm_event_sources(adev, pi->active_auto_throttle_sources); | ||
3807 | } | ||
3808 | } else { | ||
3809 | if (pi->active_auto_throttle_sources & (1 << source)) { | ||
3810 | pi->active_auto_throttle_sources &= ~(1 << source); | ||
3811 | si_set_dpm_event_sources(adev, pi->active_auto_throttle_sources); | ||
3812 | } | ||
3813 | } | ||
3814 | } | ||
3815 | |||
3816 | static void si_start_dpm(struct amdgpu_device *adev) | ||
3817 | { | ||
3818 | WREG32_P(GENERAL_PWRMGT, GLOBAL_PWRMGT_EN, ~GLOBAL_PWRMGT_EN); | ||
3819 | } | ||
3820 | |||
3821 | static void si_stop_dpm(struct amdgpu_device *adev) | ||
3822 | { | ||
3823 | WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN); | ||
3824 | } | ||
3825 | |||
3826 | static void si_enable_sclk_control(struct amdgpu_device *adev, bool enable) | ||
3827 | { | ||
3828 | if (enable) | ||
3829 | WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF); | ||
3830 | else | ||
3831 | WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF); | ||
3832 | |||
3833 | } | ||
3834 | |||
3835 | #if 0 | ||
3836 | static int si_notify_hardware_of_thermal_state(struct amdgpu_device *adev, | ||
3837 | u32 thermal_level) | ||
3838 | { | ||
3839 | PPSMC_Result ret; | ||
3840 | |||
3841 | if (thermal_level == 0) { | ||
3842 | ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableThermalInterrupt); | ||
3843 | if (ret == PPSMC_Result_OK) | ||
3844 | return 0; | ||
3845 | else | ||
3846 | return -EINVAL; | ||
3847 | } | ||
3848 | return 0; | ||
3849 | } | ||
3850 | |||
3851 | static void si_notify_hardware_vpu_recovery_event(struct amdgpu_device *adev) | ||
3852 | { | ||
3853 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen, true); | ||
3854 | } | ||
3855 | #endif | ||
3856 | |||
3857 | #if 0 | ||
3858 | static int si_notify_hw_of_powersource(struct amdgpu_device *adev, bool ac_power) | ||
3859 | { | ||
3860 | if (ac_power) | ||
3861 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ? | ||
3862 | 0 : -EINVAL; | ||
3863 | |||
3864 | return 0; | ||
3865 | } | ||
3866 | #endif | ||
3867 | |||
3868 | static PPSMC_Result si_send_msg_to_smc_with_parameter(struct amdgpu_device *adev, | ||
3869 | PPSMC_Msg msg, u32 parameter) | ||
3870 | { | ||
3871 | WREG32(SMC_SCRATCH0, parameter); | ||
3872 | return amdgpu_si_send_msg_to_smc(adev, msg); | ||
3873 | } | ||
3874 | |||
3875 | static int si_restrict_performance_levels_before_switch(struct amdgpu_device *adev) | ||
3876 | { | ||
3877 | if (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_NoForcedLevel) != PPSMC_Result_OK) | ||
3878 | return -EINVAL; | ||
3879 | |||
3880 | return (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) == PPSMC_Result_OK) ? | ||
3881 | 0 : -EINVAL; | ||
3882 | } | ||
3883 | |||
3884 | static int si_dpm_force_performance_level(struct amdgpu_device *adev, | ||
3885 | enum amdgpu_dpm_forced_level level) | ||
3886 | { | ||
3887 | struct amdgpu_ps *rps = adev->pm.dpm.current_ps; | ||
3888 | struct si_ps *ps = si_get_ps(rps); | ||
3889 | u32 levels = ps->performance_level_count; | ||
3890 | |||
3891 | if (level == AMDGPU_DPM_FORCED_LEVEL_HIGH) { | ||
3892 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK) | ||
3893 | return -EINVAL; | ||
3894 | |||
3895 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK) | ||
3896 | return -EINVAL; | ||
3897 | } else if (level == AMDGPU_DPM_FORCED_LEVEL_LOW) { | ||
3898 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK) | ||
3899 | return -EINVAL; | ||
3900 | |||
3901 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK) | ||
3902 | return -EINVAL; | ||
3903 | } else if (level == AMDGPU_DPM_FORCED_LEVEL_AUTO) { | ||
3904 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK) | ||
3905 | return -EINVAL; | ||
3906 | |||
3907 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK) | ||
3908 | return -EINVAL; | ||
3909 | } | ||
3910 | |||
3911 | adev->pm.dpm.forced_level = level; | ||
3912 | |||
3913 | return 0; | ||
3914 | } | ||
3915 | |||
3916 | #if 0 | ||
3917 | static int si_set_boot_state(struct amdgpu_device *adev) | ||
3918 | { | ||
3919 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToInitialState) == PPSMC_Result_OK) ? | ||
3920 | 0 : -EINVAL; | ||
3921 | } | ||
3922 | #endif | ||
3923 | |||
3924 | static int si_set_sw_state(struct amdgpu_device *adev) | ||
3925 | { | ||
3926 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToSwState) == PPSMC_Result_OK) ? | ||
3927 | 0 : -EINVAL; | ||
3928 | } | ||
3929 | |||
3930 | static int si_halt_smc(struct amdgpu_device *adev) | ||
3931 | { | ||
3932 | if (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_Halt) != PPSMC_Result_OK) | ||
3933 | return -EINVAL; | ||
3934 | |||
3935 | return (amdgpu_si_wait_for_smc_inactive(adev) == PPSMC_Result_OK) ? | ||
3936 | 0 : -EINVAL; | ||
3937 | } | ||
3938 | |||
3939 | static int si_resume_smc(struct amdgpu_device *adev) | ||
3940 | { | ||
3941 | if (amdgpu_si_send_msg_to_smc(adev, PPSMC_FlushDataCache) != PPSMC_Result_OK) | ||
3942 | return -EINVAL; | ||
3943 | |||
3944 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_Resume) == PPSMC_Result_OK) ? | ||
3945 | 0 : -EINVAL; | ||
3946 | } | ||
3947 | |||
3948 | static void si_dpm_start_smc(struct amdgpu_device *adev) | ||
3949 | { | ||
3950 | amdgpu_si_program_jump_on_start(adev); | ||
3951 | amdgpu_si_start_smc(adev); | ||
3952 | amdgpu_si_smc_clock(adev, true); | ||
3953 | } | ||
3954 | |||
3955 | static void si_dpm_stop_smc(struct amdgpu_device *adev) | ||
3956 | { | ||
3957 | amdgpu_si_reset_smc(adev); | ||
3958 | amdgpu_si_smc_clock(adev, false); | ||
3959 | } | ||
3960 | |||
3961 | static int si_process_firmware_header(struct amdgpu_device *adev) | ||
3962 | { | ||
3963 | struct si_power_info *si_pi = si_get_pi(adev); | ||
3964 | u32 tmp; | ||
3965 | int ret; | ||
3966 | |||
3967 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
3968 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
3969 | SISLANDS_SMC_FIRMWARE_HEADER_stateTable, | ||
3970 | &tmp, si_pi->sram_end); | ||
3971 | if (ret) | ||
3972 | return ret; | ||
3973 | |||
3974 | si_pi->state_table_start = tmp; | ||
3975 | |||
3976 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
3977 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
3978 | SISLANDS_SMC_FIRMWARE_HEADER_softRegisters, | ||
3979 | &tmp, si_pi->sram_end); | ||
3980 | if (ret) | ||
3981 | return ret; | ||
3982 | |||
3983 | si_pi->soft_regs_start = tmp; | ||
3984 | |||
3985 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
3986 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
3987 | SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable, | ||
3988 | &tmp, si_pi->sram_end); | ||
3989 | if (ret) | ||
3990 | return ret; | ||
3991 | |||
3992 | si_pi->mc_reg_table_start = tmp; | ||
3993 | |||
3994 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
3995 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
3996 | SISLANDS_SMC_FIRMWARE_HEADER_fanTable, | ||
3997 | &tmp, si_pi->sram_end); | ||
3998 | if (ret) | ||
3999 | return ret; | ||
4000 | |||
4001 | si_pi->fan_table_start = tmp; | ||
4002 | |||
4003 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
4004 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
4005 | SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable, | ||
4006 | &tmp, si_pi->sram_end); | ||
4007 | if (ret) | ||
4008 | return ret; | ||
4009 | |||
4010 | si_pi->arb_table_start = tmp; | ||
4011 | |||
4012 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
4013 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
4014 | SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable, | ||
4015 | &tmp, si_pi->sram_end); | ||
4016 | if (ret) | ||
4017 | return ret; | ||
4018 | |||
4019 | si_pi->cac_table_start = tmp; | ||
4020 | |||
4021 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
4022 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
4023 | SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration, | ||
4024 | &tmp, si_pi->sram_end); | ||
4025 | if (ret) | ||
4026 | return ret; | ||
4027 | |||
4028 | si_pi->dte_table_start = tmp; | ||
4029 | |||
4030 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
4031 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
4032 | SISLANDS_SMC_FIRMWARE_HEADER_spllTable, | ||
4033 | &tmp, si_pi->sram_end); | ||
4034 | if (ret) | ||
4035 | return ret; | ||
4036 | |||
4037 | si_pi->spll_table_start = tmp; | ||
4038 | |||
4039 | ret = amdgpu_si_read_smc_sram_dword(adev, | ||
4040 | SISLANDS_SMC_FIRMWARE_HEADER_LOCATION + | ||
4041 | SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters, | ||
4042 | &tmp, si_pi->sram_end); | ||
4043 | if (ret) | ||
4044 | return ret; | ||
4045 | |||
4046 | si_pi->papm_cfg_table_start = tmp; | ||
4047 | |||
4048 | return ret; | ||
4049 | } | ||
4050 | |||
4051 | static void si_read_clock_registers(struct amdgpu_device *adev) | ||
4052 | { | ||
4053 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4054 | |||
4055 | si_pi->clock_registers.cg_spll_func_cntl = RREG32(CG_SPLL_FUNC_CNTL); | ||
4056 | si_pi->clock_registers.cg_spll_func_cntl_2 = RREG32(CG_SPLL_FUNC_CNTL_2); | ||
4057 | si_pi->clock_registers.cg_spll_func_cntl_3 = RREG32(CG_SPLL_FUNC_CNTL_3); | ||
4058 | si_pi->clock_registers.cg_spll_func_cntl_4 = RREG32(CG_SPLL_FUNC_CNTL_4); | ||
4059 | si_pi->clock_registers.cg_spll_spread_spectrum = RREG32(CG_SPLL_SPREAD_SPECTRUM); | ||
4060 | si_pi->clock_registers.cg_spll_spread_spectrum_2 = RREG32(CG_SPLL_SPREAD_SPECTRUM_2); | ||
4061 | si_pi->clock_registers.dll_cntl = RREG32(DLL_CNTL); | ||
4062 | si_pi->clock_registers.mclk_pwrmgt_cntl = RREG32(MCLK_PWRMGT_CNTL); | ||
4063 | si_pi->clock_registers.mpll_ad_func_cntl = RREG32(MPLL_AD_FUNC_CNTL); | ||
4064 | si_pi->clock_registers.mpll_dq_func_cntl = RREG32(MPLL_DQ_FUNC_CNTL); | ||
4065 | si_pi->clock_registers.mpll_func_cntl = RREG32(MPLL_FUNC_CNTL); | ||
4066 | si_pi->clock_registers.mpll_func_cntl_1 = RREG32(MPLL_FUNC_CNTL_1); | ||
4067 | si_pi->clock_registers.mpll_func_cntl_2 = RREG32(MPLL_FUNC_CNTL_2); | ||
4068 | si_pi->clock_registers.mpll_ss1 = RREG32(MPLL_SS1); | ||
4069 | si_pi->clock_registers.mpll_ss2 = RREG32(MPLL_SS2); | ||
4070 | } | ||
4071 | |||
4072 | static void si_enable_thermal_protection(struct amdgpu_device *adev, | ||
4073 | bool enable) | ||
4074 | { | ||
4075 | if (enable) | ||
4076 | WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS); | ||
4077 | else | ||
4078 | WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS); | ||
4079 | } | ||
4080 | |||
4081 | static void si_enable_acpi_power_management(struct amdgpu_device *adev) | ||
4082 | { | ||
4083 | WREG32_P(GENERAL_PWRMGT, STATIC_PM_EN, ~STATIC_PM_EN); | ||
4084 | } | ||
4085 | |||
4086 | #if 0 | ||
4087 | static int si_enter_ulp_state(struct amdgpu_device *adev) | ||
4088 | { | ||
4089 | WREG32(SMC_MESSAGE_0, PPSMC_MSG_SwitchToMinimumPower); | ||
4090 | |||
4091 | udelay(25000); | ||
4092 | |||
4093 | return 0; | ||
4094 | } | ||
4095 | |||
4096 | static int si_exit_ulp_state(struct amdgpu_device *adev) | ||
4097 | { | ||
4098 | int i; | ||
4099 | |||
4100 | WREG32(SMC_MESSAGE_0, PPSMC_MSG_ResumeFromMinimumPower); | ||
4101 | |||
4102 | udelay(7000); | ||
4103 | |||
4104 | for (i = 0; i < adev->usec_timeout; i++) { | ||
4105 | if (RREG32(SMC_RESP_0) == 1) | ||
4106 | break; | ||
4107 | udelay(1000); | ||
4108 | } | ||
4109 | |||
4110 | return 0; | ||
4111 | } | ||
4112 | #endif | ||
4113 | |||
4114 | static int si_notify_smc_display_change(struct amdgpu_device *adev, | ||
4115 | bool has_display) | ||
4116 | { | ||
4117 | PPSMC_Msg msg = has_display ? | ||
4118 | PPSMC_MSG_HasDisplay : PPSMC_MSG_NoDisplay; | ||
4119 | |||
4120 | return (amdgpu_si_send_msg_to_smc(adev, msg) == PPSMC_Result_OK) ? | ||
4121 | 0 : -EINVAL; | ||
4122 | } | ||
4123 | |||
4124 | static void si_program_response_times(struct amdgpu_device *adev) | ||
4125 | { | ||
4126 | u32 voltage_response_time, backbias_response_time, acpi_delay_time, vbi_time_out; | ||
4127 | u32 vddc_dly, acpi_dly, vbi_dly; | ||
4128 | u32 reference_clock; | ||
4129 | |||
4130 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mvdd_chg_time, 1); | ||
4131 | |||
4132 | voltage_response_time = (u32)adev->pm.dpm.voltage_response_time; | ||
4133 | backbias_response_time = (u32)adev->pm.dpm.backbias_response_time; | ||
4134 | |||
4135 | if (voltage_response_time == 0) | ||
4136 | voltage_response_time = 1000; | ||
4137 | |||
4138 | acpi_delay_time = 15000; | ||
4139 | vbi_time_out = 100000; | ||
4140 | |||
4141 | reference_clock = amdgpu_asic_get_xclk(adev); | ||
4142 | |||
4143 | vddc_dly = (voltage_response_time * reference_clock) / 100; | ||
4144 | acpi_dly = (acpi_delay_time * reference_clock) / 100; | ||
4145 | vbi_dly = (vbi_time_out * reference_clock) / 100; | ||
4146 | |||
4147 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_delay_vreg, vddc_dly); | ||
4148 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_delay_acpi, acpi_dly); | ||
4149 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mclk_chg_timeout, vbi_dly); | ||
4150 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mc_block_delay, 0xAA); | ||
4151 | } | ||
4152 | |||
4153 | static void si_program_ds_registers(struct amdgpu_device *adev) | ||
4154 | { | ||
4155 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
4156 | u32 tmp; | ||
4157 | |||
4158 | /* DEEP_SLEEP_CLK_SEL field should be 0x10 on tahiti A0 */ | ||
4159 | if (adev->asic_type == CHIP_TAHITI && adev->rev_id == 0x0) | ||
4160 | tmp = 0x10; | ||
4161 | else | ||
4162 | tmp = 0x1; | ||
4163 | |||
4164 | if (eg_pi->sclk_deep_sleep) { | ||
4165 | WREG32_P(MISC_CLK_CNTL, DEEP_SLEEP_CLK_SEL(tmp), ~DEEP_SLEEP_CLK_SEL_MASK); | ||
4166 | WREG32_P(CG_SPLL_AUTOSCALE_CNTL, AUTOSCALE_ON_SS_CLEAR, | ||
4167 | ~AUTOSCALE_ON_SS_CLEAR); | ||
4168 | } | ||
4169 | } | ||
4170 | |||
4171 | static void si_program_display_gap(struct amdgpu_device *adev) | ||
4172 | { | ||
4173 | u32 tmp, pipe; | ||
4174 | int i; | ||
4175 | |||
4176 | tmp = RREG32(CG_DISPLAY_GAP_CNTL) & ~(DISP1_GAP_MASK | DISP2_GAP_MASK); | ||
4177 | if (adev->pm.dpm.new_active_crtc_count > 0) | ||
4178 | tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM); | ||
4179 | else | ||
4180 | tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE); | ||
4181 | |||
4182 | if (adev->pm.dpm.new_active_crtc_count > 1) | ||
4183 | tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM); | ||
4184 | else | ||
4185 | tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE); | ||
4186 | |||
4187 | WREG32(CG_DISPLAY_GAP_CNTL, tmp); | ||
4188 | |||
4189 | tmp = RREG32(DCCG_DISP_SLOW_SELECT_REG); | ||
4190 | pipe = (tmp & DCCG_DISP1_SLOW_SELECT_MASK) >> DCCG_DISP1_SLOW_SELECT_SHIFT; | ||
4191 | |||
4192 | if ((adev->pm.dpm.new_active_crtc_count > 0) && | ||
4193 | (!(adev->pm.dpm.new_active_crtcs & (1 << pipe)))) { | ||
4194 | /* find the first active crtc */ | ||
4195 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
4196 | if (adev->pm.dpm.new_active_crtcs & (1 << i)) | ||
4197 | break; | ||
4198 | } | ||
4199 | if (i == adev->mode_info.num_crtc) | ||
4200 | pipe = 0; | ||
4201 | else | ||
4202 | pipe = i; | ||
4203 | |||
4204 | tmp &= ~DCCG_DISP1_SLOW_SELECT_MASK; | ||
4205 | tmp |= DCCG_DISP1_SLOW_SELECT(pipe); | ||
4206 | WREG32(DCCG_DISP_SLOW_SELECT_REG, tmp); | ||
4207 | } | ||
4208 | |||
4209 | /* Setting this to false forces the performance state to low if the crtcs are disabled. | ||
4210 | * This can be a problem on PowerXpress systems or if you want to use the card | ||
4211 | * for offscreen rendering or compute if there are no crtcs enabled. | ||
4212 | */ | ||
4213 | si_notify_smc_display_change(adev, adev->pm.dpm.new_active_crtc_count > 0); | ||
4214 | } | ||
4215 | |||
4216 | static void si_enable_spread_spectrum(struct amdgpu_device *adev, bool enable) | ||
4217 | { | ||
4218 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4219 | |||
4220 | if (enable) { | ||
4221 | if (pi->sclk_ss) | ||
4222 | WREG32_P(GENERAL_PWRMGT, DYN_SPREAD_SPECTRUM_EN, ~DYN_SPREAD_SPECTRUM_EN); | ||
4223 | } else { | ||
4224 | WREG32_P(CG_SPLL_SPREAD_SPECTRUM, 0, ~SSEN); | ||
4225 | WREG32_P(GENERAL_PWRMGT, 0, ~DYN_SPREAD_SPECTRUM_EN); | ||
4226 | } | ||
4227 | } | ||
4228 | |||
4229 | static void si_setup_bsp(struct amdgpu_device *adev) | ||
4230 | { | ||
4231 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4232 | u32 xclk = amdgpu_asic_get_xclk(adev); | ||
4233 | |||
4234 | r600_calculate_u_and_p(pi->asi, | ||
4235 | xclk, | ||
4236 | 16, | ||
4237 | &pi->bsp, | ||
4238 | &pi->bsu); | ||
4239 | |||
4240 | r600_calculate_u_and_p(pi->pasi, | ||
4241 | xclk, | ||
4242 | 16, | ||
4243 | &pi->pbsp, | ||
4244 | &pi->pbsu); | ||
4245 | |||
4246 | |||
4247 | pi->dsp = BSP(pi->bsp) | BSU(pi->bsu); | ||
4248 | pi->psp = BSP(pi->pbsp) | BSU(pi->pbsu); | ||
4249 | |||
4250 | WREG32(CG_BSP, pi->dsp); | ||
4251 | } | ||
4252 | |||
4253 | static void si_program_git(struct amdgpu_device *adev) | ||
4254 | { | ||
4255 | WREG32_P(CG_GIT, CG_GICST(R600_GICST_DFLT), ~CG_GICST_MASK); | ||
4256 | } | ||
4257 | |||
4258 | static void si_program_tp(struct amdgpu_device *adev) | ||
4259 | { | ||
4260 | int i; | ||
4261 | enum r600_td td = R600_TD_DFLT; | ||
4262 | |||
4263 | for (i = 0; i < R600_PM_NUMBER_OF_TC; i++) | ||
4264 | WREG32(CG_FFCT_0 + i, (UTC_0(r600_utc[i]) | DTC_0(r600_dtc[i]))); | ||
4265 | |||
4266 | if (td == R600_TD_AUTO) | ||
4267 | WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_FORCE_TREND_SEL); | ||
4268 | else | ||
4269 | WREG32_P(SCLK_PWRMGT_CNTL, FIR_FORCE_TREND_SEL, ~FIR_FORCE_TREND_SEL); | ||
4270 | |||
4271 | if (td == R600_TD_UP) | ||
4272 | WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_TREND_MODE); | ||
4273 | |||
4274 | if (td == R600_TD_DOWN) | ||
4275 | WREG32_P(SCLK_PWRMGT_CNTL, FIR_TREND_MODE, ~FIR_TREND_MODE); | ||
4276 | } | ||
4277 | |||
4278 | static void si_program_tpp(struct amdgpu_device *adev) | ||
4279 | { | ||
4280 | WREG32(CG_TPC, R600_TPC_DFLT); | ||
4281 | } | ||
4282 | |||
4283 | static void si_program_sstp(struct amdgpu_device *adev) | ||
4284 | { | ||
4285 | WREG32(CG_SSP, (SSTU(R600_SSTU_DFLT) | SST(R600_SST_DFLT))); | ||
4286 | } | ||
4287 | |||
4288 | static void si_enable_display_gap(struct amdgpu_device *adev) | ||
4289 | { | ||
4290 | u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL); | ||
4291 | |||
4292 | tmp &= ~(DISP1_GAP_MASK | DISP2_GAP_MASK); | ||
4293 | tmp |= (DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE) | | ||
4294 | DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE)); | ||
4295 | |||
4296 | tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK); | ||
4297 | tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK) | | ||
4298 | DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE)); | ||
4299 | WREG32(CG_DISPLAY_GAP_CNTL, tmp); | ||
4300 | } | ||
4301 | |||
4302 | static void si_program_vc(struct amdgpu_device *adev) | ||
4303 | { | ||
4304 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4305 | |||
4306 | WREG32(CG_FTV, pi->vrc); | ||
4307 | } | ||
4308 | |||
4309 | static void si_clear_vc(struct amdgpu_device *adev) | ||
4310 | { | ||
4311 | WREG32(CG_FTV, 0); | ||
4312 | } | ||
4313 | |||
4314 | static u8 si_get_ddr3_mclk_frequency_ratio(u32 memory_clock) | ||
4315 | { | ||
4316 | u8 mc_para_index; | ||
4317 | |||
4318 | if (memory_clock < 10000) | ||
4319 | mc_para_index = 0; | ||
4320 | else if (memory_clock >= 80000) | ||
4321 | mc_para_index = 0x0f; | ||
4322 | else | ||
4323 | mc_para_index = (u8)((memory_clock - 10000) / 5000 + 1); | ||
4324 | return mc_para_index; | ||
4325 | } | ||
4326 | |||
4327 | static u8 si_get_mclk_frequency_ratio(u32 memory_clock, bool strobe_mode) | ||
4328 | { | ||
4329 | u8 mc_para_index; | ||
4330 | |||
4331 | if (strobe_mode) { | ||
4332 | if (memory_clock < 12500) | ||
4333 | mc_para_index = 0x00; | ||
4334 | else if (memory_clock > 47500) | ||
4335 | mc_para_index = 0x0f; | ||
4336 | else | ||
4337 | mc_para_index = (u8)((memory_clock - 10000) / 2500); | ||
4338 | } else { | ||
4339 | if (memory_clock < 65000) | ||
4340 | mc_para_index = 0x00; | ||
4341 | else if (memory_clock > 135000) | ||
4342 | mc_para_index = 0x0f; | ||
4343 | else | ||
4344 | mc_para_index = (u8)((memory_clock - 60000) / 5000); | ||
4345 | } | ||
4346 | return mc_para_index; | ||
4347 | } | ||
4348 | |||
4349 | static u8 si_get_strobe_mode_settings(struct amdgpu_device *adev, u32 mclk) | ||
4350 | { | ||
4351 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4352 | bool strobe_mode = false; | ||
4353 | u8 result = 0; | ||
4354 | |||
4355 | if (mclk <= pi->mclk_strobe_mode_threshold) | ||
4356 | strobe_mode = true; | ||
4357 | |||
4358 | if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) | ||
4359 | result = si_get_mclk_frequency_ratio(mclk, strobe_mode); | ||
4360 | else | ||
4361 | result = si_get_ddr3_mclk_frequency_ratio(mclk); | ||
4362 | |||
4363 | if (strobe_mode) | ||
4364 | result |= SISLANDS_SMC_STROBE_ENABLE; | ||
4365 | |||
4366 | return result; | ||
4367 | } | ||
4368 | |||
4369 | static int si_upload_firmware(struct amdgpu_device *adev) | ||
4370 | { | ||
4371 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4372 | |||
4373 | amdgpu_si_reset_smc(adev); | ||
4374 | amdgpu_si_smc_clock(adev, false); | ||
4375 | |||
4376 | return amdgpu_si_load_smc_ucode(adev, si_pi->sram_end); | ||
4377 | } | ||
4378 | |||
4379 | static bool si_validate_phase_shedding_tables(struct amdgpu_device *adev, | ||
4380 | const struct atom_voltage_table *table, | ||
4381 | const struct amdgpu_phase_shedding_limits_table *limits) | ||
4382 | { | ||
4383 | u32 data, num_bits, num_levels; | ||
4384 | |||
4385 | if ((table == NULL) || (limits == NULL)) | ||
4386 | return false; | ||
4387 | |||
4388 | data = table->mask_low; | ||
4389 | |||
4390 | num_bits = hweight32(data); | ||
4391 | |||
4392 | if (num_bits == 0) | ||
4393 | return false; | ||
4394 | |||
4395 | num_levels = (1 << num_bits); | ||
4396 | |||
4397 | if (table->count != num_levels) | ||
4398 | return false; | ||
4399 | |||
4400 | if (limits->count != (num_levels - 1)) | ||
4401 | return false; | ||
4402 | |||
4403 | return true; | ||
4404 | } | ||
4405 | |||
4406 | static void si_trim_voltage_table_to_fit_state_table(struct amdgpu_device *adev, | ||
4407 | u32 max_voltage_steps, | ||
4408 | struct atom_voltage_table *voltage_table) | ||
4409 | { | ||
4410 | unsigned int i, diff; | ||
4411 | |||
4412 | if (voltage_table->count <= max_voltage_steps) | ||
4413 | return; | ||
4414 | |||
4415 | diff = voltage_table->count - max_voltage_steps; | ||
4416 | |||
4417 | for (i= 0; i < max_voltage_steps; i++) | ||
4418 | voltage_table->entries[i] = voltage_table->entries[i + diff]; | ||
4419 | |||
4420 | voltage_table->count = max_voltage_steps; | ||
4421 | } | ||
4422 | |||
4423 | static int si_get_svi2_voltage_table(struct amdgpu_device *adev, | ||
4424 | struct amdgpu_clock_voltage_dependency_table *voltage_dependency_table, | ||
4425 | struct atom_voltage_table *voltage_table) | ||
4426 | { | ||
4427 | u32 i; | ||
4428 | |||
4429 | if (voltage_dependency_table == NULL) | ||
4430 | return -EINVAL; | ||
4431 | |||
4432 | voltage_table->mask_low = 0; | ||
4433 | voltage_table->phase_delay = 0; | ||
4434 | |||
4435 | voltage_table->count = voltage_dependency_table->count; | ||
4436 | for (i = 0; i < voltage_table->count; i++) { | ||
4437 | voltage_table->entries[i].value = voltage_dependency_table->entries[i].v; | ||
4438 | voltage_table->entries[i].smio_low = 0; | ||
4439 | } | ||
4440 | |||
4441 | return 0; | ||
4442 | } | ||
4443 | |||
4444 | static int si_construct_voltage_tables(struct amdgpu_device *adev) | ||
4445 | { | ||
4446 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4447 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
4448 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4449 | int ret; | ||
4450 | |||
4451 | if (pi->voltage_control) { | ||
4452 | ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDC, | ||
4453 | VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddc_voltage_table); | ||
4454 | if (ret) | ||
4455 | return ret; | ||
4456 | |||
4457 | if (eg_pi->vddc_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS) | ||
4458 | si_trim_voltage_table_to_fit_state_table(adev, | ||
4459 | SISLANDS_MAX_NO_VREG_STEPS, | ||
4460 | &eg_pi->vddc_voltage_table); | ||
4461 | } else if (si_pi->voltage_control_svi2) { | ||
4462 | ret = si_get_svi2_voltage_table(adev, | ||
4463 | &adev->pm.dpm.dyn_state.vddc_dependency_on_mclk, | ||
4464 | &eg_pi->vddc_voltage_table); | ||
4465 | if (ret) | ||
4466 | return ret; | ||
4467 | } else { | ||
4468 | return -EINVAL; | ||
4469 | } | ||
4470 | |||
4471 | if (eg_pi->vddci_control) { | ||
4472 | ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDCI, | ||
4473 | VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddci_voltage_table); | ||
4474 | if (ret) | ||
4475 | return ret; | ||
4476 | |||
4477 | if (eg_pi->vddci_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS) | ||
4478 | si_trim_voltage_table_to_fit_state_table(adev, | ||
4479 | SISLANDS_MAX_NO_VREG_STEPS, | ||
4480 | &eg_pi->vddci_voltage_table); | ||
4481 | } | ||
4482 | if (si_pi->vddci_control_svi2) { | ||
4483 | ret = si_get_svi2_voltage_table(adev, | ||
4484 | &adev->pm.dpm.dyn_state.vddci_dependency_on_mclk, | ||
4485 | &eg_pi->vddci_voltage_table); | ||
4486 | if (ret) | ||
4487 | return ret; | ||
4488 | } | ||
4489 | |||
4490 | if (pi->mvdd_control) { | ||
4491 | ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_MVDDC, | ||
4492 | VOLTAGE_OBJ_GPIO_LUT, &si_pi->mvdd_voltage_table); | ||
4493 | |||
4494 | if (ret) { | ||
4495 | pi->mvdd_control = false; | ||
4496 | return ret; | ||
4497 | } | ||
4498 | |||
4499 | if (si_pi->mvdd_voltage_table.count == 0) { | ||
4500 | pi->mvdd_control = false; | ||
4501 | return -EINVAL; | ||
4502 | } | ||
4503 | |||
4504 | if (si_pi->mvdd_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS) | ||
4505 | si_trim_voltage_table_to_fit_state_table(adev, | ||
4506 | SISLANDS_MAX_NO_VREG_STEPS, | ||
4507 | &si_pi->mvdd_voltage_table); | ||
4508 | } | ||
4509 | |||
4510 | if (si_pi->vddc_phase_shed_control) { | ||
4511 | ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDC, | ||
4512 | VOLTAGE_OBJ_PHASE_LUT, &si_pi->vddc_phase_shed_table); | ||
4513 | if (ret) | ||
4514 | si_pi->vddc_phase_shed_control = false; | ||
4515 | |||
4516 | if ((si_pi->vddc_phase_shed_table.count == 0) || | ||
4517 | (si_pi->vddc_phase_shed_table.count > SISLANDS_MAX_NO_VREG_STEPS)) | ||
4518 | si_pi->vddc_phase_shed_control = false; | ||
4519 | } | ||
4520 | |||
4521 | return 0; | ||
4522 | } | ||
4523 | |||
4524 | static void si_populate_smc_voltage_table(struct amdgpu_device *adev, | ||
4525 | const struct atom_voltage_table *voltage_table, | ||
4526 | SISLANDS_SMC_STATETABLE *table) | ||
4527 | { | ||
4528 | unsigned int i; | ||
4529 | |||
4530 | for (i = 0; i < voltage_table->count; i++) | ||
4531 | table->lowSMIO[i] |= cpu_to_be32(voltage_table->entries[i].smio_low); | ||
4532 | } | ||
4533 | |||
4534 | static int si_populate_smc_voltage_tables(struct amdgpu_device *adev, | ||
4535 | SISLANDS_SMC_STATETABLE *table) | ||
4536 | { | ||
4537 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4538 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
4539 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4540 | u8 i; | ||
4541 | |||
4542 | if (si_pi->voltage_control_svi2) { | ||
4543 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc, | ||
4544 | si_pi->svc_gpio_id); | ||
4545 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd, | ||
4546 | si_pi->svd_gpio_id); | ||
4547 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_plat_type, | ||
4548 | 2); | ||
4549 | } else { | ||
4550 | if (eg_pi->vddc_voltage_table.count) { | ||
4551 | si_populate_smc_voltage_table(adev, &eg_pi->vddc_voltage_table, table); | ||
4552 | table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] = | ||
4553 | cpu_to_be32(eg_pi->vddc_voltage_table.mask_low); | ||
4554 | |||
4555 | for (i = 0; i < eg_pi->vddc_voltage_table.count; i++) { | ||
4556 | if (pi->max_vddc_in_table <= eg_pi->vddc_voltage_table.entries[i].value) { | ||
4557 | table->maxVDDCIndexInPPTable = i; | ||
4558 | break; | ||
4559 | } | ||
4560 | } | ||
4561 | } | ||
4562 | |||
4563 | if (eg_pi->vddci_voltage_table.count) { | ||
4564 | si_populate_smc_voltage_table(adev, &eg_pi->vddci_voltage_table, table); | ||
4565 | |||
4566 | table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDCI] = | ||
4567 | cpu_to_be32(eg_pi->vddci_voltage_table.mask_low); | ||
4568 | } | ||
4569 | |||
4570 | |||
4571 | if (si_pi->mvdd_voltage_table.count) { | ||
4572 | si_populate_smc_voltage_table(adev, &si_pi->mvdd_voltage_table, table); | ||
4573 | |||
4574 | table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_MVDD] = | ||
4575 | cpu_to_be32(si_pi->mvdd_voltage_table.mask_low); | ||
4576 | } | ||
4577 | |||
4578 | if (si_pi->vddc_phase_shed_control) { | ||
4579 | if (si_validate_phase_shedding_tables(adev, &si_pi->vddc_phase_shed_table, | ||
4580 | &adev->pm.dpm.dyn_state.phase_shedding_limits_table)) { | ||
4581 | si_populate_smc_voltage_table(adev, &si_pi->vddc_phase_shed_table, table); | ||
4582 | |||
4583 | table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] = | ||
4584 | cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low); | ||
4585 | |||
4586 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_phase_shedding_delay, | ||
4587 | (u32)si_pi->vddc_phase_shed_table.phase_delay); | ||
4588 | } else { | ||
4589 | si_pi->vddc_phase_shed_control = false; | ||
4590 | } | ||
4591 | } | ||
4592 | } | ||
4593 | |||
4594 | return 0; | ||
4595 | } | ||
4596 | |||
4597 | static int si_populate_voltage_value(struct amdgpu_device *adev, | ||
4598 | const struct atom_voltage_table *table, | ||
4599 | u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage) | ||
4600 | { | ||
4601 | unsigned int i; | ||
4602 | |||
4603 | for (i = 0; i < table->count; i++) { | ||
4604 | if (value <= table->entries[i].value) { | ||
4605 | voltage->index = (u8)i; | ||
4606 | voltage->value = cpu_to_be16(table->entries[i].value); | ||
4607 | break; | ||
4608 | } | ||
4609 | } | ||
4610 | |||
4611 | if (i >= table->count) | ||
4612 | return -EINVAL; | ||
4613 | |||
4614 | return 0; | ||
4615 | } | ||
4616 | |||
4617 | static int si_populate_mvdd_value(struct amdgpu_device *adev, u32 mclk, | ||
4618 | SISLANDS_SMC_VOLTAGE_VALUE *voltage) | ||
4619 | { | ||
4620 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4621 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4622 | |||
4623 | if (pi->mvdd_control) { | ||
4624 | if (mclk <= pi->mvdd_split_frequency) | ||
4625 | voltage->index = 0; | ||
4626 | else | ||
4627 | voltage->index = (u8)(si_pi->mvdd_voltage_table.count) - 1; | ||
4628 | |||
4629 | voltage->value = cpu_to_be16(si_pi->mvdd_voltage_table.entries[voltage->index].value); | ||
4630 | } | ||
4631 | return 0; | ||
4632 | } | ||
4633 | |||
4634 | static int si_get_std_voltage_value(struct amdgpu_device *adev, | ||
4635 | SISLANDS_SMC_VOLTAGE_VALUE *voltage, | ||
4636 | u16 *std_voltage) | ||
4637 | { | ||
4638 | u16 v_index; | ||
4639 | bool voltage_found = false; | ||
4640 | *std_voltage = be16_to_cpu(voltage->value); | ||
4641 | |||
4642 | if (adev->pm.dpm.dyn_state.cac_leakage_table.entries) { | ||
4643 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_NEW_CAC_VOLTAGE) { | ||
4644 | if (adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries == NULL) | ||
4645 | return -EINVAL; | ||
4646 | |||
4647 | for (v_index = 0; (u32)v_index < adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) { | ||
4648 | if (be16_to_cpu(voltage->value) == | ||
4649 | (u16)adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) { | ||
4650 | voltage_found = true; | ||
4651 | if ((u32)v_index < adev->pm.dpm.dyn_state.cac_leakage_table.count) | ||
4652 | *std_voltage = | ||
4653 | adev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc; | ||
4654 | else | ||
4655 | *std_voltage = | ||
4656 | adev->pm.dpm.dyn_state.cac_leakage_table.entries[adev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc; | ||
4657 | break; | ||
4658 | } | ||
4659 | } | ||
4660 | |||
4661 | if (!voltage_found) { | ||
4662 | for (v_index = 0; (u32)v_index < adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) { | ||
4663 | if (be16_to_cpu(voltage->value) <= | ||
4664 | (u16)adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) { | ||
4665 | voltage_found = true; | ||
4666 | if ((u32)v_index < adev->pm.dpm.dyn_state.cac_leakage_table.count) | ||
4667 | *std_voltage = | ||
4668 | adev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc; | ||
4669 | else | ||
4670 | *std_voltage = | ||
4671 | adev->pm.dpm.dyn_state.cac_leakage_table.entries[adev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc; | ||
4672 | break; | ||
4673 | } | ||
4674 | } | ||
4675 | } | ||
4676 | } else { | ||
4677 | if ((u32)voltage->index < adev->pm.dpm.dyn_state.cac_leakage_table.count) | ||
4678 | *std_voltage = adev->pm.dpm.dyn_state.cac_leakage_table.entries[voltage->index].vddc; | ||
4679 | } | ||
4680 | } | ||
4681 | |||
4682 | return 0; | ||
4683 | } | ||
4684 | |||
4685 | static int si_populate_std_voltage_value(struct amdgpu_device *adev, | ||
4686 | u16 value, u8 index, | ||
4687 | SISLANDS_SMC_VOLTAGE_VALUE *voltage) | ||
4688 | { | ||
4689 | voltage->index = index; | ||
4690 | voltage->value = cpu_to_be16(value); | ||
4691 | |||
4692 | return 0; | ||
4693 | } | ||
4694 | |||
4695 | static int si_populate_phase_shedding_value(struct amdgpu_device *adev, | ||
4696 | const struct amdgpu_phase_shedding_limits_table *limits, | ||
4697 | u16 voltage, u32 sclk, u32 mclk, | ||
4698 | SISLANDS_SMC_VOLTAGE_VALUE *smc_voltage) | ||
4699 | { | ||
4700 | unsigned int i; | ||
4701 | |||
4702 | for (i = 0; i < limits->count; i++) { | ||
4703 | if ((voltage <= limits->entries[i].voltage) && | ||
4704 | (sclk <= limits->entries[i].sclk) && | ||
4705 | (mclk <= limits->entries[i].mclk)) | ||
4706 | break; | ||
4707 | } | ||
4708 | |||
4709 | smc_voltage->phase_settings = (u8)i; | ||
4710 | |||
4711 | return 0; | ||
4712 | } | ||
4713 | |||
4714 | static int si_init_arb_table_index(struct amdgpu_device *adev) | ||
4715 | { | ||
4716 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4717 | u32 tmp; | ||
4718 | int ret; | ||
4719 | |||
4720 | ret = amdgpu_si_read_smc_sram_dword(adev, si_pi->arb_table_start, | ||
4721 | &tmp, si_pi->sram_end); | ||
4722 | if (ret) | ||
4723 | return ret; | ||
4724 | |||
4725 | tmp &= 0x00FFFFFF; | ||
4726 | tmp |= MC_CG_ARB_FREQ_F1 << 24; | ||
4727 | |||
4728 | return amdgpu_si_write_smc_sram_dword(adev, si_pi->arb_table_start, | ||
4729 | tmp, si_pi->sram_end); | ||
4730 | } | ||
4731 | |||
4732 | static int si_initial_switch_from_arb_f0_to_f1(struct amdgpu_device *adev) | ||
4733 | { | ||
4734 | return ni_copy_and_switch_arb_sets(adev, MC_CG_ARB_FREQ_F0, MC_CG_ARB_FREQ_F1); | ||
4735 | } | ||
4736 | |||
4737 | static int si_reset_to_default(struct amdgpu_device *adev) | ||
4738 | { | ||
4739 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_ResetToDefaults) == PPSMC_Result_OK) ? | ||
4740 | 0 : -EINVAL; | ||
4741 | } | ||
4742 | |||
4743 | static int si_force_switch_to_arb_f0(struct amdgpu_device *adev) | ||
4744 | { | ||
4745 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4746 | u32 tmp; | ||
4747 | int ret; | ||
4748 | |||
4749 | ret = amdgpu_si_read_smc_sram_dword(adev, si_pi->arb_table_start, | ||
4750 | &tmp, si_pi->sram_end); | ||
4751 | if (ret) | ||
4752 | return ret; | ||
4753 | |||
4754 | tmp = (tmp >> 24) & 0xff; | ||
4755 | |||
4756 | if (tmp == MC_CG_ARB_FREQ_F0) | ||
4757 | return 0; | ||
4758 | |||
4759 | return ni_copy_and_switch_arb_sets(adev, tmp, MC_CG_ARB_FREQ_F0); | ||
4760 | } | ||
4761 | |||
4762 | static u32 si_calculate_memory_refresh_rate(struct amdgpu_device *adev, | ||
4763 | u32 engine_clock) | ||
4764 | { | ||
4765 | u32 dram_rows; | ||
4766 | u32 dram_refresh_rate; | ||
4767 | u32 mc_arb_rfsh_rate; | ||
4768 | u32 tmp = (RREG32(MC_ARB_RAMCFG) & NOOFROWS_MASK) >> NOOFROWS_SHIFT; | ||
4769 | |||
4770 | if (tmp >= 4) | ||
4771 | dram_rows = 16384; | ||
4772 | else | ||
4773 | dram_rows = 1 << (tmp + 10); | ||
4774 | |||
4775 | dram_refresh_rate = 1 << ((RREG32(MC_SEQ_MISC0) & 0x3) + 3); | ||
4776 | mc_arb_rfsh_rate = ((engine_clock * 10) * dram_refresh_rate / dram_rows - 32) / 64; | ||
4777 | |||
4778 | return mc_arb_rfsh_rate; | ||
4779 | } | ||
4780 | |||
4781 | static int si_populate_memory_timing_parameters(struct amdgpu_device *adev, | ||
4782 | struct rv7xx_pl *pl, | ||
4783 | SMC_SIslands_MCArbDramTimingRegisterSet *arb_regs) | ||
4784 | { | ||
4785 | u32 dram_timing; | ||
4786 | u32 dram_timing2; | ||
4787 | u32 burst_time; | ||
4788 | |||
4789 | arb_regs->mc_arb_rfsh_rate = | ||
4790 | (u8)si_calculate_memory_refresh_rate(adev, pl->sclk); | ||
4791 | |||
4792 | amdgpu_atombios_set_engine_dram_timings(adev, | ||
4793 | pl->sclk, | ||
4794 | pl->mclk); | ||
4795 | |||
4796 | dram_timing = RREG32(MC_ARB_DRAM_TIMING); | ||
4797 | dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2); | ||
4798 | burst_time = RREG32(MC_ARB_BURST_TIME) & STATE0_MASK; | ||
4799 | |||
4800 | arb_regs->mc_arb_dram_timing = cpu_to_be32(dram_timing); | ||
4801 | arb_regs->mc_arb_dram_timing2 = cpu_to_be32(dram_timing2); | ||
4802 | arb_regs->mc_arb_burst_time = (u8)burst_time; | ||
4803 | |||
4804 | return 0; | ||
4805 | } | ||
4806 | |||
4807 | static int si_do_program_memory_timing_parameters(struct amdgpu_device *adev, | ||
4808 | struct amdgpu_ps *amdgpu_state, | ||
4809 | unsigned int first_arb_set) | ||
4810 | { | ||
4811 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4812 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
4813 | SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 }; | ||
4814 | int i, ret = 0; | ||
4815 | |||
4816 | for (i = 0; i < state->performance_level_count; i++) { | ||
4817 | ret = si_populate_memory_timing_parameters(adev, &state->performance_levels[i], &arb_regs); | ||
4818 | if (ret) | ||
4819 | break; | ||
4820 | ret = amdgpu_si_copy_bytes_to_smc(adev, | ||
4821 | si_pi->arb_table_start + | ||
4822 | offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) + | ||
4823 | sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * (first_arb_set + i), | ||
4824 | (u8 *)&arb_regs, | ||
4825 | sizeof(SMC_SIslands_MCArbDramTimingRegisterSet), | ||
4826 | si_pi->sram_end); | ||
4827 | if (ret) | ||
4828 | break; | ||
4829 | } | ||
4830 | |||
4831 | return ret; | ||
4832 | } | ||
4833 | |||
4834 | static int si_program_memory_timing_parameters(struct amdgpu_device *adev, | ||
4835 | struct amdgpu_ps *amdgpu_new_state) | ||
4836 | { | ||
4837 | return si_do_program_memory_timing_parameters(adev, amdgpu_new_state, | ||
4838 | SISLANDS_DRIVER_STATE_ARB_INDEX); | ||
4839 | } | ||
4840 | |||
4841 | static int si_populate_initial_mvdd_value(struct amdgpu_device *adev, | ||
4842 | struct SISLANDS_SMC_VOLTAGE_VALUE *voltage) | ||
4843 | { | ||
4844 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4845 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4846 | |||
4847 | if (pi->mvdd_control) | ||
4848 | return si_populate_voltage_value(adev, &si_pi->mvdd_voltage_table, | ||
4849 | si_pi->mvdd_bootup_value, voltage); | ||
4850 | |||
4851 | return 0; | ||
4852 | } | ||
4853 | |||
4854 | static int si_populate_smc_initial_state(struct amdgpu_device *adev, | ||
4855 | struct amdgpu_ps *amdgpu_initial_state, | ||
4856 | SISLANDS_SMC_STATETABLE *table) | ||
4857 | { | ||
4858 | struct si_ps *initial_state = si_get_ps(amdgpu_initial_state); | ||
4859 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4860 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
4861 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4862 | u32 reg; | ||
4863 | int ret; | ||
4864 | |||
4865 | table->initialState.levels[0].mclk.vDLL_CNTL = | ||
4866 | cpu_to_be32(si_pi->clock_registers.dll_cntl); | ||
4867 | table->initialState.levels[0].mclk.vMCLK_PWRMGT_CNTL = | ||
4868 | cpu_to_be32(si_pi->clock_registers.mclk_pwrmgt_cntl); | ||
4869 | table->initialState.levels[0].mclk.vMPLL_AD_FUNC_CNTL = | ||
4870 | cpu_to_be32(si_pi->clock_registers.mpll_ad_func_cntl); | ||
4871 | table->initialState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL = | ||
4872 | cpu_to_be32(si_pi->clock_registers.mpll_dq_func_cntl); | ||
4873 | table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL = | ||
4874 | cpu_to_be32(si_pi->clock_registers.mpll_func_cntl); | ||
4875 | table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_1 = | ||
4876 | cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_1); | ||
4877 | table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_2 = | ||
4878 | cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_2); | ||
4879 | table->initialState.levels[0].mclk.vMPLL_SS = | ||
4880 | cpu_to_be32(si_pi->clock_registers.mpll_ss1); | ||
4881 | table->initialState.levels[0].mclk.vMPLL_SS2 = | ||
4882 | cpu_to_be32(si_pi->clock_registers.mpll_ss2); | ||
4883 | |||
4884 | table->initialState.levels[0].mclk.mclk_value = | ||
4885 | cpu_to_be32(initial_state->performance_levels[0].mclk); | ||
4886 | |||
4887 | table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL = | ||
4888 | cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl); | ||
4889 | table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 = | ||
4890 | cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_2); | ||
4891 | table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 = | ||
4892 | cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_3); | ||
4893 | table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 = | ||
4894 | cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_4); | ||
4895 | table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM = | ||
4896 | cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum); | ||
4897 | table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM_2 = | ||
4898 | cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum_2); | ||
4899 | |||
4900 | table->initialState.levels[0].sclk.sclk_value = | ||
4901 | cpu_to_be32(initial_state->performance_levels[0].sclk); | ||
4902 | |||
4903 | table->initialState.levels[0].arbRefreshState = | ||
4904 | SISLANDS_INITIAL_STATE_ARB_INDEX; | ||
4905 | |||
4906 | table->initialState.levels[0].ACIndex = 0; | ||
4907 | |||
4908 | ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table, | ||
4909 | initial_state->performance_levels[0].vddc, | ||
4910 | &table->initialState.levels[0].vddc); | ||
4911 | |||
4912 | if (!ret) { | ||
4913 | u16 std_vddc; | ||
4914 | |||
4915 | ret = si_get_std_voltage_value(adev, | ||
4916 | &table->initialState.levels[0].vddc, | ||
4917 | &std_vddc); | ||
4918 | if (!ret) | ||
4919 | si_populate_std_voltage_value(adev, std_vddc, | ||
4920 | table->initialState.levels[0].vddc.index, | ||
4921 | &table->initialState.levels[0].std_vddc); | ||
4922 | } | ||
4923 | |||
4924 | if (eg_pi->vddci_control) | ||
4925 | si_populate_voltage_value(adev, | ||
4926 | &eg_pi->vddci_voltage_table, | ||
4927 | initial_state->performance_levels[0].vddci, | ||
4928 | &table->initialState.levels[0].vddci); | ||
4929 | |||
4930 | if (si_pi->vddc_phase_shed_control) | ||
4931 | si_populate_phase_shedding_value(adev, | ||
4932 | &adev->pm.dpm.dyn_state.phase_shedding_limits_table, | ||
4933 | initial_state->performance_levels[0].vddc, | ||
4934 | initial_state->performance_levels[0].sclk, | ||
4935 | initial_state->performance_levels[0].mclk, | ||
4936 | &table->initialState.levels[0].vddc); | ||
4937 | |||
4938 | si_populate_initial_mvdd_value(adev, &table->initialState.levels[0].mvdd); | ||
4939 | |||
4940 | reg = CG_R(0xffff) | CG_L(0); | ||
4941 | table->initialState.levels[0].aT = cpu_to_be32(reg); | ||
4942 | table->initialState.levels[0].bSP = cpu_to_be32(pi->dsp); | ||
4943 | table->initialState.levels[0].gen2PCIE = (u8)si_pi->boot_pcie_gen; | ||
4944 | |||
4945 | if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) { | ||
4946 | table->initialState.levels[0].strobeMode = | ||
4947 | si_get_strobe_mode_settings(adev, | ||
4948 | initial_state->performance_levels[0].mclk); | ||
4949 | |||
4950 | if (initial_state->performance_levels[0].mclk > pi->mclk_edc_enable_threshold) | ||
4951 | table->initialState.levels[0].mcFlags = SISLANDS_SMC_MC_EDC_RD_FLAG | SISLANDS_SMC_MC_EDC_WR_FLAG; | ||
4952 | else | ||
4953 | table->initialState.levels[0].mcFlags = 0; | ||
4954 | } | ||
4955 | |||
4956 | table->initialState.levelCount = 1; | ||
4957 | |||
4958 | table->initialState.flags |= PPSMC_SWSTATE_FLAG_DC; | ||
4959 | |||
4960 | table->initialState.levels[0].dpm2.MaxPS = 0; | ||
4961 | table->initialState.levels[0].dpm2.NearTDPDec = 0; | ||
4962 | table->initialState.levels[0].dpm2.AboveSafeInc = 0; | ||
4963 | table->initialState.levels[0].dpm2.BelowSafeInc = 0; | ||
4964 | table->initialState.levels[0].dpm2.PwrEfficiencyRatio = 0; | ||
4965 | |||
4966 | reg = MIN_POWER_MASK | MAX_POWER_MASK; | ||
4967 | table->initialState.levels[0].SQPowerThrottle = cpu_to_be32(reg); | ||
4968 | |||
4969 | reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK; | ||
4970 | table->initialState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg); | ||
4971 | |||
4972 | return 0; | ||
4973 | } | ||
4974 | |||
4975 | static int si_populate_smc_acpi_state(struct amdgpu_device *adev, | ||
4976 | SISLANDS_SMC_STATETABLE *table) | ||
4977 | { | ||
4978 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
4979 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
4980 | struct si_power_info *si_pi = si_get_pi(adev); | ||
4981 | u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl; | ||
4982 | u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2; | ||
4983 | u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3; | ||
4984 | u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4; | ||
4985 | u32 dll_cntl = si_pi->clock_registers.dll_cntl; | ||
4986 | u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl; | ||
4987 | u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl; | ||
4988 | u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl; | ||
4989 | u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl; | ||
4990 | u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1; | ||
4991 | u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2; | ||
4992 | u32 reg; | ||
4993 | int ret; | ||
4994 | |||
4995 | table->ACPIState = table->initialState; | ||
4996 | |||
4997 | table->ACPIState.flags &= ~PPSMC_SWSTATE_FLAG_DC; | ||
4998 | |||
4999 | if (pi->acpi_vddc) { | ||
5000 | ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table, | ||
5001 | pi->acpi_vddc, &table->ACPIState.levels[0].vddc); | ||
5002 | if (!ret) { | ||
5003 | u16 std_vddc; | ||
5004 | |||
5005 | ret = si_get_std_voltage_value(adev, | ||
5006 | &table->ACPIState.levels[0].vddc, &std_vddc); | ||
5007 | if (!ret) | ||
5008 | si_populate_std_voltage_value(adev, std_vddc, | ||
5009 | table->ACPIState.levels[0].vddc.index, | ||
5010 | &table->ACPIState.levels[0].std_vddc); | ||
5011 | } | ||
5012 | table->ACPIState.levels[0].gen2PCIE = si_pi->acpi_pcie_gen; | ||
5013 | |||
5014 | if (si_pi->vddc_phase_shed_control) { | ||
5015 | si_populate_phase_shedding_value(adev, | ||
5016 | &adev->pm.dpm.dyn_state.phase_shedding_limits_table, | ||
5017 | pi->acpi_vddc, | ||
5018 | 0, | ||
5019 | 0, | ||
5020 | &table->ACPIState.levels[0].vddc); | ||
5021 | } | ||
5022 | } else { | ||
5023 | ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table, | ||
5024 | pi->min_vddc_in_table, &table->ACPIState.levels[0].vddc); | ||
5025 | if (!ret) { | ||
5026 | u16 std_vddc; | ||
5027 | |||
5028 | ret = si_get_std_voltage_value(adev, | ||
5029 | &table->ACPIState.levels[0].vddc, &std_vddc); | ||
5030 | |||
5031 | if (!ret) | ||
5032 | si_populate_std_voltage_value(adev, std_vddc, | ||
5033 | table->ACPIState.levels[0].vddc.index, | ||
5034 | &table->ACPIState.levels[0].std_vddc); | ||
5035 | } | ||
5036 | table->ACPIState.levels[0].gen2PCIE = (u8)r600_get_pcie_gen_support(adev, | ||
5037 | si_pi->sys_pcie_mask, | ||
5038 | si_pi->boot_pcie_gen, | ||
5039 | AMDGPU_PCIE_GEN1); | ||
5040 | |||
5041 | if (si_pi->vddc_phase_shed_control) | ||
5042 | si_populate_phase_shedding_value(adev, | ||
5043 | &adev->pm.dpm.dyn_state.phase_shedding_limits_table, | ||
5044 | pi->min_vddc_in_table, | ||
5045 | 0, | ||
5046 | 0, | ||
5047 | &table->ACPIState.levels[0].vddc); | ||
5048 | } | ||
5049 | |||
5050 | if (pi->acpi_vddc) { | ||
5051 | if (eg_pi->acpi_vddci) | ||
5052 | si_populate_voltage_value(adev, &eg_pi->vddci_voltage_table, | ||
5053 | eg_pi->acpi_vddci, | ||
5054 | &table->ACPIState.levels[0].vddci); | ||
5055 | } | ||
5056 | |||
5057 | mclk_pwrmgt_cntl |= MRDCK0_RESET | MRDCK1_RESET; | ||
5058 | mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB); | ||
5059 | |||
5060 | dll_cntl &= ~(MRDCK0_BYPASS | MRDCK1_BYPASS); | ||
5061 | |||
5062 | spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK; | ||
5063 | spll_func_cntl_2 |= SCLK_MUX_SEL(4); | ||
5064 | |||
5065 | table->ACPIState.levels[0].mclk.vDLL_CNTL = | ||
5066 | cpu_to_be32(dll_cntl); | ||
5067 | table->ACPIState.levels[0].mclk.vMCLK_PWRMGT_CNTL = | ||
5068 | cpu_to_be32(mclk_pwrmgt_cntl); | ||
5069 | table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL = | ||
5070 | cpu_to_be32(mpll_ad_func_cntl); | ||
5071 | table->ACPIState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL = | ||
5072 | cpu_to_be32(mpll_dq_func_cntl); | ||
5073 | table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL = | ||
5074 | cpu_to_be32(mpll_func_cntl); | ||
5075 | table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_1 = | ||
5076 | cpu_to_be32(mpll_func_cntl_1); | ||
5077 | table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_2 = | ||
5078 | cpu_to_be32(mpll_func_cntl_2); | ||
5079 | table->ACPIState.levels[0].mclk.vMPLL_SS = | ||
5080 | cpu_to_be32(si_pi->clock_registers.mpll_ss1); | ||
5081 | table->ACPIState.levels[0].mclk.vMPLL_SS2 = | ||
5082 | cpu_to_be32(si_pi->clock_registers.mpll_ss2); | ||
5083 | |||
5084 | table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL = | ||
5085 | cpu_to_be32(spll_func_cntl); | ||
5086 | table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 = | ||
5087 | cpu_to_be32(spll_func_cntl_2); | ||
5088 | table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 = | ||
5089 | cpu_to_be32(spll_func_cntl_3); | ||
5090 | table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 = | ||
5091 | cpu_to_be32(spll_func_cntl_4); | ||
5092 | |||
5093 | table->ACPIState.levels[0].mclk.mclk_value = 0; | ||
5094 | table->ACPIState.levels[0].sclk.sclk_value = 0; | ||
5095 | |||
5096 | si_populate_mvdd_value(adev, 0, &table->ACPIState.levels[0].mvdd); | ||
5097 | |||
5098 | if (eg_pi->dynamic_ac_timing) | ||
5099 | table->ACPIState.levels[0].ACIndex = 0; | ||
5100 | |||
5101 | table->ACPIState.levels[0].dpm2.MaxPS = 0; | ||
5102 | table->ACPIState.levels[0].dpm2.NearTDPDec = 0; | ||
5103 | table->ACPIState.levels[0].dpm2.AboveSafeInc = 0; | ||
5104 | table->ACPIState.levels[0].dpm2.BelowSafeInc = 0; | ||
5105 | table->ACPIState.levels[0].dpm2.PwrEfficiencyRatio = 0; | ||
5106 | |||
5107 | reg = MIN_POWER_MASK | MAX_POWER_MASK; | ||
5108 | table->ACPIState.levels[0].SQPowerThrottle = cpu_to_be32(reg); | ||
5109 | |||
5110 | reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK; | ||
5111 | table->ACPIState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg); | ||
5112 | |||
5113 | return 0; | ||
5114 | } | ||
5115 | |||
5116 | static int si_populate_ulv_state(struct amdgpu_device *adev, | ||
5117 | SISLANDS_SMC_SWSTATE *state) | ||
5118 | { | ||
5119 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
5120 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5121 | struct si_ulv_param *ulv = &si_pi->ulv; | ||
5122 | u32 sclk_in_sr = 1350; /* ??? */ | ||
5123 | int ret; | ||
5124 | |||
5125 | ret = si_convert_power_level_to_smc(adev, &ulv->pl, | ||
5126 | &state->levels[0]); | ||
5127 | if (!ret) { | ||
5128 | if (eg_pi->sclk_deep_sleep) { | ||
5129 | if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ) | ||
5130 | state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS; | ||
5131 | else | ||
5132 | state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE; | ||
5133 | } | ||
5134 | if (ulv->one_pcie_lane_in_ulv) | ||
5135 | state->flags |= PPSMC_SWSTATE_FLAG_PCIE_X1; | ||
5136 | state->levels[0].arbRefreshState = (u8)(SISLANDS_ULV_STATE_ARB_INDEX); | ||
5137 | state->levels[0].ACIndex = 1; | ||
5138 | state->levels[0].std_vddc = state->levels[0].vddc; | ||
5139 | state->levelCount = 1; | ||
5140 | |||
5141 | state->flags |= PPSMC_SWSTATE_FLAG_DC; | ||
5142 | } | ||
5143 | |||
5144 | return ret; | ||
5145 | } | ||
5146 | |||
5147 | static int si_program_ulv_memory_timing_parameters(struct amdgpu_device *adev) | ||
5148 | { | ||
5149 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5150 | struct si_ulv_param *ulv = &si_pi->ulv; | ||
5151 | SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 }; | ||
5152 | int ret; | ||
5153 | |||
5154 | ret = si_populate_memory_timing_parameters(adev, &ulv->pl, | ||
5155 | &arb_regs); | ||
5156 | if (ret) | ||
5157 | return ret; | ||
5158 | |||
5159 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_ulv_volt_change_delay, | ||
5160 | ulv->volt_change_delay); | ||
5161 | |||
5162 | ret = amdgpu_si_copy_bytes_to_smc(adev, | ||
5163 | si_pi->arb_table_start + | ||
5164 | offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) + | ||
5165 | sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * SISLANDS_ULV_STATE_ARB_INDEX, | ||
5166 | (u8 *)&arb_regs, | ||
5167 | sizeof(SMC_SIslands_MCArbDramTimingRegisterSet), | ||
5168 | si_pi->sram_end); | ||
5169 | |||
5170 | return ret; | ||
5171 | } | ||
5172 | |||
5173 | static void si_get_mvdd_configuration(struct amdgpu_device *adev) | ||
5174 | { | ||
5175 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
5176 | |||
5177 | pi->mvdd_split_frequency = 30000; | ||
5178 | } | ||
5179 | |||
5180 | static int si_init_smc_table(struct amdgpu_device *adev) | ||
5181 | { | ||
5182 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5183 | struct amdgpu_ps *amdgpu_boot_state = adev->pm.dpm.boot_ps; | ||
5184 | const struct si_ulv_param *ulv = &si_pi->ulv; | ||
5185 | SISLANDS_SMC_STATETABLE *table = &si_pi->smc_statetable; | ||
5186 | int ret; | ||
5187 | u32 lane_width; | ||
5188 | u32 vr_hot_gpio; | ||
5189 | |||
5190 | si_populate_smc_voltage_tables(adev, table); | ||
5191 | |||
5192 | switch (adev->pm.int_thermal_type) { | ||
5193 | case THERMAL_TYPE_SI: | ||
5194 | case THERMAL_TYPE_EMC2103_WITH_INTERNAL: | ||
5195 | table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL; | ||
5196 | break; | ||
5197 | case THERMAL_TYPE_NONE: | ||
5198 | table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE; | ||
5199 | break; | ||
5200 | default: | ||
5201 | table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL; | ||
5202 | break; | ||
5203 | } | ||
5204 | |||
5205 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC) | ||
5206 | table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC; | ||
5207 | |||
5208 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) { | ||
5209 | if ((adev->pdev->device != 0x6818) && (adev->pdev->device != 0x6819)) | ||
5210 | table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT; | ||
5211 | } | ||
5212 | |||
5213 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC) | ||
5214 | table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC; | ||
5215 | |||
5216 | if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) | ||
5217 | table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5; | ||
5218 | |||
5219 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REVERT_GPIO5_POLARITY) | ||
5220 | table->extraFlags |= PPSMC_EXTRAFLAGS_AC2DC_GPIO5_POLARITY_HIGH; | ||
5221 | |||
5222 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_VRHOT_GPIO_CONFIGURABLE) { | ||
5223 | table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT_PROG_GPIO; | ||
5224 | vr_hot_gpio = adev->pm.dpm.backbias_response_time; | ||
5225 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_vr_hot_gpio, | ||
5226 | vr_hot_gpio); | ||
5227 | } | ||
5228 | |||
5229 | ret = si_populate_smc_initial_state(adev, amdgpu_boot_state, table); | ||
5230 | if (ret) | ||
5231 | return ret; | ||
5232 | |||
5233 | ret = si_populate_smc_acpi_state(adev, table); | ||
5234 | if (ret) | ||
5235 | return ret; | ||
5236 | |||
5237 | table->driverState = table->initialState; | ||
5238 | |||
5239 | ret = si_do_program_memory_timing_parameters(adev, amdgpu_boot_state, | ||
5240 | SISLANDS_INITIAL_STATE_ARB_INDEX); | ||
5241 | if (ret) | ||
5242 | return ret; | ||
5243 | |||
5244 | if (ulv->supported && ulv->pl.vddc) { | ||
5245 | ret = si_populate_ulv_state(adev, &table->ULVState); | ||
5246 | if (ret) | ||
5247 | return ret; | ||
5248 | |||
5249 | ret = si_program_ulv_memory_timing_parameters(adev); | ||
5250 | if (ret) | ||
5251 | return ret; | ||
5252 | |||
5253 | WREG32(CG_ULV_CONTROL, ulv->cg_ulv_control); | ||
5254 | WREG32(CG_ULV_PARAMETER, ulv->cg_ulv_parameter); | ||
5255 | |||
5256 | lane_width = amdgpu_get_pcie_lanes(adev); | ||
5257 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width); | ||
5258 | } else { | ||
5259 | table->ULVState = table->initialState; | ||
5260 | } | ||
5261 | |||
5262 | return amdgpu_si_copy_bytes_to_smc(adev, si_pi->state_table_start, | ||
5263 | (u8 *)table, sizeof(SISLANDS_SMC_STATETABLE), | ||
5264 | si_pi->sram_end); | ||
5265 | } | ||
5266 | |||
5267 | static int si_calculate_sclk_params(struct amdgpu_device *adev, | ||
5268 | u32 engine_clock, | ||
5269 | SISLANDS_SMC_SCLK_VALUE *sclk) | ||
5270 | { | ||
5271 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
5272 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5273 | struct atom_clock_dividers dividers; | ||
5274 | u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl; | ||
5275 | u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2; | ||
5276 | u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3; | ||
5277 | u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4; | ||
5278 | u32 cg_spll_spread_spectrum = si_pi->clock_registers.cg_spll_spread_spectrum; | ||
5279 | u32 cg_spll_spread_spectrum_2 = si_pi->clock_registers.cg_spll_spread_spectrum_2; | ||
5280 | u64 tmp; | ||
5281 | u32 reference_clock = adev->clock.spll.reference_freq; | ||
5282 | u32 reference_divider; | ||
5283 | u32 fbdiv; | ||
5284 | int ret; | ||
5285 | |||
5286 | ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_ENGINE_PLL_PARAM, | ||
5287 | engine_clock, false, ÷rs); | ||
5288 | if (ret) | ||
5289 | return ret; | ||
5290 | |||
5291 | reference_divider = 1 + dividers.ref_div; | ||
5292 | |||
5293 | tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16384; | ||
5294 | do_div(tmp, reference_clock); | ||
5295 | fbdiv = (u32) tmp; | ||
5296 | |||
5297 | spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK); | ||
5298 | spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div); | ||
5299 | spll_func_cntl |= SPLL_PDIV_A(dividers.post_div); | ||
5300 | |||
5301 | spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK; | ||
5302 | spll_func_cntl_2 |= SCLK_MUX_SEL(2); | ||
5303 | |||
5304 | spll_func_cntl_3 &= ~SPLL_FB_DIV_MASK; | ||
5305 | spll_func_cntl_3 |= SPLL_FB_DIV(fbdiv); | ||
5306 | spll_func_cntl_3 |= SPLL_DITHEN; | ||
5307 | |||
5308 | if (pi->sclk_ss) { | ||
5309 | struct amdgpu_atom_ss ss; | ||
5310 | u32 vco_freq = engine_clock * dividers.post_div; | ||
5311 | |||
5312 | if (amdgpu_atombios_get_asic_ss_info(adev, &ss, | ||
5313 | ASIC_INTERNAL_ENGINE_SS, vco_freq)) { | ||
5314 | u32 clk_s = reference_clock * 5 / (reference_divider * ss.rate); | ||
5315 | u32 clk_v = 4 * ss.percentage * fbdiv / (clk_s * 10000); | ||
5316 | |||
5317 | cg_spll_spread_spectrum &= ~CLK_S_MASK; | ||
5318 | cg_spll_spread_spectrum |= CLK_S(clk_s); | ||
5319 | cg_spll_spread_spectrum |= SSEN; | ||
5320 | |||
5321 | cg_spll_spread_spectrum_2 &= ~CLK_V_MASK; | ||
5322 | cg_spll_spread_spectrum_2 |= CLK_V(clk_v); | ||
5323 | } | ||
5324 | } | ||
5325 | |||
5326 | sclk->sclk_value = engine_clock; | ||
5327 | sclk->vCG_SPLL_FUNC_CNTL = spll_func_cntl; | ||
5328 | sclk->vCG_SPLL_FUNC_CNTL_2 = spll_func_cntl_2; | ||
5329 | sclk->vCG_SPLL_FUNC_CNTL_3 = spll_func_cntl_3; | ||
5330 | sclk->vCG_SPLL_FUNC_CNTL_4 = spll_func_cntl_4; | ||
5331 | sclk->vCG_SPLL_SPREAD_SPECTRUM = cg_spll_spread_spectrum; | ||
5332 | sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cg_spll_spread_spectrum_2; | ||
5333 | |||
5334 | return 0; | ||
5335 | } | ||
5336 | |||
5337 | static int si_populate_sclk_value(struct amdgpu_device *adev, | ||
5338 | u32 engine_clock, | ||
5339 | SISLANDS_SMC_SCLK_VALUE *sclk) | ||
5340 | { | ||
5341 | SISLANDS_SMC_SCLK_VALUE sclk_tmp; | ||
5342 | int ret; | ||
5343 | |||
5344 | ret = si_calculate_sclk_params(adev, engine_clock, &sclk_tmp); | ||
5345 | if (!ret) { | ||
5346 | sclk->sclk_value = cpu_to_be32(sclk_tmp.sclk_value); | ||
5347 | sclk->vCG_SPLL_FUNC_CNTL = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL); | ||
5348 | sclk->vCG_SPLL_FUNC_CNTL_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_2); | ||
5349 | sclk->vCG_SPLL_FUNC_CNTL_3 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_3); | ||
5350 | sclk->vCG_SPLL_FUNC_CNTL_4 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_4); | ||
5351 | sclk->vCG_SPLL_SPREAD_SPECTRUM = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM); | ||
5352 | sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM_2); | ||
5353 | } | ||
5354 | |||
5355 | return ret; | ||
5356 | } | ||
5357 | |||
5358 | static int si_populate_mclk_value(struct amdgpu_device *adev, | ||
5359 | u32 engine_clock, | ||
5360 | u32 memory_clock, | ||
5361 | SISLANDS_SMC_MCLK_VALUE *mclk, | ||
5362 | bool strobe_mode, | ||
5363 | bool dll_state_on) | ||
5364 | { | ||
5365 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
5366 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5367 | u32 dll_cntl = si_pi->clock_registers.dll_cntl; | ||
5368 | u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl; | ||
5369 | u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl; | ||
5370 | u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl; | ||
5371 | u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl; | ||
5372 | u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1; | ||
5373 | u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2; | ||
5374 | u32 mpll_ss1 = si_pi->clock_registers.mpll_ss1; | ||
5375 | u32 mpll_ss2 = si_pi->clock_registers.mpll_ss2; | ||
5376 | struct atom_mpll_param mpll_param; | ||
5377 | int ret; | ||
5378 | |||
5379 | ret = amdgpu_atombios_get_memory_pll_dividers(adev, memory_clock, strobe_mode, &mpll_param); | ||
5380 | if (ret) | ||
5381 | return ret; | ||
5382 | |||
5383 | mpll_func_cntl &= ~BWCTRL_MASK; | ||
5384 | mpll_func_cntl |= BWCTRL(mpll_param.bwcntl); | ||
5385 | |||
5386 | mpll_func_cntl_1 &= ~(CLKF_MASK | CLKFRAC_MASK | VCO_MODE_MASK); | ||
5387 | mpll_func_cntl_1 |= CLKF(mpll_param.clkf) | | ||
5388 | CLKFRAC(mpll_param.clkfrac) | VCO_MODE(mpll_param.vco_mode); | ||
5389 | |||
5390 | mpll_ad_func_cntl &= ~YCLK_POST_DIV_MASK; | ||
5391 | mpll_ad_func_cntl |= YCLK_POST_DIV(mpll_param.post_div); | ||
5392 | |||
5393 | if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) { | ||
5394 | mpll_dq_func_cntl &= ~(YCLK_SEL_MASK | YCLK_POST_DIV_MASK); | ||
5395 | mpll_dq_func_cntl |= YCLK_SEL(mpll_param.yclk_sel) | | ||
5396 | YCLK_POST_DIV(mpll_param.post_div); | ||
5397 | } | ||
5398 | |||
5399 | if (pi->mclk_ss) { | ||
5400 | struct amdgpu_atom_ss ss; | ||
5401 | u32 freq_nom; | ||
5402 | u32 tmp; | ||
5403 | u32 reference_clock = adev->clock.mpll.reference_freq; | ||
5404 | |||
5405 | if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) | ||
5406 | freq_nom = memory_clock * 4; | ||
5407 | else | ||
5408 | freq_nom = memory_clock * 2; | ||
5409 | |||
5410 | tmp = freq_nom / reference_clock; | ||
5411 | tmp = tmp * tmp; | ||
5412 | if (amdgpu_atombios_get_asic_ss_info(adev, &ss, | ||
5413 | ASIC_INTERNAL_MEMORY_SS, freq_nom)) { | ||
5414 | u32 clks = reference_clock * 5 / ss.rate; | ||
5415 | u32 clkv = (u32)((((131 * ss.percentage * ss.rate) / 100) * tmp) / freq_nom); | ||
5416 | |||
5417 | mpll_ss1 &= ~CLKV_MASK; | ||
5418 | mpll_ss1 |= CLKV(clkv); | ||
5419 | |||
5420 | mpll_ss2 &= ~CLKS_MASK; | ||
5421 | mpll_ss2 |= CLKS(clks); | ||
5422 | } | ||
5423 | } | ||
5424 | |||
5425 | mclk_pwrmgt_cntl &= ~DLL_SPEED_MASK; | ||
5426 | mclk_pwrmgt_cntl |= DLL_SPEED(mpll_param.dll_speed); | ||
5427 | |||
5428 | if (dll_state_on) | ||
5429 | mclk_pwrmgt_cntl |= MRDCK0_PDNB | MRDCK1_PDNB; | ||
5430 | else | ||
5431 | mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB); | ||
5432 | |||
5433 | mclk->mclk_value = cpu_to_be32(memory_clock); | ||
5434 | mclk->vMPLL_FUNC_CNTL = cpu_to_be32(mpll_func_cntl); | ||
5435 | mclk->vMPLL_FUNC_CNTL_1 = cpu_to_be32(mpll_func_cntl_1); | ||
5436 | mclk->vMPLL_FUNC_CNTL_2 = cpu_to_be32(mpll_func_cntl_2); | ||
5437 | mclk->vMPLL_AD_FUNC_CNTL = cpu_to_be32(mpll_ad_func_cntl); | ||
5438 | mclk->vMPLL_DQ_FUNC_CNTL = cpu_to_be32(mpll_dq_func_cntl); | ||
5439 | mclk->vMCLK_PWRMGT_CNTL = cpu_to_be32(mclk_pwrmgt_cntl); | ||
5440 | mclk->vDLL_CNTL = cpu_to_be32(dll_cntl); | ||
5441 | mclk->vMPLL_SS = cpu_to_be32(mpll_ss1); | ||
5442 | mclk->vMPLL_SS2 = cpu_to_be32(mpll_ss2); | ||
5443 | |||
5444 | return 0; | ||
5445 | } | ||
5446 | |||
5447 | static void si_populate_smc_sp(struct amdgpu_device *adev, | ||
5448 | struct amdgpu_ps *amdgpu_state, | ||
5449 | SISLANDS_SMC_SWSTATE *smc_state) | ||
5450 | { | ||
5451 | struct si_ps *ps = si_get_ps(amdgpu_state); | ||
5452 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
5453 | int i; | ||
5454 | |||
5455 | for (i = 0; i < ps->performance_level_count - 1; i++) | ||
5456 | smc_state->levels[i].bSP = cpu_to_be32(pi->dsp); | ||
5457 | |||
5458 | smc_state->levels[ps->performance_level_count - 1].bSP = | ||
5459 | cpu_to_be32(pi->psp); | ||
5460 | } | ||
5461 | |||
5462 | static int si_convert_power_level_to_smc(struct amdgpu_device *adev, | ||
5463 | struct rv7xx_pl *pl, | ||
5464 | SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level) | ||
5465 | { | ||
5466 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
5467 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
5468 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5469 | int ret; | ||
5470 | bool dll_state_on; | ||
5471 | u16 std_vddc; | ||
5472 | bool gmc_pg = false; | ||
5473 | |||
5474 | if (eg_pi->pcie_performance_request && | ||
5475 | (si_pi->force_pcie_gen != AMDGPU_PCIE_GEN_INVALID)) | ||
5476 | level->gen2PCIE = (u8)si_pi->force_pcie_gen; | ||
5477 | else | ||
5478 | level->gen2PCIE = (u8)pl->pcie_gen; | ||
5479 | |||
5480 | ret = si_populate_sclk_value(adev, pl->sclk, &level->sclk); | ||
5481 | if (ret) | ||
5482 | return ret; | ||
5483 | |||
5484 | level->mcFlags = 0; | ||
5485 | |||
5486 | if (pi->mclk_stutter_mode_threshold && | ||
5487 | (pl->mclk <= pi->mclk_stutter_mode_threshold) && | ||
5488 | !eg_pi->uvd_enabled && | ||
5489 | (RREG32(DPG_PIPE_STUTTER_CONTROL) & STUTTER_ENABLE) && | ||
5490 | (adev->pm.dpm.new_active_crtc_count <= 2)) { | ||
5491 | level->mcFlags |= SISLANDS_SMC_MC_STUTTER_EN; | ||
5492 | |||
5493 | if (gmc_pg) | ||
5494 | level->mcFlags |= SISLANDS_SMC_MC_PG_EN; | ||
5495 | } | ||
5496 | |||
5497 | if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) { | ||
5498 | if (pl->mclk > pi->mclk_edc_enable_threshold) | ||
5499 | level->mcFlags |= SISLANDS_SMC_MC_EDC_RD_FLAG; | ||
5500 | |||
5501 | if (pl->mclk > eg_pi->mclk_edc_wr_enable_threshold) | ||
5502 | level->mcFlags |= SISLANDS_SMC_MC_EDC_WR_FLAG; | ||
5503 | |||
5504 | level->strobeMode = si_get_strobe_mode_settings(adev, pl->mclk); | ||
5505 | |||
5506 | if (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) { | ||
5507 | if (si_get_mclk_frequency_ratio(pl->mclk, true) >= | ||
5508 | ((RREG32(MC_SEQ_MISC7) >> 16) & 0xf)) | ||
5509 | dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false; | ||
5510 | else | ||
5511 | dll_state_on = ((RREG32(MC_SEQ_MISC6) >> 1) & 0x1) ? true : false; | ||
5512 | } else { | ||
5513 | dll_state_on = false; | ||
5514 | } | ||
5515 | } else { | ||
5516 | level->strobeMode = si_get_strobe_mode_settings(adev, | ||
5517 | pl->mclk); | ||
5518 | |||
5519 | dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false; | ||
5520 | } | ||
5521 | |||
5522 | ret = si_populate_mclk_value(adev, | ||
5523 | pl->sclk, | ||
5524 | pl->mclk, | ||
5525 | &level->mclk, | ||
5526 | (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) != 0, dll_state_on); | ||
5527 | if (ret) | ||
5528 | return ret; | ||
5529 | |||
5530 | ret = si_populate_voltage_value(adev, | ||
5531 | &eg_pi->vddc_voltage_table, | ||
5532 | pl->vddc, &level->vddc); | ||
5533 | if (ret) | ||
5534 | return ret; | ||
5535 | |||
5536 | |||
5537 | ret = si_get_std_voltage_value(adev, &level->vddc, &std_vddc); | ||
5538 | if (ret) | ||
5539 | return ret; | ||
5540 | |||
5541 | ret = si_populate_std_voltage_value(adev, std_vddc, | ||
5542 | level->vddc.index, &level->std_vddc); | ||
5543 | if (ret) | ||
5544 | return ret; | ||
5545 | |||
5546 | if (eg_pi->vddci_control) { | ||
5547 | ret = si_populate_voltage_value(adev, &eg_pi->vddci_voltage_table, | ||
5548 | pl->vddci, &level->vddci); | ||
5549 | if (ret) | ||
5550 | return ret; | ||
5551 | } | ||
5552 | |||
5553 | if (si_pi->vddc_phase_shed_control) { | ||
5554 | ret = si_populate_phase_shedding_value(adev, | ||
5555 | &adev->pm.dpm.dyn_state.phase_shedding_limits_table, | ||
5556 | pl->vddc, | ||
5557 | pl->sclk, | ||
5558 | pl->mclk, | ||
5559 | &level->vddc); | ||
5560 | if (ret) | ||
5561 | return ret; | ||
5562 | } | ||
5563 | |||
5564 | level->MaxPoweredUpCU = si_pi->max_cu; | ||
5565 | |||
5566 | ret = si_populate_mvdd_value(adev, pl->mclk, &level->mvdd); | ||
5567 | |||
5568 | return ret; | ||
5569 | } | ||
5570 | |||
5571 | static int si_populate_smc_t(struct amdgpu_device *adev, | ||
5572 | struct amdgpu_ps *amdgpu_state, | ||
5573 | SISLANDS_SMC_SWSTATE *smc_state) | ||
5574 | { | ||
5575 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
5576 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
5577 | u32 a_t; | ||
5578 | u32 t_l, t_h; | ||
5579 | u32 high_bsp; | ||
5580 | int i, ret; | ||
5581 | |||
5582 | if (state->performance_level_count >= 9) | ||
5583 | return -EINVAL; | ||
5584 | |||
5585 | if (state->performance_level_count < 2) { | ||
5586 | a_t = CG_R(0xffff) | CG_L(0); | ||
5587 | smc_state->levels[0].aT = cpu_to_be32(a_t); | ||
5588 | return 0; | ||
5589 | } | ||
5590 | |||
5591 | smc_state->levels[0].aT = cpu_to_be32(0); | ||
5592 | |||
5593 | for (i = 0; i <= state->performance_level_count - 2; i++) { | ||
5594 | ret = r600_calculate_at( | ||
5595 | (50 / SISLANDS_MAX_HARDWARE_POWERLEVELS) * 100 * (i + 1), | ||
5596 | 100 * R600_AH_DFLT, | ||
5597 | state->performance_levels[i + 1].sclk, | ||
5598 | state->performance_levels[i].sclk, | ||
5599 | &t_l, | ||
5600 | &t_h); | ||
5601 | |||
5602 | if (ret) { | ||
5603 | t_h = (i + 1) * 1000 - 50 * R600_AH_DFLT; | ||
5604 | t_l = (i + 1) * 1000 + 50 * R600_AH_DFLT; | ||
5605 | } | ||
5606 | |||
5607 | a_t = be32_to_cpu(smc_state->levels[i].aT) & ~CG_R_MASK; | ||
5608 | a_t |= CG_R(t_l * pi->bsp / 20000); | ||
5609 | smc_state->levels[i].aT = cpu_to_be32(a_t); | ||
5610 | |||
5611 | high_bsp = (i == state->performance_level_count - 2) ? | ||
5612 | pi->pbsp : pi->bsp; | ||
5613 | a_t = CG_R(0xffff) | CG_L(t_h * high_bsp / 20000); | ||
5614 | smc_state->levels[i + 1].aT = cpu_to_be32(a_t); | ||
5615 | } | ||
5616 | |||
5617 | return 0; | ||
5618 | } | ||
5619 | |||
5620 | static int si_disable_ulv(struct amdgpu_device *adev) | ||
5621 | { | ||
5622 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5623 | struct si_ulv_param *ulv = &si_pi->ulv; | ||
5624 | |||
5625 | if (ulv->supported) | ||
5626 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ? | ||
5627 | 0 : -EINVAL; | ||
5628 | |||
5629 | return 0; | ||
5630 | } | ||
5631 | |||
5632 | static bool si_is_state_ulv_compatible(struct amdgpu_device *adev, | ||
5633 | struct amdgpu_ps *amdgpu_state) | ||
5634 | { | ||
5635 | const struct si_power_info *si_pi = si_get_pi(adev); | ||
5636 | const struct si_ulv_param *ulv = &si_pi->ulv; | ||
5637 | const struct si_ps *state = si_get_ps(amdgpu_state); | ||
5638 | int i; | ||
5639 | |||
5640 | if (state->performance_levels[0].mclk != ulv->pl.mclk) | ||
5641 | return false; | ||
5642 | |||
5643 | /* XXX validate against display requirements! */ | ||
5644 | |||
5645 | for (i = 0; i < adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count; i++) { | ||
5646 | if (adev->clock.current_dispclk <= | ||
5647 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].clk) { | ||
5648 | if (ulv->pl.vddc < | ||
5649 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].v) | ||
5650 | return false; | ||
5651 | } | ||
5652 | } | ||
5653 | |||
5654 | if ((amdgpu_state->vclk != 0) || (amdgpu_state->dclk != 0)) | ||
5655 | return false; | ||
5656 | |||
5657 | return true; | ||
5658 | } | ||
5659 | |||
5660 | static int si_set_power_state_conditionally_enable_ulv(struct amdgpu_device *adev, | ||
5661 | struct amdgpu_ps *amdgpu_new_state) | ||
5662 | { | ||
5663 | const struct si_power_info *si_pi = si_get_pi(adev); | ||
5664 | const struct si_ulv_param *ulv = &si_pi->ulv; | ||
5665 | |||
5666 | if (ulv->supported) { | ||
5667 | if (si_is_state_ulv_compatible(adev, amdgpu_new_state)) | ||
5668 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableULV) == PPSMC_Result_OK) ? | ||
5669 | 0 : -EINVAL; | ||
5670 | } | ||
5671 | return 0; | ||
5672 | } | ||
5673 | |||
5674 | static int si_convert_power_state_to_smc(struct amdgpu_device *adev, | ||
5675 | struct amdgpu_ps *amdgpu_state, | ||
5676 | SISLANDS_SMC_SWSTATE *smc_state) | ||
5677 | { | ||
5678 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
5679 | struct ni_power_info *ni_pi = ni_get_pi(adev); | ||
5680 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5681 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
5682 | int i, ret; | ||
5683 | u32 threshold; | ||
5684 | u32 sclk_in_sr = 1350; /* ??? */ | ||
5685 | |||
5686 | if (state->performance_level_count > SISLANDS_MAX_HARDWARE_POWERLEVELS) | ||
5687 | return -EINVAL; | ||
5688 | |||
5689 | threshold = state->performance_levels[state->performance_level_count-1].sclk * 100 / 100; | ||
5690 | |||
5691 | if (amdgpu_state->vclk && amdgpu_state->dclk) { | ||
5692 | eg_pi->uvd_enabled = true; | ||
5693 | if (eg_pi->smu_uvd_hs) | ||
5694 | smc_state->flags |= PPSMC_SWSTATE_FLAG_UVD; | ||
5695 | } else { | ||
5696 | eg_pi->uvd_enabled = false; | ||
5697 | } | ||
5698 | |||
5699 | if (state->dc_compatible) | ||
5700 | smc_state->flags |= PPSMC_SWSTATE_FLAG_DC; | ||
5701 | |||
5702 | smc_state->levelCount = 0; | ||
5703 | for (i = 0; i < state->performance_level_count; i++) { | ||
5704 | if (eg_pi->sclk_deep_sleep) { | ||
5705 | if ((i == 0) || si_pi->sclk_deep_sleep_above_low) { | ||
5706 | if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ) | ||
5707 | smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS; | ||
5708 | else | ||
5709 | smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE; | ||
5710 | } | ||
5711 | } | ||
5712 | |||
5713 | ret = si_convert_power_level_to_smc(adev, &state->performance_levels[i], | ||
5714 | &smc_state->levels[i]); | ||
5715 | smc_state->levels[i].arbRefreshState = | ||
5716 | (u8)(SISLANDS_DRIVER_STATE_ARB_INDEX + i); | ||
5717 | |||
5718 | if (ret) | ||
5719 | return ret; | ||
5720 | |||
5721 | if (ni_pi->enable_power_containment) | ||
5722 | smc_state->levels[i].displayWatermark = | ||
5723 | (state->performance_levels[i].sclk < threshold) ? | ||
5724 | PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH; | ||
5725 | else | ||
5726 | smc_state->levels[i].displayWatermark = (i < 2) ? | ||
5727 | PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH; | ||
5728 | |||
5729 | if (eg_pi->dynamic_ac_timing) | ||
5730 | smc_state->levels[i].ACIndex = SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i; | ||
5731 | else | ||
5732 | smc_state->levels[i].ACIndex = 0; | ||
5733 | |||
5734 | smc_state->levelCount++; | ||
5735 | } | ||
5736 | |||
5737 | si_write_smc_soft_register(adev, | ||
5738 | SI_SMC_SOFT_REGISTER_watermark_threshold, | ||
5739 | threshold / 512); | ||
5740 | |||
5741 | si_populate_smc_sp(adev, amdgpu_state, smc_state); | ||
5742 | |||
5743 | ret = si_populate_power_containment_values(adev, amdgpu_state, smc_state); | ||
5744 | if (ret) | ||
5745 | ni_pi->enable_power_containment = false; | ||
5746 | |||
5747 | ret = si_populate_sq_ramping_values(adev, amdgpu_state, smc_state); | ||
5748 | if (ret) | ||
5749 | ni_pi->enable_sq_ramping = false; | ||
5750 | |||
5751 | return si_populate_smc_t(adev, amdgpu_state, smc_state); | ||
5752 | } | ||
5753 | |||
5754 | static int si_upload_sw_state(struct amdgpu_device *adev, | ||
5755 | struct amdgpu_ps *amdgpu_new_state) | ||
5756 | { | ||
5757 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5758 | struct si_ps *new_state = si_get_ps(amdgpu_new_state); | ||
5759 | int ret; | ||
5760 | u32 address = si_pi->state_table_start + | ||
5761 | offsetof(SISLANDS_SMC_STATETABLE, driverState); | ||
5762 | u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) + | ||
5763 | ((new_state->performance_level_count - 1) * | ||
5764 | sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL)); | ||
5765 | SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState; | ||
5766 | |||
5767 | memset(smc_state, 0, state_size); | ||
5768 | |||
5769 | ret = si_convert_power_state_to_smc(adev, amdgpu_new_state, smc_state); | ||
5770 | if (ret) | ||
5771 | return ret; | ||
5772 | |||
5773 | return amdgpu_si_copy_bytes_to_smc(adev, address, (u8 *)smc_state, | ||
5774 | state_size, si_pi->sram_end); | ||
5775 | } | ||
5776 | |||
5777 | static int si_upload_ulv_state(struct amdgpu_device *adev) | ||
5778 | { | ||
5779 | struct si_power_info *si_pi = si_get_pi(adev); | ||
5780 | struct si_ulv_param *ulv = &si_pi->ulv; | ||
5781 | int ret = 0; | ||
5782 | |||
5783 | if (ulv->supported && ulv->pl.vddc) { | ||
5784 | u32 address = si_pi->state_table_start + | ||
5785 | offsetof(SISLANDS_SMC_STATETABLE, ULVState); | ||
5786 | SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.ULVState; | ||
5787 | u32 state_size = sizeof(SISLANDS_SMC_SWSTATE); | ||
5788 | |||
5789 | memset(smc_state, 0, state_size); | ||
5790 | |||
5791 | ret = si_populate_ulv_state(adev, smc_state); | ||
5792 | if (!ret) | ||
5793 | ret = amdgpu_si_copy_bytes_to_smc(adev, address, (u8 *)smc_state, | ||
5794 | state_size, si_pi->sram_end); | ||
5795 | } | ||
5796 | |||
5797 | return ret; | ||
5798 | } | ||
5799 | |||
5800 | static int si_upload_smc_data(struct amdgpu_device *adev) | ||
5801 | { | ||
5802 | struct amdgpu_crtc *amdgpu_crtc = NULL; | ||
5803 | int i; | ||
5804 | |||
5805 | if (adev->pm.dpm.new_active_crtc_count == 0) | ||
5806 | return 0; | ||
5807 | |||
5808 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
5809 | if (adev->pm.dpm.new_active_crtcs & (1 << i)) { | ||
5810 | amdgpu_crtc = adev->mode_info.crtcs[i]; | ||
5811 | break; | ||
5812 | } | ||
5813 | } | ||
5814 | |||
5815 | if (amdgpu_crtc == NULL) | ||
5816 | return 0; | ||
5817 | |||
5818 | if (amdgpu_crtc->line_time <= 0) | ||
5819 | return 0; | ||
5820 | |||
5821 | if (si_write_smc_soft_register(adev, | ||
5822 | SI_SMC_SOFT_REGISTER_crtc_index, | ||
5823 | amdgpu_crtc->crtc_id) != PPSMC_Result_OK) | ||
5824 | return 0; | ||
5825 | |||
5826 | if (si_write_smc_soft_register(adev, | ||
5827 | SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, | ||
5828 | amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) | ||
5829 | return 0; | ||
5830 | |||
5831 | if (si_write_smc_soft_register(adev, | ||
5832 | SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, | ||
5833 | amdgpu_crtc->wm_low / amdgpu_crtc->line_time) != PPSMC_Result_OK) | ||
5834 | return 0; | ||
5835 | |||
5836 | return 0; | ||
5837 | } | ||
5838 | |||
5839 | static int si_set_mc_special_registers(struct amdgpu_device *adev, | ||
5840 | struct si_mc_reg_table *table) | ||
5841 | { | ||
5842 | u8 i, j, k; | ||
5843 | u32 temp_reg; | ||
5844 | |||
5845 | for (i = 0, j = table->last; i < table->last; i++) { | ||
5846 | if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
5847 | return -EINVAL; | ||
5848 | switch (table->mc_reg_address[i].s1) { | ||
5849 | case MC_SEQ_MISC1: | ||
5850 | temp_reg = RREG32(MC_PMG_CMD_EMRS); | ||
5851 | table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS; | ||
5852 | table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP; | ||
5853 | for (k = 0; k < table->num_entries; k++) | ||
5854 | table->mc_reg_table_entry[k].mc_data[j] = | ||
5855 | ((temp_reg & 0xffff0000)) | | ||
5856 | ((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16); | ||
5857 | j++; | ||
5858 | if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
5859 | return -EINVAL; | ||
5860 | |||
5861 | temp_reg = RREG32(MC_PMG_CMD_MRS); | ||
5862 | table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS; | ||
5863 | table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP; | ||
5864 | for (k = 0; k < table->num_entries; k++) { | ||
5865 | table->mc_reg_table_entry[k].mc_data[j] = | ||
5866 | (temp_reg & 0xffff0000) | | ||
5867 | (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff); | ||
5868 | if (adev->mc.vram_type != AMDGPU_VRAM_TYPE_GDDR5) | ||
5869 | table->mc_reg_table_entry[k].mc_data[j] |= 0x100; | ||
5870 | } | ||
5871 | j++; | ||
5872 | if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
5873 | return -EINVAL; | ||
5874 | |||
5875 | if (adev->mc.vram_type != AMDGPU_VRAM_TYPE_GDDR5) { | ||
5876 | table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD; | ||
5877 | table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD; | ||
5878 | for (k = 0; k < table->num_entries; k++) | ||
5879 | table->mc_reg_table_entry[k].mc_data[j] = | ||
5880 | (table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16; | ||
5881 | j++; | ||
5882 | if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
5883 | return -EINVAL; | ||
5884 | } | ||
5885 | break; | ||
5886 | case MC_SEQ_RESERVE_M: | ||
5887 | temp_reg = RREG32(MC_PMG_CMD_MRS1); | ||
5888 | table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1; | ||
5889 | table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP; | ||
5890 | for(k = 0; k < table->num_entries; k++) | ||
5891 | table->mc_reg_table_entry[k].mc_data[j] = | ||
5892 | (temp_reg & 0xffff0000) | | ||
5893 | (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff); | ||
5894 | j++; | ||
5895 | if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
5896 | return -EINVAL; | ||
5897 | break; | ||
5898 | default: | ||
5899 | break; | ||
5900 | } | ||
5901 | } | ||
5902 | |||
5903 | table->last = j; | ||
5904 | |||
5905 | return 0; | ||
5906 | } | ||
5907 | |||
5908 | static bool si_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg) | ||
5909 | { | ||
5910 | bool result = true; | ||
5911 | switch (in_reg) { | ||
5912 | case MC_SEQ_RAS_TIMING: | ||
5913 | *out_reg = MC_SEQ_RAS_TIMING_LP; | ||
5914 | break; | ||
5915 | case MC_SEQ_CAS_TIMING: | ||
5916 | *out_reg = MC_SEQ_CAS_TIMING_LP; | ||
5917 | break; | ||
5918 | case MC_SEQ_MISC_TIMING: | ||
5919 | *out_reg = MC_SEQ_MISC_TIMING_LP; | ||
5920 | break; | ||
5921 | case MC_SEQ_MISC_TIMING2: | ||
5922 | *out_reg = MC_SEQ_MISC_TIMING2_LP; | ||
5923 | break; | ||
5924 | case MC_SEQ_RD_CTL_D0: | ||
5925 | *out_reg = MC_SEQ_RD_CTL_D0_LP; | ||
5926 | break; | ||
5927 | case MC_SEQ_RD_CTL_D1: | ||
5928 | *out_reg = MC_SEQ_RD_CTL_D1_LP; | ||
5929 | break; | ||
5930 | case MC_SEQ_WR_CTL_D0: | ||
5931 | *out_reg = MC_SEQ_WR_CTL_D0_LP; | ||
5932 | break; | ||
5933 | case MC_SEQ_WR_CTL_D1: | ||
5934 | *out_reg = MC_SEQ_WR_CTL_D1_LP; | ||
5935 | break; | ||
5936 | case MC_PMG_CMD_EMRS: | ||
5937 | *out_reg = MC_SEQ_PMG_CMD_EMRS_LP; | ||
5938 | break; | ||
5939 | case MC_PMG_CMD_MRS: | ||
5940 | *out_reg = MC_SEQ_PMG_CMD_MRS_LP; | ||
5941 | break; | ||
5942 | case MC_PMG_CMD_MRS1: | ||
5943 | *out_reg = MC_SEQ_PMG_CMD_MRS1_LP; | ||
5944 | break; | ||
5945 | case MC_SEQ_PMG_TIMING: | ||
5946 | *out_reg = MC_SEQ_PMG_TIMING_LP; | ||
5947 | break; | ||
5948 | case MC_PMG_CMD_MRS2: | ||
5949 | *out_reg = MC_SEQ_PMG_CMD_MRS2_LP; | ||
5950 | break; | ||
5951 | case MC_SEQ_WR_CTL_2: | ||
5952 | *out_reg = MC_SEQ_WR_CTL_2_LP; | ||
5953 | break; | ||
5954 | default: | ||
5955 | result = false; | ||
5956 | break; | ||
5957 | } | ||
5958 | |||
5959 | return result; | ||
5960 | } | ||
5961 | |||
5962 | static void si_set_valid_flag(struct si_mc_reg_table *table) | ||
5963 | { | ||
5964 | u8 i, j; | ||
5965 | |||
5966 | for (i = 0; i < table->last; i++) { | ||
5967 | for (j = 1; j < table->num_entries; j++) { | ||
5968 | if (table->mc_reg_table_entry[j-1].mc_data[i] != table->mc_reg_table_entry[j].mc_data[i]) { | ||
5969 | table->valid_flag |= 1 << i; | ||
5970 | break; | ||
5971 | } | ||
5972 | } | ||
5973 | } | ||
5974 | } | ||
5975 | |||
5976 | static void si_set_s0_mc_reg_index(struct si_mc_reg_table *table) | ||
5977 | { | ||
5978 | u32 i; | ||
5979 | u16 address; | ||
5980 | |||
5981 | for (i = 0; i < table->last; i++) | ||
5982 | table->mc_reg_address[i].s0 = si_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ? | ||
5983 | address : table->mc_reg_address[i].s1; | ||
5984 | |||
5985 | } | ||
5986 | |||
5987 | static int si_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table, | ||
5988 | struct si_mc_reg_table *si_table) | ||
5989 | { | ||
5990 | u8 i, j; | ||
5991 | |||
5992 | if (table->last > SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
5993 | return -EINVAL; | ||
5994 | if (table->num_entries > MAX_AC_TIMING_ENTRIES) | ||
5995 | return -EINVAL; | ||
5996 | |||
5997 | for (i = 0; i < table->last; i++) | ||
5998 | si_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1; | ||
5999 | si_table->last = table->last; | ||
6000 | |||
6001 | for (i = 0; i < table->num_entries; i++) { | ||
6002 | si_table->mc_reg_table_entry[i].mclk_max = | ||
6003 | table->mc_reg_table_entry[i].mclk_max; | ||
6004 | for (j = 0; j < table->last; j++) { | ||
6005 | si_table->mc_reg_table_entry[i].mc_data[j] = | ||
6006 | table->mc_reg_table_entry[i].mc_data[j]; | ||
6007 | } | ||
6008 | } | ||
6009 | si_table->num_entries = table->num_entries; | ||
6010 | |||
6011 | return 0; | ||
6012 | } | ||
6013 | |||
6014 | static int si_initialize_mc_reg_table(struct amdgpu_device *adev) | ||
6015 | { | ||
6016 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6017 | struct atom_mc_reg_table *table; | ||
6018 | struct si_mc_reg_table *si_table = &si_pi->mc_reg_table; | ||
6019 | u8 module_index = rv770_get_memory_module_index(adev); | ||
6020 | int ret; | ||
6021 | |||
6022 | table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL); | ||
6023 | if (!table) | ||
6024 | return -ENOMEM; | ||
6025 | |||
6026 | WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING)); | ||
6027 | WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING)); | ||
6028 | WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING)); | ||
6029 | WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2)); | ||
6030 | WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS)); | ||
6031 | WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS)); | ||
6032 | WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1)); | ||
6033 | WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0)); | ||
6034 | WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1)); | ||
6035 | WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0)); | ||
6036 | WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1)); | ||
6037 | WREG32(MC_SEQ_PMG_TIMING_LP, RREG32(MC_SEQ_PMG_TIMING)); | ||
6038 | WREG32(MC_SEQ_PMG_CMD_MRS2_LP, RREG32(MC_PMG_CMD_MRS2)); | ||
6039 | WREG32(MC_SEQ_WR_CTL_2_LP, RREG32(MC_SEQ_WR_CTL_2)); | ||
6040 | |||
6041 | ret = amdgpu_atombios_init_mc_reg_table(adev, module_index, table); | ||
6042 | if (ret) | ||
6043 | goto init_mc_done; | ||
6044 | |||
6045 | ret = si_copy_vbios_mc_reg_table(table, si_table); | ||
6046 | if (ret) | ||
6047 | goto init_mc_done; | ||
6048 | |||
6049 | si_set_s0_mc_reg_index(si_table); | ||
6050 | |||
6051 | ret = si_set_mc_special_registers(adev, si_table); | ||
6052 | if (ret) | ||
6053 | goto init_mc_done; | ||
6054 | |||
6055 | si_set_valid_flag(si_table); | ||
6056 | |||
6057 | init_mc_done: | ||
6058 | kfree(table); | ||
6059 | |||
6060 | return ret; | ||
6061 | |||
6062 | } | ||
6063 | |||
6064 | static void si_populate_mc_reg_addresses(struct amdgpu_device *adev, | ||
6065 | SMC_SIslands_MCRegisters *mc_reg_table) | ||
6066 | { | ||
6067 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6068 | u32 i, j; | ||
6069 | |||
6070 | for (i = 0, j = 0; j < si_pi->mc_reg_table.last; j++) { | ||
6071 | if (si_pi->mc_reg_table.valid_flag & (1 << j)) { | ||
6072 | if (i >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE) | ||
6073 | break; | ||
6074 | mc_reg_table->address[i].s0 = | ||
6075 | cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s0); | ||
6076 | mc_reg_table->address[i].s1 = | ||
6077 | cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s1); | ||
6078 | i++; | ||
6079 | } | ||
6080 | } | ||
6081 | mc_reg_table->last = (u8)i; | ||
6082 | } | ||
6083 | |||
6084 | static void si_convert_mc_registers(const struct si_mc_reg_entry *entry, | ||
6085 | SMC_SIslands_MCRegisterSet *data, | ||
6086 | u32 num_entries, u32 valid_flag) | ||
6087 | { | ||
6088 | u32 i, j; | ||
6089 | |||
6090 | for(i = 0, j = 0; j < num_entries; j++) { | ||
6091 | if (valid_flag & (1 << j)) { | ||
6092 | data->value[i] = cpu_to_be32(entry->mc_data[j]); | ||
6093 | i++; | ||
6094 | } | ||
6095 | } | ||
6096 | } | ||
6097 | |||
6098 | static void si_convert_mc_reg_table_entry_to_smc(struct amdgpu_device *adev, | ||
6099 | struct rv7xx_pl *pl, | ||
6100 | SMC_SIslands_MCRegisterSet *mc_reg_table_data) | ||
6101 | { | ||
6102 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6103 | u32 i = 0; | ||
6104 | |||
6105 | for (i = 0; i < si_pi->mc_reg_table.num_entries; i++) { | ||
6106 | if (pl->mclk <= si_pi->mc_reg_table.mc_reg_table_entry[i].mclk_max) | ||
6107 | break; | ||
6108 | } | ||
6109 | |||
6110 | if ((i == si_pi->mc_reg_table.num_entries) && (i > 0)) | ||
6111 | --i; | ||
6112 | |||
6113 | si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[i], | ||
6114 | mc_reg_table_data, si_pi->mc_reg_table.last, | ||
6115 | si_pi->mc_reg_table.valid_flag); | ||
6116 | } | ||
6117 | |||
6118 | static void si_convert_mc_reg_table_to_smc(struct amdgpu_device *adev, | ||
6119 | struct amdgpu_ps *amdgpu_state, | ||
6120 | SMC_SIslands_MCRegisters *mc_reg_table) | ||
6121 | { | ||
6122 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
6123 | int i; | ||
6124 | |||
6125 | for (i = 0; i < state->performance_level_count; i++) { | ||
6126 | si_convert_mc_reg_table_entry_to_smc(adev, | ||
6127 | &state->performance_levels[i], | ||
6128 | &mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i]); | ||
6129 | } | ||
6130 | } | ||
6131 | |||
6132 | static int si_populate_mc_reg_table(struct amdgpu_device *adev, | ||
6133 | struct amdgpu_ps *amdgpu_boot_state) | ||
6134 | { | ||
6135 | struct si_ps *boot_state = si_get_ps(amdgpu_boot_state); | ||
6136 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6137 | struct si_ulv_param *ulv = &si_pi->ulv; | ||
6138 | SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table; | ||
6139 | |||
6140 | memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters)); | ||
6141 | |||
6142 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_seq_index, 1); | ||
6143 | |||
6144 | si_populate_mc_reg_addresses(adev, smc_mc_reg_table); | ||
6145 | |||
6146 | si_convert_mc_reg_table_entry_to_smc(adev, &boot_state->performance_levels[0], | ||
6147 | &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_INITIAL_SLOT]); | ||
6148 | |||
6149 | si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0], | ||
6150 | &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ACPI_SLOT], | ||
6151 | si_pi->mc_reg_table.last, | ||
6152 | si_pi->mc_reg_table.valid_flag); | ||
6153 | |||
6154 | if (ulv->supported && ulv->pl.vddc != 0) | ||
6155 | si_convert_mc_reg_table_entry_to_smc(adev, &ulv->pl, | ||
6156 | &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT]); | ||
6157 | else | ||
6158 | si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0], | ||
6159 | &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT], | ||
6160 | si_pi->mc_reg_table.last, | ||
6161 | si_pi->mc_reg_table.valid_flag); | ||
6162 | |||
6163 | si_convert_mc_reg_table_to_smc(adev, amdgpu_boot_state, smc_mc_reg_table); | ||
6164 | |||
6165 | return amdgpu_si_copy_bytes_to_smc(adev, si_pi->mc_reg_table_start, | ||
6166 | (u8 *)smc_mc_reg_table, | ||
6167 | sizeof(SMC_SIslands_MCRegisters), si_pi->sram_end); | ||
6168 | } | ||
6169 | |||
6170 | static int si_upload_mc_reg_table(struct amdgpu_device *adev, | ||
6171 | struct amdgpu_ps *amdgpu_new_state) | ||
6172 | { | ||
6173 | struct si_ps *new_state = si_get_ps(amdgpu_new_state); | ||
6174 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6175 | u32 address = si_pi->mc_reg_table_start + | ||
6176 | offsetof(SMC_SIslands_MCRegisters, | ||
6177 | data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT]); | ||
6178 | SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table; | ||
6179 | |||
6180 | memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters)); | ||
6181 | |||
6182 | si_convert_mc_reg_table_to_smc(adev, amdgpu_new_state, smc_mc_reg_table); | ||
6183 | |||
6184 | return amdgpu_si_copy_bytes_to_smc(adev, address, | ||
6185 | (u8 *)&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT], | ||
6186 | sizeof(SMC_SIslands_MCRegisterSet) * new_state->performance_level_count, | ||
6187 | si_pi->sram_end); | ||
6188 | } | ||
6189 | |||
6190 | static void si_enable_voltage_control(struct amdgpu_device *adev, bool enable) | ||
6191 | { | ||
6192 | if (enable) | ||
6193 | WREG32_P(GENERAL_PWRMGT, VOLT_PWRMGT_EN, ~VOLT_PWRMGT_EN); | ||
6194 | else | ||
6195 | WREG32_P(GENERAL_PWRMGT, 0, ~VOLT_PWRMGT_EN); | ||
6196 | } | ||
6197 | |||
6198 | static enum amdgpu_pcie_gen si_get_maximum_link_speed(struct amdgpu_device *adev, | ||
6199 | struct amdgpu_ps *amdgpu_state) | ||
6200 | { | ||
6201 | struct si_ps *state = si_get_ps(amdgpu_state); | ||
6202 | int i; | ||
6203 | u16 pcie_speed, max_speed = 0; | ||
6204 | |||
6205 | for (i = 0; i < state->performance_level_count; i++) { | ||
6206 | pcie_speed = state->performance_levels[i].pcie_gen; | ||
6207 | if (max_speed < pcie_speed) | ||
6208 | max_speed = pcie_speed; | ||
6209 | } | ||
6210 | return max_speed; | ||
6211 | } | ||
6212 | |||
6213 | static u16 si_get_current_pcie_speed(struct amdgpu_device *adev) | ||
6214 | { | ||
6215 | u32 speed_cntl; | ||
6216 | |||
6217 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL) & LC_CURRENT_DATA_RATE_MASK; | ||
6218 | speed_cntl >>= LC_CURRENT_DATA_RATE_SHIFT; | ||
6219 | |||
6220 | return (u16)speed_cntl; | ||
6221 | } | ||
6222 | |||
6223 | static void si_request_link_speed_change_before_state_change(struct amdgpu_device *adev, | ||
6224 | struct amdgpu_ps *amdgpu_new_state, | ||
6225 | struct amdgpu_ps *amdgpu_current_state) | ||
6226 | { | ||
6227 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6228 | enum amdgpu_pcie_gen target_link_speed = si_get_maximum_link_speed(adev, amdgpu_new_state); | ||
6229 | enum amdgpu_pcie_gen current_link_speed; | ||
6230 | |||
6231 | if (si_pi->force_pcie_gen == AMDGPU_PCIE_GEN_INVALID) | ||
6232 | current_link_speed = si_get_maximum_link_speed(adev, amdgpu_current_state); | ||
6233 | else | ||
6234 | current_link_speed = si_pi->force_pcie_gen; | ||
6235 | |||
6236 | si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID; | ||
6237 | si_pi->pspp_notify_required = false; | ||
6238 | if (target_link_speed > current_link_speed) { | ||
6239 | switch (target_link_speed) { | ||
6240 | #if defined(CONFIG_ACPI) | ||
6241 | case AMDGPU_PCIE_GEN3: | ||
6242 | if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN3, false) == 0) | ||
6243 | break; | ||
6244 | si_pi->force_pcie_gen = AMDGPU_PCIE_GEN2; | ||
6245 | if (current_link_speed == AMDGPU_PCIE_GEN2) | ||
6246 | break; | ||
6247 | case AMDGPU_PCIE_GEN2: | ||
6248 | if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) | ||
6249 | break; | ||
6250 | #endif | ||
6251 | default: | ||
6252 | si_pi->force_pcie_gen = si_get_current_pcie_speed(adev); | ||
6253 | break; | ||
6254 | } | ||
6255 | } else { | ||
6256 | if (target_link_speed < current_link_speed) | ||
6257 | si_pi->pspp_notify_required = true; | ||
6258 | } | ||
6259 | } | ||
6260 | |||
6261 | static void si_notify_link_speed_change_after_state_change(struct amdgpu_device *adev, | ||
6262 | struct amdgpu_ps *amdgpu_new_state, | ||
6263 | struct amdgpu_ps *amdgpu_current_state) | ||
6264 | { | ||
6265 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6266 | enum amdgpu_pcie_gen target_link_speed = si_get_maximum_link_speed(adev, amdgpu_new_state); | ||
6267 | u8 request; | ||
6268 | |||
6269 | if (si_pi->pspp_notify_required) { | ||
6270 | if (target_link_speed == AMDGPU_PCIE_GEN3) | ||
6271 | request = PCIE_PERF_REQ_PECI_GEN3; | ||
6272 | else if (target_link_speed == AMDGPU_PCIE_GEN2) | ||
6273 | request = PCIE_PERF_REQ_PECI_GEN2; | ||
6274 | else | ||
6275 | request = PCIE_PERF_REQ_PECI_GEN1; | ||
6276 | |||
6277 | if ((request == PCIE_PERF_REQ_PECI_GEN1) && | ||
6278 | (si_get_current_pcie_speed(adev) > 0)) | ||
6279 | return; | ||
6280 | |||
6281 | #if defined(CONFIG_ACPI) | ||
6282 | amdgpu_acpi_pcie_performance_request(adev, request, false); | ||
6283 | #endif | ||
6284 | } | ||
6285 | } | ||
6286 | |||
6287 | #if 0 | ||
6288 | static int si_ds_request(struct amdgpu_device *adev, | ||
6289 | bool ds_status_on, u32 count_write) | ||
6290 | { | ||
6291 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
6292 | |||
6293 | if (eg_pi->sclk_deep_sleep) { | ||
6294 | if (ds_status_on) | ||
6295 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_CancelThrottleOVRDSCLKDS) == | ||
6296 | PPSMC_Result_OK) ? | ||
6297 | 0 : -EINVAL; | ||
6298 | else | ||
6299 | return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_ThrottleOVRDSCLKDS) == | ||
6300 | PPSMC_Result_OK) ? 0 : -EINVAL; | ||
6301 | } | ||
6302 | return 0; | ||
6303 | } | ||
6304 | #endif | ||
6305 | |||
6306 | static void si_set_max_cu_value(struct amdgpu_device *adev) | ||
6307 | { | ||
6308 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6309 | |||
6310 | if (adev->asic_type == CHIP_VERDE) { | ||
6311 | switch (adev->pdev->device) { | ||
6312 | case 0x6820: | ||
6313 | case 0x6825: | ||
6314 | case 0x6821: | ||
6315 | case 0x6823: | ||
6316 | case 0x6827: | ||
6317 | si_pi->max_cu = 10; | ||
6318 | break; | ||
6319 | case 0x682D: | ||
6320 | case 0x6824: | ||
6321 | case 0x682F: | ||
6322 | case 0x6826: | ||
6323 | si_pi->max_cu = 8; | ||
6324 | break; | ||
6325 | case 0x6828: | ||
6326 | case 0x6830: | ||
6327 | case 0x6831: | ||
6328 | case 0x6838: | ||
6329 | case 0x6839: | ||
6330 | case 0x683D: | ||
6331 | si_pi->max_cu = 10; | ||
6332 | break; | ||
6333 | case 0x683B: | ||
6334 | case 0x683F: | ||
6335 | case 0x6829: | ||
6336 | si_pi->max_cu = 8; | ||
6337 | break; | ||
6338 | default: | ||
6339 | si_pi->max_cu = 0; | ||
6340 | break; | ||
6341 | } | ||
6342 | } else { | ||
6343 | si_pi->max_cu = 0; | ||
6344 | } | ||
6345 | } | ||
6346 | |||
6347 | static int si_patch_single_dependency_table_based_on_leakage(struct amdgpu_device *adev, | ||
6348 | struct amdgpu_clock_voltage_dependency_table *table) | ||
6349 | { | ||
6350 | u32 i; | ||
6351 | int j; | ||
6352 | u16 leakage_voltage; | ||
6353 | |||
6354 | if (table) { | ||
6355 | for (i = 0; i < table->count; i++) { | ||
6356 | switch (si_get_leakage_voltage_from_leakage_index(adev, | ||
6357 | table->entries[i].v, | ||
6358 | &leakage_voltage)) { | ||
6359 | case 0: | ||
6360 | table->entries[i].v = leakage_voltage; | ||
6361 | break; | ||
6362 | case -EAGAIN: | ||
6363 | return -EINVAL; | ||
6364 | case -EINVAL: | ||
6365 | default: | ||
6366 | break; | ||
6367 | } | ||
6368 | } | ||
6369 | |||
6370 | for (j = (table->count - 2); j >= 0; j--) { | ||
6371 | table->entries[j].v = (table->entries[j].v <= table->entries[j + 1].v) ? | ||
6372 | table->entries[j].v : table->entries[j + 1].v; | ||
6373 | } | ||
6374 | } | ||
6375 | return 0; | ||
6376 | } | ||
6377 | |||
6378 | static int si_patch_dependency_tables_based_on_leakage(struct amdgpu_device *adev) | ||
6379 | { | ||
6380 | int ret = 0; | ||
6381 | |||
6382 | ret = si_patch_single_dependency_table_based_on_leakage(adev, | ||
6383 | &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk); | ||
6384 | if (ret) | ||
6385 | DRM_ERROR("Could not patch vddc_on_sclk leakage table\n"); | ||
6386 | ret = si_patch_single_dependency_table_based_on_leakage(adev, | ||
6387 | &adev->pm.dpm.dyn_state.vddc_dependency_on_mclk); | ||
6388 | if (ret) | ||
6389 | DRM_ERROR("Could not patch vddc_on_mclk leakage table\n"); | ||
6390 | ret = si_patch_single_dependency_table_based_on_leakage(adev, | ||
6391 | &adev->pm.dpm.dyn_state.vddci_dependency_on_mclk); | ||
6392 | if (ret) | ||
6393 | DRM_ERROR("Could not patch vddci_on_mclk leakage table\n"); | ||
6394 | return ret; | ||
6395 | } | ||
6396 | |||
6397 | static void si_set_pcie_lane_width_in_smc(struct amdgpu_device *adev, | ||
6398 | struct amdgpu_ps *amdgpu_new_state, | ||
6399 | struct amdgpu_ps *amdgpu_current_state) | ||
6400 | { | ||
6401 | u32 lane_width; | ||
6402 | u32 new_lane_width = | ||
6403 | (amdgpu_new_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT; | ||
6404 | u32 current_lane_width = | ||
6405 | (amdgpu_current_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT; | ||
6406 | |||
6407 | if (new_lane_width != current_lane_width) { | ||
6408 | amdgpu_set_pcie_lanes(adev, new_lane_width); | ||
6409 | lane_width = amdgpu_get_pcie_lanes(adev); | ||
6410 | si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width); | ||
6411 | } | ||
6412 | } | ||
6413 | |||
6414 | static void si_dpm_setup_asic(struct amdgpu_device *adev) | ||
6415 | { | ||
6416 | si_read_clock_registers(adev); | ||
6417 | si_enable_acpi_power_management(adev); | ||
6418 | } | ||
6419 | |||
6420 | static int si_thermal_enable_alert(struct amdgpu_device *adev, | ||
6421 | bool enable) | ||
6422 | { | ||
6423 | u32 thermal_int = RREG32(CG_THERMAL_INT); | ||
6424 | |||
6425 | if (enable) { | ||
6426 | PPSMC_Result result; | ||
6427 | |||
6428 | thermal_int &= ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW); | ||
6429 | WREG32(CG_THERMAL_INT, thermal_int); | ||
6430 | result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableThermalInterrupt); | ||
6431 | if (result != PPSMC_Result_OK) { | ||
6432 | DRM_DEBUG_KMS("Could not enable thermal interrupts.\n"); | ||
6433 | return -EINVAL; | ||
6434 | } | ||
6435 | } else { | ||
6436 | thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW; | ||
6437 | WREG32(CG_THERMAL_INT, thermal_int); | ||
6438 | } | ||
6439 | |||
6440 | return 0; | ||
6441 | } | ||
6442 | |||
6443 | static int si_thermal_set_temperature_range(struct amdgpu_device *adev, | ||
6444 | int min_temp, int max_temp) | ||
6445 | { | ||
6446 | int low_temp = 0 * 1000; | ||
6447 | int high_temp = 255 * 1000; | ||
6448 | |||
6449 | if (low_temp < min_temp) | ||
6450 | low_temp = min_temp; | ||
6451 | if (high_temp > max_temp) | ||
6452 | high_temp = max_temp; | ||
6453 | if (high_temp < low_temp) { | ||
6454 | DRM_ERROR("invalid thermal range: %d - %d\n", low_temp, high_temp); | ||
6455 | return -EINVAL; | ||
6456 | } | ||
6457 | |||
6458 | WREG32_P(CG_THERMAL_INT, DIG_THERM_INTH(high_temp / 1000), ~DIG_THERM_INTH_MASK); | ||
6459 | WREG32_P(CG_THERMAL_INT, DIG_THERM_INTL(low_temp / 1000), ~DIG_THERM_INTL_MASK); | ||
6460 | WREG32_P(CG_THERMAL_CTRL, DIG_THERM_DPM(high_temp / 1000), ~DIG_THERM_DPM_MASK); | ||
6461 | |||
6462 | adev->pm.dpm.thermal.min_temp = low_temp; | ||
6463 | adev->pm.dpm.thermal.max_temp = high_temp; | ||
6464 | |||
6465 | return 0; | ||
6466 | } | ||
6467 | |||
6468 | static void si_fan_ctrl_set_static_mode(struct amdgpu_device *adev, u32 mode) | ||
6469 | { | ||
6470 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6471 | u32 tmp; | ||
6472 | |||
6473 | if (si_pi->fan_ctrl_is_in_default_mode) { | ||
6474 | tmp = (RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK) >> FDO_PWM_MODE_SHIFT; | ||
6475 | si_pi->fan_ctrl_default_mode = tmp; | ||
6476 | tmp = (RREG32(CG_FDO_CTRL2) & TMIN_MASK) >> TMIN_SHIFT; | ||
6477 | si_pi->t_min = tmp; | ||
6478 | si_pi->fan_ctrl_is_in_default_mode = false; | ||
6479 | } | ||
6480 | |||
6481 | tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK; | ||
6482 | tmp |= TMIN(0); | ||
6483 | WREG32(CG_FDO_CTRL2, tmp); | ||
6484 | |||
6485 | tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK; | ||
6486 | tmp |= FDO_PWM_MODE(mode); | ||
6487 | WREG32(CG_FDO_CTRL2, tmp); | ||
6488 | } | ||
6489 | |||
6490 | static int si_thermal_setup_fan_table(struct amdgpu_device *adev) | ||
6491 | { | ||
6492 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6493 | PP_SIslands_FanTable fan_table = { FDO_MODE_HARDWARE }; | ||
6494 | u32 duty100; | ||
6495 | u32 t_diff1, t_diff2, pwm_diff1, pwm_diff2; | ||
6496 | u16 fdo_min, slope1, slope2; | ||
6497 | u32 reference_clock, tmp; | ||
6498 | int ret; | ||
6499 | u64 tmp64; | ||
6500 | |||
6501 | if (!si_pi->fan_table_start) { | ||
6502 | adev->pm.dpm.fan.ucode_fan_control = false; | ||
6503 | return 0; | ||
6504 | } | ||
6505 | |||
6506 | duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT; | ||
6507 | |||
6508 | if (duty100 == 0) { | ||
6509 | adev->pm.dpm.fan.ucode_fan_control = false; | ||
6510 | return 0; | ||
6511 | } | ||
6512 | |||
6513 | tmp64 = (u64)adev->pm.dpm.fan.pwm_min * duty100; | ||
6514 | do_div(tmp64, 10000); | ||
6515 | fdo_min = (u16)tmp64; | ||
6516 | |||
6517 | t_diff1 = adev->pm.dpm.fan.t_med - adev->pm.dpm.fan.t_min; | ||
6518 | t_diff2 = adev->pm.dpm.fan.t_high - adev->pm.dpm.fan.t_med; | ||
6519 | |||
6520 | pwm_diff1 = adev->pm.dpm.fan.pwm_med - adev->pm.dpm.fan.pwm_min; | ||
6521 | pwm_diff2 = adev->pm.dpm.fan.pwm_high - adev->pm.dpm.fan.pwm_med; | ||
6522 | |||
6523 | slope1 = (u16)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100); | ||
6524 | slope2 = (u16)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100); | ||
6525 | |||
6526 | fan_table.temp_min = cpu_to_be16((50 + adev->pm.dpm.fan.t_min) / 100); | ||
6527 | fan_table.temp_med = cpu_to_be16((50 + adev->pm.dpm.fan.t_med) / 100); | ||
6528 | fan_table.temp_max = cpu_to_be16((50 + adev->pm.dpm.fan.t_max) / 100); | ||
6529 | fan_table.slope1 = cpu_to_be16(slope1); | ||
6530 | fan_table.slope2 = cpu_to_be16(slope2); | ||
6531 | fan_table.fdo_min = cpu_to_be16(fdo_min); | ||
6532 | fan_table.hys_down = cpu_to_be16(adev->pm.dpm.fan.t_hyst); | ||
6533 | fan_table.hys_up = cpu_to_be16(1); | ||
6534 | fan_table.hys_slope = cpu_to_be16(1); | ||
6535 | fan_table.temp_resp_lim = cpu_to_be16(5); | ||
6536 | reference_clock = amdgpu_asic_get_xclk(adev); | ||
6537 | |||
6538 | fan_table.refresh_period = cpu_to_be32((adev->pm.dpm.fan.cycle_delay * | ||
6539 | reference_clock) / 1600); | ||
6540 | fan_table.fdo_max = cpu_to_be16((u16)duty100); | ||
6541 | |||
6542 | tmp = (RREG32(CG_MULT_THERMAL_CTRL) & TEMP_SEL_MASK) >> TEMP_SEL_SHIFT; | ||
6543 | fan_table.temp_src = (uint8_t)tmp; | ||
6544 | |||
6545 | ret = amdgpu_si_copy_bytes_to_smc(adev, | ||
6546 | si_pi->fan_table_start, | ||
6547 | (u8 *)(&fan_table), | ||
6548 | sizeof(fan_table), | ||
6549 | si_pi->sram_end); | ||
6550 | |||
6551 | if (ret) { | ||
6552 | DRM_ERROR("Failed to load fan table to the SMC."); | ||
6553 | adev->pm.dpm.fan.ucode_fan_control = false; | ||
6554 | } | ||
6555 | |||
6556 | return ret; | ||
6557 | } | ||
6558 | |||
6559 | static int si_fan_ctrl_start_smc_fan_control(struct amdgpu_device *adev) | ||
6560 | { | ||
6561 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6562 | PPSMC_Result ret; | ||
6563 | |||
6564 | ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_StartFanControl); | ||
6565 | if (ret == PPSMC_Result_OK) { | ||
6566 | si_pi->fan_is_controlled_by_smc = true; | ||
6567 | return 0; | ||
6568 | } else { | ||
6569 | return -EINVAL; | ||
6570 | } | ||
6571 | } | ||
6572 | |||
6573 | static int si_fan_ctrl_stop_smc_fan_control(struct amdgpu_device *adev) | ||
6574 | { | ||
6575 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6576 | PPSMC_Result ret; | ||
6577 | |||
6578 | ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_StopFanControl); | ||
6579 | |||
6580 | if (ret == PPSMC_Result_OK) { | ||
6581 | si_pi->fan_is_controlled_by_smc = false; | ||
6582 | return 0; | ||
6583 | } else { | ||
6584 | return -EINVAL; | ||
6585 | } | ||
6586 | } | ||
6587 | |||
6588 | static int si_dpm_get_fan_speed_percent(struct amdgpu_device *adev, | ||
6589 | u32 *speed) | ||
6590 | { | ||
6591 | u32 duty, duty100; | ||
6592 | u64 tmp64; | ||
6593 | |||
6594 | if (adev->pm.no_fan) | ||
6595 | return -ENOENT; | ||
6596 | |||
6597 | duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT; | ||
6598 | duty = (RREG32(CG_THERMAL_STATUS) & FDO_PWM_DUTY_MASK) >> FDO_PWM_DUTY_SHIFT; | ||
6599 | |||
6600 | if (duty100 == 0) | ||
6601 | return -EINVAL; | ||
6602 | |||
6603 | tmp64 = (u64)duty * 100; | ||
6604 | do_div(tmp64, duty100); | ||
6605 | *speed = (u32)tmp64; | ||
6606 | |||
6607 | if (*speed > 100) | ||
6608 | *speed = 100; | ||
6609 | |||
6610 | return 0; | ||
6611 | } | ||
6612 | |||
6613 | static int si_dpm_set_fan_speed_percent(struct amdgpu_device *adev, | ||
6614 | u32 speed) | ||
6615 | { | ||
6616 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6617 | u32 tmp; | ||
6618 | u32 duty, duty100; | ||
6619 | u64 tmp64; | ||
6620 | |||
6621 | if (adev->pm.no_fan) | ||
6622 | return -ENOENT; | ||
6623 | |||
6624 | if (si_pi->fan_is_controlled_by_smc) | ||
6625 | return -EINVAL; | ||
6626 | |||
6627 | if (speed > 100) | ||
6628 | return -EINVAL; | ||
6629 | |||
6630 | duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT; | ||
6631 | |||
6632 | if (duty100 == 0) | ||
6633 | return -EINVAL; | ||
6634 | |||
6635 | tmp64 = (u64)speed * duty100; | ||
6636 | do_div(tmp64, 100); | ||
6637 | duty = (u32)tmp64; | ||
6638 | |||
6639 | tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK; | ||
6640 | tmp |= FDO_STATIC_DUTY(duty); | ||
6641 | WREG32(CG_FDO_CTRL0, tmp); | ||
6642 | |||
6643 | return 0; | ||
6644 | } | ||
6645 | |||
6646 | static void si_dpm_set_fan_control_mode(struct amdgpu_device *adev, u32 mode) | ||
6647 | { | ||
6648 | if (mode) { | ||
6649 | /* stop auto-manage */ | ||
6650 | if (adev->pm.dpm.fan.ucode_fan_control) | ||
6651 | si_fan_ctrl_stop_smc_fan_control(adev); | ||
6652 | si_fan_ctrl_set_static_mode(adev, mode); | ||
6653 | } else { | ||
6654 | /* restart auto-manage */ | ||
6655 | if (adev->pm.dpm.fan.ucode_fan_control) | ||
6656 | si_thermal_start_smc_fan_control(adev); | ||
6657 | else | ||
6658 | si_fan_ctrl_set_default_mode(adev); | ||
6659 | } | ||
6660 | } | ||
6661 | |||
6662 | static u32 si_dpm_get_fan_control_mode(struct amdgpu_device *adev) | ||
6663 | { | ||
6664 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6665 | u32 tmp; | ||
6666 | |||
6667 | if (si_pi->fan_is_controlled_by_smc) | ||
6668 | return 0; | ||
6669 | |||
6670 | tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK; | ||
6671 | return (tmp >> FDO_PWM_MODE_SHIFT); | ||
6672 | } | ||
6673 | |||
6674 | #if 0 | ||
6675 | static int si_fan_ctrl_get_fan_speed_rpm(struct amdgpu_device *adev, | ||
6676 | u32 *speed) | ||
6677 | { | ||
6678 | u32 tach_period; | ||
6679 | u32 xclk = amdgpu_asic_get_xclk(adev); | ||
6680 | |||
6681 | if (adev->pm.no_fan) | ||
6682 | return -ENOENT; | ||
6683 | |||
6684 | if (adev->pm.fan_pulses_per_revolution == 0) | ||
6685 | return -ENOENT; | ||
6686 | |||
6687 | tach_period = (RREG32(CG_TACH_STATUS) & TACH_PERIOD_MASK) >> TACH_PERIOD_SHIFT; | ||
6688 | if (tach_period == 0) | ||
6689 | return -ENOENT; | ||
6690 | |||
6691 | *speed = 60 * xclk * 10000 / tach_period; | ||
6692 | |||
6693 | return 0; | ||
6694 | } | ||
6695 | |||
6696 | static int si_fan_ctrl_set_fan_speed_rpm(struct amdgpu_device *adev, | ||
6697 | u32 speed) | ||
6698 | { | ||
6699 | u32 tach_period, tmp; | ||
6700 | u32 xclk = amdgpu_asic_get_xclk(adev); | ||
6701 | |||
6702 | if (adev->pm.no_fan) | ||
6703 | return -ENOENT; | ||
6704 | |||
6705 | if (adev->pm.fan_pulses_per_revolution == 0) | ||
6706 | return -ENOENT; | ||
6707 | |||
6708 | if ((speed < adev->pm.fan_min_rpm) || | ||
6709 | (speed > adev->pm.fan_max_rpm)) | ||
6710 | return -EINVAL; | ||
6711 | |||
6712 | if (adev->pm.dpm.fan.ucode_fan_control) | ||
6713 | si_fan_ctrl_stop_smc_fan_control(adev); | ||
6714 | |||
6715 | tach_period = 60 * xclk * 10000 / (8 * speed); | ||
6716 | tmp = RREG32(CG_TACH_CTRL) & ~TARGET_PERIOD_MASK; | ||
6717 | tmp |= TARGET_PERIOD(tach_period); | ||
6718 | WREG32(CG_TACH_CTRL, tmp); | ||
6719 | |||
6720 | si_fan_ctrl_set_static_mode(adev, FDO_PWM_MODE_STATIC_RPM); | ||
6721 | |||
6722 | return 0; | ||
6723 | } | ||
6724 | #endif | ||
6725 | |||
6726 | static void si_fan_ctrl_set_default_mode(struct amdgpu_device *adev) | ||
6727 | { | ||
6728 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6729 | u32 tmp; | ||
6730 | |||
6731 | if (!si_pi->fan_ctrl_is_in_default_mode) { | ||
6732 | tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK; | ||
6733 | tmp |= FDO_PWM_MODE(si_pi->fan_ctrl_default_mode); | ||
6734 | WREG32(CG_FDO_CTRL2, tmp); | ||
6735 | |||
6736 | tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK; | ||
6737 | tmp |= TMIN(si_pi->t_min); | ||
6738 | WREG32(CG_FDO_CTRL2, tmp); | ||
6739 | si_pi->fan_ctrl_is_in_default_mode = true; | ||
6740 | } | ||
6741 | } | ||
6742 | |||
6743 | static void si_thermal_start_smc_fan_control(struct amdgpu_device *adev) | ||
6744 | { | ||
6745 | if (adev->pm.dpm.fan.ucode_fan_control) { | ||
6746 | si_fan_ctrl_start_smc_fan_control(adev); | ||
6747 | si_fan_ctrl_set_static_mode(adev, FDO_PWM_MODE_STATIC); | ||
6748 | } | ||
6749 | } | ||
6750 | |||
6751 | static void si_thermal_initialize(struct amdgpu_device *adev) | ||
6752 | { | ||
6753 | u32 tmp; | ||
6754 | |||
6755 | if (adev->pm.fan_pulses_per_revolution) { | ||
6756 | tmp = RREG32(CG_TACH_CTRL) & ~EDGE_PER_REV_MASK; | ||
6757 | tmp |= EDGE_PER_REV(adev->pm.fan_pulses_per_revolution -1); | ||
6758 | WREG32(CG_TACH_CTRL, tmp); | ||
6759 | } | ||
6760 | |||
6761 | tmp = RREG32(CG_FDO_CTRL2) & ~TACH_PWM_RESP_RATE_MASK; | ||
6762 | tmp |= TACH_PWM_RESP_RATE(0x28); | ||
6763 | WREG32(CG_FDO_CTRL2, tmp); | ||
6764 | } | ||
6765 | |||
6766 | static int si_thermal_start_thermal_controller(struct amdgpu_device *adev) | ||
6767 | { | ||
6768 | int ret; | ||
6769 | |||
6770 | si_thermal_initialize(adev); | ||
6771 | ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX); | ||
6772 | if (ret) | ||
6773 | return ret; | ||
6774 | ret = si_thermal_enable_alert(adev, true); | ||
6775 | if (ret) | ||
6776 | return ret; | ||
6777 | if (adev->pm.dpm.fan.ucode_fan_control) { | ||
6778 | ret = si_halt_smc(adev); | ||
6779 | if (ret) | ||
6780 | return ret; | ||
6781 | ret = si_thermal_setup_fan_table(adev); | ||
6782 | if (ret) | ||
6783 | return ret; | ||
6784 | ret = si_resume_smc(adev); | ||
6785 | if (ret) | ||
6786 | return ret; | ||
6787 | si_thermal_start_smc_fan_control(adev); | ||
6788 | } | ||
6789 | |||
6790 | return 0; | ||
6791 | } | ||
6792 | |||
6793 | static void si_thermal_stop_thermal_controller(struct amdgpu_device *adev) | ||
6794 | { | ||
6795 | if (!adev->pm.no_fan) { | ||
6796 | si_fan_ctrl_set_default_mode(adev); | ||
6797 | si_fan_ctrl_stop_smc_fan_control(adev); | ||
6798 | } | ||
6799 | } | ||
6800 | |||
6801 | static int si_dpm_enable(struct amdgpu_device *adev) | ||
6802 | { | ||
6803 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
6804 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
6805 | struct si_power_info *si_pi = si_get_pi(adev); | ||
6806 | struct amdgpu_ps *boot_ps = adev->pm.dpm.boot_ps; | ||
6807 | int ret; | ||
6808 | |||
6809 | if (amdgpu_si_is_smc_running(adev)) | ||
6810 | return -EINVAL; | ||
6811 | if (pi->voltage_control || si_pi->voltage_control_svi2) | ||
6812 | si_enable_voltage_control(adev, true); | ||
6813 | if (pi->mvdd_control) | ||
6814 | si_get_mvdd_configuration(adev); | ||
6815 | if (pi->voltage_control || si_pi->voltage_control_svi2) { | ||
6816 | ret = si_construct_voltage_tables(adev); | ||
6817 | if (ret) { | ||
6818 | DRM_ERROR("si_construct_voltage_tables failed\n"); | ||
6819 | return ret; | ||
6820 | } | ||
6821 | } | ||
6822 | if (eg_pi->dynamic_ac_timing) { | ||
6823 | ret = si_initialize_mc_reg_table(adev); | ||
6824 | if (ret) | ||
6825 | eg_pi->dynamic_ac_timing = false; | ||
6826 | } | ||
6827 | if (pi->dynamic_ss) | ||
6828 | si_enable_spread_spectrum(adev, true); | ||
6829 | if (pi->thermal_protection) | ||
6830 | si_enable_thermal_protection(adev, true); | ||
6831 | si_setup_bsp(adev); | ||
6832 | si_program_git(adev); | ||
6833 | si_program_tp(adev); | ||
6834 | si_program_tpp(adev); | ||
6835 | si_program_sstp(adev); | ||
6836 | si_enable_display_gap(adev); | ||
6837 | si_program_vc(adev); | ||
6838 | ret = si_upload_firmware(adev); | ||
6839 | if (ret) { | ||
6840 | DRM_ERROR("si_upload_firmware failed\n"); | ||
6841 | return ret; | ||
6842 | } | ||
6843 | ret = si_process_firmware_header(adev); | ||
6844 | if (ret) { | ||
6845 | DRM_ERROR("si_process_firmware_header failed\n"); | ||
6846 | return ret; | ||
6847 | } | ||
6848 | ret = si_initial_switch_from_arb_f0_to_f1(adev); | ||
6849 | if (ret) { | ||
6850 | DRM_ERROR("si_initial_switch_from_arb_f0_to_f1 failed\n"); | ||
6851 | return ret; | ||
6852 | } | ||
6853 | ret = si_init_smc_table(adev); | ||
6854 | if (ret) { | ||
6855 | DRM_ERROR("si_init_smc_table failed\n"); | ||
6856 | return ret; | ||
6857 | } | ||
6858 | ret = si_init_smc_spll_table(adev); | ||
6859 | if (ret) { | ||
6860 | DRM_ERROR("si_init_smc_spll_table failed\n"); | ||
6861 | return ret; | ||
6862 | } | ||
6863 | ret = si_init_arb_table_index(adev); | ||
6864 | if (ret) { | ||
6865 | DRM_ERROR("si_init_arb_table_index failed\n"); | ||
6866 | return ret; | ||
6867 | } | ||
6868 | if (eg_pi->dynamic_ac_timing) { | ||
6869 | ret = si_populate_mc_reg_table(adev, boot_ps); | ||
6870 | if (ret) { | ||
6871 | DRM_ERROR("si_populate_mc_reg_table failed\n"); | ||
6872 | return ret; | ||
6873 | } | ||
6874 | } | ||
6875 | ret = si_initialize_smc_cac_tables(adev); | ||
6876 | if (ret) { | ||
6877 | DRM_ERROR("si_initialize_smc_cac_tables failed\n"); | ||
6878 | return ret; | ||
6879 | } | ||
6880 | ret = si_initialize_hardware_cac_manager(adev); | ||
6881 | if (ret) { | ||
6882 | DRM_ERROR("si_initialize_hardware_cac_manager failed\n"); | ||
6883 | return ret; | ||
6884 | } | ||
6885 | ret = si_initialize_smc_dte_tables(adev); | ||
6886 | if (ret) { | ||
6887 | DRM_ERROR("si_initialize_smc_dte_tables failed\n"); | ||
6888 | return ret; | ||
6889 | } | ||
6890 | ret = si_populate_smc_tdp_limits(adev, boot_ps); | ||
6891 | if (ret) { | ||
6892 | DRM_ERROR("si_populate_smc_tdp_limits failed\n"); | ||
6893 | return ret; | ||
6894 | } | ||
6895 | ret = si_populate_smc_tdp_limits_2(adev, boot_ps); | ||
6896 | if (ret) { | ||
6897 | DRM_ERROR("si_populate_smc_tdp_limits_2 failed\n"); | ||
6898 | return ret; | ||
6899 | } | ||
6900 | si_program_response_times(adev); | ||
6901 | si_program_ds_registers(adev); | ||
6902 | si_dpm_start_smc(adev); | ||
6903 | ret = si_notify_smc_display_change(adev, false); | ||
6904 | if (ret) { | ||
6905 | DRM_ERROR("si_notify_smc_display_change failed\n"); | ||
6906 | return ret; | ||
6907 | } | ||
6908 | si_enable_sclk_control(adev, true); | ||
6909 | si_start_dpm(adev); | ||
6910 | |||
6911 | si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, true); | ||
6912 | si_thermal_start_thermal_controller(adev); | ||
6913 | ni_update_current_ps(adev, boot_ps); | ||
6914 | |||
6915 | return 0; | ||
6916 | } | ||
6917 | |||
6918 | static int si_set_temperature_range(struct amdgpu_device *adev) | ||
6919 | { | ||
6920 | int ret; | ||
6921 | |||
6922 | ret = si_thermal_enable_alert(adev, false); | ||
6923 | if (ret) | ||
6924 | return ret; | ||
6925 | ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX); | ||
6926 | if (ret) | ||
6927 | return ret; | ||
6928 | ret = si_thermal_enable_alert(adev, true); | ||
6929 | if (ret) | ||
6930 | return ret; | ||
6931 | |||
6932 | return ret; | ||
6933 | } | ||
6934 | |||
6935 | static void si_dpm_disable(struct amdgpu_device *adev) | ||
6936 | { | ||
6937 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
6938 | struct amdgpu_ps *boot_ps = adev->pm.dpm.boot_ps; | ||
6939 | |||
6940 | if (!amdgpu_si_is_smc_running(adev)) | ||
6941 | return; | ||
6942 | si_thermal_stop_thermal_controller(adev); | ||
6943 | si_disable_ulv(adev); | ||
6944 | si_clear_vc(adev); | ||
6945 | if (pi->thermal_protection) | ||
6946 | si_enable_thermal_protection(adev, false); | ||
6947 | si_enable_power_containment(adev, boot_ps, false); | ||
6948 | si_enable_smc_cac(adev, boot_ps, false); | ||
6949 | si_enable_spread_spectrum(adev, false); | ||
6950 | si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, false); | ||
6951 | si_stop_dpm(adev); | ||
6952 | si_reset_to_default(adev); | ||
6953 | si_dpm_stop_smc(adev); | ||
6954 | si_force_switch_to_arb_f0(adev); | ||
6955 | |||
6956 | ni_update_current_ps(adev, boot_ps); | ||
6957 | } | ||
6958 | |||
6959 | static int si_dpm_pre_set_power_state(struct amdgpu_device *adev) | ||
6960 | { | ||
6961 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
6962 | struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps; | ||
6963 | struct amdgpu_ps *new_ps = &requested_ps; | ||
6964 | |||
6965 | ni_update_requested_ps(adev, new_ps); | ||
6966 | si_apply_state_adjust_rules(adev, &eg_pi->requested_rps); | ||
6967 | |||
6968 | return 0; | ||
6969 | } | ||
6970 | |||
6971 | static int si_power_control_set_level(struct amdgpu_device *adev) | ||
6972 | { | ||
6973 | struct amdgpu_ps *new_ps = adev->pm.dpm.requested_ps; | ||
6974 | int ret; | ||
6975 | |||
6976 | ret = si_restrict_performance_levels_before_switch(adev); | ||
6977 | if (ret) | ||
6978 | return ret; | ||
6979 | ret = si_halt_smc(adev); | ||
6980 | if (ret) | ||
6981 | return ret; | ||
6982 | ret = si_populate_smc_tdp_limits(adev, new_ps); | ||
6983 | if (ret) | ||
6984 | return ret; | ||
6985 | ret = si_populate_smc_tdp_limits_2(adev, new_ps); | ||
6986 | if (ret) | ||
6987 | return ret; | ||
6988 | ret = si_resume_smc(adev); | ||
6989 | if (ret) | ||
6990 | return ret; | ||
6991 | ret = si_set_sw_state(adev); | ||
6992 | if (ret) | ||
6993 | return ret; | ||
6994 | return 0; | ||
6995 | } | ||
6996 | |||
6997 | static int si_dpm_set_power_state(struct amdgpu_device *adev) | ||
6998 | { | ||
6999 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
7000 | struct amdgpu_ps *new_ps = &eg_pi->requested_rps; | ||
7001 | struct amdgpu_ps *old_ps = &eg_pi->current_rps; | ||
7002 | int ret; | ||
7003 | |||
7004 | ret = si_disable_ulv(adev); | ||
7005 | if (ret) { | ||
7006 | DRM_ERROR("si_disable_ulv failed\n"); | ||
7007 | return ret; | ||
7008 | } | ||
7009 | ret = si_restrict_performance_levels_before_switch(adev); | ||
7010 | if (ret) { | ||
7011 | DRM_ERROR("si_restrict_performance_levels_before_switch failed\n"); | ||
7012 | return ret; | ||
7013 | } | ||
7014 | if (eg_pi->pcie_performance_request) | ||
7015 | si_request_link_speed_change_before_state_change(adev, new_ps, old_ps); | ||
7016 | ni_set_uvd_clock_before_set_eng_clock(adev, new_ps, old_ps); | ||
7017 | ret = si_enable_power_containment(adev, new_ps, false); | ||
7018 | if (ret) { | ||
7019 | DRM_ERROR("si_enable_power_containment failed\n"); | ||
7020 | return ret; | ||
7021 | } | ||
7022 | ret = si_enable_smc_cac(adev, new_ps, false); | ||
7023 | if (ret) { | ||
7024 | DRM_ERROR("si_enable_smc_cac failed\n"); | ||
7025 | return ret; | ||
7026 | } | ||
7027 | ret = si_halt_smc(adev); | ||
7028 | if (ret) { | ||
7029 | DRM_ERROR("si_halt_smc failed\n"); | ||
7030 | return ret; | ||
7031 | } | ||
7032 | ret = si_upload_sw_state(adev, new_ps); | ||
7033 | if (ret) { | ||
7034 | DRM_ERROR("si_upload_sw_state failed\n"); | ||
7035 | return ret; | ||
7036 | } | ||
7037 | ret = si_upload_smc_data(adev); | ||
7038 | if (ret) { | ||
7039 | DRM_ERROR("si_upload_smc_data failed\n"); | ||
7040 | return ret; | ||
7041 | } | ||
7042 | ret = si_upload_ulv_state(adev); | ||
7043 | if (ret) { | ||
7044 | DRM_ERROR("si_upload_ulv_state failed\n"); | ||
7045 | return ret; | ||
7046 | } | ||
7047 | if (eg_pi->dynamic_ac_timing) { | ||
7048 | ret = si_upload_mc_reg_table(adev, new_ps); | ||
7049 | if (ret) { | ||
7050 | DRM_ERROR("si_upload_mc_reg_table failed\n"); | ||
7051 | return ret; | ||
7052 | } | ||
7053 | } | ||
7054 | ret = si_program_memory_timing_parameters(adev, new_ps); | ||
7055 | if (ret) { | ||
7056 | DRM_ERROR("si_program_memory_timing_parameters failed\n"); | ||
7057 | return ret; | ||
7058 | } | ||
7059 | si_set_pcie_lane_width_in_smc(adev, new_ps, old_ps); | ||
7060 | |||
7061 | ret = si_resume_smc(adev); | ||
7062 | if (ret) { | ||
7063 | DRM_ERROR("si_resume_smc failed\n"); | ||
7064 | return ret; | ||
7065 | } | ||
7066 | ret = si_set_sw_state(adev); | ||
7067 | if (ret) { | ||
7068 | DRM_ERROR("si_set_sw_state failed\n"); | ||
7069 | return ret; | ||
7070 | } | ||
7071 | ni_set_uvd_clock_after_set_eng_clock(adev, new_ps, old_ps); | ||
7072 | if (eg_pi->pcie_performance_request) | ||
7073 | si_notify_link_speed_change_after_state_change(adev, new_ps, old_ps); | ||
7074 | ret = si_set_power_state_conditionally_enable_ulv(adev, new_ps); | ||
7075 | if (ret) { | ||
7076 | DRM_ERROR("si_set_power_state_conditionally_enable_ulv failed\n"); | ||
7077 | return ret; | ||
7078 | } | ||
7079 | ret = si_enable_smc_cac(adev, new_ps, true); | ||
7080 | if (ret) { | ||
7081 | DRM_ERROR("si_enable_smc_cac failed\n"); | ||
7082 | return ret; | ||
7083 | } | ||
7084 | ret = si_enable_power_containment(adev, new_ps, true); | ||
7085 | if (ret) { | ||
7086 | DRM_ERROR("si_enable_power_containment failed\n"); | ||
7087 | return ret; | ||
7088 | } | ||
7089 | |||
7090 | ret = si_power_control_set_level(adev); | ||
7091 | if (ret) { | ||
7092 | DRM_ERROR("si_power_control_set_level failed\n"); | ||
7093 | return ret; | ||
7094 | } | ||
7095 | |||
7096 | return 0; | ||
7097 | } | ||
7098 | |||
7099 | static void si_dpm_post_set_power_state(struct amdgpu_device *adev) | ||
7100 | { | ||
7101 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
7102 | struct amdgpu_ps *new_ps = &eg_pi->requested_rps; | ||
7103 | |||
7104 | ni_update_current_ps(adev, new_ps); | ||
7105 | } | ||
7106 | |||
7107 | #if 0 | ||
7108 | void si_dpm_reset_asic(struct amdgpu_device *adev) | ||
7109 | { | ||
7110 | si_restrict_performance_levels_before_switch(adev); | ||
7111 | si_disable_ulv(adev); | ||
7112 | si_set_boot_state(adev); | ||
7113 | } | ||
7114 | #endif | ||
7115 | |||
7116 | static void si_dpm_display_configuration_changed(struct amdgpu_device *adev) | ||
7117 | { | ||
7118 | si_program_display_gap(adev); | ||
7119 | } | ||
7120 | |||
7121 | |||
7122 | static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev, | ||
7123 | struct amdgpu_ps *rps, | ||
7124 | struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info, | ||
7125 | u8 table_rev) | ||
7126 | { | ||
7127 | rps->caps = le32_to_cpu(non_clock_info->ulCapsAndSettings); | ||
7128 | rps->class = le16_to_cpu(non_clock_info->usClassification); | ||
7129 | rps->class2 = le16_to_cpu(non_clock_info->usClassification2); | ||
7130 | |||
7131 | if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { | ||
7132 | rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); | ||
7133 | rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); | ||
7134 | } else if (r600_is_uvd_state(rps->class, rps->class2)) { | ||
7135 | rps->vclk = RV770_DEFAULT_VCLK_FREQ; | ||
7136 | rps->dclk = RV770_DEFAULT_DCLK_FREQ; | ||
7137 | } else { | ||
7138 | rps->vclk = 0; | ||
7139 | rps->dclk = 0; | ||
7140 | } | ||
7141 | |||
7142 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) | ||
7143 | adev->pm.dpm.boot_ps = rps; | ||
7144 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) | ||
7145 | adev->pm.dpm.uvd_ps = rps; | ||
7146 | } | ||
7147 | |||
7148 | static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | ||
7149 | struct amdgpu_ps *rps, int index, | ||
7150 | union pplib_clock_info *clock_info) | ||
7151 | { | ||
7152 | struct rv7xx_power_info *pi = rv770_get_pi(adev); | ||
7153 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
7154 | struct si_power_info *si_pi = si_get_pi(adev); | ||
7155 | struct si_ps *ps = si_get_ps(rps); | ||
7156 | u16 leakage_voltage; | ||
7157 | struct rv7xx_pl *pl = &ps->performance_levels[index]; | ||
7158 | int ret; | ||
7159 | |||
7160 | ps->performance_level_count = index + 1; | ||
7161 | |||
7162 | pl->sclk = le16_to_cpu(clock_info->si.usEngineClockLow); | ||
7163 | pl->sclk |= clock_info->si.ucEngineClockHigh << 16; | ||
7164 | pl->mclk = le16_to_cpu(clock_info->si.usMemoryClockLow); | ||
7165 | pl->mclk |= clock_info->si.ucMemoryClockHigh << 16; | ||
7166 | |||
7167 | pl->vddc = le16_to_cpu(clock_info->si.usVDDC); | ||
7168 | pl->vddci = le16_to_cpu(clock_info->si.usVDDCI); | ||
7169 | pl->flags = le32_to_cpu(clock_info->si.ulFlags); | ||
7170 | pl->pcie_gen = r600_get_pcie_gen_support(adev, | ||
7171 | si_pi->sys_pcie_mask, | ||
7172 | si_pi->boot_pcie_gen, | ||
7173 | clock_info->si.ucPCIEGen); | ||
7174 | |||
7175 | /* patch up vddc if necessary */ | ||
7176 | ret = si_get_leakage_voltage_from_leakage_index(adev, pl->vddc, | ||
7177 | &leakage_voltage); | ||
7178 | if (ret == 0) | ||
7179 | pl->vddc = leakage_voltage; | ||
7180 | |||
7181 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_ACPI) { | ||
7182 | pi->acpi_vddc = pl->vddc; | ||
7183 | eg_pi->acpi_vddci = pl->vddci; | ||
7184 | si_pi->acpi_pcie_gen = pl->pcie_gen; | ||
7185 | } | ||
7186 | |||
7187 | if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) && | ||
7188 | index == 0) { | ||
7189 | /* XXX disable for A0 tahiti */ | ||
7190 | si_pi->ulv.supported = false; | ||
7191 | si_pi->ulv.pl = *pl; | ||
7192 | si_pi->ulv.one_pcie_lane_in_ulv = false; | ||
7193 | si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT; | ||
7194 | si_pi->ulv.cg_ulv_parameter = SISLANDS_CGULVPARAMETER_DFLT; | ||
7195 | si_pi->ulv.cg_ulv_control = SISLANDS_CGULVCONTROL_DFLT; | ||
7196 | } | ||
7197 | |||
7198 | if (pi->min_vddc_in_table > pl->vddc) | ||
7199 | pi->min_vddc_in_table = pl->vddc; | ||
7200 | |||
7201 | if (pi->max_vddc_in_table < pl->vddc) | ||
7202 | pi->max_vddc_in_table = pl->vddc; | ||
7203 | |||
7204 | /* patch up boot state */ | ||
7205 | if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) { | ||
7206 | u16 vddc, vddci, mvdd; | ||
7207 | amdgpu_atombios_get_default_voltages(adev, &vddc, &vddci, &mvdd); | ||
7208 | pl->mclk = adev->clock.default_mclk; | ||
7209 | pl->sclk = adev->clock.default_sclk; | ||
7210 | pl->vddc = vddc; | ||
7211 | pl->vddci = vddci; | ||
7212 | si_pi->mvdd_bootup_value = mvdd; | ||
7213 | } | ||
7214 | |||
7215 | if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | ||
7216 | ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) { | ||
7217 | adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk = pl->sclk; | ||
7218 | adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.mclk = pl->mclk; | ||
7219 | adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddc = pl->vddc; | ||
7220 | adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddci = pl->vddci; | ||
7221 | } | ||
7222 | } | ||
7223 | |||
7224 | union pplib_power_state { | ||
7225 | struct _ATOM_PPLIB_STATE v1; | ||
7226 | struct _ATOM_PPLIB_STATE_V2 v2; | ||
7227 | }; | ||
7228 | |||
7229 | static int si_parse_power_table(struct amdgpu_device *adev) | ||
7230 | { | ||
7231 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | ||
7232 | struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info; | ||
7233 | union pplib_power_state *power_state; | ||
7234 | int i, j, k, non_clock_array_index, clock_array_index; | ||
7235 | union pplib_clock_info *clock_info; | ||
7236 | struct _StateArray *state_array; | ||
7237 | struct _ClockInfoArray *clock_info_array; | ||
7238 | struct _NonClockInfoArray *non_clock_info_array; | ||
7239 | union power_info *power_info; | ||
7240 | int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); | ||
7241 | u16 data_offset; | ||
7242 | u8 frev, crev; | ||
7243 | u8 *power_state_offset; | ||
7244 | struct si_ps *ps; | ||
7245 | |||
7246 | if (!amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
7247 | &frev, &crev, &data_offset)) | ||
7248 | return -EINVAL; | ||
7249 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); | ||
7250 | |||
7251 | amdgpu_add_thermal_controller(adev); | ||
7252 | |||
7253 | state_array = (struct _StateArray *) | ||
7254 | (mode_info->atom_context->bios + data_offset + | ||
7255 | le16_to_cpu(power_info->pplib.usStateArrayOffset)); | ||
7256 | clock_info_array = (struct _ClockInfoArray *) | ||
7257 | (mode_info->atom_context->bios + data_offset + | ||
7258 | le16_to_cpu(power_info->pplib.usClockInfoArrayOffset)); | ||
7259 | non_clock_info_array = (struct _NonClockInfoArray *) | ||
7260 | (mode_info->atom_context->bios + data_offset + | ||
7261 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | ||
7262 | |||
7263 | adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) * | ||
7264 | state_array->ucNumEntries, GFP_KERNEL); | ||
7265 | if (!adev->pm.dpm.ps) | ||
7266 | return -ENOMEM; | ||
7267 | power_state_offset = (u8 *)state_array->states; | ||
7268 | for (i = 0; i < state_array->ucNumEntries; i++) { | ||
7269 | u8 *idx; | ||
7270 | power_state = (union pplib_power_state *)power_state_offset; | ||
7271 | non_clock_array_index = power_state->v2.nonClockInfoIndex; | ||
7272 | non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) | ||
7273 | &non_clock_info_array->nonClockInfo[non_clock_array_index]; | ||
7274 | ps = kzalloc(sizeof(struct si_ps), GFP_KERNEL); | ||
7275 | if (ps == NULL) { | ||
7276 | kfree(adev->pm.dpm.ps); | ||
7277 | return -ENOMEM; | ||
7278 | } | ||
7279 | adev->pm.dpm.ps[i].ps_priv = ps; | ||
7280 | si_parse_pplib_non_clock_info(adev, &adev->pm.dpm.ps[i], | ||
7281 | non_clock_info, | ||
7282 | non_clock_info_array->ucEntrySize); | ||
7283 | k = 0; | ||
7284 | idx = (u8 *)&power_state->v2.clockInfoIndex[0]; | ||
7285 | for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) { | ||
7286 | clock_array_index = idx[j]; | ||
7287 | if (clock_array_index >= clock_info_array->ucNumEntries) | ||
7288 | continue; | ||
7289 | if (k >= SISLANDS_MAX_HARDWARE_POWERLEVELS) | ||
7290 | break; | ||
7291 | clock_info = (union pplib_clock_info *) | ||
7292 | ((u8 *)&clock_info_array->clockInfo[0] + | ||
7293 | (clock_array_index * clock_info_array->ucEntrySize)); | ||
7294 | si_parse_pplib_clock_info(adev, | ||
7295 | &adev->pm.dpm.ps[i], k, | ||
7296 | clock_info); | ||
7297 | k++; | ||
7298 | } | ||
7299 | power_state_offset += 2 + power_state->v2.ucNumDPMLevels; | ||
7300 | } | ||
7301 | adev->pm.dpm.num_ps = state_array->ucNumEntries; | ||
7302 | |||
7303 | /* fill in the vce power states */ | ||
7304 | for (i = 0; i < AMDGPU_MAX_VCE_LEVELS; i++) { | ||
7305 | u32 sclk, mclk; | ||
7306 | clock_array_index = adev->pm.dpm.vce_states[i].clk_idx; | ||
7307 | clock_info = (union pplib_clock_info *) | ||
7308 | &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize]; | ||
7309 | sclk = le16_to_cpu(clock_info->si.usEngineClockLow); | ||
7310 | sclk |= clock_info->si.ucEngineClockHigh << 16; | ||
7311 | mclk = le16_to_cpu(clock_info->si.usMemoryClockLow); | ||
7312 | mclk |= clock_info->si.ucMemoryClockHigh << 16; | ||
7313 | adev->pm.dpm.vce_states[i].sclk = sclk; | ||
7314 | adev->pm.dpm.vce_states[i].mclk = mclk; | ||
7315 | } | ||
7316 | |||
7317 | return 0; | ||
7318 | } | ||
7319 | |||
7320 | static int si_dpm_init(struct amdgpu_device *adev) | ||
7321 | { | ||
7322 | struct rv7xx_power_info *pi; | ||
7323 | struct evergreen_power_info *eg_pi; | ||
7324 | struct ni_power_info *ni_pi; | ||
7325 | struct si_power_info *si_pi; | ||
7326 | struct atom_clock_dividers dividers; | ||
7327 | int ret; | ||
7328 | u32 mask; | ||
7329 | |||
7330 | si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL); | ||
7331 | if (si_pi == NULL) | ||
7332 | return -ENOMEM; | ||
7333 | adev->pm.dpm.priv = si_pi; | ||
7334 | ni_pi = &si_pi->ni; | ||
7335 | eg_pi = &ni_pi->eg; | ||
7336 | pi = &eg_pi->rv7xx; | ||
7337 | |||
7338 | ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); | ||
7339 | if (ret) | ||
7340 | si_pi->sys_pcie_mask = 0; | ||
7341 | else | ||
7342 | si_pi->sys_pcie_mask = mask; | ||
7343 | si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID; | ||
7344 | si_pi->boot_pcie_gen = si_get_current_pcie_speed(adev); | ||
7345 | |||
7346 | si_set_max_cu_value(adev); | ||
7347 | |||
7348 | rv770_get_max_vddc(adev); | ||
7349 | si_get_leakage_vddc(adev); | ||
7350 | si_patch_dependency_tables_based_on_leakage(adev); | ||
7351 | |||
7352 | pi->acpi_vddc = 0; | ||
7353 | eg_pi->acpi_vddci = 0; | ||
7354 | pi->min_vddc_in_table = 0; | ||
7355 | pi->max_vddc_in_table = 0; | ||
7356 | |||
7357 | ret = amdgpu_get_platform_caps(adev); | ||
7358 | if (ret) | ||
7359 | return ret; | ||
7360 | |||
7361 | ret = amdgpu_parse_extended_power_table(adev); | ||
7362 | if (ret) | ||
7363 | return ret; | ||
7364 | |||
7365 | ret = si_parse_power_table(adev); | ||
7366 | if (ret) | ||
7367 | return ret; | ||
7368 | |||
7369 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | ||
7370 | kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL); | ||
7371 | if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | ||
7372 | amdgpu_free_extended_power_table(adev); | ||
7373 | return -ENOMEM; | ||
7374 | } | ||
7375 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4; | ||
7376 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0; | ||
7377 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0; | ||
7378 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000; | ||
7379 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 720; | ||
7380 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000; | ||
7381 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 810; | ||
7382 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000; | ||
7383 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 900; | ||
7384 | |||
7385 | if (adev->pm.dpm.voltage_response_time == 0) | ||
7386 | adev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT; | ||
7387 | if (adev->pm.dpm.backbias_response_time == 0) | ||
7388 | adev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT; | ||
7389 | |||
7390 | ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_ENGINE_PLL_PARAM, | ||
7391 | 0, false, ÷rs); | ||
7392 | if (ret) | ||
7393 | pi->ref_div = dividers.ref_div + 1; | ||
7394 | else | ||
7395 | pi->ref_div = R600_REFERENCEDIVIDER_DFLT; | ||
7396 | |||
7397 | eg_pi->smu_uvd_hs = false; | ||
7398 | |||
7399 | pi->mclk_strobe_mode_threshold = 40000; | ||
7400 | if (si_is_special_1gb_platform(adev)) | ||
7401 | pi->mclk_stutter_mode_threshold = 0; | ||
7402 | else | ||
7403 | pi->mclk_stutter_mode_threshold = pi->mclk_strobe_mode_threshold; | ||
7404 | pi->mclk_edc_enable_threshold = 40000; | ||
7405 | eg_pi->mclk_edc_wr_enable_threshold = 40000; | ||
7406 | |||
7407 | ni_pi->mclk_rtt_mode_threshold = eg_pi->mclk_edc_wr_enable_threshold; | ||
7408 | |||
7409 | pi->voltage_control = | ||
7410 | amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC, | ||
7411 | VOLTAGE_OBJ_GPIO_LUT); | ||
7412 | if (!pi->voltage_control) { | ||
7413 | si_pi->voltage_control_svi2 = | ||
7414 | amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC, | ||
7415 | VOLTAGE_OBJ_SVID2); | ||
7416 | if (si_pi->voltage_control_svi2) | ||
7417 | amdgpu_atombios_get_svi2_info(adev, SET_VOLTAGE_TYPE_ASIC_VDDC, | ||
7418 | &si_pi->svd_gpio_id, &si_pi->svc_gpio_id); | ||
7419 | } | ||
7420 | |||
7421 | pi->mvdd_control = | ||
7422 | amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_MVDDC, | ||
7423 | VOLTAGE_OBJ_GPIO_LUT); | ||
7424 | |||
7425 | eg_pi->vddci_control = | ||
7426 | amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDCI, | ||
7427 | VOLTAGE_OBJ_GPIO_LUT); | ||
7428 | if (!eg_pi->vddci_control) | ||
7429 | si_pi->vddci_control_svi2 = | ||
7430 | amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDCI, | ||
7431 | VOLTAGE_OBJ_SVID2); | ||
7432 | |||
7433 | si_pi->vddc_phase_shed_control = | ||
7434 | amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC, | ||
7435 | VOLTAGE_OBJ_PHASE_LUT); | ||
7436 | |||
7437 | rv770_get_engine_memory_ss(adev); | ||
7438 | |||
7439 | pi->asi = RV770_ASI_DFLT; | ||
7440 | pi->pasi = CYPRESS_HASI_DFLT; | ||
7441 | pi->vrc = SISLANDS_VRC_DFLT; | ||
7442 | |||
7443 | pi->gfx_clock_gating = true; | ||
7444 | |||
7445 | eg_pi->sclk_deep_sleep = true; | ||
7446 | si_pi->sclk_deep_sleep_above_low = false; | ||
7447 | |||
7448 | if (adev->pm.int_thermal_type != THERMAL_TYPE_NONE) | ||
7449 | pi->thermal_protection = true; | ||
7450 | else | ||
7451 | pi->thermal_protection = false; | ||
7452 | |||
7453 | eg_pi->dynamic_ac_timing = true; | ||
7454 | |||
7455 | eg_pi->light_sleep = true; | ||
7456 | #if defined(CONFIG_ACPI) | ||
7457 | eg_pi->pcie_performance_request = | ||
7458 | amdgpu_acpi_is_pcie_performance_request_supported(adev); | ||
7459 | #else | ||
7460 | eg_pi->pcie_performance_request = false; | ||
7461 | #endif | ||
7462 | |||
7463 | si_pi->sram_end = SMC_RAM_END; | ||
7464 | |||
7465 | adev->pm.dpm.dyn_state.mclk_sclk_ratio = 4; | ||
7466 | adev->pm.dpm.dyn_state.sclk_mclk_delta = 15000; | ||
7467 | adev->pm.dpm.dyn_state.vddc_vddci_delta = 200; | ||
7468 | adev->pm.dpm.dyn_state.valid_sclk_values.count = 0; | ||
7469 | adev->pm.dpm.dyn_state.valid_sclk_values.values = NULL; | ||
7470 | adev->pm.dpm.dyn_state.valid_mclk_values.count = 0; | ||
7471 | adev->pm.dpm.dyn_state.valid_mclk_values.values = NULL; | ||
7472 | |||
7473 | si_initialize_powertune_defaults(adev); | ||
7474 | |||
7475 | /* make sure dc limits are valid */ | ||
7476 | if ((adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) || | ||
7477 | (adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0)) | ||
7478 | adev->pm.dpm.dyn_state.max_clock_voltage_on_dc = | ||
7479 | adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | ||
7480 | |||
7481 | si_pi->fan_ctrl_is_in_default_mode = true; | ||
7482 | |||
7483 | return 0; | ||
7484 | } | ||
7485 | |||
7486 | static void si_dpm_fini(struct amdgpu_device *adev) | ||
7487 | { | ||
7488 | int i; | ||
7489 | |||
7490 | if (adev->pm.dpm.ps) | ||
7491 | for (i = 0; i < adev->pm.dpm.num_ps; i++) | ||
7492 | kfree(adev->pm.dpm.ps[i].ps_priv); | ||
7493 | kfree(adev->pm.dpm.ps); | ||
7494 | kfree(adev->pm.dpm.priv); | ||
7495 | kfree(adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries); | ||
7496 | amdgpu_free_extended_power_table(adev); | ||
7497 | } | ||
7498 | |||
7499 | static void si_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev, | ||
7500 | struct seq_file *m) | ||
7501 | { | ||
7502 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
7503 | struct amdgpu_ps *rps = &eg_pi->current_rps; | ||
7504 | struct si_ps *ps = si_get_ps(rps); | ||
7505 | struct rv7xx_pl *pl; | ||
7506 | u32 current_index = | ||
7507 | (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >> | ||
7508 | CURRENT_STATE_INDEX_SHIFT; | ||
7509 | |||
7510 | if (current_index >= ps->performance_level_count) { | ||
7511 | seq_printf(m, "invalid dpm profile %d\n", current_index); | ||
7512 | } else { | ||
7513 | pl = &ps->performance_levels[current_index]; | ||
7514 | seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk); | ||
7515 | seq_printf(m, "power level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n", | ||
7516 | current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1); | ||
7517 | } | ||
7518 | } | ||
7519 | |||
7520 | static int si_dpm_set_interrupt_state(struct amdgpu_device *adev, | ||
7521 | struct amdgpu_irq_src *source, | ||
7522 | unsigned type, | ||
7523 | enum amdgpu_interrupt_state state) | ||
7524 | { | ||
7525 | u32 cg_thermal_int; | ||
7526 | |||
7527 | switch (type) { | ||
7528 | case AMDGPU_THERMAL_IRQ_LOW_TO_HIGH: | ||
7529 | switch (state) { | ||
7530 | case AMDGPU_IRQ_STATE_DISABLE: | ||
7531 | cg_thermal_int = RREG32_SMC(CG_THERMAL_INT); | ||
7532 | cg_thermal_int |= THERM_INT_MASK_HIGH; | ||
7533 | WREG32_SMC(CG_THERMAL_INT, cg_thermal_int); | ||
7534 | break; | ||
7535 | case AMDGPU_IRQ_STATE_ENABLE: | ||
7536 | cg_thermal_int = RREG32_SMC(CG_THERMAL_INT); | ||
7537 | cg_thermal_int &= ~THERM_INT_MASK_HIGH; | ||
7538 | WREG32_SMC(CG_THERMAL_INT, cg_thermal_int); | ||
7539 | break; | ||
7540 | default: | ||
7541 | break; | ||
7542 | } | ||
7543 | break; | ||
7544 | |||
7545 | case AMDGPU_THERMAL_IRQ_HIGH_TO_LOW: | ||
7546 | switch (state) { | ||
7547 | case AMDGPU_IRQ_STATE_DISABLE: | ||
7548 | cg_thermal_int = RREG32_SMC(CG_THERMAL_INT); | ||
7549 | cg_thermal_int |= THERM_INT_MASK_LOW; | ||
7550 | WREG32_SMC(CG_THERMAL_INT, cg_thermal_int); | ||
7551 | break; | ||
7552 | case AMDGPU_IRQ_STATE_ENABLE: | ||
7553 | cg_thermal_int = RREG32_SMC(CG_THERMAL_INT); | ||
7554 | cg_thermal_int &= ~THERM_INT_MASK_LOW; | ||
7555 | WREG32_SMC(CG_THERMAL_INT, cg_thermal_int); | ||
7556 | break; | ||
7557 | default: | ||
7558 | break; | ||
7559 | } | ||
7560 | break; | ||
7561 | |||
7562 | default: | ||
7563 | break; | ||
7564 | } | ||
7565 | return 0; | ||
7566 | } | ||
7567 | |||
7568 | static int si_dpm_process_interrupt(struct amdgpu_device *adev, | ||
7569 | struct amdgpu_irq_src *source, | ||
7570 | struct amdgpu_iv_entry *entry) | ||
7571 | { | ||
7572 | bool queue_thermal = false; | ||
7573 | |||
7574 | if (entry == NULL) | ||
7575 | return -EINVAL; | ||
7576 | |||
7577 | switch (entry->src_id) { | ||
7578 | case 230: /* thermal low to high */ | ||
7579 | DRM_DEBUG("IH: thermal low to high\n"); | ||
7580 | adev->pm.dpm.thermal.high_to_low = false; | ||
7581 | queue_thermal = true; | ||
7582 | break; | ||
7583 | case 231: /* thermal high to low */ | ||
7584 | DRM_DEBUG("IH: thermal high to low\n"); | ||
7585 | adev->pm.dpm.thermal.high_to_low = true; | ||
7586 | queue_thermal = true; | ||
7587 | break; | ||
7588 | default: | ||
7589 | break; | ||
7590 | } | ||
7591 | |||
7592 | if (queue_thermal) | ||
7593 | schedule_work(&adev->pm.dpm.thermal.work); | ||
7594 | |||
7595 | return 0; | ||
7596 | } | ||
7597 | |||
7598 | static int si_dpm_late_init(void *handle) | ||
7599 | { | ||
7600 | int ret; | ||
7601 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7602 | |||
7603 | if (!amdgpu_dpm) | ||
7604 | return 0; | ||
7605 | |||
7606 | /* init the sysfs and debugfs files late */ | ||
7607 | ret = amdgpu_pm_sysfs_init(adev); | ||
7608 | if (ret) | ||
7609 | return ret; | ||
7610 | |||
7611 | ret = si_set_temperature_range(adev); | ||
7612 | if (ret) | ||
7613 | return ret; | ||
7614 | #if 0 //TODO ? | ||
7615 | si_dpm_powergate_uvd(adev, true); | ||
7616 | #endif | ||
7617 | return 0; | ||
7618 | } | ||
7619 | |||
7620 | /** | ||
7621 | * si_dpm_init_microcode - load ucode images from disk | ||
7622 | * | ||
7623 | * @adev: amdgpu_device pointer | ||
7624 | * | ||
7625 | * Use the firmware interface to load the ucode images into | ||
7626 | * the driver (not loaded into hw). | ||
7627 | * Returns 0 on success, error on failure. | ||
7628 | */ | ||
7629 | static int si_dpm_init_microcode(struct amdgpu_device *adev) | ||
7630 | { | ||
7631 | const char *chip_name; | ||
7632 | char fw_name[30]; | ||
7633 | int err; | ||
7634 | |||
7635 | DRM_DEBUG("\n"); | ||
7636 | switch (adev->asic_type) { | ||
7637 | case CHIP_TAHITI: | ||
7638 | chip_name = "tahiti"; | ||
7639 | break; | ||
7640 | case CHIP_PITCAIRN: | ||
7641 | if ((adev->pdev->revision == 0x81) || | ||
7642 | (adev->pdev->device == 0x6810) || | ||
7643 | (adev->pdev->device == 0x6811) || | ||
7644 | (adev->pdev->device == 0x6816) || | ||
7645 | (adev->pdev->device == 0x6817) || | ||
7646 | (adev->pdev->device == 0x6806)) | ||
7647 | chip_name = "pitcairn_k"; | ||
7648 | else | ||
7649 | chip_name = "pitcairn"; | ||
7650 | break; | ||
7651 | case CHIP_VERDE: | ||
7652 | if ((adev->pdev->revision == 0x81) || | ||
7653 | (adev->pdev->revision == 0x83) || | ||
7654 | (adev->pdev->revision == 0x87) || | ||
7655 | (adev->pdev->device == 0x6820) || | ||
7656 | (adev->pdev->device == 0x6821) || | ||
7657 | (adev->pdev->device == 0x6822) || | ||
7658 | (adev->pdev->device == 0x6823) || | ||
7659 | (adev->pdev->device == 0x682A) || | ||
7660 | (adev->pdev->device == 0x682B)) | ||
7661 | chip_name = "verde_k"; | ||
7662 | else | ||
7663 | chip_name = "verde"; | ||
7664 | break; | ||
7665 | case CHIP_OLAND: | ||
7666 | if ((adev->pdev->revision == 0xC7) || | ||
7667 | (adev->pdev->revision == 0x80) || | ||
7668 | (adev->pdev->revision == 0x81) || | ||
7669 | (adev->pdev->revision == 0x83) || | ||
7670 | (adev->pdev->device == 0x6604) || | ||
7671 | (adev->pdev->device == 0x6605)) | ||
7672 | chip_name = "oland_k"; | ||
7673 | else | ||
7674 | chip_name = "oland"; | ||
7675 | break; | ||
7676 | case CHIP_HAINAN: | ||
7677 | if ((adev->pdev->revision == 0x81) || | ||
7678 | (adev->pdev->revision == 0x83) || | ||
7679 | (adev->pdev->revision == 0xC3) || | ||
7680 | (adev->pdev->device == 0x6664) || | ||
7681 | (adev->pdev->device == 0x6665) || | ||
7682 | (adev->pdev->device == 0x6667)) | ||
7683 | chip_name = "hainan_k"; | ||
7684 | else | ||
7685 | chip_name = "hainan"; | ||
7686 | break; | ||
7687 | default: BUG(); | ||
7688 | } | ||
7689 | |||
7690 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); | ||
7691 | err = request_firmware(&adev->pm.fw, fw_name, adev->dev); | ||
7692 | if (err) | ||
7693 | goto out; | ||
7694 | err = amdgpu_ucode_validate(adev->pm.fw); | ||
7695 | |||
7696 | out: | ||
7697 | if (err) { | ||
7698 | DRM_ERROR("si_smc: Failed to load firmware. err = %d\"%s\"\n", | ||
7699 | err, fw_name); | ||
7700 | release_firmware(adev->pm.fw); | ||
7701 | adev->pm.fw = NULL; | ||
7702 | } | ||
7703 | return err; | ||
7704 | |||
7705 | } | ||
7706 | |||
7707 | static int si_dpm_sw_init(void *handle) | ||
7708 | { | ||
7709 | int ret; | ||
7710 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7711 | |||
7712 | ret = amdgpu_irq_add_id(adev, 230, &adev->pm.dpm.thermal.irq); | ||
7713 | if (ret) | ||
7714 | return ret; | ||
7715 | |||
7716 | ret = amdgpu_irq_add_id(adev, 231, &adev->pm.dpm.thermal.irq); | ||
7717 | if (ret) | ||
7718 | return ret; | ||
7719 | |||
7720 | /* default to balanced state */ | ||
7721 | adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; | ||
7722 | adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; | ||
7723 | adev->pm.dpm.forced_level = AMDGPU_DPM_FORCED_LEVEL_AUTO; | ||
7724 | adev->pm.default_sclk = adev->clock.default_sclk; | ||
7725 | adev->pm.default_mclk = adev->clock.default_mclk; | ||
7726 | adev->pm.current_sclk = adev->clock.default_sclk; | ||
7727 | adev->pm.current_mclk = adev->clock.default_mclk; | ||
7728 | adev->pm.int_thermal_type = THERMAL_TYPE_NONE; | ||
7729 | |||
7730 | if (amdgpu_dpm == 0) | ||
7731 | return 0; | ||
7732 | |||
7733 | ret = si_dpm_init_microcode(adev); | ||
7734 | if (ret) | ||
7735 | return ret; | ||
7736 | |||
7737 | INIT_WORK(&adev->pm.dpm.thermal.work, amdgpu_dpm_thermal_work_handler); | ||
7738 | mutex_lock(&adev->pm.mutex); | ||
7739 | ret = si_dpm_init(adev); | ||
7740 | if (ret) | ||
7741 | goto dpm_failed; | ||
7742 | adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps; | ||
7743 | if (amdgpu_dpm == 1) | ||
7744 | amdgpu_pm_print_power_states(adev); | ||
7745 | mutex_unlock(&adev->pm.mutex); | ||
7746 | DRM_INFO("amdgpu: dpm initialized\n"); | ||
7747 | |||
7748 | return 0; | ||
7749 | |||
7750 | dpm_failed: | ||
7751 | si_dpm_fini(adev); | ||
7752 | mutex_unlock(&adev->pm.mutex); | ||
7753 | DRM_ERROR("amdgpu: dpm initialization failed\n"); | ||
7754 | return ret; | ||
7755 | } | ||
7756 | |||
7757 | static int si_dpm_sw_fini(void *handle) | ||
7758 | { | ||
7759 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7760 | |||
7761 | mutex_lock(&adev->pm.mutex); | ||
7762 | amdgpu_pm_sysfs_fini(adev); | ||
7763 | si_dpm_fini(adev); | ||
7764 | mutex_unlock(&adev->pm.mutex); | ||
7765 | |||
7766 | return 0; | ||
7767 | } | ||
7768 | |||
7769 | static int si_dpm_hw_init(void *handle) | ||
7770 | { | ||
7771 | int ret; | ||
7772 | |||
7773 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7774 | |||
7775 | if (!amdgpu_dpm) | ||
7776 | return 0; | ||
7777 | |||
7778 | mutex_lock(&adev->pm.mutex); | ||
7779 | si_dpm_setup_asic(adev); | ||
7780 | ret = si_dpm_enable(adev); | ||
7781 | if (ret) | ||
7782 | adev->pm.dpm_enabled = false; | ||
7783 | else | ||
7784 | adev->pm.dpm_enabled = true; | ||
7785 | mutex_unlock(&adev->pm.mutex); | ||
7786 | |||
7787 | return ret; | ||
7788 | } | ||
7789 | |||
7790 | static int si_dpm_hw_fini(void *handle) | ||
7791 | { | ||
7792 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7793 | |||
7794 | if (adev->pm.dpm_enabled) { | ||
7795 | mutex_lock(&adev->pm.mutex); | ||
7796 | si_dpm_disable(adev); | ||
7797 | mutex_unlock(&adev->pm.mutex); | ||
7798 | } | ||
7799 | |||
7800 | return 0; | ||
7801 | } | ||
7802 | |||
7803 | static int si_dpm_suspend(void *handle) | ||
7804 | { | ||
7805 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7806 | |||
7807 | if (adev->pm.dpm_enabled) { | ||
7808 | mutex_lock(&adev->pm.mutex); | ||
7809 | /* disable dpm */ | ||
7810 | si_dpm_disable(adev); | ||
7811 | /* reset the power state */ | ||
7812 | adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps; | ||
7813 | mutex_unlock(&adev->pm.mutex); | ||
7814 | } | ||
7815 | return 0; | ||
7816 | } | ||
7817 | |||
7818 | static int si_dpm_resume(void *handle) | ||
7819 | { | ||
7820 | int ret; | ||
7821 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7822 | |||
7823 | if (adev->pm.dpm_enabled) { | ||
7824 | /* asic init will reset to the boot state */ | ||
7825 | mutex_lock(&adev->pm.mutex); | ||
7826 | si_dpm_setup_asic(adev); | ||
7827 | ret = si_dpm_enable(adev); | ||
7828 | if (ret) | ||
7829 | adev->pm.dpm_enabled = false; | ||
7830 | else | ||
7831 | adev->pm.dpm_enabled = true; | ||
7832 | mutex_unlock(&adev->pm.mutex); | ||
7833 | if (adev->pm.dpm_enabled) | ||
7834 | amdgpu_pm_compute_clocks(adev); | ||
7835 | } | ||
7836 | return 0; | ||
7837 | } | ||
7838 | |||
7839 | static bool si_dpm_is_idle(void *handle) | ||
7840 | { | ||
7841 | /* XXX */ | ||
7842 | return true; | ||
7843 | } | ||
7844 | |||
7845 | static int si_dpm_wait_for_idle(void *handle) | ||
7846 | { | ||
7847 | /* XXX */ | ||
7848 | return 0; | ||
7849 | } | ||
7850 | |||
7851 | static int si_dpm_soft_reset(void *handle) | ||
7852 | { | ||
7853 | return 0; | ||
7854 | } | ||
7855 | |||
7856 | static int si_dpm_set_clockgating_state(void *handle, | ||
7857 | enum amd_clockgating_state state) | ||
7858 | { | ||
7859 | return 0; | ||
7860 | } | ||
7861 | |||
7862 | static int si_dpm_set_powergating_state(void *handle, | ||
7863 | enum amd_powergating_state state) | ||
7864 | { | ||
7865 | return 0; | ||
7866 | } | ||
7867 | |||
7868 | /* get temperature in millidegrees */ | ||
7869 | static int si_dpm_get_temp(struct amdgpu_device *adev) | ||
7870 | { | ||
7871 | u32 temp; | ||
7872 | int actual_temp = 0; | ||
7873 | |||
7874 | temp = (RREG32(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >> | ||
7875 | CTF_TEMP_SHIFT; | ||
7876 | |||
7877 | if (temp & 0x200) | ||
7878 | actual_temp = 255; | ||
7879 | else | ||
7880 | actual_temp = temp & 0x1ff; | ||
7881 | |||
7882 | actual_temp = (actual_temp * 1000); | ||
7883 | |||
7884 | return actual_temp; | ||
7885 | } | ||
7886 | |||
7887 | static u32 si_dpm_get_sclk(struct amdgpu_device *adev, bool low) | ||
7888 | { | ||
7889 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
7890 | struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps); | ||
7891 | |||
7892 | if (low) | ||
7893 | return requested_state->performance_levels[0].sclk; | ||
7894 | else | ||
7895 | return requested_state->performance_levels[requested_state->performance_level_count - 1].sclk; | ||
7896 | } | ||
7897 | |||
7898 | static u32 si_dpm_get_mclk(struct amdgpu_device *adev, bool low) | ||
7899 | { | ||
7900 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | ||
7901 | struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps); | ||
7902 | |||
7903 | if (low) | ||
7904 | return requested_state->performance_levels[0].mclk; | ||
7905 | else | ||
7906 | return requested_state->performance_levels[requested_state->performance_level_count - 1].mclk; | ||
7907 | } | ||
7908 | |||
7909 | static void si_dpm_print_power_state(struct amdgpu_device *adev, | ||
7910 | struct amdgpu_ps *rps) | ||
7911 | { | ||
7912 | struct si_ps *ps = si_get_ps(rps); | ||
7913 | struct rv7xx_pl *pl; | ||
7914 | int i; | ||
7915 | |||
7916 | amdgpu_dpm_print_class_info(rps->class, rps->class2); | ||
7917 | amdgpu_dpm_print_cap_info(rps->caps); | ||
7918 | DRM_INFO("\tuvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk); | ||
7919 | for (i = 0; i < ps->performance_level_count; i++) { | ||
7920 | pl = &ps->performance_levels[i]; | ||
7921 | if (adev->asic_type >= CHIP_TAHITI) | ||
7922 | DRM_INFO("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n", | ||
7923 | i, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1); | ||
7924 | else | ||
7925 | DRM_INFO("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u\n", | ||
7926 | i, pl->sclk, pl->mclk, pl->vddc, pl->vddci); | ||
7927 | } | ||
7928 | amdgpu_dpm_print_ps_status(adev, rps); | ||
7929 | } | ||
7930 | |||
7931 | static int si_dpm_early_init(void *handle) | ||
7932 | { | ||
7933 | |||
7934 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7935 | |||
7936 | si_dpm_set_dpm_funcs(adev); | ||
7937 | si_dpm_set_irq_funcs(adev); | ||
7938 | return 0; | ||
7939 | } | ||
7940 | |||
7941 | |||
7942 | const struct amd_ip_funcs si_dpm_ip_funcs = { | ||
7943 | .name = "si_dpm", | ||
7944 | .early_init = si_dpm_early_init, | ||
7945 | .late_init = si_dpm_late_init, | ||
7946 | .sw_init = si_dpm_sw_init, | ||
7947 | .sw_fini = si_dpm_sw_fini, | ||
7948 | .hw_init = si_dpm_hw_init, | ||
7949 | .hw_fini = si_dpm_hw_fini, | ||
7950 | .suspend = si_dpm_suspend, | ||
7951 | .resume = si_dpm_resume, | ||
7952 | .is_idle = si_dpm_is_idle, | ||
7953 | .wait_for_idle = si_dpm_wait_for_idle, | ||
7954 | .soft_reset = si_dpm_soft_reset, | ||
7955 | .set_clockgating_state = si_dpm_set_clockgating_state, | ||
7956 | .set_powergating_state = si_dpm_set_powergating_state, | ||
7957 | }; | ||
7958 | |||
7959 | static const struct amdgpu_dpm_funcs si_dpm_funcs = { | ||
7960 | .get_temperature = &si_dpm_get_temp, | ||
7961 | .pre_set_power_state = &si_dpm_pre_set_power_state, | ||
7962 | .set_power_state = &si_dpm_set_power_state, | ||
7963 | .post_set_power_state = &si_dpm_post_set_power_state, | ||
7964 | .display_configuration_changed = &si_dpm_display_configuration_changed, | ||
7965 | .get_sclk = &si_dpm_get_sclk, | ||
7966 | .get_mclk = &si_dpm_get_mclk, | ||
7967 | .print_power_state = &si_dpm_print_power_state, | ||
7968 | .debugfs_print_current_performance_level = &si_dpm_debugfs_print_current_performance_level, | ||
7969 | .force_performance_level = &si_dpm_force_performance_level, | ||
7970 | .vblank_too_short = &si_dpm_vblank_too_short, | ||
7971 | .set_fan_control_mode = &si_dpm_set_fan_control_mode, | ||
7972 | .get_fan_control_mode = &si_dpm_get_fan_control_mode, | ||
7973 | .set_fan_speed_percent = &si_dpm_set_fan_speed_percent, | ||
7974 | .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, | ||
7975 | }; | ||
7976 | |||
7977 | static void si_dpm_set_dpm_funcs(struct amdgpu_device *adev) | ||
7978 | { | ||
7979 | if (adev->pm.funcs == NULL) | ||
7980 | adev->pm.funcs = &si_dpm_funcs; | ||
7981 | } | ||
7982 | |||
7983 | static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = { | ||
7984 | .set = si_dpm_set_interrupt_state, | ||
7985 | .process = si_dpm_process_interrupt, | ||
7986 | }; | ||
7987 | |||
7988 | static void si_dpm_set_irq_funcs(struct amdgpu_device *adev) | ||
7989 | { | ||
7990 | adev->pm.dpm.thermal.irq.num_types = AMDGPU_THERMAL_IRQ_LAST; | ||
7991 | adev->pm.dpm.thermal.irq.funcs = &si_dpm_irq_funcs; | ||
7992 | } | ||
7993 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.h b/drivers/gpu/drm/amd/amdgpu/si_dpm.h new file mode 100644 index 000000000000..51ce21c5f4fb --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.h | |||
@@ -0,0 +1,1015 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #ifndef __SI_DPM_H__ | ||
24 | #define __SI_DPM_H__ | ||
25 | |||
26 | #include "amdgpu_atombios.h" | ||
27 | #include "sislands_smc.h" | ||
28 | |||
29 | #define MC_CG_CONFIG 0x96f | ||
30 | #define MC_ARB_CG 0x9fa | ||
31 | #define CG_ARB_REQ(x) ((x) << 0) | ||
32 | #define CG_ARB_REQ_MASK (0xff << 0) | ||
33 | |||
34 | #define MC_ARB_DRAM_TIMING_1 0x9fc | ||
35 | #define MC_ARB_DRAM_TIMING_2 0x9fd | ||
36 | #define MC_ARB_DRAM_TIMING_3 0x9fe | ||
37 | #define MC_ARB_DRAM_TIMING2_1 0x9ff | ||
38 | #define MC_ARB_DRAM_TIMING2_2 0xa00 | ||
39 | #define MC_ARB_DRAM_TIMING2_3 0xa01 | ||
40 | |||
41 | #define MAX_NO_OF_MVDD_VALUES 2 | ||
42 | #define MAX_NO_VREG_STEPS 32 | ||
43 | #define NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16 | ||
44 | #define SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE 32 | ||
45 | #define SMC_NISLANDS_MC_REGISTER_ARRAY_SET_COUNT 20 | ||
46 | #define RV770_ASI_DFLT 1000 | ||
47 | #define CYPRESS_HASI_DFLT 400000 | ||
48 | #define PCIE_PERF_REQ_PECI_GEN1 2 | ||
49 | #define PCIE_PERF_REQ_PECI_GEN2 3 | ||
50 | #define PCIE_PERF_REQ_PECI_GEN3 4 | ||
51 | #define RV770_DEFAULT_VCLK_FREQ 53300 /* 10 khz */ | ||
52 | #define RV770_DEFAULT_DCLK_FREQ 40000 /* 10 khz */ | ||
53 | |||
54 | #define SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE 16 | ||
55 | |||
56 | #define RV770_SMC_TABLE_ADDRESS 0xB000 | ||
57 | #define RV770_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 3 | ||
58 | |||
59 | #define SMC_STROBE_RATIO 0x0F | ||
60 | #define SMC_STROBE_ENABLE 0x10 | ||
61 | |||
62 | #define SMC_MC_EDC_RD_FLAG 0x01 | ||
63 | #define SMC_MC_EDC_WR_FLAG 0x02 | ||
64 | #define SMC_MC_RTT_ENABLE 0x04 | ||
65 | #define SMC_MC_STUTTER_EN 0x08 | ||
66 | |||
67 | #define RV770_SMC_VOLTAGEMASK_VDDC 0 | ||
68 | #define RV770_SMC_VOLTAGEMASK_MVDD 1 | ||
69 | #define RV770_SMC_VOLTAGEMASK_VDDCI 2 | ||
70 | #define RV770_SMC_VOLTAGEMASK_MAX 4 | ||
71 | |||
72 | #define NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16 | ||
73 | #define NISLANDS_SMC_STROBE_RATIO 0x0F | ||
74 | #define NISLANDS_SMC_STROBE_ENABLE 0x10 | ||
75 | |||
76 | #define NISLANDS_SMC_MC_EDC_RD_FLAG 0x01 | ||
77 | #define NISLANDS_SMC_MC_EDC_WR_FLAG 0x02 | ||
78 | #define NISLANDS_SMC_MC_RTT_ENABLE 0x04 | ||
79 | #define NISLANDS_SMC_MC_STUTTER_EN 0x08 | ||
80 | |||
81 | #define MAX_NO_VREG_STEPS 32 | ||
82 | |||
83 | #define NISLANDS_SMC_VOLTAGEMASK_VDDC 0 | ||
84 | #define NISLANDS_SMC_VOLTAGEMASK_MVDD 1 | ||
85 | #define NISLANDS_SMC_VOLTAGEMASK_VDDCI 2 | ||
86 | #define NISLANDS_SMC_VOLTAGEMASK_MAX 4 | ||
87 | |||
88 | #define SISLANDS_MCREGISTERTABLE_INITIAL_SLOT 0 | ||
89 | #define SISLANDS_MCREGISTERTABLE_ACPI_SLOT 1 | ||
90 | #define SISLANDS_MCREGISTERTABLE_ULV_SLOT 2 | ||
91 | #define SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 3 | ||
92 | |||
93 | #define SISLANDS_LEAKAGE_INDEX0 0xff01 | ||
94 | #define SISLANDS_MAX_LEAKAGE_COUNT 4 | ||
95 | |||
96 | #define SISLANDS_MAX_HARDWARE_POWERLEVELS 5 | ||
97 | #define SISLANDS_INITIAL_STATE_ARB_INDEX 0 | ||
98 | #define SISLANDS_ACPI_STATE_ARB_INDEX 1 | ||
99 | #define SISLANDS_ULV_STATE_ARB_INDEX 2 | ||
100 | #define SISLANDS_DRIVER_STATE_ARB_INDEX 3 | ||
101 | |||
102 | #define SISLANDS_DPM2_MAX_PULSE_SKIP 256 | ||
103 | |||
104 | #define SISLANDS_DPM2_NEAR_TDP_DEC 10 | ||
105 | #define SISLANDS_DPM2_ABOVE_SAFE_INC 5 | ||
106 | #define SISLANDS_DPM2_BELOW_SAFE_INC 20 | ||
107 | |||
108 | #define SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80 | ||
109 | |||
110 | #define SISLANDS_DPM2_MAXPS_PERCENT_H 99 | ||
111 | #define SISLANDS_DPM2_MAXPS_PERCENT_M 99 | ||
112 | |||
113 | #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF | ||
114 | #define SISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12 | ||
115 | #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15 | ||
116 | #define SISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E | ||
117 | #define SISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF | ||
118 | |||
119 | #define SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN 10 | ||
120 | |||
121 | #define SISLANDS_VRC_DFLT 0xC000B3 | ||
122 | #define SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT 1687 | ||
123 | #define SISLANDS_CGULVPARAMETER_DFLT 0x00040035 | ||
124 | #define SISLANDS_CGULVCONTROL_DFLT 0x1f007550 | ||
125 | |||
126 | #define SI_ASI_DFLT 10000 | ||
127 | #define SI_BSP_DFLT 0x41EB | ||
128 | #define SI_BSU_DFLT 0x2 | ||
129 | #define SI_AH_DFLT 5 | ||
130 | #define SI_RLP_DFLT 25 | ||
131 | #define SI_RMP_DFLT 65 | ||
132 | #define SI_LHP_DFLT 40 | ||
133 | #define SI_LMP_DFLT 15 | ||
134 | #define SI_TD_DFLT 0 | ||
135 | #define SI_UTC_DFLT_00 0x24 | ||
136 | #define SI_UTC_DFLT_01 0x22 | ||
137 | #define SI_UTC_DFLT_02 0x22 | ||
138 | #define SI_UTC_DFLT_03 0x22 | ||
139 | #define SI_UTC_DFLT_04 0x22 | ||
140 | #define SI_UTC_DFLT_05 0x22 | ||
141 | #define SI_UTC_DFLT_06 0x22 | ||
142 | #define SI_UTC_DFLT_07 0x22 | ||
143 | #define SI_UTC_DFLT_08 0x22 | ||
144 | #define SI_UTC_DFLT_09 0x22 | ||
145 | #define SI_UTC_DFLT_10 0x22 | ||
146 | #define SI_UTC_DFLT_11 0x22 | ||
147 | #define SI_UTC_DFLT_12 0x22 | ||
148 | #define SI_UTC_DFLT_13 0x22 | ||
149 | #define SI_UTC_DFLT_14 0x22 | ||
150 | #define SI_DTC_DFLT_00 0x24 | ||
151 | #define SI_DTC_DFLT_01 0x22 | ||
152 | #define SI_DTC_DFLT_02 0x22 | ||
153 | #define SI_DTC_DFLT_03 0x22 | ||
154 | #define SI_DTC_DFLT_04 0x22 | ||
155 | #define SI_DTC_DFLT_05 0x22 | ||
156 | #define SI_DTC_DFLT_06 0x22 | ||
157 | #define SI_DTC_DFLT_07 0x22 | ||
158 | #define SI_DTC_DFLT_08 0x22 | ||
159 | #define SI_DTC_DFLT_09 0x22 | ||
160 | #define SI_DTC_DFLT_10 0x22 | ||
161 | #define SI_DTC_DFLT_11 0x22 | ||
162 | #define SI_DTC_DFLT_12 0x22 | ||
163 | #define SI_DTC_DFLT_13 0x22 | ||
164 | #define SI_DTC_DFLT_14 0x22 | ||
165 | #define SI_VRC_DFLT 0x0000C003 | ||
166 | #define SI_VOLTAGERESPONSETIME_DFLT 1000 | ||
167 | #define SI_BACKBIASRESPONSETIME_DFLT 1000 | ||
168 | #define SI_VRU_DFLT 0x3 | ||
169 | #define SI_SPLLSTEPTIME_DFLT 0x1000 | ||
170 | #define SI_SPLLSTEPUNIT_DFLT 0x3 | ||
171 | #define SI_TPU_DFLT 0 | ||
172 | #define SI_TPC_DFLT 0x200 | ||
173 | #define SI_SSTU_DFLT 0 | ||
174 | #define SI_SST_DFLT 0x00C8 | ||
175 | #define SI_GICST_DFLT 0x200 | ||
176 | #define SI_FCT_DFLT 0x0400 | ||
177 | #define SI_FCTU_DFLT 0 | ||
178 | #define SI_CTXCGTT3DRPHC_DFLT 0x20 | ||
179 | #define SI_CTXCGTT3DRSDC_DFLT 0x40 | ||
180 | #define SI_VDDC3DOORPHC_DFLT 0x100 | ||
181 | #define SI_VDDC3DOORSDC_DFLT 0x7 | ||
182 | #define SI_VDDC3DOORSU_DFLT 0 | ||
183 | #define SI_MPLLLOCKTIME_DFLT 100 | ||
184 | #define SI_MPLLRESETTIME_DFLT 150 | ||
185 | #define SI_VCOSTEPPCT_DFLT 20 | ||
186 | #define SI_ENDINGVCOSTEPPCT_DFLT 5 | ||
187 | #define SI_REFERENCEDIVIDER_DFLT 4 | ||
188 | |||
189 | #define SI_PM_NUMBER_OF_TC 15 | ||
190 | #define SI_PM_NUMBER_OF_SCLKS 20 | ||
191 | #define SI_PM_NUMBER_OF_MCLKS 4 | ||
192 | #define SI_PM_NUMBER_OF_VOLTAGE_LEVELS 4 | ||
193 | #define SI_PM_NUMBER_OF_ACTIVITY_LEVELS 3 | ||
194 | |||
195 | /* XXX are these ok? */ | ||
196 | #define SI_TEMP_RANGE_MIN (90 * 1000) | ||
197 | #define SI_TEMP_RANGE_MAX (120 * 1000) | ||
198 | |||
199 | #define FDO_PWM_MODE_STATIC 1 | ||
200 | #define FDO_PWM_MODE_STATIC_RPM 5 | ||
201 | |||
202 | enum ni_dc_cac_level | ||
203 | { | ||
204 | NISLANDS_DCCAC_LEVEL_0 = 0, | ||
205 | NISLANDS_DCCAC_LEVEL_1, | ||
206 | NISLANDS_DCCAC_LEVEL_2, | ||
207 | NISLANDS_DCCAC_LEVEL_3, | ||
208 | NISLANDS_DCCAC_LEVEL_4, | ||
209 | NISLANDS_DCCAC_LEVEL_5, | ||
210 | NISLANDS_DCCAC_LEVEL_6, | ||
211 | NISLANDS_DCCAC_LEVEL_7, | ||
212 | NISLANDS_DCCAC_MAX_LEVELS | ||
213 | }; | ||
214 | |||
215 | enum si_cac_config_reg_type | ||
216 | { | ||
217 | SISLANDS_CACCONFIG_MMR = 0, | ||
218 | SISLANDS_CACCONFIG_CGIND, | ||
219 | SISLANDS_CACCONFIG_MAX | ||
220 | }; | ||
221 | |||
222 | enum si_power_level { | ||
223 | SI_POWER_LEVEL_LOW = 0, | ||
224 | SI_POWER_LEVEL_MEDIUM = 1, | ||
225 | SI_POWER_LEVEL_HIGH = 2, | ||
226 | SI_POWER_LEVEL_CTXSW = 3, | ||
227 | }; | ||
228 | |||
229 | enum si_td { | ||
230 | SI_TD_AUTO, | ||
231 | SI_TD_UP, | ||
232 | SI_TD_DOWN, | ||
233 | }; | ||
234 | |||
235 | enum si_display_watermark { | ||
236 | SI_DISPLAY_WATERMARK_LOW = 0, | ||
237 | SI_DISPLAY_WATERMARK_HIGH = 1, | ||
238 | }; | ||
239 | |||
240 | enum si_display_gap | ||
241 | { | ||
242 | SI_PM_DISPLAY_GAP_VBLANK_OR_WM = 0, | ||
243 | SI_PM_DISPLAY_GAP_VBLANK = 1, | ||
244 | SI_PM_DISPLAY_GAP_WATERMARK = 2, | ||
245 | SI_PM_DISPLAY_GAP_IGNORE = 3, | ||
246 | }; | ||
247 | |||
248 | extern const struct amd_ip_funcs si_dpm_ip_funcs; | ||
249 | |||
250 | struct ni_leakage_coeffients | ||
251 | { | ||
252 | u32 at; | ||
253 | u32 bt; | ||
254 | u32 av; | ||
255 | u32 bv; | ||
256 | s32 t_slope; | ||
257 | s32 t_intercept; | ||
258 | u32 t_ref; | ||
259 | }; | ||
260 | |||
261 | struct SMC_Evergreen_MCRegisterAddress | ||
262 | { | ||
263 | uint16_t s0; | ||
264 | uint16_t s1; | ||
265 | }; | ||
266 | |||
267 | typedef struct SMC_Evergreen_MCRegisterAddress SMC_Evergreen_MCRegisterAddress; | ||
268 | |||
269 | struct evergreen_mc_reg_entry { | ||
270 | u32 mclk_max; | ||
271 | u32 mc_data[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE]; | ||
272 | }; | ||
273 | |||
274 | struct evergreen_mc_reg_table { | ||
275 | u8 last; | ||
276 | u8 num_entries; | ||
277 | u16 valid_flag; | ||
278 | struct evergreen_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; | ||
279 | SMC_Evergreen_MCRegisterAddress mc_reg_address[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE]; | ||
280 | }; | ||
281 | |||
282 | struct SMC_Evergreen_MCRegisterSet | ||
283 | { | ||
284 | uint32_t value[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE]; | ||
285 | }; | ||
286 | |||
287 | typedef struct SMC_Evergreen_MCRegisterSet SMC_Evergreen_MCRegisterSet; | ||
288 | |||
289 | struct SMC_Evergreen_MCRegisters | ||
290 | { | ||
291 | uint8_t last; | ||
292 | uint8_t reserved[3]; | ||
293 | SMC_Evergreen_MCRegisterAddress address[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE]; | ||
294 | SMC_Evergreen_MCRegisterSet data[5]; | ||
295 | }; | ||
296 | |||
297 | typedef struct SMC_Evergreen_MCRegisters SMC_Evergreen_MCRegisters; | ||
298 | |||
299 | struct SMC_NIslands_MCRegisterSet | ||
300 | { | ||
301 | uint32_t value[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
302 | }; | ||
303 | |||
304 | typedef struct SMC_NIslands_MCRegisterSet SMC_NIslands_MCRegisterSet; | ||
305 | |||
306 | struct ni_mc_reg_entry { | ||
307 | u32 mclk_max; | ||
308 | u32 mc_data[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
309 | }; | ||
310 | |||
311 | struct SMC_NIslands_MCRegisterAddress | ||
312 | { | ||
313 | uint16_t s0; | ||
314 | uint16_t s1; | ||
315 | }; | ||
316 | |||
317 | typedef struct SMC_NIslands_MCRegisterAddress SMC_NIslands_MCRegisterAddress; | ||
318 | |||
319 | struct SMC_NIslands_MCRegisters | ||
320 | { | ||
321 | uint8_t last; | ||
322 | uint8_t reserved[3]; | ||
323 | SMC_NIslands_MCRegisterAddress address[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
324 | SMC_NIslands_MCRegisterSet data[SMC_NISLANDS_MC_REGISTER_ARRAY_SET_COUNT]; | ||
325 | }; | ||
326 | |||
327 | typedef struct SMC_NIslands_MCRegisters SMC_NIslands_MCRegisters; | ||
328 | |||
329 | struct evergreen_ulv_param { | ||
330 | bool supported; | ||
331 | struct rv7xx_pl *pl; | ||
332 | }; | ||
333 | |||
334 | struct evergreen_arb_registers { | ||
335 | u32 mc_arb_dram_timing; | ||
336 | u32 mc_arb_dram_timing2; | ||
337 | u32 mc_arb_rfsh_rate; | ||
338 | u32 mc_arb_burst_time; | ||
339 | }; | ||
340 | |||
341 | struct at { | ||
342 | u32 rlp; | ||
343 | u32 rmp; | ||
344 | u32 lhp; | ||
345 | u32 lmp; | ||
346 | }; | ||
347 | |||
348 | struct ni_clock_registers { | ||
349 | u32 cg_spll_func_cntl; | ||
350 | u32 cg_spll_func_cntl_2; | ||
351 | u32 cg_spll_func_cntl_3; | ||
352 | u32 cg_spll_func_cntl_4; | ||
353 | u32 cg_spll_spread_spectrum; | ||
354 | u32 cg_spll_spread_spectrum_2; | ||
355 | u32 mclk_pwrmgt_cntl; | ||
356 | u32 dll_cntl; | ||
357 | u32 mpll_ad_func_cntl; | ||
358 | u32 mpll_ad_func_cntl_2; | ||
359 | u32 mpll_dq_func_cntl; | ||
360 | u32 mpll_dq_func_cntl_2; | ||
361 | u32 mpll_ss1; | ||
362 | u32 mpll_ss2; | ||
363 | }; | ||
364 | |||
365 | struct RV770_SMC_SCLK_VALUE | ||
366 | { | ||
367 | uint32_t vCG_SPLL_FUNC_CNTL; | ||
368 | uint32_t vCG_SPLL_FUNC_CNTL_2; | ||
369 | uint32_t vCG_SPLL_FUNC_CNTL_3; | ||
370 | uint32_t vCG_SPLL_SPREAD_SPECTRUM; | ||
371 | uint32_t vCG_SPLL_SPREAD_SPECTRUM_2; | ||
372 | uint32_t sclk_value; | ||
373 | }; | ||
374 | |||
375 | typedef struct RV770_SMC_SCLK_VALUE RV770_SMC_SCLK_VALUE; | ||
376 | |||
377 | struct RV770_SMC_MCLK_VALUE | ||
378 | { | ||
379 | uint32_t vMPLL_AD_FUNC_CNTL; | ||
380 | uint32_t vMPLL_AD_FUNC_CNTL_2; | ||
381 | uint32_t vMPLL_DQ_FUNC_CNTL; | ||
382 | uint32_t vMPLL_DQ_FUNC_CNTL_2; | ||
383 | uint32_t vMCLK_PWRMGT_CNTL; | ||
384 | uint32_t vDLL_CNTL; | ||
385 | uint32_t vMPLL_SS; | ||
386 | uint32_t vMPLL_SS2; | ||
387 | uint32_t mclk_value; | ||
388 | }; | ||
389 | |||
390 | typedef struct RV770_SMC_MCLK_VALUE RV770_SMC_MCLK_VALUE; | ||
391 | |||
392 | |||
393 | struct RV730_SMC_MCLK_VALUE | ||
394 | { | ||
395 | uint32_t vMCLK_PWRMGT_CNTL; | ||
396 | uint32_t vDLL_CNTL; | ||
397 | uint32_t vMPLL_FUNC_CNTL; | ||
398 | uint32_t vMPLL_FUNC_CNTL2; | ||
399 | uint32_t vMPLL_FUNC_CNTL3; | ||
400 | uint32_t vMPLL_SS; | ||
401 | uint32_t vMPLL_SS2; | ||
402 | uint32_t mclk_value; | ||
403 | }; | ||
404 | |||
405 | typedef struct RV730_SMC_MCLK_VALUE RV730_SMC_MCLK_VALUE; | ||
406 | |||
407 | struct RV770_SMC_VOLTAGE_VALUE | ||
408 | { | ||
409 | uint16_t value; | ||
410 | uint8_t index; | ||
411 | uint8_t padding; | ||
412 | }; | ||
413 | |||
414 | typedef struct RV770_SMC_VOLTAGE_VALUE RV770_SMC_VOLTAGE_VALUE; | ||
415 | |||
416 | union RV7XX_SMC_MCLK_VALUE | ||
417 | { | ||
418 | RV770_SMC_MCLK_VALUE mclk770; | ||
419 | RV730_SMC_MCLK_VALUE mclk730; | ||
420 | }; | ||
421 | |||
422 | typedef union RV7XX_SMC_MCLK_VALUE RV7XX_SMC_MCLK_VALUE, *LPRV7XX_SMC_MCLK_VALUE; | ||
423 | |||
424 | struct RV770_SMC_HW_PERFORMANCE_LEVEL | ||
425 | { | ||
426 | uint8_t arbValue; | ||
427 | union{ | ||
428 | uint8_t seqValue; | ||
429 | uint8_t ACIndex; | ||
430 | }; | ||
431 | uint8_t displayWatermark; | ||
432 | uint8_t gen2PCIE; | ||
433 | uint8_t gen2XSP; | ||
434 | uint8_t backbias; | ||
435 | uint8_t strobeMode; | ||
436 | uint8_t mcFlags; | ||
437 | uint32_t aT; | ||
438 | uint32_t bSP; | ||
439 | RV770_SMC_SCLK_VALUE sclk; | ||
440 | RV7XX_SMC_MCLK_VALUE mclk; | ||
441 | RV770_SMC_VOLTAGE_VALUE vddc; | ||
442 | RV770_SMC_VOLTAGE_VALUE mvdd; | ||
443 | RV770_SMC_VOLTAGE_VALUE vddci; | ||
444 | uint8_t reserved1; | ||
445 | uint8_t reserved2; | ||
446 | uint8_t stateFlags; | ||
447 | uint8_t padding; | ||
448 | }; | ||
449 | |||
450 | typedef struct RV770_SMC_HW_PERFORMANCE_LEVEL RV770_SMC_HW_PERFORMANCE_LEVEL; | ||
451 | |||
452 | struct RV770_SMC_SWSTATE | ||
453 | { | ||
454 | uint8_t flags; | ||
455 | uint8_t padding1; | ||
456 | uint8_t padding2; | ||
457 | uint8_t padding3; | ||
458 | RV770_SMC_HW_PERFORMANCE_LEVEL levels[RV770_SMC_PERFORMANCE_LEVELS_PER_SWSTATE]; | ||
459 | }; | ||
460 | |||
461 | typedef struct RV770_SMC_SWSTATE RV770_SMC_SWSTATE; | ||
462 | |||
463 | struct RV770_SMC_VOLTAGEMASKTABLE | ||
464 | { | ||
465 | uint8_t highMask[RV770_SMC_VOLTAGEMASK_MAX]; | ||
466 | uint32_t lowMask[RV770_SMC_VOLTAGEMASK_MAX]; | ||
467 | }; | ||
468 | |||
469 | typedef struct RV770_SMC_VOLTAGEMASKTABLE RV770_SMC_VOLTAGEMASKTABLE; | ||
470 | |||
471 | struct RV770_SMC_STATETABLE | ||
472 | { | ||
473 | uint8_t thermalProtectType; | ||
474 | uint8_t systemFlags; | ||
475 | uint8_t maxVDDCIndexInPPTable; | ||
476 | uint8_t extraFlags; | ||
477 | uint8_t highSMIO[MAX_NO_VREG_STEPS]; | ||
478 | uint32_t lowSMIO[MAX_NO_VREG_STEPS]; | ||
479 | RV770_SMC_VOLTAGEMASKTABLE voltageMaskTable; | ||
480 | RV770_SMC_SWSTATE initialState; | ||
481 | RV770_SMC_SWSTATE ACPIState; | ||
482 | RV770_SMC_SWSTATE driverState; | ||
483 | RV770_SMC_SWSTATE ULVState; | ||
484 | }; | ||
485 | |||
486 | typedef struct RV770_SMC_STATETABLE RV770_SMC_STATETABLE; | ||
487 | |||
488 | struct vddc_table_entry { | ||
489 | u16 vddc; | ||
490 | u8 vddc_index; | ||
491 | u8 high_smio; | ||
492 | u32 low_smio; | ||
493 | }; | ||
494 | |||
495 | struct rv770_clock_registers { | ||
496 | u32 cg_spll_func_cntl; | ||
497 | u32 cg_spll_func_cntl_2; | ||
498 | u32 cg_spll_func_cntl_3; | ||
499 | u32 cg_spll_spread_spectrum; | ||
500 | u32 cg_spll_spread_spectrum_2; | ||
501 | u32 mpll_ad_func_cntl; | ||
502 | u32 mpll_ad_func_cntl_2; | ||
503 | u32 mpll_dq_func_cntl; | ||
504 | u32 mpll_dq_func_cntl_2; | ||
505 | u32 mclk_pwrmgt_cntl; | ||
506 | u32 dll_cntl; | ||
507 | u32 mpll_ss1; | ||
508 | u32 mpll_ss2; | ||
509 | }; | ||
510 | |||
511 | struct rv730_clock_registers { | ||
512 | u32 cg_spll_func_cntl; | ||
513 | u32 cg_spll_func_cntl_2; | ||
514 | u32 cg_spll_func_cntl_3; | ||
515 | u32 cg_spll_spread_spectrum; | ||
516 | u32 cg_spll_spread_spectrum_2; | ||
517 | u32 mclk_pwrmgt_cntl; | ||
518 | u32 dll_cntl; | ||
519 | u32 mpll_func_cntl; | ||
520 | u32 mpll_func_cntl2; | ||
521 | u32 mpll_func_cntl3; | ||
522 | u32 mpll_ss; | ||
523 | u32 mpll_ss2; | ||
524 | }; | ||
525 | |||
526 | union r7xx_clock_registers { | ||
527 | struct rv770_clock_registers rv770; | ||
528 | struct rv730_clock_registers rv730; | ||
529 | }; | ||
530 | |||
531 | struct rv7xx_power_info { | ||
532 | /* flags */ | ||
533 | bool mem_gddr5; | ||
534 | bool pcie_gen2; | ||
535 | bool dynamic_pcie_gen2; | ||
536 | bool acpi_pcie_gen2; | ||
537 | bool boot_in_gen2; | ||
538 | bool voltage_control; /* vddc */ | ||
539 | bool mvdd_control; | ||
540 | bool sclk_ss; | ||
541 | bool mclk_ss; | ||
542 | bool dynamic_ss; | ||
543 | bool gfx_clock_gating; | ||
544 | bool mg_clock_gating; | ||
545 | bool mgcgtssm; | ||
546 | bool power_gating; | ||
547 | bool thermal_protection; | ||
548 | bool display_gap; | ||
549 | bool dcodt; | ||
550 | bool ulps; | ||
551 | /* registers */ | ||
552 | union r7xx_clock_registers clk_regs; | ||
553 | u32 s0_vid_lower_smio_cntl; | ||
554 | /* voltage */ | ||
555 | u32 vddc_mask_low; | ||
556 | u32 mvdd_mask_low; | ||
557 | u32 mvdd_split_frequency; | ||
558 | u32 mvdd_low_smio[MAX_NO_OF_MVDD_VALUES]; | ||
559 | u16 max_vddc; | ||
560 | u16 max_vddc_in_table; | ||
561 | u16 min_vddc_in_table; | ||
562 | struct vddc_table_entry vddc_table[MAX_NO_VREG_STEPS]; | ||
563 | u8 valid_vddc_entries; | ||
564 | /* dc odt */ | ||
565 | u32 mclk_odt_threshold; | ||
566 | u8 odt_value_0[2]; | ||
567 | u8 odt_value_1[2]; | ||
568 | /* stored values */ | ||
569 | u32 boot_sclk; | ||
570 | u16 acpi_vddc; | ||
571 | u32 ref_div; | ||
572 | u32 active_auto_throttle_sources; | ||
573 | u32 mclk_stutter_mode_threshold; | ||
574 | u32 mclk_strobe_mode_threshold; | ||
575 | u32 mclk_edc_enable_threshold; | ||
576 | u32 bsp; | ||
577 | u32 bsu; | ||
578 | u32 pbsp; | ||
579 | u32 pbsu; | ||
580 | u32 dsp; | ||
581 | u32 psp; | ||
582 | u32 asi; | ||
583 | u32 pasi; | ||
584 | u32 vrc; | ||
585 | u32 restricted_levels; | ||
586 | u32 rlp; | ||
587 | u32 rmp; | ||
588 | u32 lhp; | ||
589 | u32 lmp; | ||
590 | /* smc offsets */ | ||
591 | u16 state_table_start; | ||
592 | u16 soft_regs_start; | ||
593 | u16 sram_end; | ||
594 | /* scratch structs */ | ||
595 | RV770_SMC_STATETABLE smc_statetable; | ||
596 | }; | ||
597 | |||
598 | struct rv7xx_pl { | ||
599 | u32 sclk; | ||
600 | u32 mclk; | ||
601 | u16 vddc; | ||
602 | u16 vddci; /* eg+ only */ | ||
603 | u32 flags; | ||
604 | enum amdgpu_pcie_gen pcie_gen; /* si+ only */ | ||
605 | }; | ||
606 | |||
607 | struct rv7xx_ps { | ||
608 | struct rv7xx_pl high; | ||
609 | struct rv7xx_pl medium; | ||
610 | struct rv7xx_pl low; | ||
611 | bool dc_compatible; | ||
612 | }; | ||
613 | |||
614 | struct si_ps { | ||
615 | u16 performance_level_count; | ||
616 | bool dc_compatible; | ||
617 | struct rv7xx_pl performance_levels[NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE]; | ||
618 | }; | ||
619 | |||
620 | struct ni_mc_reg_table { | ||
621 | u8 last; | ||
622 | u8 num_entries; | ||
623 | u16 valid_flag; | ||
624 | struct ni_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; | ||
625 | SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
626 | }; | ||
627 | |||
628 | struct ni_cac_data | ||
629 | { | ||
630 | struct ni_leakage_coeffients leakage_coefficients; | ||
631 | u32 i_leakage; | ||
632 | s32 leakage_minimum_temperature; | ||
633 | u32 pwr_const; | ||
634 | u32 dc_cac_value; | ||
635 | u32 bif_cac_value; | ||
636 | u32 lkge_pwr; | ||
637 | u8 mc_wr_weight; | ||
638 | u8 mc_rd_weight; | ||
639 | u8 allow_ovrflw; | ||
640 | u8 num_win_tdp; | ||
641 | u8 l2num_win_tdp; | ||
642 | u8 lts_truncate_n; | ||
643 | }; | ||
644 | |||
645 | struct evergreen_power_info { | ||
646 | /* must be first! */ | ||
647 | struct rv7xx_power_info rv7xx; | ||
648 | /* flags */ | ||
649 | bool vddci_control; | ||
650 | bool dynamic_ac_timing; | ||
651 | bool abm; | ||
652 | bool mcls; | ||
653 | bool light_sleep; | ||
654 | bool memory_transition; | ||
655 | bool pcie_performance_request; | ||
656 | bool pcie_performance_request_registered; | ||
657 | bool sclk_deep_sleep; | ||
658 | bool dll_default_on; | ||
659 | bool ls_clock_gating; | ||
660 | bool smu_uvd_hs; | ||
661 | bool uvd_enabled; | ||
662 | /* stored values */ | ||
663 | u16 acpi_vddci; | ||
664 | u8 mvdd_high_index; | ||
665 | u8 mvdd_low_index; | ||
666 | u32 mclk_edc_wr_enable_threshold; | ||
667 | struct evergreen_mc_reg_table mc_reg_table; | ||
668 | struct atom_voltage_table vddc_voltage_table; | ||
669 | struct atom_voltage_table vddci_voltage_table; | ||
670 | struct evergreen_arb_registers bootup_arb_registers; | ||
671 | struct evergreen_ulv_param ulv; | ||
672 | struct at ats[2]; | ||
673 | /* smc offsets */ | ||
674 | u16 mc_reg_table_start; | ||
675 | struct amdgpu_ps current_rps; | ||
676 | struct rv7xx_ps current_ps; | ||
677 | struct amdgpu_ps requested_rps; | ||
678 | struct rv7xx_ps requested_ps; | ||
679 | }; | ||
680 | |||
681 | struct PP_NIslands_Dpm2PerfLevel | ||
682 | { | ||
683 | uint8_t MaxPS; | ||
684 | uint8_t TgtAct; | ||
685 | uint8_t MaxPS_StepInc; | ||
686 | uint8_t MaxPS_StepDec; | ||
687 | uint8_t PSST; | ||
688 | uint8_t NearTDPDec; | ||
689 | uint8_t AboveSafeInc; | ||
690 | uint8_t BelowSafeInc; | ||
691 | uint8_t PSDeltaLimit; | ||
692 | uint8_t PSDeltaWin; | ||
693 | uint8_t Reserved[6]; | ||
694 | }; | ||
695 | |||
696 | typedef struct PP_NIslands_Dpm2PerfLevel PP_NIslands_Dpm2PerfLevel; | ||
697 | |||
698 | struct PP_NIslands_DPM2Parameters | ||
699 | { | ||
700 | uint32_t TDPLimit; | ||
701 | uint32_t NearTDPLimit; | ||
702 | uint32_t SafePowerLimit; | ||
703 | uint32_t PowerBoostLimit; | ||
704 | }; | ||
705 | typedef struct PP_NIslands_DPM2Parameters PP_NIslands_DPM2Parameters; | ||
706 | |||
707 | struct NISLANDS_SMC_SCLK_VALUE | ||
708 | { | ||
709 | uint32_t vCG_SPLL_FUNC_CNTL; | ||
710 | uint32_t vCG_SPLL_FUNC_CNTL_2; | ||
711 | uint32_t vCG_SPLL_FUNC_CNTL_3; | ||
712 | uint32_t vCG_SPLL_FUNC_CNTL_4; | ||
713 | uint32_t vCG_SPLL_SPREAD_SPECTRUM; | ||
714 | uint32_t vCG_SPLL_SPREAD_SPECTRUM_2; | ||
715 | uint32_t sclk_value; | ||
716 | }; | ||
717 | |||
718 | typedef struct NISLANDS_SMC_SCLK_VALUE NISLANDS_SMC_SCLK_VALUE; | ||
719 | |||
720 | struct NISLANDS_SMC_MCLK_VALUE | ||
721 | { | ||
722 | uint32_t vMPLL_FUNC_CNTL; | ||
723 | uint32_t vMPLL_FUNC_CNTL_1; | ||
724 | uint32_t vMPLL_FUNC_CNTL_2; | ||
725 | uint32_t vMPLL_AD_FUNC_CNTL; | ||
726 | uint32_t vMPLL_AD_FUNC_CNTL_2; | ||
727 | uint32_t vMPLL_DQ_FUNC_CNTL; | ||
728 | uint32_t vMPLL_DQ_FUNC_CNTL_2; | ||
729 | uint32_t vMCLK_PWRMGT_CNTL; | ||
730 | uint32_t vDLL_CNTL; | ||
731 | uint32_t vMPLL_SS; | ||
732 | uint32_t vMPLL_SS2; | ||
733 | uint32_t mclk_value; | ||
734 | }; | ||
735 | |||
736 | typedef struct NISLANDS_SMC_MCLK_VALUE NISLANDS_SMC_MCLK_VALUE; | ||
737 | |||
738 | struct NISLANDS_SMC_VOLTAGE_VALUE | ||
739 | { | ||
740 | uint16_t value; | ||
741 | uint8_t index; | ||
742 | uint8_t padding; | ||
743 | }; | ||
744 | |||
745 | typedef struct NISLANDS_SMC_VOLTAGE_VALUE NISLANDS_SMC_VOLTAGE_VALUE; | ||
746 | |||
747 | struct NISLANDS_SMC_HW_PERFORMANCE_LEVEL | ||
748 | { | ||
749 | uint8_t arbValue; | ||
750 | uint8_t ACIndex; | ||
751 | uint8_t displayWatermark; | ||
752 | uint8_t gen2PCIE; | ||
753 | uint8_t reserved1; | ||
754 | uint8_t reserved2; | ||
755 | uint8_t strobeMode; | ||
756 | uint8_t mcFlags; | ||
757 | uint32_t aT; | ||
758 | uint32_t bSP; | ||
759 | NISLANDS_SMC_SCLK_VALUE sclk; | ||
760 | NISLANDS_SMC_MCLK_VALUE mclk; | ||
761 | NISLANDS_SMC_VOLTAGE_VALUE vddc; | ||
762 | NISLANDS_SMC_VOLTAGE_VALUE mvdd; | ||
763 | NISLANDS_SMC_VOLTAGE_VALUE vddci; | ||
764 | NISLANDS_SMC_VOLTAGE_VALUE std_vddc; | ||
765 | uint32_t powergate_en; | ||
766 | uint8_t hUp; | ||
767 | uint8_t hDown; | ||
768 | uint8_t stateFlags; | ||
769 | uint8_t arbRefreshState; | ||
770 | uint32_t SQPowerThrottle; | ||
771 | uint32_t SQPowerThrottle_2; | ||
772 | uint32_t reserved[2]; | ||
773 | PP_NIslands_Dpm2PerfLevel dpm2; | ||
774 | }; | ||
775 | |||
776 | typedef struct NISLANDS_SMC_HW_PERFORMANCE_LEVEL NISLANDS_SMC_HW_PERFORMANCE_LEVEL; | ||
777 | |||
778 | struct NISLANDS_SMC_SWSTATE | ||
779 | { | ||
780 | uint8_t flags; | ||
781 | uint8_t levelCount; | ||
782 | uint8_t padding2; | ||
783 | uint8_t padding3; | ||
784 | NISLANDS_SMC_HW_PERFORMANCE_LEVEL levels[1]; | ||
785 | }; | ||
786 | |||
787 | typedef struct NISLANDS_SMC_SWSTATE NISLANDS_SMC_SWSTATE; | ||
788 | |||
789 | struct NISLANDS_SMC_VOLTAGEMASKTABLE | ||
790 | { | ||
791 | uint8_t highMask[NISLANDS_SMC_VOLTAGEMASK_MAX]; | ||
792 | uint32_t lowMask[NISLANDS_SMC_VOLTAGEMASK_MAX]; | ||
793 | }; | ||
794 | |||
795 | typedef struct NISLANDS_SMC_VOLTAGEMASKTABLE NISLANDS_SMC_VOLTAGEMASKTABLE; | ||
796 | |||
797 | #define NISLANDS_MAX_NO_VREG_STEPS 32 | ||
798 | |||
799 | struct NISLANDS_SMC_STATETABLE | ||
800 | { | ||
801 | uint8_t thermalProtectType; | ||
802 | uint8_t systemFlags; | ||
803 | uint8_t maxVDDCIndexInPPTable; | ||
804 | uint8_t extraFlags; | ||
805 | uint8_t highSMIO[NISLANDS_MAX_NO_VREG_STEPS]; | ||
806 | uint32_t lowSMIO[NISLANDS_MAX_NO_VREG_STEPS]; | ||
807 | NISLANDS_SMC_VOLTAGEMASKTABLE voltageMaskTable; | ||
808 | PP_NIslands_DPM2Parameters dpm2Params; | ||
809 | NISLANDS_SMC_SWSTATE initialState; | ||
810 | NISLANDS_SMC_SWSTATE ACPIState; | ||
811 | NISLANDS_SMC_SWSTATE ULVState; | ||
812 | NISLANDS_SMC_SWSTATE driverState; | ||
813 | NISLANDS_SMC_HW_PERFORMANCE_LEVEL dpmLevels[NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1]; | ||
814 | }; | ||
815 | |||
816 | typedef struct NISLANDS_SMC_STATETABLE NISLANDS_SMC_STATETABLE; | ||
817 | |||
818 | struct ni_power_info { | ||
819 | /* must be first! */ | ||
820 | struct evergreen_power_info eg; | ||
821 | struct ni_clock_registers clock_registers; | ||
822 | struct ni_mc_reg_table mc_reg_table; | ||
823 | u32 mclk_rtt_mode_threshold; | ||
824 | /* flags */ | ||
825 | bool use_power_boost_limit; | ||
826 | bool support_cac_long_term_average; | ||
827 | bool cac_enabled; | ||
828 | bool cac_configuration_required; | ||
829 | bool driver_calculate_cac_leakage; | ||
830 | bool pc_enabled; | ||
831 | bool enable_power_containment; | ||
832 | bool enable_cac; | ||
833 | bool enable_sq_ramping; | ||
834 | /* smc offsets */ | ||
835 | u16 arb_table_start; | ||
836 | u16 fan_table_start; | ||
837 | u16 cac_table_start; | ||
838 | u16 spll_table_start; | ||
839 | /* CAC stuff */ | ||
840 | struct ni_cac_data cac_data; | ||
841 | u32 dc_cac_table[NISLANDS_DCCAC_MAX_LEVELS]; | ||
842 | const struct ni_cac_weights *cac_weights; | ||
843 | u8 lta_window_size; | ||
844 | u8 lts_truncate; | ||
845 | struct si_ps current_ps; | ||
846 | struct si_ps requested_ps; | ||
847 | /* scratch structs */ | ||
848 | SMC_NIslands_MCRegisters smc_mc_reg_table; | ||
849 | NISLANDS_SMC_STATETABLE smc_statetable; | ||
850 | }; | ||
851 | |||
852 | struct si_cac_config_reg | ||
853 | { | ||
854 | u32 offset; | ||
855 | u32 mask; | ||
856 | u32 shift; | ||
857 | u32 value; | ||
858 | enum si_cac_config_reg_type type; | ||
859 | }; | ||
860 | |||
861 | struct si_powertune_data | ||
862 | { | ||
863 | u32 cac_window; | ||
864 | u32 l2_lta_window_size_default; | ||
865 | u8 lts_truncate_default; | ||
866 | u8 shift_n_default; | ||
867 | u8 operating_temp; | ||
868 | struct ni_leakage_coeffients leakage_coefficients; | ||
869 | u32 fixed_kt; | ||
870 | u32 lkge_lut_v0_percent; | ||
871 | u8 dc_cac[NISLANDS_DCCAC_MAX_LEVELS]; | ||
872 | bool enable_powertune_by_default; | ||
873 | }; | ||
874 | |||
875 | struct si_dyn_powertune_data | ||
876 | { | ||
877 | u32 cac_leakage; | ||
878 | s32 leakage_minimum_temperature; | ||
879 | u32 wintime; | ||
880 | u32 l2_lta_window_size; | ||
881 | u8 lts_truncate; | ||
882 | u8 shift_n; | ||
883 | u8 dc_pwr_value; | ||
884 | bool disable_uvd_powertune; | ||
885 | }; | ||
886 | |||
887 | struct si_dte_data | ||
888 | { | ||
889 | u32 tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; | ||
890 | u32 r[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; | ||
891 | u32 k; | ||
892 | u32 t0; | ||
893 | u32 max_t; | ||
894 | u8 window_size; | ||
895 | u8 temp_select; | ||
896 | u8 dte_mode; | ||
897 | u8 tdep_count; | ||
898 | u8 t_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; | ||
899 | u32 tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; | ||
900 | u32 tdep_r[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; | ||
901 | u32 t_threshold; | ||
902 | bool enable_dte_by_default; | ||
903 | }; | ||
904 | |||
905 | struct si_clock_registers { | ||
906 | u32 cg_spll_func_cntl; | ||
907 | u32 cg_spll_func_cntl_2; | ||
908 | u32 cg_spll_func_cntl_3; | ||
909 | u32 cg_spll_func_cntl_4; | ||
910 | u32 cg_spll_spread_spectrum; | ||
911 | u32 cg_spll_spread_spectrum_2; | ||
912 | u32 dll_cntl; | ||
913 | u32 mclk_pwrmgt_cntl; | ||
914 | u32 mpll_ad_func_cntl; | ||
915 | u32 mpll_dq_func_cntl; | ||
916 | u32 mpll_func_cntl; | ||
917 | u32 mpll_func_cntl_1; | ||
918 | u32 mpll_func_cntl_2; | ||
919 | u32 mpll_ss1; | ||
920 | u32 mpll_ss2; | ||
921 | }; | ||
922 | |||
923 | struct si_mc_reg_entry { | ||
924 | u32 mclk_max; | ||
925 | u32 mc_data[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
926 | }; | ||
927 | |||
928 | struct si_mc_reg_table { | ||
929 | u8 last; | ||
930 | u8 num_entries; | ||
931 | u16 valid_flag; | ||
932 | struct si_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; | ||
933 | SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
934 | }; | ||
935 | |||
936 | struct si_leakage_voltage_entry | ||
937 | { | ||
938 | u16 voltage; | ||
939 | u16 leakage_index; | ||
940 | }; | ||
941 | |||
942 | struct si_leakage_voltage | ||
943 | { | ||
944 | u16 count; | ||
945 | struct si_leakage_voltage_entry entries[SISLANDS_MAX_LEAKAGE_COUNT]; | ||
946 | }; | ||
947 | |||
948 | |||
949 | struct si_ulv_param { | ||
950 | bool supported; | ||
951 | u32 cg_ulv_control; | ||
952 | u32 cg_ulv_parameter; | ||
953 | u32 volt_change_delay; | ||
954 | struct rv7xx_pl pl; | ||
955 | bool one_pcie_lane_in_ulv; | ||
956 | }; | ||
957 | |||
958 | struct si_power_info { | ||
959 | /* must be first! */ | ||
960 | struct ni_power_info ni; | ||
961 | struct si_clock_registers clock_registers; | ||
962 | struct si_mc_reg_table mc_reg_table; | ||
963 | struct atom_voltage_table mvdd_voltage_table; | ||
964 | struct atom_voltage_table vddc_phase_shed_table; | ||
965 | struct si_leakage_voltage leakage_voltage; | ||
966 | u16 mvdd_bootup_value; | ||
967 | struct si_ulv_param ulv; | ||
968 | u32 max_cu; | ||
969 | /* pcie gen */ | ||
970 | enum amdgpu_pcie_gen force_pcie_gen; | ||
971 | enum amdgpu_pcie_gen boot_pcie_gen; | ||
972 | enum amdgpu_pcie_gen acpi_pcie_gen; | ||
973 | u32 sys_pcie_mask; | ||
974 | /* flags */ | ||
975 | bool enable_dte; | ||
976 | bool enable_ppm; | ||
977 | bool vddc_phase_shed_control; | ||
978 | bool pspp_notify_required; | ||
979 | bool sclk_deep_sleep_above_low; | ||
980 | bool voltage_control_svi2; | ||
981 | bool vddci_control_svi2; | ||
982 | /* smc offsets */ | ||
983 | u32 sram_end; | ||
984 | u32 state_table_start; | ||
985 | u32 soft_regs_start; | ||
986 | u32 mc_reg_table_start; | ||
987 | u32 arb_table_start; | ||
988 | u32 cac_table_start; | ||
989 | u32 dte_table_start; | ||
990 | u32 spll_table_start; | ||
991 | u32 papm_cfg_table_start; | ||
992 | u32 fan_table_start; | ||
993 | /* CAC stuff */ | ||
994 | const struct si_cac_config_reg *cac_weights; | ||
995 | const struct si_cac_config_reg *lcac_config; | ||
996 | const struct si_cac_config_reg *cac_override; | ||
997 | const struct si_powertune_data *powertune_data; | ||
998 | struct si_dyn_powertune_data dyn_powertune_data; | ||
999 | /* DTE stuff */ | ||
1000 | struct si_dte_data dte_data; | ||
1001 | /* scratch structs */ | ||
1002 | SMC_SIslands_MCRegisters smc_mc_reg_table; | ||
1003 | SISLANDS_SMC_STATETABLE smc_statetable; | ||
1004 | PP_SIslands_PAPMParameters papm_parm; | ||
1005 | /* SVI2 */ | ||
1006 | u8 svd_gpio_id; | ||
1007 | u8 svc_gpio_id; | ||
1008 | /* fan control */ | ||
1009 | bool fan_ctrl_is_in_default_mode; | ||
1010 | u32 t_min; | ||
1011 | u32 fan_ctrl_default_mode; | ||
1012 | bool fan_is_controlled_by_smc; | ||
1013 | }; | ||
1014 | |||
1015 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c b/drivers/gpu/drm/amd/amdgpu/si_ih.c new file mode 100644 index 000000000000..8fae3d4a2360 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #include "drmP.h" | ||
24 | #include "amdgpu.h" | ||
25 | #include "amdgpu_ih.h" | ||
26 | #include "si/sid.h" | ||
27 | #include "si_ih.h" | ||
28 | |||
29 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev); | ||
30 | |||
31 | static void si_ih_enable_interrupts(struct amdgpu_device *adev) | ||
32 | { | ||
33 | u32 ih_cntl = RREG32(IH_CNTL); | ||
34 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); | ||
35 | |||
36 | ih_cntl |= ENABLE_INTR; | ||
37 | ih_rb_cntl |= IH_RB_ENABLE; | ||
38 | WREG32(IH_CNTL, ih_cntl); | ||
39 | WREG32(IH_RB_CNTL, ih_rb_cntl); | ||
40 | adev->irq.ih.enabled = true; | ||
41 | } | ||
42 | |||
43 | static void si_ih_disable_interrupts(struct amdgpu_device *adev) | ||
44 | { | ||
45 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); | ||
46 | u32 ih_cntl = RREG32(IH_CNTL); | ||
47 | |||
48 | ih_rb_cntl &= ~IH_RB_ENABLE; | ||
49 | ih_cntl &= ~ENABLE_INTR; | ||
50 | WREG32(IH_RB_CNTL, ih_rb_cntl); | ||
51 | WREG32(IH_CNTL, ih_cntl); | ||
52 | WREG32(IH_RB_RPTR, 0); | ||
53 | WREG32(IH_RB_WPTR, 0); | ||
54 | adev->irq.ih.enabled = false; | ||
55 | adev->irq.ih.rptr = 0; | ||
56 | } | ||
57 | |||
58 | static int si_ih_irq_init(struct amdgpu_device *adev) | ||
59 | { | ||
60 | int rb_bufsz; | ||
61 | u32 interrupt_cntl, ih_cntl, ih_rb_cntl; | ||
62 | u64 wptr_off; | ||
63 | |||
64 | si_ih_disable_interrupts(adev); | ||
65 | WREG32(INTERRUPT_CNTL2, adev->irq.ih.gpu_addr >> 8); | ||
66 | interrupt_cntl = RREG32(INTERRUPT_CNTL); | ||
67 | interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE; | ||
68 | interrupt_cntl &= ~IH_REQ_NONSNOOP_EN; | ||
69 | WREG32(INTERRUPT_CNTL, interrupt_cntl); | ||
70 | |||
71 | WREG32(IH_RB_BASE, adev->irq.ih.gpu_addr >> 8); | ||
72 | rb_bufsz = order_base_2(adev->irq.ih.ring_size / 4); | ||
73 | |||
74 | ih_rb_cntl = IH_WPTR_OVERFLOW_ENABLE | | ||
75 | IH_WPTR_OVERFLOW_CLEAR | | ||
76 | (rb_bufsz << 1) | | ||
77 | IH_WPTR_WRITEBACK_ENABLE; | ||
78 | |||
79 | wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4); | ||
80 | WREG32(IH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off)); | ||
81 | WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFF); | ||
82 | WREG32(IH_RB_CNTL, ih_rb_cntl); | ||
83 | WREG32(IH_RB_RPTR, 0); | ||
84 | WREG32(IH_RB_WPTR, 0); | ||
85 | |||
86 | ih_cntl = MC_WRREQ_CREDIT(0x10) | MC_WR_CLEAN_CNT(0x10) | MC_VMID(0); | ||
87 | if (adev->irq.msi_enabled) | ||
88 | ih_cntl |= RPTR_REARM; | ||
89 | WREG32(IH_CNTL, ih_cntl); | ||
90 | |||
91 | pci_set_master(adev->pdev); | ||
92 | si_ih_enable_interrupts(adev); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | static void si_ih_irq_disable(struct amdgpu_device *adev) | ||
98 | { | ||
99 | si_ih_disable_interrupts(adev); | ||
100 | mdelay(1); | ||
101 | } | ||
102 | |||
103 | static u32 si_ih_get_wptr(struct amdgpu_device *adev) | ||
104 | { | ||
105 | u32 wptr, tmp; | ||
106 | |||
107 | wptr = le32_to_cpu(adev->wb.wb[adev->irq.ih.wptr_offs]); | ||
108 | |||
109 | if (wptr & IH_RB_WPTR__RB_OVERFLOW_MASK) { | ||
110 | wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK; | ||
111 | dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", | ||
112 | wptr, adev->irq.ih.rptr, (wptr + 16) & adev->irq.ih.ptr_mask); | ||
113 | adev->irq.ih.rptr = (wptr + 16) & adev->irq.ih.ptr_mask; | ||
114 | tmp = RREG32(IH_RB_CNTL); | ||
115 | tmp |= IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK; | ||
116 | WREG32(IH_RB_CNTL, tmp); | ||
117 | } | ||
118 | return (wptr & adev->irq.ih.ptr_mask); | ||
119 | } | ||
120 | |||
121 | static void si_ih_decode_iv(struct amdgpu_device *adev, | ||
122 | struct amdgpu_iv_entry *entry) | ||
123 | { | ||
124 | u32 ring_index = adev->irq.ih.rptr >> 2; | ||
125 | uint32_t dw[4]; | ||
126 | |||
127 | dw[0] = le32_to_cpu(adev->irq.ih.ring[ring_index + 0]); | ||
128 | dw[1] = le32_to_cpu(adev->irq.ih.ring[ring_index + 1]); | ||
129 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); | ||
130 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); | ||
131 | |||
132 | entry->src_id = dw[0] & 0xff; | ||
133 | entry->src_data = dw[1] & 0xfffffff; | ||
134 | entry->ring_id = dw[2] & 0xff; | ||
135 | entry->vm_id = (dw[2] >> 8) & 0xff; | ||
136 | |||
137 | adev->irq.ih.rptr += 16; | ||
138 | } | ||
139 | |||
140 | static void si_ih_set_rptr(struct amdgpu_device *adev) | ||
141 | { | ||
142 | WREG32(IH_RB_RPTR, adev->irq.ih.rptr); | ||
143 | } | ||
144 | |||
145 | static int si_ih_early_init(void *handle) | ||
146 | { | ||
147 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
148 | |||
149 | si_ih_set_interrupt_funcs(adev); | ||
150 | |||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static int si_ih_sw_init(void *handle) | ||
155 | { | ||
156 | int r; | ||
157 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
158 | |||
159 | r = amdgpu_ih_ring_init(adev, 64 * 1024, false); | ||
160 | if (r) | ||
161 | return r; | ||
162 | |||
163 | return amdgpu_irq_init(adev); | ||
164 | } | ||
165 | |||
166 | static int si_ih_sw_fini(void *handle) | ||
167 | { | ||
168 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
169 | |||
170 | amdgpu_irq_fini(adev); | ||
171 | amdgpu_ih_ring_fini(adev); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int si_ih_hw_init(void *handle) | ||
177 | { | ||
178 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
179 | |||
180 | return si_ih_irq_init(adev); | ||
181 | } | ||
182 | |||
183 | static int si_ih_hw_fini(void *handle) | ||
184 | { | ||
185 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
186 | |||
187 | si_ih_irq_disable(adev); | ||
188 | |||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | static int si_ih_suspend(void *handle) | ||
193 | { | ||
194 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
195 | |||
196 | return si_ih_hw_fini(adev); | ||
197 | } | ||
198 | |||
199 | static int si_ih_resume(void *handle) | ||
200 | { | ||
201 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
202 | |||
203 | return si_ih_hw_init(adev); | ||
204 | } | ||
205 | |||
206 | static bool si_ih_is_idle(void *handle) | ||
207 | { | ||
208 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
209 | u32 tmp = RREG32(SRBM_STATUS); | ||
210 | |||
211 | if (tmp & SRBM_STATUS__IH_BUSY_MASK) | ||
212 | return false; | ||
213 | |||
214 | return true; | ||
215 | } | ||
216 | |||
217 | static int si_ih_wait_for_idle(void *handle) | ||
218 | { | ||
219 | unsigned i; | ||
220 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
221 | |||
222 | for (i = 0; i < adev->usec_timeout; i++) { | ||
223 | if (si_ih_is_idle(handle)) | ||
224 | return 0; | ||
225 | udelay(1); | ||
226 | } | ||
227 | return -ETIMEDOUT; | ||
228 | } | ||
229 | |||
230 | static int si_ih_soft_reset(void *handle) | ||
231 | { | ||
232 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
233 | |||
234 | u32 srbm_soft_reset = 0; | ||
235 | u32 tmp = RREG32(SRBM_STATUS); | ||
236 | |||
237 | if (tmp & SRBM_STATUS__IH_BUSY_MASK) | ||
238 | srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_IH_MASK; | ||
239 | |||
240 | if (srbm_soft_reset) { | ||
241 | tmp = RREG32(SRBM_SOFT_RESET); | ||
242 | tmp |= srbm_soft_reset; | ||
243 | dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp); | ||
244 | WREG32(SRBM_SOFT_RESET, tmp); | ||
245 | tmp = RREG32(SRBM_SOFT_RESET); | ||
246 | |||
247 | udelay(50); | ||
248 | |||
249 | tmp &= ~srbm_soft_reset; | ||
250 | WREG32(SRBM_SOFT_RESET, tmp); | ||
251 | tmp = RREG32(SRBM_SOFT_RESET); | ||
252 | |||
253 | udelay(50); | ||
254 | } | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static int si_ih_set_clockgating_state(void *handle, | ||
260 | enum amd_clockgating_state state) | ||
261 | { | ||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | static int si_ih_set_powergating_state(void *handle, | ||
266 | enum amd_powergating_state state) | ||
267 | { | ||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | const struct amd_ip_funcs si_ih_ip_funcs = { | ||
272 | .name = "si_ih", | ||
273 | .early_init = si_ih_early_init, | ||
274 | .late_init = NULL, | ||
275 | .sw_init = si_ih_sw_init, | ||
276 | .sw_fini = si_ih_sw_fini, | ||
277 | .hw_init = si_ih_hw_init, | ||
278 | .hw_fini = si_ih_hw_fini, | ||
279 | .suspend = si_ih_suspend, | ||
280 | .resume = si_ih_resume, | ||
281 | .is_idle = si_ih_is_idle, | ||
282 | .wait_for_idle = si_ih_wait_for_idle, | ||
283 | .soft_reset = si_ih_soft_reset, | ||
284 | .set_clockgating_state = si_ih_set_clockgating_state, | ||
285 | .set_powergating_state = si_ih_set_powergating_state, | ||
286 | }; | ||
287 | |||
288 | static const struct amdgpu_ih_funcs si_ih_funcs = { | ||
289 | .get_wptr = si_ih_get_wptr, | ||
290 | .decode_iv = si_ih_decode_iv, | ||
291 | .set_rptr = si_ih_set_rptr | ||
292 | }; | ||
293 | |||
294 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev) | ||
295 | { | ||
296 | if (adev->irq.ih_funcs == NULL) | ||
297 | adev->irq.ih_funcs = &si_ih_funcs; | ||
298 | } | ||
299 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.h b/drivers/gpu/drm/amd/amdgpu/si_ih.h new file mode 100644 index 000000000000..f3e3a954369c --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_ih.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __SI_IH_H__ | ||
25 | #define __SI_IH_H__ | ||
26 | |||
27 | extern const struct amd_ip_funcs si_ih_ip_funcs; | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_smc.c b/drivers/gpu/drm/amd/amdgpu/si_smc.c new file mode 100644 index 000000000000..668ba99d6c05 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/si_smc.c | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Alex Deucher | ||
23 | */ | ||
24 | |||
25 | #include <linux/firmware.h> | ||
26 | #include "drmP.h" | ||
27 | #include "amdgpu.h" | ||
28 | #include "si/sid.h" | ||
29 | #include "ppsmc.h" | ||
30 | #include "amdgpu_ucode.h" | ||
31 | #include "sislands_smc.h" | ||
32 | |||
33 | static int si_set_smc_sram_address(struct amdgpu_device *adev, | ||
34 | u32 smc_address, u32 limit) | ||
35 | { | ||
36 | if (smc_address & 3) | ||
37 | return -EINVAL; | ||
38 | if ((smc_address + 3) > limit) | ||
39 | return -EINVAL; | ||
40 | |||
41 | WREG32(SMC_IND_INDEX_0, smc_address); | ||
42 | WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); | ||
43 | |||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | int amdgpu_si_copy_bytes_to_smc(struct amdgpu_device *adev, | ||
48 | u32 smc_start_address, | ||
49 | const u8 *src, u32 byte_count, u32 limit) | ||
50 | { | ||
51 | unsigned long flags; | ||
52 | int ret = 0; | ||
53 | u32 data, original_data, addr, extra_shift; | ||
54 | |||
55 | if (smc_start_address & 3) | ||
56 | return -EINVAL; | ||
57 | if ((smc_start_address + byte_count) > limit) | ||
58 | return -EINVAL; | ||
59 | |||
60 | addr = smc_start_address; | ||
61 | |||
62 | spin_lock_irqsave(&adev->smc_idx_lock, flags); | ||
63 | while (byte_count >= 4) { | ||
64 | /* SMC address space is BE */ | ||
65 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; | ||
66 | |||
67 | ret = si_set_smc_sram_address(adev, addr, limit); | ||
68 | if (ret) | ||
69 | goto done; | ||
70 | |||
71 | WREG32(SMC_IND_DATA_0, data); | ||
72 | |||
73 | src += 4; | ||
74 | byte_count -= 4; | ||
75 | addr += 4; | ||
76 | } | ||
77 | |||
78 | /* RMW for the final bytes */ | ||
79 | if (byte_count > 0) { | ||
80 | data = 0; | ||
81 | |||
82 | ret = si_set_smc_sram_address(adev, addr, limit); | ||
83 | if (ret) | ||
84 | goto done; | ||
85 | |||
86 | original_data = RREG32(SMC_IND_DATA_0); | ||
87 | extra_shift = 8 * (4 - byte_count); | ||
88 | |||
89 | while (byte_count > 0) { | ||
90 | /* SMC address space is BE */ | ||
91 | data = (data << 8) + *src++; | ||
92 | byte_count--; | ||
93 | } | ||
94 | |||
95 | data <<= extra_shift; | ||
96 | data |= (original_data & ~((~0UL) << extra_shift)); | ||
97 | |||
98 | ret = si_set_smc_sram_address(adev, addr, limit); | ||
99 | if (ret) | ||
100 | goto done; | ||
101 | |||
102 | WREG32(SMC_IND_DATA_0, data); | ||
103 | } | ||
104 | |||
105 | done: | ||
106 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | ||
107 | |||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | void amdgpu_si_start_smc(struct amdgpu_device *adev) | ||
112 | { | ||
113 | u32 tmp = RREG32_SMC(SMC_SYSCON_RESET_CNTL); | ||
114 | |||
115 | tmp &= ~RST_REG; | ||
116 | |||
117 | WREG32_SMC(SMC_SYSCON_RESET_CNTL, tmp); | ||
118 | } | ||
119 | |||
120 | void amdgpu_si_reset_smc(struct amdgpu_device *adev) | ||
121 | { | ||
122 | u32 tmp; | ||
123 | |||
124 | RREG32(CB_CGTT_SCLK_CTRL); | ||
125 | RREG32(CB_CGTT_SCLK_CTRL); | ||
126 | RREG32(CB_CGTT_SCLK_CTRL); | ||
127 | RREG32(CB_CGTT_SCLK_CTRL); | ||
128 | |||
129 | tmp = RREG32_SMC(SMC_SYSCON_RESET_CNTL) | | ||
130 | RST_REG; | ||
131 | WREG32_SMC(SMC_SYSCON_RESET_CNTL, tmp); | ||
132 | } | ||
133 | |||
134 | int amdgpu_si_program_jump_on_start(struct amdgpu_device *adev) | ||
135 | { | ||
136 | static const u8 data[] = { 0x0E, 0x00, 0x40, 0x40 }; | ||
137 | |||
138 | return amdgpu_si_copy_bytes_to_smc(adev, 0x0, data, 4, sizeof(data)+1); | ||
139 | } | ||
140 | |||
141 | void amdgpu_si_smc_clock(struct amdgpu_device *adev, bool enable) | ||
142 | { | ||
143 | u32 tmp = RREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0); | ||
144 | |||
145 | if (enable) | ||
146 | tmp &= ~CK_DISABLE; | ||
147 | else | ||
148 | tmp |= CK_DISABLE; | ||
149 | |||
150 | WREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0, tmp); | ||
151 | } | ||
152 | |||
153 | bool amdgpu_si_is_smc_running(struct amdgpu_device *adev) | ||
154 | { | ||
155 | u32 rst = RREG32_SMC(SMC_SYSCON_RESET_CNTL); | ||
156 | u32 clk = RREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0); | ||
157 | |||
158 | if (!(rst & RST_REG) && !(clk & CK_DISABLE)) | ||
159 | return true; | ||
160 | |||
161 | return false; | ||
162 | } | ||
163 | |||
164 | PPSMC_Result amdgpu_si_send_msg_to_smc(struct amdgpu_device *adev, | ||
165 | PPSMC_Msg msg) | ||
166 | { | ||
167 | u32 tmp; | ||
168 | int i; | ||
169 | |||
170 | if (!amdgpu_si_is_smc_running(adev)) | ||
171 | return PPSMC_Result_Failed; | ||
172 | |||
173 | WREG32(SMC_MESSAGE_0, msg); | ||
174 | |||
175 | for (i = 0; i < adev->usec_timeout; i++) { | ||
176 | tmp = RREG32(SMC_RESP_0); | ||
177 | if (tmp != 0) | ||
178 | break; | ||
179 | udelay(1); | ||
180 | } | ||
181 | |||
182 | return (PPSMC_Result)RREG32(SMC_RESP_0); | ||
183 | } | ||
184 | |||
185 | PPSMC_Result amdgpu_si_wait_for_smc_inactive(struct amdgpu_device *adev) | ||
186 | { | ||
187 | u32 tmp; | ||
188 | int i; | ||
189 | |||
190 | if (!amdgpu_si_is_smc_running(adev)) | ||
191 | return PPSMC_Result_OK; | ||
192 | |||
193 | for (i = 0; i < adev->usec_timeout; i++) { | ||
194 | tmp = RREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0); | ||
195 | if ((tmp & CKEN) == 0) | ||
196 | break; | ||
197 | udelay(1); | ||
198 | } | ||
199 | |||
200 | return PPSMC_Result_OK; | ||
201 | } | ||
202 | |||
203 | int amdgpu_si_load_smc_ucode(struct amdgpu_device *adev, u32 limit) | ||
204 | { | ||
205 | const struct smc_firmware_header_v1_0 *hdr; | ||
206 | unsigned long flags; | ||
207 | u32 ucode_start_address; | ||
208 | u32 ucode_size; | ||
209 | const u8 *src; | ||
210 | u32 data; | ||
211 | |||
212 | if (!adev->pm.fw) | ||
213 | return -EINVAL; | ||
214 | |||
215 | hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; | ||
216 | |||
217 | amdgpu_ucode_print_smc_hdr(&hdr->header); | ||
218 | |||
219 | adev->pm.fw_version = le32_to_cpu(hdr->header.ucode_version); | ||
220 | ucode_start_address = le32_to_cpu(hdr->ucode_start_addr); | ||
221 | ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes); | ||
222 | src = (const u8 *) | ||
223 | (adev->pm.fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
224 | if (ucode_size & 3) | ||
225 | return -EINVAL; | ||
226 | |||
227 | spin_lock_irqsave(&adev->smc_idx_lock, flags); | ||
228 | WREG32(SMC_IND_INDEX_0, ucode_start_address); | ||
229 | WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); | ||
230 | while (ucode_size >= 4) { | ||
231 | /* SMC address space is BE */ | ||
232 | data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; | ||
233 | |||
234 | WREG32(SMC_IND_DATA_0, data); | ||
235 | |||
236 | src += 4; | ||
237 | ucode_size -= 4; | ||
238 | } | ||
239 | WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); | ||
240 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | int amdgpu_si_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | ||
246 | u32 *value, u32 limit) | ||
247 | { | ||
248 | unsigned long flags; | ||
249 | int ret; | ||
250 | |||
251 | spin_lock_irqsave(&adev->smc_idx_lock, flags); | ||
252 | ret = si_set_smc_sram_address(adev, smc_address, limit); | ||
253 | if (ret == 0) | ||
254 | *value = RREG32(SMC_IND_DATA_0); | ||
255 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | ||
256 | |||
257 | return ret; | ||
258 | } | ||
259 | |||
260 | int amdgpu_si_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | ||
261 | u32 value, u32 limit) | ||
262 | { | ||
263 | unsigned long flags; | ||
264 | int ret; | ||
265 | |||
266 | spin_lock_irqsave(&adev->smc_idx_lock, flags); | ||
267 | ret = si_set_smc_sram_address(adev, smc_address, limit); | ||
268 | if (ret == 0) | ||
269 | WREG32(SMC_IND_DATA_0, value); | ||
270 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); | ||
271 | |||
272 | return ret; | ||
273 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sislands_smc.h b/drivers/gpu/drm/amd/amdgpu/sislands_smc.h new file mode 100644 index 000000000000..ee4b846e58fa --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/sislands_smc.h | |||
@@ -0,0 +1,422 @@ | |||
1 | /* | ||
2 | * Copyright 2013 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #ifndef PP_SISLANDS_SMC_H | ||
24 | #define PP_SISLANDS_SMC_H | ||
25 | |||
26 | #include "ppsmc.h" | ||
27 | |||
28 | #pragma pack(push, 1) | ||
29 | |||
30 | #define SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16 | ||
31 | |||
32 | struct PP_SIslands_Dpm2PerfLevel | ||
33 | { | ||
34 | uint8_t MaxPS; | ||
35 | uint8_t TgtAct; | ||
36 | uint8_t MaxPS_StepInc; | ||
37 | uint8_t MaxPS_StepDec; | ||
38 | uint8_t PSSamplingTime; | ||
39 | uint8_t NearTDPDec; | ||
40 | uint8_t AboveSafeInc; | ||
41 | uint8_t BelowSafeInc; | ||
42 | uint8_t PSDeltaLimit; | ||
43 | uint8_t PSDeltaWin; | ||
44 | uint16_t PwrEfficiencyRatio; | ||
45 | uint8_t Reserved[4]; | ||
46 | }; | ||
47 | |||
48 | typedef struct PP_SIslands_Dpm2PerfLevel PP_SIslands_Dpm2PerfLevel; | ||
49 | |||
50 | struct PP_SIslands_DPM2Status | ||
51 | { | ||
52 | uint32_t dpm2Flags; | ||
53 | uint8_t CurrPSkip; | ||
54 | uint8_t CurrPSkipPowerShift; | ||
55 | uint8_t CurrPSkipTDP; | ||
56 | uint8_t CurrPSkipOCP; | ||
57 | uint8_t MaxSPLLIndex; | ||
58 | uint8_t MinSPLLIndex; | ||
59 | uint8_t CurrSPLLIndex; | ||
60 | uint8_t InfSweepMode; | ||
61 | uint8_t InfSweepDir; | ||
62 | uint8_t TDPexceeded; | ||
63 | uint8_t reserved; | ||
64 | uint8_t SwitchDownThreshold; | ||
65 | uint32_t SwitchDownCounter; | ||
66 | uint32_t SysScalingFactor; | ||
67 | }; | ||
68 | |||
69 | typedef struct PP_SIslands_DPM2Status PP_SIslands_DPM2Status; | ||
70 | |||
71 | struct PP_SIslands_DPM2Parameters | ||
72 | { | ||
73 | uint32_t TDPLimit; | ||
74 | uint32_t NearTDPLimit; | ||
75 | uint32_t SafePowerLimit; | ||
76 | uint32_t PowerBoostLimit; | ||
77 | uint32_t MinLimitDelta; | ||
78 | }; | ||
79 | typedef struct PP_SIslands_DPM2Parameters PP_SIslands_DPM2Parameters; | ||
80 | |||
81 | struct PP_SIslands_PAPMStatus | ||
82 | { | ||
83 | uint32_t EstimatedDGPU_T; | ||
84 | uint32_t EstimatedDGPU_P; | ||
85 | uint32_t EstimatedAPU_T; | ||
86 | uint32_t EstimatedAPU_P; | ||
87 | uint8_t dGPU_T_Limit_Exceeded; | ||
88 | uint8_t reserved[3]; | ||
89 | }; | ||
90 | typedef struct PP_SIslands_PAPMStatus PP_SIslands_PAPMStatus; | ||
91 | |||
92 | struct PP_SIslands_PAPMParameters | ||
93 | { | ||
94 | uint32_t NearTDPLimitTherm; | ||
95 | uint32_t NearTDPLimitPAPM; | ||
96 | uint32_t PlatformPowerLimit; | ||
97 | uint32_t dGPU_T_Limit; | ||
98 | uint32_t dGPU_T_Warning; | ||
99 | uint32_t dGPU_T_Hysteresis; | ||
100 | }; | ||
101 | typedef struct PP_SIslands_PAPMParameters PP_SIslands_PAPMParameters; | ||
102 | |||
103 | struct SISLANDS_SMC_SCLK_VALUE | ||
104 | { | ||
105 | uint32_t vCG_SPLL_FUNC_CNTL; | ||
106 | uint32_t vCG_SPLL_FUNC_CNTL_2; | ||
107 | uint32_t vCG_SPLL_FUNC_CNTL_3; | ||
108 | uint32_t vCG_SPLL_FUNC_CNTL_4; | ||
109 | uint32_t vCG_SPLL_SPREAD_SPECTRUM; | ||
110 | uint32_t vCG_SPLL_SPREAD_SPECTRUM_2; | ||
111 | uint32_t sclk_value; | ||
112 | }; | ||
113 | |||
114 | typedef struct SISLANDS_SMC_SCLK_VALUE SISLANDS_SMC_SCLK_VALUE; | ||
115 | |||
116 | struct SISLANDS_SMC_MCLK_VALUE | ||
117 | { | ||
118 | uint32_t vMPLL_FUNC_CNTL; | ||
119 | uint32_t vMPLL_FUNC_CNTL_1; | ||
120 | uint32_t vMPLL_FUNC_CNTL_2; | ||
121 | uint32_t vMPLL_AD_FUNC_CNTL; | ||
122 | uint32_t vMPLL_DQ_FUNC_CNTL; | ||
123 | uint32_t vMCLK_PWRMGT_CNTL; | ||
124 | uint32_t vDLL_CNTL; | ||
125 | uint32_t vMPLL_SS; | ||
126 | uint32_t vMPLL_SS2; | ||
127 | uint32_t mclk_value; | ||
128 | }; | ||
129 | |||
130 | typedef struct SISLANDS_SMC_MCLK_VALUE SISLANDS_SMC_MCLK_VALUE; | ||
131 | |||
132 | struct SISLANDS_SMC_VOLTAGE_VALUE | ||
133 | { | ||
134 | uint16_t value; | ||
135 | uint8_t index; | ||
136 | uint8_t phase_settings; | ||
137 | }; | ||
138 | |||
139 | typedef struct SISLANDS_SMC_VOLTAGE_VALUE SISLANDS_SMC_VOLTAGE_VALUE; | ||
140 | |||
141 | struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL | ||
142 | { | ||
143 | uint8_t ACIndex; | ||
144 | uint8_t displayWatermark; | ||
145 | uint8_t gen2PCIE; | ||
146 | uint8_t UVDWatermark; | ||
147 | uint8_t VCEWatermark; | ||
148 | uint8_t strobeMode; | ||
149 | uint8_t mcFlags; | ||
150 | uint8_t padding; | ||
151 | uint32_t aT; | ||
152 | uint32_t bSP; | ||
153 | SISLANDS_SMC_SCLK_VALUE sclk; | ||
154 | SISLANDS_SMC_MCLK_VALUE mclk; | ||
155 | SISLANDS_SMC_VOLTAGE_VALUE vddc; | ||
156 | SISLANDS_SMC_VOLTAGE_VALUE mvdd; | ||
157 | SISLANDS_SMC_VOLTAGE_VALUE vddci; | ||
158 | SISLANDS_SMC_VOLTAGE_VALUE std_vddc; | ||
159 | uint8_t hysteresisUp; | ||
160 | uint8_t hysteresisDown; | ||
161 | uint8_t stateFlags; | ||
162 | uint8_t arbRefreshState; | ||
163 | uint32_t SQPowerThrottle; | ||
164 | uint32_t SQPowerThrottle_2; | ||
165 | uint32_t MaxPoweredUpCU; | ||
166 | SISLANDS_SMC_VOLTAGE_VALUE high_temp_vddc; | ||
167 | SISLANDS_SMC_VOLTAGE_VALUE low_temp_vddc; | ||
168 | uint32_t reserved[2]; | ||
169 | PP_SIslands_Dpm2PerfLevel dpm2; | ||
170 | }; | ||
171 | |||
172 | #define SISLANDS_SMC_STROBE_RATIO 0x0F | ||
173 | #define SISLANDS_SMC_STROBE_ENABLE 0x10 | ||
174 | |||
175 | #define SISLANDS_SMC_MC_EDC_RD_FLAG 0x01 | ||
176 | #define SISLANDS_SMC_MC_EDC_WR_FLAG 0x02 | ||
177 | #define SISLANDS_SMC_MC_RTT_ENABLE 0x04 | ||
178 | #define SISLANDS_SMC_MC_STUTTER_EN 0x08 | ||
179 | #define SISLANDS_SMC_MC_PG_EN 0x10 | ||
180 | |||
181 | typedef struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL SISLANDS_SMC_HW_PERFORMANCE_LEVEL; | ||
182 | |||
183 | struct SISLANDS_SMC_SWSTATE | ||
184 | { | ||
185 | uint8_t flags; | ||
186 | uint8_t levelCount; | ||
187 | uint8_t padding2; | ||
188 | uint8_t padding3; | ||
189 | SISLANDS_SMC_HW_PERFORMANCE_LEVEL levels[1]; | ||
190 | }; | ||
191 | |||
192 | typedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE; | ||
193 | |||
194 | #define SISLANDS_SMC_VOLTAGEMASK_VDDC 0 | ||
195 | #define SISLANDS_SMC_VOLTAGEMASK_MVDD 1 | ||
196 | #define SISLANDS_SMC_VOLTAGEMASK_VDDCI 2 | ||
197 | #define SISLANDS_SMC_VOLTAGEMASK_MAX 4 | ||
198 | |||
199 | struct SISLANDS_SMC_VOLTAGEMASKTABLE | ||
200 | { | ||
201 | uint32_t lowMask[SISLANDS_SMC_VOLTAGEMASK_MAX]; | ||
202 | }; | ||
203 | |||
204 | typedef struct SISLANDS_SMC_VOLTAGEMASKTABLE SISLANDS_SMC_VOLTAGEMASKTABLE; | ||
205 | |||
206 | #define SISLANDS_MAX_NO_VREG_STEPS 32 | ||
207 | |||
208 | struct SISLANDS_SMC_STATETABLE | ||
209 | { | ||
210 | uint8_t thermalProtectType; | ||
211 | uint8_t systemFlags; | ||
212 | uint8_t maxVDDCIndexInPPTable; | ||
213 | uint8_t extraFlags; | ||
214 | uint32_t lowSMIO[SISLANDS_MAX_NO_VREG_STEPS]; | ||
215 | SISLANDS_SMC_VOLTAGEMASKTABLE voltageMaskTable; | ||
216 | SISLANDS_SMC_VOLTAGEMASKTABLE phaseMaskTable; | ||
217 | PP_SIslands_DPM2Parameters dpm2Params; | ||
218 | SISLANDS_SMC_SWSTATE initialState; | ||
219 | SISLANDS_SMC_SWSTATE ACPIState; | ||
220 | SISLANDS_SMC_SWSTATE ULVState; | ||
221 | SISLANDS_SMC_SWSTATE driverState; | ||
222 | SISLANDS_SMC_HW_PERFORMANCE_LEVEL dpmLevels[SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1]; | ||
223 | }; | ||
224 | |||
225 | typedef struct SISLANDS_SMC_STATETABLE SISLANDS_SMC_STATETABLE; | ||
226 | |||
227 | #define SI_SMC_SOFT_REGISTER_mclk_chg_timeout 0x0 | ||
228 | #define SI_SMC_SOFT_REGISTER_delay_vreg 0xC | ||
229 | #define SI_SMC_SOFT_REGISTER_delay_acpi 0x28 | ||
230 | #define SI_SMC_SOFT_REGISTER_seq_index 0x5C | ||
231 | #define SI_SMC_SOFT_REGISTER_mvdd_chg_time 0x60 | ||
232 | #define SI_SMC_SOFT_REGISTER_mclk_switch_lim 0x70 | ||
233 | #define SI_SMC_SOFT_REGISTER_watermark_threshold 0x78 | ||
234 | #define SI_SMC_SOFT_REGISTER_phase_shedding_delay 0x88 | ||
235 | #define SI_SMC_SOFT_REGISTER_ulv_volt_change_delay 0x8C | ||
236 | #define SI_SMC_SOFT_REGISTER_mc_block_delay 0x98 | ||
237 | #define SI_SMC_SOFT_REGISTER_ticks_per_us 0xA8 | ||
238 | #define SI_SMC_SOFT_REGISTER_crtc_index 0xC4 | ||
239 | #define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min 0xC8 | ||
240 | #define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max 0xCC | ||
241 | #define SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width 0xF4 | ||
242 | #define SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen 0xFC | ||
243 | #define SI_SMC_SOFT_REGISTER_vr_hot_gpio 0x100 | ||
244 | #define SI_SMC_SOFT_REGISTER_svi_rework_plat_type 0x118 | ||
245 | #define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd 0x11c | ||
246 | #define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc 0x120 | ||
247 | |||
248 | struct PP_SIslands_FanTable | ||
249 | { | ||
250 | uint8_t fdo_mode; | ||
251 | uint8_t padding; | ||
252 | int16_t temp_min; | ||
253 | int16_t temp_med; | ||
254 | int16_t temp_max; | ||
255 | int16_t slope1; | ||
256 | int16_t slope2; | ||
257 | int16_t fdo_min; | ||
258 | int16_t hys_up; | ||
259 | int16_t hys_down; | ||
260 | int16_t hys_slope; | ||
261 | int16_t temp_resp_lim; | ||
262 | int16_t temp_curr; | ||
263 | int16_t slope_curr; | ||
264 | int16_t pwm_curr; | ||
265 | uint32_t refresh_period; | ||
266 | int16_t fdo_max; | ||
267 | uint8_t temp_src; | ||
268 | int8_t padding2; | ||
269 | }; | ||
270 | |||
271 | typedef struct PP_SIslands_FanTable PP_SIslands_FanTable; | ||
272 | |||
273 | #define SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16 | ||
274 | #define SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES 32 | ||
275 | |||
276 | #define SMC_SISLANDS_SCALE_I 7 | ||
277 | #define SMC_SISLANDS_SCALE_R 12 | ||
278 | |||
279 | struct PP_SIslands_CacConfig | ||
280 | { | ||
281 | uint16_t cac_lkge_lut[SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES]; | ||
282 | uint32_t lkge_lut_V0; | ||
283 | uint32_t lkge_lut_Vstep; | ||
284 | uint32_t WinTime; | ||
285 | uint32_t R_LL; | ||
286 | uint32_t calculation_repeats; | ||
287 | uint32_t l2numWin_TDP; | ||
288 | uint32_t dc_cac; | ||
289 | uint8_t lts_truncate_n; | ||
290 | uint8_t SHIFT_N; | ||
291 | uint8_t log2_PG_LKG_SCALE; | ||
292 | uint8_t cac_temp; | ||
293 | uint32_t lkge_lut_T0; | ||
294 | uint32_t lkge_lut_Tstep; | ||
295 | }; | ||
296 | |||
297 | typedef struct PP_SIslands_CacConfig PP_SIslands_CacConfig; | ||
298 | |||
299 | #define SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE 16 | ||
300 | #define SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT 20 | ||
301 | |||
302 | struct SMC_SIslands_MCRegisterAddress | ||
303 | { | ||
304 | uint16_t s0; | ||
305 | uint16_t s1; | ||
306 | }; | ||
307 | |||
308 | typedef struct SMC_SIslands_MCRegisterAddress SMC_SIslands_MCRegisterAddress; | ||
309 | |||
310 | struct SMC_SIslands_MCRegisterSet | ||
311 | { | ||
312 | uint32_t value[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
313 | }; | ||
314 | |||
315 | typedef struct SMC_SIslands_MCRegisterSet SMC_SIslands_MCRegisterSet; | ||
316 | |||
317 | struct SMC_SIslands_MCRegisters | ||
318 | { | ||
319 | uint8_t last; | ||
320 | uint8_t reserved[3]; | ||
321 | SMC_SIslands_MCRegisterAddress address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; | ||
322 | SMC_SIslands_MCRegisterSet data[SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT]; | ||
323 | }; | ||
324 | |||
325 | typedef struct SMC_SIslands_MCRegisters SMC_SIslands_MCRegisters; | ||
326 | |||
327 | struct SMC_SIslands_MCArbDramTimingRegisterSet | ||
328 | { | ||
329 | uint32_t mc_arb_dram_timing; | ||
330 | uint32_t mc_arb_dram_timing2; | ||
331 | uint8_t mc_arb_rfsh_rate; | ||
332 | uint8_t mc_arb_burst_time; | ||
333 | uint8_t padding[2]; | ||
334 | }; | ||
335 | |||
336 | typedef struct SMC_SIslands_MCArbDramTimingRegisterSet SMC_SIslands_MCArbDramTimingRegisterSet; | ||
337 | |||
338 | struct SMC_SIslands_MCArbDramTimingRegisters | ||
339 | { | ||
340 | uint8_t arb_current; | ||
341 | uint8_t reserved[3]; | ||
342 | SMC_SIslands_MCArbDramTimingRegisterSet data[16]; | ||
343 | }; | ||
344 | |||
345 | typedef struct SMC_SIslands_MCArbDramTimingRegisters SMC_SIslands_MCArbDramTimingRegisters; | ||
346 | |||
347 | struct SMC_SISLANDS_SPLL_DIV_TABLE | ||
348 | { | ||
349 | uint32_t freq[256]; | ||
350 | uint32_t ss[256]; | ||
351 | }; | ||
352 | |||
353 | #define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK 0x01ffffff | ||
354 | #define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT 0 | ||
355 | #define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK 0xfe000000 | ||
356 | #define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT 25 | ||
357 | #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK 0x000fffff | ||
358 | #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT 0 | ||
359 | #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK 0xfff00000 | ||
360 | #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT 20 | ||
361 | |||
362 | typedef struct SMC_SISLANDS_SPLL_DIV_TABLE SMC_SISLANDS_SPLL_DIV_TABLE; | ||
363 | |||
364 | #define SMC_SISLANDS_DTE_MAX_FILTER_STAGES 5 | ||
365 | |||
366 | #define SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE 16 | ||
367 | |||
368 | struct Smc_SIslands_DTE_Configuration | ||
369 | { | ||
370 | uint32_t tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; | ||
371 | uint32_t R[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; | ||
372 | uint32_t K; | ||
373 | uint32_t T0; | ||
374 | uint32_t MaxT; | ||
375 | uint8_t WindowSize; | ||
376 | uint8_t Tdep_count; | ||
377 | uint8_t temp_select; | ||
378 | uint8_t DTE_mode; | ||
379 | uint8_t T_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; | ||
380 | uint32_t Tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; | ||
381 | uint32_t Tdep_R[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; | ||
382 | uint32_t Tthreshold; | ||
383 | }; | ||
384 | |||
385 | typedef struct Smc_SIslands_DTE_Configuration Smc_SIslands_DTE_Configuration; | ||
386 | |||
387 | #define SMC_SISLANDS_DTE_STATUS_FLAG_DTE_ON 1 | ||
388 | |||
389 | #define SISLANDS_SMC_FIRMWARE_HEADER_LOCATION 0x10000 | ||
390 | |||
391 | #define SISLANDS_SMC_FIRMWARE_HEADER_version 0x0 | ||
392 | #define SISLANDS_SMC_FIRMWARE_HEADER_flags 0x4 | ||
393 | #define SISLANDS_SMC_FIRMWARE_HEADER_softRegisters 0xC | ||
394 | #define SISLANDS_SMC_FIRMWARE_HEADER_stateTable 0x10 | ||
395 | #define SISLANDS_SMC_FIRMWARE_HEADER_fanTable 0x14 | ||
396 | #define SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable 0x18 | ||
397 | #define SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable 0x24 | ||
398 | #define SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable 0x30 | ||
399 | #define SISLANDS_SMC_FIRMWARE_HEADER_spllTable 0x38 | ||
400 | #define SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration 0x40 | ||
401 | #define SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters 0x48 | ||
402 | |||
403 | #pragma pack(pop) | ||
404 | |||
405 | int amdgpu_si_copy_bytes_to_smc(struct amdgpu_device *adev, | ||
406 | u32 smc_start_address, | ||
407 | const u8 *src, u32 byte_count, u32 limit); | ||
408 | void amdgpu_si_start_smc(struct amdgpu_device *adev); | ||
409 | void amdgpu_si_reset_smc(struct amdgpu_device *adev); | ||
410 | int amdgpu_si_program_jump_on_start(struct amdgpu_device *adev); | ||
411 | void amdgpu_si_smc_clock(struct amdgpu_device *adev, bool enable); | ||
412 | bool amdgpu_si_is_smc_running(struct amdgpu_device *adev); | ||
413 | PPSMC_Result amdgpu_si_send_msg_to_smc(struct amdgpu_device *adev, PPSMC_Msg msg); | ||
414 | PPSMC_Result amdgpu_si_wait_for_smc_inactive(struct amdgpu_device *adev); | ||
415 | int amdgpu_si_load_smc_ucode(struct amdgpu_device *adev, u32 limit); | ||
416 | int amdgpu_si_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | ||
417 | u32 *value, u32 limit); | ||
418 | int amdgpu_si_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | ||
419 | u32 value, u32 limit); | ||
420 | |||
421 | #endif | ||
422 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c index 10c0407dcb6e..f6c941550b8f 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | |||
@@ -526,6 +526,20 @@ static void uvd_v4_2_ring_emit_ib(struct amdgpu_ring *ring, | |||
526 | amdgpu_ring_write(ring, ib->length_dw); | 526 | amdgpu_ring_write(ring, ib->length_dw); |
527 | } | 527 | } |
528 | 528 | ||
529 | static unsigned uvd_v4_2_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
530 | { | ||
531 | return | ||
532 | 4; /* uvd_v4_2_ring_emit_ib */ | ||
533 | } | ||
534 | |||
535 | static unsigned uvd_v4_2_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
536 | { | ||
537 | return | ||
538 | 2 + /* uvd_v4_2_ring_emit_hdp_flush */ | ||
539 | 2 + /* uvd_v4_2_ring_emit_hdp_invalidate */ | ||
540 | 14; /* uvd_v4_2_ring_emit_fence x1 no user fence */ | ||
541 | } | ||
542 | |||
529 | /** | 543 | /** |
530 | * uvd_v4_2_mc_resume - memory controller programming | 544 | * uvd_v4_2_mc_resume - memory controller programming |
531 | * | 545 | * |
@@ -756,6 +770,8 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { | |||
756 | .pad_ib = amdgpu_ring_generic_pad_ib, | 770 | .pad_ib = amdgpu_ring_generic_pad_ib, |
757 | .begin_use = amdgpu_uvd_ring_begin_use, | 771 | .begin_use = amdgpu_uvd_ring_begin_use, |
758 | .end_use = amdgpu_uvd_ring_end_use, | 772 | .end_use = amdgpu_uvd_ring_end_use, |
773 | .get_emit_ib_size = uvd_v4_2_ring_get_emit_ib_size, | ||
774 | .get_dma_frame_size = uvd_v4_2_ring_get_dma_frame_size, | ||
759 | }; | 775 | }; |
760 | 776 | ||
761 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) | 777 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index 8513376062c1..400c16fe579e 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
@@ -577,6 +577,20 @@ static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring, | |||
577 | amdgpu_ring_write(ring, ib->length_dw); | 577 | amdgpu_ring_write(ring, ib->length_dw); |
578 | } | 578 | } |
579 | 579 | ||
580 | static unsigned uvd_v5_0_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
581 | { | ||
582 | return | ||
583 | 6; /* uvd_v5_0_ring_emit_ib */ | ||
584 | } | ||
585 | |||
586 | static unsigned uvd_v5_0_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
587 | { | ||
588 | return | ||
589 | 2 + /* uvd_v5_0_ring_emit_hdp_flush */ | ||
590 | 2 + /* uvd_v5_0_ring_emit_hdp_invalidate */ | ||
591 | 14; /* uvd_v5_0_ring_emit_fence x1 no user fence */ | ||
592 | } | ||
593 | |||
580 | static bool uvd_v5_0_is_idle(void *handle) | 594 | static bool uvd_v5_0_is_idle(void *handle) |
581 | { | 595 | { |
582 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 596 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
@@ -807,6 +821,8 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | |||
807 | .pad_ib = amdgpu_ring_generic_pad_ib, | 821 | .pad_ib = amdgpu_ring_generic_pad_ib, |
808 | .begin_use = amdgpu_uvd_ring_begin_use, | 822 | .begin_use = amdgpu_uvd_ring_begin_use, |
809 | .end_use = amdgpu_uvd_ring_end_use, | 823 | .end_use = amdgpu_uvd_ring_end_use, |
824 | .get_emit_ib_size = uvd_v5_0_ring_get_emit_ib_size, | ||
825 | .get_dma_frame_size = uvd_v5_0_ring_get_dma_frame_size, | ||
810 | }; | 826 | }; |
811 | 827 | ||
812 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) | 828 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 2abe8a93c99f..e0fd9f21ed95 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -725,6 +725,31 @@ static void uvd_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | |||
725 | amdgpu_ring_write(ring, 0xE); | 725 | amdgpu_ring_write(ring, 0xE); |
726 | } | 726 | } |
727 | 727 | ||
728 | static unsigned uvd_v6_0_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
729 | { | ||
730 | return | ||
731 | 8; /* uvd_v6_0_ring_emit_ib */ | ||
732 | } | ||
733 | |||
734 | static unsigned uvd_v6_0_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
735 | { | ||
736 | return | ||
737 | 2 + /* uvd_v6_0_ring_emit_hdp_flush */ | ||
738 | 2 + /* uvd_v6_0_ring_emit_hdp_invalidate */ | ||
739 | 10 + /* uvd_v6_0_ring_emit_pipeline_sync */ | ||
740 | 14; /* uvd_v6_0_ring_emit_fence x1 no user fence */ | ||
741 | } | ||
742 | |||
743 | static unsigned uvd_v6_0_ring_get_dma_frame_size_vm(struct amdgpu_ring *ring) | ||
744 | { | ||
745 | return | ||
746 | 2 + /* uvd_v6_0_ring_emit_hdp_flush */ | ||
747 | 2 + /* uvd_v6_0_ring_emit_hdp_invalidate */ | ||
748 | 10 + /* uvd_v6_0_ring_emit_pipeline_sync */ | ||
749 | 20 + /* uvd_v6_0_ring_emit_vm_flush */ | ||
750 | 14 + 14; /* uvd_v6_0_ring_emit_fence x2 vm fence */ | ||
751 | } | ||
752 | |||
728 | static bool uvd_v6_0_is_idle(void *handle) | 753 | static bool uvd_v6_0_is_idle(void *handle) |
729 | { | 754 | { |
730 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 755 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
@@ -1037,6 +1062,8 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { | |||
1037 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1062 | .pad_ib = amdgpu_ring_generic_pad_ib, |
1038 | .begin_use = amdgpu_uvd_ring_begin_use, | 1063 | .begin_use = amdgpu_uvd_ring_begin_use, |
1039 | .end_use = amdgpu_uvd_ring_end_use, | 1064 | .end_use = amdgpu_uvd_ring_end_use, |
1065 | .get_emit_ib_size = uvd_v6_0_ring_get_emit_ib_size, | ||
1066 | .get_dma_frame_size = uvd_v6_0_ring_get_dma_frame_size, | ||
1040 | }; | 1067 | }; |
1041 | 1068 | ||
1042 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { | 1069 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { |
@@ -1056,6 +1083,8 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { | |||
1056 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1083 | .pad_ib = amdgpu_ring_generic_pad_ib, |
1057 | .begin_use = amdgpu_uvd_ring_begin_use, | 1084 | .begin_use = amdgpu_uvd_ring_begin_use, |
1058 | .end_use = amdgpu_uvd_ring_end_use, | 1085 | .end_use = amdgpu_uvd_ring_end_use, |
1086 | .get_emit_ib_size = uvd_v6_0_ring_get_emit_ib_size, | ||
1087 | .get_dma_frame_size = uvd_v6_0_ring_get_dma_frame_size_vm, | ||
1059 | }; | 1088 | }; |
1060 | 1089 | ||
1061 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) | 1090 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c index 5fa55b52c00e..76e64ad04a53 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | |||
@@ -30,10 +30,10 @@ | |||
30 | #include "amdgpu.h" | 30 | #include "amdgpu.h" |
31 | #include "amdgpu_vce.h" | 31 | #include "amdgpu_vce.h" |
32 | #include "cikd.h" | 32 | #include "cikd.h" |
33 | |||
34 | #include "vce/vce_2_0_d.h" | 33 | #include "vce/vce_2_0_d.h" |
35 | #include "vce/vce_2_0_sh_mask.h" | 34 | #include "vce/vce_2_0_sh_mask.h" |
36 | 35 | #include "smu/smu_7_0_1_d.h" | |
36 | #include "smu/smu_7_0_1_sh_mask.h" | ||
37 | #include "oss/oss_2_0_d.h" | 37 | #include "oss/oss_2_0_d.h" |
38 | #include "oss/oss_2_0_sh_mask.h" | 38 | #include "oss/oss_2_0_sh_mask.h" |
39 | 39 | ||
@@ -193,6 +193,8 @@ static int vce_v2_0_early_init(void *handle) | |||
193 | { | 193 | { |
194 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 194 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
195 | 195 | ||
196 | adev->vce.num_rings = 2; | ||
197 | |||
196 | vce_v2_0_set_ring_funcs(adev); | 198 | vce_v2_0_set_ring_funcs(adev); |
197 | vce_v2_0_set_irq_funcs(adev); | 199 | vce_v2_0_set_irq_funcs(adev); |
198 | 200 | ||
@@ -202,7 +204,7 @@ static int vce_v2_0_early_init(void *handle) | |||
202 | static int vce_v2_0_sw_init(void *handle) | 204 | static int vce_v2_0_sw_init(void *handle) |
203 | { | 205 | { |
204 | struct amdgpu_ring *ring; | 206 | struct amdgpu_ring *ring; |
205 | int r; | 207 | int r, i; |
206 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 208 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
207 | 209 | ||
208 | /* VCE */ | 210 | /* VCE */ |
@@ -219,19 +221,14 @@ static int vce_v2_0_sw_init(void *handle) | |||
219 | if (r) | 221 | if (r) |
220 | return r; | 222 | return r; |
221 | 223 | ||
222 | ring = &adev->vce.ring[0]; | 224 | for (i = 0; i < adev->vce.num_rings; i++) { |
223 | sprintf(ring->name, "vce0"); | 225 | ring = &adev->vce.ring[i]; |
224 | r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf, | 226 | sprintf(ring->name, "vce%d", i); |
225 | &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE); | 227 | r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf, |
226 | if (r) | 228 | &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE); |
227 | return r; | 229 | if (r) |
228 | 230 | return r; | |
229 | ring = &adev->vce.ring[1]; | 231 | } |
230 | sprintf(ring->name, "vce1"); | ||
231 | r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf, | ||
232 | &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE); | ||
233 | if (r) | ||
234 | return r; | ||
235 | 232 | ||
236 | return r; | 233 | return r; |
237 | } | 234 | } |
@@ -254,29 +251,23 @@ static int vce_v2_0_sw_fini(void *handle) | |||
254 | 251 | ||
255 | static int vce_v2_0_hw_init(void *handle) | 252 | static int vce_v2_0_hw_init(void *handle) |
256 | { | 253 | { |
257 | struct amdgpu_ring *ring; | 254 | int r, i; |
258 | int r; | ||
259 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 255 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
260 | 256 | ||
261 | r = vce_v2_0_start(adev); | 257 | r = vce_v2_0_start(adev); |
258 | /* this error mean vcpu not in running state, so just skip ring test, not stop driver initialize */ | ||
262 | if (r) | 259 | if (r) |
263 | /* this error mean vcpu not in running state, so just skip ring test, not stop driver initialize */ | ||
264 | return 0; | 260 | return 0; |
265 | 261 | ||
266 | ring = &adev->vce.ring[0]; | 262 | for (i = 0; i < adev->vce.num_rings; i++) |
267 | ring->ready = true; | 263 | adev->vce.ring[i].ready = false; |
268 | r = amdgpu_ring_test_ring(ring); | ||
269 | if (r) { | ||
270 | ring->ready = false; | ||
271 | return r; | ||
272 | } | ||
273 | 264 | ||
274 | ring = &adev->vce.ring[1]; | 265 | for (i = 0; i < adev->vce.num_rings; i++) { |
275 | ring->ready = true; | 266 | r = amdgpu_ring_test_ring(&adev->vce.ring[i]); |
276 | r = amdgpu_ring_test_ring(ring); | 267 | if (r) |
277 | if (r) { | 268 | return r; |
278 | ring->ready = false; | 269 | else |
279 | return r; | 270 | adev->vce.ring[i].ready = true; |
280 | } | 271 | } |
281 | 272 | ||
282 | DRM_INFO("VCE initialized successfully.\n"); | 273 | DRM_INFO("VCE initialized successfully.\n"); |
@@ -548,11 +539,28 @@ static int vce_v2_0_process_interrupt(struct amdgpu_device *adev, | |||
548 | return 0; | 539 | return 0; |
549 | } | 540 | } |
550 | 541 | ||
542 | static void vce_v2_0_set_bypass_mode(struct amdgpu_device *adev, bool enable) | ||
543 | { | ||
544 | u32 tmp = RREG32_SMC(ixGCK_DFS_BYPASS_CNTL); | ||
545 | |||
546 | if (enable) | ||
547 | tmp |= GCK_DFS_BYPASS_CNTL__BYPASSECLK_MASK; | ||
548 | else | ||
549 | tmp &= ~GCK_DFS_BYPASS_CNTL__BYPASSECLK_MASK; | ||
550 | |||
551 | WREG32_SMC(ixGCK_DFS_BYPASS_CNTL, tmp); | ||
552 | } | ||
553 | |||
554 | |||
551 | static int vce_v2_0_set_clockgating_state(void *handle, | 555 | static int vce_v2_0_set_clockgating_state(void *handle, |
552 | enum amd_clockgating_state state) | 556 | enum amd_clockgating_state state) |
553 | { | 557 | { |
554 | bool gate = false; | 558 | bool gate = false; |
555 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 559 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
560 | bool enable = (state == AMD_CG_STATE_GATE) ? true : false; | ||
561 | |||
562 | |||
563 | vce_v2_0_set_bypass_mode(adev, enable); | ||
556 | 564 | ||
557 | if (state == AMD_CG_STATE_GATE) | 565 | if (state == AMD_CG_STATE_GATE) |
558 | gate = true; | 566 | gate = true; |
@@ -614,12 +622,16 @@ static const struct amdgpu_ring_funcs vce_v2_0_ring_funcs = { | |||
614 | .pad_ib = amdgpu_ring_generic_pad_ib, | 622 | .pad_ib = amdgpu_ring_generic_pad_ib, |
615 | .begin_use = amdgpu_vce_ring_begin_use, | 623 | .begin_use = amdgpu_vce_ring_begin_use, |
616 | .end_use = amdgpu_vce_ring_end_use, | 624 | .end_use = amdgpu_vce_ring_end_use, |
625 | .get_emit_ib_size = amdgpu_vce_ring_get_emit_ib_size, | ||
626 | .get_dma_frame_size = amdgpu_vce_ring_get_dma_frame_size, | ||
617 | }; | 627 | }; |
618 | 628 | ||
619 | static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev) | 629 | static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev) |
620 | { | 630 | { |
621 | adev->vce.ring[0].funcs = &vce_v2_0_ring_funcs; | 631 | int i; |
622 | adev->vce.ring[1].funcs = &vce_v2_0_ring_funcs; | 632 | |
633 | for (i = 0; i < adev->vce.num_rings; i++) | ||
634 | adev->vce.ring[i].funcs = &vce_v2_0_ring_funcs; | ||
623 | } | 635 | } |
624 | 636 | ||
625 | static const struct amdgpu_irq_src_funcs vce_v2_0_irq_funcs = { | 637 | static const struct amdgpu_irq_src_funcs vce_v2_0_irq_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c index 615b8b16ad04..a6b4e27bee89 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | |||
@@ -70,8 +70,10 @@ static uint32_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring) | |||
70 | 70 | ||
71 | if (ring == &adev->vce.ring[0]) | 71 | if (ring == &adev->vce.ring[0]) |
72 | return RREG32(mmVCE_RB_RPTR); | 72 | return RREG32(mmVCE_RB_RPTR); |
73 | else | 73 | else if (ring == &adev->vce.ring[1]) |
74 | return RREG32(mmVCE_RB_RPTR2); | 74 | return RREG32(mmVCE_RB_RPTR2); |
75 | else | ||
76 | return RREG32(mmVCE_RB_RPTR3); | ||
75 | } | 77 | } |
76 | 78 | ||
77 | /** | 79 | /** |
@@ -87,8 +89,10 @@ static uint32_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring) | |||
87 | 89 | ||
88 | if (ring == &adev->vce.ring[0]) | 90 | if (ring == &adev->vce.ring[0]) |
89 | return RREG32(mmVCE_RB_WPTR); | 91 | return RREG32(mmVCE_RB_WPTR); |
90 | else | 92 | else if (ring == &adev->vce.ring[1]) |
91 | return RREG32(mmVCE_RB_WPTR2); | 93 | return RREG32(mmVCE_RB_WPTR2); |
94 | else | ||
95 | return RREG32(mmVCE_RB_WPTR3); | ||
92 | } | 96 | } |
93 | 97 | ||
94 | /** | 98 | /** |
@@ -104,8 +108,10 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring) | |||
104 | 108 | ||
105 | if (ring == &adev->vce.ring[0]) | 109 | if (ring == &adev->vce.ring[0]) |
106 | WREG32(mmVCE_RB_WPTR, ring->wptr); | 110 | WREG32(mmVCE_RB_WPTR, ring->wptr); |
107 | else | 111 | else if (ring == &adev->vce.ring[1]) |
108 | WREG32(mmVCE_RB_WPTR2, ring->wptr); | 112 | WREG32(mmVCE_RB_WPTR2, ring->wptr); |
113 | else | ||
114 | WREG32(mmVCE_RB_WPTR3, ring->wptr); | ||
109 | } | 115 | } |
110 | 116 | ||
111 | static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override) | 117 | static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override) |
@@ -229,6 +235,13 @@ static int vce_v3_0_start(struct amdgpu_device *adev) | |||
229 | WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); | 235 | WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); |
230 | WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4); | 236 | WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4); |
231 | 237 | ||
238 | ring = &adev->vce.ring[2]; | ||
239 | WREG32(mmVCE_RB_RPTR3, ring->wptr); | ||
240 | WREG32(mmVCE_RB_WPTR3, ring->wptr); | ||
241 | WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr); | ||
242 | WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr)); | ||
243 | WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4); | ||
244 | |||
232 | mutex_lock(&adev->grbm_idx_mutex); | 245 | mutex_lock(&adev->grbm_idx_mutex); |
233 | for (idx = 0; idx < 2; ++idx) { | 246 | for (idx = 0; idx < 2; ++idx) { |
234 | if (adev->vce.harvest_config & (1 << idx)) | 247 | if (adev->vce.harvest_config & (1 << idx)) |
@@ -345,6 +358,8 @@ static int vce_v3_0_early_init(void *handle) | |||
345 | (AMDGPU_VCE_HARVEST_VCE0 | AMDGPU_VCE_HARVEST_VCE1)) | 358 | (AMDGPU_VCE_HARVEST_VCE0 | AMDGPU_VCE_HARVEST_VCE1)) |
346 | return -ENOENT; | 359 | return -ENOENT; |
347 | 360 | ||
361 | adev->vce.num_rings = 3; | ||
362 | |||
348 | vce_v3_0_set_ring_funcs(adev); | 363 | vce_v3_0_set_ring_funcs(adev); |
349 | vce_v3_0_set_irq_funcs(adev); | 364 | vce_v3_0_set_irq_funcs(adev); |
350 | 365 | ||
@@ -355,7 +370,7 @@ static int vce_v3_0_sw_init(void *handle) | |||
355 | { | 370 | { |
356 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 371 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
357 | struct amdgpu_ring *ring; | 372 | struct amdgpu_ring *ring; |
358 | int r; | 373 | int r, i; |
359 | 374 | ||
360 | /* VCE */ | 375 | /* VCE */ |
361 | r = amdgpu_irq_add_id(adev, 167, &adev->vce.irq); | 376 | r = amdgpu_irq_add_id(adev, 167, &adev->vce.irq); |
@@ -371,19 +386,14 @@ static int vce_v3_0_sw_init(void *handle) | |||
371 | if (r) | 386 | if (r) |
372 | return r; | 387 | return r; |
373 | 388 | ||
374 | ring = &adev->vce.ring[0]; | 389 | for (i = 0; i < adev->vce.num_rings; i++) { |
375 | sprintf(ring->name, "vce0"); | 390 | ring = &adev->vce.ring[i]; |
376 | r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf, | 391 | sprintf(ring->name, "vce%d", i); |
377 | &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE); | 392 | r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf, |
378 | if (r) | 393 | &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE); |
379 | return r; | 394 | if (r) |
380 | 395 | return r; | |
381 | ring = &adev->vce.ring[1]; | 396 | } |
382 | sprintf(ring->name, "vce1"); | ||
383 | r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf, | ||
384 | &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE); | ||
385 | if (r) | ||
386 | return r; | ||
387 | 397 | ||
388 | return r; | 398 | return r; |
389 | } | 399 | } |
@@ -413,10 +423,10 @@ static int vce_v3_0_hw_init(void *handle) | |||
413 | if (r) | 423 | if (r) |
414 | return r; | 424 | return r; |
415 | 425 | ||
416 | adev->vce.ring[0].ready = false; | 426 | for (i = 0; i < adev->vce.num_rings; i++) |
417 | adev->vce.ring[1].ready = false; | 427 | adev->vce.ring[i].ready = false; |
418 | 428 | ||
419 | for (i = 0; i < 2; i++) { | 429 | for (i = 0; i < adev->vce.num_rings; i++) { |
420 | r = amdgpu_ring_test_ring(&adev->vce.ring[i]); | 430 | r = amdgpu_ring_test_ring(&adev->vce.ring[i]); |
421 | if (r) | 431 | if (r) |
422 | return r; | 432 | return r; |
@@ -674,6 +684,7 @@ static int vce_v3_0_process_interrupt(struct amdgpu_device *adev, | |||
674 | switch (entry->src_data) { | 684 | switch (entry->src_data) { |
675 | case 0: | 685 | case 0: |
676 | case 1: | 686 | case 1: |
687 | case 2: | ||
677 | amdgpu_fence_process(&adev->vce.ring[entry->src_data]); | 688 | amdgpu_fence_process(&adev->vce.ring[entry->src_data]); |
678 | break; | 689 | break; |
679 | default: | 690 | default: |
@@ -685,7 +696,7 @@ static int vce_v3_0_process_interrupt(struct amdgpu_device *adev, | |||
685 | return 0; | 696 | return 0; |
686 | } | 697 | } |
687 | 698 | ||
688 | static void vce_v3_set_bypass_mode(struct amdgpu_device *adev, bool enable) | 699 | static void vce_v3_0_set_bypass_mode(struct amdgpu_device *adev, bool enable) |
689 | { | 700 | { |
690 | u32 tmp = RREG32_SMC(ixGCK_DFS_BYPASS_CNTL); | 701 | u32 tmp = RREG32_SMC(ixGCK_DFS_BYPASS_CNTL); |
691 | 702 | ||
@@ -704,8 +715,9 @@ static int vce_v3_0_set_clockgating_state(void *handle, | |||
704 | bool enable = (state == AMD_CG_STATE_GATE) ? true : false; | 715 | bool enable = (state == AMD_CG_STATE_GATE) ? true : false; |
705 | int i; | 716 | int i; |
706 | 717 | ||
707 | if (adev->asic_type == CHIP_POLARIS10) | 718 | if ((adev->asic_type == CHIP_POLARIS10) || |
708 | vce_v3_set_bypass_mode(adev, enable); | 719 | (adev->asic_type == CHIP_TONGA)) |
720 | vce_v3_0_set_bypass_mode(adev, enable); | ||
709 | 721 | ||
710 | if (!(adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) | 722 | if (!(adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) |
711 | return 0; | 723 | return 0; |
@@ -763,6 +775,60 @@ static int vce_v3_0_set_powergating_state(void *handle, | |||
763 | return vce_v3_0_start(adev); | 775 | return vce_v3_0_start(adev); |
764 | } | 776 | } |
765 | 777 | ||
778 | static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring, | ||
779 | struct amdgpu_ib *ib, unsigned int vm_id, bool ctx_switch) | ||
780 | { | ||
781 | amdgpu_ring_write(ring, VCE_CMD_IB_VM); | ||
782 | amdgpu_ring_write(ring, vm_id); | ||
783 | amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); | ||
784 | amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr)); | ||
785 | amdgpu_ring_write(ring, ib->length_dw); | ||
786 | } | ||
787 | |||
788 | static void vce_v3_0_emit_vm_flush(struct amdgpu_ring *ring, | ||
789 | unsigned int vm_id, uint64_t pd_addr) | ||
790 | { | ||
791 | amdgpu_ring_write(ring, VCE_CMD_UPDATE_PTB); | ||
792 | amdgpu_ring_write(ring, vm_id); | ||
793 | amdgpu_ring_write(ring, pd_addr >> 12); | ||
794 | |||
795 | amdgpu_ring_write(ring, VCE_CMD_FLUSH_TLB); | ||
796 | amdgpu_ring_write(ring, vm_id); | ||
797 | amdgpu_ring_write(ring, VCE_CMD_END); | ||
798 | } | ||
799 | |||
800 | static void vce_v3_0_emit_pipeline_sync(struct amdgpu_ring *ring) | ||
801 | { | ||
802 | uint32_t seq = ring->fence_drv.sync_seq; | ||
803 | uint64_t addr = ring->fence_drv.gpu_addr; | ||
804 | |||
805 | amdgpu_ring_write(ring, VCE_CMD_WAIT_GE); | ||
806 | amdgpu_ring_write(ring, lower_32_bits(addr)); | ||
807 | amdgpu_ring_write(ring, upper_32_bits(addr)); | ||
808 | amdgpu_ring_write(ring, seq); | ||
809 | } | ||
810 | |||
811 | static unsigned vce_v3_0_ring_get_emit_ib_size(struct amdgpu_ring *ring) | ||
812 | { | ||
813 | return | ||
814 | 5; /* vce_v3_0_ring_emit_ib */ | ||
815 | } | ||
816 | |||
817 | static unsigned vce_v3_0_ring_get_dma_frame_size(struct amdgpu_ring *ring) | ||
818 | { | ||
819 | return | ||
820 | 4 + /* vce_v3_0_emit_pipeline_sync */ | ||
821 | 6; /* amdgpu_vce_ring_emit_fence x1 no user fence */ | ||
822 | } | ||
823 | |||
824 | static unsigned vce_v3_0_ring_get_dma_frame_size_vm(struct amdgpu_ring *ring) | ||
825 | { | ||
826 | return | ||
827 | 6 + /* vce_v3_0_emit_vm_flush */ | ||
828 | 4 + /* vce_v3_0_emit_pipeline_sync */ | ||
829 | 6 + 6; /* amdgpu_vce_ring_emit_fence x2 vm fence */ | ||
830 | } | ||
831 | |||
766 | const struct amd_ip_funcs vce_v3_0_ip_funcs = { | 832 | const struct amd_ip_funcs vce_v3_0_ip_funcs = { |
767 | .name = "vce_v3_0", | 833 | .name = "vce_v3_0", |
768 | .early_init = vce_v3_0_early_init, | 834 | .early_init = vce_v3_0_early_init, |
@@ -783,7 +849,7 @@ const struct amd_ip_funcs vce_v3_0_ip_funcs = { | |||
783 | .set_powergating_state = vce_v3_0_set_powergating_state, | 849 | .set_powergating_state = vce_v3_0_set_powergating_state, |
784 | }; | 850 | }; |
785 | 851 | ||
786 | static const struct amdgpu_ring_funcs vce_v3_0_ring_funcs = { | 852 | static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = { |
787 | .get_rptr = vce_v3_0_ring_get_rptr, | 853 | .get_rptr = vce_v3_0_ring_get_rptr, |
788 | .get_wptr = vce_v3_0_ring_get_wptr, | 854 | .get_wptr = vce_v3_0_ring_get_wptr, |
789 | .set_wptr = vce_v3_0_ring_set_wptr, | 855 | .set_wptr = vce_v3_0_ring_set_wptr, |
@@ -796,12 +862,42 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_funcs = { | |||
796 | .pad_ib = amdgpu_ring_generic_pad_ib, | 862 | .pad_ib = amdgpu_ring_generic_pad_ib, |
797 | .begin_use = amdgpu_vce_ring_begin_use, | 863 | .begin_use = amdgpu_vce_ring_begin_use, |
798 | .end_use = amdgpu_vce_ring_end_use, | 864 | .end_use = amdgpu_vce_ring_end_use, |
865 | .get_emit_ib_size = vce_v3_0_ring_get_emit_ib_size, | ||
866 | .get_dma_frame_size = vce_v3_0_ring_get_dma_frame_size, | ||
867 | }; | ||
868 | |||
869 | static const struct amdgpu_ring_funcs vce_v3_0_ring_vm_funcs = { | ||
870 | .get_rptr = vce_v3_0_ring_get_rptr, | ||
871 | .get_wptr = vce_v3_0_ring_get_wptr, | ||
872 | .set_wptr = vce_v3_0_ring_set_wptr, | ||
873 | .parse_cs = NULL, | ||
874 | .emit_ib = vce_v3_0_ring_emit_ib, | ||
875 | .emit_vm_flush = vce_v3_0_emit_vm_flush, | ||
876 | .emit_pipeline_sync = vce_v3_0_emit_pipeline_sync, | ||
877 | .emit_fence = amdgpu_vce_ring_emit_fence, | ||
878 | .test_ring = amdgpu_vce_ring_test_ring, | ||
879 | .test_ib = amdgpu_vce_ring_test_ib, | ||
880 | .insert_nop = amdgpu_ring_insert_nop, | ||
881 | .pad_ib = amdgpu_ring_generic_pad_ib, | ||
882 | .begin_use = amdgpu_vce_ring_begin_use, | ||
883 | .end_use = amdgpu_vce_ring_end_use, | ||
884 | .get_emit_ib_size = vce_v3_0_ring_get_emit_ib_size, | ||
885 | .get_dma_frame_size = vce_v3_0_ring_get_dma_frame_size_vm, | ||
799 | }; | 886 | }; |
800 | 887 | ||
801 | static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev) | 888 | static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev) |
802 | { | 889 | { |
803 | adev->vce.ring[0].funcs = &vce_v3_0_ring_funcs; | 890 | int i; |
804 | adev->vce.ring[1].funcs = &vce_v3_0_ring_funcs; | 891 | |
892 | if (adev->asic_type >= CHIP_STONEY) { | ||
893 | for (i = 0; i < adev->vce.num_rings; i++) | ||
894 | adev->vce.ring[i].funcs = &vce_v3_0_ring_vm_funcs; | ||
895 | DRM_INFO("VCE enabled in VM mode\n"); | ||
896 | } else { | ||
897 | for (i = 0; i < adev->vce.num_rings; i++) | ||
898 | adev->vce.ring[i].funcs = &vce_v3_0_ring_phys_funcs; | ||
899 | DRM_INFO("VCE enabled in physical mode\n"); | ||
900 | } | ||
805 | } | 901 | } |
806 | 902 | ||
807 | static const struct amdgpu_irq_src_funcs vce_v3_0_irq_funcs = { | 903 | static const struct amdgpu_irq_src_funcs vce_v3_0_irq_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index f2e8aa1a0dbd..b688e2f77419 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c | |||
@@ -1650,7 +1650,7 @@ static int vi_common_early_init(void *handle) | |||
1650 | AMD_PG_SUPPORT_GFX_PIPELINE | | 1650 | AMD_PG_SUPPORT_GFX_PIPELINE | |
1651 | AMD_PG_SUPPORT_UVD | | 1651 | AMD_PG_SUPPORT_UVD | |
1652 | AMD_PG_SUPPORT_VCE; | 1652 | AMD_PG_SUPPORT_VCE; |
1653 | adev->external_rev_id = adev->rev_id + 0x1; | 1653 | adev->external_rev_id = adev->rev_id + 0x61; |
1654 | break; | 1654 | break; |
1655 | default: | 1655 | default: |
1656 | /* FIXME: not supported yet */ | 1656 | /* FIXME: not supported yet */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/vid.h b/drivers/gpu/drm/amd/amdgpu/vid.h index 062ee1676480..f62b261660d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/vid.h +++ b/drivers/gpu/drm/amd/amdgpu/vid.h | |||
@@ -369,4 +369,8 @@ | |||
369 | #define VCE_CMD_IB_AUTO 0x00000005 | 369 | #define VCE_CMD_IB_AUTO 0x00000005 |
370 | #define VCE_CMD_SEMAPHORE 0x00000006 | 370 | #define VCE_CMD_SEMAPHORE 0x00000006 |
371 | 371 | ||
372 | #define VCE_CMD_IB_VM 0x00000102 | ||
373 | #define VCE_CMD_WAIT_GE 0x00000106 | ||
374 | #define VCE_CMD_UPDATE_PTB 0x00000107 | ||
375 | #define VCE_CMD_FLUSH_TLB 0x00000108 | ||
372 | #endif | 376 | #endif |
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h index db710418f35f..c934b78c9e2f 100644 --- a/drivers/gpu/drm/amd/include/amd_shared.h +++ b/drivers/gpu/drm/amd/include/amd_shared.h | |||
@@ -29,7 +29,12 @@ | |||
29 | * Supported ASIC types | 29 | * Supported ASIC types |
30 | */ | 30 | */ |
31 | enum amd_asic_type { | 31 | enum amd_asic_type { |
32 | CHIP_BONAIRE = 0, | 32 | CHIP_TAHITI = 0, |
33 | CHIP_PITCAIRN, | ||
34 | CHIP_VERDE, | ||
35 | CHIP_OLAND, | ||
36 | CHIP_HAINAN, | ||
37 | CHIP_BONAIRE, | ||
33 | CHIP_KAVERI, | 38 | CHIP_KAVERI, |
34 | CHIP_KABINI, | 39 | CHIP_KABINI, |
35 | CHIP_HAWAII, | 40 | CHIP_HAWAII, |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/si/clearstate_si.h b/drivers/gpu/drm/amd/include/asic_reg/si/clearstate_si.h new file mode 100644 index 000000000000..66e39cdb5cb0 --- /dev/null +++ b/drivers/gpu/drm/amd/include/asic_reg/si/clearstate_si.h | |||
@@ -0,0 +1,941 @@ | |||
1 | /* | ||
2 | * Copyright 2013 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | static const u32 si_SECT_CONTEXT_def_1[] = | ||
25 | { | ||
26 | 0x00000000, // DB_RENDER_CONTROL | ||
27 | 0x00000000, // DB_COUNT_CONTROL | ||
28 | 0x00000000, // DB_DEPTH_VIEW | ||
29 | 0x00000000, // DB_RENDER_OVERRIDE | ||
30 | 0x00000000, // DB_RENDER_OVERRIDE2 | ||
31 | 0x00000000, // DB_HTILE_DATA_BASE | ||
32 | 0, // HOLE | ||
33 | 0, // HOLE | ||
34 | 0x00000000, // DB_DEPTH_BOUNDS_MIN | ||
35 | 0x00000000, // DB_DEPTH_BOUNDS_MAX | ||
36 | 0x00000000, // DB_STENCIL_CLEAR | ||
37 | 0x00000000, // DB_DEPTH_CLEAR | ||
38 | 0x00000000, // PA_SC_SCREEN_SCISSOR_TL | ||
39 | 0x40004000, // PA_SC_SCREEN_SCISSOR_BR | ||
40 | 0, // HOLE | ||
41 | 0x00000000, // DB_DEPTH_INFO | ||
42 | 0x00000000, // DB_Z_INFO | ||
43 | 0x00000000, // DB_STENCIL_INFO | ||
44 | 0x00000000, // DB_Z_READ_BASE | ||
45 | 0x00000000, // DB_STENCIL_READ_BASE | ||
46 | 0x00000000, // DB_Z_WRITE_BASE | ||
47 | 0x00000000, // DB_STENCIL_WRITE_BASE | ||
48 | 0x00000000, // DB_DEPTH_SIZE | ||
49 | 0x00000000, // DB_DEPTH_SLICE | ||
50 | 0, // HOLE | ||
51 | 0, // HOLE | ||
52 | 0, // HOLE | ||
53 | 0, // HOLE | ||
54 | 0, // HOLE | ||
55 | 0, // HOLE | ||
56 | 0, // HOLE | ||
57 | 0, // HOLE | ||
58 | 0x00000000, // TA_BC_BASE_ADDR | ||
59 | 0, // HOLE | ||
60 | 0, // HOLE | ||
61 | 0, // HOLE | ||
62 | 0, // HOLE | ||
63 | 0, // HOLE | ||
64 | 0, // HOLE | ||
65 | 0, // HOLE | ||
66 | 0, // HOLE | ||
67 | 0, // HOLE | ||
68 | 0, // HOLE | ||
69 | 0, // HOLE | ||
70 | 0, // HOLE | ||
71 | 0, // HOLE | ||
72 | 0, // HOLE | ||
73 | 0, // HOLE | ||
74 | 0, // HOLE | ||
75 | 0, // HOLE | ||
76 | 0, // HOLE | ||
77 | 0, // HOLE | ||
78 | 0, // HOLE | ||
79 | 0, // HOLE | ||
80 | 0, // HOLE | ||
81 | 0, // HOLE | ||
82 | 0, // HOLE | ||
83 | 0, // HOLE | ||
84 | 0, // HOLE | ||
85 | 0, // HOLE | ||
86 | 0, // HOLE | ||
87 | 0, // HOLE | ||
88 | 0, // HOLE | ||
89 | 0, // HOLE | ||
90 | 0, // HOLE | ||
91 | 0, // HOLE | ||
92 | 0, // HOLE | ||
93 | 0, // HOLE | ||
94 | 0, // HOLE | ||
95 | 0, // HOLE | ||
96 | 0, // HOLE | ||
97 | 0, // HOLE | ||
98 | 0, // HOLE | ||
99 | 0, // HOLE | ||
100 | 0, // HOLE | ||
101 | 0, // HOLE | ||
102 | 0, // HOLE | ||
103 | 0, // HOLE | ||
104 | 0, // HOLE | ||
105 | 0, // HOLE | ||
106 | 0, // HOLE | ||
107 | 0, // HOLE | ||
108 | 0, // HOLE | ||
109 | 0, // HOLE | ||
110 | 0, // HOLE | ||
111 | 0, // HOLE | ||
112 | 0, // HOLE | ||
113 | 0, // HOLE | ||
114 | 0, // HOLE | ||
115 | 0, // HOLE | ||
116 | 0, // HOLE | ||
117 | 0, // HOLE | ||
118 | 0, // HOLE | ||
119 | 0, // HOLE | ||
120 | 0, // HOLE | ||
121 | 0, // HOLE | ||
122 | 0, // HOLE | ||
123 | 0, // HOLE | ||
124 | 0, // HOLE | ||
125 | 0, // HOLE | ||
126 | 0, // HOLE | ||
127 | 0, // HOLE | ||
128 | 0, // HOLE | ||
129 | 0, // HOLE | ||
130 | 0, // HOLE | ||
131 | 0, // HOLE | ||
132 | 0, // HOLE | ||
133 | 0, // HOLE | ||
134 | 0, // HOLE | ||
135 | 0, // HOLE | ||
136 | 0, // HOLE | ||
137 | 0, // HOLE | ||
138 | 0, // HOLE | ||
139 | 0, // HOLE | ||
140 | 0, // HOLE | ||
141 | 0, // HOLE | ||
142 | 0, // HOLE | ||
143 | 0, // HOLE | ||
144 | 0, // HOLE | ||
145 | 0, // HOLE | ||
146 | 0, // HOLE | ||
147 | 0, // HOLE | ||
148 | 0, // HOLE | ||
149 | 0, // HOLE | ||
150 | 0, // HOLE | ||
151 | 0, // HOLE | ||
152 | 0x00000000, // COHER_DEST_BASE_2 | ||
153 | 0x00000000, // COHER_DEST_BASE_3 | ||
154 | 0x00000000, // PA_SC_WINDOW_OFFSET | ||
155 | 0x80000000, // PA_SC_WINDOW_SCISSOR_TL | ||
156 | 0x40004000, // PA_SC_WINDOW_SCISSOR_BR | ||
157 | 0x0000ffff, // PA_SC_CLIPRECT_RULE | ||
158 | 0x00000000, // PA_SC_CLIPRECT_0_TL | ||
159 | 0x40004000, // PA_SC_CLIPRECT_0_BR | ||
160 | 0x00000000, // PA_SC_CLIPRECT_1_TL | ||
161 | 0x40004000, // PA_SC_CLIPRECT_1_BR | ||
162 | 0x00000000, // PA_SC_CLIPRECT_2_TL | ||
163 | 0x40004000, // PA_SC_CLIPRECT_2_BR | ||
164 | 0x00000000, // PA_SC_CLIPRECT_3_TL | ||
165 | 0x40004000, // PA_SC_CLIPRECT_3_BR | ||
166 | 0xaa99aaaa, // PA_SC_EDGERULE | ||
167 | 0x00000000, // PA_SU_HARDWARE_SCREEN_OFFSET | ||
168 | 0xffffffff, // CB_TARGET_MASK | ||
169 | 0xffffffff, // CB_SHADER_MASK | ||
170 | 0x80000000, // PA_SC_GENERIC_SCISSOR_TL | ||
171 | 0x40004000, // PA_SC_GENERIC_SCISSOR_BR | ||
172 | 0x00000000, // COHER_DEST_BASE_0 | ||
173 | 0x00000000, // COHER_DEST_BASE_1 | ||
174 | 0x80000000, // PA_SC_VPORT_SCISSOR_0_TL | ||
175 | 0x40004000, // PA_SC_VPORT_SCISSOR_0_BR | ||
176 | 0x80000000, // PA_SC_VPORT_SCISSOR_1_TL | ||
177 | 0x40004000, // PA_SC_VPORT_SCISSOR_1_BR | ||
178 | 0x80000000, // PA_SC_VPORT_SCISSOR_2_TL | ||
179 | 0x40004000, // PA_SC_VPORT_SCISSOR_2_BR | ||
180 | 0x80000000, // PA_SC_VPORT_SCISSOR_3_TL | ||
181 | 0x40004000, // PA_SC_VPORT_SCISSOR_3_BR | ||
182 | 0x80000000, // PA_SC_VPORT_SCISSOR_4_TL | ||
183 | 0x40004000, // PA_SC_VPORT_SCISSOR_4_BR | ||
184 | 0x80000000, // PA_SC_VPORT_SCISSOR_5_TL | ||
185 | 0x40004000, // PA_SC_VPORT_SCISSOR_5_BR | ||
186 | 0x80000000, // PA_SC_VPORT_SCISSOR_6_TL | ||
187 | 0x40004000, // PA_SC_VPORT_SCISSOR_6_BR | ||
188 | 0x80000000, // PA_SC_VPORT_SCISSOR_7_TL | ||
189 | 0x40004000, // PA_SC_VPORT_SCISSOR_7_BR | ||
190 | 0x80000000, // PA_SC_VPORT_SCISSOR_8_TL | ||
191 | 0x40004000, // PA_SC_VPORT_SCISSOR_8_BR | ||
192 | 0x80000000, // PA_SC_VPORT_SCISSOR_9_TL | ||
193 | 0x40004000, // PA_SC_VPORT_SCISSOR_9_BR | ||
194 | 0x80000000, // PA_SC_VPORT_SCISSOR_10_TL | ||
195 | 0x40004000, // PA_SC_VPORT_SCISSOR_10_BR | ||
196 | 0x80000000, // PA_SC_VPORT_SCISSOR_11_TL | ||
197 | 0x40004000, // PA_SC_VPORT_SCISSOR_11_BR | ||
198 | 0x80000000, // PA_SC_VPORT_SCISSOR_12_TL | ||
199 | 0x40004000, // PA_SC_VPORT_SCISSOR_12_BR | ||
200 | 0x80000000, // PA_SC_VPORT_SCISSOR_13_TL | ||
201 | 0x40004000, // PA_SC_VPORT_SCISSOR_13_BR | ||
202 | 0x80000000, // PA_SC_VPORT_SCISSOR_14_TL | ||
203 | 0x40004000, // PA_SC_VPORT_SCISSOR_14_BR | ||
204 | 0x80000000, // PA_SC_VPORT_SCISSOR_15_TL | ||
205 | 0x40004000, // PA_SC_VPORT_SCISSOR_15_BR | ||
206 | 0x00000000, // PA_SC_VPORT_ZMIN_0 | ||
207 | 0x3f800000, // PA_SC_VPORT_ZMAX_0 | ||
208 | 0x00000000, // PA_SC_VPORT_ZMIN_1 | ||
209 | 0x3f800000, // PA_SC_VPORT_ZMAX_1 | ||
210 | 0x00000000, // PA_SC_VPORT_ZMIN_2 | ||
211 | 0x3f800000, // PA_SC_VPORT_ZMAX_2 | ||
212 | 0x00000000, // PA_SC_VPORT_ZMIN_3 | ||
213 | 0x3f800000, // PA_SC_VPORT_ZMAX_3 | ||
214 | 0x00000000, // PA_SC_VPORT_ZMIN_4 | ||
215 | 0x3f800000, // PA_SC_VPORT_ZMAX_4 | ||
216 | 0x00000000, // PA_SC_VPORT_ZMIN_5 | ||
217 | 0x3f800000, // PA_SC_VPORT_ZMAX_5 | ||
218 | 0x00000000, // PA_SC_VPORT_ZMIN_6 | ||
219 | 0x3f800000, // PA_SC_VPORT_ZMAX_6 | ||
220 | 0x00000000, // PA_SC_VPORT_ZMIN_7 | ||
221 | 0x3f800000, // PA_SC_VPORT_ZMAX_7 | ||
222 | 0x00000000, // PA_SC_VPORT_ZMIN_8 | ||
223 | 0x3f800000, // PA_SC_VPORT_ZMAX_8 | ||
224 | 0x00000000, // PA_SC_VPORT_ZMIN_9 | ||
225 | 0x3f800000, // PA_SC_VPORT_ZMAX_9 | ||
226 | 0x00000000, // PA_SC_VPORT_ZMIN_10 | ||
227 | 0x3f800000, // PA_SC_VPORT_ZMAX_10 | ||
228 | 0x00000000, // PA_SC_VPORT_ZMIN_11 | ||
229 | 0x3f800000, // PA_SC_VPORT_ZMAX_11 | ||
230 | 0x00000000, // PA_SC_VPORT_ZMIN_12 | ||
231 | 0x3f800000, // PA_SC_VPORT_ZMAX_12 | ||
232 | 0x00000000, // PA_SC_VPORT_ZMIN_13 | ||
233 | 0x3f800000, // PA_SC_VPORT_ZMAX_13 | ||
234 | 0x00000000, // PA_SC_VPORT_ZMIN_14 | ||
235 | 0x3f800000, // PA_SC_VPORT_ZMAX_14 | ||
236 | 0x00000000, // PA_SC_VPORT_ZMIN_15 | ||
237 | 0x3f800000, // PA_SC_VPORT_ZMAX_15 | ||
238 | }; | ||
239 | static const u32 si_SECT_CONTEXT_def_2[] = | ||
240 | { | ||
241 | 0x00000000, // CP_PERFMON_CNTX_CNTL | ||
242 | 0x00000000, // CP_RINGID | ||
243 | 0x00000000, // CP_VMID | ||
244 | 0, // HOLE | ||
245 | 0, // HOLE | ||
246 | 0, // HOLE | ||
247 | 0, // HOLE | ||
248 | 0, // HOLE | ||
249 | 0, // HOLE | ||
250 | 0, // HOLE | ||
251 | 0, // HOLE | ||
252 | 0, // HOLE | ||
253 | 0, // HOLE | ||
254 | 0, // HOLE | ||
255 | 0, // HOLE | ||
256 | 0, // HOLE | ||
257 | 0, // HOLE | ||
258 | 0, // HOLE | ||
259 | 0, // HOLE | ||
260 | 0, // HOLE | ||
261 | 0, // HOLE | ||
262 | 0, // HOLE | ||
263 | 0, // HOLE | ||
264 | 0, // HOLE | ||
265 | 0, // HOLE | ||
266 | 0, // HOLE | ||
267 | 0, // HOLE | ||
268 | 0, // HOLE | ||
269 | 0, // HOLE | ||
270 | 0, // HOLE | ||
271 | 0, // HOLE | ||
272 | 0, // HOLE | ||
273 | 0, // HOLE | ||
274 | 0, // HOLE | ||
275 | 0, // HOLE | ||
276 | 0, // HOLE | ||
277 | 0, // HOLE | ||
278 | 0, // HOLE | ||
279 | 0, // HOLE | ||
280 | 0, // HOLE | ||
281 | 0xffffffff, // VGT_MAX_VTX_INDX | ||
282 | 0x00000000, // VGT_MIN_VTX_INDX | ||
283 | 0x00000000, // VGT_INDX_OFFSET | ||
284 | 0x00000000, // VGT_MULTI_PRIM_IB_RESET_INDX | ||
285 | 0, // HOLE | ||
286 | 0x00000000, // CB_BLEND_RED | ||
287 | 0x00000000, // CB_BLEND_GREEN | ||
288 | 0x00000000, // CB_BLEND_BLUE | ||
289 | 0x00000000, // CB_BLEND_ALPHA | ||
290 | 0, // HOLE | ||
291 | 0, // HOLE | ||
292 | 0x00000000, // DB_STENCIL_CONTROL | ||
293 | 0x00000000, // DB_STENCILREFMASK | ||
294 | 0x00000000, // DB_STENCILREFMASK_BF | ||
295 | 0, // HOLE | ||
296 | 0x00000000, // PA_CL_VPORT_XSCALE | ||
297 | 0x00000000, // PA_CL_VPORT_XOFFSET | ||
298 | 0x00000000, // PA_CL_VPORT_YSCALE | ||
299 | 0x00000000, // PA_CL_VPORT_YOFFSET | ||
300 | 0x00000000, // PA_CL_VPORT_ZSCALE | ||
301 | 0x00000000, // PA_CL_VPORT_ZOFFSET | ||
302 | 0x00000000, // PA_CL_VPORT_XSCALE_1 | ||
303 | 0x00000000, // PA_CL_VPORT_XOFFSET_1 | ||
304 | 0x00000000, // PA_CL_VPORT_YSCALE_1 | ||
305 | 0x00000000, // PA_CL_VPORT_YOFFSET_1 | ||
306 | 0x00000000, // PA_CL_VPORT_ZSCALE_1 | ||
307 | 0x00000000, // PA_CL_VPORT_ZOFFSET_1 | ||
308 | 0x00000000, // PA_CL_VPORT_XSCALE_2 | ||
309 | 0x00000000, // PA_CL_VPORT_XOFFSET_2 | ||
310 | 0x00000000, // PA_CL_VPORT_YSCALE_2 | ||
311 | 0x00000000, // PA_CL_VPORT_YOFFSET_2 | ||
312 | 0x00000000, // PA_CL_VPORT_ZSCALE_2 | ||
313 | 0x00000000, // PA_CL_VPORT_ZOFFSET_2 | ||
314 | 0x00000000, // PA_CL_VPORT_XSCALE_3 | ||
315 | 0x00000000, // PA_CL_VPORT_XOFFSET_3 | ||
316 | 0x00000000, // PA_CL_VPORT_YSCALE_3 | ||
317 | 0x00000000, // PA_CL_VPORT_YOFFSET_3 | ||
318 | 0x00000000, // PA_CL_VPORT_ZSCALE_3 | ||
319 | 0x00000000, // PA_CL_VPORT_ZOFFSET_3 | ||
320 | 0x00000000, // PA_CL_VPORT_XSCALE_4 | ||
321 | 0x00000000, // PA_CL_VPORT_XOFFSET_4 | ||
322 | 0x00000000, // PA_CL_VPORT_YSCALE_4 | ||
323 | 0x00000000, // PA_CL_VPORT_YOFFSET_4 | ||
324 | 0x00000000, // PA_CL_VPORT_ZSCALE_4 | ||
325 | 0x00000000, // PA_CL_VPORT_ZOFFSET_4 | ||
326 | 0x00000000, // PA_CL_VPORT_XSCALE_5 | ||
327 | 0x00000000, // PA_CL_VPORT_XOFFSET_5 | ||
328 | 0x00000000, // PA_CL_VPORT_YSCALE_5 | ||
329 | 0x00000000, // PA_CL_VPORT_YOFFSET_5 | ||
330 | 0x00000000, // PA_CL_VPORT_ZSCALE_5 | ||
331 | 0x00000000, // PA_CL_VPORT_ZOFFSET_5 | ||
332 | 0x00000000, // PA_CL_VPORT_XSCALE_6 | ||
333 | 0x00000000, // PA_CL_VPORT_XOFFSET_6 | ||
334 | 0x00000000, // PA_CL_VPORT_YSCALE_6 | ||
335 | 0x00000000, // PA_CL_VPORT_YOFFSET_6 | ||
336 | 0x00000000, // PA_CL_VPORT_ZSCALE_6 | ||
337 | 0x00000000, // PA_CL_VPORT_ZOFFSET_6 | ||
338 | 0x00000000, // PA_CL_VPORT_XSCALE_7 | ||
339 | 0x00000000, // PA_CL_VPORT_XOFFSET_7 | ||
340 | 0x00000000, // PA_CL_VPORT_YSCALE_7 | ||
341 | 0x00000000, // PA_CL_VPORT_YOFFSET_7 | ||
342 | 0x00000000, // PA_CL_VPORT_ZSCALE_7 | ||
343 | 0x00000000, // PA_CL_VPORT_ZOFFSET_7 | ||
344 | 0x00000000, // PA_CL_VPORT_XSCALE_8 | ||
345 | 0x00000000, // PA_CL_VPORT_XOFFSET_8 | ||
346 | 0x00000000, // PA_CL_VPORT_YSCALE_8 | ||
347 | 0x00000000, // PA_CL_VPORT_YOFFSET_8 | ||
348 | 0x00000000, // PA_CL_VPORT_ZSCALE_8 | ||
349 | 0x00000000, // PA_CL_VPORT_ZOFFSET_8 | ||
350 | 0x00000000, // PA_CL_VPORT_XSCALE_9 | ||
351 | 0x00000000, // PA_CL_VPORT_XOFFSET_9 | ||
352 | 0x00000000, // PA_CL_VPORT_YSCALE_9 | ||
353 | 0x00000000, // PA_CL_VPORT_YOFFSET_9 | ||
354 | 0x00000000, // PA_CL_VPORT_ZSCALE_9 | ||
355 | 0x00000000, // PA_CL_VPORT_ZOFFSET_9 | ||
356 | 0x00000000, // PA_CL_VPORT_XSCALE_10 | ||
357 | 0x00000000, // PA_CL_VPORT_XOFFSET_10 | ||
358 | 0x00000000, // PA_CL_VPORT_YSCALE_10 | ||
359 | 0x00000000, // PA_CL_VPORT_YOFFSET_10 | ||
360 | 0x00000000, // PA_CL_VPORT_ZSCALE_10 | ||
361 | 0x00000000, // PA_CL_VPORT_ZOFFSET_10 | ||
362 | 0x00000000, // PA_CL_VPORT_XSCALE_11 | ||
363 | 0x00000000, // PA_CL_VPORT_XOFFSET_11 | ||
364 | 0x00000000, // PA_CL_VPORT_YSCALE_11 | ||
365 | 0x00000000, // PA_CL_VPORT_YOFFSET_11 | ||
366 | 0x00000000, // PA_CL_VPORT_ZSCALE_11 | ||
367 | 0x00000000, // PA_CL_VPORT_ZOFFSET_11 | ||
368 | 0x00000000, // PA_CL_VPORT_XSCALE_12 | ||
369 | 0x00000000, // PA_CL_VPORT_XOFFSET_12 | ||
370 | 0x00000000, // PA_CL_VPORT_YSCALE_12 | ||
371 | 0x00000000, // PA_CL_VPORT_YOFFSET_12 | ||
372 | 0x00000000, // PA_CL_VPORT_ZSCALE_12 | ||
373 | 0x00000000, // PA_CL_VPORT_ZOFFSET_12 | ||
374 | 0x00000000, // PA_CL_VPORT_XSCALE_13 | ||
375 | 0x00000000, // PA_CL_VPORT_XOFFSET_13 | ||
376 | 0x00000000, // PA_CL_VPORT_YSCALE_13 | ||
377 | 0x00000000, // PA_CL_VPORT_YOFFSET_13 | ||
378 | 0x00000000, // PA_CL_VPORT_ZSCALE_13 | ||
379 | 0x00000000, // PA_CL_VPORT_ZOFFSET_13 | ||
380 | 0x00000000, // PA_CL_VPORT_XSCALE_14 | ||
381 | 0x00000000, // PA_CL_VPORT_XOFFSET_14 | ||
382 | 0x00000000, // PA_CL_VPORT_YSCALE_14 | ||
383 | 0x00000000, // PA_CL_VPORT_YOFFSET_14 | ||
384 | 0x00000000, // PA_CL_VPORT_ZSCALE_14 | ||
385 | 0x00000000, // PA_CL_VPORT_ZOFFSET_14 | ||
386 | 0x00000000, // PA_CL_VPORT_XSCALE_15 | ||
387 | 0x00000000, // PA_CL_VPORT_XOFFSET_15 | ||
388 | 0x00000000, // PA_CL_VPORT_YSCALE_15 | ||
389 | 0x00000000, // PA_CL_VPORT_YOFFSET_15 | ||
390 | 0x00000000, // PA_CL_VPORT_ZSCALE_15 | ||
391 | 0x00000000, // PA_CL_VPORT_ZOFFSET_15 | ||
392 | 0x00000000, // PA_CL_UCP_0_X | ||
393 | 0x00000000, // PA_CL_UCP_0_Y | ||
394 | 0x00000000, // PA_CL_UCP_0_Z | ||
395 | 0x00000000, // PA_CL_UCP_0_W | ||
396 | 0x00000000, // PA_CL_UCP_1_X | ||
397 | 0x00000000, // PA_CL_UCP_1_Y | ||
398 | 0x00000000, // PA_CL_UCP_1_Z | ||
399 | 0x00000000, // PA_CL_UCP_1_W | ||
400 | 0x00000000, // PA_CL_UCP_2_X | ||
401 | 0x00000000, // PA_CL_UCP_2_Y | ||
402 | 0x00000000, // PA_CL_UCP_2_Z | ||
403 | 0x00000000, // PA_CL_UCP_2_W | ||
404 | 0x00000000, // PA_CL_UCP_3_X | ||
405 | 0x00000000, // PA_CL_UCP_3_Y | ||
406 | 0x00000000, // PA_CL_UCP_3_Z | ||
407 | 0x00000000, // PA_CL_UCP_3_W | ||
408 | 0x00000000, // PA_CL_UCP_4_X | ||
409 | 0x00000000, // PA_CL_UCP_4_Y | ||
410 | 0x00000000, // PA_CL_UCP_4_Z | ||
411 | 0x00000000, // PA_CL_UCP_4_W | ||
412 | 0x00000000, // PA_CL_UCP_5_X | ||
413 | 0x00000000, // PA_CL_UCP_5_Y | ||
414 | 0x00000000, // PA_CL_UCP_5_Z | ||
415 | 0x00000000, // PA_CL_UCP_5_W | ||
416 | 0, // HOLE | ||
417 | 0, // HOLE | ||
418 | 0, // HOLE | ||
419 | 0, // HOLE | ||
420 | 0, // HOLE | ||
421 | 0, // HOLE | ||
422 | 0, // HOLE | ||
423 | 0, // HOLE | ||
424 | 0, // HOLE | ||
425 | 0, // HOLE | ||
426 | 0x00000000, // SPI_PS_INPUT_CNTL_0 | ||
427 | 0x00000000, // SPI_PS_INPUT_CNTL_1 | ||
428 | 0x00000000, // SPI_PS_INPUT_CNTL_2 | ||
429 | 0x00000000, // SPI_PS_INPUT_CNTL_3 | ||
430 | 0x00000000, // SPI_PS_INPUT_CNTL_4 | ||
431 | 0x00000000, // SPI_PS_INPUT_CNTL_5 | ||
432 | 0x00000000, // SPI_PS_INPUT_CNTL_6 | ||
433 | 0x00000000, // SPI_PS_INPUT_CNTL_7 | ||
434 | 0x00000000, // SPI_PS_INPUT_CNTL_8 | ||
435 | 0x00000000, // SPI_PS_INPUT_CNTL_9 | ||
436 | 0x00000000, // SPI_PS_INPUT_CNTL_10 | ||
437 | 0x00000000, // SPI_PS_INPUT_CNTL_11 | ||
438 | 0x00000000, // SPI_PS_INPUT_CNTL_12 | ||
439 | 0x00000000, // SPI_PS_INPUT_CNTL_13 | ||
440 | 0x00000000, // SPI_PS_INPUT_CNTL_14 | ||
441 | 0x00000000, // SPI_PS_INPUT_CNTL_15 | ||
442 | 0x00000000, // SPI_PS_INPUT_CNTL_16 | ||
443 | 0x00000000, // SPI_PS_INPUT_CNTL_17 | ||
444 | 0x00000000, // SPI_PS_INPUT_CNTL_18 | ||
445 | 0x00000000, // SPI_PS_INPUT_CNTL_19 | ||
446 | 0x00000000, // SPI_PS_INPUT_CNTL_20 | ||
447 | 0x00000000, // SPI_PS_INPUT_CNTL_21 | ||
448 | 0x00000000, // SPI_PS_INPUT_CNTL_22 | ||
449 | 0x00000000, // SPI_PS_INPUT_CNTL_23 | ||
450 | 0x00000000, // SPI_PS_INPUT_CNTL_24 | ||
451 | 0x00000000, // SPI_PS_INPUT_CNTL_25 | ||
452 | 0x00000000, // SPI_PS_INPUT_CNTL_26 | ||
453 | 0x00000000, // SPI_PS_INPUT_CNTL_27 | ||
454 | 0x00000000, // SPI_PS_INPUT_CNTL_28 | ||
455 | 0x00000000, // SPI_PS_INPUT_CNTL_29 | ||
456 | 0x00000000, // SPI_PS_INPUT_CNTL_30 | ||
457 | 0x00000000, // SPI_PS_INPUT_CNTL_31 | ||
458 | 0x00000000, // SPI_VS_OUT_CONFIG | ||
459 | 0, // HOLE | ||
460 | 0x00000000, // SPI_PS_INPUT_ENA | ||
461 | 0x00000000, // SPI_PS_INPUT_ADDR | ||
462 | 0x00000000, // SPI_INTERP_CONTROL_0 | ||
463 | 0x00000002, // SPI_PS_IN_CONTROL | ||
464 | 0, // HOLE | ||
465 | 0x00000000, // SPI_BARYC_CNTL | ||
466 | 0, // HOLE | ||
467 | 0x00000000, // SPI_TMPRING_SIZE | ||
468 | 0, // HOLE | ||
469 | 0, // HOLE | ||
470 | 0, // HOLE | ||
471 | 0, // HOLE | ||
472 | 0, // HOLE | ||
473 | 0, // HOLE | ||
474 | 0x00000000, // SPI_WAVE_MGMT_1 | ||
475 | 0x00000000, // SPI_WAVE_MGMT_2 | ||
476 | 0x00000000, // SPI_SHADER_POS_FORMAT | ||
477 | 0x00000000, // SPI_SHADER_Z_FORMAT | ||
478 | 0x00000000, // SPI_SHADER_COL_FORMAT | ||
479 | 0, // HOLE | ||
480 | 0, // HOLE | ||
481 | 0, // HOLE | ||
482 | 0, // HOLE | ||
483 | 0, // HOLE | ||
484 | 0, // HOLE | ||
485 | 0, // HOLE | ||
486 | 0, // HOLE | ||
487 | 0, // HOLE | ||
488 | 0, // HOLE | ||
489 | 0, // HOLE | ||
490 | 0, // HOLE | ||
491 | 0, // HOLE | ||
492 | 0, // HOLE | ||
493 | 0, // HOLE | ||
494 | 0, // HOLE | ||
495 | 0, // HOLE | ||
496 | 0, // HOLE | ||
497 | 0, // HOLE | ||
498 | 0, // HOLE | ||
499 | 0, // HOLE | ||
500 | 0, // HOLE | ||
501 | 0, // HOLE | ||
502 | 0, // HOLE | ||
503 | 0, // HOLE | ||
504 | 0, // HOLE | ||
505 | 0x00000000, // CB_BLEND0_CONTROL | ||
506 | 0x00000000, // CB_BLEND1_CONTROL | ||
507 | 0x00000000, // CB_BLEND2_CONTROL | ||
508 | 0x00000000, // CB_BLEND3_CONTROL | ||
509 | 0x00000000, // CB_BLEND4_CONTROL | ||
510 | 0x00000000, // CB_BLEND5_CONTROL | ||
511 | 0x00000000, // CB_BLEND6_CONTROL | ||
512 | 0x00000000, // CB_BLEND7_CONTROL | ||
513 | }; | ||
514 | static const u32 si_SECT_CONTEXT_def_3[] = | ||
515 | { | ||
516 | 0x00000000, // PA_CL_POINT_X_RAD | ||
517 | 0x00000000, // PA_CL_POINT_Y_RAD | ||
518 | 0x00000000, // PA_CL_POINT_SIZE | ||
519 | 0x00000000, // PA_CL_POINT_CULL_RAD | ||
520 | 0x00000000, // VGT_DMA_BASE_HI | ||
521 | 0x00000000, // VGT_DMA_BASE | ||
522 | }; | ||
523 | static const u32 si_SECT_CONTEXT_def_4[] = | ||
524 | { | ||
525 | 0x00000000, // DB_DEPTH_CONTROL | ||
526 | 0x00000000, // DB_EQAA | ||
527 | 0x00000000, // CB_COLOR_CONTROL | ||
528 | 0x00000000, // DB_SHADER_CONTROL | ||
529 | 0x00090000, // PA_CL_CLIP_CNTL | ||
530 | 0x00000004, // PA_SU_SC_MODE_CNTL | ||
531 | 0x00000000, // PA_CL_VTE_CNTL | ||
532 | 0x00000000, // PA_CL_VS_OUT_CNTL | ||
533 | 0x00000000, // PA_CL_NANINF_CNTL | ||
534 | 0x00000000, // PA_SU_LINE_STIPPLE_CNTL | ||
535 | 0x00000000, // PA_SU_LINE_STIPPLE_SCALE | ||
536 | 0x00000000, // PA_SU_PRIM_FILTER_CNTL | ||
537 | 0, // HOLE | ||
538 | 0, // HOLE | ||
539 | 0, // HOLE | ||
540 | 0, // HOLE | ||
541 | 0, // HOLE | ||
542 | 0, // HOLE | ||
543 | 0, // HOLE | ||
544 | 0, // HOLE | ||
545 | 0, // HOLE | ||
546 | 0, // HOLE | ||
547 | 0, // HOLE | ||
548 | 0, // HOLE | ||
549 | 0, // HOLE | ||
550 | 0, // HOLE | ||
551 | 0, // HOLE | ||
552 | 0, // HOLE | ||
553 | 0, // HOLE | ||
554 | 0, // HOLE | ||
555 | 0, // HOLE | ||
556 | 0, // HOLE | ||
557 | 0, // HOLE | ||
558 | 0, // HOLE | ||
559 | 0, // HOLE | ||
560 | 0, // HOLE | ||
561 | 0, // HOLE | ||
562 | 0, // HOLE | ||
563 | 0, // HOLE | ||
564 | 0, // HOLE | ||
565 | 0, // HOLE | ||
566 | 0, // HOLE | ||
567 | 0, // HOLE | ||
568 | 0, // HOLE | ||
569 | 0, // HOLE | ||
570 | 0, // HOLE | ||
571 | 0, // HOLE | ||
572 | 0, // HOLE | ||
573 | 0, // HOLE | ||
574 | 0, // HOLE | ||
575 | 0, // HOLE | ||
576 | 0, // HOLE | ||
577 | 0, // HOLE | ||
578 | 0, // HOLE | ||
579 | 0, // HOLE | ||
580 | 0, // HOLE | ||
581 | 0, // HOLE | ||
582 | 0, // HOLE | ||
583 | 0, // HOLE | ||
584 | 0, // HOLE | ||
585 | 0, // HOLE | ||
586 | 0, // HOLE | ||
587 | 0, // HOLE | ||
588 | 0, // HOLE | ||
589 | 0, // HOLE | ||
590 | 0, // HOLE | ||
591 | 0, // HOLE | ||
592 | 0, // HOLE | ||
593 | 0, // HOLE | ||
594 | 0, // HOLE | ||
595 | 0, // HOLE | ||
596 | 0, // HOLE | ||
597 | 0, // HOLE | ||
598 | 0, // HOLE | ||
599 | 0, // HOLE | ||
600 | 0, // HOLE | ||
601 | 0, // HOLE | ||
602 | 0, // HOLE | ||
603 | 0, // HOLE | ||
604 | 0, // HOLE | ||
605 | 0, // HOLE | ||
606 | 0, // HOLE | ||
607 | 0, // HOLE | ||
608 | 0, // HOLE | ||
609 | 0, // HOLE | ||
610 | 0, // HOLE | ||
611 | 0, // HOLE | ||
612 | 0, // HOLE | ||
613 | 0, // HOLE | ||
614 | 0, // HOLE | ||
615 | 0, // HOLE | ||
616 | 0, // HOLE | ||
617 | 0, // HOLE | ||
618 | 0, // HOLE | ||
619 | 0, // HOLE | ||
620 | 0, // HOLE | ||
621 | 0, // HOLE | ||
622 | 0, // HOLE | ||
623 | 0, // HOLE | ||
624 | 0, // HOLE | ||
625 | 0, // HOLE | ||
626 | 0, // HOLE | ||
627 | 0, // HOLE | ||
628 | 0, // HOLE | ||
629 | 0, // HOLE | ||
630 | 0, // HOLE | ||
631 | 0, // HOLE | ||
632 | 0, // HOLE | ||
633 | 0, // HOLE | ||
634 | 0, // HOLE | ||
635 | 0, // HOLE | ||
636 | 0, // HOLE | ||
637 | 0, // HOLE | ||
638 | 0, // HOLE | ||
639 | 0, // HOLE | ||
640 | 0, // HOLE | ||
641 | 0, // HOLE | ||
642 | 0, // HOLE | ||
643 | 0, // HOLE | ||
644 | 0, // HOLE | ||
645 | 0, // HOLE | ||
646 | 0, // HOLE | ||
647 | 0, // HOLE | ||
648 | 0, // HOLE | ||
649 | 0, // HOLE | ||
650 | 0, // HOLE | ||
651 | 0, // HOLE | ||
652 | 0, // HOLE | ||
653 | 0x00000000, // PA_SU_POINT_SIZE | ||
654 | 0x00000000, // PA_SU_POINT_MINMAX | ||
655 | 0x00000000, // PA_SU_LINE_CNTL | ||
656 | 0x00000000, // PA_SC_LINE_STIPPLE | ||
657 | 0x00000000, // VGT_OUTPUT_PATH_CNTL | ||
658 | 0x00000000, // VGT_HOS_CNTL | ||
659 | 0x00000000, // VGT_HOS_MAX_TESS_LEVEL | ||
660 | 0x00000000, // VGT_HOS_MIN_TESS_LEVEL | ||
661 | 0x00000000, // VGT_HOS_REUSE_DEPTH | ||
662 | 0x00000000, // VGT_GROUP_PRIM_TYPE | ||
663 | 0x00000000, // VGT_GROUP_FIRST_DECR | ||
664 | 0x00000000, // VGT_GROUP_DECR | ||
665 | 0x00000000, // VGT_GROUP_VECT_0_CNTL | ||
666 | 0x00000000, // VGT_GROUP_VECT_1_CNTL | ||
667 | 0x00000000, // VGT_GROUP_VECT_0_FMT_CNTL | ||
668 | 0x00000000, // VGT_GROUP_VECT_1_FMT_CNTL | ||
669 | 0x00000000, // VGT_GS_MODE | ||
670 | 0, // HOLE | ||
671 | 0x00000000, // PA_SC_MODE_CNTL_0 | ||
672 | 0x00000000, // PA_SC_MODE_CNTL_1 | ||
673 | 0x00000000, // VGT_ENHANCE | ||
674 | 0x00000100, // VGT_GS_PER_ES | ||
675 | 0x00000080, // VGT_ES_PER_GS | ||
676 | 0x00000002, // VGT_GS_PER_VS | ||
677 | 0x00000000, // VGT_GSVS_RING_OFFSET_1 | ||
678 | 0x00000000, // VGT_GSVS_RING_OFFSET_2 | ||
679 | 0x00000000, // VGT_GSVS_RING_OFFSET_3 | ||
680 | 0x00000000, // VGT_GS_OUT_PRIM_TYPE | ||
681 | 0x00000000, // IA_ENHANCE | ||
682 | }; | ||
683 | static const u32 si_SECT_CONTEXT_def_5[] = | ||
684 | { | ||
685 | 0x00000000, // VGT_PRIMITIVEID_EN | ||
686 | }; | ||
687 | static const u32 si_SECT_CONTEXT_def_6[] = | ||
688 | { | ||
689 | 0x00000000, // VGT_PRIMITIVEID_RESET | ||
690 | }; | ||
691 | static const u32 si_SECT_CONTEXT_def_7[] = | ||
692 | { | ||
693 | 0x00000000, // VGT_MULTI_PRIM_IB_RESET_EN | ||
694 | 0, // HOLE | ||
695 | 0, // HOLE | ||
696 | 0x00000000, // VGT_INSTANCE_STEP_RATE_0 | ||
697 | 0x00000000, // VGT_INSTANCE_STEP_RATE_1 | ||
698 | 0x000000ff, // IA_MULTI_VGT_PARAM | ||
699 | 0x00000000, // VGT_ESGS_RING_ITEMSIZE | ||
700 | 0x00000000, // VGT_GSVS_RING_ITEMSIZE | ||
701 | 0x00000000, // VGT_REUSE_OFF | ||
702 | 0x00000000, // VGT_VTX_CNT_EN | ||
703 | 0x00000000, // DB_HTILE_SURFACE | ||
704 | 0x00000000, // DB_SRESULTS_COMPARE_STATE0 | ||
705 | 0x00000000, // DB_SRESULTS_COMPARE_STATE1 | ||
706 | 0x00000000, // DB_PRELOAD_CONTROL | ||
707 | 0, // HOLE | ||
708 | 0x00000000, // VGT_STRMOUT_BUFFER_SIZE_0 | ||
709 | 0x00000000, // VGT_STRMOUT_VTX_STRIDE_0 | ||
710 | 0, // HOLE | ||
711 | 0x00000000, // VGT_STRMOUT_BUFFER_OFFSET_0 | ||
712 | 0x00000000, // VGT_STRMOUT_BUFFER_SIZE_1 | ||
713 | 0x00000000, // VGT_STRMOUT_VTX_STRIDE_1 | ||
714 | 0, // HOLE | ||
715 | 0x00000000, // VGT_STRMOUT_BUFFER_OFFSET_1 | ||
716 | 0x00000000, // VGT_STRMOUT_BUFFER_SIZE_2 | ||
717 | 0x00000000, // VGT_STRMOUT_VTX_STRIDE_2 | ||
718 | 0, // HOLE | ||
719 | 0x00000000, // VGT_STRMOUT_BUFFER_OFFSET_2 | ||
720 | 0x00000000, // VGT_STRMOUT_BUFFER_SIZE_3 | ||
721 | 0x00000000, // VGT_STRMOUT_VTX_STRIDE_3 | ||
722 | 0, // HOLE | ||
723 | 0x00000000, // VGT_STRMOUT_BUFFER_OFFSET_3 | ||
724 | 0, // HOLE | ||
725 | 0, // HOLE | ||
726 | 0, // HOLE | ||
727 | 0, // HOLE | ||
728 | 0, // HOLE | ||
729 | 0, // HOLE | ||
730 | 0x00000000, // VGT_STRMOUT_DRAW_OPAQUE_OFFSET | ||
731 | 0x00000000, // VGT_STRMOUT_DRAW_OPAQUE_BUFFER_FILLED_SIZE | ||
732 | 0x00000000, // VGT_STRMOUT_DRAW_OPAQUE_VERTEX_STRIDE | ||
733 | 0, // HOLE | ||
734 | 0x00000000, // VGT_GS_MAX_VERT_OUT | ||
735 | 0, // HOLE | ||
736 | 0, // HOLE | ||
737 | 0, // HOLE | ||
738 | 0, // HOLE | ||
739 | 0, // HOLE | ||
740 | 0, // HOLE | ||
741 | 0x00000000, // VGT_SHADER_STAGES_EN | ||
742 | 0x00000000, // VGT_LS_HS_CONFIG | ||
743 | 0x00000000, // VGT_GS_VERT_ITEMSIZE | ||
744 | 0x00000000, // VGT_GS_VERT_ITEMSIZE_1 | ||
745 | 0x00000000, // VGT_GS_VERT_ITEMSIZE_2 | ||
746 | 0x00000000, // VGT_GS_VERT_ITEMSIZE_3 | ||
747 | 0x00000000, // VGT_TF_PARAM | ||
748 | 0x00000000, // DB_ALPHA_TO_MASK | ||
749 | 0, // HOLE | ||
750 | 0x00000000, // PA_SU_POLY_OFFSET_DB_FMT_CNTL | ||
751 | 0x00000000, // PA_SU_POLY_OFFSET_CLAMP | ||
752 | 0x00000000, // PA_SU_POLY_OFFSET_FRONT_SCALE | ||
753 | 0x00000000, // PA_SU_POLY_OFFSET_FRONT_OFFSET | ||
754 | 0x00000000, // PA_SU_POLY_OFFSET_BACK_SCALE | ||
755 | 0x00000000, // PA_SU_POLY_OFFSET_BACK_OFFSET | ||
756 | 0x00000000, // VGT_GS_INSTANCE_CNT | ||
757 | 0x00000000, // VGT_STRMOUT_CONFIG | ||
758 | 0x00000000, // VGT_STRMOUT_BUFFER_CONFIG | ||
759 | 0, // HOLE | ||
760 | 0, // HOLE | ||
761 | 0, // HOLE | ||
762 | 0, // HOLE | ||
763 | 0, // HOLE | ||
764 | 0, // HOLE | ||
765 | 0, // HOLE | ||
766 | 0, // HOLE | ||
767 | 0, // HOLE | ||
768 | 0, // HOLE | ||
769 | 0, // HOLE | ||
770 | 0, // HOLE | ||
771 | 0, // HOLE | ||
772 | 0, // HOLE | ||
773 | 0x00000000, // PA_SC_CENTROID_PRIORITY_0 | ||
774 | 0x00000000, // PA_SC_CENTROID_PRIORITY_1 | ||
775 | 0x00001000, // PA_SC_LINE_CNTL | ||
776 | 0x00000000, // PA_SC_AA_CONFIG | ||
777 | 0x00000005, // PA_SU_VTX_CNTL | ||
778 | 0x3f800000, // PA_CL_GB_VERT_CLIP_ADJ | ||
779 | 0x3f800000, // PA_CL_GB_VERT_DISC_ADJ | ||
780 | 0x3f800000, // PA_CL_GB_HORZ_CLIP_ADJ | ||
781 | 0x3f800000, // PA_CL_GB_HORZ_DISC_ADJ | ||
782 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0 | ||
783 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_1 | ||
784 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_2 | ||
785 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_3 | ||
786 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_0 | ||
787 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_1 | ||
788 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_2 | ||
789 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_3 | ||
790 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_0 | ||
791 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_1 | ||
792 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_2 | ||
793 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_3 | ||
794 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_0 | ||
795 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_1 | ||
796 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_2 | ||
797 | 0x00000000, // PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_3 | ||
798 | 0xffffffff, // PA_SC_AA_MASK_X0Y0_X1Y0 | ||
799 | 0xffffffff, // PA_SC_AA_MASK_X0Y1_X1Y1 | ||
800 | 0, // HOLE | ||
801 | 0, // HOLE | ||
802 | 0, // HOLE | ||
803 | 0, // HOLE | ||
804 | 0, // HOLE | ||
805 | 0, // HOLE | ||
806 | 0x0000000e, // VGT_VERTEX_REUSE_BLOCK_CNTL | ||
807 | 0x00000010, // VGT_OUT_DEALLOC_CNTL | ||
808 | 0x00000000, // CB_COLOR0_BASE | ||
809 | 0x00000000, // CB_COLOR0_PITCH | ||
810 | 0x00000000, // CB_COLOR0_SLICE | ||
811 | 0x00000000, // CB_COLOR0_VIEW | ||
812 | 0x00000000, // CB_COLOR0_INFO | ||
813 | 0x00000000, // CB_COLOR0_ATTRIB | ||
814 | 0, // HOLE | ||
815 | 0x00000000, // CB_COLOR0_CMASK | ||
816 | 0x00000000, // CB_COLOR0_CMASK_SLICE | ||
817 | 0x00000000, // CB_COLOR0_FMASK | ||
818 | 0x00000000, // CB_COLOR0_FMASK_SLICE | ||
819 | 0x00000000, // CB_COLOR0_CLEAR_WORD0 | ||
820 | 0x00000000, // CB_COLOR0_CLEAR_WORD1 | ||
821 | 0, // HOLE | ||
822 | 0, // HOLE | ||
823 | 0x00000000, // CB_COLOR1_BASE | ||
824 | 0x00000000, // CB_COLOR1_PITCH | ||
825 | 0x00000000, // CB_COLOR1_SLICE | ||
826 | 0x00000000, // CB_COLOR1_VIEW | ||
827 | 0x00000000, // CB_COLOR1_INFO | ||
828 | 0x00000000, // CB_COLOR1_ATTRIB | ||
829 | 0, // HOLE | ||
830 | 0x00000000, // CB_COLOR1_CMASK | ||
831 | 0x00000000, // CB_COLOR1_CMASK_SLICE | ||
832 | 0x00000000, // CB_COLOR1_FMASK | ||
833 | 0x00000000, // CB_COLOR1_FMASK_SLICE | ||
834 | 0x00000000, // CB_COLOR1_CLEAR_WORD0 | ||
835 | 0x00000000, // CB_COLOR1_CLEAR_WORD1 | ||
836 | 0, // HOLE | ||
837 | 0, // HOLE | ||
838 | 0x00000000, // CB_COLOR2_BASE | ||
839 | 0x00000000, // CB_COLOR2_PITCH | ||
840 | 0x00000000, // CB_COLOR2_SLICE | ||
841 | 0x00000000, // CB_COLOR2_VIEW | ||
842 | 0x00000000, // CB_COLOR2_INFO | ||
843 | 0x00000000, // CB_COLOR2_ATTRIB | ||
844 | 0, // HOLE | ||
845 | 0x00000000, // CB_COLOR2_CMASK | ||
846 | 0x00000000, // CB_COLOR2_CMASK_SLICE | ||
847 | 0x00000000, // CB_COLOR2_FMASK | ||
848 | 0x00000000, // CB_COLOR2_FMASK_SLICE | ||
849 | 0x00000000, // CB_COLOR2_CLEAR_WORD0 | ||
850 | 0x00000000, // CB_COLOR2_CLEAR_WORD1 | ||
851 | 0, // HOLE | ||
852 | 0, // HOLE | ||
853 | 0x00000000, // CB_COLOR3_BASE | ||
854 | 0x00000000, // CB_COLOR3_PITCH | ||
855 | 0x00000000, // CB_COLOR3_SLICE | ||
856 | 0x00000000, // CB_COLOR3_VIEW | ||
857 | 0x00000000, // CB_COLOR3_INFO | ||
858 | 0x00000000, // CB_COLOR3_ATTRIB | ||
859 | 0, // HOLE | ||
860 | 0x00000000, // CB_COLOR3_CMASK | ||
861 | 0x00000000, // CB_COLOR3_CMASK_SLICE | ||
862 | 0x00000000, // CB_COLOR3_FMASK | ||
863 | 0x00000000, // CB_COLOR3_FMASK_SLICE | ||
864 | 0x00000000, // CB_COLOR3_CLEAR_WORD0 | ||
865 | 0x00000000, // CB_COLOR3_CLEAR_WORD1 | ||
866 | 0, // HOLE | ||
867 | 0, // HOLE | ||
868 | 0x00000000, // CB_COLOR4_BASE | ||
869 | 0x00000000, // CB_COLOR4_PITCH | ||
870 | 0x00000000, // CB_COLOR4_SLICE | ||
871 | 0x00000000, // CB_COLOR4_VIEW | ||
872 | 0x00000000, // CB_COLOR4_INFO | ||
873 | 0x00000000, // CB_COLOR4_ATTRIB | ||
874 | 0, // HOLE | ||
875 | 0x00000000, // CB_COLOR4_CMASK | ||
876 | 0x00000000, // CB_COLOR4_CMASK_SLICE | ||
877 | 0x00000000, // CB_COLOR4_FMASK | ||
878 | 0x00000000, // CB_COLOR4_FMASK_SLICE | ||
879 | 0x00000000, // CB_COLOR4_CLEAR_WORD0 | ||
880 | 0x00000000, // CB_COLOR4_CLEAR_WORD1 | ||
881 | 0, // HOLE | ||
882 | 0, // HOLE | ||
883 | 0x00000000, // CB_COLOR5_BASE | ||
884 | 0x00000000, // CB_COLOR5_PITCH | ||
885 | 0x00000000, // CB_COLOR5_SLICE | ||
886 | 0x00000000, // CB_COLOR5_VIEW | ||
887 | 0x00000000, // CB_COLOR5_INFO | ||
888 | 0x00000000, // CB_COLOR5_ATTRIB | ||
889 | 0, // HOLE | ||
890 | 0x00000000, // CB_COLOR5_CMASK | ||
891 | 0x00000000, // CB_COLOR5_CMASK_SLICE | ||
892 | 0x00000000, // CB_COLOR5_FMASK | ||
893 | 0x00000000, // CB_COLOR5_FMASK_SLICE | ||
894 | 0x00000000, // CB_COLOR5_CLEAR_WORD0 | ||
895 | 0x00000000, // CB_COLOR5_CLEAR_WORD1 | ||
896 | 0, // HOLE | ||
897 | 0, // HOLE | ||
898 | 0x00000000, // CB_COLOR6_BASE | ||
899 | 0x00000000, // CB_COLOR6_PITCH | ||
900 | 0x00000000, // CB_COLOR6_SLICE | ||
901 | 0x00000000, // CB_COLOR6_VIEW | ||
902 | 0x00000000, // CB_COLOR6_INFO | ||
903 | 0x00000000, // CB_COLOR6_ATTRIB | ||
904 | 0, // HOLE | ||
905 | 0x00000000, // CB_COLOR6_CMASK | ||
906 | 0x00000000, // CB_COLOR6_CMASK_SLICE | ||
907 | 0x00000000, // CB_COLOR6_FMASK | ||
908 | 0x00000000, // CB_COLOR6_FMASK_SLICE | ||
909 | 0x00000000, // CB_COLOR6_CLEAR_WORD0 | ||
910 | 0x00000000, // CB_COLOR6_CLEAR_WORD1 | ||
911 | 0, // HOLE | ||
912 | 0, // HOLE | ||
913 | 0x00000000, // CB_COLOR7_BASE | ||
914 | 0x00000000, // CB_COLOR7_PITCH | ||
915 | 0x00000000, // CB_COLOR7_SLICE | ||
916 | 0x00000000, // CB_COLOR7_VIEW | ||
917 | 0x00000000, // CB_COLOR7_INFO | ||
918 | 0x00000000, // CB_COLOR7_ATTRIB | ||
919 | 0, // HOLE | ||
920 | 0x00000000, // CB_COLOR7_CMASK | ||
921 | 0x00000000, // CB_COLOR7_CMASK_SLICE | ||
922 | 0x00000000, // CB_COLOR7_FMASK | ||
923 | 0x00000000, // CB_COLOR7_FMASK_SLICE | ||
924 | 0x00000000, // CB_COLOR7_CLEAR_WORD0 | ||
925 | 0x00000000, // CB_COLOR7_CLEAR_WORD1 | ||
926 | }; | ||
927 | static const struct cs_extent_def si_SECT_CONTEXT_defs[] = | ||
928 | { | ||
929 | {si_SECT_CONTEXT_def_1, 0x0000a000, 212 }, | ||
930 | {si_SECT_CONTEXT_def_2, 0x0000a0d8, 272 }, | ||
931 | {si_SECT_CONTEXT_def_3, 0x0000a1f5, 6 }, | ||
932 | {si_SECT_CONTEXT_def_4, 0x0000a200, 157 }, | ||
933 | {si_SECT_CONTEXT_def_5, 0x0000a2a1, 1 }, | ||
934 | {si_SECT_CONTEXT_def_6, 0x0000a2a3, 1 }, | ||
935 | {si_SECT_CONTEXT_def_7, 0x0000a2a5, 233 }, | ||
936 | { NULL, 0, 0 } | ||
937 | }; | ||
938 | static const struct cs_section_def si_cs_data[] = { | ||
939 | { si_SECT_CONTEXT_defs, SECT_CONTEXT }, | ||
940 | { NULL, SECT_NONE } | ||
941 | }; | ||
diff --git a/drivers/gpu/drm/amd/include/asic_reg/si/si_reg.h b/drivers/gpu/drm/amd/include/asic_reg/si/si_reg.h new file mode 100644 index 000000000000..895c8e2353e3 --- /dev/null +++ b/drivers/gpu/drm/amd/include/asic_reg/si/si_reg.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright 2010 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Alex Deucher | ||
23 | */ | ||
24 | #ifndef __SI_REG_H__ | ||
25 | #define __SI_REG_H__ | ||
26 | |||
27 | /* SI */ | ||
28 | #define SI_DC_GPIO_HPD_MASK 0x196c | ||
29 | #define SI_DC_GPIO_HPD_A 0x196d | ||
30 | #define SI_DC_GPIO_HPD_EN 0x196e | ||
31 | #define SI_DC_GPIO_HPD_Y 0x196f | ||
32 | |||
33 | #define SI_GRPH_CONTROL 0x1a01 | ||
34 | # define SI_GRPH_DEPTH(x) (((x) & 0x3) << 0) | ||
35 | # define SI_GRPH_DEPTH_8BPP 0 | ||
36 | # define SI_GRPH_DEPTH_16BPP 1 | ||
37 | # define SI_GRPH_DEPTH_32BPP 2 | ||
38 | # define SI_GRPH_NUM_BANKS(x) (((x) & 0x3) << 2) | ||
39 | # define SI_ADDR_SURF_2_BANK 0 | ||
40 | # define SI_ADDR_SURF_4_BANK 1 | ||
41 | # define SI_ADDR_SURF_8_BANK 2 | ||
42 | # define SI_ADDR_SURF_16_BANK 3 | ||
43 | # define SI_GRPH_Z(x) (((x) & 0x3) << 4) | ||
44 | # define SI_GRPH_BANK_WIDTH(x) (((x) & 0x3) << 6) | ||
45 | # define SI_ADDR_SURF_BANK_WIDTH_1 0 | ||
46 | # define SI_ADDR_SURF_BANK_WIDTH_2 1 | ||
47 | # define SI_ADDR_SURF_BANK_WIDTH_4 2 | ||
48 | # define SI_ADDR_SURF_BANK_WIDTH_8 3 | ||
49 | # define SI_GRPH_FORMAT(x) (((x) & 0x7) << 8) | ||
50 | /* 8 BPP */ | ||
51 | # define SI_GRPH_FORMAT_INDEXED 0 | ||
52 | /* 16 BPP */ | ||
53 | # define SI_GRPH_FORMAT_ARGB1555 0 | ||
54 | # define SI_GRPH_FORMAT_ARGB565 1 | ||
55 | # define SI_GRPH_FORMAT_ARGB4444 2 | ||
56 | # define SI_GRPH_FORMAT_AI88 3 | ||
57 | # define SI_GRPH_FORMAT_MONO16 4 | ||
58 | # define SI_GRPH_FORMAT_BGRA5551 5 | ||
59 | /* 32 BPP */ | ||
60 | # define SI_GRPH_FORMAT_ARGB8888 0 | ||
61 | # define SI_GRPH_FORMAT_ARGB2101010 1 | ||
62 | # define SI_GRPH_FORMAT_32BPP_DIG 2 | ||
63 | # define SI_GRPH_FORMAT_8B_ARGB2101010 3 | ||
64 | # define SI_GRPH_FORMAT_BGRA1010102 4 | ||
65 | # define SI_GRPH_FORMAT_8B_BGRA1010102 5 | ||
66 | # define SI_GRPH_FORMAT_RGB111110 6 | ||
67 | # define SI_GRPH_FORMAT_BGR101111 7 | ||
68 | # define SI_GRPH_BANK_HEIGHT(x) (((x) & 0x3) << 11) | ||
69 | # define SI_ADDR_SURF_BANK_HEIGHT_1 0 | ||
70 | # define SI_ADDR_SURF_BANK_HEIGHT_2 1 | ||
71 | # define SI_ADDR_SURF_BANK_HEIGHT_4 2 | ||
72 | # define SI_ADDR_SURF_BANK_HEIGHT_8 3 | ||
73 | # define SI_GRPH_TILE_SPLIT(x) (((x) & 0x7) << 13) | ||
74 | # define SI_ADDR_SURF_TILE_SPLIT_64B 0 | ||
75 | # define SI_ADDR_SURF_TILE_SPLIT_128B 1 | ||
76 | # define SI_ADDR_SURF_TILE_SPLIT_256B 2 | ||
77 | # define SI_ADDR_SURF_TILE_SPLIT_512B 3 | ||
78 | # define SI_ADDR_SURF_TILE_SPLIT_1KB 4 | ||
79 | # define SI_ADDR_SURF_TILE_SPLIT_2KB 5 | ||
80 | # define SI_ADDR_SURF_TILE_SPLIT_4KB 6 | ||
81 | # define SI_GRPH_MACRO_TILE_ASPECT(x) (((x) & 0x3) << 18) | ||
82 | # define SI_ADDR_SURF_MACRO_TILE_ASPECT_1 0 | ||
83 | # define SI_ADDR_SURF_MACRO_TILE_ASPECT_2 1 | ||
84 | # define SI_ADDR_SURF_MACRO_TILE_ASPECT_4 2 | ||
85 | # define SI_ADDR_SURF_MACRO_TILE_ASPECT_8 3 | ||
86 | # define SI_GRPH_ARRAY_MODE(x) (((x) & 0x7) << 20) | ||
87 | # define SI_GRPH_ARRAY_LINEAR_GENERAL 0 | ||
88 | # define SI_GRPH_ARRAY_LINEAR_ALIGNED 1 | ||
89 | # define SI_GRPH_ARRAY_1D_TILED_THIN1 2 | ||
90 | # define SI_GRPH_ARRAY_2D_TILED_THIN1 4 | ||
91 | # define SI_GRPH_PIPE_CONFIG(x) (((x) & 0x1f) << 24) | ||
92 | # define SI_ADDR_SURF_P2 0 | ||
93 | # define SI_ADDR_SURF_P4_8x16 4 | ||
94 | # define SI_ADDR_SURF_P4_16x16 5 | ||
95 | # define SI_ADDR_SURF_P4_16x32 6 | ||
96 | # define SI_ADDR_SURF_P4_32x32 7 | ||
97 | # define SI_ADDR_SURF_P8_16x16_8x16 8 | ||
98 | # define SI_ADDR_SURF_P8_16x32_8x16 9 | ||
99 | # define SI_ADDR_SURF_P8_32x32_8x16 10 | ||
100 | # define SI_ADDR_SURF_P8_16x32_16x16 11 | ||
101 | # define SI_ADDR_SURF_P8_32x32_16x16 12 | ||
102 | # define SI_ADDR_SURF_P8_32x32_16x32 13 | ||
103 | # define SI_ADDR_SURF_P8_32x64_32x32 14 | ||
104 | |||
105 | #endif | ||
diff --git a/drivers/gpu/drm/amd/include/asic_reg/si/sid.h b/drivers/gpu/drm/amd/include/asic_reg/si/sid.h new file mode 100644 index 000000000000..8c5608a4d526 --- /dev/null +++ b/drivers/gpu/drm/amd/include/asic_reg/si/sid.h | |||
@@ -0,0 +1,2426 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Alex Deucher | ||
23 | */ | ||
24 | #ifndef SI_H | ||
25 | #define SI_H | ||
26 | |||
27 | #define TAHITI_RB_BITMAP_WIDTH_PER_SH 2 | ||
28 | |||
29 | #define TAHITI_GB_ADDR_CONFIG_GOLDEN 0x12011003 | ||
30 | #define VERDE_GB_ADDR_CONFIG_GOLDEN 0x12010002 | ||
31 | #define HAINAN_GB_ADDR_CONFIG_GOLDEN 0x02010001 | ||
32 | |||
33 | #define SI_MAX_SH_GPRS 256 | ||
34 | #define SI_MAX_TEMP_GPRS 16 | ||
35 | #define SI_MAX_SH_THREADS 256 | ||
36 | #define SI_MAX_SH_STACK_ENTRIES 4096 | ||
37 | #define SI_MAX_FRC_EOV_CNT 16384 | ||
38 | #define SI_MAX_BACKENDS 8 | ||
39 | #define SI_MAX_BACKENDS_MASK 0xFF | ||
40 | #define SI_MAX_BACKENDS_PER_SE_MASK 0x0F | ||
41 | #define SI_MAX_SIMDS 12 | ||
42 | #define SI_MAX_SIMDS_MASK 0x0FFF | ||
43 | #define SI_MAX_SIMDS_PER_SE_MASK 0x00FF | ||
44 | #define SI_MAX_PIPES 8 | ||
45 | #define SI_MAX_PIPES_MASK 0xFF | ||
46 | #define SI_MAX_PIPES_PER_SIMD_MASK 0x3F | ||
47 | #define SI_MAX_LDS_NUM 0xFFFF | ||
48 | #define SI_MAX_TCC 16 | ||
49 | #define SI_MAX_TCC_MASK 0xFFFF | ||
50 | |||
51 | #define AMDGPU_NUM_OF_VMIDS 8 | ||
52 | |||
53 | /* SMC IND accessor regs */ | ||
54 | #define SMC_IND_INDEX_0 0x80 | ||
55 | #define SMC_IND_DATA_0 0x81 | ||
56 | |||
57 | #define SMC_IND_ACCESS_CNTL 0x8A | ||
58 | # define AUTO_INCREMENT_IND_0 (1 << 0) | ||
59 | #define SMC_MESSAGE_0 0x8B | ||
60 | #define SMC_RESP_0 0x8C | ||
61 | |||
62 | /* CG IND registers are accessed via SMC indirect space + SMC_CG_IND_START */ | ||
63 | #define SMC_CG_IND_START 0xc0030000 | ||
64 | #define SMC_CG_IND_END 0xc0040000 | ||
65 | |||
66 | #define CG_CGTT_LOCAL_0 0x400 | ||
67 | #define CG_CGTT_LOCAL_1 0x401 | ||
68 | |||
69 | /* SMC IND registers */ | ||
70 | #define SMC_SYSCON_RESET_CNTL 0x80000000 | ||
71 | # define RST_REG (1 << 0) | ||
72 | #define SMC_SYSCON_CLOCK_CNTL_0 0x80000004 | ||
73 | # define CK_DISABLE (1 << 0) | ||
74 | # define CKEN (1 << 24) | ||
75 | |||
76 | #define VGA_HDP_CONTROL 0xCA | ||
77 | #define VGA_MEMORY_DISABLE (1 << 4) | ||
78 | |||
79 | #define DCCG_DISP_SLOW_SELECT_REG 0x13F | ||
80 | #define DCCG_DISP1_SLOW_SELECT(x) ((x) << 0) | ||
81 | #define DCCG_DISP1_SLOW_SELECT_MASK (7 << 0) | ||
82 | #define DCCG_DISP1_SLOW_SELECT_SHIFT 0 | ||
83 | #define DCCG_DISP2_SLOW_SELECT(x) ((x) << 4) | ||
84 | #define DCCG_DISP2_SLOW_SELECT_MASK (7 << 4) | ||
85 | #define DCCG_DISP2_SLOW_SELECT_SHIFT 4 | ||
86 | |||
87 | #define CG_SPLL_FUNC_CNTL 0x180 | ||
88 | #define SPLL_RESET (1 << 0) | ||
89 | #define SPLL_SLEEP (1 << 1) | ||
90 | #define SPLL_BYPASS_EN (1 << 3) | ||
91 | #define SPLL_REF_DIV(x) ((x) << 4) | ||
92 | #define SPLL_REF_DIV_MASK (0x3f << 4) | ||
93 | #define SPLL_PDIV_A(x) ((x) << 20) | ||
94 | #define SPLL_PDIV_A_MASK (0x7f << 20) | ||
95 | #define SPLL_PDIV_A_SHIFT 20 | ||
96 | #define CG_SPLL_FUNC_CNTL_2 0x181 | ||
97 | #define SCLK_MUX_SEL(x) ((x) << 0) | ||
98 | #define SCLK_MUX_SEL_MASK (0x1ff << 0) | ||
99 | #define SPLL_CTLREQ_CHG (1 << 23) | ||
100 | #define SCLK_MUX_UPDATE (1 << 26) | ||
101 | #define CG_SPLL_FUNC_CNTL_3 0x182 | ||
102 | #define SPLL_FB_DIV(x) ((x) << 0) | ||
103 | #define SPLL_FB_DIV_MASK (0x3ffffff << 0) | ||
104 | #define SPLL_FB_DIV_SHIFT 0 | ||
105 | #define SPLL_DITHEN (1 << 28) | ||
106 | #define CG_SPLL_FUNC_CNTL_4 0x183 | ||
107 | |||
108 | #define SPLL_STATUS 0x185 | ||
109 | #define SPLL_CHG_STATUS (1 << 1) | ||
110 | #define SPLL_CNTL_MODE 0x186 | ||
111 | #define SPLL_SW_DIR_CONTROL (1 << 0) | ||
112 | # define SPLL_REFCLK_SEL(x) ((x) << 26) | ||
113 | # define SPLL_REFCLK_SEL_MASK (3 << 26) | ||
114 | |||
115 | #define CG_SPLL_SPREAD_SPECTRUM 0x188 | ||
116 | #define SSEN (1 << 0) | ||
117 | #define CLK_S(x) ((x) << 4) | ||
118 | #define CLK_S_MASK (0xfff << 4) | ||
119 | #define CLK_S_SHIFT 4 | ||
120 | #define CG_SPLL_SPREAD_SPECTRUM_2 0x189 | ||
121 | #define CLK_V(x) ((x) << 0) | ||
122 | #define CLK_V_MASK (0x3ffffff << 0) | ||
123 | #define CLK_V_SHIFT 0 | ||
124 | |||
125 | #define CG_SPLL_AUTOSCALE_CNTL 0x18b | ||
126 | # define AUTOSCALE_ON_SS_CLEAR (1 << 9) | ||
127 | |||
128 | /* discrete uvd clocks */ | ||
129 | #define CG_UPLL_FUNC_CNTL 0x18d | ||
130 | # define UPLL_RESET_MASK 0x00000001 | ||
131 | # define UPLL_SLEEP_MASK 0x00000002 | ||
132 | # define UPLL_BYPASS_EN_MASK 0x00000004 | ||
133 | # define UPLL_CTLREQ_MASK 0x00000008 | ||
134 | # define UPLL_VCO_MODE_MASK 0x00000600 | ||
135 | # define UPLL_REF_DIV_MASK 0x003F0000 | ||
136 | # define UPLL_CTLACK_MASK 0x40000000 | ||
137 | # define UPLL_CTLACK2_MASK 0x80000000 | ||
138 | #define CG_UPLL_FUNC_CNTL_2 0x18e | ||
139 | # define UPLL_PDIV_A(x) ((x) << 0) | ||
140 | # define UPLL_PDIV_A_MASK 0x0000007F | ||
141 | # define UPLL_PDIV_B(x) ((x) << 8) | ||
142 | # define UPLL_PDIV_B_MASK 0x00007F00 | ||
143 | # define VCLK_SRC_SEL(x) ((x) << 20) | ||
144 | # define VCLK_SRC_SEL_MASK 0x01F00000 | ||
145 | # define DCLK_SRC_SEL(x) ((x) << 25) | ||
146 | # define DCLK_SRC_SEL_MASK 0x3E000000 | ||
147 | #define CG_UPLL_FUNC_CNTL_3 0x18f | ||
148 | # define UPLL_FB_DIV(x) ((x) << 0) | ||
149 | # define UPLL_FB_DIV_MASK 0x01FFFFFF | ||
150 | #define CG_UPLL_FUNC_CNTL_4 0x191 | ||
151 | # define UPLL_SPARE_ISPARE9 0x00020000 | ||
152 | #define CG_UPLL_FUNC_CNTL_5 0x192 | ||
153 | # define RESET_ANTI_MUX_MASK 0x00000200 | ||
154 | #define CG_UPLL_SPREAD_SPECTRUM 0x194 | ||
155 | # define SSEN_MASK 0x00000001 | ||
156 | |||
157 | #define MPLL_BYPASSCLK_SEL 0x197 | ||
158 | # define MPLL_CLKOUT_SEL(x) ((x) << 8) | ||
159 | # define MPLL_CLKOUT_SEL_MASK 0xFF00 | ||
160 | |||
161 | #define CG_CLKPIN_CNTL 0x198 | ||
162 | # define XTALIN_DIVIDE (1 << 1) | ||
163 | # define BCLK_AS_XCLK (1 << 2) | ||
164 | #define CG_CLKPIN_CNTL_2 0x199 | ||
165 | # define FORCE_BIF_REFCLK_EN (1 << 3) | ||
166 | # define MUX_TCLK_TO_XCLK (1 << 8) | ||
167 | |||
168 | #define THM_CLK_CNTL 0x19b | ||
169 | # define CMON_CLK_SEL(x) ((x) << 0) | ||
170 | # define CMON_CLK_SEL_MASK 0xFF | ||
171 | # define TMON_CLK_SEL(x) ((x) << 8) | ||
172 | # define TMON_CLK_SEL_MASK 0xFF00 | ||
173 | #define MISC_CLK_CNTL 0x19c | ||
174 | # define DEEP_SLEEP_CLK_SEL(x) ((x) << 0) | ||
175 | # define DEEP_SLEEP_CLK_SEL_MASK 0xFF | ||
176 | # define ZCLK_SEL(x) ((x) << 8) | ||
177 | # define ZCLK_SEL_MASK 0xFF00 | ||
178 | |||
179 | #define CG_THERMAL_CTRL 0x1c0 | ||
180 | #define DPM_EVENT_SRC(x) ((x) << 0) | ||
181 | #define DPM_EVENT_SRC_MASK (7 << 0) | ||
182 | #define DIG_THERM_DPM(x) ((x) << 14) | ||
183 | #define DIG_THERM_DPM_MASK 0x003FC000 | ||
184 | #define DIG_THERM_DPM_SHIFT 14 | ||
185 | #define CG_THERMAL_STATUS 0x1c1 | ||
186 | #define FDO_PWM_DUTY(x) ((x) << 9) | ||
187 | #define FDO_PWM_DUTY_MASK (0xff << 9) | ||
188 | #define FDO_PWM_DUTY_SHIFT 9 | ||
189 | #define CG_THERMAL_INT 0x1c2 | ||
190 | #define DIG_THERM_INTH(x) ((x) << 8) | ||
191 | #define DIG_THERM_INTH_MASK 0x0000FF00 | ||
192 | #define DIG_THERM_INTH_SHIFT 8 | ||
193 | #define DIG_THERM_INTL(x) ((x) << 16) | ||
194 | #define DIG_THERM_INTL_MASK 0x00FF0000 | ||
195 | #define DIG_THERM_INTL_SHIFT 16 | ||
196 | #define THERM_INT_MASK_HIGH (1 << 24) | ||
197 | #define THERM_INT_MASK_LOW (1 << 25) | ||
198 | |||
199 | #define CG_MULT_THERMAL_CTRL 0x1c4 | ||
200 | #define TEMP_SEL(x) ((x) << 20) | ||
201 | #define TEMP_SEL_MASK (0xff << 20) | ||
202 | #define TEMP_SEL_SHIFT 20 | ||
203 | #define CG_MULT_THERMAL_STATUS 0x1c5 | ||
204 | #define ASIC_MAX_TEMP(x) ((x) << 0) | ||
205 | #define ASIC_MAX_TEMP_MASK 0x000001ff | ||
206 | #define ASIC_MAX_TEMP_SHIFT 0 | ||
207 | #define CTF_TEMP(x) ((x) << 9) | ||
208 | #define CTF_TEMP_MASK 0x0003fe00 | ||
209 | #define CTF_TEMP_SHIFT 9 | ||
210 | |||
211 | #define CG_FDO_CTRL0 0x1d5 | ||
212 | #define FDO_STATIC_DUTY(x) ((x) << 0) | ||
213 | #define FDO_STATIC_DUTY_MASK 0x000000FF | ||
214 | #define FDO_STATIC_DUTY_SHIFT 0 | ||
215 | #define CG_FDO_CTRL1 0x1d6 | ||
216 | #define FMAX_DUTY100(x) ((x) << 0) | ||
217 | #define FMAX_DUTY100_MASK 0x000000FF | ||
218 | #define FMAX_DUTY100_SHIFT 0 | ||
219 | #define CG_FDO_CTRL2 0x1d7 | ||
220 | #define TMIN(x) ((x) << 0) | ||
221 | #define TMIN_MASK 0x000000FF | ||
222 | #define TMIN_SHIFT 0 | ||
223 | #define FDO_PWM_MODE(x) ((x) << 11) | ||
224 | #define FDO_PWM_MODE_MASK (7 << 11) | ||
225 | #define FDO_PWM_MODE_SHIFT 11 | ||
226 | #define TACH_PWM_RESP_RATE(x) ((x) << 25) | ||
227 | #define TACH_PWM_RESP_RATE_MASK (0x7f << 25) | ||
228 | #define TACH_PWM_RESP_RATE_SHIFT 25 | ||
229 | |||
230 | #define CG_TACH_CTRL 0x1dc | ||
231 | # define EDGE_PER_REV(x) ((x) << 0) | ||
232 | # define EDGE_PER_REV_MASK (0x7 << 0) | ||
233 | # define EDGE_PER_REV_SHIFT 0 | ||
234 | # define TARGET_PERIOD(x) ((x) << 3) | ||
235 | # define TARGET_PERIOD_MASK 0xfffffff8 | ||
236 | # define TARGET_PERIOD_SHIFT 3 | ||
237 | #define CG_TACH_STATUS 0x1dd | ||
238 | # define TACH_PERIOD(x) ((x) << 0) | ||
239 | # define TACH_PERIOD_MASK 0xffffffff | ||
240 | # define TACH_PERIOD_SHIFT 0 | ||
241 | |||
242 | #define GENERAL_PWRMGT 0x1e0 | ||
243 | # define GLOBAL_PWRMGT_EN (1 << 0) | ||
244 | # define STATIC_PM_EN (1 << 1) | ||
245 | # define THERMAL_PROTECTION_DIS (1 << 2) | ||
246 | # define THERMAL_PROTECTION_TYPE (1 << 3) | ||
247 | # define SW_SMIO_INDEX(x) ((x) << 6) | ||
248 | # define SW_SMIO_INDEX_MASK (1 << 6) | ||
249 | # define SW_SMIO_INDEX_SHIFT 6 | ||
250 | # define VOLT_PWRMGT_EN (1 << 10) | ||
251 | # define DYN_SPREAD_SPECTRUM_EN (1 << 23) | ||
252 | #define CG_TPC 0x1e1 | ||
253 | #define SCLK_PWRMGT_CNTL 0x1e2 | ||
254 | # define SCLK_PWRMGT_OFF (1 << 0) | ||
255 | # define SCLK_LOW_D1 (1 << 1) | ||
256 | # define FIR_RESET (1 << 4) | ||
257 | # define FIR_FORCE_TREND_SEL (1 << 5) | ||
258 | # define FIR_TREND_MODE (1 << 6) | ||
259 | # define DYN_GFX_CLK_OFF_EN (1 << 7) | ||
260 | # define GFX_CLK_FORCE_ON (1 << 8) | ||
261 | # define GFX_CLK_REQUEST_OFF (1 << 9) | ||
262 | # define GFX_CLK_FORCE_OFF (1 << 10) | ||
263 | # define GFX_CLK_OFF_ACPI_D1 (1 << 11) | ||
264 | # define GFX_CLK_OFF_ACPI_D2 (1 << 12) | ||
265 | # define GFX_CLK_OFF_ACPI_D3 (1 << 13) | ||
266 | # define DYN_LIGHT_SLEEP_EN (1 << 14) | ||
267 | |||
268 | #define TARGET_AND_CURRENT_PROFILE_INDEX 0x1e6 | ||
269 | # define CURRENT_STATE_INDEX_MASK (0xf << 4) | ||
270 | # define CURRENT_STATE_INDEX_SHIFT 4 | ||
271 | |||
272 | #define CG_FTV 0x1ef | ||
273 | |||
274 | #define CG_FFCT_0 0x1f0 | ||
275 | # define UTC_0(x) ((x) << 0) | ||
276 | # define UTC_0_MASK (0x3ff << 0) | ||
277 | # define DTC_0(x) ((x) << 10) | ||
278 | # define DTC_0_MASK (0x3ff << 10) | ||
279 | |||
280 | #define CG_BSP 0x1ff | ||
281 | # define BSP(x) ((x) << 0) | ||
282 | # define BSP_MASK (0xffff << 0) | ||
283 | # define BSU(x) ((x) << 16) | ||
284 | # define BSU_MASK (0xf << 16) | ||
285 | #define CG_AT 0x200 | ||
286 | # define CG_R(x) ((x) << 0) | ||
287 | # define CG_R_MASK (0xffff << 0) | ||
288 | # define CG_L(x) ((x) << 16) | ||
289 | # define CG_L_MASK (0xffff << 16) | ||
290 | |||
291 | #define CG_GIT 0x201 | ||
292 | # define CG_GICST(x) ((x) << 0) | ||
293 | # define CG_GICST_MASK (0xffff << 0) | ||
294 | # define CG_GIPOT(x) ((x) << 16) | ||
295 | # define CG_GIPOT_MASK (0xffff << 16) | ||
296 | |||
297 | #define CG_SSP 0x203 | ||
298 | # define SST(x) ((x) << 0) | ||
299 | # define SST_MASK (0xffff << 0) | ||
300 | # define SSTU(x) ((x) << 16) | ||
301 | # define SSTU_MASK (0xf << 16) | ||
302 | |||
303 | #define CG_DISPLAY_GAP_CNTL 0x20a | ||
304 | # define DISP1_GAP(x) ((x) << 0) | ||
305 | # define DISP1_GAP_MASK (3 << 0) | ||
306 | # define DISP2_GAP(x) ((x) << 2) | ||
307 | # define DISP2_GAP_MASK (3 << 2) | ||
308 | # define VBI_TIMER_COUNT(x) ((x) << 4) | ||
309 | # define VBI_TIMER_COUNT_MASK (0x3fff << 4) | ||
310 | # define VBI_TIMER_UNIT(x) ((x) << 20) | ||
311 | # define VBI_TIMER_UNIT_MASK (7 << 20) | ||
312 | # define DISP1_GAP_MCHG(x) ((x) << 24) | ||
313 | # define DISP1_GAP_MCHG_MASK (3 << 24) | ||
314 | # define DISP2_GAP_MCHG(x) ((x) << 26) | ||
315 | # define DISP2_GAP_MCHG_MASK (3 << 26) | ||
316 | |||
317 | #define CG_ULV_CONTROL 0x21e | ||
318 | #define CG_ULV_PARAMETER 0x21f | ||
319 | |||
320 | #define SMC_SCRATCH0 0x221 | ||
321 | |||
322 | #define CG_CAC_CTRL 0x22e | ||
323 | # define CAC_WINDOW(x) ((x) << 0) | ||
324 | # define CAC_WINDOW_MASK 0x00ffffff | ||
325 | |||
326 | #define DMIF_ADDR_CONFIG 0x2F5 | ||
327 | |||
328 | #define DMIF_ADDR_CALC 0x300 | ||
329 | |||
330 | #define PIPE0_DMIF_BUFFER_CONTROL 0x0328 | ||
331 | # define DMIF_BUFFERS_ALLOCATED(x) ((x) << 0) | ||
332 | # define DMIF_BUFFERS_ALLOCATED_COMPLETED (1 << 4) | ||
333 | |||
334 | #define SRBM_STATUS 0x394 | ||
335 | #define GRBM_RQ_PENDING (1 << 5) | ||
336 | #define VMC_BUSY (1 << 8) | ||
337 | #define MCB_BUSY (1 << 9) | ||
338 | #define MCB_NON_DISPLAY_BUSY (1 << 10) | ||
339 | #define MCC_BUSY (1 << 11) | ||
340 | #define MCD_BUSY (1 << 12) | ||
341 | #define SEM_BUSY (1 << 14) | ||
342 | #define IH_BUSY (1 << 17) | ||
343 | |||
344 | #define SRBM_SOFT_RESET 0x398 | ||
345 | #define SOFT_RESET_BIF (1 << 1) | ||
346 | #define SOFT_RESET_DC (1 << 5) | ||
347 | #define SOFT_RESET_DMA1 (1 << 6) | ||
348 | #define SOFT_RESET_GRBM (1 << 8) | ||
349 | #define SOFT_RESET_HDP (1 << 9) | ||
350 | #define SOFT_RESET_IH (1 << 10) | ||
351 | #define SOFT_RESET_MC (1 << 11) | ||
352 | #define SOFT_RESET_ROM (1 << 14) | ||
353 | #define SOFT_RESET_SEM (1 << 15) | ||
354 | #define SOFT_RESET_VMC (1 << 17) | ||
355 | #define SOFT_RESET_DMA (1 << 20) | ||
356 | #define SOFT_RESET_TST (1 << 21) | ||
357 | #define SOFT_RESET_REGBB (1 << 22) | ||
358 | #define SOFT_RESET_ORB (1 << 23) | ||
359 | |||
360 | #define CC_SYS_RB_BACKEND_DISABLE 0x3A0 | ||
361 | #define GC_USER_SYS_RB_BACKEND_DISABLE 0x3A1 | ||
362 | |||
363 | #define SRBM_READ_ERROR 0x3A6 | ||
364 | #define SRBM_INT_CNTL 0x3A8 | ||
365 | #define SRBM_INT_ACK 0x3AA | ||
366 | |||
367 | #define SRBM_STATUS2 0x3B1 | ||
368 | #define DMA_BUSY (1 << 5) | ||
369 | #define DMA1_BUSY (1 << 6) | ||
370 | |||
371 | #define VM_L2_CNTL 0x500 | ||
372 | #define ENABLE_L2_CACHE (1 << 0) | ||
373 | #define ENABLE_L2_FRAGMENT_PROCESSING (1 << 1) | ||
374 | #define L2_CACHE_PTE_ENDIAN_SWAP_MODE(x) ((x) << 2) | ||
375 | #define L2_CACHE_PDE_ENDIAN_SWAP_MODE(x) ((x) << 4) | ||
376 | #define ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE (1 << 9) | ||
377 | #define ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE (1 << 10) | ||
378 | #define EFFECTIVE_L2_QUEUE_SIZE(x) (((x) & 7) << 15) | ||
379 | #define CONTEXT1_IDENTITY_ACCESS_MODE(x) (((x) & 3) << 19) | ||
380 | #define VM_L2_CNTL2 0x501 | ||
381 | #define INVALIDATE_ALL_L1_TLBS (1 << 0) | ||
382 | #define INVALIDATE_L2_CACHE (1 << 1) | ||
383 | #define INVALIDATE_CACHE_MODE(x) ((x) << 26) | ||
384 | #define INVALIDATE_PTE_AND_PDE_CACHES 0 | ||
385 | #define INVALIDATE_ONLY_PTE_CACHES 1 | ||
386 | #define INVALIDATE_ONLY_PDE_CACHES 2 | ||
387 | #define VM_L2_CNTL3 0x502 | ||
388 | #define BANK_SELECT(x) ((x) << 0) | ||
389 | #define L2_CACHE_UPDATE_MODE(x) ((x) << 6) | ||
390 | #define L2_CACHE_BIGK_FRAGMENT_SIZE(x) ((x) << 15) | ||
391 | #define L2_CACHE_BIGK_ASSOCIATIVITY (1 << 20) | ||
392 | #define VM_L2_STATUS 0x503 | ||
393 | #define L2_BUSY (1 << 0) | ||
394 | #define VM_CONTEXT0_CNTL 0x504 | ||
395 | #define ENABLE_CONTEXT (1 << 0) | ||
396 | #define PAGE_TABLE_DEPTH(x) (((x) & 3) << 1) | ||
397 | #define RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT (1 << 3) | ||
398 | #define RANGE_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 4) | ||
399 | #define DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT (1 << 6) | ||
400 | #define DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 7) | ||
401 | #define PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT (1 << 9) | ||
402 | #define PDE0_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 10) | ||
403 | #define VALID_PROTECTION_FAULT_ENABLE_INTERRUPT (1 << 12) | ||
404 | #define VALID_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 13) | ||
405 | #define READ_PROTECTION_FAULT_ENABLE_INTERRUPT (1 << 15) | ||
406 | #define READ_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 16) | ||
407 | #define WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT (1 << 18) | ||
408 | #define WRITE_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 19) | ||
409 | #define PAGE_TABLE_BLOCK_SIZE(x) (((x) & 0xF) << 24) | ||
410 | #define VM_CONTEXT1_CNTL 0x505 | ||
411 | #define VM_CONTEXT0_CNTL2 0x50C | ||
412 | #define VM_CONTEXT1_CNTL2 0x50D | ||
413 | #define VM_CONTEXT8_PAGE_TABLE_BASE_ADDR 0x50E | ||
414 | #define VM_CONTEXT9_PAGE_TABLE_BASE_ADDR 0x50F | ||
415 | #define VM_CONTEXT10_PAGE_TABLE_BASE_ADDR 0x510 | ||
416 | #define VM_CONTEXT11_PAGE_TABLE_BASE_ADDR 0x511 | ||
417 | #define VM_CONTEXT12_PAGE_TABLE_BASE_ADDR 0x512 | ||
418 | #define VM_CONTEXT13_PAGE_TABLE_BASE_ADDR 0x513 | ||
419 | #define VM_CONTEXT14_PAGE_TABLE_BASE_ADDR 0x514 | ||
420 | #define VM_CONTEXT15_PAGE_TABLE_BASE_ADDR 0x515 | ||
421 | |||
422 | #define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x53f | ||
423 | #define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x537 | ||
424 | #define PROTECTIONS_MASK (0xf << 0) | ||
425 | #define PROTECTIONS_SHIFT 0 | ||
426 | /* bit 0: range | ||
427 | * bit 1: pde0 | ||
428 | * bit 2: valid | ||
429 | * bit 3: read | ||
430 | * bit 4: write | ||
431 | */ | ||
432 | #define MEMORY_CLIENT_ID_MASK (0xff << 12) | ||
433 | #define MEMORY_CLIENT_ID_SHIFT 12 | ||
434 | #define MEMORY_CLIENT_RW_MASK (1 << 24) | ||
435 | #define MEMORY_CLIENT_RW_SHIFT 24 | ||
436 | #define FAULT_VMID_MASK (0xf << 25) | ||
437 | #define FAULT_VMID_SHIFT 25 | ||
438 | |||
439 | #define VM_INVALIDATE_REQUEST 0x51E | ||
440 | #define VM_INVALIDATE_RESPONSE 0x51F | ||
441 | |||
442 | #define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR 0x546 | ||
443 | #define VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR 0x547 | ||
444 | |||
445 | #define VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x54F | ||
446 | #define VM_CONTEXT1_PAGE_TABLE_BASE_ADDR 0x550 | ||
447 | #define VM_CONTEXT2_PAGE_TABLE_BASE_ADDR 0x551 | ||
448 | #define VM_CONTEXT3_PAGE_TABLE_BASE_ADDR 0x552 | ||
449 | #define VM_CONTEXT4_PAGE_TABLE_BASE_ADDR 0x553 | ||
450 | #define VM_CONTEXT5_PAGE_TABLE_BASE_ADDR 0x554 | ||
451 | #define VM_CONTEXT6_PAGE_TABLE_BASE_ADDR 0x555 | ||
452 | #define VM_CONTEXT7_PAGE_TABLE_BASE_ADDR 0x556 | ||
453 | #define VM_CONTEXT0_PAGE_TABLE_START_ADDR 0x557 | ||
454 | #define VM_CONTEXT1_PAGE_TABLE_START_ADDR 0x558 | ||
455 | |||
456 | #define VM_CONTEXT0_PAGE_TABLE_END_ADDR 0x55F | ||
457 | #define VM_CONTEXT1_PAGE_TABLE_END_ADDR 0x560 | ||
458 | |||
459 | #define VM_L2_CG 0x570 | ||
460 | #define MC_CG_ENABLE (1 << 18) | ||
461 | #define MC_LS_ENABLE (1 << 19) | ||
462 | |||
463 | #define MC_SHARED_CHMAP 0x801 | ||
464 | #define NOOFCHAN_SHIFT 12 | ||
465 | #define NOOFCHAN_MASK 0x0000f000 | ||
466 | #define MC_SHARED_CHREMAP 0x802 | ||
467 | |||
468 | #define MC_VM_FB_LOCATION 0x809 | ||
469 | #define MC_VM_AGP_TOP 0x80A | ||
470 | #define MC_VM_AGP_BOT 0x80B | ||
471 | #define MC_VM_AGP_BASE 0x80C | ||
472 | #define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x80D | ||
473 | #define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x80E | ||
474 | #define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x80F | ||
475 | |||
476 | #define MC_VM_MX_L1_TLB_CNTL 0x819 | ||
477 | #define ENABLE_L1_TLB (1 << 0) | ||
478 | #define ENABLE_L1_FRAGMENT_PROCESSING (1 << 1) | ||
479 | #define SYSTEM_ACCESS_MODE_PA_ONLY (0 << 3) | ||
480 | #define SYSTEM_ACCESS_MODE_USE_SYS_MAP (1 << 3) | ||
481 | #define SYSTEM_ACCESS_MODE_IN_SYS (2 << 3) | ||
482 | #define SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 3) | ||
483 | #define SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 5) | ||
484 | #define ENABLE_ADVANCED_DRIVER_MODEL (1 << 6) | ||
485 | |||
486 | #define MC_SHARED_BLACKOUT_CNTL 0x82B | ||
487 | |||
488 | #define MC_HUB_MISC_HUB_CG 0x82E | ||
489 | #define MC_HUB_MISC_VM_CG 0x82F | ||
490 | |||
491 | #define MC_HUB_MISC_SIP_CG 0x830 | ||
492 | |||
493 | #define MC_XPB_CLK_GAT 0x91E | ||
494 | |||
495 | #define MC_CITF_MISC_RD_CG 0x992 | ||
496 | #define MC_CITF_MISC_WR_CG 0x993 | ||
497 | #define MC_CITF_MISC_VM_CG 0x994 | ||
498 | |||
499 | #define MC_ARB_RAMCFG 0x9D8 | ||
500 | #define NOOFBANK_SHIFT 0 | ||
501 | #define NOOFBANK_MASK 0x00000003 | ||
502 | #define NOOFRANK_SHIFT 2 | ||
503 | #define NOOFRANK_MASK 0x00000004 | ||
504 | #define NOOFROWS_SHIFT 3 | ||
505 | #define NOOFROWS_MASK 0x00000038 | ||
506 | #define NOOFCOLS_SHIFT 6 | ||
507 | #define NOOFCOLS_MASK 0x000000C0 | ||
508 | #define CHANSIZE_SHIFT 8 | ||
509 | #define CHANSIZE_MASK 0x00000100 | ||
510 | #define CHANSIZE_OVERRIDE (1 << 11) | ||
511 | #define NOOFGROUPS_SHIFT 12 | ||
512 | #define NOOFGROUPS_MASK 0x00001000 | ||
513 | |||
514 | #define MC_ARB_DRAM_TIMING 0x9DD | ||
515 | #define MC_ARB_DRAM_TIMING2 0x9DE | ||
516 | |||
517 | #define MC_ARB_BURST_TIME 0xA02 | ||
518 | #define STATE0(x) ((x) << 0) | ||
519 | #define STATE0_MASK (0x1f << 0) | ||
520 | #define STATE0_SHIFT 0 | ||
521 | #define STATE1(x) ((x) << 5) | ||
522 | #define STATE1_MASK (0x1f << 5) | ||
523 | #define STATE1_SHIFT 5 | ||
524 | #define STATE2(x) ((x) << 10) | ||
525 | #define STATE2_MASK (0x1f << 10) | ||
526 | #define STATE2_SHIFT 10 | ||
527 | #define STATE3(x) ((x) << 15) | ||
528 | #define STATE3_MASK (0x1f << 15) | ||
529 | #define STATE3_SHIFT 15 | ||
530 | |||
531 | #define MC_SEQ_TRAIN_WAKEUP_CNTL 0xA3A | ||
532 | #define TRAIN_DONE_D0 (1 << 30) | ||
533 | #define TRAIN_DONE_D1 (1 << 31) | ||
534 | |||
535 | #define MC_SEQ_SUP_CNTL 0xA32 | ||
536 | #define RUN_MASK (1 << 0) | ||
537 | #define MC_SEQ_SUP_PGM 0xA33 | ||
538 | #define MC_PMG_AUTO_CMD 0xA34 | ||
539 | |||
540 | #define MC_IO_PAD_CNTL_D0 0xA74 | ||
541 | #define MEM_FALL_OUT_CMD (1 << 8) | ||
542 | |||
543 | #define MC_SEQ_RAS_TIMING 0xA28 | ||
544 | #define MC_SEQ_CAS_TIMING 0xA29 | ||
545 | #define MC_SEQ_MISC_TIMING 0xA2A | ||
546 | #define MC_SEQ_MISC_TIMING2 0xA2B | ||
547 | #define MC_SEQ_PMG_TIMING 0xA2C | ||
548 | #define MC_SEQ_RD_CTL_D0 0xA2D | ||
549 | #define MC_SEQ_RD_CTL_D1 0xA2E | ||
550 | #define MC_SEQ_WR_CTL_D0 0xA2F | ||
551 | #define MC_SEQ_WR_CTL_D1 0xA30 | ||
552 | |||
553 | #define MC_SEQ_MISC0 0xA80 | ||
554 | #define MC_SEQ_MISC0_VEN_ID_SHIFT 8 | ||
555 | #define MC_SEQ_MISC0_VEN_ID_MASK 0x00000f00 | ||
556 | #define MC_SEQ_MISC0_VEN_ID_VALUE 3 | ||
557 | #define MC_SEQ_MISC0_REV_ID_SHIFT 12 | ||
558 | #define MC_SEQ_MISC0_REV_ID_MASK 0x0000f000 | ||
559 | #define MC_SEQ_MISC0_REV_ID_VALUE 1 | ||
560 | #define MC_SEQ_MISC0_GDDR5_SHIFT 28 | ||
561 | #define MC_SEQ_MISC0_GDDR5_MASK 0xf0000000 | ||
562 | #define MC_SEQ_MISC0_GDDR5_VALUE 5 | ||
563 | #define MC_SEQ_MISC1 0xA81 | ||
564 | #define MC_SEQ_RESERVE_M 0xA82 | ||
565 | #define MC_PMG_CMD_EMRS 0xA83 | ||
566 | |||
567 | #define MC_SEQ_IO_DEBUG_INDEX 0xA91 | ||
568 | #define MC_SEQ_IO_DEBUG_DATA 0xA92 | ||
569 | |||
570 | #define MC_SEQ_MISC5 0xA95 | ||
571 | #define MC_SEQ_MISC6 0xA96 | ||
572 | |||
573 | #define MC_SEQ_MISC7 0xA99 | ||
574 | |||
575 | #define MC_SEQ_RAS_TIMING_LP 0xA9B | ||
576 | #define MC_SEQ_CAS_TIMING_LP 0xA9C | ||
577 | #define MC_SEQ_MISC_TIMING_LP 0xA9D | ||
578 | #define MC_SEQ_MISC_TIMING2_LP 0xA9E | ||
579 | #define MC_SEQ_WR_CTL_D0_LP 0xA9F | ||
580 | #define MC_SEQ_WR_CTL_D1_LP 0xAA0 | ||
581 | #define MC_SEQ_PMG_CMD_EMRS_LP 0xAA1 | ||
582 | #define MC_SEQ_PMG_CMD_MRS_LP 0xAA2 | ||
583 | |||
584 | #define MC_PMG_CMD_MRS 0xAAB | ||
585 | |||
586 | #define MC_SEQ_RD_CTL_D0_LP 0xAC7 | ||
587 | #define MC_SEQ_RD_CTL_D1_LP 0xAC8 | ||
588 | |||
589 | #define MC_PMG_CMD_MRS1 0xAD1 | ||
590 | #define MC_SEQ_PMG_CMD_MRS1_LP 0xAD2 | ||
591 | #define MC_SEQ_PMG_TIMING_LP 0xAD3 | ||
592 | |||
593 | #define MC_SEQ_WR_CTL_2 0xAD5 | ||
594 | #define MC_SEQ_WR_CTL_2_LP 0xAD6 | ||
595 | #define MC_PMG_CMD_MRS2 0xAD7 | ||
596 | #define MC_SEQ_PMG_CMD_MRS2_LP 0xAD8 | ||
597 | |||
598 | #define MCLK_PWRMGT_CNTL 0xAE8 | ||
599 | # define DLL_SPEED(x) ((x) << 0) | ||
600 | # define DLL_SPEED_MASK (0x1f << 0) | ||
601 | # define DLL_READY (1 << 6) | ||
602 | # define MC_INT_CNTL (1 << 7) | ||
603 | # define MRDCK0_PDNB (1 << 8) | ||
604 | # define MRDCK1_PDNB (1 << 9) | ||
605 | # define MRDCK0_RESET (1 << 16) | ||
606 | # define MRDCK1_RESET (1 << 17) | ||
607 | # define DLL_READY_READ (1 << 24) | ||
608 | #define DLL_CNTL 0xAE9 | ||
609 | # define MRDCK0_BYPASS (1 << 24) | ||
610 | # define MRDCK1_BYPASS (1 << 25) | ||
611 | |||
612 | #define MPLL_CNTL_MODE 0xAEC | ||
613 | # define MPLL_MCLK_SEL (1 << 11) | ||
614 | #define MPLL_FUNC_CNTL 0xAED | ||
615 | #define BWCTRL(x) ((x) << 20) | ||
616 | #define BWCTRL_MASK (0xff << 20) | ||
617 | #define MPLL_FUNC_CNTL_1 0xAEE | ||
618 | #define VCO_MODE(x) ((x) << 0) | ||
619 | #define VCO_MODE_MASK (3 << 0) | ||
620 | #define CLKFRAC(x) ((x) << 4) | ||
621 | #define CLKFRAC_MASK (0xfff << 4) | ||
622 | #define CLKF(x) ((x) << 16) | ||
623 | #define CLKF_MASK (0xfff << 16) | ||
624 | #define MPLL_FUNC_CNTL_2 0xAEF | ||
625 | #define MPLL_AD_FUNC_CNTL 0xAF0 | ||
626 | #define YCLK_POST_DIV(x) ((x) << 0) | ||
627 | #define YCLK_POST_DIV_MASK (7 << 0) | ||
628 | #define MPLL_DQ_FUNC_CNTL 0xAF1 | ||
629 | #define YCLK_SEL(x) ((x) << 4) | ||
630 | #define YCLK_SEL_MASK (1 << 4) | ||
631 | |||
632 | #define MPLL_SS1 0xAF3 | ||
633 | #define CLKV(x) ((x) << 0) | ||
634 | #define CLKV_MASK (0x3ffffff << 0) | ||
635 | #define MPLL_SS2 0xAF4 | ||
636 | #define CLKS(x) ((x) << 0) | ||
637 | #define CLKS_MASK (0xfff << 0) | ||
638 | |||
639 | #define HDP_HOST_PATH_CNTL 0xB00 | ||
640 | #define CLOCK_GATING_DIS (1 << 23) | ||
641 | #define HDP_NONSURFACE_BASE 0xB01 | ||
642 | #define HDP_NONSURFACE_INFO 0xB02 | ||
643 | #define HDP_NONSURFACE_SIZE 0xB03 | ||
644 | |||
645 | #define HDP_DEBUG0 0xBCC | ||
646 | |||
647 | #define HDP_ADDR_CONFIG 0xBD2 | ||
648 | #define HDP_MISC_CNTL 0xBD3 | ||
649 | #define HDP_FLUSH_INVALIDATE_CACHE (1 << 0) | ||
650 | #define HDP_MEM_POWER_LS 0xBD4 | ||
651 | #define HDP_LS_ENABLE (1 << 0) | ||
652 | |||
653 | #define ATC_MISC_CG 0xCD4 | ||
654 | |||
655 | #define IH_RB_CNTL 0xF80 | ||
656 | # define IH_RB_ENABLE (1 << 0) | ||
657 | # define IH_IB_SIZE(x) ((x) << 1) /* log2 */ | ||
658 | # define IH_RB_FULL_DRAIN_ENABLE (1 << 6) | ||
659 | # define IH_WPTR_WRITEBACK_ENABLE (1 << 8) | ||
660 | # define IH_WPTR_WRITEBACK_TIMER(x) ((x) << 9) /* log2 */ | ||
661 | # define IH_WPTR_OVERFLOW_ENABLE (1 << 16) | ||
662 | # define IH_WPTR_OVERFLOW_CLEAR (1 << 31) | ||
663 | #define IH_RB_BASE 0xF81 | ||
664 | #define IH_RB_RPTR 0xF82 | ||
665 | #define IH_RB_WPTR 0xF83 | ||
666 | # define RB_OVERFLOW (1 << 0) | ||
667 | # define WPTR_OFFSET_MASK 0x3fffc | ||
668 | #define IH_RB_WPTR_ADDR_HI 0xF84 | ||
669 | #define IH_RB_WPTR_ADDR_LO 0xF85 | ||
670 | #define IH_CNTL 0xF86 | ||
671 | # define ENABLE_INTR (1 << 0) | ||
672 | # define IH_MC_SWAP(x) ((x) << 1) | ||
673 | # define IH_MC_SWAP_NONE 0 | ||
674 | # define IH_MC_SWAP_16BIT 1 | ||
675 | # define IH_MC_SWAP_32BIT 2 | ||
676 | # define IH_MC_SWAP_64BIT 3 | ||
677 | # define RPTR_REARM (1 << 4) | ||
678 | # define MC_WRREQ_CREDIT(x) ((x) << 15) | ||
679 | # define MC_WR_CLEAN_CNT(x) ((x) << 20) | ||
680 | # define MC_VMID(x) ((x) << 25) | ||
681 | |||
682 | #define CONFIG_MEMSIZE 0x150A | ||
683 | |||
684 | #define INTERRUPT_CNTL 0x151A | ||
685 | # define IH_DUMMY_RD_OVERRIDE (1 << 0) | ||
686 | # define IH_DUMMY_RD_EN (1 << 1) | ||
687 | # define IH_REQ_NONSNOOP_EN (1 << 3) | ||
688 | # define GEN_IH_INT_EN (1 << 8) | ||
689 | #define INTERRUPT_CNTL2 0x151B | ||
690 | |||
691 | #define HDP_MEM_COHERENCY_FLUSH_CNTL 0x1520 | ||
692 | |||
693 | #define BIF_FB_EN 0x1524 | ||
694 | #define FB_READ_EN (1 << 0) | ||
695 | #define FB_WRITE_EN (1 << 1) | ||
696 | |||
697 | #define HDP_REG_COHERENCY_FLUSH_CNTL 0x1528 | ||
698 | |||
699 | /* DCE6 ELD audio interface */ | ||
700 | #define AZ_F0_CODEC_ENDPOINT_INDEX 0x1780 | ||
701 | # define AZ_ENDPOINT_REG_INDEX(x) (((x) & 0xff) << 0) | ||
702 | # define AZ_ENDPOINT_REG_WRITE_EN (1 << 8) | ||
703 | #define AZ_F0_CODEC_ENDPOINT_DATA 0x1781 | ||
704 | |||
705 | #define AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER 0x25 | ||
706 | #define SPEAKER_ALLOCATION(x) (((x) & 0x7f) << 0) | ||
707 | #define SPEAKER_ALLOCATION_MASK (0x7f << 0) | ||
708 | #define SPEAKER_ALLOCATION_SHIFT 0 | ||
709 | #define HDMI_CONNECTION (1 << 16) | ||
710 | #define DP_CONNECTION (1 << 17) | ||
711 | |||
712 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0 0x28 /* LPCM */ | ||
713 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR1 0x29 /* AC3 */ | ||
714 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR2 0x2A /* MPEG1 */ | ||
715 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR3 0x2B /* MP3 */ | ||
716 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR4 0x2C /* MPEG2 */ | ||
717 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR5 0x2D /* AAC */ | ||
718 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR6 0x2E /* DTS */ | ||
719 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR7 0x2F /* ATRAC */ | ||
720 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR8 0x30 /* one bit audio - leave at 0 (default) */ | ||
721 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR9 0x31 /* Dolby Digital */ | ||
722 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR10 0x32 /* DTS-HD */ | ||
723 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR11 0x33 /* MAT-MLP */ | ||
724 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR12 0x34 /* DTS */ | ||
725 | #define AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13 0x35 /* WMA Pro */ | ||
726 | # define MAX_CHANNELS(x) (((x) & 0x7) << 0) | ||
727 | /* max channels minus one. 7 = 8 channels */ | ||
728 | # define SUPPORTED_FREQUENCIES(x) (((x) & 0xff) << 8) | ||
729 | # define DESCRIPTOR_BYTE_2(x) (((x) & 0xff) << 16) | ||
730 | # define SUPPORTED_FREQUENCIES_STEREO(x) (((x) & 0xff) << 24) /* LPCM only */ | ||
731 | /* SUPPORTED_FREQUENCIES, SUPPORTED_FREQUENCIES_STEREO | ||
732 | * bit0 = 32 kHz | ||
733 | * bit1 = 44.1 kHz | ||
734 | * bit2 = 48 kHz | ||
735 | * bit3 = 88.2 kHz | ||
736 | * bit4 = 96 kHz | ||
737 | * bit5 = 176.4 kHz | ||
738 | * bit6 = 192 kHz | ||
739 | */ | ||
740 | |||
741 | #define AZ_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC 0x37 | ||
742 | # define VIDEO_LIPSYNC(x) (((x) & 0xff) << 0) | ||
743 | # define AUDIO_LIPSYNC(x) (((x) & 0xff) << 8) | ||
744 | /* VIDEO_LIPSYNC, AUDIO_LIPSYNC | ||
745 | * 0 = invalid | ||
746 | * x = legal delay value | ||
747 | * 255 = sync not supported | ||
748 | */ | ||
749 | #define AZ_F0_CODEC_PIN_CONTROL_RESPONSE_HBR 0x38 | ||
750 | # define HBR_CAPABLE (1 << 0) /* enabled by default */ | ||
751 | |||
752 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO0 0x3a | ||
753 | # define MANUFACTURER_ID(x) (((x) & 0xffff) << 0) | ||
754 | # define PRODUCT_ID(x) (((x) & 0xffff) << 16) | ||
755 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO1 0x3b | ||
756 | # define SINK_DESCRIPTION_LEN(x) (((x) & 0xff) << 0) | ||
757 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO2 0x3c | ||
758 | # define PORT_ID0(x) (((x) & 0xffffffff) << 0) | ||
759 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO3 0x3d | ||
760 | # define PORT_ID1(x) (((x) & 0xffffffff) << 0) | ||
761 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO4 0x3e | ||
762 | # define DESCRIPTION0(x) (((x) & 0xff) << 0) | ||
763 | # define DESCRIPTION1(x) (((x) & 0xff) << 8) | ||
764 | # define DESCRIPTION2(x) (((x) & 0xff) << 16) | ||
765 | # define DESCRIPTION3(x) (((x) & 0xff) << 24) | ||
766 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO5 0x3f | ||
767 | # define DESCRIPTION4(x) (((x) & 0xff) << 0) | ||
768 | # define DESCRIPTION5(x) (((x) & 0xff) << 8) | ||
769 | # define DESCRIPTION6(x) (((x) & 0xff) << 16) | ||
770 | # define DESCRIPTION7(x) (((x) & 0xff) << 24) | ||
771 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO6 0x40 | ||
772 | # define DESCRIPTION8(x) (((x) & 0xff) << 0) | ||
773 | # define DESCRIPTION9(x) (((x) & 0xff) << 8) | ||
774 | # define DESCRIPTION10(x) (((x) & 0xff) << 16) | ||
775 | # define DESCRIPTION11(x) (((x) & 0xff) << 24) | ||
776 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO7 0x41 | ||
777 | # define DESCRIPTION12(x) (((x) & 0xff) << 0) | ||
778 | # define DESCRIPTION13(x) (((x) & 0xff) << 8) | ||
779 | # define DESCRIPTION14(x) (((x) & 0xff) << 16) | ||
780 | # define DESCRIPTION15(x) (((x) & 0xff) << 24) | ||
781 | #define AZ_F0_CODEC_PIN_CONTROL_SINK_INFO8 0x42 | ||
782 | # define DESCRIPTION16(x) (((x) & 0xff) << 0) | ||
783 | # define DESCRIPTION17(x) (((x) & 0xff) << 8) | ||
784 | |||
785 | #define AZ_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL 0x54 | ||
786 | # define AUDIO_ENABLED (1 << 31) | ||
787 | |||
788 | #define AZ_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT 0x56 | ||
789 | #define PORT_CONNECTIVITY_MASK (3 << 30) | ||
790 | #define PORT_CONNECTIVITY_SHIFT 30 | ||
791 | |||
792 | #define DC_LB_MEMORY_SPLIT 0x1AC3 | ||
793 | #define DC_LB_MEMORY_CONFIG(x) ((x) << 20) | ||
794 | |||
795 | #define PRIORITY_A_CNT 0x1AC6 | ||
796 | #define PRIORITY_MARK_MASK 0x7fff | ||
797 | #define PRIORITY_OFF (1 << 16) | ||
798 | #define PRIORITY_ALWAYS_ON (1 << 20) | ||
799 | #define PRIORITY_B_CNT 0x1AC7 | ||
800 | |||
801 | #define DPG_PIPE_ARBITRATION_CONTROL3 0x1B32 | ||
802 | # define LATENCY_WATERMARK_MASK(x) ((x) << 16) | ||
803 | #define DPG_PIPE_LATENCY_CONTROL 0x1B33 | ||
804 | # define LATENCY_LOW_WATERMARK(x) ((x) << 0) | ||
805 | # define LATENCY_HIGH_WATERMARK(x) ((x) << 16) | ||
806 | |||
807 | /* 0x6bb8, 0x77b8, 0x103b8, 0x10fb8, 0x11bb8, 0x127b8 */ | ||
808 | #define VLINE_STATUS 0x1AEE | ||
809 | # define VLINE_OCCURRED (1 << 0) | ||
810 | # define VLINE_ACK (1 << 4) | ||
811 | # define VLINE_STAT (1 << 12) | ||
812 | # define VLINE_INTERRUPT (1 << 16) | ||
813 | # define VLINE_INTERRUPT_TYPE (1 << 17) | ||
814 | /* 0x6bbc, 0x77bc, 0x103bc, 0x10fbc, 0x11bbc, 0x127bc */ | ||
815 | #define VBLANK_STATUS 0x1AEF | ||
816 | # define VBLANK_OCCURRED (1 << 0) | ||
817 | # define VBLANK_ACK (1 << 4) | ||
818 | # define VBLANK_STAT (1 << 12) | ||
819 | # define VBLANK_INTERRUPT (1 << 16) | ||
820 | # define VBLANK_INTERRUPT_TYPE (1 << 17) | ||
821 | |||
822 | /* 0x6b40, 0x7740, 0x10340, 0x10f40, 0x11b40, 0x12740 */ | ||
823 | #define INT_MASK 0x1AD0 | ||
824 | # define VBLANK_INT_MASK (1 << 0) | ||
825 | # define VLINE_INT_MASK (1 << 4) | ||
826 | |||
827 | #define DISP_INTERRUPT_STATUS 0x183D | ||
828 | # define LB_D1_VLINE_INTERRUPT (1 << 2) | ||
829 | # define LB_D1_VBLANK_INTERRUPT (1 << 3) | ||
830 | # define DC_HPD1_INTERRUPT (1 << 17) | ||
831 | # define DC_HPD1_RX_INTERRUPT (1 << 18) | ||
832 | # define DACA_AUTODETECT_INTERRUPT (1 << 22) | ||
833 | # define DACB_AUTODETECT_INTERRUPT (1 << 23) | ||
834 | # define DC_I2C_SW_DONE_INTERRUPT (1 << 24) | ||
835 | # define DC_I2C_HW_DONE_INTERRUPT (1 << 25) | ||
836 | #define DISP_INTERRUPT_STATUS_CONTINUE 0x183E | ||
837 | # define LB_D2_VLINE_INTERRUPT (1 << 2) | ||
838 | # define LB_D2_VBLANK_INTERRUPT (1 << 3) | ||
839 | # define DC_HPD2_INTERRUPT (1 << 17) | ||
840 | # define DC_HPD2_RX_INTERRUPT (1 << 18) | ||
841 | # define DISP_TIMER_INTERRUPT (1 << 24) | ||
842 | #define DISP_INTERRUPT_STATUS_CONTINUE2 0x183F | ||
843 | # define LB_D3_VLINE_INTERRUPT (1 << 2) | ||
844 | # define LB_D3_VBLANK_INTERRUPT (1 << 3) | ||
845 | # define DC_HPD3_INTERRUPT (1 << 17) | ||
846 | # define DC_HPD3_RX_INTERRUPT (1 << 18) | ||
847 | #define DISP_INTERRUPT_STATUS_CONTINUE3 0x1840 | ||
848 | # define LB_D4_VLINE_INTERRUPT (1 << 2) | ||
849 | # define LB_D4_VBLANK_INTERRUPT (1 << 3) | ||
850 | # define DC_HPD4_INTERRUPT (1 << 17) | ||
851 | # define DC_HPD4_RX_INTERRUPT (1 << 18) | ||
852 | #define DISP_INTERRUPT_STATUS_CONTINUE4 0x1853 | ||
853 | # define LB_D5_VLINE_INTERRUPT (1 << 2) | ||
854 | # define LB_D5_VBLANK_INTERRUPT (1 << 3) | ||
855 | # define DC_HPD5_INTERRUPT (1 << 17) | ||
856 | # define DC_HPD5_RX_INTERRUPT (1 << 18) | ||
857 | #define DISP_INTERRUPT_STATUS_CONTINUE5 0x1854 | ||
858 | # define LB_D6_VLINE_INTERRUPT (1 << 2) | ||
859 | # define LB_D6_VBLANK_INTERRUPT (1 << 3) | ||
860 | # define DC_HPD6_INTERRUPT (1 << 17) | ||
861 | # define DC_HPD6_RX_INTERRUPT (1 << 18) | ||
862 | |||
863 | /* 0x6858, 0x7458, 0x10058, 0x10c58, 0x11858, 0x12458 */ | ||
864 | #define GRPH_INT_STATUS 0x1A16 | ||
865 | # define GRPH_PFLIP_INT_OCCURRED (1 << 0) | ||
866 | # define GRPH_PFLIP_INT_CLEAR (1 << 8) | ||
867 | /* 0x685c, 0x745c, 0x1005c, 0x10c5c, 0x1185c, 0x1245c */ | ||
868 | #define GRPH_INT_CONTROL 0x1A17 | ||
869 | # define GRPH_PFLIP_INT_MASK (1 << 0) | ||
870 | # define GRPH_PFLIP_INT_TYPE (1 << 8) | ||
871 | |||
872 | #define DAC_AUTODETECT_INT_CONTROL 0x19F2 | ||
873 | |||
874 | #define DC_HPD1_INT_STATUS 0x1807 | ||
875 | #define DC_HPD2_INT_STATUS 0x180A | ||
876 | #define DC_HPD3_INT_STATUS 0x180D | ||
877 | #define DC_HPD4_INT_STATUS 0x1810 | ||
878 | #define DC_HPD5_INT_STATUS 0x1813 | ||
879 | #define DC_HPD6_INT_STATUS 0x1816 | ||
880 | # define DC_HPDx_INT_STATUS (1 << 0) | ||
881 | # define DC_HPDx_SENSE (1 << 1) | ||
882 | # define DC_HPDx_RX_INT_STATUS (1 << 8) | ||
883 | |||
884 | #define DC_HPD1_INT_CONTROL 0x1808 | ||
885 | #define DC_HPD2_INT_CONTROL 0x180B | ||
886 | #define DC_HPD3_INT_CONTROL 0x180E | ||
887 | #define DC_HPD4_INT_CONTROL 0x1811 | ||
888 | #define DC_HPD5_INT_CONTROL 0x1814 | ||
889 | #define DC_HPD6_INT_CONTROL 0x1817 | ||
890 | # define DC_HPDx_INT_ACK (1 << 0) | ||
891 | # define DC_HPDx_INT_POLARITY (1 << 8) | ||
892 | # define DC_HPDx_INT_EN (1 << 16) | ||
893 | # define DC_HPDx_RX_INT_ACK (1 << 20) | ||
894 | # define DC_HPDx_RX_INT_EN (1 << 24) | ||
895 | |||
896 | #define DC_HPD1_CONTROL 0x1809 | ||
897 | #define DC_HPD2_CONTROL 0x180C | ||
898 | #define DC_HPD3_CONTROL 0x180F | ||
899 | #define DC_HPD4_CONTROL 0x1812 | ||
900 | #define DC_HPD5_CONTROL 0x1815 | ||
901 | #define DC_HPD6_CONTROL 0x1818 | ||
902 | # define DC_HPDx_CONNECTION_TIMER(x) ((x) << 0) | ||
903 | # define DC_HPDx_RX_INT_TIMER(x) ((x) << 16) | ||
904 | # define DC_HPDx_EN (1 << 28) | ||
905 | |||
906 | #define DPG_PIPE_STUTTER_CONTROL 0x1B35 | ||
907 | # define STUTTER_ENABLE (1 << 0) | ||
908 | |||
909 | /* 0x6e98, 0x7a98, 0x10698, 0x11298, 0x11e98, 0x12a98 */ | ||
910 | #define CRTC_STATUS_FRAME_COUNT 0x1BA6 | ||
911 | |||
912 | /* Audio clocks */ | ||
913 | #define DCCG_AUDIO_DTO_SOURCE 0x05ac | ||
914 | # define DCCG_AUDIO_DTO0_SOURCE_SEL(x) ((x) << 0) /* crtc0 - crtc5 */ | ||
915 | # define DCCG_AUDIO_DTO_SEL (1 << 4) /* 0=dto0 1=dto1 */ | ||
916 | |||
917 | #define DCCG_AUDIO_DTO0_PHASE 0x05b0 | ||
918 | #define DCCG_AUDIO_DTO0_MODULE 0x05b4 | ||
919 | #define DCCG_AUDIO_DTO1_PHASE 0x05c0 | ||
920 | #define DCCG_AUDIO_DTO1_MODULE 0x05c4 | ||
921 | |||
922 | #define AFMT_AUDIO_SRC_CONTROL 0x1c4f | ||
923 | #define AFMT_AUDIO_SRC_SELECT(x) (((x) & 7) << 0) | ||
924 | /* AFMT_AUDIO_SRC_SELECT | ||
925 | * 0 = stream0 | ||
926 | * 1 = stream1 | ||
927 | * 2 = stream2 | ||
928 | * 3 = stream3 | ||
929 | * 4 = stream4 | ||
930 | * 5 = stream5 | ||
931 | */ | ||
932 | |||
933 | #define GRBM_CNTL 0x2000 | ||
934 | #define GRBM_READ_TIMEOUT(x) ((x) << 0) | ||
935 | |||
936 | #define GRBM_STATUS2 0x2002 | ||
937 | #define RLC_RQ_PENDING (1 << 0) | ||
938 | #define RLC_BUSY (1 << 8) | ||
939 | #define TC_BUSY (1 << 9) | ||
940 | |||
941 | #define GRBM_STATUS 0x2004 | ||
942 | #define CMDFIFO_AVAIL_MASK 0x0000000F | ||
943 | #define RING2_RQ_PENDING (1 << 4) | ||
944 | #define SRBM_RQ_PENDING (1 << 5) | ||
945 | #define RING1_RQ_PENDING (1 << 6) | ||
946 | #define CF_RQ_PENDING (1 << 7) | ||
947 | #define PF_RQ_PENDING (1 << 8) | ||
948 | #define GDS_DMA_RQ_PENDING (1 << 9) | ||
949 | #define GRBM_EE_BUSY (1 << 10) | ||
950 | #define DB_CLEAN (1 << 12) | ||
951 | #define CB_CLEAN (1 << 13) | ||
952 | #define TA_BUSY (1 << 14) | ||
953 | #define GDS_BUSY (1 << 15) | ||
954 | #define VGT_BUSY (1 << 17) | ||
955 | #define IA_BUSY_NO_DMA (1 << 18) | ||
956 | #define IA_BUSY (1 << 19) | ||
957 | #define SX_BUSY (1 << 20) | ||
958 | #define SPI_BUSY (1 << 22) | ||
959 | #define BCI_BUSY (1 << 23) | ||
960 | #define SC_BUSY (1 << 24) | ||
961 | #define PA_BUSY (1 << 25) | ||
962 | #define DB_BUSY (1 << 26) | ||
963 | #define CP_COHERENCY_BUSY (1 << 28) | ||
964 | #define CP_BUSY (1 << 29) | ||
965 | #define CB_BUSY (1 << 30) | ||
966 | #define GUI_ACTIVE (1 << 31) | ||
967 | #define GRBM_STATUS_SE0 0x2005 | ||
968 | #define GRBM_STATUS_SE1 0x2006 | ||
969 | #define SE_DB_CLEAN (1 << 1) | ||
970 | #define SE_CB_CLEAN (1 << 2) | ||
971 | #define SE_BCI_BUSY (1 << 22) | ||
972 | #define SE_VGT_BUSY (1 << 23) | ||
973 | #define SE_PA_BUSY (1 << 24) | ||
974 | #define SE_TA_BUSY (1 << 25) | ||
975 | #define SE_SX_BUSY (1 << 26) | ||
976 | #define SE_SPI_BUSY (1 << 27) | ||
977 | #define SE_SC_BUSY (1 << 29) | ||
978 | #define SE_DB_BUSY (1 << 30) | ||
979 | #define SE_CB_BUSY (1 << 31) | ||
980 | |||
981 | #define GRBM_SOFT_RESET 0x2008 | ||
982 | #define SOFT_RESET_CP (1 << 0) | ||
983 | #define SOFT_RESET_CB (1 << 1) | ||
984 | #define SOFT_RESET_RLC (1 << 2) | ||
985 | #define SOFT_RESET_DB (1 << 3) | ||
986 | #define SOFT_RESET_GDS (1 << 4) | ||
987 | #define SOFT_RESET_PA (1 << 5) | ||
988 | #define SOFT_RESET_SC (1 << 6) | ||
989 | #define SOFT_RESET_BCI (1 << 7) | ||
990 | #define SOFT_RESET_SPI (1 << 8) | ||
991 | #define SOFT_RESET_SX (1 << 10) | ||
992 | #define SOFT_RESET_TC (1 << 11) | ||
993 | #define SOFT_RESET_TA (1 << 12) | ||
994 | #define SOFT_RESET_VGT (1 << 14) | ||
995 | #define SOFT_RESET_IA (1 << 15) | ||
996 | |||
997 | #define GRBM_GFX_INDEX 0x200B | ||
998 | #define INSTANCE_INDEX(x) ((x) << 0) | ||
999 | #define SH_INDEX(x) ((x) << 8) | ||
1000 | #define SE_INDEX(x) ((x) << 16) | ||
1001 | #define SH_BROADCAST_WRITES (1 << 29) | ||
1002 | #define INSTANCE_BROADCAST_WRITES (1 << 30) | ||
1003 | #define SE_BROADCAST_WRITES (1 << 31) | ||
1004 | |||
1005 | #define GRBM_INT_CNTL 0x2018 | ||
1006 | # define RDERR_INT_ENABLE (1 << 0) | ||
1007 | # define GUI_IDLE_INT_ENABLE (1 << 19) | ||
1008 | |||
1009 | #define CP_STRMOUT_CNTL 0x213F | ||
1010 | #define SCRATCH_REG0 0x2140 | ||
1011 | #define SCRATCH_REG1 0x2141 | ||
1012 | #define SCRATCH_REG2 0x2142 | ||
1013 | #define SCRATCH_REG3 0x2143 | ||
1014 | #define SCRATCH_REG4 0x2144 | ||
1015 | #define SCRATCH_REG5 0x2145 | ||
1016 | #define SCRATCH_REG6 0x2146 | ||
1017 | #define SCRATCH_REG7 0x2147 | ||
1018 | |||
1019 | #define SCRATCH_UMSK 0x2150 | ||
1020 | #define SCRATCH_ADDR 0x2151 | ||
1021 | |||
1022 | #define CP_SEM_WAIT_TIMER 0x216F | ||
1023 | |||
1024 | #define CP_SEM_INCOMPLETE_TIMER_CNTL 0x2172 | ||
1025 | |||
1026 | #define CP_ME_CNTL 0x21B6 | ||
1027 | #define CP_CE_HALT (1 << 24) | ||
1028 | #define CP_PFP_HALT (1 << 26) | ||
1029 | #define CP_ME_HALT (1 << 28) | ||
1030 | |||
1031 | #define CP_COHER_CNTL2 0x217A | ||
1032 | |||
1033 | #define CP_RB2_RPTR 0x21BE | ||
1034 | #define CP_RB1_RPTR 0x21BF | ||
1035 | #define CP_RB0_RPTR 0x21C0 | ||
1036 | #define CP_RB_WPTR_DELAY 0x21C1 | ||
1037 | |||
1038 | #define CP_QUEUE_THRESHOLDS 0x21D8 | ||
1039 | #define ROQ_IB1_START(x) ((x) << 0) | ||
1040 | #define ROQ_IB2_START(x) ((x) << 8) | ||
1041 | #define CP_MEQ_THRESHOLDS 0x21D9 | ||
1042 | #define MEQ1_START(x) ((x) << 0) | ||
1043 | #define MEQ2_START(x) ((x) << 8) | ||
1044 | |||
1045 | #define CP_PERFMON_CNTL 0x21FF | ||
1046 | |||
1047 | #define VGT_VTX_VECT_EJECT_REG 0x222C | ||
1048 | |||
1049 | #define VGT_CACHE_INVALIDATION 0x2231 | ||
1050 | #define CACHE_INVALIDATION(x) ((x) << 0) | ||
1051 | #define VC_ONLY 0 | ||
1052 | #define TC_ONLY 1 | ||
1053 | #define VC_AND_TC 2 | ||
1054 | #define AUTO_INVLD_EN(x) ((x) << 6) | ||
1055 | #define NO_AUTO 0 | ||
1056 | #define ES_AUTO 1 | ||
1057 | #define GS_AUTO 2 | ||
1058 | #define ES_AND_GS_AUTO 3 | ||
1059 | #define VGT_ESGS_RING_SIZE 0x2232 | ||
1060 | #define VGT_GSVS_RING_SIZE 0x2233 | ||
1061 | |||
1062 | #define VGT_GS_VERTEX_REUSE 0x2235 | ||
1063 | |||
1064 | #define VGT_PRIMITIVE_TYPE 0x2256 | ||
1065 | #define VGT_INDEX_TYPE 0x2257 | ||
1066 | |||
1067 | #define VGT_NUM_INDICES 0x225C | ||
1068 | #define VGT_NUM_INSTANCES 0x225D | ||
1069 | |||
1070 | #define VGT_TF_RING_SIZE 0x2262 | ||
1071 | |||
1072 | #define VGT_HS_OFFCHIP_PARAM 0x226C | ||
1073 | |||
1074 | #define VGT_TF_MEMORY_BASE 0x226E | ||
1075 | |||
1076 | #define CC_GC_SHADER_ARRAY_CONFIG 0x226F | ||
1077 | #define INACTIVE_CUS_MASK 0xFFFF0000 | ||
1078 | #define INACTIVE_CUS_SHIFT 16 | ||
1079 | #define GC_USER_SHADER_ARRAY_CONFIG 0x2270 | ||
1080 | |||
1081 | #define PA_CL_ENHANCE 0x2285 | ||
1082 | #define CLIP_VTX_REORDER_ENA (1 << 0) | ||
1083 | #define NUM_CLIP_SEQ(x) ((x) << 1) | ||
1084 | |||
1085 | #define PA_SU_LINE_STIPPLE_VALUE 0x2298 | ||
1086 | |||
1087 | #define PA_SC_LINE_STIPPLE_STATE 0x22C4 | ||
1088 | |||
1089 | #define PA_SC_FORCE_EOV_MAX_CNTS 0x22C9 | ||
1090 | #define FORCE_EOV_MAX_CLK_CNT(x) ((x) << 0) | ||
1091 | #define FORCE_EOV_MAX_REZ_CNT(x) ((x) << 16) | ||
1092 | |||
1093 | #define PA_SC_FIFO_SIZE 0x22F3 | ||
1094 | #define SC_FRONTEND_PRIM_FIFO_SIZE(x) ((x) << 0) | ||
1095 | #define SC_BACKEND_PRIM_FIFO_SIZE(x) ((x) << 6) | ||
1096 | #define SC_HIZ_TILE_FIFO_SIZE(x) ((x) << 15) | ||
1097 | #define SC_EARLYZ_TILE_FIFO_SIZE(x) ((x) << 23) | ||
1098 | |||
1099 | #define PA_SC_ENHANCE 0x22FC | ||
1100 | |||
1101 | #define SQ_CONFIG 0x2300 | ||
1102 | |||
1103 | #define SQC_CACHES 0x2302 | ||
1104 | |||
1105 | #define SQ_POWER_THROTTLE 0x2396 | ||
1106 | #define MIN_POWER(x) ((x) << 0) | ||
1107 | #define MIN_POWER_MASK (0x3fff << 0) | ||
1108 | #define MIN_POWER_SHIFT 0 | ||
1109 | #define MAX_POWER(x) ((x) << 16) | ||
1110 | #define MAX_POWER_MASK (0x3fff << 16) | ||
1111 | #define MAX_POWER_SHIFT 0 | ||
1112 | #define SQ_POWER_THROTTLE2 0x2397 | ||
1113 | #define MAX_POWER_DELTA(x) ((x) << 0) | ||
1114 | #define MAX_POWER_DELTA_MASK (0x3fff << 0) | ||
1115 | #define MAX_POWER_DELTA_SHIFT 0 | ||
1116 | #define STI_SIZE(x) ((x) << 16) | ||
1117 | #define STI_SIZE_MASK (0x3ff << 16) | ||
1118 | #define STI_SIZE_SHIFT 16 | ||
1119 | #define LTI_RATIO(x) ((x) << 27) | ||
1120 | #define LTI_RATIO_MASK (0xf << 27) | ||
1121 | #define LTI_RATIO_SHIFT 27 | ||
1122 | |||
1123 | #define SX_DEBUG_1 0x2418 | ||
1124 | |||
1125 | #define SPI_STATIC_THREAD_MGMT_1 0x2438 | ||
1126 | #define SPI_STATIC_THREAD_MGMT_2 0x2439 | ||
1127 | #define SPI_STATIC_THREAD_MGMT_3 0x243A | ||
1128 | #define SPI_PS_MAX_WAVE_ID 0x243B | ||
1129 | |||
1130 | #define SPI_CONFIG_CNTL 0x2440 | ||
1131 | |||
1132 | #define SPI_CONFIG_CNTL_1 0x244F | ||
1133 | #define VTX_DONE_DELAY(x) ((x) << 0) | ||
1134 | #define INTERP_ONE_PRIM_PER_ROW (1 << 4) | ||
1135 | |||
1136 | #define CGTS_TCC_DISABLE 0x2452 | ||
1137 | #define CGTS_USER_TCC_DISABLE 0x2453 | ||
1138 | #define TCC_DISABLE_MASK 0xFFFF0000 | ||
1139 | #define TCC_DISABLE_SHIFT 16 | ||
1140 | #define CGTS_SM_CTRL_REG 0x2454 | ||
1141 | #define OVERRIDE (1 << 21) | ||
1142 | #define LS_OVERRIDE (1 << 22) | ||
1143 | |||
1144 | #define SPI_LB_CU_MASK 0x24D5 | ||
1145 | |||
1146 | #define TA_CNTL_AUX 0x2542 | ||
1147 | |||
1148 | #define CC_RB_BACKEND_DISABLE 0x263D | ||
1149 | #define BACKEND_DISABLE(x) ((x) << 16) | ||
1150 | #define GB_ADDR_CONFIG 0x263E | ||
1151 | #define NUM_PIPES(x) ((x) << 0) | ||
1152 | #define NUM_PIPES_MASK 0x00000007 | ||
1153 | #define NUM_PIPES_SHIFT 0 | ||
1154 | #define PIPE_INTERLEAVE_SIZE(x) ((x) << 4) | ||
1155 | #define PIPE_INTERLEAVE_SIZE_MASK 0x00000070 | ||
1156 | #define PIPE_INTERLEAVE_SIZE_SHIFT 4 | ||
1157 | #define NUM_SHADER_ENGINES(x) ((x) << 12) | ||
1158 | #define NUM_SHADER_ENGINES_MASK 0x00003000 | ||
1159 | #define NUM_SHADER_ENGINES_SHIFT 12 | ||
1160 | #define SHADER_ENGINE_TILE_SIZE(x) ((x) << 16) | ||
1161 | #define SHADER_ENGINE_TILE_SIZE_MASK 0x00070000 | ||
1162 | #define SHADER_ENGINE_TILE_SIZE_SHIFT 16 | ||
1163 | #define NUM_GPUS(x) ((x) << 20) | ||
1164 | #define NUM_GPUS_MASK 0x00700000 | ||
1165 | #define NUM_GPUS_SHIFT 20 | ||
1166 | #define MULTI_GPU_TILE_SIZE(x) ((x) << 24) | ||
1167 | #define MULTI_GPU_TILE_SIZE_MASK 0x03000000 | ||
1168 | #define MULTI_GPU_TILE_SIZE_SHIFT 24 | ||
1169 | #define ROW_SIZE(x) ((x) << 28) | ||
1170 | #define ROW_SIZE_MASK 0x30000000 | ||
1171 | #define ROW_SIZE_SHIFT 28 | ||
1172 | |||
1173 | #define GB_TILE_MODE0 0x2644 | ||
1174 | # define MICRO_TILE_MODE(x) ((x) << 0) | ||
1175 | # define ADDR_SURF_DISPLAY_MICRO_TILING 0 | ||
1176 | # define ADDR_SURF_THIN_MICRO_TILING 1 | ||
1177 | # define ADDR_SURF_DEPTH_MICRO_TILING 2 | ||
1178 | # define ARRAY_MODE(x) ((x) << 2) | ||
1179 | # define ARRAY_LINEAR_GENERAL 0 | ||
1180 | # define ARRAY_LINEAR_ALIGNED 1 | ||
1181 | # define ARRAY_1D_TILED_THIN1 2 | ||
1182 | # define ARRAY_2D_TILED_THIN1 4 | ||
1183 | # define PIPE_CONFIG(x) ((x) << 6) | ||
1184 | # define ADDR_SURF_P2 0 | ||
1185 | # define ADDR_SURF_P4_8x16 4 | ||
1186 | # define ADDR_SURF_P4_16x16 5 | ||
1187 | # define ADDR_SURF_P4_16x32 6 | ||
1188 | # define ADDR_SURF_P4_32x32 7 | ||
1189 | # define ADDR_SURF_P8_16x16_8x16 8 | ||
1190 | # define ADDR_SURF_P8_16x32_8x16 9 | ||
1191 | # define ADDR_SURF_P8_32x32_8x16 10 | ||
1192 | # define ADDR_SURF_P8_16x32_16x16 11 | ||
1193 | # define ADDR_SURF_P8_32x32_16x16 12 | ||
1194 | # define ADDR_SURF_P8_32x32_16x32 13 | ||
1195 | # define ADDR_SURF_P8_32x64_32x32 14 | ||
1196 | # define TILE_SPLIT(x) ((x) << 11) | ||
1197 | # define ADDR_SURF_TILE_SPLIT_64B 0 | ||
1198 | # define ADDR_SURF_TILE_SPLIT_128B 1 | ||
1199 | # define ADDR_SURF_TILE_SPLIT_256B 2 | ||
1200 | # define ADDR_SURF_TILE_SPLIT_512B 3 | ||
1201 | # define ADDR_SURF_TILE_SPLIT_1KB 4 | ||
1202 | # define ADDR_SURF_TILE_SPLIT_2KB 5 | ||
1203 | # define ADDR_SURF_TILE_SPLIT_4KB 6 | ||
1204 | # define BANK_WIDTH(x) ((x) << 14) | ||
1205 | # define ADDR_SURF_BANK_WIDTH_1 0 | ||
1206 | # define ADDR_SURF_BANK_WIDTH_2 1 | ||
1207 | # define ADDR_SURF_BANK_WIDTH_4 2 | ||
1208 | # define ADDR_SURF_BANK_WIDTH_8 3 | ||
1209 | # define BANK_HEIGHT(x) ((x) << 16) | ||
1210 | # define ADDR_SURF_BANK_HEIGHT_1 0 | ||
1211 | # define ADDR_SURF_BANK_HEIGHT_2 1 | ||
1212 | # define ADDR_SURF_BANK_HEIGHT_4 2 | ||
1213 | # define ADDR_SURF_BANK_HEIGHT_8 3 | ||
1214 | # define MACRO_TILE_ASPECT(x) ((x) << 18) | ||
1215 | # define ADDR_SURF_MACRO_ASPECT_1 0 | ||
1216 | # define ADDR_SURF_MACRO_ASPECT_2 1 | ||
1217 | # define ADDR_SURF_MACRO_ASPECT_4 2 | ||
1218 | # define ADDR_SURF_MACRO_ASPECT_8 3 | ||
1219 | # define NUM_BANKS(x) ((x) << 20) | ||
1220 | # define ADDR_SURF_2_BANK 0 | ||
1221 | # define ADDR_SURF_4_BANK 1 | ||
1222 | # define ADDR_SURF_8_BANK 2 | ||
1223 | # define ADDR_SURF_16_BANK 3 | ||
1224 | #define GB_TILE_MODE1 0x2645 | ||
1225 | #define GB_TILE_MODE2 0x2646 | ||
1226 | #define GB_TILE_MODE3 0x2647 | ||
1227 | #define GB_TILE_MODE4 0x2648 | ||
1228 | #define GB_TILE_MODE5 0x2649 | ||
1229 | #define GB_TILE_MODE6 0x264a | ||
1230 | #define GB_TILE_MODE7 0x264b | ||
1231 | #define GB_TILE_MODE8 0x264c | ||
1232 | #define GB_TILE_MODE9 0x264d | ||
1233 | #define GB_TILE_MODE10 0x264e | ||
1234 | #define GB_TILE_MODE11 0x264f | ||
1235 | #define GB_TILE_MODE12 0x2650 | ||
1236 | #define GB_TILE_MODE13 0x2651 | ||
1237 | #define GB_TILE_MODE14 0x2652 | ||
1238 | #define GB_TILE_MODE15 0x2653 | ||
1239 | #define GB_TILE_MODE16 0x2654 | ||
1240 | #define GB_TILE_MODE17 0x2655 | ||
1241 | #define GB_TILE_MODE18 0x2656 | ||
1242 | #define GB_TILE_MODE19 0x2657 | ||
1243 | #define GB_TILE_MODE20 0x2658 | ||
1244 | #define GB_TILE_MODE21 0x2659 | ||
1245 | #define GB_TILE_MODE22 0x265a | ||
1246 | #define GB_TILE_MODE23 0x265b | ||
1247 | #define GB_TILE_MODE24 0x265c | ||
1248 | #define GB_TILE_MODE25 0x265d | ||
1249 | #define GB_TILE_MODE26 0x265e | ||
1250 | #define GB_TILE_MODE27 0x265f | ||
1251 | #define GB_TILE_MODE28 0x2660 | ||
1252 | #define GB_TILE_MODE29 0x2661 | ||
1253 | #define GB_TILE_MODE30 0x2662 | ||
1254 | #define GB_TILE_MODE31 0x2663 | ||
1255 | |||
1256 | #define CB_PERFCOUNTER0_SELECT0 0x2688 | ||
1257 | #define CB_PERFCOUNTER0_SELECT1 0x2689 | ||
1258 | #define CB_PERFCOUNTER1_SELECT0 0x268A | ||
1259 | #define CB_PERFCOUNTER1_SELECT1 0x268B | ||
1260 | #define CB_PERFCOUNTER2_SELECT0 0x268C | ||
1261 | #define CB_PERFCOUNTER2_SELECT1 0x268D | ||
1262 | #define CB_PERFCOUNTER3_SELECT0 0x268E | ||
1263 | #define CB_PERFCOUNTER3_SELECT1 0x268F | ||
1264 | |||
1265 | #define CB_CGTT_SCLK_CTRL 0x2698 | ||
1266 | |||
1267 | #define GC_USER_RB_BACKEND_DISABLE 0x26DF | ||
1268 | #define BACKEND_DISABLE_MASK 0x00FF0000 | ||
1269 | #define BACKEND_DISABLE_SHIFT 16 | ||
1270 | |||
1271 | #define TCP_CHAN_STEER_LO 0x2B03 | ||
1272 | #define TCP_CHAN_STEER_HI 0x2B94 | ||
1273 | |||
1274 | #define CP_RB0_BASE 0x3040 | ||
1275 | #define CP_RB0_CNTL 0x3041 | ||
1276 | #define RB_BUFSZ(x) ((x) << 0) | ||
1277 | #define RB_BLKSZ(x) ((x) << 8) | ||
1278 | #define BUF_SWAP_32BIT (2 << 16) | ||
1279 | #define RB_NO_UPDATE (1 << 27) | ||
1280 | #define RB_RPTR_WR_ENA (1 << 31) | ||
1281 | |||
1282 | #define CP_RB0_RPTR_ADDR 0x3043 | ||
1283 | #define CP_RB0_RPTR_ADDR_HI 0x3044 | ||
1284 | #define CP_RB0_WPTR 0x3045 | ||
1285 | |||
1286 | #define CP_PFP_UCODE_ADDR 0x3054 | ||
1287 | #define CP_PFP_UCODE_DATA 0x3055 | ||
1288 | #define CP_ME_RAM_RADDR 0x3056 | ||
1289 | #define CP_ME_RAM_WADDR 0x3057 | ||
1290 | #define CP_ME_RAM_DATA 0x3058 | ||
1291 | |||
1292 | #define CP_CE_UCODE_ADDR 0x305A | ||
1293 | #define CP_CE_UCODE_DATA 0x305B | ||
1294 | |||
1295 | #define CP_RB1_BASE 0x3060 | ||
1296 | #define CP_RB1_CNTL 0x3061 | ||
1297 | #define CP_RB1_RPTR_ADDR 0x3062 | ||
1298 | #define CP_RB1_RPTR_ADDR_HI 0x3063 | ||
1299 | #define CP_RB1_WPTR 0x3064 | ||
1300 | #define CP_RB2_BASE 0x3065 | ||
1301 | #define CP_RB2_CNTL 0x3066 | ||
1302 | #define CP_RB2_RPTR_ADDR 0x3067 | ||
1303 | #define CP_RB2_RPTR_ADDR_HI 0x3068 | ||
1304 | #define CP_RB2_WPTR 0x3069 | ||
1305 | #define CP_INT_CNTL_RING0 0x306A | ||
1306 | #define CP_INT_CNTL_RING1 0x306B | ||
1307 | #define CP_INT_CNTL_RING2 0x306C | ||
1308 | # define CNTX_BUSY_INT_ENABLE (1 << 19) | ||
1309 | # define CNTX_EMPTY_INT_ENABLE (1 << 20) | ||
1310 | # define WAIT_MEM_SEM_INT_ENABLE (1 << 21) | ||
1311 | # define TIME_STAMP_INT_ENABLE (1 << 26) | ||
1312 | # define CP_RINGID2_INT_ENABLE (1 << 29) | ||
1313 | # define CP_RINGID1_INT_ENABLE (1 << 30) | ||
1314 | # define CP_RINGID0_INT_ENABLE (1 << 31) | ||
1315 | #define CP_INT_STATUS_RING0 0x306D | ||
1316 | #define CP_INT_STATUS_RING1 0x306E | ||
1317 | #define CP_INT_STATUS_RING2 0x306F | ||
1318 | # define WAIT_MEM_SEM_INT_STAT (1 << 21) | ||
1319 | # define TIME_STAMP_INT_STAT (1 << 26) | ||
1320 | # define CP_RINGID2_INT_STAT (1 << 29) | ||
1321 | # define CP_RINGID1_INT_STAT (1 << 30) | ||
1322 | # define CP_RINGID0_INT_STAT (1 << 31) | ||
1323 | |||
1324 | #define CP_MEM_SLP_CNTL 0x3079 | ||
1325 | # define CP_MEM_LS_EN (1 << 0) | ||
1326 | |||
1327 | #define CP_DEBUG 0x307F | ||
1328 | |||
1329 | #define RLC_CNTL 0x30C0 | ||
1330 | # define RLC_ENABLE (1 << 0) | ||
1331 | #define RLC_RL_BASE 0x30C1 | ||
1332 | #define RLC_RL_SIZE 0x30C2 | ||
1333 | #define RLC_LB_CNTL 0x30C3 | ||
1334 | # define LOAD_BALANCE_ENABLE (1 << 0) | ||
1335 | #define RLC_SAVE_AND_RESTORE_BASE 0x30C4 | ||
1336 | #define RLC_LB_CNTR_MAX 0x30C5 | ||
1337 | #define RLC_LB_CNTR_INIT 0x30C6 | ||
1338 | |||
1339 | #define RLC_CLEAR_STATE_RESTORE_BASE 0x30C8 | ||
1340 | |||
1341 | #define RLC_UCODE_ADDR 0x30CB | ||
1342 | #define RLC_UCODE_DATA 0x30CC | ||
1343 | |||
1344 | #define RLC_GPU_CLOCK_COUNT_LSB 0x30CE | ||
1345 | #define RLC_GPU_CLOCK_COUNT_MSB 0x30CF | ||
1346 | #define RLC_CAPTURE_GPU_CLOCK_COUNT 0x30D0 | ||
1347 | #define RLC_MC_CNTL 0x30D1 | ||
1348 | #define RLC_UCODE_CNTL 0x30D2 | ||
1349 | #define RLC_STAT 0x30D3 | ||
1350 | # define RLC_BUSY_STATUS (1 << 0) | ||
1351 | # define GFX_POWER_STATUS (1 << 1) | ||
1352 | # define GFX_CLOCK_STATUS (1 << 2) | ||
1353 | # define GFX_LS_STATUS (1 << 3) | ||
1354 | |||
1355 | #define RLC_PG_CNTL 0x30D7 | ||
1356 | # define GFX_PG_ENABLE (1 << 0) | ||
1357 | # define GFX_PG_SRC (1 << 1) | ||
1358 | |||
1359 | #define RLC_CGTT_MGCG_OVERRIDE 0x3100 | ||
1360 | #define RLC_CGCG_CGLS_CTRL 0x3101 | ||
1361 | # define CGCG_EN (1 << 0) | ||
1362 | # define CGLS_EN (1 << 1) | ||
1363 | |||
1364 | #define RLC_TTOP_D 0x3105 | ||
1365 | # define RLC_PUD(x) ((x) << 0) | ||
1366 | # define RLC_PUD_MASK (0xff << 0) | ||
1367 | # define RLC_PDD(x) ((x) << 8) | ||
1368 | # define RLC_PDD_MASK (0xff << 8) | ||
1369 | # define RLC_TTPD(x) ((x) << 16) | ||
1370 | # define RLC_TTPD_MASK (0xff << 16) | ||
1371 | # define RLC_MSD(x) ((x) << 24) | ||
1372 | # define RLC_MSD_MASK (0xff << 24) | ||
1373 | |||
1374 | #define RLC_LB_INIT_CU_MASK 0x3107 | ||
1375 | |||
1376 | #define RLC_PG_AO_CU_MASK 0x310B | ||
1377 | #define RLC_MAX_PG_CU 0x310C | ||
1378 | # define MAX_PU_CU(x) ((x) << 0) | ||
1379 | # define MAX_PU_CU_MASK (0xff << 0) | ||
1380 | #define RLC_AUTO_PG_CTRL 0x310C | ||
1381 | # define AUTO_PG_EN (1 << 0) | ||
1382 | # define GRBM_REG_SGIT(x) ((x) << 3) | ||
1383 | # define GRBM_REG_SGIT_MASK (0xffff << 3) | ||
1384 | # define PG_AFTER_GRBM_REG_ST(x) ((x) << 19) | ||
1385 | # define PG_AFTER_GRBM_REG_ST_MASK (0x1fff << 19) | ||
1386 | |||
1387 | #define RLC_SERDES_WR_MASTER_MASK_0 0x3115 | ||
1388 | #define RLC_SERDES_WR_MASTER_MASK_1 0x3116 | ||
1389 | #define RLC_SERDES_WR_CTRL 0x3117 | ||
1390 | |||
1391 | #define RLC_SERDES_MASTER_BUSY_0 0x3119 | ||
1392 | #define RLC_SERDES_MASTER_BUSY_1 0x311A | ||
1393 | |||
1394 | #define RLC_GCPM_GENERAL_3 0x311E | ||
1395 | |||
1396 | #define DB_RENDER_CONTROL 0xA000 | ||
1397 | |||
1398 | #define DB_DEPTH_INFO 0xA00F | ||
1399 | |||
1400 | #define PA_SC_RASTER_CONFIG 0xA0D4 | ||
1401 | # define RASTER_CONFIG_RB_MAP_0 0 | ||
1402 | # define RASTER_CONFIG_RB_MAP_1 1 | ||
1403 | # define RASTER_CONFIG_RB_MAP_2 2 | ||
1404 | # define RASTER_CONFIG_RB_MAP_3 3 | ||
1405 | |||
1406 | #define VGT_EVENT_INITIATOR 0xA2A4 | ||
1407 | # define SAMPLE_STREAMOUTSTATS1 (1 << 0) | ||
1408 | # define SAMPLE_STREAMOUTSTATS2 (2 << 0) | ||
1409 | # define SAMPLE_STREAMOUTSTATS3 (3 << 0) | ||
1410 | # define CACHE_FLUSH_TS (4 << 0) | ||
1411 | # define CACHE_FLUSH (6 << 0) | ||
1412 | # define CS_PARTIAL_FLUSH (7 << 0) | ||
1413 | # define VGT_STREAMOUT_RESET (10 << 0) | ||
1414 | # define END_OF_PIPE_INCR_DE (11 << 0) | ||
1415 | # define END_OF_PIPE_IB_END (12 << 0) | ||
1416 | # define RST_PIX_CNT (13 << 0) | ||
1417 | # define VS_PARTIAL_FLUSH (15 << 0) | ||
1418 | # define PS_PARTIAL_FLUSH (16 << 0) | ||
1419 | # define CACHE_FLUSH_AND_INV_TS_EVENT (20 << 0) | ||
1420 | # define ZPASS_DONE (21 << 0) | ||
1421 | # define CACHE_FLUSH_AND_INV_EVENT (22 << 0) | ||
1422 | # define PERFCOUNTER_START (23 << 0) | ||
1423 | # define PERFCOUNTER_STOP (24 << 0) | ||
1424 | # define PIPELINESTAT_START (25 << 0) | ||
1425 | # define PIPELINESTAT_STOP (26 << 0) | ||
1426 | # define PERFCOUNTER_SAMPLE (27 << 0) | ||
1427 | # define SAMPLE_PIPELINESTAT (30 << 0) | ||
1428 | # define SAMPLE_STREAMOUTSTATS (32 << 0) | ||
1429 | # define RESET_VTX_CNT (33 << 0) | ||
1430 | # define VGT_FLUSH (36 << 0) | ||
1431 | # define BOTTOM_OF_PIPE_TS (40 << 0) | ||
1432 | # define DB_CACHE_FLUSH_AND_INV (42 << 0) | ||
1433 | # define FLUSH_AND_INV_DB_DATA_TS (43 << 0) | ||
1434 | # define FLUSH_AND_INV_DB_META (44 << 0) | ||
1435 | # define FLUSH_AND_INV_CB_DATA_TS (45 << 0) | ||
1436 | # define FLUSH_AND_INV_CB_META (46 << 0) | ||
1437 | # define CS_DONE (47 << 0) | ||
1438 | # define PS_DONE (48 << 0) | ||
1439 | # define FLUSH_AND_INV_CB_PIXEL_DATA (49 << 0) | ||
1440 | # define THREAD_TRACE_START (51 << 0) | ||
1441 | # define THREAD_TRACE_STOP (52 << 0) | ||
1442 | # define THREAD_TRACE_FLUSH (54 << 0) | ||
1443 | # define THREAD_TRACE_FINISH (55 << 0) | ||
1444 | |||
1445 | /* PIF PHY0 registers idx/data 0x8/0xc */ | ||
1446 | #define PB0_PIF_CNTL 0x10 | ||
1447 | # define LS2_EXIT_TIME(x) ((x) << 17) | ||
1448 | # define LS2_EXIT_TIME_MASK (0x7 << 17) | ||
1449 | # define LS2_EXIT_TIME_SHIFT 17 | ||
1450 | #define PB0_PIF_PAIRING 0x11 | ||
1451 | # define MULTI_PIF (1 << 25) | ||
1452 | #define PB0_PIF_PWRDOWN_0 0x12 | ||
1453 | # define PLL_POWER_STATE_IN_TXS2_0(x) ((x) << 7) | ||
1454 | # define PLL_POWER_STATE_IN_TXS2_0_MASK (0x7 << 7) | ||
1455 | # define PLL_POWER_STATE_IN_TXS2_0_SHIFT 7 | ||
1456 | # define PLL_POWER_STATE_IN_OFF_0(x) ((x) << 10) | ||
1457 | # define PLL_POWER_STATE_IN_OFF_0_MASK (0x7 << 10) | ||
1458 | # define PLL_POWER_STATE_IN_OFF_0_SHIFT 10 | ||
1459 | # define PLL_RAMP_UP_TIME_0(x) ((x) << 24) | ||
1460 | # define PLL_RAMP_UP_TIME_0_MASK (0x7 << 24) | ||
1461 | # define PLL_RAMP_UP_TIME_0_SHIFT 24 | ||
1462 | #define PB0_PIF_PWRDOWN_1 0x13 | ||
1463 | # define PLL_POWER_STATE_IN_TXS2_1(x) ((x) << 7) | ||
1464 | # define PLL_POWER_STATE_IN_TXS2_1_MASK (0x7 << 7) | ||
1465 | # define PLL_POWER_STATE_IN_TXS2_1_SHIFT 7 | ||
1466 | # define PLL_POWER_STATE_IN_OFF_1(x) ((x) << 10) | ||
1467 | # define PLL_POWER_STATE_IN_OFF_1_MASK (0x7 << 10) | ||
1468 | # define PLL_POWER_STATE_IN_OFF_1_SHIFT 10 | ||
1469 | # define PLL_RAMP_UP_TIME_1(x) ((x) << 24) | ||
1470 | # define PLL_RAMP_UP_TIME_1_MASK (0x7 << 24) | ||
1471 | # define PLL_RAMP_UP_TIME_1_SHIFT 24 | ||
1472 | |||
1473 | #define PB0_PIF_PWRDOWN_2 0x17 | ||
1474 | # define PLL_POWER_STATE_IN_TXS2_2(x) ((x) << 7) | ||
1475 | # define PLL_POWER_STATE_IN_TXS2_2_MASK (0x7 << 7) | ||
1476 | # define PLL_POWER_STATE_IN_TXS2_2_SHIFT 7 | ||
1477 | # define PLL_POWER_STATE_IN_OFF_2(x) ((x) << 10) | ||
1478 | # define PLL_POWER_STATE_IN_OFF_2_MASK (0x7 << 10) | ||
1479 | # define PLL_POWER_STATE_IN_OFF_2_SHIFT 10 | ||
1480 | # define PLL_RAMP_UP_TIME_2(x) ((x) << 24) | ||
1481 | # define PLL_RAMP_UP_TIME_2_MASK (0x7 << 24) | ||
1482 | # define PLL_RAMP_UP_TIME_2_SHIFT 24 | ||
1483 | #define PB0_PIF_PWRDOWN_3 0x18 | ||
1484 | # define PLL_POWER_STATE_IN_TXS2_3(x) ((x) << 7) | ||
1485 | # define PLL_POWER_STATE_IN_TXS2_3_MASK (0x7 << 7) | ||
1486 | # define PLL_POWER_STATE_IN_TXS2_3_SHIFT 7 | ||
1487 | # define PLL_POWER_STATE_IN_OFF_3(x) ((x) << 10) | ||
1488 | # define PLL_POWER_STATE_IN_OFF_3_MASK (0x7 << 10) | ||
1489 | # define PLL_POWER_STATE_IN_OFF_3_SHIFT 10 | ||
1490 | # define PLL_RAMP_UP_TIME_3(x) ((x) << 24) | ||
1491 | # define PLL_RAMP_UP_TIME_3_MASK (0x7 << 24) | ||
1492 | # define PLL_RAMP_UP_TIME_3_SHIFT 24 | ||
1493 | /* PIF PHY1 registers idx/data 0x10/0x14 */ | ||
1494 | #define PB1_PIF_CNTL 0x10 | ||
1495 | #define PB1_PIF_PAIRING 0x11 | ||
1496 | #define PB1_PIF_PWRDOWN_0 0x12 | ||
1497 | #define PB1_PIF_PWRDOWN_1 0x13 | ||
1498 | |||
1499 | #define PB1_PIF_PWRDOWN_2 0x17 | ||
1500 | #define PB1_PIF_PWRDOWN_3 0x18 | ||
1501 | /* PCIE registers idx/data 0x30/0x34 */ | ||
1502 | #define PCIE_CNTL2 0x1c /* PCIE */ | ||
1503 | # define SLV_MEM_LS_EN (1 << 16) | ||
1504 | # define SLV_MEM_AGGRESSIVE_LS_EN (1 << 17) | ||
1505 | # define MST_MEM_LS_EN (1 << 18) | ||
1506 | # define REPLAY_MEM_LS_EN (1 << 19) | ||
1507 | #define PCIE_LC_STATUS1 0x28 /* PCIE */ | ||
1508 | # define LC_REVERSE_RCVR (1 << 0) | ||
1509 | # define LC_REVERSE_XMIT (1 << 1) | ||
1510 | # define LC_OPERATING_LINK_WIDTH_MASK (0x7 << 2) | ||
1511 | # define LC_OPERATING_LINK_WIDTH_SHIFT 2 | ||
1512 | # define LC_DETECTED_LINK_WIDTH_MASK (0x7 << 5) | ||
1513 | # define LC_DETECTED_LINK_WIDTH_SHIFT 5 | ||
1514 | |||
1515 | #define PCIE_P_CNTL 0x40 /* PCIE */ | ||
1516 | # define P_IGNORE_EDB_ERR (1 << 6) | ||
1517 | |||
1518 | /* PCIE PORT registers idx/data 0x38/0x3c */ | ||
1519 | #define PCIE_LC_CNTL 0xa0 | ||
1520 | # define LC_L0S_INACTIVITY(x) ((x) << 8) | ||
1521 | # define LC_L0S_INACTIVITY_MASK (0xf << 8) | ||
1522 | # define LC_L0S_INACTIVITY_SHIFT 8 | ||
1523 | # define LC_L1_INACTIVITY(x) ((x) << 12) | ||
1524 | # define LC_L1_INACTIVITY_MASK (0xf << 12) | ||
1525 | # define LC_L1_INACTIVITY_SHIFT 12 | ||
1526 | # define LC_PMI_TO_L1_DIS (1 << 16) | ||
1527 | # define LC_ASPM_TO_L1_DIS (1 << 24) | ||
1528 | #define PCIE_LC_LINK_WIDTH_CNTL 0xa2 /* PCIE_P */ | ||
1529 | # define LC_LINK_WIDTH_SHIFT 0 | ||
1530 | # define LC_LINK_WIDTH_MASK 0x7 | ||
1531 | # define LC_LINK_WIDTH_X0 0 | ||
1532 | # define LC_LINK_WIDTH_X1 1 | ||
1533 | # define LC_LINK_WIDTH_X2 2 | ||
1534 | # define LC_LINK_WIDTH_X4 3 | ||
1535 | # define LC_LINK_WIDTH_X8 4 | ||
1536 | # define LC_LINK_WIDTH_X16 6 | ||
1537 | # define LC_LINK_WIDTH_RD_SHIFT 4 | ||
1538 | # define LC_LINK_WIDTH_RD_MASK 0x70 | ||
1539 | # define LC_RECONFIG_ARC_MISSING_ESCAPE (1 << 7) | ||
1540 | # define LC_RECONFIG_NOW (1 << 8) | ||
1541 | # define LC_RENEGOTIATION_SUPPORT (1 << 9) | ||
1542 | # define LC_RENEGOTIATE_EN (1 << 10) | ||
1543 | # define LC_SHORT_RECONFIG_EN (1 << 11) | ||
1544 | # define LC_UPCONFIGURE_SUPPORT (1 << 12) | ||
1545 | # define LC_UPCONFIGURE_DIS (1 << 13) | ||
1546 | # define LC_DYN_LANES_PWR_STATE(x) ((x) << 21) | ||
1547 | # define LC_DYN_LANES_PWR_STATE_MASK (0x3 << 21) | ||
1548 | # define LC_DYN_LANES_PWR_STATE_SHIFT 21 | ||
1549 | #define PCIE_LC_N_FTS_CNTL 0xa3 /* PCIE_P */ | ||
1550 | # define LC_XMIT_N_FTS(x) ((x) << 0) | ||
1551 | # define LC_XMIT_N_FTS_MASK (0xff << 0) | ||
1552 | # define LC_XMIT_N_FTS_SHIFT 0 | ||
1553 | # define LC_XMIT_N_FTS_OVERRIDE_EN (1 << 8) | ||
1554 | # define LC_N_FTS_MASK (0xff << 24) | ||
1555 | #define PCIE_LC_SPEED_CNTL 0xa4 /* PCIE_P */ | ||
1556 | # define LC_GEN2_EN_STRAP (1 << 0) | ||
1557 | # define LC_GEN3_EN_STRAP (1 << 1) | ||
1558 | # define LC_TARGET_LINK_SPEED_OVERRIDE_EN (1 << 2) | ||
1559 | # define LC_TARGET_LINK_SPEED_OVERRIDE_MASK (0x3 << 3) | ||
1560 | # define LC_TARGET_LINK_SPEED_OVERRIDE_SHIFT 3 | ||
1561 | # define LC_FORCE_EN_SW_SPEED_CHANGE (1 << 5) | ||
1562 | # define LC_FORCE_DIS_SW_SPEED_CHANGE (1 << 6) | ||
1563 | # define LC_FORCE_EN_HW_SPEED_CHANGE (1 << 7) | ||
1564 | # define LC_FORCE_DIS_HW_SPEED_CHANGE (1 << 8) | ||
1565 | # define LC_INITIATE_LINK_SPEED_CHANGE (1 << 9) | ||
1566 | # define LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_MASK (0x3 << 10) | ||
1567 | # define LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_SHIFT 10 | ||
1568 | # define LC_CURRENT_DATA_RATE_MASK (0x3 << 13) /* 0/1/2 = gen1/2/3 */ | ||
1569 | # define LC_CURRENT_DATA_RATE_SHIFT 13 | ||
1570 | # define LC_CLR_FAILED_SPD_CHANGE_CNT (1 << 16) | ||
1571 | # define LC_OTHER_SIDE_EVER_SENT_GEN2 (1 << 18) | ||
1572 | # define LC_OTHER_SIDE_SUPPORTS_GEN2 (1 << 19) | ||
1573 | # define LC_OTHER_SIDE_EVER_SENT_GEN3 (1 << 20) | ||
1574 | # define LC_OTHER_SIDE_SUPPORTS_GEN3 (1 << 21) | ||
1575 | |||
1576 | #define PCIE_LC_CNTL2 0xb1 | ||
1577 | # define LC_ALLOW_PDWN_IN_L1 (1 << 17) | ||
1578 | # define LC_ALLOW_PDWN_IN_L23 (1 << 18) | ||
1579 | |||
1580 | #define PCIE_LC_CNTL3 0xb5 /* PCIE_P */ | ||
1581 | # define LC_GO_TO_RECOVERY (1 << 30) | ||
1582 | #define PCIE_LC_CNTL4 0xb6 /* PCIE_P */ | ||
1583 | # define LC_REDO_EQ (1 << 5) | ||
1584 | # define LC_SET_QUIESCE (1 << 13) | ||
1585 | |||
1586 | /* | ||
1587 | * UVD | ||
1588 | */ | ||
1589 | #define UVD_UDEC_ADDR_CONFIG 0x3bd3 | ||
1590 | #define UVD_UDEC_DB_ADDR_CONFIG 0x3bd4 | ||
1591 | #define UVD_UDEC_DBW_ADDR_CONFIG 0x3bd5 | ||
1592 | #define UVD_RBC_RB_RPTR 0x3da4 | ||
1593 | #define UVD_RBC_RB_WPTR 0x3da5 | ||
1594 | #define UVD_STATUS 0x3daf | ||
1595 | |||
1596 | #define UVD_CGC_CTRL 0x3dc2 | ||
1597 | # define DCM (1 << 0) | ||
1598 | # define CG_DT(x) ((x) << 2) | ||
1599 | # define CG_DT_MASK (0xf << 2) | ||
1600 | # define CLK_OD(x) ((x) << 6) | ||
1601 | # define CLK_OD_MASK (0x1f << 6) | ||
1602 | |||
1603 | /* UVD CTX indirect */ | ||
1604 | #define UVD_CGC_MEM_CTRL 0xC0 | ||
1605 | #define UVD_CGC_CTRL2 0xC1 | ||
1606 | # define DYN_OR_EN (1 << 0) | ||
1607 | # define DYN_RR_EN (1 << 1) | ||
1608 | # define G_DIV_ID(x) ((x) << 2) | ||
1609 | # define G_DIV_ID_MASK (0x7 << 2) | ||
1610 | |||
1611 | /* | ||
1612 | * PM4 | ||
1613 | */ | ||
1614 | #define PACKET0(reg, n) ((RADEON_PACKET_TYPE0 << 30) | \ | ||
1615 | (((reg) >> 2) & 0xFFFF) | \ | ||
1616 | ((n) & 0x3FFF) << 16) | ||
1617 | #define CP_PACKET2 0x80000000 | ||
1618 | #define PACKET2_PAD_SHIFT 0 | ||
1619 | #define PACKET2_PAD_MASK (0x3fffffff << 0) | ||
1620 | |||
1621 | #define PACKET2(v) (CP_PACKET2 | REG_SET(PACKET2_PAD, (v))) | ||
1622 | #define RADEON_PACKET_TYPE3 3 | ||
1623 | #define PACKET3(op, n) ((RADEON_PACKET_TYPE3 << 30) | \ | ||
1624 | (((op) & 0xFF) << 8) | \ | ||
1625 | ((n) & 0x3FFF) << 16) | ||
1626 | |||
1627 | #define PACKET3_COMPUTE(op, n) (PACKET3(op, n) | 1 << 1) | ||
1628 | |||
1629 | /* Packet 3 types */ | ||
1630 | #define PACKET3_NOP 0x10 | ||
1631 | #define PACKET3_SET_BASE 0x11 | ||
1632 | #define PACKET3_BASE_INDEX(x) ((x) << 0) | ||
1633 | #define GDS_PARTITION_BASE 2 | ||
1634 | #define CE_PARTITION_BASE 3 | ||
1635 | #define PACKET3_CLEAR_STATE 0x12 | ||
1636 | #define PACKET3_INDEX_BUFFER_SIZE 0x13 | ||
1637 | #define PACKET3_DISPATCH_DIRECT 0x15 | ||
1638 | #define PACKET3_DISPATCH_INDIRECT 0x16 | ||
1639 | #define PACKET3_ALLOC_GDS 0x1B | ||
1640 | #define PACKET3_WRITE_GDS_RAM 0x1C | ||
1641 | #define PACKET3_ATOMIC_GDS 0x1D | ||
1642 | #define PACKET3_ATOMIC 0x1E | ||
1643 | #define PACKET3_OCCLUSION_QUERY 0x1F | ||
1644 | #define PACKET3_SET_PREDICATION 0x20 | ||
1645 | #define PACKET3_REG_RMW 0x21 | ||
1646 | #define PACKET3_COND_EXEC 0x22 | ||
1647 | #define PACKET3_PRED_EXEC 0x23 | ||
1648 | #define PACKET3_DRAW_INDIRECT 0x24 | ||
1649 | #define PACKET3_DRAW_INDEX_INDIRECT 0x25 | ||
1650 | #define PACKET3_INDEX_BASE 0x26 | ||
1651 | #define PACKET3_DRAW_INDEX_2 0x27 | ||
1652 | #define PACKET3_CONTEXT_CONTROL 0x28 | ||
1653 | #define PACKET3_INDEX_TYPE 0x2A | ||
1654 | #define PACKET3_DRAW_INDIRECT_MULTI 0x2C | ||
1655 | #define PACKET3_DRAW_INDEX_AUTO 0x2D | ||
1656 | #define PACKET3_DRAW_INDEX_IMMD 0x2E | ||
1657 | #define PACKET3_NUM_INSTANCES 0x2F | ||
1658 | #define PACKET3_DRAW_INDEX_MULTI_AUTO 0x30 | ||
1659 | #define PACKET3_INDIRECT_BUFFER_CONST 0x31 | ||
1660 | #define PACKET3_INDIRECT_BUFFER 0x3F | ||
1661 | #define PACKET3_STRMOUT_BUFFER_UPDATE 0x34 | ||
1662 | #define PACKET3_DRAW_INDEX_OFFSET_2 0x35 | ||
1663 | #define PACKET3_DRAW_INDEX_MULTI_ELEMENT 0x36 | ||
1664 | #define PACKET3_WRITE_DATA 0x37 | ||
1665 | #define WRITE_DATA_DST_SEL(x) ((x) << 8) | ||
1666 | /* 0 - register | ||
1667 | * 1 - memory (sync - via GRBM) | ||
1668 | * 2 - tc/l2 | ||
1669 | * 3 - gds | ||
1670 | * 4 - reserved | ||
1671 | * 5 - memory (async - direct) | ||
1672 | */ | ||
1673 | #define WR_ONE_ADDR (1 << 16) | ||
1674 | #define WR_CONFIRM (1 << 20) | ||
1675 | #define WRITE_DATA_ENGINE_SEL(x) ((x) << 30) | ||
1676 | /* 0 - me | ||
1677 | * 1 - pfp | ||
1678 | * 2 - ce | ||
1679 | */ | ||
1680 | #define PACKET3_DRAW_INDEX_INDIRECT_MULTI 0x38 | ||
1681 | #define PACKET3_MEM_SEMAPHORE 0x39 | ||
1682 | #define PACKET3_MPEG_INDEX 0x3A | ||
1683 | #define PACKET3_COPY_DW 0x3B | ||
1684 | #define PACKET3_WAIT_REG_MEM 0x3C | ||
1685 | #define WAIT_REG_MEM_FUNCTION(x) ((x) << 0) | ||
1686 | /* 0 - always | ||
1687 | * 1 - < | ||
1688 | * 2 - <= | ||
1689 | * 3 - == | ||
1690 | * 4 - != | ||
1691 | * 5 - >= | ||
1692 | * 6 - > | ||
1693 | */ | ||
1694 | #define WAIT_REG_MEM_MEM_SPACE(x) ((x) << 4) | ||
1695 | /* 0 - reg | ||
1696 | * 1 - mem | ||
1697 | */ | ||
1698 | #define WAIT_REG_MEM_ENGINE(x) ((x) << 8) | ||
1699 | /* 0 - me | ||
1700 | * 1 - pfp | ||
1701 | */ | ||
1702 | #define PACKET3_MEM_WRITE 0x3D | ||
1703 | #define PACKET3_COPY_DATA 0x40 | ||
1704 | #define PACKET3_CP_DMA 0x41 | ||
1705 | /* 1. header | ||
1706 | * 2. SRC_ADDR_LO or DATA [31:0] | ||
1707 | * 3. CP_SYNC [31] | SRC_SEL [30:29] | ENGINE [27] | DST_SEL [21:20] | | ||
1708 | * SRC_ADDR_HI [7:0] | ||
1709 | * 4. DST_ADDR_LO [31:0] | ||
1710 | * 5. DST_ADDR_HI [7:0] | ||
1711 | * 6. COMMAND [30:21] | BYTE_COUNT [20:0] | ||
1712 | */ | ||
1713 | # define PACKET3_CP_DMA_DST_SEL(x) ((x) << 20) | ||
1714 | /* 0 - DST_ADDR | ||
1715 | * 1 - GDS | ||
1716 | */ | ||
1717 | # define PACKET3_CP_DMA_ENGINE(x) ((x) << 27) | ||
1718 | /* 0 - ME | ||
1719 | * 1 - PFP | ||
1720 | */ | ||
1721 | # define PACKET3_CP_DMA_SRC_SEL(x) ((x) << 29) | ||
1722 | /* 0 - SRC_ADDR | ||
1723 | * 1 - GDS | ||
1724 | * 2 - DATA | ||
1725 | */ | ||
1726 | # define PACKET3_CP_DMA_CP_SYNC (1 << 31) | ||
1727 | /* COMMAND */ | ||
1728 | # define PACKET3_CP_DMA_DIS_WC (1 << 21) | ||
1729 | # define PACKET3_CP_DMA_CMD_SRC_SWAP(x) ((x) << 22) | ||
1730 | /* 0 - none | ||
1731 | * 1 - 8 in 16 | ||
1732 | * 2 - 8 in 32 | ||
1733 | * 3 - 8 in 64 | ||
1734 | */ | ||
1735 | # define PACKET3_CP_DMA_CMD_DST_SWAP(x) ((x) << 24) | ||
1736 | /* 0 - none | ||
1737 | * 1 - 8 in 16 | ||
1738 | * 2 - 8 in 32 | ||
1739 | * 3 - 8 in 64 | ||
1740 | */ | ||
1741 | # define PACKET3_CP_DMA_CMD_SAS (1 << 26) | ||
1742 | /* 0 - memory | ||
1743 | * 1 - register | ||
1744 | */ | ||
1745 | # define PACKET3_CP_DMA_CMD_DAS (1 << 27) | ||
1746 | /* 0 - memory | ||
1747 | * 1 - register | ||
1748 | */ | ||
1749 | # define PACKET3_CP_DMA_CMD_SAIC (1 << 28) | ||
1750 | # define PACKET3_CP_DMA_CMD_DAIC (1 << 29) | ||
1751 | # define PACKET3_CP_DMA_CMD_RAW_WAIT (1 << 30) | ||
1752 | #define PACKET3_PFP_SYNC_ME 0x42 | ||
1753 | #define PACKET3_SURFACE_SYNC 0x43 | ||
1754 | # define PACKET3_DEST_BASE_0_ENA (1 << 0) | ||
1755 | # define PACKET3_DEST_BASE_1_ENA (1 << 1) | ||
1756 | # define PACKET3_CB0_DEST_BASE_ENA (1 << 6) | ||
1757 | # define PACKET3_CB1_DEST_BASE_ENA (1 << 7) | ||
1758 | # define PACKET3_CB2_DEST_BASE_ENA (1 << 8) | ||
1759 | # define PACKET3_CB3_DEST_BASE_ENA (1 << 9) | ||
1760 | # define PACKET3_CB4_DEST_BASE_ENA (1 << 10) | ||
1761 | # define PACKET3_CB5_DEST_BASE_ENA (1 << 11) | ||
1762 | # define PACKET3_CB6_DEST_BASE_ENA (1 << 12) | ||
1763 | # define PACKET3_CB7_DEST_BASE_ENA (1 << 13) | ||
1764 | # define PACKET3_DB_DEST_BASE_ENA (1 << 14) | ||
1765 | # define PACKET3_DEST_BASE_2_ENA (1 << 19) | ||
1766 | # define PACKET3_DEST_BASE_3_ENA (1 << 21) | ||
1767 | # define PACKET3_TCL1_ACTION_ENA (1 << 22) | ||
1768 | # define PACKET3_TC_ACTION_ENA (1 << 23) | ||
1769 | # define PACKET3_CB_ACTION_ENA (1 << 25) | ||
1770 | # define PACKET3_DB_ACTION_ENA (1 << 26) | ||
1771 | # define PACKET3_SH_KCACHE_ACTION_ENA (1 << 27) | ||
1772 | # define PACKET3_SH_ICACHE_ACTION_ENA (1 << 29) | ||
1773 | #define PACKET3_ME_INITIALIZE 0x44 | ||
1774 | #define PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16) | ||
1775 | #define PACKET3_COND_WRITE 0x45 | ||
1776 | #define PACKET3_EVENT_WRITE 0x46 | ||
1777 | #define EVENT_TYPE(x) ((x) << 0) | ||
1778 | #define EVENT_INDEX(x) ((x) << 8) | ||
1779 | /* 0 - any non-TS event | ||
1780 | * 1 - ZPASS_DONE | ||
1781 | * 2 - SAMPLE_PIPELINESTAT | ||
1782 | * 3 - SAMPLE_STREAMOUTSTAT* | ||
1783 | * 4 - *S_PARTIAL_FLUSH | ||
1784 | * 5 - EOP events | ||
1785 | * 6 - EOS events | ||
1786 | * 7 - CACHE_FLUSH, CACHE_FLUSH_AND_INV_EVENT | ||
1787 | */ | ||
1788 | #define INV_L2 (1 << 20) | ||
1789 | /* INV TC L2 cache when EVENT_INDEX = 7 */ | ||
1790 | #define PACKET3_EVENT_WRITE_EOP 0x47 | ||
1791 | #define DATA_SEL(x) ((x) << 29) | ||
1792 | /* 0 - discard | ||
1793 | * 1 - send low 32bit data | ||
1794 | * 2 - send 64bit data | ||
1795 | * 3 - send 64bit counter value | ||
1796 | */ | ||
1797 | #define INT_SEL(x) ((x) << 24) | ||
1798 | /* 0 - none | ||
1799 | * 1 - interrupt only (DATA_SEL = 0) | ||
1800 | * 2 - interrupt when data write is confirmed | ||
1801 | */ | ||
1802 | #define PACKET3_EVENT_WRITE_EOS 0x48 | ||
1803 | #define PACKET3_PREAMBLE_CNTL 0x4A | ||
1804 | # define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE (2 << 28) | ||
1805 | # define PACKET3_PREAMBLE_END_CLEAR_STATE (3 << 28) | ||
1806 | #define PACKET3_ONE_REG_WRITE 0x57 | ||
1807 | #define PACKET3_LOAD_CONFIG_REG 0x5F | ||
1808 | #define PACKET3_LOAD_CONTEXT_REG 0x60 | ||
1809 | #define PACKET3_LOAD_SH_REG 0x61 | ||
1810 | #define PACKET3_SET_CONFIG_REG 0x68 | ||
1811 | #define PACKET3_SET_CONFIG_REG_START 0x00002000 | ||
1812 | #define PACKET3_SET_CONFIG_REG_END 0x00002c00 | ||
1813 | #define PACKET3_SET_CONTEXT_REG 0x69 | ||
1814 | #define PACKET3_SET_CONTEXT_REG_START 0x000a000 | ||
1815 | #define PACKET3_SET_CONTEXT_REG_END 0x000a400 | ||
1816 | #define PACKET3_SET_CONTEXT_REG_INDIRECT 0x73 | ||
1817 | #define PACKET3_SET_RESOURCE_INDIRECT 0x74 | ||
1818 | #define PACKET3_SET_SH_REG 0x76 | ||
1819 | #define PACKET3_SET_SH_REG_START 0x00002c00 | ||
1820 | #define PACKET3_SET_SH_REG_END 0x00003000 | ||
1821 | #define PACKET3_SET_SH_REG_OFFSET 0x77 | ||
1822 | #define PACKET3_ME_WRITE 0x7A | ||
1823 | #define PACKET3_SCRATCH_RAM_WRITE 0x7D | ||
1824 | #define PACKET3_SCRATCH_RAM_READ 0x7E | ||
1825 | #define PACKET3_CE_WRITE 0x7F | ||
1826 | #define PACKET3_LOAD_CONST_RAM 0x80 | ||
1827 | #define PACKET3_WRITE_CONST_RAM 0x81 | ||
1828 | #define PACKET3_WRITE_CONST_RAM_OFFSET 0x82 | ||
1829 | #define PACKET3_DUMP_CONST_RAM 0x83 | ||
1830 | #define PACKET3_INCREMENT_CE_COUNTER 0x84 | ||
1831 | #define PACKET3_INCREMENT_DE_COUNTER 0x85 | ||
1832 | #define PACKET3_WAIT_ON_CE_COUNTER 0x86 | ||
1833 | #define PACKET3_WAIT_ON_DE_COUNTER 0x87 | ||
1834 | #define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88 | ||
1835 | #define PACKET3_SET_CE_DE_COUNTERS 0x89 | ||
1836 | #define PACKET3_WAIT_ON_AVAIL_BUFFER 0x8A | ||
1837 | #define PACKET3_SWITCH_BUFFER 0x8B | ||
1838 | |||
1839 | /* ASYNC DMA - first instance at 0xd000, second at 0xd800 */ | ||
1840 | #define DMA0_REGISTER_OFFSET 0x0 /* not a register */ | ||
1841 | #define DMA1_REGISTER_OFFSET 0x200 /* not a register */ | ||
1842 | |||
1843 | #define DMA_RB_CNTL 0x3400 | ||
1844 | # define DMA_RB_ENABLE (1 << 0) | ||
1845 | # define DMA_RB_SIZE(x) ((x) << 1) /* log2 */ | ||
1846 | # define DMA_RB_SWAP_ENABLE (1 << 9) /* 8IN32 */ | ||
1847 | # define DMA_RPTR_WRITEBACK_ENABLE (1 << 12) | ||
1848 | # define DMA_RPTR_WRITEBACK_SWAP_ENABLE (1 << 13) /* 8IN32 */ | ||
1849 | # define DMA_RPTR_WRITEBACK_TIMER(x) ((x) << 16) /* log2 */ | ||
1850 | #define DMA_RB_BASE 0x3401 | ||
1851 | #define DMA_RB_RPTR 0x3402 | ||
1852 | #define DMA_RB_WPTR 0x3403 | ||
1853 | |||
1854 | #define DMA_RB_RPTR_ADDR_HI 0x3407 | ||
1855 | #define DMA_RB_RPTR_ADDR_LO 0x3408 | ||
1856 | |||
1857 | #define DMA_IB_CNTL 0x3409 | ||
1858 | # define DMA_IB_ENABLE (1 << 0) | ||
1859 | # define DMA_IB_SWAP_ENABLE (1 << 4) | ||
1860 | # define CMD_VMID_FORCE (1 << 31) | ||
1861 | #define DMA_IB_RPTR 0x340a | ||
1862 | #define DMA_CNTL 0x340b | ||
1863 | # define TRAP_ENABLE (1 << 0) | ||
1864 | # define SEM_INCOMPLETE_INT_ENABLE (1 << 1) | ||
1865 | # define SEM_WAIT_INT_ENABLE (1 << 2) | ||
1866 | # define DATA_SWAP_ENABLE (1 << 3) | ||
1867 | # define FENCE_SWAP_ENABLE (1 << 4) | ||
1868 | # define CTXEMPTY_INT_ENABLE (1 << 28) | ||
1869 | #define DMA_STATUS_REG 0x340d | ||
1870 | # define DMA_IDLE (1 << 0) | ||
1871 | #define DMA_TILING_CONFIG 0x342e | ||
1872 | |||
1873 | #define DMA_POWER_CNTL 0x342f | ||
1874 | # define MEM_POWER_OVERRIDE (1 << 8) | ||
1875 | #define DMA_CLK_CTRL 0x3430 | ||
1876 | |||
1877 | #define DMA_PG 0x3435 | ||
1878 | # define PG_CNTL_ENABLE (1 << 0) | ||
1879 | #define DMA_PGFSM_CONFIG 0x3436 | ||
1880 | #define DMA_PGFSM_WRITE 0x3437 | ||
1881 | |||
1882 | #define DMA_PACKET(cmd, b, t, s, n) ((((cmd) & 0xF) << 28) | \ | ||
1883 | (((b) & 0x1) << 26) | \ | ||
1884 | (((t) & 0x1) << 23) | \ | ||
1885 | (((s) & 0x1) << 22) | \ | ||
1886 | (((n) & 0xFFFFF) << 0)) | ||
1887 | |||
1888 | #define DMA_IB_PACKET(cmd, vmid, n) ((((cmd) & 0xF) << 28) | \ | ||
1889 | (((vmid) & 0xF) << 20) | \ | ||
1890 | (((n) & 0xFFFFF) << 0)) | ||
1891 | |||
1892 | #define DMA_PTE_PDE_PACKET(n) ((2 << 28) | \ | ||
1893 | (1 << 26) | \ | ||
1894 | (1 << 21) | \ | ||
1895 | (((n) & 0xFFFFF) << 0)) | ||
1896 | |||
1897 | /* async DMA Packet types */ | ||
1898 | #define DMA_PACKET_WRITE 0x2 | ||
1899 | #define DMA_PACKET_COPY 0x3 | ||
1900 | #define DMA_PACKET_INDIRECT_BUFFER 0x4 | ||
1901 | #define DMA_PACKET_SEMAPHORE 0x5 | ||
1902 | #define DMA_PACKET_FENCE 0x6 | ||
1903 | #define DMA_PACKET_TRAP 0x7 | ||
1904 | #define DMA_PACKET_SRBM_WRITE 0x9 | ||
1905 | #define DMA_PACKET_CONSTANT_FILL 0xd | ||
1906 | #define DMA_PACKET_POLL_REG_MEM 0xe | ||
1907 | #define DMA_PACKET_NOP 0xf | ||
1908 | |||
1909 | #define VCE_STATUS 0x20004 | ||
1910 | #define VCE_VCPU_CNTL 0x20014 | ||
1911 | #define VCE_CLK_EN (1 << 0) | ||
1912 | #define VCE_VCPU_CACHE_OFFSET0 0x20024 | ||
1913 | #define VCE_VCPU_CACHE_SIZE0 0x20028 | ||
1914 | #define VCE_VCPU_CACHE_OFFSET1 0x2002c | ||
1915 | #define VCE_VCPU_CACHE_SIZE1 0x20030 | ||
1916 | #define VCE_VCPU_CACHE_OFFSET2 0x20034 | ||
1917 | #define VCE_VCPU_CACHE_SIZE2 0x20038 | ||
1918 | #define VCE_SOFT_RESET 0x20120 | ||
1919 | #define VCE_ECPU_SOFT_RESET (1 << 0) | ||
1920 | #define VCE_FME_SOFT_RESET (1 << 2) | ||
1921 | #define VCE_RB_BASE_LO2 0x2016c | ||
1922 | #define VCE_RB_BASE_HI2 0x20170 | ||
1923 | #define VCE_RB_SIZE2 0x20174 | ||
1924 | #define VCE_RB_RPTR2 0x20178 | ||
1925 | #define VCE_RB_WPTR2 0x2017c | ||
1926 | #define VCE_RB_BASE_LO 0x20180 | ||
1927 | #define VCE_RB_BASE_HI 0x20184 | ||
1928 | #define VCE_RB_SIZE 0x20188 | ||
1929 | #define VCE_RB_RPTR 0x2018c | ||
1930 | #define VCE_RB_WPTR 0x20190 | ||
1931 | #define VCE_CLOCK_GATING_A 0x202f8 | ||
1932 | #define VCE_CLOCK_GATING_B 0x202fc | ||
1933 | #define VCE_UENC_CLOCK_GATING 0x205bc | ||
1934 | #define VCE_UENC_REG_CLOCK_GATING 0x205c0 | ||
1935 | #define VCE_FW_REG_STATUS 0x20e10 | ||
1936 | # define VCE_FW_REG_STATUS_BUSY (1 << 0) | ||
1937 | # define VCE_FW_REG_STATUS_PASS (1 << 3) | ||
1938 | # define VCE_FW_REG_STATUS_DONE (1 << 11) | ||
1939 | #define VCE_LMI_FW_START_KEYSEL 0x20e18 | ||
1940 | #define VCE_LMI_FW_PERIODIC_CTRL 0x20e20 | ||
1941 | #define VCE_LMI_CTRL2 0x20e74 | ||
1942 | #define VCE_LMI_CTRL 0x20e98 | ||
1943 | #define VCE_LMI_VM_CTRL 0x20ea0 | ||
1944 | #define VCE_LMI_SWAP_CNTL 0x20eb4 | ||
1945 | #define VCE_LMI_SWAP_CNTL1 0x20eb8 | ||
1946 | #define VCE_LMI_CACHE_CTRL 0x20ef4 | ||
1947 | |||
1948 | #define VCE_CMD_NO_OP 0x00000000 | ||
1949 | #define VCE_CMD_END 0x00000001 | ||
1950 | #define VCE_CMD_IB 0x00000002 | ||
1951 | #define VCE_CMD_FENCE 0x00000003 | ||
1952 | #define VCE_CMD_TRAP 0x00000004 | ||
1953 | #define VCE_CMD_IB_AUTO 0x00000005 | ||
1954 | #define VCE_CMD_SEMAPHORE 0x00000006 | ||
1955 | |||
1956 | |||
1957 | //#dce stupp | ||
1958 | /* display controller offsets used for crtc/cur/lut/grph/viewport/etc. */ | ||
1959 | #define SI_CRTC0_REGISTER_OFFSET 0 //(0x6df0 - 0x6df0)/4 | ||
1960 | #define SI_CRTC1_REGISTER_OFFSET 0x300 //(0x79f0 - 0x6df0)/4 | ||
1961 | #define SI_CRTC2_REGISTER_OFFSET 0x2600 //(0x105f0 - 0x6df0)/4 | ||
1962 | #define SI_CRTC3_REGISTER_OFFSET 0x2900 //(0x111f0 - 0x6df0)/4 | ||
1963 | #define SI_CRTC4_REGISTER_OFFSET 0x2c00 //(0x11df0 - 0x6df0)/4 | ||
1964 | #define SI_CRTC5_REGISTER_OFFSET 0x2f00 //(0x129f0 - 0x6df0)/4 | ||
1965 | |||
1966 | #define CURSOR_WIDTH 64 | ||
1967 | #define CURSOR_HEIGHT 64 | ||
1968 | #define AMDGPU_MM_INDEX 0x0000 | ||
1969 | #define AMDGPU_MM_DATA 0x0001 | ||
1970 | |||
1971 | #define VERDE_NUM_CRTC 6 | ||
1972 | #define BLACKOUT_MODE_MASK 0x00000007 | ||
1973 | #define VGA_RENDER_CONTROL 0xC0 | ||
1974 | #define R_000300_VGA_RENDER_CONTROL 0xC0 | ||
1975 | #define C_000300_VGA_VSTATUS_CNTL 0xFFFCFFFF | ||
1976 | #define EVERGREEN_CRTC_STATUS 0x1BA3 | ||
1977 | #define EVERGREEN_CRTC_V_BLANK (1 << 0) | ||
1978 | #define EVERGREEN_CRTC_STATUS_POSITION 0x1BA4 | ||
1979 | /* CRTC blocks at 0x6df0, 0x79f0, 0x105f0, 0x111f0, 0x11df0, 0x129f0 */ | ||
1980 | #define EVERGREEN_CRTC_V_BLANK_START_END 0x1b8d | ||
1981 | #define EVERGREEN_CRTC_CONTROL 0x1b9c | ||
1982 | #define EVERGREEN_CRTC_MASTER_EN (1 << 0) | ||
1983 | #define EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE (1 << 24) | ||
1984 | #define EVERGREEN_CRTC_BLANK_CONTROL 0x1b9d | ||
1985 | #define EVERGREEN_CRTC_BLANK_DATA_EN (1 << 8) | ||
1986 | #define EVERGREEN_CRTC_V_BLANK (1 << 0) | ||
1987 | #define EVERGREEN_CRTC_STATUS_HV_COUNT 0x1ba8 | ||
1988 | #define EVERGREEN_CRTC_UPDATE_LOCK 0x1bb5 | ||
1989 | #define EVERGREEN_MASTER_UPDATE_LOCK 0x1bbd | ||
1990 | #define EVERGREEN_MASTER_UPDATE_MODE 0x1bbe | ||
1991 | #define EVERGREEN_GRPH_UPDATE_LOCK (1 << 16) | ||
1992 | #define EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x1a07 | ||
1993 | #define EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH 0x1a08 | ||
1994 | #define EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS 0x1a04 | ||
1995 | #define EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS 0x1a05 | ||
1996 | #define EVERGREEN_GRPH_UPDATE 0x1a11 | ||
1997 | #define EVERGREEN_VGA_MEMORY_BASE_ADDRESS 0xc4 | ||
1998 | #define EVERGREEN_VGA_MEMORY_BASE_ADDRESS_HIGH 0xc9 | ||
1999 | #define EVERGREEN_GRPH_SURFACE_UPDATE_PENDING (1 << 2) | ||
2000 | |||
2001 | #define EVERGREEN_DATA_FORMAT 0x1ac0 | ||
2002 | # define EVERGREEN_INTERLEAVE_EN (1 << 0) | ||
2003 | |||
2004 | #define MC_SHARED_CHMAP__NOOFCHAN_MASK 0xf000 | ||
2005 | #define MC_SHARED_CHMAP__NOOFCHAN__SHIFT 0xc | ||
2006 | |||
2007 | #define R600_D1GRPH_ARRAY_MODE_LINEAR_GENERAL (0 << 20) | ||
2008 | #define R600_D1GRPH_ARRAY_MODE_LINEAR_ALIGNED (1 << 20) | ||
2009 | #define R600_D1GRPH_ARRAY_MODE_1D_TILED_THIN1 (2 << 20) | ||
2010 | #define R600_D1GRPH_ARRAY_MODE_2D_TILED_THIN1 (4 << 20) | ||
2011 | |||
2012 | #define R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x1a45 | ||
2013 | #define R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x1845 | ||
2014 | |||
2015 | #define R700_D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH 0x1847 | ||
2016 | #define R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH 0x1a47 | ||
2017 | |||
2018 | #define DISP_INTERRUPT_STATUS__LB_D1_VBLANK_INTERRUPT_MASK 0x8 | ||
2019 | #define DISP_INTERRUPT_STATUS_CONTINUE__LB_D2_VBLANK_INTERRUPT_MASK 0x8 | ||
2020 | #define DISP_INTERRUPT_STATUS_CONTINUE2__LB_D3_VBLANK_INTERRUPT_MASK 0x8 | ||
2021 | #define DISP_INTERRUPT_STATUS_CONTINUE3__LB_D4_VBLANK_INTERRUPT_MASK 0x8 | ||
2022 | #define DISP_INTERRUPT_STATUS_CONTINUE4__LB_D5_VBLANK_INTERRUPT_MASK 0x8 | ||
2023 | #define DISP_INTERRUPT_STATUS_CONTINUE5__LB_D6_VBLANK_INTERRUPT_MASK 0x8 | ||
2024 | |||
2025 | #define DISP_INTERRUPT_STATUS__LB_D1_VLINE_INTERRUPT_MASK 0x4 | ||
2026 | #define DISP_INTERRUPT_STATUS_CONTINUE__LB_D2_VLINE_INTERRUPT_MASK 0x4 | ||
2027 | #define DISP_INTERRUPT_STATUS_CONTINUE2__LB_D3_VLINE_INTERRUPT_MASK 0x4 | ||
2028 | #define DISP_INTERRUPT_STATUS_CONTINUE3__LB_D4_VLINE_INTERRUPT_MASK 0x4 | ||
2029 | #define DISP_INTERRUPT_STATUS_CONTINUE4__LB_D5_VLINE_INTERRUPT_MASK 0x4 | ||
2030 | #define DISP_INTERRUPT_STATUS_CONTINUE5__LB_D6_VLINE_INTERRUPT_MASK 0x4 | ||
2031 | |||
2032 | #define DISP_INTERRUPT_STATUS__DC_HPD1_INTERRUPT_MASK 0x20000 | ||
2033 | #define DISP_INTERRUPT_STATUS_CONTINUE__DC_HPD2_INTERRUPT_MASK 0x20000 | ||
2034 | #define DISP_INTERRUPT_STATUS_CONTINUE2__DC_HPD3_INTERRUPT_MASK 0x20000 | ||
2035 | #define DISP_INTERRUPT_STATUS_CONTINUE3__DC_HPD4_INTERRUPT_MASK 0x20000 | ||
2036 | #define DISP_INTERRUPT_STATUS_CONTINUE4__DC_HPD5_INTERRUPT_MASK 0x20000 | ||
2037 | #define DISP_INTERRUPT_STATUS_CONTINUE5__DC_HPD6_INTERRUPT_MASK 0x20000 | ||
2038 | |||
2039 | #define GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_OCCURRED_MASK 0x1 | ||
2040 | #define GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK 0x100 | ||
2041 | |||
2042 | #define DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK 0x1 | ||
2043 | |||
2044 | #define R600_D1GRPH_SWAP_CONTROL 0x1843 | ||
2045 | #define R600_D1GRPH_SWAP_ENDIAN_NONE (0 << 0) | ||
2046 | #define R600_D1GRPH_SWAP_ENDIAN_16BIT (1 << 0) | ||
2047 | #define R600_D1GRPH_SWAP_ENDIAN_32BIT (2 << 0) | ||
2048 | #define R600_D1GRPH_SWAP_ENDIAN_64BIT (3 << 0) | ||
2049 | |||
2050 | #define AVIVO_D1VGA_CONTROL 0x00cc | ||
2051 | # define AVIVO_DVGA_CONTROL_MODE_ENABLE (1 << 0) | ||
2052 | # define AVIVO_DVGA_CONTROL_TIMING_SELECT (1 << 8) | ||
2053 | # define AVIVO_DVGA_CONTROL_SYNC_POLARITY_SELECT (1 << 9) | ||
2054 | # define AVIVO_DVGA_CONTROL_OVERSCAN_TIMING_SELECT (1 << 10) | ||
2055 | # define AVIVO_DVGA_CONTROL_OVERSCAN_COLOR_EN (1 << 16) | ||
2056 | # define AVIVO_DVGA_CONTROL_ROTATE (1 << 24) | ||
2057 | #define AVIVO_D2VGA_CONTROL 0x00ce | ||
2058 | |||
2059 | #define R600_BUS_CNTL 0x1508 | ||
2060 | # define R600_BIOS_ROM_DIS (1 << 1) | ||
2061 | |||
2062 | #define R600_ROM_CNTL 0x580 | ||
2063 | # define R600_SCK_OVERWRITE (1 << 1) | ||
2064 | # define R600_SCK_PRESCALE_CRYSTAL_CLK_SHIFT 28 | ||
2065 | # define R600_SCK_PRESCALE_CRYSTAL_CLK_MASK (0xf << 28) | ||
2066 | |||
2067 | #define GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK 0x1 | ||
2068 | |||
2069 | #define FMT_BIT_DEPTH_CONTROL 0x1bf2 | ||
2070 | #define FMT_TRUNCATE_EN (1 << 0) | ||
2071 | #define FMT_TRUNCATE_DEPTH (1 << 4) | ||
2072 | #define FMT_SPATIAL_DITHER_EN (1 << 8) | ||
2073 | #define FMT_SPATIAL_DITHER_MODE(x) ((x) << 9) | ||
2074 | #define FMT_SPATIAL_DITHER_DEPTH (1 << 12) | ||
2075 | #define FMT_FRAME_RANDOM_ENABLE (1 << 13) | ||
2076 | #define FMT_RGB_RANDOM_ENABLE (1 << 14) | ||
2077 | #define FMT_HIGHPASS_RANDOM_ENABLE (1 << 15) | ||
2078 | #define FMT_TEMPORAL_DITHER_EN (1 << 16) | ||
2079 | #define FMT_TEMPORAL_DITHER_DEPTH (1 << 20) | ||
2080 | #define FMT_TEMPORAL_DITHER_OFFSET(x) ((x) << 21) | ||
2081 | #define FMT_TEMPORAL_LEVEL (1 << 24) | ||
2082 | #define FMT_TEMPORAL_DITHER_RESET (1 << 25) | ||
2083 | #define FMT_25FRC_SEL(x) ((x) << 26) | ||
2084 | #define FMT_50FRC_SEL(x) ((x) << 28) | ||
2085 | #define FMT_75FRC_SEL(x) ((x) << 30) | ||
2086 | |||
2087 | #define EVERGREEN_DC_LUT_CONTROL 0x1a80 | ||
2088 | #define EVERGREEN_DC_LUT_BLACK_OFFSET_BLUE 0x1a81 | ||
2089 | #define EVERGREEN_DC_LUT_BLACK_OFFSET_GREEN 0x1a82 | ||
2090 | #define EVERGREEN_DC_LUT_BLACK_OFFSET_RED 0x1a83 | ||
2091 | #define EVERGREEN_DC_LUT_WHITE_OFFSET_BLUE 0x1a84 | ||
2092 | #define EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN 0x1a85 | ||
2093 | #define EVERGREEN_DC_LUT_WHITE_OFFSET_RED 0x1a86 | ||
2094 | #define EVERGREEN_DC_LUT_30_COLOR 0x1a7c | ||
2095 | #define EVERGREEN_DC_LUT_RW_INDEX 0x1a79 | ||
2096 | #define EVERGREEN_DC_LUT_WRITE_EN_MASK 0x1a7e | ||
2097 | #define EVERGREEN_DC_LUT_RW_MODE 0x1a78 | ||
2098 | |||
2099 | #define EVERGREEN_GRPH_ENABLE 0x1a00 | ||
2100 | #define EVERGREEN_GRPH_CONTROL 0x1a01 | ||
2101 | #define EVERGREEN_GRPH_DEPTH(x) (((x) & 0x3) << 0) | ||
2102 | #define EVERGREEN_GRPH_DEPTH_8BPP 0 | ||
2103 | #define EVERGREEN_GRPH_DEPTH_16BPP 1 | ||
2104 | #define EVERGREEN_GRPH_DEPTH_32BPP 2 | ||
2105 | #define EVERGREEN_GRPH_NUM_BANKS(x) (((x) & 0x3) << 2) | ||
2106 | #define EVERGREEN_ADDR_SURF_2_BANK 0 | ||
2107 | #define EVERGREEN_ADDR_SURF_4_BANK 1 | ||
2108 | #define EVERGREEN_ADDR_SURF_8_BANK 2 | ||
2109 | #define EVERGREEN_ADDR_SURF_16_BANK 3 | ||
2110 | #define EVERGREEN_GRPH_Z(x) (((x) & 0x3) << 4) | ||
2111 | #define EVERGREEN_GRPH_BANK_WIDTH(x) (((x) & 0x3) << 6) | ||
2112 | #define EVERGREEN_ADDR_SURF_BANK_WIDTH_1 0 | ||
2113 | #define EVERGREEN_ADDR_SURF_BANK_WIDTH_2 1 | ||
2114 | #define EVERGREEN_ADDR_SURF_BANK_WIDTH_4 2 | ||
2115 | #define EVERGREEN_ADDR_SURF_BANK_WIDTH_8 3 | ||
2116 | #define EVERGREEN_GRPH_FORMAT(x) (((x) & 0x7) << 8) | ||
2117 | |||
2118 | #define EVERGREEN_GRPH_FORMAT_INDEXED 0 | ||
2119 | #define EVERGREEN_GRPH_FORMAT_ARGB1555 0 | ||
2120 | #define EVERGREEN_GRPH_FORMAT_ARGB565 1 | ||
2121 | #define EVERGREEN_GRPH_FORMAT_ARGB4444 2 | ||
2122 | #define EVERGREEN_GRPH_FORMAT_AI88 3 | ||
2123 | #define EVERGREEN_GRPH_FORMAT_MONO16 4 | ||
2124 | #define EVERGREEN_GRPH_FORMAT_BGRA5551 5 | ||
2125 | |||
2126 | /* 32 BPP */ | ||
2127 | #define EVERGREEN_GRPH_FORMAT_ARGB8888 0 | ||
2128 | #define EVERGREEN_GRPH_FORMAT_ARGB2101010 1 | ||
2129 | #define EVERGREEN_GRPH_FORMAT_32BPP_DIG 2 | ||
2130 | #define EVERGREEN_GRPH_FORMAT_8B_ARGB2101010 3 | ||
2131 | #define EVERGREEN_GRPH_FORMAT_BGRA1010102 4 | ||
2132 | #define EVERGREEN_GRPH_FORMAT_8B_BGRA1010102 5 | ||
2133 | #define EVERGREEN_GRPH_FORMAT_RGB111110 6 | ||
2134 | #define EVERGREEN_GRPH_FORMAT_BGR101111 7 | ||
2135 | #define EVERGREEN_GRPH_BANK_HEIGHT(x) (((x) & 0x3) << 11) | ||
2136 | #define EVERGREEN_ADDR_SURF_BANK_HEIGHT_1 0 | ||
2137 | #define EVERGREEN_ADDR_SURF_BANK_HEIGHT_2 1 | ||
2138 | #define EVERGREEN_ADDR_SURF_BANK_HEIGHT_4 2 | ||
2139 | #define EVERGREEN_ADDR_SURF_BANK_HEIGHT_8 3 | ||
2140 | #define EVERGREEN_GRPH_TILE_SPLIT(x) (((x) & 0x7) << 13) | ||
2141 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_64B 0 | ||
2142 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_128B 1 | ||
2143 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_256B 2 | ||
2144 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_512B 3 | ||
2145 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_1KB 4 | ||
2146 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_2KB 5 | ||
2147 | #define EVERGREEN_ADDR_SURF_TILE_SPLIT_4KB 6 | ||
2148 | #define EVERGREEN_GRPH_MACRO_TILE_ASPECT(x) (((x) & 0x3) << 18) | ||
2149 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_1 0 | ||
2150 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_2 1 | ||
2151 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_4 2 | ||
2152 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_8 3 | ||
2153 | #define EVERGREEN_GRPH_ARRAY_MODE(x) (((x) & 0x7) << 20) | ||
2154 | #define EVERGREEN_GRPH_ARRAY_LINEAR_GENERAL 0 | ||
2155 | #define EVERGREEN_GRPH_ARRAY_LINEAR_ALIGNED 1 | ||
2156 | #define EVERGREEN_GRPH_ARRAY_1D_TILED_THIN1 2 | ||
2157 | #define EVERGREEN_GRPH_ARRAY_2D_TILED_THIN1 4 | ||
2158 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_1 0 | ||
2159 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_2 1 | ||
2160 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_4 2 | ||
2161 | #define EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_8 3 | ||
2162 | |||
2163 | #define EVERGREEN_GRPH_SWAP_CONTROL 0x1a03 | ||
2164 | #define EVERGREEN_GRPH_ENDIAN_SWAP(x) (((x) & 0x3) << 0) | ||
2165 | # define EVERGREEN_GRPH_ENDIAN_NONE 0 | ||
2166 | # define EVERGREEN_GRPH_ENDIAN_8IN16 1 | ||
2167 | # define EVERGREEN_GRPH_ENDIAN_8IN32 2 | ||
2168 | # define EVERGREEN_GRPH_ENDIAN_8IN64 3 | ||
2169 | |||
2170 | #define EVERGREEN_D3VGA_CONTROL 0xf8 | ||
2171 | #define EVERGREEN_D4VGA_CONTROL 0xf9 | ||
2172 | #define EVERGREEN_D5VGA_CONTROL 0xfa | ||
2173 | #define EVERGREEN_D6VGA_CONTROL 0xfb | ||
2174 | |||
2175 | #define EVERGREEN_GRPH_SURFACE_ADDRESS_MASK 0xffffff00 | ||
2176 | |||
2177 | #define EVERGREEN_GRPH_LUT_10BIT_BYPASS_CONTROL 0x1a02 | ||
2178 | #define EVERGREEN_LUT_10BIT_BYPASS_EN (1 << 8) | ||
2179 | |||
2180 | #define EVERGREEN_GRPH_PITCH 0x1a06 | ||
2181 | #define EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x1a07 | ||
2182 | #define EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH 0x1a08 | ||
2183 | #define EVERGREEN_GRPH_SURFACE_OFFSET_X 0x1a09 | ||
2184 | #define EVERGREEN_GRPH_SURFACE_OFFSET_Y 0x1a0a | ||
2185 | #define EVERGREEN_GRPH_X_START 0x1a0b | ||
2186 | #define EVERGREEN_GRPH_Y_START 0x1a0c | ||
2187 | #define EVERGREEN_GRPH_X_END 0x1a0d | ||
2188 | #define EVERGREEN_GRPH_Y_END 0x1a0e | ||
2189 | #define EVERGREEN_GRPH_UPDATE 0x1a11 | ||
2190 | #define EVERGREEN_GRPH_SURFACE_UPDATE_PENDING (1 << 2) | ||
2191 | #define EVERGREEN_GRPH_UPDATE_LOCK (1 << 16) | ||
2192 | #define EVERGREEN_GRPH_FLIP_CONTROL 0x1a12 | ||
2193 | #define EVERGREEN_GRPH_SURFACE_UPDATE_H_RETRACE_EN (1 << 0) | ||
2194 | |||
2195 | #define EVERGREEN_VIEWPORT_START 0x1b5c | ||
2196 | #define EVERGREEN_VIEWPORT_SIZE 0x1b5d | ||
2197 | #define EVERGREEN_DESKTOP_HEIGHT 0x1ac1 | ||
2198 | |||
2199 | /* CUR blocks at 0x6998, 0x7598, 0x10198, 0x10d98, 0x11998, 0x12598 */ | ||
2200 | #define EVERGREEN_CUR_CONTROL 0x1a66 | ||
2201 | # define EVERGREEN_CURSOR_EN (1 << 0) | ||
2202 | # define EVERGREEN_CURSOR_MODE(x) (((x) & 0x3) << 8) | ||
2203 | # define EVERGREEN_CURSOR_MONO 0 | ||
2204 | # define EVERGREEN_CURSOR_24_1 1 | ||
2205 | # define EVERGREEN_CURSOR_24_8_PRE_MULT 2 | ||
2206 | # define EVERGREEN_CURSOR_24_8_UNPRE_MULT 3 | ||
2207 | # define EVERGREEN_CURSOR_2X_MAGNIFY (1 << 16) | ||
2208 | # define EVERGREEN_CURSOR_FORCE_MC_ON (1 << 20) | ||
2209 | # define EVERGREEN_CURSOR_URGENT_CONTROL(x) (((x) & 0x7) << 24) | ||
2210 | # define EVERGREEN_CURSOR_URGENT_ALWAYS 0 | ||
2211 | # define EVERGREEN_CURSOR_URGENT_1_8 1 | ||
2212 | # define EVERGREEN_CURSOR_URGENT_1_4 2 | ||
2213 | # define EVERGREEN_CURSOR_URGENT_3_8 3 | ||
2214 | # define EVERGREEN_CURSOR_URGENT_1_2 4 | ||
2215 | #define EVERGREEN_CUR_SURFACE_ADDRESS 0x1a67 | ||
2216 | # define EVERGREEN_CUR_SURFACE_ADDRESS_MASK 0xfffff000 | ||
2217 | #define EVERGREEN_CUR_SIZE 0x1a68 | ||
2218 | #define EVERGREEN_CUR_SURFACE_ADDRESS_HIGH 0x1a69 | ||
2219 | #define EVERGREEN_CUR_POSITION 0x1a6a | ||
2220 | #define EVERGREEN_CUR_HOT_SPOT 0x1a6b | ||
2221 | #define EVERGREEN_CUR_COLOR1 0x1a6c | ||
2222 | #define EVERGREEN_CUR_COLOR2 0x1a6d | ||
2223 | #define EVERGREEN_CUR_UPDATE 0x1a6e | ||
2224 | # define EVERGREEN_CURSOR_UPDATE_PENDING (1 << 0) | ||
2225 | # define EVERGREEN_CURSOR_UPDATE_TAKEN (1 << 1) | ||
2226 | # define EVERGREEN_CURSOR_UPDATE_LOCK (1 << 16) | ||
2227 | # define EVERGREEN_CURSOR_DISABLE_MULTIPLE_UPDATE (1 << 24) | ||
2228 | |||
2229 | |||
2230 | #define NI_INPUT_CSC_CONTROL 0x1a35 | ||
2231 | # define NI_INPUT_CSC_GRPH_MODE(x) (((x) & 0x3) << 0) | ||
2232 | # define NI_INPUT_CSC_BYPASS 0 | ||
2233 | # define NI_INPUT_CSC_PROG_COEFF 1 | ||
2234 | # define NI_INPUT_CSC_PROG_SHARED_MATRIXA 2 | ||
2235 | # define NI_INPUT_CSC_OVL_MODE(x) (((x) & 0x3) << 4) | ||
2236 | |||
2237 | #define NI_OUTPUT_CSC_CONTROL 0x1a3c | ||
2238 | # define NI_OUTPUT_CSC_GRPH_MODE(x) (((x) & 0x7) << 0) | ||
2239 | # define NI_OUTPUT_CSC_BYPASS 0 | ||
2240 | # define NI_OUTPUT_CSC_TV_RGB 1 | ||
2241 | # define NI_OUTPUT_CSC_YCBCR_601 2 | ||
2242 | # define NI_OUTPUT_CSC_YCBCR_709 3 | ||
2243 | # define NI_OUTPUT_CSC_PROG_COEFF 4 | ||
2244 | # define NI_OUTPUT_CSC_PROG_SHARED_MATRIXB 5 | ||
2245 | # define NI_OUTPUT_CSC_OVL_MODE(x) (((x) & 0x7) << 4) | ||
2246 | |||
2247 | #define NI_DEGAMMA_CONTROL 0x1a58 | ||
2248 | # define NI_GRPH_DEGAMMA_MODE(x) (((x) & 0x3) << 0) | ||
2249 | # define NI_DEGAMMA_BYPASS 0 | ||
2250 | # define NI_DEGAMMA_SRGB_24 1 | ||
2251 | # define NI_DEGAMMA_XVYCC_222 2 | ||
2252 | # define NI_OVL_DEGAMMA_MODE(x) (((x) & 0x3) << 4) | ||
2253 | # define NI_ICON_DEGAMMA_MODE(x) (((x) & 0x3) << 8) | ||
2254 | # define NI_CURSOR_DEGAMMA_MODE(x) (((x) & 0x3) << 12) | ||
2255 | |||
2256 | #define NI_GAMUT_REMAP_CONTROL 0x1a59 | ||
2257 | # define NI_GRPH_GAMUT_REMAP_MODE(x) (((x) & 0x3) << 0) | ||
2258 | # define NI_GAMUT_REMAP_BYPASS 0 | ||
2259 | # define NI_GAMUT_REMAP_PROG_COEFF 1 | ||
2260 | # define NI_GAMUT_REMAP_PROG_SHARED_MATRIXA 2 | ||
2261 | # define NI_GAMUT_REMAP_PROG_SHARED_MATRIXB 3 | ||
2262 | # define NI_OVL_GAMUT_REMAP_MODE(x) (((x) & 0x3) << 4) | ||
2263 | |||
2264 | #define NI_REGAMMA_CONTROL 0x1aa0 | ||
2265 | # define NI_GRPH_REGAMMA_MODE(x) (((x) & 0x7) << 0) | ||
2266 | # define NI_REGAMMA_BYPASS 0 | ||
2267 | # define NI_REGAMMA_SRGB_24 1 | ||
2268 | # define NI_REGAMMA_XVYCC_222 2 | ||
2269 | # define NI_REGAMMA_PROG_A 3 | ||
2270 | # define NI_REGAMMA_PROG_B 4 | ||
2271 | # define NI_OVL_REGAMMA_MODE(x) (((x) & 0x7) << 4) | ||
2272 | |||
2273 | |||
2274 | #define NI_PRESCALE_GRPH_CONTROL 0x1a2d | ||
2275 | # define NI_GRPH_PRESCALE_BYPASS (1 << 4) | ||
2276 | |||
2277 | #define NI_PRESCALE_OVL_CONTROL 0x1a31 | ||
2278 | # define NI_OVL_PRESCALE_BYPASS (1 << 4) | ||
2279 | |||
2280 | #define NI_INPUT_GAMMA_CONTROL 0x1a10 | ||
2281 | # define NI_GRPH_INPUT_GAMMA_MODE(x) (((x) & 0x3) << 0) | ||
2282 | # define NI_INPUT_GAMMA_USE_LUT 0 | ||
2283 | # define NI_INPUT_GAMMA_BYPASS 1 | ||
2284 | # define NI_INPUT_GAMMA_SRGB_24 2 | ||
2285 | # define NI_INPUT_GAMMA_XVYCC_222 3 | ||
2286 | # define NI_OVL_INPUT_GAMMA_MODE(x) (((x) & 0x3) << 4) | ||
2287 | |||
2288 | #define IH_RB_WPTR__RB_OVERFLOW_MASK 0x1 | ||
2289 | #define IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK 0x80000000 | ||
2290 | #define SRBM_STATUS__IH_BUSY_MASK 0x20000 | ||
2291 | #define SRBM_SOFT_RESET__SOFT_RESET_IH_MASK 0x400 | ||
2292 | |||
2293 | #define BLACKOUT_MODE_MASK 0x00000007 | ||
2294 | #define VGA_RENDER_CONTROL 0xC0 | ||
2295 | #define R_000300_VGA_RENDER_CONTROL 0xC0 | ||
2296 | #define C_000300_VGA_VSTATUS_CNTL 0xFFFCFFFF | ||
2297 | #define EVERGREEN_CRTC_STATUS 0x1BA3 | ||
2298 | #define EVERGREEN_CRTC_V_BLANK (1 << 0) | ||
2299 | #define EVERGREEN_CRTC_STATUS_POSITION 0x1BA4 | ||
2300 | /* CRTC blocks at 0x6df0, 0x79f0, 0x105f0, 0x111f0, 0x11df0, 0x129f0 */ | ||
2301 | #define EVERGREEN_CRTC_V_BLANK_START_END 0x1b8d | ||
2302 | #define EVERGREEN_CRTC_CONTROL 0x1b9c | ||
2303 | # define EVERGREEN_CRTC_MASTER_EN (1 << 0) | ||
2304 | # define EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE (1 << 24) | ||
2305 | #define EVERGREEN_CRTC_BLANK_CONTROL 0x1b9d | ||
2306 | # define EVERGREEN_CRTC_BLANK_DATA_EN (1 << 8) | ||
2307 | # define EVERGREEN_CRTC_V_BLANK (1 << 0) | ||
2308 | #define EVERGREEN_CRTC_STATUS_HV_COUNT 0x1ba8 | ||
2309 | #define EVERGREEN_CRTC_UPDATE_LOCK 0x1bb5 | ||
2310 | #define EVERGREEN_MASTER_UPDATE_LOCK 0x1bbd | ||
2311 | #define EVERGREEN_MASTER_UPDATE_MODE 0x1bbe | ||
2312 | #define EVERGREEN_GRPH_UPDATE_LOCK (1 << 16) | ||
2313 | #define EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x1a07 | ||
2314 | #define EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH 0x1a08 | ||
2315 | #define EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS 0x1a04 | ||
2316 | #define EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS 0x1a05 | ||
2317 | #define EVERGREEN_GRPH_UPDATE 0x1a11 | ||
2318 | #define EVERGREEN_VGA_MEMORY_BASE_ADDRESS 0xc4 | ||
2319 | #define EVERGREEN_VGA_MEMORY_BASE_ADDRESS_HIGH 0xc9 | ||
2320 | #define EVERGREEN_GRPH_SURFACE_UPDATE_PENDING (1 << 2) | ||
2321 | |||
2322 | #define mmVM_CONTEXT1_CNTL__xxRANGE_PROTECTION_FAULT_ENABLE_DEFAULT_MASK 0x10 | ||
2323 | #define mmVM_CONTEXT1_CNTL__xxRANGE_PROTECTION_FAULT_ENABLE_DEFAULT__SHIFT 0x4 | ||
2324 | #define mmVM_CONTEXT1_CNTL__xxDUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT_MASK 0x80 | ||
2325 | #define mmVM_CONTEXT1_CNTL__xxDUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT__SHIFT 0x7 | ||
2326 | #define mmVM_CONTEXT1_CNTL__xxPDE0_PROTECTION_FAULT_ENABLE_DEFAULT_MASK 0x400 | ||
2327 | #define mmVM_CONTEXT1_CNTL__xxPDE0_PROTECTION_FAULT_ENABLE_DEFAULT__SHIFT 0xa | ||
2328 | #define mmVM_CONTEXT1_CNTL__xxVALID_PROTECTION_FAULT_ENABLE_DEFAULT_MASK 0x2000 | ||
2329 | #define mmVM_CONTEXT1_CNTL__xxVALID_PROTECTION_FAULT_ENABLE_DEFAULT__SHIFT 0xd | ||
2330 | #define mmVM_CONTEXT1_CNTL__xxREAD_PROTECTION_FAULT_ENABLE_DEFAULT_MASK 0x10000 | ||
2331 | #define mmVM_CONTEXT1_CNTL__xxREAD_PROTECTION_FAULT_ENABLE_DEFAULT__SHIFT 0x10 | ||
2332 | #define mmVM_CONTEXT1_CNTL__xxWRITE_PROTECTION_FAULT_ENABLE_DEFAULT_MASK 0x80000 | ||
2333 | #define mmVM_CONTEXT1_CNTL__xxWRITE_PROTECTION_FAULT_ENABLE_DEFAULT__SHIFT 0x13 | ||
2334 | |||
2335 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxVMID_MASK 0x1e000000 | ||
2336 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxVMID__SHIFT 0x19 | ||
2337 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxPROTECTIONS_MASK 0xff | ||
2338 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxPROTECTIONS__SHIFT 0x0 | ||
2339 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxMEMORY_CLIENT_ID_MASK 0xff000 | ||
2340 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxMEMORY_CLIENT_ID__SHIFT 0xc | ||
2341 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxMEMORY_CLIENT_RW_MASK 0x1000000 | ||
2342 | #define mmVM_CONTEXT1_PROTECTION_FAULT_STATUS__xxMEMORY_CLIENT_RW__SHIFT 0x18 | ||
2343 | |||
2344 | #define mmMC_SHARED_BLACKOUT_CNTL__xxBLACKOUT_MODE_MASK 0x7 | ||
2345 | #define mmMC_SHARED_BLACKOUT_CNTL__xxBLACKOUT_MODE__SHIFT 0x0 | ||
2346 | |||
2347 | #define mmBIF_FB_EN__xxFB_READ_EN_MASK 0x1 | ||
2348 | #define mmBIF_FB_EN__xxFB_READ_EN__SHIFT 0x0 | ||
2349 | #define mmBIF_FB_EN__xxFB_WRITE_EN_MASK 0x2 | ||
2350 | #define mmBIF_FB_EN__xxFB_WRITE_EN__SHIFT 0x1 | ||
2351 | |||
2352 | #define mmSRBM_SOFT_RESET__xxSOFT_RESET_VMC_MASK 0x20000 | ||
2353 | #define mmSRBM_SOFT_RESET__xxSOFT_RESET_VMC__SHIFT 0x11 | ||
2354 | #define mmSRBM_SOFT_RESET__xxSOFT_RESET_MC_MASK 0x800 | ||
2355 | #define mmSRBM_SOFT_RESET__xxSOFT_RESET_MC__SHIFT 0xb | ||
2356 | |||
2357 | #define VM_CONTEXT1_CNTL__RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK 0x8 | ||
2358 | #define VM_CONTEXT1_CNTL__RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT__SHIFT 0x3 | ||
2359 | #define VM_CONTEXT1_CNTL__DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK 0x40 | ||
2360 | #define VM_CONTEXT1_CNTL__DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT__SHIFT 0x6 | ||
2361 | #define VM_CONTEXT1_CNTL__PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK 0x200 | ||
2362 | #define VM_CONTEXT1_CNTL__PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT__SHIFT 0x9 | ||
2363 | #define VM_CONTEXT1_CNTL__VALID_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK 0x1000 | ||
2364 | #define VM_CONTEXT1_CNTL__VALID_PROTECTION_FAULT_ENABLE_INTERRUPT__SHIFT 0xc | ||
2365 | #define VM_CONTEXT1_CNTL__READ_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK 0x8000 | ||
2366 | #define VM_CONTEXT1_CNTL__READ_PROTECTION_FAULT_ENABLE_INTERRUPT__SHIFT 0xf | ||
2367 | #define VM_CONTEXT1_CNTL__WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK 0x40000 | ||
2368 | #define VM_CONTEXT1_CNTL__WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT__SHIFT 0x12 | ||
2369 | |||
2370 | #define MC_SEQ_MISC0__MT__MASK 0xf0000000 | ||
2371 | #define MC_SEQ_MISC0__MT__GDDR1 0x10000000 | ||
2372 | #define MC_SEQ_MISC0__MT__DDR2 0x20000000 | ||
2373 | #define MC_SEQ_MISC0__MT__GDDR3 0x30000000 | ||
2374 | #define MC_SEQ_MISC0__MT__GDDR4 0x40000000 | ||
2375 | #define MC_SEQ_MISC0__MT__GDDR5 0x50000000 | ||
2376 | #define MC_SEQ_MISC0__MT__HBM 0x60000000 | ||
2377 | #define MC_SEQ_MISC0__MT__DDR3 0xB0000000 | ||
2378 | |||
2379 | #define SRBM_STATUS__MCB_BUSY_MASK 0x200 | ||
2380 | #define SRBM_STATUS__MCB_BUSY__SHIFT 0x9 | ||
2381 | #define SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK 0x400 | ||
2382 | #define SRBM_STATUS__MCB_NON_DISPLAY_BUSY__SHIFT 0xa | ||
2383 | #define SRBM_STATUS__MCC_BUSY_MASK 0x800 | ||
2384 | #define SRBM_STATUS__MCC_BUSY__SHIFT 0xb | ||
2385 | #define SRBM_STATUS__MCD_BUSY_MASK 0x1000 | ||
2386 | #define SRBM_STATUS__MCD_BUSY__SHIFT 0xc | ||
2387 | #define SRBM_STATUS__VMC_BUSY_MASK 0x100 | ||
2388 | #define SRBM_STATUS__VMC_BUSY__SHIFT 0x8 | ||
2389 | |||
2390 | |||
2391 | #define GRBM_STATUS__GUI_ACTIVE_MASK 0x80000000 | ||
2392 | #define CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK 0x4000000 | ||
2393 | #define CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK 0x800000 | ||
2394 | #define CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK 0x400000 | ||
2395 | #define PACKET3_SEM_WAIT_ON_SIGNAL (0x1 << 12) | ||
2396 | #define PACKET3_SEM_SEL_SIGNAL (0x6 << 29) | ||
2397 | #define PACKET3_SEM_SEL_WAIT (0x7 << 29) | ||
2398 | |||
2399 | #define CONFIG_CNTL 0x1509 | ||
2400 | #define CC_DRM_ID_STRAPS 0X1559 | ||
2401 | #define AMDGPU_PCIE_INDEX 0xc | ||
2402 | #define AMDGPU_PCIE_DATA 0xd | ||
2403 | |||
2404 | #define DMA_SEM_INCOMPLETE_TIMER_CNTL 0x3411 | ||
2405 | #define DMA_SEM_WAIT_FAIL_TIMER_CNTL 0x3412 | ||
2406 | #define DMA_MODE 0x342f | ||
2407 | #define DMA_RB_RPTR_ADDR_HI 0x3407 | ||
2408 | #define DMA_RB_RPTR_ADDR_LO 0x3408 | ||
2409 | #define DMA_BUSY_MASK 0x20 | ||
2410 | #define DMA1_BUSY_MASK 0X40 | ||
2411 | #define SDMA_MAX_INSTANCE 2 | ||
2412 | |||
2413 | #define PCIE_BUS_CLK 10000 | ||
2414 | #define TCLK (PCIE_BUS_CLK / 10) | ||
2415 | #define CC_DRM_ID_STRAPS__ATI_REV_ID_MASK 0xf0000000 | ||
2416 | #define CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT 0x1c | ||
2417 | #define PCIE_PORT_INDEX 0xe | ||
2418 | #define PCIE_PORT_DATA 0xf | ||
2419 | #define EVERGREEN_PIF_PHY0_INDEX 0x8 | ||
2420 | #define EVERGREEN_PIF_PHY0_DATA 0xc | ||
2421 | #define EVERGREEN_PIF_PHY1_INDEX 0x10 | ||
2422 | #define EVERGREEN_PIF_PHY1_DATA 0x14 | ||
2423 | |||
2424 | #define MC_VM_FB_OFFSET 0x81a | ||
2425 | |||
2426 | #endif | ||
diff --git a/drivers/gpu/drm/amd/include/atombios.h b/drivers/gpu/drm/amd/include/atombios.h index 3493da5c8f0e..4a4d3797a6d3 100644 --- a/drivers/gpu/drm/amd/include/atombios.h +++ b/drivers/gpu/drm/amd/include/atombios.h | |||
@@ -494,6 +494,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V3 | |||
494 | union | 494 | union |
495 | { | 495 | { |
496 | ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter | 496 | ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter |
497 | ULONG ulClockParams; //ULONG access for BE | ||
497 | ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter | 498 | ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter |
498 | }; | 499 | }; |
499 | UCHAR ucRefDiv; //Output Parameter | 500 | UCHAR ucRefDiv; //Output Parameter |
@@ -526,6 +527,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V5 | |||
526 | union | 527 | union |
527 | { | 528 | { |
528 | ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter | 529 | ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter |
530 | ULONG ulClockParams; //ULONG access for BE | ||
529 | ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter | 531 | ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter |
530 | }; | 532 | }; |
531 | UCHAR ucRefDiv; //Output Parameter | 533 | UCHAR ucRefDiv; //Output Parameter |
diff --git a/drivers/gpu/drm/amd/include/cgs_common.h b/drivers/gpu/drm/amd/include/cgs_common.h index b86aba9d019f..6aa8938fd826 100644 --- a/drivers/gpu/drm/amd/include/cgs_common.h +++ b/drivers/gpu/drm/amd/include/cgs_common.h | |||
@@ -119,6 +119,8 @@ enum cgs_system_info_id { | |||
119 | CGS_SYSTEM_INFO_PG_FLAGS, | 119 | CGS_SYSTEM_INFO_PG_FLAGS, |
120 | CGS_SYSTEM_INFO_GFX_CU_INFO, | 120 | CGS_SYSTEM_INFO_GFX_CU_INFO, |
121 | CGS_SYSTEM_INFO_GFX_SE_INFO, | 121 | CGS_SYSTEM_INFO_GFX_SE_INFO, |
122 | CGS_SYSTEM_INFO_PCIE_SUB_SYS_ID, | ||
123 | CGS_SYSTEM_INFO_PCIE_SUB_SYS_VENDOR_ID, | ||
122 | CGS_SYSTEM_INFO_ID_MAXIMUM, | 124 | CGS_SYSTEM_INFO_ID_MAXIMUM, |
123 | }; | 125 | }; |
124 | 126 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index 2de34a5a85c2..b1d19409bf86 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c | |||
@@ -538,7 +538,6 @@ int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_event event_id, void *input, | |||
538 | ret = pem_handle_event(pp_handle->eventmgr, event_id, &data); | 538 | ret = pem_handle_event(pp_handle->eventmgr, event_id, &data); |
539 | break; | 539 | break; |
540 | case AMD_PP_EVENT_READJUST_POWER_STATE: | 540 | case AMD_PP_EVENT_READJUST_POWER_STATE: |
541 | pp_handle->hwmgr->current_ps = pp_handle->hwmgr->boot_ps; | ||
542 | ret = pem_handle_event(pp_handle->eventmgr, event_id, &data); | 541 | ret = pem_handle_event(pp_handle->eventmgr, event_id, &data); |
543 | break; | 542 | break; |
544 | default: | 543 | default: |
@@ -765,15 +764,12 @@ static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size) | |||
765 | PP_CHECK_HW(hwmgr); | 764 | PP_CHECK_HW(hwmgr); |
766 | 765 | ||
767 | if (!hwmgr->hardcode_pp_table) { | 766 | if (!hwmgr->hardcode_pp_table) { |
768 | hwmgr->hardcode_pp_table = | 767 | hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table, |
769 | kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL); | 768 | hwmgr->soft_pp_table_size, |
769 | GFP_KERNEL); | ||
770 | 770 | ||
771 | if (!hwmgr->hardcode_pp_table) | 771 | if (!hwmgr->hardcode_pp_table) |
772 | return -ENOMEM; | 772 | return -ENOMEM; |
773 | |||
774 | /* to avoid powerplay crash when hardcode pptable is empty */ | ||
775 | memcpy(hwmgr->hardcode_pp_table, hwmgr->soft_pp_table, | ||
776 | hwmgr->soft_pp_table_size); | ||
777 | } | 773 | } |
778 | 774 | ||
779 | memcpy(hwmgr->hardcode_pp_table, buf, size); | 775 | memcpy(hwmgr->hardcode_pp_table, buf, size); |
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c index a46225c0fc01..1d1875a7cb2d 100644 --- a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c +++ b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c | |||
@@ -70,11 +70,12 @@ int psm_set_states(struct pp_eventmgr *eventmgr, unsigned long *state_id) | |||
70 | int i; | 70 | int i; |
71 | 71 | ||
72 | table_entries = hwmgr->num_ps; | 72 | table_entries = hwmgr->num_ps; |
73 | |||
73 | state = hwmgr->ps; | 74 | state = hwmgr->ps; |
74 | 75 | ||
75 | for (i = 0; i < table_entries; i++) { | 76 | for (i = 0; i < table_entries; i++) { |
76 | if (state->id == *state_id) { | 77 | if (state->id == *state_id) { |
77 | hwmgr->request_ps = state; | 78 | memcpy(hwmgr->request_ps, state, hwmgr->ps_size); |
78 | return 0; | 79 | return 0; |
79 | } | 80 | } |
80 | state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size); | 81 | state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size); |
@@ -106,7 +107,7 @@ int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip) | |||
106 | if (!equal || phm_check_smc_update_required_for_display_configuration(hwmgr)) { | 107 | if (!equal || phm_check_smc_update_required_for_display_configuration(hwmgr)) { |
107 | phm_apply_state_adjust_rules(hwmgr, requested, pcurrent); | 108 | phm_apply_state_adjust_rules(hwmgr, requested, pcurrent); |
108 | phm_set_power_state(hwmgr, &pcurrent->hardware, &requested->hardware); | 109 | phm_set_power_state(hwmgr, &pcurrent->hardware, &requested->hardware); |
109 | hwmgr->current_ps = requested; | 110 | memcpy(hwmgr->current_ps, hwmgr->request_ps, hwmgr->ps_size); |
110 | } | 111 | } |
111 | return 0; | 112 | return 0; |
112 | } | 113 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/Makefile b/drivers/gpu/drm/amd/powerplay/hwmgr/Makefile index abbcbc9f6eca..6e359c90dfda 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/Makefile +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | HARDWARE_MGR = hwmgr.o processpptables.o functiontables.o \ | 5 | HARDWARE_MGR = hwmgr.o processpptables.o functiontables.o \ |
6 | hardwaremanager.o pp_acpi.o cz_hwmgr.o \ | 6 | hardwaremanager.o pp_acpi.o cz_hwmgr.o \ |
7 | cz_clockpowergating.o tonga_powertune.o\ | 7 | cz_clockpowergating.o tonga_powertune.o\ |
8 | tonga_processpptables.o ppatomctrl.o \ | 8 | process_pptables_v1_0.o ppatomctrl.o \ |
9 | tonga_hwmgr.o pppcielanes.o tonga_thermal.o\ | 9 | tonga_hwmgr.o pppcielanes.o tonga_thermal.o\ |
10 | fiji_powertune.o fiji_hwmgr.o tonga_clockpowergating.o \ | 10 | fiji_powertune.o fiji_hwmgr.o tonga_clockpowergating.o \ |
11 | fiji_clockpowergating.o fiji_thermal.o \ | 11 | fiji_clockpowergating.o fiji_thermal.o \ |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c index 9368e21f5695..74300d6ef686 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c | |||
@@ -44,8 +44,8 @@ | |||
44 | #include "dce/dce_10_0_sh_mask.h" | 44 | #include "dce/dce_10_0_sh_mask.h" |
45 | #include "pppcielanes.h" | 45 | #include "pppcielanes.h" |
46 | #include "fiji_hwmgr.h" | 46 | #include "fiji_hwmgr.h" |
47 | #include "tonga_processpptables.h" | 47 | #include "process_pptables_v1_0.h" |
48 | #include "tonga_pptable.h" | 48 | #include "pptable_v1_0.h" |
49 | #include "pp_debug.h" | 49 | #include "pp_debug.h" |
50 | #include "pp_acpi.h" | 50 | #include "pp_acpi.h" |
51 | #include "amd_pcie_helpers.h" | 51 | #include "amd_pcie_helpers.h" |
@@ -112,7 +112,7 @@ static const uint8_t fiji_clock_stretch_amount_conversion[2][6] = | |||
112 | 112 | ||
113 | static const unsigned long PhwFiji_Magic = (unsigned long)(PHM_VIslands_Magic); | 113 | static const unsigned long PhwFiji_Magic = (unsigned long)(PHM_VIslands_Magic); |
114 | 114 | ||
115 | struct fiji_power_state *cast_phw_fiji_power_state( | 115 | static struct fiji_power_state *cast_phw_fiji_power_state( |
116 | struct pp_hw_power_state *hw_ps) | 116 | struct pp_hw_power_state *hw_ps) |
117 | { | 117 | { |
118 | PP_ASSERT_WITH_CODE((PhwFiji_Magic == hw_ps->magic), | 118 | PP_ASSERT_WITH_CODE((PhwFiji_Magic == hw_ps->magic), |
@@ -122,7 +122,8 @@ struct fiji_power_state *cast_phw_fiji_power_state( | |||
122 | return (struct fiji_power_state *)hw_ps; | 122 | return (struct fiji_power_state *)hw_ps; |
123 | } | 123 | } |
124 | 124 | ||
125 | const struct fiji_power_state *cast_const_phw_fiji_power_state( | 125 | static const struct |
126 | fiji_power_state *cast_const_phw_fiji_power_state( | ||
126 | const struct pp_hw_power_state *hw_ps) | 127 | const struct pp_hw_power_state *hw_ps) |
127 | { | 128 | { |
128 | PP_ASSERT_WITH_CODE((PhwFiji_Magic == hw_ps->magic), | 129 | PP_ASSERT_WITH_CODE((PhwFiji_Magic == hw_ps->magic), |
@@ -1626,7 +1627,7 @@ static int fiji_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) | |||
1626 | * @param voltage - voltage to look for | 1627 | * @param voltage - voltage to look for |
1627 | * @return 0 on success | 1628 | * @return 0 on success |
1628 | */ | 1629 | */ |
1629 | uint8_t fiji_get_voltage_index( | 1630 | static uint8_t fiji_get_voltage_index( |
1630 | struct phm_ppt_v1_voltage_lookup_table *lookup_table, uint16_t voltage) | 1631 | struct phm_ppt_v1_voltage_lookup_table *lookup_table, uint16_t voltage) |
1631 | { | 1632 | { |
1632 | uint8_t count = (uint8_t) (lookup_table->count); | 1633 | uint8_t count = (uint8_t) (lookup_table->count); |
@@ -1690,7 +1691,7 @@ static int fiji_populate_cac_table(struct pp_hwmgr *hwmgr, | |||
1690 | * @return always 0 | 1691 | * @return always 0 |
1691 | */ | 1692 | */ |
1692 | 1693 | ||
1693 | int fiji_populate_smc_voltage_tables(struct pp_hwmgr *hwmgr, | 1694 | static int fiji_populate_smc_voltage_tables(struct pp_hwmgr *hwmgr, |
1694 | struct SMU73_Discrete_DpmTable *table) | 1695 | struct SMU73_Discrete_DpmTable *table) |
1695 | { | 1696 | { |
1696 | int result; | 1697 | int result; |
@@ -2301,7 +2302,7 @@ static int fiji_populate_all_memory_levels(struct pp_hwmgr *hwmgr) | |||
2301 | * @param mclk the MCLK value to be used in the decision if MVDD should be high or low. | 2302 | * @param mclk the MCLK value to be used in the decision if MVDD should be high or low. |
2302 | * @param voltage the SMC VOLTAGE structure to be populated | 2303 | * @param voltage the SMC VOLTAGE structure to be populated |
2303 | */ | 2304 | */ |
2304 | int fiji_populate_mvdd_value(struct pp_hwmgr *hwmgr, | 2305 | static int fiji_populate_mvdd_value(struct pp_hwmgr *hwmgr, |
2305 | uint32_t mclk, SMIO_Pattern *smio_pat) | 2306 | uint32_t mclk, SMIO_Pattern *smio_pat) |
2306 | { | 2307 | { |
2307 | const struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); | 2308 | const struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); |
@@ -4005,7 +4006,7 @@ static int fiji_get_pp_table_entry(struct pp_hwmgr *hwmgr, | |||
4005 | 4006 | ||
4006 | ps = (struct fiji_power_state *)(&state->hardware); | 4007 | ps = (struct fiji_power_state *)(&state->hardware); |
4007 | 4008 | ||
4008 | result = tonga_get_powerplay_table_entry(hwmgr, entry_index, state, | 4009 | result = get_powerplay_table_entry_v1_0(hwmgr, entry_index, state, |
4009 | fiji_get_pp_table_entry_callback_func); | 4010 | fiji_get_pp_table_entry_callback_func); |
4010 | 4011 | ||
4011 | /* This is the earliest time we have all the dependency table and the VBIOS boot state | 4012 | /* This is the earliest time we have all the dependency table and the VBIOS boot state |
@@ -4622,7 +4623,7 @@ static int fiji_generate_dpm_level_enable_mask( | |||
4622 | return 0; | 4623 | return 0; |
4623 | } | 4624 | } |
4624 | 4625 | ||
4625 | int fiji_enable_disable_uvd_dpm(struct pp_hwmgr *hwmgr, bool enable) | 4626 | static int fiji_enable_disable_uvd_dpm(struct pp_hwmgr *hwmgr, bool enable) |
4626 | { | 4627 | { |
4627 | return smum_send_msg_to_smc(hwmgr->smumgr, enable ? | 4628 | return smum_send_msg_to_smc(hwmgr->smumgr, enable ? |
4628 | (PPSMC_Msg)PPSMC_MSG_UVDDPM_Enable : | 4629 | (PPSMC_Msg)PPSMC_MSG_UVDDPM_Enable : |
@@ -4636,14 +4637,14 @@ int fiji_enable_disable_vce_dpm(struct pp_hwmgr *hwmgr, bool enable) | |||
4636 | PPSMC_MSG_VCEDPM_Disable); | 4637 | PPSMC_MSG_VCEDPM_Disable); |
4637 | } | 4638 | } |
4638 | 4639 | ||
4639 | int fiji_enable_disable_samu_dpm(struct pp_hwmgr *hwmgr, bool enable) | 4640 | static int fiji_enable_disable_samu_dpm(struct pp_hwmgr *hwmgr, bool enable) |
4640 | { | 4641 | { |
4641 | return smum_send_msg_to_smc(hwmgr->smumgr, enable? | 4642 | return smum_send_msg_to_smc(hwmgr->smumgr, enable? |
4642 | PPSMC_MSG_SAMUDPM_Enable : | 4643 | PPSMC_MSG_SAMUDPM_Enable : |
4643 | PPSMC_MSG_SAMUDPM_Disable); | 4644 | PPSMC_MSG_SAMUDPM_Disable); |
4644 | } | 4645 | } |
4645 | 4646 | ||
4646 | int fiji_enable_disable_acp_dpm(struct pp_hwmgr *hwmgr, bool enable) | 4647 | static int fiji_enable_disable_acp_dpm(struct pp_hwmgr *hwmgr, bool enable) |
4647 | { | 4648 | { |
4648 | return smum_send_msg_to_smc(hwmgr->smumgr, enable? | 4649 | return smum_send_msg_to_smc(hwmgr->smumgr, enable? |
4649 | PPSMC_MSG_ACPDPM_Enable : | 4650 | PPSMC_MSG_ACPDPM_Enable : |
@@ -4880,7 +4881,7 @@ static void fiji_apply_dal_minimum_voltage_request(struct pp_hwmgr *hwmgr) | |||
4880 | return; | 4881 | return; |
4881 | } | 4882 | } |
4882 | 4883 | ||
4883 | int fiji_upload_dpm_level_enable_mask(struct pp_hwmgr *hwmgr) | 4884 | static int fiji_upload_dpm_level_enable_mask(struct pp_hwmgr *hwmgr) |
4884 | { | 4885 | { |
4885 | int result; | 4886 | int result; |
4886 | struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); | 4887 | struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); |
@@ -5156,7 +5157,7 @@ static int fiji_program_display_gap(struct pp_hwmgr *hwmgr) | |||
5156 | return 0; | 5157 | return 0; |
5157 | } | 5158 | } |
5158 | 5159 | ||
5159 | int fiji_display_configuration_changed_task(struct pp_hwmgr *hwmgr) | 5160 | static int fiji_display_configuration_changed_task(struct pp_hwmgr *hwmgr) |
5160 | { | 5161 | { |
5161 | return fiji_program_display_gap(hwmgr); | 5162 | return fiji_program_display_gap(hwmgr); |
5162 | } | 5163 | } |
@@ -5187,7 +5188,7 @@ static int fiji_set_max_fan_rpm_output(struct pp_hwmgr *hwmgr, | |||
5187 | PPSMC_MSG_SetFanRpmMax, us_max_fan_rpm); | 5188 | PPSMC_MSG_SetFanRpmMax, us_max_fan_rpm); |
5188 | } | 5189 | } |
5189 | 5190 | ||
5190 | int fiji_dpm_set_interrupt_state(void *private_data, | 5191 | static int fiji_dpm_set_interrupt_state(void *private_data, |
5191 | unsigned src_id, unsigned type, | 5192 | unsigned src_id, unsigned type, |
5192 | int enabled) | 5193 | int enabled) |
5193 | { | 5194 | { |
@@ -5235,7 +5236,7 @@ int fiji_dpm_set_interrupt_state(void *private_data, | |||
5235 | return 0; | 5236 | return 0; |
5236 | } | 5237 | } |
5237 | 5238 | ||
5238 | int fiji_register_internal_thermal_interrupt(struct pp_hwmgr *hwmgr, | 5239 | static int fiji_register_internal_thermal_interrupt(struct pp_hwmgr *hwmgr, |
5239 | const void *thermal_interrupt_info) | 5240 | const void *thermal_interrupt_info) |
5240 | { | 5241 | { |
5241 | int result; | 5242 | int result; |
@@ -5405,7 +5406,10 @@ static inline bool fiji_are_power_levels_equal(const struct fiji_performance_lev | |||
5405 | (pl1->pcie_lane == pl2->pcie_lane)); | 5406 | (pl1->pcie_lane == pl2->pcie_lane)); |
5406 | } | 5407 | } |
5407 | 5408 | ||
5408 | int fiji_check_states_equal(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *pstate1, const struct pp_hw_power_state *pstate2, bool *equal) | 5409 | static int |
5410 | fiji_check_states_equal(struct pp_hwmgr *hwmgr, | ||
5411 | const struct pp_hw_power_state *pstate1, | ||
5412 | const struct pp_hw_power_state *pstate2, bool *equal) | ||
5409 | { | 5413 | { |
5410 | const struct fiji_power_state *psa = cast_const_phw_fiji_power_state(pstate1); | 5414 | const struct fiji_power_state *psa = cast_const_phw_fiji_power_state(pstate1); |
5411 | const struct fiji_power_state *psb = cast_const_phw_fiji_power_state(pstate2); | 5415 | const struct fiji_power_state *psb = cast_const_phw_fiji_power_state(pstate2); |
@@ -5437,7 +5441,8 @@ int fiji_check_states_equal(struct pp_hwmgr *hwmgr, const struct pp_hw_power_sta | |||
5437 | return 0; | 5441 | return 0; |
5438 | } | 5442 | } |
5439 | 5443 | ||
5440 | bool fiji_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hwmgr) | 5444 | static bool |
5445 | fiji_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hwmgr) | ||
5441 | { | 5446 | { |
5442 | struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); | 5447 | struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); |
5443 | bool is_update_required = false; | 5448 | bool is_update_required = false; |
@@ -5547,7 +5552,7 @@ static const struct pp_hwmgr_func fiji_hwmgr_funcs = { | |||
5547 | .dynamic_state_management_enable = &fiji_enable_dpm_tasks, | 5552 | .dynamic_state_management_enable = &fiji_enable_dpm_tasks, |
5548 | .dynamic_state_management_disable = &fiji_disable_dpm_tasks, | 5553 | .dynamic_state_management_disable = &fiji_disable_dpm_tasks, |
5549 | .force_dpm_level = &fiji_dpm_force_dpm_level, | 5554 | .force_dpm_level = &fiji_dpm_force_dpm_level, |
5550 | .get_num_of_pp_table_entries = &tonga_get_number_of_powerplay_table_entries, | 5555 | .get_num_of_pp_table_entries = &get_number_of_powerplay_table_entries_v1_0, |
5551 | .get_power_state_size = &fiji_get_power_state_size, | 5556 | .get_power_state_size = &fiji_get_power_state_size, |
5552 | .get_pp_table_entry = &fiji_get_pp_table_entry, | 5557 | .get_pp_table_entry = &fiji_get_pp_table_entry, |
5553 | .patch_boot_state = &fiji_patch_boot_state, | 5558 | .patch_boot_state = &fiji_patch_boot_state, |
@@ -5589,7 +5594,7 @@ static const struct pp_hwmgr_func fiji_hwmgr_funcs = { | |||
5589 | int fiji_hwmgr_init(struct pp_hwmgr *hwmgr) | 5594 | int fiji_hwmgr_init(struct pp_hwmgr *hwmgr) |
5590 | { | 5595 | { |
5591 | hwmgr->hwmgr_func = &fiji_hwmgr_funcs; | 5596 | hwmgr->hwmgr_func = &fiji_hwmgr_funcs; |
5592 | hwmgr->pptable_func = &tonga_pptable_funcs; | 5597 | hwmgr->pptable_func = &pptable_v1_0_funcs; |
5593 | pp_fiji_thermal_initialize(hwmgr); | 5598 | pp_fiji_thermal_initialize(hwmgr); |
5594 | return 0; | 5599 | return 0; |
5595 | } | 5600 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c index 92976b68d6fd..7f431e762262 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c | |||
@@ -152,7 +152,7 @@ int fiji_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr) | |||
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
155 | int fiji_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr) | 155 | static int fiji_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr) |
156 | { | 156 | { |
157 | int result; | 157 | int result; |
158 | 158 | ||
@@ -421,7 +421,7 @@ int fiji_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr) | |||
421 | * @param Result the last failure code | 421 | * @param Result the last failure code |
422 | * @return result from set temperature range routine | 422 | * @return result from set temperature range routine |
423 | */ | 423 | */ |
424 | int tf_fiji_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | 424 | static int tf_fiji_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, |
425 | void *input, void *output, void *storage, int result) | 425 | void *input, void *output, void *storage, int result) |
426 | { | 426 | { |
427 | struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); | 427 | struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); |
@@ -533,7 +533,7 @@ int tf_fiji_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | |||
533 | * @param Result the last failure code | 533 | * @param Result the last failure code |
534 | * @return result from set temperature range routine | 534 | * @return result from set temperature range routine |
535 | */ | 535 | */ |
536 | int tf_fiji_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, | 536 | static int tf_fiji_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, |
537 | void *input, void *output, void *storage, int result) | 537 | void *input, void *output, void *storage, int result) |
538 | { | 538 | { |
539 | /* If the fantable setup has failed we could have disabled | 539 | /* If the fantable setup has failed we could have disabled |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c index 789f98ad2615..14f8c1f4da3d 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | |||
@@ -24,8 +24,6 @@ | |||
24 | #include "hwmgr.h" | 24 | #include "hwmgr.h" |
25 | #include "hardwaremanager.h" | 25 | #include "hardwaremanager.h" |
26 | #include "power_state.h" | 26 | #include "power_state.h" |
27 | #include "pp_acpi.h" | ||
28 | #include "amd_acpi.h" | ||
29 | #include "pp_debug.h" | 27 | #include "pp_debug.h" |
30 | 28 | ||
31 | #define PHM_FUNC_CHECK(hw) \ | 29 | #define PHM_FUNC_CHECK(hw) \ |
@@ -34,38 +32,6 @@ | |||
34 | return -EINVAL; \ | 32 | return -EINVAL; \ |
35 | } while (0) | 33 | } while (0) |
36 | 34 | ||
37 | void phm_init_dynamic_caps(struct pp_hwmgr *hwmgr) | ||
38 | { | ||
39 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableVoltageTransition); | ||
40 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableEngineTransition); | ||
41 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMemoryTransition); | ||
42 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMGClockGating); | ||
43 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMGCGTSSM); | ||
44 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableLSClockGating); | ||
45 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_Force3DClockSupport); | ||
46 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableLightSleep); | ||
47 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMCLS); | ||
48 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisablePowerGating); | ||
49 | |||
50 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableDPM); | ||
51 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableSMUUVDHandshake); | ||
52 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_ThermalAutoThrottling); | ||
53 | |||
54 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PCIEPerformanceRequest); | ||
55 | |||
56 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_NoOD5Support); | ||
57 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UserMaxClockForMultiDisplays); | ||
58 | |||
59 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_VpuRecoveryInProgress); | ||
60 | |||
61 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDDPM); | ||
62 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_VCEDPM); | ||
63 | |||
64 | if (acpi_atcs_functions_supported(hwmgr->device, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST) && | ||
65 | acpi_atcs_functions_supported(hwmgr->device, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION)) | ||
66 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PCIEPerformanceRequest); | ||
67 | } | ||
68 | |||
69 | bool phm_is_hw_access_blocked(struct pp_hwmgr *hwmgr) | 35 | bool phm_is_hw_access_blocked(struct pp_hwmgr *hwmgr) |
70 | { | 36 | { |
71 | return hwmgr->block_hw_access; | 37 | return hwmgr->block_hw_access; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c index d829076ed9ea..524d0dd4f0e9 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | |||
@@ -32,8 +32,8 @@ | |||
32 | #include "pp_debug.h" | 32 | #include "pp_debug.h" |
33 | #include "ppatomctrl.h" | 33 | #include "ppatomctrl.h" |
34 | #include "ppsmc.h" | 34 | #include "ppsmc.h" |
35 | 35 | #include "pp_acpi.h" | |
36 | #define VOLTAGE_SCALE 4 | 36 | #include "amd_acpi.h" |
37 | 37 | ||
38 | extern int cz_hwmgr_init(struct pp_hwmgr *hwmgr); | 38 | extern int cz_hwmgr_init(struct pp_hwmgr *hwmgr); |
39 | extern int tonga_hwmgr_init(struct pp_hwmgr *hwmgr); | 39 | extern int tonga_hwmgr_init(struct pp_hwmgr *hwmgr); |
@@ -41,23 +41,12 @@ extern int fiji_hwmgr_init(struct pp_hwmgr *hwmgr); | |||
41 | extern int polaris10_hwmgr_init(struct pp_hwmgr *hwmgr); | 41 | extern int polaris10_hwmgr_init(struct pp_hwmgr *hwmgr); |
42 | extern int iceland_hwmgr_init(struct pp_hwmgr *hwmgr); | 42 | extern int iceland_hwmgr_init(struct pp_hwmgr *hwmgr); |
43 | 43 | ||
44 | static int hwmgr_set_features_platform_caps(struct pp_hwmgr *hwmgr) | 44 | static void hwmgr_init_default_caps(struct pp_hwmgr *hwmgr); |
45 | { | 45 | static int hwmgr_set_user_specify_caps(struct pp_hwmgr *hwmgr); |
46 | if (amdgpu_sclk_deep_sleep_en) | ||
47 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
48 | PHM_PlatformCaps_SclkDeepSleep); | ||
49 | else | ||
50 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
51 | PHM_PlatformCaps_SclkDeepSleep); | ||
52 | |||
53 | if (amdgpu_powercontainment) | ||
54 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
55 | PHM_PlatformCaps_PowerContainment); | ||
56 | else | ||
57 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
58 | PHM_PlatformCaps_PowerContainment); | ||
59 | 46 | ||
60 | return 0; | 47 | uint8_t convert_to_vid(uint16_t vddc) |
48 | { | ||
49 | return (uint8_t) ((6200 - (vddc * VOLTAGE_SCALE)) / 25); | ||
61 | } | 50 | } |
62 | 51 | ||
63 | int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | 52 | int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) |
@@ -76,13 +65,12 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | |||
76 | hwmgr->device = pp_init->device; | 65 | hwmgr->device = pp_init->device; |
77 | hwmgr->chip_family = pp_init->chip_family; | 66 | hwmgr->chip_family = pp_init->chip_family; |
78 | hwmgr->chip_id = pp_init->chip_id; | 67 | hwmgr->chip_id = pp_init->chip_id; |
79 | hwmgr->hw_revision = pp_init->rev_id; | ||
80 | hwmgr->sub_sys_id = pp_init->sub_sys_id; | ||
81 | hwmgr->sub_vendor_id = pp_init->sub_vendor_id; | ||
82 | hwmgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; | 68 | hwmgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; |
83 | hwmgr->power_source = PP_PowerSource_AC; | 69 | hwmgr->power_source = PP_PowerSource_AC; |
70 | hwmgr->pp_table_version = PP_TABLE_V1; | ||
84 | 71 | ||
85 | hwmgr_set_features_platform_caps(hwmgr); | 72 | hwmgr_init_default_caps(hwmgr); |
73 | hwmgr_set_user_specify_caps(hwmgr); | ||
86 | 74 | ||
87 | switch (hwmgr->chip_family) { | 75 | switch (hwmgr->chip_family) { |
88 | case AMDGPU_FAMILY_CZ: | 76 | case AMDGPU_FAMILY_CZ: |
@@ -111,8 +99,6 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | |||
111 | return -EINVAL; | 99 | return -EINVAL; |
112 | } | 100 | } |
113 | 101 | ||
114 | phm_init_dynamic_caps(hwmgr); | ||
115 | |||
116 | return 0; | 102 | return 0; |
117 | } | 103 | } |
118 | 104 | ||
@@ -131,6 +117,8 @@ int hwmgr_fini(struct pp_hwmgr *hwmgr) | |||
131 | kfree(hwmgr->set_temperature_range.function_list); | 117 | kfree(hwmgr->set_temperature_range.function_list); |
132 | 118 | ||
133 | kfree(hwmgr->ps); | 119 | kfree(hwmgr->ps); |
120 | kfree(hwmgr->current_ps); | ||
121 | kfree(hwmgr->request_ps); | ||
134 | kfree(hwmgr); | 122 | kfree(hwmgr); |
135 | return 0; | 123 | return 0; |
136 | } | 124 | } |
@@ -155,10 +143,17 @@ int hw_init_power_state_table(struct pp_hwmgr *hwmgr) | |||
155 | sizeof(struct pp_power_state); | 143 | sizeof(struct pp_power_state); |
156 | 144 | ||
157 | hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL); | 145 | hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL); |
158 | |||
159 | if (hwmgr->ps == NULL) | 146 | if (hwmgr->ps == NULL) |
160 | return -ENOMEM; | 147 | return -ENOMEM; |
161 | 148 | ||
149 | hwmgr->request_ps = kzalloc(size, GFP_KERNEL); | ||
150 | if (hwmgr->request_ps == NULL) | ||
151 | return -ENOMEM; | ||
152 | |||
153 | hwmgr->current_ps = kzalloc(size, GFP_KERNEL); | ||
154 | if (hwmgr->current_ps == NULL) | ||
155 | return -ENOMEM; | ||
156 | |||
162 | state = hwmgr->ps; | 157 | state = hwmgr->ps; |
163 | 158 | ||
164 | for (i = 0; i < table_entries; i++) { | 159 | for (i = 0; i < table_entries; i++) { |
@@ -166,7 +161,8 @@ int hw_init_power_state_table(struct pp_hwmgr *hwmgr) | |||
166 | 161 | ||
167 | if (state->classification.flags & PP_StateClassificationFlag_Boot) { | 162 | if (state->classification.flags & PP_StateClassificationFlag_Boot) { |
168 | hwmgr->boot_ps = state; | 163 | hwmgr->boot_ps = state; |
169 | hwmgr->current_ps = hwmgr->request_ps = state; | 164 | memcpy(hwmgr->current_ps, state, size); |
165 | memcpy(hwmgr->request_ps, state, size); | ||
170 | } | 166 | } |
171 | 167 | ||
172 | state->id = i + 1; /* assigned unique num for every power state id */ | 168 | state->id = i + 1; /* assigned unique num for every power state id */ |
@@ -176,6 +172,7 @@ int hw_init_power_state_table(struct pp_hwmgr *hwmgr) | |||
176 | state = (struct pp_power_state *)((unsigned long)state + size); | 172 | state = (struct pp_power_state *)((unsigned long)state + size); |
177 | } | 173 | } |
178 | 174 | ||
175 | |||
179 | return 0; | 176 | return 0; |
180 | } | 177 | } |
181 | 178 | ||
@@ -209,8 +206,6 @@ int phm_wait_on_register(struct pp_hwmgr *hwmgr, uint32_t index, | |||
209 | } | 206 | } |
210 | 207 | ||
211 | 208 | ||
212 | |||
213 | |||
214 | /** | 209 | /** |
215 | * Returns once the part of the register indicated by the mask has | 210 | * Returns once the part of the register indicated by the mask has |
216 | * reached the given value.The indirect space is described by giving | 211 | * reached the given value.The indirect space is described by giving |
@@ -452,6 +447,27 @@ uint8_t phm_get_voltage_index( | |||
452 | return i - 1; | 447 | return i - 1; |
453 | } | 448 | } |
454 | 449 | ||
450 | uint8_t phm_get_voltage_id(pp_atomctrl_voltage_table *voltage_table, | ||
451 | uint32_t voltage) | ||
452 | { | ||
453 | uint8_t count = (uint8_t) (voltage_table->count); | ||
454 | uint8_t i = 0; | ||
455 | |||
456 | PP_ASSERT_WITH_CODE((NULL != voltage_table), | ||
457 | "Voltage Table empty.", return 0;); | ||
458 | PP_ASSERT_WITH_CODE((0 != count), | ||
459 | "Voltage Table empty.", return 0;); | ||
460 | |||
461 | for (i = 0; i < count; i++) { | ||
462 | /* find first voltage bigger than requested */ | ||
463 | if (voltage_table->entries[i].value >= voltage) | ||
464 | return i; | ||
465 | } | ||
466 | |||
467 | /* voltage is bigger than max voltage in the table */ | ||
468 | return i - 1; | ||
469 | } | ||
470 | |||
455 | uint16_t phm_find_closest_vddci(struct pp_atomctrl_voltage_table *vddci_table, uint16_t vddci) | 471 | uint16_t phm_find_closest_vddci(struct pp_atomctrl_voltage_table *vddci_table, uint16_t vddci) |
456 | { | 472 | { |
457 | uint32_t i; | 473 | uint32_t i; |
@@ -539,7 +555,8 @@ int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr | |||
539 | table_clk_vlt->entries[2].v = 810; | 555 | table_clk_vlt->entries[2].v = 810; |
540 | table_clk_vlt->entries[3].clk = PP_DAL_POWERLEVEL_PERFORMANCE; | 556 | table_clk_vlt->entries[3].clk = PP_DAL_POWERLEVEL_PERFORMANCE; |
541 | table_clk_vlt->entries[3].v = 900; | 557 | table_clk_vlt->entries[3].v = 900; |
542 | pptable_info->vddc_dep_on_dal_pwrl = table_clk_vlt; | 558 | if (pptable_info != NULL) |
559 | pptable_info->vddc_dep_on_dal_pwrl = table_clk_vlt; | ||
543 | hwmgr->dyn_state.vddc_dep_on_dal_pwrl = table_clk_vlt; | 560 | hwmgr->dyn_state.vddc_dep_on_dal_pwrl = table_clk_vlt; |
544 | } | 561 | } |
545 | 562 | ||
@@ -605,3 +622,94 @@ void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr) | |||
605 | printk(KERN_ERR "DAL requested level can not" | 622 | printk(KERN_ERR "DAL requested level can not" |
606 | " found a available voltage in VDDC DPM Table \n"); | 623 | " found a available voltage in VDDC DPM Table \n"); |
607 | } | 624 | } |
625 | |||
626 | void hwmgr_init_default_caps(struct pp_hwmgr *hwmgr) | ||
627 | { | ||
628 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableVoltageTransition); | ||
629 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableEngineTransition); | ||
630 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMemoryTransition); | ||
631 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMGClockGating); | ||
632 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMGCGTSSM); | ||
633 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableLSClockGating); | ||
634 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_Force3DClockSupport); | ||
635 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableLightSleep); | ||
636 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableMCLS); | ||
637 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisablePowerGating); | ||
638 | |||
639 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableDPM); | ||
640 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DisableSMUUVDHandshake); | ||
641 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_ThermalAutoThrottling); | ||
642 | |||
643 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PCIEPerformanceRequest); | ||
644 | |||
645 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_NoOD5Support); | ||
646 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UserMaxClockForMultiDisplays); | ||
647 | |||
648 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_VpuRecoveryInProgress); | ||
649 | |||
650 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDDPM); | ||
651 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_VCEDPM); | ||
652 | |||
653 | if (acpi_atcs_functions_supported(hwmgr->device, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST) && | ||
654 | acpi_atcs_functions_supported(hwmgr->device, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION)) | ||
655 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PCIEPerformanceRequest); | ||
656 | |||
657 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
658 | PHM_PlatformCaps_DynamicPatchPowerState); | ||
659 | |||
660 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
661 | PHM_PlatformCaps_EnableSMU7ThermalManagement); | ||
662 | |||
663 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
664 | PHM_PlatformCaps_DynamicPowerManagement); | ||
665 | |||
666 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
667 | PHM_PlatformCaps_SMC); | ||
668 | |||
669 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
670 | PHM_PlatformCaps_DynamicUVDState); | ||
671 | |||
672 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
673 | PHM_PlatformCaps_FanSpeedInTableIsRPM); | ||
674 | |||
675 | return; | ||
676 | } | ||
677 | |||
678 | int hwmgr_set_user_specify_caps(struct pp_hwmgr *hwmgr) | ||
679 | { | ||
680 | if (amdgpu_sclk_deep_sleep_en) | ||
681 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
682 | PHM_PlatformCaps_SclkDeepSleep); | ||
683 | else | ||
684 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
685 | PHM_PlatformCaps_SclkDeepSleep); | ||
686 | |||
687 | if (amdgpu_powercontainment) | ||
688 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | ||
689 | PHM_PlatformCaps_PowerContainment); | ||
690 | else | ||
691 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
692 | PHM_PlatformCaps_PowerContainment); | ||
693 | |||
694 | hwmgr->feature_mask = amdgpu_pp_feature_mask; | ||
695 | |||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | int phm_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, | ||
700 | uint32_t sclk, uint16_t id, uint16_t *voltage) | ||
701 | { | ||
702 | uint32_t vol; | ||
703 | int ret = 0; | ||
704 | |||
705 | if (hwmgr->chip_id < CHIP_POLARIS10) { | ||
706 | atomctrl_get_voltage_evv_on_sclk(hwmgr, voltage_type, sclk, id, voltage); | ||
707 | if (*voltage >= 2000 || *voltage == 0) | ||
708 | *voltage = 1150; | ||
709 | } else { | ||
710 | ret = atomctrl_get_voltage_evv_on_sclk_ai(hwmgr, voltage_type, sclk, id, &vol); | ||
711 | *voltage = (uint16_t)vol/100; | ||
712 | } | ||
713 | return ret; | ||
714 | } | ||
715 | |||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c index 8a7ada50551c..5abe43360ec0 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c | |||
@@ -781,7 +781,7 @@ static int iceland_upload_firmware(struct pp_hwmgr *hwmgr) | |||
781 | * @param hwmgr the address of the powerplay hardware manager. | 781 | * @param hwmgr the address of the powerplay hardware manager. |
782 | * @return always 0 | 782 | * @return always 0 |
783 | */ | 783 | */ |
784 | int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | 784 | static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) |
785 | { | 785 | { |
786 | iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend); | 786 | iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend); |
787 | 787 | ||
@@ -1355,14 +1355,6 @@ static int iceland_populate_smc_mvdd_table(struct pp_hwmgr *hwmgr, | |||
1355 | return 0; | 1355 | return 0; |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | /** | ||
1359 | * Convert a voltage value in mv unit to VID number required by SMU firmware | ||
1360 | */ | ||
1361 | static uint8_t convert_to_vid(uint16_t vddc) | ||
1362 | { | ||
1363 | return (uint8_t) ((6200 - (vddc * VOLTAGE_SCALE)) / 25); | ||
1364 | } | ||
1365 | |||
1366 | int iceland_populate_bapm_vddc_vid_sidd(struct pp_hwmgr *hwmgr) | 1358 | int iceland_populate_bapm_vddc_vid_sidd(struct pp_hwmgr *hwmgr) |
1367 | { | 1359 | { |
1368 | int i; | 1360 | int i; |
@@ -2606,7 +2598,7 @@ static int iceland_populate_smc_initial_state(struct pp_hwmgr *hwmgr) | |||
2606 | * @param pInput the pointer to input data (PowerState) | 2598 | * @param pInput the pointer to input data (PowerState) |
2607 | * @return always 0 | 2599 | * @return always 0 |
2608 | */ | 2600 | */ |
2609 | int iceland_init_smc_table(struct pp_hwmgr *hwmgr) | 2601 | static int iceland_init_smc_table(struct pp_hwmgr *hwmgr) |
2610 | { | 2602 | { |
2611 | int result; | 2603 | int result; |
2612 | iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend); | 2604 | iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend); |
@@ -4629,7 +4621,7 @@ static int iceland_update_vce_dpm(struct pp_hwmgr *hwmgr, const void *input) | |||
4629 | return 0; | 4621 | return 0; |
4630 | } | 4622 | } |
4631 | 4623 | ||
4632 | int iceland_update_sclk_threshold(struct pp_hwmgr *hwmgr) | 4624 | static int iceland_update_sclk_threshold(struct pp_hwmgr *hwmgr) |
4633 | { | 4625 | { |
4634 | iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend); | 4626 | iceland_hwmgr *data = (iceland_hwmgr *)(hwmgr->backend); |
4635 | 4627 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_clockpowergating.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_clockpowergating.c index b5edb5105986..7e405b04c2c5 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_clockpowergating.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_clockpowergating.c | |||
@@ -31,7 +31,7 @@ int polaris10_phm_powerdown_uvd(struct pp_hwmgr *hwmgr) | |||
31 | return 0; | 31 | return 0; |
32 | } | 32 | } |
33 | 33 | ||
34 | int polaris10_phm_powerup_uvd(struct pp_hwmgr *hwmgr) | 34 | static int polaris10_phm_powerup_uvd(struct pp_hwmgr *hwmgr) |
35 | { | 35 | { |
36 | if (phm_cf_want_uvd_power_gating(hwmgr)) { | 36 | if (phm_cf_want_uvd_power_gating(hwmgr)) { |
37 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 37 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
@@ -47,7 +47,7 @@ int polaris10_phm_powerup_uvd(struct pp_hwmgr *hwmgr) | |||
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | int polaris10_phm_powerdown_vce(struct pp_hwmgr *hwmgr) | 50 | static int polaris10_phm_powerdown_vce(struct pp_hwmgr *hwmgr) |
51 | { | 51 | { |
52 | if (phm_cf_want_vce_power_gating(hwmgr)) | 52 | if (phm_cf_want_vce_power_gating(hwmgr)) |
53 | return smum_send_msg_to_smc(hwmgr->smumgr, | 53 | return smum_send_msg_to_smc(hwmgr->smumgr, |
@@ -55,7 +55,7 @@ int polaris10_phm_powerdown_vce(struct pp_hwmgr *hwmgr) | |||
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | 57 | ||
58 | int polaris10_phm_powerup_vce(struct pp_hwmgr *hwmgr) | 58 | static int polaris10_phm_powerup_vce(struct pp_hwmgr *hwmgr) |
59 | { | 59 | { |
60 | if (phm_cf_want_vce_power_gating(hwmgr)) | 60 | if (phm_cf_want_vce_power_gating(hwmgr)) |
61 | return smum_send_msg_to_smc(hwmgr->smumgr, | 61 | return smum_send_msg_to_smc(hwmgr->smumgr, |
@@ -63,7 +63,7 @@ int polaris10_phm_powerup_vce(struct pp_hwmgr *hwmgr) | |||
63 | return 0; | 63 | return 0; |
64 | } | 64 | } |
65 | 65 | ||
66 | int polaris10_phm_powerdown_samu(struct pp_hwmgr *hwmgr) | 66 | static int polaris10_phm_powerdown_samu(struct pp_hwmgr *hwmgr) |
67 | { | 67 | { |
68 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 68 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
69 | PHM_PlatformCaps_SamuPowerGating)) | 69 | PHM_PlatformCaps_SamuPowerGating)) |
@@ -72,7 +72,7 @@ int polaris10_phm_powerdown_samu(struct pp_hwmgr *hwmgr) | |||
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | int polaris10_phm_powerup_samu(struct pp_hwmgr *hwmgr) | 75 | static int polaris10_phm_powerup_samu(struct pp_hwmgr *hwmgr) |
76 | { | 76 | { |
77 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 77 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
78 | PHM_PlatformCaps_SamuPowerGating)) | 78 | PHM_PlatformCaps_SamuPowerGating)) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c index b69132296672..191ed504effb 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c | |||
@@ -33,11 +33,11 @@ | |||
33 | #include "pp_debug.h" | 33 | #include "pp_debug.h" |
34 | #include "ppatomctrl.h" | 34 | #include "ppatomctrl.h" |
35 | #include "atombios.h" | 35 | #include "atombios.h" |
36 | #include "tonga_pptable.h" | 36 | #include "pptable_v1_0.h" |
37 | #include "pppcielanes.h" | 37 | #include "pppcielanes.h" |
38 | #include "amd_pcie_helpers.h" | 38 | #include "amd_pcie_helpers.h" |
39 | #include "hardwaremanager.h" | 39 | #include "hardwaremanager.h" |
40 | #include "tonga_processpptables.h" | 40 | #include "process_pptables_v1_0.h" |
41 | #include "cgs_common.h" | 41 | #include "cgs_common.h" |
42 | #include "smu74.h" | 42 | #include "smu74.h" |
43 | #include "smu_ucode_xfer_vi.h" | 43 | #include "smu_ucode_xfer_vi.h" |
@@ -108,7 +108,7 @@ enum DPM_EVENT_SRC { | |||
108 | 108 | ||
109 | static const unsigned long PhwPolaris10_Magic = (unsigned long)(PHM_VIslands_Magic); | 109 | static const unsigned long PhwPolaris10_Magic = (unsigned long)(PHM_VIslands_Magic); |
110 | 110 | ||
111 | struct polaris10_power_state *cast_phw_polaris10_power_state( | 111 | static struct polaris10_power_state *cast_phw_polaris10_power_state( |
112 | struct pp_hw_power_state *hw_ps) | 112 | struct pp_hw_power_state *hw_ps) |
113 | { | 113 | { |
114 | PP_ASSERT_WITH_CODE((PhwPolaris10_Magic == hw_ps->magic), | 114 | PP_ASSERT_WITH_CODE((PhwPolaris10_Magic == hw_ps->magic), |
@@ -118,7 +118,8 @@ struct polaris10_power_state *cast_phw_polaris10_power_state( | |||
118 | return (struct polaris10_power_state *)hw_ps; | 118 | return (struct polaris10_power_state *)hw_ps; |
119 | } | 119 | } |
120 | 120 | ||
121 | const struct polaris10_power_state *cast_const_phw_polaris10_power_state( | 121 | static const struct polaris10_power_state * |
122 | cast_const_phw_polaris10_power_state( | ||
122 | const struct pp_hw_power_state *hw_ps) | 123 | const struct pp_hw_power_state *hw_ps) |
123 | { | 124 | { |
124 | PP_ASSERT_WITH_CODE((PhwPolaris10_Magic == hw_ps->magic), | 125 | PP_ASSERT_WITH_CODE((PhwPolaris10_Magic == hw_ps->magic), |
@@ -141,7 +142,7 @@ static bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr) | |||
141 | * @param hwmgr the address of the powerplay hardware manager. | 142 | * @param hwmgr the address of the powerplay hardware manager. |
142 | * @return always 0 | 143 | * @return always 0 |
143 | */ | 144 | */ |
144 | int phm_get_mc_microcode_version (struct pp_hwmgr *hwmgr) | 145 | static int phm_get_mc_microcode_version(struct pp_hwmgr *hwmgr) |
145 | { | 146 | { |
146 | cgs_write_register(hwmgr->device, mmMC_SEQ_IO_DEBUG_INDEX, 0x9F); | 147 | cgs_write_register(hwmgr->device, mmMC_SEQ_IO_DEBUG_INDEX, 0x9F); |
147 | 148 | ||
@@ -150,7 +151,7 @@ int phm_get_mc_microcode_version (struct pp_hwmgr *hwmgr) | |||
150 | return 0; | 151 | return 0; |
151 | } | 152 | } |
152 | 153 | ||
153 | uint16_t phm_get_current_pcie_speed(struct pp_hwmgr *hwmgr) | 154 | static uint16_t phm_get_current_pcie_speed(struct pp_hwmgr *hwmgr) |
154 | { | 155 | { |
155 | uint32_t speedCntl = 0; | 156 | uint32_t speedCntl = 0; |
156 | 157 | ||
@@ -161,7 +162,7 @@ uint16_t phm_get_current_pcie_speed(struct pp_hwmgr *hwmgr) | |||
161 | PCIE_LC_SPEED_CNTL, LC_CURRENT_DATA_RATE)); | 162 | PCIE_LC_SPEED_CNTL, LC_CURRENT_DATA_RATE)); |
162 | } | 163 | } |
163 | 164 | ||
164 | int phm_get_current_pcie_lane_number(struct pp_hwmgr *hwmgr) | 165 | static int phm_get_current_pcie_lane_number(struct pp_hwmgr *hwmgr) |
165 | { | 166 | { |
166 | uint32_t link_width; | 167 | uint32_t link_width; |
167 | 168 | ||
@@ -181,7 +182,7 @@ int phm_get_current_pcie_lane_number(struct pp_hwmgr *hwmgr) | |||
181 | * @param pHwMgr the address of the powerplay hardware manager. | 182 | * @param pHwMgr the address of the powerplay hardware manager. |
182 | * @return always PP_Result_OK | 183 | * @return always PP_Result_OK |
183 | */ | 184 | */ |
184 | int polaris10_enable_smc_voltage_controller(struct pp_hwmgr *hwmgr) | 185 | static int polaris10_enable_smc_voltage_controller(struct pp_hwmgr *hwmgr) |
185 | { | 186 | { |
186 | PP_ASSERT_WITH_CODE( | 187 | PP_ASSERT_WITH_CODE( |
187 | (hwmgr->smumgr->smumgr_funcs->send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Voltage_Cntl_Enable) == 0), | 188 | (hwmgr->smumgr->smumgr_funcs->send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Voltage_Cntl_Enable) == 0), |
@@ -661,7 +662,7 @@ static int polaris10_setup_default_pcie_table(struct pp_hwmgr *hwmgr) | |||
661 | * on the power policy or external client requests, | 662 | * on the power policy or external client requests, |
662 | * such as UVD request, etc. | 663 | * such as UVD request, etc. |
663 | */ | 664 | */ |
664 | int polaris10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) | 665 | static int polaris10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) |
665 | { | 666 | { |
666 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 667 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
667 | struct phm_ppt_v1_information *table_info = | 668 | struct phm_ppt_v1_information *table_info = |
@@ -735,11 +736,6 @@ int polaris10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) | |||
735 | return 0; | 736 | return 0; |
736 | } | 737 | } |
737 | 738 | ||
738 | uint8_t convert_to_vid(uint16_t vddc) | ||
739 | { | ||
740 | return (uint8_t) ((6200 - (vddc * VOLTAGE_SCALE)) / 25); | ||
741 | } | ||
742 | |||
743 | /** | 739 | /** |
744 | * Mvdd table preparation for SMC. | 740 | * Mvdd table preparation for SMC. |
745 | * | 741 | * |
@@ -840,7 +836,7 @@ static int polaris10_populate_cac_table(struct pp_hwmgr *hwmgr, | |||
840 | * @return always 0 | 836 | * @return always 0 |
841 | */ | 837 | */ |
842 | 838 | ||
843 | int polaris10_populate_smc_voltage_tables(struct pp_hwmgr *hwmgr, | 839 | static int polaris10_populate_smc_voltage_tables(struct pp_hwmgr *hwmgr, |
844 | struct SMU74_Discrete_DpmTable *table) | 840 | struct SMU74_Discrete_DpmTable *table) |
845 | { | 841 | { |
846 | polaris10_populate_smc_vddci_table(hwmgr, table); | 842 | polaris10_populate_smc_vddci_table(hwmgr, table); |
@@ -1417,7 +1413,7 @@ static int polaris10_populate_all_memory_levels(struct pp_hwmgr *hwmgr) | |||
1417 | * @param mclk the MCLK value to be used in the decision if MVDD should be high or low. | 1413 | * @param mclk the MCLK value to be used in the decision if MVDD should be high or low. |
1418 | * @param voltage the SMC VOLTAGE structure to be populated | 1414 | * @param voltage the SMC VOLTAGE structure to be populated |
1419 | */ | 1415 | */ |
1420 | int polaris10_populate_mvdd_value(struct pp_hwmgr *hwmgr, | 1416 | static int polaris10_populate_mvdd_value(struct pp_hwmgr *hwmgr, |
1421 | uint32_t mclk, SMIO_Pattern *smio_pat) | 1417 | uint32_t mclk, SMIO_Pattern *smio_pat) |
1422 | { | 1418 | { |
1423 | const struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 1419 | const struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
@@ -1931,7 +1927,7 @@ static int polaris10_populate_vr_config(struct pp_hwmgr *hwmgr, | |||
1931 | } | 1927 | } |
1932 | 1928 | ||
1933 | 1929 | ||
1934 | int polaris10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) | 1930 | static int polaris10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) |
1935 | { | 1931 | { |
1936 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 1932 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
1937 | SMU74_Discrete_DpmTable *table = &(data->smc_state_table); | 1933 | SMU74_Discrete_DpmTable *table = &(data->smc_state_table); |
@@ -2560,7 +2556,7 @@ static int polaris10_disable_thermal_auto_throttle(struct pp_hwmgr *hwmgr) | |||
2560 | return polaris10_disable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); | 2556 | return polaris10_disable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); |
2561 | } | 2557 | } |
2562 | 2558 | ||
2563 | int polaris10_pcie_performance_request(struct pp_hwmgr *hwmgr) | 2559 | static int polaris10_pcie_performance_request(struct pp_hwmgr *hwmgr) |
2564 | { | 2560 | { |
2565 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 2561 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
2566 | data->pcie_performance_request = true; | 2562 | data->pcie_performance_request = true; |
@@ -2568,7 +2564,7 @@ int polaris10_pcie_performance_request(struct pp_hwmgr *hwmgr) | |||
2568 | return 0; | 2564 | return 0; |
2569 | } | 2565 | } |
2570 | 2566 | ||
2571 | int polaris10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | 2567 | static int polaris10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) |
2572 | { | 2568 | { |
2573 | int tmp_result, result = 0; | 2569 | int tmp_result, result = 0; |
2574 | tmp_result = (!polaris10_is_dpm_running(hwmgr)) ? 0 : -1; | 2570 | tmp_result = (!polaris10_is_dpm_running(hwmgr)) ? 0 : -1; |
@@ -2749,12 +2745,12 @@ int polaris10_reset_asic_tasks(struct pp_hwmgr *hwmgr) | |||
2749 | return 0; | 2745 | return 0; |
2750 | } | 2746 | } |
2751 | 2747 | ||
2752 | int polaris10_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) | 2748 | static int polaris10_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) |
2753 | { | 2749 | { |
2754 | return phm_hwmgr_backend_fini(hwmgr); | 2750 | return phm_hwmgr_backend_fini(hwmgr); |
2755 | } | 2751 | } |
2756 | 2752 | ||
2757 | int polaris10_set_features_platform_caps(struct pp_hwmgr *hwmgr) | 2753 | static int polaris10_set_features_platform_caps(struct pp_hwmgr *hwmgr) |
2758 | { | 2754 | { |
2759 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 2755 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
2760 | 2756 | ||
@@ -3109,7 +3105,7 @@ static int polaris10_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr) | |||
3109 | return 0; | 3105 | return 0; |
3110 | } | 3106 | } |
3111 | 3107 | ||
3112 | int polaris10_patch_voltage_workaround(struct pp_hwmgr *hwmgr) | 3108 | static int polaris10_patch_voltage_workaround(struct pp_hwmgr *hwmgr) |
3113 | { | 3109 | { |
3114 | struct phm_ppt_v1_information *table_info = | 3110 | struct phm_ppt_v1_information *table_info = |
3115 | (struct phm_ppt_v1_information *)(hwmgr->pptable); | 3111 | (struct phm_ppt_v1_information *)(hwmgr->pptable); |
@@ -3118,11 +3114,27 @@ int polaris10_patch_voltage_workaround(struct pp_hwmgr *hwmgr) | |||
3118 | struct phm_ppt_v1_voltage_lookup_table *lookup_table = | 3114 | struct phm_ppt_v1_voltage_lookup_table *lookup_table = |
3119 | table_info->vddc_lookup_table; | 3115 | table_info->vddc_lookup_table; |
3120 | uint32_t i; | 3116 | uint32_t i; |
3117 | uint32_t hw_revision, sub_vendor_id, sub_sys_id; | ||
3118 | struct cgs_system_info sys_info = {0}; | ||
3119 | |||
3120 | sys_info.size = sizeof(struct cgs_system_info); | ||
3121 | 3121 | ||
3122 | if (hwmgr->chip_id == CHIP_POLARIS10 && hwmgr->hw_revision == 0xC7 && | 3122 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_REV; |
3123 | ((hwmgr->sub_sys_id == 0xb37 && hwmgr->sub_vendor_id == 0x1002) || | 3123 | cgs_query_system_info(hwmgr->device, &sys_info); |
3124 | (hwmgr->sub_sys_id == 0x4a8 && hwmgr->sub_vendor_id == 0x1043) || | 3124 | hw_revision = (uint32_t)sys_info.value; |
3125 | (hwmgr->sub_sys_id == 0x9480 && hwmgr->sub_vendor_id == 0x1682))) { | 3125 | |
3126 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_SUB_SYS_ID; | ||
3127 | cgs_query_system_info(hwmgr->device, &sys_info); | ||
3128 | sub_sys_id = (uint32_t)sys_info.value; | ||
3129 | |||
3130 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_SUB_SYS_VENDOR_ID; | ||
3131 | cgs_query_system_info(hwmgr->device, &sys_info); | ||
3132 | sub_vendor_id = (uint32_t)sys_info.value; | ||
3133 | |||
3134 | if (hwmgr->chip_id == CHIP_POLARIS10 && hw_revision == 0xC7 && | ||
3135 | ((sub_sys_id == 0xb37 && sub_vendor_id == 0x1002) || | ||
3136 | (sub_sys_id == 0x4a8 && sub_vendor_id == 0x1043) || | ||
3137 | (sub_sys_id == 0x9480 && sub_vendor_id == 0x1682))) { | ||
3126 | if (lookup_table->entries[dep_mclk_table->entries[dep_mclk_table->count-1].vddInd].us_vdd >= 1000) | 3138 | if (lookup_table->entries[dep_mclk_table->entries[dep_mclk_table->count-1].vddInd].us_vdd >= 1000) |
3127 | return 0; | 3139 | return 0; |
3128 | 3140 | ||
@@ -3137,7 +3149,7 @@ int polaris10_patch_voltage_workaround(struct pp_hwmgr *hwmgr) | |||
3137 | } | 3149 | } |
3138 | 3150 | ||
3139 | 3151 | ||
3140 | int polaris10_hwmgr_backend_init(struct pp_hwmgr *hwmgr) | 3152 | static int polaris10_hwmgr_backend_init(struct pp_hwmgr *hwmgr) |
3141 | { | 3153 | { |
3142 | struct polaris10_hwmgr *data; | 3154 | struct polaris10_hwmgr *data; |
3143 | struct pp_atomctrl_gpio_pin_assignment gpio_pin_assignment; | 3155 | struct pp_atomctrl_gpio_pin_assignment gpio_pin_assignment; |
@@ -3880,7 +3892,7 @@ static int polaris10_get_pp_table_entry(struct pp_hwmgr *hwmgr, | |||
3880 | 3892 | ||
3881 | ps = (struct polaris10_power_state *)(&state->hardware); | 3893 | ps = (struct polaris10_power_state *)(&state->hardware); |
3882 | 3894 | ||
3883 | result = tonga_get_powerplay_table_entry(hwmgr, entry_index, state, | 3895 | result = get_powerplay_table_entry_v1_0(hwmgr, entry_index, state, |
3884 | polaris10_get_pp_table_entry_callback_func); | 3896 | polaris10_get_pp_table_entry_callback_func); |
3885 | 3897 | ||
3886 | /* This is the earliest time we have all the dependency table and the VBIOS boot state | 3898 | /* This is the earliest time we have all the dependency table and the VBIOS boot state |
@@ -4347,7 +4359,8 @@ static int polaris10_generate_dpm_level_enable_mask( | |||
4347 | return 0; | 4359 | return 0; |
4348 | } | 4360 | } |
4349 | 4361 | ||
4350 | int polaris10_enable_disable_uvd_dpm(struct pp_hwmgr *hwmgr, bool enable) | 4362 | static int |
4363 | polaris10_enable_disable_uvd_dpm(struct pp_hwmgr *hwmgr, bool enable) | ||
4351 | { | 4364 | { |
4352 | return smum_send_msg_to_smc(hwmgr->smumgr, enable ? | 4365 | return smum_send_msg_to_smc(hwmgr->smumgr, enable ? |
4353 | PPSMC_MSG_UVDDPM_Enable : | 4366 | PPSMC_MSG_UVDDPM_Enable : |
@@ -4361,7 +4374,8 @@ int polaris10_enable_disable_vce_dpm(struct pp_hwmgr *hwmgr, bool enable) | |||
4361 | PPSMC_MSG_VCEDPM_Disable); | 4374 | PPSMC_MSG_VCEDPM_Disable); |
4362 | } | 4375 | } |
4363 | 4376 | ||
4364 | int polaris10_enable_disable_samu_dpm(struct pp_hwmgr *hwmgr, bool enable) | 4377 | static int |
4378 | polaris10_enable_disable_samu_dpm(struct pp_hwmgr *hwmgr, bool enable) | ||
4365 | { | 4379 | { |
4366 | return smum_send_msg_to_smc(hwmgr->smumgr, enable? | 4380 | return smum_send_msg_to_smc(hwmgr->smumgr, enable? |
4367 | PPSMC_MSG_SAMUDPM_Enable : | 4381 | PPSMC_MSG_SAMUDPM_Enable : |
@@ -4675,14 +4689,16 @@ static int polaris10_set_max_fan_pwm_output(struct pp_hwmgr *hwmgr, uint16_t us_ | |||
4675 | } | 4689 | } |
4676 | 4690 | ||
4677 | 4691 | ||
4678 | int polaris10_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display) | 4692 | static int |
4693 | polaris10_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display) | ||
4679 | { | 4694 | { |
4680 | PPSMC_Msg msg = has_display ? (PPSMC_Msg)PPSMC_HasDisplay : (PPSMC_Msg)PPSMC_NoDisplay; | 4695 | PPSMC_Msg msg = has_display ? (PPSMC_Msg)PPSMC_HasDisplay : (PPSMC_Msg)PPSMC_NoDisplay; |
4681 | 4696 | ||
4682 | return (smum_send_msg_to_smc(hwmgr->smumgr, msg) == 0) ? 0 : -1; | 4697 | return (smum_send_msg_to_smc(hwmgr->smumgr, msg) == 0) ? 0 : -1; |
4683 | } | 4698 | } |
4684 | 4699 | ||
4685 | int polaris10_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr) | 4700 | static int |
4701 | polaris10_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr) | ||
4686 | { | 4702 | { |
4687 | uint32_t num_active_displays = 0; | 4703 | uint32_t num_active_displays = 0; |
4688 | struct cgs_display_info info = {0}; | 4704 | struct cgs_display_info info = {0}; |
@@ -4705,7 +4721,7 @@ int polaris10_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwm | |||
4705 | * @param hwmgr the address of the powerplay hardware manager. | 4721 | * @param hwmgr the address of the powerplay hardware manager. |
4706 | * @return always OK | 4722 | * @return always OK |
4707 | */ | 4723 | */ |
4708 | int polaris10_program_display_gap(struct pp_hwmgr *hwmgr) | 4724 | static int polaris10_program_display_gap(struct pp_hwmgr *hwmgr) |
4709 | { | 4725 | { |
4710 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 4726 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
4711 | uint32_t num_active_displays = 0; | 4727 | uint32_t num_active_displays = 0; |
@@ -4750,7 +4766,7 @@ int polaris10_program_display_gap(struct pp_hwmgr *hwmgr) | |||
4750 | } | 4766 | } |
4751 | 4767 | ||
4752 | 4768 | ||
4753 | int polaris10_display_configuration_changed_task(struct pp_hwmgr *hwmgr) | 4769 | static int polaris10_display_configuration_changed_task(struct pp_hwmgr *hwmgr) |
4754 | { | 4770 | { |
4755 | return polaris10_program_display_gap(hwmgr); | 4771 | return polaris10_program_display_gap(hwmgr); |
4756 | } | 4772 | } |
@@ -4774,13 +4790,15 @@ static int polaris10_set_max_fan_rpm_output(struct pp_hwmgr *hwmgr, uint16_t us_ | |||
4774 | PPSMC_MSG_SetFanRpmMax, us_max_fan_rpm); | 4790 | PPSMC_MSG_SetFanRpmMax, us_max_fan_rpm); |
4775 | } | 4791 | } |
4776 | 4792 | ||
4777 | int polaris10_register_internal_thermal_interrupt(struct pp_hwmgr *hwmgr, | 4793 | static int |
4794 | polaris10_register_internal_thermal_interrupt(struct pp_hwmgr *hwmgr, | ||
4778 | const void *thermal_interrupt_info) | 4795 | const void *thermal_interrupt_info) |
4779 | { | 4796 | { |
4780 | return 0; | 4797 | return 0; |
4781 | } | 4798 | } |
4782 | 4799 | ||
4783 | bool polaris10_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hwmgr) | 4800 | static bool polaris10_check_smc_update_required_for_display_configuration( |
4801 | struct pp_hwmgr *hwmgr) | ||
4784 | { | 4802 | { |
4785 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 4803 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
4786 | bool is_update_required = false; | 4804 | bool is_update_required = false; |
@@ -4810,7 +4828,9 @@ static inline bool polaris10_are_power_levels_equal(const struct polaris10_perfo | |||
4810 | (pl1->pcie_lane == pl2->pcie_lane)); | 4828 | (pl1->pcie_lane == pl2->pcie_lane)); |
4811 | } | 4829 | } |
4812 | 4830 | ||
4813 | int polaris10_check_states_equal(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *pstate1, const struct pp_hw_power_state *pstate2, bool *equal) | 4831 | static int polaris10_check_states_equal(struct pp_hwmgr *hwmgr, |
4832 | const struct pp_hw_power_state *pstate1, | ||
4833 | const struct pp_hw_power_state *pstate2, bool *equal) | ||
4814 | { | 4834 | { |
4815 | const struct polaris10_power_state *psa = cast_const_phw_polaris10_power_state(pstate1); | 4835 | const struct polaris10_power_state *psa = cast_const_phw_polaris10_power_state(pstate1); |
4816 | const struct polaris10_power_state *psb = cast_const_phw_polaris10_power_state(pstate2); | 4836 | const struct polaris10_power_state *psb = cast_const_phw_polaris10_power_state(pstate2); |
@@ -4841,7 +4861,7 @@ int polaris10_check_states_equal(struct pp_hwmgr *hwmgr, const struct pp_hw_powe | |||
4841 | return 0; | 4861 | return 0; |
4842 | } | 4862 | } |
4843 | 4863 | ||
4844 | int polaris10_upload_mc_firmware(struct pp_hwmgr *hwmgr) | 4864 | static int polaris10_upload_mc_firmware(struct pp_hwmgr *hwmgr) |
4845 | { | 4865 | { |
4846 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 4866 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
4847 | 4867 | ||
@@ -4954,7 +4974,7 @@ static int polaris10_init_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
4954 | return 0; | 4974 | return 0; |
4955 | } | 4975 | } |
4956 | 4976 | ||
4957 | int polaris10_setup_asic_task(struct pp_hwmgr *hwmgr) | 4977 | static int polaris10_setup_asic_task(struct pp_hwmgr *hwmgr) |
4958 | { | 4978 | { |
4959 | int tmp_result, result = 0; | 4979 | int tmp_result, result = 0; |
4960 | 4980 | ||
@@ -5225,7 +5245,7 @@ static const struct pp_hwmgr_func polaris10_hwmgr_funcs = { | |||
5225 | .get_sclk = polaris10_dpm_get_sclk, | 5245 | .get_sclk = polaris10_dpm_get_sclk, |
5226 | .patch_boot_state = polaris10_dpm_patch_boot_state, | 5246 | .patch_boot_state = polaris10_dpm_patch_boot_state, |
5227 | .get_pp_table_entry = polaris10_get_pp_table_entry, | 5247 | .get_pp_table_entry = polaris10_get_pp_table_entry, |
5228 | .get_num_of_pp_table_entries = tonga_get_number_of_powerplay_table_entries, | 5248 | .get_num_of_pp_table_entries = get_number_of_powerplay_table_entries_v1_0, |
5229 | .print_current_perforce_level = polaris10_print_current_perforce_level, | 5249 | .print_current_perforce_level = polaris10_print_current_perforce_level, |
5230 | .powerdown_uvd = polaris10_phm_powerdown_uvd, | 5250 | .powerdown_uvd = polaris10_phm_powerdown_uvd, |
5231 | .powergate_uvd = polaris10_phm_powergate_uvd, | 5251 | .powergate_uvd = polaris10_phm_powergate_uvd, |
@@ -5262,7 +5282,7 @@ static const struct pp_hwmgr_func polaris10_hwmgr_funcs = { | |||
5262 | int polaris10_hwmgr_init(struct pp_hwmgr *hwmgr) | 5282 | int polaris10_hwmgr_init(struct pp_hwmgr *hwmgr) |
5263 | { | 5283 | { |
5264 | hwmgr->hwmgr_func = &polaris10_hwmgr_funcs; | 5284 | hwmgr->hwmgr_func = &polaris10_hwmgr_funcs; |
5265 | hwmgr->pptable_func = &tonga_pptable_funcs; | 5285 | hwmgr->pptable_func = &pptable_v1_0_funcs; |
5266 | pp_polaris10_thermal_initialize(hwmgr); | 5286 | pp_polaris10_thermal_initialize(hwmgr); |
5267 | 5287 | ||
5268 | return 0; | 5288 | return 0; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h index 33c33947e827..378ab342c257 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "ppatomctrl.h" | 30 | #include "ppatomctrl.h" |
31 | #include "polaris10_ppsmc.h" | 31 | #include "polaris10_ppsmc.h" |
32 | #include "polaris10_powertune.h" | 32 | #include "polaris10_powertune.h" |
33 | #include "polaris10_smumgr.h" | ||
33 | 34 | ||
34 | #define POLARIS10_MAX_HARDWARE_POWERLEVELS 2 | 35 | #define POLARIS10_MAX_HARDWARE_POWERLEVELS 2 |
35 | 36 | ||
@@ -165,10 +166,6 @@ struct polaris10_pcie_perf_range { | |||
165 | uint16_t max; | 166 | uint16_t max; |
166 | uint16_t min; | 167 | uint16_t min; |
167 | }; | 168 | }; |
168 | struct polaris10_range_table { | ||
169 | uint32_t trans_lower_frequency; /* in 10khz */ | ||
170 | uint32_t trans_upper_frequency; | ||
171 | }; | ||
172 | 169 | ||
173 | struct polaris10_hwmgr { | 170 | struct polaris10_hwmgr { |
174 | struct polaris10_dpm_table dpm_table; | 171 | struct polaris10_dpm_table dpm_table; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_powertune.h b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_powertune.h index bc78e28f010d..329119d6cc71 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_powertune.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_powertune.h | |||
@@ -66,19 +66,6 @@ struct polaris10_pt_config_reg { | |||
66 | enum polaris10_pt_config_reg_type type; | 66 | enum polaris10_pt_config_reg_type type; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | struct polaris10_pt_defaults { | ||
70 | uint8_t SviLoadLineEn; | ||
71 | uint8_t SviLoadLineVddC; | ||
72 | uint8_t TDC_VDDC_ThrottleReleaseLimitPerc; | ||
73 | uint8_t TDC_MAWt; | ||
74 | uint8_t TdcWaterfallCtl; | ||
75 | uint8_t DTEAmbientTempBase; | ||
76 | |||
77 | uint32_t DisplayCac; | ||
78 | uint32_t BAPM_TEMP_GRADIENT; | ||
79 | uint16_t BAPMTI_R[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS]; | ||
80 | uint16_t BAPMTI_RC[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS]; | ||
81 | }; | ||
82 | 69 | ||
83 | void polaris10_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr); | 70 | void polaris10_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr); |
84 | int polaris10_populate_bapm_parameters_in_dpm_table(struct pp_hwmgr *hwmgr); | 71 | int polaris10_populate_bapm_parameters_in_dpm_table(struct pp_hwmgr *hwmgr); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_thermal.c index b206632d4650..41f835adba91 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_thermal.c | |||
@@ -152,7 +152,7 @@ int polaris10_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr) | |||
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
155 | int polaris10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr) | 155 | static int polaris10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr) |
156 | { | 156 | { |
157 | int result; | 157 | int result; |
158 | 158 | ||
@@ -425,7 +425,7 @@ int polaris10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr) | |||
425 | * @param Result the last failure code | 425 | * @param Result the last failure code |
426 | * @return result from set temperature range routine | 426 | * @return result from set temperature range routine |
427 | */ | 427 | */ |
428 | int tf_polaris10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | 428 | static int tf_polaris10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, |
429 | void *input, void *output, void *storage, int result) | 429 | void *input, void *output, void *storage, int result) |
430 | { | 430 | { |
431 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); | 431 | struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); |
@@ -537,7 +537,7 @@ int tf_polaris10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | |||
537 | * @param Result the last failure code | 537 | * @param Result the last failure code |
538 | * @return result from set temperature range routine | 538 | * @return result from set temperature range routine |
539 | */ | 539 | */ |
540 | int tf_polaris10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, | 540 | static int tf_polaris10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, |
541 | void *input, void *output, void *storage, int result) | 541 | void *input, void *output, void *storage, int result) |
542 | { | 542 | { |
543 | /* If the fantable setup has failed we could have disabled | 543 | /* If the fantable setup has failed we could have disabled |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_pptable.h b/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h index f127198aafc4..1e870f58dd12 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_pptable.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pptable_v1_0.h | |||
@@ -164,7 +164,7 @@ typedef struct _ATOM_Tonga_State { | |||
164 | typedef struct _ATOM_Tonga_State_Array { | 164 | typedef struct _ATOM_Tonga_State_Array { |
165 | UCHAR ucRevId; | 165 | UCHAR ucRevId; |
166 | UCHAR ucNumEntries; /* Number of entries. */ | 166 | UCHAR ucNumEntries; /* Number of entries. */ |
167 | ATOM_Tonga_State states[1]; /* Dynamically allocate entries. */ | 167 | ATOM_Tonga_State entries[1]; /* Dynamically allocate entries. */ |
168 | } ATOM_Tonga_State_Array; | 168 | } ATOM_Tonga_State_Array; |
169 | 169 | ||
170 | typedef struct _ATOM_Tonga_MCLK_Dependency_Record { | 170 | typedef struct _ATOM_Tonga_MCLK_Dependency_Record { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c index a0ffd4a73d8c..7de701d8a450 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c | |||
@@ -23,13 +23,13 @@ | |||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | 25 | ||
26 | #include "tonga_processpptables.h" | 26 | #include "process_pptables_v1_0.h" |
27 | #include "ppatomctrl.h" | 27 | #include "ppatomctrl.h" |
28 | #include "atombios.h" | 28 | #include "atombios.h" |
29 | #include "pp_debug.h" | 29 | #include "pp_debug.h" |
30 | #include "hwmgr.h" | 30 | #include "hwmgr.h" |
31 | #include "cgs_common.h" | 31 | #include "cgs_common.h" |
32 | #include "tonga_pptable.h" | 32 | #include "pptable_v1_0.h" |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Private Function used during initialization. | 35 | * Private Function used during initialization. |
@@ -153,12 +153,14 @@ const void *get_powerplay_table(struct pp_hwmgr *hwmgr) | |||
153 | static int get_vddc_lookup_table( | 153 | static int get_vddc_lookup_table( |
154 | struct pp_hwmgr *hwmgr, | 154 | struct pp_hwmgr *hwmgr, |
155 | phm_ppt_v1_voltage_lookup_table **lookup_table, | 155 | phm_ppt_v1_voltage_lookup_table **lookup_table, |
156 | const ATOM_Tonga_Voltage_Lookup_Table *vddc_lookup_pp_tables, | 156 | const ATOM_Tonga_Voltage_Lookup_Table *vddc_lookup_pp_tables, |
157 | uint32_t max_levels | 157 | uint32_t max_levels |
158 | ) | 158 | ) |
159 | { | 159 | { |
160 | uint32_t table_size, i; | 160 | uint32_t table_size, i; |
161 | phm_ppt_v1_voltage_lookup_table *table; | 161 | phm_ppt_v1_voltage_lookup_table *table; |
162 | phm_ppt_v1_voltage_lookup_record *record; | ||
163 | ATOM_Tonga_Voltage_Lookup_Record *atom_record; | ||
162 | 164 | ||
163 | PP_ASSERT_WITH_CODE((0 != vddc_lookup_pp_tables->ucNumEntries), | 165 | PP_ASSERT_WITH_CODE((0 != vddc_lookup_pp_tables->ucNumEntries), |
164 | "Invalid CAC Leakage PowerPlay Table!", return 1); | 166 | "Invalid CAC Leakage PowerPlay Table!", return 1); |
@@ -176,15 +178,17 @@ static int get_vddc_lookup_table( | |||
176 | table->count = vddc_lookup_pp_tables->ucNumEntries; | 178 | table->count = vddc_lookup_pp_tables->ucNumEntries; |
177 | 179 | ||
178 | for (i = 0; i < vddc_lookup_pp_tables->ucNumEntries; i++) { | 180 | for (i = 0; i < vddc_lookup_pp_tables->ucNumEntries; i++) { |
179 | table->entries[i].us_calculated = 0; | 181 | record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
180 | table->entries[i].us_vdd = | 182 | phm_ppt_v1_voltage_lookup_record, |
181 | vddc_lookup_pp_tables->entries[i].usVdd; | 183 | entries, table, i); |
182 | table->entries[i].us_cac_low = | 184 | atom_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
183 | vddc_lookup_pp_tables->entries[i].usCACLow; | 185 | ATOM_Tonga_Voltage_Lookup_Record, |
184 | table->entries[i].us_cac_mid = | 186 | entries, vddc_lookup_pp_tables, i); |
185 | vddc_lookup_pp_tables->entries[i].usCACMid; | 187 | record->us_calculated = 0; |
186 | table->entries[i].us_cac_high = | 188 | record->us_vdd = atom_record->usVdd; |
187 | vddc_lookup_pp_tables->entries[i].usCACHigh; | 189 | record->us_cac_low = atom_record->usCACLow; |
190 | record->us_cac_mid = atom_record->usCACMid; | ||
191 | record->us_cac_high = atom_record->usCACHigh; | ||
188 | } | 192 | } |
189 | 193 | ||
190 | *lookup_table = table; | 194 | *lookup_table = table; |
@@ -313,11 +317,12 @@ static int init_dpm_2_parameters( | |||
313 | static int get_valid_clk( | 317 | static int get_valid_clk( |
314 | struct pp_hwmgr *hwmgr, | 318 | struct pp_hwmgr *hwmgr, |
315 | struct phm_clock_array **clk_table, | 319 | struct phm_clock_array **clk_table, |
316 | const phm_ppt_v1_clock_voltage_dependency_table * clk_volt_pp_table | 320 | phm_ppt_v1_clock_voltage_dependency_table const *clk_volt_pp_table |
317 | ) | 321 | ) |
318 | { | 322 | { |
319 | uint32_t table_size, i; | 323 | uint32_t table_size, i; |
320 | struct phm_clock_array *table; | 324 | struct phm_clock_array *table; |
325 | phm_ppt_v1_clock_voltage_dependency_record *dep_record; | ||
321 | 326 | ||
322 | PP_ASSERT_WITH_CODE((0 != clk_volt_pp_table->count), | 327 | PP_ASSERT_WITH_CODE((0 != clk_volt_pp_table->count), |
323 | "Invalid PowerPlay Table!", return -1); | 328 | "Invalid PowerPlay Table!", return -1); |
@@ -334,9 +339,12 @@ static int get_valid_clk( | |||
334 | 339 | ||
335 | table->count = (uint32_t)clk_volt_pp_table->count; | 340 | table->count = (uint32_t)clk_volt_pp_table->count; |
336 | 341 | ||
337 | for (i = 0; i < table->count; i++) | 342 | for (i = 0; i < table->count; i++) { |
338 | table->values[i] = (uint32_t)clk_volt_pp_table->entries[i].clk; | 343 | dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
339 | 344 | phm_ppt_v1_clock_voltage_dependency_record, | |
345 | entries, clk_volt_pp_table, i); | ||
346 | table->values[i] = (uint32_t)dep_record->clk; | ||
347 | } | ||
340 | *clk_table = table; | 348 | *clk_table = table; |
341 | 349 | ||
342 | return 0; | 350 | return 0; |
@@ -345,7 +353,7 @@ static int get_valid_clk( | |||
345 | static int get_hard_limits( | 353 | static int get_hard_limits( |
346 | struct pp_hwmgr *hwmgr, | 354 | struct pp_hwmgr *hwmgr, |
347 | struct phm_clock_and_voltage_limits *limits, | 355 | struct phm_clock_and_voltage_limits *limits, |
348 | const ATOM_Tonga_Hard_Limit_Table * limitable | 356 | ATOM_Tonga_Hard_Limit_Table const *limitable |
349 | ) | 357 | ) |
350 | { | 358 | { |
351 | PP_ASSERT_WITH_CODE((0 != limitable->ucNumEntries), "Invalid PowerPlay Table!", return -1); | 359 | PP_ASSERT_WITH_CODE((0 != limitable->ucNumEntries), "Invalid PowerPlay Table!", return -1); |
@@ -363,11 +371,13 @@ static int get_hard_limits( | |||
363 | static int get_mclk_voltage_dependency_table( | 371 | static int get_mclk_voltage_dependency_table( |
364 | struct pp_hwmgr *hwmgr, | 372 | struct pp_hwmgr *hwmgr, |
365 | phm_ppt_v1_clock_voltage_dependency_table **pp_tonga_mclk_dep_table, | 373 | phm_ppt_v1_clock_voltage_dependency_table **pp_tonga_mclk_dep_table, |
366 | const ATOM_Tonga_MCLK_Dependency_Table * mclk_dep_table | 374 | ATOM_Tonga_MCLK_Dependency_Table const *mclk_dep_table |
367 | ) | 375 | ) |
368 | { | 376 | { |
369 | uint32_t table_size, i; | 377 | uint32_t table_size, i; |
370 | phm_ppt_v1_clock_voltage_dependency_table *mclk_table; | 378 | phm_ppt_v1_clock_voltage_dependency_table *mclk_table; |
379 | phm_ppt_v1_clock_voltage_dependency_record *mclk_table_record; | ||
380 | ATOM_Tonga_MCLK_Dependency_Record *mclk_dep_record; | ||
371 | 381 | ||
372 | PP_ASSERT_WITH_CODE((0 != mclk_dep_table->ucNumEntries), | 382 | PP_ASSERT_WITH_CODE((0 != mclk_dep_table->ucNumEntries), |
373 | "Invalid PowerPlay Table!", return -1); | 383 | "Invalid PowerPlay Table!", return -1); |
@@ -385,16 +395,17 @@ static int get_mclk_voltage_dependency_table( | |||
385 | mclk_table->count = (uint32_t)mclk_dep_table->ucNumEntries; | 395 | mclk_table->count = (uint32_t)mclk_dep_table->ucNumEntries; |
386 | 396 | ||
387 | for (i = 0; i < mclk_dep_table->ucNumEntries; i++) { | 397 | for (i = 0; i < mclk_dep_table->ucNumEntries; i++) { |
388 | mclk_table->entries[i].vddInd = | 398 | mclk_table_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
389 | mclk_dep_table->entries[i].ucVddcInd; | 399 | phm_ppt_v1_clock_voltage_dependency_record, |
390 | mclk_table->entries[i].vdd_offset = | 400 | entries, mclk_table, i); |
391 | mclk_dep_table->entries[i].usVddgfxOffset; | 401 | mclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
392 | mclk_table->entries[i].vddci = | 402 | ATOM_Tonga_MCLK_Dependency_Record, |
393 | mclk_dep_table->entries[i].usVddci; | 403 | entries, mclk_dep_table, i); |
394 | mclk_table->entries[i].mvdd = | 404 | mclk_table_record->vddInd = mclk_dep_record->ucVddcInd; |
395 | mclk_dep_table->entries[i].usMvdd; | 405 | mclk_table_record->vdd_offset = mclk_dep_record->usVddgfxOffset; |
396 | mclk_table->entries[i].clk = | 406 | mclk_table_record->vddci = mclk_dep_record->usVddci; |
397 | mclk_dep_table->entries[i].ulMclk; | 407 | mclk_table_record->mvdd = mclk_dep_record->usMvdd; |
408 | mclk_table_record->clk = mclk_dep_record->ulMclk; | ||
398 | } | 409 | } |
399 | 410 | ||
400 | *pp_tonga_mclk_dep_table = mclk_table; | 411 | *pp_tonga_mclk_dep_table = mclk_table; |
@@ -405,15 +416,17 @@ static int get_mclk_voltage_dependency_table( | |||
405 | static int get_sclk_voltage_dependency_table( | 416 | static int get_sclk_voltage_dependency_table( |
406 | struct pp_hwmgr *hwmgr, | 417 | struct pp_hwmgr *hwmgr, |
407 | phm_ppt_v1_clock_voltage_dependency_table **pp_tonga_sclk_dep_table, | 418 | phm_ppt_v1_clock_voltage_dependency_table **pp_tonga_sclk_dep_table, |
408 | const PPTable_Generic_SubTable_Header *sclk_dep_table | 419 | PPTable_Generic_SubTable_Header const *sclk_dep_table |
409 | ) | 420 | ) |
410 | { | 421 | { |
411 | uint32_t table_size, i; | 422 | uint32_t table_size, i; |
412 | phm_ppt_v1_clock_voltage_dependency_table *sclk_table; | 423 | phm_ppt_v1_clock_voltage_dependency_table *sclk_table; |
424 | phm_ppt_v1_clock_voltage_dependency_record *sclk_table_record; | ||
413 | 425 | ||
414 | if (sclk_dep_table->ucRevId < 1) { | 426 | if (sclk_dep_table->ucRevId < 1) { |
415 | const ATOM_Tonga_SCLK_Dependency_Table *tonga_table = | 427 | const ATOM_Tonga_SCLK_Dependency_Table *tonga_table = |
416 | (ATOM_Tonga_SCLK_Dependency_Table *)sclk_dep_table; | 428 | (ATOM_Tonga_SCLK_Dependency_Table *)sclk_dep_table; |
429 | ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record; | ||
417 | 430 | ||
418 | PP_ASSERT_WITH_CODE((0 != tonga_table->ucNumEntries), | 431 | PP_ASSERT_WITH_CODE((0 != tonga_table->ucNumEntries), |
419 | "Invalid PowerPlay Table!", return -1); | 432 | "Invalid PowerPlay Table!", return -1); |
@@ -431,20 +444,23 @@ static int get_sclk_voltage_dependency_table( | |||
431 | sclk_table->count = (uint32_t)tonga_table->ucNumEntries; | 444 | sclk_table->count = (uint32_t)tonga_table->ucNumEntries; |
432 | 445 | ||
433 | for (i = 0; i < tonga_table->ucNumEntries; i++) { | 446 | for (i = 0; i < tonga_table->ucNumEntries; i++) { |
434 | sclk_table->entries[i].vddInd = | 447 | sclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
435 | tonga_table->entries[i].ucVddInd; | 448 | ATOM_Tonga_SCLK_Dependency_Record, |
436 | sclk_table->entries[i].vdd_offset = | 449 | entries, tonga_table, i); |
437 | tonga_table->entries[i].usVddcOffset; | 450 | sclk_table_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
438 | sclk_table->entries[i].clk = | 451 | phm_ppt_v1_clock_voltage_dependency_record, |
439 | tonga_table->entries[i].ulSclk; | 452 | entries, sclk_table, i); |
440 | sclk_table->entries[i].cks_enable = | 453 | sclk_table_record->vddInd = sclk_dep_record->ucVddInd; |
441 | (((tonga_table->entries[i].ucCKSVOffsetandDisable & 0x80) >> 7) == 0) ? 1 : 0; | 454 | sclk_table_record->vdd_offset = sclk_dep_record->usVddcOffset; |
442 | sclk_table->entries[i].cks_voffset = | 455 | sclk_table_record->clk = sclk_dep_record->ulSclk; |
443 | (tonga_table->entries[i].ucCKSVOffsetandDisable & 0x7F); | 456 | sclk_table_record->cks_enable = |
457 | (((sclk_dep_record->ucCKSVOffsetandDisable & 0x80) >> 7) == 0) ? 1 : 0; | ||
458 | sclk_table_record->cks_voffset = (sclk_dep_record->ucCKSVOffsetandDisable & 0x7F); | ||
444 | } | 459 | } |
445 | } else { | 460 | } else { |
446 | const ATOM_Polaris_SCLK_Dependency_Table *polaris_table = | 461 | const ATOM_Polaris_SCLK_Dependency_Table *polaris_table = |
447 | (ATOM_Polaris_SCLK_Dependency_Table *)sclk_dep_table; | 462 | (ATOM_Polaris_SCLK_Dependency_Table *)sclk_dep_table; |
463 | ATOM_Polaris_SCLK_Dependency_Record *sclk_dep_record; | ||
448 | 464 | ||
449 | PP_ASSERT_WITH_CODE((0 != polaris_table->ucNumEntries), | 465 | PP_ASSERT_WITH_CODE((0 != polaris_table->ucNumEntries), |
450 | "Invalid PowerPlay Table!", return -1); | 466 | "Invalid PowerPlay Table!", return -1); |
@@ -462,17 +478,19 @@ static int get_sclk_voltage_dependency_table( | |||
462 | sclk_table->count = (uint32_t)polaris_table->ucNumEntries; | 478 | sclk_table->count = (uint32_t)polaris_table->ucNumEntries; |
463 | 479 | ||
464 | for (i = 0; i < polaris_table->ucNumEntries; i++) { | 480 | for (i = 0; i < polaris_table->ucNumEntries; i++) { |
465 | sclk_table->entries[i].vddInd = | 481 | sclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
466 | polaris_table->entries[i].ucVddInd; | 482 | ATOM_Polaris_SCLK_Dependency_Record, |
467 | sclk_table->entries[i].vdd_offset = | 483 | entries, polaris_table, i); |
468 | polaris_table->entries[i].usVddcOffset; | 484 | sclk_table_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
469 | sclk_table->entries[i].clk = | 485 | phm_ppt_v1_clock_voltage_dependency_record, |
470 | polaris_table->entries[i].ulSclk; | 486 | entries, sclk_table, i); |
471 | sclk_table->entries[i].cks_enable = | 487 | sclk_table_record->vddInd = sclk_dep_record->ucVddInd; |
472 | (((polaris_table->entries[i].ucCKSVOffsetandDisable & 0x80) >> 7) == 0) ? 1 : 0; | 488 | sclk_table_record->vdd_offset = sclk_dep_record->usVddcOffset; |
473 | sclk_table->entries[i].cks_voffset = | 489 | sclk_table_record->clk = sclk_dep_record->ulSclk; |
474 | (polaris_table->entries[i].ucCKSVOffsetandDisable & 0x7F); | 490 | sclk_table_record->cks_enable = |
475 | sclk_table->entries[i].sclk_offset = polaris_table->entries[i].ulSclkOffset; | 491 | (((sclk_dep_record->ucCKSVOffsetandDisable & 0x80) >> 7) == 0) ? 1 : 0; |
492 | sclk_table_record->cks_voffset = (sclk_dep_record->ucCKSVOffsetandDisable & 0x7F); | ||
493 | sclk_table_record->sclk_offset = sclk_dep_record->ulSclkOffset; | ||
476 | } | 494 | } |
477 | } | 495 | } |
478 | *pp_tonga_sclk_dep_table = sclk_table; | 496 | *pp_tonga_sclk_dep_table = sclk_table; |
@@ -483,16 +501,19 @@ static int get_sclk_voltage_dependency_table( | |||
483 | static int get_pcie_table( | 501 | static int get_pcie_table( |
484 | struct pp_hwmgr *hwmgr, | 502 | struct pp_hwmgr *hwmgr, |
485 | phm_ppt_v1_pcie_table **pp_tonga_pcie_table, | 503 | phm_ppt_v1_pcie_table **pp_tonga_pcie_table, |
486 | const PPTable_Generic_SubTable_Header * pTable | 504 | PPTable_Generic_SubTable_Header const *ptable |
487 | ) | 505 | ) |
488 | { | 506 | { |
489 | uint32_t table_size, i, pcie_count; | 507 | uint32_t table_size, i, pcie_count; |
490 | phm_ppt_v1_pcie_table *pcie_table; | 508 | phm_ppt_v1_pcie_table *pcie_table; |
491 | struct phm_ppt_v1_information *pp_table_information = | 509 | struct phm_ppt_v1_information *pp_table_information = |
492 | (struct phm_ppt_v1_information *)(hwmgr->pptable); | 510 | (struct phm_ppt_v1_information *)(hwmgr->pptable); |
511 | phm_ppt_v1_pcie_record *pcie_record; | ||
512 | |||
513 | if (ptable->ucRevId < 1) { | ||
514 | const ATOM_Tonga_PCIE_Table *atom_pcie_table = (ATOM_Tonga_PCIE_Table *)ptable; | ||
515 | ATOM_Tonga_PCIE_Record *atom_pcie_record; | ||
493 | 516 | ||
494 | if (pTable->ucRevId < 1) { | ||
495 | const ATOM_Tonga_PCIE_Table *atom_pcie_table = (ATOM_Tonga_PCIE_Table *)pTable; | ||
496 | PP_ASSERT_WITH_CODE((atom_pcie_table->ucNumEntries != 0), | 517 | PP_ASSERT_WITH_CODE((atom_pcie_table->ucNumEntries != 0), |
497 | "Invalid PowerPlay Table!", return -1); | 518 | "Invalid PowerPlay Table!", return -1); |
498 | 519 | ||
@@ -518,18 +539,23 @@ static int get_pcie_table( | |||
518 | Disregarding the excess entries... \n"); | 539 | Disregarding the excess entries... \n"); |
519 | 540 | ||
520 | pcie_table->count = pcie_count; | 541 | pcie_table->count = pcie_count; |
521 | |||
522 | for (i = 0; i < pcie_count; i++) { | 542 | for (i = 0; i < pcie_count; i++) { |
523 | pcie_table->entries[i].gen_speed = | 543 | pcie_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
524 | atom_pcie_table->entries[i].ucPCIEGenSpeed; | 544 | phm_ppt_v1_pcie_record, |
525 | pcie_table->entries[i].lane_width = | 545 | entries, pcie_table, i); |
526 | atom_pcie_table->entries[i].usPCIELaneWidth; | 546 | atom_pcie_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
547 | ATOM_Tonga_PCIE_Record, | ||
548 | entries, atom_pcie_table, i); | ||
549 | pcie_record->gen_speed = atom_pcie_record->ucPCIEGenSpeed; | ||
550 | pcie_record->lane_width = atom_pcie_record->usPCIELaneWidth; | ||
527 | } | 551 | } |
528 | 552 | ||
529 | *pp_tonga_pcie_table = pcie_table; | 553 | *pp_tonga_pcie_table = pcie_table; |
530 | } else { | 554 | } else { |
531 | /* Polaris10/Polaris11 and newer. */ | 555 | /* Polaris10/Polaris11 and newer. */ |
532 | const ATOM_Polaris10_PCIE_Table *atom_pcie_table = (ATOM_Polaris10_PCIE_Table *)pTable; | 556 | const ATOM_Polaris10_PCIE_Table *atom_pcie_table = (ATOM_Polaris10_PCIE_Table *)ptable; |
557 | ATOM_Polaris10_PCIE_Record *atom_pcie_record; | ||
558 | |||
533 | PP_ASSERT_WITH_CODE((atom_pcie_table->ucNumEntries != 0), | 559 | PP_ASSERT_WITH_CODE((atom_pcie_table->ucNumEntries != 0), |
534 | "Invalid PowerPlay Table!", return -1); | 560 | "Invalid PowerPlay Table!", return -1); |
535 | 561 | ||
@@ -557,12 +583,15 @@ static int get_pcie_table( | |||
557 | pcie_table->count = pcie_count; | 583 | pcie_table->count = pcie_count; |
558 | 584 | ||
559 | for (i = 0; i < pcie_count; i++) { | 585 | for (i = 0; i < pcie_count; i++) { |
560 | pcie_table->entries[i].gen_speed = | 586 | pcie_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
561 | atom_pcie_table->entries[i].ucPCIEGenSpeed; | 587 | phm_ppt_v1_pcie_record, |
562 | pcie_table->entries[i].lane_width = | 588 | entries, pcie_table, i); |
563 | atom_pcie_table->entries[i].usPCIELaneWidth; | 589 | atom_pcie_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
564 | pcie_table->entries[i].pcie_sclk = | 590 | ATOM_Polaris10_PCIE_Record, |
565 | atom_pcie_table->entries[i].ulPCIE_Sclk; | 591 | entries, atom_pcie_table, i); |
592 | pcie_record->gen_speed = atom_pcie_record->ucPCIEGenSpeed; | ||
593 | pcie_record->lane_width = atom_pcie_record->usPCIELaneWidth; | ||
594 | pcie_record->pcie_sclk = atom_pcie_record->ulPCIE_Sclk; | ||
566 | } | 595 | } |
567 | 596 | ||
568 | *pp_tonga_pcie_table = pcie_table; | 597 | *pp_tonga_pcie_table = pcie_table; |
@@ -684,6 +713,7 @@ static int get_mm_clock_voltage_table( | |||
684 | uint32_t table_size, i; | 713 | uint32_t table_size, i; |
685 | const ATOM_Tonga_MM_Dependency_Record *mm_dependency_record; | 714 | const ATOM_Tonga_MM_Dependency_Record *mm_dependency_record; |
686 | phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table; | 715 | phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table; |
716 | phm_ppt_v1_mm_clock_voltage_dependency_record *mm_table_record; | ||
687 | 717 | ||
688 | PP_ASSERT_WITH_CODE((0 != mm_dependency_table->ucNumEntries), | 718 | PP_ASSERT_WITH_CODE((0 != mm_dependency_table->ucNumEntries), |
689 | "Invalid PowerPlay Table!", return -1); | 719 | "Invalid PowerPlay Table!", return -1); |
@@ -700,14 +730,19 @@ static int get_mm_clock_voltage_table( | |||
700 | mm_table->count = mm_dependency_table->ucNumEntries; | 730 | mm_table->count = mm_dependency_table->ucNumEntries; |
701 | 731 | ||
702 | for (i = 0; i < mm_dependency_table->ucNumEntries; i++) { | 732 | for (i = 0; i < mm_dependency_table->ucNumEntries; i++) { |
703 | mm_dependency_record = &mm_dependency_table->entries[i]; | 733 | mm_dependency_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
704 | mm_table->entries[i].vddcInd = mm_dependency_record->ucVddcInd; | 734 | ATOM_Tonga_MM_Dependency_Record, |
705 | mm_table->entries[i].vddgfx_offset = mm_dependency_record->usVddgfxOffset; | 735 | entries, mm_dependency_table, i); |
706 | mm_table->entries[i].aclk = mm_dependency_record->ulAClk; | 736 | mm_table_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
707 | mm_table->entries[i].samclock = mm_dependency_record->ulSAMUClk; | 737 | phm_ppt_v1_mm_clock_voltage_dependency_record, |
708 | mm_table->entries[i].eclk = mm_dependency_record->ulEClk; | 738 | entries, mm_table, i); |
709 | mm_table->entries[i].vclk = mm_dependency_record->ulVClk; | 739 | mm_table_record->vddcInd = mm_dependency_record->ucVddcInd; |
710 | mm_table->entries[i].dclk = mm_dependency_record->ulDClk; | 740 | mm_table_record->vddgfx_offset = mm_dependency_record->usVddgfxOffset; |
741 | mm_table_record->aclk = mm_dependency_record->ulAClk; | ||
742 | mm_table_record->samclock = mm_dependency_record->ulSAMUClk; | ||
743 | mm_table_record->eclk = mm_dependency_record->ulEClk; | ||
744 | mm_table_record->vclk = mm_dependency_record->ulVClk; | ||
745 | mm_table_record->dclk = mm_dependency_record->ulDClk; | ||
711 | } | 746 | } |
712 | 747 | ||
713 | *tonga_mm_table = mm_table; | 748 | *tonga_mm_table = mm_table; |
@@ -1014,7 +1049,7 @@ static int check_powerplay_tables( | |||
1014 | return 0; | 1049 | return 0; |
1015 | } | 1050 | } |
1016 | 1051 | ||
1017 | int tonga_pp_tables_initialize(struct pp_hwmgr *hwmgr) | 1052 | int pp_tables_v1_0_initialize(struct pp_hwmgr *hwmgr) |
1018 | { | 1053 | { |
1019 | int result = 0; | 1054 | int result = 0; |
1020 | const ATOM_Tonga_POWERPLAYTABLE *powerplay_table; | 1055 | const ATOM_Tonga_POWERPLAYTABLE *powerplay_table; |
@@ -1065,7 +1100,7 @@ int tonga_pp_tables_initialize(struct pp_hwmgr *hwmgr) | |||
1065 | return result; | 1100 | return result; |
1066 | } | 1101 | } |
1067 | 1102 | ||
1068 | int tonga_pp_tables_uninitialize(struct pp_hwmgr *hwmgr) | 1103 | int pp_tables_v1_0_uninitialize(struct pp_hwmgr *hwmgr) |
1069 | { | 1104 | { |
1070 | struct phm_ppt_v1_information *pp_table_information = | 1105 | struct phm_ppt_v1_information *pp_table_information = |
1071 | (struct phm_ppt_v1_information *)(hwmgr->pptable); | 1106 | (struct phm_ppt_v1_information *)(hwmgr->pptable); |
@@ -1109,14 +1144,14 @@ int tonga_pp_tables_uninitialize(struct pp_hwmgr *hwmgr) | |||
1109 | return 0; | 1144 | return 0; |
1110 | } | 1145 | } |
1111 | 1146 | ||
1112 | const struct pp_table_func tonga_pptable_funcs = { | 1147 | const struct pp_table_func pptable_v1_0_funcs = { |
1113 | .pptable_init = tonga_pp_tables_initialize, | 1148 | .pptable_init = pp_tables_v1_0_initialize, |
1114 | .pptable_fini = tonga_pp_tables_uninitialize, | 1149 | .pptable_fini = pp_tables_v1_0_uninitialize, |
1115 | }; | 1150 | }; |
1116 | 1151 | ||
1117 | int tonga_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr) | 1152 | int get_number_of_powerplay_table_entries_v1_0(struct pp_hwmgr *hwmgr) |
1118 | { | 1153 | { |
1119 | const ATOM_Tonga_State_Array * state_arrays; | 1154 | ATOM_Tonga_State_Array const *state_arrays; |
1120 | const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr); | 1155 | const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr); |
1121 | 1156 | ||
1122 | PP_ASSERT_WITH_CODE((NULL != pp_table), | 1157 | PP_ASSERT_WITH_CODE((NULL != pp_table), |
@@ -1163,6 +1198,71 @@ static uint32_t make_classification_flags(struct pp_hwmgr *hwmgr, | |||
1163 | return result; | 1198 | return result; |
1164 | } | 1199 | } |
1165 | 1200 | ||
1201 | static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr) | ||
1202 | { | ||
1203 | const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr); | ||
1204 | const ATOM_Tonga_VCE_State_Table *vce_state_table = | ||
1205 | (ATOM_Tonga_VCE_State_Table *)(((unsigned long)pp_table) + le16_to_cpu(pp_table->usVCEStateTableOffset)); | ||
1206 | |||
1207 | if (vce_state_table == NULL) | ||
1208 | return 0; | ||
1209 | |||
1210 | return vce_state_table->ucNumEntries; | ||
1211 | } | ||
1212 | |||
1213 | static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i, | ||
1214 | struct pp_vce_state *vce_state, void **clock_info, uint32_t *flag) | ||
1215 | { | ||
1216 | const ATOM_Tonga_VCE_State_Record *vce_state_record; | ||
1217 | ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record; | ||
1218 | ATOM_Tonga_MCLK_Dependency_Record *mclk_dep_record; | ||
1219 | ATOM_Tonga_MM_Dependency_Record *mm_dep_record; | ||
1220 | const ATOM_Tonga_POWERPLAYTABLE *pptable = get_powerplay_table(hwmgr); | ||
1221 | const ATOM_Tonga_VCE_State_Table *vce_state_table = (ATOM_Tonga_VCE_State_Table *)(((unsigned long)pptable) | ||
1222 | + le16_to_cpu(pptable->usVCEStateTableOffset)); | ||
1223 | const ATOM_Tonga_SCLK_Dependency_Table *sclk_dep_table = (ATOM_Tonga_SCLK_Dependency_Table *)(((unsigned long)pptable) | ||
1224 | + le16_to_cpu(pptable->usSclkDependencyTableOffset)); | ||
1225 | const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table = (ATOM_Tonga_MCLK_Dependency_Table *)(((unsigned long)pptable) | ||
1226 | + le16_to_cpu(pptable->usMclkDependencyTableOffset)); | ||
1227 | const ATOM_Tonga_MM_Dependency_Table *mm_dep_table = (ATOM_Tonga_MM_Dependency_Table *)(((unsigned long)pptable) | ||
1228 | + le16_to_cpu(pptable->usMMDependencyTableOffset)); | ||
1229 | |||
1230 | PP_ASSERT_WITH_CODE((i < vce_state_table->ucNumEntries), | ||
1231 | "Requested state entry ID is out of range!", | ||
1232 | return -EINVAL); | ||
1233 | |||
1234 | vce_state_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( | ||
1235 | ATOM_Tonga_VCE_State_Record, | ||
1236 | entries, vce_state_table, i); | ||
1237 | sclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( | ||
1238 | ATOM_Tonga_SCLK_Dependency_Record, | ||
1239 | entries, sclk_dep_table, | ||
1240 | vce_state_record->ucSCLKIndex); | ||
1241 | mm_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( | ||
1242 | ATOM_Tonga_MM_Dependency_Record, | ||
1243 | entries, mm_dep_table, | ||
1244 | vce_state_record->ucVCEClockIndex); | ||
1245 | *flag = vce_state_record->ucFlag; | ||
1246 | |||
1247 | vce_state->evclk = mm_dep_record->ulEClk; | ||
1248 | vce_state->ecclk = mm_dep_record->ulEClk; | ||
1249 | vce_state->sclk = sclk_dep_record->ulSclk; | ||
1250 | |||
1251 | if (vce_state_record->ucMCLKIndex >= mclk_dep_table->ucNumEntries) | ||
1252 | mclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( | ||
1253 | ATOM_Tonga_MCLK_Dependency_Record, | ||
1254 | entries, mclk_dep_table, | ||
1255 | mclk_dep_table->ucNumEntries - 1); | ||
1256 | else | ||
1257 | mclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( | ||
1258 | ATOM_Tonga_MCLK_Dependency_Record, | ||
1259 | entries, mclk_dep_table, | ||
1260 | vce_state_record->ucMCLKIndex); | ||
1261 | |||
1262 | vce_state->mclk = mclk_dep_record->ulMclk; | ||
1263 | return 0; | ||
1264 | } | ||
1265 | |||
1166 | /** | 1266 | /** |
1167 | * Create a Power State out of an entry in the PowerPlay table. | 1267 | * Create a Power State out of an entry in the PowerPlay table. |
1168 | * This function is called by the hardware back-end. | 1268 | * This function is called by the hardware back-end. |
@@ -1171,15 +1271,17 @@ static uint32_t make_classification_flags(struct pp_hwmgr *hwmgr, | |||
1171 | * @param power_state The address of the PowerState instance being created. | 1271 | * @param power_state The address of the PowerState instance being created. |
1172 | * @return -1 if the entry cannot be retrieved. | 1272 | * @return -1 if the entry cannot be retrieved. |
1173 | */ | 1273 | */ |
1174 | int tonga_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, | 1274 | int get_powerplay_table_entry_v1_0(struct pp_hwmgr *hwmgr, |
1175 | uint32_t entry_index, struct pp_power_state *power_state, | 1275 | uint32_t entry_index, struct pp_power_state *power_state, |
1176 | int (*call_back_func)(struct pp_hwmgr *, void *, | 1276 | int (*call_back_func)(struct pp_hwmgr *, void *, |
1177 | struct pp_power_state *, void *, uint32_t)) | 1277 | struct pp_power_state *, void *, uint32_t)) |
1178 | { | 1278 | { |
1179 | int result = 0; | 1279 | int result = 0; |
1180 | const ATOM_Tonga_State_Array * state_arrays; | 1280 | const ATOM_Tonga_State_Array *state_arrays; |
1181 | const ATOM_Tonga_State *state_entry; | 1281 | const ATOM_Tonga_State *state_entry; |
1182 | const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr); | 1282 | const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr); |
1283 | int i, j; | ||
1284 | uint32_t flags = 0; | ||
1183 | 1285 | ||
1184 | PP_ASSERT_WITH_CODE((NULL != pp_table), "Missing PowerPlay Table!", return -1;); | 1286 | PP_ASSERT_WITH_CODE((NULL != pp_table), "Missing PowerPlay Table!", return -1;); |
1185 | power_state->classification.bios_index = entry_index; | 1287 | power_state->classification.bios_index = entry_index; |
@@ -1196,7 +1298,9 @@ int tonga_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, | |||
1196 | PP_ASSERT_WITH_CODE((entry_index <= state_arrays->ucNumEntries), | 1298 | PP_ASSERT_WITH_CODE((entry_index <= state_arrays->ucNumEntries), |
1197 | "Invalid PowerPlay Table State Array Entry.", return -1); | 1299 | "Invalid PowerPlay Table State Array Entry.", return -1); |
1198 | 1300 | ||
1199 | state_entry = &(state_arrays->states[entry_index]); | 1301 | state_entry = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( |
1302 | ATOM_Tonga_State, entries, | ||
1303 | state_arrays, entry_index); | ||
1200 | 1304 | ||
1201 | result = call_back_func(hwmgr, (void *)state_entry, power_state, | 1305 | result = call_back_func(hwmgr, (void *)state_entry, power_state, |
1202 | (void *)pp_table, | 1306 | (void *)pp_table, |
@@ -1209,5 +1313,13 @@ int tonga_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, | |||
1209 | PP_StateClassificationFlag_Boot)) | 1313 | PP_StateClassificationFlag_Boot)) |
1210 | result = hwmgr->hwmgr_func->patch_boot_state(hwmgr, &(power_state->hardware)); | 1314 | result = hwmgr->hwmgr_func->patch_boot_state(hwmgr, &(power_state->hardware)); |
1211 | 1315 | ||
1316 | hwmgr->num_vce_state_tables = i = ppt_get_num_of_vce_state_table_entries_v1_0(hwmgr); | ||
1317 | |||
1318 | if ((i != 0) && (i <= PP_MAX_VCE_LEVELS)) { | ||
1319 | for (j = 0; j < i; j++) | ||
1320 | ppt_get_vce_state_table_entry_v1_0(hwmgr, j, &(hwmgr->vce_states[j]), NULL, &flags); | ||
1321 | } | ||
1322 | |||
1212 | return result; | 1323 | return result; |
1213 | } | 1324 | } |
1325 | |||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.h b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.h index d24b8887f466..b9710abdff01 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.h | |||
@@ -20,14 +20,14 @@ | |||
20 | * OTHER DEALINGS IN THE SOFTWARE. | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | #ifndef TONGA_PROCESSPPTABLES_H | 23 | #ifndef _PROCESSPPTABLES_V1_0_H |
24 | #define TONGA_PROCESSPPTABLES_H | 24 | #define _PROCESSPPTABLES_V1_0_H |
25 | 25 | ||
26 | #include "hwmgr.h" | 26 | #include "hwmgr.h" |
27 | 27 | ||
28 | extern const struct pp_table_func tonga_pptable_funcs; | 28 | extern const struct pp_table_func pptable_v1_0_funcs; |
29 | extern int tonga_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr); | 29 | extern int get_number_of_powerplay_table_entries_v1_0(struct pp_hwmgr *hwmgr); |
30 | extern int tonga_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index, | 30 | extern int get_powerplay_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t entry_index, |
31 | struct pp_power_state *power_state, int (*call_back_func)(struct pp_hwmgr *, void *, | 31 | struct pp_power_state *power_state, int (*call_back_func)(struct pp_hwmgr *, void *, |
32 | struct pp_power_state *, void *, uint32_t)); | 32 | struct pp_power_state *, void *, uint32_t)); |
33 | 33 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c index 6c321b0d8a1e..ccf7ebeaf892 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c | |||
@@ -1523,7 +1523,7 @@ int get_number_of_vce_state_table_entries( | |||
1523 | 1523 | ||
1524 | int get_vce_state_table_entry(struct pp_hwmgr *hwmgr, | 1524 | int get_vce_state_table_entry(struct pp_hwmgr *hwmgr, |
1525 | unsigned long i, | 1525 | unsigned long i, |
1526 | struct PP_VCEState *vce_state, | 1526 | struct pp_vce_state *vce_state, |
1527 | void **clock_info, | 1527 | void **clock_info, |
1528 | unsigned long *flag) | 1528 | unsigned long *flag) |
1529 | { | 1529 | { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c index 7f9ba7f15e19..582d04aed346 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c | |||
@@ -29,8 +29,8 @@ | |||
29 | #include "tonga_hwmgr.h" | 29 | #include "tonga_hwmgr.h" |
30 | #include "pptable.h" | 30 | #include "pptable.h" |
31 | #include "processpptables.h" | 31 | #include "processpptables.h" |
32 | #include "tonga_processpptables.h" | 32 | #include "process_pptables_v1_0.h" |
33 | #include "tonga_pptable.h" | 33 | #include "pptable_v1_0.h" |
34 | #include "pp_debug.h" | 34 | #include "pp_debug.h" |
35 | #include "tonga_ppsmc.h" | 35 | #include "tonga_ppsmc.h" |
36 | #include "cgs_common.h" | 36 | #include "cgs_common.h" |
@@ -202,6 +202,7 @@ uint8_t tonga_get_voltage_id(pp_atomctrl_voltage_table *voltage_table, | |||
202 | return i - 1; | 202 | return i - 1; |
203 | } | 203 | } |
204 | 204 | ||
205 | |||
205 | /** | 206 | /** |
206 | * @brief PhwTonga_GetVoltageOrder | 207 | * @brief PhwTonga_GetVoltageOrder |
207 | * Returns index of requested voltage record in lookup(table) | 208 | * Returns index of requested voltage record in lookup(table) |
@@ -229,7 +230,7 @@ uint8_t tonga_get_voltage_index(phm_ppt_v1_voltage_lookup_table *look_up_table, | |||
229 | return i-1; | 230 | return i-1; |
230 | } | 231 | } |
231 | 232 | ||
232 | bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr) | 233 | static bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr) |
233 | { | 234 | { |
234 | /* | 235 | /* |
235 | * We return the status of Voltage Control instead of checking SCLK/MCLK DPM | 236 | * We return the status of Voltage Control instead of checking SCLK/MCLK DPM |
@@ -334,7 +335,7 @@ void tonga_initialize_dpm_defaults(struct pp_hwmgr *hwmgr) | |||
334 | 335 | ||
335 | } | 336 | } |
336 | 337 | ||
337 | int tonga_update_sclk_threshold(struct pp_hwmgr *hwmgr) | 338 | static int tonga_update_sclk_threshold(struct pp_hwmgr *hwmgr) |
338 | { | 339 | { |
339 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); | 340 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); |
340 | 341 | ||
@@ -771,7 +772,7 @@ int tonga_set_boot_state(struct pp_hwmgr *hwmgr) | |||
771 | * @param hwmgr the address of the powerplay hardware manager. | 772 | * @param hwmgr the address of the powerplay hardware manager. |
772 | * @return always 0 | 773 | * @return always 0 |
773 | */ | 774 | */ |
774 | int tonga_process_firmware_header(struct pp_hwmgr *hwmgr) | 775 | static int tonga_process_firmware_header(struct pp_hwmgr *hwmgr) |
775 | { | 776 | { |
776 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); | 777 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); |
777 | struct tonga_smumgr *tonga_smu = (struct tonga_smumgr *)(hwmgr->smumgr->backend); | 778 | struct tonga_smumgr *tonga_smu = (struct tonga_smumgr *)(hwmgr->smumgr->backend); |
@@ -1315,15 +1316,6 @@ static int tonga_populate_smc_mvdd_table(struct pp_hwmgr *hwmgr, | |||
1315 | } | 1316 | } |
1316 | 1317 | ||
1317 | /** | 1318 | /** |
1318 | * Convert a voltage value in mv unit to VID number required by SMU firmware | ||
1319 | */ | ||
1320 | static uint8_t convert_to_vid(uint16_t vddc) | ||
1321 | { | ||
1322 | return (uint8_t) ((6200 - (vddc * VOLTAGE_SCALE)) / 25); | ||
1323 | } | ||
1324 | |||
1325 | |||
1326 | /** | ||
1327 | * Preparation of vddc and vddgfx CAC tables for SMC. | 1319 | * Preparation of vddc and vddgfx CAC tables for SMC. |
1328 | * | 1320 | * |
1329 | * @param hwmgr the address of the hardware manager | 1321 | * @param hwmgr the address of the hardware manager |
@@ -2894,7 +2886,7 @@ int tonga_populate_smc_initial_state(struct pp_hwmgr *hwmgr, | |||
2894 | * @param pInput the pointer to input data (PowerState) | 2886 | * @param pInput the pointer to input data (PowerState) |
2895 | * @return always 0 | 2887 | * @return always 0 |
2896 | */ | 2888 | */ |
2897 | int tonga_init_smc_table(struct pp_hwmgr *hwmgr) | 2889 | static int tonga_init_smc_table(struct pp_hwmgr *hwmgr) |
2898 | { | 2890 | { |
2899 | int result; | 2891 | int result; |
2900 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); | 2892 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); |
@@ -3989,7 +3981,7 @@ int tonga_set_valid_flag(phw_tonga_mc_reg_table *table) | |||
3989 | return 0; | 3981 | return 0; |
3990 | } | 3982 | } |
3991 | 3983 | ||
3992 | int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr) | 3984 | static int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr) |
3993 | { | 3985 | { |
3994 | int result; | 3986 | int result; |
3995 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); | 3987 | tonga_hwmgr *data = (tonga_hwmgr *)(hwmgr->backend); |
@@ -4326,6 +4318,79 @@ int tonga_program_voting_clients(struct pp_hwmgr *hwmgr) | |||
4326 | return 0; | 4318 | return 0; |
4327 | } | 4319 | } |
4328 | 4320 | ||
4321 | static void tonga_set_dpm_event_sources(struct pp_hwmgr *hwmgr, uint32_t sources) | ||
4322 | { | ||
4323 | bool protection; | ||
4324 | enum DPM_EVENT_SRC src; | ||
4325 | |||
4326 | switch (sources) { | ||
4327 | default: | ||
4328 | printk(KERN_ERR "Unknown throttling event sources."); | ||
4329 | /* fall through */ | ||
4330 | case 0: | ||
4331 | protection = false; | ||
4332 | /* src is unused */ | ||
4333 | break; | ||
4334 | case (1 << PHM_AutoThrottleSource_Thermal): | ||
4335 | protection = true; | ||
4336 | src = DPM_EVENT_SRC_DIGITAL; | ||
4337 | break; | ||
4338 | case (1 << PHM_AutoThrottleSource_External): | ||
4339 | protection = true; | ||
4340 | src = DPM_EVENT_SRC_EXTERNAL; | ||
4341 | break; | ||
4342 | case (1 << PHM_AutoThrottleSource_External) | | ||
4343 | (1 << PHM_AutoThrottleSource_Thermal): | ||
4344 | protection = true; | ||
4345 | src = DPM_EVENT_SRC_DIGITAL_OR_EXTERNAL; | ||
4346 | break; | ||
4347 | } | ||
4348 | /* Order matters - don't enable thermal protection for the wrong source. */ | ||
4349 | if (protection) { | ||
4350 | PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_CTRL, | ||
4351 | DPM_EVENT_SRC, src); | ||
4352 | PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, GENERAL_PWRMGT, | ||
4353 | THERMAL_PROTECTION_DIS, | ||
4354 | !phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | ||
4355 | PHM_PlatformCaps_ThermalController)); | ||
4356 | } else | ||
4357 | PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, GENERAL_PWRMGT, | ||
4358 | THERMAL_PROTECTION_DIS, 1); | ||
4359 | } | ||
4360 | |||
4361 | static int tonga_enable_auto_throttle_source(struct pp_hwmgr *hwmgr, | ||
4362 | PHM_AutoThrottleSource source) | ||
4363 | { | ||
4364 | struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); | ||
4365 | |||
4366 | if (!(data->active_auto_throttle_sources & (1 << source))) { | ||
4367 | data->active_auto_throttle_sources |= 1 << source; | ||
4368 | tonga_set_dpm_event_sources(hwmgr, data->active_auto_throttle_sources); | ||
4369 | } | ||
4370 | return 0; | ||
4371 | } | ||
4372 | |||
4373 | static int tonga_enable_thermal_auto_throttle(struct pp_hwmgr *hwmgr) | ||
4374 | { | ||
4375 | return tonga_enable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); | ||
4376 | } | ||
4377 | |||
4378 | static int tonga_disable_auto_throttle_source(struct pp_hwmgr *hwmgr, | ||
4379 | PHM_AutoThrottleSource source) | ||
4380 | { | ||
4381 | struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); | ||
4382 | |||
4383 | if (data->active_auto_throttle_sources & (1 << source)) { | ||
4384 | data->active_auto_throttle_sources &= ~(1 << source); | ||
4385 | tonga_set_dpm_event_sources(hwmgr, data->active_auto_throttle_sources); | ||
4386 | } | ||
4387 | return 0; | ||
4388 | } | ||
4389 | |||
4390 | static int tonga_disable_thermal_auto_throttle(struct pp_hwmgr *hwmgr) | ||
4391 | { | ||
4392 | return tonga_disable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); | ||
4393 | } | ||
4329 | 4394 | ||
4330 | int tonga_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | 4395 | int tonga_enable_dpm_tasks(struct pp_hwmgr *hwmgr) |
4331 | { | 4396 | { |
@@ -4409,6 +4474,10 @@ int tonga_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
4409 | PP_ASSERT_WITH_CODE((tmp_result == 0), | 4474 | PP_ASSERT_WITH_CODE((tmp_result == 0), |
4410 | "Failed to power control set level!", result = tmp_result); | 4475 | "Failed to power control set level!", result = tmp_result); |
4411 | 4476 | ||
4477 | tmp_result = tonga_enable_thermal_auto_throttle(hwmgr); | ||
4478 | PP_ASSERT_WITH_CODE((0 == tmp_result), | ||
4479 | "Failed to enable thermal auto throttle!", result = tmp_result); | ||
4480 | |||
4412 | return result; | 4481 | return result; |
4413 | } | 4482 | } |
4414 | 4483 | ||
@@ -4420,6 +4489,10 @@ int tonga_disable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
4420 | PP_ASSERT_WITH_CODE((0 == tmp_result), | 4489 | PP_ASSERT_WITH_CODE((0 == tmp_result), |
4421 | "SMC is still running!", return 0); | 4490 | "SMC is still running!", return 0); |
4422 | 4491 | ||
4492 | tmp_result = tonga_disable_thermal_auto_throttle(hwmgr); | ||
4493 | PP_ASSERT_WITH_CODE((tmp_result == 0), | ||
4494 | "Failed to disable thermal auto throttle!", result = tmp_result); | ||
4495 | |||
4423 | tmp_result = tonga_stop_dpm(hwmgr); | 4496 | tmp_result = tonga_stop_dpm(hwmgr); |
4424 | PP_ASSERT_WITH_CODE((0 == tmp_result), | 4497 | PP_ASSERT_WITH_CODE((0 == tmp_result), |
4425 | "Failed to stop DPM!", result = tmp_result); | 4498 | "Failed to stop DPM!", result = tmp_result); |
@@ -5090,7 +5163,7 @@ static int tonga_get_pp_table_entry(struct pp_hwmgr *hwmgr, | |||
5090 | 5163 | ||
5091 | tonga_ps = cast_phw_tonga_power_state(&(ps->hardware)); | 5164 | tonga_ps = cast_phw_tonga_power_state(&(ps->hardware)); |
5092 | 5165 | ||
5093 | result = tonga_get_powerplay_table_entry(hwmgr, entry_index, ps, | 5166 | result = get_powerplay_table_entry_v1_0(hwmgr, entry_index, ps, |
5094 | tonga_get_pp_table_entry_callback_func); | 5167 | tonga_get_pp_table_entry_callback_func); |
5095 | 5168 | ||
5096 | /* This is the earliest time we have all the dependency table and the VBIOS boot state | 5169 | /* This is the earliest time we have all the dependency table and the VBIOS boot state |
@@ -6254,7 +6327,7 @@ static const struct pp_hwmgr_func tonga_hwmgr_funcs = { | |||
6254 | .get_sclk = tonga_dpm_get_sclk, | 6327 | .get_sclk = tonga_dpm_get_sclk, |
6255 | .patch_boot_state = tonga_dpm_patch_boot_state, | 6328 | .patch_boot_state = tonga_dpm_patch_boot_state, |
6256 | .get_pp_table_entry = tonga_get_pp_table_entry, | 6329 | .get_pp_table_entry = tonga_get_pp_table_entry, |
6257 | .get_num_of_pp_table_entries = tonga_get_number_of_powerplay_table_entries, | 6330 | .get_num_of_pp_table_entries = get_number_of_powerplay_table_entries_v1_0, |
6258 | .print_current_perforce_level = tonga_print_current_perforce_level, | 6331 | .print_current_perforce_level = tonga_print_current_perforce_level, |
6259 | .powerdown_uvd = tonga_phm_powerdown_uvd, | 6332 | .powerdown_uvd = tonga_phm_powerdown_uvd, |
6260 | .powergate_uvd = tonga_phm_powergate_uvd, | 6333 | .powergate_uvd = tonga_phm_powergate_uvd, |
@@ -6290,7 +6363,7 @@ static const struct pp_hwmgr_func tonga_hwmgr_funcs = { | |||
6290 | int tonga_hwmgr_init(struct pp_hwmgr *hwmgr) | 6363 | int tonga_hwmgr_init(struct pp_hwmgr *hwmgr) |
6291 | { | 6364 | { |
6292 | hwmgr->hwmgr_func = &tonga_hwmgr_funcs; | 6365 | hwmgr->hwmgr_func = &tonga_hwmgr_funcs; |
6293 | hwmgr->pptable_func = &tonga_pptable_funcs; | 6366 | hwmgr->pptable_func = &pptable_v1_0_funcs; |
6294 | pp_tonga_thermal_initialize(hwmgr); | 6367 | pp_tonga_thermal_initialize(hwmgr); |
6295 | return 0; | 6368 | return 0; |
6296 | } | 6369 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_powertune.c index 9496ade3247e..24d9a05e7997 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_powertune.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_powertune.c | |||
@@ -56,9 +56,6 @@ void tonga_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr) | |||
56 | else | 56 | else |
57 | tonga_hwmgr->power_tune_defaults = &tonga_power_tune_data_set_array[0]; | 57 | tonga_hwmgr->power_tune_defaults = &tonga_power_tune_data_set_array[0]; |
58 | 58 | ||
59 | /* Assume disabled */ | ||
60 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
61 | PHM_PlatformCaps_PowerContainment); | ||
62 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | 59 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
63 | PHM_PlatformCaps_CAC); | 60 | PHM_PlatformCaps_CAC); |
64 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | 61 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h index 3f8172f545b0..18f39e89a7aa 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +++ b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | |||
@@ -131,9 +131,6 @@ struct amd_pp_init { | |||
131 | struct cgs_device *device; | 131 | struct cgs_device *device; |
132 | uint32_t chip_family; | 132 | uint32_t chip_family; |
133 | uint32_t chip_id; | 133 | uint32_t chip_id; |
134 | uint32_t rev_id; | ||
135 | uint16_t sub_sys_id; | ||
136 | uint16_t sub_vendor_id; | ||
137 | }; | 134 | }; |
138 | 135 | ||
139 | enum amd_pp_display_config_type{ | 136 | enum amd_pp_display_config_type{ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h index 962cb5385951..d4495839c64c 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h | |||
@@ -341,7 +341,6 @@ extern int phm_powerdown_uvd(struct pp_hwmgr *hwmgr); | |||
341 | extern int phm_setup_asic(struct pp_hwmgr *hwmgr); | 341 | extern int phm_setup_asic(struct pp_hwmgr *hwmgr); |
342 | extern int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr); | 342 | extern int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr); |
343 | extern int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr); | 343 | extern int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr); |
344 | extern void phm_init_dynamic_caps(struct pp_hwmgr *hwmgr); | ||
345 | extern bool phm_is_hw_access_blocked(struct pp_hwmgr *hwmgr); | 344 | extern bool phm_is_hw_access_blocked(struct pp_hwmgr *hwmgr); |
346 | extern int phm_block_hw_access(struct pp_hwmgr *hwmgr, bool block); | 345 | extern int phm_block_hw_access(struct pp_hwmgr *hwmgr, bool block); |
347 | extern int phm_set_power_state(struct pp_hwmgr *hwmgr, | 346 | extern int phm_set_power_state(struct pp_hwmgr *hwmgr, |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h index 36b4ec9c9cb1..e98748344801 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | |||
@@ -31,18 +31,20 @@ | |||
31 | #include "hwmgr_ppt.h" | 31 | #include "hwmgr_ppt.h" |
32 | #include "ppatomctrl.h" | 32 | #include "ppatomctrl.h" |
33 | #include "hwmgr_ppt.h" | 33 | #include "hwmgr_ppt.h" |
34 | #include "power_state.h" | ||
34 | 35 | ||
35 | struct pp_instance; | 36 | struct pp_instance; |
36 | struct pp_hwmgr; | 37 | struct pp_hwmgr; |
37 | struct pp_hw_power_state; | ||
38 | struct pp_power_state; | ||
39 | struct PP_VCEState; | ||
40 | struct phm_fan_speed_info; | 38 | struct phm_fan_speed_info; |
41 | struct pp_atomctrl_voltage_table; | 39 | struct pp_atomctrl_voltage_table; |
42 | 40 | ||
43 | |||
44 | extern int amdgpu_powercontainment; | 41 | extern int amdgpu_powercontainment; |
45 | extern int amdgpu_sclk_deep_sleep_en; | 42 | extern int amdgpu_sclk_deep_sleep_en; |
43 | extern unsigned amdgpu_pp_feature_mask; | ||
44 | |||
45 | #define VOLTAGE_SCALE 4 | ||
46 | |||
47 | uint8_t convert_to_vid(uint16_t vddc); | ||
46 | 48 | ||
47 | enum DISPLAY_GAP { | 49 | enum DISPLAY_GAP { |
48 | DISPLAY_GAP_VBLANK_OR_WM = 0, /* Wait for vblank or MCHG watermark. */ | 50 | DISPLAY_GAP_VBLANK_OR_WM = 0, /* Wait for vblank or MCHG watermark. */ |
@@ -52,7 +54,6 @@ enum DISPLAY_GAP { | |||
52 | }; | 54 | }; |
53 | typedef enum DISPLAY_GAP DISPLAY_GAP; | 55 | typedef enum DISPLAY_GAP DISPLAY_GAP; |
54 | 56 | ||
55 | |||
56 | struct vi_dpm_level { | 57 | struct vi_dpm_level { |
57 | bool enabled; | 58 | bool enabled; |
58 | uint32_t value; | 59 | uint32_t value; |
@@ -74,6 +75,19 @@ enum PP_Result { | |||
74 | #define PCIE_PERF_REQ_GEN2 3 | 75 | #define PCIE_PERF_REQ_GEN2 3 |
75 | #define PCIE_PERF_REQ_GEN3 4 | 76 | #define PCIE_PERF_REQ_GEN3 4 |
76 | 77 | ||
78 | enum PP_FEATURE_MASK { | ||
79 | PP_SCLK_DPM_MASK = 0x1, | ||
80 | PP_MCLK_DPM_MASK = 0x2, | ||
81 | PP_PCIE_DPM_MASK = 0x4, | ||
82 | PP_SCLK_DEEP_SLEEP_MASK = 0x8, | ||
83 | PP_POWER_CONTAINMENT_MASK = 0x10, | ||
84 | PP_UVD_HANDSHAKE_MASK = 0x20, | ||
85 | PP_SMC_VOLTAGE_CONTROL_MASK = 0x40, | ||
86 | PP_VBI_TIME_SUPPORT_MASK = 0x80, | ||
87 | PP_ULV_MASK = 0x100, | ||
88 | PP_ENABLE_GFX_CG_THRU_SMU = 0x200 | ||
89 | }; | ||
90 | |||
77 | enum PHM_BackEnd_Magic { | 91 | enum PHM_BackEnd_Magic { |
78 | PHM_Dummy_Magic = 0xAA5555AA, | 92 | PHM_Dummy_Magic = 0xAA5555AA, |
79 | PHM_RV770_Magic = 0xDCBAABCD, | 93 | PHM_RV770_Magic = 0xDCBAABCD, |
@@ -354,7 +368,7 @@ struct pp_table_func { | |||
354 | int (*pptable_get_vce_state_table_entry)( | 368 | int (*pptable_get_vce_state_table_entry)( |
355 | struct pp_hwmgr *hwmgr, | 369 | struct pp_hwmgr *hwmgr, |
356 | unsigned long i, | 370 | unsigned long i, |
357 | struct PP_VCEState *vce_state, | 371 | struct pp_vce_state *vce_state, |
358 | void **clock_info, | 372 | void **clock_info, |
359 | unsigned long *flag); | 373 | unsigned long *flag); |
360 | }; | 374 | }; |
@@ -573,22 +587,43 @@ struct phm_microcode_version_info { | |||
573 | uint32_t NB; | 587 | uint32_t NB; |
574 | }; | 588 | }; |
575 | 589 | ||
590 | #define PP_MAX_VCE_LEVELS 6 | ||
591 | |||
592 | enum PP_VCE_LEVEL { | ||
593 | PP_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */ | ||
594 | PP_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */ | ||
595 | PP_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */ | ||
596 | PP_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */ | ||
597 | PP_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */ | ||
598 | PP_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */ | ||
599 | }; | ||
600 | |||
601 | |||
602 | enum PP_TABLE_VERSION { | ||
603 | PP_TABLE_V0 = 0, | ||
604 | PP_TABLE_V1, | ||
605 | PP_TABLE_V2, | ||
606 | PP_TABLE_MAX | ||
607 | }; | ||
608 | |||
576 | /** | 609 | /** |
577 | * The main hardware manager structure. | 610 | * The main hardware manager structure. |
578 | */ | 611 | */ |
579 | struct pp_hwmgr { | 612 | struct pp_hwmgr { |
580 | uint32_t chip_family; | 613 | uint32_t chip_family; |
581 | uint32_t chip_id; | 614 | uint32_t chip_id; |
582 | uint32_t hw_revision; | ||
583 | uint32_t sub_sys_id; | ||
584 | uint32_t sub_vendor_id; | ||
585 | 615 | ||
616 | uint32_t pp_table_version; | ||
586 | void *device; | 617 | void *device; |
587 | struct pp_smumgr *smumgr; | 618 | struct pp_smumgr *smumgr; |
588 | const void *soft_pp_table; | 619 | const void *soft_pp_table; |
589 | uint32_t soft_pp_table_size; | 620 | uint32_t soft_pp_table_size; |
590 | void *hardcode_pp_table; | 621 | void *hardcode_pp_table; |
591 | bool need_pp_table_upload; | 622 | bool need_pp_table_upload; |
623 | |||
624 | struct pp_vce_state vce_states[PP_MAX_VCE_LEVELS]; | ||
625 | uint32_t num_vce_state_tables; | ||
626 | |||
592 | enum amd_dpm_forced_level dpm_level; | 627 | enum amd_dpm_forced_level dpm_level; |
593 | bool block_hw_access; | 628 | bool block_hw_access; |
594 | struct phm_gfx_arbiter gfx_arbiter; | 629 | struct phm_gfx_arbiter gfx_arbiter; |
@@ -626,6 +661,7 @@ struct pp_hwmgr { | |||
626 | struct pp_power_state *boot_ps; | 661 | struct pp_power_state *boot_ps; |
627 | struct pp_power_state *uvd_ps; | 662 | struct pp_power_state *uvd_ps; |
628 | struct amd_pp_display_configuration display_config; | 663 | struct amd_pp_display_configuration display_config; |
664 | uint32_t feature_mask; | ||
629 | }; | 665 | }; |
630 | 666 | ||
631 | 667 | ||
@@ -661,6 +697,8 @@ extern void phm_trim_voltage_table_to_fit_state_table(uint32_t max_vol_steps, st | |||
661 | extern int phm_reset_single_dpm_table(void *table, uint32_t count, int max); | 697 | extern int phm_reset_single_dpm_table(void *table, uint32_t count, int max); |
662 | extern void phm_setup_pcie_table_entry(void *table, uint32_t index, uint32_t pcie_gen, uint32_t pcie_lanes); | 698 | extern void phm_setup_pcie_table_entry(void *table, uint32_t index, uint32_t pcie_gen, uint32_t pcie_lanes); |
663 | extern int32_t phm_get_dpm_level_enable_mask_value(void *table); | 699 | extern int32_t phm_get_dpm_level_enable_mask_value(void *table); |
700 | extern uint8_t phm_get_voltage_id(struct pp_atomctrl_voltage_table *voltage_table, | ||
701 | uint32_t voltage); | ||
664 | extern uint8_t phm_get_voltage_index(struct phm_ppt_v1_voltage_lookup_table *lookup_table, uint16_t voltage); | 702 | extern uint8_t phm_get_voltage_index(struct phm_ppt_v1_voltage_lookup_table *lookup_table, uint16_t voltage); |
665 | extern uint16_t phm_find_closest_vddci(struct pp_atomctrl_voltage_table *vddci_table, uint16_t vddci); | 703 | extern uint16_t phm_find_closest_vddci(struct pp_atomctrl_voltage_table *vddci_table, uint16_t vddci); |
666 | extern int phm_find_boot_level(void *table, uint32_t value, uint32_t *boot_level); | 704 | extern int phm_find_boot_level(void *table, uint32_t value, uint32_t *boot_level); |
@@ -671,6 +709,9 @@ extern int phm_hwmgr_backend_fini(struct pp_hwmgr *hwmgr); | |||
671 | extern uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask); | 709 | extern uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask); |
672 | extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr); | 710 | extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr); |
673 | 711 | ||
712 | extern int phm_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, | ||
713 | uint32_t sclk, uint16_t id, uint16_t *voltage); | ||
714 | |||
674 | #define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU | 715 | #define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU |
675 | 716 | ||
676 | #define PHM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT | 717 | #define PHM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT |
@@ -685,8 +726,6 @@ extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr); | |||
685 | PHM_FIELD_SHIFT(reg, field)) | 726 | PHM_FIELD_SHIFT(reg, field)) |
686 | 727 | ||
687 | 728 | ||
688 | |||
689 | |||
690 | /* Operations on named fields. */ | 729 | /* Operations on named fields. */ |
691 | 730 | ||
692 | #define PHM_READ_FIELD(device, reg, field) \ | 731 | #define PHM_READ_FIELD(device, reg, field) \ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/power_state.h b/drivers/gpu/drm/amd/powerplay/inc/power_state.h index a3f0ce4d5835..9ceaed9ac52a 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/power_state.h +++ b/drivers/gpu/drm/amd/powerplay/inc/power_state.h | |||
@@ -158,7 +158,7 @@ struct pp_power_state { | |||
158 | 158 | ||
159 | 159 | ||
160 | /*Structure to hold a VCE state entry*/ | 160 | /*Structure to hold a VCE state entry*/ |
161 | struct PP_VCEState { | 161 | struct pp_vce_state { |
162 | uint32_t evclk; | 162 | uint32_t evclk; |
163 | uint32_t ecclk; | 163 | uint32_t ecclk; |
164 | uint32_t sclk; | 164 | uint32_t sclk; |
@@ -171,30 +171,28 @@ enum PP_MMProfilingState { | |||
171 | PP_MMProfilingState_Stopped | 171 | PP_MMProfilingState_Stopped |
172 | }; | 172 | }; |
173 | 173 | ||
174 | struct PP_Clock_Engine_Request { | 174 | struct pp_clock_engine_request { |
175 | unsigned long clientType; | 175 | unsigned long client_type; |
176 | unsigned long ctxid; | 176 | unsigned long ctx_id; |
177 | uint64_t context_handle; | 177 | uint64_t context_handle; |
178 | unsigned long sclk; | 178 | unsigned long sclk; |
179 | unsigned long sclkHardMin; | 179 | unsigned long sclk_hard_min; |
180 | unsigned long mclk; | 180 | unsigned long mclk; |
181 | unsigned long iclk; | 181 | unsigned long iclk; |
182 | unsigned long evclk; | 182 | unsigned long evclk; |
183 | unsigned long ecclk; | 183 | unsigned long ecclk; |
184 | unsigned long ecclkHardMin; | 184 | unsigned long ecclk_hard_min; |
185 | unsigned long vclk; | 185 | unsigned long vclk; |
186 | unsigned long dclk; | 186 | unsigned long dclk; |
187 | unsigned long samclk; | 187 | unsigned long sclk_over_drive; |
188 | unsigned long acpclk; | 188 | unsigned long mclk_over_drive; |
189 | unsigned long sclkOverdrive; | ||
190 | unsigned long mclkOverdrive; | ||
191 | unsigned long sclk_threshold; | 189 | unsigned long sclk_threshold; |
192 | unsigned long flag; | 190 | unsigned long flag; |
193 | unsigned long vclk_ceiling; | 191 | unsigned long vclk_ceiling; |
194 | unsigned long dclk_ceiling; | 192 | unsigned long dclk_ceiling; |
195 | unsigned long num_cus; | 193 | unsigned long num_cus; |
196 | unsigned long pmflag; | 194 | unsigned long pm_flag; |
197 | enum PP_MMProfilingState MMProfilingState; | 195 | enum PP_MMProfilingState mm_profiling_state; |
198 | }; | 196 | }; |
199 | 197 | ||
200 | #endif | 198 | #endif |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h b/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h index d7d83b7c7f95..bfdbec10cdd5 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h +++ b/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h | |||
@@ -43,5 +43,8 @@ | |||
43 | } while (0) | 43 | } while (0) |
44 | 44 | ||
45 | 45 | ||
46 | #define GET_FLEXIBLE_ARRAY_MEMBER_ADDR(type, member, ptr, n) \ | ||
47 | (type *)((char *)&(ptr)->member + (sizeof(type) * (n))) | ||
48 | |||
46 | #endif /* PP_DEBUG_H */ | 49 | #endif /* PP_DEBUG_H */ |
47 | 50 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h index 3c235f0177cd..34abfd2cde53 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h | |||
@@ -74,7 +74,6 @@ struct pp_smumgr_func { | |||
74 | struct pp_smumgr { | 74 | struct pp_smumgr { |
75 | uint32_t chip_family; | 75 | uint32_t chip_family; |
76 | uint32_t chip_id; | 76 | uint32_t chip_id; |
77 | uint32_t hw_revision; | ||
78 | void *device; | 77 | void *device; |
79 | void *backend; | 78 | void *backend; |
80 | uint32_t usec_timeout; | 79 | uint32_t usec_timeout; |
@@ -122,6 +121,12 @@ extern int smu_allocate_memory(void *device, uint32_t size, | |||
122 | 121 | ||
123 | extern int smu_free_memory(void *device, void *handle); | 122 | extern int smu_free_memory(void *device, void *handle); |
124 | 123 | ||
124 | extern int cz_smum_init(struct pp_smumgr *smumgr); | ||
125 | extern int iceland_smum_init(struct pp_smumgr *smumgr); | ||
126 | extern int tonga_smum_init(struct pp_smumgr *smumgr); | ||
127 | extern int fiji_smum_init(struct pp_smumgr *smumgr); | ||
128 | extern int polaris10_smum_init(struct pp_smumgr *smumgr); | ||
129 | |||
125 | #define SMUM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT | 130 | #define SMUM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT |
126 | 131 | ||
127 | #define SMUM_FIELD_MASK(reg, field) reg##__##field##_MASK | 132 | #define SMUM_FIELD_MASK(reg, field) reg##__##field##_MASK |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c index 87c023e518ab..5a44485526d2 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | |||
@@ -89,13 +89,8 @@ static int cz_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg) | |||
89 | if (result != 0) | 89 | if (result != 0) |
90 | return result; | 90 | return result; |
91 | 91 | ||
92 | result = SMUM_WAIT_FIELD_UNEQUAL(smumgr, | 92 | return SMUM_WAIT_FIELD_UNEQUAL(smumgr, |
93 | SMU_MP1_SRBM2P_RESP_0, CONTENT, 0); | 93 | SMU_MP1_SRBM2P_RESP_0, CONTENT, 0); |
94 | |||
95 | if (result != 0) | ||
96 | return result; | ||
97 | |||
98 | return 0; | ||
99 | } | 94 | } |
100 | 95 | ||
101 | static int cz_set_smc_sram_address(struct pp_smumgr *smumgr, | 96 | static int cz_set_smc_sram_address(struct pp_smumgr *smumgr, |
@@ -106,12 +101,12 @@ static int cz_set_smc_sram_address(struct pp_smumgr *smumgr, | |||
106 | 101 | ||
107 | if (0 != (3 & smc_address)) { | 102 | if (0 != (3 & smc_address)) { |
108 | printk(KERN_ERR "[ powerplay ] SMC address must be 4 byte aligned\n"); | 103 | printk(KERN_ERR "[ powerplay ] SMC address must be 4 byte aligned\n"); |
109 | return -1; | 104 | return -EINVAL; |
110 | } | 105 | } |
111 | 106 | ||
112 | if (limit <= (smc_address + 3)) { | 107 | if (limit <= (smc_address + 3)) { |
113 | printk(KERN_ERR "[ powerplay ] SMC address beyond the SMC RAM area\n"); | 108 | printk(KERN_ERR "[ powerplay ] SMC address beyond the SMC RAM area\n"); |
114 | return -1; | 109 | return -EINVAL; |
115 | } | 110 | } |
116 | 111 | ||
117 | cgs_write_register(smumgr->device, mmMP0PUB_IND_INDEX_0, | 112 | cgs_write_register(smumgr->device, mmMP0PUB_IND_INDEX_0, |
@@ -129,9 +124,10 @@ static int cz_write_smc_sram_dword(struct pp_smumgr *smumgr, | |||
129 | return -EINVAL; | 124 | return -EINVAL; |
130 | 125 | ||
131 | result = cz_set_smc_sram_address(smumgr, smc_address, limit); | 126 | result = cz_set_smc_sram_address(smumgr, smc_address, limit); |
132 | cgs_write_register(smumgr->device, mmMP0PUB_IND_DATA_0, value); | 127 | if (!result) |
128 | cgs_write_register(smumgr->device, mmMP0PUB_IND_DATA_0, value); | ||
133 | 129 | ||
134 | return 0; | 130 | return result; |
135 | } | 131 | } |
136 | 132 | ||
137 | static int cz_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr, | 133 | static int cz_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr, |
@@ -148,7 +144,6 @@ static int cz_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr, | |||
148 | static int cz_request_smu_load_fw(struct pp_smumgr *smumgr) | 144 | static int cz_request_smu_load_fw(struct pp_smumgr *smumgr) |
149 | { | 145 | { |
150 | struct cz_smumgr *cz_smu = (struct cz_smumgr *)(smumgr->backend); | 146 | struct cz_smumgr *cz_smu = (struct cz_smumgr *)(smumgr->backend); |
151 | int result = 0; | ||
152 | uint32_t smc_address; | 147 | uint32_t smc_address; |
153 | 148 | ||
154 | if (!smumgr->reload_fw) { | 149 | if (!smumgr->reload_fw) { |
@@ -177,11 +172,9 @@ static int cz_request_smu_load_fw(struct pp_smumgr *smumgr) | |||
177 | cz_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_ExecuteJob, | 172 | cz_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_ExecuteJob, |
178 | cz_smu->toc_entry_power_profiling_index); | 173 | cz_smu->toc_entry_power_profiling_index); |
179 | 174 | ||
180 | result = cz_send_msg_to_smc_with_parameter(smumgr, | 175 | return cz_send_msg_to_smc_with_parameter(smumgr, |
181 | PPSMC_MSG_ExecuteJob, | 176 | PPSMC_MSG_ExecuteJob, |
182 | cz_smu->toc_entry_initialize_index); | 177 | cz_smu->toc_entry_initialize_index); |
183 | |||
184 | return result; | ||
185 | } | 178 | } |
186 | 179 | ||
187 | static int cz_check_fw_load_finish(struct pp_smumgr *smumgr, | 180 | static int cz_check_fw_load_finish(struct pp_smumgr *smumgr, |
@@ -195,9 +188,6 @@ static int cz_check_fw_load_finish(struct pp_smumgr *smumgr, | |||
195 | if (smumgr == NULL || smumgr->device == NULL) | 188 | if (smumgr == NULL || smumgr->device == NULL) |
196 | return -EINVAL; | 189 | return -EINVAL; |
197 | 190 | ||
198 | return cgs_read_register(smumgr->device, | ||
199 | mmSMU_MP1_SRBM2P_ARG_0); | ||
200 | |||
201 | cgs_write_register(smumgr->device, mmMP0PUB_IND_INDEX, index); | 191 | cgs_write_register(smumgr->device, mmMP0PUB_IND_INDEX, index); |
202 | 192 | ||
203 | for (i = 0; i < smumgr->usec_timeout; i++) { | 193 | for (i = 0; i < smumgr->usec_timeout; i++) { |
@@ -275,7 +265,10 @@ static int cz_start_smu(struct pp_smumgr *smumgr) | |||
275 | if (smumgr->chip_id == CHIP_STONEY) | 265 | if (smumgr->chip_id == CHIP_STONEY) |
276 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | 266 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); |
277 | 267 | ||
278 | cz_request_smu_load_fw(smumgr); | 268 | ret = cz_request_smu_load_fw(smumgr); |
269 | if (ret) | ||
270 | printk(KERN_ERR "[ powerplay] SMU firmware load failed\n"); | ||
271 | |||
279 | cz_check_fw_load_finish(smumgr, fw_to_check); | 272 | cz_check_fw_load_finish(smumgr, fw_to_check); |
280 | 273 | ||
281 | ret = cz_load_mec_firmware(smumgr); | 274 | ret = cz_load_mec_firmware(smumgr); |
@@ -566,10 +559,7 @@ static int cz_smu_construct_toc_for_bootup(struct pp_smumgr *smumgr) | |||
566 | 559 | ||
567 | cz_smu_populate_single_ucode_load_task(smumgr, | 560 | cz_smu_populate_single_ucode_load_task(smumgr, |
568 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); | 561 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); |
569 | if (smumgr->chip_id == CHIP_STONEY) | 562 | if (smumgr->chip_id != CHIP_STONEY) |
570 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
571 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); | ||
572 | else | ||
573 | cz_smu_populate_single_ucode_load_task(smumgr, | 563 | cz_smu_populate_single_ucode_load_task(smumgr, |
574 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, false); | 564 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, false); |
575 | cz_smu_populate_single_ucode_load_task(smumgr, | 565 | cz_smu_populate_single_ucode_load_task(smumgr, |
@@ -580,10 +570,7 @@ static int cz_smu_construct_toc_for_bootup(struct pp_smumgr *smumgr) | |||
580 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); | 570 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); |
581 | cz_smu_populate_single_ucode_load_task(smumgr, | 571 | cz_smu_populate_single_ucode_load_task(smumgr, |
582 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | 572 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); |
583 | if (smumgr->chip_id == CHIP_STONEY) | 573 | if (smumgr->chip_id != CHIP_STONEY) |
584 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
585 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | ||
586 | else | ||
587 | cz_smu_populate_single_ucode_load_task(smumgr, | 574 | cz_smu_populate_single_ucode_load_task(smumgr, |
588 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); | 575 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); |
589 | cz_smu_populate_single_ucode_load_task(smumgr, | 576 | cz_smu_populate_single_ucode_load_task(smumgr, |
@@ -610,19 +597,12 @@ static int cz_smu_construct_toc(struct pp_smumgr *smumgr) | |||
610 | struct cz_smumgr *cz_smu = (struct cz_smumgr *)smumgr->backend; | 597 | struct cz_smumgr *cz_smu = (struct cz_smumgr *)smumgr->backend; |
611 | 598 | ||
612 | cz_smu->toc_entry_used_count = 0; | 599 | cz_smu->toc_entry_used_count = 0; |
613 | |||
614 | cz_smu_initialize_toc_empty_job_list(smumgr); | 600 | cz_smu_initialize_toc_empty_job_list(smumgr); |
615 | |||
616 | cz_smu_construct_toc_for_rlc_aram_save(smumgr); | 601 | cz_smu_construct_toc_for_rlc_aram_save(smumgr); |
617 | |||
618 | cz_smu_construct_toc_for_vddgfx_enter(smumgr); | 602 | cz_smu_construct_toc_for_vddgfx_enter(smumgr); |
619 | |||
620 | cz_smu_construct_toc_for_vddgfx_exit(smumgr); | 603 | cz_smu_construct_toc_for_vddgfx_exit(smumgr); |
621 | |||
622 | cz_smu_construct_toc_for_power_profiling(smumgr); | 604 | cz_smu_construct_toc_for_power_profiling(smumgr); |
623 | |||
624 | cz_smu_construct_toc_for_bootup(smumgr); | 605 | cz_smu_construct_toc_for_bootup(smumgr); |
625 | |||
626 | cz_smu_construct_toc_for_clock_table(smumgr); | 606 | cz_smu_construct_toc_for_clock_table(smumgr); |
627 | 607 | ||
628 | return 0; | 608 | return 0; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c index 704ff4cc0023..8047ad221e74 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include "cgs_common.h" | 40 | #include "cgs_common.h" |
41 | 41 | ||
42 | #define POLARIS10_SMC_SIZE 0x20000 | 42 | #define POLARIS10_SMC_SIZE 0x20000 |
43 | #define VOLTAGE_SCALE 4 | ||
44 | 43 | ||
45 | /* Microcode file is stored in this buffer */ | 44 | /* Microcode file is stored in this buffer */ |
46 | #define BUFFER_SIZE 80000 | 45 | #define BUFFER_SIZE 80000 |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h index e5377aec057f..7c2445f1f043 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h | |||
@@ -26,12 +26,27 @@ | |||
26 | 26 | ||
27 | #include <polaris10_ppsmc.h> | 27 | #include <polaris10_ppsmc.h> |
28 | #include <pp_endian.h> | 28 | #include <pp_endian.h> |
29 | #include "smu74.h" | ||
29 | 30 | ||
30 | struct polaris10_avfs { | 31 | struct polaris10_avfs { |
31 | enum AVFS_BTC_STATUS avfs_btc_status; | 32 | enum AVFS_BTC_STATUS avfs_btc_status; |
32 | uint32_t avfs_btc_param; | 33 | uint32_t avfs_btc_param; |
33 | }; | 34 | }; |
34 | 35 | ||
36 | struct polaris10_pt_defaults { | ||
37 | uint8_t SviLoadLineEn; | ||
38 | uint8_t SviLoadLineVddC; | ||
39 | uint8_t TDC_VDDC_ThrottleReleaseLimitPerc; | ||
40 | uint8_t TDC_MAWt; | ||
41 | uint8_t TdcWaterfallCtl; | ||
42 | uint8_t DTEAmbientTempBase; | ||
43 | |||
44 | uint32_t DisplayCac; | ||
45 | uint32_t BAPM_TEMP_GRADIENT; | ||
46 | uint16_t BAPMTI_R[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS]; | ||
47 | uint16_t BAPMTI_RC[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS]; | ||
48 | }; | ||
49 | |||
35 | struct polaris10_buffer_entry { | 50 | struct polaris10_buffer_entry { |
36 | uint32_t data_size; | 51 | uint32_t data_size; |
37 | uint32_t mc_addr_low; | 52 | uint32_t mc_addr_low; |
@@ -40,6 +55,11 @@ struct polaris10_buffer_entry { | |||
40 | unsigned long handle; | 55 | unsigned long handle; |
41 | }; | 56 | }; |
42 | 57 | ||
58 | struct polaris10_range_table { | ||
59 | uint32_t trans_lower_frequency; /* in 10khz */ | ||
60 | uint32_t trans_upper_frequency; | ||
61 | }; | ||
62 | |||
43 | struct polaris10_smumgr { | 63 | struct polaris10_smumgr { |
44 | uint8_t *header; | 64 | uint8_t *header; |
45 | uint8_t *mec_image; | 65 | uint8_t *mec_image; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c index cf3cabee8918..bbeb786db003 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c | |||
@@ -28,11 +28,7 @@ | |||
28 | #include "smumgr.h" | 28 | #include "smumgr.h" |
29 | #include "cgs_common.h" | 29 | #include "cgs_common.h" |
30 | #include "linux/delay.h" | 30 | #include "linux/delay.h" |
31 | #include "cz_smumgr.h" | 31 | |
32 | #include "tonga_smumgr.h" | ||
33 | #include "iceland_smumgr.h" | ||
34 | #include "fiji_smumgr.h" | ||
35 | #include "polaris10_smumgr.h" | ||
36 | 32 | ||
37 | int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | 33 | int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle) |
38 | { | 34 | { |
@@ -48,7 +44,6 @@ int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | |||
48 | smumgr->device = pp_init->device; | 44 | smumgr->device = pp_init->device; |
49 | smumgr->chip_family = pp_init->chip_family; | 45 | smumgr->chip_family = pp_init->chip_family; |
50 | smumgr->chip_id = pp_init->chip_id; | 46 | smumgr->chip_id = pp_init->chip_id; |
51 | smumgr->hw_revision = pp_init->rev_id; | ||
52 | smumgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; | 47 | smumgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; |
53 | smumgr->reload_fw = 1; | 48 | smumgr->reload_fw = 1; |
54 | handle->smu_mgr = smumgr; | 49 | handle->smu_mgr = smumgr; |
diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c index 3d2e91c4d78e..b404287abb97 100644 --- a/drivers/gpu/drm/drm_global.c +++ b/drivers/gpu/drm/drm_global.c | |||
@@ -65,30 +65,34 @@ void drm_global_release(void) | |||
65 | 65 | ||
66 | int drm_global_item_ref(struct drm_global_reference *ref) | 66 | int drm_global_item_ref(struct drm_global_reference *ref) |
67 | { | 67 | { |
68 | int ret; | 68 | int ret = 0; |
69 | struct drm_global_item *item = &glob[ref->global_type]; | 69 | struct drm_global_item *item = &glob[ref->global_type]; |
70 | 70 | ||
71 | mutex_lock(&item->mutex); | 71 | mutex_lock(&item->mutex); |
72 | if (item->refcount == 0) { | 72 | if (item->refcount == 0) { |
73 | item->object = kzalloc(ref->size, GFP_KERNEL); | 73 | ref->object = kzalloc(ref->size, GFP_KERNEL); |
74 | if (unlikely(item->object == NULL)) { | 74 | if (unlikely(ref->object == NULL)) { |
75 | ret = -ENOMEM; | 75 | ret = -ENOMEM; |
76 | goto out_err; | 76 | goto error_unlock; |
77 | } | 77 | } |
78 | |||
79 | ref->object = item->object; | ||
80 | ret = ref->init(ref); | 78 | ret = ref->init(ref); |
81 | if (unlikely(ret != 0)) | 79 | if (unlikely(ret != 0)) |
82 | goto out_err; | 80 | goto error_free; |
83 | 81 | ||
82 | item->object = ref->object; | ||
83 | } else { | ||
84 | ref->object = item->object; | ||
84 | } | 85 | } |
86 | |||
85 | ++item->refcount; | 87 | ++item->refcount; |
86 | ref->object = item->object; | ||
87 | mutex_unlock(&item->mutex); | 88 | mutex_unlock(&item->mutex); |
88 | return 0; | 89 | return 0; |
89 | out_err: | 90 | |
91 | error_free: | ||
92 | kfree(ref->object); | ||
93 | ref->object = NULL; | ||
94 | error_unlock: | ||
90 | mutex_unlock(&item->mutex); | 95 | mutex_unlock(&item->mutex); |
91 | item->object = NULL; | ||
92 | return ret; | 96 | return ret; |
93 | } | 97 | } |
94 | EXPORT_SYMBOL(drm_global_item_ref); | 98 | EXPORT_SYMBOL(drm_global_item_ref); |
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index 5e1d7899dd72..fa5440dc9a19 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c | |||
@@ -61,7 +61,7 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned) | |||
61 | if (domain == QXL_GEM_DOMAIN_VRAM) | 61 | if (domain == QXL_GEM_DOMAIN_VRAM) |
62 | qbo->placements[c++].flags = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_VRAM | pflag; | 62 | qbo->placements[c++].flags = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_VRAM | pflag; |
63 | if (domain == QXL_GEM_DOMAIN_SURFACE) | 63 | if (domain == QXL_GEM_DOMAIN_SURFACE) |
64 | qbo->placements[c++].flags = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_PRIV0 | pflag; | 64 | qbo->placements[c++].flags = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_PRIV | pflag; |
65 | if (domain == QXL_GEM_DOMAIN_CPU) | 65 | if (domain == QXL_GEM_DOMAIN_CPU) |
66 | qbo->placements[c++].flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | pflag; | 66 | qbo->placements[c++].flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | pflag; |
67 | if (!c) | 67 | if (!c) |
@@ -151,7 +151,7 @@ void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, | |||
151 | 151 | ||
152 | if (bo->tbo.mem.mem_type == TTM_PL_VRAM) | 152 | if (bo->tbo.mem.mem_type == TTM_PL_VRAM) |
153 | map = qdev->vram_mapping; | 153 | map = qdev->vram_mapping; |
154 | else if (bo->tbo.mem.mem_type == TTM_PL_PRIV0) | 154 | else if (bo->tbo.mem.mem_type == TTM_PL_PRIV) |
155 | map = qdev->surface_mapping; | 155 | map = qdev->surface_mapping; |
156 | else | 156 | else |
157 | goto fallback; | 157 | goto fallback; |
@@ -191,7 +191,7 @@ void qxl_bo_kunmap_atomic_page(struct qxl_device *qdev, | |||
191 | 191 | ||
192 | if (bo->tbo.mem.mem_type == TTM_PL_VRAM) | 192 | if (bo->tbo.mem.mem_type == TTM_PL_VRAM) |
193 | map = qdev->vram_mapping; | 193 | map = qdev->vram_mapping; |
194 | else if (bo->tbo.mem.mem_type == TTM_PL_PRIV0) | 194 | else if (bo->tbo.mem.mem_type == TTM_PL_PRIV) |
195 | map = qdev->surface_mapping; | 195 | map = qdev->surface_mapping; |
196 | else | 196 | else |
197 | goto fallback; | 197 | goto fallback; |
@@ -311,7 +311,7 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo) | |||
311 | 311 | ||
312 | int qxl_surf_evict(struct qxl_device *qdev) | 312 | int qxl_surf_evict(struct qxl_device *qdev) |
313 | { | 313 | { |
314 | return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV0); | 314 | return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV); |
315 | } | 315 | } |
316 | 316 | ||
317 | int qxl_vram_evict(struct qxl_device *qdev) | 317 | int qxl_vram_evict(struct qxl_device *qdev) |
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 6a22de045cb5..a257ad26beef 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c | |||
@@ -168,7 +168,7 @@ static int qxl_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | |||
168 | man->default_caching = TTM_PL_FLAG_CACHED; | 168 | man->default_caching = TTM_PL_FLAG_CACHED; |
169 | break; | 169 | break; |
170 | case TTM_PL_VRAM: | 170 | case TTM_PL_VRAM: |
171 | case TTM_PL_PRIV0: | 171 | case TTM_PL_PRIV: |
172 | /* "On-card" video ram */ | 172 | /* "On-card" video ram */ |
173 | man->func = &ttm_bo_manager_func; | 173 | man->func = &ttm_bo_manager_func; |
174 | man->gpu_offset = 0; | 174 | man->gpu_offset = 0; |
@@ -235,7 +235,7 @@ static int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev, | |||
235 | mem->bus.base = qdev->vram_base; | 235 | mem->bus.base = qdev->vram_base; |
236 | mem->bus.offset = mem->start << PAGE_SHIFT; | 236 | mem->bus.offset = mem->start << PAGE_SHIFT; |
237 | break; | 237 | break; |
238 | case TTM_PL_PRIV0: | 238 | case TTM_PL_PRIV: |
239 | mem->bus.is_iomem = true; | 239 | mem->bus.is_iomem = true; |
240 | mem->bus.base = qdev->surfaceram_base; | 240 | mem->bus.base = qdev->surfaceram_base; |
241 | mem->bus.offset = mem->start << PAGE_SHIFT; | 241 | mem->bus.offset = mem->start << PAGE_SHIFT; |
@@ -376,7 +376,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo, | |||
376 | qbo = to_qxl_bo(bo); | 376 | qbo = to_qxl_bo(bo); |
377 | qdev = qbo->gem_base.dev->dev_private; | 377 | qdev = qbo->gem_base.dev->dev_private; |
378 | 378 | ||
379 | if (bo->mem.mem_type == TTM_PL_PRIV0 && qbo->surface_id) | 379 | if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id) |
380 | qxl_surface_evict(qdev, qbo, new_mem ? true : false); | 380 | qxl_surface_evict(qdev, qbo, new_mem ? true : false); |
381 | } | 381 | } |
382 | 382 | ||
@@ -422,7 +422,7 @@ int qxl_ttm_init(struct qxl_device *qdev) | |||
422 | DRM_ERROR("Failed initializing VRAM heap.\n"); | 422 | DRM_ERROR("Failed initializing VRAM heap.\n"); |
423 | return r; | 423 | return r; |
424 | } | 424 | } |
425 | r = ttm_bo_init_mm(&qdev->mman.bdev, TTM_PL_PRIV0, | 425 | r = ttm_bo_init_mm(&qdev->mman.bdev, TTM_PL_PRIV, |
426 | qdev->surfaceram_size / PAGE_SIZE); | 426 | qdev->surfaceram_size / PAGE_SIZE); |
427 | if (r) { | 427 | if (r) { |
428 | DRM_ERROR("Failed initializing Surfaces heap.\n"); | 428 | DRM_ERROR("Failed initializing Surfaces heap.\n"); |
@@ -445,7 +445,7 @@ int qxl_ttm_init(struct qxl_device *qdev) | |||
445 | void qxl_ttm_fini(struct qxl_device *qdev) | 445 | void qxl_ttm_fini(struct qxl_device *qdev) |
446 | { | 446 | { |
447 | ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_VRAM); | 447 | ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_VRAM); |
448 | ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_PRIV0); | 448 | ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_PRIV); |
449 | ttm_bo_device_release(&qdev->mman.bdev); | 449 | ttm_bo_device_release(&qdev->mman.bdev); |
450 | qxl_ttm_global_fini(qdev); | 450 | qxl_ttm_global_fini(qdev); |
451 | DRM_INFO("qxl: ttm finalized\n"); | 451 | DRM_INFO("qxl: ttm finalized\n"); |
@@ -489,7 +489,7 @@ static int qxl_ttm_debugfs_init(struct qxl_device *qdev) | |||
489 | if (i == 0) | 489 | if (i == 0) |
490 | qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv; | 490 | qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv; |
491 | else | 491 | else |
492 | qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv; | 492 | qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV].priv; |
493 | 493 | ||
494 | } | 494 | } |
495 | return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i); | 495 | return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i); |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index a00dd2f74527..b423c0159581 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
@@ -639,7 +639,7 @@ void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) | |||
639 | * Used at driver startup. | 639 | * Used at driver startup. |
640 | * Returns true if virtual or false if not. | 640 | * Returns true if virtual or false if not. |
641 | */ | 641 | */ |
642 | static bool radeon_device_is_virtual(void) | 642 | bool radeon_device_is_virtual(void) |
643 | { | 643 | { |
644 | #ifdef CONFIG_X86 | 644 | #ifdef CONFIG_X86 |
645 | return boot_cpu_has(X86_FEATURE_HYPERVISOR); | 645 | return boot_cpu_has(X86_FEATURE_HYPERVISOR); |
@@ -1594,7 +1594,8 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, | |||
1594 | 1594 | ||
1595 | rdev = dev->dev_private; | 1595 | rdev = dev->dev_private; |
1596 | 1596 | ||
1597 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) | 1597 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF || |
1598 | dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) | ||
1598 | return 0; | 1599 | return 0; |
1599 | 1600 | ||
1600 | drm_kms_helper_poll_disable(dev); | 1601 | drm_kms_helper_poll_disable(dev); |
@@ -1689,7 +1690,8 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon) | |||
1689 | struct drm_crtc *crtc; | 1690 | struct drm_crtc *crtc; |
1690 | int r; | 1691 | int r; |
1691 | 1692 | ||
1692 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) | 1693 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF || |
1694 | dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) | ||
1693 | return 0; | 1695 | return 0; |
1694 | 1696 | ||
1695 | if (fbcon) { | 1697 | if (fbcon) { |
@@ -1956,14 +1958,3 @@ static void radeon_debugfs_remove_files(struct radeon_device *rdev) | |||
1956 | } | 1958 | } |
1957 | #endif | 1959 | #endif |
1958 | } | 1960 | } |
1959 | |||
1960 | #if defined(CONFIG_DEBUG_FS) | ||
1961 | int radeon_debugfs_init(struct drm_minor *minor) | ||
1962 | { | ||
1963 | return 0; | ||
1964 | } | ||
1965 | |||
1966 | void radeon_debugfs_cleanup(struct drm_minor *minor) | ||
1967 | { | ||
1968 | } | ||
1969 | #endif | ||
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 07e44931f1f1..78367ba8bb7d 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
@@ -156,11 +156,6 @@ void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); | |||
156 | extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd, | 156 | extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd, |
157 | unsigned long arg); | 157 | unsigned long arg); |
158 | 158 | ||
159 | #if defined(CONFIG_DEBUG_FS) | ||
160 | int radeon_debugfs_init(struct drm_minor *minor); | ||
161 | void radeon_debugfs_cleanup(struct drm_minor *minor); | ||
162 | #endif | ||
163 | |||
164 | /* atpx handler */ | 159 | /* atpx handler */ |
165 | #if defined(CONFIG_VGA_SWITCHEROO) | 160 | #if defined(CONFIG_VGA_SWITCHEROO) |
166 | void radeon_register_atpx_handler(void); | 161 | void radeon_register_atpx_handler(void); |
@@ -311,6 +306,8 @@ MODULE_DEVICE_TABLE(pci, pciidlist); | |||
311 | 306 | ||
312 | static struct drm_driver kms_driver; | 307 | static struct drm_driver kms_driver; |
313 | 308 | ||
309 | bool radeon_device_is_virtual(void); | ||
310 | |||
314 | static int radeon_kick_out_firmware_fb(struct pci_dev *pdev) | 311 | static int radeon_kick_out_firmware_fb(struct pci_dev *pdev) |
315 | { | 312 | { |
316 | struct apertures_struct *ap; | 313 | struct apertures_struct *ap; |
@@ -364,6 +361,16 @@ radeon_pci_remove(struct pci_dev *pdev) | |||
364 | drm_put_dev(dev); | 361 | drm_put_dev(dev); |
365 | } | 362 | } |
366 | 363 | ||
364 | static void | ||
365 | radeon_pci_shutdown(struct pci_dev *pdev) | ||
366 | { | ||
367 | /* if we are running in a VM, make sure the device | ||
368 | * torn down properly on reboot/shutdown | ||
369 | */ | ||
370 | if (radeon_device_is_virtual()) | ||
371 | radeon_pci_remove(pdev); | ||
372 | } | ||
373 | |||
367 | static int radeon_pmops_suspend(struct device *dev) | 374 | static int radeon_pmops_suspend(struct device *dev) |
368 | { | 375 | { |
369 | struct pci_dev *pdev = to_pci_dev(dev); | 376 | struct pci_dev *pdev = to_pci_dev(dev); |
@@ -375,6 +382,14 @@ static int radeon_pmops_resume(struct device *dev) | |||
375 | { | 382 | { |
376 | struct pci_dev *pdev = to_pci_dev(dev); | 383 | struct pci_dev *pdev = to_pci_dev(dev); |
377 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | 384 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
385 | |||
386 | /* GPU comes up enabled by the bios on resume */ | ||
387 | if (radeon_is_px(drm_dev)) { | ||
388 | pm_runtime_disable(dev); | ||
389 | pm_runtime_set_active(dev); | ||
390 | pm_runtime_enable(dev); | ||
391 | } | ||
392 | |||
378 | return radeon_resume_kms(drm_dev, true, true); | 393 | return radeon_resume_kms(drm_dev, true, true); |
379 | } | 394 | } |
380 | 395 | ||
@@ -531,10 +546,6 @@ static struct drm_driver kms_driver = { | |||
531 | .disable_vblank = radeon_disable_vblank_kms, | 546 | .disable_vblank = radeon_disable_vblank_kms, |
532 | .get_vblank_timestamp = radeon_get_vblank_timestamp_kms, | 547 | .get_vblank_timestamp = radeon_get_vblank_timestamp_kms, |
533 | .get_scanout_position = radeon_get_crtc_scanoutpos, | 548 | .get_scanout_position = radeon_get_crtc_scanoutpos, |
534 | #if defined(CONFIG_DEBUG_FS) | ||
535 | .debugfs_init = radeon_debugfs_init, | ||
536 | .debugfs_cleanup = radeon_debugfs_cleanup, | ||
537 | #endif | ||
538 | .irq_preinstall = radeon_driver_irq_preinstall_kms, | 549 | .irq_preinstall = radeon_driver_irq_preinstall_kms, |
539 | .irq_postinstall = radeon_driver_irq_postinstall_kms, | 550 | .irq_postinstall = radeon_driver_irq_postinstall_kms, |
540 | .irq_uninstall = radeon_driver_irq_uninstall_kms, | 551 | .irq_uninstall = radeon_driver_irq_uninstall_kms, |
@@ -576,6 +587,7 @@ static struct pci_driver radeon_kms_pci_driver = { | |||
576 | .id_table = pciidlist, | 587 | .id_table = pciidlist, |
577 | .probe = radeon_pci_probe, | 588 | .probe = radeon_pci_probe, |
578 | .remove = radeon_pci_remove, | 589 | .remove = radeon_pci_remove, |
590 | .shutdown = radeon_pci_shutdown, | ||
579 | .driver.pm = &radeon_pm_ops, | 591 | .driver.pm = &radeon_pm_ops, |
580 | }; | 592 | }; |
581 | 593 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c index 568e036d547e..0daad446d2c7 100644 --- a/drivers/gpu/drm/radeon/radeon_fb.c +++ b/drivers/gpu/drm/radeon/radeon_fb.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/pm_runtime.h> | ||
28 | 29 | ||
29 | #include <drm/drmP.h> | 30 | #include <drm/drmP.h> |
30 | #include <drm/drm_crtc.h> | 31 | #include <drm/drm_crtc.h> |
@@ -46,8 +47,35 @@ struct radeon_fbdev { | |||
46 | struct radeon_device *rdev; | 47 | struct radeon_device *rdev; |
47 | }; | 48 | }; |
48 | 49 | ||
50 | static int | ||
51 | radeonfb_open(struct fb_info *info, int user) | ||
52 | { | ||
53 | struct radeon_fbdev *rfbdev = info->par; | ||
54 | struct radeon_device *rdev = rfbdev->rdev; | ||
55 | int ret = pm_runtime_get_sync(rdev->ddev->dev); | ||
56 | if (ret < 0 && ret != -EACCES) { | ||
57 | pm_runtime_mark_last_busy(rdev->ddev->dev); | ||
58 | pm_runtime_put_autosuspend(rdev->ddev->dev); | ||
59 | return ret; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int | ||
65 | radeonfb_release(struct fb_info *info, int user) | ||
66 | { | ||
67 | struct radeon_fbdev *rfbdev = info->par; | ||
68 | struct radeon_device *rdev = rfbdev->rdev; | ||
69 | |||
70 | pm_runtime_mark_last_busy(rdev->ddev->dev); | ||
71 | pm_runtime_put_autosuspend(rdev->ddev->dev); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
49 | static struct fb_ops radeonfb_ops = { | 75 | static struct fb_ops radeonfb_ops = { |
50 | .owner = THIS_MODULE, | 76 | .owner = THIS_MODULE, |
77 | .fb_open = radeonfb_open, | ||
78 | .fb_release = radeonfb_release, | ||
51 | .fb_check_var = drm_fb_helper_check_var, | 79 | .fb_check_var = drm_fb_helper_check_var, |
52 | .fb_set_par = drm_fb_helper_set_par, | 80 | .fb_set_par = drm_fb_helper_set_par, |
53 | .fb_fillrect = drm_fb_helper_cfb_fillrect, | 81 | .fb_fillrect = drm_fb_helper_cfb_fillrect, |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 835563c1f0ed..4388ddeec8d2 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -641,11 +641,11 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
641 | if (rdev->family >= CHIP_CAYMAN) { | 641 | if (rdev->family >= CHIP_CAYMAN) { |
642 | struct radeon_fpriv *fpriv; | 642 | struct radeon_fpriv *fpriv; |
643 | struct radeon_vm *vm; | 643 | struct radeon_vm *vm; |
644 | int r; | ||
645 | 644 | ||
646 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); | 645 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); |
647 | if (unlikely(!fpriv)) { | 646 | if (unlikely(!fpriv)) { |
648 | return -ENOMEM; | 647 | r = -ENOMEM; |
648 | goto out_suspend; | ||
649 | } | 649 | } |
650 | 650 | ||
651 | if (rdev->accel_working) { | 651 | if (rdev->accel_working) { |
@@ -653,14 +653,14 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
653 | r = radeon_vm_init(rdev, vm); | 653 | r = radeon_vm_init(rdev, vm); |
654 | if (r) { | 654 | if (r) { |
655 | kfree(fpriv); | 655 | kfree(fpriv); |
656 | return r; | 656 | goto out_suspend; |
657 | } | 657 | } |
658 | 658 | ||
659 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); | 659 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); |
660 | if (r) { | 660 | if (r) { |
661 | radeon_vm_fini(rdev, vm); | 661 | radeon_vm_fini(rdev, vm); |
662 | kfree(fpriv); | 662 | kfree(fpriv); |
663 | return r; | 663 | goto out_suspend; |
664 | } | 664 | } |
665 | 665 | ||
666 | /* map the ib pool buffer read only into | 666 | /* map the ib pool buffer read only into |
@@ -674,15 +674,16 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
674 | if (r) { | 674 | if (r) { |
675 | radeon_vm_fini(rdev, vm); | 675 | radeon_vm_fini(rdev, vm); |
676 | kfree(fpriv); | 676 | kfree(fpriv); |
677 | return r; | 677 | goto out_suspend; |
678 | } | 678 | } |
679 | } | 679 | } |
680 | file_priv->driver_priv = fpriv; | 680 | file_priv->driver_priv = fpriv; |
681 | } | 681 | } |
682 | 682 | ||
683 | out_suspend: | ||
683 | pm_runtime_mark_last_busy(dev->dev); | 684 | pm_runtime_mark_last_busy(dev->dev); |
684 | pm_runtime_put_autosuspend(dev->dev); | 685 | pm_runtime_put_autosuspend(dev->dev); |
685 | return 0; | 686 | return r; |
686 | } | 687 | } |
687 | 688 | ||
688 | /** | 689 | /** |
@@ -717,6 +718,8 @@ void radeon_driver_postclose_kms(struct drm_device *dev, | |||
717 | kfree(fpriv); | 718 | kfree(fpriv); |
718 | file_priv->driver_priv = NULL; | 719 | file_priv->driver_priv = NULL; |
719 | } | 720 | } |
721 | pm_runtime_mark_last_busy(dev->dev); | ||
722 | pm_runtime_put_autosuspend(dev->dev); | ||
720 | } | 723 | } |
721 | 724 | ||
722 | /** | 725 | /** |
@@ -733,6 +736,8 @@ void radeon_driver_preclose_kms(struct drm_device *dev, | |||
733 | { | 736 | { |
734 | struct radeon_device *rdev = dev->dev_private; | 737 | struct radeon_device *rdev = dev->dev_private; |
735 | 738 | ||
739 | pm_runtime_get_sync(dev->dev); | ||
740 | |||
736 | mutex_lock(&rdev->gem.mutex); | 741 | mutex_lock(&rdev->gem.mutex); |
737 | if (rdev->hyperz_filp == file_priv) | 742 | if (rdev->hyperz_filp == file_priv) |
738 | rdev->hyperz_filp = NULL; | 743 | rdev->hyperz_filp = NULL; |
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c2a30bdc8a01..fc6217dfe401 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -57,14 +57,14 @@ static struct attribute ttm_bo_count = { | |||
57 | static inline int ttm_mem_type_from_place(const struct ttm_place *place, | 57 | static inline int ttm_mem_type_from_place(const struct ttm_place *place, |
58 | uint32_t *mem_type) | 58 | uint32_t *mem_type) |
59 | { | 59 | { |
60 | int i; | 60 | int pos; |
61 | 61 | ||
62 | for (i = 0; i <= TTM_PL_PRIV5; i++) | 62 | pos = ffs(place->flags & TTM_PL_MASK_MEM); |
63 | if (place->flags & (1 << i)) { | 63 | if (unlikely(!pos)) |
64 | *mem_type = i; | 64 | return -EINVAL; |
65 | return 0; | 65 | |
66 | } | 66 | *mem_type = pos - 1; |
67 | return -EINVAL; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type) | 70 | static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type) |
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index bef9f6feb635..cec4b4baa179 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | |||
@@ -858,7 +858,6 @@ static int ttm_dma_pool_get_pages(struct dma_pool *pool, | |||
858 | if (count) { | 858 | if (count) { |
859 | d_page = list_first_entry(&pool->free_list, struct dma_page, page_list); | 859 | d_page = list_first_entry(&pool->free_list, struct dma_page, page_list); |
860 | ttm->pages[index] = d_page->p; | 860 | ttm->pages[index] = d_page->p; |
861 | ttm_dma->cpu_address[index] = d_page->vaddr; | ||
862 | ttm_dma->dma_address[index] = d_page->dma; | 861 | ttm_dma->dma_address[index] = d_page->dma; |
863 | list_move_tail(&d_page->page_list, &ttm_dma->pages_list); | 862 | list_move_tail(&d_page->page_list, &ttm_dma->pages_list); |
864 | r = 0; | 863 | r = 0; |
@@ -989,7 +988,6 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev) | |||
989 | INIT_LIST_HEAD(&ttm_dma->pages_list); | 988 | INIT_LIST_HEAD(&ttm_dma->pages_list); |
990 | for (i = 0; i < ttm->num_pages; i++) { | 989 | for (i = 0; i < ttm->num_pages; i++) { |
991 | ttm->pages[i] = NULL; | 990 | ttm->pages[i] = NULL; |
992 | ttm_dma->cpu_address[i] = 0; | ||
993 | ttm_dma->dma_address[i] = 0; | 991 | ttm_dma->dma_address[i] = 0; |
994 | } | 992 | } |
995 | 993 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index bc5aa573f466..aee3c00f836e 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c | |||
@@ -57,10 +57,8 @@ static void ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm) | |||
57 | { | 57 | { |
58 | ttm->ttm.pages = drm_calloc_large(ttm->ttm.num_pages, | 58 | ttm->ttm.pages = drm_calloc_large(ttm->ttm.num_pages, |
59 | sizeof(*ttm->ttm.pages) + | 59 | sizeof(*ttm->ttm.pages) + |
60 | sizeof(*ttm->dma_address) + | 60 | sizeof(*ttm->dma_address)); |
61 | sizeof(*ttm->cpu_address)); | 61 | ttm->dma_address = (void *) (ttm->ttm.pages + ttm->ttm.num_pages); |
62 | ttm->cpu_address = (void *) (ttm->ttm.pages + ttm->ttm.num_pages); | ||
63 | ttm->dma_address = (void *) (ttm->cpu_address + ttm->ttm.num_pages); | ||
64 | } | 62 | } |
65 | 63 | ||
66 | #ifdef CONFIG_X86 | 64 | #ifdef CONFIG_X86 |
@@ -244,7 +242,6 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma) | |||
244 | 242 | ||
245 | drm_free_large(ttm->pages); | 243 | drm_free_large(ttm->pages); |
246 | ttm->pages = NULL; | 244 | ttm->pages = NULL; |
247 | ttm_dma->cpu_address = NULL; | ||
248 | ttm_dma->dma_address = NULL; | 245 | ttm_dma->dma_address = NULL; |
249 | } | 246 | } |
250 | EXPORT_SYMBOL(ttm_dma_tt_fini); | 247 | EXPORT_SYMBOL(ttm_dma_tt_fini); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 74304b03f9d4..070d750af16d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | |||
@@ -67,10 +67,10 @@ | |||
67 | VMWGFX_NUM_GB_SURFACE +\ | 67 | VMWGFX_NUM_GB_SURFACE +\ |
68 | VMWGFX_NUM_GB_SCREEN_TARGET) | 68 | VMWGFX_NUM_GB_SCREEN_TARGET) |
69 | 69 | ||
70 | #define VMW_PL_GMR TTM_PL_PRIV0 | 70 | #define VMW_PL_GMR (TTM_PL_PRIV + 0) |
71 | #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 | 71 | #define VMW_PL_FLAG_GMR (TTM_PL_FLAG_PRIV << 0) |
72 | #define VMW_PL_MOB TTM_PL_PRIV1 | 72 | #define VMW_PL_MOB (TTM_PL_PRIV + 1) |
73 | #define VMW_PL_FLAG_MOB TTM_PL_FLAG_PRIV1 | 73 | #define VMW_PL_FLAG_MOB (TTM_PL_FLAG_PRIV << 1) |
74 | 74 | ||
75 | #define VMW_RES_CONTEXT ttm_driver_type0 | 75 | #define VMW_RES_CONTEXT ttm_driver_type0 |
76 | #define VMW_RES_SURFACE ttm_driver_type1 | 76 | #define VMW_RES_SURFACE ttm_driver_type1 |
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 6f2c59887ba6..9eb940d6755f 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -45,37 +45,7 @@ struct ttm_bo_device; | |||
45 | 45 | ||
46 | struct drm_mm_node; | 46 | struct drm_mm_node; |
47 | 47 | ||
48 | /** | 48 | struct ttm_placement; |
49 | * struct ttm_place | ||
50 | * | ||
51 | * @fpfn: first valid page frame number to put the object | ||
52 | * @lpfn: last valid page frame number to put the object | ||
53 | * @flags: memory domain and caching flags for the object | ||
54 | * | ||
55 | * Structure indicating a possible place to put an object. | ||
56 | */ | ||
57 | struct ttm_place { | ||
58 | unsigned fpfn; | ||
59 | unsigned lpfn; | ||
60 | uint32_t flags; | ||
61 | }; | ||
62 | |||
63 | /** | ||
64 | * struct ttm_placement | ||
65 | * | ||
66 | * @num_placement: number of preferred placements | ||
67 | * @placement: preferred placements | ||
68 | * @num_busy_placement: number of preferred placements when need to evict buffer | ||
69 | * @busy_placement: preferred placements when need to evict buffer | ||
70 | * | ||
71 | * Structure indicating the placement you request for an object. | ||
72 | */ | ||
73 | struct ttm_placement { | ||
74 | unsigned num_placement; | ||
75 | const struct ttm_place *placement; | ||
76 | unsigned num_busy_placement; | ||
77 | const struct ttm_place *busy_placement; | ||
78 | }; | ||
79 | 49 | ||
80 | /** | 50 | /** |
81 | * struct ttm_bus_placement | 51 | * struct ttm_bus_placement |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index c986fa7effd2..4f0a92185995 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -133,7 +133,6 @@ struct ttm_tt { | |||
133 | * struct ttm_dma_tt | 133 | * struct ttm_dma_tt |
134 | * | 134 | * |
135 | * @ttm: Base ttm_tt struct. | 135 | * @ttm: Base ttm_tt struct. |
136 | * @cpu_address: The CPU address of the pages | ||
137 | * @dma_address: The DMA (bus) addresses of the pages | 136 | * @dma_address: The DMA (bus) addresses of the pages |
138 | * @pages_list: used by some page allocation backend | 137 | * @pages_list: used by some page allocation backend |
139 | * | 138 | * |
@@ -143,7 +142,6 @@ struct ttm_tt { | |||
143 | */ | 142 | */ |
144 | struct ttm_dma_tt { | 143 | struct ttm_dma_tt { |
145 | struct ttm_tt ttm; | 144 | struct ttm_tt ttm; |
146 | void **cpu_address; | ||
147 | dma_addr_t *dma_address; | 145 | dma_addr_t *dma_address; |
148 | struct list_head pages_list; | 146 | struct list_head pages_list; |
149 | }; | 147 | }; |
diff --git a/include/drm/ttm/ttm_placement.h b/include/drm/ttm/ttm_placement.h index 8ed44f9bbdfb..932be0c8086e 100644 --- a/include/drm/ttm/ttm_placement.h +++ b/include/drm/ttm/ttm_placement.h | |||
@@ -30,6 +30,9 @@ | |||
30 | 30 | ||
31 | #ifndef _TTM_PLACEMENT_H_ | 31 | #ifndef _TTM_PLACEMENT_H_ |
32 | #define _TTM_PLACEMENT_H_ | 32 | #define _TTM_PLACEMENT_H_ |
33 | |||
34 | #include <linux/types.h> | ||
35 | |||
33 | /* | 36 | /* |
34 | * Memory regions for data placement. | 37 | * Memory regions for data placement. |
35 | */ | 38 | */ |
@@ -37,24 +40,12 @@ | |||
37 | #define TTM_PL_SYSTEM 0 | 40 | #define TTM_PL_SYSTEM 0 |
38 | #define TTM_PL_TT 1 | 41 | #define TTM_PL_TT 1 |
39 | #define TTM_PL_VRAM 2 | 42 | #define TTM_PL_VRAM 2 |
40 | #define TTM_PL_PRIV0 3 | 43 | #define TTM_PL_PRIV 3 |
41 | #define TTM_PL_PRIV1 4 | ||
42 | #define TTM_PL_PRIV2 5 | ||
43 | #define TTM_PL_PRIV3 6 | ||
44 | #define TTM_PL_PRIV4 7 | ||
45 | #define TTM_PL_PRIV5 8 | ||
46 | #define TTM_PL_SWAPPED 15 | ||
47 | 44 | ||
48 | #define TTM_PL_FLAG_SYSTEM (1 << TTM_PL_SYSTEM) | 45 | #define TTM_PL_FLAG_SYSTEM (1 << TTM_PL_SYSTEM) |
49 | #define TTM_PL_FLAG_TT (1 << TTM_PL_TT) | 46 | #define TTM_PL_FLAG_TT (1 << TTM_PL_TT) |
50 | #define TTM_PL_FLAG_VRAM (1 << TTM_PL_VRAM) | 47 | #define TTM_PL_FLAG_VRAM (1 << TTM_PL_VRAM) |
51 | #define TTM_PL_FLAG_PRIV0 (1 << TTM_PL_PRIV0) | 48 | #define TTM_PL_FLAG_PRIV (1 << TTM_PL_PRIV) |
52 | #define TTM_PL_FLAG_PRIV1 (1 << TTM_PL_PRIV1) | ||
53 | #define TTM_PL_FLAG_PRIV2 (1 << TTM_PL_PRIV2) | ||
54 | #define TTM_PL_FLAG_PRIV3 (1 << TTM_PL_PRIV3) | ||
55 | #define TTM_PL_FLAG_PRIV4 (1 << TTM_PL_PRIV4) | ||
56 | #define TTM_PL_FLAG_PRIV5 (1 << TTM_PL_PRIV5) | ||
57 | #define TTM_PL_FLAG_SWAPPED (1 << TTM_PL_SWAPPED) | ||
58 | #define TTM_PL_MASK_MEM 0x0000FFFF | 49 | #define TTM_PL_MASK_MEM 0x0000FFFF |
59 | 50 | ||
60 | /* | 51 | /* |
@@ -72,7 +63,6 @@ | |||
72 | #define TTM_PL_FLAG_CACHED (1 << 16) | 63 | #define TTM_PL_FLAG_CACHED (1 << 16) |
73 | #define TTM_PL_FLAG_UNCACHED (1 << 17) | 64 | #define TTM_PL_FLAG_UNCACHED (1 << 17) |
74 | #define TTM_PL_FLAG_WC (1 << 18) | 65 | #define TTM_PL_FLAG_WC (1 << 18) |
75 | #define TTM_PL_FLAG_SHARED (1 << 20) | ||
76 | #define TTM_PL_FLAG_NO_EVICT (1 << 21) | 66 | #define TTM_PL_FLAG_NO_EVICT (1 << 21) |
77 | #define TTM_PL_FLAG_TOPDOWN (1 << 22) | 67 | #define TTM_PL_FLAG_TOPDOWN (1 << 22) |
78 | 68 | ||
@@ -82,14 +72,36 @@ | |||
82 | 72 | ||
83 | #define TTM_PL_MASK_MEMTYPE (TTM_PL_MASK_MEM | TTM_PL_MASK_CACHING) | 73 | #define TTM_PL_MASK_MEMTYPE (TTM_PL_MASK_MEM | TTM_PL_MASK_CACHING) |
84 | 74 | ||
85 | /* | 75 | /** |
86 | * Access flags to be used for CPU- and GPU- mappings. | 76 | * struct ttm_place |
87 | * The idea is that the TTM synchronization mechanism will | 77 | * |
88 | * allow concurrent READ access and exclusive write access. | 78 | * @fpfn: first valid page frame number to put the object |
89 | * Currently GPU- and CPU accesses are exclusive. | 79 | * @lpfn: last valid page frame number to put the object |
80 | * @flags: memory domain and caching flags for the object | ||
81 | * | ||
82 | * Structure indicating a possible place to put an object. | ||
90 | */ | 83 | */ |
84 | struct ttm_place { | ||
85 | unsigned fpfn; | ||
86 | unsigned lpfn; | ||
87 | uint32_t flags; | ||
88 | }; | ||
91 | 89 | ||
92 | #define TTM_ACCESS_READ (1 << 0) | 90 | /** |
93 | #define TTM_ACCESS_WRITE (1 << 1) | 91 | * struct ttm_placement |
92 | * | ||
93 | * @num_placement: number of preferred placements | ||
94 | * @placement: preferred placements | ||
95 | * @num_busy_placement: number of preferred placements when need to evict buffer | ||
96 | * @busy_placement: preferred placements when need to evict buffer | ||
97 | * | ||
98 | * Structure indicating the placement you request for an object. | ||
99 | */ | ||
100 | struct ttm_placement { | ||
101 | unsigned num_placement; | ||
102 | const struct ttm_place *placement; | ||
103 | unsigned num_busy_placement; | ||
104 | const struct ttm_place *busy_placement; | ||
105 | }; | ||
94 | 106 | ||
95 | #endif | 107 | #endif |
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index ae2845fdcb5f..d6b5a21f3d3c 100644 --- a/include/uapi/drm/amdgpu_drm.h +++ b/include/uapi/drm/amdgpu_drm.h | |||
@@ -649,6 +649,7 @@ struct drm_amdgpu_info_hw_ip { | |||
649 | * Supported GPU families | 649 | * Supported GPU families |
650 | */ | 650 | */ |
651 | #define AMDGPU_FAMILY_UNKNOWN 0 | 651 | #define AMDGPU_FAMILY_UNKNOWN 0 |
652 | #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */ | ||
652 | #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */ | 653 | #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */ |
653 | #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */ | 654 | #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */ |
654 | #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */ | 655 | #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */ |