Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 15 | #include <linux/module.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 16 | #include <linux/of.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 17 | #include <linux/platform_device.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * This macro must be used by the different irqchip drivers to declare |
| 21 | * the association between their DT compatible string and their |
| 22 | * initialization function. |
| 23 | * |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 24 | * @name: name that must be unique across all IRQCHIP_DECLARE of the |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 25 | * same file. |
| 26 | * @compstr: compatible string of the irqchip driver |
| 27 | * @fn: initialization function |
| 28 | */ |
| 29 | #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) |
| 30 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 31 | extern int platform_irqchip_probe(struct platform_device *pdev); |
| 32 | |
| 33 | #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ |
| 34 | static const struct of_device_id drv_name##_irqchip_match_table[] = { |
| 35 | |
| 36 | #define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn }, |
| 37 | |
| 38 | #define IRQCHIP_PLATFORM_DRIVER_END(drv_name) \ |
| 39 | {}, \ |
| 40 | }; \ |
| 41 | MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \ |
| 42 | static struct platform_driver drv_name##_driver = { \ |
| 43 | .probe = platform_irqchip_probe, \ |
| 44 | .driver = { \ |
| 45 | .name = #drv_name, \ |
| 46 | .owner = THIS_MODULE, \ |
| 47 | .of_match_table = drv_name##_irqchip_match_table, \ |
| 48 | .suppress_bind_attrs = true, \ |
| 49 | }, \ |
| 50 | }; \ |
| 51 | builtin_platform_driver(drv_name##_driver) |
| 52 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 53 | /* |
| 54 | * This macro must be used by the different irqchip drivers to declare |
| 55 | * the association between their version and their initialization function. |
| 56 | * |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 57 | * @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 58 | * same file. |
| 59 | * @subtable: Subtable to be identified in MADT |
| 60 | * @validate: Function to be called on that subtable to check its validity. |
| 61 | * Can be NULL. |
| 62 | * @data: data to be checked by the validate function. |
| 63 | * @fn: initialization function |
| 64 | */ |
| 65 | #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn) \ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 66 | ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(irqchip, name, \ |
| 67 | ACPI_SIG_MADT, subtable, \ |
| 68 | validate, data, fn) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 69 | |
| 70 | #ifdef CONFIG_IRQCHIP |
| 71 | void irqchip_init(void); |
| 72 | #else |
| 73 | static inline void irqchip_init(void) {} |
| 74 | #endif |
| 75 | |
| 76 | #endif |