From adb4caf765cc977c8de6534d0bf77df9dd243e41 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Thu, 23 Apr 2026 10:53:36 +0530 Subject: [PATCH] lib: sbi_irqchip: Allow interrupt client to specify line sensing The interrupt client should be allowed to specify the line sensing type of the hwirqs for which it is registering handler. To support this, add hwirq_flags parameter to hwirq_setup() callback provided by the irqchip driver. Signed-off-by: Anup Patel Link: https://lore.kernel.org/r/20260423052339.356900-4-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel --- include/sbi/sbi_irqchip.h | 13 +++++++++++-- lib/sbi/sbi_irqchip.c | 4 ++-- lib/utils/irqchip/imsic.c | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/sbi/sbi_irqchip.h b/include/sbi/sbi_irqchip.h index 77b54110..9035dcef 100644 --- a/include/sbi/sbi_irqchip.h +++ b/include/sbi/sbi_irqchip.h @@ -43,7 +43,16 @@ struct sbi_irqchip_device { int (*process_hwirqs)(struct sbi_irqchip_device *chip); /** Setup a hardware interrupt of this irqchip */ - int (*hwirq_setup)(struct sbi_irqchip_device *chip, u32 hwirq); + int (*hwirq_setup)(struct sbi_irqchip_device *chip, u32 hwirq, + u32 hwirq_flags); +#define SBI_HWIRQ_FLAGS_NONE 0x00000000UL +#define SBI_HWIRQ_FLAGS_EDGE_RISING 0x00000001UL +#define SBI_HWIRQ_FLAGS_EDGE_FALLING 0x00000002UL +#define SBI_HWIRQ_FLAGS_EDGE_BOTH (SBI_HWIRQ_FLAGS_EDGE_RISING | \ + SBI_HWIRQ_FLAGS_EDGE_FALLING) +#define SBI_HWIRQ_FLAGS_LEVEL_HIGH 0x00000004UL +#define SBI_HWIRQ_FLAGS_LEVEL_LOW 0x00000008UL +#define SBI_HWIRQ_FLAGS_LEVEL_SENSE_MASK 0x0000000fUL /** Cleanup a hardware interrupt of this irqchip */ void (*hwirq_cleanup)(struct sbi_irqchip_device *chip, u32 hwirq); @@ -91,7 +100,7 @@ int sbi_irqchip_set_raw_handler(struct sbi_irqchip_device *chip, u32 hwirq, /** Register a hardware interrupt handler */ int sbi_irqchip_register_handler(struct sbi_irqchip_device *chip, - u32 first_hwirq, u32 num_hwirq, + u32 first_hwirq, u32 num_hwirq, u32 hwirq_flags, int (*callback)(u32 hwirq, void *opaque), void *opaque); /** Unregister a hardware interrupt handler */ diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c index f9e2eb5a..ea684303 100644 --- a/lib/sbi/sbi_irqchip.c +++ b/lib/sbi/sbi_irqchip.c @@ -136,7 +136,7 @@ int sbi_irqchip_set_raw_handler(struct sbi_irqchip_device *chip, u32 hwirq, } int sbi_irqchip_register_handler(struct sbi_irqchip_device *chip, - u32 first_hwirq, u32 num_hwirq, + u32 first_hwirq, u32 num_hwirq, u32 hwirq_flags, int (*callback)(u32 hwirq, void *opaque), void *priv) { struct sbi_irqchip_handler *h, *th, *nh; @@ -177,7 +177,7 @@ int sbi_irqchip_register_handler(struct sbi_irqchip_device *chip, if (chip->hwirq_setup) { for (i = 0; i < h->num_hwirq; i++) { - rc = chip->hwirq_setup(chip, h->first_hwirq + i); + rc = chip->hwirq_setup(chip, h->first_hwirq + i, hwirq_flags); if (rc) { if (chip->hwirq_cleanup) { for (j = 0; j < i; j++) diff --git a/lib/utils/irqchip/imsic.c b/lib/utils/irqchip/imsic.c index 7559a069..877255f8 100644 --- a/lib/utils/irqchip/imsic.c +++ b/lib/utils/irqchip/imsic.c @@ -346,9 +346,9 @@ int imsic_data_check(struct imsic_data *imsic) return 0; } -static int imsic_hwirq_setup(struct sbi_irqchip_device *chip, u32 hwirq) +static int imsic_hwirq_setup(struct sbi_irqchip_device *chip, u32 hwirq, u32 hwirq_flags) { - if (!hwirq || hwirq == IMSIC_IPI_ID) + if (!hwirq || hwirq == IMSIC_IPI_ID || hwirq_flags != SBI_HWIRQ_FLAGS_NONE) return SBI_ENOTSUPP; return 0; }