Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
0004  *        http://www.samsung.com/
0005  * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
0006  *
0007  * Samsung Exynos SoC Adaptive Supply Voltage support
0008  */
0009 #ifndef __LINUX_SOC_EXYNOS_ASV_H
0010 #define __LINUX_SOC_EXYNOS_ASV_H
0011 
0012 struct regmap;
0013 
0014 /* HPM, IDS values to select target group */
0015 struct asv_limit_entry {
0016     unsigned int hpm;
0017     unsigned int ids;
0018 };
0019 
0020 struct exynos_asv_table {
0021     unsigned int num_rows;
0022     unsigned int num_cols;
0023     u32 *buf;
0024 };
0025 
0026 struct exynos_asv_subsys {
0027     struct exynos_asv *asv;
0028     const char *cpu_dt_compat;
0029     int id;
0030     struct exynos_asv_table table;
0031 
0032     unsigned int base_volt;
0033     unsigned int offset_volt_h;
0034     unsigned int offset_volt_l;
0035 };
0036 
0037 struct exynos_asv {
0038     struct device *dev;
0039     struct regmap *chipid_regmap;
0040     struct exynos_asv_subsys subsys[2];
0041 
0042     int (*opp_get_voltage)(const struct exynos_asv_subsys *subs,
0043                    int level, unsigned int voltage);
0044     unsigned int group;
0045     unsigned int table;
0046 
0047     /* True if SG fields from PKG_ID register should be used */
0048     bool use_sg;
0049     /* ASV bin read from DT */
0050     int of_bin;
0051 };
0052 
0053 static inline u32 __asv_get_table_entry(const struct exynos_asv_table *table,
0054                     unsigned int row, unsigned int col)
0055 {
0056     return table->buf[row * (table->num_cols) + col];
0057 }
0058 
0059 static inline u32 exynos_asv_opp_get_voltage(const struct exynos_asv_subsys *subsys,
0060                     unsigned int level, unsigned int group)
0061 {
0062     return __asv_get_table_entry(&subsys->table, level, group + 1);
0063 }
0064 
0065 static inline u32 exynos_asv_opp_get_frequency(const struct exynos_asv_subsys *subsys,
0066                     unsigned int level)
0067 {
0068     return __asv_get_table_entry(&subsys->table, level, 0);
0069 }
0070 
0071 int exynos_asv_init(struct device *dev, struct regmap *regmap);
0072 
0073 #endif /* __LINUX_SOC_EXYNOS_ASV_H */