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