pic.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. struct irq_chip *chip = irq_desc_get_chip(desc);
  20. unsigned int cascade_irq = i8259_irq();
  21. if (cascade_irq != NO_IRQ)
  22. generic_handle_irq(cascade_irq);
  23. chip->irq_eoi(&desc->irq_data);
  24. }
  25. #endif /* CONFIG_PPC_I8259 */
  26. void __init mpc86xx_init_irq(void)
  27. {
  28. #ifdef CONFIG_PPC_I8259
  29. struct device_node *np;
  30. struct device_node *cascade_node = NULL;
  31. int cascade_irq;
  32. #endif
  33. struct mpic *mpic = mpic_alloc(NULL, 0,
  34. MPIC_PRIMARY | MPIC_WANTS_RESET |
  35. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
  36. MPIC_SINGLE_DEST_CPU,
  37. 0, 256, " MPIC ");
  38. BUG_ON(mpic == NULL);
  39. mpic_init(mpic);
  40. #ifdef CONFIG_PPC_I8259
  41. /* Initialize i8259 controller */
  42. for_each_node_by_type(np, "interrupt-controller")
  43. if (of_device_is_compatible(np, "chrp,iic")) {
  44. cascade_node = np;
  45. break;
  46. }
  47. if (cascade_node == NULL) {
  48. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  49. return;
  50. }
  51. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  52. if (cascade_irq == NO_IRQ) {
  53. printk(KERN_ERR "Failed to map cascade interrupt\n");
  54. return;
  55. }
  56. i8259_init(cascade_node, 0);
  57. of_node_put(cascade_node);
  58. irq_set_chained_handler(cascade_irq, mpc86xx_8259_cascade);
  59. #endif
  60. }