Added support to load partial and compressed bitstreams.
The partial bitstreams can be loaded using the below commands
Commands:
fpga loadp <dev> <addr> <size>
fpga loadbp <dev> <addr> <size>
The compressed and full bit streams can be loaded using the
old commands(fpga load and fpga loadb).
Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
return -1;
}
- result = fpga_load(0, fpga_data, data_size);
+ result = fpga_load(0, fpga_data, data_size, BIT_FULL);
if (!result)
bootstage_mark(BOOTSTAGE_ID_START);
#define FPGA_DUMP 3
#define FPGA_LOADMK 4
#define FPGA_LOADFS 5
+#define FPGA_LOADP 6
+#define FPGA_LOADBP 7
/* ------------------------------------------------------------------------- */
/* command form:
wrong_parms = 1;
#endif
case FPGA_LOAD:
+ case FPGA_LOADP:
case FPGA_LOADB:
+ case FPGA_LOADBP:
case FPGA_DUMP:
if (!fpga_data || !data_size)
wrong_parms = 1;
break;
case FPGA_LOAD:
- rc = fpga_load(dev, fpga_data, data_size);
+ rc = fpga_load(dev, fpga_data, data_size, BIT_FULL);
+ break;
+
+ case FPGA_LOADP:
+ rc = fpga_load(dev, fpga_data, data_size, BIT_PARTIAL);
break;
case FPGA_LOADB:
- rc = fpga_loadbitstream(dev, fpga_data, data_size);
+ rc = fpga_loadbitstream(dev, fpga_data, data_size, BIT_FULL);
break;
+
+ case FPGA_LOADBP:
+ rc = fpga_loadbitstream(dev, fpga_data, data_size, BIT_PARTIAL);
+ break;
+
#ifdef CONFIG_FPGA_LOADFS
case FPGA_LOADFS:
rc = fpga_fsload(dev, fpga_data, data_size, &fpga_fsinfo);
op = FPGA_LOADB;
else if (!strcmp("load", opstr))
op = FPGA_LOAD;
+ else if (!strcmp("loadp", opstr))
+ op = FPGA_LOADP;
+ else if (!strcmp("loadbp", opstr))
+ op = FPGA_LOADBP;
#ifdef CONFIG_FPGA_LOADFS
else if (!strcmp("loadfs", opstr))
op = FPGA_LOADFS;
" dump\t[dev]\t\t\tLoad device to memory buffer\n"
" info\t[dev]\t\t\tlist known device information\n"
" load\t[dev] [address] [size]\tLoad device from memory buffer\n"
+ " loadp\t[dev] [address] [size]\t"
+ "Load device from memory buffer with partial bitstream\n"
" loadb\t[dev] [address] [size]\t"
"Load device from bitstream buffer (Xilinx only)\n"
+ " loadbp\t[dev] [address] [size]\t"
+ "Load device from bitstream buffer with partial bitstream"
+ "(Xilinx only)\n"
" loadmk [dev] [address]\tLoad device generated with mkimage"
#if defined(CONFIG_FIT)
"\n"
}
#ifdef CONFIG_SPL_FPGA_BIT
return fpga_loadbitstream(devnum, (char *)CONFIG_SPL_FPGA_LOAD_ADDR,
- desc_xilinx->size);
+ desc_xilinx->size, BIT_FULL);
#else
return fpga_load(devnum, (const void *)CONFIG_SPL_FPGA_LOAD_ADDR,
- desc_xilinx->size);
+ desc_xilinx->size, BIT_FULL);
#endif
}
#endif
/*
* Convert bitstream data and load into the fpga
*/
-int __weak fpga_loadbitstream(int devnum, char *fpgadata, size_t size)
+int __weak fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
+ bitstream_type bstype)
{
printf("Bitstream support not implemented for this FPGA device\n");
return FPGA_FAIL;
/*
* Generic multiplexing code
*/
-int fpga_load(int devnum, const void *buf, size_t bsize)
+int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype)
{
int ret_val = FPGA_FAIL; /* assume failure */
const fpga_desc *desc = fpga_validate(devnum, buf, bsize,
switch (desc->devtype) {
case fpga_xilinx:
#if defined(CONFIG_FPGA_XILINX)
- ret_val = xilinx_load(desc->devdesc, buf, bsize);
+ ret_val = xilinx_load(desc->devdesc, buf, bsize,
+ bstype);
#else
fpga_no_sup((char *)__func__, "Xilinx devices");
#endif
/* ------------------------------------------------------------------------- */
-int fpga_loadbitstream(int devnum, char *fpgadata, size_t size)
+int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
+ bitstream_type bstype)
{
unsigned int length;
unsigned int swapsize;
dataptr += 4;
printf(" bytes in bitstream = %d\n", swapsize);
- return fpga_load(devnum, dataptr, swapsize);
+ return fpga_load(devnum, dataptr, swapsize, bstype);
}
#ifdef CONFIG_FPGA_LOADFS
}
#endif
-int xilinx_load(Xilinx_desc *desc, const void *buf, size_t bsize)
+int xilinx_load(Xilinx_desc *desc, const void *buf, size_t bsize,
+ bitstream_type bstype)
{
int ret_val = FPGA_FAIL; /* assume a failure */
#if defined(CONFIG_FPGA_ZYNQPL)
PRINTF("%s: Launching the Zynq PL Loader...\n",
__func__);
- ret_val = zynq_load(desc, buf, bsize);
+ ret_val = zynq_load(desc, buf, bsize, bstype);
#else
printf("%s: No support for Zynq devices.\n",
__func__);
return FPGA_SUCCESS;
}
-static int zynq_dma_xfer_init(u32 partialbit)
+static int zynq_dma_xfer_init(bitstream_type bstype)
{
u32 status, control, isr_status;
unsigned long ts;
/* Clear loopback bit */
clrbits_le32(&devcfg_base->mctrl, DEVCFG_MCTRL_PCAP_LPBK);
- if (!partialbit) {
+ if (bstype != BIT_PARTIAL) {
zynq_slcr_devcfg_disable();
/* Setting PCFG_PROG_B signal to high */
static int zynq_validate_bitstream(Xilinx_desc *desc, const void *buf,
size_t bsize, u32 blocksize, u32 *swap,
- u32 *partialbit)
+ bitstream_type *bstype)
{
u32 *buf_start;
u32 diff;
- /* Detect if we are going working with partial or full bitstream */
- if (bsize != desc->size) {
- printf("%s: Working with partial bitstream\n", __func__);
- *partialbit = 1;
- }
buf_start = check_data((u8 *)buf, blocksize, swap);
if (!buf_start)
return FPGA_FAIL;
}
- if (zynq_dma_xfer_init(*partialbit))
+ if (zynq_dma_xfer_init(*bstype))
return FPGA_FAIL;
return 0;
{
unsigned long ts; /* Timestamp */
u32 isr_status, swap;
- u32 partialbit = 0;
+ bitstream_type bstype;
u32 blocksize;
u32 pos = 0;
int fstype;
if (fs_read(filename, (u32) buf, pos, blocksize) < 0)
return FPGA_FAIL;
+ bstype = BIT_FULL;
+
if (zynq_validate_bitstream(desc, buf, bsize, blocksize, &swap,
- &partialbit))
+ &bstype))
return FPGA_FAIL;
dcache_disable();
debug("%s: FPGA config done\n", __func__);
- if (!partialbit)
+ if (bstype != BIT_PARTIAL)
zynq_slcr_devcfg_enable();
return FPGA_SUCCESS;
}
#endif
-int zynq_load(Xilinx_desc *desc, const void *buf, size_t bsize)
+int zynq_load(Xilinx_desc *desc, const void *buf, size_t bsize,
+ bitstream_type bstype)
{
unsigned long ts; /* Timestamp */
- u32 partialbit = 0;
u32 isr_status, swap;
/*
* in chunks
*/
if (zynq_validate_bitstream(desc, buf, bsize, bsize, &swap,
- &partialbit))
+ &bstype))
return FPGA_FAIL;
buf = zynq_align_dma_buffer((u32 *)buf, bsize, swap);
debug("%s: FPGA config done\n", __func__);
- if (!partialbit)
+ if (bstype != BIT_PARTIAL)
zynq_slcr_devcfg_enable();
return FPGA_SUCCESS;
} fpga_fs_info;
#endif
+typedef enum {
+ BIT_FULL = 0,
+ BIT_PARTIAL,
+ BIT_COMPRESSED
+} bitstream_type;
+
/* root function definitions */
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_load(int devnum, const void *buf, size_t bsize,
+ bitstream_type bstype);
#ifdef CONFIG_FPGA_LOADFS
extern int fpga_fsload(int devnum, const void *buf, size_t size,
fpga_fs_info *fpga_fsinfo);
#endif
-extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size);
+extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
+ bitstream_type bstype);
extern int fpga_dump(int devnum, const void *buf, size_t bsize);
extern int fpga_info(int devnum);
extern const fpga_desc *const fpga_validate(int devnum, const void *buf,
/* Generic Xilinx Functions
*********************************************************************/
-extern int xilinx_load(Xilinx_desc *desc, const void *image, size_t size);
+extern int xilinx_load(Xilinx_desc *desc, const void *image, size_t size,
+ bitstream_type bstype);
#ifdef CONFIG_FPGA_LOADFS
extern int xilinx_fsload(Xilinx_desc *desc, const void *buf, size_t bsize,
fpga_fs_info *fpga_fsinfo);
#include <xilinx.h>
-extern int zynq_load(Xilinx_desc *desc, const void *image, size_t size);
+extern int zynq_load(Xilinx_desc *desc, const void *image, size_t size,
+ bitstream_type bstype);
#ifdef CONFIG_FPGA_LOADFS
extern int zynq_fsload(Xilinx_desc *desc, const void *buf, size_t bsize,
fpga_fs_info *fsinfo);