Chipselect in SPI binding with mpc5200-psc-spi

Grant Likely grant.likely at secretlab.ca
Wed Jul 8 01:57:32 EST 2009


On Tue, Jul 7, 2009 at 8:31 AM, Henk Stegeman<henk.stegeman at gmail.com> wrote:
> 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 module).

>
>
> 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 = irq_of_parse_and_map(np, 0);
>        if (pdata->sample_irq == NO_IRQ) {
>                ret = pdata->sample_irq;
>                dev_err(dev, "Unable to get sample IRQ from of\n");
>                ..
>                }
>
>
> My dts has:
>        gpt6: timer at 660 {       // General Purpose Timer GPT6 in GPIO mode for
> SMC4000IO sample irq.
>                interrupt-controller;
>                #interrupt-cells = <1>;
>                compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
>                reg = <0x660 0x10>;
>                interrupts = <1 15 0>;
>                interrupt-parent = <&mpc5200_pic>;
>        };
>
>
>        io-controller at 0 {
>                compatible = "microkey,smc4000io";
>                linux,modalias = "of_smc4000io";
>                spi-max-frequency = <800000>;
>                spi-cpha;
>                reg = <0>;
>                word-delay-us = <30>;
>                interrupt-controller = <&gpt6>; // Use GPT6 as the IRQ controller
>                interrupts = <2>; // And make it edge falling
>        };
>
>
> Thanks in advance,
>
> Henk.
>
> On Fri, Feb 13, 2009 at 5:19 PM, Grant Likely<grant.likely at secretlab.ca> wrote:
>> On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <henk.stegeman at 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 at 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 at 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 at 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.
>>
>



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


More information about the Linuxppc-dev mailing list