1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (C) 2012 Thomas Petazzoni 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This file is licensed under the terms of the GNU General Public 7*4882a593Smuzhiyun * License version 2. This program is licensed "as is" without any 8*4882a593Smuzhiyun * warranty of any kind, whether express or implied. 9*4882a593Smuzhiyun */ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/acpi.h> 12*4882a593Smuzhiyun #include <linux/init.h> 13*4882a593Smuzhiyun #include <linux/of_device.h> 14*4882a593Smuzhiyun #include <linux/of_irq.h> 15*4882a593Smuzhiyun #include <linux/irqchip.h> 16*4882a593Smuzhiyun #include <linux/platform_device.h> 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* 19*4882a593Smuzhiyun * This special of_device_id is the sentinel at the end of the 20*4882a593Smuzhiyun * of_device_id[] array of all irqchips. It is automatically placed at 21*4882a593Smuzhiyun * the end of the array by the linker, thanks to being part of a 22*4882a593Smuzhiyun * special section. 23*4882a593Smuzhiyun */ 24*4882a593Smuzhiyun static const struct of_device_id 25*4882a593Smuzhiyun irqchip_of_match_end __used __section("__irqchip_of_table_end"); 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun extern struct of_device_id __irqchip_of_table[]; 28*4882a593Smuzhiyun irqchip_init(void)29*4882a593Smuzhiyunvoid __init irqchip_init(void) 30*4882a593Smuzhiyun { 31*4882a593Smuzhiyun of_irq_init(__irqchip_of_table); 32*4882a593Smuzhiyun acpi_probe_device_table(irqchip); 33*4882a593Smuzhiyun } 34*4882a593Smuzhiyun platform_irqchip_probe(struct platform_device * pdev)35*4882a593Smuzhiyunint platform_irqchip_probe(struct platform_device *pdev) 36*4882a593Smuzhiyun { 37*4882a593Smuzhiyun struct device_node *np = pdev->dev.of_node; 38*4882a593Smuzhiyun struct device_node *par_np = of_irq_find_parent(np); 39*4882a593Smuzhiyun of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev); 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun if (!irq_init_cb) 42*4882a593Smuzhiyun return -EINVAL; 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun if (par_np == np) 45*4882a593Smuzhiyun par_np = NULL; 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun /* 48*4882a593Smuzhiyun * If there's a parent interrupt controller and none of the parent irq 49*4882a593Smuzhiyun * domains have been registered, that means the parent interrupt 50*4882a593Smuzhiyun * controller has not been initialized yet. it's not time for this 51*4882a593Smuzhiyun * interrupt controller to initialize. So, defer probe of this 52*4882a593Smuzhiyun * interrupt controller. The actual initialization callback of this 53*4882a593Smuzhiyun * interrupt controller can check for specific domains as necessary. 54*4882a593Smuzhiyun */ 55*4882a593Smuzhiyun if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) 56*4882a593Smuzhiyun return -EPROBE_DEFER; 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun return irq_init_cb(np, par_np); 59*4882a593Smuzhiyun } 60*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(platform_irqchip_probe); 61