From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.243]) by ozlabs.org (Postfix) with ESMTP id 4DBCCDE12F for ; Fri, 6 Jul 2007 03:20:44 +1000 (EST) Received: by an-out-0708.google.com with SMTP id c37so478380anc for ; Thu, 05 Jul 2007 10:20:43 -0700 (PDT) Message-ID: <4b73d43f0707051020o67e671dft1d3b3816776d8eb7@mail.gmail.com> Date: Thu, 5 Jul 2007 11:20:42 -0600 From: "John Rigby" To: "=?ISO-8859-1?Q?K=E1ri_Dav=ED=F0sson?=" Subject: Re: OF devices and non OF devices In-Reply-To: <4b73d43f0707050628qd9db2afu3b63dd654be32646@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_139909_13133801.1183656042942" References: <4b73d43f0707030931v42aefc72x2598546e48ae87e8@mail.gmail.com> <4b73d43f0707050628qd9db2afu3b63dd654be32646@mail.gmail.com> Cc: linuxppc-embedded@ozlabs.org List-Id: Linux on Embedded PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , ------=_Part_139909_13133801.1183656042942 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline There must be something else wrong with your configuration. On my Lite5200B fsl_i2c_probe gets called with no changes to the driver. The kernel version is 2.6.22-rc7 The relevant part of my device tree is: i2c@3d00 { device_type =3D "i2c"; compatible =3D "mpc5200b-i2c\0mpc5200-i2c\0fsl-i2c"; cell-index =3D <0>; reg =3D <3d00 40>; interrupts =3D <2 f 0>; interrupt-parent =3D <&mpc5200_pic>; fsl5200-clocking; }; i2c@3d40 { device_type =3D "i2c"; compatible =3D "mpc5200b-i2c\0mpc5200-i2c\0fsl-i2c"; cell-index =3D <1>; reg =3D <3d40 40>; interrupts =3D <2 10 0>; interrupt-parent =3D <&mpc5200_pic>; fsl5200-clocking; }; I turned on DEBUG in drivers/base/dd.c and a call to pr_debug in the probe routine and here are the relevant log messages: [ 27.258245] platform: Matched Device fsl-i2c.0 with Driver fsl-i2c [ 27.258269] platform: Probing driver fsl-i2c with device fsl-i2c.0 [ 27.258299] I2C: here in fsl_i2c_probe [ 27.258732] bound device 'fsl-i2c.0' to driver 'fsl-i2c' [ 27.258756] platform: Bound Device fsl-i2c.0 to Driver fsl-i2c [ 27.258776] platform: Matched Device fsl-i2c.1 with Driver fsl-i2c [ 27.258789] platform: Probing driver fsl-i2c with device fsl-i2c.1 [ 27.258821] I2C: here in fsl_i2c_probe [ 27.259269] bound device 'fsl-i2c.1' to driver 'fsl-i2c' [ 27.259293] platform: Bound Device fsl-i2c.1 to Driver fsl-i2c John On 7/5/07, John Rigby wrote: > > kd, > > Ok, obviously It doesn't work the way I thought. Hopefully someone who > does > understand this will comment. > > John > > On 7/4/07, K=E1ri Dav=ED=F0sson wrote: > > > > John, thank you for your answare. > > > > Enabling CONFIG_FSL_SOC only enabled the execution of the init function > > (fsl_i2c_init()) > > of the fsl-i2c driver (i2c-mpc.c). The .probe function of the driver wa= s > > never called > > until I converted the driver to the OF model and added the .match_table > > to the driver structure. > > > > Then I get the .probe function (fsl_i2c_probe()) called and the i2c bus > > set up. > > > > Similar thing happens for the i2c device PCF8563 i.e., the init functin > > of the driver (pcf8563_init()) > > is called the driver is registered with the kernel, but the .probe > > (pcf8563_probe()) is never called. > > > > The driver pcf8563 has _NO_ exported structures or functions so I > > basically have no handle on it > > that I can utilize in board specific setup. > > > > The way I suspect this is supposed to work is that from the board settu= p > > files I would do > > rtc_dev =3D platform_device_register_simple("pcf8563", -1, NULL, 0); > > which should later trigger the calling of the pcf8563_probe() function. > > > > This is doing things in the same way as the fsl i2c code, i.e. > > i2c_dev =3D platform_device_register_simple("i2c", i, r, 2); > > which by the way does not work untill I have converted the fsl_i2c ( > > i2c-mpc.c) driver to the OF structure. > > > > So still the method of gluing together the OF drivers and non OF driver= s > > eludes me. > > > > rg > > kd > > > > P.S. I did check the 2.6.21-RC7-git3 and found that the i2c-mpc.c and > > the rtc-pcf85763.c are basically the same > > as what I am working with in 2.6.20+ > > ________________________________ > > > > From: John Rigby [mailto: jcrigby@gmail.com] > > Sent: 3. j=FAl=ED 2007 16:31 > > To: K=E1ri Dav=ED=F0sson > > Cc: linuxppc-embedded@ozlabs.org > > Subject: Re: OF devices and non OF devices > > > > > > One place to find binding between OF devices and non OF devices is in > > arch/powerpc/sysdev/fsl_soc.c > > The typical pattern is: > > if of_find_compatible_node "of-device-name" > > platform_device_register_simple ""platform-device-name" > > platform_device_add_data ... > > > > > > > > On 7/3/07, K=E1ri Dav=ED=F0sson wrote: > > > > Hi, > > > > I am attempting to get some non OF devices working for an mpc > > 5200 board, in particular > > PCF8563 RTC. > > > > This device has an non OF device interface which I believe is > > correct. After all it should work > > on non OF platforms. > > > > I have managed to get the board to run the i2c initialization > > (and probe) for the fsl-mpc i2c driver by > > converting the fsl-mpc i2c driver to OF driver (I found some > > patch here that I based this work on). > > > > > > fsl-i2c is one of the devices handled by fsl_soc.c so you shouldn't nee= d > > to change anything to > > make it work in the latest kernel. CONFIG_FSL_SOC was only added to > > lite5200_defconfig recently so > > that may explain why it's not on in your kernel. > > > > > > > > Since the PCF8563 driver is not OF driver only its > > initaliziation code is run but the .probe function > > of the driver is never run. Basically (as far as I can > > understand) the .probe is never run because the > > driver is not an OF driver. > > > > I could convert the PCF8563 driver to OF driver and make it wor= k > > for our puposes but I feel this is > > 1) Wrong > > 2) therefore wasted work. > > > > > > Since the driver must run on non OF platforms then it should not be > > converted. You just need to add a platform_device_register somewhere. > > I don't think fsl_soc.c is the right place since it is not part of an > > freescale SOC. > > You could probably put it in a board specific startup routine. > > > > > > > > What seems to elude me is some glue that glues together the OF > > part of the driver space to the non OF part > > of the driver space. > > > > Any hints or pointers on where to find this glue? > > > > Regards, > > kd > > > > P.S. Kernel is post 2.6.20. > > > > -- > > K=E1ri Dav=ED=F0sson | kari.davidsson@marel.i= s > > Hugb=FAna=F0arger=F0 | www.marel.com > > Tel: 563-8156 Fax: +354 563 8001 > > Iceland > > _______________________________________________ > > Linuxppc-embedded mailing list > > Linuxppc-embedded@ozlabs.org > > https://ozlabs.org/mailman/listinfo/linuxppc-embedded > > > > > > > > _______________________________________________ > > Linuxppc-embedded mailing list > > Linuxppc-embedded@ozlabs.org > > https://ozlabs.org/mailman/listinfo/linuxppc-embedded > > > > ------=_Part_139909_13133801.1183656042942 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline There must be something else wrong with your configuration.
On my Lite52= 00B fsl_i2c_probe gets called with no changes to the driver.

The ker= nel version is 2.6.22-rc7

The relevant part of my device tree is:

        i2c@3d00 {
  &nb= sp;         device_type =3D "i2c";<= br>            compatible =3D = "mpc5200b-i2c\0mpc5200-i2c\0fsl-i2c";
     = ;       cell-index =3D <0>;
  &= nbsp;         reg =3D <3d00 40>;
            interrupts =3D= <2 f 0>;
           = interrupt-parent =3D <&mpc5200_pic>;
     = ;       fsl5200-clocking;
    &n= bsp;   };

        i2c@3d40 {=
            device_type = =3D "i2c";
            compatible =3D= "mpc5200b-i2c\0mpc5200-i2c\0fsl-i2c";
    &nbs= p;       cell-index =3D <1>;
  =           reg =3D <3d40 40>;
&n= bsp;           interrupts =3D <2= 10 0>;
            inte= rrupt-parent =3D <&mpc5200_pic>;
            fsl5200-clocki= ng;
        };

I turned on DEBUG in= drivers/base/dd.c and a call to pr_debug in the probe routine
and here = are the relevant log messages:

[   27.258245] platform: Ma= tched Device=20 fsl-i2c.0 with Driver fsl-i2c
[   27.258269] platform: Probing= driver fsl-i2c with device fsl-i2c.0
[   27.258299] I2C: here= in fsl_i2c_probe
[   27.258732] bound device 'fsl-i2c.0&#= 39; to driver 'fsl-i2c'
[   27.258756] platform: Bound Device fsl-i2c.0 to Driver fsl= -i2c
[   27.258776] platform: Matched Device fsl-i2c.1 with Dr= iver fsl-i2c
[   27.258789] platform: Probing driver fsl-i2c w= ith device fsl-i2c.1
[  =20 27.258821] I2C: here in fsl_i2c_probe
[   27.259269] bound dev= ice 'fsl-i2c.1' to driver 'fsl-i2c'
[   27.259= 293] platform: Bound Device fsl-i2c.1 to Driver fsl-i2c

John

=
On 7/5/07, John Rigby <jcrigby@gmail.com> wrote:
kd,

Ok, obviously It doesn't work the way I thought.  Hopef= ully someone who does
understand this will comment.

John

On 7/4/07, K=E1ri Dav=ED=F0sson <kari.davidsson@marel.is= > wrote:
John, thank you for your answare.

Enabling CONFIG_FSL_SOC only enabl= ed the execution of the init function (fsl_i2c_init())
of the fsl-i2c dr= iver (i2c-mpc.c). The .probe function of the driver was never called
until I converted the driver to the OF model and added the .match_table to = the driver structure.

Then I get the .probe function (fsl_i2c_probe(= )) called and the i2c bus set up.

Similar thing happens for the i2c = device PCF8563=20 i.e., the init functin of the driver (pcf8563_init())
is called the driv= er is registered with the kernel, but the .probe (pcf8563_probe()) is never= called.

The driver pcf8563 has _NO_ exported structures or function= s so I basically have no handle on it
that I can utilize in board specific setup.

The way I suspect th= is is supposed to work is that from the board settup files I would do
rt= c_dev =3D platform_device_register_simple("pcf8563", -1, NULL, 0)= ;
which should later trigger the calling of the pcf8563_probe() function.=

This is doing things in the same way as the fsl i2c code, i.e.
i= 2c_dev =3D platform_device_register_simple("i2c", i, r, 2);
which by the way does not work untill I have converted the fsl_i2c (i2c-mpc= .c) driver to the OF structure.

So still the method of gluing togeth= er the OF drivers and non OF drivers eludes me.

rg
kd

P.S. I did check the 2.6.21-RC7-git3 and found that the i2c-mpc.c and the r= tc-pcf85763.c are basically the same
as what I am working with in 2.6.20= +
________________________________

From: John Rigby [mailto: jcrigby@gmail.com]
Sent: 3. j=FAl=ED 2007 16:31
To: K=E1ri Dav=ED= =F0sson
Cc: linuxppc-emb= edded@ozlabs.org
Subject: Re: OF devices and non OF devices


One place to = find binding between OF devices and non OF devices is in arch/powerpc/sysde= v/fsl_soc.c
The typical pattern is:
    if of_find_compatibl= e_node "of-device-name"
      &n= bsp; platform_device_register_simple ""platform-device-name&= quot;
        platform_device_ad= d_data ...



On 7/3/07, K=E1ri Dav=ED=F0sson <kari.davidsson@marel.is> wrote:

   &nb= sp;    Hi,

      &= nbsp; I am attempting to get some non OF devices working for an mpc 52= 00 board, in particular
        PCF8563 RTC.

&nb= sp;       This device has an non OF devi= ce interface which I believe is correct. After all it should work
 =        on non OF platforms.

 = ;       I have managed to get the board = to run the i2c initialization (and probe) for the fsl-mpc i2c driver by
        converting the fsl-mpc = i2c driver to OF driver (I found some patch here that I based this work on)= .


fsl-i2c is one of the devices handled by fsl_soc.c so you shou= ldn't need to change anything to
make it work in the latest kernel.  CONFIG_FSL_SOC was only a= dded to lite5200_defconfig recently so
that may explain why it's not= on in your kernel.



      &nbs= p; Since the PCF8563 driver is not OF driver only its initaliziation c= ode is run but the .probe function
        of the driver is never = run. Basically (as far as I can understand) the .probe is never run because= the
        driver is not an OF= driver.

        I could con= vert the PCF8563 driver to OF driver and make it work for our puposes but I= feel this is
        1) Wrong
  = ;      2) therefore wasted work.


S= ince the driver must run on non OF platforms then it should not be converte= d.  You just need to add a platform_device_register somewhere.I don't think fsl_soc.c is  the right place since it is not = part of an freescale SOC.
You could probably put it in a board specific startup routine.

<= br>
        What seems to elude = me is some glue that glues together the OF part of the driver space to the = non OF part
        of the drive= r space.

        Any hints or pointe= rs on where to find this glue?

      &= nbsp; Regards,
        kd
        P.S. Kernel is post 2= .6.20.

        --
 &= nbsp;      K=E1ri Dav=ED=F0sson  &n= bsp;            = ;    | kari.davidsson@marel.is
       &n= bsp;Hugb=FAna=F0arger=F0        &nb= sp;          | www.marel.com
      =   Tel: 563-8156 Fax: +354 563 8001
        Iceland
  =       _______________________________________= ________
        Linuxppc-embedded maili= ng list
        Linuxppc-embedded@ozlabs.org
 &= nbsp;       https://ozlabs.org/mailman/listinfo/linuxppc-embedded



_______________________________________________
Linu= xppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
<= /div>

------=_Part_139909_13133801.1183656042942--