sfrench/cifs-2.6.git
2 years agoMerge tag 'spi-nor/for-5.14' into mtd/next
Miquel Raynal [Wed, 30 Jun 2021 10:52:24 +0000 (12:52 +0200)]
Merge tag 'spi-nor/for-5.14' into mtd/next

SPI NOR core changes:
- Ability to dump SFDP tables via sysfs
- Support for erasing OTP regions on Winbond and similar flashes
- Few API doc updates and fixes
- Locking support for MX25L12805D

SPI NOR controller drivers changes:
- Use SPI_MODE_X_MASK in nxp-spifi
- Intel Alder Lake-M SPI serial flash support

2 years agoMerge tag 'nand/for-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux...
Richard Weinberger [Tue, 29 Jun 2021 21:01:39 +0000 (23:01 +0200)]
Merge tag 'nand/for-5.14' of git://git./linux/kernel/git/mtd/linux into mtd/next

Raw NAND core:
* Allow SDR timings to be nacked
* Bring support for NV-DDR timings which involved a number of small
  preparation changes to bring new helpers, properly introduce NV-DDR
  structures, fill them, differenciate them and pick the best timing set.
* Add the necessary infrastructure to parse the new gpio-cs property
  which aims at enlarging the number of available CS when a hardware
  controller is too constrained.
* Update dead URL
* Silence static checker warning in nand_setup_interface()
* BBT:
  - Fix corner case in bad block table handling
* onfi:
  - Use more recent ONFI specification wording
  - Use the BIT() macro when possible

Raw NAND controller drivers:
* Atmel:
  - Ensure the data interface is supported.
* Arasan:
  - Finer grain NV-DDR configuration
  - Rename the data interface register
  - Use the right DMA mask
  - Leverage additional GPIO CS
  - Ensure proper configuration for the asserted target
  - Add support for the NV-DDR interface
  - Fix a macro parameter
* brcmnand:
  - Convert bindings to json-schema
* OMAP:
  - Various fixes and style improvements
  - Add larger page NAND chips support
* PL35X:
  - New driver
* QCOM:
  - Avoid writing to obsolete register
  - Delete an unneeded bool conversion
  - Allow override of partition parser
* Marvell:
  - Minor documentation correction
  - Add missing clk_disable_unprepare() on error in marvell_nfc_resume()
* R852:
  - Use DEVICE_ATTR_RO() helper macro
* MTK:
  - Remove redundant dev_err call in mtk_ecc_probe()
* HISI504:
  - Remove redundant dev_err call in probe

SPI-NAND core:
* Light reorganisation for the introduction of a core resume handler
* Fix double counting of ECC stats

SPI-NAND manufacturer drivers:
* Macronix:
  - Add support for serial NAND flash

2 years agomtd: spi-nor: remove redundant continue statement
Colin Ian King [Fri, 18 Jun 2021 09:33:31 +0000 (10:33 +0100)]
mtd: spi-nor: remove redundant continue statement

The continue statement at the end of a for-loop has no effect,
invert the if expression and remove the continue.

Addresses-Coverity: ("Continue has no effect")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2 years agomtd: rawnand: omap: Add larger page NAND chips support
Miquel Raynal [Thu, 10 Jun 2021 13:49:06 +0000 (15:49 +0200)]
mtd: rawnand: omap: Add larger page NAND chips support

There is no reason to be limited to 4kiB page NAND chips just because
this is the maximum length the ELM is able to handle in one go. Just
call the ELM several times and it will process as many data as needed.

Here we introduce the concept of ECC page (which is at most 4kiB). The
ELM will be sought as many times as there are ECC pages.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Ryan Barnett <ryan.barnett@collins.com>
Link: https://lore.kernel.org/linux-mtd/20210610134906.3503303-6-miquel.raynal@bootlin.com
2 years agomtd: rawnand: omap: Various style fixes
Miquel Raynal [Thu, 10 Jun 2021 13:49:05 +0000 (15:49 +0200)]
mtd: rawnand: omap: Various style fixes

Fix the comments style, declare the variables in a reverse Christmas
tree order, add an upper case character at the beginning of a sentence.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610134906.3503303-5-miquel.raynal@bootlin.com
2 years agomtd: rawnand: omap: Check return values
Miquel Raynal [Thu, 10 Jun 2021 13:49:04 +0000 (15:49 +0200)]
mtd: rawnand: omap: Check return values

Check the return value of many helpers which might return error codes.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610134906.3503303-4-miquel.raynal@bootlin.com
2 years agomtd: rawnand: omap: Rename a macro
Miquel Raynal [Thu, 10 Jun 2021 13:49:03 +0000 (15:49 +0200)]
mtd: rawnand: omap: Rename a macro

The macro BADBLOCK_MARKER_LENGTH is pretty long and could be reduced to
BBM_LEN which is more handy to use in the code.

This is a purely cosmetic change and is only done to avoid further
change to contain 100+ char lines just because of this definition.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610134906.3503303-3-miquel.raynal@bootlin.com
2 years agomtd: rawnand: omap: Aggregate the HW configuration of the ELM
Miquel Raynal [Thu, 10 Jun 2021 13:49:02 +0000 (15:49 +0200)]
mtd: rawnand: omap: Aggregate the HW configuration of the ELM

Instead of calling elm_config() for each possible BCH configuration,
just save the BCH configuration that must be applied and use it in a
single call at the bottom.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610134906.3503303-2-miquel.raynal@bootlin.com
2 years agomtd: rawnand: pl353: Add support for the ARM PL353 SMC NAND controller
Miquel Raynal [Thu, 10 Jun 2021 08:20:40 +0000 (10:20 +0200)]
mtd: rawnand: pl353: Add support for the ARM PL353 SMC NAND controller

This hardware controller is embedded in XilinX Zynq-7000 SoCs and has
partial support for Hamming ECC correction.

This work is inspired from the original contributions of Punnaiah
Choudary Kalluri and Naga Sureshkumar Relli.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Michael Walle <michael@walle.cc> [on zynq-7000]
Link: https://lore.kernel.org/linux-mtd/20210610082040.2075611-19-miquel.raynal@bootlin.com
2 years agodt-bindings: mtd: pl353-nand: Describe this hardware controller
Miquel Raynal [Thu, 10 Jun 2021 08:20:39 +0000 (10:20 +0200)]
dt-bindings: mtd: pl353-nand: Describe this hardware controller

Add a yaml description of this NAND controller which is described as a
subnode of the SMC bus.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/linux-mtd/20210610082040.2075611-18-miquel.raynal@bootlin.com
2 years agoMAINTAINERS: Add PL353 NAND controller entry
Miquel Raynal [Thu, 10 Jun 2021 08:20:38 +0000 (10:20 +0200)]
MAINTAINERS: Add PL353 NAND controller entry

Add Naga from Xilinx and myself responsible of this driver.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
Link: https://lore.kernel.org/linux-mtd/20210610082040.2075611-17-miquel.raynal@bootlin.com
2 years agomtd: rawnand: qcom: avoid writing to obsolete register
Md Sadre Alam [Tue, 8 Jun 2021 06:48:36 +0000 (12:18 +0530)]
mtd: rawnand: qcom: avoid writing to obsolete register

QPIC_EBI2_ECC_BUF_CFG register got obsolete from QPIC V2.0 onwards.
Avoid writing this register if QPIC version is V2.0 or newer.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1623134916-562-1-git-send-email-mdalam@codeaurora.org
2 years agomtd: rawnand: marvell: Minor documentation correction
Souptick Joarder [Mon, 7 Jun 2021 19:37:36 +0000 (01:07 +0530)]
mtd: rawnand: marvell: Minor documentation correction

Kernel test robot throws below warning ->
drivers/mtd/nand/raw/marvell_nand.c:454: warning: This comment starts
with '/**', but isn't a kernel-doc comment. Refer
Documentation/doc-guide/kernel-doc.rst

Minor documentation correction.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210607193736.4654-1-jrdr.linux@gmail.com
2 years agomtd: rawnand: r852: use DEVICE_ATTR_RO() helper macro
Zhen Lei [Thu, 3 Jun 2021 12:33:39 +0000 (20:33 +0800)]
mtd: rawnand: r852: use DEVICE_ATTR_RO() helper macro

Use DEVICE_ATTR_RO() helper macro instead of plain DEVICE_ATTR(), which
makes the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210603123339.12089-1-thunder.leizhen@huawei.com
2 years agomtd: spinand: add SPI-NAND MTD resume handler
Patrice Chotard [Wed, 2 Jun 2021 09:49:13 +0000 (11:49 +0200)]
mtd: spinand: add SPI-NAND MTD resume handler

After power up, all SPI NAND's blocks are locked. Only read operations
are allowed, write and erase operations are forbidden.
The SPI NAND framework unlocks all the blocks during its initialization.

During a standby low power, the memory is powered down, losing its
configuration.
During the resume, the QSPI driver state is restored but the SPI NAND
framework does not reconfigured the memory.

This patch adds SPI-NAND MTD PM handlers for resume ops.
SPI NAND resume op re-initializes SPI NAND flash to its probed state.

Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210602094913.26472-4-patrice.chotard@foss.st.com
2 years agomtd: spinand: Add spinand_init_flash() helper
Patrice Chotard [Wed, 2 Jun 2021 09:49:12 +0000 (11:49 +0200)]
mtd: spinand: Add spinand_init_flash() helper

Add spinand_init_flash() helper which implement
all needed init for future SPI-NAND resume ops.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210602094913.26472-3-patrice.chotard@foss.st.com
2 years agomtd: spinand: add spinand_read_cfg() helper
Patrice Chotard [Wed, 2 Jun 2021 09:49:11 +0000 (11:49 +0200)]
mtd: spinand: add spinand_read_cfg() helper

Put REG_CFG reading code in spinand_read_cfg().
This function will be needed by the future SPI-NAND resume ops.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210602094913.26472-2-patrice.chotard@foss.st.com
2 years agomtd: rawnand: marvell: add missing clk_disable_unprepare() on error in marvell_nfc_re...
Yang Yingliang [Tue, 1 Jun 2021 12:58:14 +0000 (20:58 +0800)]
mtd: rawnand: marvell: add missing clk_disable_unprepare() on error in marvell_nfc_resume()

Add clk_disable_unprepare() on error path in marvell_nfc_resume().

Fixes: bd9c3f9b3c00 ("mtd: rawnand: marvell: add suspend and resume hooks")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210601125814.3260364-1-yangyingliang@huawei.com
2 years agomtd: rawnand: arasan: Finer grain NV-DDR configuration
Miquel Raynal [Thu, 27 May 2021 08:49:59 +0000 (10:49 +0200)]
mtd: rawnand: arasan: Finer grain NV-DDR configuration

Add support for the timings register which may improve a bit the
overall throughput.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210527084959.208804-2-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Rename the data interface register
Miquel Raynal [Thu, 27 May 2021 08:49:58 +0000 (10:49 +0200)]
mtd: rawnand: arasan: Rename the data interface register

There are 2 timing registers:
- "data interface"
- "timings"

So far, the "data interface" register was named "timings" which begins
misleading when bringing support for the "timings" register. Rename it
to "data_iface".

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210527084959.208804-1-miquel.raynal@bootlin.com
2 years agomtd: rawnand: onfi: Fix endianness when reading NV-DDR values
Miquel Raynal [Thu, 27 May 2021 08:49:13 +0000 (10:49 +0200)]
mtd: rawnand: onfi: Fix endianness when reading NV-DDR values

Without the use of le16_to_cpu(), these accesses would have been wrong
on a big-endian machine.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 45606518f961 ("mtd: rawnand: Add onfi_fill_nvddr_interface_config() helper")
Fixes: 9310668fb60a ("mtd: rawnand: Retrieve NV-DDR timing modes from the ONFI parameter page")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210527084913.208635-1-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Use the right DMA mask
Miquel Raynal [Thu, 27 May 2021 08:45:48 +0000 (10:45 +0200)]
mtd: rawnand: arasan: Use the right DMA mask

Xilinx ZynqMP SoC and the Arasan controller support 64-bit DMA
addressing. Define the right mask otherwise the default is 32
and some accesses may overflow the default mask.

Reported-by: Jorge Courett <jorge.courett@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Jorge Courett <jorge.courett@gmail.com>
Link: https://lore.kernel.org/linux-mtd/20210527084548.208429-1-miquel.raynal@bootlin.com
2 years agomtd: spi-nor: add initial sysfs support
Michael Walle [Mon, 3 May 2021 15:56:51 +0000 (17:56 +0200)]
mtd: spi-nor: add initial sysfs support

Add support to show the manufacturer, the partname and JEDEC identifier
as well as to dump the SFDP table. Not all flashes list their SFDP table
contents in their datasheet. So having that is useful. It might also be
helpful in bug reports from users.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
2 years agomtd: spi-nor: sfdp: save a copy of the SFDP data
Michael Walle [Mon, 3 May 2021 15:56:50 +0000 (17:56 +0200)]
mtd: spi-nor: sfdp: save a copy of the SFDP data

Due to possible mode switching to 8D-8D-8D, it might not be possible to
read the SFDP after the initial probe. To be able to dump the SFDP via
sysfs afterwards, make a complete copy of it.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Tested-by: Heiko Thiery <heiko.thiery@gmail.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2 years agomtd: Convert list_for_each to entry variant
Zou Wei [Tue, 8 Jun 2021 12:34:59 +0000 (20:34 +0800)]
mtd: Convert list_for_each to entry variant

convert list_for_each() to list_for_each_entry() where
applicable.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1623155699-61935-1-git-send-email-zou_wei@huawei.com
2 years agodt-bindings: mtd: Convert ti, am654-hbmc.txt to YAML schema
Vignesh Raghavendra [Fri, 11 Jun 2021 05:35:33 +0000 (11:05 +0530)]
dt-bindings: mtd: Convert ti, am654-hbmc.txt to YAML schema

Convert ti,am654-hbmc.txt to YAML schema for better checks and
validations of DT.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2 years agomtd: inftl: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:28:50 +0000 (10:28 +0800)]
mtd: inftl: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610022850.15397-1-thunder.leizhen@huawei.com
2 years agomtd: amd76xrom: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:26:31 +0000 (10:26 +0800)]
mtd: amd76xrom: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610022631.15344-1-thunder.leizhen@huawei.com
2 years agomtd: ck804xrom: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:24:16 +0000 (10:24 +0800)]
mtd: ck804xrom: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610022416.15291-1-thunder.leizhen@huawei.com
2 years agomtd: esb2rom: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:22:39 +0000 (10:22 +0800)]
mtd: esb2rom: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610022239.15238-1-thunder.leizhen@huawei.com
2 years agomtd: ichxrom: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:21:00 +0000 (10:21 +0800)]
mtd: ichxrom: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610022100.15185-1-thunder.leizhen@huawei.com
2 years agomtd: sun_uflash: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:14:00 +0000 (10:14 +0800)]
mtd: sun_uflash: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610021400.15132-1-thunder.leizhen@huawei.com
2 years agomtd: mtdoops: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:12:01 +0000 (10:12 +0800)]
mtd: mtdoops: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610021201.15076-1-thunder.leizhen@huawei.com
2 years agomtd: rawnand: atmel: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:09:58 +0000 (10:09 +0800)]
mtd: rawnand: atmel: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610020958.15023-1-thunder.leizhen@huawei.com
2 years agomtd: rawnand: sunxi: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:06:20 +0000 (10:06 +0800)]
mtd: rawnand: sunxi: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610020620.14970-1-thunder.leizhen@huawei.com
2 years agomtd: nftl: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 02:01:30 +0000 (10:01 +0800)]
mtd: nftl: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610020130.14917-1-thunder.leizhen@huawei.com
2 years agomtd: rfd_ftl: remove unnecessary oom message
Zhen Lei [Thu, 10 Jun 2021 01:50:52 +0000 (09:50 +0800)]
mtd: rfd_ftl: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610015052.14864-1-thunder.leizhen@huawei.com
2 years agomtd: devices: add support for microchip 48l640 EERAM
Heiko Schocher [Mon, 7 Jun 2021 03:39:09 +0000 (05:39 +0200)]
mtd: devices: add support for microchip 48l640 EERAM

The Microchip 48l640 is a 8KByte EERAM connected via SPI.

Signed-off-by: Heiko Schocher <hs@denx.de>
Tested-by: Fabio Estevam <festevam@denx.de>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210607033909.1424605-3-hs@denx.de
2 years agomtd: devices: add devicetree documentation for microchip 48l640
Heiko Schocher [Mon, 7 Jun 2021 03:39:08 +0000 (05:39 +0200)]
mtd: devices: add devicetree documentation for microchip 48l640

The Microchip 48l640 is a 8KByte EERAM connected via SPI.
Add devicetree bindings documentation.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210607033909.1424605-2-hs@denx.de
2 years agomtd: core: use MTD_DEVICE_ATTR_RO/RW() helper macros
Zhen Lei [Thu, 3 Jun 2021 12:53:23 +0000 (20:53 +0800)]
mtd: core: use MTD_DEVICE_ATTR_RO/RW() helper macros

Use MTD_DEVICE_ATTR_RO/RW() helper macros instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210603125323.12142-3-thunder.leizhen@huawei.com
2 years agomtd: core: add MTD_DEVICE_ATTR_RO/RW() helper macros
Zhen Lei [Thu, 3 Jun 2021 12:53:22 +0000 (20:53 +0800)]
mtd: core: add MTD_DEVICE_ATTR_RO/RW() helper macros

Compared with the definition of DEVICE_ATTR_RO/RW(), the read and write
function names of the sysfs attribute have an additional "mtd_" prefix.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210603125323.12142-2-thunder.leizhen@huawei.com
2 years agomtd: mtdpart: use DEVICE_ATTR_RO() helper macro
Zhen Lei [Thu, 3 Jun 2021 12:30:41 +0000 (20:30 +0800)]
mtd: mtdpart: use DEVICE_ATTR_RO() helper macro

Use DEVICE_ATTR_RO() helper macro instead of plain DEVICE_ATTR(), which
makes the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210603123041.12036-1-thunder.leizhen@huawei.com
2 years agomtd: spinand: Fix double counting of ECC stats
Miquel Raynal [Thu, 27 May 2021 08:43:45 +0000 (10:43 +0200)]
mtd: spinand: Fix double counting of ECC stats

In the raw NAND world, ECC engines increment ecc_stats and the final
caller is responsible for returning -EBADMSG if the verification
failed.

In the SPI-NAND world it was a bit different until now because there was
only one possible ECC engine: the on-die one. Indeed, the
spinand_mtd_read() call was incrementing the ecc_stats counters
depending on the outcome of spinand_check_ecc_status() directly.

So now let's split the logic like this:
- spinand_check_ecc_status() is specific to the SPI-NAND on-die engine
  and is kept very simple: it just returns the ECC status (bonus point:
  the content of this helper can be overloaded).
- spinand_ondie_ecc_finish_io_req() is the caller of
  spinand_check_ecc_status() and will increment the counters and
  eventually return -EBADMSG.
- spinand_mtd_read() is not tied to the on-die ECC implementation and
  should be able to handle results coming from other ECC engines: it has
  the responsibility of returning the maximum number of bitflips which
  happened during the entire operation as this is the only helper that
  is aware that several pages may be read in a row.

Fixes: 945845b54c9c ("mtd: spinand: Instantiate a SPI-NAND on-die ECC engine")
Reported-by: YouChing Lin <ycllin@mxic.com.tw>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: YouChing Lin <ycllin@mxic.com.tw>
Link: https://lore.kernel.org/linux-mtd/20210527084345.208215-1-miquel.raynal@bootlin.com
2 years agoMerge tag 'memory-controller-drv-pl353-5.14' into nand/next
Miquel Raynal [Fri, 11 Jun 2021 18:29:52 +0000 (20:29 +0200)]
Merge tag 'memory-controller-drv-pl353-5.14' into nand/next

Memory controller drivers for v5.14 - PL353

Bigger work around ARM Primecell PL35x SMC memory controller driver by
Miquel Raynal built on previous series from Naga Sureshkumar Relli.

This includes bindings cleanup and correction, converting these to
dtschema and several cleanyps in pl353-smc driver.

2 years agodt-binding: memory: pl353-smc: Convert to yaml
Miquel Raynal [Thu, 10 Jun 2021 08:20:30 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Convert to yaml

Convert this binding file to yaml schema.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-10-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agoMAINTAINERS: Add PL353 SMC entry
Miquel Raynal [Thu, 10 Jun 2021 08:20:37 +0000 (10:20 +0200)]
MAINTAINERS: Add PL353 SMC entry

Add Naga from Xilinx and myself responsible of this driver.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
Link: https://lore.kernel.org/r/20210610082040.2075611-16-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agomemory: pl353-smc: Declare variables following a reverse christmas tree order
Miquel Raynal [Thu, 10 Jun 2021 08:20:36 +0000 (10:20 +0200)]
memory: pl353-smc: Declare variables following a reverse christmas tree order

This is a purely cosmetic change.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210610082040.2075611-15-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agomemory: pl353-smc: Avoid useless acronyms in descriptions
Miquel Raynal [Thu, 10 Jun 2021 08:20:35 +0000 (10:20 +0200)]
memory: pl353-smc: Avoid useless acronyms in descriptions

APER does not mean anything, while it seems legitimate to call this
clock the AXI peripheral clock.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210610082040.2075611-14-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agomemory: pl353-smc: Let lower level controller drivers handle inits
Miquel Raynal [Thu, 10 Jun 2021 08:20:34 +0000 (10:20 +0200)]
memory: pl353-smc: Let lower level controller drivers handle inits

There is no point in having all these definitions at the SMC bus level,
these are extremely tight to the NAND controller driver implementation,
are not particularly generic, imply more boilerplate than needed, do
not really follow the device model by receiving no argument and some of
them are actually buggy.

Let's get rid of these right now as there is no current user and keep
this driver at a simple level: only the SMC bare initializations.

The NAND controller driver which I am going to introduce will take care
of redefining properly all these helpers and using them directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210610082040.2075611-13-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agomemory: pl353-smc: Rename goto labels
Miquel Raynal [Thu, 10 Jun 2021 08:20:33 +0000 (10:20 +0200)]
memory: pl353-smc: Rename goto labels

A goto label is better named

        do_something:

than

        out_something_to_do:

Use the former wording and really describe what the jump involves.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210610082040.2075611-12-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agomemory: pl353-smc: Fix style
Miquel Raynal [Thu, 10 Jun 2021 08:20:32 +0000 (10:20 +0200)]
memory: pl353-smc: Fix style

Use proper spacing.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210610082040.2075611-11-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Fix the NAND controller node in the example
Miquel Raynal [Thu, 10 Jun 2021 08:20:29 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Fix the NAND controller node in the example

To be fully valid, the NAND controller node in the example should be
named nand-controller instead of flash, should be at the address @0,0
instead of @e1000000 and should have a couple of:
- #address-cells
- #size-cells
properties.

The label is being renamed nfc0 as well which is more usual than nand_0.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-8-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Drop unsupported nodes from the example
Miquel Raynal [Thu, 10 Jun 2021 08:20:28 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Drop unsupported nodes from the example

These nodes are given as examples and are not described nor used
anywhere else. There is also no hardware of my knowledge compatible with
these yet. If we want to be backward compatible, then we should avoid
partially describing nodes and their content while there are no users.
Plus, the examples are wrong (the addresses should be updated) so
let's drop them before converting this file to yaml (only the NAND node,
which will be fixed in the example and described somewhere else is
kept).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-7-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Fix the example syntax and style
Miquel Raynal [Thu, 10 Jun 2021 08:20:27 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Fix the example syntax and style

Enhance the spacing, the comment style, add { }, remove (...).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-6-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Describe the child reg property
Miquel Raynal [Thu, 10 Jun 2021 08:20:26 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Describe the child reg property

Each chil node should have a reg property, no matter the type of
controller (NAND, NOR, SRAM). This should be part of the bindings.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-5-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Drop the partitioning section
Miquel Raynal [Thu, 10 Jun 2021 08:20:25 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Drop the partitioning section

This sentence does not belong to this file as this file describes the
bus on which various controllers are wired to.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-4-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Document the range property
Miquel Raynal [Thu, 10 Jun 2021 08:20:24 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Document the range property

The ranges property is missing in the description while actually used in
the example. This property is actually needed, so mention it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-3-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agodt-binding: memory: pl353-smc: Rephrase the binding
Miquel Raynal [Thu, 10 Jun 2021 08:20:23 +0000 (10:20 +0200)]
dt-binding: memory: pl353-smc: Rephrase the binding

Reword this document before converting it to yaml.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210610082040.2075611-2-miquel.raynal@bootlin.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2 years agomtd: spi-nor: otp: implement erase for Winbond and similar flashes
Michael Walle [Mon, 7 Jun 2021 11:27:44 +0000 (13:27 +0200)]
mtd: spi-nor: otp: implement erase for Winbond and similar flashes

Winbond flashes with OTP support provide a command to erase the OTP
data. This might come in handy during development.

This was tested with a Winbond W25Q32JW on a LS1028A SoC with the
NXP FSPI controller.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
2 years agomtd: spi-nor: otp: return -EROFS if region is read-only
Michael Walle [Mon, 7 Jun 2021 11:27:43 +0000 (13:27 +0200)]
mtd: spi-nor: otp: return -EROFS if region is read-only

SPI NOR flashes will just ignore program commands if the OTP region is
locked. Thus, a user might not notice that the intended write didn't end
up in the flash. Return -EROFS to the user in this case. From what I can
tell, chips/cfi_cmdset_0001.c also return this error code.

One could optimize spi_nor_mtd_otp_range_is_locked() to read the status
register only once and not for every OTP region, but for that we would
need some more invasive changes. Given that this is
one-time-programmable memory and the normal access mode is reading, we
just live with the small overhead.

By moving the code around a bit, we can just check the length before
calling spi_nor_mtd_otp_range_is_locked() and avoid an underflow there
if a len is 0. This way we don't need to take the lock either. We also
skip the "*retlen = 0" assignment, mtdcore already takes care of that
for us.

Fixes: 069089acf88b ("mtd: spi-nor: add OTP support")
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
2 years agomtd: spi-nor: otp: use more consistent wording
Michael Walle [Mon, 7 Jun 2021 11:27:42 +0000 (13:27 +0200)]
mtd: spi-nor: otp: use more consistent wording

Use the wording as used in the datasheet to describe the access methods
of the security registers (aka OTP storage). This will also match the
function names.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
2 years agomtd: spi-nor: otp: fix access to security registers in 4 byte mode
Michael Walle [Mon, 7 Jun 2021 11:27:41 +0000 (13:27 +0200)]
mtd: spi-nor: otp: fix access to security registers in 4 byte mode

The security registers either take a 3 byte or a 4 byte address offset,
depending on the address mode of the flash. Thus just leave the
nor->addr_width as is.

Fixes: cad3193fe9d1 ("mtd: spi-nor: implement OTP support for Winbond and similar flashes")
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
2 years agomtd: spi-nor: enable locking support for MX25L12805D
David Bauer [Mon, 10 May 2021 13:33:40 +0000 (15:33 +0200)]
mtd: spi-nor: enable locking support for MX25L12805D

Macronix MX25L12805D supports locking with 4 block
protection bits in its status register. Add the corresponding
flag in order to clear these bits when unloking the flash.

Otherwise, the flash might not be writable depending on the state
left by the bootloader.

Tested-on: Ubiquiti UniFi AC Lite (ath79)

Signed-off-by: David Bauer <mail@david-bauer.net>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Michael Walle <michael@walle.cc>
2 years agomtd: spi-nor: macronix: Fix name for mx66l51235f
Tudor Ambarus [Fri, 2 Apr 2021 08:20:31 +0000 (11:20 +0300)]
mtd: spi-nor: macronix: Fix name for mx66l51235f

According to macronix website, there is no mx66l51235l part number.
The chip detected as such is actually mx66l51235f. Rename the flash.
Do not update the mx66l51235l name from the spi_nor_dev_ids[], since
there are dt that are using this compatible.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
2 years agomtd: spi-nor: intel-spi: Add support for Intel Alder Lake-M SPI serial flash
Mika Westerberg [Thu, 15 Apr 2021 10:11:38 +0000 (13:11 +0300)]
mtd: spi-nor: intel-spi: Add support for Intel Alder Lake-M SPI serial flash

Intel Alder Lake-M has the same SPI serial flash controller as Alder
Lake-S. Add Alder Lake-M PCI ID to the driver list of supported devices.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
2 years agomtd: spi-nor: otp: fix kerneldoc typos
Michael Walle [Wed, 5 May 2021 20:00:17 +0000 (22:00 +0200)]
mtd: spi-nor: otp: fix kerneldoc typos

Use the correct argument names in the kerneldoc.

Fixes: cad3193fe9d1 ("mtd: spi-nor: implement OTP support for Winbond and similar flashes")
Reported-by: Pratyush Yadav <p.yadav@ti.com>
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2 years agomtd: spi-nor: Add documentation for spi_nor_soft_reset()
Pratyush Yadav [Tue, 11 May 2021 09:39:58 +0000 (15:09 +0530)]
mtd: spi-nor: Add documentation for spi_nor_soft_reset()

Document what the function does and that it should only be used when it
is known that the device supports it. This will avoid unaware
programmers thinking that they can arbitrarily use it to reset the
device.

Suggested-by: Michael Walle <michael@walle.cc>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Michael Walle <michael@walle.cc>
2 years agomtd: spi-nor: nxp-spifi: Use SPI_MODE_X_MASK
Andy Shevchenko [Mon, 10 May 2021 14:13:43 +0000 (17:13 +0300)]
mtd: spi-nor: nxp-spifi: Use SPI_MODE_X_MASK

Use SPI_MODE_X_MASK instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Michael Walle <michael@walle.cc>
2 years agomtd: spinand: macronix: Add support for serial NAND flash
Jaime Liao [Thu, 20 May 2021 01:45:08 +0000 (09:45 +0800)]
mtd: spinand: macronix: Add support for serial NAND flash

Macronix NAND Flash devices are available in different configurations
and densities.

MX"35" means SPI NAND
MX35"LF"/"UF" , LF means 3V and UF meands 1.8V
MX35LF"2G" , 2G means 2Gbits
MX35LF2G"E4"/"24"/"14",
E4 means internal ECC and Quad I/O(x4)
24 means 8-bit ecc requirement and Quad I/O(x4)
14 means 4-bit ecc requirement and Quad I/O(x4)

MX35LF2G14AC is 3V 2Gbit serial NAND flash device
(without on-die ECC)
https://www.mxic.com.tw/Lists/Datasheet/Attachments/7926/MX35LF2G14AC,%203V,%202Gb,%20v1.1.pdf

MX35UF4G24AD is 1.8V 4Gbit serial NAND flash device
(without on-die ECC)
https://www.mxic.com.tw/Lists/Datasheet/Attachments/7980/MX35UF4G24AD,%201.8V,%204Gb,%20v0.00.pdf

MX35UF4GE4AD/MX35UF2GE4AD are 1.8V 4G/2Gbit serial
NAND flash device with 8-bit on-die ECC
https://www.mxic.com.tw/Lists/Datasheet/Attachments/7983/MX35UF4GE4AD,%201.8V,%204Gb,%20v0.00.pdf

MX35UF2GE4AC/MX35UF1GE4AC are 1.8V 2G/1Gbit serial
NAND flash device with 8-bit on-die ECC
https://www.mxic.com.tw/Lists/Datasheet/Attachments/7974/MX35UF2GE4AC,%201.8V,%202Gb,%20v1.0.pdf

MX35UF2G14AC/MX35UF1G14AC are 1.8V 2G/1Gbit serial
NAND flash device (without on-die ECC)
https://www.mxic.com.tw/Lists/Datasheet/Attachments/7931/MX35UF2G14AC,%201.8V,%202Gb,%20v1.1.pdf

Validated via normal(default) and QUAD mode by read, erase, read back,
on Xilinx Zynq PicoZed FPGA board which included Macronix
SPI Host(drivers/spi/spi-mxic.c).

Signed-off-by: Jaime Liao <jaimeliao@mxic.com.tw>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1621475108-22523-1-git-send-email-jaimeliao@mxic.com.tw
2 years agomtd: rawnand: qcom: Delete an unneeded bool conversion
Zhen Lei [Mon, 10 May 2021 11:49:44 +0000 (19:49 +0800)]
mtd: rawnand: qcom: Delete an unneeded bool conversion

The result of an expression consisting of a single relational operator is
already of the bool type and does not need to be evaluated explicitly.

No functional change.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210510114944.3527-1-thunder.leizhen@huawei.com
2 years agomtd: rawnand: arasan: Leverage additional GPIO CS
Miquel Raynal [Wed, 26 May 2021 09:32:42 +0000 (11:32 +0200)]
mtd: rawnand: arasan: Leverage additional GPIO CS

Make use of the cs-gpios DT property as well as the core helper to parse
it so that the Arasan controller driver can now assert many more chips
than natively.

The Arasan controller has an internal limitation: RB0 is tied to CS0 and
RB1 is tied to CS1. Hence, it is possible to use external GPIOs as long
as one or the other native CS is not used (or configured to be driven as
a GPIO) and that all additional CS are physically wired on its
corresponding RB line. Eg. CS0 is used as a native CS, CS1 is not used
as native CS and may be used as a GPIO CS, CS2 is an additional GPIO
CS. Then the target asserted by CS0 should also be wired to RB0, while
the targets asserted by CS1 and CS2 should be wired to RB1.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210526093242.183847-5-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Ensure proper configuration for the asserted target
Miquel Raynal [Wed, 26 May 2021 09:32:41 +0000 (11:32 +0200)]
mtd: rawnand: arasan: Ensure proper configuration for the asserted target

The controller being always asserting one CS or the other, there is no
need to actually select the right target before doing a page read/write.
However, the anfc_select_target() helper actually also changes the
timing configuration and clock in the case were two different NAND chips
with different timing requirements would be used. In this situation, we
must ensure proper configuration of the controller by calling it.

As a consequence of this change, the anfc_select_target() helper is
being moved earlier in the driver.

Fixes: 88ffef1b65cf ("mtd: rawnand: arasan: Support the hardware BCH ECC engine")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210526093242.183847-4-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Add a helper to parse the gpio-cs DT property
Miquel Raynal [Wed, 26 May 2021 09:32:40 +0000 (11:32 +0200)]
mtd: rawnand: Add a helper to parse the gpio-cs DT property

New chips may feature a lot of CS because of their extended length. As
many controllers have been designed a decade ago, they usually only
feature just a couple. This does not mean that the entire range of
these chips cannot be accessed: it is just a matter of adding more
GPIO CS in the hardware design. A DT property has been added to
describe the CS array: cs-gpios.

Here is the code parsing it this new property, allocating what needs to
be, requesting the GPIOs and returning an array with the additional
available CS. The first entries of this array are left empty and are
reserved for native CS.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210526093242.183847-3-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Move struct gpio_desc declaration to the top
Miquel Raynal [Wed, 26 May 2021 09:32:39 +0000 (11:32 +0200)]
mtd: rawnand: Move struct gpio_desc declaration to the top

The struct gpio_desc is declared in the middle of the rawnand.h header,
right before the first function using it (nand_gpio_waitrdy). Before
adding a new function and to make it clear: move the declaration to the
top of the file.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210526093242.183847-2-miquel.raynal@bootlin.com
2 years agomtd: parsers: qcom: Fix leaking of partition name
Ansuel Smith [Tue, 25 May 2021 23:09:31 +0000 (01:09 +0200)]
mtd: parsers: qcom: Fix leaking of partition name

Add cleanup function as the name variable for the partition name was
allocaed but never freed after the use as the add mtd function
duplicate the name and free the pparts struct as the partition name is
assumed to be static.
The leak was found using kmemleak.

Fixes: 803eb124e1a6 ("mtd: parsers: Add Qcom SMEM parser")
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210525230931.30013-1-ansuelsmth@gmail.com
2 years agomtd: partitions: redboot: fix style issues
Corentin Labbe [Thu, 20 May 2021 11:48:51 +0000 (11:48 +0000)]
mtd: partitions: redboot: fix style issues

This patch fixes easy checkpatch issues.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210520114851.1274609-2-clabbe@baylibre.com
2 years agomtd: partitions: redboot: seek fis-index-block in the right node
Corentin Labbe [Thu, 20 May 2021 11:48:50 +0000 (11:48 +0000)]
mtd: partitions: redboot: seek fis-index-block in the right node

fis-index-block is seeked in the master node and not in the partitions node.
For following binding and current usage, the driver need to check the
partitions subnode.

Fixes: c0e118c8a1a3 ("mtd: partitions: Add OF support to RedBoot partitions")
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210520114851.1274609-1-clabbe@baylibre.com
2 years agomtd: devices: Remove superfluous "break"
Ding Senjie [Fri, 14 May 2021 12:44:51 +0000 (20:44 +0800)]
mtd: devices: Remove superfluous "break"

Remove superfluous "break", as there is a "return" before it.

Signed-off-by: Ding Senjie <dingsenjie@yulong.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210514124451.20352-1-dingsenjie@163.com
2 years agodt-binding: mtd: nand: Document the cs-gpios property
Miquel Raynal [Mon, 10 May 2021 17:18:00 +0000 (19:18 +0200)]
dt-binding: mtd: nand: Document the cs-gpios property

To reach higher capacities, arrays of chips are now pretty common.
Unfortunately, most of the controllers have been designed a decade ago
and did not all anticipate the need for several chip-selects. The new
cs-gpios property allows to workaround this limitation by adding as many
GPIO chip-select as needed.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/linux-mtd/20210510171800.27225-1-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Support NV-DDR interface
Miquel Raynal [Wed, 5 May 2021 21:37:50 +0000 (23:37 +0200)]
mtd: rawnand: arasan: Support NV-DDR interface

Add support for the NV-DDR interface.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-23-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Workaround a misbehaving prog type with NV-DDR
Miquel Raynal [Wed, 5 May 2021 21:37:49 +0000 (23:37 +0200)]
mtd: rawnand: arasan: Workaround a misbehaving prog type with NV-DDR

As explained in the comment introduced above the fix, the Arasan
controller driver starts an operation when the prog register is being
written with a "type" specific to the action to perform.

The prog type used until now to perform a CHANGE READ COLUMN with an SDR
interface was the PAGE READ type (CMD + ADDR + CMD +
DATA). Unfortunately, for an unknown reason (let's call this a silicon
bug) any CHANGE READ COLUMN performed this way in NV-DDR mode will fail:
the data ready flag will never be triggered, nor will be the transfer
complete flag. Forcefully, this leads to a timeout situation which is
not easy to handle.

Fortunately, it was spotted that sending the same commands through a
different prog register "type", CHANGE READ COLUMN ENHANCED, would work
all the time (even though this particular command is not supported by
the core and is only available in a limited set of devices - we only
care about the controller configuration and not the actual command which
is sent to the device). So let's use this type instead when a CHANGE
READ COLUMN is requested.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-22-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Fix a macro parameter
Miquel Raynal [Wed, 5 May 2021 21:37:48 +0000 (23:37 +0200)]
mtd: rawnand: arasan: Fix a macro parameter

This macro is not yet being used so the compilers never complained
about it.

Fix the macro before using it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-21-miquel.raynal@bootlin.com
2 years agoMAINTAINERS: Add myself as co-maintainer of the Arasan NAND controller driver
Miquel Raynal [Wed, 5 May 2021 21:37:47 +0000 (23:37 +0200)]
MAINTAINERS: Add myself as co-maintainer of the Arasan NAND controller driver

When I submitted the driver I added Naga as Maintainer and forgot to
add myself.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-20-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Choose the best timings, NV-DDR included
Miquel Raynal [Wed, 5 May 2021 21:37:46 +0000 (23:37 +0200)]
mtd: rawnand: Choose the best timings, NV-DDR included

Now that the necessary peaces to support the NV-DDR interface type have
been contributed, let's add the relevant logic to make use of it. In
particular, the core does not choose the best SDR timings anymore but
calls a more generic helper instead.

This helper checks if NV-DDR is supported by trying to find the best
NV-DDR supported mode through a logic very close to what is being done
for SDR timings. If no NV-DDR mode in common between the NAND controller
and the NAND chip is found, the core will fallback to SDR.

Side note: theoretically, the data clock speed in NV-DDR mode 0 is
slower than in SDR mode 5. In the situation where we would get a working
NV-DDR mode 0, we could also try if SDR mode 5 is supported and
eventually fallback to it in order to get the fastest possible
throughput. However, in the field, it looks like most of the devices
supporting NV-DDR avoid implementing the fastest SDR modes (like 4 and 5
EDO modes, which are a bit more complicated to handle than the other SDR
modes). So, we will stick to the simplest logic: try NV-DDR otherwise
fallback to SDR. If someone else experiences strong differences because
of that we may still implement the logic defined above.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-19-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Allow SDR timings to be nacked
Miquel Raynal [Wed, 5 May 2021 21:37:45 +0000 (23:37 +0200)]
mtd: rawnand: Allow SDR timings to be nacked

This should never happen in theory and is probably a controller driver
bug. Anyway it's probably better to bail out at this point if this
happens rather than continuing the boot process.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-18-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Support enabling NV-DDR through SET_FEATURES
Miquel Raynal [Wed, 5 May 2021 21:37:44 +0000 (23:37 +0200)]
mtd: rawnand: Support enabling NV-DDR through SET_FEATURES

Until now the parameter of the ADDR_TIMING_MODE feature was just the
ONFI timing mode (from 0 to 5) because we were only supporting the SDR
data interface. In the same byte, bits 4 and 5 indicate which data
interface is being configured so use them to set the right mode and also
read them back to ensure the right timing has been setup on the chip's
side.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-17-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Add a helper to find the closest ONFI NV-DDR mode
Miquel Raynal [Wed, 5 May 2021 21:37:43 +0000 (23:37 +0200)]
mtd: rawnand: Add a helper to find the closest ONFI NV-DDR mode

Introduce a similar helper to onfi_find_closest_sdr_mode(), but for
NV-DDR timings. It just takes a timing structure as parameter and
returns the closest mode by comparing all minimum timings. This is
useful for rigid controllers on which tuning the timings is not
possible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-16-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Handle the double bytes in NV-DDR mode
Miquel Raynal [Wed, 5 May 2021 21:37:42 +0000 (23:37 +0200)]
mtd: rawnand: Handle the double bytes in NV-DDR mode

As explained in chapter "NV-DDR / NV-DDR2 / NV-DDR3 and Repeat Bytes" of
the ONFI specification, with some commands (mainly the commands which do
not transfer actual data) the data bytes are repeated twice and it is
the responsibility of the receiver to discard them properly. The
concerned commands are: SET_FEATURES, READ_ID, GET_FEATURES,
READ_STATUS, READ_STATUS_ENHANCED, ODT_CONFIGURE. Hence, in the NAND
core we are only impacted by the implementation of READ_ID, GET_FEATURES
and READ_STATUS.

The logic is the same for all:
2/ Check if it is relevant to read all data bytes twice.
1/ Allocate a buffer with twice the requested size (may be done
   statically).
2/ Update the instruction structure to read these extra bytes in the
   allocated buffer.
3/ Copy the even bytes into the original buffer. The performance hit is
   negligible on such small data transfers anyway and we don't really
   care about performances at this stage anyway.
4/ Free the allocated buffer, if any.

Note: nand_data_read_op() is also impacted because it is theoretically
possible to run the command/address cycles first, and, as another
operation, do the data transfers. In this case we can easily identify
the impacted commands because the force_8bit flag will be set (due to
the same reason: their data does not go through the same pipeline).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-15-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Access SDR and NV-DDR timings through a common macro
Miquel Raynal [Wed, 5 May 2021 21:37:41 +0000 (23:37 +0200)]
mtd: rawnand: Access SDR and NV-DDR timings through a common macro

Most timings related to the bus timings are different between SDR and
NV-DDR. However, we identified 9 individual timings which are more
related to the NAND chip internals. These are common between the two
interface types. Fortunately, only these common timings are being shared
through the NAND core and its ->exec_op() interface, which allows the
writing of a simple macro checking the interface type and depending on
it, returning either the relevant SDR timing or the NV-DDR timing. This
is the purpose of the NAND_COMMON_TIMING_PS() macro.

As all this is evaluated at build time, one will immediately be notified
in case a non common timing is being accessed through this macro.

Two handy macros are also inserted at the same time, which use
PSEC_TO_NSEC or PSEC_TO_MSEC so that it is very easy to return timings
in milli-, nano- or pico-seconds, as usually requested by the internal
API.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-14-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Avoid accessing NV-DDR timings from legacy code
Miquel Raynal [Wed, 5 May 2021 21:37:40 +0000 (23:37 +0200)]
mtd: rawnand: Avoid accessing NV-DDR timings from legacy code

Legacy code should not benefit from newer features, especially in
helpers that have been deprecated for a very long time. People who want
NV-DDR support must migrate their driver to the ->exec_op() API.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-13-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Add onfi_fill_nvddr_interface_config() helper
Miquel Raynal [Wed, 5 May 2021 21:37:39 +0000 (23:37 +0200)]
mtd: rawnand: Add onfi_fill_nvddr_interface_config() helper

Same logic as for the SDR path, let's create a
onfi_fill_nvddr_interface_config() helper to fill an interface
configuration structure with NV-DDR timings, given a specific ONFI mode.

There is one additional thing to do compared to SDR mode: tCAD timing
can be fast or slow and this depends on an ONFI parameter page bit. By
default the slow value is declared in the timings structure definition,
but this helper can shrink it down if necessary.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-12-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Add an indirection on onfi_fill_interface_config()
Miquel Raynal [Wed, 5 May 2021 21:37:38 +0000 (23:37 +0200)]
mtd: rawnand: Add an indirection on onfi_fill_interface_config()

This helper actually fills the interface configuration with SDR data.
As part of the work to bring NV-DDR support, let's rename this helper
onfi_fill_sdr_interface_config() and add a generic indirection to it.

There are no functional changes here, but this will simplify a next
change which adds onfi_fill_nvddr_interface_config() support.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-11-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Retrieve NV-DDR timing modes from the ONFI parameter page
Miquel Raynal [Wed, 5 May 2021 21:37:37 +0000 (23:37 +0200)]
mtd: rawnand: Retrieve NV-DDR timing modes from the ONFI parameter page

When parsing the ONFI parameter page, save the available NV-DDR timing
modes in the core's dynamic ONFI structure. Once available to the rest
of the core out of the ONFI driver, these values will then be used to
derive the best timing mode.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-10-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Add NV-DDR timings
Miquel Raynal [Wed, 5 May 2021 21:37:36 +0000 (23:37 +0200)]
mtd: rawnand: Add NV-DDR timings

Create the relevant ONFI NV-DDR timings structure and fill it with
default values from the ONFI specification.

Add the relevant structure entries and helpers.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-9-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Clarify the NV-DDR entries in the ONFI structure
Miquel Raynal [Wed, 5 May 2021 21:37:35 +0000 (23:37 +0200)]
mtd: rawnand: Clarify the NV-DDR entries in the ONFI structure

Both src_sync_timing_mode and src_ssync_features entries of the ONFI
parameter page have been updated and now are named nvddr_timing_modes,
nvddr2_timing_modes and nvddr_nvddr2_features, which is much more
understandable for someone which do not know the history of the ONFI
specification. Update the relevant structure with regard to these
changes.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-8-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Use more recent ONFI specification wording
Miquel Raynal [Wed, 5 May 2021 21:37:34 +0000 (23:37 +0200)]
mtd: rawnand: Use more recent ONFI specification wording

In particular, first ONFI specifications referred to SDR modes as
asynchronous modes, which is not the term we usually have in mind. The
spec has then been updated, so do the same here in the NAND subsystem to
avoid any possible confusion.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-7-miquel.raynal@bootlin.com
2 years agomtd: rawnand: Update dead URL
Miquel Raynal [Wed, 5 May 2021 21:37:33 +0000 (23:37 +0200)]
mtd: rawnand: Update dead URL

The current link to the ONFI specification is broken, the onfi.org
website now points to materials on Micron's website. Update the URL
accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-6-miquel.raynal@bootlin.com
2 years agomtd: rawnand: onfi: Use the BIT() macro when possible
Miquel Raynal [Wed, 5 May 2021 21:37:32 +0000 (23:37 +0200)]
mtd: rawnand: onfi: Use the BIT() macro when possible

Update the onfi.h header to use the BIT() macro.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Alexander Dahl <ada@thorsis.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-5-miquel.raynal@bootlin.com
2 years agomtd: rawnand: atmel: Check the proposed data interface is supported
Miquel Raynal [Wed, 5 May 2021 21:37:31 +0000 (23:37 +0200)]
mtd: rawnand: atmel: Check the proposed data interface is supported

Check the data interface is supported in ->setup_interface() before
acknowledging the timings.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-4-miquel.raynal@bootlin.com
2 years agomtd: rawnand: arasan: Check the proposed data interface is supported
Miquel Raynal [Wed, 5 May 2021 21:37:30 +0000 (23:37 +0200)]
mtd: rawnand: arasan: Check the proposed data interface is supported

Check the data interface is supported in ->setup_interface() before
acknowledging the timings.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-3-miquel.raynal@bootlin.com