106fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnar#ifndef _LINUX_IRQ_H
206fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnar#define _LINUX_IRQ_H
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Please do not include this file in generic code.  There is currently
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * no requirement for any architecture to implement anything held
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * within this file.
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Thanks. --rmk
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1223f9b317e0ba4fbc5fc9524275d0105fa87e2027Adrian Bunk#include <linux/smp.h>
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1406fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnar#ifndef CONFIG_S390
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/linkage.h>
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/cache.h>
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/spinlock.h>
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/cpumask.h>
20503e57630309643562c12f09d4c8a96eb629ee33Ralf Baechle#include <linux/gfp.h>
21908dcecda1d18803b5823f30e6c47d2882dc0cf1Jan Beulich#include <linux/irqreturn.h>
22dd3a1db900f2a215a7d7dd71b836e149a6cf5fedThomas Gleixner#include <linux/irqnr.h>
2377904fd64eb9131c337dd068e4196d25c2f9de7eDavid Howells#include <linux/errno.h>
24503e57630309643562c12f09d4c8a96eb629ee33Ralf Baechle#include <linux/topology.h>
253aa551c9b4c40018f0e261a178e3d25478dc04a9Thomas Gleixner#include <linux/wait.h>
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/irq.h>
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/ptrace.h>
297d12e780e003f93433d49ce78cfedf4b4c52adc5David Howells#include <asm/irq_regs.h>
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
31ab7798ffcf98b11a9525cf65bacdae3fd58d357fThomas Gleixnerstruct seq_file;
32ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmakerstruct module;
3357a58a9435aef3e0342ba4b2c97e0ddfea6f2c7fDavid Howellsstruct irq_desc;
34781295762defc709a609efc01d8bb065276cd9a2Thomas Gleixnerstruct irq_data;
35ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisontypedef	void (*irq_flow_handler_t)(unsigned int irq,
367d12e780e003f93433d49ce78cfedf4b4c52adc5David Howells					    struct irq_desc *desc);
37781295762defc709a609efc01d8bb065276cd9a2Thomas Gleixnertypedef	void (*irq_preflow_handler_t)(struct irq_data *data);
3857a58a9435aef3e0342ba4b2c97e0ddfea6f2c7fDavid Howells
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * IRQ line status.
416e21361619328751e2637b004e14cf360aafbddcThomas Gleixner *
425d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * Bits 0-7 are the same as the IRQF_* bits in linux/interrupt.h
435d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner *
445d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_NONE		- default, unspecified type
455d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_EDGE_RISING		- rising edge triggered
465d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_EDGE_FALLING	- falling edge triggered
475d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_EDGE_BOTH		- rising and falling edge triggered
485d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_LEVEL_HIGH		- high level triggered
495d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_LEVEL_LOW		- low level triggered
505d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_LEVEL_MASK		- Mask to filter out the level bits
515d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_SENSE_MASK		- Mask for all the above bits
523fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt * IRQ_TYPE_DEFAULT		- For use by some PICs to ask irq_set_type
533fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt *				  to setup the HW to a sane default (used
543fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt *                                by irqdomain map() callbacks to synchronize
553fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt *                                the HW state and SW flags for a newly
563fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt *                                allocated descriptor).
573fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt *
585d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_TYPE_PROBE		- Special flag for probing in progress
595d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner *
605d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * Bits which can be modified via irq_set/clear/modify_status_flags()
615d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_LEVEL			- Interrupt is level type. Will be also
625d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner *				  updated in the code when the above trigger
630911f124bf55357803d53197cc1ae5479f5e37e2Geert Uytterhoeven *				  bits are modified via irq_set_irq_type()
645d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_PER_CPU			- Mark an interrupt PER_CPU. Will protect
655d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner *				  it from affinity setting
665d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_NOPROBE			- Interrupt cannot be probed by autoprobing
675d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_NOREQUEST		- Interrupt cannot be requested via
685d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner *				  request_irq()
697f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt * IRQ_NOTHREAD			- Interrupt cannot be threaded
705d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_NOAUTOEN			- Interrupt is not automatically enabled in
715d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner *				  request/setup_irq()
725d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_NO_BALANCING		- Interrupt cannot be balanced (affinity set)
735d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_MOVE_PCNTXT		- Interrupt can be migrated from process context
745d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner * IRQ_NESTED_TRHEAD		- Interrupt nests into another thread
7531d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier * IRQ_PER_CPU_DEVID		- Dev_id is a per-cpu variable
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
775d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixnerenum {
785d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_NONE		= 0x00000000,
795d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_EDGE_RISING	= 0x00000001,
805d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_EDGE_FALLING	= 0x00000002,
815d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_EDGE_BOTH	= (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING),
825d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_LEVEL_HIGH	= 0x00000004,
835d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_LEVEL_LOW	= 0x00000008,
845d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_LEVEL_MASK	= (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
855d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_SENSE_MASK	= 0x0000000f,
863fca40c704dd013797f2c0c518f37cd2cc8e19feBenjamin Herrenschmidt	IRQ_TYPE_DEFAULT	= IRQ_TYPE_SENSE_MASK,
875d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner
885d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_TYPE_PROBE		= 0x00000010,
895d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner
905d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_LEVEL		= (1 <<  8),
915d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_PER_CPU		= (1 <<  9),
925d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_NOPROBE		= (1 << 10),
935d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_NOREQUEST		= (1 << 11),
945d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_NOAUTOEN		= (1 << 12),
955d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_NO_BALANCING	= (1 << 13),
965d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_MOVE_PCNTXT		= (1 << 14),
975d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner	IRQ_NESTED_THREAD	= (1 << 15),
987f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt	IRQ_NOTHREAD		= (1 << 16),
9931d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier	IRQ_PER_CPU_DEVID	= (1 << 17),
1005d4d8fc9ac3e9a90bbdf90bae6864cb2c01f2208Thomas Gleixner};
101950f4427c2ddc921164088a20f01304cf231437cThomas Gleixner
102442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner#define IRQF_MODIFY_MASK	\
103442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner	(IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \
104872434d69c644b8aa5088b835598dc3cd9832affThomas Gleixner	 IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL | IRQ_NO_BALANCING | \
10531d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier	 IRQ_PER_CPU | IRQ_NESTED_THREAD | IRQ_NOTHREAD | IRQ_PER_CPU_DEVID)
106442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner
1078f53f92404bead2ab2154d45c8f508880bb5d95dThomas Gleixner#define IRQ_NO_BALANCING_MASK	(IRQ_PER_CPU | IRQ_NO_BALANCING)
1088f53f92404bead2ab2154d45c8f508880bb5d95dThomas Gleixner
1093b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner/*
1103b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner * Return value for chip->irq_set_affinity()
1113b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner *
1123b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner * IRQ_SET_MASK_OK	- OK, core updates irq_data.affinity
1133b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner * IRQ_SET_MASK_NOCPY	- OK, chip did update irq_data.affinity
1143b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner */
1153b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixnerenum {
1163b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner	IRQ_SET_MASK_OK = 0,
1173b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner	IRQ_SET_MASK_OK_NOCOPY,
1183b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner};
1193b8249e759c701c4a82f99d957be651a7657bf6fThomas Gleixner
1205b912c108c8b1fcecbfe13d6d9a183db97b682d3Eric W. Biedermanstruct msi_desc;
12108a543ad33fc188650801bd36eed4ffe272643e1Grant Likelystruct irq_domain;
1226a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
1238fee5c36177ee098fa41f5fe72999609fef4df6bIngo Molnar/**
124ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * struct irq_data - per irq and irq chip data passed down to chip functions
125ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @irq:		interrupt number
12608a543ad33fc188650801bd36eed4ffe272643e1Grant Likely * @hwirq:		hardware interrupt number, local to the interrupt domain
127ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @node:		node index useful for balancing
12830398bf6c684a77274dbdabf7efc1f24e4a99028Randy Dunlap * @state_use_accessors: status information for irq chip functions.
12991c499178139d6597e68db19638e4135510a34b8Thomas Gleixner *			Use accessor functions to deal with it
130ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @chip:		low level interrupt hardware access
13108a543ad33fc188650801bd36eed4ffe272643e1Grant Likely * @domain:		Interrupt translation domain; responsible for mapping
13208a543ad33fc188650801bd36eed4ffe272643e1Grant Likely *			between hwirq number and linux irq number.
133ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @handler_data:	per-IRQ data for the irq_chip methods
134ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @chip_data:		platform-specific per-chip private data for the chip
135ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner *			methods, to allow shared chip implementations
136ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @msi_desc:		MSI descriptor
137ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * @affinity:		IRQ affinity on SMP
138ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner *
139ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * The fields here need to overlay the ones in irq_desc until we
140ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * cleaned up the direct references and switched everything over to
141ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner * irq_data.
142ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner */
143ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixnerstruct irq_data {
144ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	unsigned int		irq;
14508a543ad33fc188650801bd36eed4ffe272643e1Grant Likely	unsigned long		hwirq;
146ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	unsigned int		node;
14791c499178139d6597e68db19638e4135510a34b8Thomas Gleixner	unsigned int		state_use_accessors;
148ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	struct irq_chip		*chip;
14908a543ad33fc188650801bd36eed4ffe272643e1Grant Likely	struct irq_domain	*domain;
150ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	void			*handler_data;
151ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	void			*chip_data;
152ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	struct msi_desc		*msi_desc;
153ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner#ifdef CONFIG_SMP
154ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner	cpumask_var_t		affinity;
155ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner#endif
156ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner};
157ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner
158f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner/*
159f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner * Bit masks for irq_data.state
160f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner *
161876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner * IRQD_TRIGGER_MASK		- Mask for the trigger type bits
162f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner * IRQD_SETAFFINITY_PENDING	- Affinity setting is pending
163a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner * IRQD_NO_BALANCING		- Balancing disabled for this IRQ
164a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner * IRQD_PER_CPU			- Interrupt is per cpu
1652bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixner * IRQD_AFFINITY_SET		- Interrupt affinity was set
166876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner * IRQD_LEVEL			- Interrupt is level triggered
1677f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner * IRQD_WAKEUP_STATE		- Interrupt is configured for wakeup
1687f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner *				  from suspend
169e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner * IRDQ_MOVE_PCNTXT		- Interrupt can be moved in process
170e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner *				  context
17132f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner * IRQD_IRQ_DISABLED		- Disabled state of the interrupt
17232f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner * IRQD_IRQ_MASKED		- Masked state of the interrupt
17332f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner * IRQD_IRQ_INPROGRESS		- In progress state of the interrupt
174f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner */
175f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixnerenum {
176876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner	IRQD_TRIGGER_MASK		= 0xf,
177a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner	IRQD_SETAFFINITY_PENDING	= (1 <<  8),
178a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner	IRQD_NO_BALANCING		= (1 << 10),
179a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner	IRQD_PER_CPU			= (1 << 11),
1802bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixner	IRQD_AFFINITY_SET		= (1 << 12),
181876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner	IRQD_LEVEL			= (1 << 13),
1827f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner	IRQD_WAKEUP_STATE		= (1 << 14),
183e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner	IRQD_MOVE_PCNTXT		= (1 << 15),
184801a0e9ae36e9b487092e31699d28c0b9a21ad52Thomas Gleixner	IRQD_IRQ_DISABLED		= (1 << 16),
18532f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner	IRQD_IRQ_MASKED			= (1 << 17),
18632f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner	IRQD_IRQ_INPROGRESS		= (1 << 18),
187f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner};
188f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner
189f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixnerstatic inline bool irqd_is_setaffinity_pending(struct irq_data *d)
190f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner{
191f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner	return d->state_use_accessors & IRQD_SETAFFINITY_PENDING;
192f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner}
193f230b6d5c48f8d12f4dfa1f8b5ab0b0320076d21Thomas Gleixner
194a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixnerstatic inline bool irqd_is_per_cpu(struct irq_data *d)
195a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner{
196a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner	return d->state_use_accessors & IRQD_PER_CPU;
197a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner}
198a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner
199a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixnerstatic inline bool irqd_can_balance(struct irq_data *d)
200a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner{
201a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner	return !(d->state_use_accessors & (IRQD_PER_CPU | IRQD_NO_BALANCING));
202a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner}
203a005677b3dd05decdd8880cf3044ae709856f58fThomas Gleixner
2042bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixnerstatic inline bool irqd_affinity_was_set(struct irq_data *d)
2052bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixner{
2062bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixner	return d->state_use_accessors & IRQD_AFFINITY_SET;
2072bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixner}
2082bdd10558c8d93009cb6c32ce9e30800fbb08addThomas Gleixner
209ee38c04b58983a236b43bae71b2415d38bceaf75Thomas Gleixnerstatic inline void irqd_mark_affinity_was_set(struct irq_data *d)
210ee38c04b58983a236b43bae71b2415d38bceaf75Thomas Gleixner{
211ee38c04b58983a236b43bae71b2415d38bceaf75Thomas Gleixner	d->state_use_accessors |= IRQD_AFFINITY_SET;
212ee38c04b58983a236b43bae71b2415d38bceaf75Thomas Gleixner}
213ee38c04b58983a236b43bae71b2415d38bceaf75Thomas Gleixner
214876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixnerstatic inline u32 irqd_get_trigger_type(struct irq_data *d)
215876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner{
216876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner	return d->state_use_accessors & IRQD_TRIGGER_MASK;
217876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner}
218876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner
219876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner/*
220876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner * Must only be called inside irq_chip.irq_set_type() functions.
221876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner */
222876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixnerstatic inline void irqd_set_trigger_type(struct irq_data *d, u32 type)
223876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner{
224876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner	d->state_use_accessors &= ~IRQD_TRIGGER_MASK;
225876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner	d->state_use_accessors |= type & IRQD_TRIGGER_MASK;
226876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner}
227876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner
228876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixnerstatic inline bool irqd_is_level_type(struct irq_data *d)
229876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner{
230876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner	return d->state_use_accessors & IRQD_LEVEL;
231876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner}
232876dbd4cc1b35c1a4cb96a2be1d43ea0eabce3b4Thomas Gleixner
2337f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixnerstatic inline bool irqd_is_wakeup_set(struct irq_data *d)
2347f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner{
2357f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner	return d->state_use_accessors & IRQD_WAKEUP_STATE;
2367f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner}
2377f94226f03299f1ca32f118f02f2a0295e0e5e93Thomas Gleixner
238e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixnerstatic inline bool irqd_can_move_in_process_context(struct irq_data *d)
239e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner{
240e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner	return d->state_use_accessors & IRQD_MOVE_PCNTXT;
241e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner}
242e1ef824146131709d7466e37f889f2dab24ca98eThomas Gleixner
243801a0e9ae36e9b487092e31699d28c0b9a21ad52Thomas Gleixnerstatic inline bool irqd_irq_disabled(struct irq_data *d)
244801a0e9ae36e9b487092e31699d28c0b9a21ad52Thomas Gleixner{
245801a0e9ae36e9b487092e31699d28c0b9a21ad52Thomas Gleixner	return d->state_use_accessors & IRQD_IRQ_DISABLED;
246801a0e9ae36e9b487092e31699d28c0b9a21ad52Thomas Gleixner}
247801a0e9ae36e9b487092e31699d28c0b9a21ad52Thomas Gleixner
24832f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixnerstatic inline bool irqd_irq_masked(struct irq_data *d)
24932f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner{
25032f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner	return d->state_use_accessors & IRQD_IRQ_MASKED;
25132f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner}
25232f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner
25332f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixnerstatic inline bool irqd_irq_inprogress(struct irq_data *d)
25432f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner{
25532f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner	return d->state_use_accessors & IRQD_IRQ_INPROGRESS;
25632f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner}
25732f4125ebffee4f3c4dbc6a437fc656129eb9e60Thomas Gleixner
2589cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner/*
2599cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner * Functions for chained handlers which can be enabled/disabled by the
2609cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner * standard disable_irq/enable_irq calls. Must be called with
2619cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner * irq_desc->lock held.
2629cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner */
2639cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixnerstatic inline void irqd_set_chained_irq_inprogress(struct irq_data *d)
2649cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner{
2659cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner	d->state_use_accessors |= IRQD_IRQ_INPROGRESS;
2669cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner}
2679cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner
2689cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixnerstatic inline void irqd_clr_chained_irq_inprogress(struct irq_data *d)
2699cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner{
2709cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner	d->state_use_accessors &= ~IRQD_IRQ_INPROGRESS;
2719cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner}
2729cff60dfc3d54b60bc069627cee5624bfaa3f823Thomas Gleixner
273a699e4e49ec3fb62c4a44394357d14081df10befGrant Likelystatic inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
274a699e4e49ec3fb62c4a44394357d14081df10befGrant Likely{
275a699e4e49ec3fb62c4a44394357d14081df10befGrant Likely	return d->hwirq;
276a699e4e49ec3fb62c4a44394357d14081df10befGrant Likely}
277a699e4e49ec3fb62c4a44394357d14081df10befGrant Likely
278ff7dcd44dd446db2c3e13bdedf2d52b8e0127f16Thomas Gleixner/**
2796a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner * struct irq_chip - hardware interrupt chip descriptor
2808fee5c36177ee098fa41f5fe72999609fef4df6bIngo Molnar *
2818fee5c36177ee098fa41f5fe72999609fef4df6bIngo Molnar * @name:		name for /proc/interrupts
282f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_startup:	start up the interrupt (defaults to ->enable if NULL)
283f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_shutdown:	shut down the interrupt (defaults to ->disable if NULL)
284f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_enable:		enable the interrupt (defaults to chip->unmask if NULL)
285f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_disable:	disable the interrupt
286f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_ack:		start of a new interrupt
287f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_mask:		mask an interrupt source
288f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_mask_ack:	ack and mask an interrupt source
289f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_unmask:		unmask an interrupt source
290f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_eoi:		end of interrupt
291f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_set_affinity:	set the CPU affinity on SMP machines
292f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_retrigger:	resend an IRQ to the CPU
293f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_set_type:	set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
294f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_set_wake:	enable/disable power-management wake-on of an IRQ
295f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_bus_lock:	function to lock access to slow bus (i2c) chips
296f8822657e799b02c55556c99a601261e207a299dThomas Gleixner * @irq_bus_sync_unlock:function to sync and unlock slow bus (i2c) chips
2970fdb4b259ed3e91b687ac26848202f5e7c217e62David Daney * @irq_cpu_online:	configure an interrupt source for a secondary CPU
2980fdb4b259ed3e91b687ac26848202f5e7c217e62David Daney * @irq_cpu_offline:	un-configure an interrupt source for a secondary CPU
299cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner * @irq_suspend:	function called from core code on suspend once per chip
300cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner * @irq_resume:		function called from core code on resume once per chip
301cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner * @irq_pm_shutdown:	function called from core code on shutdown once per chip
302ab7798ffcf98b11a9525cf65bacdae3fd58d357fThomas Gleixner * @irq_print_chip:	optional to print special chip info in show_interrupts
3032bff17ad2107c66fc8ca96501a7128dd7fa7a390Thomas Gleixner * @flags:		chip specific flags
30470aedd24d20e75198f5a0b11750faabbb56924e2Thomas Gleixner *
3058fee5c36177ee098fa41f5fe72999609fef4df6bIngo Molnar * @release:		release function solely used by UML
3061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
3076a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerstruct irq_chip {
3086a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner	const char	*name;
309f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	unsigned int	(*irq_startup)(struct irq_data *data);
310f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_shutdown)(struct irq_data *data);
311f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_enable)(struct irq_data *data);
312f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_disable)(struct irq_data *data);
313f8822657e799b02c55556c99a601261e207a299dThomas Gleixner
314f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_ack)(struct irq_data *data);
315f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_mask)(struct irq_data *data);
316f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_mask_ack)(struct irq_data *data);
317f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_unmask)(struct irq_data *data);
318f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_eoi)(struct irq_data *data);
319f8822657e799b02c55556c99a601261e207a299dThomas Gleixner
320f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	int		(*irq_set_affinity)(struct irq_data *data, const struct cpumask *dest, bool force);
321f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	int		(*irq_retrigger)(struct irq_data *data);
322f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	int		(*irq_set_type)(struct irq_data *data, unsigned int flow_type);
323f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	int		(*irq_set_wake)(struct irq_data *data, unsigned int on);
324f8822657e799b02c55556c99a601261e207a299dThomas Gleixner
325f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_bus_lock)(struct irq_data *data);
326f8822657e799b02c55556c99a601261e207a299dThomas Gleixner	void		(*irq_bus_sync_unlock)(struct irq_data *data);
327f8822657e799b02c55556c99a601261e207a299dThomas Gleixner
3280fdb4b259ed3e91b687ac26848202f5e7c217e62David Daney	void		(*irq_cpu_online)(struct irq_data *data);
3290fdb4b259ed3e91b687ac26848202f5e7c217e62David Daney	void		(*irq_cpu_offline)(struct irq_data *data);
3300fdb4b259ed3e91b687ac26848202f5e7c217e62David Daney
331cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner	void		(*irq_suspend)(struct irq_data *data);
332cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner	void		(*irq_resume)(struct irq_data *data);
333cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner	void		(*irq_pm_shutdown)(struct irq_data *data);
334cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner
335ab7798ffcf98b11a9525cf65bacdae3fd58d357fThomas Gleixner	void		(*irq_print_chip)(struct irq_data *data, struct seq_file *p);
336ab7798ffcf98b11a9525cf65bacdae3fd58d357fThomas Gleixner
3372bff17ad2107c66fc8ca96501a7128dd7fa7a390Thomas Gleixner	unsigned long	flags;
3382bff17ad2107c66fc8ca96501a7128dd7fa7a390Thomas Gleixner
339b77d6adc922b8bbf8b16b67f567958c42962cf88Paolo 'Blaisorblade' Giarrusso	/* Currently used only by UML, might disappear one day.*/
340b77d6adc922b8bbf8b16b67f567958c42962cf88Paolo 'Blaisorblade' Giarrusso#ifdef CONFIG_IRQ_RELEASE_METHOD
34171d218b75fa91219c6bd310fbdd257dfbcac6c88Ingo Molnar	void		(*release)(unsigned int irq, void *dev_id);
342b77d6adc922b8bbf8b16b67f567958c42962cf88Paolo 'Blaisorblade' Giarrusso#endif
3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
345d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner/*
346d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner * irq_chip specific flags
347d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner *
34877694b408abb8f92195ad5ed6ce5492f1d794c77Thomas Gleixner * IRQCHIP_SET_TYPE_MASKED:	Mask before calling chip.irq_set_type()
34977694b408abb8f92195ad5ed6ce5492f1d794c77Thomas Gleixner * IRQCHIP_EOI_IF_HANDLED:	Only issue irq_eoi() when irq was handled
350d209a699a0b975ad47f399d70ddc3791f1b84496Thomas Gleixner * IRQCHIP_MASK_ON_SUSPEND:	Mask non wake irqs in the suspend path
351b3d422329f2e061d66af4f933ef316e50e5edcacThomas Gleixner * IRQCHIP_ONOFFLINE_ENABLED:	Only call irq_on/off_line callbacks
352b3d422329f2e061d66af4f933ef316e50e5edcacThomas Gleixner *				when irq enabled
35360f96b41f71d2a13d1c0a457b8b77958f77142d1Santosh Shilimkar * IRQCHIP_SKIP_SET_WAKE:	Skip chip.irq_set_wake(), for this irq chip
354d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner */
355d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixnerenum {
356d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner	IRQCHIP_SET_TYPE_MASKED		= (1 <<  0),
35777694b408abb8f92195ad5ed6ce5492f1d794c77Thomas Gleixner	IRQCHIP_EOI_IF_HANDLED		= (1 <<  1),
358d209a699a0b975ad47f399d70ddc3791f1b84496Thomas Gleixner	IRQCHIP_MASK_ON_SUSPEND		= (1 <<  2),
359b3d422329f2e061d66af4f933ef316e50e5edcacThomas Gleixner	IRQCHIP_ONOFFLINE_ENABLED	= (1 <<  3),
36060f96b41f71d2a13d1c0a457b8b77958f77142d1Santosh Shilimkar	IRQCHIP_SKIP_SET_WAKE		= (1 <<  4),
361d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner};
362d4d5e08960844a062da8387ee5f16ca7a33200d0Thomas Gleixner
363e144710b302525de5b90b9c3ba43562458d8957fThomas Gleixner/* This include will go away once we isolated irq_desc usage to core code */
364e144710b302525de5b90b9c3ba43562458d8957fThomas Gleixner#include <linux/irqdesc.h>
3650b8f1efad30bd58f89961b82dfe68b9edf8fd2acYinghai Lu
36634ffdb7233d5847808d2b63ca6761dac3af9c942Ingo Molnar/*
36734ffdb7233d5847808d2b63ca6761dac3af9c942Ingo Molnar * Pick up the arch-dependent methods:
36834ffdb7233d5847808d2b63ca6761dac3af9c942Ingo Molnar */
36934ffdb7233d5847808d2b63ca6761dac3af9c942Ingo Molnar#include <asm/hw_irq.h>
3701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
371b683de2b3cb17bb10fa6fd4af614dc75b5749fe0Thomas Gleixner#ifndef NR_IRQS_LEGACY
372b683de2b3cb17bb10fa6fd4af614dc75b5749fe0Thomas Gleixner# define NR_IRQS_LEGACY 0
373b683de2b3cb17bb10fa6fd4af614dc75b5749fe0Thomas Gleixner#endif
374b683de2b3cb17bb10fa6fd4af614dc75b5749fe0Thomas Gleixner
3751318a481fc37c503a901b96ae06b692ca2b21af5Thomas Gleixner#ifndef ARCH_IRQ_INIT_FLAGS
3761318a481fc37c503a901b96ae06b692ca2b21af5Thomas Gleixner# define ARCH_IRQ_INIT_FLAGS	0
3771318a481fc37c503a901b96ae06b692ca2b21af5Thomas Gleixner#endif
3781318a481fc37c503a901b96ae06b692ca2b21af5Thomas Gleixner
379c1594b77e46124bb462f961e536120e471c67446Thomas Gleixner#define IRQ_DEFAULT_INIT_FLAGS	ARCH_IRQ_INIT_FLAGS
3801318a481fc37c503a901b96ae06b692ca2b21af5Thomas Gleixner
381e144710b302525de5b90b9c3ba43562458d8957fThomas Gleixnerstruct irqaction;
38206fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnarextern int setup_irq(unsigned int irq, struct irqaction *new);
383cbf94f06824780183e4bba165c7c29d5c7bd9a51Magnus Dammextern void remove_irq(unsigned int irq, struct irqaction *act);
38431d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngierextern int setup_percpu_irq(unsigned int irq, struct irqaction *new);
38531d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngierextern void remove_percpu_irq(unsigned int irq, struct irqaction *act);
3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3870fdb4b259ed3e91b687ac26848202f5e7c217e62David Daneyextern void irq_cpu_online(void);
3880fdb4b259ed3e91b687ac26848202f5e7c217e62David Daneyextern void irq_cpu_offline(void);
389c2d0c555c22242c3a76e366074c4d83ef9fa3b8cDavid Daneyextern int __irq_set_affinity_locked(struct irq_data *data,  const struct cpumask *cpumask);
3900fdb4b259ed3e91b687ac26848202f5e7c217e62David Daney
3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_GENERIC_HARDIRQS
39206fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnar
3933a3856d00c74560a7b8d9f8a13c1ca94ee786b78Thomas Gleixner#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ)
394a439520f8b18917b322f576be04c54aba84bb044Thomas Gleixnervoid irq_move_irq(struct irq_data *data);
395a439520f8b18917b322f576be04c54aba84bb044Thomas Gleixnervoid irq_move_masked_irq(struct irq_data *data);
396e144710b302525de5b90b9c3ba43562458d8957fThomas Gleixner#else
397a439520f8b18917b322f576be04c54aba84bb044Thomas Gleixnerstatic inline void irq_move_irq(struct irq_data *data) { }
398a439520f8b18917b322f576be04c54aba84bb044Thomas Gleixnerstatic inline void irq_move_masked_irq(struct irq_data *data) { }
399e144710b302525de5b90b9c3ba43562458d8957fThomas Gleixner#endif
40054d5d42404e7705cf3804593189e963350d470e5Ashok Raj
4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int no_irq_affinity;
4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4036a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner/*
4046a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner * Built-in IRQ handlers for various IRQ types,
405bebd04cc4569844effbdae49c01a48e57fa77864Krzysztof Halasa * callable via desc->handle_irq()
4066a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner */
407ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisonextern void handle_level_irq(unsigned int irq, struct irq_desc *desc);
408ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisonextern void handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc);
409ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisonextern void handle_edge_irq(unsigned int irq, struct irq_desc *desc);
4100521c8fbb3da45c2a58cd551ca6e9644983f6028Thomas Gleixnerextern void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc);
411ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisonextern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
412ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisonextern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
41331d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngierextern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc);
414ec7015840ad7a8cdc87f52367ffe9c0b0401d919Harvey Harrisonextern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
41531b47cf7609288893a10706c648faa932c7aef90Mark Brownextern void handle_nested_irq(unsigned int irq);
4166a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
4176a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner/* Handling of unhandled and spurious interrupts: */
41834ffdb7233d5847808d2b63ca6761dac3af9c942Ingo Molnarextern void note_interrupt(unsigned int irq, struct irq_desc *desc,
419bedd30d986a05e32dc3eab874e4b9ed8a38058bbThomas Gleixner			   irqreturn_t action_ret);
4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
421a4633adcdbc15ac51afcd0e1395de58cee27cf92Thomas Gleixner
4226a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner/* Enable/disable irq debugging output: */
4236a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerextern int noirqdebug_setup(char *str);
4246a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
4256a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner/* Checks whether the interrupt can be requested by request_irq(): */
4266a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerextern int can_request_irq(unsigned int irq, unsigned long irqflags);
4276a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
428f8b5473fcbddbfde827ecf82aa0e81fa2a878220Thomas Gleixner/* Dummy irq-chip implementations: */
4296a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerextern struct irq_chip no_irq_chip;
430f8b5473fcbddbfde827ecf82aa0e81fa2a878220Thomas Gleixnerextern struct irq_chip dummy_irq_chip;
4316a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
4326a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerextern void
4333836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixnerirq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
434a460e745e8f9c75a0525ff94154a0629f9d3e05dIngo Molnar			      irq_flow_handler_t handle, const char *name);
435a460e745e8f9c75a0525ff94154a0629f9d3e05dIngo Molnar
4363836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixnerstatic inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *chip,
4373836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner					    irq_flow_handler_t handle)
4383836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner{
4393836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner	irq_set_chip_and_handler_name(irq, chip, handle, NULL);
4403836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner}
4413836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner
44231d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngierextern int irq_set_percpu_devid(unsigned int irq);
44331d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier
4446a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerextern void
4453836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
446a460e745e8f9c75a0525ff94154a0629f9d3e05dIngo Molnar		  const char *name);
4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4486a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerstatic inline void
4493836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixnerirq_set_handler(unsigned int irq, irq_flow_handler_t handle)
4506a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner{
4513836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner	__irq_set_handler(irq, handle, 0, NULL);
4526a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner}
4536a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
4546a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner/*
4556a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner * Set a highlevel chained flow handler for a given IRQ.
4566a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner * (a chained handler is automatically enabled and set to
4577f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt *  IRQ_NOREQUEST, IRQ_NOPROBE, and IRQ_NOTHREAD)
4586a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner */
4596a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixnerstatic inline void
4603836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixnerirq_set_chained_handler(unsigned int irq, irq_flow_handler_t handle)
4616a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner{
4623836ca08aad4575c120ccf328652f3873eea9063Thomas Gleixner	__irq_set_handler(irq, handle, 1, NULL);
4636a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner}
4646a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner
465442471848f5abb55b99cba1229301655f67492b4Thomas Gleixnervoid irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set);
466442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner
467442471848f5abb55b99cba1229301655f67492b4Thomas Gleixnerstatic inline void irq_set_status_flags(unsigned int irq, unsigned long set)
468442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner{
469442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner	irq_modify_status(irq, 0, set);
470442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner}
471442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner
472442471848f5abb55b99cba1229301655f67492b4Thomas Gleixnerstatic inline void irq_clear_status_flags(unsigned int irq, unsigned long clr)
473442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner{
474442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner	irq_modify_status(irq, clr, 0);
475442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner}
476442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner
477a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline void irq_set_noprobe(unsigned int irq)
478442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner{
479442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner	irq_modify_status(irq, 0, IRQ_NOPROBE);
480442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner}
481442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner
482a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline void irq_set_probe(unsigned int irq)
483442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner{
484442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner	irq_modify_status(irq, IRQ_NOPROBE, 0);
485442471848f5abb55b99cba1229301655f67492b4Thomas Gleixner}
48646f4f8f665080900e865392f4b3593be463bf0d8Ralf Baechle
4877f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundtstatic inline void irq_set_nothread(unsigned int irq)
4887f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt{
4897f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt	irq_modify_status(irq, 0, IRQ_NOTHREAD);
4907f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt}
4917f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt
4927f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundtstatic inline void irq_set_thread(unsigned int irq)
4937f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt{
4947f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt	irq_modify_status(irq, IRQ_NOTHREAD, 0);
4957f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt}
4967f1b1244e159a8490d7fb13667c6cb7e1e75046bPaul Mundt
4976f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixnerstatic inline void irq_set_nested_thread(unsigned int irq, bool nest)
4986f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner{
4996f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner	if (nest)
5006f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner		irq_set_status_flags(irq, IRQ_NESTED_THREAD);
5016f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner	else
5026f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner		irq_clear_status_flags(irq, IRQ_NESTED_THREAD);
5036f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner}
5046f91a52d9bb28396177662f1da0f2e2cef9cf5d0Thomas Gleixner
50531d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngierstatic inline void irq_set_percpu_devid_flags(unsigned int irq)
50631d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier{
50731d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier	irq_set_status_flags(irq,
50831d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier			     IRQ_NOAUTOEN | IRQ_PER_CPU | IRQ_NOTHREAD |
50931d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier			     IRQ_NOPROBE | IRQ_PER_CPU_DEVID);
51031d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier}
51131d9d9b6d83030f748d013e61502fa5477e2ac0eMarc Zyngier
5123a16d713626735f3016da0521b7bf251cd78e836Eric W. Biederman/* Handle dynamic irq creation and destruction */
513d047f53a2ecce37e3bdf79eac5a326fbaadb3628Yinghai Luextern unsigned int create_irq_nr(unsigned int irq_want, int node);
5143a16d713626735f3016da0521b7bf251cd78e836Eric W. Biedermanextern int create_irq(void);
5153a16d713626735f3016da0521b7bf251cd78e836Eric W. Biedermanextern void destroy_irq(unsigned int irq);
5163a16d713626735f3016da0521b7bf251cd78e836Eric W. Biederman
517b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner/*
518b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and
519b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner * irq_free_desc instead.
520b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner */
5213a16d713626735f3016da0521b7bf251cd78e836Eric W. Biedermanextern void dynamic_irq_cleanup(unsigned int irq);
522b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixnerstatic inline void dynamic_irq_init(unsigned int irq)
523b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner{
524b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner	dynamic_irq_cleanup(irq);
525b7b29338dc7111ed8bd4d6555d84afae13ebe752Thomas Gleixner}
526dd87eb3a24c4527741122713e223d74b85d43c85Thomas Gleixner
5273a16d713626735f3016da0521b7bf251cd78e836Eric W. Biederman/* Set/get chip/data for an IRQ: */
528a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerextern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
529a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerextern int irq_set_handler_data(unsigned int irq, void *data);
530a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerextern int irq_set_chip_data(unsigned int irq, void *data);
531a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerextern int irq_set_irq_type(unsigned int irq, unsigned int type);
532a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerextern int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry);
533f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixnerextern struct irq_data *irq_get_irq_data(unsigned int irq);
534dd87eb3a24c4527741122713e223d74b85d43c85Thomas Gleixner
535a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline struct irq_chip *irq_get_chip(unsigned int irq)
536f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
537f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	struct irq_data *d = irq_get_irq_data(irq);
538f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d ? d->chip : NULL;
539f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
540f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
541f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixnerstatic inline struct irq_chip *irq_data_get_irq_chip(struct irq_data *d)
542f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
543f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d->chip;
544f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
545f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
546a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline void *irq_get_chip_data(unsigned int irq)
547f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
548f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	struct irq_data *d = irq_get_irq_data(irq);
549f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d ? d->chip_data : NULL;
550f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
551f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
552f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixnerstatic inline void *irq_data_get_irq_chip_data(struct irq_data *d)
553f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
554f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d->chip_data;
555f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
556f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
557a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline void *irq_get_handler_data(unsigned int irq)
558f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
559f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	struct irq_data *d = irq_get_irq_data(irq);
560f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d ? d->handler_data : NULL;
561f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
562f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
563a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline void *irq_data_get_irq_handler_data(struct irq_data *d)
564f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
565f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d->handler_data;
566f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
567f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
568a0cd9ca2b907d7ee26575e7b63ac92dad768a75eThomas Gleixnerstatic inline struct msi_desc *irq_get_msi_desc(unsigned int irq)
569f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
570f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	struct irq_data *d = irq_get_irq_data(irq);
571f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d ? d->msi_desc : NULL;
572f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
573f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
574f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixnerstatic inline struct msi_desc *irq_data_get_msi(struct irq_data *d)
575f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner{
576f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner	return d->msi_desc;
577f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner}
578f303a6dd127b5ec6de90d1cd79ed19820c7e9658Thomas Gleixner
579b6873807a7143b7d6d8b06809295e559d07d7debSebastian Andrzej Siewiorint __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
580b6873807a7143b7d6d8b06809295e559d07d7debSebastian Andrzej Siewior		struct module *owner);
581b6873807a7143b7d6d8b06809295e559d07d7debSebastian Andrzej Siewior
582ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker/* use macros to avoid needing export.h for THIS_MODULE */
583ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker#define irq_alloc_descs(irq, from, cnt, node)	\
584ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker	__irq_alloc_descs(irq, from, cnt, node, THIS_MODULE)
585b6873807a7143b7d6d8b06809295e559d07d7debSebastian Andrzej Siewior
586ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker#define irq_alloc_desc(node)			\
587ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker	irq_alloc_descs(-1, 0, 1, node)
5881f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner
589ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker#define irq_alloc_desc_at(at, node)		\
590ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker	irq_alloc_descs(at, at, 1, node)
5911f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner
592ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker#define irq_alloc_desc_from(from, node)		\
593ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmaker	irq_alloc_descs(-1, from, 1, node)
5941f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner
595ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmakervoid irq_free_descs(unsigned int irq, unsigned int cnt);
596ec53cf23c0ddb0c29950b9a4ac46964c4c6c6c2fPaul Gortmakerint irq_reserve_irqs(unsigned int from, unsigned int cnt);
5971f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner
5981f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixnerstatic inline void irq_free_desc(unsigned int irq)
5991f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner{
6001f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner	irq_free_descs(irq, 1);
6011f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner}
6021f5a5b87f78fade3ae48dfd55e8765d1d622ea4eThomas Gleixner
603639bd12f778d55a2632fde5af7d0719abc1871b9Paul Mundtstatic inline int irq_reserve_irq(unsigned int irq)
604639bd12f778d55a2632fde5af7d0719abc1871b9Paul Mundt{
605639bd12f778d55a2632fde5af7d0719abc1871b9Paul Mundt	return irq_reserve_irqs(irq, 1);
606639bd12f778d55a2632fde5af7d0719abc1871b9Paul Mundt}
607639bd12f778d55a2632fde5af7d0719abc1871b9Paul Mundt
6087d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#ifndef irq_reg_writel
6097d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner# define irq_reg_writel(val, addr)	writel(val, addr)
6107d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#endif
6117d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#ifndef irq_reg_readl
6127d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner# define irq_reg_readl(addr)		readl(addr)
6137d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#endif
6147d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
6157d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner/**
6167d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * struct irq_chip_regs - register offsets for struct irq_gci
6177d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @enable:	Enable register offset to reg_base
6187d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @disable:	Disable register offset to reg_base
6197d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @mask:	Mask register offset to reg_base
6207d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @ack:	Ack register offset to reg_base
6217d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @eoi:	Eoi register offset to reg_base
6227d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @type:	Type configuration register offset to reg_base
6237d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @polarity:	Polarity configuration register offset to reg_base
6247d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner */
6257d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstruct irq_chip_regs {
6267d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		enable;
6277d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		disable;
6287d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		mask;
6297d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		ack;
6307d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		eoi;
6317d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		type;
6327d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned long		polarity;
6337d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner};
6347d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
6357d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner/**
6367d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * struct irq_chip_type - Generic interrupt chip instance for a flow type
6377d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @chip:		The real interrupt chip which provides the callbacks
6387d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @regs:		Register offsets for this chip
6397d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @handler:		Flow handler associated with this chip
6407d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @type:		Chip can handle these flow types
6417d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner *
6427d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * A irq_generic_chip can have several instances of irq_chip_type when
6437d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * it requires different functions and register offsets for different
6447d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * flow types.
6457d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner */
6467d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstruct irq_chip_type {
6477d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	struct irq_chip		chip;
6487d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	struct irq_chip_regs	regs;
6497d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	irq_flow_handler_t	handler;
6507d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	u32			type;
6517d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner};
6527d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
6537d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner/**
6547d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * struct irq_chip_generic - Generic irq chip data structure
6557d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @lock:		Lock to protect register and cache data access
6567d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @reg_base:		Register base address (virtual)
6577d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @irq_base:		Interrupt base nr for this chip
6587d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @irq_cnt:		Number of interrupts handled by this chip
6597d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @mask_cache:		Cached mask register
6607d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @type_cache:		Cached type register
6617d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @polarity_cache:	Cached polarity register
6627d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @wake_enabled:	Interrupt can wakeup from suspend
6637d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @wake_active:	Interrupt is marked as an wakeup from suspend source
6647d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @num_ct:		Number of available irq_chip_type instances (usually 1)
6657d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @private:		Private data for non generic chip callbacks
666cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner * @list:		List head for keeping track of instances
6677d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @chip_types:		Array of interrupt irq_chip_types
6687d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner *
6697d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * Note, that irq_chip_generic can have multiple irq_chip_type
6707d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * implementations which can be associated to a particular irq line of
6717d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * an irq_chip_generic instance. That allows to share and protect
6727d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * state in an irq_chip_generic instance when we need to implement
6737d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * different flow mechanisms (level/edge) for it.
6747d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner */
6757d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstruct irq_chip_generic {
6767d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	raw_spinlock_t		lock;
6777d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	void __iomem		*reg_base;
6787d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned int		irq_base;
6797d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned int		irq_cnt;
6807d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	u32			mask_cache;
6817d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	u32			type_cache;
6827d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	u32			polarity_cache;
6837d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	u32			wake_enabled;
6847d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	u32			wake_active;
6857d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	unsigned int		num_ct;
6867d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	void			*private;
687cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner	struct list_head	list;
6887d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	struct irq_chip_type	chip_types[0];
6897d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner};
6907d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
6917d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner/**
6927d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * enum irq_gc_flags - Initialization flags for generic irq chips
6937d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @IRQ_GC_INIT_MASK_CACHE:	Initialize the mask_cache by reading mask reg
6947d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner * @IRQ_GC_INIT_NESTED_LOCK:	Set the lock class of the irqs to nested for
6957d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner *				irq chips which need to call irq_set_wake() on
6967d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner *				the parent irq. Usually GPIO implementations
6977d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner */
6987d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerenum irq_gc_flags {
6997d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	IRQ_GC_INIT_MASK_CACHE		= 1 << 0,
7007d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	IRQ_GC_INIT_NESTED_LOCK		= 1 << 1,
7017d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner};
7027d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7037d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner/* Generic chip callback functions */
7047d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_noop(struct irq_data *d);
7057d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_mask_disable_reg(struct irq_data *d);
7067d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_mask_set_bit(struct irq_data *d);
7077d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_mask_clr_bit(struct irq_data *d);
7087d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_unmask_enable_reg(struct irq_data *d);
709659fb32d1b67476f4ade25e9ea0e2642a5b9c4b5Simon Guinotvoid irq_gc_ack_set_bit(struct irq_data *d);
710659fb32d1b67476f4ade25e9ea0e2642a5b9c4b5Simon Guinotvoid irq_gc_ack_clr_bit(struct irq_data *d);
7117d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_mask_disable_reg_and_ack(struct irq_data *d);
7127d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_gc_eoi(struct irq_data *d);
7137d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerint irq_gc_set_wake(struct irq_data *d, unsigned int on);
7147d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7157d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner/* Setup functions for irq_chip_generic */
7167d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstruct irq_chip_generic *
7177d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerirq_alloc_generic_chip(const char *name, int nr_ct, unsigned int irq_base,
7187d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner		       void __iomem *reg_base, irq_flow_handler_t handler);
7197d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnervoid irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
7207d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner			    enum irq_gc_flags flags, unsigned int clr,
7217d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner			    unsigned int set);
7227d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerint irq_setup_alt_chip(struct irq_data *d, unsigned int type);
723cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixnervoid irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
724cfefd21e693dca791bf9ecfc9dd3794facad533cThomas Gleixner			     unsigned int clr, unsigned int set);
7257d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7267d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstatic inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
7277d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner{
7287d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	return container_of(d->chip, struct irq_chip_type, chip);
7297d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner}
7307d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7317d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
7327d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7337d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#ifdef CONFIG_SMP
7347d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstatic inline void irq_gc_lock(struct irq_chip_generic *gc)
7357d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner{
7367d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	raw_spin_lock(&gc->lock);
7377d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner}
7387d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7397d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstatic inline void irq_gc_unlock(struct irq_chip_generic *gc)
7407d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner{
7417d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner	raw_spin_unlock(&gc->lock);
7427d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner}
7437d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#else
7447d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstatic inline void irq_gc_lock(struct irq_chip_generic *gc) { }
7457d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixnerstatic inline void irq_gc_unlock(struct irq_chip_generic *gc) { }
7467d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner#endif
7477d8280624797bbe2f5170bd3c85c75a8c9c74242Thomas Gleixner
7486a6de9ef5850d063c3d3fb50784bfe3a6d0712c6Thomas Gleixner#endif /* CONFIG_GENERIC_HARDIRQS */
7491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
75006fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnar#endif /* !CONFIG_S390 */
7511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
75206fcb0c6fb3aae9570a32ac3b72a8222563baa69Ingo Molnar#endif /* _LINUX_IRQ_H */
753