aboutsummaryrefslogtreecommitdiff
path: root/include/linux/mtd/nand.h
AgeCommit message (Collapse)AuthorFilesLines
2017-01-30mtd: nand: fix nand.h kernel-doc warningsRandy Dunlap1-1/+2
Fix kernel-doc warnings in <linux/mtd/nand.h>: ..//include/linux/mtd/nand.h:658: warning: No description found for parameter 'tCEH_min' ..//include/linux/mtd/nand.h:877: warning: No description found for parameter 'data_interface' Fixes: eee64b700e26 ("mtd: nand: Introduce nand_data_interface") Signed-off-by: Randy Dunlap <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-11-29Merge tag 'nand/for-4.10' of github.com:linux-nand/linuxBrian Norris1-0/+30
From Boris Brezillon: """ This pull request contains the following notable changes: - new tango NAND controller driver - new ox820 NAND controller driver - addition of a new full-ID entry in the nand_ids table - rework of the s3c240 driver to support DT - extension of the nand_sdr_timings to expose tCCS, tPROG and tR - addition of a new flag to ask the core to wait for tCCS when sending a RNDIN/RNDOUT command - addition of a new flag to ask the core to let the controller driver send the READ/PROGPAGE command This pull request also contains minor fixes/cleanup/cosmetic changes: - properly support 512 ECC step size in the sunxi driver - improve the error messages in the pxa probe path - fix module autoload in the omap2 driver - cleanup of several nand drivers to return nand_scan{_tail}() error code instead of returning -EIO - various cleanups in the denali driver - cleanups in the ooblayout handling (MTD core) - fix an error check in nandsim """
2016-11-19mtd: nand: Support controllers with custom pageMarc Gonzalez1-0/+12
If your controller already sends the required NAND commands when reading or writing a page, then the framework is not supposed to send READ0 and SEQIN/PAGEPROG respectively. Signed-off-by: Marc Gonzalez <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-11-07mtd: nand: Wait tCCS after a column changeBoris Brezillon1-0/+10
Drivers implementing ->cmd_ctrl() and relying on the default ->cmdfunc() implementation usually don't wait tCCS when a column change (RNDIN or RNDOUT) is requested. Add an option flag to ask the core to do so (note that we keep this as an opt-in to avoid breaking existing implementations), and make use of the ->data_interface information is available (otherwise, wait 500ns). Signed-off-by: Boris Brezillon <[email protected]> Tested-by: Marc Gonzalez <[email protected]>
2016-11-07mtd: nand: Add a few more timings to nand_sdr_timingsBoris Brezillon1-0/+8
Add the tR_max, tBERS_max, tPROG_max and tCCS_min timings to the nand_sdr_timings struct. Assign default/safe values for the statically defined timings, and extract them from the ONFI parameter table if the NAND is ONFI compliant. Signed-off-by: Boris Brezillon <[email protected]> Tested-by: Marc Gonzalez <[email protected]>
2016-10-28mtd: nand: Fix data interface configuration logicBoris Brezillon1-1/+1
When changing from one data interface setting to another, one has to ensure a specific sequence which is described in the ONFI spec. One of these constraints is that the CE line has go high after a reset before a command can be sent with the new data interface setting, which is not guaranteed by the current implementation. Rework the nand_reset() function and all the call sites to make sure the CE line is asserted and released when required. Also make sure to actually apply the new data interface setting on the first die. Signed-off-by: Boris Brezillon <[email protected]> Fixes: d8e725dd8311 ("mtd: nand: automate NAND timings selection") Reviewed-by: Sascha Hauer <[email protected]> Tested-by: Marc Gonzalez <[email protected]>
2016-09-23mtd: nand: Provide nand_cleanup() function to free NAND related resourcesRichard Weinberger1-1/+4
Provide a nand_cleanup() function to free all nand related resources without unregistering the mtd device. This should allow drivers to call mtd_device_unregister() and handle its return value and still being able to cleanup all nand related resources. Signed-off-by: Richard Weinberger <[email protected]> Signed-off-by: Daniel Walter <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-09-23mtd: nand: Add an option to maximize the ECC strengthBoris Brezillon1-0/+1
The generic NAND DT bindings allows one to tweak the ECC strength and step size to their need. It can be used to lower the ECC strength to match a bootloader/firmware config, but might also be used to get a better reliability. In the latter case, the user might want to use the maximum ECC strength without having to explicitly calculate the exact value (this value not only depends on the OOB size, but also on the NAND controller, and can be tricky to extract). Add a generic 'nand-ecc-maximize' DT property and the associated NAND_ECC_MAXIMIZE flag, to let ECC controller drivers select the best ECC strength and step-size on their own. Signed-off-by: Boris Brezillon <[email protected]> Acked-by: Rob Herring <[email protected]>
2016-09-23mtd: nand: automate NAND timings selectionBoris Brezillon1-4/+10
The NAND framework provides several helpers to query timing modes supported by a NAND chip, but this implies that all NAND controller drivers have to implement the same timings selection dance. Also currently NAND devices can be resetted at arbitrary places which also resets the timing for ONFI chips to timing mode 0. Provide a common logic to select the best timings based on ONFI or ->onfi_timing_mode_default information. Hook this into nand_reset() to make sure the new timing is applied each time during a reset. NAND controller willing to support timings adjustment should just implement the ->setup_data_interface() method. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Sascha Hauer <[email protected]>
2016-09-23mtd: nand: Expose data interface for ONFI mode 0Sascha Hauer1-0/+2
The nand layer will need ONFI mode 0 to use it as timing mode before and right after reset. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-09-23mtd: nand: Add function to convert ONFI mode to data_interfaceSascha Hauer1-0/+5
onfi_init_data_interface() initializes a data interface with values from a given ONFI mode. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-09-23mtd: nand: Introduce nand_data_interfaceSascha Hauer1-49/+117
Currently we have no data structure to fully describe a NAND timing. We only have struct nand_sdr_timings for NAND timings in SDR mode, but nothing for DDR mode and also no container to store both types of timing. This patch adds struct nand_data_interface which stores the timing type and a union of different timings. This can be used to pass to drivers in order to configure the timing. Add kerneldoc for struct nand_sdr_timings while touching it anyway. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-09-23mtd: nand: Create a NAND reset functionSascha Hauer1-0/+4
When NAND devices are resetted some initialization may have to be done, like for example they have to be configured for the timing mode that shall be used. To get a common place where this initialization can be implemented create a nand_reset() function. This currently only issues a NAND_CMD_RESET to the NAND device. The places issuing this command manually are replaced with a call to nand_reset(). Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-09-23mtd: nand: remove unnecessary 'extern' from function declarationsSascha Hauer1-15/+15
'extern' is not necessary for function declarations. To prevent people from adding the keyword to new declarations remove the existing ones. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-09-23mtd: nand: import nand_hw_control_init()Marc Gonzalez1-0/+7
The code to initialize a struct nand_hw_control is duplicated across several drivers. Factorize it using an inline function. Signed-off-by: Marc Gonzalez <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-06-09mtd: nand: add ESMT manufacturerRafał Miłecki1-0/+1
I got device with ESMT (Elite Semiconductor Memory Technology Inc) F59L1G81MA flash that was detected as: [ 0.852034] nand: device found, Manufacturer ID: 0xc8, Chip ID: 0xd1 [ 0.858402] nand: Unknown NAND 128MiB 3,3V 8-bit [ 0.863031] nand: 128MiB, SLC, page size: 2048, OOB size: 64 According to the F59L1G81MA datasheet (and Read Id documentation) C8h is a "Maker Code" which should mean ESMT. Add it to fix above "Unknown". Signed-off-by: Rafał Miłecki <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-05-05mtd: mtd: drop NAND_ECC_SOFT_BCH enum valueRafał Miłecki1-1/+0
This value should not be part of nand_ecc_modes_t as it specifies algorithm not a mode. We successfully managed to introduce new "algo" field which is respected now. Signed-off-by: Rafał Miłecki <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-05-05mtd: nand: kill the ecc->layout fieldBoris Brezillon1-2/+0
Now that all NAND drivers have switched to mtd_ooblayout_ops, we can kill the ecc->layout field. Signed-off-by: Boris Brezillon <[email protected]>
2016-04-19mtd: nand: implement the default mtd_ooblayout_opsBoris Brezillon1-0/+3
Replace the default nand_ecclayout definitions for large and small page devices with the equivalent mtd_ooblayout_ops. Signed-off-by: Boris Brezillon <[email protected]>
2016-04-19mtd: nand: export default read/write oob functionsBoris Brezillon1-0/+14
Export the default read/write oob functions (for the standard and syndrome scheme), so that drivers can use them for their raw implementation and implement their own functions for the normal oob operation. This is required if your ECC engine is capable of fixing some of the OOB data. In this case you have to overload the ->read_oob() and ->write_oob(), but if you don't specify the ->read/write_oob_raw() functions they are assigned to the ->read/write_oob() implementation, which is not what you want. Signed-off-by: Boris Brezillon <[email protected]>
2016-04-19mtd: nand: add new enum for storing ECC algorithmRafał Miłecki1-0/+8
Our nand_ecc_modes_t is already a bit abused by value NAND_ECC_SOFT_BCH. This enum should store ECC mode only and putting algorithm details there is a bad idea. It would result in too many values impossible to support in a sane way. To solve this problem let's add a new enum. We'll have to modify all drivers to set it properly but once it's done it'll be possible to drop NAND_ECC_SOFT_BCH. That will result in a cleaner design and more possibilities like setting ECC algorithm for hardware ECC mode. Signed-off-by: Rafał Miłecki <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
2016-03-10mtd: nand: don't select chip in nand_chip's block_bad opArchit Taneja1-1/+1
One of the arguments passed to struct nand_chip's block_bad op is 'getchip', which, if true, is supposed to get and select the nand device, and later unselect and release the device. This op is intended to be replaceable by drivers. The drivers shouldn't be responsible for selecting/unselecting chip. Like other ops, the chip should already be selected before the block_bad op is called. Remove the getchip argument from the block_bad op and nand_block_checkbad. Move the chip selection to nand_block_isbad, since it is the only caller to nand_block_checkbad which requires chip selection. Modify nand_block_bad (the default function for the op) such that it doesn't select the chip. Remove the getchip argument from the bad_block funcs in cafe_nand, diskonchip and docg4 drivers. Reviewed-by: Boris Brezillon <[email protected]> Signed-off-by: Archit Taneja <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2016-01-26mtd: nand: kill unused ->ecclayout field in platform_nand_chip structBoris BREZILLON1-2/+0
This field is not set in any board file and can thus be dropped. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2016-01-22mtd: nand: add NAND_NEED_SCRAMBLING option flagBoris BREZILLON1-0/+6
Some MLC NANDs are sensitive to repeated patterns and require data to be scrambled in order to limit the number of bitflips. Add a new flag to let the NAND controller know about this constraint. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2016-01-07mtd: nand: add helpers to access ->privBoris BREZILLON1-0/+10
Add two helpers to access the field reserved for private controller data. This makes it clearer what this field is reserved for and ease future refactoring. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2016-01-06mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functionsBoris BREZILLON1-0/+10
The default NAND read functions are relying on the underlying controller driver to correct bitflips, but some of those controllers cannot properly fix bitflips in erased pages. Check for bitflips in erased pages in default core functions if the driver delegated the this check by setting the NAND_ECC_GENERIC_ERASED_CHECK flag. Signed-off-by: Boris Brezillon <[email protected]> Tested-by: Franklin S Cooper Jr. <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2016-01-06mtd: nand: return consistent error codes in ecc.correct() implementationsBoris BREZILLON1-1/+7
The error code returned by the ecc.correct() are not consistent over the all implementations. Document the expected behavior in include/linux/mtd/nand.h and fix offending implementations. [Brian: this looks like a bugfix for the ECC reporting in the bf5xx_nand driver, but we haven't seen any testing results for it] Signed-off-by: Boris Brezillon <[email protected]> Tested-by: Franklin S Cooper Jr. <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-12-18mtd: nand: remove unused and buggy get_platform_nandchip() helper functionBoris BREZILLON1-9/+0
Nobody uses the get_platform_nandchip() helper function which is supposed to return a pointer to a platform_nand_chip struct from an mtd_info pointer. Moreover, this function is buggy since the introduction of the plat_nand layer (chip->priv is now storing a pointer to an intermediate plat_nand_data structure allocated in plat_nand_probe(), and we have no way to retrieve a pointer to the provided platform_nand_chip struct from this plat_nand_data pointer). While we are at it, remove the useless (and buggy, since it's pointing to something stored on the stack) data->chip.priv assignment. Signed-off-by: Boris Brezillon <[email protected]> Fixes: 711fdf627ce1 ("[MTD] [NAND] platform NAND driver: add driver") Cc: Vitaly Wool <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-12-18mtd: nand: kill the chip->flash_node fieldBoris BREZILLON1-5/+2
Now that the nand_chip struct directly embeds an mtd_info struct we can get rid of the ->flash_node field and forward set/get_flash_node requests to the MTD layer. As a side effect, we no longer need the mtd_set_of_node() call done in nand_dt_init(). Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-12-18mtd: nand: update mtd_to_nand()Boris BREZILLON1-1/+1
Now that all drivers are using the mtd instance embedded in the nand_chip struct we can safely update the mtd_to_nand() implementation to use the container_of macro instead of returning the content of mtd->priv. This will allow us to remove mtd->priv = chip assignments done in all NAND controller drivers. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-12-08mtd: nand: add nand_to_mtd() helperBoris BREZILLON1-0/+5
Add a new helper to retrieve the MTD device attached to a NAND chip. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-12-08mtd: nand: embed an mtd_info structure into nand_chipBoris BREZILLON1-0/+2
Currently all NAND controller drivers are providing both the mtd_info and nand_chip struct and then let the NAND subsystem to initialize a few things before registering the mtd instance to the MTD layer. Embed an mtd_info field into nand_chip to add some consistency to all NAND controller drivers. This change will also help factorizing boilerplate code copied in all NAND drivers. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-12-01mtd: nand: fix typo (t_ald -> t_adl)Brian Norris1-2/+2
It's "ADL" ("ALE to data loading" time) not "ALD". Signed-off-by: Brian Norris <[email protected]> Reviewed-by: Boris Brezillon <[email protected]>
2015-12-01mtd: nand: fix ONFI parameter page layoutBoris BREZILLON1-2/+2
src_ssync_features field is only 1 byte large, and the 4th reserved area is actually 8 bytes large. Fixes: d1e1f4e42b5 ("mtd: nand: add support for reading ONFI parameters from NAND device") Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-11-19mtd: merge in mtd_to_nand() branchBrian Norris1-0/+5
In case other subsystems want to merge in this helper for use in their drivers, let's bring in that development separately from the rest of MTD -next development. Signed-off-by: Brian Norris <[email protected]>
2015-11-19mtd: nand: add an mtd_to_nand() helperBoris BREZILLON1-0/+5
Some drivers are retrieving the nand_chip pointer using the container_of macro on a struct wrapping both the nand_chip and the mtd_info struct while the standard way of retrieving this pointer is through mtd->priv. Provide an helper to do that. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-11-11mtd: add get/set of_node/flash_node helpersBrian Norris1-0/+11
We are going to begin using the mtd->dev.of_node field for MTD device nodes, so let's add helpers for it. Also, we'll be making some conversions on spi_nor (and nand_chip eventually) too, so get that ready with their own helpers. Signed-off-by: Brian Norris <[email protected]> Reviewed-by: Boris Brezillon <[email protected]>
2015-10-13mtd: nand: pass page number to ecc->write_xxx() methodsBoris BREZILLON1-3/+3
The ->read_xxx() methods are all passed the page number the NAND controller is supposed to read, but ->write_xxx() do not have such a parameter. This is a problem if we want to properly implement data scrambling/randomization in order to mitigate MLC sensibility to repeated pattern: to prevent bitflips in adjacent pages in the same block we need to avoid repeating the same pattern at the same offset in those pages, hence the randomizer/scrambler engine need to be passed the page value in order to adapt its seed accordingly. Moreover, adding the page parameter to the ->write_xxx() methods add some consistency to the current API. Signed-off-by: Boris Brezillon <[email protected]> CC: Josh Wu <[email protected]> CC: Ezequiel Garcia <[email protected]> CC: Maxime Ripard <[email protected]> CC: Greg Kroah-Hartman <[email protected]> CC: Huang Shijie <[email protected]> CC: Stefan Agner <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] Signed-off-by: Brian Norris <[email protected]>
2015-10-01mtd: nand: remove unused ->init_size() hookBoris BREZILLON1-6/+0
The ->init_size() hook was introduced to let NAND controller drivers support NAND devices that could not be described in the nand_ids table. Since then, the core has added support for extended-id parsing and full-id description, thus allowing to describe pretty much all existing NANDs. Moreover, this hook is not used by any mainline driver, and should not be used by new drivers, because detecting the NAND chip is not something controller specific. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-09-21mtd: nand: add nand_check_erased helper functionsBoris BREZILLON1-0/+5
Add two helper functions to help NAND controller drivers test whether a specific NAND region is erased or not. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-09-11mtd: nand: Rename nand_chip .dn to .flash_nodeMarek Vasut1-2/+2
Use a more descriptive name for the device_node element in struct nand_chip . This name matches the element name used for device_node property of a flash in the spi-nor framework. Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-07-07mtd: nand: Fix NAND_USE_BOUNCE_BUFFER flag conflictScott Wood1-5/+5
Commit 66507c7bc8895f0da6b ("mtd: nand: Add support to use nand_base poi databuf as bounce buffer") added a flag NAND_USE_BOUNCE_BUFFER using the same bit value as the existing NAND_BUSWIDTH_AUTO. Cc: Kamal Dasu <[email protected]> Fixes: 66507c7bc8895f0da6b ("mtd: nand: Add support to use nand_base poi databuf as bounce buffer") Signed-off-by: Scott Wood <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2015-05-11mtd: nand: add common DT init codeBrian Norris1-0/+5
These are already-documented common bindings for NAND chips. Let's handle them in nand_base. If NAND controller drivers need to act on this data before bringing up the NAND chip (e.g., fill out ECC callback functions, change HW modes, etc.), then they can do so between calling nand_scan_ident() and nand_scan_tail(). Signed-off-by: Brian Norris <[email protected]>
2015-05-06mtd: nand_bbt: make nand_scan_bbt() staticBrian Norris1-1/+0
This implementation detail is no longer needed outside of nand_bbt.c. Signed-off-by: Brian Norris <[email protected]>
2014-11-25mtd: nand: add ATO manufacturer infoBrian Norris1-0/+1
Tested with ATO AFND1G08U3, 128MiB NAND. Signed-off-by: Brian Norris <[email protected]>
2014-11-20mtd: nand: provide detailed description for raw read/write page methodsBoris BREZILLON1-2/+15
read_page_raw and write_page_raw method description is not clear enough. It clearly specifies that ECC correction should not be involved but does not talk about specific layout (by layout I mean where in-band and out-of-band data are stored on the NAND media) used by NAND/ECC controllers. Those specific layouts might impact MTD users and thus should be hidden (as already done in the standard NAND_ECC_HW_SYNDROME implementation). Clearly state this constraint in the nand_ecc_ctrl struct documentation. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2014-09-22mtd: nand: support ONFI timing mode retrieval for non-ONFI NANDsBoris BREZILLON1-0/+11
Add an onfi_timing_mode_default field to nand_chip and nand_flash_dev in order to support NAND timings definition for non-ONFI NAND. NAND that support better timings mode than the default one have to define a new entry in the nand_ids table. The default timing mode should be deduced from timings description from the datasheet and the ONFI specification (www.onfi.org/~/media/ONFI/specs/onfi_3_1_spec.pdf, chapter 4.15 "Timing Parameters"). You should choose the closest mode that fit the timings requirements of your NAND chip. Signed-off-by: Boris BREZILLON <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2014-08-19Merge l2-mtd/next into l2-mtd/masterBrian Norris1-0/+1
2014-08-19mtd: nand: fix DocBook warnings on nand_sdr_timings docBoris BREZILLON1-1/+1
Change the comment type (from /** to /*) to prevent DocBook from complaining about missing description for nand_sdr_timings fields. There is currently no need in documenting those fields because they are fully described in the ONFI specification (which is pointed out in the comment). Signed-off-by: Boris BREZILLON <[email protected]> Reported-by: Randy Dunlap <[email protected]> Acked-by: Randy Dunlap <[email protected]> Tested-by: Randy Dunlap <[email protected]> Signed-off-by: Brian Norris <[email protected]>
2014-08-19mtd: fix linux/mtd/nand.h kernel-doc warningRandy Dunlap1-0/+1
Fix kernel-doc warning in <linux/mtd/nand.h>: Warning(..//include/linux/mtd/nand.h:795): No description found for parameter 'ecc' Signed-off-by: Randy Dunlap <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Brian Norris <[email protected]> Cc: [email protected] Signed-off-by: Brian Norris <[email protected]>