@@ -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;