Skip to content

Commit 8429bb3

Browse files
mtd: nand: support Micron READ RETRY
Micron provides READ RETRY support via the ONFI vendor-specific parameter block (to indicate how many read-retry modes are available) and the ONFI {GET,SET}_FEATURES commands with a vendor-specific feature address (to support reading/switching the current read-retry mode). The recommended sequence is as follows: 1. Perform PAGE_READ operation 2. If no ECC error, we are done 3. Run SET_FEATURES with feature address 89h, mode 1 4. Retry PAGE_READ operation 5. If ECC error and there are remaining supported modes, increment the mode and return to step 3. Otherwise, this is a true ECC error. 6. Run SET_FEATURES with feature address 89h, mode 0, to return to the default state. This patch implements the chip->setup_read_retry() callback for Micron and fills in the chip->read_retries. Tested on Micron MT29F32G08CBADA, which supports 8 read-retry modes. The Micron vendor-specific table was checked against the datasheets for the following Micron NAND: Needs retry Cell-type Part number Vendor revision Byte 180 ----------- --------- ---------------- --------------- ------------ No SLC MT29F16G08ABABA 1 Reserved (0) No MLC MT29F32G08CBABA 1 Reserved (0) No SLC MT29F1G08AACWP 1 0 Yes MLC MT29F32G08CBADA 1 08h Yes MLC MT29F64G08CBABA 2 08h Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Huang Shijie <b32955@freescale.com>
1 parent ba84fb5 commit 8429bb3

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,6 +2979,30 @@ static int nand_flash_detect_ext_param_page(struct mtd_info *mtd,
29792979
return ret;
29802980
}
29812981

2982+
static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode)
2983+
{
2984+
struct nand_chip *chip = mtd->priv;
2985+
uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode};
2986+
2987+
return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY,
2988+
feature);
2989+
}
2990+
2991+
/*
2992+
* Configure chip properties from Micron vendor-specific ONFI table
2993+
*/
2994+
static void nand_onfi_detect_micron(struct nand_chip *chip,
2995+
struct nand_onfi_params *p)
2996+
{
2997+
struct nand_onfi_vendor_micron *micron = (void *)p->vendor;
2998+
2999+
if (le16_to_cpu(p->vendor_revision) < 1)
3000+
return;
3001+
3002+
chip->read_retries = micron->read_retry_options;
3003+
chip->setup_read_retry = nand_setup_read_retry_micron;
3004+
}
3005+
29823006
/*
29833007
* Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise.
29843008
*/
@@ -3085,6 +3109,9 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
30853109
pr_warn("Could not retrieve ONFI ECC requirements\n");
30863110
}
30873111

3112+
if (p->jedec_id == NAND_MFR_MICRON)
3113+
nand_onfi_detect_micron(chip, p);
3114+
30883115
return 1;
30893116
}
30903117

‎include/linux/mtd/nand.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ struct nand_chip;
219219
/* ONFI feature address */
220220
#define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
221221

222+
/* Vendor-specific feature address (Micron) */
223+
#define ONFI_FEATURE_ADDR_READ_RETRY 0x89
224+
222225
/* ONFI subfeature parameters length */
223226
#define ONFI_SUBFEATURE_PARAM_LEN 4
224227

0 commit comments

Comments
 (0)