diff mbox series

[V3,7/9] cpu: imx8: fix get core name and rate

Message ID 20200503135855.11484-7-peng.fan@nxp.com
State Accepted
Commit 55bc96f3b675d719a473a8985636e76381b18cb8
Headers show
Series [V3,1/9] uclass: cpu: Add new API to get udevice for current CPU | expand

Commit Message

Peng Fan May 3, 2020, 1:58 p.m. UTC
When current cpu is A53, using is_cortex_a53 could not detect A72
information, so check cpu device compatible property to get
the correct information.

Reviewed-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
V3:
 None
V2:
 Add R-b tag

 drivers/cpu/imx8_cpu.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

Comments

Stefano Babic May 4, 2020, 7:35 a.m. UTC | #1
> When current cpu is A53, using is_cortex_a53 could not detect A72
> information, so check cpu device compatible property to get
> the correct information.
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
index c4679e1642..cd11b78d06 100644
--- a/drivers/cpu/imx8_cpu.c
+++ b/drivers/cpu/imx8_cpu.c
@@ -48,13 +48,13 @@  const char *get_imx8_rev(u32 rev)
 	}
 }
 
-const char *get_core_name(void)
+const char *get_core_name(struct udevice *dev)
 {
-	if (is_cortex_a35())
+	if (!device_is_compatible(dev, "arm,cortex-a35"))
 		return "A35";
-	else if (is_cortex_a53())
+	else if (!device_is_compatible(dev, "arm,cortex-a53"))
 		return "A53";
-	else if (is_cortex_a72())
+	else if (!device_is_compatible(dev, "arm,cortex-a72"))
 		return "A72";
 	else
 		return "?";
@@ -170,12 +170,19 @@  static const struct udevice_id cpu_imx8_ids[] = {
 	{ }
 };
 
-static ulong imx8_get_cpu_rate(void)
+static ulong imx8_get_cpu_rate(struct udevice *dev)
 {
 	ulong rate;
-	int ret;
-	int type = is_cortex_a35() ? SC_R_A35 : is_cortex_a53() ?
-		   SC_R_A53 : SC_R_A72;
+	int ret, type;
+
+	if (!device_is_compatible(dev, "arm,cortex-a35"))
+		type = SC_R_A35;
+	else if (!device_is_compatible(dev, "arm,cortex-a53"))
+		type = SC_R_A53;
+	else if (!device_is_compatible(dev, "arm,cortex-a72"))
+		type = SC_R_A72;
+	else
+		return 0;
 
 	ret = sc_pm_get_clock_rate(-1, type, SC_PM_CLK_CPU,
 				   (sc_pm_clock_rate_t *)&rate);
@@ -194,10 +201,10 @@  static int imx8_cpu_probe(struct udevice *dev)
 
 	cpurev = get_cpu_rev();
 	plat->cpurev = cpurev;
-	plat->name = get_core_name();
+	plat->name = get_core_name(dev);
 	plat->rev = get_imx8_rev(cpurev & 0xFFF);
 	plat->type = get_imx8_type((cpurev & 0xFF000) >> 12);
-	plat->freq_mhz = imx8_get_cpu_rate() / 1000000;
+	plat->freq_mhz = imx8_get_cpu_rate(dev) / 1000000;
 	plat->mpidr = dev_read_addr(dev);
 	if (plat->mpidr == FDT_ADDR_T_NONE) {
 		printf("%s: Failed to get CPU reg property\n", __func__);