All of lore.kernel.org
 help / color / mirror / Atom feed
* Chipselect in SPI binding with mpc5200-psc-spi
@ 2008-10-29 13:43 Henk Stegeman
  2008-10-29 14:45 ` Grant Likely
  0 siblings, 1 reply; 12+ messages in thread
From: Henk Stegeman @ 2008-10-29 13:43 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

..
..
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?

Thanks in advance.
Henk.

[-- Attachment #2: Type: text/html, Size: 2834 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2008-10-29 13:43 Chipselect in SPI binding with mpc5200-psc-spi Henk Stegeman
@ 2008-10-29 14:45 ` Grant Likely
  2009-02-13 10:40   ` Henk Stegeman
  0 siblings, 1 reply; 12+ messages in thread
From: Grant Likely @ 2008-10-29 14:45 UTC (permalink / raw)
  To: Henk Stegeman; +Cc: linuxppc-dev

On Wed, Oct 29, 2008 at 7:43 AM, Henk Stegeman <henk.stegeman@gmail.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 = "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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2008-10-29 14:45 ` Grant Likely
@ 2009-02-13 10:40   ` Henk Stegeman
  2009-02-13 15:19     ` Grant Likely
  0 siblings, 1 reply; 12+ messages in thread
From: Henk Stegeman @ 2009-02-13 10:40 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 3952 bytes --]

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 <grant.likely@secretlab.ca>wrote:

> On Wed, Oct 29, 2008 at 7:43 AM, Henk Stegeman <henk.stegeman@gmail.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 = "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.
>

[-- Attachment #2: Type: text/html, Size: 7559 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-02-13 10:40   ` Henk Stegeman
@ 2009-02-13 15:19     ` Grant Likely
  2009-02-13 15:52       ` Henk Stegeman
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Grant Likely @ 2009-02-13 15:19 UTC (permalink / raw)
  To: Henk Stegeman; +Cc: linuxppc-dev

On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman@gmail.com> wrote:
> 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>;
>             };

There is a better way to do this, and driver support for it is
currently merged into Ben Herrenschmidt's -next tree.

Do this instead:
        io-controller@0 {
                compatible = "microkey,smc4000io";
                spi-max-frequency = <1000000>;
                reg = <0>;
                interrupt-controller = < &gpt6 >;     // Use GPT6 as
the IRQ controller
                interrupts = < 1 >;    // And make it rising edge.
        };

Then add these two properties to the GPT node:

        interrupt-controller;
        #interrupt-cells = <1>;

Then you can use normal irq_of_parse_and_map() to set up your handler.

> 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);

Yes, this is right.  The psc_spi driver automatically registers all
spi children that it finds in the device tree onto the SPI bus.
Therefore registering an spi_driver() is the right thing to do.

> 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.

Correct.  of_platform_driver isn't useful in this case because the
device cannot exist independently of the SPI bus.  Plus an
of_platform_device doesn't provide any information about the SPI bus
itself.

g.

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-02-13 15:19     ` Grant Likely
@ 2009-02-13 15:52       ` Henk Stegeman
  2009-06-15 16:36       ` Kári Davíðsson
  2009-07-07 14:31       ` Henk Stegeman
  2 siblings, 0 replies; 12+ messages in thread
From: Henk Stegeman @ 2009-02-13 15:52 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 3906 bytes --]

Thanks Greg,

I'm having success more success with the driver now,

The device gets nicely probed and the probe function gets the properties
from the device tree,

The following patch from Anton Vorontsov:

http://kerneltrap.org/mailarchive/linux-kernel/2008/5/23/1922744

Was very useful  as example for adding the of support to my 'own' spi slave
driver.

(Thanks Anton,)

Henk.

On Fri, Feb 13, 2009 at 4:19 PM, Grant Likely <grant.likely@secretlab.ca>wrote:

> On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman@gmail.com>
> wrote:
> > 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>;
> >             };
>
> There is a better way to do this, and driver support for it is
> currently merged into Ben Herrenschmidt's -next tree.
>
> Do this instead:
>         io-controller@0 {
>                compatible = "microkey,smc4000io";
>                spi-max-frequency = <1000000>;
>                reg = <0>;
>                 interrupt-controller = < &gpt6 >;     // Use GPT6 as
> the IRQ controller
>                interrupts = < 1 >;    // And make it rising edge.
>        };
>
> Then add these two properties to the GPT node:
>
>        interrupt-controller;
>        #interrupt-cells = <1>;
>
> Then you can use normal irq_of_parse_and_map() to set up your handler.
>
> > 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);
>
> Yes, this is right.  The psc_spi driver automatically registers all
> spi children that it finds in the device tree onto the SPI bus.
> Therefore registering an spi_driver() is the right thing to do.
>
> > 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.
>
> Correct.  of_platform_driver isn't useful in this case because the
> device cannot exist independently of the SPI bus.  Plus an
> of_platform_device doesn't provide any information about the SPI bus
> itself.
>
> g.
>
> --
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
>

[-- Attachment #2: Type: text/html, Size: 6384 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-02-13 15:19     ` Grant Likely
  2009-02-13 15:52       ` Henk Stegeman
@ 2009-06-15 16:36       ` Kári Davíðsson
  2009-06-15 17:31         ` Grant Likely
  2009-07-07 14:31       ` Henk Stegeman
  2 siblings, 1 reply; 12+ messages in thread
From: Kári Davíðsson @ 2009-06-15 16:36 UTC (permalink / raw)
  Cc: linuxppc-dev

Is this true?

Grant Likely wrote:
> 
> Yes, this is right.  The psc_spi driver automatically registers all
> spi children that it finds in the device tree onto the SPI bus.
> Therefore registering an spi_driver() is the right thing to do.

I am writing an SPI protocol driver and I find that my driver
is never probed.

I tried to add and call to of_register_spi_devices() in the
drivers/spi/mpc52xx_psc_spi.c::mpc52xx_psc_spi_of_probe() function,
without much effect besided that the DTS node is parsed but the driver probe
is not called, actually it complains about a modalias for my node is missing.

This is with kernel 2.6.29.3.

rg
kd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-06-15 16:36       ` Kári Davíðsson
@ 2009-06-15 17:31         ` Grant Likely
  2009-06-16 10:41           ` Kári Davíðsson
  0 siblings, 1 reply; 12+ messages in thread
From: Grant Likely @ 2009-06-15 17:31 UTC (permalink / raw)
  To: Kári Davíðsson; +Cc: linuxppc-dev

On Mon, Jun 15, 2009 at 10:36 AM, K=E1ri
Dav=ED=F0sson<kari.davidsson@marel.com> wrote:
> Is this true?
>
> Grant Likely wrote:
>>
>> Yes, this is right. =A0The psc_spi driver automatically registers all
>> spi children that it finds in the device tree onto the SPI bus.
>> Therefore registering an spi_driver() is the right thing to do.
>
> I am writing an SPI protocol driver and I find that my driver
> is never probed.
>
> I tried to add and call to of_register_spi_devices() in the
> drivers/spi/mpc52xx_psc_spi.c::mpc52xx_psc_spi_of_probe() function,
> without much effect besided that the DTS node is parsed but the driver pr=
obe
> is not called, actually it complains about a modalias for my node is
> missing.

What do you see when you look in /sys/bus/spi/devices?  You should see
a directory for your device.  What do you see in /sys/bus/spi/drivers?
 In here you should see your driver.  If they are both there, then you
just have a problem matching your driver name to the device name.

g.

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-06-15 17:31         ` Grant Likely
@ 2009-06-16 10:41           ` Kári Davíðsson
  0 siblings, 0 replies; 12+ messages in thread
From: Kári Davíðsson @ 2009-06-16 10:41 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

Now my driver gets probed.

This "modalias" error was due to wrong "compatible" attribute of
my of node.

But I still need to have the call to of_register_spi_devices().

The attached patch shows what I mean.

rg
kd

Grant Likely wrote:
> On Mon, Jun 15, 2009 at 10:36 AM, Kári
> Davíðsson<kari.davidsson@marel.com> wrote:
>> Is this true?
>>
>> Grant Likely wrote:
>>> Yes, this is right.  The psc_spi driver automatically registers all
>>> spi children that it finds in the device tree onto the SPI bus.
>>> Therefore registering an spi_driver() is the right thing to do.
>> I am writing an SPI protocol driver and I find that my driver
>> is never probed.
>>
>> I tried to add and call to of_register_spi_devices() in the
>> drivers/spi/mpc52xx_psc_spi.c::mpc52xx_psc_spi_of_probe() function,
>> without much effect besided that the DTS node is parsed but the driver probe
>> is not called, actually it complains about a modalias for my node is
>> missing.
> 
> What do you see when you look in /sys/bus/spi/devices?  You should see
> a directory for your device.  What do you see in /sys/bus/spi/drivers?
>  In here you should see your driver.  If they are both there, then you
> just have a problem matching your driver name to the device name.
> 
> g.
> 

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1677 bytes --]

Index: drivers/spi/mpc52xx_psc_spi.c
===================================================================
--- drivers/spi/mpc52xx_psc_spi.c	(revision 548)
+++ drivers/spi/mpc52xx_psc_spi.c	(working copy)
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/spi/spi.h>
 #include <linux/fsl_devices.h>
+#include <linux/of_spi.h>
 
 #include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
@@ -371,7 +372,7 @@
 
 /* bus_num is used only for the case dev->platform_data == NULL */
 static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
-				u32 size, unsigned int irq, s16 bus_num)
+				u32 size, unsigned int irq, s16 bus_num, struct spi_master ** pmaster)
 {
 	struct fsl_spi_platform_data *pdata = dev->platform_data;
 	struct mpc52xx_psc_spi *mps;
@@ -439,6 +440,10 @@
 	if (ret < 0)
 		goto unreg_master;
 
+    dev_info(dev, "Activated\n");
+
+    *pmaster = master;
+
 	return ret;
 
 unreg_master:
@@ -474,6 +479,8 @@
 	const u32 *regaddr_p;
 	u64 regaddr64, size64;
 	s16 id = -1;
+    int res;
+    struct spi_master * master = NULL;;
 
 	regaddr_p = of_get_address(op->node, 0, &size64, NULL);
 	if (!regaddr_p) {
@@ -495,8 +502,16 @@
 		id = *psc_nump + 1;
 	}
 
-	return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
-					irq_of_parse_and_map(op->node, 0), id);
+	res = mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
+					irq_of_parse_and_map(op->node, 0), id, &master);
+
+    if( master != NULL )
+    {
+        /* Add any subnodes on the SPI bus */
+        of_register_spi_devices( master, op->node);
+    }
+
+    return res;
 }
 
 static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-02-13 15:19     ` Grant Likely
  2009-02-13 15:52       ` Henk Stegeman
  2009-06-15 16:36       ` Kári Davíðsson
@ 2009-07-07 14:31       ` Henk Stegeman
  2009-07-07 15:57         ` Grant Likely
  2 siblings, 1 reply; 12+ messages in thread
From: Henk Stegeman @ 2009-07-07 14:31 UTC (permalink / raw)
  To: Grant Likely, linuxppc-dev

I tried to make use of the irq-controller mode of the GPT as
suggested, however I'm not getting the IRQ.
Does anyone have an idea what I could be missing? (I've been testing
with 2.6.30).


The driver reports from it's probe:
[    1.502853] spi_master spi32766.0 Unable to get sample IRQ from of

My driver has:
	pdata->sample_irq =3D irq_of_parse_and_map(np, 0);
	if (pdata->sample_irq =3D=3D NO_IRQ) {
		ret =3D pdata->sample_irq;
		dev_err(dev, "Unable to get sample IRQ from of\n");
                ..
                }


My dts has:
	gpt6: timer@660 {	// General Purpose Timer GPT6 in GPIO mode for
SMC4000IO sample irq.
		interrupt-controller;
		#interrupt-cells =3D <1>;
		compatible =3D "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
		reg =3D <0x660 0x10>;
		interrupts =3D <1 15 0>;
		interrupt-parent =3D <&mpc5200_pic>;
	};


	io-controller@0 {
		compatible =3D "microkey,smc4000io";
		linux,modalias =3D "of_smc4000io";
		spi-max-frequency =3D <800000>;
		spi-cpha;
		reg =3D <0>;
		word-delay-us =3D <30>;
		interrupt-controller =3D <&gpt6>; // Use GPT6 as the IRQ controller
		interrupts =3D <2>; // And make it edge falling
	};


Thanks in advance,

Henk.

On Fri, Feb 13, 2009 at 5:19 PM, Grant Likely<grant.likely@secretlab.ca> wr=
ote:
> On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman@gmail.com> =
wrote:
>> 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 out=
put
>> to the CPU.
>> My idea is to add it as a gpios property in the slave device's
>> configuration:
>>
>> =A0 =A0 =A0 =A0 spi@2400 { =A0 =A0 =A0 =A0// PSC3 (SPI IF to the IO-cont=
roller )
>> =A0 =A0 =A0 =A0 =A0 =A0 device_type =3D "spi";
>> =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>;
>> =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc5200-psc-spi","fsl,mpc520=
0b-psc-spi";
>> =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <2>;
>> =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x2400 0x100>;
>> =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <2 3 0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&mpc5200_pic>;
>> =A0 =A0 =A0 =A0 =A0 =A0 gpios =3D <&gpt4 0 0>;
>>
>> =A0 =A0 =A0 =A0 =A0 =A0 io-controller@0 {
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "microkey,smc4000io";
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 spi-max-frequency =3D <1000000>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // gpios: first is IRQ to cpu
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gpios =3D <&gpt6 0 0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 };
>
> There is a better way to do this, and driver support for it is
> currently merged into Ben Herrenschmidt's -next tree.
>
> Do this instead:
> =A0 =A0 =A0 =A0io-controller@0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "microkey,smc4000io";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-max-frequency =3D <1000000>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller =3D < &gpt6 >; =A0 =
=A0 // Use GPT6 as
> the IRQ controller
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D < 1 >; =A0 =A0// And make i=
t rising edge.
> =A0 =A0 =A0 =A0};
>
> Then add these two properties to the GPT node:
>
> =A0 =A0 =A0 =A0interrupt-controller;
> =A0 =A0 =A0 =A0#interrupt-cells =3D <1>;
>
> Then you can use normal irq_of_parse_and_map() to set up your handler.
>
>> How should I then register my spi slave driver? My smc4000io_probe funct=
ion
>> gets called correctly by of_spi support but when I register as follows:
>>
>> static struct spi_driver smc4000io_driver =3D {
>> =A0 =A0 .driver =3D {
>> =A0 =A0 =A0 =A0 .name =A0 =A0=3D "smc4000io",
>> =A0 =A0 =A0 =A0 .bus =A0 =A0=3D &spi_bus_type,
>> =A0 =A0 =A0 =A0 .owner =A0 =A0=3D THIS_MODULE,
>> =A0 =A0 },
>> =A0 =A0 .probe =A0 =A0 =A0 =A0=3D smc4000io_probe,
>> =A0 =A0 .remove =A0 =A0 =A0 =A0=3D __devexit_p(smc4000io_remove),
>> };
>>
>> static int __init smc4000io_init(void)
>> {
>> =A0 =A0 return spi_register_driver(&smc4000io_driver);
>> }
>>
>> static void __exit smc4000io_exit(void)
>> {
>> =A0 =A0 spi_unregister_driver(&smc4000io_driver);
>> }
>>
>> module_init(smc4000io_init);
>
> Yes, this is right. =A0The psc_spi driver automatically registers all
> spi children that it finds in the device tree onto the SPI bus.
> Therefore registering an spi_driver() is the right thing to do.
>
>> But when I do:
>>
>> static struct of_platform_driver smc4000_spi_of_driver =3D {
>> =A0 =A0 .name =3D "smc4000io",
>> =A0 =A0 .match_table =3D smc4000io_of_match,
>> =A0 =A0 .probe =3D smc4000io_of_probe,
>> =A0 =A0 .remove =A0 =A0 =A0 =A0=3D __devexit_p(smc4000io_of_remove),
>> };
>>
>> static int __init smc4000io_init(void)
>> {
>> =A0 =A0 return of_register_platform_driver(&smc4000_spi_of_driver);
>> }
>> module_init(smc4000io_init);
>>
>> Then my smc4000io_of_probe function never gets called.
>
> Correct. =A0of_platform_driver isn't useful in this case because the
> device cannot exist independently of the SPI bus. =A0Plus an
> of_platform_device doesn't provide any information about the SPI bus
> itself.
>
> g.
>
> --
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-07-07 14:31       ` Henk Stegeman
@ 2009-07-07 15:57         ` Grant Likely
  2009-07-08 13:07           ` Henk Stegeman
  0 siblings, 1 reply; 12+ messages in thread
From: Grant Likely @ 2009-07-07 15:57 UTC (permalink / raw)
  To: Henk Stegeman; +Cc: linuxppc-dev

On Tue, Jul 7, 2009 at 8:31 AM, Henk Stegeman<henk.stegeman@gmail.com> wrot=
e:
> I tried to make use of the irq-controller mode of the GPT as
> suggested, however I'm not getting the IRQ.
> Does anyone have an idea what I could be missing? (I've been testing
> with 2.6.30).

Make sure the 5200 general purpose timer driver is compiled in (not a modul=
e).

>
>
> The driver reports from it's probe:
> [ =A0 =A01.502853] spi_master spi32766.0 Unable to get sample IRQ from of
>
> My driver has:
> =A0 =A0 =A0 =A0pdata->sample_irq =3D irq_of_parse_and_map(np, 0);
> =A0 =A0 =A0 =A0if (pdata->sample_irq =3D=3D NO_IRQ) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D pdata->sample_irq;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_err(dev, "Unable to get sample IRQ fro=
m of\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0..
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
>
>
> My dts has:
> =A0 =A0 =A0 =A0gpt6: timer@660 { =A0 =A0 =A0 // General Purpose Timer GPT=
6 in GPIO mode for
> SMC4000IO sample irq.
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#interrupt-cells =3D <1>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "fsl,mpc5200b-gpt","fsl,mpc=
5200-gpt";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x660 0x10>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <1 15 0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpc5200_pic>;
> =A0 =A0 =A0 =A0};
>
>
> =A0 =A0 =A0 =A0io-controller@0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "microkey,smc4000io";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0linux,modalias =3D "of_smc4000io";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-max-frequency =3D <800000>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-cpha;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0word-delay-us =3D <30>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller =3D <&gpt6>; // Use G=
PT6 as the IRQ controller
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <2>; // And make it edge fa=
lling
> =A0 =A0 =A0 =A0};
>
>
> Thanks in advance,
>
> Henk.
>
> On Fri, Feb 13, 2009 at 5:19 PM, Grant Likely<grant.likely@secretlab.ca> =
wrote:
>> On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman@gmail.com>=
 wrote:
>>> 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 ou=
tput
>>> to the CPU.
>>> My idea is to add it as a gpios property in the slave device's
>>> configuration:
>>>
>>> =A0 =A0 =A0 =A0 spi@2400 { =A0 =A0 =A0 =A0// PSC3 (SPI IF to the IO-con=
troller )
>>> =A0 =A0 =A0 =A0 =A0 =A0 device_type =3D "spi";
>>> =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc5200-psc-spi","fsl,mpc52=
00b-psc-spi";
>>> =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <2>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x2400 0x100>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <2 3 0>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&mpc5200_pic>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 gpios =3D <&gpt4 0 0>;
>>>
>>> =A0 =A0 =A0 =A0 =A0 =A0 io-controller@0 {
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "microkey,smc4000io";
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 spi-max-frequency =3D <1000000>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // gpios: first is IRQ to cpu
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gpios =3D <&gpt6 0 0>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 };
>>
>> There is a better way to do this, and driver support for it is
>> currently merged into Ben Herrenschmidt's -next tree.
>>
>> Do this instead:
>> =A0 =A0 =A0 =A0io-controller@0 {
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "microkey,smc4000io";
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-max-frequency =3D <1000000>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller =3D < &gpt6 >; =A0 =
=A0 // Use GPT6 as
>> the IRQ controller
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D < 1 >; =A0 =A0// And make =
it rising edge.
>> =A0 =A0 =A0 =A0};
>>
>> Then add these two properties to the GPT node:
>>
>> =A0 =A0 =A0 =A0interrupt-controller;
>> =A0 =A0 =A0 =A0#interrupt-cells =3D <1>;
>>
>> Then you can use normal irq_of_parse_and_map() to set up your handler.
>>
>>> How should I then register my spi slave driver? My smc4000io_probe func=
tion
>>> gets called correctly by of_spi support but when I register as follows:
>>>
>>> static struct spi_driver smc4000io_driver =3D {
>>> =A0 =A0 .driver =3D {
>>> =A0 =A0 =A0 =A0 .name =A0 =A0=3D "smc4000io",
>>> =A0 =A0 =A0 =A0 .bus =A0 =A0=3D &spi_bus_type,
>>> =A0 =A0 =A0 =A0 .owner =A0 =A0=3D THIS_MODULE,
>>> =A0 =A0 },
>>> =A0 =A0 .probe =A0 =A0 =A0 =A0=3D smc4000io_probe,
>>> =A0 =A0 .remove =A0 =A0 =A0 =A0=3D __devexit_p(smc4000io_remove),
>>> };
>>>
>>> static int __init smc4000io_init(void)
>>> {
>>> =A0 =A0 return spi_register_driver(&smc4000io_driver);
>>> }
>>>
>>> static void __exit smc4000io_exit(void)
>>> {
>>> =A0 =A0 spi_unregister_driver(&smc4000io_driver);
>>> }
>>>
>>> module_init(smc4000io_init);
>>
>> Yes, this is right. =A0The psc_spi driver automatically registers all
>> spi children that it finds in the device tree onto the SPI bus.
>> Therefore registering an spi_driver() is the right thing to do.
>>
>>> But when I do:
>>>
>>> static struct of_platform_driver smc4000_spi_of_driver =3D {
>>> =A0 =A0 .name =3D "smc4000io",
>>> =A0 =A0 .match_table =3D smc4000io_of_match,
>>> =A0 =A0 .probe =3D smc4000io_of_probe,
>>> =A0 =A0 .remove =A0 =A0 =A0 =A0=3D __devexit_p(smc4000io_of_remove),
>>> };
>>>
>>> static int __init smc4000io_init(void)
>>> {
>>> =A0 =A0 return of_register_platform_driver(&smc4000_spi_of_driver);
>>> }
>>> module_init(smc4000io_init);
>>>
>>> Then my smc4000io_of_probe function never gets called.
>>
>> Correct. =A0of_platform_driver isn't useful in this case because the
>> device cannot exist independently of the SPI bus. =A0Plus an
>> of_platform_device doesn't provide any information about the SPI bus
>> itself.
>>
>> g.
>>
>> --
>> Grant Likely, B.Sc., P.Eng.
>> Secret Lab Technologies Ltd.
>>
>



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
  2009-07-07 15:57         ` Grant Likely
@ 2009-07-08 13:07           ` Henk Stegeman
  0 siblings, 0 replies; 12+ messages in thread
From: Henk Stegeman @ 2009-07-08 13:07 UTC (permalink / raw)
  To: linuxppc-dev

It now works, in the dts

interrupt-controller =3D < &gpt6 >;     // Use GPT6 as

should have been

interrupt-parent =3D < &gpt6 >;     // Use GPT6 as

On Tue, Jul 7, 2009 at 5:57 PM, Grant Likely<grant.likely@secretlab.ca> wro=
te:
> On Tue, Jul 7, 2009 at 8:31 AM, Henk Stegeman<henk.stegeman@gmail.com> wr=
ote:
>> I tried to make use of the irq-controller mode of the GPT as
>> suggested, however I'm not getting the IRQ.
>> Does anyone have an idea what I could be missing? (I've been testing
>> with 2.6.30).
>
> Make sure the 5200 general purpose timer driver is compiled in (not a mod=
ule).
>
>>
>>
>> The driver reports from it's probe:
>> [ =A0 =A01.502853] spi_master spi32766.0 Unable to get sample IRQ from o=
f
>>
>> My driver has:
>> =A0 =A0 =A0 =A0pdata->sample_irq =3D irq_of_parse_and_map(np, 0);
>> =A0 =A0 =A0 =A0if (pdata->sample_irq =3D=3D NO_IRQ) {
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D pdata->sample_irq;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_err(dev, "Unable to get sample IRQ fr=
om of\n");
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0..
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
>>
>>
>> My dts has:
>> =A0 =A0 =A0 =A0gpt6: timer@660 { =A0 =A0 =A0 // General Purpose Timer GP=
T6 in GPIO mode for
>> SMC4000IO sample irq.
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#interrupt-cells =3D <1>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "fsl,mpc5200b-gpt","fsl,mp=
c5200-gpt";
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x660 0x10>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <1 15 0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpc5200_pic>;
>> =A0 =A0 =A0 =A0};
>>
>>
>> =A0 =A0 =A0 =A0io-controller@0 {
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "microkey,smc4000io";
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0linux,modalias =3D "of_smc4000io";
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-max-frequency =3D <800000>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-cpha;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0word-delay-us =3D <30>;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller =3D <&gpt6>; // Use =
GPT6 as the IRQ controller
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <2>; // And make it edge f=
alling
>> =A0 =A0 =A0 =A0};
>>
>>
>> Thanks in advance,
>>
>> Henk.
>>
>> On Fri, Feb 13, 2009 at 5:19 PM, Grant Likely<grant.likely@secretlab.ca>=
 wrote:
>>> On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman@gmail.com=
> wrote:
>>>> 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 o=
utput
>>>> to the CPU.
>>>> My idea is to add it as a gpios property in the slave device's
>>>> configuration:
>>>>
>>>> =A0 =A0 =A0 =A0 spi@2400 { =A0 =A0 =A0 =A0// PSC3 (SPI IF to the IO-co=
ntroller )
>>>> =A0 =A0 =A0 =A0 =A0 =A0 device_type =3D "spi";
>>>> =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc5200-psc-spi","fsl,mpc5=
200b-psc-spi";
>>>> =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <2>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x2400 0x100>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <2 3 0>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&mpc5200_pic>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 gpios =3D <&gpt4 0 0>;
>>>>
>>>> =A0 =A0 =A0 =A0 =A0 =A0 io-controller@0 {
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "microkey,smc4000io";
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 spi-max-frequency =3D <1000000>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // gpios: first is IRQ to cpu
>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gpios =3D <&gpt6 0 0>;
>>>> =A0 =A0 =A0 =A0 =A0 =A0 };
>>>
>>> There is a better way to do this, and driver support for it is
>>> currently merged into Ben Herrenschmidt's -next tree.
>>>
>>> Do this instead:
>>> =A0 =A0 =A0 =A0io-controller@0 {
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "microkey,smc4000io";
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spi-max-frequency =3D <1000000>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0>;
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-controller =3D < &gpt6 >; =A0 =
=A0 // Use GPT6 as
>>> the IRQ controller
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D < 1 >; =A0 =A0// And make=
 it rising edge.
>>> =A0 =A0 =A0 =A0};
>>>
>>> Then add these two properties to the GPT node:
>>>
>>> =A0 =A0 =A0 =A0interrupt-controller;
>>> =A0 =A0 =A0 =A0#interrupt-cells =3D <1>;
>>>
>>> Then you can use normal irq_of_parse_and_map() to set up your handler.
>>>
>>>> How should I then register my spi slave driver? My smc4000io_probe fun=
ction
>>>> gets called correctly by of_spi support but when I register as follows=
:
>>>>
>>>> static struct spi_driver smc4000io_driver =3D {
>>>> =A0 =A0 .driver =3D {
>>>> =A0 =A0 =A0 =A0 .name =A0 =A0=3D "smc4000io",
>>>> =A0 =A0 =A0 =A0 .bus =A0 =A0=3D &spi_bus_type,
>>>> =A0 =A0 =A0 =A0 .owner =A0 =A0=3D THIS_MODULE,
>>>> =A0 =A0 },
>>>> =A0 =A0 .probe =A0 =A0 =A0 =A0=3D smc4000io_probe,
>>>> =A0 =A0 .remove =A0 =A0 =A0 =A0=3D __devexit_p(smc4000io_remove),
>>>> };
>>>>
>>>> static int __init smc4000io_init(void)
>>>> {
>>>> =A0 =A0 return spi_register_driver(&smc4000io_driver);
>>>> }
>>>>
>>>> static void __exit smc4000io_exit(void)
>>>> {
>>>> =A0 =A0 spi_unregister_driver(&smc4000io_driver);
>>>> }
>>>>
>>>> module_init(smc4000io_init);
>>>
>>> Yes, this is right. =A0The psc_spi driver automatically registers all
>>> spi children that it finds in the device tree onto the SPI bus.
>>> Therefore registering an spi_driver() is the right thing to do.
>>>
>>>> But when I do:
>>>>
>>>> static struct of_platform_driver smc4000_spi_of_driver =3D {
>>>> =A0 =A0 .name =3D "smc4000io",
>>>> =A0 =A0 .match_table =3D smc4000io_of_match,
>>>> =A0 =A0 .probe =3D smc4000io_of_probe,
>>>> =A0 =A0 .remove =A0 =A0 =A0 =A0=3D __devexit_p(smc4000io_of_remove),
>>>> };
>>>>
>>>> static int __init smc4000io_init(void)
>>>> {
>>>> =A0 =A0 return of_register_platform_driver(&smc4000_spi_of_driver);
>>>> }
>>>> module_init(smc4000io_init);
>>>>
>>>> Then my smc4000io_of_probe function never gets called.
>>>
>>> Correct. =A0of_platform_driver isn't useful in this case because the
>>> device cannot exist independently of the SPI bus. =A0Plus an
>>> of_platform_device doesn't provide any information about the SPI bus
>>> itself.
>>>
>>> g.
>>>
>>> --
>>> Grant Likely, B.Sc., P.Eng.
>>> Secret Lab Technologies Ltd.
>>>
>>
>
>
>
> --
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Chipselect in SPI binding with mpc5200-psc-spi
@ 2009-03-27 21:14 Yann Pelletier
  0 siblings, 0 replies; 12+ messages in thread
From: Yann Pelletier @ 2009-03-27 21:14 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 3612 bytes --]


I'm trying to do the same sort of thing


On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman at gmail.com<https://ozlabs.org/mailman/listinfo/linuxppc-dev>> wrote:
> 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 at 2400<https://ozlabs.org/mailman/listinfo/linuxppc-dev> {        // 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 at 0<https://ozlabs.org/mailman/listinfo/linuxppc-dev> {
>                 compatible = "microkey,smc4000io";
>                 spi-max-frequency = <1000000>;
>                 reg = <0>;
>                 // gpios: first is IRQ to cpu
>                 gpios = <&gpt6 0 0>;
>             };

There is a better way to do this, and driver support for it is
currently merged into Ben Herrenschmidt's -next tree.

Do this instead:
        io-controller at 0<https://ozlabs.org/mailman/listinfo/linuxppc-dev> {
                compatible = "microkey,smc4000io";
                spi-max-frequency = <1000000>;
                reg = <0>;
                interrupt-controller = < &gpt6 >;     // Use GPT6 as
the IRQ controller
                interrupts = < 1 >;    // And make it rising edge.
        };

Then add these two properties to the GPT node:

        interrupt-controller;
        #interrupt-cells = <1>;

Then you can use normal irq_of_parse_and_map() to set up your handler.

> 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);

Yes, this is right.  The psc_spi driver automatically registers all
spi children that it finds in the device tree onto the SPI bus.
Therefore registering an spi_driver() is the right thing to do.

> 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.

Correct.  of_platform_driver isn't useful in this case because the
device cannot exist independently of the SPI bus.  Plus an
of_platform_device doesn't provide any information about the SPI bus
itself.

g.

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


[-- Attachment #2: Type: text/html, Size: 28370 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-07-08 13:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-29 13:43 Chipselect in SPI binding with mpc5200-psc-spi Henk Stegeman
2008-10-29 14:45 ` Grant Likely
2009-02-13 10:40   ` Henk Stegeman
2009-02-13 15:19     ` Grant Likely
2009-02-13 15:52       ` Henk Stegeman
2009-06-15 16:36       ` Kári Davíðsson
2009-06-15 17:31         ` Grant Likely
2009-06-16 10:41           ` Kári Davíðsson
2009-07-07 14:31       ` Henk Stegeman
2009-07-07 15:57         ` Grant Likely
2009-07-08 13:07           ` Henk Stegeman
2009-03-27 21:14 Yann Pelletier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.