xilinx_irq.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <common.h>
  20. #include <watchdog.h>
  21. #include <command.h>
  22. #include <asm/processor.h>
  23. #include <asm/interrupt.h>
  24. #include <ppc4xx.h>
  25. #include <ppc_asm.tmpl>
  26. #include <commproc.h>
  27. #include <asm/io.h>
  28. #include <asm/xilinx_irq.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. void pic_enable(void)
  31. {
  32. debug("Xilinx PIC at 0x%8x\n", intc);
  33. /*
  34. * Disable all external interrupts until they are
  35. * explicitly requested.
  36. */
  37. out_be32((u32 *) IER, 0);
  38. /* Acknowledge any pending interrupts just in case. */
  39. out_be32((u32 *) IAR, 0xffffffff);
  40. /* Turn on the Master Enable. */
  41. out_be32((u32 *) MER, 0x3UL);
  42. return;
  43. }
  44. int xilinx_pic_irq_get(void)
  45. {
  46. u32 irq;
  47. irq = in_be32((u32 *) IVR);
  48. /* If no interrupt is pending then all bits of the IVR are set to 1. As
  49. * the IVR is as many bits wide as numbers of inputs are available.
  50. * Therefore, if all bits of the IVR are set to one, its content will
  51. * be bigger than XPAR_INTC_MAX_NUM_INTR_INPUTS.
  52. */
  53. if (irq >= XPAR_INTC_MAX_NUM_INTR_INPUTS)
  54. irq = -1; /* report no pending interrupt. */
  55. debug("get_irq: %d\n", irq);
  56. return (irq);
  57. }
  58. void pic_irq_enable(unsigned int irq)
  59. {
  60. u32 mask = IRQ_MASK(irq);
  61. debug("enable: %d\n", irq);
  62. out_be32((u32 *) SIE, mask);
  63. }
  64. void pic_irq_disable(unsigned int irq)
  65. {
  66. u32 mask = IRQ_MASK(irq);
  67. debug("disable: %d\n", irq);
  68. out_be32((u32 *) CIE, mask);
  69. }
  70. void pic_irq_ack(unsigned int irq)
  71. {
  72. u32 mask = IRQ_MASK(irq);
  73. debug("ack: %d\n", irq);
  74. out_be32((u32 *) IAR, mask);
  75. }
  76. void external_interrupt(struct pt_regs *regs)
  77. {
  78. int irq;
  79. irq = xilinx_pic_irq_get();
  80. if (irq < 0)
  81. return;
  82. interrupt_run_handler(irq);
  83. return;
  84. }