All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: spi-gpio: Add check for cs-gpios dt property
@ 2013-11-13  8:02 Gerlando Falauto
  2013-11-13 13:33 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Gerlando Falauto @ 2013-11-13  8:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Gerlando Falauto, Maxime Ripard, Mark Brown

The bindings assumed that the cs-gpios property is always there.
However, a single SPI device can also work fine without an explicit chip select.
Use the SPI_GPIO_NO_CHIPSELECT mode when the property is not present or invaild.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-gpio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 0021fc4..3f21208 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -463,9 +463,16 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		 * property of the node.
 		 */
 
-		for (i = 0; i < SPI_N_CHIPSEL; i++)
+		for (i = 0; i < SPI_N_CHIPSEL; i++) {
 			spi_gpio->cs_gpios[i] =
 				of_get_named_gpio(np, "cs-gpios", i);
+			if ((SPI_N_CHIPSEL == 1)
+			&& !gpio_is_valid(spi_gpio->cs_gpios[i] < 0)) {
+				dev_info(&pdev->dev,
+					"no cs-gpios property, using no-cs mode\n");
+				spi_gpio->cs_gpios[i] = SPI_GPIO_NO_CHIPSELECT;
+			}
+		}
 	}
 #endif
 
-- 
1.8.0.1


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

* Re: [PATCH] spi: spi-gpio: Add check for cs-gpios dt property
  2013-11-13  8:02 [PATCH] spi: spi-gpio: Add check for cs-gpios dt property Gerlando Falauto
@ 2013-11-13 13:33 ` Mark Brown
  2013-11-13 14:33   ` Gerlando Falauto
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2013-11-13 13:33 UTC (permalink / raw)
  To: Gerlando Falauto; +Cc: linux-kernel, Maxime Ripard

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

On Wed, Nov 13, 2013 at 09:02:28AM +0100, Gerlando Falauto wrote:
> The bindings assumed that the cs-gpios property is always there.
> However, a single SPI device can also work fine without an explicit chip select.
> Use the SPI_GPIO_NO_CHIPSELECT mode when the property is not present or invaild.

Given that for most systems a missing /CS would be an error it seems
better to add an explicit property to enable this in order to help make
problems with the more common case more obvious.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] spi: spi-gpio: Add check for cs-gpios dt property
  2013-11-13 13:33 ` Mark Brown
@ 2013-11-13 14:33   ` Gerlando Falauto
  2013-11-13 14:57     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Gerlando Falauto @ 2013-11-13 14:33 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel@vger.kernel.org, Maxime Ripard

Hi Mark,

On 11/13/2013 02:33 PM, Mark Brown wrote:
> On Wed, Nov 13, 2013 at 09:02:28AM +0100, Gerlando Falauto wrote:
>> The bindings assumed that the cs-gpios property is always there.
>> However, a single SPI device can also work fine without an explicit chip select.
>> Use the SPI_GPIO_NO_CHIPSELECT mode when the property is not present or invaild.
>
> Given that for most systems a missing /CS would be an error it seems
> better to add an explicit property to enable this in order to help make
> problems with the more common case more obvious.
>

Thank you for your answer.
How about an empty

	cs-gpios;

property? To explicitly state we haven't just forgotten it -- we just 
know we don't have one instead. (There are plenty of empty "ranges;" 
properties in ARM DTSes -- I don't know if the use case is the same though).

Or else a null-valued

	cs-gpios = <0>;

property?

I'm open to other proposals of course.

Thanks again!
Gerlando

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

* Re: [PATCH] spi: spi-gpio: Add check for cs-gpios dt property
  2013-11-13 14:33   ` Gerlando Falauto
@ 2013-11-13 14:57     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-11-13 14:57 UTC (permalink / raw)
  To: Gerlando Falauto; +Cc: linux-kernel@vger.kernel.org, Maxime Ripard

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

On Wed, Nov 13, 2013 at 03:33:00PM +0100, Gerlando Falauto wrote:

> How about an empty

> 	cs-gpios;

> property? To explicitly state we haven't just forgotten it -- we
> just know we don't have one instead. (There are plenty of empty
> "ranges;" properties in ARM DTSes -- I don't know if the use case is
> the same though).

That seems reasonable.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-11-13 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-13  8:02 [PATCH] spi: spi-gpio: Add check for cs-gpios dt property Gerlando Falauto
2013-11-13 13:33 ` Mark Brown
2013-11-13 14:33   ` Gerlando Falauto
2013-11-13 14:57     ` Mark Brown

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.