linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] spi: spi-gpio: Add dt support for a single device with no chip select
@ 2014-10-27 15:27 Torsten Fleischer
  2014-10-27 17:30 ` Mark Rutland
  0 siblings, 1 reply; 3+ messages in thread
From: Torsten Fleischer @ 2014-10-27 15:27 UTC (permalink / raw)
  To: linux-spi, linux-kernel, Mark Brown, devicetree; +Cc: Torsten Fleischer

From: Torsten Fleischer <torfl6749@gmail.com>

Use an empty 'cs-gpios' property if a single device is connected which
has no chip select.
This refers to the discussion at https://lkml.org/lkml/2013/11/13/62.

Signed-off-by: Torsten Fleischer <torfl6749@gmail.com>
---
 Documentation/devicetree/bindings/spi/spi-gpio.txt |  6 ++++--
 drivers/spi/spi-gpio.c                             | 10 +++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-gpio.txt b/Documentation/devicetree/bindings/spi/spi-gpio.txt
index 8a824be..ad8795f 100644
--- a/Documentation/devicetree/bindings/spi/spi-gpio.txt
+++ b/Documentation/devicetree/bindings/spi/spi-gpio.txt
@@ -8,8 +8,10 @@ Required properties:
  - gpio-sck: GPIO spec for the SCK line to use
  - gpio-miso: GPIO spec for the MISO line to use
  - gpio-mosi: GPIO spec for the MOSI line to use
- - cs-gpios: GPIOs to use for chipselect lines
- - num-chipselects: number of chipselect lines
+ - cs-gpios: GPIOs to use for chipselect lines. Leave this property empty if
+             a single device with no chip select is connected.
+ - num-chipselects: Number of chipselect lines. Has to be "1" even if a single
+                    device with no chip select is connected.
 
 Example:
 
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 9f59553..b343818a 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -461,9 +461,13 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		 * property of the node.
 		 */
 
-		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) &&
+				(of_gpio_named_count(np, "cs-gpios") == 0))
+			spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT;
+		else
+			for (i = 0; i < SPI_N_CHIPSEL; i++)
+				spi_gpio->cs_gpios[i] =
+					of_get_named_gpio(np, "cs-gpios", i);
 	}
 #endif
 
-- 
1.8.4.5

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

* Re: [PATCH 1/1] spi: spi-gpio: Add dt support for a single device with no chip select
  2014-10-27 15:27 [PATCH 1/1] spi: spi-gpio: Add dt support for a single device with no chip select Torsten Fleischer
@ 2014-10-27 17:30 ` Mark Rutland
  2014-10-30  6:52   ` Torsten Fleischer
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Rutland @ 2014-10-27 17:30 UTC (permalink / raw)
  To: Torsten Fleischer
  Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mark Brown, devicetree@vger.kernel.org

On Mon, Oct 27, 2014 at 03:27:17PM +0000, Torsten Fleischer wrote:
> From: Torsten Fleischer <torfl6749@gmail.com>
> 
> Use an empty 'cs-gpios' property if a single device is connected which
> has no chip select.
> This refers to the discussion at https://lkml.org/lkml/2013/11/13/62.
> 
> Signed-off-by: Torsten Fleischer <torfl6749@gmail.com>
> ---
>  Documentation/devicetree/bindings/spi/spi-gpio.txt |  6 ++++--
>  drivers/spi/spi-gpio.c                             | 10 +++++++---
>  2 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/spi/spi-gpio.txt b/Documentation/devicetree/bindings/spi/spi-gpio.txt
> index 8a824be..ad8795f 100644
> --- a/Documentation/devicetree/bindings/spi/spi-gpio.txt
> +++ b/Documentation/devicetree/bindings/spi/spi-gpio.txt
> @@ -8,8 +8,10 @@ Required properties:
>   - gpio-sck: GPIO spec for the SCK line to use
>   - gpio-miso: GPIO spec for the MISO line to use
>   - gpio-mosi: GPIO spec for the MOSI line to use
> - - cs-gpios: GPIOs to use for chipselect lines
> - - num-chipselects: number of chipselect lines
> + - cs-gpios: GPIOs to use for chipselect lines. Leave this property empty if
> +             a single device with no chip select is connected.
> + - num-chipselects: Number of chipselect lines. Has to be "1" even if a single
> +                    device with no chip select is connected.

Why not just have num-chipselectes = <0>, and no cs-gpios property?

That would match the HW, and is unambigious as the author has to state
explicitly that there are no chipselects.

Mark.

>  
>  Example:
>  
> diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
> index 9f59553..b343818a 100644
> --- a/drivers/spi/spi-gpio.c
> +++ b/drivers/spi/spi-gpio.c
> @@ -461,9 +461,13 @@ static int spi_gpio_probe(struct platform_device *pdev)
>  		 * property of the node.
>  		 */
>  
> -		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) &&
> +				(of_gpio_named_count(np, "cs-gpios") == 0))
> +			spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT;
> +		else
> +			for (i = 0; i < SPI_N_CHIPSEL; i++)
> +				spi_gpio->cs_gpios[i] =
> +					of_get_named_gpio(np, "cs-gpios", i);
>  	}
>  #endif
>  
> -- 
> 1.8.4.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/1] spi: spi-gpio: Add dt support for a single device with no chip select
  2014-10-27 17:30 ` Mark Rutland
@ 2014-10-30  6:52   ` Torsten Fleischer
  0 siblings, 0 replies; 3+ messages in thread
From: Torsten Fleischer @ 2014-10-30  6:52 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Mark Brown,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

2014-10-27 18:30 GMT+01:00 Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>:
> On Mon, Oct 27, 2014 at 03:27:17PM +0000, Torsten Fleischer wrote:
>> From: Torsten Fleischer <torfl6749-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>
>> Use an empty 'cs-gpios' property if a single device is connected which
>> has no chip select.
>> This refers to the discussion at https://lkml.org/lkml/2013/11/13/62.
>>
>> Signed-off-by: Torsten Fleischer <torfl6749-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  Documentation/devicetree/bindings/spi/spi-gpio.txt |  6 ++++--
>>  drivers/spi/spi-gpio.c                             | 10 +++++++---
>>  2 files changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/spi/spi-gpio.txt b/Documentation/devicetree/bindings/spi/spi-gpio.txt
>> index 8a824be..ad8795f 100644
>> --- a/Documentation/devicetree/bindings/spi/spi-gpio.txt
>> +++ b/Documentation/devicetree/bindings/spi/spi-gpio.txt
>> @@ -8,8 +8,10 @@ Required properties:
>>   - gpio-sck: GPIO spec for the SCK line to use
>>   - gpio-miso: GPIO spec for the MISO line to use
>>   - gpio-mosi: GPIO spec for the MOSI line to use
>> - - cs-gpios: GPIOs to use for chipselect lines
>> - - num-chipselects: number of chipselect lines
>> + - cs-gpios: GPIOs to use for chipselect lines. Leave this property empty if
>> +             a single device with no chip select is connected.
>> + - num-chipselects: Number of chipselect lines. Has to be "1" even if a single
>> +                    device with no chip select is connected.
>
> Why not just have num-chipselectes = <0>, and no cs-gpios property?
>
> That would match the HW, and is unambigious as the author has to state
> explicitly that there are no chipselects.

Thanks for the objection. I agree to your proposal. This is a clearer
way to describe such
a hardware. I will send an updated patch.

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

end of thread, other threads:[~2014-10-30  6:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-27 15:27 [PATCH 1/1] spi: spi-gpio: Add dt support for a single device with no chip select Torsten Fleischer
2014-10-27 17:30 ` Mark Rutland
2014-10-30  6:52   ` Torsten Fleischer

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