diff mbox

[v4,2/5] dt-bindings: gpio: add raspberry pi GPIO expander binding

Message ID 214ff3856c430b8045b63b25d83733b77054dfab.1517923836.git.baruch@tkos.co.il (mailing list archive)
State New, archived
Headers show

Commit Message

Baruch Siach Feb. 7, 2018, 6:35 p.m. UTC
The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware over
I2C. The firmware mailbox interface allows the ARM core to control the
GPIO lines.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
v4:
  * Move the example gpio node under the firmware node
  * Rename gpio node name to plain 'gpio'

v3:
  * Rename node name.

v2:
  * Rename compatible string to raspberrypi,firmware-gpio
---
 .../bindings/gpio/raspberrypi,firmware-gpio.txt    | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt

Comments

Rob Herring (Arm) Feb. 13, 2018, 11:20 p.m. UTC | #1
On Wed, Feb 07, 2018 at 08:35:23PM +0200, Baruch Siach wrote:
> The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware over
> I2C. The firmware mailbox interface allows the ARM core to control the
> GPIO lines.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> v4:
>   * Move the example gpio node under the firmware node
>   * Rename gpio node name to plain 'gpio'
> 
> v3:
>   * Rename node name.
> 
> v2:
>   * Rename compatible string to raspberrypi,firmware-gpio
> ---
>  .../bindings/gpio/raspberrypi,firmware-gpio.txt    | 29 ++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
> 
> diff --git a/Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt b/Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
> new file mode 100644
> index 000000000000..30326528faa9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
> @@ -0,0 +1,29 @@
> +Raspberry Pi GPIO expander
> +
> +The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
> +firmware exposes a mailbox interface that allows the ARM core to control the
> +GPIO lines on the expander.
> +
> +Required properties:
> +
> +- compatible : Should be "raspberrypi,firmware-gpio"
> +- gpio-controller : Marks the device node as a gpio controller
> +- #gpio-cells : Should be two.  The first cell is the pin number, and
> +  the second cell is used to specify the gpio polarity:
> +  0 = active high
> +  1 = active low
> +- firmware : Reference to the RPi firmware device node

This is the parent node. You don't need it.

> +
> +Example:
> +
> +firmware: firmware {
> +	compatible = "raspberrypi,bcm2835-firmware";
> +	mboxes = <&mailbox>;

No, sorry. /firmware is the container of firmware nodes. So 
something like this:

firmware {
	rpi-firmware {
		compatible = "raspberrypi,bcm2835-firmware";
		mboxes = <&mailbox>;
		gpio {
		 compatible = "raspberrypi,firmware-gpio";

		};
	};
};

> +
> +	expgpio: gpio {
> +		 compatible = "raspberrypi,firmware-gpio";
> +		 gpio-controller;
> +		 #gpio-cells = <2>;
> +		 firmware = <&firmware>;
> +	 };
> +};
> -- 
> 2.15.1
>
Baruch Siach Feb. 20, 2018, 7:34 a.m. UTC | #2
Hi Rob,

Thanks again for reviewing.

On Tue, Feb 13, 2018 at 05:20:07PM -0600, Rob Herring wrote:
> On Wed, Feb 07, 2018 at 08:35:23PM +0200, Baruch Siach wrote:
> > +Raspberry Pi GPIO expander
> > +
> > +The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
> > +firmware exposes a mailbox interface that allows the ARM core to control the
> > +GPIO lines on the expander.
> > +
> > +Required properties:
> > +
> > +- compatible : Should be "raspberrypi,firmware-gpio"
> > +- gpio-controller : Marks the device node as a gpio controller
> > +- #gpio-cells : Should be two.  The first cell is the pin number, and
> > +  the second cell is used to specify the gpio polarity:
> > +  0 = active high
> > +  1 = active low
> > +- firmware : Reference to the RPi firmware device node
> 
> This is the parent node. You don't need it.

OK. I guess of_get_parent() will do the trick.

> > +Example:
> > +
> > +firmware: firmware {
> > +	compatible = "raspberrypi,bcm2835-firmware";
> > +	mboxes = <&mailbox>;
> 
> No, sorry. /firmware is the container of firmware nodes. So 
> something like this:
> 
> firmware {
> 	rpi-firmware {
> 		compatible = "raspberrypi,bcm2835-firmware";
> 		mboxes = <&mailbox>;
> 		gpio {
> 		 compatible = "raspberrypi,firmware-gpio";
> 
> 		};
> 	};
> };

This is the hierarchy we currently have at arch/arm/boot/dts/bcm2835-rpi.dtsi:

/ {
        soc {
                firmware: firmware {
                        compatible = "raspberrypi,bcm2835-firmware";
                        mboxes = <&mailbox>;
                };
        };
};


Are you suggesting to add another container between 'soc' and 'firmware'? Or 
is it the 'firmware' node name that we need to change to 'rpi-firmware'?

> > +
> > +	expgpio: gpio {
> > +		 compatible = "raspberrypi,firmware-gpio";
> > +		 gpio-controller;
> > +		 #gpio-cells = <2>;
> > +		 firmware = <&firmware>;
> > +	 };
> > +};

baruch
Rob Herring (Arm) Feb. 20, 2018, 1:39 p.m. UTC | #3
On Tue, Feb 20, 2018 at 1:34 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> Hi Rob,
>
> Thanks again for reviewing.
>
> On Tue, Feb 13, 2018 at 05:20:07PM -0600, Rob Herring wrote:
>> On Wed, Feb 07, 2018 at 08:35:23PM +0200, Baruch Siach wrote:
>> > +Raspberry Pi GPIO expander
>> > +
>> > +The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
>> > +firmware exposes a mailbox interface that allows the ARM core to control the
>> > +GPIO lines on the expander.
>> > +
>> > +Required properties:
>> > +
>> > +- compatible : Should be "raspberrypi,firmware-gpio"
>> > +- gpio-controller : Marks the device node as a gpio controller
>> > +- #gpio-cells : Should be two.  The first cell is the pin number, and
>> > +  the second cell is used to specify the gpio polarity:
>> > +  0 = active high
>> > +  1 = active low
>> > +- firmware : Reference to the RPi firmware device node
>>
>> This is the parent node. You don't need it.
>
> OK. I guess of_get_parent() will do the trick.
>
>> > +Example:
>> > +
>> > +firmware: firmware {
>> > +   compatible = "raspberrypi,bcm2835-firmware";
>> > +   mboxes = <&mailbox>;
>>
>> No, sorry. /firmware is the container of firmware nodes. So
>> something like this:
>>
>> firmware {
>>       rpi-firmware {
>>               compatible = "raspberrypi,bcm2835-firmware";
>>               mboxes = <&mailbox>;
>>               gpio {
>>                compatible = "raspberrypi,firmware-gpio";
>>
>>               };
>>       };
>> };
>
> This is the hierarchy we currently have at arch/arm/boot/dts/bcm2835-rpi.dtsi:
>
> / {
>         soc {
>                 firmware: firmware {
>                         compatible = "raspberrypi,bcm2835-firmware";
>                         mboxes = <&mailbox>;
>                 };
>         };
> };
>
> Are you suggesting to add another container between 'soc' and 'firmware'? Or
> is it the 'firmware' node name that we need to change to 'rpi-firmware'?

Ah, I guess RPi missed following putting its firmware node under a
/firmware node rather than under /soc. We try to put all firmware
interfaces (you can have more than one) under /firmware. So just as I
wrote out. But you don't need to change that for this.

Just noting this is a child of "raspberrypi,bcm2835-firmware" is enough.

Rob
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt b/Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
new file mode 100644
index 000000000000..30326528faa9
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
@@ -0,0 +1,29 @@ 
+Raspberry Pi GPIO expander
+
+The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
+firmware exposes a mailbox interface that allows the ARM core to control the
+GPIO lines on the expander.
+
+Required properties:
+
+- compatible : Should be "raspberrypi,firmware-gpio"
+- gpio-controller : Marks the device node as a gpio controller
+- #gpio-cells : Should be two.  The first cell is the pin number, and
+  the second cell is used to specify the gpio polarity:
+  0 = active high
+  1 = active low
+- firmware : Reference to the RPi firmware device node
+
+Example:
+
+firmware: firmware {
+	compatible = "raspberrypi,bcm2835-firmware";
+	mboxes = <&mailbox>;
+
+	expgpio: gpio {
+		 compatible = "raspberrypi,firmware-gpio";
+		 gpio-controller;
+		 #gpio-cells = <2>;
+		 firmware = <&firmware>;
+	 };
+};