aboutsummaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorMarek Vasut2018-05-12 22:25:28 +0200
committerTom Rini2018-05-23 22:05:54 -0400
commit26a642238bdecc53527142dc043b29e21c5cc94c (patch)
tree1a81ef88824375974c41211f25c3d0b9dfbedbfe /common/spl
parentb11ed7d602a48021d8ab96518ad80996d2b86077 (diff)
spl: fit: Add support for loading FPGA bitstream
Add support for loading FPGA into the SPL fitImage support. The mechanism is flexible and allows user to override the actual function for loading the FPGA itself. This is because on some systems, the FPGA must be programmed to allow DRAM access, so loading the full fitImage may not be possible if it contains the bitstream. Instead, the spl_load_fpga_image() provides all the tools to load the bitstream in parts while programming it into the FPGA. Signed-off-by: Marek Vasut <marex@denx.de> [trini: Don't always have a branch to print out type] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/spl_fit.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 8b5befcec2b..2321ebb0dde 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -140,6 +140,14 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
return (data_size + info->bl_len - 1) / info->bl_len;
}
+#ifdef CONFIG_SPL_FPGA_SUPPORT
+__weak int spl_load_fpga_image(struct spl_load_info *info, size_t length,
+ int nr_sectors, int sector_offset)
+{
+ return 0;
+}
+#endif
+
/**
* spl_load_fit_image(): load the image described in a certain FIT node
* @info: points to information about the device to load data from
@@ -161,7 +169,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
void *fit, ulong base_offset, int node,
struct spl_image_info *image_info)
{
- int offset;
+ int offset, sector_offset;
size_t length;
int len;
ulong size;
@@ -209,9 +217,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
overhead = get_aligned_image_overhead(info, offset);
nr_sectors = get_aligned_image_size(info, length, offset);
+ sector_offset = sector + get_aligned_image_offset(info, offset);
- if (info->read(info,
- sector + get_aligned_image_offset(info, offset),
+#ifdef CONFIG_SPL_FPGA_SUPPORT
+ if (type == IH_TYPE_FPGA) {
+ return spl_load_fpga_image(info, length, nr_sectors,
+ sector_offset);
+ }
+#endif
+
+ if (info->read(info, sector_offset,
nr_sectors, (void *)load_ptr) != nr_sectors)
return -EIO;
@@ -387,6 +402,20 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
return -1;
}
+#ifdef CONFIG_SPL_FPGA_SUPPORT
+ node = spl_fit_get_image_node(fit, images, "fpga", 0);
+ if (node >= 0) {
+ /* Load the image and set up the spl_image structure */
+ ret = spl_load_fit_image(info, sector, fit, base_offset, node,
+ spl_image);
+ if (ret) {
+ printf("%s: Cannot load the FPGA: %i\n", __func__, ret);
+ return ret;
+ }
+ node = -1;
+ }
+#endif
+
/*
* Find the U-Boot image using the following search order:
* - start at 'firmware' (e.g. an ARM Trusted Firmware)