soc: rockchip: Implement rockchip_of_get_leakage()

Change-Id: I6d1bf9ee6957455c2cb6623aa112d918a9fea4d4
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
This commit is contained in:
Finley Xiao
2019-02-14 20:37:43 +08:00
committed by Tao Huang
parent 3967d5965f
commit 8da9fcee28
2 changed files with 36 additions and 0 deletions

View File

@@ -354,6 +354,35 @@ pvtm_value_out:
return ret;
}
int rockchip_of_get_leakage(struct device *dev, char *lkg_name, int *leakage)
{
struct device_node *np;
struct nvmem_cell *cell;
int ret;
np = of_parse_phandle(dev->of_node, "operating-points-v2", 0);
if (!np) {
dev_warn(dev, "OPP-v2 not supported\n");
return -ENOENT;
}
cell = of_nvmem_cell_get(np, "leakage");
if (IS_ERR(cell)) {
ret = rockchip_get_efuse_value(np, lkg_name, leakage);
} else {
nvmem_cell_put(cell);
ret = rockchip_get_efuse_value(np, "leakage", leakage);
}
of_node_put(np);
if (ret) {
dev_err(dev, "Failed to get %s\n", lkg_name);
return -EINVAL;
}
return 0;
}
EXPORT_SYMBOL(rockchip_of_get_leakage);
void rockchip_of_get_lkg_sel(struct device *dev, struct device_node *np,
char *lkg_name, int process,
int *volt_sel, int *scale_sel)

View File

@@ -48,6 +48,7 @@ struct thermal_opp_info {
};
#ifdef CONFIG_ROCKCHIP_OPP
int rockchip_of_get_leakage(struct device *dev, char *lkg_name, int *leakage);
void rockchip_of_get_lkg_sel(struct device *dev, struct device_node *np,
char *lkg_name, int process,
int *volt_sel, int *scale_sel);
@@ -83,6 +84,12 @@ int rockchip_dev_low_temp_adjust(struct thermal_opp_info *info,
int rockchip_dev_high_temp_adjust(struct thermal_opp_info *info,
bool is_high);
#else
static inline int rockchip_of_get_leakage(struct device *dev, char *lkg_name,
int *leakage)
{
return -ENOTSUPP;
}
static inline void rockchip_of_get_lkg_sel(struct device *dev,
struct device_node *np,
char *lkg_name, int process,