Commit | Line | Data |
---|---|---|
f6e916b8 TP |
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 | ||
46e589a3 | 14 | #include <linux/acpi.h> |
762a21fd | 15 | #include <linux/module.h> |
91e20b50 | 16 | #include <linux/of.h> |
f1985002 | 17 | #include <linux/of_irq.h> |
f8410e62 | 18 | #include <linux/platform_device.h> |
91e20b50 | 19 | |
f1985002 MZ |
20 | /* Undefined on purpose */ |
21 | extern of_irq_init_cb_t typecheck_irq_init_cb; | |
22 | ||
23 | #define typecheck_irq_init_cb(fn) \ | |
24 | (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) | |
25 | ||
91e20b50 JP |
26 | /* |
27 | * This macro must be used by the different irqchip drivers to declare | |
28 | * the association between their DT compatible string and their | |
29 | * initialization function. | |
30 | * | |
c5f48c0a | 31 | * @name: name that must be unique across all IRQCHIP_DECLARE of the |
91e20b50 | 32 | * same file. |
b8419e7b | 33 | * @compat: compatible string of the irqchip driver |
91e20b50 JP |
34 | * @fn: initialization function |
35 | */ | |
f1985002 MZ |
36 | #define IRQCHIP_DECLARE(name, compat, fn) \ |
37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | |
91e20b50 | 38 | |
f8410e62 SK |
39 | extern int platform_irqchip_probe(struct platform_device *pdev); |
40 | ||
41 | #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ | |
42 | static const struct of_device_id drv_name##_irqchip_match_table[] = { | |
43 | ||
f1985002 MZ |
44 | #define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \ |
45 | .data = typecheck_irq_init_cb(fn), }, | |
f8410e62 | 46 | |
334f7d42 FL |
47 | |
48 | #define IRQCHIP_PLATFORM_DRIVER_END(drv_name, ...) \ | |
f8410e62 SK |
49 | {}, \ |
50 | }; \ | |
51 | MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \ | |
1ba54782 AB |
52 | static struct platform_driver drv_name##_driver = { \ |
53 | .probe = IS_ENABLED(CONFIG_IRQCHIP) ? \ | |
54 | platform_irqchip_probe : NULL, \ | |
f8410e62 SK |
55 | .driver = { \ |
56 | .name = #drv_name, \ | |
57 | .owner = THIS_MODULE, \ | |
58 | .of_match_table = drv_name##_irqchip_match_table, \ | |
59 | .suppress_bind_attrs = true, \ | |
334f7d42 | 60 | __VA_ARGS__ \ |
f8410e62 SK |
61 | }, \ |
62 | }; \ | |
63 | builtin_platform_driver(drv_name##_driver) | |
64 | ||
46e589a3 MZ |
65 | /* |
66 | * This macro must be used by the different irqchip drivers to declare | |
67 | * the association between their version and their initialization function. | |
68 | * | |
c5f48c0a | 69 | * @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the |
46e589a3 MZ |
70 | * same file. |
71 | * @subtable: Subtable to be identified in MADT | |
72 | * @validate: Function to be called on that subtable to check its validity. | |
73 | * Can be NULL. | |
74 | * @data: data to be checked by the validate function. | |
75 | * @fn: initialization function | |
76 | */ | |
77 | #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn) \ | |
aba3c7ed OC |
78 | ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(irqchip, name, \ |
79 | ACPI_SIG_MADT, subtable, \ | |
80 | validate, data, fn) | |
46e589a3 | 81 | |
0d7c1210 | 82 | #ifdef CONFIG_IRQCHIP |
f6e916b8 | 83 | void irqchip_init(void); |
0d7c1210 BH |
84 | #else |
85 | static inline void irqchip_init(void) {} | |
86 | #endif | |
f6e916b8 TP |
87 | |
88 | #endif |