diff mbox series

[1/3] dt-bindings: spi: Add spi-mux-gpio

Message ID 20190412050213.17698-2-chris.packham@alliedtelesis.co.nz
State New, archived
Headers show
Series spi: SPI bus multiplexer | expand

Commit Message

Chris Packham April 12, 2019, 5:02 a.m. UTC
Add binding documentation for spi-mux-gpio which is a slightly more
complicated hardware implementation of using gpios to steer SPI chip
selects.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 .../devicetree/bindings/spi/spi-mux-gpio.txt  | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-mux-gpio.txt

Comments

Rob Herring April 29, 2019, 9:37 p.m. UTC | #1
On Fri, Apr 12, 2019 at 05:02:11PM +1200, Chris Packham wrote:
> Add binding documentation for spi-mux-gpio which is a slightly more
> complicated hardware implementation of using gpios to steer SPI chip
> selects.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>  .../devicetree/bindings/spi/spi-mux-gpio.txt  | 45 +++++++++++++++++++
>  1 file changed, 45 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
> 
> diff --git a/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt b/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
> new file mode 100644
> index 000000000000..a32f25321d37
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
> @@ -0,0 +1,45 @@
> +SPI bus gpio multiplexer
> +
> +The SPI bus gpio multiplexer can be used to implement more complicated access
> +logic than can be supported with the cs-gpios property of a SPI bus.
> +
> +In the example below we have a SoC with a single SPI CS that is gated by the
> +state of a gpio to select the desired SPI device.
> +
> +     +----------+  CS    +-----+ CS0  +----+
> +     |          |--------|     |------|    |
> +     |          |        | \ / |      +----+
> +     |   SoC    |        |  +  |
> +     |          |  GPIO  | / \ | CS1  +----+
> +     |          |--------|     |------|    |
> +     +----------+        +-----+      +----+
> +
> +Required properties:
> +- compatible	- must be "spi-mux-gpio"
> +- gpios		- gpios used to implement the multiplexing logic
> +- spi-parent-bus - parent spi bus to use
> +
> +Optional properties:
> +- spi-parent-cs - chip select on parent bus to use. Defaults to 0 if not
> +                  specified.
> +
> +Example for a multiplexer with a single gpio:
> +
> +	spi-mux {
> +		compatible = "spi-mux-gpio";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		gpios = <&gpio0 1 0>;
> +		spi-parent-bus = <&spi0>;
> +		spi-parent-cs = <0>;

Why is this out of band? We can do something similar to I2C and use the 
mux-control binding:

spi {
	mux@0 {
		compatible = "spi-mux";
		reg "0"; 
		mux-controls = ...;

		spi-dev@0 {};
		spi-dev@1 {};
	};

	spi-dev@1 {};

};

Rob
Chris Packham Jan. 13, 2020, 3:43 a.m. UTC | #2
Hi Rob,

On Mon, 2019-04-29 at 16:37 -0500, Rob Herring wrote:
> On Fri, Apr 12, 2019 at 05:02:11PM +1200, Chris Packham wrote:
> > Add binding documentation for spi-mux-gpio which is a slightly more
> > complicated hardware implementation of using gpios to steer SPI chip
> > selects.
> > 
> > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > ---
> >  .../devicetree/bindings/spi/spi-mux-gpio.txt  | 45 +++++++++++++++++++
> >  1 file changed, 45 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt b/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
> > new file mode 100644
> > index 000000000000..a32f25321d37
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
> > @@ -0,0 +1,45 @@
> > +SPI bus gpio multiplexer
> > +
> > +The SPI bus gpio multiplexer can be used to implement more complicated access
> > +logic than can be supported with the cs-gpios property of a SPI bus.
> > +
> > +In the example below we have a SoC with a single SPI CS that is gated by the
> > +state of a gpio to select the desired SPI device.
> > +
> > +     +----------+  CS    +-----+ CS0  +----+
> > +     |          |--------|     |------|    |
> > +     |          |        | \ / |      +----+
> > +     |   SoC    |        |  +  |
> > +     |          |  GPIO  | / \ | CS1  +----+
> > +     |          |--------|     |------|    |
> > +     +----------+        +-----+      +----+
> > +
> > +Required properties:
> > +- compatible	- must be "spi-mux-gpio"
> > +- gpios		- gpios used to implement the multiplexing logic
> > +- spi-parent-bus - parent spi bus to use
> > +
> > +Optional properties:
> > +- spi-parent-cs - chip select on parent bus to use. Defaults to 0 if not
> > +                  specified.
> > +
> > +Example for a multiplexer with a single gpio:
> > +
> > +	spi-mux {
> > +		compatible = "spi-mux-gpio";
> > +		#address-cells = <1>;
> > +		#size-cells = <0>;
> > +		gpios = <&gpio0 1 0>;
> > +		spi-parent-bus = <&spi0>;
> > +		spi-parent-cs = <0>;
> 
> Why is this out of band? We can do something similar to I2C and use the 
> mux-control binding:
> 
> spi {
> 	mux@0 {
> 		compatible = "spi-mux";
> 		reg "0"; 
> 		mux-controls = ...;
> 
> 		spi-dev@0 {};
> 		spi-dev@1 {};
> 	};
> 
> 	spi-dev@1 {};
> 
> };

I've been re-visiting this thread and an older one[1] with an eye on
implementing a solution with mux-controls.

One thing I'm confused about is your comment that the mux should be in-
band like i2c. Looking at the one user of i2c-mux (at91-natte.dtsi) it
also appears out of band and determine the parent bus with a i2c-parent 
property (similar to how I did it in my original submission). I also
can't see how the mux would work in-band since it lacks the correct
#address-cells etc for a spi device.

I'm wondering if I've missed something obvious.

--
[1] - https://patchwork.kernel.org/patch/2706151/
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt b/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
new file mode 100644
index 000000000000..a32f25321d37
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
@@ -0,0 +1,45 @@ 
+SPI bus gpio multiplexer
+
+The SPI bus gpio multiplexer can be used to implement more complicated access
+logic than can be supported with the cs-gpios property of a SPI bus.
+
+In the example below we have a SoC with a single SPI CS that is gated by the
+state of a gpio to select the desired SPI device.
+
+     +----------+  CS    +-----+ CS0  +----+
+     |          |--------|     |------|    |
+     |          |        | \ / |      +----+
+     |   SoC    |        |  +  |
+     |          |  GPIO  | / \ | CS1  +----+
+     |          |--------|     |------|    |
+     +----------+        +-----+      +----+
+
+Required properties:
+- compatible	- must be "spi-mux-gpio"
+- gpios		- gpios used to implement the multiplexing logic
+- spi-parent-bus - parent spi bus to use
+
+Optional properties:
+- spi-parent-cs - chip select on parent bus to use. Defaults to 0 if not
+                  specified.
+
+Example for a multiplexer with a single gpio:
+
+	spi-mux {
+		compatible = "spi-mux-gpio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gpios = <&gpio0 1 0>;
+		spi-parent-bus = <&spi0>;
+		spi-parent-cs = <0>;
+
+		spi-dev@0 {
+			compatible = "...";
+			reg = <0>;
+		}
+
+		spi-dev@1 {
+			compatible = "...";
+			reg = <1>;
+		}
+	};