xilinx_irq.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * (C) Copyright 2008
  3. * Ricado Ribalda-Universidad Autonoma de Madrid-ricardo.ribalda@uam.es
  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 <commproc.h>
  16. #include <asm/io.h>
  17. #include <asm/xilinx_irq.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. void pic_enable(void)
  20. {
  21. debug("Xilinx PIC at 0x%8x\n", intc);
  22. /*
  23. * Disable all external interrupts until they are
  24. * explicitly requested.
  25. */
  26. out_be32((u32 *) IER, 0);
  27. /* Acknowledge any pending interrupts just in case. */
  28. out_be32((u32 *) IAR, 0xffffffff);
  29. /* Turn on the Master Enable. */
  30. out_be32((u32 *) MER, 0x3UL);
  31. return;
  32. }
  33. int xilinx_pic_irq_get(void)
  34. {
  35. u32 irq;
  36. irq = in_be32((u32 *) IVR);
  37. /* If no interrupt is pending then all bits of the IVR are set to 1. As
  38. * the IVR is as many bits wide as numbers of inputs are available.
  39. * Therefore, if all bits of the IVR are set to one, its content will
  40. * be bigger than XPAR_INTC_MAX_NUM_INTR_INPUTS.
  41. */
  42. if (irq >= XPAR_INTC_MAX_NUM_INTR_INPUTS)
  43. irq = -1; /* report no pending interrupt. */
  44. debug("get_irq: %d\n", irq);
  45. return (irq);
  46. }
  47. void pic_irq_enable(unsigned int irq)
  48. {
  49. u32 mask = IRQ_MASK(irq);
  50. debug("enable: %d\n", irq);
  51. out_be32((u32 *) SIE, mask);
  52. }
  53. void pic_irq_disable(unsigned int irq)
  54. {
  55. u32 mask = IRQ_MASK(irq);
  56. debug("disable: %d\n", irq);
  57. out_be32((u32 *) CIE, mask);
  58. }
  59. void pic_irq_ack(unsigned int irq)
  60. {
  61. u32 mask = IRQ_MASK(irq);
  62. debug("ack: %d\n", irq);
  63. out_be32((u32 *) IAR, mask);
  64. }
  65. void external_interrupt(struct pt_regs *regs)
  66. {
  67. int irq;
  68. irq = xilinx_pic_irq_get();
  69. if (irq < 0)
  70. return;
  71. interrupt_run_handler(irq);
  72. return;
  73. }