diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index 1e38f4e00a2363..c7128c450e05be 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -82,6 +82,31 @@ static int qcom_cpufreq_simple_get_version(struct device *cpu_dev, return 0; } +static int qcom_cpufreq_msm8916_get_version(struct device *cpu_dev, + struct device_node *np, + char **pvs_name, + struct qcom_cpufreq_drv *drv) +{ + u8 *pvs, *speedbin; + + *pvs_name = NULL; + pvs = qcom_cpufreq_read_nvmem_cell(np, "pvs", NULL); + if (IS_ERR(pvs)) + return PTR_ERR(pvs); + + speedbin = qcom_cpufreq_read_nvmem_cell(np, *pvs ? "bin2" : "bin1", NULL); + if (IS_ERR(speedbin)) { + kfree(pvs); + return PTR_ERR(speedbin); + } + + dev_dbg(cpu_dev, "speedbin: %d (pvs: %d)\n", *speedbin, *pvs); + drv->versions = 1 << *speedbin; + kfree(speedbin); + kfree(pvs); + return 0; +} + static void get_krait_bin_format_a(struct device *cpu_dev, int *speed, int *pvs, int *pvs_ver, u8 *buf) @@ -251,6 +276,13 @@ static const struct qcom_cpufreq_match_data match_data_msm8909 = { .genpd_names = msm8909_genpd_names, }; +static const char *msm8916_genpd_names[] = { "mx", "apc", "cx", NULL }; + +static const struct qcom_cpufreq_match_data match_data_msm8916 = { + .get_version = qcom_cpufreq_msm8916_get_version, + .genpd_names = msm8916_genpd_names, +}; + static const char *qcs404_genpd_names[] = { "cpr", NULL }; static const struct qcom_cpufreq_match_data match_data_qcs404 = { @@ -403,6 +435,8 @@ static struct platform_driver qcom_cpufreq_driver = { static const struct of_device_id qcom_cpufreq_match_list[] __initconst = { { .compatible = "qcom,msm8909", .data = &match_data_msm8909 }, + { .compatible = "qcom,msm8916", .data = &match_data_msm8916 }, + { .compatible = "qcom,apq8016", .data = &match_data_msm8916 }, { .compatible = "qcom,apq8096", .data = &match_data_kryo }, { .compatible = "qcom,msm8996", .data = &match_data_kryo }, { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },