Re: [PATCH] i2c-designware: add OF binding support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 3, 2011 at 9:04 PM, Rob Herring <robherring2@xxxxxxxxx> wrote:
> From: Rob Herring <rob.herring@xxxxxxxxxxx>
>
> Add of_match_table and DT style i2c registration to designware i2c
> driver.
>
> Signed-off-by: Rob Herring <rob.herring@xxxxxxxxxxx>
> Cc: Grant Likely <grant.likely@xxxxxxxxxxxx>
> Cc: devicetree-discuss@xxxxxxxxxxxxxxxx
> Cc: Ben Dooks <ben-linux@xxxxxxxxx>
> Cc: linux-i2c@xxxxxxxxxxxxxxx
> ---
>  Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 ++++++++++++++++++++++
>  drivers/i2c/busses/i2c-designware.c              |   13 ++++++++++++
>  2 files changed, 36 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt
>
> diff --git a/Documentation/devicetree/bindings/i2c/dw-i2c.txt b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
> new file mode 100644
> index 0000000..cbcb404
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
> @@ -0,0 +1,23 @@
> +* Synopsys DesignWare I2C
> +
> +Required properties :
> +
> + - compatible : should be "snps,designware-i2c"
> + - reg : Offset and length of the register set for the device
> + - interrupts : <IRQ> where IRQ is the interrupt number.
> +
> +Recommended properties :
> +
> + - clock-frequency : desired I2C bus clock frequency in Hz.
> +
> +Example :
> +
> +       i2c@f0000 {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +               compatible = "snps,designware-i2c";
> +               reg = <0xf0000 0x1000>;
> +               interrupts = <11>;
> +               clock-frequency = <400000>;
> +       };
> +
> diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
> index b7a51c4..2911a49 100644
> --- a/drivers/i2c/busses/i2c-designware.c
> +++ b/drivers/i2c/busses/i2c-designware.c
> @@ -37,6 +37,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> +#include <linux/of_i2c.h>
>
>  /*
>  * Registers offset
> @@ -770,12 +771,17 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
>        adap->algo = &i2c_dw_algo;
>        adap->dev.parent = &pdev->dev;
>
> +#ifdef CONFIG_OF
> +       r = i2c_add_adapter(adap);
> +#else
>        adap->nr = pdev->id;
>        r = i2c_add_numbered_adapter(adap);
> +#endif

Unnecessary.  i2c_add_numbered_adapter will dynamically assign a bus
number now if nr is -1.

Otherwise, the patch looks good.  You can add the following after
removing the above hunk.  Besides, the way this is changed with an
#ifdef will break non-dt users in the same kernel.  You know better
than to do that!  :-)

Acked-by: Grant Likely <grant.likely@xxxxxxxxxxxx> (after fixing above problem)

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


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux