irq_asic.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Portions copyright (C) 2005-2009 Scientific Atlanta
  3. * Portions copyright (C) 2009 Cisco Systems, Inc.
  4. *
  5. * Modified from arch/mips/kernel/irq-rm7000.c:
  6. * Copyright (C) 2003 Ralf Baechle
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/kernel.h>
  16. #include <asm/irq_cpu.h>
  17. #include <asm/mipsregs.h>
  18. #include <asm/system.h>
  19. #include <asm/mach-powertv/asic_regs.h>
  20. static inline void unmask_asic_irq(unsigned int irq)
  21. {
  22. unsigned long enable_bit;
  23. enable_bit = (1 << (irq & 0x1f));
  24. switch (irq >> 5) {
  25. case 0:
  26. asic_write(asic_read(ien_int_0) | enable_bit, ien_int_0);
  27. break;
  28. case 1:
  29. asic_write(asic_read(ien_int_1) | enable_bit, ien_int_1);
  30. break;
  31. case 2:
  32. asic_write(asic_read(ien_int_2) | enable_bit, ien_int_2);
  33. break;
  34. case 3:
  35. asic_write(asic_read(ien_int_3) | enable_bit, ien_int_3);
  36. break;
  37. default:
  38. BUG();
  39. }
  40. }
  41. static inline void mask_asic_irq(unsigned int irq)
  42. {
  43. unsigned long disable_mask;
  44. disable_mask = ~(1 << (irq & 0x1f));
  45. switch (irq >> 5) {
  46. case 0:
  47. asic_write(asic_read(ien_int_0) & disable_mask, ien_int_0);
  48. break;
  49. case 1:
  50. asic_write(asic_read(ien_int_1) & disable_mask, ien_int_1);
  51. break;
  52. case 2:
  53. asic_write(asic_read(ien_int_2) & disable_mask, ien_int_2);
  54. break;
  55. case 3:
  56. asic_write(asic_read(ien_int_3) & disable_mask, ien_int_3);
  57. break;
  58. default:
  59. BUG();
  60. }
  61. }
  62. static struct irq_chip asic_irq_chip = {
  63. .name = "ASIC Level",
  64. .ack = mask_asic_irq,
  65. .mask = mask_asic_irq,
  66. .mask_ack = mask_asic_irq,
  67. .unmask = unmask_asic_irq,
  68. .eoi = unmask_asic_irq,
  69. };
  70. void __init asic_irq_init(void)
  71. {
  72. int i;
  73. /* set priority to 0 */
  74. write_c0_status(read_c0_status() & ~(0x0000fc00));
  75. asic_write(0, ien_int_0);
  76. asic_write(0, ien_int_1);
  77. asic_write(0, ien_int_2);
  78. asic_write(0, ien_int_3);
  79. asic_write(0x0fffffff, int_level_3_3);
  80. asic_write(0xffffffff, int_level_3_2);
  81. asic_write(0xffffffff, int_level_3_1);
  82. asic_write(0xffffffff, int_level_3_0);
  83. asic_write(0xffffffff, int_level_2_3);
  84. asic_write(0xffffffff, int_level_2_2);
  85. asic_write(0xffffffff, int_level_2_1);
  86. asic_write(0xffffffff, int_level_2_0);
  87. asic_write(0xffffffff, int_level_1_3);
  88. asic_write(0xffffffff, int_level_1_2);
  89. asic_write(0xffffffff, int_level_1_1);
  90. asic_write(0xffffffff, int_level_1_0);
  91. asic_write(0xffffffff, int_level_0_3);
  92. asic_write(0xffffffff, int_level_0_2);
  93. asic_write(0xffffffff, int_level_0_1);
  94. asic_write(0xffffffff, int_level_0_0);
  95. asic_write(0xf, int_int_scan);
  96. /*
  97. * Initialize interrupt handlers.
  98. */
  99. for (i = 0; i < NR_IRQS; i++)
  100. set_irq_chip_and_handler(i, &asic_irq_chip, handle_level_irq);
  101. }