Frank Wille | 10 Jan 2012 14:15
Picon

New trigger types for OpenPIC

Hi!

We have many OpenPIC-based PICs in powerpc/pic, which also support
different polarities of level- and edge-triggers. So I suggest to extened
our trigger types like this (powerpc/include/intr.h):

/* Interrupt sharing types. */
#define IST_NONE		0       /* none */  
#define IST_PULSE		1       /* pulsed */
#define IST_EDGE		2       /* edge-triggered */ 
#define IST_LEVEL		3       /* level-triggered */
/* new: */
#define IST_EDGE_FALLING	IST_EDGE
#define IST_EDGE_RAISING	4
#define IST_LEVEL_LOW		IST_LEVEL
#define IST_LEVEL_HIGH		5

Additionally I would change the PICs which support polarities as in the
following example for the mpcsoc PIC:

--- pic_mpcsoc.c        20 Jun 2011 06:21:45 -0000      1.2
+++ pic_mpcsoc.c        10 Jan 2012 13:04:01 -0000
 <at>  <at>  -161,9 +161,11  <at>  <at> 

        x = irq;
        x |= OPENPIC_IMASK;
-       x |= (i8259iswired && irq == 0) ?
+       x |= ((i8259iswired && irq == 0) ||
+           type == IST_EDGE_RAISING || type == IST_LEVEL_HIGH) ?
            OPENPIC_POLARITY_POSITIVE : OPENPIC_POLARITY_NEGATIVE;
(Continue reading)

Toru Nishimura | 10 Jan 2012 15:03

Re: New trigger types for OpenPIC

Frank Wille asked;

> I suggest to extend our trigger types like this (powerpc/include/intr.h):
> ...
> ... support polarities as in the following example for the mpcsoc PIC:

How about using plain if-clauses there like;

    if (i8259iswired && irq == 0)
        x |= OPENPIC_POLARITY_POSITIVE; /* ISA style southbridge compat */
    else if (type == IST_LEVEL_RISING || type == IST_LEVEL_HIGH)
        x |= OPENPIC_POLARITY_POSITIVE;
    else
        x |= OPENPIC_POLARITY_NEGATIVE;
    if (type == IST_EDGE_FALLING || type == IST_EDGE_RASING)
        x |= OPENPIC_SENSE_EDGE;
    else
        x |= OPENPIC_SENSE_LEVEL;

Toru Nishimura / ALKYL Technology

Frank Wille | 10 Jan 2012 15:39
Picon

Re: New trigger types for OpenPIC

On Tue, 10 Jan 2012 23:03:32 +0900
"Toru Nishimura" <locore64 <at> alkyltechnology.com> wrote:

> How about using plain if-clauses there like;
> 
>     if (i8259iswired && irq == 0)
>         x |= OPENPIC_POLARITY_POSITIVE; /* ISA style southbridge
> compat */ else if (type == IST_LEVEL_RISING || type == IST_LEVEL_HIGH)
>         x |= OPENPIC_POLARITY_POSITIVE;
>     else
>         x |= OPENPIC_POLARITY_NEGATIVE;
>     if (type == IST_EDGE_FALLING || type == IST_EDGE_RASING)
>         x |= OPENPIC_SENSE_EDGE;
>     else
>         x |= OPENPIC_SENSE_LEVEL;

Ok for me. This might increase readability.

I just realized that I will also have to add the new types to intr.c.

--- intr.c      27 Sep 2011 01:02:36 -0000      1.18
+++ intr.c      10 Jan 2012 14:37:03 -0000
 <at>  <at>  -168,8 +168,10  <at>  <at> 
        case IST_NONE:
                is->is_type = type;
                break;
-       case IST_EDGE:
-       case IST_LEVEL:
+       case IST_EDGE_FALLING:
+       case IST_EDGE_RAISING:
(Continue reading)


Gmane