Skip to contentSkip to conversation

spi: support for Socionext Synquacer platform

PATCH Superseded [email protected] 4 participants 10 messages Jan 9, 2018 – Jan 15, 2018 5 messages not in the archive

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover spi: support for Socionext Synquacer platform

From: Jassi Brar <[email protected]>

Hello,

Support for Socionext's FIP controller intended for flash device interfacing.
The controller can operate in 'direct' or 'command' mode. One mode directly talks and provide a read/write i/f to the flash device. Other works as plain SPI mode. This driver runs the controller as a SPI controller.

Jassi Brar (3):
dt-bindings: spi: Add DT bindings for Synquacer
spi: Add spi driver for Socionext Synquacer platform
MAINTAINERS: Add entry for Synquacer SPI driver

 .../devicetree/bindings/spi/spi-synquacer.txt      |  24 +
 MAINTAINERS                                        |   7 +
 drivers/spi/Kconfig                                |  11 +
 drivers/spi/Makefile                               |   1 +
 drivers/spi/spi-synquacer.c                        | 664 +++++++++++++++++++++
 5 files changed, 707 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-synquacer.txt
 create mode 100644 drivers/spi/spi-synquacer.c
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1515503383-8909-1-git-send-email-jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/3 dt-bindings: spi: Add DT bindings for Synquacer

From: Jassi Brar <[email protected]>

This patch adds documentation for Device-Tree bindings for the Socionext Synquacer spi driver.

---
 .../devicetree/bindings/spi/spi-synquacer.txt      | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-synquacer.txt
Documentation/devicetree/bindings/spi/spi-synquacer.txt new file +24 -0
new file mode 100644
index 0000000..d013cfd
@@ -0,0 +1,24 @@
+* Socionext Synquacer HS-SPI bindings
+
+Required Properties:
+- compatible: should be "socionext,synquacer-spi"
+- reg: physical base address of the controller and length of memory mapped
+       region.
+- clocks: Must contain an entry for rate source clock(s).
+- clock-names: Shall be "iHCLK" or "iPCLK". iHCLK is preferred over iPCLK
+
+Optional Properties:
+- num-cs: total number of chipselects
+- socionext,use-rtm: boolean, if required to use "retimed clock" for RX
+- socionext,set-aces: boolean, if same active clock edges field to be set.
+
+Example:
+
+	spi0: spi@ff110000 {
+		compatible = "socionext,synquacer-spi";
+		reg = <0xff110000 0x1000>;
+		clocks = <&clk_fip006_spi>;
+		clock-names = "iHCLK";
+		socionext,use-rtm;
+		socionext,set-aces;
+	};
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1515503432-8971-1-git-send-email-jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCHv1 1/3] dt-bindings: spi: Add DT bindings for Synquacer

Quoted 2 lines · On Tue, Jan 09, 2018 at 06:40:32PM +0530…
+- socionext,use-rtm: boolean, if required to use "retimed clock" for RX
+- socionext,set-aces: boolean, if same active clock edges field to be set.

What are these and why are they configurable? The active clock edges thing in particular sounds a little like it might be related to the SPI modes?

#5 lore raw

PATCH 2/3 spi: Add spi driver for Socionext Synquacer platform

In reply to a message not in the archive

From: Jassi Brar <[email protected]>

This patch adds support for controller found on synquacer platforms.

---
 drivers/spi/Kconfig         |  11 +
 drivers/spi/Makefile        |   1 +
 drivers/spi/spi-synquacer.c | 664 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 676 insertions(+)
 create mode 100644 drivers/spi/spi-synquacer.c
drivers/spi/Kconfig +11 -0
index 6037839..9e04bbe 100644
@@ -659,6 +659,17 @@ config SPI_SUN6I
 	help
 	  This enables using the SPI controller on the Allwinner A31 SoCs.
 
+config SPI_SYNQUACER
+	tristate "Socionext's Synquacer HighSpeed SPI controller"
+	depends on ARCH_SYNQUACER || COMPILE_TEST
+	select SPI_BITBANG
+	help
+	  SPI driver for Socionext's High speed SPI controller which provides
+	  various operating modes for interfacing to serial peripheral devices
+	  that use the de-facto standard SPI protocol.
+
+	  It also supports the new dual-bit and quad-bit SPI protocol.
+
 config SPI_MXS
 	tristate "Freescale MXS SPI controller"
 	depends on ARCH_MXS
drivers/spi/Makefile +1 -0
index 34c5f28..7c222f2 100644
@@ -96,6 +96,7 @@ obj-$(CONFIG_SPI_STM32) 		+= spi-stm32.o
 obj-$(CONFIG_SPI_ST_SSC4)		+= spi-st-ssc4.o
 obj-$(CONFIG_SPI_SUN4I)			+= spi-sun4i.o
 obj-$(CONFIG_SPI_SUN6I)			+= spi-sun6i.o
+obj-$(CONFIG_SPI_SYNQUACER)		+= spi-synquacer.o
 obj-$(CONFIG_SPI_TEGRA114)		+= spi-tegra114.o
 obj-$(CONFIG_SPI_TEGRA20_SFLASH)	+= spi-tegra20-sflash.o
 obj-$(CONFIG_SPI_TEGRA20_SLINK)		+= spi-tegra20-slink.o
drivers/spi/spi-synquacer.c new file +664 -0

664 lines not on this page · raw message

Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1515503448-9025-1-git-send-email-jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#7 lore raw

Re: [PATCHv1 2/3] spi: Add spi driver for Socionext Synquacer platform

On Tue, Jan 09, 2018 at 06:40:48PM +0530, [email protected] wrote:

This is basically fine, a couple of style things plus the question I had on the bindings:

drivers/spi/spi-synquacer.c line 3

Quoted 5 lines

+++ b/drivers/spi/spi-synquacer.c

drivers/spi/spi-synquacer.c new file +3 -0
@@ -0,0 +1,664 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Synquacer HSSPI controller driver

Mixing C and C++ style comments on adjacent lines looks messy, just make the whole thing C++.

drivers/spi/spi-synquacer.c line 228

Quoted 2 lines
drivers/spi/spi-synquacer.c new file +2 -0
+       speed = xfer->speed_hz ? : spi->max_speed_hz;
+       bpw = xfer->bits_per_word ? : spi->bits_per_word;

I'm not a big fan of all the ternery operator use in the driver, it's not super helpful for legibility.

drivers/spi/spi-synquacer.c line 363

Quoted 6 lines
drivers/spi/spi-synquacer.c new file +6 -0
+	if (sspi->bpw == 8)
+		words = xfer->len / 1;
+	else if (sspi->bpw == 16)
+		words = xfer->len / 2;
+	else
+		words = xfer->len / 4;

This should be a switch statement; a safety check for invalid values wouldn't go amiss either.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: [PATCHv1 2/3] spi: Add spi driver for Socionext Synquacer platform

Quoted 5 lines · Mark Brown

On Tue, Jan 09, 2018 at 06:40:48PM +0530, [email protected] wrote:

This is basically fine, a couple of style things plus the question I had on the bindings:

Quoted 9 lines

drivers/spi/spi-synquacer.c line 3

Quoted 5 lines

+++ b/drivers/spi/spi-synquacer.c

drivers/spi/spi-synquacer.c new file +3 -0
@@ -0,0 +1,664 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Synquacer HSSPI controller driver

Mixing C and C++ style comments on adjacent lines looks messy, just make the whole thing C++.

Fixed.

Quoted 6 lines

drivers/spi/spi-synquacer.c line 228

Quoted 2 lines
drivers/spi/spi-synquacer.c new file +2 -0
+       speed = xfer->speed_hz ? : spi->max_speed_hz;
+       bpw = xfer->bits_per_word ? : spi->bits_per_word;

I'm not a big fan of all the ternery operator use in the driver, it's not super helpful for legibility.

This actually goes away now.

Quoted 10 lines

drivers/spi/spi-synquacer.c line 363

Quoted 6 lines
drivers/spi/spi-synquacer.c new file +6 -0
+     if (sspi->bpw == 8)
+             words = xfer->len / 1;
+     else if (sspi->bpw == 16)
+             words = xfer->len / 2;
+     else
+             words = xfer->len / 4;

This should be a switch statement; a safety check for invalid values wouldn't go amiss either.

ok

Thank you.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCHv1 2/3] spi: Add spi driver for Socionext Synquacer platform

In reply to a message not in the archive

T24gVHVlLCAyMDE4LTAxLTA5IGF0IDE4OjQwICswNTMwLCBqYXNzaXNpbmdoYnJhckBnbWFpbC5j b20gd3JvdGU6DQo+IEZyb206IEphc3NpIEJyYXIgPGphc3dpbmRlci5zaW5naEBsaW5hcm8ub3Jn Pg0KPiANCj4gVGhpcyBwYXRjaCBhZGRzIHN1cHBvcnQgZm9yIGNvbnRyb2xsZXIgZm91bmQgb24g c3lucXVhY2VyIHBsYXRmb3Jtcy4NCj4gDQo+IFNpZ25lZC1vZmYtYnk6IEphc3NpIEJyYXIgPGph c3dpbmRlci5zaW5naEBsaW5hcm8ub3JnPg0KPiANCj4gK3N0YXRpYyBpbnQgc3lucXVhY2VyX3Nw aV9jb25maWcoc3RydWN0IHNwaV9tYXN0ZXIgKm1hc3RlciwNCj4gKwkJCQkgIHN0cnVjdCBzcGlf ZGV2aWNlICpzcGksDQo+ICsJCQkJICBzdHJ1Y3Qgc3BpX3RyYW5zZmVyICp4ZmVyKQ0KPiArew0K PiArCXN0cnVjdCBzeW5xdWFjZXJfc3BpICpzc3BpID0gc3BpX21hc3Rlcl9nZXRfZGV2ZGF0YSht YXN0ZXIpOw0KPiArCXVuc2lnbmVkIGludCBzcGVlZCwgbW9kZSwgYnB3LCBjcywgYnVzX3dpZHRo Ow0KPiArCXVuc2lnbmVkIGxvbmcgcmF0ZSwgdHJhbnNmX21vZGU7DQo+ICsJdTMyIHZhbCwgZGl2 Ow0KPiArDQo+ICsJLyogRnVsbCBEdXBsZXggb25seSBvbiAxYml0IHdpZGUgYnVzICovDQo+ICsJ aWYgKHhmZXItPnJ4X2J1ZiAmJiB4ZmVyLT50eF9idWYgJiYNCj4gKwkJCSh4ZmVyLT5yeF9uYml0 cyAhPSAxIHx8IHhmZXItPnR4X25iaXRzICE9IDEpKSB7D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WZvcmUg aXQgaXMgc2NoZWR1bGVkIHRvIHJ1biBhZ2Fpbi4gIEhvcGUgdGhhdCBmaWZvIGlzIGxhcmdlLi4u DQoNClVzdWFsbHkgd2hlbiBhIGRldmljZSBoYXMgYSBmaWZvIHRoYXQgbXVzdCBiZSBlbXB0aWVk IGJlZm9yZSBpdA0Kb3ZlcmZsb3dzLCBpdCBpcyBlaXRoZXIgZW1wdGllZCBmcm9tIGFuIGludGVy cnVwdCBoYW5kbGVyIG9yIHRoZQ0KaW50ZXJydXB0IGhhbmRsZXIgd2lsbCBxdWV1ZSBhIHdvcmsg ZnVuY3Rpb24gb3IgdGFza2xldCB0aGF0IHdpbGwgZW1wdHkNCml0LiAgRG9pbmcgaXQgZnJvbSB1 c2VyIGNvbnRleHQgaGFzIGEgbWF4aW11bSBsYXRlbmN5IHRoYXQgaXMgdG9vIGhpZ2guDQoNCg== --
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1515527945.25398.59.camel-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org

#12 lore raw

Re: [PATCHv1 2/3] spi: Add spi driver for Socionext Synquacer platform

Quoted 4 lines · Trent Piepho

Usually when a device has a fifo that must be emptied before it overflows, it is either emptied from an interrupt handler or the interrupt handler will queue a work function or tasklet that will empty it. Doing it from user context has a maximum latency that is too high.

It wouldn't be the first SPI controller that lacked interrupt support, this is depressingly common.

#13 lore raw

Re: [PATCHv1 2/3] spi: Add spi driver for Socionext Synquacer platform

In reply to a message not in the archive
Quoted 7 lines · Trent Piepho
Quoted 6 lines · On Tue, 2018-01-09 at 18:40 +0530, jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public…

From: Jassi Brar <[email protected]>

This patch adds support for controller found on synquacer platforms.

Quoted 17 lines

drivers/spi/spi-synquacer.c line 213

Quoted 13 lines
drivers/spi/spi-synquacer.c new file +13 -0
+static int synquacer_spi_config(struct spi_master *master,
+                               struct spi_device *spi,
+                               struct spi_transfer *xfer)
+{
+     struct synquacer_spi *sspi = spi_master_get_devdata(master);
+     unsigned int speed, mode, bpw, cs, bus_width;
+     unsigned long rate, transf_mode;
+     u32 val, div;
+
+     /* Full Duplex only on 1bit wide bus */
+     if (xfer->rx_buf && xfer->tx_buf &&
+                     (xfer->rx_nbits != 1 || xfer->tx_nbits != 1)) {
+             dev_err(sspi->dev, "RX and TX bus widths must match!\n");

This looks like the wrong error message is being printed. It does not match the comment nor the code.

Well, TX and TX bus widths should both be 1 for Full-Duplex mode. I have anyway tried to made it clearer.

Quoted 8 lines

drivers/spi/spi-synquacer.c line 228

Quoted 2 lines
drivers/spi/spi-synquacer.c new file +2 -0
+     speed = xfer->speed_hz ? : spi->max_speed_hz;
+     bpw = xfer->bits_per_word ? : spi->bits_per_word;

You shouldn't need to do this checking. __spi_validate() should have already set these fields in xfer to their defaults if they weren't set, checked xfer speed is less than controller max speed, checked bus width is supported, etc.

Cool. Thanks

Quoted 15 lines

drivers/spi/spi-synquacer.c line 236

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +7 -0
+     /* return if nothing to change */
+     if (speed == sspi->speed &&
+                     bus_width == sspi->bus_width && bpw == sspi->bpw &&
+                     mode == sspi->mode && cs == sspi->cs &&
+                     transf_mode == sspi->old_transf_mode) {
+             return 0;
+     }

Good optimization to not reprogram on every xfer, since usually speed, bits, etc. stays the same for a series of xfers. However, often SPI clients generate a number write, read pairs. In this case transf_mode will alternate and the optimization will fail to work, even through it is very likely that nothing (especially bus speed, which can be slow to change) else changed.

Quoted 3 lines

Consider allowing changing between read and write without unnecessarily reprogramming everything else.

Tracking transf_mode is actually redundant. I have removed it.

Quoted 27 lines

drivers/spi/spi-synquacer.c line 250

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +5 -0
+
+     if (xfer->tx_buf)
+             sspi->old_transf_mode = TXBIT;
+     else
+             sspi->old_transf_mode = RXBIT;

Why not just:

sspi->old_transf_mode = transf_mode;

Also, why is this "old_" when all the other ones, sspi->speed, etc., don't have "old_" in front. Seems inconsistent unless there is something special about transf_mode I have missed.

drivers/spi/spi-synquacer.c line 312

Quoted 8 lines
drivers/spi/spi-synquacer.c new file +7 -0
+
+     if (xfer->tx_buf && xfer->rx_buf)
+             val |= (DATA_TXRX << DATA_SHIFT);
+     else if (xfer->rx_buf)
+             val |= (DATA_RX << DATA_SHIFT);
+     else
+             val |= (DATA_TX << DATA_SHIFT);

Looks like one needs to set three different modes for bi, rx, and tx. But your transf_mode variable only has two settings, rx and tx. It won't detect change between tx and bi.

Quoted 1 line
Quoted 9 lines

drivers/spi/spi-synquacer.c line 339

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +5 -0
+
+     val = readl_relaxed(sspi->regs + FIFOCFG);
+     val |= RX_FLUSH;
+     val |= TX_FLUSH;
+     writel_relaxed(val, sspi->regs + FIFOCFG);

If this causes the master to pulse the chipselect it will mess up messages that have more than one xfer.

No, that just resets the fifos.

Quoted 6 lines

drivers/spi/spi-synquacer.c line 342

Quoted 3 lines
drivers/spi/spi-synquacer.c new file +3 -0
+
+     /* See if we can transfer 4-bytes as 1 word even if not asked */
+     bpw = xfer->bits_per_word ? : spi->bits_per_word;

Don't neeed this as xfer->bits_per_word is already normalized.

OK

Quoted 10 lines

drivers/spi/spi-synquacer.c line 348

Quoted 6 lines
drivers/spi/spi-synquacer.c new file +6 -0
+     if (bpw == 8 && !(xfer->len % 4) && !(spi->mode & SPI_LSB_FIRST)) {
+             bpw = xfer->bits_per_word;
+             xfer->bits_per_word = 32;
+     } else {
+             bpw = xfer->bits_per_word;
+     }

What's the point of the bpw = xfer->bits_per_word above? It would already be set to that value.

Cleaned.

Quoted 9 lines

drivers/spi/spi-synquacer.c line 352

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +4 -0
+
+     ret = synquacer_spi_config(master, spi, xfer);
+     if (ret) {
+             xfer->bits_per_word = bpw;

Why not restore xfer->bits_per_word immediately after call to synquacer_spi_config, before if statement. It's not used again. Then you don't have to restore it also at the end of the function.

Done.

Quoted 6 lines

drivers/spi/spi-synquacer.c line 365

Quoted 3 lines
drivers/spi/spi-synquacer.c new file +2 -0
+
+     spin_lock_irqsave(&sspi->lock, flags);

What's this lock for? I see no other use than here.

Remnant of old driver. Dropped.

Quoted 5 lines
Quoted 1 line

+ master->min_speed_hz = master->max_speed_hz / 254;

The configure function rejects divisors larger than 127. Seems like these should match.

Fixed.

Quoted 12 lines

I notice your transfer function does not use interrupts. It will spin in a tight loop polling DMSTATUS waiting for data to arrive. Not very friendly for a multitasking operating system. It would be much better if there was a way wait for in an interrupt at the start of your while loop and have the controller trigger one when the tx and/or rx fifo has
some amount of data in it (like half full).

You'll likely also find that in an interruptable kernel that your transfer function will eventually stop running and another process will run. Multitasking. When this happens, it might be many milliseconds before it is scheduled to run again. Hope that fifo is large...

Quoted 5 lines

Usually when a device has a fifo that must be emptied before it overflows, it is either emptied from an interrupt handler or the interrupt handler will queue a work function or tasklet that will empty it. Doing it from user context has a maximum latency that is too high.

I am aware of the benefits of interrupts, unfortunately the h/w doesn't seem to support.

Thank you.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

PATCH 3/3 MAINTAINERS: Add entry for Synquacer SPI driver

In reply to a message not in the archive

From: Jassi Brar <[email protected]>

Add entry for the Synquacer spi driver and DT bindings.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index d76af75..9500c23 100644
@@ -12627,6 +12627,13 @@ F:	drivers/md/raid*
 F:	include/linux/raid/
 F:	include/uapi/linux/raid/
 
+SOCIONEXT (SNI) Synquacer SPI DRIVER
+M:	Jassi Brar <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/spi/spi-synquacer.c
+F:	Documentation/devicetree/bindings/spi/spi-synquacer.txt
+
 SONIC NETWORK DRIVER
 M:	Thomas Bogendoerfer <[email protected]>
 L:	[email protected]
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html