Commit Graph

10 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Md Sadre Alam
fdf3ee5c6e mtd: nand: Add qpic_common API file
Add qpic_common.c file which hold all the common
qpic APIs which will be used by both qpic raw nand
driver and qpic spi nand driver.

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