Hi Alan,

thanks for your answer and sorry for my late replay.

> In your case though, It would be better to make it configurable in the
> driver rather than just being hard-coded to something other than the
> default (because this patch will break code which has it already working
> the default way). I'd recommend adding it to the platform data in
> include/linux/spi/at86rf230.h .

If I understand you right, you suggest to add the irq type setup to the
rf230 driver but make it configurable from the platform driver. I changed
the patch to use the platform data to configure the irq type. When the
irq type is not set in the platform data the rf230 driver won't call the
irq_set_irq_type() function.

Is this what you suggested? :

diff --git a/drivers/net/ieee802154/at86rf230.c 
b/drivers/net/ieee802154/at86rf230.c
index a4a62e1..369299b 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -31,13 +31,14 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/at86rf230.h>
 #include <linux/skbuff.h>
+#include <linux/irq.h>
 
 #include <net/mac802154.h>
 #include <net/wpan-phy.h>
 
 struct at86rf230_local {
        struct spi_device *spi;
-       int rstn, slp_tr, dig2;
+       int rstn, slp_tr, dig2, irq_type;
 
        u8 part;
        u8 vers;
@@ -774,6 +775,7 @@ static int at86rf230_fill_data(struct spi_device *spi)
        lp->rstn = pdata->rstn;
        lp->slp_tr = pdata->slp_tr;
        lp->dig2 = pdata->dig2;
+       lp->irq_type = pdata->irq_type;
 
        return 0;
 }
@@ -892,6 +894,12 @@ static int at86rf230_probe(struct spi_device *spi)
        if (rc)
                goto err_gpio_dir;
 
+       if (lp->irq_type) {
+               rc = irq_set_irq_type(spi->irq, lp->irq_type);
+               if (rc)
+                       goto err_gpio_dir;
+       }
+
        rc = request_irq(spi->irq, at86rf230_isr, IRQF_SHARED,
                         dev_name(&spi->dev), lp);
        if (rc)
diff --git a/include/linux/spi/at86rf230.h b/include/linux/spi/at86rf230.h
index b2b1afb..f4a06d8 100644
--- a/include/linux/spi/at86rf230.h
+++ b/include/linux/spi/at86rf230.h
@@ -26,6 +26,7 @@ struct at86rf230_platform_data {
        int rstn;
        int slp_tr;
        int dig2;
+       int irq_type;
 };
 
 #endif



Thanks,
Sascha


On 01/23/2013 06:03 PM, Alan Ott wrote:

> On 01/15/2013 06:45 PM, Sascha Herrmann wrote:
>> Hi,
>>
>> I managed to connect the rf230 chip (using one Module from the Atmel
>> RZ600 Kit) to an Raspberry Pi with some success. One problem I had
>> with this, is that GPIO Interrupt for the rf230 must be set to
>> IRQ_TYPE_EDGE_RISING. Without setting the type the bcm2708 GPIO code
>> doesn't activate the interrupt.
>>
>> My question is, where is the correct place to setup this interrupt
>> type? At the moment I think the right place would be the probe function
>> of the at86rf230 driver, since the driver has the knowledge, that the
>> interrupt handler should be called with the rising edge of the signal.
>> I added a patch below, showing how I modified the driver. Do you think,
>> that is the right way to do this, or should this setup go somewhere
>> else?
>>
>> diff --git a/drivers/net/ieee802154/at86rf230.c 
>> b/drivers/net/ieee802154/at86rf230.c
>> index a4a62e1..fb1a108 100644
>> --- a/drivers/net/ieee802154/at86rf230.c
>> +++ b/drivers/net/ieee802154/at86rf230.c
>> @@ -31,6 +31,7 @@
>>  #include <linux/spi/spi.h>
>>  #include <linux/spi/at86rf230.h>
>>  #include <linux/skbuff.h>
>> +#include <linux/irq.h>
>>  
>>  #include <net/mac802154.h>
>>  #include <net/wpan-phy.h>
>> @@ -892,6 +893,10 @@ static int at86rf230_probe(struct spi_device *spi)
>>      if (rc)
>>              goto err_gpio_dir;
>>  
>> +    rc = irq_set_irq_type(spi->irq, IRQ_TYPE_EDGE_RISING);
>> +    if (rc)
>> +            goto err_gpio_dir;
>> +
>>      rc = request_irq(spi->irq, at86rf230_isr, IRQF_SHARED,
>>                       dev_name(&spi->dev), lp);
>>      if (rc)
>>
> 
> Hi Sascha,
> 
> Typically the CPU/board side (board file or Device Tree) would be set up
> to handle the polarity of the interrupt that the device uses, as
> typically CPUs have more control than devices do. However, it can really
> be done both ways, configuring the device, or configuring the CPU.
> 
> In your case though, It would be better to make it configurable in the
> driver rather than just being hard-coded to something other than the
> default (because this patch will break code which has it already working
> the default way). I'd recommend adding it to the platform data in
> include/linux/spi/at86rf230.h .
> 
> Alan.
> 



------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to