irq.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * arch/arm/mach-pnx4008/irq.c
  3. *
  4. * PNX4008 IRQ controller driver
  5. *
  6. * Author: Dmitry Chigirev <source@mvista.com>
  7. *
  8. * Based on reference code received from Philips:
  9. * Copyright (C) 2003 Philips Semiconductors
  10. *
  11. * 2005 (c) MontaVista Software, Inc. This file is licensed under
  12. * the terms of the GNU General Public License version 2. This program
  13. * is licensed "as is" without any warranty of any kind, whether express
  14. * or implied.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #include <linux/mm.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/list.h>
  21. #include <linux/init.h>
  22. #include <linux/ioport.h>
  23. #include <linux/device.h>
  24. #include <linux/irq.h>
  25. #include <linux/io.h>
  26. #include <mach/hardware.h>
  27. #include <asm/setup.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/page.h>
  30. #include <asm/system.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/irq.h>
  33. #include <asm/mach/map.h>
  34. #include <mach/irq.h>
  35. static u8 pnx4008_irq_type[NR_IRQS] = PNX4008_IRQ_TYPES;
  36. static void pnx4008_mask_irq(struct irq_data *d)
  37. {
  38. __raw_writel(__raw_readl(INTC_ER(d->irq)) & ~INTC_BIT(d->irq), INTC_ER(d->irq)); /* mask interrupt */
  39. }
  40. static void pnx4008_unmask_irq(struct irq_data *d)
  41. {
  42. __raw_writel(__raw_readl(INTC_ER(d->irq)) | INTC_BIT(d->irq), INTC_ER(d->irq)); /* unmask interrupt */
  43. }
  44. static void pnx4008_mask_ack_irq(struct irq_data *d)
  45. {
  46. __raw_writel(__raw_readl(INTC_ER(d->irq)) & ~INTC_BIT(d->irq), INTC_ER(d->irq)); /* mask interrupt */
  47. __raw_writel(INTC_BIT(d->irq), INTC_SR(d->irq)); /* clear interrupt status */
  48. }
  49. static int pnx4008_set_irq_type(struct irq_data *d, unsigned int type)
  50. {
  51. switch (type) {
  52. case IRQ_TYPE_EDGE_RISING:
  53. __raw_writel(__raw_readl(INTC_ATR(d->irq)) | INTC_BIT(d->irq), INTC_ATR(d->irq)); /*edge sensitive */
  54. __raw_writel(__raw_readl(INTC_APR(d->irq)) | INTC_BIT(d->irq), INTC_APR(d->irq)); /*rising edge */
  55. irq_set_handler(d->irq, handle_edge_irq);
  56. break;
  57. case IRQ_TYPE_EDGE_FALLING:
  58. __raw_writel(__raw_readl(INTC_ATR(d->irq)) | INTC_BIT(d->irq), INTC_ATR(d->irq)); /*edge sensitive */
  59. __raw_writel(__raw_readl(INTC_APR(d->irq)) & ~INTC_BIT(d->irq), INTC_APR(d->irq)); /*falling edge */
  60. irq_set_handler(d->irq, handle_edge_irq);
  61. break;
  62. case IRQ_TYPE_LEVEL_LOW:
  63. __raw_writel(__raw_readl(INTC_ATR(d->irq)) & ~INTC_BIT(d->irq), INTC_ATR(d->irq)); /*level sensitive */
  64. __raw_writel(__raw_readl(INTC_APR(d->irq)) & ~INTC_BIT(d->irq), INTC_APR(d->irq)); /*low level */
  65. irq_set_handler(d->irq, handle_level_irq);
  66. break;
  67. case IRQ_TYPE_LEVEL_HIGH:
  68. __raw_writel(__raw_readl(INTC_ATR(d->irq)) & ~INTC_BIT(d->irq), INTC_ATR(d->irq)); /*level sensitive */
  69. __raw_writel(__raw_readl(INTC_APR(d->irq)) | INTC_BIT(d->irq), INTC_APR(d->irq)); /* high level */
  70. irq_set_handler(d->irq, handle_level_irq);
  71. break;
  72. /* IRQ_TYPE_EDGE_BOTH is not supported */
  73. default:
  74. printk(KERN_ERR "PNX4008 IRQ: Unsupported irq type %d\n", type);
  75. return -1;
  76. }
  77. return 0;
  78. }
  79. static struct irq_chip pnx4008_irq_chip = {
  80. .irq_ack = pnx4008_mask_ack_irq,
  81. .irq_mask = pnx4008_mask_irq,
  82. .irq_unmask = pnx4008_unmask_irq,
  83. .irq_set_type = pnx4008_set_irq_type,
  84. };
  85. void __init pnx4008_init_irq(void)
  86. {
  87. unsigned int i;
  88. /* configure IRQ's */
  89. for (i = 0; i < NR_IRQS; i++) {
  90. set_irq_flags(i, IRQF_VALID);
  91. irq_set_chip(i, &pnx4008_irq_chip);
  92. pnx4008_set_irq_type(irq_get_irq_data(i), pnx4008_irq_type[i]);
  93. }
  94. /* configure and enable IRQ 0,1,30,31 (cascade interrupts) */
  95. pnx4008_set_irq_type(irq_get_irq_data(SUB1_IRQ_N),
  96. pnx4008_irq_type[SUB1_IRQ_N]);
  97. pnx4008_set_irq_type(irq_get_irq_data(SUB2_IRQ_N),
  98. pnx4008_irq_type[SUB2_IRQ_N]);
  99. pnx4008_set_irq_type(irq_get_irq_data(SUB1_FIQ_N),
  100. pnx4008_irq_type[SUB1_FIQ_N]);
  101. pnx4008_set_irq_type(irq_get_irq_data(SUB2_FIQ_N),
  102. pnx4008_irq_type[SUB2_FIQ_N]);
  103. /* mask all others */
  104. __raw_writel((1 << SUB2_FIQ_N) | (1 << SUB1_FIQ_N) |
  105. (1 << SUB2_IRQ_N) | (1 << SUB1_IRQ_N),
  106. INTC_ER(MAIN_BASE_INT));
  107. __raw_writel(0, INTC_ER(SIC1_BASE_INT));
  108. __raw_writel(0, INTC_ER(SIC2_BASE_INT));
  109. }