xref: /dflybsd-src/sys/dev/drm/include/linux/interrupt.h (revision 802fda022d020e8bc9ede6244f135ee3984e9592)
11e59d133SFrançois Tigeot /*
277a6b00eSFrançois Tigeot  * Copyright (c) 2017-2020 François Tigeot <ftigeot@wolfpond.org>
31e59d133SFrançois Tigeot  * All rights reserved.
41e59d133SFrançois Tigeot  *
51e59d133SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
61e59d133SFrançois Tigeot  * modification, are permitted provided that the following conditions
71e59d133SFrançois Tigeot  * are met:
81e59d133SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
91e59d133SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
101e59d133SFrançois Tigeot  *    disclaimer.
111e59d133SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
121e59d133SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
131e59d133SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
141e59d133SFrançois Tigeot  *
151e59d133SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161e59d133SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171e59d133SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181e59d133SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191e59d133SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201e59d133SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211e59d133SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221e59d133SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231e59d133SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241e59d133SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251e59d133SFrançois Tigeot  */
261e59d133SFrançois Tigeot 
271e59d133SFrançois Tigeot #ifndef _LINUX_INTERRUPT_H_
281e59d133SFrançois Tigeot #define _LINUX_INTERRUPT_H_
291e59d133SFrançois Tigeot 
301e59d133SFrançois Tigeot #include <linux/kernel.h>
311e59d133SFrançois Tigeot #include <linux/bitops.h>
32237ffc69SFrançois Tigeot #include <linux/preempt.h>
33d6aa1cc5SFrançois Tigeot #include <linux/cpumask.h>
34de2d8016SFrançois Tigeot #include <linux/irqreturn.h>
351334141fSFrançois Tigeot #include <linux/hardirq.h>
36de2d8016SFrançois Tigeot #include <linux/irqflags.h>
375915b712SFrançois Tigeot #include <linux/hrtimer.h>
381e59d133SFrançois Tigeot #include <linux/kref.h>
391e59d133SFrançois Tigeot 
401e59d133SFrançois Tigeot #include <linux/atomic.h>
411e59d133SFrançois Tigeot 
42183e2373SFrançois Tigeot #define IRQF_SHARED	0x00000080
43183e2373SFrançois Tigeot 
441e59d133SFrançois Tigeot struct tasklet_struct {
451e59d133SFrançois Tigeot 	unsigned long state;
461e59d133SFrançois Tigeot 	void (*func)(unsigned long);
471e59d133SFrançois Tigeot 	unsigned long data;
48*802fda02SFrançois Tigeot 	atomic_t count;
491e59d133SFrançois Tigeot };
501e59d133SFrançois Tigeot 
511e59d133SFrançois Tigeot enum {
521e59d133SFrançois Tigeot 	TASKLET_STATE_SCHED,
5377a6b00eSFrançois Tigeot 	TASKLET_STATE_RUN,
5477a6b00eSFrançois Tigeot 	TASKLET_IS_DYING
551e59d133SFrançois Tigeot };
561e59d133SFrançois Tigeot 
57183e2373SFrançois Tigeot typedef irqreturn_t (*irq_handler_t)(int, void *);
58183e2373SFrançois Tigeot 
59183e2373SFrançois Tigeot int request_irq(unsigned int irq, irq_handler_t handler,
60183e2373SFrançois Tigeot 		unsigned long flags, const char *name, void *dev);
61183e2373SFrançois Tigeot 
62183e2373SFrançois Tigeot void free_irq(unsigned int irq, void *dev_id);
63183e2373SFrançois Tigeot 
64bb7b9e8bSFrançois Tigeot void disable_irq(unsigned int irq);
65bb7b9e8bSFrançois Tigeot void enable_irq(unsigned int irq);
66bb7b9e8bSFrançois Tigeot 
6777a6b00eSFrançois Tigeot void tasklet_init(struct tasklet_struct *t,
6877a6b00eSFrançois Tigeot 		  void (*func)(unsigned long), unsigned long data);
6977a6b00eSFrançois Tigeot void tasklet_schedule(struct tasklet_struct *t);
7077a6b00eSFrançois Tigeot void tasklet_hi_schedule(struct tasklet_struct *t);
7177a6b00eSFrançois Tigeot void tasklet_kill(struct tasklet_struct *t);
7277a6b00eSFrançois Tigeot 
73*802fda02SFrançois Tigeot static inline void
tasklet_enable(struct tasklet_struct * t)74*802fda02SFrançois Tigeot tasklet_enable(struct tasklet_struct *t)
75*802fda02SFrançois Tigeot {
76*802fda02SFrançois Tigeot 	atomic_dec(&t->count);
77*802fda02SFrançois Tigeot }
78*802fda02SFrançois Tigeot 
79*802fda02SFrançois Tigeot static inline void
tasklet_disable(struct tasklet_struct * t)80*802fda02SFrançois Tigeot tasklet_disable(struct tasklet_struct *t)
81*802fda02SFrançois Tigeot {
82*802fda02SFrançois Tigeot 	atomic_inc(&t->count);
83*802fda02SFrançois Tigeot }
84*802fda02SFrançois Tigeot 
851e59d133SFrançois Tigeot #endif	/* _LINUX_INTERRUPT_H_ */
86