Skip to contentSkip to conversation

arm: socfpga: Add FPGA drivers for Arria 10 FPGA loadfs

PATCH Superseded tien.fong.chee at intel.com 1 participant 1 message Oct 31, 2017

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 8/20 arm: socfpga: Add FPGA drivers for Arria 10 FPGA loadfs

From: Tien Fong Chee <[email protected]>

Add FPGA drivers to support FPGA loadfs to program FPGA.
The drivers are designed based on generic firmware loader framework, specific firmware loader handling is defined in fpga_manager_arria10.c. These drivers can handle FPGA program operation from
loading RBF image in flash to memory and then to program FPGA.

---
 arch/arm/mach-socfpga/Makefile                     |   1 +
 arch/arm/mach-socfpga/fpga_manager_arria10.c       | 132 +++++++++
 .../include/mach/fpga_manager_arria10.h            |  32 ++
 drivers/fpga/socfpga_arria10.c                     | 330 +++++++++++++++++++++
 include/altera.h                                   |   6 +
 5 files changed, 501 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/fpga_manager_arria10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 286bfef..432a5a8 100644
@@ -28,6 +28,7 @@ obj-y	+= clock_manager_arria10.o
 obj-y	+= misc_arria10.o
 obj-y	+= pinmux_arria10.o
 obj-y	+= reset_manager_arria10.o
+obj-$(CONFIG_CMD_FPGA_LOADFS) += fpga_manager_arria10.o
 endif
 
 ifdef CONFIG_SPL_BUILD
arch/arm/mach-socfpga/fpga_manager_arria10.c new file +132 -0

132 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h +32 -0
index 9cbf696..dc7337f 100644
@@ -8,6 +8,8 @@
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
+#include <asm/cache.h>
+
 #define ALT_FPGAMGR_IMGCFG_STAT_F2S_CRC_ERROR_SET_MSK		BIT(0)
 #define ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK	BIT(1)
 #define ALT_FPGAMGR_IMGCFG_STAT_F2S_USERMODE_SET_MSK 		BIT(2)
@@ -89,11 +91,41 @@ struct socfpga_fpga_manager {
 	u32  imgcfg_fifo_status;
 };
 
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+enum rbf_type {unknown, periph_section, core_section};
+enum rbf_security {invalid, unencrypted, encrypted};
+
+struct rbf_info {
+	enum rbf_type section;
+	enum rbf_security security;
+};
+
+struct flash_info {
+	char *interface;
+	char *dev_part;
+	char *filename;
+	int fstype;
+	u32 remaining;
+	u32 flash_offset;
+	struct rbf_info rbfinfo;
+	struct image_header header;
+};
+#endif
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32 core);
+const char *get_cff_devpart(const void *fdt, int *len);
+int fs_flash_preinit(struct flash_info *flashinfo, u32 *buffer,
+		     u32 *buffer_sizebytes);
+int fs_flash_read(struct flash_info *flashinfo, u32 *buffer,
+		  u32 *buffer_sizebytes);
+#endif
+void set_flash_devpart(char *name, char *devpart);
 
 #endif /* __ASSEMBLY__ */
 
drivers/fpga/socfpga_arria10.c +330 -0

351 lines not on this page · raw message

include/altera.h +6 -0
index 48d3eb7..0597e8a 100644
@@ -84,6 +84,10 @@ typedef struct {
 extern int altera_load(Altera_desc *desc, const void *image, size_t size);
 extern int altera_dump(Altera_desc *desc, const void *buf, size_t bsize);
 extern int altera_info(Altera_desc *desc);
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+int altera_loadfs(Altera_desc *desc, const void *buf, size_t bsize,
+		   fpga_fs_info *fpga_fsinfo);
+#endif
 
 /* Board specific implementation specific function types
  *********************************************************************/
@@ -111,6 +115,8 @@ typedef struct {
 
 #ifdef CONFIG_FPGA_SOCFPGA
 int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
+int socfpga_loadfs(Altera_desc *desc, const void *buf, size_t bsize,
+		   fpga_fs_info *fpga_fsinfo);
 #endif
 
 #ifdef CONFIG_FPGA_STRATIX_V
Signature · 1 line
2.2.0