Skip to contentSkip to conversation

spi: sh-msiof: Add support for R-Car H2 and M2

PATCH Applied Geert Uytterhoeven 4 participants 16 messages Feb 25, 2014 – Feb 28, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover spi: sh-msiof: Add support for R-Car H2 and M2

Hi Mark,

This patch series refactors the sh-msiof SPI driver and adds support for the MSIOF variant in the Renesas R-Car H2 (r8a7790) and M2 (r8a7791) SoCs.

It was tested on the Lager and Koelsch development boards, using a dummy driver for the Renesas r2a11302ft PMIC that reads out the PMIC's version ID.

[1/6] spi: sh-msiof: Improve bindings
[2/6] spi: sh-msiof: Move default FIFO sizes to device ID data [3/6] spi: sh-msiof: Add support for R-Car H2 and M2
[4/6] spi: sh-msiof: Move clock management to (un)prepare_message() [5/6] spi: sh-msiof: Convert to let spi core validate xfer->bits_per_word [6/6] spi: sh-msiof: Use core message handling instead of spi-bitbang

These are (reworked versions of) the remaining patches not taken from v1. Changelogs are available in the individual patches.

Some of this work was based on a patch series by Takashi Yoshii <[email protected]>.

Thanks!

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

#1 lore raw

PATCH v2 1/6 spi: sh-msiof: Improve bindings

From: Geert Uytterhoeven <[email protected]>

Documentation:
- Add missing "interrupt-parent", "#address-cells", "#size-cells", and "clocks" properties,
- Add missing default values for "num-cs", "renesas,tx-fifo-size" and

    "renesas,rx-fifo-size",

- Add a reference to the pinctrl documentation.

Implementation:
- As "num-cs" is marked optional, provide a sensible default.

---
v2:
- As num-cs is marked optional, provide a sensible default

 Documentation/devicetree/bindings/spi/sh-msiof.txt |   24 ++++++++++++++------
 drivers/spi/spi-sh-msiof.c                         |    2 +-
 2 files changed, 18 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/spi/sh-msiof.txt +17 -7
index e6222106ca36..eae3c8c9300e 100644
@@ -1,12 +1,22 @@
 Renesas MSIOF spi controller
 
 Required properties:
-- compatible : 	"renesas,sh-msiof" for SuperH or
-		"renesas,sh-mobile-msiof" for SH Mobile series
-- reg : Offset and length of the register set for the device
-- interrupts : interrupt line used by MSIOF
+- compatible           : "renesas,sh-msiof" for SuperH, or
+			 "renesas,sh-mobile-msiof" for SH Mobile series.
+- reg                  : Offset and length of the register set for the device
+- interrupt-parent     : The phandle for the interrupt controller that
+			 services interrupts for this device
+- interrupts           : Interrupt specifier
+- #address-cells       : Must be <1>
+- #size-cells          : Must be <0>
 
 Optional properties:
-- num-cs		: total number of chip-selects
-- renesas,tx-fifo-size	: Overrides the default tx fifo size given in words
-- renesas,rx-fifo-size	: Overrides the default rx fifo size given in words
+- clocks               : Must contain a reference to the functional clock.
+- num-cs               : Total number of chip-selects (default is 1)
+- renesas,tx-fifo-size : Overrides the default tx fifo size given in words
+			 (default is 64)
+- renesas,rx-fifo-size : Overrides the default rx fifo size given in words
+			 (default is 64)
+
+Pinctrl properties might be needed, too.  See
+Documentation/devicetree/bindings/pinctrl/renesas,*.
drivers/spi/spi-sh-msiof.c +1 -1
index 92515c1ececa..bbe963018e1a 100644
@@ -663,7 +663,7 @@ static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
 {
 	struct sh_msiof_spi_info *info;
 	struct device_node *np = dev->of_node;
-	u32 num_cs = 0;
+	u32 num_cs = 1;
 
 	info = devm_kzalloc(dev, sizeof(struct sh_msiof_spi_info), GFP_KERNEL);
 	if (!info) {
Signature · 6 lines
1.7.9.5

--
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
#2 lore raw

PATCH v2 2/6 spi: sh-msiof: Move default FIFO sizes to device ID data

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

As different variants of MSIOF have different FIFO sizes, move the default FIFO sizes to a new struct sh_msiof_chipdata, pointed to from the device ID data.

---
v2:
- New

 drivers/spi/spi-sh-msiof.c |   50 ++++++++++++++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 16 deletions(-)
drivers/spi/spi-sh-msiof.c +34 -16
index bbe963018e1a..bf389184924d 100644
@@ -20,6 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 
@@ -29,11 +30,18 @@
 
 #include <asm/unaligned.h>
 
+
+struct sh_msiof_chipdata {
+	u16 tx_fifo_size;
+	u16 rx_fifo_size;
+};
+
 struct sh_msiof_spi_priv {
 	struct spi_bitbang bitbang; /* must be first for spi_bitbang.c */
 	void __iomem *mapbase;
 	struct clk *clk;
 	struct platform_device *pdev;
+	const struct sh_msiof_chipdata *chipdata;
 	struct sh_msiof_spi_info *info;
 	struct completion done;
 	unsigned long flags;
@@ -112,10 +120,6 @@ struct sh_msiof_spi_priv {
 #define STR_REOF	0x00000080 /* Frame Reception End */
 
 
-#define DEFAULT_TX_FIFO_SIZE	64
-#define DEFAULT_RX_FIFO_SIZE	64
-
-
 static u32 sh_msiof_read(struct sh_msiof_spi_priv *p, int reg_offs)
 {
 	switch (reg_offs) {
@@ -659,6 +663,18 @@ static u32 sh_msiof_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
 }
 
 #ifdef CONFIG_OF
+static const struct sh_msiof_chipdata sh_data = {
+	.tx_fifo_size = 64,
+	.rx_fifo_size = 64,
+};
+
+static const struct of_device_id sh_msiof_match[] = {
+	{ .compatible = "renesas,sh-msiof",        .data = &sh_data },
+	{ .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
+	{},
+};
+MODULE_DEVICE_TABLE(of, sh_msiof_match);
+
 static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
 {
 	struct sh_msiof_spi_info *info;
@@ -693,6 +709,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 {
 	struct resource	*r;
 	struct spi_master *master;
+	const struct of_device_id *of_id;
 	struct sh_msiof_spi_priv *p;
 	int i;
 	int ret;
@@ -706,10 +723,15 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	p = spi_master_get_devdata(master);
 
 	platform_set_drvdata(pdev, p);
-	if (pdev->dev.of_node)
+
+	of_id = of_match_device(sh_msiof_match, &pdev->dev);
+	if (of_id) {
+		p->chipdata = of_id->data;
 		p->info = sh_msiof_spi_parse_dt(&pdev->dev);
-	else
+	} else {
+		p->chipdata = (const void *)pdev->id_entry->driver_data;
 		p->info = dev_get_platdata(&pdev->dev);
+	}
 
 	if (!p->info) {
 		dev_err(&pdev->dev, "failed to obtain device info\n");
@@ -756,11 +778,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	p->pdev = pdev;
 	pm_runtime_enable(&pdev->dev);
 
-	/* The standard version of MSIOF use 64 word FIFOs */
-	p->tx_fifo_size = DEFAULT_TX_FIFO_SIZE;
-	p->rx_fifo_size = DEFAULT_RX_FIFO_SIZE;
-
 	/* Platform data may override FIFO sizes */
+	p->tx_fifo_size = p->chipdata->tx_fifo_size;
+	p->rx_fifo_size = p->chipdata->rx_fifo_size;
 	if (p->info->tx_fifo_override)
 		p->tx_fifo_size = p->info->tx_fifo_override;
 	if (p->info->rx_fifo_override)
@@ -810,18 +830,16 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
 	return ret;
 }
 
-#ifdef CONFIG_OF
-static const struct of_device_id sh_msiof_match[] = {
-	{ .compatible = "renesas,sh-msiof", },
-	{ .compatible = "renesas,sh-mobile-msiof", },
+static struct platform_device_id spi_driver_ids[] = {
+	{ "spi_sh_msiof",	(kernel_ulong_t)&sh_data },
 	{},
 };
-MODULE_DEVICE_TABLE(of, sh_msiof_match);
-#endif
+MODULE_DEVICE_TABLE(platform, spi_driver_ids);
 
 static struct platform_driver sh_msiof_spi_drv = {
 	.probe		= sh_msiof_spi_probe,
 	.remove		= sh_msiof_spi_remove,
+	.id_table	= spi_driver_ids,
 	.driver		= {
 		.name		= "spi_sh_msiof",
 		.owner		= THIS_MODULE,
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v2 3/6 spi: sh-msiof: Add support for R-Car H2 and M2

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

Add support for the MSIOF variant in the R-Car H2 (r8a7790) and M2 (r8a7791) SoCs.

Binding documentation:
- Add future-proof "renesas,msiof-<soctype>" compatible values,
- The default for "renesas,rx-fifo-size" is 256 on R-Car H2 and M2,
- "renesas,tx-fifo-size" and "renesas,rx-fifo-size" are deprecated for soctype-specific bindings,
- Add example bindings.

Implementation:
- MSIOF on R-Car H2 and M2 requires the transmission of dummy data if data is being received only (cfr. "Set SICTR.TSCKE to 1" and "Write dummy transmission data to SITFDR" in paragraph "Transmit and Receive Procedures" of the Hardware User's Manual).
- As RX depends on TX, MSIOF on R-Car H2 and M2 also lacks the RSCR register (Receive Clock Select Register), and some bits in the RMDR1 (Receive Mode Register 1) and TMDR2 (Transmit Mode Register 2) registers.
- Use the recently introduced SPI_MASTER_MUST_TX flag to enable support for dummy transmission in the SPI core, and to differentiate from other MSIOF implementations in code paths that need this.
- New DT compatible values ("renesas,msiof-r8a7790" and "renesas,msiof-r8a7791") are added, as well as new platform device names ("spi_r8a7790_msiof" and "spi_r8a7791_msiof").
- The default RX FIFO size is 256 words on R-Car H2 and M2.

This is loosely based on a set of patches from Takashi Yoshii <[email protected]>.

---
v2:
- Rebased on top of new "spi: sh-msiof: Move default FIFO sizes to device ID data",
- The default RX FIFO size is 256 words on R-Car H2 and M2,
- Deprecated overriding the FIFO size,
- Synced DT example with node from real DTS.

 Documentation/devicetree/bindings/spi/sh-msiof.txt |   23 ++++++++++++++++++--
 drivers/spi/spi-sh-msiof.c                         |   23 +++++++++++++++++---
 2 files changed, 41 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/spi/sh-msiof.txt +21 -2
index eae3c8c9300e..1f0cb33763a1 100644
@@ -1,8 +1,13 @@
 Renesas MSIOF spi controller
 
 Required properties:
-- compatible           : "renesas,sh-msiof" for SuperH, or
+- compatible           : "renesas,msiof-<soctype>" for SoCs,
+			 "renesas,sh-msiof" for SuperH, or
 			 "renesas,sh-mobile-msiof" for SH Mobile series.
+			 Examples with soctypes are:
+			 "renesas,msiof-sh7724" (SH)
+			 "renesas,msiof-r8a7790" (R-Car H2)
+			 "renesas,msiof-r8a7791" (R-Car M2)
 - reg                  : Offset and length of the register set for the device
 - interrupt-parent     : The phandle for the interrupt controller that
 			 services interrupts for this device
@@ -13,10 +18,24 @@ Required properties:
 Optional properties:
 - clocks               : Must contain a reference to the functional clock.
 - num-cs               : Total number of chip-selects (default is 1)
+
+Optional properties, deprecated for soctype-specific bindings:
 - renesas,tx-fifo-size : Overrides the default tx fifo size given in words
 			 (default is 64)
 - renesas,rx-fifo-size : Overrides the default rx fifo size given in words
-			 (default is 64)
+			 (default is 64, or 256 on R-Car H2 and M2)
 
 Pinctrl properties might be needed, too.  See
 Documentation/devicetree/bindings/pinctrl/renesas,*.
+
+Example:
+
+	msiof0: spi@e6e20000 {
+		compatible = "renesas,msiof-r8a7791";
+		reg = <0 0xe6e20000 0 0x0064>;
+		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
drivers/spi/spi-sh-msiof.c +20 -3
index bf389184924d..3baef2bacaed 100644
@@ -34,6 +34,7 @@
 struct sh_msiof_chipdata {
 	u16 tx_fifo_size;
 	u16 rx_fifo_size;
+	u16 master_flags;
 };
 
 struct sh_msiof_spi_priv {
@@ -214,7 +215,8 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
 	k = min_t(int, k, ARRAY_SIZE(sh_msiof_spi_clk_table) - 1);
 
 	sh_msiof_write(p, TSCR, sh_msiof_spi_clk_table[k].scr);
-	sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
+	if (!(p->chipdata->master_flags & SPI_MASTER_MUST_TX))
+		sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
 }
 
 static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
@@ -237,6 +239,10 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
 	tmp |= !cs_high << MDR1_SYNCAC_SHIFT;
 	tmp |= lsb_first << MDR1_BITLSB_SHIFT;
 	sh_msiof_write(p, TMDR1, tmp | MDR1_TRMD | TMDR1_PCON);
+	if (p->chipdata->master_flags & SPI_MASTER_MUST_TX) {
+		/* These bits are reserved if RX needs TX */
+		tmp &= ~0x0000ffff;
+	}
 	sh_msiof_write(p, RMDR1, tmp);
 
 	tmp = 0;
@@ -257,7 +263,7 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
 {
 	u32 dr2 = MDR2_BITLEN1(bits) | MDR2_WDLEN1(words);
 
-	if (tx_buf)
+	if (tx_buf || (p->chipdata->master_flags & SPI_MASTER_MUST_TX))
 		sh_msiof_write(p, TMDR2, dr2);
 	else
 		sh_msiof_write(p, TMDR2, dr2 | MDR2_GRPMASK1);
@@ -666,11 +672,20 @@ static u32 sh_msiof_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
 static const struct sh_msiof_chipdata sh_data = {
 	.tx_fifo_size = 64,
 	.rx_fifo_size = 64,
+	.master_flags = 0,
+};
+
+static const struct sh_msiof_chipdata r8a779x_data = {
+	.tx_fifo_size = 64,
+	.rx_fifo_size = 256,
+	.master_flags = SPI_MASTER_MUST_TX,
 };
 
 static const struct of_device_id sh_msiof_match[] = {
 	{ .compatible = "renesas,sh-msiof",        .data = &sh_data },
 	{ .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
+	{ .compatible = "renesas,msiof-r8a7790",   .data = &r8a779x_data },
+	{ .compatible = "renesas,msiof-r8a7791",   .data = &r8a779x_data },
 	{},
 };
 MODULE_DEVICE_TABLE(of, sh_msiof_match);
@@ -789,7 +804,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	/* init master and bitbang code */
 	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
 	master->mode_bits |= SPI_LSB_FIRST | SPI_3WIRE;
-	master->flags = 0;
+	master->flags = p->chipdata->master_flags;
 	master->bus_num = pdev->id;
 	master->dev.of_node = pdev->dev.of_node;
 	master->num_chipselect = p->info->num_chipselect;
@@ -832,6 +847,8 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
 
 static struct platform_device_id spi_driver_ids[] = {
 	{ "spi_sh_msiof",	(kernel_ulong_t)&sh_data },
+	{ "spi_r8a7790_msiof",	(kernel_ulong_t)&r8a779x_data },
+	{ "spi_r8a7791_msiof",	(kernel_ulong_t)&r8a779x_data },
 	{},
 };
 MODULE_DEVICE_TABLE(platform, spi_driver_ids);
Signature · 1 line
1.7.9.5
#4 lore raw

Hi Geert,

Thank you for the patch.

Overall the series is great. I ran some time ago into issues with CCF due to the driver use of spi-bitbang, I'm happy to see this being fixed, thanks a lot. I have one small comment below though.

Quoted 53 lines · On Tuesday 25 February 2014 11:21:10 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

Add support for the MSIOF variant in the R-Car H2 (r8a7790) and M2 (r8a7791) SoCs.

Binding documentation:
- Add future-proof "renesas,msiof-<soctype>" compatible values,
- The default for "renesas,rx-fifo-size" is 256 on R-Car H2 and M2,
- "renesas,tx-fifo-size" and "renesas,rx-fifo-size" are deprecated for soctype-specific bindings,
- Add example bindings.

Implementation:
- MSIOF on R-Car H2 and M2 requires the transmission of dummy data if data is being received only (cfr. "Set SICTR.TSCKE to 1" and "Write dummy transmission data to SITFDR" in paragraph "Transmit and Receive Procedures" of the Hardware User's Manual).
- As RX depends on TX, MSIOF on R-Car H2 and M2 also lacks the RSCR register (Receive Clock Select Register), and some bits in the RMDR1 (Receive Mode Register 1) and TMDR2 (Transmit Mode Register 2) registers.
- Use the recently introduced SPI_MASTER_MUST_TX flag to enable support for dummy transmission in the SPI core, and to differentiate from other MSIOF implementations in code paths that need this.
- New DT compatible values ("renesas,msiof-r8a7790" and "renesas,msiof-r8a7791") are added, as well as new platform device names ("spi_r8a7790_msiof" and "spi_r8a7791_msiof").
- The default RX FIFO size is 256 words on R-Car H2 and M2.

This is loosely based on a set of patches from Takashi Yoshii <[email protected]>.

---
v2:
- Rebased on top of new "spi: sh-msiof: Move default FIFO sizes to device ID data",
- The default RX FIFO size is 256 words on R-Car H2 and M2,
- Deprecated overriding the FIFO size,
- Synced DT example with node from real DTS.

 Documentation/devicetree/bindings/spi/sh-msiof.txt |   23 +++++++++++++++--
 drivers/spi/spi-sh-msiof.c                         |   23 ++++++++++++++---
 2 files changed, 41 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/spi/sh-msiof.txt index eae3c8c9300e..1f0cb33763a1 100644

Documentation/devicetree/bindings/spi/sh-msiof.txt line 8

Quoted 9 lines
Documentation/devicetree/bindings/spi/sh-msiof.txt +4 -1
@@ -1,8 +1,13 @@
 Renesas MSIOF spi controller
 
 Required properties:
-- compatible           : "renesas,sh-msiof" for SuperH, or
+- compatible           : "renesas,msiof-<soctype>" for SoCs,
+			 "renesas,sh-msiof" for SuperH, or
 			 "renesas,sh-mobile-msiof" for SH Mobile series.
+			 Examples with soctypes are:
+			 "renesas,msiof-sh7724" (SH)

Given that the driver doesn't handle the "renesas,msiof-sh7724" compatible string this might not be a good example. Furthermore SuperH doesn't have DT support. I would thus drop the "renesas,sh-msiof" compatible string from patch 1/6 and wouldn't mention sh7724 here. I very much doubt that someone would have developed DT support for SuperH on the side and shipped products that would be broken by this change :-)

Quoted 114 lines
Documentation/devicetree/bindings/spi/sh-msiof.txt +2 -0
+			 "renesas,msiof-r8a7790" (R-Car H2)
+			 "renesas,msiof-r8a7791" (R-Car M2)
 - reg                  : Offset and length of the register set for the

device - interrupt-parent : The phandle for the interrupt controller
that services interrupts for this device

Documentation/devicetree/bindings/spi/sh-msiof.txt +15 -1
@@ -13,10 +18,24 @@ Required properties:
 Optional properties:
 - clocks               : Must contain a reference to the functional clock.
 - num-cs               : Total number of chip-selects (default is 1)
+
+Optional properties, deprecated for soctype-specific bindings:
 - renesas,tx-fifo-size : Overrides the default tx fifo size given in words
 			 (default is 64)
 - renesas,rx-fifo-size : Overrides the default rx fifo size given in words
-			 (default is 64)
+			 (default is 64, or 256 on R-Car H2 and M2)
 
 Pinctrl properties might be needed, too.  See
 Documentation/devicetree/bindings/pinctrl/renesas,*.
+
+Example:
+
+	msiof0: spi@e6e20000 {
+		compatible = "renesas,msiof-r8a7791";
+		reg = <0 0xe6e20000 0 0x0064>;
+		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
drivers/spi/spi-sh-msiof.c +20 -4
index bf389184924d..3baef2bacaed 100644
@@ -34,6 +34,7 @@
 struct sh_msiof_chipdata {
 	u16 tx_fifo_size;
 	u16 rx_fifo_size;
+	u16 master_flags;
 };
 
 struct sh_msiof_spi_priv {
@@ -214,7 +215,8 @@ static void sh_msiof_spi_set_clk_regs(struct
 sh_msiof_spi_priv *p, k = min_t(int, k, ARRAY_SIZE(sh_msiof_spi_clk_table)
- 1);
 
 	sh_msiof_write(p, TSCR, sh_msiof_spi_clk_table[k].scr);
-	sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
+	if (!(p->chipdata->master_flags & SPI_MASTER_MUST_TX))
+		sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
 }
 
 static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
@@ -237,6 +239,10 @@ static void sh_msiof_spi_set_pin_regs(struct
 sh_msiof_spi_priv *p, tmp |= !cs_high << MDR1_SYNCAC_SHIFT;
 	tmp |= lsb_first << MDR1_BITLSB_SHIFT;
 	sh_msiof_write(p, TMDR1, tmp | MDR1_TRMD | TMDR1_PCON);
+	if (p->chipdata->master_flags & SPI_MASTER_MUST_TX) {
+		/* These bits are reserved if RX needs TX */
+		tmp &= ~0x0000ffff;
+	}
 	sh_msiof_write(p, RMDR1, tmp);
 
 	tmp = 0;
@@ -257,7 +263,7 @@ static void sh_msiof_spi_set_mode_regs(struct
 sh_msiof_spi_priv *p, {
 	u32 dr2 = MDR2_BITLEN1(bits) | MDR2_WDLEN1(words);
 
-	if (tx_buf)
+	if (tx_buf || (p->chipdata->master_flags & SPI_MASTER_MUST_TX))
 		sh_msiof_write(p, TMDR2, dr2);
 	else
 		sh_msiof_write(p, TMDR2, dr2 | MDR2_GRPMASK1);
@@ -666,11 +672,20 @@ static u32 sh_msiof_spi_txrx_word(struct spi_device
 *spi, unsigned nsecs, static const struct sh_msiof_chipdata sh_data = {
 	.tx_fifo_size = 64,
 	.rx_fifo_size = 64,
+	.master_flags = 0,
+};
+
+static const struct sh_msiof_chipdata r8a779x_data = {
+	.tx_fifo_size = 64,
+	.rx_fifo_size = 256,
+	.master_flags = SPI_MASTER_MUST_TX,
 };
 
 static const struct of_device_id sh_msiof_match[] = {
 	{ .compatible = "renesas,sh-msiof",        .data = &sh_data },
 	{ .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
+	{ .compatible = "renesas,msiof-r8a7790",   .data = &r8a779x_data },
+	{ .compatible = "renesas,msiof-r8a7791",   .data = &r8a779x_data },
 	{},
 };
 MODULE_DEVICE_TABLE(of, sh_msiof_match);
@@ -789,7 +804,7 @@ static int sh_msiof_spi_probe(struct platform_device
 *pdev) /* init master and bitbang code */
 	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
 	master->mode_bits |= SPI_LSB_FIRST | SPI_3WIRE;
-	master->flags = 0;
+	master->flags = p->chipdata->master_flags;
 	master->bus_num = pdev->id;
 	master->dev.of_node = pdev->dev.of_node;
 	master->num_chipselect = p->info->num_chipselect;
@@ -832,6 +847,8 @@ static int sh_msiof_spi_remove(struct platform_device
 *pdev)
 
 static struct platform_device_id spi_driver_ids[] = {
 	{ "spi_sh_msiof",	(kernel_ulong_t)&sh_data },
+	{ "spi_r8a7790_msiof",	(kernel_ulong_t)&r8a779x_data },
+	{ "spi_r8a7791_msiof",	(kernel_ulong_t)&r8a779x_data },
 	{},
 };

MODULE_DEVICE_TABLE(platform, spi_driver_ids);

Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Hi Laurent,

Quoted 8 lines · Laurent Pinchart
Quoted 8 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/spi/sh-msiof.txt index eae3c8c9300e..1f0cb33763a1 100644

Documentation/devicetree/bindings/spi/sh-msiof.txt +0 -0
@@ -1,8 +1,13 @@
 Renesas MSIOF spi controller
 
Quoted 14 lines

Documentation/devicetree/bindings/spi/sh-msiof.txt line 8

Quoted 7 lines
Documentation/devicetree/bindings/spi/sh-msiof.txt +4 -1
 Required properties:
-- compatible           : "renesas,sh-msiof" for SuperH, or
+- compatible           : "renesas,msiof-<soctype>" for SoCs,
+                      "renesas,sh-msiof" for SuperH, or
                       "renesas,sh-mobile-msiof" for SH Mobile series.
+                      Examples with soctypes are:
+                      "renesas,msiof-sh7724" (SH)

Given that the driver doesn't handle the "renesas,msiof-sh7724" compatible string this might not be a good example. Furthermore SuperH doesn't have DT support. I would thus drop the "renesas,sh-msiof" compatible string from patch 1/6 and wouldn't mention sh7724 here. I very much doubt that someone would have developed DT support for SuperH on the side and shipped products that would be broken by this change :-)

Right. Originally I had 'or "renesas,sh-msiof" as fallback', but the fallbacks have been dropped, so it indeed won't work with just "renesas,msiof-sh7724". I'll fix that.

Thanks for your review!

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

#6 lore raw
In reply to Laurent Pinchart
Quoted 8 lines · Laurent Pinchart
Quoted 8 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/spi/sh-msiof.txt index eae3c8c9300e..1f0cb33763a1 100644

Documentation/devicetree/bindings/spi/sh-msiof.txt +0 -0
@@ -1,8 +1,13 @@
 Renesas MSIOF spi controller
 
Quoted 14 lines

Documentation/devicetree/bindings/spi/sh-msiof.txt line 8

Quoted 7 lines
Documentation/devicetree/bindings/spi/sh-msiof.txt +4 -1
 Required properties:
-- compatible           : "renesas,sh-msiof" for SuperH, or
+- compatible           : "renesas,msiof-<soctype>" for SoCs,
+                      "renesas,sh-msiof" for SuperH, or
                       "renesas,sh-mobile-msiof" for SH Mobile series.
+                      Examples with soctypes are:
+                      "renesas,msiof-sh7724" (SH)

Given that the driver doesn't handle the "renesas,msiof-sh7724" compatible string this might not be a good example. Furthermore SuperH doesn't have DT support. I would thus drop the "renesas,sh-msiof" compatible string from patch 1/6 and wouldn't mention sh7724 here. I very much doubt that someone would have developed DT support for SuperH on the side and shipped products that would be broken by this change :-)

Upon reading your comment again: do you suggest to also remove the plain "renesas,sh-msiof"? That one was present before, since DT support was added to the driver in

commit cf9c86efecf9510e62388fd174cf607671c59fa3

Author: Bastian Hecht <[email protected]>
Date:   Wed Dec 12 12:54:48 2012 +0100

spi/sh-msiof: Add device tree parsing to driver

This adds the capability to retrieve setup data from the device tree node. The usage of platform data is still available.

So I prefer not to remove any pre-existing compatible values. Do you agree?

Thanks!

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

#7 lore raw

Hi Geert,

Quoted 35 lines · On Thursday 27 February 2014 09:39:54 Geert Uytterhoeven wrote:
Quoted 9 lines · Laurent Pinchart
Quoted 9 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/spi/sh-msiof.txt index eae3c8c9300e..1f0cb33763a1 100644

Documentation/devicetree/bindings/spi/sh-msiof.txt +0 -0
@@ -1,8 +1,13 @@
 
 Renesas MSIOF spi controller
 
Quoted 14 lines

Documentation/devicetree/bindings/spi/sh-msiof.txt line 8

Quoted 7 lines
Documentation/devicetree/bindings/spi/sh-msiof.txt +4 -1
 Required properties:
-- compatible           : "renesas,sh-msiof" for SuperH, or
+- compatible           : "renesas,msiof-<soctype>" for SoCs,
+                      "renesas,sh-msiof" for SuperH, or
                       "renesas,sh-mobile-msiof" for SH Mobile series.
+                      Examples with soctypes are:
+                      "renesas,msiof-sh7724" (SH)

Given that the driver doesn't handle the "renesas,msiof-sh7724" compatible string this might not be a good example. Furthermore SuperH doesn't have DT support. I would thus drop the "renesas,sh-msiof" compatible string from patch 1/6 and wouldn't mention sh7724 here. I very much doubt that someone would have developed DT support for SuperH on the side and shipped products that would be broken by this change :-)

Upon reading your comment again: do you suggest to also remove the plain "renesas,sh-msiof"? That one was present before, since DT support was added to the driver in

commit cf9c86efecf9510e62388fd174cf607671c59fa3

Author: Bastian Hecht <[email protected]>
Date:   Wed Dec 12 12:54:48 2012 +0100

spi/sh-msiof: Add device tree parsing to driver

Quoted 8 lines

This adds the capability to retrieve setup data from the device tree node. The usage of platform data is still available.

So I prefer not to remove any pre-existing compatible values. Do you agree?

I'd like to remove it (in a separate patch) if we can. The reason is that keeping the DT ABI both forward- and backward-compatible is pretty painful enough without having to care about compatibility strings that have no user. I'd rather work on adding DT support for SuperH MSIOF later when we'll have a platform we can test it on, instead of trying to guess now what the needs will be, get users later and realize even later on that we made a mistake that we can't fix because those users will have DT binaries in the wild. Every unneeded bit of DT bindings that we keep in the kernel is one potential problem for future binary compatibility.

Signature · 3 lines
Regards,

Laurent Pinchart
#8 lore raw
Quoted 33 lines · Laurent Pinchart
Quoted 24 lines
Quoted 7 lines

Documentation/devicetree/bindings/spi/sh-msiof.txt line 8

Quoted 6 lines

-- compatible : "renesas,sh-msiof" for SuperH, or
+- compatible : "renesas,msiof-<soctype>" for SoCs,

Documentation/devicetree/bindings/spi/sh-msiof.txt +3 -0
+                      "renesas,sh-msiof" for SuperH, or
                       "renesas,sh-mobile-msiof" for SH Mobile series.
+                      Examples with soctypes are:
+                      "renesas,msiof-sh7724" (SH)
Quoted 6 lines

Given that the driver doesn't handle the "renesas,msiof-sh7724" compatible string this might not be a good example. Furthermore SuperH doesn't have DT support. I would thus drop the "renesas,sh-msiof" compatible string from patch 1/6 and wouldn't mention sh7724 here. I very much doubt that someone would have developed DT support for SuperH on the side and shipped products that would be broken by this change :-)

Upon reading your comment again: do you suggest to also remove the plain "renesas,sh-msiof"? That one was present before, since DT support was added to the driver in

commit cf9c86efecf9510e62388fd174cf607671c59fa3

Author: Bastian Hecht <[email protected]>
Date:   Wed Dec 12 12:54:48 2012 +0100

spi/sh-msiof: Add device tree parsing to driver

Quoted 8 lines

This adds the capability to retrieve setup data from the device tree node. The usage of platform data is still available.

So I prefer not to remove any pre-existing compatible values. Do you agree?

Quoted 9 lines

I'd like to remove it (in a separate patch) if we can. The reason is that keeping the DT ABI both forward- and backward-compatible is pretty painful enough without having to care about compatibility strings that have no user. I'd rather work on adding DT support for SuperH MSIOF later when we'll have a platform we can test it on, instead of trying to guess now what the needs will be, get users later and realize even later on that we made a mistake that we can't fix because those users will have DT binaries in the wild. Every unneeded bit of DT bindings that we keep in the kernel is one potential problem for future binary compatibility.

I agree about the complexity of keeping the DT ABI forward- and backward-compatible.

However, in this case I don't think it hurts that much to just keep it:
- DT compatible values and platform device names are kept in sync through a pointer to the same struct sh_msiof_chipdata, so there's not much maintenance needed.
- DT compatible "renesas,sh-msiof" means exactly the same as the "spi_sh_msiof" platform device name, which is currently in use.

So even if SuperH never moves to DT, we have to keep support for that specific MSIOF implementation, unless we drop the platform device version, too (Hmm, maybe that's what you're alluding to ;-)

And if we remove "renesas,sh-msiof", we should probably remove "renesas,sh-mobile-msiof", too, as there are no current users, and it also assumes the same MSIOF implementation?

Bastian: What was your real plan with "renesas,sh-msiof" and "renesas,sh-mobile-msiof"?

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

#9 lore raw

Hi Geert,

Quoted 55 lines · On Thursday 27 February 2014 12:09:52 Geert Uytterhoeven wrote:
Quoted 34 lines · Laurent Pinchart
Quoted 25 lines
Quoted 7 lines

Documentation/devicetree/bindings/spi/sh-msiof.txt line 8

Quoted 6 lines

-- compatible : "renesas,sh-msiof" for SuperH, or
+- compatible : "renesas,msiof-<soctype>" for SoCs,

Documentation/devicetree/bindings/spi/sh-msiof.txt +3 -0
+                      "renesas,sh-msiof" for SuperH, or
                       "renesas,sh-mobile-msiof" for SH Mobile series.
+                      Examples with soctypes are:
+                      "renesas,msiof-sh7724" (SH)
Quoted 7 lines

Given that the driver doesn't handle the "renesas,msiof-sh7724" compatible string this might not be a good example. Furthermore SuperH doesn't have DT support. I would thus drop the "renesas,sh-msiof" compatible string from patch 1/6 and wouldn't mention sh7724 here. I very much doubt that someone would have developed DT support for SuperH on the side and shipped products that would be broken by this change :-)

Upon reading your comment again: do you suggest to also remove the plain "renesas,sh-msiof"? That one was present before, since DT support was added to the driver in

commit cf9c86efecf9510e62388fd174cf607671c59fa3

Author: Bastian Hecht <[email protected]>
Date:   Wed Dec 12 12:54:48 2012 +0100

spi/sh-msiof: Add device tree parsing to driver

Quoted 8 lines

This adds the capability to retrieve setup data from the device tree node. The usage of platform data is still available.

So I prefer not to remove any pre-existing compatible values. Do you agree?

Quoted 9 lines

I'd like to remove it (in a separate patch) if we can. The reason is that keeping the DT ABI both forward- and backward-compatible is pretty painful enough without having to care about compatibility strings that have no user. I'd rather work on adding DT support for SuperH MSIOF later when we'll have a platform we can test it on, instead of trying to guess now what the needs will be, get users later and realize even later on that we made a mistake that we can't fix because those users will have DT binaries in the wild. Every unneeded bit of DT bindings that we keep in the kernel is one potential problem for future binary compatibility.

I agree about the complexity of keeping the DT ABI forward- and backward-compatible.

However, in this case I don't think it hurts that much to just keep it:
- DT compatible values and platform device names are kept in sync through a pointer to the same struct sh_msiof_chipdata, so there's not much maintenance needed.
- DT compatible "renesas,sh-msiof" means exactly the same as the "spi_sh_msiof" platform device name, which is currently in use.

Quoted 3 lines

So even if SuperH never moves to DT, we have to keep support for that specific MSIOF implementation, unless we drop the platform device version, too (Hmm, maybe that's what you're alluding to ;-)

Of course, I'm not trying to get support for SuperH dropped, I'm sure someone would realize and complain before the end of the century ;-)

Quoted 3 lines

And if we remove "renesas,sh-msiof", we should probably remove "renesas,sh-mobile-msiof", too, as there are no current users, and it also assumes the same MSIOF implementation?

I'm not too familiar with the MSIOF hardware, can "renesas,sh-mobile-msiof" be used as a fallback for the currently support ARM SoCs ?

Quoted 2 lines

Bastian: What was your real plan with "renesas,sh-msiof" and "renesas,sh-mobile-msiof"?

Signature · 3 lines
Regards,

Laurent Pinchart
#10 lore raw

Hi Laurent,

Quoted 6 lines · Laurent Pinchart
Quoted 3 lines

And if we remove "renesas,sh-msiof", we should probably remove "renesas,sh-mobile-msiof", too, as there are no current users, and it also assumes the same MSIOF implementation?

I'm not too familiar with the MSIOF hardware, can "renesas,sh-mobile-msiof" be used as a fallback for the currently support ARM SoCs ?

r8a73a4/APE6: No
r8a7740/A1: Maybe (not 100% clear to me from the datasheet) r8a7790/R-Car H2: No
r8a7791/R-Car M2: No
sh7372/AP4: No information
sh73a0/AG5: No information

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

#11 lore raw

PATCH v2 4/6 spi: sh-msiof: Move clock management to (un)prepare_message()

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

Move clock management and pin configuration from the bitbang chipselect() method to the SPI core prepare_message() and unprepare_message() methods.

As spi_master.{,un}prepare_message() is guaranteed to be called in matching pairs, the clock management synchronization is no longer needed.

As sh_msiof_spi_set_pin_regs() is no longer called at spi_master.setup() time (through spi_bitbang_setup() and the spi_bitbang.chipselect() callback), we now have to take care of that ourselves.

---
v2:
- Removed clock management synchronization,
- Configure pins in the .setup() routine.

 drivers/spi/spi-sh-msiof.c |   61 +++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 23 deletions(-)
drivers/spi/spi-sh-msiof.c +38 -23
index 3baef2bacaed..18e3a8d628e9 100644
@@ -45,7 +45,6 @@ struct sh_msiof_spi_priv {
 	const struct sh_msiof_chipdata *chipdata;
 	struct sh_msiof_spi_info *info;
 	struct completion done;
-	unsigned long flags;
 	int tx_fifo_size;
 	int rx_fifo_size;
 };
@@ -458,6 +457,7 @@ static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
 static int sh_msiof_spi_setup(struct spi_device *spi)
 {
 	struct device_node	*np = spi->master->dev.of_node;
+	struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
 
 	if (!np) {
 		/*
@@ -467,12 +467,46 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
 		spi->cs_gpio = (uintptr_t)spi->controller_data;
 	}
 
+	/* Configure pins before deasserting CS */
+	sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
+				  !!(spi->mode & SPI_CPHA),
+				  !!(spi->mode & SPI_3WIRE),
+				  !!(spi->mode & SPI_LSB_FIRST),
+				  !!(spi->mode & SPI_CS_HIGH));
+
 	return spi_bitbang_setup(spi);
 }
 
+static int sh_msiof_prepare_message(struct spi_master *master,
+				    struct spi_message *msg)
+{
+	struct sh_msiof_spi_priv *p = spi_master_get_devdata(master);
+	const struct spi_device *spi = msg->spi;
+
+	pm_runtime_get_sync(&p->pdev->dev);
+	clk_enable(p->clk);
+
+	/* Configure pins before asserting CS */
+	sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
+				  !!(spi->mode & SPI_CPHA),
+				  !!(spi->mode & SPI_3WIRE),
+				  !!(spi->mode & SPI_LSB_FIRST),
+				  !!(spi->mode & SPI_CS_HIGH));
+	return 0;
+}
+
+static int sh_msiof_unprepare_message(struct spi_master *master,
+				      struct spi_message *msg)
+{
+	struct sh_msiof_spi_priv *p = spi_master_get_devdata(master);
+
+	clk_disable(p->clk);
+	pm_runtime_put(&p->pdev->dev);
+	return 0;
+}
+
 static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
 {
-	struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
 	int value;
 
 	/* chip select is active low unless SPI_CS_HIGH is set */
@@ -481,29 +515,8 @@ static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
 	else
 		value = (is_on = BITBANG_CS_ACTIVE) ? 0 : 1;
 
-	if (is_on = BITBANG_CS_ACTIVE) {
-		if (!test_and_set_bit(0, &p->flags)) {
-			pm_runtime_get_sync(&p->pdev->dev);
-			clk_enable(p->clk);
-		}
-
-		/* Configure pins before asserting CS */
-		sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
-					  !!(spi->mode & SPI_CPHA),
-					  !!(spi->mode & SPI_3WIRE),
-					  !!(spi->mode & SPI_LSB_FIRST),
-					  !!(spi->mode & SPI_CS_HIGH));
-	}
-
 	if (spi->cs_gpio >= 0)
 		gpio_set_value(spi->cs_gpio, value);
-
-	if (is_on = BITBANG_CS_INACTIVE) {
-		if (test_and_clear_bit(0, &p->flags)) {
-			clk_disable(p->clk);
-			pm_runtime_put(&p->pdev->dev);
-		}
-	}
 }
 
 static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
@@ -810,6 +823,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	master->num_chipselect = p->info->num_chipselect;
 	master->setup = sh_msiof_spi_setup;
 	master->cleanup = spi_bitbang_cleanup;
+	master->prepare_message = sh_msiof_prepare_message;
+	master->unprepare_message = sh_msiof_unprepare_message;
 
 	p->bitbang.master = master;
 	p->bitbang.chipselect = sh_msiof_spi_chipselect;
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v2 5/6 spi: sh-msiof: Convert to let spi core validate xfer->bits_per_word

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

Set bits_per_word_mask so the spi core will reject transfers that attempt to use an unsupported bits_per_word value.

---
v2:
- No changes

 drivers/spi/spi-sh-msiof.c |   19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/spi/spi-sh-msiof.c +2 -17
index 18e3a8d628e9..27536933d734 100644
@@ -438,22 +438,6 @@ static u32 sh_msiof_spi_hz(struct spi_device *spi, struct spi_transfer *t)
 	return hz;
 }
 
-static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
-				       struct spi_transfer *t)
-{
-	int bits;
-
-	/* noting to check hz values against since parent clock is disabled */
-
-	bits = sh_msiof_spi_bits(spi, t);
-	if (bits < 8)
-		return -EINVAL;
-	if (bits > 32)
-		return -EINVAL;
-
-	return spi_bitbang_setup_transfer(spi, t);
-}
-
 static int sh_msiof_spi_setup(struct spi_device *spi)
 {
 	struct device_node	*np = spi->master->dev.of_node;
@@ -825,10 +809,11 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	master->cleanup = spi_bitbang_cleanup;
 	master->prepare_message = sh_msiof_prepare_message;
 	master->unprepare_message = sh_msiof_unprepare_message;
+	master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
 
 	p->bitbang.master = master;
 	p->bitbang.chipselect = sh_msiof_spi_chipselect;
-	p->bitbang.setup_transfer = sh_msiof_spi_setup_transfer;
+	p->bitbang.setup_transfer = spi_bitbang_setup_transfer;
 	p->bitbang.txrx_bufs = sh_msiof_spi_txrx;
 	p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word;
 	p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word;
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v2 6/6 spi: sh-msiof: Use core message handling instead of spi-bitbang

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

The only remaining feature of spi-bitbang used by this driver is the chipselect() callback, which just does conditional GPIO. This is handled fine by the SPI core's spi_set_cs(), hence switch the driver to use the core message handling through our own transfer_one() method.

As the (optional) GPIO CS is no longer deasserted at spi_master.setup() time (through spi_bitbang_setup() and the spi_bitbang.chipselect() callback), we now have to take care of that ourselves.

Remove the call to spi_master_put() in sh_msiof_spi_remove(), as our SPI master is now registered using devm_spi_register_master() (spi_bitbang_start() uses the non-managed version).

---
v2:
- Deassert (optional) GPIO CS in sh_msiof_spi_setup()

 drivers/spi/Kconfig        |    1 -
 drivers/spi/spi-sh-msiof.c |   67 +++++++++++++-------------------------------
 2 files changed, 20 insertions(+), 48 deletions(-)
drivers/spi/Kconfig +0 -1
index 64d8cac0f326..17df2069fca2 100644
@@ -429,7 +429,6 @@ config SPI_SH_MSIOF
 	tristate "SuperH MSIOF SPI controller"
 	depends on HAVE_CLK
 	depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
-	select SPI_BITBANG
 	help
 	  SPI driver for SuperH and SH Mobile MSIOF blocks.
 
drivers/spi/spi-sh-msiof.c +20 -47

129 lines not on this page · raw message

Signature · 1 line
1.7.9.5
Acked-by on the v2 series
#14 lore raw
In reply to Geert Uytterhoeven
Quoted 15 lines · Geert Uytterhoeven

Hi Mark,

This patch series refactors the sh-msiof SPI driver and adds support for the MSIOF variant in the Renesas R-Car H2 (r8a7790) and M2 (r8a7791) SoCs.

It was tested on the Lager and Koelsch development boards, using a dummy driver for the Renesas r2a11302ft PMIC that reads out the PMIC's version ID.

[1/6] spi: sh-msiof: Improve bindings
[2/6] spi: sh-msiof: Move default FIFO sizes to device ID data [3/6] spi: sh-msiof: Add support for R-Car H2 and M2
[4/6] spi: sh-msiof: Move clock management to (un)prepare_message() [5/6] spi: sh-msiof: Convert to let spi core validate xfer->bits_per_word [6/6] spi: sh-msiof: Use core message handling instead of spi-bitbang

Quoted 5 lines

These are (reworked versions of) the remaining patches not taken from v1. Changelogs are available in the individual patches.

Some of this work was based on a patch series by Takashi Yoshii <[email protected]>.

Hi Geert,

Thanks for this updated version. I like the way you reworked the DT bindings to let the FIFO configuration stay in the driver. Also getting rid of the now-not-needed bitbang dependency is a great thing. All these patches look good to me.

Cheers,

/ magnus

maintainer Applied
#15 lore raw
In reply to Geert Uytterhoeven
Quoted 4 lines · Geert Uytterhoeven

Hi Mark,

This patch series refactors the sh-msiof SPI driver and adds support for the MSIOF variant in the Renesas R-Car H2 (r8a7790) and M2 (r8a7791) SoCs.

I applied all these, thanks. Laurent does make a valid point about the fallback, though - can you please send a followup patch which addresses that?