Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e186eb0c authored by Priyansh Jain's avatar Priyansh Jain Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarPriyansh Jain <quic_priyjain@quicinc.com>
parent c9f18c13
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
// 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 <linux/module.h>
#include <linux/thermal.h>
@@ -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);
+38 −6
Original line number Diff line number Diff line
// 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);
	}