aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2012-09-13 02:57:52 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-09-29 10:54:19 -0400
commit7db03eccfc23783a95dd78383b3fad55224aaa7b (patch)
tree5d9c827c7e61ad862c270ced408f0c3b2529bc27
parent2caf87a49eb53fac266b1271ebd6c1d1daa0d0d0 (diff)
mtd: add helpers to set/get features for ONFI nand
Add the set-features(0xef)/get-features(0xee) helpers for ONFI nand. Also add the necessary macros. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/nand/nand_base.c50
-rw-r--r--include/linux/mtd/nand.h14
2 files changed, 64 insertions, 0 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 88f671cb96c7..d06a80d4ee75 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2700,6 +2700,50 @@ static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
2700} 2700}
2701 2701
2702/** 2702/**
2703 * nand_onfi_set_features- [REPLACEABLE] set features for ONFI nand
2704 * @mtd: MTD device structure
2705 * @chip: nand chip info structure
2706 * @addr: feature address.
2707 * @subfeature_param: the subfeature parameters, a four bytes array.
2708 */
2709static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip,
2710 int addr, uint8_t *subfeature_param)
2711{
2712 int status;
2713
2714 if (!chip->onfi_version)
2715 return -EINVAL;
2716
2717 chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1);
2718 chip->write_buf(mtd, subfeature_param, ONFI_SUBFEATURE_PARAM_LEN);
2719 status = chip->waitfunc(mtd, chip);
2720 if (status & NAND_STATUS_FAIL)
2721 return -EIO;
2722 return 0;
2723}
2724
2725/**
2726 * nand_onfi_get_features- [REPLACEABLE] get features for ONFI nand
2727 * @mtd: MTD device structure
2728 * @chip: nand chip info structure
2729 * @addr: feature address.
2730 * @subfeature_param: the subfeature parameters, a four bytes array.
2731 */
2732static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,
2733 int addr, uint8_t *subfeature_param)
2734{
2735 if (!chip->onfi_version)
2736 return -EINVAL;
2737
2738 /* clear the sub feature parameters */
2739 memset(subfeature_param, 0, ONFI_SUBFEATURE_PARAM_LEN);
2740
2741 chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, addr, -1);
2742 chip->read_buf(mtd, subfeature_param, ONFI_SUBFEATURE_PARAM_LEN);
2743 return 0;
2744}
2745
2746/**
2703 * nand_suspend - [MTD Interface] Suspend the NAND flash 2747 * nand_suspend - [MTD Interface] Suspend the NAND flash
2704 * @mtd: MTD device structure 2748 * @mtd: MTD device structure
2705 */ 2749 */
@@ -3223,6 +3267,12 @@ int nand_scan_tail(struct mtd_info *mtd)
3223 if (!chip->write_page) 3267 if (!chip->write_page)
3224 chip->write_page = nand_write_page; 3268 chip->write_page = nand_write_page;
3225 3269
3270 /* set for ONFI nand */
3271 if (!chip->onfi_set_features)
3272 chip->onfi_set_features = nand_onfi_set_features;
3273 if (!chip->onfi_get_features)
3274 chip->onfi_get_features = nand_onfi_get_features;
3275
3226 /* 3276 /*
3227 * Check ECC mode, default to software if 3byte/512byte hardware ECC is 3277 * Check ECC mode, default to software if 3byte/512byte hardware ECC is
3228 * selected and we have 256 byte pagesize fallback to software ECC 3278 * selected and we have 256 byte pagesize fallback to software ECC
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index d245199ccaf3..922f313970d4 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -92,6 +92,8 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
92#define NAND_CMD_READID 0x90 92#define NAND_CMD_READID 0x90
93#define NAND_CMD_ERASE2 0xd0 93#define NAND_CMD_ERASE2 0xd0
94#define NAND_CMD_PARAM 0xec 94#define NAND_CMD_PARAM 0xec
95#define NAND_CMD_GET_FEATURES 0xee
96#define NAND_CMD_SET_FEATURES 0xef
95#define NAND_CMD_RESET 0xff 97#define NAND_CMD_RESET 0xff
96 98
97#define NAND_CMD_LOCK 0x2a 99#define NAND_CMD_LOCK 0x2a
@@ -229,6 +231,12 @@ typedef enum {
229/* Keep gcc happy */ 231/* Keep gcc happy */
230struct nand_chip; 232struct nand_chip;
231 233
234/* ONFI feature address */
235#define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
236
237/* ONFI subfeature parameters length */
238#define ONFI_SUBFEATURE_PARAM_LEN 4
239
232struct nand_onfi_params { 240struct nand_onfi_params {
233 /* rev info and features block */ 241 /* rev info and features block */
234 /* 'O' 'N' 'F' 'I' */ 242 /* 'O' 'N' 'F' 'I' */
@@ -454,6 +462,8 @@ struct nand_buffers {
454 * non 0 if ONFI supported. 462 * non 0 if ONFI supported.
455 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is 463 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is
456 * supported, 0 otherwise. 464 * supported, 0 otherwise.
465 * @onfi_set_features [REPLACEABLE] set the features for ONFI nand
466 * @onfi_get_features [REPLACEABLE] get the features for ONFI nand
457 * @ecclayout: [REPLACEABLE] the default ECC placement scheme 467 * @ecclayout: [REPLACEABLE] the default ECC placement scheme
458 * @bbt: [INTERN] bad block table pointer 468 * @bbt: [INTERN] bad block table pointer
459 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash 469 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash
@@ -496,6 +506,10 @@ struct nand_chip {
496 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, 506 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
497 const uint8_t *buf, int oob_required, int page, 507 const uint8_t *buf, int oob_required, int page,
498 int cached, int raw); 508 int cached, int raw);
509 int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip,
510 int feature_addr, uint8_t *subfeature_para);
511 int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
512 int feature_addr, uint8_t *subfeature_para);
499 513
500 int chip_delay; 514 int chip_delay;
501 unsigned int options; 515 unsigned int options;