From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manjunatha GK Subject: Re: Converting i2c-omap driver to use device tree Date: Fri, 24 Jun 2011 19:08:34 +0530 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0708256244574866621==" Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Sender: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org To: Thomas Abraham Cc: "devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org\"" List-Id: devicetree@vger.kernel.org --===============0708256244574866621== Content-Type: multipart/alternative; boundary=0016e6dab3496b83f104a675519b --0016e6dab3496b83f104a675519b Content-Type: text/plain; charset=ISO-8859-1 Hi Thomas, On 24 June 2011 18:13, Thomas Abraham 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 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@48072000 { > > + compatible = "ti,omap_i2c"; > > + reg = <0x48072000 0x80>; > > + #address-cells = <1>; > > + #size-cells = <0>; > > Shouldn't size-cells = 1 ? > > > + > > + twl@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 --0016e6dab3496b83f104a675519b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Thomas,

On 24 June 2011 18:13, Thomas = Abraham <= thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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 h= ave
> 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:
>
> +=A0=A0=A0=A0=A0=A0 i2c@48072000 {
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 compatible =3D "ti,om= ap_i2c";
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 reg =3D <0x48072000 0x8= 0>;
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 #address-cells =3D <1&g= t;;
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 #size-cells =3D <0>;=

Shouldn't size-cells =3D 1 ?

> +
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 twl@48 {
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 co= mpatible =3D "twl6030,4030-6030";
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 re= g =3D < 0x48 >;
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 };
> +=A0=A0=A0=A0=A0=A0 };
>
> and board file is changed as:
>
> @@ -685,6 +686,10 @@ static void __init omap4_panda_init(void)
> =A0{
> =A0=A0=A0=A0=A0=A0=A0 int package =3D OMAP_PACKAGE_CBS;
>
> +#ifdef CONFIG_OF
> +=A0=A0=A0=A0=A0=A0 of_platform_prepare(NULL, NULL);
> +#endif /* CONFIG_OF */

Is of_platform_prepare still required?
=A0
=
not required. removed now.


> +
> =A0=A0=A0=A0=A0=A0=A0 if (omap_rev() =3D=3D OMAP4430_REV_ES1_0)
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 package =3D OMAP_PACKAGE= _CBL;
> =A0=A0=A0=A0=A0=A0=A0 omap4_mux_init(board_mux, NULL, package);
> @@ -700,6 +705,7 @@ static void __init omap4_panda_init(void)
> =A0=A0=A0=A0=A0=A0=A0 omap4_ehci_init();
> =A0=A0=A0=A0=A0=A0=A0 usb_musb_init(&musb_board_data);
> =A0=A0=A0=A0=A0=A0=A0 omap4_panda_display_init();
> +=A0=A0=A0=A0=A0=A0 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 e= ntry in dts file.

> =A0}
>
> 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[] =3D {
>
> =A0static int __init omap4_panda_i2c_init(void)
> =A0{
> -=A0=A0=A0=A0=A0=A0 omap4_pmic_init("twl6030", &omap4_pa= nda_twldata);
> +=A0=A0=A0=A0=A0=A0 //omap4_pmic_init("twl6030", &omap4_= panda_twldata);
> @@ -685,6 +686,10 @@ static void __init omap4_panda_init(void)
> =A0{
> =A0=A0=A0=A0=A0=A0=A0 int package =3D OMAP_PACKAGE_CBS;
>
> +#ifdef CONFIG_OF
> +=A0=A0=A0=A0=A0=A0 of_platform_prepare(NULL, NULL);
> +#endif /* CONFIG_OF */
> +
> =A0=A0=A0=A0=A0=A0=A0 if (omap_rev() =3D=3D OMAP4430_REV_ES1_0)
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 package =3D OMAP_PACKAGE= _CBL;
> =A0=A0=A0=A0=A0=A0=A0 omap4_mux_init(board_mux, NULL, package);
> @@ -700,6 +705,7 @@ static void __init omap4_panda_init(void)
> =A0=A0=A0=A0=A0=A0=A0 omap4_ehci_init();
> =A0=A0=A0=A0=A0=A0=A0 usb_musb_init(&musb_board_data);
> =A0=A0=A0=A0=A0=A0=A0 omap4_panda_display_init();
> +=A0=A0=A0=A0=A0=A0 of_platform_populate(NULL, NULL, NULL, NULL);
> =A0}
>
> and i2c-omap is modified as:
>
> +static const struct of_device_id omap_i2c_of_match[];
> =A0static int __devinit
> =A0omap_i2c_probe(struct platform_device *pdev)
> =A0{
> @@ -1162,6 +1169,12 @@ static int omap_i2c_resume(struct device *dev)<= br> > =A0=A0=A0=A0=A0=A0=A0 return 0;
> =A0}
>
> +static const struct of_device_id omap_i2c_of_match[] =3D {
> +=A0=A0=A0=A0=A0=A0 {.compatible =3D "omap_i2c", },
> +=A0=A0=A0=A0=A0=A0 {},
> +}
> +MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
>
> With the above changes, i was expecting probe function to be called si= nce
> 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 pop= ulated
(set to omap_i2c_of_match)?
=A0
Yes. This en= try was missing with my changes. With of_match_table, probe is getting call= ed.
Thanks for the pointer.

-Manjunath
--0016e6dab3496b83f104a675519b-- --===============0708256244574866621== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org https://lists.ozlabs.org/listinfo/devicetree-discuss --===============0708256244574866621==--