Commit graph

112 commits

Author SHA1 Message Date
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
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
Artem Bityutskiy 73a4421c5a [MTD] Clarify OOB-operation interface comments
Add more comment to OOB I/O interface. Read/write are not
symmetric which is confusing and should be documented.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 15:27:50 +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
Artem Bityutskiy d416085572 [MTD] [NOR] Intel: remove ugly PROGREGION macros
Remove ugly and weird MTD_PROGREGION_CTRLMODE_VALID() and
MTD_PROGREGION_CTRLMODE_INVALID() macros. There is only one
user of them and they are used locally just for printing.

Anyway, this patch is a preparation for removing mtd->ecctype
and mtd->eccsize, but these macros use them. Fix this.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 15:26:37 +00:00
Stefan Roese 0d36da3b40 [MTD] physmap: Add support for 64 bit resources
This patch adds support for 64 bit resources enabled via the
CONFIG_RESOURCES_64BIT option. Now a 64 bit can be passed to the
physmap driver.

Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 14:50:41 +00:00
Haavard Skinnemoen ad7d314480 [MTD] Don't include linux/mtd/map.h from linux/mtd/physmap.h
Replace the inclusion of linux/mtd/map.h with a forward-declaration
of struct map_info. This allows linux/mtd/physmap.h to be included by
e.g. board code even if the MTD subsystem is disabled.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 14:40:12 +00:00
David Woodhouse c1f1625860 Merge branch 'master' of git://git.infradead.org/~kmpark/onenand-mtd-2.6 2007-02-09 12:36:22 +00:00
Randy Dunlap 552a8278d0 [MTD] [NAND] Add kernel-doc for cellinfo field of struct nand_chip
Fixes kernel-doc warning in mtd/nand.h.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2007-02-09 11:43:19 +00: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
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 9bfbc9b24f [MTD] OneNAND: Remove unused fields
- Remove unused fields
- Fix typo

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-01-31 14:25:21 +09:00
Kyungmin Park 75384b0d9c [MTD] OneNAND: Update copyrights and code cleanup
Update copyrights and code cleanup

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-01-18 11:10:57 +09:00
Kyungmin Park 738d61f537 [MTD] OneNAND: Reduce Double Density Package (DDP) operations
- DDP code clean-up
- Reduce block & bufferram operations in DDP

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-01-18 11:00:31 +09:00
Adrian Hunter a8de85d557 [MTD] OneNAND: Implement read-while-load
Read-while-load enables higher performance read operations.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-01-10 14:58:42 +02:00
Kyungmin Park 60d84f9739 [MTD] OneNAND: add subpage write support
OneNAND supports up to 4 writes at one NAND page. Add support of this feature.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2007-01-10 14:35:00 +02:00
David Woodhouse bd3c97a7c7 Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-12-01 09:56:43 +00:00
Artem Bityutskiy 9fe912cea3 [MTD] add get and put methods
This patch adds get_device() and put_device() methods to the MTD description
structure (struct mtd_info). These methods are called by MTD whenever the MTD
device is get or put. They are needed when the underlying driver is something
smarter then just flash chip driver, for example UBI.

Signed-off-by: Artem Bityutskiy <dedekind@infradead.org>
2006-11-29 17:04:53 +02:00
Artem Bityutskiy 7799308f34 [MTD] add get_mtd_device_nm() function
This patch adds one more function to the MTD interface to make it possible to
open MTD devices by their names, not only numbers. This is very handy in many
situations. Also, MTD device number depend on load order and may vary, while
names are fixed.

Signed-off-by: Artem Bityutskiy <dedekind@infradead.org>
2006-11-29 17:04:31 +02:00
Thomas Gleixner 29072b9607 [MTD] NAND: add subpage write support
Many SLC NANDs support up to 4 writes at one NAND page. Add support
of this feature.

Signed-off-by: Artem Bityutskiy <dedekind@infradead.org>
2006-11-29 17:03:52 +02:00
Artem Bityutskiy c0fe10aef3 [MTD] increase MAX_MTD_DEVICES
Signed-off-by: Artem Bityutskiy <dedekind@infradead.org>
2006-11-29 16:57:34 +02:00
David Woodhouse 103e40f633 Merge git://git.infradead.org/~kmpark/onenand-mtd-2.6 2006-11-29 00:03:10 +00:00
Vitaly Wool 7014568bad [MTD] [NAND] remove len/ooblen confusion.
As was discussed between Ricard Wanderlöf, David Woodhouse, Artem 
Bityutskiy and me, the current API for reading/writing OOB is confusing. 

The thing that introduces confusion is the need to specify ops.len 
together with ops.ooblen for reads/writes that concern only OOB not data 
area. So, ops.len is overloaded: when ops.datbuf != NULL it serves to 
specify the length of the data read, and when ops.datbuf == NULL, it 
serves to specify the full OOB read length.

The patch inlined below is the slightly updated version of the previous 
patch serving the same purpose, but with the new Artem's comments taken 
into account.

Artem, BTW, thanks a lot for your valuable input!

Signed-off-by: Vitaly Wool <vwool@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-11-28 22:39:03 +00:00
Richard Purdie 1918767299 [MTD] Allow variable block sizes in mtd_blkdevs
Currently, mtd_blkdevs enforces a block size of 512, even if the drivers
can seemingly request a different size. This patch fixes mtd_blkdevs so
block sizes other than 512 work correctly.

Signed-off-by: Richard Purdie <rpurdie@openedhand.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-11-28 22:27:47 +00:00
Kyungmin Park f4f91ac3c8 [MTD] OneNAND: Single bit error detection
Idea from Jarkko Lavinen

Signed-off-by: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2006-11-16 12:03:56 +09:00
Kyungmin Park 08f782b60a [MTD] OneNAND: lock support
Now you can use mtd lock inferface on OneNAND

The idea is from Nemakal, Vijaya, thanks

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2006-11-16 11:29:39 +09:00
Kyungmin Park 2c22120fbd MTD: OneNAND: interrupt based wait support
We can use the two methods to wait.
  1. polling: read interrupt status register
  2. interrupt: use kernel ineterrupt mechanism

  To use interrupt method, you first connect onenand interrupt pin to your
platform and configure interrupt properly

Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
2006-11-16 11:23:48 +09:00
Randy Dunlap 351edd240d [PATCH] MTD: fix last kernel-doc warning
Fix the last current kernel-doc warning:
Warning(/var/linsrc/linux-2619-rc3g5//include/linux/mtd/nand.h:416): No description found for parameter 'write_page'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-10-30 12:08:41 -08:00
David Woodhouse 7dcdcbef5d [MTD] NAND: Combined oob buffer so it's contiguous with data
Ditch the separate oobrbuf and oobwbuf fields from the chip buffers,
and use only a single buffer immediately after the data. This accommodates
NAND controllers such as the OLPC CAFÉ chip, which can't do scatter/gather
DMA so needs the OOB buffer to be contiguous with the data, for both read
and write.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-10-21 17:48:58 +01:00
Uwe Zeisberger f30c226954 fix file specification in comments
Many files include the filename at the beginning, serveral used a wrong one.

Signed-off-by: Uwe Zeisberger <Uwe_Zeisberger@digi.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
2006-10-03 23:01:26 +02:00
Kyungmin Park 28b79ff966 [MTD ONENAND] Check OneNAND lock scheme & all block unlock command support
OneNAND lock scheme depends on density and process of chip.
Some OneNAND chips support all block unlock

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-09-26 16:46:28 +01:00
David Woodhouse b77d95c78f [MTD NAND] Provide prototype for newly-exported nand_wait_ready()
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-09-25 21:58:50 +01:00
David Woodhouse 956e944c76 [MTD NAND] Allow override of page read and write functions.
- allow high-level nand_write_page() function to be overridden
- likewise low-level write_page_raw() and read_page_raw() functions
- Clean up the abuse of chip->ecc.{write,read}_page() with MTD_OOB_RAW

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-09-25 17:12:39 +01:00
David Woodhouse 4bf63fcb83 [MTD NAND] Allocate chip->buffers separately to allow it to be overridden
In particular, the board driver might need it to be DMAable.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-09-25 17:08:04 +01:00
David Woodhouse 3b85c3211e [MTD NAND] Split nand_scan() into two parts; allow board driver to intervene
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-09-25 17:06:53 +01:00
Haavard Skinnemoen 5b0c5c2c0d MTD: Convert Atmel PRI information to AMD format
Atmel flash chips don't have PRI information in the same format as
AMD flash chips. This patch installs a fixup for all Atmel chips that
converts the relevant PRI fields into AMD format.

Only the fields that are actually used by the command set is actually
converted. The rest are initialized to zero (which should be safe)

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2006-08-16 20:13:06 -05:00
Randy Dunlap ea9b6dcc15 MTD: kernel-doc fixes + additions
Fix some kernel-doc typos/spellos.
Use kernel-doc syntax in places where it was almost used.
Correct/add struct, struct field, and function param names where needed.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-29 08:55:41 +01:00
Randy Dunlap 844d3b427e MTD: fix all kernel-doc warnings
Fix all kernel-doc warnings in MTD headers and source files:
- add some missing struct fields;
- correct some function parameter names;
- use kernel-doc format for function doc. headers;
- nand_ecc.c contains only exported interfaces, no internal ones;

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-29 08:55:00 +01:00
Linus Torvalds cee4cca740 Merge git://git.infradead.org/hdrcleanup-2.6
* git://git.infradead.org/hdrcleanup-2.6: (63 commits)
  [S390] __FD_foo definitions.
  Switch to __s32 types in joystick.h instead of C99 types for consistency.
  Add <sys/types.h> to headers included for userspace in <linux/input.h>
  Move inclusion of <linux/compat.h> out of user scope in asm-x86_64/mtrr.h
  Remove struct fddi_statistics from user view in <linux/if_fddi.h>
  Move user-visible parts of drivers/s390/crypto/z90crypt.h to include/asm-s390
  Revert include/media changes: Mauro says those ioctls are only used in-kernel(!)
  Include <linux/types.h> and use __uXX types in <linux/cramfs_fs.h>
  Use __uXX types in <linux/i2o_dev.h>, include <linux/ioctl.h> too
  Remove private struct dx_hash_info from public view in <linux/ext3_fs.h>
  Include <linux/types.h> and use __uXX types in <linux/affs_hardblocks.h>
  Use __uXX types in <linux/divert.h> for struct divert_blk et al.
  Use __u32 for elf_addr_t in <asm-powerpc/elf.h>, not u32. It's user-visible.
  Remove PPP_FCS from user view in <linux/ppp_defs.h>, remove __P mess entirely
  Use __uXX types in user-visible structures in <linux/nbd.h>
  Don't use 'u32' in user-visible struct ip_conntrack_old_tuple.
  Use __uXX types for S390 DASD volume label definitions which are user-visible
  S390 BIODASDREADCMB ioctl should use __u64 not u64 type.
  Remove unneeded inclusion of <linux/time.h> from <linux/ufs_fs.h>
  Fix private integer types used in V4L2 ioctls.
  ...

Manually resolve conflict in include/linux/mtd/physmap.h
2006-06-20 15:10:08 -07:00
Thomas Gleixner 7bc3312bef [MTD] NAND: Fix breakage all over the place
Following problems are addressed:

- wrong status caused early break out of nand_wait()
- removed the bogus status check in nand_wait() which
  is a relict of the abandoned support for interrupted
  erase.
- status check moved to the correct place in read_oob
- oob support for syndrom based ecc with strange layouts
- use given offset in the AUTOOOB based oob operations

Partially based on a patch from Vitaly Vool <vwool@ru.mvista.com>
Thanks to Savin Zlobec <savin@epico.si> for tracking down the
status problem.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-06-20 20:31:24 +01:00
Artem B. Bityutskiy 783ed81ff3 [MTD] assume mtd->writesize is 1 for NOR flashes
Signed-off-by: Artem B. Bityitskiy
2006-06-14 19:53:44 +04:00
Thomas Gleixner f1a28c0284 [MTD] NAND Expose the new raw mode function and status info to userspace
The raw read/write access to NAND (without ECC) has been changed in the
NAND rework. Expose the new way - setting the file mode via ioctl - to
userspace. Also allow to read out the ecc statistics information so userspace
tools can see that bitflips happened and whether errors where correctable
or not. Also expose the number of bad blocks for the partition, so nandwrite
can check if the data fits into the parition before writing to it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-30 00:37:34 +02:00
Thomas Gleixner 8593fbc68b [MTD] Rework the out of band handling completely
Hopefully the last iteration on this!

The handling of out of band data on NAND was accompanied by tons of fruitless
discussions and halfarsed patches to make it work for a particular
problem. Sufficiently annoyed by I all those "I know it better" mails and the
resonable amount of discarded "it solves my problem" patches, I finally decided
to go for the big rework. After removing the _ecc variants of mtd read/write
functions the solution to satisfy the various requirements was to refactor the
read/write _oob functions in mtd.

The major change is that read/write_oob now takes a pointer to an operation
descriptor structure "struct mtd_oob_ops".instead of having a function with at
least seven arguments.

read/write_oob which should probably renamed to a more descriptive name, can do
the following tasks:

- read/write out of band data
- read/write data content and out of band data
- read/write raw data content and out of band data (ecc disabled)

struct mtd_oob_ops has a mode field, which determines the oob handling mode.

Aside of the MTD_OOB_RAW mode, which is intended to be especially for
diagnostic purposes and some internal functions e.g. bad block table creation,
the other two modes are for mtd clients:

MTD_OOB_PLACE puts/gets the given oob data exactly to/from the place which is
described by the ooboffs and ooblen fields of the mtd_oob_ops strcuture. It's
up to the caller to make sure that the byte positions are not used by the ECC
placement algorithms.

MTD_OOB_AUTO puts/gets the given oob data automaticaly to/from the places in
the out of band area which are described by the oobfree tuples in the ecclayout
data structre which is associated to the devicee.

The decision whether data plus oob or oob only handling is done depends on the
setting of the datbuf member of the data structure. When datbuf == NULL then
the internal read/write_oob functions are selected, otherwise the read/write
data routines are invoked.

Tested on a few platforms with all variants. Please be aware of possible
regressions for your particular device / application scenario

Disclaimer: Any whining will be ignored from those who just contributed "hot
air blurb" and never sat down to tackle the underlying problem of the mess in
the NAND driver grown over time and the big chunk of work to fix up the
existing users. The problem was not the holiness of the existing MTD
interfaces. The problems was the lack of time to go for the big overhaul. It's
easy to add more mess to the existing one, but it takes alot of effort to go
for a real solution.

Improvements and bugfixes are welcome!

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-29 15:06:51 +02:00
Thomas Gleixner f4a43cfcec [MTD] Remove silly MTD_WRITE/READ macros
Most of those macros are unused and the used ones just obfuscate
the code. Remove them and fixup all users.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-29 15:06:50 +02:00
Thomas Gleixner 5bd34c091a [MTD] NAND Replace oobinfo by ecclayout
The nand_oobinfo structure is not fitting the newer error correction
demands anymore. Replace it by struct nand_ecclayout and fixup the users
all over the place. Keep the nand_oobinfo based ioctl for user space
compability reasons.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-29 15:06:50 +02:00
Thomas Gleixner ff268fb879 [MTD] NAND Consolidate oobinfo handling
The info structure for out of band data was copied into
the mtd structure. Make it a pointer and remove the ability
to set it from userspace. The position of ecc bytes is
defined by the hardware and should not be changed by software.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-29 15:06:49 +02:00
Thomas Gleixner 8be834f762 [MTD] NAND Fix platform structure and NDFC driver
The platform structure was lacking an oobinfo field.
The NDFC driver had some remains from another tree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-29 15:06:49 +02:00
Thomas Gleixner f75e5097ef [MTD] NAND modularize write function
Modularize the write function and reorganaize the internal buffer
management. Remove obsolete chip options and fixup all affected
users.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-26 18:52:08 +02:00
Thomas Gleixner f5bbdacc41 [MTD] NAND Modularize read function
Split the core of the read function out and implement
seperate handling functions for software and hardware
ECC.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-25 12:45:27 +01:00
Thomas Gleixner 9577f44a89 [MTD] NAND Add read/write function pointers to struct nand_ecc_ctrl
Add read/write function pointers to struct nand_ecc_ctrl to
prepare the modulaization of nand_read/write functions. The
current implementation handles every type of ecc mode
software/hardware and all kinds of strange ecc placement
schemes in one switch/if construct. Thats too complex to
maintain and too inflexible to expand. Modularization will
also shorten the code pathes of the read/write functions.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-25 12:45:27 +01:00