irq.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * arch/arm/mach-iop33x/irq.c
  3. *
  4. * Generic IOP331 IRQ handling functionality
  5. *
  6. * Author: Dave Jiang <dave.jiang@intel.com>
  7. * Copyright (C) 2003 Intel Corp.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <asm/mach/irq.h>
  17. #include <asm/irq.h>
  18. #include <mach/hardware.h>
  19. #include <asm/mach-types.h>
  20. static u32 iop33x_mask0;
  21. static u32 iop33x_mask1;
  22. static void intctl0_write(u32 val)
  23. {
  24. asm volatile("mcr p6, 0, %0, c0, c0, 0" : : "r" (val));
  25. }
  26. static void intctl1_write(u32 val)
  27. {
  28. asm volatile("mcr p6, 0, %0, c1, c0, 0" : : "r" (val));
  29. }
  30. static void intstr0_write(u32 val)
  31. {
  32. asm volatile("mcr p6, 0, %0, c2, c0, 0" : : "r" (val));
  33. }
  34. static void intstr1_write(u32 val)
  35. {
  36. asm volatile("mcr p6, 0, %0, c3, c0, 0" : : "r" (val));
  37. }
  38. static void intbase_write(u32 val)
  39. {
  40. asm volatile("mcr p6, 0, %0, c12, c0, 0" : : "r" (val));
  41. }
  42. static void intsize_write(u32 val)
  43. {
  44. asm volatile("mcr p6, 0, %0, c13, c0, 0" : : "r" (val));
  45. }
  46. static void
  47. iop33x_irq_mask1 (struct irq_data *d)
  48. {
  49. iop33x_mask0 &= ~(1 << d->irq);
  50. intctl0_write(iop33x_mask0);
  51. }
  52. static void
  53. iop33x_irq_mask2 (struct irq_data *d)
  54. {
  55. iop33x_mask1 &= ~(1 << (d->irq - 32));
  56. intctl1_write(iop33x_mask1);
  57. }
  58. static void
  59. iop33x_irq_unmask1(struct irq_data *d)
  60. {
  61. iop33x_mask0 |= 1 << d->irq;
  62. intctl0_write(iop33x_mask0);
  63. }
  64. static void
  65. iop33x_irq_unmask2(struct irq_data *d)
  66. {
  67. iop33x_mask1 |= (1 << (d->irq - 32));
  68. intctl1_write(iop33x_mask1);
  69. }
  70. struct irq_chip iop33x_irqchip1 = {
  71. .name = "IOP33x-1",
  72. .irq_ack = iop33x_irq_mask1,
  73. .irq_mask = iop33x_irq_mask1,
  74. .irq_unmask = iop33x_irq_unmask1,
  75. };
  76. struct irq_chip iop33x_irqchip2 = {
  77. .name = "IOP33x-2",
  78. .irq_ack = iop33x_irq_mask2,
  79. .irq_mask = iop33x_irq_mask2,
  80. .irq_unmask = iop33x_irq_unmask2,
  81. };
  82. void __init iop33x_init_irq(void)
  83. {
  84. int i;
  85. iop_init_cp6_handler();
  86. intctl0_write(0);
  87. intctl1_write(0);
  88. intstr0_write(0);
  89. intstr1_write(0);
  90. intbase_write(0);
  91. intsize_write(1);
  92. if (machine_is_iq80331())
  93. *IOP3XX_PCIIRSR = 0x0f;
  94. for (i = 0; i < NR_IRQS; i++) {
  95. irq_set_chip_and_handler(i,
  96. (i < 32) ? &iop33x_irqchip1 : &iop33x_irqchip2,
  97. handle_level_irq);
  98. set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
  99. }
  100. }