[U-Boot] [PATCH 4/9] riscv: ae350: initialize PLIC

Andes uboot at andestech.com
Tue Mar 19 09:07:45 UTC 2019


From: Rick Chen <rick at andestech.com>

Initialize PLIC when ae350 board startup.

Signed-off-by: Rick Chen <rick at andestech.com>
Cc: Greentime Hu <greentime at andestech.com>
---
 board/AndesTech/ax25-ae350/ax25-ae350.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
index d343453..ebeb4b8 100644
--- a/board/AndesTech/ax25-ae350/ax25-ae350.c
+++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
@@ -11,10 +11,17 @@
 #include <linux/io.h>
 #include <faraday/ftsmc020.h>
 #include <fdtdec.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+#include <cpu.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 extern phys_addr_t prior_stage_fdt_address;
+extern int plic_init(int harts);
+
 /*
  * Miscellaneous platform dependent initializations
  */
@@ -97,9 +104,32 @@ int smc_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_NDS_PLIC
+int init_plic(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_find_first_device(UCLASS_CPU, &dev);
+	if (ret)
+		return ret;
+
+	if (ret == 0 && dev != NULL) {
+		ret = cpu_get_count(dev);
+		plic_init(ret);
+		return 0;
+	}
+
+	return -ENODEV;
+}
+#endif
+
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
+#ifdef CONFIG_NDS_PLIC
+	init_plic();
+#endif
 	smc_init();
 
 	return 0;
-- 
2.7.4



More information about the U-Boot mailing list