[PATCH 5/7] i2c: i2c_gpio: add devicetree support
Sascha Hauer
s.hauer at pengutronix.de
Tue Jun 24 00:03:56 PDT 2014
On Tue, Jun 24, 2014 at 01:21:11AM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
> .../devicetree/bindings/gpio/gpio_i2c.txt | 32 +++++++++++++
> drivers/i2c/busses/i2c-gpio.c | 54 +++++++++++++++++++--
> include/of_gpio.h | 55 ++++++++++++++++++++++
> 3 files changed, 138 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/gpio/gpio_i2c.txt b/Documentation/devicetree/bindings/gpio/gpio_i2c.txt
> new file mode 100644
> index 0000000..4f8ec94
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio_i2c.txt
We already have this binding in dts/Bindings/i2c/i2c-gpio.txt, no need
to duplicate it here. Documentation/devicetree is only for barebox
specific bindings.
> @@ -0,0 +1,32 @@
> +Device-Tree bindings for i2c gpio driver
> +
> +Required properties:
> + - compatible = "i2c-gpio";
> + - gpios: sda and scl gpio
> +
> +
> +Optional properties:
> + - i2c-gpio,sda-open-drain: sda as open drain
> + - i2c-gpio,scl-open-drain: scl as open drain
> + - i2c-gpio,scl-output-only: scl as output only
> + - i2c-gpio,delay-us: delay between GPIO operations (may depend on each platform)
> + - i2c-gpio,timeout-ms: timeout to get data
> +
> +Example nodes:
> +
> +i2c at 0 {
> + compatible = "i2c-gpio";
> + gpios = <&pioA 23 0 /* sda */
> + &pioA 24 0 /* scl */
> + >;
> + i2c-gpio,sda-open-drain;
> + i2c-gpio,scl-open-drain;
> + i2c-gpio,delay-us = <2>; /* ~100 kHz */
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + rv3029c2 at 56 {
> + compatible = "rv3029c2";
> + reg = <0x56>;
> + };
> +};
> diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
> index 8b49c2c..29dc3d2 100644
> --- a/drivers/i2c/busses/i2c-gpio.c
> +++ b/drivers/i2c/busses/i2c-gpio.c
> @@ -15,6 +15,7 @@
> #include <i2c/i2c-gpio.h>
> #include <init.h>
> #include <gpio.h>
> +#include <of_gpio.h>
>
> struct i2c_gpio_private_data {
> struct i2c_adapter adap;
> @@ -83,6 +84,38 @@ static int i2c_gpio_getscl(void *data)
> return gpio_get_value(pdata->scl_pin);
> }
>
> +static int of_i2c_gpio_probe(struct device_node *np,
> + struct i2c_gpio_platform_data *pdata)
> +{
> + u32 reg;
> +
Consider adding a
is (!IS_ENABLED(CONFIG_OFDEVICE))
return -ENODEV;
to allow the compiler to throw away the rest of this function.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list