diff options
author | loos <loos@FreeBSD.org> | 2014-02-13 17:58:52 +0000 |
---|---|---|
committer | loos <loos@FreeBSD.org> | 2014-02-13 17:58:52 +0000 |
commit | 4969f2c1cac596d80cba8e9f98f3be2f87a8c639 (patch) | |
tree | fbcaee70b7518ece1d94e6c256911369f0bcbcbd /share | |
parent | 03c3f2092682aca3cb1c101cb3ee84621f5447f0 (diff) | |
download | FreeBSD-src-4969f2c1cac596d80cba8e9f98f3be2f87a8c639.zip FreeBSD-src-4969f2c1cac596d80cba8e9f98f3be2f87a8c639.tar.gz |
Add OFW support to the in tree gpio compatible devices: gpioiic(4) and
gpioled(4).
Tested on RPi and BBB (using the hardware I2C controller and gpioiic(4) for
the I2C tests). It was also verified for regressions on RSPRO (MIPS/ar71xx)
used as reference for a non OFW-based system.
Update the gpioled(4) and gpioiic(4) man pages with some details and
examples about the FDT/OFW support.
Some compatibility details pointed out by imp@ will follow in subsequent
commits.
Approved by: adrian (mentor, implicit)
Diffstat (limited to 'share')
-rw-r--r-- | share/man/man4/gpioiic.4 | 68 | ||||
-rw-r--r-- | share/man/man4/gpioled.4 | 70 |
2 files changed, 135 insertions, 3 deletions
diff --git a/share/man/man4/gpioiic.4 b/share/man/man4/gpioiic.4 index cbcaec9..e3f9814 100644 --- a/share/man/man4/gpioiic.4 +++ b/share/man/man4/gpioiic.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 5, 2013 +.Dd February 13, 2014 .Dt GPIOIIC 4 .Os .Sh NAME @@ -65,7 +65,7 @@ This is a bitmask of the pins on the that are to be used for SCLOCK and SDATA from the GPIO IIC bit-banging bus. To configure pin 0 and 7, use the bitmask of -10000001 and convert it to a hexadecimal value of 0x0081. +0b10000001 and convert it to a hexadecimal value of 0x0081. Please note that this mask should only ever have two bits set (any others bits - i.e., pins - will be ignored). .It Va hint.gpioiic.%d.scl @@ -73,13 +73,77 @@ Indicates which bit in the .Va hint.gpioiic.%d.pins should be used as the SCLOCK source. +Optional, defaults to 0. .It Va hint.gpioiic.%d.sda Indicates which bit in the .Va hint.gpioiic.%d.pins should be used as the SDATA source. +Optional, defaults to 1. +.El +.Pp +On a +.Xr FDT 4 +based system, like +.Li ARM , the dts part for a +.Nm gpioiic +device usually looks like: +.Bd -literal +gpio: gpio { + + gpio-controller; + ... + + gpioiic0 { + compatible = "gpioiic"; + /* + * Attach to GPIO pins 21 and 22. Set them + * initially as inputs. + */ + gpios = <&gpio 21 1 0 + &gpio 22 1 0>; + scl = <0>; /* GPIO pin 21 - optional */ + sda = <1>; /* GPIO pin 22 - optional */ + + /* This is an example of a gpioiic child. */ + gpioiic-child0 { + compatible = "lm75"; + i2c-address = <0x4f>; + }; + }; +}; +.Ed +.Pp +Where: +.Bl -tag -width ".Va compatible" +.It Va compatible +Should always be set to "gpioiic". +.It Va gpios +The +.Va gpios +property indicates which GPIO pins should be used for SCLOCK and SDATA +on the GPIO IIC bit-banging bus. +For more details about the +.Va gpios +property, please consult +.Pa /usr/src/sys/boot/fdt/dts/bindings-gpio.txt . +.It Va scl +The +.Va scl +option indicates which bit in the +.Va gpios +should be used as the SCLOCK source. +Optional, defaults to 0. +.It Va sda +The +.Va sda +option indicates which bit in the +.Va gpios +should be used as the SDATA source. +Optional, defaults to 1. .El .Sh SEE ALSO +.Xr fdt 4 , .Xr gpio 4 , .Xr gpioled 4 , .Xr iic 4 , diff --git a/share/man/man4/gpioled.4 b/share/man/man4/gpioled.4 index 76f59fa..74c28e6 100644 --- a/share/man/man4/gpioled.4 +++ b/share/man/man4/gpioled.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 5, 2013 +.Dd February 13, 2014 .Dt GPIOLED 4 .Os .Sh NAME @@ -68,7 +68,75 @@ Which pin on the GPIO interface to map to this instance. Please note that this mask should only ever have one bit set (any others bits - i.e., pins - will be ignored). .El +.Pp +On a +.Xr FDT 4 +based system, like +.Li ARM , the dts part for a +.Nm gpioled +device usually looks like: +.Bd -literal +gpio: gpio { + + gpio-controller; + ... + + led0 { + compatible = "gpioled"; + gpios = <&gpio 16 2 0>; /* GPIO pin 16. */ + name = "ok"; + }; + + led1 { + compatible = "gpioled"; + gpios = <&gpio 17 2 0>; /* GPIO pin 17. */ + name = "user-led1"; + }; +}; +.Ed +.Pp +And optionally, you can choose combine all the leds under a single +.Dq gpio-leds +compatible node: +.Bd -literal +simplebus0 { + + ... + + leds { + compatible = "gpio-leds"; + + led0 { + gpios = <&gpio 16 2 0>; + name = "ok" + }; + + led1 { + gpios = <&gpio 17 2 0>; + name = "user-led1" + }; + }; +}; +.Ed +.Pp +Both methods are equally supported and it is possible to have the leds +defined with any sort of mix between the methods. +The only restriction is that a GPIO pin cannot be mapped by two different +(gpio)leds. +.Pp +For more details about the +.Va gpios +property, please consult +.Pa /usr/src/sys/boot/fdt/dts/bindings-gpio.txt . +.Pp +The property +.Va name +is the arbitrary name of device in +.Pa /dev/led/ +to create for +.Xr led 4 . .Sh SEE ALSO +.Xr fdt 4 , .Xr gpio 4 , .Xr led 4 , .Xr gpioiic 4 |