From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by ozlabs.org (Postfix) with ESMTP id 16350DDFAC for ; Fri, 13 Feb 2009 21:48:08 +1100 (EST) Received: by bwz12 with SMTP id 12so3110018bwz.9 for ; Fri, 13 Feb 2009 02:48:06 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 13 Feb 2009 11:40:31 +0100 Message-ID: Subject: Re: Chipselect in SPI binding with mpc5200-psc-spi From: Henk Stegeman To: linuxppc-dev@ozlabs.org Content-Type: multipart/alternative; boundary=0016364587e85365d60462ca77f3 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --0016364587e85365d60462ca77f3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I'm busy adding support for slave deviced behind mpc52xx-psc-spi. One complication I have is that my SPI slave device has an interrupt output to the CPU. My idea is to add it as a gpios property in the slave device's configuration: spi@2400 { // PSC3 (SPI IF to the IO-controller ) device_type = "spi"; #address-cells = <1>; #size-cells = <0>; compatible = "fsl,mpc5200-psc-spi","fsl,mpc5200b-psc-spi"; cell-index = <2>; reg = <0x2400 0x100>; interrupts = <2 3 0>; interrupt-parent = <&mpc5200_pic>; gpios = <&gpt4 0 0>; io-controller@0 { compatible = "microkey,smc4000io"; spi-max-frequency = <1000000>; reg = <0>; // gpios: first is IRQ to cpu gpios = <&gpt6 0 0>; }; }; Are there better/easier ways to do this? How should I then register my spi slave driver? My smc4000io_probe function gets called correctly by of_spi support but when I register as follows: static struct spi_driver smc4000io_driver = { .driver = { .name = "smc4000io", .bus = &spi_bus_type, .owner = THIS_MODULE, }, .probe = smc4000io_probe, .remove = __devexit_p(smc4000io_remove), }; static int __init smc4000io_init(void) { return spi_register_driver(&smc4000io_driver); } static void __exit smc4000io_exit(void) { spi_unregister_driver(&smc4000io_driver); } module_init(smc4000io_init); But when I do: static struct of_platform_driver smc4000_spi_of_driver = { .name = "smc4000io", .match_table = smc4000io_of_match, .probe = smc4000io_of_probe, .remove = __devexit_p(smc4000io_of_remove), }; static int __init smc4000io_init(void) { return of_register_platform_driver(&smc4000_spi_of_driver); } module_init(smc4000io_init); Then my smc4000io_of_probe function never gets called. Thanks in advance, Henk. On Wed, Oct 29, 2008 at 3:45 PM, Grant Likely wrote: > On Wed, Oct 29, 2008 at 7:43 AM, Henk Stegeman > wrote: > > .. > > .. > > In my dts > > > > I have my chipselect defined as follows: > > > > gpt4: timer@640 { // General Purpose Timer GPT4 in GPIO mode > for > > SMC4000IO chip select. > > compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio"; > > cell-index = <4>; > > reg = <0x640 0x10>; > > interrupts = <1 13 0>; > > interrupt-parent = <&mpc5200_pic>; > > gpio-controller; > > #gpio-cells = <2>; > > }; > > > > I found the gpio in > > # cat /sys/class/gpio/gpiochip215/label > > /soc5200@f0000000/timer@640 > > > > The spi controller is defined like this: > > > > spi@2400 { > > device_type = "spi"; > > #address-cells = <1>; > > #size-cells = <0>; > > compatible = "fsl,mpc5200-psc-spi","fsl,mpc5200b-psc-spi"; > > cell-index = <2>; > > reg = <2400 100>; > > interrupts = <2 3 0>; > > interrupt-parent = <&mpc5200_pic>; > > gpios = <&gpt4 0 0>; > > > > io-controller@0 { > > compatible = "microkey,smc4000io"; > > spi-max-frequency = <1000000>; > > reg = <0>; > > }; > > }; > > > > At bootup linux (2.6.27) reports: > > > > mpc52xx-psc-spi f0000960.spi: probe called without platform data, no > > (de)activate_cs function will be called. > > > > Is my assumption wrong that the gpios property is the way to map > chipselects > > to the spi driver? > > Yes, that is the way you should work specify the chip selects, but the > driver hasn't been updated to support it yet. > > g. > > -- > Grant Likely, B.Sc., P.Eng. > Secret Lab Technologies Ltd. > --0016364587e85365d60462ca77f3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm busy adding support for slave deviced behind mpc52xx-psc-spi.
On= e complication I have is that my SPI slave device has an interrupt output t= o the CPU.
My idea is to add it as a gpios property in the slave device&= #39;s configuration:

      &= nbsp; spi@2400 {        // PSC3 (SPI IF = to the IO-controller )
        &= nbsp;   device_type =3D "spi";
   &nb= sp;        #address-cells =3D <1>;=
            #siz= e-cells =3D <0>;
            compatib= le =3D "fsl,mpc5200-psc-spi","fsl,mpc5200b-psc-spi";            cell-in= dex =3D <2>;
         = ;   reg =3D <0x2400 0x100>;
    &nbs= p;       interrupts =3D <2 3 0>;
&nb= sp;           interrupt-p= arent =3D <&mpc5200_pic>;
            gpios = =3D <&gpt4 0 0>;

       = ;     io-controller@0 {
    &nbs= p;           compatible = =3D "microkey,smc4000io";
      =           spi-max-frequency = =3D <1000000>;
        &nb= sp;       reg =3D <0>;
            &nb= sp;   // gpios: first is IRQ to cpu
    &n= bsp;           gpios =3D = <&gpt6 0 0>;
        &= nbsp;   };
        };


Are there better/easier ways to do this?

How should I th= en register my spi slave driver? My smc4000io_probe function gets called co= rrectly by of_spi support but when I register as follows:

static struct spi_driver smc4000io_dr= iver =3D {
    .driver =3D {
     =    .name    =3D "smc4000io",
 &n= bsp;      .bus    =3D &spi_bus_type,=
        .owner    =3D THIS= _MODULE,
    },
    .probe     =    =3D smc4000io_probe,
    .remove  =       =3D __devexit_p(smc4000io_remove),
};

s= tatic int __init smc4000io_init(void)
{
    return spi= _register_driver(&smc4000io_driver);
}

static void __exit smc4000io_exit(void)
{
    spi_= unregister_driver(&smc4000io_driver);
}

module_init(smc4000io= _init);

But when I do:

On Wed, Oct 29, 2008 at 3:45= PM, Grant Likely <grant.likely@secretlab.ca> wrote:
On Wed, Oct 29, 2008 at 7:43 AM, Henk= Stegeman <henk.stegeman@gmai= l.com> wrote:
> ..
> ..
> In my dts
>
> I have my chipselect defined as follows:
>
>         gpt4: timer@640 {    // General = Purpose Timer GPT4 in GPIO mode for
> SMC4000IO chip select.
>             compatible =3D "fsl,mpc= 5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
>             cell-index =3D <4>; >             reg =3D <0x640 0x10>;<= br> >             interrupts =3D <1 13 0>= ;;
>             interrupt-parent =3D <&am= p;mpc5200_pic>;
>             gpio-controller;
>             #gpio-cells =3D <2>; >         };
>
> I found the gpio in
> # cat /sys/class/gpio/gpiochip215/label
> /soc5200@f0000000/timer@640
>
> The spi controller is defined like this:
>
>         spi@2400 {
>             device_type =3D "spi&qu= ot;;
>             #address-cells =3D <1>= ;
>             #size-cells =3D <0>; >             compatible =3D "fsl,mpc= 5200-psc-spi","fsl,mpc5200b-psc-spi";
>             cell-index =3D <2>; >             reg =3D <2400 100>; >             interrupts =3D <2 3 0>= ;
>             interrupt-parent =3D <&am= p;mpc5200_pic>;
>             gpios =3D <&gpt4 0 0&= gt;;
>
>             io-controller@0 {
>                 compatible =3D= "microkey,smc4000io";
>                 spi-max-freque= ncy =3D <1000000>;
>                 reg =3D <0&= gt;;
>             };
>         };
>
> At bootup linux (2.6.27) reports:
>
> mpc52xx-psc-spi f0000960.spi: probe called without platform data, no > (de)activate_cs function will be called.
>
> Is my assumption wrong that the gpios property is the way to map chips= elects
> to the spi driver?

Yes, that is the way you should work specify the chip selects, = but the
driver hasn't been updated to support it yet.

g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

--0016364587e85365d60462ca77f3--