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> 2762a37553SKen Wang #include "drmP.h" 2862a37553SKen Wang #include "amdgpu.h" 2962a37553SKen Wang #include "amdgpu_atombios.h" 3062a37553SKen Wang #include "amdgpu_ih.h" 3162a37553SKen Wang #include "amdgpu_uvd.h" 3262a37553SKen Wang #include "amdgpu_vce.h" 3362a37553SKen Wang #include "atom.h" 3462a37553SKen Wang #include "amdgpu_powerplay.h" 3562a37553SKen Wang #include "si/sid.h" 3662a37553SKen Wang #include "si_ih.h" 3762a37553SKen Wang #include "gfx_v6_0.h" 3862a37553SKen Wang #include "gmc_v6_0.h" 3962a37553SKen Wang #include "si_dma.h" 4062a37553SKen Wang #include "dce_v6_0.h" 4162a37553SKen Wang #include "si.h" 422120df47SAlex Deucher #include "dce_virtual.h" 4362a37553SKen Wang 4462a37553SKen Wang static const u32 tahiti_golden_registers[] = 4562a37553SKen Wang { 467c0a705eSFlora Cui 0x17bc, 0x00000030, 0x00000011, 4762a37553SKen Wang 0x2684, 0x00010000, 0x00018208, 4862a37553SKen Wang 0x260c, 0xffffffff, 0x00000000, 4962a37553SKen Wang 0x260d, 0xf00fffff, 0x00000400, 5062a37553SKen Wang 0x260e, 0x0002021c, 0x00020200, 5162a37553SKen Wang 0x031e, 0x00000080, 0x00000000, 527c0a705eSFlora Cui 0x340c, 0x000000c0, 0x00800040, 537c0a705eSFlora Cui 0x360c, 0x000000c0, 0x00800040, 5462a37553SKen Wang 0x16ec, 0x000000f0, 0x00000070, 5562a37553SKen Wang 0x16f0, 0x00200000, 0x50100000, 5662a37553SKen Wang 0x1c0c, 0x31000311, 0x00000011, 5762a37553SKen Wang 0x09df, 0x00000003, 0x000007ff, 5862a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 5962a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 6062a37553SKen Wang 0x22c9, 0xffffffff, 0x00ffffff, 6162a37553SKen Wang 0x22c4, 0x0000ff0f, 0x00000000, 6262a37553SKen Wang 0xa293, 0x07ffffff, 0x4e000000, 6362a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x2a00126a, 647c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0040, 6562a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 6662a37553SKen Wang 0x2440, 0x07ffffff, 0x03000000, 6762a37553SKen Wang 0x23a2, 0x01ff1f3f, 0x00000000, 6862a37553SKen Wang 0x23a1, 0x01ff1f3f, 0x00000000, 6962a37553SKen Wang 0x2418, 0x0000007f, 0x00000020, 7062a37553SKen Wang 0x2542, 0x00010000, 0x00010000, 7162a37553SKen Wang 0x2b05, 0x00000200, 0x000002fb, 7262a37553SKen Wang 0x2b04, 0xffffffff, 0x0000543b, 7362a37553SKen Wang 0x2b03, 0xffffffff, 0xa9210876, 7462a37553SKen Wang 0x2234, 0xffffffff, 0x000fff40, 7562a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 7662a37553SKen Wang 0x0504, 0x20000000, 0x20fffed8, 777c0a705eSFlora Cui 0x0570, 0x000c0fc0, 0x000c0400, 787c0a705eSFlora Cui 0x052c, 0x0fffffff, 0xffffffff, 797c0a705eSFlora Cui 0x052d, 0x0fffffff, 0x0fffffff, 807c0a705eSFlora Cui 0x052e, 0x0fffffff, 0x0fffffff, 817c0a705eSFlora Cui 0x052f, 0x0fffffff, 0x0fffffff 8262a37553SKen Wang }; 8362a37553SKen Wang 8462a37553SKen Wang static const u32 tahiti_golden_registers2[] = 8562a37553SKen Wang { 8662a37553SKen Wang 0x0319, 0x00000001, 0x00000001 8762a37553SKen Wang }; 8862a37553SKen Wang 8962a37553SKen Wang static const u32 tahiti_golden_rlc_registers[] = 9062a37553SKen Wang { 917c0a705eSFlora Cui 0x263e, 0xffffffff, 0x12011003, 9262a37553SKen Wang 0x3109, 0xffffffff, 0x00601005, 9362a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 9462a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 9562a37553SKen Wang 0x30c5, 0xffffffff, 0x00000800, 9662a37553SKen Wang 0x30c3, 0xffffffff, 0x800000f4, 977c0a705eSFlora Cui 0x3d2a, 0x00000008, 0x00000000 9862a37553SKen Wang }; 9962a37553SKen Wang 10062a37553SKen Wang static const u32 pitcairn_golden_registers[] = 10162a37553SKen Wang { 1021245a694SFlora Cui 0x17bc, 0x00000030, 0x00000011, 10362a37553SKen Wang 0x2684, 0x00010000, 0x00018208, 10462a37553SKen Wang 0x260c, 0xffffffff, 0x00000000, 10562a37553SKen Wang 0x260d, 0xf00fffff, 0x00000400, 10662a37553SKen Wang 0x260e, 0x0002021c, 0x00020200, 10762a37553SKen Wang 0x031e, 0x00000080, 0x00000000, 10862a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 10962a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 11062a37553SKen Wang 0x16ec, 0x000000f0, 0x00000070, 11162a37553SKen Wang 0x16f0, 0x00200000, 0x50100000, 11262a37553SKen Wang 0x1c0c, 0x31000311, 0x00000011, 11362a37553SKen Wang 0x0ab9, 0x00073ffe, 0x000022a2, 11462a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 11562a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 11662a37553SKen Wang 0x22c9, 0xffffffff, 0x00ffffff, 11762a37553SKen Wang 0x22c4, 0x0000ff0f, 0x00000000, 11862a37553SKen Wang 0xa293, 0x07ffffff, 0x4e000000, 11962a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x2a00126a, 1201245a694SFlora Cui 0x000c, 0xffffffff, 0x0040, 12162a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 12262a37553SKen Wang 0x2440, 0x07ffffff, 0x03000000, 12362a37553SKen Wang 0x2418, 0x0000007f, 0x00000020, 12462a37553SKen Wang 0x2542, 0x00010000, 0x00010000, 12562a37553SKen Wang 0x2b05, 0x000003ff, 0x000000f7, 12662a37553SKen Wang 0x2b04, 0xffffffff, 0x00000000, 12762a37553SKen Wang 0x2b03, 0xffffffff, 0x32761054, 12862a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 1291245a694SFlora Cui 0x0570, 0x000c0fc0, 0x000c0400, 1301245a694SFlora Cui 0x052c, 0x0fffffff, 0xffffffff, 1311245a694SFlora Cui 0x052d, 0x0fffffff, 0x0fffffff, 1321245a694SFlora Cui 0x052e, 0x0fffffff, 0x0fffffff, 1331245a694SFlora Cui 0x052f, 0x0fffffff, 0x0fffffff 13462a37553SKen Wang }; 13562a37553SKen Wang 13662a37553SKen Wang static const u32 pitcairn_golden_rlc_registers[] = 13762a37553SKen Wang { 1381245a694SFlora Cui 0x263e, 0xffffffff, 0x12011003, 13962a37553SKen Wang 0x3109, 0xffffffff, 0x00601004, 14062a37553SKen Wang 0x311f, 0xffffffff, 0x10102020, 14162a37553SKen Wang 0x3122, 0xffffffff, 0x01000020, 14262a37553SKen Wang 0x30c5, 0xffffffff, 0x00000800, 14362a37553SKen Wang 0x30c3, 0xffffffff, 0x800000a4 14462a37553SKen Wang }; 14562a37553SKen Wang 14662a37553SKen Wang static const u32 verde_pg_init[] = 14762a37553SKen Wang { 14862a37553SKen Wang 0xd4f, 0xffffffff, 0x40000, 14962a37553SKen Wang 0xd4e, 0xffffffff, 0x200010ff, 15062a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15162a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15262a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15362a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15462a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15562a37553SKen Wang 0xd4f, 0xffffffff, 0x7007, 15662a37553SKen Wang 0xd4e, 0xffffffff, 0x300010ff, 15762a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15862a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 15962a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16062a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16162a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16262a37553SKen Wang 0xd4f, 0xffffffff, 0x400000, 16362a37553SKen Wang 0xd4e, 0xffffffff, 0x100010ff, 16462a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16562a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16662a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16762a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16862a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 16962a37553SKen Wang 0xd4f, 0xffffffff, 0x120200, 17062a37553SKen Wang 0xd4e, 0xffffffff, 0x500010ff, 17162a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 17262a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 17362a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 17462a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 17562a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 17662a37553SKen Wang 0xd4f, 0xffffffff, 0x1e1e16, 17762a37553SKen Wang 0xd4e, 0xffffffff, 0x600010ff, 17862a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 17962a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18062a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18162a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18262a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18362a37553SKen Wang 0xd4f, 0xffffffff, 0x171f1e, 18462a37553SKen Wang 0xd4e, 0xffffffff, 0x700010ff, 18562a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18662a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18762a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18862a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 18962a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 19062a37553SKen Wang 0xd4f, 0xffffffff, 0x0, 19162a37553SKen Wang 0xd4e, 0xffffffff, 0x9ff, 19262a37553SKen Wang 0xd40, 0xffffffff, 0x0, 19362a37553SKen Wang 0xd41, 0xffffffff, 0x10000800, 19462a37553SKen Wang 0xd41, 0xffffffff, 0xf, 19562a37553SKen Wang 0xd41, 0xffffffff, 0xf, 19662a37553SKen Wang 0xd40, 0xffffffff, 0x4, 19762a37553SKen Wang 0xd41, 0xffffffff, 0x1000051e, 19862a37553SKen Wang 0xd41, 0xffffffff, 0xffff, 19962a37553SKen Wang 0xd41, 0xffffffff, 0xffff, 20062a37553SKen Wang 0xd40, 0xffffffff, 0x8, 20162a37553SKen Wang 0xd41, 0xffffffff, 0x80500, 20262a37553SKen Wang 0xd40, 0xffffffff, 0x12, 20362a37553SKen Wang 0xd41, 0xffffffff, 0x9050c, 20462a37553SKen Wang 0xd40, 0xffffffff, 0x1d, 20562a37553SKen Wang 0xd41, 0xffffffff, 0xb052c, 20662a37553SKen Wang 0xd40, 0xffffffff, 0x2a, 20762a37553SKen Wang 0xd41, 0xffffffff, 0x1053e, 20862a37553SKen Wang 0xd40, 0xffffffff, 0x2d, 20962a37553SKen Wang 0xd41, 0xffffffff, 0x10546, 21062a37553SKen Wang 0xd40, 0xffffffff, 0x30, 21162a37553SKen Wang 0xd41, 0xffffffff, 0xa054e, 21262a37553SKen Wang 0xd40, 0xffffffff, 0x3c, 21362a37553SKen Wang 0xd41, 0xffffffff, 0x1055f, 21462a37553SKen Wang 0xd40, 0xffffffff, 0x3f, 21562a37553SKen Wang 0xd41, 0xffffffff, 0x10567, 21662a37553SKen Wang 0xd40, 0xffffffff, 0x42, 21762a37553SKen Wang 0xd41, 0xffffffff, 0x1056f, 21862a37553SKen Wang 0xd40, 0xffffffff, 0x45, 21962a37553SKen Wang 0xd41, 0xffffffff, 0x10572, 22062a37553SKen Wang 0xd40, 0xffffffff, 0x48, 22162a37553SKen Wang 0xd41, 0xffffffff, 0x20575, 22262a37553SKen Wang 0xd40, 0xffffffff, 0x4c, 22362a37553SKen Wang 0xd41, 0xffffffff, 0x190801, 22462a37553SKen Wang 0xd40, 0xffffffff, 0x67, 22562a37553SKen Wang 0xd41, 0xffffffff, 0x1082a, 22662a37553SKen Wang 0xd40, 0xffffffff, 0x6a, 22762a37553SKen Wang 0xd41, 0xffffffff, 0x1b082d, 22862a37553SKen Wang 0xd40, 0xffffffff, 0x87, 22962a37553SKen Wang 0xd41, 0xffffffff, 0x310851, 23062a37553SKen Wang 0xd40, 0xffffffff, 0xba, 23162a37553SKen Wang 0xd41, 0xffffffff, 0x891, 23262a37553SKen Wang 0xd40, 0xffffffff, 0xbc, 23362a37553SKen Wang 0xd41, 0xffffffff, 0x893, 23462a37553SKen Wang 0xd40, 0xffffffff, 0xbe, 23562a37553SKen Wang 0xd41, 0xffffffff, 0x20895, 23662a37553SKen Wang 0xd40, 0xffffffff, 0xc2, 23762a37553SKen Wang 0xd41, 0xffffffff, 0x20899, 23862a37553SKen Wang 0xd40, 0xffffffff, 0xc6, 23962a37553SKen Wang 0xd41, 0xffffffff, 0x2089d, 24062a37553SKen Wang 0xd40, 0xffffffff, 0xca, 24162a37553SKen Wang 0xd41, 0xffffffff, 0x8a1, 24262a37553SKen Wang 0xd40, 0xffffffff, 0xcc, 24362a37553SKen Wang 0xd41, 0xffffffff, 0x8a3, 24462a37553SKen Wang 0xd40, 0xffffffff, 0xce, 24562a37553SKen Wang 0xd41, 0xffffffff, 0x308a5, 24662a37553SKen Wang 0xd40, 0xffffffff, 0xd3, 24762a37553SKen Wang 0xd41, 0xffffffff, 0x6d08cd, 24862a37553SKen Wang 0xd40, 0xffffffff, 0x142, 24962a37553SKen Wang 0xd41, 0xffffffff, 0x2000095a, 25062a37553SKen Wang 0xd41, 0xffffffff, 0x1, 25162a37553SKen Wang 0xd40, 0xffffffff, 0x144, 25262a37553SKen Wang 0xd41, 0xffffffff, 0x301f095b, 25362a37553SKen Wang 0xd40, 0xffffffff, 0x165, 25462a37553SKen Wang 0xd41, 0xffffffff, 0xc094d, 25562a37553SKen Wang 0xd40, 0xffffffff, 0x173, 25662a37553SKen Wang 0xd41, 0xffffffff, 0xf096d, 25762a37553SKen Wang 0xd40, 0xffffffff, 0x184, 25862a37553SKen Wang 0xd41, 0xffffffff, 0x15097f, 25962a37553SKen Wang 0xd40, 0xffffffff, 0x19b, 26062a37553SKen Wang 0xd41, 0xffffffff, 0xc0998, 26162a37553SKen Wang 0xd40, 0xffffffff, 0x1a9, 26262a37553SKen Wang 0xd41, 0xffffffff, 0x409a7, 26362a37553SKen Wang 0xd40, 0xffffffff, 0x1af, 26462a37553SKen Wang 0xd41, 0xffffffff, 0xcdc, 26562a37553SKen Wang 0xd40, 0xffffffff, 0x1b1, 26662a37553SKen Wang 0xd41, 0xffffffff, 0x800, 26762a37553SKen Wang 0xd42, 0xffffffff, 0x6c9b2000, 26862a37553SKen Wang 0xd44, 0xfc00, 0x2000, 26962a37553SKen Wang 0xd51, 0xffffffff, 0xfc0, 27062a37553SKen Wang 0xa35, 0x00000100, 0x100 27162a37553SKen Wang }; 27262a37553SKen Wang 27362a37553SKen Wang static const u32 verde_golden_rlc_registers[] = 27462a37553SKen Wang { 27562a37553SKen Wang 0x3109, 0xffffffff, 0x033f1005, 27662a37553SKen Wang 0x311f, 0xffffffff, 0x10808020, 27762a37553SKen Wang 0x3122, 0xffffffff, 0x00800008, 27862a37553SKen Wang 0x30c5, 0xffffffff, 0x00001000, 27962a37553SKen Wang 0x30c3, 0xffffffff, 0x80010014 28062a37553SKen Wang }; 28162a37553SKen Wang 28262a37553SKen Wang static const u32 verde_golden_registers[] = 28362a37553SKen Wang { 28462a37553SKen Wang 0x2684, 0x00010000, 0x00018208, 28562a37553SKen Wang 0x260c, 0xffffffff, 0x00000000, 28662a37553SKen Wang 0x260d, 0xf00fffff, 0x00000400, 28762a37553SKen Wang 0x260e, 0x0002021c, 0x00020200, 28862a37553SKen Wang 0x031e, 0x00000080, 0x00000000, 28962a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 29062a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 29162a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 29262a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 29362a37553SKen Wang 0x16ec, 0x000000f0, 0x00000070, 29462a37553SKen Wang 0x16f0, 0x00200000, 0x50100000, 29562a37553SKen Wang 29662a37553SKen Wang 0x1c0c, 0x31000311, 0x00000011, 29762a37553SKen Wang 0x0ab9, 0x00073ffe, 0x000022a2, 29862a37553SKen Wang 0x0ab9, 0x00073ffe, 0x000022a2, 29962a37553SKen Wang 0x0ab9, 0x00073ffe, 0x000022a2, 30062a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 30162a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 30262a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 30362a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 30462a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 30562a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 30662a37553SKen Wang 0x2285, 0xffffffff, 0x00ffffff, 30762a37553SKen Wang 0x22c4, 0x0000ff0f, 0x00000000, 30862a37553SKen Wang 30962a37553SKen Wang 0xa293, 0x07ffffff, 0x4e000000, 31062a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x0000124a, 31162a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x0000124a, 31262a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x0000124a, 31362a37553SKen Wang 0x000c, 0x000000ff, 0x0040, 31462a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 31562a37553SKen Wang 0x2440, 0x07ffffff, 0x03000000, 31662a37553SKen Wang 0x2440, 0x07ffffff, 0x03000000, 31762a37553SKen Wang 0x23a2, 0x01ff1f3f, 0x00000000, 31862a37553SKen Wang 0x23a3, 0x01ff1f3f, 0x00000000, 31962a37553SKen Wang 0x23a2, 0x01ff1f3f, 0x00000000, 32062a37553SKen Wang 0x23a1, 0x01ff1f3f, 0x00000000, 32162a37553SKen Wang 0x23a1, 0x01ff1f3f, 0x00000000, 32262a37553SKen Wang 32362a37553SKen Wang 0x23a1, 0x01ff1f3f, 0x00000000, 32462a37553SKen Wang 0x2418, 0x0000007f, 0x00000020, 32562a37553SKen Wang 0x2542, 0x00010000, 0x00010000, 32662a37553SKen Wang 0x2b01, 0x000003ff, 0x00000003, 32762a37553SKen Wang 0x2b05, 0x000003ff, 0x00000003, 32862a37553SKen Wang 0x2b05, 0x000003ff, 0x00000003, 32962a37553SKen Wang 0x2b04, 0xffffffff, 0x00000000, 33062a37553SKen Wang 0x2b04, 0xffffffff, 0x00000000, 33162a37553SKen Wang 0x2b04, 0xffffffff, 0x00000000, 33262a37553SKen Wang 0x2b03, 0xffffffff, 0x00001032, 33362a37553SKen Wang 0x2b03, 0xffffffff, 0x00001032, 33462a37553SKen Wang 0x2b03, 0xffffffff, 0x00001032, 33562a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 33662a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 33762a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 33862a37553SKen Wang 0x0570, 0x000c0fc0, 0x000c0400 33962a37553SKen Wang }; 34062a37553SKen Wang 34162a37553SKen Wang static const u32 oland_golden_registers[] = 34262a37553SKen Wang { 343*6b7985efSFlora Cui 0x17bc, 0x00000030, 0x00000011, 34462a37553SKen Wang 0x2684, 0x00010000, 0x00018208, 34562a37553SKen Wang 0x260c, 0xffffffff, 0x00000000, 34662a37553SKen Wang 0x260d, 0xf00fffff, 0x00000400, 34762a37553SKen Wang 0x260e, 0x0002021c, 0x00020200, 34862a37553SKen Wang 0x031e, 0x00000080, 0x00000000, 34962a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 35062a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 35162a37553SKen Wang 0x16ec, 0x000000f0, 0x00000070, 352*6b7985efSFlora Cui 0x16f0, 0x00200000, 0x50100000, 35362a37553SKen Wang 0x1c0c, 0x31000311, 0x00000011, 35462a37553SKen Wang 0x0ab9, 0x00073ffe, 0x000022a2, 35562a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 35662a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 35762a37553SKen Wang 0x22c9, 0xffffffff, 0x00ffffff, 35862a37553SKen Wang 0x22c4, 0x0000ff0f, 0x00000000, 35962a37553SKen Wang 0xa293, 0x07ffffff, 0x4e000000, 36062a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x00000082, 361*6b7985efSFlora Cui 0x000c, 0xffffffff, 0x0040, 36262a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 36362a37553SKen Wang 0x2440, 0x07ffffff, 0x03000000, 36462a37553SKen Wang 0x2418, 0x0000007f, 0x00000020, 36562a37553SKen Wang 0x2542, 0x00010000, 0x00010000, 36662a37553SKen Wang 0x2b05, 0x000003ff, 0x000000f3, 36762a37553SKen Wang 0x2b04, 0xffffffff, 0x00000000, 36862a37553SKen Wang 0x2b03, 0xffffffff, 0x00003210, 36962a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 370*6b7985efSFlora Cui 0x0570, 0x000c0fc0, 0x000c0400, 371*6b7985efSFlora Cui 0x052c, 0x0fffffff, 0xffffffff, 372*6b7985efSFlora Cui 0x052d, 0x0fffffff, 0x0fffffff, 373*6b7985efSFlora Cui 0x052e, 0x0fffffff, 0x0fffffff, 374*6b7985efSFlora Cui 0x052f, 0x0fffffff, 0x0fffffff 37562a37553SKen Wang }; 37662a37553SKen Wang 37762a37553SKen Wang static const u32 oland_golden_rlc_registers[] = 37862a37553SKen Wang { 379*6b7985efSFlora Cui 0x263e, 0xffffffff, 0x02010002, 38062a37553SKen Wang 0x3109, 0xffffffff, 0x00601005, 38162a37553SKen Wang 0x311f, 0xffffffff, 0x10104040, 38262a37553SKen Wang 0x3122, 0xffffffff, 0x0100000a, 38362a37553SKen Wang 0x30c5, 0xffffffff, 0x00000800, 38462a37553SKen Wang 0x30c3, 0xffffffff, 0x800000f4 38562a37553SKen Wang }; 38662a37553SKen Wang 38762a37553SKen Wang static const u32 hainan_golden_registers[] = 38862a37553SKen Wang { 389bd27b678SFlora Cui 0x17bc, 0x00000030, 0x00000011, 39062a37553SKen Wang 0x2684, 0x00010000, 0x00018208, 39162a37553SKen Wang 0x260c, 0xffffffff, 0x00000000, 39262a37553SKen Wang 0x260d, 0xf00fffff, 0x00000400, 39362a37553SKen Wang 0x260e, 0x0002021c, 0x00020200, 394bd27b678SFlora Cui 0x031e, 0x00000080, 0x00000000, 395bd27b678SFlora Cui 0x3430, 0xff000fff, 0x00000100, 39662a37553SKen Wang 0x340c, 0x000300c0, 0x00800040, 39762a37553SKen Wang 0x3630, 0xff000fff, 0x00000100, 39862a37553SKen Wang 0x360c, 0x000300c0, 0x00800040, 399bd27b678SFlora Cui 0x16ec, 0x000000f0, 0x00000070, 400bd27b678SFlora Cui 0x16f0, 0x00200000, 0x50100000, 401bd27b678SFlora Cui 0x1c0c, 0x31000311, 0x00000011, 40262a37553SKen Wang 0x0ab9, 0x00073ffe, 0x000022a2, 40362a37553SKen Wang 0x0903, 0x000007ff, 0x00000000, 40462a37553SKen Wang 0x2285, 0xf000001f, 0x00000007, 40562a37553SKen Wang 0x22c9, 0xffffffff, 0x00ffffff, 40662a37553SKen Wang 0x22c4, 0x0000ff0f, 0x00000000, 407bd27b678SFlora Cui 0xa293, 0x07ffffff, 0x4e000000, 40862a37553SKen Wang 0xa0d4, 0x3f3f3fff, 0x00000000, 409bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0040, 41062a37553SKen Wang 0x000d, 0x00000040, 0x00004040, 41162a37553SKen Wang 0x2440, 0x03e00000, 0x03600000, 41262a37553SKen Wang 0x2418, 0x0000007f, 0x00000020, 41362a37553SKen Wang 0x2542, 0x00010000, 0x00010000, 41462a37553SKen Wang 0x2b05, 0x000003ff, 0x000000f1, 41562a37553SKen Wang 0x2b04, 0xffffffff, 0x00000000, 41662a37553SKen Wang 0x2b03, 0xffffffff, 0x00003210, 41762a37553SKen Wang 0x2235, 0x0000001f, 0x00000010, 418bd27b678SFlora Cui 0x0570, 0x000c0fc0, 0x000c0400, 419bd27b678SFlora Cui 0x052c, 0x0fffffff, 0xffffffff, 420bd27b678SFlora Cui 0x052d, 0x0fffffff, 0x0fffffff, 421bd27b678SFlora Cui 0x052e, 0x0fffffff, 0x0fffffff, 422bd27b678SFlora Cui 0x052f, 0x0fffffff, 0x0fffffff 42362a37553SKen Wang }; 42462a37553SKen Wang 42562a37553SKen Wang static const u32 hainan_golden_registers2[] = 42662a37553SKen Wang { 427bd27b678SFlora Cui 0x263e, 0xffffffff, 0x2011003 42862a37553SKen Wang }; 42962a37553SKen Wang 43062a37553SKen Wang static const u32 tahiti_mgcg_cgcg_init[] = 43162a37553SKen Wang { 43262a37553SKen Wang 0x3100, 0xffffffff, 0xfffffffc, 43362a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 43462a37553SKen Wang 0x2698, 0xffffffff, 0x00000100, 43562a37553SKen Wang 0x24a9, 0xffffffff, 0x00000100, 43662a37553SKen Wang 0x3059, 0xffffffff, 0x00000100, 43762a37553SKen Wang 0x25dd, 0xffffffff, 0x00000100, 43862a37553SKen Wang 0x2261, 0xffffffff, 0x06000100, 43962a37553SKen Wang 0x2286, 0xffffffff, 0x00000100, 44062a37553SKen Wang 0x24a8, 0xffffffff, 0x00000100, 44162a37553SKen Wang 0x30e0, 0xffffffff, 0x00000100, 44262a37553SKen Wang 0x22ca, 0xffffffff, 0x00000100, 44362a37553SKen Wang 0x2451, 0xffffffff, 0x00000100, 44462a37553SKen Wang 0x2362, 0xffffffff, 0x00000100, 44562a37553SKen Wang 0x2363, 0xffffffff, 0x00000100, 44662a37553SKen Wang 0x240c, 0xffffffff, 0x00000100, 44762a37553SKen Wang 0x240d, 0xffffffff, 0x00000100, 44862a37553SKen Wang 0x240e, 0xffffffff, 0x00000100, 44962a37553SKen Wang 0x240f, 0xffffffff, 0x00000100, 45062a37553SKen Wang 0x2b60, 0xffffffff, 0x00000100, 45162a37553SKen Wang 0x2b15, 0xffffffff, 0x00000100, 45262a37553SKen Wang 0x225f, 0xffffffff, 0x06000100, 45362a37553SKen Wang 0x261a, 0xffffffff, 0x00000100, 45462a37553SKen Wang 0x2544, 0xffffffff, 0x00000100, 45562a37553SKen Wang 0x2bc1, 0xffffffff, 0x00000100, 45662a37553SKen Wang 0x2b81, 0xffffffff, 0x00000100, 45762a37553SKen Wang 0x2527, 0xffffffff, 0x00000100, 45862a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 45962a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 46062a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 46162a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 46262a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 46362a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 46462a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 46562a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 46662a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 46762a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 46862a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 46962a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 47062a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 47162a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 47262a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 47362a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 47462a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 47562a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 47662a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 47762a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 47862a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 47962a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 48062a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 48162a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 48262a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 48362a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 48462a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 48562a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 48662a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 48762a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 48862a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 48962a37553SKen Wang 0x2476, 0xffffffff, 0x00070006, 49062a37553SKen Wang 0x2477, 0xffffffff, 0x00090008, 49162a37553SKen Wang 0x2478, 0xffffffff, 0x0000000c, 49262a37553SKen Wang 0x2479, 0xffffffff, 0x000b000a, 49362a37553SKen Wang 0x247a, 0xffffffff, 0x000e000d, 49462a37553SKen Wang 0x247b, 0xffffffff, 0x00080007, 49562a37553SKen Wang 0x247c, 0xffffffff, 0x000a0009, 49662a37553SKen Wang 0x247d, 0xffffffff, 0x0000000d, 49762a37553SKen Wang 0x247e, 0xffffffff, 0x000c000b, 49862a37553SKen Wang 0x247f, 0xffffffff, 0x000f000e, 49962a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 50062a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 50162a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 50262a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 50362a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 50462a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 50562a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 50662a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 50762a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 50862a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 50962a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 51062a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 51162a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 51262a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 51362a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 51462a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 51562a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 51662a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 51762a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 51862a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 51962a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 52062a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 52162a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 52262a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 52362a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 52462a37553SKen Wang 0x2499, 0xffffffff, 0x000e000d, 52562a37553SKen Wang 0x249a, 0xffffffff, 0x0010000f, 52662a37553SKen Wang 0x249b, 0xffffffff, 0x00000013, 52762a37553SKen Wang 0x249c, 0xffffffff, 0x00120011, 52862a37553SKen Wang 0x249d, 0xffffffff, 0x00150014, 52962a37553SKen Wang 0x249e, 0xffffffff, 0x000f000e, 53062a37553SKen Wang 0x249f, 0xffffffff, 0x00110010, 53162a37553SKen Wang 0x24a0, 0xffffffff, 0x00000014, 53262a37553SKen Wang 0x24a1, 0xffffffff, 0x00130012, 53362a37553SKen Wang 0x24a2, 0xffffffff, 0x00160015, 53462a37553SKen Wang 0x24a3, 0xffffffff, 0x0010000f, 53562a37553SKen Wang 0x24a4, 0xffffffff, 0x00120011, 53662a37553SKen Wang 0x24a5, 0xffffffff, 0x00000015, 53762a37553SKen Wang 0x24a6, 0xffffffff, 0x00140013, 53862a37553SKen Wang 0x24a7, 0xffffffff, 0x00170016, 53962a37553SKen Wang 0x2454, 0xffffffff, 0x96940200, 54062a37553SKen Wang 0x21c2, 0xffffffff, 0x00900100, 54162a37553SKen Wang 0x311e, 0xffffffff, 0x00000080, 54262a37553SKen Wang 0x3101, 0xffffffff, 0x0020003f, 5437c0a705eSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 5447c0a705eSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 5457c0a705eSFlora Cui 0x0583, 0xffffffff, 0x00000100, 5467c0a705eSFlora Cui 0x0409, 0xffffffff, 0x00000100, 5477c0a705eSFlora Cui 0x040b, 0x00000101, 0x00000000, 5487c0a705eSFlora Cui 0x082a, 0xffffffff, 0x00000104, 5497c0a705eSFlora Cui 0x0993, 0x000c0000, 0x000c0000, 5507c0a705eSFlora Cui 0x0992, 0x000c0000, 0x000c0000, 55162a37553SKen Wang 0x1579, 0xff000fff, 0x00000100, 55262a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 5537c0a705eSFlora Cui 0x0bd4, 0x00000001, 0x00000001, 5547c0a705eSFlora Cui 0x0c33, 0xc0000fff, 0x00000104, 55562a37553SKen Wang 0x3079, 0x00000001, 0x00000001, 55662a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 55762a37553SKen Wang 0x3630, 0xfffffff0, 0x00000100 55862a37553SKen Wang }; 55962a37553SKen Wang static const u32 pitcairn_mgcg_cgcg_init[] = 56062a37553SKen Wang { 56162a37553SKen Wang 0x3100, 0xffffffff, 0xfffffffc, 56262a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 56362a37553SKen Wang 0x2698, 0xffffffff, 0x00000100, 56462a37553SKen Wang 0x24a9, 0xffffffff, 0x00000100, 56562a37553SKen Wang 0x3059, 0xffffffff, 0x00000100, 56662a37553SKen Wang 0x25dd, 0xffffffff, 0x00000100, 56762a37553SKen Wang 0x2261, 0xffffffff, 0x06000100, 56862a37553SKen Wang 0x2286, 0xffffffff, 0x00000100, 56962a37553SKen Wang 0x24a8, 0xffffffff, 0x00000100, 57062a37553SKen Wang 0x30e0, 0xffffffff, 0x00000100, 57162a37553SKen Wang 0x22ca, 0xffffffff, 0x00000100, 57262a37553SKen Wang 0x2451, 0xffffffff, 0x00000100, 57362a37553SKen Wang 0x2362, 0xffffffff, 0x00000100, 57462a37553SKen Wang 0x2363, 0xffffffff, 0x00000100, 57562a37553SKen Wang 0x240c, 0xffffffff, 0x00000100, 57662a37553SKen Wang 0x240d, 0xffffffff, 0x00000100, 57762a37553SKen Wang 0x240e, 0xffffffff, 0x00000100, 57862a37553SKen Wang 0x240f, 0xffffffff, 0x00000100, 57962a37553SKen Wang 0x2b60, 0xffffffff, 0x00000100, 58062a37553SKen Wang 0x2b15, 0xffffffff, 0x00000100, 58162a37553SKen Wang 0x225f, 0xffffffff, 0x06000100, 58262a37553SKen Wang 0x261a, 0xffffffff, 0x00000100, 58362a37553SKen Wang 0x2544, 0xffffffff, 0x00000100, 58462a37553SKen Wang 0x2bc1, 0xffffffff, 0x00000100, 58562a37553SKen Wang 0x2b81, 0xffffffff, 0x00000100, 58662a37553SKen Wang 0x2527, 0xffffffff, 0x00000100, 58762a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 58862a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 58962a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 59062a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 59162a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 59262a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 59362a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 59462a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 59562a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 59662a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 59762a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 59862a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 59962a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 60062a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 60162a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 60262a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 60362a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 60462a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 60562a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 60662a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 60762a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 60862a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 60962a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 61062a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 61162a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 61262a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 61362a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 61462a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 61562a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 61662a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 61762a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 61862a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 61962a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 62062a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 62162a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 62262a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 62362a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 62462a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 62562a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 62662a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 62762a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 62862a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 62962a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 63062a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 63162a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 63262a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 63362a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 63462a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 63562a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 63662a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 63762a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 63862a37553SKen Wang 0x2454, 0xffffffff, 0x96940200, 63962a37553SKen Wang 0x21c2, 0xffffffff, 0x00900100, 64062a37553SKen Wang 0x311e, 0xffffffff, 0x00000080, 64162a37553SKen Wang 0x3101, 0xffffffff, 0x0020003f, 6421245a694SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 6431245a694SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 6441245a694SFlora Cui 0x0583, 0xffffffff, 0x00000100, 6451245a694SFlora Cui 0x0409, 0xffffffff, 0x00000100, 6461245a694SFlora Cui 0x040b, 0x00000101, 0x00000000, 6471245a694SFlora Cui 0x082a, 0xffffffff, 0x00000104, 64862a37553SKen Wang 0x1579, 0xff000fff, 0x00000100, 64962a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 6501245a694SFlora Cui 0x0bd4, 0x00000001, 0x00000001, 6511245a694SFlora Cui 0x0c33, 0xc0000fff, 0x00000104, 65262a37553SKen Wang 0x3079, 0x00000001, 0x00000001, 65362a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 65462a37553SKen Wang 0x3630, 0xfffffff0, 0x00000100 65562a37553SKen Wang }; 65662a37553SKen Wang static const u32 verde_mgcg_cgcg_init[] = 65762a37553SKen Wang { 65862a37553SKen Wang 0x3100, 0xffffffff, 0xfffffffc, 65962a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 66062a37553SKen Wang 0x2698, 0xffffffff, 0x00000100, 66162a37553SKen Wang 0x24a9, 0xffffffff, 0x00000100, 66262a37553SKen Wang 0x3059, 0xffffffff, 0x00000100, 66362a37553SKen Wang 0x25dd, 0xffffffff, 0x00000100, 66462a37553SKen Wang 0x2261, 0xffffffff, 0x06000100, 66562a37553SKen Wang 0x2286, 0xffffffff, 0x00000100, 66662a37553SKen Wang 0x24a8, 0xffffffff, 0x00000100, 66762a37553SKen Wang 0x30e0, 0xffffffff, 0x00000100, 66862a37553SKen Wang 0x22ca, 0xffffffff, 0x00000100, 66962a37553SKen Wang 0x2451, 0xffffffff, 0x00000100, 67062a37553SKen Wang 0x2362, 0xffffffff, 0x00000100, 67162a37553SKen Wang 0x2363, 0xffffffff, 0x00000100, 67262a37553SKen Wang 0x240c, 0xffffffff, 0x00000100, 67362a37553SKen Wang 0x240d, 0xffffffff, 0x00000100, 67462a37553SKen Wang 0x240e, 0xffffffff, 0x00000100, 67562a37553SKen Wang 0x240f, 0xffffffff, 0x00000100, 67662a37553SKen Wang 0x2b60, 0xffffffff, 0x00000100, 67762a37553SKen Wang 0x2b15, 0xffffffff, 0x00000100, 67862a37553SKen Wang 0x225f, 0xffffffff, 0x06000100, 67962a37553SKen Wang 0x261a, 0xffffffff, 0x00000100, 68062a37553SKen Wang 0x2544, 0xffffffff, 0x00000100, 68162a37553SKen Wang 0x2bc1, 0xffffffff, 0x00000100, 68262a37553SKen Wang 0x2b81, 0xffffffff, 0x00000100, 68362a37553SKen Wang 0x2527, 0xffffffff, 0x00000100, 68462a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 68562a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 68662a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 68762a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 68862a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 68962a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 69062a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 69162a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 69262a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 69362a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 69462a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 69562a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 69662a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 69762a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 69862a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 69962a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 70062a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 70162a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 70262a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 70362a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 70462a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 70562a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 70662a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 70762a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 70862a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 70962a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 71062a37553SKen Wang 0x2480, 0xffffffff, 0x00090008, 71162a37553SKen Wang 0x2481, 0xffffffff, 0x000b000a, 71262a37553SKen Wang 0x2482, 0xffffffff, 0x000c000f, 71362a37553SKen Wang 0x2483, 0xffffffff, 0x000e000d, 71462a37553SKen Wang 0x2484, 0xffffffff, 0x00110010, 71562a37553SKen Wang 0x2485, 0xffffffff, 0x000a0009, 71662a37553SKen Wang 0x2486, 0xffffffff, 0x000c000b, 71762a37553SKen Wang 0x2487, 0xffffffff, 0x0000000f, 71862a37553SKen Wang 0x2488, 0xffffffff, 0x000e000d, 71962a37553SKen Wang 0x2489, 0xffffffff, 0x00110010, 72062a37553SKen Wang 0x248a, 0xffffffff, 0x000b000a, 72162a37553SKen Wang 0x248b, 0xffffffff, 0x000d000c, 72262a37553SKen Wang 0x248c, 0xffffffff, 0x00000010, 72362a37553SKen Wang 0x248d, 0xffffffff, 0x000f000e, 72462a37553SKen Wang 0x248e, 0xffffffff, 0x00120011, 72562a37553SKen Wang 0x248f, 0xffffffff, 0x000c000b, 72662a37553SKen Wang 0x2490, 0xffffffff, 0x000e000d, 72762a37553SKen Wang 0x2491, 0xffffffff, 0x00000011, 72862a37553SKen Wang 0x2492, 0xffffffff, 0x0010000f, 72962a37553SKen Wang 0x2493, 0xffffffff, 0x00130012, 73062a37553SKen Wang 0x2494, 0xffffffff, 0x000d000c, 73162a37553SKen Wang 0x2495, 0xffffffff, 0x000f000e, 73262a37553SKen Wang 0x2496, 0xffffffff, 0x00100013, 73362a37553SKen Wang 0x2497, 0xffffffff, 0x00120011, 73462a37553SKen Wang 0x2498, 0xffffffff, 0x00150014, 73562a37553SKen Wang 0x2454, 0xffffffff, 0x96940200, 73662a37553SKen Wang 0x21c2, 0xffffffff, 0x00900100, 73762a37553SKen Wang 0x311e, 0xffffffff, 0x00000080, 73862a37553SKen Wang 0x3101, 0xffffffff, 0x0020003f, 73962a37553SKen Wang 0xc, 0xffffffff, 0x0000001c, 74062a37553SKen Wang 0xd, 0x000f0000, 0x000f0000, 74162a37553SKen Wang 0x583, 0xffffffff, 0x00000100, 74262a37553SKen Wang 0x409, 0xffffffff, 0x00000100, 74362a37553SKen Wang 0x40b, 0x00000101, 0x00000000, 74462a37553SKen Wang 0x82a, 0xffffffff, 0x00000104, 74562a37553SKen Wang 0x993, 0x000c0000, 0x000c0000, 74662a37553SKen Wang 0x992, 0x000c0000, 0x000c0000, 74762a37553SKen Wang 0x1579, 0xff000fff, 0x00000100, 74862a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 74962a37553SKen Wang 0xbd4, 0x00000001, 0x00000001, 75062a37553SKen Wang 0xc33, 0xc0000fff, 0x00000104, 75162a37553SKen Wang 0x3079, 0x00000001, 0x00000001, 75262a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 75362a37553SKen Wang 0x3630, 0xfffffff0, 0x00000100 75462a37553SKen Wang }; 75562a37553SKen Wang static const u32 oland_mgcg_cgcg_init[] = 75662a37553SKen Wang { 75762a37553SKen Wang 0x3100, 0xffffffff, 0xfffffffc, 75862a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 75962a37553SKen Wang 0x2698, 0xffffffff, 0x00000100, 76062a37553SKen Wang 0x24a9, 0xffffffff, 0x00000100, 76162a37553SKen Wang 0x3059, 0xffffffff, 0x00000100, 76262a37553SKen Wang 0x25dd, 0xffffffff, 0x00000100, 76362a37553SKen Wang 0x2261, 0xffffffff, 0x06000100, 76462a37553SKen Wang 0x2286, 0xffffffff, 0x00000100, 76562a37553SKen Wang 0x24a8, 0xffffffff, 0x00000100, 76662a37553SKen Wang 0x30e0, 0xffffffff, 0x00000100, 76762a37553SKen Wang 0x22ca, 0xffffffff, 0x00000100, 76862a37553SKen Wang 0x2451, 0xffffffff, 0x00000100, 76962a37553SKen Wang 0x2362, 0xffffffff, 0x00000100, 77062a37553SKen Wang 0x2363, 0xffffffff, 0x00000100, 77162a37553SKen Wang 0x240c, 0xffffffff, 0x00000100, 77262a37553SKen Wang 0x240d, 0xffffffff, 0x00000100, 77362a37553SKen Wang 0x240e, 0xffffffff, 0x00000100, 77462a37553SKen Wang 0x240f, 0xffffffff, 0x00000100, 77562a37553SKen Wang 0x2b60, 0xffffffff, 0x00000100, 77662a37553SKen Wang 0x2b15, 0xffffffff, 0x00000100, 77762a37553SKen Wang 0x225f, 0xffffffff, 0x06000100, 77862a37553SKen Wang 0x261a, 0xffffffff, 0x00000100, 77962a37553SKen Wang 0x2544, 0xffffffff, 0x00000100, 78062a37553SKen Wang 0x2bc1, 0xffffffff, 0x00000100, 78162a37553SKen Wang 0x2b81, 0xffffffff, 0x00000100, 78262a37553SKen Wang 0x2527, 0xffffffff, 0x00000100, 78362a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 78462a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 78562a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 78662a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 78762a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 78862a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 78962a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 79062a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 79162a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 79262a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 79362a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 79462a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 79562a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 79662a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 79762a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 79862a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 79962a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 80062a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 80162a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 80262a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 80362a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 80462a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 80562a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 80662a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 80762a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 80862a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 80962a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 81062a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 81162a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 81262a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 81362a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 81462a37553SKen Wang 0x2454, 0xffffffff, 0x96940200, 81562a37553SKen Wang 0x21c2, 0xffffffff, 0x00900100, 81662a37553SKen Wang 0x311e, 0xffffffff, 0x00000080, 81762a37553SKen Wang 0x3101, 0xffffffff, 0x0020003f, 818*6b7985efSFlora Cui 0x000c, 0xffffffff, 0x0000001c, 819*6b7985efSFlora Cui 0x000d, 0x000f0000, 0x000f0000, 820*6b7985efSFlora Cui 0x0583, 0xffffffff, 0x00000100, 821*6b7985efSFlora Cui 0x0409, 0xffffffff, 0x00000100, 822*6b7985efSFlora Cui 0x040b, 0x00000101, 0x00000000, 823*6b7985efSFlora Cui 0x082a, 0xffffffff, 0x00000104, 824*6b7985efSFlora Cui 0x0993, 0x000c0000, 0x000c0000, 825*6b7985efSFlora Cui 0x0992, 0x000c0000, 0x000c0000, 82662a37553SKen Wang 0x1579, 0xff000fff, 0x00000100, 82762a37553SKen Wang 0x157a, 0x00000001, 0x00000001, 828*6b7985efSFlora Cui 0x0bd4, 0x00000001, 0x00000001, 829*6b7985efSFlora Cui 0x0c33, 0xc0000fff, 0x00000104, 83062a37553SKen Wang 0x3079, 0x00000001, 0x00000001, 83162a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 83262a37553SKen Wang 0x3630, 0xfffffff0, 0x00000100 83362a37553SKen Wang }; 83462a37553SKen Wang static const u32 hainan_mgcg_cgcg_init[] = 83562a37553SKen Wang { 83662a37553SKen Wang 0x3100, 0xffffffff, 0xfffffffc, 83762a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 83862a37553SKen Wang 0x2698, 0xffffffff, 0x00000100, 83962a37553SKen Wang 0x24a9, 0xffffffff, 0x00000100, 84062a37553SKen Wang 0x3059, 0xffffffff, 0x00000100, 84162a37553SKen Wang 0x25dd, 0xffffffff, 0x00000100, 84262a37553SKen Wang 0x2261, 0xffffffff, 0x06000100, 84362a37553SKen Wang 0x2286, 0xffffffff, 0x00000100, 84462a37553SKen Wang 0x24a8, 0xffffffff, 0x00000100, 84562a37553SKen Wang 0x30e0, 0xffffffff, 0x00000100, 84662a37553SKen Wang 0x22ca, 0xffffffff, 0x00000100, 84762a37553SKen Wang 0x2451, 0xffffffff, 0x00000100, 84862a37553SKen Wang 0x2362, 0xffffffff, 0x00000100, 84962a37553SKen Wang 0x2363, 0xffffffff, 0x00000100, 85062a37553SKen Wang 0x240c, 0xffffffff, 0x00000100, 85162a37553SKen Wang 0x240d, 0xffffffff, 0x00000100, 85262a37553SKen Wang 0x240e, 0xffffffff, 0x00000100, 85362a37553SKen Wang 0x240f, 0xffffffff, 0x00000100, 85462a37553SKen Wang 0x2b60, 0xffffffff, 0x00000100, 85562a37553SKen Wang 0x2b15, 0xffffffff, 0x00000100, 85662a37553SKen Wang 0x225f, 0xffffffff, 0x06000100, 85762a37553SKen Wang 0x261a, 0xffffffff, 0x00000100, 85862a37553SKen Wang 0x2544, 0xffffffff, 0x00000100, 85962a37553SKen Wang 0x2bc1, 0xffffffff, 0x00000100, 86062a37553SKen Wang 0x2b81, 0xffffffff, 0x00000100, 86162a37553SKen Wang 0x2527, 0xffffffff, 0x00000100, 86262a37553SKen Wang 0x200b, 0xffffffff, 0xe0000000, 86362a37553SKen Wang 0x2458, 0xffffffff, 0x00010000, 86462a37553SKen Wang 0x2459, 0xffffffff, 0x00030002, 86562a37553SKen Wang 0x245a, 0xffffffff, 0x00040007, 86662a37553SKen Wang 0x245b, 0xffffffff, 0x00060005, 86762a37553SKen Wang 0x245c, 0xffffffff, 0x00090008, 86862a37553SKen Wang 0x245d, 0xffffffff, 0x00020001, 86962a37553SKen Wang 0x245e, 0xffffffff, 0x00040003, 87062a37553SKen Wang 0x245f, 0xffffffff, 0x00000007, 87162a37553SKen Wang 0x2460, 0xffffffff, 0x00060005, 87262a37553SKen Wang 0x2461, 0xffffffff, 0x00090008, 87362a37553SKen Wang 0x2462, 0xffffffff, 0x00030002, 87462a37553SKen Wang 0x2463, 0xffffffff, 0x00050004, 87562a37553SKen Wang 0x2464, 0xffffffff, 0x00000008, 87662a37553SKen Wang 0x2465, 0xffffffff, 0x00070006, 87762a37553SKen Wang 0x2466, 0xffffffff, 0x000a0009, 87862a37553SKen Wang 0x2467, 0xffffffff, 0x00040003, 87962a37553SKen Wang 0x2468, 0xffffffff, 0x00060005, 88062a37553SKen Wang 0x2469, 0xffffffff, 0x00000009, 88162a37553SKen Wang 0x246a, 0xffffffff, 0x00080007, 88262a37553SKen Wang 0x246b, 0xffffffff, 0x000b000a, 88362a37553SKen Wang 0x246c, 0xffffffff, 0x00050004, 88462a37553SKen Wang 0x246d, 0xffffffff, 0x00070006, 88562a37553SKen Wang 0x246e, 0xffffffff, 0x0008000b, 88662a37553SKen Wang 0x246f, 0xffffffff, 0x000a0009, 88762a37553SKen Wang 0x2470, 0xffffffff, 0x000d000c, 88862a37553SKen Wang 0x2471, 0xffffffff, 0x00060005, 88962a37553SKen Wang 0x2472, 0xffffffff, 0x00080007, 89062a37553SKen Wang 0x2473, 0xffffffff, 0x0000000b, 89162a37553SKen Wang 0x2474, 0xffffffff, 0x000a0009, 89262a37553SKen Wang 0x2475, 0xffffffff, 0x000d000c, 89362a37553SKen Wang 0x2454, 0xffffffff, 0x96940200, 89462a37553SKen Wang 0x21c2, 0xffffffff, 0x00900100, 89562a37553SKen Wang 0x311e, 0xffffffff, 0x00000080, 89662a37553SKen Wang 0x3101, 0xffffffff, 0x0020003f, 897bd27b678SFlora Cui 0x000c, 0xffffffff, 0x0000001c, 898bd27b678SFlora Cui 0x000d, 0x000f0000, 0x000f0000, 899bd27b678SFlora Cui 0x0583, 0xffffffff, 0x00000100, 900bd27b678SFlora Cui 0x0409, 0xffffffff, 0x00000100, 901bd27b678SFlora Cui 0x082a, 0xffffffff, 0x00000104, 902bd27b678SFlora Cui 0x0993, 0x000c0000, 0x000c0000, 903bd27b678SFlora Cui 0x0992, 0x000c0000, 0x000c0000, 904bd27b678SFlora Cui 0x0bd4, 0x00000001, 0x00000001, 905bd27b678SFlora Cui 0x0c33, 0xc0000fff, 0x00000104, 90662a37553SKen Wang 0x3079, 0x00000001, 0x00000001, 90762a37553SKen Wang 0x3430, 0xfffffff0, 0x00000100, 90862a37553SKen Wang 0x3630, 0xfffffff0, 0x00000100 90962a37553SKen Wang }; 91062a37553SKen Wang 91162a37553SKen Wang static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg) 91262a37553SKen Wang { 91362a37553SKen Wang unsigned long flags; 91462a37553SKen Wang u32 r; 91562a37553SKen Wang 91662a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 91762a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 91862a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 91962a37553SKen Wang r = RREG32(AMDGPU_PCIE_DATA); 92062a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 92162a37553SKen Wang return r; 92262a37553SKen Wang } 92362a37553SKen Wang 92462a37553SKen Wang static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 92562a37553SKen Wang { 92662a37553SKen Wang unsigned long flags; 92762a37553SKen Wang 92862a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 92962a37553SKen Wang WREG32(AMDGPU_PCIE_INDEX, reg); 93062a37553SKen Wang (void)RREG32(AMDGPU_PCIE_INDEX); 93162a37553SKen Wang WREG32(AMDGPU_PCIE_DATA, v); 93262a37553SKen Wang (void)RREG32(AMDGPU_PCIE_DATA); 93362a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 93462a37553SKen Wang } 93562a37553SKen Wang 936d1936cc2SBaoyou Xie static u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) 93736b9a952SHuang Rui { 93836b9a952SHuang Rui unsigned long flags; 93936b9a952SHuang Rui u32 r; 94036b9a952SHuang Rui 94136b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 94236b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 94336b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 94436b9a952SHuang Rui r = RREG32(PCIE_PORT_DATA); 94536b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 94636b9a952SHuang Rui return r; 94736b9a952SHuang Rui } 94836b9a952SHuang Rui 949d1936cc2SBaoyou Xie static void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 95036b9a952SHuang Rui { 95136b9a952SHuang Rui unsigned long flags; 95236b9a952SHuang Rui 95336b9a952SHuang Rui spin_lock_irqsave(&adev->pcie_idx_lock, flags); 95436b9a952SHuang Rui WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 95536b9a952SHuang Rui (void)RREG32(PCIE_PORT_INDEX); 95636b9a952SHuang Rui WREG32(PCIE_PORT_DATA, (v)); 95736b9a952SHuang Rui (void)RREG32(PCIE_PORT_DATA); 95836b9a952SHuang Rui spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 95936b9a952SHuang Rui } 96036b9a952SHuang Rui 96162a37553SKen Wang static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) 96262a37553SKen Wang { 96362a37553SKen Wang unsigned long flags; 96462a37553SKen Wang u32 r; 96562a37553SKen Wang 96662a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 96762a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 96862a37553SKen Wang r = RREG32(SMC_IND_DATA_0); 96962a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 97062a37553SKen Wang return r; 97162a37553SKen Wang } 97262a37553SKen Wang 97362a37553SKen Wang static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 97462a37553SKen Wang { 97562a37553SKen Wang unsigned long flags; 97662a37553SKen Wang 97762a37553SKen Wang spin_lock_irqsave(&adev->smc_idx_lock, flags); 97862a37553SKen Wang WREG32(SMC_IND_INDEX_0, (reg)); 97962a37553SKen Wang WREG32(SMC_IND_DATA_0, (v)); 98062a37553SKen Wang spin_unlock_irqrestore(&adev->smc_idx_lock, flags); 98162a37553SKen Wang } 98262a37553SKen Wang 98362a37553SKen Wang static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = { 98462a37553SKen Wang {GRBM_STATUS, false}, 98562a37553SKen Wang {GB_ADDR_CONFIG, false}, 98662a37553SKen Wang {MC_ARB_RAMCFG, false}, 98762a37553SKen Wang {GB_TILE_MODE0, false}, 98862a37553SKen Wang {GB_TILE_MODE1, false}, 98962a37553SKen Wang {GB_TILE_MODE2, false}, 99062a37553SKen Wang {GB_TILE_MODE3, false}, 99162a37553SKen Wang {GB_TILE_MODE4, false}, 99262a37553SKen Wang {GB_TILE_MODE5, false}, 99362a37553SKen Wang {GB_TILE_MODE6, false}, 99462a37553SKen Wang {GB_TILE_MODE7, false}, 99562a37553SKen Wang {GB_TILE_MODE8, false}, 99662a37553SKen Wang {GB_TILE_MODE9, false}, 99762a37553SKen Wang {GB_TILE_MODE10, false}, 99862a37553SKen Wang {GB_TILE_MODE11, false}, 99962a37553SKen Wang {GB_TILE_MODE12, false}, 100062a37553SKen Wang {GB_TILE_MODE13, false}, 100162a37553SKen Wang {GB_TILE_MODE14, false}, 100262a37553SKen Wang {GB_TILE_MODE15, false}, 100362a37553SKen Wang {GB_TILE_MODE16, false}, 100462a37553SKen Wang {GB_TILE_MODE17, false}, 100562a37553SKen Wang {GB_TILE_MODE18, false}, 100662a37553SKen Wang {GB_TILE_MODE19, false}, 100762a37553SKen Wang {GB_TILE_MODE20, false}, 100862a37553SKen Wang {GB_TILE_MODE21, false}, 100962a37553SKen Wang {GB_TILE_MODE22, false}, 101062a37553SKen Wang {GB_TILE_MODE23, false}, 101162a37553SKen Wang {GB_TILE_MODE24, false}, 101262a37553SKen Wang {GB_TILE_MODE25, false}, 101362a37553SKen Wang {GB_TILE_MODE26, false}, 101462a37553SKen Wang {GB_TILE_MODE27, false}, 101562a37553SKen Wang {GB_TILE_MODE28, false}, 101662a37553SKen Wang {GB_TILE_MODE29, false}, 101762a37553SKen Wang {GB_TILE_MODE30, false}, 101862a37553SKen Wang {GB_TILE_MODE31, false}, 101962a37553SKen Wang {CC_RB_BACKEND_DISABLE, false, true}, 102062a37553SKen Wang {GC_USER_RB_BACKEND_DISABLE, false, true}, 102162a37553SKen Wang {PA_SC_RASTER_CONFIG, false, true}, 102262a37553SKen Wang }; 102362a37553SKen Wang 102462a37553SKen Wang static uint32_t si_read_indexed_register(struct amdgpu_device *adev, 102562a37553SKen Wang u32 se_num, u32 sh_num, 102662a37553SKen Wang u32 reg_offset) 102762a37553SKen Wang { 102862a37553SKen Wang uint32_t val; 102962a37553SKen Wang 103062a37553SKen Wang mutex_lock(&adev->grbm_idx_mutex); 103162a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 103262a37553SKen Wang amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff); 103362a37553SKen Wang 103462a37553SKen Wang val = RREG32(reg_offset); 103562a37553SKen Wang 103662a37553SKen Wang if (se_num != 0xffffffff || sh_num != 0xffffffff) 103762a37553SKen Wang amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); 103862a37553SKen Wang mutex_unlock(&adev->grbm_idx_mutex); 103962a37553SKen Wang return val; 104062a37553SKen Wang } 104162a37553SKen Wang 104262a37553SKen Wang static int si_read_register(struct amdgpu_device *adev, u32 se_num, 104362a37553SKen Wang u32 sh_num, u32 reg_offset, u32 *value) 104462a37553SKen Wang { 104562a37553SKen Wang uint32_t i; 104662a37553SKen Wang 104762a37553SKen Wang *value = 0; 104862a37553SKen Wang for (i = 0; i < ARRAY_SIZE(si_allowed_read_registers); i++) { 104962a37553SKen Wang if (reg_offset != si_allowed_read_registers[i].reg_offset) 105062a37553SKen Wang continue; 105162a37553SKen Wang 105262a37553SKen Wang if (!si_allowed_read_registers[i].untouched) 105362a37553SKen Wang *value = si_allowed_read_registers[i].grbm_indexed ? 105462a37553SKen Wang si_read_indexed_register(adev, se_num, 105562a37553SKen Wang sh_num, reg_offset) : 105662a37553SKen Wang RREG32(reg_offset); 105762a37553SKen Wang return 0; 105862a37553SKen Wang } 105962a37553SKen Wang return -EINVAL; 106062a37553SKen Wang } 106162a37553SKen Wang 106262a37553SKen Wang static bool si_read_disabled_bios(struct amdgpu_device *adev) 106362a37553SKen Wang { 106462a37553SKen Wang u32 bus_cntl; 106562a37553SKen Wang u32 d1vga_control = 0; 106662a37553SKen Wang u32 d2vga_control = 0; 106762a37553SKen Wang u32 vga_render_control = 0; 106862a37553SKen Wang u32 rom_cntl; 106962a37553SKen Wang bool r; 107062a37553SKen Wang 107162a37553SKen Wang bus_cntl = RREG32(R600_BUS_CNTL); 107262a37553SKen Wang if (adev->mode_info.num_crtc) { 107362a37553SKen Wang d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); 107462a37553SKen Wang d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); 107562a37553SKen Wang vga_render_control = RREG32(VGA_RENDER_CONTROL); 107662a37553SKen Wang } 107762a37553SKen Wang rom_cntl = RREG32(R600_ROM_CNTL); 107862a37553SKen Wang 107962a37553SKen Wang /* enable the rom */ 108062a37553SKen Wang WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS)); 108162a37553SKen Wang if (adev->mode_info.num_crtc) { 108262a37553SKen Wang /* Disable VGA mode */ 108362a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, 108462a37553SKen Wang (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 108562a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 108662a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, 108762a37553SKen Wang (d2vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 108862a37553SKen Wang AVIVO_DVGA_CONTROL_TIMING_SELECT))); 108962a37553SKen Wang WREG32(VGA_RENDER_CONTROL, 109062a37553SKen Wang (vga_render_control & C_000300_VGA_VSTATUS_CNTL)); 109162a37553SKen Wang } 109262a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE); 109362a37553SKen Wang 109462a37553SKen Wang r = amdgpu_read_bios(adev); 109562a37553SKen Wang 109662a37553SKen Wang /* restore regs */ 109762a37553SKen Wang WREG32(R600_BUS_CNTL, bus_cntl); 109862a37553SKen Wang if (adev->mode_info.num_crtc) { 109962a37553SKen Wang WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); 110062a37553SKen Wang WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); 110162a37553SKen Wang WREG32(VGA_RENDER_CONTROL, vga_render_control); 110262a37553SKen Wang } 110362a37553SKen Wang WREG32(R600_ROM_CNTL, rom_cntl); 110462a37553SKen Wang return r; 110562a37553SKen Wang } 110662a37553SKen Wang 110762a37553SKen Wang //xxx: not implemented 110862a37553SKen Wang static int si_asic_reset(struct amdgpu_device *adev) 110962a37553SKen Wang { 111062a37553SKen Wang return 0; 111162a37553SKen Wang } 111262a37553SKen Wang 111362a37553SKen Wang static void si_vga_set_state(struct amdgpu_device *adev, bool state) 111462a37553SKen Wang { 111562a37553SKen Wang uint32_t temp; 111662a37553SKen Wang 111762a37553SKen Wang temp = RREG32(CONFIG_CNTL); 111862a37553SKen Wang if (state == false) { 111962a37553SKen Wang temp &= ~(1<<0); 112062a37553SKen Wang temp |= (1<<1); 112162a37553SKen Wang } else { 112262a37553SKen Wang temp &= ~(1<<1); 112362a37553SKen Wang } 112462a37553SKen Wang WREG32(CONFIG_CNTL, temp); 112562a37553SKen Wang } 112662a37553SKen Wang 112762a37553SKen Wang static u32 si_get_xclk(struct amdgpu_device *adev) 112862a37553SKen Wang { 112962a37553SKen Wang u32 reference_clock = adev->clock.spll.reference_freq; 113062a37553SKen Wang u32 tmp; 113162a37553SKen Wang 113262a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL_2); 113362a37553SKen Wang if (tmp & MUX_TCLK_TO_XCLK) 113462a37553SKen Wang return TCLK; 113562a37553SKen Wang 113662a37553SKen Wang tmp = RREG32(CG_CLKPIN_CNTL); 113762a37553SKen Wang if (tmp & XTALIN_DIVIDE) 113862a37553SKen Wang return reference_clock / 4; 113962a37553SKen Wang 114062a37553SKen Wang return reference_clock; 114162a37553SKen Wang } 11421919696eSMaruthi Srinivas Bayyavarapu 114362a37553SKen Wang //xxx:not implemented 114462a37553SKen Wang static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) 114562a37553SKen Wang { 114662a37553SKen Wang return 0; 114762a37553SKen Wang } 114862a37553SKen Wang 11494e99a44eSMonk Liu static void si_detect_hw_virtualization(struct amdgpu_device *adev) 11504e99a44eSMonk Liu { 11514e99a44eSMonk Liu if (is_virtual_machine()) /* passthrough mode */ 11524e99a44eSMonk Liu adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; 11534e99a44eSMonk Liu } 11544e99a44eSMonk Liu 115562a37553SKen Wang static const struct amdgpu_asic_funcs si_asic_funcs = 115662a37553SKen Wang { 115762a37553SKen Wang .read_disabled_bios = &si_read_disabled_bios, 11584e99a44eSMonk Liu .detect_hw_virtualization = si_detect_hw_virtualization, 115962a37553SKen Wang .read_register = &si_read_register, 116062a37553SKen Wang .reset = &si_asic_reset, 116162a37553SKen Wang .set_vga_state = &si_vga_set_state, 116262a37553SKen Wang .get_xclk = &si_get_xclk, 116362a37553SKen Wang .set_uvd_clocks = &si_set_uvd_clocks, 116462a37553SKen Wang .set_vce_clocks = NULL, 116562a37553SKen Wang }; 116662a37553SKen Wang 116762a37553SKen Wang static uint32_t si_get_rev_id(struct amdgpu_device *adev) 116862a37553SKen Wang { 116962a37553SKen Wang return (RREG32(CC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK) 117062a37553SKen Wang >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT; 117162a37553SKen Wang } 117262a37553SKen Wang 117362a37553SKen Wang static int si_common_early_init(void *handle) 117462a37553SKen Wang { 117562a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 117662a37553SKen Wang 117762a37553SKen Wang adev->smc_rreg = &si_smc_rreg; 117862a37553SKen Wang adev->smc_wreg = &si_smc_wreg; 117962a37553SKen Wang adev->pcie_rreg = &si_pcie_rreg; 118062a37553SKen Wang adev->pcie_wreg = &si_pcie_wreg; 118136b9a952SHuang Rui adev->pciep_rreg = &si_pciep_rreg; 118236b9a952SHuang Rui adev->pciep_wreg = &si_pciep_wreg; 118362a37553SKen Wang adev->uvd_ctx_rreg = NULL; 118462a37553SKen Wang adev->uvd_ctx_wreg = NULL; 118562a37553SKen Wang adev->didt_rreg = NULL; 118662a37553SKen Wang adev->didt_wreg = NULL; 118762a37553SKen Wang 118862a37553SKen Wang adev->asic_funcs = &si_asic_funcs; 118962a37553SKen Wang 119062a37553SKen Wang adev->rev_id = si_get_rev_id(adev); 119162a37553SKen Wang adev->external_rev_id = 0xFF; 119262a37553SKen Wang switch (adev->asic_type) { 119362a37553SKen Wang case CHIP_TAHITI: 119462a37553SKen Wang adev->cg_flags = 119562a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 119662a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 119762a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 119862a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 119962a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 120062a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 120162a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 120262a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 120362a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 120462a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 120562a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 120662a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 120762a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 120862a37553SKen Wang adev->pg_flags = 0; 12097c0a705eSFlora Cui adev->external_rev_id = (adev->rev_id == 0) ? 1 : 12107c0a705eSFlora Cui (adev->rev_id == 1) ? 5 : 6; 121162a37553SKen Wang break; 121262a37553SKen Wang case CHIP_PITCAIRN: 121362a37553SKen Wang adev->cg_flags = 121462a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 121562a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 121662a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 121762a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 121862a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 121962a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 122062a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 122162a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 122262a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 122362a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 122462a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 122562a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 122662a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 122762a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 122862a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 122962a37553SKen Wang adev->pg_flags = 0; 1230e285a9a6SFlora Cui adev->external_rev_id = adev->rev_id + 20; 123162a37553SKen Wang break; 123262a37553SKen Wang 123362a37553SKen Wang case CHIP_VERDE: 123462a37553SKen Wang adev->cg_flags = 123562a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 123662a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 123762a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 123862a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 123962a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS_LS | 124062a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 124162a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 124262a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 124362a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 124462a37553SKen Wang AMD_CG_SUPPORT_SDMA_LS | 124562a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 124662a37553SKen Wang AMD_CG_SUPPORT_VCE_MGCG | 124762a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 124862a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 124962a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 125062a37553SKen Wang adev->pg_flags = 0; 125162a37553SKen Wang //??? 125262a37553SKen Wang adev->external_rev_id = adev->rev_id + 0x14; 125362a37553SKen Wang break; 125462a37553SKen Wang case CHIP_OLAND: 125562a37553SKen Wang adev->cg_flags = 125662a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 125762a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 125862a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 125962a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 126062a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 126162a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 126262a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 126362a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 126462a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 126562a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 126662a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 126762a37553SKen Wang AMD_CG_SUPPORT_UVD_MGCG | 126862a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 126962a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 127062a37553SKen Wang adev->pg_flags = 0; 127162a37553SKen Wang break; 127262a37553SKen Wang case CHIP_HAINAN: 127362a37553SKen Wang adev->cg_flags = 127462a37553SKen Wang AMD_CG_SUPPORT_GFX_MGCG | 127562a37553SKen Wang AMD_CG_SUPPORT_GFX_MGLS | 127662a37553SKen Wang /*AMD_CG_SUPPORT_GFX_CGCG |*/ 127762a37553SKen Wang AMD_CG_SUPPORT_GFX_CGLS | 127862a37553SKen Wang AMD_CG_SUPPORT_GFX_CGTS | 127962a37553SKen Wang AMD_CG_SUPPORT_GFX_CP_LS | 128062a37553SKen Wang AMD_CG_SUPPORT_GFX_RLC_LS | 128162a37553SKen Wang AMD_CG_SUPPORT_MC_LS | 128262a37553SKen Wang AMD_CG_SUPPORT_MC_MGCG | 128362a37553SKen Wang AMD_CG_SUPPORT_SDMA_MGCG | 128462a37553SKen Wang AMD_CG_SUPPORT_BIF_LS | 128562a37553SKen Wang AMD_CG_SUPPORT_HDP_LS | 128662a37553SKen Wang AMD_CG_SUPPORT_HDP_MGCG; 128762a37553SKen Wang adev->pg_flags = 0; 128805319478SFlora Cui adev->external_rev_id = 70; 128962a37553SKen Wang break; 129062a37553SKen Wang 129162a37553SKen Wang default: 129262a37553SKen Wang return -EINVAL; 129362a37553SKen Wang } 129462a37553SKen Wang 129562a37553SKen Wang return 0; 129662a37553SKen Wang } 129762a37553SKen Wang 129862a37553SKen Wang static int si_common_sw_init(void *handle) 129962a37553SKen Wang { 130062a37553SKen Wang return 0; 130162a37553SKen Wang } 130262a37553SKen Wang 130362a37553SKen Wang static int si_common_sw_fini(void *handle) 130462a37553SKen Wang { 130562a37553SKen Wang return 0; 130662a37553SKen Wang } 130762a37553SKen Wang 130862a37553SKen Wang 130962a37553SKen Wang static void si_init_golden_registers(struct amdgpu_device *adev) 131062a37553SKen Wang { 131162a37553SKen Wang switch (adev->asic_type) { 131262a37553SKen Wang case CHIP_TAHITI: 131362a37553SKen Wang amdgpu_program_register_sequence(adev, 131462a37553SKen Wang tahiti_golden_registers, 131562a37553SKen Wang (const u32)ARRAY_SIZE(tahiti_golden_registers)); 131662a37553SKen Wang amdgpu_program_register_sequence(adev, 131762a37553SKen Wang tahiti_golden_rlc_registers, 131862a37553SKen Wang (const u32)ARRAY_SIZE(tahiti_golden_rlc_registers)); 131962a37553SKen Wang amdgpu_program_register_sequence(adev, 132062a37553SKen Wang tahiti_mgcg_cgcg_init, 132162a37553SKen Wang (const u32)ARRAY_SIZE(tahiti_mgcg_cgcg_init)); 132262a37553SKen Wang amdgpu_program_register_sequence(adev, 132362a37553SKen Wang tahiti_golden_registers2, 132462a37553SKen Wang (const u32)ARRAY_SIZE(tahiti_golden_registers2)); 132562a37553SKen Wang break; 132662a37553SKen Wang case CHIP_PITCAIRN: 132762a37553SKen Wang amdgpu_program_register_sequence(adev, 132862a37553SKen Wang pitcairn_golden_registers, 132962a37553SKen Wang (const u32)ARRAY_SIZE(pitcairn_golden_registers)); 133062a37553SKen Wang amdgpu_program_register_sequence(adev, 133162a37553SKen Wang pitcairn_golden_rlc_registers, 133262a37553SKen Wang (const u32)ARRAY_SIZE(pitcairn_golden_rlc_registers)); 133362a37553SKen Wang amdgpu_program_register_sequence(adev, 133462a37553SKen Wang pitcairn_mgcg_cgcg_init, 133562a37553SKen Wang (const u32)ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); 133662a37553SKen Wang case CHIP_VERDE: 133762a37553SKen Wang amdgpu_program_register_sequence(adev, 133862a37553SKen Wang verde_golden_registers, 133962a37553SKen Wang (const u32)ARRAY_SIZE(verde_golden_registers)); 134062a37553SKen Wang amdgpu_program_register_sequence(adev, 134162a37553SKen Wang verde_golden_rlc_registers, 134262a37553SKen Wang (const u32)ARRAY_SIZE(verde_golden_rlc_registers)); 134362a37553SKen Wang amdgpu_program_register_sequence(adev, 134462a37553SKen Wang verde_mgcg_cgcg_init, 134562a37553SKen Wang (const u32)ARRAY_SIZE(verde_mgcg_cgcg_init)); 134662a37553SKen Wang amdgpu_program_register_sequence(adev, 134762a37553SKen Wang verde_pg_init, 134862a37553SKen Wang (const u32)ARRAY_SIZE(verde_pg_init)); 134962a37553SKen Wang break; 135062a37553SKen Wang case CHIP_OLAND: 135162a37553SKen Wang amdgpu_program_register_sequence(adev, 135262a37553SKen Wang oland_golden_registers, 135362a37553SKen Wang (const u32)ARRAY_SIZE(oland_golden_registers)); 135462a37553SKen Wang amdgpu_program_register_sequence(adev, 135562a37553SKen Wang oland_golden_rlc_registers, 135662a37553SKen Wang (const u32)ARRAY_SIZE(oland_golden_rlc_registers)); 135762a37553SKen Wang amdgpu_program_register_sequence(adev, 135862a37553SKen Wang oland_mgcg_cgcg_init, 135962a37553SKen Wang (const u32)ARRAY_SIZE(oland_mgcg_cgcg_init)); 136062a37553SKen Wang case CHIP_HAINAN: 136162a37553SKen Wang amdgpu_program_register_sequence(adev, 136262a37553SKen Wang hainan_golden_registers, 136362a37553SKen Wang (const u32)ARRAY_SIZE(hainan_golden_registers)); 136462a37553SKen Wang amdgpu_program_register_sequence(adev, 136562a37553SKen Wang hainan_golden_registers2, 136662a37553SKen Wang (const u32)ARRAY_SIZE(hainan_golden_registers2)); 136762a37553SKen Wang amdgpu_program_register_sequence(adev, 136862a37553SKen Wang hainan_mgcg_cgcg_init, 136962a37553SKen Wang (const u32)ARRAY_SIZE(hainan_mgcg_cgcg_init)); 137062a37553SKen Wang break; 137162a37553SKen Wang 137262a37553SKen Wang 137362a37553SKen Wang default: 137462a37553SKen Wang BUG(); 137562a37553SKen Wang } 137662a37553SKen Wang } 137762a37553SKen Wang 137862a37553SKen Wang static void si_pcie_gen3_enable(struct amdgpu_device *adev) 137962a37553SKen Wang { 138062a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 138162a37553SKen Wang int bridge_pos, gpu_pos; 138262a37553SKen Wang u32 speed_cntl, mask, current_data_rate; 138362a37553SKen Wang int ret, i; 138462a37553SKen Wang u16 tmp16; 138562a37553SKen Wang 138662a37553SKen Wang if (pci_is_root_bus(adev->pdev->bus)) 138762a37553SKen Wang return; 138862a37553SKen Wang 138962a37553SKen Wang if (amdgpu_pcie_gen2 == 0) 139062a37553SKen Wang return; 139162a37553SKen Wang 139262a37553SKen Wang if (adev->flags & AMD_IS_APU) 139362a37553SKen Wang return; 139462a37553SKen Wang 139562a37553SKen Wang ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); 139662a37553SKen Wang if (ret != 0) 139762a37553SKen Wang return; 139862a37553SKen Wang 139962a37553SKen Wang if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) 140062a37553SKen Wang return; 140162a37553SKen Wang 140236b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 140362a37553SKen Wang current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> 140462a37553SKen Wang LC_CURRENT_DATA_RATE_SHIFT; 140562a37553SKen Wang if (mask & DRM_PCIE_SPEED_80) { 140662a37553SKen Wang if (current_data_rate == 2) { 140762a37553SKen Wang DRM_INFO("PCIE gen 3 link speeds already enabled\n"); 140862a37553SKen Wang return; 140962a37553SKen Wang } 141062a37553SKen Wang DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); 141162a37553SKen Wang } else if (mask & DRM_PCIE_SPEED_50) { 141262a37553SKen Wang if (current_data_rate == 1) { 141362a37553SKen Wang DRM_INFO("PCIE gen 2 link speeds already enabled\n"); 141462a37553SKen Wang return; 141562a37553SKen Wang } 141662a37553SKen Wang DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n"); 141762a37553SKen Wang } 141862a37553SKen Wang 141962a37553SKen Wang bridge_pos = pci_pcie_cap(root); 142062a37553SKen Wang if (!bridge_pos) 142162a37553SKen Wang return; 142262a37553SKen Wang 142362a37553SKen Wang gpu_pos = pci_pcie_cap(adev->pdev); 142462a37553SKen Wang if (!gpu_pos) 142562a37553SKen Wang return; 142662a37553SKen Wang 142762a37553SKen Wang if (mask & DRM_PCIE_SPEED_80) { 142862a37553SKen Wang if (current_data_rate != 2) { 142962a37553SKen Wang u16 bridge_cfg, gpu_cfg; 143062a37553SKen Wang u16 bridge_cfg2, gpu_cfg2; 143162a37553SKen Wang u32 max_lw, current_lw, tmp; 143262a37553SKen Wang 143362a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); 143462a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); 143562a37553SKen Wang 143662a37553SKen Wang tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD; 143762a37553SKen Wang pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); 143862a37553SKen Wang 143962a37553SKen Wang tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD; 144062a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); 144162a37553SKen Wang 144262a37553SKen Wang tmp = RREG32_PCIE(PCIE_LC_STATUS1); 144362a37553SKen Wang max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; 144462a37553SKen Wang current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; 144562a37553SKen Wang 144662a37553SKen Wang if (current_lw < max_lw) { 144736b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 144862a37553SKen Wang if (tmp & LC_RENEGOTIATION_SUPPORT) { 144962a37553SKen Wang tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); 145062a37553SKen Wang tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); 145162a37553SKen Wang tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; 145236b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); 145362a37553SKen Wang } 145462a37553SKen Wang } 145562a37553SKen Wang 145662a37553SKen Wang for (i = 0; i < 10; i++) { 145762a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16); 145862a37553SKen Wang if (tmp16 & PCI_EXP_DEVSTA_TRPND) 145962a37553SKen Wang break; 146062a37553SKen Wang 146162a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); 146262a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); 146362a37553SKen Wang 146462a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); 146562a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); 146662a37553SKen Wang 146736b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 146862a37553SKen Wang tmp |= LC_SET_QUIESCE; 146936b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 147062a37553SKen Wang 147136b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 147262a37553SKen Wang tmp |= LC_REDO_EQ; 147336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 147462a37553SKen Wang 147562a37553SKen Wang mdelay(100); 147662a37553SKen Wang 147762a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16); 147862a37553SKen Wang tmp16 &= ~PCI_EXP_LNKCTL_HAWD; 147962a37553SKen Wang tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD); 148062a37553SKen Wang pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); 148162a37553SKen Wang 148262a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16); 148362a37553SKen Wang tmp16 &= ~PCI_EXP_LNKCTL_HAWD; 148462a37553SKen Wang tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD); 148562a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); 148662a37553SKen Wang 148762a37553SKen Wang pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16); 148862a37553SKen Wang tmp16 &= ~((1 << 4) | (7 << 9)); 148962a37553SKen Wang tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9))); 149062a37553SKen Wang pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16); 149162a37553SKen Wang 149262a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); 149362a37553SKen Wang tmp16 &= ~((1 << 4) | (7 << 9)); 149462a37553SKen Wang tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); 149562a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); 149662a37553SKen Wang 149736b9a952SHuang Rui tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); 149862a37553SKen Wang tmp &= ~LC_SET_QUIESCE; 149936b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); 150062a37553SKen Wang } 150162a37553SKen Wang } 150262a37553SKen Wang } 150362a37553SKen Wang 150462a37553SKen Wang speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; 150562a37553SKen Wang speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; 150636b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 150762a37553SKen Wang 150862a37553SKen Wang pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); 150962a37553SKen Wang tmp16 &= ~0xf; 151062a37553SKen Wang if (mask & DRM_PCIE_SPEED_80) 151162a37553SKen Wang tmp16 |= 3; 151262a37553SKen Wang else if (mask & DRM_PCIE_SPEED_50) 151362a37553SKen Wang tmp16 |= 2; 151462a37553SKen Wang else 151562a37553SKen Wang tmp16 |= 1; 151662a37553SKen Wang pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); 151762a37553SKen Wang 151836b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 151962a37553SKen Wang speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; 152036b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); 152162a37553SKen Wang 152262a37553SKen Wang for (i = 0; i < adev->usec_timeout; i++) { 152336b9a952SHuang Rui speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); 152462a37553SKen Wang if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) 152562a37553SKen Wang break; 152662a37553SKen Wang udelay(1); 152762a37553SKen Wang } 152862a37553SKen Wang } 152962a37553SKen Wang 153062a37553SKen Wang static inline u32 si_pif_phy0_rreg(struct amdgpu_device *adev, u32 reg) 153162a37553SKen Wang { 153262a37553SKen Wang unsigned long flags; 153362a37553SKen Wang u32 r; 153462a37553SKen Wang 153562a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 153662a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 153762a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY0_DATA); 153862a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 153962a37553SKen Wang return r; 154062a37553SKen Wang } 154162a37553SKen Wang 154262a37553SKen Wang static inline void si_pif_phy0_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 154362a37553SKen Wang { 154462a37553SKen Wang unsigned long flags; 154562a37553SKen Wang 154662a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 154762a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 154862a37553SKen Wang WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); 154962a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 155062a37553SKen Wang } 155162a37553SKen Wang 155262a37553SKen Wang static inline u32 si_pif_phy1_rreg(struct amdgpu_device *adev, u32 reg) 155362a37553SKen Wang { 155462a37553SKen Wang unsigned long flags; 155562a37553SKen Wang u32 r; 155662a37553SKen Wang 155762a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 155862a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 155962a37553SKen Wang r = RREG32(EVERGREEN_PIF_PHY1_DATA); 156062a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 156162a37553SKen Wang return r; 156262a37553SKen Wang } 156362a37553SKen Wang 156462a37553SKen Wang static inline void si_pif_phy1_wreg(struct amdgpu_device *adev, u32 reg, u32 v) 156562a37553SKen Wang { 156662a37553SKen Wang unsigned long flags; 156762a37553SKen Wang 156862a37553SKen Wang spin_lock_irqsave(&adev->pcie_idx_lock, flags); 156962a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 157062a37553SKen Wang WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); 157162a37553SKen Wang spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); 157262a37553SKen Wang } 157362a37553SKen Wang static void si_program_aspm(struct amdgpu_device *adev) 157462a37553SKen Wang { 157562a37553SKen Wang u32 data, orig; 157662a37553SKen Wang bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; 157762a37553SKen Wang bool disable_clkreq = false; 157862a37553SKen Wang 157962a37553SKen Wang if (amdgpu_aspm == 0) 158062a37553SKen Wang return; 158162a37553SKen Wang 158262a37553SKen Wang if (adev->flags & AMD_IS_APU) 158362a37553SKen Wang return; 158436b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 158562a37553SKen Wang data &= ~LC_XMIT_N_FTS_MASK; 158662a37553SKen Wang data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; 158762a37553SKen Wang if (orig != data) 158836b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); 158962a37553SKen Wang 159036b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); 159162a37553SKen Wang data |= LC_GO_TO_RECOVERY; 159262a37553SKen Wang if (orig != data) 159336b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); 159462a37553SKen Wang 159562a37553SKen Wang orig = data = RREG32_PCIE(PCIE_P_CNTL); 159662a37553SKen Wang data |= P_IGNORE_EDB_ERR; 159762a37553SKen Wang if (orig != data) 159862a37553SKen Wang WREG32_PCIE(PCIE_P_CNTL, data); 159962a37553SKen Wang 160036b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 160162a37553SKen Wang data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); 160262a37553SKen Wang data |= LC_PMI_TO_L1_DIS; 160362a37553SKen Wang if (!disable_l0s) 160462a37553SKen Wang data |= LC_L0S_INACTIVITY(7); 160562a37553SKen Wang 160662a37553SKen Wang if (!disable_l1) { 160762a37553SKen Wang data |= LC_L1_INACTIVITY(7); 160862a37553SKen Wang data &= ~LC_PMI_TO_L1_DIS; 160962a37553SKen Wang if (orig != data) 161036b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 161162a37553SKen Wang 161262a37553SKen Wang if (!disable_plloff_in_l1) { 161362a37553SKen Wang bool clk_req_support; 161462a37553SKen Wang 161562a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 161662a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 161762a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 161862a37553SKen Wang if (orig != data) 161962a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 162062a37553SKen Wang 162162a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 162262a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 162362a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 162462a37553SKen Wang if (orig != data) 162562a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 162662a37553SKen Wang 162762a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 162862a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); 162962a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); 163062a37553SKen Wang if (orig != data) 163162a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 163262a37553SKen Wang 163362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 163462a37553SKen Wang data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); 163562a37553SKen Wang data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); 163662a37553SKen Wang if (orig != data) 163762a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 163862a37553SKen Wang 163962a37553SKen Wang if ((adev->family != CHIP_OLAND) && (adev->family != CHIP_HAINAN)) { 164062a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0); 164162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 164262a37553SKen Wang if (orig != data) 164362a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data); 164462a37553SKen Wang 164562a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1); 164662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 164762a37553SKen Wang if (orig != data) 164862a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data); 164962a37553SKen Wang 165062a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_2); 165162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 165262a37553SKen Wang if (orig != data) 165362a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_2, data); 165462a37553SKen Wang 165562a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_3); 165662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 165762a37553SKen Wang if (orig != data) 165862a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_3, data); 165962a37553SKen Wang 166062a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0); 166162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_0_MASK; 166262a37553SKen Wang if (orig != data) 166362a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data); 166462a37553SKen Wang 166562a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1); 166662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_1_MASK; 166762a37553SKen Wang if (orig != data) 166862a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data); 166962a37553SKen Wang 167062a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_2); 167162a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_2_MASK; 167262a37553SKen Wang if (orig != data) 167362a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_2, data); 167462a37553SKen Wang 167562a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_3); 167662a37553SKen Wang data &= ~PLL_RAMP_UP_TIME_3_MASK; 167762a37553SKen Wang if (orig != data) 167862a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); 167962a37553SKen Wang } 168036b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); 168162a37553SKen Wang data &= ~LC_DYN_LANES_PWR_STATE_MASK; 168262a37553SKen Wang data |= LC_DYN_LANES_PWR_STATE(3); 168362a37553SKen Wang if (orig != data) 168436b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); 168562a37553SKen Wang 168662a37553SKen Wang orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); 168762a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 168862a37553SKen Wang if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN)) 168962a37553SKen Wang data |= LS2_EXIT_TIME(5); 169062a37553SKen Wang if (orig != data) 169162a37553SKen Wang si_pif_phy0_wreg(adev,PB0_PIF_CNTL, data); 169262a37553SKen Wang 169362a37553SKen Wang orig = data = si_pif_phy1_rreg(adev,PB1_PIF_CNTL); 169462a37553SKen Wang data &= ~LS2_EXIT_TIME_MASK; 169562a37553SKen Wang if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN)) 169662a37553SKen Wang data |= LS2_EXIT_TIME(5); 169762a37553SKen Wang if (orig != data) 169862a37553SKen Wang si_pif_phy1_wreg(adev,PB1_PIF_CNTL, data); 169962a37553SKen Wang 170062a37553SKen Wang if (!disable_clkreq && 170162a37553SKen Wang !pci_is_root_bus(adev->pdev->bus)) { 170262a37553SKen Wang struct pci_dev *root = adev->pdev->bus->self; 170362a37553SKen Wang u32 lnkcap; 170462a37553SKen Wang 170562a37553SKen Wang clk_req_support = false; 170662a37553SKen Wang pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); 170762a37553SKen Wang if (lnkcap & PCI_EXP_LNKCAP_CLKPM) 170862a37553SKen Wang clk_req_support = true; 170962a37553SKen Wang } else { 171062a37553SKen Wang clk_req_support = false; 171162a37553SKen Wang } 171262a37553SKen Wang 171362a37553SKen Wang if (clk_req_support) { 171436b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); 171562a37553SKen Wang data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; 171662a37553SKen Wang if (orig != data) 171736b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); 171862a37553SKen Wang 171962a37553SKen Wang orig = data = RREG32(THM_CLK_CNTL); 172062a37553SKen Wang data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); 172162a37553SKen Wang data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); 172262a37553SKen Wang if (orig != data) 172362a37553SKen Wang WREG32(THM_CLK_CNTL, data); 172462a37553SKen Wang 172562a37553SKen Wang orig = data = RREG32(MISC_CLK_CNTL); 172662a37553SKen Wang data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); 172762a37553SKen Wang data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); 172862a37553SKen Wang if (orig != data) 172962a37553SKen Wang WREG32(MISC_CLK_CNTL, data); 173062a37553SKen Wang 173162a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL); 173262a37553SKen Wang data &= ~BCLK_AS_XCLK; 173362a37553SKen Wang if (orig != data) 173462a37553SKen Wang WREG32(CG_CLKPIN_CNTL, data); 173562a37553SKen Wang 173662a37553SKen Wang orig = data = RREG32(CG_CLKPIN_CNTL_2); 173762a37553SKen Wang data &= ~FORCE_BIF_REFCLK_EN; 173862a37553SKen Wang if (orig != data) 173962a37553SKen Wang WREG32(CG_CLKPIN_CNTL_2, data); 174062a37553SKen Wang 174162a37553SKen Wang orig = data = RREG32(MPLL_BYPASSCLK_SEL); 174262a37553SKen Wang data &= ~MPLL_CLKOUT_SEL_MASK; 174362a37553SKen Wang data |= MPLL_CLKOUT_SEL(4); 174462a37553SKen Wang if (orig != data) 174562a37553SKen Wang WREG32(MPLL_BYPASSCLK_SEL, data); 174662a37553SKen Wang 174762a37553SKen Wang orig = data = RREG32(SPLL_CNTL_MODE); 174862a37553SKen Wang data &= ~SPLL_REFCLK_SEL_MASK; 174962a37553SKen Wang if (orig != data) 175062a37553SKen Wang WREG32(SPLL_CNTL_MODE, data); 175162a37553SKen Wang } 175262a37553SKen Wang } 175362a37553SKen Wang } else { 175462a37553SKen Wang if (orig != data) 175536b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 175662a37553SKen Wang } 175762a37553SKen Wang 175862a37553SKen Wang orig = data = RREG32_PCIE(PCIE_CNTL2); 175962a37553SKen Wang data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; 176062a37553SKen Wang if (orig != data) 176162a37553SKen Wang WREG32_PCIE(PCIE_CNTL2, data); 176262a37553SKen Wang 176362a37553SKen Wang if (!disable_l0s) { 176436b9a952SHuang Rui data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); 176562a37553SKen Wang if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { 176662a37553SKen Wang data = RREG32_PCIE(PCIE_LC_STATUS1); 176762a37553SKen Wang if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { 176836b9a952SHuang Rui orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); 176962a37553SKen Wang data &= ~LC_L0S_INACTIVITY_MASK; 177062a37553SKen Wang if (orig != data) 177136b9a952SHuang Rui WREG32_PCIE_PORT(PCIE_LC_CNTL, data); 177262a37553SKen Wang } 177362a37553SKen Wang } 177462a37553SKen Wang } 177562a37553SKen Wang } 177662a37553SKen Wang 177762a37553SKen Wang static void si_fix_pci_max_read_req_size(struct amdgpu_device *adev) 177862a37553SKen Wang { 177962a37553SKen Wang int readrq; 178062a37553SKen Wang u16 v; 178162a37553SKen Wang 178262a37553SKen Wang readrq = pcie_get_readrq(adev->pdev); 178362a37553SKen Wang v = ffs(readrq) - 8; 178462a37553SKen Wang if ((v == 0) || (v == 6) || (v == 7)) 178562a37553SKen Wang pcie_set_readrq(adev->pdev, 512); 178662a37553SKen Wang } 178762a37553SKen Wang 178862a37553SKen Wang static int si_common_hw_init(void *handle) 178962a37553SKen Wang { 179062a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 179162a37553SKen Wang 179262a37553SKen Wang si_fix_pci_max_read_req_size(adev); 179362a37553SKen Wang si_init_golden_registers(adev); 179462a37553SKen Wang si_pcie_gen3_enable(adev); 179562a37553SKen Wang si_program_aspm(adev); 179662a37553SKen Wang 179762a37553SKen Wang return 0; 179862a37553SKen Wang } 179962a37553SKen Wang 180062a37553SKen Wang static int si_common_hw_fini(void *handle) 180162a37553SKen Wang { 180262a37553SKen Wang return 0; 180362a37553SKen Wang } 180462a37553SKen Wang 180562a37553SKen Wang static int si_common_suspend(void *handle) 180662a37553SKen Wang { 180762a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 180862a37553SKen Wang 180962a37553SKen Wang return si_common_hw_fini(adev); 181062a37553SKen Wang } 181162a37553SKen Wang 181262a37553SKen Wang static int si_common_resume(void *handle) 181362a37553SKen Wang { 181462a37553SKen Wang struct amdgpu_device *adev = (struct amdgpu_device *)handle; 181562a37553SKen Wang 181662a37553SKen Wang return si_common_hw_init(adev); 181762a37553SKen Wang } 181862a37553SKen Wang 181962a37553SKen Wang static bool si_common_is_idle(void *handle) 182062a37553SKen Wang { 182162a37553SKen Wang return true; 182262a37553SKen Wang } 182362a37553SKen Wang 182462a37553SKen Wang static int si_common_wait_for_idle(void *handle) 182562a37553SKen Wang { 182662a37553SKen Wang return 0; 182762a37553SKen Wang } 182862a37553SKen Wang 182962a37553SKen Wang static int si_common_soft_reset(void *handle) 183062a37553SKen Wang { 183162a37553SKen Wang return 0; 183262a37553SKen Wang } 183362a37553SKen Wang 183462a37553SKen Wang static int si_common_set_clockgating_state(void *handle, 183562a37553SKen Wang enum amd_clockgating_state state) 183662a37553SKen Wang { 183762a37553SKen Wang return 0; 183862a37553SKen Wang } 183962a37553SKen Wang 184062a37553SKen Wang static int si_common_set_powergating_state(void *handle, 184162a37553SKen Wang enum amd_powergating_state state) 184262a37553SKen Wang { 184362a37553SKen Wang return 0; 184462a37553SKen Wang } 184562a37553SKen Wang 1846a1255107SAlex Deucher static const struct amd_ip_funcs si_common_ip_funcs = { 184762a37553SKen Wang .name = "si_common", 184862a37553SKen Wang .early_init = si_common_early_init, 184962a37553SKen Wang .late_init = NULL, 185062a37553SKen Wang .sw_init = si_common_sw_init, 185162a37553SKen Wang .sw_fini = si_common_sw_fini, 185262a37553SKen Wang .hw_init = si_common_hw_init, 185362a37553SKen Wang .hw_fini = si_common_hw_fini, 185462a37553SKen Wang .suspend = si_common_suspend, 185562a37553SKen Wang .resume = si_common_resume, 185662a37553SKen Wang .is_idle = si_common_is_idle, 185762a37553SKen Wang .wait_for_idle = si_common_wait_for_idle, 185862a37553SKen Wang .soft_reset = si_common_soft_reset, 185962a37553SKen Wang .set_clockgating_state = si_common_set_clockgating_state, 186062a37553SKen Wang .set_powergating_state = si_common_set_powergating_state, 186162a37553SKen Wang }; 186262a37553SKen Wang 1863a1255107SAlex Deucher static const struct amdgpu_ip_block_version si_common_ip_block = 186462a37553SKen Wang { 186562a37553SKen Wang .type = AMD_IP_BLOCK_TYPE_COMMON, 186662a37553SKen Wang .major = 1, 186762a37553SKen Wang .minor = 0, 186862a37553SKen Wang .rev = 0, 186962a37553SKen Wang .funcs = &si_common_ip_funcs, 18702120df47SAlex Deucher }; 18712120df47SAlex Deucher 187262a37553SKen Wang int si_set_ip_blocks(struct amdgpu_device *adev) 187362a37553SKen Wang { 187462a37553SKen Wang switch (adev->asic_type) { 187562a37553SKen Wang case CHIP_VERDE: 187662a37553SKen Wang case CHIP_TAHITI: 187762a37553SKen Wang case CHIP_PITCAIRN: 1878a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_common_ip_block); 1879a1255107SAlex Deucher amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block); 1880a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_ih_ip_block); 1881a1255107SAlex Deucher amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1882a1255107SAlex Deucher if (adev->enable_virtual_display) 1883a1255107SAlex Deucher amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1884a1255107SAlex Deucher else 1885a1255107SAlex Deucher amdgpu_ip_block_add(adev, &dce_v6_0_ip_block); 1886a1255107SAlex Deucher amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block); 1887a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_dma_ip_block); 1888a1255107SAlex Deucher /* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */ 1889a1255107SAlex Deucher /* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */ 1890a1255107SAlex Deucher break; 189162a37553SKen Wang case CHIP_OLAND: 1892a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_common_ip_block); 1893a1255107SAlex Deucher amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block); 1894a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_ih_ip_block); 1895a1255107SAlex Deucher amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1896a1255107SAlex Deucher if (adev->enable_virtual_display) 1897a1255107SAlex Deucher amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1898a1255107SAlex Deucher else 1899a1255107SAlex Deucher amdgpu_ip_block_add(adev, &dce_v6_4_ip_block); 1900a1255107SAlex Deucher amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block); 1901a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_dma_ip_block); 1902a1255107SAlex Deucher /* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */ 1903a1255107SAlex Deucher /* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */ 190462a37553SKen Wang break; 190562a37553SKen Wang case CHIP_HAINAN: 1906a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_common_ip_block); 1907a1255107SAlex Deucher amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block); 1908a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_ih_ip_block); 1909a1255107SAlex Deucher amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1910a1255107SAlex Deucher if (adev->enable_virtual_display) 1911a1255107SAlex Deucher amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1912a1255107SAlex Deucher amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block); 1913a1255107SAlex Deucher amdgpu_ip_block_add(adev, &si_dma_ip_block); 191462a37553SKen Wang break; 191562a37553SKen Wang default: 191662a37553SKen Wang BUG(); 191762a37553SKen Wang } 191862a37553SKen Wang return 0; 191962a37553SKen Wang } 192062a37553SKen Wang 1921