linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit
@ 2023-05-24  9:19 Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 1/5] " Boerge Struempfel
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Boerge Struempfel @ 2023-05-24  9:19 UTC (permalink / raw)
  Cc: boerge.struempfel, bstruempfel, andy.shevchenko, festevam,
	amit.kumar-mahapatra, broonie, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, linux-spi,
	linux-arm-kernel, linux-kernel

Some spi controller switch the mosi line to high, whenever they are
idle. This may not be desired in all use cases. For example neopixel
leds can get confused and flicker due to misinterpreting the idle state.
Therefore, we introduce a new spi-mode bit, with which the idle behaviour
can be overwritten on a per device basis.

---

Link for versions:
  v1 and v2: https://lore.kernel.org/linux-spi/20230511135632.78344-1-bstruempfel@ultratronik.de/
  v3: https://lore.kernel.org/linux-spi/20230517103007.26287-1-boerge.struempfel@gmail.com/T/#t
  v4: https://lore.kernel.org/linux-spi/CAEktqctboF3=ykVNtPsifcmHzF6dWwoEcVh+O4H1u-R=TT6gHg@mail.gmail.com/T/#t
  v5: https://lore.kernel.org/linux-spi/20230520190856.34720-1-boerge.struempfel@gmail.com/T/#t

Changes from V5:
  - Added a patch to reorder the command line options for
    spidev_test in order to increase usability. The indentation
    fixes were also done in this patch.

Changes from V4:
  - Added the SPI_3WIRE_HIZ mode bit to spidev
  - Added the SPI_MOSI_IDLE_LOW mode bit to the spidev_test
    userspace tool and added the two other missing spi mode
    bits (SPI_3WIRE_HIZ and SPI_RX_CPHA_FLIP) to it as well.

Changes from V3:
  - Added missing paranthesis which caused builderrors

Changes from V2:
  - Removed the device-tree binding since this should not be managed by
    the DT but by the device itself.
  - Replaced all occurences of spi->chip_select with the corresponding
    macro spi_get_chipselect(spi,0)

Changes from V1:
  - Added patch, introducing the new devicetree binding flag
  - Split the generic spi part of the patch from the imx-spi specific
    part
  - Replaced SPI_CPOL and SPI_CPHA by the combined SPI_MODE_X_MASK bit
    in the imx-spi.c modebits.
  - Added the SPI_MOSI_IDLE_LOW bit to spidev

Boerge Struempfel (5):
  spi: add SPI_MOSI_IDLE_LOW mode bit
  spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
  spi: spidev: add two new spi mode bits
  spi: spidev_test: Sorted the options into logical groups
  spi: spidev_test Add three missing spi mode bits

 drivers/spi/spi-imx.c        |   9 ++-
 drivers/spi/spidev.c         |   3 +-
 include/uapi/linux/spi/spi.h |   3 +-
 tools/spi/spidev_test.c      | 107 +++++++++++++++++++++--------------
 4 files changed, 76 insertions(+), 46 deletions(-)

-- 
2.40.1


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

* [PATCH v6 1/5] spi: add SPI_MOSI_IDLE_LOW mode bit
  2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
@ 2023-05-24  9:19 ` Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 2/5] spi: spi-imx: add support for " Boerge Struempfel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Boerge Struempfel @ 2023-05-24  9:19 UTC (permalink / raw)
  Cc: boerge.struempfel, bstruempfel, andy.shevchenko, festevam,
	amit.kumar-mahapatra, broonie, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, linux-spi,
	linux-arm-kernel, linux-kernel

Some spi controller switch the mosi line to high, whenever they are
idle. This may not be desired in all use cases. For example neopixel
leds can get confused and flicker due to misinterpreting the idle state.
Therefore, we introduce a new spi-mode bit, with which the idle behaviour
can be overwritten on a per device basis.

Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
---
 include/uapi/linux/spi/spi.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/spi/spi.h b/include/uapi/linux/spi/spi.h
index 9d5f58059703..ca56e477d161 100644
--- a/include/uapi/linux/spi/spi.h
+++ b/include/uapi/linux/spi/spi.h
@@ -28,6 +28,7 @@
 #define	SPI_RX_OCTAL		_BITUL(14)	/* receive with 8 wires */
 #define	SPI_3WIRE_HIZ		_BITUL(15)	/* high impedance turnaround */
 #define	SPI_RX_CPHA_FLIP	_BITUL(16)	/* flip CPHA on Rx only xfer */
+#define SPI_MOSI_IDLE_LOW	_BITUL(17)	/* leave mosi line low when idle */
 
 /*
  * All the bits defined above should be covered by SPI_MODE_USER_MASK.
@@ -37,6 +38,6 @@
  * These bits must not overlap. A static assert check should make sure of that.
  * If adding extra bits, make sure to increase the bit index below as well.
  */
-#define SPI_MODE_USER_MASK	(_BITUL(17) - 1)
+#define SPI_MODE_USER_MASK	(_BITUL(18) - 1)
 
 #endif /* _UAPI_SPI_H */
-- 
2.40.1


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

* [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
  2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 1/5] " Boerge Struempfel
@ 2023-05-24  9:19 ` Boerge Struempfel
  2023-05-24  9:47   ` Frieder Schrempf
  2023-05-30 12:46   ` Mark Brown
  2023-05-24  9:19 ` [PATCH v6 3/5] spi: spidev: add two new spi mode bits Boerge Struempfel
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 11+ messages in thread
From: Boerge Struempfel @ 2023-05-24  9:19 UTC (permalink / raw)
  Cc: boerge.struempfel, bstruempfel, andy.shevchenko, festevam,
	amit.kumar-mahapatra, broonie, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, linux-spi,
	linux-arm-kernel, linux-kernel

By default, the spi-imx controller pulls the mosi line high, whenever it
is idle. This behaviour can be inverted per CS by setting the
corresponding DATA_CTL bit in the config register of the controller.

Also, since the controller mode-bits have to be touched anyways, the
SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag.

Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
---
 drivers/spi/spi-imx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 34e5f81ec431..1c4172fcba2d 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -281,6 +281,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device
 #define MX51_ECSPI_CONFIG_SCLKPOL(cs)	(1 << ((cs & 3) +  4))
 #define MX51_ECSPI_CONFIG_SBBCTRL(cs)	(1 << ((cs & 3) +  8))
 #define MX51_ECSPI_CONFIG_SSBPOL(cs)	(1 << ((cs & 3) + 12))
+#define MX51_ECSPI_CONFIG_DATACTL(cs)	(1 << ((cs & 3) + 16))
 #define MX51_ECSPI_CONFIG_SCLKCTL(cs)	(1 << ((cs & 3) + 20))
 
 #define MX51_ECSPI_INT		0x10
@@ -573,6 +574,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
 		cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0));
 	}
 
+	if (spi->mode & SPI_MOSI_IDLE_LOW)
+		cfg |= MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0));
+	else
+		cfg &= ~MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0));
+
 	if (spi->mode & SPI_CS_HIGH)
 		cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0));
 	else
@@ -1743,7 +1749,8 @@ static int spi_imx_probe(struct platform_device *pdev)
 	spi_imx->controller->prepare_message = spi_imx_prepare_message;
 	spi_imx->controller->unprepare_message = spi_imx_unprepare_message;
 	spi_imx->controller->slave_abort = spi_imx_slave_abort;
-	spi_imx->controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS;
+	spi_imx->controller->mode_bits = SPI_MODE_X_MASK | SPI_CS_HIGH | SPI_NO_CS |
+					 SPI_MOSI_IDLE_LOW;
 
 	if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) ||
 	    is_imx53_ecspi(spi_imx))
-- 
2.40.1


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

* [PATCH v6 3/5] spi: spidev: add two new spi mode bits
  2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 1/5] " Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 2/5] spi: spi-imx: add support for " Boerge Struempfel
@ 2023-05-24  9:19 ` Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 4/5] spi: spidev_test: Sorted the options into logical groups Boerge Struempfel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Boerge Struempfel @ 2023-05-24  9:19 UTC (permalink / raw)
  Cc: boerge.struempfel, bstruempfel, andy.shevchenko, festevam,
	amit.kumar-mahapatra, broonie, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, linux-spi,
	linux-arm-kernel, linux-kernel

Allow userspace to set SPI_MOSI_IDLE_LOW and the SPI_3WIRE_HIZ mode bit
using the SPI_IOC_WR_MODE32 ioctl.

Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
---
 drivers/spi/spidev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 39d94c850839..c8b938e0f342 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -64,7 +64,8 @@ static_assert(N_SPI_MINORS > 0 && N_SPI_MINORS <= 256);
 				| SPI_NO_CS | SPI_READY | SPI_TX_DUAL \
 				| SPI_TX_QUAD | SPI_TX_OCTAL | SPI_RX_DUAL \
 				| SPI_RX_QUAD | SPI_RX_OCTAL \
-				| SPI_RX_CPHA_FLIP)
+				| SPI_RX_CPHA_FLIP | SPI_3WIRE_HIZ \
+				| SPI_MOSI_IDLE_LOW)
 
 struct spidev_data {
 	dev_t			devt;
-- 
2.40.1


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

* [PATCH v6 4/5] spi: spidev_test: Sorted the options into logical groups
  2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
                   ` (2 preceding siblings ...)
  2023-05-24  9:19 ` [PATCH v6 3/5] spi: spidev: add two new spi mode bits Boerge Struempfel
@ 2023-05-24  9:19 ` Boerge Struempfel
  2023-05-24  9:19 ` [PATCH v6 5/5] spi: spidev_test Add three missing spi mode bits Boerge Struempfel
  2023-05-30 17:40 ` [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Mark Brown
  5 siblings, 0 replies; 11+ messages in thread
From: Boerge Struempfel @ 2023-05-24  9:19 UTC (permalink / raw)
  Cc: boerge.struempfel, bstruempfel, andy.shevchenko, festevam,
	amit.kumar-mahapatra, broonie, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, linux-spi,
	linux-arm-kernel, linux-kernel

In order to increase usability, the command line options are sorted into
logical groups. In addition, the usage string was sorted alphabetically,
and the missing parameters '8','i' and 'o' were added. Furthermore, the
option descriptions were moved further to the right, in order to allow
for longer option names.

Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
---
 tools/spi/spidev_test.c | 90 ++++++++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 42 deletions(-)

diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index b0ca44c70e83..2d2cee339b39 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -172,28 +172,34 @@
 
 static void print_usage(const char *prog)
 {
-	printf("Usage: %s [-DsbdlHOLC3vpNR24SI]\n", prog);
-	puts("  -D --device   device to use (default /dev/spidev1.1)\n"
-	     "  -s --speed    max speed (Hz)\n"
-	     "  -d --delay    delay (usec)\n"
-	     "  -b --bpw      bits per word\n"
-	     "  -i --input    input data from a file (e.g. \"test.bin\")\n"
-	     "  -o --output   output data to a file (e.g. \"results.bin\")\n"
-	     "  -l --loop     loopback\n"
-	     "  -H --cpha     clock phase\n"
-	     "  -O --cpol     clock polarity\n"
-	     "  -L --lsb      least significant bit first\n"
-	     "  -C --cs-high  chip select active high\n"
-	     "  -3 --3wire    SI/SO signals shared\n"
-	     "  -v --verbose  Verbose (show tx buffer)\n"
-	     "  -p            Send data (e.g. \"1234\\xde\\xad\")\n"
-	     "  -N --no-cs    no chip select\n"
-	     "  -R --ready    slave pulls low to pause\n"
-	     "  -2 --dual     dual transfer\n"
-	     "  -4 --quad     quad transfer\n"
-	     "  -8 --octal    octal transfer\n"
-	     "  -S --size     transfer size\n"
-	     "  -I --iter     iterations\n");
+	printf("Usage: %s [-2348CDHILNORSbdilopsv]\n", prog);
+	puts("general device settings:\n"
+		 "  -D --device         device to use (default /dev/spidev1.1)\n"
+		 "  -s --speed          max speed (Hz)\n"
+		 "  -d --delay          delay (usec)\n"
+		 "  -l --loop           loopback\n"
+		 "spi mode:\n"
+		 "  -H --cpha           clock phase\n"
+		 "  -O --cpol           clock polarity\n"
+		 "number of wires for transmission:\n"
+		 "  -2 --dual           dual transfer\n"
+		 "  -4 --quad           quad transfer\n"
+		 "  -8 --octal          octal transfer\n"
+		 "  -3 --3wire          SI/SO signals shared\n"
+		 "data:\n"
+		 "  -i --input          input data from a file (e.g. \"test.bin\")\n"
+		 "  -o --output         output data to a file (e.g. \"results.bin\")\n"
+		 "  -p                  Send data (e.g. \"1234\\xde\\xad\")\n"
+		 "  -S --size           transfer size\n"
+		 "  -I --iter           iterations\n"
+		 "additional parameters:\n"
+		 "  -b --bpw            bits per word\n"
+		 "  -L --lsb            least significant bit first\n"
+		 "  -C --cs-high        chip select active high\n"
+		 "  -N --no-cs          no chip select\n"
+		 "  -R --ready          slave pulls low to pause\n"
+		 "misc:\n"
+		 "  -v --verbose        Verbose (show tx buffer)\n");
 	exit(1);
 }
 
@@ -201,26 +207,26 @@ static void parse_opts(int argc, char *argv[])
 {
 	while (1) {
 		static const struct option lopts[] = {
-			{ "device",  1, 0, 'D' },
-			{ "speed",   1, 0, 's' },
-			{ "delay",   1, 0, 'd' },
-			{ "bpw",     1, 0, 'b' },
-			{ "input",   1, 0, 'i' },
-			{ "output",  1, 0, 'o' },
-			{ "loop",    0, 0, 'l' },
-			{ "cpha",    0, 0, 'H' },
-			{ "cpol",    0, 0, 'O' },
-			{ "lsb",     0, 0, 'L' },
-			{ "cs-high", 0, 0, 'C' },
-			{ "3wire",   0, 0, '3' },
-			{ "no-cs",   0, 0, 'N' },
-			{ "ready",   0, 0, 'R' },
-			{ "dual",    0, 0, '2' },
-			{ "verbose", 0, 0, 'v' },
-			{ "quad",    0, 0, '4' },
-			{ "octal",   0, 0, '8' },
-			{ "size",    1, 0, 'S' },
-			{ "iter",    1, 0, 'I' },
+			{ "device",        1, 0, 'D' },
+			{ "speed",         1, 0, 's' },
+			{ "delay",         1, 0, 'd' },
+			{ "loop",          0, 0, 'l' },
+			{ "cpha",          0, 0, 'H' },
+			{ "cpol",          0, 0, 'O' },
+			{ "dual",          0, 0, '2' },
+			{ "quad",          0, 0, '4' },
+			{ "octal",         0, 0, '8' },
+			{ "3wire",         0, 0, '3' },
+			{ "input",         1, 0, 'i' },
+			{ "output",        1, 0, 'o' },
+			{ "size",          1, 0, 'S' },
+			{ "iter",          1, 0, 'I' },
+			{ "bpw",           1, 0, 'b' },
+			{ "lsb",           0, 0, 'L' },
+			{ "cs-high",       0, 0, 'C' },
+			{ "no-cs",         0, 0, 'N' },
+			{ "ready",         0, 0, 'R' },
+			{ "verbose",       0, 0, 'v' },
 			{ NULL, 0, 0, 0 },
 		};
 		int c;
-- 
2.40.1


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

* [PATCH v6 5/5] spi: spidev_test Add three missing spi mode bits
  2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
                   ` (3 preceding siblings ...)
  2023-05-24  9:19 ` [PATCH v6 4/5] spi: spidev_test: Sorted the options into logical groups Boerge Struempfel
@ 2023-05-24  9:19 ` Boerge Struempfel
  2023-05-30 17:40 ` [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Mark Brown
  5 siblings, 0 replies; 11+ messages in thread
From: Boerge Struempfel @ 2023-05-24  9:19 UTC (permalink / raw)
  Cc: boerge.struempfel, bstruempfel, andy.shevchenko, festevam,
	amit.kumar-mahapatra, broonie, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, linux-spi,
	linux-arm-kernel, linux-kernel

Added the three missing spi mode bits SPI_3WIRE_HIZ, SPI_RX_CPHA_FLIP,
and SPI_MOSI_IDLE_LOW.

Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
---
 tools/spi/spidev_test.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index 2d2cee339b39..9179942d7f15 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -172,7 +172,7 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
 
 static void print_usage(const char *prog)
 {
-	printf("Usage: %s [-2348CDHILNORSbdilopsv]\n", prog);
+	printf("Usage: %s [-2348CDFHILMNORSZbdilopsv]\n", prog);
 	puts("general device settings:\n"
 		 "  -D --device         device to use (default /dev/spidev1.1)\n"
 		 "  -s --speed          max speed (Hz)\n"
@@ -181,11 +181,13 @@ static void print_usage(const char *prog)
 		 "spi mode:\n"
 		 "  -H --cpha           clock phase\n"
 		 "  -O --cpol           clock polarity\n"
+		 "  -F --rx-cpha-flip   flip CPHA on Rx only xfer\n"
 		 "number of wires for transmission:\n"
 		 "  -2 --dual           dual transfer\n"
 		 "  -4 --quad           quad transfer\n"
 		 "  -8 --octal          octal transfer\n"
 		 "  -3 --3wire          SI/SO signals shared\n"
+		 "  -Z --3wire-hiz      high impedance turnaround\n"
 		 "data:\n"
 		 "  -i --input          input data from a file (e.g. \"test.bin\")\n"
 		 "  -o --output         output data to a file (e.g. \"results.bin\")\n"
@@ -198,6 +200,7 @@ static void print_usage(const char *prog)
 		 "  -C --cs-high        chip select active high\n"
 		 "  -N --no-cs          no chip select\n"
 		 "  -R --ready          slave pulls low to pause\n"
+		 "  -M --mosi-idle-low  leave mosi line low when idle\n"
 		 "misc:\n"
 		 "  -v --verbose        Verbose (show tx buffer)\n");
 	exit(1);
@@ -213,10 +216,12 @@ static void parse_opts(int argc, char *argv[])
 			{ "loop",          0, 0, 'l' },
 			{ "cpha",          0, 0, 'H' },
 			{ "cpol",          0, 0, 'O' },
+			{ "rx-cpha-flip",  0, 0, 'F' },
 			{ "dual",          0, 0, '2' },
 			{ "quad",          0, 0, '4' },
 			{ "octal",         0, 0, '8' },
 			{ "3wire",         0, 0, '3' },
+			{ "3wire-hiz",     0, 0, 'Z' },
 			{ "input",         1, 0, 'i' },
 			{ "output",        1, 0, 'o' },
 			{ "size",          1, 0, 'S' },
@@ -226,12 +231,13 @@ static void parse_opts(int argc, char *argv[])
 			{ "cs-high",       0, 0, 'C' },
 			{ "no-cs",         0, 0, 'N' },
 			{ "ready",         0, 0, 'R' },
+			{ "mosi-idle-low", 0, 0, 'M' },
 			{ "verbose",       0, 0, 'v' },
 			{ NULL, 0, 0, 0 },
 		};
 		int c;
 
-		c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3NR248p:vS:I:",
+		c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3ZFMNR248p:vS:I:",
 				lopts, NULL);
 
 		if (c == -1)
@@ -274,6 +280,15 @@ static void parse_opts(int argc, char *argv[])
 		case '3':
 			mode |= SPI_3WIRE;
 			break;
+		case 'Z':
+			mode |= SPI_3WIRE_HIZ;
+			break;
+		case 'F':
+			mode |= SPI_RX_CPHA_FLIP;
+			break;
+		case 'M':
+			mode |= SPI_MOSI_IDLE_LOW;
+			break;
 		case 'N':
 			mode |= SPI_NO_CS;
 			break;
-- 
2.40.1


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

* Re: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
  2023-05-24  9:19 ` [PATCH v6 2/5] spi: spi-imx: add support for " Boerge Struempfel
@ 2023-05-24  9:47   ` Frieder Schrempf
  2023-05-24 11:42     ` Börge Strümpfel
  2023-05-30 12:46   ` Mark Brown
  1 sibling, 1 reply; 11+ messages in thread
From: Frieder Schrempf @ 2023-05-24  9:47 UTC (permalink / raw)
  To: Boerge Struempfel
  Cc: bstruempfel, andy.shevchenko, festevam, amit.kumar-mahapatra,
	broonie, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-spi, linux-arm-kernel, linux-kernel

On 24.05.23 11:19, Boerge Struempfel wrote:
> By default, the spi-imx controller pulls the mosi line high, whenever it
> is idle. This behaviour can be inverted per CS by setting the
> corresponding DATA_CTL bit in the config register of the controller.
> 
> Also, since the controller mode-bits have to be touched anyways, the
> SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag.
> 
> Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>

Thanks for working on this! We used a similar downstream patch for
driving NeoPixels with i.MX. I'm happy to see a proper upstream solution.

I also have this Python module [1] around for using spidev to drive the
LEDs. It would be nice to see support for SPI_MOSI_IDLE_LOW in py-spidev
[2] so we could use it there. Though the latter looks a bit like it is
not properly maintained anymore.

[1] https://github.com/fschrempf/py-neopixel-spidev
[2] https://github.com/doceme/py-spidev

Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>

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

* Re: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
  2023-05-24  9:47   ` Frieder Schrempf
@ 2023-05-24 11:42     ` Börge Strümpfel
  0 siblings, 0 replies; 11+ messages in thread
From: Börge Strümpfel @ 2023-05-24 11:42 UTC (permalink / raw)
  To: Frieder Schrempf
  Cc: bstruempfel, andy.shevchenko, festevam, amit.kumar-mahapatra,
	broonie, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-spi, linux-arm-kernel, linux-kernel,
	gch981213

Am Mi., 24. Mai 2023 um 11:47 Uhr schrieb Frieder Schrempf
<frieder.schrempf@kontron.de>:
>
> On 24.05.23 11:19, Boerge Struempfel wrote:
> > By default, the spi-imx controller pulls the mosi line high, whenever it
> > is idle. This behaviour can be inverted per CS by setting the
> > corresponding DATA_CTL bit in the config register of the controller.
> >
> > Also, since the controller mode-bits have to be touched anyways, the
> > SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag.
> >
> > Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
>
> Thanks for working on this! We used a similar downstream patch for
> driving NeoPixels with i.MX. I'm happy to see a proper upstream solution.
>

Thanks for your reply. I'm glad to see that there is an interest for this
and I'm not the only one, who is working with this.

> I also have this Python module [1] around for using spidev to drive the
> LEDs. It would be nice to see support for SPI_MOSI_IDLE_LOW in py-spidev
> [2] so we could use it there. Though the latter looks a bit like it is
> not properly maintained anymore.

The python modules looks interesting.

FYI: there is already another patch by Chuanhong Guo on the mailing
list, which implements a proper driver for neopixel leds. It also allows
to add them via DT and access them via sys-fs. It might be an
interesting upstream alternative for your python module if it gets
accepted.

https://lore.kernel.org/lkml/20221212045558.69602-1-gch981213@gmail.com/

>
> [1] https://github.com/fschrempf/py-neopixel-spidev
> [2] https://github.com/doceme/py-spidev
>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>

--
Kind Regards,
Börge Strümpfel

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

* Re: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
  2023-05-24  9:19 ` [PATCH v6 2/5] spi: spi-imx: add support for " Boerge Struempfel
  2023-05-24  9:47   ` Frieder Schrempf
@ 2023-05-30 12:46   ` Mark Brown
  2023-05-30 13:27     ` Börge Strümpfel
  1 sibling, 1 reply; 11+ messages in thread
From: Mark Brown @ 2023-05-30 12:46 UTC (permalink / raw)
  To: Boerge Struempfel
  Cc: bstruempfel, andy.shevchenko, festevam, amit.kumar-mahapatra,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, NXP Linux Team,
	linux-spi, linux-arm-kernel, linux-kernel

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

On Wed, May 24, 2023 at 11:19:45AM +0200, Boerge Struempfel wrote:
> By default, the spi-imx controller pulls the mosi line high, whenever it
> is idle. This behaviour can be inverted per CS by setting the
> corresponding DATA_CTL bit in the config register of the controller.

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] 11+ messages in thread

* Re: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
  2023-05-30 12:46   ` Mark Brown
@ 2023-05-30 13:27     ` Börge Strümpfel
  0 siblings, 0 replies; 11+ messages in thread
From: Börge Strümpfel @ 2023-05-30 13:27 UTC (permalink / raw)
  To: Mark Brown
  Cc: bstruempfel, andy.shevchenko, festevam, amit.kumar-mahapatra,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, NXP Linux Team,
	linux-spi, linux-arm-kernel, linux-kernel

Am Di., 30. Mai 2023 um 14:46 Uhr schrieb Mark Brown <broonie@kernel.org>:
>
> On Wed, May 24, 2023 at 11:19:45AM +0200, Boerge Struempfel wrote:
> > By default, the spi-imx controller pulls the mosi line high, whenever it
> > is idle. This behaviour can be inverted per CS by setting the
> > corresponding DATA_CTL bit in the config register of the controller.
>
> This doesn't apply against current code, please check and resend.

I wrote this patch against the current master and not the next/master.
I'll upload an adjusted patch version momentarily.
I'm sorry for the inconvenience.

--
Kind Regards,
Börge Strümpfel

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

* Re: [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit
  2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
                   ` (4 preceding siblings ...)
  2023-05-24  9:19 ` [PATCH v6 5/5] spi: spidev_test Add three missing spi mode bits Boerge Struempfel
@ 2023-05-30 17:40 ` Mark Brown
  5 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2023-05-30 17:40 UTC (permalink / raw)
  To: Boerge Struempfel
  Cc: bstruempfel, andy.shevchenko, festevam, amit.kumar-mahapatra,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, NXP Linux Team,
	linux-spi, linux-arm-kernel, linux-kernel

On Wed, 24 May 2023 11:19:43 +0200, Boerge Struempfel wrote:
> Some spi controller switch the mosi line to high, whenever they are
> idle. This may not be desired in all use cases. For example neopixel
> leds can get confused and flicker due to misinterpreting the idle state.
> Therefore, we introduce a new spi-mode bit, with which the idle behaviour
> can be overwritten on a per device basis.
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/5] spi: add SPI_MOSI_IDLE_LOW mode bit
      commit: fe73245592fef75a7c41180a3fbb07c9a75f622e
[2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
      commit: 6a983ff5102ff0d859df05ca3f5cf2f6a17c0fad
[3/5] spi: spidev: add two new spi mode bits
      commit: 5cc223ca4858ec40bd2b8522ebc51c0d4963e51f
[4/5] spi: spidev_test: Sorted the options into logical groups
      commit: 113f36f2dce3a5a1aacbfa700c44080ec37ee3a0
[5/5] spi: spidev_test Add three missing spi mode bits
      commit: b229a7f530ebea90c8e21b56872f3102e3d54461

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

end of thread, other threads:[~2023-05-30 17:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24  9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
2023-05-24  9:19 ` [PATCH v6 1/5] " Boerge Struempfel
2023-05-24  9:19 ` [PATCH v6 2/5] spi: spi-imx: add support for " Boerge Struempfel
2023-05-24  9:47   ` Frieder Schrempf
2023-05-24 11:42     ` Börge Strümpfel
2023-05-30 12:46   ` Mark Brown
2023-05-30 13:27     ` Börge Strümpfel
2023-05-24  9:19 ` [PATCH v6 3/5] spi: spidev: add two new spi mode bits Boerge Struempfel
2023-05-24  9:19 ` [PATCH v6 4/5] spi: spidev_test: Sorted the options into logical groups Boerge Struempfel
2023-05-24  9:19 ` [PATCH v6 5/5] spi: spidev_test Add three missing spi mode bits Boerge Struempfel
2023-05-30 17:40 ` [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).