From adb3bd7654467765ecb271a21953739679638f01 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Sun, 3 May 2020 21:58:51 +0800 Subject: cpu: imx8: reimplement get cpu count Return 4 is not correct on i.MX8DX/DXL/8QM and etc. we need to count available cpu node with device_type "cpu". Reviewed-by: Simon Glass Signed-off-by: Peng Fan --- drivers/cpu/imx8_cpu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'drivers/cpu/imx8_cpu.c') diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 95653683ac2..7c54c290b88 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -118,7 +118,24 @@ static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info) static int cpu_imx_get_count(struct udevice *dev) { - return 4; + ofnode node; + int num = 0; + + ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { + const char *device_type; + + if (!ofnode_is_available(node)) + continue; + + device_type = ofnode_read_string(node, "device_type"); + if (!device_type) + continue; + + if (!strcmp(device_type, "cpu")) + num++; + } + + return num; } static int cpu_imx_get_vendor(struct udevice *dev, char *buf, int size) -- cgit v1.2.3 From 177f9996d3cdf04a592bc0fece640cf4d492d1cb Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Sun, 3 May 2020 21:58:52 +0800 Subject: cpu: imx8: support a72 as boot cpu Support booting i.MX8QM with A72 as boot cpu Reviewed-by: Simon Glass Signed-off-by: Peng Fan --- drivers/cpu/imx8_cpu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers/cpu/imx8_cpu.c') diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 7c54c290b88..c4679e1642c 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -20,6 +20,7 @@ struct cpu_imx_platdata { const char *type; u32 cpurev; u32 freq_mhz; + u32 mpidr; }; const char *get_imx8_type(u32 imxtype) @@ -144,16 +145,28 @@ static int cpu_imx_get_vendor(struct udevice *dev, char *buf, int size) return 0; } +static int cpu_imx_is_current(struct udevice *dev) +{ + struct cpu_imx_platdata *plat = dev_get_platdata(dev); + + if (plat->mpidr == (read_mpidr() & 0xffff)) + return 1; + + return 0; +} + static const struct cpu_ops cpu_imx8_ops = { .get_desc = cpu_imx_get_desc, .get_info = cpu_imx_get_info, .get_count = cpu_imx_get_count, .get_vendor = cpu_imx_get_vendor, + .is_current = cpu_imx_is_current, }; static const struct udevice_id cpu_imx8_ids[] = { { .compatible = "arm,cortex-a35" }, { .compatible = "arm,cortex-a53" }, + { .compatible = "arm,cortex-a72" }, { } }; @@ -185,6 +198,12 @@ static int imx8_cpu_probe(struct udevice *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->mpidr = dev_read_addr(dev); + if (plat->mpidr == FDT_ADDR_T_NONE) { + printf("%s: Failed to get CPU reg property\n", __func__); + return -EINVAL; + } + return 0; } -- cgit v1.2.3 From 55bc96f3b675d719a473a8985636e76381b18cb8 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Sun, 3 May 2020 21:58:53 +0800 Subject: cpu: imx8: fix get core name and rate 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 Signed-off-by: Peng Fan --- drivers/cpu/imx8_cpu.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'drivers/cpu/imx8_cpu.c') diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index c4679e1642c..cd11b78d061 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__); -- cgit v1.2.3 From 3ee6ea443eb466399ab325a58b377326ac5c57b5 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Sun, 3 May 2020 21:58:54 +0800 Subject: cpu: imx_cpu: Print the CPU temperature for iMX8QM A72 iMX8QM registers two thermal devices for CPUs, get the temperature from "cpu-thermal1" device for A72 Reviewed-by: Simon Glass Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/cpu/imx8_cpu.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/cpu/imx8_cpu.c') diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index cd11b78d061..85ba7b7df2c 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -61,13 +61,15 @@ const char *get_core_name(struct udevice *dev) } #if IS_ENABLED(CONFIG_IMX_SCU_THERMAL) -static int cpu_imx_get_temp(void) +static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) { struct udevice *thermal_dev; int cpu_tmp, ret; - ret = uclass_get_device_by_name(UCLASS_THERMAL, "cpu-thermal0", - &thermal_dev); + if (!strcmp(plat->name, "A72")) + ret = uclass_get_device(UCLASS_THERMAL, 1, &thermal_dev); + else + ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev); if (!ret) { ret = thermal_get_temp(thermal_dev, &cpu_tmp); @@ -80,7 +82,7 @@ static int cpu_imx_get_temp(void) return cpu_tmp; } #else -static int cpu_imx_get_temp(void) +static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) { return 0; } @@ -89,7 +91,7 @@ static int cpu_imx_get_temp(void) int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) { struct cpu_imx_platdata *plat = dev_get_platdata(dev); - int ret; + int ret, temp; if (size < 100) return -ENOSPC; @@ -98,9 +100,13 @@ int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) plat->type, plat->rev, plat->name, plat->freq_mhz); if (IS_ENABLED(CONFIG_IMX_SCU_THERMAL)) { + temp = cpu_imx_get_temp(plat); buf = buf + ret; size = size - ret; - ret = snprintf(buf, size, " at %dC", cpu_imx_get_temp()); + if (temp != 0xdeadbeef) + ret = snprintf(buf, size, " at %dC", temp); + else + ret = snprintf(buf, size, " - invalid sensor data"); } snprintf(buf + ret, size - ret, "\n"); -- cgit v1.2.3 From 8142a97d541ef1473925b3677d6bf86bcddb69ac Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 3 May 2020 21:58:55 +0800 Subject: cpu: imx8: show RevC instead of Rev? at boot log Add REVC informaiton. Reviewed-by: Simon Glass Signed-off-by: Frank Li Signed-off-by: Peng Fan --- drivers/cpu/imx8_cpu.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/cpu/imx8_cpu.c') diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 85ba7b7df2c..95c14c98d86 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -43,6 +43,8 @@ const char *get_imx8_rev(u32 rev) return "A"; case CHIP_REV_B: return "B"; + case CHIP_REV_C: + return "C"; default: return "?"; } -- cgit v1.2.3