drivers: rkflash: fix error in SPI Nand ECC refresh case

Change-Id: I4d4797631270ffc3fb6177dceae3009e63c5fa6a
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin
2019-11-04 14:14:46 +08:00
committed by Tao Huang
parent 71aba3f2bc
commit c568d24da7
8 changed files with 18 additions and 16 deletions

View File

@@ -8,10 +8,10 @@
#ifdef CONFIG_RK_NANDC_NAND
#include "flash.h"
#endif
#ifdef CONFIG_RK_SFC_NOR
#ifdef CONFIG_RK_SFC_NAND
#include "sfc_nand.h"
#endif
#ifdef CONFIG_RK_SFC_NAND
#ifdef CONFIG_RK_SFC_NOR
#include "sfc_nor.h"
#endif

View File

@@ -73,7 +73,7 @@ static unsigned long rkflash_req_jiffies;
static unsigned int rknand_req_do;
/* For rkflash dev private data, including mtd dev and block dev */
static int rkflash_dev_initialised;
static int rkflash_dev_initialised = 0;
static DEFINE_MUTEX(g_flash_ops_mutex);
static int rkflash_flash_gc(void)
@@ -712,13 +712,13 @@ int rkflash_dev_init(void __iomem *reg_addr,
case FLASH_TYPE_SFC_NOR:
#ifdef CONFIG_RK_SFC_NOR_MTD
ret = sfc_nor_mtd_init(sfnor_dev, &g_flash_ops_mutex);
pr_err("%s device register as blk dev, ret= %d\n", __func__, ret);
pr_err("%s device register as mtd dev, ret= %d\n", __func__, ret);
break;
#endif
case FLASH_TYPE_SFC_NAND:
#ifdef CONFIG_RK_SFC_NAND_MTD
ret = sfc_nand_mtd_init(sfnand_dev, &g_flash_ops_mutex);
pr_err("%s device register as blk dev, ret= %d\n", __func__, ret);
pr_err("%s device register as mtd dev, ret= %d\n", __func__, ret);
break;
#endif
case FLASH_TYPE_NANDC_NAND:

View File

@@ -95,8 +95,12 @@ struct STRUCT_PART_INFO {
} __packed;
/* Including Dev APIs */
#ifdef CONFIG_RK_SFC_NAND_MTD
int sfc_nand_mtd_init(struct SFNAND_DEV *p_dev, struct mutex *lock);
#endif
#ifdef CONFIG_RK_SFC_NOR_MTD
int sfc_nor_mtd_init(struct SFNOR_DEV *p_dev, struct mutex *lock);
#endif
int rkflash_dev_suspend(void);
int rkflash_dev_resume(void __iomem *reg_addr);

View File

@@ -8,7 +8,6 @@
#include <linux/slab.h>
#include "rkflash_debug.h"
#include "sfc.h"
#include "sfc_nand.h"
static struct nand_info spi_nand_tbl[] = {
@@ -574,7 +573,10 @@ u32 sfc_nand_check_bad_block(u8 cs, u32 addr)
ret = sfc_nand_read_page_raw(cs, addr, gp_page_buf);
if (ret == SFC_NAND_ECC_ERROR)
return true;
rkflash_print_error("%s page= %x ret= %x data0= %x, spare0= %x\n",
__func__, addr, ret, gp_page_buf[0],
(gp_page_buf[data_size / 4] & 0xFF));
/* Original bad block */
if ((gp_page_buf[data_size / 4] & 0xFF) != 0xFF)
return true;

View File

@@ -6,6 +6,7 @@
#define __SFC_NAND_H
#include "flash_com.h"
#include "sfc.h"
#define SFC_NAND_PROG_ERASE_ERROR 2
#define SFC_NAND_HW_ERROR 1

View File

@@ -6,7 +6,6 @@
#include "rkflash_api.h"
#include "rk_sftl.h"
#include "sfc_nand.h"
struct SFNAND_DEV *sfnand_dev;

View File

@@ -124,20 +124,18 @@ static int sfc_read_mtd(struct mtd_info *mtd, loff_t from, size_t len,
while (remaing) {
memset(p_dev->dma_buf, 0xa5, SFC_NAND_PAGE_MAX_SIZE);
ret = sfc_nand_read_page(0, addr / page_size, (u32 *)p_dev->dma_buf, spare);
if (ret == SFC_NAND_HW_ERROR)
break;
if (ret == SFC_NAND_ECC_ERROR) {
rkflash_print_dio("%s addr %x ret= %d\n",
__func__, addr, ret);
rkflash_print_error("%s addr %x ret= %d\n",
__func__, addr, ret);
mtd->ecc_stats.failed++;
ecc_failed = true;
ret = 0;
} else if (ret == SFC_NAND_ECC_REFRESH) {
rkflash_print_dio("%s addr %x ret= %d\n",
__func__, addr, ret);
mtd->ecc_stats.corrected += 1;
max_bitflips = 1;
ret = 0;
}
off = addr & mtd->writesize_mask;
@@ -181,7 +179,7 @@ static int sfc_markbad_mtd(struct mtd_info *mtd, loff_t ofs)
u32 ret;
struct snand_mtd_dev *p_dev = mtd_to_priv(mtd);
rkflash_print_dio("%s %llx\n", __func__, ofs);
rkflash_print_error("%s %llx\n", __func__, ofs);
if (ofs & mtd->erasesize_mask)
return -EINVAL;
@@ -287,4 +285,3 @@ error_out:
return ret;
}

View File

@@ -265,4 +265,3 @@ error_out:
return ret;
}