Thanks Greg,<br><br>I'm having success more success with the driver now,<br><br>The device gets nicely probed and the probe function gets the properties from the device tree,<br><br>The following patch from Anton Vorontsov:<br>
<br><a href="http://kerneltrap.org/mailarchive/linux-kernel/2008/5/23/1922744">http://kerneltrap.org/mailarchive/linux-kernel/2008/5/23/1922744</a><br><br>Was very useful as example for adding the of support to my 'own' spi slave driver.<br>
<br>(Thanks Anton,)<br><br>Henk.<br><br><div class="gmail_quote">On Fri, Feb 13, 2009 at 4:19 PM, Grant Likely <span dir="ltr"><<a href="mailto:grant.likely@secretlab.ca">grant.likely@secretlab.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman <<a href="mailto:henk.stegeman@gmail.com">henk.stegeman@gmail.com</a>> wrote:<br>
> I'm busy adding support for slave deviced behind mpc52xx-psc-spi.<br>
> One complication I have is that my SPI slave device has an interrupt output<br>
> to the CPU.<br>
> My idea is to add it as a gpios property in the slave device's<br>
> configuration:<br>
><br>
> spi@2400 { // PSC3 (SPI IF to the IO-controller )<br>
> device_type = "spi";<br>
> #address-cells = <1>;<br>
> #size-cells = <0>;<br>
> compatible = "fsl,mpc5200-psc-spi","fsl,mpc5200b-psc-spi";<br>
> cell-index = <2>;<br>
> reg = <0x2400 0x100>;<br>
> interrupts = <2 3 0>;<br>
> interrupt-parent = <&mpc5200_pic>;<br>
> gpios = <&gpt4 0 0>;<br>
><br>
> io-controller@0 {<br>
> compatible = "microkey,smc4000io";<br>
> spi-max-frequency = <1000000>;<br>
> reg = <0>;<br>
> // gpios: first is IRQ to cpu<br>
> gpios = <&gpt6 0 0>;<br>
> };<br>
<br>
</div>There is a better way to do this, and driver support for it is<br>
currently merged into Ben Herrenschmidt's -next tree.<br>
<br>
Do this instead:<br>
<div class="Ih2E3d"> io-controller@0 {<br>
compatible = "microkey,smc4000io";<br>
spi-max-frequency = <1000000>;<br>
reg = <0>;<br>
</div> interrupt-controller = < &gpt6 >; // Use GPT6 as<br>
the IRQ controller<br>
interrupts = < 1 >; // And make it rising edge.<br>
};<br>
<br>
Then add these two properties to the GPT node:<br>
<br>
interrupt-controller;<br>
#interrupt-cells = <1>;<br>
<br>
Then you can use normal irq_of_parse_and_map() to set up your handler.<br>
<div class="Ih2E3d"><br>
> How should I then register my spi slave driver? My smc4000io_probe function<br>
> gets called correctly by of_spi support but when I register as follows:<br>
><br>
> static struct spi_driver smc4000io_driver = {<br>
> .driver = {<br>
> .name = "smc4000io",<br>
> .bus = &spi_bus_type,<br>
> .owner = THIS_MODULE,<br>
> },<br>
> .probe = smc4000io_probe,<br>
> .remove = __devexit_p(smc4000io_remove),<br>
> };<br>
><br>
> static int __init smc4000io_init(void)<br>
> {<br>
> return spi_register_driver(&smc4000io_driver);<br>
> }<br>
><br>
> static void __exit smc4000io_exit(void)<br>
> {<br>
> spi_unregister_driver(&smc4000io_driver);<br>
> }<br>
><br>
> module_init(smc4000io_init);<br>
<br>
</div>Yes, this is right. The psc_spi driver automatically registers all<br>
spi children that it finds in the device tree onto the SPI bus.<br>
Therefore registering an spi_driver() is the right thing to do.<br>
<div class="Ih2E3d"><br>
> But when I do:<br>
><br>
> static struct of_platform_driver smc4000_spi_of_driver = {<br>
> .name = "smc4000io",<br>
> .match_table = smc4000io_of_match,<br>
> .probe = smc4000io_of_probe,<br>
> .remove = __devexit_p(smc4000io_of_remove),<br>
> };<br>
><br>
> static int __init smc4000io_init(void)<br>
> {<br>
> return of_register_platform_driver(&smc4000_spi_of_driver);<br>
> }<br>
> module_init(smc4000io_init);<br>
><br>
> Then my smc4000io_of_probe function never gets called.<br>
<br>
</div>Correct. of_platform_driver isn't useful in this case because the<br>
device cannot exist independently of the SPI bus. Plus an<br>
of_platform_device doesn't provide any information about the SPI bus<br>
itself.<br>
<div><div></div><div class="Wj3C7c"><br>
g.<br>
<br>
--<br>
Grant Likely, B.Sc., P.Eng.<br>
Secret Lab Technologies Ltd.<br>
</div></div></blockquote></div><br>