irq.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Freescale STMP37XX/STMP378X common interrupt handling code
  3. *
  4. * Author: Vladislav Buzov <vbuzov@embeddedalley.com>
  5. *
  6. * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
  7. * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
  8. */
  9. /*
  10. * The code contained herein is licensed under the GNU General Public
  11. * License. You may obtain a copy of the GNU General Public License
  12. * Version 2 or later at the following locations:
  13. *
  14. * http://www.opensource.org/licenses/gpl-license.html
  15. * http://www.gnu.org/copyleft/gpl.html
  16. */
  17. #include <linux/init.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/delay.h>
  20. #include <linux/irq.h>
  21. #include <linux/sysdev.h>
  22. #include <mach/stmp3xxx.h>
  23. #include <mach/regs-icoll.h>
  24. void __init stmp3xxx_init_irq(struct irq_chip *chip)
  25. {
  26. unsigned int i;
  27. /* Reset the interrupt controller */
  28. HW_ICOLL_CTRL_CLR(BM_ICOLL_CTRL_CLKGATE);
  29. udelay(10);
  30. HW_ICOLL_CTRL_CLR(BM_ICOLL_CTRL_SFTRST);
  31. udelay(10);
  32. HW_ICOLL_CTRL_SET(BM_ICOLL_CTRL_SFTRST);
  33. while (!(HW_ICOLL_CTRL_RD() & BM_ICOLL_CTRL_CLKGATE))
  34. continue;
  35. HW_ICOLL_CTRL_CLR(BM_ICOLL_CTRL_SFTRST | BM_ICOLL_CTRL_CLKGATE);
  36. /* Disable all interrupts initially */
  37. for (i = 0; i < NR_REAL_IRQS; i++) {
  38. chip->mask(i);
  39. set_irq_chip(i, chip);
  40. set_irq_handler(i, handle_level_irq);
  41. set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
  42. }
  43. /* Ensure vector is cleared */
  44. HW_ICOLL_LEVELACK_WR(1);
  45. HW_ICOLL_LEVELACK_WR(2);
  46. HW_ICOLL_LEVELACK_WR(4);
  47. HW_ICOLL_LEVELACK_WR(8);
  48. HW_ICOLL_VECTOR_WR(0);
  49. /* Barrier */
  50. (void) HW_ICOLL_STAT_RD();
  51. }