You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
soc: rockchip: opp_select: Add support to parse rockchip,pvtpll
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Change-Id: Ic6c7b2cc7a17ca1a33245c5c164cf586f33a9064
This commit is contained in:
@@ -59,7 +59,6 @@ struct pvtm_config {
|
||||
int temp_prop[2];
|
||||
const char *tz_name;
|
||||
struct thermal_zone_device *tz;
|
||||
struct regmap *grf;
|
||||
};
|
||||
|
||||
struct lkg_conversion_table {
|
||||
@@ -338,9 +337,6 @@ static int rockchip_parse_pvtm_config(struct device_node *np,
|
||||
if (of_property_read_u32(np, "rockchip,pvtm-offset",
|
||||
&pvtm->offset))
|
||||
return -EINVAL;
|
||||
pvtm->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
|
||||
if (IS_ERR(pvtm->grf))
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if (of_property_read_u32_array(np, "rockchip,pvtm-ch", pvtm->ch, 2))
|
||||
@@ -725,11 +721,11 @@ static unsigned long rockchip_pvtpll_get_rate(struct rockchip_opp_info *info)
|
||||
int i;
|
||||
|
||||
#define MIN_STABLE_DELTA 3
|
||||
regmap_read(info->grf, info->pvtpll_avg_offset, &rate0);
|
||||
regmap_read(info->pvtpll_base, info->pvtpll_avg_offset, &rate0);
|
||||
/* max delay 2ms */
|
||||
for (i = 0; i < 20; i++) {
|
||||
udelay(100);
|
||||
regmap_read(info->grf, info->pvtpll_avg_offset, &rate1);
|
||||
regmap_read(info->pvtpll_base, info->pvtpll_avg_offset, &rate1);
|
||||
delta = abs(rate1 - rate0);
|
||||
rate0 = rate1;
|
||||
if (delta <= MIN_STABLE_DELTA)
|
||||
@@ -854,7 +850,7 @@ static void rockchip_pvtpll_calibrate_opp(struct rockchip_opp_info *info)
|
||||
unsigned long rate, pvtpll_rate, old_rate, cur_rate, delta0, delta1;
|
||||
int i = 0, max_count, step, cur_step, ret;
|
||||
|
||||
if (!info || !info->grf)
|
||||
if (!info || !info->pvtpll_base)
|
||||
return;
|
||||
|
||||
dev_dbg(info->dev, "calibrating opp ...\n");
|
||||
@@ -1051,6 +1047,7 @@ out:
|
||||
}
|
||||
|
||||
static int rockchip_get_pvtm_pvtpll(struct device *dev, struct device_node *np,
|
||||
struct rockchip_opp_info *info,
|
||||
const char *reg_name)
|
||||
{
|
||||
struct regulator *reg;
|
||||
@@ -1067,6 +1064,9 @@ static int rockchip_get_pvtm_pvtpll(struct device *dev, struct device_node *np,
|
||||
return pvtm_value;
|
||||
}
|
||||
|
||||
if (!info || !info->pvtpll_base)
|
||||
return -ENOMEM;
|
||||
|
||||
pvtm = kzalloc(sizeof(*pvtm), GFP_KERNEL);
|
||||
if (!pvtm)
|
||||
return -ENOMEM;
|
||||
@@ -1102,7 +1102,7 @@ static int rockchip_get_pvtm_pvtpll(struct device *dev, struct device_node *np,
|
||||
}
|
||||
usleep_range(pvtm->sample_time, pvtm->sample_time + 100);
|
||||
|
||||
ret = regmap_read(pvtm->grf, pvtm->offset, &pvtm_value);
|
||||
ret = regmap_read(info->pvtpll_base, pvtm->offset, &pvtm_value);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to get pvtm from 0x%x\n", pvtm->offset);
|
||||
goto resetore_volt;
|
||||
@@ -1179,8 +1179,9 @@ static int rockchip_get_pvtm(struct device *dev, struct device_node *np,
|
||||
}
|
||||
|
||||
static void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
|
||||
const char *reg_name, int bin, int process,
|
||||
int *volt_sel, int *scale_sel)
|
||||
struct rockchip_opp_info *info,
|
||||
const char *reg_name, int *volt_sel,
|
||||
int *scale_sel)
|
||||
{
|
||||
struct property *prop = NULL;
|
||||
char name[NAME_MAX];
|
||||
@@ -1188,7 +1189,7 @@ static void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
|
||||
u32 hw = 0;
|
||||
|
||||
if (of_property_read_bool(np, "rockchip,pvtm-pvtpll"))
|
||||
pvtm = rockchip_get_pvtm_pvtpll(dev, np, reg_name);
|
||||
pvtm = rockchip_get_pvtm_pvtpll(dev, np, info, reg_name);
|
||||
else
|
||||
pvtm = rockchip_get_pvtm(dev, np, reg_name);
|
||||
if (pvtm <= 0)
|
||||
@@ -1196,19 +1197,19 @@ static void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
|
||||
|
||||
if (!volt_sel)
|
||||
goto next;
|
||||
if (process >= 0) {
|
||||
if (info->process >= 0) {
|
||||
snprintf(name, sizeof(name),
|
||||
"rockchip,p%d-pvtm-voltage-sel", process);
|
||||
"rockchip,p%d-pvtm-voltage-sel", info->process);
|
||||
prop = of_find_property(np, name, NULL);
|
||||
} else if (bin > 0) {
|
||||
} else if (info->bin > 0) {
|
||||
of_property_read_u32(np, "rockchip,pvtm-hw", &hw);
|
||||
if (hw && (hw & BIT(bin))) {
|
||||
if (hw && (hw & BIT(info->bin))) {
|
||||
sprintf(name, "rockchip,pvtm-voltage-sel-hw");
|
||||
prop = of_find_property(np, name, NULL);
|
||||
}
|
||||
if (!prop) {
|
||||
snprintf(name, sizeof(name),
|
||||
"rockchip,pvtm-voltage-sel-B%d", bin);
|
||||
"rockchip,pvtm-voltage-sel-B%d", info->bin);
|
||||
prop = of_find_property(np, name, NULL);
|
||||
}
|
||||
}
|
||||
@@ -1222,9 +1223,9 @@ next:
|
||||
if (!scale_sel)
|
||||
return;
|
||||
prop = NULL;
|
||||
if (process >= 0) {
|
||||
if (info->process >= 0) {
|
||||
snprintf(name, sizeof(name),
|
||||
"rockchip,p%d-pvtm-scaling-sel", process);
|
||||
"rockchip,p%d-pvtm-scaling-sel", info->process);
|
||||
prop = of_find_property(np, name, NULL);
|
||||
}
|
||||
if (!prop)
|
||||
@@ -1485,8 +1486,8 @@ static void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
|
||||
|
||||
rockchip_of_get_lkg_sel(dev, np, lkg_name, info->process,
|
||||
&lkg_volt_sel, &lkg_scale);
|
||||
rockchip_of_get_pvtm_sel(dev, np, reg_name, info->bin, info->process,
|
||||
&pvtm_volt_sel, &pvtm_scale);
|
||||
rockchip_of_get_pvtm_sel(dev, np, info, reg_name, &pvtm_volt_sel,
|
||||
&pvtm_scale);
|
||||
rockchip_of_get_bin_sel(dev, np, info->bin, &bin_scale);
|
||||
rockchip_of_get_bin_volt_sel(dev, np, info->bin, &bin_volt_sel);
|
||||
info->scale = max3(lkg_scale, pvtm_scale, bin_scale);
|
||||
@@ -1707,6 +1708,10 @@ int rockchip_init_opp_info(struct device *dev, struct rockchip_opp_info *info,
|
||||
info->cci_grf = NULL;
|
||||
}
|
||||
|
||||
info->pvtpll_base = syscon_regmap_lookup_by_phandle(np, "rockchip,pvtpll");
|
||||
if (IS_ERR(info->pvtpll_base))
|
||||
info->pvtpll_base = info->grf;
|
||||
|
||||
ret = rockchip_get_opp_clk(dev, np, info);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@@ -104,6 +104,7 @@ struct rockchip_opp_info {
|
||||
struct mutex dvfs_mutex;
|
||||
const struct rockchip_opp_data *data;
|
||||
struct pvtpll_opp_table *opp_table;
|
||||
struct regmap *pvtpll_base;
|
||||
unsigned int pvtpll_avg_offset;
|
||||
unsigned int pvtpll_min_rate;
|
||||
unsigned int pvtpll_volt_step;
|
||||
|
||||
Reference in New Issue
Block a user