mtd: Flex-OneNAND support
PATCH 1/14 mtd: Flex-OneNAND support
From: Rohit Hagargundgi <[email protected]>
Add support for Samsung Flex-OneNAND devices.
Flex-OneNAND combines SLC and MLC technologies into a single device. SLC area provides increased reliability and speed, suitable for storing code such as bootloader, kernel and root file system. MLC area provides high density and is suitable for storing user data.
SLC and MLC regions can be configured through kernel parameter.
---
Documentation/kernel-parameters.txt | 10 drivers/mtd/onenand/onenand_base.c | 857 +++++++++++++++++++++++--- drivers/mtd/onenand/onenand_bbt.c | 14 drivers/mtd/onenand/onenand_sim.c | 81 ++ include/linux/mtd/onenand.h | 18 include/linux/mtd/onenand_regs.h | 20 6 files changed, 913 insertions(+), 87 deletions(-)
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~mtd-flex-onenand-support +10 -0
@@ -1385,6 +1385,16 @@ and is between 256 and 4096 characters. mtdparts= [MTD] See drivers/mtd/cmdlinepart.c. + onenand.bdry= [HW,MTD] Flex-OneNAND Boundary Configuration + + Format: [die0_boundary][,die0_lock][,die1_boundary][,die1_lock] + + boundary - index of last SLC block on Flex-OneNAND. + The remaining blocks are configured as MLC blocks. + lock - Configure if Flex-OneNAND boundary should be locked. + Once locked, the boundary cannot be changed. + 1 indicates lock status, 0 indicates unlock status. + mtdset= [ARM] ARM/S3C2412 JIVE boot control
drivers/mtd/onenand/onenand_base.c renamed from drivers/mtd/onenand/onenand_base.c~mtd-flex-onenand-support +783 -74
1,238 lines not on this page · raw message
drivers/mtd/onenand/onenand_bbt.c renamed from drivers/mtd/onenand/onenand_bbt.c~mtd-flex-onenand-support +10 -4
@@ -63,6 +63,7 @@ static int create_bbt(struct mtd_info *mloff_t from;size_t readlen, ooblen;struct mtd_oob_ops ops; +int rgn;printk (KERN_INFO "Scanning device for bad blocks\n" );
@@ -76,7 +77,7 @@ static int create_bbt(struct mtd_info *m/* 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,12 @@ static int create_bbt(struct mtd_info *m } } i +=2 ; - from += (1 << bbm->bbt_erase_shift); + +if (FLEXONENAND (this)) { + rgn =flexonenand_region (mtd, from); + from += mtd->eraseregions[rgn].erasesize; + }else + from += (1 << bbm->bbt_erase_shift); }return 0 ;
@@ -143,7 +149,7 @@ static int onenand_isbad_bbt(struct mtd_uint8_t res;/* Get block number * 2 */ - block = (int ) (offs >> (bbm->bbt_erase_shift -1 )); + block = (int ) (onenand_block (this, offs) <<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 +184,7 @@ int onenand_scan_bbt(struct mtd_info *mtstruct 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 renamed from drivers/mtd/onenand/onenand_sim.c~mtd-flex-onenand-support +74 -7
170 lines not on this page · raw message
include/linux/mtd/onenand.h renamed from include/linux/mtd/onenand.h~mtd-flex-onenand-support +18 -0
@@ -17,6 +17,7 @@#include <linux/mtd/onenand_regs.h> #include <linux/mtd/bbm.h> +#define MAX_DIES 2#define MAX_BUFFERRAM 2/* Scan and identify a OneNAND device */
@@ -51,7 +52,12 @@ struct onenand_bufferram {/** * struct onenand_chip - OneNAND Private Flash Chip Data * @base: [BOARDSPECIFIC] address to access OneNAND +* @dies: [INTERN][FLEX-ONENAND] number of dies on chip +* @boundary: [INTERN][FLEX-ONENAND] Boundary of the dies +* @diesize: [INTERN][FLEX-ONENAND] Size of the dies * @chipsize: [INTERN] the size of one chip for multichip arrays +* FIXME For Flex-OneNAND, chipsize holds maximum possible +* device size ie when all blocks are considered MLC * @device_id: [INTERN] device ID * @density_mask: chip density, used for DDP devices * @verstion_id: [INTERN] version ID
@@ -92,9 +98,13 @@ struct onenand_bufferram {*/ struct onenand_chip {void __iomem *base; +unsigned dies; +unsigned boundary[MAX_DIES ]; +loff_t diesize[MAX_DIES ];unsigned int chipsize;unsigned int device_id;unsigned int version_id; +unsigned int technology;unsigned int density_mask;unsigned int options;
@@ -145,6 +155,8 @@ struct onenand_chip {#define ONENAND_SET_BUFFERRAM0 (this) (this->bufferram_index = 0)#define ONENAND_SET_BUFFERRAM1 (this) (this->bufferram_index = 1) +#define FLEXONENAND (this) \ + (this->device_id & DEVICE_IS_FLEXONENAND)#define ONENAND_GET_SYS_CFG1 (this) \ (this->read_word(this->base + ONENAND_REG_SYS_CFG1))#define ONENAND_SET_SYS_CFG1 (v, this) \
@@ -153,6 +165,9 @@ struct onenand_chip {#define ONENAND_IS_DDP (this) \ (this->device_id & ONENAND_DEVICE_IS_DDP) +#define ONENAND_IS_MLC (this) \ + (this->technology & ONENAND_TECHNOLOGY_IS_MLC) +#ifdef CONFIG_MTD_ONENAND_2X_PROGRAM #define ONENAND_IS_2PLANE (this) \ (this->options & ONENAND_HAS_2PLANE)
@@ -189,5 +204,8 @@ struct onenand_manufacturers {int onenand_bbt_read_oob (struct mtd_info *mtd,loff_t from,struct mtd_oob_ops *ops); +unsigned onenand_block (struct onenand_chip *this,loff_t addr); +loff_t onenand_addr (struct onenand_chip *this,int block); +int flexonenand_region (struct mtd_info *mtd,loff_t addr);#endif /* __LINUX_MTD_ONENAND_H */
include/linux/mtd/onenand_regs.h renamed from include/linux/mtd/onenand_regs.h~mtd-flex-onenand-support +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 */
_
Quoted 10 lines · On Tue, 2009-05-12 at 13:46 -0700, [email protected] wrote:
From: Rohit Hagargundgi <[email protected]>
Add support for Samsung Flex-OneNAND devices.
Flex-OneNAND combines SLC and MLC technologies into a single device. SLC area provides increased reliability and speed, suitable for storing code such as bootloader, kernel and root file system. MLC area provides high density and is suitable for storing user data.
SLC and MLC regions can be configured through kernel parameter.
Adrian,
I remember you once reviewed Rohit's patch, tested it, and acked it. Does this version have your ack?
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 11 lines · On Tue, 2009-05-12 at 13:46 -0700, [email protected] wrote:
From: Rohit Hagargundgi <[email protected]>
Add support for Samsung Flex-OneNAND devices.
Flex-OneNAND combines SLC and MLC technologies into a single device. SLC area provides increased reliability and speed, suitable for storing code such as bootloader, kernel and root file system. MLC area provides high density and is suitable for storing user data.
SLC and MLC regions can be configured through kernel parameter.
Quoted 7 lines
[[email protected]: export flexoand_region and onenand_addr]Signed-off-by Rohit Hagargundgi <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Cc David Woodhouse <[email protected]>Cc Vishak G <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
Hi Andrew,
you sent this bunch of patches to MTD ML. What does it mean? Does it mean you are going to send them to Linus some time later? Or you want review, or acks?
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 5 lines · Artem Bityutskiy
Hi Andrew,
you sent this bunch of patches to MTD ML. What does it mean? Does it mean you are going to send them to Linus some time later? Or you want review, or acks?
The patches are in the -mm tree, so he would like David Woodhouse to decide what to do with each one. It is also an opportunity for anybody on the cc: list to review them and send feedback.
Here is a document that explains the process:
http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt
Quoted 8 lines · On Fri, 15 May 2009 15:07:26 -0700 Kevin Cernekee <[email protected]> wrote:
Quoted 5 lines · Artem Bityutskiy
Hi Andrew,
you sent this bunch of patches to MTD ML. What does it mean? Does it mean you are going to send them to Linus some time later? Or you want review, or acks?
Quoted 6 lines
The patches are in the -mm tree, so he would like David Woodhouse to decide what to do with each one. It is also an opportunity for anybody on the cc: list to review them and send feedback.
Here is a document that explains the process:
http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt
Yup. The headers tell it all:
To:dwmw2
Cc:people-and-mailing-lists
Quoted 11 lines · On Tue, 2009-05-12 at 13:46 -0700, [email protected] wrote:
From: Rohit Hagargundgi <[email protected]>
Add support for Samsung Flex-OneNAND devices.
Flex-OneNAND combines SLC and MLC technologies into a single device. SLC area provides increased reliability and speed, suitable for storing code such as bootloader, kernel and root file system. MLC area provides high density and is suitable for storing user data.
SLC and MLC regions can be configured through kernel parameter.
Quoted 7 lines
[[email protected]: export flexoand_region and onenand_addr]Signed-off-by Rohit Hagargundgi <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Cc David Woodhouse <[email protected]>Cc Vishak G <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
I get the following warning when compile this:
drivers/mtd/onenand/onenand_base.c:3263: warning: ‘flexonenand_setup’ defined but not used
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)