Re: Chipselect in SPI binding with mpc5200-psc-spi
It now works, in the dts interrupt-controller = gpt6 ; // Use GPT6 as should have been interrupt-parent = gpt6 ; // Use GPT6 as On Tue, Jul 7, 2009 at 5:57 PM, Grant Likelygrant.lik...@secretlab.ca wrote: On Tue, Jul 7, 2009 at 8:31 AM, Henk Stegemanhenk.stege...@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: ti...@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-control...@0 { compatible = microkey,smc4000io; linux,modalias = of_smc4000io; spi-max-frequency = 80; 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 Likelygrant.lik...@secretlab.ca wrote: On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman henk.stege...@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: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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.
Re: Chipselect in SPI binding with mpc5200-psc-spi
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 = 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: ti...@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-control...@0 { compatible = microkey,smc4000io; linux,modalias = of_smc4000io; spi-max-frequency = 80; 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 Likelygrant.lik...@secretlab.ca wrote: On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman henk.stege...@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: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
On Tue, Jul 7, 2009 at 8:31 AM, Henk Stegemanhenk.stege...@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: ti...@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-control...@0 { compatible = microkey,smc4000io; linux,modalias = of_smc4000io; spi-max-frequency = 80; 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 Likelygrant.lik...@secretlab.ca wrote: On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman henk.stege...@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: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
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íðssonkari.davids...@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. 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) ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
On Mon, Jun 15, 2009 at 10:36 AM, Kári Davíðssonkari.davids...@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. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
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.comhttps://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 2400https://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 0https://ozlabs.org/mailman/listinfo/linuxppc-dev { compatible = microkey,smc4000io; spi-max-frequency = 100; 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 0https://ozlabs.org/mailman/listinfo/linuxppc-dev { compatible = microkey,smc4000io; spi-max-frequency = 100; 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. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
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: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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.lik...@secretlab.cawrote: On Wed, Oct 29, 2008 at 7:43 AM, Henk Stegeman henk.stege...@gmail.com wrote: .. .. In my dts I have my chipselect defined as follows: gpt4: ti...@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 /soc5...@f000/ti...@640 The spi controller is defined like this: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; reg = 0; }; }; At bootup linux (2.6.27) reports: mpc52xx-psc-spi f960.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. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman henk.stege...@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: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
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.lik...@secretlab.cawrote: On Fri, Feb 13, 2009 at 3:40 AM, Henk Stegeman henk.stege...@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: s...@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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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-control...@0 { compatible = microkey,smc4000io; spi-max-frequency = 100; 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. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Chipselect in SPI binding with mpc5200-psc-spi
On Wed, Oct 29, 2008 at 7:43 AM, Henk Stegeman [EMAIL PROTECTED] wrote: .. .. In my dts I have my chipselect defined as follows: gpt4: [EMAIL PROTECTED] {// 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 /[EMAIL PROTECTED]/[EMAIL PROTECTED] The spi controller is defined like this: [EMAIL PROTECTED] { 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; [EMAIL PROTECTED] { compatible = microkey,smc4000io; spi-max-frequency = 100; reg = 0; }; }; At bootup linux (2.6.27) reports: mpc52xx-psc-spi f960.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. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev