All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] vf610-zii-dev-rev-b SPI fails at boot
@ 2019-02-21 15:24 ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 7+ messages in thread
From: Russell King - ARM Linux admin @ 2019-02-21 15:24 UTC (permalink / raw)
  To: linux-arm-kernel, Mark Brown, linux-spi, Lorenzo Bianconi

While booting 4.20 on the ZII development revision B board, I notice 
this in the kernel logs:

spi spi0.1: setup: unsupported mode bits 4
spi_gpio spi0: can't setup spi0.1, status -22
spi_master spi0: spi_device register error /spi0/at93c46d@1
spi_master spi0: Failed to create SPI device for /spi0/at93c46d@1

This is for the at93c46d@1 device attached to spi-gpio (see
arch/arm/boot/dts/vf610-zii-dev-rev-b.dts around line 330).  This
is declared with "spi-cs-high;" in DT.  It appears to be complaining
about the SPI_CS_HIGH flag.

It appears this warning comes from drivers/spi/spi.c around lines
2828-2847 due to:

	bad_bits = spi->mode & ~(spi->controller->mode_bits | SPI_CS_WORD);

and it looks like spi-gpio sets:

	master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL;

but then goes on to set:

	spi_gpio->bitbang.flags = SPI_CS_HIGH;

However, this is ignored by bitbang if master->mode_bits has already
been set:

	if (!master->mode_bits)
		master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags;

It looks like this commit introduced for v4.19 broke the driver:

commit 4b859db2c60692560afbfef1b030d0ddef57b7ee
Author: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date:   Sat Jul 28 10:19:14 2018 +0200

by setting master->mode_bits - prior to this, bitbang would have set
the mode bits itself.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

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

* [BUG] vf610-zii-dev-rev-b SPI fails at boot
@ 2019-02-21 15:24 ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 7+ messages in thread
From: Russell King - ARM Linux admin @ 2019-02-21 15:24 UTC (permalink / raw)
  To: linux-arm-kernel, Mark Brown, linux-spi, Lorenzo Bianconi

While booting 4.20 on the ZII development revision B board, I notice 
this in the kernel logs:

spi spi0.1: setup: unsupported mode bits 4
spi_gpio spi0: can't setup spi0.1, status -22
spi_master spi0: spi_device register error /spi0/at93c46d@1
spi_master spi0: Failed to create SPI device for /spi0/at93c46d@1

This is for the at93c46d@1 device attached to spi-gpio (see
arch/arm/boot/dts/vf610-zii-dev-rev-b.dts around line 330).  This
is declared with "spi-cs-high;" in DT.  It appears to be complaining
about the SPI_CS_HIGH flag.

It appears this warning comes from drivers/spi/spi.c around lines
2828-2847 due to:

	bad_bits = spi->mode & ~(spi->controller->mode_bits | SPI_CS_WORD);

and it looks like spi-gpio sets:

	master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL;

but then goes on to set:

	spi_gpio->bitbang.flags = SPI_CS_HIGH;

However, this is ignored by bitbang if master->mode_bits has already
been set:

	if (!master->mode_bits)
		master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags;

It looks like this commit introduced for v4.19 broke the driver:

commit 4b859db2c60692560afbfef1b030d0ddef57b7ee
Author: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date:   Sat Jul 28 10:19:14 2018 +0200

by setting master->mode_bits - prior to this, bitbang would have set
the mode bits itself.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] spi: spi-gpio: fix SPI_CS_HIGH capability
  2019-02-21 15:24 ` Russell King - ARM Linux admin
@ 2019-02-21 15:59   ` Russell King
  -1 siblings, 0 replies; 7+ messages in thread
From: Russell King @ 2019-02-21 15:59 UTC (permalink / raw)
  To: Mark Brown, Lorenzo Bianconi; +Cc: linux-arm-kernel, linux-spi

spi-gpio is capable of dealing with active-high chip-selects.
Unfortunately, commit 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE
support") broke this by setting master->mode_bits, which overrides
the setting in the spi-bitbang code.  Fix this.

Fixes: 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE support")
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
Patch against 4.20

 drivers/spi/spi-gpio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 45973ee3ae11..2d7cfe3c7732 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -410,7 +410,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		return status;
 
 	master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
-	master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL;
+	master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL | SPI_CS_HIGH;
 	master->flags = master_flags;
 	master->bus_num = pdev->id;
 	/* The master needs to think there is a chipselect even if not connected */
@@ -437,7 +437,6 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3;
 	}
 	spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer;
-	spi_gpio->bitbang.flags = SPI_CS_HIGH;
 
 	status = spi_bitbang_start(&spi_gpio->bitbang);
 	if (status)
-- 
2.7.4

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

* [PATCH] spi: spi-gpio: fix SPI_CS_HIGH capability
@ 2019-02-21 15:59   ` Russell King
  0 siblings, 0 replies; 7+ messages in thread
From: Russell King @ 2019-02-21 15:59 UTC (permalink / raw)
  To: Mark Brown, Lorenzo Bianconi; +Cc: linux-arm-kernel, linux-spi

spi-gpio is capable of dealing with active-high chip-selects.
Unfortunately, commit 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE
support") broke this by setting master->mode_bits, which overrides
the setting in the spi-bitbang code.  Fix this.

Fixes: 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE support")
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
Patch against 4.20

 drivers/spi/spi-gpio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 45973ee3ae11..2d7cfe3c7732 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -410,7 +410,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		return status;
 
 	master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
-	master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL;
+	master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL | SPI_CS_HIGH;
 	master->flags = master_flags;
 	master->bus_num = pdev->id;
 	/* The master needs to think there is a chipselect even if not connected */
@@ -437,7 +437,6 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3;
 	}
 	spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer;
-	spi_gpio->bitbang.flags = SPI_CS_HIGH;
 
 	status = spi_bitbang_start(&spi_gpio->bitbang);
 	if (status)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] spi: spi-gpio: fix SPI_CS_HIGH capability
  2019-02-21 15:59   ` Russell King
@ 2019-02-21 16:14     ` Fabio Estevam
  -1 siblings, 0 replies; 7+ messages in thread
From: Fabio Estevam @ 2019-02-21 16:14 UTC (permalink / raw)
  To: Russell King, Jonathan Neuschäfer
  Cc: Lorenzo Bianconi, Mark Brown,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-spi

On Thu, Feb 21, 2019 at 1:00 PM Russell King <rmk+kernel@armlinux.org.uk> wrote:
>
> spi-gpio is capable of dealing with active-high chip-selects.
> Unfortunately, commit 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE
> support") broke this by setting master->mode_bits, which overrides
> the setting in the spi-bitbang code.  Fix this.
>
> Fixes: 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE support")
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Patch against 4.20

Adding Jonathan who sent a similar fix recently:
https://patchwork.kernel.org/patch/10804855/

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

* Re: [PATCH] spi: spi-gpio: fix SPI_CS_HIGH capability
@ 2019-02-21 16:14     ` Fabio Estevam
  0 siblings, 0 replies; 7+ messages in thread
From: Fabio Estevam @ 2019-02-21 16:14 UTC (permalink / raw)
  To: Russell King, Jonathan Neuschäfer
  Cc: Lorenzo Bianconi, Mark Brown,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-spi

On Thu, Feb 21, 2019 at 1:00 PM Russell King <rmk+kernel@armlinux.org.uk> wrote:
>
> spi-gpio is capable of dealing with active-high chip-selects.
> Unfortunately, commit 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE
> support") broke this by setting master->mode_bits, which overrides
> the setting in the spi-bitbang code.  Fix this.
>
> Fixes: 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE support")
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Patch against 4.20

Adding Jonathan who sent a similar fix recently:
https://patchwork.kernel.org/patch/10804855/

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] spi: spi-gpio: fix SPI_CS_HIGH capability
  2019-02-21 16:14     ` Fabio Estevam
  (?)
@ 2019-02-21 19:21     ` Jonathan Neuschäfer
  -1 siblings, 0 replies; 7+ messages in thread
From: Jonathan Neuschäfer @ 2019-02-21 19:21 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Jonathan Neuschäfer, linux-spi, Russell King, Mark Brown,
	Lorenzo Bianconi,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE


[-- Attachment #1.1: Type: text/plain, Size: 789 bytes --]

On Thu, Feb 21, 2019 at 01:14:04PM -0300, Fabio Estevam wrote:
> On Thu, Feb 21, 2019 at 1:00 PM Russell King <rmk+kernel@armlinux.org.uk> wrote:
> >
> > spi-gpio is capable of dealing with active-high chip-selects.
> > Unfortunately, commit 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE
> > support") broke this by setting master->mode_bits, which overrides
> > the setting in the spi-bitbang code.  Fix this.
> >
> > Fixes: 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE support")
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> > Patch against 4.20
> 
> Adding Jonathan who sent a similar fix recently:
> https://patchwork.kernel.org/patch/10804855/

Hello Russel,

your patch looks better, and I think Mark Brown has already applied it.

Thanks.

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-02-21 19:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 15:24 [BUG] vf610-zii-dev-rev-b SPI fails at boot Russell King - ARM Linux admin
2019-02-21 15:24 ` Russell King - ARM Linux admin
2019-02-21 15:59 ` [PATCH] spi: spi-gpio: fix SPI_CS_HIGH capability Russell King
2019-02-21 15:59   ` Russell King
2019-02-21 16:14   ` Fabio Estevam
2019-02-21 16:14     ` Fabio Estevam
2019-02-21 19:21     ` Jonathan Neuschäfer

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.