pic.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. #include <linux/stddef.h>
  10. #include <linux/kernel.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/of_platform.h>
  13. #include <asm/system.h>
  14. #include <asm/mpic.h>
  15. #include <asm/i8259.h>
  16. #ifdef CONFIG_PPC_I8259
  17. static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
  18. {
  19. unsigned int cascade_irq = i8259_irq();
  20. if (cascade_irq != NO_IRQ)
  21. generic_handle_irq(cascade_irq);
  22. desc->chip->eoi(irq);
  23. }
  24. #endif /* CONFIG_PPC_I8259 */
  25. void __init mpc86xx_init_irq(void)
  26. {
  27. struct mpic *mpic;
  28. struct device_node *np;
  29. struct resource res;
  30. #ifdef CONFIG_PPC_I8259
  31. struct device_node *cascade_node = NULL;
  32. int cascade_irq;
  33. #endif
  34. /* Determine PIC address. */
  35. np = of_find_node_by_type(NULL, "open-pic");
  36. if (np == NULL)
  37. return;
  38. of_address_to_resource(np, 0, &res);
  39. mpic = mpic_alloc(np, res.start,
  40. MPIC_PRIMARY | MPIC_WANTS_RESET |
  41. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
  42. MPIC_SINGLE_DEST_CPU,
  43. 0, 256, " MPIC ");
  44. of_node_put(np);
  45. BUG_ON(mpic == NULL);
  46. mpic_init(mpic);
  47. #ifdef CONFIG_PPC_I8259
  48. /* Initialize i8259 controller */
  49. for_each_node_by_type(np, "interrupt-controller")
  50. if (of_device_is_compatible(np, "chrp,iic")) {
  51. cascade_node = np;
  52. break;
  53. }
  54. if (cascade_node == NULL) {
  55. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  56. return;
  57. }
  58. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  59. if (cascade_irq == NO_IRQ) {
  60. printk(KERN_ERR "Failed to map cascade interrupt\n");
  61. return;
  62. }
  63. i8259_init(cascade_node, 0);
  64. of_node_put(cascade_node);
  65. set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade);
  66. #endif
  67. }