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

Commit e1709678 authored by Amit Nischal's avatar Amit Nischal Committed by Gerrit - the friendly Code Review server
Browse files

clk: qcom: Update logic to get the cpu node



Current logic to get the cpu node works fine with cpu reg
property with address-cells equal to 1 but for latest
kernel version, address-cells could be 1 or 2 depending upon
the MPIDR_EL1 register size. So add support for the same by
updating the logic to get cpu node value.

Change-Id: I23413e7b148f636bd72aa8c1a15a1aec3c52b9c5
Signed-off-by: default avatarAmit Nischal <anischal@codeaurora.org>
parent ddbece73
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -230,19 +230,31 @@ static struct cpu_clk_8939 *cpuclk[] = { &a53_bc_clk, &a53_lc_clk, &cci_clk};

static struct clk *logical_cpu_to_clk(int cpu)
{
	struct device_node *cpu_node = of_get_cpu_node(cpu, NULL);
	u32 reg;
	struct device_node *cpu_node;
	const u32 *cell;
	u64 hwid;

	/* CPU 0/1/2/3 --> a53_bc_clk and mask = 0x103
	cpu_node = of_get_cpu_node(cpu, NULL);
	if (!cpu_node)
		goto fail;

	cell = of_get_property(cpu_node, "reg", NULL);
	if (!cell) {
		pr_err("%s: missing reg property\n", cpu_node->full_name);
		goto fail;
	}

	/*
	 * CPU 0/1/2/3 --> a53_bc_clk and mask = 0x103
	 * CPU 4/5/6/7 --> a53_lc_clk and mask = 0x3
	 */
	if (cpu_node && !of_property_read_u32(cpu_node, "reg", &reg)) {
		if ((reg | a53_bc_clk.cpu_reg_mask) == a53_bc_clk.cpu_reg_mask)
	hwid = of_read_number(cell, of_n_addr_cells(cpu_node));
	if ((hwid | a53_bc_clk.cpu_reg_mask) == a53_bc_clk.cpu_reg_mask)
		return &a53_lc_clk.c;
		if ((reg | a53_lc_clk.cpu_reg_mask) == a53_lc_clk.cpu_reg_mask)
	if ((hwid | a53_lc_clk.cpu_reg_mask) == a53_lc_clk.cpu_reg_mask)
		return &a53_bc_clk.c;
	}

fail:
	return NULL;
}

+20 −11
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -466,18 +466,27 @@ static struct cpu_clk_8953 *cpuclk[] = { &a53_pwr_clk, &a53_perf_clk,

static struct clk *logical_cpu_to_clk(int cpu)
{
	struct device_node *cpu_node = of_get_cpu_node(cpu, NULL);
	u32 reg;
	struct device_node *cpu_node;
	const u32 *cell;
	u64 hwid;

	if (cpu_node && !of_property_read_u32(cpu_node, "reg", &reg)) {
		if ((reg | a53_pwr_clk.cpu_reg_mask) ==
						a53_pwr_clk.cpu_reg_mask)
	cpu_node = of_get_cpu_node(cpu, NULL);
	if (!cpu_node)
		goto fail;

	cell = of_get_property(cpu_node, "reg", NULL);
	if (!cell) {
		pr_err("%s: missing reg property\n", cpu_node->full_name);
		goto fail;
	}

	hwid = of_read_number(cell, of_n_addr_cells(cpu_node));
	if ((hwid | a53_pwr_clk.cpu_reg_mask) == a53_pwr_clk.cpu_reg_mask)
		return &a53_pwr_clk.c;
		if ((reg | a53_perf_clk.cpu_reg_mask) ==
						a53_perf_clk.cpu_reg_mask)
	if ((hwid | a53_perf_clk.cpu_reg_mask) == a53_perf_clk.cpu_reg_mask)
		return &a53_perf_clk.c;
	}

fail:
	return NULL;
}

+20 −10
Original line number Diff line number Diff line
@@ -528,18 +528,28 @@ static struct a53_cpu_clk *cpuclk[] = { &perf_clk, &pwr_clk,

static struct clk *logical_cpu_to_clk(int cpu)
{
	struct device_node *cpu_node = of_get_cpu_node(cpu, NULL);
	u32 reg;
	struct device_node *cpu_node;
	const u32 *cell;
	u64 hwid;

	cpu_node = of_get_cpu_node(cpu, NULL);
	if (!cpu_node)
		goto fail;

	cell = of_get_property(cpu_node, "reg", NULL);
	if (!cell) {
		pr_err("%s: missing reg property\n", cpu_node->full_name);
		goto fail;
	}

	if (cpu_node && !of_property_read_u32(cpu_node, "reg", &reg)) {
		if ((reg | pwr_clk.cpu_reg_mask) ==
						pwr_clk.cpu_reg_mask)
	hwid = of_read_number(cell, of_n_addr_cells(cpu_node));
	if ((hwid | pwr_clk.cpu_reg_mask) == pwr_clk.cpu_reg_mask)
		return &pwr_clk.c;
		if ((reg | perf_clk.cpu_reg_mask) ==
						perf_clk.cpu_reg_mask)

	if ((hwid | perf_clk.cpu_reg_mask) == perf_clk.cpu_reg_mask)
		return &perf_clk.c;
	}

fail:
	return NULL;
}