mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
soc: rockchip: opp_select: Implement rockchip_set_opp_supported_hw()
This implements new APIs to get soc info and set opp hardware info. Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Change-Id: I167a37f661ce6fc8b32afc7768985fe23e35318c
This commit is contained in:
@@ -1301,6 +1301,65 @@ static int rockchip_get_volt_rm_table(struct device *dev, struct device_node *np
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rockchip_get_soc_info(struct device *dev, struct device_node *np,
|
||||
int *bin, int *process)
|
||||
{
|
||||
u8 value = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (*bin >= 0 || *process >= 0)
|
||||
return 0;
|
||||
|
||||
if (of_property_match_string(np, "nvmem-cell-names",
|
||||
"specification_serial_number") >= 0) {
|
||||
ret = rockchip_nvmem_cell_read_u8(np,
|
||||
"specification_serial_number",
|
||||
&value);
|
||||
if (ret) {
|
||||
dev_err(dev,
|
||||
"Failed to get specification_serial_number\n");
|
||||
return ret;
|
||||
}
|
||||
/* M */
|
||||
if (value == 0xd)
|
||||
*bin = 1;
|
||||
/* J */
|
||||
else if (value == 0xa)
|
||||
*bin = 2;
|
||||
}
|
||||
|
||||
if (*bin < 0)
|
||||
*bin = 0;
|
||||
dev_info(dev, "bin=%d\n", *bin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rockchip_set_opp_supported_hw(struct device *dev,
|
||||
struct device_node *np,
|
||||
struct rockchip_opp_info *info)
|
||||
{
|
||||
u32 version = 0, speed = 0;
|
||||
|
||||
if (!of_property_read_bool(np, "rockchip,supported-hw"))
|
||||
return 0;
|
||||
if (info->supported_hw[0] || info->supported_hw[1])
|
||||
return 0;
|
||||
|
||||
if (info->bin >= 0)
|
||||
version = info->bin;
|
||||
if (info->volt_sel >= 0)
|
||||
speed = info->volt_sel;
|
||||
/* SoC Version */
|
||||
info->supported_hw[0] = BIT(version);
|
||||
/* Speed Grade */
|
||||
info->supported_hw[1] = BIT(speed);
|
||||
|
||||
dev_info(dev, "soc version=%d, speed=%d\n", version, speed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
|
||||
const char *reg_name,
|
||||
struct rockchip_opp_info *info)
|
||||
@@ -1476,11 +1535,13 @@ int rockchip_init_opp_info(struct device *dev, struct rockchip_opp_info *info,
|
||||
|
||||
if (info->data && info->data->get_soc_info)
|
||||
info->data->get_soc_info(dev, np, &info->bin, &info->process);
|
||||
rockchip_get_soc_info(dev, np, &info->bin, &info->process);
|
||||
|
||||
rockchip_get_scale_volt_sel(dev, "leakage", reg_name, info);
|
||||
|
||||
if (info && info->data && info->data->set_soc_info)
|
||||
info->data->set_soc_info(dev, np, info);
|
||||
rockchip_set_opp_supported_hw(dev, np, info);
|
||||
|
||||
ret = rockchip_opp_set_config(dev, info, clk_name, reg_name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user