linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] spi: omap2: disable DMA requests before complete()
@ 2012-12-12  8:45 Felipe Balbi
  2012-12-12  8:46 ` [PATCH 2/2] spi: devicetree: add support for loopback mode Felipe Balbi
  2012-12-15  0:35 ` [PATCH 1/2] spi: omap2: disable DMA requests before complete() Grant Likely
  0 siblings, 2 replies; 6+ messages in thread
From: Felipe Balbi @ 2012-12-12  8:45 UTC (permalink / raw)
  To: spi-devel-general, rob, rob.herring
  Cc: grant.likely, devicetree-discuss, Linux OMAP Mailing List,
	Linux Kernel Mailing List, Tony Lindgren, Felipe Balbi

No actual errors have been found for completing
before disabling DMA request lines, but it just
looks more semantically correct that on our DMA
callback we quiesce the whole thing before stating
transfer is finished.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index b610f52..68446db 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -298,10 +298,10 @@ static void omap2_mcspi_rx_callback(void *data)
 	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
 	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	complete(&mcspi_dma->dma_rx_completion);
-
 	/* We must disable the DMA RX request */
 	omap2_mcspi_set_dma_req(spi, 1, 0);
+
+	complete(&mcspi_dma->dma_rx_completion);
 }
 
 static void omap2_mcspi_tx_callback(void *data)
@@ -310,10 +310,10 @@ static void omap2_mcspi_tx_callback(void *data)
 	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
 	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	complete(&mcspi_dma->dma_tx_completion);
-
 	/* We must disable the DMA TX request */
 	omap2_mcspi_set_dma_req(spi, 0, 0);
+
+	complete(&mcspi_dma->dma_tx_completion);
 }
 
 static void omap2_mcspi_tx_dma(struct spi_device *spi,
-- 
1.8.1.rc1.5.g7e0651a


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] spi: devicetree: add support for loopback mode
  2012-12-12  8:45 [PATCH 1/2] spi: omap2: disable DMA requests before complete() Felipe Balbi
@ 2012-12-12  8:46 ` Felipe Balbi
  2012-12-15  0:32   ` Grant Likely
  2012-12-15  0:35 ` [PATCH 1/2] spi: omap2: disable DMA requests before complete() Grant Likely
  1 sibling, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2012-12-12  8:46 UTC (permalink / raw)
  To: spi-devel-general, rob, rob.herring
  Cc: grant.likely, devicetree-discuss, Linux OMAP Mailing List,
	Linux Kernel Mailing List, Tony Lindgren, Felipe Balbi

there are a few spi master drivers which make
use of that flag but there is no way to pass it
through devicetree.

This patch just creates a way to pass SPI_LOOP
via devicetree.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++
 drivers/spi/spi.c                                 | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
index 296015e..1949586 100644
--- a/Documentation/devicetree/bindings/spi/spi-bus.txt
+++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
@@ -55,6 +55,8 @@ contain the following properties.
     		chip select active high
 - spi-3wire       - (optional) Empty property indicating device requires
     		    3-wire mode.
+- spi-loopback    - (optional) Empty property indicating device requires
+    		    loopback mode.
 
 If a gpio chipselect is used for the SPI slave the gpio number will be passed
 via the cs_gpio
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3f1b9ee..6bcdc03 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -868,6 +868,8 @@ static void of_register_spi_devices(struct spi_master *master)
 			spi->mode |= SPI_CS_HIGH;
 		if (of_find_property(nc, "spi-3wire", NULL))
 			spi->mode |= SPI_3WIRE;
+		if (of_find_property(nc, "spi-loopback", NULL))
+			spi->mode |= SPI_LOOP;
 
 		/* Device speed */
 		prop = of_get_property(nc, "spi-max-frequency", &len);
-- 
1.8.1.rc1.5.g7e0651a


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] spi: devicetree: add support for loopback mode
  2012-12-12  8:46 ` [PATCH 2/2] spi: devicetree: add support for loopback mode Felipe Balbi
@ 2012-12-15  0:32   ` Grant Likely
  2012-12-15 14:55     ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Grant Likely @ 2012-12-15  0:32 UTC (permalink / raw)
  To: Felipe Balbi, spi-devel-general, rob, rob.herring
  Cc: devicetree-discuss, Linux OMAP Mailing List,
	Linux Kernel Mailing List, Tony Lindgren, Felipe Balbi

On Wed, 12 Dec 2012 10:46:00 +0200, Felipe Balbi <balbi@ti.com> wrote:
> there are a few spi master drivers which make
> use of that flag but there is no way to pass it
> through devicetree.
> 
> This patch just creates a way to pass SPI_LOOP
> via devicetree.

I don't understand how this would be useful since loopback mode is
really just a test feature. Is there any reason to do loopback for
something other than test?

I think it would be better to add a sysfs or debugfs property to
manipulate the SPI_LOOP flag from userspace. What do you think?

g.

> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> ---
>  Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++
>  drivers/spi/spi.c                                 | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
> index 296015e..1949586 100644
> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt
> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
> @@ -55,6 +55,8 @@ contain the following properties.
>      		chip select active high
>  - spi-3wire       - (optional) Empty property indicating device requires
>      		    3-wire mode.
> +- spi-loopback    - (optional) Empty property indicating device requires
> +    		    loopback mode.
>  
>  If a gpio chipselect is used for the SPI slave the gpio number will be passed
>  via the cs_gpio
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 3f1b9ee..6bcdc03 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -868,6 +868,8 @@ static void of_register_spi_devices(struct spi_master *master)
>  			spi->mode |= SPI_CS_HIGH;
>  		if (of_find_property(nc, "spi-3wire", NULL))
>  			spi->mode |= SPI_3WIRE;
> +		if (of_find_property(nc, "spi-loopback", NULL))
> +			spi->mode |= SPI_LOOP;
>  
>  		/* Device speed */
>  		prop = of_get_property(nc, "spi-max-frequency", &len);
> -- 
> 1.8.1.rc1.5.g7e0651a
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] spi: omap2: disable DMA requests before complete()
  2012-12-12  8:45 [PATCH 1/2] spi: omap2: disable DMA requests before complete() Felipe Balbi
  2012-12-12  8:46 ` [PATCH 2/2] spi: devicetree: add support for loopback mode Felipe Balbi
@ 2012-12-15  0:35 ` Grant Likely
  1 sibling, 0 replies; 6+ messages in thread
From: Grant Likely @ 2012-12-15  0:35 UTC (permalink / raw)
  To: Felipe Balbi, spi-devel-general, rob, rob.herring
  Cc: devicetree-discuss, Linux OMAP Mailing List,
	Linux Kernel Mailing List, Tony Lindgren, Felipe Balbi

On Wed, 12 Dec 2012 10:45:59 +0200, Felipe Balbi <balbi@ti.com> wrote:
> No actual errors have been found for completing
> before disabling DMA request lines, but it just
> looks more semantically correct that on our DMA
> callback we quiesce the whole thing before stating
> transfer is finished.
> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>

Applied, thanks.

g.

> ---
>  drivers/spi/spi-omap2-mcspi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index b610f52..68446db 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -298,10 +298,10 @@ static void omap2_mcspi_rx_callback(void *data)
>  	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
>  	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
>  
> -	complete(&mcspi_dma->dma_rx_completion);
> -
>  	/* We must disable the DMA RX request */
>  	omap2_mcspi_set_dma_req(spi, 1, 0);
> +
> +	complete(&mcspi_dma->dma_rx_completion);
>  }
>  
>  static void omap2_mcspi_tx_callback(void *data)
> @@ -310,10 +310,10 @@ static void omap2_mcspi_tx_callback(void *data)
>  	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
>  	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
>  
> -	complete(&mcspi_dma->dma_tx_completion);
> -
>  	/* We must disable the DMA TX request */
>  	omap2_mcspi_set_dma_req(spi, 0, 0);
> +
> +	complete(&mcspi_dma->dma_tx_completion);
>  }
>  
>  static void omap2_mcspi_tx_dma(struct spi_device *spi,
> -- 
> 1.8.1.rc1.5.g7e0651a
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] spi: devicetree: add support for loopback mode
  2012-12-15  0:32   ` Grant Likely
@ 2012-12-15 14:55     ` Felipe Balbi
  2012-12-16 21:14       ` Grant Likely
  0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2012-12-15 14:55 UTC (permalink / raw)
  To: Grant Likely
  Cc: Felipe Balbi, spi-devel-general, rob, rob.herring,
	devicetree-discuss, Linux OMAP Mailing List,
	Linux Kernel Mailing List, Tony Lindgren

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

On Sat, Dec 15, 2012 at 12:32:24AM +0000, Grant Likely wrote:
> On Wed, 12 Dec 2012 10:46:00 +0200, Felipe Balbi <balbi@ti.com> wrote:
> > there are a few spi master drivers which make
> > use of that flag but there is no way to pass it
> > through devicetree.
> > 
> > This patch just creates a way to pass SPI_LOOP
> > via devicetree.
> 
> I don't understand how this would be useful since loopback mode is
> really just a test feature. Is there any reason to do loopback for
> something other than test?
> 
> I think it would be better to add a sysfs or debugfs property to
> manipulate the SPI_LOOP flag from userspace. What do you think?

might be nicer in the long run, indeed. Want me to look into it, or do
you wanna do it yourself ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] spi: devicetree: add support for loopback mode
  2012-12-15 14:55     ` Felipe Balbi
@ 2012-12-16 21:14       ` Grant Likely
  0 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2012-12-16 21:14 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Felipe Balbi, spi-devel-general, rob, rob.herring,
	devicetree-discuss, Linux OMAP Mailing List,
	Linux Kernel Mailing List, Tony Lindgren

On Sat, 15 Dec 2012 16:55:46 +0200, Felipe Balbi <balbi@ti.com> wrote:
> On Sat, Dec 15, 2012 at 12:32:24AM +0000, Grant Likely wrote:
> > On Wed, 12 Dec 2012 10:46:00 +0200, Felipe Balbi <balbi@ti.com> wrote:
> > > there are a few spi master drivers which make
> > > use of that flag but there is no way to pass it
> > > through devicetree.
> > > 
> > > This patch just creates a way to pass SPI_LOOP
> > > via devicetree.
> > 
> > I don't understand how this would be useful since loopback mode is
> > really just a test feature. Is there any reason to do loopback for
> > something other than test?
> > 
> > I think it would be better to add a sysfs or debugfs property to
> > manipulate the SPI_LOOP flag from userspace. What do you think?
> 
> might be nicer in the long run, indeed. Want me to look into it, or do
> you wanna do it yourself ?

Yes, please look into it. After all, you're the one who needs the feature/  :-)

g.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-12-16 21:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-12  8:45 [PATCH 1/2] spi: omap2: disable DMA requests before complete() Felipe Balbi
2012-12-12  8:46 ` [PATCH 2/2] spi: devicetree: add support for loopback mode Felipe Balbi
2012-12-15  0:32   ` Grant Likely
2012-12-15 14:55     ` Felipe Balbi
2012-12-16 21:14       ` Grant Likely
2012-12-15  0:35 ` [PATCH 1/2] spi: omap2: disable DMA requests before complete() Grant Likely

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