All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] Fix for imx-spi CS GPIOs
@ 2017-11-06 19:46 ` Trent Piepho
  0 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Trent Piepho, Shawn Guo, Sascha Hauer, Fabio Estevam, Mark Brown

Changes from V1:
 * Collected reviewed bys.
 * Minor change to coding style in one patch.

Changes from V2:
 * Reverted minor coding change from V2, it was right to begin with
 * Have imx-spi also honor "num-cs" property
 * Leak of spi_bitbang on failure needed to be fixed differently
 * Port to linux-next, which has other changes to spi-imx

Changes from V3:
 * Remove leak fix patch which was applied separately.
 * Add documentation about native CS to driver tree bindings document.

CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>,
CC: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Trent Piepho (3):
  spi: imx: GPIO chip select DT property should not be required
  spi: imx: Don't require platform data chipselect array
  ARM: imx: Update spi_imx platform data to reflect current state

 .../devicetree/bindings/spi/fsl-imx-cspi.txt       | 18 ++++++++----
 arch/arm/mach-imx/mach-mx31_3ds.c                  | 18 ++----------
 arch/arm/mach-imx/mach-mx31lilly.c                 | 12 ++------
 arch/arm/mach-imx/mach-mx31lite.c                  | 16 ++---------
 arch/arm/mach-imx/mach-mx31moboard.c               | 17 ++----------
 arch/arm/mach-imx/mach-pcm037_eet.c                |  5 +---
 drivers/spi/spi-imx.c                              | 32 ++++++++++++----------
 include/linux/platform_data/spi-imx.h              | 29 ++++++++++++--------
 8 files changed, 57 insertions(+), 90 deletions(-)

-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 0/3] Fix for imx-spi CS GPIOs
@ 2017-11-06 19:46 ` Trent Piepho
  0 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-arm-kernel

Changes from V1:
 * Collected reviewed bys.
 * Minor change to coding style in one patch.

Changes from V2:
 * Reverted minor coding change from V2, it was right to begin with
 * Have imx-spi also honor "num-cs" property
 * Leak of spi_bitbang on failure needed to be fixed differently
 * Port to linux-next, which has other changes to spi-imx

Changes from V3:
 * Remove leak fix patch which was applied separately.
 * Add documentation about native CS to driver tree bindings document.

CC: Shawn Guo <shawnguo@kernel.org>,
CC: Sascha Hauer <kernel@pengutronix.de>,
CC: Fabio Estevam <fabio.estevam@nxp.com>,
CC: Mark Brown <broonie@kernel.org>

Trent Piepho (3):
  spi: imx: GPIO chip select DT property should not be required
  spi: imx: Don't require platform data chipselect array
  ARM: imx: Update spi_imx platform data to reflect current state

 .../devicetree/bindings/spi/fsl-imx-cspi.txt       | 18 ++++++++----
 arch/arm/mach-imx/mach-mx31_3ds.c                  | 18 ++----------
 arch/arm/mach-imx/mach-mx31lilly.c                 | 12 ++------
 arch/arm/mach-imx/mach-mx31lite.c                  | 16 ++---------
 arch/arm/mach-imx/mach-mx31moboard.c               | 17 ++----------
 arch/arm/mach-imx/mach-pcm037_eet.c                |  5 +---
 drivers/spi/spi-imx.c                              | 32 ++++++++++++----------
 include/linux/platform_data/spi-imx.h              | 29 ++++++++++++--------
 8 files changed, 57 insertions(+), 90 deletions(-)

-- 
2.14.3

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required
  2017-11-06 19:46 ` Trent Piepho
@ 2017-11-06 19:46     ` Trent Piepho
  -1 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Trent Piepho, Mark Brown, Shawn Guo, Sascha Hauer, Fabio Estevam,
	Oleksij Rempel

The driver will fail to load if the device tree property for gpio chip
selects is not specified.  Change the driver to make the property optional.
Also have the driver respect the "num-cs" property in the standard way.

This way one can use the native CS lines using standard bindings instead of
being forced to specify a gpio-cs of <0>.

Since native CS do not work in a commonly useful manner with this
hardware/driver, note in the documention that most users probably should
use GPIO based CS lines rather than native.

CC: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
CC: Oleksij Rempel <o.rempel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
---
 Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt | 18 ++++++++++++------
 drivers/spi/spi-imx.c                                  | 18 ++++++++++--------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
index 5bf13960f7f4..e3c48b20b1a6 100644
--- a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
+++ b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
@@ -12,24 +12,30 @@ Required properties:
   - "fsl,imx53-ecspi" for SPI compatible with the one integrated on i.MX53 and later Soc
 - reg : Offset and length of the register set for the device
 - interrupts : Should contain CSPI/eCSPI interrupt
-- cs-gpios : Specifies the gpio pins to be used for chipselects.
 - clocks : Clock specifiers for both ipg and per clocks.
 - clock-names : Clock names should include both "ipg" and "per"
 See the clock consumer binding,
 	Documentation/devicetree/bindings/clock/clock-bindings.txt
-- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
-		Documentation/devicetree/bindings/dma/dma.txt
-- dma-names: DMA request names should include "tx" and "rx" if present.
 
-Obsolete properties:
-- fsl,spi-num-chipselects : Contains the number of the chipselect
+Recommended properties:
+- cs-gpios : GPIOs to use as chip selects, see spi-bus.txt.  While the native chip
+select lines can be used, they appear to always generate a pulse between each
+word of a transfer.  Most use cases will require GPIO based chip selects to
+generate a valid transaction.
 
 Optional properties:
+- num-cs :  Number of total chip selects, see spi-bus.txt.
+- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
+Documentation/devicetree/bindings/dma/dma.txt.
+- dma-names: DMA request names, if present, should include "tx" and "rx".
 - fsl,spi-rdy-drctl: Integer, representing the value of DRCTL, the register
 controlling the SPI_READY handling. Note that to enable the DRCTL consideration,
 the SPI_READY mode-flag needs to be set too.
 Valid values are: 0 (disabled), 1 (edge-triggered burst) and 2 (level-triggered burst).
 
+Obsolete properties:
+- fsl,spi-num-chipselects : Contains the number of the chipselect
+
 Example:
 
 ecspi@70010000 {
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 301cdb721bad..ad54f8258513 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1523,6 +1523,7 @@ static int spi_imx_probe(struct platform_device *pdev)
 
 	spi_imx->devtype_data = devtype_data;
 
+	/* Get number of chip selects, either platform data or OF */
 	if (mxc_platform_info) {
 		master->num_chipselect = mxc_platform_info->num_chipselect;
 		master->cs_gpios = devm_kzalloc(&master->dev,
@@ -1532,7 +1533,13 @@ static int spi_imx_probe(struct platform_device *pdev)
 
 		for (i = 0; i < master->num_chipselect; i++)
 			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
- 	}
+	} else {
+		u32 num_cs;
+
+		if (!of_property_read_u32(np, "num-cs", &num_cs))
+			master->num_chipselect = num_cs;
+		/* If not preset, default value of 1 is used */
+	}
 
 	spi_imx->bitbang.chipselect = spi_imx_chipselect;
 	spi_imx->bitbang.setup_transfer = spi_imx_setupxfer;
@@ -1619,13 +1626,8 @@ static int spi_imx_probe(struct platform_device *pdev)
 		goto out_clk_put;
 	}
 
-	if (!spi_imx->slave_mode) {
-		if (!master->cs_gpios) {
-			dev_err(&pdev->dev, "No CS GPIOs available\n");
-			ret = -EINVAL;
-			goto out_clk_put;
-		}
-
+	/* Request GPIO CS lines, if any */
+	if (!spi_imx->slave_mode && master->cs_gpios) {
 		for (i = 0; i < master->num_chipselect; i++) {
 			if (!gpio_is_valid(master->cs_gpios[i]))
 				continue;
-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required
@ 2017-11-06 19:46     ` Trent Piepho
  0 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-arm-kernel

The driver will fail to load if the device tree property for gpio chip
selects is not specified.  Change the driver to make the property optional.
Also have the driver respect the "num-cs" property in the standard way.

This way one can use the native CS lines using standard bindings instead of
being forced to specify a gpio-cs of <0>.

Since native CS do not work in a commonly useful manner with this
hardware/driver, note in the documention that most users probably should
use GPIO based CS lines rather than native.

CC: Mark Brown <broonie@kernel.org>
CC: Shawn Guo <shawnguo@kernel.org>
CC: Sascha Hauer <kernel@pengutronix.de>
CC: Fabio Estevam <fabio.estevam@nxp.com>
CC: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt | 18 ++++++++++++------
 drivers/spi/spi-imx.c                                  | 18 ++++++++++--------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
index 5bf13960f7f4..e3c48b20b1a6 100644
--- a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
+++ b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
@@ -12,24 +12,30 @@ Required properties:
   - "fsl,imx53-ecspi" for SPI compatible with the one integrated on i.MX53 and later Soc
 - reg : Offset and length of the register set for the device
 - interrupts : Should contain CSPI/eCSPI interrupt
-- cs-gpios : Specifies the gpio pins to be used for chipselects.
 - clocks : Clock specifiers for both ipg and per clocks.
 - clock-names : Clock names should include both "ipg" and "per"
 See the clock consumer binding,
 	Documentation/devicetree/bindings/clock/clock-bindings.txt
-- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
-		Documentation/devicetree/bindings/dma/dma.txt
-- dma-names: DMA request names should include "tx" and "rx" if present.
 
-Obsolete properties:
-- fsl,spi-num-chipselects : Contains the number of the chipselect
+Recommended properties:
+- cs-gpios : GPIOs to use as chip selects, see spi-bus.txt.  While the native chip
+select lines can be used, they appear to always generate a pulse between each
+word of a transfer.  Most use cases will require GPIO based chip selects to
+generate a valid transaction.
 
 Optional properties:
+- num-cs :  Number of total chip selects, see spi-bus.txt.
+- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
+Documentation/devicetree/bindings/dma/dma.txt.
+- dma-names: DMA request names, if present, should include "tx" and "rx".
 - fsl,spi-rdy-drctl: Integer, representing the value of DRCTL, the register
 controlling the SPI_READY handling. Note that to enable the DRCTL consideration,
 the SPI_READY mode-flag needs to be set too.
 Valid values are: 0 (disabled), 1 (edge-triggered burst) and 2 (level-triggered burst).
 
+Obsolete properties:
+- fsl,spi-num-chipselects : Contains the number of the chipselect
+
 Example:
 
 ecspi at 70010000 {
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 301cdb721bad..ad54f8258513 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1523,6 +1523,7 @@ static int spi_imx_probe(struct platform_device *pdev)
 
 	spi_imx->devtype_data = devtype_data;
 
+	/* Get number of chip selects, either platform data or OF */
 	if (mxc_platform_info) {
 		master->num_chipselect = mxc_platform_info->num_chipselect;
 		master->cs_gpios = devm_kzalloc(&master->dev,
@@ -1532,7 +1533,13 @@ static int spi_imx_probe(struct platform_device *pdev)
 
 		for (i = 0; i < master->num_chipselect; i++)
 			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
- 	}
+	} else {
+		u32 num_cs;
+
+		if (!of_property_read_u32(np, "num-cs", &num_cs))
+			master->num_chipselect = num_cs;
+		/* If not preset, default value of 1 is used */
+	}
 
 	spi_imx->bitbang.chipselect = spi_imx_chipselect;
 	spi_imx->bitbang.setup_transfer = spi_imx_setupxfer;
@@ -1619,13 +1626,8 @@ static int spi_imx_probe(struct platform_device *pdev)
 		goto out_clk_put;
 	}
 
-	if (!spi_imx->slave_mode) {
-		if (!master->cs_gpios) {
-			dev_err(&pdev->dev, "No CS GPIOs available\n");
-			ret = -EINVAL;
-			goto out_clk_put;
-		}
-
+	/* Request GPIO CS lines, if any */
+	if (!spi_imx->slave_mode && master->cs_gpios) {
 		for (i = 0; i < master->num_chipselect; i++) {
 			if (!gpio_is_valid(master->cs_gpios[i]))
 				continue;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 2/3] spi: imx: Don't require platform data chipselect array
  2017-11-06 19:46 ` Trent Piepho
@ 2017-11-06 19:46     ` Trent Piepho
  -1 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Trent Piepho, Shawn Guo, Sascha Hauer, Fabio Estevam, Mark Brown

If the array is not present, assume all chip selects are native.  This
is the standard behavior for SPI masters configured via the device
tree and the behavior of this driver as well when it is configured via
device tree.

This reduces platform data vs DT differences and allows most of the
platform data based boards to remove their chip select arrays.

CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
CC: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
---
 drivers/spi/spi-imx.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index ad54f8258513..5caa6c9524fa 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1526,13 +1526,15 @@ static int spi_imx_probe(struct platform_device *pdev)
 	/* Get number of chip selects, either platform data or OF */
 	if (mxc_platform_info) {
 		master->num_chipselect = mxc_platform_info->num_chipselect;
-		master->cs_gpios = devm_kzalloc(&master->dev,
-			sizeof(int) * master->num_chipselect, GFP_KERNEL);
-		if (!master->cs_gpios)
-			return -ENOMEM;
-
-		for (i = 0; i < master->num_chipselect; i++)
-			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
+		if (mxc_platform_info->chipselect) {
+			master->cs_gpios = devm_kzalloc(&master->dev,
+				sizeof(int) * master->num_chipselect, GFP_KERNEL);
+			if (!master->cs_gpios)
+				return -ENOMEM;
+
+			for (i = 0; i < master->num_chipselect; i++)
+				master->cs_gpios[i] = mxc_platform_info->chipselect[i];
+		}
 	} else {
 		u32 num_cs;
 
-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 2/3] spi: imx: Don't require platform data chipselect array
@ 2017-11-06 19:46     ` Trent Piepho
  0 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-arm-kernel

If the array is not present, assume all chip selects are native.  This
is the standard behavior for SPI masters configured via the device
tree and the behavior of this driver as well when it is configured via
device tree.

This reduces platform data vs DT differences and allows most of the
platform data based boards to remove their chip select arrays.

CC: Shawn Guo <shawnguo@kernel.org>
CC: Sascha Hauer <kernel@pengutronix.de>
CC: Fabio Estevam <fabio.estevam@nxp.com>
CC: Mark Brown <broonie@kernel.org>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 drivers/spi/spi-imx.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index ad54f8258513..5caa6c9524fa 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1526,13 +1526,15 @@ static int spi_imx_probe(struct platform_device *pdev)
 	/* Get number of chip selects, either platform data or OF */
 	if (mxc_platform_info) {
 		master->num_chipselect = mxc_platform_info->num_chipselect;
-		master->cs_gpios = devm_kzalloc(&master->dev,
-			sizeof(int) * master->num_chipselect, GFP_KERNEL);
-		if (!master->cs_gpios)
-			return -ENOMEM;
-
-		for (i = 0; i < master->num_chipselect; i++)
-			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
+		if (mxc_platform_info->chipselect) {
+			master->cs_gpios = devm_kzalloc(&master->dev,
+				sizeof(int) * master->num_chipselect, GFP_KERNEL);
+			if (!master->cs_gpios)
+				return -ENOMEM;
+
+			for (i = 0; i < master->num_chipselect; i++)
+				master->cs_gpios[i] = mxc_platform_info->chipselect[i];
+		}
 	} else {
 		u32 num_cs;
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state
  2017-11-06 19:46 ` Trent Piepho
@ 2017-11-06 19:46     ` Trent Piepho
  -1 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Trent Piepho, Shawn Guo, Sascha Hauer, Fabio Estevam

The docs for the spi_imx platform data still refer to a -32 offset used to
specify a native chip select.  This was removed in commit 602c8f4485cd
("spi: imx: fix use of native chip-selects with devicetree") and no
longer works as documented.  Update documentation.

The macro MXC_SPI_CS() is no longer is needed.

If a board uses all native chip selects, then it's not necessary to
specify a chip select array at all, as all native is the default (this is
how device-tree configured SPI masters work too).  Most of the spi-imx
platform data users have their chip select arrays removed by this patch.

This patch also fixes a bug in mx31moboard introduced in the '602 commit.
When that board was updated in commit 901f26bce64a ("ARM: imx: set
correct chip_select in platform setup") to reflect the SPI change, only
SPI bus 2 was updated and SPI bus 1 was left with non-sequential chip
selects.  The mc13783 spi device on bus 1 had its chip select updated as
if it were on bus 2.

CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
Acked-by: Greg Ungerer <gerg-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
---
 arch/arm/mach-imx/mach-mx31_3ds.c     | 18 ++----------------
 arch/arm/mach-imx/mach-mx31lilly.c    | 12 ++----------
 arch/arm/mach-imx/mach-mx31lite.c     | 16 ++--------------
 arch/arm/mach-imx/mach-mx31moboard.c  | 17 +++--------------
 arch/arm/mach-imx/mach-pcm037_eet.c   |  5 +----
 include/linux/platform_data/spi-imx.h | 29 +++++++++++++++++------------
 6 files changed, 27 insertions(+), 70 deletions(-)

diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
index 68c3f0799d5b..9d87f1dcf7bb 100644
--- a/arch/arm/mach-imx/mach-mx31_3ds.c
+++ b/arch/arm/mach-imx/mach-mx31_3ds.c
@@ -374,26 +374,12 @@ static struct imx_ssi_platform_data mx31_3ds_ssi_pdata = {
 };
 
 /* SPI */
-static int spi0_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-	.chipselect	= spi0_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
-};
-
-static int spi1_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
+	.num_chipselect	= 3,
 };
 
 static const struct spi_imx_master spi1_pdata __initconst = {
-	.chipselect	= spi1_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
+	.num_chipselect	= 3,
 };
 
 static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c
index 6fd463642954..8bf52819d4d9 100644
--- a/arch/arm/mach-imx/mach-mx31lilly.c
+++ b/arch/arm/mach-imx/mach-mx31lilly.c
@@ -226,20 +226,12 @@ static void __init lilly1131_usb_init(void)
 
 /* SPI */
 
-static int spi_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-	.chipselect = spi_internal_chipselect,
-	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
+	.num_chipselect = 3,
 };
 
 static const struct spi_imx_master spi1_pdata __initconst = {
-	.chipselect = spi_internal_chipselect,
-	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
+	.num_chipselect = 3,
 };
 
 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c
index f033a57d5694..fcbaf0070ccf 100644
--- a/arch/arm/mach-imx/mach-mx31lite.c
+++ b/arch/arm/mach-imx/mach-mx31lite.c
@@ -83,15 +83,8 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 };
 
 /* SPI */
-static int spi0_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-	.chipselect	= spi0_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
+	.num_chipselect	= 3,
 };
 
 static const struct mxc_nand_platform_data
@@ -133,13 +126,8 @@ static struct platform_device smsc911x_device = {
  * The MC13783 is the only hard-wired SPI device on the module.
  */
 
-static int spi1_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-};
-
 static const struct spi_imx_master spi1_pdata __initconst = {
-	.chipselect	= spi1_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
+	.num_chipselect	= 1,
 };
 
 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index 7716f83aecdd..643a3d749703 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -152,14 +152,8 @@ static const struct imxi2c_platform_data moboard_i2c1_data __initconst = {
 	.bitrate = 100000,
 };
 
-static int moboard_spi1_cs[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master moboard_spi1_pdata __initconst = {
-	.chipselect	= moboard_spi1_cs,
-	.num_chipselect	= ARRAY_SIZE(moboard_spi1_cs),
+	.num_chipselect	= 3,
 };
 
 static struct regulator_consumer_supply sdhc_consumers[] = {
@@ -296,19 +290,14 @@ static struct spi_board_info moboard_spi_board_info[] __initdata = {
 		/* irq number is run-time assigned */
 		.max_speed_hz = 300000,
 		.bus_num = 1,
-		.chip_select = 1,
+		.chip_select = 0,
 		.platform_data = &moboard_pmic,
 		.mode = SPI_CS_HIGH,
 	},
 };
 
-static int moboard_spi2_cs[] = {
-	MXC_SPI_CS(0), MXC_SPI_CS(1),
-};
-
 static const struct spi_imx_master moboard_spi2_pdata __initconst = {
-	.chipselect	= moboard_spi2_cs,
-	.num_chipselect	= ARRAY_SIZE(moboard_spi2_cs),
+	.num_chipselect	= 2,
 };
 
 #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0)
diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c
index 95bd97710494..15bc956d466b 100644
--- a/arch/arm/mach-imx/mach-pcm037_eet.c
+++ b/arch/arm/mach-imx/mach-pcm037_eet.c
@@ -56,11 +56,8 @@ static struct spi_board_info pcm037_spi_dev[] = {
 };
 
 /* Platform Data for MXC CSPI */
-static int pcm037_spi1_cs[] = { MXC_SPI_CS(0), MXC_SPI_CS(1), };
-
 static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
-	.chipselect = pcm037_spi1_cs,
-	.num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
+	.num_chipselect = 2,
 };
 
 /* GPIO-keys input device */
diff --git a/include/linux/platform_data/spi-imx.h b/include/linux/platform_data/spi-imx.h
index 08be445e8eb8..9b2ed66ef7a2 100644
--- a/include/linux/platform_data/spi-imx.h
+++ b/include/linux/platform_data/spi-imx.h
@@ -4,24 +4,29 @@
 
 /*
  * struct spi_imx_master - device.platform_data for SPI controller devices.
- * @chipselect: Array of chipselects for this master. Numbers >= 0 mean gpio
- *              pins, numbers < 0 mean internal CSPI chipselects according
- *              to MXC_SPI_CS(). Normally you want to use gpio based chip
- *              selects as the CSPI module tries to be intelligent about
- *              when to assert the chipselect: The CSPI module deasserts the
- *              chipselect once it runs out of input data. The other problem
- *              is that it is not possible to mix between high active and low
- *              active chipselects on one single bus using the internal
- *              chipselects. Unfortunately Freescale decided to put some
+ * @chipselect: Array of chipselects for this master or NULL.  Numbers >= 0
+ *              mean GPIO pins, -ENOENT means internal CSPI chipselect
+ *              matching the position in the array.  E.g., if chipselect[1] =
+ *              -ENOENT then a SPI slave using chip select 1 will use the
+ *              native SS1 line of the CSPI.  Omitting the array will use
+ *              all native chip selects.
+
+ *              Normally you want to use gpio based chip selects as the CSPI
+ *              module tries to be intelligent about when to assert the
+ *              chipselect:  The CSPI module deasserts the chipselect once it
+ *              runs out of input data.  The other problem is that it is not
+ *              possible to mix between high active and low active chipselects
+ *              on one single bus using the internal chipselects.
+ *              Unfortunately, on some SoCs, Freescale decided to put some
  *              chipselects on dedicated pins which are not usable as gpios,
  *              so we have to support the internal chipselects.
- * @num_chipselect: ARRAY_SIZE(chipselect)
+ *
+ * @num_chipselect: If @chipselect is specified, ARRAY_SIZE(chipselect),
+ *                  otherwise the number of native chip selects.
  */
 struct spi_imx_master {
 	int	*chipselect;
 	int	num_chipselect;
 };
 
-#define MXC_SPI_CS(no)	((no) - 32)
-
 #endif /* __MACH_SPI_H_*/
-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state
@ 2017-11-06 19:46     ` Trent Piepho
  0 siblings, 0 replies; 18+ messages in thread
From: Trent Piepho @ 2017-11-06 19:46 UTC (permalink / raw)
  To: linux-arm-kernel

The docs for the spi_imx platform data still refer to a -32 offset used to
specify a native chip select.  This was removed in commit 602c8f4485cd
("spi: imx: fix use of native chip-selects with devicetree") and no
longer works as documented.  Update documentation.

The macro MXC_SPI_CS() is no longer is needed.

If a board uses all native chip selects, then it's not necessary to
specify a chip select array at all, as all native is the default (this is
how device-tree configured SPI masters work too).  Most of the spi-imx
platform data users have their chip select arrays removed by this patch.

This patch also fixes a bug in mx31moboard introduced in the '602 commit.
When that board was updated in commit 901f26bce64a ("ARM: imx: set
correct chip_select in platform setup") to reflect the SPI change, only
SPI bus 2 was updated and SPI bus 1 was left with non-sequential chip
selects.  The mc13783 spi device on bus 1 had its chip select updated as
if it were on bus 2.

CC: Shawn Guo <shawnguo@kernel.org>
CC: Sascha Hauer <kernel@pengutronix.de>
CC: Fabio Estevam <fabio.estevam@nxp.com>
Acked-by: Greg Ungerer <gerg@linux-m68k.org>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 arch/arm/mach-imx/mach-mx31_3ds.c     | 18 ++----------------
 arch/arm/mach-imx/mach-mx31lilly.c    | 12 ++----------
 arch/arm/mach-imx/mach-mx31lite.c     | 16 ++--------------
 arch/arm/mach-imx/mach-mx31moboard.c  | 17 +++--------------
 arch/arm/mach-imx/mach-pcm037_eet.c   |  5 +----
 include/linux/platform_data/spi-imx.h | 29 +++++++++++++++++------------
 6 files changed, 27 insertions(+), 70 deletions(-)

diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
index 68c3f0799d5b..9d87f1dcf7bb 100644
--- a/arch/arm/mach-imx/mach-mx31_3ds.c
+++ b/arch/arm/mach-imx/mach-mx31_3ds.c
@@ -374,26 +374,12 @@ static struct imx_ssi_platform_data mx31_3ds_ssi_pdata = {
 };
 
 /* SPI */
-static int spi0_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-	.chipselect	= spi0_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
-};
-
-static int spi1_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
+	.num_chipselect	= 3,
 };
 
 static const struct spi_imx_master spi1_pdata __initconst = {
-	.chipselect	= spi1_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
+	.num_chipselect	= 3,
 };
 
 static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c
index 6fd463642954..8bf52819d4d9 100644
--- a/arch/arm/mach-imx/mach-mx31lilly.c
+++ b/arch/arm/mach-imx/mach-mx31lilly.c
@@ -226,20 +226,12 @@ static void __init lilly1131_usb_init(void)
 
 /* SPI */
 
-static int spi_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-	.chipselect = spi_internal_chipselect,
-	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
+	.num_chipselect = 3,
 };
 
 static const struct spi_imx_master spi1_pdata __initconst = {
-	.chipselect = spi_internal_chipselect,
-	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
+	.num_chipselect = 3,
 };
 
 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c
index f033a57d5694..fcbaf0070ccf 100644
--- a/arch/arm/mach-imx/mach-mx31lite.c
+++ b/arch/arm/mach-imx/mach-mx31lite.c
@@ -83,15 +83,8 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 };
 
 /* SPI */
-static int spi0_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(1),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-	.chipselect	= spi0_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
+	.num_chipselect	= 3,
 };
 
 static const struct mxc_nand_platform_data
@@ -133,13 +126,8 @@ static struct platform_device smsc911x_device = {
  * The MC13783 is the only hard-wired SPI device on the module.
  */
 
-static int spi1_internal_chipselect[] = {
-	MXC_SPI_CS(0),
-};
-
 static const struct spi_imx_master spi1_pdata __initconst = {
-	.chipselect	= spi1_internal_chipselect,
-	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
+	.num_chipselect	= 1,
 };
 
 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index 7716f83aecdd..643a3d749703 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -152,14 +152,8 @@ static const struct imxi2c_platform_data moboard_i2c1_data __initconst = {
 	.bitrate = 100000,
 };
 
-static int moboard_spi1_cs[] = {
-	MXC_SPI_CS(0),
-	MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master moboard_spi1_pdata __initconst = {
-	.chipselect	= moboard_spi1_cs,
-	.num_chipselect	= ARRAY_SIZE(moboard_spi1_cs),
+	.num_chipselect	= 3,
 };
 
 static struct regulator_consumer_supply sdhc_consumers[] = {
@@ -296,19 +290,14 @@ static struct spi_board_info moboard_spi_board_info[] __initdata = {
 		/* irq number is run-time assigned */
 		.max_speed_hz = 300000,
 		.bus_num = 1,
-		.chip_select = 1,
+		.chip_select = 0,
 		.platform_data = &moboard_pmic,
 		.mode = SPI_CS_HIGH,
 	},
 };
 
-static int moboard_spi2_cs[] = {
-	MXC_SPI_CS(0), MXC_SPI_CS(1),
-};
-
 static const struct spi_imx_master moboard_spi2_pdata __initconst = {
-	.chipselect	= moboard_spi2_cs,
-	.num_chipselect	= ARRAY_SIZE(moboard_spi2_cs),
+	.num_chipselect	= 2,
 };
 
 #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0)
diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c
index 95bd97710494..15bc956d466b 100644
--- a/arch/arm/mach-imx/mach-pcm037_eet.c
+++ b/arch/arm/mach-imx/mach-pcm037_eet.c
@@ -56,11 +56,8 @@ static struct spi_board_info pcm037_spi_dev[] = {
 };
 
 /* Platform Data for MXC CSPI */
-static int pcm037_spi1_cs[] = { MXC_SPI_CS(0), MXC_SPI_CS(1), };
-
 static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
-	.chipselect = pcm037_spi1_cs,
-	.num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
+	.num_chipselect = 2,
 };
 
 /* GPIO-keys input device */
diff --git a/include/linux/platform_data/spi-imx.h b/include/linux/platform_data/spi-imx.h
index 08be445e8eb8..9b2ed66ef7a2 100644
--- a/include/linux/platform_data/spi-imx.h
+++ b/include/linux/platform_data/spi-imx.h
@@ -4,24 +4,29 @@
 
 /*
  * struct spi_imx_master - device.platform_data for SPI controller devices.
- * @chipselect: Array of chipselects for this master. Numbers >= 0 mean gpio
- *              pins, numbers < 0 mean internal CSPI chipselects according
- *              to MXC_SPI_CS(). Normally you want to use gpio based chip
- *              selects as the CSPI module tries to be intelligent about
- *              when to assert the chipselect: The CSPI module deasserts the
- *              chipselect once it runs out of input data. The other problem
- *              is that it is not possible to mix between high active and low
- *              active chipselects on one single bus using the internal
- *              chipselects. Unfortunately Freescale decided to put some
+ * @chipselect: Array of chipselects for this master or NULL.  Numbers >= 0
+ *              mean GPIO pins, -ENOENT means internal CSPI chipselect
+ *              matching the position in the array.  E.g., if chipselect[1] =
+ *              -ENOENT then a SPI slave using chip select 1 will use the
+ *              native SS1 line of the CSPI.  Omitting the array will use
+ *              all native chip selects.
+
+ *              Normally you want to use gpio based chip selects as the CSPI
+ *              module tries to be intelligent about when to assert the
+ *              chipselect:  The CSPI module deasserts the chipselect once it
+ *              runs out of input data.  The other problem is that it is not
+ *              possible to mix between high active and low active chipselects
+ *              on one single bus using the internal chipselects.
+ *              Unfortunately, on some SoCs, Freescale decided to put some
  *              chipselects on dedicated pins which are not usable as gpios,
  *              so we have to support the internal chipselects.
- * @num_chipselect: ARRAY_SIZE(chipselect)
+ *
+ * @num_chipselect: If @chipselect is specified, ARRAY_SIZE(chipselect),
+ *                  otherwise the number of native chip selects.
  */
 struct spi_imx_master {
 	int	*chipselect;
 	int	num_chipselect;
 };
 
-#define MXC_SPI_CS(no)	((no) - 32)
-
 #endif /* __MACH_SPI_H_*/
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required
  2017-11-06 19:46     ` Trent Piepho
@ 2017-11-07  6:45         ` Oleksij Rempel
  -1 siblings, 0 replies; 18+ messages in thread
From: Oleksij Rempel @ 2017-11-07  6:45 UTC (permalink / raw)
  To: Trent Piepho, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Mark Brown, Sascha Hauer, Fabio Estevam, Shawn Guo

Hi,

On 06.11.2017 20:46, Trent Piepho wrote:
> The driver will fail to load if the device tree property for gpio chip
> selects is not specified.  Change the driver to make the property optional.
> Also have the driver respect the "num-cs" property in the standard way.
> 
> This way one can use the native CS lines using standard bindings instead of
> being forced to specify a gpio-cs of <0>.
> 
> Since native CS do not work in a commonly useful manner with this
> hardware/driver, note in the documention that most users probably should
> use GPIO based CS lines rather than native.
> 
> CC: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
> CC: Oleksij Rempel <o.rempel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>


Reviewed-by: Oleksij Rempel <o.rempel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>


> ---
>  Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt | 18 ++++++++++++------
>  drivers/spi/spi-imx.c                                  | 18 ++++++++++--------
>  2 files changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
> index 5bf13960f7f4..e3c48b20b1a6 100644
> --- a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
> +++ b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
> @@ -12,24 +12,30 @@ Required properties:
>    - "fsl,imx53-ecspi" for SPI compatible with the one integrated on i.MX53 and later Soc
>  - reg : Offset and length of the register set for the device
>  - interrupts : Should contain CSPI/eCSPI interrupt
> -- cs-gpios : Specifies the gpio pins to be used for chipselects.
>  - clocks : Clock specifiers for both ipg and per clocks.
>  - clock-names : Clock names should include both "ipg" and "per"
>  See the clock consumer binding,
>  	Documentation/devicetree/bindings/clock/clock-bindings.txt
> -- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
> -		Documentation/devicetree/bindings/dma/dma.txt
> -- dma-names: DMA request names should include "tx" and "rx" if present.
>  
> -Obsolete properties:
> -- fsl,spi-num-chipselects : Contains the number of the chipselect
> +Recommended properties:
> +- cs-gpios : GPIOs to use as chip selects, see spi-bus.txt.  While the native chip
> +select lines can be used, they appear to always generate a pulse between each
> +word of a transfer.  Most use cases will require GPIO based chip selects to
> +generate a valid transaction.
>  
>  Optional properties:
> +- num-cs :  Number of total chip selects, see spi-bus.txt.
> +- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
> +Documentation/devicetree/bindings/dma/dma.txt.
> +- dma-names: DMA request names, if present, should include "tx" and "rx".
>  - fsl,spi-rdy-drctl: Integer, representing the value of DRCTL, the register
>  controlling the SPI_READY handling. Note that to enable the DRCTL consideration,
>  the SPI_READY mode-flag needs to be set too.
>  Valid values are: 0 (disabled), 1 (edge-triggered burst) and 2 (level-triggered burst).
>  
> +Obsolete properties:
> +- fsl,spi-num-chipselects : Contains the number of the chipselect
> +
>  Example:
>  
>  ecspi@70010000 {
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 301cdb721bad..ad54f8258513 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -1523,6 +1523,7 @@ static int spi_imx_probe(struct platform_device *pdev)
>  
>  	spi_imx->devtype_data = devtype_data;
>  
> +	/* Get number of chip selects, either platform data or OF */
>  	if (mxc_platform_info) {
>  		master->num_chipselect = mxc_platform_info->num_chipselect;
>  		master->cs_gpios = devm_kzalloc(&master->dev,
> @@ -1532,7 +1533,13 @@ static int spi_imx_probe(struct platform_device *pdev)
>  
>  		for (i = 0; i < master->num_chipselect; i++)
>  			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
> - 	}
> +	} else {
> +		u32 num_cs;
> +
> +		if (!of_property_read_u32(np, "num-cs", &num_cs))
> +			master->num_chipselect = num_cs;
> +		/* If not preset, default value of 1 is used */
> +	}
>  
>  	spi_imx->bitbang.chipselect = spi_imx_chipselect;
>  	spi_imx->bitbang.setup_transfer = spi_imx_setupxfer;
> @@ -1619,13 +1626,8 @@ static int spi_imx_probe(struct platform_device *pdev)
>  		goto out_clk_put;
>  	}
>  
> -	if (!spi_imx->slave_mode) {
> -		if (!master->cs_gpios) {
> -			dev_err(&pdev->dev, "No CS GPIOs available\n");
> -			ret = -EINVAL;
> -			goto out_clk_put;
> -		}
> -
> +	/* Request GPIO CS lines, if any */
> +	if (!spi_imx->slave_mode && master->cs_gpios) {
>  		for (i = 0; i < master->num_chipselect; i++) {
>  			if (!gpio_is_valid(master->cs_gpios[i]))
>  				continue;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required
@ 2017-11-07  6:45         ` Oleksij Rempel
  0 siblings, 0 replies; 18+ messages in thread
From: Oleksij Rempel @ 2017-11-07  6:45 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 06.11.2017 20:46, Trent Piepho wrote:
> The driver will fail to load if the device tree property for gpio chip
> selects is not specified.  Change the driver to make the property optional.
> Also have the driver respect the "num-cs" property in the standard way.
> 
> This way one can use the native CS lines using standard bindings instead of
> being forced to specify a gpio-cs of <0>.
> 
> Since native CS do not work in a commonly useful manner with this
> hardware/driver, note in the documention that most users probably should
> use GPIO based CS lines rather than native.
> 
> CC: Mark Brown <broonie@kernel.org>
> CC: Shawn Guo <shawnguo@kernel.org>
> CC: Sascha Hauer <kernel@pengutronix.de>
> CC: Fabio Estevam <fabio.estevam@nxp.com>
> CC: Oleksij Rempel <o.rempel@pengutronix.de>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>


Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>


> ---
>  Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt | 18 ++++++++++++------
>  drivers/spi/spi-imx.c                                  | 18 ++++++++++--------
>  2 files changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
> index 5bf13960f7f4..e3c48b20b1a6 100644
> --- a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
> +++ b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt
> @@ -12,24 +12,30 @@ Required properties:
>    - "fsl,imx53-ecspi" for SPI compatible with the one integrated on i.MX53 and later Soc
>  - reg : Offset and length of the register set for the device
>  - interrupts : Should contain CSPI/eCSPI interrupt
> -- cs-gpios : Specifies the gpio pins to be used for chipselects.
>  - clocks : Clock specifiers for both ipg and per clocks.
>  - clock-names : Clock names should include both "ipg" and "per"
>  See the clock consumer binding,
>  	Documentation/devicetree/bindings/clock/clock-bindings.txt
> -- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
> -		Documentation/devicetree/bindings/dma/dma.txt
> -- dma-names: DMA request names should include "tx" and "rx" if present.
>  
> -Obsolete properties:
> -- fsl,spi-num-chipselects : Contains the number of the chipselect
> +Recommended properties:
> +- cs-gpios : GPIOs to use as chip selects, see spi-bus.txt.  While the native chip
> +select lines can be used, they appear to always generate a pulse between each
> +word of a transfer.  Most use cases will require GPIO based chip selects to
> +generate a valid transaction.
>  
>  Optional properties:
> +- num-cs :  Number of total chip selects, see spi-bus.txt.
> +- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
> +Documentation/devicetree/bindings/dma/dma.txt.
> +- dma-names: DMA request names, if present, should include "tx" and "rx".
>  - fsl,spi-rdy-drctl: Integer, representing the value of DRCTL, the register
>  controlling the SPI_READY handling. Note that to enable the DRCTL consideration,
>  the SPI_READY mode-flag needs to be set too.
>  Valid values are: 0 (disabled), 1 (edge-triggered burst) and 2 (level-triggered burst).
>  
> +Obsolete properties:
> +- fsl,spi-num-chipselects : Contains the number of the chipselect
> +
>  Example:
>  
>  ecspi at 70010000 {
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 301cdb721bad..ad54f8258513 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -1523,6 +1523,7 @@ static int spi_imx_probe(struct platform_device *pdev)
>  
>  	spi_imx->devtype_data = devtype_data;
>  
> +	/* Get number of chip selects, either platform data or OF */
>  	if (mxc_platform_info) {
>  		master->num_chipselect = mxc_platform_info->num_chipselect;
>  		master->cs_gpios = devm_kzalloc(&master->dev,
> @@ -1532,7 +1533,13 @@ static int spi_imx_probe(struct platform_device *pdev)
>  
>  		for (i = 0; i < master->num_chipselect; i++)
>  			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
> - 	}
> +	} else {
> +		u32 num_cs;
> +
> +		if (!of_property_read_u32(np, "num-cs", &num_cs))
> +			master->num_chipselect = num_cs;
> +		/* If not preset, default value of 1 is used */
> +	}
>  
>  	spi_imx->bitbang.chipselect = spi_imx_chipselect;
>  	spi_imx->bitbang.setup_transfer = spi_imx_setupxfer;
> @@ -1619,13 +1626,8 @@ static int spi_imx_probe(struct platform_device *pdev)
>  		goto out_clk_put;
>  	}
>  
> -	if (!spi_imx->slave_mode) {
> -		if (!master->cs_gpios) {
> -			dev_err(&pdev->dev, "No CS GPIOs available\n");
> -			ret = -EINVAL;
> -			goto out_clk_put;
> -		}
> -
> +	/* Request GPIO CS lines, if any */
> +	if (!spi_imx->slave_mode && master->cs_gpios) {
>  		for (i = 0; i < master->num_chipselect; i++) {
>  			if (!gpio_is_valid(master->cs_gpios[i]))
>  				continue;
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 2/3] spi: imx: Don't require platform data chipselect array
  2017-11-06 19:46     ` Trent Piepho
@ 2017-11-07  6:58         ` Oleksij Rempel
  -1 siblings, 0 replies; 18+ messages in thread
From: Oleksij Rempel @ 2017-11-07  6:58 UTC (permalink / raw)
  To: Trent Piepho, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Fabio Estevam, Mark Brown, Shawn Guo, Sascha Hauer

On 06.11.2017 20:46, Trent Piepho wrote:
> If the array is not present, assume all chip selects are native.  This
> is the standard behavior for SPI masters configured via the device
> tree and the behavior of this driver as well when it is configured via
> device tree.
> 
> This reduces platform data vs DT differences and allows most of the
> platform data based boards to remove their chip select arrays.
> 
> CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
> CC: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>

Reviewed-by: Oleksij Rempel <o.rempel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

> ---
>  drivers/spi/spi-imx.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index ad54f8258513..5caa6c9524fa 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -1526,13 +1526,15 @@ static int spi_imx_probe(struct platform_device *pdev)
>  	/* Get number of chip selects, either platform data or OF */
>  	if (mxc_platform_info) {
>  		master->num_chipselect = mxc_platform_info->num_chipselect;
> -		master->cs_gpios = devm_kzalloc(&master->dev,
> -			sizeof(int) * master->num_chipselect, GFP_KERNEL);
> -		if (!master->cs_gpios)
> -			return -ENOMEM;
> -
> -		for (i = 0; i < master->num_chipselect; i++)
> -			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
> +		if (mxc_platform_info->chipselect) {
> +			master->cs_gpios = devm_kzalloc(&master->dev,
> +				sizeof(int) * master->num_chipselect, GFP_KERNEL);
> +			if (!master->cs_gpios)
> +				return -ENOMEM;
> +
> +			for (i = 0; i < master->num_chipselect; i++)
> +				master->cs_gpios[i] = mxc_platform_info->chipselect[i];
> +		}
>  	} else {
>  		u32 num_cs;
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 2/3] spi: imx: Don't require platform data chipselect array
@ 2017-11-07  6:58         ` Oleksij Rempel
  0 siblings, 0 replies; 18+ messages in thread
From: Oleksij Rempel @ 2017-11-07  6:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 06.11.2017 20:46, Trent Piepho wrote:
> If the array is not present, assume all chip selects are native.  This
> is the standard behavior for SPI masters configured via the device
> tree and the behavior of this driver as well when it is configured via
> device tree.
> 
> This reduces platform data vs DT differences and allows most of the
> platform data based boards to remove their chip select arrays.
> 
> CC: Shawn Guo <shawnguo@kernel.org>
> CC: Sascha Hauer <kernel@pengutronix.de>
> CC: Fabio Estevam <fabio.estevam@nxp.com>
> CC: Mark Brown <broonie@kernel.org>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>

> ---
>  drivers/spi/spi-imx.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index ad54f8258513..5caa6c9524fa 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -1526,13 +1526,15 @@ static int spi_imx_probe(struct platform_device *pdev)
>  	/* Get number of chip selects, either platform data or OF */
>  	if (mxc_platform_info) {
>  		master->num_chipselect = mxc_platform_info->num_chipselect;
> -		master->cs_gpios = devm_kzalloc(&master->dev,
> -			sizeof(int) * master->num_chipselect, GFP_KERNEL);
> -		if (!master->cs_gpios)
> -			return -ENOMEM;
> -
> -		for (i = 0; i < master->num_chipselect; i++)
> -			master->cs_gpios[i] = mxc_platform_info->chipselect[i];
> +		if (mxc_platform_info->chipselect) {
> +			master->cs_gpios = devm_kzalloc(&master->dev,
> +				sizeof(int) * master->num_chipselect, GFP_KERNEL);
> +			if (!master->cs_gpios)
> +				return -ENOMEM;
> +
> +			for (i = 0; i < master->num_chipselect; i++)
> +				master->cs_gpios[i] = mxc_platform_info->chipselect[i];
> +		}
>  	} else {
>  		u32 num_cs;
>  
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state
  2017-11-06 19:46     ` Trent Piepho
@ 2017-11-07  7:03         ` Oleksij Rempel
  -1 siblings, 0 replies; 18+ messages in thread
From: Oleksij Rempel @ 2017-11-07  7:03 UTC (permalink / raw)
  To: Trent Piepho, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Fabio Estevam, Shawn Guo, Sascha Hauer



On 06.11.2017 20:46, Trent Piepho wrote:
> The docs for the spi_imx platform data still refer to a -32 offset used to
> specify a native chip select.  This was removed in commit 602c8f4485cd
> ("spi: imx: fix use of native chip-selects with devicetree") and no
> longer works as documented.  Update documentation.
> 
> The macro MXC_SPI_CS() is no longer is needed.
> 
> If a board uses all native chip selects, then it's not necessary to
> specify a chip select array at all, as all native is the default (this is
> how device-tree configured SPI masters work too).  Most of the spi-imx
> platform data users have their chip select arrays removed by this patch.
> 
> This patch also fixes a bug in mx31moboard introduced in the '602 commit.
> When that board was updated in commit 901f26bce64a ("ARM: imx: set
> correct chip_select in platform setup") to reflect the SPI change, only
> SPI bus 2 was updated and SPI bus 1 was left with non-sequential chip
> selects.  The mc13783 spi device on bus 1 had its chip select updated as
> if it were on bus 2.
> 
> CC: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> CC: Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> CC: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
> Acked-by: Greg Ungerer <gerg-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
> Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>

Reviewed-by: Oleksij Rempel <o.rempel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

> ---
>  arch/arm/mach-imx/mach-mx31_3ds.c     | 18 ++----------------
>  arch/arm/mach-imx/mach-mx31lilly.c    | 12 ++----------
>  arch/arm/mach-imx/mach-mx31lite.c     | 16 ++--------------
>  arch/arm/mach-imx/mach-mx31moboard.c  | 17 +++--------------
>  arch/arm/mach-imx/mach-pcm037_eet.c   |  5 +----
>  include/linux/platform_data/spi-imx.h | 29 +++++++++++++++++------------
>  6 files changed, 27 insertions(+), 70 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
> index 68c3f0799d5b..9d87f1dcf7bb 100644
> --- a/arch/arm/mach-imx/mach-mx31_3ds.c
> +++ b/arch/arm/mach-imx/mach-mx31_3ds.c
> @@ -374,26 +374,12 @@ static struct imx_ssi_platform_data mx31_3ds_ssi_pdata = {
>  };
>  
>  /* SPI */
> -static int spi0_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master spi0_pdata __initconst = {
> -	.chipselect	= spi0_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
> -};
> -
> -static int spi1_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> +	.num_chipselect	= 3,
>  };
>  
>  static const struct spi_imx_master spi1_pdata __initconst = {
> -	.chipselect	= spi1_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
> +	.num_chipselect	= 3,
>  };
>  
>  static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
> diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c
> index 6fd463642954..8bf52819d4d9 100644
> --- a/arch/arm/mach-imx/mach-mx31lilly.c
> +++ b/arch/arm/mach-imx/mach-mx31lilly.c
> @@ -226,20 +226,12 @@ static void __init lilly1131_usb_init(void)
>  
>  /* SPI */
>  
> -static int spi_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master spi0_pdata __initconst = {
> -	.chipselect = spi_internal_chipselect,
> -	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
> +	.num_chipselect = 3,
>  };
>  
>  static const struct spi_imx_master spi1_pdata __initconst = {
> -	.chipselect = spi_internal_chipselect,
> -	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
> +	.num_chipselect = 3,
>  };
>  
>  static struct mc13xxx_platform_data mc13783_pdata __initdata = {
> diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c
> index f033a57d5694..fcbaf0070ccf 100644
> --- a/arch/arm/mach-imx/mach-mx31lite.c
> +++ b/arch/arm/mach-imx/mach-mx31lite.c
> @@ -83,15 +83,8 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
>  };
>  
>  /* SPI */
> -static int spi0_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master spi0_pdata __initconst = {
> -	.chipselect	= spi0_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
> +	.num_chipselect	= 3,
>  };
>  
>  static const struct mxc_nand_platform_data
> @@ -133,13 +126,8 @@ static struct platform_device smsc911x_device = {
>   * The MC13783 is the only hard-wired SPI device on the module.
>   */
>  
> -static int spi1_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -};
> -
>  static const struct spi_imx_master spi1_pdata __initconst = {
> -	.chipselect	= spi1_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
> +	.num_chipselect	= 1,
>  };
>  
>  static struct mc13xxx_platform_data mc13783_pdata __initdata = {
> diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
> index 7716f83aecdd..643a3d749703 100644
> --- a/arch/arm/mach-imx/mach-mx31moboard.c
> +++ b/arch/arm/mach-imx/mach-mx31moboard.c
> @@ -152,14 +152,8 @@ static const struct imxi2c_platform_data moboard_i2c1_data __initconst = {
>  	.bitrate = 100000,
>  };
>  
> -static int moboard_spi1_cs[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master moboard_spi1_pdata __initconst = {
> -	.chipselect	= moboard_spi1_cs,
> -	.num_chipselect	= ARRAY_SIZE(moboard_spi1_cs),
> +	.num_chipselect	= 3,
>  };
>  
>  static struct regulator_consumer_supply sdhc_consumers[] = {
> @@ -296,19 +290,14 @@ static struct spi_board_info moboard_spi_board_info[] __initdata = {
>  		/* irq number is run-time assigned */
>  		.max_speed_hz = 300000,
>  		.bus_num = 1,
> -		.chip_select = 1,
> +		.chip_select = 0,
>  		.platform_data = &moboard_pmic,
>  		.mode = SPI_CS_HIGH,
>  	},
>  };
>  
> -static int moboard_spi2_cs[] = {
> -	MXC_SPI_CS(0), MXC_SPI_CS(1),
> -};
> -
>  static const struct spi_imx_master moboard_spi2_pdata __initconst = {
> -	.chipselect	= moboard_spi2_cs,
> -	.num_chipselect	= ARRAY_SIZE(moboard_spi2_cs),
> +	.num_chipselect	= 2,
>  };
>  
>  #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0)
> diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c
> index 95bd97710494..15bc956d466b 100644
> --- a/arch/arm/mach-imx/mach-pcm037_eet.c
> +++ b/arch/arm/mach-imx/mach-pcm037_eet.c
> @@ -56,11 +56,8 @@ static struct spi_board_info pcm037_spi_dev[] = {
>  };
>  
>  /* Platform Data for MXC CSPI */
> -static int pcm037_spi1_cs[] = { MXC_SPI_CS(0), MXC_SPI_CS(1), };
> -
>  static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
> -	.chipselect = pcm037_spi1_cs,
> -	.num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
> +	.num_chipselect = 2,
>  };
>  
>  /* GPIO-keys input device */
> diff --git a/include/linux/platform_data/spi-imx.h b/include/linux/platform_data/spi-imx.h
> index 08be445e8eb8..9b2ed66ef7a2 100644
> --- a/include/linux/platform_data/spi-imx.h
> +++ b/include/linux/platform_data/spi-imx.h
> @@ -4,24 +4,29 @@
>  
>  /*
>   * struct spi_imx_master - device.platform_data for SPI controller devices.
> - * @chipselect: Array of chipselects for this master. Numbers >= 0 mean gpio
> - *              pins, numbers < 0 mean internal CSPI chipselects according
> - *              to MXC_SPI_CS(). Normally you want to use gpio based chip
> - *              selects as the CSPI module tries to be intelligent about
> - *              when to assert the chipselect: The CSPI module deasserts the
> - *              chipselect once it runs out of input data. The other problem
> - *              is that it is not possible to mix between high active and low
> - *              active chipselects on one single bus using the internal
> - *              chipselects. Unfortunately Freescale decided to put some
> + * @chipselect: Array of chipselects for this master or NULL.  Numbers >= 0
> + *              mean GPIO pins, -ENOENT means internal CSPI chipselect
> + *              matching the position in the array.  E.g., if chipselect[1] =
> + *              -ENOENT then a SPI slave using chip select 1 will use the
> + *              native SS1 line of the CSPI.  Omitting the array will use
> + *              all native chip selects.
> +
> + *              Normally you want to use gpio based chip selects as the CSPI
> + *              module tries to be intelligent about when to assert the
> + *              chipselect:  The CSPI module deasserts the chipselect once it
> + *              runs out of input data.  The other problem is that it is not
> + *              possible to mix between high active and low active chipselects
> + *              on one single bus using the internal chipselects.
> + *              Unfortunately, on some SoCs, Freescale decided to put some
>   *              chipselects on dedicated pins which are not usable as gpios,
>   *              so we have to support the internal chipselects.
> - * @num_chipselect: ARRAY_SIZE(chipselect)
> + *
> + * @num_chipselect: If @chipselect is specified, ARRAY_SIZE(chipselect),
> + *                  otherwise the number of native chip selects.
>   */
>  struct spi_imx_master {
>  	int	*chipselect;
>  	int	num_chipselect;
>  };
>  
> -#define MXC_SPI_CS(no)	((no) - 32)
> -
>  #endif /* __MACH_SPI_H_*/
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state
@ 2017-11-07  7:03         ` Oleksij Rempel
  0 siblings, 0 replies; 18+ messages in thread
From: Oleksij Rempel @ 2017-11-07  7:03 UTC (permalink / raw)
  To: linux-arm-kernel



On 06.11.2017 20:46, Trent Piepho wrote:
> The docs for the spi_imx platform data still refer to a -32 offset used to
> specify a native chip select.  This was removed in commit 602c8f4485cd
> ("spi: imx: fix use of native chip-selects with devicetree") and no
> longer works as documented.  Update documentation.
> 
> The macro MXC_SPI_CS() is no longer is needed.
> 
> If a board uses all native chip selects, then it's not necessary to
> specify a chip select array at all, as all native is the default (this is
> how device-tree configured SPI masters work too).  Most of the spi-imx
> platform data users have their chip select arrays removed by this patch.
> 
> This patch also fixes a bug in mx31moboard introduced in the '602 commit.
> When that board was updated in commit 901f26bce64a ("ARM: imx: set
> correct chip_select in platform setup") to reflect the SPI change, only
> SPI bus 2 was updated and SPI bus 1 was left with non-sequential chip
> selects.  The mc13783 spi device on bus 1 had its chip select updated as
> if it were on bus 2.
> 
> CC: Shawn Guo <shawnguo@kernel.org>
> CC: Sascha Hauer <kernel@pengutronix.de>
> CC: Fabio Estevam <fabio.estevam@nxp.com>
> Acked-by: Greg Ungerer <gerg@linux-m68k.org>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>

> ---
>  arch/arm/mach-imx/mach-mx31_3ds.c     | 18 ++----------------
>  arch/arm/mach-imx/mach-mx31lilly.c    | 12 ++----------
>  arch/arm/mach-imx/mach-mx31lite.c     | 16 ++--------------
>  arch/arm/mach-imx/mach-mx31moboard.c  | 17 +++--------------
>  arch/arm/mach-imx/mach-pcm037_eet.c   |  5 +----
>  include/linux/platform_data/spi-imx.h | 29 +++++++++++++++++------------
>  6 files changed, 27 insertions(+), 70 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
> index 68c3f0799d5b..9d87f1dcf7bb 100644
> --- a/arch/arm/mach-imx/mach-mx31_3ds.c
> +++ b/arch/arm/mach-imx/mach-mx31_3ds.c
> @@ -374,26 +374,12 @@ static struct imx_ssi_platform_data mx31_3ds_ssi_pdata = {
>  };
>  
>  /* SPI */
> -static int spi0_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master spi0_pdata __initconst = {
> -	.chipselect	= spi0_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
> -};
> -
> -static int spi1_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> +	.num_chipselect	= 3,
>  };
>  
>  static const struct spi_imx_master spi1_pdata __initconst = {
> -	.chipselect	= spi1_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
> +	.num_chipselect	= 3,
>  };
>  
>  static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
> diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c
> index 6fd463642954..8bf52819d4d9 100644
> --- a/arch/arm/mach-imx/mach-mx31lilly.c
> +++ b/arch/arm/mach-imx/mach-mx31lilly.c
> @@ -226,20 +226,12 @@ static void __init lilly1131_usb_init(void)
>  
>  /* SPI */
>  
> -static int spi_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master spi0_pdata __initconst = {
> -	.chipselect = spi_internal_chipselect,
> -	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
> +	.num_chipselect = 3,
>  };
>  
>  static const struct spi_imx_master spi1_pdata __initconst = {
> -	.chipselect = spi_internal_chipselect,
> -	.num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
> +	.num_chipselect = 3,
>  };
>  
>  static struct mc13xxx_platform_data mc13783_pdata __initdata = {
> diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c
> index f033a57d5694..fcbaf0070ccf 100644
> --- a/arch/arm/mach-imx/mach-mx31lite.c
> +++ b/arch/arm/mach-imx/mach-mx31lite.c
> @@ -83,15 +83,8 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
>  };
>  
>  /* SPI */
> -static int spi0_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(1),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master spi0_pdata __initconst = {
> -	.chipselect	= spi0_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi0_internal_chipselect),
> +	.num_chipselect	= 3,
>  };
>  
>  static const struct mxc_nand_platform_data
> @@ -133,13 +126,8 @@ static struct platform_device smsc911x_device = {
>   * The MC13783 is the only hard-wired SPI device on the module.
>   */
>  
> -static int spi1_internal_chipselect[] = {
> -	MXC_SPI_CS(0),
> -};
> -
>  static const struct spi_imx_master spi1_pdata __initconst = {
> -	.chipselect	= spi1_internal_chipselect,
> -	.num_chipselect	= ARRAY_SIZE(spi1_internal_chipselect),
> +	.num_chipselect	= 1,
>  };
>  
>  static struct mc13xxx_platform_data mc13783_pdata __initdata = {
> diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
> index 7716f83aecdd..643a3d749703 100644
> --- a/arch/arm/mach-imx/mach-mx31moboard.c
> +++ b/arch/arm/mach-imx/mach-mx31moboard.c
> @@ -152,14 +152,8 @@ static const struct imxi2c_platform_data moboard_i2c1_data __initconst = {
>  	.bitrate = 100000,
>  };
>  
> -static int moboard_spi1_cs[] = {
> -	MXC_SPI_CS(0),
> -	MXC_SPI_CS(2),
> -};
> -
>  static const struct spi_imx_master moboard_spi1_pdata __initconst = {
> -	.chipselect	= moboard_spi1_cs,
> -	.num_chipselect	= ARRAY_SIZE(moboard_spi1_cs),
> +	.num_chipselect	= 3,
>  };
>  
>  static struct regulator_consumer_supply sdhc_consumers[] = {
> @@ -296,19 +290,14 @@ static struct spi_board_info moboard_spi_board_info[] __initdata = {
>  		/* irq number is run-time assigned */
>  		.max_speed_hz = 300000,
>  		.bus_num = 1,
> -		.chip_select = 1,
> +		.chip_select = 0,
>  		.platform_data = &moboard_pmic,
>  		.mode = SPI_CS_HIGH,
>  	},
>  };
>  
> -static int moboard_spi2_cs[] = {
> -	MXC_SPI_CS(0), MXC_SPI_CS(1),
> -};
> -
>  static const struct spi_imx_master moboard_spi2_pdata __initconst = {
> -	.chipselect	= moboard_spi2_cs,
> -	.num_chipselect	= ARRAY_SIZE(moboard_spi2_cs),
> +	.num_chipselect	= 2,
>  };
>  
>  #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0)
> diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c
> index 95bd97710494..15bc956d466b 100644
> --- a/arch/arm/mach-imx/mach-pcm037_eet.c
> +++ b/arch/arm/mach-imx/mach-pcm037_eet.c
> @@ -56,11 +56,8 @@ static struct spi_board_info pcm037_spi_dev[] = {
>  };
>  
>  /* Platform Data for MXC CSPI */
> -static int pcm037_spi1_cs[] = { MXC_SPI_CS(0), MXC_SPI_CS(1), };
> -
>  static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
> -	.chipselect = pcm037_spi1_cs,
> -	.num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
> +	.num_chipselect = 2,
>  };
>  
>  /* GPIO-keys input device */
> diff --git a/include/linux/platform_data/spi-imx.h b/include/linux/platform_data/spi-imx.h
> index 08be445e8eb8..9b2ed66ef7a2 100644
> --- a/include/linux/platform_data/spi-imx.h
> +++ b/include/linux/platform_data/spi-imx.h
> @@ -4,24 +4,29 @@
>  
>  /*
>   * struct spi_imx_master - device.platform_data for SPI controller devices.
> - * @chipselect: Array of chipselects for this master. Numbers >= 0 mean gpio
> - *              pins, numbers < 0 mean internal CSPI chipselects according
> - *              to MXC_SPI_CS(). Normally you want to use gpio based chip
> - *              selects as the CSPI module tries to be intelligent about
> - *              when to assert the chipselect: The CSPI module deasserts the
> - *              chipselect once it runs out of input data. The other problem
> - *              is that it is not possible to mix between high active and low
> - *              active chipselects on one single bus using the internal
> - *              chipselects. Unfortunately Freescale decided to put some
> + * @chipselect: Array of chipselects for this master or NULL.  Numbers >= 0
> + *              mean GPIO pins, -ENOENT means internal CSPI chipselect
> + *              matching the position in the array.  E.g., if chipselect[1] =
> + *              -ENOENT then a SPI slave using chip select 1 will use the
> + *              native SS1 line of the CSPI.  Omitting the array will use
> + *              all native chip selects.
> +
> + *              Normally you want to use gpio based chip selects as the CSPI
> + *              module tries to be intelligent about when to assert the
> + *              chipselect:  The CSPI module deasserts the chipselect once it
> + *              runs out of input data.  The other problem is that it is not
> + *              possible to mix between high active and low active chipselects
> + *              on one single bus using the internal chipselects.
> + *              Unfortunately, on some SoCs, Freescale decided to put some
>   *              chipselects on dedicated pins which are not usable as gpios,
>   *              so we have to support the internal chipselects.
> - * @num_chipselect: ARRAY_SIZE(chipselect)
> + *
> + * @num_chipselect: If @chipselect is specified, ARRAY_SIZE(chipselect),
> + *                  otherwise the number of native chip selects.
>   */
>  struct spi_imx_master {
>  	int	*chipselect;
>  	int	num_chipselect;
>  };
>  
> -#define MXC_SPI_CS(no)	((no) - 32)
> -
>  #endif /* __MACH_SPI_H_*/
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required
  2017-11-06 19:46     ` Trent Piepho
@ 2017-11-08 19:26         ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2017-11-08 19:26 UTC (permalink / raw)
  To: Trent Piepho
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Shawn Guo,
	Sascha Hauer, Fabio Estevam, Oleksij Rempel

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

On Mon, Nov 06, 2017 at 11:46:16AM -0800, Trent Piepho wrote:
> The driver will fail to load if the device tree property for gpio chip
> selects is not specified.  Change the driver to make the property optional.
> Also have the driver respect the "num-cs" property in the standard way.

This doesn't apply against current code, please check and resend.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required
@ 2017-11-08 19:26         ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2017-11-08 19:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 06, 2017 at 11:46:16AM -0800, Trent Piepho wrote:
> The driver will fail to load if the device tree property for gpio chip
> selects is not specified.  Change the driver to make the property optional.
> Also have the driver respect the "num-cs" property in the standard way.

This doesn't apply against current code, please check and resend.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171108/f368c6ae/attachment.sig>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state
  2017-11-06 19:46     ` Trent Piepho
@ 2017-11-16  7:47       ` Shawn Guo
  -1 siblings, 0 replies; 18+ messages in thread
From: Shawn Guo @ 2017-11-16  7:47 UTC (permalink / raw)
  To: Trent Piepho; +Cc: Fabio Estevam, Sascha Hauer, linux-arm-kernel, linux-spi

On Mon, Nov 06, 2017 at 11:46:18AM -0800, Trent Piepho wrote:
> The docs for the spi_imx platform data still refer to a -32 offset used to
> specify a native chip select.  This was removed in commit 602c8f4485cd
> ("spi: imx: fix use of native chip-selects with devicetree") and no
> longer works as documented.  Update documentation.
> 
> The macro MXC_SPI_CS() is no longer is needed.
> 
> If a board uses all native chip selects, then it's not necessary to
> specify a chip select array at all, as all native is the default (this is
> how device-tree configured SPI masters work too).  Most of the spi-imx
> platform data users have their chip select arrays removed by this patch.
> 
> This patch also fixes a bug in mx31moboard introduced in the '602 commit.
> When that board was updated in commit 901f26bce64a ("ARM: imx: set
> correct chip_select in platform setup") to reflect the SPI change, only
> SPI bus 2 was updated and SPI bus 1 was left with non-sequential chip
> selects.  The mc13783 spi device on bus 1 had its chip select updated as
> if it were on bus 2.
> 
> CC: Shawn Guo <shawnguo@kernel.org>

Acked-by: Shawn Guo <shawnguo@kernel.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state
@ 2017-11-16  7:47       ` Shawn Guo
  0 siblings, 0 replies; 18+ messages in thread
From: Shawn Guo @ 2017-11-16  7:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 06, 2017 at 11:46:18AM -0800, Trent Piepho wrote:
> The docs for the spi_imx platform data still refer to a -32 offset used to
> specify a native chip select.  This was removed in commit 602c8f4485cd
> ("spi: imx: fix use of native chip-selects with devicetree") and no
> longer works as documented.  Update documentation.
> 
> The macro MXC_SPI_CS() is no longer is needed.
> 
> If a board uses all native chip selects, then it's not necessary to
> specify a chip select array at all, as all native is the default (this is
> how device-tree configured SPI masters work too).  Most of the spi-imx
> platform data users have their chip select arrays removed by this patch.
> 
> This patch also fixes a bug in mx31moboard introduced in the '602 commit.
> When that board was updated in commit 901f26bce64a ("ARM: imx: set
> correct chip_select in platform setup") to reflect the SPI change, only
> SPI bus 2 was updated and SPI bus 1 was left with non-sequential chip
> selects.  The mc13783 spi device on bus 1 had its chip select updated as
> if it were on bus 2.
> 
> CC: Shawn Guo <shawnguo@kernel.org>

Acked-by: Shawn Guo <shawnguo@kernel.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-11-16  7:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 19:46 [PATCH v4 0/3] Fix for imx-spi CS GPIOs Trent Piepho
2017-11-06 19:46 ` Trent Piepho
     [not found] ` <20171106194618.9421-1-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-11-06 19:46   ` [PATCH v4 1/3] spi: imx: GPIO chip select DT property should not be required Trent Piepho
2017-11-06 19:46     ` Trent Piepho
     [not found]     ` <20171106194618.9421-2-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-11-07  6:45       ` Oleksij Rempel
2017-11-07  6:45         ` Oleksij Rempel
2017-11-08 19:26       ` Mark Brown
2017-11-08 19:26         ` Mark Brown
2017-11-06 19:46   ` [PATCH v4 2/3] spi: imx: Don't require platform data chipselect array Trent Piepho
2017-11-06 19:46     ` Trent Piepho
     [not found]     ` <20171106194618.9421-3-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-11-07  6:58       ` Oleksij Rempel
2017-11-07  6:58         ` Oleksij Rempel
2017-11-06 19:46   ` [PATCH v4 3/3] ARM: imx: Update spi_imx platform data to reflect current state Trent Piepho
2017-11-06 19:46     ` Trent Piepho
     [not found]     ` <20171106194618.9421-4-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-11-07  7:03       ` Oleksij Rempel
2017-11-07  7:03         ` Oleksij Rempel
2017-11-16  7:47     ` Shawn Guo
2017-11-16  7:47       ` Shawn Guo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.