Skip to content

Commit

Permalink
drivers: intc: gic: implement set pending interrupt
Browse files Browse the repository at this point in the history
Implement a function to set pending interrupts for Arm GIC.

Signed-off-by: Manuel Argüelles <[email protected]>
  • Loading branch information
manuargue authored and carlescufi committed Aug 12, 2024
1 parent 42c8732 commit 2786cb9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/interrupt_controller/intc_gic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (c) 2018 Marvell
* Copyright (c) 2018 Lexmark International, Inc.
* Copyright (c) 2019 Stephanos Ioannidis <[email protected]>
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -79,6 +80,16 @@ bool arm_gic_irq_is_pending(unsigned int irq)
return (enabler & (1 << int_off)) != 0;
}

void arm_gic_irq_set_pending(unsigned int irq)
{
int int_grp, int_off;

int_grp = irq / 32;
int_off = irq % 32;

sys_write32((1 << int_off), (GICD_ISPENDRn + int_grp * 4));
}

void arm_gic_irq_clear_pending(unsigned int irq)
{
int int_grp, int_off;
Expand Down
9 changes: 9 additions & 0 deletions drivers/interrupt_controller/intc_gicv3.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2020 Broadcom
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -227,6 +228,14 @@ bool arm_gic_irq_is_pending(unsigned int intid)
return (val & mask) != 0;
}

void arm_gic_irq_set_pending(unsigned int intid)
{
uint32_t mask = BIT(intid & (GIC_NUM_INTR_PER_REG - 1));
uint32_t idx = intid / GIC_NUM_INTR_PER_REG;

sys_write32(mask, ISPENDR(GET_DIST_BASE(intid), idx));
}

void arm_gic_irq_clear_pending(unsigned int intid)
{
uint32_t mask = BIT(intid & (GIC_NUM_INTR_PER_REG - 1));
Expand Down
7 changes: 7 additions & 0 deletions include/zephyr/drivers/interrupt_controller/gic.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ bool arm_gic_irq_is_enabled(unsigned int irq);
*/
bool arm_gic_irq_is_pending(unsigned int irq);

/**
* @brief Set interrupt as pending
*
* @param irq interrupt ID
*/
void arm_gic_irq_set_pending(unsigned int irq);

/**
* @brief Clear the pending irq
*
Expand Down

0 comments on commit 2786cb9

Please sign in to comment.