1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 * All rights reserved. 5 */ 6 #ifndef __KERNEL_INTERRUPT_H 7 #define __KERNEL_INTERRUPT_H 8 9 #include <types_ext.h> 10 #include <sys/queue.h> 11 12 #define ITRF_TRIGGER_LEVEL (1 << 0) 13 14 struct itr_chip { 15 const struct itr_ops *ops; 16 }; 17 18 struct itr_ops { 19 void (*add)(struct itr_chip *chip, size_t it, uint32_t flags); 20 void (*enable)(struct itr_chip *chip, size_t it); 21 void (*disable)(struct itr_chip *chip, size_t it); 22 void (*raise_pi)(struct itr_chip *chip, size_t it); 23 void (*raise_sgi)(struct itr_chip *chip, size_t it, 24 uint8_t cpu_mask); 25 void (*set_affinity)(struct itr_chip *chip, size_t it, 26 uint8_t cpu_mask); 27 }; 28 29 enum itr_return { 30 ITRR_NONE, 31 ITRR_HANDLED, 32 }; 33 34 struct itr_handler { 35 size_t it; 36 uint32_t flags; 37 enum itr_return (*handler)(struct itr_handler *h); 38 void *data; 39 SLIST_ENTRY(itr_handler) link; 40 }; 41 42 void itr_init(struct itr_chip *data); 43 void itr_handle(size_t it); 44 45 void itr_add(struct itr_handler *handler); 46 void itr_enable(size_t it); 47 void itr_disable(size_t it); 48 /* raise the Peripheral Interrupt corresponding to the interrupt ID */ 49 void itr_raise_pi(size_t it); 50 /* 51 * raise the Software Generated Interrupt corresponding to the interrupt ID, 52 * the cpu_mask represents which cpu interface to forward. 53 */ 54 void itr_raise_sgi(size_t it, uint8_t cpu_mask); 55 /* 56 * let corresponding interrupt forward to the cpu interface 57 * according to the cpu_mask. 58 */ 59 void itr_set_affinity(size_t it, uint8_t cpu_mask); 60 61 #endif /*__KERNEL_INTERRUPT_H*/ 62