spi: orion.c: Add direct access mode
Subsystems (2)
PATCH v7 1/1 spi: orion.c: Add direct access mode
This patch adds support for the direct access mode to the Orion SPI driver which is used on the Marvell Armada based SoCs. In this direct mode, all data written to (or read from) a specifically mapped MBus window (linked to one SPI chip-select on one of the SPI controllers) will be transferred directly to the SPI bus. Without the need to control the SPI registers in between. This can improve the SPI transfer rate in such cases.
Both, direct-read and -write mode are supported. But only the write mode has been tested. This mode especially benefits from the SPI direct mode, as the data bytes are written head-to-head to the SPI bus, without any additional addresses.
One use-case for this direct write mode is, programming a FPGA bitstream image into the FPGA connected to the SPI bus at maximum speed.
This mode is described in chapter "22.5.2 Direct Write to SPI" in the Marvell Armada XP Functional Spec Datasheet.
---
v7:
- Changed tx function to only write the really intended number of bytes (drop DIV_ROUND_UP) as suggested by Arnd.
- Added Arnd's Acked-by
v6:
- Switched from memcpy() to writesl() for the TX transfer.
- Only one page is mapped via ioremap as this is sufficient for the currently implemented simple TX transfer.
- Removed max_transfer_size() as its not needed with the current one page mapping that supports an unlimited amount of SPI data.
- Added a comment to the 'reg' description in the DT bindings documentation as suggested by Arnd.
- Changed 'reg' and 'ranges' to use '<' and '>' in this file.
- Changed size to 0xffffffff in this file.
- Added a small paragraph to the commit text, describing the possibility to support SPI-NOR & SPI-NAND devices via this direct access mode.
v5:
- Added some documentation for the direct mode to the orion-spi DT bindings document, including an example and a reference to the mbus DT bindings documentation.
v4:
- Add max_transfer_size()
- Fall back from direct-write mode to PIO mode when
- transfer size is exceedeed
- non-8bit transfers
- Restrict to direct-write mode for now. SPI direct read mode can be added later, when someone has a platform supporting this mode.
v3:
- Used static MBus windows again, as suggested by Arnd
- No new DT bindings needed for this. The MBus windows need to be configured in the 'reg' property of the SPI controller. This is done in a separate patch for the Armada platforms.
- The direct mapping is configured and enable by adding the specific MBus entry to the 'ranges' property of the 'soc' node in the board dts file.
v2:
- Use one MBus window for each SPI controller instead of one for for each SPI device. This MBus window is re-assigned, once the CS changes.
- Assert the CS over the entire message
- Don't restrict the direct access mode to only direct write mode
- Add check for max size before using memcpy()
- Remove spidev from DT bindings documentation
.../devicetree/bindings/spi/spi-orion.txt | 49 +++++++++++- drivers/spi/spi-orion.c | 87 ++++++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/spi/spi-orion.txt +48 -1
@@ -8,7 +8,15 @@ Required properties: - "marvell,armada-380-spi", for the Armada 38x SoCs - "marvell,armada-390-spi", for the Armada 39x SoCs - "marvell,armada-xp-spi", for the Armada XP SoCs -- reg : offset and length of the register set for the device +- reg : offset and length of the register set for the device. + This property can optionally have additional entries to configure + the SPI direct access mode that some of the Marvell SoCs support + additionally to the normal indirect access (PIO) mode. The values + for the MBus "target" and "attribute" are defined in the Marvell + SoC "Functional Specifications" Manual in the chapter "Marvell + Core Processor Address Decoding". + The eight register sets following the control registers refer to + chip-select lines 0 through 7 respectively. - cell-index : Which of multiple SPI controllers is this. Optional properties: - interrupts : Is currently not used.
@@ -23,3 +31,42 @@ Example: interrupts = <23>; status = "disabled"; }; + +Example with SPI direct mode support (optionally): + spi0: spi at 10600 { + compatible = "marvell,orion-spi"; + #address-cells = <1>; + #size-cells = <0>; + cell-index = <0>; + reg = <MBUS_ID(0xf0, 0x01) 0x10600 0x28>, /* control */ + <MBUS_ID(0x01, 0x1e) 0 0xffffffff>, /* CS0 */ + <MBUS_ID(0x01, 0x5e) 0 0xffffffff>, /* CS1 */ + <MBUS_ID(0x01, 0x9e) 0 0xffffffff>, /* CS2 */ + <MBUS_ID(0x01, 0xde) 0 0xffffffff>, /* CS3 */ + <MBUS_ID(0x01, 0x1f) 0 0xffffffff>, /* CS4 */ + <MBUS_ID(0x01, 0x5f) 0 0xffffffff>, /* CS5 */ + <MBUS_ID(0x01, 0x9f) 0 0xffffffff>, /* CS6 */ + <MBUS_ID(0x01, 0xdf) 0 0xffffffff>; /* CS7 */ + interrupts = <23>; + status = "disabled"; + }; + +To enable the direct mode, the board specific 'ranges' property in the +'soc' node needs to add the entries for the desired SPI controllers +and its chip-selects that are used in the direct mode instead of PIO +mode. Here an example for this (SPI controller 0, device 1 and SPI +controller 1, device 2 are used in direct mode. All other SPI device +are used in the default indirect (PIO) mode): + soc { + /* + * Enable the SPI direct access by configuring an entry + * here in the board-specific ranges property + */ + ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000>, /* internal regs */ + <MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000>, /* BootROM */ + <MBUS_ID(0x01, 0x5e) 0 0 0xf1100000 0x10000>, /* SPI0-DEV1 */ + <MBUS_ID(0x01, 0x9a) 0 0 0xf1110000 0x10000>; /* SPI1-DEV2 */ + +For further information on the MBus bindings, please see the MBus +DT documentation: +Documentation/devicetree/bindings/bus/mvebu-mbus.txt
drivers/spi/spi-orion.c +87 -0
138 lines not on this page · raw message
Signature · 1 line
2.8.2
Mark Brown
maintainerPATCH v7 1/1 spi: orion.c: Add direct access mode
drivers/spi/spi-orion.c orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) · line 401
Quoted 4 lines · Stefan Roese
drivers/spi/spi-orion.c +4
-0+if ((orion_spi->direct_access[cs].vaddr) && (xfer->tx_buf) && + (word_len ==8 )) { +unsigned int cnt = count >>2 ; +unsigned int rem = count %4 ;
For the benefit of readers please write divisions as divisions and let
the compiler figure out if they can be turned into shifts.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160502/bf2b69b6/attachment.sig>