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