linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* External interrupt on 460EX
@ 2008-10-15 14:43 Felix Radensky
  2008-10-15 15:00 ` Stefan Roese
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Radensky @ 2008-10-15 14:43 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

I'm running Linux 2.6.26 on custom board based on AMCC 460EX.
I'm trying to catch interrupt generated by CPLD, but without any luck.

The interrupt is connected to GPIO 45. U-Boot (1.3.4) configures this
pin as external interrupt 12 (interrupt 20 in UIC 3). I've added the 
following
entry to board device tree (in opb section)

cpld@2,0 {
    device_type = "cpld";
    interrupts = <20 1>;
    interrupt-parent = <&UIC3>;
};

In my driver I do the following:

    /* Find CPLD node in device tree */
    np = of_find_node_by_type(NULL, "cpld");
    if (!np) {
        printk(KERN_INFO "No CPLD found in device tree\n");
        return -1;
    }

    /* Get and map irq number from device tree */
    cpld_irq = irq_of_parse_and_map(np, 0);
    if (cpld_irq == NO_IRQ) {
        printk(KERN_ERR "irq_of_parse_and_map failed\n");
        of_node_put(np);
        return -ENODEV;
    }

    /* Register CPLD interrupt handler */
    rc = request_irq(cpld_irq, cpld_interrupt,
             IRQF_TRIGGER_LOW, "CPLD", NULL);

And I see this interrupt in /proc/interrups after loading
the driver. However interrupt handler is never invoked,
although hardware guys see that GPIO line goes down
when interrupt is generated.

What am I doing wrong ?

Thanks a lot in advance ?

Felix.



 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: External interrupt on 460EX
  2008-10-15 14:43 External interrupt on 460EX Felix Radensky
@ 2008-10-15 15:00 ` Stefan Roese
  2008-10-15 15:18   ` Felix Radensky
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2008-10-15 15:00 UTC (permalink / raw)
  To: linuxppc-embedded; +Cc: Felix Radensky

Felix,

On Wednesday 15 October 2008, Felix Radensky wrote:
> I'm running Linux 2.6.26 on custom board based on AMCC 460EX.
> I'm trying to catch interrupt generated by CPLD, but without any luck.
>
> The interrupt is connected to GPIO 45. U-Boot (1.3.4) configures this
> pin as external interrupt 12 (interrupt 20 in UIC 3). I've added the
> following
> entry to board device tree (in opb section)
>
> cpld@2,0 {
>     device_type = "cpld";
>     interrupts = <20 1>;

Is this interrupt active on rising edge? This is what you have configured 
here. When you need level, active low, then you need to write:

     interrupts = <20 8>;

And be careful which dts version you are using. Is this 20 decimal or hex?

>     interrupt-parent = <&UIC3>;
> };
>
> In my driver I do the following:
>
>     /* Find CPLD node in device tree */
>     np = of_find_node_by_type(NULL, "cpld");
>     if (!np) {
>         printk(KERN_INFO "No CPLD found in device tree\n");
>         return -1;
>     }
>
>     /* Get and map irq number from device tree */
>     cpld_irq = irq_of_parse_and_map(np, 0);
>     if (cpld_irq == NO_IRQ) {
>         printk(KERN_ERR "irq_of_parse_and_map failed\n");
>         of_node_put(np);
>         return -ENODEV;
>     }
>
>     /* Register CPLD interrupt handler */
>     rc = request_irq(cpld_irq, cpld_interrupt,
>              IRQF_TRIGGER_LOW, "CPLD", NULL);
>
> And I see this interrupt in /proc/interrups after loading
> the driver. However interrupt handler is never invoked,
> although hardware guys see that GPIO line goes down
> when interrupt is generated.
>
> What am I doing wrong ?

Another idea is that you didn't configure the pin multiplexing correctly. Most 
external IRQ's are shared with other functions and/or GPIO's. You need to 
configure the multiplexing correctly for external IRQ functionality. This is 
usually done in U-Boot with the CFG_4xx_GPIO_TABLE. 

I suggest you check here first.

Best regards,
Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: External interrupt on 460EX
  2008-10-15 15:00 ` Stefan Roese
@ 2008-10-15 15:18   ` Felix Radensky
  2008-10-16  7:44     ` Stefan Roese
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Radensky @ 2008-10-15 15:18 UTC (permalink / raw)
  To: Stefan Roese, linuxppc-embedded

Hi, Stefan

Stefan Roese wrote:
> Felix,
>
> On Wednesday 15 October 2008, Felix Radensky wrote:
>   
>> I'm running Linux 2.6.26 on custom board based on AMCC 460EX.
>> I'm trying to catch interrupt generated by CPLD, but without any luck.
>>
>> The interrupt is connected to GPIO 45. U-Boot (1.3.4) configures this
>> pin as external interrupt 12 (interrupt 20 in UIC 3). I've added the
>> following
>> entry to board device tree (in opb section)
>>
>> cpld@2,0 {
>>     device_type = "cpld";
>>     interrupts = <20 1>;
>>     
>
> Is this interrupt active on rising edge? This is what you have configured 
> here. When you need level, active low, then you need to write:
>
>      interrupts = <20 8>;
>
> And be careful which dts version you are using. Is this 20 decimal or hex?
>
>   
The interrupt is indeed level, active low. Where can I find information 
on UIC
interrupt settings for device tree ? I'm using dtc 1.2.0, 20 is decimal. 
Is it ok ?
>>     interrupt-parent = <&UIC3>;
>> };
>>
>> In my driver I do the following:
>>
>>     /* Find CPLD node in device tree */
>>     np = of_find_node_by_type(NULL, "cpld");
>>     if (!np) {
>>         printk(KERN_INFO "No CPLD found in device tree\n");
>>         return -1;
>>     }
>>
>>     /* Get and map irq number from device tree */
>>     cpld_irq = irq_of_parse_and_map(np, 0);
>>     if (cpld_irq == NO_IRQ) {
>>         printk(KERN_ERR "irq_of_parse_and_map failed\n");
>>         of_node_put(np);
>>         return -ENODEV;
>>     }
>>
>>     /* Register CPLD interrupt handler */
>>     rc = request_irq(cpld_irq, cpld_interrupt,
>>              IRQF_TRIGGER_LOW, "CPLD", NULL);
>>
>> And I see this interrupt in /proc/interrups after loading
>> the driver. However interrupt handler is never invoked,
>> although hardware guys see that GPIO line goes down
>> when interrupt is generated.
>>
>> What am I doing wrong ?
>>     
>
> Another idea is that you didn't configure the pin multiplexing correctly. Most 
> external IRQ's are shared with other functions and/or GPIO's. You need to 
> configure the multiplexing correctly for external IRQ functionality. This is 
> usually done in U-Boot with the CFG_4xx_GPIO_TABLE. 
>
> I suggest you check here first.
>   
I've checked that, here's the relevant line from u-boot:
{GPIO1_BASE, GPIO_IN , GPIO_ALT3, GPIO_OUT_0}, /* GPIO45 CS(5)          
EOT/TC1         IRQ(12)*/

If I understand this code correctly, u-boot configures this line as ALT3 
(which is external IRQ 12)

Thanks.

Felix.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: External interrupt on 460EX
  2008-10-15 15:18   ` Felix Radensky
@ 2008-10-16  7:44     ` Stefan Roese
  2008-10-16  9:22       ` Felix Radensky
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2008-10-16  7:44 UTC (permalink / raw)
  To: Felix Radensky; +Cc: linuxppc-embedded

Felix,

On Wednesday 15 October 2008, Felix Radensky wrote:
> >> The interrupt is connected to GPIO 45. U-Boot (1.3.4) configures this
> >> pin as external interrupt 12 (interrupt 20 in UIC 3). I've added the
> >> following
> >> entry to board device tree (in opb section)
> >>
> >> cpld@2,0 {
> >>     device_type = "cpld";
> >>     interrupts = <20 1>;
> >
> > Is this interrupt active on rising edge? This is what you have configured
> > here. When you need level, active low, then you need to write:
> >
> >      interrupts = <20 8>;
> >
> > And be careful which dts version you are using. Is this 20 decimal or
> > hex?
>
> The interrupt is indeed level, active low. Where can I find information
> on UIC
> interrupt settings for device tree ?

Not sure if this is really documented. Those values are from 
include/asm-ppc/irq.h:

#define IRQ_TYPE_NONE           0x00000000      /* Default, unspecified type 
*/
#define IRQ_TYPE_EDGE_RISING    0x00000001      /* Edge rising type */
#define IRQ_TYPE_EDGE_FALLING   0x00000002      /* Edge falling type */
#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
#define IRQ_TYPE_LEVEL_HIGH     0x00000004      /* Level high type */
#define IRQ_TYPE_LEVEL_LOW      0x00000008      /* Level low type */

> I'm using dtc 1.2.0, 20 is decimal. 
> Is it ok ?

This doesn't really depend on the dtc version but on the version of the dts 
file itself. Is your dts a v1 dts file? Do you have this in your dts:

/dts-v1/;

?

If yes, then you have a v1 dts file and all number without 0x are decimal 
numbers. Then the "20" is correct for ext IRQ 12. If not then this number is 
hex and you should write "14" instead.

> >>     interrupt-parent = <&UIC3>;
> >> };
> >>
> >> In my driver I do the following:
> >>
> >>     /* Find CPLD node in device tree */
> >>     np = of_find_node_by_type(NULL, "cpld");
> >>     if (!np) {
> >>         printk(KERN_INFO "No CPLD found in device tree\n");
> >>         return -1;
> >>     }
> >>
> >>     /* Get and map irq number from device tree */
> >>     cpld_irq = irq_of_parse_and_map(np, 0);
> >>     if (cpld_irq == NO_IRQ) {
> >>         printk(KERN_ERR "irq_of_parse_and_map failed\n");
> >>         of_node_put(np);
> >>         return -ENODEV;
> >>     }
> >>
> >>     /* Register CPLD interrupt handler */
> >>     rc = request_irq(cpld_irq, cpld_interrupt,
> >>              IRQF_TRIGGER_LOW, "CPLD", NULL);
> >>
> >> And I see this interrupt in /proc/interrups after loading
> >> the driver. However interrupt handler is never invoked,
> >> although hardware guys see that GPIO line goes down
> >> when interrupt is generated.
> >>
> >> What am I doing wrong ?
> >
> > Another idea is that you didn't configure the pin multiplexing correctly.
> > Most external IRQ's are shared with other functions and/or GPIO's. You
> > need to configure the multiplexing correctly for external IRQ
> > functionality. This is usually done in U-Boot with the
> > CFG_4xx_GPIO_TABLE.
> >
> > I suggest you check here first.
>
> I've checked that, here's the relevant line from u-boot:
> {GPIO1_BASE, GPIO_IN , GPIO_ALT3, GPIO_OUT_0}, /* GPIO45 CS(5)
> EOT/TC1         IRQ(12)*/
>
> If I understand this code correctly, u-boot configures this line as ALT3
> (which is external IRQ 12)

Yes, this seems to be correct.

Best regards,
Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: External interrupt on 460EX
  2008-10-16  7:44     ` Stefan Roese
@ 2008-10-16  9:22       ` Felix Radensky
  0 siblings, 0 replies; 5+ messages in thread
From: Felix Radensky @ 2008-10-16  9:22 UTC (permalink / raw)
  To: Stefan Roese; +Cc: linuxppc-embedded

Hi, Stefan

Stefan Roese wrote:
> Felix,
>
> On Wednesday 15 October 2008, Felix Radensky wrote:
>   
>>>> The interrupt is connected to GPIO 45. U-Boot (1.3.4) configures this
>>>> pin as external interrupt 12 (interrupt 20 in UIC 3). I've added the
>>>> following
>>>> entry to board device tree (in opb section)
>>>>
>>>> cpld@2,0 {
>>>>     device_type = "cpld";
>>>>     interrupts = <20 1>;
>>>>         
>>> Is this interrupt active on rising edge? This is what you have configured
>>> here. When you need level, active low, then you need to write:
>>>
>>>      interrupts = <20 8>;
>>>
>>> And be careful which dts version you are using. Is this 20 decimal or
>>> hex?
>>>       
>> The interrupt is indeed level, active low. Where can I find information
>> on UIC
>> interrupt settings for device tree ?
>>     
>
> Not sure if this is really documented. Those values are from 
> include/asm-ppc/irq.h:
>
> #define IRQ_TYPE_NONE           0x00000000      /* Default, unspecified type 
> */
> #define IRQ_TYPE_EDGE_RISING    0x00000001      /* Edge rising type */
> #define IRQ_TYPE_EDGE_FALLING   0x00000002      /* Edge falling type */
> #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
> #define IRQ_TYPE_LEVEL_HIGH     0x00000004      /* Level high type */
> #define IRQ_TYPE_LEVEL_LOW      0x00000008      /* Level low type */
>
>   
Thanks for clarification. I was looking at booting-without-of.txt and 
took my number
from there.
>> I'm using dtc 1.2.0, 20 is decimal. 
>> Is it ok ?
>>     
>
> This doesn't really depend on the dtc version but on the version of the dts 
> file itself. Is your dts a v1 dts file? Do you have this in your dts:
>
> /dts-v1/;
>
> ?
>
> If yes, then you have a v1 dts file and all number without 0x are decimal 
> numbers. Then the "20" is correct for ext IRQ 12. If not then this number is 
> hex and you should write "14" instead.
>
>   
Bingo !!! That was my problem. I've started getting interrupts  after 
changing the irq
number to 14.

Thanks a lot !!! Your answers are great as always.

Felix.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-10-16  9:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-15 14:43 External interrupt on 460EX Felix Radensky
2008-10-15 15:00 ` Stefan Roese
2008-10-15 15:18   ` Felix Radensky
2008-10-16  7:44     ` Stefan Roese
2008-10-16  9:22       ` Felix Radensky

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).