mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
mtd: nand: Support controllers with custom page
If your controller already sends the required NAND commands when reading or writing a page, then the framework is not supposed to send READ0 and SEQIN/PAGEPROG respectively. Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> [Linux commit: 3371d663bb4579f1b2003a92162edd6d90edd089] Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
committed by
Masahiro Yamada
parent
6f84b26b53
commit
1fb87de83d
@@ -1732,6 +1732,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
|
|||||||
__func__, buf);
|
__func__, buf);
|
||||||
|
|
||||||
read_retry:
|
read_retry:
|
||||||
|
if (nand_standard_page_accessors(&chip->ecc))
|
||||||
chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
|
chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2423,6 +2424,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
|
|||||||
else
|
else
|
||||||
subpage = 0;
|
subpage = 0;
|
||||||
|
|
||||||
|
if (nand_standard_page_accessors(&chip->ecc))
|
||||||
chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
|
chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
|
||||||
|
|
||||||
if (unlikely(raw))
|
if (unlikely(raw))
|
||||||
@@ -2446,6 +2448,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
|
|||||||
|
|
||||||
if (!cached || !NAND_HAS_CACHEPROG(chip)) {
|
if (!cached || !NAND_HAS_CACHEPROG(chip)) {
|
||||||
|
|
||||||
|
if (nand_standard_page_accessors(&chip->ecc))
|
||||||
chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
|
chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
|
||||||
status = chip->waitfunc(mtd, chip);
|
status = chip->waitfunc(mtd, chip);
|
||||||
/*
|
/*
|
||||||
@@ -4126,6 +4129,26 @@ static bool nand_ecc_strength_good(struct mtd_info *mtd)
|
|||||||
return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds;
|
return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool invalid_ecc_page_accessors(struct nand_chip *chip)
|
||||||
|
{
|
||||||
|
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
||||||
|
|
||||||
|
if (nand_standard_page_accessors(ecc))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAND_ECC_CUSTOM_PAGE_ACCESS flag is set, make sure the NAND
|
||||||
|
* controller driver implements all the page accessors because
|
||||||
|
* default helpers are not suitable when the core does not
|
||||||
|
* send the READ0/PAGEPROG commands.
|
||||||
|
*/
|
||||||
|
return (!ecc->read_page || !ecc->write_page ||
|
||||||
|
!ecc->read_page_raw || !ecc->write_page_raw ||
|
||||||
|
(NAND_HAS_SUBPAGE_READ(chip) && !ecc->read_subpage) ||
|
||||||
|
(NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage &&
|
||||||
|
ecc->hwctl && ecc->calculate));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_scan_tail - [NAND Interface] Scan for the NAND device
|
* nand_scan_tail - [NAND Interface] Scan for the NAND device
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
@@ -4145,6 +4168,11 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|||||||
BUG_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) &&
|
BUG_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) &&
|
||||||
!(chip->bbt_options & NAND_BBT_USE_FLASH));
|
!(chip->bbt_options & NAND_BBT_USE_FLASH));
|
||||||
|
|
||||||
|
if (invalid_ecc_page_accessors(chip)) {
|
||||||
|
pr_err("Invalid ECC page accessors setup\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(chip->options & NAND_OWN_BUFFERS)) {
|
if (!(chip->options & NAND_OWN_BUFFERS)) {
|
||||||
nbuf = kzalloc(sizeof(struct nand_buffers), GFP_KERNEL);
|
nbuf = kzalloc(sizeof(struct nand_buffers), GFP_KERNEL);
|
||||||
chip->buffers = nbuf;
|
chip->buffers = nbuf;
|
||||||
|
@@ -154,6 +154,12 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
#define NAND_ECC_GENERIC_ERASED_CHECK BIT(0)
|
#define NAND_ECC_GENERIC_ERASED_CHECK BIT(0)
|
||||||
#define NAND_ECC_MAXIMIZE BIT(1)
|
#define NAND_ECC_MAXIMIZE BIT(1)
|
||||||
|
/*
|
||||||
|
* If your controller already sends the required NAND commands when
|
||||||
|
* reading or writing a page, then the framework is not supposed to
|
||||||
|
* send READ0 and SEQIN/PAGEPROG respectively.
|
||||||
|
*/
|
||||||
|
#define NAND_ECC_CUSTOM_PAGE_ACCESS BIT(2)
|
||||||
|
|
||||||
/* Bit mask for flags passed to do_nand_read_ecc */
|
/* Bit mask for flags passed to do_nand_read_ecc */
|
||||||
#define NAND_GET_DEVICE 0x80
|
#define NAND_GET_DEVICE 0x80
|
||||||
@@ -202,6 +208,7 @@ typedef enum {
|
|||||||
/* Macros to identify the above */
|
/* Macros to identify the above */
|
||||||
#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
|
#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
|
||||||
#define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ))
|
#define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ))
|
||||||
|
#define NAND_HAS_SUBPAGE_WRITE(chip) !((chip)->options & NAND_NO_SUBPAGE_WRITE)
|
||||||
|
|
||||||
/* Non chip related options */
|
/* Non chip related options */
|
||||||
/* This option skips the bbt scan during initialization. */
|
/* This option skips the bbt scan during initialization. */
|
||||||
@@ -568,6 +575,11 @@ struct nand_ecc_ctrl {
|
|||||||
int page);
|
int page);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int nand_standard_page_accessors(struct nand_ecc_ctrl *ecc)
|
||||||
|
{
|
||||||
|
return !(ecc->options & NAND_ECC_CUSTOM_PAGE_ACCESS);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct nand_buffers - buffer structure for read/write
|
* struct nand_buffers - buffer structure for read/write
|
||||||
* @ecccalc: buffer pointer for calculated ECC, size is oobsize.
|
* @ecccalc: buffer pointer for calculated ECC, size is oobsize.
|
||||||
|
Reference in New Issue
Block a user