diff --git a/drivers/cpufreq/rockchip-cpufreq.c b/drivers/cpufreq/rockchip-cpufreq.c index 206f47335503..173da325ce6d 100644 --- a/drivers/cpufreq/rockchip-cpufreq.c +++ b/drivers/cpufreq/rockchip-cpufreq.c @@ -58,14 +58,15 @@ static LIST_HEAD(cluster_info_list); static int px30_get_soc_info(struct device *dev, struct device_node *np, int *bin, int *process) { - int ret = 0, value = -EINVAL; + int ret = 0; + u8 value = 0; if (!bin) return 0; if (of_property_match_string(np, "nvmem-cell-names", "performance") >= 0) { - ret = rockchip_get_efuse_value(np, "performance", &value); + ret = rockchip_nvmem_cell_read_u8(np, "performance", &value); if (ret) { dev_err(dev, "Failed to get soc performance value\n"); return ret; @@ -81,13 +82,14 @@ static int px30_get_soc_info(struct device *dev, struct device_node *np, static int rk3288_get_soc_info(struct device *dev, struct device_node *np, int *bin, int *process) { - int ret = 0, value = -EINVAL; + int ret = 0; + u8 value = 0; char *name; if (!bin) goto next; if (of_property_match_string(np, "nvmem-cell-names", "special") >= 0) { - ret = rockchip_get_efuse_value(np, "special", &value); + ret = rockchip_nvmem_cell_read_u8(np, "special", &value); if (ret) { dev_err(dev, "Failed to get soc special value\n"); goto out; @@ -104,7 +106,7 @@ static int rk3288_get_soc_info(struct device *dev, struct device_node *np, name = "performance"; if (of_property_match_string(np, "nvmem-cell-names", name) >= 0) { - ret = rockchip_get_efuse_value(np, name, &value); + ret = rockchip_nvmem_cell_read_u8(np, name, &value); if (ret) { dev_err(dev, "Failed to get soc performance value\n"); goto out; @@ -122,7 +124,7 @@ next: goto out; if (of_property_match_string(np, "nvmem-cell-names", "process") >= 0) { - ret = rockchip_get_efuse_value(np, "process", &value); + ret = rockchip_nvmem_cell_read_u8(np, "process", &value); if (ret) { dev_err(dev, "Failed to get soc process version\n"); goto out; @@ -140,16 +142,17 @@ out: static int rk3399_get_soc_info(struct device *dev, struct device_node *np, int *bin, int *process) { - int ret = 0, value = -EINVAL; + int ret = 0; + u8 value = 0; if (!bin) return 0; if (of_property_match_string(np, "nvmem-cell-names", "specification_serial_number") >= 0) { - ret = rockchip_get_efuse_value(np, - "specification_serial_number", - &value); + ret = rockchip_nvmem_cell_read_u8(np, + "specification_serial_number", + &value); if (ret) { dev_err(dev, "Failed to get specification_serial_number\n"); @@ -161,9 +164,9 @@ static int rk3399_get_soc_info(struct device *dev, struct device_node *np, } else if (value == 0x1) { if (of_property_match_string(np, "nvmem-cell-names", "customer_demand") >= 0) { - ret = rockchip_get_efuse_value(np, - "customer_demand", - &value); + ret = rockchip_nvmem_cell_read_u8(np, + "customer_demand", + &value); if (ret) { dev_err(dev, "Failed to get customer_demand\n"); goto out; @@ -188,10 +191,11 @@ out: static int rv1126_get_soc_info(struct device *dev, struct device_node *np, int *bin, int *process) { - int ret = 0, value = -EINVAL; + int ret = 0; + u8 value = 0; if (of_property_match_string(np, "nvmem-cell-names", "performance") >= 0) { - ret = rockchip_get_efuse_value(np, "performance", &value); + ret = rockchip_nvmem_cell_read_u8(np, "performance", &value); if (ret) { dev_err(dev, "Failed to get soc performance value\n"); return ret; diff --git a/drivers/gpu/arm/midgard/platform/rk/mali_kbase_config_rk.c b/drivers/gpu/arm/midgard/platform/rk/mali_kbase_config_rk.c index f48ce67cb569..9c71a78f95d7 100644 --- a/drivers/gpu/arm/midgard/platform/rk/mali_kbase_config_rk.c +++ b/drivers/gpu/arm/midgard/platform/rk/mali_kbase_config_rk.c @@ -434,7 +434,8 @@ static void kbase_platform_rk_remove_sysfs_files(struct device *dev) static int rk3288_get_soc_info(struct device *dev, struct device_node *np, int *bin, int *process) { - int ret = -EINVAL, value = -EINVAL; + int ret = -EINVAL; + u8 value = 0; char *name; if (!bin) @@ -445,7 +446,7 @@ static int rk3288_get_soc_info(struct device *dev, struct device_node *np, else name = "performance"; if (of_property_match_string(np, "nvmem-cell-names", name) >= 0) { - ret = rockchip_get_efuse_value(np, name, &value); + ret = rockchip_nvmem_cell_read_u8(np, name, &value); if (ret) { dev_err(dev, "Failed to get soc performance value\n"); goto out; diff --git a/drivers/soc/rockchip/rockchip_opp_select.c b/drivers/soc/rockchip/rockchip_opp_select.c index 34e9be1a5fcc..1520e2f96ea6 100644 --- a/drivers/soc/rockchip/rockchip_opp_select.c +++ b/drivers/soc/rockchip/rockchip_opp_select.c @@ -22,7 +22,6 @@ #define MAX_PROP_NAME_LEN 6 #define SEL_TABLE_END ~1 -#define LEAKAGE_INVALID 0xff #define AVS_DELETE_OPP 0 #define AVS_SCALING_RATE 1 @@ -120,35 +119,6 @@ static const struct lkg_conversion_table conv_table[] = { { 400, 53 }, }; -int rockchip_get_efuse_value(struct device_node *np, char *porp_name, - int *value) -{ - struct nvmem_cell *cell; - unsigned char *buf; - size_t len; - - cell = of_nvmem_cell_get(np, porp_name); - if (IS_ERR(cell)) - return PTR_ERR(cell); - - buf = (unsigned char *)nvmem_cell_read(cell, &len); - - nvmem_cell_put(cell); - - if (IS_ERR(buf)) - return PTR_ERR(buf); - - if (buf[0] == LEAKAGE_INVALID) - return -EINVAL; - - *value = buf[0]; - - kfree(buf); - - return 0; -} -EXPORT_SYMBOL(rockchip_get_efuse_value); - static int rockchip_nvmem_cell_read_common(struct device_node *np, const char *cell_id, void *val, size_t count) @@ -178,19 +148,19 @@ static int rockchip_nvmem_cell_read_common(struct device_node *np, return 0; } -static int rockchip_nvmem_cell_read_u8(struct device_node *np, - const char *cell_id, - u8 *val) +int rockchip_nvmem_cell_read_u8(struct device_node *np, const char *cell_id, + u8 *val) { return rockchip_nvmem_cell_read_common(np, cell_id, val, sizeof(*val)); } +EXPORT_SYMBOL(rockchip_nvmem_cell_read_u8); -static int rockchip_nvmem_cell_read_u16(struct device_node *np, - const char *cell_id, - u16 *val) +int rockchip_nvmem_cell_read_u16(struct device_node *np, const char *cell_id, + u16 *val) { return rockchip_nvmem_cell_read_common(np, cell_id, val, sizeof(*val)); } +EXPORT_SYMBOL(rockchip_nvmem_cell_read_u16); static int rockchip_get_sel_table(struct device_node *np, char *porp_name, struct sel_table **table) @@ -503,7 +473,8 @@ static int rockchip_adjust_leakage(struct device *dev, struct device_node *np, int *leakage) { struct nvmem_cell *cell; - u32 value = 0, temp; + u8 value = 0; + u32 temp; int conversion; int ret; @@ -511,7 +482,7 @@ static int rockchip_adjust_leakage(struct device *dev, struct device_node *np, if (IS_ERR(cell)) goto next; nvmem_cell_put(cell); - ret = rockchip_get_efuse_value(np, "leakage_temp", &value); + ret = rockchip_nvmem_cell_read_u8(np, "leakage_temp", &value); if (ret) { dev_err(dev, "Failed to get leakage temp\n"); return -EINVAL; @@ -523,7 +494,8 @@ static int rockchip_adjust_leakage(struct device *dev, struct device_node *np, * The ambient temp : temp = (temp_efuse / 63) * (40 - 20) + 20 * Reserves a decimal point : temp = temp * 10 */ - temp = mul_frac((int_to_frac(value) / 63 * 20 + int_to_frac(20)), + temp = value; + temp = mul_frac((int_to_frac(temp) / 63 * 20 + int_to_frac(20)), int_to_frac(10)); conversion = temp_to_conversion_rate(frac_to_int(temp)); *leakage = *leakage * conversion / 100; @@ -533,7 +505,7 @@ next: if (IS_ERR(cell)) return 0; nvmem_cell_put(cell); - ret = rockchip_get_efuse_value(np, "leakage_volt", &value); + ret = rockchip_nvmem_cell_read_u8(np, "leakage_volt", &value); if (ret) { dev_err(dev, "Failed to get leakage volt\n"); return -EINVAL; @@ -569,16 +541,19 @@ static int rockchip_get_leakage_v1(struct device *dev, struct device_node *np, { struct nvmem_cell *cell; int ret = 0; + u8 value = 0; cell = of_nvmem_cell_get(np, "leakage"); if (IS_ERR(cell)) { - ret = rockchip_get_efuse_value(np, lkg_name, leakage); + ret = rockchip_nvmem_cell_read_u8(np, lkg_name, &value); } else { nvmem_cell_put(cell); - ret = rockchip_get_efuse_value(np, "leakage", leakage); + ret = rockchip_nvmem_cell_read_u8(np, "leakage", &value); } if (ret) dev_err(dev, "Failed to get %s\n", lkg_name); + else + *leakage = value; return ret; } diff --git a/drivers/video/rockchip/mpp/mpp_rkvenc.c b/drivers/video/rockchip/mpp/mpp_rkvenc.c index 1fc3c244e7f0..bbe82497f15f 100644 --- a/drivers/video/rockchip/mpp/mpp_rkvenc.c +++ b/drivers/video/rockchip/mpp/mpp_rkvenc.c @@ -964,10 +964,11 @@ static struct monitor_dev_profile enc_mdevp = { static int rv1126_get_soc_info(struct device *dev, struct device_node *np, int *bin, int *process) { - int ret = 0, value = -EINVAL; + int ret = 0; + u8 value = 0; if (of_property_match_string(np, "nvmem-cell-names", "performance") >= 0) { - ret = rockchip_get_efuse_value(np, "performance", &value); + ret = rockchip_nvmem_cell_read_u8(np, "performance", &value); if (ret) { dev_err(dev, "Failed to get soc performance value\n"); return ret; diff --git a/include/soc/rockchip/rockchip_opp_select.h b/include/soc/rockchip/rockchip_opp_select.h index 4dc0d9b8789f..e31c36c7f506 100644 --- a/include/soc/rockchip/rockchip_opp_select.h +++ b/include/soc/rockchip/rockchip_opp_select.h @@ -18,8 +18,10 @@ void rockchip_of_get_bin_sel(struct device *dev, struct device_node *np, int bin, int *scale_sel); void rockchip_of_get_bin_volt_sel(struct device *dev, struct device_node *np, int bin, int *bin_volt_sel); -int rockchip_get_efuse_value(struct device_node *np, char *porp_name, - int *value); +int rockchip_nvmem_cell_read_u8(struct device_node *np, const char *cell_id, + u8 *val); +int rockchip_nvmem_cell_read_u16(struct device_node *np, const char *cell_id, + u16 *val); void rockchip_get_soc_info(struct device *dev, const struct of_device_id *matches, int *bin, int *process); @@ -65,10 +67,16 @@ static inline void rockchip_of_get_bin_volt_sel(struct device *dev, { } -static inline int rockchip_get_efuse_value(struct device_node *np, - char *porp_name, int *value) +static inline int rockchip_nvmem_cell_read_u8(struct device_node *np, + const char *cell_id, u8 *val) { - return -ENOTSUPP; + return -EOPNOTSUPP; +} + +static inline int rockchip_nvmem_cell_read_u16(struct device_node *np, + const char *cell_id, u16 *val) +{ + return -EOPNOTSUPP; } static inline void rockchip_get_soc_info(struct device *dev,