Converting i2c-omap driver to use device tree

Manjunatha GK manjugk at ti.com
Fri Jun 24 23:38:34 EST 2011


Hi Thomas,

On 24 June 2011 18:13, Thomas Abraham <thomas.abraham at linaro.org> wrote:

> Hi Manjunath,
>
> I will try to give some comments based on whatever little I know about
> DT. My comments maybe wrong too, I am still learning DT.
>
> On 23 June 2011 19:45, Manjunatha GK <manjugk at linaro.org> wrote:
> > Hi Grant,
> > I am trying to convert i2c-omap driver to use device tree. Since omap i2c
> > driver uses it's own mechanism to register as platform device, I have
> > commented out i2c device registration part from board file and trying to
> use
> > DT data in probe function of i2c driver.
> >
> > I have i2c node declared under omap4-panda.dts as:
> >
> > +       i2c at 48072000 {
> > +               compatible = "ti,omap_i2c";
> > +               reg = <0x48072000 0x80>;
> > +               #address-cells = <1>;
> > +               #size-cells = <0>;
>
> Shouldn't size-cells = 1 ?
>
> > +
> > +               twl at 48 {
> > +                       compatible = "twl6030,4030-6030";
> > +                       reg = < 0x48 >;
> > +               };
> > +       };
> >
> > and board file is changed as:
> >
> > @@ -685,6 +686,10 @@ static void __init omap4_panda_init(void)
> >  {
> >         int package = OMAP_PACKAGE_CBS;
> >
> > +#ifdef CONFIG_OF
> > +       of_platform_prepare(NULL, NULL);
> > +#endif /* CONFIG_OF */
>
> Is of_platform_prepare still required?
>

not required. removed now.


> > +
> >         if (omap_rev() == OMAP4430_REV_ES1_0)
> >                 package = OMAP_PACKAGE_CBL;
> >         omap4_mux_init(board_mux, NULL, package);
> > @@ -700,6 +705,7 @@ static void __init omap4_panda_init(void)
> >         omap4_ehci_init();
> >         usb_musb_init(&musb_board_data);
> >         omap4_panda_display_init();
> > +       of_platform_populate(NULL, NULL, NULL, NULL);
>
> Is it not required to provide the second parameter (matches) atleast?
> It depends on your dts file I guess. Maybe a proper matching is not
> happening.
>
yes. updated with second parameter as per entry in dts file.

>
> >  }
> >
> > I have commented out device registration for I2C1 in board file:
> >
> > diff --git a/arch/arm/mach-omap2/board-omap4panda.c
> > b/arch/arm/mach-omap2/board-omap4panda.c
> > index c9d1e13..0c31f35 100644
> > --- a/arch/arm/mach-omap2/board-omap4panda.c
> > +++ b/arch/arm/mach-omap2/board-omap4panda.c
> > @@ -409,7 +410,7 @@ static struct i2c_board_info __initdata
> > panda_i2c_eeprom[] = {
> >
> >  static int __init omap4_panda_i2c_init(void)
> >  {
> > -       omap4_pmic_init("twl6030", &omap4_panda_twldata);
> > +       //omap4_pmic_init("twl6030", &omap4_panda_twldata);
> > @@ -685,6 +686,10 @@ static void __init omap4_panda_init(void)
> >  {
> >         int package = OMAP_PACKAGE_CBS;
> >
> > +#ifdef CONFIG_OF
> > +       of_platform_prepare(NULL, NULL);
> > +#endif /* CONFIG_OF */
> > +
> >         if (omap_rev() == OMAP4430_REV_ES1_0)
> >                 package = OMAP_PACKAGE_CBL;
> >         omap4_mux_init(board_mux, NULL, package);
> > @@ -700,6 +705,7 @@ static void __init omap4_panda_init(void)
> >         omap4_ehci_init();
> >         usb_musb_init(&musb_board_data);
> >         omap4_panda_display_init();
> > +       of_platform_populate(NULL, NULL, NULL, NULL);
> >  }
> >
> > and i2c-omap is modified as:
> >
> > +static const struct of_device_id omap_i2c_of_match[];
> >  static int __devinit
> >  omap_i2c_probe(struct platform_device *pdev)
> >  {
> > @@ -1162,6 +1169,12 @@ static int omap_i2c_resume(struct device *dev)
> >         return 0;
> >  }
> >
> > +static const struct of_device_id omap_i2c_of_match[] = {
> > +       {.compatible = "omap_i2c", },
> > +       {},
> > +}
> > +MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
> >
> > With the above changes, i was expecting probe function to be called since
> > device gets binded to driver. But probe will never get called.
> >
> > Did I miss anything with above procedure?
>
> What about platform_driver->driver.of_match_table? Is it populated
> (set to omap_i2c_of_match)?
>

Yes. This entry was missing with my changes. With of_match_table, probe is
getting called.
Thanks for the pointer.

-Manjunath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/devicetree-discuss/attachments/20110624/f1da6928/attachment-0001.html>


More information about the devicetree-discuss mailing list