18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2011 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Authors: Alex Deucher
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#include <linux/pci.h>
268c2ecf20Sopenharmony_ci#include <linux/seq_file.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include "atom.h"
298c2ecf20Sopenharmony_ci#include "btc_dpm.h"
308c2ecf20Sopenharmony_ci#include "btcd.h"
318c2ecf20Sopenharmony_ci#include "cypress_dpm.h"
328c2ecf20Sopenharmony_ci#include "r600_dpm.h"
338c2ecf20Sopenharmony_ci#include "radeon.h"
348c2ecf20Sopenharmony_ci#include "radeon_asic.h"
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F0           0x0a
378c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F1           0x0b
388c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F2           0x0c
398c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F3           0x0d
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define MC_CG_SEQ_DRAMCONF_S0       0x05
428c2ecf20Sopenharmony_ci#define MC_CG_SEQ_DRAMCONF_S1       0x06
438c2ecf20Sopenharmony_ci#define MC_CG_SEQ_YCLK_SUSPEND      0x04
448c2ecf20Sopenharmony_ci#define MC_CG_SEQ_YCLK_RESUME       0x0a
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define SMC_RAM_END 0x8000
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#ifndef BTC_MGCG_SEQUENCE
498c2ecf20Sopenharmony_ci#define BTC_MGCG_SEQUENCE  300
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistruct rv7xx_ps *rv770_get_ps(struct radeon_ps *rps);
528c2ecf20Sopenharmony_cistruct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev);
538c2ecf20Sopenharmony_cistruct evergreen_power_info *evergreen_get_pi(struct radeon_device *rdev);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciextern int ni_mc_load_microcode(struct radeon_device *rdev);
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci//********* BARTS **************//
588c2ecf20Sopenharmony_cistatic const u32 barts_cgcg_cgls_default[] =
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	/* Register,   Value,     Mask bits */
618c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
628c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
638c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
648c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
658c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
668c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
678c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
688c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
698c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
708c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
718c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
728c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
738c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
748c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
758c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
768c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
778c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
788c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
798c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
808c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
818c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
828c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
838c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
848c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
858c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
868c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
878c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
888c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
898c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
908c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
918c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
928c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
938c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
948c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
958c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
968c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
978c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
988c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
998c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
1008c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1018c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
1028c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1038c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
1048c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1058c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
1068c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1078c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
1088c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff
1098c2ecf20Sopenharmony_ci};
1108c2ecf20Sopenharmony_ci#define BARTS_CGCG_CGLS_DEFAULT_LENGTH sizeof(barts_cgcg_cgls_default) / (3 * sizeof(u32))
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cistatic const u32 barts_cgcg_cgls_disable[] =
1138c2ecf20Sopenharmony_ci{
1148c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
1158c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1168c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
1178c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1188c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
1198c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1208c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
1218c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1228c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
1238c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1248c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
1258c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1268c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
1278c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1288c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
1298c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1308c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
1318c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1328c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
1338c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1348c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
1358c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1368c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
1378c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1388c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
1398c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1408c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
1418c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1428c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
1438c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1448c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
1458c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1468c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
1478c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1488c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
1498c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1508c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
1518c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1528c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
1538c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1548c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
1558c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1568c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
1578c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1588c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
1598c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1608c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
1618c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1628c2ecf20Sopenharmony_ci	0x00000644, 0x000f7912, 0x001f4180,
1638c2ecf20Sopenharmony_ci	0x00000644, 0x000f3812, 0x001f4180
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci#define BARTS_CGCG_CGLS_DISABLE_LENGTH sizeof(barts_cgcg_cgls_disable) / (3 * sizeof(u32))
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cistatic const u32 barts_cgcg_cgls_enable[] =
1688c2ecf20Sopenharmony_ci{
1698c2ecf20Sopenharmony_ci	/* 0x0000c124, 0x84180000, 0x00180000, */
1708c2ecf20Sopenharmony_ci	0x00000644, 0x000f7892, 0x001f4080,
1718c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
1728c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1738c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
1748c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1758c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
1768c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1778c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
1788c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1798c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
1808c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1818c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
1828c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1838c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
1848c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1858c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
1868c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1878c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
1888c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1898c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
1908c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1918c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
1928c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1938c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
1948c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
1958c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
1968c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1978c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
1988c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
1998c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
2008c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2018c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
2028c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2038c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
2048c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2058c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
2068c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2078c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
2088c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2098c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
2108c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2118c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
2128c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2138c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
2148c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2158c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
2168c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
2178c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
2188c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff
2198c2ecf20Sopenharmony_ci};
2208c2ecf20Sopenharmony_ci#define BARTS_CGCG_CGLS_ENABLE_LENGTH sizeof(barts_cgcg_cgls_enable) / (3 * sizeof(u32))
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cistatic const u32 barts_mgcg_default[] =
2238c2ecf20Sopenharmony_ci{
2248c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
2258c2ecf20Sopenharmony_ci	0x00005448, 0x00000100, 0xffffffff,
2268c2ecf20Sopenharmony_ci	0x000055e4, 0x00600100, 0xffffffff,
2278c2ecf20Sopenharmony_ci	0x0000160c, 0x00000100, 0xffffffff,
2288c2ecf20Sopenharmony_ci	0x0000c164, 0x00000100, 0xffffffff,
2298c2ecf20Sopenharmony_ci	0x00008a18, 0x00000100, 0xffffffff,
2308c2ecf20Sopenharmony_ci	0x0000897c, 0x06000100, 0xffffffff,
2318c2ecf20Sopenharmony_ci	0x00008b28, 0x00000100, 0xffffffff,
2328c2ecf20Sopenharmony_ci	0x00009144, 0x00000100, 0xffffffff,
2338c2ecf20Sopenharmony_ci	0x00009a60, 0x00000100, 0xffffffff,
2348c2ecf20Sopenharmony_ci	0x00009868, 0x00000100, 0xffffffff,
2358c2ecf20Sopenharmony_ci	0x00008d58, 0x00000100, 0xffffffff,
2368c2ecf20Sopenharmony_ci	0x00009510, 0x00000100, 0xffffffff,
2378c2ecf20Sopenharmony_ci	0x0000949c, 0x00000100, 0xffffffff,
2388c2ecf20Sopenharmony_ci	0x00009654, 0x00000100, 0xffffffff,
2398c2ecf20Sopenharmony_ci	0x00009030, 0x00000100, 0xffffffff,
2408c2ecf20Sopenharmony_ci	0x00009034, 0x00000100, 0xffffffff,
2418c2ecf20Sopenharmony_ci	0x00009038, 0x00000100, 0xffffffff,
2428c2ecf20Sopenharmony_ci	0x0000903c, 0x00000100, 0xffffffff,
2438c2ecf20Sopenharmony_ci	0x00009040, 0x00000100, 0xffffffff,
2448c2ecf20Sopenharmony_ci	0x0000a200, 0x00000100, 0xffffffff,
2458c2ecf20Sopenharmony_ci	0x0000a204, 0x00000100, 0xffffffff,
2468c2ecf20Sopenharmony_ci	0x0000a208, 0x00000100, 0xffffffff,
2478c2ecf20Sopenharmony_ci	0x0000a20c, 0x00000100, 0xffffffff,
2488c2ecf20Sopenharmony_ci	0x0000977c, 0x00000100, 0xffffffff,
2498c2ecf20Sopenharmony_ci	0x00003f80, 0x00000100, 0xffffffff,
2508c2ecf20Sopenharmony_ci	0x0000a210, 0x00000100, 0xffffffff,
2518c2ecf20Sopenharmony_ci	0x0000a214, 0x00000100, 0xffffffff,
2528c2ecf20Sopenharmony_ci	0x000004d8, 0x00000100, 0xffffffff,
2538c2ecf20Sopenharmony_ci	0x00009784, 0x00000100, 0xffffffff,
2548c2ecf20Sopenharmony_ci	0x00009698, 0x00000100, 0xffffffff,
2558c2ecf20Sopenharmony_ci	0x000004d4, 0x00000200, 0xffffffff,
2568c2ecf20Sopenharmony_ci	0x000004d0, 0x00000000, 0xffffffff,
2578c2ecf20Sopenharmony_ci	0x000030cc, 0x00000100, 0xffffffff,
2588c2ecf20Sopenharmony_ci	0x0000d0c0, 0xff000100, 0xffffffff,
2598c2ecf20Sopenharmony_ci	0x0000802c, 0x40000000, 0xffffffff,
2608c2ecf20Sopenharmony_ci	0x0000915c, 0x00010000, 0xffffffff,
2618c2ecf20Sopenharmony_ci	0x00009160, 0x00030002, 0xffffffff,
2628c2ecf20Sopenharmony_ci	0x00009164, 0x00050004, 0xffffffff,
2638c2ecf20Sopenharmony_ci	0x00009168, 0x00070006, 0xffffffff,
2648c2ecf20Sopenharmony_ci	0x00009178, 0x00070000, 0xffffffff,
2658c2ecf20Sopenharmony_ci	0x0000917c, 0x00030002, 0xffffffff,
2668c2ecf20Sopenharmony_ci	0x00009180, 0x00050004, 0xffffffff,
2678c2ecf20Sopenharmony_ci	0x0000918c, 0x00010006, 0xffffffff,
2688c2ecf20Sopenharmony_ci	0x00009190, 0x00090008, 0xffffffff,
2698c2ecf20Sopenharmony_ci	0x00009194, 0x00070000, 0xffffffff,
2708c2ecf20Sopenharmony_ci	0x00009198, 0x00030002, 0xffffffff,
2718c2ecf20Sopenharmony_ci	0x0000919c, 0x00050004, 0xffffffff,
2728c2ecf20Sopenharmony_ci	0x000091a8, 0x00010006, 0xffffffff,
2738c2ecf20Sopenharmony_ci	0x000091ac, 0x00090008, 0xffffffff,
2748c2ecf20Sopenharmony_ci	0x000091b0, 0x00070000, 0xffffffff,
2758c2ecf20Sopenharmony_ci	0x000091b4, 0x00030002, 0xffffffff,
2768c2ecf20Sopenharmony_ci	0x000091b8, 0x00050004, 0xffffffff,
2778c2ecf20Sopenharmony_ci	0x000091c4, 0x00010006, 0xffffffff,
2788c2ecf20Sopenharmony_ci	0x000091c8, 0x00090008, 0xffffffff,
2798c2ecf20Sopenharmony_ci	0x000091cc, 0x00070000, 0xffffffff,
2808c2ecf20Sopenharmony_ci	0x000091d0, 0x00030002, 0xffffffff,
2818c2ecf20Sopenharmony_ci	0x000091d4, 0x00050004, 0xffffffff,
2828c2ecf20Sopenharmony_ci	0x000091e0, 0x00010006, 0xffffffff,
2838c2ecf20Sopenharmony_ci	0x000091e4, 0x00090008, 0xffffffff,
2848c2ecf20Sopenharmony_ci	0x000091e8, 0x00000000, 0xffffffff,
2858c2ecf20Sopenharmony_ci	0x000091ec, 0x00070000, 0xffffffff,
2868c2ecf20Sopenharmony_ci	0x000091f0, 0x00030002, 0xffffffff,
2878c2ecf20Sopenharmony_ci	0x000091f4, 0x00050004, 0xffffffff,
2888c2ecf20Sopenharmony_ci	0x00009200, 0x00010006, 0xffffffff,
2898c2ecf20Sopenharmony_ci	0x00009204, 0x00090008, 0xffffffff,
2908c2ecf20Sopenharmony_ci	0x00009208, 0x00070000, 0xffffffff,
2918c2ecf20Sopenharmony_ci	0x0000920c, 0x00030002, 0xffffffff,
2928c2ecf20Sopenharmony_ci	0x00009210, 0x00050004, 0xffffffff,
2938c2ecf20Sopenharmony_ci	0x0000921c, 0x00010006, 0xffffffff,
2948c2ecf20Sopenharmony_ci	0x00009220, 0x00090008, 0xffffffff,
2958c2ecf20Sopenharmony_ci	0x00009224, 0x00070000, 0xffffffff,
2968c2ecf20Sopenharmony_ci	0x00009228, 0x00030002, 0xffffffff,
2978c2ecf20Sopenharmony_ci	0x0000922c, 0x00050004, 0xffffffff,
2988c2ecf20Sopenharmony_ci	0x00009238, 0x00010006, 0xffffffff,
2998c2ecf20Sopenharmony_ci	0x0000923c, 0x00090008, 0xffffffff,
3008c2ecf20Sopenharmony_ci	0x00009294, 0x00000000, 0xffffffff,
3018c2ecf20Sopenharmony_ci	0x0000802c, 0x40010000, 0xffffffff,
3028c2ecf20Sopenharmony_ci	0x0000915c, 0x00010000, 0xffffffff,
3038c2ecf20Sopenharmony_ci	0x00009160, 0x00030002, 0xffffffff,
3048c2ecf20Sopenharmony_ci	0x00009164, 0x00050004, 0xffffffff,
3058c2ecf20Sopenharmony_ci	0x00009168, 0x00070006, 0xffffffff,
3068c2ecf20Sopenharmony_ci	0x00009178, 0x00070000, 0xffffffff,
3078c2ecf20Sopenharmony_ci	0x0000917c, 0x00030002, 0xffffffff,
3088c2ecf20Sopenharmony_ci	0x00009180, 0x00050004, 0xffffffff,
3098c2ecf20Sopenharmony_ci	0x0000918c, 0x00010006, 0xffffffff,
3108c2ecf20Sopenharmony_ci	0x00009190, 0x00090008, 0xffffffff,
3118c2ecf20Sopenharmony_ci	0x00009194, 0x00070000, 0xffffffff,
3128c2ecf20Sopenharmony_ci	0x00009198, 0x00030002, 0xffffffff,
3138c2ecf20Sopenharmony_ci	0x0000919c, 0x00050004, 0xffffffff,
3148c2ecf20Sopenharmony_ci	0x000091a8, 0x00010006, 0xffffffff,
3158c2ecf20Sopenharmony_ci	0x000091ac, 0x00090008, 0xffffffff,
3168c2ecf20Sopenharmony_ci	0x000091b0, 0x00070000, 0xffffffff,
3178c2ecf20Sopenharmony_ci	0x000091b4, 0x00030002, 0xffffffff,
3188c2ecf20Sopenharmony_ci	0x000091b8, 0x00050004, 0xffffffff,
3198c2ecf20Sopenharmony_ci	0x000091c4, 0x00010006, 0xffffffff,
3208c2ecf20Sopenharmony_ci	0x000091c8, 0x00090008, 0xffffffff,
3218c2ecf20Sopenharmony_ci	0x000091cc, 0x00070000, 0xffffffff,
3228c2ecf20Sopenharmony_ci	0x000091d0, 0x00030002, 0xffffffff,
3238c2ecf20Sopenharmony_ci	0x000091d4, 0x00050004, 0xffffffff,
3248c2ecf20Sopenharmony_ci	0x000091e0, 0x00010006, 0xffffffff,
3258c2ecf20Sopenharmony_ci	0x000091e4, 0x00090008, 0xffffffff,
3268c2ecf20Sopenharmony_ci	0x000091e8, 0x00000000, 0xffffffff,
3278c2ecf20Sopenharmony_ci	0x000091ec, 0x00070000, 0xffffffff,
3288c2ecf20Sopenharmony_ci	0x000091f0, 0x00030002, 0xffffffff,
3298c2ecf20Sopenharmony_ci	0x000091f4, 0x00050004, 0xffffffff,
3308c2ecf20Sopenharmony_ci	0x00009200, 0x00010006, 0xffffffff,
3318c2ecf20Sopenharmony_ci	0x00009204, 0x00090008, 0xffffffff,
3328c2ecf20Sopenharmony_ci	0x00009208, 0x00070000, 0xffffffff,
3338c2ecf20Sopenharmony_ci	0x0000920c, 0x00030002, 0xffffffff,
3348c2ecf20Sopenharmony_ci	0x00009210, 0x00050004, 0xffffffff,
3358c2ecf20Sopenharmony_ci	0x0000921c, 0x00010006, 0xffffffff,
3368c2ecf20Sopenharmony_ci	0x00009220, 0x00090008, 0xffffffff,
3378c2ecf20Sopenharmony_ci	0x00009224, 0x00070000, 0xffffffff,
3388c2ecf20Sopenharmony_ci	0x00009228, 0x00030002, 0xffffffff,
3398c2ecf20Sopenharmony_ci	0x0000922c, 0x00050004, 0xffffffff,
3408c2ecf20Sopenharmony_ci	0x00009238, 0x00010006, 0xffffffff,
3418c2ecf20Sopenharmony_ci	0x0000923c, 0x00090008, 0xffffffff,
3428c2ecf20Sopenharmony_ci	0x00009294, 0x00000000, 0xffffffff,
3438c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
3448c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
3458c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3468c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
3478c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3488c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
3498c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3508c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
3518c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3528c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
3538c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3548c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
3558c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3568c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
3578c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3588c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
3598c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3608c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
3618c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3628c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
3638c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3648c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
3658c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3668c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
3678c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff
3688c2ecf20Sopenharmony_ci};
3698c2ecf20Sopenharmony_ci#define BARTS_MGCG_DEFAULT_LENGTH sizeof(barts_mgcg_default) / (3 * sizeof(u32))
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistatic const u32 barts_mgcg_disable[] =
3728c2ecf20Sopenharmony_ci{
3738c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
3748c2ecf20Sopenharmony_ci	0x000008f8, 0x00000000, 0xffffffff,
3758c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
3768c2ecf20Sopenharmony_ci	0x000008f8, 0x00000001, 0xffffffff,
3778c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
3788c2ecf20Sopenharmony_ci	0x000008f8, 0x00000002, 0xffffffff,
3798c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
3808c2ecf20Sopenharmony_ci	0x000008f8, 0x00000003, 0xffffffff,
3818c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
3828c2ecf20Sopenharmony_ci	0x00009150, 0x00600000, 0xffffffff
3838c2ecf20Sopenharmony_ci};
3848c2ecf20Sopenharmony_ci#define BARTS_MGCG_DISABLE_LENGTH sizeof(barts_mgcg_disable) / (3 * sizeof(u32))
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_cistatic const u32 barts_mgcg_enable[] =
3878c2ecf20Sopenharmony_ci{
3888c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
3898c2ecf20Sopenharmony_ci	0x000008f8, 0x00000000, 0xffffffff,
3908c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3918c2ecf20Sopenharmony_ci	0x000008f8, 0x00000001, 0xffffffff,
3928c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3938c2ecf20Sopenharmony_ci	0x000008f8, 0x00000002, 0xffffffff,
3948c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3958c2ecf20Sopenharmony_ci	0x000008f8, 0x00000003, 0xffffffff,
3968c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
3978c2ecf20Sopenharmony_ci	0x00009150, 0x81944000, 0xffffffff
3988c2ecf20Sopenharmony_ci};
3998c2ecf20Sopenharmony_ci#define BARTS_MGCG_ENABLE_LENGTH sizeof(barts_mgcg_enable) / (3 * sizeof(u32))
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci//********* CAICOS **************//
4028c2ecf20Sopenharmony_cistatic const u32 caicos_cgcg_cgls_default[] =
4038c2ecf20Sopenharmony_ci{
4048c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
4058c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4068c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
4078c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4088c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
4098c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4108c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
4118c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4128c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
4138c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4148c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
4158c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4168c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
4178c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4188c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
4198c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4208c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
4218c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4228c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
4238c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4248c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
4258c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4268c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
4278c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4288c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
4298c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4308c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
4318c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4328c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
4338c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4348c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
4358c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4368c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
4378c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4388c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
4398c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4408c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
4418c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4428c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
4438c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4448c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
4458c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4468c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
4478c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4488c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
4498c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4508c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
4518c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff
4528c2ecf20Sopenharmony_ci};
4538c2ecf20Sopenharmony_ci#define CAICOS_CGCG_CGLS_DEFAULT_LENGTH sizeof(caicos_cgcg_cgls_default) / (3 * sizeof(u32))
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_cistatic const u32 caicos_cgcg_cgls_disable[] =
4568c2ecf20Sopenharmony_ci{
4578c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
4588c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4598c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
4608c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4618c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
4628c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4638c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
4648c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4658c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
4668c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4678c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
4688c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4698c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
4708c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4718c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
4728c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4738c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
4748c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4758c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
4768c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4778c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
4788c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4798c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
4808c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
4818c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
4828c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4838c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
4848c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4858c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
4868c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4878c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
4888c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4898c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
4908c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4918c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
4928c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4938c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
4948c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4958c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
4968c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4978c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
4988c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
4998c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
5008c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5018c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
5028c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5038c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
5048c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5058c2ecf20Sopenharmony_ci	0x00000644, 0x000f7912, 0x001f4180,
5068c2ecf20Sopenharmony_ci	0x00000644, 0x000f3812, 0x001f4180
5078c2ecf20Sopenharmony_ci};
5088c2ecf20Sopenharmony_ci#define CAICOS_CGCG_CGLS_DISABLE_LENGTH sizeof(caicos_cgcg_cgls_disable) / (3 * sizeof(u32))
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_cistatic const u32 caicos_cgcg_cgls_enable[] =
5118c2ecf20Sopenharmony_ci{
5128c2ecf20Sopenharmony_ci	/* 0x0000c124, 0x84180000, 0x00180000, */
5138c2ecf20Sopenharmony_ci	0x00000644, 0x000f7892, 0x001f4080,
5148c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
5158c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5168c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
5178c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5188c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
5198c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5208c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
5218c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5228c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
5238c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5248c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
5258c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5268c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
5278c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5288c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
5298c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5308c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
5318c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5328c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
5338c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5348c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
5358c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5368c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
5378c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
5388c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
5398c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5408c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
5418c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5428c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
5438c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5448c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
5458c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5468c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
5478c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5488c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
5498c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5508c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
5518c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5528c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
5538c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5548c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
5558c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5568c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
5578c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5588c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
5598c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
5608c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
5618c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff
5628c2ecf20Sopenharmony_ci};
5638c2ecf20Sopenharmony_ci#define CAICOS_CGCG_CGLS_ENABLE_LENGTH sizeof(caicos_cgcg_cgls_enable) / (3 * sizeof(u32))
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_cistatic const u32 caicos_mgcg_default[] =
5668c2ecf20Sopenharmony_ci{
5678c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
5688c2ecf20Sopenharmony_ci	0x00005448, 0x00000100, 0xffffffff,
5698c2ecf20Sopenharmony_ci	0x000055e4, 0x00600100, 0xffffffff,
5708c2ecf20Sopenharmony_ci	0x0000160c, 0x00000100, 0xffffffff,
5718c2ecf20Sopenharmony_ci	0x0000c164, 0x00000100, 0xffffffff,
5728c2ecf20Sopenharmony_ci	0x00008a18, 0x00000100, 0xffffffff,
5738c2ecf20Sopenharmony_ci	0x0000897c, 0x06000100, 0xffffffff,
5748c2ecf20Sopenharmony_ci	0x00008b28, 0x00000100, 0xffffffff,
5758c2ecf20Sopenharmony_ci	0x00009144, 0x00000100, 0xffffffff,
5768c2ecf20Sopenharmony_ci	0x00009a60, 0x00000100, 0xffffffff,
5778c2ecf20Sopenharmony_ci	0x00009868, 0x00000100, 0xffffffff,
5788c2ecf20Sopenharmony_ci	0x00008d58, 0x00000100, 0xffffffff,
5798c2ecf20Sopenharmony_ci	0x00009510, 0x00000100, 0xffffffff,
5808c2ecf20Sopenharmony_ci	0x0000949c, 0x00000100, 0xffffffff,
5818c2ecf20Sopenharmony_ci	0x00009654, 0x00000100, 0xffffffff,
5828c2ecf20Sopenharmony_ci	0x00009030, 0x00000100, 0xffffffff,
5838c2ecf20Sopenharmony_ci	0x00009034, 0x00000100, 0xffffffff,
5848c2ecf20Sopenharmony_ci	0x00009038, 0x00000100, 0xffffffff,
5858c2ecf20Sopenharmony_ci	0x0000903c, 0x00000100, 0xffffffff,
5868c2ecf20Sopenharmony_ci	0x00009040, 0x00000100, 0xffffffff,
5878c2ecf20Sopenharmony_ci	0x0000a200, 0x00000100, 0xffffffff,
5888c2ecf20Sopenharmony_ci	0x0000a204, 0x00000100, 0xffffffff,
5898c2ecf20Sopenharmony_ci	0x0000a208, 0x00000100, 0xffffffff,
5908c2ecf20Sopenharmony_ci	0x0000a20c, 0x00000100, 0xffffffff,
5918c2ecf20Sopenharmony_ci	0x0000977c, 0x00000100, 0xffffffff,
5928c2ecf20Sopenharmony_ci	0x00003f80, 0x00000100, 0xffffffff,
5938c2ecf20Sopenharmony_ci	0x0000a210, 0x00000100, 0xffffffff,
5948c2ecf20Sopenharmony_ci	0x0000a214, 0x00000100, 0xffffffff,
5958c2ecf20Sopenharmony_ci	0x000004d8, 0x00000100, 0xffffffff,
5968c2ecf20Sopenharmony_ci	0x00009784, 0x00000100, 0xffffffff,
5978c2ecf20Sopenharmony_ci	0x00009698, 0x00000100, 0xffffffff,
5988c2ecf20Sopenharmony_ci	0x000004d4, 0x00000200, 0xffffffff,
5998c2ecf20Sopenharmony_ci	0x000004d0, 0x00000000, 0xffffffff,
6008c2ecf20Sopenharmony_ci	0x000030cc, 0x00000100, 0xffffffff,
6018c2ecf20Sopenharmony_ci	0x0000d0c0, 0xff000100, 0xffffffff,
6028c2ecf20Sopenharmony_ci	0x0000915c, 0x00010000, 0xffffffff,
6038c2ecf20Sopenharmony_ci	0x00009160, 0x00030002, 0xffffffff,
6048c2ecf20Sopenharmony_ci	0x00009164, 0x00050004, 0xffffffff,
6058c2ecf20Sopenharmony_ci	0x00009168, 0x00070006, 0xffffffff,
6068c2ecf20Sopenharmony_ci	0x00009178, 0x00070000, 0xffffffff,
6078c2ecf20Sopenharmony_ci	0x0000917c, 0x00030002, 0xffffffff,
6088c2ecf20Sopenharmony_ci	0x00009180, 0x00050004, 0xffffffff,
6098c2ecf20Sopenharmony_ci	0x0000918c, 0x00010006, 0xffffffff,
6108c2ecf20Sopenharmony_ci	0x00009190, 0x00090008, 0xffffffff,
6118c2ecf20Sopenharmony_ci	0x00009194, 0x00070000, 0xffffffff,
6128c2ecf20Sopenharmony_ci	0x00009198, 0x00030002, 0xffffffff,
6138c2ecf20Sopenharmony_ci	0x0000919c, 0x00050004, 0xffffffff,
6148c2ecf20Sopenharmony_ci	0x000091a8, 0x00010006, 0xffffffff,
6158c2ecf20Sopenharmony_ci	0x000091ac, 0x00090008, 0xffffffff,
6168c2ecf20Sopenharmony_ci	0x000091e8, 0x00000000, 0xffffffff,
6178c2ecf20Sopenharmony_ci	0x00009294, 0x00000000, 0xffffffff,
6188c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
6198c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6208c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
6218c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6228c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
6238c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6248c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
6258c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6268c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
6278c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6288c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
6298c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6308c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
6318c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6328c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
6338c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6348c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
6358c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6368c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
6378c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6388c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
6398c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6408c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
6418c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff
6428c2ecf20Sopenharmony_ci};
6438c2ecf20Sopenharmony_ci#define CAICOS_MGCG_DEFAULT_LENGTH sizeof(caicos_mgcg_default) / (3 * sizeof(u32))
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_cistatic const u32 caicos_mgcg_disable[] =
6468c2ecf20Sopenharmony_ci{
6478c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
6488c2ecf20Sopenharmony_ci	0x000008f8, 0x00000000, 0xffffffff,
6498c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
6508c2ecf20Sopenharmony_ci	0x000008f8, 0x00000001, 0xffffffff,
6518c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
6528c2ecf20Sopenharmony_ci	0x000008f8, 0x00000002, 0xffffffff,
6538c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
6548c2ecf20Sopenharmony_ci	0x000008f8, 0x00000003, 0xffffffff,
6558c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
6568c2ecf20Sopenharmony_ci	0x00009150, 0x00600000, 0xffffffff
6578c2ecf20Sopenharmony_ci};
6588c2ecf20Sopenharmony_ci#define CAICOS_MGCG_DISABLE_LENGTH sizeof(caicos_mgcg_disable) / (3 * sizeof(u32))
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_cistatic const u32 caicos_mgcg_enable[] =
6618c2ecf20Sopenharmony_ci{
6628c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
6638c2ecf20Sopenharmony_ci	0x000008f8, 0x00000000, 0xffffffff,
6648c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6658c2ecf20Sopenharmony_ci	0x000008f8, 0x00000001, 0xffffffff,
6668c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6678c2ecf20Sopenharmony_ci	0x000008f8, 0x00000002, 0xffffffff,
6688c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6698c2ecf20Sopenharmony_ci	0x000008f8, 0x00000003, 0xffffffff,
6708c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6718c2ecf20Sopenharmony_ci	0x00009150, 0x46944040, 0xffffffff
6728c2ecf20Sopenharmony_ci};
6738c2ecf20Sopenharmony_ci#define CAICOS_MGCG_ENABLE_LENGTH sizeof(caicos_mgcg_enable) / (3 * sizeof(u32))
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci//********* TURKS **************//
6768c2ecf20Sopenharmony_cistatic const u32 turks_cgcg_cgls_default[] =
6778c2ecf20Sopenharmony_ci{
6788c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
6798c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6808c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
6818c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6828c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
6838c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6848c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
6858c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6868c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
6878c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6888c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
6898c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6908c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
6918c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6928c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
6938c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6948c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
6958c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6968c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
6978c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
6988c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
6998c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7008c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
7018c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7028c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
7038c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7048c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
7058c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7068c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
7078c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7088c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
7098c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7108c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
7118c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7128c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
7138c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7148c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
7158c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7168c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
7178c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7188c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
7198c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7208c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
7218c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7228c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
7238c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7248c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
7258c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff
7268c2ecf20Sopenharmony_ci};
7278c2ecf20Sopenharmony_ci#define TURKS_CGCG_CGLS_DEFAULT_LENGTH  sizeof(turks_cgcg_cgls_default) / (3 * sizeof(u32))
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_cistatic const u32 turks_cgcg_cgls_disable[] =
7308c2ecf20Sopenharmony_ci{
7318c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
7328c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7338c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
7348c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7358c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
7368c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7378c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
7388c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7398c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
7408c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7418c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
7428c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7438c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
7448c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7458c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
7468c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7478c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
7488c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7498c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
7508c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7518c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
7528c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7538c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
7548c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
7558c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
7568c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7578c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
7588c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7598c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
7608c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7618c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
7628c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7638c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
7648c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7658c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
7668c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7678c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
7688c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7698c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
7708c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7718c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
7728c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7738c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
7748c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7758c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
7768c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7778c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
7788c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7798c2ecf20Sopenharmony_ci	0x00000644, 0x000f7912, 0x001f4180,
7808c2ecf20Sopenharmony_ci	0x00000644, 0x000f3812, 0x001f4180
7818c2ecf20Sopenharmony_ci};
7828c2ecf20Sopenharmony_ci#define TURKS_CGCG_CGLS_DISABLE_LENGTH sizeof(turks_cgcg_cgls_disable) / (3 * sizeof(u32))
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_cistatic const u32 turks_cgcg_cgls_enable[] =
7858c2ecf20Sopenharmony_ci{
7868c2ecf20Sopenharmony_ci	/* 0x0000c124, 0x84180000, 0x00180000, */
7878c2ecf20Sopenharmony_ci	0x00000644, 0x000f7892, 0x001f4080,
7888c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
7898c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7908c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
7918c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7928c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
7938c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7948c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
7958c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7968c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
7978c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
7988c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
7998c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8008c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
8018c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8028c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
8038c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8048c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
8058c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8068c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
8078c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8088c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
8098c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8108c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
8118c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
8128c2ecf20Sopenharmony_ci	0x000008f8, 0x00000020, 0xffffffff,
8138c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8148c2ecf20Sopenharmony_ci	0x000008f8, 0x00000021, 0xffffffff,
8158c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8168c2ecf20Sopenharmony_ci	0x000008f8, 0x00000022, 0xffffffff,
8178c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8188c2ecf20Sopenharmony_ci	0x000008f8, 0x00000023, 0xffffffff,
8198c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8208c2ecf20Sopenharmony_ci	0x000008f8, 0x00000024, 0xffffffff,
8218c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8228c2ecf20Sopenharmony_ci	0x000008f8, 0x00000025, 0xffffffff,
8238c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8248c2ecf20Sopenharmony_ci	0x000008f8, 0x00000026, 0xffffffff,
8258c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8268c2ecf20Sopenharmony_ci	0x000008f8, 0x00000027, 0xffffffff,
8278c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8288c2ecf20Sopenharmony_ci	0x000008f8, 0x00000028, 0xffffffff,
8298c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8308c2ecf20Sopenharmony_ci	0x000008f8, 0x00000029, 0xffffffff,
8318c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8328c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002a, 0xffffffff,
8338c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
8348c2ecf20Sopenharmony_ci	0x000008f8, 0x0000002b, 0xffffffff,
8358c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff
8368c2ecf20Sopenharmony_ci};
8378c2ecf20Sopenharmony_ci#define TURKS_CGCG_CGLS_ENABLE_LENGTH sizeof(turks_cgcg_cgls_enable) / (3 * sizeof(u32))
8388c2ecf20Sopenharmony_ci
8398c2ecf20Sopenharmony_ci// These are the sequences for turks_mgcg_shls
8408c2ecf20Sopenharmony_cistatic const u32 turks_mgcg_default[] =
8418c2ecf20Sopenharmony_ci{
8428c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
8438c2ecf20Sopenharmony_ci	0x00005448, 0x00000100, 0xffffffff,
8448c2ecf20Sopenharmony_ci	0x000055e4, 0x00600100, 0xffffffff,
8458c2ecf20Sopenharmony_ci	0x0000160c, 0x00000100, 0xffffffff,
8468c2ecf20Sopenharmony_ci	0x0000c164, 0x00000100, 0xffffffff,
8478c2ecf20Sopenharmony_ci	0x00008a18, 0x00000100, 0xffffffff,
8488c2ecf20Sopenharmony_ci	0x0000897c, 0x06000100, 0xffffffff,
8498c2ecf20Sopenharmony_ci	0x00008b28, 0x00000100, 0xffffffff,
8508c2ecf20Sopenharmony_ci	0x00009144, 0x00000100, 0xffffffff,
8518c2ecf20Sopenharmony_ci	0x00009a60, 0x00000100, 0xffffffff,
8528c2ecf20Sopenharmony_ci	0x00009868, 0x00000100, 0xffffffff,
8538c2ecf20Sopenharmony_ci	0x00008d58, 0x00000100, 0xffffffff,
8548c2ecf20Sopenharmony_ci	0x00009510, 0x00000100, 0xffffffff,
8558c2ecf20Sopenharmony_ci	0x0000949c, 0x00000100, 0xffffffff,
8568c2ecf20Sopenharmony_ci	0x00009654, 0x00000100, 0xffffffff,
8578c2ecf20Sopenharmony_ci	0x00009030, 0x00000100, 0xffffffff,
8588c2ecf20Sopenharmony_ci	0x00009034, 0x00000100, 0xffffffff,
8598c2ecf20Sopenharmony_ci	0x00009038, 0x00000100, 0xffffffff,
8608c2ecf20Sopenharmony_ci	0x0000903c, 0x00000100, 0xffffffff,
8618c2ecf20Sopenharmony_ci	0x00009040, 0x00000100, 0xffffffff,
8628c2ecf20Sopenharmony_ci	0x0000a200, 0x00000100, 0xffffffff,
8638c2ecf20Sopenharmony_ci	0x0000a204, 0x00000100, 0xffffffff,
8648c2ecf20Sopenharmony_ci	0x0000a208, 0x00000100, 0xffffffff,
8658c2ecf20Sopenharmony_ci	0x0000a20c, 0x00000100, 0xffffffff,
8668c2ecf20Sopenharmony_ci	0x0000977c, 0x00000100, 0xffffffff,
8678c2ecf20Sopenharmony_ci	0x00003f80, 0x00000100, 0xffffffff,
8688c2ecf20Sopenharmony_ci	0x0000a210, 0x00000100, 0xffffffff,
8698c2ecf20Sopenharmony_ci	0x0000a214, 0x00000100, 0xffffffff,
8708c2ecf20Sopenharmony_ci	0x000004d8, 0x00000100, 0xffffffff,
8718c2ecf20Sopenharmony_ci	0x00009784, 0x00000100, 0xffffffff,
8728c2ecf20Sopenharmony_ci	0x00009698, 0x00000100, 0xffffffff,
8738c2ecf20Sopenharmony_ci	0x000004d4, 0x00000200, 0xffffffff,
8748c2ecf20Sopenharmony_ci	0x000004d0, 0x00000000, 0xffffffff,
8758c2ecf20Sopenharmony_ci	0x000030cc, 0x00000100, 0xffffffff,
8768c2ecf20Sopenharmony_ci	0x0000d0c0, 0x00000100, 0xffffffff,
8778c2ecf20Sopenharmony_ci	0x0000915c, 0x00010000, 0xffffffff,
8788c2ecf20Sopenharmony_ci	0x00009160, 0x00030002, 0xffffffff,
8798c2ecf20Sopenharmony_ci	0x00009164, 0x00050004, 0xffffffff,
8808c2ecf20Sopenharmony_ci	0x00009168, 0x00070006, 0xffffffff,
8818c2ecf20Sopenharmony_ci	0x00009178, 0x00070000, 0xffffffff,
8828c2ecf20Sopenharmony_ci	0x0000917c, 0x00030002, 0xffffffff,
8838c2ecf20Sopenharmony_ci	0x00009180, 0x00050004, 0xffffffff,
8848c2ecf20Sopenharmony_ci	0x0000918c, 0x00010006, 0xffffffff,
8858c2ecf20Sopenharmony_ci	0x00009190, 0x00090008, 0xffffffff,
8868c2ecf20Sopenharmony_ci	0x00009194, 0x00070000, 0xffffffff,
8878c2ecf20Sopenharmony_ci	0x00009198, 0x00030002, 0xffffffff,
8888c2ecf20Sopenharmony_ci	0x0000919c, 0x00050004, 0xffffffff,
8898c2ecf20Sopenharmony_ci	0x000091a8, 0x00010006, 0xffffffff,
8908c2ecf20Sopenharmony_ci	0x000091ac, 0x00090008, 0xffffffff,
8918c2ecf20Sopenharmony_ci	0x000091b0, 0x00070000, 0xffffffff,
8928c2ecf20Sopenharmony_ci	0x000091b4, 0x00030002, 0xffffffff,
8938c2ecf20Sopenharmony_ci	0x000091b8, 0x00050004, 0xffffffff,
8948c2ecf20Sopenharmony_ci	0x000091c4, 0x00010006, 0xffffffff,
8958c2ecf20Sopenharmony_ci	0x000091c8, 0x00090008, 0xffffffff,
8968c2ecf20Sopenharmony_ci	0x000091cc, 0x00070000, 0xffffffff,
8978c2ecf20Sopenharmony_ci	0x000091d0, 0x00030002, 0xffffffff,
8988c2ecf20Sopenharmony_ci	0x000091d4, 0x00050004, 0xffffffff,
8998c2ecf20Sopenharmony_ci	0x000091e0, 0x00010006, 0xffffffff,
9008c2ecf20Sopenharmony_ci	0x000091e4, 0x00090008, 0xffffffff,
9018c2ecf20Sopenharmony_ci	0x000091e8, 0x00000000, 0xffffffff,
9028c2ecf20Sopenharmony_ci	0x000091ec, 0x00070000, 0xffffffff,
9038c2ecf20Sopenharmony_ci	0x000091f0, 0x00030002, 0xffffffff,
9048c2ecf20Sopenharmony_ci	0x000091f4, 0x00050004, 0xffffffff,
9058c2ecf20Sopenharmony_ci	0x00009200, 0x00010006, 0xffffffff,
9068c2ecf20Sopenharmony_ci	0x00009204, 0x00090008, 0xffffffff,
9078c2ecf20Sopenharmony_ci	0x00009208, 0x00070000, 0xffffffff,
9088c2ecf20Sopenharmony_ci	0x0000920c, 0x00030002, 0xffffffff,
9098c2ecf20Sopenharmony_ci	0x00009210, 0x00050004, 0xffffffff,
9108c2ecf20Sopenharmony_ci	0x0000921c, 0x00010006, 0xffffffff,
9118c2ecf20Sopenharmony_ci	0x00009220, 0x00090008, 0xffffffff,
9128c2ecf20Sopenharmony_ci	0x00009294, 0x00000000, 0xffffffff,
9138c2ecf20Sopenharmony_ci	0x000008f8, 0x00000010, 0xffffffff,
9148c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9158c2ecf20Sopenharmony_ci	0x000008f8, 0x00000011, 0xffffffff,
9168c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9178c2ecf20Sopenharmony_ci	0x000008f8, 0x00000012, 0xffffffff,
9188c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9198c2ecf20Sopenharmony_ci	0x000008f8, 0x00000013, 0xffffffff,
9208c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9218c2ecf20Sopenharmony_ci	0x000008f8, 0x00000014, 0xffffffff,
9228c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9238c2ecf20Sopenharmony_ci	0x000008f8, 0x00000015, 0xffffffff,
9248c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9258c2ecf20Sopenharmony_ci	0x000008f8, 0x00000016, 0xffffffff,
9268c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9278c2ecf20Sopenharmony_ci	0x000008f8, 0x00000017, 0xffffffff,
9288c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9298c2ecf20Sopenharmony_ci	0x000008f8, 0x00000018, 0xffffffff,
9308c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9318c2ecf20Sopenharmony_ci	0x000008f8, 0x00000019, 0xffffffff,
9328c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9338c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001a, 0xffffffff,
9348c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9358c2ecf20Sopenharmony_ci	0x000008f8, 0x0000001b, 0xffffffff,
9368c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff
9378c2ecf20Sopenharmony_ci};
9388c2ecf20Sopenharmony_ci#define TURKS_MGCG_DEFAULT_LENGTH sizeof(turks_mgcg_default) / (3 * sizeof(u32))
9398c2ecf20Sopenharmony_ci
9408c2ecf20Sopenharmony_cistatic const u32 turks_mgcg_disable[] =
9418c2ecf20Sopenharmony_ci{
9428c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
9438c2ecf20Sopenharmony_ci	0x000008f8, 0x00000000, 0xffffffff,
9448c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
9458c2ecf20Sopenharmony_ci	0x000008f8, 0x00000001, 0xffffffff,
9468c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
9478c2ecf20Sopenharmony_ci	0x000008f8, 0x00000002, 0xffffffff,
9488c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
9498c2ecf20Sopenharmony_ci	0x000008f8, 0x00000003, 0xffffffff,
9508c2ecf20Sopenharmony_ci	0x000008fc, 0xffffffff, 0xffffffff,
9518c2ecf20Sopenharmony_ci	0x00009150, 0x00600000, 0xffffffff
9528c2ecf20Sopenharmony_ci};
9538c2ecf20Sopenharmony_ci#define TURKS_MGCG_DISABLE_LENGTH sizeof(turks_mgcg_disable) / (3 * sizeof(u32))
9548c2ecf20Sopenharmony_ci
9558c2ecf20Sopenharmony_cistatic const u32 turks_mgcg_enable[] =
9568c2ecf20Sopenharmony_ci{
9578c2ecf20Sopenharmony_ci	0x0000802c, 0xc0000000, 0xffffffff,
9588c2ecf20Sopenharmony_ci	0x000008f8, 0x00000000, 0xffffffff,
9598c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9608c2ecf20Sopenharmony_ci	0x000008f8, 0x00000001, 0xffffffff,
9618c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9628c2ecf20Sopenharmony_ci	0x000008f8, 0x00000002, 0xffffffff,
9638c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9648c2ecf20Sopenharmony_ci	0x000008f8, 0x00000003, 0xffffffff,
9658c2ecf20Sopenharmony_ci	0x000008fc, 0x00000000, 0xffffffff,
9668c2ecf20Sopenharmony_ci	0x00009150, 0x6e944000, 0xffffffff
9678c2ecf20Sopenharmony_ci};
9688c2ecf20Sopenharmony_ci#define TURKS_MGCG_ENABLE_LENGTH sizeof(turks_mgcg_enable) / (3 * sizeof(u32))
9698c2ecf20Sopenharmony_ci
9708c2ecf20Sopenharmony_ci#endif
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci#ifndef BTC_SYSLS_SEQUENCE
9738c2ecf20Sopenharmony_ci#define BTC_SYSLS_SEQUENCE  100
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci
9768c2ecf20Sopenharmony_ci//********* BARTS **************//
9778c2ecf20Sopenharmony_cistatic const u32 barts_sysls_default[] =
9788c2ecf20Sopenharmony_ci{
9798c2ecf20Sopenharmony_ci	/* Register,   Value,     Mask bits */
9808c2ecf20Sopenharmony_ci	0x000055e8, 0x00000000, 0xffffffff,
9818c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000000, 0xffffffff,
9828c2ecf20Sopenharmony_ci	0x000015c0, 0x000c1401, 0xffffffff,
9838c2ecf20Sopenharmony_ci	0x0000264c, 0x000c0400, 0xffffffff,
9848c2ecf20Sopenharmony_ci	0x00002648, 0x000c0400, 0xffffffff,
9858c2ecf20Sopenharmony_ci	0x00002650, 0x000c0400, 0xffffffff,
9868c2ecf20Sopenharmony_ci	0x000020b8, 0x000c0400, 0xffffffff,
9878c2ecf20Sopenharmony_ci	0x000020bc, 0x000c0400, 0xffffffff,
9888c2ecf20Sopenharmony_ci	0x000020c0, 0x000c0c80, 0xffffffff,
9898c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
9908c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680fff, 0xffffffff,
9918c2ecf20Sopenharmony_ci	0x000004c8, 0x00000001, 0xffffffff,
9928c2ecf20Sopenharmony_ci	0x000064ec, 0x00000000, 0xffffffff,
9938c2ecf20Sopenharmony_ci	0x00000c7c, 0x00000000, 0xffffffff,
9948c2ecf20Sopenharmony_ci	0x00006dfc, 0x00000000, 0xffffffff
9958c2ecf20Sopenharmony_ci};
9968c2ecf20Sopenharmony_ci#define BARTS_SYSLS_DEFAULT_LENGTH sizeof(barts_sysls_default) / (3 * sizeof(u32))
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_cistatic const u32 barts_sysls_disable[] =
9998c2ecf20Sopenharmony_ci{
10008c2ecf20Sopenharmony_ci	0x000055e8, 0x00000000, 0xffffffff,
10018c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000000, 0xffffffff,
10028c2ecf20Sopenharmony_ci	0x000015c0, 0x00041401, 0xffffffff,
10038c2ecf20Sopenharmony_ci	0x0000264c, 0x00040400, 0xffffffff,
10048c2ecf20Sopenharmony_ci	0x00002648, 0x00040400, 0xffffffff,
10058c2ecf20Sopenharmony_ci	0x00002650, 0x00040400, 0xffffffff,
10068c2ecf20Sopenharmony_ci	0x000020b8, 0x00040400, 0xffffffff,
10078c2ecf20Sopenharmony_ci	0x000020bc, 0x00040400, 0xffffffff,
10088c2ecf20Sopenharmony_ci	0x000020c0, 0x00040c80, 0xffffffff,
10098c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
10108c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680000, 0xffffffff,
10118c2ecf20Sopenharmony_ci	0x000004c8, 0x00000001, 0xffffffff,
10128c2ecf20Sopenharmony_ci	0x000064ec, 0x00007ffd, 0xffffffff,
10138c2ecf20Sopenharmony_ci	0x00000c7c, 0x0000ff00, 0xffffffff,
10148c2ecf20Sopenharmony_ci	0x00006dfc, 0x0000007f, 0xffffffff
10158c2ecf20Sopenharmony_ci};
10168c2ecf20Sopenharmony_ci#define BARTS_SYSLS_DISABLE_LENGTH sizeof(barts_sysls_disable) / (3 * sizeof(u32))
10178c2ecf20Sopenharmony_ci
10188c2ecf20Sopenharmony_cistatic const u32 barts_sysls_enable[] =
10198c2ecf20Sopenharmony_ci{
10208c2ecf20Sopenharmony_ci	0x000055e8, 0x00000001, 0xffffffff,
10218c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000100, 0xffffffff,
10228c2ecf20Sopenharmony_ci	0x000015c0, 0x000c1401, 0xffffffff,
10238c2ecf20Sopenharmony_ci	0x0000264c, 0x000c0400, 0xffffffff,
10248c2ecf20Sopenharmony_ci	0x00002648, 0x000c0400, 0xffffffff,
10258c2ecf20Sopenharmony_ci	0x00002650, 0x000c0400, 0xffffffff,
10268c2ecf20Sopenharmony_ci	0x000020b8, 0x000c0400, 0xffffffff,
10278c2ecf20Sopenharmony_ci	0x000020bc, 0x000c0400, 0xffffffff,
10288c2ecf20Sopenharmony_ci	0x000020c0, 0x000c0c80, 0xffffffff,
10298c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
10308c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680fff, 0xffffffff,
10318c2ecf20Sopenharmony_ci	0x000004c8, 0x00000000, 0xffffffff,
10328c2ecf20Sopenharmony_ci	0x000064ec, 0x00000000, 0xffffffff,
10338c2ecf20Sopenharmony_ci	0x00000c7c, 0x00000000, 0xffffffff,
10348c2ecf20Sopenharmony_ci	0x00006dfc, 0x00000000, 0xffffffff
10358c2ecf20Sopenharmony_ci};
10368c2ecf20Sopenharmony_ci#define BARTS_SYSLS_ENABLE_LENGTH sizeof(barts_sysls_enable) / (3 * sizeof(u32))
10378c2ecf20Sopenharmony_ci
10388c2ecf20Sopenharmony_ci//********* CAICOS **************//
10398c2ecf20Sopenharmony_cistatic const u32 caicos_sysls_default[] =
10408c2ecf20Sopenharmony_ci{
10418c2ecf20Sopenharmony_ci	0x000055e8, 0x00000000, 0xffffffff,
10428c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000000, 0xffffffff,
10438c2ecf20Sopenharmony_ci	0x000015c0, 0x000c1401, 0xffffffff,
10448c2ecf20Sopenharmony_ci	0x0000264c, 0x000c0400, 0xffffffff,
10458c2ecf20Sopenharmony_ci	0x00002648, 0x000c0400, 0xffffffff,
10468c2ecf20Sopenharmony_ci	0x00002650, 0x000c0400, 0xffffffff,
10478c2ecf20Sopenharmony_ci	0x000020b8, 0x000c0400, 0xffffffff,
10488c2ecf20Sopenharmony_ci	0x000020bc, 0x000c0400, 0xffffffff,
10498c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
10508c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680fff, 0xffffffff,
10518c2ecf20Sopenharmony_ci	0x000004c8, 0x00000001, 0xffffffff,
10528c2ecf20Sopenharmony_ci	0x000064ec, 0x00000000, 0xffffffff,
10538c2ecf20Sopenharmony_ci	0x00000c7c, 0x00000000, 0xffffffff,
10548c2ecf20Sopenharmony_ci	0x00006dfc, 0x00000000, 0xffffffff
10558c2ecf20Sopenharmony_ci};
10568c2ecf20Sopenharmony_ci#define CAICOS_SYSLS_DEFAULT_LENGTH sizeof(caicos_sysls_default) / (3 * sizeof(u32))
10578c2ecf20Sopenharmony_ci
10588c2ecf20Sopenharmony_cistatic const u32 caicos_sysls_disable[] =
10598c2ecf20Sopenharmony_ci{
10608c2ecf20Sopenharmony_ci	0x000055e8, 0x00000000, 0xffffffff,
10618c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000000, 0xffffffff,
10628c2ecf20Sopenharmony_ci	0x000015c0, 0x00041401, 0xffffffff,
10638c2ecf20Sopenharmony_ci	0x0000264c, 0x00040400, 0xffffffff,
10648c2ecf20Sopenharmony_ci	0x00002648, 0x00040400, 0xffffffff,
10658c2ecf20Sopenharmony_ci	0x00002650, 0x00040400, 0xffffffff,
10668c2ecf20Sopenharmony_ci	0x000020b8, 0x00040400, 0xffffffff,
10678c2ecf20Sopenharmony_ci	0x000020bc, 0x00040400, 0xffffffff,
10688c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
10698c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680000, 0xffffffff,
10708c2ecf20Sopenharmony_ci	0x000004c8, 0x00000001, 0xffffffff,
10718c2ecf20Sopenharmony_ci	0x000064ec, 0x00007ffd, 0xffffffff,
10728c2ecf20Sopenharmony_ci	0x00000c7c, 0x0000ff00, 0xffffffff,
10738c2ecf20Sopenharmony_ci	0x00006dfc, 0x0000007f, 0xffffffff
10748c2ecf20Sopenharmony_ci};
10758c2ecf20Sopenharmony_ci#define CAICOS_SYSLS_DISABLE_LENGTH sizeof(caicos_sysls_disable) / (3 * sizeof(u32))
10768c2ecf20Sopenharmony_ci
10778c2ecf20Sopenharmony_cistatic const u32 caicos_sysls_enable[] =
10788c2ecf20Sopenharmony_ci{
10798c2ecf20Sopenharmony_ci	0x000055e8, 0x00000001, 0xffffffff,
10808c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000100, 0xffffffff,
10818c2ecf20Sopenharmony_ci	0x000015c0, 0x000c1401, 0xffffffff,
10828c2ecf20Sopenharmony_ci	0x0000264c, 0x000c0400, 0xffffffff,
10838c2ecf20Sopenharmony_ci	0x00002648, 0x000c0400, 0xffffffff,
10848c2ecf20Sopenharmony_ci	0x00002650, 0x000c0400, 0xffffffff,
10858c2ecf20Sopenharmony_ci	0x000020b8, 0x000c0400, 0xffffffff,
10868c2ecf20Sopenharmony_ci	0x000020bc, 0x000c0400, 0xffffffff,
10878c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
10888c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680fff, 0xffffffff,
10898c2ecf20Sopenharmony_ci	0x000064ec, 0x00000000, 0xffffffff,
10908c2ecf20Sopenharmony_ci	0x00000c7c, 0x00000000, 0xffffffff,
10918c2ecf20Sopenharmony_ci	0x00006dfc, 0x00000000, 0xffffffff,
10928c2ecf20Sopenharmony_ci	0x000004c8, 0x00000000, 0xffffffff
10938c2ecf20Sopenharmony_ci};
10948c2ecf20Sopenharmony_ci#define CAICOS_SYSLS_ENABLE_LENGTH sizeof(caicos_sysls_enable) / (3 * sizeof(u32))
10958c2ecf20Sopenharmony_ci
10968c2ecf20Sopenharmony_ci//********* TURKS **************//
10978c2ecf20Sopenharmony_cistatic const u32 turks_sysls_default[] =
10988c2ecf20Sopenharmony_ci{
10998c2ecf20Sopenharmony_ci	0x000055e8, 0x00000000, 0xffffffff,
11008c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000000, 0xffffffff,
11018c2ecf20Sopenharmony_ci	0x000015c0, 0x000c1401, 0xffffffff,
11028c2ecf20Sopenharmony_ci	0x0000264c, 0x000c0400, 0xffffffff,
11038c2ecf20Sopenharmony_ci	0x00002648, 0x000c0400, 0xffffffff,
11048c2ecf20Sopenharmony_ci	0x00002650, 0x000c0400, 0xffffffff,
11058c2ecf20Sopenharmony_ci	0x000020b8, 0x000c0400, 0xffffffff,
11068c2ecf20Sopenharmony_ci	0x000020bc, 0x000c0400, 0xffffffff,
11078c2ecf20Sopenharmony_ci	0x000020c0, 0x000c0c80, 0xffffffff,
11088c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
11098c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680fff, 0xffffffff,
11108c2ecf20Sopenharmony_ci	0x000004c8, 0x00000001, 0xffffffff,
11118c2ecf20Sopenharmony_ci	0x000064ec, 0x00000000, 0xffffffff,
11128c2ecf20Sopenharmony_ci	0x00000c7c, 0x00000000, 0xffffffff,
11138c2ecf20Sopenharmony_ci	0x00006dfc, 0x00000000, 0xffffffff
11148c2ecf20Sopenharmony_ci};
11158c2ecf20Sopenharmony_ci#define TURKS_SYSLS_DEFAULT_LENGTH sizeof(turks_sysls_default) / (3 * sizeof(u32))
11168c2ecf20Sopenharmony_ci
11178c2ecf20Sopenharmony_cistatic const u32 turks_sysls_disable[] =
11188c2ecf20Sopenharmony_ci{
11198c2ecf20Sopenharmony_ci	0x000055e8, 0x00000000, 0xffffffff,
11208c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000000, 0xffffffff,
11218c2ecf20Sopenharmony_ci	0x000015c0, 0x00041401, 0xffffffff,
11228c2ecf20Sopenharmony_ci	0x0000264c, 0x00040400, 0xffffffff,
11238c2ecf20Sopenharmony_ci	0x00002648, 0x00040400, 0xffffffff,
11248c2ecf20Sopenharmony_ci	0x00002650, 0x00040400, 0xffffffff,
11258c2ecf20Sopenharmony_ci	0x000020b8, 0x00040400, 0xffffffff,
11268c2ecf20Sopenharmony_ci	0x000020bc, 0x00040400, 0xffffffff,
11278c2ecf20Sopenharmony_ci	0x000020c0, 0x00040c80, 0xffffffff,
11288c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
11298c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680000, 0xffffffff,
11308c2ecf20Sopenharmony_ci	0x000004c8, 0x00000001, 0xffffffff,
11318c2ecf20Sopenharmony_ci	0x000064ec, 0x00007ffd, 0xffffffff,
11328c2ecf20Sopenharmony_ci	0x00000c7c, 0x0000ff00, 0xffffffff,
11338c2ecf20Sopenharmony_ci	0x00006dfc, 0x0000007f, 0xffffffff
11348c2ecf20Sopenharmony_ci};
11358c2ecf20Sopenharmony_ci#define TURKS_SYSLS_DISABLE_LENGTH sizeof(turks_sysls_disable) / (3 * sizeof(u32))
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_cistatic const u32 turks_sysls_enable[] =
11388c2ecf20Sopenharmony_ci{
11398c2ecf20Sopenharmony_ci	0x000055e8, 0x00000001, 0xffffffff,
11408c2ecf20Sopenharmony_ci	0x0000d0bc, 0x00000100, 0xffffffff,
11418c2ecf20Sopenharmony_ci	0x000015c0, 0x000c1401, 0xffffffff,
11428c2ecf20Sopenharmony_ci	0x0000264c, 0x000c0400, 0xffffffff,
11438c2ecf20Sopenharmony_ci	0x00002648, 0x000c0400, 0xffffffff,
11448c2ecf20Sopenharmony_ci	0x00002650, 0x000c0400, 0xffffffff,
11458c2ecf20Sopenharmony_ci	0x000020b8, 0x000c0400, 0xffffffff,
11468c2ecf20Sopenharmony_ci	0x000020bc, 0x000c0400, 0xffffffff,
11478c2ecf20Sopenharmony_ci	0x000020c0, 0x000c0c80, 0xffffffff,
11488c2ecf20Sopenharmony_ci	0x0000f4a0, 0x000000c0, 0xffffffff,
11498c2ecf20Sopenharmony_ci	0x0000f4a4, 0x00680fff, 0xffffffff,
11508c2ecf20Sopenharmony_ci	0x000004c8, 0x00000000, 0xffffffff,
11518c2ecf20Sopenharmony_ci	0x000064ec, 0x00000000, 0xffffffff,
11528c2ecf20Sopenharmony_ci	0x00000c7c, 0x00000000, 0xffffffff,
11538c2ecf20Sopenharmony_ci	0x00006dfc, 0x00000000, 0xffffffff
11548c2ecf20Sopenharmony_ci};
11558c2ecf20Sopenharmony_ci#define TURKS_SYSLS_ENABLE_LENGTH sizeof(turks_sysls_enable) / (3 * sizeof(u32))
11568c2ecf20Sopenharmony_ci
11578c2ecf20Sopenharmony_ci#endif
11588c2ecf20Sopenharmony_ci
11598c2ecf20Sopenharmony_ciu32 btc_valid_sclk[40] =
11608c2ecf20Sopenharmony_ci{
11618c2ecf20Sopenharmony_ci	5000,   10000,  15000,  20000,  25000,  30000,  35000,  40000,  45000,  50000,
11628c2ecf20Sopenharmony_ci	55000,  60000,  65000,  70000,  75000,  80000,  85000,  90000,  95000,  100000,
11638c2ecf20Sopenharmony_ci	105000, 110000, 11500,  120000, 125000, 130000, 135000, 140000, 145000, 150000,
11648c2ecf20Sopenharmony_ci	155000, 160000, 165000, 170000, 175000, 180000, 185000, 190000, 195000, 200000
11658c2ecf20Sopenharmony_ci};
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_cistatic const struct radeon_blacklist_clocks btc_blacklist_clocks[] = {
11688c2ecf20Sopenharmony_ci	{ 10000, 30000, RADEON_SCLK_UP },
11698c2ecf20Sopenharmony_ci	{ 15000, 30000, RADEON_SCLK_UP },
11708c2ecf20Sopenharmony_ci	{ 20000, 30000, RADEON_SCLK_UP },
11718c2ecf20Sopenharmony_ci	{ 25000, 30000, RADEON_SCLK_UP }
11728c2ecf20Sopenharmony_ci};
11738c2ecf20Sopenharmony_ci
11748c2ecf20Sopenharmony_civoid btc_get_max_clock_from_voltage_dependency_table(struct radeon_clock_voltage_dependency_table *table,
11758c2ecf20Sopenharmony_ci						     u32 *max_clock)
11768c2ecf20Sopenharmony_ci{
11778c2ecf20Sopenharmony_ci	u32 i, clock = 0;
11788c2ecf20Sopenharmony_ci
11798c2ecf20Sopenharmony_ci	if ((table == NULL) || (table->count == 0)) {
11808c2ecf20Sopenharmony_ci		*max_clock = clock;
11818c2ecf20Sopenharmony_ci		return;
11828c2ecf20Sopenharmony_ci	}
11838c2ecf20Sopenharmony_ci
11848c2ecf20Sopenharmony_ci	for (i = 0; i < table->count; i++) {
11858c2ecf20Sopenharmony_ci		if (clock < table->entries[i].clk)
11868c2ecf20Sopenharmony_ci			clock = table->entries[i].clk;
11878c2ecf20Sopenharmony_ci	}
11888c2ecf20Sopenharmony_ci	*max_clock = clock;
11898c2ecf20Sopenharmony_ci}
11908c2ecf20Sopenharmony_ci
11918c2ecf20Sopenharmony_civoid btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table,
11928c2ecf20Sopenharmony_ci					u32 clock, u16 max_voltage, u16 *voltage)
11938c2ecf20Sopenharmony_ci{
11948c2ecf20Sopenharmony_ci	u32 i;
11958c2ecf20Sopenharmony_ci
11968c2ecf20Sopenharmony_ci	if ((table == NULL) || (table->count == 0))
11978c2ecf20Sopenharmony_ci		return;
11988c2ecf20Sopenharmony_ci
11998c2ecf20Sopenharmony_ci	for (i= 0; i < table->count; i++) {
12008c2ecf20Sopenharmony_ci		if (clock <= table->entries[i].clk) {
12018c2ecf20Sopenharmony_ci			if (*voltage < table->entries[i].v)
12028c2ecf20Sopenharmony_ci				*voltage = (u16)((table->entries[i].v < max_voltage) ?
12038c2ecf20Sopenharmony_ci						  table->entries[i].v : max_voltage);
12048c2ecf20Sopenharmony_ci			return;
12058c2ecf20Sopenharmony_ci		}
12068c2ecf20Sopenharmony_ci	}
12078c2ecf20Sopenharmony_ci
12088c2ecf20Sopenharmony_ci	*voltage = (*voltage > max_voltage) ? *voltage : max_voltage;
12098c2ecf20Sopenharmony_ci}
12108c2ecf20Sopenharmony_ci
12118c2ecf20Sopenharmony_cistatic u32 btc_find_valid_clock(struct radeon_clock_array *clocks,
12128c2ecf20Sopenharmony_ci				u32 max_clock, u32 requested_clock)
12138c2ecf20Sopenharmony_ci{
12148c2ecf20Sopenharmony_ci	unsigned int i;
12158c2ecf20Sopenharmony_ci
12168c2ecf20Sopenharmony_ci	if ((clocks == NULL) || (clocks->count == 0))
12178c2ecf20Sopenharmony_ci		return (requested_clock < max_clock) ? requested_clock : max_clock;
12188c2ecf20Sopenharmony_ci
12198c2ecf20Sopenharmony_ci	for (i = 0; i < clocks->count; i++) {
12208c2ecf20Sopenharmony_ci		if (clocks->values[i] >= requested_clock)
12218c2ecf20Sopenharmony_ci			return (clocks->values[i] < max_clock) ? clocks->values[i] : max_clock;
12228c2ecf20Sopenharmony_ci	}
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci	return (clocks->values[clocks->count - 1] < max_clock) ?
12258c2ecf20Sopenharmony_ci		clocks->values[clocks->count - 1] : max_clock;
12268c2ecf20Sopenharmony_ci}
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_cistatic u32 btc_get_valid_mclk(struct radeon_device *rdev,
12298c2ecf20Sopenharmony_ci			      u32 max_mclk, u32 requested_mclk)
12308c2ecf20Sopenharmony_ci{
12318c2ecf20Sopenharmony_ci	return btc_find_valid_clock(&rdev->pm.dpm.dyn_state.valid_mclk_values,
12328c2ecf20Sopenharmony_ci				    max_mclk, requested_mclk);
12338c2ecf20Sopenharmony_ci}
12348c2ecf20Sopenharmony_ci
12358c2ecf20Sopenharmony_cistatic u32 btc_get_valid_sclk(struct radeon_device *rdev,
12368c2ecf20Sopenharmony_ci			      u32 max_sclk, u32 requested_sclk)
12378c2ecf20Sopenharmony_ci{
12388c2ecf20Sopenharmony_ci	return btc_find_valid_clock(&rdev->pm.dpm.dyn_state.valid_sclk_values,
12398c2ecf20Sopenharmony_ci				    max_sclk, requested_sclk);
12408c2ecf20Sopenharmony_ci}
12418c2ecf20Sopenharmony_ci
12428c2ecf20Sopenharmony_civoid btc_skip_blacklist_clocks(struct radeon_device *rdev,
12438c2ecf20Sopenharmony_ci			       const u32 max_sclk, const u32 max_mclk,
12448c2ecf20Sopenharmony_ci			       u32 *sclk, u32 *mclk)
12458c2ecf20Sopenharmony_ci{
12468c2ecf20Sopenharmony_ci	int i, num_blacklist_clocks;
12478c2ecf20Sopenharmony_ci
12488c2ecf20Sopenharmony_ci	if ((sclk == NULL) || (mclk == NULL))
12498c2ecf20Sopenharmony_ci		return;
12508c2ecf20Sopenharmony_ci
12518c2ecf20Sopenharmony_ci	num_blacklist_clocks = ARRAY_SIZE(btc_blacklist_clocks);
12528c2ecf20Sopenharmony_ci
12538c2ecf20Sopenharmony_ci	for (i = 0; i < num_blacklist_clocks; i++) {
12548c2ecf20Sopenharmony_ci		if ((btc_blacklist_clocks[i].sclk == *sclk) &&
12558c2ecf20Sopenharmony_ci		    (btc_blacklist_clocks[i].mclk == *mclk))
12568c2ecf20Sopenharmony_ci			break;
12578c2ecf20Sopenharmony_ci	}
12588c2ecf20Sopenharmony_ci
12598c2ecf20Sopenharmony_ci	if (i < num_blacklist_clocks) {
12608c2ecf20Sopenharmony_ci		if (btc_blacklist_clocks[i].action == RADEON_SCLK_UP) {
12618c2ecf20Sopenharmony_ci			*sclk = btc_get_valid_sclk(rdev, max_sclk, *sclk + 1);
12628c2ecf20Sopenharmony_ci
12638c2ecf20Sopenharmony_ci			if (*sclk < max_sclk)
12648c2ecf20Sopenharmony_ci				btc_skip_blacklist_clocks(rdev, max_sclk, max_mclk, sclk, mclk);
12658c2ecf20Sopenharmony_ci		}
12668c2ecf20Sopenharmony_ci	}
12678c2ecf20Sopenharmony_ci}
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_civoid btc_adjust_clock_combinations(struct radeon_device *rdev,
12708c2ecf20Sopenharmony_ci				   const struct radeon_clock_and_voltage_limits *max_limits,
12718c2ecf20Sopenharmony_ci				   struct rv7xx_pl *pl)
12728c2ecf20Sopenharmony_ci{
12738c2ecf20Sopenharmony_ci
12748c2ecf20Sopenharmony_ci	if ((pl->mclk == 0) || (pl->sclk == 0))
12758c2ecf20Sopenharmony_ci		return;
12768c2ecf20Sopenharmony_ci
12778c2ecf20Sopenharmony_ci	if (pl->mclk == pl->sclk)
12788c2ecf20Sopenharmony_ci		return;
12798c2ecf20Sopenharmony_ci
12808c2ecf20Sopenharmony_ci	if (pl->mclk > pl->sclk) {
12818c2ecf20Sopenharmony_ci		if (((pl->mclk + (pl->sclk - 1)) / pl->sclk) > rdev->pm.dpm.dyn_state.mclk_sclk_ratio)
12828c2ecf20Sopenharmony_ci			pl->sclk = btc_get_valid_sclk(rdev,
12838c2ecf20Sopenharmony_ci						      max_limits->sclk,
12848c2ecf20Sopenharmony_ci						      (pl->mclk +
12858c2ecf20Sopenharmony_ci						       (rdev->pm.dpm.dyn_state.mclk_sclk_ratio - 1)) /
12868c2ecf20Sopenharmony_ci						      rdev->pm.dpm.dyn_state.mclk_sclk_ratio);
12878c2ecf20Sopenharmony_ci	} else {
12888c2ecf20Sopenharmony_ci		if ((pl->sclk - pl->mclk) > rdev->pm.dpm.dyn_state.sclk_mclk_delta)
12898c2ecf20Sopenharmony_ci			pl->mclk = btc_get_valid_mclk(rdev,
12908c2ecf20Sopenharmony_ci						      max_limits->mclk,
12918c2ecf20Sopenharmony_ci						      pl->sclk -
12928c2ecf20Sopenharmony_ci						      rdev->pm.dpm.dyn_state.sclk_mclk_delta);
12938c2ecf20Sopenharmony_ci	}
12948c2ecf20Sopenharmony_ci}
12958c2ecf20Sopenharmony_ci
12968c2ecf20Sopenharmony_cistatic u16 btc_find_voltage(struct atom_voltage_table *table, u16 voltage)
12978c2ecf20Sopenharmony_ci{
12988c2ecf20Sopenharmony_ci	unsigned int i;
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	for (i = 0; i < table->count; i++) {
13018c2ecf20Sopenharmony_ci		if (voltage <= table->entries[i].value)
13028c2ecf20Sopenharmony_ci			return table->entries[i].value;
13038c2ecf20Sopenharmony_ci	}
13048c2ecf20Sopenharmony_ci
13058c2ecf20Sopenharmony_ci	return table->entries[table->count - 1].value;
13068c2ecf20Sopenharmony_ci}
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_civoid btc_apply_voltage_delta_rules(struct radeon_device *rdev,
13098c2ecf20Sopenharmony_ci				   u16 max_vddc, u16 max_vddci,
13108c2ecf20Sopenharmony_ci				   u16 *vddc, u16 *vddci)
13118c2ecf20Sopenharmony_ci{
13128c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
13138c2ecf20Sopenharmony_ci	u16 new_voltage;
13148c2ecf20Sopenharmony_ci
13158c2ecf20Sopenharmony_ci	if ((0 == *vddc) || (0 == *vddci))
13168c2ecf20Sopenharmony_ci		return;
13178c2ecf20Sopenharmony_ci
13188c2ecf20Sopenharmony_ci	if (*vddc > *vddci) {
13198c2ecf20Sopenharmony_ci		if ((*vddc - *vddci) > rdev->pm.dpm.dyn_state.vddc_vddci_delta) {
13208c2ecf20Sopenharmony_ci			new_voltage = btc_find_voltage(&eg_pi->vddci_voltage_table,
13218c2ecf20Sopenharmony_ci						       (*vddc - rdev->pm.dpm.dyn_state.vddc_vddci_delta));
13228c2ecf20Sopenharmony_ci			*vddci = (new_voltage < max_vddci) ? new_voltage : max_vddci;
13238c2ecf20Sopenharmony_ci		}
13248c2ecf20Sopenharmony_ci	} else {
13258c2ecf20Sopenharmony_ci		if ((*vddci - *vddc) > rdev->pm.dpm.dyn_state.vddc_vddci_delta) {
13268c2ecf20Sopenharmony_ci			new_voltage = btc_find_voltage(&eg_pi->vddc_voltage_table,
13278c2ecf20Sopenharmony_ci						       (*vddci - rdev->pm.dpm.dyn_state.vddc_vddci_delta));
13288c2ecf20Sopenharmony_ci			*vddc = (new_voltage < max_vddc) ? new_voltage : max_vddc;
13298c2ecf20Sopenharmony_ci		}
13308c2ecf20Sopenharmony_ci	}
13318c2ecf20Sopenharmony_ci}
13328c2ecf20Sopenharmony_ci
13338c2ecf20Sopenharmony_cistatic void btc_enable_bif_dynamic_pcie_gen2(struct radeon_device *rdev,
13348c2ecf20Sopenharmony_ci					     bool enable)
13358c2ecf20Sopenharmony_ci{
13368c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
13378c2ecf20Sopenharmony_ci	u32 tmp, bif;
13388c2ecf20Sopenharmony_ci
13398c2ecf20Sopenharmony_ci	tmp = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
13408c2ecf20Sopenharmony_ci	if (enable) {
13418c2ecf20Sopenharmony_ci		if ((tmp & LC_OTHER_SIDE_EVER_SENT_GEN2) &&
13428c2ecf20Sopenharmony_ci		    (tmp & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
13438c2ecf20Sopenharmony_ci			if (!pi->boot_in_gen2) {
13448c2ecf20Sopenharmony_ci				bif = RREG32(CG_BIF_REQ_AND_RSP) & ~CG_CLIENT_REQ_MASK;
13458c2ecf20Sopenharmony_ci				bif |= CG_CLIENT_REQ(0xd);
13468c2ecf20Sopenharmony_ci				WREG32(CG_BIF_REQ_AND_RSP, bif);
13478c2ecf20Sopenharmony_ci
13488c2ecf20Sopenharmony_ci				tmp &= ~LC_HW_VOLTAGE_IF_CONTROL_MASK;
13498c2ecf20Sopenharmony_ci				tmp |= LC_HW_VOLTAGE_IF_CONTROL(1);
13508c2ecf20Sopenharmony_ci				tmp |= LC_GEN2_EN_STRAP;
13518c2ecf20Sopenharmony_ci
13528c2ecf20Sopenharmony_ci				tmp |= LC_CLR_FAILED_SPD_CHANGE_CNT;
13538c2ecf20Sopenharmony_ci				WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
13548c2ecf20Sopenharmony_ci				udelay(10);
13558c2ecf20Sopenharmony_ci				tmp &= ~LC_CLR_FAILED_SPD_CHANGE_CNT;
13568c2ecf20Sopenharmony_ci				WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
13578c2ecf20Sopenharmony_ci			}
13588c2ecf20Sopenharmony_ci		}
13598c2ecf20Sopenharmony_ci	} else {
13608c2ecf20Sopenharmony_ci		if ((tmp & LC_OTHER_SIDE_EVER_SENT_GEN2) ||
13618c2ecf20Sopenharmony_ci		    (tmp & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
13628c2ecf20Sopenharmony_ci			if (!pi->boot_in_gen2) {
13638c2ecf20Sopenharmony_ci				bif = RREG32(CG_BIF_REQ_AND_RSP) & ~CG_CLIENT_REQ_MASK;
13648c2ecf20Sopenharmony_ci				bif |= CG_CLIENT_REQ(0xd);
13658c2ecf20Sopenharmony_ci				WREG32(CG_BIF_REQ_AND_RSP, bif);
13668c2ecf20Sopenharmony_ci
13678c2ecf20Sopenharmony_ci				tmp &= ~LC_HW_VOLTAGE_IF_CONTROL_MASK;
13688c2ecf20Sopenharmony_ci				tmp &= ~LC_GEN2_EN_STRAP;
13698c2ecf20Sopenharmony_ci			}
13708c2ecf20Sopenharmony_ci			WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
13718c2ecf20Sopenharmony_ci		}
13728c2ecf20Sopenharmony_ci	}
13738c2ecf20Sopenharmony_ci}
13748c2ecf20Sopenharmony_ci
13758c2ecf20Sopenharmony_cistatic void btc_enable_dynamic_pcie_gen2(struct radeon_device *rdev,
13768c2ecf20Sopenharmony_ci					 bool enable)
13778c2ecf20Sopenharmony_ci{
13788c2ecf20Sopenharmony_ci	btc_enable_bif_dynamic_pcie_gen2(rdev, enable);
13798c2ecf20Sopenharmony_ci
13808c2ecf20Sopenharmony_ci	if (enable)
13818c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, ENABLE_GEN2PCIE, ~ENABLE_GEN2PCIE);
13828c2ecf20Sopenharmony_ci	else
13838c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, 0, ~ENABLE_GEN2PCIE);
13848c2ecf20Sopenharmony_ci}
13858c2ecf20Sopenharmony_ci
13868c2ecf20Sopenharmony_cistatic int btc_disable_ulv(struct radeon_device *rdev)
13878c2ecf20Sopenharmony_ci{
13888c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
13898c2ecf20Sopenharmony_ci
13908c2ecf20Sopenharmony_ci	if (eg_pi->ulv.supported) {
13918c2ecf20Sopenharmony_ci		if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_DisableULV) != PPSMC_Result_OK)
13928c2ecf20Sopenharmony_ci			return -EINVAL;
13938c2ecf20Sopenharmony_ci	}
13948c2ecf20Sopenharmony_ci	return 0;
13958c2ecf20Sopenharmony_ci}
13968c2ecf20Sopenharmony_ci
13978c2ecf20Sopenharmony_cistatic int btc_populate_ulv_state(struct radeon_device *rdev,
13988c2ecf20Sopenharmony_ci				  RV770_SMC_STATETABLE *table)
13998c2ecf20Sopenharmony_ci{
14008c2ecf20Sopenharmony_ci	int ret = -EINVAL;
14018c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
14028c2ecf20Sopenharmony_ci	struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
14038c2ecf20Sopenharmony_ci
14048c2ecf20Sopenharmony_ci	if (ulv_pl->vddc) {
14058c2ecf20Sopenharmony_ci		ret = cypress_convert_power_level_to_smc(rdev,
14068c2ecf20Sopenharmony_ci							 ulv_pl,
14078c2ecf20Sopenharmony_ci							 &table->ULVState.levels[0],
14088c2ecf20Sopenharmony_ci							 PPSMC_DISPLAY_WATERMARK_LOW);
14098c2ecf20Sopenharmony_ci		if (ret == 0) {
14108c2ecf20Sopenharmony_ci			table->ULVState.levels[0].arbValue = MC_CG_ARB_FREQ_F0;
14118c2ecf20Sopenharmony_ci			table->ULVState.levels[0].ACIndex = 1;
14128c2ecf20Sopenharmony_ci
14138c2ecf20Sopenharmony_ci			table->ULVState.levels[1] = table->ULVState.levels[0];
14148c2ecf20Sopenharmony_ci			table->ULVState.levels[2] = table->ULVState.levels[0];
14158c2ecf20Sopenharmony_ci
14168c2ecf20Sopenharmony_ci			table->ULVState.flags |= PPSMC_SWSTATE_FLAG_DC;
14178c2ecf20Sopenharmony_ci
14188c2ecf20Sopenharmony_ci			WREG32(CG_ULV_CONTROL, BTC_CGULVCONTROL_DFLT);
14198c2ecf20Sopenharmony_ci			WREG32(CG_ULV_PARAMETER, BTC_CGULVPARAMETER_DFLT);
14208c2ecf20Sopenharmony_ci		}
14218c2ecf20Sopenharmony_ci	}
14228c2ecf20Sopenharmony_ci
14238c2ecf20Sopenharmony_ci	return ret;
14248c2ecf20Sopenharmony_ci}
14258c2ecf20Sopenharmony_ci
14268c2ecf20Sopenharmony_cistatic int btc_populate_smc_acpi_state(struct radeon_device *rdev,
14278c2ecf20Sopenharmony_ci				       RV770_SMC_STATETABLE *table)
14288c2ecf20Sopenharmony_ci{
14298c2ecf20Sopenharmony_ci	int ret = cypress_populate_smc_acpi_state(rdev, table);
14308c2ecf20Sopenharmony_ci
14318c2ecf20Sopenharmony_ci	if (ret == 0) {
14328c2ecf20Sopenharmony_ci		table->ACPIState.levels[0].ACIndex = 0;
14338c2ecf20Sopenharmony_ci		table->ACPIState.levels[1].ACIndex = 0;
14348c2ecf20Sopenharmony_ci		table->ACPIState.levels[2].ACIndex = 0;
14358c2ecf20Sopenharmony_ci	}
14368c2ecf20Sopenharmony_ci
14378c2ecf20Sopenharmony_ci	return ret;
14388c2ecf20Sopenharmony_ci}
14398c2ecf20Sopenharmony_ci
14408c2ecf20Sopenharmony_civoid btc_program_mgcg_hw_sequence(struct radeon_device *rdev,
14418c2ecf20Sopenharmony_ci				  const u32 *sequence, u32 count)
14428c2ecf20Sopenharmony_ci{
14438c2ecf20Sopenharmony_ci	u32 i, length = count * 3;
14448c2ecf20Sopenharmony_ci	u32 tmp;
14458c2ecf20Sopenharmony_ci
14468c2ecf20Sopenharmony_ci	for (i = 0; i < length; i+=3) {
14478c2ecf20Sopenharmony_ci		tmp = RREG32(sequence[i]);
14488c2ecf20Sopenharmony_ci		tmp &= ~sequence[i+2];
14498c2ecf20Sopenharmony_ci		tmp |= sequence[i+1] & sequence[i+2];
14508c2ecf20Sopenharmony_ci		WREG32(sequence[i], tmp);
14518c2ecf20Sopenharmony_ci	}
14528c2ecf20Sopenharmony_ci}
14538c2ecf20Sopenharmony_ci
14548c2ecf20Sopenharmony_cistatic void btc_cg_clock_gating_default(struct radeon_device *rdev)
14558c2ecf20Sopenharmony_ci{
14568c2ecf20Sopenharmony_ci	u32 count;
14578c2ecf20Sopenharmony_ci	const u32 *p = NULL;
14588c2ecf20Sopenharmony_ci
14598c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_BARTS) {
14608c2ecf20Sopenharmony_ci		p = (const u32 *)&barts_cgcg_cgls_default;
14618c2ecf20Sopenharmony_ci		count = BARTS_CGCG_CGLS_DEFAULT_LENGTH;
14628c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_TURKS) {
14638c2ecf20Sopenharmony_ci		p = (const u32 *)&turks_cgcg_cgls_default;
14648c2ecf20Sopenharmony_ci		count = TURKS_CGCG_CGLS_DEFAULT_LENGTH;
14658c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_CAICOS) {
14668c2ecf20Sopenharmony_ci		p = (const u32 *)&caicos_cgcg_cgls_default;
14678c2ecf20Sopenharmony_ci		count = CAICOS_CGCG_CGLS_DEFAULT_LENGTH;
14688c2ecf20Sopenharmony_ci	} else
14698c2ecf20Sopenharmony_ci		return;
14708c2ecf20Sopenharmony_ci
14718c2ecf20Sopenharmony_ci	btc_program_mgcg_hw_sequence(rdev, p, count);
14728c2ecf20Sopenharmony_ci}
14738c2ecf20Sopenharmony_ci
14748c2ecf20Sopenharmony_cistatic void btc_cg_clock_gating_enable(struct radeon_device *rdev,
14758c2ecf20Sopenharmony_ci				       bool enable)
14768c2ecf20Sopenharmony_ci{
14778c2ecf20Sopenharmony_ci	u32 count;
14788c2ecf20Sopenharmony_ci	const u32 *p = NULL;
14798c2ecf20Sopenharmony_ci
14808c2ecf20Sopenharmony_ci	if (enable) {
14818c2ecf20Sopenharmony_ci		if (rdev->family == CHIP_BARTS) {
14828c2ecf20Sopenharmony_ci			p = (const u32 *)&barts_cgcg_cgls_enable;
14838c2ecf20Sopenharmony_ci			count = BARTS_CGCG_CGLS_ENABLE_LENGTH;
14848c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_TURKS) {
14858c2ecf20Sopenharmony_ci			p = (const u32 *)&turks_cgcg_cgls_enable;
14868c2ecf20Sopenharmony_ci			count = TURKS_CGCG_CGLS_ENABLE_LENGTH;
14878c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_CAICOS) {
14888c2ecf20Sopenharmony_ci			p = (const u32 *)&caicos_cgcg_cgls_enable;
14898c2ecf20Sopenharmony_ci			count = CAICOS_CGCG_CGLS_ENABLE_LENGTH;
14908c2ecf20Sopenharmony_ci		} else
14918c2ecf20Sopenharmony_ci			return;
14928c2ecf20Sopenharmony_ci	} else {
14938c2ecf20Sopenharmony_ci		if (rdev->family == CHIP_BARTS) {
14948c2ecf20Sopenharmony_ci			p = (const u32 *)&barts_cgcg_cgls_disable;
14958c2ecf20Sopenharmony_ci			count = BARTS_CGCG_CGLS_DISABLE_LENGTH;
14968c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_TURKS) {
14978c2ecf20Sopenharmony_ci			p = (const u32 *)&turks_cgcg_cgls_disable;
14988c2ecf20Sopenharmony_ci			count = TURKS_CGCG_CGLS_DISABLE_LENGTH;
14998c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_CAICOS) {
15008c2ecf20Sopenharmony_ci			p = (const u32 *)&caicos_cgcg_cgls_disable;
15018c2ecf20Sopenharmony_ci			count = CAICOS_CGCG_CGLS_DISABLE_LENGTH;
15028c2ecf20Sopenharmony_ci		} else
15038c2ecf20Sopenharmony_ci			return;
15048c2ecf20Sopenharmony_ci	}
15058c2ecf20Sopenharmony_ci
15068c2ecf20Sopenharmony_ci	btc_program_mgcg_hw_sequence(rdev, p, count);
15078c2ecf20Sopenharmony_ci}
15088c2ecf20Sopenharmony_ci
15098c2ecf20Sopenharmony_cistatic void btc_mg_clock_gating_default(struct radeon_device *rdev)
15108c2ecf20Sopenharmony_ci{
15118c2ecf20Sopenharmony_ci	u32 count;
15128c2ecf20Sopenharmony_ci	const u32 *p = NULL;
15138c2ecf20Sopenharmony_ci
15148c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_BARTS) {
15158c2ecf20Sopenharmony_ci		p = (const u32 *)&barts_mgcg_default;
15168c2ecf20Sopenharmony_ci		count = BARTS_MGCG_DEFAULT_LENGTH;
15178c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_TURKS) {
15188c2ecf20Sopenharmony_ci		p = (const u32 *)&turks_mgcg_default;
15198c2ecf20Sopenharmony_ci		count = TURKS_MGCG_DEFAULT_LENGTH;
15208c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_CAICOS) {
15218c2ecf20Sopenharmony_ci		p = (const u32 *)&caicos_mgcg_default;
15228c2ecf20Sopenharmony_ci		count = CAICOS_MGCG_DEFAULT_LENGTH;
15238c2ecf20Sopenharmony_ci	} else
15248c2ecf20Sopenharmony_ci		return;
15258c2ecf20Sopenharmony_ci
15268c2ecf20Sopenharmony_ci	btc_program_mgcg_hw_sequence(rdev, p, count);
15278c2ecf20Sopenharmony_ci}
15288c2ecf20Sopenharmony_ci
15298c2ecf20Sopenharmony_cistatic void btc_mg_clock_gating_enable(struct radeon_device *rdev,
15308c2ecf20Sopenharmony_ci				       bool enable)
15318c2ecf20Sopenharmony_ci{
15328c2ecf20Sopenharmony_ci	u32 count;
15338c2ecf20Sopenharmony_ci	const u32 *p = NULL;
15348c2ecf20Sopenharmony_ci
15358c2ecf20Sopenharmony_ci	if (enable) {
15368c2ecf20Sopenharmony_ci		if (rdev->family == CHIP_BARTS) {
15378c2ecf20Sopenharmony_ci			p = (const u32 *)&barts_mgcg_enable;
15388c2ecf20Sopenharmony_ci			count = BARTS_MGCG_ENABLE_LENGTH;
15398c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_TURKS) {
15408c2ecf20Sopenharmony_ci			p = (const u32 *)&turks_mgcg_enable;
15418c2ecf20Sopenharmony_ci			count = TURKS_MGCG_ENABLE_LENGTH;
15428c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_CAICOS) {
15438c2ecf20Sopenharmony_ci			p = (const u32 *)&caicos_mgcg_enable;
15448c2ecf20Sopenharmony_ci			count = CAICOS_MGCG_ENABLE_LENGTH;
15458c2ecf20Sopenharmony_ci		} else
15468c2ecf20Sopenharmony_ci			return;
15478c2ecf20Sopenharmony_ci	} else {
15488c2ecf20Sopenharmony_ci		if (rdev->family == CHIP_BARTS) {
15498c2ecf20Sopenharmony_ci			p = (const u32 *)&barts_mgcg_disable[0];
15508c2ecf20Sopenharmony_ci			count = BARTS_MGCG_DISABLE_LENGTH;
15518c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_TURKS) {
15528c2ecf20Sopenharmony_ci			p = (const u32 *)&turks_mgcg_disable[0];
15538c2ecf20Sopenharmony_ci			count = TURKS_MGCG_DISABLE_LENGTH;
15548c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_CAICOS) {
15558c2ecf20Sopenharmony_ci			p = (const u32 *)&caicos_mgcg_disable[0];
15568c2ecf20Sopenharmony_ci			count = CAICOS_MGCG_DISABLE_LENGTH;
15578c2ecf20Sopenharmony_ci		} else
15588c2ecf20Sopenharmony_ci			return;
15598c2ecf20Sopenharmony_ci	}
15608c2ecf20Sopenharmony_ci
15618c2ecf20Sopenharmony_ci	btc_program_mgcg_hw_sequence(rdev, p, count);
15628c2ecf20Sopenharmony_ci}
15638c2ecf20Sopenharmony_ci
15648c2ecf20Sopenharmony_cistatic void btc_ls_clock_gating_default(struct radeon_device *rdev)
15658c2ecf20Sopenharmony_ci{
15668c2ecf20Sopenharmony_ci	u32 count;
15678c2ecf20Sopenharmony_ci	const u32 *p = NULL;
15688c2ecf20Sopenharmony_ci
15698c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_BARTS) {
15708c2ecf20Sopenharmony_ci		p = (const u32 *)&barts_sysls_default;
15718c2ecf20Sopenharmony_ci		count = BARTS_SYSLS_DEFAULT_LENGTH;
15728c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_TURKS) {
15738c2ecf20Sopenharmony_ci		p = (const u32 *)&turks_sysls_default;
15748c2ecf20Sopenharmony_ci		count = TURKS_SYSLS_DEFAULT_LENGTH;
15758c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_CAICOS) {
15768c2ecf20Sopenharmony_ci		p = (const u32 *)&caicos_sysls_default;
15778c2ecf20Sopenharmony_ci		count = CAICOS_SYSLS_DEFAULT_LENGTH;
15788c2ecf20Sopenharmony_ci	} else
15798c2ecf20Sopenharmony_ci		return;
15808c2ecf20Sopenharmony_ci
15818c2ecf20Sopenharmony_ci	btc_program_mgcg_hw_sequence(rdev, p, count);
15828c2ecf20Sopenharmony_ci}
15838c2ecf20Sopenharmony_ci
15848c2ecf20Sopenharmony_cistatic void btc_ls_clock_gating_enable(struct radeon_device *rdev,
15858c2ecf20Sopenharmony_ci				       bool enable)
15868c2ecf20Sopenharmony_ci{
15878c2ecf20Sopenharmony_ci	u32 count;
15888c2ecf20Sopenharmony_ci	const u32 *p = NULL;
15898c2ecf20Sopenharmony_ci
15908c2ecf20Sopenharmony_ci	if (enable) {
15918c2ecf20Sopenharmony_ci		if (rdev->family == CHIP_BARTS) {
15928c2ecf20Sopenharmony_ci			p = (const u32 *)&barts_sysls_enable;
15938c2ecf20Sopenharmony_ci			count = BARTS_SYSLS_ENABLE_LENGTH;
15948c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_TURKS) {
15958c2ecf20Sopenharmony_ci			p = (const u32 *)&turks_sysls_enable;
15968c2ecf20Sopenharmony_ci			count = TURKS_SYSLS_ENABLE_LENGTH;
15978c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_CAICOS) {
15988c2ecf20Sopenharmony_ci			p = (const u32 *)&caicos_sysls_enable;
15998c2ecf20Sopenharmony_ci			count = CAICOS_SYSLS_ENABLE_LENGTH;
16008c2ecf20Sopenharmony_ci		} else
16018c2ecf20Sopenharmony_ci			return;
16028c2ecf20Sopenharmony_ci	} else {
16038c2ecf20Sopenharmony_ci		if (rdev->family == CHIP_BARTS) {
16048c2ecf20Sopenharmony_ci			p = (const u32 *)&barts_sysls_disable;
16058c2ecf20Sopenharmony_ci			count = BARTS_SYSLS_DISABLE_LENGTH;
16068c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_TURKS) {
16078c2ecf20Sopenharmony_ci			p = (const u32 *)&turks_sysls_disable;
16088c2ecf20Sopenharmony_ci			count = TURKS_SYSLS_DISABLE_LENGTH;
16098c2ecf20Sopenharmony_ci		} else if (rdev->family == CHIP_CAICOS) {
16108c2ecf20Sopenharmony_ci			p = (const u32 *)&caicos_sysls_disable;
16118c2ecf20Sopenharmony_ci			count = CAICOS_SYSLS_DISABLE_LENGTH;
16128c2ecf20Sopenharmony_ci		} else
16138c2ecf20Sopenharmony_ci			return;
16148c2ecf20Sopenharmony_ci	}
16158c2ecf20Sopenharmony_ci
16168c2ecf20Sopenharmony_ci	btc_program_mgcg_hw_sequence(rdev, p, count);
16178c2ecf20Sopenharmony_ci}
16188c2ecf20Sopenharmony_ci
16198c2ecf20Sopenharmony_cibool btc_dpm_enabled(struct radeon_device *rdev)
16208c2ecf20Sopenharmony_ci{
16218c2ecf20Sopenharmony_ci	if (rv770_is_smc_running(rdev))
16228c2ecf20Sopenharmony_ci		return true;
16238c2ecf20Sopenharmony_ci	else
16248c2ecf20Sopenharmony_ci		return false;
16258c2ecf20Sopenharmony_ci}
16268c2ecf20Sopenharmony_ci
16278c2ecf20Sopenharmony_cistatic int btc_init_smc_table(struct radeon_device *rdev,
16288c2ecf20Sopenharmony_ci			      struct radeon_ps *radeon_boot_state)
16298c2ecf20Sopenharmony_ci{
16308c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
16318c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
16328c2ecf20Sopenharmony_ci	RV770_SMC_STATETABLE *table = &pi->smc_statetable;
16338c2ecf20Sopenharmony_ci	int ret;
16348c2ecf20Sopenharmony_ci
16358c2ecf20Sopenharmony_ci	memset(table, 0, sizeof(RV770_SMC_STATETABLE));
16368c2ecf20Sopenharmony_ci
16378c2ecf20Sopenharmony_ci	cypress_populate_smc_voltage_tables(rdev, table);
16388c2ecf20Sopenharmony_ci
16398c2ecf20Sopenharmony_ci	switch (rdev->pm.int_thermal_type) {
16408c2ecf20Sopenharmony_ci	case THERMAL_TYPE_EVERGREEN:
16418c2ecf20Sopenharmony_ci	case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
16428c2ecf20Sopenharmony_ci		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
16438c2ecf20Sopenharmony_ci		break;
16448c2ecf20Sopenharmony_ci	case THERMAL_TYPE_NONE:
16458c2ecf20Sopenharmony_ci		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
16468c2ecf20Sopenharmony_ci		break;
16478c2ecf20Sopenharmony_ci	default:
16488c2ecf20Sopenharmony_ci		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
16498c2ecf20Sopenharmony_ci		break;
16508c2ecf20Sopenharmony_ci	}
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
16538c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
16548c2ecf20Sopenharmony_ci
16558c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT)
16568c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
16578c2ecf20Sopenharmony_ci
16588c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
16598c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
16608c2ecf20Sopenharmony_ci
16618c2ecf20Sopenharmony_ci	if (pi->mem_gddr5)
16628c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
16638c2ecf20Sopenharmony_ci
16648c2ecf20Sopenharmony_ci	ret = cypress_populate_smc_initial_state(rdev, radeon_boot_state, table);
16658c2ecf20Sopenharmony_ci	if (ret)
16668c2ecf20Sopenharmony_ci		return ret;
16678c2ecf20Sopenharmony_ci
16688c2ecf20Sopenharmony_ci	if (eg_pi->sclk_deep_sleep)
16698c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PSKIP_CNTL, PSKIP_ON_ALLOW_STOP_HI(32),
16708c2ecf20Sopenharmony_ci			 ~PSKIP_ON_ALLOW_STOP_HI_MASK);
16718c2ecf20Sopenharmony_ci
16728c2ecf20Sopenharmony_ci	ret = btc_populate_smc_acpi_state(rdev, table);
16738c2ecf20Sopenharmony_ci	if (ret)
16748c2ecf20Sopenharmony_ci		return ret;
16758c2ecf20Sopenharmony_ci
16768c2ecf20Sopenharmony_ci	if (eg_pi->ulv.supported) {
16778c2ecf20Sopenharmony_ci		ret = btc_populate_ulv_state(rdev, table);
16788c2ecf20Sopenharmony_ci		if (ret)
16798c2ecf20Sopenharmony_ci			eg_pi->ulv.supported = false;
16808c2ecf20Sopenharmony_ci	}
16818c2ecf20Sopenharmony_ci
16828c2ecf20Sopenharmony_ci	table->driverState = table->initialState;
16838c2ecf20Sopenharmony_ci
16848c2ecf20Sopenharmony_ci	return rv770_copy_bytes_to_smc(rdev,
16858c2ecf20Sopenharmony_ci				       pi->state_table_start,
16868c2ecf20Sopenharmony_ci				       (u8 *)table,
16878c2ecf20Sopenharmony_ci				       sizeof(RV770_SMC_STATETABLE),
16888c2ecf20Sopenharmony_ci				       pi->sram_end);
16898c2ecf20Sopenharmony_ci}
16908c2ecf20Sopenharmony_ci
16918c2ecf20Sopenharmony_cistatic void btc_set_at_for_uvd(struct radeon_device *rdev,
16928c2ecf20Sopenharmony_ci			       struct radeon_ps *radeon_new_state)
16938c2ecf20Sopenharmony_ci{
16948c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
16958c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
16968c2ecf20Sopenharmony_ci	int idx = 0;
16978c2ecf20Sopenharmony_ci
16988c2ecf20Sopenharmony_ci	if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2))
16998c2ecf20Sopenharmony_ci		idx = 1;
17008c2ecf20Sopenharmony_ci
17018c2ecf20Sopenharmony_ci	if ((idx == 1) && !eg_pi->smu_uvd_hs) {
17028c2ecf20Sopenharmony_ci		pi->rlp = 10;
17038c2ecf20Sopenharmony_ci		pi->rmp = 100;
17048c2ecf20Sopenharmony_ci		pi->lhp = 100;
17058c2ecf20Sopenharmony_ci		pi->lmp = 10;
17068c2ecf20Sopenharmony_ci	} else {
17078c2ecf20Sopenharmony_ci		pi->rlp = eg_pi->ats[idx].rlp;
17088c2ecf20Sopenharmony_ci		pi->rmp = eg_pi->ats[idx].rmp;
17098c2ecf20Sopenharmony_ci		pi->lhp = eg_pi->ats[idx].lhp;
17108c2ecf20Sopenharmony_ci		pi->lmp = eg_pi->ats[idx].lmp;
17118c2ecf20Sopenharmony_ci	}
17128c2ecf20Sopenharmony_ci
17138c2ecf20Sopenharmony_ci}
17148c2ecf20Sopenharmony_ci
17158c2ecf20Sopenharmony_civoid btc_notify_uvd_to_smc(struct radeon_device *rdev,
17168c2ecf20Sopenharmony_ci			   struct radeon_ps *radeon_new_state)
17178c2ecf20Sopenharmony_ci{
17188c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_ci	if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2)) {
17218c2ecf20Sopenharmony_ci		rv770_write_smc_soft_register(rdev,
17228c2ecf20Sopenharmony_ci					      RV770_SMC_SOFT_REGISTER_uvd_enabled, 1);
17238c2ecf20Sopenharmony_ci		eg_pi->uvd_enabled = true;
17248c2ecf20Sopenharmony_ci	} else {
17258c2ecf20Sopenharmony_ci		rv770_write_smc_soft_register(rdev,
17268c2ecf20Sopenharmony_ci					      RV770_SMC_SOFT_REGISTER_uvd_enabled, 0);
17278c2ecf20Sopenharmony_ci		eg_pi->uvd_enabled = false;
17288c2ecf20Sopenharmony_ci	}
17298c2ecf20Sopenharmony_ci}
17308c2ecf20Sopenharmony_ci
17318c2ecf20Sopenharmony_ciint btc_reset_to_default(struct radeon_device *rdev)
17328c2ecf20Sopenharmony_ci{
17338c2ecf20Sopenharmony_ci	if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_ResetToDefaults) != PPSMC_Result_OK)
17348c2ecf20Sopenharmony_ci		return -EINVAL;
17358c2ecf20Sopenharmony_ci
17368c2ecf20Sopenharmony_ci	return 0;
17378c2ecf20Sopenharmony_ci}
17388c2ecf20Sopenharmony_ci
17398c2ecf20Sopenharmony_cistatic void btc_stop_smc(struct radeon_device *rdev)
17408c2ecf20Sopenharmony_ci{
17418c2ecf20Sopenharmony_ci	int i;
17428c2ecf20Sopenharmony_ci
17438c2ecf20Sopenharmony_ci	for (i = 0; i < rdev->usec_timeout; i++) {
17448c2ecf20Sopenharmony_ci		if (((RREG32(LB_SYNC_RESET_SEL) & LB_SYNC_RESET_SEL_MASK) >> LB_SYNC_RESET_SEL_SHIFT) != 1)
17458c2ecf20Sopenharmony_ci			break;
17468c2ecf20Sopenharmony_ci		udelay(1);
17478c2ecf20Sopenharmony_ci	}
17488c2ecf20Sopenharmony_ci	udelay(100);
17498c2ecf20Sopenharmony_ci
17508c2ecf20Sopenharmony_ci	r7xx_stop_smc(rdev);
17518c2ecf20Sopenharmony_ci}
17528c2ecf20Sopenharmony_ci
17538c2ecf20Sopenharmony_civoid btc_read_arb_registers(struct radeon_device *rdev)
17548c2ecf20Sopenharmony_ci{
17558c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17568c2ecf20Sopenharmony_ci	struct evergreen_arb_registers *arb_registers =
17578c2ecf20Sopenharmony_ci		&eg_pi->bootup_arb_registers;
17588c2ecf20Sopenharmony_ci
17598c2ecf20Sopenharmony_ci	arb_registers->mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING);
17608c2ecf20Sopenharmony_ci	arb_registers->mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
17618c2ecf20Sopenharmony_ci	arb_registers->mc_arb_rfsh_rate = RREG32(MC_ARB_RFSH_RATE);
17628c2ecf20Sopenharmony_ci	arb_registers->mc_arb_burst_time = RREG32(MC_ARB_BURST_TIME);
17638c2ecf20Sopenharmony_ci}
17648c2ecf20Sopenharmony_ci
17658c2ecf20Sopenharmony_ci
17668c2ecf20Sopenharmony_cistatic void btc_set_arb0_registers(struct radeon_device *rdev,
17678c2ecf20Sopenharmony_ci				   struct evergreen_arb_registers *arb_registers)
17688c2ecf20Sopenharmony_ci{
17698c2ecf20Sopenharmony_ci	u32 val;
17708c2ecf20Sopenharmony_ci
17718c2ecf20Sopenharmony_ci	WREG32(MC_ARB_DRAM_TIMING,  arb_registers->mc_arb_dram_timing);
17728c2ecf20Sopenharmony_ci	WREG32(MC_ARB_DRAM_TIMING2, arb_registers->mc_arb_dram_timing2);
17738c2ecf20Sopenharmony_ci
17748c2ecf20Sopenharmony_ci	val = (arb_registers->mc_arb_rfsh_rate & POWERMODE0_MASK) >>
17758c2ecf20Sopenharmony_ci		POWERMODE0_SHIFT;
17768c2ecf20Sopenharmony_ci	WREG32_P(MC_ARB_RFSH_RATE, POWERMODE0(val), ~POWERMODE0_MASK);
17778c2ecf20Sopenharmony_ci
17788c2ecf20Sopenharmony_ci	val = (arb_registers->mc_arb_burst_time & STATE0_MASK) >>
17798c2ecf20Sopenharmony_ci		STATE0_SHIFT;
17808c2ecf20Sopenharmony_ci	WREG32_P(MC_ARB_BURST_TIME, STATE0(val), ~STATE0_MASK);
17818c2ecf20Sopenharmony_ci}
17828c2ecf20Sopenharmony_ci
17838c2ecf20Sopenharmony_cistatic void btc_set_boot_state_timing(struct radeon_device *rdev)
17848c2ecf20Sopenharmony_ci{
17858c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17868c2ecf20Sopenharmony_ci
17878c2ecf20Sopenharmony_ci	if (eg_pi->ulv.supported)
17888c2ecf20Sopenharmony_ci		btc_set_arb0_registers(rdev, &eg_pi->bootup_arb_registers);
17898c2ecf20Sopenharmony_ci}
17908c2ecf20Sopenharmony_ci
17918c2ecf20Sopenharmony_cistatic bool btc_is_state_ulv_compatible(struct radeon_device *rdev,
17928c2ecf20Sopenharmony_ci					struct radeon_ps *radeon_state)
17938c2ecf20Sopenharmony_ci{
17948c2ecf20Sopenharmony_ci	struct rv7xx_ps *state = rv770_get_ps(radeon_state);
17958c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
17968c2ecf20Sopenharmony_ci	struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
17978c2ecf20Sopenharmony_ci
17988c2ecf20Sopenharmony_ci	if (state->low.mclk != ulv_pl->mclk)
17998c2ecf20Sopenharmony_ci		return false;
18008c2ecf20Sopenharmony_ci
18018c2ecf20Sopenharmony_ci	if (state->low.vddci != ulv_pl->vddci)
18028c2ecf20Sopenharmony_ci		return false;
18038c2ecf20Sopenharmony_ci
18048c2ecf20Sopenharmony_ci	/* XXX check minclocks, etc. */
18058c2ecf20Sopenharmony_ci
18068c2ecf20Sopenharmony_ci	return true;
18078c2ecf20Sopenharmony_ci}
18088c2ecf20Sopenharmony_ci
18098c2ecf20Sopenharmony_ci
18108c2ecf20Sopenharmony_cistatic int btc_set_ulv_dram_timing(struct radeon_device *rdev)
18118c2ecf20Sopenharmony_ci{
18128c2ecf20Sopenharmony_ci	u32 val;
18138c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
18148c2ecf20Sopenharmony_ci	struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
18158c2ecf20Sopenharmony_ci
18168c2ecf20Sopenharmony_ci	radeon_atom_set_engine_dram_timings(rdev,
18178c2ecf20Sopenharmony_ci					    ulv_pl->sclk,
18188c2ecf20Sopenharmony_ci					    ulv_pl->mclk);
18198c2ecf20Sopenharmony_ci
18208c2ecf20Sopenharmony_ci	val = rv770_calculate_memory_refresh_rate(rdev, ulv_pl->sclk);
18218c2ecf20Sopenharmony_ci	WREG32_P(MC_ARB_RFSH_RATE, POWERMODE0(val), ~POWERMODE0_MASK);
18228c2ecf20Sopenharmony_ci
18238c2ecf20Sopenharmony_ci	val = cypress_calculate_burst_time(rdev, ulv_pl->sclk, ulv_pl->mclk);
18248c2ecf20Sopenharmony_ci	WREG32_P(MC_ARB_BURST_TIME, STATE0(val), ~STATE0_MASK);
18258c2ecf20Sopenharmony_ci
18268c2ecf20Sopenharmony_ci	return 0;
18278c2ecf20Sopenharmony_ci}
18288c2ecf20Sopenharmony_ci
18298c2ecf20Sopenharmony_cistatic int btc_enable_ulv(struct radeon_device *rdev)
18308c2ecf20Sopenharmony_ci{
18318c2ecf20Sopenharmony_ci	if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_EnableULV) != PPSMC_Result_OK)
18328c2ecf20Sopenharmony_ci		return -EINVAL;
18338c2ecf20Sopenharmony_ci
18348c2ecf20Sopenharmony_ci	return 0;
18358c2ecf20Sopenharmony_ci}
18368c2ecf20Sopenharmony_ci
18378c2ecf20Sopenharmony_cistatic int btc_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev,
18388c2ecf20Sopenharmony_ci							struct radeon_ps *radeon_new_state)
18398c2ecf20Sopenharmony_ci{
18408c2ecf20Sopenharmony_ci	int ret = 0;
18418c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
18428c2ecf20Sopenharmony_ci
18438c2ecf20Sopenharmony_ci	if (eg_pi->ulv.supported) {
18448c2ecf20Sopenharmony_ci		if (btc_is_state_ulv_compatible(rdev, radeon_new_state)) {
18458c2ecf20Sopenharmony_ci			// Set ARB[0] to reflect the DRAM timing needed for ULV.
18468c2ecf20Sopenharmony_ci			ret = btc_set_ulv_dram_timing(rdev);
18478c2ecf20Sopenharmony_ci			if (ret == 0)
18488c2ecf20Sopenharmony_ci				ret = btc_enable_ulv(rdev);
18498c2ecf20Sopenharmony_ci		}
18508c2ecf20Sopenharmony_ci	}
18518c2ecf20Sopenharmony_ci
18528c2ecf20Sopenharmony_ci	return ret;
18538c2ecf20Sopenharmony_ci}
18548c2ecf20Sopenharmony_ci
18558c2ecf20Sopenharmony_cistatic bool btc_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
18568c2ecf20Sopenharmony_ci{
18578c2ecf20Sopenharmony_ci	bool result = true;
18588c2ecf20Sopenharmony_ci
18598c2ecf20Sopenharmony_ci	switch (in_reg) {
18608c2ecf20Sopenharmony_ci	case MC_SEQ_RAS_TIMING >> 2:
18618c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_RAS_TIMING_LP >> 2;
18628c2ecf20Sopenharmony_ci		break;
18638c2ecf20Sopenharmony_ci	case MC_SEQ_CAS_TIMING >> 2:
18648c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_CAS_TIMING_LP >> 2;
18658c2ecf20Sopenharmony_ci		break;
18668c2ecf20Sopenharmony_ci	case MC_SEQ_MISC_TIMING >> 2:
18678c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_MISC_TIMING_LP >> 2;
18688c2ecf20Sopenharmony_ci		break;
18698c2ecf20Sopenharmony_ci	case MC_SEQ_MISC_TIMING2 >> 2:
18708c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_MISC_TIMING2_LP >> 2;
18718c2ecf20Sopenharmony_ci		break;
18728c2ecf20Sopenharmony_ci	case MC_SEQ_RD_CTL_D0 >> 2:
18738c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_RD_CTL_D0_LP >> 2;
18748c2ecf20Sopenharmony_ci		break;
18758c2ecf20Sopenharmony_ci	case MC_SEQ_RD_CTL_D1 >> 2:
18768c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_RD_CTL_D1_LP >> 2;
18778c2ecf20Sopenharmony_ci		break;
18788c2ecf20Sopenharmony_ci	case MC_SEQ_WR_CTL_D0 >> 2:
18798c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_WR_CTL_D0_LP >> 2;
18808c2ecf20Sopenharmony_ci		break;
18818c2ecf20Sopenharmony_ci	case MC_SEQ_WR_CTL_D1 >> 2:
18828c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_WR_CTL_D1_LP >> 2;
18838c2ecf20Sopenharmony_ci		break;
18848c2ecf20Sopenharmony_ci	case MC_PMG_CMD_EMRS >> 2:
18858c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
18868c2ecf20Sopenharmony_ci		break;
18878c2ecf20Sopenharmony_ci	case MC_PMG_CMD_MRS >> 2:
18888c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_MRS_LP >> 2;
18898c2ecf20Sopenharmony_ci		break;
18908c2ecf20Sopenharmony_ci	case MC_PMG_CMD_MRS1 >> 2:
18918c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
18928c2ecf20Sopenharmony_ci		break;
18938c2ecf20Sopenharmony_ci	default:
18948c2ecf20Sopenharmony_ci		result = false;
18958c2ecf20Sopenharmony_ci		break;
18968c2ecf20Sopenharmony_ci	}
18978c2ecf20Sopenharmony_ci
18988c2ecf20Sopenharmony_ci	return result;
18998c2ecf20Sopenharmony_ci}
19008c2ecf20Sopenharmony_ci
19018c2ecf20Sopenharmony_cistatic void btc_set_valid_flag(struct evergreen_mc_reg_table *table)
19028c2ecf20Sopenharmony_ci{
19038c2ecf20Sopenharmony_ci	u8 i, j;
19048c2ecf20Sopenharmony_ci
19058c2ecf20Sopenharmony_ci	for (i = 0; i < table->last; i++) {
19068c2ecf20Sopenharmony_ci		for (j = 1; j < table->num_entries; j++) {
19078c2ecf20Sopenharmony_ci			if (table->mc_reg_table_entry[j-1].mc_data[i] !=
19088c2ecf20Sopenharmony_ci			    table->mc_reg_table_entry[j].mc_data[i]) {
19098c2ecf20Sopenharmony_ci				table->valid_flag |= (1 << i);
19108c2ecf20Sopenharmony_ci				break;
19118c2ecf20Sopenharmony_ci			}
19128c2ecf20Sopenharmony_ci		}
19138c2ecf20Sopenharmony_ci	}
19148c2ecf20Sopenharmony_ci}
19158c2ecf20Sopenharmony_ci
19168c2ecf20Sopenharmony_cistatic int btc_set_mc_special_registers(struct radeon_device *rdev,
19178c2ecf20Sopenharmony_ci					struct evergreen_mc_reg_table *table)
19188c2ecf20Sopenharmony_ci{
19198c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
19208c2ecf20Sopenharmony_ci	u8 i, j, k;
19218c2ecf20Sopenharmony_ci	u32 tmp;
19228c2ecf20Sopenharmony_ci
19238c2ecf20Sopenharmony_ci	for (i = 0, j = table->last; i < table->last; i++) {
19248c2ecf20Sopenharmony_ci		switch (table->mc_reg_address[i].s1) {
19258c2ecf20Sopenharmony_ci		case MC_SEQ_MISC1 >> 2:
19268c2ecf20Sopenharmony_ci			tmp = RREG32(MC_PMG_CMD_EMRS);
19278c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS >> 2;
19288c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
19298c2ecf20Sopenharmony_ci			for (k = 0; k < table->num_entries; k++) {
19308c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[k].mc_data[j] =
19318c2ecf20Sopenharmony_ci					((tmp & 0xffff0000)) |
19328c2ecf20Sopenharmony_ci					((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
19338c2ecf20Sopenharmony_ci			}
19348c2ecf20Sopenharmony_ci			j++;
19358c2ecf20Sopenharmony_ci
19368c2ecf20Sopenharmony_ci			if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19378c2ecf20Sopenharmony_ci				return -EINVAL;
19388c2ecf20Sopenharmony_ci
19398c2ecf20Sopenharmony_ci			tmp = RREG32(MC_PMG_CMD_MRS);
19408c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS >> 2;
19418c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP >> 2;
19428c2ecf20Sopenharmony_ci			for (k = 0; k < table->num_entries; k++) {
19438c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[k].mc_data[j] =
19448c2ecf20Sopenharmony_ci					(tmp & 0xffff0000) |
19458c2ecf20Sopenharmony_ci					(table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
19468c2ecf20Sopenharmony_ci				if (!pi->mem_gddr5)
19478c2ecf20Sopenharmony_ci					table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
19488c2ecf20Sopenharmony_ci			}
19498c2ecf20Sopenharmony_ci			j++;
19508c2ecf20Sopenharmony_ci
19518c2ecf20Sopenharmony_ci			if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19528c2ecf20Sopenharmony_ci				return -EINVAL;
19538c2ecf20Sopenharmony_ci			break;
19548c2ecf20Sopenharmony_ci		case MC_SEQ_RESERVE_M >> 2:
19558c2ecf20Sopenharmony_ci			tmp = RREG32(MC_PMG_CMD_MRS1);
19568c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1 >> 2;
19578c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
19588c2ecf20Sopenharmony_ci			for (k = 0; k < table->num_entries; k++) {
19598c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[k].mc_data[j] =
19608c2ecf20Sopenharmony_ci					(tmp & 0xffff0000) |
19618c2ecf20Sopenharmony_ci					(table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
19628c2ecf20Sopenharmony_ci			}
19638c2ecf20Sopenharmony_ci			j++;
19648c2ecf20Sopenharmony_ci
19658c2ecf20Sopenharmony_ci			if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19668c2ecf20Sopenharmony_ci				return -EINVAL;
19678c2ecf20Sopenharmony_ci			break;
19688c2ecf20Sopenharmony_ci		default:
19698c2ecf20Sopenharmony_ci			break;
19708c2ecf20Sopenharmony_ci		}
19718c2ecf20Sopenharmony_ci	}
19728c2ecf20Sopenharmony_ci
19738c2ecf20Sopenharmony_ci	table->last = j;
19748c2ecf20Sopenharmony_ci
19758c2ecf20Sopenharmony_ci	return 0;
19768c2ecf20Sopenharmony_ci}
19778c2ecf20Sopenharmony_ci
19788c2ecf20Sopenharmony_cistatic void btc_set_s0_mc_reg_index(struct evergreen_mc_reg_table *table)
19798c2ecf20Sopenharmony_ci{
19808c2ecf20Sopenharmony_ci	u32 i;
19818c2ecf20Sopenharmony_ci	u16 address;
19828c2ecf20Sopenharmony_ci
19838c2ecf20Sopenharmony_ci	for (i = 0; i < table->last; i++) {
19848c2ecf20Sopenharmony_ci		table->mc_reg_address[i].s0 =
19858c2ecf20Sopenharmony_ci			btc_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
19868c2ecf20Sopenharmony_ci			address : table->mc_reg_address[i].s1;
19878c2ecf20Sopenharmony_ci	}
19888c2ecf20Sopenharmony_ci}
19898c2ecf20Sopenharmony_ci
19908c2ecf20Sopenharmony_cistatic int btc_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
19918c2ecf20Sopenharmony_ci				       struct evergreen_mc_reg_table *eg_table)
19928c2ecf20Sopenharmony_ci{
19938c2ecf20Sopenharmony_ci	u8 i, j;
19948c2ecf20Sopenharmony_ci
19958c2ecf20Sopenharmony_ci	if (table->last > SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
19968c2ecf20Sopenharmony_ci		return -EINVAL;
19978c2ecf20Sopenharmony_ci
19988c2ecf20Sopenharmony_ci	if (table->num_entries > MAX_AC_TIMING_ENTRIES)
19998c2ecf20Sopenharmony_ci		return -EINVAL;
20008c2ecf20Sopenharmony_ci
20018c2ecf20Sopenharmony_ci	for (i = 0; i < table->last; i++)
20028c2ecf20Sopenharmony_ci		eg_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
20038c2ecf20Sopenharmony_ci	eg_table->last = table->last;
20048c2ecf20Sopenharmony_ci
20058c2ecf20Sopenharmony_ci	for (i = 0; i < table->num_entries; i++) {
20068c2ecf20Sopenharmony_ci		eg_table->mc_reg_table_entry[i].mclk_max =
20078c2ecf20Sopenharmony_ci			table->mc_reg_table_entry[i].mclk_max;
20088c2ecf20Sopenharmony_ci		for(j = 0; j < table->last; j++)
20098c2ecf20Sopenharmony_ci			eg_table->mc_reg_table_entry[i].mc_data[j] =
20108c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[i].mc_data[j];
20118c2ecf20Sopenharmony_ci	}
20128c2ecf20Sopenharmony_ci	eg_table->num_entries = table->num_entries;
20138c2ecf20Sopenharmony_ci
20148c2ecf20Sopenharmony_ci	return 0;
20158c2ecf20Sopenharmony_ci}
20168c2ecf20Sopenharmony_ci
20178c2ecf20Sopenharmony_cistatic int btc_initialize_mc_reg_table(struct radeon_device *rdev)
20188c2ecf20Sopenharmony_ci{
20198c2ecf20Sopenharmony_ci	int ret;
20208c2ecf20Sopenharmony_ci	struct atom_mc_reg_table *table;
20218c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
20228c2ecf20Sopenharmony_ci	struct evergreen_mc_reg_table *eg_table = &eg_pi->mc_reg_table;
20238c2ecf20Sopenharmony_ci	u8 module_index = rv770_get_memory_module_index(rdev);
20248c2ecf20Sopenharmony_ci
20258c2ecf20Sopenharmony_ci	table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
20268c2ecf20Sopenharmony_ci	if (!table)
20278c2ecf20Sopenharmony_ci		return -ENOMEM;
20288c2ecf20Sopenharmony_ci
20298c2ecf20Sopenharmony_ci	/* Program additional LP registers that are no longer programmed by VBIOS */
20308c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
20318c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
20328c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
20338c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
20348c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
20358c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
20368c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
20378c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
20388c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
20398c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
20408c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
20418c2ecf20Sopenharmony_ci
20428c2ecf20Sopenharmony_ci	ret = radeon_atom_init_mc_reg_table(rdev, module_index, table);
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci	if (ret)
20458c2ecf20Sopenharmony_ci		goto init_mc_done;
20468c2ecf20Sopenharmony_ci
20478c2ecf20Sopenharmony_ci	ret = btc_copy_vbios_mc_reg_table(table, eg_table);
20488c2ecf20Sopenharmony_ci
20498c2ecf20Sopenharmony_ci	if (ret)
20508c2ecf20Sopenharmony_ci		goto init_mc_done;
20518c2ecf20Sopenharmony_ci
20528c2ecf20Sopenharmony_ci	btc_set_s0_mc_reg_index(eg_table);
20538c2ecf20Sopenharmony_ci	ret = btc_set_mc_special_registers(rdev, eg_table);
20548c2ecf20Sopenharmony_ci
20558c2ecf20Sopenharmony_ci	if (ret)
20568c2ecf20Sopenharmony_ci		goto init_mc_done;
20578c2ecf20Sopenharmony_ci
20588c2ecf20Sopenharmony_ci	btc_set_valid_flag(eg_table);
20598c2ecf20Sopenharmony_ci
20608c2ecf20Sopenharmony_ciinit_mc_done:
20618c2ecf20Sopenharmony_ci	kfree(table);
20628c2ecf20Sopenharmony_ci
20638c2ecf20Sopenharmony_ci	return ret;
20648c2ecf20Sopenharmony_ci}
20658c2ecf20Sopenharmony_ci
20668c2ecf20Sopenharmony_cistatic void btc_init_stutter_mode(struct radeon_device *rdev)
20678c2ecf20Sopenharmony_ci{
20688c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
20698c2ecf20Sopenharmony_ci	u32 tmp;
20708c2ecf20Sopenharmony_ci
20718c2ecf20Sopenharmony_ci	if (pi->mclk_stutter_mode_threshold) {
20728c2ecf20Sopenharmony_ci		if (pi->mem_gddr5) {
20738c2ecf20Sopenharmony_ci			tmp = RREG32(MC_PMG_AUTO_CFG);
20748c2ecf20Sopenharmony_ci			if ((0x200 & tmp) == 0) {
20758c2ecf20Sopenharmony_ci				tmp = (tmp & 0xfffffc0b) | 0x204;
20768c2ecf20Sopenharmony_ci				WREG32(MC_PMG_AUTO_CFG, tmp);
20778c2ecf20Sopenharmony_ci			}
20788c2ecf20Sopenharmony_ci		}
20798c2ecf20Sopenharmony_ci	}
20808c2ecf20Sopenharmony_ci}
20818c2ecf20Sopenharmony_ci
20828c2ecf20Sopenharmony_cibool btc_dpm_vblank_too_short(struct radeon_device *rdev)
20838c2ecf20Sopenharmony_ci{
20848c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
20858c2ecf20Sopenharmony_ci	u32 vblank_time = r600_dpm_get_vblank_time(rdev);
20868c2ecf20Sopenharmony_ci	u32 switch_limit = pi->mem_gddr5 ? 450 : 100;
20878c2ecf20Sopenharmony_ci
20888c2ecf20Sopenharmony_ci	if (vblank_time < switch_limit)
20898c2ecf20Sopenharmony_ci		return true;
20908c2ecf20Sopenharmony_ci	else
20918c2ecf20Sopenharmony_ci		return false;
20928c2ecf20Sopenharmony_ci
20938c2ecf20Sopenharmony_ci}
20948c2ecf20Sopenharmony_ci
20958c2ecf20Sopenharmony_cistatic void btc_apply_state_adjust_rules(struct radeon_device *rdev,
20968c2ecf20Sopenharmony_ci					 struct radeon_ps *rps)
20978c2ecf20Sopenharmony_ci{
20988c2ecf20Sopenharmony_ci	struct rv7xx_ps *ps = rv770_get_ps(rps);
20998c2ecf20Sopenharmony_ci	struct radeon_clock_and_voltage_limits *max_limits;
21008c2ecf20Sopenharmony_ci	bool disable_mclk_switching;
21018c2ecf20Sopenharmony_ci	u32 mclk, sclk;
21028c2ecf20Sopenharmony_ci	u16 vddc, vddci;
21038c2ecf20Sopenharmony_ci
21048c2ecf20Sopenharmony_ci	if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
21058c2ecf20Sopenharmony_ci	    btc_dpm_vblank_too_short(rdev))
21068c2ecf20Sopenharmony_ci		disable_mclk_switching = true;
21078c2ecf20Sopenharmony_ci	else
21088c2ecf20Sopenharmony_ci		disable_mclk_switching = false;
21098c2ecf20Sopenharmony_ci
21108c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.ac_power)
21118c2ecf20Sopenharmony_ci		max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
21128c2ecf20Sopenharmony_ci	else
21138c2ecf20Sopenharmony_ci		max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
21148c2ecf20Sopenharmony_ci
21158c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.ac_power == false) {
21168c2ecf20Sopenharmony_ci		if (ps->high.mclk > max_limits->mclk)
21178c2ecf20Sopenharmony_ci			ps->high.mclk = max_limits->mclk;
21188c2ecf20Sopenharmony_ci		if (ps->high.sclk > max_limits->sclk)
21198c2ecf20Sopenharmony_ci			ps->high.sclk = max_limits->sclk;
21208c2ecf20Sopenharmony_ci		if (ps->high.vddc > max_limits->vddc)
21218c2ecf20Sopenharmony_ci			ps->high.vddc = max_limits->vddc;
21228c2ecf20Sopenharmony_ci		if (ps->high.vddci > max_limits->vddci)
21238c2ecf20Sopenharmony_ci			ps->high.vddci = max_limits->vddci;
21248c2ecf20Sopenharmony_ci
21258c2ecf20Sopenharmony_ci		if (ps->medium.mclk > max_limits->mclk)
21268c2ecf20Sopenharmony_ci			ps->medium.mclk = max_limits->mclk;
21278c2ecf20Sopenharmony_ci		if (ps->medium.sclk > max_limits->sclk)
21288c2ecf20Sopenharmony_ci			ps->medium.sclk = max_limits->sclk;
21298c2ecf20Sopenharmony_ci		if (ps->medium.vddc > max_limits->vddc)
21308c2ecf20Sopenharmony_ci			ps->medium.vddc = max_limits->vddc;
21318c2ecf20Sopenharmony_ci		if (ps->medium.vddci > max_limits->vddci)
21328c2ecf20Sopenharmony_ci			ps->medium.vddci = max_limits->vddci;
21338c2ecf20Sopenharmony_ci
21348c2ecf20Sopenharmony_ci		if (ps->low.mclk > max_limits->mclk)
21358c2ecf20Sopenharmony_ci			ps->low.mclk = max_limits->mclk;
21368c2ecf20Sopenharmony_ci		if (ps->low.sclk > max_limits->sclk)
21378c2ecf20Sopenharmony_ci			ps->low.sclk = max_limits->sclk;
21388c2ecf20Sopenharmony_ci		if (ps->low.vddc > max_limits->vddc)
21398c2ecf20Sopenharmony_ci			ps->low.vddc = max_limits->vddc;
21408c2ecf20Sopenharmony_ci		if (ps->low.vddci > max_limits->vddci)
21418c2ecf20Sopenharmony_ci			ps->low.vddci = max_limits->vddci;
21428c2ecf20Sopenharmony_ci	}
21438c2ecf20Sopenharmony_ci
21448c2ecf20Sopenharmony_ci	/* XXX validate the min clocks required for display */
21458c2ecf20Sopenharmony_ci
21468c2ecf20Sopenharmony_ci	if (disable_mclk_switching) {
21478c2ecf20Sopenharmony_ci		sclk = ps->low.sclk;
21488c2ecf20Sopenharmony_ci		mclk = ps->high.mclk;
21498c2ecf20Sopenharmony_ci		vddc = ps->low.vddc;
21508c2ecf20Sopenharmony_ci		vddci = ps->high.vddci;
21518c2ecf20Sopenharmony_ci	} else {
21528c2ecf20Sopenharmony_ci		sclk = ps->low.sclk;
21538c2ecf20Sopenharmony_ci		mclk = ps->low.mclk;
21548c2ecf20Sopenharmony_ci		vddc = ps->low.vddc;
21558c2ecf20Sopenharmony_ci		vddci = ps->low.vddci;
21568c2ecf20Sopenharmony_ci	}
21578c2ecf20Sopenharmony_ci
21588c2ecf20Sopenharmony_ci	/* adjusted low state */
21598c2ecf20Sopenharmony_ci	ps->low.sclk = sclk;
21608c2ecf20Sopenharmony_ci	ps->low.mclk = mclk;
21618c2ecf20Sopenharmony_ci	ps->low.vddc = vddc;
21628c2ecf20Sopenharmony_ci	ps->low.vddci = vddci;
21638c2ecf20Sopenharmony_ci
21648c2ecf20Sopenharmony_ci	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
21658c2ecf20Sopenharmony_ci				  &ps->low.sclk, &ps->low.mclk);
21668c2ecf20Sopenharmony_ci
21678c2ecf20Sopenharmony_ci	/* adjusted medium, high states */
21688c2ecf20Sopenharmony_ci	if (ps->medium.sclk < ps->low.sclk)
21698c2ecf20Sopenharmony_ci		ps->medium.sclk = ps->low.sclk;
21708c2ecf20Sopenharmony_ci	if (ps->medium.vddc < ps->low.vddc)
21718c2ecf20Sopenharmony_ci		ps->medium.vddc = ps->low.vddc;
21728c2ecf20Sopenharmony_ci	if (ps->high.sclk < ps->medium.sclk)
21738c2ecf20Sopenharmony_ci		ps->high.sclk = ps->medium.sclk;
21748c2ecf20Sopenharmony_ci	if (ps->high.vddc < ps->medium.vddc)
21758c2ecf20Sopenharmony_ci		ps->high.vddc = ps->medium.vddc;
21768c2ecf20Sopenharmony_ci
21778c2ecf20Sopenharmony_ci	if (disable_mclk_switching) {
21788c2ecf20Sopenharmony_ci		mclk = ps->low.mclk;
21798c2ecf20Sopenharmony_ci		if (mclk < ps->medium.mclk)
21808c2ecf20Sopenharmony_ci			mclk = ps->medium.mclk;
21818c2ecf20Sopenharmony_ci		if (mclk < ps->high.mclk)
21828c2ecf20Sopenharmony_ci			mclk = ps->high.mclk;
21838c2ecf20Sopenharmony_ci		ps->low.mclk = mclk;
21848c2ecf20Sopenharmony_ci		ps->low.vddci = vddci;
21858c2ecf20Sopenharmony_ci		ps->medium.mclk = mclk;
21868c2ecf20Sopenharmony_ci		ps->medium.vddci = vddci;
21878c2ecf20Sopenharmony_ci		ps->high.mclk = mclk;
21888c2ecf20Sopenharmony_ci		ps->high.vddci = vddci;
21898c2ecf20Sopenharmony_ci	} else {
21908c2ecf20Sopenharmony_ci		if (ps->medium.mclk < ps->low.mclk)
21918c2ecf20Sopenharmony_ci			ps->medium.mclk = ps->low.mclk;
21928c2ecf20Sopenharmony_ci		if (ps->medium.vddci < ps->low.vddci)
21938c2ecf20Sopenharmony_ci			ps->medium.vddci = ps->low.vddci;
21948c2ecf20Sopenharmony_ci		if (ps->high.mclk < ps->medium.mclk)
21958c2ecf20Sopenharmony_ci			ps->high.mclk = ps->medium.mclk;
21968c2ecf20Sopenharmony_ci		if (ps->high.vddci < ps->medium.vddci)
21978c2ecf20Sopenharmony_ci			ps->high.vddci = ps->medium.vddci;
21988c2ecf20Sopenharmony_ci	}
21998c2ecf20Sopenharmony_ci
22008c2ecf20Sopenharmony_ci	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
22018c2ecf20Sopenharmony_ci				  &ps->medium.sclk, &ps->medium.mclk);
22028c2ecf20Sopenharmony_ci	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
22038c2ecf20Sopenharmony_ci				  &ps->high.sclk, &ps->high.mclk);
22048c2ecf20Sopenharmony_ci
22058c2ecf20Sopenharmony_ci	btc_adjust_clock_combinations(rdev, max_limits, &ps->low);
22068c2ecf20Sopenharmony_ci	btc_adjust_clock_combinations(rdev, max_limits, &ps->medium);
22078c2ecf20Sopenharmony_ci	btc_adjust_clock_combinations(rdev, max_limits, &ps->high);
22088c2ecf20Sopenharmony_ci
22098c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
22108c2ecf20Sopenharmony_ci					   ps->low.sclk, max_limits->vddc, &ps->low.vddc);
22118c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
22128c2ecf20Sopenharmony_ci					   ps->low.mclk, max_limits->vddci, &ps->low.vddci);
22138c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
22148c2ecf20Sopenharmony_ci					   ps->low.mclk, max_limits->vddc, &ps->low.vddc);
22158c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
22168c2ecf20Sopenharmony_ci					   rdev->clock.current_dispclk, max_limits->vddc, &ps->low.vddc);
22178c2ecf20Sopenharmony_ci
22188c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
22198c2ecf20Sopenharmony_ci					   ps->medium.sclk, max_limits->vddc, &ps->medium.vddc);
22208c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
22218c2ecf20Sopenharmony_ci					   ps->medium.mclk, max_limits->vddci, &ps->medium.vddci);
22228c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
22238c2ecf20Sopenharmony_ci					   ps->medium.mclk, max_limits->vddc, &ps->medium.vddc);
22248c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
22258c2ecf20Sopenharmony_ci					   rdev->clock.current_dispclk, max_limits->vddc, &ps->medium.vddc);
22268c2ecf20Sopenharmony_ci
22278c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
22288c2ecf20Sopenharmony_ci					   ps->high.sclk, max_limits->vddc, &ps->high.vddc);
22298c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
22308c2ecf20Sopenharmony_ci					   ps->high.mclk, max_limits->vddci, &ps->high.vddci);
22318c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
22328c2ecf20Sopenharmony_ci					   ps->high.mclk, max_limits->vddc, &ps->high.vddc);
22338c2ecf20Sopenharmony_ci	btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
22348c2ecf20Sopenharmony_ci					   rdev->clock.current_dispclk, max_limits->vddc, &ps->high.vddc);
22358c2ecf20Sopenharmony_ci
22368c2ecf20Sopenharmony_ci	btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
22378c2ecf20Sopenharmony_ci				      &ps->low.vddc, &ps->low.vddci);
22388c2ecf20Sopenharmony_ci	btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
22398c2ecf20Sopenharmony_ci				      &ps->medium.vddc, &ps->medium.vddci);
22408c2ecf20Sopenharmony_ci	btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
22418c2ecf20Sopenharmony_ci				      &ps->high.vddc, &ps->high.vddci);
22428c2ecf20Sopenharmony_ci
22438c2ecf20Sopenharmony_ci	if ((ps->high.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) &&
22448c2ecf20Sopenharmony_ci	    (ps->medium.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) &&
22458c2ecf20Sopenharmony_ci	    (ps->low.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc))
22468c2ecf20Sopenharmony_ci		ps->dc_compatible = true;
22478c2ecf20Sopenharmony_ci	else
22488c2ecf20Sopenharmony_ci		ps->dc_compatible = false;
22498c2ecf20Sopenharmony_ci
22508c2ecf20Sopenharmony_ci	if (ps->low.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
22518c2ecf20Sopenharmony_ci		ps->low.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
22528c2ecf20Sopenharmony_ci	if (ps->medium.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
22538c2ecf20Sopenharmony_ci		ps->medium.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
22548c2ecf20Sopenharmony_ci	if (ps->high.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
22558c2ecf20Sopenharmony_ci		ps->high.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
22568c2ecf20Sopenharmony_ci}
22578c2ecf20Sopenharmony_ci
22588c2ecf20Sopenharmony_cistatic void btc_update_current_ps(struct radeon_device *rdev,
22598c2ecf20Sopenharmony_ci				  struct radeon_ps *rps)
22608c2ecf20Sopenharmony_ci{
22618c2ecf20Sopenharmony_ci	struct rv7xx_ps *new_ps = rv770_get_ps(rps);
22628c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
22638c2ecf20Sopenharmony_ci
22648c2ecf20Sopenharmony_ci	eg_pi->current_rps = *rps;
22658c2ecf20Sopenharmony_ci	eg_pi->current_ps = *new_ps;
22668c2ecf20Sopenharmony_ci	eg_pi->current_rps.ps_priv = &eg_pi->current_ps;
22678c2ecf20Sopenharmony_ci}
22688c2ecf20Sopenharmony_ci
22698c2ecf20Sopenharmony_cistatic void btc_update_requested_ps(struct radeon_device *rdev,
22708c2ecf20Sopenharmony_ci				    struct radeon_ps *rps)
22718c2ecf20Sopenharmony_ci{
22728c2ecf20Sopenharmony_ci	struct rv7xx_ps *new_ps = rv770_get_ps(rps);
22738c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
22748c2ecf20Sopenharmony_ci
22758c2ecf20Sopenharmony_ci	eg_pi->requested_rps = *rps;
22768c2ecf20Sopenharmony_ci	eg_pi->requested_ps = *new_ps;
22778c2ecf20Sopenharmony_ci	eg_pi->requested_rps.ps_priv = &eg_pi->requested_ps;
22788c2ecf20Sopenharmony_ci}
22798c2ecf20Sopenharmony_ci
22808c2ecf20Sopenharmony_ci#if 0
22818c2ecf20Sopenharmony_civoid btc_dpm_reset_asic(struct radeon_device *rdev)
22828c2ecf20Sopenharmony_ci{
22838c2ecf20Sopenharmony_ci	rv770_restrict_performance_levels_before_switch(rdev);
22848c2ecf20Sopenharmony_ci	btc_disable_ulv(rdev);
22858c2ecf20Sopenharmony_ci	btc_set_boot_state_timing(rdev);
22868c2ecf20Sopenharmony_ci	rv770_set_boot_state(rdev);
22878c2ecf20Sopenharmony_ci}
22888c2ecf20Sopenharmony_ci#endif
22898c2ecf20Sopenharmony_ci
22908c2ecf20Sopenharmony_ciint btc_dpm_pre_set_power_state(struct radeon_device *rdev)
22918c2ecf20Sopenharmony_ci{
22928c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
22938c2ecf20Sopenharmony_ci	struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps;
22948c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = &requested_ps;
22958c2ecf20Sopenharmony_ci
22968c2ecf20Sopenharmony_ci	btc_update_requested_ps(rdev, new_ps);
22978c2ecf20Sopenharmony_ci
22988c2ecf20Sopenharmony_ci	btc_apply_state_adjust_rules(rdev, &eg_pi->requested_rps);
22998c2ecf20Sopenharmony_ci
23008c2ecf20Sopenharmony_ci	return 0;
23018c2ecf20Sopenharmony_ci}
23028c2ecf20Sopenharmony_ci
23038c2ecf20Sopenharmony_ciint btc_dpm_set_power_state(struct radeon_device *rdev)
23048c2ecf20Sopenharmony_ci{
23058c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
23068c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = &eg_pi->requested_rps;
23078c2ecf20Sopenharmony_ci	struct radeon_ps *old_ps = &eg_pi->current_rps;
23088c2ecf20Sopenharmony_ci	int ret;
23098c2ecf20Sopenharmony_ci
23108c2ecf20Sopenharmony_ci	ret = btc_disable_ulv(rdev);
23118c2ecf20Sopenharmony_ci	btc_set_boot_state_timing(rdev);
23128c2ecf20Sopenharmony_ci	ret = rv770_restrict_performance_levels_before_switch(rdev);
23138c2ecf20Sopenharmony_ci	if (ret) {
23148c2ecf20Sopenharmony_ci		DRM_ERROR("rv770_restrict_performance_levels_before_switch failed\n");
23158c2ecf20Sopenharmony_ci		return ret;
23168c2ecf20Sopenharmony_ci	}
23178c2ecf20Sopenharmony_ci	if (eg_pi->pcie_performance_request)
23188c2ecf20Sopenharmony_ci		cypress_notify_link_speed_change_before_state_change(rdev, new_ps, old_ps);
23198c2ecf20Sopenharmony_ci
23208c2ecf20Sopenharmony_ci	rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
23218c2ecf20Sopenharmony_ci	ret = rv770_halt_smc(rdev);
23228c2ecf20Sopenharmony_ci	if (ret) {
23238c2ecf20Sopenharmony_ci		DRM_ERROR("rv770_halt_smc failed\n");
23248c2ecf20Sopenharmony_ci		return ret;
23258c2ecf20Sopenharmony_ci	}
23268c2ecf20Sopenharmony_ci	btc_set_at_for_uvd(rdev, new_ps);
23278c2ecf20Sopenharmony_ci	if (eg_pi->smu_uvd_hs)
23288c2ecf20Sopenharmony_ci		btc_notify_uvd_to_smc(rdev, new_ps);
23298c2ecf20Sopenharmony_ci	ret = cypress_upload_sw_state(rdev, new_ps);
23308c2ecf20Sopenharmony_ci	if (ret) {
23318c2ecf20Sopenharmony_ci		DRM_ERROR("cypress_upload_sw_state failed\n");
23328c2ecf20Sopenharmony_ci		return ret;
23338c2ecf20Sopenharmony_ci	}
23348c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing) {
23358c2ecf20Sopenharmony_ci		ret = cypress_upload_mc_reg_table(rdev, new_ps);
23368c2ecf20Sopenharmony_ci		if (ret) {
23378c2ecf20Sopenharmony_ci			DRM_ERROR("cypress_upload_mc_reg_table failed\n");
23388c2ecf20Sopenharmony_ci			return ret;
23398c2ecf20Sopenharmony_ci		}
23408c2ecf20Sopenharmony_ci	}
23418c2ecf20Sopenharmony_ci
23428c2ecf20Sopenharmony_ci	cypress_program_memory_timing_parameters(rdev, new_ps);
23438c2ecf20Sopenharmony_ci
23448c2ecf20Sopenharmony_ci	ret = rv770_resume_smc(rdev);
23458c2ecf20Sopenharmony_ci	if (ret) {
23468c2ecf20Sopenharmony_ci		DRM_ERROR("rv770_resume_smc failed\n");
23478c2ecf20Sopenharmony_ci		return ret;
23488c2ecf20Sopenharmony_ci	}
23498c2ecf20Sopenharmony_ci	ret = rv770_set_sw_state(rdev);
23508c2ecf20Sopenharmony_ci	if (ret) {
23518c2ecf20Sopenharmony_ci		DRM_ERROR("rv770_set_sw_state failed\n");
23528c2ecf20Sopenharmony_ci		return ret;
23538c2ecf20Sopenharmony_ci	}
23548c2ecf20Sopenharmony_ci	rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
23558c2ecf20Sopenharmony_ci
23568c2ecf20Sopenharmony_ci	if (eg_pi->pcie_performance_request)
23578c2ecf20Sopenharmony_ci		cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
23588c2ecf20Sopenharmony_ci
23598c2ecf20Sopenharmony_ci	ret = btc_set_power_state_conditionally_enable_ulv(rdev, new_ps);
23608c2ecf20Sopenharmony_ci	if (ret) {
23618c2ecf20Sopenharmony_ci		DRM_ERROR("btc_set_power_state_conditionally_enable_ulv failed\n");
23628c2ecf20Sopenharmony_ci		return ret;
23638c2ecf20Sopenharmony_ci	}
23648c2ecf20Sopenharmony_ci
23658c2ecf20Sopenharmony_ci	return 0;
23668c2ecf20Sopenharmony_ci}
23678c2ecf20Sopenharmony_ci
23688c2ecf20Sopenharmony_civoid btc_dpm_post_set_power_state(struct radeon_device *rdev)
23698c2ecf20Sopenharmony_ci{
23708c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
23718c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = &eg_pi->requested_rps;
23728c2ecf20Sopenharmony_ci
23738c2ecf20Sopenharmony_ci	btc_update_current_ps(rdev, new_ps);
23748c2ecf20Sopenharmony_ci}
23758c2ecf20Sopenharmony_ci
23768c2ecf20Sopenharmony_ciint btc_dpm_enable(struct radeon_device *rdev)
23778c2ecf20Sopenharmony_ci{
23788c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
23798c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
23808c2ecf20Sopenharmony_ci	struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
23818c2ecf20Sopenharmony_ci	int ret;
23828c2ecf20Sopenharmony_ci
23838c2ecf20Sopenharmony_ci	if (pi->gfx_clock_gating)
23848c2ecf20Sopenharmony_ci		btc_cg_clock_gating_default(rdev);
23858c2ecf20Sopenharmony_ci
23868c2ecf20Sopenharmony_ci	if (btc_dpm_enabled(rdev))
23878c2ecf20Sopenharmony_ci		return -EINVAL;
23888c2ecf20Sopenharmony_ci
23898c2ecf20Sopenharmony_ci	if (pi->mg_clock_gating)
23908c2ecf20Sopenharmony_ci		btc_mg_clock_gating_default(rdev);
23918c2ecf20Sopenharmony_ci
23928c2ecf20Sopenharmony_ci	if (eg_pi->ls_clock_gating)
23938c2ecf20Sopenharmony_ci		btc_ls_clock_gating_default(rdev);
23948c2ecf20Sopenharmony_ci
23958c2ecf20Sopenharmony_ci	if (pi->voltage_control) {
23968c2ecf20Sopenharmony_ci		rv770_enable_voltage_control(rdev, true);
23978c2ecf20Sopenharmony_ci		ret = cypress_construct_voltage_tables(rdev);
23988c2ecf20Sopenharmony_ci		if (ret) {
23998c2ecf20Sopenharmony_ci			DRM_ERROR("cypress_construct_voltage_tables failed\n");
24008c2ecf20Sopenharmony_ci			return ret;
24018c2ecf20Sopenharmony_ci		}
24028c2ecf20Sopenharmony_ci	}
24038c2ecf20Sopenharmony_ci
24048c2ecf20Sopenharmony_ci	if (pi->mvdd_control) {
24058c2ecf20Sopenharmony_ci		ret = cypress_get_mvdd_configuration(rdev);
24068c2ecf20Sopenharmony_ci		if (ret) {
24078c2ecf20Sopenharmony_ci			DRM_ERROR("cypress_get_mvdd_configuration failed\n");
24088c2ecf20Sopenharmony_ci			return ret;
24098c2ecf20Sopenharmony_ci		}
24108c2ecf20Sopenharmony_ci	}
24118c2ecf20Sopenharmony_ci
24128c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing) {
24138c2ecf20Sopenharmony_ci		ret = btc_initialize_mc_reg_table(rdev);
24148c2ecf20Sopenharmony_ci		if (ret)
24158c2ecf20Sopenharmony_ci			eg_pi->dynamic_ac_timing = false;
24168c2ecf20Sopenharmony_ci	}
24178c2ecf20Sopenharmony_ci
24188c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_BACKBIAS)
24198c2ecf20Sopenharmony_ci		rv770_enable_backbias(rdev, true);
24208c2ecf20Sopenharmony_ci
24218c2ecf20Sopenharmony_ci	if (pi->dynamic_ss)
24228c2ecf20Sopenharmony_ci		cypress_enable_spread_spectrum(rdev, true);
24238c2ecf20Sopenharmony_ci
24248c2ecf20Sopenharmony_ci	if (pi->thermal_protection)
24258c2ecf20Sopenharmony_ci		rv770_enable_thermal_protection(rdev, true);
24268c2ecf20Sopenharmony_ci
24278c2ecf20Sopenharmony_ci	rv770_setup_bsp(rdev);
24288c2ecf20Sopenharmony_ci	rv770_program_git(rdev);
24298c2ecf20Sopenharmony_ci	rv770_program_tp(rdev);
24308c2ecf20Sopenharmony_ci	rv770_program_tpp(rdev);
24318c2ecf20Sopenharmony_ci	rv770_program_sstp(rdev);
24328c2ecf20Sopenharmony_ci	rv770_program_engine_speed_parameters(rdev);
24338c2ecf20Sopenharmony_ci	cypress_enable_display_gap(rdev);
24348c2ecf20Sopenharmony_ci	rv770_program_vc(rdev);
24358c2ecf20Sopenharmony_ci
24368c2ecf20Sopenharmony_ci	if (pi->dynamic_pcie_gen2)
24378c2ecf20Sopenharmony_ci		btc_enable_dynamic_pcie_gen2(rdev, true);
24388c2ecf20Sopenharmony_ci
24398c2ecf20Sopenharmony_ci	ret = rv770_upload_firmware(rdev);
24408c2ecf20Sopenharmony_ci	if (ret) {
24418c2ecf20Sopenharmony_ci		DRM_ERROR("rv770_upload_firmware failed\n");
24428c2ecf20Sopenharmony_ci		return ret;
24438c2ecf20Sopenharmony_ci	}
24448c2ecf20Sopenharmony_ci	ret = cypress_get_table_locations(rdev);
24458c2ecf20Sopenharmony_ci	if (ret) {
24468c2ecf20Sopenharmony_ci		DRM_ERROR("cypress_get_table_locations failed\n");
24478c2ecf20Sopenharmony_ci		return ret;
24488c2ecf20Sopenharmony_ci	}
24498c2ecf20Sopenharmony_ci	ret = btc_init_smc_table(rdev, boot_ps);
24508c2ecf20Sopenharmony_ci	if (ret)
24518c2ecf20Sopenharmony_ci		return ret;
24528c2ecf20Sopenharmony_ci
24538c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing) {
24548c2ecf20Sopenharmony_ci		ret = cypress_populate_mc_reg_table(rdev, boot_ps);
24558c2ecf20Sopenharmony_ci		if (ret) {
24568c2ecf20Sopenharmony_ci			DRM_ERROR("cypress_populate_mc_reg_table failed\n");
24578c2ecf20Sopenharmony_ci			return ret;
24588c2ecf20Sopenharmony_ci		}
24598c2ecf20Sopenharmony_ci	}
24608c2ecf20Sopenharmony_ci
24618c2ecf20Sopenharmony_ci	cypress_program_response_times(rdev);
24628c2ecf20Sopenharmony_ci	r7xx_start_smc(rdev);
24638c2ecf20Sopenharmony_ci	ret = cypress_notify_smc_display_change(rdev, false);
24648c2ecf20Sopenharmony_ci	if (ret) {
24658c2ecf20Sopenharmony_ci		DRM_ERROR("cypress_notify_smc_display_change failed\n");
24668c2ecf20Sopenharmony_ci		return ret;
24678c2ecf20Sopenharmony_ci	}
24688c2ecf20Sopenharmony_ci	cypress_enable_sclk_control(rdev, true);
24698c2ecf20Sopenharmony_ci
24708c2ecf20Sopenharmony_ci	if (eg_pi->memory_transition)
24718c2ecf20Sopenharmony_ci		cypress_enable_mclk_control(rdev, true);
24728c2ecf20Sopenharmony_ci
24738c2ecf20Sopenharmony_ci	cypress_start_dpm(rdev);
24748c2ecf20Sopenharmony_ci
24758c2ecf20Sopenharmony_ci	if (pi->gfx_clock_gating)
24768c2ecf20Sopenharmony_ci		btc_cg_clock_gating_enable(rdev, true);
24778c2ecf20Sopenharmony_ci
24788c2ecf20Sopenharmony_ci	if (pi->mg_clock_gating)
24798c2ecf20Sopenharmony_ci		btc_mg_clock_gating_enable(rdev, true);
24808c2ecf20Sopenharmony_ci
24818c2ecf20Sopenharmony_ci	if (eg_pi->ls_clock_gating)
24828c2ecf20Sopenharmony_ci		btc_ls_clock_gating_enable(rdev, true);
24838c2ecf20Sopenharmony_ci
24848c2ecf20Sopenharmony_ci	rv770_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
24858c2ecf20Sopenharmony_ci
24868c2ecf20Sopenharmony_ci	btc_init_stutter_mode(rdev);
24878c2ecf20Sopenharmony_ci
24888c2ecf20Sopenharmony_ci	btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
24898c2ecf20Sopenharmony_ci
24908c2ecf20Sopenharmony_ci	return 0;
24918c2ecf20Sopenharmony_ci};
24928c2ecf20Sopenharmony_ci
24938c2ecf20Sopenharmony_civoid btc_dpm_disable(struct radeon_device *rdev)
24948c2ecf20Sopenharmony_ci{
24958c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
24968c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
24978c2ecf20Sopenharmony_ci
24988c2ecf20Sopenharmony_ci	if (!btc_dpm_enabled(rdev))
24998c2ecf20Sopenharmony_ci		return;
25008c2ecf20Sopenharmony_ci
25018c2ecf20Sopenharmony_ci	rv770_clear_vc(rdev);
25028c2ecf20Sopenharmony_ci
25038c2ecf20Sopenharmony_ci	if (pi->thermal_protection)
25048c2ecf20Sopenharmony_ci		rv770_enable_thermal_protection(rdev, false);
25058c2ecf20Sopenharmony_ci
25068c2ecf20Sopenharmony_ci	if (pi->dynamic_pcie_gen2)
25078c2ecf20Sopenharmony_ci		btc_enable_dynamic_pcie_gen2(rdev, false);
25088c2ecf20Sopenharmony_ci
25098c2ecf20Sopenharmony_ci	if (rdev->irq.installed &&
25108c2ecf20Sopenharmony_ci	    r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) {
25118c2ecf20Sopenharmony_ci		rdev->irq.dpm_thermal = false;
25128c2ecf20Sopenharmony_ci		radeon_irq_set(rdev);
25138c2ecf20Sopenharmony_ci	}
25148c2ecf20Sopenharmony_ci
25158c2ecf20Sopenharmony_ci	if (pi->gfx_clock_gating)
25168c2ecf20Sopenharmony_ci		btc_cg_clock_gating_enable(rdev, false);
25178c2ecf20Sopenharmony_ci
25188c2ecf20Sopenharmony_ci	if (pi->mg_clock_gating)
25198c2ecf20Sopenharmony_ci		btc_mg_clock_gating_enable(rdev, false);
25208c2ecf20Sopenharmony_ci
25218c2ecf20Sopenharmony_ci	if (eg_pi->ls_clock_gating)
25228c2ecf20Sopenharmony_ci		btc_ls_clock_gating_enable(rdev, false);
25238c2ecf20Sopenharmony_ci
25248c2ecf20Sopenharmony_ci	rv770_stop_dpm(rdev);
25258c2ecf20Sopenharmony_ci	btc_reset_to_default(rdev);
25268c2ecf20Sopenharmony_ci	btc_stop_smc(rdev);
25278c2ecf20Sopenharmony_ci	cypress_enable_spread_spectrum(rdev, false);
25288c2ecf20Sopenharmony_ci
25298c2ecf20Sopenharmony_ci	btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
25308c2ecf20Sopenharmony_ci}
25318c2ecf20Sopenharmony_ci
25328c2ecf20Sopenharmony_civoid btc_dpm_setup_asic(struct radeon_device *rdev)
25338c2ecf20Sopenharmony_ci{
25348c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
25358c2ecf20Sopenharmony_ci	int r;
25368c2ecf20Sopenharmony_ci
25378c2ecf20Sopenharmony_ci	r = ni_mc_load_microcode(rdev);
25388c2ecf20Sopenharmony_ci	if (r)
25398c2ecf20Sopenharmony_ci		DRM_ERROR("Failed to load MC firmware!\n");
25408c2ecf20Sopenharmony_ci	rv770_get_memory_type(rdev);
25418c2ecf20Sopenharmony_ci	rv740_read_clock_registers(rdev);
25428c2ecf20Sopenharmony_ci	btc_read_arb_registers(rdev);
25438c2ecf20Sopenharmony_ci	rv770_read_voltage_smio_registers(rdev);
25448c2ecf20Sopenharmony_ci
25458c2ecf20Sopenharmony_ci	if (eg_pi->pcie_performance_request)
25468c2ecf20Sopenharmony_ci		cypress_advertise_gen2_capability(rdev);
25478c2ecf20Sopenharmony_ci
25488c2ecf20Sopenharmony_ci	rv770_get_pcie_gen2_status(rdev);
25498c2ecf20Sopenharmony_ci	rv770_enable_acpi_pm(rdev);
25508c2ecf20Sopenharmony_ci}
25518c2ecf20Sopenharmony_ci
25528c2ecf20Sopenharmony_ciint btc_dpm_init(struct radeon_device *rdev)
25538c2ecf20Sopenharmony_ci{
25548c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi;
25558c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi;
25568c2ecf20Sopenharmony_ci	struct atom_clock_dividers dividers;
25578c2ecf20Sopenharmony_ci	int ret;
25588c2ecf20Sopenharmony_ci
25598c2ecf20Sopenharmony_ci	eg_pi = kzalloc(sizeof(struct evergreen_power_info), GFP_KERNEL);
25608c2ecf20Sopenharmony_ci	if (eg_pi == NULL)
25618c2ecf20Sopenharmony_ci		return -ENOMEM;
25628c2ecf20Sopenharmony_ci	rdev->pm.dpm.priv = eg_pi;
25638c2ecf20Sopenharmony_ci	pi = &eg_pi->rv7xx;
25648c2ecf20Sopenharmony_ci
25658c2ecf20Sopenharmony_ci	rv770_get_max_vddc(rdev);
25668c2ecf20Sopenharmony_ci
25678c2ecf20Sopenharmony_ci	eg_pi->ulv.supported = false;
25688c2ecf20Sopenharmony_ci	pi->acpi_vddc = 0;
25698c2ecf20Sopenharmony_ci	eg_pi->acpi_vddci = 0;
25708c2ecf20Sopenharmony_ci	pi->min_vddc_in_table = 0;
25718c2ecf20Sopenharmony_ci	pi->max_vddc_in_table = 0;
25728c2ecf20Sopenharmony_ci
25738c2ecf20Sopenharmony_ci	ret = r600_get_platform_caps(rdev);
25748c2ecf20Sopenharmony_ci	if (ret)
25758c2ecf20Sopenharmony_ci		return ret;
25768c2ecf20Sopenharmony_ci
25778c2ecf20Sopenharmony_ci	ret = rv7xx_parse_power_table(rdev);
25788c2ecf20Sopenharmony_ci	if (ret)
25798c2ecf20Sopenharmony_ci		return ret;
25808c2ecf20Sopenharmony_ci	ret = r600_parse_extended_power_table(rdev);
25818c2ecf20Sopenharmony_ci	if (ret)
25828c2ecf20Sopenharmony_ci		return ret;
25838c2ecf20Sopenharmony_ci
25848c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
25858c2ecf20Sopenharmony_ci		kcalloc(4,
25868c2ecf20Sopenharmony_ci			sizeof(struct radeon_clock_voltage_dependency_entry),
25878c2ecf20Sopenharmony_ci			GFP_KERNEL);
25888c2ecf20Sopenharmony_ci	if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
25898c2ecf20Sopenharmony_ci		r600_free_extended_power_table(rdev);
25908c2ecf20Sopenharmony_ci		return -ENOMEM;
25918c2ecf20Sopenharmony_ci	}
25928c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
25938c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
25948c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
25958c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
25968c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 800;
25978c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
25988c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 800;
25998c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
26008c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 800;
26018c2ecf20Sopenharmony_ci
26028c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.voltage_response_time == 0)
26038c2ecf20Sopenharmony_ci		rdev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
26048c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.backbias_response_time == 0)
26058c2ecf20Sopenharmony_ci		rdev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
26068c2ecf20Sopenharmony_ci
26078c2ecf20Sopenharmony_ci	ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
26088c2ecf20Sopenharmony_ci					     0, false, &dividers);
26098c2ecf20Sopenharmony_ci	if (ret)
26108c2ecf20Sopenharmony_ci		pi->ref_div = dividers.ref_div + 1;
26118c2ecf20Sopenharmony_ci	else
26128c2ecf20Sopenharmony_ci		pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
26138c2ecf20Sopenharmony_ci
26148c2ecf20Sopenharmony_ci	pi->mclk_strobe_mode_threshold = 40000;
26158c2ecf20Sopenharmony_ci	pi->mclk_edc_enable_threshold = 40000;
26168c2ecf20Sopenharmony_ci	eg_pi->mclk_edc_wr_enable_threshold = 40000;
26178c2ecf20Sopenharmony_ci
26188c2ecf20Sopenharmony_ci	pi->rlp = RV770_RLP_DFLT;
26198c2ecf20Sopenharmony_ci	pi->rmp = RV770_RMP_DFLT;
26208c2ecf20Sopenharmony_ci	pi->lhp = RV770_LHP_DFLT;
26218c2ecf20Sopenharmony_ci	pi->lmp = RV770_LMP_DFLT;
26228c2ecf20Sopenharmony_ci
26238c2ecf20Sopenharmony_ci	eg_pi->ats[0].rlp = RV770_RLP_DFLT;
26248c2ecf20Sopenharmony_ci	eg_pi->ats[0].rmp = RV770_RMP_DFLT;
26258c2ecf20Sopenharmony_ci	eg_pi->ats[0].lhp = RV770_LHP_DFLT;
26268c2ecf20Sopenharmony_ci	eg_pi->ats[0].lmp = RV770_LMP_DFLT;
26278c2ecf20Sopenharmony_ci
26288c2ecf20Sopenharmony_ci	eg_pi->ats[1].rlp = BTC_RLP_UVD_DFLT;
26298c2ecf20Sopenharmony_ci	eg_pi->ats[1].rmp = BTC_RMP_UVD_DFLT;
26308c2ecf20Sopenharmony_ci	eg_pi->ats[1].lhp = BTC_LHP_UVD_DFLT;
26318c2ecf20Sopenharmony_ci	eg_pi->ats[1].lmp = BTC_LMP_UVD_DFLT;
26328c2ecf20Sopenharmony_ci
26338c2ecf20Sopenharmony_ci	eg_pi->smu_uvd_hs = true;
26348c2ecf20Sopenharmony_ci
26358c2ecf20Sopenharmony_ci	pi->voltage_control =
26368c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, 0);
26378c2ecf20Sopenharmony_ci
26388c2ecf20Sopenharmony_ci	pi->mvdd_control =
26398c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0);
26408c2ecf20Sopenharmony_ci
26418c2ecf20Sopenharmony_ci	eg_pi->vddci_control =
26428c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
26438c2ecf20Sopenharmony_ci
26448c2ecf20Sopenharmony_ci	rv770_get_engine_memory_ss(rdev);
26458c2ecf20Sopenharmony_ci
26468c2ecf20Sopenharmony_ci	pi->asi = RV770_ASI_DFLT;
26478c2ecf20Sopenharmony_ci	pi->pasi = CYPRESS_HASI_DFLT;
26488c2ecf20Sopenharmony_ci	pi->vrc = CYPRESS_VRC_DFLT;
26498c2ecf20Sopenharmony_ci
26508c2ecf20Sopenharmony_ci	pi->power_gating = false;
26518c2ecf20Sopenharmony_ci
26528c2ecf20Sopenharmony_ci	pi->gfx_clock_gating = true;
26538c2ecf20Sopenharmony_ci
26548c2ecf20Sopenharmony_ci	pi->mg_clock_gating = true;
26558c2ecf20Sopenharmony_ci	pi->mgcgtssm = true;
26568c2ecf20Sopenharmony_ci	eg_pi->ls_clock_gating = false;
26578c2ecf20Sopenharmony_ci	eg_pi->sclk_deep_sleep = false;
26588c2ecf20Sopenharmony_ci
26598c2ecf20Sopenharmony_ci	pi->dynamic_pcie_gen2 = true;
26608c2ecf20Sopenharmony_ci
26618c2ecf20Sopenharmony_ci	if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
26628c2ecf20Sopenharmony_ci		pi->thermal_protection = true;
26638c2ecf20Sopenharmony_ci	else
26648c2ecf20Sopenharmony_ci		pi->thermal_protection = false;
26658c2ecf20Sopenharmony_ci
26668c2ecf20Sopenharmony_ci	pi->display_gap = true;
26678c2ecf20Sopenharmony_ci
26688c2ecf20Sopenharmony_ci	if (rdev->flags & RADEON_IS_MOBILITY)
26698c2ecf20Sopenharmony_ci		pi->dcodt = true;
26708c2ecf20Sopenharmony_ci	else
26718c2ecf20Sopenharmony_ci		pi->dcodt = false;
26728c2ecf20Sopenharmony_ci
26738c2ecf20Sopenharmony_ci	pi->ulps = true;
26748c2ecf20Sopenharmony_ci
26758c2ecf20Sopenharmony_ci	eg_pi->dynamic_ac_timing = true;
26768c2ecf20Sopenharmony_ci	eg_pi->abm = true;
26778c2ecf20Sopenharmony_ci	eg_pi->mcls = true;
26788c2ecf20Sopenharmony_ci	eg_pi->light_sleep = true;
26798c2ecf20Sopenharmony_ci	eg_pi->memory_transition = true;
26808c2ecf20Sopenharmony_ci#if defined(CONFIG_ACPI)
26818c2ecf20Sopenharmony_ci	eg_pi->pcie_performance_request =
26828c2ecf20Sopenharmony_ci		radeon_acpi_is_pcie_performance_request_supported(rdev);
26838c2ecf20Sopenharmony_ci#else
26848c2ecf20Sopenharmony_ci	eg_pi->pcie_performance_request = false;
26858c2ecf20Sopenharmony_ci#endif
26868c2ecf20Sopenharmony_ci
26878c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_BARTS)
26888c2ecf20Sopenharmony_ci		eg_pi->dll_default_on = true;
26898c2ecf20Sopenharmony_ci	else
26908c2ecf20Sopenharmony_ci		eg_pi->dll_default_on = false;
26918c2ecf20Sopenharmony_ci
26928c2ecf20Sopenharmony_ci	eg_pi->sclk_deep_sleep = false;
26938c2ecf20Sopenharmony_ci	if (ASIC_IS_LOMBOK(rdev))
26948c2ecf20Sopenharmony_ci		pi->mclk_stutter_mode_threshold = 30000;
26958c2ecf20Sopenharmony_ci	else
26968c2ecf20Sopenharmony_ci		pi->mclk_stutter_mode_threshold = 0;
26978c2ecf20Sopenharmony_ci
26988c2ecf20Sopenharmony_ci	pi->sram_end = SMC_RAM_END;
26998c2ecf20Sopenharmony_ci
27008c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
27018c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
27028c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2 = 900;
27038c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_sclk_values.count = ARRAY_SIZE(btc_valid_sclk);
27048c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_sclk_values.values = btc_valid_sclk;
27058c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
27068c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
27078c2ecf20Sopenharmony_ci
27088c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_TURKS)
27098c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
27108c2ecf20Sopenharmony_ci	else
27118c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.sclk_mclk_delta = 10000;
27128c2ecf20Sopenharmony_ci
27138c2ecf20Sopenharmony_ci	/* make sure dc limits are valid */
27148c2ecf20Sopenharmony_ci	if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
27158c2ecf20Sopenharmony_ci	    (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
27168c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
27178c2ecf20Sopenharmony_ci			rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
27188c2ecf20Sopenharmony_ci
27198c2ecf20Sopenharmony_ci	return 0;
27208c2ecf20Sopenharmony_ci}
27218c2ecf20Sopenharmony_ci
27228c2ecf20Sopenharmony_civoid btc_dpm_fini(struct radeon_device *rdev)
27238c2ecf20Sopenharmony_ci{
27248c2ecf20Sopenharmony_ci	int i;
27258c2ecf20Sopenharmony_ci
27268c2ecf20Sopenharmony_ci	for (i = 0; i < rdev->pm.dpm.num_ps; i++) {
27278c2ecf20Sopenharmony_ci		kfree(rdev->pm.dpm.ps[i].ps_priv);
27288c2ecf20Sopenharmony_ci	}
27298c2ecf20Sopenharmony_ci	kfree(rdev->pm.dpm.ps);
27308c2ecf20Sopenharmony_ci	kfree(rdev->pm.dpm.priv);
27318c2ecf20Sopenharmony_ci	kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
27328c2ecf20Sopenharmony_ci	r600_free_extended_power_table(rdev);
27338c2ecf20Sopenharmony_ci}
27348c2ecf20Sopenharmony_ci
27358c2ecf20Sopenharmony_civoid btc_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
27368c2ecf20Sopenharmony_ci						     struct seq_file *m)
27378c2ecf20Sopenharmony_ci{
27388c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
27398c2ecf20Sopenharmony_ci	struct radeon_ps *rps = &eg_pi->current_rps;
27408c2ecf20Sopenharmony_ci	struct rv7xx_ps *ps = rv770_get_ps(rps);
27418c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
27428c2ecf20Sopenharmony_ci	u32 current_index =
27438c2ecf20Sopenharmony_ci		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
27448c2ecf20Sopenharmony_ci		CURRENT_PROFILE_INDEX_SHIFT;
27458c2ecf20Sopenharmony_ci
27468c2ecf20Sopenharmony_ci	if (current_index > 2) {
27478c2ecf20Sopenharmony_ci		seq_printf(m, "invalid dpm profile %d\n", current_index);
27488c2ecf20Sopenharmony_ci	} else {
27498c2ecf20Sopenharmony_ci		if (current_index == 0)
27508c2ecf20Sopenharmony_ci			pl = &ps->low;
27518c2ecf20Sopenharmony_ci		else if (current_index == 1)
27528c2ecf20Sopenharmony_ci			pl = &ps->medium;
27538c2ecf20Sopenharmony_ci		else /* current_index == 2 */
27548c2ecf20Sopenharmony_ci			pl = &ps->high;
27558c2ecf20Sopenharmony_ci		seq_printf(m, "uvd    vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
27568c2ecf20Sopenharmony_ci		seq_printf(m, "power level %d    sclk: %u mclk: %u vddc: %u vddci: %u\n",
27578c2ecf20Sopenharmony_ci			   current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci);
27588c2ecf20Sopenharmony_ci	}
27598c2ecf20Sopenharmony_ci}
27608c2ecf20Sopenharmony_ci
27618c2ecf20Sopenharmony_ciu32 btc_dpm_get_current_sclk(struct radeon_device *rdev)
27628c2ecf20Sopenharmony_ci{
27638c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
27648c2ecf20Sopenharmony_ci	struct radeon_ps *rps = &eg_pi->current_rps;
27658c2ecf20Sopenharmony_ci	struct rv7xx_ps *ps = rv770_get_ps(rps);
27668c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
27678c2ecf20Sopenharmony_ci	u32 current_index =
27688c2ecf20Sopenharmony_ci		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
27698c2ecf20Sopenharmony_ci		CURRENT_PROFILE_INDEX_SHIFT;
27708c2ecf20Sopenharmony_ci
27718c2ecf20Sopenharmony_ci	if (current_index > 2) {
27728c2ecf20Sopenharmony_ci		return 0;
27738c2ecf20Sopenharmony_ci	} else {
27748c2ecf20Sopenharmony_ci		if (current_index == 0)
27758c2ecf20Sopenharmony_ci			pl = &ps->low;
27768c2ecf20Sopenharmony_ci		else if (current_index == 1)
27778c2ecf20Sopenharmony_ci			pl = &ps->medium;
27788c2ecf20Sopenharmony_ci		else /* current_index == 2 */
27798c2ecf20Sopenharmony_ci			pl = &ps->high;
27808c2ecf20Sopenharmony_ci		return pl->sclk;
27818c2ecf20Sopenharmony_ci	}
27828c2ecf20Sopenharmony_ci}
27838c2ecf20Sopenharmony_ci
27848c2ecf20Sopenharmony_ciu32 btc_dpm_get_current_mclk(struct radeon_device *rdev)
27858c2ecf20Sopenharmony_ci{
27868c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
27878c2ecf20Sopenharmony_ci	struct radeon_ps *rps = &eg_pi->current_rps;
27888c2ecf20Sopenharmony_ci	struct rv7xx_ps *ps = rv770_get_ps(rps);
27898c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
27908c2ecf20Sopenharmony_ci	u32 current_index =
27918c2ecf20Sopenharmony_ci		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
27928c2ecf20Sopenharmony_ci		CURRENT_PROFILE_INDEX_SHIFT;
27938c2ecf20Sopenharmony_ci
27948c2ecf20Sopenharmony_ci	if (current_index > 2) {
27958c2ecf20Sopenharmony_ci		return 0;
27968c2ecf20Sopenharmony_ci	} else {
27978c2ecf20Sopenharmony_ci		if (current_index == 0)
27988c2ecf20Sopenharmony_ci			pl = &ps->low;
27998c2ecf20Sopenharmony_ci		else if (current_index == 1)
28008c2ecf20Sopenharmony_ci			pl = &ps->medium;
28018c2ecf20Sopenharmony_ci		else /* current_index == 2 */
28028c2ecf20Sopenharmony_ci			pl = &ps->high;
28038c2ecf20Sopenharmony_ci		return pl->mclk;
28048c2ecf20Sopenharmony_ci	}
28058c2ecf20Sopenharmony_ci}
28068c2ecf20Sopenharmony_ci
28078c2ecf20Sopenharmony_ciu32 btc_dpm_get_sclk(struct radeon_device *rdev, bool low)
28088c2ecf20Sopenharmony_ci{
28098c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
28108c2ecf20Sopenharmony_ci	struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps);
28118c2ecf20Sopenharmony_ci
28128c2ecf20Sopenharmony_ci	if (low)
28138c2ecf20Sopenharmony_ci		return requested_state->low.sclk;
28148c2ecf20Sopenharmony_ci	else
28158c2ecf20Sopenharmony_ci		return requested_state->high.sclk;
28168c2ecf20Sopenharmony_ci}
28178c2ecf20Sopenharmony_ci
28188c2ecf20Sopenharmony_ciu32 btc_dpm_get_mclk(struct radeon_device *rdev, bool low)
28198c2ecf20Sopenharmony_ci{
28208c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
28218c2ecf20Sopenharmony_ci	struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps);
28228c2ecf20Sopenharmony_ci
28238c2ecf20Sopenharmony_ci	if (low)
28248c2ecf20Sopenharmony_ci		return requested_state->low.mclk;
28258c2ecf20Sopenharmony_ci	else
28268c2ecf20Sopenharmony_ci		return requested_state->high.mclk;
28278c2ecf20Sopenharmony_ci}
2828