aboutsummaryrefslogtreecommitdiff
path: root/drivers/mtd/nand/raw/fsl_ifc_spl.c
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2023-11-04 16:37:44 -0400
committerTom Rini <trini@konsulko.com>2023-11-16 12:43:48 -0500
commit38ef64e6ce3d1f84478c6d2700e4d76f80cfcaf4 (patch)
tree4b390e237ef5d64a318e6381c570291c5e45bb3e /drivers/mtd/nand/raw/fsl_ifc_spl.c
parent57d3da6fee1d4d8691a74d9b7bb5b7bc0d4e4e63 (diff)
downloadu-boot-38ef64e6ce3d1f84478c6d2700e4d76f80cfcaf4.zip
u-boot-38ef64e6ce3d1f84478c6d2700e4d76f80cfcaf4.tar.gz
u-boot-38ef64e6ce3d1f84478c6d2700e4d76f80cfcaf4.tar.bz2
spl: nand: Set bl_len to page size
Since commit 34793598c83 ("mtd: nand: mxs_nand_spl: Remove the page aligned access") there are no longer any users of nand_get_mtd. However, it is still important to know what the page size is so we can allocate a large-enough buffer. If the image size is not page-aligned, we will go off the end of the buffer and clobber some memory. Introduce a new function nand_page_size which returns the page size. For most drivers it is easy to determine the page size. However, a few need to be modified since they only keep the page size around temporarily. It's possible that this patch could cause a regression on some platforms if the offset is non-aligned and there is invalid address space immediately before the load address. spl_load_legacy_img does not (except when compressing) respect bl_len, so only boards with SPL_LOAD_FIT (8 boards) or SPL_LOAD_IMX_CONTAINER (none in tree) would be affected. defconfig CONFIG_TEXT_BASE ======================= ================ am335x_evm 0x80800000 am43xx_evm 0x80800000 am43xx_evm_rtconly 0x80800000 am43xx_evm_usbhost_boot 0x80800000 am43xx_hs_evm 0x80800000 dra7xx_evm 0x80800000 gwventana_nand 0x17800000 imx8mn_bsh_smm_s2 0x40200000 All the sitara boards have DDR mapped at 0x80000000. gwventana is an i.MX6Q which has DDR at 0x10000000. I don't have the IMX8MNRM handy, but on the i.MX8M DDR starts at 0x40000000. Therefore all of these boards can handle a little underflow. Signed-off-by: Sean Anderson <seanga2@gmail.com>
Diffstat (limited to 'drivers/mtd/nand/raw/fsl_ifc_spl.c')
-rw-r--r--drivers/mtd/nand/raw/fsl_ifc_spl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/mtd/nand/raw/fsl_ifc_spl.c b/drivers/mtd/nand/raw/fsl_ifc_spl.c
index c67065e..69d26f1 100644
--- a/drivers/mtd/nand/raw/fsl_ifc_spl.c
+++ b/drivers/mtd/nand/raw/fsl_ifc_spl.c
@@ -106,6 +106,8 @@ static inline int bad_block(uchar *marker, int port_size)
return __raw_readw((u16 *)marker) != 0xffff;
}
+static int saved_page_size;
+
int nand_spl_load_image(uint32_t offs, unsigned int uboot_size, void *vdst)
{
struct fsl_ifc_fcm *gregs = (void *)CFG_SYS_IFC_ADDR;
@@ -150,6 +152,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int uboot_size, void *vdst)
if (port_size == 8)
bad_marker = 5;
}
+ saved_page_size = page_size;
ver = ifc_in32(&gregs->ifc_rev);
if (ver >= FSL_IFC_V2_0_0)
@@ -302,6 +305,11 @@ void nand_init(void)
{
}
+unsigned int nand_page_size(void)
+{
+ return saved_page_size;
+}
+
void nand_deselect(void)
{
}