]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 5 Nov 2025 11:21:34 +0000 (12:21 +0100)
committerViresh Kumar <viresh.kumar@linaro.org>
Mon, 10 Nov 2025 10:46:52 +0000 (16:16 +0530)
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the
case for some Google devices (the OnHub family) that can't make use of
SMEM to detect the SoC ID (and socinfo can't be used either as it does
depends on SMEM presence).

To handle these specific case, check if the SMEM is not initialized (by
checking if the qcom_smem_get_soc_id returns -ENODEV) and fallback to
OF machine compatible checking to identify the SoC variant.

Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/qcom-cpufreq-nvmem.c

index 765a5bb81829e1bbd584fd7e30139966c911f104..d5af74bf71c6e719990ea0bc549cdf07adeeca58 100644 (file)
@@ -256,13 +256,22 @@ len_error:
        return ret;
 }
 
+static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = {
+       { .compatible = "qcom,ipq8062", .data = (const void *)QCOM_ID_IPQ8062 },
+       { .compatible = "qcom,ipq8064", .data = (const void *)QCOM_ID_IPQ8064 },
+       { .compatible = "qcom,ipq8065", .data = (const void *)QCOM_ID_IPQ8065 },
+       { .compatible = "qcom,ipq8066", .data = (const void *)QCOM_ID_IPQ8066 },
+       { .compatible = "qcom,ipq8068", .data = (const void *)QCOM_ID_IPQ8068 },
+       { .compatible = "qcom,ipq8069", .data = (const void *)QCOM_ID_IPQ8069 },
+};
+
 static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
                                             struct nvmem_cell *speedbin_nvmem,
                                             char **pvs_name,
                                             struct qcom_cpufreq_drv *drv)
 {
+       int msm_id = -1, ret = 0;
        int speed = 0, pvs = 0;
-       int msm_id, ret = 0;
        u8 *speedbin;
        size_t len;
 
@@ -279,8 +288,30 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
        get_krait_bin_format_a(cpu_dev, &speed, &pvs, speedbin);
 
        ret = qcom_smem_get_soc_id(&msm_id);
-       if (ret)
+       if (ret == -ENODEV) {
+               const struct of_device_id *match;
+               struct device_node *root;
+
+               root = of_find_node_by_path("/");
+               if (!root) {
+                       ret = -ENODEV;
+                       goto exit;
+               }
+
+               /* Fallback to compatible match with no SMEM initialized */
+               match = of_match_node(qcom_cpufreq_ipq806x_match_list, root);
+               of_node_put(root);
+               if (!match) {
+                       ret = -ENODEV;
+                       goto exit;
+               }
+
+               /* We found a matching device, get the msm_id from the data entry */
+               msm_id = (int)(uintptr_t)match->data;
+               ret = 0;
+       } else if (ret) {
                goto exit;
+       }
 
        switch (msm_id) {
        case QCOM_ID_IPQ8062: