irq.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * linux/arch/arm/mach-pxa/irq.c
  3. *
  4. * Generic PXA IRQ handling
  5. *
  6. * Author: Nicolas Pitre
  7. * Created: Jun 15, 2001
  8. * Copyright: MontaVista Software Inc.
  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 version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/module.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/sysdev.h>
  18. #include <asm/hardware.h>
  19. #include <asm/irq.h>
  20. #include <asm/mach/irq.h>
  21. #include <asm/arch/pxa-regs.h>
  22. #include "generic.h"
  23. /*
  24. * This is for peripheral IRQs internal to the PXA chip.
  25. */
  26. static void pxa_mask_low_irq(unsigned int irq)
  27. {
  28. ICMR &= ~(1 << irq);
  29. }
  30. static void pxa_unmask_low_irq(unsigned int irq)
  31. {
  32. ICMR |= (1 << irq);
  33. }
  34. static struct irq_chip pxa_internal_chip_low = {
  35. .name = "SC",
  36. .ack = pxa_mask_low_irq,
  37. .mask = pxa_mask_low_irq,
  38. .unmask = pxa_unmask_low_irq,
  39. };
  40. void __init pxa_init_irq_low(void)
  41. {
  42. int irq;
  43. /* disable all IRQs */
  44. ICMR = 0;
  45. /* all IRQs are IRQ, not FIQ */
  46. ICLR = 0;
  47. /* only unmasked interrupts kick us out of idle */
  48. ICCR = 1;
  49. for (irq = PXA_IRQ(0); irq <= PXA_IRQ(31); irq++) {
  50. set_irq_chip(irq, &pxa_internal_chip_low);
  51. set_irq_handler(irq, handle_level_irq);
  52. set_irq_flags(irq, IRQF_VALID);
  53. }
  54. }
  55. #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  56. /*
  57. * This is for the second set of internal IRQs as found on the PXA27x.
  58. */
  59. static void pxa_mask_high_irq(unsigned int irq)
  60. {
  61. ICMR2 &= ~(1 << (irq - 32));
  62. }
  63. static void pxa_unmask_high_irq(unsigned int irq)
  64. {
  65. ICMR2 |= (1 << (irq - 32));
  66. }
  67. static struct irq_chip pxa_internal_chip_high = {
  68. .name = "SC-hi",
  69. .ack = pxa_mask_high_irq,
  70. .mask = pxa_mask_high_irq,
  71. .unmask = pxa_unmask_high_irq,
  72. };
  73. void __init pxa_init_irq_high(void)
  74. {
  75. int irq;
  76. ICMR2 = 0;
  77. ICLR2 = 0;
  78. for (irq = PXA_IRQ(32); irq < PXA_IRQ(64); irq++) {
  79. set_irq_chip(irq, &pxa_internal_chip_high);
  80. set_irq_handler(irq, handle_level_irq);
  81. set_irq_flags(irq, IRQF_VALID);
  82. }
  83. }
  84. #endif
  85. void __init pxa_init_irq_set_wake(int (*set_wake)(unsigned int, unsigned int))
  86. {
  87. pxa_internal_chip_low.set_wake = set_wake;
  88. #ifdef CONFIG_PXA27x
  89. pxa_internal_chip_high.set_wake = set_wake;
  90. #endif
  91. pxa_init_gpio_set_wake(set_wake);
  92. }
  93. #ifdef CONFIG_PM
  94. static unsigned long saved_icmr[2];
  95. static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state)
  96. {
  97. switch (dev->id) {
  98. case 0:
  99. saved_icmr[0] = ICMR;
  100. ICMR = 0;
  101. break;
  102. #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  103. case 1:
  104. saved_icmr[1] = ICMR2;
  105. ICMR2 = 0;
  106. break;
  107. #endif
  108. default:
  109. return -EINVAL;
  110. }
  111. return 0;
  112. }
  113. static int pxa_irq_resume(struct sys_device *dev)
  114. {
  115. switch (dev->id) {
  116. case 0:
  117. ICMR = saved_icmr[0];
  118. ICLR = 0;
  119. ICCR = 1;
  120. break;
  121. #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  122. case 1:
  123. ICMR2 = saved_icmr[1];
  124. ICLR2 = 0;
  125. break;
  126. #endif
  127. default:
  128. return -EINVAL;
  129. }
  130. return 0;
  131. }
  132. #else
  133. #define pxa_irq_suspend NULL
  134. #define pxa_irq_resume NULL
  135. #endif
  136. struct sysdev_class pxa_irq_sysclass = {
  137. .name = "irq",
  138. .suspend = pxa_irq_suspend,
  139. .resume = pxa_irq_resume,
  140. };
  141. static int __init pxa_irq_init(void)
  142. {
  143. return sysdev_class_register(&pxa_irq_sysclass);
  144. }
  145. core_initcall(pxa_irq_init);