1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUXKPI_LINUX_INTERRUPT_H_ 30 #define _LINUXKPI_LINUX_INTERRUPT_H_ 31 32 #include "linux/kernel.h" 33 #include "los_base.h" 34 #include "linux/workqueue.h" 35 36 #ifdef __cplusplus 37 #if __cplusplus 38 extern "C" { 39 #endif /* __cplusplus */ 40 #endif /* __cplusplus */ 41 42 #define IRQ_RETVAL(x) ((x) != IRQ_NONE) 43 44 /** 45 * These correspond to the IORESOURCE_IRQ_* defines in 46 * linux/ioport.h to select the interrupt line behaviour. 47 */ 48 #define IRQF_TRIGGER_LOW 0x00000008 49 #define IRQF_TRIGGER_HIGH 0x00000004 50 #define IRQF_TRIGGER_FALLING 0x00000002 51 #define IRQF_TRIGGER_RISING 0x00000001 52 #define IRQF_TRIGGER_NONE 0x00000000 53 #define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \ 54 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING) 55 #define IRQF_PROBE_SHARED 0x00000100 56 57 #define IRQ_DEFAULT_PRIORITY 0x0 58 59 typedef enum irqreturn { 60 IRQ_NONE = (0U << 0), /* interrupt was not from this device. */ 61 IRQ_HANDLED = (1U << 0), /* interrupt was handled by this device. */ 62 IRQ_WAKE_THREAD = (1U << 1) /* handler requests to wake the handler thread. */ 63 } irqreturn_t; 64 65 typedef irqreturn_t (*irq_handler_t)(int, void *); 66 typedef void (*irq_bottom_half_handler_t)(struct work_struct *); 67 68 typedef struct irq_args { 69 int iIrq; 70 void *pDevId; 71 const char *pName; 72 } irq_args; 73 74 #define request_irq(irq, handler, flags, name, dev) \ 75 linux_request_irq(irq, handler, flags, name, dev) 76 77 #define free_irq(irq, dev_id) \ 78 linux_free_irq(irq, dev_id) 79 80 #define enable_irq(irq) \ 81 linux_enable_irq(irq) 82 83 #define disable_irq(irq) \ 84 linux_disable_irq(irq) 85 86 extern int linux_request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, 87 const char *name, void *dev); 88 extern void linux_free_irq(unsigned int irq, void *dev_id); 89 extern void linux_enable_irq(unsigned int irq); 90 extern void linux_disable_irq(unsigned int irq); 91 92 #ifdef WORKQUEUE_SUPPORT_PRIORITY 93 extern bool irq_bottom_half(struct workqueue_struct *workQueue, irq_bottom_half_handler_t handler, void *data, 94 unsigned int pri); 95 #else 96 extern bool irq_bottom_half(struct workqueue_struct *workQueue, irq_bottom_half_handler_t handler, void *data); 97 #endif 98 99 #ifdef __cplusplus 100 #if __cplusplus 101 } 102 #endif /* __cplusplus */ 103 #endif /* __cplusplus */ 104 105 #endif /* _LINUXKPI_LINUX_INTERRUPT_H_ */ 106