diff mbox

[2/2] spi: devicetree: add support for loopback mode

Message ID 1355301960-21523-2-git-send-email-balbi@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi Dec. 12, 2012, 8:46 a.m. UTC
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(+)

Comments

Grant Likely Dec. 15, 2012, 12:32 a.m. UTC | #1
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
>
Felipe Balbi Dec. 15, 2012, 2:55 p.m. UTC | #2
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 ?
Grant Likely Dec. 16, 2012, 9:14 p.m. UTC | #3
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.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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