diff mbox

[2/2] arm: dt: Add device tree support for i2c instance 1 on exynos4 dt machine

Message ID 1310950241-13602-3-git-send-email-thomas.abraham@linaro.org
State New
Headers show

Commit Message

thomas.abraham@linaro.org July 18, 2011, 12:50 a.m. UTC
Add device node for i2c instance 1 and list all its connected slave
devices.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
 arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
 arch/arm/mach-exynos4/Kconfig           |    1 +
 arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
 3 files changed, 28 insertions(+), 1 deletions(-)

Comments

Grant Likely July 18, 2011, 4:30 a.m. UTC | #1
On Mon, Jul 18, 2011 at 06:20:41AM +0530, Thomas Abraham wrote:
> Add device node for i2c instance 1 and list all its connected slave
> devices.
> 
> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
> ---
>  arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
>  arch/arm/mach-exynos4/Kconfig           |    1 +
>  arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
>  3 files changed, 28 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
> index d65c18c..29c40ed 100644
> --- a/arch/arm/boot/dts/exynos4-smdkv310.dts
> +++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
> @@ -23,7 +23,7 @@
>  	};
>  
>  	chosen {
> -		bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
> +		bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
>  	};
>  
>  	soc {
> @@ -64,5 +64,22 @@
>  			samsung,sdhci-cd-type = <0>;
>  			samsung,sdhci-clkdiv-external;
>  		};
> +
> +		i2c@13870000 {
> +			compatible = "samsung,s3c2440-i2c";
> +			reg = <0x13870000 0x100>;
> +			interrupts = <345>;
> +			samsung,i2c-bus-number = <1>;
> +			samsung,i2c-slave-addr = <16>;
> +			samsung,i2c-sda-delay = <100>;
> +			samsung,i2c-max-bus-freq = <100000>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +
> +			wm8994@1a {
> +				compatible = "wlf,wm8994";
> +				reg = <0x1a>;
> +			};
> +		};
>  	};
>  };
> diff --git a/arch/arm/mach-exynos4/Kconfig b/arch/arm/mach-exynos4/Kconfig
> index bb97b7e..c7fce3e 100644
> --- a/arch/arm/mach-exynos4/Kconfig
> +++ b/arch/arm/mach-exynos4/Kconfig
> @@ -193,6 +193,7 @@ config MACH_EXYNOS4_DT
>  	select S3C_DEV_HSMMC
>  	select S3C_DEV_HSMMC2
>  	select EXYNOS4_SETUP_SDHCI
> +	select EXYNOS4_SETUP_I2C1
>  	help
>  	  Machine support for Samsung Exynos4 machine with device tree enabled.
>  
> diff --git a/arch/arm/mach-exynos4/mach-exynos4-dt.c b/arch/arm/mach-exynos4/mach-exynos4-dt.c
> index 120665a..ef6b4cb 100644
> --- a/arch/arm/mach-exynos4/mach-exynos4-dt.c
> +++ b/arch/arm/mach-exynos4/mach-exynos4-dt.c
> @@ -23,7 +23,10 @@
>  #include <plat/regs-serial.h>
>  #include <plat/exynos4.h>
>  #include <plat/cpu.h>
> +#include <plat/devs.h>
>  #include <plat/sdhci.h>
> +#include <plat/iic.h>
> +#include <plat/iic-core.h>
>  
>  #include <mach/map.h>
>  
> @@ -62,6 +65,10 @@ static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
>  	},
>  };
>  
> +static struct s3c2410_platform_i2c exynos4_dt_i2c_data1 __initdata = {
> +	.cfg_gpio	= s3c_i2c1_cfg_gpio,
> +};
> +
>  /*
>   * The following lookup table is used to override device names when devices
>   * are registered from device tree. Optionally, the platform data can also
> @@ -75,6 +82,8 @@ static const struct of_dev_auxdata exynos4_auxdata_lookup[] __initconst = {
>  				"s3c-sdhci.2", &s3c_hsmmc2_def_platdata),
>  	OF_DEV_AUXDATA("samsung,s3c6410-sdhci", EXYNOS4_PA_HSMMC(0),
>  				"s3c-sdhci.0", &s3c_hsmmc0_def_platdata),
> +	OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS4_PA_IIC(1),
> +				"s3c2440-i2c.1", &exynos4_dt_i2c_data1),

Should not need the platform_data here.  Add DT support to the GPIO
driver and decode the data from there (which should be easy).

g.
Ben Dooks July 18, 2011, 9:45 a.m. UTC | #2
On Sun, Jul 17, 2011 at 10:30:59PM -0600, Grant Likely wrote:
> On Mon, Jul 18, 2011 at 06:20:41AM +0530, Thomas Abraham wrote:
> > Add device node for i2c instance 1 and list all its connected slave
> > devices.
> > 
> > Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
> > ---
> >  arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
> >  arch/arm/mach-exynos4/Kconfig           |    1 +
> >  arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
> >  3 files changed, 28 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
> > index d65c18c..29c40ed 100644
> > --- a/arch/arm/boot/dts/exynos4-smdkv310.dts
> > +++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
> > @@ -23,7 +23,7 @@
> >  	};
> >  
> >  	chosen {
> > -		bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
> > +		bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
> >  	};
> >  
> >  	soc {
> > @@ -64,5 +64,22 @@
> >  			samsung,sdhci-cd-type = <0>;
> >  			samsung,sdhci-clkdiv-external;
> >  		};
> > +
> > +		i2c@13870000 {
> > +			compatible = "samsung,s3c2440-i2c";
> > +			reg = <0x13870000 0x100>;
> > +			interrupts = <345>;
> > +			samsung,i2c-bus-number = <1>;
> > +			samsung,i2c-slave-addr = <16>;
> > +			samsung,i2c-sda-delay = <100>;
> > +			samsung,i2c-max-bus-freq = <100000>;
> > +			#address-cells = <1>;
> > +			#size-cells = <0>;
> > +
> > +			wm8994@1a {
> > +				compatible = "wlf,wm8994";
> > +				reg = <0x1a>;
> > +			};
> > +		};
> >  	};
> >  };
> > diff --git a/arch/arm/mach-exynos4/Kconfig b/arch/arm/mach-exynos4/Kconfig
> > index bb97b7e..c7fce3e 100644
> > --- a/arch/arm/mach-exynos4/Kconfig
> > +++ b/arch/arm/mach-exynos4/Kconfig
> > @@ -193,6 +193,7 @@ config MACH_EXYNOS4_DT
> >  	select S3C_DEV_HSMMC
> >  	select S3C_DEV_HSMMC2
> >  	select EXYNOS4_SETUP_SDHCI
> > +	select EXYNOS4_SETUP_I2C1
> >  	help
> >  	  Machine support for Samsung Exynos4 machine with device tree enabled.
> >  
> > diff --git a/arch/arm/mach-exynos4/mach-exynos4-dt.c b/arch/arm/mach-exynos4/mach-exynos4-dt.c
> > index 120665a..ef6b4cb 100644
> > --- a/arch/arm/mach-exynos4/mach-exynos4-dt.c
> > +++ b/arch/arm/mach-exynos4/mach-exynos4-dt.c
> > @@ -23,7 +23,10 @@
> >  #include <plat/regs-serial.h>
> >  #include <plat/exynos4.h>
> >  #include <plat/cpu.h>
> > +#include <plat/devs.h>
> >  #include <plat/sdhci.h>
> > +#include <plat/iic.h>
> > +#include <plat/iic-core.h>
> >  
> >  #include <mach/map.h>
> >  
> > @@ -62,6 +65,10 @@ static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
> >  	},
> >  };
> >  
> > +static struct s3c2410_platform_i2c exynos4_dt_i2c_data1 __initdata = {
> > +	.cfg_gpio	= s3c_i2c1_cfg_gpio,
> > +};
> > +
> >  /*
> >   * The following lookup table is used to override device names when devices
> >   * are registered from device tree. Optionally, the platform data can also
> > @@ -75,6 +82,8 @@ static const struct of_dev_auxdata exynos4_auxdata_lookup[] __initconst = {
> >  				"s3c-sdhci.2", &s3c_hsmmc2_def_platdata),
> >  	OF_DEV_AUXDATA("samsung,s3c6410-sdhci", EXYNOS4_PA_HSMMC(0),
> >  				"s3c-sdhci.0", &s3c_hsmmc0_def_platdata),
> > +	OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS4_PA_IIC(1),
> > +				"s3c2440-i2c.1", &exynos4_dt_i2c_data1),
> 
> Should not need the platform_data here.  Add DT support to the GPIO
> driver and decode the data from there (which should be easy).

Hmm, do we have any sane way of passing which configuration settings
should be applied to the gpio pins (given that there can be up to 13
non-IO settings for some of these pins).

Also, since this data is really part of the SoC, I don't really want
to see n different .dts files hanging around with the same information
in it.

Maybe it is time for a standardised callback to allow devices to connect
themselves to the pins they need, and have dt capability of over-riding
the information if it needs it.
G, Manjunath Kondaiah July 18, 2011, 11:53 a.m. UTC | #3
Abraham,
Few comments on i2c child devices handling:

On 18 July 2011 06:20, Thomas Abraham <thomas.abraham@linaro.org> wrote:
> Add device node for i2c instance 1 and list all its connected slave
> devices.
>
> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
> ---
>  arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
>  arch/arm/mach-exynos4/Kconfig           |    1 +
>  arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
>  3 files changed, 28 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
> index d65c18c..29c40ed 100644
> --- a/arch/arm/boot/dts/exynos4-smdkv310.dts
> +++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
> @@ -23,7 +23,7 @@
>        };
>
>        chosen {
> -               bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
> +               bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
>        };
>
>        soc {
> @@ -64,5 +64,22 @@
>                        samsung,sdhci-cd-type = <0>;
>                        samsung,sdhci-clkdiv-external;
>                };
> +
> +               i2c@13870000 {
> +                       compatible = "samsung,s3c2440-i2c";
> +                       reg = <0x13870000 0x100>;
> +                       interrupts = <345>;
> +                       samsung,i2c-bus-number = <1>;
> +                       samsung,i2c-slave-addr = <16>;
> +                       samsung,i2c-sda-delay = <100>;
> +                       samsung,i2c-max-bus-freq = <100000>;
> +                       #address-cells = <1>;
> +                       #size-cells = <0>;
> +
> +                       wm8994@1a {
> +                               compatible = "wlf,wm8994";
> +                               reg = <0x1a>;
> +                       };

The i2c child devices are board specific.
For ex: few boards such as smdkxxx based on exynos4 has wm8994 with
i2c1 controller
where as other boards based on exynos4 does not have any i2c1 devices.
Hence these child entries should go to board specific .dts file right?
There should be soc specific .dts file and board specific dts file
should include soc dts file.

-M
Grant Likely July 18, 2011, 8:28 p.m. UTC | #4
On Mon, Jul 18, 2011 at 3:45 AM, Ben Dooks <ben-i2c@fluff.org> wrote:
> On Sun, Jul 17, 2011 at 10:30:59PM -0600, Grant Likely wrote:
>> On Mon, Jul 18, 2011 at 06:20:41AM +0530, Thomas Abraham wrote:
>> > Add device node for i2c instance 1 and list all its connected slave
>> > devices.
>> >
>> > Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
>> > ---
>> >  arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
>> >  arch/arm/mach-exynos4/Kconfig           |    1 +
>> >  arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
>> >  3 files changed, 28 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
>> > index d65c18c..29c40ed 100644
>> > --- a/arch/arm/boot/dts/exynos4-smdkv310.dts
>> > +++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
>> > @@ -23,7 +23,7 @@
>> >     };
>> >
>> >     chosen {
>> > -           bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
>> > +           bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
>> >     };
>> >
>> >     soc {
>> > @@ -64,5 +64,22 @@
>> >                     samsung,sdhci-cd-type = <0>;
>> >                     samsung,sdhci-clkdiv-external;
>> >             };
>> > +
>> > +           i2c@13870000 {
>> > +                   compatible = "samsung,s3c2440-i2c";
>> > +                   reg = <0x13870000 0x100>;
>> > +                   interrupts = <345>;
>> > +                   samsung,i2c-bus-number = <1>;
>> > +                   samsung,i2c-slave-addr = <16>;
>> > +                   samsung,i2c-sda-delay = <100>;
>> > +                   samsung,i2c-max-bus-freq = <100000>;
>> > +                   #address-cells = <1>;
>> > +                   #size-cells = <0>;
>> > +
>> > +                   wm8994@1a {
>> > +                           compatible = "wlf,wm8994";
>> > +                           reg = <0x1a>;
>> > +                   };
>> > +           };
>> >     };
>> >  };
>> > diff --git a/arch/arm/mach-exynos4/Kconfig b/arch/arm/mach-exynos4/Kconfig
>> > index bb97b7e..c7fce3e 100644
>> > --- a/arch/arm/mach-exynos4/Kconfig
>> > +++ b/arch/arm/mach-exynos4/Kconfig
>> > @@ -193,6 +193,7 @@ config MACH_EXYNOS4_DT
>> >     select S3C_DEV_HSMMC
>> >     select S3C_DEV_HSMMC2
>> >     select EXYNOS4_SETUP_SDHCI
>> > +   select EXYNOS4_SETUP_I2C1
>> >     help
>> >       Machine support for Samsung Exynos4 machine with device tree enabled.
>> >
>> > diff --git a/arch/arm/mach-exynos4/mach-exynos4-dt.c b/arch/arm/mach-exynos4/mach-exynos4-dt.c
>> > index 120665a..ef6b4cb 100644
>> > --- a/arch/arm/mach-exynos4/mach-exynos4-dt.c
>> > +++ b/arch/arm/mach-exynos4/mach-exynos4-dt.c
>> > @@ -23,7 +23,10 @@
>> >  #include <plat/regs-serial.h>
>> >  #include <plat/exynos4.h>
>> >  #include <plat/cpu.h>
>> > +#include <plat/devs.h>
>> >  #include <plat/sdhci.h>
>> > +#include <plat/iic.h>
>> > +#include <plat/iic-core.h>
>> >
>> >  #include <mach/map.h>
>> >
>> > @@ -62,6 +65,10 @@ static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
>> >     },
>> >  };
>> >
>> > +static struct s3c2410_platform_i2c exynos4_dt_i2c_data1 __initdata = {
>> > +   .cfg_gpio       = s3c_i2c1_cfg_gpio,
>> > +};
>> > +
>> >  /*
>> >   * The following lookup table is used to override device names when devices
>> >   * are registered from device tree. Optionally, the platform data can also
>> > @@ -75,6 +82,8 @@ static const struct of_dev_auxdata exynos4_auxdata_lookup[] __initconst = {
>> >                             "s3c-sdhci.2", &s3c_hsmmc2_def_platdata),
>> >     OF_DEV_AUXDATA("samsung,s3c6410-sdhci", EXYNOS4_PA_HSMMC(0),
>> >                             "s3c-sdhci.0", &s3c_hsmmc0_def_platdata),
>> > +   OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS4_PA_IIC(1),
>> > +                           "s3c2440-i2c.1", &exynos4_dt_i2c_data1),
>>
>> Should not need the platform_data here.  Add DT support to the GPIO
>> driver and decode the data from there (which should be easy).
>
> Hmm, do we have any sane way of passing which configuration settings
> should be applied to the gpio pins (given that there can be up to 13
> non-IO settings for some of these pins).

I've been looking at having an IO routing configuration node that sets
up the SoC for a particular board.  This works for static
configuration, which seems to be 99% of the use cases, but it doesn't
help much for IO configuration that needs to be manipulated at
runtime.

> Also, since this data is really part of the SoC, I don't really want
> to see n different .dts files hanging around with the same information
> in it.

Yes, the SoC details should be in a .dtsi (dts include file) file that
is included by the board file.  Properties in the board .dts file will
overlay and override data in the SoC file.

> Maybe it is time for a standardised callback to allow devices to connect
> themselves to the pins they need, and have dt capability of over-riding
> the information if it needs it.

Linus W. has been working on the pinmux subsystem to handle doing
that.  Personally, I'm not excited about device drivers managing their
own pin configuration just because the interactions and requirements
between device can be very complex.  I'd rather have it handled in a
single place for the whole system, but I'm not the one concentrating
on that problems space.

g.
Grant Likely July 18, 2011, 8:30 p.m. UTC | #5
On Mon, Jul 18, 2011 at 5:53 AM, G, Manjunath Kondaiah
<manjugk@linaro.org> wrote:
> Abraham,
> Few comments on i2c child devices handling:
>
> On 18 July 2011 06:20, Thomas Abraham <thomas.abraham@linaro.org> wrote:
>> Add device node for i2c instance 1 and list all its connected slave
>> devices.
>>
>> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
>> ---
>>  arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
>>  arch/arm/mach-exynos4/Kconfig           |    1 +
>>  arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
>>  3 files changed, 28 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
>> index d65c18c..29c40ed 100644
>> --- a/arch/arm/boot/dts/exynos4-smdkv310.dts
>> +++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
>> @@ -23,7 +23,7 @@
>>        };
>>
>>        chosen {
>> -               bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
>> +               bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
>>        };
>>
>>        soc {
>> @@ -64,5 +64,22 @@
>>                        samsung,sdhci-cd-type = <0>;
>>                        samsung,sdhci-clkdiv-external;
>>                };
>> +
>> +               i2c@13870000 {
>> +                       compatible = "samsung,s3c2440-i2c";
>> +                       reg = <0x13870000 0x100>;
>> +                       interrupts = <345>;
>> +                       samsung,i2c-bus-number = <1>;
>> +                       samsung,i2c-slave-addr = <16>;
>> +                       samsung,i2c-sda-delay = <100>;
>> +                       samsung,i2c-max-bus-freq = <100000>;
>> +                       #address-cells = <1>;
>> +                       #size-cells = <0>;
>> +
>> +                       wm8994@1a {
>> +                               compatible = "wlf,wm8994";
>> +                               reg = <0x1a>;
>> +                       };
>
> The i2c child devices are board specific.
> For ex: few boards such as smdkxxx based on exynos4 has wm8994 with
> i2c1 controller
> where as other boards based on exynos4 does not have any i2c1 devices.
> Hence these child entries should go to board specific .dts file right?

No, the i2c bus node should still appear in the SoC .dtsi file.  If a
board doesn't use a particular i2c bus, then the board.dts file can
add a status = "disabled"; property to the i2c bus node to disable it.

g.
G, Manjunath Kondaiah July 19, 2011, 5:05 p.m. UTC | #6
On Tue, Jul 19, 2011 at 2:00 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
> On Mon, Jul 18, 2011 at 5:53 AM, G, Manjunath Kondaiah
> <manjugk@linaro.org> wrote:
>> Abraham,
>> Few comments on i2c child devices handling:
>>
>> On 18 July 2011 06:20, Thomas Abraham <thomas.abraham@linaro.org> wrote:
>>> Add device node for i2c instance 1 and list all its connected slave
>>> devices.
>>>
>>> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
>>> ---
>>>  arch/arm/boot/dts/exynos4-smdkv310.dts  |   19 ++++++++++++++++++-
>>>  arch/arm/mach-exynos4/Kconfig           |    1 +
>>>  arch/arm/mach-exynos4/mach-exynos4-dt.c |    9 +++++++++
>>>  3 files changed, 28 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
>>> index d65c18c..29c40ed 100644
>>> --- a/arch/arm/boot/dts/exynos4-smdkv310.dts
>>> +++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
>>> @@ -23,7 +23,7 @@
>>>        };
>>>
>>>        chosen {
>>> -               bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
>>> +               bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
>>>        };
>>>
>>>        soc {
>>> @@ -64,5 +64,22 @@
>>>                        samsung,sdhci-cd-type = <0>;
>>>                        samsung,sdhci-clkdiv-external;
>>>                };
>>> +
>>> +               i2c@13870000 {
>>> +                       compatible = "samsung,s3c2440-i2c";
>>> +                       reg = <0x13870000 0x100>;
>>> +                       interrupts = <345>;
>>> +                       samsung,i2c-bus-number = <1>;
>>> +                       samsung,i2c-slave-addr = <16>;
>>> +                       samsung,i2c-sda-delay = <100>;
>>> +                       samsung,i2c-max-bus-freq = <100000>;
>>> +                       #address-cells = <1>;
>>> +                       #size-cells = <0>;
>>> +
>>> +                       wm8994@1a {
>>> +                               compatible = "wlf,wm8994";
>>> +                               reg = <0x1a>;
>>> +                       };
>>
>> The i2c child devices are board specific.
>> For ex: few boards such as smdkxxx based on exynos4 has wm8994 with
>> i2c1 controller
>> where as other boards based on exynos4 does not have any i2c1 devices.
>> Hence these child entries should go to board specific .dts file right?
>
> No, the i2c bus node should still appear in the SoC .dtsi file.  If a
> board doesn't use a particular i2c bus, then the board.dts file can
> add a status = "disabled"; property to the i2c bus node to disable it.

that's right. I am referring to I2C slave devices. For a given SoC,
two different
boards can have different i2c slave devices with different slave
address. In that case,
it is better to have i2c child/slave nodes in board .dts file.

-M
Tony Lindgren July 22, 2011, 7:12 a.m. UTC | #7
* G, Manjunath Kondaiah <manjugk@ti.com> [110719 09:59]:
> On Tue, Jul 19, 2011 at 2:00 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
> >
> > No, the i2c bus node should still appear in the SoC .dtsi file.  If a
> > board doesn't use a particular i2c bus, then the board.dts file can
> > add a status = "disabled"; property to the i2c bus node to disable it.
> 
> that's right. I am referring to I2C slave devices. For a given SoC,
> two different
> boards can have different i2c slave devices with different slave
> address. In that case,
> it is better to have i2c child/slave nodes in board .dts file.

This is OK for now, but from bus/hwmod point of view we need to reset all
the unused devices as otherwise PM will never work properly.

Disabling each device in the board .dts file will never be done correctly
for most boards.. And on each board, probably 2/3 of the devices are unused
because of the pin limitations :)

So the disabling of unused devices should be done with a late_initcall and
controlled by kernel cmdline. We were thinking hwmod.disable=[0|1].

The late_initcall to disable unused device tree devices could also be
added later on to device tree core code.

Regards,

Tony
diff mbox

Patch

diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
index d65c18c..29c40ed 100644
--- a/arch/arm/boot/dts/exynos4-smdkv310.dts
+++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
@@ -23,7 +23,7 @@ 
 	};
 
 	chosen {
-		bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200";
+		bootargs = "root=/dev/mmcblk0p1 rootfstype=ext3 rootwait console=ttySAC1,115200 init=/linuxrc";
 	};
 
 	soc {
@@ -64,5 +64,22 @@ 
 			samsung,sdhci-cd-type = <0>;
 			samsung,sdhci-clkdiv-external;
 		};
+
+		i2c@13870000 {
+			compatible = "samsung,s3c2440-i2c";
+			reg = <0x13870000 0x100>;
+			interrupts = <345>;
+			samsung,i2c-bus-number = <1>;
+			samsung,i2c-slave-addr = <16>;
+			samsung,i2c-sda-delay = <100>;
+			samsung,i2c-max-bus-freq = <100000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			wm8994@1a {
+				compatible = "wlf,wm8994";
+				reg = <0x1a>;
+			};
+		};
 	};
 };
diff --git a/arch/arm/mach-exynos4/Kconfig b/arch/arm/mach-exynos4/Kconfig
index bb97b7e..c7fce3e 100644
--- a/arch/arm/mach-exynos4/Kconfig
+++ b/arch/arm/mach-exynos4/Kconfig
@@ -193,6 +193,7 @@  config MACH_EXYNOS4_DT
 	select S3C_DEV_HSMMC
 	select S3C_DEV_HSMMC2
 	select EXYNOS4_SETUP_SDHCI
+	select EXYNOS4_SETUP_I2C1
 	help
 	  Machine support for Samsung Exynos4 machine with device tree enabled.
 
diff --git a/arch/arm/mach-exynos4/mach-exynos4-dt.c b/arch/arm/mach-exynos4/mach-exynos4-dt.c
index 120665a..ef6b4cb 100644
--- a/arch/arm/mach-exynos4/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos4/mach-exynos4-dt.c
@@ -23,7 +23,10 @@ 
 #include <plat/regs-serial.h>
 #include <plat/exynos4.h>
 #include <plat/cpu.h>
+#include <plat/devs.h>
 #include <plat/sdhci.h>
+#include <plat/iic.h>
+#include <plat/iic-core.h>
 
 #include <mach/map.h>
 
@@ -62,6 +65,10 @@  static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
 	},
 };
 
+static struct s3c2410_platform_i2c exynos4_dt_i2c_data1 __initdata = {
+	.cfg_gpio	= s3c_i2c1_cfg_gpio,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. Optionally, the platform data can also
@@ -75,6 +82,8 @@  static const struct of_dev_auxdata exynos4_auxdata_lookup[] __initconst = {
 				"s3c-sdhci.2", &s3c_hsmmc2_def_platdata),
 	OF_DEV_AUXDATA("samsung,s3c6410-sdhci", EXYNOS4_PA_HSMMC(0),
 				"s3c-sdhci.0", &s3c_hsmmc0_def_platdata),
+	OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS4_PA_IIC(1),
+				"s3c2440-i2c.1", &exynos4_dt_i2c_data1),
 	{},
 };