From: Michal Simek Date: Fri, 17 Jan 2014 08:56:07 +0000 (+0100) Subject: zynq: Add fpga support to u-boot SPL X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=81a0e8c2ea26a0efbf99139f93435745858fd297;p=thirdparty%2Fu-boot.git zynq: Add fpga support to u-boot SPL Call board_init to ensure that fpga is properly detected. Enable bit and bin formats. Signed-off-by: Michal Simek --- diff --git a/arch/arm/cpu/armv7/zynq/spl.c b/arch/arm/cpu/armv7/zynq/spl.c index e41523017cd..f6686b4d649 100644 --- a/arch/arm/cpu/armv7/zynq/spl.c +++ b/arch/arm/cpu/armv7/zynq/spl.c @@ -33,6 +33,11 @@ void board_init_f(ulong dummy) board_init_r(NULL, 0); } +void spl_board_init(void) +{ + board_init(); +} + u32 spl_boot_device(void) { u32 mode; diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index fc2f2260f88..a1703f0899c 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include DECLARE_GLOBAL_DATA_PTR; @@ -69,6 +71,35 @@ static int mmc_load_image_raw_os(struct mmc *mmc) } #endif +#ifdef CONFIG_SPL_FPGA_SUPPORT +static int mmc_load_fpga_image_fat(struct mmc *mmc) +{ + int err; + int devnum = 0; + const fpga_desc *const desc = fpga_get_desc(devnum); + Xilinx_desc *desc_xilinx = desc->devdesc; + + /* FIXME = standard file size + header desc_xilinx->size + 0x6c */ + err = file_fat_read(CONFIG_SPL_FPGA_LOAD_ARGS_NAME, + (void *)CONFIG_SPL_FPGA_LOAD_ADDR, + 0); + if (err <= 0) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + printf("spl: error reading image %s, err - %d\n", + CONFIG_SPL_FAT_LOAD_ARGS_NAME, err); +#endif + return -1; + } +#ifdef CONFIG_SPL_FPGA_BIT + return fpga_loadbitstream(devnum, (char *)CONFIG_SPL_FPGA_LOAD_ADDR, + desc_xilinx->size); +#else + return fpga_load(devnum, (const void *)CONFIG_SPL_FPGA_LOAD_ADDR, + desc_xilinx->size); +#endif +} +#endif + #ifdef CONFIG_SPL_FAT_SUPPORT static int mmc_load_image_fat(struct mmc *mmc, const char *filename) { @@ -161,6 +192,9 @@ void spl_mmc_load_image(void) #endif hang(); } +#ifdef CONFIG_SPL_FPGA_SUPPORT + mmc_load_fpga_image_fat(mmc); +#endif #ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || mmc_load_image_fat_os(mmc)) diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index b940d9b316b..2ed2f959a1e 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -38,7 +38,7 @@ static void fpga_no_sup(char *fn, char *msg) /* fpga_get_desc * map a device number to a descriptor */ -static const fpga_desc *const fpga_get_desc(int devnum) +const fpga_desc *const fpga_get_desc(int devnum) { fpga_desc *desc = (fpga_desc *)NULL; diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 993656f2d95..cc00280c51a 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -356,13 +356,23 @@ #define CONFIG_SPL_LIBCOMMON_SUPPORT #define CONFIG_SPL_LIBGENERIC_SUPPORT #define CONFIG_SPL_SERIAL_SUPPORT +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/zynq/u-boot-spl.lds" /* Disable dcache for SPL just for sure */ #ifdef CONFIG_SPL_BUILD #define CONFIG_SYS_DCACHE_OFF -#undef CONFIG_FPGA +#endif + +/* FPGA support */ +#define CONFIG_SPL_FPGA_SUPPORT +#define CONFIG_SPL_FPGA_LOAD_ADDR 0x1000000 +/* #define CONFIG_SPL_FPGA_BIT */ +#ifdef CONFIG_SPL_FPGA_BIT +# define CONFIG_SPL_FPGA_LOAD_ARGS_NAME "download.bit" +#else +# define CONFIG_SPL_FPGA_LOAD_ARGS_NAME "fpga.bin" #endif /* MMC support */ diff --git a/include/fpga.h b/include/fpga.h index 15e603a169d..acc9efc883b 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -40,6 +40,7 @@ typedef struct { /* typedef fpga_desc */ extern void fpga_init(void); extern int fpga_add(fpga_type devtype, void *desc); extern int fpga_count(void); +extern const fpga_desc *const fpga_get_desc(int devnum); extern int fpga_load(int devnum, const void *buf, size_t bsize); extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size); extern int fpga_dump(int devnum, const void *buf, size_t bsize); diff --git a/spl/Makefile b/spl/Makefile index 5e5472d97ce..c7b626c4bcc 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -68,6 +68,7 @@ LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/ LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/ LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/ LIBS-y += fs/ +LIBS-$(CONFIG_SPL_FPGA_SUPPORT) += drivers/fpga/ LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \ drivers/power/pmic/