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> 27248a1d6fSMasahiro Yamada #include <drm/drmP.h> 2862a37553SKen Wang #include "amdgpu.h" 2962a37553SKen Wang #include "amdgpu_atombios.h" 3062a37553SKen Wang #include "amdgpu_ih.h" 3162a37553SKen Wang #include "amdgpu_uvd.h" 3262a37553SKen Wang #include "amdgpu_vce.h" 3362a37553SKen Wang #include "atom.h" 340bf67185SAlex Deucher #include "amd_pcie.h" 35*b905090dSRex Zhu #include "si_dpm.h" 36689957b1SAlex Deucher #include "sid.h" 3762a37553SKen Wang #include "si_ih.h" 3862a37553SKen Wang #include "gfx_v6_0.h" 3962a37553SKen Wang #include "gmc_v6_0.h" 4062a37553SKen Wang #include "si_dma.h" 4162a37553SKen Wang #include "dce_v6_0.h" 4262a37553SKen Wang #include "si.h" 432120df47SAlex Deucher #include "dce_virtual.h" 4478bbe771STom St Denis #include "gca/gfx_6_0_d.h" 4578bbe771STom St Denis #include "oss/oss_1_0_d.h" 4678bbe771STom St Denis #include "gmc/gmc_6_0_d.h" 4778bbe771STom St Denis #include "dce/dce_6_0_d.h" 4878bbe771STom St Denis #include "uvd/uvd_4_0_d.h" 49bbf282d8SAlex Deucher #include "bif/bif_3_0_d.h" 5062a37553SKen Wang 5162a37553SKen Wang static const u32 tahiti_golden_registers[] = 5262a37553SKen Wang { 5378bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 5478bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 5578bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 5678bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 5778bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 5878bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 597c0a705eSFlora Cui 0x340c, 0x000000c0, 0x00800040, 607c0a705eSFlora Cui 0x360c, 0x000000c0, 0x00800040, 6178bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 6278bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 6378bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 6478bbe771STom St Denis mmMC_ARB_WTM_CNTL_RD, 0x00000003, 0x000007ff, 6578bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 6678bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 6778bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 6878bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 6978bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 7078bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, 717c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0040, 7262a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 7378bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 7478bbe771STom St Denis mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, 7578bbe771STom St Denis mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, 7678bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 7778bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 7878bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x00000200, 0x000002fb, 7978bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, 8078bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, 8178bbe771STom St Denis mmVGT_FIFO_DEPTHS, 0xffffffff, 0x000fff40, 8278bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 8378bbe771STom St Denis mmVM_CONTEXT0_CNTL, 0x20000000, 0x20fffed8, 8478bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 8578bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 8678bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 8778bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 8878bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 8962a37553SKen Wang }; 9062a37553SKen Wang 9162a37553SKen Wang static const u32 tahiti_golden_registers2[] = 9262a37553SKen Wang { 9378bbe771STom St Denis mmMCIF_MEM_CONTROL, 0x00000001, 0x00000001, 9462a37553SKen Wang }; 9562a37553SKen Wang 9662a37553SKen Wang static const u32 tahiti_golden_rlc_registers[] = 9762a37553SKen Wang { 9878bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, 9978bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, 10062a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 10162a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 10278bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 10378bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, 10478bbe771STom St Denis mmUVD_CGC_GATE, 0x00000008, 0x00000000, 10562a37553SKen Wang }; 10662a37553SKen Wang 10762a37553SKen Wang static const u32 pitcairn_golden_registers[] = 10862a37553SKen Wang { 10978bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 11078bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 11178bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 11278bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 11378bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 11478bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 11562a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 11662a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 11778bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 11878bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 11978bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 12078bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 12178bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 12278bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 12378bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 12478bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 12578bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 12678bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, 1271245a694SFlora Cui 0x000c, 0xffffffff, 0x0040, 12862a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 12978bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 13078bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 13178bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 13278bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f7, 13378bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 13478bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x32761054, 13578bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 13678bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 13778bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 13878bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 13978bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14078bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14162a37553SKen Wang }; 14262a37553SKen Wang 14362a37553SKen Wang static const u32 pitcairn_golden_rlc_registers[] = 14462a37553SKen Wang { 14578bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, 14678bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601004, 14762a37553SKen Wang 0x311f, 0xffffffff, 0x10102020, 14862a37553SKen Wang 0x3122, 0xffffffff, 0x01000020, 14978bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 15078bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000a4, 15162a37553SKen Wang }; 15262a37553SKen Wang 15362a37553SKen Wang static const u32 verde_pg_init[] = 15462a37553SKen Wang { 15578bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x40000, 15678bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x200010ff, 15778bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 15878bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 15978bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 16278bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x7007, 16378bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x300010ff, 16478bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x400000, 17078bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x100010ff, 17178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x120200, 17778bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x500010ff, 17878bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x1e1e16, 18478bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x600010ff, 18578bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x171f1e, 19178bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x700010ff, 19278bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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_CONFIG, 0xffffffff, 0x9ff, 19978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x0, 20078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10000800, 20178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, 20278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, 20378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4, 20478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1000051e, 20578bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, 20678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, 20778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x8, 20878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x80500, 20978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x12, 21078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x9050c, 21178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1d, 21278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xb052c, 21378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2a, 21478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1053e, 21578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2d, 21678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10546, 21778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x30, 21878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xa054e, 21978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3c, 22078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1055f, 22178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3f, 22278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10567, 22378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x42, 22478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1056f, 22578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x45, 22678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10572, 22778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x48, 22878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20575, 22978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4c, 23078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x190801, 23178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x67, 23278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1082a, 23378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x6a, 23478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1b082d, 23578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x87, 23678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x310851, 23778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xba, 23878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x891, 23978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbc, 24078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x893, 24178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbe, 24278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20895, 24378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc2, 24478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20899, 24578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc6, 24678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2089d, 24778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xca, 24878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a1, 24978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xcc, 25078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a3, 25178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xce, 25278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x308a5, 25378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xd3, 25478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x6d08cd, 25578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x142, 25678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2000095a, 25778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1, 25878bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x144, 25978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x301f095b, 26078bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x165, 26178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc094d, 26278bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x173, 26378bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf096d, 26478bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x184, 26578bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x15097f, 26678bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x19b, 26778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc0998, 26878bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1a9, 26978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x409a7, 27078bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1af, 27178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xcdc, 27278bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1b1, 27378bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x800, 27478bbe771STom St Denis mmGMCON_RENG_EXECUTE, 0xffffffff, 0x6c9b2000, 27578bbe771STom St Denis mmGMCON_MISC2, 0xfc00, 0x2000, 27678bbe771STom St Denis mmGMCON_MISC3, 0xffffffff, 0xfc0, 27778bbe771STom St Denis mmMC_PMG_AUTO_CFG, 0x00000100, 0x100, 27862a37553SKen Wang }; 27962a37553SKen Wang 28062a37553SKen Wang static const u32 verde_golden_rlc_registers[] = 28162a37553SKen Wang { 28278bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, 28378bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x033f1005, 28462a37553SKen Wang 0x311f, 0xffffffff, 0x10808020, 28562a37553SKen Wang 0x3122, 0xffffffff, 0x00800008, 28678bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00001000, 28778bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x80010014, 28862a37553SKen Wang }; 28962a37553SKen Wang 29062a37553SKen Wang static const u32 verde_golden_registers[] = 29162a37553SKen Wang { 29278bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 29378bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 29478bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 29578bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 29678bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 29778bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 29862a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 29962a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 30078bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 30178bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 30278bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 30378bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 30478bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 30578bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 30678bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 30778bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 30878bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 30978bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x0000124a, 310dae5c298SFlora Cui 0x000c, 0xffffffff, 0x0040, 31162a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 31278bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 31378bbe771STom St Denis mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, 31478bbe771STom St Denis mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, 31578bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 31678bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 31778bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x00000003, 31878bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 31978bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00001032, 32078bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 32178bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 32278bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 32378bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 32478bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 32578bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 32662a37553SKen Wang }; 32762a37553SKen Wang 32862a37553SKen Wang static const u32 oland_golden_registers[] = 32962a37553SKen Wang { 33078bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 33178bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 33278bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 33378bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 33478bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 33578bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 33662a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 33762a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 33878bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 33978bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 34078bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 34178bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 34278bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 34378bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 34478bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 34578bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 34678bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 34778bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000082, 3486b7985efSFlora Cui 0x000c, 0xffffffff, 0x0040, 34962a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 35078bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 35178bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 35278bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 35378bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f3, 35478bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 35578bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, 35678bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 35778bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 35878bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 35978bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36078bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36178bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36278bbe771STom St Denis 36362a37553SKen Wang }; 36462a37553SKen Wang 36562a37553SKen Wang static const u32 oland_golden_rlc_registers[] = 36662a37553SKen Wang { 36778bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, 36878bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, 36962a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 37062a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 37178bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 37278bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, 37362a37553SKen Wang }; 37462a37553SKen Wang 37562a37553SKen Wang static const u32 hainan_golden_registers[] = 37662a37553SKen Wang { 377bd27b678SFlora Cui 0x17bc, 0x00000030, 0x00000011, 37878bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 37978bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 38078bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 38178bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 382bd27b678SFlora Cui 0x031e, 0x00000080, 0x00000000, 383bd27b678SFlora Cui 0x3430, 0xff000fff, 0x00000100, 38462a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 38562a37553SKen Wang 0x3630, 0xff000fff, 0x00000100, 38662a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 387bd27b678SFlora Cui 0x16ec, 0x000000f0, 0x00000070, 388bd27b678SFlora Cui 0x16f0, 0x00200000, 0x50100000, 389bd27b678SFlora Cui 0x1c0c, 0x31000311, 0x00000011, 39078bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 39178bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 39278bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 39378bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 39478bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 39578bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 39678bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000000, 397bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0040, 39862a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 39978bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x03e00000, 0x03600000, 40078bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 40178bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 40278bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f1, 40378bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 40478bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, 40578bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 40678bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 40778bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 40878bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 40978bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41078bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41162a37553SKen Wang }; 41262a37553SKen Wang 41362a37553SKen Wang static const u32 hainan_golden_registers2[] = 41462a37553SKen Wang { 41578bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x2011003, 41662a37553SKen Wang }; 41762a37553SKen Wang 41862a37553SKen Wang static const u32 tahiti_mgcg_cgcg_init[] = 41962a37553SKen Wang { 42078bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 42178bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 42278bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 42378bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 42478bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 42578bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 42678bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 42778bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 42878bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 42978bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 43078bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 43178bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 43278bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 43378bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 43478bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 43578bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 43678bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 43778bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 43878bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 43978bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 44078bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 44178bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 44278bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 44378bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 44478bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 44578bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 44678bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 44762a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 44862a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 44962a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 45062a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 45162a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 45262a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 45362a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 45462a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 45562a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 45662a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 45762a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 45862a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 45962a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 46062a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 46162a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 46262a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 46362a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 46462a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 46562a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 46662a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 46762a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 46862a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 46962a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 47062a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 47162a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 47262a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 47362a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 47462a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 47562a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 47662a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 47762a37553SKen Wang 0x2476, 0xffffffff, 0x00070006, 47862a37553SKen Wang 0x2477, 0xffffffff, 0x00090008, 47962a37553SKen Wang 0x2478, 0xffffffff, 0x0000000c, 48062a37553SKen Wang 0x2479, 0xffffffff, 0x000b000a, 48162a37553SKen Wang 0x247a, 0xffffffff, 0x000e000d, 48262a37553SKen Wang 0x247b, 0xffffffff, 0x00080007, 48362a37553SKen Wang 0x247c, 0xffffffff, 0x000a0009, 48462a37553SKen Wang 0x247d, 0xffffffff, 0x0000000d, 48562a37553SKen Wang 0x247e, 0xffffffff, 0x000c000b, 48662a37553SKen Wang 0x247f, 0xffffffff, 0x000f000e, 48762a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 48862a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 48962a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 49062a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 49162a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 49262a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 49362a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 49462a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 49562a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 49662a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 49762a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 49862a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 49962a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 50062a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 50162a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 50262a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 50362a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 50462a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 50562a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 50662a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 50762a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 50862a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 50962a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 51062a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 51162a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 51262a37553SKen Wang 0x2499, 0xffffffff, 0x000e000d, 51362a37553SKen Wang 0x249a, 0xffffffff, 0x0010000f, 51462a37553SKen Wang 0x249b, 0xffffffff, 0x00000013, 51562a37553SKen Wang 0x249c, 0xffffffff, 0x00120011, 51662a37553SKen Wang 0x249d, 0xffffffff, 0x00150014, 51762a37553SKen Wang 0x249e, 0xffffffff, 0x000f000e, 51862a37553SKen Wang 0x249f, 0xffffffff, 0x00110010, 51962a37553SKen Wang 0x24a0, 0xffffffff, 0x00000014, 52062a37553SKen Wang 0x24a1, 0xffffffff, 0x00130012, 52162a37553SKen Wang 0x24a2, 0xffffffff, 0x00160015, 52262a37553SKen Wang 0x24a3, 0xffffffff, 0x0010000f, 52362a37553SKen Wang 0x24a4, 0xffffffff, 0x00120011, 52462a37553SKen Wang 0x24a5, 0xffffffff, 0x00000015, 52562a37553SKen Wang 0x24a6, 0xffffffff, 0x00140013, 52662a37553SKen Wang 0x24a7, 0xffffffff, 0x00170016, 52778bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 52878bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 52978bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 53078bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 5317c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 5327c0a705eSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 5337c0a705eSFlora Cui 0x0583, 0xffffffff, 0x00000100, 53478bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 53578bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 53678bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 53778bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 53878bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 53978bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 54062a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 54178bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 54278bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 54378bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 54462a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 54578bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 54662a37553SKen Wang }; 54762a37553SKen Wang static const u32 pitcairn_mgcg_cgcg_init[] = 54862a37553SKen Wang { 54978bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 55078bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 55178bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 55278bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 55378bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 55478bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 55578bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 55678bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 55778bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 55878bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 55978bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 56078bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 56178bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 56278bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 56378bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 56478bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 56578bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 56678bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 56778bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 56878bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 56978bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 57078bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 57178bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 57278bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 57378bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 57478bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 57578bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 57662a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 57762a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 57862a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 57962a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 58062a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 58162a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 58262a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 58362a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 58462a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 58562a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 58662a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 58762a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 58862a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 58962a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 59062a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 59162a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 59262a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 59362a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 59462a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 59562a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 59662a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 59762a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 59862a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 59962a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 60062a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 60162a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 60262a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 60362a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 60462a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 60562a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 60662a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 60762a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 60862a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 60962a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 61062a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 61162a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 61262a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 61362a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 61462a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 61562a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 61662a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 61762a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 61862a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 61962a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 62062a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 62162a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 62262a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 62362a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 62462a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 62562a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 62678bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 62778bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 62878bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 62978bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 6301245a694SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 6311245a694SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 6321245a694SFlora Cui 0x0583, 0xffffffff, 0x00000100, 63378bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 63478bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 63578bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 63678bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 63762a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 63878bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 63978bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 64078bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 64162a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 64278bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 64362a37553SKen Wang }; 64478bbe771STom St Denis 64562a37553SKen Wang static const u32 verde_mgcg_cgcg_init[] = 64662a37553SKen Wang { 64778bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 64878bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 64978bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 65078bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 65178bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 65278bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 65378bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 65478bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 65578bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 65678bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 65778bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 65878bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 65978bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 66078bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 66178bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 66278bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 66378bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 66478bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 66578bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 66678bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 66778bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 66878bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 66978bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 67078bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 67178bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 67278bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 67378bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 67462a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 67562a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 67662a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 67762a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 67862a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 67962a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 68062a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 68162a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 68262a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 68362a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 68462a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 68562a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 68662a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 68762a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 68862a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 68962a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 69062a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 69162a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 69262a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 69362a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 69462a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 69562a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 69662a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 69762a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 69862a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 69962a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 70062a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 70162a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 70262a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 70362a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 70462a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 70562a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 70662a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 70762a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 70862a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 70962a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 71062a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 71162a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 71262a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 71362a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 71462a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 71562a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 71662a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 71762a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 71862a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 71962a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 72062a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 72162a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 72262a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 72362a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 72478bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 72578bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 72678bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 72778bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 728dae5c298SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 729dae5c298SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 730dae5c298SFlora Cui 0x0583, 0xffffffff, 0x00000100, 73178bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 73278bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 73378bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 73478bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 73578bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 73678bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 73762a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 73878bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 73978bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 74078bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 74162a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 74278bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 74362a37553SKen Wang }; 74478bbe771STom St Denis 74562a37553SKen Wang static const u32 oland_mgcg_cgcg_init[] = 74662a37553SKen Wang { 74778bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 74878bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 74978bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 75078bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 75178bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 75278bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 75378bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 75478bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 75578bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 75678bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 75778bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 75878bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 75978bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 76078bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 76178bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 76278bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 76378bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 76478bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 76578bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 76678bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 76778bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 76878bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 76978bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 77078bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 77178bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 77278bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 77378bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 77462a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 77562a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 77662a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 77762a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 77862a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 77962a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 78062a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 78162a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 78262a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 78362a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 78462a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 78562a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 78662a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 78762a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 78862a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 78962a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 79062a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 79162a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 79262a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 79362a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 79462a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 79562a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 79662a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 79762a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 79862a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 79962a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 80062a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 80162a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 80262a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 80362a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 80478bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 80578bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 80678bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 80778bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 8086b7985efSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 8096b7985efSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 8106b7985efSFlora Cui 0x0583, 0xffffffff, 0x00000100, 81178bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 81278bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 81378bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 81478bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 81578bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 81678bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 81762a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 81878bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 81978bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 82078bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 82162a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 82278bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 82362a37553SKen Wang }; 82478bbe771STom St Denis 82562a37553SKen Wang static const u32 hainan_mgcg_cgcg_init[] = 82662a37553SKen Wang { 82778bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 82878bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 82978bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 83078bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 83178bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 83278bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 83378bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 83478bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 83578bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 83678bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 83778bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 83878bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 83978bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 84078bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 84178bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 84278bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 84378bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 84478bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 84578bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 84678bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 84778bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 84878bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 84978bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 85078bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 85178bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 85278bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 85378bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 85462a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 85562a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 85662a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 85762a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 85862a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 85962a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 86062a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 86162a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 86262a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 86362a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 86462a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 86562a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 86662a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 86762a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 86862a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 86962a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 87062a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 87162a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 87262a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 87362a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 87462a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 87562a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 87662a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 87762a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 87862a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 87962a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 88062a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 88162a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 88262a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 88362a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 88478bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 88578bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 88678bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 88778bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 888bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 889bd27b678SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 890bd27b678SFlora Cui 0x0583, 0xffffffff, 0x00000100, 891bd27b678SFlora Cui 0x0409, 0xffffffff, 0x00000100, 89278bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 89378bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 89478bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 89578bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 89678bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 89778bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 89862a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 89978bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 90062a37553SKen Wang }; 90162a37553SKen Wang 90262a37553SKen Wang static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg) 90362a37553SKen Wang { 90462a37553SKen Wang unsigned long flags; 90562a37553SKen Wang u32 r; 90662a37553SKen Wang 90762a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 90862a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 90962a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 91062a37553SKen Wang r = RREG32(AMDGPU_PCIE_DATA); 91162a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 91262a37553SKen Wang return r; 91362a37553SKen Wang } 91462a37553SKen Wang 91562a37553SKen Wang static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 91662a37553SKen Wang { 91762a37553SKen Wang unsigned long flags; 91862a37553SKen Wang 91962a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 92062a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 92162a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 92262a37553SKen Wang WREG32(AMDGPU_PCIE_DATA, v); 92362a37553SKen Wang (void)RREG32(AMDGPU_PCIE_DATA); 92462a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 92562a37553SKen Wang } 92662a37553SKen Wang 927d1936cc2SBaoyou Xie static u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) 92836b9a952SHuang Rui { 92936b9a952SHuang Rui unsigned long flags; 93036b9a952SHuang Rui u32 r; 93136b9a952SHuang Rui 93236b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 93336b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 93436b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 93536b9a952SHuang Rui r = RREG32(PCIE_PORT_DATA); 93636b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 93736b9a952SHuang Rui return r; 93836b9a952SHuang Rui } 93936b9a952SHuang Rui 940d1936cc2SBaoyou Xie static void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 94136b9a952SHuang Rui { 94236b9a952SHuang Rui unsigned long flags; 94336b9a952SHuang Rui 94436b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 94536b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 94636b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 94736b9a952SHuang Rui WREG32(PCIE_PORT_DATA, (v)); 94836b9a952SHuang Rui (void)RREG32(PCIE_PORT_DATA); 94936b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 95036b9a952SHuang Rui } 95136b9a952SHuang Rui 95262a37553SKen Wang static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) 95362a37553SKen Wang { 95462a37553SKen Wang unsigned long flags; 95562a37553SKen Wang u32 r; 95662a37553SKen Wang 95762a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 95862a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 95962a37553SKen Wang r = RREG32(SMC_IND_DATA_0); 96062a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 96162a37553SKen Wang return r; 96262a37553SKen Wang } 96362a37553SKen Wang 96462a37553SKen Wang static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 96562a37553SKen Wang { 96662a37553SKen Wang unsigned long flags; 96762a37553SKen Wang 96862a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 96962a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 97062a37553SKen Wang WREG32(SMC_IND_DATA_0, (v)); 97162a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 97262a37553SKen Wang } 97362a37553SKen Wang 97462a37553SKen Wang static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { 97597fcc76bSChristian König {GRBM_STATUS}, 97697fcc76bSChristian König {GB_ADDR_CONFIG}, 97797fcc76bSChristian König {MC_ARB_RAMCFG}, 97897fcc76bSChristian König {GB_TILE_MODE0}, 97997fcc76bSChristian König {GB_TILE_MODE1}, 98097fcc76bSChristian König {GB_TILE_MODE2}, 98197fcc76bSChristian König {GB_TILE_MODE3}, 98297fcc76bSChristian König {GB_TILE_MODE4}, 98397fcc76bSChristian König {GB_TILE_MODE5}, 98497fcc76bSChristian König {GB_TILE_MODE6}, 98597fcc76bSChristian König {GB_TILE_MODE7}, 98697fcc76bSChristian König {GB_TILE_MODE8}, 98797fcc76bSChristian König {GB_TILE_MODE9}, 98897fcc76bSChristian König {GB_TILE_MODE10}, 98997fcc76bSChristian König {GB_TILE_MODE11}, 99097fcc76bSChristian König {GB_TILE_MODE12}, 99197fcc76bSChristian König {GB_TILE_MODE13}, 99297fcc76bSChristian König {GB_TILE_MODE14}, 99397fcc76bSChristian König {GB_TILE_MODE15}, 99497fcc76bSChristian König {GB_TILE_MODE16}, 99597fcc76bSChristian König {GB_TILE_MODE17}, 99697fcc76bSChristian König {GB_TILE_MODE18}, 99797fcc76bSChristian König {GB_TILE_MODE19}, 99897fcc76bSChristian König {GB_TILE_MODE20}, 99997fcc76bSChristian König {GB_TILE_MODE21}, 100097fcc76bSChristian König {GB_TILE_MODE22}, 100197fcc76bSChristian König {GB_TILE_MODE23}, 100297fcc76bSChristian König {GB_TILE_MODE24}, 100397fcc76bSChristian König {GB_TILE_MODE25}, 100497fcc76bSChristian König {GB_TILE_MODE26}, 100597fcc76bSChristian König {GB_TILE_MODE27}, 100697fcc76bSChristian König {GB_TILE_MODE28}, 100797fcc76bSChristian König {GB_TILE_MODE29}, 100897fcc76bSChristian König {GB_TILE_MODE30}, 100997fcc76bSChristian König {GB_TILE_MODE31}, 101097fcc76bSChristian König {CC_RB_BACKEND_DISABLE, true}, 101197fcc76bSChristian König {GC_USER_RB_BACKEND_DISABLE, true}, 101297fcc76bSChristian König {PA_SC_RASTER_CONFIG, true}, 101362a37553SKen Wang }; 101462a37553SKen Wang 1015dd5dfa61SFlora Cui static uint32_t si_get_register_value(struct amdgpu_device *adev, 1016dd5dfa61SFlora Cui bool indexed, u32 se_num, 1017dd5dfa61SFlora Cui u32 sh_num, u32 reg_offset) 101862a37553SKen Wang { 1019dd5dfa61SFlora Cui if (indexed) { 102062a37553SKen Wang uint32_t val; 1021dd5dfa61SFlora Cui unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num; 1022dd5dfa61SFlora Cui unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num; 1023dd5dfa61SFlora Cui 1024dd5dfa61SFlora Cui switch (reg_offset) { 1025dd5dfa61SFlora Cui case mmCC_RB_BACKEND_DISABLE: 1026dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable; 1027dd5dfa61SFlora Cui case mmGC_USER_RB_BACKEND_DISABLE: 1028dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable; 1029dd5dfa61SFlora Cui case mmPA_SC_RASTER_CONFIG: 1030dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config; 1031dd5dfa61SFlora Cui } 103262a37553SKen Wang 103362a37553SKen Wang mutex_lock(&adev->grbm_idx_mutex); 103462a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 103562a37553SKen Wang amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff); 103662a37553SKen Wang 103762a37553SKen Wang val = RREG32(reg_offset); 103862a37553SKen Wang 103962a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 104062a37553SKen Wang amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); 104162a37553SKen Wang mutex_unlock(&adev->grbm_idx_mutex); 104262a37553SKen Wang return val; 1043dd5dfa61SFlora Cui } else { 1044dd5dfa61SFlora Cui unsigned idx; 104562a37553SKen Wang 1046dd5dfa61SFlora Cui switch (reg_offset) { 1047dd5dfa61SFlora Cui case mmGB_ADDR_CONFIG: 1048dd5dfa61SFlora Cui return adev->gfx.config.gb_addr_config; 1049dd5dfa61SFlora Cui case mmMC_ARB_RAMCFG: 1050dd5dfa61SFlora Cui return adev->gfx.config.mc_arb_ramcfg; 1051dd5dfa61SFlora Cui case mmGB_TILE_MODE0: 1052dd5dfa61SFlora Cui case mmGB_TILE_MODE1: 1053dd5dfa61SFlora Cui case mmGB_TILE_MODE2: 1054dd5dfa61SFlora Cui case mmGB_TILE_MODE3: 1055dd5dfa61SFlora Cui case mmGB_TILE_MODE4: 1056dd5dfa61SFlora Cui case mmGB_TILE_MODE5: 1057dd5dfa61SFlora Cui case mmGB_TILE_MODE6: 1058dd5dfa61SFlora Cui case mmGB_TILE_MODE7: 1059dd5dfa61SFlora Cui case mmGB_TILE_MODE8: 1060dd5dfa61SFlora Cui case mmGB_TILE_MODE9: 1061dd5dfa61SFlora Cui case mmGB_TILE_MODE10: 1062dd5dfa61SFlora Cui case mmGB_TILE_MODE11: 1063dd5dfa61SFlora Cui case mmGB_TILE_MODE12: 1064dd5dfa61SFlora Cui case mmGB_TILE_MODE13: 1065dd5dfa61SFlora Cui case mmGB_TILE_MODE14: 1066dd5dfa61SFlora Cui case mmGB_TILE_MODE15: 1067dd5dfa61SFlora Cui case mmGB_TILE_MODE16: 1068dd5dfa61SFlora Cui case mmGB_TILE_MODE17: 1069dd5dfa61SFlora Cui case mmGB_TILE_MODE18: 1070dd5dfa61SFlora Cui case mmGB_TILE_MODE19: 1071dd5dfa61SFlora Cui case mmGB_TILE_MODE20: 1072dd5dfa61SFlora Cui case mmGB_TILE_MODE21: 1073dd5dfa61SFlora Cui case mmGB_TILE_MODE22: 1074dd5dfa61SFlora Cui case mmGB_TILE_MODE23: 1075dd5dfa61SFlora Cui case mmGB_TILE_MODE24: 1076dd5dfa61SFlora Cui case mmGB_TILE_MODE25: 1077dd5dfa61SFlora Cui case mmGB_TILE_MODE26: 1078dd5dfa61SFlora Cui case mmGB_TILE_MODE27: 1079dd5dfa61SFlora Cui case mmGB_TILE_MODE28: 1080dd5dfa61SFlora Cui case mmGB_TILE_MODE29: 1081dd5dfa61SFlora Cui case mmGB_TILE_MODE30: 1082dd5dfa61SFlora Cui case mmGB_TILE_MODE31: 1083dd5dfa61SFlora Cui idx = (reg_offset - mmGB_TILE_MODE0); 1084dd5dfa61SFlora Cui return adev->gfx.config.tile_mode_array[idx]; 1085dd5dfa61SFlora Cui default: 1086dd5dfa61SFlora Cui return RREG32(reg_offset); 1087dd5dfa61SFlora Cui } 1088dd5dfa61SFlora Cui } 1089dd5dfa61SFlora Cui } 109062a37553SKen Wang static int si_read_register(struct amdgpu_device *adev, u32 se_num, 109162a37553SKen Wang u32 sh_num, u32 reg_offset, u32 *value) 109262a37553SKen Wang { 109362a37553SKen Wang uint32_t i; 109462a37553SKen Wang 109562a37553SKen Wang *value = 0; 109662a37553SKen Wang for (i = 0; i < ARRAY_SIZE(si_allowed_read_registers); i++) { 109797fcc76bSChristian König bool indexed = si_allowed_read_registers[i].grbm_indexed; 109897fcc76bSChristian König 109962a37553SKen Wang if (reg_offset != si_allowed_read_registers[i].reg_offset) 110062a37553SKen Wang continue; 110162a37553SKen Wang 110297fcc76bSChristian König *value = si_get_register_value(adev, indexed, se_num, sh_num, 110397fcc76bSChristian König reg_offset); 110462a37553SKen Wang return 0; 110562a37553SKen Wang } 110662a37553SKen Wang return -EINVAL; 110762a37553SKen Wang } 110862a37553SKen Wang 110962a37553SKen Wang static bool si_read_disabled_bios(struct amdgpu_device *adev) 111062a37553SKen Wang { 111162a37553SKen Wang u32 bus_cntl; 111262a37553SKen Wang u32 d1vga_control = 0; 111362a37553SKen Wang u32 d2vga_control = 0; 111462a37553SKen Wang u32 vga_render_control = 0; 111562a37553SKen Wang u32 rom_cntl; 111662a37553SKen Wang bool r; 111762a37553SKen Wang 111862a37553SKen Wang bus_cntl = RREG32(R600_BUS_CNTL); 111962a37553SKen Wang if (adev->mode_info.num_crtc) { 112062a37553SKen Wang d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); 112162a37553SKen Wang d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); 112262a37553SKen Wang vga_render_control = RREG32(VGA_RENDER_CONTROL); 112362a37553SKen Wang } 112462a37553SKen Wang rom_cntl = RREG32(R600_ROM_CNTL); 112562a37553SKen Wang 112662a37553SKen Wang /* enable the rom */ 112762a37553SKen Wang WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS)); 112862a37553SKen Wang if (adev->mode_info.num_crtc) { 112962a37553SKen Wang /* Disable VGA mode */ 113062a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, 113162a37553SKen Wang (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 113262a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 113362a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, 113462a37553SKen Wang (d2vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 113562a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 113662a37553SKen Wang WREG32(VGA_RENDER_CONTROL, 113762a37553SKen Wang (vga_render_control & C_000300_VGA_VSTATUS_CNTL)); 113862a37553SKen Wang } 113962a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE); 114062a37553SKen Wang 114162a37553SKen Wang r = amdgpu_read_bios(adev); 114262a37553SKen Wang 114362a37553SKen Wang /* restore regs */ 114462a37553SKen Wang WREG32(R600_BUS_CNTL, bus_cntl); 114562a37553SKen Wang if (adev->mode_info.num_crtc) { 114662a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); 114762a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); 114862a37553SKen Wang WREG32(VGA_RENDER_CONTROL, vga_render_control); 114962a37553SKen Wang } 115062a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl); 115162a37553SKen Wang return r; 115262a37553SKen Wang } 115362a37553SKen Wang 11546d949d24SAlex Deucher #define mmROM_INDEX 0x2A 11556d949d24SAlex Deucher #define mmROM_DATA 0x2B 11566d949d24SAlex Deucher 11576d949d24SAlex Deucher static bool si_read_bios_from_rom(struct amdgpu_device *adev, 11586d949d24SAlex Deucher u8 *bios, u32 length_bytes) 11596d949d24SAlex Deucher { 11606d949d24SAlex Deucher u32 *dw_ptr; 11616d949d24SAlex Deucher u32 i, length_dw; 11626d949d24SAlex Deucher 11636d949d24SAlex Deucher if (bios == NULL) 11646d949d24SAlex Deucher return false; 11656d949d24SAlex Deucher if (length_bytes == 0) 11666d949d24SAlex Deucher return false; 11676d949d24SAlex Deucher /* APU vbios image is part of sbios image */ 11686d949d24SAlex Deucher if (adev->flags & AMD_IS_APU) 11696d949d24SAlex Deucher return false; 11706d949d24SAlex Deucher 11716d949d24SAlex Deucher dw_ptr = (u32 *)bios; 11726d949d24SAlex Deucher length_dw = ALIGN(length_bytes, 4) / 4; 11736d949d24SAlex Deucher /* set rom index to 0 */ 11746d949d24SAlex Deucher WREG32(mmROM_INDEX, 0); 11756d949d24SAlex Deucher for (i = 0; i < length_dw; i++) 11766d949d24SAlex Deucher dw_ptr[i] = RREG32(mmROM_DATA); 11776d949d24SAlex Deucher 11786d949d24SAlex Deucher return true; 11796d949d24SAlex Deucher } 11806d949d24SAlex Deucher 118162a37553SKen Wang //xxx: not implemented 118262a37553SKen Wang static int si_asic_reset(struct amdgpu_device *adev) 118362a37553SKen Wang { 118462a37553SKen Wang return 0; 118562a37553SKen Wang } 118662a37553SKen Wang 1187bbf282d8SAlex Deucher static u32 si_get_config_memsize(struct amdgpu_device *adev) 1188bbf282d8SAlex Deucher { 1189bbf282d8SAlex Deucher return RREG32(mmCONFIG_MEMSIZE); 1190bbf282d8SAlex Deucher } 1191bbf282d8SAlex Deucher 119262a37553SKen Wang static void si_vga_set_state(struct amdgpu_device *adev, bool state) 119362a37553SKen Wang { 119462a37553SKen Wang uint32_t temp; 119562a37553SKen Wang 119662a37553SKen Wang temp = RREG32(CONFIG_CNTL); 119762a37553SKen Wang if (state == false) { 119862a37553SKen Wang temp &= ~(1<<0); 119962a37553SKen Wang temp |= (1<<1); 120062a37553SKen Wang } else { 120162a37553SKen Wang temp &= ~(1<<1); 120262a37553SKen Wang } 120362a37553SKen Wang WREG32(CONFIG_CNTL, temp); 120462a37553SKen Wang } 120562a37553SKen Wang 120662a37553SKen Wang static u32 si_get_xclk(struct amdgpu_device *adev) 120762a37553SKen Wang { 120862a37553SKen Wang u32 reference_clock = adev->clock.spll.reference_freq; 120962a37553SKen Wang u32 tmp; 121062a37553SKen Wang 121162a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL_2); 121262a37553SKen Wang if (tmp & MUX_TCLK_TO_XCLK) 121362a37553SKen Wang return TCLK; 121462a37553SKen Wang 121562a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL); 121662a37553SKen Wang if (tmp & XTALIN_DIVIDE) 121762a37553SKen Wang return reference_clock / 4; 121862a37553SKen Wang 121962a37553SKen Wang return reference_clock; 122062a37553SKen Wang } 12211919696eSMaruthi Srinivas Bayyavarapu 122262a37553SKen Wang //xxx:not implemented 122362a37553SKen Wang static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) 122462a37553SKen Wang { 122562a37553SKen Wang return 0; 122662a37553SKen Wang } 122762a37553SKen Wang 12284e99a44eSMonk Liu static void si_detect_hw_virtualization(struct amdgpu_device *adev) 12294e99a44eSMonk Liu { 12304e99a44eSMonk Liu if (is_virtual_machine()) /* passthrough mode */ 12315a5099cbSXiangliang Yu adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; 12324e99a44eSMonk Liu } 12334e99a44eSMonk Liu 123469882565SChristian König static void si_flush_hdp(struct amdgpu_device *adev, struct amdgpu_ring *ring) 12352d5e0807SAlex Deucher { 123669882565SChristian König if (!ring || !ring->funcs->emit_wreg) { 12372d5e0807SAlex Deucher WREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1); 12382d5e0807SAlex Deucher RREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL); 123969882565SChristian König } else { 124069882565SChristian König amdgpu_ring_emit_wreg(ring, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1); 124169882565SChristian König } 12422d5e0807SAlex Deucher } 12432d5e0807SAlex Deucher 124469882565SChristian König static void si_invalidate_hdp(struct amdgpu_device *adev, 124569882565SChristian König struct amdgpu_ring *ring) 12462d5e0807SAlex Deucher { 124769882565SChristian König if (!ring || !ring->funcs->emit_wreg) { 12482d5e0807SAlex Deucher WREG32(mmHDP_DEBUG0, 1); 12492d5e0807SAlex Deucher RREG32(mmHDP_DEBUG0); 125069882565SChristian König } else { 125169882565SChristian König amdgpu_ring_emit_wreg(ring, mmHDP_DEBUG0, 1); 125269882565SChristian König } 12532d5e0807SAlex Deucher } 12542d5e0807SAlex Deucher 125562a37553SKen Wang static const struct amdgpu_asic_funcs si_asic_funcs = 125662a37553SKen Wang { 125762a37553SKen Wang .read_disabled_bios = &si_read_disabled_bios, 12586d949d24SAlex Deucher .read_bios_from_rom = &si_read_bios_from_rom, 125962a37553SKen Wang .read_register = &si_read_register, 126062a37553SKen Wang .reset = &si_asic_reset, 126162a37553SKen Wang .set_vga_state = &si_vga_set_state, 126262a37553SKen Wang .get_xclk = &si_get_xclk, 126362a37553SKen Wang .set_uvd_clocks = &si_set_uvd_clocks, 126462a37553SKen Wang .set_vce_clocks = NULL, 1265bbf282d8SAlex Deucher .get_config_memsize = &si_get_config_memsize, 12662d5e0807SAlex Deucher .flush_hdp = &si_flush_hdp, 12672d5e0807SAlex Deucher .invalidate_hdp = &si_invalidate_hdp, 126862a37553SKen Wang }; 126962a37553SKen Wang 127062a37553SKen Wang static uint32_t si_get_rev_id(struct amdgpu_device *adev) 127162a37553SKen Wang { 127262a37553SKen Wang return (RREG32(CC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK) 127362a37553SKen Wang >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; 127462a37553SKen Wang } 127562a37553SKen Wang 127662a37553SKen Wang static int si_common_early_init(void *handle) 127762a37553SKen Wang { 127862a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 127962a37553SKen Wang 128062a37553SKen Wang adev->smc_rreg = &si_smc_rreg; 128162a37553SKen Wang adev->smc_wreg = &si_smc_wreg; 128262a37553SKen Wang adev->pcie_rreg = &si_pcie_rreg; 128362a37553SKen Wang adev->pcie_wreg = &si_pcie_wreg; 128436b9a952SHuang Rui adev->pciep_rreg = &si_pciep_rreg; 128536b9a952SHuang Rui adev->pciep_wreg = &si_pciep_wreg; 128662a37553SKen Wang adev->uvd_ctx_rreg = NULL; 128762a37553SKen Wang adev->uvd_ctx_wreg = NULL; 128862a37553SKen Wang adev->didt_rreg = NULL; 128962a37553SKen Wang adev->didt_wreg = NULL; 129062a37553SKen Wang 129162a37553SKen Wang adev->asic_funcs = &si_asic_funcs; 129262a37553SKen Wang 129362a37553SKen Wang adev->rev_id = si_get_rev_id(adev); 129462a37553SKen Wang adev->external_rev_id = 0xFF; 129562a37553SKen Wang switch (adev->asic_type) { 129662a37553SKen Wang case CHIP_TAHITI: 129762a37553SKen Wang adev->cg_flags = 129862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 129962a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 130062a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 130162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 130262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 130362a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 130462a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 130562a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 130662a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 130762a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 130862a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 130962a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 131062a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 131162a37553SKen Wang adev->pg_flags = 0; 13127c0a705eSFlora Cui adev->external_rev_id = (adev->rev_id == 0) ? 1 : 13137c0a705eSFlora Cui (adev->rev_id == 1) ? 5 : 6; 131462a37553SKen Wang break; 131562a37553SKen Wang case CHIP_PITCAIRN: 131662a37553SKen Wang adev->cg_flags = 131762a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 131862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 131962a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 132062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 132162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 132262a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 132362a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 132462a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 132562a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 132662a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 132762a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 132862a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 132962a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 133062a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 133162a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 133262a37553SKen Wang adev->pg_flags = 0; 1333e285a9a6SFlora Cui adev->external_rev_id = adev->rev_id + 20; 133462a37553SKen Wang break; 133562a37553SKen Wang 133662a37553SKen Wang case CHIP_VERDE: 133762a37553SKen Wang adev->cg_flags = 133862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 133962a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 134062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 134162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 134262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS_LS | 134362a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 134462a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 134562a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 134662a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 134762a37553SKen Wang AMD_CG_SUPPORT_SDMA_LS | 134862a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 134962a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 135062a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 135162a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 135262a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 135362a37553SKen Wang adev->pg_flags = 0; 135462a37553SKen Wang //??? 1355f815b29cSFlora Cui adev->external_rev_id = adev->rev_id + 40; 135662a37553SKen Wang break; 135762a37553SKen Wang case CHIP_OLAND: 135862a37553SKen Wang adev->cg_flags = 135962a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 136062a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 136162a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 136262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 136362a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 136462a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 136562a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 136662a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 136762a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 136862a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 136962a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 137062a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 137162a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 137262a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 137362a37553SKen Wang adev->pg_flags = 0; 13748fd74cb4SFlora Cui adev->external_rev_id = 60; 137562a37553SKen Wang break; 137662a37553SKen Wang case CHIP_HAINAN: 137762a37553SKen Wang adev->cg_flags = 137862a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 137962a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 138062a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 138162a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 138262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 138362a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 138462a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 138562a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 138662a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 138762a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 138862a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 138962a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 139062a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 139162a37553SKen Wang adev->pg_flags = 0; 139205319478SFlora Cui adev->external_rev_id = 70; 139362a37553SKen Wang break; 139462a37553SKen Wang 139562a37553SKen Wang default: 139662a37553SKen Wang return -EINVAL; 139762a37553SKen Wang } 139862a37553SKen Wang 139962a37553SKen Wang return 0; 140062a37553SKen Wang } 140162a37553SKen Wang 140262a37553SKen Wang static int si_common_sw_init(void *handle) 140362a37553SKen Wang { 140462a37553SKen Wang return 0; 140562a37553SKen Wang } 140662a37553SKen Wang 140762a37553SKen Wang static int si_common_sw_fini(void *handle) 140862a37553SKen Wang { 140962a37553SKen Wang return 0; 141062a37553SKen Wang } 141162a37553SKen Wang 141262a37553SKen Wang 141362a37553SKen Wang static void si_init_golden_registers(struct amdgpu_device *adev) 141462a37553SKen Wang { 141562a37553SKen Wang switch (adev->asic_type) { 141662a37553SKen Wang case CHIP_TAHITI: 14179c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 141862a37553SKen Wang tahiti_golden_registers, 1419c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_registers)); 14209c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 142162a37553SKen Wang tahiti_golden_rlc_registers, 1422c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_rlc_registers)); 14239c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 142462a37553SKen Wang tahiti_mgcg_cgcg_init, 1425c47b41a7SChristian König ARRAY_SIZE(tahiti_mgcg_cgcg_init)); 14269c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 142762a37553SKen Wang tahiti_golden_registers2, 1428c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_registers2)); 142962a37553SKen Wang break; 143062a37553SKen Wang case CHIP_PITCAIRN: 14319c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 143262a37553SKen Wang pitcairn_golden_registers, 1433c47b41a7SChristian König ARRAY_SIZE(pitcairn_golden_registers)); 14349c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 143562a37553SKen Wang pitcairn_golden_rlc_registers, 1436c47b41a7SChristian König ARRAY_SIZE(pitcairn_golden_rlc_registers)); 14379c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 143862a37553SKen Wang pitcairn_mgcg_cgcg_init, 1439c47b41a7SChristian König ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); 14405694785cSJean Delvare break; 144162a37553SKen Wang case CHIP_VERDE: 14429c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 144362a37553SKen Wang verde_golden_registers, 1444c47b41a7SChristian König ARRAY_SIZE(verde_golden_registers)); 14459c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 144662a37553SKen Wang verde_golden_rlc_registers, 1447c47b41a7SChristian König ARRAY_SIZE(verde_golden_rlc_registers)); 14489c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 144962a37553SKen Wang verde_mgcg_cgcg_init, 1450c47b41a7SChristian König ARRAY_SIZE(verde_mgcg_cgcg_init)); 14519c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 145262a37553SKen Wang verde_pg_init, 1453c47b41a7SChristian König ARRAY_SIZE(verde_pg_init)); 145462a37553SKen Wang break; 145562a37553SKen Wang case CHIP_OLAND: 14569c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 145762a37553SKen Wang oland_golden_registers, 1458c47b41a7SChristian König ARRAY_SIZE(oland_golden_registers)); 14599c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 146062a37553SKen Wang oland_golden_rlc_registers, 1461c47b41a7SChristian König ARRAY_SIZE(oland_golden_rlc_registers)); 14629c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 146362a37553SKen Wang oland_mgcg_cgcg_init, 1464c47b41a7SChristian König ARRAY_SIZE(oland_mgcg_cgcg_init)); 14655694785cSJean Delvare break; 146662a37553SKen Wang case CHIP_HAINAN: 14679c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 146862a37553SKen Wang hainan_golden_registers, 1469c47b41a7SChristian König ARRAY_SIZE(hainan_golden_registers)); 14709c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 147162a37553SKen Wang hainan_golden_registers2, 1472c47b41a7SChristian König ARRAY_SIZE(hainan_golden_registers2)); 14739c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 147462a37553SKen Wang hainan_mgcg_cgcg_init, 1475c47b41a7SChristian König ARRAY_SIZE(hainan_mgcg_cgcg_init)); 147662a37553SKen Wang break; 147762a37553SKen Wang 147862a37553SKen Wang 147962a37553SKen Wang default: 148062a37553SKen Wang BUG(); 148162a37553SKen Wang } 148262a37553SKen Wang } 148362a37553SKen Wang 148462a37553SKen Wang static void si_pcie_gen3_enable(struct amdgpu_device *adev) 148562a37553SKen Wang { 148662a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 148762a37553SKen Wang int bridge_pos, gpu_pos; 14880bf67185SAlex Deucher u32 speed_cntl, current_data_rate; 14890bf67185SAlex Deucher int i; 149062a37553SKen Wang u16 tmp16; 149162a37553SKen Wang 149262a37553SKen Wang if (pci_is_root_bus(adev->pdev->bus)) 149362a37553SKen Wang return; 149462a37553SKen Wang 149562a37553SKen Wang if (amdgpu_pcie_gen2 == 0) 149662a37553SKen Wang return; 149762a37553SKen Wang 149862a37553SKen Wang if (adev->flags & AMD_IS_APU) 149962a37553SKen Wang return; 150062a37553SKen Wang 15010bf67185SAlex Deucher if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | 15020bf67185SAlex Deucher CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) 150362a37553SKen Wang return; 150462a37553SKen Wang 150536b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 150662a37553SKen Wang current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> 150762a37553SKen Wang LC_CURRENT_DATA_RATE_SHIFT; 15080bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { 150962a37553SKen Wang if (current_data_rate == 2) { 151062a37553SKen Wang DRM_INFO("PCIE gen 3 link speeds already enabled\n"); 151162a37553SKen Wang return; 151262a37553SKen Wang } 151362a37553SKen Wang DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); 15140bf67185SAlex Deucher } else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) { 151562a37553SKen Wang if (current_data_rate == 1) { 151662a37553SKen Wang DRM_INFO("PCIE gen 2 link speeds already enabled\n"); 151762a37553SKen Wang return; 151862a37553SKen Wang } 151962a37553SKen Wang DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n"); 152062a37553SKen Wang } 152162a37553SKen Wang 152262a37553SKen Wang bridge_pos = pci_pcie_cap(root); 152362a37553SKen Wang if (!bridge_pos) 152462a37553SKen Wang return; 152562a37553SKen Wang 152662a37553SKen Wang gpu_pos = pci_pcie_cap(adev->pdev); 152762a37553SKen Wang if (!gpu_pos) 152862a37553SKen Wang return; 152962a37553SKen Wang 15300bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { 153162a37553SKen Wang if (current_data_rate != 2) { 153262a37553SKen Wang u16 bridge_cfg, gpu_cfg; 153362a37553SKen Wang u16 bridge_cfg2, gpu_cfg2; 153462a37553SKen Wang u32 max_lw, current_lw, tmp; 153562a37553SKen Wang 153662a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); 153762a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); 153862a37553SKen Wang 153962a37553SKen Wang tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD; 154062a37553SKen Wang pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); 154162a37553SKen Wang 154262a37553SKen Wang tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD; 154362a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); 154462a37553SKen Wang 154562a37553SKen Wang tmp = RREG32_PCIE(PCIE_LC_STATUS1); 154662a37553SKen Wang max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; 154762a37553SKen Wang current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; 154862a37553SKen Wang 154962a37553SKen Wang if (current_lw < max_lw) { 155036b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 155162a37553SKen Wang if (tmp & LC_RENEGOTIATION_SUPPORT) { 155262a37553SKen Wang tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); 155362a37553SKen Wang tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); 155462a37553SKen Wang tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; 155536b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); 155662a37553SKen Wang } 155762a37553SKen Wang } 155862a37553SKen Wang 155962a37553SKen Wang for (i = 0; i < 10; i++) { 156062a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16); 156162a37553SKen Wang if (tmp16 & PCI_EXP_DEVSTA_TRPND) 156262a37553SKen Wang break; 156362a37553SKen Wang 156462a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); 156562a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); 156662a37553SKen Wang 156762a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); 156862a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); 156962a37553SKen Wang 157036b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 157162a37553SKen Wang tmp |= LC_SET_QUIESCE; 157236b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 157362a37553SKen Wang 157436b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 157562a37553SKen Wang tmp |= LC_REDO_EQ; 157636b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 157762a37553SKen Wang 157862a37553SKen Wang mdelay(100); 157962a37553SKen Wang 158062a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16); 158162a37553SKen Wang tmp16 &= ~PCI_EXP_LNKCTL_HAWD; 158262a37553SKen Wang tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD); 158362a37553SKen Wang pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); 158462a37553SKen Wang 158562a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16); 158662a37553SKen Wang tmp16 &= ~PCI_EXP_LNKCTL_HAWD; 158762a37553SKen Wang tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD); 158862a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); 158962a37553SKen Wang 159062a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16); 159162a37553SKen Wang tmp16 &= ~((1 << 4) | (7 << 9)); 159262a37553SKen Wang tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9))); 159362a37553SKen Wang pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16); 159462a37553SKen Wang 159562a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); 159662a37553SKen Wang tmp16 &= ~((1 << 4) | (7 << 9)); 159762a37553SKen Wang tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); 159862a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); 159962a37553SKen Wang 160036b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 160162a37553SKen Wang tmp &= ~LC_SET_QUIESCE; 160236b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 160362a37553SKen Wang } 160462a37553SKen Wang } 160562a37553SKen Wang } 160662a37553SKen Wang 160762a37553SKen Wang speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; 160862a37553SKen Wang speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; 160936b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 161062a37553SKen Wang 161162a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); 161262a37553SKen Wang tmp16 &= ~0xf; 16130bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) 161462a37553SKen Wang tmp16 |= 3; 16150bf67185SAlex Deucher else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) 161662a37553SKen Wang tmp16 |= 2; 161762a37553SKen Wang else 161862a37553SKen Wang tmp16 |= 1; 161962a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); 162062a37553SKen Wang 162136b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 162262a37553SKen Wang speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; 162336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 162462a37553SKen Wang 162562a37553SKen Wang for (i = 0; i < adev->usec_timeout; i++) { 162636b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 162762a37553SKen Wang if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) 162862a37553SKen Wang break; 162962a37553SKen Wang udelay(1); 163062a37553SKen Wang } 163162a37553SKen Wang } 163262a37553SKen Wang 163362a37553SKen Wang static inline u32 si_pif_phy0_rreg(struct amdgpu_device *adev, u32 reg) 163462a37553SKen Wang { 163562a37553SKen Wang unsigned long flags; 163662a37553SKen Wang u32 r; 163762a37553SKen Wang 163862a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 163962a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 164062a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY0_DATA); 164162a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 164262a37553SKen Wang return r; 164362a37553SKen Wang } 164462a37553SKen Wang 164562a37553SKen Wang static inline void si_pif_phy0_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 164662a37553SKen Wang { 164762a37553SKen Wang unsigned long flags; 164862a37553SKen Wang 164962a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 165062a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 165162a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); 165262a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 165362a37553SKen Wang } 165462a37553SKen Wang 165562a37553SKen Wang static inline u32 si_pif_phy1_rreg(struct amdgpu_device *adev, u32 reg) 165662a37553SKen Wang { 165762a37553SKen Wang unsigned long flags; 165862a37553SKen Wang u32 r; 165962a37553SKen Wang 166062a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 166162a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 166262a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY1_DATA); 166362a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 166462a37553SKen Wang return r; 166562a37553SKen Wang } 166662a37553SKen Wang 166762a37553SKen Wang static inline void si_pif_phy1_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 166862a37553SKen Wang { 166962a37553SKen Wang unsigned long flags; 167062a37553SKen Wang 167162a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 167262a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 167362a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); 167462a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 167562a37553SKen Wang } 167662a37553SKen Wang static void si_program_aspm(struct amdgpu_device *adev) 167762a37553SKen Wang { 167862a37553SKen Wang u32 data, orig; 167962a37553SKen Wang bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; 168062a37553SKen Wang bool disable_clkreq = false; 168162a37553SKen Wang 168262a37553SKen Wang if (amdgpu_aspm == 0) 168362a37553SKen Wang return; 168462a37553SKen Wang 168562a37553SKen Wang if (adev->flags & AMD_IS_APU) 168662a37553SKen Wang return; 168736b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 168862a37553SKen Wang data &= ~LC_XMIT_N_FTS_MASK; 168962a37553SKen Wang data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; 169062a37553SKen Wang if (orig != data) 169136b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); 169262a37553SKen Wang 169336b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); 169462a37553SKen Wang data |= LC_GO_TO_RECOVERY; 169562a37553SKen Wang if (orig != data) 169636b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); 169762a37553SKen Wang 169862a37553SKen Wang orig = data = RREG32_PCIE(PCIE_P_CNTL); 169962a37553SKen Wang data |= P_IGNORE_EDB_ERR; 170062a37553SKen Wang if (orig != data) 170162a37553SKen Wang WREG32_PCIE(PCIE_P_CNTL, data); 170262a37553SKen Wang 170336b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 170462a37553SKen Wang data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); 170562a37553SKen Wang data |= LC_PMI_TO_L1_DIS; 170662a37553SKen Wang if (!disable_l0s) 170762a37553SKen Wang data |= LC_L0S_INACTIVITY(7); 170862a37553SKen Wang 170962a37553SKen Wang if (!disable_l1) { 171062a37553SKen Wang data |= LC_L1_INACTIVITY(7); 171162a37553SKen Wang data &= ~LC_PMI_TO_L1_DIS; 171262a37553SKen Wang if (orig != data) 171336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 171462a37553SKen Wang 171562a37553SKen Wang if (!disable_plloff_in_l1) { 171662a37553SKen Wang bool clk_req_support; 171762a37553SKen Wang 171862a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 171962a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 172062a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 172162a37553SKen Wang if (orig != data) 172262a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 172362a37553SKen Wang 172462a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 172562a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 172662a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 172762a37553SKen Wang if (orig != data) 172862a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 172962a37553SKen Wang 173062a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 173162a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 173262a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 173362a37553SKen Wang if (orig != data) 173462a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 173562a37553SKen Wang 173662a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 173762a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 173862a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 173962a37553SKen Wang if (orig != data) 174062a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 174162a37553SKen Wang 174262a37553SKen Wang if ((adev->family != CHIP_OLAND) && (adev->family != CHIP_HAINAN)) { 174362a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 174462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 174562a37553SKen Wang if (orig != data) 174662a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 174762a37553SKen Wang 174862a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 174962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 175062a37553SKen Wang if (orig != data) 175162a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 175262a37553SKen Wang 175362a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_2); 175462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 175562a37553SKen Wang if (orig != data) 175662a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_2, data); 175762a37553SKen Wang 175862a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_3); 175962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 176062a37553SKen Wang if (orig != data) 176162a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_3, data); 176262a37553SKen Wang 176362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 176462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 176562a37553SKen Wang if (orig != data) 176662a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 176762a37553SKen Wang 176862a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 176962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 177062a37553SKen Wang if (orig != data) 177162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 177262a37553SKen Wang 177362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_2); 177462a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 177562a37553SKen Wang if (orig != data) 177662a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_2, data); 177762a37553SKen Wang 177862a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_3); 177962a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 178062a37553SKen Wang if (orig != data) 178162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); 178262a37553SKen Wang } 178336b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 178462a37553SKen Wang data &= ~LC_DYN_LANES_PWR_STATE_MASK; 178562a37553SKen Wang data |= LC_DYN_LANES_PWR_STATE(3); 178662a37553SKen Wang if (orig != data) 178736b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); 178862a37553SKen Wang 178962a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); 179062a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 179162a37553SKen Wang if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN)) 179262a37553SKen Wang data |= LS2_EXIT_TIME(5); 179362a37553SKen Wang if (orig != data) 179462a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_CNTL, data); 179562a37553SKen Wang 179662a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_CNTL); 179762a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 179862a37553SKen Wang if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN)) 179962a37553SKen Wang data |= LS2_EXIT_TIME(5); 180062a37553SKen Wang if (orig != data) 180162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_CNTL, data); 180262a37553SKen Wang 180362a37553SKen Wang if (!disable_clkreq && 180462a37553SKen Wang !pci_is_root_bus(adev->pdev->bus)) { 180562a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 180662a37553SKen Wang u32 lnkcap; 180762a37553SKen Wang 180862a37553SKen Wang clk_req_support = false; 180962a37553SKen Wang pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); 181062a37553SKen Wang if (lnkcap & PCI_EXP_LNKCAP_CLKPM) 181162a37553SKen Wang clk_req_support = true; 181262a37553SKen Wang } else { 181362a37553SKen Wang clk_req_support = false; 181462a37553SKen Wang } 181562a37553SKen Wang 181662a37553SKen Wang if (clk_req_support) { 181736b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); 181862a37553SKen Wang data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; 181962a37553SKen Wang if (orig != data) 182036b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); 182162a37553SKen Wang 182262a37553SKen Wang orig = data = RREG32(THM_CLK_CNTL); 182362a37553SKen Wang data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); 182462a37553SKen Wang data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); 182562a37553SKen Wang if (orig != data) 182662a37553SKen Wang WREG32(THM_CLK_CNTL, data); 182762a37553SKen Wang 182862a37553SKen Wang orig = data = RREG32(MISC_CLK_CNTL); 182962a37553SKen Wang data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); 183062a37553SKen Wang data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); 183162a37553SKen Wang if (orig != data) 183262a37553SKen Wang WREG32(MISC_CLK_CNTL, data); 183362a37553SKen Wang 183462a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL); 183562a37553SKen Wang data &= ~BCLK_AS_XCLK; 183662a37553SKen Wang if (orig != data) 183762a37553SKen Wang WREG32(CG_CLKPIN_CNTL, data); 183862a37553SKen Wang 183962a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL_2); 184062a37553SKen Wang data &= ~FORCE_BIF_REFCLK_EN; 184162a37553SKen Wang if (orig != data) 184262a37553SKen Wang WREG32(CG_CLKPIN_CNTL_2, data); 184362a37553SKen Wang 184462a37553SKen Wang orig = data = RREG32(MPLL_BYPASSCLK_SEL); 184562a37553SKen Wang data &= ~MPLL_CLKOUT_SEL_MASK; 184662a37553SKen Wang data |= MPLL_CLKOUT_SEL(4); 184762a37553SKen Wang if (orig != data) 184862a37553SKen Wang WREG32(MPLL_BYPASSCLK_SEL, data); 184962a37553SKen Wang 185062a37553SKen Wang orig = data = RREG32(SPLL_CNTL_MODE); 185162a37553SKen Wang data &= ~SPLL_REFCLK_SEL_MASK; 185262a37553SKen Wang if (orig != data) 185362a37553SKen Wang WREG32(SPLL_CNTL_MODE, data); 185462a37553SKen Wang } 185562a37553SKen Wang } 185662a37553SKen Wang } else { 185762a37553SKen Wang if (orig != data) 185836b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 185962a37553SKen Wang } 186062a37553SKen Wang 186162a37553SKen Wang orig = data = RREG32_PCIE(PCIE_CNTL2); 186262a37553SKen Wang data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; 186362a37553SKen Wang if (orig != data) 186462a37553SKen Wang WREG32_PCIE(PCIE_CNTL2, data); 186562a37553SKen Wang 186662a37553SKen Wang if (!disable_l0s) { 186736b9a952SHuang Rui data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 186862a37553SKen Wang if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { 186962a37553SKen Wang data = RREG32_PCIE(PCIE_LC_STATUS1); 187062a37553SKen Wang if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { 187136b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 187262a37553SKen Wang data &= ~LC_L0S_INACTIVITY_MASK; 187362a37553SKen Wang if (orig != data) 187436b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 187562a37553SKen Wang } 187662a37553SKen Wang } 187762a37553SKen Wang } 187862a37553SKen Wang } 187962a37553SKen Wang 188062a37553SKen Wang static void si_fix_pci_max_read_req_size(struct amdgpu_device *adev) 188162a37553SKen Wang { 188262a37553SKen Wang int readrq; 188362a37553SKen Wang u16 v; 188462a37553SKen Wang 188562a37553SKen Wang readrq = pcie_get_readrq(adev->pdev); 188662a37553SKen Wang v = ffs(readrq) - 8; 188762a37553SKen Wang if ((v == 0) || (v == 6) || (v == 7)) 188862a37553SKen Wang pcie_set_readrq(adev->pdev, 512); 188962a37553SKen Wang } 189062a37553SKen Wang 189162a37553SKen Wang static int si_common_hw_init(void *handle) 189262a37553SKen Wang { 189362a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 189462a37553SKen Wang 189562a37553SKen Wang si_fix_pci_max_read_req_size(adev); 189662a37553SKen Wang si_init_golden_registers(adev); 189762a37553SKen Wang si_pcie_gen3_enable(adev); 189862a37553SKen Wang si_program_aspm(adev); 189962a37553SKen Wang 190062a37553SKen Wang return 0; 190162a37553SKen Wang } 190262a37553SKen Wang 190362a37553SKen Wang static int si_common_hw_fini(void *handle) 190462a37553SKen Wang { 190562a37553SKen Wang return 0; 190662a37553SKen Wang } 190762a37553SKen Wang 190862a37553SKen Wang static int si_common_suspend(void *handle) 190962a37553SKen Wang { 191062a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 191162a37553SKen Wang 191262a37553SKen Wang return si_common_hw_fini(adev); 191362a37553SKen Wang } 191462a37553SKen Wang 191562a37553SKen Wang static int si_common_resume(void *handle) 191662a37553SKen Wang { 191762a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 191862a37553SKen Wang 191962a37553SKen Wang return si_common_hw_init(adev); 192062a37553SKen Wang } 192162a37553SKen Wang 192262a37553SKen Wang static bool si_common_is_idle(void *handle) 192362a37553SKen Wang { 192462a37553SKen Wang return true; 192562a37553SKen Wang } 192662a37553SKen Wang 192762a37553SKen Wang static int si_common_wait_for_idle(void *handle) 192862a37553SKen Wang { 192962a37553SKen Wang return 0; 193062a37553SKen Wang } 193162a37553SKen Wang 193262a37553SKen Wang static int si_common_soft_reset(void *handle) 193362a37553SKen Wang { 193462a37553SKen Wang return 0; 193562a37553SKen Wang } 193662a37553SKen Wang 193762a37553SKen Wang static int si_common_set_clockgating_state(void *handle, 193862a37553SKen Wang enum amd_clockgating_state state) 193962a37553SKen Wang { 194062a37553SKen Wang return 0; 194162a37553SKen Wang } 194262a37553SKen Wang 194362a37553SKen Wang static int si_common_set_powergating_state(void *handle, 194462a37553SKen Wang enum amd_powergating_state state) 194562a37553SKen Wang { 194662a37553SKen Wang return 0; 194762a37553SKen Wang } 194862a37553SKen Wang 1949a1255107SAlex Deucher static const struct amd_ip_funcs si_common_ip_funcs = { 195062a37553SKen Wang .name = "si_common", 195162a37553SKen Wang .early_init = si_common_early_init, 195262a37553SKen Wang .late_init = NULL, 195362a37553SKen Wang .sw_init = si_common_sw_init, 195462a37553SKen Wang .sw_fini = si_common_sw_fini, 195562a37553SKen Wang .hw_init = si_common_hw_init, 195662a37553SKen Wang .hw_fini = si_common_hw_fini, 195762a37553SKen Wang .suspend = si_common_suspend, 195862a37553SKen Wang .resume = si_common_resume, 195962a37553SKen Wang .is_idle = si_common_is_idle, 196062a37553SKen Wang .wait_for_idle = si_common_wait_for_idle, 196162a37553SKen Wang .soft_reset = si_common_soft_reset, 196262a37553SKen Wang .set_clockgating_state = si_common_set_clockgating_state, 196362a37553SKen Wang .set_powergating_state = si_common_set_powergating_state, 196462a37553SKen Wang }; 196562a37553SKen Wang 1966a1255107SAlex Deucher static const struct amdgpu_ip_block_version si_common_ip_block = 196762a37553SKen Wang { 196862a37553SKen Wang .type = AMD_IP_BLOCK_TYPE_COMMON, 196962a37553SKen Wang .major = 1, 197062a37553SKen Wang .minor = 0, 197162a37553SKen Wang .rev = 0, 197262a37553SKen Wang .funcs = &si_common_ip_funcs, 19732120df47SAlex Deucher }; 19742120df47SAlex Deucher 197562a37553SKen Wang int si_set_ip_blocks(struct amdgpu_device *adev) 197662a37553SKen Wang { 1977c8394f38SXiangliang Yu si_detect_hw_virtualization(adev); 1978c8394f38SXiangliang Yu 197962a37553SKen Wang switch (adev->asic_type) { 198062a37553SKen Wang case CHIP_VERDE: 198162a37553SKen Wang case CHIP_TAHITI: 198262a37553SKen Wang case CHIP_PITCAIRN: 19832990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 19842990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 19852990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 1986*b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 1987a1255107SAlex Deucher if (adev->enable_virtual_display) 19882990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 1989a1255107SAlex Deucher else 19902990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_v6_0_ip_block); 19912990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 19922990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 19932990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ 19942990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 1995a1255107SAlex Deucher break; 199662a37553SKen Wang case CHIP_OLAND: 19972990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 19982990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 19992990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 2000*b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2001a1255107SAlex Deucher if (adev->enable_virtual_display) 20022990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 2003a1255107SAlex Deucher else 20042990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); 20052990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 20062990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 20072990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ 20082990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 200962a37553SKen Wang break; 201062a37553SKen Wang case CHIP_HAINAN: 20112990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 20122990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 20132990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 2014*b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2015a1255107SAlex Deucher if (adev->enable_virtual_display) 20162990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 20172990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 20182990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 201962a37553SKen Wang break; 202062a37553SKen Wang default: 202162a37553SKen Wang BUG(); 202262a37553SKen Wang } 202362a37553SKen Wang return 0; 202462a37553SKen Wang } 202562a37553SKen Wang 2026