summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand: move function hooks to struct nand_legacySascha Hauer2020-11-091-213/+213
| | | | | | | Linux had moved the traditional nand function hooks to an extra struct nand_legacy. Do the same in barebox for compatibility. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: rename class_dev to devSascha Hauer2020-11-091-6/+6
| | | | | | | | The mtds own device is named 'dev' in the Kernel whereas it's named 'class_dev' in barebox. Rename it to 'dev' for better compatilibility to the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Add underscore prefix to mtd hooksSascha Hauer2020-11-061-11/+11
| | | | | | | In the Kernel the mtd function hooks begin with an underscore. Do the same in barebox to be better comparable to the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Pass struct nand_chip aroundSascha Hauer2020-11-061-414/+392
| | | | | | | | | Traditionally Linux passed a struct mtd_info * around as context between the different functions. This has been changed to a struct nand_chip *. Do the same for barebox as well as another step towards updating the NAND layer to current Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: drop unused errstat hookSascha Hauer2020-11-061-15/+0
| | | | | | chip->errstat is never set by any driver, so remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: drop unused erase_cmd hookSascha Hauer2020-11-061-2/+1
| | | | | | chip->erase_cmd is never used, so remove this hook. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Drop asynchronous erase supportSascha Hauer2020-11-061-14/+5
| | | | | | | asynchronous erase support is unused and also dropped from the Kernel, so remove it from barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: base: fix use of uninitialized struct memberAhmad Fatoum2020-06-031-0/+1
| | | | | | | | | | | ooblen is read in nand_do_read_ops, despite never having been assigned a value. Because ooblen is used to indicate how many bytes of oobbuf are usable and oobbuf is NULL, use 0 as initial value. Found on ARCH=sandbox using clang-analyzer. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: don't call BBT functions if BBT support isn't builtLucas Stach2019-12-021-2/+2
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Add and use static inline wrapper for getting nand_chip from mtdSascha Hauer2019-08-261-36/+36
| | | | | | | | | All drivers in tree use mtd->priv for the nand_chip. Add and use a static inline wrapper mtd_to_nand() which we already have in the kernel for getting the nand_chip from the mtd_info struct. Next step would be to embed a struct mtd_info into struct nand_chip. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd-gpmi-nand'Sascha Hauer2019-08-151-0/+27
|\
| * mtd: nand: Add function to parse device tree propertiesSascha Hauer2019-08-061-0/+27
| | | | | | | | | | | | | | This adds nand_of_parse_node() which can be used to parse generic NAND device properties. Not very complete yet, but it's a start. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: Add ecc parameters as device parametersSascha Hauer2019-07-181-0/+4
|/ | | | | | | The ecc strength/bytes/size values are useful informations sometimes, add them as device parameters. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "mtd: nand: Kill the chip->scan_bbt() hook"Sascha Hauer2019-01-211-1/+5
| | | | This reverts commit 95ce69795506293eae28d6e64055d2c7ae27f164.
* 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>