summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorRick Chen <rick@andestech.com>2019-08-21 11:26:50 +0800
committerAndes <uboot@andestech.com>2019-09-03 09:30:54 +0800
commitd58b0a6ee10710b259412fdeaf0eb24474af8401 (patch)
treeb481330acf56a96c36593d70c3daa3b3e2082e74 /arch
parentf6cb427fdc1d2c4236f0a9bc97068c30ca228282 (diff)
downloadu-boot-d58b0a6ee10710b259412fdeaf0eb24474af8401.tar.gz
u-boot-d58b0a6ee10710b259412fdeaf0eb24474af8401.tar.bz2
u-boot-d58b0a6ee10710b259412fdeaf0eb24474af8401.zip
riscv: andes_plic: init plic by scanning each cpu node
Initialize plic driver by ofnode_for_each_subnode() instead of cpu_get_count(). This way can support to skip some harts which maybe marked as unavailable, but the cpu node exists indeed. Signed-off-by: Rick Chen <rick@andestech.com> Cc: KC Lin <kclin@andestech.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/lib/andes_plic.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/arch/riscv/lib/andes_plic.c b/arch/riscv/lib/andes_plic.c
index 2ffe49ac90..28568e4e2b 100644
--- a/arch/riscv/lib/andes_plic.c
+++ b/arch/riscv/lib/andes_plic.c
@@ -44,15 +44,12 @@ static int init_plic(void);
} \
} while (0)
-static int enable_ipi(int harts)
+static int enable_ipi(int hart)
{
- int i;
- int en = ENABLE_HART_IPI;
+ int en;
- for (i = 0; i < harts; i++) {
- en = en >> i;
- writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));
- }
+ en = ENABLE_HART_IPI >> hart;
+ writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, hart));
return 0;
}
@@ -60,18 +57,35 @@ static int enable_ipi(int harts)
static int init_plic(void)
{
struct udevice *dev;
+ ofnode node;
int ret;
+ u32 reg;
ret = uclass_find_first_device(UCLASS_CPU, &dev);
if (ret)
return ret;
if (ret == 0 && dev) {
- ret = cpu_get_count(dev);
- if (ret < 0)
- return ret;
+ ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) {
+ const char *device_type;
+
+ device_type = ofnode_read_string(node, "device_type");
+ if (!device_type)
+ continue;
+
+ if (strcmp(device_type, "cpu"))
+ continue;
+
+ /* skip if hart is marked as not available */
+ if (!ofnode_is_available(node))
+ continue;
+
+ /* read hart ID of CPU */
+ ret = ofnode_read_u32(node, "reg", &reg);
+ if (ret == 0)
+ enable_ipi(reg);
+ }
- enable_ipi(ret);
return 0;
}