* [PATCH 4/6] spi: bcm2835: warn about native-chip-selects being used
@ 2015-03-29 14:03 Martin Sperl
[not found] ` <0330B85B-A297-482B-80A9-E01F236D33D2-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
Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Tested-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
---
drivers/spi/spi-bcm2835.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
Applies against spi - topic/bcm2835
Could get replaced by something similar to this.
if (!gpio_is_valid(spi->gpio_cs)) {
if (spi->chip_select == 0) {
spi->gpio_cs = 8;
gpio_set_output(spi->gpio_cs);
}
if (spi->chip_select == 1) {
spi->gpio_cs = 7;
gpio_set_output(spi->gpio_cs);
}
}
But I do not know what is the correct call to use.
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index adf157b..601fc5e 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -82,6 +82,7 @@ struct bcm2835_spi {
u8 *rx_buf;
int tx_len;
int rx_len;
+ bool native_cs_use_warning_done;
};
static inline u32 bcm2835_rd(struct bcm2835_spi *bs, unsigned reg)
@@ -287,6 +288,9 @@ static void bcm2835_spi_set_cs(struct spi_device *spi, bool gpio_level)
static int bcm2835_spi_setup(struct spi_device *spi)
{
+ struct spi_master *master = spi->master;
+ struct bcm2835_spi *bs = spi_master_get_devdata(master);
+
/*
* sanity checking the native-chipselects
*/
@@ -294,6 +298,14 @@ static int bcm2835_spi_setup(struct spi_device *spi)
return 0;
if (gpio_is_valid(spi->cs_gpio))
return 0;
+ /* we are in the native chipselect case now,
+ * so warn about the fact that some things may not work as well
+ */
+ if (!bs->native_cs_use_warning_done) {
+ dev_warn(&spi->dev,
+ "setup: native chipselect is used - some driver functions/optimizations are not applied\n");
+ bs->native_cs_use_warning_done = 1;
+ }
if (spi->chip_select < 3)
return 0;
--
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 4/6] spi: bcm2835: warn about native-chip-selects being used
[not found] ` <0330B85B-A297-482B-80A9-E01F236D33D2-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
@ 2015-03-30 4:22 ` Mark Brown
[not found] ` <20150330042205.GB1568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-03-31 3:23 ` Stephen Warren
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2015-03-30 4:22 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: 565 bytes --]
On Sun, Mar 29, 2015 at 04:03:26PM +0200, Martin Sperl wrote:
> Could get replaced by something similar to this.
> if (!gpio_is_valid(spi->gpio_cs)) {
> if (spi->chip_select == 0) {
> spi->gpio_cs = 8;
> gpio_set_output(spi->gpio_cs);
> }
> if (spi->chip_select == 1) {
> spi->gpio_cs = 7;
> gpio_set_output(spi->gpio_cs);
> }
> }
> But I do not know what is the correct call to use.
I don't know what you mean by "correct call" here, sorry. If you're
talking about working out which GPIO maps to the /CS pin then can the
pinctrl API help?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 4/6] spi: bcm2835: warn about native-chip-selects being used
[not found] ` <20150330042205.GB1568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2015-03-30 19:20 ` Martin Sperl
[not found] ` <4790EEB6-C62D-4FE0-98AE-26ADE3024B04-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Martin Sperl @ 2015-03-30 19:20 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:22, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>>
>> But I do not know what is the correct call to use.
>
> I don't know what you mean by "correct call" here, sorry. If you're
> talking about working out which GPIO maps to the /CS pin then can the
> pinctrl API help?
Well - how do I change the mode of a GPIO to output (which is typically ALT0)?
something like this:
>> gpio_set_output(spi->gpio_cs);
I was hoping someone would have an explicit pointer...
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
* Re: [PATCH 4/6] spi: bcm2835: warn about native-chip-selects being used
[not found] ` <4790EEB6-C62D-4FE0-98AE-26ADE3024B04-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
@ 2015-03-31 3:21 ` Stephen Warren
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2015-03-31 3:21 UTC (permalink / raw)
To: Martin Sperl
Cc: Mark Brown, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
On 03/30/2015 01:20 PM, Martin Sperl wrote:
>
>> On 30.03.2015, at 06:22, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>>>
>>> But I do not know what is the correct call to use.
>>
>> I don't know what you mean by "correct call" here, sorry. If you're
>> talking about working out which GPIO maps to the /CS pin then can the
>> pinctrl API help?
>
> Well - how do I change the mode of a GPIO to output (which is typically ALT0)?
> something like this:
>
>>> gpio_set_output(spi->gpio_cs);
>
> I was hoping someone would have an explicit pointer...
Presumably the following DT bindings would work:
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
Documentation/devicetree/bindings/pinctrl/brcm,bcm2835-gpio.txt
--
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 4/6] spi: bcm2835: warn about native-chip-selects being used
[not found] ` <0330B85B-A297-482B-80A9-E01F236D33D2-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-30 4:22 ` Mark Brown
@ 2015-03-31 3:23 ` Stephen Warren
1 sibling, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2015-03-31 3:23 UTC (permalink / raw)
To: Martin Sperl
Cc: Mark Brown, lee-DgEjT+Ai2ygdnm+yROfE0A,
linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel
On 03/29/2015 08:03 AM, Martin Sperl wrote:
> Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
> Tested-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
It would be useful to have a commit description saying why such a
warning was useful.
> diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
> @@ -82,6 +82,7 @@ struct bcm2835_spi {
> u8 *rx_buf;
> int tx_len;
> int rx_len;
> + bool native_cs_use_warning_done;
> };
...
> @@ -294,6 +298,14 @@ static int bcm2835_spi_setup(struct spi_device *spi)
...
> + /* we are in the native chipselect case now,
> + * so warn about the fact that some things may not work as well
What things and why? (I'm asking mainly because that should be in the
commit description and perhaps this comment).
> + */
> + if (!bs->native_cs_use_warning_done) {
> + dev_warn(&spi->dev,
> + "setup: native chipselect is used - some driver functions/optimizations are not applied\n");
> + bs->native_cs_use_warning_done = 1;
> + }
Isn't there a warn_once() that would remove the need to check/set
native_cs_use_warning_done?
--
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 3:23 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 4/6] spi: bcm2835: warn about native-chip-selects being used Martin Sperl
[not found] ` <0330B85B-A297-482B-80A9-E01F236D33D2-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-30 4:22 ` Mark Brown
[not found] ` <20150330042205.GB1568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-03-30 19:20 ` Martin Sperl
[not found] ` <4790EEB6-C62D-4FE0-98AE-26ADE3024B04-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-31 3:21 ` Stephen Warren
2015-03-31 3:23 ` Stephen Warren
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).