Lines Matching +full:drv +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0
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>
33 #include <dt-bindings/arm/qcom,ids.h>
36 IPQ8062_VERSION = 0,
44 IPQ8074_HAWKEYE_VERSION = 0,
54 struct qcom_cpufreq_drv *drv);
74 struct qcom_cpufreq_drv *drv) in qcom_cpufreq_simple_get_version() argument
84 drv->versions = 1 << *speedbin; in qcom_cpufreq_simple_get_version()
86 return 0; in qcom_cpufreq_simple_get_version()
97 *speed = pte_efuse & 0xf; in get_krait_bin_format_a()
98 if (*speed == 0xf) in get_krait_bin_format_a()
99 *speed = (pte_efuse >> 4) & 0xf; in get_krait_bin_format_a()
101 if (*speed == 0xf) { in get_krait_bin_format_a()
102 *speed = 0; in get_krait_bin_format_a()
108 *pvs = (pte_efuse >> 10) & 0x7; in get_krait_bin_format_a()
109 if (*pvs == 0x7) in get_krait_bin_format_a()
110 *pvs = (pte_efuse >> 13) & 0x7; in get_krait_bin_format_a()
112 if (*pvs == 0x7) { in get_krait_bin_format_a()
113 *pvs = 0; in get_krait_bin_format_a()
127 redundant_sel = (pte_efuse >> 24) & 0x7; in get_krait_bin_format_b()
129 *pvs_ver = (pte_efuse >> 4) & 0x3; in get_krait_bin_format_b()
133 *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7); in get_krait_bin_format_b()
134 *speed = (pte_efuse >> 27) & 0xf; in get_krait_bin_format_b()
137 *pvs = (pte_efuse >> 27) & 0xf; in get_krait_bin_format_b()
138 *speed = pte_efuse & 0x7; in get_krait_bin_format_b()
141 /* 4 bits of PVS are in efuse register bits 31, 8-6. */ in get_krait_bin_format_b()
142 *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7); in get_krait_bin_format_b()
143 *speed = pte_efuse & 0x7; in get_krait_bin_format_b()
150 dev_warn(cpu_dev, "Speed bin not set. Defaulting to 0!\n"); in get_krait_bin_format_b()
151 *speed = 0; in get_krait_bin_format_b()
160 dev_warn(cpu_dev, "PVS bin not set. Defaulting to 0!\n"); in get_krait_bin_format_b()
161 *pvs = 0; in get_krait_bin_format_b()
170 struct qcom_cpufreq_drv *drv) in qcom_cpufreq_kryo_name_version() argument
200 drv->versions = 1 << (unsigned int)(*speedbin); in qcom_cpufreq_kryo_name_version()
204 drv->versions = 1 << ((unsigned int)(*speedbin) + 4); in qcom_cpufreq_kryo_name_version()
212 return 0; in qcom_cpufreq_kryo_name_version()
218 struct qcom_cpufreq_drv *drv) in qcom_cpufreq_krait_name_version() argument
220 int speed = 0, pvs = 0, pvs_ver = 0; in qcom_cpufreq_krait_name_version()
223 int ret = 0; in qcom_cpufreq_krait_name_version()
239 dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n"); in qcom_cpufreq_krait_name_version()
240 ret = -ENODEV; in qcom_cpufreq_krait_name_version()
244 snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d", in qcom_cpufreq_krait_name_version()
247 drv->versions = (1 << speed); in qcom_cpufreq_krait_name_version()
257 struct qcom_cpufreq_drv *drv) in qcom_cpufreq_ipq8064_name_version() argument
259 int speed = 0, pvs = 0; in qcom_cpufreq_ipq8064_name_version()
260 int msm_id, ret = 0; in qcom_cpufreq_ipq8064_name_version()
269 dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n"); in qcom_cpufreq_ipq8064_name_version()
270 ret = -ENODEV; in qcom_cpufreq_ipq8064_name_version()
282 drv->versions = BIT(IPQ8062_VERSION); in qcom_cpufreq_ipq8064_name_version()
287 drv->versions = BIT(IPQ8064_VERSION); in qcom_cpufreq_ipq8064_name_version()
291 drv->versions = BIT(IPQ8065_VERSION); in qcom_cpufreq_ipq8064_name_version()
297 drv->versions = BIT(IPQ8062_VERSION); in qcom_cpufreq_ipq8064_name_version()
302 snprintf(*pvs_name, sizeof("speed0-pvsXX"), "speed0-pvs%d", pvs); in qcom_cpufreq_ipq8064_name_version()
312 struct qcom_cpufreq_drv *drv) in qcom_cpufreq_ipq6018_name_version() argument
333 * --------------------------------- in qcom_cpufreq_ipq6018_name_version()
334 * 2’b0 No Limit BIT(0) in qcom_cpufreq_ipq6018_name_version()
337 drv->versions = 1 << (unsigned int)(*speedbin); in qcom_cpufreq_ipq6018_name_version()
342 * speed-bin, but that is not enough for IPQ6000 which in qcom_cpufreq_ipq6018_name_version()
346 drv->versions = IPQ6000_VERSION; in qcom_cpufreq_ipq6018_name_version()
352 drv->versions = IPQ6000_VERSION; in qcom_cpufreq_ipq6018_name_version()
357 return 0; in qcom_cpufreq_ipq6018_name_version()
363 struct qcom_cpufreq_drv *drv) in qcom_cpufreq_ipq8074_name_version() argument
379 drv->versions = BIT(IPQ8074_ACORN_VERSION); in qcom_cpufreq_ipq8074_name_version()
385 drv->versions = BIT(IPQ8074_HAWKEYE_VERSION); in qcom_cpufreq_ipq8074_name_version()
391 drv->versions = BIT(IPQ8074_ACORN_VERSION); in qcom_cpufreq_ipq8074_name_version()
395 return 0; in qcom_cpufreq_ipq8074_name_version()
431 static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) in qcom_cpufreq_suspend_virt_devs() argument
433 const char * const *name = drv->data->genpd_names; in qcom_cpufreq_suspend_virt_devs()
436 if (!drv->cpus[cpu].virt_devs) in qcom_cpufreq_suspend_virt_devs()
439 for (i = 0; *name; i++, name++) in qcom_cpufreq_suspend_virt_devs()
440 device_set_awake_path(drv->cpus[cpu].virt_devs[i]); in qcom_cpufreq_suspend_virt_devs()
443 static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) in qcom_cpufreq_put_virt_devs() argument
445 const char * const *name = drv->data->genpd_names; in qcom_cpufreq_put_virt_devs()
448 if (!drv->cpus[cpu].virt_devs) in qcom_cpufreq_put_virt_devs()
451 for (i = 0; *name; i++, name++) in qcom_cpufreq_put_virt_devs()
452 pm_runtime_put(drv->cpus[cpu].virt_devs[i]); in qcom_cpufreq_put_virt_devs()
457 struct qcom_cpufreq_drv *drv; in qcom_cpufreq_probe() local
460 char pvs_name_buffer[] = "speedXX-pvsXX-vXX"; in qcom_cpufreq_probe()
466 cpu_dev = get_cpu_device(0); in qcom_cpufreq_probe()
468 return -ENODEV; in qcom_cpufreq_probe()
473 return -ENOENT; in qcom_cpufreq_probe()
475 ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu") || in qcom_cpufreq_probe()
476 of_device_is_compatible(np, "operating-points-v2-krait-cpu"); in qcom_cpufreq_probe()
478 return -ENOENT; in qcom_cpufreq_probe()
480 drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()), in qcom_cpufreq_probe()
482 if (!drv) in qcom_cpufreq_probe()
483 return -ENOMEM; in qcom_cpufreq_probe()
485 match = pdev->dev.platform_data; in qcom_cpufreq_probe()
486 drv->data = match->data; in qcom_cpufreq_probe()
487 if (!drv->data) in qcom_cpufreq_probe()
488 return -ENODEV; in qcom_cpufreq_probe()
490 if (drv->data->get_version) { in qcom_cpufreq_probe()
496 ret = drv->data->get_version(cpu_dev, in qcom_cpufreq_probe()
497 speedbin_nvmem, &pvs_name, drv); in qcom_cpufreq_probe()
513 ret = -ENODEV; in qcom_cpufreq_probe()
517 if (drv->data->get_version) { in qcom_cpufreq_probe()
518 config.supported_hw = &drv->versions; in qcom_cpufreq_probe()
525 if (drv->data->genpd_names) { in qcom_cpufreq_probe()
526 config.genpd_names = drv->data->genpd_names; in qcom_cpufreq_probe()
531 drv->cpus[cpu].opp_token = dev_pm_opp_set_config(cpu_dev, &config); in qcom_cpufreq_probe()
532 if (drv->cpus[cpu].opp_token < 0) { in qcom_cpufreq_probe()
533 ret = drv->cpus[cpu].opp_token; in qcom_cpufreq_probe()
543 for (i = 0; *name; i++, name++) { in qcom_cpufreq_probe()
551 for (j = 0; *name && j < i; j++, name++) in qcom_cpufreq_probe()
557 drv->cpus[cpu].virt_devs = virt_devs; in qcom_cpufreq_probe()
561 cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, in qcom_cpufreq_probe()
562 NULL, 0); in qcom_cpufreq_probe()
564 platform_set_drvdata(pdev, drv); in qcom_cpufreq_probe()
565 return 0; in qcom_cpufreq_probe()
573 qcom_cpufreq_put_virt_devs(drv, cpu); in qcom_cpufreq_probe()
574 dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); in qcom_cpufreq_probe()
581 struct qcom_cpufreq_drv *drv = platform_get_drvdata(pdev); in qcom_cpufreq_remove() local
587 qcom_cpufreq_put_virt_devs(drv, cpu); in qcom_cpufreq_remove()
588 dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); in qcom_cpufreq_remove()
594 struct qcom_cpufreq_drv *drv = dev_get_drvdata(dev); in qcom_cpufreq_suspend() local
598 qcom_cpufreq_suspend_virt_devs(drv, cpu); in qcom_cpufreq_suspend()
600 return 0; in qcom_cpufreq_suspend()
609 .name = "qcom-cpufreq-nvmem",
644 return -ENODEV; in qcom_cpufreq_init()
648 return -ENODEV; in qcom_cpufreq_init()
651 if (unlikely(ret < 0)) in qcom_cpufreq_init()
654 cpufreq_pdev = platform_device_register_data(NULL, "qcom-cpufreq-nvmem", in qcom_cpufreq_init()
655 -1, match, sizeof(*match)); in qcom_cpufreq_init()
657 if (0 == ret) in qcom_cpufreq_init()
658 return 0; in qcom_cpufreq_init()