linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/6] spi: bcm2835: fill FIFO before enabling interrupts to
@ 2015-03-29 14:03 Martin Sperl
       [not found] ` <3628E5E2-7EA9-488F-AF5F-A2E43D2D1E3E-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
  0 siblings, 1 reply; 19+ 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

 reduce interrupts/message

To reduce the number of interrupts/message we fill the FIFO before
enabling interrupts - for short messages this reduces the interrupt count
from 2 to 1 interrupt.

There have been rare cases where short (<200ns) chip-select switches with
native CS have been observed during such operation, this is why this
optimization is only enabled for GPIO-CS.

Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Tested-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
---
 drivers/spi/spi-bcm2835.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Applies against spi - topic/bcm2835

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 72d4525..adf157b 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -203,6 +203,22 @@ static int bcm2835_spi_transfer_one(struct spi_master *master,
 	bs->tx_len = tfr->len;
 	bs->rx_len = tfr->len;
 
+	/* fill in fifo if we have gpio-cs
+	 * note that there have been rare events where the native-CS
+	 * flapped for <1us which may change the behaviour
+	 * with gpio-cs this does not happen, so it is implemented
+	 * only for this case
+	 */
+	if (gpio_is_valid(spi->cs_gpio)) {
+		/* enable HW block, but without interrupts enabled
+		 * this would triggern an immediate interrupt
+		 */
+		bcm2835_wr(bs, BCM2835_SPI_CS,
+			   cs | BCM2835_SPI_CS_TA);
+		/* fill in tx fifo as much as possible */
+		bcm2835_wr_fifo(bs);
+	}
+
 	/*
 	 * Enable the HW block. This will immediately trigger a DONE (TX
 	 * empty) interrupt, upon which we will fill the TX FIFO with the
-- 
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] 19+ messages in thread

end of thread, other threads:[~2015-04-08  9:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 14:03 [PATCH 3/6] spi: bcm2835: fill FIFO before enabling interrupts to Martin Sperl
     [not found] ` <3628E5E2-7EA9-488F-AF5F-A2E43D2D1E3E-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-29 16:55   ` Mark Brown
2015-03-31  3:16   ` Stephen Warren
     [not found]     ` <551A1185.6060502-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-31  5:25       ` Mark Brown
     [not found]         ` <20150331052519.GZ2869-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-05  1:49           ` Stephen Warren
     [not found]             ` <552094B5.3050109-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-04-06 17:21               ` Mark Brown
     [not found]                 ` <20150406172130.GU6023-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-07  6:25                   ` Martin Sperl
     [not found]                     ` <B9B4E3CA-D9F2-4A79-BC78-C3BD4B3844F2-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-04-07  6:43                       ` Martin Sperl
2015-04-07 15:39                       ` Stephen Warren
     [not found]                         ` <5523FA17.6040009-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-04-07 16:28                           ` Mark Brown
     [not found]                             ` <20150407162857.GM6023-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-08  9:41                               ` Martin Sperl
2015-04-07 17:05                           ` Martin Sperl
     [not found]                             ` <1BAEDC46-354E-49F4-BC6A-6AA5C1A4A1B4-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-04-07 17:40                               ` Mark Brown
     [not found]                                 ` <20150407174003.GN6023-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-07 18:18                                   ` Martin Sperl
     [not found]                                     ` <BD11C8AC-F517-4120-BBD6-07618EE86604-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-04-07 18:23                                       ` Mark Brown
     [not found]                                         ` <20150407182327.GP6023-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-07 20:28                                           ` Martin Sperl
2015-04-08  2:01                               ` Stephen Warren
     [not found]                                 ` <55248C07.8070903-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-04-08  7:14                                   ` Martin Sperl
2015-03-31  5:51       ` Martin Sperl

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