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 #include <linux/acpi.h>
0012 #include <linux/init.h>
0013 #include <linux/of_device.h>
0014 #include <linux/of_irq.h>
0015 #include <linux/irqchip.h>
0016 #include <linux/platform_device.h>
0017 
0018 /*
0019  * This special of_device_id is the sentinel at the end of the
0020  * of_device_id[] array of all irqchips. It is automatically placed at
0021  * the end of the array by the linker, thanks to being part of a
0022  * special section.
0023  */
0024 static const struct of_device_id
0025 irqchip_of_match_end __used __section("__irqchip_of_table_end");
0026 
0027 extern struct of_device_id __irqchip_of_table[];
0028 
0029 void __init irqchip_init(void)
0030 {
0031     of_irq_init(__irqchip_of_table);
0032     acpi_probe_device_table(irqchip);
0033 }
0034 
0035 int platform_irqchip_probe(struct platform_device *pdev)
0036 {
0037     struct device_node *np = pdev->dev.of_node;
0038     struct device_node *par_np = of_irq_find_parent(np);
0039     of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev);
0040 
0041     if (!irq_init_cb)
0042         return -EINVAL;
0043 
0044     if (par_np == np)
0045         par_np = NULL;
0046 
0047     /*
0048      * If there's a parent interrupt controller and  none of the parent irq
0049      * domains have been registered, that means the parent interrupt
0050      * controller has not been initialized yet.  it's not time for this
0051      * interrupt controller to initialize. So, defer probe of this
0052      * interrupt controller. The actual initialization callback of this
0053      * interrupt controller can check for specific domains as necessary.
0054      */
0055     if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
0056         return -EPROBE_DEFER;
0057 
0058     return irq_init_cb(np, par_np);
0059 }
0060 EXPORT_SYMBOL_GPL(platform_irqchip_probe);