Skip to content

Commit 3518b90

Browse files
finley1226rkhuangtao
authored andcommitted
soc: rockchip: opp_select: Add support to select voltage accroding to bin
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Change-Id: I6244d0c6865efbfb82164b3512e6f66adec45302
1 parent 037690d commit 3518b90

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

drivers/soc/rockchip/rockchip_opp_select.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,21 @@ void rockchip_of_get_bin_sel(struct device *dev, struct device_node *np,
677677
}
678678
EXPORT_SYMBOL(rockchip_of_get_bin_sel);
679679

680+
void rockchip_of_get_bin_volt_sel(struct device *dev, struct device_node *np,
681+
int bin, int *bin_volt_sel)
682+
{
683+
int ret = 0;
684+
685+
if (!bin_volt_sel || bin < 0)
686+
return;
687+
688+
ret = rockchip_get_bin_sel(np, "rockchip,bin-voltage-sel",
689+
bin, bin_volt_sel);
690+
if (!ret)
691+
dev_info(dev, "bin-volt-sel=%d\n", *bin_volt_sel);
692+
}
693+
EXPORT_SYMBOL(rockchip_of_get_bin_volt_sel);
694+
680695
void rockchip_get_soc_info(struct device *dev,
681696
const struct of_device_id *matches,
682697
int *bin, int *process)
@@ -718,6 +733,7 @@ void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
718733
struct device_node *np;
719734
int lkg_scale = 0, pvtm_scale = 0, bin_scale = 0;
720735
int lkg_volt_sel = -EINVAL, pvtm_volt_sel = -EINVAL;
736+
int bin_volt_sel = -EINVAL;
721737

722738
np = of_parse_phandle(dev->of_node, "operating-points-v2", 0);
723739
if (!np) {
@@ -730,10 +746,15 @@ void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
730746
rockchip_of_get_pvtm_sel(dev, np, reg_name, process,
731747
&pvtm_volt_sel, &pvtm_scale);
732748
rockchip_of_get_bin_sel(dev, np, bin, &bin_scale);
749+
rockchip_of_get_bin_volt_sel(dev, np, bin, &bin_volt_sel);
733750
if (scale)
734751
*scale = max3(lkg_scale, pvtm_scale, bin_scale);
735-
if (volt_sel)
736-
*volt_sel = max(lkg_volt_sel, pvtm_volt_sel);
752+
if (volt_sel) {
753+
if (bin_volt_sel >= 0)
754+
*volt_sel = bin_volt_sel;
755+
else
756+
*volt_sel = max(lkg_volt_sel, pvtm_volt_sel);
757+
}
737758

738759
of_node_put(np);
739760
}

include/soc/rockchip/rockchip_opp_select.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
1616
int *volt_sel, int *scale_sel);
1717
void rockchip_of_get_bin_sel(struct device *dev, struct device_node *np,
1818
int bin, int *scale_sel);
19+
void rockchip_of_get_bin_volt_sel(struct device *dev, struct device_node *np,
20+
int bin, int *bin_volt_sel);
1921
int rockchip_get_efuse_value(struct device_node *np, char *porp_name,
2022
int *value);
2123
void rockchip_get_soc_info(struct device *dev,
@@ -56,6 +58,12 @@ static inline void rockchip_of_get_bin_sel(struct device *dev,
5658
{
5759
}
5860

61+
static inline void rockchip_of_get_bin_volt_sel(struct device *dev,
62+
struct device_node *np,
63+
int bin, int *bin_volt_sel)
64+
{
65+
}
66+
5967
static inline int rockchip_get_efuse_value(struct device_node *np,
6068
char *porp_name, int *value)
6169
{

0 commit comments

Comments
 (0)