1 /* 2 * Copyright (c) 2016, Linaro Limited 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 */ 27 #ifndef __KERNEL_INTERRUPT_H 28 #define __KERNEL_INTERRUPT_H 29 30 #include <types_ext.h> 31 #include <sys/queue.h> 32 33 #define ITRF_TRIGGER_LEVEL (1 << 0) 34 35 struct itr_chip { 36 const struct itr_ops *ops; 37 }; 38 39 struct itr_ops { 40 void (*add)(struct itr_chip *chip, size_t it, uint32_t flags); 41 void (*enable)(struct itr_chip *chip, size_t it); 42 void (*disable)(struct itr_chip *chip, size_t it); 43 }; 44 45 enum itr_return { 46 ITRR_NONE, 47 ITRR_HANDLED, 48 }; 49 50 struct itr_handler { 51 size_t it; 52 uint32_t flags; 53 enum itr_return (*handler)(struct itr_handler *h); 54 void *data; 55 SLIST_ENTRY(itr_handler) link; 56 }; 57 58 void itr_init(struct itr_chip *data); 59 void itr_handle(size_t it); 60 61 void itr_add(struct itr_handler *handler); 62 void itr_enable(struct itr_handler *handler); 63 void itr_disable(struct itr_handler *handler); 64 65 #endif /*__KERNEL_INTERRUPT_H*/ 66