diff options
author | Han Xu <han.xu@nxp.com> | 2017-08-30 15:12:35 -0500 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 2558e3203d8f3d01f690f90b4d2ff2a56712cf6e (patch) | |
tree | 2b335ae92426ba239dd674d508acecd6f9717988 /drivers/mtd | |
parent | 6a10f47451e9d2c4c84cac703821f9497709f788 (diff) |
MLK-16329-1: mtd: fsl-flexspi: fix the unalignment issue for fspi
ARM64 platforms may access FSPI from non-64-bit-aligned address which
causes unalignment fault. Fixed the issue for AHB reading.
Signed-off-by: Han Xu <han.xu@nxp.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/spi-nor/fsl-flexspi.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/mtd/spi-nor/fsl-flexspi.c b/drivers/mtd/spi-nor/fsl-flexspi.c index a6ab4c22c6fe..7828b6b80c2e 100644 --- a/drivers/mtd/spi-nor/fsl-flexspi.c +++ b/drivers/mtd/spi-nor/fsl-flexspi.c @@ -1027,6 +1027,7 @@ static ssize_t fsl_flexspi_read(struct spi_nor *nor, loff_t from, size_t len, u_char *buf) { struct fsl_flexspi *flex = nor->priv; + int i, j; /* if necessary,ioremap buffer before AHB read, */ if (!flex->ahb_addr) { @@ -1059,10 +1060,20 @@ static ssize_t fsl_flexspi_read(struct spi_nor *nor, loff_t from, } } - /* Read out the data directly from the AHB buffer.*/ - memcpy(buf, - flex->ahb_addr + flex->chip_base_addr + from - flex->memmap_offs, - len); + /* For non-8-byte alignment cases */ + if (from % 8) { + j = 8 - (from & 0x7); + for (i = 0; i < j; ++i) { + memcpy(buf + i, flex->ahb_addr + flex->chip_base_addr + + from - flex->memmap_offs + i, 1); + } + memcpy(buf + j, flex->ahb_addr + flex->chip_base_addr + from + - flex->memmap_offs + j, len - j); + } else { + /* Read out the data directly from the AHB buffer.*/ + memcpy(buf, flex->ahb_addr + flex->chip_base_addr + from + - flex->memmap_offs, len); + } return len; } |