Commit Graph

1208 Commits

Author SHA1 Message Date
Linus Torvalds
cbbf0a759f * MTD changes:
Apart from a binding conversion to yaml, only minor changes/small fixes
 have been merged.
 
 * Raw NAND changes:
 
 Various controller drivers received minor fixes like DMA mapping checks,
 better timing derivations or bitflip statistics.
 It has also been discovered that some Hynix NAND flashes were not
 supporting read-retries, which is not properly supported.
 
 * SPI NAND changes:
 
 In order to support high-speed modes, certain chips need extra
 configuration like adding more dummy cycles. This is now possible,
 especially on Winbond chips.
 
 Aside from that, Gigadevice gets support for a new chip (GD5F1GM9).
 
 * SPI NOR changes:
 
 A notable changes is the fix for exiting 4-byte addressing on Infineon
 SEMPER flashes. These flashes do not support the standard EX4B
 opcode (E9h), and use a vendor-specific opcode (B8h) instead.
 
 There is also a fix for unlocking flashes that are write-protected at
 power-on. This was caused by using an uninitialized mtd_info in
 spi_nor_try_unlock_all().
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE9HuaYnbmDhq/XIDIJWrqGEe9VoQFAmiLn/sACgkQJWrqGEe9
 VoTGowf/c6kynDuMlQbTANv/UIYX/LRFZsnIx0LB32LWrhLaUIBsbFxejyt07WG9
 ryej+xRUtSHGsqMIw+B/PjvA4hUNLdsSwO/udIwstXNQjJcO9OKp/ucpvlxLzIha
 REq8IifvT9vLLA+Efoq2L25dM14KjuFCAjwm3GH/SmdTOqPhI/Bbnx4vRWIPeXrx
 XZ69ovIiu5NqLTD5IFGsu+omhbFWlDtVALtKNknrTOXWrjLZhDpieO4f7M9rvru6
 OwazFQAWuixzqZRMFqvOzu8KUDnOHi9gHrzi6tS7T1zBUDz9ywdBtaHYCd7VlMJh
 uV1wjUdWjnIh9E8R/llv3D+ko1Ya1w==
 =IS/d
 -----END PGP SIGNATURE-----

Merge tag 'mtd/for-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd updates from Miquel Raynal:
 "MTD changes:

   - Apart from a binding conversion to yaml, only minor changes/small
     fixes have been merged.

  Raw NAND changes:

   - Minor fixes for various controller drivers like DMA mapping checks,
     better timing derivations or bitflip statistics.

   - some Hynix NAND flashes were not supporting read-retries, so don't
     even try to do it

  SPI NAND changes:

   - In order to support high-speed modes, certain chips need extra
     configuration like adding more dummy cycles. This is now possible,
     especially on Winbond chips.

   - Aside from that, Gigadevice gets support for a new chip (GD5F1GM9).

  SPI NOR changes:

   - A notable changes is the fix for exiting 4-byte addressing on
     Infineon SEMPER flashes. These flashes do not support the standard
     EX4B opcode (E9h), and use a vendor-specific opcode (B8h) instead.

   - There is also a fix for unlocking flashes that are write-protected
     at power-on. This was caused by using an uninitialized mtd_info in
     spi_nor_try_unlock_all()"

* tag 'mtd/for-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (26 commits)
  mtd: spinand: winbond: Add comment about the maximum frequency
  mtd: spinand: winbond: Enable high-speed modes on w35n0xjw
  mtd: spinand: winbond: Enable high-speed modes on w25n0xjw
  mtd: spinand: Add a ->configure_chip() hook
  mtd: spinand: Add a frequency field to all READ_FROM_CACHE variants
  mtd: spinand: Fix macro alignment
  spi: spi-mem: Take into account the actual maximum frequency
  spi: spi-mem: Use picoseconds for calculating the op durations
  mtd: rawnand: atmel: set pmecc data setup time
  mtd: spinand: propagate spinand_wait() errors from spinand_write_page()
  mtd: rawnand: fsmc: Add missing check after DMA map
  mtd: rawnand: rockchip: Add missing check after DMA map
  mtd: rawnand: hynix: don't try read-retry on SLC NANDs
  mtd: rawnand: atmel: Fix dma_mapping_error() address
  mtd: nand: brcmnand: fix mtd corrected bits stat
  mtd: rawnand: renesas: Add missing check after DMA map
  mtd: spinand: gigadevice: Add support for GD5F1GM9 chips
  mtd: nand: brcmnand: replace manual string choices with standard helpers
  mtd: map: Don't use "proxy" headers
  mtd: spi-nor: Fix spi_nor_try_unlock_all()
  ...
2025-07-31 13:43:02 -07:00
Linus Torvalds
4522ae2def This pull request contains the following changes for UBI and UBIFS:
UBIFS:
 	- No longer use write_cache_pages()
 
 UBI:
 	- Removal of an unused function
 -----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCAA0FiEEdgfidid8lnn52cLTZvlZhesYu8EFAmiJJ9UWHHJpY2hhcmRA
 c2lnbWEtc3Rhci5hdAAKCRBm+VmF6xi7wf4gEACYUeCKRPJOc6qoCnhsqONKymE/
 jVXxCWOBqpoyF0wtt0BXcS46FpXzKufb2U2BHL6j2/v77qXBYv/KenT1PJe9llXH
 CNoGQb/zgr7cGFULetE12iaTJYxcIyaWfCk1pH7+n8JWeLwTQE66P1PdK5uEzHEp
 5gtDyOic8hSIShLBC01/Td9FVRD3A79DhZUP2WDYxsiZGbA93IvE0RpV2x6iBnOG
 uOzcHAZfnnlO22GoCqcQe5xaqOo3f4mJch6StEDLAs7EN1jvZMSH4wjM6Sbl+R4Z
 3rzLE0LwqItVZCA9yBsZWZLvaGWhS44UH6HXiluTh0a6NzSoyOAg2U+4vU3frfbY
 Kbnum9Rujc3NaVyHHHKmpDWEglj1bk8oN0EXVIOx887JkLjJF0FkSlo+gXp+cA+f
 C0DpsSdJp6XhJsD60dp4gnas8stISmEN0xs/qgICXMo2WByIZlLtsOgBNwfocD8t
 PtckkemupulEnSb9GJ/niAJttACSQFI9DCfnZibj3PYu3OeubSD30mJs/SY6rXOR
 XS9jejSKxdyhyboL9PwuSPVbD2rj/uD/uL8R2ypGbrwNyQGvqUgBQUQjnhNDiOvt
 CHwCtkmoupWxJscmu34K91zrN19i/9Nw4g+/2SOBz6NvVmIknTtuBQfBL57f2ykq
 tZlNwdV/e/a2WCx7dg==
 =/AwZ
 -----END PGP SIGNATURE-----

Merge tag 'ubifs-for-linus-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs

Pull UBI and UBIFS updates from Richard Weinberger:
 "UBIFS:
   - No longer use write_cache_pages()

  UBI:
   - Remove an unused function"

* tag 'ubifs-for-linus-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs:
  ubifs: stop using write_cache_pages
  mtd: ubi: Remove unused ubi_flush
2025-07-31 10:08:44 -07:00
Miquel Raynal
9cf9db888f * Raw NAND changes:
Various controller drivers received minor fixes like DMA mapping checks,
 better timing derivations or bitflip statistics.
 It has also been discovered that some Hynix NAND flashes were not
 supporting read-retries, which is not properly supported.
 
 * SPI NAND changes:
 
 In order to support high-speed modes, certain chips need extra
 configuration like adding more dummy cycles. This is now possible,
 especially on Winbond chips.
 
 Aside from that, Gigadevice gets support for a new chip (GD5F1GM9).
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE9HuaYnbmDhq/XIDIJWrqGEe9VoQFAmiLnj0ACgkQJWrqGEe9
 VoSHCQf/XHxFyj3kvDzbS1qtMfEF8qLxveyucOgvPxnM0v9rDVcsdTaWBVfyJsNX
 vzUPJ3J4NfWQNYo4ya/aennWt/ZCEa+tT6XI9xFp1YRizmQucC7dQLeaGp+eR0Tl
 HVrPLWEVo+3vplI4EWvzwTvBYx5PBmB1t1SzDjx/SsQtG3OS9xgw/DKfV7odHBsH
 REpoUY64QLRtsGL896gkohEGgAd86nqfpaFetS1S3YXfYWryEmAigrDBIQ/IMTCM
 D4lLcgEw82f2Dsa7zhVtxntrfYy2xOOp34kADmbByrBjFbwmcXvKocy7Ahj2dRaq
 JsCkH/Pc1wAHq5uu9GLy24aqzt0OPA==
 =68JT
 -----END PGP SIGNATURE-----

Merge tag 'nand/for-6.17' into mtd/next

* Raw NAND changes:

Various controller drivers received minor fixes like DMA mapping checks,
better timing derivations or bitflip statistics.
It has also been discovered that some Hynix NAND flashes were not
supporting read-retries, which is not properly supported.

* SPI NAND changes:

In order to support high-speed modes, certain chips need extra
configuration like adding more dummy cycles. This is now possible,
especially on Winbond chips.

Aside from that, Gigadevice gets support for a new chip (GD5F1GM9).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-31 18:52:16 +02:00
Miquel Raynal
535f30d997 mtd: spinand: winbond: Enable high-speed modes on w35n0xjw
w35n0xjw chips can run at up to 166MHz in octal mode, but this is only
possible after programming various VCR registers.

Implement the new ->configure_chip() hook for this purpose.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-30 11:32:16 +02:00
Miquel Raynal
f1a91175fa mtd: spinand: winbond: Enable high-speed modes on w25n0xjw
w25n0xjw chips have a high-speed capability hidden in a configuration
register. Once enabled, dual/quad SDR reads may be performed at a much
higher frequency.

Implement the new ->configure_chip() hook for this purpose and configure
the SR4 register accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-30 11:32:16 +02:00
Miquel Raynal
da55809ebb mtd: spinand: Add a ->configure_chip() hook
There is already a manufacturer hook, which is manufacturer specific but
not chip specific. We no longer have access to the actual NAND identity
at this stage so let's add a per-chip configuration hook to align the
chip configuration (if any) with the core's setting.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-30 11:32:16 +02:00
Miquel Raynal
d81ad9d78e mtd: spinand: Add a frequency field to all READ_FROM_CACHE variants
These macros had initially no frequency field. When I added the "maximum
operation frequency" field, I did it initially on very common macros and
I decided to add an optional field for that (with VA_ARGS) in order to
prevent massively unreadable changes. I then added new variants in the
spinand.h header, and requested a frequency field for them by
default. Some times later, I also added maximum frequencies to other
existing variants, but I did it incorrectly, without noticing I was
wrong because the field was optional.

This mix is error prone, so let's do what I should have done since the
very beginning: add a frequency field to all READ_FROM_CACHE variants.

There is no functional change.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-30 11:32:16 +02:00
Miquel Raynal
5de7ea4965 mtd: spinand: Fix macro alignment
No functional change, just a style fix to align with the other
macros all around.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-30 11:32:15 +02:00
Andy Shevchenko
56eb7c13b9 mtd: map: Don't use "proxy" headers
Update header inclusions to follow IWYU (Include What You Use)
principle.

Note that kernel.h is discouraged to be included as it's written
at the top of that file.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-07-28 12:08:21 +02:00
Dr. David Alan Gilbert
ca7be9c0a1 mtd: ubi: Remove unused ubi_flush
ubi_flush() was added in 2012 as part of
commit 62f384552b ("UBI: modify ubi_wl_flush function to clear work queue
for a lnum")
but has remained unused.

(It's friend ubi_wl_flush() is still used)

Remove it.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
2025-07-24 22:19:17 +02:00
Mark Brown
69e536c932
spidev: introduce trivial abb sensor device
Merge series from Heiko Schocher <hs@denx.de>:

This series introduces the changes needed for trivial spi
based sensors from ABB, currently operated from userspace.
2025-07-21 15:39:07 +01:00
Gabor Juhos
0dc7e656dd
mtd: nand: qpic-common: add defines for ECC_MODE values
Add defines for the values of the ECC_MODE field of the NAND_DEV0_ECC_CFG
register and change both the 'qcom-nandc' and 'spi-qpic-snand' drivers to
use those instead of magic numbers.

No functional changes. This is in preparation for adding 8 bit ECC strength
support for the 'spi-qpic-snand' driver.

Reviewed-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20250702-qpic-snand-8bit-ecc-v2-1-ae2c17a30bb7@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-07-02 17:02:42 +01:00
Gabor Juhos
ddaad4ad77
mtd: nand: qpic_common: prevent out of bounds access of BAM arrays
The common QPIC code does not do any boundary checking when it handles
the command elements and scatter gater list arrays of a BAM transaction,
thus it allows to access out of bounds elements in those.

Although it is the responsibility of the given driver to allocate enough
space for all possible BAM transaction variations, however there can be
mistakes in the driver code which can lead to hidden memory corruption
issues which are hard to debug.

This kind of problem has been observed during testing the 'spi-qpic-snand'
driver. Although the driver has been fixed with a preceding patch, but it
still makes sense to reduce the chance of having such errors again later.

In order to prevent such errors, change the qcom_alloc_bam_transaction()
function to store the number of elements of the arrays in the
'bam_transaction' strucutre during allocation. Also, add sanity checks to
the qcom_prep_bam_dma_desc_{cmd,data}() functions to avoid using out of
bounds indices for the arrays.

Tested-by: Lakshmi Sowjanya D <quic_laksd@quicinc.com>     # on SDX75
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Link: https://patch.msgid.link/20250618-qpic-snand-avoid-mem-corruption-v3-2-319c71296cda@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-06-29 22:10:47 +01:00
Miquel Raynal
dba90f5a79 mtd: spinand: winbond: Prevent unsupported frequencies on dual/quad I/O variants
Dual and quad capable chips natively support dual and quad I/O variants
at up to 104MHz (1-2-2 and 1-4-4 operations). Reaching the maximum speed
of 166MHz is theoretically possible (while still unsupported in the
field) by adding a few more dummy cycles. Let's be accurate and clearly
state this limit.

Setting a maximum frequency implies adding the frequency parameter to
the macro, which is done using a variadic argument to avoid impacting
all the other drivers which already make use of this macro.

Fixes: 1ea808b4d1 ("mtd: spinand: winbond: Update the *JW chip definitions")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-06-18 11:18:45 +02:00
Miquel Raynal
635e118317 Revert "mtd: core: always create master device"
The idea behind this patch was to always let a "master" mtd device
available to anchor runtime PM. Historically, there was no mtd device
representing the whole storage as soon as partitions were coming into
play. The introduction of CONFIG_MTD_PARTITIONED_MASTER allowed to keep
this "master" device, but was not enabled by default to avoid breaking
existing users (otherwise the mtd device numbering would be totally
messed up with an off by 1, at least).

The approach of adding an mtd_master class on top of partitioned mtd
devices is breaking the mtd core in many creative ways, so better think
again this approach and revert the faulty changes for now.

This reverts commit 0aa7b390fc.

Fixes: 0aa7b390fc ("mtd: core: always create master device")
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-06-18 11:18:23 +02:00
Miquel Raynal
aa70292325 The SPI NAND subsystem has seen the introduction of DTR operations (the
equivalent of DDR transfers), which involved quite a few preparation
 patches for clarifying macro names.
 
 In the raw NAND subsystem, the brcmnand driver has been "fixed" for old
 legacy SoCs with an update of the ->exec_op() hook, there has been the
 introduction of a new controller driver named Loongson-1, and the
 Qualcomm driver has received quite a few misc fixes as well as a new
 compatible.
 
 Aside from this, there is the usual load of misc improvement and fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE9HuaYnbmDhq/XIDIJWrqGEe9VoQFAmg90ysACgkQJWrqGEe9
 VoTK8gf/U+28sdthNVHENmeQwgzMdjAaZkEn0qftRVplPUTGSqvkrTBQ2tsyGVpj
 V2jJ85WzQ6c+YVRjUsgojX4JClh0tfNrm8ySSu3TOAv98E/sCFttQgyCbELtt6GL
 P4/1g/BqHlagi1ouU95AtH3njZX9qXBq9cQGz3ZWX+qeS0p52wPsj1G8iy6syBR+
 M6GZI92iINSXJUBlFBXzijDSxqcLWsAg8P2E5dTyL9Ukjcju0+fSQtt1oCp1F50+
 zXJHfj3mB+BtBnX6nGhMu3sqY7LaM2NpEq7k6xtvo9ivWZwFAOK+uc31iGvAcKaZ
 R1A72QkRE3e0vQZjrX1JKZvXMVXt4Q==
 =Uj/O
 -----END PGP SIGNATURE-----

Merge tag 'nand/for-6.16' into mtd/next

The SPI NAND subsystem has seen the introduction of DTR operations (the
equivalent of DDR transfers), which involved quite a few preparation
patches for clarifying macro names.

In the raw NAND subsystem, the brcmnand driver has been "fixed" for old
legacy SoCs with an update of the ->exec_op() hook, there has been the
introduction of a new controller driver named Loongson-1, and the
Qualcomm driver has received quite a few misc fixes as well as a new
compatible.

Aside from this, there is the usual load of misc improvement and fixes.
2025-06-02 18:39:50 +02:00
Alexander Usyskin
0aa7b390fc mtd: core: always create master device
Create master device without partition when
CONFIG_MTD_PARTITIONED_MASTER flag is unset.

This streamlines device tree and allows to anchor
runtime power management on master device in all cases.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-05-13 09:33:57 +02:00
Md Sadre Alam
ee000969f2 mtd: rawnand: qcom: Pass 18 bit offset from NANDc base to BAM base
The BAM command descriptor provides only 18 bits to specify the BAM
register offset. Additionally, in the BAM command descriptor, the BAM
register offset is supposed to be specified as "(NANDc base - BAM base)
+ reg_off". Since, the BAM controller expecting the value in the form of
"NANDc base - BAM base", so that added a new field 'bam_offset' in the NAND
properties structure and use it while preparing the command descriptor.

Previously, the driver was specifying the NANDc base address in the BAM
command descriptor.

Cc: stable@vger.kernel.org
Fixes: 8d6b6d7e13 ("mtd: nand: qcom: support for command descriptor formation")
Tested-by: Lakshmi Sowjanya D <quic_laksd@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Acked-by: Mark Brown <broonie@kernel.org>
Tested-by: Gabor Juhos <j4g8y7@gmail.com> # on IPQ9574
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:35 +02:00
Miquel Raynal
51b252cce1 mtd: spinand: Define octal operations
SPI NAND chips may support octal "read from cache" and "program load"
transfers. List the opcodes by defining the relevant macros describing
these operations.

However, due to the hardware available I had, 0x82 and 0xc2 are
untested and given as reference, only 0xc4 could be (successfully)
tested.

Controllers supporting operations mixing SDR and DTR operations might
even leverage octal DTR data I/O transfers.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
ac3a4b17e0 mtd: spinand: Use more specific naming for the (quad) program load op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the (quad) program load macro name.

While at modifying it, better add the missing_ OP suffix to align with
all the other macros of the same kind.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
07cdbae7f8 mtd: spinand: Use more specific naming for the (single) program load op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the (single) program load macro name.

While at modifying it, better add the missing_ OP suffix to align with
all the other macros of the same kind.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
36e461894c mtd: spinand: Use more specific naming for the program execution op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the program execution macro name.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
[Miquel: Fixed conflicts with -next by updating esmt and micron drivers]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
9c6911072c mtd: spinand: Use more specific naming for the (quad IO) read from cache ops
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really mean by describing the expected bus
topology in the (quad IO) read from cache macro names.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
1deae734cc mtd: spinand: Use more specific naming for the (quad output) read from cache ops
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really mean by describing the expected bus
topology in the (quad output) read from cache macro names.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
d9de177996 mtd: spinand: Use more specific naming for the (dual IO) read from cache ops
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really mean by describing the expected bus
topology in the (dual IO) read from cache macro names. While at
modifying them, better reordering the macros to group them all by bus
topology which now feels more intuitive.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
684f7105e8 mtd: spinand: Use more specific naming for the (dual output) read from cache ops
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really mean by describing the expected bus
topology in the (dual output) read from cache macro names.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
ea2087d4e6 mtd: spinand: Use more specific naming for the (single) read from cache ops
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really mean by describing the expected bus
topology in the (single) read from cache macro names.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
7528c97c0c mtd: spinand: Use more specific naming for the page read op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the page read macro name.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:34 +02:00
Miquel Raynal
7e8533b273 mtd: spinand: Use more specific naming for the erase op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the erase macro name.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:33 +02:00
Miquel Raynal
429330cd1c mtd: spinand: Use more specific naming for the get/set feature ops
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really mean by describing the expected bus
topology in the get/set feature macro names.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
[Miquel: Fixed conflicts with -next by updating macronix driver]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:05:03 +02:00
Miquel Raynal
2a294fa215 mtd: spinand: Use more specific naming for the read ID op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the read ID macro name.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:01:58 +02:00
Miquel Raynal
d54e34c58a mtd: spinand: Use more specific naming for the write enable/disable op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the write enable/disable macro names.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
[Miquel: Fixed conflicts with -next by updating esmt and micron drivers]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-29 11:00:56 +02:00
Miquel Raynal
b15d97139f mtd: spinand: Use more specific naming for the reset op
SPI operations have been initially described through macros implicitly
implying the use of a single SPI SDR bus. Macros for supporting dual and
quad I/O transfers have been added on top, generally inspired by vendor
vendor naming, followed by DTR operations. Soon we might see octal
and even octal DTR operations as well (including the opcode byte).

Let's clarify what the macro really means by describing the expected bus
topology in the reset macro name.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-28 10:24:39 +02:00
Miquel Raynal
1c1fd374a2 mtd: spinand: Fix build with gcc < 7.5
__VA_OPT__ is a macro that is useful when some arguments can be present
or not to entirely skip some part of a definition. Unfortunately, it
is a too recent addition that some of the still supported old GCC
versions do not know about, and is anyway not part of C11 that is the
version used in the kernel.

Find a trick to remove this macro, typically '__VA_ARGS__ + 0' is a
workaround used in netlink.h which works very well here, as we either
expect:
- 0
- A positive value
- No value, which means the field should be 0.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503181330.YcDXGy7F-lkp@intel.com/
Fixes: 7ce0d16d58 ("mtd: spinand: Add an optional frequency to read from cache macros")
Cc: stable@vger.kernel.org
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-07 09:05:31 +02:00
Linus Torvalds
f6e0150b20 * MTD changes:
The atmel,dataflash binding has been converted to yaml and the physmap
 one constrained. Some logs are improved, error path are getting reworked
 a bit, few patches target the use of str_enabled_disabled().
 
 * Raw NAND changes:
 i.MX8 and i.MX31 now have their own compatible, the Qcom driver got
 cleaned, the Broadcom driver got fixed.
 
 * SPI NAND changes:
 Two main features have been added:
 - OTP support has been brought, and ESMT and Micron manufacturer drivers
   implement it.
 - Read retry, and Macronix manufacturer driver implement it.
 
 * SPI NOR changes:
 Adding support for few flashes. Few cleanup patches for the core
 driver, where we touched the headers inclusion list and we start using
 the scope based mutex cleanup helpers.
 
 There is as well a bunch of minor improvements and fixes in drivers and
 bindings.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE9HuaYnbmDhq/XIDIJWrqGEe9VoQFAmfkMTQACgkQJWrqGEe9
 VoS+Fgf/apT4C5115f4EolKAcato3QpJ+J1+S0Oy6yYSKQVwKNa4NkdBIeKXfQLc
 rjNdsoE9RmibCKViX3D3rjlMnynbkIr4F3YHbgP4lz7y2TQUVA7Dy0sp2RX+9M3G
 +a5u6lfUyGA/uzJPJUESaPpjLWLg5uTRcduD8hGVid9D+/KFYWNF0EsufobT8JmT
 X/R+aVS58W0uqLEJtiaINsD6D3f8ukMZCNgsvuAUINSUNUrX61pVQZwQAZ4eCCNa
 W+YaLdsMtrwRBdoRGXfrElHEvnufglYocUo+9h8EOVMQ84rfNH363Nu+1WxTVGDj
 GLB5O9knQFy7DR0M4gYBAqqji41nTg==
 =O/Ud
 -----END PGP SIGNATURE-----

Merge tag 'mtd/for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd updates from Miquel Raynal:
 "MTD changes:

   - The atmel,dataflash binding has been converted to yaml and the
     physmap one constrained. Some logs are improved, error path are
     getting reworked a bit, few patches target the use of
     str_enabled_disabled().

  Raw NAND changes:

   - i.MX8 and i.MX31 now have their own compatible, the Qcom driver got
     cleaned, the Broadcom driver got fixed.

  SPI NAND changes:

     - OTP support has been brought, and ESMT and Micron manufacturer
       drivers implement it.

     - Read retry, and Macronix manufacturer driver implement it.

  SPI NOR changes:

   - Adding support for few flashes. Few cleanup patches for the core
     driver, where we touched the headers inclusion list and we start
     using the scope based mutex cleanup helpers.

  There is also a bunch of minor improvements and fixes in drivers
  and bindings"

* tag 'mtd/for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (34 commits)
  dt-bindings: mtd: atmel,dataflash: convert txt to yaml
  mtd: mchp48l640: Use str_enable_disable() in mchp48l640_write_prepare()
  mtd: rawnand: gpmi: Use str_enabled_disabled() in gpmi_nand_attach_chip()
  mtd: mtdpart: Do not supply NULL to printf()
  dt-bindings: mtd: gpmi-nand: Add compatible string for i.MX8 chips
  mtd: nand: Fix a kdoc comment
  mtd: spinand: Improve spinand_info macros style
  mtd: spi-nor: drop unused <linux/of_platform.h>
  mtd: spi-nor: explicitly include <linux/of.h>
  mtd: spi-nor: explicitly include <linux/math64.h>
  mtd: spi-nor: macronix: add support for mx66{l2, u1}g45g
  mtd: spi-nor: macronix: Add post_sfdp fixups for Quad Input Page Program
  mtd: Fix error handling in mtd_device_parse_register() error path
  mtd: capture device name setting failure when adding mtd
  mtd: Add check for devm_kcalloc()
  mtd: Replace kcalloc() with devm_kcalloc()
  dt-bindings: mtd: physmap: Ensure all properties are defined
  mtd: rawnand: brcmnand: fix PM resume warning
  dt-bindings: mtd: mxc-nand: Document fsl,imx31-nand
  mtd: spinand: macronix: Add support for read retry
  ...
2025-03-26 10:28:36 -07:00
Miquel Raynal
ca8cbbb2be mtd: nand: Fix a kdoc comment
The max_bad_eraseblocks_per_lun member of nand_device obviously
describes a number of *maximum* number of bad eraseblocks per LUN.

Fix this obvious typo.

Fixes: 377e517b5f ("mtd: nand: Add max_bad_eraseblocks_per_lun info to memorg")
Cc: <stable+noautosel@kernel.org> # fix kdoc comment
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-03-18 17:15:39 +01:00
Miquel Raynal
b28f47ac3d mtd: spinand: Improve spinand_info macros style
Let's assume all these macros should not have a trailing comma, this way
the caller can use a more formal and usual C writing style, as reflected
in the Macronix driver.

Acked-by: Pratyush Yadav <pratyush@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-03-18 16:56:02 +01:00
Cheng Ming Lin
f2cb43c980 mtd: spinand: Add read retry support
When the host ECC fails to correct the data error of NAND device,
there's a special read for data recovery method which can be setup
by the host for the next read. There are several retry levels that
can be attempted until the lost data is recovered or definitely
assumed lost.

Signed-off-by: Cheng Ming Lin <chengminglin@mxic.com.tw>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-03-04 12:02:11 +01:00
Md Sadre Alam
7304d19090
spi: spi-qpic: add driver for QCOM SPI NAND flash Interface
This driver implements support for the SPI-NAND mode of QCOM NAND Flash
Interface as a SPI-MEM controller with pipelined ECC capability.

Co-developed-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Co-developed-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Link: https://patch.msgid.link/20250224111414.2809669-3-quic_mdalam@quicinc.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-03-03 13:00:21 +00:00
Christian Marangi
1db50b96b0 mtd: rawnand: qcom: finish converting register to FIELD_PREP
With some research in some obscure old QSDK, it was possible to find the
MASK of the last register there were still set with raw shift and
convert them to FIELD_PREP API.

This is only a cleanup and modernize the code a bit and doesn't make
any behaviour change.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-02-11 13:55:15 +01:00
Martin Kurbanov
9ad2857c82 mtd: spinand: otp: add helpers functions
The global functions spinand_otp_read() and spinand_otp_write() have
been introduced. Since most SPI-NAND flashes read/write OTP in the same
way, let's define global functions to avoid code duplication.

Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-02-10 15:52:59 +01:00
Martin Kurbanov
e278b8c73b mtd: spinand: make spinand_{wait,otp_page_size} global
Change the functions spinand_wait() and spinand_otp_page_size() from
static to global so that SPI NAND flash drivers don't duplicate it.

Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-02-10 15:52:59 +01:00
Martin Kurbanov
c06b1f753b mtd: spinand: add OTP support
The MTD subsystem already supports accessing two OTP areas: user and
factory. User areas can be written by the user.

This patch provides the SPINAND_FACT_OTP_INFO and SPINAND_USER_OTP_INFO
macros to add parameters to spinand_info.
To implement OTP operations, the client (flash driver) is provided with
callbacks for user area:
    .read(), .write(), .info(), .lock(), .erase();
and for factory area:
    .read(), .info();

Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-02-10 15:52:59 +01:00
Martin Kurbanov
07d0aa9393 mtd: spinand: make spinand_{read,write}_page global
Change these functions from static to global so that to use them later
in OTP operations. Since reading OTP pages is no different from reading
pages from the main area.

Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-02-10 15:52:59 +01:00
Miquel Raynal
8586bc8d95 mtd: spinand: Add support for read DTR operations
Advanced SPI-NAND chips are capable of reading data much faster by
leveraging DTR support. This support extends to dual and quad
configurations.

Create macros defining all possible read from cache DTR variants:
- SPINAND_PAGE_READ_FROM_CACHE_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_X2_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_X4_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_DUALIO_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_QUADIO_DTR_OP

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-01-15 19:24:03 +01:00
Miquel Raynal
7ce0d16d58 mtd: spinand: Add an optional frequency to read from cache macros
While the SPINAND_PAGE_READ_FROM_CACHE_FAST_OP macro is supposed to be
able to run at the flash highest supported frequency, it is not the case
of the regular read from cache, which may be limited in terms of maximum
frequency. Add an optional argument to this macro, which will be used to
set the maximum frequency, if any.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-01-15 19:23:47 +01:00
Miquel Raynal
0420872478 mtd: spinand: Create distinct fast and slow read from cache variants
So far, the SPINAND_PAGE_READ_FROM_CACHE_OP macro was taking a first
argument, "fast", which was inducing the possibility to support higher
bus frequencies than with the normal (slower) read from cache
alternative. In practice, without frequency change on the bus, this was
likely without effect, besides perhaps allowing another variant of the
same command, that could run at the default highest speed. If we want to
support this fully, we need to add a frequency parameter to the slowest
command. But before we do that, let's drop the "fast" boolean from the
macro and duplicate it, this will further help supporting having
different frequencies allowed for each variant.

The change is also of course propagated to all users. It has the nice
effect to have all macros aligned on the same pattern.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-01-15 19:23:28 +01:00
Md Sadre Alam
b937186679 mtd: rawnand: qcom: Fix build issue on x86 architecture
Fix a buffer overflow issue in qcom_clear_bam_transaction by using
struct_group to group related fields and avoid FORTIFY_SOURCE warnings.

On x86 architecture, the following error occurs due to warnings being
treated as errors:

In function ‘fortify_memset_chk’,
    inlined from ‘qcom_clear_bam_transaction’ at
drivers/mtd/nand/qpic_common.c:88:2:
./include/linux/fortify-string.h:480:25: error: call to ‘__write_overflow_field’
declared with attribute warning: detected write beyond size of field
(1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
  480 |                         __write_overflow_field(p_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  LD [M]  drivers/mtd/nand/nandcore.o
  CC [M]  drivers/w1/masters/mxc_w1.o
cc1: all warnings being treated as errors

This patch addresses the issue by grouping the related fields in
struct bam_transaction using struct_group and updating the memset call
accordingly.

Fixes: 8c52932da5 ("mtd: rawnand: qcom: cleanup qcom_nandc driver")
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-01-08 19:26:39 +01:00
Miquel Raynal
8d3cd6b875 Topic branch with preparation changes from Qcom in order to apply on top
the spi bits adding the Qcom SPI-NAND controller driver re-using a lot
 of code that has been shared.
 
 With this goal in mind, the raw NAND controller driver has been cleaned
 up and reorganized, and only the relevant structures/helpers which have
 nothing raw NAND specific should now be exported.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE9HuaYnbmDhq/XIDIJWrqGEe9VoQFAmdq0moACgkQJWrqGEe9
 VoS3cwgAh+aISqETMIQbG8/i2LzbBjzCAEDKC1nwnk2buwlvJC8omUDF6xpBe1AL
 grN3j5ltmlDj834+S8UI9/9QFYExrKp3SlDzzbvdpDNgGsgFT56B2Mq0eZfju2b0
 BXUuMUllKZGR6bm1ddKwEvFtgqulJdBiTOD28PIDsW1+ZgpFPLN7wYzyAme3s6Aw
 xwqwthUWt7J3zXTMRxBAqwBG63Xkb30AiF0q7EYNzjZ6455c/XIJcTSmDTI9/Wx1
 O2oBbG7EpbXlMISosiDkbBrfCseDduGpZLeCE7pMDkWpsdFJbV5qeM4z3UJvQ9vu
 rLRMtSEhJ6tJF/dRn+YlqlIz72uKsQ==
 =BqI2
 -----END PGP SIGNATURE-----

Merge tag 'mtd/qcom-reorg-for-spi-6.14' into nand/next

Topic branch with preparation changes from Qcom in order to apply on top
the spi bits adding the Qcom SPI-NAND controller driver re-using a lot
of code that has been shared.

With this goal in mind, the raw NAND controller driver has been cleaned
up and reorganized, and only the relevant structures/helpers which have
nothing raw NAND specific should now be exported.
2024-12-24 16:44:01 +01:00
Md Sadre Alam
0c08080fd7 mtd: rawnand: qcom: use FIELD_PREP and GENMASK
Use the bitfield macro FIELD_PREP, and GENMASK to
do the shift and mask in one go. This makes the code
more readable.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2024-12-24 16:22:02 +01:00