Commit e5acf9c8 authored by Miquel Raynal's avatar Miquel Raynal

mtd: nand: ecc-hamming: Move Hamming code to the generic NAND layer

Hamming ECC code might be later re-used by the SPI NAND layer.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200929230124.31491-12-miquel.raynal@bootlin.com
parent cbd87780
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/io.h> #include <linux/io.h>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <net/ax88796.h> #include <net/ax88796.h>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include "devs.h" #include "devs.h"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/platform_data/asoc-s3c24xx_simtec.h> #include <linux/platform_data/asoc-s3c24xx_simtec.h>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include "gpio-cfg.h" #include "gpio-cfg.h"
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include "gpio-cfg.h" #include "gpio-cfg.h"
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include "cpu.h" #include "cpu.h"
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/memblock.h> #include <linux/memblock.h>
......
...@@ -152,6 +152,7 @@ config SM_FTL ...@@ -152,6 +152,7 @@ config SM_FTL
tristate "SmartMedia/xD new translation layer" tristate "SmartMedia/xD new translation layer"
depends on BLOCK depends on BLOCK
select MTD_BLKDEVS select MTD_BLKDEVS
select MTD_NAND_CORE
select MTD_NAND_ECC_SW_HAMMING select MTD_NAND_ECC_SW_HAMMING
help help
This enables EXPERIMENTAL R/W support for SmartMedia/xD This enables EXPERIMENTAL R/W support for SmartMedia/xD
......
...@@ -15,6 +15,17 @@ config MTD_NAND_ECC ...@@ -15,6 +15,17 @@ config MTD_NAND_ECC
bool bool
depends on MTD_NAND_CORE depends on MTD_NAND_CORE
config MTD_NAND_ECC_SW_HAMMING
bool
config MTD_NAND_ECC_SW_HAMMING_SMC
bool "NAND ECC Smart Media byte order"
depends on MTD_NAND_ECC_SW_HAMMING
default n
help
Software ECC according to the Smart Media Specification.
The original Linux implementation had byte 0 and 1 swapped.
config MTD_NAND_ECC_SW_BCH config MTD_NAND_ECC_SW_BCH
bool "Software BCH ECC engine" bool "Software BCH ECC engine"
select BCH select BCH
......
...@@ -8,4 +8,5 @@ obj-y += raw/ ...@@ -8,4 +8,5 @@ obj-y += raw/
obj-y += spi/ obj-y += spi/
nandcore-$(CONFIG_MTD_NAND_ECC) += ecc.o nandcore-$(CONFIG_MTD_NAND_ECC) += ecc.o
nandcore-$(CONFIG_MTD_NAND_ECC_SW_HAMMING) += ecc-sw-hamming.o
nandcore-$(CONFIG_MTD_NAND_ECC_SW_BCH) += ecc-sw-bch.o nandcore-$(CONFIG_MTD_NAND_ECC_SW_BCH) += ecc-sw-bch.o
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
/* /*
......
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
config MTD_NAND_ECC_SW_HAMMING
tristate
config MTD_NAND_ECC_SW_HAMMING_SMC
bool "NAND ECC Smart Media byte order"
depends on MTD_NAND_ECC_SW_HAMMING
default n
help
Software ECC according to the Smart Media Specification.
The original Linux implementation had byte 0 and 1 swapped.
menuconfig MTD_RAW_NAND menuconfig MTD_RAW_NAND
tristate "Raw/Parallel NAND Device Support" tristate "Raw/Parallel NAND Device Support"
select MTD_NAND_CORE select MTD_NAND_CORE
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MTD_RAW_NAND) += nand.o obj-$(CONFIG_MTD_RAW_NAND) += nand.o
obj-$(CONFIG_MTD_NAND_ECC_SW_HAMMING) += nand_ecc.o
obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o
obj-$(CONFIG_MTD_NAND_CAFE) += cafe_nand.o obj-$(CONFIG_MTD_NAND_CAFE) += cafe_nand.o
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <asm/io.h> #include <asm/io.h>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/fsl_ifc.h> #include <linux/fsl_ifc.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#define DRV_NAME "lpc32xx_mlc" #define DRV_NAME "lpc32xx_mlc"
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include "internals.h" #include "internals.h"
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/nand-ecc-sw-bch.h> #include <linux/mtd/nand-ecc-sw-bch.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/bitops.h> #include <linux/bitops.h>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/ndfc.h> #include <linux/mtd/ndfc.h>
#include <linux/slab.h> #include <linux/slab.h>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/platform_data/mtd-nand-s3c2410.h> #include <linux/platform_data/mtd-nand-s3c2410.h>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/sharpsl.h> #include <linux/mtd/sharpsl.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/slab.h> #include <linux/slab.h>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_data/txx9/ndfmc.h> #include <linux/platform_data/txx9/ndfmc.h>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include "nand/raw/sm_common.h" #include "nand/raw/sm_common.h"
#include "sm_ftl.h" #include "sm_ftl.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include "mtd_test.h" #include "mtd_test.h"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* This file is the header for the ECC algorithm. * This file is the header for the ECC algorithm.
*/ */
#ifndef __MTD_NAND_ECC_H__ #ifndef __MTD_NAND_ECC_SW_HAMMING_H__
#define __MTD_NAND_ECC_H__ #define __MTD_NAND_ECC_SW_HAMMING_H__
struct nand_chip; struct nand_chip;
...@@ -36,4 +36,4 @@ int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc, ...@@ -36,4 +36,4 @@ int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc,
int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc, int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc,
u_char *calc_ecc); u_char *calc_ecc);
#endif /* __MTD_NAND_ECC_H__ */ #endif /* __MTD_NAND_ECC_SW_HAMMING_H__ */
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define _MTD_SHARPSL_H #define _MTD_SHARPSL_H
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand-ecc-sw-hamming.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
struct sharpsl_nand_platform_data { struct sharpsl_nand_platform_data {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment