irqchip.c 1.8 KB

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