1 /* SPDX-License-Identifier: MIT */ 2 3 /* 4 * (c) 2023-2024 Microchip Technology Inc. 5 * (c) 2024 Vates 6 */ 7 8 #ifndef ASM__RISCV__INTERRUPT_CONTOLLER_H 9 #define ASM__RISCV__INTERRUPT_CONTOLLER_H 10 11 struct dt_device_node; 12 13 enum intc_version { 14 INTC_APLIC, 15 }; 16 17 struct cpu_user_regs; 18 struct irq_desc; 19 20 struct intc_info { 21 enum intc_version hw_version; 22 const struct dt_device_node *node; 23 24 /* number of irqs */ 25 unsigned int num_irqs; 26 }; 27 28 struct intc_hw_operations { 29 /* Hold intc hw information */ 30 const struct intc_info *info; 31 /* Initialize the intc and the boot CPU */ 32 int (*init)(void); 33 34 /* hw_irq_controller to enable/disable/eoi host irq */ 35 const struct hw_interrupt_type *host_irq_type; 36 37 /* Set IRQ type */ 38 void (*set_irq_type)(struct irq_desc *desc, unsigned int type); 39 /* Set IRQ priority */ 40 void (*set_irq_priority)(struct irq_desc *desc, unsigned int priority); 41 42 /* handle external interrupt */ 43 void (*handle_interrupt)(struct cpu_user_regs *regs); 44 }; 45 46 void intc_preinit(void); 47 48 void register_intc_ops(const struct intc_hw_operations *ops); 49 50 void intc_init(void); 51 52 void intc_route_irq_to_xen(struct irq_desc *desc, unsigned int priority); 53 54 void intc_handle_external_irqs(struct cpu_user_regs *regs); 55 56 #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ 57