xref: /linux/drivers/gpu/drm/radeon/btc_dpm.c (revision c182615f3ea31eb4df6133beb0d62d8ff7b83e08)
16596afd4SAlex Deucher /*
26596afd4SAlex Deucher  * Copyright 2011 Advanced Micro Devices, Inc.
36596afd4SAlex Deucher  *
46596afd4SAlex Deucher  * Permission is hereby granted, free of charge, to any person obtaining a
56596afd4SAlex Deucher  * copy of this software and associated documentation files (the "Software"),
66596afd4SAlex Deucher  * to deal in the Software without restriction, including without limitation
76596afd4SAlex Deucher  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
86596afd4SAlex Deucher  * and/or sell copies of the Software, and to permit persons to whom the
96596afd4SAlex Deucher  * Software is furnished to do so, subject to the following conditions:
106596afd4SAlex Deucher  *
116596afd4SAlex Deucher  * The above copyright notice and this permission notice shall be included in
126596afd4SAlex Deucher  * all copies or substantial portions of the Software.
136596afd4SAlex Deucher  *
146596afd4SAlex Deucher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
156596afd4SAlex Deucher  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
166596afd4SAlex Deucher  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
176596afd4SAlex Deucher  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
186596afd4SAlex Deucher  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
196596afd4SAlex Deucher  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
206596afd4SAlex Deucher  * OTHER DEALINGS IN THE SOFTWARE.
216596afd4SAlex Deucher  *
226596afd4SAlex Deucher  * Authors: Alex Deucher
236596afd4SAlex Deucher  */
246596afd4SAlex Deucher 
25*c182615fSSam Ravnborg #include <linux/seq_file.h>
26*c182615fSSam Ravnborg 
27*c182615fSSam Ravnborg #include <drm/drm_pci.h>
28*c182615fSSam Ravnborg 
29*c182615fSSam Ravnborg #include "atom.h"
30*c182615fSSam Ravnborg #include "btc_dpm.h"
31*c182615fSSam Ravnborg #include "btcd.h"
32*c182615fSSam Ravnborg #include "cypress_dpm.h"
33*c182615fSSam Ravnborg #include "r600_dpm.h"
346596afd4SAlex Deucher #include "radeon.h"
3501467a9bSMichele Curti #include "radeon_asic.h"
366596afd4SAlex Deucher 
376596afd4SAlex Deucher #define MC_CG_ARB_FREQ_F0           0x0a
386596afd4SAlex Deucher #define MC_CG_ARB_FREQ_F1           0x0b
396596afd4SAlex Deucher #define MC_CG_ARB_FREQ_F2           0x0c
406596afd4SAlex Deucher #define MC_CG_ARB_FREQ_F3           0x0d
416596afd4SAlex Deucher 
426596afd4SAlex Deucher #define MC_CG_SEQ_DRAMCONF_S0       0x05
436596afd4SAlex Deucher #define MC_CG_SEQ_DRAMCONF_S1       0x06
446596afd4SAlex Deucher #define MC_CG_SEQ_YCLK_SUSPEND      0x04
456596afd4SAlex Deucher #define MC_CG_SEQ_YCLK_RESUME       0x0a
466596afd4SAlex Deucher 
476596afd4SAlex Deucher #define SMC_RAM_END 0x8000
486596afd4SAlex Deucher 
496596afd4SAlex Deucher #ifndef BTC_MGCG_SEQUENCE
506596afd4SAlex Deucher #define BTC_MGCG_SEQUENCE  300
516596afd4SAlex Deucher 
526596afd4SAlex Deucher struct rv7xx_ps *rv770_get_ps(struct radeon_ps *rps);
536596afd4SAlex Deucher struct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev);
546596afd4SAlex Deucher struct evergreen_power_info *evergreen_get_pi(struct radeon_device *rdev);
556596afd4SAlex Deucher 
566c7bcceaSAlex Deucher extern int ni_mc_load_microcode(struct radeon_device *rdev);
576596afd4SAlex Deucher 
586596afd4SAlex Deucher //********* BARTS **************//
596596afd4SAlex Deucher static const u32 barts_cgcg_cgls_default[] =
606596afd4SAlex Deucher {
616596afd4SAlex Deucher 	/* Register,   Value,     Mask bits */
626596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
636596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
646596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
656596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
666596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
676596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
686596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
696596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
706596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
716596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
726596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
736596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
746596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
756596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
766596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
776596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
786596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
796596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
806596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
816596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
826596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
836596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
846596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
856596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
866596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
876596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
886596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
896596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
906596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
916596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
926596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
936596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
946596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
956596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
966596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
976596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
986596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
996596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1006596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
1016596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1026596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
1036596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1046596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
1056596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1066596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
1076596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1086596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
1096596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff
1106596afd4SAlex Deucher };
1116596afd4SAlex Deucher #define BARTS_CGCG_CGLS_DEFAULT_LENGTH sizeof(barts_cgcg_cgls_default) / (3 * sizeof(u32))
1126596afd4SAlex Deucher 
1136596afd4SAlex Deucher static const u32 barts_cgcg_cgls_disable[] =
1146596afd4SAlex Deucher {
1156596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
1166596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1176596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
1186596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1196596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
1206596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1216596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
1226596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1236596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
1246596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1256596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
1266596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1276596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
1286596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1296596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
1306596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1316596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
1326596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1336596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
1346596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1356596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
1366596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1376596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
1386596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1396596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
1406596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1416596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
1426596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1436596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
1446596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1456596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
1466596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1476596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
1486596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1496596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
1506596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1516596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
1526596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1536596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
1546596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1556596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
1566596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1576596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
1586596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1596596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
1606596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1616596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
1626596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1636596afd4SAlex Deucher 	0x00000644, 0x000f7912, 0x001f4180,
1646596afd4SAlex Deucher 	0x00000644, 0x000f3812, 0x001f4180
1656596afd4SAlex Deucher };
1666596afd4SAlex Deucher #define BARTS_CGCG_CGLS_DISABLE_LENGTH sizeof(barts_cgcg_cgls_disable) / (3 * sizeof(u32))
1676596afd4SAlex Deucher 
1686596afd4SAlex Deucher static const u32 barts_cgcg_cgls_enable[] =
1696596afd4SAlex Deucher {
1706596afd4SAlex Deucher 	/* 0x0000c124, 0x84180000, 0x00180000, */
1716596afd4SAlex Deucher 	0x00000644, 0x000f7892, 0x001f4080,
1726596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
1736596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1746596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
1756596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1766596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
1776596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1786596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
1796596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1806596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
1816596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1826596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
1836596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1846596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
1856596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1866596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
1876596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1886596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
1896596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1906596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
1916596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1926596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
1936596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1946596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
1956596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
1966596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
1976596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
1986596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
1996596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2006596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
2016596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2026596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
2036596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2046596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
2056596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2066596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
2076596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2086596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
2096596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2106596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
2116596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2126596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
2136596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2146596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
2156596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2166596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
2176596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
2186596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
2196596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff
2206596afd4SAlex Deucher };
2216596afd4SAlex Deucher #define BARTS_CGCG_CGLS_ENABLE_LENGTH sizeof(barts_cgcg_cgls_enable) / (3 * sizeof(u32))
2226596afd4SAlex Deucher 
2236596afd4SAlex Deucher static const u32 barts_mgcg_default[] =
2246596afd4SAlex Deucher {
2256596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
2266596afd4SAlex Deucher 	0x00005448, 0x00000100, 0xffffffff,
2276596afd4SAlex Deucher 	0x000055e4, 0x00600100, 0xffffffff,
2286596afd4SAlex Deucher 	0x0000160c, 0x00000100, 0xffffffff,
2296596afd4SAlex Deucher 	0x0000c164, 0x00000100, 0xffffffff,
2306596afd4SAlex Deucher 	0x00008a18, 0x00000100, 0xffffffff,
2316596afd4SAlex Deucher 	0x0000897c, 0x06000100, 0xffffffff,
2326596afd4SAlex Deucher 	0x00008b28, 0x00000100, 0xffffffff,
2336596afd4SAlex Deucher 	0x00009144, 0x00000100, 0xffffffff,
2346596afd4SAlex Deucher 	0x00009a60, 0x00000100, 0xffffffff,
2356596afd4SAlex Deucher 	0x00009868, 0x00000100, 0xffffffff,
2366596afd4SAlex Deucher 	0x00008d58, 0x00000100, 0xffffffff,
2376596afd4SAlex Deucher 	0x00009510, 0x00000100, 0xffffffff,
2386596afd4SAlex Deucher 	0x0000949c, 0x00000100, 0xffffffff,
2396596afd4SAlex Deucher 	0x00009654, 0x00000100, 0xffffffff,
2406596afd4SAlex Deucher 	0x00009030, 0x00000100, 0xffffffff,
2416596afd4SAlex Deucher 	0x00009034, 0x00000100, 0xffffffff,
2426596afd4SAlex Deucher 	0x00009038, 0x00000100, 0xffffffff,
2436596afd4SAlex Deucher 	0x0000903c, 0x00000100, 0xffffffff,
2446596afd4SAlex Deucher 	0x00009040, 0x00000100, 0xffffffff,
2456596afd4SAlex Deucher 	0x0000a200, 0x00000100, 0xffffffff,
2466596afd4SAlex Deucher 	0x0000a204, 0x00000100, 0xffffffff,
2476596afd4SAlex Deucher 	0x0000a208, 0x00000100, 0xffffffff,
2486596afd4SAlex Deucher 	0x0000a20c, 0x00000100, 0xffffffff,
2496596afd4SAlex Deucher 	0x0000977c, 0x00000100, 0xffffffff,
2506596afd4SAlex Deucher 	0x00003f80, 0x00000100, 0xffffffff,
2516596afd4SAlex Deucher 	0x0000a210, 0x00000100, 0xffffffff,
2526596afd4SAlex Deucher 	0x0000a214, 0x00000100, 0xffffffff,
2536596afd4SAlex Deucher 	0x000004d8, 0x00000100, 0xffffffff,
2546596afd4SAlex Deucher 	0x00009784, 0x00000100, 0xffffffff,
2556596afd4SAlex Deucher 	0x00009698, 0x00000100, 0xffffffff,
2566596afd4SAlex Deucher 	0x000004d4, 0x00000200, 0xffffffff,
2576596afd4SAlex Deucher 	0x000004d0, 0x00000000, 0xffffffff,
2586596afd4SAlex Deucher 	0x000030cc, 0x00000100, 0xffffffff,
2596596afd4SAlex Deucher 	0x0000d0c0, 0xff000100, 0xffffffff,
2606596afd4SAlex Deucher 	0x0000802c, 0x40000000, 0xffffffff,
2616596afd4SAlex Deucher 	0x0000915c, 0x00010000, 0xffffffff,
2626596afd4SAlex Deucher 	0x00009160, 0x00030002, 0xffffffff,
2636596afd4SAlex Deucher 	0x00009164, 0x00050004, 0xffffffff,
2646596afd4SAlex Deucher 	0x00009168, 0x00070006, 0xffffffff,
2656596afd4SAlex Deucher 	0x00009178, 0x00070000, 0xffffffff,
2666596afd4SAlex Deucher 	0x0000917c, 0x00030002, 0xffffffff,
2676596afd4SAlex Deucher 	0x00009180, 0x00050004, 0xffffffff,
2686596afd4SAlex Deucher 	0x0000918c, 0x00010006, 0xffffffff,
2696596afd4SAlex Deucher 	0x00009190, 0x00090008, 0xffffffff,
2706596afd4SAlex Deucher 	0x00009194, 0x00070000, 0xffffffff,
2716596afd4SAlex Deucher 	0x00009198, 0x00030002, 0xffffffff,
2726596afd4SAlex Deucher 	0x0000919c, 0x00050004, 0xffffffff,
2736596afd4SAlex Deucher 	0x000091a8, 0x00010006, 0xffffffff,
2746596afd4SAlex Deucher 	0x000091ac, 0x00090008, 0xffffffff,
2756596afd4SAlex Deucher 	0x000091b0, 0x00070000, 0xffffffff,
2766596afd4SAlex Deucher 	0x000091b4, 0x00030002, 0xffffffff,
2776596afd4SAlex Deucher 	0x000091b8, 0x00050004, 0xffffffff,
2786596afd4SAlex Deucher 	0x000091c4, 0x00010006, 0xffffffff,
2796596afd4SAlex Deucher 	0x000091c8, 0x00090008, 0xffffffff,
2806596afd4SAlex Deucher 	0x000091cc, 0x00070000, 0xffffffff,
2816596afd4SAlex Deucher 	0x000091d0, 0x00030002, 0xffffffff,
2826596afd4SAlex Deucher 	0x000091d4, 0x00050004, 0xffffffff,
2836596afd4SAlex Deucher 	0x000091e0, 0x00010006, 0xffffffff,
2846596afd4SAlex Deucher 	0x000091e4, 0x00090008, 0xffffffff,
2856596afd4SAlex Deucher 	0x000091e8, 0x00000000, 0xffffffff,
2866596afd4SAlex Deucher 	0x000091ec, 0x00070000, 0xffffffff,
2876596afd4SAlex Deucher 	0x000091f0, 0x00030002, 0xffffffff,
2886596afd4SAlex Deucher 	0x000091f4, 0x00050004, 0xffffffff,
2896596afd4SAlex Deucher 	0x00009200, 0x00010006, 0xffffffff,
2906596afd4SAlex Deucher 	0x00009204, 0x00090008, 0xffffffff,
2916596afd4SAlex Deucher 	0x00009208, 0x00070000, 0xffffffff,
2926596afd4SAlex Deucher 	0x0000920c, 0x00030002, 0xffffffff,
2936596afd4SAlex Deucher 	0x00009210, 0x00050004, 0xffffffff,
2946596afd4SAlex Deucher 	0x0000921c, 0x00010006, 0xffffffff,
2956596afd4SAlex Deucher 	0x00009220, 0x00090008, 0xffffffff,
2966596afd4SAlex Deucher 	0x00009224, 0x00070000, 0xffffffff,
2976596afd4SAlex Deucher 	0x00009228, 0x00030002, 0xffffffff,
2986596afd4SAlex Deucher 	0x0000922c, 0x00050004, 0xffffffff,
2996596afd4SAlex Deucher 	0x00009238, 0x00010006, 0xffffffff,
3006596afd4SAlex Deucher 	0x0000923c, 0x00090008, 0xffffffff,
3016596afd4SAlex Deucher 	0x00009294, 0x00000000, 0xffffffff,
3026596afd4SAlex Deucher 	0x0000802c, 0x40010000, 0xffffffff,
3036596afd4SAlex Deucher 	0x0000915c, 0x00010000, 0xffffffff,
3046596afd4SAlex Deucher 	0x00009160, 0x00030002, 0xffffffff,
3056596afd4SAlex Deucher 	0x00009164, 0x00050004, 0xffffffff,
3066596afd4SAlex Deucher 	0x00009168, 0x00070006, 0xffffffff,
3076596afd4SAlex Deucher 	0x00009178, 0x00070000, 0xffffffff,
3086596afd4SAlex Deucher 	0x0000917c, 0x00030002, 0xffffffff,
3096596afd4SAlex Deucher 	0x00009180, 0x00050004, 0xffffffff,
3106596afd4SAlex Deucher 	0x0000918c, 0x00010006, 0xffffffff,
3116596afd4SAlex Deucher 	0x00009190, 0x00090008, 0xffffffff,
3126596afd4SAlex Deucher 	0x00009194, 0x00070000, 0xffffffff,
3136596afd4SAlex Deucher 	0x00009198, 0x00030002, 0xffffffff,
3146596afd4SAlex Deucher 	0x0000919c, 0x00050004, 0xffffffff,
3156596afd4SAlex Deucher 	0x000091a8, 0x00010006, 0xffffffff,
3166596afd4SAlex Deucher 	0x000091ac, 0x00090008, 0xffffffff,
3176596afd4SAlex Deucher 	0x000091b0, 0x00070000, 0xffffffff,
3186596afd4SAlex Deucher 	0x000091b4, 0x00030002, 0xffffffff,
3196596afd4SAlex Deucher 	0x000091b8, 0x00050004, 0xffffffff,
3206596afd4SAlex Deucher 	0x000091c4, 0x00010006, 0xffffffff,
3216596afd4SAlex Deucher 	0x000091c8, 0x00090008, 0xffffffff,
3226596afd4SAlex Deucher 	0x000091cc, 0x00070000, 0xffffffff,
3236596afd4SAlex Deucher 	0x000091d0, 0x00030002, 0xffffffff,
3246596afd4SAlex Deucher 	0x000091d4, 0x00050004, 0xffffffff,
3256596afd4SAlex Deucher 	0x000091e0, 0x00010006, 0xffffffff,
3266596afd4SAlex Deucher 	0x000091e4, 0x00090008, 0xffffffff,
3276596afd4SAlex Deucher 	0x000091e8, 0x00000000, 0xffffffff,
3286596afd4SAlex Deucher 	0x000091ec, 0x00070000, 0xffffffff,
3296596afd4SAlex Deucher 	0x000091f0, 0x00030002, 0xffffffff,
3306596afd4SAlex Deucher 	0x000091f4, 0x00050004, 0xffffffff,
3316596afd4SAlex Deucher 	0x00009200, 0x00010006, 0xffffffff,
3326596afd4SAlex Deucher 	0x00009204, 0x00090008, 0xffffffff,
3336596afd4SAlex Deucher 	0x00009208, 0x00070000, 0xffffffff,
3346596afd4SAlex Deucher 	0x0000920c, 0x00030002, 0xffffffff,
3356596afd4SAlex Deucher 	0x00009210, 0x00050004, 0xffffffff,
3366596afd4SAlex Deucher 	0x0000921c, 0x00010006, 0xffffffff,
3376596afd4SAlex Deucher 	0x00009220, 0x00090008, 0xffffffff,
3386596afd4SAlex Deucher 	0x00009224, 0x00070000, 0xffffffff,
3396596afd4SAlex Deucher 	0x00009228, 0x00030002, 0xffffffff,
3406596afd4SAlex Deucher 	0x0000922c, 0x00050004, 0xffffffff,
3416596afd4SAlex Deucher 	0x00009238, 0x00010006, 0xffffffff,
3426596afd4SAlex Deucher 	0x0000923c, 0x00090008, 0xffffffff,
3436596afd4SAlex Deucher 	0x00009294, 0x00000000, 0xffffffff,
3446596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
3456596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
3466596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3476596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
3486596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3496596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
3506596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3516596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
3526596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3536596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
3546596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3556596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
3566596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3576596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
3586596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3596596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
3606596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3616596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
3626596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3636596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
3646596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3656596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
3666596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3676596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
3686596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff
3696596afd4SAlex Deucher };
3706596afd4SAlex Deucher #define BARTS_MGCG_DEFAULT_LENGTH sizeof(barts_mgcg_default) / (3 * sizeof(u32))
3716596afd4SAlex Deucher 
3726596afd4SAlex Deucher static const u32 barts_mgcg_disable[] =
3736596afd4SAlex Deucher {
3746596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
3756596afd4SAlex Deucher 	0x000008f8, 0x00000000, 0xffffffff,
3766596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
3776596afd4SAlex Deucher 	0x000008f8, 0x00000001, 0xffffffff,
3786596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
3796596afd4SAlex Deucher 	0x000008f8, 0x00000002, 0xffffffff,
3806596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
3816596afd4SAlex Deucher 	0x000008f8, 0x00000003, 0xffffffff,
3826596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
3836596afd4SAlex Deucher 	0x00009150, 0x00600000, 0xffffffff
3846596afd4SAlex Deucher };
3856596afd4SAlex Deucher #define BARTS_MGCG_DISABLE_LENGTH sizeof(barts_mgcg_disable) / (3 * sizeof(u32))
3866596afd4SAlex Deucher 
3876596afd4SAlex Deucher static const u32 barts_mgcg_enable[] =
3886596afd4SAlex Deucher {
3896596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
3906596afd4SAlex Deucher 	0x000008f8, 0x00000000, 0xffffffff,
3916596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3926596afd4SAlex Deucher 	0x000008f8, 0x00000001, 0xffffffff,
3936596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3946596afd4SAlex Deucher 	0x000008f8, 0x00000002, 0xffffffff,
3956596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3966596afd4SAlex Deucher 	0x000008f8, 0x00000003, 0xffffffff,
3976596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
3986596afd4SAlex Deucher 	0x00009150, 0x81944000, 0xffffffff
3996596afd4SAlex Deucher };
4006596afd4SAlex Deucher #define BARTS_MGCG_ENABLE_LENGTH sizeof(barts_mgcg_enable) / (3 * sizeof(u32))
4016596afd4SAlex Deucher 
4026596afd4SAlex Deucher //********* CAICOS **************//
4036596afd4SAlex Deucher static const u32 caicos_cgcg_cgls_default[] =
4046596afd4SAlex Deucher {
4056596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
4066596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4076596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
4086596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4096596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
4106596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4116596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
4126596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4136596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
4146596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4156596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
4166596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4176596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
4186596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4196596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
4206596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4216596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
4226596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4236596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
4246596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4256596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
4266596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4276596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
4286596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4296596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
4306596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4316596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
4326596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4336596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
4346596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4356596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
4366596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4376596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
4386596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4396596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
4406596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4416596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
4426596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4436596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
4446596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4456596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
4466596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4476596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
4486596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4496596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
4506596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4516596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
4526596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff
4536596afd4SAlex Deucher };
4546596afd4SAlex Deucher #define CAICOS_CGCG_CGLS_DEFAULT_LENGTH sizeof(caicos_cgcg_cgls_default) / (3 * sizeof(u32))
4556596afd4SAlex Deucher 
4566596afd4SAlex Deucher static const u32 caicos_cgcg_cgls_disable[] =
4576596afd4SAlex Deucher {
4586596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
4596596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4606596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
4616596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4626596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
4636596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4646596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
4656596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4666596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
4676596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4686596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
4696596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4706596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
4716596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4726596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
4736596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4746596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
4756596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4766596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
4776596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4786596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
4796596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4806596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
4816596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
4826596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
4836596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4846596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
4856596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4866596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
4876596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4886596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
4896596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4906596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
4916596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4926596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
4936596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4946596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
4956596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4966596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
4976596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
4986596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
4996596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5006596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
5016596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5026596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
5036596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5046596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
5056596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5066596afd4SAlex Deucher 	0x00000644, 0x000f7912, 0x001f4180,
5076596afd4SAlex Deucher 	0x00000644, 0x000f3812, 0x001f4180
5086596afd4SAlex Deucher };
5096596afd4SAlex Deucher #define CAICOS_CGCG_CGLS_DISABLE_LENGTH sizeof(caicos_cgcg_cgls_disable) / (3 * sizeof(u32))
5106596afd4SAlex Deucher 
5116596afd4SAlex Deucher static const u32 caicos_cgcg_cgls_enable[] =
5126596afd4SAlex Deucher {
5136596afd4SAlex Deucher 	/* 0x0000c124, 0x84180000, 0x00180000, */
5146596afd4SAlex Deucher 	0x00000644, 0x000f7892, 0x001f4080,
5156596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
5166596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5176596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
5186596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5196596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
5206596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5216596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
5226596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5236596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
5246596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5256596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
5266596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5276596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
5286596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5296596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
5306596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5316596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
5326596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5336596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
5346596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5356596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
5366596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5376596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
5386596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
5396596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
5406596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5416596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
5426596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5436596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
5446596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5456596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
5466596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5476596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
5486596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5496596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
5506596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5516596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
5526596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5536596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
5546596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5556596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
5566596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5576596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
5586596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5596596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
5606596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
5616596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
5626596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff
5636596afd4SAlex Deucher };
5646596afd4SAlex Deucher #define CAICOS_CGCG_CGLS_ENABLE_LENGTH sizeof(caicos_cgcg_cgls_enable) / (3 * sizeof(u32))
5656596afd4SAlex Deucher 
5666596afd4SAlex Deucher static const u32 caicos_mgcg_default[] =
5676596afd4SAlex Deucher {
5686596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
5696596afd4SAlex Deucher 	0x00005448, 0x00000100, 0xffffffff,
5706596afd4SAlex Deucher 	0x000055e4, 0x00600100, 0xffffffff,
5716596afd4SAlex Deucher 	0x0000160c, 0x00000100, 0xffffffff,
5726596afd4SAlex Deucher 	0x0000c164, 0x00000100, 0xffffffff,
5736596afd4SAlex Deucher 	0x00008a18, 0x00000100, 0xffffffff,
5746596afd4SAlex Deucher 	0x0000897c, 0x06000100, 0xffffffff,
5756596afd4SAlex Deucher 	0x00008b28, 0x00000100, 0xffffffff,
5766596afd4SAlex Deucher 	0x00009144, 0x00000100, 0xffffffff,
5776596afd4SAlex Deucher 	0x00009a60, 0x00000100, 0xffffffff,
5786596afd4SAlex Deucher 	0x00009868, 0x00000100, 0xffffffff,
5796596afd4SAlex Deucher 	0x00008d58, 0x00000100, 0xffffffff,
5806596afd4SAlex Deucher 	0x00009510, 0x00000100, 0xffffffff,
5816596afd4SAlex Deucher 	0x0000949c, 0x00000100, 0xffffffff,
5826596afd4SAlex Deucher 	0x00009654, 0x00000100, 0xffffffff,
5836596afd4SAlex Deucher 	0x00009030, 0x00000100, 0xffffffff,
5846596afd4SAlex Deucher 	0x00009034, 0x00000100, 0xffffffff,
5856596afd4SAlex Deucher 	0x00009038, 0x00000100, 0xffffffff,
5866596afd4SAlex Deucher 	0x0000903c, 0x00000100, 0xffffffff,
5876596afd4SAlex Deucher 	0x00009040, 0x00000100, 0xffffffff,
5886596afd4SAlex Deucher 	0x0000a200, 0x00000100, 0xffffffff,
5896596afd4SAlex Deucher 	0x0000a204, 0x00000100, 0xffffffff,
5906596afd4SAlex Deucher 	0x0000a208, 0x00000100, 0xffffffff,
5916596afd4SAlex Deucher 	0x0000a20c, 0x00000100, 0xffffffff,
5926596afd4SAlex Deucher 	0x0000977c, 0x00000100, 0xffffffff,
5936596afd4SAlex Deucher 	0x00003f80, 0x00000100, 0xffffffff,
5946596afd4SAlex Deucher 	0x0000a210, 0x00000100, 0xffffffff,
5956596afd4SAlex Deucher 	0x0000a214, 0x00000100, 0xffffffff,
5966596afd4SAlex Deucher 	0x000004d8, 0x00000100, 0xffffffff,
5976596afd4SAlex Deucher 	0x00009784, 0x00000100, 0xffffffff,
5986596afd4SAlex Deucher 	0x00009698, 0x00000100, 0xffffffff,
5996596afd4SAlex Deucher 	0x000004d4, 0x00000200, 0xffffffff,
6006596afd4SAlex Deucher 	0x000004d0, 0x00000000, 0xffffffff,
6016596afd4SAlex Deucher 	0x000030cc, 0x00000100, 0xffffffff,
6026596afd4SAlex Deucher 	0x0000d0c0, 0xff000100, 0xffffffff,
6036596afd4SAlex Deucher 	0x0000915c, 0x00010000, 0xffffffff,
6046596afd4SAlex Deucher 	0x00009160, 0x00030002, 0xffffffff,
6056596afd4SAlex Deucher 	0x00009164, 0x00050004, 0xffffffff,
6066596afd4SAlex Deucher 	0x00009168, 0x00070006, 0xffffffff,
6076596afd4SAlex Deucher 	0x00009178, 0x00070000, 0xffffffff,
6086596afd4SAlex Deucher 	0x0000917c, 0x00030002, 0xffffffff,
6096596afd4SAlex Deucher 	0x00009180, 0x00050004, 0xffffffff,
6106596afd4SAlex Deucher 	0x0000918c, 0x00010006, 0xffffffff,
6116596afd4SAlex Deucher 	0x00009190, 0x00090008, 0xffffffff,
6126596afd4SAlex Deucher 	0x00009194, 0x00070000, 0xffffffff,
6136596afd4SAlex Deucher 	0x00009198, 0x00030002, 0xffffffff,
6146596afd4SAlex Deucher 	0x0000919c, 0x00050004, 0xffffffff,
6156596afd4SAlex Deucher 	0x000091a8, 0x00010006, 0xffffffff,
6166596afd4SAlex Deucher 	0x000091ac, 0x00090008, 0xffffffff,
6176596afd4SAlex Deucher 	0x000091e8, 0x00000000, 0xffffffff,
6186596afd4SAlex Deucher 	0x00009294, 0x00000000, 0xffffffff,
6196596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
6206596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6216596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
6226596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6236596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
6246596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6256596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
6266596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6276596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
6286596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6296596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
6306596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6316596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
6326596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6336596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
6346596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6356596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
6366596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6376596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
6386596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6396596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
6406596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6416596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
6426596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff
6436596afd4SAlex Deucher };
6446596afd4SAlex Deucher #define CAICOS_MGCG_DEFAULT_LENGTH sizeof(caicos_mgcg_default) / (3 * sizeof(u32))
6456596afd4SAlex Deucher 
6466596afd4SAlex Deucher static const u32 caicos_mgcg_disable[] =
6476596afd4SAlex Deucher {
6486596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
6496596afd4SAlex Deucher 	0x000008f8, 0x00000000, 0xffffffff,
6506596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
6516596afd4SAlex Deucher 	0x000008f8, 0x00000001, 0xffffffff,
6526596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
6536596afd4SAlex Deucher 	0x000008f8, 0x00000002, 0xffffffff,
6546596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
6556596afd4SAlex Deucher 	0x000008f8, 0x00000003, 0xffffffff,
6566596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
6576596afd4SAlex Deucher 	0x00009150, 0x00600000, 0xffffffff
6586596afd4SAlex Deucher };
6596596afd4SAlex Deucher #define CAICOS_MGCG_DISABLE_LENGTH sizeof(caicos_mgcg_disable) / (3 * sizeof(u32))
6606596afd4SAlex Deucher 
6616596afd4SAlex Deucher static const u32 caicos_mgcg_enable[] =
6626596afd4SAlex Deucher {
6636596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
6646596afd4SAlex Deucher 	0x000008f8, 0x00000000, 0xffffffff,
6656596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6666596afd4SAlex Deucher 	0x000008f8, 0x00000001, 0xffffffff,
6676596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6686596afd4SAlex Deucher 	0x000008f8, 0x00000002, 0xffffffff,
6696596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6706596afd4SAlex Deucher 	0x000008f8, 0x00000003, 0xffffffff,
6716596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6726596afd4SAlex Deucher 	0x00009150, 0x46944040, 0xffffffff
6736596afd4SAlex Deucher };
6746596afd4SAlex Deucher #define CAICOS_MGCG_ENABLE_LENGTH sizeof(caicos_mgcg_enable) / (3 * sizeof(u32))
6756596afd4SAlex Deucher 
6766596afd4SAlex Deucher //********* TURKS **************//
6776596afd4SAlex Deucher static const u32 turks_cgcg_cgls_default[] =
6786596afd4SAlex Deucher {
6796596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
6806596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6816596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
6826596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6836596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
6846596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6856596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
6866596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6876596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
6886596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6896596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
6906596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6916596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
6926596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6936596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
6946596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6956596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
6966596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6976596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
6986596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
6996596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
7006596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7016596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
7026596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7036596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
7046596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7056596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
7066596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7076596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
7086596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7096596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
7106596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7116596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
7126596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7136596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
7146596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7156596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
7166596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7176596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
7186596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7196596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
7206596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7216596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
7226596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7236596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
7246596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7256596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
7266596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff
7276596afd4SAlex Deucher };
7286596afd4SAlex Deucher #define TURKS_CGCG_CGLS_DEFAULT_LENGTH  sizeof(turks_cgcg_cgls_default) / (3 * sizeof(u32))
7296596afd4SAlex Deucher 
7306596afd4SAlex Deucher static const u32 turks_cgcg_cgls_disable[] =
7316596afd4SAlex Deucher {
7326596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
7336596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7346596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
7356596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7366596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
7376596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7386596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
7396596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7406596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
7416596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7426596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
7436596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7446596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
7456596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7466596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
7476596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7486596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
7496596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7506596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
7516596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7526596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
7536596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7546596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
7556596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
7566596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
7576596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7586596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
7596596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7606596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
7616596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7626596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
7636596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7646596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
7656596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7666596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
7676596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7686596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
7696596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7706596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
7716596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7726596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
7736596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7746596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
7756596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7766596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
7776596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7786596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
7796596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7806596afd4SAlex Deucher 	0x00000644, 0x000f7912, 0x001f4180,
7816596afd4SAlex Deucher 	0x00000644, 0x000f3812, 0x001f4180
7826596afd4SAlex Deucher };
7836596afd4SAlex Deucher #define TURKS_CGCG_CGLS_DISABLE_LENGTH sizeof(turks_cgcg_cgls_disable) / (3 * sizeof(u32))
7846596afd4SAlex Deucher 
7856596afd4SAlex Deucher static const u32 turks_cgcg_cgls_enable[] =
7866596afd4SAlex Deucher {
7876596afd4SAlex Deucher 	/* 0x0000c124, 0x84180000, 0x00180000, */
7886596afd4SAlex Deucher 	0x00000644, 0x000f7892, 0x001f4080,
7896596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
7906596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7916596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
7926596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7936596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
7946596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7956596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
7966596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7976596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
7986596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
7996596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
8006596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8016596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
8026596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8036596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
8046596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8056596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
8066596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8076596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
8086596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8096596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
8106596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8116596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
8126596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
8136596afd4SAlex Deucher 	0x000008f8, 0x00000020, 0xffffffff,
8146596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8156596afd4SAlex Deucher 	0x000008f8, 0x00000021, 0xffffffff,
8166596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8176596afd4SAlex Deucher 	0x000008f8, 0x00000022, 0xffffffff,
8186596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8196596afd4SAlex Deucher 	0x000008f8, 0x00000023, 0xffffffff,
8206596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8216596afd4SAlex Deucher 	0x000008f8, 0x00000024, 0xffffffff,
8226596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8236596afd4SAlex Deucher 	0x000008f8, 0x00000025, 0xffffffff,
8246596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8256596afd4SAlex Deucher 	0x000008f8, 0x00000026, 0xffffffff,
8266596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8276596afd4SAlex Deucher 	0x000008f8, 0x00000027, 0xffffffff,
8286596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8296596afd4SAlex Deucher 	0x000008f8, 0x00000028, 0xffffffff,
8306596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8316596afd4SAlex Deucher 	0x000008f8, 0x00000029, 0xffffffff,
8326596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8336596afd4SAlex Deucher 	0x000008f8, 0x0000002a, 0xffffffff,
8346596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
8356596afd4SAlex Deucher 	0x000008f8, 0x0000002b, 0xffffffff,
8366596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff
8376596afd4SAlex Deucher };
8386596afd4SAlex Deucher #define TURKS_CGCG_CGLS_ENABLE_LENGTH sizeof(turks_cgcg_cgls_enable) / (3 * sizeof(u32))
8396596afd4SAlex Deucher 
8406596afd4SAlex Deucher // These are the sequences for turks_mgcg_shls
8416596afd4SAlex Deucher static const u32 turks_mgcg_default[] =
8426596afd4SAlex Deucher {
8436596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
8446596afd4SAlex Deucher 	0x00005448, 0x00000100, 0xffffffff,
8456596afd4SAlex Deucher 	0x000055e4, 0x00600100, 0xffffffff,
8466596afd4SAlex Deucher 	0x0000160c, 0x00000100, 0xffffffff,
8476596afd4SAlex Deucher 	0x0000c164, 0x00000100, 0xffffffff,
8486596afd4SAlex Deucher 	0x00008a18, 0x00000100, 0xffffffff,
8496596afd4SAlex Deucher 	0x0000897c, 0x06000100, 0xffffffff,
8506596afd4SAlex Deucher 	0x00008b28, 0x00000100, 0xffffffff,
8516596afd4SAlex Deucher 	0x00009144, 0x00000100, 0xffffffff,
8526596afd4SAlex Deucher 	0x00009a60, 0x00000100, 0xffffffff,
8536596afd4SAlex Deucher 	0x00009868, 0x00000100, 0xffffffff,
8546596afd4SAlex Deucher 	0x00008d58, 0x00000100, 0xffffffff,
8556596afd4SAlex Deucher 	0x00009510, 0x00000100, 0xffffffff,
8566596afd4SAlex Deucher 	0x0000949c, 0x00000100, 0xffffffff,
8576596afd4SAlex Deucher 	0x00009654, 0x00000100, 0xffffffff,
8586596afd4SAlex Deucher 	0x00009030, 0x00000100, 0xffffffff,
8596596afd4SAlex Deucher 	0x00009034, 0x00000100, 0xffffffff,
8606596afd4SAlex Deucher 	0x00009038, 0x00000100, 0xffffffff,
8616596afd4SAlex Deucher 	0x0000903c, 0x00000100, 0xffffffff,
8626596afd4SAlex Deucher 	0x00009040, 0x00000100, 0xffffffff,
8636596afd4SAlex Deucher 	0x0000a200, 0x00000100, 0xffffffff,
8646596afd4SAlex Deucher 	0x0000a204, 0x00000100, 0xffffffff,
8656596afd4SAlex Deucher 	0x0000a208, 0x00000100, 0xffffffff,
8666596afd4SAlex Deucher 	0x0000a20c, 0x00000100, 0xffffffff,
8676596afd4SAlex Deucher 	0x0000977c, 0x00000100, 0xffffffff,
8686596afd4SAlex Deucher 	0x00003f80, 0x00000100, 0xffffffff,
8696596afd4SAlex Deucher 	0x0000a210, 0x00000100, 0xffffffff,
8706596afd4SAlex Deucher 	0x0000a214, 0x00000100, 0xffffffff,
8716596afd4SAlex Deucher 	0x000004d8, 0x00000100, 0xffffffff,
8726596afd4SAlex Deucher 	0x00009784, 0x00000100, 0xffffffff,
8736596afd4SAlex Deucher 	0x00009698, 0x00000100, 0xffffffff,
8746596afd4SAlex Deucher 	0x000004d4, 0x00000200, 0xffffffff,
8756596afd4SAlex Deucher 	0x000004d0, 0x00000000, 0xffffffff,
8766596afd4SAlex Deucher 	0x000030cc, 0x00000100, 0xffffffff,
8776596afd4SAlex Deucher 	0x0000d0c0, 0x00000100, 0xffffffff,
8786596afd4SAlex Deucher 	0x0000915c, 0x00010000, 0xffffffff,
8796596afd4SAlex Deucher 	0x00009160, 0x00030002, 0xffffffff,
8806596afd4SAlex Deucher 	0x00009164, 0x00050004, 0xffffffff,
8816596afd4SAlex Deucher 	0x00009168, 0x00070006, 0xffffffff,
8826596afd4SAlex Deucher 	0x00009178, 0x00070000, 0xffffffff,
8836596afd4SAlex Deucher 	0x0000917c, 0x00030002, 0xffffffff,
8846596afd4SAlex Deucher 	0x00009180, 0x00050004, 0xffffffff,
8856596afd4SAlex Deucher 	0x0000918c, 0x00010006, 0xffffffff,
8866596afd4SAlex Deucher 	0x00009190, 0x00090008, 0xffffffff,
8876596afd4SAlex Deucher 	0x00009194, 0x00070000, 0xffffffff,
8886596afd4SAlex Deucher 	0x00009198, 0x00030002, 0xffffffff,
8896596afd4SAlex Deucher 	0x0000919c, 0x00050004, 0xffffffff,
8906596afd4SAlex Deucher 	0x000091a8, 0x00010006, 0xffffffff,
8916596afd4SAlex Deucher 	0x000091ac, 0x00090008, 0xffffffff,
8926596afd4SAlex Deucher 	0x000091b0, 0x00070000, 0xffffffff,
8936596afd4SAlex Deucher 	0x000091b4, 0x00030002, 0xffffffff,
8946596afd4SAlex Deucher 	0x000091b8, 0x00050004, 0xffffffff,
8956596afd4SAlex Deucher 	0x000091c4, 0x00010006, 0xffffffff,
8966596afd4SAlex Deucher 	0x000091c8, 0x00090008, 0xffffffff,
8976596afd4SAlex Deucher 	0x000091cc, 0x00070000, 0xffffffff,
8986596afd4SAlex Deucher 	0x000091d0, 0x00030002, 0xffffffff,
8996596afd4SAlex Deucher 	0x000091d4, 0x00050004, 0xffffffff,
9006596afd4SAlex Deucher 	0x000091e0, 0x00010006, 0xffffffff,
9016596afd4SAlex Deucher 	0x000091e4, 0x00090008, 0xffffffff,
9026596afd4SAlex Deucher 	0x000091e8, 0x00000000, 0xffffffff,
9036596afd4SAlex Deucher 	0x000091ec, 0x00070000, 0xffffffff,
9046596afd4SAlex Deucher 	0x000091f0, 0x00030002, 0xffffffff,
9056596afd4SAlex Deucher 	0x000091f4, 0x00050004, 0xffffffff,
9066596afd4SAlex Deucher 	0x00009200, 0x00010006, 0xffffffff,
9076596afd4SAlex Deucher 	0x00009204, 0x00090008, 0xffffffff,
9086596afd4SAlex Deucher 	0x00009208, 0x00070000, 0xffffffff,
9096596afd4SAlex Deucher 	0x0000920c, 0x00030002, 0xffffffff,
9106596afd4SAlex Deucher 	0x00009210, 0x00050004, 0xffffffff,
9116596afd4SAlex Deucher 	0x0000921c, 0x00010006, 0xffffffff,
9126596afd4SAlex Deucher 	0x00009220, 0x00090008, 0xffffffff,
9136596afd4SAlex Deucher 	0x00009294, 0x00000000, 0xffffffff,
9146596afd4SAlex Deucher 	0x000008f8, 0x00000010, 0xffffffff,
9156596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9166596afd4SAlex Deucher 	0x000008f8, 0x00000011, 0xffffffff,
9176596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9186596afd4SAlex Deucher 	0x000008f8, 0x00000012, 0xffffffff,
9196596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9206596afd4SAlex Deucher 	0x000008f8, 0x00000013, 0xffffffff,
9216596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9226596afd4SAlex Deucher 	0x000008f8, 0x00000014, 0xffffffff,
9236596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9246596afd4SAlex Deucher 	0x000008f8, 0x00000015, 0xffffffff,
9256596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9266596afd4SAlex Deucher 	0x000008f8, 0x00000016, 0xffffffff,
9276596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9286596afd4SAlex Deucher 	0x000008f8, 0x00000017, 0xffffffff,
9296596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9306596afd4SAlex Deucher 	0x000008f8, 0x00000018, 0xffffffff,
9316596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9326596afd4SAlex Deucher 	0x000008f8, 0x00000019, 0xffffffff,
9336596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9346596afd4SAlex Deucher 	0x000008f8, 0x0000001a, 0xffffffff,
9356596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9366596afd4SAlex Deucher 	0x000008f8, 0x0000001b, 0xffffffff,
9376596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff
9386596afd4SAlex Deucher };
9396596afd4SAlex Deucher #define TURKS_MGCG_DEFAULT_LENGTH sizeof(turks_mgcg_default) / (3 * sizeof(u32))
9406596afd4SAlex Deucher 
9416596afd4SAlex Deucher static const u32 turks_mgcg_disable[] =
9426596afd4SAlex Deucher {
9436596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
9446596afd4SAlex Deucher 	0x000008f8, 0x00000000, 0xffffffff,
9456596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
9466596afd4SAlex Deucher 	0x000008f8, 0x00000001, 0xffffffff,
9476596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
9486596afd4SAlex Deucher 	0x000008f8, 0x00000002, 0xffffffff,
9496596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
9506596afd4SAlex Deucher 	0x000008f8, 0x00000003, 0xffffffff,
9516596afd4SAlex Deucher 	0x000008fc, 0xffffffff, 0xffffffff,
9526596afd4SAlex Deucher 	0x00009150, 0x00600000, 0xffffffff
9536596afd4SAlex Deucher };
9546596afd4SAlex Deucher #define TURKS_MGCG_DISABLE_LENGTH sizeof(turks_mgcg_disable) / (3 * sizeof(u32))
9556596afd4SAlex Deucher 
9566596afd4SAlex Deucher static const u32 turks_mgcg_enable[] =
9576596afd4SAlex Deucher {
9586596afd4SAlex Deucher 	0x0000802c, 0xc0000000, 0xffffffff,
9596596afd4SAlex Deucher 	0x000008f8, 0x00000000, 0xffffffff,
9606596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9616596afd4SAlex Deucher 	0x000008f8, 0x00000001, 0xffffffff,
9626596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9636596afd4SAlex Deucher 	0x000008f8, 0x00000002, 0xffffffff,
9646596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9656596afd4SAlex Deucher 	0x000008f8, 0x00000003, 0xffffffff,
9666596afd4SAlex Deucher 	0x000008fc, 0x00000000, 0xffffffff,
9676596afd4SAlex Deucher 	0x00009150, 0x6e944000, 0xffffffff
9686596afd4SAlex Deucher };
9696596afd4SAlex Deucher #define TURKS_MGCG_ENABLE_LENGTH sizeof(turks_mgcg_enable) / (3 * sizeof(u32))
9706596afd4SAlex Deucher 
9716596afd4SAlex Deucher #endif
9726596afd4SAlex Deucher 
9736596afd4SAlex Deucher #ifndef BTC_SYSLS_SEQUENCE
9746596afd4SAlex Deucher #define BTC_SYSLS_SEQUENCE  100
9756596afd4SAlex Deucher 
9766596afd4SAlex Deucher 
9776596afd4SAlex Deucher //********* BARTS **************//
9786596afd4SAlex Deucher static const u32 barts_sysls_default[] =
9796596afd4SAlex Deucher {
9806596afd4SAlex Deucher 	/* Register,   Value,     Mask bits */
9816596afd4SAlex Deucher 	0x000055e8, 0x00000000, 0xffffffff,
9826596afd4SAlex Deucher 	0x0000d0bc, 0x00000000, 0xffffffff,
9836596afd4SAlex Deucher 	0x000015c0, 0x000c1401, 0xffffffff,
9846596afd4SAlex Deucher 	0x0000264c, 0x000c0400, 0xffffffff,
9856596afd4SAlex Deucher 	0x00002648, 0x000c0400, 0xffffffff,
9866596afd4SAlex Deucher 	0x00002650, 0x000c0400, 0xffffffff,
9876596afd4SAlex Deucher 	0x000020b8, 0x000c0400, 0xffffffff,
9886596afd4SAlex Deucher 	0x000020bc, 0x000c0400, 0xffffffff,
9896596afd4SAlex Deucher 	0x000020c0, 0x000c0c80, 0xffffffff,
9906596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
9916596afd4SAlex Deucher 	0x0000f4a4, 0x00680fff, 0xffffffff,
9926596afd4SAlex Deucher 	0x000004c8, 0x00000001, 0xffffffff,
9936596afd4SAlex Deucher 	0x000064ec, 0x00000000, 0xffffffff,
9946596afd4SAlex Deucher 	0x00000c7c, 0x00000000, 0xffffffff,
9956596afd4SAlex Deucher 	0x00006dfc, 0x00000000, 0xffffffff
9966596afd4SAlex Deucher };
9976596afd4SAlex Deucher #define BARTS_SYSLS_DEFAULT_LENGTH sizeof(barts_sysls_default) / (3 * sizeof(u32))
9986596afd4SAlex Deucher 
9996596afd4SAlex Deucher static const u32 barts_sysls_disable[] =
10006596afd4SAlex Deucher {
10016596afd4SAlex Deucher 	0x000055e8, 0x00000000, 0xffffffff,
10026596afd4SAlex Deucher 	0x0000d0bc, 0x00000000, 0xffffffff,
10036596afd4SAlex Deucher 	0x000015c0, 0x00041401, 0xffffffff,
10046596afd4SAlex Deucher 	0x0000264c, 0x00040400, 0xffffffff,
10056596afd4SAlex Deucher 	0x00002648, 0x00040400, 0xffffffff,
10066596afd4SAlex Deucher 	0x00002650, 0x00040400, 0xffffffff,
10076596afd4SAlex Deucher 	0x000020b8, 0x00040400, 0xffffffff,
10086596afd4SAlex Deucher 	0x000020bc, 0x00040400, 0xffffffff,
10096596afd4SAlex Deucher 	0x000020c0, 0x00040c80, 0xffffffff,
10106596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
10116596afd4SAlex Deucher 	0x0000f4a4, 0x00680000, 0xffffffff,
10126596afd4SAlex Deucher 	0x000004c8, 0x00000001, 0xffffffff,
10136596afd4SAlex Deucher 	0x000064ec, 0x00007ffd, 0xffffffff,
10146596afd4SAlex Deucher 	0x00000c7c, 0x0000ff00, 0xffffffff,
10156596afd4SAlex Deucher 	0x00006dfc, 0x0000007f, 0xffffffff
10166596afd4SAlex Deucher };
10176596afd4SAlex Deucher #define BARTS_SYSLS_DISABLE_LENGTH sizeof(barts_sysls_disable) / (3 * sizeof(u32))
10186596afd4SAlex Deucher 
10196596afd4SAlex Deucher static const u32 barts_sysls_enable[] =
10206596afd4SAlex Deucher {
10216596afd4SAlex Deucher 	0x000055e8, 0x00000001, 0xffffffff,
10226596afd4SAlex Deucher 	0x0000d0bc, 0x00000100, 0xffffffff,
10236596afd4SAlex Deucher 	0x000015c0, 0x000c1401, 0xffffffff,
10246596afd4SAlex Deucher 	0x0000264c, 0x000c0400, 0xffffffff,
10256596afd4SAlex Deucher 	0x00002648, 0x000c0400, 0xffffffff,
10266596afd4SAlex Deucher 	0x00002650, 0x000c0400, 0xffffffff,
10276596afd4SAlex Deucher 	0x000020b8, 0x000c0400, 0xffffffff,
10286596afd4SAlex Deucher 	0x000020bc, 0x000c0400, 0xffffffff,
10296596afd4SAlex Deucher 	0x000020c0, 0x000c0c80, 0xffffffff,
10306596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
10316596afd4SAlex Deucher 	0x0000f4a4, 0x00680fff, 0xffffffff,
10326596afd4SAlex Deucher 	0x000004c8, 0x00000000, 0xffffffff,
10336596afd4SAlex Deucher 	0x000064ec, 0x00000000, 0xffffffff,
10346596afd4SAlex Deucher 	0x00000c7c, 0x00000000, 0xffffffff,
10356596afd4SAlex Deucher 	0x00006dfc, 0x00000000, 0xffffffff
10366596afd4SAlex Deucher };
10376596afd4SAlex Deucher #define BARTS_SYSLS_ENABLE_LENGTH sizeof(barts_sysls_enable) / (3 * sizeof(u32))
10386596afd4SAlex Deucher 
10396596afd4SAlex Deucher //********* CAICOS **************//
10406596afd4SAlex Deucher static const u32 caicos_sysls_default[] =
10416596afd4SAlex Deucher {
10426596afd4SAlex Deucher 	0x000055e8, 0x00000000, 0xffffffff,
10436596afd4SAlex Deucher 	0x0000d0bc, 0x00000000, 0xffffffff,
10446596afd4SAlex Deucher 	0x000015c0, 0x000c1401, 0xffffffff,
10456596afd4SAlex Deucher 	0x0000264c, 0x000c0400, 0xffffffff,
10466596afd4SAlex Deucher 	0x00002648, 0x000c0400, 0xffffffff,
10476596afd4SAlex Deucher 	0x00002650, 0x000c0400, 0xffffffff,
10486596afd4SAlex Deucher 	0x000020b8, 0x000c0400, 0xffffffff,
10496596afd4SAlex Deucher 	0x000020bc, 0x000c0400, 0xffffffff,
10506596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
10516596afd4SAlex Deucher 	0x0000f4a4, 0x00680fff, 0xffffffff,
10526596afd4SAlex Deucher 	0x000004c8, 0x00000001, 0xffffffff,
10536596afd4SAlex Deucher 	0x000064ec, 0x00000000, 0xffffffff,
10546596afd4SAlex Deucher 	0x00000c7c, 0x00000000, 0xffffffff,
10556596afd4SAlex Deucher 	0x00006dfc, 0x00000000, 0xffffffff
10566596afd4SAlex Deucher };
10576596afd4SAlex Deucher #define CAICOS_SYSLS_DEFAULT_LENGTH sizeof(caicos_sysls_default) / (3 * sizeof(u32))
10586596afd4SAlex Deucher 
10596596afd4SAlex Deucher static const u32 caicos_sysls_disable[] =
10606596afd4SAlex Deucher {
10616596afd4SAlex Deucher 	0x000055e8, 0x00000000, 0xffffffff,
10626596afd4SAlex Deucher 	0x0000d0bc, 0x00000000, 0xffffffff,
10636596afd4SAlex Deucher 	0x000015c0, 0x00041401, 0xffffffff,
10646596afd4SAlex Deucher 	0x0000264c, 0x00040400, 0xffffffff,
10656596afd4SAlex Deucher 	0x00002648, 0x00040400, 0xffffffff,
10666596afd4SAlex Deucher 	0x00002650, 0x00040400, 0xffffffff,
10676596afd4SAlex Deucher 	0x000020b8, 0x00040400, 0xffffffff,
10686596afd4SAlex Deucher 	0x000020bc, 0x00040400, 0xffffffff,
10696596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
10706596afd4SAlex Deucher 	0x0000f4a4, 0x00680000, 0xffffffff,
10716596afd4SAlex Deucher 	0x000004c8, 0x00000001, 0xffffffff,
10726596afd4SAlex Deucher 	0x000064ec, 0x00007ffd, 0xffffffff,
10736596afd4SAlex Deucher 	0x00000c7c, 0x0000ff00, 0xffffffff,
10746596afd4SAlex Deucher 	0x00006dfc, 0x0000007f, 0xffffffff
10756596afd4SAlex Deucher };
10766596afd4SAlex Deucher #define CAICOS_SYSLS_DISABLE_LENGTH sizeof(caicos_sysls_disable) / (3 * sizeof(u32))
10776596afd4SAlex Deucher 
10786596afd4SAlex Deucher static const u32 caicos_sysls_enable[] =
10796596afd4SAlex Deucher {
10806596afd4SAlex Deucher 	0x000055e8, 0x00000001, 0xffffffff,
10816596afd4SAlex Deucher 	0x0000d0bc, 0x00000100, 0xffffffff,
10826596afd4SAlex Deucher 	0x000015c0, 0x000c1401, 0xffffffff,
10836596afd4SAlex Deucher 	0x0000264c, 0x000c0400, 0xffffffff,
10846596afd4SAlex Deucher 	0x00002648, 0x000c0400, 0xffffffff,
10856596afd4SAlex Deucher 	0x00002650, 0x000c0400, 0xffffffff,
10866596afd4SAlex Deucher 	0x000020b8, 0x000c0400, 0xffffffff,
10876596afd4SAlex Deucher 	0x000020bc, 0x000c0400, 0xffffffff,
10886596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
10896596afd4SAlex Deucher 	0x0000f4a4, 0x00680fff, 0xffffffff,
10906596afd4SAlex Deucher 	0x000064ec, 0x00000000, 0xffffffff,
10916596afd4SAlex Deucher 	0x00000c7c, 0x00000000, 0xffffffff,
10926596afd4SAlex Deucher 	0x00006dfc, 0x00000000, 0xffffffff,
10936596afd4SAlex Deucher 	0x000004c8, 0x00000000, 0xffffffff
10946596afd4SAlex Deucher };
10956596afd4SAlex Deucher #define CAICOS_SYSLS_ENABLE_LENGTH sizeof(caicos_sysls_enable) / (3 * sizeof(u32))
10966596afd4SAlex Deucher 
10976596afd4SAlex Deucher //********* TURKS **************//
10986596afd4SAlex Deucher static const u32 turks_sysls_default[] =
10996596afd4SAlex Deucher {
11006596afd4SAlex Deucher 	0x000055e8, 0x00000000, 0xffffffff,
11016596afd4SAlex Deucher 	0x0000d0bc, 0x00000000, 0xffffffff,
11026596afd4SAlex Deucher 	0x000015c0, 0x000c1401, 0xffffffff,
11036596afd4SAlex Deucher 	0x0000264c, 0x000c0400, 0xffffffff,
11046596afd4SAlex Deucher 	0x00002648, 0x000c0400, 0xffffffff,
11056596afd4SAlex Deucher 	0x00002650, 0x000c0400, 0xffffffff,
11066596afd4SAlex Deucher 	0x000020b8, 0x000c0400, 0xffffffff,
11076596afd4SAlex Deucher 	0x000020bc, 0x000c0400, 0xffffffff,
11086596afd4SAlex Deucher 	0x000020c0, 0x000c0c80, 0xffffffff,
11096596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
11106596afd4SAlex Deucher 	0x0000f4a4, 0x00680fff, 0xffffffff,
11116596afd4SAlex Deucher 	0x000004c8, 0x00000001, 0xffffffff,
11126596afd4SAlex Deucher 	0x000064ec, 0x00000000, 0xffffffff,
11136596afd4SAlex Deucher 	0x00000c7c, 0x00000000, 0xffffffff,
11146596afd4SAlex Deucher 	0x00006dfc, 0x00000000, 0xffffffff
11156596afd4SAlex Deucher };
11166596afd4SAlex Deucher #define TURKS_SYSLS_DEFAULT_LENGTH sizeof(turks_sysls_default) / (3 * sizeof(u32))
11176596afd4SAlex Deucher 
11186596afd4SAlex Deucher static const u32 turks_sysls_disable[] =
11196596afd4SAlex Deucher {
11206596afd4SAlex Deucher 	0x000055e8, 0x00000000, 0xffffffff,
11216596afd4SAlex Deucher 	0x0000d0bc, 0x00000000, 0xffffffff,
11226596afd4SAlex Deucher 	0x000015c0, 0x00041401, 0xffffffff,
11236596afd4SAlex Deucher 	0x0000264c, 0x00040400, 0xffffffff,
11246596afd4SAlex Deucher 	0x00002648, 0x00040400, 0xffffffff,
11256596afd4SAlex Deucher 	0x00002650, 0x00040400, 0xffffffff,
11266596afd4SAlex Deucher 	0x000020b8, 0x00040400, 0xffffffff,
11276596afd4SAlex Deucher 	0x000020bc, 0x00040400, 0xffffffff,
11286596afd4SAlex Deucher 	0x000020c0, 0x00040c80, 0xffffffff,
11296596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
11306596afd4SAlex Deucher 	0x0000f4a4, 0x00680000, 0xffffffff,
11316596afd4SAlex Deucher 	0x000004c8, 0x00000001, 0xffffffff,
11326596afd4SAlex Deucher 	0x000064ec, 0x00007ffd, 0xffffffff,
11336596afd4SAlex Deucher 	0x00000c7c, 0x0000ff00, 0xffffffff,
11346596afd4SAlex Deucher 	0x00006dfc, 0x0000007f, 0xffffffff
11356596afd4SAlex Deucher };
11366596afd4SAlex Deucher #define TURKS_SYSLS_DISABLE_LENGTH sizeof(turks_sysls_disable) / (3 * sizeof(u32))
11376596afd4SAlex Deucher 
11386596afd4SAlex Deucher static const u32 turks_sysls_enable[] =
11396596afd4SAlex Deucher {
11406596afd4SAlex Deucher 	0x000055e8, 0x00000001, 0xffffffff,
11416596afd4SAlex Deucher 	0x0000d0bc, 0x00000100, 0xffffffff,
11426596afd4SAlex Deucher 	0x000015c0, 0x000c1401, 0xffffffff,
11436596afd4SAlex Deucher 	0x0000264c, 0x000c0400, 0xffffffff,
11446596afd4SAlex Deucher 	0x00002648, 0x000c0400, 0xffffffff,
11456596afd4SAlex Deucher 	0x00002650, 0x000c0400, 0xffffffff,
11466596afd4SAlex Deucher 	0x000020b8, 0x000c0400, 0xffffffff,
11476596afd4SAlex Deucher 	0x000020bc, 0x000c0400, 0xffffffff,
11486596afd4SAlex Deucher 	0x000020c0, 0x000c0c80, 0xffffffff,
11496596afd4SAlex Deucher 	0x0000f4a0, 0x000000c0, 0xffffffff,
11506596afd4SAlex Deucher 	0x0000f4a4, 0x00680fff, 0xffffffff,
11516596afd4SAlex Deucher 	0x000004c8, 0x00000000, 0xffffffff,
11526596afd4SAlex Deucher 	0x000064ec, 0x00000000, 0xffffffff,
11536596afd4SAlex Deucher 	0x00000c7c, 0x00000000, 0xffffffff,
11546596afd4SAlex Deucher 	0x00006dfc, 0x00000000, 0xffffffff
11556596afd4SAlex Deucher };
11566596afd4SAlex Deucher #define TURKS_SYSLS_ENABLE_LENGTH sizeof(turks_sysls_enable) / (3 * sizeof(u32))
11576596afd4SAlex Deucher 
11586596afd4SAlex Deucher #endif
11596596afd4SAlex Deucher 
116069e0b57aSAlex Deucher u32 btc_valid_sclk[40] =
1161d22b7e40SAlex Deucher {
1162d22b7e40SAlex Deucher 	5000,   10000,  15000,  20000,  25000,  30000,  35000,  40000,  45000,  50000,
1163d22b7e40SAlex Deucher 	55000,  60000,  65000,  70000,  75000,  80000,  85000,  90000,  95000,  100000,
1164d22b7e40SAlex Deucher 	105000, 110000, 11500,  120000, 125000, 130000, 135000, 140000, 145000, 150000,
1165d22b7e40SAlex Deucher 	155000, 160000, 165000, 170000, 175000, 180000, 185000, 190000, 195000, 200000
1166d22b7e40SAlex Deucher };
1167d22b7e40SAlex Deucher 
11683cf8bb1aSJérome Glisse static const struct radeon_blacklist_clocks btc_blacklist_clocks[] = {
1169d22b7e40SAlex Deucher 	{ 10000, 30000, RADEON_SCLK_UP },
1170d22b7e40SAlex Deucher 	{ 15000, 30000, RADEON_SCLK_UP },
1171d22b7e40SAlex Deucher 	{ 20000, 30000, RADEON_SCLK_UP },
1172d22b7e40SAlex Deucher 	{ 25000, 30000, RADEON_SCLK_UP }
1173d22b7e40SAlex Deucher };
1174d22b7e40SAlex Deucher 
117560779143SAlex Deucher void btc_get_max_clock_from_voltage_dependency_table(struct radeon_clock_voltage_dependency_table *table,
117660779143SAlex Deucher 						     u32 *max_clock)
117760779143SAlex Deucher {
117860779143SAlex Deucher 	u32 i, clock = 0;
117960779143SAlex Deucher 
118060779143SAlex Deucher 	if ((table == NULL) || (table->count == 0)) {
118160779143SAlex Deucher 		*max_clock = clock;
118260779143SAlex Deucher 		return;
118360779143SAlex Deucher 	}
118460779143SAlex Deucher 
118560779143SAlex Deucher 	for (i = 0; i < table->count; i++) {
118660779143SAlex Deucher 		if (clock < table->entries[i].clk)
118760779143SAlex Deucher 			clock = table->entries[i].clk;
118860779143SAlex Deucher 	}
118960779143SAlex Deucher 	*max_clock = clock;
119060779143SAlex Deucher }
119160779143SAlex Deucher 
119269e0b57aSAlex Deucher void btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table,
1193d22b7e40SAlex Deucher 					u32 clock, u16 max_voltage, u16 *voltage)
1194d22b7e40SAlex Deucher {
1195d22b7e40SAlex Deucher 	u32 i;
1196d22b7e40SAlex Deucher 
1197d22b7e40SAlex Deucher 	if ((table == NULL) || (table->count == 0))
1198d22b7e40SAlex Deucher 		return;
1199d22b7e40SAlex Deucher 
1200d22b7e40SAlex Deucher 	for (i= 0; i < table->count; i++) {
1201d22b7e40SAlex Deucher 		if (clock <= table->entries[i].clk) {
1202d22b7e40SAlex Deucher 			if (*voltage < table->entries[i].v)
1203d22b7e40SAlex Deucher 				*voltage = (u16)((table->entries[i].v < max_voltage) ?
1204d22b7e40SAlex Deucher 						  table->entries[i].v : max_voltage);
1205d22b7e40SAlex Deucher 			return;
1206d22b7e40SAlex Deucher 		}
1207d22b7e40SAlex Deucher 	}
1208d22b7e40SAlex Deucher 
1209d22b7e40SAlex Deucher 	*voltage = (*voltage > max_voltage) ? *voltage : max_voltage;
1210d22b7e40SAlex Deucher }
1211d22b7e40SAlex Deucher 
1212d22b7e40SAlex Deucher static u32 btc_find_valid_clock(struct radeon_clock_array *clocks,
1213d22b7e40SAlex Deucher 				u32 max_clock, u32 requested_clock)
1214d22b7e40SAlex Deucher {
1215d22b7e40SAlex Deucher 	unsigned int i;
1216d22b7e40SAlex Deucher 
1217d22b7e40SAlex Deucher 	if ((clocks == NULL) || (clocks->count == 0))
1218d22b7e40SAlex Deucher 		return (requested_clock < max_clock) ? requested_clock : max_clock;
1219d22b7e40SAlex Deucher 
1220d22b7e40SAlex Deucher 	for (i = 0; i < clocks->count; i++) {
1221d22b7e40SAlex Deucher 		if (clocks->values[i] >= requested_clock)
1222d22b7e40SAlex Deucher 			return (clocks->values[i] < max_clock) ? clocks->values[i] : max_clock;
1223d22b7e40SAlex Deucher 	}
1224d22b7e40SAlex Deucher 
1225d22b7e40SAlex Deucher 	return (clocks->values[clocks->count - 1] < max_clock) ?
1226d22b7e40SAlex Deucher 		clocks->values[clocks->count - 1] : max_clock;
1227d22b7e40SAlex Deucher }
1228d22b7e40SAlex Deucher 
1229d22b7e40SAlex Deucher static u32 btc_get_valid_mclk(struct radeon_device *rdev,
1230d22b7e40SAlex Deucher 			      u32 max_mclk, u32 requested_mclk)
1231d22b7e40SAlex Deucher {
1232d22b7e40SAlex Deucher 	return btc_find_valid_clock(&rdev->pm.dpm.dyn_state.valid_mclk_values,
1233d22b7e40SAlex Deucher 				    max_mclk, requested_mclk);
1234d22b7e40SAlex Deucher }
1235d22b7e40SAlex Deucher 
1236d22b7e40SAlex Deucher static u32 btc_get_valid_sclk(struct radeon_device *rdev,
1237d22b7e40SAlex Deucher 			      u32 max_sclk, u32 requested_sclk)
1238d22b7e40SAlex Deucher {
1239d22b7e40SAlex Deucher 	return btc_find_valid_clock(&rdev->pm.dpm.dyn_state.valid_sclk_values,
1240d22b7e40SAlex Deucher 				    max_sclk, requested_sclk);
1241d22b7e40SAlex Deucher }
1242d22b7e40SAlex Deucher 
124369e0b57aSAlex Deucher void btc_skip_blacklist_clocks(struct radeon_device *rdev,
1244d22b7e40SAlex Deucher 			       const u32 max_sclk, const u32 max_mclk,
1245d22b7e40SAlex Deucher 			       u32 *sclk, u32 *mclk)
1246d22b7e40SAlex Deucher {
1247d22b7e40SAlex Deucher 	int i, num_blacklist_clocks;
1248d22b7e40SAlex Deucher 
1249d22b7e40SAlex Deucher 	if ((sclk == NULL) || (mclk == NULL))
1250d22b7e40SAlex Deucher 		return;
1251d22b7e40SAlex Deucher 
1252d22b7e40SAlex Deucher 	num_blacklist_clocks = ARRAY_SIZE(btc_blacklist_clocks);
1253d22b7e40SAlex Deucher 
1254d22b7e40SAlex Deucher 	for (i = 0; i < num_blacklist_clocks; i++) {
1255d22b7e40SAlex Deucher 		if ((btc_blacklist_clocks[i].sclk == *sclk) &&
1256d22b7e40SAlex Deucher 		    (btc_blacklist_clocks[i].mclk == *mclk))
1257d22b7e40SAlex Deucher 			break;
1258d22b7e40SAlex Deucher 	}
1259d22b7e40SAlex Deucher 
1260d22b7e40SAlex Deucher 	if (i < num_blacklist_clocks) {
1261d22b7e40SAlex Deucher 		if (btc_blacklist_clocks[i].action == RADEON_SCLK_UP) {
1262d22b7e40SAlex Deucher 			*sclk = btc_get_valid_sclk(rdev, max_sclk, *sclk + 1);
1263d22b7e40SAlex Deucher 
1264d22b7e40SAlex Deucher 			if (*sclk < max_sclk)
1265d22b7e40SAlex Deucher 				btc_skip_blacklist_clocks(rdev, max_sclk, max_mclk, sclk, mclk);
1266d22b7e40SAlex Deucher 		}
1267d22b7e40SAlex Deucher 	}
1268d22b7e40SAlex Deucher }
1269d22b7e40SAlex Deucher 
127069e0b57aSAlex Deucher void btc_adjust_clock_combinations(struct radeon_device *rdev,
1271d22b7e40SAlex Deucher 				   const struct radeon_clock_and_voltage_limits *max_limits,
1272d22b7e40SAlex Deucher 				   struct rv7xx_pl *pl)
1273d22b7e40SAlex Deucher {
1274d22b7e40SAlex Deucher 
1275d22b7e40SAlex Deucher 	if ((pl->mclk == 0) || (pl->sclk == 0))
1276d22b7e40SAlex Deucher 		return;
1277d22b7e40SAlex Deucher 
1278d22b7e40SAlex Deucher 	if (pl->mclk == pl->sclk)
1279d22b7e40SAlex Deucher 		return;
1280d22b7e40SAlex Deucher 
1281d22b7e40SAlex Deucher 	if (pl->mclk > pl->sclk) {
1282d22b7e40SAlex Deucher 		if (((pl->mclk + (pl->sclk - 1)) / pl->sclk) > rdev->pm.dpm.dyn_state.mclk_sclk_ratio)
1283d22b7e40SAlex Deucher 			pl->sclk = btc_get_valid_sclk(rdev,
1284d22b7e40SAlex Deucher 						      max_limits->sclk,
1285d22b7e40SAlex Deucher 						      (pl->mclk +
1286d22b7e40SAlex Deucher 						       (rdev->pm.dpm.dyn_state.mclk_sclk_ratio - 1)) /
1287d22b7e40SAlex Deucher 						      rdev->pm.dpm.dyn_state.mclk_sclk_ratio);
1288d22b7e40SAlex Deucher 	} else {
1289d22b7e40SAlex Deucher 		if ((pl->sclk - pl->mclk) > rdev->pm.dpm.dyn_state.sclk_mclk_delta)
1290d22b7e40SAlex Deucher 			pl->mclk = btc_get_valid_mclk(rdev,
1291d22b7e40SAlex Deucher 						      max_limits->mclk,
1292d22b7e40SAlex Deucher 						      pl->sclk -
1293d22b7e40SAlex Deucher 						      rdev->pm.dpm.dyn_state.sclk_mclk_delta);
1294d22b7e40SAlex Deucher 	}
1295d22b7e40SAlex Deucher }
1296d22b7e40SAlex Deucher 
1297d22b7e40SAlex Deucher static u16 btc_find_voltage(struct atom_voltage_table *table, u16 voltage)
1298d22b7e40SAlex Deucher {
1299d22b7e40SAlex Deucher 	unsigned int i;
1300d22b7e40SAlex Deucher 
1301d22b7e40SAlex Deucher 	for (i = 0; i < table->count; i++) {
1302d22b7e40SAlex Deucher 		if (voltage <= table->entries[i].value)
1303d22b7e40SAlex Deucher 			return table->entries[i].value;
1304d22b7e40SAlex Deucher 	}
1305d22b7e40SAlex Deucher 
1306d22b7e40SAlex Deucher 	return table->entries[table->count - 1].value;
1307d22b7e40SAlex Deucher }
1308d22b7e40SAlex Deucher 
130969e0b57aSAlex Deucher void btc_apply_voltage_delta_rules(struct radeon_device *rdev,
1310d22b7e40SAlex Deucher 				   u16 max_vddc, u16 max_vddci,
1311d22b7e40SAlex Deucher 				   u16 *vddc, u16 *vddci)
1312d22b7e40SAlex Deucher {
1313d22b7e40SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
1314d22b7e40SAlex Deucher 	u16 new_voltage;
1315d22b7e40SAlex Deucher 
1316d22b7e40SAlex Deucher 	if ((0 == *vddc) || (0 == *vddci))
1317d22b7e40SAlex Deucher 		return;
1318d22b7e40SAlex Deucher 
1319d22b7e40SAlex Deucher 	if (*vddc > *vddci) {
1320d22b7e40SAlex Deucher 		if ((*vddc - *vddci) > rdev->pm.dpm.dyn_state.vddc_vddci_delta) {
1321d22b7e40SAlex Deucher 			new_voltage = btc_find_voltage(&eg_pi->vddci_voltage_table,
1322d22b7e40SAlex Deucher 						       (*vddc - rdev->pm.dpm.dyn_state.vddc_vddci_delta));
1323d22b7e40SAlex Deucher 			*vddci = (new_voltage < max_vddci) ? new_voltage : max_vddci;
1324d22b7e40SAlex Deucher 		}
1325d22b7e40SAlex Deucher 	} else {
1326d22b7e40SAlex Deucher 		if ((*vddci - *vddc) > rdev->pm.dpm.dyn_state.vddc_vddci_delta) {
1327d22b7e40SAlex Deucher 			new_voltage = btc_find_voltage(&eg_pi->vddc_voltage_table,
1328d22b7e40SAlex Deucher 						       (*vddci - rdev->pm.dpm.dyn_state.vddc_vddci_delta));
1329d22b7e40SAlex Deucher 			*vddc = (new_voltage < max_vddc) ? new_voltage : max_vddc;
1330d22b7e40SAlex Deucher 		}
1331d22b7e40SAlex Deucher 	}
1332d22b7e40SAlex Deucher }
1333d22b7e40SAlex Deucher 
13346596afd4SAlex Deucher static void btc_enable_bif_dynamic_pcie_gen2(struct radeon_device *rdev,
13356596afd4SAlex Deucher 					     bool enable)
13366596afd4SAlex Deucher {
13376596afd4SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
13386596afd4SAlex Deucher 	u32 tmp, bif;
13396596afd4SAlex Deucher 
13406596afd4SAlex Deucher 	tmp = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
13416596afd4SAlex Deucher 	if (enable) {
13426596afd4SAlex Deucher 		if ((tmp & LC_OTHER_SIDE_EVER_SENT_GEN2) &&
13436596afd4SAlex Deucher 		    (tmp & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
13446596afd4SAlex Deucher 			if (!pi->boot_in_gen2) {
13456596afd4SAlex Deucher 				bif = RREG32(CG_BIF_REQ_AND_RSP) & ~CG_CLIENT_REQ_MASK;
13466596afd4SAlex Deucher 				bif |= CG_CLIENT_REQ(0xd);
13476596afd4SAlex Deucher 				WREG32(CG_BIF_REQ_AND_RSP, bif);
13486596afd4SAlex Deucher 
13496596afd4SAlex Deucher 				tmp &= ~LC_HW_VOLTAGE_IF_CONTROL_MASK;
13506596afd4SAlex Deucher 				tmp |= LC_HW_VOLTAGE_IF_CONTROL(1);
13516596afd4SAlex Deucher 				tmp |= LC_GEN2_EN_STRAP;
13526596afd4SAlex Deucher 
13536596afd4SAlex Deucher 				tmp |= LC_CLR_FAILED_SPD_CHANGE_CNT;
13546596afd4SAlex Deucher 				WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
13556596afd4SAlex Deucher 				udelay(10);
13566596afd4SAlex Deucher 				tmp &= ~LC_CLR_FAILED_SPD_CHANGE_CNT;
13576596afd4SAlex Deucher 				WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
13586596afd4SAlex Deucher 			}
13596596afd4SAlex Deucher 		}
13606596afd4SAlex Deucher 	} else {
13616596afd4SAlex Deucher 		if ((tmp & LC_OTHER_SIDE_EVER_SENT_GEN2) ||
13626596afd4SAlex Deucher 		    (tmp & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
13636596afd4SAlex Deucher 			if (!pi->boot_in_gen2) {
13646596afd4SAlex Deucher 				bif = RREG32(CG_BIF_REQ_AND_RSP) & ~CG_CLIENT_REQ_MASK;
13656596afd4SAlex Deucher 				bif |= CG_CLIENT_REQ(0xd);
13666596afd4SAlex Deucher 				WREG32(CG_BIF_REQ_AND_RSP, bif);
13676596afd4SAlex Deucher 
13686596afd4SAlex Deucher 				tmp &= ~LC_HW_VOLTAGE_IF_CONTROL_MASK;
13696596afd4SAlex Deucher 				tmp &= ~LC_GEN2_EN_STRAP;
13706596afd4SAlex Deucher 			}
13716596afd4SAlex Deucher 			WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
13726596afd4SAlex Deucher 		}
13736596afd4SAlex Deucher 	}
13746596afd4SAlex Deucher }
13756596afd4SAlex Deucher 
13766596afd4SAlex Deucher static void btc_enable_dynamic_pcie_gen2(struct radeon_device *rdev,
13776596afd4SAlex Deucher 					 bool enable)
13786596afd4SAlex Deucher {
13796596afd4SAlex Deucher 	btc_enable_bif_dynamic_pcie_gen2(rdev, enable);
13806596afd4SAlex Deucher 
13816596afd4SAlex Deucher 	if (enable)
13826596afd4SAlex Deucher 		WREG32_P(GENERAL_PWRMGT, ENABLE_GEN2PCIE, ~ENABLE_GEN2PCIE);
13836596afd4SAlex Deucher 	else
13846596afd4SAlex Deucher 		WREG32_P(GENERAL_PWRMGT, 0, ~ENABLE_GEN2PCIE);
13856596afd4SAlex Deucher }
13866596afd4SAlex Deucher 
13876596afd4SAlex Deucher static int btc_disable_ulv(struct radeon_device *rdev)
13886596afd4SAlex Deucher {
13896596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
13906596afd4SAlex Deucher 
13916596afd4SAlex Deucher 	if (eg_pi->ulv.supported) {
13926596afd4SAlex Deucher 		if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_DisableULV) != PPSMC_Result_OK)
13936596afd4SAlex Deucher 			return -EINVAL;
13946596afd4SAlex Deucher 	}
13956596afd4SAlex Deucher 	return 0;
13966596afd4SAlex Deucher }
13976596afd4SAlex Deucher 
13986596afd4SAlex Deucher static int btc_populate_ulv_state(struct radeon_device *rdev,
13996596afd4SAlex Deucher 				  RV770_SMC_STATETABLE *table)
14006596afd4SAlex Deucher {
14016596afd4SAlex Deucher 	int ret = -EINVAL;
14026596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
14036596afd4SAlex Deucher 	struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
14046596afd4SAlex Deucher 
14056596afd4SAlex Deucher 	if (ulv_pl->vddc) {
14066596afd4SAlex Deucher 		ret = cypress_convert_power_level_to_smc(rdev,
14076596afd4SAlex Deucher 							 ulv_pl,
14086596afd4SAlex Deucher 							 &table->ULVState.levels[0],
14096596afd4SAlex Deucher 							 PPSMC_DISPLAY_WATERMARK_LOW);
14106596afd4SAlex Deucher 		if (ret == 0) {
14116596afd4SAlex Deucher 			table->ULVState.levels[0].arbValue = MC_CG_ARB_FREQ_F0;
14126596afd4SAlex Deucher 			table->ULVState.levels[0].ACIndex = 1;
14136596afd4SAlex Deucher 
14146596afd4SAlex Deucher 			table->ULVState.levels[1] = table->ULVState.levels[0];
14156596afd4SAlex Deucher 			table->ULVState.levels[2] = table->ULVState.levels[0];
14166596afd4SAlex Deucher 
14176596afd4SAlex Deucher 			table->ULVState.flags |= PPSMC_SWSTATE_FLAG_DC;
14186596afd4SAlex Deucher 
14196596afd4SAlex Deucher 			WREG32(CG_ULV_CONTROL, BTC_CGULVCONTROL_DFLT);
14206596afd4SAlex Deucher 			WREG32(CG_ULV_PARAMETER, BTC_CGULVPARAMETER_DFLT);
14216596afd4SAlex Deucher 		}
14226596afd4SAlex Deucher 	}
14236596afd4SAlex Deucher 
14246596afd4SAlex Deucher 	return ret;
14256596afd4SAlex Deucher }
14266596afd4SAlex Deucher 
14276596afd4SAlex Deucher static int btc_populate_smc_acpi_state(struct radeon_device *rdev,
14286596afd4SAlex Deucher 				       RV770_SMC_STATETABLE *table)
14296596afd4SAlex Deucher {
14306596afd4SAlex Deucher 	int ret = cypress_populate_smc_acpi_state(rdev, table);
14316596afd4SAlex Deucher 
14326596afd4SAlex Deucher 	if (ret == 0) {
14336596afd4SAlex Deucher 		table->ACPIState.levels[0].ACIndex = 0;
14346596afd4SAlex Deucher 		table->ACPIState.levels[1].ACIndex = 0;
14356596afd4SAlex Deucher 		table->ACPIState.levels[2].ACIndex = 0;
14366596afd4SAlex Deucher 	}
14376596afd4SAlex Deucher 
14386596afd4SAlex Deucher 	return ret;
14396596afd4SAlex Deucher }
14406596afd4SAlex Deucher 
144169e0b57aSAlex Deucher void btc_program_mgcg_hw_sequence(struct radeon_device *rdev,
14426596afd4SAlex Deucher 				  const u32 *sequence, u32 count)
14436596afd4SAlex Deucher {
14446596afd4SAlex Deucher 	u32 i, length = count * 3;
14456596afd4SAlex Deucher 	u32 tmp;
14466596afd4SAlex Deucher 
14476596afd4SAlex Deucher 	for (i = 0; i < length; i+=3) {
14486596afd4SAlex Deucher 		tmp = RREG32(sequence[i]);
14496596afd4SAlex Deucher 		tmp &= ~sequence[i+2];
14506596afd4SAlex Deucher 		tmp |= sequence[i+1] & sequence[i+2];
14516596afd4SAlex Deucher 		WREG32(sequence[i], tmp);
14526596afd4SAlex Deucher 	}
14536596afd4SAlex Deucher }
14546596afd4SAlex Deucher 
14556596afd4SAlex Deucher static void btc_cg_clock_gating_default(struct radeon_device *rdev)
14566596afd4SAlex Deucher {
14576596afd4SAlex Deucher 	u32 count;
14586596afd4SAlex Deucher 	const u32 *p = NULL;
14596596afd4SAlex Deucher 
14606596afd4SAlex Deucher 	if (rdev->family == CHIP_BARTS) {
14616596afd4SAlex Deucher 		p = (const u32 *)&barts_cgcg_cgls_default;
14626596afd4SAlex Deucher 		count = BARTS_CGCG_CGLS_DEFAULT_LENGTH;
14636596afd4SAlex Deucher 	} else if (rdev->family == CHIP_TURKS) {
14646596afd4SAlex Deucher 		p = (const u32 *)&turks_cgcg_cgls_default;
14656596afd4SAlex Deucher 		count = TURKS_CGCG_CGLS_DEFAULT_LENGTH;
14666596afd4SAlex Deucher 	} else if (rdev->family == CHIP_CAICOS) {
14676596afd4SAlex Deucher 		p = (const u32 *)&caicos_cgcg_cgls_default;
14686596afd4SAlex Deucher 		count = CAICOS_CGCG_CGLS_DEFAULT_LENGTH;
14696596afd4SAlex Deucher 	} else
14706596afd4SAlex Deucher 		return;
14716596afd4SAlex Deucher 
14726596afd4SAlex Deucher 	btc_program_mgcg_hw_sequence(rdev, p, count);
14736596afd4SAlex Deucher }
14746596afd4SAlex Deucher 
14756596afd4SAlex Deucher static void btc_cg_clock_gating_enable(struct radeon_device *rdev,
14766596afd4SAlex Deucher 				       bool enable)
14776596afd4SAlex Deucher {
14786596afd4SAlex Deucher 	u32 count;
14796596afd4SAlex Deucher 	const u32 *p = NULL;
14806596afd4SAlex Deucher 
14816596afd4SAlex Deucher 	if (enable) {
14826596afd4SAlex Deucher 		if (rdev->family == CHIP_BARTS) {
14836596afd4SAlex Deucher 			p = (const u32 *)&barts_cgcg_cgls_enable;
14846596afd4SAlex Deucher 			count = BARTS_CGCG_CGLS_ENABLE_LENGTH;
14856596afd4SAlex Deucher 		} else if (rdev->family == CHIP_TURKS) {
14866596afd4SAlex Deucher 			p = (const u32 *)&turks_cgcg_cgls_enable;
14876596afd4SAlex Deucher 			count = TURKS_CGCG_CGLS_ENABLE_LENGTH;
14886596afd4SAlex Deucher 		} else if (rdev->family == CHIP_CAICOS) {
14896596afd4SAlex Deucher 			p = (const u32 *)&caicos_cgcg_cgls_enable;
14906596afd4SAlex Deucher 			count = CAICOS_CGCG_CGLS_ENABLE_LENGTH;
14916596afd4SAlex Deucher 		} else
14926596afd4SAlex Deucher 			return;
14936596afd4SAlex Deucher 	} else {
14946596afd4SAlex Deucher 		if (rdev->family == CHIP_BARTS) {
14956596afd4SAlex Deucher 			p = (const u32 *)&barts_cgcg_cgls_disable;
14966596afd4SAlex Deucher 			count = BARTS_CGCG_CGLS_DISABLE_LENGTH;
14976596afd4SAlex Deucher 		} else if (rdev->family == CHIP_TURKS) {
14986596afd4SAlex Deucher 			p = (const u32 *)&turks_cgcg_cgls_disable;
14996596afd4SAlex Deucher 			count = TURKS_CGCG_CGLS_DISABLE_LENGTH;
15006596afd4SAlex Deucher 		} else if (rdev->family == CHIP_CAICOS) {
15016596afd4SAlex Deucher 			p = (const u32 *)&caicos_cgcg_cgls_disable;
15026596afd4SAlex Deucher 			count = CAICOS_CGCG_CGLS_DISABLE_LENGTH;
15036596afd4SAlex Deucher 		} else
15046596afd4SAlex Deucher 			return;
15056596afd4SAlex Deucher 	}
15066596afd4SAlex Deucher 
15076596afd4SAlex Deucher 	btc_program_mgcg_hw_sequence(rdev, p, count);
15086596afd4SAlex Deucher }
15096596afd4SAlex Deucher 
15106596afd4SAlex Deucher static void btc_mg_clock_gating_default(struct radeon_device *rdev)
15116596afd4SAlex Deucher {
15126596afd4SAlex Deucher 	u32 count;
15136596afd4SAlex Deucher 	const u32 *p = NULL;
15146596afd4SAlex Deucher 
15156596afd4SAlex Deucher 	if (rdev->family == CHIP_BARTS) {
15166596afd4SAlex Deucher 		p = (const u32 *)&barts_mgcg_default;
15176596afd4SAlex Deucher 		count = BARTS_MGCG_DEFAULT_LENGTH;
15186596afd4SAlex Deucher 	} else if (rdev->family == CHIP_TURKS) {
15196596afd4SAlex Deucher 		p = (const u32 *)&turks_mgcg_default;
15206596afd4SAlex Deucher 		count = TURKS_MGCG_DEFAULT_LENGTH;
15216596afd4SAlex Deucher 	} else if (rdev->family == CHIP_CAICOS) {
15226596afd4SAlex Deucher 		p = (const u32 *)&caicos_mgcg_default;
15236596afd4SAlex Deucher 		count = CAICOS_MGCG_DEFAULT_LENGTH;
15246596afd4SAlex Deucher 	} else
15256596afd4SAlex Deucher 		return;
15266596afd4SAlex Deucher 
15276596afd4SAlex Deucher 	btc_program_mgcg_hw_sequence(rdev, p, count);
15286596afd4SAlex Deucher }
15296596afd4SAlex Deucher 
15306596afd4SAlex Deucher static void btc_mg_clock_gating_enable(struct radeon_device *rdev,
15316596afd4SAlex Deucher 				       bool enable)
15326596afd4SAlex Deucher {
15336596afd4SAlex Deucher 	u32 count;
15346596afd4SAlex Deucher 	const u32 *p = NULL;
15356596afd4SAlex Deucher 
15366596afd4SAlex Deucher 	if (enable) {
15376596afd4SAlex Deucher 		if (rdev->family == CHIP_BARTS) {
15386596afd4SAlex Deucher 			p = (const u32 *)&barts_mgcg_enable;
15396596afd4SAlex Deucher 			count = BARTS_MGCG_ENABLE_LENGTH;
15406596afd4SAlex Deucher 		} else if (rdev->family == CHIP_TURKS) {
15416596afd4SAlex Deucher 			p = (const u32 *)&turks_mgcg_enable;
15426596afd4SAlex Deucher 			count = TURKS_MGCG_ENABLE_LENGTH;
15436596afd4SAlex Deucher 		} else if (rdev->family == CHIP_CAICOS) {
15446596afd4SAlex Deucher 			p = (const u32 *)&caicos_mgcg_enable;
15456596afd4SAlex Deucher 			count = CAICOS_MGCG_ENABLE_LENGTH;
15466596afd4SAlex Deucher 		} else
15476596afd4SAlex Deucher 			return;
15486596afd4SAlex Deucher 	} else {
15496596afd4SAlex Deucher 		if (rdev->family == CHIP_BARTS) {
15506596afd4SAlex Deucher 			p = (const u32 *)&barts_mgcg_disable[0];
15516596afd4SAlex Deucher 			count = BARTS_MGCG_DISABLE_LENGTH;
15526596afd4SAlex Deucher 		} else if (rdev->family == CHIP_TURKS) {
15536596afd4SAlex Deucher 			p = (const u32 *)&turks_mgcg_disable[0];
15546596afd4SAlex Deucher 			count = TURKS_MGCG_DISABLE_LENGTH;
15556596afd4SAlex Deucher 		} else if (rdev->family == CHIP_CAICOS) {
15566596afd4SAlex Deucher 			p = (const u32 *)&caicos_mgcg_disable[0];
15576596afd4SAlex Deucher 			count = CAICOS_MGCG_DISABLE_LENGTH;
15586596afd4SAlex Deucher 		} else
15596596afd4SAlex Deucher 			return;
15606596afd4SAlex Deucher 	}
15616596afd4SAlex Deucher 
15626596afd4SAlex Deucher 	btc_program_mgcg_hw_sequence(rdev, p, count);
15636596afd4SAlex Deucher }
15646596afd4SAlex Deucher 
15656596afd4SAlex Deucher static void btc_ls_clock_gating_default(struct radeon_device *rdev)
15666596afd4SAlex Deucher {
15676596afd4SAlex Deucher 	u32 count;
15686596afd4SAlex Deucher 	const u32 *p = NULL;
15696596afd4SAlex Deucher 
15706596afd4SAlex Deucher 	if (rdev->family == CHIP_BARTS) {
15716596afd4SAlex Deucher 		p = (const u32 *)&barts_sysls_default;
15726596afd4SAlex Deucher 		count = BARTS_SYSLS_DEFAULT_LENGTH;
15736596afd4SAlex Deucher 	} else if (rdev->family == CHIP_TURKS) {
15746596afd4SAlex Deucher 		p = (const u32 *)&turks_sysls_default;
15756596afd4SAlex Deucher 		count = TURKS_SYSLS_DEFAULT_LENGTH;
15766596afd4SAlex Deucher 	} else if (rdev->family == CHIP_CAICOS) {
15776596afd4SAlex Deucher 		p = (const u32 *)&caicos_sysls_default;
15786596afd4SAlex Deucher 		count = CAICOS_SYSLS_DEFAULT_LENGTH;
15796596afd4SAlex Deucher 	} else
15806596afd4SAlex Deucher 		return;
15816596afd4SAlex Deucher 
15826596afd4SAlex Deucher 	btc_program_mgcg_hw_sequence(rdev, p, count);
15836596afd4SAlex Deucher }
15846596afd4SAlex Deucher 
15856596afd4SAlex Deucher static void btc_ls_clock_gating_enable(struct radeon_device *rdev,
15866596afd4SAlex Deucher 				       bool enable)
15876596afd4SAlex Deucher {
15886596afd4SAlex Deucher 	u32 count;
15896596afd4SAlex Deucher 	const u32 *p = NULL;
15906596afd4SAlex Deucher 
15916596afd4SAlex Deucher 	if (enable) {
15926596afd4SAlex Deucher 		if (rdev->family == CHIP_BARTS) {
15936596afd4SAlex Deucher 			p = (const u32 *)&barts_sysls_enable;
15946596afd4SAlex Deucher 			count = BARTS_SYSLS_ENABLE_LENGTH;
15956596afd4SAlex Deucher 		} else if (rdev->family == CHIP_TURKS) {
15966596afd4SAlex Deucher 			p = (const u32 *)&turks_sysls_enable;
15976596afd4SAlex Deucher 			count = TURKS_SYSLS_ENABLE_LENGTH;
15986596afd4SAlex Deucher 		} else if (rdev->family == CHIP_CAICOS) {
15996596afd4SAlex Deucher 			p = (const u32 *)&caicos_sysls_enable;
16006596afd4SAlex Deucher 			count = CAICOS_SYSLS_ENABLE_LENGTH;
16016596afd4SAlex Deucher 		} else
16026596afd4SAlex Deucher 			return;
16036596afd4SAlex Deucher 	} else {
16046596afd4SAlex Deucher 		if (rdev->family == CHIP_BARTS) {
16056596afd4SAlex Deucher 			p = (const u32 *)&barts_sysls_disable;
16066596afd4SAlex Deucher 			count = BARTS_SYSLS_DISABLE_LENGTH;
16076596afd4SAlex Deucher 		} else if (rdev->family == CHIP_TURKS) {
16086596afd4SAlex Deucher 			p = (const u32 *)&turks_sysls_disable;
16096596afd4SAlex Deucher 			count = TURKS_SYSLS_DISABLE_LENGTH;
16106596afd4SAlex Deucher 		} else if (rdev->family == CHIP_CAICOS) {
16116596afd4SAlex Deucher 			p = (const u32 *)&caicos_sysls_disable;
16126596afd4SAlex Deucher 			count = CAICOS_SYSLS_DISABLE_LENGTH;
16136596afd4SAlex Deucher 		} else
16146596afd4SAlex Deucher 			return;
16156596afd4SAlex Deucher 	}
16166596afd4SAlex Deucher 
16176596afd4SAlex Deucher 	btc_program_mgcg_hw_sequence(rdev, p, count);
16186596afd4SAlex Deucher }
16196596afd4SAlex Deucher 
162069e0b57aSAlex Deucher bool btc_dpm_enabled(struct radeon_device *rdev)
16216596afd4SAlex Deucher {
16226596afd4SAlex Deucher 	if (rv770_is_smc_running(rdev))
16236596afd4SAlex Deucher 		return true;
16246596afd4SAlex Deucher 	else
16256596afd4SAlex Deucher 		return false;
16266596afd4SAlex Deucher }
16276596afd4SAlex Deucher 
16284cb3a02fSAlex Deucher static int btc_init_smc_table(struct radeon_device *rdev,
16294cb3a02fSAlex Deucher 			      struct radeon_ps *radeon_boot_state)
16306596afd4SAlex Deucher {
16316596afd4SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
16326596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
16336596afd4SAlex Deucher 	RV770_SMC_STATETABLE *table = &pi->smc_statetable;
16346596afd4SAlex Deucher 	int ret;
16356596afd4SAlex Deucher 
16366596afd4SAlex Deucher 	memset(table, 0, sizeof(RV770_SMC_STATETABLE));
16376596afd4SAlex Deucher 
16386596afd4SAlex Deucher 	cypress_populate_smc_voltage_tables(rdev, table);
16396596afd4SAlex Deucher 
16406596afd4SAlex Deucher 	switch (rdev->pm.int_thermal_type) {
16416596afd4SAlex Deucher 	case THERMAL_TYPE_EVERGREEN:
16426596afd4SAlex Deucher 	case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
16436596afd4SAlex Deucher 		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
16446596afd4SAlex Deucher 		break;
16456596afd4SAlex Deucher 	case THERMAL_TYPE_NONE:
16466596afd4SAlex Deucher 		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
16476596afd4SAlex Deucher 		break;
16486596afd4SAlex Deucher 	default:
16496596afd4SAlex Deucher 		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
16506596afd4SAlex Deucher 		break;
16516596afd4SAlex Deucher 	}
16526596afd4SAlex Deucher 
16536596afd4SAlex Deucher 	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
16546596afd4SAlex Deucher 		table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
16556596afd4SAlex Deucher 
16566596afd4SAlex Deucher 	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT)
16576596afd4SAlex Deucher 		table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
16586596afd4SAlex Deucher 
16596596afd4SAlex Deucher 	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
16606596afd4SAlex Deucher 		table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
16616596afd4SAlex Deucher 
16626596afd4SAlex Deucher 	if (pi->mem_gddr5)
16636596afd4SAlex Deucher 		table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
16646596afd4SAlex Deucher 
16656596afd4SAlex Deucher 	ret = cypress_populate_smc_initial_state(rdev, radeon_boot_state, table);
16666596afd4SAlex Deucher 	if (ret)
16676596afd4SAlex Deucher 		return ret;
16686596afd4SAlex Deucher 
16696596afd4SAlex Deucher 	if (eg_pi->sclk_deep_sleep)
16706596afd4SAlex Deucher 		WREG32_P(SCLK_PSKIP_CNTL, PSKIP_ON_ALLOW_STOP_HI(32),
16716596afd4SAlex Deucher 			 ~PSKIP_ON_ALLOW_STOP_HI_MASK);
16726596afd4SAlex Deucher 
16736596afd4SAlex Deucher 	ret = btc_populate_smc_acpi_state(rdev, table);
16746596afd4SAlex Deucher 	if (ret)
16756596afd4SAlex Deucher 		return ret;
16766596afd4SAlex Deucher 
16776596afd4SAlex Deucher 	if (eg_pi->ulv.supported) {
16786596afd4SAlex Deucher 		ret = btc_populate_ulv_state(rdev, table);
16796596afd4SAlex Deucher 		if (ret)
16806596afd4SAlex Deucher 			eg_pi->ulv.supported = false;
16816596afd4SAlex Deucher 	}
16826596afd4SAlex Deucher 
16836596afd4SAlex Deucher 	table->driverState = table->initialState;
16846596afd4SAlex Deucher 
16856596afd4SAlex Deucher 	return rv770_copy_bytes_to_smc(rdev,
16866596afd4SAlex Deucher 				       pi->state_table_start,
16876596afd4SAlex Deucher 				       (u8 *)table,
16886596afd4SAlex Deucher 				       sizeof(RV770_SMC_STATETABLE),
16896596afd4SAlex Deucher 				       pi->sram_end);
16906596afd4SAlex Deucher }
16916596afd4SAlex Deucher 
16924cb3a02fSAlex Deucher static void btc_set_at_for_uvd(struct radeon_device *rdev,
16934cb3a02fSAlex Deucher 			       struct radeon_ps *radeon_new_state)
1694f85392bcSAlex Deucher {
1695f85392bcSAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
1696f85392bcSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
1697f85392bcSAlex Deucher 	int idx = 0;
1698f85392bcSAlex Deucher 
1699f85392bcSAlex Deucher 	if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2))
1700f85392bcSAlex Deucher 		idx = 1;
1701f85392bcSAlex Deucher 
1702f85392bcSAlex Deucher 	if ((idx == 1) && !eg_pi->smu_uvd_hs) {
1703f85392bcSAlex Deucher 		pi->rlp = 10;
1704f85392bcSAlex Deucher 		pi->rmp = 100;
1705f85392bcSAlex Deucher 		pi->lhp = 100;
1706f85392bcSAlex Deucher 		pi->lmp = 10;
1707f85392bcSAlex Deucher 	} else {
1708f85392bcSAlex Deucher 		pi->rlp = eg_pi->ats[idx].rlp;
1709f85392bcSAlex Deucher 		pi->rmp = eg_pi->ats[idx].rmp;
1710f85392bcSAlex Deucher 		pi->lhp = eg_pi->ats[idx].lhp;
1711f85392bcSAlex Deucher 		pi->lmp = eg_pi->ats[idx].lmp;
1712f85392bcSAlex Deucher 	}
1713f85392bcSAlex Deucher 
1714f85392bcSAlex Deucher }
1715f85392bcSAlex Deucher 
17164cb3a02fSAlex Deucher void btc_notify_uvd_to_smc(struct radeon_device *rdev,
17174cb3a02fSAlex Deucher 			   struct radeon_ps *radeon_new_state)
1718f85392bcSAlex Deucher {
1719f85392bcSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
1720f85392bcSAlex Deucher 
1721f85392bcSAlex Deucher 	if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2)) {
1722f85392bcSAlex Deucher 		rv770_write_smc_soft_register(rdev,
1723f85392bcSAlex Deucher 					      RV770_SMC_SOFT_REGISTER_uvd_enabled, 1);
1724f85392bcSAlex Deucher 		eg_pi->uvd_enabled = true;
1725f85392bcSAlex Deucher 	} else {
1726f85392bcSAlex Deucher 		rv770_write_smc_soft_register(rdev,
1727f85392bcSAlex Deucher 					      RV770_SMC_SOFT_REGISTER_uvd_enabled, 0);
1728f85392bcSAlex Deucher 		eg_pi->uvd_enabled = false;
1729f85392bcSAlex Deucher 	}
1730f85392bcSAlex Deucher }
1731f85392bcSAlex Deucher 
173269e0b57aSAlex Deucher int btc_reset_to_default(struct radeon_device *rdev)
17336596afd4SAlex Deucher {
17346596afd4SAlex Deucher 	if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_ResetToDefaults) != PPSMC_Result_OK)
17356596afd4SAlex Deucher 		return -EINVAL;
17366596afd4SAlex Deucher 
17376596afd4SAlex Deucher 	return 0;
17386596afd4SAlex Deucher }
17396596afd4SAlex Deucher 
17406596afd4SAlex Deucher static void btc_stop_smc(struct radeon_device *rdev)
17416596afd4SAlex Deucher {
17426596afd4SAlex Deucher 	int i;
17436596afd4SAlex Deucher 
17446596afd4SAlex Deucher 	for (i = 0; i < rdev->usec_timeout; i++) {
17456596afd4SAlex Deucher 		if (((RREG32(LB_SYNC_RESET_SEL) & LB_SYNC_RESET_SEL_MASK) >> LB_SYNC_RESET_SEL_SHIFT) != 1)
17466596afd4SAlex Deucher 			break;
17476596afd4SAlex Deucher 		udelay(1);
17486596afd4SAlex Deucher 	}
17496596afd4SAlex Deucher 	udelay(100);
17506596afd4SAlex Deucher 
17516596afd4SAlex Deucher 	r7xx_stop_smc(rdev);
17526596afd4SAlex Deucher }
17536596afd4SAlex Deucher 
175469e0b57aSAlex Deucher void btc_read_arb_registers(struct radeon_device *rdev)
17556596afd4SAlex Deucher {
17566596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17576596afd4SAlex Deucher 	struct evergreen_arb_registers *arb_registers =
17586596afd4SAlex Deucher 		&eg_pi->bootup_arb_registers;
17596596afd4SAlex Deucher 
17606596afd4SAlex Deucher 	arb_registers->mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING);
17616596afd4SAlex Deucher 	arb_registers->mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
17626596afd4SAlex Deucher 	arb_registers->mc_arb_rfsh_rate = RREG32(MC_ARB_RFSH_RATE);
17636596afd4SAlex Deucher 	arb_registers->mc_arb_burst_time = RREG32(MC_ARB_BURST_TIME);
17646596afd4SAlex Deucher }
17656596afd4SAlex Deucher 
17666596afd4SAlex Deucher 
17676596afd4SAlex Deucher static void btc_set_arb0_registers(struct radeon_device *rdev,
17686596afd4SAlex Deucher 				   struct evergreen_arb_registers *arb_registers)
17696596afd4SAlex Deucher {
17706596afd4SAlex Deucher 	u32 val;
17716596afd4SAlex Deucher 
17726596afd4SAlex Deucher 	WREG32(MC_ARB_DRAM_TIMING,  arb_registers->mc_arb_dram_timing);
17736596afd4SAlex Deucher 	WREG32(MC_ARB_DRAM_TIMING2, arb_registers->mc_arb_dram_timing2);
17746596afd4SAlex Deucher 
17756596afd4SAlex Deucher 	val = (arb_registers->mc_arb_rfsh_rate & POWERMODE0_MASK) >>
17766596afd4SAlex Deucher 		POWERMODE0_SHIFT;
17776596afd4SAlex Deucher 	WREG32_P(MC_ARB_RFSH_RATE, POWERMODE0(val), ~POWERMODE0_MASK);
17786596afd4SAlex Deucher 
17796596afd4SAlex Deucher 	val = (arb_registers->mc_arb_burst_time & STATE0_MASK) >>
17806596afd4SAlex Deucher 		STATE0_SHIFT;
17816596afd4SAlex Deucher 	WREG32_P(MC_ARB_BURST_TIME, STATE0(val), ~STATE0_MASK);
17826596afd4SAlex Deucher }
17836596afd4SAlex Deucher 
17846596afd4SAlex Deucher static void btc_set_boot_state_timing(struct radeon_device *rdev)
17856596afd4SAlex Deucher {
17866596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17876596afd4SAlex Deucher 
17886596afd4SAlex Deucher 	if (eg_pi->ulv.supported)
17896596afd4SAlex Deucher 		btc_set_arb0_registers(rdev, &eg_pi->bootup_arb_registers);
17906596afd4SAlex Deucher }
17916596afd4SAlex Deucher 
17926596afd4SAlex Deucher static bool btc_is_state_ulv_compatible(struct radeon_device *rdev,
17936596afd4SAlex Deucher 					struct radeon_ps *radeon_state)
17946596afd4SAlex Deucher {
17956596afd4SAlex Deucher 	struct rv7xx_ps *state = rv770_get_ps(radeon_state);
17966596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17976596afd4SAlex Deucher 	struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
17986596afd4SAlex Deucher 
17996596afd4SAlex Deucher 	if (state->low.mclk != ulv_pl->mclk)
18006596afd4SAlex Deucher 		return false;
18016596afd4SAlex Deucher 
18026596afd4SAlex Deucher 	if (state->low.vddci != ulv_pl->vddci)
18036596afd4SAlex Deucher 		return false;
18046596afd4SAlex Deucher 
18056596afd4SAlex Deucher 	/* XXX check minclocks, etc. */
18066596afd4SAlex Deucher 
18076596afd4SAlex Deucher 	return true;
18086596afd4SAlex Deucher }
18096596afd4SAlex Deucher 
18106596afd4SAlex Deucher 
18116596afd4SAlex Deucher static int btc_set_ulv_dram_timing(struct radeon_device *rdev)
18126596afd4SAlex Deucher {
18136596afd4SAlex Deucher 	u32 val;
18146596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
18156596afd4SAlex Deucher 	struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
18166596afd4SAlex Deucher 
18176596afd4SAlex Deucher 	radeon_atom_set_engine_dram_timings(rdev,
18186596afd4SAlex Deucher 					    ulv_pl->sclk,
18196596afd4SAlex Deucher 					    ulv_pl->mclk);
18206596afd4SAlex Deucher 
18216596afd4SAlex Deucher 	val = rv770_calculate_memory_refresh_rate(rdev, ulv_pl->sclk);
18226596afd4SAlex Deucher 	WREG32_P(MC_ARB_RFSH_RATE, POWERMODE0(val), ~POWERMODE0_MASK);
18236596afd4SAlex Deucher 
18246596afd4SAlex Deucher 	val = cypress_calculate_burst_time(rdev, ulv_pl->sclk, ulv_pl->mclk);
18256596afd4SAlex Deucher 	WREG32_P(MC_ARB_BURST_TIME, STATE0(val), ~STATE0_MASK);
18266596afd4SAlex Deucher 
18276596afd4SAlex Deucher 	return 0;
18286596afd4SAlex Deucher }
18296596afd4SAlex Deucher 
18306596afd4SAlex Deucher static int btc_enable_ulv(struct radeon_device *rdev)
18316596afd4SAlex Deucher {
18326596afd4SAlex Deucher 	if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_EnableULV) != PPSMC_Result_OK)
18336596afd4SAlex Deucher 		return -EINVAL;
18346596afd4SAlex Deucher 
18356596afd4SAlex Deucher 	return 0;
18366596afd4SAlex Deucher }
18376596afd4SAlex Deucher 
18384cb3a02fSAlex Deucher static int btc_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev,
18394cb3a02fSAlex Deucher 							struct radeon_ps *radeon_new_state)
18406596afd4SAlex Deucher {
18416596afd4SAlex Deucher 	int ret = 0;
18426596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
18436596afd4SAlex Deucher 
18446596afd4SAlex Deucher 	if (eg_pi->ulv.supported) {
18456596afd4SAlex Deucher 		if (btc_is_state_ulv_compatible(rdev, radeon_new_state)) {
18466596afd4SAlex Deucher 			// Set ARB[0] to reflect the DRAM timing needed for ULV.
18476596afd4SAlex Deucher 			ret = btc_set_ulv_dram_timing(rdev);
18486596afd4SAlex Deucher 			if (ret == 0)
18496596afd4SAlex Deucher 				ret = btc_enable_ulv(rdev);
18506596afd4SAlex Deucher 		}
18516596afd4SAlex Deucher 	}
18526596afd4SAlex Deucher 
18536596afd4SAlex Deucher 	return ret;
18546596afd4SAlex Deucher }
18556596afd4SAlex Deucher 
18566596afd4SAlex Deucher static bool btc_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
18576596afd4SAlex Deucher {
18586596afd4SAlex Deucher 	bool result = true;
18596596afd4SAlex Deucher 
18606596afd4SAlex Deucher 	switch (in_reg) {
18616596afd4SAlex Deucher 	case MC_SEQ_RAS_TIMING >> 2:
18626596afd4SAlex Deucher 		*out_reg = MC_SEQ_RAS_TIMING_LP >> 2;
18636596afd4SAlex Deucher 		break;
18646596afd4SAlex Deucher 	case MC_SEQ_CAS_TIMING >> 2:
18656596afd4SAlex Deucher 		*out_reg = MC_SEQ_CAS_TIMING_LP >> 2;
18666596afd4SAlex Deucher 		break;
18676596afd4SAlex Deucher 	case MC_SEQ_MISC_TIMING >> 2:
18686596afd4SAlex Deucher 		*out_reg = MC_SEQ_MISC_TIMING_LP >> 2;
18696596afd4SAlex Deucher 		break;
18706596afd4SAlex Deucher 	case MC_SEQ_MISC_TIMING2 >> 2:
18716596afd4SAlex Deucher 		*out_reg = MC_SEQ_MISC_TIMING2_LP >> 2;
18726596afd4SAlex Deucher 		break;
18736596afd4SAlex Deucher 	case MC_SEQ_RD_CTL_D0 >> 2:
18746596afd4SAlex Deucher 		*out_reg = MC_SEQ_RD_CTL_D0_LP >> 2;
18756596afd4SAlex Deucher 		break;
18766596afd4SAlex Deucher 	case MC_SEQ_RD_CTL_D1 >> 2:
18776596afd4SAlex Deucher 		*out_reg = MC_SEQ_RD_CTL_D1_LP >> 2;
18786596afd4SAlex Deucher 		break;
18796596afd4SAlex Deucher 	case MC_SEQ_WR_CTL_D0 >> 2:
18806596afd4SAlex Deucher 		*out_reg = MC_SEQ_WR_CTL_D0_LP >> 2;
18816596afd4SAlex Deucher 		break;
18826596afd4SAlex Deucher 	case MC_SEQ_WR_CTL_D1 >> 2:
18836596afd4SAlex Deucher 		*out_reg = MC_SEQ_WR_CTL_D1_LP >> 2;
18846596afd4SAlex Deucher 		break;
18856596afd4SAlex Deucher 	case MC_PMG_CMD_EMRS >> 2:
18866596afd4SAlex Deucher 		*out_reg = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
18876596afd4SAlex Deucher 		break;
18886596afd4SAlex Deucher 	case MC_PMG_CMD_MRS >> 2:
18896596afd4SAlex Deucher 		*out_reg = MC_SEQ_PMG_CMD_MRS_LP >> 2;
18906596afd4SAlex Deucher 		break;
18916596afd4SAlex Deucher 	case MC_PMG_CMD_MRS1 >> 2:
18926596afd4SAlex Deucher 		*out_reg = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
18936596afd4SAlex Deucher 		break;
18946596afd4SAlex Deucher 	default:
18956596afd4SAlex Deucher 		result = false;
18966596afd4SAlex Deucher 		break;
18976596afd4SAlex Deucher 	}
18986596afd4SAlex Deucher 
18996596afd4SAlex Deucher 	return result;
19006596afd4SAlex Deucher }
19016596afd4SAlex Deucher 
19026596afd4SAlex Deucher static void btc_set_valid_flag(struct evergreen_mc_reg_table *table)
19036596afd4SAlex Deucher {
19046596afd4SAlex Deucher 	u8 i, j;
19056596afd4SAlex Deucher 
19066596afd4SAlex Deucher 	for (i = 0; i < table->last; i++) {
19076596afd4SAlex Deucher 		for (j = 1; j < table->num_entries; j++) {
19086596afd4SAlex Deucher 			if (table->mc_reg_table_entry[j-1].mc_data[i] !=
19096596afd4SAlex Deucher 			    table->mc_reg_table_entry[j].mc_data[i]) {
19106596afd4SAlex Deucher 				table->valid_flag |= (1 << i);
19116596afd4SAlex Deucher 				break;
19126596afd4SAlex Deucher 			}
19136596afd4SAlex Deucher 		}
19146596afd4SAlex Deucher 	}
19156596afd4SAlex Deucher }
19166596afd4SAlex Deucher 
19176596afd4SAlex Deucher static int btc_set_mc_special_registers(struct radeon_device *rdev,
19186596afd4SAlex Deucher 					struct evergreen_mc_reg_table *table)
19196596afd4SAlex Deucher {
19206596afd4SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
19216596afd4SAlex Deucher 	u8 i, j, k;
19226596afd4SAlex Deucher 	u32 tmp;
19236596afd4SAlex Deucher 
19246596afd4SAlex Deucher 	for (i = 0, j = table->last; i < table->last; i++) {
19256596afd4SAlex Deucher 		switch (table->mc_reg_address[i].s1) {
19266596afd4SAlex Deucher 		case MC_SEQ_MISC1 >> 2:
19276596afd4SAlex Deucher 			tmp = RREG32(MC_PMG_CMD_EMRS);
19286596afd4SAlex Deucher 			table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS >> 2;
19296596afd4SAlex Deucher 			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
19306596afd4SAlex Deucher 			for (k = 0; k < table->num_entries; k++) {
19316596afd4SAlex Deucher 				table->mc_reg_table_entry[k].mc_data[j] =
19326596afd4SAlex Deucher 					((tmp & 0xffff0000)) |
19336596afd4SAlex Deucher 					((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
19346596afd4SAlex Deucher 			}
19356596afd4SAlex Deucher 			j++;
19366596afd4SAlex Deucher 
193796d8df84SDan Carpenter 			if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19386596afd4SAlex Deucher 				return -EINVAL;
19396596afd4SAlex Deucher 
19406596afd4SAlex Deucher 			tmp = RREG32(MC_PMG_CMD_MRS);
19416596afd4SAlex Deucher 			table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS >> 2;
19426596afd4SAlex Deucher 			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP >> 2;
19436596afd4SAlex Deucher 			for (k = 0; k < table->num_entries; k++) {
19446596afd4SAlex Deucher 				table->mc_reg_table_entry[k].mc_data[j] =
19456596afd4SAlex Deucher 					(tmp & 0xffff0000) |
19466596afd4SAlex Deucher 					(table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
19476596afd4SAlex Deucher 				if (!pi->mem_gddr5)
19486596afd4SAlex Deucher 					table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
19496596afd4SAlex Deucher 			}
19506596afd4SAlex Deucher 			j++;
19516596afd4SAlex Deucher 
195296d8df84SDan Carpenter 			if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19536596afd4SAlex Deucher 				return -EINVAL;
19546596afd4SAlex Deucher 			break;
19556596afd4SAlex Deucher 		case MC_SEQ_RESERVE_M >> 2:
19566596afd4SAlex Deucher 			tmp = RREG32(MC_PMG_CMD_MRS1);
19576596afd4SAlex Deucher 			table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1 >> 2;
19586596afd4SAlex Deucher 			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
19596596afd4SAlex Deucher 			for (k = 0; k < table->num_entries; k++) {
19606596afd4SAlex Deucher 				table->mc_reg_table_entry[k].mc_data[j] =
19616596afd4SAlex Deucher 					(tmp & 0xffff0000) |
19626596afd4SAlex Deucher 					(table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
19636596afd4SAlex Deucher 			}
19646596afd4SAlex Deucher 			j++;
19656596afd4SAlex Deucher 
196696d8df84SDan Carpenter 			if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19676596afd4SAlex Deucher 				return -EINVAL;
19686596afd4SAlex Deucher 			break;
19696596afd4SAlex Deucher 		default:
19706596afd4SAlex Deucher 			break;
19716596afd4SAlex Deucher 		}
19726596afd4SAlex Deucher 	}
19736596afd4SAlex Deucher 
19746596afd4SAlex Deucher 	table->last = j;
19756596afd4SAlex Deucher 
19766596afd4SAlex Deucher 	return 0;
19776596afd4SAlex Deucher }
19786596afd4SAlex Deucher 
19796596afd4SAlex Deucher static void btc_set_s0_mc_reg_index(struct evergreen_mc_reg_table *table)
19806596afd4SAlex Deucher {
19816596afd4SAlex Deucher 	u32 i;
19826596afd4SAlex Deucher 	u16 address;
19836596afd4SAlex Deucher 
19846596afd4SAlex Deucher 	for (i = 0; i < table->last; i++) {
19856596afd4SAlex Deucher 		table->mc_reg_address[i].s0 =
19866596afd4SAlex Deucher 			btc_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
19876596afd4SAlex Deucher 			address : table->mc_reg_address[i].s1;
19886596afd4SAlex Deucher 	}
19896596afd4SAlex Deucher }
19906596afd4SAlex Deucher 
19916596afd4SAlex Deucher static int btc_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
19926596afd4SAlex Deucher 				       struct evergreen_mc_reg_table *eg_table)
19936596afd4SAlex Deucher {
19946596afd4SAlex Deucher 	u8 i, j;
19956596afd4SAlex Deucher 
19966596afd4SAlex Deucher 	if (table->last > SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19976596afd4SAlex Deucher 		return -EINVAL;
19986596afd4SAlex Deucher 
19996596afd4SAlex Deucher 	if (table->num_entries > MAX_AC_TIMING_ENTRIES)
20006596afd4SAlex Deucher 		return -EINVAL;
20016596afd4SAlex Deucher 
20026596afd4SAlex Deucher 	for (i = 0; i < table->last; i++)
20036596afd4SAlex Deucher 		eg_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
20046596afd4SAlex Deucher 	eg_table->last = table->last;
20056596afd4SAlex Deucher 
20066596afd4SAlex Deucher 	for (i = 0; i < table->num_entries; i++) {
20076596afd4SAlex Deucher 		eg_table->mc_reg_table_entry[i].mclk_max =
20086596afd4SAlex Deucher 			table->mc_reg_table_entry[i].mclk_max;
20096596afd4SAlex Deucher 		for(j = 0; j < table->last; j++)
20106596afd4SAlex Deucher 			eg_table->mc_reg_table_entry[i].mc_data[j] =
20116596afd4SAlex Deucher 				table->mc_reg_table_entry[i].mc_data[j];
20126596afd4SAlex Deucher 	}
20136596afd4SAlex Deucher 	eg_table->num_entries = table->num_entries;
20146596afd4SAlex Deucher 
20156596afd4SAlex Deucher 	return 0;
20166596afd4SAlex Deucher }
20176596afd4SAlex Deucher 
20186596afd4SAlex Deucher static int btc_initialize_mc_reg_table(struct radeon_device *rdev)
20196596afd4SAlex Deucher {
20206596afd4SAlex Deucher 	int ret;
20216596afd4SAlex Deucher 	struct atom_mc_reg_table *table;
20226596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
20236596afd4SAlex Deucher 	struct evergreen_mc_reg_table *eg_table = &eg_pi->mc_reg_table;
20246596afd4SAlex Deucher 	u8 module_index = rv770_get_memory_module_index(rdev);
20256596afd4SAlex Deucher 
20266596afd4SAlex Deucher 	table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
20276596afd4SAlex Deucher 	if (!table)
20286596afd4SAlex Deucher 		return -ENOMEM;
20296596afd4SAlex Deucher 
20306596afd4SAlex Deucher 	/* Program additional LP registers that are no longer programmed by VBIOS */
20316596afd4SAlex Deucher 	WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
20326596afd4SAlex Deucher 	WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
20336596afd4SAlex Deucher 	WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
20346596afd4SAlex Deucher 	WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
20356596afd4SAlex Deucher 	WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
20366596afd4SAlex Deucher 	WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
20376596afd4SAlex Deucher 	WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
20386596afd4SAlex Deucher 	WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
20396596afd4SAlex Deucher 	WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
20406596afd4SAlex Deucher 	WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
20416596afd4SAlex Deucher 	WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
20426596afd4SAlex Deucher 
20436596afd4SAlex Deucher 	ret = radeon_atom_init_mc_reg_table(rdev, module_index, table);
20446596afd4SAlex Deucher 
20456596afd4SAlex Deucher 	if (ret)
20466596afd4SAlex Deucher 		goto init_mc_done;
20476596afd4SAlex Deucher 
20486596afd4SAlex Deucher 	ret = btc_copy_vbios_mc_reg_table(table, eg_table);
20496596afd4SAlex Deucher 
20506596afd4SAlex Deucher 	if (ret)
20516596afd4SAlex Deucher 		goto init_mc_done;
20526596afd4SAlex Deucher 
20536596afd4SAlex Deucher 	btc_set_s0_mc_reg_index(eg_table);
20546596afd4SAlex Deucher 	ret = btc_set_mc_special_registers(rdev, eg_table);
20556596afd4SAlex Deucher 
20566596afd4SAlex Deucher 	if (ret)
20576596afd4SAlex Deucher 		goto init_mc_done;
20586596afd4SAlex Deucher 
20596596afd4SAlex Deucher 	btc_set_valid_flag(eg_table);
20606596afd4SAlex Deucher 
20616596afd4SAlex Deucher init_mc_done:
20626596afd4SAlex Deucher 	kfree(table);
20636596afd4SAlex Deucher 
20646596afd4SAlex Deucher 	return ret;
20656596afd4SAlex Deucher }
20666596afd4SAlex Deucher 
20676596afd4SAlex Deucher static void btc_init_stutter_mode(struct radeon_device *rdev)
20686596afd4SAlex Deucher {
20696596afd4SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
20706596afd4SAlex Deucher 	u32 tmp;
20716596afd4SAlex Deucher 
20726596afd4SAlex Deucher 	if (pi->mclk_stutter_mode_threshold) {
20736596afd4SAlex Deucher 		if (pi->mem_gddr5) {
20746596afd4SAlex Deucher 			tmp = RREG32(MC_PMG_AUTO_CFG);
20756596afd4SAlex Deucher 			if ((0x200 & tmp) == 0) {
20766596afd4SAlex Deucher 				tmp = (tmp & 0xfffffc0b) | 0x204;
20776596afd4SAlex Deucher 				WREG32(MC_PMG_AUTO_CFG, tmp);
20786596afd4SAlex Deucher 			}
20796596afd4SAlex Deucher 		}
20806596afd4SAlex Deucher 	}
20816596afd4SAlex Deucher }
20826596afd4SAlex Deucher 
2083a84301c6SAlex Deucher bool btc_dpm_vblank_too_short(struct radeon_device *rdev)
2084a84301c6SAlex Deucher {
2085a84301c6SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
2086a84301c6SAlex Deucher 	u32 vblank_time = r600_dpm_get_vblank_time(rdev);
2087a84301c6SAlex Deucher 	u32 switch_limit = pi->mem_gddr5 ? 450 : 100;
2088a84301c6SAlex Deucher 
2089a84301c6SAlex Deucher 	if (vblank_time < switch_limit)
2090a84301c6SAlex Deucher 		return true;
2091a84301c6SAlex Deucher 	else
2092a84301c6SAlex Deucher 		return false;
2093a84301c6SAlex Deucher 
2094a84301c6SAlex Deucher }
2095a84301c6SAlex Deucher 
20964cb3a02fSAlex Deucher static void btc_apply_state_adjust_rules(struct radeon_device *rdev,
20974cb3a02fSAlex Deucher 					 struct radeon_ps *rps)
2098d22b7e40SAlex Deucher {
2099d22b7e40SAlex Deucher 	struct rv7xx_ps *ps = rv770_get_ps(rps);
2100d22b7e40SAlex Deucher 	struct radeon_clock_and_voltage_limits *max_limits;
2101d22b7e40SAlex Deucher 	bool disable_mclk_switching;
2102d22b7e40SAlex Deucher 	u32 mclk, sclk;
2103d22b7e40SAlex Deucher 	u16 vddc, vddci;
2104d22b7e40SAlex Deucher 
2105a84301c6SAlex Deucher 	if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
2106a84301c6SAlex Deucher 	    btc_dpm_vblank_too_short(rdev))
2107d22b7e40SAlex Deucher 		disable_mclk_switching = true;
2108d22b7e40SAlex Deucher 	else
2109d22b7e40SAlex Deucher 		disable_mclk_switching = false;
2110d22b7e40SAlex Deucher 
2111d22b7e40SAlex Deucher 	if (rdev->pm.dpm.ac_power)
2112d22b7e40SAlex Deucher 		max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
2113d22b7e40SAlex Deucher 	else
2114d22b7e40SAlex Deucher 		max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
2115d22b7e40SAlex Deucher 
2116d22b7e40SAlex Deucher 	if (rdev->pm.dpm.ac_power == false) {
2117d22b7e40SAlex Deucher 		if (ps->high.mclk > max_limits->mclk)
2118d22b7e40SAlex Deucher 			ps->high.mclk = max_limits->mclk;
2119d22b7e40SAlex Deucher 		if (ps->high.sclk > max_limits->sclk)
2120d22b7e40SAlex Deucher 			ps->high.sclk = max_limits->sclk;
2121d22b7e40SAlex Deucher 		if (ps->high.vddc > max_limits->vddc)
2122d22b7e40SAlex Deucher 			ps->high.vddc = max_limits->vddc;
2123d22b7e40SAlex Deucher 		if (ps->high.vddci > max_limits->vddci)
2124d22b7e40SAlex Deucher 			ps->high.vddci = max_limits->vddci;
2125d22b7e40SAlex Deucher 
2126d22b7e40SAlex Deucher 		if (ps->medium.mclk > max_limits->mclk)
2127d22b7e40SAlex Deucher 			ps->medium.mclk = max_limits->mclk;
2128d22b7e40SAlex Deucher 		if (ps->medium.sclk > max_limits->sclk)
2129d22b7e40SAlex Deucher 			ps->medium.sclk = max_limits->sclk;
2130d22b7e40SAlex Deucher 		if (ps->medium.vddc > max_limits->vddc)
2131d22b7e40SAlex Deucher 			ps->medium.vddc = max_limits->vddc;
2132d22b7e40SAlex Deucher 		if (ps->medium.vddci > max_limits->vddci)
2133d22b7e40SAlex Deucher 			ps->medium.vddci = max_limits->vddci;
2134d22b7e40SAlex Deucher 
2135d22b7e40SAlex Deucher 		if (ps->low.mclk > max_limits->mclk)
2136d22b7e40SAlex Deucher 			ps->low.mclk = max_limits->mclk;
2137d22b7e40SAlex Deucher 		if (ps->low.sclk > max_limits->sclk)
2138d22b7e40SAlex Deucher 			ps->low.sclk = max_limits->sclk;
2139d22b7e40SAlex Deucher 		if (ps->low.vddc > max_limits->vddc)
2140d22b7e40SAlex Deucher 			ps->low.vddc = max_limits->vddc;
2141d22b7e40SAlex Deucher 		if (ps->low.vddci > max_limits->vddci)
2142d22b7e40SAlex Deucher 			ps->low.vddci = max_limits->vddci;
2143d22b7e40SAlex Deucher 	}
2144d22b7e40SAlex Deucher 
2145d22b7e40SAlex Deucher 	/* XXX validate the min clocks required for display */
2146d22b7e40SAlex Deucher 
2147d22b7e40SAlex Deucher 	if (disable_mclk_switching) {
2148d22b7e40SAlex Deucher 		sclk = ps->low.sclk;
2149d22b7e40SAlex Deucher 		mclk = ps->high.mclk;
2150d22b7e40SAlex Deucher 		vddc = ps->low.vddc;
2151d22b7e40SAlex Deucher 		vddci = ps->high.vddci;
2152d22b7e40SAlex Deucher 	} else {
2153d22b7e40SAlex Deucher 		sclk = ps->low.sclk;
2154d22b7e40SAlex Deucher 		mclk = ps->low.mclk;
2155d22b7e40SAlex Deucher 		vddc = ps->low.vddc;
2156d22b7e40SAlex Deucher 		vddci = ps->low.vddci;
2157d22b7e40SAlex Deucher 	}
2158d22b7e40SAlex Deucher 
2159d22b7e40SAlex Deucher 	/* adjusted low state */
2160d22b7e40SAlex Deucher 	ps->low.sclk = sclk;
2161d22b7e40SAlex Deucher 	ps->low.mclk = mclk;
2162d22b7e40SAlex Deucher 	ps->low.vddc = vddc;
2163d22b7e40SAlex Deucher 	ps->low.vddci = vddci;
2164d22b7e40SAlex Deucher 
2165d22b7e40SAlex Deucher 	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
2166d22b7e40SAlex Deucher 				  &ps->low.sclk, &ps->low.mclk);
2167d22b7e40SAlex Deucher 
2168d22b7e40SAlex Deucher 	/* adjusted medium, high states */
2169d22b7e40SAlex Deucher 	if (ps->medium.sclk < ps->low.sclk)
2170d22b7e40SAlex Deucher 		ps->medium.sclk = ps->low.sclk;
2171d22b7e40SAlex Deucher 	if (ps->medium.vddc < ps->low.vddc)
2172d22b7e40SAlex Deucher 		ps->medium.vddc = ps->low.vddc;
2173d22b7e40SAlex Deucher 	if (ps->high.sclk < ps->medium.sclk)
2174d22b7e40SAlex Deucher 		ps->high.sclk = ps->medium.sclk;
2175d22b7e40SAlex Deucher 	if (ps->high.vddc < ps->medium.vddc)
2176d22b7e40SAlex Deucher 		ps->high.vddc = ps->medium.vddc;
2177d22b7e40SAlex Deucher 
2178d22b7e40SAlex Deucher 	if (disable_mclk_switching) {
2179d22b7e40SAlex Deucher 		mclk = ps->low.mclk;
2180d22b7e40SAlex Deucher 		if (mclk < ps->medium.mclk)
2181d22b7e40SAlex Deucher 			mclk = ps->medium.mclk;
2182d22b7e40SAlex Deucher 		if (mclk < ps->high.mclk)
2183d22b7e40SAlex Deucher 			mclk = ps->high.mclk;
2184d22b7e40SAlex Deucher 		ps->low.mclk = mclk;
2185d22b7e40SAlex Deucher 		ps->low.vddci = vddci;
2186d22b7e40SAlex Deucher 		ps->medium.mclk = mclk;
2187d22b7e40SAlex Deucher 		ps->medium.vddci = vddci;
2188d22b7e40SAlex Deucher 		ps->high.mclk = mclk;
2189d22b7e40SAlex Deucher 		ps->high.vddci = vddci;
2190d22b7e40SAlex Deucher 	} else {
2191d22b7e40SAlex Deucher 		if (ps->medium.mclk < ps->low.mclk)
2192d22b7e40SAlex Deucher 			ps->medium.mclk = ps->low.mclk;
2193d22b7e40SAlex Deucher 		if (ps->medium.vddci < ps->low.vddci)
2194d22b7e40SAlex Deucher 			ps->medium.vddci = ps->low.vddci;
2195d22b7e40SAlex Deucher 		if (ps->high.mclk < ps->medium.mclk)
2196d22b7e40SAlex Deucher 			ps->high.mclk = ps->medium.mclk;
2197d22b7e40SAlex Deucher 		if (ps->high.vddci < ps->medium.vddci)
2198d22b7e40SAlex Deucher 			ps->high.vddci = ps->medium.vddci;
2199d22b7e40SAlex Deucher 	}
2200d22b7e40SAlex Deucher 
2201d22b7e40SAlex Deucher 	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
2202d22b7e40SAlex Deucher 				  &ps->medium.sclk, &ps->medium.mclk);
2203d22b7e40SAlex Deucher 	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
2204d22b7e40SAlex Deucher 				  &ps->high.sclk, &ps->high.mclk);
2205d22b7e40SAlex Deucher 
2206d22b7e40SAlex Deucher 	btc_adjust_clock_combinations(rdev, max_limits, &ps->low);
2207d22b7e40SAlex Deucher 	btc_adjust_clock_combinations(rdev, max_limits, &ps->medium);
2208d22b7e40SAlex Deucher 	btc_adjust_clock_combinations(rdev, max_limits, &ps->high);
2209d22b7e40SAlex Deucher 
2210d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
2211d22b7e40SAlex Deucher 					   ps->low.sclk, max_limits->vddc, &ps->low.vddc);
2212d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
2213d22b7e40SAlex Deucher 					   ps->low.mclk, max_limits->vddci, &ps->low.vddci);
2214d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
2215d22b7e40SAlex Deucher 					   ps->low.mclk, max_limits->vddc, &ps->low.vddc);
22164489cd62SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
22174489cd62SAlex Deucher 					   rdev->clock.current_dispclk, max_limits->vddc, &ps->low.vddc);
22184489cd62SAlex Deucher 
2219d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
2220d22b7e40SAlex Deucher 					   ps->medium.sclk, max_limits->vddc, &ps->medium.vddc);
2221d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
2222d22b7e40SAlex Deucher 					   ps->medium.mclk, max_limits->vddci, &ps->medium.vddci);
2223d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
2224d22b7e40SAlex Deucher 					   ps->medium.mclk, max_limits->vddc, &ps->medium.vddc);
22254489cd62SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
22264489cd62SAlex Deucher 					   rdev->clock.current_dispclk, max_limits->vddc, &ps->medium.vddc);
22274489cd62SAlex Deucher 
2228d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
2229d22b7e40SAlex Deucher 					   ps->high.sclk, max_limits->vddc, &ps->high.vddc);
2230d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
2231d22b7e40SAlex Deucher 					   ps->high.mclk, max_limits->vddci, &ps->high.vddci);
2232d22b7e40SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
2233d22b7e40SAlex Deucher 					   ps->high.mclk, max_limits->vddc, &ps->high.vddc);
22344489cd62SAlex Deucher 	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
22354489cd62SAlex Deucher 					   rdev->clock.current_dispclk, max_limits->vddc, &ps->high.vddc);
2236d22b7e40SAlex Deucher 
2237d22b7e40SAlex Deucher 	btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
2238d22b7e40SAlex Deucher 				      &ps->low.vddc, &ps->low.vddci);
2239d22b7e40SAlex Deucher 	btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
2240d22b7e40SAlex Deucher 				      &ps->medium.vddc, &ps->medium.vddci);
2241d22b7e40SAlex Deucher 	btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
2242d22b7e40SAlex Deucher 				      &ps->high.vddc, &ps->high.vddci);
2243d22b7e40SAlex Deucher 
2244d22b7e40SAlex Deucher 	if ((ps->high.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) &&
2245d22b7e40SAlex Deucher 	    (ps->medium.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) &&
2246d22b7e40SAlex Deucher 	    (ps->low.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc))
2247d22b7e40SAlex Deucher 		ps->dc_compatible = true;
2248d22b7e40SAlex Deucher 	else
2249d22b7e40SAlex Deucher 		ps->dc_compatible = false;
2250d22b7e40SAlex Deucher 
2251d22b7e40SAlex Deucher 	if (ps->low.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
2252d22b7e40SAlex Deucher 		ps->low.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
2253d22b7e40SAlex Deucher 	if (ps->medium.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
2254d22b7e40SAlex Deucher 		ps->medium.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
2255d22b7e40SAlex Deucher 	if (ps->high.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
2256d22b7e40SAlex Deucher 		ps->high.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
2257d22b7e40SAlex Deucher }
2258d22b7e40SAlex Deucher 
2259e8a9539fSAlex Deucher static void btc_update_current_ps(struct radeon_device *rdev,
2260e8a9539fSAlex Deucher 				  struct radeon_ps *rps)
2261e8a9539fSAlex Deucher {
2262e8a9539fSAlex Deucher 	struct rv7xx_ps *new_ps = rv770_get_ps(rps);
2263e8a9539fSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2264e8a9539fSAlex Deucher 
2265e8a9539fSAlex Deucher 	eg_pi->current_rps = *rps;
2266e8a9539fSAlex Deucher 	eg_pi->current_ps = *new_ps;
2267e8a9539fSAlex Deucher 	eg_pi->current_rps.ps_priv = &eg_pi->current_ps;
2268e8a9539fSAlex Deucher }
2269e8a9539fSAlex Deucher 
2270e8a9539fSAlex Deucher static void btc_update_requested_ps(struct radeon_device *rdev,
2271e8a9539fSAlex Deucher 				    struct radeon_ps *rps)
2272e8a9539fSAlex Deucher {
2273e8a9539fSAlex Deucher 	struct rv7xx_ps *new_ps = rv770_get_ps(rps);
2274e8a9539fSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2275e8a9539fSAlex Deucher 
2276e8a9539fSAlex Deucher 	eg_pi->requested_rps = *rps;
2277e8a9539fSAlex Deucher 	eg_pi->requested_ps = *new_ps;
2278e8a9539fSAlex Deucher 	eg_pi->requested_rps.ps_priv = &eg_pi->requested_ps;
2279e8a9539fSAlex Deucher }
2280e8a9539fSAlex Deucher 
22817ff96f9dSAlex Deucher #if 0
22826596afd4SAlex Deucher void btc_dpm_reset_asic(struct radeon_device *rdev)
22836596afd4SAlex Deucher {
22846596afd4SAlex Deucher 	rv770_restrict_performance_levels_before_switch(rdev);
22856596afd4SAlex Deucher 	btc_disable_ulv(rdev);
22866596afd4SAlex Deucher 	btc_set_boot_state_timing(rdev);
22876596afd4SAlex Deucher 	rv770_set_boot_state(rdev);
22886596afd4SAlex Deucher }
22897ff96f9dSAlex Deucher #endif
22906596afd4SAlex Deucher 
2291e8a9539fSAlex Deucher int btc_dpm_pre_set_power_state(struct radeon_device *rdev)
2292e8a9539fSAlex Deucher {
2293e8a9539fSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2294e8a9539fSAlex Deucher 	struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps;
2295e8a9539fSAlex Deucher 	struct radeon_ps *new_ps = &requested_ps;
2296e8a9539fSAlex Deucher 
2297e8a9539fSAlex Deucher 	btc_update_requested_ps(rdev, new_ps);
2298e8a9539fSAlex Deucher 
2299e8a9539fSAlex Deucher 	btc_apply_state_adjust_rules(rdev, &eg_pi->requested_rps);
2300e8a9539fSAlex Deucher 
2301e8a9539fSAlex Deucher 	return 0;
2302e8a9539fSAlex Deucher }
2303e8a9539fSAlex Deucher 
23046596afd4SAlex Deucher int btc_dpm_set_power_state(struct radeon_device *rdev)
23056596afd4SAlex Deucher {
23066596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2307e8a9539fSAlex Deucher 	struct radeon_ps *new_ps = &eg_pi->requested_rps;
2308e8a9539fSAlex Deucher 	struct radeon_ps *old_ps = &eg_pi->current_rps;
2309aafb3afaSAlex Deucher 	int ret;
2310d22b7e40SAlex Deucher 
2311aafb3afaSAlex Deucher 	ret = btc_disable_ulv(rdev);
23126596afd4SAlex Deucher 	btc_set_boot_state_timing(rdev);
2313aafb3afaSAlex Deucher 	ret = rv770_restrict_performance_levels_before_switch(rdev);
231472dd2c54SAlex Deucher 	if (ret) {
231572dd2c54SAlex Deucher 		DRM_ERROR("rv770_restrict_performance_levels_before_switch failed\n");
2316aafb3afaSAlex Deucher 		return ret;
231772dd2c54SAlex Deucher 	}
23186596afd4SAlex Deucher 	if (eg_pi->pcie_performance_request)
2319dbc34160SAlex Deucher 		cypress_notify_link_speed_change_before_state_change(rdev, new_ps, old_ps);
23206596afd4SAlex Deucher 
23215d77d776SAlex Deucher 	rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
2322aafb3afaSAlex Deucher 	ret = rv770_halt_smc(rdev);
232372dd2c54SAlex Deucher 	if (ret) {
232472dd2c54SAlex Deucher 		DRM_ERROR("rv770_halt_smc failed\n");
2325aafb3afaSAlex Deucher 		return ret;
232672dd2c54SAlex Deucher 	}
23274cb3a02fSAlex Deucher 	btc_set_at_for_uvd(rdev, new_ps);
2328f85392bcSAlex Deucher 	if (eg_pi->smu_uvd_hs)
23294cb3a02fSAlex Deucher 		btc_notify_uvd_to_smc(rdev, new_ps);
2330aafb3afaSAlex Deucher 	ret = cypress_upload_sw_state(rdev, new_ps);
233172dd2c54SAlex Deucher 	if (ret) {
233272dd2c54SAlex Deucher 		DRM_ERROR("cypress_upload_sw_state failed\n");
2333aafb3afaSAlex Deucher 		return ret;
233472dd2c54SAlex Deucher 	}
2335aafb3afaSAlex Deucher 	if (eg_pi->dynamic_ac_timing) {
2336aafb3afaSAlex Deucher 		ret = cypress_upload_mc_reg_table(rdev, new_ps);
233772dd2c54SAlex Deucher 		if (ret) {
233872dd2c54SAlex Deucher 			DRM_ERROR("cypress_upload_mc_reg_table failed\n");
2339aafb3afaSAlex Deucher 			return ret;
2340aafb3afaSAlex Deucher 		}
234172dd2c54SAlex Deucher 	}
23426596afd4SAlex Deucher 
2343dbc34160SAlex Deucher 	cypress_program_memory_timing_parameters(rdev, new_ps);
23446596afd4SAlex Deucher 
2345aafb3afaSAlex Deucher 	ret = rv770_resume_smc(rdev);
234672dd2c54SAlex Deucher 	if (ret) {
234772dd2c54SAlex Deucher 		DRM_ERROR("rv770_resume_smc failed\n");
2348aafb3afaSAlex Deucher 		return ret;
234972dd2c54SAlex Deucher 	}
2350aafb3afaSAlex Deucher 	ret = rv770_set_sw_state(rdev);
235172dd2c54SAlex Deucher 	if (ret) {
235272dd2c54SAlex Deucher 		DRM_ERROR("rv770_set_sw_state failed\n");
2353aafb3afaSAlex Deucher 		return ret;
235472dd2c54SAlex Deucher 	}
23555d77d776SAlex Deucher 	rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
23566596afd4SAlex Deucher 
23576596afd4SAlex Deucher 	if (eg_pi->pcie_performance_request)
2358dbc34160SAlex Deucher 		cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
23596596afd4SAlex Deucher 
2360aafb3afaSAlex Deucher 	ret = btc_set_power_state_conditionally_enable_ulv(rdev, new_ps);
236172dd2c54SAlex Deucher 	if (ret) {
236272dd2c54SAlex Deucher 		DRM_ERROR("btc_set_power_state_conditionally_enable_ulv failed\n");
2363aafb3afaSAlex Deucher 		return ret;
236472dd2c54SAlex Deucher 	}
23656596afd4SAlex Deucher 
23666596afd4SAlex Deucher 	return 0;
23676596afd4SAlex Deucher }
23686596afd4SAlex Deucher 
2369e8a9539fSAlex Deucher void btc_dpm_post_set_power_state(struct radeon_device *rdev)
2370e8a9539fSAlex Deucher {
2371e8a9539fSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2372e8a9539fSAlex Deucher 	struct radeon_ps *new_ps = &eg_pi->requested_rps;
2373e8a9539fSAlex Deucher 
2374e8a9539fSAlex Deucher 	btc_update_current_ps(rdev, new_ps);
2375e8a9539fSAlex Deucher }
2376e8a9539fSAlex Deucher 
23776596afd4SAlex Deucher int btc_dpm_enable(struct radeon_device *rdev)
23786596afd4SAlex Deucher {
23796596afd4SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
23806596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2381dbc34160SAlex Deucher 	struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
2382aafb3afaSAlex Deucher 	int ret;
23836596afd4SAlex Deucher 
23846596afd4SAlex Deucher 	if (pi->gfx_clock_gating)
23856596afd4SAlex Deucher 		btc_cg_clock_gating_default(rdev);
23866596afd4SAlex Deucher 
23876596afd4SAlex Deucher 	if (btc_dpm_enabled(rdev))
23886596afd4SAlex Deucher 		return -EINVAL;
23896596afd4SAlex Deucher 
23906596afd4SAlex Deucher 	if (pi->mg_clock_gating)
23916596afd4SAlex Deucher 		btc_mg_clock_gating_default(rdev);
23926596afd4SAlex Deucher 
23936596afd4SAlex Deucher 	if (eg_pi->ls_clock_gating)
23946596afd4SAlex Deucher 		btc_ls_clock_gating_default(rdev);
23956596afd4SAlex Deucher 
23966596afd4SAlex Deucher 	if (pi->voltage_control) {
23976596afd4SAlex Deucher 		rv770_enable_voltage_control(rdev, true);
2398aafb3afaSAlex Deucher 		ret = cypress_construct_voltage_tables(rdev);
2399fa4b5471SAlex Deucher 		if (ret) {
2400fa4b5471SAlex Deucher 			DRM_ERROR("cypress_construct_voltage_tables failed\n");
2401aafb3afaSAlex Deucher 			return ret;
24026596afd4SAlex Deucher 		}
2403fa4b5471SAlex Deucher 	}
24046596afd4SAlex Deucher 
2405aafb3afaSAlex Deucher 	if (pi->mvdd_control) {
2406aafb3afaSAlex Deucher 		ret = cypress_get_mvdd_configuration(rdev);
2407fa4b5471SAlex Deucher 		if (ret) {
2408fa4b5471SAlex Deucher 			DRM_ERROR("cypress_get_mvdd_configuration failed\n");
2409aafb3afaSAlex Deucher 			return ret;
2410aafb3afaSAlex Deucher 		}
2411fa4b5471SAlex Deucher 	}
24126596afd4SAlex Deucher 
2413aafb3afaSAlex Deucher 	if (eg_pi->dynamic_ac_timing) {
2414aafb3afaSAlex Deucher 		ret = btc_initialize_mc_reg_table(rdev);
2415aafb3afaSAlex Deucher 		if (ret)
2416aafb3afaSAlex Deucher 			eg_pi->dynamic_ac_timing = false;
2417aafb3afaSAlex Deucher 	}
24186596afd4SAlex Deucher 
24196596afd4SAlex Deucher 	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_BACKBIAS)
24206596afd4SAlex Deucher 		rv770_enable_backbias(rdev, true);
24216596afd4SAlex Deucher 
24226596afd4SAlex Deucher 	if (pi->dynamic_ss)
24236596afd4SAlex Deucher 		cypress_enable_spread_spectrum(rdev, true);
24246596afd4SAlex Deucher 
24256596afd4SAlex Deucher 	if (pi->thermal_protection)
24266596afd4SAlex Deucher 		rv770_enable_thermal_protection(rdev, true);
24276596afd4SAlex Deucher 
24286596afd4SAlex Deucher 	rv770_setup_bsp(rdev);
24296596afd4SAlex Deucher 	rv770_program_git(rdev);
24306596afd4SAlex Deucher 	rv770_program_tp(rdev);
24316596afd4SAlex Deucher 	rv770_program_tpp(rdev);
24326596afd4SAlex Deucher 	rv770_program_sstp(rdev);
24336596afd4SAlex Deucher 	rv770_program_engine_speed_parameters(rdev);
24346596afd4SAlex Deucher 	cypress_enable_display_gap(rdev);
24356596afd4SAlex Deucher 	rv770_program_vc(rdev);
24366596afd4SAlex Deucher 
24376596afd4SAlex Deucher 	if (pi->dynamic_pcie_gen2)
24386596afd4SAlex Deucher 		btc_enable_dynamic_pcie_gen2(rdev, true);
24396596afd4SAlex Deucher 
2440aafb3afaSAlex Deucher 	ret = rv770_upload_firmware(rdev);
2441fa4b5471SAlex Deucher 	if (ret) {
2442fa4b5471SAlex Deucher 		DRM_ERROR("rv770_upload_firmware failed\n");
2443aafb3afaSAlex Deucher 		return ret;
2444fa4b5471SAlex Deucher 	}
2445aafb3afaSAlex Deucher 	ret = cypress_get_table_locations(rdev);
2446fa4b5471SAlex Deucher 	if (ret) {
2447fa4b5471SAlex Deucher 		DRM_ERROR("cypress_get_table_locations failed\n");
2448aafb3afaSAlex Deucher 		return ret;
2449fa4b5471SAlex Deucher 	}
2450aafb3afaSAlex Deucher 	ret = btc_init_smc_table(rdev, boot_ps);
2451aafb3afaSAlex Deucher 	if (ret)
2452aafb3afaSAlex Deucher 		return ret;
24536596afd4SAlex Deucher 
2454aafb3afaSAlex Deucher 	if (eg_pi->dynamic_ac_timing) {
2455aafb3afaSAlex Deucher 		ret = cypress_populate_mc_reg_table(rdev, boot_ps);
2456fa4b5471SAlex Deucher 		if (ret) {
2457fa4b5471SAlex Deucher 			DRM_ERROR("cypress_populate_mc_reg_table failed\n");
2458aafb3afaSAlex Deucher 			return ret;
2459aafb3afaSAlex Deucher 		}
2460fa4b5471SAlex Deucher 	}
24616596afd4SAlex Deucher 
24626596afd4SAlex Deucher 	cypress_program_response_times(rdev);
24636596afd4SAlex Deucher 	r7xx_start_smc(rdev);
2464aafb3afaSAlex Deucher 	ret = cypress_notify_smc_display_change(rdev, false);
2465fa4b5471SAlex Deucher 	if (ret) {
2466fa4b5471SAlex Deucher 		DRM_ERROR("cypress_notify_smc_display_change failed\n");
2467aafb3afaSAlex Deucher 		return ret;
2468fa4b5471SAlex Deucher 	}
24696596afd4SAlex Deucher 	cypress_enable_sclk_control(rdev, true);
24706596afd4SAlex Deucher 
24716596afd4SAlex Deucher 	if (eg_pi->memory_transition)
24726596afd4SAlex Deucher 		cypress_enable_mclk_control(rdev, true);
24736596afd4SAlex Deucher 
24746596afd4SAlex Deucher 	cypress_start_dpm(rdev);
24756596afd4SAlex Deucher 
24766596afd4SAlex Deucher 	if (pi->gfx_clock_gating)
24776596afd4SAlex Deucher 		btc_cg_clock_gating_enable(rdev, true);
24786596afd4SAlex Deucher 
24796596afd4SAlex Deucher 	if (pi->mg_clock_gating)
24806596afd4SAlex Deucher 		btc_mg_clock_gating_enable(rdev, true);
24816596afd4SAlex Deucher 
24826596afd4SAlex Deucher 	if (eg_pi->ls_clock_gating)
24836596afd4SAlex Deucher 		btc_ls_clock_gating_enable(rdev, true);
24846596afd4SAlex Deucher 
24856596afd4SAlex Deucher 	rv770_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
24866596afd4SAlex Deucher 
24876596afd4SAlex Deucher 	btc_init_stutter_mode(rdev);
24886596afd4SAlex Deucher 
2489e8a9539fSAlex Deucher 	btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
2490e8a9539fSAlex Deucher 
24916596afd4SAlex Deucher 	return 0;
24926596afd4SAlex Deucher };
24936596afd4SAlex Deucher 
24946596afd4SAlex Deucher void btc_dpm_disable(struct radeon_device *rdev)
24956596afd4SAlex Deucher {
24966596afd4SAlex Deucher 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
24976596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
24986596afd4SAlex Deucher 
24996596afd4SAlex Deucher 	if (!btc_dpm_enabled(rdev))
25006596afd4SAlex Deucher 		return;
25016596afd4SAlex Deucher 
25026596afd4SAlex Deucher 	rv770_clear_vc(rdev);
25036596afd4SAlex Deucher 
25046596afd4SAlex Deucher 	if (pi->thermal_protection)
25056596afd4SAlex Deucher 		rv770_enable_thermal_protection(rdev, false);
25066596afd4SAlex Deucher 
25076596afd4SAlex Deucher 	if (pi->dynamic_pcie_gen2)
25086596afd4SAlex Deucher 		btc_enable_dynamic_pcie_gen2(rdev, false);
25096596afd4SAlex Deucher 
25106596afd4SAlex Deucher 	if (rdev->irq.installed &&
25116596afd4SAlex Deucher 	    r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) {
25126596afd4SAlex Deucher 		rdev->irq.dpm_thermal = false;
25136596afd4SAlex Deucher 		radeon_irq_set(rdev);
25146596afd4SAlex Deucher 	}
25156596afd4SAlex Deucher 
25166596afd4SAlex Deucher 	if (pi->gfx_clock_gating)
25176596afd4SAlex Deucher 		btc_cg_clock_gating_enable(rdev, false);
25186596afd4SAlex Deucher 
25196596afd4SAlex Deucher 	if (pi->mg_clock_gating)
25206596afd4SAlex Deucher 		btc_mg_clock_gating_enable(rdev, false);
25216596afd4SAlex Deucher 
25226596afd4SAlex Deucher 	if (eg_pi->ls_clock_gating)
25236596afd4SAlex Deucher 		btc_ls_clock_gating_enable(rdev, false);
25246596afd4SAlex Deucher 
25256596afd4SAlex Deucher 	rv770_stop_dpm(rdev);
25266596afd4SAlex Deucher 	btc_reset_to_default(rdev);
25276596afd4SAlex Deucher 	btc_stop_smc(rdev);
25286596afd4SAlex Deucher 	cypress_enable_spread_spectrum(rdev, false);
2529e8a9539fSAlex Deucher 
2530e8a9539fSAlex Deucher 	btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
25316596afd4SAlex Deucher }
25326596afd4SAlex Deucher 
25336596afd4SAlex Deucher void btc_dpm_setup_asic(struct radeon_device *rdev)
25346596afd4SAlex Deucher {
25356596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
25366c7bcceaSAlex Deucher 	int r;
25376596afd4SAlex Deucher 
25386c7bcceaSAlex Deucher 	r = ni_mc_load_microcode(rdev);
25396c7bcceaSAlex Deucher 	if (r)
25406c7bcceaSAlex Deucher 		DRM_ERROR("Failed to load MC firmware!\n");
25416596afd4SAlex Deucher 	rv770_get_memory_type(rdev);
25426596afd4SAlex Deucher 	rv740_read_clock_registers(rdev);
25436596afd4SAlex Deucher 	btc_read_arb_registers(rdev);
25446596afd4SAlex Deucher 	rv770_read_voltage_smio_registers(rdev);
25456596afd4SAlex Deucher 
25466596afd4SAlex Deucher 	if (eg_pi->pcie_performance_request)
25476596afd4SAlex Deucher 		cypress_advertise_gen2_capability(rdev);
25486596afd4SAlex Deucher 
25496596afd4SAlex Deucher 	rv770_get_pcie_gen2_status(rdev);
25506596afd4SAlex Deucher 	rv770_enable_acpi_pm(rdev);
25516596afd4SAlex Deucher }
25526596afd4SAlex Deucher 
25536596afd4SAlex Deucher int btc_dpm_init(struct radeon_device *rdev)
25546596afd4SAlex Deucher {
25556596afd4SAlex Deucher 	struct rv7xx_power_info *pi;
25566596afd4SAlex Deucher 	struct evergreen_power_info *eg_pi;
25576596afd4SAlex Deucher 	struct atom_clock_dividers dividers;
25586596afd4SAlex Deucher 	int ret;
25596596afd4SAlex Deucher 
25606596afd4SAlex Deucher 	eg_pi = kzalloc(sizeof(struct evergreen_power_info), GFP_KERNEL);
25616596afd4SAlex Deucher 	if (eg_pi == NULL)
25626596afd4SAlex Deucher 		return -ENOMEM;
25636596afd4SAlex Deucher 	rdev->pm.dpm.priv = eg_pi;
25646596afd4SAlex Deucher 	pi = &eg_pi->rv7xx;
25656596afd4SAlex Deucher 
25666596afd4SAlex Deucher 	rv770_get_max_vddc(rdev);
25676596afd4SAlex Deucher 
25686596afd4SAlex Deucher 	eg_pi->ulv.supported = false;
25696596afd4SAlex Deucher 	pi->acpi_vddc = 0;
25706596afd4SAlex Deucher 	eg_pi->acpi_vddci = 0;
25716596afd4SAlex Deucher 	pi->min_vddc_in_table = 0;
25726596afd4SAlex Deucher 	pi->max_vddc_in_table = 0;
25736596afd4SAlex Deucher 
257482f79cc5SAlex Deucher 	ret = r600_get_platform_caps(rdev);
257582f79cc5SAlex Deucher 	if (ret)
257682f79cc5SAlex Deucher 		return ret;
257782f79cc5SAlex Deucher 
25786596afd4SAlex Deucher 	ret = rv7xx_parse_power_table(rdev);
25796596afd4SAlex Deucher 	if (ret)
25806596afd4SAlex Deucher 		return ret;
2581d22b7e40SAlex Deucher 	ret = r600_parse_extended_power_table(rdev);
2582d22b7e40SAlex Deucher 	if (ret)
2583d22b7e40SAlex Deucher 		return ret;
25846596afd4SAlex Deucher 
25854489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
25866396bb22SKees Cook 		kcalloc(4,
25876396bb22SKees Cook 			sizeof(struct radeon_clock_voltage_dependency_entry),
25886396bb22SKees Cook 			GFP_KERNEL);
25894489cd62SAlex Deucher 	if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
25904489cd62SAlex Deucher 		r600_free_extended_power_table(rdev);
25914489cd62SAlex Deucher 		return -ENOMEM;
25924489cd62SAlex Deucher 	}
25934489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
25944489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
25954489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
25964489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
25974489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 800;
25984489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
25994489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 800;
26004489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
26014489cd62SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 800;
26024489cd62SAlex Deucher 
26036596afd4SAlex Deucher 	if (rdev->pm.dpm.voltage_response_time == 0)
26046596afd4SAlex Deucher 		rdev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
26056596afd4SAlex Deucher 	if (rdev->pm.dpm.backbias_response_time == 0)
26066596afd4SAlex Deucher 		rdev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
26076596afd4SAlex Deucher 
26086596afd4SAlex Deucher 	ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
26096596afd4SAlex Deucher 					     0, false, &dividers);
26106596afd4SAlex Deucher 	if (ret)
26116596afd4SAlex Deucher 		pi->ref_div = dividers.ref_div + 1;
26126596afd4SAlex Deucher 	else
26136596afd4SAlex Deucher 		pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
26146596afd4SAlex Deucher 
26156596afd4SAlex Deucher 	pi->mclk_strobe_mode_threshold = 40000;
26166596afd4SAlex Deucher 	pi->mclk_edc_enable_threshold = 40000;
26176596afd4SAlex Deucher 	eg_pi->mclk_edc_wr_enable_threshold = 40000;
26186596afd4SAlex Deucher 
2619f85392bcSAlex Deucher 	pi->rlp = RV770_RLP_DFLT;
2620f85392bcSAlex Deucher 	pi->rmp = RV770_RMP_DFLT;
2621f85392bcSAlex Deucher 	pi->lhp = RV770_LHP_DFLT;
2622f85392bcSAlex Deucher 	pi->lmp = RV770_LMP_DFLT;
2623f85392bcSAlex Deucher 
2624f85392bcSAlex Deucher 	eg_pi->ats[0].rlp = RV770_RLP_DFLT;
2625f85392bcSAlex Deucher 	eg_pi->ats[0].rmp = RV770_RMP_DFLT;
2626f85392bcSAlex Deucher 	eg_pi->ats[0].lhp = RV770_LHP_DFLT;
2627f85392bcSAlex Deucher 	eg_pi->ats[0].lmp = RV770_LMP_DFLT;
2628f85392bcSAlex Deucher 
2629f85392bcSAlex Deucher 	eg_pi->ats[1].rlp = BTC_RLP_UVD_DFLT;
2630f85392bcSAlex Deucher 	eg_pi->ats[1].rmp = BTC_RMP_UVD_DFLT;
2631f85392bcSAlex Deucher 	eg_pi->ats[1].lhp = BTC_LHP_UVD_DFLT;
2632f85392bcSAlex Deucher 	eg_pi->ats[1].lmp = BTC_LMP_UVD_DFLT;
2633f85392bcSAlex Deucher 
2634f85392bcSAlex Deucher 	eg_pi->smu_uvd_hs = true;
2635f85392bcSAlex Deucher 
26366596afd4SAlex Deucher 	pi->voltage_control =
263758653abdSAlex Deucher 		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, 0);
26386596afd4SAlex Deucher 
26396596afd4SAlex Deucher 	pi->mvdd_control =
264058653abdSAlex Deucher 		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0);
26416596afd4SAlex Deucher 
26426596afd4SAlex Deucher 	eg_pi->vddci_control =
264358653abdSAlex Deucher 		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
26446596afd4SAlex Deucher 
2645b841ce7bSAlex Deucher 	rv770_get_engine_memory_ss(rdev);
26466596afd4SAlex Deucher 
26476596afd4SAlex Deucher 	pi->asi = RV770_ASI_DFLT;
26486596afd4SAlex Deucher 	pi->pasi = CYPRESS_HASI_DFLT;
26496596afd4SAlex Deucher 	pi->vrc = CYPRESS_VRC_DFLT;
26506596afd4SAlex Deucher 
26516596afd4SAlex Deucher 	pi->power_gating = false;
26526596afd4SAlex Deucher 
26536596afd4SAlex Deucher 	pi->gfx_clock_gating = true;
26546596afd4SAlex Deucher 
26556596afd4SAlex Deucher 	pi->mg_clock_gating = true;
26566596afd4SAlex Deucher 	pi->mgcgtssm = true;
26576596afd4SAlex Deucher 	eg_pi->ls_clock_gating = false;
26586596afd4SAlex Deucher 	eg_pi->sclk_deep_sleep = false;
26596596afd4SAlex Deucher 
26606596afd4SAlex Deucher 	pi->dynamic_pcie_gen2 = true;
26616596afd4SAlex Deucher 
2662fda83724SAlex Deucher 	if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
26636596afd4SAlex Deucher 		pi->thermal_protection = true;
26646596afd4SAlex Deucher 	else
26656596afd4SAlex Deucher 		pi->thermal_protection = false;
26666596afd4SAlex Deucher 
26676596afd4SAlex Deucher 	pi->display_gap = true;
26686596afd4SAlex Deucher 
26696596afd4SAlex Deucher 	if (rdev->flags & RADEON_IS_MOBILITY)
26706596afd4SAlex Deucher 		pi->dcodt = true;
26716596afd4SAlex Deucher 	else
26726596afd4SAlex Deucher 		pi->dcodt = false;
26736596afd4SAlex Deucher 
26746596afd4SAlex Deucher 	pi->ulps = true;
26756596afd4SAlex Deucher 
26766596afd4SAlex Deucher 	eg_pi->dynamic_ac_timing = true;
26776596afd4SAlex Deucher 	eg_pi->abm = true;
26786596afd4SAlex Deucher 	eg_pi->mcls = true;
26796596afd4SAlex Deucher 	eg_pi->light_sleep = true;
26806596afd4SAlex Deucher 	eg_pi->memory_transition = true;
26816596afd4SAlex Deucher #if defined(CONFIG_ACPI)
26826596afd4SAlex Deucher 	eg_pi->pcie_performance_request =
26836596afd4SAlex Deucher 		radeon_acpi_is_pcie_performance_request_supported(rdev);
26846596afd4SAlex Deucher #else
26856596afd4SAlex Deucher 	eg_pi->pcie_performance_request = false;
26866596afd4SAlex Deucher #endif
26876596afd4SAlex Deucher 
26886596afd4SAlex Deucher 	if (rdev->family == CHIP_BARTS)
26896596afd4SAlex Deucher 		eg_pi->dll_default_on = true;
26906596afd4SAlex Deucher 	else
26916596afd4SAlex Deucher 		eg_pi->dll_default_on = false;
26926596afd4SAlex Deucher 
26936596afd4SAlex Deucher 	eg_pi->sclk_deep_sleep = false;
26946596afd4SAlex Deucher 	if (ASIC_IS_LOMBOK(rdev))
26956596afd4SAlex Deucher 		pi->mclk_stutter_mode_threshold = 30000;
26966596afd4SAlex Deucher 	else
26976596afd4SAlex Deucher 		pi->mclk_stutter_mode_threshold = 0;
26986596afd4SAlex Deucher 
26996596afd4SAlex Deucher 	pi->sram_end = SMC_RAM_END;
27006596afd4SAlex Deucher 
2701d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
2702d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
2703d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2 = 900;
2704d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.valid_sclk_values.count = ARRAY_SIZE(btc_valid_sclk);
2705d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.valid_sclk_values.values = btc_valid_sclk;
2706d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
2707d22b7e40SAlex Deucher 	rdev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
2708d22b7e40SAlex Deucher 
2709d22b7e40SAlex Deucher 	if (rdev->family == CHIP_TURKS)
2710d22b7e40SAlex Deucher 		rdev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
2711d22b7e40SAlex Deucher 	else
2712d22b7e40SAlex Deucher 		rdev->pm.dpm.dyn_state.sclk_mclk_delta = 10000;
2713d22b7e40SAlex Deucher 
27141ff60ddbSAlex Deucher 	/* make sure dc limits are valid */
27151ff60ddbSAlex Deucher 	if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
27161ff60ddbSAlex Deucher 	    (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
27171ff60ddbSAlex Deucher 		rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
27181ff60ddbSAlex Deucher 			rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
27191ff60ddbSAlex Deucher 
27206596afd4SAlex Deucher 	return 0;
27216596afd4SAlex Deucher }
27226596afd4SAlex Deucher 
27236596afd4SAlex Deucher void btc_dpm_fini(struct radeon_device *rdev)
27246596afd4SAlex Deucher {
27256596afd4SAlex Deucher 	int i;
27266596afd4SAlex Deucher 
27276596afd4SAlex Deucher 	for (i = 0; i < rdev->pm.dpm.num_ps; i++) {
27286596afd4SAlex Deucher 		kfree(rdev->pm.dpm.ps[i].ps_priv);
27296596afd4SAlex Deucher 	}
27306596afd4SAlex Deucher 	kfree(rdev->pm.dpm.ps);
27316596afd4SAlex Deucher 	kfree(rdev->pm.dpm.priv);
27324489cd62SAlex Deucher 	kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
2733d22b7e40SAlex Deucher 	r600_free_extended_power_table(rdev);
27346596afd4SAlex Deucher }
2735e8a9539fSAlex Deucher 
27369f3f63f2SAlex Deucher void btc_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
27379f3f63f2SAlex Deucher 						     struct seq_file *m)
27389f3f63f2SAlex Deucher {
27399f3f63f2SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
27409f3f63f2SAlex Deucher 	struct radeon_ps *rps = &eg_pi->current_rps;
27419f3f63f2SAlex Deucher 	struct rv7xx_ps *ps = rv770_get_ps(rps);
27429f3f63f2SAlex Deucher 	struct rv7xx_pl *pl;
27439f3f63f2SAlex Deucher 	u32 current_index =
27449f3f63f2SAlex Deucher 		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
27459f3f63f2SAlex Deucher 		CURRENT_PROFILE_INDEX_SHIFT;
27469f3f63f2SAlex Deucher 
27479f3f63f2SAlex Deucher 	if (current_index > 2) {
27489f3f63f2SAlex Deucher 		seq_printf(m, "invalid dpm profile %d\n", current_index);
27499f3f63f2SAlex Deucher 	} else {
27509f3f63f2SAlex Deucher 		if (current_index == 0)
27519f3f63f2SAlex Deucher 			pl = &ps->low;
27529f3f63f2SAlex Deucher 		else if (current_index == 1)
27539f3f63f2SAlex Deucher 			pl = &ps->medium;
27549f3f63f2SAlex Deucher 		else /* current_index == 2 */
27559f3f63f2SAlex Deucher 			pl = &ps->high;
27569f3f63f2SAlex Deucher 		seq_printf(m, "uvd    vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
27579f3f63f2SAlex Deucher 		seq_printf(m, "power level %d    sclk: %u mclk: %u vddc: %u vddci: %u\n",
27589f3f63f2SAlex Deucher 			   current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci);
27599f3f63f2SAlex Deucher 	}
27609f3f63f2SAlex Deucher }
27619f3f63f2SAlex Deucher 
276299550ee9SAlex Deucher u32 btc_dpm_get_current_sclk(struct radeon_device *rdev)
276399550ee9SAlex Deucher {
276499550ee9SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
276599550ee9SAlex Deucher 	struct radeon_ps *rps = &eg_pi->current_rps;
276699550ee9SAlex Deucher 	struct rv7xx_ps *ps = rv770_get_ps(rps);
276799550ee9SAlex Deucher 	struct rv7xx_pl *pl;
276899550ee9SAlex Deucher 	u32 current_index =
276999550ee9SAlex Deucher 		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
277099550ee9SAlex Deucher 		CURRENT_PROFILE_INDEX_SHIFT;
277199550ee9SAlex Deucher 
277299550ee9SAlex Deucher 	if (current_index > 2) {
277399550ee9SAlex Deucher 		return 0;
277499550ee9SAlex Deucher 	} else {
277599550ee9SAlex Deucher 		if (current_index == 0)
277699550ee9SAlex Deucher 			pl = &ps->low;
277799550ee9SAlex Deucher 		else if (current_index == 1)
277899550ee9SAlex Deucher 			pl = &ps->medium;
277999550ee9SAlex Deucher 		else /* current_index == 2 */
278099550ee9SAlex Deucher 			pl = &ps->high;
278199550ee9SAlex Deucher 		return pl->sclk;
278299550ee9SAlex Deucher 	}
278399550ee9SAlex Deucher }
278499550ee9SAlex Deucher 
278599550ee9SAlex Deucher u32 btc_dpm_get_current_mclk(struct radeon_device *rdev)
278699550ee9SAlex Deucher {
278799550ee9SAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
278899550ee9SAlex Deucher 	struct radeon_ps *rps = &eg_pi->current_rps;
278999550ee9SAlex Deucher 	struct rv7xx_ps *ps = rv770_get_ps(rps);
279099550ee9SAlex Deucher 	struct rv7xx_pl *pl;
279199550ee9SAlex Deucher 	u32 current_index =
279299550ee9SAlex Deucher 		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
279399550ee9SAlex Deucher 		CURRENT_PROFILE_INDEX_SHIFT;
279499550ee9SAlex Deucher 
279599550ee9SAlex Deucher 	if (current_index > 2) {
279699550ee9SAlex Deucher 		return 0;
279799550ee9SAlex Deucher 	} else {
279899550ee9SAlex Deucher 		if (current_index == 0)
279999550ee9SAlex Deucher 			pl = &ps->low;
280099550ee9SAlex Deucher 		else if (current_index == 1)
280199550ee9SAlex Deucher 			pl = &ps->medium;
280299550ee9SAlex Deucher 		else /* current_index == 2 */
280399550ee9SAlex Deucher 			pl = &ps->high;
280499550ee9SAlex Deucher 		return pl->mclk;
280599550ee9SAlex Deucher 	}
280699550ee9SAlex Deucher }
280799550ee9SAlex Deucher 
2808e8a9539fSAlex Deucher u32 btc_dpm_get_sclk(struct radeon_device *rdev, bool low)
2809e8a9539fSAlex Deucher {
2810e8a9539fSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2811e8a9539fSAlex Deucher 	struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps);
2812e8a9539fSAlex Deucher 
2813e8a9539fSAlex Deucher 	if (low)
2814e8a9539fSAlex Deucher 		return requested_state->low.sclk;
2815e8a9539fSAlex Deucher 	else
2816e8a9539fSAlex Deucher 		return requested_state->high.sclk;
2817e8a9539fSAlex Deucher }
2818e8a9539fSAlex Deucher 
2819e8a9539fSAlex Deucher u32 btc_dpm_get_mclk(struct radeon_device *rdev, bool low)
2820e8a9539fSAlex Deucher {
2821e8a9539fSAlex Deucher 	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
2822e8a9539fSAlex Deucher 	struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps);
2823e8a9539fSAlex Deucher 
2824e8a9539fSAlex Deucher 	if (low)
2825e8a9539fSAlex Deucher 		return requested_state->low.mclk;
2826e8a9539fSAlex Deucher 	else
2827e8a9539fSAlex Deucher 		return requested_state->high.mclk;
2828e8a9539fSAlex Deucher }
2829