162a37553SKen Wang /* 262a37553SKen Wang * Copyright 2015 Advanced Micro Devices, Inc. 362a37553SKen Wang * 462a37553SKen Wang * Permission is hereby granted, free of charge, to any person obtaining a 562a37553SKen Wang * copy of this software and associated documentation files (the "Software"), 662a37553SKen Wang * to deal in the Software without restriction, including without limitation 762a37553SKen Wang * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862a37553SKen Wang * and/or sell copies of the Software, and to permit persons to whom the 962a37553SKen Wang * Software is furnished to do so, subject to the following conditions: 1062a37553SKen Wang * 1162a37553SKen Wang * The above copyright notice and this permission notice shall be included in 1262a37553SKen Wang * all copies or substantial portions of the Software. 1362a37553SKen Wang * 1462a37553SKen Wang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562a37553SKen Wang * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662a37553SKen Wang * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762a37553SKen Wang * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862a37553SKen Wang * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962a37553SKen Wang * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062a37553SKen Wang * OTHER DEALINGS IN THE SOFTWARE. 2162a37553SKen Wang * 2262a37553SKen Wang */ 2362a37553SKen Wang 2462a37553SKen Wang #include <linux/firmware.h> 2562a37553SKen Wang #include <linux/slab.h> 2662a37553SKen Wang #include <linux/module.h> 2747b757fbSSam Ravnborg #include <linux/pci.h> 2847b757fbSSam Ravnborg 296f786950SAlex Deucher #include <drm/amdgpu_drm.h> 306f786950SAlex Deucher 3162a37553SKen Wang #include "amdgpu.h" 3262a37553SKen Wang #include "amdgpu_atombios.h" 3362a37553SKen Wang #include "amdgpu_ih.h" 3462a37553SKen Wang #include "amdgpu_uvd.h" 3562a37553SKen Wang #include "amdgpu_vce.h" 3662a37553SKen Wang #include "atom.h" 370bf67185SAlex Deucher #include "amd_pcie.h" 38b905090dSRex Zhu #include "si_dpm.h" 39689957b1SAlex Deucher #include "sid.h" 4062a37553SKen Wang #include "si_ih.h" 4162a37553SKen Wang #include "gfx_v6_0.h" 4262a37553SKen Wang #include "gmc_v6_0.h" 4362a37553SKen Wang #include "si_dma.h" 4462a37553SKen Wang #include "dce_v6_0.h" 4562a37553SKen Wang #include "si.h" 46d375615cSSonny Jiang #include "uvd_v3_1.h" 47733ee71aSRyan Taylor #include "amdgpu_vkms.h" 4878bbe771STom St Denis #include "gca/gfx_6_0_d.h" 4978bbe771STom St Denis #include "oss/oss_1_0_d.h" 509c39d77cSAlex Deucher #include "oss/oss_1_0_sh_mask.h" 5178bbe771STom St Denis #include "gmc/gmc_6_0_d.h" 5278bbe771STom St Denis #include "dce/dce_6_0_d.h" 5378bbe771STom St Denis #include "uvd/uvd_4_0_d.h" 54bbf282d8SAlex Deucher #include "bif/bif_3_0_d.h" 55b45e18acSKent Russell #include "bif/bif_3_0_sh_mask.h" 5662a37553SKen Wang 5764200c46SMauro Rossi #include "amdgpu_dm.h" 5864200c46SMauro Rossi 5962a37553SKen Wang static const u32 tahiti_golden_registers[] = 6062a37553SKen Wang { 6178bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 6278bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 6378bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 6478bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 6578bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 6678bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 677c0a705eSFlora Cui 0x340c, 0x000000c0, 0x00800040, 687c0a705eSFlora Cui 0x360c, 0x000000c0, 0x00800040, 6978bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 7078bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 7178bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 7278bbe771STom St Denis mmMC_ARB_WTM_CNTL_RD, 0x00000003, 0x000007ff, 7378bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 7478bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 7578bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 7678bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 7778bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 7878bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, 797c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0040, 8062a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 8178bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 8278bbe771STom St Denis mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, 8378bbe771STom St Denis mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, 8478bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 8578bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 8678bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x00000200, 0x000002fb, 8778bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, 8878bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, 8978bbe771STom St Denis mmVGT_FIFO_DEPTHS, 0xffffffff, 0x000fff40, 9078bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 9178bbe771STom St Denis mmVM_CONTEXT0_CNTL, 0x20000000, 0x20fffed8, 9278bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 9378bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 9478bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 9578bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 9678bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 9762a37553SKen Wang }; 9862a37553SKen Wang 9962a37553SKen Wang static const u32 tahiti_golden_registers2[] = 10062a37553SKen Wang { 10178bbe771STom St Denis mmMCIF_MEM_CONTROL, 0x00000001, 0x00000001, 10262a37553SKen Wang }; 10362a37553SKen Wang 10462a37553SKen Wang static const u32 tahiti_golden_rlc_registers[] = 10562a37553SKen Wang { 10678bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, 10778bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, 10862a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 10962a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 11078bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 11178bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, 11278bbe771STom St Denis mmUVD_CGC_GATE, 0x00000008, 0x00000000, 11362a37553SKen Wang }; 11462a37553SKen Wang 11562a37553SKen Wang static const u32 pitcairn_golden_registers[] = 11662a37553SKen Wang { 11778bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 11878bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 11978bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 12078bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 12178bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 12278bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 12362a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 12462a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 12578bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 12678bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 12778bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 12878bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 12978bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 13078bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 13178bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 13278bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 13378bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 13478bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, 1351245a694SFlora Cui 0x000c, 0xffffffff, 0x0040, 13662a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 13778bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 13878bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 13978bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 14078bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f7, 14178bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 14278bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x32761054, 14378bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 14478bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 14578bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 14678bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14778bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14878bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14962a37553SKen Wang }; 15062a37553SKen Wang 15162a37553SKen Wang static const u32 pitcairn_golden_rlc_registers[] = 15262a37553SKen Wang { 15378bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, 15478bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601004, 15562a37553SKen Wang 0x311f, 0xffffffff, 0x10102020, 15662a37553SKen Wang 0x3122, 0xffffffff, 0x01000020, 15778bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 15878bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000a4, 15962a37553SKen Wang }; 16062a37553SKen Wang 16162a37553SKen Wang static const u32 verde_pg_init[] = 16262a37553SKen Wang { 16378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x40000, 16478bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x200010ff, 16578bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16678bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16778bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16878bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16978bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 17078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x7007, 17178bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x300010ff, 17278bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 17378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 17478bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 17578bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 17678bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 17778bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x400000, 17878bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x100010ff, 17978bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18278bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18478bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x120200, 18578bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x500010ff, 18678bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18778bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18878bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 18978bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x1e1e16, 19278bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x600010ff, 19378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19478bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19578bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19678bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19778bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19878bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x171f1e, 19978bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x700010ff, 20078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20278bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20478bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20578bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20678bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x9ff, 20778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x0, 20878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10000800, 20978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, 21078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, 21178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4, 21278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1000051e, 21378bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, 21478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, 21578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x8, 21678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x80500, 21778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x12, 21878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x9050c, 21978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1d, 22078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xb052c, 22178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2a, 22278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1053e, 22378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2d, 22478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10546, 22578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x30, 22678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xa054e, 22778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3c, 22878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1055f, 22978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3f, 23078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10567, 23178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x42, 23278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1056f, 23378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x45, 23478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10572, 23578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x48, 23678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20575, 23778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4c, 23878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x190801, 23978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x67, 24078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1082a, 24178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x6a, 24278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1b082d, 24378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x87, 24478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x310851, 24578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xba, 24678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x891, 24778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbc, 24878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x893, 24978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbe, 25078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20895, 25178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc2, 25278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20899, 25378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc6, 25478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2089d, 25578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xca, 25678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a1, 25778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xcc, 25878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a3, 25978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xce, 26078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x308a5, 26178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xd3, 26278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x6d08cd, 26378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x142, 26478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2000095a, 26578bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1, 26678bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x144, 26778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x301f095b, 26878bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x165, 26978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc094d, 27078bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x173, 27178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf096d, 27278bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x184, 27378bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x15097f, 27478bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x19b, 27578bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc0998, 27678bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1a9, 27778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x409a7, 27878bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1af, 27978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xcdc, 28078bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1b1, 28178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x800, 28278bbe771STom St Denis mmGMCON_RENG_EXECUTE, 0xffffffff, 0x6c9b2000, 28378bbe771STom St Denis mmGMCON_MISC2, 0xfc00, 0x2000, 28478bbe771STom St Denis mmGMCON_MISC3, 0xffffffff, 0xfc0, 28578bbe771STom St Denis mmMC_PMG_AUTO_CFG, 0x00000100, 0x100, 28662a37553SKen Wang }; 28762a37553SKen Wang 28862a37553SKen Wang static const u32 verde_golden_rlc_registers[] = 28962a37553SKen Wang { 29078bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, 29178bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x033f1005, 29262a37553SKen Wang 0x311f, 0xffffffff, 0x10808020, 29362a37553SKen Wang 0x3122, 0xffffffff, 0x00800008, 29478bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00001000, 29578bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x80010014, 29662a37553SKen Wang }; 29762a37553SKen Wang 29862a37553SKen Wang static const u32 verde_golden_registers[] = 29962a37553SKen Wang { 30078bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 30178bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 30278bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 30378bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 30478bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 30578bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 30662a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 30762a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 30878bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 30978bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 31078bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 31178bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 31278bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 31378bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 31478bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 31578bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 31678bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 31778bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x0000124a, 318dae5c298SFlora Cui 0x000c, 0xffffffff, 0x0040, 31962a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 32078bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 32178bbe771STom St Denis mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, 32278bbe771STom St Denis mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, 32378bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 32478bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 32578bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x00000003, 32678bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 32778bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00001032, 32878bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 32978bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 33078bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 33178bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 33278bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 33378bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 33462a37553SKen Wang }; 33562a37553SKen Wang 33662a37553SKen Wang static const u32 oland_golden_registers[] = 33762a37553SKen Wang { 33878bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 33978bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 34078bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 34178bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 34278bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 34378bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 34462a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 34562a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 34678bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 34778bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 34878bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 34978bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 35078bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 35178bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 35278bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 35378bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 35478bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 35578bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000082, 3566b7985efSFlora Cui 0x000c, 0xffffffff, 0x0040, 35762a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 35878bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 35978bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 36078bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 36178bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f3, 36278bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 36378bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, 36478bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 36578bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 36678bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 36778bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36878bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36978bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 37078bbe771STom St Denis 37162a37553SKen Wang }; 37262a37553SKen Wang 37362a37553SKen Wang static const u32 oland_golden_rlc_registers[] = 37462a37553SKen Wang { 37578bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, 37678bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, 37762a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 37862a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 37978bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 38078bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, 38162a37553SKen Wang }; 38262a37553SKen Wang 38362a37553SKen Wang static const u32 hainan_golden_registers[] = 38462a37553SKen Wang { 385bd27b678SFlora Cui 0x17bc, 0x00000030, 0x00000011, 38678bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 38778bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 38878bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 38978bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 390bd27b678SFlora Cui 0x031e, 0x00000080, 0x00000000, 391bd27b678SFlora Cui 0x3430, 0xff000fff, 0x00000100, 39262a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 39362a37553SKen Wang 0x3630, 0xff000fff, 0x00000100, 39462a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 395bd27b678SFlora Cui 0x16ec, 0x000000f0, 0x00000070, 396bd27b678SFlora Cui 0x16f0, 0x00200000, 0x50100000, 397bd27b678SFlora Cui 0x1c0c, 0x31000311, 0x00000011, 39878bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 39978bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 40078bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 40178bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 40278bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 40378bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 40478bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000000, 405bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0040, 40662a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 40778bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x03e00000, 0x03600000, 40878bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 40978bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 41078bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f1, 41178bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 41278bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, 41378bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 41478bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 41578bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 41678bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41778bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41878bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41962a37553SKen Wang }; 42062a37553SKen Wang 42162a37553SKen Wang static const u32 hainan_golden_registers2[] = 42262a37553SKen Wang { 42378bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x2011003, 42462a37553SKen Wang }; 42562a37553SKen Wang 42662a37553SKen Wang static const u32 tahiti_mgcg_cgcg_init[] = 42762a37553SKen Wang { 42878bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 42978bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 43078bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 43178bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 43278bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 43378bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 43478bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 43578bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 43678bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 43778bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 43878bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 43978bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 44078bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 44178bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 44278bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 44378bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 44478bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 44578bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 44678bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 44778bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 44878bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 44978bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 45078bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 45178bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 45278bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 45378bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 45478bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 45562a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 45662a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 45762a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 45862a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 45962a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 46062a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 46162a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 46262a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 46362a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 46462a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 46562a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 46662a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 46762a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 46862a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 46962a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 47062a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 47162a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 47262a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 47362a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 47462a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 47562a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 47662a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 47762a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 47862a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 47962a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 48062a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 48162a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 48262a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 48362a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 48462a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 48562a37553SKen Wang 0x2476, 0xffffffff, 0x00070006, 48662a37553SKen Wang 0x2477, 0xffffffff, 0x00090008, 48762a37553SKen Wang 0x2478, 0xffffffff, 0x0000000c, 48862a37553SKen Wang 0x2479, 0xffffffff, 0x000b000a, 48962a37553SKen Wang 0x247a, 0xffffffff, 0x000e000d, 49062a37553SKen Wang 0x247b, 0xffffffff, 0x00080007, 49162a37553SKen Wang 0x247c, 0xffffffff, 0x000a0009, 49262a37553SKen Wang 0x247d, 0xffffffff, 0x0000000d, 49362a37553SKen Wang 0x247e, 0xffffffff, 0x000c000b, 49462a37553SKen Wang 0x247f, 0xffffffff, 0x000f000e, 49562a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 49662a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 49762a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 49862a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 49962a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 50062a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 50162a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 50262a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 50362a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 50462a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 50562a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 50662a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 50762a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 50862a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 50962a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 51062a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 51162a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 51262a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 51362a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 51462a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 51562a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 51662a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 51762a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 51862a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 51962a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 52062a37553SKen Wang 0x2499, 0xffffffff, 0x000e000d, 52162a37553SKen Wang 0x249a, 0xffffffff, 0x0010000f, 52262a37553SKen Wang 0x249b, 0xffffffff, 0x00000013, 52362a37553SKen Wang 0x249c, 0xffffffff, 0x00120011, 52462a37553SKen Wang 0x249d, 0xffffffff, 0x00150014, 52562a37553SKen Wang 0x249e, 0xffffffff, 0x000f000e, 52662a37553SKen Wang 0x249f, 0xffffffff, 0x00110010, 52762a37553SKen Wang 0x24a0, 0xffffffff, 0x00000014, 52862a37553SKen Wang 0x24a1, 0xffffffff, 0x00130012, 52962a37553SKen Wang 0x24a2, 0xffffffff, 0x00160015, 53062a37553SKen Wang 0x24a3, 0xffffffff, 0x0010000f, 53162a37553SKen Wang 0x24a4, 0xffffffff, 0x00120011, 53262a37553SKen Wang 0x24a5, 0xffffffff, 0x00000015, 53362a37553SKen Wang 0x24a6, 0xffffffff, 0x00140013, 53462a37553SKen Wang 0x24a7, 0xffffffff, 0x00170016, 53578bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 53678bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 53778bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 53878bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 5397c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 5407c0a705eSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 5417c0a705eSFlora Cui 0x0583, 0xffffffff, 0x00000100, 54278bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 54378bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 54478bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 54578bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 54678bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 54778bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 54862a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 54978bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 55078bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 55178bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 55262a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 55378bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 55462a37553SKen Wang }; 55562a37553SKen Wang static const u32 pitcairn_mgcg_cgcg_init[] = 55662a37553SKen Wang { 55778bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 55878bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 55978bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 56078bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 56178bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 56278bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 56378bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 56478bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 56578bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 56678bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 56778bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 56878bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 56978bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 57078bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 57178bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 57278bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 57378bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 57478bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 57578bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 57678bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 57778bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 57878bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 57978bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 58078bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 58178bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 58278bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 58378bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 58462a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 58562a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 58662a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 58762a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 58862a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 58962a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 59062a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 59162a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 59262a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 59362a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 59462a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 59562a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 59662a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 59762a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 59862a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 59962a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 60062a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 60162a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 60262a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 60362a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 60462a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 60562a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 60662a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 60762a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 60862a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 60962a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 61062a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 61162a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 61262a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 61362a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 61462a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 61562a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 61662a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 61762a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 61862a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 61962a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 62062a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 62162a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 62262a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 62362a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 62462a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 62562a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 62662a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 62762a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 62862a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 62962a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 63062a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 63162a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 63262a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 63362a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 63478bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 63578bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 63678bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 63778bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 6381245a694SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 6391245a694SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 6401245a694SFlora Cui 0x0583, 0xffffffff, 0x00000100, 64178bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 64278bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 64378bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 64478bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 64562a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 64678bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 64778bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 64878bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 64962a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 65078bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 65162a37553SKen Wang }; 65278bbe771STom St Denis 65362a37553SKen Wang static const u32 verde_mgcg_cgcg_init[] = 65462a37553SKen Wang { 65578bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 65678bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 65778bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 65878bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 65978bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 66078bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 66178bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 66278bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 66378bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 66478bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 66578bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 66678bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 66778bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 66878bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 66978bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 67078bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 67178bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 67278bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 67378bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 67478bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 67578bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 67678bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 67778bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 67878bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 67978bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 68078bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 68178bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 68262a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 68362a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 68462a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 68562a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 68662a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 68762a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 68862a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 68962a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 69062a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 69162a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 69262a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 69362a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 69462a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 69562a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 69662a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 69762a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 69862a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 69962a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 70062a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 70162a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 70262a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 70362a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 70462a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 70562a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 70662a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 70762a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 70862a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 70962a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 71062a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 71162a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 71262a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 71362a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 71462a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 71562a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 71662a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 71762a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 71862a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 71962a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 72062a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 72162a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 72262a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 72362a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 72462a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 72562a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 72662a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 72762a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 72862a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 72962a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 73062a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 73162a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 73278bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 73378bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 73478bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 73578bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 736dae5c298SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 737dae5c298SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 738dae5c298SFlora Cui 0x0583, 0xffffffff, 0x00000100, 73978bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 74078bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 74178bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 74278bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 74378bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 74478bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 74562a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 74678bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 74778bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 74878bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 74962a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 75078bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 75162a37553SKen Wang }; 75278bbe771STom St Denis 75362a37553SKen Wang static const u32 oland_mgcg_cgcg_init[] = 75462a37553SKen Wang { 75578bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 75678bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 75778bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 75878bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 75978bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 76078bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 76178bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 76278bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 76378bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 76478bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 76578bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 76678bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 76778bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 76878bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 76978bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 77078bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 77178bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 77278bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 77378bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 77478bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 77578bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 77678bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 77778bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 77878bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 77978bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 78078bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 78178bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 78262a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 78362a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 78462a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 78562a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 78662a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 78762a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 78862a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 78962a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 79062a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 79162a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 79262a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 79362a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 79462a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 79562a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 79662a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 79762a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 79862a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 79962a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 80062a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 80162a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 80262a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 80362a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 80462a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 80562a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 80662a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 80762a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 80862a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 80962a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 81062a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 81162a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 81278bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 81378bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 81478bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 81578bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 8166b7985efSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 8176b7985efSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 8186b7985efSFlora Cui 0x0583, 0xffffffff, 0x00000100, 81978bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 82078bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 82178bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 82278bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 82378bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 82478bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 82562a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 82678bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 82778bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 82878bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 82962a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 83078bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 83162a37553SKen Wang }; 83278bbe771STom St Denis 83362a37553SKen Wang static const u32 hainan_mgcg_cgcg_init[] = 83462a37553SKen Wang { 83578bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 83678bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 83778bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 83878bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 83978bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 84078bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 84178bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 84278bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 84378bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 84478bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 84578bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 84678bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 84778bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 84878bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 84978bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 85078bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 85178bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 85278bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 85378bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 85478bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 85578bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 85678bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 85778bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 85878bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 85978bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 86078bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 86178bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 86262a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 86362a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 86462a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 86562a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 86662a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 86762a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 86862a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 86962a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 87062a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 87162a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 87262a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 87362a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 87462a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 87562a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 87662a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 87762a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 87862a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 87962a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 88062a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 88162a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 88262a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 88362a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 88462a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 88562a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 88662a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 88762a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 88862a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 88962a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 89062a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 89162a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 89278bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 89378bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 89478bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 89578bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 896bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 897bd27b678SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 898bd27b678SFlora Cui 0x0583, 0xffffffff, 0x00000100, 899bd27b678SFlora Cui 0x0409, 0xffffffff, 0x00000100, 90078bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 90178bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 90278bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 90378bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 90478bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 90578bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 90662a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 90778bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 90862a37553SKen Wang }; 90962a37553SKen Wang 9103b246e8bSAlex Deucher /* XXX: update when we support VCE */ 9113b246e8bSAlex Deucher #if 0 9123b246e8bSAlex Deucher /* tahiti, pitcarin, verde */ 9133b246e8bSAlex Deucher static const struct amdgpu_video_codec_info tahiti_video_codecs_encode_array[] = 9143b246e8bSAlex Deucher { 9153b246e8bSAlex Deucher { 9166f786950SAlex Deucher .codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, 9173b246e8bSAlex Deucher .max_width = 2048, 9183b246e8bSAlex Deucher .max_height = 1152, 9193b246e8bSAlex Deucher .max_pixels_per_frame = 2048 * 1152, 9203b246e8bSAlex Deucher .max_level = 0, 9213b246e8bSAlex Deucher }, 9223b246e8bSAlex Deucher }; 9233b246e8bSAlex Deucher 9243b246e8bSAlex Deucher static const struct amdgpu_video_codecs tahiti_video_codecs_encode = 9253b246e8bSAlex Deucher { 9263b246e8bSAlex Deucher .codec_count = ARRAY_SIZE(tahiti_video_codecs_encode_array), 9273b246e8bSAlex Deucher .codec_array = tahiti_video_codecs_encode_array, 9283b246e8bSAlex Deucher }; 9293b246e8bSAlex Deucher #else 9303b246e8bSAlex Deucher static const struct amdgpu_video_codecs tahiti_video_codecs_encode = 9313b246e8bSAlex Deucher { 9323b246e8bSAlex Deucher .codec_count = 0, 9333b246e8bSAlex Deucher .codec_array = NULL, 9343b246e8bSAlex Deucher }; 9353b246e8bSAlex Deucher #endif 9363b246e8bSAlex Deucher /* oland and hainan don't support encode */ 9373b246e8bSAlex Deucher static const struct amdgpu_video_codecs hainan_video_codecs_encode = 9383b246e8bSAlex Deucher { 9393b246e8bSAlex Deucher .codec_count = 0, 9403b246e8bSAlex Deucher .codec_array = NULL, 9413b246e8bSAlex Deucher }; 9423b246e8bSAlex Deucher 9433b246e8bSAlex Deucher /* tahiti, pitcarin, verde, oland */ 9443b246e8bSAlex Deucher static const struct amdgpu_video_codec_info tahiti_video_codecs_decode_array[] = 9453b246e8bSAlex Deucher { 9463b246e8bSAlex Deucher { 9476f786950SAlex Deucher .codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2, 9483b246e8bSAlex Deucher .max_width = 2048, 9493b246e8bSAlex Deucher .max_height = 1152, 9503b246e8bSAlex Deucher .max_pixels_per_frame = 2048 * 1152, 9513b246e8bSAlex Deucher .max_level = 3, 9523b246e8bSAlex Deucher }, 9533b246e8bSAlex Deucher { 9546f786950SAlex Deucher .codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4, 9553b246e8bSAlex Deucher .max_width = 2048, 9563b246e8bSAlex Deucher .max_height = 1152, 9573b246e8bSAlex Deucher .max_pixels_per_frame = 2048 * 1152, 9583b246e8bSAlex Deucher .max_level = 5, 9593b246e8bSAlex Deucher }, 9603b246e8bSAlex Deucher { 9616f786950SAlex Deucher .codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, 9623b246e8bSAlex Deucher .max_width = 2048, 9633b246e8bSAlex Deucher .max_height = 1152, 9643b246e8bSAlex Deucher .max_pixels_per_frame = 2048 * 1152, 9653b246e8bSAlex Deucher .max_level = 41, 9663b246e8bSAlex Deucher }, 9673b246e8bSAlex Deucher { 9686f786950SAlex Deucher .codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1, 9693b246e8bSAlex Deucher .max_width = 2048, 9703b246e8bSAlex Deucher .max_height = 1152, 9713b246e8bSAlex Deucher .max_pixels_per_frame = 2048 * 1152, 9723b246e8bSAlex Deucher .max_level = 4, 9733b246e8bSAlex Deucher }, 9743b246e8bSAlex Deucher }; 9753b246e8bSAlex Deucher 9763b246e8bSAlex Deucher static const struct amdgpu_video_codecs tahiti_video_codecs_decode = 9773b246e8bSAlex Deucher { 9783b246e8bSAlex Deucher .codec_count = ARRAY_SIZE(tahiti_video_codecs_decode_array), 9793b246e8bSAlex Deucher .codec_array = tahiti_video_codecs_decode_array, 9803b246e8bSAlex Deucher }; 9813b246e8bSAlex Deucher 9823b246e8bSAlex Deucher /* hainan doesn't support decode */ 9833b246e8bSAlex Deucher static const struct amdgpu_video_codecs hainan_video_codecs_decode = 9843b246e8bSAlex Deucher { 9853b246e8bSAlex Deucher .codec_count = 0, 9863b246e8bSAlex Deucher .codec_array = NULL, 9873b246e8bSAlex Deucher }; 9883b246e8bSAlex Deucher 9893b246e8bSAlex Deucher static int si_query_video_codecs(struct amdgpu_device *adev, bool encode, 9903b246e8bSAlex Deucher const struct amdgpu_video_codecs **codecs) 9913b246e8bSAlex Deucher { 9923b246e8bSAlex Deucher switch (adev->asic_type) { 9933b246e8bSAlex Deucher case CHIP_VERDE: 9943b246e8bSAlex Deucher case CHIP_TAHITI: 9953b246e8bSAlex Deucher case CHIP_PITCAIRN: 9963b246e8bSAlex Deucher if (encode) 9973b246e8bSAlex Deucher *codecs = &tahiti_video_codecs_encode; 9983b246e8bSAlex Deucher else 9993b246e8bSAlex Deucher *codecs = &tahiti_video_codecs_decode; 10003b246e8bSAlex Deucher return 0; 10013b246e8bSAlex Deucher case CHIP_OLAND: 10023b246e8bSAlex Deucher if (encode) 10033b246e8bSAlex Deucher *codecs = &hainan_video_codecs_encode; 10043b246e8bSAlex Deucher else 10053b246e8bSAlex Deucher *codecs = &tahiti_video_codecs_decode; 10063b246e8bSAlex Deucher return 0; 10073b246e8bSAlex Deucher case CHIP_HAINAN: 10083b246e8bSAlex Deucher if (encode) 10093b246e8bSAlex Deucher *codecs = &hainan_video_codecs_encode; 10103b246e8bSAlex Deucher else 10113b246e8bSAlex Deucher *codecs = &hainan_video_codecs_decode; 10123b246e8bSAlex Deucher return 0; 10133b246e8bSAlex Deucher default: 10143b246e8bSAlex Deucher return -EINVAL; 10153b246e8bSAlex Deucher } 10163b246e8bSAlex Deucher } 10173b246e8bSAlex Deucher 101862a37553SKen Wang static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg) 101962a37553SKen Wang { 102062a37553SKen Wang unsigned long flags; 102162a37553SKen Wang u32 r; 102262a37553SKen Wang 102362a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 102462a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 102562a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 102662a37553SKen Wang r = RREG32(AMDGPU_PCIE_DATA); 102762a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 102862a37553SKen Wang return r; 102962a37553SKen Wang } 103062a37553SKen Wang 103162a37553SKen Wang static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 103262a37553SKen Wang { 103362a37553SKen Wang unsigned long flags; 103462a37553SKen Wang 103562a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 103662a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 103762a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 103862a37553SKen Wang WREG32(AMDGPU_PCIE_DATA, v); 103962a37553SKen Wang (void)RREG32(AMDGPU_PCIE_DATA); 104062a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 104162a37553SKen Wang } 104262a37553SKen Wang 1043d1936cc2SBaoyou Xie static u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) 104436b9a952SHuang Rui { 104536b9a952SHuang Rui unsigned long flags; 104636b9a952SHuang Rui u32 r; 104736b9a952SHuang Rui 104836b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 104936b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 105036b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 105136b9a952SHuang Rui r = RREG32(PCIE_PORT_DATA); 105236b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 105336b9a952SHuang Rui return r; 105436b9a952SHuang Rui } 105536b9a952SHuang Rui 1056d1936cc2SBaoyou Xie static void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 105736b9a952SHuang Rui { 105836b9a952SHuang Rui unsigned long flags; 105936b9a952SHuang Rui 106036b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 106136b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 106236b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 106336b9a952SHuang Rui WREG32(PCIE_PORT_DATA, (v)); 106436b9a952SHuang Rui (void)RREG32(PCIE_PORT_DATA); 106536b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 106636b9a952SHuang Rui } 106736b9a952SHuang Rui 106862a37553SKen Wang static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) 106962a37553SKen Wang { 107062a37553SKen Wang unsigned long flags; 107162a37553SKen Wang u32 r; 107262a37553SKen Wang 107362a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 107462a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 107562a37553SKen Wang r = RREG32(SMC_IND_DATA_0); 107662a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 107762a37553SKen Wang return r; 107862a37553SKen Wang } 107962a37553SKen Wang 108062a37553SKen Wang static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 108162a37553SKen Wang { 108262a37553SKen Wang unsigned long flags; 108362a37553SKen Wang 108462a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 108562a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 108662a37553SKen Wang WREG32(SMC_IND_DATA_0, (v)); 108762a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 108862a37553SKen Wang } 108962a37553SKen Wang 109080533a85SSonny Jiang static u32 si_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg) 109180533a85SSonny Jiang { 109280533a85SSonny Jiang unsigned long flags; 109380533a85SSonny Jiang u32 r; 109480533a85SSonny Jiang 109580533a85SSonny Jiang spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags); 109680533a85SSonny Jiang WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff)); 109780533a85SSonny Jiang r = RREG32(mmUVD_CTX_DATA); 109880533a85SSonny Jiang spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags); 109980533a85SSonny Jiang return r; 110080533a85SSonny Jiang } 110180533a85SSonny Jiang 110280533a85SSonny Jiang static void si_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 110380533a85SSonny Jiang { 110480533a85SSonny Jiang unsigned long flags; 110580533a85SSonny Jiang 110680533a85SSonny Jiang spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags); 110780533a85SSonny Jiang WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff)); 110880533a85SSonny Jiang WREG32(mmUVD_CTX_DATA, (v)); 110980533a85SSonny Jiang spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags); 111080533a85SSonny Jiang } 111180533a85SSonny Jiang 111262a37553SKen Wang static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { 111397fcc76bSChristian König {GRBM_STATUS}, 1114664fe85aSMarek Olšák {mmGRBM_STATUS2}, 1115664fe85aSMarek Olšák {mmGRBM_STATUS_SE0}, 1116664fe85aSMarek Olšák {mmGRBM_STATUS_SE1}, 1117664fe85aSMarek Olšák {mmSRBM_STATUS}, 1118664fe85aSMarek Olšák {mmSRBM_STATUS2}, 1119664fe85aSMarek Olšák {DMA_STATUS_REG + DMA0_REGISTER_OFFSET}, 1120664fe85aSMarek Olšák {DMA_STATUS_REG + DMA1_REGISTER_OFFSET}, 1121664fe85aSMarek Olšák {mmCP_STAT}, 1122664fe85aSMarek Olšák {mmCP_STALLED_STAT1}, 1123664fe85aSMarek Olšák {mmCP_STALLED_STAT2}, 1124664fe85aSMarek Olšák {mmCP_STALLED_STAT3}, 112597fcc76bSChristian König {GB_ADDR_CONFIG}, 112697fcc76bSChristian König {MC_ARB_RAMCFG}, 112797fcc76bSChristian König {GB_TILE_MODE0}, 112897fcc76bSChristian König {GB_TILE_MODE1}, 112997fcc76bSChristian König {GB_TILE_MODE2}, 113097fcc76bSChristian König {GB_TILE_MODE3}, 113197fcc76bSChristian König {GB_TILE_MODE4}, 113297fcc76bSChristian König {GB_TILE_MODE5}, 113397fcc76bSChristian König {GB_TILE_MODE6}, 113497fcc76bSChristian König {GB_TILE_MODE7}, 113597fcc76bSChristian König {GB_TILE_MODE8}, 113697fcc76bSChristian König {GB_TILE_MODE9}, 113797fcc76bSChristian König {GB_TILE_MODE10}, 113897fcc76bSChristian König {GB_TILE_MODE11}, 113997fcc76bSChristian König {GB_TILE_MODE12}, 114097fcc76bSChristian König {GB_TILE_MODE13}, 114197fcc76bSChristian König {GB_TILE_MODE14}, 114297fcc76bSChristian König {GB_TILE_MODE15}, 114397fcc76bSChristian König {GB_TILE_MODE16}, 114497fcc76bSChristian König {GB_TILE_MODE17}, 114597fcc76bSChristian König {GB_TILE_MODE18}, 114697fcc76bSChristian König {GB_TILE_MODE19}, 114797fcc76bSChristian König {GB_TILE_MODE20}, 114897fcc76bSChristian König {GB_TILE_MODE21}, 114997fcc76bSChristian König {GB_TILE_MODE22}, 115097fcc76bSChristian König {GB_TILE_MODE23}, 115197fcc76bSChristian König {GB_TILE_MODE24}, 115297fcc76bSChristian König {GB_TILE_MODE25}, 115397fcc76bSChristian König {GB_TILE_MODE26}, 115497fcc76bSChristian König {GB_TILE_MODE27}, 115597fcc76bSChristian König {GB_TILE_MODE28}, 115697fcc76bSChristian König {GB_TILE_MODE29}, 115797fcc76bSChristian König {GB_TILE_MODE30}, 115897fcc76bSChristian König {GB_TILE_MODE31}, 115997fcc76bSChristian König {CC_RB_BACKEND_DISABLE, true}, 116097fcc76bSChristian König {GC_USER_RB_BACKEND_DISABLE, true}, 116197fcc76bSChristian König {PA_SC_RASTER_CONFIG, true}, 116262a37553SKen Wang }; 116362a37553SKen Wang 1164dd5dfa61SFlora Cui static uint32_t si_get_register_value(struct amdgpu_device *adev, 1165dd5dfa61SFlora Cui bool indexed, u32 se_num, 1166dd5dfa61SFlora Cui u32 sh_num, u32 reg_offset) 116762a37553SKen Wang { 1168dd5dfa61SFlora Cui if (indexed) { 116962a37553SKen Wang uint32_t val; 1170dd5dfa61SFlora Cui unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num; 1171dd5dfa61SFlora Cui unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num; 1172dd5dfa61SFlora Cui 1173dd5dfa61SFlora Cui switch (reg_offset) { 1174dd5dfa61SFlora Cui case mmCC_RB_BACKEND_DISABLE: 1175dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable; 1176dd5dfa61SFlora Cui case mmGC_USER_RB_BACKEND_DISABLE: 1177dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable; 1178dd5dfa61SFlora Cui case mmPA_SC_RASTER_CONFIG: 1179dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config; 1180dd5dfa61SFlora Cui } 118162a37553SKen Wang 118262a37553SKen Wang mutex_lock(&adev->grbm_idx_mutex); 118362a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 1184d51ac6d0SLe Ma amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff, 0); 118562a37553SKen Wang 118662a37553SKen Wang val = RREG32(reg_offset); 118762a37553SKen Wang 118862a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 1189d51ac6d0SLe Ma amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, 0); 119062a37553SKen Wang mutex_unlock(&adev->grbm_idx_mutex); 119162a37553SKen Wang return val; 1192dd5dfa61SFlora Cui } else { 1193dd5dfa61SFlora Cui unsigned idx; 119462a37553SKen Wang 1195dd5dfa61SFlora Cui switch (reg_offset) { 1196dd5dfa61SFlora Cui case mmGB_ADDR_CONFIG: 1197dd5dfa61SFlora Cui return adev->gfx.config.gb_addr_config; 1198dd5dfa61SFlora Cui case mmMC_ARB_RAMCFG: 1199dd5dfa61SFlora Cui return adev->gfx.config.mc_arb_ramcfg; 1200dd5dfa61SFlora Cui case mmGB_TILE_MODE0: 1201dd5dfa61SFlora Cui case mmGB_TILE_MODE1: 1202dd5dfa61SFlora Cui case mmGB_TILE_MODE2: 1203dd5dfa61SFlora Cui case mmGB_TILE_MODE3: 1204dd5dfa61SFlora Cui case mmGB_TILE_MODE4: 1205dd5dfa61SFlora Cui case mmGB_TILE_MODE5: 1206dd5dfa61SFlora Cui case mmGB_TILE_MODE6: 1207dd5dfa61SFlora Cui case mmGB_TILE_MODE7: 1208dd5dfa61SFlora Cui case mmGB_TILE_MODE8: 1209dd5dfa61SFlora Cui case mmGB_TILE_MODE9: 1210dd5dfa61SFlora Cui case mmGB_TILE_MODE10: 1211dd5dfa61SFlora Cui case mmGB_TILE_MODE11: 1212dd5dfa61SFlora Cui case mmGB_TILE_MODE12: 1213dd5dfa61SFlora Cui case mmGB_TILE_MODE13: 1214dd5dfa61SFlora Cui case mmGB_TILE_MODE14: 1215dd5dfa61SFlora Cui case mmGB_TILE_MODE15: 1216dd5dfa61SFlora Cui case mmGB_TILE_MODE16: 1217dd5dfa61SFlora Cui case mmGB_TILE_MODE17: 1218dd5dfa61SFlora Cui case mmGB_TILE_MODE18: 1219dd5dfa61SFlora Cui case mmGB_TILE_MODE19: 1220dd5dfa61SFlora Cui case mmGB_TILE_MODE20: 1221dd5dfa61SFlora Cui case mmGB_TILE_MODE21: 1222dd5dfa61SFlora Cui case mmGB_TILE_MODE22: 1223dd5dfa61SFlora Cui case mmGB_TILE_MODE23: 1224dd5dfa61SFlora Cui case mmGB_TILE_MODE24: 1225dd5dfa61SFlora Cui case mmGB_TILE_MODE25: 1226dd5dfa61SFlora Cui case mmGB_TILE_MODE26: 1227dd5dfa61SFlora Cui case mmGB_TILE_MODE27: 1228dd5dfa61SFlora Cui case mmGB_TILE_MODE28: 1229dd5dfa61SFlora Cui case mmGB_TILE_MODE29: 1230dd5dfa61SFlora Cui case mmGB_TILE_MODE30: 1231dd5dfa61SFlora Cui case mmGB_TILE_MODE31: 1232dd5dfa61SFlora Cui idx = (reg_offset - mmGB_TILE_MODE0); 1233dd5dfa61SFlora Cui return adev->gfx.config.tile_mode_array[idx]; 1234dd5dfa61SFlora Cui default: 1235dd5dfa61SFlora Cui return RREG32(reg_offset); 1236dd5dfa61SFlora Cui } 1237dd5dfa61SFlora Cui } 1238dd5dfa61SFlora Cui } 123962a37553SKen Wang static int si_read_register(struct amdgpu_device *adev, u32 se_num, 124062a37553SKen Wang u32 sh_num, u32 reg_offset, u32 *value) 124162a37553SKen Wang { 124262a37553SKen Wang uint32_t i; 124362a37553SKen Wang 124462a37553SKen Wang *value = 0; 124562a37553SKen Wang for (i = 0; i < ARRAY_SIZE(si_allowed_read_registers); i++) { 124697fcc76bSChristian König bool indexed = si_allowed_read_registers[i].grbm_indexed; 124797fcc76bSChristian König 124862a37553SKen Wang if (reg_offset != si_allowed_read_registers[i].reg_offset) 124962a37553SKen Wang continue; 125062a37553SKen Wang 125197fcc76bSChristian König *value = si_get_register_value(adev, indexed, se_num, sh_num, 125297fcc76bSChristian König reg_offset); 125362a37553SKen Wang return 0; 125462a37553SKen Wang } 125562a37553SKen Wang return -EINVAL; 125662a37553SKen Wang } 125762a37553SKen Wang 125862a37553SKen Wang static bool si_read_disabled_bios(struct amdgpu_device *adev) 125962a37553SKen Wang { 126062a37553SKen Wang u32 bus_cntl; 126162a37553SKen Wang u32 d1vga_control = 0; 126262a37553SKen Wang u32 d2vga_control = 0; 126362a37553SKen Wang u32 vga_render_control = 0; 126462a37553SKen Wang u32 rom_cntl; 126562a37553SKen Wang bool r; 126662a37553SKen Wang 126762a37553SKen Wang bus_cntl = RREG32(R600_BUS_CNTL); 126862a37553SKen Wang if (adev->mode_info.num_crtc) { 126962a37553SKen Wang d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); 127062a37553SKen Wang d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); 127162a37553SKen Wang vga_render_control = RREG32(VGA_RENDER_CONTROL); 127262a37553SKen Wang } 127362a37553SKen Wang rom_cntl = RREG32(R600_ROM_CNTL); 127462a37553SKen Wang 127562a37553SKen Wang /* enable the rom */ 127662a37553SKen Wang WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS)); 127762a37553SKen Wang if (adev->mode_info.num_crtc) { 127862a37553SKen Wang /* Disable VGA mode */ 127962a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, 128062a37553SKen Wang (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 128162a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 128262a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, 128362a37553SKen Wang (d2vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 128462a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 128562a37553SKen Wang WREG32(VGA_RENDER_CONTROL, 128662a37553SKen Wang (vga_render_control & C_000300_VGA_VSTATUS_CNTL)); 128762a37553SKen Wang } 128862a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE); 128962a37553SKen Wang 129062a37553SKen Wang r = amdgpu_read_bios(adev); 129162a37553SKen Wang 129262a37553SKen Wang /* restore regs */ 129362a37553SKen Wang WREG32(R600_BUS_CNTL, bus_cntl); 129462a37553SKen Wang if (adev->mode_info.num_crtc) { 129562a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); 129662a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); 129762a37553SKen Wang WREG32(VGA_RENDER_CONTROL, vga_render_control); 129862a37553SKen Wang } 129962a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl); 130062a37553SKen Wang return r; 130162a37553SKen Wang } 130262a37553SKen Wang 13036d949d24SAlex Deucher #define mmROM_INDEX 0x2A 13046d949d24SAlex Deucher #define mmROM_DATA 0x2B 13056d949d24SAlex Deucher 13066d949d24SAlex Deucher static bool si_read_bios_from_rom(struct amdgpu_device *adev, 13076d949d24SAlex Deucher u8 *bios, u32 length_bytes) 13086d949d24SAlex Deucher { 13096d949d24SAlex Deucher u32 *dw_ptr; 13106d949d24SAlex Deucher u32 i, length_dw; 13116d949d24SAlex Deucher 13126d949d24SAlex Deucher if (bios == NULL) 13136d949d24SAlex Deucher return false; 13146d949d24SAlex Deucher if (length_bytes == 0) 13156d949d24SAlex Deucher return false; 13166d949d24SAlex Deucher /* APU vbios image is part of sbios image */ 13176d949d24SAlex Deucher if (adev->flags & AMD_IS_APU) 13186d949d24SAlex Deucher return false; 13196d949d24SAlex Deucher 13206d949d24SAlex Deucher dw_ptr = (u32 *)bios; 13216d949d24SAlex Deucher length_dw = ALIGN(length_bytes, 4) / 4; 13226d949d24SAlex Deucher /* set rom index to 0 */ 13236d949d24SAlex Deucher WREG32(mmROM_INDEX, 0); 13246d949d24SAlex Deucher for (i = 0; i < length_dw; i++) 13256d949d24SAlex Deucher dw_ptr[i] = RREG32(mmROM_DATA); 13266d949d24SAlex Deucher 13276d949d24SAlex Deucher return true; 13286d949d24SAlex Deucher } 13296d949d24SAlex Deucher 13306cd3c679SAlex Deucher static void si_set_clk_bypass_mode(struct amdgpu_device *adev) 13316cd3c679SAlex Deucher { 13326cd3c679SAlex Deucher u32 tmp, i; 13336cd3c679SAlex Deucher 13346cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL); 13356cd3c679SAlex Deucher tmp |= SPLL_BYPASS_EN; 13366cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL, tmp); 13376cd3c679SAlex Deucher 13386cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL_2); 13396cd3c679SAlex Deucher tmp |= SPLL_CTLREQ_CHG; 13406cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL_2, tmp); 13416cd3c679SAlex Deucher 13426cd3c679SAlex Deucher for (i = 0; i < adev->usec_timeout; i++) { 13436cd3c679SAlex Deucher if (RREG32(SPLL_STATUS) & SPLL_CHG_STATUS) 13446cd3c679SAlex Deucher break; 13456cd3c679SAlex Deucher udelay(1); 13466cd3c679SAlex Deucher } 13476cd3c679SAlex Deucher 13486cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL_2); 13496cd3c679SAlex Deucher tmp &= ~(SPLL_CTLREQ_CHG | SCLK_MUX_UPDATE); 13506cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL_2, tmp); 13516cd3c679SAlex Deucher 13526cd3c679SAlex Deucher tmp = RREG32(MPLL_CNTL_MODE); 13536cd3c679SAlex Deucher tmp &= ~MPLL_MCLK_SEL; 13546cd3c679SAlex Deucher WREG32(MPLL_CNTL_MODE, tmp); 13556cd3c679SAlex Deucher } 13566cd3c679SAlex Deucher 13576cd3c679SAlex Deucher static void si_spll_powerdown(struct amdgpu_device *adev) 13586cd3c679SAlex Deucher { 13596cd3c679SAlex Deucher u32 tmp; 13606cd3c679SAlex Deucher 13616cd3c679SAlex Deucher tmp = RREG32(SPLL_CNTL_MODE); 13626cd3c679SAlex Deucher tmp |= SPLL_SW_DIR_CONTROL; 13636cd3c679SAlex Deucher WREG32(SPLL_CNTL_MODE, tmp); 13646cd3c679SAlex Deucher 13656cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL); 13666cd3c679SAlex Deucher tmp |= SPLL_RESET; 13676cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL, tmp); 13686cd3c679SAlex Deucher 13696cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL); 13706cd3c679SAlex Deucher tmp |= SPLL_SLEEP; 13716cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL, tmp); 13726cd3c679SAlex Deucher 13736cd3c679SAlex Deucher tmp = RREG32(SPLL_CNTL_MODE); 13746cd3c679SAlex Deucher tmp &= ~SPLL_SW_DIR_CONTROL; 13756cd3c679SAlex Deucher WREG32(SPLL_CNTL_MODE, tmp); 13766cd3c679SAlex Deucher } 13776cd3c679SAlex Deucher 13786cd3c679SAlex Deucher static int si_gpu_pci_config_reset(struct amdgpu_device *adev) 13796cd3c679SAlex Deucher { 13806cd3c679SAlex Deucher u32 i; 13816cd3c679SAlex Deucher int r = -EINVAL; 13826cd3c679SAlex Deucher 138325bd5527SAlex Deucher amdgpu_atombios_scratch_regs_engine_hung(adev, true); 13846cd3c679SAlex Deucher 13856cd3c679SAlex Deucher /* set mclk/sclk to bypass */ 13866cd3c679SAlex Deucher si_set_clk_bypass_mode(adev); 13876cd3c679SAlex Deucher /* powerdown spll */ 13886cd3c679SAlex Deucher si_spll_powerdown(adev); 13896cd3c679SAlex Deucher /* disable BM */ 13906cd3c679SAlex Deucher pci_clear_master(adev->pdev); 13916cd3c679SAlex Deucher /* reset */ 13926cd3c679SAlex Deucher amdgpu_device_pci_config_reset(adev); 13936cd3c679SAlex Deucher 13946cd3c679SAlex Deucher udelay(100); 13956cd3c679SAlex Deucher 13966cd3c679SAlex Deucher /* wait for asic to come out of reset */ 13976cd3c679SAlex Deucher for (i = 0; i < adev->usec_timeout; i++) { 13986cd3c679SAlex Deucher if (RREG32(mmCONFIG_MEMSIZE) != 0xffffffff) { 13996cd3c679SAlex Deucher /* enable BM */ 14006cd3c679SAlex Deucher pci_set_master(adev->pdev); 14016cd3c679SAlex Deucher adev->has_hw_reset = true; 14026cd3c679SAlex Deucher r = 0; 14036cd3c679SAlex Deucher break; 14046cd3c679SAlex Deucher } 14056cd3c679SAlex Deucher udelay(1); 14066cd3c679SAlex Deucher } 140725bd5527SAlex Deucher amdgpu_atombios_scratch_regs_engine_hung(adev, false); 14086cd3c679SAlex Deucher 14096cd3c679SAlex Deucher return r; 14106cd3c679SAlex Deucher } 14116cd3c679SAlex Deucher 14123670c242SAlex Deucher static bool si_asic_supports_baco(struct amdgpu_device *adev) 14133670c242SAlex Deucher { 14143670c242SAlex Deucher return false; 14153670c242SAlex Deucher } 14163670c242SAlex Deucher 1417dd81eedeSAlex Deucher static enum amd_reset_method 1418dd81eedeSAlex Deucher si_asic_reset_method(struct amdgpu_device *adev) 1419dd81eedeSAlex Deucher { 1420ffbfd081SAlex Deucher if (amdgpu_reset_method == AMD_RESET_METHOD_PCI) 1421ffbfd081SAlex Deucher return amdgpu_reset_method; 1422ffbfd081SAlex Deucher else if (amdgpu_reset_method != AMD_RESET_METHOD_LEGACY && 1423273da6ffSWenhui Sheng amdgpu_reset_method != -1) 1424273da6ffSWenhui Sheng dev_warn(adev->dev, "Specified reset method:%d isn't supported, using AUTO instead.\n", 1425273da6ffSWenhui Sheng amdgpu_reset_method); 1426273da6ffSWenhui Sheng 1427dd81eedeSAlex Deucher return AMD_RESET_METHOD_LEGACY; 1428dd81eedeSAlex Deucher } 1429dd81eedeSAlex Deucher 1430ffbfd081SAlex Deucher static int si_asic_reset(struct amdgpu_device *adev) 1431ffbfd081SAlex Deucher { 1432ffbfd081SAlex Deucher int r; 1433ffbfd081SAlex Deucher 1434ffbfd081SAlex Deucher switch (si_asic_reset_method(adev)) { 1435ffbfd081SAlex Deucher case AMD_RESET_METHOD_PCI: 1436ffbfd081SAlex Deucher dev_info(adev->dev, "PCI reset\n"); 1437ffbfd081SAlex Deucher r = amdgpu_device_pci_reset(adev); 1438ffbfd081SAlex Deucher break; 1439ffbfd081SAlex Deucher default: 1440ffbfd081SAlex Deucher dev_info(adev->dev, "PCI CONFIG reset\n"); 1441ffbfd081SAlex Deucher r = si_gpu_pci_config_reset(adev); 1442ffbfd081SAlex Deucher break; 1443ffbfd081SAlex Deucher } 1444ffbfd081SAlex Deucher 1445ffbfd081SAlex Deucher return r; 1446ffbfd081SAlex Deucher } 1447ffbfd081SAlex Deucher 1448bbf282d8SAlex Deucher static u32 si_get_config_memsize(struct amdgpu_device *adev) 1449bbf282d8SAlex Deucher { 1450bbf282d8SAlex Deucher return RREG32(mmCONFIG_MEMSIZE); 1451bbf282d8SAlex Deucher } 1452bbf282d8SAlex Deucher 145362a37553SKen Wang static void si_vga_set_state(struct amdgpu_device *adev, bool state) 145462a37553SKen Wang { 145562a37553SKen Wang uint32_t temp; 145662a37553SKen Wang 145762a37553SKen Wang temp = RREG32(CONFIG_CNTL); 1458e66cdf25SZheng Bin if (!state) { 145962a37553SKen Wang temp &= ~(1<<0); 146062a37553SKen Wang temp |= (1<<1); 146162a37553SKen Wang } else { 146262a37553SKen Wang temp &= ~(1<<1); 146362a37553SKen Wang } 146462a37553SKen Wang WREG32(CONFIG_CNTL, temp); 146562a37553SKen Wang } 146662a37553SKen Wang 146762a37553SKen Wang static u32 si_get_xclk(struct amdgpu_device *adev) 146862a37553SKen Wang { 146962a37553SKen Wang u32 reference_clock = adev->clock.spll.reference_freq; 147062a37553SKen Wang u32 tmp; 147162a37553SKen Wang 147262a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL_2); 147362a37553SKen Wang if (tmp & MUX_TCLK_TO_XCLK) 147462a37553SKen Wang return TCLK; 147562a37553SKen Wang 147662a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL); 147762a37553SKen Wang if (tmp & XTALIN_DIVIDE) 147862a37553SKen Wang return reference_clock / 4; 147962a37553SKen Wang 148062a37553SKen Wang return reference_clock; 148162a37553SKen Wang } 14821919696eSMaruthi Srinivas Bayyavarapu 148369882565SChristian König static void si_flush_hdp(struct amdgpu_device *adev, struct amdgpu_ring *ring) 14842d5e0807SAlex Deucher { 148569882565SChristian König if (!ring || !ring->funcs->emit_wreg) { 14862d5e0807SAlex Deucher WREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1); 14872d5e0807SAlex Deucher RREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL); 148869882565SChristian König } else { 148969882565SChristian König amdgpu_ring_emit_wreg(ring, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1); 149069882565SChristian König } 14912d5e0807SAlex Deucher } 14922d5e0807SAlex Deucher 149369882565SChristian König static void si_invalidate_hdp(struct amdgpu_device *adev, 149469882565SChristian König struct amdgpu_ring *ring) 14952d5e0807SAlex Deucher { 149669882565SChristian König if (!ring || !ring->funcs->emit_wreg) { 14972d5e0807SAlex Deucher WREG32(mmHDP_DEBUG0, 1); 14982d5e0807SAlex Deucher RREG32(mmHDP_DEBUG0); 149969882565SChristian König } else { 150069882565SChristian König amdgpu_ring_emit_wreg(ring, mmHDP_DEBUG0, 1); 150169882565SChristian König } 15022d5e0807SAlex Deucher } 15032d5e0807SAlex Deucher 15040a881af8SAlex Deucher static bool si_need_full_reset(struct amdgpu_device *adev) 15050a881af8SAlex Deucher { 15060a881af8SAlex Deucher /* change this when we support soft reset */ 15070a881af8SAlex Deucher return true; 15080a881af8SAlex Deucher } 15090a881af8SAlex Deucher 15107450bbe7SAlex Deucher static bool si_need_reset_on_init(struct amdgpu_device *adev) 15117450bbe7SAlex Deucher { 15127450bbe7SAlex Deucher return false; 15137450bbe7SAlex Deucher } 15147450bbe7SAlex Deucher 151520ca25e8SAlex Deucher static int si_get_pcie_lanes(struct amdgpu_device *adev) 151620ca25e8SAlex Deucher { 151720ca25e8SAlex Deucher u32 link_width_cntl; 151820ca25e8SAlex Deucher 151920ca25e8SAlex Deucher if (adev->flags & AMD_IS_APU) 152020ca25e8SAlex Deucher return 0; 152120ca25e8SAlex Deucher 152220ca25e8SAlex Deucher link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 152320ca25e8SAlex Deucher 152420ca25e8SAlex Deucher switch ((link_width_cntl & LC_LINK_WIDTH_RD_MASK) >> LC_LINK_WIDTH_RD_SHIFT) { 152520ca25e8SAlex Deucher case LC_LINK_WIDTH_X1: 152620ca25e8SAlex Deucher return 1; 152720ca25e8SAlex Deucher case LC_LINK_WIDTH_X2: 152820ca25e8SAlex Deucher return 2; 152920ca25e8SAlex Deucher case LC_LINK_WIDTH_X4: 153020ca25e8SAlex Deucher return 4; 153120ca25e8SAlex Deucher case LC_LINK_WIDTH_X8: 153220ca25e8SAlex Deucher return 8; 153320ca25e8SAlex Deucher case LC_LINK_WIDTH_X0: 153420ca25e8SAlex Deucher case LC_LINK_WIDTH_X16: 153520ca25e8SAlex Deucher default: 153620ca25e8SAlex Deucher return 16; 153720ca25e8SAlex Deucher } 153820ca25e8SAlex Deucher } 153920ca25e8SAlex Deucher 154020ca25e8SAlex Deucher static void si_set_pcie_lanes(struct amdgpu_device *adev, int lanes) 154120ca25e8SAlex Deucher { 154220ca25e8SAlex Deucher u32 link_width_cntl, mask; 154320ca25e8SAlex Deucher 154420ca25e8SAlex Deucher if (adev->flags & AMD_IS_APU) 154520ca25e8SAlex Deucher return; 154620ca25e8SAlex Deucher 154720ca25e8SAlex Deucher switch (lanes) { 154820ca25e8SAlex Deucher case 0: 154920ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X0; 155020ca25e8SAlex Deucher break; 155120ca25e8SAlex Deucher case 1: 155220ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X1; 155320ca25e8SAlex Deucher break; 155420ca25e8SAlex Deucher case 2: 155520ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X2; 155620ca25e8SAlex Deucher break; 155720ca25e8SAlex Deucher case 4: 155820ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X4; 155920ca25e8SAlex Deucher break; 156020ca25e8SAlex Deucher case 8: 156120ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X8; 156220ca25e8SAlex Deucher break; 156320ca25e8SAlex Deucher case 16: 156420ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X16; 156520ca25e8SAlex Deucher break; 156620ca25e8SAlex Deucher default: 156720ca25e8SAlex Deucher DRM_ERROR("invalid pcie lane request: %d\n", lanes); 156820ca25e8SAlex Deucher return; 156920ca25e8SAlex Deucher } 157020ca25e8SAlex Deucher 157120ca25e8SAlex Deucher link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 157220ca25e8SAlex Deucher link_width_cntl &= ~LC_LINK_WIDTH_MASK; 157320ca25e8SAlex Deucher link_width_cntl |= mask << LC_LINK_WIDTH_SHIFT; 157420ca25e8SAlex Deucher link_width_cntl |= (LC_RECONFIG_NOW | 157520ca25e8SAlex Deucher LC_RECONFIG_ARC_MISSING_ESCAPE); 157620ca25e8SAlex Deucher 157720ca25e8SAlex Deucher WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); 157820ca25e8SAlex Deucher } 157920ca25e8SAlex Deucher 1580b45e18acSKent Russell static void si_get_pcie_usage(struct amdgpu_device *adev, uint64_t *count0, 1581b45e18acSKent Russell uint64_t *count1) 1582b45e18acSKent Russell { 1583b45e18acSKent Russell uint32_t perfctr = 0; 1584b45e18acSKent Russell uint64_t cnt0_of, cnt1_of; 1585b45e18acSKent Russell int tmp; 1586b45e18acSKent Russell 1587b45e18acSKent Russell /* This reports 0 on APUs, so return to avoid writing/reading registers 1588b45e18acSKent Russell * that may or may not be different from their GPU counterparts 1589b45e18acSKent Russell */ 1590b45e18acSKent Russell if (adev->flags & AMD_IS_APU) 1591b45e18acSKent Russell return; 1592b45e18acSKent Russell 1593b45e18acSKent Russell /* Set the 2 events that we wish to watch, defined above */ 1594b45e18acSKent Russell /* Reg 40 is # received msgs, Reg 104 is # of posted requests sent */ 1595b45e18acSKent Russell perfctr = REG_SET_FIELD(perfctr, PCIE_PERF_CNTL_TXCLK, EVENT0_SEL, 40); 1596b45e18acSKent Russell perfctr = REG_SET_FIELD(perfctr, PCIE_PERF_CNTL_TXCLK, EVENT1_SEL, 104); 1597b45e18acSKent Russell 1598b45e18acSKent Russell /* Write to enable desired perf counters */ 1599b45e18acSKent Russell WREG32_PCIE(ixPCIE_PERF_CNTL_TXCLK, perfctr); 1600b45e18acSKent Russell /* Zero out and enable the perf counters 1601b45e18acSKent Russell * Write 0x5: 1602b45e18acSKent Russell * Bit 0 = Start all counters(1) 1603b45e18acSKent Russell * Bit 2 = Global counter reset enable(1) 1604b45e18acSKent Russell */ 1605b45e18acSKent Russell WREG32_PCIE(ixPCIE_PERF_COUNT_CNTL, 0x00000005); 1606b45e18acSKent Russell 1607b45e18acSKent Russell msleep(1000); 1608b45e18acSKent Russell 1609b45e18acSKent Russell /* Load the shadow and disable the perf counters 1610b45e18acSKent Russell * Write 0x2: 1611b45e18acSKent Russell * Bit 0 = Stop counters(0) 1612b45e18acSKent Russell * Bit 1 = Load the shadow counters(1) 1613b45e18acSKent Russell */ 1614b45e18acSKent Russell WREG32_PCIE(ixPCIE_PERF_COUNT_CNTL, 0x00000002); 1615b45e18acSKent Russell 1616b45e18acSKent Russell /* Read register values to get any >32bit overflow */ 1617b45e18acSKent Russell tmp = RREG32_PCIE(ixPCIE_PERF_CNTL_TXCLK); 1618b45e18acSKent Russell cnt0_of = REG_GET_FIELD(tmp, PCIE_PERF_CNTL_TXCLK, COUNTER0_UPPER); 1619b45e18acSKent Russell cnt1_of = REG_GET_FIELD(tmp, PCIE_PERF_CNTL_TXCLK, COUNTER1_UPPER); 1620b45e18acSKent Russell 1621b45e18acSKent Russell /* Get the values and add the overflow */ 1622b45e18acSKent Russell *count0 = RREG32_PCIE(ixPCIE_PERF_COUNT0_TXCLK) | (cnt0_of << 32); 1623b45e18acSKent Russell *count1 = RREG32_PCIE(ixPCIE_PERF_COUNT1_TXCLK) | (cnt1_of << 32); 1624b45e18acSKent Russell } 1625b45e18acSKent Russell 1626dcea6e65SKent Russell static uint64_t si_get_pcie_replay_count(struct amdgpu_device *adev) 1627dcea6e65SKent Russell { 1628dcea6e65SKent Russell uint64_t nak_r, nak_g; 1629dcea6e65SKent Russell 1630dcea6e65SKent Russell /* Get the number of NAKs received and generated */ 1631dcea6e65SKent Russell nak_r = RREG32_PCIE(ixPCIE_RX_NUM_NAK); 1632dcea6e65SKent Russell nak_g = RREG32_PCIE(ixPCIE_RX_NUM_NAK_GENERATED); 1633dcea6e65SKent Russell 1634dcea6e65SKent Russell /* Add the total number of NAKs, i.e the number of replays */ 1635dcea6e65SKent Russell return (nak_r + nak_g); 1636dcea6e65SKent Russell } 1637dcea6e65SKent Russell 16383b0627a4SAlex Jivin static int si_uvd_send_upll_ctlreq(struct amdgpu_device *adev, 16393b0627a4SAlex Jivin unsigned cg_upll_func_cntl) 16403b0627a4SAlex Jivin { 16413b0627a4SAlex Jivin unsigned i; 16423b0627a4SAlex Jivin 16433b0627a4SAlex Jivin /* Make sure UPLL_CTLREQ is deasserted */ 16443b0627a4SAlex Jivin WREG32_P(cg_upll_func_cntl, 0, ~UPLL_CTLREQ_MASK); 16453b0627a4SAlex Jivin 16463b0627a4SAlex Jivin mdelay(10); 16473b0627a4SAlex Jivin 16483b0627a4SAlex Jivin /* Assert UPLL_CTLREQ */ 16493b0627a4SAlex Jivin WREG32_P(cg_upll_func_cntl, UPLL_CTLREQ_MASK, ~UPLL_CTLREQ_MASK); 16503b0627a4SAlex Jivin 16513b0627a4SAlex Jivin /* Wait for CTLACK and CTLACK2 to get asserted */ 16523b0627a4SAlex Jivin for (i = 0; i < SI_MAX_CTLACKS_ASSERTION_WAIT; ++i) { 16533b0627a4SAlex Jivin uint32_t mask = UPLL_CTLACK_MASK | UPLL_CTLACK2_MASK; 16543b0627a4SAlex Jivin 16553b0627a4SAlex Jivin if ((RREG32(cg_upll_func_cntl) & mask) == mask) 16563b0627a4SAlex Jivin break; 16573b0627a4SAlex Jivin mdelay(10); 16583b0627a4SAlex Jivin } 16593b0627a4SAlex Jivin 16603b0627a4SAlex Jivin /* Deassert UPLL_CTLREQ */ 16613b0627a4SAlex Jivin WREG32_P(cg_upll_func_cntl, 0, ~UPLL_CTLREQ_MASK); 16623b0627a4SAlex Jivin 16633b0627a4SAlex Jivin if (i == SI_MAX_CTLACKS_ASSERTION_WAIT) { 16643b0627a4SAlex Jivin DRM_ERROR("Timeout setting UVD clocks!\n"); 16653b0627a4SAlex Jivin return -ETIMEDOUT; 16663b0627a4SAlex Jivin } 16673b0627a4SAlex Jivin 16683b0627a4SAlex Jivin return 0; 16693b0627a4SAlex Jivin } 16703b0627a4SAlex Jivin 16713b0627a4SAlex Jivin static unsigned si_uvd_calc_upll_post_div(unsigned vco_freq, 16723b0627a4SAlex Jivin unsigned target_freq, 16733b0627a4SAlex Jivin unsigned pd_min, 16743b0627a4SAlex Jivin unsigned pd_even) 16753b0627a4SAlex Jivin { 16763b0627a4SAlex Jivin unsigned post_div = vco_freq / target_freq; 16773b0627a4SAlex Jivin 16783b0627a4SAlex Jivin /* Adjust to post divider minimum value */ 16793b0627a4SAlex Jivin if (post_div < pd_min) 16803b0627a4SAlex Jivin post_div = pd_min; 16813b0627a4SAlex Jivin 16823b0627a4SAlex Jivin /* We alway need a frequency less than or equal the target */ 16833b0627a4SAlex Jivin if ((vco_freq / post_div) > target_freq) 16843b0627a4SAlex Jivin post_div += 1; 16853b0627a4SAlex Jivin 16863b0627a4SAlex Jivin /* Post dividers above a certain value must be even */ 16873b0627a4SAlex Jivin if (post_div > pd_even && post_div % 2) 16883b0627a4SAlex Jivin post_div += 1; 16893b0627a4SAlex Jivin 16903b0627a4SAlex Jivin return post_div; 16913b0627a4SAlex Jivin } 16923b0627a4SAlex Jivin 16933b0627a4SAlex Jivin /** 16943b0627a4SAlex Jivin * si_calc_upll_dividers - calc UPLL clock dividers 16953b0627a4SAlex Jivin * 16963b0627a4SAlex Jivin * @adev: amdgpu_device pointer 16973b0627a4SAlex Jivin * @vclk: wanted VCLK 16983b0627a4SAlex Jivin * @dclk: wanted DCLK 16993b0627a4SAlex Jivin * @vco_min: minimum VCO frequency 17003b0627a4SAlex Jivin * @vco_max: maximum VCO frequency 17013b0627a4SAlex Jivin * @fb_factor: factor to multiply vco freq with 17023b0627a4SAlex Jivin * @fb_mask: limit and bitmask for feedback divider 17033b0627a4SAlex Jivin * @pd_min: post divider minimum 17043b0627a4SAlex Jivin * @pd_max: post divider maximum 17053b0627a4SAlex Jivin * @pd_even: post divider must be even above this value 17063b0627a4SAlex Jivin * @optimal_fb_div: resulting feedback divider 17073b0627a4SAlex Jivin * @optimal_vclk_div: resulting vclk post divider 17083b0627a4SAlex Jivin * @optimal_dclk_div: resulting dclk post divider 17093b0627a4SAlex Jivin * 17103b0627a4SAlex Jivin * Calculate dividers for UVDs UPLL (except APUs). 17113b0627a4SAlex Jivin * Returns zero on success; -EINVAL on error. 17123b0627a4SAlex Jivin */ 17133b0627a4SAlex Jivin static int si_calc_upll_dividers(struct amdgpu_device *adev, 17143b0627a4SAlex Jivin unsigned vclk, unsigned dclk, 17153b0627a4SAlex Jivin unsigned vco_min, unsigned vco_max, 17163b0627a4SAlex Jivin unsigned fb_factor, unsigned fb_mask, 17173b0627a4SAlex Jivin unsigned pd_min, unsigned pd_max, 17183b0627a4SAlex Jivin unsigned pd_even, 17193b0627a4SAlex Jivin unsigned *optimal_fb_div, 17203b0627a4SAlex Jivin unsigned *optimal_vclk_div, 17213b0627a4SAlex Jivin unsigned *optimal_dclk_div) 17223b0627a4SAlex Jivin { 17233b0627a4SAlex Jivin unsigned vco_freq, ref_freq = adev->clock.spll.reference_freq; 17243b0627a4SAlex Jivin 17253b0627a4SAlex Jivin /* Start off with something large */ 17263b0627a4SAlex Jivin unsigned optimal_score = ~0; 17273b0627a4SAlex Jivin 17283b0627a4SAlex Jivin /* Loop through vco from low to high */ 17293b0627a4SAlex Jivin vco_min = max(max(vco_min, vclk), dclk); 17303b0627a4SAlex Jivin for (vco_freq = vco_min; vco_freq <= vco_max; vco_freq += 100) { 17313b0627a4SAlex Jivin uint64_t fb_div = (uint64_t)vco_freq * fb_factor; 17323b0627a4SAlex Jivin unsigned vclk_div, dclk_div, score; 17333b0627a4SAlex Jivin 17343b0627a4SAlex Jivin do_div(fb_div, ref_freq); 17353b0627a4SAlex Jivin 17363b0627a4SAlex Jivin /* fb div out of range ? */ 17373b0627a4SAlex Jivin if (fb_div > fb_mask) 17383b0627a4SAlex Jivin break; /* It can oly get worse */ 17393b0627a4SAlex Jivin 17403b0627a4SAlex Jivin fb_div &= fb_mask; 17413b0627a4SAlex Jivin 17423b0627a4SAlex Jivin /* Calc vclk divider with current vco freq */ 17433b0627a4SAlex Jivin vclk_div = si_uvd_calc_upll_post_div(vco_freq, vclk, 17443b0627a4SAlex Jivin pd_min, pd_even); 17453b0627a4SAlex Jivin if (vclk_div > pd_max) 17463b0627a4SAlex Jivin break; /* vco is too big, it has to stop */ 17473b0627a4SAlex Jivin 17483b0627a4SAlex Jivin /* Calc dclk divider with current vco freq */ 17493b0627a4SAlex Jivin dclk_div = si_uvd_calc_upll_post_div(vco_freq, dclk, 17503b0627a4SAlex Jivin pd_min, pd_even); 17513b0627a4SAlex Jivin if (dclk_div > pd_max) 17523b0627a4SAlex Jivin break; /* vco is too big, it has to stop */ 17533b0627a4SAlex Jivin 17543b0627a4SAlex Jivin /* Calc score with current vco freq */ 17553b0627a4SAlex Jivin score = vclk - (vco_freq / vclk_div) + dclk - (vco_freq / dclk_div); 17563b0627a4SAlex Jivin 17573b0627a4SAlex Jivin /* Determine if this vco setting is better than current optimal settings */ 17583b0627a4SAlex Jivin if (score < optimal_score) { 17593b0627a4SAlex Jivin *optimal_fb_div = fb_div; 17603b0627a4SAlex Jivin *optimal_vclk_div = vclk_div; 17613b0627a4SAlex Jivin *optimal_dclk_div = dclk_div; 17623b0627a4SAlex Jivin optimal_score = score; 17633b0627a4SAlex Jivin if (optimal_score == 0) 17643b0627a4SAlex Jivin break; /* It can't get better than this */ 17653b0627a4SAlex Jivin } 17663b0627a4SAlex Jivin } 17673b0627a4SAlex Jivin 17683b0627a4SAlex Jivin /* Did we found a valid setup ? */ 17693b0627a4SAlex Jivin if (optimal_score == ~0) 17703b0627a4SAlex Jivin return -EINVAL; 17713b0627a4SAlex Jivin 17723b0627a4SAlex Jivin return 0; 17733b0627a4SAlex Jivin } 17743b0627a4SAlex Jivin 17753b0627a4SAlex Jivin static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) 17763b0627a4SAlex Jivin { 17773b0627a4SAlex Jivin unsigned fb_div = 0, vclk_div = 0, dclk_div = 0; 17783b0627a4SAlex Jivin int r; 17793b0627a4SAlex Jivin 17803b0627a4SAlex Jivin /* Bypass vclk and dclk with bclk */ 17813b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_2, 17823b0627a4SAlex Jivin VCLK_SRC_SEL(1) | DCLK_SRC_SEL(1), 17833b0627a4SAlex Jivin ~(VCLK_SRC_SEL_MASK | DCLK_SRC_SEL_MASK)); 17843b0627a4SAlex Jivin 17853b0627a4SAlex Jivin /* Put PLL in bypass mode */ 17863b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_BYPASS_EN_MASK, ~UPLL_BYPASS_EN_MASK); 17873b0627a4SAlex Jivin 17883b0627a4SAlex Jivin if (!vclk || !dclk) { 17893b0627a4SAlex Jivin /* Keep the Bypass mode */ 17903b0627a4SAlex Jivin return 0; 17913b0627a4SAlex Jivin } 17923b0627a4SAlex Jivin 17933b0627a4SAlex Jivin r = si_calc_upll_dividers(adev, vclk, dclk, 125000, 250000, 17943b0627a4SAlex Jivin 16384, 0x03FFFFFF, 0, 128, 5, 17953b0627a4SAlex Jivin &fb_div, &vclk_div, &dclk_div); 17963b0627a4SAlex Jivin if (r) 17973b0627a4SAlex Jivin return r; 17983b0627a4SAlex Jivin 17993b0627a4SAlex Jivin /* Set RESET_ANTI_MUX to 0 */ 18003b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_5, 0, ~RESET_ANTI_MUX_MASK); 18013b0627a4SAlex Jivin 18023b0627a4SAlex Jivin /* Set VCO_MODE to 1 */ 18033b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_VCO_MODE_MASK, ~UPLL_VCO_MODE_MASK); 18043b0627a4SAlex Jivin 18053b0627a4SAlex Jivin /* Disable sleep mode */ 18063b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_SLEEP_MASK); 18073b0627a4SAlex Jivin 18083b0627a4SAlex Jivin /* Deassert UPLL_RESET */ 18093b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_RESET_MASK); 18103b0627a4SAlex Jivin 18113b0627a4SAlex Jivin mdelay(1); 18123b0627a4SAlex Jivin 18133b0627a4SAlex Jivin r = si_uvd_send_upll_ctlreq(adev, CG_UPLL_FUNC_CNTL); 18143b0627a4SAlex Jivin if (r) 18153b0627a4SAlex Jivin return r; 18163b0627a4SAlex Jivin 18173b0627a4SAlex Jivin /* Assert UPLL_RESET again */ 18183b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_RESET_MASK, ~UPLL_RESET_MASK); 18193b0627a4SAlex Jivin 18203b0627a4SAlex Jivin /* Disable spread spectrum. */ 18213b0627a4SAlex Jivin WREG32_P(CG_UPLL_SPREAD_SPECTRUM, 0, ~SSEN_MASK); 18223b0627a4SAlex Jivin 18233b0627a4SAlex Jivin /* Set feedback divider */ 18243b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_3, UPLL_FB_DIV(fb_div), ~UPLL_FB_DIV_MASK); 18253b0627a4SAlex Jivin 18263b0627a4SAlex Jivin /* Set ref divider to 0 */ 18273b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_REF_DIV_MASK); 18283b0627a4SAlex Jivin 18293b0627a4SAlex Jivin if (fb_div < 307200) 18303b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_4, 0, ~UPLL_SPARE_ISPARE9); 18313b0627a4SAlex Jivin else 18323b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_4, 18333b0627a4SAlex Jivin UPLL_SPARE_ISPARE9, 18343b0627a4SAlex Jivin ~UPLL_SPARE_ISPARE9); 18353b0627a4SAlex Jivin 18363b0627a4SAlex Jivin /* Set PDIV_A and PDIV_B */ 18373b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_2, 18383b0627a4SAlex Jivin UPLL_PDIV_A(vclk_div) | UPLL_PDIV_B(dclk_div), 18393b0627a4SAlex Jivin ~(UPLL_PDIV_A_MASK | UPLL_PDIV_B_MASK)); 18403b0627a4SAlex Jivin 18413b0627a4SAlex Jivin /* Give the PLL some time to settle */ 18423b0627a4SAlex Jivin mdelay(15); 18433b0627a4SAlex Jivin 18443b0627a4SAlex Jivin /* Deassert PLL_RESET */ 18453b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_RESET_MASK); 18463b0627a4SAlex Jivin 18473b0627a4SAlex Jivin mdelay(15); 18483b0627a4SAlex Jivin 18493b0627a4SAlex Jivin /* Switch from bypass mode to normal mode */ 18503b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_BYPASS_EN_MASK); 18513b0627a4SAlex Jivin 18523b0627a4SAlex Jivin r = si_uvd_send_upll_ctlreq(adev, CG_UPLL_FUNC_CNTL); 18533b0627a4SAlex Jivin if (r) 18543b0627a4SAlex Jivin return r; 18553b0627a4SAlex Jivin 18563b0627a4SAlex Jivin /* Switch VCLK and DCLK selection */ 18573b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_2, 18583b0627a4SAlex Jivin VCLK_SRC_SEL(2) | DCLK_SRC_SEL(2), 18593b0627a4SAlex Jivin ~(VCLK_SRC_SEL_MASK | DCLK_SRC_SEL_MASK)); 18603b0627a4SAlex Jivin 18613b0627a4SAlex Jivin mdelay(100); 18623b0627a4SAlex Jivin 18633b0627a4SAlex Jivin return 0; 18643b0627a4SAlex Jivin } 18653b0627a4SAlex Jivin 1866fb40bcebSAlex Jivin static int si_vce_send_vcepll_ctlreq(struct amdgpu_device *adev) 1867fb40bcebSAlex Jivin { 1868fb40bcebSAlex Jivin unsigned i; 1869fb40bcebSAlex Jivin 1870fb40bcebSAlex Jivin /* Make sure VCEPLL_CTLREQ is deasserted */ 1871fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~UPLL_CTLREQ_MASK); 1872fb40bcebSAlex Jivin 1873fb40bcebSAlex Jivin mdelay(10); 1874fb40bcebSAlex Jivin 1875fb40bcebSAlex Jivin /* Assert UPLL_CTLREQ */ 1876fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, UPLL_CTLREQ_MASK, ~UPLL_CTLREQ_MASK); 1877fb40bcebSAlex Jivin 1878fb40bcebSAlex Jivin /* Wait for CTLACK and CTLACK2 to get asserted */ 1879fb40bcebSAlex Jivin for (i = 0; i < SI_MAX_CTLACKS_ASSERTION_WAIT; ++i) { 1880fb40bcebSAlex Jivin uint32_t mask = UPLL_CTLACK_MASK | UPLL_CTLACK2_MASK; 1881fb40bcebSAlex Jivin 1882fb40bcebSAlex Jivin if ((RREG32_SMC(CG_VCEPLL_FUNC_CNTL) & mask) == mask) 1883fb40bcebSAlex Jivin break; 1884fb40bcebSAlex Jivin mdelay(10); 1885fb40bcebSAlex Jivin } 1886fb40bcebSAlex Jivin 1887fb40bcebSAlex Jivin /* Deassert UPLL_CTLREQ */ 1888fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~UPLL_CTLREQ_MASK); 1889fb40bcebSAlex Jivin 1890fb40bcebSAlex Jivin if (i == SI_MAX_CTLACKS_ASSERTION_WAIT) { 1891fb40bcebSAlex Jivin DRM_ERROR("Timeout setting UVD clocks!\n"); 1892fb40bcebSAlex Jivin return -ETIMEDOUT; 1893fb40bcebSAlex Jivin } 1894fb40bcebSAlex Jivin 1895fb40bcebSAlex Jivin return 0; 1896fb40bcebSAlex Jivin } 1897fb40bcebSAlex Jivin 1898fb40bcebSAlex Jivin static int si_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) 1899fb40bcebSAlex Jivin { 1900fb40bcebSAlex Jivin unsigned fb_div = 0, evclk_div = 0, ecclk_div = 0; 1901fb40bcebSAlex Jivin int r; 1902fb40bcebSAlex Jivin 1903fb40bcebSAlex Jivin /* Bypass evclk and ecclk with bclk */ 1904fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_2, 1905fb40bcebSAlex Jivin EVCLK_SRC_SEL(1) | ECCLK_SRC_SEL(1), 1906fb40bcebSAlex Jivin ~(EVCLK_SRC_SEL_MASK | ECCLK_SRC_SEL_MASK)); 1907fb40bcebSAlex Jivin 1908fb40bcebSAlex Jivin /* Put PLL in bypass mode */ 1909fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_BYPASS_EN_MASK, 1910fb40bcebSAlex Jivin ~VCEPLL_BYPASS_EN_MASK); 1911fb40bcebSAlex Jivin 1912fb40bcebSAlex Jivin if (!evclk || !ecclk) { 1913fb40bcebSAlex Jivin /* Keep the Bypass mode, put PLL to sleep */ 1914fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_SLEEP_MASK, 1915fb40bcebSAlex Jivin ~VCEPLL_SLEEP_MASK); 1916fb40bcebSAlex Jivin return 0; 1917fb40bcebSAlex Jivin } 1918fb40bcebSAlex Jivin 1919fb40bcebSAlex Jivin r = si_calc_upll_dividers(adev, evclk, ecclk, 125000, 250000, 1920fb40bcebSAlex Jivin 16384, 0x03FFFFFF, 0, 128, 5, 1921fb40bcebSAlex Jivin &fb_div, &evclk_div, &ecclk_div); 1922fb40bcebSAlex Jivin if (r) 1923fb40bcebSAlex Jivin return r; 1924fb40bcebSAlex Jivin 1925fb40bcebSAlex Jivin /* Set RESET_ANTI_MUX to 0 */ 1926fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_5, 0, ~RESET_ANTI_MUX_MASK); 1927fb40bcebSAlex Jivin 1928fb40bcebSAlex Jivin /* Set VCO_MODE to 1 */ 1929fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_VCO_MODE_MASK, 1930fb40bcebSAlex Jivin ~VCEPLL_VCO_MODE_MASK); 1931fb40bcebSAlex Jivin 1932fb40bcebSAlex Jivin /* Toggle VCEPLL_SLEEP to 1 then back to 0 */ 1933fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_SLEEP_MASK, 1934fb40bcebSAlex Jivin ~VCEPLL_SLEEP_MASK); 1935fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_SLEEP_MASK); 1936fb40bcebSAlex Jivin 1937fb40bcebSAlex Jivin /* Deassert VCEPLL_RESET */ 1938fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_RESET_MASK); 1939fb40bcebSAlex Jivin 1940fb40bcebSAlex Jivin mdelay(1); 1941fb40bcebSAlex Jivin 1942fb40bcebSAlex Jivin r = si_vce_send_vcepll_ctlreq(adev); 1943fb40bcebSAlex Jivin if (r) 1944fb40bcebSAlex Jivin return r; 1945fb40bcebSAlex Jivin 1946fb40bcebSAlex Jivin /* Assert VCEPLL_RESET again */ 1947fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_RESET_MASK, ~VCEPLL_RESET_MASK); 1948fb40bcebSAlex Jivin 1949fb40bcebSAlex Jivin /* Disable spread spectrum. */ 1950fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_SPREAD_SPECTRUM, 0, ~SSEN_MASK); 1951fb40bcebSAlex Jivin 1952fb40bcebSAlex Jivin /* Set feedback divider */ 1953fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_3, 1954fb40bcebSAlex Jivin VCEPLL_FB_DIV(fb_div), 1955fb40bcebSAlex Jivin ~VCEPLL_FB_DIV_MASK); 1956fb40bcebSAlex Jivin 1957fb40bcebSAlex Jivin /* Set ref divider to 0 */ 1958fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_REF_DIV_MASK); 1959fb40bcebSAlex Jivin 1960fb40bcebSAlex Jivin /* Set PDIV_A and PDIV_B */ 1961fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_2, 1962fb40bcebSAlex Jivin VCEPLL_PDIV_A(evclk_div) | VCEPLL_PDIV_B(ecclk_div), 1963fb40bcebSAlex Jivin ~(VCEPLL_PDIV_A_MASK | VCEPLL_PDIV_B_MASK)); 1964fb40bcebSAlex Jivin 1965fb40bcebSAlex Jivin /* Give the PLL some time to settle */ 1966fb40bcebSAlex Jivin mdelay(15); 1967fb40bcebSAlex Jivin 1968fb40bcebSAlex Jivin /* Deassert PLL_RESET */ 1969fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_RESET_MASK); 1970fb40bcebSAlex Jivin 1971fb40bcebSAlex Jivin mdelay(15); 1972fb40bcebSAlex Jivin 1973fb40bcebSAlex Jivin /* Switch from bypass mode to normal mode */ 1974fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_BYPASS_EN_MASK); 1975fb40bcebSAlex Jivin 1976fb40bcebSAlex Jivin r = si_vce_send_vcepll_ctlreq(adev); 1977fb40bcebSAlex Jivin if (r) 1978fb40bcebSAlex Jivin return r; 1979fb40bcebSAlex Jivin 1980fb40bcebSAlex Jivin /* Switch VCLK and DCLK selection */ 1981fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_2, 1982fb40bcebSAlex Jivin EVCLK_SRC_SEL(16) | ECCLK_SRC_SEL(16), 1983fb40bcebSAlex Jivin ~(EVCLK_SRC_SEL_MASK | ECCLK_SRC_SEL_MASK)); 1984fb40bcebSAlex Jivin 1985fb40bcebSAlex Jivin mdelay(100); 1986fb40bcebSAlex Jivin 1987fb40bcebSAlex Jivin return 0; 1988fb40bcebSAlex Jivin } 1989fb40bcebSAlex Jivin 1990632d9f94SAlex Deucher static void si_pre_asic_init(struct amdgpu_device *adev) 1991632d9f94SAlex Deucher { 1992632d9f94SAlex Deucher } 1993632d9f94SAlex Deucher 199462a37553SKen Wang static const struct amdgpu_asic_funcs si_asic_funcs = 199562a37553SKen Wang { 199662a37553SKen Wang .read_disabled_bios = &si_read_disabled_bios, 19976d949d24SAlex Deucher .read_bios_from_rom = &si_read_bios_from_rom, 199862a37553SKen Wang .read_register = &si_read_register, 199962a37553SKen Wang .reset = &si_asic_reset, 2000dd81eedeSAlex Deucher .reset_method = &si_asic_reset_method, 200162a37553SKen Wang .set_vga_state = &si_vga_set_state, 200262a37553SKen Wang .get_xclk = &si_get_xclk, 200362a37553SKen Wang .set_uvd_clocks = &si_set_uvd_clocks, 2004fb40bcebSAlex Jivin .set_vce_clocks = &si_set_vce_clocks, 200520ca25e8SAlex Deucher .get_pcie_lanes = &si_get_pcie_lanes, 200620ca25e8SAlex Deucher .set_pcie_lanes = &si_set_pcie_lanes, 2007bbf282d8SAlex Deucher .get_config_memsize = &si_get_config_memsize, 20082d5e0807SAlex Deucher .flush_hdp = &si_flush_hdp, 20092d5e0807SAlex Deucher .invalidate_hdp = &si_invalidate_hdp, 20100a881af8SAlex Deucher .need_full_reset = &si_need_full_reset, 2011b45e18acSKent Russell .get_pcie_usage = &si_get_pcie_usage, 20127450bbe7SAlex Deucher .need_reset_on_init = &si_need_reset_on_init, 2013dcea6e65SKent Russell .get_pcie_replay_count = &si_get_pcie_replay_count, 20143670c242SAlex Deucher .supports_baco = &si_asic_supports_baco, 2015632d9f94SAlex Deucher .pre_asic_init = &si_pre_asic_init, 20163b246e8bSAlex Deucher .query_video_codecs = &si_query_video_codecs, 201762a37553SKen Wang }; 201862a37553SKen Wang 201962a37553SKen Wang static uint32_t si_get_rev_id(struct amdgpu_device *adev) 202062a37553SKen Wang { 202162a37553SKen Wang return (RREG32(CC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK) 202262a37553SKen Wang >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; 202362a37553SKen Wang } 202462a37553SKen Wang 202562a37553SKen Wang static int si_common_early_init(void *handle) 202662a37553SKen Wang { 202762a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 202862a37553SKen Wang 202962a37553SKen Wang adev->smc_rreg = &si_smc_rreg; 203062a37553SKen Wang adev->smc_wreg = &si_smc_wreg; 203162a37553SKen Wang adev->pcie_rreg = &si_pcie_rreg; 203262a37553SKen Wang adev->pcie_wreg = &si_pcie_wreg; 203336b9a952SHuang Rui adev->pciep_rreg = &si_pciep_rreg; 203436b9a952SHuang Rui adev->pciep_wreg = &si_pciep_wreg; 203580533a85SSonny Jiang adev->uvd_ctx_rreg = si_uvd_ctx_rreg; 203680533a85SSonny Jiang adev->uvd_ctx_wreg = si_uvd_ctx_wreg; 203762a37553SKen Wang adev->didt_rreg = NULL; 203862a37553SKen Wang adev->didt_wreg = NULL; 203962a37553SKen Wang 204062a37553SKen Wang adev->asic_funcs = &si_asic_funcs; 204162a37553SKen Wang 204262a37553SKen Wang adev->rev_id = si_get_rev_id(adev); 204362a37553SKen Wang adev->external_rev_id = 0xFF; 204462a37553SKen Wang switch (adev->asic_type) { 204562a37553SKen Wang case CHIP_TAHITI: 204662a37553SKen Wang adev->cg_flags = 204762a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 204862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 204962a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 205062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 205162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 205262a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 205362a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 205462a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 205562a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 205662a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 205762a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 205862a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 205962a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 206062a37553SKen Wang adev->pg_flags = 0; 20617c0a705eSFlora Cui adev->external_rev_id = (adev->rev_id == 0) ? 1 : 20627c0a705eSFlora Cui (adev->rev_id == 1) ? 5 : 6; 206362a37553SKen Wang break; 206462a37553SKen Wang case CHIP_PITCAIRN: 206562a37553SKen Wang adev->cg_flags = 206662a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 206762a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 206862a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 206962a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 207062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 207162a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 207262a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 207362a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 207462a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 207562a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 207662a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 207762a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 207862a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 207962a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 208062a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 208162a37553SKen Wang adev->pg_flags = 0; 2082e285a9a6SFlora Cui adev->external_rev_id = adev->rev_id + 20; 208362a37553SKen Wang break; 208462a37553SKen Wang 208562a37553SKen Wang case CHIP_VERDE: 208662a37553SKen Wang adev->cg_flags = 208762a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 208862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 208962a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 209062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 209162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS_LS | 209262a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 209362a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 209462a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 209562a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 209662a37553SKen Wang AMD_CG_SUPPORT_SDMA_LS | 209762a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 209862a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 209962a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 210062a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 210162a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 210262a37553SKen Wang adev->pg_flags = 0; 210362a37553SKen Wang //??? 2104f815b29cSFlora Cui adev->external_rev_id = adev->rev_id + 40; 210562a37553SKen Wang break; 210662a37553SKen Wang case CHIP_OLAND: 210762a37553SKen Wang adev->cg_flags = 210862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 210962a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 211062a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 211162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 211262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 211362a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 211462a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 211562a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 211662a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 211762a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 211862a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 211962a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 212062a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 212162a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 212262a37553SKen Wang adev->pg_flags = 0; 21238fd74cb4SFlora Cui adev->external_rev_id = 60; 212462a37553SKen Wang break; 212562a37553SKen Wang case CHIP_HAINAN: 212662a37553SKen Wang adev->cg_flags = 212762a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 212862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 212962a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 213062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 213162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 213262a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 213362a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 213462a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 213562a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 213662a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 213762a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 213862a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 213962a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 214062a37553SKen Wang adev->pg_flags = 0; 214105319478SFlora Cui adev->external_rev_id = 70; 214262a37553SKen Wang break; 214362a37553SKen Wang 214462a37553SKen Wang default: 214562a37553SKen Wang return -EINVAL; 214662a37553SKen Wang } 214762a37553SKen Wang 214862a37553SKen Wang return 0; 214962a37553SKen Wang } 215062a37553SKen Wang 215162a37553SKen Wang static int si_common_sw_init(void *handle) 215262a37553SKen Wang { 215362a37553SKen Wang return 0; 215462a37553SKen Wang } 215562a37553SKen Wang 215662a37553SKen Wang static int si_common_sw_fini(void *handle) 215762a37553SKen Wang { 215862a37553SKen Wang return 0; 215962a37553SKen Wang } 216062a37553SKen Wang 216162a37553SKen Wang 216262a37553SKen Wang static void si_init_golden_registers(struct amdgpu_device *adev) 216362a37553SKen Wang { 216462a37553SKen Wang switch (adev->asic_type) { 216562a37553SKen Wang case CHIP_TAHITI: 21669c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 216762a37553SKen Wang tahiti_golden_registers, 2168c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_registers)); 21699c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 217062a37553SKen Wang tahiti_golden_rlc_registers, 2171c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_rlc_registers)); 21729c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 217362a37553SKen Wang tahiti_mgcg_cgcg_init, 2174c47b41a7SChristian König ARRAY_SIZE(tahiti_mgcg_cgcg_init)); 21759c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 217662a37553SKen Wang tahiti_golden_registers2, 2177c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_registers2)); 217862a37553SKen Wang break; 217962a37553SKen Wang case CHIP_PITCAIRN: 21809c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 218162a37553SKen Wang pitcairn_golden_registers, 2182c47b41a7SChristian König ARRAY_SIZE(pitcairn_golden_registers)); 21839c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 218462a37553SKen Wang pitcairn_golden_rlc_registers, 2185c47b41a7SChristian König ARRAY_SIZE(pitcairn_golden_rlc_registers)); 21869c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 218762a37553SKen Wang pitcairn_mgcg_cgcg_init, 2188c47b41a7SChristian König ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); 21895694785cSJean Delvare break; 219062a37553SKen Wang case CHIP_VERDE: 21919c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 219262a37553SKen Wang verde_golden_registers, 2193c47b41a7SChristian König ARRAY_SIZE(verde_golden_registers)); 21949c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 219562a37553SKen Wang verde_golden_rlc_registers, 2196c47b41a7SChristian König ARRAY_SIZE(verde_golden_rlc_registers)); 21979c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 219862a37553SKen Wang verde_mgcg_cgcg_init, 2199c47b41a7SChristian König ARRAY_SIZE(verde_mgcg_cgcg_init)); 22009c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 220162a37553SKen Wang verde_pg_init, 2202c47b41a7SChristian König ARRAY_SIZE(verde_pg_init)); 220362a37553SKen Wang break; 220462a37553SKen Wang case CHIP_OLAND: 22059c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 220662a37553SKen Wang oland_golden_registers, 2207c47b41a7SChristian König ARRAY_SIZE(oland_golden_registers)); 22089c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 220962a37553SKen Wang oland_golden_rlc_registers, 2210c47b41a7SChristian König ARRAY_SIZE(oland_golden_rlc_registers)); 22119c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 221262a37553SKen Wang oland_mgcg_cgcg_init, 2213c47b41a7SChristian König ARRAY_SIZE(oland_mgcg_cgcg_init)); 22145694785cSJean Delvare break; 221562a37553SKen Wang case CHIP_HAINAN: 22169c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 221762a37553SKen Wang hainan_golden_registers, 2218c47b41a7SChristian König ARRAY_SIZE(hainan_golden_registers)); 22199c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 222062a37553SKen Wang hainan_golden_registers2, 2221c47b41a7SChristian König ARRAY_SIZE(hainan_golden_registers2)); 22229c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 222362a37553SKen Wang hainan_mgcg_cgcg_init, 2224c47b41a7SChristian König ARRAY_SIZE(hainan_mgcg_cgcg_init)); 222562a37553SKen Wang break; 222662a37553SKen Wang 222762a37553SKen Wang 222862a37553SKen Wang default: 222962a37553SKen Wang BUG(); 223062a37553SKen Wang } 223162a37553SKen Wang } 223262a37553SKen Wang 223362a37553SKen Wang static void si_pcie_gen3_enable(struct amdgpu_device *adev) 223462a37553SKen Wang { 223562a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 22360bf67185SAlex Deucher u32 speed_cntl, current_data_rate; 22370bf67185SAlex Deucher int i; 223862a37553SKen Wang u16 tmp16; 223962a37553SKen Wang 224062a37553SKen Wang if (pci_is_root_bus(adev->pdev->bus)) 224162a37553SKen Wang return; 224262a37553SKen Wang 224362a37553SKen Wang if (amdgpu_pcie_gen2 == 0) 224462a37553SKen Wang return; 224562a37553SKen Wang 224662a37553SKen Wang if (adev->flags & AMD_IS_APU) 224762a37553SKen Wang return; 224862a37553SKen Wang 22490bf67185SAlex Deucher if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | 22500bf67185SAlex Deucher CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) 225162a37553SKen Wang return; 225262a37553SKen Wang 225336b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 225462a37553SKen Wang current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> 225562a37553SKen Wang LC_CURRENT_DATA_RATE_SHIFT; 22560bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { 225762a37553SKen Wang if (current_data_rate == 2) { 225862a37553SKen Wang DRM_INFO("PCIE gen 3 link speeds already enabled\n"); 225962a37553SKen Wang return; 226062a37553SKen Wang } 226162a37553SKen Wang DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); 22620bf67185SAlex Deucher } else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) { 226362a37553SKen Wang if (current_data_rate == 1) { 226462a37553SKen Wang DRM_INFO("PCIE gen 2 link speeds already enabled\n"); 226562a37553SKen Wang return; 226662a37553SKen Wang } 226762a37553SKen Wang DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n"); 226862a37553SKen Wang } 226962a37553SKen Wang 227088027c89SFrederick Lawler if (!pci_is_pcie(root) || !pci_is_pcie(adev->pdev)) 227162a37553SKen Wang return; 227262a37553SKen Wang 22730bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { 227462a37553SKen Wang if (current_data_rate != 2) { 227562a37553SKen Wang u16 bridge_cfg, gpu_cfg; 227662a37553SKen Wang u16 bridge_cfg2, gpu_cfg2; 227762a37553SKen Wang u32 max_lw, current_lw, tmp; 227862a37553SKen Wang 2279ce7d8811SIlpo Järvinen pcie_capability_set_word(root, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_HAWD); 2280ce7d8811SIlpo Järvinen pcie_capability_set_word(adev->pdev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_HAWD); 228162a37553SKen Wang 228262a37553SKen Wang tmp = RREG32_PCIE(PCIE_LC_STATUS1); 228362a37553SKen Wang max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; 228462a37553SKen Wang current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; 228562a37553SKen Wang 228662a37553SKen Wang if (current_lw < max_lw) { 228736b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 228862a37553SKen Wang if (tmp & LC_RENEGOTIATION_SUPPORT) { 228962a37553SKen Wang tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); 229062a37553SKen Wang tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); 229162a37553SKen Wang tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; 229236b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); 229362a37553SKen Wang } 229462a37553SKen Wang } 229562a37553SKen Wang 229662a37553SKen Wang for (i = 0; i < 10; i++) { 229788027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 229888027c89SFrederick Lawler PCI_EXP_DEVSTA, 229988027c89SFrederick Lawler &tmp16); 230062a37553SKen Wang if (tmp16 & PCI_EXP_DEVSTA_TRPND) 230162a37553SKen Wang break; 230262a37553SKen Wang 230388027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL, 230488027c89SFrederick Lawler &bridge_cfg); 230588027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 230688027c89SFrederick Lawler PCI_EXP_LNKCTL, 230788027c89SFrederick Lawler &gpu_cfg); 230862a37553SKen Wang 230988027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL2, 231088027c89SFrederick Lawler &bridge_cfg2); 231188027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 231288027c89SFrederick Lawler PCI_EXP_LNKCTL2, 231388027c89SFrederick Lawler &gpu_cfg2); 231462a37553SKen Wang 231536b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 231662a37553SKen Wang tmp |= LC_SET_QUIESCE; 231736b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 231862a37553SKen Wang 231936b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 232062a37553SKen Wang tmp |= LC_REDO_EQ; 232136b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 232262a37553SKen Wang 232362a37553SKen Wang mdelay(100); 232462a37553SKen Wang 2325ce7d8811SIlpo Järvinen pcie_capability_clear_and_set_word(root, PCI_EXP_LNKCTL, 2326ce7d8811SIlpo Järvinen PCI_EXP_LNKCTL_HAWD, 2327ce7d8811SIlpo Järvinen bridge_cfg & 2328ce7d8811SIlpo Järvinen PCI_EXP_LNKCTL_HAWD); 2329ce7d8811SIlpo Järvinen pcie_capability_clear_and_set_word(adev->pdev, PCI_EXP_LNKCTL, 2330ce7d8811SIlpo Järvinen PCI_EXP_LNKCTL_HAWD, 2331ce7d8811SIlpo Järvinen gpu_cfg & 2332ce7d8811SIlpo Järvinen PCI_EXP_LNKCTL_HAWD); 233362a37553SKen Wang 2334*bb87e511SIlpo Järvinen pcie_capability_clear_and_set_word(root, PCI_EXP_LNKCTL2, 2335*bb87e511SIlpo Järvinen PCI_EXP_LNKCTL2_ENTER_COMP | 2336*bb87e511SIlpo Järvinen PCI_EXP_LNKCTL2_TX_MARGIN, 2337*bb87e511SIlpo Järvinen bridge_cfg2 & 233835e768e2SBjorn Helgaas (PCI_EXP_LNKCTL2_ENTER_COMP | 233935e768e2SBjorn Helgaas PCI_EXP_LNKCTL2_TX_MARGIN)); 2340*bb87e511SIlpo Järvinen pcie_capability_clear_and_set_word(adev->pdev, PCI_EXP_LNKCTL2, 2341*bb87e511SIlpo Järvinen PCI_EXP_LNKCTL2_ENTER_COMP | 2342*bb87e511SIlpo Järvinen PCI_EXP_LNKCTL2_TX_MARGIN, 2343*bb87e511SIlpo Järvinen gpu_cfg2 & 234435e768e2SBjorn Helgaas (PCI_EXP_LNKCTL2_ENTER_COMP | 234535e768e2SBjorn Helgaas PCI_EXP_LNKCTL2_TX_MARGIN)); 234662a37553SKen Wang 234736b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 234862a37553SKen Wang tmp &= ~LC_SET_QUIESCE; 234936b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 235062a37553SKen Wang } 235162a37553SKen Wang } 235262a37553SKen Wang } 235362a37553SKen Wang 235462a37553SKen Wang speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; 235562a37553SKen Wang speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; 235636b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 235762a37553SKen Wang 2358*bb87e511SIlpo Järvinen tmp16 = 0; 23590bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) 236035e768e2SBjorn Helgaas tmp16 |= PCI_EXP_LNKCTL2_TLS_8_0GT; /* gen3 */ 23610bf67185SAlex Deucher else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) 236235e768e2SBjorn Helgaas tmp16 |= PCI_EXP_LNKCTL2_TLS_5_0GT; /* gen2 */ 236362a37553SKen Wang else 236435e768e2SBjorn Helgaas tmp16 |= PCI_EXP_LNKCTL2_TLS_2_5GT; /* gen1 */ 2365*bb87e511SIlpo Järvinen pcie_capability_clear_and_set_word(adev->pdev, PCI_EXP_LNKCTL2, 2366*bb87e511SIlpo Järvinen PCI_EXP_LNKCTL2_TLS, tmp16); 236762a37553SKen Wang 236836b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 236962a37553SKen Wang speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; 237036b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 237162a37553SKen Wang 237262a37553SKen Wang for (i = 0; i < adev->usec_timeout; i++) { 237336b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 237462a37553SKen Wang if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) 237562a37553SKen Wang break; 237662a37553SKen Wang udelay(1); 237762a37553SKen Wang } 237862a37553SKen Wang } 237962a37553SKen Wang 238062a37553SKen Wang static inline u32 si_pif_phy0_rreg(struct amdgpu_device *adev, u32 reg) 238162a37553SKen Wang { 238262a37553SKen Wang unsigned long flags; 238362a37553SKen Wang u32 r; 238462a37553SKen Wang 238562a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 238662a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 238762a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY0_DATA); 238862a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 238962a37553SKen Wang return r; 239062a37553SKen Wang } 239162a37553SKen Wang 239262a37553SKen Wang static inline void si_pif_phy0_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 239362a37553SKen Wang { 239462a37553SKen Wang unsigned long flags; 239562a37553SKen Wang 239662a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 239762a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 239862a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); 239962a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 240062a37553SKen Wang } 240162a37553SKen Wang 240262a37553SKen Wang static inline u32 si_pif_phy1_rreg(struct amdgpu_device *adev, u32 reg) 240362a37553SKen Wang { 240462a37553SKen Wang unsigned long flags; 240562a37553SKen Wang u32 r; 240662a37553SKen Wang 240762a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 240862a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 240962a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY1_DATA); 241062a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 241162a37553SKen Wang return r; 241262a37553SKen Wang } 241362a37553SKen Wang 241462a37553SKen Wang static inline void si_pif_phy1_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 241562a37553SKen Wang { 241662a37553SKen Wang unsigned long flags; 241762a37553SKen Wang 241862a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 241962a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 242062a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); 242162a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 242262a37553SKen Wang } 242362a37553SKen Wang static void si_program_aspm(struct amdgpu_device *adev) 242462a37553SKen Wang { 242562a37553SKen Wang u32 data, orig; 242662a37553SKen Wang bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; 242762a37553SKen Wang bool disable_clkreq = false; 242862a37553SKen Wang 24290ab5d711SMario Limonciello if (!amdgpu_device_should_use_aspm(adev)) 243062a37553SKen Wang return; 243162a37553SKen Wang 243236b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 243362a37553SKen Wang data &= ~LC_XMIT_N_FTS_MASK; 243462a37553SKen Wang data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; 243562a37553SKen Wang if (orig != data) 243636b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); 243762a37553SKen Wang 243836b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); 243962a37553SKen Wang data |= LC_GO_TO_RECOVERY; 244062a37553SKen Wang if (orig != data) 244136b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); 244262a37553SKen Wang 244362a37553SKen Wang orig = data = RREG32_PCIE(PCIE_P_CNTL); 244462a37553SKen Wang data |= P_IGNORE_EDB_ERR; 244562a37553SKen Wang if (orig != data) 244662a37553SKen Wang WREG32_PCIE(PCIE_P_CNTL, data); 244762a37553SKen Wang 244836b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 244962a37553SKen Wang data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); 245062a37553SKen Wang data |= LC_PMI_TO_L1_DIS; 245162a37553SKen Wang if (!disable_l0s) 245262a37553SKen Wang data |= LC_L0S_INACTIVITY(7); 245362a37553SKen Wang 245462a37553SKen Wang if (!disable_l1) { 245562a37553SKen Wang data |= LC_L1_INACTIVITY(7); 245662a37553SKen Wang data &= ~LC_PMI_TO_L1_DIS; 245762a37553SKen Wang if (orig != data) 245836b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 245962a37553SKen Wang 246062a37553SKen Wang if (!disable_plloff_in_l1) { 246162a37553SKen Wang bool clk_req_support; 246262a37553SKen Wang 246362a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 246462a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 246562a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 246662a37553SKen Wang if (orig != data) 246762a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 246862a37553SKen Wang 246962a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 247062a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 247162a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 247262a37553SKen Wang if (orig != data) 247362a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 247462a37553SKen Wang 247562a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 247662a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 247762a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 247862a37553SKen Wang if (orig != data) 247962a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 248062a37553SKen Wang 248162a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 248262a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 248362a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 248462a37553SKen Wang if (orig != data) 248562a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 248662a37553SKen Wang 248777efe48aSJean Delvare if ((adev->asic_type != CHIP_OLAND) && (adev->asic_type != CHIP_HAINAN)) { 248862a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 248962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 249062a37553SKen Wang if (orig != data) 249162a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 249262a37553SKen Wang 249362a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 249462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 249562a37553SKen Wang if (orig != data) 249662a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 249762a37553SKen Wang 249862a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_2); 249962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 250062a37553SKen Wang if (orig != data) 250162a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_2, data); 250262a37553SKen Wang 250362a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_3); 250462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 250562a37553SKen Wang if (orig != data) 250662a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_3, data); 250762a37553SKen Wang 250862a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 250962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 251062a37553SKen Wang if (orig != data) 251162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 251262a37553SKen Wang 251362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 251462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 251562a37553SKen Wang if (orig != data) 251662a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 251762a37553SKen Wang 251862a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_2); 251962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 252062a37553SKen Wang if (orig != data) 252162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_2, data); 252262a37553SKen Wang 252362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_3); 252462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 252562a37553SKen Wang if (orig != data) 252662a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); 252762a37553SKen Wang } 252836b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 252962a37553SKen Wang data &= ~LC_DYN_LANES_PWR_STATE_MASK; 253062a37553SKen Wang data |= LC_DYN_LANES_PWR_STATE(3); 253162a37553SKen Wang if (orig != data) 253236b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); 253362a37553SKen Wang 253462a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); 253562a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 253677efe48aSJean Delvare if ((adev->asic_type == CHIP_OLAND) || (adev->asic_type == CHIP_HAINAN)) 253762a37553SKen Wang data |= LS2_EXIT_TIME(5); 253862a37553SKen Wang if (orig != data) 253962a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_CNTL, data); 254062a37553SKen Wang 254162a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_CNTL); 254262a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 254377efe48aSJean Delvare if ((adev->asic_type == CHIP_OLAND) || (adev->asic_type == CHIP_HAINAN)) 254462a37553SKen Wang data |= LS2_EXIT_TIME(5); 254562a37553SKen Wang if (orig != data) 254662a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_CNTL, data); 254762a37553SKen Wang 254862a37553SKen Wang if (!disable_clkreq && 254962a37553SKen Wang !pci_is_root_bus(adev->pdev->bus)) { 255062a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 255162a37553SKen Wang u32 lnkcap; 255262a37553SKen Wang 255362a37553SKen Wang clk_req_support = false; 255462a37553SKen Wang pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); 255562a37553SKen Wang if (lnkcap & PCI_EXP_LNKCAP_CLKPM) 255662a37553SKen Wang clk_req_support = true; 255762a37553SKen Wang } else { 255862a37553SKen Wang clk_req_support = false; 255962a37553SKen Wang } 256062a37553SKen Wang 256162a37553SKen Wang if (clk_req_support) { 256236b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); 256362a37553SKen Wang data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; 256462a37553SKen Wang if (orig != data) 256536b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); 256662a37553SKen Wang 256762a37553SKen Wang orig = data = RREG32(THM_CLK_CNTL); 256862a37553SKen Wang data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); 256962a37553SKen Wang data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); 257062a37553SKen Wang if (orig != data) 257162a37553SKen Wang WREG32(THM_CLK_CNTL, data); 257262a37553SKen Wang 257362a37553SKen Wang orig = data = RREG32(MISC_CLK_CNTL); 257462a37553SKen Wang data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); 257562a37553SKen Wang data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); 257662a37553SKen Wang if (orig != data) 257762a37553SKen Wang WREG32(MISC_CLK_CNTL, data); 257862a37553SKen Wang 257962a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL); 258062a37553SKen Wang data &= ~BCLK_AS_XCLK; 258162a37553SKen Wang if (orig != data) 258262a37553SKen Wang WREG32(CG_CLKPIN_CNTL, data); 258362a37553SKen Wang 258462a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL_2); 258562a37553SKen Wang data &= ~FORCE_BIF_REFCLK_EN; 258662a37553SKen Wang if (orig != data) 258762a37553SKen Wang WREG32(CG_CLKPIN_CNTL_2, data); 258862a37553SKen Wang 258962a37553SKen Wang orig = data = RREG32(MPLL_BYPASSCLK_SEL); 259062a37553SKen Wang data &= ~MPLL_CLKOUT_SEL_MASK; 259162a37553SKen Wang data |= MPLL_CLKOUT_SEL(4); 259262a37553SKen Wang if (orig != data) 259362a37553SKen Wang WREG32(MPLL_BYPASSCLK_SEL, data); 259462a37553SKen Wang 259562a37553SKen Wang orig = data = RREG32(SPLL_CNTL_MODE); 259662a37553SKen Wang data &= ~SPLL_REFCLK_SEL_MASK; 259762a37553SKen Wang if (orig != data) 259862a37553SKen Wang WREG32(SPLL_CNTL_MODE, data); 259962a37553SKen Wang } 260062a37553SKen Wang } 260162a37553SKen Wang } else { 260262a37553SKen Wang if (orig != data) 260336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 260462a37553SKen Wang } 260562a37553SKen Wang 260662a37553SKen Wang orig = data = RREG32_PCIE(PCIE_CNTL2); 260762a37553SKen Wang data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; 260862a37553SKen Wang if (orig != data) 260962a37553SKen Wang WREG32_PCIE(PCIE_CNTL2, data); 261062a37553SKen Wang 261162a37553SKen Wang if (!disable_l0s) { 261236b9a952SHuang Rui data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 261362a37553SKen Wang if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { 261462a37553SKen Wang data = RREG32_PCIE(PCIE_LC_STATUS1); 261562a37553SKen Wang if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { 261636b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 261762a37553SKen Wang data &= ~LC_L0S_INACTIVITY_MASK; 261862a37553SKen Wang if (orig != data) 261936b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 262062a37553SKen Wang } 262162a37553SKen Wang } 262262a37553SKen Wang } 262362a37553SKen Wang } 262462a37553SKen Wang 262562a37553SKen Wang static void si_fix_pci_max_read_req_size(struct amdgpu_device *adev) 262662a37553SKen Wang { 262762a37553SKen Wang int readrq; 262862a37553SKen Wang u16 v; 262962a37553SKen Wang 263062a37553SKen Wang readrq = pcie_get_readrq(adev->pdev); 263162a37553SKen Wang v = ffs(readrq) - 8; 263262a37553SKen Wang if ((v == 0) || (v == 6) || (v == 7)) 263362a37553SKen Wang pcie_set_readrq(adev->pdev, 512); 263462a37553SKen Wang } 263562a37553SKen Wang 263662a37553SKen Wang static int si_common_hw_init(void *handle) 263762a37553SKen Wang { 263862a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 263962a37553SKen Wang 264062a37553SKen Wang si_fix_pci_max_read_req_size(adev); 264162a37553SKen Wang si_init_golden_registers(adev); 264262a37553SKen Wang si_pcie_gen3_enable(adev); 264362a37553SKen Wang si_program_aspm(adev); 264462a37553SKen Wang 264562a37553SKen Wang return 0; 264662a37553SKen Wang } 264762a37553SKen Wang 264862a37553SKen Wang static int si_common_hw_fini(void *handle) 264962a37553SKen Wang { 265062a37553SKen Wang return 0; 265162a37553SKen Wang } 265262a37553SKen Wang 265362a37553SKen Wang static int si_common_suspend(void *handle) 265462a37553SKen Wang { 265562a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 265662a37553SKen Wang 265762a37553SKen Wang return si_common_hw_fini(adev); 265862a37553SKen Wang } 265962a37553SKen Wang 266062a37553SKen Wang static int si_common_resume(void *handle) 266162a37553SKen Wang { 266262a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 266362a37553SKen Wang 266462a37553SKen Wang return si_common_hw_init(adev); 266562a37553SKen Wang } 266662a37553SKen Wang 266762a37553SKen Wang static bool si_common_is_idle(void *handle) 266862a37553SKen Wang { 266962a37553SKen Wang return true; 267062a37553SKen Wang } 267162a37553SKen Wang 267262a37553SKen Wang static int si_common_wait_for_idle(void *handle) 267362a37553SKen Wang { 267462a37553SKen Wang return 0; 267562a37553SKen Wang } 267662a37553SKen Wang 267762a37553SKen Wang static int si_common_soft_reset(void *handle) 267862a37553SKen Wang { 267962a37553SKen Wang return 0; 268062a37553SKen Wang } 268162a37553SKen Wang 268262a37553SKen Wang static int si_common_set_clockgating_state(void *handle, 268362a37553SKen Wang enum amd_clockgating_state state) 268462a37553SKen Wang { 268562a37553SKen Wang return 0; 268662a37553SKen Wang } 268762a37553SKen Wang 268862a37553SKen Wang static int si_common_set_powergating_state(void *handle, 268962a37553SKen Wang enum amd_powergating_state state) 269062a37553SKen Wang { 269162a37553SKen Wang return 0; 269262a37553SKen Wang } 269362a37553SKen Wang 2694a1255107SAlex Deucher static const struct amd_ip_funcs si_common_ip_funcs = { 269562a37553SKen Wang .name = "si_common", 269662a37553SKen Wang .early_init = si_common_early_init, 269762a37553SKen Wang .late_init = NULL, 269862a37553SKen Wang .sw_init = si_common_sw_init, 269962a37553SKen Wang .sw_fini = si_common_sw_fini, 270062a37553SKen Wang .hw_init = si_common_hw_init, 270162a37553SKen Wang .hw_fini = si_common_hw_fini, 270262a37553SKen Wang .suspend = si_common_suspend, 270362a37553SKen Wang .resume = si_common_resume, 270462a37553SKen Wang .is_idle = si_common_is_idle, 270562a37553SKen Wang .wait_for_idle = si_common_wait_for_idle, 270662a37553SKen Wang .soft_reset = si_common_soft_reset, 270762a37553SKen Wang .set_clockgating_state = si_common_set_clockgating_state, 270862a37553SKen Wang .set_powergating_state = si_common_set_powergating_state, 270962a37553SKen Wang }; 271062a37553SKen Wang 2711a1255107SAlex Deucher static const struct amdgpu_ip_block_version si_common_ip_block = 271262a37553SKen Wang { 271362a37553SKen Wang .type = AMD_IP_BLOCK_TYPE_COMMON, 271462a37553SKen Wang .major = 1, 271562a37553SKen Wang .minor = 0, 271662a37553SKen Wang .rev = 0, 271762a37553SKen Wang .funcs = &si_common_ip_funcs, 27182120df47SAlex Deucher }; 27192120df47SAlex Deucher 272062a37553SKen Wang int si_set_ip_blocks(struct amdgpu_device *adev) 272162a37553SKen Wang { 272262a37553SKen Wang switch (adev->asic_type) { 272362a37553SKen Wang case CHIP_VERDE: 272462a37553SKen Wang case CHIP_TAHITI: 272562a37553SKen Wang case CHIP_PITCAIRN: 27262990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 27272990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 27282990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 27293089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 27303089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2731b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2732a1255107SAlex Deucher if (adev->enable_virtual_display) 2733733ee71aSRyan Taylor amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 273464200c46SMauro Rossi #if defined(CONFIG_DRM_AMD_DC) && defined(CONFIG_DRM_AMD_DC_SI) 273564200c46SMauro Rossi else if (amdgpu_device_has_dc_support(adev)) 273664200c46SMauro Rossi amdgpu_device_ip_block_add(adev, &dm_ip_block); 273764200c46SMauro Rossi #endif 2738a1255107SAlex Deucher else 27392990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_v6_0_ip_block); 2740ee2e74f7SSonny Jiang amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); 27412990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 2742a1255107SAlex Deucher break; 274362a37553SKen Wang case CHIP_OLAND: 27442990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 27452990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 27462990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 27473089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 27483089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2749b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2750a1255107SAlex Deucher if (adev->enable_virtual_display) 2751733ee71aSRyan Taylor amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 275264200c46SMauro Rossi #if defined(CONFIG_DRM_AMD_DC) && defined(CONFIG_DRM_AMD_DC_SI) 275364200c46SMauro Rossi else if (amdgpu_device_has_dc_support(adev)) 275464200c46SMauro Rossi amdgpu_device_ip_block_add(adev, &dm_ip_block); 275564200c46SMauro Rossi #endif 2756a1255107SAlex Deucher else 27572990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); 2758d375615cSSonny Jiang amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); 27592990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 276062a37553SKen Wang break; 276162a37553SKen Wang case CHIP_HAINAN: 27622990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 27632990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 27642990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 27653089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 27663089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2767b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2768a1255107SAlex Deucher if (adev->enable_virtual_display) 2769733ee71aSRyan Taylor amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); 277062a37553SKen Wang break; 277162a37553SKen Wang default: 277262a37553SKen Wang BUG(); 277362a37553SKen Wang } 277462a37553SKen Wang return 0; 277562a37553SKen Wang } 277662a37553SKen Wang 2777