xilinx_irq.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * (C) Copyright 2008
  3. * Ricado Ribalda-Universidad Autonoma de Madrid-ricardo.ribalda@gmail.com
  4. * This work has been supported by: QTechnology http://qtec.com/
  5. * Based on interrupts.c Wolfgang Denk-DENX Software Engineering-wd@denx.de
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <watchdog.h>
  10. #include <command.h>
  11. #include <asm/processor.h>
  12. #include <asm/interrupt.h>
  13. #include <asm/ppc4xx.h>
  14. #include <ppc_asm.tmpl>
  15. #include <asm/io.h>
  16. #include <asm/xilinx_irq.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. void pic_enable(void)
  19. {
  20. debug("Xilinx PIC at 0x%8x\n", intc);
  21. /*
  22. * Disable all external interrupts until they are
  23. * explicitly requested.
  24. */
  25. out_be32((u32 *) IER, 0);
  26. /* Acknowledge any pending interrupts just in case. */
  27. out_be32((u32 *) IAR, 0xffffffff);
  28. /* Turn on the Master Enable. */
  29. out_be32((u32 *) MER, 0x3UL);
  30. return;
  31. }
  32. int xilinx_pic_irq_get(void)
  33. {
  34. u32 irq;
  35. irq = in_be32((u32 *) IVR);
  36. /* If no interrupt is pending then all bits of the IVR are set to 1. As
  37. * the IVR is as many bits wide as numbers of inputs are available.
  38. * Therefore, if all bits of the IVR are set to one, its content will
  39. * be bigger than XPAR_INTC_MAX_NUM_INTR_INPUTS.
  40. */
  41. if (irq >= XPAR_INTC_MAX_NUM_INTR_INPUTS)
  42. irq = -1; /* report no pending interrupt. */
  43. debug("get_irq: %d\n", irq);
  44. return (irq);
  45. }
  46. void pic_irq_enable(unsigned int irq)
  47. {
  48. u32 mask = IRQ_MASK(irq);
  49. debug("enable: %d\n", irq);
  50. out_be32((u32 *) SIE, mask);
  51. }
  52. void pic_irq_disable(unsigned int irq)
  53. {
  54. u32 mask = IRQ_MASK(irq);
  55. debug("disable: %d\n", irq);
  56. out_be32((u32 *) CIE, mask);
  57. }
  58. void pic_irq_ack(unsigned int irq)
  59. {
  60. u32 mask = IRQ_MASK(irq);
  61. debug("ack: %d\n", irq);
  62. out_be32((u32 *) IAR, mask);
  63. }
  64. void external_interrupt(struct pt_regs *regs)
  65. {
  66. int irq;
  67. irq = xilinx_pic_irq_get();
  68. if (irq < 0)
  69. return;
  70. interrupt_run_handler(irq);
  71. return;
  72. }