linuxppc-dev.lists.ozlabs.org archive mirror
 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
@ 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@ozlabs.org

[-- 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
  -- strict thread matches above, loose matches on Subject: below --
2009-03-27 21:14 Yann Pelletier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).