From e186eb0c0caf9ec883afd6c426a216e7aeaf9f90 Mon Sep 17 00:00:00 2001 From: Priyansh Jain Date: Tue, 12 Jul 2022 10:52:03 +0530 Subject: [PATCH] drivers: thermal: Dynamic cpu's support in cpu voltage cooling driver Add support for dynamic cpu's in cpu voltage cooling driver. Change-Id: Id8dd7800d230e657c16d853da673cb5e9aaf3ca6 Signed-off-by: Priyansh Jain --- drivers/thermal/qcom/cpu_isolate.c | 7 ++++ drivers/thermal/qcom/cpu_voltage_cooling.c | 44 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/qcom/cpu_isolate.c b/drivers/thermal/qcom/cpu_isolate.c index ff2621df8003..0e3821c258bf 100644 --- a/drivers/thermal/qcom/cpu_isolate.c +++ b/drivers/thermal/qcom/cpu_isolate.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -320,6 +321,12 @@ static int cpu_isolate_probe(struct platform_device *pdev) break; } } + + if (cpu_isolate_cdev->cpu_id == -1) { + dev_err(&pdev->dev, "Invalid CPU phandle\n"); + continue; + } + INIT_WORK(&cpu_isolate_cdev->reg_work, cpu_isolate_register_cdev); list_add(&cpu_isolate_cdev->node, &cpu_isolate_cdev_list); diff --git a/drivers/thermal/qcom/cpu_voltage_cooling.c b/drivers/thermal/qcom/cpu_voltage_cooling.c index d0c235e5ce6d..54402dcf024b 100644 --- a/drivers/thermal/qcom/cpu_voltage_cooling.c +++ b/drivers/thermal/qcom/cpu_voltage_cooling.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. */ #define pr_fmt(fmt) "%s:%s " fmt, KBUILD_MODNAME, __func__ @@ -282,8 +283,7 @@ static int cc_init(struct device_node *np, int *cpus) } } snprintf(cc_cdev->cdev_name, THERMAL_NAME_LENGTH, - "thermal-cluster-%d-%d", cc_cdev->cpu_map[0], - cc_cdev->cpu_map[1]); + np->name); cc_cdev->cdev = thermal_of_cooling_device_register( np, cc_cdev->cdev_name, cc_cdev, &cc_cooling_ops); @@ -307,21 +307,53 @@ static int cc_cooling_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct device_node *dev_phandle, *subsys_np = NULL; struct device *cpu_dev; - int ret = 0, idx = 0, cpu; + int ret = 0, idx = 0, count = 0, cpu; + int cpu_count = 0; u32 cpu_map[CPU_MAP_CT]; for_each_available_child_of_node(np, subsys_np) { - for (idx = 0; idx < CPU_MAP_CT; idx++) { - dev_phandle = of_parse_phandle(subsys_np, "qcom,cpus", + cpu_count = of_count_phandle_with_args(subsys_np, "qcom,cluster0", + NULL); + for (idx = 0; idx < cpu_count; idx++) { + dev_phandle = of_parse_phandle(subsys_np, "qcom,cluster0", idx); for_each_possible_cpu(cpu) { cpu_dev = get_cpu_device(cpu); if (cpu_dev && cpu_dev->of_node == dev_phandle) { - cpu_map[idx] = cpu; + cpu_map[count] = cpu; + count++; break; } } + if (count) + break; + } + if (!count) { + pr_debug("Disabled as no core on cluster 0\n"); + return ret; + } + + cpu_count = of_count_phandle_with_args(subsys_np, "qcom,cluster1", + NULL); + for (idx = 0; idx < cpu_count; idx++) { + dev_phandle = of_parse_phandle(subsys_np, "qcom,cluster1", + idx); + for_each_possible_cpu(cpu) { + cpu_dev = get_cpu_device(cpu); + if (cpu_dev && cpu_dev->of_node == + dev_phandle) { + cpu_map[count] = cpu; + count++; + break; + } + } + if (count == 2) + break; + } + if (count != 2) { + pr_debug("Disabled as no core on cluster 1\n"); + return ret; } ret = cc_init(subsys_np, cpu_map); }