Skip to contentSkip to conversation

spi: orion.c: Add direct access mode

PATCH Superseded Stefan Roese 4 participants 9 messages Apr 20, 2016 – Jun 16, 2016

Subsystems (2)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

This patch adds support for the direct write 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.

Currently only the direct write mode is supported. 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, that are also written in the direct read mode.

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.

It should be possible to support SPI-NOR and SPI-NAND devices via this direct access mode as well. But this needs further work, e.g.:
- The mapping of the MBus window needs to get extended to span the complete flash device size
- The address / control data needs to get inserted into the SPI controller registers

Cc Thomas Petazzoni <[email protected]>
Cc Gregory CLEMENT <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Brown <[email protected]>

---
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                            | 79 ++++++++++++++++++++++
 2 files changed, 127 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/spi/spi-orion.txt +48 -1
index 98bc698..4f629cc 100644
@@ -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 +79 -0

130 lines not on this page · raw message

Signature · 1 line
2.8.1
#1 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

Hi Stefan,

Quoted 19 lines · Stefan Roese

This patch adds support for the direct write 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.

Currently only the direct write mode is supported. 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, that are also written in the direct read mode.

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.

Quoted 6 lines

It should be possible to support SPI-NOR and SPI-NAND devices via this direct access mode as well. But this needs further work, e.g.:
- The mapping of the MBus window needs to get extended to span the complete flash device size
- The address / control data needs to get inserted into the SPI controller registers

This patch looks really nice. And, from my point of view, especially because I don't see how it could introduce a regression for the existing boards :)

[...]

Quoted 35 lines
Documentation/devicetree/bindings/spi/spi-orion.txt +19 -1
index 98bc698..4f629cc 100644
@@ -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 */

Documentation/devicetree/bindings/spi/spi-orion.txt Example: · line 53

Quoted 10 lines
Documentation/devicetree/bindings/spi/spi-orion.txt +10 -0
+		      <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";
+	};
+

As you don't submit any patch for the dtsi, I assume that you expect that this part will be done at board level. In this case as I wrote above we are sure that all the board continue working without any need to test them.

[...]

Quoted 47 lines
drivers/spi/spi-orion.c +13 -0
index a87cfd4..3e20afd 100644
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/clk.h>
 #include <linux/sizes.h>
@@ -43,6 +44,9 @@
 #define ORION_SPI_INT_CAUSE_REG		0x10
 #define ORION_SPI_TIMING_PARAMS_REG	0x18
 
+/* Register for the "Direct Mode" */
+#define SPI_DIRECT_WRITE_CONFIG_REG	0x20
+
 #define ORION_SPI_TMISO_SAMPLE_MASK	(0x3 << 6)
 #define ORION_SPI_TMISO_SAMPLE_1	(1 << 6)
 #define ORION_SPI_TMISO_SAMPLE_2	(2 << 6)
@@ -78,11 +82,18 @@ struct orion_spi_dev {
 	bool			is_errata_50mhz_ac;
 };
 
+struct orion_direct_acc {
+	void __iomem		*vaddr;
+	u32			size;
+};
+
 struct orion_spi {
 	struct spi_master	*master;
 	void __iomem		*base;
 	struct clk              *clk;
 	const struct orion_spi_dev *devdata;
+
+	struct orion_direct_acc	direct_access[ORION_NUM_CHIPSELECTS];
 };
 
 static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg)
@@ -372,10 +383,30 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
 {
 	unsigned int count;
 	int word_len;
+	struct orion_spi *orion_spi;
+	int cs = spi->chip_select;

drivers/spi/spi-orion.c orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) · line 397

Quoted 10 lines
drivers/spi/spi-orion.c +6 -0
 
 	word_len = spi->bits_per_word;
 	count = xfer->len;
 
+	orion_spi = spi_master_get_devdata(spi->master);
+
+	/*
+	 * Use SPI direct write mode if base address is available. Otherwise
+	 * fall back to PIO mode for this transfer.
+	 */

That means that once the direct write mode is set in the device tree you can't go back to the PIO mode. So, if I understand well, once you have programmed a FPGA bitstream image into the FPGA you won't use this SPI for a more standard communication. However, I don't know how to switch from a mode to another in an elegant way (without adding an ioctl command).

Quoted 5 lines
drivers/spi/spi-orion.c +5 -0
+	if ((orion_spi->direct_access[cs].vaddr) && (xfer->tx_buf) &&
+	    (word_len == 8)) {
+		/*
+		 * Send the TX-data to the SPI device via the direct
+		 * mapped address window

drivers/spi/spi-orion.c orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) · line 412

Quoted 10 lines
drivers/spi/spi-orion.c +7 -0
+		 */
+		writesl(orion_spi->direct_access[cs].vaddr, xfer->tx_buf,
+			DIV_ROUND_UP(count, 4));
+
+		return count;
+	}
+
 	if (word_len == 8) {
 		const u8 *tx = xfer->tx_buf;
 		u8 *rx = xfer->rx_buf;

Gregory

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

Hi Gregory,

Quoted 76 lines · Gregory CLEMENT
Quoted 19 lines · Stefan Roese

This patch adds support for the direct write 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.

Currently only the direct write mode is supported. 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, that are also written in the direct read mode.

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.

Quoted 6 lines

It should be possible to support SPI-NOR and SPI-NAND devices via this direct access mode as well. But this needs further work, e.g.:
- The mapping of the MBus window needs to get extended to span the complete flash device size
- The address / control data needs to get inserted into the SPI controller registers

This patch looks really nice. And, from my point of view, especially because I don't see how it could introduce a regression for the existing boards :)

[...]

Quoted 42 lines
Documentation/devicetree/bindings/spi/spi-orion.txt +26 -1
index 98bc698..4f629cc 100644
@@ -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>;
Quoted 8 lines

Documentation/devicetree/bindings/spi/spi-orion.txt Example: · line 53

Quoted 3 lines
Documentation/devicetree/bindings/spi/spi-orion.txt +3 -0
+		status = "disabled";
+	};
+

As you don't submit any patch for the dtsi, I assume that you expect that this part will be done at board level. In this case as I wrote above we are sure that all the board continue working without any need to test them.

No, this won't work without any changes to the Armada dtsi / dts files. As the SPI controller node needs to get moved for this 'reg' property to work (suggestion from Arnd).

I've submitted 2 patches for the dtsi / dts files a short while ago:

http://www.spinics.net/lists/arm-kernel/msg495524.html
http://www.spinics.net/lists/arm-kernel/msg495523.html

When this SPI driver patch gets accepted, I'll send an updated patchset for the dtsi / dts files.

Quoted 52 lines

[...]

Quoted 51 lines
drivers/spi/spi-orion.c +13 -0
index a87cfd4..3e20afd 100644
@@ -18,6 +18,7 @@
  #include <linux/module.h>
  #include <linux/pm_runtime.h>
  #include <linux/of.h>
+#include <linux/of_address.h>
  #include <linux/of_device.h>
  #include <linux/clk.h>
  #include <linux/sizes.h>
@@ -43,6 +44,9 @@
  #define ORION_SPI_INT_CAUSE_REG		0x10
  #define ORION_SPI_TIMING_PARAMS_REG	0x18
 
+/* Register for the "Direct Mode" */
+#define SPI_DIRECT_WRITE_CONFIG_REG	0x20
+
  #define ORION_SPI_TMISO_SAMPLE_MASK	(0x3 << 6)
  #define ORION_SPI_TMISO_SAMPLE_1	(1 << 6)
  #define ORION_SPI_TMISO_SAMPLE_2	(2 << 6)
@@ -78,11 +82,18 @@ struct orion_spi_dev {
  	bool			is_errata_50mhz_ac;
  };
 
+struct orion_direct_acc {
+	void __iomem		*vaddr;
+	u32			size;
+};
+
  struct orion_spi {
  	struct spi_master	*master;
  	void __iomem		*base;
  	struct clk              *clk;
  	const struct orion_spi_dev *devdata;
+
+	struct orion_direct_acc	direct_access[ORION_NUM_CHIPSELECTS];
  };
 
  static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg)
@@ -372,10 +383,30 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
  {
  	unsigned int count;
  	int word_len;
+	struct orion_spi *orion_spi;
+	int cs = spi->chip_select;
 
  	word_len = spi->bits_per_word;
  	count = xfer->len;
 
Quoted 11 lines

drivers/spi/spi-orion.c orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) · line 397

Quoted 6 lines
drivers/spi/spi-orion.c +6 -0
+	orion_spi = spi_master_get_devdata(spi->master);
+
+	/*
+	 * Use SPI direct write mode if base address is available. Otherwise
+	 * fall back to PIO mode for this transfer.
+	 */

That means that once the direct write mode is set in the device tree you can't go back to the PIO mode. So, if I understand well, once you have programmed a FPGA bitstream image into the FPGA you won't use this SPI for a more standard communication.

Correct. We're using this SPI bus on this "SPI device" for FPGA programming only. This can be done multiple times though. Currently there is no way to switch operation modes at runtime. I'm not sure if this is really needed. Either a device supports this mode or it doesn't.

Quoted 3 lines

However, I don't know how to switch
from a mode to another in an elegant way (without adding an ioctl command).

Yes. Please see above, as I don't know if this is really needed in practice.

Thanks,
Stefan

#3 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

Hi Stefan,

Quoted 9 lines · Stefan Roese
Quoted 4 lines

As you don't submit any patch for the dtsi, I assume that you expect that this part will be done at board level. In this case as I wrote above we are sure that all the board continue working without any need to test them.

No, this won't work without any changes to the Armada dtsi / dts files. As the SPI controller node needs to get moved for this 'reg' property to work (suggestion from Arnd).

Quoted 8 lines

I've submitted 2 patches for the dtsi / dts files a short while ago:

http://www.spinics.net/lists/arm-kernel/msg495524.html
http://www.spinics.net/lists/arm-kernel/msg495523.html

When this SPI driver patch gets accepted, I'll send an updated patchset for the dtsi / dts files.

Unless I am wrong the SPI driver patch got accepted, but I didn't see an updated patchset for the dtsi / dts files. Did I miss it?

Else would you ming to send them? Then I will be able to apply them on the mvebu tree.

Thanks,

Gregory

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

Hi Gregory,

Quoted 15 lines · Gregory CLEMENT
Quoted 12 lines · Stefan Roese
Quoted 4 lines

As you don't submit any patch for the dtsi, I assume that you expect that this part will be done at board level. In this case as I wrote above we are sure that all the board continue working without any need to test them.

No, this won't work without any changes to the Armada dtsi / dts files. As the SPI controller node needs to get moved for this 'reg' property to work (suggestion from Arnd).

I've submitted 2 patches for the dtsi / dts files a short while ago:

Quoted 7 lines
Quoted 5 lines

http://www.spinics.net/lists/arm-kernel/msg495524.html
http://www.spinics.net/lists/arm-kernel/msg495523.html

When this SPI driver patch gets accepted, I'll send an updated patchset for the dtsi / dts files.

Unless I am wrong the SPI driver patch got accepted,

Correct. Its in linux-next now.

Quoted 2 lines

but I didn't see an
updated patchset for the dtsi / dts files. Did I miss it?

No, you didn't miss it.

Quoted 2 lines

Else would you ming to send them? Then I will be able to apply them on the mvebu tree.

Its on my list. Thanks for reminding me. I'll get to working on this next week and will send an updated patch series then.

Thanks,
Stefan

#5 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

In reply to Stefan Roese
Quoted 26 lines · Stefan Roese

This patch adds support for the direct write 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.

Currently only the direct write mode is supported. 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, that are also written in the direct read mode.

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.

It should be possible to support SPI-NOR and SPI-NAND devices via this direct access mode as well. But this needs further work, e.g.:
- The mapping of the MBus window needs to get extended to span the complete flash device size
- The address / control data needs to get inserted into the SPI controller registers

Quoted 6 lines
Cc Thomas Petazzoni <[email protected]>
Cc Gregory CLEMENT <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Brown <[email protected]>

Its been a while since v6 of this direct write access mode has been posted. This is a gentle ping on its status.

Arnd / Mark, do you have any additional change requests or are you okay with the current version?

Thanks,
Stefan

#6 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

Quoted 34 lines · On Monday 02 May 2016 08:47:15 Stefan Roese wrote:
Quoted 26 lines · Stefan Roese

This patch adds support for the direct write 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.

Currently only the direct write mode is supported. 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, that are also written in the direct read mode.

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.

It should be possible to support SPI-NOR and SPI-NAND devices via this direct access mode as well. But this needs further work, e.g.:
- The mapping of the MBus window needs to get extended to span the complete flash device size
- The address / control data needs to get inserted into the SPI controller registers

Quoted 6 lines
Cc Thomas Petazzoni <[email protected]>
Cc Gregory CLEMENT <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Brown <[email protected]>
Quoted 5 lines

Its been a while since v6 of this direct write access mode has been posted. This is a gentle ping on its status.

Arnd / Mark, do you have any additional change requests or are you okay with the current version?

No objections, please add

Two questions though:

- you now always send a multiple of four byte in each transfer, are there any downsides in doing this, e.g. some SPI devices that might get confused by receiving additional uninitialized data?

- How does the performance compare to the normal mode, is it basically unchanged, or does this patch make things faster?

Arnd

#7 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

Hi Arnd,

Quoted 38 lines · Arnd Bergmann
Quoted 37 lines · On Monday 02 May 2016 08:47:15 Stefan Roese wrote:
Quoted 26 lines · Stefan Roese

This patch adds support for the direct write 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.

Currently only the direct write mode is supported. 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, that are also written in the direct read mode.

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.

It should be possible to support SPI-NOR and SPI-NAND devices via this direct access mode as well. But this needs further work, e.g.:
- The mapping of the MBus window needs to get extended to span the complete flash device size
- The address / control data needs to get inserted into the SPI controller registers

Quoted 6 lines
Cc Thomas Petazzoni <[email protected]>
Cc Gregory CLEMENT <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Brown <[email protected]>

Its been a while since v6 of this direct write access mode has been posted. This is a gentle ping on its status.

Quoted 6 lines
Quoted 2 lines

Arnd / Mark, do you have any additional change requests or are you okay with the current version?

No objections, please add

Thanks.

Quoted 5 lines

Two questions though:

- you now always send a multiple of four byte in each transfer, are there any downsides in doing this, e.g. some SPI devices that might get confused by receiving additional uninitialized data?

Yes, this is something that might happen on such devices. AFAIK, my device (Altera FPGA) has no such restriction though. IIRC, the size of the bitfiles is always 4-byte aligned.

I'll try to send v7 of this patch with a fully byte-size correct handling later today.

Quoted 2 lines

- How does the performance compare to the normal mode, is it basically unchanged, or does this patch make things faster?

The performance is increased. The factor of course depends on the SPI transfer speed. Here the numbers for a ~70KiB image transferred at 27MHz SPI speed:

Using the PIO SPI transfer:

real    0m0.128s
user    0m0.010s
sys     0m0.120s

Using the direct write mode:

real    0m0.040s
user    0m0.000s
sys     0m0.020s

Thanks,
Stefan

maintainer
#8 lore raw

PATCH v6 1/1 spi: orion.c: Add direct access mode

In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · On Monday 02 May 2016 08:47:15 Stefan Roese wrote:

Its been a while since v6 of this direct write access mode has been posted. This is a gentle ping on its status.

Arnd / Mark, do you have any additional change requests or are you okay with the current version?

Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed. Sending content free pings just adds to the mail volume (if they are seen at all) and if something has gone wrong you'll have to resend the patches anyway.

Quoted 3 lines

- you now always send a multiple of four byte in each transfer, are there any downsides in doing this, e.g. some SPI devices that might get confused by receiving additional uninitialized data?

Yes, this will break a large proportion of devices.
-------------- 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/b84af846/attachment.sig>