Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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/module.h>
16#include <linux/of.h>
17#include <linux/of_irq.h>
18#include <linux/platform_device.h>
19
20typedef int (*platform_irq_probe_t)(struct platform_device *, struct device_node *);
21
22/* Undefined on purpose */
23extern of_irq_init_cb_t typecheck_irq_init_cb;
24extern platform_irq_probe_t typecheck_irq_probe;
25
26#define typecheck_irq_init_cb(fn) \
27 (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn)
28
29#define typecheck_irq_probe(fn) \
30 (__typecheck(typecheck_irq_probe, &fn) ? fn : fn)
31
32/*
33 * This macro must be used by the different irqchip drivers to declare
34 * the association between their DT compatible string and their
35 * initialization function.
36 *
37 * @name: name that must be unique across all IRQCHIP_DECLARE of the
38 * same file.
39 * @compat: compatible string of the irqchip driver
40 * @fn: initialization function
41 */
42#define IRQCHIP_DECLARE(name, compat, fn) \
43 OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn))
44
45extern int platform_irqchip_probe(struct platform_device *pdev);
46
47#define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
48static const struct of_device_id drv_name##_irqchip_match_table[] = {
49
50#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \
51 .data = typecheck_irq_probe(fn), },
52
53
54#define IRQCHIP_PLATFORM_DRIVER_END(drv_name, ...) \
55 {}, \
56}; \
57MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \
58static struct platform_driver drv_name##_driver = { \
59 .probe = IS_ENABLED(CONFIG_IRQCHIP) ? \
60 platform_irqchip_probe : NULL, \
61 .driver = { \
62 .name = #drv_name, \
63 .owner = THIS_MODULE, \
64 .of_match_table = drv_name##_irqchip_match_table, \
65 .suppress_bind_attrs = true, \
66 __VA_ARGS__ \
67 }, \
68}; \
69builtin_platform_driver(drv_name##_driver)
70
71/*
72 * This macro must be used by the different irqchip drivers to declare
73 * the association between their version and their initialization function.
74 *
75 * @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the
76 * same file.
77 * @subtable: Subtable to be identified in MADT
78 * @validate: Function to be called on that subtable to check its validity.
79 * Can be NULL.
80 * @data: data to be checked by the validate function.
81 * @fn: initialization function
82 */
83#define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn) \
84 ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(irqchip, name, \
85 ACPI_SIG_MADT, subtable, \
86 validate, data, fn)
87
88#ifdef CONFIG_IRQCHIP
89void irqchip_init(void);
90#else
91static inline void irqchip_init(void) {}
92#endif
93
94#endif