Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2012 Thomas Petazzoni
0003  *
0004  * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
0005  *
0006  * This file is licensed under the terms of the GNU General Public
0007  * License version 2.  This program is licensed "as is" without any
0008  * warranty of any kind, whether express or implied.
0009  */
0010 
0011 #ifndef _LINUX_IRQCHIP_H
0012 #define _LINUX_IRQCHIP_H
0013 
0014 #include <linux/acpi.h>
0015 #include <linux/module.h>
0016 #include <linux/of.h>
0017 #include <linux/of_irq.h>
0018 #include <linux/platform_device.h>
0019 
0020 /* Undefined on purpose */
0021 extern of_irq_init_cb_t typecheck_irq_init_cb;
0022 
0023 #define typecheck_irq_init_cb(fn)                   \
0024     (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn)
0025 
0026 /*
0027  * This macro must be used by the different irqchip drivers to declare
0028  * the association between their DT compatible string and their
0029  * initialization function.
0030  *
0031  * @name: name that must be unique across all IRQCHIP_DECLARE of the
0032  * same file.
0033  * @compat: compatible string of the irqchip driver
0034  * @fn: initialization function
0035  */
0036 #define IRQCHIP_DECLARE(name, compat, fn)   \
0037     OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn))
0038 
0039 extern int platform_irqchip_probe(struct platform_device *pdev);
0040 
0041 #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
0042 static const struct of_device_id drv_name##_irqchip_match_table[] = {
0043 
0044 #define IRQCHIP_MATCH(compat, fn) { .compatible = compat,       \
0045                     .data = typecheck_irq_init_cb(fn), },
0046 
0047 #define IRQCHIP_PLATFORM_DRIVER_END(drv_name)               \
0048     {},                             \
0049 };                                  \
0050 MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table);        \
0051 static struct platform_driver drv_name##_driver = {         \
0052     .probe  = IS_ENABLED(CONFIG_IRQCHIP) ?              \
0053             platform_irqchip_probe : NULL,          \
0054     .driver = {                         \
0055         .name = #drv_name,                  \
0056         .owner = THIS_MODULE,                   \
0057         .of_match_table = drv_name##_irqchip_match_table,   \
0058         .suppress_bind_attrs = true,                \
0059     },                              \
0060 };                                  \
0061 builtin_platform_driver(drv_name##_driver)
0062 
0063 /*
0064  * This macro must be used by the different irqchip drivers to declare
0065  * the association between their version and their initialization function.
0066  *
0067  * @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the
0068  * same file.
0069  * @subtable: Subtable to be identified in MADT
0070  * @validate: Function to be called on that subtable to check its validity.
0071  *            Can be NULL.
0072  * @data: data to be checked by the validate function.
0073  * @fn: initialization function
0074  */
0075 #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn)    \
0076     ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(irqchip, name,        \
0077                       ACPI_SIG_MADT, subtable,  \
0078                       validate, data, fn)
0079 
0080 #ifdef CONFIG_IRQCHIP
0081 void irqchip_init(void);
0082 #else
0083 static inline void irqchip_init(void) {}
0084 #endif
0085 
0086 #endif