spl: Support loading a FIT from SPI
cover spl: Support loading a FIT from SPI
This series makes sure that raw read of fit is dma aligned and supports loading a fit from SPI.
Verified on DRA7-evm.
Lokesh Vutla (2):
spl: Make sure destination address is dma aligned when loading fit
spl: Support loading a FIT from SPI
common/spl/spl_fit.c | 11 +++++++---- drivers/mtd/spi/spi_spl_load.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/2 spl: Make sure destination address is dma aligned when loading fit
Peripherals like spi etc. uses DMA for transfers. So, when loading the fit image the destination address should be dma aligned.
---
- Assuming u-boot.bin load addr will always be dma aligned.
common/spl/spl_fit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
common/spl/spl_fit.c +7 -4
@@ -91,7 +91,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)void *load_ptr;int fdt_offset, fdt_len;int data_offset, data_size; -int base_offset; +int base_offset, align_len;int src_sector;void *dst;
@@ -117,7 +117,9 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* In fact the FIT has its own load address, but we assume it cannot * be before CONFIG_SYS_TEXT_BASE. */ - fit = (void *)(CONFIG_SYS_TEXT_BASE - size - info->bl_len); + align_len =ARCH_DMA_MINALIGN -1 ; + fit = (void *)((CONFIG_SYS_TEXT_BASE - size - info->bl_len - + align_len) & ~align_len); sectors = (size + info->bl_len -1 ) / info->bl_len; count = info->read (info, sector, sectors, fit); debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu\n",
@@ -173,8 +175,9 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)/* * Read the device tree and place it after the image. There may be * some extra data before it since we can only read entire blocks. +* And also align the destination address to ARCH_DMA_MINALIGN. */ - dst = load_ptr + data_size; + dst = (void *)((load + data_size + align_len) & ~align_len); fdt_offset += base_offset; count = info->read (info, sector + fdt_offset / info->bl_len, sectors, dst);
@@ -188,7 +191,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* After this we will have the U-Boot image and its device tree ready * for us to start. */ -memcpy (dst, dst + fdt_offset % info->bl_len, fdt_len); +memcpy (load_ptr + data_size, dst + fdt_offset % info->bl_len, fdt_len);return 0 ; }
Signature · 1 line
2.1.4
PATCH 1/2 spl: Make sure destination address is dma aligned when loading fit
Quoted 4 lines · Lokesh Vutla
Peripherals like spi etc. uses DMA for transfers. So, when loading the fit image the destination address should be dma aligned.
Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160408/32ec2bc4/attachment.sig>
PATCH 1/2 spl: Make sure destination address is dma aligned when loading fit
In reply to Lokesh VutlaQuoted 2 lines · Lokesh Vutla
Peripherals like spi etc. uses DMA for transfers. So, when loading the fit image the destination address should be dma aligned.
After the v5 of my FS support for FIT[1], this patch is no more necessary. Patch 2 is alone sufficient.
[1] http://patchwork.ozlabs.org/patch/618403/
Thanks and regards,
Lokesh
Quoted 53 lines
Signed-off-by Lokesh Vutla <[email protected]>---
- Assuming u-boot.bin load addr will always be dma aligned.common/spl/spl_fit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)common/spl/spl_fit.c +7
-4@@ -91,7 +91,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)void *load_ptr;int fdt_offset, fdt_len;int data_offset, data_size; -int base_offset; +int base_offset, align_len;int src_sector;void *dst;@@ -117,7 +117,9 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* In fact the FIT has its own load address, but we assume it cannot * be before CONFIG_SYS_TEXT_BASE. */ - fit = (void *)(CONFIG_SYS_TEXT_BASE - size - info->bl_len); + align_len =ARCH_DMA_MINALIGN -1 ; + fit = (void *)((CONFIG_SYS_TEXT_BASE - size - info->bl_len - + align_len) & ~align_len); sectors = (size + info->bl_len -1 ) / info->bl_len; count = info->read (info, sector, sectors, fit); debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu\n",@@ -173,8 +175,9 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)/* * Read the device tree and place it after the image. There may be * some extra data before it since we can only read entire blocks. +* And also align the destination address to ARCH_DMA_MINALIGN. */ - dst = load_ptr + data_size; + dst = (void *)((load + data_size + align_len) & ~align_len); fdt_offset += base_offset; count = info->read (info, sector + fdt_offset / info->bl_len, sectors, dst);@@ -188,7 +191,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* After this we will have the U-Boot image and its device tree ready * for us to start. */ -memcpy (dst, dst + fdt_offset % info->bl_len, fdt_len); +memcpy (load_ptr + data_size, dst + fdt_offset % info->bl_len, fdt_len);return 0 ; }
PATCH 1/2 spl: Make sure destination address is dma aligned when loading fit
Quoted 10 lines · Lokesh Vutla
Quoted 2 lines · Lokesh Vutla
Peripherals like spi etc. uses DMA for transfers. So, when loading the fit image the destination address should be dma aligned.
After the v5 of my FS support for FIT[1], this patch is no more necessary. Patch 2 is alone sufficient.
Thanks. Note that if you register with patchwork you should be able to manage the state of your own patches as well. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160505/8ed109ca/attachment.sig>
PATCH 1/2 spl: Make sure destination address is dma aligned when loading fit
Quoted 8 lines · Tom Rini
Quoted 6 lines · Lokesh Vutla
Quoted 2 lines · Lokesh Vutla
Peripherals like spi etc. uses DMA for transfers. So, when loading the fit image the destination address should be dma aligned.
Quoted 7 lines
Quoted 4 lines
After the v5 of my FS support for FIT[1], this patch is no more necessary. Patch 2 is alone sufficient.
Thanks. Note that if you register with patchwork you should be able to manage the state of your own patches as well. Thanks!
Sure, Ill register with patchwork.
Thanks and regards,
Lokesh
Quoted 1 line
PATCH 2/2 spl: Support loading a FIT from SPI
In reply to Lokesh VutlaDetect a FIT when loading from SPI and handle it using the new FIT SPL support.
--- drivers/mtd/spi/spi_spl_load.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/mtd/spi/spi_spl_load.c +29 -3
@@ -44,6 +44,18 @@ static int spi_load_image_os(struct spi_flash *flash, }#endif +static ulong spl_spi_fit_read (struct spl_load_info *load,ulong sector, +ulong count,void *buf) +{ +struct spi_flash *flash = load->dev; +ulong ret; + + ret =spi_flash_read (flash, sector, count, buf); +if (!ret) +return count; +else +return 0 ; +}/* * The main entry for SPI booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image
@@ -81,9 +93,23 @@ int spl_spi_load_image(void)if (err)return err; -spl_parse_image_header (header); - err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , - spl_image.size, (void *)spl_image.load_addr); +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT )) { +struct spl_load_info load; + +debug ("Found FIT\n" ); + load.dev = flash; + load.priv =NULL ; + load.bl_len =1 ; + load.read = spl_spi_fit_read; + err =spl_load_simple_fit (&load, +CONFIG_SYS_SPI_U_BOOT_OFFS , + header); + }else { +spl_parse_image_header (header); + err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , + spl_image.size, + (void *)spl_image.load_addr); + } }return err;
Signature · 1 line
2.1.4
PATCH 2/2 spl: Support loading a FIT from SPI
Quoted 4 lines · Lokesh Vutla
Detect a FIT when loading from SPI and handle it using the new FIT SPL support.
Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160408/513e2ae5/attachment.sig>