linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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