xref: /OK3568_Linux_fs/kernel/include/linux/irqchip.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2012 Thomas Petazzoni
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * This file is licensed under the terms of the GNU General Public
7*4882a593Smuzhiyun  * License version 2.  This program is licensed "as is" without any
8*4882a593Smuzhiyun  * warranty of any kind, whether express or implied.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #ifndef _LINUX_IRQCHIP_H
12*4882a593Smuzhiyun #define _LINUX_IRQCHIP_H
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #include <linux/acpi.h>
15*4882a593Smuzhiyun #include <linux/module.h>
16*4882a593Smuzhiyun #include <linux/of.h>
17*4882a593Smuzhiyun #include <linux/platform_device.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun /*
20*4882a593Smuzhiyun  * This macro must be used by the different irqchip drivers to declare
21*4882a593Smuzhiyun  * the association between their DT compatible string and their
22*4882a593Smuzhiyun  * initialization function.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * @name: name that must be unique across all IRQCHIP_DECLARE of the
25*4882a593Smuzhiyun  * same file.
26*4882a593Smuzhiyun  * @compstr: compatible string of the irqchip driver
27*4882a593Smuzhiyun  * @fn: initialization function
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn)
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun extern int platform_irqchip_probe(struct platform_device *pdev);
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
34*4882a593Smuzhiyun static const struct of_device_id drv_name##_irqchip_match_table[] = {
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #define IRQCHIP_PLATFORM_DRIVER_END(drv_name)				\
39*4882a593Smuzhiyun 	{},								\
40*4882a593Smuzhiyun };									\
41*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table);		\
42*4882a593Smuzhiyun static struct platform_driver drv_name##_driver = {		\
43*4882a593Smuzhiyun 	.probe  = platform_irqchip_probe,				\
44*4882a593Smuzhiyun 	.driver = {							\
45*4882a593Smuzhiyun 		.name = #drv_name,					\
46*4882a593Smuzhiyun 		.owner = THIS_MODULE,					\
47*4882a593Smuzhiyun 		.of_match_table = drv_name##_irqchip_match_table,	\
48*4882a593Smuzhiyun 		.suppress_bind_attrs = true,				\
49*4882a593Smuzhiyun 	},								\
50*4882a593Smuzhiyun };									\
51*4882a593Smuzhiyun builtin_platform_driver(drv_name##_driver)
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /*
54*4882a593Smuzhiyun  * This macro must be used by the different irqchip drivers to declare
55*4882a593Smuzhiyun  * the association between their version and their initialization function.
56*4882a593Smuzhiyun  *
57*4882a593Smuzhiyun  * @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the
58*4882a593Smuzhiyun  * same file.
59*4882a593Smuzhiyun  * @subtable: Subtable to be identified in MADT
60*4882a593Smuzhiyun  * @validate: Function to be called on that subtable to check its validity.
61*4882a593Smuzhiyun  *            Can be NULL.
62*4882a593Smuzhiyun  * @data: data to be checked by the validate function.
63*4882a593Smuzhiyun  * @fn: initialization function
64*4882a593Smuzhiyun  */
65*4882a593Smuzhiyun #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn)	\
66*4882a593Smuzhiyun 	ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(irqchip, name,		\
67*4882a593Smuzhiyun 					  ACPI_SIG_MADT, subtable,	\
68*4882a593Smuzhiyun 					  validate, data, fn)
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #ifdef CONFIG_IRQCHIP
71*4882a593Smuzhiyun void irqchip_init(void);
72*4882a593Smuzhiyun #else
irqchip_init(void)73*4882a593Smuzhiyun static inline void irqchip_init(void) {}
74*4882a593Smuzhiyun #endif
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #endif
77