irq.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * arch/score/kernel/irq.c
  3. *
  4. * Score Processor version.
  5. *
  6. * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
  7. * Chen Liqin <liqin.chen@sunplusct.com>
  8. * Lennox Wu <lennox.wu@sunplusct.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, see the file COPYING, or write
  22. * to the Free Software Foundation, Inc.,
  23. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. #include <linux/interrupt.h>
  26. #include <linux/kernel_stat.h>
  27. #include <linux/seq_file.h>
  28. #include <asm/io.h>
  29. /*
  30. * handles all normal device IRQs
  31. */
  32. asmlinkage void do_IRQ(int irq)
  33. {
  34. irq_enter();
  35. generic_handle_irq(irq);
  36. irq_exit();
  37. }
  38. static void score_mask(unsigned int irq_nr)
  39. {
  40. unsigned int irq_source = 63 - irq_nr;
  41. if (irq_source < 32)
  42. __raw_writel((__raw_readl((void *)P_INT_MASKL) | \
  43. (1 << irq_source)), (void *)P_INT_MASKL);
  44. else
  45. __raw_writel((__raw_readl((void *)P_INT_MASKH) | \
  46. (1 << (irq_source - 32))), (void *)P_INT_MASKH);
  47. }
  48. static void score_unmask(unsigned int irq_nr)
  49. {
  50. unsigned int irq_source = 63 - irq_nr;
  51. if (irq_source < 32)
  52. __raw_writel((__raw_readl((void *)P_INT_MASKL) & \
  53. ~(1 << irq_source)), (void *)P_INT_MASKL);
  54. else
  55. __raw_writel((__raw_readl((void *)P_INT_MASKH) & \
  56. ~(1 << (irq_source - 32))), (void *)P_INT_MASKH);
  57. }
  58. struct irq_chip score_irq_chip = {
  59. .name = "Score7-level",
  60. .mask = score_mask,
  61. .mask_ack = score_mask,
  62. .unmask = score_unmask,
  63. };
  64. /*
  65. * initialise the interrupt system
  66. */
  67. void __init init_IRQ(void)
  68. {
  69. int index;
  70. unsigned long target_addr;
  71. for (index = 0; index < NR_IRQS; ++index)
  72. set_irq_chip_and_handler(index, &score_irq_chip,
  73. handle_level_irq);
  74. for (target_addr = IRQ_VECTOR_BASE_ADDR;
  75. target_addr <= IRQ_VECTOR_END_ADDR;
  76. target_addr += IRQ_VECTOR_SIZE)
  77. memcpy((void *)target_addr, \
  78. interrupt_exception_vector, IRQ_VECTOR_SIZE);
  79. __raw_writel(0xffffffff, (void *)P_INT_MASKL);
  80. __raw_writel(0xffffffff, (void *)P_INT_MASKH);
  81. __asm__ __volatile__(
  82. "mtcr %0, cr3\n\t"
  83. : : "r" (EXCEPTION_VECTOR_BASE_ADDR | \
  84. VECTOR_ADDRESS_OFFSET_MODE16));
  85. }
  86. /*
  87. * Generic, controller-independent functions:
  88. */
  89. int show_interrupts(struct seq_file *p, void *v)
  90. {
  91. int i = *(loff_t *)v, cpu;
  92. struct irqaction *action;
  93. unsigned long flags;
  94. if (i == 0) {
  95. seq_puts(p, " ");
  96. for_each_online_cpu(cpu)
  97. seq_printf(p, "CPU%d ", cpu);
  98. seq_putc(p, '\n');
  99. }
  100. if (i < NR_IRQS) {
  101. spin_lock_irqsave(&irq_desc[i].lock, flags);
  102. action = irq_desc[i].action;
  103. if (!action)
  104. goto unlock;
  105. seq_printf(p, "%3d: ", i);
  106. seq_printf(p, "%10u ", kstat_irqs(i));
  107. seq_printf(p, " %8s", irq_desc[i].chip->name ? : "-");
  108. seq_printf(p, " %s", action->name);
  109. for (action = action->next; action; action = action->next)
  110. seq_printf(p, ", %s", action->name);
  111. seq_putc(p, '\n');
  112. unlock:
  113. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  114. }
  115. return 0;
  116. }