Skip to contentSkip to conversation

SPI-NAND support

PATCH Superseded Miquel Raynal 5 participants 41 messages Aug 1, 2018 – Aug 8, 2018

Subsystems (16)

v6 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Miquel Raynal

author maintainer
#0 lore raw

v6 cover SPI-NAND support

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

Changes since v4:
-----------------
* Added Jagan's Acked-by tags to every patch related to the SPI-mem/SPI-NAND addition.
* Rebased on top of master.

Changes since v3:
-----------------
* Fixed the debug messages in spi-mem to print either Rx or Tx data.
* Fixed a Kconfig error that prevented to build mtdparts with plain defconfig.
* Fixed a compilation error due to the above error that prevented one file to be compiled.
* Adapted the mtd command to probe MTD partitions also.
* Declared mtd_probe_devices() in a header so mtdparts or UBI could use it too (to probe all devices and MTD partitions in a clean way).
* As I worked on mtdparts, I found annoying and completely useless the fact that we need to prefix the environment variable with "mtdparts=". Canceled this obligation.
* Added one patch to allow spi-nand devices to be recognized by mtdparts (this is purely useless but needed to be done in order to use this command).
* Removed useless definitions of MTD device types in UBI code.
* Wrote a generic mtdparts environment variable parser, used by the mtd command.
* Used the mtd_probe_devices() function from get_mtd_info() in cmd/mtdparts.c to be sure the desired partition really does not exist (otherwise it will be probed and then found).

Changes since v2:
-----------------
* Rebased on u-boot master branch.
* Removed extra-parenthesis in
"mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing"
* s/fiels/files/ in "mtd: move NAND fiels into a raw/ subdirectory"
* Do not describe generic SPI device properties in SPI NAND bindings.
* Changes in the mtd command:
* Printing more information in 'mtd list' (device type, device characteristics)
* Switch to do_div() instead of '(u32)value64b % value32b' which only worked because value32b was a power of 2.
* Removed erase.chip option.
* By default, erase/read/write happen on the full MTD device while a dump will only work on a single page.

Changes since v1:
-----------------
* Fixed the nand_memorg structure of the MX35LF2GE4AB chip.
* Added Reviewed-by tags from Jagan.
* Backported and squashed two patches fixing things in the SPI NAND core received on the Linux ML.
* Backported more changes in mtdcore.c from Linux.
* Added a patch to add a fallback on mtd->_read/_write() in mtdcore.c when mtd->_read/write_oob() is not supported.
* Removed the DT changes, useless as the DTs are not available in mainline yet.
* Addressed Boris/Stefan comments on the 'mtd' command.
* Added support for multi-pages OOB read/write.

Boris Brezillon (7):
mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
mtd: Add sanity checks in mtd_write/read_oob()
mtd: nand: Add core infrastructure to deal with NAND devices
mtd: nand: Pass mode information to nand_page_io_req
spi: Extend the core to ease integration of SPI memory controllers
mtd: spinand: Add initial support for the MX35LF1GE4AB chip
dt-bindings: Add bindings for SPI NAND devices

Brian Norris (1):
mtd: add get/set of_node/flash_node helpers

Ezequiel Garcia (1):
mtd: Uninline mtd_write_oob and move it to mtdcore.c

Frieder Schrempf (1):
mtd: spinand: Add initial support for Winbond W25M02GV

Miquel Raynal (15):
mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing
mtd: fix build issue with includes
mtd: move definitions to enlarge their range
mtd: move all flash categories inside MTD submenu
mtd: move NAND files into a raw/ subdirectory
mtd: rename nand into rawnand in Kconfig prompt
mtd: spinand: Add initial support for the MX35LF2GE4AB chip
mtd: declare MTD_PARTITIONS symbol in Kconfig
cmd: ubi: delete useless and misleading definitions
cmd: mtdparts: accept spi-nand devices
cmd: mtdparts: add a generic 'mtdparts' parser
cmd: mtdparts: remove useless 'mtdparts=' prefix
mtd: uclass: add probe function
cmd: mtd: add 'mtd' command
cmd: mtdparts: try to probe the MTD devices as a fallback

Peter Pan (2):
mtd: nand: Add core infrastructure to support SPI NANDs
mtd: spinand: Add initial support for Micron MT29F2G01ABAGD

 MAINTAINERS                                   |    6 +-
 Makefile                                      |    2 +-
 README                                        |    6 +-
 arch/arm/mach-uniphier/board_late_init.c      |    2 +-
 cmd/Kconfig                                   |    7 +
 cmd/Makefile                                  |    1 +
 cmd/mtd.c                                     |  392 ++++++++
 cmd/mtdparts.c                                |  113 ++-
 cmd/ubi.c                                     |    5 -
 common/spl/Kconfig                            |    2 +-
 common/spl/spl_spi.c                          |    2 +-
 doc/README.SPL                                |    4 +-
 doc/README.arm-relocation                     |    2 +-
 doc/README.nand                               |    6 +-
 doc/README.zynq                               |    2 +-
 doc/device-tree-bindings/mtd/spi-nand.txt     |    5 +
 drivers/Makefile                              |    2 +-
 drivers/mtd/Kconfig                           |    7 +-
 drivers/mtd/Makefile                          |    4 +-
 drivers/mtd/mtd-uclass.c                      |    9 +
 drivers/mtd/mtdcore.c                         |  106 ++-
 drivers/mtd/mtdcore.h                         |    6 -
 drivers/mtd/mtdpart.c                         |    6 +-
 drivers/mtd/nand/Kconfig                      |  299 +-----
 drivers/mtd/nand/Makefile                     |   78 +-
 drivers/mtd/nand/bbt.c                        |  132 +++
 drivers/mtd/nand/core.c                       |  243 +++++
 drivers/mtd/nand/raw/Kconfig                  |  297 ++++++
 drivers/mtd/nand/raw/Makefile                 |   77 ++
 drivers/mtd/nand/{ => raw}/am335x_spl_bch.c   |    0
 drivers/mtd/nand/{ => raw}/arasan_nfc.c       |    0
 drivers/mtd/nand/{ => raw}/atmel_nand.c       |    0
 drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h   |    0
 drivers/mtd/nand/{ => raw}/davinci_nand.c     |    2 +-
 drivers/mtd/nand/{ => raw}/denali.c           |    0
 drivers/mtd/nand/{ => raw}/denali.h           |    0
 drivers/mtd/nand/{ => raw}/denali_dt.c        |    0
 drivers/mtd/nand/{ => raw}/denali_spl.c       |    0
 drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c    |    0
 drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c     |    0
 drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c     |    0
 drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c      |    0
 drivers/mtd/nand/{ => raw}/fsl_upm.c          |    0
 drivers/mtd/nand/{ => raw}/fsmc_nand.c        |    0
 drivers/mtd/nand/{ => raw}/kb9202_nand.c      |    0
 drivers/mtd/nand/{ => raw}/kirkwood_nand.c    |    0
 drivers/mtd/nand/{ => raw}/kmeter1_nand.c     |    0
 drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c |    0
 drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c |    0
 drivers/mtd/nand/{ => raw}/mxc_nand.c         |    0
 drivers/mtd/nand/{ => raw}/mxc_nand.h         |    0
 drivers/mtd/nand/{ => raw}/mxc_nand_spl.c     |    0
 drivers/mtd/nand/{ => raw}/mxs_nand.c         |    0
 drivers/mtd/nand/{ => raw}/mxs_nand.h         |    0
 drivers/mtd/nand/{ => raw}/mxs_nand_dt.c      |    0
 drivers/mtd/nand/{ => raw}/mxs_nand_spl.c     |    0
 drivers/mtd/nand/{ => raw}/nand.c             |    0
 drivers/mtd/nand/{ => raw}/nand_base.c        |   56 --
 drivers/mtd/nand/{ => raw}/nand_bbt.c         |    0
 drivers/mtd/nand/{ => raw}/nand_bch.c         |    0
 drivers/mtd/nand/{ => raw}/nand_ecc.c         |    2 +-
 drivers/mtd/nand/{ => raw}/nand_ids.c         |    0
 drivers/mtd/nand/{ => raw}/nand_plat.c        |    0
 drivers/mtd/nand/{ => raw}/nand_spl_load.c    |    0
 drivers/mtd/nand/{ => raw}/nand_spl_loaders.c |    0
 drivers/mtd/nand/{ => raw}/nand_spl_simple.c  |    0
 drivers/mtd/nand/{ => raw}/nand_timings.c     |    0
 drivers/mtd/nand/{ => raw}/nand_util.c        |    2 +-
 drivers/mtd/nand/{ => raw}/omap_elm.c         |    0
 drivers/mtd/nand/{ => raw}/omap_gpmc.c        |    0
 drivers/mtd/nand/{ => raw}/pxa3xx_nand.c      |    2 +-
 drivers/mtd/nand/{ => raw}/pxa3xx_nand.h      |    0
 drivers/mtd/nand/{ => raw}/sunxi_nand.c       |    0
 drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c   |    0
 drivers/mtd/nand/{ => raw}/tegra_nand.c       |    0
 drivers/mtd/nand/{ => raw}/tegra_nand.h       |    0
 drivers/mtd/nand/{ => raw}/vf610_nfc.c        |    0
 drivers/mtd/nand/{ => raw}/zynq_nand.c        |    0
 drivers/mtd/nand/spi/Kconfig                  |    7 +
 drivers/mtd/nand/spi/Makefile                 |    4 +
 drivers/mtd/nand/spi/core.c                   | 1254 +++++++++++++++++++++++++
 drivers/mtd/nand/spi/macronix.c               |  146 +++
 drivers/mtd/nand/spi/micron.c                 |  135 +++
 drivers/mtd/nand/spi/winbond.c                |  143 +++
 drivers/mtd/onenand/onenand_base.c            |   60 --
 drivers/spi/Kconfig                           |    7 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-mem.c                         |  500 ++++++++++
 include/configs/MPC8313ERDB.h                 |    2 +-
 include/jffs2/load_kernel.h                   |    7 +-
 include/linux/mtd/mtd.h                       |   34 +-
 include/linux/mtd/nand.h                      |  734 +++++++++++++++
 include/linux/mtd/partitions.h                |    3 +
 include/linux/mtd/spinand.h                   |  432 +++++++++
 include/spi-mem.h                             |  258 +++++
 include/spi.h                                 |   11 +
 96 files changed, 5064 insertions(+), 561 deletions(-)
 create mode 100644 cmd/mtd.c
 create mode 100644 doc/device-tree-bindings/mtd/spi-nand.txt
 create mode 100644 drivers/mtd/nand/bbt.c
 create mode 100644 drivers/mtd/nand/core.c
 create mode 100644 drivers/mtd/nand/raw/Kconfig
 create mode 100644 drivers/mtd/nand/raw/Makefile
 rename drivers/mtd/nand/{ => raw}/am335x_spl_bch.c (100%)
 rename drivers/mtd/nand/{ => raw}/arasan_nfc.c (100%)
 rename drivers/mtd/nand/{ => raw}/atmel_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h (100%)
 rename drivers/mtd/nand/{ => raw}/davinci_nand.c (99%)
 rename drivers/mtd/nand/{ => raw}/denali.c (100%)
 rename drivers/mtd/nand/{ => raw}/denali.h (100%)
 rename drivers/mtd/nand/{ => raw}/denali_dt.c (100%)
 rename drivers/mtd/nand/{ => raw}/denali_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_upm.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsmc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/kb9202_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/kirkwood_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/kmeter1_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c (100%)
 rename drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxc_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/mxc_nand_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand_dt.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_base.c (98%)
 rename drivers/mtd/nand/{ => raw}/nand_bbt.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_bch.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_ecc.c (99%)
 rename drivers/mtd/nand/{ => raw}/nand_ids.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_plat.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_spl_load.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_spl_loaders.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_spl_simple.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_timings.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_util.c (99%)
 rename drivers/mtd/nand/{ => raw}/omap_elm.c (100%)
 rename drivers/mtd/nand/{ => raw}/omap_gpmc.c (100%)
 rename drivers/mtd/nand/{ => raw}/pxa3xx_nand.c (99%)
 rename drivers/mtd/nand/{ => raw}/pxa3xx_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/sunxi_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/tegra_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/tegra_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/vf610_nfc.c (100%)
 rename drivers/mtd/nand/{ => raw}/zynq_nand.c (100%)
 create mode 100644 drivers/mtd/nand/spi/Kconfig
 create mode 100644 drivers/mtd/nand/spi/Makefile
 create mode 100644 drivers/mtd/nand/spi/core.c
 create mode 100644 drivers/mtd/nand/spi/macronix.c
 create mode 100644 drivers/mtd/nand/spi/micron.c
 create mode 100644 drivers/mtd/nand/spi/winbond.c
 create mode 100644 drivers/spi/spi-mem.c
 create mode 100644 include/linux/mtd/nand.h
 create mode 100644 include/linux/mtd/spinand.h
 create mode 100644 include/spi-mem.h
Signature · 1 line
2.14.1
author maintainer
#1 lore raw

PATCH v6 1/27 mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing

From: Boris Brezillon <[email protected]>

Some MTD sublayers/drivers are implementing ->_read/write_oob() and provide dummy wrappers for their ->_read/write() implementations. Let the core handle this case instead of duplicating the logic.

---
 drivers/mtd/mtdcore.c              | 31 ++++++++++++++++++--
 drivers/mtd/mtdpart.c              |  6 ++--
 drivers/mtd/nand/nand_base.c       | 56 -----------------------------------
 drivers/mtd/onenand/onenand_base.c | 60 --------------------------------------
 4 files changed, 33 insertions(+), 120 deletions(-)
drivers/mtd/mtdcore.c +29 -2
index 6217be2352..60ad28efd4 100644
@@ -937,7 +937,20 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
 	 * representing the maximum number of bitflips that were corrected on
 	 * any one ecc region (if applicable; zero otherwise).
 	 */
-	ret_code = mtd->_read(mtd, from, len, retlen, buf);
+	if (mtd->_read) {
+		ret_code = mtd->_read(mtd, from, len, retlen, buf);
+	} else if (mtd->_read_oob) {
+		struct mtd_oob_ops ops = {
+			.len = len,
+			.datbuf = buf,
+		};
+
+		ret_code = mtd->_read_oob(mtd, from, &ops);
+		*retlen = ops.retlen;
+	} else {
+		return -ENOTSUPP;
+	}
+
 	if (unlikely(ret_code < 0))
 		return ret_code;
 	if (mtd->ecc_strength == 0)
@@ -952,10 +965,24 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 	*retlen = 0;
 	if (to < 0 || to > mtd->size || len > mtd->size - to)
 		return -EINVAL;
-	if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE))
+	if ((!mtd->_write && !mtd->_write_oob) ||
+	    !(mtd->flags & MTD_WRITEABLE))
 		return -EROFS;
 	if (!len)
 		return 0;
+
+	if (!mtd->_write) {
+		struct mtd_oob_ops ops = {
+			.len = len,
+			.datbuf = (u8 *)buf,
+		};
+		int ret;
+
+		ret = mtd->_write_oob(mtd, to, &ops);
+		*retlen = ops.retlen;
+		return ret;
+	}
+
 	return mtd->_write(mtd, to, len, retlen, buf);
 }
 EXPORT_SYMBOL_GPL(mtd_write);
drivers/mtd/mtdpart.c +4 -2
index f87c962205..ccbb1757ea 100644
@@ -417,8 +417,10 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
 	slave->mtd.dev.parent = master->dev.parent;
 #endif
 
-	slave->mtd._read = part_read;
-	slave->mtd._write = part_write;
+	if (master->_read)
+		slave->mtd._read = part_read;
+	if (master->_write)
+		slave->mtd._write = part_write;
 
 	if (master->_panic_write)
 		slave->mtd._panic_write = part_panic_write;
drivers/mtd/nand/nand_base.c +0 -56

74 lines not on this page · raw message

drivers/mtd/onenand/onenand_base.c +0 -60

78 lines not on this page · raw message

Signature · 1 line
2.14.1
author maintainer
#2 lore raw

PATCH v6 2/27 mtd: Uninline mtd_write_oob and move it to mtdcore.c

In reply to Miquel Raynal

From: Ezequiel Garcia <[email protected]>

There's no reason for having mtd_write_oob inlined in mtd.h header. Move it to mtdcore.c where it belongs.

---
 drivers/mtd/mtdcore.c   | 12 ++++++++++++
 include/linux/mtd/mtd.h | 12 +-----------
 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/mtd/mtdcore.c +12 -0
index 60ad28efd4..ad61406dac 100644
@@ -1031,6 +1031,18 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
 }
 EXPORT_SYMBOL_GPL(mtd_read_oob);
 
+int mtd_write_oob(struct mtd_info *mtd, loff_t to,
+				struct mtd_oob_ops *ops)
+{
+	ops->retlen = ops->oobretlen = 0;
+	if (!mtd->_write_oob)
+		return -EOPNOTSUPP;
+	if (!(mtd->flags & MTD_WRITEABLE))
+		return -EROFS;
+	return mtd->_write_oob(mtd, to, ops);
+}
+EXPORT_SYMBOL_GPL(mtd_write_oob);
+
 /**
  * mtd_ooblayout_ecc - Get the OOB region definition of a specific ECC section
  * @mtd: MTD device structure
include/linux/mtd/mtd.h +1 -11
index 823e535b82..eb39f38887 100644
@@ -351,17 +351,7 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 		    const u_char *buf);
 
 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
-
-static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
-				struct mtd_oob_ops *ops)
-{
-	ops->retlen = ops->oobretlen = 0;
-	if (!mtd->_write_oob)
-		return -EOPNOTSUPP;
-	if (!(mtd->flags & MTD_WRITEABLE))
-		return -EROFS;
-	return mtd->_write_oob(mtd, to, ops);
-}
+int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
 
 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
 			   struct otp_info *buf);
Signature · 1 line
2.14.1
author maintainer
#3 lore raw

PATCH v6 3/27 mtd: Add sanity checks in mtd_write/read_oob()

In reply to Miquel Raynal

From: Boris Brezillon <[email protected]>

Unlike what's done in mtd_read/write(), there are no checks to make sure the parameters passed to mtd_read/write_oob() are consistent, which forces implementers of ->_read/write_oob() to do it, which in turn leads to code duplication and possibly errors in the logic.

Do general sanity checks, like ops fields consistency and range checking.

Cc Peter Pan <[email protected]>
[Miquel: squashed the fix about the chip's size check]
---
 drivers/mtd/mtdcore.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
drivers/mtd/mtdcore.c +45 -0
index ad61406dac..9a3efe95df 100644
@@ -1010,12 +1010,50 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 }
 EXPORT_SYMBOL_GPL(mtd_panic_write);
 
+static int mtd_check_oob_ops(struct mtd_info *mtd, loff_t offs,
+			     struct mtd_oob_ops *ops)
+{
+	/*
+	 * Some users are setting ->datbuf or ->oobbuf to NULL, but are leaving
+	 * ->len or ->ooblen uninitialized. Force ->len and ->ooblen to 0 in
+	 *  this case.
+	 */
+	if (!ops->datbuf)
+		ops->len = 0;
+
+	if (!ops->oobbuf)
+		ops->ooblen = 0;
+
+	if (offs < 0 || offs + ops->len > mtd->size)
+		return -EINVAL;
+
+	if (ops->ooblen) {
+		u64 maxooblen;
+
+		if (ops->ooboffs >= mtd_oobavail(mtd, ops))
+			return -EINVAL;
+
+		maxooblen = ((mtd_div_by_ws(mtd->size, mtd) -
+			      mtd_div_by_ws(offs, mtd)) *
+			     mtd_oobavail(mtd, ops)) - ops->ooboffs;
+		if (ops->ooblen > maxooblen)
+			return -EINVAL;
+	}
+
+	return 0;
+}
+
 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
 {
 	int ret_code;
 	ops->retlen = ops->oobretlen = 0;
 	if (!mtd->_read_oob)
 		return -EOPNOTSUPP;
+
+	ret_code = mtd_check_oob_ops(mtd, from, ops);
+	if (ret_code)
+		return ret_code;
+
 	/*
 	 * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
 	 * similar to mtd->_read(), returning a non-negative integer
@@ -1034,11 +1072,18 @@ EXPORT_SYMBOL_GPL(mtd_read_oob);
 int mtd_write_oob(struct mtd_info *mtd, loff_t to,
 				struct mtd_oob_ops *ops)
 {
+	int ret;
+
 	ops->retlen = ops->oobretlen = 0;
 	if (!mtd->_write_oob)
 		return -EOPNOTSUPP;
 	if (!(mtd->flags & MTD_WRITEABLE))
 		return -EROFS;
+
+	ret = mtd_check_oob_ops(mtd, to, ops);
+	if (ret)
+		return ret;
+
 	return mtd->_write_oob(mtd, to, ops);
 }
 EXPORT_SYMBOL_GPL(mtd_write_oob);
Signature · 1 line
2.14.1
author maintainer
#4 lore raw

PATCH v6 4/27 mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing

In reply to Miquel Raynal

Some MTD sublayers/drivers are implementing ->_read/write() and not ->_read/write_oob().

While for NAND devices both are usually valid, for NOR devices, using the _oob variant has no real meaning. But, as the MTD layer is supposed to hide as much as possible the flash complexity to the user, there is no reason to error out while it is just a matter of rewritting things internally.

Add a fallback on mtd->_read() (resp. mtd->_write()) when the user calls mtd_read_oob() (resp. mtd_write_oob()) while mtd->_read_oob() (resp. mtd->_write_oob) is not implemented. There is already a fallback on the _oob variant if the former is used.

---
 drivers/mtd/mtdcore.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/mtd/mtdcore.c +20 -6
index 9a3efe95df..fb1d68d5e2 100644
@@ -1047,20 +1047,27 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
 {
 	int ret_code;
 	ops->retlen = ops->oobretlen = 0;
-	if (!mtd->_read_oob)
-		return -EOPNOTSUPP;
 
 	ret_code = mtd_check_oob_ops(mtd, from, ops);
 	if (ret_code)
 		return ret_code;
 
+	/* Check the validity of a potential fallback on mtd->_read */
+	if (!mtd->_read_oob && (!mtd->_read || ops->oobbuf))
+		return -EOPNOTSUPP;
+
+	if (mtd->_read_oob)
+		ret_code = mtd->_read_oob(mtd, from, ops);
+	else
+		ret_code = mtd->_read(mtd, from, ops->len, &ops->retlen,
+				      ops->datbuf);
+
 	/*
 	 * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
 	 * similar to mtd->_read(), returning a non-negative integer
 	 * representing max bitflips. In other cases, mtd->_read_oob() may
 	 * return -EUCLEAN. In all cases, perform similar logic to mtd_read().
 	 */
-	ret_code = mtd->_read_oob(mtd, from, ops);
 	if (unlikely(ret_code < 0))
 		return ret_code;
 	if (mtd->ecc_strength == 0)
@@ -1075,8 +1082,7 @@ int mtd_write_oob(struct mtd_info *mtd, loff_t to,
 	int ret;
 
 	ops->retlen = ops->oobretlen = 0;
-	if (!mtd->_write_oob)
-		return -EOPNOTSUPP;
+
 	if (!(mtd->flags & MTD_WRITEABLE))
 		return -EROFS;
 
@@ -1084,7 +1090,15 @@ int mtd_write_oob(struct mtd_info *mtd, loff_t to,
 	if (ret)
 		return ret;
 
-	return mtd->_write_oob(mtd, to, ops);
+	/* Check the validity of a potential fallback on mtd->_write */
+	if (!mtd->_write_oob && (!mtd->_write || ops->oobbuf))
+		return -EOPNOTSUPP;
+
+	if (mtd->_write_oob)
+		return mtd->_write_oob(mtd, to, ops);
+	else
+		return mtd->_write(mtd, to, ops->len, &ops->retlen,
+				   ops->datbuf);
 }
 EXPORT_SYMBOL_GPL(mtd_write_oob);
 
Signature · 1 line
2.14.1
author maintainer
#5 lore raw

PATCH v6 5/27 mtd: add get/set of_node/flash_node helpers

In reply to Miquel Raynal

From: Brian Norris <[email protected]>

We are going to begin using the mtd->dev.of_node field for MTD device nodes, so let's add helpers for it. Also, we'll be making some conversions on spi_nor (and nand_chip eventually) too, so get that ready with their own helpers.

---
 include/linux/mtd/mtd.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/linux/mtd/mtd.h +11 -0
index eb39f38887..ea659c354b 100644
@@ -306,6 +306,17 @@ struct mtd_info {
 	int usecount;
 };
 
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+				   const struct device_node *np)
+{
+	mtd->dev->node.np = np;
+}
+
+static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+	return mtd->dev->node.np;
+}
+
 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
 		      struct mtd_oob_region *oobecc);
 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
Signature · 1 line
2.14.1
author maintainer
#6 lore raw

PATCH v6 6/27 mtd: fix build issue with includes

In reply to Miquel Raynal

Fix build errors produced by mtd.h and dm/device.h if not included in the right order.

---
 include/linux/mtd/mtd.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/mtd/mtd.h +1 -0
index ea659c354b..8def104627 100644
@@ -21,6 +21,7 @@
 #include <mtd/mtd-abi.h>
 #include <linux/errno.h>
 #include <div64.h>
+#include <dm/device.h>
 
 #define MAX_MTD_DEVICES 32
 #endif
Signature · 1 line
2.14.1
author maintainer
#7 lore raw

PATCH v6 7/27 mtd: move definitions to enlarge their range

In reply to Miquel Raynal

Some helpers might be useful in a future 'mtd' U-Boot command to parse MTD device list.

---
 drivers/mtd/mtdcore.h   | 6 ------
 include/linux/mtd/mtd.h | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/mtd/mtdcore.h +0 -6
index 7b0353399a..1d181a1045 100644
@@ -5,7 +5,6 @@
 
 extern struct mutex mtd_table_mutex;
 
-struct mtd_info *__mtd_next_device(int i);
 int add_mtd_device(struct mtd_info *mtd);
 int del_mtd_device(struct mtd_info *mtd);
 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
@@ -16,8 +15,3 @@ int parse_mtd_partitions(struct mtd_info *master, const char * const *types,
 
 int __init init_mtdchar(void);
 void __exit cleanup_mtdchar(void);
-
-#define mtd_for_each_device(mtd)			\
-	for ((mtd) = __mtd_next_device(0);		\
-	     (mtd) != NULL;				\
-	     (mtd) = __mtd_next_device(mtd->index + 1))
include/linux/mtd/mtd.h +6 -0
index 8def104627..6771ee2586 100644
@@ -517,6 +517,12 @@ int del_mtd_device(struct mtd_info *mtd);
 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
 int del_mtd_partitions(struct mtd_info *);
 
+struct mtd_info *__mtd_next_device(int i);
+#define mtd_for_each_device(mtd)			\
+	for ((mtd) = __mtd_next_device(0);		\
+	     (mtd) != NULL;				\
+	     (mtd) = __mtd_next_device(mtd->index + 1))
+
 int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
 		loff_t *maxsize, int devtype, uint64_t chipsize);
 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
Signature · 1 line
2.14.1
author maintainer
#8 lore raw

PATCH v6 8/27 mtd: move all flash categories inside MTD submenu

In reply to Miquel Raynal

There is no reason to have NAND, SPI flashes and UBI sections outside of the MTD submenu in Kconfig.

---
 drivers/mtd/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/Kconfig +2 -2
index 41f8883ec2..9341d518f3 100644
@@ -59,10 +59,10 @@ config RENESAS_RPC_HF
 	  This enables access to Hyperflash memory through the Renesas
 	  RCar Gen3 RPC controller.
 
-endmenu
-
 source "drivers/mtd/nand/Kconfig"
 
 source "drivers/mtd/spi/Kconfig"
 
 source "drivers/mtd/ubi/Kconfig"
+
+endmenu
Signature · 1 line
2.14.1
author maintainer
#9 lore raw

PATCH v6 9/27 mtd: move NAND files into a raw/ subdirectory

In reply to Miquel Raynal

NAND flavors, like serial and parallel, have a lot in common and would benefit to share code. Let's move raw (parallel) NAND specific code in a raw/ subdirectory, to ease the addition of a core file in nand/ and the introduction of a spi/ subdirectory specific to SPI NANDs.

Documentation, README*, and MAINTAINERS files are updated accordingly.

---
 MAINTAINERS                                   |   6 +-
 Makefile                                      |   2 +-
 README                                        |   6 +-
 arch/arm/mach-uniphier/board_late_init.c      |   2 +-
 common/spl/Kconfig                            |   2 +-
 common/spl/spl_spi.c                          |   2 +-
 doc/README.SPL                                |   4 +-
 doc/README.arm-relocation                     |   2 +-
 doc/README.nand                               |   6 +-
 doc/README.zynq                               |   2 +-
 drivers/Makefile                              |   2 +-
 drivers/mtd/Makefile                          |   2 +
 drivers/mtd/nand/Kconfig                      | 298 +-------------------------
 drivers/mtd/nand/Makefile                     |  75 -------
 drivers/mtd/nand/raw/Kconfig                  | 297 +++++++++++++++++++++++++
 drivers/mtd/nand/raw/Makefile                 |  77 +++++++
 drivers/mtd/nand/{ => raw}/am335x_spl_bch.c   |   0
 drivers/mtd/nand/{ => raw}/arasan_nfc.c       |   0
 drivers/mtd/nand/{ => raw}/atmel_nand.c       |   0
 drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h   |   0
 drivers/mtd/nand/{ => raw}/davinci_nand.c     |   2 +-
 drivers/mtd/nand/{ => raw}/denali.c           |   0
 drivers/mtd/nand/{ => raw}/denali.h           |   0
 drivers/mtd/nand/{ => raw}/denali_dt.c        |   0
 drivers/mtd/nand/{ => raw}/denali_spl.c       |   0
 drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c    |   0
 drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c     |   0
 drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c     |   0
 drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c      |   0
 drivers/mtd/nand/{ => raw}/fsl_upm.c          |   0
 drivers/mtd/nand/{ => raw}/fsmc_nand.c        |   0
 drivers/mtd/nand/{ => raw}/kb9202_nand.c      |   0
 drivers/mtd/nand/{ => raw}/kirkwood_nand.c    |   0
 drivers/mtd/nand/{ => raw}/kmeter1_nand.c     |   0
 drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c |   0
 drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c |   0
 drivers/mtd/nand/{ => raw}/mxc_nand.c         |   0
 drivers/mtd/nand/{ => raw}/mxc_nand.h         |   0
 drivers/mtd/nand/{ => raw}/mxc_nand_spl.c     |   0
 drivers/mtd/nand/{ => raw}/mxs_nand.c         |   0
 drivers/mtd/nand/{ => raw}/mxs_nand.h         |   0
 drivers/mtd/nand/{ => raw}/mxs_nand_dt.c      |   0
 drivers/mtd/nand/{ => raw}/mxs_nand_spl.c     |   0
 drivers/mtd/nand/{ => raw}/nand.c             |   0
 drivers/mtd/nand/{ => raw}/nand_base.c        |   0
 drivers/mtd/nand/{ => raw}/nand_bbt.c         |   0
 drivers/mtd/nand/{ => raw}/nand_bch.c         |   0
 drivers/mtd/nand/{ => raw}/nand_ecc.c         |   2 +-
 drivers/mtd/nand/{ => raw}/nand_ids.c         |   0
 drivers/mtd/nand/{ => raw}/nand_plat.c        |   0
 drivers/mtd/nand/{ => raw}/nand_spl_load.c    |   0
 drivers/mtd/nand/{ => raw}/nand_spl_loaders.c |   0
 drivers/mtd/nand/{ => raw}/nand_spl_simple.c  |   0
 drivers/mtd/nand/{ => raw}/nand_timings.c     |   0
 drivers/mtd/nand/{ => raw}/nand_util.c        |   2 +-
 drivers/mtd/nand/{ => raw}/omap_elm.c         |   0
 drivers/mtd/nand/{ => raw}/omap_gpmc.c        |   0
 drivers/mtd/nand/{ => raw}/pxa3xx_nand.c      |   2 +-
 drivers/mtd/nand/{ => raw}/pxa3xx_nand.h      |   0
 drivers/mtd/nand/{ => raw}/sunxi_nand.c       |   0
 drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c   |   0
 drivers/mtd/nand/{ => raw}/tegra_nand.c       |   0
 drivers/mtd/nand/{ => raw}/tegra_nand.h       |   0
 drivers/mtd/nand/{ => raw}/vf610_nfc.c        |   0
 drivers/mtd/nand/{ => raw}/zynq_nand.c        |   0
 include/configs/MPC8313ERDB.h                 |   2 +-
 66 files changed, 400 insertions(+), 395 deletions(-)
 create mode 100644 drivers/mtd/nand/raw/Kconfig
 create mode 100644 drivers/mtd/nand/raw/Makefile
 rename drivers/mtd/nand/{ => raw}/am335x_spl_bch.c (100%)
 rename drivers/mtd/nand/{ => raw}/arasan_nfc.c (100%)
 rename drivers/mtd/nand/{ => raw}/atmel_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h (100%)
 rename drivers/mtd/nand/{ => raw}/davinci_nand.c (99%)
 rename drivers/mtd/nand/{ => raw}/denali.c (100%)
 rename drivers/mtd/nand/{ => raw}/denali.h (100%)
 rename drivers/mtd/nand/{ => raw}/denali_dt.c (100%)
 rename drivers/mtd/nand/{ => raw}/denali_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_upm.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsmc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/kb9202_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/kirkwood_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/kmeter1_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c (100%)
 rename drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxc_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/mxc_nand_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand_dt.c (100%)
 rename drivers/mtd/nand/{ => raw}/mxs_nand_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_base.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_bbt.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_bch.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_ecc.c (99%)
 rename drivers/mtd/nand/{ => raw}/nand_ids.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_plat.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_spl_load.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_spl_loaders.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_spl_simple.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_timings.c (100%)
 rename drivers/mtd/nand/{ => raw}/nand_util.c (99%)
 rename drivers/mtd/nand/{ => raw}/omap_elm.c (100%)
 rename drivers/mtd/nand/{ => raw}/omap_gpmc.c (100%)
 rename drivers/mtd/nand/{ => raw}/pxa3xx_nand.c (99%)
 rename drivers/mtd/nand/{ => raw}/pxa3xx_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/sunxi_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/tegra_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/tegra_nand.h (100%)
 rename drivers/mtd/nand/{ => raw}/vf610_nfc.c (100%)
 rename drivers/mtd/nand/{ => raw}/zynq_nand.c (100%)
MAINTAINERS +3 -3
index e44280ceb6..63f2457494 100644
@@ -281,7 +281,7 @@ F:	drivers/i2c/i2c-cdns.c
 F:	drivers/i2c/muxes/pca954x.c
 F:	drivers/i2c/zynq_i2c.c
 F:	drivers/mmc/zynq_sdhci.c
-F:	drivers/mtd/nand/zynq_nand.c
+F:	drivers/mtd/nand/raw/zynq_nand.c
 F:	drivers/net/phy/xilinx_phy.c
 F:	drivers/net/zynq_gem.c
 F:	drivers/serial/serial_zynq.c
@@ -305,7 +305,7 @@ F:	drivers/i2c/i2c-cdns.c
 F:	drivers/i2c/muxes/pca954x.c
 F:	drivers/i2c/zynq_i2c.c
 F:	drivers/mmc/zynq_sdhci.c
-F:	drivers/mtd/nand/zynq_nand.c
+F:	drivers/mtd/nand/raw/zynq_nand.c
 F:	drivers/net/phy/xilinx_phy.c
 F:	drivers/net/zynq_gem.c
 F:	drivers/serial/serial_zynq.c
@@ -440,7 +440,7 @@ NAND FLASH
 #M:	Scott Wood <[email protected]>
 S:	Orphaned (Since 2018-07)
 T:	git git://git.denx.de/u-boot-nand-flash.git
-F:	drivers/mtd/nand/
+F:	drivers/mtd/nand/raw/
 
 NDS32
 M:	Macpaul Lin <[email protected]>
Makefile +1 -1
index 675d011c95..a54bffb3ef 100644
@@ -685,7 +685,7 @@ libs-y += drivers/dma/
 libs-y += drivers/gpio/
 libs-y += drivers/i2c/
 libs-y += drivers/mtd/
-libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
+libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/raw/
 libs-y += drivers/mtd/onenand/
 libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
 libs-y += drivers/mtd/spi/
README +3 -3
index aee0f7371c..fd5034ce91 100644
@@ -3264,8 +3264,8 @@ Low Level (hardware related) configuration options:
 		a 16 bit bus.
 		Not all NAND drivers use this symbol.
 		Example of drivers that use it:
-		- drivers/mtd/nand/ndfc.c
-		- drivers/mtd/nand/mxc_nand.c
+		- drivers/mtd/nand/raw/ndfc.c
+		- drivers/mtd/nand/raw/mxc_nand.c
 
 - CONFIG_SYS_NDFC_EBC0_CFG
 		Sets the EBC0_CFG register for the NDFC. If not defined
@@ -3382,7 +3382,7 @@ Low Level (hardware related) configuration options:
 - CONFIG_SYS_NAND_NO_SUBPAGE_WRITE
 		Option to disable subpage write in NAND driver
 		driver that uses this:
-		drivers/mtd/nand/davinci_nand.c
+		drivers/mtd/nand/raw/davinci_nand.c
 
 Freescale QE/FMAN Firmware Support:
 -----------------------------------
arch/arm/mach-uniphier/board_late_init.c +1 -1
index 8ffb9a8d3c..1b871c62ce 100644
@@ -12,7 +12,7 @@
 #include <stdio.h>
 #include <linux/io.h>
 #include <linux/printk.h>
-#include <../drivers/mtd/nand/denali.h>
+#include <../drivers/mtd/nand/raw/denali.h>
 
 #include "init.h"
 
common/spl/Kconfig +1 -1
index 2af26a881a..7bf7a23542 100644
@@ -479,7 +479,7 @@ config SPL_NAND_SUPPORT
 	help
 	  Enable support for NAND (Negative AND) flash in SPL. NAND flash
 	  can be used to allow SPL to load U-Boot from supported devices.
-	  This enables the drivers in drivers/mtd/nand as part of an SPL
+	  This enables the drivers in drivers/mtd/nand/raw as part of an SPL
 	  build.
 
 config SPL_NET_SUPPORT
common/spl/spl_spi.c +1 -1
index ba60a3a3c5..0016d49739 100644
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2011 OMICRON electronics GmbH
  *
- * based on drivers/mtd/nand/nand_spl_load.c
+ * based on drivers/mtd/nand/raw/nand_spl_load.c
  *
  * Copyright (C) 2011
  * Heiko Schocher, DENX Software Engineering, hs at denx.de.
doc/README.SPL +2 -2
index 3ba313caa8..fc1ca1ad4f 100644
@@ -57,11 +57,11 @@ CONFIG_SPL_FAT_SUPPORT (fs/fat/libfat.o)
 CONFIG_SPL_EXT_SUPPORT
 CONFIG_SPL_LIBGENERIC_SUPPORT (lib/libgeneric.o)
 CONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o)
-CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o)
+CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/raw/libnand.o)
 CONFIG_SPL_DRIVERS_MISC_SUPPORT (drivers/misc)
 CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
 CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
-CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
+CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/raw/nand_spl_load.o)
 CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
 CONFIG_SPL_RAM_DEVICE (common/spl/spl.c)
 CONFIG_SPL_WATCHDOG_SUPPORT (drivers/watchdog/libwatchdog.o)
doc/README.arm-relocation +1 -1
index 645b3746c8..d2a7e8122e 100644
@@ -84,7 +84,7 @@ Relocation with SPL (example for the tx25 booting from NAND Flash):
 - cpu copies the first page from NAND to 0xbb000000 (IMX_NFC_BASE)
   and start with code execution on this address.
 
-- The First page contains u-boot code from drivers/mtd/nand/mxc_nand_spl.c
+- The First page contains u-boot code from drivers/mtd/nand/raw/mxc_nand_spl.c
   which inits the dram, cpu registers, reloacte itself to CONFIG_SPL_TEXT_BASE	and loads
   the "real" u-boot to CONFIG_SYS_NAND_U_BOOT_DST and starts execution
   @CONFIG_SYS_NAND_U_BOOT_START
doc/README.nand +3 -3
index cda11b43ff..ec461b2dc9 100644
@@ -116,7 +116,7 @@ Configuration Options:
       The maximum number of NAND chips per device to be supported.
 
    CONFIG_SYS_NAND_SELF_INIT
-      Traditionally, glue code in drivers/mtd/nand/nand.c has driven
+      Traditionally, glue code in drivers/mtd/nand/raw/nand.c has driven
       the initialization process -- it provides the mtd and nand
       structs, calls a board init function for a specific device,
       calls nand_scan(), and registers with mtd.
@@ -125,7 +125,7 @@ Configuration Options:
       run code between nand_scan_ident() and nand_scan_tail(), or other
       deviations from the "normal" flow.
 
-      If a board defines CONFIG_SYS_NAND_SELF_INIT, drivers/mtd/nand/nand.c
+      If a board defines CONFIG_SYS_NAND_SELF_INIT, drivers/mtd/nand/raw/nand.c
       will make one call to board_nand_init(), with no arguments.  That
       function is responsible for calling a driver init function for
       each NAND device on the board, that performs all initialization
@@ -280,7 +280,7 @@ NOTE:
 =====
 
 The Disk On Chip driver is currently broken and has been for some time.
-There is a driver in drivers/mtd/nand, taken from Linux, that works with
+There is a driver in drivers/mtd/nand/raw, taken from Linux, that works with
 the current NAND system but has not yet been adapted to the u-boot
 environment.
 
doc/README.zynq +1 -1
index 5b0672c503..da977b2016 100644
@@ -63,7 +63,7 @@ bootmode strings at runtime.
   spi - drivers/spi/zynq_spi.c
   qspi - drivers/spi/zynq_qspi.c
   i2c - drivers/i2c/zynq_i2c.c
-  nand - drivers/mtd/nand/zynq_nand.c
+  nand - drivers/mtd/nand/raw/zynq_nand.c
 - Done proper cleanups on board configurations
 - Added basic FDT support for zynq boards
 - d-cache support for zynq_gem.c
drivers/Makefile +1 -1
index 276e5ee4d7..ccd1b648d0 100644
@@ -6,7 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
 obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
-obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/
+obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
 obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
 obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
 obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
drivers/mtd/Makefile +2 -0
index 9cec06510c..cdf515256a 100644
@@ -18,3 +18,5 @@ obj-$(CONFIG_FLASH_PIC32) += pic32_flash.o
 obj-$(CONFIG_ST_SMI) += st_smi.o
 obj-$(CONFIG_STM32_FLASH) += stm32_flash.o
 obj-$(CONFIG_RENESAS_RPC_HF) += renesas_rpc_hf.o
+
+obj-y += nand/
drivers/mtd/nand/Kconfig +1 -297

298 lines not on this page · raw message

drivers/mtd/nand/Makefile +0 -75

77 lines not on this page · raw message

drivers/mtd/nand/raw/Kconfig new file +297 -0

297 lines not on this page · raw message

drivers/mtd/nand/raw/Makefile new file +77 -0

77 lines not on this page · raw message

drivers/mtd/nand/raw/am335x_spl_bch.c renamed from drivers/mtd/nand/am335x_spl_bch.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/am335x_spl_bch.c
rename to drivers/mtd/nand/raw/am335x_spl_bch.c
drivers/mtd/nand/raw/arasan_nfc.c renamed from drivers/mtd/nand/arasan_nfc.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/arasan_nfc.c
rename to drivers/mtd/nand/raw/arasan_nfc.c
drivers/mtd/nand/raw/atmel_nand.c renamed from drivers/mtd/nand/atmel_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/atmel_nand.c
rename to drivers/mtd/nand/raw/atmel_nand.c
drivers/mtd/nand/raw/atmel_nand_ecc.h renamed from drivers/mtd/nand/atmel_nand_ecc.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/atmel_nand_ecc.h
rename to drivers/mtd/nand/raw/atmel_nand_ecc.h
drivers/mtd/nand/raw/davinci_nand.c renamed from drivers/mtd/nand/davinci_nand.c +1 -1
similarity index 99%
rename from drivers/mtd/nand/davinci_nand.c
rename to drivers/mtd/nand/raw/davinci_nand.c
index 305e68ad49..e6a84a52b4 100644
@@ -9,7 +9,7 @@
 
 /*
  *
- * linux/drivers/mtd/nand/nand_davinci.c
+ * linux/drivers/mtd/nand/raw/nand_davinci.c
  *
  * NAND Flash Driver
  *
drivers/mtd/nand/raw/denali.c renamed from drivers/mtd/nand/denali.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/denali.c
rename to drivers/mtd/nand/raw/denali.c
drivers/mtd/nand/raw/denali.h renamed from drivers/mtd/nand/denali.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/denali.h
rename to drivers/mtd/nand/raw/denali.h
drivers/mtd/nand/raw/denali_dt.c renamed from drivers/mtd/nand/denali_dt.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/denali_dt.c
rename to drivers/mtd/nand/raw/denali_dt.c
drivers/mtd/nand/raw/denali_spl.c renamed from drivers/mtd/nand/denali_spl.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/denali_spl.c
rename to drivers/mtd/nand/raw/denali_spl.c
drivers/mtd/nand/raw/fsl_elbc_nand.c renamed from drivers/mtd/nand/fsl_elbc_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/fsl_elbc_nand.c
rename to drivers/mtd/nand/raw/fsl_elbc_nand.c
drivers/mtd/nand/raw/fsl_elbc_spl.c renamed from drivers/mtd/nand/fsl_elbc_spl.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/fsl_elbc_spl.c
rename to drivers/mtd/nand/raw/fsl_elbc_spl.c
drivers/mtd/nand/raw/fsl_ifc_nand.c renamed from drivers/mtd/nand/fsl_ifc_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/fsl_ifc_nand.c
rename to drivers/mtd/nand/raw/fsl_ifc_nand.c
drivers/mtd/nand/raw/fsl_ifc_spl.c renamed from drivers/mtd/nand/fsl_ifc_spl.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/fsl_ifc_spl.c
rename to drivers/mtd/nand/raw/fsl_ifc_spl.c
drivers/mtd/nand/raw/fsl_upm.c renamed from drivers/mtd/nand/fsl_upm.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/fsl_upm.c
rename to drivers/mtd/nand/raw/fsl_upm.c
drivers/mtd/nand/raw/fsmc_nand.c renamed from drivers/mtd/nand/fsmc_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/fsmc_nand.c
rename to drivers/mtd/nand/raw/fsmc_nand.c
drivers/mtd/nand/raw/kb9202_nand.c renamed from drivers/mtd/nand/kb9202_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/kb9202_nand.c
rename to drivers/mtd/nand/raw/kb9202_nand.c
drivers/mtd/nand/raw/kirkwood_nand.c renamed from drivers/mtd/nand/kirkwood_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/kirkwood_nand.c
rename to drivers/mtd/nand/raw/kirkwood_nand.c
drivers/mtd/nand/raw/kmeter1_nand.c renamed from drivers/mtd/nand/kmeter1_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/kmeter1_nand.c
rename to drivers/mtd/nand/raw/kmeter1_nand.c
drivers/mtd/nand/raw/lpc32xx_nand_mlc.c renamed from drivers/mtd/nand/lpc32xx_nand_mlc.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/lpc32xx_nand_mlc.c
rename to drivers/mtd/nand/raw/lpc32xx_nand_mlc.c
drivers/mtd/nand/raw/lpc32xx_nand_slc.c renamed from drivers/mtd/nand/lpc32xx_nand_slc.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/lpc32xx_nand_slc.c
rename to drivers/mtd/nand/raw/lpc32xx_nand_slc.c
drivers/mtd/nand/raw/mxc_nand.c renamed from drivers/mtd/nand/mxc_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxc_nand.c
rename to drivers/mtd/nand/raw/mxc_nand.c
drivers/mtd/nand/raw/mxc_nand.h renamed from drivers/mtd/nand/mxc_nand.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxc_nand.h
rename to drivers/mtd/nand/raw/mxc_nand.h
drivers/mtd/nand/raw/mxc_nand_spl.c renamed from drivers/mtd/nand/mxc_nand_spl.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxc_nand_spl.c
rename to drivers/mtd/nand/raw/mxc_nand_spl.c
drivers/mtd/nand/raw/mxs_nand.c renamed from drivers/mtd/nand/mxs_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxs_nand.c
rename to drivers/mtd/nand/raw/mxs_nand.c
drivers/mtd/nand/raw/mxs_nand.h renamed from drivers/mtd/nand/mxs_nand.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxs_nand.h
rename to drivers/mtd/nand/raw/mxs_nand.h
drivers/mtd/nand/raw/mxs_nand_dt.c renamed from drivers/mtd/nand/mxs_nand_dt.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxs_nand_dt.c
rename to drivers/mtd/nand/raw/mxs_nand_dt.c
drivers/mtd/nand/raw/mxs_nand_spl.c renamed from drivers/mtd/nand/mxs_nand_spl.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/mxs_nand_spl.c
rename to drivers/mtd/nand/raw/mxs_nand_spl.c
drivers/mtd/nand/raw/nand.c renamed from drivers/mtd/nand/nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand.c
rename to drivers/mtd/nand/raw/nand.c
drivers/mtd/nand/raw/nand_base.c renamed from drivers/mtd/nand/nand_base.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_base.c
rename to drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/raw/nand_bbt.c renamed from drivers/mtd/nand/nand_bbt.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_bbt.c
rename to drivers/mtd/nand/raw/nand_bbt.c
drivers/mtd/nand/raw/nand_bch.c renamed from drivers/mtd/nand/nand_bch.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_bch.c
rename to drivers/mtd/nand/raw/nand_bch.c
drivers/mtd/nand/raw/nand_ecc.c renamed from drivers/mtd/nand/nand_ecc.c +1 -1
similarity index 99%
rename from drivers/mtd/nand/nand_ecc.c
rename to drivers/mtd/nand/raw/nand_ecc.c
index 05e55fce9a..2bc329be1a 100644
@@ -3,7 +3,7 @@
  * This file contains an ECC algorithm from Toshiba that detects and
  * corrects 1 bit errors in a 256 byte block of data.
  *
- * drivers/mtd/nand/nand_ecc.c
+ * drivers/mtd/nand/raw/nand_ecc.c
  *
  * Copyright (C) 2000-2004 Steven J. Hill (sjhill at realitydiluted.com)
  *                         Toshiba America Electronics Components, Inc.
drivers/mtd/nand/raw/nand_ids.c renamed from drivers/mtd/nand/nand_ids.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_ids.c
rename to drivers/mtd/nand/raw/nand_ids.c
drivers/mtd/nand/raw/nand_plat.c renamed from drivers/mtd/nand/nand_plat.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_plat.c
rename to drivers/mtd/nand/raw/nand_plat.c
drivers/mtd/nand/raw/nand_spl_load.c renamed from drivers/mtd/nand/nand_spl_load.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_spl_load.c
rename to drivers/mtd/nand/raw/nand_spl_load.c
drivers/mtd/nand/raw/nand_spl_loaders.c renamed from drivers/mtd/nand/nand_spl_loaders.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_spl_loaders.c
rename to drivers/mtd/nand/raw/nand_spl_loaders.c
drivers/mtd/nand/raw/nand_spl_simple.c renamed from drivers/mtd/nand/nand_spl_simple.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_spl_simple.c
rename to drivers/mtd/nand/raw/nand_spl_simple.c
drivers/mtd/nand/raw/nand_timings.c renamed from drivers/mtd/nand/nand_timings.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/nand_timings.c
rename to drivers/mtd/nand/raw/nand_timings.c
drivers/mtd/nand/raw/nand_util.c renamed from drivers/mtd/nand/nand_util.c +1 -1
similarity index 99%
rename from drivers/mtd/nand/nand_util.c
rename to drivers/mtd/nand/raw/nand_util.c
index 1ded7aa920..fc2235c1a0 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * drivers/mtd/nand/nand_util.c
+ * drivers/mtd/nand/raw/nand_util.c
  *
  * Copyright (C) 2006 by Weiss-Electronic GmbH.
  * All rights reserved.
drivers/mtd/nand/raw/omap_elm.c renamed from drivers/mtd/nand/omap_elm.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/omap_elm.c
rename to drivers/mtd/nand/raw/omap_elm.c
drivers/mtd/nand/raw/omap_gpmc.c renamed from drivers/mtd/nand/omap_gpmc.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/omap_gpmc.c
rename to drivers/mtd/nand/raw/omap_gpmc.c
drivers/mtd/nand/raw/pxa3xx_nand.c renamed from drivers/mtd/nand/pxa3xx_nand.c +1 -1
similarity index 99%
rename from drivers/mtd/nand/pxa3xx_nand.c
rename to drivers/mtd/nand/raw/pxa3xx_nand.c
index 9d02fd8eb1..67b2b62f76 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * drivers/mtd/nand/pxa3xx_nand.c
+ * drivers/mtd/nand/raw/pxa3xx_nand.c
  *
  * Copyright © 2005 Intel Corporation
  * Copyright © 2006 Marvell International Ltd.
drivers/mtd/nand/raw/pxa3xx_nand.h renamed from drivers/mtd/nand/pxa3xx_nand.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/pxa3xx_nand.h
rename to drivers/mtd/nand/raw/pxa3xx_nand.h
drivers/mtd/nand/raw/sunxi_nand.c renamed from drivers/mtd/nand/sunxi_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/sunxi_nand.c
rename to drivers/mtd/nand/raw/sunxi_nand.c
drivers/mtd/nand/raw/sunxi_nand_spl.c renamed from drivers/mtd/nand/sunxi_nand_spl.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/sunxi_nand_spl.c
rename to drivers/mtd/nand/raw/sunxi_nand_spl.c
drivers/mtd/nand/raw/tegra_nand.c renamed from drivers/mtd/nand/tegra_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/tegra_nand.c
rename to drivers/mtd/nand/raw/tegra_nand.c
drivers/mtd/nand/raw/tegra_nand.h renamed from drivers/mtd/nand/tegra_nand.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/tegra_nand.h
rename to drivers/mtd/nand/raw/tegra_nand.h
drivers/mtd/nand/raw/vf610_nfc.c renamed from drivers/mtd/nand/vf610_nfc.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/vf610_nfc.c
rename to drivers/mtd/nand/raw/vf610_nfc.c
drivers/mtd/nand/raw/zynq_nand.c renamed from drivers/mtd/nand/zynq_nand.c +0 -0
similarity index 100%
rename from drivers/mtd/nand/zynq_nand.c
rename to drivers/mtd/nand/raw/zynq_nand.c
include/configs/MPC8313ERDB.h +1 -1
index 1f56deb151..2a58058ebb 100644
@@ -242,7 +242,7 @@
 				/* LB refresh timer prescal, 266MHz/32 */
 #define CONFIG_SYS_LBC_MRTPR	0x20000000  /*TODO */
 
-/* drivers/mtd/nand/nand.c */
+/* drivers/mtd/nand/raw/nand.c */
 #if defined(CONFIG_NAND) && defined(CONFIG_SPL_BUILD)
 #define CONFIG_SYS_NAND_BASE		0xFFF00000
 #else
Signature · 1 line
2.14.1
author maintainer
#10 lore raw

PATCH v6 10/27 mtd: rename nand into rawnand in Kconfig prompt

In reply to Miquel Raynal

Sync the Kconfig raw NAND entry title with the code architecture.

---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +1 -1
index 1e4ea7bdd4..008f7b4b4b 100644
@@ -1,6 +1,6 @@
 
 menuconfig NAND
-	bool "NAND Device Support"
+	bool "Raw NAND Device Support"
 if NAND
 
 config SYS_NAND_SELF_INIT
Signature · 1 line
2.14.1
author maintainer
#11 lore raw

PATCH v6 11/27 mtd: nand: Add core infrastructure to deal with NAND devices

In reply to Miquel Raynal

From: Boris Brezillon <[email protected]>

Add an intermediate layer to abstract NAND device interface so that some logic can be shared between SPI NANDs, parallel/raw NANDs, OneNANDs, ...

---
 drivers/mtd/nand/Kconfig  |   3 +
 drivers/mtd/nand/Makefile |   2 +
 drivers/mtd/nand/bbt.c    | 132 +++++++++
 drivers/mtd/nand/core.c   | 243 +++++++++++++++
 include/linux/mtd/nand.h  | 731 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1111 insertions(+)
 create mode 100644 drivers/mtd/nand/bbt.c
 create mode 100644 drivers/mtd/nand/core.c
 create mode 100644 include/linux/mtd/nand.h
drivers/mtd/nand/Kconfig +3 -0
index 6d53734718..1c1a1f487e 100644
@@ -1 +1,4 @@
+config MTD_NAND_CORE
+	tristate
+
 source "drivers/mtd/nand/raw/Kconfig"
drivers/mtd/nand/Makefile +2 -0
index 69f40d1563..cd492dbc14 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+nandcore-objs := core.o bbt.o
+obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
drivers/mtd/nand/bbt.c new file +132 -0

132 lines not on this page · raw message

drivers/mtd/nand/core.c new file +243 -0

243 lines not on this page · raw message

include/linux/mtd/nand.h new file +731 -0

731 lines not on this page · raw message

Signature · 1 line
2.14.1
author maintainer
#12 lore raw

PATCH v6 12/27 mtd: nand: Pass mode information to nand_page_io_req

In reply to Miquel Raynal

From: Boris Brezillon <[email protected]>

The NAND sub-layers are likely to need the MTD_OPS_XXX mode information in order to decide if they should enable/disable ECC or how they should place the OOB bytes in the provided OOB buffer.

Add a field to nand_page_io_req to pass this information.

---
 include/linux/mtd/nand.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/mtd/nand.h +3 -0
index ada7af4a41..13e8dd1103 100644
@@ -86,6 +86,7 @@ struct nand_pos {
  * @ooboffs: the OOB offset within the page
  * @ooblen: the number of OOB bytes to read from/write to this page
  * @oobbuf: buffer to store OOB data in or get OOB data from
+ * @mode: one of the %MTD_OPS_XXX mode
  *
  * This object is used to pass per-page I/O requests to NAND sub-layers. This
  * way all useful information are already formatted in a useful way and
@@ -106,6 +107,7 @@ struct nand_page_io_req {
 		const void *out;
 		void *in;
 	} oobbuf;
+	int mode;
 };
 
 /**
@@ -599,6 +601,7 @@ static inline void nanddev_io_iter_init(struct nand_device *nand,
 {
 	struct mtd_info *mtd = nanddev_to_mtd(nand);
 
+	iter->req.mode = req->mode;
 	iter->req.dataoffs = nanddev_offs_to_pos(nand, offs, &iter->req.pos);
 	iter->req.ooboffs = req->ooboffs;
 	iter->oobbytes_per_page = mtd_oobavail(mtd, req);
Signature · 1 line
2.14.1
author maintainer
#13 lore raw

PATCH v6 13/27 spi: Extend the core to ease integration of SPI memory controllers

In reply to Miquel Raynal

From: Boris Brezillon <[email protected]>

Some controllers are exposing high-level interfaces to access various kind of SPI memories. Unfortunately they do not fit in the current spi_controller model and usually have drivers placed in drivers/mtd/spi-nor which are only supporting SPI NORs and not SPI memories in general.

This is an attempt at defining a SPI memory interface which works for all kinds of SPI memories (NORs, NANDs, SRAMs).

---
 drivers/spi/Kconfig   |   7 +
 drivers/spi/Makefile  |   1 +
 drivers/spi/spi-mem.c | 500 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/spi-mem.h     | 258 ++++++++++++++++++++++++++
 include/spi.h         |  11 ++
 5 files changed, 777 insertions(+)
 create mode 100644 drivers/spi/spi-mem.c
 create mode 100644 include/spi-mem.h
drivers/spi/Kconfig +7 -0
index b85fca5628..6286b2e234 100644
@@ -18,6 +18,13 @@ config DM_SPI
 
 if DM_SPI
 
+config SPI_MEM
+	bool "SPI memory extension"
+	help
+	  Enable this option if you want to enable the SPI memory extension.
+	  This extension is meant to simplify interaction with SPI memories
+	  by providing an high-level interface to send memory-like commands.
+
 config ALTERA_SPI
 	bool "Altera SPI driver"
 	help
drivers/spi/Makefile +1 -0
index 95b03a29dc..7971adeb6f 100644
@@ -8,6 +8,7 @@ ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
+obj-$(CONFIG_SPI_MEM) += spi-mem.o
 else
 obj-y += spi.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi_legacy.o
drivers/spi/spi-mem.c new file +500 -0

500 lines not on this page · raw message

include/spi-mem.h new file +258 -0

258 lines not on this page · raw message

include/spi.h +11 -0
index 9754c53aa1..938627bc01 100644
@@ -9,6 +9,8 @@
 #ifndef _SPI_H_
 #define _SPI_H_
 
+#include <common.h>
+
 /* SPI mode flags */
 #define SPI_CPHA	BIT(0)			/* clock phase */
 #define SPI_CPOL	BIT(1)			/* clock polarity */
@@ -402,6 +404,15 @@ struct dm_spi_ops {
 	int (*xfer)(struct udevice *dev, unsigned int bitlen, const void *dout,
 		    void *din, unsigned long flags);
 
+	/**
+	 * Optimized handlers for SPI memory-like operations.
+	 *
+	 * Optimized/dedicated operations for interactions with SPI memory. This
+	 * field is optional and should only be implemented if the controller
+	 * has native support for memory like operations.
+	 */
+	const struct spi_controller_mem_ops *mem_ops;
+
 	/**
 	 * Set transfer speed.
 	 * This sets a new speed to be applied for next spi_xfer().
Signature · 1 line
2.14.1
author maintainer
#14 lore raw

PATCH v6 14/27 mtd: nand: Add core infrastructure to support SPI NANDs

In reply to Miquel Raynal

From: Peter Pan <[email protected]>

Add a SPI NAND framework based on the generic NAND framework and the spi-mem infrastructure.

In its current state, this framework supports the following features:

- single/dual/quad IO modes
- on-die ECC

---
 drivers/mtd/nand/Kconfig      |    2 +
 drivers/mtd/nand/Makefile     |    1 +
 drivers/mtd/nand/spi/Kconfig  |    7 +
 drivers/mtd/nand/spi/Makefile |    4 +
 drivers/mtd/nand/spi/core.c   | 1235 +++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/spinand.h   |  427 ++++++++++++++
 6 files changed, 1676 insertions(+)
 create mode 100644 drivers/mtd/nand/spi/Kconfig
 create mode 100644 drivers/mtd/nand/spi/Makefile
 create mode 100644 drivers/mtd/nand/spi/core.c
 create mode 100644 include/linux/mtd/spinand.h
drivers/mtd/nand/Kconfig +2 -0
index 1c1a1f487e..78ae04bdcb 100644
@@ -2,3 +2,5 @@ config MTD_NAND_CORE
 	tristate
 
 source "drivers/mtd/nand/raw/Kconfig"
+
+source "drivers/mtd/nand/spi/Kconfig"
drivers/mtd/nand/Makefile +1 -0
index cd492dbc14..a358bc680e 100644
@@ -2,3 +2,4 @@
 
 nandcore-objs := core.o bbt.o
 obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
+obj-$(CONFIG_MTD_SPI_NAND) += spi/
drivers/mtd/nand/spi/Kconfig new file +7 -0
new file mode 100644
index 0000000000..2197cb531f
@@ -0,0 +1,7 @@
+menuconfig MTD_SPI_NAND
+	bool "SPI NAND device Support"
+	depends on MTD && DM_SPI
+	select MTD_NAND_CORE
+	select SPI_MEM
+	help
+	  This is the framework for the SPI NAND device drivers.
drivers/mtd/nand/spi/Makefile new file +4 -0
new file mode 100644
index 0000000000..f0c6e69d2e
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+spinand-objs := core.o
+obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c new file +1235 -0

1,235 lines not on this page · raw message

include/linux/mtd/spinand.h new file +427 -0

427 lines not on this page · raw message

Signature · 1 line
2.14.1
author maintainer
#15 lore raw

PATCH v6 15/27 mtd: spinand: Add initial support for Micron MT29F2G01ABAGD

In reply to Miquel Raynal

From: Peter Pan <[email protected]>

Add a basic driver for Micron SPI NANDs. Only one device is supported right now, but the driver will be extended to support more devices afterwards.

---
 drivers/mtd/nand/spi/Makefile |   2 +-
 drivers/mtd/nand/spi/core.c   |  17 ++++++
 drivers/mtd/nand/spi/micron.c | 135 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/spinand.h   |   3 +
 4 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/micron.c
drivers/mtd/nand/spi/Makefile +1 -1
index f0c6e69d2e..4eb745abd4 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o
+spinand-objs := core.o micron.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +17 -0
index 08f853ae11..36b8b52bc2 100644
@@ -829,8 +829,25 @@ static const struct nand_ops spinand_ops = {
 	.isbad = spinand_isbad,
 };
 
+static const struct spinand_manufacturer *spinand_manufacturers[] = {
+	&micron_spinand_manufacturer,
+};
+
 static int spinand_manufacturer_detect(struct spinand_device *spinand)
 {
+	unsigned int i;
+	int ret;
+
+	for (i = 0; i < ARRAY_SIZE(spinand_manufacturers); i++) {
+		ret = spinand_manufacturers[i]->ops->detect(spinand);
+		if (ret > 0) {
+			spinand->manufacturer = spinand_manufacturers[i];
+			return 0;
+		} else if (ret < 0) {
+			return ret;
+		}
+	}
+
 	return -ENOTSUPP;
 }
 
drivers/mtd/nand/spi/micron.c new file +135 -0

135 lines not on this page · raw message

include/linux/mtd/spinand.h +3 -0
index ad59fc01ef..5302d38de8 100644
@@ -200,6 +200,9 @@ struct spinand_manufacturer {
 	const struct spinand_manufacturer_ops *ops;
 };
 
+/* SPI NAND manufacturers */
+extern const struct spinand_manufacturer micron_spinand_manufacturer;
+
 /**
  * struct spinand_op_variants - SPI NAND operation variants
  * @ops: the list of variants for a given operation
Signature · 1 line
2.14.1
author maintainer
#16 lore raw

PATCH v6 16/27 mtd: spinand: Add initial support for Winbond W25M02GV

In reply to Miquel Raynal

From: Frieder Schrempf <[email protected]>

Add support for the W25M02GV chip.

---
 drivers/mtd/nand/spi/Makefile  |   2 +-
 drivers/mtd/nand/spi/core.c    |   1 +
 drivers/mtd/nand/spi/winbond.c | 143 +++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/spinand.h    |   1 +
 4 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/winbond.c
drivers/mtd/nand/spi/Makefile +1 -1
index 4eb745abd4..11ba5de68b 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o micron.o
+spinand-objs := core.o micron.o winbond.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +1 -0
index 36b8b52bc2..ef3e6445d8 100644
@@ -831,6 +831,7 @@ static const struct nand_ops spinand_ops = {
 
 static const struct spinand_manufacturer *spinand_manufacturers[] = {
 	&micron_spinand_manufacturer,
+	&winbond_spinand_manufacturer,
 };
 
 static int spinand_manufacturer_detect(struct spinand_device *spinand)
drivers/mtd/nand/spi/winbond.c new file +143 -0

143 lines not on this page · raw message

include/linux/mtd/spinand.h +1 -0
index 5302d38de8..d40a7c8f4e 100644
@@ -202,6 +202,7 @@ struct spinand_manufacturer {
 
 /* SPI NAND manufacturers */
 extern const struct spinand_manufacturer micron_spinand_manufacturer;
+extern const struct spinand_manufacturer winbond_spinand_manufacturer;
 
 /**
  * struct spinand_op_variants - SPI NAND operation variants
Signature · 1 line
2.14.1
author maintainer
#17 lore raw

PATCH v6 17/27 mtd: spinand: Add initial support for the MX35LF1GE4AB chip

In reply to Miquel Raynal

From: Boris Brezillon <[email protected]>

Add minimal support for the MX35LF1GE4AB SPI NAND chip.

---
 drivers/mtd/nand/spi/Makefile   |   2 +-
 drivers/mtd/nand/spi/core.c     |   1 +
 drivers/mtd/nand/spi/macronix.c | 138 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/spinand.h     |   1 +
 4 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/macronix.c
drivers/mtd/nand/spi/Makefile +1 -1
index 11ba5de68b..a66edd9199 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o micron.o winbond.o
+spinand-objs := core.o macronix.o micron.o winbond.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +1 -0
index ef3e6445d8..362d104846 100644
@@ -830,6 +830,7 @@ static const struct nand_ops spinand_ops = {
 };
 
 static const struct spinand_manufacturer *spinand_manufacturers[] = {
+	&macronix_spinand_manufacturer,
 	&micron_spinand_manufacturer,
 	&winbond_spinand_manufacturer,
 };
drivers/mtd/nand/spi/macronix.c new file +138 -0

138 lines not on this page · raw message

include/linux/mtd/spinand.h +1 -0
index d40a7c8f4e..8c9c756179 100644
@@ -201,6 +201,7 @@ struct spinand_manufacturer {
 };
 
 /* SPI NAND manufacturers */
+extern const struct spinand_manufacturer macronix_spinand_manufacturer;
 extern const struct spinand_manufacturer micron_spinand_manufacturer;
 extern const struct spinand_manufacturer winbond_spinand_manufacturer;
 
Signature · 1 line
2.14.1
author maintainer
#18 lore raw

PATCH v6 18/27 mtd: spinand: Add initial support for the MX35LF2GE4AB chip

In reply to Miquel Raynal

Add support for the MX35LF2GE4AB chip, which is similar to its cousin MX35LF1GE4AB, with two planes instead of one.

---
 drivers/mtd/nand/spi/macronix.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/mtd/nand/spi/macronix.c +14 -6
index dd351dcb6c..662c561e50 100644
@@ -27,13 +27,13 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
 		SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
 		SPINAND_PROG_LOAD(false, 0, NULL, 0));
 
-static int mx35lf1ge4ab_ooblayout_ecc(struct mtd_info *mtd, int section,
+static int mx35lfxge4ab_ooblayout_ecc(struct mtd_info *mtd, int section,
 				      struct mtd_oob_region *region)
 {
 	return -ERANGE;
 }
 
-static int mx35lf1ge4ab_ooblayout_free(struct mtd_info *mtd, int section,
+static int mx35lfxge4ab_ooblayout_free(struct mtd_info *mtd, int section,
 				       struct mtd_oob_region *region)
 {
 	if (section)
@@ -45,9 +45,9 @@ static int mx35lf1ge4ab_ooblayout_free(struct mtd_info *mtd, int section,
 	return 0;
 }
 
-static const struct mtd_ooblayout_ops mx35lf1ge4ab_ooblayout = {
-	.ecc = mx35lf1ge4ab_ooblayout_ecc,
-	.free = mx35lf1ge4ab_ooblayout_free,
+static const struct mtd_ooblayout_ops mx35lfxge4ab_ooblayout = {
+	.ecc = mx35lfxge4ab_ooblayout_ecc,
+	.free = mx35lfxge4ab_ooblayout_free,
 };
 
 static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
@@ -102,8 +102,16 @@ static const struct spinand_info macronix_spinand_table[] = {
 					      &write_cache_variants,
 					      &update_cache_variants),
 		     SPINAND_HAS_QE_BIT,
-		     SPINAND_ECCINFO(&mx35lf1ge4ab_ooblayout,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
+	SPINAND_INFO("MX35LF2GE4AB", 0x22,
+		     NAND_MEMORG(1, 2048, 64, 64, 2048, 2, 1, 1),
+		     NAND_ECCREQ(4, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     SPINAND_HAS_QE_BIT,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
 };
 
 static int macronix_spinand_detect(struct spinand_device *spinand)
Signature · 1 line
2.14.1
author maintainer
#19 lore raw

PATCH v6 19/27 dt-bindings: Add bindings for SPI NAND devices

In reply to Miquel Raynal

From: Boris Brezillon <[email protected]>

Add bindings for SPI NAND chips.

---
 doc/device-tree-bindings/mtd/spi-nand.txt | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 doc/device-tree-bindings/mtd/spi-nand.txt
doc/device-tree-bindings/mtd/spi-nand.txt new file +5 -0
new file mode 100644
index 0000000000..8b51f3b6d5
@@ -0,0 +1,5 @@
+SPI NAND flash
+
+Required properties:
+- compatible: should be "spi-nand"
+- reg: should encode the chip-select line used to access the NAND chip
Signature · 1 line
2.14.1
author maintainer
#20 lore raw

PATCH v6 20/27 mtd: declare MTD_PARTITIONS symbol in Kconfig

In reply to Miquel Raynal

UBI selects MTD_PARTITIONS which is the symbol to compile drivers/mtd/mtdpart.c. Unfortunately, the symbol was not defined in Kconfig and this worked only with board files defining it. Fix this by adding a boolean in Kconfig so boards defined by defconfig files only will work as expected.

---
 drivers/mtd/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
drivers/mtd/Kconfig +3 -0
index 9341d518f3..d98457e223 100644
@@ -1,5 +1,8 @@
 menu "MTD Support"
 
+config MTD_PARTITIONS
+	bool
+
 config MTD
 	bool "Enable Driver Model for MTD drivers"
 	depends on DM
Signature · 1 line
2.14.1
author maintainer
#21 lore raw

PATCH v6 21/27 cmd: ubi: delete useless and misleading definitions

In reply to Miquel Raynal

These definitions are simply not used and are misleading because similar definitions exist in jffs2/load_kernel.h and are used widely to define MTD device types (which is, by the way, totally redundant with what the MTD core does). Remove these definitions.

---
 cmd/ubi.c | 5 -----
 1 file changed, 5 deletions(-)
cmd/ubi.c +0 -5
index 913f0f71fd..0a3405a3b1 100644
@@ -27,11 +27,6 @@
 #undef ubi_msg
 #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__)
 
-#define DEV_TYPE_NONE		0
-#define DEV_TYPE_NAND		1
-#define DEV_TYPE_ONENAND	2
-#define DEV_TYPE_NOR		3
-
 /* Private own data */
 static struct ubi_device *ubi;
 static char buffer[80];
Signature · 1 line
2.14.1
author maintainer
#22 lore raw

PATCH v6 22/27 cmd: mtdparts: accept spi-nand devices

In reply to Miquel Raynal

Let spi-nand devices be recognized by mtdparts. This is superfluous but a full mtdparts rework would be very time-consuming.

---
 cmd/mtdparts.c              | 13 ++++++++-----
 include/jffs2/load_kernel.h |  7 +++++--
 2 files changed, 13 insertions(+), 7 deletions(-)
cmd/mtdparts.c +8 -5
index 0da3afd75f..f26a761c99 100644
@@ -37,7 +37,7 @@
  * mtdids=<idmap>[,<idmap>,...]
  *
  * <idmap>    := <dev-id>=<mtd-id>
- * <dev-id>   := 'nand'|'nor'|'onenand'<dev-num>
+ * <dev-id>   := 'nand'|'nor'|'onenand'|'spi-nand'<dev-num>
  * <dev-num>  := mtd device number, 0...
  * <mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)
  *
@@ -336,7 +336,7 @@ static int part_validate_eraseblock(struct mtdids *id, struct part_info *part)
 
 	if (!mtd->numeraseregions) {
 		/*
-		 * Only one eraseregion (NAND, OneNAND or uniform NOR),
+		 * Only one eraseregion (NAND, SPI-NAND, OneNAND or uniform NOR),
 		 * checking for alignment is easy here
 		 */
 		offset = part->offset;
@@ -1027,7 +1027,7 @@ static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_
 }
 
 /**
- * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
+ * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'|'spi-nand'<dev-num>,
  * return device type and number.
  *
  * @param id string describing device id
@@ -1051,6 +1051,9 @@ int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type,
 	} else if (strncmp(p, "onenand", 7) == 0) {
 		*dev_type = MTD_DEV_TYPE_ONENAND;
 		p += 7;
+	} else if (strncmp(p, "spi-nand", 8) == 0) {
+		*dev_type = MTD_DEV_TYPE_SPINAND;
+		p += 8;
 	} else {
 		printf("incorrect device type in %s\n", id);
 		return 1;
@@ -1633,7 +1636,7 @@ static int parse_mtdids(const char *const ids)
 	while(p && (*p != '\0')) {
 
 		ret = 1;
-		/* parse 'nor'|'nand'|'onenand'<dev-num> */
+		/* parse 'nor'|'nand'|'onenand'|'spi-nand'<dev-num> */
 		if (mtd_id_parse(p, &p, &type, &num) != 0)
 			break;
 
@@ -2109,7 +2112,7 @@ static char mtdparts_help_text[] =
 	"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
 	"mtdids=<idmap>[,<idmap>,...]\n\n"
 	"<idmap>    := <dev-id>=<mtd-id>\n"
-	"<dev-id>   := 'nand'|'nor'|'onenand'<dev-num>\n"
+	"<dev-id>   := 'nand'|'nor'|'onenand'|'spi-nand'<dev-num>\n"
 	"<dev-num>  := mtd device number, 0...\n"
 	"<mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
 	"'mtdparts' - partition list\n\n"
include/jffs2/load_kernel.h +5 -2
index 1ddff062ad..9346d7ee9f 100644
@@ -15,9 +15,12 @@
 #define MTD_DEV_TYPE_NOR	0x0001
 #define MTD_DEV_TYPE_NAND	0x0002
 #define MTD_DEV_TYPE_ONENAND	0x0004
+#define MTD_DEV_TYPE_SPINAND	0x0008
 
-#define MTD_DEV_TYPE(type) ((type == MTD_DEV_TYPE_NAND) ? "nand" :	\
-			(type == MTD_DEV_TYPE_ONENAND) ? "onenand" : "nor")
+#define MTD_DEV_TYPE(type) (type == MTD_DEV_TYPE_NAND ? "nand" :	\
+			    (type == MTD_DEV_TYPE_NOR ? "nor" :		\
+			     (type == MTD_DEV_TYPE_ONENAND ? "onenand" : \
+			      "spi-nand")))				\
 
 struct mtd_device {
 	struct list_head link;
Signature · 1 line
2.14.1
author maintainer
#23 lore raw

PATCH v6 23/27 cmd: mtdparts: add a generic 'mtdparts' parser

In reply to Miquel Raynal

The current parser is very specific to U-Boot mtdparts implementation. It does not use MTD structures like mtd_info and mtd_partition. Write some kind of a wrapper around the current implementation to allow other commands to benefit from this parsing in a user-friendly way.

This new command will allocate an mtd_partition array for each successful call. This array must be freed after use by the caller. The given 'mtdparts' buffer pointer will be moved forward to the next MTD device (if any, it will point towards a '\0' character otherwise).

---
 cmd/mtdparts.c                 | 71 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/partitions.h |  3 ++
 2 files changed, 74 insertions(+)
cmd/mtdparts.c +71 -0
index f26a761c99..27e84db0e4 100644
@@ -78,6 +78,7 @@
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 
 #if defined(CONFIG_CMD_NAND)
 #include <linux/mtd/rawnand.h>
@@ -705,6 +706,76 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i
 	return 0;
 }
 
+int mtdparts_parse_part(struct mtd_info *parent, const char **_mtdparts,
+			struct mtd_partition **_parts, int *_nb_parts)
+{
+	const char *mtdparts = *_mtdparts;
+	struct part_info *part_legacy;
+	struct mtd_partition *parts;
+	int cur_off = 0, cur_sz = 0;
+	int nb_parts = 0;
+	char *names;
+	int ret, idx;
+
+	*_parts = NULL;
+	*_nb_parts = 0;
+
+	/* First, iterate over the partitions until we know their number */
+	while (mtdparts[0] != '\0' && mtdparts[0] != ';') {
+		ret = part_parse(mtdparts, &mtdparts, &part_legacy);
+		if (ret)
+			return ret;
+
+		nb_parts++;
+		free(part_legacy);
+	}
+
+	/* Allocate an array of partitions to give back to the caller */
+	parts = malloc((sizeof(*parts) + 20) * nb_parts);
+	names = (char *)&parts[nb_parts];
+	if (!parts) {
+		printf("Could not allocate enough space to save partitions meta-data\n");
+		return -ENOMEM;
+	}
+
+	/* Iterate again over each partition to save the data in our array */
+	for (idx = 0; idx < nb_parts; idx++) {
+		char *name;
+
+		ret = part_parse(*_mtdparts, _mtdparts, &part_legacy);
+		if (ret)
+			return ret;
+
+		name = &names[idx * 20];
+		strncpy(name, part_legacy->name, 20);
+		parts[idx].name = name;
+
+		parts[idx].size = part_legacy->size;
+		if (parts[idx].size == SIZE_REMAINING)
+			parts[idx].size = parent->size - cur_sz;
+		cur_sz += parts[idx].size;
+
+		parts[idx].offset = part_legacy->offset;
+		if (parts[idx].offset == OFFSET_NOT_SPECIFIED)
+			parts[idx].offset = cur_off;
+		cur_off += parts[idx].size;
+
+		parts[idx].mask_flags = part_legacy->mask_flags;
+		parts[idx].ecclayout = parent->ecclayout;
+
+		free(part_legacy);
+	}
+
+	/* Offset by one mtdparts to point to the next device if needed */
+	if (*_mtdparts[0] == ';')
+		_mtdparts++;
+
+	*_parts = parts;
+	*_nb_parts = nb_parts;
+
+	return 0;
+}
+
 /**
  * Check device number to be within valid range for given device type.
  *
include/linux/mtd/partitions.h +3 -0
index ce0e8dbee4..0cf26ca945 100644
@@ -87,4 +87,7 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
 int mtd_del_partition(struct mtd_info *master, int partno);
 uint64_t mtd_get_device_size(const struct mtd_info *mtd);
 
+int mtdparts_parse_part(struct mtd_info *parent, const char **_mtdparts,
+			struct mtd_partition **_parts, int *_nb_parts);
+
 #endif
Signature · 1 line
2.14.1
author maintainer
#24 lore raw

PATCH v6 24/27 cmd: mtdparts: remove useless 'mtdparts=' prefix

In reply to Miquel Raynal

All U-Boot users must define the mtdparts environment variable with:
setenv mtdparts mtdparts=...

This is a pure software limitation and is a complete non-sense. Remove this limitation but keep the backward compatibility.

---
 cmd/mtdparts.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
cmd/mtdparts.c +6 -11
index 27e84db0e4..ef8588bd71 100644
@@ -44,7 +44,7 @@
  *
  * 'mtdparts' - partition list
  *
- * mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]
+ * mtdparts=[mtdparts=]<mtd-def>[;<mtd-def>...]
  *
  * <mtd-def>  := <mtd-id>:<part-def>[,<part-def>...]
  * <mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)
@@ -62,11 +62,11 @@
  *
  * 1 NOR Flash, with 1 single writable partition:
  * mtdids=nor0=edb7312-nor
- * mtdparts=mtdparts=edb7312-nor:-
+ * mtdparts=[mtdparts=]edb7312-nor:-
  *
  * 1 NOR Flash with 2 partitions, 1 NAND with one
  * mtdids=nor0=edb7312-nor,nand0=edb7312-nand
- * mtdparts=mtdparts=edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
+ * mtdparts=[mtdparts=]edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
  *
  */
 
@@ -1167,9 +1167,6 @@ static int generate_mtdparts(char *buf, u32 buflen)
 		return 0;
 	}
 
-	strcpy(p, "mtdparts=");
-	p += 9;
-
 	list_for_each(dentry, &devices) {
 		dev = list_entry(dentry, struct mtd_device, link);
 
@@ -1640,11 +1637,9 @@ static int parse_mtdparts(const char *const mtdparts)
 	if (!p)
 		p = mtdparts;
 
-	if (strncmp(p, "mtdparts=", 9) != 0) {
-		printf("mtdparts variable doesn't start with 'mtdparts='\n");
-		return err;
-	}
-	p += 9;
+	/* Skip the useless prefix, if any */
+	if (strncmp(p, "mtdparts=", 9) == 0)
+		p += 9;
 
 	while (*p != '\0') {
 		err = 1;
Signature · 1 line
2.14.1
author maintainer
#25 lore raw

PATCH v6 25/27 mtd: uclass: add probe function

In reply to Miquel Raynal

The user might want to trigger the probe of any MTD device, export these functions so they can be called from a command source file.

---
 drivers/mtd/mtd-uclass.c | 9 +++++++++
 include/linux/mtd/mtd.h  | 3 +++
 2 files changed, 12 insertions(+)
drivers/mtd/mtd-uclass.c +9 -0
index 9ca049c437..9a9470410c 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device-internal.h>
 #include <errno.h>
 #include <mtd.h>
 
@@ -13,6 +14,14 @@
  * The uclass private is pointed to mtd_info.
  */
 
+int mtd_probe(struct udevice *dev)
+{
+	if (device_active(dev))
+		return 0;
+
+	return device_probe(dev);
+}
+
 UCLASS_DRIVER(mtd) = {
 	.id		= UCLASS_MTD,
 	.name		= "mtd",
include/linux/mtd/mtd.h +3 -0
index 6771ee2586..7dd45bde65 100644
@@ -533,5 +533,8 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
 			  const uint64_t length, uint64_t *len_incl_bad,
 			  int *truncated);
+
+int mtd_probe(struct udevice *dev);
+
 #endif
 #endif /* __MTD_MTD_H__ */
Signature · 1 line
2.14.1
author maintainer
#26 lore raw

PATCH v6 26/27 cmd: mtd: add 'mtd' command

In reply to Miquel Raynal

There should not be a 'nand' command, a 'sf' command and certainly not another 'spi-nand'. Write a 'mtd' command instead to manage all MTD devices at once. This should be the preferred way to access any MTD device.

---
 cmd/Kconfig             |   7 +
 cmd/Makefile            |   1 +
 cmd/mtd.c               | 392 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/Makefile    |   2 +-
 include/linux/mtd/mtd.h |   1 +
 5 files changed, 402 insertions(+), 1 deletion(-)
 create mode 100644 cmd/mtd.c
cmd/Kconfig +7 -0
index 0cf530d923..45ead0ffce 100644
@@ -848,6 +848,13 @@ config CMD_MMC_SWRITE
 	  Enable support for the "mmc swrite" command to write Android sparse
 	  images to eMMC.
 
+config CMD_MTD
+	bool "mtd"
+	depends on CMD_MTDPARTS
+	select MTD_PARTITIONS
+	help
+	  MTD commands support.
+
 config CMD_NAND
 	bool "nand"
 	default y if NAND_SUNXI
cmd/Makefile +1 -0
index 323f1fd2c7..32fd102189 100644
@@ -90,6 +90,7 @@ obj-$(CONFIG_CMD_MISC) += misc.o
 obj-$(CONFIG_CMD_MMC) += mmc.o
 obj-$(CONFIG_CMD_MMC_SPI) += mmc_spi.o
 obj-$(CONFIG_MP) += mp.o
+obj-$(CONFIG_CMD_MTD) += mtd.o
 obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
cmd/mtd.c new file +392 -0

392 lines not on this page · raw message

drivers/mtd/Makefile +1 -1
index cdf515256a..22ceda93c0 100644
@@ -3,7 +3,7 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
-ifneq (,$(findstring y,$(CONFIG_MTD_DEVICE)$(CONFIG_CMD_NAND)$(CONFIG_CMD_ONENAND)$(CONFIG_CMD_SF)))
+ifneq (,$(findstring y,$(CONFIG_MTD_DEVICE)$(CONFIG_CMD_NAND)$(CONFIG_CMD_ONENAND)$(CONFIG_CMD_SF)$(CONFIG_CMD_MTD)))
 obj-y += mtdcore.o mtd_uboot.o
 endif
 obj-$(CONFIG_MTD) += mtd-uclass.o
include/linux/mtd/mtd.h +1 -0
index 7dd45bde65..4ca5d764d7 100644
@@ -535,6 +535,7 @@ void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
 			  int *truncated);
 
 int mtd_probe(struct udevice *dev);
+int mtd_probe_devices(void);
 
 #endif
 #endif /* __MTD_MTD_H__ */
Signature · 1 line
2.14.1
author maintainer
#27 lore raw

PATCH v6 27/27 cmd: mtdparts: try to probe the MTD devices as a fallback

In reply to Miquel Raynal

Current implementation of mtdparts command errors out if the desired MTD device is not found. Fallback to the new probe function in this case before erroring out.

This will the save the user the need to call something like 'mtd list' before mtdparts.

---
 cmd/mtdparts.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
cmd/mtdparts.c +9 -3
index ef8588bd71..76f0138e4d 100644
@@ -305,9 +305,15 @@ static int get_mtd_info(u8 type, u8 num, struct mtd_info **mtd)
 
 	sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
 	*mtd = get_mtd_device_nm(mtd_dev);
-	if (IS_ERR(*mtd)) {
-		printf("Device %s not found!\n", mtd_dev);
-		return 1;
+	if (IS_ERR_OR_NULL(*mtd)) {
+#ifdef CONFIG_CMD_MTD
+		mtd_probe_devices();
+		*mtd = get_mtd_device_nm(mtd_dev);
+#endif
+		if (IS_ERR_OR_NULL(*mtd)) {
+			printf("Device %s not found!\n", mtd_dev);
+			return 1;
+		}
 	}
 	put_mtd_device(*mtd);
 
Signature · 1 line
2.14.1
author maintainer
#28 lore raw

v6 cover SPI-NAND support

In reply to Miquel Raynal

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Jagan, is this version OK? Is it part of your PR?

Thanks,
Miquèl

#29 lore raw

v6 cover SPI-NAND support

Quoted 44 lines · Miquel Raynal

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

Quoted 4 lines

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

#30 lore raw

v6 cover SPI-NAND support

Quoted 45 lines · Jagan Teki
Quoted 44 lines · Miquel Raynal

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 38 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

Quoted 8 lines
Quoted 4 lines

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

author maintainer
#31 lore raw

v6 cover SPI-NAND support

Hi Jagan,

Jagan Teki <[email protected]> wrote on Fri, 3 Aug 2018 17:38:33 +0530:

Quoted 49 lines · Jagan Teki
Quoted 48 lines · Miquel Raynal
Quoted 47 lines

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

Thanks for the reports.

Quoted 3 lines

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

Boris supposedly fixed all the build issues related to my changes (I don't think the "missing interrupt parent" in a DTS file is related), please pull his branch [1].

The fixes are under the form of fixups if you wanna check them. Otherwise you can just 'rebase -i --autosquash' to automatically squash them with the commit introducing the regression.

[1] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814

Thanks,
Miquèl

Signature · 3 lines
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#32 lore raw

v6 cover SPI-NAND support

Quoted 69 lines · On Sat, 4 Aug 2018 09:23:05 +0200 Miquel Raynal <[email protected]>…

Hi Jagan,

Jagan Teki <[email protected]> wrote on Fri, 3 Aug 2018 17:38:33 +0530:

Quoted 49 lines · Jagan Teki
Quoted 48 lines · Miquel Raynal
Quoted 47 lines

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

Thanks for the reports.

Quoted 3 lines

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

Quoted 7 lines

Boris supposedly fixed all the build issues related to my changes (I don't think the "missing interrupt parent" in a DTS file is related), please pull his branch [1].

The fixes are under the form of fixups if you wanna check them. Otherwise you can just 'rebase -i --autosquash' to automatically squash them with the commit introducing the regression.

One more thing, if you want to make things bisectable patch 6 ("mtd: fix build issue with includes") and it's fixup should be squashed in patch 5 ("mtd: add get/set of_node/flash_node helpers"), because the build failure you're fixing in patch 6 is introduced by patch 5.

Quoted 2 lines

[1] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814

You mean

[1]https://github.com/bbrezillon/u-boot/commits/wip-spi

author maintainer
#33 lore raw

v6 cover SPI-NAND support

Hi Boris,

Boris Brezillon <[email protected]> wrote on Sat, 4 Aug 2018 10:34:55 +0200:

Quoted 86 lines
Quoted 69 lines · On Sat, 4 Aug 2018 09:23:05 +0200 Miquel Raynal <[email protected]>…

Hi Jagan,

Jagan Teki <[email protected]> wrote on Fri, 3 Aug 2018 17:38:33 +0530:

Quoted 49 lines · Jagan Teki
Quoted 48 lines · Miquel Raynal
Quoted 47 lines

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

Thanks for the reports.

Quoted 3 lines

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

Quoted 7 lines

Boris supposedly fixed all the build issues related to my changes (I don't think the "missing interrupt parent" in a DTS file is related), please pull his branch [1].

The fixes are under the form of fixups if you wanna check them. Otherwise you can just 'rebase -i --autosquash' to automatically squash them with the commit introducing the regression.

One more thing, if you want to make things bisectable patch 6 ("mtd: fix build issue with includes") and it's fixup should be squashed in patch 5 ("mtd: add get/set of_node/flash_node helpers"), because the build failure you're fixing in patch 6 is introduced by patch 5.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

[1] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814

You mean

[1]https://github.com/bbrezillon/u-boot/commits/wip-spi

Oops!

Thanks,
Miquèl

#34 lore raw

v6 cover SPI-NAND support

Are you planning to send the next version?

Quoted 102 lines · Miquel Raynal

Hi Boris,

Boris Brezillon <[email protected]> wrote on Sat, 4 Aug 2018 10:34:55 +0200:

Quoted 86 lines
Quoted 69 lines · On Sat, 4 Aug 2018 09:23:05 +0200 Miquel Raynal <[email protected]>…

Hi Jagan,

Jagan Teki <[email protected]> wrote on Fri, 3 Aug 2018 17:38:33 +0530:

Quoted 49 lines · Jagan Teki
Quoted 48 lines · Miquel Raynal
Quoted 47 lines

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

Thanks for the reports.

Quoted 3 lines

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

Quoted 7 lines

Boris supposedly fixed all the build issues related to my changes (I don't think the "missing interrupt parent" in a DTS file is related), please pull his branch [1].

The fixes are under the form of fixups if you wanna check them. Otherwise you can just 'rebase -i --autosquash' to automatically squash them with the commit introducing the regression.

One more thing, if you want to make things bisectable patch 6 ("mtd: fix build issue with includes") and it's fixup should be squashed in patch 5 ("mtd: add get/set of_node/flash_node helpers"), because the build failure you're fixing in patch 6 is introduced by patch 5.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

[1] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814

You mean

[1]https://github.com/bbrezillon/u-boot/commits/wip-spi

Oops!

Thanks,
Miquèl

Signature · 4 lines
Jagan Teki
Senior Linux Kernel Engineer | Amarula Solutions
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
author maintainer
#35 lore raw

v6 cover SPI-NAND support

Hi Jagan,

Jagan Teki <[email protected]> wrote on Mon, 6 Aug 2018 23:20:19 +0530:

Quoted 1 line

Are you planning to send the next version?

I was not as we gave you a branch to pull patches from and test with Travis if the warnings were gone [1].

Of course I can send the patches if you want them here also.

If Stefan sends a new iteration of his series I could fold the changes.

[1] https://github.com/bbrezillon/u-boot/commits/wip-spi

Thanks,
Miquèl

#36 lore raw

v6 cover SPI-NAND support

In reply to Miquel Raynal

2018-08-04 9:23 GMT+02:00 Miquel Raynal <[email protected]>:

Quoted 66 lines

Hi Jagan,

Jagan Teki <[email protected]> wrote on Fri, 3 Aug 2018 17:38:33 +0530:

Quoted 49 lines · Jagan Teki
Quoted 48 lines · Miquel Raynal
Quoted 47 lines

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

Thanks for the reports.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

Boris supposedly fixed all the build issues related to my changes (I don't think the "missing interrupt parent" in a DTS file is related), please pull his branch [1].

the DTS warnings are unrelated and can be ignored. Only the onenand_* stuff seems
to be a regression.I wonder if VCT is the only board remaining with OneNAND support?

Quoted 15 lines

The fixes are under the form of fixups if you wanna check them. Otherwise you can just 'rebase -i --autosquash' to automatically squash them with the commit introducing the regression.

[1] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814

Thanks,
Miquèl

--
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

Signature · 1 line
- Daniel
author maintainer
#37 lore raw

v6 cover SPI-NAND support

Hi Daniel,

Daniel Schwierzeck <[email protected]> wrote on Tue, 7 Aug 2018 16:39:34 +0200:

Quoted 70 lines

2018-08-04 9:23 GMT+02:00 Miquel Raynal <[email protected]>:

Quoted 69 lines

Hi Jagan,

Jagan Teki <[email protected]> wrote on Fri, 3 Aug 2018 17:38:33 +0530:

Quoted 49 lines · Jagan Teki
Quoted 48 lines · Miquel Raynal
Quoted 47 lines

Hi Jagan, Tom,

Miquel Raynal <[email protected]> wrote on Wed, 1 Aug 2018 10:18:21 +0200:

Quoted 31 lines

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Quoted 7 lines

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

I can't see a pull request flow on U-Boot ML, I suppose you use a different mean for that purpose.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Jagan, is this version OK? Is it part of your PR?

Travis is going on [1], will send PR once all fine.

[1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788

There are some build issues, not quite sure whether it relates. please look into it.

Thanks for the reports.

Quoted 3 lines

[2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
[3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815

Quoted 7 lines
Quoted 3 lines

Boris supposedly fixed all the build issues related to my changes (I don't think the "missing interrupt parent" in a DTS file is related), please pull his branch [1].

the DTS warnings are unrelated and can be ignored. Only the onenand_* stuff seems
to be a regression.

OneNAND warnings should be gone with Boris fixups.

Thanks,
Miquèl

#38 lore raw

v6 cover SPI-NAND support

In reply to Miquel Raynal

Hi Miquel,

I just noticed that when using this patchset version, I'm getting oopses / crashes while trying to attach an MTD partition to UBI using "ubi part". This did not happen with earlier versions.

I digged a bit into it and noticed that for example mtd_read() in mtdcore.c has some differences which are not mentioned in the commit history. Perhaps this is some mistake, or I did something wrong - I wanted to mention it.

Tomorrow I can dig into it a bit more if necessary.

Thanks,
Stefan

Quoted 292 lines · Miquel Raynal

During the last months, Boris Brezillon shared his work to support serial flashes within Linux. First, he delivered (and merged) a new layer called spi-mem. He also initiated in Linux MTD subsystem the move of all 'raw' NAND related code to a raw/ subdirectory, adding at the same time a NAND core that would be shared with all NAND devices. Then, he contributed a generic SPI-NAND driver, making use of this NAND core, as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort of MTD devices. This should become the default command instead of having one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514), featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

Quoted 4 lines

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition

Thanks,
Miquèl

Changes since v5:
-----------------
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

Changes since v4:
-----------------
* Added Jagan's Acked-by tags to every patch related to the SPI-mem/SPI-NAND addition.
* Rebased on top of master.

Changes since v3:
-----------------
* Fixed the debug messages in spi-mem to print either Rx or Tx data.
* Fixed a Kconfig error that prevented to build mtdparts with plain defconfig.
* Fixed a compilation error due to the above error that prevented one file to be compiled.
* Adapted the mtd command to probe MTD partitions also.
* Declared mtd_probe_devices() in a header so mtdparts or UBI could use it too (to probe all devices and MTD partitions in a clean way).
* As I worked on mtdparts, I found annoying and completely useless the fact that we need to prefix the environment variable with "mtdparts=". Canceled this obligation.
* Added one patch to allow spi-nand devices to be recognized by mtdparts (this is purely useless but needed to be done in order to use this command).
* Removed useless definitions of MTD device types in UBI code.
* Wrote a generic mtdparts environment variable parser, used by the mtd command.
* Used the mtd_probe_devices() function from get_mtd_info() in cmd/mtdparts.c to be sure the desired partition really does not exist (otherwise it will be probed and then found).

Changes since v2:
-----------------
* Rebased on u-boot master branch.
* Removed extra-parenthesis in
"mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing"
* s/fiels/files/ in "mtd: move NAND fiels into a raw/ subdirectory"
* Do not describe generic SPI device properties in SPI NAND bindings.
* Changes in the mtd command:
* Printing more information in 'mtd list' (device type, device characteristics)
* Switch to do_div() instead of '(u32)value64b % value32b' which only worked because value32b was a power of 2.
* Removed erase.chip option.
* By default, erase/read/write happen on the full MTD device while a dump will only work on a single page.

Changes since v1:
-----------------
* Fixed the nand_memorg structure of the MX35LF2GE4AB chip.
* Added Reviewed-by tags from Jagan.
* Backported and squashed two patches fixing things in the SPI NAND core received on the Linux ML.
* Backported more changes in mtdcore.c from Linux.
* Added a patch to add a fallback on mtd->_read/_write() in mtdcore.c when mtd->_read/write_oob() is not supported.
* Removed the DT changes, useless as the DTs are not available in mainline yet.
* Addressed Boris/Stefan comments on the 'mtd' command.
* Added support for multi-pages OOB read/write.

Boris Brezillon (7):
mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
mtd: Add sanity checks in mtd_write/read_oob()
mtd: nand: Add core infrastructure to deal with NAND devices
mtd: nand: Pass mode information to nand_page_io_req
spi: Extend the core to ease integration of SPI memory controllers
mtd: spinand: Add initial support for the MX35LF1GE4AB chip
dt-bindings: Add bindings for SPI NAND devices

Brian Norris (1):
mtd: add get/set of_node/flash_node helpers

Ezequiel Garcia (1):
mtd: Uninline mtd_write_oob and move it to mtdcore.c

Frieder Schrempf (1):
mtd: spinand: Add initial support for Winbond W25M02GV

Miquel Raynal (15):
mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing
mtd: fix build issue with includes
mtd: move definitions to enlarge their range
mtd: move all flash categories inside MTD submenu
mtd: move NAND files into a raw/ subdirectory
mtd: rename nand into rawnand in Kconfig prompt
mtd: spinand: Add initial support for the MX35LF2GE4AB chip
mtd: declare MTD_PARTITIONS symbol in Kconfig
cmd: ubi: delete useless and misleading definitions
cmd: mtdparts: accept spi-nand devices
cmd: mtdparts: add a generic 'mtdparts' parser
cmd: mtdparts: remove useless 'mtdparts=' prefix
mtd: uclass: add probe function
cmd: mtd: add 'mtd' command
cmd: mtdparts: try to probe the MTD devices as a fallback

Peter Pan (2):
mtd: nand: Add core infrastructure to support SPI NANDs
mtd: spinand: Add initial support for Micron MT29F2G01ABAGD

  MAINTAINERS                                   |    6 +-
  Makefile                                      |    2 +-
  README                                        |    6 +-
  arch/arm/mach-uniphier/board_late_init.c      |    2 +-
  cmd/Kconfig                                   |    7 +
  cmd/Makefile                                  |    1 +
  cmd/mtd.c                                     |  392 ++++++++
  cmd/mtdparts.c                                |  113 ++-
  cmd/ubi.c                                     |    5 -
  common/spl/Kconfig                            |    2 +-
  common/spl/spl_spi.c                          |    2 +-
  doc/README.SPL                                |    4 +-
  doc/README.arm-relocation                     |    2 +-
  doc/README.nand                               |    6 +-
  doc/README.zynq                               |    2 +-
  doc/device-tree-bindings/mtd/spi-nand.txt     |    5 +
  drivers/Makefile                              |    2 +-
  drivers/mtd/Kconfig                           |    7 +-
  drivers/mtd/Makefile                          |    4 +-
  drivers/mtd/mtd-uclass.c                      |    9 +
  drivers/mtd/mtdcore.c                         |  106 ++-
  drivers/mtd/mtdcore.h                         |    6 -
  drivers/mtd/mtdpart.c                         |    6 +-
  drivers/mtd/nand/Kconfig                      |  299 +-----
  drivers/mtd/nand/Makefile                     |   78 +-
  drivers/mtd/nand/bbt.c                        |  132 +++
  drivers/mtd/nand/core.c                       |  243 +++++
  drivers/mtd/nand/raw/Kconfig                  |  297 ++++++
  drivers/mtd/nand/raw/Makefile                 |   77 ++
  drivers/mtd/nand/{ => raw}/am335x_spl_bch.c   |    0
  drivers/mtd/nand/{ => raw}/arasan_nfc.c       |    0
  drivers/mtd/nand/{ => raw}/atmel_nand.c       |    0
  drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h   |    0
  drivers/mtd/nand/{ => raw}/davinci_nand.c     |    2 +-
  drivers/mtd/nand/{ => raw}/denali.c           |    0
  drivers/mtd/nand/{ => raw}/denali.h           |    0
  drivers/mtd/nand/{ => raw}/denali_dt.c        |    0
  drivers/mtd/nand/{ => raw}/denali_spl.c       |    0
  drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c    |    0
  drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c     |    0
  drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c     |    0
  drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c      |    0
  drivers/mtd/nand/{ => raw}/fsl_upm.c          |    0
  drivers/mtd/nand/{ => raw}/fsmc_nand.c        |    0
  drivers/mtd/nand/{ => raw}/kb9202_nand.c      |    0
  drivers/mtd/nand/{ => raw}/kirkwood_nand.c    |    0
  drivers/mtd/nand/{ => raw}/kmeter1_nand.c     |    0
  drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c |    0
  drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c |    0
  drivers/mtd/nand/{ => raw}/mxc_nand.c         |    0
  drivers/mtd/nand/{ => raw}/mxc_nand.h         |    0
  drivers/mtd/nand/{ => raw}/mxc_nand_spl.c     |    0
  drivers/mtd/nand/{ => raw}/mxs_nand.c         |    0
  drivers/mtd/nand/{ => raw}/mxs_nand.h         |    0
  drivers/mtd/nand/{ => raw}/mxs_nand_dt.c      |    0
  drivers/mtd/nand/{ => raw}/mxs_nand_spl.c     |    0
  drivers/mtd/nand/{ => raw}/nand.c             |    0
  drivers/mtd/nand/{ => raw}/nand_base.c        |   56 --
  drivers/mtd/nand/{ => raw}/nand_bbt.c         |    0
  drivers/mtd/nand/{ => raw}/nand_bch.c         |    0
  drivers/mtd/nand/{ => raw}/nand_ecc.c         |    2 +-
  drivers/mtd/nand/{ => raw}/nand_ids.c         |    0
  drivers/mtd/nand/{ => raw}/nand_plat.c        |    0
  drivers/mtd/nand/{ => raw}/nand_spl_load.c    |    0
  drivers/mtd/nand/{ => raw}/nand_spl_loaders.c |    0
  drivers/mtd/nand/{ => raw}/nand_spl_simple.c  |    0
  drivers/mtd/nand/{ => raw}/nand_timings.c     |    0
  drivers/mtd/nand/{ => raw}/nand_util.c        |    2 +-
  drivers/mtd/nand/{ => raw}/omap_elm.c         |    0
  drivers/mtd/nand/{ => raw}/omap_gpmc.c        |    0
  drivers/mtd/nand/{ => raw}/pxa3xx_nand.c      |    2 +-
  drivers/mtd/nand/{ => raw}/pxa3xx_nand.h      |    0
  drivers/mtd/nand/{ => raw}/sunxi_nand.c       |    0
  drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c   |    0
  drivers/mtd/nand/{ => raw}/tegra_nand.c       |    0
  drivers/mtd/nand/{ => raw}/tegra_nand.h       |    0
  drivers/mtd/nand/{ => raw}/vf610_nfc.c        |    0
  drivers/mtd/nand/{ => raw}/zynq_nand.c        |    0
  drivers/mtd/nand/spi/Kconfig                  |    7 +
  drivers/mtd/nand/spi/Makefile                 |    4 +
  drivers/mtd/nand/spi/core.c                   | 1254 +++++++++++++++++++++++++
  drivers/mtd/nand/spi/macronix.c               |  146 +++
  drivers/mtd/nand/spi/micron.c                 |  135 +++
  drivers/mtd/nand/spi/winbond.c                |  143 +++
  drivers/mtd/onenand/onenand_base.c            |   60 --
  drivers/spi/Kconfig                           |    7 +
  drivers/spi/Makefile                          |    1 +
  drivers/spi/spi-mem.c                         |  500 ++++++++++
  include/configs/MPC8313ERDB.h                 |    2 +-
  include/jffs2/load_kernel.h                   |    7 +-
  include/linux/mtd/mtd.h                       |   34 +-
  include/linux/mtd/nand.h                      |  734 +++++++++++++++
  include/linux/mtd/partitions.h                |    3 +
  include/linux/mtd/spinand.h                   |  432 +++++++++
  include/spi-mem.h                             |  258 +++++
  include/spi.h                                 |   11 +
  96 files changed, 5064 insertions(+), 561 deletions(-)

create mode 100644 cmd/mtd.c
create mode 100644 doc/device-tree-bindings/mtd/spi-nand.txt create mode 100644 drivers/mtd/nand/bbt.c
create mode 100644 drivers/mtd/nand/core.c
create mode 100644 drivers/mtd/nand/raw/Kconfig create mode 100644 drivers/mtd/nand/raw/Makefile rename drivers/mtd/nand/{ => raw}/am335x_spl_bch.c (100%) rename drivers/mtd/nand/{ => raw}/arasan_nfc.c (100%) rename drivers/mtd/nand/{ => raw}/atmel_nand.c (100%) rename drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h (100%) rename drivers/mtd/nand/{ => raw}/davinci_nand.c (99%) rename drivers/mtd/nand/{ => raw}/denali.c (100%) rename drivers/mtd/nand/{ => raw}/denali.h (100%) rename drivers/mtd/nand/{ => raw}/denali_dt.c (100%) rename drivers/mtd/nand/{ => raw}/denali_spl.c (100%) rename drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c (100%) rename drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c (100%) rename drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c (100%) rename drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c (100%) rename drivers/mtd/nand/{ => raw}/fsl_upm.c (100%) rename drivers/mtd/nand/{ => raw}/fsmc_nand.c (100%) rename drivers/mtd/nand/{ => raw}/kb9202_nand.c (100%) rename drivers/mtd/nand/{ => raw}/kirkwood_nand.c (100%) rename drivers/mtd/nand/{ => raw}/kmeter1_nand.c (100%) rename drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c (100%) rename drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c (100%) rename drivers/mtd/nand/{ => raw}/mxc_nand.c (100%) rename drivers/mtd/nand/{ => raw}/mxc_nand.h (100%) rename drivers/mtd/nand/{ => raw}/mxc_nand_spl.c (100%) rename drivers/mtd/nand/{ => raw}/mxs_nand.c (100%) rename drivers/mtd/nand/{ => raw}/mxs_nand.h (100%) rename drivers/mtd/nand/{ => raw}/mxs_nand_dt.c (100%) rename drivers/mtd/nand/{ => raw}/mxs_nand_spl.c (100%) rename drivers/mtd/nand/{ => raw}/nand.c (100%) rename drivers/mtd/nand/{ => raw}/nand_base.c (98%) rename drivers/mtd/nand/{ => raw}/nand_bbt.c (100%) rename drivers/mtd/nand/{ => raw}/nand_bch.c (100%) rename drivers/mtd/nand/{ => raw}/nand_ecc.c (99%) rename drivers/mtd/nand/{ => raw}/nand_ids.c (100%) rename drivers/mtd/nand/{ => raw}/nand_plat.c (100%) rename drivers/mtd/nand/{ => raw}/nand_spl_load.c (100%) rename drivers/mtd/nand/{ => raw}/nand_spl_loaders.c (100%) rename drivers/mtd/nand/{ => raw}/nand_spl_simple.c (100%) rename drivers/mtd/nand/{ => raw}/nand_timings.c (100%) rename drivers/mtd/nand/{ => raw}/nand_util.c (99%) rename drivers/mtd/nand/{ => raw}/omap_elm.c (100%) rename drivers/mtd/nand/{ => raw}/omap_gpmc.c (100%) rename drivers/mtd/nand/{ => raw}/pxa3xx_nand.c (99%) rename drivers/mtd/nand/{ => raw}/pxa3xx_nand.h (100%) rename drivers/mtd/nand/{ => raw}/sunxi_nand.c (100%) rename drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c (100%) rename drivers/mtd/nand/{ => raw}/tegra_nand.c (100%) rename drivers/mtd/nand/{ => raw}/tegra_nand.h (100%) rename drivers/mtd/nand/{ => raw}/vf610_nfc.c (100%) rename drivers/mtd/nand/{ => raw}/zynq_nand.c (100%) create mode 100644 drivers/mtd/nand/spi/Kconfig create mode 100644 drivers/mtd/nand/spi/Makefile

Quoted 9 lines

create mode 100644 drivers/mtd/nand/spi/core.c create mode 100644 drivers/mtd/nand/spi/macronix.c create mode 100644 drivers/mtd/nand/spi/micron.c create mode 100644 drivers/mtd/nand/spi/winbond.c create mode 100644 drivers/spi/spi-mem.c create mode 100644 include/linux/mtd/nand.h create mode 100644 include/linux/mtd/spinand.h create mode 100644 include/spi-mem.h

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#39 lore raw

v6 cover SPI-NAND support

Quoted 11 lines · On Mon, 6 Aug 2018 19:45:24 +0200 Stefan Roese <[email protected]> wrote:

Hi Miquel,

I just noticed that when using this patchset version, I'm getting oopses / crashes while trying to attach an MTD partition to UBI using "ubi part". This did not happen with earlier versions.

I digged a bit into it and noticed that for example mtd_read() in mtdcore.c has some differences which are not mentioned in the commit history. Perhaps this is some mistake, or I did something wrong - I wanted to mention it.

I have a branch containing this patchset there [1], just in case you want to make sure this is not a mistake you made when applying patches.

[1]https://github.com/bbrezillon/u-boot/tree/wip-spi

#40 lore raw

v6 cover SPI-NAND support

Hi Boris,

Quoted 15 lines · Boris Brezillon
Quoted 11 lines · On Mon, 6 Aug 2018 19:45:24 +0200 Stefan Roese <[email protected]> wrote:

Hi Miquel,

I just noticed that when using this patchset version, I'm getting oopses / crashes while trying to attach an MTD partition to UBI using "ubi part". This did not happen with earlier versions.

I digged a bit into it and noticed that for example mtd_read() in mtdcore.c has some differences which are not mentioned in the commit history. Perhaps this is some mistake, or I did something wrong - I wanted to mention it.

Quoted 4 lines

I have a branch containing this patchset there [1], just in case you want to make sure this is not a mistake you made when applying patches.

[1]https://github.com/bbrezillon/u-boot/tree/wip-spi

Seems that I fat-fingered here something. Applying v6 of this patchset again, all seems fine so far. So:

Thanks,
Stefan