Flex-OneNAND support
Subsystems (3)
PATCH 1/1 Flex-OneNAND support
Hi,
This is a repost of the Flex-OneNAND devices support. Changes since the last post:
- Fix bug which caused 2X program in OneNAND to fail.
- Fix bug with eraseregions containing odd number of blocks.
- Add routine to check blocks are erased before changing boundary.
Thanks,
Rohit
--- drivers/mtd/onenand/Kconfig | 62 +++ drivers/mtd/onenand/onenand_base.c | 829 ++++++++++++++++++++++++++++++++---- drivers/mtd/onenand/onenand_bbt.c | 13 +- drivers/mtd/onenand/onenand_sim.c | 76 +++- include/linux/mtd/onenand.h | 41 ++ include/linux/mtd/onenand_regs.h | 20 +- 6 files changed, 950 insertions(+), 91 deletions(-)
drivers/mtd/onenand/Kconfig +62 -0
@@ -71,4 +71,66 @@ config MTD_ONENAND_SIM The simulator may simulate various OneNAND flash chips for the OneNAND MTD layer. +config MTD_FLEXONENAND_BOUNDARY + bool "Flex-OneNAND Boundary Configuration" + depends on MTD_ONENAND + default n + help + Set SLC and MLC regions of Flex-OneNAND + +config MTD_FLEXONENAND_DIE0_BOUNDARY + int "Last SLC Block of Flex-OneNAND (min = 0, max = 1023)" + depends on MTD_ONENAND && MTD_FLEXONENAND_BOUNDARY + default "-1" + help + Configure Partition Information (PI) of Flex-OneNAND + + Entered value indicates index of last SLC block on Flex-OneNAND. + The remaining blocks are configured as MLC blocks. + + A value of -1 means that PI remains unchanged. + + This setting applies to : + - SDP Flex-OneNAND + - Die 1 of DDP Flex-OneNAND. + +config MTD_FLEXONENAND_DIE0_ISLOCKED + bool "Lock Boundary of Flex-OneNAND" + depends on MTD_ONENAND && MTD_FLEXONENAND_BOUNDARY + default n + help + Configure if Flex-OneNAND boundary should be locked. + Once locked, the boundary cannot be changed. + + This setting applies to : + - SDP Flex-OneNAND + - Die 1 of DDP Flex-OneNAND + +config MTD_FLEXONENAND_DDP_BOUNDARY + bool "Flex-OneNAND DDP Boundary Configuration" + depends on MTD_ONENAND && MTD_FLEXONENAND_BOUNDARY + default n + help + Set SLC and MLC regions of Die 2 of Flex-OneNAND DDP + +config MTD_FLEXONENAND_DIE1_BOUNDARY + int "Last SLC Block of Flex-OneNAND Die 2 (min = 0, max = 1023)" + depends on MTD_ONENAND && MTD_FLEXONENAND_BOUNDARY && MTD_FLEXONENAND_DDP_BOUNDARY + default "-1" + help + Configure Partition Information (PI) for Die 2 of DDP Flex-OneNAND. + + Entered value indicates index of last SLC block on Flex-OneNAND. + The remaining blocks are configured as MLC blocks. + + A value of -1 means that PI remains unchanged. + +config MTD_FLEXONENAND_DIE1_ISLOCKED + bool "Lock Boundary of Flex-OneNAND Die 2" + depends on MTD_ONENAND && MTD_FLEXONENAND_BOUNDARY && MTD_FLEXONENAND_DDP_BOUNDARY + default n + help + Configure if boundary for Die 2 of DDP Flex-OneNAND should be locked. + Once locked, the boundary cannot be changed. + endif # MTD_ONENAND
drivers/mtd/onenand/onenand_base.c +750 -79
1,226 lines not on this page · raw message
drivers/mtd/onenand/onenand_bbt.c +9 -4
@@ -60,6 +60,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descrstruct bbm_info *bbm = this->bbm;int i, j, numblocks, len, scanlen;int startblock; +unsigned slc =0 ;loff_t from;size_t readlen, ooblen;struct mtd_oob_ops ops;
@@ -76,7 +77,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr/* Note that numblocks is 2 * (real numblocks) here; * see i += 2 below as it makses shifting and masking less painful */ - numblocks = mtd->size >> (bbm->bbt_erase_shift -1 ); + numblocks = this->chipsize >> (bbm->bbt_erase_shift -1 ); startblock =0 ; from =0 ;
@@ -106,7 +107,11 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr } } i +=2 ; - from += (1 << bbm->bbt_erase_shift); +onenand_get_block (this, from, &slc); +if (slc) + from += (1 << bbm->bbt_erase_shift) >>1 ; +else + from += (1 << bbm->bbt_erase_shift); }return 0 ;
@@ -143,7 +148,7 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)uint8_t res;/* Get block number * 2 */ - block = (int ) (offs >> (bbm->bbt_erase_shift -1 )); + block = (int ) (onenand_get_block (this, offs,NULL ) <<1 ); res = (bbm->bbt[block >>3 ] >> (block &0x06 )) &0x03 ; DEBUG(MTD_DEBUG_LEVEL2, "onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
@@ -178,7 +183,7 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)struct bbm_info *bbm = this->bbm;int len, ret =0 ; - len = mtd->size >> (this->erase_shift +2 ); + len = this->chipsize >> (this->erase_shift +2 );/* Allocate memory (2bit per block) and clear the memory bad block table */ bbm->bbt =kzalloc (len,GFP_KERNEL );if (!bbm->bbt) {
drivers/mtd/onenand/onenand_sim.c +70 -6
166 lines not on this page · raw message
include/linux/mtd/onenand.h +41 -0
82 lines not on this page · raw message
include/linux/mtd/onenand_regs.h +18 -2
@@ -67,6 +67,9 @@/* * Device ID Register F001h (R) */ +#define DEVICE_IS_FLEXONENAND (1 << 9) +#define FLEXONENAND_PI_MASK (0x3ff) +#define FLEXONENAND_PI_UNLOCK_SHIFT (14)#define ONENAND_DEVICE_DENSITY_MASK (0xf)#define ONENAND_DEVICE_DENSITY_SHIFT (4)#define ONENAND_DEVICE_IS_DDP (1 << 3)
@@ -84,6 +87,11 @@#define ONENAND_VERSION_PROCESS_SHIFT (8)/* +* Technology Register F006h (R) +*/ +#define ONENAND_TECHNOLOGY_IS_MLC (1 << 0) + +/* * Start Address 1 F100h (R/W) & Start Address 2 F101h (R/W) */ #define ONENAND_DDP_SHIFT (15)
@@ -93,7 +101,8 @@/* * Start Address 8 F107h (R/W) */ -#define ONENAND_FPA_MASK (0x3f) +/* Note: It's actually 0x3f in case of SLC */ +#define ONENAND_FPA_MASK (0x7f)#define ONENAND_FPA_SHIFT (2)#define ONENAND_FSA_MASK (0x03)
@@ -105,7 +114,8 @@#define ONENAND_BSA_BOOTRAM (0 << 2)#define ONENAND_BSA_DATARAM0 (2 << 2)#define ONENAND_BSA_DATARAM1 (3 << 2) -#define ONENAND_BSC_MASK (0x03) +/* Note: It's actually 0x03 in case of SLC */ +#define ONENAND_BSC_MASK (0x07)/* * Command Register F220h (R/W)
@@ -124,9 +134,13 @@#define ONENAND_CMD_RESET (0xF0)#define ONENAND_CMD_OTP_ACCESS (0x65)#define ONENAND_CMD_READID (0x90) +#define FLEXONENAND_CMD_PI_UPDATE (0x05) +#define FLEXONENAND_CMD_PI_ACCESS (0x66) +#define FLEXONENAND_CMD_RECOVER_LSB (0x05)/* NOTE: Those are not *REAL* commands */ #define ONENAND_CMD_BUFFERRAM (0x1978) +#define FLEXONENAND_CMD_READ_PI (0x1985)/* * System Configuration 1 Register F221h (R, R/W)
@@ -192,10 +206,12 @@#define ONENAND_ECC_1BIT_ALL (0x5555)#define ONENAND_ECC_2BIT (1 << 1)#define ONENAND_ECC_2BIT_ALL (0xAAAA) +#define FLEXONENAND_UNCORRECTABLE_ERROR (0x1010)/* * One-Time Programmable (OTP) */ +#define FLEXONENAND_OTP_LOCK_OFFSET (2048)#define ONENAND_OTP_LOCK_OFFSET (14)#endif /* __ONENAND_REG_H */
Signature · 1 line
1.5.4.3