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 <linux/irq.h>
  17. #include <asm/irq_cpu.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/system.h>
  20. #include <asm/mach-powertv/asic_regs.h>
  21. static inline void unmask_asic_irq(struct irq_data *d)
  22. {
  23. unsigned long enable_bit;
  24. unsigned int irq = d->irq;
  25. enable_bit = (1 << (irq & 0x1f));
  26. switch (irq >> 5) {
  27. case 0:
  28. asic_write(asic_read(ien_int_0) | enable_bit, ien_int_0);
  29. break;
  30. case 1:
  31. asic_write(asic_read(ien_int_1) | enable_bit, ien_int_1);
  32. break;
  33. case 2:
  34. asic_write(asic_read(ien_int_2) | enable_bit, ien_int_2);
  35. break;
  36. case 3:
  37. asic_write(asic_read(ien_int_3) | enable_bit, ien_int_3);
  38. break;
  39. default:
  40. BUG();
  41. }
  42. }
  43. static inline void mask_asic_irq(struct irq_data *d)
  44. {
  45. unsigned long disable_mask;
  46. unsigned int irq = d->irq;
  47. disable_mask = ~(1 << (irq & 0x1f));
  48. switch (irq >> 5) {
  49. case 0:
  50. asic_write(asic_read(ien_int_0) & disable_mask, ien_int_0);
  51. break;
  52. case 1:
  53. asic_write(asic_read(ien_int_1) & disable_mask, ien_int_1);
  54. break;
  55. case 2:
  56. asic_write(asic_read(ien_int_2) & disable_mask, ien_int_2);
  57. break;
  58. case 3:
  59. asic_write(asic_read(ien_int_3) & disable_mask, ien_int_3);
  60. break;
  61. default:
  62. BUG();
  63. }
  64. }
  65. static struct irq_chip asic_irq_chip = {
  66. .name = "ASIC Level",
  67. .irq_mask = mask_asic_irq,
  68. .irq_unmask = 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. irq_set_chip_and_handler(i, &asic_irq_chip, handle_level_irq);
  101. }