vic.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * linux/arch/arm/common/vic.c
  3. *
  4. * Copyright (C) 1999 - 2003 ARM Limited
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/init.h>
  22. #include <linux/list.h>
  23. #include <asm/io.h>
  24. #include <asm/irq.h>
  25. #include <asm/mach/irq.h>
  26. #include <asm/hardware/vic.h>
  27. static void __iomem *vic_base;
  28. static void vic_mask_irq(unsigned int irq)
  29. {
  30. irq -= IRQ_VIC_START;
  31. writel(1 << irq, vic_base + VIC_INT_ENABLE_CLEAR);
  32. }
  33. static void vic_unmask_irq(unsigned int irq)
  34. {
  35. irq -= IRQ_VIC_START;
  36. writel(1 << irq, vic_base + VIC_INT_ENABLE);
  37. }
  38. static struct irqchip vic_chip = {
  39. .ack = vic_mask_irq,
  40. .mask = vic_mask_irq,
  41. .unmask = vic_unmask_irq,
  42. };
  43. void __init vic_init(void __iomem *base, u32 vic_sources)
  44. {
  45. unsigned int i;
  46. vic_base = base;
  47. /* Disable all interrupts initially. */
  48. writel(0, vic_base + VIC_INT_SELECT);
  49. writel(0, vic_base + VIC_INT_ENABLE);
  50. writel(~0, vic_base + VIC_INT_ENABLE_CLEAR);
  51. writel(0, vic_base + VIC_IRQ_STATUS);
  52. writel(0, vic_base + VIC_ITCR);
  53. writel(~0, vic_base + VIC_INT_SOFT_CLEAR);
  54. /*
  55. * Make sure we clear all existing interrupts
  56. */
  57. writel(0, vic_base + VIC_VECT_ADDR);
  58. for (i = 0; i < 19; i++) {
  59. unsigned int value;
  60. value = readl(vic_base + VIC_VECT_ADDR);
  61. writel(value, vic_base + VIC_VECT_ADDR);
  62. }
  63. for (i = 0; i < 16; i++) {
  64. void __iomem *reg = vic_base + VIC_VECT_CNTL0 + (i * 4);
  65. writel(VIC_VECT_CNTL_ENABLE | i, reg);
  66. }
  67. writel(32, vic_base + VIC_DEF_VECT_ADDR);
  68. for (i = 0; i < 32; i++) {
  69. unsigned int irq = IRQ_VIC_START + i;
  70. set_irq_chip(irq, &vic_chip);
  71. if (vic_sources & (1 << i)) {
  72. set_irq_handler(irq, do_level_IRQ);
  73. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  74. }
  75. }
  76. }