* [PATCH/RFC 6/6] spi: bcm2835: set gpio-cs to high state prior to any
@ 2015-03-29 14:03 Martin Sperl
[not found] ` <DA037FBB-56A7-4379-88F0-650367BBB822-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Martin Sperl @ 2015-03-29 14:03 UTC (permalink / raw)
To: Mark Brown, Stephen Warren, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
device initialization
The situation has been observed that on the RPI after a reboot the
GPIOs used for chip-selects are set to low when pinctl finishes setting
up the direction of the pins.
This can negatively impact the spi-bus and inhibit propper device
detection.
This (incomplete) code pulls the CS high to avoid the situation in the
common case of "normal" CS-priority - it still needs a revisit to get
the reverse polarity cases right as well.
A variation of this probably should get moved into spi_register_master
to fix this for other spi-controller as well.
Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Tested-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
---
drivers/spi/spi-bcm2835.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
Applies against spi - topic/bcm2835.
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 1d731b8..b6825a4 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -349,6 +349,26 @@ static int bcm2835_spi_setup(struct spi_device *spi)
return -EINVAL;
}
+static void bcm2835_spi_initialsetup_gpio(struct spi_master *master)
+{
+ int i;
+ bool level;
+
+ if (!master->cs_gpios)
+ return;
+
+ for (i = 0; i < master->num_chipselect; i++) {
+ if (gpio_is_valid(master->cs_gpios[i])) {
+ /* actually we need to figure out the
+ * configured CSPOL of that device here,
+ * not sure how to do that...
+ */
+ level = true;
+ gpio_set_value(master->cs_gpios[i], level);
+ }
+ }
+}
+
static int bcm2835_spi_probe(struct platform_device *pdev)
{
struct spi_master *master;
@@ -414,6 +434,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
goto out_clk_disable;
}
+ /* set GPIO-CS to disabled */
+ bcm2835_spi_initialsetup_gpio(master);
+
return 0;
out_clk_disable:
--
1.7.10.4
--
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: [PATCH/RFC 6/6] spi: bcm2835: set gpio-cs to high state prior to any
[not found] ` <DA037FBB-56A7-4379-88F0-650367BBB822-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
@ 2015-03-30 4:28 ` Mark Brown
[not found] ` <20150330042821.GD1568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2015-03-30 4:28 UTC (permalink / raw)
To: Martin Sperl
Cc: Stephen Warren, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
[-- Attachment #1: Type: text/plain, Size: 229 bytes --]
On Sun, Mar 29, 2015 at 04:03:28PM +0200, Martin Sperl wrote:
> A variation of this probably should get moved into spi_register_master
> to fix this for other spi-controller as well.
Yes, this is the wrong place to solve this.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFC 6/6] spi: bcm2835: set gpio-cs to high state prior to any
[not found] ` <20150330042821.GD1568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2015-03-30 19:25 ` Martin Sperl
[not found] ` <F17E5383-B75E-4884-9673-0C9E95750E4A-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Martin Sperl @ 2015-03-30 19:25 UTC (permalink / raw)
To: Mark Brown
Cc: Stephen Warren, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
> On 30.03.2015, at 06:28, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>
> On Sun, Mar 29, 2015 at 04:03:28PM +0200, Martin Sperl wrote:
>
>> A variation of this probably should get moved into spi_register_master
>> to fix this for other spi-controller as well.
>
> Yes, this is the wrong place to solve this.
So should we move that into spi_register_master?
My question for completeness remains: how do we get the devices
from dt or whatever while we are still registering the master?
Also I am still missing a bit of the big picture and vision how
to implement it taking all different HW/setup cases into account.
That is why I have put it as an RFC - mostly to get the issue some
exposure and some ideas.
--
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] 5+ messages in thread
* Re: [PATCH/RFC 6/6] spi: bcm2835: set gpio-cs to high state prior to any
[not found] ` <F17E5383-B75E-4884-9673-0C9E95750E4A-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
@ 2015-03-31 3:35 ` Stephen Warren
[not found] ` <551A1611.1090708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2015-03-31 3:35 UTC (permalink / raw)
To: Martin Sperl
Cc: Mark Brown, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
On 03/30/2015 01:25 PM, Martin Sperl wrote:
>
>> On 30.03.2015, at 06:28, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>>
>> On Sun, Mar 29, 2015 at 04:03:28PM +0200, Martin Sperl wrote:
>>
>>> A variation of this probably should get moved into spi_register_master
>>> to fix this for other spi-controller as well.
>>
>> Yes, this is the wrong place to solve this.
>
> So should we move that into spi_register_master?
> My question for completeness remains: how do we get the devices
> from dt or whatever while we are still registering the master?
>
> Also I am still missing a bit of the big picture and vision how
> to implement it taking all different HW/setup cases into account.
>
> That is why I have put it as an RFC - mostly to get the issue some
> exposure and some ideas.
I suspect the solution is simply not to have the pinctrl node set the CS
pins to GPIO_OUT, but rather rely on gpio_request() ->
bcm2835_gpio_request() -> bcm2835_pmx_gpio_set_direction() setting up
the pinmux function for any GPIOs that are requested. Presumably, the CS
GPIO for each chip is only requested when the DT node for the SPI device
(not SPI controller device) has been parsed, so the correct GPIO CS
value can be passed to gpio_request()/gpio_direction_output()?
--
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] 5+ messages in thread
* Re: [PATCH/RFC 6/6] spi: bcm2835: set gpio-cs to high state prior to any
[not found] ` <551A1611.1090708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2015-03-31 5:56 ` Martin Sperl
0 siblings, 0 replies; 5+ messages in thread
From: Martin Sperl @ 2015-03-31 5:56 UTC (permalink / raw)
To: Stephen Warren
Cc: Mark Brown, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
> On 31.03.2015, at 05:35, Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> wrote:
>
> I suspect the solution is simply not to have the pinctrl node set the CS
> pins to GPIO_OUT, but rather rely on gpio_request() ->
> bcm2835_gpio_request() -> bcm2835_pmx_gpio_set_direction() setting up
> the pinmux function for any GPIOs that are requested. Presumably, the CS
> GPIO for each chip is only requested when the DT node for the SPI device
> (not SPI controller device) has been parsed, so the correct GPIO CS
> value can be passed to gpio_request()/gpio_direction_output()?
I will investigate that and create a patch to spi_register_master that
does that for any GPIO-chipselect - this still leaves the question of
how to iterate over all the configured devices early to detect if they
hace cspol set and then setting it low instead of high.
Martin
--
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] 5+ messages in thread
end of thread, other threads:[~2015-03-31 5:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 14:03 [PATCH/RFC 6/6] spi: bcm2835: set gpio-cs to high state prior to any Martin Sperl
[not found] ` <DA037FBB-56A7-4379-88F0-650367BBB822-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-30 4:28 ` Mark Brown
[not found] ` <20150330042821.GD1568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-03-30 19:25 ` Martin Sperl
[not found] ` <F17E5383-B75E-4884-9673-0C9E95750E4A-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-31 3:35 ` Stephen Warren
[not found] ` <551A1611.1090708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-31 5:56 ` Martin Sperl
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.