pic.c 1.6 KB

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