aboutsummaryrefslogtreecommitdiff
path: root/drivers/cpu
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2020-05-03 21:58:51 +0800
committerStefano Babic <sbabic@denx.de>2020-05-03 15:45:49 +0200
commitadb3bd7654467765ecb271a21953739679638f01 (patch)
treeea6c621a54d566d28e0563f4c8c6dd65e133f35b /drivers/cpu
parentf5b66af2cb18b1577b2898413e98df7dcd9bc67f (diff)
downloadu-boot-adb3bd7654467765ecb271a21953739679638f01.zip
u-boot-adb3bd7654467765ecb271a21953739679638f01.tar.gz
u-boot-adb3bd7654467765ecb271a21953739679638f01.tar.bz2
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 <sjg@chromium.org> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'drivers/cpu')
-rw-r--r--drivers/cpu/imx8_cpu.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
index 9565368..7c54c29 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)