18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2019 Samsung Electronics Co., Ltd.
48c2ecf20Sopenharmony_ci *	      http://www.samsung.com/
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Samsung Exynos 5422 SoC Adaptive Supply Voltage support
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/bitrev.h>
108c2ecf20Sopenharmony_ci#include <linux/errno.h>
118c2ecf20Sopenharmony_ci#include <linux/regmap.h>
128c2ecf20Sopenharmony_ci#include <linux/soc/samsung/exynos-chipid.h>
138c2ecf20Sopenharmony_ci#include <linux/slab.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "exynos-asv.h"
168c2ecf20Sopenharmony_ci#include "exynos5422-asv.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define ASV_GROUPS_NUM		14
198c2ecf20Sopenharmony_ci#define ASV_ARM_DVFS_NUM	20
208c2ecf20Sopenharmony_ci#define ASV_ARM_BIN2_DVFS_NUM	17
218c2ecf20Sopenharmony_ci#define ASV_KFC_DVFS_NUM	14
228c2ecf20Sopenharmony_ci#define ASV_KFC_BIN2_DVFS_NUM	12
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/*
258c2ecf20Sopenharmony_ci * This array is a set of 4 ASV data tables, first column of each ASV table
268c2ecf20Sopenharmony_ci * contains frequency value in MHz and subsequent columns contain the CPU
278c2ecf20Sopenharmony_ci * cluster's supply voltage values in uV.
288c2ecf20Sopenharmony_ci * In order to create a set of OPPs for specific SoC revision one of the voltage
298c2ecf20Sopenharmony_ci * columns (1...14) from one of the tables (0...3) is selected during
308c2ecf20Sopenharmony_ci * initialization. There are separate ASV tables for the big (ARM) and little
318c2ecf20Sopenharmony_ci * (KFC) CPU cluster. Only OPPs which are already defined in devicetree
328c2ecf20Sopenharmony_ci * will be updated.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic const u32 asv_arm_table[][ASV_ARM_DVFS_NUM][ASV_GROUPS_NUM + 1] = {
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	/* ARM 0, 1 */
388c2ecf20Sopenharmony_ci	{ 2100,    1362500, 1362500, 1350000, 1337500, 1325000, 1312500, 1300000,
398c2ecf20Sopenharmony_ci	  1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000 },
408c2ecf20Sopenharmony_ci	{ 2000,    1312500, 1312500, 1300000, 1287500, 1275000, 1262500, 1250000,
418c2ecf20Sopenharmony_ci	  1237500, 1225000, 1237500, 1225000, 1212500, 1200000, 1187500 },
428c2ecf20Sopenharmony_ci	{ 1900,    1250000, 1237500, 1225000, 1212500, 1200000, 1187500, 1175000,
438c2ecf20Sopenharmony_ci	  1162500, 1150000, 1162500, 1150000, 1137500, 1125000, 1112500 },
448c2ecf20Sopenharmony_ci	{ 1800,    1200000, 1187500, 1175000, 1162500, 1150000, 1137500, 1125000,
458c2ecf20Sopenharmony_ci	  1112500, 1100000, 1112500, 1100000, 1087500, 1075000, 1062500 },
468c2ecf20Sopenharmony_ci	{ 1700,    1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500,
478c2ecf20Sopenharmony_ci	  1075000, 1062500, 1075000, 1062500, 1050000, 1037500, 1025000 },
488c2ecf20Sopenharmony_ci	{ 1600,    1125000, 1112500, 1100000, 1087500, 1075000, 1062500, 1050000,
498c2ecf20Sopenharmony_ci	  1037500, 1025000, 1037500, 1025000, 1012500, 1000000, 987500 },
508c2ecf20Sopenharmony_ci	{ 1500,    1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500,
518c2ecf20Sopenharmony_ci	  1000000, 987500,  1000000, 987500,  975000,  962500,  950000 },
528c2ecf20Sopenharmony_ci	{ 1400,    1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
538c2ecf20Sopenharmony_ci	  975000,  962500,  975000,  962500,  950000,  937500,  925000 },
548c2ecf20Sopenharmony_ci	{ 1300,    1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000,
558c2ecf20Sopenharmony_ci	  962500,  950000,  962500,  950000,  937500,  925000,  912500 },
568c2ecf20Sopenharmony_ci	{ 1200,    1025000, 1012500, 1000000, 987500,  975000,  962500,  950000,
578c2ecf20Sopenharmony_ci	  937500,  925000,  937500,  925000,  912500,  900000,  900000 },
588c2ecf20Sopenharmony_ci	{ 1100,    1000000, 987500,  975000,  962500,  950000,  937500,  925000,
598c2ecf20Sopenharmony_ci	  912500,  900000,  900000,  900000,  900000,  900000,  900000 },
608c2ecf20Sopenharmony_ci	{ 1000,    975000,  962500,  950000,  937500,  925000,  912500,  900000,
618c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
628c2ecf20Sopenharmony_ci	{ 900,     950000,  937500,  925000,  912500,  900000,  900000,  900000,
638c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
648c2ecf20Sopenharmony_ci	{ 800,     925000,  912500,  900000,  900000,  900000,  900000,  900000,
658c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
668c2ecf20Sopenharmony_ci	{ 700,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
678c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
688c2ecf20Sopenharmony_ci	{ 600,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
698c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
708c2ecf20Sopenharmony_ci	{ 500,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
718c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
728c2ecf20Sopenharmony_ci	{ 400,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
738c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
748c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
758c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
768c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
778c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
788c2ecf20Sopenharmony_ci}, {
798c2ecf20Sopenharmony_ci	/* ARM 2 */
808c2ecf20Sopenharmony_ci	{ 2100,    1362500, 1362500, 1350000, 1337500, 1325000, 1312500, 1300000,
818c2ecf20Sopenharmony_ci	  1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000 },
828c2ecf20Sopenharmony_ci	{ 2000,    1312500, 1312500, 1312500, 1300000, 1275000, 1262500, 1250000,
838c2ecf20Sopenharmony_ci	  1237500, 1225000, 1237500, 1225000, 1212500, 1200000, 1187500 },
848c2ecf20Sopenharmony_ci	{ 1900,    1262500, 1250000, 1250000, 1237500, 1212500, 1200000, 1187500,
858c2ecf20Sopenharmony_ci	  1175000, 1162500, 1175000, 1162500, 1150000, 1137500, 1125000 },
868c2ecf20Sopenharmony_ci	{ 1800,    1212500, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500,
878c2ecf20Sopenharmony_ci	  1125000, 1112500, 1125000, 1112500, 1100000, 1087500, 1075000 },
888c2ecf20Sopenharmony_ci	{ 1700,    1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
898c2ecf20Sopenharmony_ci	  1087500, 1075000, 1087500, 1075000, 1062500, 1050000, 1037500 },
908c2ecf20Sopenharmony_ci	{ 1600,    1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
918c2ecf20Sopenharmony_ci	  1050000, 1037500, 1050000, 1037500, 1025000, 1012500, 1000000 },
928c2ecf20Sopenharmony_ci	{ 1500,    1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
938c2ecf20Sopenharmony_ci	  1012500, 1000000, 1012500, 1000000, 987500,  975000,  962500 },
948c2ecf20Sopenharmony_ci	{ 1400,    1075000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000,
958c2ecf20Sopenharmony_ci	  987500,  975000,  987500,  975000,  962500,  950000,  937500 },
968c2ecf20Sopenharmony_ci	{ 1300,    1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000,
978c2ecf20Sopenharmony_ci	  962500,  950000,  962500,  950000,  937500,  925000,  912500 },
988c2ecf20Sopenharmony_ci	{ 1200,    1025000, 1012500, 1000000, 987500,  975000,  962500,  950000,
998c2ecf20Sopenharmony_ci	  937500,  925000,  937500,  925000,  912500,  900000,  900000 },
1008c2ecf20Sopenharmony_ci	{ 1100,    1000000, 987500,  975000,  962500,  950000,  937500,  925000,
1018c2ecf20Sopenharmony_ci	  912500,  900000,  900000,  900000,  900000,  900000,  900000 },
1028c2ecf20Sopenharmony_ci	{ 1000,    975000,  962500,  950000,  937500,  925000,  912500,  900000,
1038c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1048c2ecf20Sopenharmony_ci	{ 900,     950000,  937500,  925000,  912500,  900000,  900000,  900000,
1058c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1068c2ecf20Sopenharmony_ci	{ 800,     925000,  912500,  900000,  900000,  900000,  900000,  900000,
1078c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1088c2ecf20Sopenharmony_ci	{ 700,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1098c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1108c2ecf20Sopenharmony_ci	{ 600,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1118c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1128c2ecf20Sopenharmony_ci	{ 500,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1138c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1148c2ecf20Sopenharmony_ci	{ 400,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1158c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1168c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1178c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1188c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1198c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1208c2ecf20Sopenharmony_ci}, {
1218c2ecf20Sopenharmony_ci	/* ARM 3 */
1228c2ecf20Sopenharmony_ci	{ 2100,    1362500, 1362500, 1350000, 1337500, 1325000, 1312500, 1300000,
1238c2ecf20Sopenharmony_ci	  1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000 },
1248c2ecf20Sopenharmony_ci	{ 2000,    1312500, 1312500, 1300000, 1287500, 1275000, 1262500, 1250000,
1258c2ecf20Sopenharmony_ci	  1237500, 1225000, 1237500, 1225000, 1212500, 1200000, 1187500 },
1268c2ecf20Sopenharmony_ci	{ 1900,    1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500,
1278c2ecf20Sopenharmony_ci	  1175000, 1162500, 1175000, 1162500, 1150000, 1137500, 1125000 },
1288c2ecf20Sopenharmony_ci	{ 1800,    1212500, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500,
1298c2ecf20Sopenharmony_ci	  1125000, 1112500, 1125000, 1112500, 1100000, 1087500, 1075000 },
1308c2ecf20Sopenharmony_ci	{ 1700,    1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
1318c2ecf20Sopenharmony_ci	  1087500, 1075000, 1087500, 1075000, 1062500, 1050000, 1037500 },
1328c2ecf20Sopenharmony_ci	{ 1600,    1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
1338c2ecf20Sopenharmony_ci	  1050000, 1037500, 1050000, 1037500, 1025000, 1012500, 1000000 },
1348c2ecf20Sopenharmony_ci	{ 1500,    1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
1358c2ecf20Sopenharmony_ci	  1012500, 1000000, 1012500, 1000000, 987500,  975000,  962500 },
1368c2ecf20Sopenharmony_ci	{ 1400,    1075000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000,
1378c2ecf20Sopenharmony_ci	  987500,  975000,  987500,  975000,  962500,  950000,  937500 },
1388c2ecf20Sopenharmony_ci	{ 1300,    1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000,
1398c2ecf20Sopenharmony_ci	  962500,  950000,  962500,  950000,  937500,  925000,  912500 },
1408c2ecf20Sopenharmony_ci	{ 1200,    1025000, 1012500, 1000000, 987500,  975000,  962500,  950000,
1418c2ecf20Sopenharmony_ci	  937500,  925000,  937500,  925000,  912500,  900000,  900000 },
1428c2ecf20Sopenharmony_ci	{ 1100,    1000000, 987500,  975000,  962500,  950000,  937500,  925000,
1438c2ecf20Sopenharmony_ci	  912500,  900000,  900000,  900000,  900000,  900000,  900000 },
1448c2ecf20Sopenharmony_ci	{ 1000,    975000,  962500,  950000,  937500,  925000,  912500,  900000,
1458c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1468c2ecf20Sopenharmony_ci	{ 900,     950000,  937500,  925000,  912500,  900000,  900000,  900000,
1478c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1488c2ecf20Sopenharmony_ci	{ 800,     925000,  912500,  900000,  900000,  900000,  900000,  900000,
1498c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1508c2ecf20Sopenharmony_ci	{ 700,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1518c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1528c2ecf20Sopenharmony_ci	{ 600,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1538c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1548c2ecf20Sopenharmony_ci	{ 500,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1558c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1568c2ecf20Sopenharmony_ci	{ 400,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1578c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1588c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1598c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1608c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1618c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1628c2ecf20Sopenharmony_ci}, {
1638c2ecf20Sopenharmony_ci	/* ARM bin 2 */
1648c2ecf20Sopenharmony_ci	{ 1800,    1237500, 1225000, 1212500, 1200000, 1187500, 1175000, 1162500,
1658c2ecf20Sopenharmony_ci	  1150000, 1137500, 1150000, 1137500, 1125000, 1112500, 1100000 },
1668c2ecf20Sopenharmony_ci	{ 1700,    1200000, 1187500, 1175000, 1162500, 1150000, 1137500, 1125000,
1678c2ecf20Sopenharmony_ci	  1112500, 1100000, 1112500, 1100000, 1087500, 1075000, 1062500 },
1688c2ecf20Sopenharmony_ci	{ 1600,    1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500,
1698c2ecf20Sopenharmony_ci	  1075000, 1062500, 1075000, 1062500, 1050000, 1037500, 1025000 },
1708c2ecf20Sopenharmony_ci	{ 1500,    1125000, 1112500, 1100000, 1087500, 1075000, 1062500, 1050000,
1718c2ecf20Sopenharmony_ci	  1037500, 1025000, 1037500, 1025000, 1012500, 1000000, 987500 },
1728c2ecf20Sopenharmony_ci	{ 1400,    1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
1738c2ecf20Sopenharmony_ci	  1012500, 1000000, 1012500, 1000000, 987500,  975000,  962500 },
1748c2ecf20Sopenharmony_ci	{ 1300,    1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500,
1758c2ecf20Sopenharmony_ci	  1000000, 987500,  1000000, 987500,  975000,  962500,  950000 },
1768c2ecf20Sopenharmony_ci	{ 1200,    1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
1778c2ecf20Sopenharmony_ci	  975000,  962500,  975000,  962500,  950000,  937500,  925000 },
1788c2ecf20Sopenharmony_ci	{ 1100,    1037500, 1025000, 1012500, 1000000, 987500,  975000,  962500,
1798c2ecf20Sopenharmony_ci	  950000,  937500,  950000,  937500,  925000,  912500,  900000 },
1808c2ecf20Sopenharmony_ci	{ 1000,    1012500, 1000000, 987500,  975000,  962500,  950000,  937500,
1818c2ecf20Sopenharmony_ci	  925000,  912500,  925000,  912500,  900000,  900000,  900000 },
1828c2ecf20Sopenharmony_ci	{ 900,     987500,  975000,  962500,  950000,  937500,  925000,  912500,
1838c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1848c2ecf20Sopenharmony_ci	{ 800,     962500,  950000,  937500,  925000,  912500,  900000,  900000,
1858c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1868c2ecf20Sopenharmony_ci	{ 700,     937500,  925000,  912500,  900000,  900000,  900000,  900000,
1878c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1888c2ecf20Sopenharmony_ci	{ 600,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1898c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1908c2ecf20Sopenharmony_ci	{ 500,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1918c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1928c2ecf20Sopenharmony_ci	{ 400,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1938c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1948c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1958c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1968c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
1978c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
1988c2ecf20Sopenharmony_ci}
1998c2ecf20Sopenharmony_ci};
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_cistatic const u32 asv_kfc_table[][ASV_KFC_DVFS_NUM][ASV_GROUPS_NUM + 1] = {
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	/* KFC 0, 1 */
2048c2ecf20Sopenharmony_ci	{ 1500000, 1300000, 1300000, 1300000, 1287500, 1287500, 1287500, 1275000,
2058c2ecf20Sopenharmony_ci	  1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500 },
2068c2ecf20Sopenharmony_ci	{ 1400000, 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000,
2078c2ecf20Sopenharmony_ci	  1187500, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500 },
2088c2ecf20Sopenharmony_ci	{ 1300000, 1225000, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000,
2098c2ecf20Sopenharmony_ci	  1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500 },
2108c2ecf20Sopenharmony_ci	{ 1200000, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
2118c2ecf20Sopenharmony_ci	  1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500 },
2128c2ecf20Sopenharmony_ci	{ 1100000, 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
2138c2ecf20Sopenharmony_ci	  1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000 },
2148c2ecf20Sopenharmony_ci	{ 1000000, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
2158c2ecf20Sopenharmony_ci	  1012500, 1000000, 987500,  975000,  962500,  950000,  937500 },
2168c2ecf20Sopenharmony_ci	{ 900000,  1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
2178c2ecf20Sopenharmony_ci	  975000,  962500,  950000,  937500,  925000,  912500,  900000 },
2188c2ecf20Sopenharmony_ci	{ 800000,  1025000, 1012500, 1000000, 987500,  975000,  962500,  950000,
2198c2ecf20Sopenharmony_ci	  937500,  925000,  912500,  900000,  900000,  900000,  900000 },
2208c2ecf20Sopenharmony_ci	{ 700000,  987500,  975000,  962500,  950000,  937500,  925000,  912500,
2218c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2228c2ecf20Sopenharmony_ci	{ 600000,  950000,  937500,  925000,  912500,  900000,  900000,  900000,
2238c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2248c2ecf20Sopenharmony_ci	{ 500000,  912500,  900000,  900000,  900000,  900000,  900000,  900000,
2258c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2268c2ecf20Sopenharmony_ci	{ 400000,  900000,  900000,  900000,  900000,  900000,  900000,  900000,
2278c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2288c2ecf20Sopenharmony_ci	{ 300000,  900000,  900000,  900000,  900000,  900000,  900000,  900000,
2298c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2308c2ecf20Sopenharmony_ci	{ 200000,  900000,  900000,  900000,  900000,  900000,  900000,  900000,
2318c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2328c2ecf20Sopenharmony_ci}, {
2338c2ecf20Sopenharmony_ci	/* KFC 2 */
2348c2ecf20Sopenharmony_ci	{ 1500,    1300000, 1300000, 1300000, 1287500, 1287500, 1287500, 1275000,
2358c2ecf20Sopenharmony_ci	  1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500 },
2368c2ecf20Sopenharmony_ci	{ 1400,    1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000,
2378c2ecf20Sopenharmony_ci	  1187500, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500 },
2388c2ecf20Sopenharmony_ci	{ 1300,    1225000, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000,
2398c2ecf20Sopenharmony_ci	  1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500 },
2408c2ecf20Sopenharmony_ci	{ 1200,    1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
2418c2ecf20Sopenharmony_ci	  1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500 },
2428c2ecf20Sopenharmony_ci	{ 1100,    1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
2438c2ecf20Sopenharmony_ci	  1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000 },
2448c2ecf20Sopenharmony_ci	{ 1000,    1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
2458c2ecf20Sopenharmony_ci	  1012500, 1000000, 987500,  975000,  962500,  950000,  937500 },
2468c2ecf20Sopenharmony_ci	{ 900,     1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
2478c2ecf20Sopenharmony_ci	  975000,  962500,  950000,  937500,  925000,  912500,  900000 },
2488c2ecf20Sopenharmony_ci	{ 800,     1025000, 1012500, 1000000, 987500,  975000,  962500,  950000,
2498c2ecf20Sopenharmony_ci	  937500,  925000,  912500,  900000,  900000,  900000,  900000 },
2508c2ecf20Sopenharmony_ci	{ 700,     987500,  975000,  962500,  950000,  937500,  925000,  912500,
2518c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2528c2ecf20Sopenharmony_ci	{ 600,     950000,  937500,  925000,  912500,  900000,  900000,  900000,
2538c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2548c2ecf20Sopenharmony_ci	{ 500,     912500,  900000,  900000,  900000,  900000,  900000,  900000,
2558c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2568c2ecf20Sopenharmony_ci	{ 400,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
2578c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2588c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
2598c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2608c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
2618c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2628c2ecf20Sopenharmony_ci}, {
2638c2ecf20Sopenharmony_ci	/* KFC 3 */
2648c2ecf20Sopenharmony_ci	{ 1500,    1300000, 1300000, 1300000, 1287500, 1287500, 1287500, 1275000,
2658c2ecf20Sopenharmony_ci	  1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500 },
2668c2ecf20Sopenharmony_ci	{ 1400,    1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000,
2678c2ecf20Sopenharmony_ci	  1187500, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500 },
2688c2ecf20Sopenharmony_ci	{ 1300,    1225000, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000,
2698c2ecf20Sopenharmony_ci	  1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500 },
2708c2ecf20Sopenharmony_ci	{ 1200,    1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
2718c2ecf20Sopenharmony_ci	  1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500 },
2728c2ecf20Sopenharmony_ci	{ 1100,    1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
2738c2ecf20Sopenharmony_ci	  1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000 },
2748c2ecf20Sopenharmony_ci	{ 1000,    1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
2758c2ecf20Sopenharmony_ci	  1012500, 1000000, 987500,  975000,  962500,  950000,  937500 },
2768c2ecf20Sopenharmony_ci	{ 900,     1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
2778c2ecf20Sopenharmony_ci	  975000,  962500,  950000,  937500,  925000,  912500,  900000 },
2788c2ecf20Sopenharmony_ci	{ 800,     1025000, 1012500, 1000000, 987500,  975000,  962500,  950000,
2798c2ecf20Sopenharmony_ci	  937500,  925000,  912500,  900000,  900000,  900000,  900000 },
2808c2ecf20Sopenharmony_ci	{ 700,     987500,  975000,  962500,  950000,  937500,  925000,  912500,
2818c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2828c2ecf20Sopenharmony_ci	{ 600,     950000,  937500,  925000,  912500,  900000,  900000,  900000,
2838c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2848c2ecf20Sopenharmony_ci	{ 500,     912500,  900000,  900000,  900000,  900000,  900000,  900000,
2858c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2868c2ecf20Sopenharmony_ci	{ 400,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
2878c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2888c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
2898c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2908c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
2918c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
2928c2ecf20Sopenharmony_ci}, {
2938c2ecf20Sopenharmony_ci	/* KFC bin 2 */
2948c2ecf20Sopenharmony_ci	{ 1300,    1250000, 1237500, 1225000, 1212500, 1200000, 1187500, 1175000,
2958c2ecf20Sopenharmony_ci	  1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500 },
2968c2ecf20Sopenharmony_ci	{ 1200,    1200000, 1187500, 1175000, 1162500, 1150000, 1137500, 1125000,
2978c2ecf20Sopenharmony_ci	  1112500, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500 },
2988c2ecf20Sopenharmony_ci	{ 1100,    1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500,
2998c2ecf20Sopenharmony_ci	  1075000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000 },
3008c2ecf20Sopenharmony_ci	{ 1000,    1125000, 1112500, 1100000, 1087500, 1075000, 1062500, 1050000,
3018c2ecf20Sopenharmony_ci	  1037500, 1025000, 1012500, 1000000, 987500,  975000,  962500 },
3028c2ecf20Sopenharmony_ci	{ 900,     1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500,
3038c2ecf20Sopenharmony_ci	  1000000, 987500,  975000,  962500,  950000,  937500,  925000 },
3048c2ecf20Sopenharmony_ci	{ 800,     1050000, 1037500, 1025000, 1012500, 1000000, 987500,  975000,
3058c2ecf20Sopenharmony_ci	  962500,  950000,  937500,  925000,  912500,  900000,  900000 },
3068c2ecf20Sopenharmony_ci	{ 700,     1012500, 1000000, 987500,  975000,  962500,  950000,  937500,
3078c2ecf20Sopenharmony_ci	  925000,  912500,  900000,  900000,  900000,  900000,  900000 },
3088c2ecf20Sopenharmony_ci	{ 600,     975000,  962500,  950000,  937500,  925000,  912500,  900000,
3098c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
3108c2ecf20Sopenharmony_ci	{ 500,     937500,  925000,  912500,  900000,  900000,  900000,  900000,
3118c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
3128c2ecf20Sopenharmony_ci	{ 400,     925000,  912500,  900000,  900000,  900000,  900000,  900000,
3138c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
3148c2ecf20Sopenharmony_ci	{ 300,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
3158c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
3168c2ecf20Sopenharmony_ci	{ 200,     900000,  900000,  900000,  900000,  900000,  900000,  900000,
3178c2ecf20Sopenharmony_ci	  900000,  900000,  900000,  900000,  900000,  900000,  900000 },
3188c2ecf20Sopenharmony_ci}
3198c2ecf20Sopenharmony_ci};
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_cistatic const struct asv_limit_entry __asv_limits[ASV_GROUPS_NUM] = {
3228c2ecf20Sopenharmony_ci	{ 13, 55 },
3238c2ecf20Sopenharmony_ci	{ 21, 65 },
3248c2ecf20Sopenharmony_ci	{ 25, 69 },
3258c2ecf20Sopenharmony_ci	{ 30, 72 },
3268c2ecf20Sopenharmony_ci	{ 36, 74 },
3278c2ecf20Sopenharmony_ci	{ 43, 76 },
3288c2ecf20Sopenharmony_ci	{ 51, 78 },
3298c2ecf20Sopenharmony_ci	{ 65, 80 },
3308c2ecf20Sopenharmony_ci	{ 81, 82 },
3318c2ecf20Sopenharmony_ci	{ 98, 84 },
3328c2ecf20Sopenharmony_ci	{ 119, 87 },
3338c2ecf20Sopenharmony_ci	{ 135, 89 },
3348c2ecf20Sopenharmony_ci	{ 150, 92 },
3358c2ecf20Sopenharmony_ci	{ 999, 999 },
3368c2ecf20Sopenharmony_ci};
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistatic int exynos5422_asv_get_group(struct exynos_asv *asv)
3398c2ecf20Sopenharmony_ci{
3408c2ecf20Sopenharmony_ci	unsigned int pkgid_reg, auxi_reg;
3418c2ecf20Sopenharmony_ci	int hpm, ids, i;
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_PKG_ID, &pkgid_reg);
3448c2ecf20Sopenharmony_ci	regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_AUX_INFO, &auxi_reg);
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci	if (asv->use_sg) {
3478c2ecf20Sopenharmony_ci		u32 sga = (pkgid_reg >> EXYNOS5422_SG_A_OFFSET) &
3488c2ecf20Sopenharmony_ci			   EXYNOS5422_SG_A_MASK;
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci		u32 sgb = (pkgid_reg >> EXYNOS5422_SG_B_OFFSET) &
3518c2ecf20Sopenharmony_ci			   EXYNOS5422_SG_B_MASK;
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci		if ((pkgid_reg >> EXYNOS5422_SG_BSIGN_OFFSET) &
3548c2ecf20Sopenharmony_ci		     EXYNOS5422_SG_BSIGN_MASK)
3558c2ecf20Sopenharmony_ci			return sga + sgb;
3568c2ecf20Sopenharmony_ci		else
3578c2ecf20Sopenharmony_ci			return sga - sgb;
3588c2ecf20Sopenharmony_ci	}
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	hpm = (auxi_reg >> EXYNOS5422_TMCB_OFFSET) & EXYNOS5422_TMCB_MASK;
3618c2ecf20Sopenharmony_ci	ids = (pkgid_reg >> EXYNOS5422_IDS_OFFSET) & EXYNOS5422_IDS_MASK;
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci	for (i = 0; i < ASV_GROUPS_NUM; i++) {
3648c2ecf20Sopenharmony_ci		if (ids <= __asv_limits[i].ids)
3658c2ecf20Sopenharmony_ci			break;
3668c2ecf20Sopenharmony_ci		if (hpm <= __asv_limits[i].hpm)
3678c2ecf20Sopenharmony_ci			break;
3688c2ecf20Sopenharmony_ci	}
3698c2ecf20Sopenharmony_ci	if (i < ASV_GROUPS_NUM)
3708c2ecf20Sopenharmony_ci		return i;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	return 0;
3738c2ecf20Sopenharmony_ci}
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_cistatic int __asv_offset_voltage(unsigned int index)
3768c2ecf20Sopenharmony_ci{
3778c2ecf20Sopenharmony_ci	switch (index) {
3788c2ecf20Sopenharmony_ci	case 1:
3798c2ecf20Sopenharmony_ci		return 12500;
3808c2ecf20Sopenharmony_ci	case 2:
3818c2ecf20Sopenharmony_ci		return 50000;
3828c2ecf20Sopenharmony_ci	case 3:
3838c2ecf20Sopenharmony_ci		return 25000;
3848c2ecf20Sopenharmony_ci	default:
3858c2ecf20Sopenharmony_ci		return 0;
3868c2ecf20Sopenharmony_ci	};
3878c2ecf20Sopenharmony_ci}
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_cistatic void exynos5422_asv_offset_voltage_setup(struct exynos_asv *asv)
3908c2ecf20Sopenharmony_ci{
3918c2ecf20Sopenharmony_ci	struct exynos_asv_subsys *subsys;
3928c2ecf20Sopenharmony_ci	unsigned int reg, value;
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_AUX_INFO, &reg);
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci	/* ARM offset voltage setup */
3978c2ecf20Sopenharmony_ci	subsys = &asv->subsys[EXYNOS_ASV_SUBSYS_ID_ARM];
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci	subsys->base_volt = 1000000;
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci	value = (reg >> EXYNOS5422_ARM_UP_OFFSET) & EXYNOS5422_ARM_UP_MASK;
4028c2ecf20Sopenharmony_ci	subsys->offset_volt_h = __asv_offset_voltage(value);
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci	value = (reg >> EXYNOS5422_ARM_DN_OFFSET) & EXYNOS5422_ARM_DN_MASK;
4058c2ecf20Sopenharmony_ci	subsys->offset_volt_l = __asv_offset_voltage(value);
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci	/* KFC offset voltage setup */
4088c2ecf20Sopenharmony_ci	subsys = &asv->subsys[EXYNOS_ASV_SUBSYS_ID_KFC];
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci	subsys->base_volt = 1000000;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	value = (reg >> EXYNOS5422_KFC_UP_OFFSET) & EXYNOS5422_KFC_UP_MASK;
4138c2ecf20Sopenharmony_ci	subsys->offset_volt_h = __asv_offset_voltage(value);
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	value = (reg >> EXYNOS5422_KFC_DN_OFFSET) & EXYNOS5422_KFC_DN_MASK;
4168c2ecf20Sopenharmony_ci	subsys->offset_volt_l = __asv_offset_voltage(value);
4178c2ecf20Sopenharmony_ci}
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistatic int exynos5422_asv_opp_get_voltage(const struct exynos_asv_subsys *subsys,
4208c2ecf20Sopenharmony_ci					  int level, unsigned int volt)
4218c2ecf20Sopenharmony_ci{
4228c2ecf20Sopenharmony_ci	unsigned int asv_volt;
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	if (level >= subsys->table.num_rows)
4258c2ecf20Sopenharmony_ci		return volt;
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	asv_volt = exynos_asv_opp_get_voltage(subsys, level,
4288c2ecf20Sopenharmony_ci					      subsys->asv->group);
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	if (volt > subsys->base_volt)
4318c2ecf20Sopenharmony_ci		asv_volt += subsys->offset_volt_h;
4328c2ecf20Sopenharmony_ci	else
4338c2ecf20Sopenharmony_ci		asv_volt += subsys->offset_volt_l;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	return asv_volt;
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic unsigned int exynos5422_asv_parse_table(unsigned int pkg_id)
4398c2ecf20Sopenharmony_ci{
4408c2ecf20Sopenharmony_ci	return (pkg_id >> EXYNOS5422_TABLE_OFFSET) & EXYNOS5422_TABLE_MASK;
4418c2ecf20Sopenharmony_ci}
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic bool exynos5422_asv_parse_bin2(unsigned int pkg_id)
4448c2ecf20Sopenharmony_ci{
4458c2ecf20Sopenharmony_ci	return (pkg_id >> EXYNOS5422_BIN2_OFFSET) & EXYNOS5422_BIN2_MASK;
4468c2ecf20Sopenharmony_ci}
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cistatic bool exynos5422_asv_parse_sg(unsigned int pkg_id)
4498c2ecf20Sopenharmony_ci{
4508c2ecf20Sopenharmony_ci	return (pkg_id >> EXYNOS5422_USESG_OFFSET) & EXYNOS5422_USESG_MASK;
4518c2ecf20Sopenharmony_ci}
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ciint exynos5422_asv_init(struct exynos_asv *asv)
4548c2ecf20Sopenharmony_ci{
4558c2ecf20Sopenharmony_ci	struct exynos_asv_subsys *subsys;
4568c2ecf20Sopenharmony_ci	unsigned int table_index;
4578c2ecf20Sopenharmony_ci	unsigned int pkg_id;
4588c2ecf20Sopenharmony_ci	bool bin2;
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_PKG_ID, &pkg_id);
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci	if (asv->of_bin == 2) {
4638c2ecf20Sopenharmony_ci		bin2 = true;
4648c2ecf20Sopenharmony_ci		asv->use_sg = false;
4658c2ecf20Sopenharmony_ci	} else {
4668c2ecf20Sopenharmony_ci		asv->use_sg = exynos5422_asv_parse_sg(pkg_id);
4678c2ecf20Sopenharmony_ci		bin2 = exynos5422_asv_parse_bin2(pkg_id);
4688c2ecf20Sopenharmony_ci	}
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci	asv->group = exynos5422_asv_get_group(asv);
4718c2ecf20Sopenharmony_ci	asv->table = exynos5422_asv_parse_table(pkg_id);
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci	exynos5422_asv_offset_voltage_setup(asv);
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci	if (bin2) {
4768c2ecf20Sopenharmony_ci		table_index = 3;
4778c2ecf20Sopenharmony_ci	} else {
4788c2ecf20Sopenharmony_ci		if (asv->table == 2 || asv->table == 3)
4798c2ecf20Sopenharmony_ci			table_index = asv->table - 1;
4808c2ecf20Sopenharmony_ci		else
4818c2ecf20Sopenharmony_ci			table_index = 0;
4828c2ecf20Sopenharmony_ci	}
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci	subsys = &asv->subsys[EXYNOS_ASV_SUBSYS_ID_ARM];
4858c2ecf20Sopenharmony_ci	subsys->cpu_dt_compat = "arm,cortex-a15";
4868c2ecf20Sopenharmony_ci	if (bin2)
4878c2ecf20Sopenharmony_ci		subsys->table.num_rows = ASV_ARM_BIN2_DVFS_NUM;
4888c2ecf20Sopenharmony_ci	else
4898c2ecf20Sopenharmony_ci		subsys->table.num_rows = ASV_ARM_DVFS_NUM;
4908c2ecf20Sopenharmony_ci	subsys->table.num_cols = ASV_GROUPS_NUM + 1;
4918c2ecf20Sopenharmony_ci	subsys->table.buf = (u32 *)asv_arm_table[table_index];
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci	subsys = &asv->subsys[EXYNOS_ASV_SUBSYS_ID_KFC];
4948c2ecf20Sopenharmony_ci	subsys->cpu_dt_compat = "arm,cortex-a7";
4958c2ecf20Sopenharmony_ci	if (bin2)
4968c2ecf20Sopenharmony_ci		subsys->table.num_rows = ASV_KFC_BIN2_DVFS_NUM;
4978c2ecf20Sopenharmony_ci	else
4988c2ecf20Sopenharmony_ci		subsys->table.num_rows = ASV_KFC_DVFS_NUM;
4998c2ecf20Sopenharmony_ci	subsys->table.num_cols = ASV_GROUPS_NUM + 1;
5008c2ecf20Sopenharmony_ci	subsys->table.buf = (u32 *)asv_kfc_table[table_index];
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci	asv->opp_get_voltage = exynos5422_asv_opp_get_voltage;
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci	return 0;
5058c2ecf20Sopenharmony_ci}
506