OneNAND MTD support
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Kyungmin Park
maintainerPATCH 1/1 OneNAND MTD support
Hi
We are happy to release OneNAND MTD to open source community.
Brief desciption of OneNAND is following
Samsung OneNANDT is a highly reliable embedded memory targeted for both consumer electronic, and next generation mobile phone market. With Samsung's accumulated NAND flash technologies over the last decade, Samsung designs an ideal single memory chip based on NAND architecture integrating SRAM buffers and logic interface.
Samsung OneNANDT takes both advantages from high-speed data read function of NOR flash and the advanced data storage function of NAND flash. (from
http://www.samsung.com/Products/Semiconductor/Flash/OneNAND_TM/index.htm)
This patch is based on latest linux 2.6 kernel from linux-omap-2.6.git
It's simple implementation.
So there's no optimization and performance tuning.
It is useful to test OneNAND chip with new platform and verify hardware configurations.
Now it's tested with CRAMFS and JFFS2 on OMAP OSK
Note: The bad block handling is not yet implemented.
since we want to use NAND BBT routine and NAND BBT routine has NAND-specific code, then
At first we want to split BBT code into BBT core and NAND-specific code then we will merge with OneNAND
Any comments are welcome.
Thank you.
Kyungmin Park
drivers/mtd/onenand/Kconfig (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +36 -0
@@ -0,0 +1,36 @@ +# +# linux/drivers/mtd/onenand/Kconfig +# + +menu "OneNAND Flash Device Drivers (EXPERIMENTAL)" + depends on MTD != n && EXPERIMENTAL + +config MTD_ONENAND + tristate "OneNAND Device Support" + depends on MTD + select MTD_ONENAND_INFO + help + This enables support for accessing all type of OneNAND flash + devices. For further information see + <http://www.samsung.com/Products/Semiconductor/Flash/OneNAND_TM/index.htm>. + +config MTD_ONENAND_VERIFY_WRITE + bool "Verify OneNAND page writes" + depends on MTD_ONENAND + help + This adds an extra check when data is written to the flash. The + OneNAND flash device internally checks only bits transitioning + from 1 to 0. There is a rare possibility that even though the + device thinks the write was successful, a bit could have been + flipped accidentaly due to device wear or something else. + +config MTD_ONENAND_INFO + tristate + +config MTD_ONENAND_OMAP + tristate "OneNAND Flash device on OMAP board" + depends on ARM && ARCH_OMAP && MTD_ONENAND + help + Support for OneNAND flash on TI OMAP board. + +endmenu
drivers/mtd/onenand/Makefile (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +8 -0
@@ -0,0 +1,8 @@ +# +# linux/drivers/mtd/onenand/Makefile +# + +obj-$(CONFIG_MTD_ONENAND) += onenand_base.o +obj-$(CONFIG_MTD_ONENAND_INFO) += onenand_info.o + +obj-$(CONFIG_MTD_ONENAND_OMAP) += omap-onenand.o
drivers/mtd/onenand/omap-onenand.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +196 -0
196 lines not on this page · raw message
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +1310 -0
1,310 lines not on this page · raw message
drivers/mtd/onenand/onenand_info.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +53 -0
53 lines not on this page · raw message
include/linux/mtd/onenand.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +132 -0
132 lines not on this page · raw message
include/linux/mtd/onenand_regs.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +167 -0
167 lines not on this page · raw message
Quoted 1 line · Kyungmin Park
This patch is based on latest linux 2.6 kernel from linux-omap-2.6.git
Please provide a patch against MTD-CVS
Quoted 5 lines
Note: The bad block handling is not yet implemented.
since we want to use NAND BBT routine and NAND BBT routine has NAND-specific code, then
At first we want to split BBT code into BBT core and NAND-specific code then we will merge with OneNAND
Makes sense.
tglx
Some remarks:
Kconfig and Makefile need references in drivers/mtd/Kconfig and drivers/mtd/Makefile !!!
+menu "OneNAND Flash Device Drivers (EXPERIMENTAL)"
+ depends on MTD != n && EXPERIMENTAL
+
+config MTD_ONENAND
+ tristate "OneNAND Device Support"
+ depends on MTD
+ select MTD_ONENAND_INFO
Why do you need a seperate config option, which is just a mirror of MTD_ONENAND ?
+
+ /* try the first address */
+ omap_onenand_flash_base = ioremap(OMAP_ONENAND_FLASH_START1, SZ_128K);
Why a seperate static variable ? Please use the base member of the private structure.
+static int onenand_wait(struct mtd_info *mtd, int state) +{
+ struct onenand_chip * this = mtd->priv;
+ unsigned long timeout;
+ unsigned int flags = ONENAND_INT_MASTER;
+ unsigned int interrupt = 0;
+ unsigned int ctrl, ecc;
+
+ /* The 10 msec is enough */
+ timeout = jiffies + msecs_to_jiffies(10);
+ while (time_before(jiffies, timeout)) {
+ interrupt = onenand_readw(this->base + ONENAND_REG_INTERRUPT);
+
+ if (interrupt & flags)
+ break;
+ yield();
Please use cond_resched() instead of yield()
+ }
+ /* To get correct interrupt status in timeout case */
+ interrupt = onenand_readw(this->base + ONENAND_REG_INTERRUPT);
+
+ if (!interrupt)
+ BUG();
A timeout should be handled gracefully by the driver. Use BUG() to catch errors, which are caused by invalid arguments to a function, uninitialized data structures or calling from a wrong context.
+static int onenand_dataram(struct mtd_info *mtd, int write,
+ unsigned char *buffer, int offset, int count)
+{
+ struct onenand_chip *this = mtd->priv;
+ void __iomem *src, *dest;
+ void __iomem *dataram;
+
+ dataram = this->base + ONENAND_DATARAM;
+
+ if (ONENAND_CURRENT_BUFFERRAM(this))
+ dataram += mtd->oobblock;
+
+ if (write) {
+ src = buffer;
+ dest = dataram + offset;
+ } else {
+ src = dataram + offset;
+ dest = buffer;
+ }
+
+ memcpy(dest, src, count);
Can the read/write functions be seperate please ?
Only the hardware access should be replaceable by the board driver. Calculations which are valid for every implementation should be done in generic code. This reduces the code size and the error sources for hardware specific implementations
+static int onenand_spareram(struct mtd_info *mtd, int write,
+ unsigned char *buffer, int offset, int count)
Same as above.
+static void onenand_get_device(struct onenand_chip *this, int new_state) +{
+ struct onenand_chip *active = this;
+ DECLARE_WAITQUEUE(wait, current);
+
+ /*
+ * Grab the lock and see if the device is available
+ */
+retry:
+ if (active == this) {
That's bogus, as active is never changed.
+#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
+/**
+ * onenand_verify_page - [GENERIC] verify the chip contents after a write
+ * @param mtd MTD device structure
+ * @param buf the databuffer to verify
+ * @param block block address
+ * @param page page address
+ *
+ * Check DataRAM area directly
+ */
+static int onenand_verify_page(struct mtd_info *mtd, u_char *buf,
+ loff_t addr, int block, int page)
+{
<SNIP>
+ dataram1 = dataram0 + mtd->oobblock;
+
+ if (memcmp(dataram0, dataram1, mtd->oobblock))
+ return -EBADMSG;
See onenand_dataram()
+static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) <SNIP>
+ /* There's no return value */
+ this->wait(mtd, FL_UNLOCKING);
Why not ?
+ /* Sanity check */
+ while (onenand_readw(this->base + ONENAND_REG_CTRL_STATUS)
+ & ONENAND_CTRL_ONGO)
+ continue;
What happens if the condition is not met ?
<SNIP>
+ /* Sanity check */
+ while (onenand_readw(this->base + ONENAND_REG_CTRL_STATUS)
+ & ONENAND_CTRL_ONGO)
+ continue;
Same as above
+ /* Set block address for read block status */
+ value = onenand_block_address(this->device_id, block);
+ onenand_writew(value, this->base + ONENAND_REG_START_ADDRESS1);
+
+ /* Check lock status */
+ status = onenand_readw(this->base + ONENAND_REG_WP_STATUS);
+ if (!(status & ONENAND_WP_US))
+ printk(KERN_ERR "block = %d, wp status = 0x%x\n", block, status);
+ }
+
+ return 0;
The function returns unconditionally success, even if the status is not correct !
+/**
+ * onenand_scan - [OneNAND Interface] Probe the OneNAND device
+ * @param mtd MTD device structure
+ *
+ * OneNAND detection method:
+ * Compare the the values from command with ones from register
+ */
+static int onenand_probe(struct mtd_info *mtd)
Please make comment and function name consistent.
+/*
+ * linux/drivers/mtd/onenand/onenand_info.c
<SNIP>
+EXPORT_SYMBOL_GPL(onenand_print_device_info); +EXPORT_SYMBOL_GPL(onenand_print_maf_info);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Kyungmin Park <[email protected]>"); +MODULE_DESCRIPTION("Display OneNAND device and manufacturer ID's");
Please link this with onenand_base.c. It's overkill to have those exports and a seperate module. The seperate nand_ids file in drivers/mtd/nand is solely there to make it reusable by the legacy DiskOnChip drivers. Once those are gone the id table will be linked to nand_base.c unconditionally.
+ FL_ERASING,
+ FL_SYNCING,
+ FL_UNLOCKING,
+} onenand_state_t;
Shouldnt there be a LOCK counterpart to UNLOCK ?
+/*
+ * Functions to access the OneNAND IO region
+ */
+#define onenand_readw(a) readw(a)
+#define onenand_writew(v,a) writew(v, a)
Please make onenand_readw/writew functions accessible by function pointers along with default implementations, so the board driver can override them if necessary.
Kyungmin Park
maintainerHi
It's new patch as your request
and I append some bufferram function to reduce unnecessary read access.
It's similay page buf in NAND.
Regards
Kyungmin Park
Quoted 5 lines
Some remarks:
KconfigandMakefileneed references indrivers/mtd/Kconfiganddrivers/mtd/Makefile!!!
Yes, I'm missing
Quoted 9 lines
(quoted diff) +5
-0+menu "OneNAND Flash Device Drivers (EXPERIMENTAL)" + depends on MTD != n && EXPERIMENTAL + +config MTD_ONENAND + tristate "OneNAND Device Support"depends on MTD
selectMTD_ONENAND_INFOWhy do you need a seperate config option, which is just a mirror of
MTD_ONENAND ?
I don't understood. What's meaning?
Quoted 8 lines
(quoted diff) +3
-0+ + /* try the first address */ + omap_onenand_flash_base =
ioremap(OMAP_ONENAND_FLASH_START1, SZ_128K);Why a seperate static variable ? Please use the base member of the private structure.
OK. I done.
Quoted 23 lines
(quoted diff) +21
-0+static int onenand_dataram(struct mtd_info *mtd, int write, + unsigned char *buffer, int offset, int count) +{ + struct onenand_chip *this = mtd->priv; + void __iomem *src, *dest; + void __iomem *dataram; + + dataram = this->base + ONENAND_DATARAM; + + if (ONENAND_CURRENT_BUFFERRAM(this)) + dataram += mtd->oobblock; + + if (write) { + src = buffer; + dest = dataram + offset; + } else { + src = dataram + offset; + dest = buffer; + } + + memcpy(dest, src, count);
Quoted 6 lines
Can the read/write functions be seperate please ?
Only the hardware access should be replaceable by the board driver. Calculations which are valid for every implementation should be done in
generic code. This reduces the code size and the error sources for hardware specific implementations
As your request, I create read/write_bufferram function instread of dataram and spareram
Quoted 8 lines
+static int
onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
<SNIP>(quoted diff) +2
-0+ /* There's no return value */ + this->wait(mtd, FL_UNLOCKING);Why not ?
There's no status check in locking mechanism
Quoted 8 lines
(quoted diff) +2
-0+ /* Sanity check */ + while (onenand_readw(this->base +
ONENAND_REG_CTRL_STATUS)(quoted diff) +2
-0+ & ONENAND_CTRL_ONGO) + continue;What happens if the condition is not met ?
I think it's board bug. For safety I check it.
Quoted 11 lines
(quoted diff) +8
-0+/** + * onenand_scan - [OneNAND Interface] Probe the OneNAND device + * @param mtd MTD device structure + * + * OneNAND detection method: + * Compare the the values from command with ones from register + */ +static int onenand_probe(struct mtd_info *mtd)Please make comment and function name consistent.
OK. fix it
Quoted 13 lines
(quoted diff) +8
-0+/* + * linux/drivers/mtd/onenand/onenand_info.c +EXPORT_SYMBOL_GPL(onenand_print_device_info); +EXPORT_SYMBOL_GPL(onenand_print_maf_info); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Kyungmin Park <[email protected]>"); +MODULE_DESCRIPTION("Display OneNAND device and manufacturer ID's");
Quoted 5 lines
Please link this with
onenand_base.c. It's overkill to have those exports and a seperate module. The seperatenand_idsfile indrivers/mtd/nandis solely there to make it reusable by the legacy DiskOnChip drivers. Once those are gone the id table will be linked tonand_base.cunconditionally.
I merged it
Quoted 8 lines
(quoted diff) +4
-0+ FL_ERASING, + FL_SYNCING, + FL_UNLOCKING, +} onenand_state_t;Shouldnt there be a LOCK counterpart to UNLOCK ?
OK.
Quoted 8 lines
(quoted diff) +5
-0+/* + * Functions to access the OneNAND IO region + */ +#define onenand_readw(a) readw(a) +#define onenand_writew(v,a) writew(v, a)
Quoted 4 lines
Please make onenand_readw/writew functions accessible by function pointers along with default implementations, so the board driver can override them if necessary.
It's just memory access function. I think no need to make a function.
drivers/mtd/Kconfig (mode:100644) +2 -0
@@ -261,5 +261,7 @@ source "drivers/mtd/nand/Kconfig" +source "drivers/mtd/onenand/Kconfig" + endmenu
drivers/mtd/Makefile (mode:100644) +1 -1
@@ -24,4 +24,4 @@ nftl-objs := nftlcore.o nftlmount.o inftl-objs := inftlcore.o inftlmount.o -obj-y += chips/ maps/ devices/ nand/ +obj-y += chips/ maps/ devices/ nand/ onenand/
drivers/mtd/onenand/Kconfig (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +32 -0
@@ -0,0 +1,32 @@ +# +# linux/drivers/mtd/onenand/Kconfig +# + +menu "OneNAND Flash Device Drivers (EXPERIMENTAL)" + depends on MTD != n && EXPERIMENTAL + +config MTD_ONENAND + tristate "OneNAND Device Support" + depends on MTD + help + This enables support for accessing all type of OneNAND flash + devices. For further information see + <http://www.samsung.com/Products/Semiconductor/Flash/OneNAND_TM/index.htm>. + +config MTD_ONENAND_VERIFY_WRITE + bool "Verify OneNAND page writes" + depends on MTD_ONENAND + help + This adds an extra check when data is written to the flash. The + OneNAND flash device internally checks only bits transitioning + from 1 to 0. There is a rare possibility that even though the + device thinks the write was successful, a bit could have been + flipped accidentaly due to device wear or something else. + +config MTD_ONENAND_OMAP + tristate "OneNAND Flash device on OMAP board" + depends on ARM && ARCH_OMAP && MTD_ONENAND + help + Support for OneNAND flash on TI OMAP board. + +endmenu
drivers/mtd/onenand/Makefile (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for the OneNAND MTD +# + +# Core functionality. +obj-$(CONFIG_MTD_ONENAND) += onenand_base.o + +# Board specific. +obj-$(CONFIG_MTD_ONENAND_OMAP) += omap-onenand.o
drivers/mtd/onenand/omap-onenand.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +179 -0
179 lines not on this page · raw message
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +1433 -0
1,433 lines not on this page · raw message
include/linux/mtd/onenand.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +147 -0
147 lines not on this page · raw message
include/linux/mtd/onenand_regs.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +167 -0
167 lines not on this page · raw message
Hi, Kyungmin
Quoted 5 lines · Kyungmin Park
It's new patch as your request
and I append some bufferram function to reduce unnecessary read access.
It's similay page buf in NAND.
Thanks, looks much better now.
Quoted 5 lines
Quoted 3 lines
select
MTD_ONENAND_INFOWhy do you need a seperate config option, which is just a mirror of
MTD_ONENAND?
I don't understood. What's meaning?
MTD_ONENAND_INFO is a seperate config option, which gets turned on when MTD_ONENAND is selected. This does not make much sense as you have only MTD_ONENAND which can select MTD_ONENAND_INFO. Its superfluid anyway as you merged the info code into the base code now.
Quoted 2 lines
Quoted 1 line
+static int onenand_unlock(struct
mtd_info*mtd,loff_tofs,There's no status check in locking mechanism
Hmm. So all the status errors checked in onenand_wait() will never happen here ?
Quoted 10 lines
Quoted 8 lines
(quoted diff) +2
-0+ /* Sanity check */ + while (onenand_readw(this->base +
ONENAND_REG_CTRL_STATUS)(quoted diff) +2
-0+ & ONENAND_CTRL_ONGO) + continue;What happens if the condition is not met ?
I think it's board bug. For safety I check it.
Then some kind of timeout is definitely appropriate. You will endup in a dead loop when the condition is not met due to the bug.
Quoted 6 lines
Quoted 6 lines
include/linux/mtd/onenand.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +5
-0+/* + * Functions to access the OneNAND IO region + */ +#define onenand_readw(a) readw(a) +#define onenand_writew(v,a) writew(v, a)
Quoted 6 lines
Quoted 4 lines
Please make onenand_readw/writew functions accessible by function pointers along with default implementations, so the board driver can override them if necessary.
It's just memory access function. I think no need to make a function.
Yes, on your board. It turned out to be a good choice to turn _all_ the functions which access hardware into function pointers. People design weird hardware and the overhead of the function pointer based access is minimal. Keeping it your way, one has to replace 4 complex functions (command, wait, read/ write) instead of providing 4 small and simple ones.
+config MTD_ONENAND_OMAP
+ tristate "OneNAND Flash device on OMAP board"
+ depends on ARM && ARCH_OMAP && MTD_ONENAND
"depends on ARCH_OMAP && MTD_ONENAND" is enough, as ARCH_OMAP already depends on ARM
+++ uncommitted/drivers/mtd/onenand/omap-onenand.c
+ default:
+ printk(KERN_WARNING "Unsupported OneNAND device\n");
+ err = -ENXIO;
+ goto out_buf;
+ }
+
+ goto out;
return 0;
This is the normal return path. Below is error exit (cleanup)
+
+out_buf:
+ onenand_release(omap_onenand_mtd);
+ iounmap(this->base);
+out_mtd:
+ kfree(omap_onenand_mtd);
+out:
+ return err;
+++ uncommitted/drivers/mtd/onenand/onenand_base.c (mode:100644) +static int onenand_read_bufferram(struct mtd_info *mtd, int area,
+ unsigned char *buffer, int offset, size_t count)
+{
+ struct onenand_chip *this = mtd->priv;
+ void __iomem *bufferram;
+
+ if (area == DATARAM)
+ bufferram = this->base + ONENAND_DATARAM;
+ else if (area == SPARERAM)
+ bufferram = this->base + ONENAND_SPARERAM;
+ else
+ bufferram = this->base + ONENAND_BOOTRAM;
+
+ if (ONENAND_CURRENT_BUFFERRAM(this)) {
+ if (area == DATARAM)
+ bufferram += mtd->oobblock;
+ else if (area == SPARERAM)
+ bufferram += mtd->oobsize;
+ }
+
+ memcpy(buffer, bufferram + offset, count);
+
+ return 0;
+}
area can be a direct offset (ONENAND_DATARAM, ONENAND_SPARERAM, ONENAND_BOOTRAM), so you can just write: bufferram = this->base + area;
+static int onenand_write_bufferram(struct mtd_info *mtd, int area,
+ const unsigned char *buffer, int offset, size_t count)
+{
Same as onenand_read_bufferram
+ if (ONENAND_CURRENT_BUFFERRAM(this)) {
+ if (area == DATARAM)
+ bufferram += mtd->oobblock;
+ else if (area == SPARERAM)
+ bufferram += mtd->oobsize;
+ }
Please make this a inline function used in read/write_bufferram
+EXPORT_SYMBOL(onenand_scan);
+EXPORT_SYMBOL(onenand_release);
Would you mind to change those exports to EXPORT_SYMBOL_GPL ?
+++ uncommitted/include/linux/mtd/onenand_regs.h (mode:100644)
+/* Memory Address Map Translation (Word order) */
+#define ONENAND_MEMORY_MAP(x) ((x) << 1)
Is this considered to be a general rule, i.e. is this the only valid way to address the chip ?
+struct onenand_chip {
+ void __iomem *base;
+ unsigned int chipsize;
+ unsigned int device_id;
+ unsigned int version_id;
+ unsigned int options;
Are device_id and version_id necessary for anything else than scan ? If no, please remove.
Kyungmin Park
maintainerHi
Thank you for comments and advice.
Here's new patch.
Regards
Kyungmin Park
Quoted 13 lines
Quoted 2 lines
Quoted 1 line
+static int onenand_unlock(struct
mtd_info*mtd,loff_tofs,There's no status check in locking mechanism
Hmm. So all the status errors checked in
onenand_wait()will never happen here ?Quoted 7 lines
Quoted 7 lines
(quoted diff) +2
-0+ /* Sanity check */ + while (onenand_readw(this->base +
ONENAND_REG_CTRL_STATUS)(quoted diff) +2
-0+ & ONENAND_CTRL_ONGO) + continue;
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
What happens if the condition is not met ?
I think it's board bug. For safety I check it.
Then some kind of timeout is definitely appropriate. You will endup in a
dead loop when the condition is not met due to the bug.
In OneNAND after operation done, The interrupt and controller status is updated simultaneously.
So it's no problem checking controller status.
If the problem occurs, It's chip bug.
Quoted 16 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +5
-0+/* + * Functions to access the OneNAND IO region + */ +#define onenand_readw(a) readw(a) +#define onenand_writew(v,a) writew(v, a)Please make onenand_readw/writew functions accessible by function pointers along with default implementations, so the board
driver can
Quoted 4 lines
Quoted 2 lines
override them if necessary.
It's just memory access function. I think no need to make a
function.
Quoted 8 lines
Yes, on your board. It turned out to be a good choice to turn _all_ the
functions which access hardware into function pointers. People design weird hardware and the overhead of the function pointer based access is
minimal. Keeping it your way, one has to replace 4 complex functions (command, wait, read/ write) instead of providing 4 small and simple ones.
OK. I do it
Quoted 7 lines
(quoted diff) +3
-0+config MTD_ONENAND_OMAP + tristate "OneNAND Flash device on OMAP board" + depends on ARM && ARCH_OMAP && MTD_ONENAND"depends on
ARCH_OMAP&&MTD_ONENAND" is enough, asARCH_OMAPalready depends on ARM
It's derived from omap-nand-flash.c, But it's not sended to MTD. OK. I done
Quoted 11 lines
+++
uncommitted/drivers/mtd/onenand/omap-onenand.c(quoted diff) +7
-0+ default: + printk(KERN_WARNING "Unsupported OneNAND device\n"); + err = -ENXIO; + goto out_buf; + } + + goto out;
Quoted 2 lines
return 0;This is the normal return path. Below is error exit (cleanup)
OK
Quoted 36 lines
+++
uncommitted/drivers/mtd/onenand/onenand_base.c(mode:100644)(quoted diff) +24
-0+static int onenand_read_bufferram(struct mtd_info *mtd, int area, + unsigned char *buffer, int offset, size_t count) +{ + struct onenand_chip *this = mtd->priv; + void __iomem *bufferram; + + if (area == DATARAM) + bufferram = this->base + ONENAND_DATARAM; + else if (area == SPARERAM) + bufferram = this->base + ONENAND_SPARERAM; + else + bufferram = this->base + ONENAND_BOOTRAM; + + if (ONENAND_CURRENT_BUFFERRAM(this)) { + if (area == DATARAM) + bufferram += mtd->oobblock; + else if (area == SPARERAM) + bufferram += mtd->oobsize; + } + + memcpy(buffer, bufferram + offset, count); + + return 0; +}area can be a direct offset (
ONENAND_DATARAM,ONENAND_SPARERAM,ONENAND_BOOTRAM), so you can just write: bufferram =this->base+ area;(quoted diff) +3
-0+static int onenand_write_bufferram(struct mtd_info *mtd, int area, + const unsigned char *buffer, int offset, size_t count) +{
Quoted 1 line
Same as
onenand_read_bufferram
Yes It is more natual. why I don't know this method :)
Quoted 9 lines
(quoted diff) +6
-0+ if (ONENAND_CURRENT_BUFFERRAM(this)) { + if (area == DATARAM) + bufferram += mtd->oobblock; + else if (area == SPARERAM) + bufferram += mtd->oobsize; + }Please make this a inline function used in read/write_bufferram
I done.
Quoted 5 lines
(quoted diff) +2
-0+EXPORT_SYMBOL(onenand_scan); +EXPORT_SYMBOL(onenand_release);Would you mind to change those exports to
EXPORT_SYMBOL_GPL?
In fact I not sure and also don't know license issue.
If we develop the some commercial mtd user software then can we use mtd device code exported with GPL? Is there no problem?
Quoted 9 lines
+++
uncommitted/include/linux/mtd/onenand_regs.h(mode:100644)(quoted diff) +2
-0+/* Memory Address Map Translation (Word order) */ +#define ONENAND_MEMORY_MAP(x) ((x) << 1)Is this considered to be a general rule, i.e. is this the only valid way
to address the chip ?
To comply with Spec. In Spec. most register addresses are written in word e.g., Interrupt status registers is 0xf241h
#define ONENAND_REG_INTERRUPT ONENAND_MEMORY_MAP(0xF241)
Quoted 8 lines
(quoted diff) +6
-0+struct onenand_chip { + void __iomem *base; + unsigned int chipsize; + unsigned int device_id; + unsigned int version_id; + unsigned int options;
Quoted 4 lines
Are
device_idandversion_idnecessary for anything else than scan ? If
no, please remove.
device_id necessary to control DDP chip. But I'm not yet tested with DDP chip.version_id is not necessary. removed.
drivers/mtd/Kconfig (mode:100644) +2 -0
@@ -261,5 +261,7 @@ source "drivers/mtd/nand/Kconfig" +source "drivers/mtd/onenand/Kconfig" + endmenu
drivers/mtd/Makefile (mode:100644) +1 -1
@@ -24,4 +24,4 @@ nftl-objs := nftlcore.o nftlmount.o inftl-objs := inftlcore.o inftlmount.o -obj-y += chips/ maps/ devices/ nand/ +obj-y += chips/ maps/ devices/ nand/ onenand/
drivers/mtd/onenand/Kconfig (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +32 -0
@@ -0,0 +1,32 @@ +# +# linux/drivers/mtd/onenand/Kconfig +# + +menu "OneNAND Flash Device Drivers (EXPERIMENTAL)" + depends on MTD != n && EXPERIMENTAL + +config MTD_ONENAND + tristate "OneNAND Device Support" + depends on MTD + help + This enables support for accessing all type of OneNAND flash + devices. For further information see + <http://www.samsung.com/Products/Semiconductor/Flash/OneNAND_TM/index.htm>. + +config MTD_ONENAND_VERIFY_WRITE + bool "Verify OneNAND page writes" + depends on MTD_ONENAND + help + This adds an extra check when data is written to the flash. The + OneNAND flash device internally checks only bits transitioning + from 1 to 0. There is a rare possibility that even though the + device thinks the write was successful, a bit could have been + flipped accidentaly due to device wear or something else. + +config MTD_ONENAND_OMAP + tristate "OneNAND Flash device on OMAP board" + depends on ARCH_OMAP && MTD_ONENAND + help + Support for OneNAND flash on TI OMAP board. + +endmenu
drivers/mtd/onenand/Makefile (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for the OneNAND MTD +# + +# Core functionality. +obj-$(CONFIG_MTD_ONENAND) += onenand_base.o + +# Board specific. +obj-$(CONFIG_MTD_ONENAND_OMAP) += omap-onenand.o
drivers/mtd/onenand/omap-onenand.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +179 -0
179 lines not on this page · raw message
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +1464 -0
1,464 lines not on this page · raw message
include/linux/mtd/onenand.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +137 -0
137 lines not on this page · raw message
include/linux/mtd/onenand_regs.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +167 -0
167 lines not on this page · raw message
Quoted 2 lines · Kyungmin Park
It's derived from
omap-nand-flash.c, But it's not sended to MTD. OK. I done
I removed the redundant dependencies in drivers/mtd/nand and drivers/mtd/maps too.
Quoted 9 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +2
-0+EXPORT_SYMBOL(onenand_scan); +EXPORT_SYMBOL(onenand_release);Would you mind to change those exports to
EXPORT_SYMBOL_GPL?In fact I not sure and also don't know license issue.
If we develop the some commercial mtd user software then can we use mtd device code exported with GPL? Is there no problem?
User space software is not concerned of kernel licences.
If you talk about a proprietary closed source kernel module which needs those exports, you are stepping into a legal grey area regardless of the exports style. I don't see a point where it makes sense to have a closed source board driver, as it just initializes a data structure and calls generic handling code.
Quoted 5 lines
Quoted 3 lines
Are
device_idandversion_idnecessary for anything else than scan ? If
no, please remove.
device_idnecessary to control DDP chip. But I'm not yet tested with DDP chip.
Ok.
Some nitpicks though
+ /* The 10 msec is enough */
+ timeout = jiffies + msecs_to_jiffies(10);
+ while (time_before(jiffies, timeout)) {
On CPU's which have HZ=100 (1 jiffy == 10ms) this might be critical, as you might set the timeout immidiately before the timer interrupt happens. Using a 20ms timeout will keep you on the safe side in any case
Please clean up your includes to avoid redundant includes of header files.
tglx
Kyungmin Park
maintainerQuoted 14 lines
Quoted 9 lines
Quoted 6 lines
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +2
-0+EXPORT_SYMBOL(onenand_scan); +EXPORT_SYMBOL(onenand_release);Would you mind to change those exports to
EXPORT_SYMBOL_GPL?In fact I not sure and also don't know license issue. If we develop the some commercial mtd user software then
can we use mtd
Quoted 1 line
device code exported with GPL? Is there no problem?
User space software is not concerned of kernel licences.
Quoted 9 lines
If you talk about a proprietary closed source kernel module which needs
those exports, you are stepping into a legal grey area regardless of the
exports style. I don't see a point where it makes sense to have a closed
source board driver, as it just initializes a data structure and calls generic handling code.
OK
Quoted 7 lines
Some nitpicks though
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +3
-0+ /* The 10 msec is enough */ + timeout = jiffies + msecs_to_jiffies(10); + while (time_before(jiffies, timeout)) {
Quoted 5 lines
On CPU's which have HZ=100 (1 jiffy == 10ms) this might be critical, as
you might set the timeout immidiately before the timer interrupt happens. Using a 20ms timeout will keep you on the safe side in any case
No problem.
Quoted 4 lines
Please clean up your includes to avoid redundant includes of header files.
which one do you mean?
Are there not required header file?
Regards
Kyungmin Park.
Quoted 5 lines · Kyungmin Park
Quoted 2 lines
Please clean up your includes to avoid redundant includes of header files.
which one do you mean?
Are there not required header file?
in omap-onenand.c
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/onenand.h>
+#include <linux/mtd/partitions.h>
Same in onenand_base.c
in onenand.h you have:
+#include <linux/config.h>
----------^^^^^^^^^^^^^^^^
Not needed, as your header does not contain CONFIG_XXX dependend stuff
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/mtd/mtd.h>
----------^^^^^^^^^^^^^^^^^
Already included above
+#include <linux/mtd/onenand_regs.h>
tglx
Kyungmin Park
maintainerQuoted 12 lines
in
onenand.hyou have:+#include <
linux/config.h>
----------^^^^^^^^^^^^^^^^
Not needed, as your header does not containCONFIG_XXXdependend stuff(quoted diff) +3
-1+#include <linux/kernel.h> +#include <linux/spinlock.h> +#include <linux/mtd/mtd.h> ----------^^^^^^^^^^^^^^^^^Already included above
Quoted 1 line
+#include <
linux/mtd/onenand_regs.h>
OK.
Is there another issue? :)
Regards
Kyungmin Park
drivers/mtd/Kconfig (mode:100644) +2 -0
@@ -261,5 +261,7 @@ source "drivers/mtd/nand/Kconfig" +source "drivers/mtd/onenand/Kconfig" + endmenu
drivers/mtd/Makefile (mode:100644) +1 -1
@@ -24,4 +24,4 @@ nftl-objs := nftlcore.o nftlmount.o inftl-objs := inftlcore.o inftlmount.o -obj-y += chips/ maps/ devices/ nand/ +obj-y += chips/ maps/ devices/ nand/ onenand/
drivers/mtd/onenand/Kconfig (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +32 -0
@@ -0,0 +1,32 @@ +# +# linux/drivers/mtd/onenand/Kconfig +# + +menu "OneNAND Flash Device Drivers (EXPERIMENTAL)" + depends on MTD != n && EXPERIMENTAL + +config MTD_ONENAND + tristate "OneNAND Device Support" + depends on MTD + help + This enables support for accessing all type of OneNAND flash + devices. For further information see + <http://www.samsung.com/Products/Semiconductor/Flash/OneNAND_TM/index.htm>. + +config MTD_ONENAND_VERIFY_WRITE + bool "Verify OneNAND page writes" + depends on MTD_ONENAND + help + This adds an extra check when data is written to the flash. The + OneNAND flash device internally checks only bits transitioning + from 1 to 0. There is a rare possibility that even though the + device thinks the write was successful, a bit could have been + flipped accidentaly due to device wear or something else. + +config MTD_ONENAND_OMAP + tristate "OneNAND Flash device on OMAP board" + depends on ARCH_OMAP && MTD_ONENAND + help + Support for OneNAND flash on TI OMAP board. + +endmenu
drivers/mtd/onenand/Makefile (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for the OneNAND MTD +# + +# Core functionality. +obj-$(CONFIG_MTD_ONENAND) += onenand_base.o + +# Board specific. +obj-$(CONFIG_MTD_ONENAND_OMAP) += omap-onenand.o
drivers/mtd/onenand/omap-onenand.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +178 -0
178 lines not on this page · raw message
drivers/mtd/onenand/onenand_base.c (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +1462 -0
1,462 lines not on this page · raw message
include/linux/mtd/onenand.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +134 -0
134 lines not on this page · raw message
include/linux/mtd/onenand_regs.h (mode:100644) renamed from dev/null (tree:4b825dc642cb6eb9a060e54bf8d69288fbee4904) +167 -0
167 lines not on this page · raw message
Quoted 1 line · Kyungmin Park
Is there another issue? :)
Not at the moment :)
Committed to CVS.
Thanks,
tglx
Quoted 3 lines · Kyungmin Park
Hi
We are happy to release OneNAND MTD to open source community.
Hello,
+config MTD_ONENAND_VERIFY_WRITE
+ bool "Verify OneNAND page writes" + depends on MTD_ONENAND + help + This adds an extra check when data is written to the flash. The + OneNAND flash device internally checks only bits transitioning + from 1 to 0. There is a rare possibility that even though the + device thinks the write was successful, a bit could have been + flipped accidentaly due to device wear or something else.
Why general MTD CONFIG_MTD_NAND_VERIFY_WRITE config option and -
Quoted 1 line
verify_bufdriver method (seenand_base.c) is not enough and you need
your own verify option?
Quoted 4 lines · Artem B. Bityuckiy
Why general MTD
CONFIG_MTD_NAND_VERIFY_WRITEconfig option and -Quoted 1 line
verify_bufdriver method (seenand_base.c) is not enough and you needyour own verify option?
Because its a seperate driver in a seperate directory. It's ok.
tglx