162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (C) 2012 Thomas Petazzoni 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This file is licensed under the terms of the GNU General Public 762306a36Sopenharmony_ci * License version 2. This program is licensed "as is" without any 862306a36Sopenharmony_ci * warranty of any kind, whether express or implied. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/acpi.h> 1262306a36Sopenharmony_ci#include <linux/init.h> 1362306a36Sopenharmony_ci#include <linux/of.h> 1462306a36Sopenharmony_ci#include <linux/of_irq.h> 1562306a36Sopenharmony_ci#include <linux/irqchip.h> 1662306a36Sopenharmony_ci#include <linux/platform_device.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* 1962306a36Sopenharmony_ci * This special of_device_id is the sentinel at the end of the 2062306a36Sopenharmony_ci * of_device_id[] array of all irqchips. It is automatically placed at 2162306a36Sopenharmony_ci * the end of the array by the linker, thanks to being part of a 2262306a36Sopenharmony_ci * special section. 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_cistatic const struct of_device_id 2562306a36Sopenharmony_ciirqchip_of_match_end __used __section("__irqchip_of_table_end"); 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciextern struct of_device_id __irqchip_of_table[]; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_civoid __init irqchip_init(void) 3062306a36Sopenharmony_ci{ 3162306a36Sopenharmony_ci of_irq_init(__irqchip_of_table); 3262306a36Sopenharmony_ci acpi_probe_device_table(irqchip); 3362306a36Sopenharmony_ci} 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciint platform_irqchip_probe(struct platform_device *pdev) 3662306a36Sopenharmony_ci{ 3762306a36Sopenharmony_ci struct device_node *np = pdev->dev.of_node; 3862306a36Sopenharmony_ci struct device_node *par_np = of_irq_find_parent(np); 3962306a36Sopenharmony_ci of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev); 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci if (!irq_init_cb) { 4262306a36Sopenharmony_ci of_node_put(par_np); 4362306a36Sopenharmony_ci return -EINVAL; 4462306a36Sopenharmony_ci } 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci if (par_np == np) 4762306a36Sopenharmony_ci par_np = NULL; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci /* 5062306a36Sopenharmony_ci * If there's a parent interrupt controller and none of the parent irq 5162306a36Sopenharmony_ci * domains have been registered, that means the parent interrupt 5262306a36Sopenharmony_ci * controller has not been initialized yet. it's not time for this 5362306a36Sopenharmony_ci * interrupt controller to initialize. So, defer probe of this 5462306a36Sopenharmony_ci * interrupt controller. The actual initialization callback of this 5562306a36Sopenharmony_ci * interrupt controller can check for specific domains as necessary. 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_ci if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) { 5862306a36Sopenharmony_ci of_node_put(par_np); 5962306a36Sopenharmony_ci return -EPROBE_DEFER; 6062306a36Sopenharmony_ci } 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci return irq_init_cb(np, par_np); 6362306a36Sopenharmony_ci} 6462306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(platform_irqchip_probe); 65