Skip to contentSkip to conversation

spi: support for Socionext Synquacer platform

PATCH In review [email protected] 6 participants 14 messages Feb 27, 2018 – Mar 1, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

v4 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.

Changes since v3:
# Convert IS_ERR returned from devm_clk_get(iPCLK) to NULL, that way
we can call clk_xxx(IPCLK) without first checking for it being valid.

Changes since v2:
# Made iHCLK clock property required in DT, and iPCLK an optional extra. # Hardcode max number of slaves to 4, as specified in the manual.

Changes since v1:
# Changed licence header to C++ style comment. # Removed redundant lock and transfer_mode backup member. # Fixed divisor to allow upto 254.

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      |  23 +
 MAINTAINERS                                        |   7 +
 drivers/spi/Kconfig                                |  11 +
 drivers/spi/Makefile                               |   1 +
 drivers/spi/spi-synquacer.c                        | 663 +++++++++++++++++++++
 5 files changed, 705 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-synquacer.txt
 create mode 100644 drivers/spi/spi-synquacer.c
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v4 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      | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-synquacer.txt
Documentation/devicetree/bindings/spi/spi-synquacer.txt new file +23 -0
new file mode 100644
index 0000000..d945a4a
@@ -0,0 +1,23 @@
+* 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: core clock iHCLK. Optional rate clock iPCLK (default is iHCLK)
+- clock-names: Shall be "iHCLK" and "iPCLK" respectively
+
+Optional Properties:
+- 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 · 1 line
2.7.4
author maintainer
#2 lore raw

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

In reply to [email protected]

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 | 663 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 675 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 +663 -0

663 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

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

Hi Jassi,

Quoted 5 lines · On Tue, Feb 27, 2018 at 1:58 PM, <[email protected]> wrote:

From: Jassi Brar <[email protected]>

This patch adds support for controller found on synquacer platforms.

Thanks for your patch!

drivers/spi/spi-synquacer.c line 123

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +4 -0
 
+static void read_fifo(struct synquacer_spi *sspi)
+{
+       u32 len = readl_relaxed(sspi->regs + DMSTATUS);
+       int i;

unsigned int, as len is unsigned.

drivers/spi/spi-synquacer.c line 164

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +4 -0
+static void write_fifo(struct synquacer_spi *sspi)
+{
+       u32 len = readl_relaxed(sspi->regs + DMSTATUS);
+       int i;

unsigned int, as len is unsigned.

drivers/spi/spi-synquacer.c line 207

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +7 -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;

unsigned int, as max_speed_hz is u32, else you'll do a 64/32-bit division later.

drivers/spi/spi-synquacer.c line 324

Quoted 6 lines
drivers/spi/spi-synquacer.c new file +6 -0
+static int synquacer_spi_transfer_one(struct spi_master *master,
+                                     struct spi_device *spi,
+                                     struct spi_transfer *xfer)
+{
+       struct synquacer_spi *sspi = spi_master_get_devdata(master);
+       int ret, words, busy = 0;

unsigned int words, as xfr->len is unsigned.

Quoted 1 line

+ unsigned long bpw;

unsigned int is plenty (bits_per_word is even u8).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#4 lore raw

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

Quoted 47 lines · Geert Uytterhoeven

Hi Jassi,

Quoted 5 lines · On Tue, Feb 27, 2018 at 1:58 PM, <[email protected]> wrote:

From: Jassi Brar <[email protected]>

This patch adds support for controller found on synquacer platforms.

Thanks for your patch!

drivers/spi/spi-synquacer.c line 123

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +4 -0
 
+static void read_fifo(struct synquacer_spi *sspi)
+{
+       u32 len = readl_relaxed(sspi->regs + DMSTATUS);
+       int i;

unsigned int, as len is unsigned.

drivers/spi/spi-synquacer.c line 164

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +4 -0
+static void write_fifo(struct synquacer_spi *sspi)
+{
+       u32 len = readl_relaxed(sspi->regs + DMSTATUS);
+       int i;

unsigned int, as len is unsigned.

drivers/spi/spi-synquacer.c line 207

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +7 -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;

unsigned int, as max_speed_hz is u32, else you'll do a 64/32-bit division later.

drivers/spi/spi-synquacer.c line 324

Quoted 6 lines
drivers/spi/spi-synquacer.c new file +6 -0
+static int synquacer_spi_transfer_one(struct spi_master *master,
+                                     struct spi_device *spi,
+                                     struct spi_transfer *xfer)
+{
+       struct synquacer_spi *sspi = spi_master_get_devdata(master);
+       int ret, words, busy = 0;

unsigned int words, as xfr->len is unsigned.

Quoted 4 lines
Quoted 1 line

+ unsigned long bpw;

unsigned int is plenty (bits_per_word is even u8).

Will fix all.

Thank you.

#5 lore raw

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

In reply to [email protected]
Quoted 21 lines · On Tue, 2018-02-27 at 18:28 +0530, [email protected] wrote:

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 | 663 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 675 insertions(+)
 create mode 100644 drivers/spi/spi-synquacer.c
drivers/spi/Kconfig +1 -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

drivers/spi/Kconfig config SPI_SUN6I · line 672

Quoted 10 lines
drivers/spi/Kconfig +10 -0
+	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.
+

As someone who designs and develops embedded Linux devices, it would be really useful if there was a bit more documentation about the driver.

The hardware doesn't support DMA or even interrupts, and must busy wait for the duration of the entire SPI transfers. That's kind of a Big Deal. A design that involves lots of SPI transfers on a slow clock will work fine on most SPI hardware, but will be utterly unfeasible here. It would be nice to say something about that. I'd probably put it in driver code.

author maintainer
#6 lore raw

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

Quoted 36 lines · Trent Piepho
Quoted 21 lines · On Tue, 2018-02-27 at 18:28 +0530, [email protected] wrote:

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 | 663 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 675 insertions(+)
 create mode 100644 drivers/spi/spi-synquacer.c
drivers/spi/Kconfig +1 -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

drivers/spi/Kconfig config SPI_SUN6I · line 672

Quoted 10 lines
drivers/spi/Kconfig +10 -0
+     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.
+

As someone who designs and develops embedded Linux devices, it would be really useful if there was a bit more documentation about the driver.

Quoted 8 lines

The hardware doesn't support DMA or even interrupts, and must busy wait for the duration of the entire SPI transfers. That's kind of a Big Deal. A design that involves lots of SPI transfers on a slow clock will work fine on most SPI hardware, but will be utterly unfeasible here. It would be nice to say something about that. I'd probably put it in driver code.

From marketing point of view, why would I want to advertise my limitations? :)

Its not like any random platform might want to use this driver, nor the enduser could do anything about it (its not a s/w issue). The decision to integrate the ip in a SoC is already taken before the driver is written. Obviously the users that need high spi performance are not its intended target.

BTW, the IP is actually not that bad. It is meant for interfacing flash devices and can operate in two modes - "direct" mode where it maps flash memory as i/o region and the other last resort "spi" mode where we could manually drive the flash. This driver implements that limited "spi" mode.

Cheers!

#7 lore raw

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

Quoted 52 lines · Jassi Brar
Quoted 36 lines · Trent Piepho
Quoted 21 lines · On Tue, 2018-02-27 at 18:28 +0530, [email protected] wrote:

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 | 663 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 675 insertions(+)
 create mode 100644 drivers/spi/spi-synquacer.c
drivers/spi/Kconfig +1 -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

drivers/spi/Kconfig config SPI_SUN6I · line 672

Quoted 10 lines
drivers/spi/Kconfig +10 -0
+     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.
+

As someone who designs and develops embedded Linux devices, it would be really useful if there was a bit more documentation about the driver.

Quoted 7 lines

The hardware doesn't support DMA or even interrupts, and must busy wait for the duration of the entire SPI transfers. That's kind of a Big Deal. A design that involves lots of SPI transfers on a slow clock will work fine on most SPI hardware, but will be utterly unfeasible here. It would be nice to say something about that. I'd probably put it in driver code.

From marketing point of view, why would I want to advertise my limitations? :)

Its not like any random platform might want to use this driver, nor the enduser could do anything about it (its not a s/w issue). The decision to integrate the ip in a SoC is already taken before the driver is written. Obviously the users that need high spi performance are not its intended target.

Quoted 6 lines

BTW, the IP is actually not that bad. It is meant for interfacing flash devices and can operate in two modes - "direct" mode where it maps flash memory as i/o region and the other last resort "spi" mode where we could manually drive the flash. This driver implements that limited "spi" mode.

My SoC manual does list interrupts for this IP block. Are you sure SynQuacer uses the same version of the IP as before?

author maintainer
#8 lore raw

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

Quoted 60 lines · Ard Biesheuvel
Quoted 52 lines · Jassi Brar
Quoted 36 lines · Trent Piepho
Quoted 21 lines · On Tue, 2018-02-27 at 18:28 +0530, [email protected] wrote:

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 | 663 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 675 insertions(+)
 create mode 100644 drivers/spi/spi-synquacer.c
drivers/spi/Kconfig +1 -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

drivers/spi/Kconfig config SPI_SUN6I · line 672

Quoted 10 lines
drivers/spi/Kconfig +10 -0
+     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.
+

As someone who designs and develops embedded Linux devices, it would be really useful if there was a bit more documentation about the driver.

Quoted 7 lines

The hardware doesn't support DMA or even interrupts, and must busy wait for the duration of the entire SPI transfers. That's kind of a Big Deal. A design that involves lots of SPI transfers on a slow clock will work fine on most SPI hardware, but will be utterly unfeasible here. It would be nice to say something about that. I'd probably put it in driver code.

From marketing point of view, why would I want to advertise my limitations? :)

Its not like any random platform might want to use this driver, nor the enduser could do anything about it (its not a s/w issue). The decision to integrate the ip in a SoC is already taken before the driver is written. Obviously the users that need high spi performance are not its intended target.

Quoted 6 lines

BTW, the IP is actually not that bad. It is meant for interfacing flash devices and can operate in two modes - "direct" mode where it maps flash memory as i/o region and the other last resort "spi" mode where we could manually drive the flash. This driver implements that limited "spi" mode.

Quoted 3 lines

My SoC manual does list interrupts for this IP block. Are you sure SynQuacer uses the same version of the IP as before?

Having got hold of english specs, the newer version does seem to support IRQ despite being named same "FIP006" as before. Let me investigate deeper.

Thanks.

#9 lore raw

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

In reply to Jassi Brar
Quoted 26 lines · Jassi Brar
Quoted 17 lines · Trent Piepho

drivers/spi/Kconfig config SPI_SUN6I · line 672

Quoted 12 lines · On Tue, 2018-02-27 at 18:28 +0530, [email protected] wrote:
drivers/spi/Kconfig +11 -0
+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.
+

As someone who designs and develops embedded Linux devices, it would be really useful if there was a bit more documentation about the driver.

Quoted 7 lines

The hardware doesn't support DMA or even interrupts, and must busy wait for the duration of the entire SPI transfers. That's kind of a Big Deal. A design that involves lots of SPI transfers on a slow clock will work fine on most SPI hardware, but will be utterly unfeasible here. It would be nice to say something about that. I'd probably put it in driver code.

Quoted 7 lines

From marketing point of view, why would I want to advertise my limitations? :)

Its not like any random platform might want to use this driver, nor the enduser could do anything about it (its not a s/w issue). The decision to integrate the ip in a SoC is already taken before the driver is written. Obviously the users that need high spi performance are not its intended target.

It helps when choosing hardware, designing products, and also with software design. Example:

I really need another GPIO pin on this SoC. Here's this interrupt line from a spi slave. I don't need that and can take the pin. I can poll the slave at a low rate and it'll be ok as there is no tight latency requirement.

That might use a lot more CPU that one would think.

Quoted 5 lines

BTW, the IP is actually not that bad. It is meant for interfacing flash devices and can operate in two modes - "direct" mode where it maps flash memory as i/o region and the other last resort "spi" mode where we could manually drive the flash. This driver implements that limited "spi" mode.

Here's another example, someone has a "direct" flash on their hardware, probably just copied from the reference design. In doing cost engineering for the next rev, they determine that they don't need much performance from this flash and should be able to use a cheaper non-vol storage part (eeprom..). The new part has a Linux driver. No one realizes the significance of switching from "direct" to "spi" mode.

#10 lore raw

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

In reply to [email protected]
Quoted 3 lines · On Tue, Feb 27, 2018 at 2:58 PM, <[email protected]> wrote:

From: Jassi Brar <[email protected]>

This patch adds support for controller found on synquacer platforms.

Thanks for the patch!

Unfortunately it has a set of typical mistakes. Perhaps you guys eventually do follow some common style?

See my comments below.

Quoted 15 lines
drivers/spi/spi-synquacer.c new file +14 -0
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+#include <linux/spinlock.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
 
+#define PCC0           0x4

drivers/spi/spi-synquacer.c line 39

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +9 -0
+#define PCC(n)         (PCC0 + (n) * 4)
+#define RTM    BIT(3)
+#define ACES   BIT(2)
+#define SAFESYNC       BIT(16)
+#define CPHA   BIT(0)
+#define CPOL   BIT(1)
+#define SSPOL  BIT(4)
+#define SDIR   BIT(7)
 
+#define SS2CD  5

What is this?

Quoted 1 line

+#define SENDIAN BIT(8)

Why above list of bits is unordered?

drivers/spi/spi-synquacer.c line 42

Quoted 3 lines
drivers/spi/spi-synquacer.c new file +2 -0
+#define CDRS_SHIFT     9
 
+#define CDRS_MASK      0x7f

GENMASK() ?

drivers/spi/spi-synquacer.c line 61

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +4 -0
+#define        DMSTART         0x38
+#define TRIGGER                BIT(0)
+#define DMSTOP         BIT(8)
 
+#define CS_MASK                3

GENMASK() ?

drivers/spi/spi-synquacer.c line 66

Quoted 6 lines
drivers/spi/spi-synquacer.c new file +5 -0
+#define CS_SHIFT       16
+#define DATA_TXRX      0
+#define DATA_RX                1
+#define DATA_TX                2
 
+#define DATA_MASK      3

GENMASK() ?

drivers/spi/spi-synquacer.c line 72

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +6 -0
+#define DATA_SHIFT     26
+#define BUS_WIDTH      24
+
+#define        DMBCC           0x3c
+#define DMSTATUS       0x40
 
+#define RX_DATA_MASK   0x1f

GENMASK() ?

drivers/spi/spi-synquacer.c line 74

Quoted 3 lines
drivers/spi/spi-synquacer.c new file +2 -0
+#define RX_DATA_SHIFT  8
 
+#define TX_DATA_MASK   0x1f

GENMASK() ?

drivers/spi/spi-synquacer.c line 80

Quoted 7 lines
drivers/spi/spi-synquacer.c new file +6 -0
+#define TX_DATA_SHIFT  16
+
+#define TXBITCNT       0x44
+
+#define FIFOCFG                0x4c
 
+#define BPW_MASK       0x3

GENMASK() ?

drivers/spi/spi-synquacer.c line 84

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +4 -0
+#define BPW_SHIFT      8
+#define RX_FLUSH       BIT(11)
+#define TX_FLUSH       BIT(12)
 
+#define RX_TRSHLD_MASK         0xf

GENMASK() ?

drivers/spi/spi-synquacer.c line 86

Quoted 3 lines
drivers/spi/spi-synquacer.c new file +2 -0
+#define RX_TRSHLD_SHIFT                0
 
+#define TX_TRSHLD_MASK         0xf

GENMASK() ?

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +5 -0
+#define TX_TRSHLD_SHIFT                4
+
+#define TXFIFO         0x50
+#define RXFIFO         0x90
+#define MID            0xfc

drivers/spi/spi-synquacer.c line 101

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +10 -0
+
+#define FIFO_DEPTH     16
+#define TX_TRSHLD      4
+#define RX_TRSHLD      (FIFO_DEPTH - TX_TRSHLD)
+
+#define TXBIT  BIT(1)
+#define RXBIT  BIT(2)
+
+#define IHCLK  0
+#define IPCLK  1

To all above. Can you do all definitions under a dedicated namespace?

drivers/spi/spi-synquacer.c line 105

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +3 -0
+struct synquacer_spi {
 
+       struct device *dev;
+       struct spi_master *master;

Isn't one refers to another?

drivers/spi/spi-synquacer.c line 114

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +9 -0
+
+       unsigned int cs;
+       unsigned int bpw;
+       unsigned int mode;
+       unsigned int speed;
+       bool aces, rtm;
+       void *rx_buf;
+       const void *tx_buf;
 
+       struct clk *clk[2];

Ouch. Please, split with a proper names.

Quoted 11 lines
drivers/spi/spi-synquacer.c new file +11 -0
+       void __iomem *regs;
+       unsigned int tx_words, rx_words;
+       unsigned int bus_width;
+};
+
+static void read_fifo(struct synquacer_spi *sspi)
+{
+       u32 len = readl_relaxed(sspi->regs + DMSTATUS);
+       int i;
+
+       len = (len >> RX_DATA_SHIFT) & RX_DATA_MASK;

drivers/spi/spi-synquacer.c line 134

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +9 -0
+       len = min_t(unsigned int, len, sspi->rx_words);
+
 
+       switch (sspi->bpw) {
+       case 8:
+               {
+               u8 *buf = sspi->rx_buf;
+
+               for (i = 0; i < len; i++)
+                       *buf++ = readb_relaxed(sspi->regs + RXFIFO);

readsb() ?

drivers/spi/spi-synquacer.c line 146

Quoted 12 lines
drivers/spi/spi-synquacer.c new file +12 -0
+               sspi->rx_buf = buf;
+               break;
+               }
+       case 16:
+               {
+               u16 *buf = sspi->rx_buf;
+
+               for (i = 0; i < len; i++)
+                       *buf++ = readw_relaxed(sspi->regs + RXFIFO);
+               sspi->rx_buf = buf;
+               break;
+               }

readsw() ?

drivers/spi/spi-synquacer.c line 155

Quoted 9 lines
drivers/spi/spi-synquacer.c new file +9 -0
+       default:
+               {
+               u32 *buf = sspi->rx_buf;
+
+               for (i = 0; i < len; i++)
+                       *buf++ = readl_relaxed(sspi->regs + RXFIFO);
+               sspi->rx_buf = buf;
+               break;
+               }

readsl() ?

Quoted 13 lines
drivers/spi/spi-synquacer.c new file +13 -0
+       }
+
+       sspi->rx_words -= len;
+}
+
+static void write_fifo(struct synquacer_spi *sspi)
+{
+       u32 len = readl_relaxed(sspi->regs + DMSTATUS);
+       int i;
+
+       len = (len >> TX_DATA_SHIFT) & TX_DATA_MASK;
+       len = min_t(unsigned int, FIFO_DEPTH - len, sspi->tx_words);
+

drivers/spi/spi-synquacer.c line 178

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +10 -0
+       switch (sspi->bpw) {
+       case 8:
+               {
+               const u8 *buf = sspi->tx_buf;
+
+               for (i = 0; i < len; i++)
+                       writeb_relaxed(*buf++, sspi->regs + TXFIFO);
+               sspi->tx_buf = buf;
+               break;
+               }

writesb() ?

drivers/spi/spi-synquacer.c line 187

Quoted 9 lines
drivers/spi/spi-synquacer.c new file +9 -0
+       case 16:
+               {
+               const u16 *buf = sspi->tx_buf;
+
+               for (i = 0; i < len; i++)
+                       writew_relaxed(*buf++, sspi->regs + TXFIFO);
+               sspi->tx_buf = buf;
+               break;
+               }

writesw() ?

drivers/spi/spi-synquacer.c line 196

Quoted 9 lines
drivers/spi/spi-synquacer.c new file +9 -0
+       default:
+               {
+               const u32 *buf = sspi->tx_buf;
+
+               for (i = 0; i < len; i++)
+                       writel_relaxed(*buf++, sspi->regs + TXFIFO);
+               sspi->tx_buf = buf;
+               break;
+               }

writesl() ?

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +4 -0
+       }
+       sspi->tx_words -= len;
+}
+

drivers/spi/spi-synquacer.c line 210

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +10 -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;
+       u32 val, div;
+
+       /* Full Duplex only on 1bit wide bus */

1-bit

drivers/spi/spi-synquacer.c line 333

Quoted 8 lines
drivers/spi/spi-synquacer.c new file +6 -0
+}
 
+static int synquacer_spi_transfer_one(struct spi_master *master,
+                                     struct spi_device *spi,
+                                     struct spi_transfer *xfer)
+{
 
+       /* See if we can transfer 4-bytes as 1 word even if not asked */

Why?

drivers/spi/spi-synquacer.c line 426

Quoted 12 lines
drivers/spi/spi-synquacer.c new file +9 -0
+       bpw = xfer->bits_per_word;
+       if (bpw == 8 && !(xfer->len % 4) && !(spi->mode & SPI_LSB_FIRST))
+               xfer->bits_per_word = 32;
 
+}
 
+static void synquacer_spi_set_cs(struct spi_device *spi, bool enable)
+{
+       struct synquacer_spi *sspi = spi_master_get_devdata(spi->master);
+       u32 val;
 
+       if (!enable) {

Why not to use positive condition?

drivers/spi/spi-synquacer.c line 449

Quoted 10 lines
drivers/spi/spi-synquacer.c new file +7 -0
+       } else {
 
+       }
+}
 
+static int synquacer_spi_enable(struct spi_master *master)
+{
+       struct synquacer_spi *sspi = spi_master_get_devdata(master);
 
+       u32 val;

unsigned int retries = 65535;

drivers/spi/spi-synquacer.c line 457

Quoted 9 lines
drivers/spi/spi-synquacer.c new file +8 -0
+
+       /* Disable module */
+       writel_relaxed(0, sspi->regs + MCTRL);
 
+       val = 0xfffff;
+       while (--val && (readl_relaxed(sspi->regs + MCTRL) & MES))
+               cpu_relax();
+       if (!val)
+               return -EBUSY;

while (readl...(...) && --retries)
cpu_relax();
if (!retries)
return -EBUSY;

drivers/spi/spi-synquacer.c line 495

Quoted 11 lines
drivers/spi/spi-synquacer.c new file +9 -0
+static int synquacer_spi_probe(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct spi_master *master;
+       struct synquacer_spi *sspi;
+       struct resource *res;
+       int ret;
+
 
 
+       master = spi_alloc_master(&pdev->dev, sizeof(*sspi));

s/master/controller/ ?

I guess it might make sense to do for entire driver.

drivers/spi/spi-synquacer.c line 497

Quoted 2 lines
drivers/spi/spi-synquacer.c new file +2 -0
+       if (!master)
+               return -ENOMEM;

+ empty line ?

drivers/spi/spi-synquacer.c line 527

Quoted 3 lines
drivers/spi/spi-synquacer.c new file +2 -0
+       platform_set_drvdata(pdev, master);
 
+       clk_prepare_enable(sspi->clk[IPCLK]);

Also can fail.

drivers/spi/spi-synquacer.c line 587

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +4 -0
+       ret = clk_prepare_enable(sspi->clk[IHCLK]);
+       if (ret)
+               goto put_spi;
 
+#ifdef CONFIG_PM_SLEEP

__maybe_unused

drivers/spi/spi-synquacer.c line 616

Quoted 5 lines
drivers/spi/spi-synquacer.c new file +3 -0
+static int synquacer_spi_suspend(struct device *dev)
 
+static int synquacer_spi_resume(struct device *dev)
 
+               clk_prepare_enable(sspi->clk[IPCLK]);

It can fail.

drivers/spi/spi-synquacer.c line 642

Quoted 12 lines
drivers/spi/spi-synquacer.c new file +10 -0
+               ret = clk_prepare_enable(sspi->clk[IHCLK]);
+               if (ret < 0) {
+                       dev_err(dev, "failed to enable clk (%d)\n", ret);
+                       return ret;
+               }
 
+}
+#endif /* CONFIG_PM_SLEEP */
 
+static const struct dev_pm_ops synquacer_spi_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(synquacer_spi_suspend, synquacer_spi_resume)
+};

static SIMPLE_DEV_PM_OPS() ?

drivers/spi/spi-synquacer.c line 646

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +3 -0
+static const struct of_device_id synquacer_spi_of_match[] = {
+       {.compatible = "socionext,synquacer-spi",},
 
+       {},

No comma needed.

drivers/spi/spi-synquacer.c line 654

Quoted 9 lines
drivers/spi/spi-synquacer.c new file +7 -0
+};
+MODULE_DEVICE_TABLE(of, synquacer_spi_of_match);
 
+static struct platform_driver synquacer_spi_driver = {
+       .driver = {
+               .name = "synquacer-spi",
+               .pm = &synquacer_spi_pm_ops,
 
+               .of_match_table = of_match_ptr(synquacer_spi_of_match),

of_match_ptr() should be dropped.

Quoted 4 lines
drivers/spi/spi-synquacer.c new file +4 -0
+       },
+       .probe = synquacer_spi_probe,
+       .remove = synquacer_spi_remove,
+};
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

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

Quoted 12 lines · Andy Shevchenko
Quoted 11 lines
drivers/spi/spi-synquacer.c new file +11 -0
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+#include <linux/spinlock.h>
Quoted 2 lines

drivers/spi/spi-synquacer.c line 21

Quoted 2 lines
drivers/spi/spi-synquacer.c new file +2 -0
+#include <linux/clk.h>
+#include <linux/clk-provider.h>

Forgot to add.
Is there any clock provider? I perhaps missed it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#12 lore raw

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

In reply to [email protected]

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 93a12af..866b230 100644
@@ -12851,6 +12851,13 @@ S:	Maintained
 F:	drivers/net/ethernet/socionext/netsec.c
 F:	Documentation/devicetree/bindings/net/socionext-netsec.txt
 
+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 · 1 line
2.7.4
maintainer
#13 lore raw
In reply to [email protected]
Quoted 4 lines · On Tue, Feb 27, 2018 at 06:26:22PM +0530, [email protected] wrote:

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.

If any updates are needed to a patch that's already been applied you should submit incremental patches which make those updates. This avoids having to change published git commits which could cause problems for people working against git.