• Home
  • Raw
  • Download

Lines Matching +full:qcom +full:- +full:cpufreq +full:- +full:nvmem

1 // SPDX-License-Identifier: GPL-2.0
7 * In Certain QCOM SoCs like apq8096 and msm8996 that have KRYO processors,
10 * defines the voltage and frequency value based on the msm-id in SMEM
12 * The qcom-cpufreq-nvmem driver reads the msm-id and efuse value from the SoC
15 * operating-points-v2 table when it is parsed by the OPP framework.
23 #include <linux/nvmem-consumer.h>
30 #include <linux/soc/qcom/smem.h>
119 /* 4 bits of PVS are in efuse register bits 31, 8-6. */ in get_krait_bin_format_b()
155 /* The first 4 bytes are format, next to them is the actual msm-id */ in qcom_cpufreq_get_msm_id()
187 return -ENODEV; in qcom_cpufreq_kryo_name_version()
196 drv->versions = 1 << (unsigned int)(*speedbin); in qcom_cpufreq_kryo_name_version()
199 drv->versions = 1 << ((unsigned int)(*speedbin) + 4); in qcom_cpufreq_kryo_name_version()
235 dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n"); in qcom_cpufreq_krait_name_version()
236 ret = -ENODEV; in qcom_cpufreq_krait_name_version()
240 snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d", in qcom_cpufreq_krait_name_version()
243 drv->versions = (1 << speed); in qcom_cpufreq_krait_name_version()
270 char pvs_name_buffer[] = "speedXX-pvsXX-vXX"; in qcom_cpufreq_probe()
278 return -ENODEV; in qcom_cpufreq_probe()
282 return -ENOENT; in qcom_cpufreq_probe()
284 ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu"); in qcom_cpufreq_probe()
287 return -ENOENT; in qcom_cpufreq_probe()
292 return -ENOMEM; in qcom_cpufreq_probe()
294 match = pdev->dev.platform_data; in qcom_cpufreq_probe()
295 drv->data = match->data; in qcom_cpufreq_probe()
296 if (!drv->data) { in qcom_cpufreq_probe()
297 ret = -ENODEV; in qcom_cpufreq_probe()
301 if (drv->data->get_version) { in qcom_cpufreq_probe()
304 if (PTR_ERR(speedbin_nvmem) != -EPROBE_DEFER) in qcom_cpufreq_probe()
306 "Could not get nvmem cell: %ld\n", in qcom_cpufreq_probe()
312 ret = drv->data->get_version(cpu_dev, in qcom_cpufreq_probe()
322 drv->names_opp_tables = kcalloc(num_possible_cpus(), in qcom_cpufreq_probe()
323 sizeof(*drv->names_opp_tables), in qcom_cpufreq_probe()
325 if (!drv->names_opp_tables) { in qcom_cpufreq_probe()
326 ret = -ENOMEM; in qcom_cpufreq_probe()
329 drv->hw_opp_tables = kcalloc(num_possible_cpus(), in qcom_cpufreq_probe()
330 sizeof(*drv->hw_opp_tables), in qcom_cpufreq_probe()
332 if (!drv->hw_opp_tables) { in qcom_cpufreq_probe()
333 ret = -ENOMEM; in qcom_cpufreq_probe()
337 drv->genpd_opp_tables = kcalloc(num_possible_cpus(), in qcom_cpufreq_probe()
338 sizeof(*drv->genpd_opp_tables), in qcom_cpufreq_probe()
340 if (!drv->genpd_opp_tables) { in qcom_cpufreq_probe()
341 ret = -ENOMEM; in qcom_cpufreq_probe()
348 ret = -ENODEV; in qcom_cpufreq_probe()
352 if (drv->data->get_version) { in qcom_cpufreq_probe()
355 drv->names_opp_tables[cpu] = dev_pm_opp_set_prop_name( in qcom_cpufreq_probe()
358 if (IS_ERR(drv->names_opp_tables[cpu])) { in qcom_cpufreq_probe()
359 ret = PTR_ERR(drv->names_opp_tables[cpu]); in qcom_cpufreq_probe()
366 drv->hw_opp_tables[cpu] = dev_pm_opp_set_supported_hw( in qcom_cpufreq_probe()
367 cpu_dev, &drv->versions, 1); in qcom_cpufreq_probe()
368 if (IS_ERR(drv->hw_opp_tables[cpu])) { in qcom_cpufreq_probe()
369 ret = PTR_ERR(drv->hw_opp_tables[cpu]); in qcom_cpufreq_probe()
376 if (drv->data->genpd_names) { in qcom_cpufreq_probe()
377 drv->genpd_opp_tables[cpu] = in qcom_cpufreq_probe()
379 drv->data->genpd_names, in qcom_cpufreq_probe()
381 if (IS_ERR(drv->genpd_opp_tables[cpu])) { in qcom_cpufreq_probe()
382 ret = PTR_ERR(drv->genpd_opp_tables[cpu]); in qcom_cpufreq_probe()
383 if (ret != -EPROBE_DEFER) in qcom_cpufreq_probe()
392 cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, in qcom_cpufreq_probe()
404 if (IS_ERR_OR_NULL(drv->genpd_opp_tables[cpu])) in qcom_cpufreq_probe()
406 dev_pm_opp_detach_genpd(drv->genpd_opp_tables[cpu]); in qcom_cpufreq_probe()
408 kfree(drv->genpd_opp_tables); in qcom_cpufreq_probe()
411 if (IS_ERR_OR_NULL(drv->names_opp_tables[cpu])) in qcom_cpufreq_probe()
413 dev_pm_opp_put_prop_name(drv->names_opp_tables[cpu]); in qcom_cpufreq_probe()
416 if (IS_ERR_OR_NULL(drv->hw_opp_tables[cpu])) in qcom_cpufreq_probe()
418 dev_pm_opp_put_supported_hw(drv->hw_opp_tables[cpu]); in qcom_cpufreq_probe()
420 kfree(drv->hw_opp_tables); in qcom_cpufreq_probe()
422 kfree(drv->names_opp_tables); in qcom_cpufreq_probe()
437 if (drv->names_opp_tables[cpu]) in qcom_cpufreq_remove()
438 dev_pm_opp_put_supported_hw(drv->names_opp_tables[cpu]); in qcom_cpufreq_remove()
439 if (drv->hw_opp_tables[cpu]) in qcom_cpufreq_remove()
440 dev_pm_opp_put_supported_hw(drv->hw_opp_tables[cpu]); in qcom_cpufreq_remove()
441 if (drv->genpd_opp_tables[cpu]) in qcom_cpufreq_remove()
442 dev_pm_opp_detach_genpd(drv->genpd_opp_tables[cpu]); in qcom_cpufreq_remove()
445 kfree(drv->names_opp_tables); in qcom_cpufreq_remove()
446 kfree(drv->hw_opp_tables); in qcom_cpufreq_remove()
447 kfree(drv->genpd_opp_tables); in qcom_cpufreq_remove()
457 .name = "qcom-cpufreq-nvmem",
462 { .compatible = "qcom,apq8096", .data = &match_data_kryo },
463 { .compatible = "qcom,msm8996", .data = &match_data_kryo },
464 { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
465 { .compatible = "qcom,ipq8064", .data = &match_data_krait },
466 { .compatible = "qcom,apq8064", .data = &match_data_krait },
467 { .compatible = "qcom,msm8974", .data = &match_data_krait },
468 { .compatible = "qcom,msm8960", .data = &match_data_krait },
474 * Since the driver depends on smem and nvmem drivers, which may
486 return -ENODEV; in qcom_cpufreq_init()
491 return -ENODEV; in qcom_cpufreq_init()
497 cpufreq_pdev = platform_device_register_data(NULL, "qcom-cpufreq-nvmem", in qcom_cpufreq_init()
498 -1, match, sizeof(*match)); in qcom_cpufreq_init()
515 MODULE_DESCRIPTION("Qualcomm Technologies, Inc. CPUfreq driver");