WIP FPC-III support
[linux/fpc-iii.git] / drivers / soc / samsung / exynos-asv.h
blob3fd1f2acd9995290273dd7a5e17b78ab9d40c411
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
7 * Samsung Exynos SoC Adaptive Supply Voltage support
8 */
9 #ifndef __LINUX_SOC_EXYNOS_ASV_H
10 #define __LINUX_SOC_EXYNOS_ASV_H
12 struct regmap;
14 /* HPM, IDS values to select target group */
15 struct asv_limit_entry {
16 unsigned int hpm;
17 unsigned int ids;
20 struct exynos_asv_table {
21 unsigned int num_rows;
22 unsigned int num_cols;
23 u32 *buf;
26 struct exynos_asv_subsys {
27 struct exynos_asv *asv;
28 const char *cpu_dt_compat;
29 int id;
30 struct exynos_asv_table table;
32 unsigned int base_volt;
33 unsigned int offset_volt_h;
34 unsigned int offset_volt_l;
37 struct exynos_asv {
38 struct device *dev;
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);
44 unsigned int group;
45 unsigned int table;
47 /* True if SG fields from PKG_ID register should be used */
48 bool use_sg;
49 /* ASV bin read from DT */
50 int of_bin;
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,
66 unsigned int level)
68 return __asv_get_table_entry(&subsys->table, level, 0);
71 #endif /* __LINUX_SOC_EXYNOS_ASV_H */