This series adds a UCLASS_SPI_EEPROM uclass, a driver for AT25-style
parts, a sandbox emulator and a DM test.

v6 is a resend that fixes two problems with v5, and makes no other
functional change.

Tom reported that v5 broke the sandbox_vpl CI job. Patch 3 added the
sandbox SPI EEPROM emulator to drivers/misc/Makefile with
obj-$(CONFIG_SANDBOX), which is not phase-aware, so the emulator was
also linked into TPL, VPL and SPL. With it in the image, sandbox_vpl
stops right after "Trying to boot from sandbox_file", and the CI log
shows nothing useful. The emulator now sits in the existing
"ifndef CONFIG_XPL_BUILD" block next to the other sandbox emulators,
as i2c_eeprom_emul.o does. The "vpl or test_spl" test.py selection
used by the sandbox_vpl CI job fails 12 tests with v5 applied on
v2026.10-rc5 and passes all 12 with v6.

Simon pointed out that v5 was threaded wrongly on patchwork. I had
sent it with --in-reply-to pointing at the v4 cover letter, so the
patches ended up in the old thread. v6 is a fresh thread with all
three patches replying to this cover letter.

Testing on sandbox: "ut dm" gives the same set of failures as
unpatched v2026.10-rc5 here (all environment/fixture related), and the
new spi_eeprom test passes along with spi_flash. The sandbox_vpl
test.py selection passes, as above.

Changes in v6:
- Patch 3: build the sandbox SPI EEPROM emulator only in U-Boot
  proper (not in TPL/VPL/SPL), fixing the sandbox_vpl CI failure.
- Resent as a new, correctly threaded series.

Changes in v5:
- New patch 1: test/dm/sf.c now asks for the emulator attached to its
  own slave rather than the first one in UCLASS_SPI_EMUL, fixing a
  heap corruption once a second SPI emulator exists.
- Patch 2 commit message reworded: imperative mood, "driver model"
  rather than "driver mode", and it now explains the motivation.
- SPI_EEPROM_CMD_SIZE removed. Address length is an addr_len field in
  driver data, overridable from the device tree, so 8-, 16- and 24-bit
  addressed parts are handled.
- AT25_CMD_* opcodes moved to a private header,
  drivers/misc/spi_eeprom_priv.h.
- Read path no longer computes "offset + size"; probe() rejects a
  "size" that does not fit the configured address width.
- of_to_plat() dropped; geometry read in probe().
- "size", "pagesize" and "address-width" follow the in-tree atmel,at25
  binding (dts/upstream/Bindings/eeprom/at25.yaml).
- Compatible list taken from that binding, plus the "atmel,at25"
  fallback.
- Kconfig: "depends on MISC" dropped, help text expanded.
- include/spi_eeprom.h converted to kerneldoc.
- Sandbox EEPROM node in test.dts follows the binding.

Changes in v4:
- Emulator frees its backing store in a remove() method.
- Full kerneldoc for sandbox_spi_emul_get().

Changes in v3:
- Reindented with tabs; the series is now checkpatch-clean.
- Dropped the no-op write stub in favour of returning -ENOSYS.
- Removed dead code, fixed the read bounds check, corrected the
  AT25160 geometry, switched to u8 types and added a MAINTAINERS entry.
- Added the sandbox emulator and the DM test.

João Loureiro (3):
  test: dm: sf: Get the emulator attached to the flash slave
  spi: Introduce initial driver-model support for SPI EEPROMs
  sandbox: spi: Add SPI EEPROM emulator and DM test

 MAINTAINERS                    |   9 ++
 arch/sandbox/dts/test.dts      |  16 +-
 configs/sandbox_defconfig      |   1 +
 drivers/misc/Kconfig           |  15 ++
 drivers/misc/Makefile          |   2 +
 drivers/misc/spi_eeprom.c      | 267 +++++++++++++++++++++++++++++++++
 drivers/misc/spi_eeprom_emul.c | 130 ++++++++++++++++
 drivers/misc/spi_eeprom_priv.h |  18 +++
 drivers/spi/sandbox_spi.c      |  37 ++++-
 include/dm/uclass-id.h         |   1 +
 include/spi_eeprom.h           |  95 ++++++++++++
 test/dm/Makefile               |   1 +
 test/dm/sf.c                   |   9 +-
 test/dm/spi_eeprom.c           |  46 ++++++
 14 files changed, 643 insertions(+), 4 deletions(-)
 create mode 100644 drivers/misc/spi_eeprom.c
 create mode 100644 drivers/misc/spi_eeprom_emul.c
 create mode 100644 drivers/misc/spi_eeprom_priv.h
 create mode 100644 include/spi_eeprom.h
 create mode 100644 test/dm/spi_eeprom.c


base-commit: a06e89ab05eaa2b8344d521319399333cd760ae5
-- 
2.43.0

Reply via email to