irq.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
  3. * Author: Fuxin Zhang, zhangfx@lemote.com
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #include <linux/delay.h>
  11. #include <linux/interrupt.h>
  12. #include <loongson.h>
  13. /*
  14. * the first level int-handler will jump here if it is a bonito irq
  15. */
  16. void bonito_irqdispatch(void)
  17. {
  18. u32 int_status;
  19. int i;
  20. /* workaround the IO dma problem: let cpu looping to allow DMA finish */
  21. int_status = BONITO_INTISR;
  22. if (int_status & (1 << 10)) {
  23. while (int_status & (1 << 10)) {
  24. udelay(1);
  25. int_status = BONITO_INTISR;
  26. }
  27. }
  28. /* Get pending sources, masked by current enables */
  29. int_status = BONITO_INTISR & BONITO_INTEN;
  30. if (int_status != 0) {
  31. i = __ffs(int_status);
  32. int_status &= ~(1 << i);
  33. do_IRQ(BONITO_IRQ_BASE + i);
  34. }
  35. }
  36. asmlinkage void plat_irq_dispatch(void)
  37. {
  38. unsigned int pending;
  39. pending = read_c0_cause() & read_c0_status() & ST0_IM;
  40. /* machine-specific plat_irq_dispatch */
  41. mach_irq_dispatch(pending);
  42. }
  43. void __init arch_init_irq(void)
  44. {
  45. /*
  46. * Clear all of the interrupts while we change the able around a bit.
  47. * int-handler is not on bootstrap
  48. */
  49. clear_c0_status(ST0_IM | ST0_BEV);
  50. local_irq_disable();
  51. /* setting irq trigger mode */
  52. set_irq_trigger_mode();
  53. /* no steer */
  54. BONITO_INTSTEER = 0;
  55. /*
  56. * Mask out all interrupt by writing "1" to all bit position in
  57. * the interrupt reset reg.
  58. */
  59. BONITO_INTENCLR = ~0;
  60. /* machine specific irq init */
  61. mach_init_irq();
  62. }