src/ppe/pk/gpe/gpe_irq_init.c
/// Define the polarity and trigger condition for an interrupt.
///
/// It is up to the application to take care of any side effects that may
/// occur from programming or reprogramming the interrupt controller.  For
/// example, changing edge/level sensitivity or active level may set or clear
/// interrupt status in the controller.
///
/// Note that PK allows this API to be called from any context, and changes
/// to the interrupt controller are made from a critical section.
///
/// Return values other then PK_OK (0) are errors; see \ref pk_errors
///
/// \retval 0 Successful completion
///
/// \retval -PK_INVALID_ARGUMENT_IRQ_SETUP One or more arguments are invalid,
/// including an invalid \a irq, or invalid \a polarity or \a trigger parameters.
Define the polarity and trigger condition for an interrupt.
It is up to the application to take care of any side effects that may
occur from programming or reprogramming the interrupt controller.  For
example, changing edge/level sensitivity or active level may set or clear
interrupt status in the controller.

Note that PK allows this API to be called from any context, and changes
to the interrupt controller are made from a critical section.

Return values other then PK_OK (0) are errors; see \ref pk_errors

\retval 0 Successful completion

\retval -PK_INVALID_ARGUMENT_IRQ_SETUP One or more arguments are invalid,
including an invalid \a irq, or invalid \a polarity or \a trigger parameters.
Define the polarity and trigger condition for an interrupt . It is up to the application to take care of any side effects that may occur from programming or reprogramming the interrupt controller . For example changing edge / level sensitivity or active level may set or clear interrupt status in the controller . Note that PK allows this API to be called from any context and changes to the interrupt controller are made from a critical section . Return values other then PK_OK ( 0 ) are errors ; see \ ref pk_errors \ retval 0 Successful completion \ retval - PK_INVALID_ARGUMENT_IRQ_SETUP One or more arguments are invalid including an invalid \ a irq or invalid \ a polarity or \ a trigger parameters .
int
pk_irq_setup(PkIrqId irq,
             int      polarity,
             int      trigger)
{
    PkMachineContext ctx;
    if (PK_ERROR_CHECK_API)
    {
        PK_ERROR_IF(!OCCHW_IRQ_VALID(irq) ||
                    !OCCHW_IRQ_OWNED(irq) ||
                    !((polarity == PK_IRQ_POLARITY_ACTIVE_HIGH) ||
                      (polarity == PK_IRQ_POLARITY_ACTIVE_LOW)) ||
                    !((trigger == PK_IRQ_TRIGGER_LEVEL_SENSITIVE) ||
                      (trigger == PK_IRQ_TRIGGER_EDGE_SENSITIVE)),
                    PK_INVALID_ARGUMENT_IRQ_SETUP);
    }
    pk_critical_section_enter(&ctx);
    if (polarity == PK_IRQ_POLARITY_ACTIVE_HIGH)
    {
        out32(OCCHW_OIEPR_OR(irq), OCCHW_IRQ_MASK32(irq));
    }
    else
    {
        out32(OCCHW_OIEPR_CLR(irq), OCCHW_IRQ_MASK32(irq));
    }
    if (trigger == PK_IRQ_TRIGGER_EDGE_SENSITIVE)
    {
        out32(OCCHW_OITR_OR(irq), OCCHW_IRQ_MASK32(irq));
    }
    else
    {
        out32(OCCHW_OITR_CLR(irq), OCCHW_IRQ_MASK32(irq));
    }
    pk_critical_section_exit(&ctx);
    return PK_OK;
}
int pk_irq_setup ( PkIrqId irq , int polarity , int trigger ) { PkMachineContext ctx ; if ( PK_ERROR_CHECK_API ) { PK_ERROR_IF ( ! OCCHW_IRQ_VALID ( irq ) || ! OCCHW_IRQ_OWNED ( irq ) || ! ( ( polarity == PK_IRQ_POLARITY_ACTIVE_HIGH ) || ( polarity == PK_IRQ_POLARITY_ACTIVE_LOW ) ) || ! ( ( trigger == PK_IRQ_TRIGGER_LEVEL_SENSITIVE ) || ( trigger == PK_IRQ_TRIGGER_EDGE_SENSITIVE ) ) , PK_INVALID_ARGUMENT_IRQ_SETUP ) ; } pk_critical_section_enter ( & ctx ) ; if ( polarity == PK_IRQ_POLARITY_ACTIVE_HIGH ) { out32 ( OCCHW_OIEPR_OR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; } else { out32 ( OCCHW_OIEPR_CLR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; } if ( trigger == PK_IRQ_TRIGGER_EDGE_SENSITIVE ) { out32 ( OCCHW_OITR_OR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; } else { out32 ( OCCHW_OITR_CLR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; } pk_critical_section_exit ( & ctx ) ; return PK_OK ; }
Define the polarity and trigger condition for an interrupt.
Define the polarity and trigger condition for an interrupt .