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 | ||
46e589a3 | 11 | #include <linux/acpi.h> |
f6e916b8 | 12 | #include <linux/init.h> |
f8410e62 | 13 | #include <linux/of_device.h> |
f6e916b8 | 14 | #include <linux/of_irq.h> |
559ba4b1 | 15 | #include <linux/irqchip.h> |
f8410e62 | 16 | #include <linux/platform_device.h> |
f6e916b8 | 17 | |
f6e916b8 TP |
18 | /* |
19 | * This special of_device_id is the sentinel at the end of the | |
20 | * of_device_id[] array of all irqchips. It is automatically placed at | |
21 | * the end of the array by the linker, thanks to being part of a | |
22 | * special section. | |
23 | */ | |
24 | static const struct of_device_id | |
33def849 | 25 | irqchip_of_match_end __used __section("__irqchip_of_table_end"); |
f6e916b8 | 26 | |
735e0da7 | 27 | extern struct of_device_id __irqchip_of_table[]; |
f6e916b8 TP |
28 | |
29 | void __init irqchip_init(void) | |
30 | { | |
735e0da7 | 31 | of_irq_init(__irqchip_of_table); |
46e589a3 | 32 | acpi_probe_device_table(irqchip); |
f6e916b8 | 33 | } |
f8410e62 SK |
34 | |
35 | int platform_irqchip_probe(struct platform_device *pdev) | |
36 | { | |
37 | struct device_node *np = pdev->dev.of_node; | |
38 | struct device_node *par_np = of_irq_find_parent(np); | |
39 | of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev); | |
40 | ||
41 | if (!irq_init_cb) | |
42 | return -EINVAL; | |
43 | ||
44 | if (par_np == np) | |
45 | par_np = NULL; | |
46 | ||
47 | /* | |
48 | * If there's a parent interrupt controller and none of the parent irq | |
49 | * domains have been registered, that means the parent interrupt | |
50 | * controller has not been initialized yet. it's not time for this | |
51 | * interrupt controller to initialize. So, defer probe of this | |
52 | * interrupt controller. The actual initialization callback of this | |
53 | * interrupt controller can check for specific domains as necessary. | |
54 | */ | |
7828a3ef | 55 | if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) |
f8410e62 SK |
56 | return -EPROBE_DEFER; |
57 | ||
58 | return irq_init_cb(np, par_np); | |
59 | } | |
60 | EXPORT_SYMBOL_GPL(platform_irqchip_probe); |