18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2013 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 */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <linux/math64.h>
258c2ecf20Sopenharmony_ci#include <linux/pci.h>
268c2ecf20Sopenharmony_ci#include <linux/seq_file.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include "atom.h"
298c2ecf20Sopenharmony_ci#include "r600_dpm.h"
308c2ecf20Sopenharmony_ci#include "radeon.h"
318c2ecf20Sopenharmony_ci#include "radeon_asic.h"
328c2ecf20Sopenharmony_ci#include "si_dpm.h"
338c2ecf20Sopenharmony_ci#include "sid.h"
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F0           0x0a
368c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F1           0x0b
378c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F2           0x0c
388c2ecf20Sopenharmony_ci#define MC_CG_ARB_FREQ_F3           0x0d
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define SMC_RAM_END                 0x20000
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define SCLK_MIN_DEEPSLEEP_FREQ     1350
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_tahiti[] =
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0xc, SISLANDS_CACCONFIG_CGIND },
478c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
488c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x101, SISLANDS_CACCONFIG_CGIND },
498c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0xc, SISLANDS_CACCONFIG_CGIND },
508c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
518c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
528c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
538c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
548c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
558c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x8fc, SISLANDS_CACCONFIG_CGIND },
568c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
578c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x95, SISLANDS_CACCONFIG_CGIND },
588c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x34e, SISLANDS_CACCONFIG_CGIND },
598c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x1a1, SISLANDS_CACCONFIG_CGIND },
608c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0xda, SISLANDS_CACCONFIG_CGIND },
618c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
628c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
638c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x46, SISLANDS_CACCONFIG_CGIND },
648c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
658c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x208, SISLANDS_CACCONFIG_CGIND },
668c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0xe7, SISLANDS_CACCONFIG_CGIND },
678c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x948, SISLANDS_CACCONFIG_CGIND },
688c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
698c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
708c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
718c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
728c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
738c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
748c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
758c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
768c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x167, SISLANDS_CACCONFIG_CGIND },
778c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
788c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
798c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
808c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
818c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
828c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
838c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
848c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
858c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x31, SISLANDS_CACCONFIG_CGIND },
868c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
878c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
888c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
898c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
908c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
918c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
928c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
938c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
948c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
958c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
968c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
978c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
988c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
998c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1008c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1018c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1028c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1038c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1048c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1058c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x18e, SISLANDS_CACCONFIG_CGIND },
1068c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
1078c2ecf20Sopenharmony_ci};
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg lcac_tahiti[] =
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	{ 0x143, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
1128c2ecf20Sopenharmony_ci	{ 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1138c2ecf20Sopenharmony_ci	{ 0x146, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
1148c2ecf20Sopenharmony_ci	{ 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1158c2ecf20Sopenharmony_ci	{ 0x149, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
1168c2ecf20Sopenharmony_ci	{ 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1178c2ecf20Sopenharmony_ci	{ 0x14c, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
1188c2ecf20Sopenharmony_ci	{ 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1198c2ecf20Sopenharmony_ci	{ 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1208c2ecf20Sopenharmony_ci	{ 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1218c2ecf20Sopenharmony_ci	{ 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1228c2ecf20Sopenharmony_ci	{ 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1238c2ecf20Sopenharmony_ci	{ 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1248c2ecf20Sopenharmony_ci	{ 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1258c2ecf20Sopenharmony_ci	{ 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1268c2ecf20Sopenharmony_ci	{ 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1278c2ecf20Sopenharmony_ci	{ 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1288c2ecf20Sopenharmony_ci	{ 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1298c2ecf20Sopenharmony_ci	{ 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1308c2ecf20Sopenharmony_ci	{ 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1318c2ecf20Sopenharmony_ci	{ 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1328c2ecf20Sopenharmony_ci	{ 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1338c2ecf20Sopenharmony_ci	{ 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1348c2ecf20Sopenharmony_ci	{ 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1358c2ecf20Sopenharmony_ci	{ 0x8c, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1368c2ecf20Sopenharmony_ci	{ 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1378c2ecf20Sopenharmony_ci	{ 0x8f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1388c2ecf20Sopenharmony_ci	{ 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1398c2ecf20Sopenharmony_ci	{ 0x92, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1408c2ecf20Sopenharmony_ci	{ 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1418c2ecf20Sopenharmony_ci	{ 0x95, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1428c2ecf20Sopenharmony_ci	{ 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1438c2ecf20Sopenharmony_ci	{ 0x14f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1448c2ecf20Sopenharmony_ci	{ 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1458c2ecf20Sopenharmony_ci	{ 0x152, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1468c2ecf20Sopenharmony_ci	{ 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1478c2ecf20Sopenharmony_ci	{ 0x155, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1488c2ecf20Sopenharmony_ci	{ 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1498c2ecf20Sopenharmony_ci	{ 0x158, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1508c2ecf20Sopenharmony_ci	{ 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1518c2ecf20Sopenharmony_ci	{ 0x110, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1528c2ecf20Sopenharmony_ci	{ 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1538c2ecf20Sopenharmony_ci	{ 0x113, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1548c2ecf20Sopenharmony_ci	{ 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1558c2ecf20Sopenharmony_ci	{ 0x116, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1568c2ecf20Sopenharmony_ci	{ 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1578c2ecf20Sopenharmony_ci	{ 0x119, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
1588c2ecf20Sopenharmony_ci	{ 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1598c2ecf20Sopenharmony_ci	{ 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1608c2ecf20Sopenharmony_ci	{ 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1618c2ecf20Sopenharmony_ci	{ 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1628c2ecf20Sopenharmony_ci	{ 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1638c2ecf20Sopenharmony_ci	{ 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1648c2ecf20Sopenharmony_ci	{ 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1658c2ecf20Sopenharmony_ci	{ 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1668c2ecf20Sopenharmony_ci	{ 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1678c2ecf20Sopenharmony_ci	{ 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1688c2ecf20Sopenharmony_ci	{ 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1698c2ecf20Sopenharmony_ci	{ 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1708c2ecf20Sopenharmony_ci	{ 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1718c2ecf20Sopenharmony_ci	{ 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1728c2ecf20Sopenharmony_ci	{ 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1738c2ecf20Sopenharmony_ci	{ 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1748c2ecf20Sopenharmony_ci	{ 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1758c2ecf20Sopenharmony_ci	{ 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1768c2ecf20Sopenharmony_ci	{ 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1778c2ecf20Sopenharmony_ci	{ 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1788c2ecf20Sopenharmony_ci	{ 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1798c2ecf20Sopenharmony_ci	{ 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1808c2ecf20Sopenharmony_ci	{ 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1818c2ecf20Sopenharmony_ci	{ 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1828c2ecf20Sopenharmony_ci	{ 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1838c2ecf20Sopenharmony_ci	{ 0x16d, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1848c2ecf20Sopenharmony_ci	{ 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1858c2ecf20Sopenharmony_ci	{ 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1868c2ecf20Sopenharmony_ci	{ 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1878c2ecf20Sopenharmony_ci	{ 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1888c2ecf20Sopenharmony_ci	{ 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1898c2ecf20Sopenharmony_ci	{ 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1908c2ecf20Sopenharmony_ci	{ 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1918c2ecf20Sopenharmony_ci	{ 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1928c2ecf20Sopenharmony_ci	{ 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1938c2ecf20Sopenharmony_ci	{ 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1948c2ecf20Sopenharmony_ci	{ 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1958c2ecf20Sopenharmony_ci	{ 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1968c2ecf20Sopenharmony_ci	{ 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1978c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci};
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_override_tahiti[] =
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
2048c2ecf20Sopenharmony_ci};
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cistatic const struct si_powertune_data powertune_data_tahiti =
2078c2ecf20Sopenharmony_ci{
2088c2ecf20Sopenharmony_ci	((1 << 16) | 27027),
2098c2ecf20Sopenharmony_ci	6,
2108c2ecf20Sopenharmony_ci	0,
2118c2ecf20Sopenharmony_ci	4,
2128c2ecf20Sopenharmony_ci	95,
2138c2ecf20Sopenharmony_ci	{
2148c2ecf20Sopenharmony_ci		0UL,
2158c2ecf20Sopenharmony_ci		0UL,
2168c2ecf20Sopenharmony_ci		4521550UL,
2178c2ecf20Sopenharmony_ci		309631529UL,
2188c2ecf20Sopenharmony_ci		-1270850L,
2198c2ecf20Sopenharmony_ci		4513710L,
2208c2ecf20Sopenharmony_ci		40
2218c2ecf20Sopenharmony_ci	},
2228c2ecf20Sopenharmony_ci	595000000UL,
2238c2ecf20Sopenharmony_ci	12,
2248c2ecf20Sopenharmony_ci	{
2258c2ecf20Sopenharmony_ci		0,
2268c2ecf20Sopenharmony_ci		0,
2278c2ecf20Sopenharmony_ci		0,
2288c2ecf20Sopenharmony_ci		0,
2298c2ecf20Sopenharmony_ci		0,
2308c2ecf20Sopenharmony_ci		0,
2318c2ecf20Sopenharmony_ci		0,
2328c2ecf20Sopenharmony_ci		0
2338c2ecf20Sopenharmony_ci	},
2348c2ecf20Sopenharmony_ci	true
2358c2ecf20Sopenharmony_ci};
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_tahiti =
2388c2ecf20Sopenharmony_ci{
2398c2ecf20Sopenharmony_ci	{ 1159409, 0, 0, 0, 0 },
2408c2ecf20Sopenharmony_ci	{ 777, 0, 0, 0, 0 },
2418c2ecf20Sopenharmony_ci	2,
2428c2ecf20Sopenharmony_ci	54000,
2438c2ecf20Sopenharmony_ci	127000,
2448c2ecf20Sopenharmony_ci	25,
2458c2ecf20Sopenharmony_ci	2,
2468c2ecf20Sopenharmony_ci	10,
2478c2ecf20Sopenharmony_ci	13,
2488c2ecf20Sopenharmony_ci	{ 27, 31, 35, 39, 43, 47, 54, 61, 67, 74, 81, 88, 95, 0, 0, 0 },
2498c2ecf20Sopenharmony_ci	{ 240888759, 221057860, 235370597, 162287531, 158510299, 131423027, 116673180, 103067515, 87941937, 76209048, 68209175, 64090048, 58301890, 0, 0, 0 },
2508c2ecf20Sopenharmony_ci	{ 12024, 11189, 11451, 8411, 7939, 6666, 5681, 4905, 4241, 3720, 3354, 3122, 2890, 0, 0, 0 },
2518c2ecf20Sopenharmony_ci	85,
2528c2ecf20Sopenharmony_ci	false
2538c2ecf20Sopenharmony_ci};
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_tahiti_pro =
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
2588c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
2598c2ecf20Sopenharmony_ci	5,
2608c2ecf20Sopenharmony_ci	45000,
2618c2ecf20Sopenharmony_ci	100,
2628c2ecf20Sopenharmony_ci	0xA,
2638c2ecf20Sopenharmony_ci	1,
2648c2ecf20Sopenharmony_ci	0,
2658c2ecf20Sopenharmony_ci	0x10,
2668c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
2678c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
2688c2ecf20Sopenharmony_ci	{ 0x7D0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
2698c2ecf20Sopenharmony_ci	90,
2708c2ecf20Sopenharmony_ci	true
2718c2ecf20Sopenharmony_ci};
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_new_zealand =
2748c2ecf20Sopenharmony_ci{
2758c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0 },
2768c2ecf20Sopenharmony_ci	{ 0x29B, 0x3E9, 0x537, 0x7D2, 0 },
2778c2ecf20Sopenharmony_ci	0x5,
2788c2ecf20Sopenharmony_ci	0xAFC8,
2798c2ecf20Sopenharmony_ci	0x69,
2808c2ecf20Sopenharmony_ci	0x32,
2818c2ecf20Sopenharmony_ci	1,
2828c2ecf20Sopenharmony_ci	0,
2838c2ecf20Sopenharmony_ci	0x10,
2848c2ecf20Sopenharmony_ci	{ 0x82, 0xA0, 0xB4, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE },
2858c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
2868c2ecf20Sopenharmony_ci	{ 0xDAC, 0x1388, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685 },
2878c2ecf20Sopenharmony_ci	85,
2888c2ecf20Sopenharmony_ci	true
2898c2ecf20Sopenharmony_ci};
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_aruba_pro =
2928c2ecf20Sopenharmony_ci{
2938c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
2948c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
2958c2ecf20Sopenharmony_ci	5,
2968c2ecf20Sopenharmony_ci	45000,
2978c2ecf20Sopenharmony_ci	100,
2988c2ecf20Sopenharmony_ci	0xA,
2998c2ecf20Sopenharmony_ci	1,
3008c2ecf20Sopenharmony_ci	0,
3018c2ecf20Sopenharmony_ci	0x10,
3028c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
3038c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
3048c2ecf20Sopenharmony_ci	{ 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
3058c2ecf20Sopenharmony_ci	90,
3068c2ecf20Sopenharmony_ci	true
3078c2ecf20Sopenharmony_ci};
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_malta =
3108c2ecf20Sopenharmony_ci{
3118c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
3128c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
3138c2ecf20Sopenharmony_ci	5,
3148c2ecf20Sopenharmony_ci	45000,
3158c2ecf20Sopenharmony_ci	100,
3168c2ecf20Sopenharmony_ci	0xA,
3178c2ecf20Sopenharmony_ci	1,
3188c2ecf20Sopenharmony_ci	0,
3198c2ecf20Sopenharmony_ci	0x10,
3208c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
3218c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
3228c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
3238c2ecf20Sopenharmony_ci	90,
3248c2ecf20Sopenharmony_ci	true
3258c2ecf20Sopenharmony_ci};
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_cistruct si_cac_config_reg cac_weights_pitcairn[] =
3288c2ecf20Sopenharmony_ci{
3298c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x8a, SISLANDS_CACCONFIG_CGIND },
3308c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3318c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3328c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x24d, SISLANDS_CACCONFIG_CGIND },
3338c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x19, SISLANDS_CACCONFIG_CGIND },
3348c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
3358c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3368c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
3378c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3388c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0xc11, SISLANDS_CACCONFIG_CGIND },
3398c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x7f3, SISLANDS_CACCONFIG_CGIND },
3408c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x403, SISLANDS_CACCONFIG_CGIND },
3418c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x367, SISLANDS_CACCONFIG_CGIND },
3428c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x4c9, SISLANDS_CACCONFIG_CGIND },
3438c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3448c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3458c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3468c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x45d, SISLANDS_CACCONFIG_CGIND },
3478c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x36d, SISLANDS_CACCONFIG_CGIND },
3488c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x534, SISLANDS_CACCONFIG_CGIND },
3498c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x5da, SISLANDS_CACCONFIG_CGIND },
3508c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x880, SISLANDS_CACCONFIG_CGIND },
3518c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0x201, SISLANDS_CACCONFIG_CGIND },
3528c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3538c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3548c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
3558c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x1f, SISLANDS_CACCONFIG_CGIND },
3568c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3578c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3588c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3598c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5de, SISLANDS_CACCONFIG_CGIND },
3608c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3618c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x7b, SISLANDS_CACCONFIG_CGIND },
3628c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3638c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x13, SISLANDS_CACCONFIG_CGIND },
3648c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0xf9, SISLANDS_CACCONFIG_CGIND },
3658c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x66, SISLANDS_CACCONFIG_CGIND },
3668c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3678c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x13, SISLANDS_CACCONFIG_CGIND },
3688c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3698c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3708c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3718c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3728c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3738c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3748c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3758c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3768c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3778c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3788c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3798c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3808c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3818c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3828c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3838c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3848c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3858c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3868c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
3878c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
3888c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x186, SISLANDS_CACCONFIG_CGIND },
3898c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
3908c2ecf20Sopenharmony_ci};
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg lcac_pitcairn[] =
3938c2ecf20Sopenharmony_ci{
3948c2ecf20Sopenharmony_ci	{ 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
3958c2ecf20Sopenharmony_ci	{ 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
3968c2ecf20Sopenharmony_ci	{ 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
3978c2ecf20Sopenharmony_ci	{ 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
3988c2ecf20Sopenharmony_ci	{ 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
3998c2ecf20Sopenharmony_ci	{ 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4008c2ecf20Sopenharmony_ci	{ 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4018c2ecf20Sopenharmony_ci	{ 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4028c2ecf20Sopenharmony_ci	{ 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4038c2ecf20Sopenharmony_ci	{ 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4048c2ecf20Sopenharmony_ci	{ 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4058c2ecf20Sopenharmony_ci	{ 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4068c2ecf20Sopenharmony_ci	{ 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4078c2ecf20Sopenharmony_ci	{ 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4088c2ecf20Sopenharmony_ci	{ 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4098c2ecf20Sopenharmony_ci	{ 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4108c2ecf20Sopenharmony_ci	{ 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4118c2ecf20Sopenharmony_ci	{ 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4128c2ecf20Sopenharmony_ci	{ 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4138c2ecf20Sopenharmony_ci	{ 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4148c2ecf20Sopenharmony_ci	{ 0x8f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4158c2ecf20Sopenharmony_ci	{ 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4168c2ecf20Sopenharmony_ci	{ 0x146, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4178c2ecf20Sopenharmony_ci	{ 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4188c2ecf20Sopenharmony_ci	{ 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4198c2ecf20Sopenharmony_ci	{ 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4208c2ecf20Sopenharmony_ci	{ 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4218c2ecf20Sopenharmony_ci	{ 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4228c2ecf20Sopenharmony_ci	{ 0x116, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4238c2ecf20Sopenharmony_ci	{ 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4248c2ecf20Sopenharmony_ci	{ 0x155, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4258c2ecf20Sopenharmony_ci	{ 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4268c2ecf20Sopenharmony_ci	{ 0x92, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4278c2ecf20Sopenharmony_ci	{ 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4288c2ecf20Sopenharmony_ci	{ 0x149, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4298c2ecf20Sopenharmony_ci	{ 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4308c2ecf20Sopenharmony_ci	{ 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4318c2ecf20Sopenharmony_ci	{ 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4328c2ecf20Sopenharmony_ci	{ 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4338c2ecf20Sopenharmony_ci	{ 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4348c2ecf20Sopenharmony_ci	{ 0x119, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4358c2ecf20Sopenharmony_ci	{ 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4368c2ecf20Sopenharmony_ci	{ 0x158, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4378c2ecf20Sopenharmony_ci	{ 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4388c2ecf20Sopenharmony_ci	{ 0x95, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
4398c2ecf20Sopenharmony_ci	{ 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4408c2ecf20Sopenharmony_ci	{ 0x14c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4418c2ecf20Sopenharmony_ci	{ 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4428c2ecf20Sopenharmony_ci	{ 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4438c2ecf20Sopenharmony_ci	{ 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4448c2ecf20Sopenharmony_ci	{ 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4458c2ecf20Sopenharmony_ci	{ 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4468c2ecf20Sopenharmony_ci	{ 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4478c2ecf20Sopenharmony_ci	{ 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4488c2ecf20Sopenharmony_ci	{ 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4498c2ecf20Sopenharmony_ci	{ 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4508c2ecf20Sopenharmony_ci	{ 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4518c2ecf20Sopenharmony_ci	{ 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4528c2ecf20Sopenharmony_ci	{ 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4538c2ecf20Sopenharmony_ci	{ 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4548c2ecf20Sopenharmony_ci	{ 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4558c2ecf20Sopenharmony_ci	{ 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4568c2ecf20Sopenharmony_ci	{ 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4578c2ecf20Sopenharmony_ci	{ 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4588c2ecf20Sopenharmony_ci	{ 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4598c2ecf20Sopenharmony_ci	{ 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4608c2ecf20Sopenharmony_ci	{ 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4618c2ecf20Sopenharmony_ci	{ 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4628c2ecf20Sopenharmony_ci	{ 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4638c2ecf20Sopenharmony_ci	{ 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4648c2ecf20Sopenharmony_ci	{ 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4658c2ecf20Sopenharmony_ci	{ 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4668c2ecf20Sopenharmony_ci	{ 0x16d, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
4678c2ecf20Sopenharmony_ci	{ 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4688c2ecf20Sopenharmony_ci	{ 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4698c2ecf20Sopenharmony_ci	{ 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4708c2ecf20Sopenharmony_ci	{ 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4718c2ecf20Sopenharmony_ci	{ 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4728c2ecf20Sopenharmony_ci	{ 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4738c2ecf20Sopenharmony_ci	{ 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4748c2ecf20Sopenharmony_ci	{ 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4758c2ecf20Sopenharmony_ci	{ 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4768c2ecf20Sopenharmony_ci	{ 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4778c2ecf20Sopenharmony_ci	{ 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4788c2ecf20Sopenharmony_ci	{ 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
4798c2ecf20Sopenharmony_ci	{ 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
4808c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
4818c2ecf20Sopenharmony_ci};
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_override_pitcairn[] =
4848c2ecf20Sopenharmony_ci{
4858c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
4868c2ecf20Sopenharmony_ci};
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_cistatic const struct si_powertune_data powertune_data_pitcairn =
4898c2ecf20Sopenharmony_ci{
4908c2ecf20Sopenharmony_ci	((1 << 16) | 27027),
4918c2ecf20Sopenharmony_ci	5,
4928c2ecf20Sopenharmony_ci	0,
4938c2ecf20Sopenharmony_ci	6,
4948c2ecf20Sopenharmony_ci	100,
4958c2ecf20Sopenharmony_ci	{
4968c2ecf20Sopenharmony_ci		51600000UL,
4978c2ecf20Sopenharmony_ci		1800000UL,
4988c2ecf20Sopenharmony_ci		7194395UL,
4998c2ecf20Sopenharmony_ci		309631529UL,
5008c2ecf20Sopenharmony_ci		-1270850L,
5018c2ecf20Sopenharmony_ci		4513710L,
5028c2ecf20Sopenharmony_ci		100
5038c2ecf20Sopenharmony_ci	},
5048c2ecf20Sopenharmony_ci	117830498UL,
5058c2ecf20Sopenharmony_ci	12,
5068c2ecf20Sopenharmony_ci	{
5078c2ecf20Sopenharmony_ci		0,
5088c2ecf20Sopenharmony_ci		0,
5098c2ecf20Sopenharmony_ci		0,
5108c2ecf20Sopenharmony_ci		0,
5118c2ecf20Sopenharmony_ci		0,
5128c2ecf20Sopenharmony_ci		0,
5138c2ecf20Sopenharmony_ci		0,
5148c2ecf20Sopenharmony_ci		0
5158c2ecf20Sopenharmony_ci	},
5168c2ecf20Sopenharmony_ci	true
5178c2ecf20Sopenharmony_ci};
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_pitcairn =
5208c2ecf20Sopenharmony_ci{
5218c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0 },
5228c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0 },
5238c2ecf20Sopenharmony_ci	0,
5248c2ecf20Sopenharmony_ci	0,
5258c2ecf20Sopenharmony_ci	0,
5268c2ecf20Sopenharmony_ci	0,
5278c2ecf20Sopenharmony_ci	0,
5288c2ecf20Sopenharmony_ci	0,
5298c2ecf20Sopenharmony_ci	0,
5308c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
5318c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
5328c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
5338c2ecf20Sopenharmony_ci	0,
5348c2ecf20Sopenharmony_ci	false
5358c2ecf20Sopenharmony_ci};
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_curacao_xt =
5388c2ecf20Sopenharmony_ci{
5398c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
5408c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
5418c2ecf20Sopenharmony_ci	5,
5428c2ecf20Sopenharmony_ci	45000,
5438c2ecf20Sopenharmony_ci	100,
5448c2ecf20Sopenharmony_ci	0xA,
5458c2ecf20Sopenharmony_ci	1,
5468c2ecf20Sopenharmony_ci	0,
5478c2ecf20Sopenharmony_ci	0x10,
5488c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
5498c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
5508c2ecf20Sopenharmony_ci	{ 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
5518c2ecf20Sopenharmony_ci	90,
5528c2ecf20Sopenharmony_ci	true
5538c2ecf20Sopenharmony_ci};
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_curacao_pro =
5568c2ecf20Sopenharmony_ci{
5578c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
5588c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
5598c2ecf20Sopenharmony_ci	5,
5608c2ecf20Sopenharmony_ci	45000,
5618c2ecf20Sopenharmony_ci	100,
5628c2ecf20Sopenharmony_ci	0xA,
5638c2ecf20Sopenharmony_ci	1,
5648c2ecf20Sopenharmony_ci	0,
5658c2ecf20Sopenharmony_ci	0x10,
5668c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
5678c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
5688c2ecf20Sopenharmony_ci	{ 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
5698c2ecf20Sopenharmony_ci	90,
5708c2ecf20Sopenharmony_ci	true
5718c2ecf20Sopenharmony_ci};
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_neptune_xt =
5748c2ecf20Sopenharmony_ci{
5758c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
5768c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
5778c2ecf20Sopenharmony_ci	5,
5788c2ecf20Sopenharmony_ci	45000,
5798c2ecf20Sopenharmony_ci	100,
5808c2ecf20Sopenharmony_ci	0xA,
5818c2ecf20Sopenharmony_ci	1,
5828c2ecf20Sopenharmony_ci	0,
5838c2ecf20Sopenharmony_ci	0x10,
5848c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
5858c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
5868c2ecf20Sopenharmony_ci	{ 0x3A2F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
5878c2ecf20Sopenharmony_ci	90,
5888c2ecf20Sopenharmony_ci	true
5898c2ecf20Sopenharmony_ci};
5908c2ecf20Sopenharmony_ci
5918c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_chelsea_pro[] =
5928c2ecf20Sopenharmony_ci{
5938c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
5948c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
5958c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
5968c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
5978c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
5988c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
5998c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
6008c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
6018c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
6028c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
6038c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
6048c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
6058c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
6068c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
6078c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
6088c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
6098c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
6108c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
6118c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
6128c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
6138c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
6148c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
6158c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
6168c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
6178c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
6188c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
6198c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
6208c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
6218c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
6228c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
6238c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
6248c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
6258c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
6268c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
6278c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
6288c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x2BD, SISLANDS_CACCONFIG_CGIND },
6298c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6308c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
6318c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6328c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
6338c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
6348c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6358c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6368c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
6378c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6388c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
6398c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6408c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
6418c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6428c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
6438c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6448c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
6458c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6468c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
6478c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6488c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
6498c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6508c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
6518c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
6528c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
6538c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
6548c2ecf20Sopenharmony_ci};
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_chelsea_xt[] =
6578c2ecf20Sopenharmony_ci{
6588c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
6598c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
6608c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
6618c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
6628c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6638c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
6648c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
6658c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
6668c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
6678c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
6688c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
6698c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
6708c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
6718c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
6728c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
6738c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
6748c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
6758c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
6768c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
6778c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
6788c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
6798c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
6808c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
6818c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
6828c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
6838c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
6848c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
6858c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
6868c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
6878c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
6888c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
6898c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
6908c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
6918c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
6928c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
6938c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x30A, SISLANDS_CACCONFIG_CGIND },
6948c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6958c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
6968c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
6978c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
6988c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
6998c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7008c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7018c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
7028c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7038c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
7048c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7058c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7068c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7078c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7088c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7098c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7108c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7118c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7128c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7138c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7148c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7158c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7168c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7178c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
7188c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
7198c2ecf20Sopenharmony_ci};
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_heathrow[] =
7228c2ecf20Sopenharmony_ci{
7238c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
7248c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
7258c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
7268c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
7278c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7288c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
7298c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
7308c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
7318c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
7328c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
7338c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
7348c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
7358c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
7368c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
7378c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
7388c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
7398c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
7408c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
7418c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
7428c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
7438c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
7448c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
7458c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
7468c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
7478c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
7488c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
7498c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
7508c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
7518c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
7528c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
7538c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
7548c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
7558c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
7568c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
7578c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
7588c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x362, SISLANDS_CACCONFIG_CGIND },
7598c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7608c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
7618c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7628c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
7638c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
7648c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7658c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7668c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
7678c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7688c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
7698c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7708c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7718c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7728c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7738c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7748c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7758c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7768c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7778c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7788c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7798c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7808c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
7818c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
7828c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
7838c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
7848c2ecf20Sopenharmony_ci};
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_cape_verde_pro[] =
7878c2ecf20Sopenharmony_ci{
7888c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
7898c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
7908c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
7918c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
7928c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
7938c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
7948c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
7958c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
7968c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
7978c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
7988c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
7998c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
8008c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
8018c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
8028c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
8038c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
8048c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
8058c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
8068c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
8078c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
8088c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
8098c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
8108c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
8118c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
8128c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
8138c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
8148c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
8158c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
8168c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
8178c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
8188c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
8198c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
8208c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
8218c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
8228c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
8238c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x315, SISLANDS_CACCONFIG_CGIND },
8248c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8258c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
8268c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8278c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
8288c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
8298c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8308c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8318c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
8328c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8338c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
8348c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8358c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
8368c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8378c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
8388c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8398c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
8408c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8418c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
8428c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8438c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
8448c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8458c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
8468c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
8478c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
8488c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
8498c2ecf20Sopenharmony_ci};
8508c2ecf20Sopenharmony_ci
8518c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_cape_verde[] =
8528c2ecf20Sopenharmony_ci{
8538c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
8548c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
8558c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
8568c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
8578c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8588c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
8598c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
8608c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
8618c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
8628c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
8638c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
8648c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
8658c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
8668c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
8678c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
8688c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
8698c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
8708c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
8718c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
8728c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
8738c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
8748c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
8758c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
8768c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
8778c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
8788c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
8798c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
8808c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
8818c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
8828c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
8838c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
8848c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
8858c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
8868c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
8878c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
8888c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
8898c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8908c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
8918c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8928c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
8938c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
8948c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8958c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8968c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
8978c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
8988c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
8998c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9008c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
9018c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9028c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
9038c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9048c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
9058c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9068c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
9078c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9088c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
9098c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9108c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
9118c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
9128c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
9138c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
9148c2ecf20Sopenharmony_ci};
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg lcac_cape_verde[] =
9178c2ecf20Sopenharmony_ci{
9188c2ecf20Sopenharmony_ci	{ 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9198c2ecf20Sopenharmony_ci	{ 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9208c2ecf20Sopenharmony_ci	{ 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9218c2ecf20Sopenharmony_ci	{ 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9228c2ecf20Sopenharmony_ci	{ 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
9238c2ecf20Sopenharmony_ci	{ 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9248c2ecf20Sopenharmony_ci	{ 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
9258c2ecf20Sopenharmony_ci	{ 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9268c2ecf20Sopenharmony_ci	{ 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
9278c2ecf20Sopenharmony_ci	{ 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9288c2ecf20Sopenharmony_ci	{ 0x143, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9298c2ecf20Sopenharmony_ci	{ 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9308c2ecf20Sopenharmony_ci	{ 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9318c2ecf20Sopenharmony_ci	{ 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9328c2ecf20Sopenharmony_ci	{ 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9338c2ecf20Sopenharmony_ci	{ 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9348c2ecf20Sopenharmony_ci	{ 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
9358c2ecf20Sopenharmony_ci	{ 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9368c2ecf20Sopenharmony_ci	{ 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
9378c2ecf20Sopenharmony_ci	{ 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9388c2ecf20Sopenharmony_ci	{ 0x8f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9398c2ecf20Sopenharmony_ci	{ 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9408c2ecf20Sopenharmony_ci	{ 0x146, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9418c2ecf20Sopenharmony_ci	{ 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9428c2ecf20Sopenharmony_ci	{ 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9438c2ecf20Sopenharmony_ci	{ 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9448c2ecf20Sopenharmony_ci	{ 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9458c2ecf20Sopenharmony_ci	{ 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9468c2ecf20Sopenharmony_ci	{ 0x164, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9478c2ecf20Sopenharmony_ci	{ 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9488c2ecf20Sopenharmony_ci	{ 0x167, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9498c2ecf20Sopenharmony_ci	{ 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9508c2ecf20Sopenharmony_ci	{ 0x16a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9518c2ecf20Sopenharmony_ci	{ 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9528c2ecf20Sopenharmony_ci	{ 0x15e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9538c2ecf20Sopenharmony_ci	{ 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9548c2ecf20Sopenharmony_ci	{ 0x161, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9558c2ecf20Sopenharmony_ci	{ 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9568c2ecf20Sopenharmony_ci	{ 0x15b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9578c2ecf20Sopenharmony_ci	{ 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9588c2ecf20Sopenharmony_ci	{ 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9598c2ecf20Sopenharmony_ci	{ 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9608c2ecf20Sopenharmony_ci	{ 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9618c2ecf20Sopenharmony_ci	{ 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9628c2ecf20Sopenharmony_ci	{ 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
9638c2ecf20Sopenharmony_ci	{ 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9648c2ecf20Sopenharmony_ci	{ 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9658c2ecf20Sopenharmony_ci	{ 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9668c2ecf20Sopenharmony_ci	{ 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9678c2ecf20Sopenharmony_ci	{ 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9688c2ecf20Sopenharmony_ci	{ 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9698c2ecf20Sopenharmony_ci	{ 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9708c2ecf20Sopenharmony_ci	{ 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
9718c2ecf20Sopenharmony_ci	{ 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
9728c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
9738c2ecf20Sopenharmony_ci};
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_override_cape_verde[] =
9768c2ecf20Sopenharmony_ci{
9778c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
9788c2ecf20Sopenharmony_ci};
9798c2ecf20Sopenharmony_ci
9808c2ecf20Sopenharmony_cistatic const struct si_powertune_data powertune_data_cape_verde =
9818c2ecf20Sopenharmony_ci{
9828c2ecf20Sopenharmony_ci	((1 << 16) | 0x6993),
9838c2ecf20Sopenharmony_ci	5,
9848c2ecf20Sopenharmony_ci	0,
9858c2ecf20Sopenharmony_ci	7,
9868c2ecf20Sopenharmony_ci	105,
9878c2ecf20Sopenharmony_ci	{
9888c2ecf20Sopenharmony_ci		0UL,
9898c2ecf20Sopenharmony_ci		0UL,
9908c2ecf20Sopenharmony_ci		7194395UL,
9918c2ecf20Sopenharmony_ci		309631529UL,
9928c2ecf20Sopenharmony_ci		-1270850L,
9938c2ecf20Sopenharmony_ci		4513710L,
9948c2ecf20Sopenharmony_ci		100
9958c2ecf20Sopenharmony_ci	},
9968c2ecf20Sopenharmony_ci	117830498UL,
9978c2ecf20Sopenharmony_ci	12,
9988c2ecf20Sopenharmony_ci	{
9998c2ecf20Sopenharmony_ci		0,
10008c2ecf20Sopenharmony_ci		0,
10018c2ecf20Sopenharmony_ci		0,
10028c2ecf20Sopenharmony_ci		0,
10038c2ecf20Sopenharmony_ci		0,
10048c2ecf20Sopenharmony_ci		0,
10058c2ecf20Sopenharmony_ci		0,
10068c2ecf20Sopenharmony_ci		0
10078c2ecf20Sopenharmony_ci	},
10088c2ecf20Sopenharmony_ci	true
10098c2ecf20Sopenharmony_ci};
10108c2ecf20Sopenharmony_ci
10118c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_cape_verde =
10128c2ecf20Sopenharmony_ci{
10138c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0 },
10148c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0 },
10158c2ecf20Sopenharmony_ci	0,
10168c2ecf20Sopenharmony_ci	0,
10178c2ecf20Sopenharmony_ci	0,
10188c2ecf20Sopenharmony_ci	0,
10198c2ecf20Sopenharmony_ci	0,
10208c2ecf20Sopenharmony_ci	0,
10218c2ecf20Sopenharmony_ci	0,
10228c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
10238c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
10248c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
10258c2ecf20Sopenharmony_ci	0,
10268c2ecf20Sopenharmony_ci	false
10278c2ecf20Sopenharmony_ci};
10288c2ecf20Sopenharmony_ci
10298c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_venus_xtx =
10308c2ecf20Sopenharmony_ci{
10318c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
10328c2ecf20Sopenharmony_ci	{ 0x71C, 0xAAB, 0xE39, 0x11C7, 0x0 },
10338c2ecf20Sopenharmony_ci	5,
10348c2ecf20Sopenharmony_ci	55000,
10358c2ecf20Sopenharmony_ci	0x69,
10368c2ecf20Sopenharmony_ci	0xA,
10378c2ecf20Sopenharmony_ci	1,
10388c2ecf20Sopenharmony_ci	0,
10398c2ecf20Sopenharmony_ci	0x3,
10408c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10418c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10428c2ecf20Sopenharmony_ci	{ 0xD6D8, 0x88B8, 0x1555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10438c2ecf20Sopenharmony_ci	90,
10448c2ecf20Sopenharmony_ci	true
10458c2ecf20Sopenharmony_ci};
10468c2ecf20Sopenharmony_ci
10478c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_venus_xt =
10488c2ecf20Sopenharmony_ci{
10498c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
10508c2ecf20Sopenharmony_ci	{ 0xBDA, 0x11C7, 0x17B4, 0x1DA1, 0x0 },
10518c2ecf20Sopenharmony_ci	5,
10528c2ecf20Sopenharmony_ci	55000,
10538c2ecf20Sopenharmony_ci	0x69,
10548c2ecf20Sopenharmony_ci	0xA,
10558c2ecf20Sopenharmony_ci	1,
10568c2ecf20Sopenharmony_ci	0,
10578c2ecf20Sopenharmony_ci	0x3,
10588c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10598c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10608c2ecf20Sopenharmony_ci	{ 0xAFC8, 0x88B8, 0x238E, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10618c2ecf20Sopenharmony_ci	90,
10628c2ecf20Sopenharmony_ci	true
10638c2ecf20Sopenharmony_ci};
10648c2ecf20Sopenharmony_ci
10658c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_venus_pro =
10668c2ecf20Sopenharmony_ci{
10678c2ecf20Sopenharmony_ci	{  0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
10688c2ecf20Sopenharmony_ci	{ 0x11C7, 0x1AAB, 0x238E, 0x2C72, 0x0 },
10698c2ecf20Sopenharmony_ci	5,
10708c2ecf20Sopenharmony_ci	55000,
10718c2ecf20Sopenharmony_ci	0x69,
10728c2ecf20Sopenharmony_ci	0xA,
10738c2ecf20Sopenharmony_ci	1,
10748c2ecf20Sopenharmony_ci	0,
10758c2ecf20Sopenharmony_ci	0x3,
10768c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10778c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10788c2ecf20Sopenharmony_ci	{ 0x88B8, 0x88B8, 0x3555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
10798c2ecf20Sopenharmony_ci	90,
10808c2ecf20Sopenharmony_ci	true
10818c2ecf20Sopenharmony_ci};
10828c2ecf20Sopenharmony_ci
10838c2ecf20Sopenharmony_cistruct si_cac_config_reg cac_weights_oland[] =
10848c2ecf20Sopenharmony_ci{
10858c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
10868c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
10878c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
10888c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
10898c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
10908c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
10918c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
10928c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
10938c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
10948c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
10958c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
10968c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
10978c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
10988c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
10998c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
11008c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
11018c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
11028c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
11038c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
11048c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
11058c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
11068c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
11078c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
11088c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
11098c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
11108c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
11118c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
11128c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
11138c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
11148c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
11158c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
11168c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
11178c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
11188c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
11198c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
11208c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
11218c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11228c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
11238c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11248c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
11258c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
11268c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11278c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11288c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
11298c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11308c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
11318c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11328c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
11338c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11348c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
11358c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11368c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
11378c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11388c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
11398c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11408c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
11418c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11428c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
11438c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
11448c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
11458c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
11468c2ecf20Sopenharmony_ci};
11478c2ecf20Sopenharmony_ci
11488c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_mars_pro[] =
11498c2ecf20Sopenharmony_ci{
11508c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
11518c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
11528c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
11538c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
11548c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11558c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
11568c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
11578c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
11588c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
11598c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
11608c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
11618c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
11628c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
11638c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
11648c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
11658c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
11668c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
11678c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
11688c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
11698c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
11708c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
11718c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
11728c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
11738c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
11748c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
11758c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
11768c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
11778c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
11788c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
11798c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
11808c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
11818c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
11828c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
11838c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
11848c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
11858c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x2, SISLANDS_CACCONFIG_CGIND },
11868c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11878c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
11888c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11898c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
11908c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
11918c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11928c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11938c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
11948c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11958c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
11968c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
11978c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
11988c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
11998c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
12008c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
12018c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
12028c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12038c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
12048c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
12058c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
12068c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
12078c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
12088c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
12098c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
12108c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
12118c2ecf20Sopenharmony_ci};
12128c2ecf20Sopenharmony_ci
12138c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_mars_xt[] =
12148c2ecf20Sopenharmony_ci{
12158c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
12168c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
12178c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
12188c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
12198c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12208c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
12218c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
12228c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
12238c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
12248c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
12258c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
12268c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
12278c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
12288c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
12298c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
12308c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
12318c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
12328c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
12338c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
12348c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
12358c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
12368c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
12378c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
12388c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
12398c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
12408c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
12418c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
12428c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
12438c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
12448c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
12458c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
12468c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
12478c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
12488c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
12498c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
12508c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x60, SISLANDS_CACCONFIG_CGIND },
12518c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12528c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
12538c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12548c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
12558c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
12568c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12578c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12588c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
12598c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12608c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
12618c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
12628c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
12638c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12648c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
12658c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
12668c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
12678c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12688c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
12698c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
12708c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
12718c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
12728c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
12738c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
12748c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
12758c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
12768c2ecf20Sopenharmony_ci};
12778c2ecf20Sopenharmony_ci
12788c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_oland_pro[] =
12798c2ecf20Sopenharmony_ci{
12808c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
12818c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
12828c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
12838c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
12848c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
12858c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
12868c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
12878c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
12888c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
12898c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
12908c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
12918c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
12928c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
12938c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
12948c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
12958c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
12968c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
12978c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
12988c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
12998c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
13008c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
13018c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
13028c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
13038c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
13048c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
13058c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
13068c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
13078c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
13088c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
13098c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
13108c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
13118c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
13128c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
13138c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
13148c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
13158c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x90, SISLANDS_CACCONFIG_CGIND },
13168c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13178c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
13188c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13198c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
13208c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
13218c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13228c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13238c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13248c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13258c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13268c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
13278c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
13288c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13298c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13308c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
13318c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
13328c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13338c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13348c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
13358c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
13368c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
13378c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
13388c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
13398c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
13408c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
13418c2ecf20Sopenharmony_ci};
13428c2ecf20Sopenharmony_ci
13438c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_oland_xt[] =
13448c2ecf20Sopenharmony_ci{
13458c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
13468c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
13478c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
13488c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
13498c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13508c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
13518c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
13528c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
13538c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
13548c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
13558c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
13568c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
13578c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
13588c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
13598c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
13608c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
13618c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
13628c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
13638c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
13648c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
13658c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
13668c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
13678c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
13688c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
13698c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
13708c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
13718c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
13728c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
13738c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
13748c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
13758c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
13768c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
13778c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
13788c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
13798c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
13808c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x120, SISLANDS_CACCONFIG_CGIND },
13818c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13828c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
13838c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13848c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
13858c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
13868c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13878c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13888c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13898c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13908c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13918c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
13928c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
13938c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13948c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13958c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
13968c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
13978c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
13988c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
13998c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
14008c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
14018c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
14028c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
14038c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
14048c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
14058c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
14068c2ecf20Sopenharmony_ci};
14078c2ecf20Sopenharmony_ci
14088c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg lcac_oland[] =
14098c2ecf20Sopenharmony_ci{
14108c2ecf20Sopenharmony_ci	{ 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14118c2ecf20Sopenharmony_ci	{ 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14128c2ecf20Sopenharmony_ci	{ 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14138c2ecf20Sopenharmony_ci	{ 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14148c2ecf20Sopenharmony_ci	{ 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
14158c2ecf20Sopenharmony_ci	{ 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14168c2ecf20Sopenharmony_ci	{ 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
14178c2ecf20Sopenharmony_ci	{ 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14188c2ecf20Sopenharmony_ci	{ 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
14198c2ecf20Sopenharmony_ci	{ 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14208c2ecf20Sopenharmony_ci	{ 0x143, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
14218c2ecf20Sopenharmony_ci	{ 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14228c2ecf20Sopenharmony_ci	{ 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14238c2ecf20Sopenharmony_ci	{ 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14248c2ecf20Sopenharmony_ci	{ 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14258c2ecf20Sopenharmony_ci	{ 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14268c2ecf20Sopenharmony_ci	{ 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14278c2ecf20Sopenharmony_ci	{ 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14288c2ecf20Sopenharmony_ci	{ 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14298c2ecf20Sopenharmony_ci	{ 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14308c2ecf20Sopenharmony_ci	{ 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14318c2ecf20Sopenharmony_ci	{ 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14328c2ecf20Sopenharmony_ci	{ 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14338c2ecf20Sopenharmony_ci	{ 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14348c2ecf20Sopenharmony_ci	{ 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14358c2ecf20Sopenharmony_ci	{ 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14368c2ecf20Sopenharmony_ci	{ 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14378c2ecf20Sopenharmony_ci	{ 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14388c2ecf20Sopenharmony_ci	{ 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14398c2ecf20Sopenharmony_ci	{ 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14408c2ecf20Sopenharmony_ci	{ 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14418c2ecf20Sopenharmony_ci	{ 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14428c2ecf20Sopenharmony_ci	{ 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14438c2ecf20Sopenharmony_ci	{ 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14448c2ecf20Sopenharmony_ci	{ 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14458c2ecf20Sopenharmony_ci	{ 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14468c2ecf20Sopenharmony_ci	{ 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14478c2ecf20Sopenharmony_ci	{ 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14488c2ecf20Sopenharmony_ci	{ 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14498c2ecf20Sopenharmony_ci	{ 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14508c2ecf20Sopenharmony_ci	{ 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14518c2ecf20Sopenharmony_ci	{ 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14528c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
14538c2ecf20Sopenharmony_ci};
14548c2ecf20Sopenharmony_ci
14558c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg lcac_mars_pro[] =
14568c2ecf20Sopenharmony_ci{
14578c2ecf20Sopenharmony_ci	{ 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14588c2ecf20Sopenharmony_ci	{ 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14598c2ecf20Sopenharmony_ci	{ 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14608c2ecf20Sopenharmony_ci	{ 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14618c2ecf20Sopenharmony_ci	{ 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
14628c2ecf20Sopenharmony_ci	{ 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14638c2ecf20Sopenharmony_ci	{ 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
14648c2ecf20Sopenharmony_ci	{ 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14658c2ecf20Sopenharmony_ci	{ 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
14668c2ecf20Sopenharmony_ci	{ 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14678c2ecf20Sopenharmony_ci	{ 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14688c2ecf20Sopenharmony_ci	{ 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14698c2ecf20Sopenharmony_ci	{ 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14708c2ecf20Sopenharmony_ci	{ 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14718c2ecf20Sopenharmony_ci	{ 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14728c2ecf20Sopenharmony_ci	{ 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14738c2ecf20Sopenharmony_ci	{ 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14748c2ecf20Sopenharmony_ci	{ 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14758c2ecf20Sopenharmony_ci	{ 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14768c2ecf20Sopenharmony_ci	{ 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14778c2ecf20Sopenharmony_ci	{ 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14788c2ecf20Sopenharmony_ci	{ 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14798c2ecf20Sopenharmony_ci	{ 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14808c2ecf20Sopenharmony_ci	{ 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14818c2ecf20Sopenharmony_ci	{ 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14828c2ecf20Sopenharmony_ci	{ 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14838c2ecf20Sopenharmony_ci	{ 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14848c2ecf20Sopenharmony_ci	{ 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14858c2ecf20Sopenharmony_ci	{ 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
14868c2ecf20Sopenharmony_ci	{ 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14878c2ecf20Sopenharmony_ci	{ 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14888c2ecf20Sopenharmony_ci	{ 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14898c2ecf20Sopenharmony_ci	{ 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14908c2ecf20Sopenharmony_ci	{ 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14918c2ecf20Sopenharmony_ci	{ 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14928c2ecf20Sopenharmony_ci	{ 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14938c2ecf20Sopenharmony_ci	{ 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14948c2ecf20Sopenharmony_ci	{ 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14958c2ecf20Sopenharmony_ci	{ 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14968c2ecf20Sopenharmony_ci	{ 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14978c2ecf20Sopenharmony_ci	{ 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
14988c2ecf20Sopenharmony_ci	{ 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
14998c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
15008c2ecf20Sopenharmony_ci};
15018c2ecf20Sopenharmony_ci
15028c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_override_oland[] =
15038c2ecf20Sopenharmony_ci{
15048c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
15058c2ecf20Sopenharmony_ci};
15068c2ecf20Sopenharmony_ci
15078c2ecf20Sopenharmony_cistatic const struct si_powertune_data powertune_data_oland =
15088c2ecf20Sopenharmony_ci{
15098c2ecf20Sopenharmony_ci	((1 << 16) | 0x6993),
15108c2ecf20Sopenharmony_ci	5,
15118c2ecf20Sopenharmony_ci	0,
15128c2ecf20Sopenharmony_ci	7,
15138c2ecf20Sopenharmony_ci	105,
15148c2ecf20Sopenharmony_ci	{
15158c2ecf20Sopenharmony_ci		0UL,
15168c2ecf20Sopenharmony_ci		0UL,
15178c2ecf20Sopenharmony_ci		7194395UL,
15188c2ecf20Sopenharmony_ci		309631529UL,
15198c2ecf20Sopenharmony_ci		-1270850L,
15208c2ecf20Sopenharmony_ci		4513710L,
15218c2ecf20Sopenharmony_ci		100
15228c2ecf20Sopenharmony_ci	},
15238c2ecf20Sopenharmony_ci	117830498UL,
15248c2ecf20Sopenharmony_ci	12,
15258c2ecf20Sopenharmony_ci	{
15268c2ecf20Sopenharmony_ci		0,
15278c2ecf20Sopenharmony_ci		0,
15288c2ecf20Sopenharmony_ci		0,
15298c2ecf20Sopenharmony_ci		0,
15308c2ecf20Sopenharmony_ci		0,
15318c2ecf20Sopenharmony_ci		0,
15328c2ecf20Sopenharmony_ci		0,
15338c2ecf20Sopenharmony_ci		0
15348c2ecf20Sopenharmony_ci	},
15358c2ecf20Sopenharmony_ci	true
15368c2ecf20Sopenharmony_ci};
15378c2ecf20Sopenharmony_ci
15388c2ecf20Sopenharmony_cistatic const struct si_powertune_data powertune_data_mars_pro =
15398c2ecf20Sopenharmony_ci{
15408c2ecf20Sopenharmony_ci	((1 << 16) | 0x6993),
15418c2ecf20Sopenharmony_ci	5,
15428c2ecf20Sopenharmony_ci	0,
15438c2ecf20Sopenharmony_ci	7,
15448c2ecf20Sopenharmony_ci	105,
15458c2ecf20Sopenharmony_ci	{
15468c2ecf20Sopenharmony_ci		0UL,
15478c2ecf20Sopenharmony_ci		0UL,
15488c2ecf20Sopenharmony_ci		7194395UL,
15498c2ecf20Sopenharmony_ci		309631529UL,
15508c2ecf20Sopenharmony_ci		-1270850L,
15518c2ecf20Sopenharmony_ci		4513710L,
15528c2ecf20Sopenharmony_ci		100
15538c2ecf20Sopenharmony_ci	},
15548c2ecf20Sopenharmony_ci	117830498UL,
15558c2ecf20Sopenharmony_ci	12,
15568c2ecf20Sopenharmony_ci	{
15578c2ecf20Sopenharmony_ci		0,
15588c2ecf20Sopenharmony_ci		0,
15598c2ecf20Sopenharmony_ci		0,
15608c2ecf20Sopenharmony_ci		0,
15618c2ecf20Sopenharmony_ci		0,
15628c2ecf20Sopenharmony_ci		0,
15638c2ecf20Sopenharmony_ci		0,
15648c2ecf20Sopenharmony_ci		0
15658c2ecf20Sopenharmony_ci	},
15668c2ecf20Sopenharmony_ci	true
15678c2ecf20Sopenharmony_ci};
15688c2ecf20Sopenharmony_ci
15698c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_oland =
15708c2ecf20Sopenharmony_ci{
15718c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0 },
15728c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0 },
15738c2ecf20Sopenharmony_ci	0,
15748c2ecf20Sopenharmony_ci	0,
15758c2ecf20Sopenharmony_ci	0,
15768c2ecf20Sopenharmony_ci	0,
15778c2ecf20Sopenharmony_ci	0,
15788c2ecf20Sopenharmony_ci	0,
15798c2ecf20Sopenharmony_ci	0,
15808c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
15818c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
15828c2ecf20Sopenharmony_ci	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
15838c2ecf20Sopenharmony_ci	0,
15848c2ecf20Sopenharmony_ci	false
15858c2ecf20Sopenharmony_ci};
15868c2ecf20Sopenharmony_ci
15878c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_mars_pro =
15888c2ecf20Sopenharmony_ci{
15898c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
15908c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
15918c2ecf20Sopenharmony_ci	5,
15928c2ecf20Sopenharmony_ci	55000,
15938c2ecf20Sopenharmony_ci	105,
15948c2ecf20Sopenharmony_ci	0xA,
15958c2ecf20Sopenharmony_ci	1,
15968c2ecf20Sopenharmony_ci	0,
15978c2ecf20Sopenharmony_ci	0x10,
15988c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
15998c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
16008c2ecf20Sopenharmony_ci	{ 0xF627, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
16018c2ecf20Sopenharmony_ci	90,
16028c2ecf20Sopenharmony_ci	true
16038c2ecf20Sopenharmony_ci};
16048c2ecf20Sopenharmony_ci
16058c2ecf20Sopenharmony_cistatic const struct si_dte_data dte_data_sun_xt =
16068c2ecf20Sopenharmony_ci{
16078c2ecf20Sopenharmony_ci	{ 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
16088c2ecf20Sopenharmony_ci	{ 0x0, 0x0, 0x0, 0x0, 0x0 },
16098c2ecf20Sopenharmony_ci	5,
16108c2ecf20Sopenharmony_ci	55000,
16118c2ecf20Sopenharmony_ci	105,
16128c2ecf20Sopenharmony_ci	0xA,
16138c2ecf20Sopenharmony_ci	1,
16148c2ecf20Sopenharmony_ci	0,
16158c2ecf20Sopenharmony_ci	0x10,
16168c2ecf20Sopenharmony_ci	{ 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
16178c2ecf20Sopenharmony_ci	{ 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
16188c2ecf20Sopenharmony_ci	{ 0xD555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
16198c2ecf20Sopenharmony_ci	90,
16208c2ecf20Sopenharmony_ci	true
16218c2ecf20Sopenharmony_ci};
16228c2ecf20Sopenharmony_ci
16238c2ecf20Sopenharmony_ci
16248c2ecf20Sopenharmony_cistatic const struct si_cac_config_reg cac_weights_hainan[] =
16258c2ecf20Sopenharmony_ci{
16268c2ecf20Sopenharmony_ci	{ 0x0, 0x0000ffff, 0, 0x2d9, SISLANDS_CACCONFIG_CGIND },
16278c2ecf20Sopenharmony_ci	{ 0x0, 0xffff0000, 16, 0x22b, SISLANDS_CACCONFIG_CGIND },
16288c2ecf20Sopenharmony_ci	{ 0x1, 0x0000ffff, 0, 0x21c, SISLANDS_CACCONFIG_CGIND },
16298c2ecf20Sopenharmony_ci	{ 0x1, 0xffff0000, 16, 0x1dc, SISLANDS_CACCONFIG_CGIND },
16308c2ecf20Sopenharmony_ci	{ 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16318c2ecf20Sopenharmony_ci	{ 0x3, 0x0000ffff, 0, 0x24e, SISLANDS_CACCONFIG_CGIND },
16328c2ecf20Sopenharmony_ci	{ 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16338c2ecf20Sopenharmony_ci	{ 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16348c2ecf20Sopenharmony_ci	{ 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16358c2ecf20Sopenharmony_ci	{ 0x5, 0x0000ffff, 0, 0x35e, SISLANDS_CACCONFIG_CGIND },
16368c2ecf20Sopenharmony_ci	{ 0x5, 0xffff0000, 16, 0x1143, SISLANDS_CACCONFIG_CGIND },
16378c2ecf20Sopenharmony_ci	{ 0x6, 0x0000ffff, 0, 0xe17, SISLANDS_CACCONFIG_CGIND },
16388c2ecf20Sopenharmony_ci	{ 0x6, 0xffff0000, 16, 0x441, SISLANDS_CACCONFIG_CGIND },
16398c2ecf20Sopenharmony_ci	{ 0x18f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16408c2ecf20Sopenharmony_ci	{ 0x7, 0x0000ffff, 0, 0x28b, SISLANDS_CACCONFIG_CGIND },
16418c2ecf20Sopenharmony_ci	{ 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16428c2ecf20Sopenharmony_ci	{ 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16438c2ecf20Sopenharmony_ci	{ 0x8, 0xffff0000, 16, 0xabe, SISLANDS_CACCONFIG_CGIND },
16448c2ecf20Sopenharmony_ci	{ 0x9, 0x0000ffff, 0, 0xf11, SISLANDS_CACCONFIG_CGIND },
16458c2ecf20Sopenharmony_ci	{ 0xa, 0x0000ffff, 0, 0x907, SISLANDS_CACCONFIG_CGIND },
16468c2ecf20Sopenharmony_ci	{ 0xb, 0x0000ffff, 0, 0xb45, SISLANDS_CACCONFIG_CGIND },
16478c2ecf20Sopenharmony_ci	{ 0xb, 0xffff0000, 16, 0xd1e, SISLANDS_CACCONFIG_CGIND },
16488c2ecf20Sopenharmony_ci	{ 0xc, 0x0000ffff, 0, 0xa2c, SISLANDS_CACCONFIG_CGIND },
16498c2ecf20Sopenharmony_ci	{ 0xd, 0x0000ffff, 0, 0x62, SISLANDS_CACCONFIG_CGIND },
16508c2ecf20Sopenharmony_ci	{ 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16518c2ecf20Sopenharmony_ci	{ 0xe, 0x0000ffff, 0, 0x1f3, SISLANDS_CACCONFIG_CGIND },
16528c2ecf20Sopenharmony_ci	{ 0xf, 0x0000ffff, 0, 0x42, SISLANDS_CACCONFIG_CGIND },
16538c2ecf20Sopenharmony_ci	{ 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16548c2ecf20Sopenharmony_ci	{ 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16558c2ecf20Sopenharmony_ci	{ 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16568c2ecf20Sopenharmony_ci	{ 0x11, 0x0000ffff, 0, 0x709, SISLANDS_CACCONFIG_CGIND },
16578c2ecf20Sopenharmony_ci	{ 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16588c2ecf20Sopenharmony_ci	{ 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16598c2ecf20Sopenharmony_ci	{ 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16608c2ecf20Sopenharmony_ci	{ 0x13, 0xffff0000, 16, 0x3a, SISLANDS_CACCONFIG_CGIND },
16618c2ecf20Sopenharmony_ci	{ 0x14, 0x0000ffff, 0, 0x357, SISLANDS_CACCONFIG_CGIND },
16628c2ecf20Sopenharmony_ci	{ 0x15, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
16638c2ecf20Sopenharmony_ci	{ 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16648c2ecf20Sopenharmony_ci	{ 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16658c2ecf20Sopenharmony_ci	{ 0x16, 0x0000ffff, 0, 0x314, SISLANDS_CACCONFIG_CGIND },
16668c2ecf20Sopenharmony_ci	{ 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16678c2ecf20Sopenharmony_ci	{ 0x17, 0x0000ffff, 0, 0x6d, SISLANDS_CACCONFIG_CGIND },
16688c2ecf20Sopenharmony_ci	{ 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16698c2ecf20Sopenharmony_ci	{ 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16708c2ecf20Sopenharmony_ci	{ 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
16718c2ecf20Sopenharmony_ci	{ 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
16728c2ecf20Sopenharmony_ci	{ 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16738c2ecf20Sopenharmony_ci	{ 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
16748c2ecf20Sopenharmony_ci	{ 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16758c2ecf20Sopenharmony_ci	{ 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
16768c2ecf20Sopenharmony_ci	{ 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16778c2ecf20Sopenharmony_ci	{ 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
16788c2ecf20Sopenharmony_ci	{ 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16798c2ecf20Sopenharmony_ci	{ 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
16808c2ecf20Sopenharmony_ci	{ 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16818c2ecf20Sopenharmony_ci	{ 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
16828c2ecf20Sopenharmony_ci	{ 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16838c2ecf20Sopenharmony_ci	{ 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
16848c2ecf20Sopenharmony_ci	{ 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
16858c2ecf20Sopenharmony_ci	{ 0x6d, 0x0000ffff, 0, 0x1b9, SISLANDS_CACCONFIG_CGIND },
16868c2ecf20Sopenharmony_ci	{ 0xFFFFFFFF }
16878c2ecf20Sopenharmony_ci};
16888c2ecf20Sopenharmony_ci
16898c2ecf20Sopenharmony_cistatic const struct si_powertune_data powertune_data_hainan =
16908c2ecf20Sopenharmony_ci{
16918c2ecf20Sopenharmony_ci	((1 << 16) | 0x6993),
16928c2ecf20Sopenharmony_ci	5,
16938c2ecf20Sopenharmony_ci	0,
16948c2ecf20Sopenharmony_ci	9,
16958c2ecf20Sopenharmony_ci	105,
16968c2ecf20Sopenharmony_ci	{
16978c2ecf20Sopenharmony_ci		0UL,
16988c2ecf20Sopenharmony_ci		0UL,
16998c2ecf20Sopenharmony_ci		7194395UL,
17008c2ecf20Sopenharmony_ci		309631529UL,
17018c2ecf20Sopenharmony_ci		-1270850L,
17028c2ecf20Sopenharmony_ci		4513710L,
17038c2ecf20Sopenharmony_ci		100
17048c2ecf20Sopenharmony_ci	},
17058c2ecf20Sopenharmony_ci	117830498UL,
17068c2ecf20Sopenharmony_ci	12,
17078c2ecf20Sopenharmony_ci	{
17088c2ecf20Sopenharmony_ci		0,
17098c2ecf20Sopenharmony_ci		0,
17108c2ecf20Sopenharmony_ci		0,
17118c2ecf20Sopenharmony_ci		0,
17128c2ecf20Sopenharmony_ci		0,
17138c2ecf20Sopenharmony_ci		0,
17148c2ecf20Sopenharmony_ci		0,
17158c2ecf20Sopenharmony_ci		0
17168c2ecf20Sopenharmony_ci	},
17178c2ecf20Sopenharmony_ci	true
17188c2ecf20Sopenharmony_ci};
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_cistruct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev);
17218c2ecf20Sopenharmony_cistruct evergreen_power_info *evergreen_get_pi(struct radeon_device *rdev);
17228c2ecf20Sopenharmony_cistruct ni_power_info *ni_get_pi(struct radeon_device *rdev);
17238c2ecf20Sopenharmony_cistruct ni_ps *ni_get_ps(struct radeon_ps *rps);
17248c2ecf20Sopenharmony_ci
17258c2ecf20Sopenharmony_ciextern int si_mc_load_microcode(struct radeon_device *rdev);
17268c2ecf20Sopenharmony_ciextern void vce_v1_0_enable_mgcg(struct radeon_device *rdev, bool enable);
17278c2ecf20Sopenharmony_ci
17288c2ecf20Sopenharmony_cistatic int si_populate_voltage_value(struct radeon_device *rdev,
17298c2ecf20Sopenharmony_ci				     const struct atom_voltage_table *table,
17308c2ecf20Sopenharmony_ci				     u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage);
17318c2ecf20Sopenharmony_cistatic int si_get_std_voltage_value(struct radeon_device *rdev,
17328c2ecf20Sopenharmony_ci				    SISLANDS_SMC_VOLTAGE_VALUE *voltage,
17338c2ecf20Sopenharmony_ci				    u16 *std_voltage);
17348c2ecf20Sopenharmony_cistatic int si_write_smc_soft_register(struct radeon_device *rdev,
17358c2ecf20Sopenharmony_ci				      u16 reg_offset, u32 value);
17368c2ecf20Sopenharmony_cistatic int si_convert_power_level_to_smc(struct radeon_device *rdev,
17378c2ecf20Sopenharmony_ci					 struct rv7xx_pl *pl,
17388c2ecf20Sopenharmony_ci					 SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level);
17398c2ecf20Sopenharmony_cistatic int si_calculate_sclk_params(struct radeon_device *rdev,
17408c2ecf20Sopenharmony_ci				    u32 engine_clock,
17418c2ecf20Sopenharmony_ci				    SISLANDS_SMC_SCLK_VALUE *sclk);
17428c2ecf20Sopenharmony_ci
17438c2ecf20Sopenharmony_cistatic void si_thermal_start_smc_fan_control(struct radeon_device *rdev);
17448c2ecf20Sopenharmony_cistatic void si_fan_ctrl_set_default_mode(struct radeon_device *rdev);
17458c2ecf20Sopenharmony_ci
17468c2ecf20Sopenharmony_cistatic struct si_power_info *si_get_pi(struct radeon_device *rdev)
17478c2ecf20Sopenharmony_ci{
17488c2ecf20Sopenharmony_ci	struct si_power_info *pi = rdev->pm.dpm.priv;
17498c2ecf20Sopenharmony_ci
17508c2ecf20Sopenharmony_ci	return pi;
17518c2ecf20Sopenharmony_ci}
17528c2ecf20Sopenharmony_ci
17538c2ecf20Sopenharmony_cistatic void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients *coeff,
17548c2ecf20Sopenharmony_ci						     u16 v, s32 t, u32 ileakage, u32 *leakage)
17558c2ecf20Sopenharmony_ci{
17568c2ecf20Sopenharmony_ci	s64 kt, kv, leakage_w, i_leakage, vddc;
17578c2ecf20Sopenharmony_ci	s64 temperature, t_slope, t_intercept, av, bv, t_ref;
17588c2ecf20Sopenharmony_ci	s64 tmp;
17598c2ecf20Sopenharmony_ci
17608c2ecf20Sopenharmony_ci	i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
17618c2ecf20Sopenharmony_ci	vddc = div64_s64(drm_int2fixp(v), 1000);
17628c2ecf20Sopenharmony_ci	temperature = div64_s64(drm_int2fixp(t), 1000);
17638c2ecf20Sopenharmony_ci
17648c2ecf20Sopenharmony_ci	t_slope = div64_s64(drm_int2fixp(coeff->t_slope), 100000000);
17658c2ecf20Sopenharmony_ci	t_intercept = div64_s64(drm_int2fixp(coeff->t_intercept), 100000000);
17668c2ecf20Sopenharmony_ci	av = div64_s64(drm_int2fixp(coeff->av), 100000000);
17678c2ecf20Sopenharmony_ci	bv = div64_s64(drm_int2fixp(coeff->bv), 100000000);
17688c2ecf20Sopenharmony_ci	t_ref = drm_int2fixp(coeff->t_ref);
17698c2ecf20Sopenharmony_ci
17708c2ecf20Sopenharmony_ci	tmp = drm_fixp_mul(t_slope, vddc) + t_intercept;
17718c2ecf20Sopenharmony_ci	kt = drm_fixp_exp(drm_fixp_mul(tmp, temperature));
17728c2ecf20Sopenharmony_ci	kt = drm_fixp_div(kt, drm_fixp_exp(drm_fixp_mul(tmp, t_ref)));
17738c2ecf20Sopenharmony_ci	kv = drm_fixp_mul(av, drm_fixp_exp(drm_fixp_mul(bv, vddc)));
17748c2ecf20Sopenharmony_ci
17758c2ecf20Sopenharmony_ci	leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
17768c2ecf20Sopenharmony_ci
17778c2ecf20Sopenharmony_ci	*leakage = drm_fixp2int(leakage_w * 1000);
17788c2ecf20Sopenharmony_ci}
17798c2ecf20Sopenharmony_ci
17808c2ecf20Sopenharmony_cistatic void si_calculate_leakage_for_v_and_t(struct radeon_device *rdev,
17818c2ecf20Sopenharmony_ci					     const struct ni_leakage_coeffients *coeff,
17828c2ecf20Sopenharmony_ci					     u16 v,
17838c2ecf20Sopenharmony_ci					     s32 t,
17848c2ecf20Sopenharmony_ci					     u32 i_leakage,
17858c2ecf20Sopenharmony_ci					     u32 *leakage)
17868c2ecf20Sopenharmony_ci{
17878c2ecf20Sopenharmony_ci	si_calculate_leakage_for_v_and_t_formula(coeff, v, t, i_leakage, leakage);
17888c2ecf20Sopenharmony_ci}
17898c2ecf20Sopenharmony_ci
17908c2ecf20Sopenharmony_cistatic void si_calculate_leakage_for_v_formula(const struct ni_leakage_coeffients *coeff,
17918c2ecf20Sopenharmony_ci					       const u32 fixed_kt, u16 v,
17928c2ecf20Sopenharmony_ci					       u32 ileakage, u32 *leakage)
17938c2ecf20Sopenharmony_ci{
17948c2ecf20Sopenharmony_ci	s64 kt, kv, leakage_w, i_leakage, vddc;
17958c2ecf20Sopenharmony_ci
17968c2ecf20Sopenharmony_ci	i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
17978c2ecf20Sopenharmony_ci	vddc = div64_s64(drm_int2fixp(v), 1000);
17988c2ecf20Sopenharmony_ci
17998c2ecf20Sopenharmony_ci	kt = div64_s64(drm_int2fixp(fixed_kt), 100000000);
18008c2ecf20Sopenharmony_ci	kv = drm_fixp_mul(div64_s64(drm_int2fixp(coeff->av), 100000000),
18018c2ecf20Sopenharmony_ci			  drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff->bv), 100000000), vddc)));
18028c2ecf20Sopenharmony_ci
18038c2ecf20Sopenharmony_ci	leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
18048c2ecf20Sopenharmony_ci
18058c2ecf20Sopenharmony_ci	*leakage = drm_fixp2int(leakage_w * 1000);
18068c2ecf20Sopenharmony_ci}
18078c2ecf20Sopenharmony_ci
18088c2ecf20Sopenharmony_cistatic void si_calculate_leakage_for_v(struct radeon_device *rdev,
18098c2ecf20Sopenharmony_ci				       const struct ni_leakage_coeffients *coeff,
18108c2ecf20Sopenharmony_ci				       const u32 fixed_kt,
18118c2ecf20Sopenharmony_ci				       u16 v,
18128c2ecf20Sopenharmony_ci				       u32 i_leakage,
18138c2ecf20Sopenharmony_ci				       u32 *leakage)
18148c2ecf20Sopenharmony_ci{
18158c2ecf20Sopenharmony_ci	si_calculate_leakage_for_v_formula(coeff, fixed_kt, v, i_leakage, leakage);
18168c2ecf20Sopenharmony_ci}
18178c2ecf20Sopenharmony_ci
18188c2ecf20Sopenharmony_ci
18198c2ecf20Sopenharmony_cistatic void si_update_dte_from_pl2(struct radeon_device *rdev,
18208c2ecf20Sopenharmony_ci				   struct si_dte_data *dte_data)
18218c2ecf20Sopenharmony_ci{
18228c2ecf20Sopenharmony_ci	u32 p_limit1 = rdev->pm.dpm.tdp_limit;
18238c2ecf20Sopenharmony_ci	u32 p_limit2 = rdev->pm.dpm.near_tdp_limit;
18248c2ecf20Sopenharmony_ci	u32 k = dte_data->k;
18258c2ecf20Sopenharmony_ci	u32 t_max = dte_data->max_t;
18268c2ecf20Sopenharmony_ci	u32 t_split[5] = { 10, 15, 20, 25, 30 };
18278c2ecf20Sopenharmony_ci	u32 t_0 = dte_data->t0;
18288c2ecf20Sopenharmony_ci	u32 i;
18298c2ecf20Sopenharmony_ci
18308c2ecf20Sopenharmony_ci	if (p_limit2 != 0 && p_limit2 <= p_limit1) {
18318c2ecf20Sopenharmony_ci		dte_data->tdep_count = 3;
18328c2ecf20Sopenharmony_ci
18338c2ecf20Sopenharmony_ci		for (i = 0; i < k; i++) {
18348c2ecf20Sopenharmony_ci			dte_data->r[i] =
18358c2ecf20Sopenharmony_ci				(t_split[i] * (t_max - t_0/(u32)1000) * (1 << 14)) /
18368c2ecf20Sopenharmony_ci				(p_limit2  * (u32)100);
18378c2ecf20Sopenharmony_ci		}
18388c2ecf20Sopenharmony_ci
18398c2ecf20Sopenharmony_ci		dte_data->tdep_r[1] = dte_data->r[4] * 2;
18408c2ecf20Sopenharmony_ci
18418c2ecf20Sopenharmony_ci		for (i = 2; i < SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE; i++) {
18428c2ecf20Sopenharmony_ci			dte_data->tdep_r[i] = dte_data->r[4];
18438c2ecf20Sopenharmony_ci		}
18448c2ecf20Sopenharmony_ci	} else {
18458c2ecf20Sopenharmony_ci		DRM_ERROR("Invalid PL2! DTE will not be updated.\n");
18468c2ecf20Sopenharmony_ci	}
18478c2ecf20Sopenharmony_ci}
18488c2ecf20Sopenharmony_ci
18498c2ecf20Sopenharmony_cistatic void si_initialize_powertune_defaults(struct radeon_device *rdev)
18508c2ecf20Sopenharmony_ci{
18518c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
18528c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
18538c2ecf20Sopenharmony_ci	bool update_dte_from_pl2 = false;
18548c2ecf20Sopenharmony_ci
18558c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_TAHITI) {
18568c2ecf20Sopenharmony_ci		si_pi->cac_weights = cac_weights_tahiti;
18578c2ecf20Sopenharmony_ci		si_pi->lcac_config = lcac_tahiti;
18588c2ecf20Sopenharmony_ci		si_pi->cac_override = cac_override_tahiti;
18598c2ecf20Sopenharmony_ci		si_pi->powertune_data = &powertune_data_tahiti;
18608c2ecf20Sopenharmony_ci		si_pi->dte_data = dte_data_tahiti;
18618c2ecf20Sopenharmony_ci
18628c2ecf20Sopenharmony_ci		switch (rdev->pdev->device) {
18638c2ecf20Sopenharmony_ci		case 0x6798:
18648c2ecf20Sopenharmony_ci			si_pi->dte_data.enable_dte_by_default = true;
18658c2ecf20Sopenharmony_ci			break;
18668c2ecf20Sopenharmony_ci		case 0x6799:
18678c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_new_zealand;
18688c2ecf20Sopenharmony_ci			break;
18698c2ecf20Sopenharmony_ci		case 0x6790:
18708c2ecf20Sopenharmony_ci		case 0x6791:
18718c2ecf20Sopenharmony_ci		case 0x6792:
18728c2ecf20Sopenharmony_ci		case 0x679E:
18738c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_aruba_pro;
18748c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
18758c2ecf20Sopenharmony_ci			break;
18768c2ecf20Sopenharmony_ci		case 0x679B:
18778c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_malta;
18788c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
18798c2ecf20Sopenharmony_ci			break;
18808c2ecf20Sopenharmony_ci		case 0x679A:
18818c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_tahiti_pro;
18828c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
18838c2ecf20Sopenharmony_ci			break;
18848c2ecf20Sopenharmony_ci		default:
18858c2ecf20Sopenharmony_ci			if (si_pi->dte_data.enable_dte_by_default == true)
18868c2ecf20Sopenharmony_ci				DRM_ERROR("DTE is not enabled!\n");
18878c2ecf20Sopenharmony_ci			break;
18888c2ecf20Sopenharmony_ci		}
18898c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_PITCAIRN) {
18908c2ecf20Sopenharmony_ci		switch (rdev->pdev->device) {
18918c2ecf20Sopenharmony_ci		case 0x6810:
18928c2ecf20Sopenharmony_ci		case 0x6818:
18938c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_pitcairn;
18948c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_pitcairn;
18958c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_pitcairn;
18968c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_pitcairn;
18978c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_curacao_xt;
18988c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
18998c2ecf20Sopenharmony_ci			break;
19008c2ecf20Sopenharmony_ci		case 0x6819:
19018c2ecf20Sopenharmony_ci		case 0x6811:
19028c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_pitcairn;
19038c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_pitcairn;
19048c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_pitcairn;
19058c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_pitcairn;
19068c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_curacao_pro;
19078c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
19088c2ecf20Sopenharmony_ci			break;
19098c2ecf20Sopenharmony_ci		case 0x6800:
19108c2ecf20Sopenharmony_ci		case 0x6806:
19118c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_pitcairn;
19128c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_pitcairn;
19138c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_pitcairn;
19148c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_pitcairn;
19158c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_neptune_xt;
19168c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
19178c2ecf20Sopenharmony_ci			break;
19188c2ecf20Sopenharmony_ci		default:
19198c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_pitcairn;
19208c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_pitcairn;
19218c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_pitcairn;
19228c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_pitcairn;
19238c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_pitcairn;
19248c2ecf20Sopenharmony_ci			break;
19258c2ecf20Sopenharmony_ci		}
19268c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_VERDE) {
19278c2ecf20Sopenharmony_ci		si_pi->lcac_config = lcac_cape_verde;
19288c2ecf20Sopenharmony_ci		si_pi->cac_override = cac_override_cape_verde;
19298c2ecf20Sopenharmony_ci		si_pi->powertune_data = &powertune_data_cape_verde;
19308c2ecf20Sopenharmony_ci
19318c2ecf20Sopenharmony_ci		switch (rdev->pdev->device) {
19328c2ecf20Sopenharmony_ci		case 0x683B:
19338c2ecf20Sopenharmony_ci		case 0x683F:
19348c2ecf20Sopenharmony_ci		case 0x6829:
19358c2ecf20Sopenharmony_ci		case 0x6835:
19368c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_cape_verde_pro;
19378c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_cape_verde;
19388c2ecf20Sopenharmony_ci			break;
19398c2ecf20Sopenharmony_ci		case 0x682C:
19408c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_cape_verde_pro;
19418c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_sun_xt;
19428c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
19438c2ecf20Sopenharmony_ci			break;
19448c2ecf20Sopenharmony_ci		case 0x6825:
19458c2ecf20Sopenharmony_ci		case 0x6827:
19468c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_heathrow;
19478c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_cape_verde;
19488c2ecf20Sopenharmony_ci			break;
19498c2ecf20Sopenharmony_ci		case 0x6824:
19508c2ecf20Sopenharmony_ci		case 0x682D:
19518c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_chelsea_xt;
19528c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_cape_verde;
19538c2ecf20Sopenharmony_ci			break;
19548c2ecf20Sopenharmony_ci		case 0x682F:
19558c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_chelsea_pro;
19568c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_cape_verde;
19578c2ecf20Sopenharmony_ci			break;
19588c2ecf20Sopenharmony_ci		case 0x6820:
19598c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_heathrow;
19608c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_venus_xtx;
19618c2ecf20Sopenharmony_ci			break;
19628c2ecf20Sopenharmony_ci		case 0x6821:
19638c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_heathrow;
19648c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_venus_xt;
19658c2ecf20Sopenharmony_ci			break;
19668c2ecf20Sopenharmony_ci		case 0x6823:
19678c2ecf20Sopenharmony_ci		case 0x682B:
19688c2ecf20Sopenharmony_ci		case 0x6822:
19698c2ecf20Sopenharmony_ci		case 0x682A:
19708c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_chelsea_pro;
19718c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_venus_pro;
19728c2ecf20Sopenharmony_ci			break;
19738c2ecf20Sopenharmony_ci		default:
19748c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_cape_verde;
19758c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_cape_verde;
19768c2ecf20Sopenharmony_ci			break;
19778c2ecf20Sopenharmony_ci		}
19788c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_OLAND) {
19798c2ecf20Sopenharmony_ci		switch (rdev->pdev->device) {
19808c2ecf20Sopenharmony_ci		case 0x6601:
19818c2ecf20Sopenharmony_ci		case 0x6621:
19828c2ecf20Sopenharmony_ci		case 0x6603:
19838c2ecf20Sopenharmony_ci		case 0x6605:
19848c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_mars_pro;
19858c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_mars_pro;
19868c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_oland;
19878c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_mars_pro;
19888c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_mars_pro;
19898c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
19908c2ecf20Sopenharmony_ci			break;
19918c2ecf20Sopenharmony_ci		case 0x6600:
19928c2ecf20Sopenharmony_ci		case 0x6606:
19938c2ecf20Sopenharmony_ci		case 0x6620:
19948c2ecf20Sopenharmony_ci		case 0x6604:
19958c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_mars_xt;
19968c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_mars_pro;
19978c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_oland;
19988c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_mars_pro;
19998c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_mars_pro;
20008c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
20018c2ecf20Sopenharmony_ci			break;
20028c2ecf20Sopenharmony_ci		case 0x6611:
20038c2ecf20Sopenharmony_ci		case 0x6613:
20048c2ecf20Sopenharmony_ci		case 0x6608:
20058c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_oland_pro;
20068c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_mars_pro;
20078c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_oland;
20088c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_mars_pro;
20098c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_mars_pro;
20108c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
20118c2ecf20Sopenharmony_ci			break;
20128c2ecf20Sopenharmony_ci		case 0x6610:
20138c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_oland_xt;
20148c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_mars_pro;
20158c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_oland;
20168c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_mars_pro;
20178c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_mars_pro;
20188c2ecf20Sopenharmony_ci			update_dte_from_pl2 = true;
20198c2ecf20Sopenharmony_ci			break;
20208c2ecf20Sopenharmony_ci		default:
20218c2ecf20Sopenharmony_ci			si_pi->cac_weights = cac_weights_oland;
20228c2ecf20Sopenharmony_ci			si_pi->lcac_config = lcac_oland;
20238c2ecf20Sopenharmony_ci			si_pi->cac_override = cac_override_oland;
20248c2ecf20Sopenharmony_ci			si_pi->powertune_data = &powertune_data_oland;
20258c2ecf20Sopenharmony_ci			si_pi->dte_data = dte_data_oland;
20268c2ecf20Sopenharmony_ci			break;
20278c2ecf20Sopenharmony_ci		}
20288c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_HAINAN) {
20298c2ecf20Sopenharmony_ci		si_pi->cac_weights = cac_weights_hainan;
20308c2ecf20Sopenharmony_ci		si_pi->lcac_config = lcac_oland;
20318c2ecf20Sopenharmony_ci		si_pi->cac_override = cac_override_oland;
20328c2ecf20Sopenharmony_ci		si_pi->powertune_data = &powertune_data_hainan;
20338c2ecf20Sopenharmony_ci		si_pi->dte_data = dte_data_sun_xt;
20348c2ecf20Sopenharmony_ci		update_dte_from_pl2 = true;
20358c2ecf20Sopenharmony_ci	} else {
20368c2ecf20Sopenharmony_ci		DRM_ERROR("Unknown SI asic revision, failed to initialize PowerTune!\n");
20378c2ecf20Sopenharmony_ci		return;
20388c2ecf20Sopenharmony_ci	}
20398c2ecf20Sopenharmony_ci
20408c2ecf20Sopenharmony_ci	ni_pi->enable_power_containment = false;
20418c2ecf20Sopenharmony_ci	ni_pi->enable_cac = false;
20428c2ecf20Sopenharmony_ci	ni_pi->enable_sq_ramping = false;
20438c2ecf20Sopenharmony_ci	si_pi->enable_dte = false;
20448c2ecf20Sopenharmony_ci
20458c2ecf20Sopenharmony_ci	if (si_pi->powertune_data->enable_powertune_by_default) {
20468c2ecf20Sopenharmony_ci		ni_pi->enable_power_containment= true;
20478c2ecf20Sopenharmony_ci		ni_pi->enable_cac = true;
20488c2ecf20Sopenharmony_ci		if (si_pi->dte_data.enable_dte_by_default) {
20498c2ecf20Sopenharmony_ci			si_pi->enable_dte = true;
20508c2ecf20Sopenharmony_ci			if (update_dte_from_pl2)
20518c2ecf20Sopenharmony_ci				si_update_dte_from_pl2(rdev, &si_pi->dte_data);
20528c2ecf20Sopenharmony_ci
20538c2ecf20Sopenharmony_ci		}
20548c2ecf20Sopenharmony_ci		ni_pi->enable_sq_ramping = true;
20558c2ecf20Sopenharmony_ci	}
20568c2ecf20Sopenharmony_ci
20578c2ecf20Sopenharmony_ci	ni_pi->driver_calculate_cac_leakage = true;
20588c2ecf20Sopenharmony_ci	ni_pi->cac_configuration_required = true;
20598c2ecf20Sopenharmony_ci
20608c2ecf20Sopenharmony_ci	if (ni_pi->cac_configuration_required) {
20618c2ecf20Sopenharmony_ci		ni_pi->support_cac_long_term_average = true;
20628c2ecf20Sopenharmony_ci		si_pi->dyn_powertune_data.l2_lta_window_size =
20638c2ecf20Sopenharmony_ci			si_pi->powertune_data->l2_lta_window_size_default;
20648c2ecf20Sopenharmony_ci		si_pi->dyn_powertune_data.lts_truncate =
20658c2ecf20Sopenharmony_ci			si_pi->powertune_data->lts_truncate_default;
20668c2ecf20Sopenharmony_ci	} else {
20678c2ecf20Sopenharmony_ci		ni_pi->support_cac_long_term_average = false;
20688c2ecf20Sopenharmony_ci		si_pi->dyn_powertune_data.l2_lta_window_size = 0;
20698c2ecf20Sopenharmony_ci		si_pi->dyn_powertune_data.lts_truncate = 0;
20708c2ecf20Sopenharmony_ci	}
20718c2ecf20Sopenharmony_ci
20728c2ecf20Sopenharmony_ci	si_pi->dyn_powertune_data.disable_uvd_powertune = false;
20738c2ecf20Sopenharmony_ci}
20748c2ecf20Sopenharmony_ci
20758c2ecf20Sopenharmony_cistatic u32 si_get_smc_power_scaling_factor(struct radeon_device *rdev)
20768c2ecf20Sopenharmony_ci{
20778c2ecf20Sopenharmony_ci	return 1;
20788c2ecf20Sopenharmony_ci}
20798c2ecf20Sopenharmony_ci
20808c2ecf20Sopenharmony_cistatic u32 si_calculate_cac_wintime(struct radeon_device *rdev)
20818c2ecf20Sopenharmony_ci{
20828c2ecf20Sopenharmony_ci	u32 xclk;
20838c2ecf20Sopenharmony_ci	u32 wintime;
20848c2ecf20Sopenharmony_ci	u32 cac_window;
20858c2ecf20Sopenharmony_ci	u32 cac_window_size;
20868c2ecf20Sopenharmony_ci
20878c2ecf20Sopenharmony_ci	xclk = radeon_get_xclk(rdev);
20888c2ecf20Sopenharmony_ci
20898c2ecf20Sopenharmony_ci	if (xclk == 0)
20908c2ecf20Sopenharmony_ci		return 0;
20918c2ecf20Sopenharmony_ci
20928c2ecf20Sopenharmony_ci	cac_window = RREG32(CG_CAC_CTRL) & CAC_WINDOW_MASK;
20938c2ecf20Sopenharmony_ci	cac_window_size = ((cac_window & 0xFFFF0000) >> 16) * (cac_window & 0x0000FFFF);
20948c2ecf20Sopenharmony_ci
20958c2ecf20Sopenharmony_ci	wintime = (cac_window_size * 100) / xclk;
20968c2ecf20Sopenharmony_ci
20978c2ecf20Sopenharmony_ci	return wintime;
20988c2ecf20Sopenharmony_ci}
20998c2ecf20Sopenharmony_ci
21008c2ecf20Sopenharmony_cistatic u32 si_scale_power_for_smc(u32 power_in_watts, u32 scaling_factor)
21018c2ecf20Sopenharmony_ci{
21028c2ecf20Sopenharmony_ci	return power_in_watts;
21038c2ecf20Sopenharmony_ci}
21048c2ecf20Sopenharmony_ci
21058c2ecf20Sopenharmony_cistatic int si_calculate_adjusted_tdp_limits(struct radeon_device *rdev,
21068c2ecf20Sopenharmony_ci					    bool adjust_polarity,
21078c2ecf20Sopenharmony_ci					    u32 tdp_adjustment,
21088c2ecf20Sopenharmony_ci					    u32 *tdp_limit,
21098c2ecf20Sopenharmony_ci					    u32 *near_tdp_limit)
21108c2ecf20Sopenharmony_ci{
21118c2ecf20Sopenharmony_ci	u32 adjustment_delta, max_tdp_limit;
21128c2ecf20Sopenharmony_ci
21138c2ecf20Sopenharmony_ci	if (tdp_adjustment > (u32)rdev->pm.dpm.tdp_od_limit)
21148c2ecf20Sopenharmony_ci		return -EINVAL;
21158c2ecf20Sopenharmony_ci
21168c2ecf20Sopenharmony_ci	max_tdp_limit = ((100 + 100) * rdev->pm.dpm.tdp_limit) / 100;
21178c2ecf20Sopenharmony_ci
21188c2ecf20Sopenharmony_ci	if (adjust_polarity) {
21198c2ecf20Sopenharmony_ci		*tdp_limit = ((100 + tdp_adjustment) * rdev->pm.dpm.tdp_limit) / 100;
21208c2ecf20Sopenharmony_ci		*near_tdp_limit = rdev->pm.dpm.near_tdp_limit_adjusted + (*tdp_limit - rdev->pm.dpm.tdp_limit);
21218c2ecf20Sopenharmony_ci	} else {
21228c2ecf20Sopenharmony_ci		*tdp_limit = ((100 - tdp_adjustment) * rdev->pm.dpm.tdp_limit) / 100;
21238c2ecf20Sopenharmony_ci		adjustment_delta  = rdev->pm.dpm.tdp_limit - *tdp_limit;
21248c2ecf20Sopenharmony_ci		if (adjustment_delta < rdev->pm.dpm.near_tdp_limit_adjusted)
21258c2ecf20Sopenharmony_ci			*near_tdp_limit = rdev->pm.dpm.near_tdp_limit_adjusted - adjustment_delta;
21268c2ecf20Sopenharmony_ci		else
21278c2ecf20Sopenharmony_ci			*near_tdp_limit = 0;
21288c2ecf20Sopenharmony_ci	}
21298c2ecf20Sopenharmony_ci
21308c2ecf20Sopenharmony_ci	if ((*tdp_limit <= 0) || (*tdp_limit > max_tdp_limit))
21318c2ecf20Sopenharmony_ci		return -EINVAL;
21328c2ecf20Sopenharmony_ci	if ((*near_tdp_limit <= 0) || (*near_tdp_limit > *tdp_limit))
21338c2ecf20Sopenharmony_ci		return -EINVAL;
21348c2ecf20Sopenharmony_ci
21358c2ecf20Sopenharmony_ci	return 0;
21368c2ecf20Sopenharmony_ci}
21378c2ecf20Sopenharmony_ci
21388c2ecf20Sopenharmony_cistatic int si_populate_smc_tdp_limits(struct radeon_device *rdev,
21398c2ecf20Sopenharmony_ci				      struct radeon_ps *radeon_state)
21408c2ecf20Sopenharmony_ci{
21418c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
21428c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
21438c2ecf20Sopenharmony_ci
21448c2ecf20Sopenharmony_ci	if (ni_pi->enable_power_containment) {
21458c2ecf20Sopenharmony_ci		SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
21468c2ecf20Sopenharmony_ci		PP_SIslands_PAPMParameters *papm_parm;
21478c2ecf20Sopenharmony_ci		struct radeon_ppm_table *ppm = rdev->pm.dpm.dyn_state.ppm_table;
21488c2ecf20Sopenharmony_ci		u32 scaling_factor = si_get_smc_power_scaling_factor(rdev);
21498c2ecf20Sopenharmony_ci		u32 tdp_limit;
21508c2ecf20Sopenharmony_ci		u32 near_tdp_limit;
21518c2ecf20Sopenharmony_ci		int ret;
21528c2ecf20Sopenharmony_ci
21538c2ecf20Sopenharmony_ci		if (scaling_factor == 0)
21548c2ecf20Sopenharmony_ci			return -EINVAL;
21558c2ecf20Sopenharmony_ci
21568c2ecf20Sopenharmony_ci		memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
21578c2ecf20Sopenharmony_ci
21588c2ecf20Sopenharmony_ci		ret = si_calculate_adjusted_tdp_limits(rdev,
21598c2ecf20Sopenharmony_ci						       false, /* ??? */
21608c2ecf20Sopenharmony_ci						       rdev->pm.dpm.tdp_adjustment,
21618c2ecf20Sopenharmony_ci						       &tdp_limit,
21628c2ecf20Sopenharmony_ci						       &near_tdp_limit);
21638c2ecf20Sopenharmony_ci		if (ret)
21648c2ecf20Sopenharmony_ci			return ret;
21658c2ecf20Sopenharmony_ci
21668c2ecf20Sopenharmony_ci		smc_table->dpm2Params.TDPLimit =
21678c2ecf20Sopenharmony_ci			cpu_to_be32(si_scale_power_for_smc(tdp_limit, scaling_factor) * 1000);
21688c2ecf20Sopenharmony_ci		smc_table->dpm2Params.NearTDPLimit =
21698c2ecf20Sopenharmony_ci			cpu_to_be32(si_scale_power_for_smc(near_tdp_limit, scaling_factor) * 1000);
21708c2ecf20Sopenharmony_ci		smc_table->dpm2Params.SafePowerLimit =
21718c2ecf20Sopenharmony_ci			cpu_to_be32(si_scale_power_for_smc((near_tdp_limit * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
21728c2ecf20Sopenharmony_ci
21738c2ecf20Sopenharmony_ci		ret = si_copy_bytes_to_smc(rdev,
21748c2ecf20Sopenharmony_ci					   (si_pi->state_table_start + offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
21758c2ecf20Sopenharmony_ci						 offsetof(PP_SIslands_DPM2Parameters, TDPLimit)),
21768c2ecf20Sopenharmony_ci					   (u8 *)(&(smc_table->dpm2Params.TDPLimit)),
21778c2ecf20Sopenharmony_ci					   sizeof(u32) * 3,
21788c2ecf20Sopenharmony_ci					   si_pi->sram_end);
21798c2ecf20Sopenharmony_ci		if (ret)
21808c2ecf20Sopenharmony_ci			return ret;
21818c2ecf20Sopenharmony_ci
21828c2ecf20Sopenharmony_ci		if (si_pi->enable_ppm) {
21838c2ecf20Sopenharmony_ci			papm_parm = &si_pi->papm_parm;
21848c2ecf20Sopenharmony_ci			memset(papm_parm, 0, sizeof(PP_SIslands_PAPMParameters));
21858c2ecf20Sopenharmony_ci			papm_parm->NearTDPLimitTherm = cpu_to_be32(ppm->dgpu_tdp);
21868c2ecf20Sopenharmony_ci			papm_parm->dGPU_T_Limit = cpu_to_be32(ppm->tj_max);
21878c2ecf20Sopenharmony_ci			papm_parm->dGPU_T_Warning = cpu_to_be32(95);
21888c2ecf20Sopenharmony_ci			papm_parm->dGPU_T_Hysteresis = cpu_to_be32(5);
21898c2ecf20Sopenharmony_ci			papm_parm->PlatformPowerLimit = 0xffffffff;
21908c2ecf20Sopenharmony_ci			papm_parm->NearTDPLimitPAPM = 0xffffffff;
21918c2ecf20Sopenharmony_ci
21928c2ecf20Sopenharmony_ci			ret = si_copy_bytes_to_smc(rdev, si_pi->papm_cfg_table_start,
21938c2ecf20Sopenharmony_ci						   (u8 *)papm_parm,
21948c2ecf20Sopenharmony_ci						   sizeof(PP_SIslands_PAPMParameters),
21958c2ecf20Sopenharmony_ci						   si_pi->sram_end);
21968c2ecf20Sopenharmony_ci			if (ret)
21978c2ecf20Sopenharmony_ci				return ret;
21988c2ecf20Sopenharmony_ci		}
21998c2ecf20Sopenharmony_ci	}
22008c2ecf20Sopenharmony_ci	return 0;
22018c2ecf20Sopenharmony_ci}
22028c2ecf20Sopenharmony_ci
22038c2ecf20Sopenharmony_cistatic int si_populate_smc_tdp_limits_2(struct radeon_device *rdev,
22048c2ecf20Sopenharmony_ci					struct radeon_ps *radeon_state)
22058c2ecf20Sopenharmony_ci{
22068c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
22078c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
22088c2ecf20Sopenharmony_ci
22098c2ecf20Sopenharmony_ci	if (ni_pi->enable_power_containment) {
22108c2ecf20Sopenharmony_ci		SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
22118c2ecf20Sopenharmony_ci		u32 scaling_factor = si_get_smc_power_scaling_factor(rdev);
22128c2ecf20Sopenharmony_ci		int ret;
22138c2ecf20Sopenharmony_ci
22148c2ecf20Sopenharmony_ci		memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
22158c2ecf20Sopenharmony_ci
22168c2ecf20Sopenharmony_ci		smc_table->dpm2Params.NearTDPLimit =
22178c2ecf20Sopenharmony_ci			cpu_to_be32(si_scale_power_for_smc(rdev->pm.dpm.near_tdp_limit_adjusted, scaling_factor) * 1000);
22188c2ecf20Sopenharmony_ci		smc_table->dpm2Params.SafePowerLimit =
22198c2ecf20Sopenharmony_ci			cpu_to_be32(si_scale_power_for_smc((rdev->pm.dpm.near_tdp_limit_adjusted * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
22208c2ecf20Sopenharmony_ci
22218c2ecf20Sopenharmony_ci		ret = si_copy_bytes_to_smc(rdev,
22228c2ecf20Sopenharmony_ci					   (si_pi->state_table_start +
22238c2ecf20Sopenharmony_ci					    offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
22248c2ecf20Sopenharmony_ci					    offsetof(PP_SIslands_DPM2Parameters, NearTDPLimit)),
22258c2ecf20Sopenharmony_ci					   (u8 *)(&(smc_table->dpm2Params.NearTDPLimit)),
22268c2ecf20Sopenharmony_ci					   sizeof(u32) * 2,
22278c2ecf20Sopenharmony_ci					   si_pi->sram_end);
22288c2ecf20Sopenharmony_ci		if (ret)
22298c2ecf20Sopenharmony_ci			return ret;
22308c2ecf20Sopenharmony_ci	}
22318c2ecf20Sopenharmony_ci
22328c2ecf20Sopenharmony_ci	return 0;
22338c2ecf20Sopenharmony_ci}
22348c2ecf20Sopenharmony_ci
22358c2ecf20Sopenharmony_cistatic u16 si_calculate_power_efficiency_ratio(struct radeon_device *rdev,
22368c2ecf20Sopenharmony_ci					       const u16 prev_std_vddc,
22378c2ecf20Sopenharmony_ci					       const u16 curr_std_vddc)
22388c2ecf20Sopenharmony_ci{
22398c2ecf20Sopenharmony_ci	u64 margin = (u64)SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN;
22408c2ecf20Sopenharmony_ci	u64 prev_vddc = (u64)prev_std_vddc;
22418c2ecf20Sopenharmony_ci	u64 curr_vddc = (u64)curr_std_vddc;
22428c2ecf20Sopenharmony_ci	u64 pwr_efficiency_ratio, n, d;
22438c2ecf20Sopenharmony_ci
22448c2ecf20Sopenharmony_ci	if ((prev_vddc == 0) || (curr_vddc == 0))
22458c2ecf20Sopenharmony_ci		return 0;
22468c2ecf20Sopenharmony_ci
22478c2ecf20Sopenharmony_ci	n = div64_u64((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin), (u64)1000);
22488c2ecf20Sopenharmony_ci	d = prev_vddc * prev_vddc;
22498c2ecf20Sopenharmony_ci	pwr_efficiency_ratio = div64_u64(n, d);
22508c2ecf20Sopenharmony_ci
22518c2ecf20Sopenharmony_ci	if (pwr_efficiency_ratio > (u64)0xFFFF)
22528c2ecf20Sopenharmony_ci		return 0;
22538c2ecf20Sopenharmony_ci
22548c2ecf20Sopenharmony_ci	return (u16)pwr_efficiency_ratio;
22558c2ecf20Sopenharmony_ci}
22568c2ecf20Sopenharmony_ci
22578c2ecf20Sopenharmony_cistatic bool si_should_disable_uvd_powertune(struct radeon_device *rdev,
22588c2ecf20Sopenharmony_ci					    struct radeon_ps *radeon_state)
22598c2ecf20Sopenharmony_ci{
22608c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
22618c2ecf20Sopenharmony_ci
22628c2ecf20Sopenharmony_ci	if (si_pi->dyn_powertune_data.disable_uvd_powertune &&
22638c2ecf20Sopenharmony_ci	    radeon_state->vclk && radeon_state->dclk)
22648c2ecf20Sopenharmony_ci		return true;
22658c2ecf20Sopenharmony_ci
22668c2ecf20Sopenharmony_ci	return false;
22678c2ecf20Sopenharmony_ci}
22688c2ecf20Sopenharmony_ci
22698c2ecf20Sopenharmony_cistatic int si_populate_power_containment_values(struct radeon_device *rdev,
22708c2ecf20Sopenharmony_ci						struct radeon_ps *radeon_state,
22718c2ecf20Sopenharmony_ci						SISLANDS_SMC_SWSTATE *smc_state)
22728c2ecf20Sopenharmony_ci{
22738c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
22748c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
22758c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
22768c2ecf20Sopenharmony_ci	SISLANDS_SMC_VOLTAGE_VALUE vddc;
22778c2ecf20Sopenharmony_ci	u32 prev_sclk;
22788c2ecf20Sopenharmony_ci	u32 max_sclk;
22798c2ecf20Sopenharmony_ci	u32 min_sclk;
22808c2ecf20Sopenharmony_ci	u16 prev_std_vddc;
22818c2ecf20Sopenharmony_ci	u16 curr_std_vddc;
22828c2ecf20Sopenharmony_ci	int i;
22838c2ecf20Sopenharmony_ci	u16 pwr_efficiency_ratio;
22848c2ecf20Sopenharmony_ci	u8 max_ps_percent;
22858c2ecf20Sopenharmony_ci	bool disable_uvd_power_tune;
22868c2ecf20Sopenharmony_ci	int ret;
22878c2ecf20Sopenharmony_ci
22888c2ecf20Sopenharmony_ci	if (ni_pi->enable_power_containment == false)
22898c2ecf20Sopenharmony_ci		return 0;
22908c2ecf20Sopenharmony_ci
22918c2ecf20Sopenharmony_ci	if (state->performance_level_count == 0)
22928c2ecf20Sopenharmony_ci		return -EINVAL;
22938c2ecf20Sopenharmony_ci
22948c2ecf20Sopenharmony_ci	if (smc_state->levelCount != state->performance_level_count)
22958c2ecf20Sopenharmony_ci		return -EINVAL;
22968c2ecf20Sopenharmony_ci
22978c2ecf20Sopenharmony_ci	disable_uvd_power_tune = si_should_disable_uvd_powertune(rdev, radeon_state);
22988c2ecf20Sopenharmony_ci
22998c2ecf20Sopenharmony_ci	smc_state->levels[0].dpm2.MaxPS = 0;
23008c2ecf20Sopenharmony_ci	smc_state->levels[0].dpm2.NearTDPDec = 0;
23018c2ecf20Sopenharmony_ci	smc_state->levels[0].dpm2.AboveSafeInc = 0;
23028c2ecf20Sopenharmony_ci	smc_state->levels[0].dpm2.BelowSafeInc = 0;
23038c2ecf20Sopenharmony_ci	smc_state->levels[0].dpm2.PwrEfficiencyRatio = 0;
23048c2ecf20Sopenharmony_ci
23058c2ecf20Sopenharmony_ci	for (i = 1; i < state->performance_level_count; i++) {
23068c2ecf20Sopenharmony_ci		prev_sclk = state->performance_levels[i-1].sclk;
23078c2ecf20Sopenharmony_ci		max_sclk  = state->performance_levels[i].sclk;
23088c2ecf20Sopenharmony_ci		if (i == 1)
23098c2ecf20Sopenharmony_ci			max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_M;
23108c2ecf20Sopenharmony_ci		else
23118c2ecf20Sopenharmony_ci			max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_H;
23128c2ecf20Sopenharmony_ci
23138c2ecf20Sopenharmony_ci		if (prev_sclk > max_sclk)
23148c2ecf20Sopenharmony_ci			return -EINVAL;
23158c2ecf20Sopenharmony_ci
23168c2ecf20Sopenharmony_ci		if ((max_ps_percent == 0) ||
23178c2ecf20Sopenharmony_ci		    (prev_sclk == max_sclk) ||
23188c2ecf20Sopenharmony_ci		    disable_uvd_power_tune) {
23198c2ecf20Sopenharmony_ci			min_sclk = max_sclk;
23208c2ecf20Sopenharmony_ci		} else if (i == 1) {
23218c2ecf20Sopenharmony_ci			min_sclk = prev_sclk;
23228c2ecf20Sopenharmony_ci		} else {
23238c2ecf20Sopenharmony_ci			min_sclk = (prev_sclk * (u32)max_ps_percent) / 100;
23248c2ecf20Sopenharmony_ci		}
23258c2ecf20Sopenharmony_ci
23268c2ecf20Sopenharmony_ci		if (min_sclk < state->performance_levels[0].sclk)
23278c2ecf20Sopenharmony_ci			min_sclk = state->performance_levels[0].sclk;
23288c2ecf20Sopenharmony_ci
23298c2ecf20Sopenharmony_ci		if (min_sclk == 0)
23308c2ecf20Sopenharmony_ci			return -EINVAL;
23318c2ecf20Sopenharmony_ci
23328c2ecf20Sopenharmony_ci		ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
23338c2ecf20Sopenharmony_ci						state->performance_levels[i-1].vddc, &vddc);
23348c2ecf20Sopenharmony_ci		if (ret)
23358c2ecf20Sopenharmony_ci			return ret;
23368c2ecf20Sopenharmony_ci
23378c2ecf20Sopenharmony_ci		ret = si_get_std_voltage_value(rdev, &vddc, &prev_std_vddc);
23388c2ecf20Sopenharmony_ci		if (ret)
23398c2ecf20Sopenharmony_ci			return ret;
23408c2ecf20Sopenharmony_ci
23418c2ecf20Sopenharmony_ci		ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
23428c2ecf20Sopenharmony_ci						state->performance_levels[i].vddc, &vddc);
23438c2ecf20Sopenharmony_ci		if (ret)
23448c2ecf20Sopenharmony_ci			return ret;
23458c2ecf20Sopenharmony_ci
23468c2ecf20Sopenharmony_ci		ret = si_get_std_voltage_value(rdev, &vddc, &curr_std_vddc);
23478c2ecf20Sopenharmony_ci		if (ret)
23488c2ecf20Sopenharmony_ci			return ret;
23498c2ecf20Sopenharmony_ci
23508c2ecf20Sopenharmony_ci		pwr_efficiency_ratio = si_calculate_power_efficiency_ratio(rdev,
23518c2ecf20Sopenharmony_ci									   prev_std_vddc, curr_std_vddc);
23528c2ecf20Sopenharmony_ci
23538c2ecf20Sopenharmony_ci		smc_state->levels[i].dpm2.MaxPS = (u8)((SISLANDS_DPM2_MAX_PULSE_SKIP * (max_sclk - min_sclk)) / max_sclk);
23548c2ecf20Sopenharmony_ci		smc_state->levels[i].dpm2.NearTDPDec = SISLANDS_DPM2_NEAR_TDP_DEC;
23558c2ecf20Sopenharmony_ci		smc_state->levels[i].dpm2.AboveSafeInc = SISLANDS_DPM2_ABOVE_SAFE_INC;
23568c2ecf20Sopenharmony_ci		smc_state->levels[i].dpm2.BelowSafeInc = SISLANDS_DPM2_BELOW_SAFE_INC;
23578c2ecf20Sopenharmony_ci		smc_state->levels[i].dpm2.PwrEfficiencyRatio = cpu_to_be16(pwr_efficiency_ratio);
23588c2ecf20Sopenharmony_ci	}
23598c2ecf20Sopenharmony_ci
23608c2ecf20Sopenharmony_ci	return 0;
23618c2ecf20Sopenharmony_ci}
23628c2ecf20Sopenharmony_ci
23638c2ecf20Sopenharmony_cistatic int si_populate_sq_ramping_values(struct radeon_device *rdev,
23648c2ecf20Sopenharmony_ci					 struct radeon_ps *radeon_state,
23658c2ecf20Sopenharmony_ci					 SISLANDS_SMC_SWSTATE *smc_state)
23668c2ecf20Sopenharmony_ci{
23678c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
23688c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
23698c2ecf20Sopenharmony_ci	u32 sq_power_throttle, sq_power_throttle2;
23708c2ecf20Sopenharmony_ci	bool enable_sq_ramping = ni_pi->enable_sq_ramping;
23718c2ecf20Sopenharmony_ci	int i;
23728c2ecf20Sopenharmony_ci
23738c2ecf20Sopenharmony_ci	if (state->performance_level_count == 0)
23748c2ecf20Sopenharmony_ci		return -EINVAL;
23758c2ecf20Sopenharmony_ci
23768c2ecf20Sopenharmony_ci	if (smc_state->levelCount != state->performance_level_count)
23778c2ecf20Sopenharmony_ci		return -EINVAL;
23788c2ecf20Sopenharmony_ci
23798c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.sq_ramping_threshold == 0)
23808c2ecf20Sopenharmony_ci		return -EINVAL;
23818c2ecf20Sopenharmony_ci
23828c2ecf20Sopenharmony_ci	if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER > (MAX_POWER_MASK >> MAX_POWER_SHIFT))
23838c2ecf20Sopenharmony_ci		enable_sq_ramping = false;
23848c2ecf20Sopenharmony_ci
23858c2ecf20Sopenharmony_ci	if (SISLANDS_DPM2_SQ_RAMP_MIN_POWER > (MIN_POWER_MASK >> MIN_POWER_SHIFT))
23868c2ecf20Sopenharmony_ci		enable_sq_ramping = false;
23878c2ecf20Sopenharmony_ci
23888c2ecf20Sopenharmony_ci	if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA > (MAX_POWER_DELTA_MASK >> MAX_POWER_DELTA_SHIFT))
23898c2ecf20Sopenharmony_ci		enable_sq_ramping = false;
23908c2ecf20Sopenharmony_ci
23918c2ecf20Sopenharmony_ci	if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT))
23928c2ecf20Sopenharmony_ci		enable_sq_ramping = false;
23938c2ecf20Sopenharmony_ci
23948c2ecf20Sopenharmony_ci	if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT))
23958c2ecf20Sopenharmony_ci		enable_sq_ramping = false;
23968c2ecf20Sopenharmony_ci
23978c2ecf20Sopenharmony_ci	for (i = 0; i < state->performance_level_count; i++) {
23988c2ecf20Sopenharmony_ci		sq_power_throttle = 0;
23998c2ecf20Sopenharmony_ci		sq_power_throttle2 = 0;
24008c2ecf20Sopenharmony_ci
24018c2ecf20Sopenharmony_ci		if ((state->performance_levels[i].sclk >= rdev->pm.dpm.sq_ramping_threshold) &&
24028c2ecf20Sopenharmony_ci		    enable_sq_ramping) {
24038c2ecf20Sopenharmony_ci			sq_power_throttle |= MAX_POWER(SISLANDS_DPM2_SQ_RAMP_MAX_POWER);
24048c2ecf20Sopenharmony_ci			sq_power_throttle |= MIN_POWER(SISLANDS_DPM2_SQ_RAMP_MIN_POWER);
24058c2ecf20Sopenharmony_ci			sq_power_throttle2 |= MAX_POWER_DELTA(SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA);
24068c2ecf20Sopenharmony_ci			sq_power_throttle2 |= STI_SIZE(SISLANDS_DPM2_SQ_RAMP_STI_SIZE);
24078c2ecf20Sopenharmony_ci			sq_power_throttle2 |= LTI_RATIO(SISLANDS_DPM2_SQ_RAMP_LTI_RATIO);
24088c2ecf20Sopenharmony_ci		} else {
24098c2ecf20Sopenharmony_ci			sq_power_throttle |= MAX_POWER_MASK | MIN_POWER_MASK;
24108c2ecf20Sopenharmony_ci			sq_power_throttle2 |= MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
24118c2ecf20Sopenharmony_ci		}
24128c2ecf20Sopenharmony_ci
24138c2ecf20Sopenharmony_ci		smc_state->levels[i].SQPowerThrottle = cpu_to_be32(sq_power_throttle);
24148c2ecf20Sopenharmony_ci		smc_state->levels[i].SQPowerThrottle_2 = cpu_to_be32(sq_power_throttle2);
24158c2ecf20Sopenharmony_ci	}
24168c2ecf20Sopenharmony_ci
24178c2ecf20Sopenharmony_ci	return 0;
24188c2ecf20Sopenharmony_ci}
24198c2ecf20Sopenharmony_ci
24208c2ecf20Sopenharmony_cistatic int si_enable_power_containment(struct radeon_device *rdev,
24218c2ecf20Sopenharmony_ci				       struct radeon_ps *radeon_new_state,
24228c2ecf20Sopenharmony_ci				       bool enable)
24238c2ecf20Sopenharmony_ci{
24248c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
24258c2ecf20Sopenharmony_ci	PPSMC_Result smc_result;
24268c2ecf20Sopenharmony_ci	int ret = 0;
24278c2ecf20Sopenharmony_ci
24288c2ecf20Sopenharmony_ci	if (ni_pi->enable_power_containment) {
24298c2ecf20Sopenharmony_ci		if (enable) {
24308c2ecf20Sopenharmony_ci			if (!si_should_disable_uvd_powertune(rdev, radeon_new_state)) {
24318c2ecf20Sopenharmony_ci				smc_result = si_send_msg_to_smc(rdev, PPSMC_TDPClampingActive);
24328c2ecf20Sopenharmony_ci				if (smc_result != PPSMC_Result_OK) {
24338c2ecf20Sopenharmony_ci					ret = -EINVAL;
24348c2ecf20Sopenharmony_ci					ni_pi->pc_enabled = false;
24358c2ecf20Sopenharmony_ci				} else {
24368c2ecf20Sopenharmony_ci					ni_pi->pc_enabled = true;
24378c2ecf20Sopenharmony_ci				}
24388c2ecf20Sopenharmony_ci			}
24398c2ecf20Sopenharmony_ci		} else {
24408c2ecf20Sopenharmony_ci			smc_result = si_send_msg_to_smc(rdev, PPSMC_TDPClampingInactive);
24418c2ecf20Sopenharmony_ci			if (smc_result != PPSMC_Result_OK)
24428c2ecf20Sopenharmony_ci				ret = -EINVAL;
24438c2ecf20Sopenharmony_ci			ni_pi->pc_enabled = false;
24448c2ecf20Sopenharmony_ci		}
24458c2ecf20Sopenharmony_ci	}
24468c2ecf20Sopenharmony_ci
24478c2ecf20Sopenharmony_ci	return ret;
24488c2ecf20Sopenharmony_ci}
24498c2ecf20Sopenharmony_ci
24508c2ecf20Sopenharmony_cistatic int si_initialize_smc_dte_tables(struct radeon_device *rdev)
24518c2ecf20Sopenharmony_ci{
24528c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
24538c2ecf20Sopenharmony_ci	int ret = 0;
24548c2ecf20Sopenharmony_ci	struct si_dte_data *dte_data = &si_pi->dte_data;
24558c2ecf20Sopenharmony_ci	Smc_SIslands_DTE_Configuration *dte_tables = NULL;
24568c2ecf20Sopenharmony_ci	u32 table_size;
24578c2ecf20Sopenharmony_ci	u8 tdep_count;
24588c2ecf20Sopenharmony_ci	u32 i;
24598c2ecf20Sopenharmony_ci
24608c2ecf20Sopenharmony_ci	if (dte_data == NULL)
24618c2ecf20Sopenharmony_ci		si_pi->enable_dte = false;
24628c2ecf20Sopenharmony_ci
24638c2ecf20Sopenharmony_ci	if (si_pi->enable_dte == false)
24648c2ecf20Sopenharmony_ci		return 0;
24658c2ecf20Sopenharmony_ci
24668c2ecf20Sopenharmony_ci	if (dte_data->k <= 0)
24678c2ecf20Sopenharmony_ci		return -EINVAL;
24688c2ecf20Sopenharmony_ci
24698c2ecf20Sopenharmony_ci	dte_tables = kzalloc(sizeof(Smc_SIslands_DTE_Configuration), GFP_KERNEL);
24708c2ecf20Sopenharmony_ci	if (dte_tables == NULL) {
24718c2ecf20Sopenharmony_ci		si_pi->enable_dte = false;
24728c2ecf20Sopenharmony_ci		return -ENOMEM;
24738c2ecf20Sopenharmony_ci	}
24748c2ecf20Sopenharmony_ci
24758c2ecf20Sopenharmony_ci	table_size = dte_data->k;
24768c2ecf20Sopenharmony_ci
24778c2ecf20Sopenharmony_ci	if (table_size > SMC_SISLANDS_DTE_MAX_FILTER_STAGES)
24788c2ecf20Sopenharmony_ci		table_size = SMC_SISLANDS_DTE_MAX_FILTER_STAGES;
24798c2ecf20Sopenharmony_ci
24808c2ecf20Sopenharmony_ci	tdep_count = dte_data->tdep_count;
24818c2ecf20Sopenharmony_ci	if (tdep_count > SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE)
24828c2ecf20Sopenharmony_ci		tdep_count = SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE;
24838c2ecf20Sopenharmony_ci
24848c2ecf20Sopenharmony_ci	dte_tables->K = cpu_to_be32(table_size);
24858c2ecf20Sopenharmony_ci	dte_tables->T0 = cpu_to_be32(dte_data->t0);
24868c2ecf20Sopenharmony_ci	dte_tables->MaxT = cpu_to_be32(dte_data->max_t);
24878c2ecf20Sopenharmony_ci	dte_tables->WindowSize = dte_data->window_size;
24888c2ecf20Sopenharmony_ci	dte_tables->temp_select = dte_data->temp_select;
24898c2ecf20Sopenharmony_ci	dte_tables->DTE_mode = dte_data->dte_mode;
24908c2ecf20Sopenharmony_ci	dte_tables->Tthreshold = cpu_to_be32(dte_data->t_threshold);
24918c2ecf20Sopenharmony_ci
24928c2ecf20Sopenharmony_ci	if (tdep_count > 0)
24938c2ecf20Sopenharmony_ci		table_size--;
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci	for (i = 0; i < table_size; i++) {
24968c2ecf20Sopenharmony_ci		dte_tables->tau[i] = cpu_to_be32(dte_data->tau[i]);
24978c2ecf20Sopenharmony_ci		dte_tables->R[i]   = cpu_to_be32(dte_data->r[i]);
24988c2ecf20Sopenharmony_ci	}
24998c2ecf20Sopenharmony_ci
25008c2ecf20Sopenharmony_ci	dte_tables->Tdep_count = tdep_count;
25018c2ecf20Sopenharmony_ci
25028c2ecf20Sopenharmony_ci	for (i = 0; i < (u32)tdep_count; i++) {
25038c2ecf20Sopenharmony_ci		dte_tables->T_limits[i] = dte_data->t_limits[i];
25048c2ecf20Sopenharmony_ci		dte_tables->Tdep_tau[i] = cpu_to_be32(dte_data->tdep_tau[i]);
25058c2ecf20Sopenharmony_ci		dte_tables->Tdep_R[i] = cpu_to_be32(dte_data->tdep_r[i]);
25068c2ecf20Sopenharmony_ci	}
25078c2ecf20Sopenharmony_ci
25088c2ecf20Sopenharmony_ci	ret = si_copy_bytes_to_smc(rdev, si_pi->dte_table_start, (u8 *)dte_tables,
25098c2ecf20Sopenharmony_ci				   sizeof(Smc_SIslands_DTE_Configuration), si_pi->sram_end);
25108c2ecf20Sopenharmony_ci	kfree(dte_tables);
25118c2ecf20Sopenharmony_ci
25128c2ecf20Sopenharmony_ci	return ret;
25138c2ecf20Sopenharmony_ci}
25148c2ecf20Sopenharmony_ci
25158c2ecf20Sopenharmony_cistatic int si_get_cac_std_voltage_max_min(struct radeon_device *rdev,
25168c2ecf20Sopenharmony_ci					  u16 *max, u16 *min)
25178c2ecf20Sopenharmony_ci{
25188c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
25198c2ecf20Sopenharmony_ci	struct radeon_cac_leakage_table *table =
25208c2ecf20Sopenharmony_ci		&rdev->pm.dpm.dyn_state.cac_leakage_table;
25218c2ecf20Sopenharmony_ci	u32 i;
25228c2ecf20Sopenharmony_ci	u32 v0_loadline;
25238c2ecf20Sopenharmony_ci
25248c2ecf20Sopenharmony_ci
25258c2ecf20Sopenharmony_ci	if (table == NULL)
25268c2ecf20Sopenharmony_ci		return -EINVAL;
25278c2ecf20Sopenharmony_ci
25288c2ecf20Sopenharmony_ci	*max = 0;
25298c2ecf20Sopenharmony_ci	*min = 0xFFFF;
25308c2ecf20Sopenharmony_ci
25318c2ecf20Sopenharmony_ci	for (i = 0; i < table->count; i++) {
25328c2ecf20Sopenharmony_ci		if (table->entries[i].vddc > *max)
25338c2ecf20Sopenharmony_ci			*max = table->entries[i].vddc;
25348c2ecf20Sopenharmony_ci		if (table->entries[i].vddc < *min)
25358c2ecf20Sopenharmony_ci			*min = table->entries[i].vddc;
25368c2ecf20Sopenharmony_ci	}
25378c2ecf20Sopenharmony_ci
25388c2ecf20Sopenharmony_ci	if (si_pi->powertune_data->lkge_lut_v0_percent > 100)
25398c2ecf20Sopenharmony_ci		return -EINVAL;
25408c2ecf20Sopenharmony_ci
25418c2ecf20Sopenharmony_ci	v0_loadline = (*min) * (100 - si_pi->powertune_data->lkge_lut_v0_percent) / 100;
25428c2ecf20Sopenharmony_ci
25438c2ecf20Sopenharmony_ci	if (v0_loadline > 0xFFFFUL)
25448c2ecf20Sopenharmony_ci		return -EINVAL;
25458c2ecf20Sopenharmony_ci
25468c2ecf20Sopenharmony_ci	*min = (u16)v0_loadline;
25478c2ecf20Sopenharmony_ci
25488c2ecf20Sopenharmony_ci	if ((*min > *max) || (*max == 0) || (*min == 0))
25498c2ecf20Sopenharmony_ci		return -EINVAL;
25508c2ecf20Sopenharmony_ci
25518c2ecf20Sopenharmony_ci	return 0;
25528c2ecf20Sopenharmony_ci}
25538c2ecf20Sopenharmony_ci
25548c2ecf20Sopenharmony_cistatic u16 si_get_cac_std_voltage_step(u16 max, u16 min)
25558c2ecf20Sopenharmony_ci{
25568c2ecf20Sopenharmony_ci	return ((max - min) + (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1)) /
25578c2ecf20Sopenharmony_ci		SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES;
25588c2ecf20Sopenharmony_ci}
25598c2ecf20Sopenharmony_ci
25608c2ecf20Sopenharmony_cistatic int si_init_dte_leakage_table(struct radeon_device *rdev,
25618c2ecf20Sopenharmony_ci				     PP_SIslands_CacConfig *cac_tables,
25628c2ecf20Sopenharmony_ci				     u16 vddc_max, u16 vddc_min, u16 vddc_step,
25638c2ecf20Sopenharmony_ci				     u16 t0, u16 t_step)
25648c2ecf20Sopenharmony_ci{
25658c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
25668c2ecf20Sopenharmony_ci	u32 leakage;
25678c2ecf20Sopenharmony_ci	unsigned int i, j;
25688c2ecf20Sopenharmony_ci	s32 t;
25698c2ecf20Sopenharmony_ci	u32 smc_leakage;
25708c2ecf20Sopenharmony_ci	u32 scaling_factor;
25718c2ecf20Sopenharmony_ci	u16 voltage;
25728c2ecf20Sopenharmony_ci
25738c2ecf20Sopenharmony_ci	scaling_factor = si_get_smc_power_scaling_factor(rdev);
25748c2ecf20Sopenharmony_ci
25758c2ecf20Sopenharmony_ci	for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++) {
25768c2ecf20Sopenharmony_ci		t = (1000 * (i * t_step + t0));
25778c2ecf20Sopenharmony_ci
25788c2ecf20Sopenharmony_ci		for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
25798c2ecf20Sopenharmony_ci			voltage = vddc_max - (vddc_step * j);
25808c2ecf20Sopenharmony_ci
25818c2ecf20Sopenharmony_ci			si_calculate_leakage_for_v_and_t(rdev,
25828c2ecf20Sopenharmony_ci							 &si_pi->powertune_data->leakage_coefficients,
25838c2ecf20Sopenharmony_ci							 voltage,
25848c2ecf20Sopenharmony_ci							 t,
25858c2ecf20Sopenharmony_ci							 si_pi->dyn_powertune_data.cac_leakage,
25868c2ecf20Sopenharmony_ci							 &leakage);
25878c2ecf20Sopenharmony_ci
25888c2ecf20Sopenharmony_ci			smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
25898c2ecf20Sopenharmony_ci
25908c2ecf20Sopenharmony_ci			if (smc_leakage > 0xFFFF)
25918c2ecf20Sopenharmony_ci				smc_leakage = 0xFFFF;
25928c2ecf20Sopenharmony_ci
25938c2ecf20Sopenharmony_ci			cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
25948c2ecf20Sopenharmony_ci				cpu_to_be16((u16)smc_leakage);
25958c2ecf20Sopenharmony_ci		}
25968c2ecf20Sopenharmony_ci	}
25978c2ecf20Sopenharmony_ci	return 0;
25988c2ecf20Sopenharmony_ci}
25998c2ecf20Sopenharmony_ci
26008c2ecf20Sopenharmony_cistatic int si_init_simplified_leakage_table(struct radeon_device *rdev,
26018c2ecf20Sopenharmony_ci					    PP_SIslands_CacConfig *cac_tables,
26028c2ecf20Sopenharmony_ci					    u16 vddc_max, u16 vddc_min, u16 vddc_step)
26038c2ecf20Sopenharmony_ci{
26048c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
26058c2ecf20Sopenharmony_ci	u32 leakage;
26068c2ecf20Sopenharmony_ci	unsigned int i, j;
26078c2ecf20Sopenharmony_ci	u32 smc_leakage;
26088c2ecf20Sopenharmony_ci	u32 scaling_factor;
26098c2ecf20Sopenharmony_ci	u16 voltage;
26108c2ecf20Sopenharmony_ci
26118c2ecf20Sopenharmony_ci	scaling_factor = si_get_smc_power_scaling_factor(rdev);
26128c2ecf20Sopenharmony_ci
26138c2ecf20Sopenharmony_ci	for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
26148c2ecf20Sopenharmony_ci		voltage = vddc_max - (vddc_step * j);
26158c2ecf20Sopenharmony_ci
26168c2ecf20Sopenharmony_ci		si_calculate_leakage_for_v(rdev,
26178c2ecf20Sopenharmony_ci					   &si_pi->powertune_data->leakage_coefficients,
26188c2ecf20Sopenharmony_ci					   si_pi->powertune_data->fixed_kt,
26198c2ecf20Sopenharmony_ci					   voltage,
26208c2ecf20Sopenharmony_ci					   si_pi->dyn_powertune_data.cac_leakage,
26218c2ecf20Sopenharmony_ci					   &leakage);
26228c2ecf20Sopenharmony_ci
26238c2ecf20Sopenharmony_ci		smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
26248c2ecf20Sopenharmony_ci
26258c2ecf20Sopenharmony_ci		if (smc_leakage > 0xFFFF)
26268c2ecf20Sopenharmony_ci			smc_leakage = 0xFFFF;
26278c2ecf20Sopenharmony_ci
26288c2ecf20Sopenharmony_ci		for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++)
26298c2ecf20Sopenharmony_ci			cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
26308c2ecf20Sopenharmony_ci				cpu_to_be16((u16)smc_leakage);
26318c2ecf20Sopenharmony_ci	}
26328c2ecf20Sopenharmony_ci	return 0;
26338c2ecf20Sopenharmony_ci}
26348c2ecf20Sopenharmony_ci
26358c2ecf20Sopenharmony_cistatic int si_initialize_smc_cac_tables(struct radeon_device *rdev)
26368c2ecf20Sopenharmony_ci{
26378c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
26388c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
26398c2ecf20Sopenharmony_ci	PP_SIslands_CacConfig *cac_tables = NULL;
26408c2ecf20Sopenharmony_ci	u16 vddc_max, vddc_min, vddc_step;
26418c2ecf20Sopenharmony_ci	u16 t0, t_step;
26428c2ecf20Sopenharmony_ci	u32 load_line_slope, reg;
26438c2ecf20Sopenharmony_ci	int ret = 0;
26448c2ecf20Sopenharmony_ci	u32 ticks_per_us = radeon_get_xclk(rdev) / 100;
26458c2ecf20Sopenharmony_ci
26468c2ecf20Sopenharmony_ci	if (ni_pi->enable_cac == false)
26478c2ecf20Sopenharmony_ci		return 0;
26488c2ecf20Sopenharmony_ci
26498c2ecf20Sopenharmony_ci	cac_tables = kzalloc(sizeof(PP_SIslands_CacConfig), GFP_KERNEL);
26508c2ecf20Sopenharmony_ci	if (!cac_tables)
26518c2ecf20Sopenharmony_ci		return -ENOMEM;
26528c2ecf20Sopenharmony_ci
26538c2ecf20Sopenharmony_ci	reg = RREG32(CG_CAC_CTRL) & ~CAC_WINDOW_MASK;
26548c2ecf20Sopenharmony_ci	reg |= CAC_WINDOW(si_pi->powertune_data->cac_window);
26558c2ecf20Sopenharmony_ci	WREG32(CG_CAC_CTRL, reg);
26568c2ecf20Sopenharmony_ci
26578c2ecf20Sopenharmony_ci	si_pi->dyn_powertune_data.cac_leakage = rdev->pm.dpm.cac_leakage;
26588c2ecf20Sopenharmony_ci	si_pi->dyn_powertune_data.dc_pwr_value =
26598c2ecf20Sopenharmony_ci		si_pi->powertune_data->dc_cac[NISLANDS_DCCAC_LEVEL_0];
26608c2ecf20Sopenharmony_ci	si_pi->dyn_powertune_data.wintime = si_calculate_cac_wintime(rdev);
26618c2ecf20Sopenharmony_ci	si_pi->dyn_powertune_data.shift_n = si_pi->powertune_data->shift_n_default;
26628c2ecf20Sopenharmony_ci
26638c2ecf20Sopenharmony_ci	si_pi->dyn_powertune_data.leakage_minimum_temperature = 80 * 1000;
26648c2ecf20Sopenharmony_ci
26658c2ecf20Sopenharmony_ci	ret = si_get_cac_std_voltage_max_min(rdev, &vddc_max, &vddc_min);
26668c2ecf20Sopenharmony_ci	if (ret)
26678c2ecf20Sopenharmony_ci		goto done_free;
26688c2ecf20Sopenharmony_ci
26698c2ecf20Sopenharmony_ci	vddc_step = si_get_cac_std_voltage_step(vddc_max, vddc_min);
26708c2ecf20Sopenharmony_ci	vddc_min = vddc_max - (vddc_step * (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1));
26718c2ecf20Sopenharmony_ci	t_step = 4;
26728c2ecf20Sopenharmony_ci	t0 = 60;
26738c2ecf20Sopenharmony_ci
26748c2ecf20Sopenharmony_ci	if (si_pi->enable_dte || ni_pi->driver_calculate_cac_leakage)
26758c2ecf20Sopenharmony_ci		ret = si_init_dte_leakage_table(rdev, cac_tables,
26768c2ecf20Sopenharmony_ci						vddc_max, vddc_min, vddc_step,
26778c2ecf20Sopenharmony_ci						t0, t_step);
26788c2ecf20Sopenharmony_ci	else
26798c2ecf20Sopenharmony_ci		ret = si_init_simplified_leakage_table(rdev, cac_tables,
26808c2ecf20Sopenharmony_ci						       vddc_max, vddc_min, vddc_step);
26818c2ecf20Sopenharmony_ci	if (ret)
26828c2ecf20Sopenharmony_ci		goto done_free;
26838c2ecf20Sopenharmony_ci
26848c2ecf20Sopenharmony_ci	load_line_slope = ((u32)rdev->pm.dpm.load_line_slope << SMC_SISLANDS_SCALE_R) / 100;
26858c2ecf20Sopenharmony_ci
26868c2ecf20Sopenharmony_ci	cac_tables->l2numWin_TDP = cpu_to_be32(si_pi->dyn_powertune_data.l2_lta_window_size);
26878c2ecf20Sopenharmony_ci	cac_tables->lts_truncate_n = si_pi->dyn_powertune_data.lts_truncate;
26888c2ecf20Sopenharmony_ci	cac_tables->SHIFT_N = si_pi->dyn_powertune_data.shift_n;
26898c2ecf20Sopenharmony_ci	cac_tables->lkge_lut_V0 = cpu_to_be32((u32)vddc_min);
26908c2ecf20Sopenharmony_ci	cac_tables->lkge_lut_Vstep = cpu_to_be32((u32)vddc_step);
26918c2ecf20Sopenharmony_ci	cac_tables->R_LL = cpu_to_be32(load_line_slope);
26928c2ecf20Sopenharmony_ci	cac_tables->WinTime = cpu_to_be32(si_pi->dyn_powertune_data.wintime);
26938c2ecf20Sopenharmony_ci	cac_tables->calculation_repeats = cpu_to_be32(2);
26948c2ecf20Sopenharmony_ci	cac_tables->dc_cac = cpu_to_be32(0);
26958c2ecf20Sopenharmony_ci	cac_tables->log2_PG_LKG_SCALE = 12;
26968c2ecf20Sopenharmony_ci	cac_tables->cac_temp = si_pi->powertune_data->operating_temp;
26978c2ecf20Sopenharmony_ci	cac_tables->lkge_lut_T0 = cpu_to_be32((u32)t0);
26988c2ecf20Sopenharmony_ci	cac_tables->lkge_lut_Tstep = cpu_to_be32((u32)t_step);
26998c2ecf20Sopenharmony_ci
27008c2ecf20Sopenharmony_ci	ret = si_copy_bytes_to_smc(rdev, si_pi->cac_table_start, (u8 *)cac_tables,
27018c2ecf20Sopenharmony_ci				   sizeof(PP_SIslands_CacConfig), si_pi->sram_end);
27028c2ecf20Sopenharmony_ci
27038c2ecf20Sopenharmony_ci	if (ret)
27048c2ecf20Sopenharmony_ci		goto done_free;
27058c2ecf20Sopenharmony_ci
27068c2ecf20Sopenharmony_ci	ret = si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_ticks_per_us, ticks_per_us);
27078c2ecf20Sopenharmony_ci
27088c2ecf20Sopenharmony_cidone_free:
27098c2ecf20Sopenharmony_ci	if (ret) {
27108c2ecf20Sopenharmony_ci		ni_pi->enable_cac = false;
27118c2ecf20Sopenharmony_ci		ni_pi->enable_power_containment = false;
27128c2ecf20Sopenharmony_ci	}
27138c2ecf20Sopenharmony_ci
27148c2ecf20Sopenharmony_ci	kfree(cac_tables);
27158c2ecf20Sopenharmony_ci
27168c2ecf20Sopenharmony_ci	return 0;
27178c2ecf20Sopenharmony_ci}
27188c2ecf20Sopenharmony_ci
27198c2ecf20Sopenharmony_cistatic int si_program_cac_config_registers(struct radeon_device *rdev,
27208c2ecf20Sopenharmony_ci					   const struct si_cac_config_reg *cac_config_regs)
27218c2ecf20Sopenharmony_ci{
27228c2ecf20Sopenharmony_ci	const struct si_cac_config_reg *config_regs = cac_config_regs;
27238c2ecf20Sopenharmony_ci	u32 data = 0, offset;
27248c2ecf20Sopenharmony_ci
27258c2ecf20Sopenharmony_ci	if (!config_regs)
27268c2ecf20Sopenharmony_ci		return -EINVAL;
27278c2ecf20Sopenharmony_ci
27288c2ecf20Sopenharmony_ci	while (config_regs->offset != 0xFFFFFFFF) {
27298c2ecf20Sopenharmony_ci		switch (config_regs->type) {
27308c2ecf20Sopenharmony_ci		case SISLANDS_CACCONFIG_CGIND:
27318c2ecf20Sopenharmony_ci			offset = SMC_CG_IND_START + config_regs->offset;
27328c2ecf20Sopenharmony_ci			if (offset < SMC_CG_IND_END)
27338c2ecf20Sopenharmony_ci				data = RREG32_SMC(offset);
27348c2ecf20Sopenharmony_ci			break;
27358c2ecf20Sopenharmony_ci		default:
27368c2ecf20Sopenharmony_ci			data = RREG32(config_regs->offset << 2);
27378c2ecf20Sopenharmony_ci			break;
27388c2ecf20Sopenharmony_ci		}
27398c2ecf20Sopenharmony_ci
27408c2ecf20Sopenharmony_ci		data &= ~config_regs->mask;
27418c2ecf20Sopenharmony_ci		data |= ((config_regs->value << config_regs->shift) & config_regs->mask);
27428c2ecf20Sopenharmony_ci
27438c2ecf20Sopenharmony_ci		switch (config_regs->type) {
27448c2ecf20Sopenharmony_ci		case SISLANDS_CACCONFIG_CGIND:
27458c2ecf20Sopenharmony_ci			offset = SMC_CG_IND_START + config_regs->offset;
27468c2ecf20Sopenharmony_ci			if (offset < SMC_CG_IND_END)
27478c2ecf20Sopenharmony_ci				WREG32_SMC(offset, data);
27488c2ecf20Sopenharmony_ci			break;
27498c2ecf20Sopenharmony_ci		default:
27508c2ecf20Sopenharmony_ci			WREG32(config_regs->offset << 2, data);
27518c2ecf20Sopenharmony_ci			break;
27528c2ecf20Sopenharmony_ci		}
27538c2ecf20Sopenharmony_ci		config_regs++;
27548c2ecf20Sopenharmony_ci	}
27558c2ecf20Sopenharmony_ci	return 0;
27568c2ecf20Sopenharmony_ci}
27578c2ecf20Sopenharmony_ci
27588c2ecf20Sopenharmony_cistatic int si_initialize_hardware_cac_manager(struct radeon_device *rdev)
27598c2ecf20Sopenharmony_ci{
27608c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
27618c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
27628c2ecf20Sopenharmony_ci	int ret;
27638c2ecf20Sopenharmony_ci
27648c2ecf20Sopenharmony_ci	if ((ni_pi->enable_cac == false) ||
27658c2ecf20Sopenharmony_ci	    (ni_pi->cac_configuration_required == false))
27668c2ecf20Sopenharmony_ci		return 0;
27678c2ecf20Sopenharmony_ci
27688c2ecf20Sopenharmony_ci	ret = si_program_cac_config_registers(rdev, si_pi->lcac_config);
27698c2ecf20Sopenharmony_ci	if (ret)
27708c2ecf20Sopenharmony_ci		return ret;
27718c2ecf20Sopenharmony_ci	ret = si_program_cac_config_registers(rdev, si_pi->cac_override);
27728c2ecf20Sopenharmony_ci	if (ret)
27738c2ecf20Sopenharmony_ci		return ret;
27748c2ecf20Sopenharmony_ci	ret = si_program_cac_config_registers(rdev, si_pi->cac_weights);
27758c2ecf20Sopenharmony_ci	if (ret)
27768c2ecf20Sopenharmony_ci		return ret;
27778c2ecf20Sopenharmony_ci
27788c2ecf20Sopenharmony_ci	return 0;
27798c2ecf20Sopenharmony_ci}
27808c2ecf20Sopenharmony_ci
27818c2ecf20Sopenharmony_cistatic int si_enable_smc_cac(struct radeon_device *rdev,
27828c2ecf20Sopenharmony_ci			     struct radeon_ps *radeon_new_state,
27838c2ecf20Sopenharmony_ci			     bool enable)
27848c2ecf20Sopenharmony_ci{
27858c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
27868c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
27878c2ecf20Sopenharmony_ci	PPSMC_Result smc_result;
27888c2ecf20Sopenharmony_ci	int ret = 0;
27898c2ecf20Sopenharmony_ci
27908c2ecf20Sopenharmony_ci	if (ni_pi->enable_cac) {
27918c2ecf20Sopenharmony_ci		if (enable) {
27928c2ecf20Sopenharmony_ci			if (!si_should_disable_uvd_powertune(rdev, radeon_new_state)) {
27938c2ecf20Sopenharmony_ci				if (ni_pi->support_cac_long_term_average) {
27948c2ecf20Sopenharmony_ci					smc_result = si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgEnable);
27958c2ecf20Sopenharmony_ci					if (smc_result != PPSMC_Result_OK)
27968c2ecf20Sopenharmony_ci						ni_pi->support_cac_long_term_average = false;
27978c2ecf20Sopenharmony_ci				}
27988c2ecf20Sopenharmony_ci
27998c2ecf20Sopenharmony_ci				smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableCac);
28008c2ecf20Sopenharmony_ci				if (smc_result != PPSMC_Result_OK) {
28018c2ecf20Sopenharmony_ci					ret = -EINVAL;
28028c2ecf20Sopenharmony_ci					ni_pi->cac_enabled = false;
28038c2ecf20Sopenharmony_ci				} else {
28048c2ecf20Sopenharmony_ci					ni_pi->cac_enabled = true;
28058c2ecf20Sopenharmony_ci				}
28068c2ecf20Sopenharmony_ci
28078c2ecf20Sopenharmony_ci				if (si_pi->enable_dte) {
28088c2ecf20Sopenharmony_ci					smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableDTE);
28098c2ecf20Sopenharmony_ci					if (smc_result != PPSMC_Result_OK)
28108c2ecf20Sopenharmony_ci						ret = -EINVAL;
28118c2ecf20Sopenharmony_ci				}
28128c2ecf20Sopenharmony_ci			}
28138c2ecf20Sopenharmony_ci		} else if (ni_pi->cac_enabled) {
28148c2ecf20Sopenharmony_ci			if (si_pi->enable_dte)
28158c2ecf20Sopenharmony_ci				smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableDTE);
28168c2ecf20Sopenharmony_ci
28178c2ecf20Sopenharmony_ci			smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableCac);
28188c2ecf20Sopenharmony_ci
28198c2ecf20Sopenharmony_ci			ni_pi->cac_enabled = false;
28208c2ecf20Sopenharmony_ci
28218c2ecf20Sopenharmony_ci			if (ni_pi->support_cac_long_term_average)
28228c2ecf20Sopenharmony_ci				smc_result = si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgDisable);
28238c2ecf20Sopenharmony_ci		}
28248c2ecf20Sopenharmony_ci	}
28258c2ecf20Sopenharmony_ci	return ret;
28268c2ecf20Sopenharmony_ci}
28278c2ecf20Sopenharmony_ci
28288c2ecf20Sopenharmony_cistatic int si_init_smc_spll_table(struct radeon_device *rdev)
28298c2ecf20Sopenharmony_ci{
28308c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
28318c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
28328c2ecf20Sopenharmony_ci	SMC_SISLANDS_SPLL_DIV_TABLE *spll_table;
28338c2ecf20Sopenharmony_ci	SISLANDS_SMC_SCLK_VALUE sclk_params;
28348c2ecf20Sopenharmony_ci	u32 fb_div, p_div;
28358c2ecf20Sopenharmony_ci	u32 clk_s, clk_v;
28368c2ecf20Sopenharmony_ci	u32 sclk = 0;
28378c2ecf20Sopenharmony_ci	int ret = 0;
28388c2ecf20Sopenharmony_ci	u32 tmp;
28398c2ecf20Sopenharmony_ci	int i;
28408c2ecf20Sopenharmony_ci
28418c2ecf20Sopenharmony_ci	if (si_pi->spll_table_start == 0)
28428c2ecf20Sopenharmony_ci		return -EINVAL;
28438c2ecf20Sopenharmony_ci
28448c2ecf20Sopenharmony_ci	spll_table = kzalloc(sizeof(SMC_SISLANDS_SPLL_DIV_TABLE), GFP_KERNEL);
28458c2ecf20Sopenharmony_ci	if (spll_table == NULL)
28468c2ecf20Sopenharmony_ci		return -ENOMEM;
28478c2ecf20Sopenharmony_ci
28488c2ecf20Sopenharmony_ci	for (i = 0; i < 256; i++) {
28498c2ecf20Sopenharmony_ci		ret = si_calculate_sclk_params(rdev, sclk, &sclk_params);
28508c2ecf20Sopenharmony_ci		if (ret)
28518c2ecf20Sopenharmony_ci			break;
28528c2ecf20Sopenharmony_ci
28538c2ecf20Sopenharmony_ci		p_div = (sclk_params.vCG_SPLL_FUNC_CNTL & SPLL_PDIV_A_MASK) >> SPLL_PDIV_A_SHIFT;
28548c2ecf20Sopenharmony_ci		fb_div = (sclk_params.vCG_SPLL_FUNC_CNTL_3 & SPLL_FB_DIV_MASK) >> SPLL_FB_DIV_SHIFT;
28558c2ecf20Sopenharmony_ci		clk_s = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM & CLK_S_MASK) >> CLK_S_SHIFT;
28568c2ecf20Sopenharmony_ci		clk_v = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM_2 & CLK_V_MASK) >> CLK_V_SHIFT;
28578c2ecf20Sopenharmony_ci
28588c2ecf20Sopenharmony_ci		fb_div &= ~0x00001FFF;
28598c2ecf20Sopenharmony_ci		fb_div >>= 1;
28608c2ecf20Sopenharmony_ci		clk_v >>= 6;
28618c2ecf20Sopenharmony_ci
28628c2ecf20Sopenharmony_ci		if (p_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT))
28638c2ecf20Sopenharmony_ci			ret = -EINVAL;
28648c2ecf20Sopenharmony_ci		if (fb_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT))
28658c2ecf20Sopenharmony_ci			ret = -EINVAL;
28668c2ecf20Sopenharmony_ci		if (clk_s & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT))
28678c2ecf20Sopenharmony_ci			ret = -EINVAL;
28688c2ecf20Sopenharmony_ci		if (clk_v & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT))
28698c2ecf20Sopenharmony_ci			ret = -EINVAL;
28708c2ecf20Sopenharmony_ci
28718c2ecf20Sopenharmony_ci		if (ret)
28728c2ecf20Sopenharmony_ci			break;
28738c2ecf20Sopenharmony_ci
28748c2ecf20Sopenharmony_ci		tmp = ((fb_div << SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK) |
28758c2ecf20Sopenharmony_ci			((p_div << SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK);
28768c2ecf20Sopenharmony_ci		spll_table->freq[i] = cpu_to_be32(tmp);
28778c2ecf20Sopenharmony_ci
28788c2ecf20Sopenharmony_ci		tmp = ((clk_v << SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK) |
28798c2ecf20Sopenharmony_ci			((clk_s << SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK);
28808c2ecf20Sopenharmony_ci		spll_table->ss[i] = cpu_to_be32(tmp);
28818c2ecf20Sopenharmony_ci
28828c2ecf20Sopenharmony_ci		sclk += 512;
28838c2ecf20Sopenharmony_ci	}
28848c2ecf20Sopenharmony_ci
28858c2ecf20Sopenharmony_ci
28868c2ecf20Sopenharmony_ci	if (!ret)
28878c2ecf20Sopenharmony_ci		ret = si_copy_bytes_to_smc(rdev, si_pi->spll_table_start,
28888c2ecf20Sopenharmony_ci					   (u8 *)spll_table, sizeof(SMC_SISLANDS_SPLL_DIV_TABLE),
28898c2ecf20Sopenharmony_ci					   si_pi->sram_end);
28908c2ecf20Sopenharmony_ci
28918c2ecf20Sopenharmony_ci	if (ret)
28928c2ecf20Sopenharmony_ci		ni_pi->enable_power_containment = false;
28938c2ecf20Sopenharmony_ci
28948c2ecf20Sopenharmony_ci	kfree(spll_table);
28958c2ecf20Sopenharmony_ci
28968c2ecf20Sopenharmony_ci	return ret;
28978c2ecf20Sopenharmony_ci}
28988c2ecf20Sopenharmony_ci
28998c2ecf20Sopenharmony_cistatic u16 si_get_lower_of_leakage_and_vce_voltage(struct radeon_device *rdev,
29008c2ecf20Sopenharmony_ci						   u16 vce_voltage)
29018c2ecf20Sopenharmony_ci{
29028c2ecf20Sopenharmony_ci	u16 highest_leakage = 0;
29038c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
29048c2ecf20Sopenharmony_ci	int i;
29058c2ecf20Sopenharmony_ci
29068c2ecf20Sopenharmony_ci	for (i = 0; i < si_pi->leakage_voltage.count; i++){
29078c2ecf20Sopenharmony_ci		if (highest_leakage < si_pi->leakage_voltage.entries[i].voltage)
29088c2ecf20Sopenharmony_ci			highest_leakage = si_pi->leakage_voltage.entries[i].voltage;
29098c2ecf20Sopenharmony_ci	}
29108c2ecf20Sopenharmony_ci
29118c2ecf20Sopenharmony_ci	if (si_pi->leakage_voltage.count && (highest_leakage < vce_voltage))
29128c2ecf20Sopenharmony_ci		return highest_leakage;
29138c2ecf20Sopenharmony_ci
29148c2ecf20Sopenharmony_ci	return vce_voltage;
29158c2ecf20Sopenharmony_ci}
29168c2ecf20Sopenharmony_ci
29178c2ecf20Sopenharmony_cistatic int si_get_vce_clock_voltage(struct radeon_device *rdev,
29188c2ecf20Sopenharmony_ci				    u32 evclk, u32 ecclk, u16 *voltage)
29198c2ecf20Sopenharmony_ci{
29208c2ecf20Sopenharmony_ci	u32 i;
29218c2ecf20Sopenharmony_ci	int ret = -EINVAL;
29228c2ecf20Sopenharmony_ci	struct radeon_vce_clock_voltage_dependency_table *table =
29238c2ecf20Sopenharmony_ci		&rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
29248c2ecf20Sopenharmony_ci
29258c2ecf20Sopenharmony_ci	if (((evclk == 0) && (ecclk == 0)) ||
29268c2ecf20Sopenharmony_ci	    (table && (table->count == 0))) {
29278c2ecf20Sopenharmony_ci		*voltage = 0;
29288c2ecf20Sopenharmony_ci		return 0;
29298c2ecf20Sopenharmony_ci	}
29308c2ecf20Sopenharmony_ci
29318c2ecf20Sopenharmony_ci	for (i = 0; i < table->count; i++) {
29328c2ecf20Sopenharmony_ci		if ((evclk <= table->entries[i].evclk) &&
29338c2ecf20Sopenharmony_ci		    (ecclk <= table->entries[i].ecclk)) {
29348c2ecf20Sopenharmony_ci			*voltage = table->entries[i].v;
29358c2ecf20Sopenharmony_ci			ret = 0;
29368c2ecf20Sopenharmony_ci			break;
29378c2ecf20Sopenharmony_ci		}
29388c2ecf20Sopenharmony_ci	}
29398c2ecf20Sopenharmony_ci
29408c2ecf20Sopenharmony_ci	/* if no match return the highest voltage */
29418c2ecf20Sopenharmony_ci	if (ret)
29428c2ecf20Sopenharmony_ci		*voltage = table->entries[table->count - 1].v;
29438c2ecf20Sopenharmony_ci
29448c2ecf20Sopenharmony_ci	*voltage = si_get_lower_of_leakage_and_vce_voltage(rdev, *voltage);
29458c2ecf20Sopenharmony_ci
29468c2ecf20Sopenharmony_ci	return ret;
29478c2ecf20Sopenharmony_ci}
29488c2ecf20Sopenharmony_ci
29498c2ecf20Sopenharmony_cistatic void si_apply_state_adjust_rules(struct radeon_device *rdev,
29508c2ecf20Sopenharmony_ci					struct radeon_ps *rps)
29518c2ecf20Sopenharmony_ci{
29528c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(rps);
29538c2ecf20Sopenharmony_ci	struct radeon_clock_and_voltage_limits *max_limits;
29548c2ecf20Sopenharmony_ci	bool disable_mclk_switching = false;
29558c2ecf20Sopenharmony_ci	bool disable_sclk_switching = false;
29568c2ecf20Sopenharmony_ci	u32 mclk, sclk;
29578c2ecf20Sopenharmony_ci	u16 vddc, vddci, min_vce_voltage = 0;
29588c2ecf20Sopenharmony_ci	u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
29598c2ecf20Sopenharmony_ci	u32 max_sclk = 0, max_mclk = 0;
29608c2ecf20Sopenharmony_ci	int i;
29618c2ecf20Sopenharmony_ci
29628c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_HAINAN) {
29638c2ecf20Sopenharmony_ci		if ((rdev->pdev->revision == 0x81) ||
29648c2ecf20Sopenharmony_ci		    (rdev->pdev->revision == 0xC3) ||
29658c2ecf20Sopenharmony_ci		    (rdev->pdev->device == 0x6664) ||
29668c2ecf20Sopenharmony_ci		    (rdev->pdev->device == 0x6665) ||
29678c2ecf20Sopenharmony_ci		    (rdev->pdev->device == 0x6667)) {
29688c2ecf20Sopenharmony_ci			max_sclk = 75000;
29698c2ecf20Sopenharmony_ci		}
29708c2ecf20Sopenharmony_ci		if ((rdev->pdev->revision == 0xC3) ||
29718c2ecf20Sopenharmony_ci		    (rdev->pdev->device == 0x6665)) {
29728c2ecf20Sopenharmony_ci			max_sclk = 60000;
29738c2ecf20Sopenharmony_ci			max_mclk = 80000;
29748c2ecf20Sopenharmony_ci		}
29758c2ecf20Sopenharmony_ci	} else if (rdev->family == CHIP_OLAND) {
29768c2ecf20Sopenharmony_ci		if ((rdev->pdev->revision == 0xC7) ||
29778c2ecf20Sopenharmony_ci		    (rdev->pdev->revision == 0x80) ||
29788c2ecf20Sopenharmony_ci		    (rdev->pdev->revision == 0x81) ||
29798c2ecf20Sopenharmony_ci		    (rdev->pdev->revision == 0x83) ||
29808c2ecf20Sopenharmony_ci		    (rdev->pdev->revision == 0x87) ||
29818c2ecf20Sopenharmony_ci		    (rdev->pdev->device == 0x6604) ||
29828c2ecf20Sopenharmony_ci		    (rdev->pdev->device == 0x6605)) {
29838c2ecf20Sopenharmony_ci			max_sclk = 75000;
29848c2ecf20Sopenharmony_ci		}
29858c2ecf20Sopenharmony_ci
29868c2ecf20Sopenharmony_ci		if (rdev->pm.dpm.high_pixelclock_count > 1)
29878c2ecf20Sopenharmony_ci			disable_sclk_switching = true;
29888c2ecf20Sopenharmony_ci	}
29898c2ecf20Sopenharmony_ci
29908c2ecf20Sopenharmony_ci	if (rps->vce_active) {
29918c2ecf20Sopenharmony_ci		rps->evclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].evclk;
29928c2ecf20Sopenharmony_ci		rps->ecclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].ecclk;
29938c2ecf20Sopenharmony_ci		si_get_vce_clock_voltage(rdev, rps->evclk, rps->ecclk,
29948c2ecf20Sopenharmony_ci					 &min_vce_voltage);
29958c2ecf20Sopenharmony_ci	} else {
29968c2ecf20Sopenharmony_ci		rps->evclk = 0;
29978c2ecf20Sopenharmony_ci		rps->ecclk = 0;
29988c2ecf20Sopenharmony_ci	}
29998c2ecf20Sopenharmony_ci
30008c2ecf20Sopenharmony_ci	if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
30018c2ecf20Sopenharmony_ci	    ni_dpm_vblank_too_short(rdev))
30028c2ecf20Sopenharmony_ci		disable_mclk_switching = true;
30038c2ecf20Sopenharmony_ci
30048c2ecf20Sopenharmony_ci	if (rps->vclk || rps->dclk) {
30058c2ecf20Sopenharmony_ci		disable_mclk_switching = true;
30068c2ecf20Sopenharmony_ci		disable_sclk_switching = true;
30078c2ecf20Sopenharmony_ci	}
30088c2ecf20Sopenharmony_ci
30098c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.ac_power)
30108c2ecf20Sopenharmony_ci		max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
30118c2ecf20Sopenharmony_ci	else
30128c2ecf20Sopenharmony_ci		max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
30138c2ecf20Sopenharmony_ci
30148c2ecf20Sopenharmony_ci	for (i = ps->performance_level_count - 2; i >= 0; i--) {
30158c2ecf20Sopenharmony_ci		if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc)
30168c2ecf20Sopenharmony_ci			ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc;
30178c2ecf20Sopenharmony_ci	}
30188c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.ac_power == false) {
30198c2ecf20Sopenharmony_ci		for (i = 0; i < ps->performance_level_count; i++) {
30208c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].mclk > max_limits->mclk)
30218c2ecf20Sopenharmony_ci				ps->performance_levels[i].mclk = max_limits->mclk;
30228c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].sclk > max_limits->sclk)
30238c2ecf20Sopenharmony_ci				ps->performance_levels[i].sclk = max_limits->sclk;
30248c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].vddc > max_limits->vddc)
30258c2ecf20Sopenharmony_ci				ps->performance_levels[i].vddc = max_limits->vddc;
30268c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].vddci > max_limits->vddci)
30278c2ecf20Sopenharmony_ci				ps->performance_levels[i].vddci = max_limits->vddci;
30288c2ecf20Sopenharmony_ci		}
30298c2ecf20Sopenharmony_ci	}
30308c2ecf20Sopenharmony_ci
30318c2ecf20Sopenharmony_ci	/* limit clocks to max supported clocks based on voltage dependency tables */
30328c2ecf20Sopenharmony_ci	btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
30338c2ecf20Sopenharmony_ci							&max_sclk_vddc);
30348c2ecf20Sopenharmony_ci	btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
30358c2ecf20Sopenharmony_ci							&max_mclk_vddci);
30368c2ecf20Sopenharmony_ci	btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
30378c2ecf20Sopenharmony_ci							&max_mclk_vddc);
30388c2ecf20Sopenharmony_ci
30398c2ecf20Sopenharmony_ci	for (i = 0; i < ps->performance_level_count; i++) {
30408c2ecf20Sopenharmony_ci		if (max_sclk_vddc) {
30418c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].sclk > max_sclk_vddc)
30428c2ecf20Sopenharmony_ci				ps->performance_levels[i].sclk = max_sclk_vddc;
30438c2ecf20Sopenharmony_ci		}
30448c2ecf20Sopenharmony_ci		if (max_mclk_vddci) {
30458c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].mclk > max_mclk_vddci)
30468c2ecf20Sopenharmony_ci				ps->performance_levels[i].mclk = max_mclk_vddci;
30478c2ecf20Sopenharmony_ci		}
30488c2ecf20Sopenharmony_ci		if (max_mclk_vddc) {
30498c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].mclk > max_mclk_vddc)
30508c2ecf20Sopenharmony_ci				ps->performance_levels[i].mclk = max_mclk_vddc;
30518c2ecf20Sopenharmony_ci		}
30528c2ecf20Sopenharmony_ci		if (max_mclk) {
30538c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].mclk > max_mclk)
30548c2ecf20Sopenharmony_ci				ps->performance_levels[i].mclk = max_mclk;
30558c2ecf20Sopenharmony_ci		}
30568c2ecf20Sopenharmony_ci		if (max_sclk) {
30578c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].sclk > max_sclk)
30588c2ecf20Sopenharmony_ci				ps->performance_levels[i].sclk = max_sclk;
30598c2ecf20Sopenharmony_ci		}
30608c2ecf20Sopenharmony_ci	}
30618c2ecf20Sopenharmony_ci
30628c2ecf20Sopenharmony_ci	/* XXX validate the min clocks required for display */
30638c2ecf20Sopenharmony_ci
30648c2ecf20Sopenharmony_ci	if (disable_mclk_switching) {
30658c2ecf20Sopenharmony_ci		mclk  = ps->performance_levels[ps->performance_level_count - 1].mclk;
30668c2ecf20Sopenharmony_ci		vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
30678c2ecf20Sopenharmony_ci	} else {
30688c2ecf20Sopenharmony_ci		mclk = ps->performance_levels[0].mclk;
30698c2ecf20Sopenharmony_ci		vddci = ps->performance_levels[0].vddci;
30708c2ecf20Sopenharmony_ci	}
30718c2ecf20Sopenharmony_ci
30728c2ecf20Sopenharmony_ci	if (disable_sclk_switching) {
30738c2ecf20Sopenharmony_ci		sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
30748c2ecf20Sopenharmony_ci		vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
30758c2ecf20Sopenharmony_ci	} else {
30768c2ecf20Sopenharmony_ci		sclk = ps->performance_levels[0].sclk;
30778c2ecf20Sopenharmony_ci		vddc = ps->performance_levels[0].vddc;
30788c2ecf20Sopenharmony_ci	}
30798c2ecf20Sopenharmony_ci
30808c2ecf20Sopenharmony_ci	if (rps->vce_active) {
30818c2ecf20Sopenharmony_ci		if (sclk < rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].sclk)
30828c2ecf20Sopenharmony_ci			sclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].sclk;
30838c2ecf20Sopenharmony_ci		if (mclk < rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].mclk)
30848c2ecf20Sopenharmony_ci			mclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].mclk;
30858c2ecf20Sopenharmony_ci	}
30868c2ecf20Sopenharmony_ci
30878c2ecf20Sopenharmony_ci	/* adjusted low state */
30888c2ecf20Sopenharmony_ci	ps->performance_levels[0].sclk = sclk;
30898c2ecf20Sopenharmony_ci	ps->performance_levels[0].mclk = mclk;
30908c2ecf20Sopenharmony_ci	ps->performance_levels[0].vddc = vddc;
30918c2ecf20Sopenharmony_ci	ps->performance_levels[0].vddci = vddci;
30928c2ecf20Sopenharmony_ci
30938c2ecf20Sopenharmony_ci	if (disable_sclk_switching) {
30948c2ecf20Sopenharmony_ci		sclk = ps->performance_levels[0].sclk;
30958c2ecf20Sopenharmony_ci		for (i = 1; i < ps->performance_level_count; i++) {
30968c2ecf20Sopenharmony_ci			if (sclk < ps->performance_levels[i].sclk)
30978c2ecf20Sopenharmony_ci				sclk = ps->performance_levels[i].sclk;
30988c2ecf20Sopenharmony_ci		}
30998c2ecf20Sopenharmony_ci		for (i = 0; i < ps->performance_level_count; i++) {
31008c2ecf20Sopenharmony_ci			ps->performance_levels[i].sclk = sclk;
31018c2ecf20Sopenharmony_ci			ps->performance_levels[i].vddc = vddc;
31028c2ecf20Sopenharmony_ci		}
31038c2ecf20Sopenharmony_ci	} else {
31048c2ecf20Sopenharmony_ci		for (i = 1; i < ps->performance_level_count; i++) {
31058c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
31068c2ecf20Sopenharmony_ci				ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
31078c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
31088c2ecf20Sopenharmony_ci				ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
31098c2ecf20Sopenharmony_ci		}
31108c2ecf20Sopenharmony_ci	}
31118c2ecf20Sopenharmony_ci
31128c2ecf20Sopenharmony_ci	if (disable_mclk_switching) {
31138c2ecf20Sopenharmony_ci		mclk = ps->performance_levels[0].mclk;
31148c2ecf20Sopenharmony_ci		for (i = 1; i < ps->performance_level_count; i++) {
31158c2ecf20Sopenharmony_ci			if (mclk < ps->performance_levels[i].mclk)
31168c2ecf20Sopenharmony_ci				mclk = ps->performance_levels[i].mclk;
31178c2ecf20Sopenharmony_ci		}
31188c2ecf20Sopenharmony_ci		for (i = 0; i < ps->performance_level_count; i++) {
31198c2ecf20Sopenharmony_ci			ps->performance_levels[i].mclk = mclk;
31208c2ecf20Sopenharmony_ci			ps->performance_levels[i].vddci = vddci;
31218c2ecf20Sopenharmony_ci		}
31228c2ecf20Sopenharmony_ci	} else {
31238c2ecf20Sopenharmony_ci		for (i = 1; i < ps->performance_level_count; i++) {
31248c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].mclk < ps->performance_levels[i - 1].mclk)
31258c2ecf20Sopenharmony_ci				ps->performance_levels[i].mclk = ps->performance_levels[i - 1].mclk;
31268c2ecf20Sopenharmony_ci			if (ps->performance_levels[i].vddci < ps->performance_levels[i - 1].vddci)
31278c2ecf20Sopenharmony_ci				ps->performance_levels[i].vddci = ps->performance_levels[i - 1].vddci;
31288c2ecf20Sopenharmony_ci		}
31298c2ecf20Sopenharmony_ci	}
31308c2ecf20Sopenharmony_ci
31318c2ecf20Sopenharmony_ci	for (i = 0; i < ps->performance_level_count; i++)
31328c2ecf20Sopenharmony_ci		btc_adjust_clock_combinations(rdev, max_limits,
31338c2ecf20Sopenharmony_ci					      &ps->performance_levels[i]);
31348c2ecf20Sopenharmony_ci
31358c2ecf20Sopenharmony_ci	for (i = 0; i < ps->performance_level_count; i++) {
31368c2ecf20Sopenharmony_ci		if (ps->performance_levels[i].vddc < min_vce_voltage)
31378c2ecf20Sopenharmony_ci			ps->performance_levels[i].vddc = min_vce_voltage;
31388c2ecf20Sopenharmony_ci		btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
31398c2ecf20Sopenharmony_ci						   ps->performance_levels[i].sclk,
31408c2ecf20Sopenharmony_ci						   max_limits->vddc,  &ps->performance_levels[i].vddc);
31418c2ecf20Sopenharmony_ci		btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
31428c2ecf20Sopenharmony_ci						   ps->performance_levels[i].mclk,
31438c2ecf20Sopenharmony_ci						   max_limits->vddci, &ps->performance_levels[i].vddci);
31448c2ecf20Sopenharmony_ci		btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
31458c2ecf20Sopenharmony_ci						   ps->performance_levels[i].mclk,
31468c2ecf20Sopenharmony_ci						   max_limits->vddc,  &ps->performance_levels[i].vddc);
31478c2ecf20Sopenharmony_ci		btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
31488c2ecf20Sopenharmony_ci						   rdev->clock.current_dispclk,
31498c2ecf20Sopenharmony_ci						   max_limits->vddc,  &ps->performance_levels[i].vddc);
31508c2ecf20Sopenharmony_ci	}
31518c2ecf20Sopenharmony_ci
31528c2ecf20Sopenharmony_ci	for (i = 0; i < ps->performance_level_count; i++) {
31538c2ecf20Sopenharmony_ci		btc_apply_voltage_delta_rules(rdev,
31548c2ecf20Sopenharmony_ci					      max_limits->vddc, max_limits->vddci,
31558c2ecf20Sopenharmony_ci					      &ps->performance_levels[i].vddc,
31568c2ecf20Sopenharmony_ci					      &ps->performance_levels[i].vddci);
31578c2ecf20Sopenharmony_ci	}
31588c2ecf20Sopenharmony_ci
31598c2ecf20Sopenharmony_ci	ps->dc_compatible = true;
31608c2ecf20Sopenharmony_ci	for (i = 0; i < ps->performance_level_count; i++) {
31618c2ecf20Sopenharmony_ci		if (ps->performance_levels[i].vddc > rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc)
31628c2ecf20Sopenharmony_ci			ps->dc_compatible = false;
31638c2ecf20Sopenharmony_ci	}
31648c2ecf20Sopenharmony_ci}
31658c2ecf20Sopenharmony_ci
31668c2ecf20Sopenharmony_ci#if 0
31678c2ecf20Sopenharmony_cistatic int si_read_smc_soft_register(struct radeon_device *rdev,
31688c2ecf20Sopenharmony_ci				     u16 reg_offset, u32 *value)
31698c2ecf20Sopenharmony_ci{
31708c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
31718c2ecf20Sopenharmony_ci
31728c2ecf20Sopenharmony_ci	return si_read_smc_sram_dword(rdev,
31738c2ecf20Sopenharmony_ci				      si_pi->soft_regs_start + reg_offset, value,
31748c2ecf20Sopenharmony_ci				      si_pi->sram_end);
31758c2ecf20Sopenharmony_ci}
31768c2ecf20Sopenharmony_ci#endif
31778c2ecf20Sopenharmony_ci
31788c2ecf20Sopenharmony_cistatic int si_write_smc_soft_register(struct radeon_device *rdev,
31798c2ecf20Sopenharmony_ci				      u16 reg_offset, u32 value)
31808c2ecf20Sopenharmony_ci{
31818c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
31828c2ecf20Sopenharmony_ci
31838c2ecf20Sopenharmony_ci	return si_write_smc_sram_dword(rdev,
31848c2ecf20Sopenharmony_ci				       si_pi->soft_regs_start + reg_offset,
31858c2ecf20Sopenharmony_ci				       value, si_pi->sram_end);
31868c2ecf20Sopenharmony_ci}
31878c2ecf20Sopenharmony_ci
31888c2ecf20Sopenharmony_cistatic bool si_is_special_1gb_platform(struct radeon_device *rdev)
31898c2ecf20Sopenharmony_ci{
31908c2ecf20Sopenharmony_ci	bool ret = false;
31918c2ecf20Sopenharmony_ci	u32 tmp, width, row, column, bank, density;
31928c2ecf20Sopenharmony_ci	bool is_memory_gddr5, is_special;
31938c2ecf20Sopenharmony_ci
31948c2ecf20Sopenharmony_ci	tmp = RREG32(MC_SEQ_MISC0);
31958c2ecf20Sopenharmony_ci	is_memory_gddr5 = (MC_SEQ_MISC0_GDDR5_VALUE == ((tmp & MC_SEQ_MISC0_GDDR5_MASK) >> MC_SEQ_MISC0_GDDR5_SHIFT));
31968c2ecf20Sopenharmony_ci	is_special = (MC_SEQ_MISC0_REV_ID_VALUE == ((tmp & MC_SEQ_MISC0_REV_ID_MASK) >> MC_SEQ_MISC0_REV_ID_SHIFT))
31978c2ecf20Sopenharmony_ci		& (MC_SEQ_MISC0_VEN_ID_VALUE == ((tmp & MC_SEQ_MISC0_VEN_ID_MASK) >> MC_SEQ_MISC0_VEN_ID_SHIFT));
31988c2ecf20Sopenharmony_ci
31998c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_IO_DEBUG_INDEX, 0xb);
32008c2ecf20Sopenharmony_ci	width = ((RREG32(MC_SEQ_IO_DEBUG_DATA) >> 1) & 1) ? 16 : 32;
32018c2ecf20Sopenharmony_ci
32028c2ecf20Sopenharmony_ci	tmp = RREG32(MC_ARB_RAMCFG);
32038c2ecf20Sopenharmony_ci	row = ((tmp & NOOFROWS_MASK) >> NOOFROWS_SHIFT) + 10;
32048c2ecf20Sopenharmony_ci	column = ((tmp & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) + 8;
32058c2ecf20Sopenharmony_ci	bank = ((tmp & NOOFBANK_MASK) >> NOOFBANK_SHIFT) + 2;
32068c2ecf20Sopenharmony_ci
32078c2ecf20Sopenharmony_ci	density = (1 << (row + column - 20 + bank)) * width;
32088c2ecf20Sopenharmony_ci
32098c2ecf20Sopenharmony_ci	if ((rdev->pdev->device == 0x6819) &&
32108c2ecf20Sopenharmony_ci	    is_memory_gddr5 && is_special && (density == 0x400))
32118c2ecf20Sopenharmony_ci		ret = true;
32128c2ecf20Sopenharmony_ci
32138c2ecf20Sopenharmony_ci	return ret;
32148c2ecf20Sopenharmony_ci}
32158c2ecf20Sopenharmony_ci
32168c2ecf20Sopenharmony_cistatic void si_get_leakage_vddc(struct radeon_device *rdev)
32178c2ecf20Sopenharmony_ci{
32188c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
32198c2ecf20Sopenharmony_ci	u16 vddc, count = 0;
32208c2ecf20Sopenharmony_ci	int i, ret;
32218c2ecf20Sopenharmony_ci
32228c2ecf20Sopenharmony_ci	for (i = 0; i < SISLANDS_MAX_LEAKAGE_COUNT; i++) {
32238c2ecf20Sopenharmony_ci		ret = radeon_atom_get_leakage_vddc_based_on_leakage_idx(rdev, &vddc, SISLANDS_LEAKAGE_INDEX0 + i);
32248c2ecf20Sopenharmony_ci
32258c2ecf20Sopenharmony_ci		if (!ret && (vddc > 0) && (vddc != (SISLANDS_LEAKAGE_INDEX0 + i))) {
32268c2ecf20Sopenharmony_ci			si_pi->leakage_voltage.entries[count].voltage = vddc;
32278c2ecf20Sopenharmony_ci			si_pi->leakage_voltage.entries[count].leakage_index =
32288c2ecf20Sopenharmony_ci				SISLANDS_LEAKAGE_INDEX0 + i;
32298c2ecf20Sopenharmony_ci			count++;
32308c2ecf20Sopenharmony_ci		}
32318c2ecf20Sopenharmony_ci	}
32328c2ecf20Sopenharmony_ci	si_pi->leakage_voltage.count = count;
32338c2ecf20Sopenharmony_ci}
32348c2ecf20Sopenharmony_ci
32358c2ecf20Sopenharmony_cistatic int si_get_leakage_voltage_from_leakage_index(struct radeon_device *rdev,
32368c2ecf20Sopenharmony_ci						     u32 index, u16 *leakage_voltage)
32378c2ecf20Sopenharmony_ci{
32388c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
32398c2ecf20Sopenharmony_ci	int i;
32408c2ecf20Sopenharmony_ci
32418c2ecf20Sopenharmony_ci	if (leakage_voltage == NULL)
32428c2ecf20Sopenharmony_ci		return -EINVAL;
32438c2ecf20Sopenharmony_ci
32448c2ecf20Sopenharmony_ci	if ((index & 0xff00) != 0xff00)
32458c2ecf20Sopenharmony_ci		return -EINVAL;
32468c2ecf20Sopenharmony_ci
32478c2ecf20Sopenharmony_ci	if ((index & 0xff) > SISLANDS_MAX_LEAKAGE_COUNT + 1)
32488c2ecf20Sopenharmony_ci		return -EINVAL;
32498c2ecf20Sopenharmony_ci
32508c2ecf20Sopenharmony_ci	if (index < SISLANDS_LEAKAGE_INDEX0)
32518c2ecf20Sopenharmony_ci		return -EINVAL;
32528c2ecf20Sopenharmony_ci
32538c2ecf20Sopenharmony_ci	for (i = 0; i < si_pi->leakage_voltage.count; i++) {
32548c2ecf20Sopenharmony_ci		if (si_pi->leakage_voltage.entries[i].leakage_index == index) {
32558c2ecf20Sopenharmony_ci			*leakage_voltage = si_pi->leakage_voltage.entries[i].voltage;
32568c2ecf20Sopenharmony_ci			return 0;
32578c2ecf20Sopenharmony_ci		}
32588c2ecf20Sopenharmony_ci	}
32598c2ecf20Sopenharmony_ci	return -EAGAIN;
32608c2ecf20Sopenharmony_ci}
32618c2ecf20Sopenharmony_ci
32628c2ecf20Sopenharmony_cistatic void si_set_dpm_event_sources(struct radeon_device *rdev, u32 sources)
32638c2ecf20Sopenharmony_ci{
32648c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
32658c2ecf20Sopenharmony_ci	bool want_thermal_protection;
32668c2ecf20Sopenharmony_ci	enum radeon_dpm_event_src dpm_event_src;
32678c2ecf20Sopenharmony_ci
32688c2ecf20Sopenharmony_ci	switch (sources) {
32698c2ecf20Sopenharmony_ci	case 0:
32708c2ecf20Sopenharmony_ci	default:
32718c2ecf20Sopenharmony_ci		want_thermal_protection = false;
32728c2ecf20Sopenharmony_ci		break;
32738c2ecf20Sopenharmony_ci	case (1 << RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL):
32748c2ecf20Sopenharmony_ci		want_thermal_protection = true;
32758c2ecf20Sopenharmony_ci		dpm_event_src = RADEON_DPM_EVENT_SRC_DIGITAL;
32768c2ecf20Sopenharmony_ci		break;
32778c2ecf20Sopenharmony_ci	case (1 << RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL):
32788c2ecf20Sopenharmony_ci		want_thermal_protection = true;
32798c2ecf20Sopenharmony_ci		dpm_event_src = RADEON_DPM_EVENT_SRC_EXTERNAL;
32808c2ecf20Sopenharmony_ci		break;
32818c2ecf20Sopenharmony_ci	case ((1 << RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL) |
32828c2ecf20Sopenharmony_ci	      (1 << RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL)):
32838c2ecf20Sopenharmony_ci		want_thermal_protection = true;
32848c2ecf20Sopenharmony_ci		dpm_event_src = RADEON_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL;
32858c2ecf20Sopenharmony_ci		break;
32868c2ecf20Sopenharmony_ci	}
32878c2ecf20Sopenharmony_ci
32888c2ecf20Sopenharmony_ci	if (want_thermal_protection) {
32898c2ecf20Sopenharmony_ci		WREG32_P(CG_THERMAL_CTRL, DPM_EVENT_SRC(dpm_event_src), ~DPM_EVENT_SRC_MASK);
32908c2ecf20Sopenharmony_ci		if (pi->thermal_protection)
32918c2ecf20Sopenharmony_ci			WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
32928c2ecf20Sopenharmony_ci	} else {
32938c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
32948c2ecf20Sopenharmony_ci	}
32958c2ecf20Sopenharmony_ci}
32968c2ecf20Sopenharmony_ci
32978c2ecf20Sopenharmony_cistatic void si_enable_auto_throttle_source(struct radeon_device *rdev,
32988c2ecf20Sopenharmony_ci					   enum radeon_dpm_auto_throttle_src source,
32998c2ecf20Sopenharmony_ci					   bool enable)
33008c2ecf20Sopenharmony_ci{
33018c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
33028c2ecf20Sopenharmony_ci
33038c2ecf20Sopenharmony_ci	if (enable) {
33048c2ecf20Sopenharmony_ci		if (!(pi->active_auto_throttle_sources & (1 << source))) {
33058c2ecf20Sopenharmony_ci			pi->active_auto_throttle_sources |= 1 << source;
33068c2ecf20Sopenharmony_ci			si_set_dpm_event_sources(rdev, pi->active_auto_throttle_sources);
33078c2ecf20Sopenharmony_ci		}
33088c2ecf20Sopenharmony_ci	} else {
33098c2ecf20Sopenharmony_ci		if (pi->active_auto_throttle_sources & (1 << source)) {
33108c2ecf20Sopenharmony_ci			pi->active_auto_throttle_sources &= ~(1 << source);
33118c2ecf20Sopenharmony_ci			si_set_dpm_event_sources(rdev, pi->active_auto_throttle_sources);
33128c2ecf20Sopenharmony_ci		}
33138c2ecf20Sopenharmony_ci	}
33148c2ecf20Sopenharmony_ci}
33158c2ecf20Sopenharmony_ci
33168c2ecf20Sopenharmony_cistatic void si_start_dpm(struct radeon_device *rdev)
33178c2ecf20Sopenharmony_ci{
33188c2ecf20Sopenharmony_ci	WREG32_P(GENERAL_PWRMGT, GLOBAL_PWRMGT_EN, ~GLOBAL_PWRMGT_EN);
33198c2ecf20Sopenharmony_ci}
33208c2ecf20Sopenharmony_ci
33218c2ecf20Sopenharmony_cistatic void si_stop_dpm(struct radeon_device *rdev)
33228c2ecf20Sopenharmony_ci{
33238c2ecf20Sopenharmony_ci	WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN);
33248c2ecf20Sopenharmony_ci}
33258c2ecf20Sopenharmony_ci
33268c2ecf20Sopenharmony_cistatic void si_enable_sclk_control(struct radeon_device *rdev, bool enable)
33278c2ecf20Sopenharmony_ci{
33288c2ecf20Sopenharmony_ci	if (enable)
33298c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF);
33308c2ecf20Sopenharmony_ci	else
33318c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
33328c2ecf20Sopenharmony_ci
33338c2ecf20Sopenharmony_ci}
33348c2ecf20Sopenharmony_ci
33358c2ecf20Sopenharmony_ci#if 0
33368c2ecf20Sopenharmony_cistatic int si_notify_hardware_of_thermal_state(struct radeon_device *rdev,
33378c2ecf20Sopenharmony_ci					       u32 thermal_level)
33388c2ecf20Sopenharmony_ci{
33398c2ecf20Sopenharmony_ci	PPSMC_Result ret;
33408c2ecf20Sopenharmony_ci
33418c2ecf20Sopenharmony_ci	if (thermal_level == 0) {
33428c2ecf20Sopenharmony_ci		ret = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableThermalInterrupt);
33438c2ecf20Sopenharmony_ci		if (ret == PPSMC_Result_OK)
33448c2ecf20Sopenharmony_ci			return 0;
33458c2ecf20Sopenharmony_ci		else
33468c2ecf20Sopenharmony_ci			return -EINVAL;
33478c2ecf20Sopenharmony_ci	}
33488c2ecf20Sopenharmony_ci	return 0;
33498c2ecf20Sopenharmony_ci}
33508c2ecf20Sopenharmony_ci
33518c2ecf20Sopenharmony_cistatic void si_notify_hardware_vpu_recovery_event(struct radeon_device *rdev)
33528c2ecf20Sopenharmony_ci{
33538c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen, true);
33548c2ecf20Sopenharmony_ci}
33558c2ecf20Sopenharmony_ci#endif
33568c2ecf20Sopenharmony_ci
33578c2ecf20Sopenharmony_ci#if 0
33588c2ecf20Sopenharmony_cistatic int si_notify_hw_of_powersource(struct radeon_device *rdev, bool ac_power)
33598c2ecf20Sopenharmony_ci{
33608c2ecf20Sopenharmony_ci	if (ac_power)
33618c2ecf20Sopenharmony_ci		return (si_send_msg_to_smc(rdev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ?
33628c2ecf20Sopenharmony_ci			0 : -EINVAL;
33638c2ecf20Sopenharmony_ci
33648c2ecf20Sopenharmony_ci	return 0;
33658c2ecf20Sopenharmony_ci}
33668c2ecf20Sopenharmony_ci#endif
33678c2ecf20Sopenharmony_ci
33688c2ecf20Sopenharmony_cistatic PPSMC_Result si_send_msg_to_smc_with_parameter(struct radeon_device *rdev,
33698c2ecf20Sopenharmony_ci						      PPSMC_Msg msg, u32 parameter)
33708c2ecf20Sopenharmony_ci{
33718c2ecf20Sopenharmony_ci	WREG32(SMC_SCRATCH0, parameter);
33728c2ecf20Sopenharmony_ci	return si_send_msg_to_smc(rdev, msg);
33738c2ecf20Sopenharmony_ci}
33748c2ecf20Sopenharmony_ci
33758c2ecf20Sopenharmony_cistatic int si_restrict_performance_levels_before_switch(struct radeon_device *rdev)
33768c2ecf20Sopenharmony_ci{
33778c2ecf20Sopenharmony_ci	if (si_send_msg_to_smc(rdev, PPSMC_MSG_NoForcedLevel) != PPSMC_Result_OK)
33788c2ecf20Sopenharmony_ci		return -EINVAL;
33798c2ecf20Sopenharmony_ci
33808c2ecf20Sopenharmony_ci	return (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 1) == PPSMC_Result_OK) ?
33818c2ecf20Sopenharmony_ci		0 : -EINVAL;
33828c2ecf20Sopenharmony_ci}
33838c2ecf20Sopenharmony_ci
33848c2ecf20Sopenharmony_ciint si_dpm_force_performance_level(struct radeon_device *rdev,
33858c2ecf20Sopenharmony_ci				   enum radeon_dpm_forced_level level)
33868c2ecf20Sopenharmony_ci{
33878c2ecf20Sopenharmony_ci	struct radeon_ps *rps = rdev->pm.dpm.current_ps;
33888c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(rps);
33898c2ecf20Sopenharmony_ci	u32 levels = ps->performance_level_count;
33908c2ecf20Sopenharmony_ci
33918c2ecf20Sopenharmony_ci	if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
33928c2ecf20Sopenharmony_ci		if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
33938c2ecf20Sopenharmony_ci			return -EINVAL;
33948c2ecf20Sopenharmony_ci
33958c2ecf20Sopenharmony_ci		if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK)
33968c2ecf20Sopenharmony_ci			return -EINVAL;
33978c2ecf20Sopenharmony_ci	} else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
33988c2ecf20Sopenharmony_ci		if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
33998c2ecf20Sopenharmony_ci			return -EINVAL;
34008c2ecf20Sopenharmony_ci
34018c2ecf20Sopenharmony_ci		if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK)
34028c2ecf20Sopenharmony_ci			return -EINVAL;
34038c2ecf20Sopenharmony_ci	} else if (level == RADEON_DPM_FORCED_LEVEL_AUTO) {
34048c2ecf20Sopenharmony_ci		if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
34058c2ecf20Sopenharmony_ci			return -EINVAL;
34068c2ecf20Sopenharmony_ci
34078c2ecf20Sopenharmony_ci		if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
34088c2ecf20Sopenharmony_ci			return -EINVAL;
34098c2ecf20Sopenharmony_ci	}
34108c2ecf20Sopenharmony_ci
34118c2ecf20Sopenharmony_ci	rdev->pm.dpm.forced_level = level;
34128c2ecf20Sopenharmony_ci
34138c2ecf20Sopenharmony_ci	return 0;
34148c2ecf20Sopenharmony_ci}
34158c2ecf20Sopenharmony_ci
34168c2ecf20Sopenharmony_ci#if 0
34178c2ecf20Sopenharmony_cistatic int si_set_boot_state(struct radeon_device *rdev)
34188c2ecf20Sopenharmony_ci{
34198c2ecf20Sopenharmony_ci	return (si_send_msg_to_smc(rdev, PPSMC_MSG_SwitchToInitialState) == PPSMC_Result_OK) ?
34208c2ecf20Sopenharmony_ci		0 : -EINVAL;
34218c2ecf20Sopenharmony_ci}
34228c2ecf20Sopenharmony_ci#endif
34238c2ecf20Sopenharmony_ci
34248c2ecf20Sopenharmony_cistatic int si_set_sw_state(struct radeon_device *rdev)
34258c2ecf20Sopenharmony_ci{
34268c2ecf20Sopenharmony_ci	return (si_send_msg_to_smc(rdev, PPSMC_MSG_SwitchToSwState) == PPSMC_Result_OK) ?
34278c2ecf20Sopenharmony_ci		0 : -EINVAL;
34288c2ecf20Sopenharmony_ci}
34298c2ecf20Sopenharmony_ci
34308c2ecf20Sopenharmony_cistatic int si_halt_smc(struct radeon_device *rdev)
34318c2ecf20Sopenharmony_ci{
34328c2ecf20Sopenharmony_ci	if (si_send_msg_to_smc(rdev, PPSMC_MSG_Halt) != PPSMC_Result_OK)
34338c2ecf20Sopenharmony_ci		return -EINVAL;
34348c2ecf20Sopenharmony_ci
34358c2ecf20Sopenharmony_ci	return (si_wait_for_smc_inactive(rdev) == PPSMC_Result_OK) ?
34368c2ecf20Sopenharmony_ci		0 : -EINVAL;
34378c2ecf20Sopenharmony_ci}
34388c2ecf20Sopenharmony_ci
34398c2ecf20Sopenharmony_cistatic int si_resume_smc(struct radeon_device *rdev)
34408c2ecf20Sopenharmony_ci{
34418c2ecf20Sopenharmony_ci	if (si_send_msg_to_smc(rdev, PPSMC_FlushDataCache) != PPSMC_Result_OK)
34428c2ecf20Sopenharmony_ci		return -EINVAL;
34438c2ecf20Sopenharmony_ci
34448c2ecf20Sopenharmony_ci	return (si_send_msg_to_smc(rdev, PPSMC_MSG_Resume) == PPSMC_Result_OK) ?
34458c2ecf20Sopenharmony_ci		0 : -EINVAL;
34468c2ecf20Sopenharmony_ci}
34478c2ecf20Sopenharmony_ci
34488c2ecf20Sopenharmony_cistatic void si_dpm_start_smc(struct radeon_device *rdev)
34498c2ecf20Sopenharmony_ci{
34508c2ecf20Sopenharmony_ci	si_program_jump_on_start(rdev);
34518c2ecf20Sopenharmony_ci	si_start_smc(rdev);
34528c2ecf20Sopenharmony_ci	si_start_smc_clock(rdev);
34538c2ecf20Sopenharmony_ci}
34548c2ecf20Sopenharmony_ci
34558c2ecf20Sopenharmony_cistatic void si_dpm_stop_smc(struct radeon_device *rdev)
34568c2ecf20Sopenharmony_ci{
34578c2ecf20Sopenharmony_ci	si_reset_smc(rdev);
34588c2ecf20Sopenharmony_ci	si_stop_smc_clock(rdev);
34598c2ecf20Sopenharmony_ci}
34608c2ecf20Sopenharmony_ci
34618c2ecf20Sopenharmony_cistatic int si_process_firmware_header(struct radeon_device *rdev)
34628c2ecf20Sopenharmony_ci{
34638c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
34648c2ecf20Sopenharmony_ci	u32 tmp;
34658c2ecf20Sopenharmony_ci	int ret;
34668c2ecf20Sopenharmony_ci
34678c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
34688c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
34698c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_stateTable,
34708c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
34718c2ecf20Sopenharmony_ci	if (ret)
34728c2ecf20Sopenharmony_ci		return ret;
34738c2ecf20Sopenharmony_ci
34748c2ecf20Sopenharmony_ci	si_pi->state_table_start = tmp;
34758c2ecf20Sopenharmony_ci
34768c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
34778c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
34788c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_softRegisters,
34798c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
34808c2ecf20Sopenharmony_ci	if (ret)
34818c2ecf20Sopenharmony_ci		return ret;
34828c2ecf20Sopenharmony_ci
34838c2ecf20Sopenharmony_ci	si_pi->soft_regs_start = tmp;
34848c2ecf20Sopenharmony_ci
34858c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
34868c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
34878c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable,
34888c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
34898c2ecf20Sopenharmony_ci	if (ret)
34908c2ecf20Sopenharmony_ci		return ret;
34918c2ecf20Sopenharmony_ci
34928c2ecf20Sopenharmony_ci	si_pi->mc_reg_table_start = tmp;
34938c2ecf20Sopenharmony_ci
34948c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
34958c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
34968c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_fanTable,
34978c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
34988c2ecf20Sopenharmony_ci	if (ret)
34998c2ecf20Sopenharmony_ci		return ret;
35008c2ecf20Sopenharmony_ci
35018c2ecf20Sopenharmony_ci	si_pi->fan_table_start = tmp;
35028c2ecf20Sopenharmony_ci
35038c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
35048c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
35058c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable,
35068c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
35078c2ecf20Sopenharmony_ci	if (ret)
35088c2ecf20Sopenharmony_ci		return ret;
35098c2ecf20Sopenharmony_ci
35108c2ecf20Sopenharmony_ci	si_pi->arb_table_start = tmp;
35118c2ecf20Sopenharmony_ci
35128c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
35138c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
35148c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable,
35158c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
35168c2ecf20Sopenharmony_ci	if (ret)
35178c2ecf20Sopenharmony_ci		return ret;
35188c2ecf20Sopenharmony_ci
35198c2ecf20Sopenharmony_ci	si_pi->cac_table_start = tmp;
35208c2ecf20Sopenharmony_ci
35218c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
35228c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
35238c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration,
35248c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
35258c2ecf20Sopenharmony_ci	if (ret)
35268c2ecf20Sopenharmony_ci		return ret;
35278c2ecf20Sopenharmony_ci
35288c2ecf20Sopenharmony_ci	si_pi->dte_table_start = tmp;
35298c2ecf20Sopenharmony_ci
35308c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
35318c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
35328c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_spllTable,
35338c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
35348c2ecf20Sopenharmony_ci	if (ret)
35358c2ecf20Sopenharmony_ci		return ret;
35368c2ecf20Sopenharmony_ci
35378c2ecf20Sopenharmony_ci	si_pi->spll_table_start = tmp;
35388c2ecf20Sopenharmony_ci
35398c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev,
35408c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
35418c2ecf20Sopenharmony_ci				     SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters,
35428c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
35438c2ecf20Sopenharmony_ci	if (ret)
35448c2ecf20Sopenharmony_ci		return ret;
35458c2ecf20Sopenharmony_ci
35468c2ecf20Sopenharmony_ci	si_pi->papm_cfg_table_start = tmp;
35478c2ecf20Sopenharmony_ci
35488c2ecf20Sopenharmony_ci	return ret;
35498c2ecf20Sopenharmony_ci}
35508c2ecf20Sopenharmony_ci
35518c2ecf20Sopenharmony_cistatic void si_read_clock_registers(struct radeon_device *rdev)
35528c2ecf20Sopenharmony_ci{
35538c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
35548c2ecf20Sopenharmony_ci
35558c2ecf20Sopenharmony_ci	si_pi->clock_registers.cg_spll_func_cntl = RREG32(CG_SPLL_FUNC_CNTL);
35568c2ecf20Sopenharmony_ci	si_pi->clock_registers.cg_spll_func_cntl_2 = RREG32(CG_SPLL_FUNC_CNTL_2);
35578c2ecf20Sopenharmony_ci	si_pi->clock_registers.cg_spll_func_cntl_3 = RREG32(CG_SPLL_FUNC_CNTL_3);
35588c2ecf20Sopenharmony_ci	si_pi->clock_registers.cg_spll_func_cntl_4 = RREG32(CG_SPLL_FUNC_CNTL_4);
35598c2ecf20Sopenharmony_ci	si_pi->clock_registers.cg_spll_spread_spectrum = RREG32(CG_SPLL_SPREAD_SPECTRUM);
35608c2ecf20Sopenharmony_ci	si_pi->clock_registers.cg_spll_spread_spectrum_2 = RREG32(CG_SPLL_SPREAD_SPECTRUM_2);
35618c2ecf20Sopenharmony_ci	si_pi->clock_registers.dll_cntl = RREG32(DLL_CNTL);
35628c2ecf20Sopenharmony_ci	si_pi->clock_registers.mclk_pwrmgt_cntl = RREG32(MCLK_PWRMGT_CNTL);
35638c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_ad_func_cntl = RREG32(MPLL_AD_FUNC_CNTL);
35648c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_dq_func_cntl = RREG32(MPLL_DQ_FUNC_CNTL);
35658c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_func_cntl = RREG32(MPLL_FUNC_CNTL);
35668c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_func_cntl_1 = RREG32(MPLL_FUNC_CNTL_1);
35678c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_func_cntl_2 = RREG32(MPLL_FUNC_CNTL_2);
35688c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_ss1 = RREG32(MPLL_SS1);
35698c2ecf20Sopenharmony_ci	si_pi->clock_registers.mpll_ss2 = RREG32(MPLL_SS2);
35708c2ecf20Sopenharmony_ci}
35718c2ecf20Sopenharmony_ci
35728c2ecf20Sopenharmony_cistatic void si_enable_thermal_protection(struct radeon_device *rdev,
35738c2ecf20Sopenharmony_ci					  bool enable)
35748c2ecf20Sopenharmony_ci{
35758c2ecf20Sopenharmony_ci	if (enable)
35768c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
35778c2ecf20Sopenharmony_ci	else
35788c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
35798c2ecf20Sopenharmony_ci}
35808c2ecf20Sopenharmony_ci
35818c2ecf20Sopenharmony_cistatic void si_enable_acpi_power_management(struct radeon_device *rdev)
35828c2ecf20Sopenharmony_ci{
35838c2ecf20Sopenharmony_ci	WREG32_P(GENERAL_PWRMGT, STATIC_PM_EN, ~STATIC_PM_EN);
35848c2ecf20Sopenharmony_ci}
35858c2ecf20Sopenharmony_ci
35868c2ecf20Sopenharmony_ci#if 0
35878c2ecf20Sopenharmony_cistatic int si_enter_ulp_state(struct radeon_device *rdev)
35888c2ecf20Sopenharmony_ci{
35898c2ecf20Sopenharmony_ci	WREG32(SMC_MESSAGE_0, PPSMC_MSG_SwitchToMinimumPower);
35908c2ecf20Sopenharmony_ci
35918c2ecf20Sopenharmony_ci	udelay(25000);
35928c2ecf20Sopenharmony_ci
35938c2ecf20Sopenharmony_ci	return 0;
35948c2ecf20Sopenharmony_ci}
35958c2ecf20Sopenharmony_ci
35968c2ecf20Sopenharmony_cistatic int si_exit_ulp_state(struct radeon_device *rdev)
35978c2ecf20Sopenharmony_ci{
35988c2ecf20Sopenharmony_ci	int i;
35998c2ecf20Sopenharmony_ci
36008c2ecf20Sopenharmony_ci	WREG32(SMC_MESSAGE_0, PPSMC_MSG_ResumeFromMinimumPower);
36018c2ecf20Sopenharmony_ci
36028c2ecf20Sopenharmony_ci	udelay(7000);
36038c2ecf20Sopenharmony_ci
36048c2ecf20Sopenharmony_ci	for (i = 0; i < rdev->usec_timeout; i++) {
36058c2ecf20Sopenharmony_ci		if (RREG32(SMC_RESP_0) == 1)
36068c2ecf20Sopenharmony_ci			break;
36078c2ecf20Sopenharmony_ci		udelay(1000);
36088c2ecf20Sopenharmony_ci	}
36098c2ecf20Sopenharmony_ci
36108c2ecf20Sopenharmony_ci	return 0;
36118c2ecf20Sopenharmony_ci}
36128c2ecf20Sopenharmony_ci#endif
36138c2ecf20Sopenharmony_ci
36148c2ecf20Sopenharmony_cistatic int si_notify_smc_display_change(struct radeon_device *rdev,
36158c2ecf20Sopenharmony_ci				     bool has_display)
36168c2ecf20Sopenharmony_ci{
36178c2ecf20Sopenharmony_ci	PPSMC_Msg msg = has_display ?
36188c2ecf20Sopenharmony_ci		PPSMC_MSG_HasDisplay : PPSMC_MSG_NoDisplay;
36198c2ecf20Sopenharmony_ci
36208c2ecf20Sopenharmony_ci	return (si_send_msg_to_smc(rdev, msg) == PPSMC_Result_OK) ?
36218c2ecf20Sopenharmony_ci		0 : -EINVAL;
36228c2ecf20Sopenharmony_ci}
36238c2ecf20Sopenharmony_ci
36248c2ecf20Sopenharmony_cistatic void si_program_response_times(struct radeon_device *rdev)
36258c2ecf20Sopenharmony_ci{
36268c2ecf20Sopenharmony_ci	u32 voltage_response_time, acpi_delay_time, vbi_time_out;
36278c2ecf20Sopenharmony_ci	u32 vddc_dly, acpi_dly, vbi_dly;
36288c2ecf20Sopenharmony_ci	u32 reference_clock;
36298c2ecf20Sopenharmony_ci
36308c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mvdd_chg_time, 1);
36318c2ecf20Sopenharmony_ci
36328c2ecf20Sopenharmony_ci	voltage_response_time = (u32)rdev->pm.dpm.voltage_response_time;
36338c2ecf20Sopenharmony_ci
36348c2ecf20Sopenharmony_ci	if (voltage_response_time == 0)
36358c2ecf20Sopenharmony_ci		voltage_response_time = 1000;
36368c2ecf20Sopenharmony_ci
36378c2ecf20Sopenharmony_ci	acpi_delay_time = 15000;
36388c2ecf20Sopenharmony_ci	vbi_time_out = 100000;
36398c2ecf20Sopenharmony_ci
36408c2ecf20Sopenharmony_ci	reference_clock = radeon_get_xclk(rdev);
36418c2ecf20Sopenharmony_ci
36428c2ecf20Sopenharmony_ci	vddc_dly = (voltage_response_time  * reference_clock) / 100;
36438c2ecf20Sopenharmony_ci	acpi_dly = (acpi_delay_time * reference_clock) / 100;
36448c2ecf20Sopenharmony_ci	vbi_dly  = (vbi_time_out * reference_clock) / 100;
36458c2ecf20Sopenharmony_ci
36468c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_delay_vreg,  vddc_dly);
36478c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_delay_acpi,  acpi_dly);
36488c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mclk_chg_timeout, vbi_dly);
36498c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mc_block_delay, 0xAA);
36508c2ecf20Sopenharmony_ci}
36518c2ecf20Sopenharmony_ci
36528c2ecf20Sopenharmony_cistatic void si_program_ds_registers(struct radeon_device *rdev)
36538c2ecf20Sopenharmony_ci{
36548c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
36558c2ecf20Sopenharmony_ci	u32 tmp = 1; /* XXX: 0x10 on tahiti A0 */
36568c2ecf20Sopenharmony_ci
36578c2ecf20Sopenharmony_ci	if (eg_pi->sclk_deep_sleep) {
36588c2ecf20Sopenharmony_ci		WREG32_P(MISC_CLK_CNTL, DEEP_SLEEP_CLK_SEL(tmp), ~DEEP_SLEEP_CLK_SEL_MASK);
36598c2ecf20Sopenharmony_ci		WREG32_P(CG_SPLL_AUTOSCALE_CNTL, AUTOSCALE_ON_SS_CLEAR,
36608c2ecf20Sopenharmony_ci			 ~AUTOSCALE_ON_SS_CLEAR);
36618c2ecf20Sopenharmony_ci	}
36628c2ecf20Sopenharmony_ci}
36638c2ecf20Sopenharmony_ci
36648c2ecf20Sopenharmony_cistatic void si_program_display_gap(struct radeon_device *rdev)
36658c2ecf20Sopenharmony_ci{
36668c2ecf20Sopenharmony_ci	u32 tmp, pipe;
36678c2ecf20Sopenharmony_ci	int i;
36688c2ecf20Sopenharmony_ci
36698c2ecf20Sopenharmony_ci	tmp = RREG32(CG_DISPLAY_GAP_CNTL) & ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
36708c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.new_active_crtc_count > 0)
36718c2ecf20Sopenharmony_ci		tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
36728c2ecf20Sopenharmony_ci	else
36738c2ecf20Sopenharmony_ci		tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE);
36748c2ecf20Sopenharmony_ci
36758c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.new_active_crtc_count > 1)
36768c2ecf20Sopenharmony_ci		tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
36778c2ecf20Sopenharmony_ci	else
36788c2ecf20Sopenharmony_ci		tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE);
36798c2ecf20Sopenharmony_ci
36808c2ecf20Sopenharmony_ci	WREG32(CG_DISPLAY_GAP_CNTL, tmp);
36818c2ecf20Sopenharmony_ci
36828c2ecf20Sopenharmony_ci	tmp = RREG32(DCCG_DISP_SLOW_SELECT_REG);
36838c2ecf20Sopenharmony_ci	pipe = (tmp & DCCG_DISP1_SLOW_SELECT_MASK) >> DCCG_DISP1_SLOW_SELECT_SHIFT;
36848c2ecf20Sopenharmony_ci
36858c2ecf20Sopenharmony_ci	if ((rdev->pm.dpm.new_active_crtc_count > 0) &&
36868c2ecf20Sopenharmony_ci	    (!(rdev->pm.dpm.new_active_crtcs & (1 << pipe)))) {
36878c2ecf20Sopenharmony_ci		/* find the first active crtc */
36888c2ecf20Sopenharmony_ci		for (i = 0; i < rdev->num_crtc; i++) {
36898c2ecf20Sopenharmony_ci			if (rdev->pm.dpm.new_active_crtcs & (1 << i))
36908c2ecf20Sopenharmony_ci				break;
36918c2ecf20Sopenharmony_ci		}
36928c2ecf20Sopenharmony_ci		if (i == rdev->num_crtc)
36938c2ecf20Sopenharmony_ci			pipe = 0;
36948c2ecf20Sopenharmony_ci		else
36958c2ecf20Sopenharmony_ci			pipe = i;
36968c2ecf20Sopenharmony_ci
36978c2ecf20Sopenharmony_ci		tmp &= ~DCCG_DISP1_SLOW_SELECT_MASK;
36988c2ecf20Sopenharmony_ci		tmp |= DCCG_DISP1_SLOW_SELECT(pipe);
36998c2ecf20Sopenharmony_ci		WREG32(DCCG_DISP_SLOW_SELECT_REG, tmp);
37008c2ecf20Sopenharmony_ci	}
37018c2ecf20Sopenharmony_ci
37028c2ecf20Sopenharmony_ci	/* Setting this to false forces the performance state to low if the crtcs are disabled.
37038c2ecf20Sopenharmony_ci	 * This can be a problem on PowerXpress systems or if you want to use the card
37048c2ecf20Sopenharmony_ci	 * for offscreen rendering or compute if there are no crtcs enabled.
37058c2ecf20Sopenharmony_ci	 */
37068c2ecf20Sopenharmony_ci	si_notify_smc_display_change(rdev, rdev->pm.dpm.new_active_crtc_count > 0);
37078c2ecf20Sopenharmony_ci}
37088c2ecf20Sopenharmony_ci
37098c2ecf20Sopenharmony_cistatic void si_enable_spread_spectrum(struct radeon_device *rdev, bool enable)
37108c2ecf20Sopenharmony_ci{
37118c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
37128c2ecf20Sopenharmony_ci
37138c2ecf20Sopenharmony_ci	if (enable) {
37148c2ecf20Sopenharmony_ci		if (pi->sclk_ss)
37158c2ecf20Sopenharmony_ci			WREG32_P(GENERAL_PWRMGT, DYN_SPREAD_SPECTRUM_EN, ~DYN_SPREAD_SPECTRUM_EN);
37168c2ecf20Sopenharmony_ci	} else {
37178c2ecf20Sopenharmony_ci		WREG32_P(CG_SPLL_SPREAD_SPECTRUM, 0, ~SSEN);
37188c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, 0, ~DYN_SPREAD_SPECTRUM_EN);
37198c2ecf20Sopenharmony_ci	}
37208c2ecf20Sopenharmony_ci}
37218c2ecf20Sopenharmony_ci
37228c2ecf20Sopenharmony_cistatic void si_setup_bsp(struct radeon_device *rdev)
37238c2ecf20Sopenharmony_ci{
37248c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
37258c2ecf20Sopenharmony_ci	u32 xclk = radeon_get_xclk(rdev);
37268c2ecf20Sopenharmony_ci
37278c2ecf20Sopenharmony_ci	r600_calculate_u_and_p(pi->asi,
37288c2ecf20Sopenharmony_ci			       xclk,
37298c2ecf20Sopenharmony_ci			       16,
37308c2ecf20Sopenharmony_ci			       &pi->bsp,
37318c2ecf20Sopenharmony_ci			       &pi->bsu);
37328c2ecf20Sopenharmony_ci
37338c2ecf20Sopenharmony_ci	r600_calculate_u_and_p(pi->pasi,
37348c2ecf20Sopenharmony_ci			       xclk,
37358c2ecf20Sopenharmony_ci			       16,
37368c2ecf20Sopenharmony_ci			       &pi->pbsp,
37378c2ecf20Sopenharmony_ci			       &pi->pbsu);
37388c2ecf20Sopenharmony_ci
37398c2ecf20Sopenharmony_ci
37408c2ecf20Sopenharmony_ci	pi->dsp = BSP(pi->bsp) | BSU(pi->bsu);
37418c2ecf20Sopenharmony_ci	pi->psp = BSP(pi->pbsp) | BSU(pi->pbsu);
37428c2ecf20Sopenharmony_ci
37438c2ecf20Sopenharmony_ci	WREG32(CG_BSP, pi->dsp);
37448c2ecf20Sopenharmony_ci}
37458c2ecf20Sopenharmony_ci
37468c2ecf20Sopenharmony_cistatic void si_program_git(struct radeon_device *rdev)
37478c2ecf20Sopenharmony_ci{
37488c2ecf20Sopenharmony_ci	WREG32_P(CG_GIT, CG_GICST(R600_GICST_DFLT), ~CG_GICST_MASK);
37498c2ecf20Sopenharmony_ci}
37508c2ecf20Sopenharmony_ci
37518c2ecf20Sopenharmony_cistatic void si_program_tp(struct radeon_device *rdev)
37528c2ecf20Sopenharmony_ci{
37538c2ecf20Sopenharmony_ci	int i;
37548c2ecf20Sopenharmony_ci	enum r600_td td = R600_TD_DFLT;
37558c2ecf20Sopenharmony_ci
37568c2ecf20Sopenharmony_ci	for (i = 0; i < R600_PM_NUMBER_OF_TC; i++)
37578c2ecf20Sopenharmony_ci		WREG32(CG_FFCT_0 + (i * 4), (UTC_0(r600_utc[i]) | DTC_0(r600_dtc[i])));
37588c2ecf20Sopenharmony_ci
37598c2ecf20Sopenharmony_ci	if (td == R600_TD_AUTO)
37608c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_FORCE_TREND_SEL);
37618c2ecf20Sopenharmony_ci	else
37628c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PWRMGT_CNTL, FIR_FORCE_TREND_SEL, ~FIR_FORCE_TREND_SEL);
37638c2ecf20Sopenharmony_ci
37648c2ecf20Sopenharmony_ci	if (td == R600_TD_UP)
37658c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_TREND_MODE);
37668c2ecf20Sopenharmony_ci
37678c2ecf20Sopenharmony_ci	if (td == R600_TD_DOWN)
37688c2ecf20Sopenharmony_ci		WREG32_P(SCLK_PWRMGT_CNTL, FIR_TREND_MODE, ~FIR_TREND_MODE);
37698c2ecf20Sopenharmony_ci}
37708c2ecf20Sopenharmony_ci
37718c2ecf20Sopenharmony_cistatic void si_program_tpp(struct radeon_device *rdev)
37728c2ecf20Sopenharmony_ci{
37738c2ecf20Sopenharmony_ci	WREG32(CG_TPC, R600_TPC_DFLT);
37748c2ecf20Sopenharmony_ci}
37758c2ecf20Sopenharmony_ci
37768c2ecf20Sopenharmony_cistatic void si_program_sstp(struct radeon_device *rdev)
37778c2ecf20Sopenharmony_ci{
37788c2ecf20Sopenharmony_ci	WREG32(CG_SSP, (SSTU(R600_SSTU_DFLT) | SST(R600_SST_DFLT)));
37798c2ecf20Sopenharmony_ci}
37808c2ecf20Sopenharmony_ci
37818c2ecf20Sopenharmony_cistatic void si_enable_display_gap(struct radeon_device *rdev)
37828c2ecf20Sopenharmony_ci{
37838c2ecf20Sopenharmony_ci	u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
37848c2ecf20Sopenharmony_ci
37858c2ecf20Sopenharmony_ci	tmp &= ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
37868c2ecf20Sopenharmony_ci	tmp |= (DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE) |
37878c2ecf20Sopenharmony_ci		DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE));
37888c2ecf20Sopenharmony_ci
37898c2ecf20Sopenharmony_ci	tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
37908c2ecf20Sopenharmony_ci	tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK) |
37918c2ecf20Sopenharmony_ci		DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE));
37928c2ecf20Sopenharmony_ci	WREG32(CG_DISPLAY_GAP_CNTL, tmp);
37938c2ecf20Sopenharmony_ci}
37948c2ecf20Sopenharmony_ci
37958c2ecf20Sopenharmony_cistatic void si_program_vc(struct radeon_device *rdev)
37968c2ecf20Sopenharmony_ci{
37978c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
37988c2ecf20Sopenharmony_ci
37998c2ecf20Sopenharmony_ci	WREG32(CG_FTV, pi->vrc);
38008c2ecf20Sopenharmony_ci}
38018c2ecf20Sopenharmony_ci
38028c2ecf20Sopenharmony_cistatic void si_clear_vc(struct radeon_device *rdev)
38038c2ecf20Sopenharmony_ci{
38048c2ecf20Sopenharmony_ci	WREG32(CG_FTV, 0);
38058c2ecf20Sopenharmony_ci}
38068c2ecf20Sopenharmony_ci
38078c2ecf20Sopenharmony_ciu8 si_get_ddr3_mclk_frequency_ratio(u32 memory_clock)
38088c2ecf20Sopenharmony_ci{
38098c2ecf20Sopenharmony_ci	u8 mc_para_index;
38108c2ecf20Sopenharmony_ci
38118c2ecf20Sopenharmony_ci	if (memory_clock < 10000)
38128c2ecf20Sopenharmony_ci		mc_para_index = 0;
38138c2ecf20Sopenharmony_ci	else if (memory_clock >= 80000)
38148c2ecf20Sopenharmony_ci		mc_para_index = 0x0f;
38158c2ecf20Sopenharmony_ci	else
38168c2ecf20Sopenharmony_ci		mc_para_index = (u8)((memory_clock - 10000) / 5000 + 1);
38178c2ecf20Sopenharmony_ci	return mc_para_index;
38188c2ecf20Sopenharmony_ci}
38198c2ecf20Sopenharmony_ci
38208c2ecf20Sopenharmony_ciu8 si_get_mclk_frequency_ratio(u32 memory_clock, bool strobe_mode)
38218c2ecf20Sopenharmony_ci{
38228c2ecf20Sopenharmony_ci	u8 mc_para_index;
38238c2ecf20Sopenharmony_ci
38248c2ecf20Sopenharmony_ci	if (strobe_mode) {
38258c2ecf20Sopenharmony_ci		if (memory_clock < 12500)
38268c2ecf20Sopenharmony_ci			mc_para_index = 0x00;
38278c2ecf20Sopenharmony_ci		else if (memory_clock > 47500)
38288c2ecf20Sopenharmony_ci			mc_para_index = 0x0f;
38298c2ecf20Sopenharmony_ci		else
38308c2ecf20Sopenharmony_ci			mc_para_index = (u8)((memory_clock - 10000) / 2500);
38318c2ecf20Sopenharmony_ci	} else {
38328c2ecf20Sopenharmony_ci		if (memory_clock < 65000)
38338c2ecf20Sopenharmony_ci			mc_para_index = 0x00;
38348c2ecf20Sopenharmony_ci		else if (memory_clock > 135000)
38358c2ecf20Sopenharmony_ci			mc_para_index = 0x0f;
38368c2ecf20Sopenharmony_ci		else
38378c2ecf20Sopenharmony_ci			mc_para_index = (u8)((memory_clock - 60000) / 5000);
38388c2ecf20Sopenharmony_ci	}
38398c2ecf20Sopenharmony_ci	return mc_para_index;
38408c2ecf20Sopenharmony_ci}
38418c2ecf20Sopenharmony_ci
38428c2ecf20Sopenharmony_cistatic u8 si_get_strobe_mode_settings(struct radeon_device *rdev, u32 mclk)
38438c2ecf20Sopenharmony_ci{
38448c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
38458c2ecf20Sopenharmony_ci	bool strobe_mode = false;
38468c2ecf20Sopenharmony_ci	u8 result = 0;
38478c2ecf20Sopenharmony_ci
38488c2ecf20Sopenharmony_ci	if (mclk <= pi->mclk_strobe_mode_threshold)
38498c2ecf20Sopenharmony_ci		strobe_mode = true;
38508c2ecf20Sopenharmony_ci
38518c2ecf20Sopenharmony_ci	if (pi->mem_gddr5)
38528c2ecf20Sopenharmony_ci		result = si_get_mclk_frequency_ratio(mclk, strobe_mode);
38538c2ecf20Sopenharmony_ci	else
38548c2ecf20Sopenharmony_ci		result = si_get_ddr3_mclk_frequency_ratio(mclk);
38558c2ecf20Sopenharmony_ci
38568c2ecf20Sopenharmony_ci	if (strobe_mode)
38578c2ecf20Sopenharmony_ci		result |= SISLANDS_SMC_STROBE_ENABLE;
38588c2ecf20Sopenharmony_ci
38598c2ecf20Sopenharmony_ci	return result;
38608c2ecf20Sopenharmony_ci}
38618c2ecf20Sopenharmony_ci
38628c2ecf20Sopenharmony_cistatic int si_upload_firmware(struct radeon_device *rdev)
38638c2ecf20Sopenharmony_ci{
38648c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
38658c2ecf20Sopenharmony_ci	int ret;
38668c2ecf20Sopenharmony_ci
38678c2ecf20Sopenharmony_ci	si_reset_smc(rdev);
38688c2ecf20Sopenharmony_ci	si_stop_smc_clock(rdev);
38698c2ecf20Sopenharmony_ci
38708c2ecf20Sopenharmony_ci	ret = si_load_smc_ucode(rdev, si_pi->sram_end);
38718c2ecf20Sopenharmony_ci
38728c2ecf20Sopenharmony_ci	return ret;
38738c2ecf20Sopenharmony_ci}
38748c2ecf20Sopenharmony_ci
38758c2ecf20Sopenharmony_cistatic bool si_validate_phase_shedding_tables(struct radeon_device *rdev,
38768c2ecf20Sopenharmony_ci					      const struct atom_voltage_table *table,
38778c2ecf20Sopenharmony_ci					      const struct radeon_phase_shedding_limits_table *limits)
38788c2ecf20Sopenharmony_ci{
38798c2ecf20Sopenharmony_ci	u32 data, num_bits, num_levels;
38808c2ecf20Sopenharmony_ci
38818c2ecf20Sopenharmony_ci	if ((table == NULL) || (limits == NULL))
38828c2ecf20Sopenharmony_ci		return false;
38838c2ecf20Sopenharmony_ci
38848c2ecf20Sopenharmony_ci	data = table->mask_low;
38858c2ecf20Sopenharmony_ci
38868c2ecf20Sopenharmony_ci	num_bits = hweight32(data);
38878c2ecf20Sopenharmony_ci
38888c2ecf20Sopenharmony_ci	if (num_bits == 0)
38898c2ecf20Sopenharmony_ci		return false;
38908c2ecf20Sopenharmony_ci
38918c2ecf20Sopenharmony_ci	num_levels = (1 << num_bits);
38928c2ecf20Sopenharmony_ci
38938c2ecf20Sopenharmony_ci	if (table->count != num_levels)
38948c2ecf20Sopenharmony_ci		return false;
38958c2ecf20Sopenharmony_ci
38968c2ecf20Sopenharmony_ci	if (limits->count != (num_levels - 1))
38978c2ecf20Sopenharmony_ci		return false;
38988c2ecf20Sopenharmony_ci
38998c2ecf20Sopenharmony_ci	return true;
39008c2ecf20Sopenharmony_ci}
39018c2ecf20Sopenharmony_ci
39028c2ecf20Sopenharmony_civoid si_trim_voltage_table_to_fit_state_table(struct radeon_device *rdev,
39038c2ecf20Sopenharmony_ci					      u32 max_voltage_steps,
39048c2ecf20Sopenharmony_ci					      struct atom_voltage_table *voltage_table)
39058c2ecf20Sopenharmony_ci{
39068c2ecf20Sopenharmony_ci	unsigned int i, diff;
39078c2ecf20Sopenharmony_ci
39088c2ecf20Sopenharmony_ci	if (voltage_table->count <= max_voltage_steps)
39098c2ecf20Sopenharmony_ci		return;
39108c2ecf20Sopenharmony_ci
39118c2ecf20Sopenharmony_ci	diff = voltage_table->count - max_voltage_steps;
39128c2ecf20Sopenharmony_ci
39138c2ecf20Sopenharmony_ci	for (i= 0; i < max_voltage_steps; i++)
39148c2ecf20Sopenharmony_ci		voltage_table->entries[i] = voltage_table->entries[i + diff];
39158c2ecf20Sopenharmony_ci
39168c2ecf20Sopenharmony_ci	voltage_table->count = max_voltage_steps;
39178c2ecf20Sopenharmony_ci}
39188c2ecf20Sopenharmony_ci
39198c2ecf20Sopenharmony_cistatic int si_get_svi2_voltage_table(struct radeon_device *rdev,
39208c2ecf20Sopenharmony_ci				     struct radeon_clock_voltage_dependency_table *voltage_dependency_table,
39218c2ecf20Sopenharmony_ci				     struct atom_voltage_table *voltage_table)
39228c2ecf20Sopenharmony_ci{
39238c2ecf20Sopenharmony_ci	u32 i;
39248c2ecf20Sopenharmony_ci
39258c2ecf20Sopenharmony_ci	if (voltage_dependency_table == NULL)
39268c2ecf20Sopenharmony_ci		return -EINVAL;
39278c2ecf20Sopenharmony_ci
39288c2ecf20Sopenharmony_ci	voltage_table->mask_low = 0;
39298c2ecf20Sopenharmony_ci	voltage_table->phase_delay = 0;
39308c2ecf20Sopenharmony_ci
39318c2ecf20Sopenharmony_ci	voltage_table->count = voltage_dependency_table->count;
39328c2ecf20Sopenharmony_ci	for (i = 0; i < voltage_table->count; i++) {
39338c2ecf20Sopenharmony_ci		voltage_table->entries[i].value = voltage_dependency_table->entries[i].v;
39348c2ecf20Sopenharmony_ci		voltage_table->entries[i].smio_low = 0;
39358c2ecf20Sopenharmony_ci	}
39368c2ecf20Sopenharmony_ci
39378c2ecf20Sopenharmony_ci	return 0;
39388c2ecf20Sopenharmony_ci}
39398c2ecf20Sopenharmony_ci
39408c2ecf20Sopenharmony_cistatic int si_construct_voltage_tables(struct radeon_device *rdev)
39418c2ecf20Sopenharmony_ci{
39428c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
39438c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
39448c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
39458c2ecf20Sopenharmony_ci	int ret;
39468c2ecf20Sopenharmony_ci
39478c2ecf20Sopenharmony_ci	if (pi->voltage_control) {
39488c2ecf20Sopenharmony_ci		ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_VDDC,
39498c2ecf20Sopenharmony_ci						    VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddc_voltage_table);
39508c2ecf20Sopenharmony_ci		if (ret)
39518c2ecf20Sopenharmony_ci			return ret;
39528c2ecf20Sopenharmony_ci
39538c2ecf20Sopenharmony_ci		if (eg_pi->vddc_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
39548c2ecf20Sopenharmony_ci			si_trim_voltage_table_to_fit_state_table(rdev,
39558c2ecf20Sopenharmony_ci								 SISLANDS_MAX_NO_VREG_STEPS,
39568c2ecf20Sopenharmony_ci								 &eg_pi->vddc_voltage_table);
39578c2ecf20Sopenharmony_ci	} else if (si_pi->voltage_control_svi2) {
39588c2ecf20Sopenharmony_ci		ret = si_get_svi2_voltage_table(rdev,
39598c2ecf20Sopenharmony_ci						&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
39608c2ecf20Sopenharmony_ci						&eg_pi->vddc_voltage_table);
39618c2ecf20Sopenharmony_ci		if (ret)
39628c2ecf20Sopenharmony_ci			return ret;
39638c2ecf20Sopenharmony_ci	} else {
39648c2ecf20Sopenharmony_ci		return -EINVAL;
39658c2ecf20Sopenharmony_ci	}
39668c2ecf20Sopenharmony_ci
39678c2ecf20Sopenharmony_ci	if (eg_pi->vddci_control) {
39688c2ecf20Sopenharmony_ci		ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_VDDCI,
39698c2ecf20Sopenharmony_ci						    VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddci_voltage_table);
39708c2ecf20Sopenharmony_ci		if (ret)
39718c2ecf20Sopenharmony_ci			return ret;
39728c2ecf20Sopenharmony_ci
39738c2ecf20Sopenharmony_ci		if (eg_pi->vddci_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
39748c2ecf20Sopenharmony_ci			si_trim_voltage_table_to_fit_state_table(rdev,
39758c2ecf20Sopenharmony_ci								 SISLANDS_MAX_NO_VREG_STEPS,
39768c2ecf20Sopenharmony_ci								 &eg_pi->vddci_voltage_table);
39778c2ecf20Sopenharmony_ci	}
39788c2ecf20Sopenharmony_ci	if (si_pi->vddci_control_svi2) {
39798c2ecf20Sopenharmony_ci		ret = si_get_svi2_voltage_table(rdev,
39808c2ecf20Sopenharmony_ci						&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
39818c2ecf20Sopenharmony_ci						&eg_pi->vddci_voltage_table);
39828c2ecf20Sopenharmony_ci		if (ret)
39838c2ecf20Sopenharmony_ci			return ret;
39848c2ecf20Sopenharmony_ci	}
39858c2ecf20Sopenharmony_ci
39868c2ecf20Sopenharmony_ci	if (pi->mvdd_control) {
39878c2ecf20Sopenharmony_ci		ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_MVDDC,
39888c2ecf20Sopenharmony_ci						    VOLTAGE_OBJ_GPIO_LUT, &si_pi->mvdd_voltage_table);
39898c2ecf20Sopenharmony_ci
39908c2ecf20Sopenharmony_ci		if (ret) {
39918c2ecf20Sopenharmony_ci			pi->mvdd_control = false;
39928c2ecf20Sopenharmony_ci			return ret;
39938c2ecf20Sopenharmony_ci		}
39948c2ecf20Sopenharmony_ci
39958c2ecf20Sopenharmony_ci		if (si_pi->mvdd_voltage_table.count == 0) {
39968c2ecf20Sopenharmony_ci			pi->mvdd_control = false;
39978c2ecf20Sopenharmony_ci			return -EINVAL;
39988c2ecf20Sopenharmony_ci		}
39998c2ecf20Sopenharmony_ci
40008c2ecf20Sopenharmony_ci		if (si_pi->mvdd_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
40018c2ecf20Sopenharmony_ci			si_trim_voltage_table_to_fit_state_table(rdev,
40028c2ecf20Sopenharmony_ci								 SISLANDS_MAX_NO_VREG_STEPS,
40038c2ecf20Sopenharmony_ci								 &si_pi->mvdd_voltage_table);
40048c2ecf20Sopenharmony_ci	}
40058c2ecf20Sopenharmony_ci
40068c2ecf20Sopenharmony_ci	if (si_pi->vddc_phase_shed_control) {
40078c2ecf20Sopenharmony_ci		ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_VDDC,
40088c2ecf20Sopenharmony_ci						    VOLTAGE_OBJ_PHASE_LUT, &si_pi->vddc_phase_shed_table);
40098c2ecf20Sopenharmony_ci		if (ret)
40108c2ecf20Sopenharmony_ci			si_pi->vddc_phase_shed_control = false;
40118c2ecf20Sopenharmony_ci
40128c2ecf20Sopenharmony_ci		if ((si_pi->vddc_phase_shed_table.count == 0) ||
40138c2ecf20Sopenharmony_ci		    (si_pi->vddc_phase_shed_table.count > SISLANDS_MAX_NO_VREG_STEPS))
40148c2ecf20Sopenharmony_ci			si_pi->vddc_phase_shed_control = false;
40158c2ecf20Sopenharmony_ci	}
40168c2ecf20Sopenharmony_ci
40178c2ecf20Sopenharmony_ci	return 0;
40188c2ecf20Sopenharmony_ci}
40198c2ecf20Sopenharmony_ci
40208c2ecf20Sopenharmony_cistatic void si_populate_smc_voltage_table(struct radeon_device *rdev,
40218c2ecf20Sopenharmony_ci					  const struct atom_voltage_table *voltage_table,
40228c2ecf20Sopenharmony_ci					  SISLANDS_SMC_STATETABLE *table)
40238c2ecf20Sopenharmony_ci{
40248c2ecf20Sopenharmony_ci	unsigned int i;
40258c2ecf20Sopenharmony_ci
40268c2ecf20Sopenharmony_ci	for (i = 0; i < voltage_table->count; i++)
40278c2ecf20Sopenharmony_ci		table->lowSMIO[i] |= cpu_to_be32(voltage_table->entries[i].smio_low);
40288c2ecf20Sopenharmony_ci}
40298c2ecf20Sopenharmony_ci
40308c2ecf20Sopenharmony_cistatic int si_populate_smc_voltage_tables(struct radeon_device *rdev,
40318c2ecf20Sopenharmony_ci					  SISLANDS_SMC_STATETABLE *table)
40328c2ecf20Sopenharmony_ci{
40338c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
40348c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
40358c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
40368c2ecf20Sopenharmony_ci	u8 i;
40378c2ecf20Sopenharmony_ci
40388c2ecf20Sopenharmony_ci	if (si_pi->voltage_control_svi2) {
40398c2ecf20Sopenharmony_ci		si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc,
40408c2ecf20Sopenharmony_ci			si_pi->svc_gpio_id);
40418c2ecf20Sopenharmony_ci		si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd,
40428c2ecf20Sopenharmony_ci			si_pi->svd_gpio_id);
40438c2ecf20Sopenharmony_ci		si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_svi_rework_plat_type,
40448c2ecf20Sopenharmony_ci					   2);
40458c2ecf20Sopenharmony_ci	} else {
40468c2ecf20Sopenharmony_ci		if (eg_pi->vddc_voltage_table.count) {
40478c2ecf20Sopenharmony_ci			si_populate_smc_voltage_table(rdev, &eg_pi->vddc_voltage_table, table);
40488c2ecf20Sopenharmony_ci			table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] =
40498c2ecf20Sopenharmony_ci				cpu_to_be32(eg_pi->vddc_voltage_table.mask_low);
40508c2ecf20Sopenharmony_ci
40518c2ecf20Sopenharmony_ci			for (i = 0; i < eg_pi->vddc_voltage_table.count; i++) {
40528c2ecf20Sopenharmony_ci				if (pi->max_vddc_in_table <= eg_pi->vddc_voltage_table.entries[i].value) {
40538c2ecf20Sopenharmony_ci					table->maxVDDCIndexInPPTable = i;
40548c2ecf20Sopenharmony_ci					break;
40558c2ecf20Sopenharmony_ci				}
40568c2ecf20Sopenharmony_ci			}
40578c2ecf20Sopenharmony_ci		}
40588c2ecf20Sopenharmony_ci
40598c2ecf20Sopenharmony_ci		if (eg_pi->vddci_voltage_table.count) {
40608c2ecf20Sopenharmony_ci			si_populate_smc_voltage_table(rdev, &eg_pi->vddci_voltage_table, table);
40618c2ecf20Sopenharmony_ci
40628c2ecf20Sopenharmony_ci			table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDCI] =
40638c2ecf20Sopenharmony_ci				cpu_to_be32(eg_pi->vddci_voltage_table.mask_low);
40648c2ecf20Sopenharmony_ci		}
40658c2ecf20Sopenharmony_ci
40668c2ecf20Sopenharmony_ci
40678c2ecf20Sopenharmony_ci		if (si_pi->mvdd_voltage_table.count) {
40688c2ecf20Sopenharmony_ci			si_populate_smc_voltage_table(rdev, &si_pi->mvdd_voltage_table, table);
40698c2ecf20Sopenharmony_ci
40708c2ecf20Sopenharmony_ci			table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_MVDD] =
40718c2ecf20Sopenharmony_ci				cpu_to_be32(si_pi->mvdd_voltage_table.mask_low);
40728c2ecf20Sopenharmony_ci		}
40738c2ecf20Sopenharmony_ci
40748c2ecf20Sopenharmony_ci		if (si_pi->vddc_phase_shed_control) {
40758c2ecf20Sopenharmony_ci			if (si_validate_phase_shedding_tables(rdev, &si_pi->vddc_phase_shed_table,
40768c2ecf20Sopenharmony_ci							      &rdev->pm.dpm.dyn_state.phase_shedding_limits_table)) {
40778c2ecf20Sopenharmony_ci				si_populate_smc_voltage_table(rdev, &si_pi->vddc_phase_shed_table, table);
40788c2ecf20Sopenharmony_ci
40798c2ecf20Sopenharmony_ci				table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING] =
40808c2ecf20Sopenharmony_ci					cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low);
40818c2ecf20Sopenharmony_ci
40828c2ecf20Sopenharmony_ci				si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_phase_shedding_delay,
40838c2ecf20Sopenharmony_ci							   (u32)si_pi->vddc_phase_shed_table.phase_delay);
40848c2ecf20Sopenharmony_ci			} else {
40858c2ecf20Sopenharmony_ci				si_pi->vddc_phase_shed_control = false;
40868c2ecf20Sopenharmony_ci			}
40878c2ecf20Sopenharmony_ci		}
40888c2ecf20Sopenharmony_ci	}
40898c2ecf20Sopenharmony_ci
40908c2ecf20Sopenharmony_ci	return 0;
40918c2ecf20Sopenharmony_ci}
40928c2ecf20Sopenharmony_ci
40938c2ecf20Sopenharmony_cistatic int si_populate_voltage_value(struct radeon_device *rdev,
40948c2ecf20Sopenharmony_ci				     const struct atom_voltage_table *table,
40958c2ecf20Sopenharmony_ci				     u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage)
40968c2ecf20Sopenharmony_ci{
40978c2ecf20Sopenharmony_ci	unsigned int i;
40988c2ecf20Sopenharmony_ci
40998c2ecf20Sopenharmony_ci	for (i = 0; i < table->count; i++) {
41008c2ecf20Sopenharmony_ci		if (value <= table->entries[i].value) {
41018c2ecf20Sopenharmony_ci			voltage->index = (u8)i;
41028c2ecf20Sopenharmony_ci			voltage->value = cpu_to_be16(table->entries[i].value);
41038c2ecf20Sopenharmony_ci			break;
41048c2ecf20Sopenharmony_ci		}
41058c2ecf20Sopenharmony_ci	}
41068c2ecf20Sopenharmony_ci
41078c2ecf20Sopenharmony_ci	if (i >= table->count)
41088c2ecf20Sopenharmony_ci		return -EINVAL;
41098c2ecf20Sopenharmony_ci
41108c2ecf20Sopenharmony_ci	return 0;
41118c2ecf20Sopenharmony_ci}
41128c2ecf20Sopenharmony_ci
41138c2ecf20Sopenharmony_cistatic int si_populate_mvdd_value(struct radeon_device *rdev, u32 mclk,
41148c2ecf20Sopenharmony_ci				  SISLANDS_SMC_VOLTAGE_VALUE *voltage)
41158c2ecf20Sopenharmony_ci{
41168c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
41178c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
41188c2ecf20Sopenharmony_ci
41198c2ecf20Sopenharmony_ci	if (pi->mvdd_control) {
41208c2ecf20Sopenharmony_ci		if (mclk <= pi->mvdd_split_frequency)
41218c2ecf20Sopenharmony_ci			voltage->index = 0;
41228c2ecf20Sopenharmony_ci		else
41238c2ecf20Sopenharmony_ci			voltage->index = (u8)(si_pi->mvdd_voltage_table.count) - 1;
41248c2ecf20Sopenharmony_ci
41258c2ecf20Sopenharmony_ci		voltage->value = cpu_to_be16(si_pi->mvdd_voltage_table.entries[voltage->index].value);
41268c2ecf20Sopenharmony_ci	}
41278c2ecf20Sopenharmony_ci	return 0;
41288c2ecf20Sopenharmony_ci}
41298c2ecf20Sopenharmony_ci
41308c2ecf20Sopenharmony_cistatic int si_get_std_voltage_value(struct radeon_device *rdev,
41318c2ecf20Sopenharmony_ci				    SISLANDS_SMC_VOLTAGE_VALUE *voltage,
41328c2ecf20Sopenharmony_ci				    u16 *std_voltage)
41338c2ecf20Sopenharmony_ci{
41348c2ecf20Sopenharmony_ci	u16 v_index;
41358c2ecf20Sopenharmony_ci	bool voltage_found = false;
41368c2ecf20Sopenharmony_ci	*std_voltage = be16_to_cpu(voltage->value);
41378c2ecf20Sopenharmony_ci
41388c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.dyn_state.cac_leakage_table.entries) {
41398c2ecf20Sopenharmony_ci		if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_NEW_CAC_VOLTAGE) {
41408c2ecf20Sopenharmony_ci			if (rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries == NULL)
41418c2ecf20Sopenharmony_ci				return -EINVAL;
41428c2ecf20Sopenharmony_ci
41438c2ecf20Sopenharmony_ci			for (v_index = 0; (u32)v_index < rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
41448c2ecf20Sopenharmony_ci				if (be16_to_cpu(voltage->value) ==
41458c2ecf20Sopenharmony_ci				    (u16)rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
41468c2ecf20Sopenharmony_ci					voltage_found = true;
41478c2ecf20Sopenharmony_ci					if ((u32)v_index < rdev->pm.dpm.dyn_state.cac_leakage_table.count)
41488c2ecf20Sopenharmony_ci						*std_voltage =
41498c2ecf20Sopenharmony_ci							rdev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
41508c2ecf20Sopenharmony_ci					else
41518c2ecf20Sopenharmony_ci						*std_voltage =
41528c2ecf20Sopenharmony_ci							rdev->pm.dpm.dyn_state.cac_leakage_table.entries[rdev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
41538c2ecf20Sopenharmony_ci					break;
41548c2ecf20Sopenharmony_ci				}
41558c2ecf20Sopenharmony_ci			}
41568c2ecf20Sopenharmony_ci
41578c2ecf20Sopenharmony_ci			if (!voltage_found) {
41588c2ecf20Sopenharmony_ci				for (v_index = 0; (u32)v_index < rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
41598c2ecf20Sopenharmony_ci					if (be16_to_cpu(voltage->value) <=
41608c2ecf20Sopenharmony_ci					    (u16)rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
41618c2ecf20Sopenharmony_ci						voltage_found = true;
41628c2ecf20Sopenharmony_ci						if ((u32)v_index < rdev->pm.dpm.dyn_state.cac_leakage_table.count)
41638c2ecf20Sopenharmony_ci							*std_voltage =
41648c2ecf20Sopenharmony_ci								rdev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
41658c2ecf20Sopenharmony_ci						else
41668c2ecf20Sopenharmony_ci							*std_voltage =
41678c2ecf20Sopenharmony_ci								rdev->pm.dpm.dyn_state.cac_leakage_table.entries[rdev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
41688c2ecf20Sopenharmony_ci						break;
41698c2ecf20Sopenharmony_ci					}
41708c2ecf20Sopenharmony_ci				}
41718c2ecf20Sopenharmony_ci			}
41728c2ecf20Sopenharmony_ci		} else {
41738c2ecf20Sopenharmony_ci			if ((u32)voltage->index < rdev->pm.dpm.dyn_state.cac_leakage_table.count)
41748c2ecf20Sopenharmony_ci				*std_voltage = rdev->pm.dpm.dyn_state.cac_leakage_table.entries[voltage->index].vddc;
41758c2ecf20Sopenharmony_ci		}
41768c2ecf20Sopenharmony_ci	}
41778c2ecf20Sopenharmony_ci
41788c2ecf20Sopenharmony_ci	return 0;
41798c2ecf20Sopenharmony_ci}
41808c2ecf20Sopenharmony_ci
41818c2ecf20Sopenharmony_cistatic int si_populate_std_voltage_value(struct radeon_device *rdev,
41828c2ecf20Sopenharmony_ci					 u16 value, u8 index,
41838c2ecf20Sopenharmony_ci					 SISLANDS_SMC_VOLTAGE_VALUE *voltage)
41848c2ecf20Sopenharmony_ci{
41858c2ecf20Sopenharmony_ci	voltage->index = index;
41868c2ecf20Sopenharmony_ci	voltage->value = cpu_to_be16(value);
41878c2ecf20Sopenharmony_ci
41888c2ecf20Sopenharmony_ci	return 0;
41898c2ecf20Sopenharmony_ci}
41908c2ecf20Sopenharmony_ci
41918c2ecf20Sopenharmony_cistatic int si_populate_phase_shedding_value(struct radeon_device *rdev,
41928c2ecf20Sopenharmony_ci					    const struct radeon_phase_shedding_limits_table *limits,
41938c2ecf20Sopenharmony_ci					    u16 voltage, u32 sclk, u32 mclk,
41948c2ecf20Sopenharmony_ci					    SISLANDS_SMC_VOLTAGE_VALUE *smc_voltage)
41958c2ecf20Sopenharmony_ci{
41968c2ecf20Sopenharmony_ci	unsigned int i;
41978c2ecf20Sopenharmony_ci
41988c2ecf20Sopenharmony_ci	for (i = 0; i < limits->count; i++) {
41998c2ecf20Sopenharmony_ci		if ((voltage <= limits->entries[i].voltage) &&
42008c2ecf20Sopenharmony_ci		    (sclk <= limits->entries[i].sclk) &&
42018c2ecf20Sopenharmony_ci		    (mclk <= limits->entries[i].mclk))
42028c2ecf20Sopenharmony_ci			break;
42038c2ecf20Sopenharmony_ci	}
42048c2ecf20Sopenharmony_ci
42058c2ecf20Sopenharmony_ci	smc_voltage->phase_settings = (u8)i;
42068c2ecf20Sopenharmony_ci
42078c2ecf20Sopenharmony_ci	return 0;
42088c2ecf20Sopenharmony_ci}
42098c2ecf20Sopenharmony_ci
42108c2ecf20Sopenharmony_cistatic int si_init_arb_table_index(struct radeon_device *rdev)
42118c2ecf20Sopenharmony_ci{
42128c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
42138c2ecf20Sopenharmony_ci	u32 tmp;
42148c2ecf20Sopenharmony_ci	int ret;
42158c2ecf20Sopenharmony_ci
42168c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev, si_pi->arb_table_start, &tmp, si_pi->sram_end);
42178c2ecf20Sopenharmony_ci	if (ret)
42188c2ecf20Sopenharmony_ci		return ret;
42198c2ecf20Sopenharmony_ci
42208c2ecf20Sopenharmony_ci	tmp &= 0x00FFFFFF;
42218c2ecf20Sopenharmony_ci	tmp |= MC_CG_ARB_FREQ_F1 << 24;
42228c2ecf20Sopenharmony_ci
42238c2ecf20Sopenharmony_ci	return si_write_smc_sram_dword(rdev, si_pi->arb_table_start,  tmp, si_pi->sram_end);
42248c2ecf20Sopenharmony_ci}
42258c2ecf20Sopenharmony_ci
42268c2ecf20Sopenharmony_cistatic int si_initial_switch_from_arb_f0_to_f1(struct radeon_device *rdev)
42278c2ecf20Sopenharmony_ci{
42288c2ecf20Sopenharmony_ci	return ni_copy_and_switch_arb_sets(rdev, MC_CG_ARB_FREQ_F0, MC_CG_ARB_FREQ_F1);
42298c2ecf20Sopenharmony_ci}
42308c2ecf20Sopenharmony_ci
42318c2ecf20Sopenharmony_cistatic int si_reset_to_default(struct radeon_device *rdev)
42328c2ecf20Sopenharmony_ci{
42338c2ecf20Sopenharmony_ci	return (si_send_msg_to_smc(rdev, PPSMC_MSG_ResetToDefaults) == PPSMC_Result_OK) ?
42348c2ecf20Sopenharmony_ci		0 : -EINVAL;
42358c2ecf20Sopenharmony_ci}
42368c2ecf20Sopenharmony_ci
42378c2ecf20Sopenharmony_cistatic int si_force_switch_to_arb_f0(struct radeon_device *rdev)
42388c2ecf20Sopenharmony_ci{
42398c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
42408c2ecf20Sopenharmony_ci	u32 tmp;
42418c2ecf20Sopenharmony_ci	int ret;
42428c2ecf20Sopenharmony_ci
42438c2ecf20Sopenharmony_ci	ret = si_read_smc_sram_dword(rdev, si_pi->arb_table_start,
42448c2ecf20Sopenharmony_ci				     &tmp, si_pi->sram_end);
42458c2ecf20Sopenharmony_ci	if (ret)
42468c2ecf20Sopenharmony_ci		return ret;
42478c2ecf20Sopenharmony_ci
42488c2ecf20Sopenharmony_ci	tmp = (tmp >> 24) & 0xff;
42498c2ecf20Sopenharmony_ci
42508c2ecf20Sopenharmony_ci	if (tmp == MC_CG_ARB_FREQ_F0)
42518c2ecf20Sopenharmony_ci		return 0;
42528c2ecf20Sopenharmony_ci
42538c2ecf20Sopenharmony_ci	return ni_copy_and_switch_arb_sets(rdev, tmp, MC_CG_ARB_FREQ_F0);
42548c2ecf20Sopenharmony_ci}
42558c2ecf20Sopenharmony_ci
42568c2ecf20Sopenharmony_cistatic u32 si_calculate_memory_refresh_rate(struct radeon_device *rdev,
42578c2ecf20Sopenharmony_ci					    u32 engine_clock)
42588c2ecf20Sopenharmony_ci{
42598c2ecf20Sopenharmony_ci	u32 dram_rows;
42608c2ecf20Sopenharmony_ci	u32 dram_refresh_rate;
42618c2ecf20Sopenharmony_ci	u32 mc_arb_rfsh_rate;
42628c2ecf20Sopenharmony_ci	u32 tmp = (RREG32(MC_ARB_RAMCFG) & NOOFROWS_MASK) >> NOOFROWS_SHIFT;
42638c2ecf20Sopenharmony_ci
42648c2ecf20Sopenharmony_ci	if (tmp >= 4)
42658c2ecf20Sopenharmony_ci		dram_rows = 16384;
42668c2ecf20Sopenharmony_ci	else
42678c2ecf20Sopenharmony_ci		dram_rows = 1 << (tmp + 10);
42688c2ecf20Sopenharmony_ci
42698c2ecf20Sopenharmony_ci	dram_refresh_rate = 1 << ((RREG32(MC_SEQ_MISC0) & 0x3) + 3);
42708c2ecf20Sopenharmony_ci	mc_arb_rfsh_rate = ((engine_clock * 10) * dram_refresh_rate / dram_rows - 32) / 64;
42718c2ecf20Sopenharmony_ci
42728c2ecf20Sopenharmony_ci	return mc_arb_rfsh_rate;
42738c2ecf20Sopenharmony_ci}
42748c2ecf20Sopenharmony_ci
42758c2ecf20Sopenharmony_cistatic int si_populate_memory_timing_parameters(struct radeon_device *rdev,
42768c2ecf20Sopenharmony_ci						struct rv7xx_pl *pl,
42778c2ecf20Sopenharmony_ci						SMC_SIslands_MCArbDramTimingRegisterSet *arb_regs)
42788c2ecf20Sopenharmony_ci{
42798c2ecf20Sopenharmony_ci	u32 dram_timing;
42808c2ecf20Sopenharmony_ci	u32 dram_timing2;
42818c2ecf20Sopenharmony_ci	u32 burst_time;
42828c2ecf20Sopenharmony_ci
42838c2ecf20Sopenharmony_ci	arb_regs->mc_arb_rfsh_rate =
42848c2ecf20Sopenharmony_ci		(u8)si_calculate_memory_refresh_rate(rdev, pl->sclk);
42858c2ecf20Sopenharmony_ci
42868c2ecf20Sopenharmony_ci	radeon_atom_set_engine_dram_timings(rdev,
42878c2ecf20Sopenharmony_ci					    pl->sclk,
42888c2ecf20Sopenharmony_ci					    pl->mclk);
42898c2ecf20Sopenharmony_ci
42908c2ecf20Sopenharmony_ci	dram_timing  = RREG32(MC_ARB_DRAM_TIMING);
42918c2ecf20Sopenharmony_ci	dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
42928c2ecf20Sopenharmony_ci	burst_time = RREG32(MC_ARB_BURST_TIME) & STATE0_MASK;
42938c2ecf20Sopenharmony_ci
42948c2ecf20Sopenharmony_ci	arb_regs->mc_arb_dram_timing  = cpu_to_be32(dram_timing);
42958c2ecf20Sopenharmony_ci	arb_regs->mc_arb_dram_timing2 = cpu_to_be32(dram_timing2);
42968c2ecf20Sopenharmony_ci	arb_regs->mc_arb_burst_time = (u8)burst_time;
42978c2ecf20Sopenharmony_ci
42988c2ecf20Sopenharmony_ci	return 0;
42998c2ecf20Sopenharmony_ci}
43008c2ecf20Sopenharmony_ci
43018c2ecf20Sopenharmony_cistatic int si_do_program_memory_timing_parameters(struct radeon_device *rdev,
43028c2ecf20Sopenharmony_ci						  struct radeon_ps *radeon_state,
43038c2ecf20Sopenharmony_ci						  unsigned int first_arb_set)
43048c2ecf20Sopenharmony_ci{
43058c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
43068c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
43078c2ecf20Sopenharmony_ci	SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
43088c2ecf20Sopenharmony_ci	int i, ret = 0;
43098c2ecf20Sopenharmony_ci
43108c2ecf20Sopenharmony_ci	for (i = 0; i < state->performance_level_count; i++) {
43118c2ecf20Sopenharmony_ci		ret = si_populate_memory_timing_parameters(rdev, &state->performance_levels[i], &arb_regs);
43128c2ecf20Sopenharmony_ci		if (ret)
43138c2ecf20Sopenharmony_ci			break;
43148c2ecf20Sopenharmony_ci		ret = si_copy_bytes_to_smc(rdev,
43158c2ecf20Sopenharmony_ci					   si_pi->arb_table_start +
43168c2ecf20Sopenharmony_ci					   offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
43178c2ecf20Sopenharmony_ci					   sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * (first_arb_set + i),
43188c2ecf20Sopenharmony_ci					   (u8 *)&arb_regs,
43198c2ecf20Sopenharmony_ci					   sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
43208c2ecf20Sopenharmony_ci					   si_pi->sram_end);
43218c2ecf20Sopenharmony_ci		if (ret)
43228c2ecf20Sopenharmony_ci			break;
43238c2ecf20Sopenharmony_ci	}
43248c2ecf20Sopenharmony_ci
43258c2ecf20Sopenharmony_ci	return ret;
43268c2ecf20Sopenharmony_ci}
43278c2ecf20Sopenharmony_ci
43288c2ecf20Sopenharmony_cistatic int si_program_memory_timing_parameters(struct radeon_device *rdev,
43298c2ecf20Sopenharmony_ci					       struct radeon_ps *radeon_new_state)
43308c2ecf20Sopenharmony_ci{
43318c2ecf20Sopenharmony_ci	return si_do_program_memory_timing_parameters(rdev, radeon_new_state,
43328c2ecf20Sopenharmony_ci						      SISLANDS_DRIVER_STATE_ARB_INDEX);
43338c2ecf20Sopenharmony_ci}
43348c2ecf20Sopenharmony_ci
43358c2ecf20Sopenharmony_cistatic int si_populate_initial_mvdd_value(struct radeon_device *rdev,
43368c2ecf20Sopenharmony_ci					  struct SISLANDS_SMC_VOLTAGE_VALUE *voltage)
43378c2ecf20Sopenharmony_ci{
43388c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
43398c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
43408c2ecf20Sopenharmony_ci
43418c2ecf20Sopenharmony_ci	if (pi->mvdd_control)
43428c2ecf20Sopenharmony_ci		return si_populate_voltage_value(rdev, &si_pi->mvdd_voltage_table,
43438c2ecf20Sopenharmony_ci						 si_pi->mvdd_bootup_value, voltage);
43448c2ecf20Sopenharmony_ci
43458c2ecf20Sopenharmony_ci	return 0;
43468c2ecf20Sopenharmony_ci}
43478c2ecf20Sopenharmony_ci
43488c2ecf20Sopenharmony_cistatic int si_populate_smc_initial_state(struct radeon_device *rdev,
43498c2ecf20Sopenharmony_ci					 struct radeon_ps *radeon_initial_state,
43508c2ecf20Sopenharmony_ci					 SISLANDS_SMC_STATETABLE *table)
43518c2ecf20Sopenharmony_ci{
43528c2ecf20Sopenharmony_ci	struct ni_ps *initial_state = ni_get_ps(radeon_initial_state);
43538c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
43548c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
43558c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
43568c2ecf20Sopenharmony_ci	u32 reg;
43578c2ecf20Sopenharmony_ci	int ret;
43588c2ecf20Sopenharmony_ci
43598c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vDLL_CNTL =
43608c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.dll_cntl);
43618c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
43628c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mclk_pwrmgt_cntl);
43638c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
43648c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_ad_func_cntl);
43658c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
43668c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_dq_func_cntl);
43678c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL =
43688c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_func_cntl);
43698c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
43708c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_1);
43718c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
43728c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_2);
43738c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_SS =
43748c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_ss1);
43758c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.vMPLL_SS2 =
43768c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_ss2);
43778c2ecf20Sopenharmony_ci
43788c2ecf20Sopenharmony_ci	table->initialState.levels[0].mclk.mclk_value =
43798c2ecf20Sopenharmony_ci		cpu_to_be32(initial_state->performance_levels[0].mclk);
43808c2ecf20Sopenharmony_ci
43818c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
43828c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl);
43838c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
43848c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_2);
43858c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
43868c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_3);
43878c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
43888c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_4);
43898c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM =
43908c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum);
43918c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM_2  =
43928c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum_2);
43938c2ecf20Sopenharmony_ci
43948c2ecf20Sopenharmony_ci	table->initialState.levels[0].sclk.sclk_value =
43958c2ecf20Sopenharmony_ci		cpu_to_be32(initial_state->performance_levels[0].sclk);
43968c2ecf20Sopenharmony_ci
43978c2ecf20Sopenharmony_ci	table->initialState.levels[0].arbRefreshState =
43988c2ecf20Sopenharmony_ci		SISLANDS_INITIAL_STATE_ARB_INDEX;
43998c2ecf20Sopenharmony_ci
44008c2ecf20Sopenharmony_ci	table->initialState.levels[0].ACIndex = 0;
44018c2ecf20Sopenharmony_ci
44028c2ecf20Sopenharmony_ci	ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
44038c2ecf20Sopenharmony_ci					initial_state->performance_levels[0].vddc,
44048c2ecf20Sopenharmony_ci					&table->initialState.levels[0].vddc);
44058c2ecf20Sopenharmony_ci
44068c2ecf20Sopenharmony_ci	if (!ret) {
44078c2ecf20Sopenharmony_ci		u16 std_vddc;
44088c2ecf20Sopenharmony_ci
44098c2ecf20Sopenharmony_ci		ret = si_get_std_voltage_value(rdev,
44108c2ecf20Sopenharmony_ci					       &table->initialState.levels[0].vddc,
44118c2ecf20Sopenharmony_ci					       &std_vddc);
44128c2ecf20Sopenharmony_ci		if (!ret)
44138c2ecf20Sopenharmony_ci			si_populate_std_voltage_value(rdev, std_vddc,
44148c2ecf20Sopenharmony_ci						      table->initialState.levels[0].vddc.index,
44158c2ecf20Sopenharmony_ci						      &table->initialState.levels[0].std_vddc);
44168c2ecf20Sopenharmony_ci	}
44178c2ecf20Sopenharmony_ci
44188c2ecf20Sopenharmony_ci	if (eg_pi->vddci_control)
44198c2ecf20Sopenharmony_ci		si_populate_voltage_value(rdev,
44208c2ecf20Sopenharmony_ci					  &eg_pi->vddci_voltage_table,
44218c2ecf20Sopenharmony_ci					  initial_state->performance_levels[0].vddci,
44228c2ecf20Sopenharmony_ci					  &table->initialState.levels[0].vddci);
44238c2ecf20Sopenharmony_ci
44248c2ecf20Sopenharmony_ci	if (si_pi->vddc_phase_shed_control)
44258c2ecf20Sopenharmony_ci		si_populate_phase_shedding_value(rdev,
44268c2ecf20Sopenharmony_ci						 &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
44278c2ecf20Sopenharmony_ci						 initial_state->performance_levels[0].vddc,
44288c2ecf20Sopenharmony_ci						 initial_state->performance_levels[0].sclk,
44298c2ecf20Sopenharmony_ci						 initial_state->performance_levels[0].mclk,
44308c2ecf20Sopenharmony_ci						 &table->initialState.levels[0].vddc);
44318c2ecf20Sopenharmony_ci
44328c2ecf20Sopenharmony_ci	si_populate_initial_mvdd_value(rdev, &table->initialState.levels[0].mvdd);
44338c2ecf20Sopenharmony_ci
44348c2ecf20Sopenharmony_ci	reg = CG_R(0xffff) | CG_L(0);
44358c2ecf20Sopenharmony_ci	table->initialState.levels[0].aT = cpu_to_be32(reg);
44368c2ecf20Sopenharmony_ci
44378c2ecf20Sopenharmony_ci	table->initialState.levels[0].bSP = cpu_to_be32(pi->dsp);
44388c2ecf20Sopenharmony_ci
44398c2ecf20Sopenharmony_ci	table->initialState.levels[0].gen2PCIE = (u8)si_pi->boot_pcie_gen;
44408c2ecf20Sopenharmony_ci
44418c2ecf20Sopenharmony_ci	if (pi->mem_gddr5) {
44428c2ecf20Sopenharmony_ci		table->initialState.levels[0].strobeMode =
44438c2ecf20Sopenharmony_ci			si_get_strobe_mode_settings(rdev,
44448c2ecf20Sopenharmony_ci						    initial_state->performance_levels[0].mclk);
44458c2ecf20Sopenharmony_ci
44468c2ecf20Sopenharmony_ci		if (initial_state->performance_levels[0].mclk > pi->mclk_edc_enable_threshold)
44478c2ecf20Sopenharmony_ci			table->initialState.levels[0].mcFlags = SISLANDS_SMC_MC_EDC_RD_FLAG | SISLANDS_SMC_MC_EDC_WR_FLAG;
44488c2ecf20Sopenharmony_ci		else
44498c2ecf20Sopenharmony_ci			table->initialState.levels[0].mcFlags =  0;
44508c2ecf20Sopenharmony_ci	}
44518c2ecf20Sopenharmony_ci
44528c2ecf20Sopenharmony_ci	table->initialState.levelCount = 1;
44538c2ecf20Sopenharmony_ci
44548c2ecf20Sopenharmony_ci	table->initialState.flags |= PPSMC_SWSTATE_FLAG_DC;
44558c2ecf20Sopenharmony_ci
44568c2ecf20Sopenharmony_ci	table->initialState.levels[0].dpm2.MaxPS = 0;
44578c2ecf20Sopenharmony_ci	table->initialState.levels[0].dpm2.NearTDPDec = 0;
44588c2ecf20Sopenharmony_ci	table->initialState.levels[0].dpm2.AboveSafeInc = 0;
44598c2ecf20Sopenharmony_ci	table->initialState.levels[0].dpm2.BelowSafeInc = 0;
44608c2ecf20Sopenharmony_ci	table->initialState.levels[0].dpm2.PwrEfficiencyRatio = 0;
44618c2ecf20Sopenharmony_ci
44628c2ecf20Sopenharmony_ci	reg = MIN_POWER_MASK | MAX_POWER_MASK;
44638c2ecf20Sopenharmony_ci	table->initialState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
44648c2ecf20Sopenharmony_ci
44658c2ecf20Sopenharmony_ci	reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
44668c2ecf20Sopenharmony_ci	table->initialState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
44678c2ecf20Sopenharmony_ci
44688c2ecf20Sopenharmony_ci	return 0;
44698c2ecf20Sopenharmony_ci}
44708c2ecf20Sopenharmony_ci
44718c2ecf20Sopenharmony_cistatic int si_populate_smc_acpi_state(struct radeon_device *rdev,
44728c2ecf20Sopenharmony_ci				      SISLANDS_SMC_STATETABLE *table)
44738c2ecf20Sopenharmony_ci{
44748c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
44758c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
44768c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
44778c2ecf20Sopenharmony_ci	u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
44788c2ecf20Sopenharmony_ci	u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
44798c2ecf20Sopenharmony_ci	u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
44808c2ecf20Sopenharmony_ci	u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
44818c2ecf20Sopenharmony_ci	u32 dll_cntl = si_pi->clock_registers.dll_cntl;
44828c2ecf20Sopenharmony_ci	u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
44838c2ecf20Sopenharmony_ci	u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
44848c2ecf20Sopenharmony_ci	u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
44858c2ecf20Sopenharmony_ci	u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
44868c2ecf20Sopenharmony_ci	u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
44878c2ecf20Sopenharmony_ci	u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
44888c2ecf20Sopenharmony_ci	u32 reg;
44898c2ecf20Sopenharmony_ci	int ret;
44908c2ecf20Sopenharmony_ci
44918c2ecf20Sopenharmony_ci	table->ACPIState = table->initialState;
44928c2ecf20Sopenharmony_ci
44938c2ecf20Sopenharmony_ci	table->ACPIState.flags &= ~PPSMC_SWSTATE_FLAG_DC;
44948c2ecf20Sopenharmony_ci
44958c2ecf20Sopenharmony_ci	if (pi->acpi_vddc) {
44968c2ecf20Sopenharmony_ci		ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
44978c2ecf20Sopenharmony_ci						pi->acpi_vddc, &table->ACPIState.levels[0].vddc);
44988c2ecf20Sopenharmony_ci		if (!ret) {
44998c2ecf20Sopenharmony_ci			u16 std_vddc;
45008c2ecf20Sopenharmony_ci
45018c2ecf20Sopenharmony_ci			ret = si_get_std_voltage_value(rdev,
45028c2ecf20Sopenharmony_ci						       &table->ACPIState.levels[0].vddc, &std_vddc);
45038c2ecf20Sopenharmony_ci			if (!ret)
45048c2ecf20Sopenharmony_ci				si_populate_std_voltage_value(rdev, std_vddc,
45058c2ecf20Sopenharmony_ci							      table->ACPIState.levels[0].vddc.index,
45068c2ecf20Sopenharmony_ci							      &table->ACPIState.levels[0].std_vddc);
45078c2ecf20Sopenharmony_ci		}
45088c2ecf20Sopenharmony_ci		table->ACPIState.levels[0].gen2PCIE = si_pi->acpi_pcie_gen;
45098c2ecf20Sopenharmony_ci
45108c2ecf20Sopenharmony_ci		if (si_pi->vddc_phase_shed_control) {
45118c2ecf20Sopenharmony_ci			si_populate_phase_shedding_value(rdev,
45128c2ecf20Sopenharmony_ci							 &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
45138c2ecf20Sopenharmony_ci							 pi->acpi_vddc,
45148c2ecf20Sopenharmony_ci							 0,
45158c2ecf20Sopenharmony_ci							 0,
45168c2ecf20Sopenharmony_ci							 &table->ACPIState.levels[0].vddc);
45178c2ecf20Sopenharmony_ci		}
45188c2ecf20Sopenharmony_ci	} else {
45198c2ecf20Sopenharmony_ci		ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
45208c2ecf20Sopenharmony_ci						pi->min_vddc_in_table, &table->ACPIState.levels[0].vddc);
45218c2ecf20Sopenharmony_ci		if (!ret) {
45228c2ecf20Sopenharmony_ci			u16 std_vddc;
45238c2ecf20Sopenharmony_ci
45248c2ecf20Sopenharmony_ci			ret = si_get_std_voltage_value(rdev,
45258c2ecf20Sopenharmony_ci						       &table->ACPIState.levels[0].vddc, &std_vddc);
45268c2ecf20Sopenharmony_ci
45278c2ecf20Sopenharmony_ci			if (!ret)
45288c2ecf20Sopenharmony_ci				si_populate_std_voltage_value(rdev, std_vddc,
45298c2ecf20Sopenharmony_ci							      table->ACPIState.levels[0].vddc.index,
45308c2ecf20Sopenharmony_ci							      &table->ACPIState.levels[0].std_vddc);
45318c2ecf20Sopenharmony_ci		}
45328c2ecf20Sopenharmony_ci		table->ACPIState.levels[0].gen2PCIE = (u8)r600_get_pcie_gen_support(rdev,
45338c2ecf20Sopenharmony_ci										    si_pi->sys_pcie_mask,
45348c2ecf20Sopenharmony_ci										    si_pi->boot_pcie_gen,
45358c2ecf20Sopenharmony_ci										    RADEON_PCIE_GEN1);
45368c2ecf20Sopenharmony_ci
45378c2ecf20Sopenharmony_ci		if (si_pi->vddc_phase_shed_control)
45388c2ecf20Sopenharmony_ci			si_populate_phase_shedding_value(rdev,
45398c2ecf20Sopenharmony_ci							 &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
45408c2ecf20Sopenharmony_ci							 pi->min_vddc_in_table,
45418c2ecf20Sopenharmony_ci							 0,
45428c2ecf20Sopenharmony_ci							 0,
45438c2ecf20Sopenharmony_ci							 &table->ACPIState.levels[0].vddc);
45448c2ecf20Sopenharmony_ci	}
45458c2ecf20Sopenharmony_ci
45468c2ecf20Sopenharmony_ci	if (pi->acpi_vddc) {
45478c2ecf20Sopenharmony_ci		if (eg_pi->acpi_vddci)
45488c2ecf20Sopenharmony_ci			si_populate_voltage_value(rdev, &eg_pi->vddci_voltage_table,
45498c2ecf20Sopenharmony_ci						  eg_pi->acpi_vddci,
45508c2ecf20Sopenharmony_ci						  &table->ACPIState.levels[0].vddci);
45518c2ecf20Sopenharmony_ci	}
45528c2ecf20Sopenharmony_ci
45538c2ecf20Sopenharmony_ci	mclk_pwrmgt_cntl |= MRDCK0_RESET | MRDCK1_RESET;
45548c2ecf20Sopenharmony_ci	mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
45558c2ecf20Sopenharmony_ci
45568c2ecf20Sopenharmony_ci	dll_cntl &= ~(MRDCK0_BYPASS | MRDCK1_BYPASS);
45578c2ecf20Sopenharmony_ci
45588c2ecf20Sopenharmony_ci	spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
45598c2ecf20Sopenharmony_ci	spll_func_cntl_2 |= SCLK_MUX_SEL(4);
45608c2ecf20Sopenharmony_ci
45618c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vDLL_CNTL =
45628c2ecf20Sopenharmony_ci		cpu_to_be32(dll_cntl);
45638c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
45648c2ecf20Sopenharmony_ci		cpu_to_be32(mclk_pwrmgt_cntl);
45658c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
45668c2ecf20Sopenharmony_ci		cpu_to_be32(mpll_ad_func_cntl);
45678c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
45688c2ecf20Sopenharmony_ci		cpu_to_be32(mpll_dq_func_cntl);
45698c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL =
45708c2ecf20Sopenharmony_ci		cpu_to_be32(mpll_func_cntl);
45718c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
45728c2ecf20Sopenharmony_ci		cpu_to_be32(mpll_func_cntl_1);
45738c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
45748c2ecf20Sopenharmony_ci		cpu_to_be32(mpll_func_cntl_2);
45758c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_SS =
45768c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_ss1);
45778c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.vMPLL_SS2 =
45788c2ecf20Sopenharmony_ci		cpu_to_be32(si_pi->clock_registers.mpll_ss2);
45798c2ecf20Sopenharmony_ci
45808c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
45818c2ecf20Sopenharmony_ci		cpu_to_be32(spll_func_cntl);
45828c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
45838c2ecf20Sopenharmony_ci		cpu_to_be32(spll_func_cntl_2);
45848c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
45858c2ecf20Sopenharmony_ci		cpu_to_be32(spll_func_cntl_3);
45868c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
45878c2ecf20Sopenharmony_ci		cpu_to_be32(spll_func_cntl_4);
45888c2ecf20Sopenharmony_ci
45898c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].mclk.mclk_value = 0;
45908c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].sclk.sclk_value = 0;
45918c2ecf20Sopenharmony_ci
45928c2ecf20Sopenharmony_ci	si_populate_mvdd_value(rdev, 0, &table->ACPIState.levels[0].mvdd);
45938c2ecf20Sopenharmony_ci
45948c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing)
45958c2ecf20Sopenharmony_ci		table->ACPIState.levels[0].ACIndex = 0;
45968c2ecf20Sopenharmony_ci
45978c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].dpm2.MaxPS = 0;
45988c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].dpm2.NearTDPDec = 0;
45998c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].dpm2.AboveSafeInc = 0;
46008c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].dpm2.BelowSafeInc = 0;
46018c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].dpm2.PwrEfficiencyRatio = 0;
46028c2ecf20Sopenharmony_ci
46038c2ecf20Sopenharmony_ci	reg = MIN_POWER_MASK | MAX_POWER_MASK;
46048c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
46058c2ecf20Sopenharmony_ci
46068c2ecf20Sopenharmony_ci	reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
46078c2ecf20Sopenharmony_ci	table->ACPIState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
46088c2ecf20Sopenharmony_ci
46098c2ecf20Sopenharmony_ci	return 0;
46108c2ecf20Sopenharmony_ci}
46118c2ecf20Sopenharmony_ci
46128c2ecf20Sopenharmony_cistatic int si_populate_ulv_state(struct radeon_device *rdev,
46138c2ecf20Sopenharmony_ci				 SISLANDS_SMC_SWSTATE *state)
46148c2ecf20Sopenharmony_ci{
46158c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
46168c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
46178c2ecf20Sopenharmony_ci	struct si_ulv_param *ulv = &si_pi->ulv;
46188c2ecf20Sopenharmony_ci	u32 sclk_in_sr = 1350; /* ??? */
46198c2ecf20Sopenharmony_ci	int ret;
46208c2ecf20Sopenharmony_ci
46218c2ecf20Sopenharmony_ci	ret = si_convert_power_level_to_smc(rdev, &ulv->pl,
46228c2ecf20Sopenharmony_ci					    &state->levels[0]);
46238c2ecf20Sopenharmony_ci	if (!ret) {
46248c2ecf20Sopenharmony_ci		if (eg_pi->sclk_deep_sleep) {
46258c2ecf20Sopenharmony_ci			if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
46268c2ecf20Sopenharmony_ci				state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
46278c2ecf20Sopenharmony_ci			else
46288c2ecf20Sopenharmony_ci				state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
46298c2ecf20Sopenharmony_ci		}
46308c2ecf20Sopenharmony_ci		if (ulv->one_pcie_lane_in_ulv)
46318c2ecf20Sopenharmony_ci			state->flags |= PPSMC_SWSTATE_FLAG_PCIE_X1;
46328c2ecf20Sopenharmony_ci		state->levels[0].arbRefreshState = (u8)(SISLANDS_ULV_STATE_ARB_INDEX);
46338c2ecf20Sopenharmony_ci		state->levels[0].ACIndex = 1;
46348c2ecf20Sopenharmony_ci		state->levels[0].std_vddc = state->levels[0].vddc;
46358c2ecf20Sopenharmony_ci		state->levelCount = 1;
46368c2ecf20Sopenharmony_ci
46378c2ecf20Sopenharmony_ci		state->flags |= PPSMC_SWSTATE_FLAG_DC;
46388c2ecf20Sopenharmony_ci	}
46398c2ecf20Sopenharmony_ci
46408c2ecf20Sopenharmony_ci	return ret;
46418c2ecf20Sopenharmony_ci}
46428c2ecf20Sopenharmony_ci
46438c2ecf20Sopenharmony_cistatic int si_program_ulv_memory_timing_parameters(struct radeon_device *rdev)
46448c2ecf20Sopenharmony_ci{
46458c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
46468c2ecf20Sopenharmony_ci	struct si_ulv_param *ulv = &si_pi->ulv;
46478c2ecf20Sopenharmony_ci	SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
46488c2ecf20Sopenharmony_ci	int ret;
46498c2ecf20Sopenharmony_ci
46508c2ecf20Sopenharmony_ci	ret = si_populate_memory_timing_parameters(rdev, &ulv->pl,
46518c2ecf20Sopenharmony_ci						   &arb_regs);
46528c2ecf20Sopenharmony_ci	if (ret)
46538c2ecf20Sopenharmony_ci		return ret;
46548c2ecf20Sopenharmony_ci
46558c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_ulv_volt_change_delay,
46568c2ecf20Sopenharmony_ci				   ulv->volt_change_delay);
46578c2ecf20Sopenharmony_ci
46588c2ecf20Sopenharmony_ci	ret = si_copy_bytes_to_smc(rdev,
46598c2ecf20Sopenharmony_ci				   si_pi->arb_table_start +
46608c2ecf20Sopenharmony_ci				   offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
46618c2ecf20Sopenharmony_ci				   sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * SISLANDS_ULV_STATE_ARB_INDEX,
46628c2ecf20Sopenharmony_ci				   (u8 *)&arb_regs,
46638c2ecf20Sopenharmony_ci				   sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
46648c2ecf20Sopenharmony_ci				   si_pi->sram_end);
46658c2ecf20Sopenharmony_ci
46668c2ecf20Sopenharmony_ci	return ret;
46678c2ecf20Sopenharmony_ci}
46688c2ecf20Sopenharmony_ci
46698c2ecf20Sopenharmony_cistatic void si_get_mvdd_configuration(struct radeon_device *rdev)
46708c2ecf20Sopenharmony_ci{
46718c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
46728c2ecf20Sopenharmony_ci
46738c2ecf20Sopenharmony_ci	pi->mvdd_split_frequency = 30000;
46748c2ecf20Sopenharmony_ci}
46758c2ecf20Sopenharmony_ci
46768c2ecf20Sopenharmony_cistatic int si_init_smc_table(struct radeon_device *rdev)
46778c2ecf20Sopenharmony_ci{
46788c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
46798c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
46808c2ecf20Sopenharmony_ci	struct radeon_ps *radeon_boot_state = rdev->pm.dpm.boot_ps;
46818c2ecf20Sopenharmony_ci	const struct si_ulv_param *ulv = &si_pi->ulv;
46828c2ecf20Sopenharmony_ci	SISLANDS_SMC_STATETABLE  *table = &si_pi->smc_statetable;
46838c2ecf20Sopenharmony_ci	int ret;
46848c2ecf20Sopenharmony_ci	u32 lane_width;
46858c2ecf20Sopenharmony_ci	u32 vr_hot_gpio;
46868c2ecf20Sopenharmony_ci
46878c2ecf20Sopenharmony_ci	si_populate_smc_voltage_tables(rdev, table);
46888c2ecf20Sopenharmony_ci
46898c2ecf20Sopenharmony_ci	switch (rdev->pm.int_thermal_type) {
46908c2ecf20Sopenharmony_ci	case THERMAL_TYPE_SI:
46918c2ecf20Sopenharmony_ci	case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
46928c2ecf20Sopenharmony_ci		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
46938c2ecf20Sopenharmony_ci		break;
46948c2ecf20Sopenharmony_ci	case THERMAL_TYPE_NONE:
46958c2ecf20Sopenharmony_ci		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
46968c2ecf20Sopenharmony_ci		break;
46978c2ecf20Sopenharmony_ci	default:
46988c2ecf20Sopenharmony_ci		table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
46998c2ecf20Sopenharmony_ci		break;
47008c2ecf20Sopenharmony_ci	}
47018c2ecf20Sopenharmony_ci
47028c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
47038c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
47048c2ecf20Sopenharmony_ci
47058c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) {
47068c2ecf20Sopenharmony_ci		if ((rdev->pdev->device != 0x6818) && (rdev->pdev->device != 0x6819))
47078c2ecf20Sopenharmony_ci			table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
47088c2ecf20Sopenharmony_ci	}
47098c2ecf20Sopenharmony_ci
47108c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
47118c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
47128c2ecf20Sopenharmony_ci
47138c2ecf20Sopenharmony_ci	if (pi->mem_gddr5)
47148c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
47158c2ecf20Sopenharmony_ci
47168c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REVERT_GPIO5_POLARITY)
47178c2ecf20Sopenharmony_ci		table->extraFlags |= PPSMC_EXTRAFLAGS_AC2DC_GPIO5_POLARITY_HIGH;
47188c2ecf20Sopenharmony_ci
47198c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_VRHOT_GPIO_CONFIGURABLE) {
47208c2ecf20Sopenharmony_ci		table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT_PROG_GPIO;
47218c2ecf20Sopenharmony_ci		vr_hot_gpio = rdev->pm.dpm.backbias_response_time;
47228c2ecf20Sopenharmony_ci		si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_vr_hot_gpio,
47238c2ecf20Sopenharmony_ci					   vr_hot_gpio);
47248c2ecf20Sopenharmony_ci	}
47258c2ecf20Sopenharmony_ci
47268c2ecf20Sopenharmony_ci	ret = si_populate_smc_initial_state(rdev, radeon_boot_state, table);
47278c2ecf20Sopenharmony_ci	if (ret)
47288c2ecf20Sopenharmony_ci		return ret;
47298c2ecf20Sopenharmony_ci
47308c2ecf20Sopenharmony_ci	ret = si_populate_smc_acpi_state(rdev, table);
47318c2ecf20Sopenharmony_ci	if (ret)
47328c2ecf20Sopenharmony_ci		return ret;
47338c2ecf20Sopenharmony_ci
47348c2ecf20Sopenharmony_ci	table->driverState = table->initialState;
47358c2ecf20Sopenharmony_ci
47368c2ecf20Sopenharmony_ci	ret = si_do_program_memory_timing_parameters(rdev, radeon_boot_state,
47378c2ecf20Sopenharmony_ci						     SISLANDS_INITIAL_STATE_ARB_INDEX);
47388c2ecf20Sopenharmony_ci	if (ret)
47398c2ecf20Sopenharmony_ci		return ret;
47408c2ecf20Sopenharmony_ci
47418c2ecf20Sopenharmony_ci	if (ulv->supported && ulv->pl.vddc) {
47428c2ecf20Sopenharmony_ci		ret = si_populate_ulv_state(rdev, &table->ULVState);
47438c2ecf20Sopenharmony_ci		if (ret)
47448c2ecf20Sopenharmony_ci			return ret;
47458c2ecf20Sopenharmony_ci
47468c2ecf20Sopenharmony_ci		ret = si_program_ulv_memory_timing_parameters(rdev);
47478c2ecf20Sopenharmony_ci		if (ret)
47488c2ecf20Sopenharmony_ci			return ret;
47498c2ecf20Sopenharmony_ci
47508c2ecf20Sopenharmony_ci		WREG32(CG_ULV_CONTROL, ulv->cg_ulv_control);
47518c2ecf20Sopenharmony_ci		WREG32(CG_ULV_PARAMETER, ulv->cg_ulv_parameter);
47528c2ecf20Sopenharmony_ci
47538c2ecf20Sopenharmony_ci		lane_width = radeon_get_pcie_lanes(rdev);
47548c2ecf20Sopenharmony_ci		si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
47558c2ecf20Sopenharmony_ci	} else {
47568c2ecf20Sopenharmony_ci		table->ULVState = table->initialState;
47578c2ecf20Sopenharmony_ci	}
47588c2ecf20Sopenharmony_ci
47598c2ecf20Sopenharmony_ci	return si_copy_bytes_to_smc(rdev, si_pi->state_table_start,
47608c2ecf20Sopenharmony_ci				    (u8 *)table, sizeof(SISLANDS_SMC_STATETABLE),
47618c2ecf20Sopenharmony_ci				    si_pi->sram_end);
47628c2ecf20Sopenharmony_ci}
47638c2ecf20Sopenharmony_ci
47648c2ecf20Sopenharmony_cistatic int si_calculate_sclk_params(struct radeon_device *rdev,
47658c2ecf20Sopenharmony_ci				    u32 engine_clock,
47668c2ecf20Sopenharmony_ci				    SISLANDS_SMC_SCLK_VALUE *sclk)
47678c2ecf20Sopenharmony_ci{
47688c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
47698c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
47708c2ecf20Sopenharmony_ci	struct atom_clock_dividers dividers;
47718c2ecf20Sopenharmony_ci	u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
47728c2ecf20Sopenharmony_ci	u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
47738c2ecf20Sopenharmony_ci	u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
47748c2ecf20Sopenharmony_ci	u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
47758c2ecf20Sopenharmony_ci	u32 cg_spll_spread_spectrum = si_pi->clock_registers.cg_spll_spread_spectrum;
47768c2ecf20Sopenharmony_ci	u32 cg_spll_spread_spectrum_2 = si_pi->clock_registers.cg_spll_spread_spectrum_2;
47778c2ecf20Sopenharmony_ci	u64 tmp;
47788c2ecf20Sopenharmony_ci	u32 reference_clock = rdev->clock.spll.reference_freq;
47798c2ecf20Sopenharmony_ci	u32 reference_divider;
47808c2ecf20Sopenharmony_ci	u32 fbdiv;
47818c2ecf20Sopenharmony_ci	int ret;
47828c2ecf20Sopenharmony_ci
47838c2ecf20Sopenharmony_ci	ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
47848c2ecf20Sopenharmony_ci					     engine_clock, false, &dividers);
47858c2ecf20Sopenharmony_ci	if (ret)
47868c2ecf20Sopenharmony_ci		return ret;
47878c2ecf20Sopenharmony_ci
47888c2ecf20Sopenharmony_ci	reference_divider = 1 + dividers.ref_div;
47898c2ecf20Sopenharmony_ci
47908c2ecf20Sopenharmony_ci	tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16384;
47918c2ecf20Sopenharmony_ci	do_div(tmp, reference_clock);
47928c2ecf20Sopenharmony_ci	fbdiv = (u32) tmp;
47938c2ecf20Sopenharmony_ci
47948c2ecf20Sopenharmony_ci	spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
47958c2ecf20Sopenharmony_ci	spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
47968c2ecf20Sopenharmony_ci	spll_func_cntl |= SPLL_PDIV_A(dividers.post_div);
47978c2ecf20Sopenharmony_ci
47988c2ecf20Sopenharmony_ci	spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
47998c2ecf20Sopenharmony_ci	spll_func_cntl_2 |= SCLK_MUX_SEL(2);
48008c2ecf20Sopenharmony_ci
48018c2ecf20Sopenharmony_ci	spll_func_cntl_3 &= ~SPLL_FB_DIV_MASK;
48028c2ecf20Sopenharmony_ci	spll_func_cntl_3 |= SPLL_FB_DIV(fbdiv);
48038c2ecf20Sopenharmony_ci	spll_func_cntl_3 |= SPLL_DITHEN;
48048c2ecf20Sopenharmony_ci
48058c2ecf20Sopenharmony_ci	if (pi->sclk_ss) {
48068c2ecf20Sopenharmony_ci		struct radeon_atom_ss ss;
48078c2ecf20Sopenharmony_ci		u32 vco_freq = engine_clock * dividers.post_div;
48088c2ecf20Sopenharmony_ci
48098c2ecf20Sopenharmony_ci		if (radeon_atombios_get_asic_ss_info(rdev, &ss,
48108c2ecf20Sopenharmony_ci						     ASIC_INTERNAL_ENGINE_SS, vco_freq)) {
48118c2ecf20Sopenharmony_ci			u32 clk_s = reference_clock * 5 / (reference_divider * ss.rate);
48128c2ecf20Sopenharmony_ci			u32 clk_v = 4 * ss.percentage * fbdiv / (clk_s * 10000);
48138c2ecf20Sopenharmony_ci
48148c2ecf20Sopenharmony_ci			cg_spll_spread_spectrum &= ~CLK_S_MASK;
48158c2ecf20Sopenharmony_ci			cg_spll_spread_spectrum |= CLK_S(clk_s);
48168c2ecf20Sopenharmony_ci			cg_spll_spread_spectrum |= SSEN;
48178c2ecf20Sopenharmony_ci
48188c2ecf20Sopenharmony_ci			cg_spll_spread_spectrum_2 &= ~CLK_V_MASK;
48198c2ecf20Sopenharmony_ci			cg_spll_spread_spectrum_2 |= CLK_V(clk_v);
48208c2ecf20Sopenharmony_ci		}
48218c2ecf20Sopenharmony_ci	}
48228c2ecf20Sopenharmony_ci
48238c2ecf20Sopenharmony_ci	sclk->sclk_value = engine_clock;
48248c2ecf20Sopenharmony_ci	sclk->vCG_SPLL_FUNC_CNTL = spll_func_cntl;
48258c2ecf20Sopenharmony_ci	sclk->vCG_SPLL_FUNC_CNTL_2 = spll_func_cntl_2;
48268c2ecf20Sopenharmony_ci	sclk->vCG_SPLL_FUNC_CNTL_3 = spll_func_cntl_3;
48278c2ecf20Sopenharmony_ci	sclk->vCG_SPLL_FUNC_CNTL_4 = spll_func_cntl_4;
48288c2ecf20Sopenharmony_ci	sclk->vCG_SPLL_SPREAD_SPECTRUM = cg_spll_spread_spectrum;
48298c2ecf20Sopenharmony_ci	sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cg_spll_spread_spectrum_2;
48308c2ecf20Sopenharmony_ci
48318c2ecf20Sopenharmony_ci	return 0;
48328c2ecf20Sopenharmony_ci}
48338c2ecf20Sopenharmony_ci
48348c2ecf20Sopenharmony_cistatic int si_populate_sclk_value(struct radeon_device *rdev,
48358c2ecf20Sopenharmony_ci				  u32 engine_clock,
48368c2ecf20Sopenharmony_ci				  SISLANDS_SMC_SCLK_VALUE *sclk)
48378c2ecf20Sopenharmony_ci{
48388c2ecf20Sopenharmony_ci	SISLANDS_SMC_SCLK_VALUE sclk_tmp;
48398c2ecf20Sopenharmony_ci	int ret;
48408c2ecf20Sopenharmony_ci
48418c2ecf20Sopenharmony_ci	ret = si_calculate_sclk_params(rdev, engine_clock, &sclk_tmp);
48428c2ecf20Sopenharmony_ci	if (!ret) {
48438c2ecf20Sopenharmony_ci		sclk->sclk_value = cpu_to_be32(sclk_tmp.sclk_value);
48448c2ecf20Sopenharmony_ci		sclk->vCG_SPLL_FUNC_CNTL = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL);
48458c2ecf20Sopenharmony_ci		sclk->vCG_SPLL_FUNC_CNTL_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_2);
48468c2ecf20Sopenharmony_ci		sclk->vCG_SPLL_FUNC_CNTL_3 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_3);
48478c2ecf20Sopenharmony_ci		sclk->vCG_SPLL_FUNC_CNTL_4 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_4);
48488c2ecf20Sopenharmony_ci		sclk->vCG_SPLL_SPREAD_SPECTRUM = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM);
48498c2ecf20Sopenharmony_ci		sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM_2);
48508c2ecf20Sopenharmony_ci	}
48518c2ecf20Sopenharmony_ci
48528c2ecf20Sopenharmony_ci	return ret;
48538c2ecf20Sopenharmony_ci}
48548c2ecf20Sopenharmony_ci
48558c2ecf20Sopenharmony_cistatic int si_populate_mclk_value(struct radeon_device *rdev,
48568c2ecf20Sopenharmony_ci				  u32 engine_clock,
48578c2ecf20Sopenharmony_ci				  u32 memory_clock,
48588c2ecf20Sopenharmony_ci				  SISLANDS_SMC_MCLK_VALUE *mclk,
48598c2ecf20Sopenharmony_ci				  bool strobe_mode,
48608c2ecf20Sopenharmony_ci				  bool dll_state_on)
48618c2ecf20Sopenharmony_ci{
48628c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
48638c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
48648c2ecf20Sopenharmony_ci	u32  dll_cntl = si_pi->clock_registers.dll_cntl;
48658c2ecf20Sopenharmony_ci	u32  mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
48668c2ecf20Sopenharmony_ci	u32  mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
48678c2ecf20Sopenharmony_ci	u32  mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
48688c2ecf20Sopenharmony_ci	u32  mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
48698c2ecf20Sopenharmony_ci	u32  mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
48708c2ecf20Sopenharmony_ci	u32  mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
48718c2ecf20Sopenharmony_ci	u32  mpll_ss1 = si_pi->clock_registers.mpll_ss1;
48728c2ecf20Sopenharmony_ci	u32  mpll_ss2 = si_pi->clock_registers.mpll_ss2;
48738c2ecf20Sopenharmony_ci	struct atom_mpll_param mpll_param;
48748c2ecf20Sopenharmony_ci	int ret;
48758c2ecf20Sopenharmony_ci
48768c2ecf20Sopenharmony_ci	ret = radeon_atom_get_memory_pll_dividers(rdev, memory_clock, strobe_mode, &mpll_param);
48778c2ecf20Sopenharmony_ci	if (ret)
48788c2ecf20Sopenharmony_ci		return ret;
48798c2ecf20Sopenharmony_ci
48808c2ecf20Sopenharmony_ci	mpll_func_cntl &= ~BWCTRL_MASK;
48818c2ecf20Sopenharmony_ci	mpll_func_cntl |= BWCTRL(mpll_param.bwcntl);
48828c2ecf20Sopenharmony_ci
48838c2ecf20Sopenharmony_ci	mpll_func_cntl_1 &= ~(CLKF_MASK | CLKFRAC_MASK | VCO_MODE_MASK);
48848c2ecf20Sopenharmony_ci	mpll_func_cntl_1 |= CLKF(mpll_param.clkf) |
48858c2ecf20Sopenharmony_ci		CLKFRAC(mpll_param.clkfrac) | VCO_MODE(mpll_param.vco_mode);
48868c2ecf20Sopenharmony_ci
48878c2ecf20Sopenharmony_ci	mpll_ad_func_cntl &= ~YCLK_POST_DIV_MASK;
48888c2ecf20Sopenharmony_ci	mpll_ad_func_cntl |= YCLK_POST_DIV(mpll_param.post_div);
48898c2ecf20Sopenharmony_ci
48908c2ecf20Sopenharmony_ci	if (pi->mem_gddr5) {
48918c2ecf20Sopenharmony_ci		mpll_dq_func_cntl &= ~(YCLK_SEL_MASK | YCLK_POST_DIV_MASK);
48928c2ecf20Sopenharmony_ci		mpll_dq_func_cntl |= YCLK_SEL(mpll_param.yclk_sel) |
48938c2ecf20Sopenharmony_ci			YCLK_POST_DIV(mpll_param.post_div);
48948c2ecf20Sopenharmony_ci	}
48958c2ecf20Sopenharmony_ci
48968c2ecf20Sopenharmony_ci	if (pi->mclk_ss) {
48978c2ecf20Sopenharmony_ci		struct radeon_atom_ss ss;
48988c2ecf20Sopenharmony_ci		u32 freq_nom;
48998c2ecf20Sopenharmony_ci		u32 tmp;
49008c2ecf20Sopenharmony_ci		u32 reference_clock = rdev->clock.mpll.reference_freq;
49018c2ecf20Sopenharmony_ci
49028c2ecf20Sopenharmony_ci		if (pi->mem_gddr5)
49038c2ecf20Sopenharmony_ci			freq_nom = memory_clock * 4;
49048c2ecf20Sopenharmony_ci		else
49058c2ecf20Sopenharmony_ci			freq_nom = memory_clock * 2;
49068c2ecf20Sopenharmony_ci
49078c2ecf20Sopenharmony_ci		tmp = freq_nom / reference_clock;
49088c2ecf20Sopenharmony_ci		tmp = tmp * tmp;
49098c2ecf20Sopenharmony_ci		if (radeon_atombios_get_asic_ss_info(rdev, &ss,
49108c2ecf20Sopenharmony_ci						     ASIC_INTERNAL_MEMORY_SS, freq_nom)) {
49118c2ecf20Sopenharmony_ci			u32 clks = reference_clock * 5 / ss.rate;
49128c2ecf20Sopenharmony_ci			u32 clkv = (u32)((((131 * ss.percentage * ss.rate) / 100) * tmp) / freq_nom);
49138c2ecf20Sopenharmony_ci
49148c2ecf20Sopenharmony_ci			mpll_ss1 &= ~CLKV_MASK;
49158c2ecf20Sopenharmony_ci			mpll_ss1 |= CLKV(clkv);
49168c2ecf20Sopenharmony_ci
49178c2ecf20Sopenharmony_ci			mpll_ss2 &= ~CLKS_MASK;
49188c2ecf20Sopenharmony_ci			mpll_ss2 |= CLKS(clks);
49198c2ecf20Sopenharmony_ci		}
49208c2ecf20Sopenharmony_ci	}
49218c2ecf20Sopenharmony_ci
49228c2ecf20Sopenharmony_ci	mclk_pwrmgt_cntl &= ~DLL_SPEED_MASK;
49238c2ecf20Sopenharmony_ci	mclk_pwrmgt_cntl |= DLL_SPEED(mpll_param.dll_speed);
49248c2ecf20Sopenharmony_ci
49258c2ecf20Sopenharmony_ci	if (dll_state_on)
49268c2ecf20Sopenharmony_ci		mclk_pwrmgt_cntl |= MRDCK0_PDNB | MRDCK1_PDNB;
49278c2ecf20Sopenharmony_ci	else
49288c2ecf20Sopenharmony_ci		mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
49298c2ecf20Sopenharmony_ci
49308c2ecf20Sopenharmony_ci	mclk->mclk_value = cpu_to_be32(memory_clock);
49318c2ecf20Sopenharmony_ci	mclk->vMPLL_FUNC_CNTL = cpu_to_be32(mpll_func_cntl);
49328c2ecf20Sopenharmony_ci	mclk->vMPLL_FUNC_CNTL_1 = cpu_to_be32(mpll_func_cntl_1);
49338c2ecf20Sopenharmony_ci	mclk->vMPLL_FUNC_CNTL_2 = cpu_to_be32(mpll_func_cntl_2);
49348c2ecf20Sopenharmony_ci	mclk->vMPLL_AD_FUNC_CNTL = cpu_to_be32(mpll_ad_func_cntl);
49358c2ecf20Sopenharmony_ci	mclk->vMPLL_DQ_FUNC_CNTL = cpu_to_be32(mpll_dq_func_cntl);
49368c2ecf20Sopenharmony_ci	mclk->vMCLK_PWRMGT_CNTL = cpu_to_be32(mclk_pwrmgt_cntl);
49378c2ecf20Sopenharmony_ci	mclk->vDLL_CNTL = cpu_to_be32(dll_cntl);
49388c2ecf20Sopenharmony_ci	mclk->vMPLL_SS = cpu_to_be32(mpll_ss1);
49398c2ecf20Sopenharmony_ci	mclk->vMPLL_SS2 = cpu_to_be32(mpll_ss2);
49408c2ecf20Sopenharmony_ci
49418c2ecf20Sopenharmony_ci	return 0;
49428c2ecf20Sopenharmony_ci}
49438c2ecf20Sopenharmony_ci
49448c2ecf20Sopenharmony_cistatic void si_populate_smc_sp(struct radeon_device *rdev,
49458c2ecf20Sopenharmony_ci			       struct radeon_ps *radeon_state,
49468c2ecf20Sopenharmony_ci			       SISLANDS_SMC_SWSTATE *smc_state)
49478c2ecf20Sopenharmony_ci{
49488c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(radeon_state);
49498c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
49508c2ecf20Sopenharmony_ci	int i;
49518c2ecf20Sopenharmony_ci
49528c2ecf20Sopenharmony_ci	for (i = 0; i < ps->performance_level_count - 1; i++)
49538c2ecf20Sopenharmony_ci		smc_state->levels[i].bSP = cpu_to_be32(pi->dsp);
49548c2ecf20Sopenharmony_ci
49558c2ecf20Sopenharmony_ci	smc_state->levels[ps->performance_level_count - 1].bSP =
49568c2ecf20Sopenharmony_ci		cpu_to_be32(pi->psp);
49578c2ecf20Sopenharmony_ci}
49588c2ecf20Sopenharmony_ci
49598c2ecf20Sopenharmony_cistatic int si_convert_power_level_to_smc(struct radeon_device *rdev,
49608c2ecf20Sopenharmony_ci					 struct rv7xx_pl *pl,
49618c2ecf20Sopenharmony_ci					 SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level)
49628c2ecf20Sopenharmony_ci{
49638c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
49648c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
49658c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
49668c2ecf20Sopenharmony_ci	int ret;
49678c2ecf20Sopenharmony_ci	bool dll_state_on;
49688c2ecf20Sopenharmony_ci	u16 std_vddc;
49698c2ecf20Sopenharmony_ci	bool gmc_pg = false;
49708c2ecf20Sopenharmony_ci
49718c2ecf20Sopenharmony_ci	if (eg_pi->pcie_performance_request &&
49728c2ecf20Sopenharmony_ci	    (si_pi->force_pcie_gen != RADEON_PCIE_GEN_INVALID))
49738c2ecf20Sopenharmony_ci		level->gen2PCIE = (u8)si_pi->force_pcie_gen;
49748c2ecf20Sopenharmony_ci	else
49758c2ecf20Sopenharmony_ci		level->gen2PCIE = (u8)pl->pcie_gen;
49768c2ecf20Sopenharmony_ci
49778c2ecf20Sopenharmony_ci	ret = si_populate_sclk_value(rdev, pl->sclk, &level->sclk);
49788c2ecf20Sopenharmony_ci	if (ret)
49798c2ecf20Sopenharmony_ci		return ret;
49808c2ecf20Sopenharmony_ci
49818c2ecf20Sopenharmony_ci	level->mcFlags =  0;
49828c2ecf20Sopenharmony_ci
49838c2ecf20Sopenharmony_ci	if (pi->mclk_stutter_mode_threshold &&
49848c2ecf20Sopenharmony_ci	    (pl->mclk <= pi->mclk_stutter_mode_threshold) &&
49858c2ecf20Sopenharmony_ci	    !eg_pi->uvd_enabled &&
49868c2ecf20Sopenharmony_ci	    (RREG32(DPG_PIPE_STUTTER_CONTROL) & STUTTER_ENABLE) &&
49878c2ecf20Sopenharmony_ci	    (rdev->pm.dpm.new_active_crtc_count <= 2)) {
49888c2ecf20Sopenharmony_ci		level->mcFlags |= SISLANDS_SMC_MC_STUTTER_EN;
49898c2ecf20Sopenharmony_ci
49908c2ecf20Sopenharmony_ci		if (gmc_pg)
49918c2ecf20Sopenharmony_ci			level->mcFlags |= SISLANDS_SMC_MC_PG_EN;
49928c2ecf20Sopenharmony_ci	}
49938c2ecf20Sopenharmony_ci
49948c2ecf20Sopenharmony_ci	if (pi->mem_gddr5) {
49958c2ecf20Sopenharmony_ci		if (pl->mclk > pi->mclk_edc_enable_threshold)
49968c2ecf20Sopenharmony_ci			level->mcFlags |= SISLANDS_SMC_MC_EDC_RD_FLAG;
49978c2ecf20Sopenharmony_ci
49988c2ecf20Sopenharmony_ci		if (pl->mclk > eg_pi->mclk_edc_wr_enable_threshold)
49998c2ecf20Sopenharmony_ci			level->mcFlags |= SISLANDS_SMC_MC_EDC_WR_FLAG;
50008c2ecf20Sopenharmony_ci
50018c2ecf20Sopenharmony_ci		level->strobeMode = si_get_strobe_mode_settings(rdev, pl->mclk);
50028c2ecf20Sopenharmony_ci
50038c2ecf20Sopenharmony_ci		if (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) {
50048c2ecf20Sopenharmony_ci			if (si_get_mclk_frequency_ratio(pl->mclk, true) >=
50058c2ecf20Sopenharmony_ci			    ((RREG32(MC_SEQ_MISC7) >> 16) & 0xf))
50068c2ecf20Sopenharmony_ci				dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
50078c2ecf20Sopenharmony_ci			else
50088c2ecf20Sopenharmony_ci				dll_state_on = ((RREG32(MC_SEQ_MISC6) >> 1) & 0x1) ? true : false;
50098c2ecf20Sopenharmony_ci		} else {
50108c2ecf20Sopenharmony_ci			dll_state_on = false;
50118c2ecf20Sopenharmony_ci		}
50128c2ecf20Sopenharmony_ci	} else {
50138c2ecf20Sopenharmony_ci		level->strobeMode = si_get_strobe_mode_settings(rdev,
50148c2ecf20Sopenharmony_ci								pl->mclk);
50158c2ecf20Sopenharmony_ci
50168c2ecf20Sopenharmony_ci		dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
50178c2ecf20Sopenharmony_ci	}
50188c2ecf20Sopenharmony_ci
50198c2ecf20Sopenharmony_ci	ret = si_populate_mclk_value(rdev,
50208c2ecf20Sopenharmony_ci				     pl->sclk,
50218c2ecf20Sopenharmony_ci				     pl->mclk,
50228c2ecf20Sopenharmony_ci				     &level->mclk,
50238c2ecf20Sopenharmony_ci				     (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) != 0, dll_state_on);
50248c2ecf20Sopenharmony_ci	if (ret)
50258c2ecf20Sopenharmony_ci		return ret;
50268c2ecf20Sopenharmony_ci
50278c2ecf20Sopenharmony_ci	ret = si_populate_voltage_value(rdev,
50288c2ecf20Sopenharmony_ci					&eg_pi->vddc_voltage_table,
50298c2ecf20Sopenharmony_ci					pl->vddc, &level->vddc);
50308c2ecf20Sopenharmony_ci	if (ret)
50318c2ecf20Sopenharmony_ci		return ret;
50328c2ecf20Sopenharmony_ci
50338c2ecf20Sopenharmony_ci
50348c2ecf20Sopenharmony_ci	ret = si_get_std_voltage_value(rdev, &level->vddc, &std_vddc);
50358c2ecf20Sopenharmony_ci	if (ret)
50368c2ecf20Sopenharmony_ci		return ret;
50378c2ecf20Sopenharmony_ci
50388c2ecf20Sopenharmony_ci	ret = si_populate_std_voltage_value(rdev, std_vddc,
50398c2ecf20Sopenharmony_ci					    level->vddc.index, &level->std_vddc);
50408c2ecf20Sopenharmony_ci	if (ret)
50418c2ecf20Sopenharmony_ci		return ret;
50428c2ecf20Sopenharmony_ci
50438c2ecf20Sopenharmony_ci	if (eg_pi->vddci_control) {
50448c2ecf20Sopenharmony_ci		ret = si_populate_voltage_value(rdev, &eg_pi->vddci_voltage_table,
50458c2ecf20Sopenharmony_ci						pl->vddci, &level->vddci);
50468c2ecf20Sopenharmony_ci		if (ret)
50478c2ecf20Sopenharmony_ci			return ret;
50488c2ecf20Sopenharmony_ci	}
50498c2ecf20Sopenharmony_ci
50508c2ecf20Sopenharmony_ci	if (si_pi->vddc_phase_shed_control) {
50518c2ecf20Sopenharmony_ci		ret = si_populate_phase_shedding_value(rdev,
50528c2ecf20Sopenharmony_ci						       &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
50538c2ecf20Sopenharmony_ci						       pl->vddc,
50548c2ecf20Sopenharmony_ci						       pl->sclk,
50558c2ecf20Sopenharmony_ci						       pl->mclk,
50568c2ecf20Sopenharmony_ci						       &level->vddc);
50578c2ecf20Sopenharmony_ci		if (ret)
50588c2ecf20Sopenharmony_ci			return ret;
50598c2ecf20Sopenharmony_ci	}
50608c2ecf20Sopenharmony_ci
50618c2ecf20Sopenharmony_ci	level->MaxPoweredUpCU = si_pi->max_cu;
50628c2ecf20Sopenharmony_ci
50638c2ecf20Sopenharmony_ci	ret = si_populate_mvdd_value(rdev, pl->mclk, &level->mvdd);
50648c2ecf20Sopenharmony_ci
50658c2ecf20Sopenharmony_ci	return ret;
50668c2ecf20Sopenharmony_ci}
50678c2ecf20Sopenharmony_ci
50688c2ecf20Sopenharmony_cistatic int si_populate_smc_t(struct radeon_device *rdev,
50698c2ecf20Sopenharmony_ci			     struct radeon_ps *radeon_state,
50708c2ecf20Sopenharmony_ci			     SISLANDS_SMC_SWSTATE *smc_state)
50718c2ecf20Sopenharmony_ci{
50728c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
50738c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
50748c2ecf20Sopenharmony_ci	u32 a_t;
50758c2ecf20Sopenharmony_ci	u32 t_l, t_h;
50768c2ecf20Sopenharmony_ci	u32 high_bsp;
50778c2ecf20Sopenharmony_ci	int i, ret;
50788c2ecf20Sopenharmony_ci
50798c2ecf20Sopenharmony_ci	if (state->performance_level_count >= 9)
50808c2ecf20Sopenharmony_ci		return -EINVAL;
50818c2ecf20Sopenharmony_ci
50828c2ecf20Sopenharmony_ci	if (state->performance_level_count < 2) {
50838c2ecf20Sopenharmony_ci		a_t = CG_R(0xffff) | CG_L(0);
50848c2ecf20Sopenharmony_ci		smc_state->levels[0].aT = cpu_to_be32(a_t);
50858c2ecf20Sopenharmony_ci		return 0;
50868c2ecf20Sopenharmony_ci	}
50878c2ecf20Sopenharmony_ci
50888c2ecf20Sopenharmony_ci	smc_state->levels[0].aT = cpu_to_be32(0);
50898c2ecf20Sopenharmony_ci
50908c2ecf20Sopenharmony_ci	for (i = 0; i <= state->performance_level_count - 2; i++) {
50918c2ecf20Sopenharmony_ci		ret = r600_calculate_at(
50928c2ecf20Sopenharmony_ci			(50 / SISLANDS_MAX_HARDWARE_POWERLEVELS) * 100 * (i + 1),
50938c2ecf20Sopenharmony_ci			100 * R600_AH_DFLT,
50948c2ecf20Sopenharmony_ci			state->performance_levels[i + 1].sclk,
50958c2ecf20Sopenharmony_ci			state->performance_levels[i].sclk,
50968c2ecf20Sopenharmony_ci			&t_l,
50978c2ecf20Sopenharmony_ci			&t_h);
50988c2ecf20Sopenharmony_ci
50998c2ecf20Sopenharmony_ci		if (ret) {
51008c2ecf20Sopenharmony_ci			t_h = (i + 1) * 1000 - 50 * R600_AH_DFLT;
51018c2ecf20Sopenharmony_ci			t_l = (i + 1) * 1000 + 50 * R600_AH_DFLT;
51028c2ecf20Sopenharmony_ci		}
51038c2ecf20Sopenharmony_ci
51048c2ecf20Sopenharmony_ci		a_t = be32_to_cpu(smc_state->levels[i].aT) & ~CG_R_MASK;
51058c2ecf20Sopenharmony_ci		a_t |= CG_R(t_l * pi->bsp / 20000);
51068c2ecf20Sopenharmony_ci		smc_state->levels[i].aT = cpu_to_be32(a_t);
51078c2ecf20Sopenharmony_ci
51088c2ecf20Sopenharmony_ci		high_bsp = (i == state->performance_level_count - 2) ?
51098c2ecf20Sopenharmony_ci			pi->pbsp : pi->bsp;
51108c2ecf20Sopenharmony_ci		a_t = CG_R(0xffff) | CG_L(t_h * high_bsp / 20000);
51118c2ecf20Sopenharmony_ci		smc_state->levels[i + 1].aT = cpu_to_be32(a_t);
51128c2ecf20Sopenharmony_ci	}
51138c2ecf20Sopenharmony_ci
51148c2ecf20Sopenharmony_ci	return 0;
51158c2ecf20Sopenharmony_ci}
51168c2ecf20Sopenharmony_ci
51178c2ecf20Sopenharmony_cistatic int si_disable_ulv(struct radeon_device *rdev)
51188c2ecf20Sopenharmony_ci{
51198c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
51208c2ecf20Sopenharmony_ci	struct si_ulv_param *ulv = &si_pi->ulv;
51218c2ecf20Sopenharmony_ci
51228c2ecf20Sopenharmony_ci	if (ulv->supported)
51238c2ecf20Sopenharmony_ci		return (si_send_msg_to_smc(rdev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ?
51248c2ecf20Sopenharmony_ci			0 : -EINVAL;
51258c2ecf20Sopenharmony_ci
51268c2ecf20Sopenharmony_ci	return 0;
51278c2ecf20Sopenharmony_ci}
51288c2ecf20Sopenharmony_ci
51298c2ecf20Sopenharmony_cistatic bool si_is_state_ulv_compatible(struct radeon_device *rdev,
51308c2ecf20Sopenharmony_ci				       struct radeon_ps *radeon_state)
51318c2ecf20Sopenharmony_ci{
51328c2ecf20Sopenharmony_ci	const struct si_power_info *si_pi = si_get_pi(rdev);
51338c2ecf20Sopenharmony_ci	const struct si_ulv_param *ulv = &si_pi->ulv;
51348c2ecf20Sopenharmony_ci	const struct ni_ps *state = ni_get_ps(radeon_state);
51358c2ecf20Sopenharmony_ci	int i;
51368c2ecf20Sopenharmony_ci
51378c2ecf20Sopenharmony_ci	if (state->performance_levels[0].mclk != ulv->pl.mclk)
51388c2ecf20Sopenharmony_ci		return false;
51398c2ecf20Sopenharmony_ci
51408c2ecf20Sopenharmony_ci	/* XXX validate against display requirements! */
51418c2ecf20Sopenharmony_ci
51428c2ecf20Sopenharmony_ci	for (i = 0; i < rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count; i++) {
51438c2ecf20Sopenharmony_ci		if (rdev->clock.current_dispclk <=
51448c2ecf20Sopenharmony_ci		    rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].clk) {
51458c2ecf20Sopenharmony_ci			if (ulv->pl.vddc <
51468c2ecf20Sopenharmony_ci			    rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].v)
51478c2ecf20Sopenharmony_ci				return false;
51488c2ecf20Sopenharmony_ci		}
51498c2ecf20Sopenharmony_ci	}
51508c2ecf20Sopenharmony_ci
51518c2ecf20Sopenharmony_ci	if ((radeon_state->vclk != 0) || (radeon_state->dclk != 0))
51528c2ecf20Sopenharmony_ci		return false;
51538c2ecf20Sopenharmony_ci
51548c2ecf20Sopenharmony_ci	return true;
51558c2ecf20Sopenharmony_ci}
51568c2ecf20Sopenharmony_ci
51578c2ecf20Sopenharmony_cistatic int si_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev,
51588c2ecf20Sopenharmony_ci						       struct radeon_ps *radeon_new_state)
51598c2ecf20Sopenharmony_ci{
51608c2ecf20Sopenharmony_ci	const struct si_power_info *si_pi = si_get_pi(rdev);
51618c2ecf20Sopenharmony_ci	const struct si_ulv_param *ulv = &si_pi->ulv;
51628c2ecf20Sopenharmony_ci
51638c2ecf20Sopenharmony_ci	if (ulv->supported) {
51648c2ecf20Sopenharmony_ci		if (si_is_state_ulv_compatible(rdev, radeon_new_state))
51658c2ecf20Sopenharmony_ci			return (si_send_msg_to_smc(rdev, PPSMC_MSG_EnableULV) == PPSMC_Result_OK) ?
51668c2ecf20Sopenharmony_ci				0 : -EINVAL;
51678c2ecf20Sopenharmony_ci	}
51688c2ecf20Sopenharmony_ci	return 0;
51698c2ecf20Sopenharmony_ci}
51708c2ecf20Sopenharmony_ci
51718c2ecf20Sopenharmony_cistatic int si_convert_power_state_to_smc(struct radeon_device *rdev,
51728c2ecf20Sopenharmony_ci					 struct radeon_ps *radeon_state,
51738c2ecf20Sopenharmony_ci					 SISLANDS_SMC_SWSTATE *smc_state)
51748c2ecf20Sopenharmony_ci{
51758c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
51768c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi = ni_get_pi(rdev);
51778c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
51788c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
51798c2ecf20Sopenharmony_ci	int i, ret;
51808c2ecf20Sopenharmony_ci	u32 threshold;
51818c2ecf20Sopenharmony_ci	u32 sclk_in_sr = 1350; /* ??? */
51828c2ecf20Sopenharmony_ci
51838c2ecf20Sopenharmony_ci	if (state->performance_level_count > SISLANDS_MAX_HARDWARE_POWERLEVELS)
51848c2ecf20Sopenharmony_ci		return -EINVAL;
51858c2ecf20Sopenharmony_ci
51868c2ecf20Sopenharmony_ci	threshold = state->performance_levels[state->performance_level_count-1].sclk * 100 / 100;
51878c2ecf20Sopenharmony_ci
51888c2ecf20Sopenharmony_ci	if (radeon_state->vclk && radeon_state->dclk) {
51898c2ecf20Sopenharmony_ci		eg_pi->uvd_enabled = true;
51908c2ecf20Sopenharmony_ci		if (eg_pi->smu_uvd_hs)
51918c2ecf20Sopenharmony_ci			smc_state->flags |= PPSMC_SWSTATE_FLAG_UVD;
51928c2ecf20Sopenharmony_ci	} else {
51938c2ecf20Sopenharmony_ci		eg_pi->uvd_enabled = false;
51948c2ecf20Sopenharmony_ci	}
51958c2ecf20Sopenharmony_ci
51968c2ecf20Sopenharmony_ci	if (state->dc_compatible)
51978c2ecf20Sopenharmony_ci		smc_state->flags |= PPSMC_SWSTATE_FLAG_DC;
51988c2ecf20Sopenharmony_ci
51998c2ecf20Sopenharmony_ci	smc_state->levelCount = 0;
52008c2ecf20Sopenharmony_ci	for (i = 0; i < state->performance_level_count; i++) {
52018c2ecf20Sopenharmony_ci		if (eg_pi->sclk_deep_sleep) {
52028c2ecf20Sopenharmony_ci			if ((i == 0) || si_pi->sclk_deep_sleep_above_low) {
52038c2ecf20Sopenharmony_ci				if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
52048c2ecf20Sopenharmony_ci					smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
52058c2ecf20Sopenharmony_ci				else
52068c2ecf20Sopenharmony_ci					smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
52078c2ecf20Sopenharmony_ci			}
52088c2ecf20Sopenharmony_ci		}
52098c2ecf20Sopenharmony_ci
52108c2ecf20Sopenharmony_ci		ret = si_convert_power_level_to_smc(rdev, &state->performance_levels[i],
52118c2ecf20Sopenharmony_ci						    &smc_state->levels[i]);
52128c2ecf20Sopenharmony_ci		smc_state->levels[i].arbRefreshState =
52138c2ecf20Sopenharmony_ci			(u8)(SISLANDS_DRIVER_STATE_ARB_INDEX + i);
52148c2ecf20Sopenharmony_ci
52158c2ecf20Sopenharmony_ci		if (ret)
52168c2ecf20Sopenharmony_ci			return ret;
52178c2ecf20Sopenharmony_ci
52188c2ecf20Sopenharmony_ci		if (ni_pi->enable_power_containment)
52198c2ecf20Sopenharmony_ci			smc_state->levels[i].displayWatermark =
52208c2ecf20Sopenharmony_ci				(state->performance_levels[i].sclk < threshold) ?
52218c2ecf20Sopenharmony_ci				PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
52228c2ecf20Sopenharmony_ci		else
52238c2ecf20Sopenharmony_ci			smc_state->levels[i].displayWatermark = (i < 2) ?
52248c2ecf20Sopenharmony_ci				PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
52258c2ecf20Sopenharmony_ci
52268c2ecf20Sopenharmony_ci		if (eg_pi->dynamic_ac_timing)
52278c2ecf20Sopenharmony_ci			smc_state->levels[i].ACIndex = SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i;
52288c2ecf20Sopenharmony_ci		else
52298c2ecf20Sopenharmony_ci			smc_state->levels[i].ACIndex = 0;
52308c2ecf20Sopenharmony_ci
52318c2ecf20Sopenharmony_ci		smc_state->levelCount++;
52328c2ecf20Sopenharmony_ci	}
52338c2ecf20Sopenharmony_ci
52348c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev,
52358c2ecf20Sopenharmony_ci				   SI_SMC_SOFT_REGISTER_watermark_threshold,
52368c2ecf20Sopenharmony_ci				   threshold / 512);
52378c2ecf20Sopenharmony_ci
52388c2ecf20Sopenharmony_ci	si_populate_smc_sp(rdev, radeon_state, smc_state);
52398c2ecf20Sopenharmony_ci
52408c2ecf20Sopenharmony_ci	ret = si_populate_power_containment_values(rdev, radeon_state, smc_state);
52418c2ecf20Sopenharmony_ci	if (ret)
52428c2ecf20Sopenharmony_ci		ni_pi->enable_power_containment = false;
52438c2ecf20Sopenharmony_ci
52448c2ecf20Sopenharmony_ci	ret = si_populate_sq_ramping_values(rdev, radeon_state, smc_state);
52458c2ecf20Sopenharmony_ci	if (ret)
52468c2ecf20Sopenharmony_ci		ni_pi->enable_sq_ramping = false;
52478c2ecf20Sopenharmony_ci
52488c2ecf20Sopenharmony_ci	return si_populate_smc_t(rdev, radeon_state, smc_state);
52498c2ecf20Sopenharmony_ci}
52508c2ecf20Sopenharmony_ci
52518c2ecf20Sopenharmony_cistatic int si_upload_sw_state(struct radeon_device *rdev,
52528c2ecf20Sopenharmony_ci			      struct radeon_ps *radeon_new_state)
52538c2ecf20Sopenharmony_ci{
52548c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
52558c2ecf20Sopenharmony_ci	struct ni_ps *new_state = ni_get_ps(radeon_new_state);
52568c2ecf20Sopenharmony_ci	int ret;
52578c2ecf20Sopenharmony_ci	u32 address = si_pi->state_table_start +
52588c2ecf20Sopenharmony_ci		offsetof(SISLANDS_SMC_STATETABLE, driverState);
52598c2ecf20Sopenharmony_ci	u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) +
52608c2ecf20Sopenharmony_ci		((new_state->performance_level_count - 1) *
52618c2ecf20Sopenharmony_ci		 sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL));
52628c2ecf20Sopenharmony_ci	SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState;
52638c2ecf20Sopenharmony_ci
52648c2ecf20Sopenharmony_ci	memset(smc_state, 0, state_size);
52658c2ecf20Sopenharmony_ci
52668c2ecf20Sopenharmony_ci	ret = si_convert_power_state_to_smc(rdev, radeon_new_state, smc_state);
52678c2ecf20Sopenharmony_ci	if (ret)
52688c2ecf20Sopenharmony_ci		return ret;
52698c2ecf20Sopenharmony_ci
52708c2ecf20Sopenharmony_ci	ret = si_copy_bytes_to_smc(rdev, address, (u8 *)smc_state,
52718c2ecf20Sopenharmony_ci				   state_size, si_pi->sram_end);
52728c2ecf20Sopenharmony_ci
52738c2ecf20Sopenharmony_ci	return ret;
52748c2ecf20Sopenharmony_ci}
52758c2ecf20Sopenharmony_ci
52768c2ecf20Sopenharmony_cistatic int si_upload_ulv_state(struct radeon_device *rdev)
52778c2ecf20Sopenharmony_ci{
52788c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
52798c2ecf20Sopenharmony_ci	struct si_ulv_param *ulv = &si_pi->ulv;
52808c2ecf20Sopenharmony_ci	int ret = 0;
52818c2ecf20Sopenharmony_ci
52828c2ecf20Sopenharmony_ci	if (ulv->supported && ulv->pl.vddc) {
52838c2ecf20Sopenharmony_ci		u32 address = si_pi->state_table_start +
52848c2ecf20Sopenharmony_ci			offsetof(SISLANDS_SMC_STATETABLE, ULVState);
52858c2ecf20Sopenharmony_ci		SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.ULVState;
52868c2ecf20Sopenharmony_ci		u32 state_size = sizeof(SISLANDS_SMC_SWSTATE);
52878c2ecf20Sopenharmony_ci
52888c2ecf20Sopenharmony_ci		memset(smc_state, 0, state_size);
52898c2ecf20Sopenharmony_ci
52908c2ecf20Sopenharmony_ci		ret = si_populate_ulv_state(rdev, smc_state);
52918c2ecf20Sopenharmony_ci		if (!ret)
52928c2ecf20Sopenharmony_ci			ret = si_copy_bytes_to_smc(rdev, address, (u8 *)smc_state,
52938c2ecf20Sopenharmony_ci						   state_size, si_pi->sram_end);
52948c2ecf20Sopenharmony_ci	}
52958c2ecf20Sopenharmony_ci
52968c2ecf20Sopenharmony_ci	return ret;
52978c2ecf20Sopenharmony_ci}
52988c2ecf20Sopenharmony_ci
52998c2ecf20Sopenharmony_cistatic int si_upload_smc_data(struct radeon_device *rdev)
53008c2ecf20Sopenharmony_ci{
53018c2ecf20Sopenharmony_ci	struct radeon_crtc *radeon_crtc = NULL;
53028c2ecf20Sopenharmony_ci	int i;
53038c2ecf20Sopenharmony_ci
53048c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.new_active_crtc_count == 0)
53058c2ecf20Sopenharmony_ci		return 0;
53068c2ecf20Sopenharmony_ci
53078c2ecf20Sopenharmony_ci	for (i = 0; i < rdev->num_crtc; i++) {
53088c2ecf20Sopenharmony_ci		if (rdev->pm.dpm.new_active_crtcs & (1 << i)) {
53098c2ecf20Sopenharmony_ci			radeon_crtc = rdev->mode_info.crtcs[i];
53108c2ecf20Sopenharmony_ci			break;
53118c2ecf20Sopenharmony_ci		}
53128c2ecf20Sopenharmony_ci	}
53138c2ecf20Sopenharmony_ci
53148c2ecf20Sopenharmony_ci	if (radeon_crtc == NULL)
53158c2ecf20Sopenharmony_ci		return 0;
53168c2ecf20Sopenharmony_ci
53178c2ecf20Sopenharmony_ci	if (radeon_crtc->line_time <= 0)
53188c2ecf20Sopenharmony_ci		return 0;
53198c2ecf20Sopenharmony_ci
53208c2ecf20Sopenharmony_ci	if (si_write_smc_soft_register(rdev,
53218c2ecf20Sopenharmony_ci				       SI_SMC_SOFT_REGISTER_crtc_index,
53228c2ecf20Sopenharmony_ci				       radeon_crtc->crtc_id) != PPSMC_Result_OK)
53238c2ecf20Sopenharmony_ci		return 0;
53248c2ecf20Sopenharmony_ci
53258c2ecf20Sopenharmony_ci	if (si_write_smc_soft_register(rdev,
53268c2ecf20Sopenharmony_ci				       SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
53278c2ecf20Sopenharmony_ci				       radeon_crtc->wm_high / radeon_crtc->line_time) != PPSMC_Result_OK)
53288c2ecf20Sopenharmony_ci		return 0;
53298c2ecf20Sopenharmony_ci
53308c2ecf20Sopenharmony_ci	if (si_write_smc_soft_register(rdev,
53318c2ecf20Sopenharmony_ci				       SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
53328c2ecf20Sopenharmony_ci				       radeon_crtc->wm_low / radeon_crtc->line_time) != PPSMC_Result_OK)
53338c2ecf20Sopenharmony_ci		return 0;
53348c2ecf20Sopenharmony_ci
53358c2ecf20Sopenharmony_ci	return 0;
53368c2ecf20Sopenharmony_ci}
53378c2ecf20Sopenharmony_ci
53388c2ecf20Sopenharmony_cistatic int si_set_mc_special_registers(struct radeon_device *rdev,
53398c2ecf20Sopenharmony_ci				       struct si_mc_reg_table *table)
53408c2ecf20Sopenharmony_ci{
53418c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
53428c2ecf20Sopenharmony_ci	u8 i, j, k;
53438c2ecf20Sopenharmony_ci	u32 temp_reg;
53448c2ecf20Sopenharmony_ci
53458c2ecf20Sopenharmony_ci	for (i = 0, j = table->last; i < table->last; i++) {
53468c2ecf20Sopenharmony_ci		if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
53478c2ecf20Sopenharmony_ci			return -EINVAL;
53488c2ecf20Sopenharmony_ci		switch (table->mc_reg_address[i].s1 << 2) {
53498c2ecf20Sopenharmony_ci		case MC_SEQ_MISC1:
53508c2ecf20Sopenharmony_ci			temp_reg = RREG32(MC_PMG_CMD_EMRS);
53518c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS >> 2;
53528c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
53538c2ecf20Sopenharmony_ci			for (k = 0; k < table->num_entries; k++)
53548c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[k].mc_data[j] =
53558c2ecf20Sopenharmony_ci					((temp_reg & 0xffff0000)) |
53568c2ecf20Sopenharmony_ci					((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
53578c2ecf20Sopenharmony_ci			j++;
53588c2ecf20Sopenharmony_ci			if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
53598c2ecf20Sopenharmony_ci				return -EINVAL;
53608c2ecf20Sopenharmony_ci
53618c2ecf20Sopenharmony_ci			temp_reg = RREG32(MC_PMG_CMD_MRS);
53628c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS >> 2;
53638c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP >> 2;
53648c2ecf20Sopenharmony_ci			for (k = 0; k < table->num_entries; k++) {
53658c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[k].mc_data[j] =
53668c2ecf20Sopenharmony_ci					(temp_reg & 0xffff0000) |
53678c2ecf20Sopenharmony_ci					(table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
53688c2ecf20Sopenharmony_ci				if (!pi->mem_gddr5)
53698c2ecf20Sopenharmony_ci					table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
53708c2ecf20Sopenharmony_ci			}
53718c2ecf20Sopenharmony_ci			j++;
53728c2ecf20Sopenharmony_ci			if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
53738c2ecf20Sopenharmony_ci				return -EINVAL;
53748c2ecf20Sopenharmony_ci
53758c2ecf20Sopenharmony_ci			if (!pi->mem_gddr5) {
53768c2ecf20Sopenharmony_ci				table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD >> 2;
53778c2ecf20Sopenharmony_ci				table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD >> 2;
53788c2ecf20Sopenharmony_ci				for (k = 0; k < table->num_entries; k++)
53798c2ecf20Sopenharmony_ci					table->mc_reg_table_entry[k].mc_data[j] =
53808c2ecf20Sopenharmony_ci						(table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16;
53818c2ecf20Sopenharmony_ci				j++;
53828c2ecf20Sopenharmony_ci				if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
53838c2ecf20Sopenharmony_ci					return -EINVAL;
53848c2ecf20Sopenharmony_ci			}
53858c2ecf20Sopenharmony_ci			break;
53868c2ecf20Sopenharmony_ci		case MC_SEQ_RESERVE_M:
53878c2ecf20Sopenharmony_ci			temp_reg = RREG32(MC_PMG_CMD_MRS1);
53888c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1 >> 2;
53898c2ecf20Sopenharmony_ci			table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
53908c2ecf20Sopenharmony_ci			for(k = 0; k < table->num_entries; k++)
53918c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[k].mc_data[j] =
53928c2ecf20Sopenharmony_ci					(temp_reg & 0xffff0000) |
53938c2ecf20Sopenharmony_ci					(table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
53948c2ecf20Sopenharmony_ci			j++;
53958c2ecf20Sopenharmony_ci			if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
53968c2ecf20Sopenharmony_ci				return -EINVAL;
53978c2ecf20Sopenharmony_ci			break;
53988c2ecf20Sopenharmony_ci		default:
53998c2ecf20Sopenharmony_ci			break;
54008c2ecf20Sopenharmony_ci		}
54018c2ecf20Sopenharmony_ci	}
54028c2ecf20Sopenharmony_ci
54038c2ecf20Sopenharmony_ci	table->last = j;
54048c2ecf20Sopenharmony_ci
54058c2ecf20Sopenharmony_ci	return 0;
54068c2ecf20Sopenharmony_ci}
54078c2ecf20Sopenharmony_ci
54088c2ecf20Sopenharmony_cistatic bool si_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
54098c2ecf20Sopenharmony_ci{
54108c2ecf20Sopenharmony_ci	bool result = true;
54118c2ecf20Sopenharmony_ci
54128c2ecf20Sopenharmony_ci	switch (in_reg) {
54138c2ecf20Sopenharmony_ci	case  MC_SEQ_RAS_TIMING >> 2:
54148c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_RAS_TIMING_LP >> 2;
54158c2ecf20Sopenharmony_ci		break;
54168c2ecf20Sopenharmony_ci	case MC_SEQ_CAS_TIMING >> 2:
54178c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_CAS_TIMING_LP >> 2;
54188c2ecf20Sopenharmony_ci		break;
54198c2ecf20Sopenharmony_ci	case MC_SEQ_MISC_TIMING >> 2:
54208c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_MISC_TIMING_LP >> 2;
54218c2ecf20Sopenharmony_ci		break;
54228c2ecf20Sopenharmony_ci	case MC_SEQ_MISC_TIMING2 >> 2:
54238c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_MISC_TIMING2_LP >> 2;
54248c2ecf20Sopenharmony_ci		break;
54258c2ecf20Sopenharmony_ci	case MC_SEQ_RD_CTL_D0 >> 2:
54268c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_RD_CTL_D0_LP >> 2;
54278c2ecf20Sopenharmony_ci		break;
54288c2ecf20Sopenharmony_ci	case MC_SEQ_RD_CTL_D1 >> 2:
54298c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_RD_CTL_D1_LP >> 2;
54308c2ecf20Sopenharmony_ci		break;
54318c2ecf20Sopenharmony_ci	case MC_SEQ_WR_CTL_D0 >> 2:
54328c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_WR_CTL_D0_LP >> 2;
54338c2ecf20Sopenharmony_ci		break;
54348c2ecf20Sopenharmony_ci	case MC_SEQ_WR_CTL_D1 >> 2:
54358c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_WR_CTL_D1_LP >> 2;
54368c2ecf20Sopenharmony_ci		break;
54378c2ecf20Sopenharmony_ci	case MC_PMG_CMD_EMRS >> 2:
54388c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
54398c2ecf20Sopenharmony_ci		break;
54408c2ecf20Sopenharmony_ci	case MC_PMG_CMD_MRS >> 2:
54418c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_MRS_LP >> 2;
54428c2ecf20Sopenharmony_ci		break;
54438c2ecf20Sopenharmony_ci	case MC_PMG_CMD_MRS1 >> 2:
54448c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
54458c2ecf20Sopenharmony_ci		break;
54468c2ecf20Sopenharmony_ci	case MC_SEQ_PMG_TIMING >> 2:
54478c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_TIMING_LP >> 2;
54488c2ecf20Sopenharmony_ci		break;
54498c2ecf20Sopenharmony_ci	case MC_PMG_CMD_MRS2 >> 2:
54508c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_PMG_CMD_MRS2_LP >> 2;
54518c2ecf20Sopenharmony_ci		break;
54528c2ecf20Sopenharmony_ci	case MC_SEQ_WR_CTL_2 >> 2:
54538c2ecf20Sopenharmony_ci		*out_reg = MC_SEQ_WR_CTL_2_LP >> 2;
54548c2ecf20Sopenharmony_ci		break;
54558c2ecf20Sopenharmony_ci	default:
54568c2ecf20Sopenharmony_ci		result = false;
54578c2ecf20Sopenharmony_ci		break;
54588c2ecf20Sopenharmony_ci	}
54598c2ecf20Sopenharmony_ci
54608c2ecf20Sopenharmony_ci	return result;
54618c2ecf20Sopenharmony_ci}
54628c2ecf20Sopenharmony_ci
54638c2ecf20Sopenharmony_cistatic void si_set_valid_flag(struct si_mc_reg_table *table)
54648c2ecf20Sopenharmony_ci{
54658c2ecf20Sopenharmony_ci	u8 i, j;
54668c2ecf20Sopenharmony_ci
54678c2ecf20Sopenharmony_ci	for (i = 0; i < table->last; i++) {
54688c2ecf20Sopenharmony_ci		for (j = 1; j < table->num_entries; j++) {
54698c2ecf20Sopenharmony_ci			if (table->mc_reg_table_entry[j-1].mc_data[i] != table->mc_reg_table_entry[j].mc_data[i]) {
54708c2ecf20Sopenharmony_ci				table->valid_flag |= 1 << i;
54718c2ecf20Sopenharmony_ci				break;
54728c2ecf20Sopenharmony_ci			}
54738c2ecf20Sopenharmony_ci		}
54748c2ecf20Sopenharmony_ci	}
54758c2ecf20Sopenharmony_ci}
54768c2ecf20Sopenharmony_ci
54778c2ecf20Sopenharmony_cistatic void si_set_s0_mc_reg_index(struct si_mc_reg_table *table)
54788c2ecf20Sopenharmony_ci{
54798c2ecf20Sopenharmony_ci	u32 i;
54808c2ecf20Sopenharmony_ci	u16 address;
54818c2ecf20Sopenharmony_ci
54828c2ecf20Sopenharmony_ci	for (i = 0; i < table->last; i++)
54838c2ecf20Sopenharmony_ci		table->mc_reg_address[i].s0 = si_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
54848c2ecf20Sopenharmony_ci			address : table->mc_reg_address[i].s1;
54858c2ecf20Sopenharmony_ci
54868c2ecf20Sopenharmony_ci}
54878c2ecf20Sopenharmony_ci
54888c2ecf20Sopenharmony_cistatic int si_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
54898c2ecf20Sopenharmony_ci				      struct si_mc_reg_table *si_table)
54908c2ecf20Sopenharmony_ci{
54918c2ecf20Sopenharmony_ci	u8 i, j;
54928c2ecf20Sopenharmony_ci
54938c2ecf20Sopenharmony_ci	if (table->last > SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
54948c2ecf20Sopenharmony_ci		return -EINVAL;
54958c2ecf20Sopenharmony_ci	if (table->num_entries > MAX_AC_TIMING_ENTRIES)
54968c2ecf20Sopenharmony_ci		return -EINVAL;
54978c2ecf20Sopenharmony_ci
54988c2ecf20Sopenharmony_ci	for (i = 0; i < table->last; i++)
54998c2ecf20Sopenharmony_ci		si_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
55008c2ecf20Sopenharmony_ci	si_table->last = table->last;
55018c2ecf20Sopenharmony_ci
55028c2ecf20Sopenharmony_ci	for (i = 0; i < table->num_entries; i++) {
55038c2ecf20Sopenharmony_ci		si_table->mc_reg_table_entry[i].mclk_max =
55048c2ecf20Sopenharmony_ci			table->mc_reg_table_entry[i].mclk_max;
55058c2ecf20Sopenharmony_ci		for (j = 0; j < table->last; j++) {
55068c2ecf20Sopenharmony_ci			si_table->mc_reg_table_entry[i].mc_data[j] =
55078c2ecf20Sopenharmony_ci				table->mc_reg_table_entry[i].mc_data[j];
55088c2ecf20Sopenharmony_ci		}
55098c2ecf20Sopenharmony_ci	}
55108c2ecf20Sopenharmony_ci	si_table->num_entries = table->num_entries;
55118c2ecf20Sopenharmony_ci
55128c2ecf20Sopenharmony_ci	return 0;
55138c2ecf20Sopenharmony_ci}
55148c2ecf20Sopenharmony_ci
55158c2ecf20Sopenharmony_cistatic int si_initialize_mc_reg_table(struct radeon_device *rdev)
55168c2ecf20Sopenharmony_ci{
55178c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
55188c2ecf20Sopenharmony_ci	struct atom_mc_reg_table *table;
55198c2ecf20Sopenharmony_ci	struct si_mc_reg_table *si_table = &si_pi->mc_reg_table;
55208c2ecf20Sopenharmony_ci	u8 module_index = rv770_get_memory_module_index(rdev);
55218c2ecf20Sopenharmony_ci	int ret;
55228c2ecf20Sopenharmony_ci
55238c2ecf20Sopenharmony_ci	table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
55248c2ecf20Sopenharmony_ci	if (!table)
55258c2ecf20Sopenharmony_ci		return -ENOMEM;
55268c2ecf20Sopenharmony_ci
55278c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
55288c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
55298c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
55308c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
55318c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
55328c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
55338c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
55348c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
55358c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
55368c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
55378c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
55388c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_TIMING_LP, RREG32(MC_SEQ_PMG_TIMING));
55398c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_PMG_CMD_MRS2_LP, RREG32(MC_PMG_CMD_MRS2));
55408c2ecf20Sopenharmony_ci	WREG32(MC_SEQ_WR_CTL_2_LP, RREG32(MC_SEQ_WR_CTL_2));
55418c2ecf20Sopenharmony_ci
55428c2ecf20Sopenharmony_ci	ret = radeon_atom_init_mc_reg_table(rdev, module_index, table);
55438c2ecf20Sopenharmony_ci	if (ret)
55448c2ecf20Sopenharmony_ci		goto init_mc_done;
55458c2ecf20Sopenharmony_ci
55468c2ecf20Sopenharmony_ci	ret = si_copy_vbios_mc_reg_table(table, si_table);
55478c2ecf20Sopenharmony_ci	if (ret)
55488c2ecf20Sopenharmony_ci		goto init_mc_done;
55498c2ecf20Sopenharmony_ci
55508c2ecf20Sopenharmony_ci	si_set_s0_mc_reg_index(si_table);
55518c2ecf20Sopenharmony_ci
55528c2ecf20Sopenharmony_ci	ret = si_set_mc_special_registers(rdev, si_table);
55538c2ecf20Sopenharmony_ci	if (ret)
55548c2ecf20Sopenharmony_ci		goto init_mc_done;
55558c2ecf20Sopenharmony_ci
55568c2ecf20Sopenharmony_ci	si_set_valid_flag(si_table);
55578c2ecf20Sopenharmony_ci
55588c2ecf20Sopenharmony_ciinit_mc_done:
55598c2ecf20Sopenharmony_ci	kfree(table);
55608c2ecf20Sopenharmony_ci
55618c2ecf20Sopenharmony_ci	return ret;
55628c2ecf20Sopenharmony_ci
55638c2ecf20Sopenharmony_ci}
55648c2ecf20Sopenharmony_ci
55658c2ecf20Sopenharmony_cistatic void si_populate_mc_reg_addresses(struct radeon_device *rdev,
55668c2ecf20Sopenharmony_ci					 SMC_SIslands_MCRegisters *mc_reg_table)
55678c2ecf20Sopenharmony_ci{
55688c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
55698c2ecf20Sopenharmony_ci	u32 i, j;
55708c2ecf20Sopenharmony_ci
55718c2ecf20Sopenharmony_ci	for (i = 0, j = 0; j < si_pi->mc_reg_table.last; j++) {
55728c2ecf20Sopenharmony_ci		if (si_pi->mc_reg_table.valid_flag & (1 << j)) {
55738c2ecf20Sopenharmony_ci			if (i >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
55748c2ecf20Sopenharmony_ci				break;
55758c2ecf20Sopenharmony_ci			mc_reg_table->address[i].s0 =
55768c2ecf20Sopenharmony_ci				cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s0);
55778c2ecf20Sopenharmony_ci			mc_reg_table->address[i].s1 =
55788c2ecf20Sopenharmony_ci				cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s1);
55798c2ecf20Sopenharmony_ci			i++;
55808c2ecf20Sopenharmony_ci		}
55818c2ecf20Sopenharmony_ci	}
55828c2ecf20Sopenharmony_ci	mc_reg_table->last = (u8)i;
55838c2ecf20Sopenharmony_ci}
55848c2ecf20Sopenharmony_ci
55858c2ecf20Sopenharmony_cistatic void si_convert_mc_registers(const struct si_mc_reg_entry *entry,
55868c2ecf20Sopenharmony_ci				    SMC_SIslands_MCRegisterSet *data,
55878c2ecf20Sopenharmony_ci				    u32 num_entries, u32 valid_flag)
55888c2ecf20Sopenharmony_ci{
55898c2ecf20Sopenharmony_ci	u32 i, j;
55908c2ecf20Sopenharmony_ci
55918c2ecf20Sopenharmony_ci	for(i = 0, j = 0; j < num_entries; j++) {
55928c2ecf20Sopenharmony_ci		if (valid_flag & (1 << j)) {
55938c2ecf20Sopenharmony_ci			data->value[i] = cpu_to_be32(entry->mc_data[j]);
55948c2ecf20Sopenharmony_ci			i++;
55958c2ecf20Sopenharmony_ci		}
55968c2ecf20Sopenharmony_ci	}
55978c2ecf20Sopenharmony_ci}
55988c2ecf20Sopenharmony_ci
55998c2ecf20Sopenharmony_cistatic void si_convert_mc_reg_table_entry_to_smc(struct radeon_device *rdev,
56008c2ecf20Sopenharmony_ci						 struct rv7xx_pl *pl,
56018c2ecf20Sopenharmony_ci						 SMC_SIslands_MCRegisterSet *mc_reg_table_data)
56028c2ecf20Sopenharmony_ci{
56038c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
56048c2ecf20Sopenharmony_ci	u32 i = 0;
56058c2ecf20Sopenharmony_ci
56068c2ecf20Sopenharmony_ci	for (i = 0; i < si_pi->mc_reg_table.num_entries; i++) {
56078c2ecf20Sopenharmony_ci		if (pl->mclk <= si_pi->mc_reg_table.mc_reg_table_entry[i].mclk_max)
56088c2ecf20Sopenharmony_ci			break;
56098c2ecf20Sopenharmony_ci	}
56108c2ecf20Sopenharmony_ci
56118c2ecf20Sopenharmony_ci	if ((i == si_pi->mc_reg_table.num_entries) && (i > 0))
56128c2ecf20Sopenharmony_ci		--i;
56138c2ecf20Sopenharmony_ci
56148c2ecf20Sopenharmony_ci	si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[i],
56158c2ecf20Sopenharmony_ci				mc_reg_table_data, si_pi->mc_reg_table.last,
56168c2ecf20Sopenharmony_ci				si_pi->mc_reg_table.valid_flag);
56178c2ecf20Sopenharmony_ci}
56188c2ecf20Sopenharmony_ci
56198c2ecf20Sopenharmony_cistatic void si_convert_mc_reg_table_to_smc(struct radeon_device *rdev,
56208c2ecf20Sopenharmony_ci					   struct radeon_ps *radeon_state,
56218c2ecf20Sopenharmony_ci					   SMC_SIslands_MCRegisters *mc_reg_table)
56228c2ecf20Sopenharmony_ci{
56238c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
56248c2ecf20Sopenharmony_ci	int i;
56258c2ecf20Sopenharmony_ci
56268c2ecf20Sopenharmony_ci	for (i = 0; i < state->performance_level_count; i++) {
56278c2ecf20Sopenharmony_ci		si_convert_mc_reg_table_entry_to_smc(rdev,
56288c2ecf20Sopenharmony_ci						     &state->performance_levels[i],
56298c2ecf20Sopenharmony_ci						     &mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i]);
56308c2ecf20Sopenharmony_ci	}
56318c2ecf20Sopenharmony_ci}
56328c2ecf20Sopenharmony_ci
56338c2ecf20Sopenharmony_cistatic int si_populate_mc_reg_table(struct radeon_device *rdev,
56348c2ecf20Sopenharmony_ci				    struct radeon_ps *radeon_boot_state)
56358c2ecf20Sopenharmony_ci{
56368c2ecf20Sopenharmony_ci	struct ni_ps *boot_state = ni_get_ps(radeon_boot_state);
56378c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
56388c2ecf20Sopenharmony_ci	struct si_ulv_param *ulv = &si_pi->ulv;
56398c2ecf20Sopenharmony_ci	SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
56408c2ecf20Sopenharmony_ci
56418c2ecf20Sopenharmony_ci	memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
56428c2ecf20Sopenharmony_ci
56438c2ecf20Sopenharmony_ci	si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_seq_index, 1);
56448c2ecf20Sopenharmony_ci
56458c2ecf20Sopenharmony_ci	si_populate_mc_reg_addresses(rdev, smc_mc_reg_table);
56468c2ecf20Sopenharmony_ci
56478c2ecf20Sopenharmony_ci	si_convert_mc_reg_table_entry_to_smc(rdev, &boot_state->performance_levels[0],
56488c2ecf20Sopenharmony_ci					     &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_INITIAL_SLOT]);
56498c2ecf20Sopenharmony_ci
56508c2ecf20Sopenharmony_ci	si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
56518c2ecf20Sopenharmony_ci				&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ACPI_SLOT],
56528c2ecf20Sopenharmony_ci				si_pi->mc_reg_table.last,
56538c2ecf20Sopenharmony_ci				si_pi->mc_reg_table.valid_flag);
56548c2ecf20Sopenharmony_ci
56558c2ecf20Sopenharmony_ci	if (ulv->supported && ulv->pl.vddc != 0)
56568c2ecf20Sopenharmony_ci		si_convert_mc_reg_table_entry_to_smc(rdev, &ulv->pl,
56578c2ecf20Sopenharmony_ci						     &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT]);
56588c2ecf20Sopenharmony_ci	else
56598c2ecf20Sopenharmony_ci		si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
56608c2ecf20Sopenharmony_ci					&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT],
56618c2ecf20Sopenharmony_ci					si_pi->mc_reg_table.last,
56628c2ecf20Sopenharmony_ci					si_pi->mc_reg_table.valid_flag);
56638c2ecf20Sopenharmony_ci
56648c2ecf20Sopenharmony_ci	si_convert_mc_reg_table_to_smc(rdev, radeon_boot_state, smc_mc_reg_table);
56658c2ecf20Sopenharmony_ci
56668c2ecf20Sopenharmony_ci	return si_copy_bytes_to_smc(rdev, si_pi->mc_reg_table_start,
56678c2ecf20Sopenharmony_ci				    (u8 *)smc_mc_reg_table,
56688c2ecf20Sopenharmony_ci				    sizeof(SMC_SIslands_MCRegisters), si_pi->sram_end);
56698c2ecf20Sopenharmony_ci}
56708c2ecf20Sopenharmony_ci
56718c2ecf20Sopenharmony_cistatic int si_upload_mc_reg_table(struct radeon_device *rdev,
56728c2ecf20Sopenharmony_ci				  struct radeon_ps *radeon_new_state)
56738c2ecf20Sopenharmony_ci{
56748c2ecf20Sopenharmony_ci	struct ni_ps *new_state = ni_get_ps(radeon_new_state);
56758c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
56768c2ecf20Sopenharmony_ci	u32 address = si_pi->mc_reg_table_start +
56778c2ecf20Sopenharmony_ci		offsetof(SMC_SIslands_MCRegisters,
56788c2ecf20Sopenharmony_ci			 data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT]);
56798c2ecf20Sopenharmony_ci	SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
56808c2ecf20Sopenharmony_ci
56818c2ecf20Sopenharmony_ci	memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
56828c2ecf20Sopenharmony_ci
56838c2ecf20Sopenharmony_ci	si_convert_mc_reg_table_to_smc(rdev, radeon_new_state, smc_mc_reg_table);
56848c2ecf20Sopenharmony_ci
56858c2ecf20Sopenharmony_ci
56868c2ecf20Sopenharmony_ci	return si_copy_bytes_to_smc(rdev, address,
56878c2ecf20Sopenharmony_ci				    (u8 *)&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT],
56888c2ecf20Sopenharmony_ci				    sizeof(SMC_SIslands_MCRegisterSet) * new_state->performance_level_count,
56898c2ecf20Sopenharmony_ci				    si_pi->sram_end);
56908c2ecf20Sopenharmony_ci
56918c2ecf20Sopenharmony_ci}
56928c2ecf20Sopenharmony_ci
56938c2ecf20Sopenharmony_cistatic void si_enable_voltage_control(struct radeon_device *rdev, bool enable)
56948c2ecf20Sopenharmony_ci{
56958c2ecf20Sopenharmony_ci	if (enable)
56968c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, VOLT_PWRMGT_EN, ~VOLT_PWRMGT_EN);
56978c2ecf20Sopenharmony_ci	else
56988c2ecf20Sopenharmony_ci		WREG32_P(GENERAL_PWRMGT, 0, ~VOLT_PWRMGT_EN);
56998c2ecf20Sopenharmony_ci}
57008c2ecf20Sopenharmony_ci
57018c2ecf20Sopenharmony_cistatic enum radeon_pcie_gen si_get_maximum_link_speed(struct radeon_device *rdev,
57028c2ecf20Sopenharmony_ci						      struct radeon_ps *radeon_state)
57038c2ecf20Sopenharmony_ci{
57048c2ecf20Sopenharmony_ci	struct ni_ps *state = ni_get_ps(radeon_state);
57058c2ecf20Sopenharmony_ci	int i;
57068c2ecf20Sopenharmony_ci	u16 pcie_speed, max_speed = 0;
57078c2ecf20Sopenharmony_ci
57088c2ecf20Sopenharmony_ci	for (i = 0; i < state->performance_level_count; i++) {
57098c2ecf20Sopenharmony_ci		pcie_speed = state->performance_levels[i].pcie_gen;
57108c2ecf20Sopenharmony_ci		if (max_speed < pcie_speed)
57118c2ecf20Sopenharmony_ci			max_speed = pcie_speed;
57128c2ecf20Sopenharmony_ci	}
57138c2ecf20Sopenharmony_ci	return max_speed;
57148c2ecf20Sopenharmony_ci}
57158c2ecf20Sopenharmony_ci
57168c2ecf20Sopenharmony_cistatic u16 si_get_current_pcie_speed(struct radeon_device *rdev)
57178c2ecf20Sopenharmony_ci{
57188c2ecf20Sopenharmony_ci	u32 speed_cntl;
57198c2ecf20Sopenharmony_ci
57208c2ecf20Sopenharmony_ci	speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL) & LC_CURRENT_DATA_RATE_MASK;
57218c2ecf20Sopenharmony_ci	speed_cntl >>= LC_CURRENT_DATA_RATE_SHIFT;
57228c2ecf20Sopenharmony_ci
57238c2ecf20Sopenharmony_ci	return (u16)speed_cntl;
57248c2ecf20Sopenharmony_ci}
57258c2ecf20Sopenharmony_ci
57268c2ecf20Sopenharmony_cistatic void si_request_link_speed_change_before_state_change(struct radeon_device *rdev,
57278c2ecf20Sopenharmony_ci							     struct radeon_ps *radeon_new_state,
57288c2ecf20Sopenharmony_ci							     struct radeon_ps *radeon_current_state)
57298c2ecf20Sopenharmony_ci{
57308c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
57318c2ecf20Sopenharmony_ci	enum radeon_pcie_gen target_link_speed = si_get_maximum_link_speed(rdev, radeon_new_state);
57328c2ecf20Sopenharmony_ci	enum radeon_pcie_gen current_link_speed;
57338c2ecf20Sopenharmony_ci
57348c2ecf20Sopenharmony_ci	if (si_pi->force_pcie_gen == RADEON_PCIE_GEN_INVALID)
57358c2ecf20Sopenharmony_ci		current_link_speed = si_get_maximum_link_speed(rdev, radeon_current_state);
57368c2ecf20Sopenharmony_ci	else
57378c2ecf20Sopenharmony_ci		current_link_speed = si_pi->force_pcie_gen;
57388c2ecf20Sopenharmony_ci
57398c2ecf20Sopenharmony_ci	si_pi->force_pcie_gen = RADEON_PCIE_GEN_INVALID;
57408c2ecf20Sopenharmony_ci	si_pi->pspp_notify_required = false;
57418c2ecf20Sopenharmony_ci	if (target_link_speed > current_link_speed) {
57428c2ecf20Sopenharmony_ci		switch (target_link_speed) {
57438c2ecf20Sopenharmony_ci#if defined(CONFIG_ACPI)
57448c2ecf20Sopenharmony_ci		case RADEON_PCIE_GEN3:
57458c2ecf20Sopenharmony_ci			if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN3, false) == 0)
57468c2ecf20Sopenharmony_ci				break;
57478c2ecf20Sopenharmony_ci			si_pi->force_pcie_gen = RADEON_PCIE_GEN2;
57488c2ecf20Sopenharmony_ci			if (current_link_speed == RADEON_PCIE_GEN2)
57498c2ecf20Sopenharmony_ci				break;
57508c2ecf20Sopenharmony_ci			fallthrough;
57518c2ecf20Sopenharmony_ci		case RADEON_PCIE_GEN2:
57528c2ecf20Sopenharmony_ci			if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
57538c2ecf20Sopenharmony_ci				break;
57548c2ecf20Sopenharmony_ci#endif
57558c2ecf20Sopenharmony_ci			/* fall through */
57568c2ecf20Sopenharmony_ci		default:
57578c2ecf20Sopenharmony_ci			si_pi->force_pcie_gen = si_get_current_pcie_speed(rdev);
57588c2ecf20Sopenharmony_ci			break;
57598c2ecf20Sopenharmony_ci		}
57608c2ecf20Sopenharmony_ci	} else {
57618c2ecf20Sopenharmony_ci		if (target_link_speed < current_link_speed)
57628c2ecf20Sopenharmony_ci			si_pi->pspp_notify_required = true;
57638c2ecf20Sopenharmony_ci	}
57648c2ecf20Sopenharmony_ci}
57658c2ecf20Sopenharmony_ci
57668c2ecf20Sopenharmony_cistatic void si_notify_link_speed_change_after_state_change(struct radeon_device *rdev,
57678c2ecf20Sopenharmony_ci							   struct radeon_ps *radeon_new_state,
57688c2ecf20Sopenharmony_ci							   struct radeon_ps *radeon_current_state)
57698c2ecf20Sopenharmony_ci{
57708c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
57718c2ecf20Sopenharmony_ci	enum radeon_pcie_gen target_link_speed = si_get_maximum_link_speed(rdev, radeon_new_state);
57728c2ecf20Sopenharmony_ci	u8 request;
57738c2ecf20Sopenharmony_ci
57748c2ecf20Sopenharmony_ci	if (si_pi->pspp_notify_required) {
57758c2ecf20Sopenharmony_ci		if (target_link_speed == RADEON_PCIE_GEN3)
57768c2ecf20Sopenharmony_ci			request = PCIE_PERF_REQ_PECI_GEN3;
57778c2ecf20Sopenharmony_ci		else if (target_link_speed == RADEON_PCIE_GEN2)
57788c2ecf20Sopenharmony_ci			request = PCIE_PERF_REQ_PECI_GEN2;
57798c2ecf20Sopenharmony_ci		else
57808c2ecf20Sopenharmony_ci			request = PCIE_PERF_REQ_PECI_GEN1;
57818c2ecf20Sopenharmony_ci
57828c2ecf20Sopenharmony_ci		if ((request == PCIE_PERF_REQ_PECI_GEN1) &&
57838c2ecf20Sopenharmony_ci		    (si_get_current_pcie_speed(rdev) > 0))
57848c2ecf20Sopenharmony_ci			return;
57858c2ecf20Sopenharmony_ci
57868c2ecf20Sopenharmony_ci#if defined(CONFIG_ACPI)
57878c2ecf20Sopenharmony_ci		radeon_acpi_pcie_performance_request(rdev, request, false);
57888c2ecf20Sopenharmony_ci#endif
57898c2ecf20Sopenharmony_ci	}
57908c2ecf20Sopenharmony_ci}
57918c2ecf20Sopenharmony_ci
57928c2ecf20Sopenharmony_ci#if 0
57938c2ecf20Sopenharmony_cistatic int si_ds_request(struct radeon_device *rdev,
57948c2ecf20Sopenharmony_ci			 bool ds_status_on, u32 count_write)
57958c2ecf20Sopenharmony_ci{
57968c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
57978c2ecf20Sopenharmony_ci
57988c2ecf20Sopenharmony_ci	if (eg_pi->sclk_deep_sleep) {
57998c2ecf20Sopenharmony_ci		if (ds_status_on)
58008c2ecf20Sopenharmony_ci			return (si_send_msg_to_smc(rdev, PPSMC_MSG_CancelThrottleOVRDSCLKDS) ==
58018c2ecf20Sopenharmony_ci				PPSMC_Result_OK) ?
58028c2ecf20Sopenharmony_ci				0 : -EINVAL;
58038c2ecf20Sopenharmony_ci		else
58048c2ecf20Sopenharmony_ci			return (si_send_msg_to_smc(rdev, PPSMC_MSG_ThrottleOVRDSCLKDS) ==
58058c2ecf20Sopenharmony_ci				PPSMC_Result_OK) ? 0 : -EINVAL;
58068c2ecf20Sopenharmony_ci	}
58078c2ecf20Sopenharmony_ci	return 0;
58088c2ecf20Sopenharmony_ci}
58098c2ecf20Sopenharmony_ci#endif
58108c2ecf20Sopenharmony_ci
58118c2ecf20Sopenharmony_cistatic void si_set_max_cu_value(struct radeon_device *rdev)
58128c2ecf20Sopenharmony_ci{
58138c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
58148c2ecf20Sopenharmony_ci
58158c2ecf20Sopenharmony_ci	if (rdev->family == CHIP_VERDE) {
58168c2ecf20Sopenharmony_ci		switch (rdev->pdev->device) {
58178c2ecf20Sopenharmony_ci		case 0x6820:
58188c2ecf20Sopenharmony_ci		case 0x6825:
58198c2ecf20Sopenharmony_ci		case 0x6821:
58208c2ecf20Sopenharmony_ci		case 0x6823:
58218c2ecf20Sopenharmony_ci		case 0x6827:
58228c2ecf20Sopenharmony_ci			si_pi->max_cu = 10;
58238c2ecf20Sopenharmony_ci			break;
58248c2ecf20Sopenharmony_ci		case 0x682D:
58258c2ecf20Sopenharmony_ci		case 0x6824:
58268c2ecf20Sopenharmony_ci		case 0x682F:
58278c2ecf20Sopenharmony_ci		case 0x6826:
58288c2ecf20Sopenharmony_ci			si_pi->max_cu = 8;
58298c2ecf20Sopenharmony_ci			break;
58308c2ecf20Sopenharmony_ci		case 0x6828:
58318c2ecf20Sopenharmony_ci		case 0x6830:
58328c2ecf20Sopenharmony_ci		case 0x6831:
58338c2ecf20Sopenharmony_ci		case 0x6838:
58348c2ecf20Sopenharmony_ci		case 0x6839:
58358c2ecf20Sopenharmony_ci		case 0x683D:
58368c2ecf20Sopenharmony_ci			si_pi->max_cu = 10;
58378c2ecf20Sopenharmony_ci			break;
58388c2ecf20Sopenharmony_ci		case 0x683B:
58398c2ecf20Sopenharmony_ci		case 0x683F:
58408c2ecf20Sopenharmony_ci		case 0x6829:
58418c2ecf20Sopenharmony_ci			si_pi->max_cu = 8;
58428c2ecf20Sopenharmony_ci			break;
58438c2ecf20Sopenharmony_ci		default:
58448c2ecf20Sopenharmony_ci			si_pi->max_cu = 0;
58458c2ecf20Sopenharmony_ci			break;
58468c2ecf20Sopenharmony_ci		}
58478c2ecf20Sopenharmony_ci	} else {
58488c2ecf20Sopenharmony_ci		si_pi->max_cu = 0;
58498c2ecf20Sopenharmony_ci	}
58508c2ecf20Sopenharmony_ci}
58518c2ecf20Sopenharmony_ci
58528c2ecf20Sopenharmony_cistatic int si_patch_single_dependency_table_based_on_leakage(struct radeon_device *rdev,
58538c2ecf20Sopenharmony_ci							     struct radeon_clock_voltage_dependency_table *table)
58548c2ecf20Sopenharmony_ci{
58558c2ecf20Sopenharmony_ci	u32 i;
58568c2ecf20Sopenharmony_ci	int j;
58578c2ecf20Sopenharmony_ci	u16 leakage_voltage;
58588c2ecf20Sopenharmony_ci
58598c2ecf20Sopenharmony_ci	if (table) {
58608c2ecf20Sopenharmony_ci		for (i = 0; i < table->count; i++) {
58618c2ecf20Sopenharmony_ci			switch (si_get_leakage_voltage_from_leakage_index(rdev,
58628c2ecf20Sopenharmony_ci									  table->entries[i].v,
58638c2ecf20Sopenharmony_ci									  &leakage_voltage)) {
58648c2ecf20Sopenharmony_ci			case 0:
58658c2ecf20Sopenharmony_ci				table->entries[i].v = leakage_voltage;
58668c2ecf20Sopenharmony_ci				break;
58678c2ecf20Sopenharmony_ci			case -EAGAIN:
58688c2ecf20Sopenharmony_ci				return -EINVAL;
58698c2ecf20Sopenharmony_ci			case -EINVAL:
58708c2ecf20Sopenharmony_ci			default:
58718c2ecf20Sopenharmony_ci				break;
58728c2ecf20Sopenharmony_ci			}
58738c2ecf20Sopenharmony_ci		}
58748c2ecf20Sopenharmony_ci
58758c2ecf20Sopenharmony_ci		for (j = (table->count - 2); j >= 0; j--) {
58768c2ecf20Sopenharmony_ci			table->entries[j].v = (table->entries[j].v <= table->entries[j + 1].v) ?
58778c2ecf20Sopenharmony_ci				table->entries[j].v : table->entries[j + 1].v;
58788c2ecf20Sopenharmony_ci		}
58798c2ecf20Sopenharmony_ci	}
58808c2ecf20Sopenharmony_ci	return 0;
58818c2ecf20Sopenharmony_ci}
58828c2ecf20Sopenharmony_ci
58838c2ecf20Sopenharmony_cistatic int si_patch_dependency_tables_based_on_leakage(struct radeon_device *rdev)
58848c2ecf20Sopenharmony_ci{
58858c2ecf20Sopenharmony_ci	int ret;
58868c2ecf20Sopenharmony_ci
58878c2ecf20Sopenharmony_ci	ret = si_patch_single_dependency_table_based_on_leakage(rdev,
58888c2ecf20Sopenharmony_ci								&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk);
58898c2ecf20Sopenharmony_ci	ret = si_patch_single_dependency_table_based_on_leakage(rdev,
58908c2ecf20Sopenharmony_ci								&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk);
58918c2ecf20Sopenharmony_ci	ret = si_patch_single_dependency_table_based_on_leakage(rdev,
58928c2ecf20Sopenharmony_ci								&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk);
58938c2ecf20Sopenharmony_ci	return ret;
58948c2ecf20Sopenharmony_ci}
58958c2ecf20Sopenharmony_ci
58968c2ecf20Sopenharmony_cistatic void si_set_pcie_lane_width_in_smc(struct radeon_device *rdev,
58978c2ecf20Sopenharmony_ci					  struct radeon_ps *radeon_new_state,
58988c2ecf20Sopenharmony_ci					  struct radeon_ps *radeon_current_state)
58998c2ecf20Sopenharmony_ci{
59008c2ecf20Sopenharmony_ci	u32 lane_width;
59018c2ecf20Sopenharmony_ci	u32 new_lane_width =
59028c2ecf20Sopenharmony_ci		((radeon_new_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
59038c2ecf20Sopenharmony_ci	u32 current_lane_width =
59048c2ecf20Sopenharmony_ci		((radeon_current_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
59058c2ecf20Sopenharmony_ci
59068c2ecf20Sopenharmony_ci	if (new_lane_width != current_lane_width) {
59078c2ecf20Sopenharmony_ci		radeon_set_pcie_lanes(rdev, new_lane_width);
59088c2ecf20Sopenharmony_ci		lane_width = radeon_get_pcie_lanes(rdev);
59098c2ecf20Sopenharmony_ci		si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
59108c2ecf20Sopenharmony_ci	}
59118c2ecf20Sopenharmony_ci}
59128c2ecf20Sopenharmony_ci
59138c2ecf20Sopenharmony_cistatic void si_set_vce_clock(struct radeon_device *rdev,
59148c2ecf20Sopenharmony_ci			     struct radeon_ps *new_rps,
59158c2ecf20Sopenharmony_ci			     struct radeon_ps *old_rps)
59168c2ecf20Sopenharmony_ci{
59178c2ecf20Sopenharmony_ci	if ((old_rps->evclk != new_rps->evclk) ||
59188c2ecf20Sopenharmony_ci	    (old_rps->ecclk != new_rps->ecclk)) {
59198c2ecf20Sopenharmony_ci		/* turn the clocks on when encoding, off otherwise */
59208c2ecf20Sopenharmony_ci		if (new_rps->evclk || new_rps->ecclk)
59218c2ecf20Sopenharmony_ci			vce_v1_0_enable_mgcg(rdev, false);
59228c2ecf20Sopenharmony_ci		else
59238c2ecf20Sopenharmony_ci			vce_v1_0_enable_mgcg(rdev, true);
59248c2ecf20Sopenharmony_ci		radeon_set_vce_clocks(rdev, new_rps->evclk, new_rps->ecclk);
59258c2ecf20Sopenharmony_ci	}
59268c2ecf20Sopenharmony_ci}
59278c2ecf20Sopenharmony_ci
59288c2ecf20Sopenharmony_civoid si_dpm_setup_asic(struct radeon_device *rdev)
59298c2ecf20Sopenharmony_ci{
59308c2ecf20Sopenharmony_ci	int r;
59318c2ecf20Sopenharmony_ci
59328c2ecf20Sopenharmony_ci	r = si_mc_load_microcode(rdev);
59338c2ecf20Sopenharmony_ci	if (r)
59348c2ecf20Sopenharmony_ci		DRM_ERROR("Failed to load MC firmware!\n");
59358c2ecf20Sopenharmony_ci	rv770_get_memory_type(rdev);
59368c2ecf20Sopenharmony_ci	si_read_clock_registers(rdev);
59378c2ecf20Sopenharmony_ci	si_enable_acpi_power_management(rdev);
59388c2ecf20Sopenharmony_ci}
59398c2ecf20Sopenharmony_ci
59408c2ecf20Sopenharmony_cistatic int si_thermal_enable_alert(struct radeon_device *rdev,
59418c2ecf20Sopenharmony_ci				   bool enable)
59428c2ecf20Sopenharmony_ci{
59438c2ecf20Sopenharmony_ci	u32 thermal_int = RREG32(CG_THERMAL_INT);
59448c2ecf20Sopenharmony_ci
59458c2ecf20Sopenharmony_ci	if (enable) {
59468c2ecf20Sopenharmony_ci		PPSMC_Result result;
59478c2ecf20Sopenharmony_ci
59488c2ecf20Sopenharmony_ci		thermal_int &= ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW);
59498c2ecf20Sopenharmony_ci		WREG32(CG_THERMAL_INT, thermal_int);
59508c2ecf20Sopenharmony_ci		rdev->irq.dpm_thermal = false;
59518c2ecf20Sopenharmony_ci		result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableThermalInterrupt);
59528c2ecf20Sopenharmony_ci		if (result != PPSMC_Result_OK) {
59538c2ecf20Sopenharmony_ci			DRM_DEBUG_KMS("Could not enable thermal interrupts.\n");
59548c2ecf20Sopenharmony_ci			return -EINVAL;
59558c2ecf20Sopenharmony_ci		}
59568c2ecf20Sopenharmony_ci	} else {
59578c2ecf20Sopenharmony_ci		thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW;
59588c2ecf20Sopenharmony_ci		WREG32(CG_THERMAL_INT, thermal_int);
59598c2ecf20Sopenharmony_ci		rdev->irq.dpm_thermal = true;
59608c2ecf20Sopenharmony_ci	}
59618c2ecf20Sopenharmony_ci
59628c2ecf20Sopenharmony_ci	return 0;
59638c2ecf20Sopenharmony_ci}
59648c2ecf20Sopenharmony_ci
59658c2ecf20Sopenharmony_cistatic int si_thermal_set_temperature_range(struct radeon_device *rdev,
59668c2ecf20Sopenharmony_ci					    int min_temp, int max_temp)
59678c2ecf20Sopenharmony_ci{
59688c2ecf20Sopenharmony_ci	int low_temp = 0 * 1000;
59698c2ecf20Sopenharmony_ci	int high_temp = 255 * 1000;
59708c2ecf20Sopenharmony_ci
59718c2ecf20Sopenharmony_ci	if (low_temp < min_temp)
59728c2ecf20Sopenharmony_ci		low_temp = min_temp;
59738c2ecf20Sopenharmony_ci	if (high_temp > max_temp)
59748c2ecf20Sopenharmony_ci		high_temp = max_temp;
59758c2ecf20Sopenharmony_ci	if (high_temp < low_temp) {
59768c2ecf20Sopenharmony_ci		DRM_ERROR("invalid thermal range: %d - %d\n", low_temp, high_temp);
59778c2ecf20Sopenharmony_ci		return -EINVAL;
59788c2ecf20Sopenharmony_ci	}
59798c2ecf20Sopenharmony_ci
59808c2ecf20Sopenharmony_ci	WREG32_P(CG_THERMAL_INT, DIG_THERM_INTH(high_temp / 1000), ~DIG_THERM_INTH_MASK);
59818c2ecf20Sopenharmony_ci	WREG32_P(CG_THERMAL_INT, DIG_THERM_INTL(low_temp / 1000), ~DIG_THERM_INTL_MASK);
59828c2ecf20Sopenharmony_ci	WREG32_P(CG_THERMAL_CTRL, DIG_THERM_DPM(high_temp / 1000), ~DIG_THERM_DPM_MASK);
59838c2ecf20Sopenharmony_ci
59848c2ecf20Sopenharmony_ci	rdev->pm.dpm.thermal.min_temp = low_temp;
59858c2ecf20Sopenharmony_ci	rdev->pm.dpm.thermal.max_temp = high_temp;
59868c2ecf20Sopenharmony_ci
59878c2ecf20Sopenharmony_ci	return 0;
59888c2ecf20Sopenharmony_ci}
59898c2ecf20Sopenharmony_ci
59908c2ecf20Sopenharmony_cistatic void si_fan_ctrl_set_static_mode(struct radeon_device *rdev, u32 mode)
59918c2ecf20Sopenharmony_ci{
59928c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
59938c2ecf20Sopenharmony_ci	u32 tmp;
59948c2ecf20Sopenharmony_ci
59958c2ecf20Sopenharmony_ci	if (si_pi->fan_ctrl_is_in_default_mode) {
59968c2ecf20Sopenharmony_ci		tmp = (RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK) >> FDO_PWM_MODE_SHIFT;
59978c2ecf20Sopenharmony_ci		si_pi->fan_ctrl_default_mode = tmp;
59988c2ecf20Sopenharmony_ci		tmp = (RREG32(CG_FDO_CTRL2) & TMIN_MASK) >> TMIN_SHIFT;
59998c2ecf20Sopenharmony_ci		si_pi->t_min = tmp;
60008c2ecf20Sopenharmony_ci		si_pi->fan_ctrl_is_in_default_mode = false;
60018c2ecf20Sopenharmony_ci	}
60028c2ecf20Sopenharmony_ci
60038c2ecf20Sopenharmony_ci	tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
60048c2ecf20Sopenharmony_ci	tmp |= TMIN(0);
60058c2ecf20Sopenharmony_ci	WREG32(CG_FDO_CTRL2, tmp);
60068c2ecf20Sopenharmony_ci
60078c2ecf20Sopenharmony_ci	tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
60088c2ecf20Sopenharmony_ci	tmp |= FDO_PWM_MODE(mode);
60098c2ecf20Sopenharmony_ci	WREG32(CG_FDO_CTRL2, tmp);
60108c2ecf20Sopenharmony_ci}
60118c2ecf20Sopenharmony_ci
60128c2ecf20Sopenharmony_cistatic int si_thermal_setup_fan_table(struct radeon_device *rdev)
60138c2ecf20Sopenharmony_ci{
60148c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
60158c2ecf20Sopenharmony_ci	PP_SIslands_FanTable fan_table = { FDO_MODE_HARDWARE };
60168c2ecf20Sopenharmony_ci	u32 duty100;
60178c2ecf20Sopenharmony_ci	u32 t_diff1, t_diff2, pwm_diff1, pwm_diff2;
60188c2ecf20Sopenharmony_ci	u16 fdo_min, slope1, slope2;
60198c2ecf20Sopenharmony_ci	u32 reference_clock, tmp;
60208c2ecf20Sopenharmony_ci	int ret;
60218c2ecf20Sopenharmony_ci	u64 tmp64;
60228c2ecf20Sopenharmony_ci
60238c2ecf20Sopenharmony_ci	if (!si_pi->fan_table_start) {
60248c2ecf20Sopenharmony_ci		rdev->pm.dpm.fan.ucode_fan_control = false;
60258c2ecf20Sopenharmony_ci		return 0;
60268c2ecf20Sopenharmony_ci	}
60278c2ecf20Sopenharmony_ci
60288c2ecf20Sopenharmony_ci	duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
60298c2ecf20Sopenharmony_ci
60308c2ecf20Sopenharmony_ci	if (duty100 == 0) {
60318c2ecf20Sopenharmony_ci		rdev->pm.dpm.fan.ucode_fan_control = false;
60328c2ecf20Sopenharmony_ci		return 0;
60338c2ecf20Sopenharmony_ci	}
60348c2ecf20Sopenharmony_ci
60358c2ecf20Sopenharmony_ci	tmp64 = (u64)rdev->pm.dpm.fan.pwm_min * duty100;
60368c2ecf20Sopenharmony_ci	do_div(tmp64, 10000);
60378c2ecf20Sopenharmony_ci	fdo_min = (u16)tmp64;
60388c2ecf20Sopenharmony_ci
60398c2ecf20Sopenharmony_ci	t_diff1 = rdev->pm.dpm.fan.t_med - rdev->pm.dpm.fan.t_min;
60408c2ecf20Sopenharmony_ci	t_diff2 = rdev->pm.dpm.fan.t_high - rdev->pm.dpm.fan.t_med;
60418c2ecf20Sopenharmony_ci
60428c2ecf20Sopenharmony_ci	pwm_diff1 = rdev->pm.dpm.fan.pwm_med - rdev->pm.dpm.fan.pwm_min;
60438c2ecf20Sopenharmony_ci	pwm_diff2 = rdev->pm.dpm.fan.pwm_high - rdev->pm.dpm.fan.pwm_med;
60448c2ecf20Sopenharmony_ci
60458c2ecf20Sopenharmony_ci	slope1 = (u16)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100);
60468c2ecf20Sopenharmony_ci	slope2 = (u16)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100);
60478c2ecf20Sopenharmony_ci
60488c2ecf20Sopenharmony_ci	fan_table.temp_min = cpu_to_be16((50 + rdev->pm.dpm.fan.t_min) / 100);
60498c2ecf20Sopenharmony_ci	fan_table.temp_med = cpu_to_be16((50 + rdev->pm.dpm.fan.t_med) / 100);
60508c2ecf20Sopenharmony_ci	fan_table.temp_max = cpu_to_be16((50 + rdev->pm.dpm.fan.t_max) / 100);
60518c2ecf20Sopenharmony_ci
60528c2ecf20Sopenharmony_ci	fan_table.slope1 = cpu_to_be16(slope1);
60538c2ecf20Sopenharmony_ci	fan_table.slope2 = cpu_to_be16(slope2);
60548c2ecf20Sopenharmony_ci
60558c2ecf20Sopenharmony_ci	fan_table.fdo_min = cpu_to_be16(fdo_min);
60568c2ecf20Sopenharmony_ci
60578c2ecf20Sopenharmony_ci	fan_table.hys_down = cpu_to_be16(rdev->pm.dpm.fan.t_hyst);
60588c2ecf20Sopenharmony_ci
60598c2ecf20Sopenharmony_ci	fan_table.hys_up = cpu_to_be16(1);
60608c2ecf20Sopenharmony_ci
60618c2ecf20Sopenharmony_ci	fan_table.hys_slope = cpu_to_be16(1);
60628c2ecf20Sopenharmony_ci
60638c2ecf20Sopenharmony_ci	fan_table.temp_resp_lim = cpu_to_be16(5);
60648c2ecf20Sopenharmony_ci
60658c2ecf20Sopenharmony_ci	reference_clock = radeon_get_xclk(rdev);
60668c2ecf20Sopenharmony_ci
60678c2ecf20Sopenharmony_ci	fan_table.refresh_period = cpu_to_be32((rdev->pm.dpm.fan.cycle_delay *
60688c2ecf20Sopenharmony_ci						reference_clock) / 1600);
60698c2ecf20Sopenharmony_ci
60708c2ecf20Sopenharmony_ci	fan_table.fdo_max = cpu_to_be16((u16)duty100);
60718c2ecf20Sopenharmony_ci
60728c2ecf20Sopenharmony_ci	tmp = (RREG32(CG_MULT_THERMAL_CTRL) & TEMP_SEL_MASK) >> TEMP_SEL_SHIFT;
60738c2ecf20Sopenharmony_ci	fan_table.temp_src = (uint8_t)tmp;
60748c2ecf20Sopenharmony_ci
60758c2ecf20Sopenharmony_ci	ret = si_copy_bytes_to_smc(rdev,
60768c2ecf20Sopenharmony_ci				   si_pi->fan_table_start,
60778c2ecf20Sopenharmony_ci				   (u8 *)(&fan_table),
60788c2ecf20Sopenharmony_ci				   sizeof(fan_table),
60798c2ecf20Sopenharmony_ci				   si_pi->sram_end);
60808c2ecf20Sopenharmony_ci
60818c2ecf20Sopenharmony_ci	if (ret) {
60828c2ecf20Sopenharmony_ci		DRM_ERROR("Failed to load fan table to the SMC.");
60838c2ecf20Sopenharmony_ci		rdev->pm.dpm.fan.ucode_fan_control = false;
60848c2ecf20Sopenharmony_ci	}
60858c2ecf20Sopenharmony_ci
60868c2ecf20Sopenharmony_ci	return 0;
60878c2ecf20Sopenharmony_ci}
60888c2ecf20Sopenharmony_ci
60898c2ecf20Sopenharmony_cistatic int si_fan_ctrl_start_smc_fan_control(struct radeon_device *rdev)
60908c2ecf20Sopenharmony_ci{
60918c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
60928c2ecf20Sopenharmony_ci	PPSMC_Result ret;
60938c2ecf20Sopenharmony_ci
60948c2ecf20Sopenharmony_ci	ret = si_send_msg_to_smc(rdev, PPSMC_StartFanControl);
60958c2ecf20Sopenharmony_ci	if (ret == PPSMC_Result_OK) {
60968c2ecf20Sopenharmony_ci		si_pi->fan_is_controlled_by_smc = true;
60978c2ecf20Sopenharmony_ci		return 0;
60988c2ecf20Sopenharmony_ci	} else {
60998c2ecf20Sopenharmony_ci		return -EINVAL;
61008c2ecf20Sopenharmony_ci	}
61018c2ecf20Sopenharmony_ci}
61028c2ecf20Sopenharmony_ci
61038c2ecf20Sopenharmony_cistatic int si_fan_ctrl_stop_smc_fan_control(struct radeon_device *rdev)
61048c2ecf20Sopenharmony_ci{
61058c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
61068c2ecf20Sopenharmony_ci	PPSMC_Result ret;
61078c2ecf20Sopenharmony_ci
61088c2ecf20Sopenharmony_ci	ret = si_send_msg_to_smc(rdev, PPSMC_StopFanControl);
61098c2ecf20Sopenharmony_ci
61108c2ecf20Sopenharmony_ci	if (ret == PPSMC_Result_OK) {
61118c2ecf20Sopenharmony_ci		si_pi->fan_is_controlled_by_smc = false;
61128c2ecf20Sopenharmony_ci		return 0;
61138c2ecf20Sopenharmony_ci	} else {
61148c2ecf20Sopenharmony_ci		return -EINVAL;
61158c2ecf20Sopenharmony_ci	}
61168c2ecf20Sopenharmony_ci}
61178c2ecf20Sopenharmony_ci
61188c2ecf20Sopenharmony_ciint si_fan_ctrl_get_fan_speed_percent(struct radeon_device *rdev,
61198c2ecf20Sopenharmony_ci				      u32 *speed)
61208c2ecf20Sopenharmony_ci{
61218c2ecf20Sopenharmony_ci	u32 duty, duty100;
61228c2ecf20Sopenharmony_ci	u64 tmp64;
61238c2ecf20Sopenharmony_ci
61248c2ecf20Sopenharmony_ci	if (rdev->pm.no_fan)
61258c2ecf20Sopenharmony_ci		return -ENOENT;
61268c2ecf20Sopenharmony_ci
61278c2ecf20Sopenharmony_ci	duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
61288c2ecf20Sopenharmony_ci	duty = (RREG32(CG_THERMAL_STATUS) & FDO_PWM_DUTY_MASK) >> FDO_PWM_DUTY_SHIFT;
61298c2ecf20Sopenharmony_ci
61308c2ecf20Sopenharmony_ci	if (duty100 == 0)
61318c2ecf20Sopenharmony_ci		return -EINVAL;
61328c2ecf20Sopenharmony_ci
61338c2ecf20Sopenharmony_ci	tmp64 = (u64)duty * 100;
61348c2ecf20Sopenharmony_ci	do_div(tmp64, duty100);
61358c2ecf20Sopenharmony_ci	*speed = (u32)tmp64;
61368c2ecf20Sopenharmony_ci
61378c2ecf20Sopenharmony_ci	if (*speed > 100)
61388c2ecf20Sopenharmony_ci		*speed = 100;
61398c2ecf20Sopenharmony_ci
61408c2ecf20Sopenharmony_ci	return 0;
61418c2ecf20Sopenharmony_ci}
61428c2ecf20Sopenharmony_ci
61438c2ecf20Sopenharmony_ciint si_fan_ctrl_set_fan_speed_percent(struct radeon_device *rdev,
61448c2ecf20Sopenharmony_ci				      u32 speed)
61458c2ecf20Sopenharmony_ci{
61468c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
61478c2ecf20Sopenharmony_ci	u32 tmp;
61488c2ecf20Sopenharmony_ci	u32 duty, duty100;
61498c2ecf20Sopenharmony_ci	u64 tmp64;
61508c2ecf20Sopenharmony_ci
61518c2ecf20Sopenharmony_ci	if (rdev->pm.no_fan)
61528c2ecf20Sopenharmony_ci		return -ENOENT;
61538c2ecf20Sopenharmony_ci
61548c2ecf20Sopenharmony_ci	if (si_pi->fan_is_controlled_by_smc)
61558c2ecf20Sopenharmony_ci		return -EINVAL;
61568c2ecf20Sopenharmony_ci
61578c2ecf20Sopenharmony_ci	if (speed > 100)
61588c2ecf20Sopenharmony_ci		return -EINVAL;
61598c2ecf20Sopenharmony_ci
61608c2ecf20Sopenharmony_ci	duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
61618c2ecf20Sopenharmony_ci
61628c2ecf20Sopenharmony_ci	if (duty100 == 0)
61638c2ecf20Sopenharmony_ci		return -EINVAL;
61648c2ecf20Sopenharmony_ci
61658c2ecf20Sopenharmony_ci	tmp64 = (u64)speed * duty100;
61668c2ecf20Sopenharmony_ci	do_div(tmp64, 100);
61678c2ecf20Sopenharmony_ci	duty = (u32)tmp64;
61688c2ecf20Sopenharmony_ci
61698c2ecf20Sopenharmony_ci	tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK;
61708c2ecf20Sopenharmony_ci	tmp |= FDO_STATIC_DUTY(duty);
61718c2ecf20Sopenharmony_ci	WREG32(CG_FDO_CTRL0, tmp);
61728c2ecf20Sopenharmony_ci
61738c2ecf20Sopenharmony_ci	return 0;
61748c2ecf20Sopenharmony_ci}
61758c2ecf20Sopenharmony_ci
61768c2ecf20Sopenharmony_civoid si_fan_ctrl_set_mode(struct radeon_device *rdev, u32 mode)
61778c2ecf20Sopenharmony_ci{
61788c2ecf20Sopenharmony_ci	if (mode) {
61798c2ecf20Sopenharmony_ci		/* stop auto-manage */
61808c2ecf20Sopenharmony_ci		if (rdev->pm.dpm.fan.ucode_fan_control)
61818c2ecf20Sopenharmony_ci			si_fan_ctrl_stop_smc_fan_control(rdev);
61828c2ecf20Sopenharmony_ci		si_fan_ctrl_set_static_mode(rdev, mode);
61838c2ecf20Sopenharmony_ci	} else {
61848c2ecf20Sopenharmony_ci		/* restart auto-manage */
61858c2ecf20Sopenharmony_ci		if (rdev->pm.dpm.fan.ucode_fan_control)
61868c2ecf20Sopenharmony_ci			si_thermal_start_smc_fan_control(rdev);
61878c2ecf20Sopenharmony_ci		else
61888c2ecf20Sopenharmony_ci			si_fan_ctrl_set_default_mode(rdev);
61898c2ecf20Sopenharmony_ci	}
61908c2ecf20Sopenharmony_ci}
61918c2ecf20Sopenharmony_ci
61928c2ecf20Sopenharmony_ciu32 si_fan_ctrl_get_mode(struct radeon_device *rdev)
61938c2ecf20Sopenharmony_ci{
61948c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
61958c2ecf20Sopenharmony_ci	u32 tmp;
61968c2ecf20Sopenharmony_ci
61978c2ecf20Sopenharmony_ci	if (si_pi->fan_is_controlled_by_smc)
61988c2ecf20Sopenharmony_ci		return 0;
61998c2ecf20Sopenharmony_ci
62008c2ecf20Sopenharmony_ci	tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;
62018c2ecf20Sopenharmony_ci	return (tmp >> FDO_PWM_MODE_SHIFT);
62028c2ecf20Sopenharmony_ci}
62038c2ecf20Sopenharmony_ci
62048c2ecf20Sopenharmony_ci#if 0
62058c2ecf20Sopenharmony_cistatic int si_fan_ctrl_get_fan_speed_rpm(struct radeon_device *rdev,
62068c2ecf20Sopenharmony_ci					 u32 *speed)
62078c2ecf20Sopenharmony_ci{
62088c2ecf20Sopenharmony_ci	u32 tach_period;
62098c2ecf20Sopenharmony_ci	u32 xclk = radeon_get_xclk(rdev);
62108c2ecf20Sopenharmony_ci
62118c2ecf20Sopenharmony_ci	if (rdev->pm.no_fan)
62128c2ecf20Sopenharmony_ci		return -ENOENT;
62138c2ecf20Sopenharmony_ci
62148c2ecf20Sopenharmony_ci	if (rdev->pm.fan_pulses_per_revolution == 0)
62158c2ecf20Sopenharmony_ci		return -ENOENT;
62168c2ecf20Sopenharmony_ci
62178c2ecf20Sopenharmony_ci	tach_period = (RREG32(CG_TACH_STATUS) & TACH_PERIOD_MASK) >> TACH_PERIOD_SHIFT;
62188c2ecf20Sopenharmony_ci	if (tach_period == 0)
62198c2ecf20Sopenharmony_ci		return -ENOENT;
62208c2ecf20Sopenharmony_ci
62218c2ecf20Sopenharmony_ci	*speed = 60 * xclk * 10000 / tach_period;
62228c2ecf20Sopenharmony_ci
62238c2ecf20Sopenharmony_ci	return 0;
62248c2ecf20Sopenharmony_ci}
62258c2ecf20Sopenharmony_ci
62268c2ecf20Sopenharmony_cistatic int si_fan_ctrl_set_fan_speed_rpm(struct radeon_device *rdev,
62278c2ecf20Sopenharmony_ci					 u32 speed)
62288c2ecf20Sopenharmony_ci{
62298c2ecf20Sopenharmony_ci	u32 tach_period, tmp;
62308c2ecf20Sopenharmony_ci	u32 xclk = radeon_get_xclk(rdev);
62318c2ecf20Sopenharmony_ci
62328c2ecf20Sopenharmony_ci	if (rdev->pm.no_fan)
62338c2ecf20Sopenharmony_ci		return -ENOENT;
62348c2ecf20Sopenharmony_ci
62358c2ecf20Sopenharmony_ci	if (rdev->pm.fan_pulses_per_revolution == 0)
62368c2ecf20Sopenharmony_ci		return -ENOENT;
62378c2ecf20Sopenharmony_ci
62388c2ecf20Sopenharmony_ci	if ((speed < rdev->pm.fan_min_rpm) ||
62398c2ecf20Sopenharmony_ci	    (speed > rdev->pm.fan_max_rpm))
62408c2ecf20Sopenharmony_ci		return -EINVAL;
62418c2ecf20Sopenharmony_ci
62428c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.fan.ucode_fan_control)
62438c2ecf20Sopenharmony_ci		si_fan_ctrl_stop_smc_fan_control(rdev);
62448c2ecf20Sopenharmony_ci
62458c2ecf20Sopenharmony_ci	tach_period = 60 * xclk * 10000 / (8 * speed);
62468c2ecf20Sopenharmony_ci	tmp = RREG32(CG_TACH_CTRL) & ~TARGET_PERIOD_MASK;
62478c2ecf20Sopenharmony_ci	tmp |= TARGET_PERIOD(tach_period);
62488c2ecf20Sopenharmony_ci	WREG32(CG_TACH_CTRL, tmp);
62498c2ecf20Sopenharmony_ci
62508c2ecf20Sopenharmony_ci	si_fan_ctrl_set_static_mode(rdev, FDO_PWM_MODE_STATIC_RPM);
62518c2ecf20Sopenharmony_ci
62528c2ecf20Sopenharmony_ci	return 0;
62538c2ecf20Sopenharmony_ci}
62548c2ecf20Sopenharmony_ci#endif
62558c2ecf20Sopenharmony_ci
62568c2ecf20Sopenharmony_cistatic void si_fan_ctrl_set_default_mode(struct radeon_device *rdev)
62578c2ecf20Sopenharmony_ci{
62588c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
62598c2ecf20Sopenharmony_ci	u32 tmp;
62608c2ecf20Sopenharmony_ci
62618c2ecf20Sopenharmony_ci	if (!si_pi->fan_ctrl_is_in_default_mode) {
62628c2ecf20Sopenharmony_ci		tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
62638c2ecf20Sopenharmony_ci		tmp |= FDO_PWM_MODE(si_pi->fan_ctrl_default_mode);
62648c2ecf20Sopenharmony_ci		WREG32(CG_FDO_CTRL2, tmp);
62658c2ecf20Sopenharmony_ci
62668c2ecf20Sopenharmony_ci		tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
62678c2ecf20Sopenharmony_ci		tmp |= TMIN(si_pi->t_min);
62688c2ecf20Sopenharmony_ci		WREG32(CG_FDO_CTRL2, tmp);
62698c2ecf20Sopenharmony_ci		si_pi->fan_ctrl_is_in_default_mode = true;
62708c2ecf20Sopenharmony_ci	}
62718c2ecf20Sopenharmony_ci}
62728c2ecf20Sopenharmony_ci
62738c2ecf20Sopenharmony_cistatic void si_thermal_start_smc_fan_control(struct radeon_device *rdev)
62748c2ecf20Sopenharmony_ci{
62758c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.fan.ucode_fan_control) {
62768c2ecf20Sopenharmony_ci		si_fan_ctrl_start_smc_fan_control(rdev);
62778c2ecf20Sopenharmony_ci		si_fan_ctrl_set_static_mode(rdev, FDO_PWM_MODE_STATIC);
62788c2ecf20Sopenharmony_ci	}
62798c2ecf20Sopenharmony_ci}
62808c2ecf20Sopenharmony_ci
62818c2ecf20Sopenharmony_cistatic void si_thermal_initialize(struct radeon_device *rdev)
62828c2ecf20Sopenharmony_ci{
62838c2ecf20Sopenharmony_ci	u32 tmp;
62848c2ecf20Sopenharmony_ci
62858c2ecf20Sopenharmony_ci	if (rdev->pm.fan_pulses_per_revolution) {
62868c2ecf20Sopenharmony_ci		tmp = RREG32(CG_TACH_CTRL) & ~EDGE_PER_REV_MASK;
62878c2ecf20Sopenharmony_ci		tmp |= EDGE_PER_REV(rdev->pm.fan_pulses_per_revolution -1);
62888c2ecf20Sopenharmony_ci		WREG32(CG_TACH_CTRL, tmp);
62898c2ecf20Sopenharmony_ci	}
62908c2ecf20Sopenharmony_ci
62918c2ecf20Sopenharmony_ci	tmp = RREG32(CG_FDO_CTRL2) & ~TACH_PWM_RESP_RATE_MASK;
62928c2ecf20Sopenharmony_ci	tmp |= TACH_PWM_RESP_RATE(0x28);
62938c2ecf20Sopenharmony_ci	WREG32(CG_FDO_CTRL2, tmp);
62948c2ecf20Sopenharmony_ci}
62958c2ecf20Sopenharmony_ci
62968c2ecf20Sopenharmony_cistatic int si_thermal_start_thermal_controller(struct radeon_device *rdev)
62978c2ecf20Sopenharmony_ci{
62988c2ecf20Sopenharmony_ci	int ret;
62998c2ecf20Sopenharmony_ci
63008c2ecf20Sopenharmony_ci	si_thermal_initialize(rdev);
63018c2ecf20Sopenharmony_ci	ret = si_thermal_set_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
63028c2ecf20Sopenharmony_ci	if (ret)
63038c2ecf20Sopenharmony_ci		return ret;
63048c2ecf20Sopenharmony_ci	ret = si_thermal_enable_alert(rdev, true);
63058c2ecf20Sopenharmony_ci	if (ret)
63068c2ecf20Sopenharmony_ci		return ret;
63078c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.fan.ucode_fan_control) {
63088c2ecf20Sopenharmony_ci		ret = si_halt_smc(rdev);
63098c2ecf20Sopenharmony_ci		if (ret)
63108c2ecf20Sopenharmony_ci			return ret;
63118c2ecf20Sopenharmony_ci		ret = si_thermal_setup_fan_table(rdev);
63128c2ecf20Sopenharmony_ci		if (ret)
63138c2ecf20Sopenharmony_ci			return ret;
63148c2ecf20Sopenharmony_ci		ret = si_resume_smc(rdev);
63158c2ecf20Sopenharmony_ci		if (ret)
63168c2ecf20Sopenharmony_ci			return ret;
63178c2ecf20Sopenharmony_ci		si_thermal_start_smc_fan_control(rdev);
63188c2ecf20Sopenharmony_ci	}
63198c2ecf20Sopenharmony_ci
63208c2ecf20Sopenharmony_ci	return 0;
63218c2ecf20Sopenharmony_ci}
63228c2ecf20Sopenharmony_ci
63238c2ecf20Sopenharmony_cistatic void si_thermal_stop_thermal_controller(struct radeon_device *rdev)
63248c2ecf20Sopenharmony_ci{
63258c2ecf20Sopenharmony_ci	if (!rdev->pm.no_fan) {
63268c2ecf20Sopenharmony_ci		si_fan_ctrl_set_default_mode(rdev);
63278c2ecf20Sopenharmony_ci		si_fan_ctrl_stop_smc_fan_control(rdev);
63288c2ecf20Sopenharmony_ci	}
63298c2ecf20Sopenharmony_ci}
63308c2ecf20Sopenharmony_ci
63318c2ecf20Sopenharmony_ciint si_dpm_enable(struct radeon_device *rdev)
63328c2ecf20Sopenharmony_ci{
63338c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
63348c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
63358c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
63368c2ecf20Sopenharmony_ci	struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
63378c2ecf20Sopenharmony_ci	int ret;
63388c2ecf20Sopenharmony_ci
63398c2ecf20Sopenharmony_ci	if (si_is_smc_running(rdev))
63408c2ecf20Sopenharmony_ci		return -EINVAL;
63418c2ecf20Sopenharmony_ci	if (pi->voltage_control || si_pi->voltage_control_svi2)
63428c2ecf20Sopenharmony_ci		si_enable_voltage_control(rdev, true);
63438c2ecf20Sopenharmony_ci	if (pi->mvdd_control)
63448c2ecf20Sopenharmony_ci		si_get_mvdd_configuration(rdev);
63458c2ecf20Sopenharmony_ci	if (pi->voltage_control || si_pi->voltage_control_svi2) {
63468c2ecf20Sopenharmony_ci		ret = si_construct_voltage_tables(rdev);
63478c2ecf20Sopenharmony_ci		if (ret) {
63488c2ecf20Sopenharmony_ci			DRM_ERROR("si_construct_voltage_tables failed\n");
63498c2ecf20Sopenharmony_ci			return ret;
63508c2ecf20Sopenharmony_ci		}
63518c2ecf20Sopenharmony_ci	}
63528c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing) {
63538c2ecf20Sopenharmony_ci		ret = si_initialize_mc_reg_table(rdev);
63548c2ecf20Sopenharmony_ci		if (ret)
63558c2ecf20Sopenharmony_ci			eg_pi->dynamic_ac_timing = false;
63568c2ecf20Sopenharmony_ci	}
63578c2ecf20Sopenharmony_ci	if (pi->dynamic_ss)
63588c2ecf20Sopenharmony_ci		si_enable_spread_spectrum(rdev, true);
63598c2ecf20Sopenharmony_ci	if (pi->thermal_protection)
63608c2ecf20Sopenharmony_ci		si_enable_thermal_protection(rdev, true);
63618c2ecf20Sopenharmony_ci	si_setup_bsp(rdev);
63628c2ecf20Sopenharmony_ci	si_program_git(rdev);
63638c2ecf20Sopenharmony_ci	si_program_tp(rdev);
63648c2ecf20Sopenharmony_ci	si_program_tpp(rdev);
63658c2ecf20Sopenharmony_ci	si_program_sstp(rdev);
63668c2ecf20Sopenharmony_ci	si_enable_display_gap(rdev);
63678c2ecf20Sopenharmony_ci	si_program_vc(rdev);
63688c2ecf20Sopenharmony_ci	ret = si_upload_firmware(rdev);
63698c2ecf20Sopenharmony_ci	if (ret) {
63708c2ecf20Sopenharmony_ci		DRM_ERROR("si_upload_firmware failed\n");
63718c2ecf20Sopenharmony_ci		return ret;
63728c2ecf20Sopenharmony_ci	}
63738c2ecf20Sopenharmony_ci	ret = si_process_firmware_header(rdev);
63748c2ecf20Sopenharmony_ci	if (ret) {
63758c2ecf20Sopenharmony_ci		DRM_ERROR("si_process_firmware_header failed\n");
63768c2ecf20Sopenharmony_ci		return ret;
63778c2ecf20Sopenharmony_ci	}
63788c2ecf20Sopenharmony_ci	ret = si_initial_switch_from_arb_f0_to_f1(rdev);
63798c2ecf20Sopenharmony_ci	if (ret) {
63808c2ecf20Sopenharmony_ci		DRM_ERROR("si_initial_switch_from_arb_f0_to_f1 failed\n");
63818c2ecf20Sopenharmony_ci		return ret;
63828c2ecf20Sopenharmony_ci	}
63838c2ecf20Sopenharmony_ci	ret = si_init_smc_table(rdev);
63848c2ecf20Sopenharmony_ci	if (ret) {
63858c2ecf20Sopenharmony_ci		DRM_ERROR("si_init_smc_table failed\n");
63868c2ecf20Sopenharmony_ci		return ret;
63878c2ecf20Sopenharmony_ci	}
63888c2ecf20Sopenharmony_ci	ret = si_init_smc_spll_table(rdev);
63898c2ecf20Sopenharmony_ci	if (ret) {
63908c2ecf20Sopenharmony_ci		DRM_ERROR("si_init_smc_spll_table failed\n");
63918c2ecf20Sopenharmony_ci		return ret;
63928c2ecf20Sopenharmony_ci	}
63938c2ecf20Sopenharmony_ci	ret = si_init_arb_table_index(rdev);
63948c2ecf20Sopenharmony_ci	if (ret) {
63958c2ecf20Sopenharmony_ci		DRM_ERROR("si_init_arb_table_index failed\n");
63968c2ecf20Sopenharmony_ci		return ret;
63978c2ecf20Sopenharmony_ci	}
63988c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing) {
63998c2ecf20Sopenharmony_ci		ret = si_populate_mc_reg_table(rdev, boot_ps);
64008c2ecf20Sopenharmony_ci		if (ret) {
64018c2ecf20Sopenharmony_ci			DRM_ERROR("si_populate_mc_reg_table failed\n");
64028c2ecf20Sopenharmony_ci			return ret;
64038c2ecf20Sopenharmony_ci		}
64048c2ecf20Sopenharmony_ci	}
64058c2ecf20Sopenharmony_ci	ret = si_initialize_smc_cac_tables(rdev);
64068c2ecf20Sopenharmony_ci	if (ret) {
64078c2ecf20Sopenharmony_ci		DRM_ERROR("si_initialize_smc_cac_tables failed\n");
64088c2ecf20Sopenharmony_ci		return ret;
64098c2ecf20Sopenharmony_ci	}
64108c2ecf20Sopenharmony_ci	ret = si_initialize_hardware_cac_manager(rdev);
64118c2ecf20Sopenharmony_ci	if (ret) {
64128c2ecf20Sopenharmony_ci		DRM_ERROR("si_initialize_hardware_cac_manager failed\n");
64138c2ecf20Sopenharmony_ci		return ret;
64148c2ecf20Sopenharmony_ci	}
64158c2ecf20Sopenharmony_ci	ret = si_initialize_smc_dte_tables(rdev);
64168c2ecf20Sopenharmony_ci	if (ret) {
64178c2ecf20Sopenharmony_ci		DRM_ERROR("si_initialize_smc_dte_tables failed\n");
64188c2ecf20Sopenharmony_ci		return ret;
64198c2ecf20Sopenharmony_ci	}
64208c2ecf20Sopenharmony_ci	ret = si_populate_smc_tdp_limits(rdev, boot_ps);
64218c2ecf20Sopenharmony_ci	if (ret) {
64228c2ecf20Sopenharmony_ci		DRM_ERROR("si_populate_smc_tdp_limits failed\n");
64238c2ecf20Sopenharmony_ci		return ret;
64248c2ecf20Sopenharmony_ci	}
64258c2ecf20Sopenharmony_ci	ret = si_populate_smc_tdp_limits_2(rdev, boot_ps);
64268c2ecf20Sopenharmony_ci	if (ret) {
64278c2ecf20Sopenharmony_ci		DRM_ERROR("si_populate_smc_tdp_limits_2 failed\n");
64288c2ecf20Sopenharmony_ci		return ret;
64298c2ecf20Sopenharmony_ci	}
64308c2ecf20Sopenharmony_ci	si_program_response_times(rdev);
64318c2ecf20Sopenharmony_ci	si_program_ds_registers(rdev);
64328c2ecf20Sopenharmony_ci	si_dpm_start_smc(rdev);
64338c2ecf20Sopenharmony_ci	ret = si_notify_smc_display_change(rdev, false);
64348c2ecf20Sopenharmony_ci	if (ret) {
64358c2ecf20Sopenharmony_ci		DRM_ERROR("si_notify_smc_display_change failed\n");
64368c2ecf20Sopenharmony_ci		return ret;
64378c2ecf20Sopenharmony_ci	}
64388c2ecf20Sopenharmony_ci	si_enable_sclk_control(rdev, true);
64398c2ecf20Sopenharmony_ci	si_start_dpm(rdev);
64408c2ecf20Sopenharmony_ci
64418c2ecf20Sopenharmony_ci	si_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
64428c2ecf20Sopenharmony_ci
64438c2ecf20Sopenharmony_ci	si_thermal_start_thermal_controller(rdev);
64448c2ecf20Sopenharmony_ci
64458c2ecf20Sopenharmony_ci	ni_update_current_ps(rdev, boot_ps);
64468c2ecf20Sopenharmony_ci
64478c2ecf20Sopenharmony_ci	return 0;
64488c2ecf20Sopenharmony_ci}
64498c2ecf20Sopenharmony_ci
64508c2ecf20Sopenharmony_cistatic int si_set_temperature_range(struct radeon_device *rdev)
64518c2ecf20Sopenharmony_ci{
64528c2ecf20Sopenharmony_ci	int ret;
64538c2ecf20Sopenharmony_ci
64548c2ecf20Sopenharmony_ci	ret = si_thermal_enable_alert(rdev, false);
64558c2ecf20Sopenharmony_ci	if (ret)
64568c2ecf20Sopenharmony_ci		return ret;
64578c2ecf20Sopenharmony_ci	ret = si_thermal_set_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
64588c2ecf20Sopenharmony_ci	if (ret)
64598c2ecf20Sopenharmony_ci		return ret;
64608c2ecf20Sopenharmony_ci	ret = si_thermal_enable_alert(rdev, true);
64618c2ecf20Sopenharmony_ci	if (ret)
64628c2ecf20Sopenharmony_ci		return ret;
64638c2ecf20Sopenharmony_ci
64648c2ecf20Sopenharmony_ci	return ret;
64658c2ecf20Sopenharmony_ci}
64668c2ecf20Sopenharmony_ci
64678c2ecf20Sopenharmony_ciint si_dpm_late_enable(struct radeon_device *rdev)
64688c2ecf20Sopenharmony_ci{
64698c2ecf20Sopenharmony_ci	int ret;
64708c2ecf20Sopenharmony_ci
64718c2ecf20Sopenharmony_ci	ret = si_set_temperature_range(rdev);
64728c2ecf20Sopenharmony_ci	if (ret)
64738c2ecf20Sopenharmony_ci		return ret;
64748c2ecf20Sopenharmony_ci
64758c2ecf20Sopenharmony_ci	return ret;
64768c2ecf20Sopenharmony_ci}
64778c2ecf20Sopenharmony_ci
64788c2ecf20Sopenharmony_civoid si_dpm_disable(struct radeon_device *rdev)
64798c2ecf20Sopenharmony_ci{
64808c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
64818c2ecf20Sopenharmony_ci	struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
64828c2ecf20Sopenharmony_ci
64838c2ecf20Sopenharmony_ci	if (!si_is_smc_running(rdev))
64848c2ecf20Sopenharmony_ci		return;
64858c2ecf20Sopenharmony_ci	si_thermal_stop_thermal_controller(rdev);
64868c2ecf20Sopenharmony_ci	si_disable_ulv(rdev);
64878c2ecf20Sopenharmony_ci	si_clear_vc(rdev);
64888c2ecf20Sopenharmony_ci	if (pi->thermal_protection)
64898c2ecf20Sopenharmony_ci		si_enable_thermal_protection(rdev, false);
64908c2ecf20Sopenharmony_ci	si_enable_power_containment(rdev, boot_ps, false);
64918c2ecf20Sopenharmony_ci	si_enable_smc_cac(rdev, boot_ps, false);
64928c2ecf20Sopenharmony_ci	si_enable_spread_spectrum(rdev, false);
64938c2ecf20Sopenharmony_ci	si_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, false);
64948c2ecf20Sopenharmony_ci	si_stop_dpm(rdev);
64958c2ecf20Sopenharmony_ci	si_reset_to_default(rdev);
64968c2ecf20Sopenharmony_ci	si_dpm_stop_smc(rdev);
64978c2ecf20Sopenharmony_ci	si_force_switch_to_arb_f0(rdev);
64988c2ecf20Sopenharmony_ci
64998c2ecf20Sopenharmony_ci	ni_update_current_ps(rdev, boot_ps);
65008c2ecf20Sopenharmony_ci}
65018c2ecf20Sopenharmony_ci
65028c2ecf20Sopenharmony_ciint si_dpm_pre_set_power_state(struct radeon_device *rdev)
65038c2ecf20Sopenharmony_ci{
65048c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
65058c2ecf20Sopenharmony_ci	struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps;
65068c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = &requested_ps;
65078c2ecf20Sopenharmony_ci
65088c2ecf20Sopenharmony_ci	ni_update_requested_ps(rdev, new_ps);
65098c2ecf20Sopenharmony_ci
65108c2ecf20Sopenharmony_ci	si_apply_state_adjust_rules(rdev, &eg_pi->requested_rps);
65118c2ecf20Sopenharmony_ci
65128c2ecf20Sopenharmony_ci	return 0;
65138c2ecf20Sopenharmony_ci}
65148c2ecf20Sopenharmony_ci
65158c2ecf20Sopenharmony_cistatic int si_power_control_set_level(struct radeon_device *rdev)
65168c2ecf20Sopenharmony_ci{
65178c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps;
65188c2ecf20Sopenharmony_ci	int ret;
65198c2ecf20Sopenharmony_ci
65208c2ecf20Sopenharmony_ci	ret = si_restrict_performance_levels_before_switch(rdev);
65218c2ecf20Sopenharmony_ci	if (ret)
65228c2ecf20Sopenharmony_ci		return ret;
65238c2ecf20Sopenharmony_ci	ret = si_halt_smc(rdev);
65248c2ecf20Sopenharmony_ci	if (ret)
65258c2ecf20Sopenharmony_ci		return ret;
65268c2ecf20Sopenharmony_ci	ret = si_populate_smc_tdp_limits(rdev, new_ps);
65278c2ecf20Sopenharmony_ci	if (ret)
65288c2ecf20Sopenharmony_ci		return ret;
65298c2ecf20Sopenharmony_ci	ret = si_populate_smc_tdp_limits_2(rdev, new_ps);
65308c2ecf20Sopenharmony_ci	if (ret)
65318c2ecf20Sopenharmony_ci		return ret;
65328c2ecf20Sopenharmony_ci	ret = si_resume_smc(rdev);
65338c2ecf20Sopenharmony_ci	if (ret)
65348c2ecf20Sopenharmony_ci		return ret;
65358c2ecf20Sopenharmony_ci	ret = si_set_sw_state(rdev);
65368c2ecf20Sopenharmony_ci	if (ret)
65378c2ecf20Sopenharmony_ci		return ret;
65388c2ecf20Sopenharmony_ci	return 0;
65398c2ecf20Sopenharmony_ci}
65408c2ecf20Sopenharmony_ci
65418c2ecf20Sopenharmony_ciint si_dpm_set_power_state(struct radeon_device *rdev)
65428c2ecf20Sopenharmony_ci{
65438c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
65448c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = &eg_pi->requested_rps;
65458c2ecf20Sopenharmony_ci	struct radeon_ps *old_ps = &eg_pi->current_rps;
65468c2ecf20Sopenharmony_ci	int ret;
65478c2ecf20Sopenharmony_ci
65488c2ecf20Sopenharmony_ci	ret = si_disable_ulv(rdev);
65498c2ecf20Sopenharmony_ci	if (ret) {
65508c2ecf20Sopenharmony_ci		DRM_ERROR("si_disable_ulv failed\n");
65518c2ecf20Sopenharmony_ci		return ret;
65528c2ecf20Sopenharmony_ci	}
65538c2ecf20Sopenharmony_ci	ret = si_restrict_performance_levels_before_switch(rdev);
65548c2ecf20Sopenharmony_ci	if (ret) {
65558c2ecf20Sopenharmony_ci		DRM_ERROR("si_restrict_performance_levels_before_switch failed\n");
65568c2ecf20Sopenharmony_ci		return ret;
65578c2ecf20Sopenharmony_ci	}
65588c2ecf20Sopenharmony_ci	if (eg_pi->pcie_performance_request)
65598c2ecf20Sopenharmony_ci		si_request_link_speed_change_before_state_change(rdev, new_ps, old_ps);
65608c2ecf20Sopenharmony_ci	ni_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
65618c2ecf20Sopenharmony_ci	ret = si_enable_power_containment(rdev, new_ps, false);
65628c2ecf20Sopenharmony_ci	if (ret) {
65638c2ecf20Sopenharmony_ci		DRM_ERROR("si_enable_power_containment failed\n");
65648c2ecf20Sopenharmony_ci		return ret;
65658c2ecf20Sopenharmony_ci	}
65668c2ecf20Sopenharmony_ci	ret = si_enable_smc_cac(rdev, new_ps, false);
65678c2ecf20Sopenharmony_ci	if (ret) {
65688c2ecf20Sopenharmony_ci		DRM_ERROR("si_enable_smc_cac failed\n");
65698c2ecf20Sopenharmony_ci		return ret;
65708c2ecf20Sopenharmony_ci	}
65718c2ecf20Sopenharmony_ci	ret = si_halt_smc(rdev);
65728c2ecf20Sopenharmony_ci	if (ret) {
65738c2ecf20Sopenharmony_ci		DRM_ERROR("si_halt_smc failed\n");
65748c2ecf20Sopenharmony_ci		return ret;
65758c2ecf20Sopenharmony_ci	}
65768c2ecf20Sopenharmony_ci	ret = si_upload_sw_state(rdev, new_ps);
65778c2ecf20Sopenharmony_ci	if (ret) {
65788c2ecf20Sopenharmony_ci		DRM_ERROR("si_upload_sw_state failed\n");
65798c2ecf20Sopenharmony_ci		return ret;
65808c2ecf20Sopenharmony_ci	}
65818c2ecf20Sopenharmony_ci	ret = si_upload_smc_data(rdev);
65828c2ecf20Sopenharmony_ci	if (ret) {
65838c2ecf20Sopenharmony_ci		DRM_ERROR("si_upload_smc_data failed\n");
65848c2ecf20Sopenharmony_ci		return ret;
65858c2ecf20Sopenharmony_ci	}
65868c2ecf20Sopenharmony_ci	ret = si_upload_ulv_state(rdev);
65878c2ecf20Sopenharmony_ci	if (ret) {
65888c2ecf20Sopenharmony_ci		DRM_ERROR("si_upload_ulv_state failed\n");
65898c2ecf20Sopenharmony_ci		return ret;
65908c2ecf20Sopenharmony_ci	}
65918c2ecf20Sopenharmony_ci	if (eg_pi->dynamic_ac_timing) {
65928c2ecf20Sopenharmony_ci		ret = si_upload_mc_reg_table(rdev, new_ps);
65938c2ecf20Sopenharmony_ci		if (ret) {
65948c2ecf20Sopenharmony_ci			DRM_ERROR("si_upload_mc_reg_table failed\n");
65958c2ecf20Sopenharmony_ci			return ret;
65968c2ecf20Sopenharmony_ci		}
65978c2ecf20Sopenharmony_ci	}
65988c2ecf20Sopenharmony_ci	ret = si_program_memory_timing_parameters(rdev, new_ps);
65998c2ecf20Sopenharmony_ci	if (ret) {
66008c2ecf20Sopenharmony_ci		DRM_ERROR("si_program_memory_timing_parameters failed\n");
66018c2ecf20Sopenharmony_ci		return ret;
66028c2ecf20Sopenharmony_ci	}
66038c2ecf20Sopenharmony_ci	si_set_pcie_lane_width_in_smc(rdev, new_ps, old_ps);
66048c2ecf20Sopenharmony_ci
66058c2ecf20Sopenharmony_ci	ret = si_resume_smc(rdev);
66068c2ecf20Sopenharmony_ci	if (ret) {
66078c2ecf20Sopenharmony_ci		DRM_ERROR("si_resume_smc failed\n");
66088c2ecf20Sopenharmony_ci		return ret;
66098c2ecf20Sopenharmony_ci	}
66108c2ecf20Sopenharmony_ci	ret = si_set_sw_state(rdev);
66118c2ecf20Sopenharmony_ci	if (ret) {
66128c2ecf20Sopenharmony_ci		DRM_ERROR("si_set_sw_state failed\n");
66138c2ecf20Sopenharmony_ci		return ret;
66148c2ecf20Sopenharmony_ci	}
66158c2ecf20Sopenharmony_ci	ni_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
66168c2ecf20Sopenharmony_ci	si_set_vce_clock(rdev, new_ps, old_ps);
66178c2ecf20Sopenharmony_ci	if (eg_pi->pcie_performance_request)
66188c2ecf20Sopenharmony_ci		si_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
66198c2ecf20Sopenharmony_ci	ret = si_set_power_state_conditionally_enable_ulv(rdev, new_ps);
66208c2ecf20Sopenharmony_ci	if (ret) {
66218c2ecf20Sopenharmony_ci		DRM_ERROR("si_set_power_state_conditionally_enable_ulv failed\n");
66228c2ecf20Sopenharmony_ci		return ret;
66238c2ecf20Sopenharmony_ci	}
66248c2ecf20Sopenharmony_ci	ret = si_enable_smc_cac(rdev, new_ps, true);
66258c2ecf20Sopenharmony_ci	if (ret) {
66268c2ecf20Sopenharmony_ci		DRM_ERROR("si_enable_smc_cac failed\n");
66278c2ecf20Sopenharmony_ci		return ret;
66288c2ecf20Sopenharmony_ci	}
66298c2ecf20Sopenharmony_ci	ret = si_enable_power_containment(rdev, new_ps, true);
66308c2ecf20Sopenharmony_ci	if (ret) {
66318c2ecf20Sopenharmony_ci		DRM_ERROR("si_enable_power_containment failed\n");
66328c2ecf20Sopenharmony_ci		return ret;
66338c2ecf20Sopenharmony_ci	}
66348c2ecf20Sopenharmony_ci
66358c2ecf20Sopenharmony_ci	ret = si_power_control_set_level(rdev);
66368c2ecf20Sopenharmony_ci	if (ret) {
66378c2ecf20Sopenharmony_ci		DRM_ERROR("si_power_control_set_level failed\n");
66388c2ecf20Sopenharmony_ci		return ret;
66398c2ecf20Sopenharmony_ci	}
66408c2ecf20Sopenharmony_ci
66418c2ecf20Sopenharmony_ci	return 0;
66428c2ecf20Sopenharmony_ci}
66438c2ecf20Sopenharmony_ci
66448c2ecf20Sopenharmony_civoid si_dpm_post_set_power_state(struct radeon_device *rdev)
66458c2ecf20Sopenharmony_ci{
66468c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
66478c2ecf20Sopenharmony_ci	struct radeon_ps *new_ps = &eg_pi->requested_rps;
66488c2ecf20Sopenharmony_ci
66498c2ecf20Sopenharmony_ci	ni_update_current_ps(rdev, new_ps);
66508c2ecf20Sopenharmony_ci}
66518c2ecf20Sopenharmony_ci
66528c2ecf20Sopenharmony_ci#if 0
66538c2ecf20Sopenharmony_civoid si_dpm_reset_asic(struct radeon_device *rdev)
66548c2ecf20Sopenharmony_ci{
66558c2ecf20Sopenharmony_ci	si_restrict_performance_levels_before_switch(rdev);
66568c2ecf20Sopenharmony_ci	si_disable_ulv(rdev);
66578c2ecf20Sopenharmony_ci	si_set_boot_state(rdev);
66588c2ecf20Sopenharmony_ci}
66598c2ecf20Sopenharmony_ci#endif
66608c2ecf20Sopenharmony_ci
66618c2ecf20Sopenharmony_civoid si_dpm_display_configuration_changed(struct radeon_device *rdev)
66628c2ecf20Sopenharmony_ci{
66638c2ecf20Sopenharmony_ci	si_program_display_gap(rdev);
66648c2ecf20Sopenharmony_ci}
66658c2ecf20Sopenharmony_ci
66668c2ecf20Sopenharmony_ciunion power_info {
66678c2ecf20Sopenharmony_ci	struct _ATOM_POWERPLAY_INFO info;
66688c2ecf20Sopenharmony_ci	struct _ATOM_POWERPLAY_INFO_V2 info_2;
66698c2ecf20Sopenharmony_ci	struct _ATOM_POWERPLAY_INFO_V3 info_3;
66708c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_POWERPLAYTABLE pplib;
66718c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2;
66728c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3;
66738c2ecf20Sopenharmony_ci};
66748c2ecf20Sopenharmony_ci
66758c2ecf20Sopenharmony_ciunion pplib_clock_info {
66768c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_R600_CLOCK_INFO r600;
66778c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780;
66788c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen;
66798c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo;
66808c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_SI_CLOCK_INFO si;
66818c2ecf20Sopenharmony_ci};
66828c2ecf20Sopenharmony_ci
66838c2ecf20Sopenharmony_ciunion pplib_power_state {
66848c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_STATE v1;
66858c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_STATE_V2 v2;
66868c2ecf20Sopenharmony_ci};
66878c2ecf20Sopenharmony_ci
66888c2ecf20Sopenharmony_cistatic void si_parse_pplib_non_clock_info(struct radeon_device *rdev,
66898c2ecf20Sopenharmony_ci					  struct radeon_ps *rps,
66908c2ecf20Sopenharmony_ci					  struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info,
66918c2ecf20Sopenharmony_ci					  u8 table_rev)
66928c2ecf20Sopenharmony_ci{
66938c2ecf20Sopenharmony_ci	rps->caps = le32_to_cpu(non_clock_info->ulCapsAndSettings);
66948c2ecf20Sopenharmony_ci	rps->class = le16_to_cpu(non_clock_info->usClassification);
66958c2ecf20Sopenharmony_ci	rps->class2 = le16_to_cpu(non_clock_info->usClassification2);
66968c2ecf20Sopenharmony_ci
66978c2ecf20Sopenharmony_ci	if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) {
66988c2ecf20Sopenharmony_ci		rps->vclk = le32_to_cpu(non_clock_info->ulVCLK);
66998c2ecf20Sopenharmony_ci		rps->dclk = le32_to_cpu(non_clock_info->ulDCLK);
67008c2ecf20Sopenharmony_ci	} else if (r600_is_uvd_state(rps->class, rps->class2)) {
67018c2ecf20Sopenharmony_ci		rps->vclk = RV770_DEFAULT_VCLK_FREQ;
67028c2ecf20Sopenharmony_ci		rps->dclk = RV770_DEFAULT_DCLK_FREQ;
67038c2ecf20Sopenharmony_ci	} else {
67048c2ecf20Sopenharmony_ci		rps->vclk = 0;
67058c2ecf20Sopenharmony_ci		rps->dclk = 0;
67068c2ecf20Sopenharmony_ci	}
67078c2ecf20Sopenharmony_ci
67088c2ecf20Sopenharmony_ci	if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT)
67098c2ecf20Sopenharmony_ci		rdev->pm.dpm.boot_ps = rps;
67108c2ecf20Sopenharmony_ci	if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
67118c2ecf20Sopenharmony_ci		rdev->pm.dpm.uvd_ps = rps;
67128c2ecf20Sopenharmony_ci}
67138c2ecf20Sopenharmony_ci
67148c2ecf20Sopenharmony_cistatic void si_parse_pplib_clock_info(struct radeon_device *rdev,
67158c2ecf20Sopenharmony_ci				      struct radeon_ps *rps, int index,
67168c2ecf20Sopenharmony_ci				      union pplib_clock_info *clock_info)
67178c2ecf20Sopenharmony_ci{
67188c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
67198c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
67208c2ecf20Sopenharmony_ci	struct si_power_info *si_pi = si_get_pi(rdev);
67218c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(rps);
67228c2ecf20Sopenharmony_ci	u16 leakage_voltage;
67238c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl = &ps->performance_levels[index];
67248c2ecf20Sopenharmony_ci	int ret;
67258c2ecf20Sopenharmony_ci
67268c2ecf20Sopenharmony_ci	ps->performance_level_count = index + 1;
67278c2ecf20Sopenharmony_ci
67288c2ecf20Sopenharmony_ci	pl->sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
67298c2ecf20Sopenharmony_ci	pl->sclk |= clock_info->si.ucEngineClockHigh << 16;
67308c2ecf20Sopenharmony_ci	pl->mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
67318c2ecf20Sopenharmony_ci	pl->mclk |= clock_info->si.ucMemoryClockHigh << 16;
67328c2ecf20Sopenharmony_ci
67338c2ecf20Sopenharmony_ci	pl->vddc = le16_to_cpu(clock_info->si.usVDDC);
67348c2ecf20Sopenharmony_ci	pl->vddci = le16_to_cpu(clock_info->si.usVDDCI);
67358c2ecf20Sopenharmony_ci	pl->flags = le32_to_cpu(clock_info->si.ulFlags);
67368c2ecf20Sopenharmony_ci	pl->pcie_gen = r600_get_pcie_gen_support(rdev,
67378c2ecf20Sopenharmony_ci						 si_pi->sys_pcie_mask,
67388c2ecf20Sopenharmony_ci						 si_pi->boot_pcie_gen,
67398c2ecf20Sopenharmony_ci						 clock_info->si.ucPCIEGen);
67408c2ecf20Sopenharmony_ci
67418c2ecf20Sopenharmony_ci	/* patch up vddc if necessary */
67428c2ecf20Sopenharmony_ci	ret = si_get_leakage_voltage_from_leakage_index(rdev, pl->vddc,
67438c2ecf20Sopenharmony_ci							&leakage_voltage);
67448c2ecf20Sopenharmony_ci	if (ret == 0)
67458c2ecf20Sopenharmony_ci		pl->vddc = leakage_voltage;
67468c2ecf20Sopenharmony_ci
67478c2ecf20Sopenharmony_ci	if (rps->class & ATOM_PPLIB_CLASSIFICATION_ACPI) {
67488c2ecf20Sopenharmony_ci		pi->acpi_vddc = pl->vddc;
67498c2ecf20Sopenharmony_ci		eg_pi->acpi_vddci = pl->vddci;
67508c2ecf20Sopenharmony_ci		si_pi->acpi_pcie_gen = pl->pcie_gen;
67518c2ecf20Sopenharmony_ci	}
67528c2ecf20Sopenharmony_ci
67538c2ecf20Sopenharmony_ci	if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
67548c2ecf20Sopenharmony_ci	    index == 0) {
67558c2ecf20Sopenharmony_ci		/* XXX disable for A0 tahiti */
67568c2ecf20Sopenharmony_ci		si_pi->ulv.supported = false;
67578c2ecf20Sopenharmony_ci		si_pi->ulv.pl = *pl;
67588c2ecf20Sopenharmony_ci		si_pi->ulv.one_pcie_lane_in_ulv = false;
67598c2ecf20Sopenharmony_ci		si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
67608c2ecf20Sopenharmony_ci		si_pi->ulv.cg_ulv_parameter = SISLANDS_CGULVPARAMETER_DFLT;
67618c2ecf20Sopenharmony_ci		si_pi->ulv.cg_ulv_control = SISLANDS_CGULVCONTROL_DFLT;
67628c2ecf20Sopenharmony_ci	}
67638c2ecf20Sopenharmony_ci
67648c2ecf20Sopenharmony_ci	if (pi->min_vddc_in_table > pl->vddc)
67658c2ecf20Sopenharmony_ci		pi->min_vddc_in_table = pl->vddc;
67668c2ecf20Sopenharmony_ci
67678c2ecf20Sopenharmony_ci	if (pi->max_vddc_in_table < pl->vddc)
67688c2ecf20Sopenharmony_ci		pi->max_vddc_in_table = pl->vddc;
67698c2ecf20Sopenharmony_ci
67708c2ecf20Sopenharmony_ci	/* patch up boot state */
67718c2ecf20Sopenharmony_ci	if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) {
67728c2ecf20Sopenharmony_ci		u16 vddc, vddci, mvdd;
67738c2ecf20Sopenharmony_ci		radeon_atombios_get_default_voltages(rdev, &vddc, &vddci, &mvdd);
67748c2ecf20Sopenharmony_ci		pl->mclk = rdev->clock.default_mclk;
67758c2ecf20Sopenharmony_ci		pl->sclk = rdev->clock.default_sclk;
67768c2ecf20Sopenharmony_ci		pl->vddc = vddc;
67778c2ecf20Sopenharmony_ci		pl->vddci = vddci;
67788c2ecf20Sopenharmony_ci		si_pi->mvdd_bootup_value = mvdd;
67798c2ecf20Sopenharmony_ci	}
67808c2ecf20Sopenharmony_ci
67818c2ecf20Sopenharmony_ci	if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) ==
67828c2ecf20Sopenharmony_ci	    ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) {
67838c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk = pl->sclk;
67848c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.mclk = pl->mclk;
67858c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddc = pl->vddc;
67868c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddci = pl->vddci;
67878c2ecf20Sopenharmony_ci	}
67888c2ecf20Sopenharmony_ci}
67898c2ecf20Sopenharmony_ci
67908c2ecf20Sopenharmony_cistatic int si_parse_power_table(struct radeon_device *rdev)
67918c2ecf20Sopenharmony_ci{
67928c2ecf20Sopenharmony_ci	struct radeon_mode_info *mode_info = &rdev->mode_info;
67938c2ecf20Sopenharmony_ci	struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info;
67948c2ecf20Sopenharmony_ci	union pplib_power_state *power_state;
67958c2ecf20Sopenharmony_ci	int i, j, k, non_clock_array_index, clock_array_index;
67968c2ecf20Sopenharmony_ci	union pplib_clock_info *clock_info;
67978c2ecf20Sopenharmony_ci	struct _StateArray *state_array;
67988c2ecf20Sopenharmony_ci	struct _ClockInfoArray *clock_info_array;
67998c2ecf20Sopenharmony_ci	struct _NonClockInfoArray *non_clock_info_array;
68008c2ecf20Sopenharmony_ci	union power_info *power_info;
68018c2ecf20Sopenharmony_ci	int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
68028c2ecf20Sopenharmony_ci	u16 data_offset;
68038c2ecf20Sopenharmony_ci	u8 frev, crev;
68048c2ecf20Sopenharmony_ci	u8 *power_state_offset;
68058c2ecf20Sopenharmony_ci	struct ni_ps *ps;
68068c2ecf20Sopenharmony_ci
68078c2ecf20Sopenharmony_ci	if (!atom_parse_data_header(mode_info->atom_context, index, NULL,
68088c2ecf20Sopenharmony_ci				   &frev, &crev, &data_offset))
68098c2ecf20Sopenharmony_ci		return -EINVAL;
68108c2ecf20Sopenharmony_ci	power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
68118c2ecf20Sopenharmony_ci
68128c2ecf20Sopenharmony_ci	state_array = (struct _StateArray *)
68138c2ecf20Sopenharmony_ci		(mode_info->atom_context->bios + data_offset +
68148c2ecf20Sopenharmony_ci		 le16_to_cpu(power_info->pplib.usStateArrayOffset));
68158c2ecf20Sopenharmony_ci	clock_info_array = (struct _ClockInfoArray *)
68168c2ecf20Sopenharmony_ci		(mode_info->atom_context->bios + data_offset +
68178c2ecf20Sopenharmony_ci		 le16_to_cpu(power_info->pplib.usClockInfoArrayOffset));
68188c2ecf20Sopenharmony_ci	non_clock_info_array = (struct _NonClockInfoArray *)
68198c2ecf20Sopenharmony_ci		(mode_info->atom_context->bios + data_offset +
68208c2ecf20Sopenharmony_ci		 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
68218c2ecf20Sopenharmony_ci
68228c2ecf20Sopenharmony_ci	rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
68238c2ecf20Sopenharmony_ci				  sizeof(struct radeon_ps),
68248c2ecf20Sopenharmony_ci				  GFP_KERNEL);
68258c2ecf20Sopenharmony_ci	if (!rdev->pm.dpm.ps)
68268c2ecf20Sopenharmony_ci		return -ENOMEM;
68278c2ecf20Sopenharmony_ci	power_state_offset = (u8 *)state_array->states;
68288c2ecf20Sopenharmony_ci	for (i = 0; i < state_array->ucNumEntries; i++) {
68298c2ecf20Sopenharmony_ci		u8 *idx;
68308c2ecf20Sopenharmony_ci		power_state = (union pplib_power_state *)power_state_offset;
68318c2ecf20Sopenharmony_ci		non_clock_array_index = power_state->v2.nonClockInfoIndex;
68328c2ecf20Sopenharmony_ci		non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
68338c2ecf20Sopenharmony_ci			&non_clock_info_array->nonClockInfo[non_clock_array_index];
68348c2ecf20Sopenharmony_ci		if (!rdev->pm.power_state[i].clock_info)
68358c2ecf20Sopenharmony_ci			return -EINVAL;
68368c2ecf20Sopenharmony_ci		ps = kzalloc(sizeof(struct ni_ps), GFP_KERNEL);
68378c2ecf20Sopenharmony_ci		if (ps == NULL) {
68388c2ecf20Sopenharmony_ci			kfree(rdev->pm.dpm.ps);
68398c2ecf20Sopenharmony_ci			return -ENOMEM;
68408c2ecf20Sopenharmony_ci		}
68418c2ecf20Sopenharmony_ci		rdev->pm.dpm.ps[i].ps_priv = ps;
68428c2ecf20Sopenharmony_ci		si_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i],
68438c2ecf20Sopenharmony_ci					      non_clock_info,
68448c2ecf20Sopenharmony_ci					      non_clock_info_array->ucEntrySize);
68458c2ecf20Sopenharmony_ci		k = 0;
68468c2ecf20Sopenharmony_ci		idx = (u8 *)&power_state->v2.clockInfoIndex[0];
68478c2ecf20Sopenharmony_ci		for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) {
68488c2ecf20Sopenharmony_ci			clock_array_index = idx[j];
68498c2ecf20Sopenharmony_ci			if (clock_array_index >= clock_info_array->ucNumEntries)
68508c2ecf20Sopenharmony_ci				continue;
68518c2ecf20Sopenharmony_ci			if (k >= SISLANDS_MAX_HARDWARE_POWERLEVELS)
68528c2ecf20Sopenharmony_ci				break;
68538c2ecf20Sopenharmony_ci			clock_info = (union pplib_clock_info *)
68548c2ecf20Sopenharmony_ci				((u8 *)&clock_info_array->clockInfo[0] +
68558c2ecf20Sopenharmony_ci				 (clock_array_index * clock_info_array->ucEntrySize));
68568c2ecf20Sopenharmony_ci			si_parse_pplib_clock_info(rdev,
68578c2ecf20Sopenharmony_ci						  &rdev->pm.dpm.ps[i], k,
68588c2ecf20Sopenharmony_ci						  clock_info);
68598c2ecf20Sopenharmony_ci			k++;
68608c2ecf20Sopenharmony_ci		}
68618c2ecf20Sopenharmony_ci		power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
68628c2ecf20Sopenharmony_ci	}
68638c2ecf20Sopenharmony_ci	rdev->pm.dpm.num_ps = state_array->ucNumEntries;
68648c2ecf20Sopenharmony_ci
68658c2ecf20Sopenharmony_ci	/* fill in the vce power states */
68668c2ecf20Sopenharmony_ci	for (i = 0; i < RADEON_MAX_VCE_LEVELS; i++) {
68678c2ecf20Sopenharmony_ci		u32 sclk, mclk;
68688c2ecf20Sopenharmony_ci		clock_array_index = rdev->pm.dpm.vce_states[i].clk_idx;
68698c2ecf20Sopenharmony_ci		clock_info = (union pplib_clock_info *)
68708c2ecf20Sopenharmony_ci			&clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
68718c2ecf20Sopenharmony_ci		sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
68728c2ecf20Sopenharmony_ci		sclk |= clock_info->si.ucEngineClockHigh << 16;
68738c2ecf20Sopenharmony_ci		mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
68748c2ecf20Sopenharmony_ci		mclk |= clock_info->si.ucMemoryClockHigh << 16;
68758c2ecf20Sopenharmony_ci		rdev->pm.dpm.vce_states[i].sclk = sclk;
68768c2ecf20Sopenharmony_ci		rdev->pm.dpm.vce_states[i].mclk = mclk;
68778c2ecf20Sopenharmony_ci	}
68788c2ecf20Sopenharmony_ci
68798c2ecf20Sopenharmony_ci	return 0;
68808c2ecf20Sopenharmony_ci}
68818c2ecf20Sopenharmony_ci
68828c2ecf20Sopenharmony_ciint si_dpm_init(struct radeon_device *rdev)
68838c2ecf20Sopenharmony_ci{
68848c2ecf20Sopenharmony_ci	struct rv7xx_power_info *pi;
68858c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi;
68868c2ecf20Sopenharmony_ci	struct ni_power_info *ni_pi;
68878c2ecf20Sopenharmony_ci	struct si_power_info *si_pi;
68888c2ecf20Sopenharmony_ci	struct atom_clock_dividers dividers;
68898c2ecf20Sopenharmony_ci	enum pci_bus_speed speed_cap = PCI_SPEED_UNKNOWN;
68908c2ecf20Sopenharmony_ci	struct pci_dev *root = rdev->pdev->bus->self;
68918c2ecf20Sopenharmony_ci	int ret;
68928c2ecf20Sopenharmony_ci
68938c2ecf20Sopenharmony_ci	si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL);
68948c2ecf20Sopenharmony_ci	if (si_pi == NULL)
68958c2ecf20Sopenharmony_ci		return -ENOMEM;
68968c2ecf20Sopenharmony_ci	rdev->pm.dpm.priv = si_pi;
68978c2ecf20Sopenharmony_ci	ni_pi = &si_pi->ni;
68988c2ecf20Sopenharmony_ci	eg_pi = &ni_pi->eg;
68998c2ecf20Sopenharmony_ci	pi = &eg_pi->rv7xx;
69008c2ecf20Sopenharmony_ci
69018c2ecf20Sopenharmony_ci	if (!pci_is_root_bus(rdev->pdev->bus))
69028c2ecf20Sopenharmony_ci		speed_cap = pcie_get_speed_cap(root);
69038c2ecf20Sopenharmony_ci	if (speed_cap == PCI_SPEED_UNKNOWN) {
69048c2ecf20Sopenharmony_ci		si_pi->sys_pcie_mask = 0;
69058c2ecf20Sopenharmony_ci	} else {
69068c2ecf20Sopenharmony_ci		if (speed_cap == PCIE_SPEED_8_0GT)
69078c2ecf20Sopenharmony_ci			si_pi->sys_pcie_mask = RADEON_PCIE_SPEED_25 |
69088c2ecf20Sopenharmony_ci				RADEON_PCIE_SPEED_50 |
69098c2ecf20Sopenharmony_ci				RADEON_PCIE_SPEED_80;
69108c2ecf20Sopenharmony_ci		else if (speed_cap == PCIE_SPEED_5_0GT)
69118c2ecf20Sopenharmony_ci			si_pi->sys_pcie_mask = RADEON_PCIE_SPEED_25 |
69128c2ecf20Sopenharmony_ci				RADEON_PCIE_SPEED_50;
69138c2ecf20Sopenharmony_ci		else
69148c2ecf20Sopenharmony_ci			si_pi->sys_pcie_mask = RADEON_PCIE_SPEED_25;
69158c2ecf20Sopenharmony_ci	}
69168c2ecf20Sopenharmony_ci	si_pi->force_pcie_gen = RADEON_PCIE_GEN_INVALID;
69178c2ecf20Sopenharmony_ci	si_pi->boot_pcie_gen = si_get_current_pcie_speed(rdev);
69188c2ecf20Sopenharmony_ci
69198c2ecf20Sopenharmony_ci	si_set_max_cu_value(rdev);
69208c2ecf20Sopenharmony_ci
69218c2ecf20Sopenharmony_ci	rv770_get_max_vddc(rdev);
69228c2ecf20Sopenharmony_ci	si_get_leakage_vddc(rdev);
69238c2ecf20Sopenharmony_ci	si_patch_dependency_tables_based_on_leakage(rdev);
69248c2ecf20Sopenharmony_ci
69258c2ecf20Sopenharmony_ci	pi->acpi_vddc = 0;
69268c2ecf20Sopenharmony_ci	eg_pi->acpi_vddci = 0;
69278c2ecf20Sopenharmony_ci	pi->min_vddc_in_table = 0;
69288c2ecf20Sopenharmony_ci	pi->max_vddc_in_table = 0;
69298c2ecf20Sopenharmony_ci
69308c2ecf20Sopenharmony_ci	ret = r600_get_platform_caps(rdev);
69318c2ecf20Sopenharmony_ci	if (ret)
69328c2ecf20Sopenharmony_ci		return ret;
69338c2ecf20Sopenharmony_ci
69348c2ecf20Sopenharmony_ci	ret = r600_parse_extended_power_table(rdev);
69358c2ecf20Sopenharmony_ci	if (ret)
69368c2ecf20Sopenharmony_ci		return ret;
69378c2ecf20Sopenharmony_ci
69388c2ecf20Sopenharmony_ci	ret = si_parse_power_table(rdev);
69398c2ecf20Sopenharmony_ci	if (ret)
69408c2ecf20Sopenharmony_ci		return ret;
69418c2ecf20Sopenharmony_ci
69428c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
69438c2ecf20Sopenharmony_ci		kcalloc(4,
69448c2ecf20Sopenharmony_ci			sizeof(struct radeon_clock_voltage_dependency_entry),
69458c2ecf20Sopenharmony_ci			GFP_KERNEL);
69468c2ecf20Sopenharmony_ci	if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
69478c2ecf20Sopenharmony_ci		r600_free_extended_power_table(rdev);
69488c2ecf20Sopenharmony_ci		return -ENOMEM;
69498c2ecf20Sopenharmony_ci	}
69508c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
69518c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
69528c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
69538c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
69548c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 720;
69558c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
69568c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 810;
69578c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
69588c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 900;
69598c2ecf20Sopenharmony_ci
69608c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.voltage_response_time == 0)
69618c2ecf20Sopenharmony_ci		rdev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
69628c2ecf20Sopenharmony_ci	if (rdev->pm.dpm.backbias_response_time == 0)
69638c2ecf20Sopenharmony_ci		rdev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
69648c2ecf20Sopenharmony_ci
69658c2ecf20Sopenharmony_ci	ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
69668c2ecf20Sopenharmony_ci					     0, false, &dividers);
69678c2ecf20Sopenharmony_ci	if (ret)
69688c2ecf20Sopenharmony_ci		pi->ref_div = dividers.ref_div + 1;
69698c2ecf20Sopenharmony_ci	else
69708c2ecf20Sopenharmony_ci		pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
69718c2ecf20Sopenharmony_ci
69728c2ecf20Sopenharmony_ci	eg_pi->smu_uvd_hs = false;
69738c2ecf20Sopenharmony_ci
69748c2ecf20Sopenharmony_ci	pi->mclk_strobe_mode_threshold = 40000;
69758c2ecf20Sopenharmony_ci	if (si_is_special_1gb_platform(rdev))
69768c2ecf20Sopenharmony_ci		pi->mclk_stutter_mode_threshold = 0;
69778c2ecf20Sopenharmony_ci	else
69788c2ecf20Sopenharmony_ci		pi->mclk_stutter_mode_threshold = pi->mclk_strobe_mode_threshold;
69798c2ecf20Sopenharmony_ci	pi->mclk_edc_enable_threshold = 40000;
69808c2ecf20Sopenharmony_ci	eg_pi->mclk_edc_wr_enable_threshold = 40000;
69818c2ecf20Sopenharmony_ci
69828c2ecf20Sopenharmony_ci	ni_pi->mclk_rtt_mode_threshold = eg_pi->mclk_edc_wr_enable_threshold;
69838c2ecf20Sopenharmony_ci
69848c2ecf20Sopenharmony_ci	pi->voltage_control =
69858c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
69868c2ecf20Sopenharmony_ci					    VOLTAGE_OBJ_GPIO_LUT);
69878c2ecf20Sopenharmony_ci	if (!pi->voltage_control) {
69888c2ecf20Sopenharmony_ci		si_pi->voltage_control_svi2 =
69898c2ecf20Sopenharmony_ci			radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
69908c2ecf20Sopenharmony_ci						    VOLTAGE_OBJ_SVID2);
69918c2ecf20Sopenharmony_ci		if (si_pi->voltage_control_svi2)
69928c2ecf20Sopenharmony_ci			radeon_atom_get_svi2_info(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
69938c2ecf20Sopenharmony_ci						  &si_pi->svd_gpio_id, &si_pi->svc_gpio_id);
69948c2ecf20Sopenharmony_ci	}
69958c2ecf20Sopenharmony_ci
69968c2ecf20Sopenharmony_ci	pi->mvdd_control =
69978c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC,
69988c2ecf20Sopenharmony_ci					    VOLTAGE_OBJ_GPIO_LUT);
69998c2ecf20Sopenharmony_ci
70008c2ecf20Sopenharmony_ci	eg_pi->vddci_control =
70018c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
70028c2ecf20Sopenharmony_ci					    VOLTAGE_OBJ_GPIO_LUT);
70038c2ecf20Sopenharmony_ci	if (!eg_pi->vddci_control)
70048c2ecf20Sopenharmony_ci		si_pi->vddci_control_svi2 =
70058c2ecf20Sopenharmony_ci			radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
70068c2ecf20Sopenharmony_ci						    VOLTAGE_OBJ_SVID2);
70078c2ecf20Sopenharmony_ci
70088c2ecf20Sopenharmony_ci	si_pi->vddc_phase_shed_control =
70098c2ecf20Sopenharmony_ci		radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
70108c2ecf20Sopenharmony_ci					    VOLTAGE_OBJ_PHASE_LUT);
70118c2ecf20Sopenharmony_ci
70128c2ecf20Sopenharmony_ci	rv770_get_engine_memory_ss(rdev);
70138c2ecf20Sopenharmony_ci
70148c2ecf20Sopenharmony_ci	pi->asi = RV770_ASI_DFLT;
70158c2ecf20Sopenharmony_ci	pi->pasi = CYPRESS_HASI_DFLT;
70168c2ecf20Sopenharmony_ci	pi->vrc = SISLANDS_VRC_DFLT;
70178c2ecf20Sopenharmony_ci
70188c2ecf20Sopenharmony_ci	pi->gfx_clock_gating = true;
70198c2ecf20Sopenharmony_ci
70208c2ecf20Sopenharmony_ci	eg_pi->sclk_deep_sleep = true;
70218c2ecf20Sopenharmony_ci	si_pi->sclk_deep_sleep_above_low = false;
70228c2ecf20Sopenharmony_ci
70238c2ecf20Sopenharmony_ci	if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
70248c2ecf20Sopenharmony_ci		pi->thermal_protection = true;
70258c2ecf20Sopenharmony_ci	else
70268c2ecf20Sopenharmony_ci		pi->thermal_protection = false;
70278c2ecf20Sopenharmony_ci
70288c2ecf20Sopenharmony_ci	eg_pi->dynamic_ac_timing = true;
70298c2ecf20Sopenharmony_ci
70308c2ecf20Sopenharmony_ci	eg_pi->light_sleep = true;
70318c2ecf20Sopenharmony_ci#if defined(CONFIG_ACPI)
70328c2ecf20Sopenharmony_ci	eg_pi->pcie_performance_request =
70338c2ecf20Sopenharmony_ci		radeon_acpi_is_pcie_performance_request_supported(rdev);
70348c2ecf20Sopenharmony_ci#else
70358c2ecf20Sopenharmony_ci	eg_pi->pcie_performance_request = false;
70368c2ecf20Sopenharmony_ci#endif
70378c2ecf20Sopenharmony_ci
70388c2ecf20Sopenharmony_ci	si_pi->sram_end = SMC_RAM_END;
70398c2ecf20Sopenharmony_ci
70408c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
70418c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
70428c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
70438c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_sclk_values.count = 0;
70448c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_sclk_values.values = NULL;
70458c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
70468c2ecf20Sopenharmony_ci	rdev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
70478c2ecf20Sopenharmony_ci
70488c2ecf20Sopenharmony_ci	si_initialize_powertune_defaults(rdev);
70498c2ecf20Sopenharmony_ci
70508c2ecf20Sopenharmony_ci	/* make sure dc limits are valid */
70518c2ecf20Sopenharmony_ci	if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
70528c2ecf20Sopenharmony_ci	    (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
70538c2ecf20Sopenharmony_ci		rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
70548c2ecf20Sopenharmony_ci			rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
70558c2ecf20Sopenharmony_ci
70568c2ecf20Sopenharmony_ci	si_pi->fan_ctrl_is_in_default_mode = true;
70578c2ecf20Sopenharmony_ci
70588c2ecf20Sopenharmony_ci	return 0;
70598c2ecf20Sopenharmony_ci}
70608c2ecf20Sopenharmony_ci
70618c2ecf20Sopenharmony_civoid si_dpm_fini(struct radeon_device *rdev)
70628c2ecf20Sopenharmony_ci{
70638c2ecf20Sopenharmony_ci	int i;
70648c2ecf20Sopenharmony_ci
70658c2ecf20Sopenharmony_ci	for (i = 0; i < rdev->pm.dpm.num_ps; i++) {
70668c2ecf20Sopenharmony_ci		kfree(rdev->pm.dpm.ps[i].ps_priv);
70678c2ecf20Sopenharmony_ci	}
70688c2ecf20Sopenharmony_ci	kfree(rdev->pm.dpm.ps);
70698c2ecf20Sopenharmony_ci	kfree(rdev->pm.dpm.priv);
70708c2ecf20Sopenharmony_ci	kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
70718c2ecf20Sopenharmony_ci	r600_free_extended_power_table(rdev);
70728c2ecf20Sopenharmony_ci}
70738c2ecf20Sopenharmony_ci
70748c2ecf20Sopenharmony_civoid si_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
70758c2ecf20Sopenharmony_ci						    struct seq_file *m)
70768c2ecf20Sopenharmony_ci{
70778c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
70788c2ecf20Sopenharmony_ci	struct radeon_ps *rps = &eg_pi->current_rps;
70798c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(rps);
70808c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
70818c2ecf20Sopenharmony_ci	u32 current_index =
70828c2ecf20Sopenharmony_ci		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
70838c2ecf20Sopenharmony_ci		CURRENT_STATE_INDEX_SHIFT;
70848c2ecf20Sopenharmony_ci
70858c2ecf20Sopenharmony_ci	if (current_index >= ps->performance_level_count) {
70868c2ecf20Sopenharmony_ci		seq_printf(m, "invalid dpm profile %d\n", current_index);
70878c2ecf20Sopenharmony_ci	} else {
70888c2ecf20Sopenharmony_ci		pl = &ps->performance_levels[current_index];
70898c2ecf20Sopenharmony_ci		seq_printf(m, "uvd    vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
70908c2ecf20Sopenharmony_ci		seq_printf(m, "power level %d    sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
70918c2ecf20Sopenharmony_ci			   current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1);
70928c2ecf20Sopenharmony_ci	}
70938c2ecf20Sopenharmony_ci}
70948c2ecf20Sopenharmony_ci
70958c2ecf20Sopenharmony_ciu32 si_dpm_get_current_sclk(struct radeon_device *rdev)
70968c2ecf20Sopenharmony_ci{
70978c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
70988c2ecf20Sopenharmony_ci	struct radeon_ps *rps = &eg_pi->current_rps;
70998c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(rps);
71008c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
71018c2ecf20Sopenharmony_ci	u32 current_index =
71028c2ecf20Sopenharmony_ci		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
71038c2ecf20Sopenharmony_ci		CURRENT_STATE_INDEX_SHIFT;
71048c2ecf20Sopenharmony_ci
71058c2ecf20Sopenharmony_ci	if (current_index >= ps->performance_level_count) {
71068c2ecf20Sopenharmony_ci		return 0;
71078c2ecf20Sopenharmony_ci	} else {
71088c2ecf20Sopenharmony_ci		pl = &ps->performance_levels[current_index];
71098c2ecf20Sopenharmony_ci		return pl->sclk;
71108c2ecf20Sopenharmony_ci	}
71118c2ecf20Sopenharmony_ci}
71128c2ecf20Sopenharmony_ci
71138c2ecf20Sopenharmony_ciu32 si_dpm_get_current_mclk(struct radeon_device *rdev)
71148c2ecf20Sopenharmony_ci{
71158c2ecf20Sopenharmony_ci	struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
71168c2ecf20Sopenharmony_ci	struct radeon_ps *rps = &eg_pi->current_rps;
71178c2ecf20Sopenharmony_ci	struct ni_ps *ps = ni_get_ps(rps);
71188c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
71198c2ecf20Sopenharmony_ci	u32 current_index =
71208c2ecf20Sopenharmony_ci		(RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
71218c2ecf20Sopenharmony_ci		CURRENT_STATE_INDEX_SHIFT;
71228c2ecf20Sopenharmony_ci
71238c2ecf20Sopenharmony_ci	if (current_index >= ps->performance_level_count) {
71248c2ecf20Sopenharmony_ci		return 0;
71258c2ecf20Sopenharmony_ci	} else {
71268c2ecf20Sopenharmony_ci		pl = &ps->performance_levels[current_index];
71278c2ecf20Sopenharmony_ci		return pl->mclk;
71288c2ecf20Sopenharmony_ci	}
71298c2ecf20Sopenharmony_ci}
7130