Skip to contentSkip to conversation

Questions about the interrupt controller

DISCUSSION Francis Moreau 3 participants 10 messages Feb 29, 2008 – Mar 3, 2008 SuperH

lore
Share & tools
lore
#0 lore raw

Hello,

I read the sh4 core peripherals manual avalaible on renesas web site (BTW do you know other 'good' documentations on the sh4 architecture ?) in order to understand how the 'intc' works.

My question is: are there any examples in the linux kernel which use the IRL interrupts when *not* configured as 4 independent interrupt requests ?

Do such interrupts need to use make_imask_irq() ?

The documentation says: "Other compatible interrupt controllers can be cascaded with INTC.". Where can I find some details about that ?

Thanks !

Signature · 1 line
Francis
#1 lore raw
Quoted 8 lines · Francis Moreau

Hello,

I read the sh4 core peripherals manual avalaible on renesas web site (BTW do you know other 'good' documentations on the sh4 architecture ?) in order to understand how the 'intc' works.

My question is: are there any examples in the linux kernel which use the IRL interrupts when *not* configured as 4 independent interrupt requests ?

The platform I'm working on does that. A CPLD with 15 IRQ sources uses the 4 IRL lines to signal them (low-active 4-bit "bus" if you will).

Quoted 1 line

Do such interrupts need to use make_imask_irq() ?

Again, I can only tell for my SH7760 platform. You need to register your own irq_chip with mask/unmask/mask_ack callbacks. On the SH7760, the IRLs trigger as vectors 0-15, and one has to provide external logic to do the irq masking/acking. SH7780 and newer IIRC provide an INTC register for that.

This is code I use:

/* CPU MODULE CPLD IRQ "CONTROLLER" */
static void exm7760_en_cpld_irq(unsigned int irq)

{
         unsigned short val = ctrl_inw(EXM7760_CPLD_MASK) & ~(1 << irq);
         ctrl_outw(val, EXM7760_CPLD_MASK);
}

static void exm7760_dis_cpld_irq(unsigned int irq)

{
         unsigned short val = ctrl_inw(EXM7760_CPLD_MASK) | (1 << irq);
         ctrl_outw(val, EXM7760_CPLD_MASK);
}
static struct irq_chip exm7760_cpld_chip __read_mostly = {
         .name           = "CPLD",
         .unmask         = exm7760_en_cpld_irq,
         .mask           = exm7760_dis_cpld_irq,
         .mask_ack       = exm7760_dis_cpld_irq,
};

static void __init exm7760_init_cpld_irq(void)

{
         int i;
         for (i = 0; i < EXM7760_CPLD_IRQNUM; i++)  {
                 set_irq_chip_and_handler_name(i, &exm7760_cpld_chip,
                                 handle_level_irq, "level");
                 set_irq_chip_data(i, NULL);
         }
}
Quoted 2 lines

The documentation says: "Other compatible interrupt controllers can be cascaded with INTC.". Where can I find some details about that ?

have a look at set_irq_chained_handler() function, for example:

static struct irq_chip exm7760_pcmcia_chip __read_mostly = {

         .name           = "CPLD-PCMCIA",
         .unmask         = exm7760_en_cardirq,
         .mask           = exm7760_dis_cardirq,
         .mask_ack       = exm7760_dis_cardirq,

};

static void exm7760_pcmcia_chain_handler(unsigned int irq,
struct irq_desc *desc)

{
         unsigned short cfctl = ctrl_inw(EXM7760_CPLD_CFCTL);
         if ((cfctl & CFCTL_RDY) = 0)
                 generic_handle_irq(EXM7760_CF_CARD0_IRQ);

         if ((cfctl & (CFCTL_RDY << CFCTL_SOCK1_SHIFT)) = 0)
                 generic_handle_irq(EXM7760_CF_CARD1_IRQ);
}

static void __init exm7760_init_pcmcia_irq(void)

{
         set_irq_chip_and_handler_name(EXM7760_CF_CARD0_IRQ,
                       &exm7760_pcmcia_chip, handle_level_irq, "level");
         set_irq_chip_and_handler_name(EXM7760_CF_CARD1_IRQ,
                       &exm7760_pcmcia_chip, handle_level_irq, "level");

         set_irq_chained_handler(EXM7760_CF_IRQ,
                                 exm7760_pcmcia_chain_handler);
}

Best regards,
Manuel Lauss

#2 lore raw
In reply to Francis Moreau

Hello Manuel,

Quoted 8 lines · Manuel Lauss

Again, I can only tell for my SH7760 platform. You need to register your own irq_chip with mask/unmask/mask_ack callbacks. On the SH7760, the IRLs trigger as vectors 0-15, and one has to provide external logic to do the irq masking/acking. SH7780 and newer IIRC provide an INTC register for that.

This is code I use:

[snip]

But couldn't you use make_imask_irq() instead ?

Quoted 5 lines
Quoted 2 lines

The documentation says: "Other compatible interrupt controllers can be cascaded with INTC.". Where can I find some details about that ?

have a look at set_irq_chained_handler() function, for example:

[snip]

Actually I'm wondering what does 'compatible' mean.... ?

Thanks

Signature · 1 line
Francis
#3 lore raw
In reply to Francis Moreau
Quoted 10 lines · Francis Moreau

Hello Manuel,

Quoted 6 lines · Manuel Lauss

Again, I can only tell for my SH7760 platform. You need to register your own irq_chip with mask/unmask/mask_ack callbacks. On the SH7760, the IRLs trigger as vectors 0-15, and one has to provide external logic to do the irq masking/acking. SH7780 and newer IIRC provide an INTC register for that.

Quoted 6 lines
Quoted 2 lines

This is code I use:

[snip]

But couldn't you use make_imask_irq() instead ?

Yes, that works too; at least for the IRL irqs if the source does not have to be acked (CF cards).

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

The documentation says: "Other compatible interrupt controllers can be cascaded with INTC.". Where can I find some details about that ?

have a look at set_irq_chained_handler() function, for example:

[snip]

Actually I'm wondering what does 'compatible' mean.... ?

4 lines which are pulled low to signal IRQ condition and the ~bitmask of those 4 lines indicates the number of the irq to trigger? Thats my understanding of how it works...

Signature · 1 line
  ml.
#4 lore raw
In reply to Francis Moreau
Quoted 4 lines · I wrote:
Quoted 1 line

But couldn't you use make_imask_irq() instead ?

Yes, that works too; at least for the IRL irqs if the source does not have to be acked (CF cards).

Now I'm not so sure about that. Paul or Magnus can probably give you better advice. I'm curious why you'd want to use IMASK?

Signature · 1 line
  ml.
#5 lore raw
In reply to Francis Moreau
Quoted 1 line · Manuel Lauss
Quoted 1 line

But couldn't you use make_imask_irq() instead ?

Ah now I understand. You are talking about the 4 IMASK bits in the SR register, right? If yes then disregard all I wrote earlier.

I'm going to shut up now. ;-)

Signature · 1 line
  ml.
#6 lore raw
In reply to Francis Moreau
Quoted 6 lines · Manuel Lauss
Quoted 1 line · Francis Moreau

But couldn't you use make_imask_irq() instead ?

Yes, that works too; at least for the IRL irqs if the source does not have to be acked (CF cards).

What do you mean by "the source doesn't have to be acked" ?

The possible case where it couldn't be used is when the irqs are edge triggered.

Another drawback is that we can't mask one single IRL irq but we have to mask all IRQs whose priority are less than the IRL irq's priority,

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

The documentation says: "Other compatible interrupt controllers can be cascaded with INTC.". Where can I find some details about that ?

have a look at set_irq_chained_handler() function, for example:

Quoted 8 lines
Quoted 3 lines

[snip]

Actually I'm wondering what does 'compatible' mean.... ?

4 lines which are pulled low to signal IRQ condition and the ~bitmask of those 4 lines indicates the number of the irq to trigger? Thats my understanding of how it works...

Do you know any datasheets out there describing this ?

In the same vein, could you point out some good documents about the SH architecture ? The ones available from Renesas web site aren't very good IMHO

Thanks Manuel

Signature · 1 line
Francis
#7 lore raw
In reply to Francis Moreau
Quoted 6 lines · Manuel Lauss
Quoted 1 line · Manuel Lauss
Quoted 1 line

But couldn't you use make_imask_irq() instead ?

Ah now I understand. You are talking about the 4 IMASK bits in the SR register, right? If yes then disregard all I wrote earlier.

Yes.

Quoted 2 lines

I'm going to shut up now. ;-)

Well what you wrote earlier is still usefull.

Signature · 1 line
Francis
#8 lore raw
In reply to Francis Moreau
Quoted 5 lines

The possible case where it couldn't be used is when the irqs are edge triggered.

Another drawback is that we can't mask one single IRL irq but we have to mask all IRQs whose priority are less than the IRL irq's priority,

According to the SH7760 datasheet, the INTC compares the priority of _every_ interrupt (IRL, On-chip peripheral) to the IMASK register. If IRQ priority is HIGHER than the level set in IMASK then the interrupt is accepted and the exception handler is invoked.

So no, I don't believen you can have a "sane" IRL irq handling scheme only with IMASK irq chip.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The documentation says: "Other compatible interrupt controllers can be cascaded with INTC.". Where can I find some details about that ?

have a look at set_irq_chained_handler() function, for example:

[snip]

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Actually I'm wondering what does 'compatible' mean.... ?

4 lines which are pulled low to signal IRQ condition and the ~bitmask of those 4 lines indicates the number of the irq to trigger? Thats my understanding of how it works...

Do you know any datasheets out there describing this ?

Take the SH7751/SH7760/SH7780 datasheets for example, it's described in the INTC chapter (Page 217 of the 7760 manual).

Quoted 3 lines

In the same vein, could you point out some good documents about the SH architecture ? The ones available from Renesas web site aren't very good IMHO

Maybe ST has some manuals for their ST40 based parts (also SH4 variants) on their site.

Signature · 1 line
  ml.
#9 lore raw
In reply to Francis Moreau
Quoted 6 lines · Manuel Lauss
Quoted 3 lines

In the same vein, could you point out some good documents about the SH architecture ? The ones available from Renesas web site aren't very good IMHO

Maybe ST has some manuals for their ST40 based parts (also SH4 variants) on their site.

There is some general information on the architecture and core at:
http://www.st.com/mcu/modules.php?name=mcu&fileúmiliesdocs&famQ
but most of it is pretty old.

Most of the recent chip datasheets are only available under NDA, although there is an old ST40RA datasheet available there.

Stuart