Commit Graph

388 Commits

Author SHA1 Message Date
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
Vitaly Wool 7e4178f90e [PATCH] NAND: fix remaining OOB length calculation
In nand_read_page_syndrome/nand_write_page_syndrome the calculation of
the remaining oob length which is not used by the prepad/ecc/postpad
areas is wrong.

Signed-off-by: Vitaly Wool <vwool@ru.mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-06-20 20:31:23 +01:00
Thomas Gleixner b6d5ee00e3 [MTD] NAND Fixup NDFC merge brokeness
Remove the remains of a broken merge.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-06-20 20:31:23 +01:00
Ben Dooks ad3b5fb772 [MTD NAND] S3C2410 driver cleanup
Fix unused variables and commenting since tglx's
new NAND updates

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-19 09:43:23 +01:00
Ben Dooks d1fef3c5e1 [MTD NAND] s3c24x0 board: Fix clock handling, ensure proper initialisation.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-19 09:29:38 +01:00
David Woodhouse 21c8db9eff [MTD] Restore MTD_ROM and MTD_RAM types
Let's not attempt the abolition of mtd->type until/unless it's properly
thought through. And certainly, let's not do it by halves.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-14 21:39:48 +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
David Woodhouse f9068876f5 [MTD NAND] Fix s3c2410 NAND driver so it at least _looks_ like it compiles
Fix the control bit handling so it even looks like it might work, too.
Bad tglx. No biscuit.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-10 00:53:16 +01:00
Andrew Morton f24ff6bf8c [MTD] Prepare physmap for 64-bit-resources
Fallout from the incoming 64-bit-resource stuff:

drivers/mtd/maps/physmap.c: In function 'physmap_flash_probe':
drivers/mtd/maps/physmap.c:94: warning: format '%.8lx' expects type 'long
unsigned int', but argument 2 has type 'resource_size_t'
drivers/mtd/maps/physmap.c:94: warning: format '%.8lx' expects type 'long
unsigned int', but argument 3 has type 'resource_size_t'

Cc: Vivek Goyal <vgoyal@in.ibm.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-06-09 15:12:34 +01:00
Joern Engel 73c619ea0e [MTD] Disconnect struct mtd_info from ABI
mtdchar.c direcly copied part of struct mtd_info to userspace, thereby
implicitly making it part of the ABI.  With this patch, struct
mtd_info is independent of the ABI and can have its fields removed,
reordered, etc.

Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
2006-05-30 14:25:35 +02:00
Joern Engel 92cbfdcc36 [MTD] replace MTD_RAM with MTD_GENERIC_TYPE
Ram devices get the extra capability of MTD_NO_ERASE - not requiring
an explicit erase before writing to it.  Currently only mtdblock uses
this capability.  Rest of the patch is a simple text replacement.

Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
2006-05-30 14:25:24 +02:00
Joern Engel e369d62e92 [MTD] replace MTD_ROM with MTD_GENERIC_TYPE
No mtd user should ever check for the device type.  Instead, device features
should be checked by the flags - if at all.
As a first step towards type removal, change MTD_ROM into MTD_GENERIC_TYPE.

Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
2006-05-30 14:25:17 +02:00
Joern Engel e1219724be [MTD] remove a forgotten MTD_XIP
MTD_XIP definition was removed in an earlier patch.  This invocation
was left by mistake.

Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
2006-05-30 14:25:05 +02:00
Andrew Morton 7e9a0bb00c [MTD] Fix build warnings (and debug build error) in nand_base.c
drivers/mtd/nand/nand_base.c: In function 'nand_transfer_oob':
drivers/mtd/nand/nand_base.c:909: warning: comparison of distinct pointer types lacks a cast
drivers/mtd/nand/nand_base.c: In function 'nand_do_read_oob':
drivers/mtd/nand/nand_base.c:1097: error: 'len' undeclared (first use in this function)
drivers/mtd/nand/nand_base.c:1097: error: (Each undeclared identifier is reported only once
drivers/mtd/nand/nand_base.c:1097: error: for each function it appears in.)
drivers/mtd/nand/nand_base.c: In function 'nand_fill_oob':
drivers/mtd/nand/nand_base.c:1411: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-30 09:06:41 +01: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 9a1fcdfd4b [MTD] NAND Signal that a bitflip was corrected by ECC
Return -EUCLEAN on read when a bitflip was detected and corrected, so the
clients can react and eventually copy the affected block to a spare one.
Make all in kernel users aware of the change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-29 15:06:51 +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
Andrew Morton 19676ff0a6 [MTD] Fix debug printk format warning in m25p80 SPI chip driver, again.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-29 11:33:33 +01:00
David Woodhouse 33280eac70 [MTD] AMD Geode NAND support can depend on X86_32; we won't see it on x86_64
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-29 11:24:29 +01:00
Thomas Gleixner ba0251fe87 [MTD] NAND Consolidate references and add back default name setting
We have a type pointer. Make use of it instead of the error prone nand_ids[i]
reference.

The NAND driver used to set default name settings from the chip ID
string for the device. The feature got lost during the rework. Add it back.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-27 01:02:13 +02:00
Thomas Gleixner cca3b837bb [MTD] NAND simplify nand_chip_select
nCE setting can be done when the first command is issued to the device.
We keep the deselect functionality as it makes sense to deassert nCE
when the device becomes idle.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-27 00:47:18 +02:00
David Woodhouse 29da9cea46 [MTD] Fix thinko in nand_write_page_hwecc()
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-26 23:05:44 +01: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
David Woodhouse e4d222ff18 [MTD] Remove PCI dependency for Geode CS553[56] NAND controller.
PCI is faked on these devices by SMM traps. Don't depend on that --
check for the chipset directly instead.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-26 02:06:27 +01:00
David Woodhouse c5b553cc2c [MTD] Fix NAND_VERIFY_WRITE case to build with tglx's recent changes
Bad tglx. No biscuit.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-25 13:25:17 +01:00
Thomas Gleixner 8546ac4f84 [MTD] Remove the only useless readv implementation
Removing readv from struct mtd_info broke block2mtd. Remove the
reference and the useless default implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-25 12:53:47 +01: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 7314e9e7d5 [MTD] NAND Cleanup oob functions
Cleanup the code in the oob related functions and
make use of the new NO_READRDY flag.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-25 12:45:27 +01:00
Thomas Gleixner 7a30601b3a [MTD] NAND Introduce NAND_NO_READRDY option
The nand driver has a superflous read ready / command
delay in the read functions. This was added to handle
chips which have an automatic read forward. Newer
chips do not have this functionality anymore. Add this
option to avoid the delay / I/O operation. Mark all
large page chips with the new option flag.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-25 12:45:26 +01:00
Thomas Gleixner 04bbd0eafb [MTD] NAND Initialize controller lock and wq only once
The lock simplifying patch did not move the lock and waitqueue
initialization into the controller allocation patch.
This reinitializes waitqueue and spinlocks also for driver
supplied controller stuctures. Move it into the allocation path.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-25 12:45:26 +01:00
Thomas Gleixner 12efdde313 [MTD] NAND fix cmd_ctrl breakage
The cmd_ctrl rework lacks some state transition flags.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-24 23:45:24 +01:00
Thomas Gleixner ace4dfee56 [MTD] NAND coding style and namespace cleanup
Cleanup the functions which are not going to change in the
next steps.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-24 23:45:24 +01:00
Thomas Gleixner d470a97c70 [MTD] NAND LED support cleanup
Move the define out of the middle of the code and add an
appropriate comment.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 23:48:57 +02:00
Thomas Gleixner cad74f2c38 [MTD] NAND remove write_byte/word function from nand_chip
The previous change of the command / hardware control allows to
remove the write_byte/word functions completely, as their only
user were nand_command and nand_command_lp.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 23:28:48 +02:00
Thomas Gleixner 7abd3ef987 [MTD] Refactor NAND hwcontrol to cmd_ctrl
The hwcontrol function enforced a step by step state machine
for any kind of hardware chip access. Let the hardware driver
know which control bits are set and inform it about a change
of the control lines. Let the hardware driver write out the
command and address bytes directly. This gives a peformance
advantage for address bus controlled chips and simplifies the
quirks in the hardware drivers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 23:25:53 +02:00
Thomas Gleixner 3821720d51 [MTD] Export nand_write_raw
The previous _ecc removal / cleanup broke (i)nftl module usage.
Export the missing symbol.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 22:33:52 +02:00
Thomas Gleixner 85b85fee0c [MTD] Mark NAND drivers TOTO and PPChameleon broken
Both drivers can not be fixed and compiled due to missing header files.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 22:03:39 +02:00
Thomas Gleixner 9223a456da [MTD] Remove read/write _ecc variants
MTD clients are agnostic of FLASH which needs ECC suppport.
Remove the functions and fixup the callers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 17:21:03 +02:00
Thomas Gleixner 2528e8cdf3 [MTD] Remove readv/readv_ecc
These functions were never implemented and added only bloat to
partition and concat code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 16:10:00 +02:00
Thomas Gleixner 9d8522df37 [MTD] Remove nand writev support
NAND writev(_ecc) support is not longer necessary. Remove it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 16:06:03 +02:00
Thomas Gleixner 0cddd6c258 [MTD] ECC rework broke diskonchip
Fix the diskonchip ecc setup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 15:59:58 +02:00
Thomas Gleixner 4cbb9b80e1 Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 12:37:31 +02:00
Thomas Gleixner 6dfc6d250d [MTD] NAND modularize ECC
First step of modularizing ECC support.
- Move ECC related functionality into a seperate embedded data structure
- Get rid of the hardware dependend constants to simplify new ECC models

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 12:00:46 +02:00
Thomas Gleixner 7aa65bfd67 [MTD] NAND cleanup nand_scan
Seperate functionality out of nand_scan so the code is more
readable. No functional change. First step of simplifying
the nand driver.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 11:54:38 +02:00
Thomas Gleixner 58dd8f2bfd [MTD] NAND consolidate data types
The NAND driver used a mix of unsigned char, u_char amd uint8_t
data types. Consolidate to uint8_t usage

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 11:52:35 +02:00
Thomas Gleixner 2c0a2bed92 [MTD] NAND whitespace and formatting cleanup
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23 11:50:56 +02:00