[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251002-spi-dw-target-v1-0-993e91c1a712@bootlin.com>
Date: Thu, 02 Oct 2025 14:14:36 +0200
From: Benoît Monin <benoit.monin@...tlin.com>
To: Mark Brown <broonie@...nel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Vladimir Kondratiev <vladimir.kondratiev@...ileye.com>,
Tawfik Bayouk <tawfik.bayouk@...ileye.com>, linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org,
Benoît Monin <benoit.monin@...tlin.com>
Subject: [PATCH RFC 0/2] Add target mode support for the DesignWare SPI
controller
The DesignWare SPI controller can act as a host or a target; the
choice between the two is set in hardware and cannot be changed by
software. When configured in target mode, the controller has a much
reduced set of capabilities. It only has a single chip-select input and
can only run standard SPI mode (no dual, quad, or octal mode). Despite
this, the overall logic of doing an SPI transfer and the register layout
is identical between both modes, so implementing the target mode reuses
much of the existing code.
The first part of this two-patch series renames the spi_controller to
ctlr instead of host and also changes the suffix of the related functions
to controller. This is done to avoid confusion when referring to the
controller in target mode.
The second patch implements the target mode support by allocating an
SPI controller of the correct type based on the spi-slave property. The
controller is then configured differently depending on the mode. For
an SPI transfer, the same transfer_one() callback is used, with the
difference being in dw_spi_update_config() where only the CTRLR0
register is set. The other registers are not relevant in target mode
and are read-only.
I am posting this as an RFC because I could only perform partial testing
on my setup. I am using an SoC with two DesignWare SPI memory-mapped
controllers identified as Synopsys DWC APB SSI v4.03, one in host mode and
the other in target mode. On the evaluation board, a microcontroller acts
as an SPI relay between the two, but it has some limitations. The number
of bits per word is fixed, as are the clock phase and polarity. It also
only copies data from the host to the target. With this limited setup,
I did test that data can be successfully transferred from the host
to the target using spidev_test. I also checked that polling works by
temporarily disabling the IRQ, but I cannot test DMA. Therefore, more
testing on different devices would be welcome.
Signed-off-by: Benoît Monin <benoit.monin@...tlin.com>
---
Benoît Monin (2):
spi: dw: rename the spi controller to ctlr
spi: dw: add target mode support
drivers/spi/spi-dw-bt1.c | 4 +-
drivers/spi/spi-dw-core.c | 188 +++++++++++++++++++++++++++-------------------
drivers/spi/spi-dw-dma.c | 22 +++---
drivers/spi/spi-dw-mmio.c | 9 +--
drivers/spi/spi-dw-pci.c | 8 +-
drivers/spi/spi-dw.h | 12 +--
6 files changed, 135 insertions(+), 108 deletions(-)
---
base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
change-id: 20250910-spi-dw-target-5b299400917b
Best regards,
--
Benoît Monin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists