summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand: nand_base: Fix compile warning if CONFIG_MTD_WRITE is not enabledTeresa Remmet2018-12-181-1/+1
| | | | | | | | | | drivers/mtd/nand/nand_base.c:337:12: warning: 'nand_default_block_markbad' defined but not used [-Wunused-function] Add __maybe_unused again to silence warning when CONFIG_MTD_WRITE is not enabled. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: detect OOB size for Toshiba 24nm raw SLCLadislav Michl2018-12-171-0/+14
| | | | | | | Linux commit 60c673824561. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Kill cellinfoLadislav Michl2018-12-171-9/+20
| | | | | | | | | The only information used from cellinfo field is whenever flash is SLC or MLC, therefore eliminate it completely. This patch is based on Linux commit 7db906b79f69. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Kill the chip->scan_bbt() hookLadislav Michl2018-12-171-5/+1
| | | | | | | | | | | Linux commit e80eba758151 adapted for Barebox: None of the existing drivers are overloading the ->scan_bbt() method, let's get rid of it and replace calls to ->scan_bbt() by nand_create_bbt() ones. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: simplify nand_bch_init() usageLadislav Michl2018-12-141-6/+2
| | | | | | | | | | | | | | Linux commit a8c65d504e0b modified for Barebox: nand_bch_init() requires several arguments which could directly be deduced from the mtd device. Get rid of those useless parameters. nand_bch_init() is also requiring the caller to provide a proper eccbytes value, while this value could be deduced from the ecc.size and ecc.strength value. Fallback to eccbytes calculation when it is set to 0. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Request strength instead of bytes for soft BCHLadislav Michl2018-12-141-7/+8
| | | | | | | | | | | | | | | | | Linux commits e0377cdebaf3 and 438320dd34a4 combined and adapted for Barebox: Previously, we requested that drivers pass ecc.size and ecc.bytes when using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC strength required for its NAND, so each driver would need to perform a strength-to-bytes calculation. Avoid duplicating this calculation in each driver by asking drivers to pass ecc.size and ecc.strength so that the strength-to-bytes calculation need only be implemented once. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: hide in-memory BBT implementation detailsLadislav Michl2018-12-141-61/+67
| | | | | | | | | | | | | | | | | Linux commit b32843b772db adapted for Barebox: nand_base.c shouldn't have to know the implementation details of nand_bbt's in-memory BBT. Specifically, nand_base shouldn't perform the bit masking and shifting to isolate a BBT entry. Instead, just move some of the BBT code into a new nand_markbad_bbt() interface. This interface allows external users (i.e., nand_base) to mark a single block as bad in the BBT. Then nand_bbt will take care of modifying the in-memory BBT and updating the flash-based BBT (if applicable). Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: refactor chip->block_markbad interfaceLadislav Michl2018-12-141-35/+52
| | | | | | | | | | | | Linux commit 5a0edb251ae9 adapted for Barebox: The chip->block_markbad pointer should really only be responsible for writing a bad block marker for new bad blocks. It should not take care of BBT-related functionality, nor should it handle bookkeeping of bad block stats. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: fix nand_lock/unlock() functionWhite Ding2018-11-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | Do nand reset before write protect check. If we want to check the WP# low or high through STATUS READ and check bit 7, we must reset the device, other operation (eg.erase/program a locked block) can also clear the bit 7 of status register. As we know the status register can be refreshed, if we do some operation to trigger it, for example if we do erase/program operation to one block that is locked, then READ STATUS, the bit 7 of READ STATUS will be 0 indicate the device in write protect, then if we do erase/program operation to another block that is unlocked, the bit 7 of READ STATUS will be 1 indicate the device is not write protect. Suppose we checked the bit 7 of READ STATUS is 0 then judge the WP# is low (write protect), but in this case the WP# maybe high if we do erase/program operation to a locked block, so we must reset the device if we want to check the WP# low or high through STATUS READ and check bit 7. Signed-off-by: White Ding <bpqw@micron.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> [Cherry-picked from linux: 57d3a9a89a06 mtd: nand: fix nand_lock/unlock() function] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: don't break long print messagesLadislav Michl2018-10-261-4/+2
| | | | | | | | | | Linux commit 2ac63d901b11 adapted for Barebox: ...However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Only call ONFI get/set features on supported chipsSascha Hauer2017-09-061-2/+6
| | | | | | | Older versions of the ONFI spec do not support get/set features, so do not call these commands when they are not available. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: use dev_add_param_enumSascha Hauer2017-04-111-8/+26
| | | | | | | dev_add_param_enum allows to pass a priv * so that the device_d * argument is not needed and can be removed later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2016-07-111-6/+7
|\
| * mtd: nand: Set ONFI function hooks earlierSascha Hauer2016-06-241-6/+7
| | | | | | | | | | | | | | | | Make the ONFI function hooks available after nand_scan_ident() but before nand_scan_tail(). Based on the kernel commit: 4204ccc mtd: set ONFI nand's default hooks in nand_set_defaults() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: simplify nand_block_checkbadUwe Kleine-König2016-07-051-4/+1
|/ | | | | | | | | | | | | | | | | | | | if (A) { if (!B) return C; return D; } return C; can be simplified to: if (A && B) return D; return C; Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Pass page argument to read_subpage hookSascha Hauer2016-05-101-2/+2
| | | | | | | Similar to what the kernel does in e004debda (mtd: nand: add "page" argument for read_subpage hook). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: export nand_check_erased_bufSascha Hauer2016-04-081-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: rename mtd_all_ff -> mtd_buf_all_ffSascha Hauer2016-03-151-1/+1
| | | | | | | To make clear this function checks a given buffer and not data on a mtd device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Add support for marking blocks as goodSascha Hauer2016-03-151-0/+59
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: default bitflip-reporting threshold to 75% of correction strengthSascha Hauer2016-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Based on Kernel commit 240181fd0ffa6 from Brian Norris: The MTD API reports -EUCLEAN only if the maximum number of bitflips found in any ECC block exceeds a certain threshold. This is done to avoid excessive -EUCLEAN reports to MTD users, which may induce additional scrubbing of data, even when the ECC algorithm in use is perfectly capable of handling the bitflips. This threshold can be controlled by user-space (via sysfs), to allow users to determine what they are willing to tolerate in their application. But it still helps to have sane defaults. In recent discussion [1], it was pointed out that our default threshold is equal to the correction strength. That means that we won't actually report any -EUCLEAN (i.e., "bitflips were corrected") errors until there are almost too many to handle. It was determined that 3/4 of the correction strength is probably a better default. [1] http://lists.infradead.org/pipermail/linux-mtd/2015-January/057259.html Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Add erased page bitflip check helper functionsMarkus Pargmann2016-01-041-0/+128
| | | | | | | | | | This adds the bitflip check helper functions from the kernel. They are used to check for bitflips in erased pages and correct them in the buffer so that UBI can work with it. Unfortunately most nand controllers do not have ECC for erased pages and don't do this on their own. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd nand: added 'bits_per_cell' propertyEnrico Jorns2015-09-231-0/+2
| | | | | | | This one is available in the kernel and used by the denali driver Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand_base: replace ifdef with IS_ENABLEAntony Pavlov2015-08-061-7/+7
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: cleanup ONFI printed errors, warningsBrian Norris2015-02-111-9/+6
| | | | | | | | | | | | | This corresponds to commit c7f23a70635895b5125aeb5593aaf8cb44d3a088 in the Linux kernel. One notable difference is however that ONFI detection is allowed here even in 16-bit mode. This is proved to work fine on an i.MX25 based machine with a x16 NAND. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2013-11-071-1/+1
|\
| * mtd: Pass device_id to add_mtd_deviceSascha Hauer2013-10-291-1/+1
| | | | | | | | | | | | | | | | | | Right now we do not support persistent names for mtd devices. The base name can be passed to add_mtd_device, but this is always appended with a dynamic number. With this patch add_mtd_device takes a device_id argument which can be used to create a mtd device with an exact name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: don't scan bbt if CONFIG_NAND_BBT not set张忠山2013-11-041-0/+3
|/ | | | | Signed-off-by: 张忠山 <zzs0213@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: update to v3.11-rc1Sascha Hauer2013-07-231-463/+2289
| | | | | | | | | | | | | | | | | | This updates the NAND stuff to Linux-3.11-rc1. It is synchronized as best as we can get: - locks removed - The splitting in different files we had to better support different features has been dropped. Instead this is now done mostly with the use of __maybe_unused Some barebox adjustments are forward ported, like: - Allow partial page writes - Optionally allow to erase bad blocks - check for all_ff before writing a page Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: introduce ecc strengthSascha Hauer2013-07-221-0/+2
| | | | | | | This introduces the ecc stength fields in the structures and fills them in, but leaves them unused right now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: rename MTD_OOB_* to MTD_OPS_*Sascha Hauer2013-07-221-9/+9
| | | | | | To sync with the Linux kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand_base: add missing newlineJan Luebbe2013-07-091-1/+1
| | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand_base: fix chipsize for multi LUN nandsJan Weitzel2013-06-241-1/+2
| | | | | | | | | Chipsize didn't take number of LUNs into account. Sync chipsize calculation to kernel commit 63795755 Tested with MT29F8G16ADBDAH4 on OMAP4 Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand_base: sync flash detection functions with linux 3.9's codeEric Bénard2013-05-171-120/+266
| | | | | | | | | this fix the problems introduced when detecting non ONFI flashes in commit 4c2bdc8728016b3412523e3264651651fe752860 "nand_base: detect more ONFI flash" Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/param'Sascha Hauer2013-05-061-10/+12
|\ | | | | | | | | Conflicts: drivers/mci/mci-core.c
| * mtd: Nand: Use dev_add_param_bool for erasebad parameterSascha Hauer2013-04-111-10/+12
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nand_base: detect more ONFI flashEric Bénard2013-04-111-7/+6
|/ | | | | | | | | | | | | | | | | | | | | | if the flash has a known type, the ONFI detection won't occur and thus we may not detect the right parameters. By testing both namd and pagesize, as done in the kernel, we can detect ONFI flash with know IDs. As an example on an i.MX53 board : - without the patch : NAND device: Manufacturer ID: 0x2c, Chip ID: 0xd3 (Micron NAND 1GiB 3,3V 8-bit), page size: 4096, OOB size: 128 - with the patch : ONFI flash detected ... ONFI param page 0 valid NAND device: Manufacturer ID: 0x2c, Chip ID: 0xd3 (Micron MT29F8G08ABACAWP), page size: 4096, OOB size: 224 in the first case the OOB size is wrong. Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Add bbt parameterSascha Hauer2013-03-091-0/+19
| | | | | | | | The information which kind of bbt (if any) is used is hidden somewhere in the NAND layer. Expose it to a device parameter to make it detectable and visible during runtime. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Add parameter to allow erasing bad blocksSascha Hauer2013-03-041-0/+20
| | | | | | | | | | | | While erasing bad blocks is a potentially dangerous operation it is sometimes needed during development or when some foreign code has touched the flash. This patch adds a device parameter 'erasebad' to allow erasing bad blocks. Since this is not wanted during production this is behind a Kconfig option. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: register nand flashes with nand specific functionSascha Hauer2013-03-041-0/+11
| | | | | | | This allows us to have some NAND specific stuff during registration, like for example adding NAND specific device parameters. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd nand: Specify pr_fmt and change messages to pr_*Sascha Hauer2013-01-271-18/+21
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: extend NAND flash detection to new MLC chipsMarcus Folkesson2012-09-161-19/+78
| | | | | | | | | | | Some of the newer MLC devices have a 6-byte ID sequence in which several field definitions differ from older chips in a manner that is not backward compatible. This method is already used in the Linux Kernel. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd nand: implement buswidth detectionSascha Hauer2012-08-031-4/+16
| | | | | | | | | | | | | | This introduces a new NAND_BUSWIDTH_AUTO flag which can be used to automatically detect the nand buswidth. The id is always read in 8bit mode. An additional callback is needed to switch the nand controller into 16bit mode. This currently depends on a safe read_byte (always) and read_buf (for onfi-only flashes) callback. It has been tested on OMAP, but is not something that generally works. For this reason the existence of the set_buswidth callback is used to determine whether we are able to do autodetection or not. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand_base: add ONFI flash detectionEric Bénard2012-07-051-25/+149
| | | | | | | | | | the code is taken from linux & u-boot implementations Validated on an i.MX53 which gives the following log : ONFI flash detected ... ONFI param page 0 valid NAND device: Manufacturer ID: 0x2c, Chip ID: 0x38 (Micron MT29F8G08ABABAWP), page size: 4096, OOB size: 224 Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/mtd: transfer NAND notions to MTD coreRobert Jarzmik2011-12-221-7/+7
| | | | | | | | | | | | | Change NAND_WRITE into MTD_WRITE. Change "page_shift" references in the core, which are purely NAND, into mtd->writesize which is MTD generic. Rename all "info" (struct mtd_info) into "mtd". Also provide a parameter to add_mtd_device() so that legacy nand devices still appear as nand<N>. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: base: Improve error reporting if reading NAND-ID failsWolfram Sang2011-11-291-3/+5
| | | | | | | | | - use KERN_ERR for messages when NAND-ID detection fails - report the IDs also if not found - print the errno if nand_scan failed Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* introduce io.hSascha Hauer2011-09-221-1/+1
| | | | | | | To allow for some generic io accessors introduce io.h and use this instead of asm/io.h throughout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: nand_block_markbad is only used with nand write supportSascha Hauer2011-04-121-21/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: make reading oob optionalSascha Hauer2011-04-111-1/+8
| | | | | | | The nand oob functions occupy quite some binary space. If not needed, we can save this space by making this configurable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: make bbt support optionalSascha Hauer2011-04-041-3/+10
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: Make different ecc modes optionalSascha Hauer2011-04-041-4/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>