Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

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>

authored by

Christian Marangi and committed by
Viresh Kumar
58f5d39d 1971b187

+33 -2
+33 -2
drivers/cpufreq/qcom-cpufreq-nvmem.c
··· 256 256 return ret; 257 257 } 258 258 259 + static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = { 260 + { .compatible = "qcom,ipq8062", .data = (const void *)QCOM_ID_IPQ8062 }, 261 + { .compatible = "qcom,ipq8064", .data = (const void *)QCOM_ID_IPQ8064 }, 262 + { .compatible = "qcom,ipq8065", .data = (const void *)QCOM_ID_IPQ8065 }, 263 + { .compatible = "qcom,ipq8066", .data = (const void *)QCOM_ID_IPQ8066 }, 264 + { .compatible = "qcom,ipq8068", .data = (const void *)QCOM_ID_IPQ8068 }, 265 + { .compatible = "qcom,ipq8069", .data = (const void *)QCOM_ID_IPQ8069 }, 266 + }; 267 + 259 268 static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, 260 269 struct nvmem_cell *speedbin_nvmem, 261 270 char **pvs_name, 262 271 struct qcom_cpufreq_drv *drv) 263 272 { 273 + int msm_id = -1, ret = 0; 264 274 int speed = 0, pvs = 0; 265 - int msm_id, ret = 0; 266 275 u8 *speedbin; 267 276 size_t len; 268 277 ··· 288 279 get_krait_bin_format_a(cpu_dev, &speed, &pvs, speedbin); 289 280 290 281 ret = qcom_smem_get_soc_id(&msm_id); 291 - if (ret) 282 + if (ret == -ENODEV) { 283 + const struct of_device_id *match; 284 + struct device_node *root; 285 + 286 + root = of_find_node_by_path("/"); 287 + if (!root) { 288 + ret = -ENODEV; 289 + goto exit; 290 + } 291 + 292 + /* Fallback to compatible match with no SMEM initialized */ 293 + match = of_match_node(qcom_cpufreq_ipq806x_match_list, root); 294 + of_node_put(root); 295 + if (!match) { 296 + ret = -ENODEV; 297 + goto exit; 298 + } 299 + 300 + /* We found a matching device, get the msm_id from the data entry */ 301 + msm_id = (int)(uintptr_t)match->data; 302 + ret = 0; 303 + } else if (ret) { 292 304 goto exit; 305 + } 293 306 294 307 switch (msm_id) { 295 308 case QCOM_ID_IPQ8062: