Add support for Samsung SoC OneNAND controllers
Subsystems (3)
PATCH v2 1/1 Add support for Samsung SoC OneNAND controllers
This patch series add support for Samsung SoC OneNAND controllers found on S3C64xx, S5PC100 and S5PC110 chips. A few extensions to OneNAND core were required to make the driver working properly on all supported SoCs.
The required platform setup code has been posted to relevant mailing list (ARM Kernel: "[PATCH] ARM: Samsung: Add platform support code for OneNAND controller" thread).
Changes since v1:
* addressed all coding style issues reported by Ben Dooks
* moved all resource definitions to platform device resources
* moved all resource definitions for different SoCs from regs-onenand.h to arch/arm/mach-{s3c64xx,s5pc100,s5pv210}/include/mach/map.h
* moved all #ifdef conditional code to separate functions
This patch series includes:
[PATCH 1/5] drivers: mtd: onenand: add support for chips with 4KB page size [PATCH 2/5] drivers: mtd: onenand: allocate verify buffer in the core [PATCH 3/5] drivers: mtd: onenand: add new callback for bufferram read [PATCH 4/5] drivers: mtd: onenand: add workaround for SYNC_WRITE mode [PATCH 5/5] drivers: mtd: add Samsung SoC OneNAND driver
PATCH 1/5 drivers: mtd: onenand: add support for chips with 4KB page size
From: Kyungmin Park <[email protected]>
This patch adds support for OneNAND chips that have 4KB page size.
--- drivers/mtd/onenand/onenand_base.c | 32 +++++++++++++++++++------------- include/linux/mtd/onenand.h | 4 ++++ 2 files changed, 23 insertions(+), 13 deletions(-)
drivers/mtd/onenand/onenand_base.c +19 -13
@@ -397,7 +397,8 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le value =onenand_bufferram_address (this, block); this->write_word (value, this->base +ONENAND_REG_START_ADDRESS2 ); -if (ONENAND_IS_MLC (this) ||ONENAND_IS_2PLANE (this)) +if (ONENAND_IS_MLC (this) ||ONENAND_IS_2PLANE (this) || +ONENAND_IS_4KB_PAGE (this))/* It is always BufferRAM0 */ ONENAND_SET_BUFFERRAM0 (this);else
@@ -426,7 +427,7 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t lecase FLEXONENAND_CMD_RECOVER_LSB :case ONENAND_CMD_READ :case ONENAND_CMD_READOOB : -if (ONENAND_IS_MLC (this)) +if (ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this))/* It is always BufferRAM0 */ dataram =ONENAND_SET_BUFFERRAM0 (this);else
@@ -466,11 +467,11 @@ static inline int onenand_read_ecc(struct onenand_chip *this) {int ecc, i, result =0 ; -if (!FLEXONENAND (this)) +if (!FLEXONENAND (this) && !ONENAND_IS_4KB_PAGE (this))return this->read_word (this->base +ONENAND_REG_ECC_STATUS );for (i =0 ; i <4 ; i++) { - ecc = this->read_word (this->base +ONENAND_REG_ECC_STATUS + i); + ecc = this->read_word (this->base +ONENAND_REG_ECC_STATUS + i*2 );if (likely (!ecc))continue ;if (ecc &FLEXONENAND_UNCORRECTABLE_ERROR )
@@ -1425,7 +1426,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,int ret;onenand_get_device (mtd,FL_READING ); - ret =ONENAND_IS_MLC (this) ? + ret =ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this) ?onenand_mlc_read_ops_nolock (mtd, from, &ops) :onenand_read_ops_nolock (mtd, from, &ops);onenand_release_device (mtd);
@@ -1460,7 +1461,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from,onenand_get_device (mtd,FL_READING );if (ops->datbuf) - ret =ONENAND_IS_MLC (this) ? + ret =ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this) ?onenand_mlc_read_ops_nolock (mtd, from, ops) :onenand_read_ops_nolock (mtd, from, ops);else
@@ -1926,7 +1927,7 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,* 2 PLANE, MLC, and Flex-OneNAND do not support * write-while-program feature. */ -if (!ONENAND_IS_2PLANE (this) && !first) { +if (!ONENAND_IS_2PLANE (this) && !ONENAND_IS_4KB_PAGE (this) && !first) {ONENAND_SET_PREV_BUFFERRAM (this); ret = this->wait (mtd,FL_WRITING );
@@ -1957,7 +1958,7 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,/* * 2 PLANE, MLC, and Flex-OneNAND wait here */ -if (ONENAND_IS_2PLANE (this)) { +if (ONENAND_IS_2PLANE (this) ||ONENAND_IS_4KB_PAGE (this)) { ret = this->wait (mtd,FL_WRITING );/* In partial page write we don't update bufferram */
@@ -2084,7 +2085,7 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,memcpy (oobbuf + column, buf, thislen); this->write_bufferram (mtd,ONENAND_SPARERAM , oobbuf,0 , mtd->oobsize); -if (ONENAND_IS_MLC (this)) { +if (ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this)) {/* Set main area of DataRAM to 0xff*/ memset (this->page_buf,0xff , mtd->writesize); this->write_bufferram(mtd, ONENAND_DATARAM,
@@ -3027,7 +3028,7 @@ static int do_otp_read(struct mtd_info *mtd, loff_t from, size_t len, this->command (mtd,ONENAND_CMD_OTP_ACCESS ,0 ,0 ); this->wait (mtd,FL_OTPING ); - ret =ONENAND_IS_MLC (this) ? + ret =ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this) ?onenand_mlc_read_ops_nolock (mtd, from, &ops) :onenand_read_ops_nolock (mtd, from, &ops);
@@ -3372,7 +3373,10 @@ static void onenand_check_features(struct mtd_info *mtd)/* Lock scheme */ switch (density) {case ONENAND_DEVICE_DENSITY_4Gb: - this->options |=ONENAND_HAS_2PLANE ; +if (ONENAND_IS_DDP (this)) + this->options |=ONENAND_HAS_2PLANE ; +else + this->options |=ONENAND_HAS_4KB_PAGE ;case ONENAND_DEVICE_DENSITY_2Gb:/* 2Gb DDP does not have 2 plane */
@@ -3393,7 +3397,7 @@ static void onenand_check_features(struct mtd_info *mtd)break ; } -if (ONENAND_IS_MLC (this)) +if (ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this)) this->options &= ~ONENAND_HAS_2PLANE ;if (FLEXONENAND (this)) {
@@ -3407,6 +3411,8 @@ static void onenand_check_features(struct mtd_info *mtd)printk (KERN_DEBUG "Chip support all block unlock\n" );if (this->options &ONENAND_HAS_2PLANE )printk (KERN_DEBUG "Chip has 2 plane\n" ); +if (this->options &ONENAND_HAS_4KB_PAGE ) +printk (KERN_DEBUG "Chip has 4KiB pagesize\n" ); }/**
@@ -3799,7 +3805,7 @@ static int onenand_probe(struct mtd_info *mtd)/* The data buffer size is equal to page size */ mtd->writesize = this->read_word (this->base +ONENAND_REG_DATA_BUFFER_SIZE );/* We use the full BufferRAM */ -if (ONENAND_IS_MLC (this)) +if (ONENAND_IS_MLC (this) ||ONENAND_IS_4KB_PAGE (this)) mtd->writesize <<=1 ; mtd->oobsize = mtd->writesize >>5 ;
include/linux/mtd/onenand.h +4 -0
@@ -175,10 +175,14 @@ struct onenand_chip {#define ONENAND_HAS_CONT_LOCK (0x0001)#define ONENAND_HAS_UNLOCK_ALL (0x0002)#define ONENAND_HAS_2PLANE (0x0004) +#define ONENAND_HAS_4KB_PAGE (0x0008)#define ONENAND_SKIP_UNLOCK_CHECK (0x0100)#define ONENAND_PAGEBUF_ALLOC (0x1000)#define ONENAND_OOBBUF_ALLOC (0x2000) +#define ONENAND_IS_4KB_PAGE (this) \ + (this->options & ONENAND_HAS_4KB_PAGE) +/* * OneNAND Flash Manufacturer ID Codes */
Signature · 1 line
1.6.4
PATCH 2/5 drivers: mtd: onenand: allocate verify buffer in the core
In reply to Marek SzyprowskiFrom: Kyungmin Park <[email protected]>
This patch extends OneNAND core code with support for OneNAND verify write check. This is done by allocating the buffer for verify read directly from the core code.
--- drivers/mtd/onenand/onenand_base.c | 13 ++++++++++++- include/linux/mtd/onenand.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletions(-)
drivers/mtd/onenand/onenand_base.c +12 -1
@@ -3932,6 +3932,13 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) __func__);return -ENOMEM ; } +#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE + this->verify_buf =kzalloc (mtd->writesize,GFP_KERNEL ); +if (!this->verify_buf) { +kfree (this->page_buf); +return -ENOMEM ; + } +#endif this->options |=ONENAND_PAGEBUF_ALLOC ; }if (!this->oob_buf) {
@@ -4059,8 +4066,12 @@ void onenand_release(struct mtd_info *mtd)kfree (this->bbm); }/* Buffers allocated by onenand_scan */ -if (this->options &ONENAND_PAGEBUF_ALLOC ) +if (this->options &ONENAND_PAGEBUF_ALLOC ) {kfree (this->page_buf); +#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE +kfree (this->verify_buf); +#endif + }if (this->options &ONENAND_OOBBUF_ALLOC )kfree (this->oob_buf);kfree (mtd->eraseregions);
include/linux/mtd/onenand.h +3 -0
@@ -125,6 +125,9 @@ struct onenand_chip {flstate_t state;unsigned char *page_buf;unsigned char *oob_buf; +#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE +unsigned char *verify_buf; +#endif int subpagesize;struct nand_ecclayout *ecclayout;
Signature · 1 line
1.6.4
PATCH 3/5 drivers: mtd: onenand: add new callback for bufferram read
In reply to Marek SzyprowskiFrom: Kyungmin Park <[email protected]>
This patch adds a new callback for the underlying drivers, which is called instead of accessing the buffer ram directly. This callback will be used by Samsung OneNAND driver to implement DMA transfers on S5PC110 SoC.
--- drivers/mtd/onenand/onenand_base.c | 6 ++---- include/linux/mtd/onenand.h | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/onenand/onenand_base.c +2 -4
@@ -1635,7 +1635,6 @@ static int onenand_verify_oob(struct mtd_info *mtd, const u_char *buf, loff_t tostatic int onenand_verify (struct mtd_info *mtd,const u_char *buf,loff_t addr,size_t len) {struct onenand_chip *this = mtd->priv; -void __iomem *dataram;int ret =0 ;int thislen, column;
@@ -1655,10 +1654,9 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,onenand_update_bufferram (mtd, addr,1 ); - dataram = this->base +ONENAND_DATARAM ; - dataram +=onenand_bufferram_offset (mtd,ONENAND_DATARAM ); + this->read_bufferram (mtd,ONENAND_DATARAM , this->verify_buf,0 , mtd->writesize); -if (memcmp (buf, dataram + column, thislen)) +if (memcmp (buf, this->verify_buf, thislen))return -EBADMSG ; len -= thislen;
include/linux/mtd/onenand.h +2 -0
@@ -212,6 +212,8 @@ struct mtd_partition;struct onenand_platform_data {void (*mmcontrol)(struct mtd_info *mtd,int sync_read); +int (*read_bufferram)(struct mtd_info *mtd,int area, +unsigned char *buffer,int offset,size_t count);struct mtd_partition *parts;unsigned int nr_parts; };
Signature · 1 line
1.6.4
PATCH 4/5 drivers: mtd: onenand: add workaround for SYNC_WRITE mode
In reply to Marek SzyprowskiFrom: Kyungmin Park <[email protected]>
Some chips fails to identify properly when SYNC_WRITE mode is enabled (the example is OneNAND on S5PC110 SoC). This patch adds a workaround for such chips.
--- drivers/mtd/onenand/onenand_base.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
drivers/mtd/onenand/onenand_base.c +9 -3
@@ -3763,6 +3763,12 @@ static int onenand_probe(struct mtd_info *mtd)/* Restore system configuration 1 */ this->write_word (syscfg, this->base +ONENAND_REG_SYS_CFG1 ); +/* Workaround */ +if (syscfg &ONENAND_SYS_CFG1_SYNC_WRITE ) { + bram_maf_id = this->read_word (this->base +ONENAND_REG_MANUFACTURER_ID ); + bram_dev_id = this->read_word (this->base +ONENAND_REG_DEVICE_ID ); + } +/* Check manufacturer ID */ if (onenand_check_maf (bram_maf_id))return -ENXIO ;
@@ -3782,6 +3788,9 @@ static int onenand_probe(struct mtd_info *mtd) this->device_id = dev_id; this->version_id = ver_id; +/* Check OneNAND features */ +onenand_check_features (mtd); + density =onenand_get_density (dev_id);if (FLEXONENAND (this)) { this->dies =ONENAND_IS_DDP (this) ?2 :1 ;
@@ -3833,9 +3842,6 @@ static int onenand_probe(struct mtd_info *mtd)else mtd->size = this->chipsize; -/* Check OneNAND features */ -onenand_check_features (mtd); -/* * We emulate the 4KiB page and 256KiB erase block size * But oobsize is still 64 bytes.
Signature · 1 line
1.6.4
PATCH 5/5 drivers: mtd: add Samsung SoC OneNAND driver
In reply to Marek SzyprowskiFrom: Kyungmin Park <[email protected]>
This patch adds a driver for OneNAND controller on Samsung SoCs. Following SoCs are supported: S3C6400, S3C6410, S5PC100 and S5PC110.
--- drivers/mtd/onenand/Kconfig | 7 + drivers/mtd/onenand/Makefile | 1 + drivers/mtd/onenand/samsung.c | 1071 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1079 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/onenand/samsung.c
drivers/mtd/onenand/Kconfig +7 -0
@@ -30,6 +30,13 @@ config MTD_ONENAND_OMAP2 Support for a OneNAND flash device connected to an OMAP2/OMAP3 CPU via the GPMC memory controller. +config MTD_ONENAND_SAMSUNG + tristate "OneNAND on Samsung SOC controller support" + depends on MTD_ONENAND && (ARCH_S3C64XX || ARCH_S5PC100 || ARCH_S5PV210) + help + Support for a OneNAND flash device connected to an Samsung SOC + S3C64XX/S5PC1XX controller. + config MTD_ONENAND_OTP bool "OneNAND OTP Support" select HAVE_MTD_OTP
drivers/mtd/onenand/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_MTD_ONENAND) += onenand.o # Board specific. obj-$(CONFIG_MTD_ONENAND_GENERIC) += generic.o obj-$(CONFIG_MTD_ONENAND_OMAP2) += omap2.o +obj-$(CONFIG_MTD_ONENAND_SAMSUNG) += samsung.o # Simulator obj-$(CONFIG_MTD_ONENAND_SIM) += onenand_sim.o
drivers/mtd/onenand/samsung.c new file +1071 -0
1,071 lines not on this page · raw message
Signature · 1 line
1.6.4
PATCH v2 1/1 Add support for Samsung SoC OneNAND controllers
In reply to Marek SzyprowskiQuoted 15 lines · Marek Szyprowski
This patch series add support for Samsung SoC OneNAND controllers found on S3C64xx, S5PC100 and S5PC110 chips. A few extensions to OneNAND core were required to make the driver working properly on all supported SoCs.
The required platform setup code has been posted to relevant mailing list (ARM Kernel: "[PATCH] ARM: Samsung: Add platform support code for OneNAND controller" thread).
Changes since v1:
* addressed all coding style issues reported by Ben Dooks
* moved all resource definitions to platform device resources
* moved all resource definitions for different SoCs fromregs-onenand.htoarch/arm/mach-{s3c64xx,s5pc100,s5pv210}/include/mach/map.h
* moved all #ifdef conditional code to separate functions
Quoted 7 lines
This patch series includes:
[PATCH 1/5] drivers: mtd: onenand: add support for chips with 4KB page size [PATCH 2/5] drivers: mtd: onenand: allocate verify buffer in the core [PATCH 3/5] drivers: mtd: onenand: add new callback for bufferram read [PATCH 4/5] drivers: mtd: onenand: add workaround for
SYNC_WRITEmode [PATCH 5/5] drivers: mtd: add Samsung SoC OneNAND driver
Pushed this series to my l2-mtd-2.6.git / dunno
Signature · 2 lines
Best Regards, Artem Bityutskiy (????? ????????)