1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
7 * Samsung Exynos SoC Adaptive Supply Voltage support
9 #ifndef __LINUX_SOC_EXYNOS_ASV_H
10 #define __LINUX_SOC_EXYNOS_ASV_H
14 /* HPM, IDS values to select target group */
15 struct asv_limit_entry {
20 struct exynos_asv_table {
21 unsigned int num_rows;
22 unsigned int num_cols;
26 struct exynos_asv_subsys {
27 struct exynos_asv *asv;
28 const char *cpu_dt_compat;
30 struct exynos_asv_table table;
32 unsigned int base_volt;
33 unsigned int offset_volt_h;
34 unsigned int offset_volt_l;
39 struct regmap *chipid_regmap;
40 struct exynos_asv_subsys subsys[2];
42 int (*opp_get_voltage)(const struct exynos_asv_subsys *subs,
43 int level, unsigned int voltage);
47 /* True if SG fields from PKG_ID register should be used */
49 /* ASV bin read from DT */
53 static inline u32 __asv_get_table_entry(const struct exynos_asv_table *table,
54 unsigned int row, unsigned int col)
56 return table->buf[row * (table->num_cols) + col];
59 static inline u32 exynos_asv_opp_get_voltage(const struct exynos_asv_subsys *subsys,
60 unsigned int level, unsigned int group)
62 return __asv_get_table_entry(&subsys->table, level, group + 1);
65 static inline u32 exynos_asv_opp_get_frequency(const struct exynos_asv_subsys *subsys,
68 return __asv_get_table_entry(&subsys->table, level, 0);
71 int exynos_asv_init(struct device *dev, struct regmap *regmap);
73 #endif /* __LINUX_SOC_EXYNOS_ASV_H */