Commit graph

98 commits

Author SHA1 Message Date
Mika Korhonen
492e150143 mtd: OneNAND: spelling fixes
Signed-off-by: Mika Korhonen <mika.j.korhonen@gmail.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-09-04 09:30:17 +01:00
Amul Saha
c90173f090 mtd: OneNAND: Allow setting of boundary information when built as module
This patch unifies the flex_bdry setting for module vs. built-in 
configuration of OneNAND.

Signed-off-by: Amul Kumar Saha <amul.saha@samsung.com>
Signed-off-by: Vishak G <vishak.g@samsung.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-06-16 08:43:33 +01:00
Kyungmin Park
31bb999ee7 mtd: onenand: add bbt_wait & unlock_all as replaceable for some platform
Add bbt_wait & unlock_all as replaceable for some platform such as
  s3c64xx s3c64xx has its own OneNAND controller and another interface

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-06-05 18:59:34 +01:00
Rohit Hagargundgi
5988af2319 mtd: Flex-OneNAND support
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.

[akpm@linux-foundation.org: export flexoand_region and onenand_addr]
Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Vishak G <vishak.g@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-06-05 18:59:21 +01:00
Adrian Hunter
ee8f376889 mtd: OneNAND: add support for OneNAND manufactured by Numonyx
In addition to adding the Numonyx manufacturer code, this patch
also ensures 'sync. write' is disabled when reading identification
data - something that the Numonyx chip objects to, but the
Samsung chip seems to ignore.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-06-05 17:49:25 +01:00
Kyungmin Park
9ce969082e [MTD] [OneNAND] Add write-while-program support
OneNAND write-while-program method of writing improves performance,
compared with ordinary writes, by transferring data to OneNAND's
RAM buffers atthe same time as programming the NAND core.

When writing several NAND pages at a time, an improvement of
12% to 25% is seen.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2009-03-23 15:14:46 +00:00
Adrian Hunter
69423d99fc [MTD] update internal API to support 64-bit device size
MTD internal API presently uses 32-bit values to represent
device size.  This patch updates them to 64-bits but leaves
the external API unchanged.  Extending the external API
is a separate issue for several reasons.  First, no one
needs it at the moment.  Secondly, whether the implementation
is done with IOCTLs, sysfs or both is still debated.  Thirdly
external API changes require the internal API to be accepted
first.

Note that although the MTD API will be able to support 64-bit
device sizes, existing drivers do not and are not required
to do so, although NAND base has been updated.

In general, changing from 32-bit to 64-bit values cause little
or no changes to the majority of the code with the following
exceptions:
    	- printk message formats
    	- division and modulus of 64-bit values
    	- NAND base support
	- 32-bit local variables used by mtdpart and mtdconcat
	- naughtily assuming one structure maps to another
	in MEMERASE ioctl

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2008-12-10 13:37:21 +00:00
Adrian Hunter
bb0eb217c9 [MTD] Define and use MTD_FAIL_ADDR_UNKNOWN instead of 0xffffffff
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2008-08-12 11:02:15 +01:00
Kyungmin Park
83973b8793 [MTD] [OneNAND] Check the ECC status first instead of controller
To get the correct information in case of power off recovery,
it should read ECC status first
Also remove previous workaround method.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-06-04 17:45:39 +01:00
Adrian Hunter
67e5a28b35 [MTD] [OneNAND] Allow for controller errors when reading
A power loss while writing can result in a page becoming unreadable.  
When the device is mounted again, reading that page gives controller 
errors. Upper level software like JFFS2 treat -EIO as fatal, refusing to 
mount at all.  That means it is necessary to treat the error as an ECC 
error to allow recovery. Note that typically in this case, the 
eraseblock can still be erased and rewritten i.e. it has not become a 
bad block.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-04-22 21:26:16 +01:00
Roel Kluin
b73d7e4381 [MTD] [OneNAND] unlikely(x) || unlikely(y) => unlikely(x || y)
Acked-By: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-04-22 19:15:28 +01:00
Kyungmin Park
66a10506d6 [MTD] [OneNAND] Fix unlock all in Double Density Package (DDP)
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-16 15:15:55 +00:00
Richard Purdie
6c77fd649f [MTD] onenand: Add panic_write function to the onenand driver
Implement the panic_write function for the onenand driver. This waits
for any active command to complete/timeout, performs the write, waits
for it to complete and then returns.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2008-02-07 10:31:23 +00:00
Kyungmin Park
69d79186dc [MTD] [OneNAND] Use pre-alloced oob buffer instead of local buffer
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:14:01 +09:00
Sheng Yongjie (Sam
978cb38a29 [MTD] [OneNAND] Use the u_char instead of char in oobbuf
In function onenand_verify_oob, local variable oobbuf shall be unsigned char.

In the case of a value is >= 0x80, it's unequal in comparing the value in an unsigned char and signed char.

Signed-off-by: Sheng Yongjie (Sam) <samsheng@trident.com.cn>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:13:24 +09:00
Kyungmin Park
b2581be291 [MTD] [OneNAND] Check the initial bad block using ONENAND_CTRL_ERROR
Some chips don't set the ONENAND_CTRL_LOAD bit.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:12:32 +09:00
Kyungmin Park
e71f04fc92 [MTD] [OneNAND] Get correct density from device ID
Use the higher bits for other purpose.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:11:38 +09:00
Kyungmin Park
b21b72cf33 [MTD] [OneNAND] Consolidate OneNAND operation order
Consolidate OneNAND operation order as OneNAND Spec.
It also doesn't break previous operation order.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:10:28 +09:00
Adrian Hunter
9d2f0b7a3d [MTD] [OneNAND] fix call to onenand_verify when writing subpages
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:07:30 +09:00
Adrian Hunter
d0b36d8cc8 [MTD] [OneNAND] Do not release chip twice
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-29 17:07:06 +09:00
Adrian Hunter
5f4d47d5d1 [MTD] [OneNAND] Do not stop reading for ECC errors
When an ECC error occurs, the read should be completed
anyway before returning -EBADMSG.  Returning -EBADMSG
straight away is incorrect.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-11-26 13:16:29 +00:00
Jeff Garzik
06efcad0d4 Eliminate pointless casts from void* in a few driver irq handlers.
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2007-10-23 19:53:16 -04:00
Adrian Hunter
3cd3a86b6f [MTD] [OneNAND] Avoid deadlock in erase callback; release chip lock first.
When the erase callback performs some other action on the flash, it's
highly likely to deadlock unless we actually release the chip lock
before calling it.

This patch mirrors that same change already done for NAND.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-10-14 13:37:53 +01:00
Adrian Hunter
30a7eb298a [MTD] [OneNAND] Return only negative error codes
The OneNAND driver was confusing JFFS2 by returning positive error
codes.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-10-14 13:37:41 +01:00
Adrian Hunter
34627f0e76 [MTD] [OneNAND] Synchronize block locking operations
Ensure OneNAND's block locking operations are synchronized
like all other operations.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-10-14 13:37:28 +01:00
Kyungmin Park
1437085c37 [MTD] [OneNAND] Fix typo related with recent commit
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-10-13 11:26:44 +01:00
Artem Bityutskiy
49dc08eeda [MTD] [OneNAND] fix numerous races
This patch make the OneNAND driver much less racy. It fixes
our "onenand_wait: read timeout!" heisenbugs. The reason of
these bugs was that the driver did not lock the chip when
accessing OTP, and it screwed up OneNAND state when the OTP
was read while JFFS2 was doing FS checking.

This patch also fixes other races I spotted:
1. BBT was not protected
2. Access to ecc_stats was not protected

Now the chip is locked when BBT is accessed.

To fix all of these I basically split all interface functions
on 'function()' and 'function_nolock()' parts.

I tested this patch on N800 hardware - it fixes our problems.
But I tested a little different version because our OneNAND
codebase is slightly out-of-date. But it should be OK.

This patch also includes the prin fixes I posted before.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-09-23 19:58:52 +01:00
Kyungmin Park
d15057b703 [MTD] [OneNAND] main read/write ops support for yaffs2
Now we can use yaffs2 on OneNAND

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-09-06 09:27:03 +01:00
Kyungmin Park
12f77c9eed [MTD] [OneNAND] Use mtd_oob_ops at oob functions
To enable the main read/write at oob ops

Next time we will commit the main read/write support for yaffs2

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-08-30 01:46:28 +01:00
Kyungmin Park
ee9745fcf2 [MTD] [OneNAND] 2X program support
The 2X Program is an extension of Program Operation.

Since the device is equipped with two DataRAMs, and two-plane NAND Flash 
memory array, these two component enables simultaneous program of 4KiB.
Plane1 has only even blocks such as block0, block2, block4 while Plane2 
has only odd blocks such as block1, block3, block5.
So MTD regards it as 4KiB page size and 256KiB block size

Now the following chips support it. (KFXXX16Q2M)
Demux: KFG2G16Q2M, KFH4G16Q2M, KFW8G16Q2M,
Mux:   KFM2G16Q2M, KFN4G16Q2M,

And more recent chips

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-06-30 08:24:57 +01:00
Michael Opdenacker
59c51591a0 Fix occurrences of "the the "
Signed-off-by: Michael Opdenacker <michael@free-electrons.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
2007-05-09 08:57:56 +02:00
Adrian Hunter
c36c46d53b [MTD] [OneNAND] Exit loop only when column start with 0
The JFFS2 requests OOB function from column 0.
But the oobtest in nand-tests doesn't.
So we only exit loop only when column start with 0.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-04-25 11:09:37 +01:00
Kyungmin Park
ad28634366 [MTD] [OneNAND] Fix access the past of the real oobfree array
Here it's not the case: all the entries are occupied by
OOB chunks. Therefore, once we get into a loop like

        for (free = this->ecclayout->oobfree; free->length; ++free) {
	}

we might end up scanning past the real oobfree array.

Probably the best way out, as the same thing might happen for common NAND
as well, is to check index against MTD_MAX_OOBFREE_ENTRIES.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-04-25 11:09:23 +01:00
Kyungmin Park
470bc84436 [MTD] [OneNAND] Classify the page data and oob buffer
Classify the page data and oob buffer
and it prevents the memory fragementation (writesize + oobsize)

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-03-09 08:08:09 +00:00
Kyungmin Park
5bc399e9ef [MTD] [OneNAND] Exit the loop when transferring/filling of the oob is finished
When transferring/filling of the oob is finished in OOB_AUTO, we exit the loop

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-03-09 08:06:39 +00:00
Adrian Hunter
81280d5879 [MTD] [OneNAND] add Nokia Copyright and a credit
add Nokia Copyright and a credit

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-03-09 08:05:57 +00:00
Kyungmin Park
e3da8067b3 [MTD] [OneNAND] Fix typo & wrong comments
Fix typo & wrong comments

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-03-09 08:05:22 +00:00
Kyungmin Park
91014e9bfa [MTD] [OneNAND] Use oob buffer instead of main one in oob functions
In oob functions, it is used main buffer instead of oob one. So fix it.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-03-09 08:04:25 +00:00
Vitaly Wool
1f92267c51 [MTD] [NAND] make oobavail public
During the MTD rework the oobavail parameter of mtd_info structure has become
private. This is not quite correct in terms of integrity and logic. If we have
means to write to OOB area, then we'd like to know upfront how many bytes out
of OOB are spare per page to be able to adapt to specific cases.
The patch inlined adds the public oobavail parameter.

Signed-off-by: Vitaly Wool <vwool@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-03-08 09:17:43 +00:00
Andrew Morton
5785bdd6fc [MTD] [ONENAND] onenand_base warning fix
drivers/mtd/onenand/onenand_base.c: In function 'onenand_bbt_read_oob':
drivers/mtd/onenand/onenand_base.c:1033: warning: format '%i' expects type 'int', but argument 3 has type 'size_t'

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-18 16:38:32 +00:00
Artem Bityutskiy
64f6071056 [MTD] remove unused ecctype,eccsize fields from struct mtd_info
Remove unused and broken mtd->ecctype and mtd->eccsize fields
from struct mtd_info. Do not remove them from userspace API
data structures (don't want to breake userspace) but mark them
as obsolete by a comment. Any userspace program which uses them
should be half-broken anyway, so this is more about saving
data structure size.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 15:27:12 +00:00
Adrian Hunter
480b9dfb1f [MTD] OneNAND: Invalidate bufferRAM after erase
OneNAND has internal bufferRAMs.  The driver keeps track of
what is in the bufferRAM to save having to load from the
NAND core.  After an erase operation, the driver must
mark bufferRAM invalid if it refers to the erased block.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 15:16:55 +00:00
Adrian Hunter
cde36b37d6 [MTD] OneNAND: Select correct chip's bufferRAM for DDP
OneNAND double-density package (DDP) has two chips, each with
their own bufferRAM.  The driver will skip loading data from
the NAND core if the data can be found in a bufferRAM, however
in that case, the correct chip's bufferRAM must be selected
before reading from bufferRAM.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-09 09:42:42 +09:00
Kyungmin Park
211ac75f5e [MTD] OneNAND: Error message printing and bad block scan erros
Provide the bad block scan with its own read function so that important error
messages that are not from the the bad block scan, can always be printed.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-07 12:15:01 +09:00
Adrian Hunter
81f38e1123 [MTD] OneNAND: Subpage write returned incorrect length written
When a write is done, the length written is returned.  When a
single subpage is written the length returned should be the
subpage size, however the page size was being returned.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-07 10:55:23 +09:00
Adrian Hunter
52e4200a6d [MTD] OneNAND: Do not allow oob write past end of page
OneNAND can write oob to successive pages, but NAND
does not do that.  For compatibility, disallow OneNAND
from writing past the end of the page.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-06 09:15:39 +09:00
Kyungmin Park
5b4246f1b0 [MTD] OneNAND: Fix typo and remove unnecessary goto statement
In previos patch, there's typo so fix it
Remove unnecessary goto statement

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-02 09:39:21 +09:00
Kyungmin Park
abf3c0f23d [MTD] OneNAND: Reduce internal BufferRAM operations
It use blockpage instead of a pair (block, page). It can also cover a small chunk access. 0x00, 0x20, 0x40 and so on.

And in JFFS2 behavior, sometimes it reads two pages alternatively.
e.g., It first reads A page, B page and A page.
So we check another bufferram to find requested page.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-02 09:29:36 +09:00
Kyungmin Park
4f4fad27ac [MTD] OneNAND: Remove line of code that was meant to be deleted in OOB_AUTO
- Iterations of the patch to add oob auto-placement support to OneNAND left a line of code that was meant to have been deleted.
- read mtd->oobsize in onenand_transfer_auto_oob to optimized memcpy

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-02 09:22:21 +09:00
Adrian Hunter
a5e7c7b447 [MTD] OneNAND: Add support for auto-placement of out-of-band data
Enable the use of oob operation mode MTD_OOB_AUTO with OneNAND.
Note that MTD_OOB_RAW is still not supported.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-02-01 09:28:18 +09:00