irq.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Interrupt handler for DaVinci boards.
  3. *
  4. * Copyright (C) 2006 Texas Instruments.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/io.h>
  26. #include <mach/hardware.h>
  27. #include <mach/cputype.h>
  28. #include <mach/common.h>
  29. #include <asm/mach/irq.h>
  30. #define FIQ_REG0_OFFSET 0x0000
  31. #define FIQ_REG1_OFFSET 0x0004
  32. #define IRQ_REG0_OFFSET 0x0008
  33. #define IRQ_REG1_OFFSET 0x000C
  34. #define IRQ_ENT_REG0_OFFSET 0x0018
  35. #define IRQ_ENT_REG1_OFFSET 0x001C
  36. #define IRQ_INCTL_REG_OFFSET 0x0020
  37. #define IRQ_EABASE_REG_OFFSET 0x0024
  38. #define IRQ_INTPRI0_REG_OFFSET 0x0030
  39. #define IRQ_INTPRI7_REG_OFFSET 0x004C
  40. static inline void davinci_irq_writel(unsigned long value, int offset)
  41. {
  42. __raw_writel(value, davinci_intc_base + offset);
  43. }
  44. static __init void
  45. davinci_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num)
  46. {
  47. struct irq_chip_generic *gc;
  48. struct irq_chip_type *ct;
  49. gc = irq_alloc_generic_chip("AINTC", 1, irq_start, base, handle_edge_irq);
  50. if (!gc) {
  51. pr_err("%s: irq_alloc_generic_chip for IRQ %u failed\n",
  52. __func__, irq_start);
  53. return;
  54. }
  55. ct = gc->chip_types;
  56. ct->chip.irq_ack = irq_gc_ack_set_bit;
  57. ct->chip.irq_mask = irq_gc_mask_clr_bit;
  58. ct->chip.irq_unmask = irq_gc_mask_set_bit;
  59. ct->regs.ack = IRQ_REG0_OFFSET;
  60. ct->regs.mask = IRQ_ENT_REG0_OFFSET;
  61. irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE,
  62. IRQ_NOREQUEST | IRQ_NOPROBE, 0);
  63. }
  64. /* ARM Interrupt Controller Initialization */
  65. void __init davinci_irq_init(void)
  66. {
  67. unsigned i, j;
  68. const u8 *davinci_def_priorities = davinci_soc_info.intc_irq_prios;
  69. davinci_intc_type = DAVINCI_INTC_TYPE_AINTC;
  70. davinci_intc_base = ioremap(davinci_soc_info.intc_base, SZ_4K);
  71. if (WARN_ON(!davinci_intc_base))
  72. return;
  73. /* Clear all interrupt requests */
  74. davinci_irq_writel(~0x0, FIQ_REG0_OFFSET);
  75. davinci_irq_writel(~0x0, FIQ_REG1_OFFSET);
  76. davinci_irq_writel(~0x0, IRQ_REG0_OFFSET);
  77. davinci_irq_writel(~0x0, IRQ_REG1_OFFSET);
  78. /* Disable all interrupts */
  79. davinci_irq_writel(0x0, IRQ_ENT_REG0_OFFSET);
  80. davinci_irq_writel(0x0, IRQ_ENT_REG1_OFFSET);
  81. /* Interrupts disabled immediately, IRQ entry reflects all */
  82. davinci_irq_writel(0x0, IRQ_INCTL_REG_OFFSET);
  83. /* we don't use the hardware vector table, just its entry addresses */
  84. davinci_irq_writel(0, IRQ_EABASE_REG_OFFSET);
  85. /* Clear all interrupt requests */
  86. davinci_irq_writel(~0x0, FIQ_REG0_OFFSET);
  87. davinci_irq_writel(~0x0, FIQ_REG1_OFFSET);
  88. davinci_irq_writel(~0x0, IRQ_REG0_OFFSET);
  89. davinci_irq_writel(~0x0, IRQ_REG1_OFFSET);
  90. for (i = IRQ_INTPRI0_REG_OFFSET; i <= IRQ_INTPRI7_REG_OFFSET; i += 4) {
  91. u32 pri;
  92. for (j = 0, pri = 0; j < 32; j += 4, davinci_def_priorities++)
  93. pri |= (*davinci_def_priorities & 0x07) << j;
  94. davinci_irq_writel(pri, i);
  95. }
  96. for (i = 0, j = 0; i < davinci_soc_info.intc_irq_num; i += 32, j += 0x04)
  97. davinci_alloc_gc(davinci_intc_base + j, i, 32);
  98. irq_set_handler(IRQ_TINT1_TINT34, handle_level_irq);
  99. }