Merge git://git.denx.de/u-boot-dm
[oweals/u-boot.git] / drivers / mtd / nand / fsl_ifc_spl.c
index 2f82f7c5c61cc0fef72969408c79e4eec8a863a7..e336cb1c94b2c9a7d37a2ba168c45d5790f57b0b 100644 (file)
@@ -88,11 +88,7 @@ static inline int bad_block(uchar *marker, int port_size)
                return __raw_readw((u16 *)marker) != 0xffff;
 }
 
-#ifdef CONFIG_TPL_BUILD
 int nand_spl_load_image(uint32_t offs, unsigned int uboot_size, void *vdst)
-#else
-static int nand_load(uint32_t offs, unsigned int uboot_size, void *vdst)
-#endif
 {
        struct fsl_ifc *ifc = IFC_BASE_ADDR;
        uchar *buf = (uchar *)CONFIG_SYS_NAND_BASE;
@@ -101,7 +97,7 @@ static int nand_load(uint32_t offs, unsigned int uboot_size, void *vdst)
        int pages_per_blk;
        int blk_size;
        int bad_marker = 0;
-       int bufnum_mask, bufnum;
+       int bufnum_mask, bufnum, ver = 0;
 
        int csor, cspr;
        int pos = 0;
@@ -134,6 +130,10 @@ static int nand_load(uint32_t offs, unsigned int uboot_size, void *vdst)
                        bad_marker = 5;
        }
 
+       ver = ifc_in32(&ifc->ifc_rev);
+       if (ver >= FSL_IFC_V2_0_0)
+               bufnum_mask = (bufnum_mask * 2) + 1;
+
        pages_per_blk =
                32 << ((csor & CSOR_NAND_PB_MASK) >> CSOR_NAND_PB_SHIFT);
 
@@ -217,15 +217,6 @@ static int nand_load(uint32_t offs, unsigned int uboot_size, void *vdst)
        return 0;
 }
 
-/*
- * Defines a static function nand_load_image() here, because non-static makes
- * the code too large for certain SPLs(minimal SPL, maximum size <= 4Kbytes)
- */
-#ifndef CONFIG_TPL_BUILD
-#define nand_spl_load_image(offs, uboot_size, vdst) \
-       nand_load(offs, uboot_size, vdst)
-#endif
-
 /*
  * Main entrypoint for NAND Boot. It's necessary that SDRAM is already
  * configured and available since this code loads the main U-boot image