Introduce the generic ECC engine abstraction
Subsystems (31)
Miquel Raynal
maintainerv7 cover Introduce the generic ECC engine abstraction
As of today, only raw NAND controllers used to feature an integrated ECC engine and so controller drivers always embedded some code to enable/disable the correction.
This statement is no longer correct as SPI-NAND devices might not embed an on-die ECC engine and must make use of an external ECC engine. We figured there are three possible situations for (generic) NAND devices: either the engine is 'on-die' (most of the SPI-NANDs, a few raw NANDs), or the engine is part of the host controller (most raw NANDs), or the engine may be external (SPI controllers might feature an hardware ECC engine, otherwise software correction can also be used).
To solve this situation, I already proposed the creation of an ECC engine abstraction (still work in progress) and this is the first step for that.
The logic in this series is:
1/ Use the generic NAND core for all NAND devices (raw and SPI). 2/ Create the ECC engine interface in drivers/mtd/nand/ecc.c 3/ Move code in driver/mtd/nand/ecc.c
Later, I will repost:
4/ Make both software engines (Hamming and BCH) generic, move them in
the ecc/ directory, clean them a bit and instantiate ECC engines. Write raw NAND helpers to use these two new engines.
5/ Isolate SPI-NAND on-die ECC engine in its own driver.
6/ Make use from the SPI-NAND layer of all the ECC engines listed
above (on user request, people can now make use of soft BCH if they don't have an ECC-engine).
7/ Extend the logic to hardware external engines. A proposal of a
driver for Macronix external ECC engine will follow in another series.
This work is now almost ready, the next steps will be:
1/ Migrate the raw NAND core to make a proper use of these ECC
engines.
2/ Deprecate in the raw NAND subsystem the interfaces used until now
(I expect we should get rid of a lot of boilerplate).
Thanks,
Miquèl
Changes in v7
=============
* Collected tags.
* Fixed subjects s/OOB placement/ECC bytes placement/.
* Moved a tab change into space to the appropriate patch.
* Moved the removal of the nand_ecc_mode public enumumeration to the right patch.
* Created helpers to retrieve the OOB layouts.
* Moved the "flags" entry of nand_ecc_props to the commit using it.
* Changed the select MTD_NAND_CORE into a depends on and moved it to the right patch too.
* Split the patch moving raw NAND bits into the ECC framework.
* Dropped an extra helper: nanddev_get_flash_node().
* Updated all the ECC framework introductory comment, following Boris' suggestions.
Changes in v6
=============
* Rebased on top of nand/next.
* Dropped the new nand-ecc-provider property. Instead, we will use nand-ecc-engine and boolean properties like nand-no-ecc-engine / nand-use-soft-ecc-engine (will be added in another series).
* Moved most of the bindings to the next series.
* Used platform_dev_put() instead of of_dev_put() on Rob's advice.
* Renamed objects: ondie -> on_die_hw.
* Renamed objects: hw -> on_host_hw.
* Used engine_type everywhere instead of provider.
* Created a rawnand compatibility layer to avoid moving deprecated code due to the rawnand core history in the generic (and clean) NAND layer.
* Enhanced the nand_ecc_algo enumeration.
Changes in v5
=============
* Rebased on top of nand/next
* Avoided a fallthrough situation in commit:
mtd: rawnand: Separate the ECC engine type and the OOB placement
* Fixed an of_dev_put() build issue due to a missing dummy helper.
* Extracted a patch that deserved to be merged quickly.
* Fixed a few issues reported by robots.
Changes in v4
=============
* Rebased on top of a recent kernel version.
* Added Boris' reviewed-by.
* Added Maxime's Acked-by tag.
* Added the missing of_device.h header to ecc.c.
* Corrected a 'minimum' comparison by using min_t.
* Updated the new Macronix raw NAND controller driver by using the new (ECC related) function names.
* Fixed a function call in ndfc.c.
* Update brcmnand.c file to fit new enumerations and structures (due to recent Kamal's changes).
* Force sm_ftl to depends on the Hamming engine, because by just selecting it the ECC code would be embedded in the NAND core and the NAND core might not be compiled in with sm_ftl.
* Fixed a structure field name that I previously added in davinci platform data.
* Moved the oob_first placement scheme to Davinci driver. Removed any occurence of it out of the driver (unused).
* Simplify structure names as proposed by Boris.
* Change enumeration/string names about ECC engine providers/placements.
* Change the logic in the of_get_nand_ecc_* helpers to ensure backward compatibility.
* Use enums intead of unsigned integers in the core when referring to ECC engine type, placement and algorithm.
* Add nand-ecc-placement DT property.
* Deprecate hw_syndrome.
* Deprecate nand-ecc-mode in favor of nand-ecc-provider.
* Fixed a typo in the Macronix ECC driver, where I made a copy/paste error which I haven't spotted because it is located in a macro only compiled when building the driver as a module (name of the of_ids was prefixed marvell_nfc instead of mxic_ecc).
* Simplified the ECC engine API by dropping the useless oobbuf parameter. Instead, ECC engine drivers are supposed to provide a spare OOB buffer if none is provided. Updated the three existing engines.
* Fixed BCH software engine with the help of Mason from Macronix.
* Added a mechanism called "tweaking req" to change the SPI-NAND requests and ensure they always contain the right amount of data/OOB needed for the ECC engine to work properly.
Changes in v3
=============
* Added Boris' Reviewed-by tags.
* Added a kernel doc header on the nand_page_io_req enumeration.
* Added support for HW engines.
* Droped the patch clarifying the value of the first entry in enumerations (which is always 0).
* Rename the nand_ecc_conf structure as nand_ecc_props because the _conf suffix implies that it is possible to edit it, while in some cases (eg. on-die ECC) there is nothing to tweak.
* Smoother introduction of the ECC engine abstraction.
* Renamed the ECC engine module nand_ecc_engine.ko.
* Moved all the ECC files into drivers/mtd/nand/. Forgot the ecc/ subdirectory.
* Added a new series to drop the ECC mode enumeration wich mixes the provider (none, hw, sw, on-die) and the OOB placement (first, syndrome).
* Various typos fixed.
* Added a few patches to fix bugs found in SPI-NAND/mtdchar.c.
* Introduced the external hardware ECC engine boilerplate.
Changes in v2
=============
* SPDX license identifiers for soft BCH and Hamming: the license macro was right, "GPL" means "GPLv2 or higher", so do not change this portion. Also update the commit messages to fit the actual change.
* Do not compile-in the NAND core by default, do it only for raw NAND. Remove the dependencies on CONFIG_MTD in a different patch. Also, keep an extra level of hierarchy in Kconfig for the NAND bits by adding a menu instead of a config.
* Moved the standard OOB layouts in the ecc/engine.c driver instead of in the NAND core.
* Used the nand_ecc_ prefix in most of the engines functions instead of just ecc_, which is now reserved for bare helpers. Get rid of the __ecc prefix.
* In the sunxi NAND controller driver: moved the ECC structure from sunxi_nfc to sunxi_nand_chip as the ECC engine is per-chip and not per controller.
* Software Hamming ECC engine is only enabled by default if raw NAND is also enabled. NDFC now selects the software Hamming ECC engine (instead of depending on it).
* Mention in software BCH and Hamming Kconfig entries that booting from NAND is very likely to fail if the user selects these symbols as modules.
* Added Boris Reviewed-by tag on the SPI-NAND typo fixing patch.
* Renamed the "mode" into a "provider" entry in the ECC configuration structures.
* Moved the "total" entry of the ECC configuration directly in the context structure (should probably not be public but let's keep it as is for now).
* Split the generic ECC engine introduction into smaller patches to do some renaming aside.
* Drop the "maximize" entry in the ECC engine configuration structure, keep using a flag like before.
* Canceled the move of the SPI-NAND specific ECC engine out of the core file.
* Amended the root ECC structures to have three nand_ecc_conf
structures: one for the defaults, one for the chip requirements, one for the user desires.
* Created a *ondie_engine pointer in the nand_ecc structure to save the on-die ECC engine, if any. For instance, saving a reference to this engine is done by the SPI-NAND core.
* Dropped the SPI-NAND flag that was used to distinguish between NAND flavors from the NAND core, it should not be needed anymore.
* Added an helper in the NAND core to put a reference on an ECC engine. This will be used by the hardware engines only.
* Renamed the files ecc/sw-{bch,hamming}.c and their headers include/linux/mtd/nand-ecc-sw-{bch,hamming}-engine.h.
* Created a MTD_NAND_ECC invisible Kconfig symbol.
* Added plenty of missing EXPORT_SYMBOL{,_GPL}().
* Minor modifications so that everything still compiles even when modules and built-in drivers are mixed in Kconfig in the whole NAND directory.
Miquel Raynal (20):
dt-bindings: mtd: Document nand-ecc-placement
mtd: rawnand: Create a new enumeration to describe ECC bytes placement
mtd: rawnand: Separate the ECC engine type and the ECC byte placement
mtd: rawnand: Create a helper to retrieve the ECC placement
mtd: rawnand: Add a kernel doc to the ECC algorithm enumeration
mtd: rawnand: Rename the ECC algorithm enumeration items
mtd: rawnand: Create a new enumeration to describe properly ECC types
mtd: rawnand: Use the new ECC engine type enumeration
mtd: nand: Move nand_device forward declaration to the top
mtd: nand: Add an extra level in the Kconfig hierarchy
mtd: nand: Drop useless 'depends on' in Kconfig
mtd: nand: Add a NAND page I/O request type
mtd: nand: Rename a core structure
mtd: nand: Add more parameters to the nand_ecc_props structure
mtd: nand: Introduce the ECC engine abstraction
mtd: nand: Convert generic NAND bits to use the ECC framework
mtd: rawnand: Hide the generic OOB layout objects behind helpers
mtd: rawnand: Write a compatibility layer
mtd: rawnand: Move generic OOB layouts to the ECC framework
mtd: rawnand: Move the user input parsing bits to the ECC framework
.../bindings/mtd/nand-controller.yaml | 10 + arch/arm/mach-davinci/board-da830-evm.c | 2 +- arch/arm/mach-davinci/board-da850-evm.c | 2 +- arch/arm/mach-davinci/board-dm355-evm.c | 2 +- arch/arm/mach-davinci/board-dm355-leopard.c | 3 +- arch/arm/mach-davinci/board-dm365-evm.c | 2 +- arch/arm/mach-davinci/board-dm644x-evm.c | 2 +- arch/arm/mach-davinci/board-dm646x-evm.c | 2 +- arch/arm/mach-davinci/board-mityomapl138.c | 2 +- arch/arm/mach-davinci/board-neuros-osd2.c | 2 +- arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +- arch/arm/mach-s3c24xx/common-smdk.c | 2 +- arch/arm/mach-s3c24xx/mach-anubis.c | 2 +- arch/arm/mach-s3c24xx/mach-at2440evb.c | 2 +- arch/arm/mach-s3c24xx/mach-bast.c | 2 +- arch/arm/mach-s3c24xx/mach-gta02.c | 2 +- arch/arm/mach-s3c24xx/mach-jive.c | 2 +- arch/arm/mach-s3c24xx/mach-mini2440.c | 2 +- arch/arm/mach-s3c24xx/mach-osiris.c | 2 +- arch/arm/mach-s3c24xx/mach-qt2410.c | 2 +- arch/arm/mach-s3c24xx/mach-rx1950.c | 2 +- arch/arm/mach-s3c24xx/mach-rx3715.c | 2 +- arch/arm/mach-s3c24xx/mach-vstms.c | 2 +- arch/arm/mach-s3c64xx/mach-hmt.c | 2 +- arch/arm/mach-s3c64xx/mach-mini6410.c | 2 +- arch/arm/mach-s3c64xx/mach-real6410.c | 2 +- drivers/mtd/nand/Kconfig | 13 + drivers/mtd/nand/Makefile | 2 + drivers/mtd/nand/ecc.c | 471 +++++++++++++++ drivers/mtd/nand/onenand/Kconfig | 1 - drivers/mtd/nand/raw/Kconfig | 2 +- drivers/mtd/nand/raw/ams-delta.c | 4 +- drivers/mtd/nand/raw/arasan-nand-controller.c | 16 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 30 +- drivers/mtd/nand/raw/au1550nd.c | 4 +- .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 3 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 27 +- .../mtd/nand/raw/cadence-nand-controller.c | 4 +- drivers/mtd/nand/raw/cafe_nand.c | 3 +- drivers/mtd/nand/raw/cs553x_nand.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 38 +- drivers/mtd/nand/raw/denali.c | 6 +- drivers/mtd/nand/raw/diskonchip.c | 3 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 20 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 12 +- drivers/mtd/nand/raw/fsl_upm.c | 4 +- drivers/mtd/nand/raw/fsmc_nand.c | 14 +- drivers/mtd/nand/raw/gpio.c | 4 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 14 +- drivers/mtd/nand/raw/hisi504_nand.c | 6 +- .../mtd/nand/raw/ingenic/ingenic_nand_drv.c | 20 +- drivers/mtd/nand/raw/lpc32xx_mlc.c | 2 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 3 +- drivers/mtd/nand/raw/marvell_nand.c | 34 +- drivers/mtd/nand/raw/meson_nand.c | 2 +- drivers/mtd/nand/raw/mpc5121_nfc.c | 4 +- drivers/mtd/nand/raw/mtk_nand.c | 10 +- drivers/mtd/nand/raw/mxc_nand.c | 25 +- drivers/mtd/nand/raw/nand_base.c | 565 +++++++----------- drivers/mtd/nand/raw/nand_esmt.c | 11 +- drivers/mtd/nand/raw/nand_hynix.c | 41 +- drivers/mtd/nand/raw/nand_jedec.c | 4 +- drivers/mtd/nand/raw/nand_micron.c | 20 +- drivers/mtd/nand/raw/nand_onfi.c | 8 +- drivers/mtd/nand/raw/nand_samsung.c | 19 +- drivers/mtd/nand/raw/nand_toshiba.c | 16 +- drivers/mtd/nand/raw/nandsim.c | 8 +- drivers/mtd/nand/raw/ndfc.c | 2 +- drivers/mtd/nand/raw/omap2.c | 22 +- drivers/mtd/nand/raw/orion_nand.c | 4 +- drivers/mtd/nand/raw/pasemi_nand.c | 4 +- drivers/mtd/nand/raw/plat_nand.c | 4 +- drivers/mtd/nand/raw/qcom_nandc.c | 2 +- drivers/mtd/nand/raw/r852.c | 3 +- drivers/mtd/nand/raw/s3c2410.c | 20 +- drivers/mtd/nand/raw/sh_flctl.c | 6 +- drivers/mtd/nand/raw/sharpsl.c | 2 +- drivers/mtd/nand/raw/socrates_nand.c | 5 +- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 9 +- drivers/mtd/nand/raw/sunxi_nand.c | 26 +- drivers/mtd/nand/raw/tango_nand.c | 4 +- drivers/mtd/nand/raw/tegra_nand.c | 34 +- drivers/mtd/nand/raw/tmio_nand.c | 2 +- drivers/mtd/nand/raw/txx9ndfmc.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 6 +- drivers/mtd/nand/raw/xway_nand.c | 4 +- drivers/mtd/nand/spi/core.c | 12 +- drivers/mtd/nand/spi/macronix.c | 6 +- drivers/mtd/nand/spi/toshiba.c | 6 +- include/linux/mtd/nand.h | 164 ++++- include/linux/mtd/rawnand.h | 34 +- include/linux/mtd/spinand.h | 2 +- include/linux/platform_data/mtd-davinci.h | 9 +- .../linux/platform_data/mtd-nand-s3c2410.h | 2 +- 94 files changed, 1221 insertions(+), 731 deletions(-) create mode 100644 drivers/mtd/nand/ecc.c
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 1/20 dt-bindings: mtd: Document nand-ecc-placement
This optional property defines where the ECC bytes are expected to be stored. No value defaults to an unknown location, while these locations can be explicitly set to OOB or interleaved depending if the ECC bytes are entirely stored in the OOB area or mixed with regular data in the main area (also sometimes referred as "syndrome").
--- .../devicetree/bindings/mtd/nand-controller.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/mtd/nand-controller.yaml +10 -0
@@ -56,6 +56,16 @@ patternProperties: (Linux will handle the calculations). soft_bch is deprecated and should be replaced by soft and nand-ecc-algo. + nand-ecc-placement: + allOf: + - $ref: /schemas/types.yaml#/definitions/string + - enum: [ oob, interleaved ] + description: + Location of the ECC bytes. This location is unknown by default + but can be explicitly set to "oob", if all ECC bytes are + known to be stored in the OOB area, or "interleaved" if ECC + bytes will be interleaved with regular data in the main area. + nand-ecc-algo: allOf: - $ref: /schemas/types.yaml#/definitions/string
Signature · 1 line
2.20.1
Re: [PATCH v7 01/20] dt-bindings: mtd: Document nand-ecc-placement
Quoted 18 lines · Miquel Raynal
This optional property defines where the ECC bytes are expected to be stored. No value defaults to an unknown location, while these locations can be explicitly set to OOB or interleaved depending if the ECC bytes are entirely stored in the OOB area or mixed with regular data in the main area (also sometimes referred as "syndrome").
Signed-off-by Miquel Raynal <[email protected]>Reviewed-by Boris Brezillon <[email protected]>--- .../devicetree/bindings/mtd/nand-controller.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)Documentation/devicetree/bindings/mtd/nand-controller.yaml +0
-0
Documentation/devicetree/bindings/mtd/nand-controller.yaml patternProperties: · line 60
Quoted 5 lines
Documentation/devicetree/bindings/mtd/nand-controller.yaml +2
-0@@ -56,6 +56,16 @@ patternProperties: (Linux will handle the calculations). soft_bch is deprecated and should be replaced by soft and nand-ecc-algo. + nand-ecc-placement: + allOf:
You can drop using allOf now, but it still works as is.
Quoted 14 lines
Documentation/devicetree/bindings/mtd/nand-controller.yaml +8
-0+ - $ref: /schemas/types.yaml#/definitions/string + - enum: [ oob, interleaved ] + description: + Location of the ECC bytes. This location is unknown by default + but can be explicitly set to "oob", if all ECC bytes are + known to be stored in the OOB area, or "interleaved" if ECC + bytes will be interleaved with regular data in the main area. + nand-ecc-algo: allOf: - $ref: /schemas/types.yaml#/definitions/stringSignature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 2/20 mtd: rawnand: Create a new enumeration to describe ECC bytes placement
In reply to Miquel RaynalThere is currently a confusion between the ECC type/mode/provider (eg. on-host, software, on-die or none) and the ECC bytes placement.
Create a new enumeration to describe this placement.
--- drivers/mtd/nand/raw/nand_base.c | 5 +++++ include/linux/mtd/rawnand.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+)
drivers/mtd/nand/raw/nand_base.c +5 -0
@@ -5018,6 +5018,11 @@ static const char * const nand_ecc_modes[] = { [NAND_ECC_ON_DIE] = "on-die", }; +static const char *const nand_ecc_placement[] = { + [NAND_ECC_PLACEMENT_OOB ] ="oob" , + [NAND_ECC_PLACEMENT_INTERLEAVED ] ="interleaved" , +}; +static int of_get_nand_ecc_mode (struct device_node *np) {const char *pm;
include/linux/mtd/rawnand.h +14 -0
@@ -92,6 +92,20 @@ enum nand_ecc_mode { NAND_ECC_ON_DIE, }; +/** +* enum nand_ecc_placement - NAND ECC bytes placement +* @NAND_ECC_PLACEMENT_UNKNOWN: The actual position of the ECC bytes is unknown +* @NAND_ECC_PLACEMENT_OOB: The ECC bytes are located in the OOB area +* @NAND_ECC_PLACEMENT_INTERLEAVED: Syndrome layout, there are ECC bytes +* interleaved with regular data in the main +* area +*/ +enum nand_ecc_placement { +NAND_ECC_PLACEMENT_UNKNOWN , +NAND_ECC_PLACEMENT_OOB , +NAND_ECC_PLACEMENT_INTERLEAVED , +}; +enum nand_ecc_algo {NAND_ECC_UNKNOWN ,NAND_ECC_HAMMING ,
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 3/20 mtd: rawnand: Separate the ECC engine type and the ECC byte placement
In reply to Miquel RaynalThe use of "syndrome" placement should not be encoded in the ECC engine mode/type.
Create a "placement" field in NAND chip and change all occurrences of the NAND_ECC_HW_SYNDROME enumeration to be just NAND_ECC_HW and possibly a placement entry like NAND_ECC_PLACEMENT_INTERLEAVED.
--- arch/arm/mach-davinci/board-dm355-leopard.c | 3 +- drivers/mtd/nand/raw/cafe_nand.c | 3 +- drivers/mtd/nand/raw/davinci_nand.c | 5 +- drivers/mtd/nand/raw/denali.c | 3 +- drivers/mtd/nand/raw/diskonchip.c | 3 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 3 +- drivers/mtd/nand/raw/nand_base.c | 109 +++++++++++--------- drivers/mtd/nand/raw/r852.c | 3 +- include/linux/mtd/rawnand.h | 6 +- include/linux/platform_data/mtd-davinci.h | 1 + 10 files changed, 81 insertions(+), 58 deletions(-)
arch/arm/mach-davinci/board-dm355-leopard.c +2 -1
@@ -76,7 +76,8 @@ static struct davinci_nand_pdata davinci_nand_data = { .mask_chipsel = BIT(14), .parts = davinci_nand_partitions, .nr_parts = ARRAY_SIZE(davinci_nand_partitions), - .ecc_mode = NAND_ECC_HW_SYNDROME, + .ecc_mode = NAND_HW_ECC_ENGINE, + .ecc_placement = NAND_ECC_PLACEMENT_INTERLEAVED, .ecc_bits = 4, .bbt_options = NAND_BBT_USE_FLASH, };
drivers/mtd/nand/raw/cafe_nand.c +2 -1
@@ -629,7 +629,8 @@ static int cafe_nand_attach_chip(struct nand_chip *chip) goto out_free_dma; } - cafe->nand.ecc.mode =NAND_ECC_HW_SYNDROME ; + cafe->nand.ecc.mode =NAND_ECC_HW ; + cafe->nand.ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; cafe->nand.ecc.size = mtd->writesize; cafe->nand.ecc.bytes =14 ; cafe->nand.ecc.strength =4 ;
drivers/mtd/nand/raw/davinci_nand.c +3 -2
@@ -168,7 +168,7 @@ static int nand_davinci_correct_1bit(struct nand_chip *chip, u_char *dat,/* * 4-bit hardware ECC ... context maintained over entire AEMIF * -* This is a syndrome engine, but we avoid NAND_ECC_HW_SYNDROME +* This is a syndrome engine, but we avoid NAND_ECC_PLACEMENT_INTERLEAVED * since that forces use of a problematic "infix OOB" layout. * Among other things, it trashes manufacturer bad block markers. * Also, and specific to this hardware, it ECC-protects the "prepad"
@@ -851,6 +851,7 @@ static int nand_davinci_probe(struct platform_device *pdev)/* Use board-specific ECC config */ info->chip.ecc.mode = pdata->ecc_mode; + info->chip.ecc.placement = pdata->ecc_placement;spin_lock_irq (&davinci_nand_lock);
@@ -897,7 +898,7 @@ static int nand_davinci_remove(struct platform_device *pdev)int ret;spin_lock_irq (&davinci_nand_lock); -if (info->chip.ecc.mode ==NAND_ECC_HW_SYNDROME ) +if (info->chip.ecc.placement ==NAND_ECC_PLACEMENT_INTERLEAVED ) ecc4_busy = false;spin_unlock_irq (&davinci_nand_lock);
drivers/mtd/nand/raw/denali.c +2 -1
@@ -1237,7 +1237,8 @@ int denali_chip_init(struct denali_controller *denali, chip->bbt_options |=NAND_BBT_USE_FLASH ; chip->bbt_options |=NAND_BBT_NO_OOB ; chip->options |=NAND_NO_SUBPAGE_WRITE ; - chip->ecc.mode =NAND_ECC_HW_SYNDROME ; + chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; chip->ecc.read_page = denali_read_page; chip->ecc.write_page = denali_write_page; chip->ecc.read_page_raw = denali_read_page_raw;
drivers/mtd/nand/raw/diskonchip.c +2 -1
@@ -1456,7 +1456,8 @@ static int __init doc_probe(unsigned long physadr) nand->ecc.calculate = doc200x_calculate_ecc; nand->ecc.correct = doc200x_correct_data; - nand->ecc.mode =NAND_ECC_HW_SYNDROME ; + nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; nand->ecc.size =512 ; nand->ecc.bytes =6 ; nand->ecc.strength =2 ;
drivers/mtd/nand/raw/lpc32xx_slc.c +2 -1
@@ -881,7 +881,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)platform_set_drvdata (pdev, host);/* NAND callbacks for LPC32xx SLC hardware */ - chip->ecc.mode =NAND_ECC_HW_SYNDROME ; + chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; chip->legacy.read_byte = lpc32xx_nand_read_byte; chip->legacy.read_buf = lpc32xx_nand_read_buf; chip->legacy.write_buf = lpc32xx_nand_write_buf;
drivers/mtd/nand/raw/nand_base.c +61 -48
122 lines not on this page · raw message
drivers/mtd/nand/raw/r852.c +2 -1
@@ -859,7 +859,8 @@ static int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) chip->legacy.write_buf = r852_write_buf;/* ecc */ - chip->ecc.mode =NAND_ECC_HW_SYNDROME ; + chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; chip->ecc.size =R852_DMA_LEN ; chip->ecc.bytes =SM_OOB_SIZE ; chip->ecc.strength =2 ;
include/linux/mtd/rawnand.h +4 -2
@@ -325,6 +325,7 @@ static const struct nand_ecc_caps __name = { \/** * struct nand_ecc_ctrl - Control structure for ECC * @mode: ECC mode +* @placement: OOB bytes placement * @algo: ECC algorithm * @steps: number of ECC steps per page * @size: data bytes per ECC step
@@ -352,7 +353,7 @@ static const struct nand_ecc_caps __name = { \* controller and always return contiguous in-band and * out-of-band data even if they're not stored * contiguously on the NAND chip (e.g. -* NAND_ECC_HW_SYNDROME interleaves in-band and +* NAND_ECC_PLACEMENT_INTERLEAVED interleaves in-band and * out-of-band data). * @write_page_raw: function to write a raw page without ECC. This function * should hide the specific layout used by the ECC
@@ -360,7 +361,7 @@ static const struct nand_ecc_caps __name = { \* in-band and out-of-band data. ECC controller is * responsible for doing the appropriate transformations * to adapt to its specific layout (e.g. -* NAND_ECC_HW_SYNDROME interleaves in-band and +* NAND_ECC_PLACEMENT_INTERLEAVED interleaves in-band and * out-of-band data). * @read_page: function to read a page according to the ECC generator * requirements; returns maximum number of bitflips corrected in
@@ -377,6 +378,7 @@ static const struct nand_ecc_caps __name = { \*/ struct nand_ecc_ctrl {enum nand_ecc_mode mode; +enum nand_ecc_placement placement;enum nand_ecc_algo algo;int steps;int size;
include/linux/platform_data/mtd-davinci.h +1 -0
@@ -69,6 +69,7 @@ struct davinci_nand_pdata { /* platform_data */* using it with large page chips. */ enum nand_ecc_mode ecc_mode; +enum nand_ecc_placement ecc_placement;u8 ecc_bits;/* e.g. NAND_BUSWIDTH_16 */
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 4/20 mtd: rawnand: Create a helper to retrieve the ECC placement
In reply to Miquel RaynalUse it from nand_dt_init() to initialize the ECC structure.
This allows the deprecation of the hw_syndrome ECC mode.
--- drivers/mtd/nand/raw/nand_base.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/mtd/nand/raw/nand_base.c +29 -0
@@ -5047,6 +5047,34 @@ static int of_get_nand_ecc_mode(struct device_node *np)return -ENODEV ; } +enum nand_ecc_placement of_get_nand_ecc_placement (struct device_node *np) +{ +enum nand_ecc_placement placement; +const char *pm; +int err; + + err =of_property_read_string (np,"nand-ecc-placement" , &pm); +if (!err) { +for (placement =NAND_ECC_PLACEMENT_INTERLEAVED ; + placement <ARRAY_SIZE (nand_ecc_placement); placement++) { +if (!strcasecmp (pm, nand_ecc_placement[placement])) +return placement; + } + } + +/* +* For backward compatibility we support few obsoleted values that don't +* have their mappings into the nand_ecc_placement enum anymore. +*/ + err =of_property_read_string (np,"nand-ecc-mode" , &pm); +if (!err) { +if (!strcasecmp (pm,"hw_syndrome" )) +return NAND_ECC_PLACEMENT_INTERLEAVED ; + } + +return NAND_ECC_PLACEMENT_UNKNOWN ; +} +static const char *const nand_ecc_algos[] = { [NAND_ECC_HAMMING ] ="hamming" , [NAND_ECC_BCH ] ="bch" ,
@@ -5143,6 +5171,7 @@ static int nand_dt_init(struct nand_chip *chip) ecc_mode =of_get_nand_ecc_mode (dn); ecc_algo =of_get_nand_ecc_algo (dn); + chip->ecc.placement =of_get_nand_ecc_placement (dn); ecc_strength =of_get_nand_ecc_strength (dn); ecc_step =of_get_nand_ecc_step_size (dn);
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 5/20 mtd: rawnand: Add a kernel doc to the ECC algorithm enumeration
In reply to Miquel RaynalBefore moving it to the generic raw NAND core, ensure the enumeration is properly described.
--- include/linux/mtd/rawnand.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/linux/mtd/rawnand.h +7 -0
@@ -106,6 +106,13 @@ enum nand_ecc_placement { NAND_ECC_PLACEMENT_INTERLEAVED, }; +/** +* enum nand_ecc_algo - NAND ECC algorithm +* @NAND_ECC_UNKNOWN: Unknown algorithm +* @NAND_ECC_HAMMING: Hamming algorithm +* @NAND_ECC_BCH: Bose-Chaudhuri-Hocquenghem algorithm +* @NAND_ECC_RS: Reed-Solomon algorithm +*/ enum nand_ecc_algo {NAND_ECC_UNKNOWN ,NAND_ECC_HAMMING ,
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 6/20 mtd: rawnand: Rename the ECC algorithm enumeration items
In reply to Miquel RaynalNAND_ECC_ is not a meaningful prefix, use NAND_ECC_ALGO_ instead.
--- drivers/mtd/nand/raw/ams-delta.c | 2 +- drivers/mtd/nand/raw/arasan-nand-controller.c | 2 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- drivers/mtd/nand/raw/au1550nd.c | 2 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 ++++----- drivers/mtd/nand/raw/davinci_nand.c | 8 +++--- drivers/mtd/nand/raw/fsl_elbc_nand.c | 2 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 2 +- drivers/mtd/nand/raw/fsl_upm.c | 2 +- drivers/mtd/nand/raw/fsmc_nand.c | 2 +- drivers/mtd/nand/raw/gpio.c | 2 +- drivers/mtd/nand/raw/marvell_nand.c | 10 +++---- drivers/mtd/nand/raw/mpc5121_nfc.c | 2 +- drivers/mtd/nand/raw/mxc_nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 26 +++++++++---------- drivers/mtd/nand/raw/nand_micron.c | 2 +- drivers/mtd/nand/raw/nandsim.c | 4 +-- drivers/mtd/nand/raw/omap2.c | 2 +- drivers/mtd/nand/raw/orion_nand.c | 2 +- drivers/mtd/nand/raw/pasemi_nand.c | 2 +- drivers/mtd/nand/raw/plat_nand.c | 2 +- drivers/mtd/nand/raw/s3c2410.c | 4 +-- drivers/mtd/nand/raw/sh_flctl.c | 2 +- drivers/mtd/nand/raw/socrates_nand.c | 2 +- drivers/mtd/nand/raw/tango_nand.c | 2 +- drivers/mtd/nand/raw/tegra_nand.c | 20 +++++++------- drivers/mtd/nand/raw/xway_nand.c | 2 +- include/linux/mtd/rawnand.h | 16 ++++++------ 28 files changed, 70 insertions(+), 70 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +1 -1
@@ -261,7 +261,7 @@ static int gpio_nand_probe(struct platform_device *pdev) } this->ecc.mode =NAND_ECC_SOFT ; - this->ecc.algo =NAND_ECC_HAMMING ; + this->ecc.algo =NAND_ECC_ALGO_HAMMING ;platform_set_drvdata (pdev, priv);
drivers/mtd/nand/raw/arasan-nand-controller.c +1 -1
@@ -983,7 +983,7 @@ static int anfc_init_hw_ecc_controller(struct arasan_nfc *nfc,mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); ecc->steps = mtd->writesize / ecc->size; - ecc->algo =NAND_ECC_BCH ; + ecc->algo =NAND_ECC_ALGO_BCH ; anand->ecc_bits = bch_gf_mag * ecc->strength; ecc->bytes =DIV_ROUND_UP (anand->ecc_bits,8 ); anand->ecc_total =DIV_ROUND_UP (anand->ecc_bits * ecc->steps,8 );
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
@@ -1099,7 +1099,7 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip)if (IS_ERR (nand->pmecc))return PTR_ERR (nand->pmecc); - chip->ecc.algo =NAND_ECC_BCH ; + chip->ecc.algo =NAND_ECC_ALGO_BCH ; chip->ecc.size = req.ecc.sectorsize; chip->ecc.bytes = req.ecc.bytes / req.ecc.nsectors; chip->ecc.strength = req.ecc.strength;
drivers/mtd/nand/raw/au1550nd.c +1 -1
@@ -295,7 +295,7 @@ static int au1550nd_probe(struct platform_device *pdev) ctx->controller.ops = &au1550nd_ops; this->controller = &ctx->controller; this->ecc.mode =NAND_ECC_SOFT ; - this->ecc.algo =NAND_ECC_HAMMING ; + this->ecc.algo =NAND_ECC_ALGO_HAMMING ;if (pd->devwidth) this->options |=NAND_BUSWIDTH_16 ;
drivers/mtd/nand/raw/brcmnand/brcmnand.c +6 -6
@@ -2545,17 +2545,17 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)return -EINVAL ; } -if (chip->ecc.algo ==NAND_ECC_UNKNOWN ) { +if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) {if (chip->ecc.strength ==1 && chip->ecc.size ==512 )/* Default to Hamming for 1-bit ECC, if unspecified */ - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;else /* Otherwise, BCH */ - chip->ecc.algo =NAND_ECC_BCH ; + chip->ecc.algo =NAND_ECC_ALGO_BCH ; } -if (chip->ecc.algo ==NAND_ECC_HAMMING && (chip->ecc.strength !=1 || - chip->ecc.size !=512 )) { +if (chip->ecc.algo ==NAND_ECC_ALGO_HAMMING && + (chip->ecc.strength !=1 || chip->ecc.size !=512 )) {dev_err (ctrl->dev,"invalid Hamming params: %d bits per %d bytes\n" , chip->ecc.strength, chip->ecc.size);return -EINVAL ;
@@ -2574,7 +2574,7 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)switch (chip->ecc.size) {case 512 : -if (chip->ecc.algo ==NAND_ECC_HAMMING ) +if (chip->ecc.algo ==NAND_ECC_ALGO_HAMMING ) cfg->ecc_level =15 ;else cfg->ecc_level = chip->ecc.strength;
drivers/mtd/nand/raw/davinci_nand.c +4 -4
@@ -593,11 +593,11 @@ static int davinci_nand_attach_chip(struct nand_chip *chip) pdata->ecc_bits =0 ;/* * This driver expects Hamming based ECC when ecc_mode is set -* to NAND_ECC_SOFT. Force ecc.algo to NAND_ECC_HAMMING to +* to NAND_ECC_SOFT. Force ecc.algo to NAND_ECC_ALGO_HAMMING to * avoid adding an extra ->ecc_algo field to * davinci_nand_pdata. */ - info->chip.ecc.algo =NAND_ECC_HAMMING ; + info->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;break ;case NAND_ECC_HW :if (pdata->ecc_bits ==4 ) {
@@ -629,7 +629,7 @@ static int davinci_nand_attach_chip(struct nand_chip *chip) info->chip.ecc.hwctl = nand_davinci_hwctl_4bit; info->chip.ecc.bytes =10 ; info->chip.ecc.options =NAND_ECC_GENERIC_ERASED_CHECK ; - info->chip.ecc.algo =NAND_ECC_BCH ; + info->chip.ecc.algo =NAND_ECC_ALGO_BCH ;/* * Update ECC layout if needed ... for 1-bit HW ECC, the
@@ -656,7 +656,7 @@ static int davinci_nand_attach_chip(struct nand_chip *chip) info->chip.ecc.correct = nand_davinci_correct_1bit; info->chip.ecc.hwctl = nand_davinci_hwctl_1bit; info->chip.ecc.bytes =3 ; - info->chip.ecc.algo =NAND_ECC_HAMMING ; + info->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ; } info->chip.ecc.size =512 ; info->chip.ecc.strength = pdata->ecc_bits;
drivers/mtd/nand/raw/fsl_elbc_nand.c +1 -1
@@ -748,7 +748,7 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip) }else {/* otherwise fall back to default software ECC */ chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; }break ;
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -1
@@ -926,7 +926,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) } }else { chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; } ret =fsl_ifc_sram_init (priv);
drivers/mtd/nand/raw/fsl_upm.c +1 -1
@@ -164,7 +164,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun, fun->chip.legacy.read_buf = fun_read_buf; fun->chip.legacy.write_buf = fun_write_buf; fun->chip.ecc.mode =NAND_ECC_SOFT ; - fun->chip.ecc.algo =NAND_ECC_HAMMING ; + fun->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;if (fun->mchip_count >1 ) fun->chip.legacy.select_chip = fun_select_chip;
drivers/mtd/nand/raw/fsmc_nand.c +1 -1
@@ -911,7 +911,7 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand)break ;case NAND_ECC_SOFT : -if (nand->ecc.algo ==NAND_ECC_BCH ) { +if (nand->ecc.algo ==NAND_ECC_ALGO_BCH ) {dev_info (host->dev,"Using 4-bit SW BCH ECC scheme\n" );break ;
drivers/mtd/nand/raw/gpio.c +1 -1
@@ -276,7 +276,7 @@ static int gpio_nand_probe(struct platform_device *pdev)nand_set_flash_node (chip, pdev->dev.of_node); chip->legacy.IO_ADDR_W = chip->legacy.IO_ADDR_R; chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; chip->options = gpiomtd->plat.options; chip->legacy.chip_delay = gpiomtd->plat.chip_delay; chip->legacy.cmd_ctrl = gpio_nand_cmd_ctrl;
drivers/mtd/nand/raw/marvell_nand.c +5 -5
@@ -780,7 +780,7 @@ static void marvell_nfc_enable_hw_ecc(struct nand_chip *chip)* When enabling BCH, set threshold to 0 to always know the * number of corrected bitflips. */ -if (chip->ecc.algo ==NAND_ECC_BCH ) +if (chip->ecc.algo ==NAND_ECC_ALGO_BCH )writel_relaxed (NDECCCTRL_BCH_EN , nfc->regs +NDECCCTRL ); } }
@@ -792,7 +792,7 @@ static void marvell_nfc_disable_hw_ecc(struct nand_chip *chip)if (ndcr &NDCR_ECC_EN ) {writel_relaxed (ndcr & ~NDCR_ECC_EN , nfc->regs +NDCR ); -if (chip->ecc.algo ==NAND_ECC_BCH ) +if (chip->ecc.algo ==NAND_ECC_ALGO_BCH )writel_relaxed (0 , nfc->regs +NDECCCTRL ); } }
@@ -966,7 +966,7 @@ static int marvell_nfc_hw_ecc_check_bitflips(struct nand_chip *chip,if (ndsr &NDSR_CORERR ) {writel_relaxed (ndsr, nfc->regs +NDSR ); -if (chip->ecc.algo ==NAND_ECC_BCH ) +if (chip->ecc.algo ==NAND_ECC_ALGO_BCH ) bf =NDSR_ERRCNT (ndsr);else bf =1 ;
@@ -2215,7 +2215,7 @@ static int marvell_nand_hw_ecc_controller_init(struct mtd_info *mtd, ecc->size = l->data_bytes;if (ecc->strength ==1 ) { - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; ecc->read_page_raw = marvell_nfc_hw_ecc_hmg_read_page_raw; ecc->read_page = marvell_nfc_hw_ecc_hmg_read_page; ecc->read_oob_raw = marvell_nfc_hw_ecc_hmg_read_oob_raw;
@@ -2225,7 +2225,7 @@ static int marvell_nand_hw_ecc_controller_init(struct mtd_info *mtd, ecc->write_oob_raw = marvell_nfc_hw_ecc_hmg_write_oob_raw; ecc->write_oob = ecc->write_oob_raw; }else { - chip->ecc.algo =NAND_ECC_BCH ; + chip->ecc.algo =NAND_ECC_ALGO_BCH ; ecc->strength =16 ; ecc->read_page_raw = marvell_nfc_hw_ecc_bch_read_page_raw; ecc->read_page = marvell_nfc_hw_ecc_bch_read_page;
drivers/mtd/nand/raw/mpc5121_nfc.c +1 -1
@@ -689,7 +689,7 @@ static int mpc5121_nfc_probe(struct platform_device *op) chip->legacy.get_features = nand_get_set_features_notsupp; chip->bbt_options =NAND_BBT_USE_FLASH ; chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* Support external chip-select logic on ADS5121 board */ if (of_machine_is_compatible ("fsl,mpc5121ads" )) {
drivers/mtd/nand/raw/mxc_nand.c +1 -1
@@ -1846,7 +1846,7 @@ static int mxcnd_probe(struct platform_device *pdev) this->ecc.mode =NAND_ECC_HW ; }else { this->ecc.mode =NAND_ECC_SOFT ; - this->ecc.algo =NAND_ECC_HAMMING ; + this->ecc.algo =NAND_ECC_ALGO_HAMMING ; }/* NAND bus width determines access functions used by upper layer */
drivers/mtd/nand/raw/nand_base.c +13 -13
@@ -5076,9 +5076,9 @@ enum nand_ecc_placement of_get_nand_ecc_placement(struct device_node *np) }static const char *const nand_ecc_algos[] = { - [NAND_ECC_HAMMING ] ="hamming" , - [NAND_ECC_BCH ] ="bch" , - [NAND_ECC_RS ] ="rs" , + [NAND_ECC_ALGO_HAMMING ] ="hamming" , + [NAND_ECC_ALGO_BCH ] ="bch" , + [NAND_ECC_ALGO_RS ] ="rs" , };static enum nand_ecc_algo of_get_nand_ecc_algo (struct device_node *np)
@@ -5089,7 +5089,7 @@ static enum nand_ecc_algo of_get_nand_ecc_algo(struct device_node *np) err =of_property_read_string (np,"nand-ecc-algo" , &pm);if (!err) { -for (ecc_algo =NAND_ECC_HAMMING ; +for (ecc_algo =NAND_ECC_ALGO_HAMMING ; ecc_algo <ARRAY_SIZE (nand_ecc_algos); ecc_algo++) {if (!strcasecmp (pm, nand_ecc_algos[ecc_algo]))
@@ -5104,12 +5104,12 @@ static enum nand_ecc_algo of_get_nand_ecc_algo(struct device_node *np) err =of_property_read_string (np,"nand-ecc-mode" , &pm);if (!err) {if (!strcasecmp (pm,"soft" )) -return NAND_ECC_HAMMING ; +return NAND_ECC_ALGO_HAMMING ;else if (!strcasecmp (pm,"soft_bch" )) -return NAND_ECC_BCH ; +return NAND_ECC_ALGO_BCH ; } -return NAND_ECC_UNKNOWN ; +return NAND_ECC_ALGO_UNKNOWN ; }static int of_get_nand_ecc_step_size (struct device_node *np)
@@ -5178,7 +5178,7 @@ static int nand_dt_init(struct nand_chip *chip)if (ecc_mode >=0 ) chip->ecc.mode = ecc_mode; -if (ecc_algo !=NAND_ECC_UNKNOWN ) +if (ecc_algo !=NAND_ECC_ALGO_UNKNOWN ) chip->ecc.algo = ecc_algo;if (ecc_strength >=0 )
@@ -5302,7 +5302,7 @@ static int nand_set_ecc_soft_ops(struct nand_chip *chip)return -EINVAL ;switch (ecc->algo) { -case NAND_ECC_HAMMING : +case NAND_ECC_ALGO_HAMMING : ecc->calculate = nand_calculate_ecc; ecc->correct = nand_correct_data; ecc->read_page = nand_read_page_swecc;
@@ -5323,7 +5323,7 @@ static int nand_set_ecc_soft_ops(struct nand_chip *chip) ecc->options |=NAND_ECC_SOFT_HAMMING_SM_ORDER ;return 0 ; -case NAND_ECC_BCH : +case NAND_ECC_ALGO_BCH :if (!mtd_nand_has_bch ()) {WARN (1 ,"CONFIG_MTD_NAND_ECC_SW_BCH not enabled\n" );return -EINVAL ;
@@ -5763,7 +5763,7 @@ static int nand_scan_tail(struct nand_chip *chip)* If no default placement scheme is given, select an appropriate one. */ if (!mtd->ooblayout && - !(ecc->mode ==NAND_ECC_SOFT && ecc->algo ==NAND_ECC_BCH )) { + !(ecc->mode ==NAND_ECC_SOFT && ecc->algo ==NAND_ECC_ALGO_BCH )) {switch (mtd->oobsize) {case 8 :case 16 :
@@ -5858,7 +5858,7 @@ static int nand_scan_tail(struct nand_chip *chip)pr_warn ("%d byte HW ECC not possible on %d byte page size, fallback to SW ECC\n" , ecc->size, mtd->writesize); ecc->mode =NAND_ECC_SOFT ; - ecc->algo =NAND_ECC_HAMMING ; + ecc->algo =NAND_ECC_ALGO_HAMMING ;break ;default :
@@ -6124,7 +6124,7 @@ EXPORT_SYMBOL(nand_scan_with_ids);void nand_cleanup (struct nand_chip *chip) {if (chip->ecc.mode ==NAND_ECC_SOFT && - chip->ecc.algo ==NAND_ECC_BCH ) + chip->ecc.algo ==NAND_ECC_ALGO_BCH )nand_bch_free ((struct nand_bch_control *)chip->ecc.priv);nanddev_cleanup (&chip->base);
drivers/mtd/nand/raw/nand_micron.c +1 -1
@@ -543,7 +543,7 @@ static int micron_nand_init(struct nand_chip *chip) chip->ecc.bytes = chip->base.eccreq.strength *2 ; chip->ecc.size =512 ; chip->ecc.strength = chip->base.eccreq.strength; - chip->ecc.algo =NAND_ECC_BCH ; + chip->ecc.algo =NAND_ECC_ALGO_BCH ; chip->ecc.read_page = micron_nand_read_page_on_die_ecc; chip->ecc.write_page = micron_nand_write_page_on_die_ecc;
drivers/mtd/nand/raw/nandsim.c +2 -2
@@ -2235,7 +2235,7 @@ static int ns_attach_chip(struct nand_chip *chip) } chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_BCH ; + chip->ecc.algo =NAND_ECC_ALGO_BCH ; chip->ecc.size =512 ; chip->ecc.strength = bch; chip->ecc.bytes = eccbytes;
@@ -2275,7 +2275,7 @@ static int __init ns_init_module(void)nand_set_controller_data (chip, (void *)ns); chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ /* and 'badblocks' parameters to work */ chip->options |=NAND_SKIP_BBTSCAN ;
drivers/mtd/nand/raw/omap2.c +1 -1
@@ -2011,7 +2011,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)*/ if (info->ecc_opt ==OMAP_ECC_HAM1_CODE_SW ) { chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ; }
drivers/mtd/nand/raw/orion_nand.c +1 -1
@@ -140,7 +140,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) nc->legacy.cmd_ctrl = orion_nand_cmd_ctrl; nc->legacy.read_buf = orion_nand_read_buf; nc->ecc.mode =NAND_ECC_SOFT ; - nc->ecc.algo =NAND_ECC_HAMMING ; + nc->ecc.algo =NAND_ECC_ALGO_HAMMING ;if (board->chip_delay) nc->legacy.chip_delay = board->chip_delay;
drivers/mtd/nand/raw/pasemi_nand.c +1 -1
@@ -133,7 +133,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev) chip->legacy.write_buf = pasemi_write_buf; chip->legacy.chip_delay =0 ; chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* Enable the following for a flash based bad block table */ chip->bbt_options =NAND_BBT_USE_FLASH ;
drivers/mtd/nand/raw/plat_nand.c +1 -1
@@ -67,7 +67,7 @@ static int plat_nand_probe(struct platform_device *pdev) data->chip.bbt_options |= pdata->chip.bbt_options; data->chip.ecc.mode =NAND_ECC_SOFT ; - data->chip.ecc.algo =NAND_ECC_HAMMING ; + data->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;platform_set_drvdata (pdev, data);
drivers/mtd/nand/raw/s3c2410.c +2 -2
@@ -938,11 +938,11 @@ static int s3c2410_nand_attach_chip(struct nand_chip *chip)case NAND_ECC_SOFT :/* * This driver expects Hamming based ECC when ecc_mode is set -* to NAND_ECC_SOFT. Force ecc.algo to NAND_ECC_HAMMING to +* to NAND_ECC_SOFT. Force ecc.algo to NAND_ECC_ALGO_HAMMING to * avoid adding an extra ecc_algo field to * s3c2410_platform_nand. */ - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;dev_info (info->device,"soft ECC\n" );break ;
drivers/mtd/nand/raw/sh_flctl.c +1 -1
@@ -1045,7 +1045,7 @@ static int flctl_chip_attach_chip(struct nand_chip *chip) flctl->flcmncr_base |= _4ECCEN; }else { chip->ecc.mode =NAND_ECC_SOFT ; - chip->ecc.algo =NAND_ECC_HAMMING ; + chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; }return 0 ;
drivers/mtd/nand/raw/socrates_nand.c +1 -1
@@ -154,7 +154,7 @@ static int socrates_nand_probe(struct platform_device *ofdev) nand_chip->legacy.dev_ready = socrates_nand_device_ready; nand_chip->ecc.mode =NAND_ECC_SOFT ;/* enable ECC */ - nand_chip->ecc.algo =NAND_ECC_HAMMING ; + nand_chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* TODO: I have no idea what real delay is. */ nand_chip->legacy.chip_delay =20 ;/* 20us command delay time */
drivers/mtd/nand/raw/tango_nand.c +1 -1
@@ -512,7 +512,7 @@ static int tango_attach_chip(struct nand_chip *chip)struct nand_ecc_ctrl *ecc = &chip->ecc; ecc->mode =NAND_ECC_HW ; - ecc->algo =NAND_ECC_BCH ; + ecc->algo =NAND_ECC_ALGO_BCH ; ecc->bytes =DIV_ROUND_UP (ecc->strength *FIELD_ORDER ,BITS_PER_BYTE ); ecc->read_page_raw = tango_read_page_raw;
drivers/mtd/nand/raw/tegra_nand.c +10 -10
@@ -479,7 +479,7 @@ static void tegra_nand_hw_ecc(struct tegra_nand_controller *ctrl, {struct tegra_nand_chip *nand =to_tegra_chip (chip); -if (chip->ecc.algo ==NAND_ECC_BCH && enable) +if (chip->ecc.algo ==NAND_ECC_ALGO_BCH && enable)writel_relaxed (nand->bch_config, ctrl->regs +BCH_CONFIG );else writel_relaxed (0 , ctrl->regs +BCH_CONFIG );
@@ -877,7 +877,7 @@ static int tegra_nand_select_strength(struct nand_chip *chip, int oobsize)int strength_len, bits_per_step;switch (chip->ecc.algo) { -case NAND_ECC_RS : +case NAND_ECC_ALGO_RS : bits_per_step =BITS_PER_STEP_RS ;if (chip->options &NAND_IS_BOOT_MEDIUM ) { strength = rs_strength_bootable;
@@ -887,7 +887,7 @@ static int tegra_nand_select_strength(struct nand_chip *chip, int oobsize) strength_len =ARRAY_SIZE (rs_strength); }break ; -case NAND_ECC_BCH : +case NAND_ECC_ALGO_BCH : bits_per_step =BITS_PER_STEP_BCH ;if (chip->options &NAND_IS_BOOT_MEDIUM ) { strength = bch_strength_bootable;
@@ -935,14 +935,14 @@ static int tegra_nand_attach_chip(struct nand_chip *chip)if (chip->options &NAND_BUSWIDTH_16 ) nand->config |=CONFIG_BUS_WIDTH_16 ; -if (chip->ecc.algo ==NAND_ECC_UNKNOWN ) { +if (chip->ecc.algo ==NAND_ECC_ALGO_UNKNOWN ) {if (mtd->writesize <2048 ) - chip->ecc.algo =NAND_ECC_RS ; + chip->ecc.algo =NAND_ECC_ALGO_RS ;else - chip->ecc.algo =NAND_ECC_BCH ; + chip->ecc.algo =NAND_ECC_ALGO_BCH ; } -if (chip->ecc.algo ==NAND_ECC_BCH && mtd->writesize <2048 ) { +if (chip->ecc.algo ==NAND_ECC_ALGO_BCH && mtd->writesize <2048 ) {dev_err (ctrl->dev,"BCH supports 2K or 4K page size only\n" );return -EINVAL ; }
@@ -963,7 +963,7 @@ static int tegra_nand_attach_chip(struct nand_chip *chip)CONFIG_SKIP_SPARE_SIZE_4 ;switch (chip->ecc.algo) { -case NAND_ECC_RS : +case NAND_ECC_ALGO_RS : bits_per_step =BITS_PER_STEP_RS * chip->ecc.strength;mtd_set_ooblayout (mtd, &tegra_nand_oob_rs_ops); nand->config_ecc |= CONFIG_HW_ECC | CONFIG_ECC_SEL |
@@ -984,7 +984,7 @@ static int tegra_nand_attach_chip(struct nand_chip *chip)return -EINVAL ; }break ; -case NAND_ECC_BCH : +case NAND_ECC_ALGO_BCH : bits_per_step =BITS_PER_STEP_BCH * chip->ecc.strength;mtd_set_ooblayout (mtd, &tegra_nand_oob_bch_ops); nand->bch_config =BCH_ENABLE ;
@@ -1013,7 +1013,7 @@ static int tegra_nand_attach_chip(struct nand_chip *chip) }dev_info (ctrl->dev,"Using %s with strength %d per 512 byte step\n" , - chip->ecc.algo ==NAND_ECC_BCH ?"BCH" :"RS" , + chip->ecc.algo ==NAND_ECC_ALGO_BCH ?"BCH" :"RS" , chip->ecc.strength); chip->ecc.bytes =DIV_ROUND_UP (bits_per_step,BITS_PER_BYTE );
drivers/mtd/nand/raw/xway_nand.c +1 -1
@@ -181,7 +181,7 @@ static int xway_nand_probe(struct platform_device *pdev) data->chip.legacy.chip_delay =30 ; data->chip.ecc.mode =NAND_ECC_SOFT ; - data->chip.ecc.algo =NAND_ECC_HAMMING ; + data->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;platform_set_drvdata (pdev, data);nand_set_controller_data (&data->chip, data);
include/linux/mtd/rawnand.h +8 -8
@@ -108,16 +108,16 @@ enum nand_ecc_placement {/** * enum nand_ecc_algo - NAND ECC algorithm -* @NAND_ECC_UNKNOWN: Unknown algorithm -* @NAND_ECC_HAMMING: Hamming algorithm -* @NAND_ECC_BCH: Bose-Chaudhuri-Hocquenghem algorithm -* @NAND_ECC_RS: Reed-Solomon algorithm +* @NAND_ECC_ALGO_UNKNOWN: Unknown algorithm +* @NAND_ECC_ALGO_HAMMING: Hamming algorithm +* @NAND_ECC_ALGO_BCH: Bose-Chaudhuri-Hocquenghem algorithm +* @NAND_ECC_ALGO_RS: Reed-Solomon algorithm */ enum nand_ecc_algo { -NAND_ECC_UNKNOWN , -NAND_ECC_HAMMING , -NAND_ECC_BCH , -NAND_ECC_RS , +NAND_ECC_ALGO_UNKNOWN , +NAND_ECC_ALGO_HAMMING , +NAND_ECC_ALGO_BCH , +NAND_ECC_ALGO_RS , };/*
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 7/20 mtd: rawnand: Create a new enumeration to describe properly ECC types
In reply to Miquel RaynalNow that the misleading mix between ECC engine type and ECC placement has been addressed, add a new enumeration to properly define ECC engine types.
--- include/linux/mtd/rawnand.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/linux/mtd/rawnand.h +16 -0
@@ -92,6 +92,22 @@ enum nand_ecc_mode { NAND_ECC_ON_DIE, }; +/** +* enum nand_ecc_engine_type - NAND ECC engine type +* @NAND_ECC_ENGINE_TYPE_INVALID: Invalid value +* @NAND_ECC_ENGINE_TYPE_NONE: No ECC correction +* @NAND_ECC_ENGINE_TYPE_SOFT: Software ECC correction +* @NAND_ECC_ENGINE_TYPE_ON_HOST: On host hardware ECC correction +* @NAND_ECC_ENGINE_TYPE_ON_DIE: On chip hardware ECC correction +*/ +enum nand_ecc_engine_type { +NAND_ECC_ENGINE_TYPE_INVALID , +NAND_ECC_ENGINE_TYPE_NONE , +NAND_ECC_ENGINE_TYPE_SOFT , +NAND_ECC_ENGINE_TYPE_ON_HOST , +NAND_ECC_ENGINE_TYPE_ON_DIE , +}; +/** * enum nand_ecc_placement - NAND ECC bytes placement * @NAND_ECC_PLACEMENT_UNKNOWN: The actual position of the ECC bytes is unknown
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 8/20 mtd: rawnand: Use the new ECC engine type enumeration
In reply to Miquel RaynalMechanical switch from the legacy "mode" enumeration to the new "engine type" enumeration in drivers and board files.
The device tree parsing is also updated to return the new enumeration from the old strings.
--- arch/arm/mach-davinci/board-da830-evm.c | 2 +- arch/arm/mach-davinci/board-da850-evm.c | 2 +- arch/arm/mach-davinci/board-dm355-evm.c | 2 +- arch/arm/mach-davinci/board-dm355-leopard.c | 2 +- arch/arm/mach-davinci/board-dm365-evm.c | 2 +- arch/arm/mach-davinci/board-dm644x-evm.c | 2 +- arch/arm/mach-davinci/board-dm646x-evm.c | 2 +- arch/arm/mach-davinci/board-mityomapl138.c | 2 +- arch/arm/mach-davinci/board-neuros-osd2.c | 2 +- arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +- arch/arm/mach-s3c24xx/common-smdk.c | 2 +- arch/arm/mach-s3c24xx/mach-anubis.c | 2 +- arch/arm/mach-s3c24xx/mach-at2440evb.c | 2 +- arch/arm/mach-s3c24xx/mach-bast.c | 2 +- arch/arm/mach-s3c24xx/mach-gta02.c | 2 +- arch/arm/mach-s3c24xx/mach-jive.c | 2 +- arch/arm/mach-s3c24xx/mach-mini2440.c | 2 +- arch/arm/mach-s3c24xx/mach-osiris.c | 2 +- arch/arm/mach-s3c24xx/mach-qt2410.c | 2 +- arch/arm/mach-s3c24xx/mach-rx1950.c | 2 +- arch/arm/mach-s3c24xx/mach-rx3715.c | 2 +- arch/arm/mach-s3c24xx/mach-vstms.c | 2 +- arch/arm/mach-s3c64xx/mach-hmt.c | 2 +- arch/arm/mach-s3c64xx/mach-mini6410.c | 2 +- arch/arm/mach-s3c64xx/mach-real6410.c | 2 +- drivers/mtd/nand/raw/ams-delta.c | 2 +- drivers/mtd/nand/raw/arasan-nand-controller.c | 12 +-- drivers/mtd/nand/raw/atmel/nand-controller.c | 14 ++-- drivers/mtd/nand/raw/au1550nd.c | 2 +- .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 3 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 +- .../mtd/nand/raw/cadence-nand-controller.c | 4 +- drivers/mtd/nand/raw/cafe_nand.c | 2 +- drivers/mtd/nand/raw/cs553x_nand.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 24 +++--- drivers/mtd/nand/raw/denali.c | 2 +- drivers/mtd/nand/raw/diskonchip.c | 2 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 18 ++--- drivers/mtd/nand/raw/fsl_ifc_nand.c | 10 +-- drivers/mtd/nand/raw/fsl_upm.c | 2 +- drivers/mtd/nand/raw/fsmc_nand.c | 12 +-- drivers/mtd/nand/raw/gpio.c | 2 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- drivers/mtd/nand/raw/hisi504_nand.c | 6 +- .../mtd/nand/raw/ingenic/ingenic_nand_drv.c | 14 ++-- drivers/mtd/nand/raw/lpc32xx_mlc.c | 2 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 2 +- drivers/mtd/nand/raw/marvell_nand.c | 17 ++-- drivers/mtd/nand/raw/meson_nand.c | 2 +- drivers/mtd/nand/raw/mpc5121_nfc.c | 2 +- drivers/mtd/nand/raw/mtk_nand.c | 6 +- drivers/mtd/nand/raw/mxc_nand.c | 23 +++--- drivers/mtd/nand/raw/nand_base.c | 78 ++++++++++++------- drivers/mtd/nand/raw/nand_micron.c | 4 +- drivers/mtd/nand/raw/nand_toshiba.c | 3 +- drivers/mtd/nand/raw/nandsim.c | 4 +- drivers/mtd/nand/raw/ndfc.c | 2 +- drivers/mtd/nand/raw/omap2.c | 20 ++--- drivers/mtd/nand/raw/orion_nand.c | 2 +- drivers/mtd/nand/raw/pasemi_nand.c | 2 +- drivers/mtd/nand/raw/plat_nand.c | 2 +- drivers/mtd/nand/raw/qcom_nandc.c | 2 +- drivers/mtd/nand/raw/r852.c | 2 +- drivers/mtd/nand/raw/s3c2410.c | 18 ++--- drivers/mtd/nand/raw/sh_flctl.c | 4 +- drivers/mtd/nand/raw/sharpsl.c | 2 +- drivers/mtd/nand/raw/socrates_nand.c | 3 +- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 9 ++- drivers/mtd/nand/raw/sunxi_nand.c | 18 ++--- drivers/mtd/nand/raw/tango_nand.c | 2 +- drivers/mtd/nand/raw/tegra_nand.c | 2 +- drivers/mtd/nand/raw/tmio_nand.c | 2 +- drivers/mtd/nand/raw/txx9ndfmc.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 4 +- drivers/mtd/nand/raw/xway_nand.c | 2 +- include/linux/mtd/rawnand.h | 4 +- include/linux/platform_data/mtd-davinci.h | 8 +- .../linux/platform_data/mtd-nand-s3c2410.h | 2 +- 78 files changed, 238 insertions(+), 212 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +1 -1
@@ -306,7 +306,7 @@ static struct davinci_nand_pdata da830_evm_nand_pdata = { .core_chipsel = 1, .parts = da830_evm_nand_partitions, .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_bits = 4, .bbt_options = NAND_BBT_USE_FLASH, .bbt_td = &da830_evm_nand_bbt_main_descr,
arch/arm/mach-davinci/board-da850-evm.c +1 -1
@@ -239,7 +239,7 @@ static struct davinci_nand_pdata da850_evm_nandflash_data = { .core_chipsel = 1, .parts = da850_evm_nandflash_partition, .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_bits = 4, .bbt_options = NAND_BBT_USE_FLASH, .timing = &da850_evm_nandflash_timing,
arch/arm/mach-davinci/board-dm355-evm.c +1 -1
@@ -82,7 +82,7 @@ static struct davinci_nand_pdata davinci_nand_data = { .mask_chipsel = BIT(14), .parts = davinci_nand_partitions, .nr_parts = ARRAY_SIZE(davinci_nand_partitions), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .bbt_options = NAND_BBT_USE_FLASH, .ecc_bits = 4, };
arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
@@ -76,7 +76,7 @@ static struct davinci_nand_pdata davinci_nand_data = { .mask_chipsel = BIT(14), .parts = davinci_nand_partitions, .nr_parts = ARRAY_SIZE(davinci_nand_partitions), - .ecc_mode = NAND_HW_ECC_ENGINE, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_placement = NAND_ECC_PLACEMENT_INTERLEAVED, .ecc_bits = 4, .bbt_options = NAND_BBT_USE_FLASH,
arch/arm/mach-davinci/board-dm365-evm.c +1 -1
@@ -146,7 +146,7 @@ static struct davinci_nand_pdata davinci_nand_data = { .mask_chipsel = BIT(14), .parts = davinci_nand_partitions, .nr_parts = ARRAY_SIZE(davinci_nand_partitions), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .bbt_options = NAND_BBT_USE_FLASH, .ecc_bits = 4, };
arch/arm/mach-davinci/board-dm644x-evm.c +1 -1
@@ -162,7 +162,7 @@ static struct davinci_nand_pdata davinci_evm_nandflash_data = { .core_chipsel = 0, .parts = davinci_evm_nandflash_partition, .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_bits = 1, .bbt_options = NAND_BBT_USE_FLASH, .timing = &davinci_evm_nandflash_timing,
arch/arm/mach-davinci/board-dm646x-evm.c +1 -1
@@ -91,7 +91,7 @@ static struct davinci_nand_pdata davinci_nand_data = { .mask_ale = 0x40000, .parts = davinci_nand_partitions, .nr_parts = ARRAY_SIZE(davinci_nand_partitions), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_bits = 1, .options = 0, };
arch/arm/mach-davinci/board-mityomapl138.c +1 -1
@@ -432,7 +432,7 @@ static struct davinci_nand_pdata mityomapl138_nandflash_data = { .core_chipsel = 1, .parts = mityomapl138_nandflash_partition, .nr_parts = ARRAY_SIZE(mityomapl138_nandflash_partition), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .bbt_options = NAND_BBT_USE_FLASH, .options = NAND_BUSWIDTH_16, .ecc_bits = 1, /* 4 bit mode is not supported with 16 bit NAND */
arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
@@ -90,7 +90,7 @@ static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = { .core_chipsel = 0, .parts = davinci_ntosd2_nandflash_partition, .nr_parts = ARRAY_SIZE(davinci_ntosd2_nandflash_partition), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_bits = 1, .bbt_options = NAND_BBT_USE_FLASH, };
arch/arm/mach-davinci/board-omapl138-hawk.c +1 -1
@@ -206,7 +206,7 @@ static struct davinci_nand_pdata omapl138_hawk_nandflash_data = { .core_chipsel = 1, .parts = omapl138_hawk_nandflash_partition, .nr_parts = ARRAY_SIZE(omapl138_hawk_nandflash_partition), - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, .ecc_bits = 4, .bbt_options = NAND_BBT_USE_FLASH, .options = NAND_BUSWIDTH_16,
arch/arm/mach-s3c24xx/common-smdk.c +1 -1
@@ -166,7 +166,7 @@ static struct s3c2410_platform_nand smdk_nand_info = { .twrph1 = 20, .nr_sets = ARRAY_SIZE(smdk_nand_sets), .sets = smdk_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };/* devices we initialise */
arch/arm/mach-s3c24xx/mach-anubis.c +1 -1
@@ -218,7 +218,7 @@ static struct s3c2410_platform_nand __initdata anubis_nand_info = { .nr_sets = ARRAY_SIZE(anubis_nand_sets), .sets = anubis_nand_sets, .select_chip = anubis_nand_select, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };/* IDE channels */
arch/arm/mach-s3c24xx/mach-at2440evb.c +1 -1
@@ -109,7 +109,7 @@ static struct s3c2410_platform_nand __initdata at2440evb_nand_info = { .twrph1 = 40, .nr_sets = ARRAY_SIZE(at2440evb_nand_sets), .sets = at2440evb_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };/* DM9000AEP 10/100 ethernet controller */
arch/arm/mach-s3c24xx/mach-bast.c +1 -1
@@ -294,7 +294,7 @@ static struct s3c2410_platform_nand __initdata bast_nand_info = { .nr_sets = ARRAY_SIZE(bast_nand_sets), .sets = bast_nand_sets, .select_chip = bast_nand_select, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };/* DM9000 */
arch/arm/mach-s3c24xx/mach-gta02.c +1 -1
@@ -416,7 +416,7 @@ static struct s3c2410_platform_nand __initdata gta02_nand_info = { .twrph1 = 15, .nr_sets = ARRAY_SIZE(gta02_nand_sets), .sets = gta02_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };
arch/arm/mach-s3c24xx/mach-jive.c +1 -1
@@ -228,7 +228,7 @@ static struct s3c2410_platform_nand __initdata jive_nand_info = { .twrph1 = 40, .sets = jive_nand_sets, .nr_sets = ARRAY_SIZE(jive_nand_sets), - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static int __init jive_mtdset (char *options)
arch/arm/mach-s3c24xx/mach-mini2440.c +1 -1
@@ -296,7 +296,7 @@ static struct s3c2410_platform_nand mini2440_nand_info __initdata = { .nr_sets = ARRAY_SIZE(mini2440_nand_sets), .sets = mini2440_nand_sets, .ignore_unset_ecc = 1, - .ecc_mode = NAND_ECC_HW, + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, };/* DM9000AEP 10/100 ethernet controller */
arch/arm/mach-s3c24xx/mach-osiris.c +1 -1
@@ -234,7 +234,7 @@ static struct s3c2410_platform_nand __initdata osiris_nand_info = { .nr_sets = ARRAY_SIZE(osiris_nand_sets), .sets = osiris_nand_sets, .select_chip = osiris_nand_select, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };/* PCMCIA control and configuration */
arch/arm/mach-s3c24xx/mach-qt2410.c +1 -1
@@ -281,7 +281,7 @@ static struct s3c2410_platform_nand __initdata qt2410_nand_info = { .twrph1 = 20, .nr_sets = ARRAY_SIZE(qt2410_nand_sets), .sets = qt2410_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };/* UDC */
arch/arm/mach-s3c24xx/mach-rx1950.c +1 -1
@@ -620,7 +620,7 @@ static struct s3c2410_platform_nand rx1950_nand_info = { .twrph1 = 15, .nr_sets = ARRAY_SIZE(rx1950_nand_sets), .sets = rx1950_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static struct s3c2410_udc_mach_info rx1950_udc_cfg__initdata = {
arch/arm/mach-s3c24xx/mach-rx3715.c +1 -1
@@ -158,7 +158,7 @@ static struct s3c2410_platform_nand __initdata rx3715_nand_info = { .twrph1 = 15, .nr_sets = ARRAY_SIZE(rx3715_nand_sets), .sets = rx3715_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static struct platform_device *rx3715_devices[]__initdata = {
arch/arm/mach-s3c24xx/mach-vstms.c +1 -1
@@ -112,7 +112,7 @@ static struct s3c2410_platform_nand __initdata vstms_nand_info = { .twrph1 = 20, .nr_sets = ARRAY_SIZE(vstms_nand_sets), .sets = vstms_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static struct platform_device *vstms_devices[]__initdata = {
arch/arm/mach-s3c64xx/mach-hmt.c +1 -1
@@ -199,7 +199,7 @@ static struct s3c2410_platform_nand hmt_nand_info = { .twrph1 = 40, .nr_sets = ARRAY_SIZE(hmt_nand_sets), .sets = hmt_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static struct gpio_led hmt_leds[] = {
arch/arm/mach-s3c64xx/mach-mini6410.c +1 -1
@@ -136,7 +136,7 @@ static struct s3c2410_platform_nand mini6410_nand_info = { .twrph1 = 40, .nr_sets = ARRAY_SIZE(mini6410_nand_sets), .sets = mini6410_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static struct s3c_fb_pd_win mini6410_lcd_type0_fb_win = {
arch/arm/mach-s3c64xx/mach-real6410.c +1 -1
@@ -188,7 +188,7 @@ static struct s3c2410_platform_nand real6410_nand_info = { .twrph1 = 40, .nr_sets = ARRAY_SIZE(real6410_nand_sets), .sets = real6410_nand_sets, - .ecc_mode = NAND_ECC_SOFT, + .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, };static struct platform_device *real6410_devices[]__initdata = {
drivers/mtd/nand/raw/ams-delta.c +1 -1
@@ -260,7 +260,7 @@ static int gpio_nand_probe(struct platform_device *pdev)return err; } - this->ecc.mode =NAND_ECC_SOFT ; + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; this->ecc.algo =NAND_ECC_ALGO_HAMMING ;platform_set_drvdata (pdev, priv);
drivers/mtd/nand/raw/arasan-nand-controller.c +6 -6
@@ -1056,17 +1056,17 @@ static int anfc_attach_chip(struct nand_chip *chip) chip->ecc.read_page_raw = nand_monolithic_read_page_raw; chip->ecc.write_page_raw = nand_monolithic_write_page_raw; -switch (chip->ecc.mode) { -case NAND_ECC_NONE : -case NAND_ECC_SOFT : -case NAND_ECC_ON_DIE : +switch (chip->ecc.engine_type) { +case NAND_ECC_ENGINE_TYPE_NONE : +case NAND_ECC_ENGINE_TYPE_SOFT : +case NAND_ECC_ENGINE_TYPE_ON_DIE :break ; -case NAND_ECC_HW : +case NAND_ECC_ENGINE_TYPE_ON_HOST : ret =anfc_init_hw_ecc_controller (nfc, chip);break ;default :dev_err (nfc->dev,"Unsupported ECC mode: %d\n" , - chip->ecc.mode); + chip->ecc.engine_type);return -EINVAL ; }
drivers/mtd/nand/raw/atmel/nand-controller.c +7 -7
@@ -1118,15 +1118,15 @@ static int atmel_nand_ecc_init(struct nand_chip *chip) nc =to_nand_controller (chip->controller); -switch (chip->ecc.mode) { -case NAND_ECC_NONE : -case NAND_ECC_SOFT : +switch (chip->ecc.engine_type) { +case NAND_ECC_ENGINE_TYPE_NONE : +case NAND_ECC_ENGINE_TYPE_SOFT :/* * Nothing to do, the core will initialize everything for us. */ break ; -case NAND_ECC_HW : +case NAND_ECC_ENGINE_TYPE_ON_HOST : ret =atmel_nand_pmecc_init (chip);if (ret)return ret;
@@ -1140,7 +1140,7 @@ static int atmel_nand_ecc_init(struct nand_chip *chip)default :/* Other modes are not supported. */ dev_err (nc->dev,"Unsupported ECC mode: %d\n" , - chip->ecc.mode); + chip->ecc.engine_type);return -ENOTSUPP ; }
@@ -1155,7 +1155,7 @@ static int atmel_hsmc_nand_ecc_init(struct nand_chip *chip)if (ret)return ret; -if (chip->ecc.mode !=NAND_ECC_HW ) +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST )return 0 ;/* Adjust the ECC operations for the HSMC IP. */
@@ -1498,7 +1498,7 @@ static void atmel_nand_init(struct atmel_nand_controller *nc,/* Default to HW ECC if pmecc is available. */ if (nc->pmecc) - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; } static void atmel_smc_nand_init(struct atmel_nand_controller *nc,
drivers/mtd/nand/raw/au1550nd.c +1 -1
@@ -294,7 +294,7 @@ static int au1550nd_probe(struct platform_device *pdev)nand_controller_init (&ctx->controller); ctx->controller.ops = &au1550nd_ops; this->controller = &ctx->controller; - this->ecc.mode =NAND_ECC_SOFT ; + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; this->ecc.algo =NAND_ECC_ALGO_HAMMING ;if (pd->devwidth)
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +2 -1
@@ -391,7 +391,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n) nand_chip->legacy.chip_delay =50 ; b47n->nand_chip.bbt_options =NAND_BBT_USE_FLASH ; - b47n->nand_chip.ecc.mode =NAND_ECC_NONE ;/* TODO: implement ECC */ +/* TODO: implement ECC */ + b47n->nand_chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_NONE ;/* Enable NAND flash access */ bcma_cc_set32(b47n->cc, BCMA_CC_4706_FLASHSCFG,
drivers/mtd/nand/raw/brcmnand/brcmnand.c +4 -4
@@ -2539,9 +2539,9 @@ static int brcmnand_setup_dev(struct brcmnand_host *host) cfg->col_adr_bytes =2 ; cfg->blk_adr_bytes =get_blk_adr_bytes (mtd->size, mtd->writesize); -if (chip->ecc.mode !=NAND_ECC_HW ) { +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST ) {dev_err (ctrl->dev,"only HW ECC supported; selected: %d\n" , - chip->ecc.mode); + chip->ecc.engine_type);return -EINVAL ; }
@@ -2561,7 +2561,7 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)return -EINVAL ; } -if (chip->ecc.mode !=NAND_ECC_NONE && +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_NONE && (!chip->ecc.size || !chip->ecc.strength)) {if (chip->base.eccreq.step_size && chip->base.eccreq.strength) {/* use detected ECC parameters */
@@ -2702,7 +2702,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) chip->legacy.read_buf = brcmnand_read_buf; chip->legacy.write_buf = brcmnand_write_buf; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.read_page = brcmnand_read_page; chip->ecc.write_page = brcmnand_write_page; chip->ecc.read_page_raw = brcmnand_read_page_raw;
drivers/mtd/nand/raw/cadence-nand-controller.c +2 -2
@@ -2610,7 +2610,7 @@ static int cadence_nand_attach_chip(struct nand_chip *chip) chip->bbt_options |=NAND_BBT_USE_FLASH ; chip->bbt_options |=NAND_BBT_NO_OOB ; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->options |=NAND_NO_SUBPAGE_WRITE ;
@@ -2756,7 +2756,7 @@ static int cadence_nand_chip_init(struct cdns_nand_ctrl *cdns_ctrl,* Default to HW ECC engine mode. If the nand-ecc-mode property is given * in the DT node, this entry will be overwritten in nand_scan_ident(). */ - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; ret =nand_scan (chip, cdns_chip->nsels);if (ret) {
drivers/mtd/nand/raw/cafe_nand.c +1 -1
@@ -629,7 +629,7 @@ static int cafe_nand_attach_chip(struct nand_chip *chip) goto out_free_dma; } - cafe->nand.ecc.mode =NAND_ECC_HW ; + cafe->nand.ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; cafe->nand.ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; cafe->nand.ecc.size = mtd->writesize; cafe->nand.ecc.bytes =14 ;
drivers/mtd/nand/raw/cs553x_nand.c +1 -1
@@ -286,7 +286,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) goto out_mtd; } - this->ecc.mode =NAND_ECC_HW ; + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; this->ecc.size =256 ; this->ecc.bytes =3 ; this->ecc.hwctl = cs_enable_hwecc;
drivers/mtd/nand/raw/davinci_nand.c +12 -12
@@ -530,11 +530,11 @@ static struct davinci_nand_pdataif (!of_property_read_string (pdev->dev.of_node,"ti,davinci-ecc-mode" , &mode)) {if (!strncmp ("none" , mode,4 )) - pdata->ecc_mode =NAND_ECC_NONE ; + pdata->engine_type =NAND_ECC_ENGINE_TYPE_NONE ;if (!strncmp ("soft" , mode,4 )) - pdata->ecc_mode =NAND_ECC_SOFT ; + pdata->engine_type =NAND_ECC_ENGINE_TYPE_SOFT ;if (!strncmp ("hw" , mode,2 )) - pdata->ecc_mode =NAND_ECC_HW ; + pdata->engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; }if (!of_property_read_u32 (pdev->dev.of_node,"ti,davinci-ecc-bits" , &prop))
@@ -585,21 +585,21 @@ static int davinci_nand_attach_chip(struct nand_chip *chip)if (IS_ERR (pdata))return PTR_ERR (pdata); -switch (info->chip.ecc.mode) { -case NAND_ECC_NONE : +switch (info->chip.ecc.engine_type) { +case NAND_ECC_ENGINE_TYPE_NONE : pdata->ecc_bits =0 ;break ; -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_SOFT : pdata->ecc_bits =0 ;/* -* This driver expects Hamming based ECC when ecc_mode is set -* to NAND_ECC_SOFT. Force ecc.algo to NAND_ECC_ALGO_HAMMING to -* avoid adding an extra ->ecc_algo field to -* davinci_nand_pdata. +* This driver expects Hamming based ECC when engine_type is set +* to NAND_ECC_ENGINE_TYPE_SOFT. Force ecc.algo to +* NAND_ECC_ALGO_HAMMING to avoid adding an extra ->ecc_algo +* field to davinci_nand_pdata. */ info->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;break ; -case NAND_ECC_HW : +case NAND_ECC_ENGINE_TYPE_ON_HOST :if (pdata->ecc_bits ==4 ) {int chunks = mtd->writesize /512 ;
@@ -850,7 +850,7 @@ static int nand_davinci_probe(struct platform_device *pdev) info->mask_cle = pdata->mask_cle ? :MASK_CLE ;/* Use board-specific ECC config */ - info->chip.ecc.mode = pdata->ecc_mode; + info->chip.ecc.engine_type = pdata->engine_type; info->chip.ecc.placement = pdata->ecc_placement;spin_lock_irq (&davinci_nand_lock);
drivers/mtd/nand/raw/denali.c +1 -1
@@ -1237,7 +1237,7 @@ int denali_chip_init(struct denali_controller *denali, chip->bbt_options |=NAND_BBT_USE_FLASH ; chip->bbt_options |=NAND_BBT_NO_OOB ; chip->options |=NAND_NO_SUBPAGE_WRITE ; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; chip->ecc.read_page = denali_read_page; chip->ecc.write_page = denali_write_page;
drivers/mtd/nand/raw/diskonchip.c +1 -1
@@ -1456,7 +1456,7 @@ static int __init doc_probe(unsigned long physadr) nand->ecc.calculate = doc200x_calculate_ecc; nand->ecc.correct = doc200x_correct_data; - nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; nand->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; nand->ecc.size =512 ; nand->ecc.bytes =6 ;
drivers/mtd/nand/raw/fsl_elbc_nand.c +9 -9
@@ -244,7 +244,7 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)return -EIO ; } -if (chip->ecc.mode !=NAND_ECC_HW ) +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST )return 0 ; elbc_fcm_ctrl->max_bitflips =0 ;
@@ -727,12 +727,12 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip)struct fsl_lbc_regs __iomem *lbc = ctrl->regs;unsigned int al; -switch (chip->ecc.mode) { +switch (chip->ecc.engine_type) {/* * if ECC was not chosen in DT, decide whether to use HW or SW ECC from * CS Base Register */ -case NAND_ECC_NONE : +case NAND_ECC_ENGINE_TYPE_NONE :/* If CS Base Register selects full hardware ECC then use it */ if ((in_be32 (&lbc->bank[priv->bank].br) &BR_DECC ) ==BR_DECC_CHK_GEN ) {
@@ -740,23 +740,23 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip) chip->ecc.write_page = fsl_elbc_write_page; chip->ecc.write_subpage = fsl_elbc_write_subpage; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ;mtd_set_ooblayout (mtd, &fsl_elbc_ooblayout_ops); chip->ecc.size =512 ; chip->ecc.bytes =3 ; chip->ecc.strength =1 ; }else {/* otherwise fall back to default software ECC */ - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; }break ;/* if SW ECC was chosen in DT, we do not need to set anything here */ -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_SOFT :break ; -/* should we also implement NAND_ECC_HW to do as the code above? */ +/* should we also implement *_ECC_ENGINE_CONTROLLER to do as above? */ default :return -EINVAL ; }
@@ -786,8 +786,8 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip) chip->page_shift);dev_dbg (priv->dev,"fsl_elbc_init: nand->phys_erase_shift = %d\n" , chip->phys_erase_shift); -dev_dbg (priv->dev,"fsl_elbc_init: nand->ecc.mode = %d\n" , - chip->ecc.mode); +dev_dbg (priv->dev,"fsl_elbc_init: nand->ecc.engine_type = %d\n" , + chip->ecc.engine_type);dev_dbg (priv->dev,"fsl_elbc_init: nand->ecc.steps = %d\n" , chip->ecc.steps); dev_dbg(priv->dev, "fsl_elbc_init: nand->ecc.bytes = %d\n",
drivers/mtd/nand/raw/fsl_ifc_nand.c +5 -5
@@ -309,7 +309,7 @@ static void fsl_ifc_cmdfunc(struct nand_chip *chip, unsigned int command, ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; ifc_nand_ctrl->index += column; -if (chip->ecc.mode ==NAND_ECC_HW ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) ifc_nand_ctrl->eccread =1 ;fsl_ifc_do_read (chip,0 , mtd);
@@ -724,8 +724,8 @@ static int fsl_ifc_attach_chip(struct nand_chip *chip) chip->page_shift);dev_dbg (priv->dev,"%s: nand->phys_erase_shift = %d\n" , __func__, chip->phys_erase_shift); -dev_dbg (priv->dev,"%s: nand->ecc.mode = %d\n" , __func__, - chip->ecc.mode); +dev_dbg (priv->dev,"%s: nand->ecc.engine_type = %d\n" , __func__, + chip->ecc.engine_type);dev_dbg (priv->dev,"%s: nand->ecc.steps = %d\n" , __func__, chip->ecc.steps); dev_dbg(priv->dev, "%s: nand->ecc.bytes = %d\n", __func__,
@@ -912,7 +912,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)/* Must also set CSOR_NAND_ECC_ENC_EN if DEC_EN set */ if (csor &CSOR_NAND_ECC_DEC_EN ) { - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ;mtd_set_ooblayout (mtd, &fsl_ifc_ooblayout_ops);/* Hardware generates ECC per 512 Bytes */
@@ -925,7 +925,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) chip->ecc.strength =8 ; } }else { - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; }
drivers/mtd/nand/raw/fsl_upm.c +1 -1
@@ -163,7 +163,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun, fun->chip.legacy.read_byte = fun_read_byte; fun->chip.legacy.read_buf = fun_read_buf; fun->chip.legacy.write_buf = fun_write_buf; - fun->chip.ecc.mode =NAND_ECC_SOFT ; + fun->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; fun->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;if (fun->mchip_count >1 ) fun->chip.legacy.select_chip = fun_select_chip;
drivers/mtd/nand/raw/fsmc_nand.c +6 -6
@@ -900,8 +900,8 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand)return 0 ; } -switch (nand->ecc.mode) { -case NAND_ECC_HW : +switch (nand->ecc.engine_type) { +case NAND_ECC_ENGINE_TYPE_ON_HOST :dev_info (host->dev,"Using 1-bit HW ECC scheme\n" ); nand->ecc.calculate = fsmc_read_hwecc_ecc1; nand->ecc.correct = nand_correct_data;
@@ -910,14 +910,14 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand) nand->ecc.options |=NAND_ECC_SOFT_HAMMING_SM_ORDER ;break ; -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_SOFT :if (nand->ecc.algo ==NAND_ECC_ALGO_BCH ) {dev_info (host->dev,"Using 4-bit SW BCH ECC scheme\n" );break ; } -case NAND_ECC_ON_DIE : +case NAND_ECC_ENGINE_TYPE_ON_DIE :break ;default :
@@ -929,7 +929,7 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand)* Don't set layout for BCH4 SW ECC. This will be * generated later in nand_bch_init() later. */ -if (nand->ecc.mode ==NAND_ECC_HW ) { +if (nand->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) {switch (mtd->oobsize) {case 16 :case 64 :
@@ -1059,7 +1059,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)* Setup default ECC mode. nand_dt_init() called from nand_scan_ident() * can overwrite this value if the DT provides a different value. */ - nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; nand->ecc.hwctl = fsmc_enable_hwecc; nand->ecc.size =512 ; nand->badblockbits =7 ;
drivers/mtd/nand/raw/gpio.c +1 -1
@@ -275,7 +275,7 @@ static int gpio_nand_probe(struct platform_device *pdev)nand_set_flash_node (chip, pdev->dev.of_node); chip->legacy.IO_ADDR_W = chip->legacy.IO_ADDR_R; - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; chip->options = gpiomtd->plat.options; chip->legacy.chip_delay = gpiomtd->plat.chip_delay;
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -1
@@ -2032,7 +2032,7 @@ static int gpmi_init_last(struct gpmi_nand_data *this) ecc->write_page_raw = gpmi_ecc_write_page_raw; ecc->read_oob_raw = gpmi_ecc_read_oob_raw; ecc->write_oob_raw = gpmi_ecc_write_oob_raw; - ecc->mode =NAND_ECC_HW ; + ecc->engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; ecc->size = bch_geo->ecc_chunk_size; ecc->strength = bch_geo->ecc_strength;mtd_set_ooblayout (mtd, &gpmi_ooblayout_ops);
drivers/mtd/nand/raw/hisi504_nand.c +3 -3
@@ -186,7 +186,7 @@ static void hisi_nfc_dma_transfer(struct hinfc_host *host, int todev)hinfc_write (host, host->dma_buffer,HINFC504_DMA_ADDR_DATA );hinfc_write (host, host->dma_oob,HINFC504_DMA_ADDR_OOB ); -if (chip->ecc.mode ==NAND_ECC_NONE ) { +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_NONE ) {hinfc_write (host, ((mtd->oobsize &HINFC504_DMA_LEN_OOB_MASK ) <<HINFC504_DMA_LEN_OOB_SHIFT ),HINFC504_DMA_LEN );
@@ -468,7 +468,7 @@ static void hisi_nfc_cmdfunc(struct nand_chip *chip, unsigned command,case NAND_CMD_STATUS : flag =hinfc_read (host,HINFC504_CON ); -if (chip->ecc.mode ==NAND_ECC_HW ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST )hinfc_write (host, flag & ~(HINFC504_CON_ECCTYPE_MASK <<HINFC504_CON_ECCTYPE_SHIFT ),HINFC504_CON );
@@ -721,7 +721,7 @@ static int hisi_nfc_attach_chip(struct nand_chip *chip) }hinfc_write (host, flag,HINFC504_CON ); -if (chip->ecc.mode ==NAND_ECC_HW ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST )hisi_nfc_ecc_probe (host);return 0 ;
drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c +7 -7
@@ -194,8 +194,8 @@ static int ingenic_nand_attach_chip(struct nand_chip *chip) (chip->ecc.strength /8 ); } -switch (chip->ecc.mode) { -case NAND_ECC_HW : +switch (chip->ecc.engine_type) { +case NAND_ECC_ENGINE_TYPE_ON_HOST :if (!nfc->ecc) {dev_err (nfc->dev,"HW ECC selected, but ECC controller not found\n" );return -ENODEV ;
@@ -205,22 +205,22 @@ static int ingenic_nand_attach_chip(struct nand_chip *chip) chip->ecc.calculate = ingenic_nand_ecc_calculate; chip->ecc.correct = ingenic_nand_ecc_correct; fallthrough; -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_SOFT :dev_info (nfc->dev,"using %s (strength %d, size %d, bytes %d)\n" , (nfc->ecc) ?"hardware ECC" :"software ECC" , chip->ecc.strength, chip->ecc.size, chip->ecc.bytes);break ; -case NAND_ECC_NONE : +case NAND_ECC_ENGINE_TYPE_NONE :dev_info (nfc->dev,"not using ECC\n" );break ;default :dev_err (nfc->dev,"ECC mode %d not supported\n" , - chip->ecc.mode); + chip->ecc.engine_type);return -EINVAL ; }/* The NAND core will generate the ECC layout for SW ECC */ -if (chip->ecc.mode !=NAND_ECC_HW ) +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST )return 0 ;/* Generate ECC layout. ECC codes are right aligned in the OOB area. */
@@ -404,7 +404,7 @@ static int ingenic_nand_init_chip(struct platform_device *pdev, mtd->dev.parent = dev; chip->options =NAND_NO_SUBPAGE_WRITE ; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->controller = &nfc->controller;nand_set_flash_node (chip, np);
drivers/mtd/nand/raw/lpc32xx_mlc.c +1 -1
@@ -656,7 +656,7 @@ static int lpc32xx_nand_attach_chip(struct nand_chip *chip)if (!host->dummy_buf)return -ENOMEM ; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ;mtd_set_ooblayout (mtd, &lpc32xx_ooblayout_ops); host->mlcsubpages = mtd->writesize /512 ;
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -1
@@ -881,7 +881,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)platform_set_drvdata (pdev, host);/* NAND callbacks for LPC32xx SLC hardware */ - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; chip->legacy.read_byte = lpc32xx_nand_read_byte; chip->legacy.read_buf = lpc32xx_nand_read_buf;
drivers/mtd/nand/raw/marvell_nand.c +9 -8
@@ -2247,7 +2247,8 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd,struct marvell_nfc *nfc =to_marvell_nfc (chip->controller);int ret; -if (ecc->mode !=NAND_ECC_NONE && (!ecc->size || !ecc->strength)) { +if (ecc->engine_type !=NAND_ECC_ENGINE_TYPE_NONE && + (!ecc->size || !ecc->strength)) {if (chip->base.eccreq.step_size && chip->base.eccreq.strength) { ecc->size = chip->base.eccreq.step_size; ecc->strength = chip->base.eccreq.strength;
@@ -2259,15 +2260,15 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd, } } -switch (ecc->mode) { -case NAND_ECC_HW : +switch (ecc->engine_type) { +case NAND_ECC_ENGINE_TYPE_ON_HOST : ret =marvell_nand_hw_ecc_controller_init (mtd, ecc);if (ret)return ret;break ; -case NAND_ECC_NONE : -case NAND_ECC_SOFT : -case NAND_ECC_ON_DIE : +case NAND_ECC_ENGINE_TYPE_NONE : +case NAND_ECC_ENGINE_TYPE_SOFT : +case NAND_ECC_ENGINE_TYPE_ON_DIE :if (!nfc->caps->is_nfcv2 && mtd->writesize !=SZ_512 && mtd->writesize !=SZ_2K ) { dev_err(nfc->dev, "NFCv1 cannot write %d bytes pages\n",
@@ -2465,7 +2466,7 @@ static int marvell_nand_attach_chip(struct nand_chip *chip)return ret; } -if (chip->ecc.mode ==NAND_ECC_HW ) { +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) {/* * Subpage write not available with hardware ECC, prohibit also * subpage read as in userspace subpage access would still be
@@ -2640,7 +2641,7 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc,* Default to HW ECC engine mode. If the nand-ecc-mode property is given * in the DT node, this entry will be overwritten in nand_scan_ident(). */ - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ;/* * Save a reference value for timing registers before
drivers/mtd/nand/raw/meson_nand.c +1 -1
@@ -1197,7 +1197,7 @@ static int meson_nand_attach_chip(struct nand_chip *nand)if (ret)return -EINVAL ; - nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; nand->ecc.write_page_raw = meson_nfc_write_page_raw; nand->ecc.write_page = meson_nfc_write_page_hwecc; nand->ecc.write_oob_raw = nand_write_oob_std;
drivers/mtd/nand/raw/mpc5121_nfc.c +1 -1
@@ -688,7 +688,7 @@ static int mpc5121_nfc_probe(struct platform_device *op) chip->legacy.set_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp; chip->bbt_options =NAND_BBT_USE_FLASH ; - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* Support external chip-select logic on ADS5121 board */
drivers/mtd/nand/raw/mtk_nand.c +3 -3
@@ -1226,8 +1226,8 @@ static int mtk_nfc_ecc_init(struct device *dev, struct mtd_info *mtd)int free, ret;/* support only ecc hw mode */ -if (nand->ecc.mode !=NAND_ECC_HW ) { -dev_err (dev,"ecc.mode not supported\n" ); +if (nand->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST ) { +dev_err (dev,"ecc.engine_type not supported\n" );return -EINVAL ; }
@@ -1390,7 +1390,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc, nand->legacy.cmd_ctrl = mtk_nfc_cmd_ctrl;/* set default mode in case dt entry is missing */ - nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; nand->ecc.write_subpage = mtk_nfc_write_subpage_hwecc; nand->ecc.write_page_raw = mtk_nfc_write_page_raw;
drivers/mtd/nand/raw/mxc_nand.c +12 -11
@@ -669,7 +669,7 @@ static void mxc_nand_enable_hwecc_v1_v2(struct nand_chip *chip, bool enable)struct mxc_nand_host *host =nand_get_controller_data (chip);uint16_t config1; -if (chip->ecc.mode !=NAND_ECC_HW ) +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST )return ; config1 =readw (NFC_V1_V2_CONFIG1 );
@@ -687,7 +687,7 @@ static void mxc_nand_enable_hwecc_v3(struct nand_chip *chip, bool enable)struct mxc_nand_host *host =nand_get_controller_data (chip);uint32_t config2; -if (chip->ecc.mode !=NAND_ECC_HW ) +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST )return ; config2 =readl (NFC_V3_CONFIG2 );
@@ -1117,7 +1117,8 @@ static void preset_v1(struct mtd_info *mtd)struct mxc_nand_host *host =nand_get_controller_data (nand_chip);uint16_t config1 =0 ; -if (nand_chip->ecc.mode ==NAND_ECC_HW && mtd->writesize) +if (nand_chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST && + mtd->writesize) config1 |=NFC_V1_V2_CONFIG1_ECC_EN ;if (!host->devtype_data->irqpending_quirk)
@@ -1227,7 +1228,7 @@ static void preset_v2(struct mtd_info *mtd)if (mtd->writesize) {uint16_t pages_per_block = mtd->erasesize / mtd->writesize; -if (nand_chip->ecc.mode ==NAND_ECC_HW ) +if (nand_chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) config1 |=NFC_V1_V2_CONFIG1_ECC_EN ; host->eccsize =get_eccsize (mtd);
@@ -1303,7 +1304,7 @@ static void preset_v3(struct mtd_info *mtd) }if (mtd->writesize) { -if (chip->ecc.mode ==NAND_ECC_HW ) +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) config2 |=NFC_V3_CONFIG2_ECC_EN ; config2 |= NFC_V3_CONFIG2_PPB(
@@ -1680,8 +1681,8 @@ static int mxcnd_attach_chip(struct nand_chip *chip)struct mxc_nand_host *host =nand_get_controller_data (chip);struct device *dev = mtd->dev.parent; -switch (chip->ecc.mode) { -case NAND_ECC_HW : +switch (chip->ecc.engine_type) { +case NAND_ECC_ENGINE_TYPE_ON_HOST : chip->ecc.read_page = mxc_nand_read_page; chip->ecc.read_page_raw = mxc_nand_read_page_raw; chip->ecc.read_oob = mxc_nand_read_oob;
@@ -1690,7 +1691,7 @@ static int mxcnd_attach_chip(struct nand_chip *chip) chip->ecc.write_oob = mxc_nand_write_oob;break ; -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_SOFT :break ;default :
@@ -1728,7 +1729,7 @@ static int mxcnd_attach_chip(struct nand_chip *chip)*/ host->used_oobsize =min (mtd->oobsize,218U ); -if (chip->ecc.mode ==NAND_ECC_HW ) { +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) {if (is_imx21_nfc (host) ||is_imx27_nfc (host)) chip->ecc.strength =1 ;else
@@ -1843,9 +1844,9 @@ static int mxcnd_probe(struct platform_device *pdev)mtd_set_ooblayout (mtd, host->devtype_data->ooblayout);if (host->pdata.hw_ecc) { - this->ecc.mode =NAND_ECC_HW ; + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; }else { - this->ecc.mode =NAND_ECC_SOFT ; + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; this->ecc.algo =NAND_ECC_ALGO_HAMMING ; }
drivers/mtd/nand/raw/nand_base.c +49 -29
179 lines not on this page · raw message
drivers/mtd/nand/raw/nand_micron.c +2 -2
@@ -497,13 +497,13 @@ static int micron_nand_init(struct nand_chip *chip) ondie =micron_supports_on_die_ecc (chip);if (ondie ==MICRON_ON_DIE_MANDATORY && - chip->ecc.mode !=NAND_ECC_ON_DIE ) { + chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_DIE ) {pr_err ("On-die ECC forcefully enabled, not supported\n" ); ret = -EINVAL ; goto err_free_manuf_data; } -if (chip->ecc.mode ==NAND_ECC_ON_DIE ) { +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_DIE ) {if (ondie ==MICRON_ON_DIE_UNSUPPORTED ) {pr_err ("On-die ECC selected but not supported\n" ); ret = -EINVAL ;
drivers/mtd/nand/raw/nand_toshiba.c +2 -1
@@ -211,7 +211,8 @@ static int toshiba_nand_init(struct nand_chip *chip) chip->options |=NAND_BBM_FIRSTPAGE |NAND_BBM_SECONDPAGE ;/* Check that chip is BENAND and ECC mode is on-die */ -if (nand_is_slc (chip) && chip->ecc.mode ==NAND_ECC_ON_DIE && +if (nand_is_slc (chip) && + chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_DIE && chip->id.data[4 ] &TOSHIBA_NAND_ID4_IS_BENAND )toshiba_nand_benand_init (chip);
drivers/mtd/nand/raw/nandsim.c +2 -2
@@ -2234,7 +2234,7 @@ static int ns_attach_chip(struct nand_chip *chip)return -EINVAL ; } - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_BCH ; chip->ecc.size =512 ; chip->ecc.strength = bch;
@@ -2274,7 +2274,7 @@ static int __init ns_init_module(void) nsmtd =nand_to_mtd (chip);nand_set_controller_data (chip, (void *)ns); - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ /* and 'badblocks' parameters to work */
drivers/mtd/nand/raw/ndfc.c +1 -1
@@ -149,7 +149,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, chip->ecc.correct = nand_correct_data; chip->ecc.hwctl = ndfc_enable_hwecc; chip->ecc.calculate = ndfc_calculate_ecc; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =256 ; chip->ecc.bytes =3 ; chip->ecc.strength =1 ;
drivers/mtd/nand/raw/omap2.c +10 -10
@@ -884,8 +884,8 @@ static int omap_correct_data(struct nand_chip *chip, u_char *dat,int stat =0 ;/* Ex NAND_ECC_HW12_2048 */ -if ((info->nand.ecc.mode ==NAND_ECC_HW ) && - (info->nand.ecc.size ==2048 )) +if (info->nand.ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST && + info->nand.ecc.size ==2048 ) blockCnt =4 ;else blockCnt =1 ;
@@ -2006,11 +2006,11 @@ static int omap_nand_attach_chip(struct nand_chip *chip)return -EINVAL ;/* -* Bail out earlier to let NAND_ECC_SOFT code create its own +* Bail out earlier to let NAND_ECC_ENGINE_TYPE_SOFT code create its own * ooblayout instead of using ours. */ if (info->ecc_opt ==OMAP_ECC_HAM1_CODE_SW ) { - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;return 0 ; }
@@ -2019,7 +2019,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)switch (info->ecc_opt) {case OMAP_ECC_HAM1_CODE_HW :dev_info (dev,"nand: using OMAP_ECC_HAM1_CODE_HW\n" ); - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.bytes =3 ; chip->ecc.size =512 ; chip->ecc.strength =1 ;
@@ -2036,7 +2036,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW :pr_info ("nand: using OMAP_ECC_BCH4_CODE_HW_DETECTION_SW\n" ); - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ; chip->ecc.bytes =7 ; chip->ecc.strength =4 ;
@@ -2056,7 +2056,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)case OMAP_ECC_BCH4_CODE_HW :pr_info ("nand: using OMAP_ECC_BCH4_CODE_HW ECC scheme\n" ); - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ;/* 14th bit is kept reserved for ROM-code compatibility */ chip->ecc.bytes =7 +1 ;
@@ -2078,7 +2078,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW :pr_info ("nand: using OMAP_ECC_BCH8_CODE_HW_DETECTION_SW\n" ); - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ; chip->ecc.bytes =13 ; chip->ecc.strength =8 ;
@@ -2098,7 +2098,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)case OMAP_ECC_BCH8_CODE_HW :pr_info ("nand: using OMAP_ECC_BCH8_CODE_HW ECC scheme\n" ); - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ;/* 14th bit is kept reserved for ROM-code compatibility */ chip->ecc.bytes =13 +1 ;
@@ -2121,7 +2121,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)case OMAP_ECC_BCH16_CODE_HW :pr_info ("Using OMAP_ECC_BCH16_CODE_HW ECC scheme\n" ); - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ; chip->ecc.bytes =26 ; chip->ecc.strength =16 ;
drivers/mtd/nand/raw/orion_nand.c +1 -1
@@ -139,7 +139,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) nc->legacy.IO_ADDR_R = nc->legacy.IO_ADDR_W = io_base; nc->legacy.cmd_ctrl = orion_nand_cmd_ctrl; nc->legacy.read_buf = orion_nand_read_buf; - nc->ecc.mode =NAND_ECC_SOFT ; + nc->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; nc->ecc.algo =NAND_ECC_ALGO_HAMMING ;if (board->chip_delay)
drivers/mtd/nand/raw/pasemi_nand.c +1 -1
@@ -132,7 +132,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev) chip->legacy.read_buf = pasemi_read_buf; chip->legacy.write_buf = pasemi_write_buf; chip->legacy.chip_delay =0 ; - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* Enable the following for a flash based bad block table */
drivers/mtd/nand/raw/plat_nand.c +1 -1
@@ -66,7 +66,7 @@ static int plat_nand_probe(struct platform_device *pdev) data->chip.options |= pdata->chip.options; data->chip.bbt_options |= pdata->chip.bbt_options; - data->chip.ecc.mode =NAND_ECC_SOFT ; + data->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; data->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;platform_set_drvdata (pdev, data);
drivers/mtd/nand/raw/qcom_nandc.c +1 -1
@@ -2548,7 +2548,7 @@ static int qcom_nand_attach_chip(struct nand_chip *chip) ecc->write_page_raw = qcom_nandc_write_page_raw; ecc->write_oob = qcom_nandc_write_oob; - ecc->mode =NAND_ECC_HW ; + ecc->engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ;mtd_set_ooblayout (mtd, &qcom_nand_ooblayout_ops);
drivers/mtd/nand/raw/r852.c +1 -1
@@ -859,7 +859,7 @@ static int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) chip->legacy.write_buf = r852_write_buf;/* ecc */ - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.placement =NAND_ECC_PLACEMENT_INTERLEAVED ; chip->ecc.size =R852_DMA_LEN ; chip->ecc.bytes =SM_OOB_SIZE ;
drivers/mtd/nand/raw/s3c2410.c +9 -9
@@ -904,7 +904,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, nmtd->info = info; nmtd->set = set; - chip->ecc.mode = info->platform->ecc_mode; + chip->ecc.engine_type = info->platform->engine_type;/* * If you use u-boot BBT creation code, specifying this flag will
@@ -929,24 +929,24 @@ static int s3c2410_nand_attach_chip(struct nand_chip *chip)struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd); -switch (chip->ecc.mode) { +switch (chip->ecc.engine_type) { -case NAND_ECC_NONE : +case NAND_ECC_ENGINE_TYPE_NONE :dev_info (info->device,"ECC disabled\n" );break ; -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_SOFT :/* -* This driver expects Hamming based ECC when ecc_mode is set -* to NAND_ECC_SOFT. Force ecc.algo to NAND_ECC_ALGO_HAMMING to -* avoid adding an extra ecc_algo field to -* s3c2410_platform_nand. +* This driver expects Hamming based ECC when engine_type is set +* to NAND_ECC_ENGINE_TYPE_SOFT. Force ecc.algo to +* NAND_ECC_ALGO_HAMMING to avoid adding an extra ecc_algo field +* to s3c2410_platform_nand. */ chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;dev_info (info->device,"soft ECC\n" );break ; -case NAND_ECC_HW : +case NAND_ECC_ENGINE_TYPE_ON_HOST : chip->ecc.calculate = s3c2410_nand_calculate_ecc; chip->ecc.correct = s3c2410_nand_correct_data; chip->ecc.strength =1 ;
drivers/mtd/nand/raw/sh_flctl.c +2 -2
@@ -1039,12 +1039,12 @@ static int flctl_chip_attach_chip(struct nand_chip *chip) chip->ecc.strength =4 ; chip->ecc.read_page = flctl_read_page_hwecc; chip->ecc.write_page = flctl_write_page_hwecc; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ;/* 4 symbols ECC enabled */ flctl->flcmncr_base |= _4ECCEN; }else { - chip->ecc.mode =NAND_ECC_SOFT ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; chip->ecc.algo =NAND_ECC_ALGO_HAMMING ; }
drivers/mtd/nand/raw/sharpsl.c +1 -1
@@ -157,7 +157,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)/* 15 us command delay time */ this->legacy.chip_delay =15 ;/* set eccmode using hardware ECC */ - this->ecc.mode =NAND_ECC_HW ; + this->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; this->ecc.size =256 ; this->ecc.bytes =3 ; this->ecc.strength =1 ;
drivers/mtd/nand/raw/socrates_nand.c +2 -1
@@ -153,7 +153,8 @@ static int socrates_nand_probe(struct platform_device *ofdev) nand_chip->legacy.read_buf = socrates_nand_read_buf; nand_chip->legacy.dev_ready = socrates_nand_device_ready; - nand_chip->ecc.mode =NAND_ECC_SOFT ;/* enable ECC */ +/* enable ECC */ + nand_chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; nand_chip->ecc.algo =NAND_ECC_ALGO_HAMMING ;/* TODO: I have no idea what real delay is. */
drivers/mtd/nand/raw/stm32_fmc2_nand.c +5 -4
@@ -1725,14 +1725,15 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)int ret;/* -* Only NAND_ECC_HW mode is actually supported +* Only NAND_ECC_ENGINE_TYPE_ON_HOST mode is actually supported * Hamming => ecc.strength = 1 * BCH4 => ecc.strength = 4 * BCH8 => ecc.strength = 8 * ECC sector size = 512 */ -if (chip->ecc.mode !=NAND_ECC_HW ) { -dev_err (nfc->dev,"nand_ecc_mode is not well defined in the DT\n" ); +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST ) { +dev_err (nfc->dev, +"nand_ecc_engine_type is not well defined in the DT\n" );return -EINVAL ; }
@@ -1942,7 +1943,7 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)NAND_USES_DMA ;/* Default ECC settings */ - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =FMC2_ECC_STEP_SIZE ; chip->ecc.strength =FMC2_ECC_BCH8 ;
drivers/mtd/nand/raw/sunxi_nand.c +9 -9
@@ -1575,7 +1575,7 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,* only have 2 bytes available in the first user data * section. */ -if (!section && ecc->mode ==NAND_ECC_HW ) { +if (!section && ecc->engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) { oobregion->offset =2 ; oobregion->length =2 ;
@@ -1720,11 +1720,11 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,static void sunxi_nand_ecc_cleanup (struct nand_ecc_ctrl *ecc) { -switch (ecc->mode) { -case NAND_ECC_HW : +switch (ecc->engine_type) { +case NAND_ECC_ENGINE_TYPE_ON_HOST :sunxi_nand_hw_ecc_ctrl_cleanup (ecc);break ; -case NAND_ECC_NONE : +case NAND_ECC_ENGINE_TYPE_NONE :default :break ; }
@@ -1752,14 +1752,14 @@ static int sunxi_nand_attach_chip(struct nand_chip *nand)if (!ecc->size || !ecc->strength)return -EINVAL ; -switch (ecc->mode) { -case NAND_ECC_HW : +switch (ecc->engine_type) { +case NAND_ECC_ENGINE_TYPE_ON_HOST : ret =sunxi_nand_hw_ecc_ctrl_init (nand, ecc, np);if (ret)return ret;break ; -case NAND_ECC_NONE : -case NAND_ECC_SOFT : +case NAND_ECC_ENGINE_TYPE_NONE : +case NAND_ECC_ENGINE_TYPE_SOFT :break ;default :return -EINVAL ;
@@ -1991,7 +1991,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,* Set the ECC mode to the default value in case nothing is specified * in the DT. */ - nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ;nand_set_flash_node (nand, np); mtd =nand_to_mtd (nand);
drivers/mtd/nand/raw/tango_nand.c +1 -1
@@ -511,7 +511,7 @@ static int tango_attach_chip(struct nand_chip *chip) {struct nand_ecc_ctrl *ecc = &chip->ecc; - ecc->mode =NAND_ECC_HW ; + ecc->engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; ecc->algo =NAND_ECC_ALGO_BCH ; ecc->bytes =DIV_ROUND_UP (ecc->strength *FIELD_ORDER ,BITS_PER_BYTE );
drivers/mtd/nand/raw/tegra_nand.c +1 -1
@@ -916,7 +916,7 @@ static int tegra_nand_attach_chip(struct nand_chip *chip)if (chip->bbt_options &NAND_BBT_USE_FLASH ) chip->bbt_options |=NAND_BBT_NO_OOB ; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ; chip->ecc.steps = mtd->writesize / chip->ecc.size;if (chip->base.eccreq.step_size !=512 ) {
drivers/mtd/nand/raw/tmio_nand.c +1 -1
@@ -410,7 +410,7 @@ static int tmio_probe(struct platform_device *dev) nand_chip->legacy.read_buf = tmio_nand_read_buf;/* set eccmode using hardware ECC */ - nand_chip->ecc.mode =NAND_ECC_HW ; + nand_chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; nand_chip->ecc.size =512 ; nand_chip->ecc.bytes =6 ; nand_chip->ecc.strength =2 ;
drivers/mtd/nand/raw/txx9ndfmc.c +1 -1
@@ -329,7 +329,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev) chip->ecc.calculate = txx9ndfmc_calculate_ecc; chip->ecc.correct = txx9ndfmc_correct_data; chip->ecc.hwctl = txx9ndfmc_enable_hwecc; - chip->ecc.mode =NAND_ECC_HW ; + chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.strength =1 ; chip->legacy.chip_delay =100 ; chip->controller = &drvdata->controller;
drivers/mtd/nand/raw/vf610_nfc.c +2 -2
@@ -732,7 +732,7 @@ static void vf610_nfc_init_controller(struct vf610_nfc *nfc)else vf610_nfc_clear (nfc,NFC_FLASH_CONFIG ,CONFIG_16BIT ); -if (nfc->chip.ecc.mode ==NAND_ECC_HW ) { +if (nfc->chip.ecc.engine_type ==NAND_ECC_ENGINE_TYPE_ON_HOST ) {/* Set ECC status offset in SRAM */ vf610_nfc_set_field(nfc, NFC_FLASH_CONFIG, CONFIG_ECC_SRAM_ADDR_MASK,
@@ -761,7 +761,7 @@ static int vf610_nfc_attach_chip(struct nand_chip *chip)return -ENXIO ; } -if (chip->ecc.mode !=NAND_ECC_HW ) +if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_ON_HOST )return 0 ;if (mtd->writesize !=PAGE_2K && mtd->oobsize <64 ) {
drivers/mtd/nand/raw/xway_nand.c +1 -1
@@ -180,7 +180,7 @@ static int xway_nand_probe(struct platform_device *pdev) data->chip.legacy.read_byte = xway_read_byte; data->chip.legacy.chip_delay =30 ; - data->chip.ecc.mode =NAND_ECC_SOFT ; + data->chip.ecc.engine_type =NAND_ECC_ENGINE_TYPE_SOFT ; data->chip.ecc.algo =NAND_ECC_ALGO_HAMMING ;platform_set_drvdata (pdev, data);
include/linux/mtd/rawnand.h +2 -2
@@ -347,7 +347,7 @@ static const struct nand_ecc_caps __name = { \/** * struct nand_ecc_ctrl - Control structure for ECC -* @mode: ECC mode +* @engine_type: ECC engine type * @placement: OOB bytes placement * @algo: ECC algorithm * @steps: number of ECC steps per page
@@ -400,7 +400,7 @@ static const struct nand_ecc_caps __name = { \* @write_oob: function to write chip OOB data */ struct nand_ecc_ctrl { -enum nand_ecc_mode mode; +enum nand_ecc_engine_type engine_type;enum nand_ecc_placement placement;enum nand_ecc_algo algo;int steps;
include/linux/platform_data/mtd-davinci.h +4 -4
@@ -60,15 +60,15 @@ struct davinci_nand_pdata { /* platform_data */struct mtd_partition *parts;unsigned nr_parts; -/* none == NAND_ECC_NONE (strongly *not* advised!!) -* soft == NAND_ECC_SOFT -* else == NAND_ECC_HW, according to ecc_bits +/* none == NAND_ECC_ENGINE_TYPE_NONE (strongly *not* advised!!) +* soft == NAND_ECC_ENGINE_TYPE_SOFT +* else == NAND_ECC_ENGINE_TYPE_ON_HOST, according to ecc_bits * * All DaVinci-family chips support 1-bit hardware ECC. * Newer ones also support 4-bit ECC, but are awkward * using it with large page chips. */ -enum nand_ecc_mode ecc_mode; +enum nand_ecc_engine_type engine_type;enum nand_ecc_placement ecc_placement;u8 ecc_bits;
include/linux/platform_data/mtd-nand-s3c2410.h +1 -1
@@ -49,7 +49,7 @@ struct s3c2410_platform_nand { unsigned int ignore_unset_ecc:1; -enum nand_ecc_mode ecc_mode; +enum nand_ecc_engine_type engine_type;int nr_sets;struct s3c2410_nand_set *sets;
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 9/20 mtd: nand: Move nand_device forward declaration to the top
In reply to Miquel RaynalThis structure might be used earlier in this file, let's move the forward declaration at the top.
--- include/linux/mtd/nand.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mtd/nand.h +2 -2
@@ -12,6 +12,8 @@#include <linux/mtd/mtd.h> +struct nand_device ; +/** * struct nand_memory_organization - Memory organization structure * @bits_per_cell: number of bits per NAND cell
@@ -133,8 +135,6 @@ struct nand_bbt {unsigned long *cache; }; -struct nand_device ; -/** * struct nand_ops - NAND operations * @erase: erase a specific block. No need to check if the block is bad before
Signature · 1 line
2.20.1
Re: [PATCH v7 09/20] mtd: nand: Move nand_device forward declaration to the top
Quoted 5 lines · Miquel Raynal
This structure might be used earlier in this file, let's move the forward declaration at the top.
Signed-off-by Miquel Raynal <[email protected]>Reviewed-by Boris Brezillon <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.
Miquel
Miquel Raynal
maintainerPATCH v7 10/20 mtd: nand: Add an extra level in the Kconfig hierarchy
In reply to Miquel RaynalUse an extra level in Kconfig for all NAND related entries.
--- drivers/mtd/nand/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/nand/Kconfig +5 -0
@@ -1,7 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only + +menu "NAND" + config MTD_NAND_CORE tristate source "drivers/mtd/nand/onenand/Kconfig" source "drivers/mtd/nand/raw/Kconfig" source "drivers/mtd/nand/spi/Kconfig" + +endmenu
Signature · 1 line
2.20.1
Re: [PATCH v7 10/20] mtd: nand: Add an extra level in the Kconfig hierarchy
Quoted 4 lines · Miquel Raynal
Use an extra level in
Kconfigfor all NAND related entries.Signed-off-by Miquel Raynal <[email protected]>Reviewed-by Boris Brezillon <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.
Miquel
Miquel Raynal
maintainerPATCH v7 11/20 mtd: nand: Drop useless 'depends on' in Kconfig
In reply to Miquel RaynalBoth OneNAND and raw NAND bits can't be compiled if MTD is disabled because of the if/endif logic in drivers/mtd/Kconfig. There is no need for an extra "depends on MTD" in their respective Kconfig files.
--- drivers/mtd/nand/onenand/Kconfig | 1 - drivers/mtd/nand/raw/Kconfig | 1 - 2 files changed, 2 deletions(-)
drivers/mtd/nand/onenand/Kconfig +0 -1
@@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig MTD_ONENAND tristate "OneNAND Device Support" - depends on MTD depends on HAS_IOMEM help This enables support for accessing all type of OneNAND flash
drivers/mtd/nand/raw/Kconfig +0 -1
@@ -12,7 +12,6 @@ config MTD_NAND_ECC_SW_HAMMING_SMC menuconfig MTD_RAW_NAND tristate "Raw/Parallel NAND Device Support" - depends on MTD select MTD_NAND_CORE select MTD_NAND_ECC_SW_HAMMING help
Signature · 1 line
2.20.1
Re: [PATCH v7 11/20] mtd: nand: Drop useless 'depends on' in Kconfig
Quoted 6 lines · Miquel Raynal
Both OneNAND and raw NAND bits can't be compiled if MTD is disabled because of the if/endif logic in
drivers/mtd/Kconfig. There is no need for an extra "depends on MTD" in their respectiveKconfigfiles.Signed-off-by Miquel Raynal <[email protected]>Reviewed-by Boris Brezillon <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.
Miquel
Miquel Raynal
maintainerPATCH v7 12/20 mtd: nand: Add a NAND page I/O request type
In reply to Miquel RaynalUse an enum to differentiate the type of I/O (reading or writing a page). Also update the request iterator.
--- drivers/mtd/nand/spi/core.c | 4 ++-- include/linux/mtd/nand.h | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/mtd/nand/spi/core.c +2 -2
@@ -497,7 +497,7 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,mutex_lock (&spinand->lock); -nanddev_io_for_each_page (nand, from, ops, &iter) { +nanddev_io_for_each_page (nand,NAND_PAGE_READ , from, ops, &iter) { ret =spinand_select_target (spinand, iter.req.pos.target);if (ret)break ;
@@ -545,7 +545,7 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,mutex_lock (&spinand->lock); -nanddev_io_for_each_page (nand, to, ops, &iter) { +nanddev_io_for_each_page (nand,NAND_PAGE_WRITE , to, ops, &iter) { ret =spinand_select_target (spinand, iter.req.pos.target);if (ret)break ;
include/linux/mtd/nand.h +16 -2
@@ -82,8 +82,19 @@ struct nand_pos {unsigned int page; }; +/** +* enum nand_page_io_req_type - Direction of an I/O request +* @NAND_PAGE_READ: from the chip, to the controller +* @NAND_PAGE_WRITE: from the controller, to the chip +*/ +enum nand_page_io_req_type { +NAND_PAGE_READ =0 , +NAND_PAGE_WRITE , +}; +/** * struct nand_page_io_req - NAND I/O request object +* @type: the type of page I/O: read or write * @pos: the position this I/O request is targeting * @dataoffs: the offset within the page * @datalen: number of data bytes to read from/write to this page
@@ -99,6 +110,7 @@ struct nand_pos {* specific commands/operations. */ struct nand_page_io_req { +enum nand_page_io_req_type type;struct nand_pos pos;unsigned int dataoffs;unsigned int datalen;
@@ -624,11 +636,13 @@ static inline void nanddev_pos_next_page(struct nand_device *nand,* layer. */ static inline void nanddev_io_iter_init (struct nand_device *nand, +enum nand_page_io_req_type reqtype,loff_t offs,struct mtd_oob_ops *req,struct nand_io_iter *iter) {struct mtd_info *mtd =nanddev_to_mtd (nand); + iter->req.type = reqtype; iter->req.mode = req->mode; iter->req.dataoffs =nanddev_offs_to_pos (nand, offs, &iter->req.pos); iter->req.ooboffs = req->ooboffs;
@@ -698,8 +712,8 @@ static inline bool nanddev_io_iter_end(struct nand_device *nand,* * Should be used for iterate over pages that are contained in an MTD request. */ -#define nanddev_io_for_each_page (nand, start, req, iter) \ - for (nanddev_io_iter_init(nand, start, req, iter); \ +#define nanddev_io_for_each_page (nand, type, start, req, iter) \ + for (nanddev_io_iter_init(nand, type, start, req, iter); \ !nanddev_io_iter_end(nand, iter); \ nanddev_io_iter_next_page(nand, iter))
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 13/20 mtd: nand: Rename a core structure
In reply to Miquel RaynalPrepare the migration to a generic ECC engine by renaming the nand_ecc_req structure into nand_ecc_props. This structure will be the base of a wider 'nand_ecc' structure.
In nand_device, these properties are still named "eccreq" even if "eccprops" might be more descriptive. This is just a transition step, this field is being replaced very soon by a much wider structure. The impact of renaming this field would be huge compared to its interest.
--- include/linux/mtd/nand.h | 8 ++++---- include/linux/mtd/spinand.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
include/linux/mtd/nand.h +4 -4
@@ -128,11 +128,11 @@ struct nand_page_io_req { };/** -* struct nand_ecc_req - NAND ECC requirements +* struct nand_ecc_props - NAND ECC properties * @strength: ECC strength -* @step_size: ECC step/block size +* @step_size: Number of bytes per step */ -struct nand_ecc_req { +struct nand_ecc_props {unsigned int strength;unsigned int step_size; };
@@ -191,7 +191,7 @@ struct nand_ops {struct nand_device {struct mtd_info mtd;struct nand_memory_organization memorg; -struct nand_ecc_req eccreq; +struct nand_ecc_props eccreq;struct nand_row_converter rowconv;struct nand_bbt bbt;const struct nand_ops *ops;
include/linux/mtd/spinand.h +1 -1
@@ -309,7 +309,7 @@ struct spinand_info {struct spinand_devid devid;u32 flags;struct nand_memory_organization memorg; -struct nand_ecc_req eccreq; +struct nand_ecc_props eccreq;struct spinand_ecc_info eccinfo;struct {const struct spinand_op_variants *read_cache;
Signature · 1 line
2.20.1
Re: [PATCH v7 13/20] mtd: nand: Rename a core structure
Quoted 11 lines · Miquel Raynal
Prepare the migration to a generic ECC engine by renaming the
nand_ecc_reqstructure intonand_ecc_props. This structure will be the base of a wider 'nand_ecc' structure.In
nand_device, these properties are still named "eccreq" even if "eccprops" might be more descriptive. This is just a transition step, this field is being replaced very soon by a much wider structure. The impact of renaming this field would be huge compared to its interest.Signed-off-by Miquel Raynal <[email protected]>Reviewed-by Boris Brezillon <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.
Miquel
Miquel Raynal
maintainerPATCH v7 14/20 mtd: nand: Add more parameters to the nand_ecc_props structure
In reply to Miquel RaynalPrepare the migration to the generic ECC framework by adding more fields to the nand_ecc_props structure which will be used widely to describe different kind of ECC properties.
Doing this imposes to move the engine type, ECC placement and algorithm enumerations in a shared place: nand.h.
--- include/linux/mtd/nand.h | 50 +++++++++++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 44 -------------------------------- 2 files changed, 50 insertions(+), 44 deletions(-)
include/linux/mtd/nand.h +50 -0
@@ -127,12 +127,62 @@ struct nand_page_io_req {int mode; }; +/** +* enum nand_ecc_engine_type - NAND ECC engine type +* @NAND_ECC_ENGINE_TYPE_INVALID: Invalid value +* @NAND_ECC_ENGINE_TYPE_NONE: No ECC correction +* @NAND_ECC_ENGINE_TYPE_SOFT: Software ECC correction +* @NAND_ECC_ENGINE_TYPE_ON_HOST: On host hardware ECC correction +* @NAND_ECC_ENGINE_TYPE_ON_DIE: On chip hardware ECC correction +*/ +enum nand_ecc_engine_type { +NAND_ECC_ENGINE_TYPE_INVALID , +NAND_ECC_ENGINE_TYPE_NONE , +NAND_ECC_ENGINE_TYPE_SOFT , +NAND_ECC_ENGINE_TYPE_ON_HOST , +NAND_ECC_ENGINE_TYPE_ON_DIE , +}; + +/** +* enum nand_ecc_placement - NAND ECC bytes placement +* @NAND_ECC_PLACEMENT_UNKNOWN: The actual position of the ECC bytes is unknown +* @NAND_ECC_PLACEMENT_OOB: The ECC bytes are located in the OOB area +* @NAND_ECC_PLACEMENT_INTERLEAVED: Syndrome layout, there are ECC bytes +* interleaved with regular data in the main +* area +*/ +enum nand_ecc_placement { +NAND_ECC_PLACEMENT_UNKNOWN , +NAND_ECC_PLACEMENT_OOB , +NAND_ECC_PLACEMENT_INTERLEAVED , +}; + +/** +* enum nand_ecc_algo - NAND ECC algorithm +* @NAND_ECC_ALGO_UNKNOWN: Unknown algorithm +* @NAND_ECC_ALGO_HAMMING: Hamming algorithm +* @NAND_ECC_ALGO_BCH: Bose-Chaudhuri-Hocquenghem algorithm +* @NAND_ECC_ALGO_RS: Reed-Solomon algorithm +*/ +enum nand_ecc_algo { +NAND_ECC_ALGO_UNKNOWN , +NAND_ECC_ALGO_HAMMING , +NAND_ECC_ALGO_BCH , +NAND_ECC_ALGO_RS , +}; +/** * struct nand_ecc_props - NAND ECC properties +* @engine_type: ECC engine type +* @placement: OOB placement (if relevant) +* @algo: ECC algorithm (if relevant) * @strength: ECC strength * @step_size: Number of bytes per step */ struct nand_ecc_props { +enum nand_ecc_engine_type engine_type; +enum nand_ecc_placement placement; +enum nand_ecc_algo algo;unsigned int strength;unsigned int step_size; };
include/linux/mtd/rawnand.h +0 -44
50 lines not on this page · raw message
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 15/20 mtd: nand: Introduce the ECC engine abstraction
In reply to Miquel RaynalCreate a generic ECC engine object.
Later the ecc.c file will receive more generic code coming from the raw NAND specific part. This is a base to instantiate ECC engine objects.
--- drivers/mtd/nand/Kconfig | 8 ++ drivers/mtd/nand/Makefile | 2 + drivers/mtd/nand/ecc.c | 157 ++++++++++++++++++++++++++++++++++++++ include/linux/mtd/nand.h | 67 ++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 drivers/mtd/nand/ecc.c
drivers/mtd/nand/Kconfig +8 -0
@@ -9,4 +9,12 @@ source "drivers/mtd/nand/onenand/Kconfig" source "drivers/mtd/nand/raw/Kconfig" source "drivers/mtd/nand/spi/Kconfig" +menu "ECC engine support" + +config MTD_NAND_ECC + bool + depends on MTD_NAND_CORE + +endmenu + endmenu
drivers/mtd/nand/Makefile +2 -0
@@ -6,3 +6,5 @@ obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o obj-y += onenand/ obj-y += raw/ obj-y += spi/ + +nandcore-$(CONFIG_MTD_NAND_ECC) += ecc.o
drivers/mtd/nand/ecc.c new file +157 -0
157 lines not on this page · raw message
include/linux/mtd/nand.h +67 -0
73 lines not on this page · raw message
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 16/20 mtd: nand: Convert generic NAND bits to use the ECC framework
In reply to Miquel RaynalEmbed a generic NAND ECC high-level object in the nand_device structure to carry all the ECC engine configuration/data. Adapt the raw NAND and SPI-NAND cores to fit the change.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 9 +++-- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 7 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 12 +++--- drivers/mtd/nand/raw/marvell_nand.c | 7 ++-- drivers/mtd/nand/raw/mtk_nand.c | 4 +- drivers/mtd/nand/raw/nand_base.c | 25 ++++++------ drivers/mtd/nand/raw/nand_esmt.c | 11 +++--- drivers/mtd/nand/raw/nand_hynix.c | 41 ++++++++++---------- drivers/mtd/nand/raw/nand_jedec.c | 4 +- drivers/mtd/nand/raw/nand_micron.c | 14 ++++--- drivers/mtd/nand/raw/nand_onfi.c | 8 ++-- drivers/mtd/nand/raw/nand_samsung.c | 19 ++++----- drivers/mtd/nand/raw/nand_toshiba.c | 11 +++--- drivers/mtd/nand/raw/sunxi_nand.c | 5 ++- drivers/mtd/nand/raw/tegra_nand.c | 9 +++-- drivers/mtd/nand/spi/core.c | 8 ++-- drivers/mtd/nand/spi/macronix.c | 6 +-- drivers/mtd/nand/spi/toshiba.c | 6 +-- include/linux/mtd/nand.h | 8 ++-- 19 files changed, 114 insertions(+), 100 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +5 -4
@@ -1043,6 +1043,7 @@ static int atmel_hsmc_nand_pmecc_read_page_raw(struct nand_chip *chip,static int atmel_nand_pmecc_init (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_nand_controller *nc;
@@ -1072,15 +1073,15 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip) req.ecc.strength =ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH ; else if (chip->ecc.strength) req.ecc.strength = chip->ecc.strength; - else if (chip->base.eccreq.strength) - req.ecc.strength = chip->base.eccreq.strength; + else if (requirements->strength) + req.ecc.strength = requirements->strength; else req.ecc.strength = ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH;if (chip->ecc.size) req.ecc.sectorsize = chip->ecc.size; -else if (chip->base.eccreq.step_size) - req.ecc.sectorsize = chip->base.eccreq.step_size; +else if (requirements->step_size) + req.ecc.sectorsize = requirements->step_size;else req.ecc.sectorsize =ATMEL_PMECC_SECTOR_SIZE_AUTO ;
drivers/mtd/nand/raw/brcmnand/brcmnand.c +4 -3
@@ -2563,10 +2563,11 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_NONE && (!chip->ecc.size || !chip->ecc.strength)) { -if (chip->base.eccreq.step_size && chip->base.eccreq.strength) { +if (chip->base.ecc.requirements.step_size && + chip->base.ecc.requirements.strength) {/* use detected ECC parameters */ - chip->ecc.size = chip->base.eccreq.step_size; - chip->ecc.strength = chip->base.eccreq.strength; + chip->ecc.size = chip->base.ecc.requirements.step_size; + chip->ecc.strength = chip->base.ecc.requirements.strength;dev_info (ctrl->dev,"Using ECC step-size %d, strength %d\n" , chip->ecc.size, chip->ecc.strength); }
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +6 -6
@@ -272,8 +272,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,default :dev_err (this->dev,"unsupported nand chip. ecc bits : %d, ecc size : %d\n" , - chip->base.eccreq.strength, - chip->base.eccreq.step_size); + chip->base.ecc.requirements.strength, + chip->base.ecc.requirements.step_size);return -EINVAL ; } geo->ecc_chunk_size = ecc_step;
@@ -517,13 +517,13 @@ static int common_nfc_set_geometry(struct gpmi_nand_data *this)if ((of_property_read_bool (this->dev->of_node,"fsl,use-minimum-ecc" )) ||legacy_set_geometry (this)) { -if (!(chip->base.eccreq.strength >0 && - chip->base.eccreq.step_size >0 )) +if (!(chip->base.ecc.requirements.strength >0 && + chip->base.ecc.requirements.step_size >0 ))return -EINVAL ;return set_geometry_by_ecc_info (this, - chip->base.eccreq.strength, - chip->base.eccreq.step_size); + chip->base.ecc.requirements.strength, + chip->base.ecc.requirements.step_size); }return 0 ;
drivers/mtd/nand/raw/marvell_nand.c +4 -3
@@ -2244,14 +2244,15 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc) {struct nand_chip *chip =mtd_to_nand (mtd); +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct marvell_nfc *nfc =to_marvell_nfc (chip->controller);int ret;if (ecc->engine_type !=NAND_ECC_ENGINE_TYPE_NONE && (!ecc->size || !ecc->strength)) { -if (chip->base.eccreq.step_size && chip->base.eccreq.strength) { - ecc->size = chip->base.eccreq.step_size; - ecc->strength = chip->base.eccreq.strength; +if (requirements->step_size && requirements->strength) { + ecc->size = requirements->step_size; + ecc->strength = requirements->strength; }else {dev_info (nfc->dev,"No minimum ECC strength, using 1b/512B\n" );
drivers/mtd/nand/raw/mtk_nand.c +2 -2
@@ -1234,8 +1234,8 @@ static int mtk_nfc_ecc_init(struct device *dev, struct mtd_info *mtd)/* if optional dt settings not present */ if (!nand->ecc.size || !nand->ecc.strength) {/* use datasheet requirements */ - nand->ecc.strength = nand->base.eccreq.strength; - nand->ecc.size = nand->base.eccreq.step_size; + nand->ecc.strength = nand->base.ecc.requirements.strength; + nand->ecc.size = nand->base.ecc.requirements.step_size;/* * align eccstrength and eccsize
drivers/mtd/nand/raw/nand_base.c +14 -11
@@ -4746,8 +4746,8 @@ static bool find_full_id_nand(struct nand_chip *chip, memorg->pagesize * memorg->pages_per_eraseblock); chip->options |= type->options; - chip->base.eccreq.strength =NAND_ECC_STRENGTH (type); - chip->base.eccreq.step_size =NAND_ECC_STEP (type); + chip->base.ecc.requirements.strength =NAND_ECC_STRENGTH (type); + chip->base.ecc.requirements.step_size =NAND_ECC_STEP (type); chip->onfi_timing_mode_default = type->onfi_timing_mode_default;
@@ -5485,8 +5485,8 @@ nand_match_ecc_req(struct nand_chip *chip, {struct mtd_info *mtd =nand_to_mtd (chip);const struct nand_ecc_step_info *stepinfo; -int req_step = chip->base.eccreq.step_size; -int req_strength = chip->base.eccreq.strength; +int req_step = chip->base.ecc.requirements.step_size; +int req_strength = chip->base.ecc.requirements.strength;int req_corr, step_size, strength, nsteps, ecc_bytes, ecc_bytes_total;int best_step, best_strength, best_ecc_bytes;int best_ecc_bytes_total =INT_MAX ;
@@ -5677,9 +5677,10 @@ static bool nand_ecc_strength_good(struct nand_chip *chip) {struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc; +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;int corr, ds_corr; -if (ecc->size ==0 || chip->base.eccreq.step_size ==0 ) +if (ecc->size ==0 || requirements->step_size ==0 )/* Not enough information */ return true;
@@ -5688,10 +5689,10 @@ static bool nand_ecc_strength_good(struct nand_chip *chip)* the correction density. */ corr = (mtd->writesize * ecc->strength) / ecc->size; - ds_corr = (mtd->writesize * chip->base.eccreq.strength) / - chip->base.eccreq.step_size; + ds_corr = (mtd->writesize * requirements->strength) / + requirements->step_size; -return corr >= ds_corr && ecc->strength >= chip->base.eccreq.strength; +return corr >= ds_corr && ecc->strength >= requirements->strength; }static int rawnand_erase (struct nand_device *nand,const struct nand_pos *pos)
@@ -5977,9 +5978,11 @@ static int nand_scan_tail(struct nand_chip *chip)/* ECC sanity check: warn if it's too weak */ if (!nand_ecc_strength_good (chip))pr_warn ("WARNING: %s: the ECC used on your system (%db/%dB) is too weak compared to the one required by the NAND chip (%db/%dB)\n" , - mtd->name, chip->ecc.strength, chip->ecc.size, - chip->base.eccreq.strength, - chip->base.eccreq.step_size); + mtd->name, + chip->base.ecc.ctx.conf.strength, + chip->base.ecc.ctx.conf.step_size, + chip->base.ecc.requirements.strength, + chip->base.ecc.requirements.step_size);/* Allow subpage writes up to ecc.steps. Not possible for MLC flash */ if (!(chip->options &NAND_NO_SUBPAGE_WRITE ) &&nand_is_slc (chip)) {
drivers/mtd/nand/raw/nand_esmt.c +6 -5
@@ -10,24 +10,25 @@static void esmt_nand_decode_id (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;nand_decode_ext_id (chip);/* Extract ECC requirements from 5th id byte. */ if (chip->id.len >=5 &&nand_is_slc (chip)) { - chip->base.eccreq.step_size =512 ; + requirements->step_size =512 ;switch (chip->id.data[4 ] &0x3 ) {case 0x0 : - chip->base.eccreq.strength =4 ; + requirements->strength =4 ;break ;case 0x1 : - chip->base.eccreq.strength =2 ; + requirements->strength =2 ;break ;case 0x2 : - chip->base.eccreq.strength =1 ; + requirements->strength =1 ;break ;default :WARN (1 ,"Could not get ECC info" ); - chip->base.eccreq.step_size =0 ; + requirements->step_size =0 ;break ; } }
drivers/mtd/nand/raw/nand_hynix.c +21 -20
83 lines not on this page · raw message
drivers/mtd/nand/raw/nand_jedec.c +2 -2
@@ -120,8 +120,8 @@ int nand_jedec_detect(struct nand_chip *chip) ecc = &p->ecc_info[0 ];if (ecc->codeword_size >=9 ) { - chip->base.eccreq.strength = ecc->ecc_bits; - chip->base.eccreq.step_size =1 << ecc->codeword_size; + chip->base.ecc.requirements.strength = ecc->ecc_bits; + chip->base.ecc.requirements.step_size =1 << ecc->codeword_size; }else {pr_warn ("Invalid codeword size\n" ); }
drivers/mtd/nand/raw/nand_micron.c +8 -6
@@ -413,6 +413,7 @@ enum {*/ static int micron_supports_on_die_ecc (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;u8 id[5 ];int ret;
@@ -425,7 +426,7 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip)/* * We only support on-die ECC of 4/512 or 8/512 */ -if (chip->base.eccreq.strength !=4 && chip->base.eccreq.strength !=8 ) +if (requirements->strength !=4 && requirements->strength !=8 )return MICRON_ON_DIE_UNSUPPORTED ;/* 0x2 means on-die ECC is available. */
@@ -466,7 +467,7 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip)/* * We only support on-die ECC of 4/512 or 8/512 */ -if (chip->base.eccreq.strength !=4 && chip->base.eccreq.strength !=8 ) +if (requirements->strength !=4 && requirements->strength !=8 )return MICRON_ON_DIE_UNSUPPORTED ;return MICRON_ON_DIE_SUPPORTED ;
@@ -474,6 +475,7 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip)static int micron_nand_init (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct micron_nand *micron;int ondie;
@@ -523,7 +525,7 @@ static int micron_nand_init(struct nand_chip *chip)* That's not needed for 8-bit ECC, because the status expose * a better approximation of the number of bitflips in a page. */ -if (chip->base.eccreq.strength ==4 ) { +if (requirements->strength ==4 ) { micron->ecc.rawbuf =kmalloc (mtd->writesize + mtd->oobsize,GFP_KERNEL );
@@ -533,16 +535,16 @@ static int micron_nand_init(struct nand_chip *chip) } } -if (chip->base.eccreq.strength ==4 ) +if (requirements->strength ==4 )mtd_set_ooblayout (mtd, µn_nand_on_die_4_ooblayout_ops);else mtd_set_ooblayout (mtd, µn_nand_on_die_8_ooblayout_ops); - chip->ecc.bytes = chip->base.eccreq.strength *2 ; + chip->ecc.bytes = requirements->strength *2 ; chip->ecc.size =512 ; - chip->ecc.strength = chip->base.eccreq.strength; + chip->ecc.strength = requirements->strength; chip->ecc.algo =NAND_ECC_ALGO_BCH ; chip->ecc.read_page = micron_nand_read_page_on_die_ecc; chip->ecc.write_page = micron_nand_write_page_on_die_ecc;
drivers/mtd/nand/raw/nand_onfi.c +4 -4
@@ -94,8 +94,8 @@ static int nand_flash_detect_ext_param_page(struct nand_chip *chip, goto ext_out; } - chip->base.eccreq.strength = ecc->ecc_bits; - chip->base.eccreq.step_size =1 << ecc->codeword_size; + chip->base.ecc.requirements.strength = ecc->ecc_bits; + chip->base.ecc.requirements.step_size =1 << ecc->codeword_size; ret =0 ; ext_out:
@@ -265,8 +265,8 @@ int nand_onfi_detect(struct nand_chip *chip) chip->options |=NAND_BUSWIDTH_16 ;if (p->ecc_bits !=0xff ) { - chip->base.eccreq.strength = p->ecc_bits; - chip->base.eccreq.step_size =512 ; + chip->base.ecc.requirements.strength = p->ecc_bits; + chip->base.ecc.requirements.step_size =512 ; }else if (onfi_version >=21 && (le16_to_cpu (p->features) &ONFI_FEATURE_EXT_PARAM_PAGE )) {
drivers/mtd/nand/raw/nand_samsung.c +10 -9
@@ -10,6 +10,7 @@static void samsung_nand_decode_id (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct nand_memory_organization *memorg;
@@ -71,23 +72,23 @@ static void samsung_nand_decode_id(struct nand_chip *chip)/* Extract ECC requirements from 5th id byte*/ extid = (chip->id.data[4 ] >>4 ) &0x07 ;if (extid <5 ) { - chip->base.eccreq.step_size =512 ; - chip->base.eccreq.strength =1 << extid; + requirements->step_size =512 ; + requirements->strength =1 << extid; }else { - chip->base.eccreq.step_size =1024 ; + requirements->step_size =1024 ;switch (extid) {case 5 : - chip->base.eccreq.strength =24 ; + requirements->strength =24 ;break ;case 6 : - chip->base.eccreq.strength =40 ; + requirements->strength =40 ;break ;case 7 : - chip->base.eccreq.strength =60 ; + requirements->strength =60 ;break ;default :WARN (1 ,"Could not decode ECC info" ); - chip->base.eccreq.step_size =0 ; + requirements->step_size =0 ; } } }else {
@@ -97,8 +98,8 @@ static void samsung_nand_decode_id(struct nand_chip *chip)switch (chip->id.data[1 ]) {/* K9F4G08U0D-S[I|C]B0(T00) */ case 0xDC : - chip->base.eccreq.step_size =512 ; - chip->base.eccreq.strength =1 ; + requirements->step_size =512 ; + requirements->strength =1 ;break ;/* K9F1G08U0E 21nm chips do not support subpage write */
drivers/mtd/nand/raw/nand_toshiba.c +6 -5
@@ -145,6 +145,7 @@ static void toshiba_nand_benand_init(struct nand_chip *chip)static void toshiba_nand_decode_id (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct nand_memory_organization *memorg;
@@ -175,20 +176,20 @@ static void toshiba_nand_decode_id(struct nand_chip *chip)* - 24nm: 8 bit ECC for each 512Byte is required. */ if (chip->id.len >=6 &&nand_is_slc (chip)) { - chip->base.eccreq.step_size =512 ; + requirements->step_size =512 ;switch (chip->id.data[5 ] &0x7 ) {case 0x4 : - chip->base.eccreq.strength =1 ; + requirements->strength =1 ;break ;case 0x5 : - chip->base.eccreq.strength =4 ; + requirements->strength =4 ;break ;case 0x6 : - chip->base.eccreq.strength =8 ; + requirements->strength =8 ;break ;default :WARN (1 ,"Could not get ECC info" ); - chip->base.eccreq.step_size =0 ; + requirements->step_size =0 ;break ; } }
drivers/mtd/nand/raw/sunxi_nand.c +3 -2
@@ -1732,6 +1732,7 @@ static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc)static int sunxi_nand_attach_chip (struct nand_chip *nand) { +struct nand_ecc_props *requirements = &nand->base.ecc.requirements;struct nand_ecc_ctrl *ecc = &nand->ecc;struct device_node *np =nand_get_flash_node (nand);int ret;
@@ -1745,8 +1746,8 @@ static int sunxi_nand_attach_chip(struct nand_chip *nand) nand->options |=NAND_SUBPAGE_READ ;if (!ecc->size) { - ecc->size = nand->base.eccreq.step_size; - ecc->strength = nand->base.eccreq.strength; + ecc->size = requirements->step_size; + ecc->strength = requirements->strength; }if (!ecc->size || !ecc->strength)
drivers/mtd/nand/raw/tegra_nand.c +5 -4
@@ -855,7 +855,7 @@ static int tegra_nand_get_strength(struct nand_chip *chip, const int *strength, }else { strength_sel = strength[i]; -if (strength_sel < chip->base.eccreq.strength) +if (strength_sel < chip->base.ecc.requirements.strength)continue ; }
@@ -908,6 +908,7 @@ static int tegra_nand_select_strength(struct nand_chip *chip, int oobsize)static int tegra_nand_attach_chip (struct nand_chip *chip) {struct tegra_nand_controller *ctrl =to_tegra_ctrl (chip->controller); +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct tegra_nand_chip *nand =to_tegra_chip (chip);struct mtd_info *mtd =nand_to_mtd (chip);int bits_per_step;
@@ -919,9 +920,9 @@ static int tegra_nand_attach_chip(struct nand_chip *chip) chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ; chip->ecc.steps = mtd->writesize / chip->ecc.size; -if (chip->base.eccreq.step_size !=512 ) { +if (requirements->step_size !=512 ) {dev_err (ctrl->dev,"Unsupported step size %d\n" , - chip->base.eccreq.step_size); + requirements->step_size);return -EINVAL ; }
@@ -952,7 +953,7 @@ static int tegra_nand_attach_chip(struct nand_chip *chip)if (ret <0 ) {dev_err (ctrl->dev,"No valid strength found, minimum %d\n" , - chip->base.eccreq.strength); + requirements->strength);return ret; }
drivers/mtd/nand/spi/core.c +4 -4
@@ -419,7 +419,7 @@ static int spinand_check_ecc_status(struct spinand_device *spinand, u8 status)* fixed, so let's return the maximum possible value so that * wear-leveling layers move the data immediately. */ -return nand->eccreq.strength; +return nand->ecc.ctx.conf.strength;case STATUS_ECC_UNCOR_ERROR :return -EBADMSG ;
@@ -903,7 +903,7 @@ int spinand_match_and_init(struct spinand_device *spinand,continue ; nand->memorg = table[i].memorg; - nand->eccreq = table[i].eccreq; + nand->ecc.requirements = table[i].eccreq; spinand->eccinfo = table[i].eccinfo; spinand->flags = table[i].flags; spinand->id.len =1 + table[i].devid.len;
@@ -1091,8 +1091,8 @@ static int spinand_init(struct spinand_device *spinand) mtd->oobavail = ret;/* Propagate ECC information to mtd_info */ - mtd->ecc_strength = nand->eccreq.strength; - mtd->ecc_step_size = nand->eccreq.step_size; + mtd->ecc_strength = nand->ecc.ctx.conf.strength; + mtd->ecc_step_size = nand->ecc.ctx.conf.step_size;return 0 ;
drivers/mtd/nand/spi/macronix.c +3 -3
@@ -84,10 +84,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,* data around if it's not necessary. */ if (mx35lf1ge4ab_get_eccsr (spinand, &eccsr)) -return nand->eccreq.strength; +return nand->ecc.ctx.conf.strength; -if (WARN_ON (eccsr > nand->eccreq.strength || !eccsr)) -return nand->eccreq.strength; +if (WARN_ON (eccsr > nand->ecc.ctx.conf.strength || !eccsr)) +return nand->ecc.ctx.conf.strength;return eccsr;
drivers/mtd/nand/spi/toshiba.c +3 -3
@@ -90,12 +90,12 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,* data around if it's not necessary. */ if (spi_mem_exec_op (spinand->spimem, &op)) -return nand->eccreq.strength; +return nand->ecc.ctx.conf.strength; mbf >>=4 ; -if (WARN_ON (mbf > nand->eccreq.strength || !mbf)) -return nand->eccreq.strength; +if (WARN_ON (mbf > nand->ecc.ctx.conf.strength || !mbf)) +return nand->ecc.ctx.conf.strength;return mbf;
include/linux/mtd/nand.h +4 -4
@@ -290,7 +290,7 @@ struct nand_ecc {* struct nand_device - NAND device * @mtd: MTD instance attached to the NAND device * @memorg: memory layout -* @eccreq: ECC requirements +* @ecc: NAND ECC object attached to the NAND device * @rowconv: position to row address converter * @bbt: bad block table info * @ops: NAND operations attached to the NAND device
@@ -298,8 +298,8 @@ struct nand_ecc {* Generic NAND object. Specialized NAND layers (raw NAND, SPI NAND, OneNAND) * should declare their own NAND object embedding a nand_device struct (that's * how inheritance is done). -* struct_nand_device->memorg and struct_nand_device->eccreq should be filled -* at device detection time to reflect the NAND device +* struct_nand_device->memorg and struct_nand_device->ecc.ctx.conf should +* be filled at device detection time to reflect the NAND device * capabilities/requirements. Once this is done nanddev_init() can be called. * It will take care of converting NAND information into MTD ones, which means * the specialized NAND layers should never manually tweak
@@ -308,7 +308,7 @@ struct nand_ecc {struct nand_device {struct mtd_info mtd;struct nand_memory_organization memorg; -struct nand_ecc_props eccreq; +struct nand_ecc ecc;struct nand_row_converter rowconv;struct nand_bbt bbt;const struct nand_ops *ops;
Signature · 1 line
2.20.1
Re: [PATCH v7 16/20] mtd: nand: Convert generic NAND bits to use the ECC framework
Quoted 3 lines · On Fri, 29 May 2020 02:25:13 +0200 Miquel Raynal <[email protected]>…
Embed a generic NAND ECC high-level object in the
nand_devicestructure to carry all the ECC engine configuration/data. Adapt the raw NAND and SPI-NAND cores to fit the change.
In order to split that one, and make future re-organizations less painful (hope we won't have to do that again, but who knows), I would recommend doing things in this order:
1/ create a nanddev_get_ecc_requirements() helper that returns a
const struct nand_ecc_props *
2/ patch spinand to use this helper
3/ introduce nand_ecc
4/ patch rawnand to use the new ecc layer
Quoted 707 lines
Signed-off-by Miquel Raynal <[email protected]>--- drivers/mtd/nand/raw/atmel/nand-controller.c | 9 +++-- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 7 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 12 +++--- drivers/mtd/nand/raw/marvell_nand.c | 7 ++-- drivers/mtd/nand/raw/mtk_nand.c | 4 +- drivers/mtd/nand/raw/nand_base.c | 25 ++++++------ drivers/mtd/nand/raw/nand_esmt.c | 11 +++--- drivers/mtd/nand/raw/nand_hynix.c | 41 ++++++++++---------- drivers/mtd/nand/raw/nand_jedec.c | 4 +- drivers/mtd/nand/raw/nand_micron.c | 14 ++++--- drivers/mtd/nand/raw/nand_onfi.c | 8 ++-- drivers/mtd/nand/raw/nand_samsung.c | 19 ++++----- drivers/mtd/nand/raw/nand_toshiba.c | 11 +++--- drivers/mtd/nand/raw/sunxi_nand.c | 5 ++- drivers/mtd/nand/raw/tegra_nand.c | 9 +++-- drivers/mtd/nand/spi/core.c | 8 ++-- drivers/mtd/nand/spi/macronix.c | 6 +-- drivers/mtd/nand/spi/toshiba.c | 6 +-- include/linux/mtd/nand.h | 8 ++-- 19 files changed, 114 insertions(+), 100 deletions(-)drivers/mtd/nand/raw/atmel/nand-controller.c +5
-4@@ -1043,6 +1043,7 @@ static int atmel_hsmc_nand_pmecc_read_page_raw(struct nand_chip *chip,static int atmel_nand_pmecc_init (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_nand_controller *nc;@@ -1072,15 +1073,15 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip) req.ecc.strength =ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH ; else if (chip->ecc.strength) req.ecc.strength = chip->ecc.strength; - else if (chip->base.eccreq.strength) - req.ecc.strength = chip->base.eccreq.strength; + else if (requirements->strength) + req.ecc.strength = requirements->strength; else req.ecc.strength = ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH;if (chip->ecc.size) req.ecc.sectorsize = chip->ecc.size; -else if (chip->base.eccreq.step_size) - req.ecc.sectorsize = chip->base.eccreq.step_size; +else if (requirements->step_size) + req.ecc.sectorsize = requirements->step_size;else req.ecc.sectorsize =ATMEL_PMECC_SECTOR_SIZE_AUTO ;drivers/mtd/nand/raw/brcmnand/brcmnand.c +4
-3@@ -2563,10 +2563,11 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)if (chip->ecc.engine_type !=NAND_ECC_ENGINE_TYPE_NONE && (!chip->ecc.size || !chip->ecc.strength)) { -if (chip->base.eccreq.step_size && chip->base.eccreq.strength) { +if (chip->base.ecc.requirements.step_size && + chip->base.ecc.requirements.strength) {/* use detected ECC parameters */ - chip->ecc.size = chip->base.eccreq.step_size; - chip->ecc.strength = chip->base.eccreq.strength; + chip->ecc.size = chip->base.ecc.requirements.step_size; + chip->ecc.strength = chip->base.ecc.requirements.strength;dev_info (ctrl->dev,"Using ECC step-size %d, strength %d\n" , chip->ecc.size, chip->ecc.strength); }drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +6
-6@@ -272,8 +272,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,default :dev_err (this->dev,"unsupported nand chip. ecc bits : %d, ecc size : %d\n" , - chip->base.eccreq.strength, - chip->base.eccreq.step_size); + chip->base.ecc.requirements.strength, + chip->base.ecc.requirements.step_size);return -EINVAL ; } geo->ecc_chunk_size = ecc_step;@@ -517,13 +517,13 @@ static int common_nfc_set_geometry(struct gpmi_nand_data *this)if ((of_property_read_bool (this->dev->of_node,"fsl,use-minimum-ecc" )) ||legacy_set_geometry (this)) { -if (!(chip->base.eccreq.strength >0 && - chip->base.eccreq.step_size >0 )) +if (!(chip->base.ecc.requirements.strength >0 && + chip->base.ecc.requirements.step_size >0 ))return -EINVAL ;return set_geometry_by_ecc_info (this, - chip->base.eccreq.strength, - chip->base.eccreq.step_size); + chip->base.ecc.requirements.strength, + chip->base.ecc.requirements.step_size); }return 0 ;drivers/mtd/nand/raw/marvell_nand.c +4
-3@@ -2244,14 +2244,15 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc) {struct nand_chip *chip =mtd_to_nand (mtd); +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct marvell_nfc *nfc =to_marvell_nfc (chip->controller);int ret;if (ecc->engine_type !=NAND_ECC_ENGINE_TYPE_NONE && (!ecc->size || !ecc->strength)) { -if (chip->base.eccreq.step_size && chip->base.eccreq.strength) { - ecc->size = chip->base.eccreq.step_size; - ecc->strength = chip->base.eccreq.strength; +if (requirements->step_size && requirements->strength) { + ecc->size = requirements->step_size; + ecc->strength = requirements->strength; }else {dev_info (nfc->dev,"No minimum ECC strength, using 1b/512B\n" );drivers/mtd/nand/raw/mtk_nand.c +2
-2@@ -1234,8 +1234,8 @@ static int mtk_nfc_ecc_init(struct device *dev, struct mtd_info *mtd)/* if optional dt settings not present */ if (!nand->ecc.size || !nand->ecc.strength) {/* use datasheet requirements */ - nand->ecc.strength = nand->base.eccreq.strength; - nand->ecc.size = nand->base.eccreq.step_size; + nand->ecc.strength = nand->base.ecc.requirements.strength; + nand->ecc.size = nand->base.ecc.requirements.step_size;/* * align eccstrength and eccsize drivers/mtd/nand/raw/nand_base.c +14
-11@@ -4746,8 +4746,8 @@ static bool find_full_id_nand(struct nand_chip *chip, memorg->pagesize * memorg->pages_per_eraseblock); chip->options |= type->options; - chip->base.eccreq.strength =NAND_ECC_STRENGTH (type); - chip->base.eccreq.step_size =NAND_ECC_STEP (type); + chip->base.ecc.requirements.strength =NAND_ECC_STRENGTH (type); + chip->base.ecc.requirements.step_size =NAND_ECC_STEP (type); chip->onfi_timing_mode_default = type->onfi_timing_mode_default;@@ -5485,8 +5485,8 @@ nand_match_ecc_req(struct nand_chip *chip, {struct mtd_info *mtd =nand_to_mtd (chip);const struct nand_ecc_step_info *stepinfo; -int req_step = chip->base.eccreq.step_size; -int req_strength = chip->base.eccreq.strength; +int req_step = chip->base.ecc.requirements.step_size; +int req_strength = chip->base.ecc.requirements.strength;int req_corr, step_size, strength, nsteps, ecc_bytes, ecc_bytes_total;int best_step, best_strength, best_ecc_bytes;int best_ecc_bytes_total =INT_MAX ;@@ -5677,9 +5677,10 @@ static bool nand_ecc_strength_good(struct nand_chip *chip) {struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc; +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;int corr, ds_corr; -if (ecc->size ==0 || chip->base.eccreq.step_size ==0 ) +if (ecc->size ==0 || requirements->step_size ==0 )/* Not enough information */ return true;@@ -5688,10 +5689,10 @@ static bool nand_ecc_strength_good(struct nand_chip *chip)* the correction density. */ corr = (mtd->writesize * ecc->strength) / ecc->size; - ds_corr = (mtd->writesize * chip->base.eccreq.strength) / - chip->base.eccreq.step_size; + ds_corr = (mtd->writesize * requirements->strength) / + requirements->step_size; -return corr >= ds_corr && ecc->strength >= chip->base.eccreq.strength; +return corr >= ds_corr && ecc->strength >= requirements->strength; }static int rawnand_erase (struct nand_device *nand,const struct nand_pos *pos)@@ -5977,9 +5978,11 @@ static int nand_scan_tail(struct nand_chip *chip)/* ECC sanity check: warn if it's too weak */ if (!nand_ecc_strength_good (chip))pr_warn ("WARNING: %s: the ECC used on your system (%db/%dB) is too weak compared to the one required by the NAND chip (%db/%dB)\n" , - mtd->name, chip->ecc.strength, chip->ecc.size, - chip->base.eccreq.strength, - chip->base.eccreq.step_size); + mtd->name, + chip->base.ecc.ctx.conf.strength, + chip->base.ecc.ctx.conf.step_size, + chip->base.ecc.requirements.strength, + chip->base.ecc.requirements.step_size);/* Allow subpage writes up to ecc.steps. Not possible for MLC flash */ if (!(chip->options &NAND_NO_SUBPAGE_WRITE ) &&nand_is_slc (chip)) {drivers/mtd/nand/raw/nand_esmt.c +6
-5@@ -10,24 +10,25 @@static void esmt_nand_decode_id (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;nand_decode_ext_id (chip);/* Extract ECC requirements from 5th id byte. */ if (chip->id.len >=5 &&nand_is_slc (chip)) { - chip->base.eccreq.step_size =512 ; + requirements->step_size =512 ;switch (chip->id.data[4 ] &0x3 ) {case 0x0 : - chip->base.eccreq.strength =4 ; + requirements->strength =4 ;break ;case 0x1 : - chip->base.eccreq.strength =2 ; + requirements->strength =2 ;break ;case 0x2 : - chip->base.eccreq.strength =1 ; + requirements->strength =1 ;break ;default :WARN (1 ,"Could not get ECC info" ); - chip->base.eccreq.step_size =0 ; + requirements->step_size =0 ;break ; } }drivers/mtd/nand/raw/nand_hynix.c +21
-20@@ -495,34 +495,35 @@ static void hynix_nand_extract_oobsize(struct nand_chip *chip,static void hynix_nand_extract_ecc_requirements (struct nand_chip *chip,bool valid_jedecid) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;u8 ecc_level = (chip->id.data[4 ] >>4 ) &0x7 ;if (valid_jedecid) {/* Reference: H27UCG8T2E datasheet */ - chip->base.eccreq.step_size =1024 ; + requirements->step_size =1024 ;switch (ecc_level) {case 0 : - chip->base.eccreq.step_size =0 ; - chip->base.eccreq.strength =0 ; + requirements->step_size =0 ; + requirements->strength =0 ;break ;case 1 : - chip->base.eccreq.strength =4 ; + requirements->strength =4 ;break ;case 2 : - chip->base.eccreq.strength =24 ; + requirements->strength =24 ;break ;case 3 : - chip->base.eccreq.strength =32 ; + requirements->strength =32 ;break ;case 4 : - chip->base.eccreq.strength =40 ; + requirements->strength =40 ;break ;case 5 : - chip->base.eccreq.strength =50 ; + requirements->strength =50 ;break ;case 6 : - chip->base.eccreq.strength =60 ; + requirements->strength =60 ;break ;default :/* @@ -543,14 +544,14 @@ static void hynix_nand_extract_ecc_requirements(struct nand_chip *chip,if (nand_tech <3 ) {/* > 26nm, reference: H27UBG8T2A datasheet */ if (ecc_level <5 ) { - chip->base.eccreq.step_size =512 ; - chip->base.eccreq.strength =1 << ecc_level; + requirements->step_size =512 ; + requirements->strength =1 << ecc_level; }else if (ecc_level <7 ) {if (ecc_level ==5 ) - chip->base.eccreq.step_size =2048 ; + requirements->step_size =2048 ;else - chip->base.eccreq.step_size =1024 ; - chip->base.eccreq.strength =24 ; + requirements->step_size =1024 ; + requirements->strength =24 ; }else {/* * We should never reach this case, but if that @@ -563,14 +564,14 @@ static void hynix_nand_extract_ecc_requirements(struct nand_chip *chip, }else {/* <= 26nm, reference: H27UBG8T2B datasheet */ if (!ecc_level) { - chip->base.eccreq.step_size =0 ; - chip->base.eccreq.strength =0 ; + requirements->step_size =0 ; + requirements->strength =0 ; }else if (ecc_level <5 ) { - chip->base.eccreq.step_size =512 ; - chip->base.eccreq.strength =1 << (ecc_level -1 ); + requirements->step_size =512 ; + requirements->strength =1 << (ecc_level -1 ); }else { - chip->base.eccreq.step_size =1024 ; - chip->base.eccreq.strength =24 + + requirements->step_size =1024 ; + requirements->strength =24 + (8 * (ecc_level -5 )); } }drivers/mtd/nand/raw/nand_jedec.c +2
-2@@ -120,8 +120,8 @@ int nand_jedec_detect(struct nand_chip *chip) ecc = &p->ecc_info[0 ];if (ecc->codeword_size >=9 ) { - chip->base.eccreq.strength = ecc->ecc_bits; - chip->base.eccreq.step_size =1 << ecc->codeword_size; + chip->base.ecc.requirements.strength = ecc->ecc_bits; + chip->base.ecc.requirements.step_size =1 << ecc->codeword_size; }else {pr_warn ("Invalid codeword size\n" ); }drivers/mtd/nand/raw/nand_micron.c +8
-6@@ -413,6 +413,7 @@ enum {*/ static int micron_supports_on_die_ecc (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;u8 id[5 ];int ret;@@ -425,7 +426,7 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip)/* * We only support on-die ECC of 4/512 or 8/512 */ -if (chip->base.eccreq.strength !=4 && chip->base.eccreq.strength !=8 ) +if (requirements->strength !=4 && requirements->strength !=8 )return MICRON_ON_DIE_UNSUPPORTED ;/* 0x2 means on-die ECC is available. */ @@ -466,7 +467,7 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip)/* * We only support on-die ECC of 4/512 or 8/512 */ -if (chip->base.eccreq.strength !=4 && chip->base.eccreq.strength !=8 ) +if (requirements->strength !=4 && requirements->strength !=8 )return MICRON_ON_DIE_UNSUPPORTED ;return MICRON_ON_DIE_SUPPORTED ;@@ -474,6 +475,7 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip)static int micron_nand_init (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct micron_nand *micron;int ondie;@@ -523,7 +525,7 @@ static int micron_nand_init(struct nand_chip *chip)* That's not needed for 8-bit ECC, because the status expose * a better approximation of the number of bitflips in a page. */ -if (chip->base.eccreq.strength ==4 ) { +if (requirements->strength ==4 ) { micron->ecc.rawbuf =kmalloc (mtd->writesize + mtd->oobsize,GFP_KERNEL );@@ -533,16 +535,16 @@ static int micron_nand_init(struct nand_chip *chip) } } -if (chip->base.eccreq.strength ==4 ) +if (requirements->strength ==4 )mtd_set_ooblayout (mtd, µn_nand_on_die_4_ooblayout_ops);else mtd_set_ooblayout (mtd, µn_nand_on_die_8_ooblayout_ops); - chip->ecc.bytes = chip->base.eccreq.strength *2 ; + chip->ecc.bytes = requirements->strength *2 ; chip->ecc.size =512 ; - chip->ecc.strength = chip->base.eccreq.strength; + chip->ecc.strength = requirements->strength; chip->ecc.algo =NAND_ECC_ALGO_BCH ; chip->ecc.read_page = micron_nand_read_page_on_die_ecc; chip->ecc.write_page = micron_nand_write_page_on_die_ecc;drivers/mtd/nand/raw/nand_onfi.c +4
-4@@ -94,8 +94,8 @@ static int nand_flash_detect_ext_param_page(struct nand_chip *chip, goto ext_out; } - chip->base.eccreq.strength = ecc->ecc_bits; - chip->base.eccreq.step_size =1 << ecc->codeword_size; + chip->base.ecc.requirements.strength = ecc->ecc_bits; + chip->base.ecc.requirements.step_size =1 << ecc->codeword_size; ret =0 ; ext_out:@@ -265,8 +265,8 @@ int nand_onfi_detect(struct nand_chip *chip) chip->options |=NAND_BUSWIDTH_16 ;if (p->ecc_bits !=0xff ) { - chip->base.eccreq.strength = p->ecc_bits; - chip->base.eccreq.step_size =512 ; + chip->base.ecc.requirements.strength = p->ecc_bits; + chip->base.ecc.requirements.step_size =512 ; }else if (onfi_version >=21 && (le16_to_cpu (p->features) &ONFI_FEATURE_EXT_PARAM_PAGE )) {drivers/mtd/nand/raw/nand_samsung.c +10
-9@@ -10,6 +10,7 @@static void samsung_nand_decode_id (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct nand_memory_organization *memorg;@@ -71,23 +72,23 @@ static void samsung_nand_decode_id(struct nand_chip *chip)/* Extract ECC requirements from 5th id byte*/ extid = (chip->id.data[4 ] >>4 ) &0x07 ;if (extid <5 ) { - chip->base.eccreq.step_size =512 ; - chip->base.eccreq.strength =1 << extid; + requirements->step_size =512 ; + requirements->strength =1 << extid; }else { - chip->base.eccreq.step_size =1024 ; + requirements->step_size =1024 ;switch (extid) {case 5 : - chip->base.eccreq.strength =24 ; + requirements->strength =24 ;break ;case 6 : - chip->base.eccreq.strength =40 ; + requirements->strength =40 ;break ;case 7 : - chip->base.eccreq.strength =60 ; + requirements->strength =60 ;break ;default :WARN (1 ,"Could not decode ECC info" ); - chip->base.eccreq.step_size =0 ; + requirements->step_size =0 ; } } }else {@@ -97,8 +98,8 @@ static void samsung_nand_decode_id(struct nand_chip *chip)switch (chip->id.data[1 ]) {/* K9F4G08U0D-S[I|C]B0(T00) */ case 0xDC : - chip->base.eccreq.step_size =512 ; - chip->base.eccreq.strength =1 ; + requirements->step_size =512 ; + requirements->strength =1 ;break ;/* K9F1G08U0E 21nm chips do not support subpage write */ drivers/mtd/nand/raw/nand_toshiba.c +6
-5@@ -145,6 +145,7 @@ static void toshiba_nand_benand_init(struct nand_chip *chip)static void toshiba_nand_decode_id (struct nand_chip *chip) { +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip);struct nand_memory_organization *memorg;@@ -175,20 +176,20 @@ static void toshiba_nand_decode_id(struct nand_chip *chip)* - 24nm: 8 bit ECC for each 512Byte is required. */ if (chip->id.len >=6 &&nand_is_slc (chip)) { - chip->base.eccreq.step_size =512 ; + requirements->step_size =512 ;switch (chip->id.data[5 ] &0x7 ) {case 0x4 : - chip->base.eccreq.strength =1 ; + requirements->strength =1 ;break ;case 0x5 : - chip->base.eccreq.strength =4 ; + requirements->strength =4 ;break ;case 0x6 : - chip->base.eccreq.strength =8 ; + requirements->strength =8 ;break ;default :WARN (1 ,"Could not get ECC info" ); - chip->base.eccreq.step_size =0 ; + requirements->step_size =0 ;break ; } }drivers/mtd/nand/raw/sunxi_nand.c +3
-2@@ -1732,6 +1732,7 @@ static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc)static int sunxi_nand_attach_chip (struct nand_chip *nand) { +struct nand_ecc_props *requirements = &nand->base.ecc.requirements;struct nand_ecc_ctrl *ecc = &nand->ecc;struct device_node *np =nand_get_flash_node (nand);int ret;@@ -1745,8 +1746,8 @@ static int sunxi_nand_attach_chip(struct nand_chip *nand) nand->options |=NAND_SUBPAGE_READ ;if (!ecc->size) { - ecc->size = nand->base.eccreq.step_size; - ecc->strength = nand->base.eccreq.strength; + ecc->size = requirements->step_size; + ecc->strength = requirements->strength; }if (!ecc->size || !ecc->strength)drivers/mtd/nand/raw/tegra_nand.c +5
-4@@ -855,7 +855,7 @@ static int tegra_nand_get_strength(struct nand_chip *chip, const int *strength, }else { strength_sel = strength[i]; -if (strength_sel < chip->base.eccreq.strength) +if (strength_sel < chip->base.ecc.requirements.strength)continue ; }@@ -908,6 +908,7 @@ static int tegra_nand_select_strength(struct nand_chip *chip, int oobsize)static int tegra_nand_attach_chip (struct nand_chip *chip) {struct tegra_nand_controller *ctrl =to_tegra_ctrl (chip->controller); +struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct tegra_nand_chip *nand =to_tegra_chip (chip);struct mtd_info *mtd =nand_to_mtd (chip);int bits_per_step;@@ -919,9 +920,9 @@ static int tegra_nand_attach_chip(struct nand_chip *chip) chip->ecc.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; chip->ecc.size =512 ; chip->ecc.steps = mtd->writesize / chip->ecc.size; -if (chip->base.eccreq.step_size !=512 ) { +if (requirements->step_size !=512 ) {dev_err (ctrl->dev,"Unsupported step size %d\n" , - chip->base.eccreq.step_size); + requirements->step_size);return -EINVAL ; }@@ -952,7 +953,7 @@ static int tegra_nand_attach_chip(struct nand_chip *chip)if (ret <0 ) {dev_err (ctrl->dev,"No valid strength found, minimum %d\n" , - chip->base.eccreq.strength); + requirements->strength);return ret; }drivers/mtd/nand/spi/core.c +4
-4@@ -419,7 +419,7 @@ static int spinand_check_ecc_status(struct spinand_device *spinand, u8 status)* fixed, so let's return the maximum possible value so that * wear-leveling layers move the data immediately. */ -return nand->eccreq.strength; +return nand->ecc.ctx.conf.strength;case STATUS_ECC_UNCOR_ERROR :return -EBADMSG ;@@ -903,7 +903,7 @@ int spinand_match_and_init(struct spinand_device *spinand,continue ; nand->memorg = table[i].memorg; - nand->eccreq = table[i].eccreq; + nand->ecc.requirements = table[i].eccreq; spinand->eccinfo = table[i].eccinfo; spinand->flags = table[i].flags; spinand->id.len =1 + table[i].devid.len;@@ -1091,8 +1091,8 @@ static int spinand_init(struct spinand_device *spinand) mtd->oobavail = ret;/* Propagate ECC information to mtd_info */ - mtd->ecc_strength = nand->eccreq.strength; - mtd->ecc_step_size = nand->eccreq.step_size; + mtd->ecc_strength = nand->ecc.ctx.conf.strength; + mtd->ecc_step_size = nand->ecc.ctx.conf.step_size;return 0 ;drivers/mtd/nand/spi/macronix.c +3
-3@@ -84,10 +84,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,* data around if it's not necessary. */ if (mx35lf1ge4ab_get_eccsr (spinand, &eccsr)) -return nand->eccreq.strength; +return nand->ecc.ctx.conf.strength; -if (WARN_ON (eccsr > nand->eccreq.strength || !eccsr)) -return nand->eccreq.strength; +if (WARN_ON (eccsr > nand->ecc.ctx.conf.strength || !eccsr)) +return nand->ecc.ctx.conf.strength;return eccsr;drivers/mtd/nand/spi/toshiba.c +3
-3@@ -90,12 +90,12 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,* data around if it's not necessary. */ if (spi_mem_exec_op (spinand->spimem, &op)) -return nand->eccreq.strength; +return nand->ecc.ctx.conf.strength; mbf >>=4 ; -if (WARN_ON (mbf > nand->eccreq.strength || !mbf)) -return nand->eccreq.strength; +if (WARN_ON (mbf > nand->ecc.ctx.conf.strength || !mbf)) +return nand->ecc.ctx.conf.strength;return mbf;include/linux/mtd/nand.h +4
-4@@ -290,7 +290,7 @@ struct nand_ecc {* struct nand_device - NAND device * @mtd: MTD instance attached to the NAND device * @memorg: memory layout -* @eccreq: ECC requirements +* @ecc: NAND ECC object attached to the NAND device * @rowconv: position to row address converter * @bbt: bad block table info * @ops: NAND operations attached to the NAND device @@ -298,8 +298,8 @@ struct nand_ecc {* Generic NAND object. Specialized NAND layers (raw NAND, SPI NAND, OneNAND) * should declare their own NAND object embedding a nand_device struct (that's * how inheritance is done). -* struct_nand_device->memorg and struct_nand_device->eccreq should be filled -* at device detection time to reflect the NAND device +* struct_nand_device->memorg and struct_nand_device->ecc.ctx.conf should +* be filled at device detection time to reflect the NAND device * capabilities/requirements. Once this is done nanddev_init() can be called. * It will take care of converting NAND information into MTD ones, which means * the specialized NAND layers should never manually tweak @@ -308,7 +308,7 @@ struct nand_ecc {struct nand_device {struct mtd_info mtd;struct nand_memory_organization memorg; -struct nand_ecc_props eccreq; +struct nand_ecc ecc;struct nand_row_converter rowconv;struct nand_bbt bbt;const struct nand_ops *ops;
Miquel Raynal
maintainerRe: [PATCH v7 16/20] mtd: nand: Convert generic NAND bits to use the ECC framework
Boris Brezillon <[email protected]> wrote on Fri, 29 May 2020 10:32:22 +0200:
Quoted 11 lines
Quoted 3 lines · On Fri, 29 May 2020 02:25:13 +0200 Miquel Raynal <[email protected]>…
Embed a generic NAND ECC high-level object in the
nand_devicestructure to carry all the ECC engine configuration/data. Adapt the raw NAND and SPI-NAND cores to fit the change.In order to split that one, and make future re-organizations less painful (hope we won't have to do that again, but who knows), I would recommend doing things in this order:
Quoted 5 lines
1/ create a
nanddev_get_ecc_requirements()helper that returns a
const structnand_ecc_props*
2/ patch spinand to use this helper
3/ introducenand_ecc
4/ patch rawnand to use the new ecc layer
Sounds like a lot of efforts for a mechanical change to me. Not mentioning that the diff is pretty small now. But ok, I'll try.
Quoted 24 lines
Quoted 24 lines
Signed-off-by Miquel Raynal <[email protected]>--- drivers/mtd/nand/raw/atmel/nand-controller.c | 9 +++-- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 7 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 12 +++--- drivers/mtd/nand/raw/marvell_nand.c | 7 ++-- drivers/mtd/nand/raw/mtk_nand.c | 4 +- drivers/mtd/nand/raw/nand_base.c | 25 ++++++------ drivers/mtd/nand/raw/nand_esmt.c | 11 +++--- drivers/mtd/nand/raw/nand_hynix.c | 41 ++++++++++---------- drivers/mtd/nand/raw/nand_jedec.c | 4 +- drivers/mtd/nand/raw/nand_micron.c | 14 ++++--- drivers/mtd/nand/raw/nand_onfi.c | 8 ++-- drivers/mtd/nand/raw/nand_samsung.c | 19 ++++----- drivers/mtd/nand/raw/nand_toshiba.c | 11 +++--- drivers/mtd/nand/raw/sunxi_nand.c | 5 ++- drivers/mtd/nand/raw/tegra_nand.c | 9 +++-- drivers/mtd/nand/spi/core.c | 8 ++-- drivers/mtd/nand/spi/macronix.c | 6 +-- drivers/mtd/nand/spi/toshiba.c | 6 +-- include/linux/mtd/nand.h | 8 ++-- 19 files changed, 114 insertions(+), 100 deletions(-)
Re: [PATCH v7 16/20] mtd: nand: Convert generic NAND bits to use the ECC framework
In reply to Miquel RaynalQuoted 4 lines · On Fri, 29 May 2020 02:25:13 +0200 Miquel Raynal <[email protected]>…
- *
struct_nand_device->memorgandstruct_nand_device->eccreqshould be filled
- * at device detection time to reflect the NAND device
+ *struct_nand_device->memorgandstruct_nand_device->ecc.ctx.confshould
+ * be filled at device detection time to reflect the NAND device
Is it not struct_nand_device->ecc.requirements?
Miquel Raynal
maintainerPATCH v7 17/20 mtd: rawnand: Hide the generic OOB layout objects behind helpers
In reply to Miquel RaynalStop exposing these objects, create helpers to retrieve them instead.
Also export an helper for the Hamming large page ops for later use.
--- drivers/mtd/nand/raw/arasan-nand-controller.c | 2 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 3 +- .../mtd/nand/raw/ingenic/ingenic_nand_drv.c | 6 ++-- drivers/mtd/nand/raw/nand_base.c | 35 ++++++++++++++----- drivers/mtd/nand/raw/nand_toshiba.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 2 +- include/linux/mtd/rawnand.h | 5 +-- 8 files changed, 38 insertions(+), 19 deletions(-)
drivers/mtd/nand/raw/arasan-nand-controller.c +1 -1
@@ -980,7 +980,7 @@ static int anfc_init_hw_ecc_controller(struct arasan_nfc *nfc,return -EINVAL ; } -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); +mtd_set_ooblayout (mtd,nand_get_large_page_layout ()); ecc->steps = mtd->writesize / ecc->size; ecc->algo =NAND_ECC_ALGO_BCH ;
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
@@ -1107,7 +1107,7 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip) chip->options |=NAND_NO_SUBPAGE_WRITE ; -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); +mtd_set_ooblayout (mtd,nand_get_large_page_layout ());return 0 ; }
drivers/mtd/nand/raw/davinci_nand.c +2 -1
@@ -645,7 +645,8 @@ static int davinci_nand_attach_chip(struct nand_chip *chip)mtd_set_ooblayout (mtd, &hwecc4_small_ooblayout_ops); }else if (chunks ==4 || chunks ==8 ) { -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); +mtd_set_ooblayout (mtd, +nand_get_large_page_layout ()); info->chip.ecc.read_page = nand_davinci_read_page_hwecc_oob_first; }else {return -EIO ;
drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c +3 -3
@@ -243,8 +243,10 @@ static int ingenic_nand_attach_chip(struct nand_chip *chip)/* For legacy reasons we use a different layout on the qi,lb60 board. */ if (of_machine_is_compatible ("qi,lb60" ))mtd_set_ooblayout (mtd, &qi_lb60_ooblayout_ops); -else +else if (nfc->soc_info->oob_layout)mtd_set_ooblayout (mtd, nfc->soc_info->oob_layout); +else +mtd_set_ooblayout (mtd,nand_get_large_page_layout ());return 0 ; }
@@ -532,7 +534,6 @@ static const struct jz_soc_info jz4740_soc_info = { .data_offset = 0x00000000, .cmd_offset = 0x00008000, .addr_offset = 0x00010000, - .oob_layout = &nand_ooblayout_lp_ops, };static const struct jz_soc_info jz4725b_soc_info = {
@@ -546,7 +547,6 @@ static const struct jz_soc_info jz4780_soc_info = { .data_offset = 0x00000000, .cmd_offset = 0x00400000, .addr_offset = 0x00800000, - .oob_layout = &nand_ooblayout_lp_ops, };static const struct of_device_id ingenic_nand_dt_match[] = {
drivers/mtd/nand/raw/nand_base.c +26 -9
@@ -95,11 +95,16 @@ static int nand_ooblayout_free_sp(struct mtd_info *mtd, int section,return 0 ; } -const struct mtd_ooblayout_ops nand_ooblayout_sp_ops = { +static const struct mtd_ooblayout_ops nand_ooblayout_sp_ops = { .ecc = nand_ooblayout_ecc_sp, .free = nand_ooblayout_free_sp, }; -EXPORT_SYMBOL_GPL (nand_ooblayout_sp_ops); + +const struct mtd_ooblayout_ops *nand_get_small_page_layout (void ) +{ +return &nand_ooblayout_sp_ops; +} +EXPORT_SYMBOL_GPL (nand_get_small_page_layout);static int nand_ooblayout_ecc_lp (struct mtd_info *mtd,int section,struct mtd_oob_region *oobregion)
@@ -131,11 +136,16 @@ static int nand_ooblayout_free_lp(struct mtd_info *mtd, int section,return 0 ; } -const struct mtd_ooblayout_ops nand_ooblayout_lp_ops = { +static const struct mtd_ooblayout_ops nand_ooblayout_lp_ops = { .ecc = nand_ooblayout_ecc_lp, .free = nand_ooblayout_free_lp, }; -EXPORT_SYMBOL_GPL (nand_ooblayout_lp_ops); + +const struct mtd_ooblayout_ops *nand_get_large_page_layout (void ) +{ +return &nand_ooblayout_lp_ops; +} +EXPORT_SYMBOL_GPL (nand_get_large_page_layout);/* * Support the old "large page" layout used for 1-bit Hamming ECC where ECC
@@ -205,6 +215,12 @@ static const struct mtd_ooblayout_ops nand_ooblayout_lp_hamming_ops = { .free = nand_ooblayout_free_lp_hamming, }; +const struct mtd_ooblayout_ops *nand_get_large_page_hamming_layout (void ) +{ +return &nand_ooblayout_lp_hamming_ops; +} +EXPORT_SYMBOL_GPL (nand_get_large_page_hamming_layout); +static int nand_pairing_dist3_get_info (struct mtd_info *mtd,int page,struct mtd_pairing_info *info) {
@@ -5379,7 +5395,7 @@ static int nand_set_ecc_soft_ops(struct nand_chip *chip)return -EINVAL ; } -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); +mtd_set_ooblayout (mtd,nand_get_large_page_layout ()); }
@@ -5388,7 +5404,7 @@ static int nand_set_ecc_soft_ops(struct nand_chip *chip)* used, otherwise we don't know how many bytes can really be * used. */ -if (mtd->ooblayout == &nand_ooblayout_lp_ops && +if (mtd->ooblayout ==nand_get_large_page_layout () && ecc->options &NAND_ECC_MAXIMIZE ) {int steps, bytes;
@@ -5787,11 +5803,12 @@ static int nand_scan_tail(struct nand_chip *chip)switch (mtd->oobsize) {case 8 :case 16 : -mtd_set_ooblayout (mtd, &nand_ooblayout_sp_ops); +mtd_set_ooblayout (mtd,nand_get_small_page_layout ());break ;case 64 :case 128 : -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_hamming_ops); +mtd_set_ooblayout (mtd, +nand_get_large_page_hamming_layout ());break ;default :/*
@@ -5803,7 +5820,7 @@ static int nand_scan_tail(struct nand_chip *chip)*/ if (ecc->engine_type ==NAND_ECC_ENGINE_TYPE_NONE ) {mtd_set_ooblayout (mtd, - &nand_ooblayout_lp_ops); +nand_get_large_page_layout ());break ; }
drivers/mtd/nand/raw/nand_toshiba.c +1 -1
@@ -140,7 +140,7 @@ static void toshiba_nand_benand_init(struct nand_chip *chip) chip->options |=NAND_SUBPAGE_READ ; -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); +mtd_set_ooblayout (mtd,nand_get_large_page_layout ()); }static void toshiba_nand_decode_id (struct nand_chip *chip)
drivers/mtd/nand/raw/vf610_nfc.c +1 -1
@@ -779,7 +779,7 @@ static int vf610_nfc_attach_chip(struct nand_chip *chip) mtd->oobsize =64 ;/* Use default large page ECC layout defined in NAND core */ -mtd_set_ooblayout (mtd, &nand_ooblayout_lp_ops); +mtd_set_ooblayout (mtd,nand_get_large_page_layout ());if (chip->ecc.strength ==32 ) { nfc->ecc_mode =ECC_60_BYTE ; chip->ecc.bytes =60 ;
include/linux/mtd/rawnand.h +3 -2
@@ -1159,8 +1159,9 @@ struct nand_chip {int (*unlock_area)(struct nand_chip *chip,loff_t ofs,uint64_t len); }; -extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops; -extern const struct mtd_ooblayout_ops nand_ooblayout_lp_ops; +const struct mtd_ooblayout_ops *nand_get_small_page_layout (void ); +const struct mtd_ooblayout_ops *nand_get_large_page_layout (void ); +const struct mtd_ooblayout_ops *nand_get_large_page_hamming_layout (void );static inline struct nand_chip *mtd_to_nand (struct mtd_info *mtd) {
Signature · 1 line
2.20.1
Re: [PATCH v7 17/20] mtd: rawnand: Hide the generic OOB layout objects behind helpers
Quoted 1 line · On Fri, 29 May 2020 02:25:14 +0200 Miquel Raynal <[email protected]>…
+const struct
mtd_ooblayout_ops*nand_get_large_page_layout(void)
nand_get_large_page_ooblayout() (same for the other helpers).
Quoted 4 lines
drivers/mtd/nand/raw/nand_base.c +4
-0+{ +return &nand_ooblayout_lp_ops; +} +EXPORT_SYMBOL_GPL (nand_get_large_page_layout);
Re: [PATCH v7 17/20] mtd: rawnand: Hide the generic OOB layout objects behind helpers
Quoted 7 lines · On Fri, 29 May 2020 10:45:48 +0200 Boris Brezillon…
Quoted 1 line · On Fri, 29 May 2020 02:25:14 +0200 Miquel Raynal <[email protected]>…
+const struct
mtd_ooblayout_ops*nand_get_large_page_layout(void)
nand_get_large_page_ooblayout()(same for the other helpers).
And sorry if I got it wrong in my previous review :-/.
Quoted 4 lines
Quoted 4 lines
drivers/mtd/nand/raw/nand_base.c +4
-0+{ +return &nand_ooblayout_lp_ops; +} +EXPORT_SYMBOL_GPL (nand_get_large_page_layout);
Miquel Raynal
maintainerRe: [PATCH v7 17/20] mtd: rawnand: Hide the generic OOB layout objects behind helpers
Boris Brezillon <[email protected]> wrote on Fri, 29 May 2020 10:46:40 +0200:
Quoted 6 lines
Quoted 3 lines · On Fri, 29 May 2020 10:45:48 +0200 Boris Brezillon…
On Fri, 29 May 2020 02:25:14 +0200
Miquel Raynal <[email protected]> wrote:
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
+const struct
mtd_ooblayout_ops*nand_get_large_page_layout(void)
nand_get_large_page_ooblayout()(same for the other helpers).And sorry if I got it wrong in my previous review :-/.
Haha, no pb ;)
Miquel Raynal
maintainerPATCH v7 18/20 mtd: rawnand: Write a compatibility layer
In reply to Miquel RaynalBefore moving generic bits from the raw NAND core to the generic NAND core, let's disociate clearly what is a rawnand legacy property, and what should be made public to other NAND users.
--- drivers/mtd/nand/raw/nand_base.c | 158 +++++++++++++++++++++---------- include/linux/mtd/rawnand.h | 12 --- 2 files changed, 107 insertions(+), 63 deletions(-)
drivers/mtd/nand/raw/nand_base.c +107 -51
@@ -5026,14 +5026,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)return ret; } -static const char *const nand_ecc_modes[] = { - [NAND_ECC_NONE ] ="none" , - [NAND_ECC_SOFT ] ="soft" , - [NAND_ECC_HW ] ="hw" , - [NAND_ECC_HW_SYNDROME ] ="hw_syndrome" , - [NAND_ECC_ON_DIE ] ="on-die" , -}; -static const char *const nand_ecc_placement[] = { [NAND_ECC_PLACEMENT_OOB ] ="oob" , [NAND_ECC_PLACEMENT_INTERLEAVED ] ="interleaved" ,
@@ -5042,7 +5034,30 @@ static const char * const nand_ecc_placement[] = {static enum nand_ecc_engine_type of_get_nand_ecc_engine_type (struct device_node *np) { -enum nand_ecc_mode eng_type; +return NAND_ECC_ENGINE_TYPE_INVALID ; +} + +static enum nand_ecc_engine_type +of_get_rawnand_ecc_engine_type_legacy (struct device_node *np) +{ +enum nand_ecc_legacy_mode { +NAND_ECC_INVALID , +NAND_ECC_NONE , +NAND_ECC_SOFT , +NAND_ECC_SOFT_BCH , +NAND_ECC_HW , +NAND_ECC_HW_SYNDROME , +NAND_ECC_ON_DIE , + }; +const char *const nand_ecc_legacy_modes[] = { + [NAND_ECC_NONE ] ="none" , + [NAND_ECC_SOFT ] ="soft" , + [NAND_ECC_SOFT_BCH ] ="soft_bch" , + [NAND_ECC_HW ] ="hw" , + [NAND_ECC_HW_SYNDROME ] ="hw_syndrome" , + [NAND_ECC_ON_DIE ] ="on-die" , + }; +enum nand_ecc_legacy_mode eng_type;const char *pm;int err;
@@ -5051,12 +5066,13 @@ of_get_nand_ecc_engine_type(struct device_node *np)return NAND_ECC_ENGINE_TYPE_INVALID ;for (eng_type =NAND_ECC_NONE ; - eng_type <ARRAY_SIZE (nand_ecc_modes); eng_type++) { -if (!strcasecmp (pm, nand_ecc_modes[eng_type])) { + eng_type <ARRAY_SIZE (nand_ecc_legacy_modes); eng_type++) { +if (!strcasecmp (pm, nand_ecc_legacy_modes[eng_type])) {switch (eng_type) {case NAND_ECC_NONE :return NAND_ECC_ENGINE_TYPE_NONE ;case NAND_ECC_SOFT : +case NAND_ECC_SOFT_BCH :return NAND_ECC_ENGINE_TYPE_SOFT ;case NAND_ECC_HW :case NAND_ECC_HW_SYNDROME :
@@ -5069,14 +5085,6 @@ of_get_nand_ecc_engine_type(struct device_node *np) } } -/* -* For backward compatibility we support few obsoleted values that don't -* have their mappings into the nand_ecc_engine_providers enum anymore -* (they were merged with other enums). -*/ -if (!strcasecmp (pm,"soft_bch" )) -return NAND_ECC_ENGINE_TYPE_SOFT ; -return NAND_ECC_ENGINE_TYPE_INVALID ; }
@@ -5088,17 +5096,22 @@ enum nand_ecc_placement of_get_nand_ecc_placement(struct device_node *np) err =of_property_read_string (np,"nand-ecc-placement" , &pm);if (!err) { -for (placement =NAND_ECC_PLACEMENT_INTERLEAVED ; +for (placement =NAND_ECC_PLACEMENT_OOB ; placement <ARRAY_SIZE (nand_ecc_placement); placement++) {if (!strcasecmp (pm, nand_ecc_placement[placement]))return placement; } } -/* -* For backward compatibility we support few obsoleted values that don't -* have their mappings into the nand_ecc_placement enum anymore. -*/ +return NAND_ECC_PLACEMENT_UNKNOWN ; +} + +enum nand_ecc_placement +of_get_rawnand_ecc_placement_legacy (struct device_node *np) +{ +const char *pm; +int err; + err =of_property_read_string (np,"nand-ecc-mode" , &pm);if (!err) {if (!strcasecmp (pm,"hw_syndrome" ))
@@ -5130,10 +5143,14 @@ static enum nand_ecc_algo of_get_nand_ecc_algo(struct device_node *np) } } -/* -* For backward compatibility we also read "nand-ecc-mode" checking -* for some obsoleted values that were specifying ECC algorithm. -*/ +return NAND_ECC_ALGO_UNKNOWN ; +} + +static enum nand_ecc_algo of_get_rawnand_ecc_algo_legacy (struct device_node *np) +{ +const char *pm; +int err; + err =of_property_read_string (np,"nand-ecc-mode" , &pm);if (!err) {if (!strcasecmp (pm,"soft" ))
@@ -5163,6 +5180,41 @@ static int of_get_nand_ecc_strength(struct device_node *np)return ret ? ret : val; } +static void nand_ecc_read_user_conf (struct nand_chip *chip) +{ +struct device_node *dn =nand_get_flash_node (chip); +struct nand_device *nand = &chip->base; +int strength, size; + + nand->ecc.user_conf.engine_type =of_get_nand_ecc_engine_type (dn); + nand->ecc.user_conf.algo =of_get_nand_ecc_algo (dn); + nand->ecc.user_conf.placement =of_get_nand_ecc_placement (dn); + + strength =of_get_nand_ecc_strength (dn); +if (strength >=0 ) + nand->ecc.user_conf.strength = strength; + + size =of_get_nand_ecc_step_size (dn); +if (size >=0 ) + nand->ecc.user_conf.step_size = size; +} + +static void rawnand_ecc_read_legacy_user_conf (struct nand_chip *chip) +{ +struct device_node *dn =nand_get_flash_node (chip); +struct nand_device *nand = &chip->base; +struct nand_ecc_props *user_conf = &nand->ecc.user_conf; + +if (user_conf->engine_type !=NAND_ECC_ENGINE_TYPE_INVALID ) + user_conf->engine_type =of_get_rawnand_ecc_engine_type_legacy (dn); + +if (user_conf->algo !=NAND_ECC_ALGO_UNKNOWN ) + user_conf->algo =of_get_rawnand_ecc_algo_legacy (dn); + +if (user_conf->placement !=NAND_ECC_PLACEMENT_UNKNOWN ) + user_conf->placement =of_get_rawnand_ecc_placement_legacy (dn); +} +static int of_get_nand_bus_width (struct device_node *np) {u32 val;
@@ -5184,12 +5236,10 @@ static bool of_get_nand_on_flash_bbt(struct device_node *np)return of_property_read_bool (np,"nand-on-flash-bbt" ); } -static int nand_dt_init (struct nand_chip *chip) +static int rawnand_dt_init (struct nand_chip *chip) { +struct nand_device *nand =mtd_to_nanddev (nand_to_mtd (chip));struct device_node *dn =nand_get_flash_node (chip); -enum nand_ecc_engine_type ecc_type; -enum nand_ecc_algo ecc_algo; -int ecc_strength, ecc_step;if (!dn)return 0 ;
@@ -5203,27 +5253,33 @@ static int nand_dt_init(struct nand_chip *chip)if (of_get_nand_on_flash_bbt (dn)) chip->bbt_options |=NAND_BBT_USE_FLASH ; - ecc_type =of_get_nand_ecc_engine_type (dn); - ecc_algo =of_get_nand_ecc_algo (dn); - chip->ecc.placement =of_get_nand_ecc_placement (dn); - ecc_strength =of_get_nand_ecc_strength (dn); - ecc_step =of_get_nand_ecc_step_size (dn); - -if (ecc_type !=NAND_ECC_ENGINE_TYPE_INVALID ) - chip->ecc.engine_type = ecc_type; - -if (ecc_algo !=NAND_ECC_ALGO_UNKNOWN ) - chip->ecc.algo = ecc_algo; - -if (ecc_strength >=0 ) - chip->ecc.strength = ecc_strength; - -if (ecc_step >0 ) - chip->ecc.size = ecc_step; -if (of_property_read_bool (dn,"nand-ecc-maximize" )) chip->ecc.options |=NAND_ECC_MAXIMIZE ; +nand_ecc_read_user_conf (chip); +rawnand_ecc_read_legacy_user_conf (chip); + +/* +* If neither the user nor the NAND controller have requested a specific +* ECC engine type, we will default to NAND_ECC_ENGINE_TYPE_ON_HOST. +*/ + nand->ecc.defaults.engine_type =NAND_ECC_ENGINE_TYPE_ON_HOST ; + +/* +* Use the user requested engine type, unless there is none, in this +* case default to the NAND controller choice, otherwise fallback to +* the raw NAND default one. +*/ +if (nand->ecc.user_conf.engine_type !=NAND_ECC_ENGINE_TYPE_INVALID ) + chip->ecc.engine_type = nand->ecc.user_conf.engine_type; +if (chip->ecc.engine_type ==NAND_ECC_ENGINE_TYPE_INVALID ) + chip->ecc.engine_type = nand->ecc.defaults.engine_type; + + chip->ecc.placement = nand->ecc.user_conf.placement; + chip->ecc.algo = nand->ecc.user_conf.algo; + chip->ecc.strength = nand->ecc.user_conf.strength; + chip->ecc.size = nand->ecc.user_conf.step_size; +return 0 ; }
@@ -5260,7 +5316,7 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,/* Enforce the right timings for reset/detection */ onfi_fill_data_interface (chip,NAND_SDR_IFACE ,0 ); - ret =nand_dt_init (chip); + ret =rawnand_dt_init (chip);if (ret)return ret;
include/linux/mtd/rawnand.h +0 -12
@@ -80,18 +80,6 @@ struct nand_chip;#define NAND_DATA_IFACE_CHECK_ONLY -1 -/* -* Constants for ECC_MODES -*/ -enum nand_ecc_mode { -NAND_ECC_INVALID , -NAND_ECC_NONE , -NAND_ECC_SOFT , -NAND_ECC_HW , -NAND_ECC_HW_SYNDROME , -NAND_ECC_ON_DIE , -}; -/* * Constants for Hardware ECC */
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 19/20 mtd: rawnand: Move generic OOB layouts to the ECC framework
In reply to Miquel RaynalThese layouts can be used by any driver, move them to the ECC core.
--- drivers/mtd/nand/ecc.c | 176 ++++++++++++++++++++++++++++++ drivers/mtd/nand/raw/Kconfig | 1 + drivers/mtd/nand/raw/nand_base.c | 177 +------------------------------ include/linux/mtd/nand.h | 4 + include/linux/mtd/rawnand.h | 5 +- 5 files changed, 183 insertions(+), 180 deletions(-)
drivers/mtd/nand/ecc.c +176 -0
@@ -152,6 +152,182 @@ int nand_ecc_finish_io_req(struct nand_device *nand, }EXPORT_SYMBOL (nand_ecc_finish_io_req); +/* Define default oob placement schemes for large and small page devices */ +static int nand_ooblayout_ecc_sp (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section >1 ) +return -ERANGE ; + +if (!section) { + oobregion->offset =0 ; +if (mtd->oobsize ==16 ) + oobregion->length =4 ; +else + oobregion->length =3 ; + }else { +if (mtd->oobsize ==8 ) +return -ERANGE ; + + oobregion->offset =6 ; + oobregion->length = total_ecc_bytes -4 ; + } + +return 0 ; +} + +static int nand_ooblayout_free_sp (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +if (section >1 ) +return -ERANGE ; + +if (mtd->oobsize ==16 ) { +if (section) +return -ERANGE ; + + oobregion->length =8 ; + oobregion->offset =8 ; + }else { + oobregion->length =2 ; +if (!section) + oobregion->offset =3 ; +else + oobregion->offset =6 ; + } + +return 0 ; +} + +static const struct mtd_ooblayout_ops nand_ooblayout_sp_ops = { + .ecc = nand_ooblayout_ecc_sp, + .free = nand_ooblayout_free_sp, +}; + +const struct mtd_ooblayout_ops *nand_get_small_page_layout (void ) +{ +return &nand_ooblayout_sp_ops; +} +EXPORT_SYMBOL_GPL (nand_get_small_page_layout); + +static int nand_ooblayout_ecc_lp (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section || !total_ecc_bytes) +return -ERANGE ; + + oobregion->length = total_ecc_bytes; + oobregion->offset = mtd->oobsize - oobregion->length; + +return 0 ; +} + +static int nand_ooblayout_free_lp (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section) +return -ERANGE ; + + oobregion->length = mtd->oobsize - total_ecc_bytes -2 ; + oobregion->offset =2 ; + +return 0 ; +} + +static const struct mtd_ooblayout_ops nand_ooblayout_lp_ops = { + .ecc = nand_ooblayout_ecc_lp, + .free = nand_ooblayout_free_lp, +}; + +const struct mtd_ooblayout_ops *nand_get_large_page_layout (void ) +{ +return &nand_ooblayout_lp_ops; +} +EXPORT_SYMBOL_GPL (nand_get_large_page_layout); + +/* +* Support the old "large page" layout used for 1-bit Hamming ECC where ECC +* are placed at a fixed offset. +*/ +static int nand_ooblayout_ecc_lp_hamming (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section) +return -ERANGE ; + +switch (mtd->oobsize) { +case 64 : + oobregion->offset =40 ; +break ; +case 128 : + oobregion->offset =80 ; +break ; +default : +return -EINVAL ; + } + + oobregion->length = total_ecc_bytes; +if (oobregion->offset + oobregion->length > mtd->oobsize) +return -ERANGE ; + +return 0 ; +} + +static int nand_ooblayout_free_lp_hamming (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; +int ecc_offset =0 ; + +if (section <0 || section >1 ) +return -ERANGE ; + +switch (mtd->oobsize) { +case 64 : + ecc_offset =40 ; +break ; +case 128 : + ecc_offset =80 ; +break ; +default : +return -EINVAL ; + } + +if (section ==0 ) { + oobregion->offset =2 ; + oobregion->length = ecc_offset -2 ; + }else { + oobregion->offset = ecc_offset + total_ecc_bytes; + oobregion->length = mtd->oobsize - oobregion->offset; + } + +return 0 ; +} + +static const struct mtd_ooblayout_ops nand_ooblayout_lp_hamming_ops = { + .ecc = nand_ooblayout_ecc_lp_hamming, + .free = nand_ooblayout_free_lp_hamming, +}; + +const struct mtd_ooblayout_ops *nand_get_large_page_hamming_layout (void ) +{ +return &nand_ooblayout_lp_hamming_ops; +} +EXPORT_SYMBOL_GPL (nand_get_large_page_hamming_layout); +MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Miquel Raynal <[email protected]>" );MODULE_DESCRIPTION ("Generic ECC engine" );
drivers/mtd/nand/raw/Kconfig +1 -0
@@ -13,6 +13,7 @@ config MTD_NAND_ECC_SW_HAMMING_SMC menuconfig MTD_RAW_NAND tristate "Raw/Parallel NAND Device Support" select MTD_NAND_CORE + select MTD_NAND_ECC select MTD_NAND_ECC_SW_HAMMING help This enables support for accessing all type of raw/parallel
drivers/mtd/nand/raw/nand_base.c +1 -176
189 lines not on this page · raw message
include/linux/mtd/nand.h +4 -0
@@ -127,6 +127,10 @@ struct nand_page_io_req {int mode; }; +const struct mtd_ooblayout_ops *nand_get_small_page_layout (void ); +const struct mtd_ooblayout_ops *nand_get_large_page_layout (void ); +const struct mtd_ooblayout_ops *nand_get_large_page_hamming_layout (void ); +/** * enum nand_ecc_engine_type - NAND ECC engine type * @NAND_ECC_ENGINE_TYPE_INVALID: Invalid value
include/linux/mtd/rawnand.h +1 -4
@@ -14,6 +14,7 @@#define __LINUX_MTD_RAWNAND_H#include <linux/mtd/mtd.h> +#include <linux/mtd/nand.h> #include <linux/mtd/flashchip.h> #include <linux/mtd/bbm.h> #include <linux/mtd/jedec.h>
@@ -1147,10 +1148,6 @@ struct nand_chip {int (*unlock_area)(struct nand_chip *chip,loff_t ofs,uint64_t len); }; -const struct mtd_ooblayout_ops *nand_get_small_page_layout (void ); -const struct mtd_ooblayout_ops *nand_get_large_page_layout (void ); -const struct mtd_ooblayout_ops *nand_get_large_page_hamming_layout (void ); -static inline struct nand_chip *mtd_to_nand (struct mtd_info *mtd) { return container_of(mtd, struct nand_chip, base.mtd);
Signature · 1 line
2.20.1
Miquel Raynal
maintainerPATCH v7 20/20 mtd: rawnand: Move the user input parsing bits to the ECC framework
In reply to Miquel RaynalMany helpers are generic to all NAND chips, they should not be restricted to be only used by raw NAND controller drivers. They might later be used by generic ECC engines and SPI-NAND devices as well so move them into a more generic place.
To avoid moving all the raw NAND core "history" into the generic NAND layer, we already moved certain bits into legacy helpers in the raw NAND core to ensure backward compatibility.
--- drivers/mtd/nand/ecc.c | 138 +++++++++++++++++ drivers/mtd/nand/raw/atmel/nand-controller.c | 3 +- drivers/mtd/nand/raw/denali.c | 3 + drivers/mtd/nand/raw/nand_base.c | 149 ++----------------- drivers/mtd/nand/raw/sunxi_nand.c | 3 +- drivers/mtd/nand/raw/tegra_nand.c | 3 +- include/linux/mtd/nand.h | 7 + include/linux/mtd/rawnand.h | 1 - 8 files changed, 165 insertions(+), 142 deletions(-)
drivers/mtd/nand/ecc.c +138 -0
@@ -328,6 +328,144 @@ const struct mtd_ooblayout_ops *nand_get_large_page_hamming_layout(void) }EXPORT_SYMBOL_GPL (nand_get_large_page_hamming_layout); +static enum nand_ecc_engine_type +of_get_nand_ecc_engine_type (struct device_node *np) +{ +return NAND_ECC_ENGINE_TYPE_INVALID ; +} + +static const char *const nand_ecc_placement[] = { + [NAND_ECC_PLACEMENT_OOB ] ="oob" , + [NAND_ECC_PLACEMENT_INTERLEAVED ] ="interleaved" , +}; + +enum nand_ecc_placement of_get_nand_ecc_placement (struct device_node *np) +{ +enum nand_ecc_placement placement; +const char *pm; +int err; + + err =of_property_read_string (np,"nand-ecc-placement" , &pm); +if (!err) { +for (placement =NAND_ECC_PLACEMENT_OOB ; + placement <ARRAY_SIZE (nand_ecc_placement); placement++) { +if (!strcasecmp (pm, nand_ecc_placement[placement])) +return placement; + } + } + +return NAND_ECC_PLACEMENT_UNKNOWN ; +} + +static const char *const nand_ecc_algos[] = { + [NAND_ECC_ALGO_HAMMING ] ="hamming" , + [NAND_ECC_ALGO_BCH ] ="bch" , + [NAND_ECC_ALGO_RS ] ="rs" , +}; + +static enum nand_ecc_algo of_get_nand_ecc_algo (struct device_node *np) +{ +enum nand_ecc_algo ecc_algo; +const char *pm; +int err; + + err =of_property_read_string (np,"nand-ecc-algo" , &pm); +if (!err) { +for (ecc_algo =NAND_ECC_ALGO_HAMMING ; + ecc_algo <ARRAY_SIZE (nand_ecc_algos); + ecc_algo++) { +if (!strcasecmp (pm, nand_ecc_algos[ecc_algo])) +return ecc_algo; + } + } + +return NAND_ECC_ALGO_UNKNOWN ; +} + +static int of_get_nand_ecc_step_size (struct device_node *np) +{ +int ret; +u32 val; + + ret =of_property_read_u32 (np,"nand-ecc-step-size" , &val); +return ret ? ret : val; +} + +static int of_get_nand_ecc_strength (struct device_node *np) +{ +int ret; +u32 val; + + ret =of_property_read_u32 (np,"nand-ecc-strength" , &val); +return ret ? ret : val; +} + +static inline bool of_get_nand_ecc_maximize (struct device_node *np) +{ +return of_property_read_bool (np,"nand-ecc-maximize" ); +} + +void nand_ecc_read_user_conf (struct nand_device *nand) +{ +struct device_node *dn =nanddev_get_of_node (nand); +int strength, size; + + nand->ecc.user_conf.engine_type =of_get_nand_ecc_engine_type (dn); + nand->ecc.user_conf.algo =of_get_nand_ecc_algo (dn); + nand->ecc.user_conf.placement =of_get_nand_ecc_placement (dn); + + strength =of_get_nand_ecc_strength (dn); +if (strength >=0 ) + nand->ecc.user_conf.strength = strength; + + size =of_get_nand_ecc_step_size (dn); +if (size >=0 ) + nand->ecc.user_conf.step_size = size; + +if (of_get_nand_ecc_maximize (dn)) + nand->ecc.user_conf.flags |=NAND_ECC_MAXIMIZE ; +} +EXPORT_SYMBOL (nand_ecc_read_user_conf); + +/** +* nand_ecc_correction_is_enough - Check if the chip configuration meets the +* datasheet requirements. +* +* @nand: Device to check +* +* If our configuration corrects A bits per B bytes and the minimum +* required correction level is X bits per Y bytes, then we must ensure +* both of the following are true: +* +* (1) A / B >= X / Y +* (2) A >= X +* +* Requirement (1) ensures we can correct for the required bitflip density. +* Requirement (2) ensures we can correct even when all bitflips are clumped +* in the same sector. +*/ +bool nand_ecc_correction_is_enough (struct nand_device *nand) +{ +struct nand_ecc_props *reqs = &nand->ecc.requirements; +struct nand_ecc_props *conf = &nand->ecc.ctx.conf; +struct mtd_info *mtd =nanddev_to_mtd (nand); +int corr, ds_corr; + +if (conf->step_size ==0 || reqs->step_size ==0 ) +/* Not enough information */ +return true; + +/* +* We get the number of corrected bits per page to compare +* the correction density. +*/ + corr = (mtd->writesize * conf->strength) / conf->step_size; + ds_corr = (mtd->writesize * reqs->strength) / reqs->step_size; + +return corr >= ds_corr && conf->strength >= reqs->strength; +} +EXPORT_SYMBOL (nand_ecc_correction_is_enough); +MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Miquel Raynal <[email protected]>" );MODULE_DESCRIPTION ("Generic ECC engine" );
drivers/mtd/nand/raw/atmel/nand-controller.c +2 -1
@@ -1045,6 +1045,7 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip) {struct nand_ecc_props *requirements = &chip->base.ecc.requirements;struct mtd_info *mtd =nand_to_mtd (chip); +struct nand_device *nanddev =mtd_to_nanddev (mtd);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_nand_controller *nc;struct atmel_pmecc_user_req req;
@@ -1069,7 +1070,7 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip) chip->ecc.size = val; } -if (chip->ecc.options &NAND_ECC_MAXIMIZE ) +if (nanddev->ecc.user_conf.flags &NAND_ECC_MAXIMIZE ) req.ecc.strength =ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH ;else if (chip->ecc.strength) req.ecc.strength = chip->ecc.strength;
drivers/mtd/nand/raw/denali.c +3 -0
@@ -1181,6 +1181,7 @@ int denali_chip_init(struct denali_controller *denali, {struct nand_chip *chip = &dchip->chip;struct mtd_info *mtd =nand_to_mtd (chip); +struct nand_device *nanddev =mtd_to_nanddev (mtd);struct denali_chip *dchip2;int i, j, ret;
@@ -1248,6 +1249,8 @@ int denali_chip_init(struct denali_controller *denali,mtd_set_ooblayout (mtd, &denali_ooblayout_ops); + nanddev->ecc.user_conf.flags |=NAND_ECC_MAXIMIZE ; + ret =nand_scan (chip, dchip->nsels);if (ret)return ret;
drivers/mtd/nand/raw/nand_base.c +11 -138
233 lines not on this page · raw message
drivers/mtd/nand/raw/sunxi_nand.c +2 -1
@@ -1609,12 +1609,13 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,static const u8 strengths[] = {16 ,24 ,28 ,32 ,40 ,48 ,56 ,60 ,64 };struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct mtd_info *mtd =nand_to_mtd (nand); +struct nand_device *nanddev =mtd_to_nanddev (mtd);struct sunxi_nand_hw_ecc *data;int nsectors;int ret;int i; -if (ecc->options &NAND_ECC_MAXIMIZE ) { +if (nanddev->ecc.user_conf.flags &NAND_ECC_MAXIMIZE ) {int bytes; ecc->size =1024 ;
drivers/mtd/nand/raw/tegra_nand.c +2 -1
@@ -840,7 +840,8 @@ static int tegra_nand_get_strength(struct nand_chip *chip, const int *strength, int strength_len, int bits_per_step, int oobsize) { - bool maximize = chip->ecc.options & NAND_ECC_MAXIMIZE; + struct nand_device *nanddev = mtd_to_nanddev(nand_to_mtd(chip)); +bool maximize = nanddev->ecc.user_conf.flags &NAND_ECC_MAXIMIZE ;int i;/*
include/linux/mtd/nand.h +7 -0
@@ -182,6 +182,7 @@ enum nand_ecc_algo {* @algo: ECC algorithm (if relevant) * @strength: ECC strength * @step_size: Number of bytes per step +* @flags: Misc properties */ struct nand_ecc_props {enum nand_ecc_engine_type engine_type;
@@ -189,10 +190,14 @@ struct nand_ecc_props {enum nand_ecc_algo algo;unsigned int strength;unsigned int step_size; +unsigned int flags; };#define NAND_ECCREQ (str, stp) { .strength = (str), .step_size = (stp) } +/* NAND ECC misc flags */ +#define NAND_ECC_MAXIMIZE BIT(0) +/** * struct nand_bbt - bad block table object * @cache: in memory BBT cache
@@ -264,12 +269,14 @@ struct nand_ecc_engine {struct nand_ecc_engine_ops *ops; }; +void nand_ecc_read_user_conf (struct nand_device *nand);int nand_ecc_init_ctx (struct nand_device *nand);void nand_ecc_cleanup_ctx (struct nand_device *nand);int nand_ecc_prepare_io_req (struct nand_device *nand,struct nand_page_io_req *req);int nand_ecc_finish_io_req (struct nand_device *nand,struct nand_page_io_req *req); +bool nand_ecc_correction_is_enough (struct nand_device *nand);/** * struct nand_ecc - Information relative to the ECC
include/linux/mtd/rawnand.h +0 -1
@@ -98,7 +98,6 @@ struct nand_chip;* pages and you want to rely on the default implementation. */ #define NAND_ECC_GENERIC_ERASED_CHECK BIT(0) -#define NAND_ECC_MAXIMIZE BIT(1)/* * Option constants for bizarre disfunctionality and real
Signature · 1 line
2.20.1