]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: spi-nor: Fix read SFDP data in dual parallel mode
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 18 Jun 2021 15:39:04 +0000 (17:39 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 30 Jun 2021 09:26:12 +0000 (11:26 +0200)
Reading the SFDP data is broken in two ways in dual parallel mode in the
current implementation.

1) It reads the data interleaved from both chips, which results in data
that can not be parsed. Since both chips have to be identical for dual
parallel mode the SFDP data will also be identical. So only read the data
from one of the chips.

2) The page, erase and chip size are not update to reflect that they should
be twice as large in dual parallel mode. Fix this by moving the update of
those parameter after running the SFDP detection rather than doing it
before.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
drivers/mtd/spi/spi-nor-core.c

index 0487a27d343b079f550cf3a9943d7f360fc87654..21e4300ceda40d1a95072cd3af58ff7a6405b08f 100644 (file)
@@ -1786,10 +1786,11 @@ static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr,
        nor->addr_width = 3;
        nor->read_dummy = 8;
 
-       if (nor->isparallel)
-               nor->spi->flags |= SPI_XFER_STRIPE;
-
        while (len) {
+               /* Both chips are identical, so should be the SFDP data */
+               if (nor->isparallel)
+                       nor->spi->flags |= SPI_XFER_LOWER;
+
                ret = nor->read(nor, addr, len, (u8 *)buf);
                if (!ret || ret > len) {
                        ret = -EIO;
@@ -2380,12 +2381,6 @@ static int spi_nor_init_params(struct spi_nor *nor,
        params->size = info->sector_size * info->n_sectors;
        params->page_size = info->page_size;
 
-       if (nor->isparallel)
-               params->page_size <<= nor->shift;
-
-       if (nor->isparallel || nor->isstacked)
-               params->size <<= nor->shift;
-
        /* (Fast) Read settings. */
        params->hwcaps.mask |= SNOR_HWCAPS_READ;
        spi_nor_set_read_settings(&params->reads[SNOR_CMD_READ],
@@ -2470,6 +2465,14 @@ static int spi_nor_init_params(struct spi_nor *nor,
                }
        }
 
+       if (nor->isparallel) {
+               nor->mtd.erasesize <<= nor->shift;
+               params->page_size <<= nor->shift;
+       }
+
+       if (nor->isparallel || nor->isstacked)
+               params->size <<= nor->shift;
+
        return 0;
 }