irq.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * arch/mips/emma2rh/markeins/irq.c
  3. * This file defines the irq handler for EMMA2RH.
  4. *
  5. * Copyright (C) NEC Electronics Corporation 2004-2006
  6. *
  7. * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c
  8. *
  9. * Copyright 2001 MontaVista Software Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/init.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/irq.h>
  28. #include <linux/types.h>
  29. #include <linux/ptrace.h>
  30. #include <linux/delay.h>
  31. #include <asm/irq_cpu.h>
  32. #include <asm/system.h>
  33. #include <asm/mipsregs.h>
  34. #include <asm/debug.h>
  35. #include <asm/addrspace.h>
  36. #include <asm/bootinfo.h>
  37. #include <asm/emma2rh/emma2rh.h>
  38. /*
  39. * IRQ mapping
  40. *
  41. * 0-7: 8 CPU interrupts
  42. * 0 - software interrupt 0
  43. * 1 - software interrupt 1
  44. * 2 - most Vrc5477 interrupts are routed to this pin
  45. * 3 - (optional) some other interrupts routed to this pin for debugg
  46. * 4 - not used
  47. * 5 - not used
  48. * 6 - not used
  49. * 7 - cpu timer (used by default)
  50. *
  51. */
  52. extern void emma2rh_sw_irq_init(u32 base);
  53. extern void emma2rh_gpio_irq_init(u32 base);
  54. extern void emma2rh_irq_init(u32 base);
  55. extern void emma2rh_irq_dispatch(void);
  56. static struct irqaction irq_cascade = {
  57. .handler = no_action,
  58. .flags = 0,
  59. .mask = CPU_MASK_NONE,
  60. .name = "cascade",
  61. .dev_id = NULL,
  62. .next = NULL,
  63. };
  64. void __init arch_init_irq(void)
  65. {
  66. u32 reg;
  67. db_run(printk("markeins_irq_setup invoked.\n"));
  68. /* by default, interrupts are disabled. */
  69. emma2rh_out32(EMMA2RH_BHIF_INT_EN_0, 0);
  70. emma2rh_out32(EMMA2RH_BHIF_INT_EN_1, 0);
  71. emma2rh_out32(EMMA2RH_BHIF_INT_EN_2, 0);
  72. emma2rh_out32(EMMA2RH_BHIF_INT1_EN_0, 0);
  73. emma2rh_out32(EMMA2RH_BHIF_INT1_EN_1, 0);
  74. emma2rh_out32(EMMA2RH_BHIF_INT1_EN_2, 0);
  75. emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, 0);
  76. clear_c0_status(0xff00);
  77. set_c0_status(0x0400);
  78. #define GPIO_PCI (0xf<<15)
  79. /* setup GPIO interrupt for PCI interface */
  80. /* direction input */
  81. reg = emma2rh_in32(EMMA2RH_GPIO_DIR);
  82. emma2rh_out32(EMMA2RH_GPIO_DIR, reg & ~GPIO_PCI);
  83. /* disable interrupt */
  84. reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
  85. emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg & ~GPIO_PCI);
  86. /* level triggerd */
  87. reg = emma2rh_in32(EMMA2RH_GPIO_INT_MODE);
  88. emma2rh_out32(EMMA2RH_GPIO_INT_MODE, reg | GPIO_PCI);
  89. reg = emma2rh_in32(EMMA2RH_GPIO_INT_CND_A);
  90. emma2rh_out32(EMMA2RH_GPIO_INT_CND_A, reg & (~GPIO_PCI));
  91. /* interrupt clear */
  92. emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~GPIO_PCI);
  93. /* init all controllers */
  94. emma2rh_irq_init(EMMA2RH_IRQ_BASE);
  95. emma2rh_sw_irq_init(EMMA2RH_SW_IRQ_BASE);
  96. emma2rh_gpio_irq_init(EMMA2RH_GPIO_IRQ_BASE);
  97. mips_cpu_irq_init();
  98. /* setup cascade interrupts */
  99. setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_SW_CASCADE, &irq_cascade);
  100. setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_GPIO_CASCADE, &irq_cascade);
  101. setup_irq(CPU_IRQ_BASE + CPU_EMMA2RH_CASCADE, &irq_cascade);
  102. }
  103. asmlinkage void plat_irq_dispatch(void)
  104. {
  105. unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
  106. if (pending & STATUSF_IP7)
  107. do_IRQ(CPU_IRQ_BASE + 7);
  108. else if (pending & STATUSF_IP2)
  109. emma2rh_irq_dispatch();
  110. else if (pending & STATUSF_IP1)
  111. do_IRQ(CPU_IRQ_BASE + 1);
  112. else if (pending & STATUSF_IP0)
  113. do_IRQ(CPU_IRQ_BASE + 0);
  114. else
  115. spurious_interrupt();
  116. }