162a37553SKen Wang /* 262a37553SKen Wang * Copyright 2015 Advanced Micro Devices, Inc. 362a37553SKen Wang * 462a37553SKen Wang * Permission is hereby granted, free of charge, to any person obtaining a 562a37553SKen Wang * copy of this software and associated documentation files (the "Software"), 662a37553SKen Wang * to deal in the Software without restriction, including without limitation 762a37553SKen Wang * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862a37553SKen Wang * and/or sell copies of the Software, and to permit persons to whom the 962a37553SKen Wang * Software is furnished to do so, subject to the following conditions: 1062a37553SKen Wang * 1162a37553SKen Wang * The above copyright notice and this permission notice shall be included in 1262a37553SKen Wang * all copies or substantial portions of the Software. 1362a37553SKen Wang * 1462a37553SKen Wang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562a37553SKen Wang * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662a37553SKen Wang * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762a37553SKen Wang * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862a37553SKen Wang * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962a37553SKen Wang * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062a37553SKen Wang * OTHER DEALINGS IN THE SOFTWARE. 2162a37553SKen Wang * 2262a37553SKen Wang */ 2362a37553SKen Wang 2462a37553SKen Wang #include <linux/firmware.h> 2562a37553SKen Wang #include <linux/slab.h> 2662a37553SKen Wang #include <linux/module.h> 2747b757fbSSam Ravnborg #include <linux/pci.h> 2847b757fbSSam Ravnborg 2962a37553SKen Wang #include "amdgpu.h" 3062a37553SKen Wang #include "amdgpu_atombios.h" 3162a37553SKen Wang #include "amdgpu_ih.h" 3262a37553SKen Wang #include "amdgpu_uvd.h" 3362a37553SKen Wang #include "amdgpu_vce.h" 3462a37553SKen Wang #include "atom.h" 350bf67185SAlex Deucher #include "amd_pcie.h" 36b905090dSRex Zhu #include "si_dpm.h" 37689957b1SAlex Deucher #include "sid.h" 3862a37553SKen Wang #include "si_ih.h" 3962a37553SKen Wang #include "gfx_v6_0.h" 4062a37553SKen Wang #include "gmc_v6_0.h" 4162a37553SKen Wang #include "si_dma.h" 4262a37553SKen Wang #include "dce_v6_0.h" 4362a37553SKen Wang #include "si.h" 44d375615cSSonny Jiang #include "uvd_v3_1.h" 452120df47SAlex Deucher #include "dce_virtual.h" 4678bbe771STom St Denis #include "gca/gfx_6_0_d.h" 4778bbe771STom St Denis #include "oss/oss_1_0_d.h" 489c39d77cSAlex Deucher #include "oss/oss_1_0_sh_mask.h" 4978bbe771STom St Denis #include "gmc/gmc_6_0_d.h" 5078bbe771STom St Denis #include "dce/dce_6_0_d.h" 5178bbe771STom St Denis #include "uvd/uvd_4_0_d.h" 52bbf282d8SAlex Deucher #include "bif/bif_3_0_d.h" 53b45e18acSKent Russell #include "bif/bif_3_0_sh_mask.h" 5462a37553SKen Wang 5564200c46SMauro Rossi #include "amdgpu_dm.h" 5664200c46SMauro Rossi 5762a37553SKen Wang static const u32 tahiti_golden_registers[] = 5862a37553SKen Wang { 5978bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 6078bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 6178bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 6278bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 6378bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 6478bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 657c0a705eSFlora Cui 0x340c, 0x000000c0, 0x00800040, 667c0a705eSFlora Cui 0x360c, 0x000000c0, 0x00800040, 6778bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 6878bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 6978bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 7078bbe771STom St Denis mmMC_ARB_WTM_CNTL_RD, 0x00000003, 0x000007ff, 7178bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 7278bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 7378bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 7478bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 7578bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 7678bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, 777c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0040, 7862a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 7978bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 8078bbe771STom St Denis mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, 8178bbe771STom St Denis mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, 8278bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 8378bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 8478bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x00000200, 0x000002fb, 8578bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, 8678bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, 8778bbe771STom St Denis mmVGT_FIFO_DEPTHS, 0xffffffff, 0x000fff40, 8878bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 8978bbe771STom St Denis mmVM_CONTEXT0_CNTL, 0x20000000, 0x20fffed8, 9078bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 9178bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 9278bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 9378bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 9478bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 9562a37553SKen Wang }; 9662a37553SKen Wang 9762a37553SKen Wang static const u32 tahiti_golden_registers2[] = 9862a37553SKen Wang { 9978bbe771STom St Denis mmMCIF_MEM_CONTROL, 0x00000001, 0x00000001, 10062a37553SKen Wang }; 10162a37553SKen Wang 10262a37553SKen Wang static const u32 tahiti_golden_rlc_registers[] = 10362a37553SKen Wang { 10478bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, 10578bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, 10662a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 10762a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 10878bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 10978bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, 11078bbe771STom St Denis mmUVD_CGC_GATE, 0x00000008, 0x00000000, 11162a37553SKen Wang }; 11262a37553SKen Wang 11362a37553SKen Wang static const u32 pitcairn_golden_registers[] = 11462a37553SKen Wang { 11578bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 11678bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 11778bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 11878bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 11978bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 12078bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 12162a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 12262a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 12378bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 12478bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 12578bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 12678bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 12778bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 12878bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 12978bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 13078bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 13178bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 13278bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, 1331245a694SFlora Cui 0x000c, 0xffffffff, 0x0040, 13462a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 13578bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 13678bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 13778bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 13878bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f7, 13978bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 14078bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x32761054, 14178bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 14278bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 14378bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 14478bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14578bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14678bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 14762a37553SKen Wang }; 14862a37553SKen Wang 14962a37553SKen Wang static const u32 pitcairn_golden_rlc_registers[] = 15062a37553SKen Wang { 15178bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, 15278bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601004, 15362a37553SKen Wang 0x311f, 0xffffffff, 0x10102020, 15462a37553SKen Wang 0x3122, 0xffffffff, 0x01000020, 15578bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 15678bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000a4, 15762a37553SKen Wang }; 15862a37553SKen Wang 15962a37553SKen Wang static const u32 verde_pg_init[] = 16062a37553SKen Wang { 16178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x40000, 16278bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x200010ff, 16378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x7007, 16978bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x300010ff, 17078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x400000, 17678bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x100010ff, 17778bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x120200, 18378bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x500010ff, 18478bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x1e1e16, 19078bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x600010ff, 19178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 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, 0x171f1e, 19778bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x700010ff, 19878bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 19978bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20078bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20178bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20278bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20378bbe771STom St Denis mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, 20478bbe771STom St Denis mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x9ff, 20578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x0, 20678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10000800, 20778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, 20878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, 20978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4, 21078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1000051e, 21178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, 21278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, 21378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x8, 21478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x80500, 21578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x12, 21678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x9050c, 21778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1d, 21878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xb052c, 21978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2a, 22078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1053e, 22178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2d, 22278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10546, 22378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x30, 22478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xa054e, 22578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3c, 22678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1055f, 22778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3f, 22878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10567, 22978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x42, 23078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1056f, 23178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x45, 23278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10572, 23378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x48, 23478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20575, 23578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4c, 23678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x190801, 23778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x67, 23878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1082a, 23978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x6a, 24078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1b082d, 24178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x87, 24278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x310851, 24378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xba, 24478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x891, 24578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbc, 24678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x893, 24778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbe, 24878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20895, 24978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc2, 25078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20899, 25178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc6, 25278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2089d, 25378bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xca, 25478bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a1, 25578bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xcc, 25678bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a3, 25778bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xce, 25878bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x308a5, 25978bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xd3, 26078bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x6d08cd, 26178bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x142, 26278bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2000095a, 26378bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1, 26478bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x144, 26578bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x301f095b, 26678bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x165, 26778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc094d, 26878bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x173, 26978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf096d, 27078bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x184, 27178bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x15097f, 27278bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x19b, 27378bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc0998, 27478bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1a9, 27578bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x409a7, 27678bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1af, 27778bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xcdc, 27878bbe771STom St Denis mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1b1, 27978bbe771STom St Denis mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x800, 28078bbe771STom St Denis mmGMCON_RENG_EXECUTE, 0xffffffff, 0x6c9b2000, 28178bbe771STom St Denis mmGMCON_MISC2, 0xfc00, 0x2000, 28278bbe771STom St Denis mmGMCON_MISC3, 0xffffffff, 0xfc0, 28378bbe771STom St Denis mmMC_PMG_AUTO_CFG, 0x00000100, 0x100, 28462a37553SKen Wang }; 28562a37553SKen Wang 28662a37553SKen Wang static const u32 verde_golden_rlc_registers[] = 28762a37553SKen Wang { 28878bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, 28978bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x033f1005, 29062a37553SKen Wang 0x311f, 0xffffffff, 0x10808020, 29162a37553SKen Wang 0x3122, 0xffffffff, 0x00800008, 29278bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00001000, 29378bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x80010014, 29462a37553SKen Wang }; 29562a37553SKen Wang 29662a37553SKen Wang static const u32 verde_golden_registers[] = 29762a37553SKen Wang { 29878bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 29978bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 30078bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 30178bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 30278bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 30378bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 30462a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 30562a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 30678bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 30778bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 30878bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 30978bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 31078bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 31178bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 31278bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 31378bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 31478bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 31578bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x0000124a, 316dae5c298SFlora Cui 0x000c, 0xffffffff, 0x0040, 31762a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 31878bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 31978bbe771STom St Denis mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, 32078bbe771STom St Denis mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, 32178bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 32278bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 32378bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x00000003, 32478bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 32578bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00001032, 32678bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 32778bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 32878bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 32978bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 33078bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 33178bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 33262a37553SKen Wang }; 33362a37553SKen Wang 33462a37553SKen Wang static const u32 oland_golden_registers[] = 33562a37553SKen Wang { 33678bbe771STom St Denis mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, 33778bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 33878bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 33978bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 34078bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 34178bbe771STom St Denis mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 34262a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 34362a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 34478bbe771STom St Denis mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 34578bbe771STom St Denis mmFBC_MISC, 0x00200000, 0x50100000, 34678bbe771STom St Denis mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, 34778bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 34878bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 34978bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 35078bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 35178bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 35278bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 35378bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000082, 3546b7985efSFlora Cui 0x000c, 0xffffffff, 0x0040, 35562a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 35678bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, 35778bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 35878bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 35978bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f3, 36078bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 36178bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, 36278bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 36378bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 36478bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 36578bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36678bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36778bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 36878bbe771STom St Denis 36962a37553SKen Wang }; 37062a37553SKen Wang 37162a37553SKen Wang static const u32 oland_golden_rlc_registers[] = 37262a37553SKen Wang { 37378bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, 37478bbe771STom St Denis mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, 37562a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 37662a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 37778bbe771STom St Denis mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, 37878bbe771STom St Denis mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, 37962a37553SKen Wang }; 38062a37553SKen Wang 38162a37553SKen Wang static const u32 hainan_golden_registers[] = 38262a37553SKen Wang { 383bd27b678SFlora Cui 0x17bc, 0x00000030, 0x00000011, 38478bbe771STom St Denis mmCB_HW_CONTROL, 0x00010000, 0x00018208, 38578bbe771STom St Denis mmDB_DEBUG, 0xffffffff, 0x00000000, 38678bbe771STom St Denis mmDB_DEBUG2, 0xf00fffff, 0x00000400, 38778bbe771STom St Denis mmDB_DEBUG3, 0x0002021c, 0x00020200, 388bd27b678SFlora Cui 0x031e, 0x00000080, 0x00000000, 389bd27b678SFlora Cui 0x3430, 0xff000fff, 0x00000100, 39062a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 39162a37553SKen Wang 0x3630, 0xff000fff, 0x00000100, 39262a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 393bd27b678SFlora Cui 0x16ec, 0x000000f0, 0x00000070, 394bd27b678SFlora Cui 0x16f0, 0x00200000, 0x50100000, 395bd27b678SFlora Cui 0x1c0c, 0x31000311, 0x00000011, 39678bbe771STom St Denis mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, 39778bbe771STom St Denis mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, 39878bbe771STom St Denis mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, 39978bbe771STom St Denis mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, 40078bbe771STom St Denis mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 40178bbe771STom St Denis mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, 40278bbe771STom St Denis mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000000, 403bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0040, 40462a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 40578bbe771STom St Denis mmSPI_CONFIG_CNTL, 0x03e00000, 0x03600000, 40678bbe771STom St Denis mmSX_DEBUG_1, 0x0000007f, 0x00000020, 40778bbe771STom St Denis mmTA_CNTL_AUX, 0x00010000, 0x00010000, 40878bbe771STom St Denis mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f1, 40978bbe771STom St Denis mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, 41078bbe771STom St Denis mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, 41178bbe771STom St Denis mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, 41278bbe771STom St Denis mmVM_L2_CG, 0x000c0fc0, 0x000c0400, 41378bbe771STom St Denis mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, 41478bbe771STom St Denis mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41578bbe771STom St Denis mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41678bbe771STom St Denis mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, 41762a37553SKen Wang }; 41862a37553SKen Wang 41962a37553SKen Wang static const u32 hainan_golden_registers2[] = 42062a37553SKen Wang { 42178bbe771STom St Denis mmGB_ADDR_CONFIG, 0xffffffff, 0x2011003, 42262a37553SKen Wang }; 42362a37553SKen Wang 42462a37553SKen Wang static const u32 tahiti_mgcg_cgcg_init[] = 42562a37553SKen Wang { 42678bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 42778bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 42878bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 42978bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 43078bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 43178bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 43278bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 43378bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 43478bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 43578bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 43678bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 43778bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 43878bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 43978bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 44078bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 44178bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 44278bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 44378bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 44478bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 44578bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 44678bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 44778bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 44878bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 44978bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 45078bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 45178bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 45278bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 45362a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 45462a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 45562a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 45662a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 45762a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 45862a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 45962a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 46062a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 46162a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 46262a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 46362a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 46462a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 46562a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 46662a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 46762a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 46862a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 46962a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 47062a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 47162a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 47262a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 47362a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 47462a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 47562a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 47662a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 47762a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 47862a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 47962a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 48062a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 48162a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 48262a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 48362a37553SKen Wang 0x2476, 0xffffffff, 0x00070006, 48462a37553SKen Wang 0x2477, 0xffffffff, 0x00090008, 48562a37553SKen Wang 0x2478, 0xffffffff, 0x0000000c, 48662a37553SKen Wang 0x2479, 0xffffffff, 0x000b000a, 48762a37553SKen Wang 0x247a, 0xffffffff, 0x000e000d, 48862a37553SKen Wang 0x247b, 0xffffffff, 0x00080007, 48962a37553SKen Wang 0x247c, 0xffffffff, 0x000a0009, 49062a37553SKen Wang 0x247d, 0xffffffff, 0x0000000d, 49162a37553SKen Wang 0x247e, 0xffffffff, 0x000c000b, 49262a37553SKen Wang 0x247f, 0xffffffff, 0x000f000e, 49362a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 49462a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 49562a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 49662a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 49762a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 49862a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 49962a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 50062a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 50162a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 50262a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 50362a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 50462a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 50562a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 50662a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 50762a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 50862a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 50962a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 51062a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 51162a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 51262a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 51362a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 51462a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 51562a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 51662a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 51762a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 51862a37553SKen Wang 0x2499, 0xffffffff, 0x000e000d, 51962a37553SKen Wang 0x249a, 0xffffffff, 0x0010000f, 52062a37553SKen Wang 0x249b, 0xffffffff, 0x00000013, 52162a37553SKen Wang 0x249c, 0xffffffff, 0x00120011, 52262a37553SKen Wang 0x249d, 0xffffffff, 0x00150014, 52362a37553SKen Wang 0x249e, 0xffffffff, 0x000f000e, 52462a37553SKen Wang 0x249f, 0xffffffff, 0x00110010, 52562a37553SKen Wang 0x24a0, 0xffffffff, 0x00000014, 52662a37553SKen Wang 0x24a1, 0xffffffff, 0x00130012, 52762a37553SKen Wang 0x24a2, 0xffffffff, 0x00160015, 52862a37553SKen Wang 0x24a3, 0xffffffff, 0x0010000f, 52962a37553SKen Wang 0x24a4, 0xffffffff, 0x00120011, 53062a37553SKen Wang 0x24a5, 0xffffffff, 0x00000015, 53162a37553SKen Wang 0x24a6, 0xffffffff, 0x00140013, 53262a37553SKen Wang 0x24a7, 0xffffffff, 0x00170016, 53378bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 53478bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 53578bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 53678bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 5377c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 5387c0a705eSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 5397c0a705eSFlora Cui 0x0583, 0xffffffff, 0x00000100, 54078bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 54178bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 54278bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 54378bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 54478bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 54578bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 54662a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 54778bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 54878bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 54978bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 55062a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 55178bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 55262a37553SKen Wang }; 55362a37553SKen Wang static const u32 pitcairn_mgcg_cgcg_init[] = 55462a37553SKen Wang { 55578bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 55678bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 55778bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 55878bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 55978bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 56078bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 56178bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 56278bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 56378bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 56478bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 56578bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 56678bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 56778bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 56878bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 56978bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 57078bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 57178bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 57278bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 57378bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 57478bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 57578bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 57678bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 57778bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 57878bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 57978bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 58078bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 58178bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 58262a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 58362a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 58462a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 58562a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 58662a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 58762a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 58862a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 58962a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 59062a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 59162a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 59262a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 59362a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 59462a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 59562a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 59662a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 59762a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 59862a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 59962a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 60062a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 60162a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 60262a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 60362a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 60462a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 60562a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 60662a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 60762a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 60862a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 60962a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 61062a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 61162a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 61262a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 61362a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 61462a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 61562a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 61662a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 61762a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 61862a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 61962a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 62062a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 62162a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 62262a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 62362a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 62462a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 62562a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 62662a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 62762a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 62862a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 62962a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 63062a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 63162a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 63278bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 63378bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 63478bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 63578bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 6361245a694SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 6371245a694SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 6381245a694SFlora Cui 0x0583, 0xffffffff, 0x00000100, 63978bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 64078bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 64178bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 64278bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 64362a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 64478bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 64578bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 64678bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 64762a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 64878bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 64962a37553SKen Wang }; 65078bbe771STom St Denis 65162a37553SKen Wang static const u32 verde_mgcg_cgcg_init[] = 65262a37553SKen Wang { 65378bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 65478bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 65578bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 65678bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 65778bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 65878bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 65978bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 66078bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 66178bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 66278bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 66378bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 66478bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 66578bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 66678bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 66778bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 66878bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 66978bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 67078bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 67178bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 67278bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 67378bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 67478bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 67578bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 67678bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 67778bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 67878bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 67978bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 68062a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 68162a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 68262a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 68362a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 68462a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 68562a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 68662a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 68762a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 68862a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 68962a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 69062a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 69162a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 69262a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 69362a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 69462a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 69562a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 69662a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 69762a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 69862a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 69962a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 70062a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 70162a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 70262a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 70362a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 70462a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 70562a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 70662a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 70762a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 70862a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 70962a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 71062a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 71162a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 71262a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 71362a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 71462a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 71562a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 71662a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 71762a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 71862a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 71962a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 72062a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 72162a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 72262a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 72362a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 72462a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 72562a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 72662a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 72762a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 72862a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 72962a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 73078bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 73178bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 73278bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 73378bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 734dae5c298SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 735dae5c298SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 736dae5c298SFlora Cui 0x0583, 0xffffffff, 0x00000100, 73778bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 73878bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 73978bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 74078bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 74178bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 74278bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 74362a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 74478bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 74578bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 74678bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 74762a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 74878bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 74962a37553SKen Wang }; 75078bbe771STom St Denis 75162a37553SKen Wang static const u32 oland_mgcg_cgcg_init[] = 75262a37553SKen Wang { 75378bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 75478bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 75578bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 75678bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 75778bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 75878bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 75978bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 76078bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 76178bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 76278bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 76378bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 76478bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 76578bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 76678bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 76778bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 76878bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 76978bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 77078bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 77178bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 77278bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 77378bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 77478bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 77578bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 77678bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 77778bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 77878bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 77978bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 78062a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 78162a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 78262a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 78362a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 78462a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 78562a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 78662a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 78762a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 78862a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 78962a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 79062a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 79162a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 79262a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 79362a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 79462a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 79562a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 79662a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 79762a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 79862a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 79962a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 80062a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 80162a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 80262a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 80362a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 80462a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 80562a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 80662a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 80762a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 80862a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 80962a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 81078bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 81178bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 81278bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 81378bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 8146b7985efSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 8156b7985efSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 8166b7985efSFlora Cui 0x0583, 0xffffffff, 0x00000100, 81778bbe771STom St Denis mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, 81878bbe771STom St Denis mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, 81978bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 82078bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 82178bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 82278bbe771STom St Denis mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, 82362a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 82478bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 82578bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 82678bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 82762a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 82878bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 82962a37553SKen Wang }; 83078bbe771STom St Denis 83162a37553SKen Wang static const u32 hainan_mgcg_cgcg_init[] = 83262a37553SKen Wang { 83378bbe771STom St Denis mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, 83478bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 83578bbe771STom St Denis mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 83678bbe771STom St Denis mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, 83778bbe771STom St Denis mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, 83878bbe771STom St Denis mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, 83978bbe771STom St Denis mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, 84078bbe771STom St Denis mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, 84178bbe771STom St Denis mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, 84278bbe771STom St Denis mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, 84378bbe771STom St Denis mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, 84478bbe771STom St Denis mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, 84578bbe771STom St Denis mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, 84678bbe771STom St Denis mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, 84778bbe771STom St Denis mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, 84878bbe771STom St Denis mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, 84978bbe771STom St Denis mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, 85078bbe771STom St Denis mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, 85178bbe771STom St Denis mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, 85278bbe771STom St Denis mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, 85378bbe771STom St Denis mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, 85478bbe771STom St Denis mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, 85578bbe771STom St Denis mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, 85678bbe771STom St Denis mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 85778bbe771STom St Denis mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, 85878bbe771STom St Denis mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, 85978bbe771STom St Denis mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 86062a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 86162a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 86262a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 86362a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 86462a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 86562a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 86662a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 86762a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 86862a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 86962a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 87062a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 87162a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 87262a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 87362a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 87462a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 87562a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 87662a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 87762a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 87862a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 87962a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 88062a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 88162a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 88262a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 88362a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 88462a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 88562a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 88662a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 88762a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 88862a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 88962a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 89078bbe771STom St Denis mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, 89178bbe771STom St Denis mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, 89278bbe771STom St Denis mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, 89378bbe771STom St Denis mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, 894bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 895bd27b678SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 896bd27b678SFlora Cui 0x0583, 0xffffffff, 0x00000100, 897bd27b678SFlora Cui 0x0409, 0xffffffff, 0x00000100, 89878bbe771STom St Denis mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, 89978bbe771STom St Denis mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, 90078bbe771STom St Denis mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, 90178bbe771STom St Denis mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, 90278bbe771STom St Denis mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, 90378bbe771STom St Denis mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, 90462a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 90578bbe771STom St Denis 0x3630, 0xfffffff0, 0x00000100, 90662a37553SKen Wang }; 90762a37553SKen Wang 90862a37553SKen Wang static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg) 90962a37553SKen Wang { 91062a37553SKen Wang unsigned long flags; 91162a37553SKen Wang u32 r; 91262a37553SKen Wang 91362a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 91462a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 91562a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 91662a37553SKen Wang r = RREG32(AMDGPU_PCIE_DATA); 91762a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 91862a37553SKen Wang return r; 91962a37553SKen Wang } 92062a37553SKen Wang 92162a37553SKen Wang static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 92262a37553SKen Wang { 92362a37553SKen Wang unsigned long flags; 92462a37553SKen Wang 92562a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 92662a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 92762a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 92862a37553SKen Wang WREG32(AMDGPU_PCIE_DATA, v); 92962a37553SKen Wang (void)RREG32(AMDGPU_PCIE_DATA); 93062a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 93162a37553SKen Wang } 93262a37553SKen Wang 933d1936cc2SBaoyou Xie static u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) 93436b9a952SHuang Rui { 93536b9a952SHuang Rui unsigned long flags; 93636b9a952SHuang Rui u32 r; 93736b9a952SHuang Rui 93836b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 93936b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 94036b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 94136b9a952SHuang Rui r = RREG32(PCIE_PORT_DATA); 94236b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 94336b9a952SHuang Rui return r; 94436b9a952SHuang Rui } 94536b9a952SHuang Rui 946d1936cc2SBaoyou Xie static void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 94736b9a952SHuang Rui { 94836b9a952SHuang Rui unsigned long flags; 94936b9a952SHuang Rui 95036b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 95136b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 95236b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 95336b9a952SHuang Rui WREG32(PCIE_PORT_DATA, (v)); 95436b9a952SHuang Rui (void)RREG32(PCIE_PORT_DATA); 95536b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 95636b9a952SHuang Rui } 95736b9a952SHuang Rui 95862a37553SKen Wang static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) 95962a37553SKen Wang { 96062a37553SKen Wang unsigned long flags; 96162a37553SKen Wang u32 r; 96262a37553SKen Wang 96362a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 96462a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 96562a37553SKen Wang r = RREG32(SMC_IND_DATA_0); 96662a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 96762a37553SKen Wang return r; 96862a37553SKen Wang } 96962a37553SKen Wang 97062a37553SKen Wang static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 97162a37553SKen Wang { 97262a37553SKen Wang unsigned long flags; 97362a37553SKen Wang 97462a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 97562a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 97662a37553SKen Wang WREG32(SMC_IND_DATA_0, (v)); 97762a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 97862a37553SKen Wang } 97962a37553SKen Wang 98080533a85SSonny Jiang static u32 si_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg) 98180533a85SSonny Jiang { 98280533a85SSonny Jiang unsigned long flags; 98380533a85SSonny Jiang u32 r; 98480533a85SSonny Jiang 98580533a85SSonny Jiang spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags); 98680533a85SSonny Jiang WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff)); 98780533a85SSonny Jiang r = RREG32(mmUVD_CTX_DATA); 98880533a85SSonny Jiang spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags); 98980533a85SSonny Jiang return r; 99080533a85SSonny Jiang } 99180533a85SSonny Jiang 99280533a85SSonny Jiang static void si_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 99380533a85SSonny Jiang { 99480533a85SSonny Jiang unsigned long flags; 99580533a85SSonny Jiang 99680533a85SSonny Jiang spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags); 99780533a85SSonny Jiang WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff)); 99880533a85SSonny Jiang WREG32(mmUVD_CTX_DATA, (v)); 99980533a85SSonny Jiang spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags); 100080533a85SSonny Jiang } 100180533a85SSonny Jiang 100262a37553SKen Wang static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { 100397fcc76bSChristian König {GRBM_STATUS}, 1004664fe85aSMarek Olšák {mmGRBM_STATUS2}, 1005664fe85aSMarek Olšák {mmGRBM_STATUS_SE0}, 1006664fe85aSMarek Olšák {mmGRBM_STATUS_SE1}, 1007664fe85aSMarek Olšák {mmSRBM_STATUS}, 1008664fe85aSMarek Olšák {mmSRBM_STATUS2}, 1009664fe85aSMarek Olšák {DMA_STATUS_REG + DMA0_REGISTER_OFFSET}, 1010664fe85aSMarek Olšák {DMA_STATUS_REG + DMA1_REGISTER_OFFSET}, 1011664fe85aSMarek Olšák {mmCP_STAT}, 1012664fe85aSMarek Olšák {mmCP_STALLED_STAT1}, 1013664fe85aSMarek Olšák {mmCP_STALLED_STAT2}, 1014664fe85aSMarek Olšák {mmCP_STALLED_STAT3}, 101597fcc76bSChristian König {GB_ADDR_CONFIG}, 101697fcc76bSChristian König {MC_ARB_RAMCFG}, 101797fcc76bSChristian König {GB_TILE_MODE0}, 101897fcc76bSChristian König {GB_TILE_MODE1}, 101997fcc76bSChristian König {GB_TILE_MODE2}, 102097fcc76bSChristian König {GB_TILE_MODE3}, 102197fcc76bSChristian König {GB_TILE_MODE4}, 102297fcc76bSChristian König {GB_TILE_MODE5}, 102397fcc76bSChristian König {GB_TILE_MODE6}, 102497fcc76bSChristian König {GB_TILE_MODE7}, 102597fcc76bSChristian König {GB_TILE_MODE8}, 102697fcc76bSChristian König {GB_TILE_MODE9}, 102797fcc76bSChristian König {GB_TILE_MODE10}, 102897fcc76bSChristian König {GB_TILE_MODE11}, 102997fcc76bSChristian König {GB_TILE_MODE12}, 103097fcc76bSChristian König {GB_TILE_MODE13}, 103197fcc76bSChristian König {GB_TILE_MODE14}, 103297fcc76bSChristian König {GB_TILE_MODE15}, 103397fcc76bSChristian König {GB_TILE_MODE16}, 103497fcc76bSChristian König {GB_TILE_MODE17}, 103597fcc76bSChristian König {GB_TILE_MODE18}, 103697fcc76bSChristian König {GB_TILE_MODE19}, 103797fcc76bSChristian König {GB_TILE_MODE20}, 103897fcc76bSChristian König {GB_TILE_MODE21}, 103997fcc76bSChristian König {GB_TILE_MODE22}, 104097fcc76bSChristian König {GB_TILE_MODE23}, 104197fcc76bSChristian König {GB_TILE_MODE24}, 104297fcc76bSChristian König {GB_TILE_MODE25}, 104397fcc76bSChristian König {GB_TILE_MODE26}, 104497fcc76bSChristian König {GB_TILE_MODE27}, 104597fcc76bSChristian König {GB_TILE_MODE28}, 104697fcc76bSChristian König {GB_TILE_MODE29}, 104797fcc76bSChristian König {GB_TILE_MODE30}, 104897fcc76bSChristian König {GB_TILE_MODE31}, 104997fcc76bSChristian König {CC_RB_BACKEND_DISABLE, true}, 105097fcc76bSChristian König {GC_USER_RB_BACKEND_DISABLE, true}, 105197fcc76bSChristian König {PA_SC_RASTER_CONFIG, true}, 105262a37553SKen Wang }; 105362a37553SKen Wang 1054dd5dfa61SFlora Cui static uint32_t si_get_register_value(struct amdgpu_device *adev, 1055dd5dfa61SFlora Cui bool indexed, u32 se_num, 1056dd5dfa61SFlora Cui u32 sh_num, u32 reg_offset) 105762a37553SKen Wang { 1058dd5dfa61SFlora Cui if (indexed) { 105962a37553SKen Wang uint32_t val; 1060dd5dfa61SFlora Cui unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num; 1061dd5dfa61SFlora Cui unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num; 1062dd5dfa61SFlora Cui 1063dd5dfa61SFlora Cui switch (reg_offset) { 1064dd5dfa61SFlora Cui case mmCC_RB_BACKEND_DISABLE: 1065dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable; 1066dd5dfa61SFlora Cui case mmGC_USER_RB_BACKEND_DISABLE: 1067dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable; 1068dd5dfa61SFlora Cui case mmPA_SC_RASTER_CONFIG: 1069dd5dfa61SFlora Cui return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config; 1070dd5dfa61SFlora Cui } 107162a37553SKen Wang 107262a37553SKen Wang mutex_lock(&adev->grbm_idx_mutex); 107362a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 107462a37553SKen Wang amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff); 107562a37553SKen Wang 107662a37553SKen Wang val = RREG32(reg_offset); 107762a37553SKen Wang 107862a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 107962a37553SKen Wang amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); 108062a37553SKen Wang mutex_unlock(&adev->grbm_idx_mutex); 108162a37553SKen Wang return val; 1082dd5dfa61SFlora Cui } else { 1083dd5dfa61SFlora Cui unsigned idx; 108462a37553SKen Wang 1085dd5dfa61SFlora Cui switch (reg_offset) { 1086dd5dfa61SFlora Cui case mmGB_ADDR_CONFIG: 1087dd5dfa61SFlora Cui return adev->gfx.config.gb_addr_config; 1088dd5dfa61SFlora Cui case mmMC_ARB_RAMCFG: 1089dd5dfa61SFlora Cui return adev->gfx.config.mc_arb_ramcfg; 1090dd5dfa61SFlora Cui case mmGB_TILE_MODE0: 1091dd5dfa61SFlora Cui case mmGB_TILE_MODE1: 1092dd5dfa61SFlora Cui case mmGB_TILE_MODE2: 1093dd5dfa61SFlora Cui case mmGB_TILE_MODE3: 1094dd5dfa61SFlora Cui case mmGB_TILE_MODE4: 1095dd5dfa61SFlora Cui case mmGB_TILE_MODE5: 1096dd5dfa61SFlora Cui case mmGB_TILE_MODE6: 1097dd5dfa61SFlora Cui case mmGB_TILE_MODE7: 1098dd5dfa61SFlora Cui case mmGB_TILE_MODE8: 1099dd5dfa61SFlora Cui case mmGB_TILE_MODE9: 1100dd5dfa61SFlora Cui case mmGB_TILE_MODE10: 1101dd5dfa61SFlora Cui case mmGB_TILE_MODE11: 1102dd5dfa61SFlora Cui case mmGB_TILE_MODE12: 1103dd5dfa61SFlora Cui case mmGB_TILE_MODE13: 1104dd5dfa61SFlora Cui case mmGB_TILE_MODE14: 1105dd5dfa61SFlora Cui case mmGB_TILE_MODE15: 1106dd5dfa61SFlora Cui case mmGB_TILE_MODE16: 1107dd5dfa61SFlora Cui case mmGB_TILE_MODE17: 1108dd5dfa61SFlora Cui case mmGB_TILE_MODE18: 1109dd5dfa61SFlora Cui case mmGB_TILE_MODE19: 1110dd5dfa61SFlora Cui case mmGB_TILE_MODE20: 1111dd5dfa61SFlora Cui case mmGB_TILE_MODE21: 1112dd5dfa61SFlora Cui case mmGB_TILE_MODE22: 1113dd5dfa61SFlora Cui case mmGB_TILE_MODE23: 1114dd5dfa61SFlora Cui case mmGB_TILE_MODE24: 1115dd5dfa61SFlora Cui case mmGB_TILE_MODE25: 1116dd5dfa61SFlora Cui case mmGB_TILE_MODE26: 1117dd5dfa61SFlora Cui case mmGB_TILE_MODE27: 1118dd5dfa61SFlora Cui case mmGB_TILE_MODE28: 1119dd5dfa61SFlora Cui case mmGB_TILE_MODE29: 1120dd5dfa61SFlora Cui case mmGB_TILE_MODE30: 1121dd5dfa61SFlora Cui case mmGB_TILE_MODE31: 1122dd5dfa61SFlora Cui idx = (reg_offset - mmGB_TILE_MODE0); 1123dd5dfa61SFlora Cui return adev->gfx.config.tile_mode_array[idx]; 1124dd5dfa61SFlora Cui default: 1125dd5dfa61SFlora Cui return RREG32(reg_offset); 1126dd5dfa61SFlora Cui } 1127dd5dfa61SFlora Cui } 1128dd5dfa61SFlora Cui } 112962a37553SKen Wang static int si_read_register(struct amdgpu_device *adev, u32 se_num, 113062a37553SKen Wang u32 sh_num, u32 reg_offset, u32 *value) 113162a37553SKen Wang { 113262a37553SKen Wang uint32_t i; 113362a37553SKen Wang 113462a37553SKen Wang *value = 0; 113562a37553SKen Wang for (i = 0; i < ARRAY_SIZE(si_allowed_read_registers); i++) { 113697fcc76bSChristian König bool indexed = si_allowed_read_registers[i].grbm_indexed; 113797fcc76bSChristian König 113862a37553SKen Wang if (reg_offset != si_allowed_read_registers[i].reg_offset) 113962a37553SKen Wang continue; 114062a37553SKen Wang 114197fcc76bSChristian König *value = si_get_register_value(adev, indexed, se_num, sh_num, 114297fcc76bSChristian König reg_offset); 114362a37553SKen Wang return 0; 114462a37553SKen Wang } 114562a37553SKen Wang return -EINVAL; 114662a37553SKen Wang } 114762a37553SKen Wang 114862a37553SKen Wang static bool si_read_disabled_bios(struct amdgpu_device *adev) 114962a37553SKen Wang { 115062a37553SKen Wang u32 bus_cntl; 115162a37553SKen Wang u32 d1vga_control = 0; 115262a37553SKen Wang u32 d2vga_control = 0; 115362a37553SKen Wang u32 vga_render_control = 0; 115462a37553SKen Wang u32 rom_cntl; 115562a37553SKen Wang bool r; 115662a37553SKen Wang 115762a37553SKen Wang bus_cntl = RREG32(R600_BUS_CNTL); 115862a37553SKen Wang if (adev->mode_info.num_crtc) { 115962a37553SKen Wang d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); 116062a37553SKen Wang d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); 116162a37553SKen Wang vga_render_control = RREG32(VGA_RENDER_CONTROL); 116262a37553SKen Wang } 116362a37553SKen Wang rom_cntl = RREG32(R600_ROM_CNTL); 116462a37553SKen Wang 116562a37553SKen Wang /* enable the rom */ 116662a37553SKen Wang WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS)); 116762a37553SKen Wang if (adev->mode_info.num_crtc) { 116862a37553SKen Wang /* Disable VGA mode */ 116962a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, 117062a37553SKen Wang (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 117162a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 117262a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, 117362a37553SKen Wang (d2vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 117462a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 117562a37553SKen Wang WREG32(VGA_RENDER_CONTROL, 117662a37553SKen Wang (vga_render_control & C_000300_VGA_VSTATUS_CNTL)); 117762a37553SKen Wang } 117862a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE); 117962a37553SKen Wang 118062a37553SKen Wang r = amdgpu_read_bios(adev); 118162a37553SKen Wang 118262a37553SKen Wang /* restore regs */ 118362a37553SKen Wang WREG32(R600_BUS_CNTL, bus_cntl); 118462a37553SKen Wang if (adev->mode_info.num_crtc) { 118562a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); 118662a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); 118762a37553SKen Wang WREG32(VGA_RENDER_CONTROL, vga_render_control); 118862a37553SKen Wang } 118962a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl); 119062a37553SKen Wang return r; 119162a37553SKen Wang } 119262a37553SKen Wang 11936d949d24SAlex Deucher #define mmROM_INDEX 0x2A 11946d949d24SAlex Deucher #define mmROM_DATA 0x2B 11956d949d24SAlex Deucher 11966d949d24SAlex Deucher static bool si_read_bios_from_rom(struct amdgpu_device *adev, 11976d949d24SAlex Deucher u8 *bios, u32 length_bytes) 11986d949d24SAlex Deucher { 11996d949d24SAlex Deucher u32 *dw_ptr; 12006d949d24SAlex Deucher u32 i, length_dw; 12016d949d24SAlex Deucher 12026d949d24SAlex Deucher if (bios == NULL) 12036d949d24SAlex Deucher return false; 12046d949d24SAlex Deucher if (length_bytes == 0) 12056d949d24SAlex Deucher return false; 12066d949d24SAlex Deucher /* APU vbios image is part of sbios image */ 12076d949d24SAlex Deucher if (adev->flags & AMD_IS_APU) 12086d949d24SAlex Deucher return false; 12096d949d24SAlex Deucher 12106d949d24SAlex Deucher dw_ptr = (u32 *)bios; 12116d949d24SAlex Deucher length_dw = ALIGN(length_bytes, 4) / 4; 12126d949d24SAlex Deucher /* set rom index to 0 */ 12136d949d24SAlex Deucher WREG32(mmROM_INDEX, 0); 12146d949d24SAlex Deucher for (i = 0; i < length_dw; i++) 12156d949d24SAlex Deucher dw_ptr[i] = RREG32(mmROM_DATA); 12166d949d24SAlex Deucher 12176d949d24SAlex Deucher return true; 12186d949d24SAlex Deucher } 12196d949d24SAlex Deucher 12206cd3c679SAlex Deucher static void si_set_clk_bypass_mode(struct amdgpu_device *adev) 12216cd3c679SAlex Deucher { 12226cd3c679SAlex Deucher u32 tmp, i; 12236cd3c679SAlex Deucher 12246cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL); 12256cd3c679SAlex Deucher tmp |= SPLL_BYPASS_EN; 12266cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL, tmp); 12276cd3c679SAlex Deucher 12286cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL_2); 12296cd3c679SAlex Deucher tmp |= SPLL_CTLREQ_CHG; 12306cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL_2, tmp); 12316cd3c679SAlex Deucher 12326cd3c679SAlex Deucher for (i = 0; i < adev->usec_timeout; i++) { 12336cd3c679SAlex Deucher if (RREG32(SPLL_STATUS) & SPLL_CHG_STATUS) 12346cd3c679SAlex Deucher break; 12356cd3c679SAlex Deucher udelay(1); 12366cd3c679SAlex Deucher } 12376cd3c679SAlex Deucher 12386cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL_2); 12396cd3c679SAlex Deucher tmp &= ~(SPLL_CTLREQ_CHG | SCLK_MUX_UPDATE); 12406cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL_2, tmp); 12416cd3c679SAlex Deucher 12426cd3c679SAlex Deucher tmp = RREG32(MPLL_CNTL_MODE); 12436cd3c679SAlex Deucher tmp &= ~MPLL_MCLK_SEL; 12446cd3c679SAlex Deucher WREG32(MPLL_CNTL_MODE, tmp); 12456cd3c679SAlex Deucher } 12466cd3c679SAlex Deucher 12476cd3c679SAlex Deucher static void si_spll_powerdown(struct amdgpu_device *adev) 12486cd3c679SAlex Deucher { 12496cd3c679SAlex Deucher u32 tmp; 12506cd3c679SAlex Deucher 12516cd3c679SAlex Deucher tmp = RREG32(SPLL_CNTL_MODE); 12526cd3c679SAlex Deucher tmp |= SPLL_SW_DIR_CONTROL; 12536cd3c679SAlex Deucher WREG32(SPLL_CNTL_MODE, tmp); 12546cd3c679SAlex Deucher 12556cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL); 12566cd3c679SAlex Deucher tmp |= SPLL_RESET; 12576cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL, tmp); 12586cd3c679SAlex Deucher 12596cd3c679SAlex Deucher tmp = RREG32(CG_SPLL_FUNC_CNTL); 12606cd3c679SAlex Deucher tmp |= SPLL_SLEEP; 12616cd3c679SAlex Deucher WREG32(CG_SPLL_FUNC_CNTL, tmp); 12626cd3c679SAlex Deucher 12636cd3c679SAlex Deucher tmp = RREG32(SPLL_CNTL_MODE); 12646cd3c679SAlex Deucher tmp &= ~SPLL_SW_DIR_CONTROL; 12656cd3c679SAlex Deucher WREG32(SPLL_CNTL_MODE, tmp); 12666cd3c679SAlex Deucher } 12676cd3c679SAlex Deucher 12686cd3c679SAlex Deucher static int si_gpu_pci_config_reset(struct amdgpu_device *adev) 12696cd3c679SAlex Deucher { 12706cd3c679SAlex Deucher u32 i; 12716cd3c679SAlex Deucher int r = -EINVAL; 12726cd3c679SAlex Deucher 12736cd3c679SAlex Deucher dev_info(adev->dev, "GPU pci config reset\n"); 12746cd3c679SAlex Deucher 12756cd3c679SAlex Deucher /* set mclk/sclk to bypass */ 12766cd3c679SAlex Deucher si_set_clk_bypass_mode(adev); 12776cd3c679SAlex Deucher /* powerdown spll */ 12786cd3c679SAlex Deucher si_spll_powerdown(adev); 12796cd3c679SAlex Deucher /* disable BM */ 12806cd3c679SAlex Deucher pci_clear_master(adev->pdev); 12816cd3c679SAlex Deucher /* reset */ 12826cd3c679SAlex Deucher amdgpu_device_pci_config_reset(adev); 12836cd3c679SAlex Deucher 12846cd3c679SAlex Deucher udelay(100); 12856cd3c679SAlex Deucher 12866cd3c679SAlex Deucher /* wait for asic to come out of reset */ 12876cd3c679SAlex Deucher for (i = 0; i < adev->usec_timeout; i++) { 12886cd3c679SAlex Deucher if (RREG32(mmCONFIG_MEMSIZE) != 0xffffffff) { 12896cd3c679SAlex Deucher /* enable BM */ 12906cd3c679SAlex Deucher pci_set_master(adev->pdev); 12916cd3c679SAlex Deucher adev->has_hw_reset = true; 12926cd3c679SAlex Deucher r = 0; 12936cd3c679SAlex Deucher break; 12946cd3c679SAlex Deucher } 12956cd3c679SAlex Deucher udelay(1); 12966cd3c679SAlex Deucher } 12976cd3c679SAlex Deucher 12986cd3c679SAlex Deucher return r; 12996cd3c679SAlex Deucher } 13006cd3c679SAlex Deucher 130162a37553SKen Wang static int si_asic_reset(struct amdgpu_device *adev) 130262a37553SKen Wang { 13036cd3c679SAlex Deucher int r; 13046cd3c679SAlex Deucher 130511043b7aSAlex Deucher dev_info(adev->dev, "PCI CONFIG reset\n"); 130611043b7aSAlex Deucher 13076cd3c679SAlex Deucher amdgpu_atombios_scratch_regs_engine_hung(adev, true); 13086cd3c679SAlex Deucher 13096cd3c679SAlex Deucher r = si_gpu_pci_config_reset(adev); 13106cd3c679SAlex Deucher 13116cd3c679SAlex Deucher amdgpu_atombios_scratch_regs_engine_hung(adev, false); 13126cd3c679SAlex Deucher 13136cd3c679SAlex Deucher return r; 131462a37553SKen Wang } 131562a37553SKen Wang 13163670c242SAlex Deucher static bool si_asic_supports_baco(struct amdgpu_device *adev) 13173670c242SAlex Deucher { 13183670c242SAlex Deucher return false; 13193670c242SAlex Deucher } 13203670c242SAlex Deucher 1321dd81eedeSAlex Deucher static enum amd_reset_method 1322dd81eedeSAlex Deucher si_asic_reset_method(struct amdgpu_device *adev) 1323dd81eedeSAlex Deucher { 1324273da6ffSWenhui Sheng if (amdgpu_reset_method != AMD_RESET_METHOD_LEGACY && 1325273da6ffSWenhui Sheng amdgpu_reset_method != -1) 1326273da6ffSWenhui Sheng dev_warn(adev->dev, "Specified reset method:%d isn't supported, using AUTO instead.\n", 1327273da6ffSWenhui Sheng amdgpu_reset_method); 1328273da6ffSWenhui Sheng 1329dd81eedeSAlex Deucher return AMD_RESET_METHOD_LEGACY; 1330dd81eedeSAlex Deucher } 1331dd81eedeSAlex Deucher 1332bbf282d8SAlex Deucher static u32 si_get_config_memsize(struct amdgpu_device *adev) 1333bbf282d8SAlex Deucher { 1334bbf282d8SAlex Deucher return RREG32(mmCONFIG_MEMSIZE); 1335bbf282d8SAlex Deucher } 1336bbf282d8SAlex Deucher 133762a37553SKen Wang static void si_vga_set_state(struct amdgpu_device *adev, bool state) 133862a37553SKen Wang { 133962a37553SKen Wang uint32_t temp; 134062a37553SKen Wang 134162a37553SKen Wang temp = RREG32(CONFIG_CNTL); 1342*e66cdf25SZheng Bin if (!state) { 134362a37553SKen Wang temp &= ~(1<<0); 134462a37553SKen Wang temp |= (1<<1); 134562a37553SKen Wang } else { 134662a37553SKen Wang temp &= ~(1<<1); 134762a37553SKen Wang } 134862a37553SKen Wang WREG32(CONFIG_CNTL, temp); 134962a37553SKen Wang } 135062a37553SKen Wang 135162a37553SKen Wang static u32 si_get_xclk(struct amdgpu_device *adev) 135262a37553SKen Wang { 135362a37553SKen Wang u32 reference_clock = adev->clock.spll.reference_freq; 135462a37553SKen Wang u32 tmp; 135562a37553SKen Wang 135662a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL_2); 135762a37553SKen Wang if (tmp & MUX_TCLK_TO_XCLK) 135862a37553SKen Wang return TCLK; 135962a37553SKen Wang 136062a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL); 136162a37553SKen Wang if (tmp & XTALIN_DIVIDE) 136262a37553SKen Wang return reference_clock / 4; 136362a37553SKen Wang 136462a37553SKen Wang return reference_clock; 136562a37553SKen Wang } 13661919696eSMaruthi Srinivas Bayyavarapu 136769882565SChristian König static void si_flush_hdp(struct amdgpu_device *adev, struct amdgpu_ring *ring) 13682d5e0807SAlex Deucher { 136969882565SChristian König if (!ring || !ring->funcs->emit_wreg) { 13702d5e0807SAlex Deucher WREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1); 13712d5e0807SAlex Deucher RREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL); 137269882565SChristian König } else { 137369882565SChristian König amdgpu_ring_emit_wreg(ring, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1); 137469882565SChristian König } 13752d5e0807SAlex Deucher } 13762d5e0807SAlex Deucher 137769882565SChristian König static void si_invalidate_hdp(struct amdgpu_device *adev, 137869882565SChristian König struct amdgpu_ring *ring) 13792d5e0807SAlex Deucher { 138069882565SChristian König if (!ring || !ring->funcs->emit_wreg) { 13812d5e0807SAlex Deucher WREG32(mmHDP_DEBUG0, 1); 13822d5e0807SAlex Deucher RREG32(mmHDP_DEBUG0); 138369882565SChristian König } else { 138469882565SChristian König amdgpu_ring_emit_wreg(ring, mmHDP_DEBUG0, 1); 138569882565SChristian König } 13862d5e0807SAlex Deucher } 13872d5e0807SAlex Deucher 13880a881af8SAlex Deucher static bool si_need_full_reset(struct amdgpu_device *adev) 13890a881af8SAlex Deucher { 13900a881af8SAlex Deucher /* change this when we support soft reset */ 13910a881af8SAlex Deucher return true; 13920a881af8SAlex Deucher } 13930a881af8SAlex Deucher 13947450bbe7SAlex Deucher static bool si_need_reset_on_init(struct amdgpu_device *adev) 13957450bbe7SAlex Deucher { 13967450bbe7SAlex Deucher return false; 13977450bbe7SAlex Deucher } 13987450bbe7SAlex Deucher 139920ca25e8SAlex Deucher static int si_get_pcie_lanes(struct amdgpu_device *adev) 140020ca25e8SAlex Deucher { 140120ca25e8SAlex Deucher u32 link_width_cntl; 140220ca25e8SAlex Deucher 140320ca25e8SAlex Deucher if (adev->flags & AMD_IS_APU) 140420ca25e8SAlex Deucher return 0; 140520ca25e8SAlex Deucher 140620ca25e8SAlex Deucher link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 140720ca25e8SAlex Deucher 140820ca25e8SAlex Deucher switch ((link_width_cntl & LC_LINK_WIDTH_RD_MASK) >> LC_LINK_WIDTH_RD_SHIFT) { 140920ca25e8SAlex Deucher case LC_LINK_WIDTH_X1: 141020ca25e8SAlex Deucher return 1; 141120ca25e8SAlex Deucher case LC_LINK_WIDTH_X2: 141220ca25e8SAlex Deucher return 2; 141320ca25e8SAlex Deucher case LC_LINK_WIDTH_X4: 141420ca25e8SAlex Deucher return 4; 141520ca25e8SAlex Deucher case LC_LINK_WIDTH_X8: 141620ca25e8SAlex Deucher return 8; 141720ca25e8SAlex Deucher case LC_LINK_WIDTH_X0: 141820ca25e8SAlex Deucher case LC_LINK_WIDTH_X16: 141920ca25e8SAlex Deucher default: 142020ca25e8SAlex Deucher return 16; 142120ca25e8SAlex Deucher } 142220ca25e8SAlex Deucher } 142320ca25e8SAlex Deucher 142420ca25e8SAlex Deucher static void si_set_pcie_lanes(struct amdgpu_device *adev, int lanes) 142520ca25e8SAlex Deucher { 142620ca25e8SAlex Deucher u32 link_width_cntl, mask; 142720ca25e8SAlex Deucher 142820ca25e8SAlex Deucher if (adev->flags & AMD_IS_APU) 142920ca25e8SAlex Deucher return; 143020ca25e8SAlex Deucher 143120ca25e8SAlex Deucher switch (lanes) { 143220ca25e8SAlex Deucher case 0: 143320ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X0; 143420ca25e8SAlex Deucher break; 143520ca25e8SAlex Deucher case 1: 143620ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X1; 143720ca25e8SAlex Deucher break; 143820ca25e8SAlex Deucher case 2: 143920ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X2; 144020ca25e8SAlex Deucher break; 144120ca25e8SAlex Deucher case 4: 144220ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X4; 144320ca25e8SAlex Deucher break; 144420ca25e8SAlex Deucher case 8: 144520ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X8; 144620ca25e8SAlex Deucher break; 144720ca25e8SAlex Deucher case 16: 144820ca25e8SAlex Deucher mask = LC_LINK_WIDTH_X16; 144920ca25e8SAlex Deucher break; 145020ca25e8SAlex Deucher default: 145120ca25e8SAlex Deucher DRM_ERROR("invalid pcie lane request: %d\n", lanes); 145220ca25e8SAlex Deucher return; 145320ca25e8SAlex Deucher } 145420ca25e8SAlex Deucher 145520ca25e8SAlex Deucher link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 145620ca25e8SAlex Deucher link_width_cntl &= ~LC_LINK_WIDTH_MASK; 145720ca25e8SAlex Deucher link_width_cntl |= mask << LC_LINK_WIDTH_SHIFT; 145820ca25e8SAlex Deucher link_width_cntl |= (LC_RECONFIG_NOW | 145920ca25e8SAlex Deucher LC_RECONFIG_ARC_MISSING_ESCAPE); 146020ca25e8SAlex Deucher 146120ca25e8SAlex Deucher WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); 146220ca25e8SAlex Deucher } 146320ca25e8SAlex Deucher 1464b45e18acSKent Russell static void si_get_pcie_usage(struct amdgpu_device *adev, uint64_t *count0, 1465b45e18acSKent Russell uint64_t *count1) 1466b45e18acSKent Russell { 1467b45e18acSKent Russell uint32_t perfctr = 0; 1468b45e18acSKent Russell uint64_t cnt0_of, cnt1_of; 1469b45e18acSKent Russell int tmp; 1470b45e18acSKent Russell 1471b45e18acSKent Russell /* This reports 0 on APUs, so return to avoid writing/reading registers 1472b45e18acSKent Russell * that may or may not be different from their GPU counterparts 1473b45e18acSKent Russell */ 1474b45e18acSKent Russell if (adev->flags & AMD_IS_APU) 1475b45e18acSKent Russell return; 1476b45e18acSKent Russell 1477b45e18acSKent Russell /* Set the 2 events that we wish to watch, defined above */ 1478b45e18acSKent Russell /* Reg 40 is # received msgs, Reg 104 is # of posted requests sent */ 1479b45e18acSKent Russell perfctr = REG_SET_FIELD(perfctr, PCIE_PERF_CNTL_TXCLK, EVENT0_SEL, 40); 1480b45e18acSKent Russell perfctr = REG_SET_FIELD(perfctr, PCIE_PERF_CNTL_TXCLK, EVENT1_SEL, 104); 1481b45e18acSKent Russell 1482b45e18acSKent Russell /* Write to enable desired perf counters */ 1483b45e18acSKent Russell WREG32_PCIE(ixPCIE_PERF_CNTL_TXCLK, perfctr); 1484b45e18acSKent Russell /* Zero out and enable the perf counters 1485b45e18acSKent Russell * Write 0x5: 1486b45e18acSKent Russell * Bit 0 = Start all counters(1) 1487b45e18acSKent Russell * Bit 2 = Global counter reset enable(1) 1488b45e18acSKent Russell */ 1489b45e18acSKent Russell WREG32_PCIE(ixPCIE_PERF_COUNT_CNTL, 0x00000005); 1490b45e18acSKent Russell 1491b45e18acSKent Russell msleep(1000); 1492b45e18acSKent Russell 1493b45e18acSKent Russell /* Load the shadow and disable the perf counters 1494b45e18acSKent Russell * Write 0x2: 1495b45e18acSKent Russell * Bit 0 = Stop counters(0) 1496b45e18acSKent Russell * Bit 1 = Load the shadow counters(1) 1497b45e18acSKent Russell */ 1498b45e18acSKent Russell WREG32_PCIE(ixPCIE_PERF_COUNT_CNTL, 0x00000002); 1499b45e18acSKent Russell 1500b45e18acSKent Russell /* Read register values to get any >32bit overflow */ 1501b45e18acSKent Russell tmp = RREG32_PCIE(ixPCIE_PERF_CNTL_TXCLK); 1502b45e18acSKent Russell cnt0_of = REG_GET_FIELD(tmp, PCIE_PERF_CNTL_TXCLK, COUNTER0_UPPER); 1503b45e18acSKent Russell cnt1_of = REG_GET_FIELD(tmp, PCIE_PERF_CNTL_TXCLK, COUNTER1_UPPER); 1504b45e18acSKent Russell 1505b45e18acSKent Russell /* Get the values and add the overflow */ 1506b45e18acSKent Russell *count0 = RREG32_PCIE(ixPCIE_PERF_COUNT0_TXCLK) | (cnt0_of << 32); 1507b45e18acSKent Russell *count1 = RREG32_PCIE(ixPCIE_PERF_COUNT1_TXCLK) | (cnt1_of << 32); 1508b45e18acSKent Russell } 1509b45e18acSKent Russell 1510dcea6e65SKent Russell static uint64_t si_get_pcie_replay_count(struct amdgpu_device *adev) 1511dcea6e65SKent Russell { 1512dcea6e65SKent Russell uint64_t nak_r, nak_g; 1513dcea6e65SKent Russell 1514dcea6e65SKent Russell /* Get the number of NAKs received and generated */ 1515dcea6e65SKent Russell nak_r = RREG32_PCIE(ixPCIE_RX_NUM_NAK); 1516dcea6e65SKent Russell nak_g = RREG32_PCIE(ixPCIE_RX_NUM_NAK_GENERATED); 1517dcea6e65SKent Russell 1518dcea6e65SKent Russell /* Add the total number of NAKs, i.e the number of replays */ 1519dcea6e65SKent Russell return (nak_r + nak_g); 1520dcea6e65SKent Russell } 1521dcea6e65SKent Russell 15223b0627a4SAlex Jivin static int si_uvd_send_upll_ctlreq(struct amdgpu_device *adev, 15233b0627a4SAlex Jivin unsigned cg_upll_func_cntl) 15243b0627a4SAlex Jivin { 15253b0627a4SAlex Jivin unsigned i; 15263b0627a4SAlex Jivin 15273b0627a4SAlex Jivin /* Make sure UPLL_CTLREQ is deasserted */ 15283b0627a4SAlex Jivin WREG32_P(cg_upll_func_cntl, 0, ~UPLL_CTLREQ_MASK); 15293b0627a4SAlex Jivin 15303b0627a4SAlex Jivin mdelay(10); 15313b0627a4SAlex Jivin 15323b0627a4SAlex Jivin /* Assert UPLL_CTLREQ */ 15333b0627a4SAlex Jivin WREG32_P(cg_upll_func_cntl, UPLL_CTLREQ_MASK, ~UPLL_CTLREQ_MASK); 15343b0627a4SAlex Jivin 15353b0627a4SAlex Jivin /* Wait for CTLACK and CTLACK2 to get asserted */ 15363b0627a4SAlex Jivin for (i = 0; i < SI_MAX_CTLACKS_ASSERTION_WAIT; ++i) { 15373b0627a4SAlex Jivin uint32_t mask = UPLL_CTLACK_MASK | UPLL_CTLACK2_MASK; 15383b0627a4SAlex Jivin 15393b0627a4SAlex Jivin if ((RREG32(cg_upll_func_cntl) & mask) == mask) 15403b0627a4SAlex Jivin break; 15413b0627a4SAlex Jivin mdelay(10); 15423b0627a4SAlex Jivin } 15433b0627a4SAlex Jivin 15443b0627a4SAlex Jivin /* Deassert UPLL_CTLREQ */ 15453b0627a4SAlex Jivin WREG32_P(cg_upll_func_cntl, 0, ~UPLL_CTLREQ_MASK); 15463b0627a4SAlex Jivin 15473b0627a4SAlex Jivin if (i == SI_MAX_CTLACKS_ASSERTION_WAIT) { 15483b0627a4SAlex Jivin DRM_ERROR("Timeout setting UVD clocks!\n"); 15493b0627a4SAlex Jivin return -ETIMEDOUT; 15503b0627a4SAlex Jivin } 15513b0627a4SAlex Jivin 15523b0627a4SAlex Jivin return 0; 15533b0627a4SAlex Jivin } 15543b0627a4SAlex Jivin 15553b0627a4SAlex Jivin static unsigned si_uvd_calc_upll_post_div(unsigned vco_freq, 15563b0627a4SAlex Jivin unsigned target_freq, 15573b0627a4SAlex Jivin unsigned pd_min, 15583b0627a4SAlex Jivin unsigned pd_even) 15593b0627a4SAlex Jivin { 15603b0627a4SAlex Jivin unsigned post_div = vco_freq / target_freq; 15613b0627a4SAlex Jivin 15623b0627a4SAlex Jivin /* Adjust to post divider minimum value */ 15633b0627a4SAlex Jivin if (post_div < pd_min) 15643b0627a4SAlex Jivin post_div = pd_min; 15653b0627a4SAlex Jivin 15663b0627a4SAlex Jivin /* We alway need a frequency less than or equal the target */ 15673b0627a4SAlex Jivin if ((vco_freq / post_div) > target_freq) 15683b0627a4SAlex Jivin post_div += 1; 15693b0627a4SAlex Jivin 15703b0627a4SAlex Jivin /* Post dividers above a certain value must be even */ 15713b0627a4SAlex Jivin if (post_div > pd_even && post_div % 2) 15723b0627a4SAlex Jivin post_div += 1; 15733b0627a4SAlex Jivin 15743b0627a4SAlex Jivin return post_div; 15753b0627a4SAlex Jivin } 15763b0627a4SAlex Jivin 15773b0627a4SAlex Jivin /** 15783b0627a4SAlex Jivin * si_calc_upll_dividers - calc UPLL clock dividers 15793b0627a4SAlex Jivin * 15803b0627a4SAlex Jivin * @adev: amdgpu_device pointer 15813b0627a4SAlex Jivin * @vclk: wanted VCLK 15823b0627a4SAlex Jivin * @dclk: wanted DCLK 15833b0627a4SAlex Jivin * @vco_min: minimum VCO frequency 15843b0627a4SAlex Jivin * @vco_max: maximum VCO frequency 15853b0627a4SAlex Jivin * @fb_factor: factor to multiply vco freq with 15863b0627a4SAlex Jivin * @fb_mask: limit and bitmask for feedback divider 15873b0627a4SAlex Jivin * @pd_min: post divider minimum 15883b0627a4SAlex Jivin * @pd_max: post divider maximum 15893b0627a4SAlex Jivin * @pd_even: post divider must be even above this value 15903b0627a4SAlex Jivin * @optimal_fb_div: resulting feedback divider 15913b0627a4SAlex Jivin * @optimal_vclk_div: resulting vclk post divider 15923b0627a4SAlex Jivin * @optimal_dclk_div: resulting dclk post divider 15933b0627a4SAlex Jivin * 15943b0627a4SAlex Jivin * Calculate dividers for UVDs UPLL (except APUs). 15953b0627a4SAlex Jivin * Returns zero on success; -EINVAL on error. 15963b0627a4SAlex Jivin */ 15973b0627a4SAlex Jivin static int si_calc_upll_dividers(struct amdgpu_device *adev, 15983b0627a4SAlex Jivin unsigned vclk, unsigned dclk, 15993b0627a4SAlex Jivin unsigned vco_min, unsigned vco_max, 16003b0627a4SAlex Jivin unsigned fb_factor, unsigned fb_mask, 16013b0627a4SAlex Jivin unsigned pd_min, unsigned pd_max, 16023b0627a4SAlex Jivin unsigned pd_even, 16033b0627a4SAlex Jivin unsigned *optimal_fb_div, 16043b0627a4SAlex Jivin unsigned *optimal_vclk_div, 16053b0627a4SAlex Jivin unsigned *optimal_dclk_div) 16063b0627a4SAlex Jivin { 16073b0627a4SAlex Jivin unsigned vco_freq, ref_freq = adev->clock.spll.reference_freq; 16083b0627a4SAlex Jivin 16093b0627a4SAlex Jivin /* Start off with something large */ 16103b0627a4SAlex Jivin unsigned optimal_score = ~0; 16113b0627a4SAlex Jivin 16123b0627a4SAlex Jivin /* Loop through vco from low to high */ 16133b0627a4SAlex Jivin vco_min = max(max(vco_min, vclk), dclk); 16143b0627a4SAlex Jivin for (vco_freq = vco_min; vco_freq <= vco_max; vco_freq += 100) { 16153b0627a4SAlex Jivin uint64_t fb_div = (uint64_t)vco_freq * fb_factor; 16163b0627a4SAlex Jivin unsigned vclk_div, dclk_div, score; 16173b0627a4SAlex Jivin 16183b0627a4SAlex Jivin do_div(fb_div, ref_freq); 16193b0627a4SAlex Jivin 16203b0627a4SAlex Jivin /* fb div out of range ? */ 16213b0627a4SAlex Jivin if (fb_div > fb_mask) 16223b0627a4SAlex Jivin break; /* It can oly get worse */ 16233b0627a4SAlex Jivin 16243b0627a4SAlex Jivin fb_div &= fb_mask; 16253b0627a4SAlex Jivin 16263b0627a4SAlex Jivin /* Calc vclk divider with current vco freq */ 16273b0627a4SAlex Jivin vclk_div = si_uvd_calc_upll_post_div(vco_freq, vclk, 16283b0627a4SAlex Jivin pd_min, pd_even); 16293b0627a4SAlex Jivin if (vclk_div > pd_max) 16303b0627a4SAlex Jivin break; /* vco is too big, it has to stop */ 16313b0627a4SAlex Jivin 16323b0627a4SAlex Jivin /* Calc dclk divider with current vco freq */ 16333b0627a4SAlex Jivin dclk_div = si_uvd_calc_upll_post_div(vco_freq, dclk, 16343b0627a4SAlex Jivin pd_min, pd_even); 16353b0627a4SAlex Jivin if (dclk_div > pd_max) 16363b0627a4SAlex Jivin break; /* vco is too big, it has to stop */ 16373b0627a4SAlex Jivin 16383b0627a4SAlex Jivin /* Calc score with current vco freq */ 16393b0627a4SAlex Jivin score = vclk - (vco_freq / vclk_div) + dclk - (vco_freq / dclk_div); 16403b0627a4SAlex Jivin 16413b0627a4SAlex Jivin /* Determine if this vco setting is better than current optimal settings */ 16423b0627a4SAlex Jivin if (score < optimal_score) { 16433b0627a4SAlex Jivin *optimal_fb_div = fb_div; 16443b0627a4SAlex Jivin *optimal_vclk_div = vclk_div; 16453b0627a4SAlex Jivin *optimal_dclk_div = dclk_div; 16463b0627a4SAlex Jivin optimal_score = score; 16473b0627a4SAlex Jivin if (optimal_score == 0) 16483b0627a4SAlex Jivin break; /* It can't get better than this */ 16493b0627a4SAlex Jivin } 16503b0627a4SAlex Jivin } 16513b0627a4SAlex Jivin 16523b0627a4SAlex Jivin /* Did we found a valid setup ? */ 16533b0627a4SAlex Jivin if (optimal_score == ~0) 16543b0627a4SAlex Jivin return -EINVAL; 16553b0627a4SAlex Jivin 16563b0627a4SAlex Jivin return 0; 16573b0627a4SAlex Jivin } 16583b0627a4SAlex Jivin 16593b0627a4SAlex Jivin static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) 16603b0627a4SAlex Jivin { 16613b0627a4SAlex Jivin unsigned fb_div = 0, vclk_div = 0, dclk_div = 0; 16623b0627a4SAlex Jivin int r; 16633b0627a4SAlex Jivin 16643b0627a4SAlex Jivin /* Bypass vclk and dclk with bclk */ 16653b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_2, 16663b0627a4SAlex Jivin VCLK_SRC_SEL(1) | DCLK_SRC_SEL(1), 16673b0627a4SAlex Jivin ~(VCLK_SRC_SEL_MASK | DCLK_SRC_SEL_MASK)); 16683b0627a4SAlex Jivin 16693b0627a4SAlex Jivin /* Put PLL in bypass mode */ 16703b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_BYPASS_EN_MASK, ~UPLL_BYPASS_EN_MASK); 16713b0627a4SAlex Jivin 16723b0627a4SAlex Jivin if (!vclk || !dclk) { 16733b0627a4SAlex Jivin /* Keep the Bypass mode */ 16743b0627a4SAlex Jivin return 0; 16753b0627a4SAlex Jivin } 16763b0627a4SAlex Jivin 16773b0627a4SAlex Jivin r = si_calc_upll_dividers(adev, vclk, dclk, 125000, 250000, 16783b0627a4SAlex Jivin 16384, 0x03FFFFFF, 0, 128, 5, 16793b0627a4SAlex Jivin &fb_div, &vclk_div, &dclk_div); 16803b0627a4SAlex Jivin if (r) 16813b0627a4SAlex Jivin return r; 16823b0627a4SAlex Jivin 16833b0627a4SAlex Jivin /* Set RESET_ANTI_MUX to 0 */ 16843b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_5, 0, ~RESET_ANTI_MUX_MASK); 16853b0627a4SAlex Jivin 16863b0627a4SAlex Jivin /* Set VCO_MODE to 1 */ 16873b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_VCO_MODE_MASK, ~UPLL_VCO_MODE_MASK); 16883b0627a4SAlex Jivin 16893b0627a4SAlex Jivin /* Disable sleep mode */ 16903b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_SLEEP_MASK); 16913b0627a4SAlex Jivin 16923b0627a4SAlex Jivin /* Deassert UPLL_RESET */ 16933b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_RESET_MASK); 16943b0627a4SAlex Jivin 16953b0627a4SAlex Jivin mdelay(1); 16963b0627a4SAlex Jivin 16973b0627a4SAlex Jivin r = si_uvd_send_upll_ctlreq(adev, CG_UPLL_FUNC_CNTL); 16983b0627a4SAlex Jivin if (r) 16993b0627a4SAlex Jivin return r; 17003b0627a4SAlex Jivin 17013b0627a4SAlex Jivin /* Assert UPLL_RESET again */ 17023b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_RESET_MASK, ~UPLL_RESET_MASK); 17033b0627a4SAlex Jivin 17043b0627a4SAlex Jivin /* Disable spread spectrum. */ 17053b0627a4SAlex Jivin WREG32_P(CG_UPLL_SPREAD_SPECTRUM, 0, ~SSEN_MASK); 17063b0627a4SAlex Jivin 17073b0627a4SAlex Jivin /* Set feedback divider */ 17083b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_3, UPLL_FB_DIV(fb_div), ~UPLL_FB_DIV_MASK); 17093b0627a4SAlex Jivin 17103b0627a4SAlex Jivin /* Set ref divider to 0 */ 17113b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_REF_DIV_MASK); 17123b0627a4SAlex Jivin 17133b0627a4SAlex Jivin if (fb_div < 307200) 17143b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_4, 0, ~UPLL_SPARE_ISPARE9); 17153b0627a4SAlex Jivin else 17163b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_4, 17173b0627a4SAlex Jivin UPLL_SPARE_ISPARE9, 17183b0627a4SAlex Jivin ~UPLL_SPARE_ISPARE9); 17193b0627a4SAlex Jivin 17203b0627a4SAlex Jivin /* Set PDIV_A and PDIV_B */ 17213b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_2, 17223b0627a4SAlex Jivin UPLL_PDIV_A(vclk_div) | UPLL_PDIV_B(dclk_div), 17233b0627a4SAlex Jivin ~(UPLL_PDIV_A_MASK | UPLL_PDIV_B_MASK)); 17243b0627a4SAlex Jivin 17253b0627a4SAlex Jivin /* Give the PLL some time to settle */ 17263b0627a4SAlex Jivin mdelay(15); 17273b0627a4SAlex Jivin 17283b0627a4SAlex Jivin /* Deassert PLL_RESET */ 17293b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_RESET_MASK); 17303b0627a4SAlex Jivin 17313b0627a4SAlex Jivin mdelay(15); 17323b0627a4SAlex Jivin 17333b0627a4SAlex Jivin /* Switch from bypass mode to normal mode */ 17343b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_BYPASS_EN_MASK); 17353b0627a4SAlex Jivin 17363b0627a4SAlex Jivin r = si_uvd_send_upll_ctlreq(adev, CG_UPLL_FUNC_CNTL); 17373b0627a4SAlex Jivin if (r) 17383b0627a4SAlex Jivin return r; 17393b0627a4SAlex Jivin 17403b0627a4SAlex Jivin /* Switch VCLK and DCLK selection */ 17413b0627a4SAlex Jivin WREG32_P(CG_UPLL_FUNC_CNTL_2, 17423b0627a4SAlex Jivin VCLK_SRC_SEL(2) | DCLK_SRC_SEL(2), 17433b0627a4SAlex Jivin ~(VCLK_SRC_SEL_MASK | DCLK_SRC_SEL_MASK)); 17443b0627a4SAlex Jivin 17453b0627a4SAlex Jivin mdelay(100); 17463b0627a4SAlex Jivin 17473b0627a4SAlex Jivin return 0; 17483b0627a4SAlex Jivin } 17493b0627a4SAlex Jivin 1750fb40bcebSAlex Jivin static int si_vce_send_vcepll_ctlreq(struct amdgpu_device *adev) 1751fb40bcebSAlex Jivin { 1752fb40bcebSAlex Jivin unsigned i; 1753fb40bcebSAlex Jivin 1754fb40bcebSAlex Jivin /* Make sure VCEPLL_CTLREQ is deasserted */ 1755fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~UPLL_CTLREQ_MASK); 1756fb40bcebSAlex Jivin 1757fb40bcebSAlex Jivin mdelay(10); 1758fb40bcebSAlex Jivin 1759fb40bcebSAlex Jivin /* Assert UPLL_CTLREQ */ 1760fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, UPLL_CTLREQ_MASK, ~UPLL_CTLREQ_MASK); 1761fb40bcebSAlex Jivin 1762fb40bcebSAlex Jivin /* Wait for CTLACK and CTLACK2 to get asserted */ 1763fb40bcebSAlex Jivin for (i = 0; i < SI_MAX_CTLACKS_ASSERTION_WAIT; ++i) { 1764fb40bcebSAlex Jivin uint32_t mask = UPLL_CTLACK_MASK | UPLL_CTLACK2_MASK; 1765fb40bcebSAlex Jivin 1766fb40bcebSAlex Jivin if ((RREG32_SMC(CG_VCEPLL_FUNC_CNTL) & mask) == mask) 1767fb40bcebSAlex Jivin break; 1768fb40bcebSAlex Jivin mdelay(10); 1769fb40bcebSAlex Jivin } 1770fb40bcebSAlex Jivin 1771fb40bcebSAlex Jivin /* Deassert UPLL_CTLREQ */ 1772fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~UPLL_CTLREQ_MASK); 1773fb40bcebSAlex Jivin 1774fb40bcebSAlex Jivin if (i == SI_MAX_CTLACKS_ASSERTION_WAIT) { 1775fb40bcebSAlex Jivin DRM_ERROR("Timeout setting UVD clocks!\n"); 1776fb40bcebSAlex Jivin return -ETIMEDOUT; 1777fb40bcebSAlex Jivin } 1778fb40bcebSAlex Jivin 1779fb40bcebSAlex Jivin return 0; 1780fb40bcebSAlex Jivin } 1781fb40bcebSAlex Jivin 1782fb40bcebSAlex Jivin static int si_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) 1783fb40bcebSAlex Jivin { 1784fb40bcebSAlex Jivin unsigned fb_div = 0, evclk_div = 0, ecclk_div = 0; 1785fb40bcebSAlex Jivin int r; 1786fb40bcebSAlex Jivin 1787fb40bcebSAlex Jivin /* Bypass evclk and ecclk with bclk */ 1788fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_2, 1789fb40bcebSAlex Jivin EVCLK_SRC_SEL(1) | ECCLK_SRC_SEL(1), 1790fb40bcebSAlex Jivin ~(EVCLK_SRC_SEL_MASK | ECCLK_SRC_SEL_MASK)); 1791fb40bcebSAlex Jivin 1792fb40bcebSAlex Jivin /* Put PLL in bypass mode */ 1793fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_BYPASS_EN_MASK, 1794fb40bcebSAlex Jivin ~VCEPLL_BYPASS_EN_MASK); 1795fb40bcebSAlex Jivin 1796fb40bcebSAlex Jivin if (!evclk || !ecclk) { 1797fb40bcebSAlex Jivin /* Keep the Bypass mode, put PLL to sleep */ 1798fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_SLEEP_MASK, 1799fb40bcebSAlex Jivin ~VCEPLL_SLEEP_MASK); 1800fb40bcebSAlex Jivin return 0; 1801fb40bcebSAlex Jivin } 1802fb40bcebSAlex Jivin 1803fb40bcebSAlex Jivin r = si_calc_upll_dividers(adev, evclk, ecclk, 125000, 250000, 1804fb40bcebSAlex Jivin 16384, 0x03FFFFFF, 0, 128, 5, 1805fb40bcebSAlex Jivin &fb_div, &evclk_div, &ecclk_div); 1806fb40bcebSAlex Jivin if (r) 1807fb40bcebSAlex Jivin return r; 1808fb40bcebSAlex Jivin 1809fb40bcebSAlex Jivin /* Set RESET_ANTI_MUX to 0 */ 1810fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_5, 0, ~RESET_ANTI_MUX_MASK); 1811fb40bcebSAlex Jivin 1812fb40bcebSAlex Jivin /* Set VCO_MODE to 1 */ 1813fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_VCO_MODE_MASK, 1814fb40bcebSAlex Jivin ~VCEPLL_VCO_MODE_MASK); 1815fb40bcebSAlex Jivin 1816fb40bcebSAlex Jivin /* Toggle VCEPLL_SLEEP to 1 then back to 0 */ 1817fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_SLEEP_MASK, 1818fb40bcebSAlex Jivin ~VCEPLL_SLEEP_MASK); 1819fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_SLEEP_MASK); 1820fb40bcebSAlex Jivin 1821fb40bcebSAlex Jivin /* Deassert VCEPLL_RESET */ 1822fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_RESET_MASK); 1823fb40bcebSAlex Jivin 1824fb40bcebSAlex Jivin mdelay(1); 1825fb40bcebSAlex Jivin 1826fb40bcebSAlex Jivin r = si_vce_send_vcepll_ctlreq(adev); 1827fb40bcebSAlex Jivin if (r) 1828fb40bcebSAlex Jivin return r; 1829fb40bcebSAlex Jivin 1830fb40bcebSAlex Jivin /* Assert VCEPLL_RESET again */ 1831fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, VCEPLL_RESET_MASK, ~VCEPLL_RESET_MASK); 1832fb40bcebSAlex Jivin 1833fb40bcebSAlex Jivin /* Disable spread spectrum. */ 1834fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_SPREAD_SPECTRUM, 0, ~SSEN_MASK); 1835fb40bcebSAlex Jivin 1836fb40bcebSAlex Jivin /* Set feedback divider */ 1837fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_3, 1838fb40bcebSAlex Jivin VCEPLL_FB_DIV(fb_div), 1839fb40bcebSAlex Jivin ~VCEPLL_FB_DIV_MASK); 1840fb40bcebSAlex Jivin 1841fb40bcebSAlex Jivin /* Set ref divider to 0 */ 1842fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_REF_DIV_MASK); 1843fb40bcebSAlex Jivin 1844fb40bcebSAlex Jivin /* Set PDIV_A and PDIV_B */ 1845fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_2, 1846fb40bcebSAlex Jivin VCEPLL_PDIV_A(evclk_div) | VCEPLL_PDIV_B(ecclk_div), 1847fb40bcebSAlex Jivin ~(VCEPLL_PDIV_A_MASK | VCEPLL_PDIV_B_MASK)); 1848fb40bcebSAlex Jivin 1849fb40bcebSAlex Jivin /* Give the PLL some time to settle */ 1850fb40bcebSAlex Jivin mdelay(15); 1851fb40bcebSAlex Jivin 1852fb40bcebSAlex Jivin /* Deassert PLL_RESET */ 1853fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_RESET_MASK); 1854fb40bcebSAlex Jivin 1855fb40bcebSAlex Jivin mdelay(15); 1856fb40bcebSAlex Jivin 1857fb40bcebSAlex Jivin /* Switch from bypass mode to normal mode */ 1858fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL, 0, ~VCEPLL_BYPASS_EN_MASK); 1859fb40bcebSAlex Jivin 1860fb40bcebSAlex Jivin r = si_vce_send_vcepll_ctlreq(adev); 1861fb40bcebSAlex Jivin if (r) 1862fb40bcebSAlex Jivin return r; 1863fb40bcebSAlex Jivin 1864fb40bcebSAlex Jivin /* Switch VCLK and DCLK selection */ 1865fb40bcebSAlex Jivin WREG32_SMC_P(CG_VCEPLL_FUNC_CNTL_2, 1866fb40bcebSAlex Jivin EVCLK_SRC_SEL(16) | ECCLK_SRC_SEL(16), 1867fb40bcebSAlex Jivin ~(EVCLK_SRC_SEL_MASK | ECCLK_SRC_SEL_MASK)); 1868fb40bcebSAlex Jivin 1869fb40bcebSAlex Jivin mdelay(100); 1870fb40bcebSAlex Jivin 1871fb40bcebSAlex Jivin return 0; 1872fb40bcebSAlex Jivin } 1873fb40bcebSAlex Jivin 1874632d9f94SAlex Deucher static void si_pre_asic_init(struct amdgpu_device *adev) 1875632d9f94SAlex Deucher { 1876632d9f94SAlex Deucher } 1877632d9f94SAlex Deucher 187862a37553SKen Wang static const struct amdgpu_asic_funcs si_asic_funcs = 187962a37553SKen Wang { 188062a37553SKen Wang .read_disabled_bios = &si_read_disabled_bios, 18816d949d24SAlex Deucher .read_bios_from_rom = &si_read_bios_from_rom, 188262a37553SKen Wang .read_register = &si_read_register, 188362a37553SKen Wang .reset = &si_asic_reset, 1884dd81eedeSAlex Deucher .reset_method = &si_asic_reset_method, 188562a37553SKen Wang .set_vga_state = &si_vga_set_state, 188662a37553SKen Wang .get_xclk = &si_get_xclk, 188762a37553SKen Wang .set_uvd_clocks = &si_set_uvd_clocks, 1888fb40bcebSAlex Jivin .set_vce_clocks = &si_set_vce_clocks, 188920ca25e8SAlex Deucher .get_pcie_lanes = &si_get_pcie_lanes, 189020ca25e8SAlex Deucher .set_pcie_lanes = &si_set_pcie_lanes, 1891bbf282d8SAlex Deucher .get_config_memsize = &si_get_config_memsize, 18922d5e0807SAlex Deucher .flush_hdp = &si_flush_hdp, 18932d5e0807SAlex Deucher .invalidate_hdp = &si_invalidate_hdp, 18940a881af8SAlex Deucher .need_full_reset = &si_need_full_reset, 1895b45e18acSKent Russell .get_pcie_usage = &si_get_pcie_usage, 18967450bbe7SAlex Deucher .need_reset_on_init = &si_need_reset_on_init, 1897dcea6e65SKent Russell .get_pcie_replay_count = &si_get_pcie_replay_count, 18983670c242SAlex Deucher .supports_baco = &si_asic_supports_baco, 1899632d9f94SAlex Deucher .pre_asic_init = &si_pre_asic_init, 190062a37553SKen Wang }; 190162a37553SKen Wang 190262a37553SKen Wang static uint32_t si_get_rev_id(struct amdgpu_device *adev) 190362a37553SKen Wang { 190462a37553SKen Wang return (RREG32(CC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK) 190562a37553SKen Wang >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; 190662a37553SKen Wang } 190762a37553SKen Wang 190862a37553SKen Wang static int si_common_early_init(void *handle) 190962a37553SKen Wang { 191062a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 191162a37553SKen Wang 191262a37553SKen Wang adev->smc_rreg = &si_smc_rreg; 191362a37553SKen Wang adev->smc_wreg = &si_smc_wreg; 191462a37553SKen Wang adev->pcie_rreg = &si_pcie_rreg; 191562a37553SKen Wang adev->pcie_wreg = &si_pcie_wreg; 191636b9a952SHuang Rui adev->pciep_rreg = &si_pciep_rreg; 191736b9a952SHuang Rui adev->pciep_wreg = &si_pciep_wreg; 191880533a85SSonny Jiang adev->uvd_ctx_rreg = si_uvd_ctx_rreg; 191980533a85SSonny Jiang adev->uvd_ctx_wreg = si_uvd_ctx_wreg; 192062a37553SKen Wang adev->didt_rreg = NULL; 192162a37553SKen Wang adev->didt_wreg = NULL; 192262a37553SKen Wang 192362a37553SKen Wang adev->asic_funcs = &si_asic_funcs; 192462a37553SKen Wang 192562a37553SKen Wang adev->rev_id = si_get_rev_id(adev); 192662a37553SKen Wang adev->external_rev_id = 0xFF; 192762a37553SKen Wang switch (adev->asic_type) { 192862a37553SKen Wang case CHIP_TAHITI: 192962a37553SKen Wang adev->cg_flags = 193062a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 193162a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 193262a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 193362a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 193462a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 193562a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 193662a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 193762a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 193862a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 193962a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 194062a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 194162a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 194262a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 194362a37553SKen Wang adev->pg_flags = 0; 19447c0a705eSFlora Cui adev->external_rev_id = (adev->rev_id == 0) ? 1 : 19457c0a705eSFlora Cui (adev->rev_id == 1) ? 5 : 6; 194662a37553SKen Wang break; 194762a37553SKen Wang case CHIP_PITCAIRN: 194862a37553SKen Wang adev->cg_flags = 194962a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 195062a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 195162a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 195262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 195362a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 195462a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 195562a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 195662a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 195762a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 195862a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 195962a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 196062a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 196162a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 196262a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 196362a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 196462a37553SKen Wang adev->pg_flags = 0; 1965e285a9a6SFlora Cui adev->external_rev_id = adev->rev_id + 20; 196662a37553SKen Wang break; 196762a37553SKen Wang 196862a37553SKen Wang case CHIP_VERDE: 196962a37553SKen Wang adev->cg_flags = 197062a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 197162a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 197262a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 197362a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 197462a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS_LS | 197562a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 197662a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 197762a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 197862a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 197962a37553SKen Wang AMD_CG_SUPPORT_SDMA_LS | 198062a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 198162a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 198262a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 198362a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 198462a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 198562a37553SKen Wang adev->pg_flags = 0; 198662a37553SKen Wang //??? 1987f815b29cSFlora Cui adev->external_rev_id = adev->rev_id + 40; 198862a37553SKen Wang break; 198962a37553SKen Wang case CHIP_OLAND: 199062a37553SKen Wang adev->cg_flags = 199162a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 199262a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 199362a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 199462a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 199562a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 199662a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 199762a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 199862a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 199962a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 200062a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 200162a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 200262a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 200362a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 200462a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 200562a37553SKen Wang adev->pg_flags = 0; 20068fd74cb4SFlora Cui adev->external_rev_id = 60; 200762a37553SKen Wang break; 200862a37553SKen Wang case CHIP_HAINAN: 200962a37553SKen Wang adev->cg_flags = 201062a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 201162a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 201262a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 201362a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 201462a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 201562a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 201662a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 201762a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 201862a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 201962a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 202062a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 202162a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 202262a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 202362a37553SKen Wang adev->pg_flags = 0; 202405319478SFlora Cui adev->external_rev_id = 70; 202562a37553SKen Wang break; 202662a37553SKen Wang 202762a37553SKen Wang default: 202862a37553SKen Wang return -EINVAL; 202962a37553SKen Wang } 203062a37553SKen Wang 203162a37553SKen Wang return 0; 203262a37553SKen Wang } 203362a37553SKen Wang 203462a37553SKen Wang static int si_common_sw_init(void *handle) 203562a37553SKen Wang { 203662a37553SKen Wang return 0; 203762a37553SKen Wang } 203862a37553SKen Wang 203962a37553SKen Wang static int si_common_sw_fini(void *handle) 204062a37553SKen Wang { 204162a37553SKen Wang return 0; 204262a37553SKen Wang } 204362a37553SKen Wang 204462a37553SKen Wang 204562a37553SKen Wang static void si_init_golden_registers(struct amdgpu_device *adev) 204662a37553SKen Wang { 204762a37553SKen Wang switch (adev->asic_type) { 204862a37553SKen Wang case CHIP_TAHITI: 20499c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 205062a37553SKen Wang tahiti_golden_registers, 2051c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_registers)); 20529c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 205362a37553SKen Wang tahiti_golden_rlc_registers, 2054c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_rlc_registers)); 20559c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 205662a37553SKen Wang tahiti_mgcg_cgcg_init, 2057c47b41a7SChristian König ARRAY_SIZE(tahiti_mgcg_cgcg_init)); 20589c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 205962a37553SKen Wang tahiti_golden_registers2, 2060c47b41a7SChristian König ARRAY_SIZE(tahiti_golden_registers2)); 206162a37553SKen Wang break; 206262a37553SKen Wang case CHIP_PITCAIRN: 20639c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 206462a37553SKen Wang pitcairn_golden_registers, 2065c47b41a7SChristian König ARRAY_SIZE(pitcairn_golden_registers)); 20669c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 206762a37553SKen Wang pitcairn_golden_rlc_registers, 2068c47b41a7SChristian König ARRAY_SIZE(pitcairn_golden_rlc_registers)); 20699c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 207062a37553SKen Wang pitcairn_mgcg_cgcg_init, 2071c47b41a7SChristian König ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); 20725694785cSJean Delvare break; 207362a37553SKen Wang case CHIP_VERDE: 20749c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 207562a37553SKen Wang verde_golden_registers, 2076c47b41a7SChristian König ARRAY_SIZE(verde_golden_registers)); 20779c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 207862a37553SKen Wang verde_golden_rlc_registers, 2079c47b41a7SChristian König ARRAY_SIZE(verde_golden_rlc_registers)); 20809c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 208162a37553SKen Wang verde_mgcg_cgcg_init, 2082c47b41a7SChristian König ARRAY_SIZE(verde_mgcg_cgcg_init)); 20839c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 208462a37553SKen Wang verde_pg_init, 2085c47b41a7SChristian König ARRAY_SIZE(verde_pg_init)); 208662a37553SKen Wang break; 208762a37553SKen Wang case CHIP_OLAND: 20889c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 208962a37553SKen Wang oland_golden_registers, 2090c47b41a7SChristian König ARRAY_SIZE(oland_golden_registers)); 20919c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 209262a37553SKen Wang oland_golden_rlc_registers, 2093c47b41a7SChristian König ARRAY_SIZE(oland_golden_rlc_registers)); 20949c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 209562a37553SKen Wang oland_mgcg_cgcg_init, 2096c47b41a7SChristian König ARRAY_SIZE(oland_mgcg_cgcg_init)); 20975694785cSJean Delvare break; 209862a37553SKen Wang case CHIP_HAINAN: 20999c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 210062a37553SKen Wang hainan_golden_registers, 2101c47b41a7SChristian König ARRAY_SIZE(hainan_golden_registers)); 21029c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 210362a37553SKen Wang hainan_golden_registers2, 2104c47b41a7SChristian König ARRAY_SIZE(hainan_golden_registers2)); 21059c3f2b54SAlex Deucher amdgpu_device_program_register_sequence(adev, 210662a37553SKen Wang hainan_mgcg_cgcg_init, 2107c47b41a7SChristian König ARRAY_SIZE(hainan_mgcg_cgcg_init)); 210862a37553SKen Wang break; 210962a37553SKen Wang 211062a37553SKen Wang 211162a37553SKen Wang default: 211262a37553SKen Wang BUG(); 211362a37553SKen Wang } 211462a37553SKen Wang } 211562a37553SKen Wang 211662a37553SKen Wang static void si_pcie_gen3_enable(struct amdgpu_device *adev) 211762a37553SKen Wang { 211862a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 21190bf67185SAlex Deucher u32 speed_cntl, current_data_rate; 21200bf67185SAlex Deucher int i; 212162a37553SKen Wang u16 tmp16; 212262a37553SKen Wang 212362a37553SKen Wang if (pci_is_root_bus(adev->pdev->bus)) 212462a37553SKen Wang return; 212562a37553SKen Wang 212662a37553SKen Wang if (amdgpu_pcie_gen2 == 0) 212762a37553SKen Wang return; 212862a37553SKen Wang 212962a37553SKen Wang if (adev->flags & AMD_IS_APU) 213062a37553SKen Wang return; 213162a37553SKen Wang 21320bf67185SAlex Deucher if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | 21330bf67185SAlex Deucher CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) 213462a37553SKen Wang return; 213562a37553SKen Wang 213636b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 213762a37553SKen Wang current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> 213862a37553SKen Wang LC_CURRENT_DATA_RATE_SHIFT; 21390bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { 214062a37553SKen Wang if (current_data_rate == 2) { 214162a37553SKen Wang DRM_INFO("PCIE gen 3 link speeds already enabled\n"); 214262a37553SKen Wang return; 214362a37553SKen Wang } 214462a37553SKen Wang DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); 21450bf67185SAlex Deucher } else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) { 214662a37553SKen Wang if (current_data_rate == 1) { 214762a37553SKen Wang DRM_INFO("PCIE gen 2 link speeds already enabled\n"); 214862a37553SKen Wang return; 214962a37553SKen Wang } 215062a37553SKen Wang DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n"); 215162a37553SKen Wang } 215262a37553SKen Wang 215388027c89SFrederick Lawler if (!pci_is_pcie(root) || !pci_is_pcie(adev->pdev)) 215462a37553SKen Wang return; 215562a37553SKen Wang 21560bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { 215762a37553SKen Wang if (current_data_rate != 2) { 215862a37553SKen Wang u16 bridge_cfg, gpu_cfg; 215962a37553SKen Wang u16 bridge_cfg2, gpu_cfg2; 216062a37553SKen Wang u32 max_lw, current_lw, tmp; 216162a37553SKen Wang 216288027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL, 216388027c89SFrederick Lawler &bridge_cfg); 216488027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, PCI_EXP_LNKCTL, 216588027c89SFrederick Lawler &gpu_cfg); 216662a37553SKen Wang 216762a37553SKen Wang tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD; 216888027c89SFrederick Lawler pcie_capability_write_word(root, PCI_EXP_LNKCTL, tmp16); 216962a37553SKen Wang 217062a37553SKen Wang tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD; 217188027c89SFrederick Lawler pcie_capability_write_word(adev->pdev, PCI_EXP_LNKCTL, 217288027c89SFrederick Lawler tmp16); 217362a37553SKen Wang 217462a37553SKen Wang tmp = RREG32_PCIE(PCIE_LC_STATUS1); 217562a37553SKen Wang max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; 217662a37553SKen Wang current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; 217762a37553SKen Wang 217862a37553SKen Wang if (current_lw < max_lw) { 217936b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 218062a37553SKen Wang if (tmp & LC_RENEGOTIATION_SUPPORT) { 218162a37553SKen Wang tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); 218262a37553SKen Wang tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); 218362a37553SKen Wang tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; 218436b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); 218562a37553SKen Wang } 218662a37553SKen Wang } 218762a37553SKen Wang 218862a37553SKen Wang for (i = 0; i < 10; i++) { 218988027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 219088027c89SFrederick Lawler PCI_EXP_DEVSTA, 219188027c89SFrederick Lawler &tmp16); 219262a37553SKen Wang if (tmp16 & PCI_EXP_DEVSTA_TRPND) 219362a37553SKen Wang break; 219462a37553SKen Wang 219588027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL, 219688027c89SFrederick Lawler &bridge_cfg); 219788027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 219888027c89SFrederick Lawler PCI_EXP_LNKCTL, 219988027c89SFrederick Lawler &gpu_cfg); 220062a37553SKen Wang 220188027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL2, 220288027c89SFrederick Lawler &bridge_cfg2); 220388027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 220488027c89SFrederick Lawler PCI_EXP_LNKCTL2, 220588027c89SFrederick Lawler &gpu_cfg2); 220662a37553SKen Wang 220736b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 220862a37553SKen Wang tmp |= LC_SET_QUIESCE; 220936b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 221062a37553SKen Wang 221136b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 221262a37553SKen Wang tmp |= LC_REDO_EQ; 221336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 221462a37553SKen Wang 221562a37553SKen Wang mdelay(100); 221662a37553SKen Wang 221788027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL, 221888027c89SFrederick Lawler &tmp16); 221962a37553SKen Wang tmp16 &= ~PCI_EXP_LNKCTL_HAWD; 222062a37553SKen Wang tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD); 222188027c89SFrederick Lawler pcie_capability_write_word(root, PCI_EXP_LNKCTL, 222288027c89SFrederick Lawler tmp16); 222362a37553SKen Wang 222488027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 222588027c89SFrederick Lawler PCI_EXP_LNKCTL, 222688027c89SFrederick Lawler &tmp16); 222762a37553SKen Wang tmp16 &= ~PCI_EXP_LNKCTL_HAWD; 222862a37553SKen Wang tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD); 222988027c89SFrederick Lawler pcie_capability_write_word(adev->pdev, 223088027c89SFrederick Lawler PCI_EXP_LNKCTL, 223188027c89SFrederick Lawler tmp16); 223262a37553SKen Wang 223388027c89SFrederick Lawler pcie_capability_read_word(root, PCI_EXP_LNKCTL2, 223488027c89SFrederick Lawler &tmp16); 223535e768e2SBjorn Helgaas tmp16 &= ~(PCI_EXP_LNKCTL2_ENTER_COMP | 223635e768e2SBjorn Helgaas PCI_EXP_LNKCTL2_TX_MARGIN); 223735e768e2SBjorn Helgaas tmp16 |= (bridge_cfg2 & 223835e768e2SBjorn Helgaas (PCI_EXP_LNKCTL2_ENTER_COMP | 223935e768e2SBjorn Helgaas PCI_EXP_LNKCTL2_TX_MARGIN)); 224088027c89SFrederick Lawler pcie_capability_write_word(root, 224188027c89SFrederick Lawler PCI_EXP_LNKCTL2, 224288027c89SFrederick Lawler tmp16); 224362a37553SKen Wang 224488027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, 224588027c89SFrederick Lawler PCI_EXP_LNKCTL2, 224688027c89SFrederick Lawler &tmp16); 224735e768e2SBjorn Helgaas tmp16 &= ~(PCI_EXP_LNKCTL2_ENTER_COMP | 224835e768e2SBjorn Helgaas PCI_EXP_LNKCTL2_TX_MARGIN); 224935e768e2SBjorn Helgaas tmp16 |= (gpu_cfg2 & 225035e768e2SBjorn Helgaas (PCI_EXP_LNKCTL2_ENTER_COMP | 225135e768e2SBjorn Helgaas PCI_EXP_LNKCTL2_TX_MARGIN)); 225288027c89SFrederick Lawler pcie_capability_write_word(adev->pdev, 225388027c89SFrederick Lawler PCI_EXP_LNKCTL2, 225488027c89SFrederick Lawler tmp16); 225562a37553SKen Wang 225636b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 225762a37553SKen Wang tmp &= ~LC_SET_QUIESCE; 225836b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 225962a37553SKen Wang } 226062a37553SKen Wang } 226162a37553SKen Wang } 226262a37553SKen Wang 226362a37553SKen Wang speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; 226462a37553SKen Wang speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; 226536b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 226662a37553SKen Wang 226788027c89SFrederick Lawler pcie_capability_read_word(adev->pdev, PCI_EXP_LNKCTL2, &tmp16); 226835e768e2SBjorn Helgaas tmp16 &= ~PCI_EXP_LNKCTL2_TLS; 226988027c89SFrederick Lawler 22700bf67185SAlex Deucher if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) 227135e768e2SBjorn Helgaas tmp16 |= PCI_EXP_LNKCTL2_TLS_8_0GT; /* gen3 */ 22720bf67185SAlex Deucher else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) 227335e768e2SBjorn Helgaas tmp16 |= PCI_EXP_LNKCTL2_TLS_5_0GT; /* gen2 */ 227462a37553SKen Wang else 227535e768e2SBjorn Helgaas tmp16 |= PCI_EXP_LNKCTL2_TLS_2_5GT; /* gen1 */ 227688027c89SFrederick Lawler pcie_capability_write_word(adev->pdev, PCI_EXP_LNKCTL2, tmp16); 227762a37553SKen Wang 227836b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 227962a37553SKen Wang speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; 228036b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 228162a37553SKen Wang 228262a37553SKen Wang for (i = 0; i < adev->usec_timeout; i++) { 228336b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 228462a37553SKen Wang if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) 228562a37553SKen Wang break; 228662a37553SKen Wang udelay(1); 228762a37553SKen Wang } 228862a37553SKen Wang } 228962a37553SKen Wang 229062a37553SKen Wang static inline u32 si_pif_phy0_rreg(struct amdgpu_device *adev, u32 reg) 229162a37553SKen Wang { 229262a37553SKen Wang unsigned long flags; 229362a37553SKen Wang u32 r; 229462a37553SKen Wang 229562a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 229662a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 229762a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY0_DATA); 229862a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 229962a37553SKen Wang return r; 230062a37553SKen Wang } 230162a37553SKen Wang 230262a37553SKen Wang static inline void si_pif_phy0_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 230362a37553SKen Wang { 230462a37553SKen Wang unsigned long flags; 230562a37553SKen Wang 230662a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 230762a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 230862a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); 230962a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 231062a37553SKen Wang } 231162a37553SKen Wang 231262a37553SKen Wang static inline u32 si_pif_phy1_rreg(struct amdgpu_device *adev, u32 reg) 231362a37553SKen Wang { 231462a37553SKen Wang unsigned long flags; 231562a37553SKen Wang u32 r; 231662a37553SKen Wang 231762a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 231862a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 231962a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY1_DATA); 232062a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 232162a37553SKen Wang return r; 232262a37553SKen Wang } 232362a37553SKen Wang 232462a37553SKen Wang static inline void si_pif_phy1_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 232562a37553SKen Wang { 232662a37553SKen Wang unsigned long flags; 232762a37553SKen Wang 232862a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 232962a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 233062a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); 233162a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 233262a37553SKen Wang } 233362a37553SKen Wang static void si_program_aspm(struct amdgpu_device *adev) 233462a37553SKen Wang { 233562a37553SKen Wang u32 data, orig; 233662a37553SKen Wang bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; 233762a37553SKen Wang bool disable_clkreq = false; 233862a37553SKen Wang 233962a37553SKen Wang if (amdgpu_aspm == 0) 234062a37553SKen Wang return; 234162a37553SKen Wang 234262a37553SKen Wang if (adev->flags & AMD_IS_APU) 234362a37553SKen Wang return; 234436b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 234562a37553SKen Wang data &= ~LC_XMIT_N_FTS_MASK; 234662a37553SKen Wang data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; 234762a37553SKen Wang if (orig != data) 234836b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); 234962a37553SKen Wang 235036b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); 235162a37553SKen Wang data |= LC_GO_TO_RECOVERY; 235262a37553SKen Wang if (orig != data) 235336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); 235462a37553SKen Wang 235562a37553SKen Wang orig = data = RREG32_PCIE(PCIE_P_CNTL); 235662a37553SKen Wang data |= P_IGNORE_EDB_ERR; 235762a37553SKen Wang if (orig != data) 235862a37553SKen Wang WREG32_PCIE(PCIE_P_CNTL, data); 235962a37553SKen Wang 236036b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 236162a37553SKen Wang data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); 236262a37553SKen Wang data |= LC_PMI_TO_L1_DIS; 236362a37553SKen Wang if (!disable_l0s) 236462a37553SKen Wang data |= LC_L0S_INACTIVITY(7); 236562a37553SKen Wang 236662a37553SKen Wang if (!disable_l1) { 236762a37553SKen Wang data |= LC_L1_INACTIVITY(7); 236862a37553SKen Wang data &= ~LC_PMI_TO_L1_DIS; 236962a37553SKen Wang if (orig != data) 237036b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 237162a37553SKen Wang 237262a37553SKen Wang if (!disable_plloff_in_l1) { 237362a37553SKen Wang bool clk_req_support; 237462a37553SKen Wang 237562a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 237662a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 237762a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 237862a37553SKen Wang if (orig != data) 237962a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 238062a37553SKen Wang 238162a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 238262a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 238362a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 238462a37553SKen Wang if (orig != data) 238562a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 238662a37553SKen Wang 238762a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 238862a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 238962a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 239062a37553SKen Wang if (orig != data) 239162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 239262a37553SKen Wang 239362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 239462a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 239562a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 239662a37553SKen Wang if (orig != data) 239762a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 239862a37553SKen Wang 239977efe48aSJean Delvare if ((adev->asic_type != CHIP_OLAND) && (adev->asic_type != CHIP_HAINAN)) { 240062a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 240162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 240262a37553SKen Wang if (orig != data) 240362a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 240462a37553SKen Wang 240562a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 240662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 240762a37553SKen Wang if (orig != data) 240862a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 240962a37553SKen Wang 241062a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_2); 241162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 241262a37553SKen Wang if (orig != data) 241362a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_2, data); 241462a37553SKen Wang 241562a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_3); 241662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 241762a37553SKen Wang if (orig != data) 241862a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_3, data); 241962a37553SKen Wang 242062a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 242162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 242262a37553SKen Wang if (orig != data) 242362a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 242462a37553SKen Wang 242562a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 242662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 242762a37553SKen Wang if (orig != data) 242862a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 242962a37553SKen Wang 243062a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_2); 243162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 243262a37553SKen Wang if (orig != data) 243362a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_2, data); 243462a37553SKen Wang 243562a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_3); 243662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 243762a37553SKen Wang if (orig != data) 243862a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); 243962a37553SKen Wang } 244036b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 244162a37553SKen Wang data &= ~LC_DYN_LANES_PWR_STATE_MASK; 244262a37553SKen Wang data |= LC_DYN_LANES_PWR_STATE(3); 244362a37553SKen Wang if (orig != data) 244436b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); 244562a37553SKen Wang 244662a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); 244762a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 244877efe48aSJean Delvare if ((adev->asic_type == CHIP_OLAND) || (adev->asic_type == CHIP_HAINAN)) 244962a37553SKen Wang data |= LS2_EXIT_TIME(5); 245062a37553SKen Wang if (orig != data) 245162a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_CNTL, data); 245262a37553SKen Wang 245362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_CNTL); 245462a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 245577efe48aSJean Delvare if ((adev->asic_type == CHIP_OLAND) || (adev->asic_type == CHIP_HAINAN)) 245662a37553SKen Wang data |= LS2_EXIT_TIME(5); 245762a37553SKen Wang if (orig != data) 245862a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_CNTL, data); 245962a37553SKen Wang 246062a37553SKen Wang if (!disable_clkreq && 246162a37553SKen Wang !pci_is_root_bus(adev->pdev->bus)) { 246262a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 246362a37553SKen Wang u32 lnkcap; 246462a37553SKen Wang 246562a37553SKen Wang clk_req_support = false; 246662a37553SKen Wang pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); 246762a37553SKen Wang if (lnkcap & PCI_EXP_LNKCAP_CLKPM) 246862a37553SKen Wang clk_req_support = true; 246962a37553SKen Wang } else { 247062a37553SKen Wang clk_req_support = false; 247162a37553SKen Wang } 247262a37553SKen Wang 247362a37553SKen Wang if (clk_req_support) { 247436b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); 247562a37553SKen Wang data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; 247662a37553SKen Wang if (orig != data) 247736b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); 247862a37553SKen Wang 247962a37553SKen Wang orig = data = RREG32(THM_CLK_CNTL); 248062a37553SKen Wang data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); 248162a37553SKen Wang data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); 248262a37553SKen Wang if (orig != data) 248362a37553SKen Wang WREG32(THM_CLK_CNTL, data); 248462a37553SKen Wang 248562a37553SKen Wang orig = data = RREG32(MISC_CLK_CNTL); 248662a37553SKen Wang data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); 248762a37553SKen Wang data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); 248862a37553SKen Wang if (orig != data) 248962a37553SKen Wang WREG32(MISC_CLK_CNTL, data); 249062a37553SKen Wang 249162a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL); 249262a37553SKen Wang data &= ~BCLK_AS_XCLK; 249362a37553SKen Wang if (orig != data) 249462a37553SKen Wang WREG32(CG_CLKPIN_CNTL, data); 249562a37553SKen Wang 249662a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL_2); 249762a37553SKen Wang data &= ~FORCE_BIF_REFCLK_EN; 249862a37553SKen Wang if (orig != data) 249962a37553SKen Wang WREG32(CG_CLKPIN_CNTL_2, data); 250062a37553SKen Wang 250162a37553SKen Wang orig = data = RREG32(MPLL_BYPASSCLK_SEL); 250262a37553SKen Wang data &= ~MPLL_CLKOUT_SEL_MASK; 250362a37553SKen Wang data |= MPLL_CLKOUT_SEL(4); 250462a37553SKen Wang if (orig != data) 250562a37553SKen Wang WREG32(MPLL_BYPASSCLK_SEL, data); 250662a37553SKen Wang 250762a37553SKen Wang orig = data = RREG32(SPLL_CNTL_MODE); 250862a37553SKen Wang data &= ~SPLL_REFCLK_SEL_MASK; 250962a37553SKen Wang if (orig != data) 251062a37553SKen Wang WREG32(SPLL_CNTL_MODE, data); 251162a37553SKen Wang } 251262a37553SKen Wang } 251362a37553SKen Wang } else { 251462a37553SKen Wang if (orig != data) 251536b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 251662a37553SKen Wang } 251762a37553SKen Wang 251862a37553SKen Wang orig = data = RREG32_PCIE(PCIE_CNTL2); 251962a37553SKen Wang data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; 252062a37553SKen Wang if (orig != data) 252162a37553SKen Wang WREG32_PCIE(PCIE_CNTL2, data); 252262a37553SKen Wang 252362a37553SKen Wang if (!disable_l0s) { 252436b9a952SHuang Rui data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 252562a37553SKen Wang if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { 252662a37553SKen Wang data = RREG32_PCIE(PCIE_LC_STATUS1); 252762a37553SKen Wang if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { 252836b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 252962a37553SKen Wang data &= ~LC_L0S_INACTIVITY_MASK; 253062a37553SKen Wang if (orig != data) 253136b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 253262a37553SKen Wang } 253362a37553SKen Wang } 253462a37553SKen Wang } 253562a37553SKen Wang } 253662a37553SKen Wang 253762a37553SKen Wang static void si_fix_pci_max_read_req_size(struct amdgpu_device *adev) 253862a37553SKen Wang { 253962a37553SKen Wang int readrq; 254062a37553SKen Wang u16 v; 254162a37553SKen Wang 254262a37553SKen Wang readrq = pcie_get_readrq(adev->pdev); 254362a37553SKen Wang v = ffs(readrq) - 8; 254462a37553SKen Wang if ((v == 0) || (v == 6) || (v == 7)) 254562a37553SKen Wang pcie_set_readrq(adev->pdev, 512); 254662a37553SKen Wang } 254762a37553SKen Wang 254862a37553SKen Wang static int si_common_hw_init(void *handle) 254962a37553SKen Wang { 255062a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 255162a37553SKen Wang 255262a37553SKen Wang si_fix_pci_max_read_req_size(adev); 255362a37553SKen Wang si_init_golden_registers(adev); 255462a37553SKen Wang si_pcie_gen3_enable(adev); 255562a37553SKen Wang si_program_aspm(adev); 255662a37553SKen Wang 255762a37553SKen Wang return 0; 255862a37553SKen Wang } 255962a37553SKen Wang 256062a37553SKen Wang static int si_common_hw_fini(void *handle) 256162a37553SKen Wang { 256262a37553SKen Wang return 0; 256362a37553SKen Wang } 256462a37553SKen Wang 256562a37553SKen Wang static int si_common_suspend(void *handle) 256662a37553SKen Wang { 256762a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 256862a37553SKen Wang 256962a37553SKen Wang return si_common_hw_fini(adev); 257062a37553SKen Wang } 257162a37553SKen Wang 257262a37553SKen Wang static int si_common_resume(void *handle) 257362a37553SKen Wang { 257462a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 257562a37553SKen Wang 257662a37553SKen Wang return si_common_hw_init(adev); 257762a37553SKen Wang } 257862a37553SKen Wang 257962a37553SKen Wang static bool si_common_is_idle(void *handle) 258062a37553SKen Wang { 258162a37553SKen Wang return true; 258262a37553SKen Wang } 258362a37553SKen Wang 258462a37553SKen Wang static int si_common_wait_for_idle(void *handle) 258562a37553SKen Wang { 258662a37553SKen Wang return 0; 258762a37553SKen Wang } 258862a37553SKen Wang 258962a37553SKen Wang static int si_common_soft_reset(void *handle) 259062a37553SKen Wang { 259162a37553SKen Wang return 0; 259262a37553SKen Wang } 259362a37553SKen Wang 259462a37553SKen Wang static int si_common_set_clockgating_state(void *handle, 259562a37553SKen Wang enum amd_clockgating_state state) 259662a37553SKen Wang { 259762a37553SKen Wang return 0; 259862a37553SKen Wang } 259962a37553SKen Wang 260062a37553SKen Wang static int si_common_set_powergating_state(void *handle, 260162a37553SKen Wang enum amd_powergating_state state) 260262a37553SKen Wang { 260362a37553SKen Wang return 0; 260462a37553SKen Wang } 260562a37553SKen Wang 2606a1255107SAlex Deucher static const struct amd_ip_funcs si_common_ip_funcs = { 260762a37553SKen Wang .name = "si_common", 260862a37553SKen Wang .early_init = si_common_early_init, 260962a37553SKen Wang .late_init = NULL, 261062a37553SKen Wang .sw_init = si_common_sw_init, 261162a37553SKen Wang .sw_fini = si_common_sw_fini, 261262a37553SKen Wang .hw_init = si_common_hw_init, 261362a37553SKen Wang .hw_fini = si_common_hw_fini, 261462a37553SKen Wang .suspend = si_common_suspend, 261562a37553SKen Wang .resume = si_common_resume, 261662a37553SKen Wang .is_idle = si_common_is_idle, 261762a37553SKen Wang .wait_for_idle = si_common_wait_for_idle, 261862a37553SKen Wang .soft_reset = si_common_soft_reset, 261962a37553SKen Wang .set_clockgating_state = si_common_set_clockgating_state, 262062a37553SKen Wang .set_powergating_state = si_common_set_powergating_state, 262162a37553SKen Wang }; 262262a37553SKen Wang 2623a1255107SAlex Deucher static const struct amdgpu_ip_block_version si_common_ip_block = 262462a37553SKen Wang { 262562a37553SKen Wang .type = AMD_IP_BLOCK_TYPE_COMMON, 262662a37553SKen Wang .major = 1, 262762a37553SKen Wang .minor = 0, 262862a37553SKen Wang .rev = 0, 262962a37553SKen Wang .funcs = &si_common_ip_funcs, 26302120df47SAlex Deucher }; 26312120df47SAlex Deucher 263262a37553SKen Wang int si_set_ip_blocks(struct amdgpu_device *adev) 263362a37553SKen Wang { 263462a37553SKen Wang switch (adev->asic_type) { 263562a37553SKen Wang case CHIP_VERDE: 263662a37553SKen Wang case CHIP_TAHITI: 263762a37553SKen Wang case CHIP_PITCAIRN: 26382990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 26392990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 26402990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 26413089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 26423089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2643b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2644a1255107SAlex Deucher if (adev->enable_virtual_display) 26452990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 264664200c46SMauro Rossi #if defined(CONFIG_DRM_AMD_DC) && defined(CONFIG_DRM_AMD_DC_SI) 264764200c46SMauro Rossi else if (amdgpu_device_has_dc_support(adev)) 264864200c46SMauro Rossi amdgpu_device_ip_block_add(adev, &dm_ip_block); 264964200c46SMauro Rossi #endif 2650a1255107SAlex Deucher else 26512990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_v6_0_ip_block); 2652ee2e74f7SSonny Jiang amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); 26532990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 2654a1255107SAlex Deucher break; 265562a37553SKen Wang case CHIP_OLAND: 26562990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 26572990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 26582990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 26593089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 26603089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2661b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2662a1255107SAlex Deucher if (adev->enable_virtual_display) 26632990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 266464200c46SMauro Rossi #if defined(CONFIG_DRM_AMD_DC) && defined(CONFIG_DRM_AMD_DC_SI) 266564200c46SMauro Rossi else if (amdgpu_device_has_dc_support(adev)) 266664200c46SMauro Rossi amdgpu_device_ip_block_add(adev, &dm_ip_block); 266764200c46SMauro Rossi #endif 2668a1255107SAlex Deucher else 26692990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); 2670d375615cSSonny Jiang amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); 26712990a1fcSAlex Deucher /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 267262a37553SKen Wang break; 267362a37553SKen Wang case CHIP_HAINAN: 26742990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_common_ip_block); 26752990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 26762990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 26773089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 26783089aa22SRex Zhu amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2679b905090dSRex Zhu amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2680a1255107SAlex Deucher if (adev->enable_virtual_display) 26812990a1fcSAlex Deucher amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 268262a37553SKen Wang break; 268362a37553SKen Wang default: 268462a37553SKen Wang BUG(); 268562a37553SKen Wang } 268662a37553SKen Wang return 0; 268762a37553SKen Wang } 268862a37553SKen Wang 2689