* [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter
@ 2016-10-07 14:56 tthayer
2016-10-07 14:56 ` tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
2016-10-07 19:33 ` [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter Geert Uytterhoeven
0 siblings, 2 replies; 5+ messages in thread
From: tthayer @ 2016-10-07 14:56 UTC (permalink / raw)
To: broonie
Cc: andriy.shevchenko, jarkko.nikula, jszhang, michael, kernel,
linux-spi, linux-kernel, tthayer
From: Thor Thayer <tthayer@opensource.altera.com>
Some SPI masters require the slave to be selected before a
transaction can occur - even in the case of GPIO chip select.
This patch adds a GPIO slave select parameter to indicate
the slave needs to be selected in the GPIO CS case.
Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
---
v2 Add to SPI framework - add bindings.
---
Documentation/devicetree/bindings/spi/spi-bus.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
index 4b1d6e7..3a006bc 100644
--- a/Documentation/devicetree/bindings/spi/spi-bus.txt
+++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
@@ -24,6 +24,7 @@ support describing the chip select layout.
Optional properties:
- cs-gpios - gpios chip select.
- num-cs - total number of chipselects.
+- gpio-ss - use internal slave select with gpio chip select.
If cs-gpios is used the number of chip selects will be increased automatically
with max(cs-gpios > hw cs).
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCHv2 2/2] spi: Add Flag to Enable Slave Select with GPIO Chip Select.
@ 2016-10-07 14:56 ` tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
0 siblings, 0 replies; 5+ messages in thread
From: tthayer @ 2016-10-07 14:56 UTC (permalink / raw)
To: broonie
Cc: andriy.shevchenko, jarkko.nikula, jszhang, michael, kernel,
linux-spi, linux-kernel, tthayer
From: Thor Thayer <tthayer@opensource.altera.com>
Some SPI masters require slave selection before the transfer
can begin [1]. The SPI framework currently selects the chip using
either 1) the internal CS mechanism or 2) the GPIO CS, but not both.
This patch adds a boolean variable to indicate both the GPIO CS and
the internal chip select should be used.
Tested On:
Altera CycloneV development kit
Compile tested for build errors on x86_64 (allyesconfigs)
[1] DesignWare dw_apb_ssi Databook, Version 3.20a (page 39)
Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
---
v2 Move changes to SPI framework based on maintainer comments
Add a new SPI master boolean variable.
---
drivers/spi/spi.c | 10 ++++++++--
include/linux/spi/spi.h | 1 +
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5787b72..c042a8c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -697,10 +697,14 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
if (spi->mode & SPI_CS_HIGH)
enable = !enable;
- if (gpio_is_valid(spi->cs_gpio))
+ if (gpio_is_valid(spi->cs_gpio)) {
gpio_set_value(spi->cs_gpio, !enable);
- else if (spi->master->set_cs)
+ /* Some SPI masters need both GPIO CS & slave_select */
+ if (spi->master->set_cs && spi->master->gpio_ss)
+ spi->master->set_cs(spi, !enable);
+ } else if (spi->master->set_cs) {
spi->master->set_cs(spi, !enable);
+ }
}
#ifdef CONFIG_HAS_DMA
@@ -1845,6 +1849,8 @@ static int of_spi_register_master(struct spi_master *master)
for (i = 0; i < nb; i++)
cs[i] = of_get_named_gpio(np, "cs-gpios", i);
+ master->gpio_ss = of_property_read_bool(np, "gpio-ss");
+
return 0;
}
#else
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 4b743ac..0437995 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -551,6 +551,7 @@ struct spi_master {
/* gpio chip select */
int *cs_gpios;
+ bool gpio_ss;
/* statistics */
struct spi_statistics statistics;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCHv2 2/2] spi: Add Flag to Enable Slave Select with GPIO Chip Select.
@ 2016-10-07 14:56 ` tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
0 siblings, 0 replies; 5+ messages in thread
From: tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx @ 2016-10-07 14:56 UTC (permalink / raw)
To: broonie-DgEjT+Ai2ygdnm+yROfE0A
Cc: andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA,
jarkko.nikula-VuQAYsv1563Yd54FQh9/CA,
jszhang-eYqpPyKDWXRBDgjK7y7TUQ, michael-XrNoQAPr3WXM9gW82pYGhQ,
kernel-NoMTM8u0nx3R7s880joybQ, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
From: Thor Thayer <tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
Some SPI masters require slave selection before the transfer
can begin [1]. The SPI framework currently selects the chip using
either 1) the internal CS mechanism or 2) the GPIO CS, but not both.
This patch adds a boolean variable to indicate both the GPIO CS and
the internal chip select should be used.
Tested On:
Altera CycloneV development kit
Compile tested for build errors on x86_64 (allyesconfigs)
[1] DesignWare dw_apb_ssi Databook, Version 3.20a (page 39)
Signed-off-by: Thor Thayer <tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
---
v2 Move changes to SPI framework based on maintainer comments
Add a new SPI master boolean variable.
---
drivers/spi/spi.c | 10 ++++++++--
include/linux/spi/spi.h | 1 +
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5787b72..c042a8c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -697,10 +697,14 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
if (spi->mode & SPI_CS_HIGH)
enable = !enable;
- if (gpio_is_valid(spi->cs_gpio))
+ if (gpio_is_valid(spi->cs_gpio)) {
gpio_set_value(spi->cs_gpio, !enable);
- else if (spi->master->set_cs)
+ /* Some SPI masters need both GPIO CS & slave_select */
+ if (spi->master->set_cs && spi->master->gpio_ss)
+ spi->master->set_cs(spi, !enable);
+ } else if (spi->master->set_cs) {
spi->master->set_cs(spi, !enable);
+ }
}
#ifdef CONFIG_HAS_DMA
@@ -1845,6 +1849,8 @@ static int of_spi_register_master(struct spi_master *master)
for (i = 0; i < nb; i++)
cs[i] = of_get_named_gpio(np, "cs-gpios", i);
+ master->gpio_ss = of_property_read_bool(np, "gpio-ss");
+
return 0;
}
#else
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 4b743ac..0437995 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -551,6 +551,7 @@ struct spi_master {
/* gpio chip select */
int *cs_gpios;
+ bool gpio_ss;
/* statistics */
struct spi_statistics statistics;
--
1.7.9.5
--
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] 5+ messages in thread
* Re: [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter
2016-10-07 14:56 [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter tthayer
2016-10-07 14:56 ` tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
@ 2016-10-07 19:33 ` Geert Uytterhoeven
2016-10-07 20:01 ` Thor Thayer
1 sibling, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2016-10-07 19:33 UTC (permalink / raw)
To: tthayer
Cc: Mark Brown, Andy Shevchenko, Jarkko Nikula, jszhang, michael,
kernel, linux-spi, linux-kernel
On Fri, Oct 7, 2016 at 4:56 PM, <tthayer@opensource.altera.com> wrote:
> From: Thor Thayer <tthayer@opensource.altera.com>
>
> Some SPI masters require the slave to be selected before a
> transaction can occur - even in the case of GPIO chip select.
>
> This patch adds a GPIO slave select parameter to indicate
> the slave needs to be selected in the GPIO CS case.
>
> Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
> ---
> v2 Add to SPI framework - add bindings.
> ---
> Documentation/devicetree/bindings/spi/spi-bus.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
> index 4b1d6e7..3a006bc 100644
> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt
> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
> @@ -24,6 +24,7 @@ support describing the chip select layout.
> Optional properties:
> - cs-gpios - gpios chip select.
> - num-cs - total number of chipselects.
> +- gpio-ss - use internal slave select with gpio chip select.
>
> If cs-gpios is used the number of chip selects will be increased automatically
> with max(cs-gpios > hw cs).
To me, this looks more like a new flag the SPI controller driver should
set in spi_master.flags, instead of a DT property.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter
2016-10-07 19:33 ` [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter Geert Uytterhoeven
@ 2016-10-07 20:01 ` Thor Thayer
0 siblings, 0 replies; 5+ messages in thread
From: Thor Thayer @ 2016-10-07 20:01 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Mark Brown, Andy Shevchenko, Jarkko Nikula, jszhang, michael,
kernel, linux-spi, linux-kernel
On 10/07/2016 02:33 PM, Geert Uytterhoeven wrote:
> On Fri, Oct 7, 2016 at 4:56 PM, <tthayer@opensource.altera.com> wrote:
>> From: Thor Thayer <tthayer@opensource.altera.com>
>>
>> Some SPI masters require the slave to be selected before a
>> transaction can occur - even in the case of GPIO chip select.
>>
>> This patch adds a GPIO slave select parameter to indicate
>> the slave needs to be selected in the GPIO CS case.
>>
>> Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
>> ---
>> v2 Add to SPI framework - add bindings.
>> ---
>> Documentation/devicetree/bindings/spi/spi-bus.txt | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
>> index 4b1d6e7..3a006bc 100644
>> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt
>> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
>> @@ -24,6 +24,7 @@ support describing the chip select layout.
>> Optional properties:
>> - cs-gpios - gpios chip select.
>> - num-cs - total number of chipselects.
>> +- gpio-ss - use internal slave select with gpio chip select.
>>
>> If cs-gpios is used the number of chip selects will be increased automatically
>> with max(cs-gpios > hw cs).
>
> To me, this looks more like a new flag the SPI controller driver should
> set in spi_master.flags, instead of a DT property.
>
Yes, I see your point since this is SPI master specific. I'll respin as
you suggest.
Thanks for reviewing!
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-07 19:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-07 14:56 [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter tthayer
2016-10-07 14:56 ` [PATCHv2 2/2] spi: Add Flag to Enable Slave Select with GPIO Chip Select tthayer
2016-10-07 14:56 ` tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
2016-10-07 19:33 ` [PATCHv2 1/2] Documentation: dt: spi: Add GPIO Slave Select Parameter Geert Uytterhoeven
2016-10-07 20:01 ` Thor Thayer
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.