[PATCH v9 0/4] Add Cortina Systems CS7542 NAND controller support
From: Fil Dunsky via B4 Relay
Date: Sun Dec 06 2026 - 09:27:41 EST
Add a programmed-I/O driver for the Cortina CS7542 NAND controller.
The controller accepts complete command, address and data phases. Use
the NAND core operation parser to validate and issue those phases.
The binding describes both chip selects, both bus widths and the
Hamming and BCH engines. The driver supports one 8-bit target,
on-host Hamming with the existing Almond+ layout, software ECC and
raw data. It initializes the reset and NAND timing at probe.
On Almond+, the reviewed driver identified the 512 MiB Spansion
S34ML04G1 and read matching U-Boot and kernel samples from RAM. It
returned to the installed OpenWrt with all partitions read-only.
I tested the v9 driver from a Linux 6.18 RAM kernel on Almond+ with
one isolated spare eraseblock writable per run. Hardware Hamming,
software Hamming in SmartMedia order, and ECC_NONE each passed page
writes and reads, erase verification, auto OOB and raw data/OOB. Both
Hamming modes corrected a single changed bit. ECC_NONE returned the
changed byte without correction.
Each test restored the original erase-counter header and verified that
the remaining pages were erased. The hardware Hamming run returned
to the installed OpenWrt. The software Hamming and ECC_NONE runs
returned automatically to the original USB Debian, where the full
raw eraseblock hashes, including OOB, matched the pre-test reads.
---
Changes in v9:
- Keep the shared flash interface out of reset without pulsing it.
Validate the chip-select child first and reset the local NAND FSM.
- Reset the local FSM on controller and Hamming timeouts. Avoid
advertising panic writes, relax sleepable poll intervals and keep
both bounded PIO deadlines.
- Handle target-less checks without advertising unsupported cache reads.
- Restrict NAND children to the two chip selects and omit the
deprecated ECC-mode property from the binding example.
- Link to v8: https://patch.msgid.link/20261204-b4-cs7542-nand-v8-0-bb068644f71f@xxxxxxxxx
Changes in v8:
- Use the NAND operation parser and transfer data directly to and from
the caller's buffers.
- Reject unsupported transfers before programming the controller.
- Reset the controller and program its default asynchronous timing.
- Keep controller-supplied raw page callbacks in the NAND core for
ECC_NONE. Disable on-host ECC for software ECC and NONE. Keep the geometry
checks and the full-page write constraint local to on-host Hamming.
- Use the standard MTD name and remove informational probe messages.
- Link to v7: https://patch.msgid.link/20261202-b4-cs7542-nand-v7-0-81d3ed341c77@xxxxxxxxx
Changes in v7:
- Keep the 100 ms PIO transfer budget independent of NAND WAITRDY.
- Use time-based tight polling for generic PIO completion.
- Reproduce the v6 regression and check full parameter and page reads,
readiness errors and a stuck request in mocked MMIO; compile the
affected ARM object for Linux and OpenWrt.
- Share the 100 ms transfer budget across Hamming page data and OOB.
Keep separate ECC and ready/busy waits, and the per-word stall limit.
- Treat a cleared request bit on the final word as completion. Cover
expiry at the boundary, a delayed observation of completion and a
final request still pending at the deadline in the MMIO model.
- Before the final-word change, the driver in an OpenWrt RAM kernel
on Almond+ matched ECC data and raw/generic OOB for 128 pages across all four
banks, with all MTD partitions read-only. The watchdog returned to
OpenWrt. The Hamming write and timeout faults were tested in MMIO
mocks with GCC and Clang.
- Link to v6: https://patch.msgid.link/20261201-b4-cs7542-nand-v6-0-e6b0d712745b@xxxxxxxxx
Changes in v6:
- Bound each PIO transfer with one deadline and preserve the cached
read position when rejecting a change-column request.
- Link to v5: https://patch.msgid.link/20261127-b4-cs7542-nand-v5-0-45b1a92bd13d@xxxxxxxxx
Changes in v5:
- Select the available NAND child, including CS1 when CS0 is disabled.
- Reject ECC_NONE; retain software ECC and monolithic raw transfers.
- Check the changed attach and probe paths with actual-source tests.
- Link to v4: https://patch.msgid.link/20261126-b4-cs7542-nand-v4-0-38e488f6f8b1@xxxxxxxxx
Changes in v4:
- Address Miquel Raynal's binding and driver review on v2.
- Describe controller capabilities rather than only the initial driver.
- Add the AXI clock, flash IRQ, optional reset and data aperture binding.
- Separate supports_op() and remove the NAND opcode whitelist.
- Use core page helpers for hardware ECC; allow software ECC/raw transfers.
- Support either chip select and reject multiple connected targets explicitly.
- Preserve bus timing through clock rate exclusivity; do not pulse flash reset.
- Clarify the vendor EXTADDR convention; retain the existing Hamming layout.
- Link to v3: https://patch.msgid.link/20261125-b4-cs7542-nand-v3-0-0b6d141c102e@xxxxxxxxx
To: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
To: Richard Weinberger <richard@xxxxxx>
To: Vignesh Raghavendra <vigneshr@xxxxxx>
To: Rob Herring <robh@xxxxxxxxxx>
To: Krzysztof Kozlowski <krzk+dt@xxxxxxxxxx>
To: Conor Dooley <conor+dt@xxxxxxxxxx>
To: Fil Dunsky <filipp.dunsky@xxxxxxxxx>
To: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Cc: linux-mtd@xxxxxxxxxxxxxxxxxxx
Cc: devicetree@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
Fil Dunsky (4):
mtd: rawnand: Honor controller raw page callbacks in ECC_NONE
dt-bindings: mtd: Add Cortina CS7542 NAND controller
mtd: rawnand: Add Cortina CS7542 controller support
MAINTAINERS: Add Cortina CS7542 NAND controller entry
.../bindings/mtd/cortina,cs7542-nand.yaml | 90 +++
MAINTAINERS | 7 +
drivers/mtd/nand/raw/Kconfig | 11 +
drivers/mtd/nand/raw/Makefile | 1 +
drivers/mtd/nand/raw/cs752x_nand.c | 766 +++++++++++++++++++++
drivers/mtd/nand/raw/nand_base.c | 10 +-
6 files changed, 881 insertions(+), 4 deletions(-)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261123-b4-cs7542-nand-87997e300079
Best regards,
--
Fil Dunsky <filipp.dunsky@xxxxxxxxx>