From: fengsheng fengsheng5@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Signed-off-by: fengsheng fengsheng5@huawei.com Reviewed-by: wuyang wuyang7@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c | 2 +- drivers/mtd/hisilicon/sfc/hrd_sflash_core.h | 1 + drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c | 27 ++++++++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c b/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c index 8935263..23254e3 100644 --- a/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c +++ b/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c @@ -26,7 +26,7 @@ #include "hrd_common.h" #include "hrd_sflash_driver.h"
-#define SFC_DRIVER_VERSION "1.9.39.0" +#define SFC_DRIVER_VERSION "1.9.60.0"
static const char *g_sflashMtdList[] = {"sflash", NULL};
diff --git a/drivers/mtd/hisilicon/sfc/hrd_sflash_core.h b/drivers/mtd/hisilicon/sfc/hrd_sflash_core.h index 56c4417..ccf1d48 100644 --- a/drivers/mtd/hisilicon/sfc/hrd_sflash_core.h +++ b/drivers/mtd/hisilicon/sfc/hrd_sflash_core.h @@ -20,6 +20,7 @@ #include "hrd_sflash_driver.h"
#define SFC_HARD_BUF_LEN (256) +#define SPI_FLASH_PAGE_SIZE (256)
#define SPI_CMD_SR_WIP 1 /* Write in Progress bit in status register position */ #define SPI_CMD_RDSR 0x05 /* Read Status Register */ diff --git a/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c b/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c index ec9887a7..81fed47 100644 --- a/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c +++ b/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c @@ -731,7 +731,7 @@ static s32 _SFC_RegModeWrite(struct SFC_SFLASH_INFO *sflash, pr_err("[SFC] [%s %d]: SFC_RegWordAlignWrite fail\n", __func__, __LINE__); return slRet; } - i += ulRemain&(~0x3); + i += ulRemain & (~0x3); }
for (; i < ulWriteLen; i++) { @@ -749,6 +749,9 @@ s32 SFC_RegModeWrite(struct SFC_SFLASH_INFO *sflash, u32 offset, const u8 *pucSrc, u32 ulWriteLen) { s32 slRet; + u32 ulPageRemain; + u32 offsetTmp = offset; + u8 *pucSrcTmp = (u8 *)pucSrc;
if (!pucSrc) { pr_err("[SFC] [%s %d]: Pointer is null\n", __func__, __LINE__); @@ -762,9 +765,23 @@ s32 SFC_RegModeWrite(struct SFC_SFLASH_INFO *sflash,
SFC_CheckErr(sflash);
- slRet = _SFC_RegModeWrite(sflash, offset, pucSrc, ulWriteLen); - if (slRet != HRD_OK) - return slRet; + /* the size of data remaining on the first page */ + ulPageRemain = SPI_FLASH_PAGE_SIZE - (offset % SPI_FLASH_PAGE_SIZE); + if (ulWriteLen >= ulPageRemain) { + slRet = _SFC_RegModeWrite(sflash, offsetTmp, pucSrcTmp, ulPageRemain); + if (slRet != HRD_OK) + return slRet; + + offsetTmp += ulPageRemain; + pucSrcTmp += ulPageRemain; + ulWriteLen -= ulPageRemain; + } + + if (ulWriteLen) { + slRet = _SFC_RegModeWrite(sflash, offsetTmp, pucSrcTmp, ulWriteLen); + if (slRet != HRD_OK) + return slRet; + }
if (SFC_IsOpErr(sflash->sfc_reg_base)) return HRD_ERR; @@ -809,7 +826,7 @@ s32 SFC_RegModeRead(struct SFC_SFLASH_INFO *sflash, pr_err("[SFC] [%s %d]: SFC_RegWordAlignRead fail\n", __func__, __LINE__); return ret; } - i += ulRemain&(~0x3); + i += ulRemain & (~0x3); }
for (; i < ulReadLen; i++) {