irq-lpd7a40x.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* arch/arm/mach-lh7a40x/irq-lpd7a40x.c
  2. *
  3. * Copyright (C) 2004 Coastal Environmental Systems
  4. * Copyright (C) 2004 Logic Product Development
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/init.h>
  12. #include <linux/module.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/ptrace.h>
  15. #include <asm/hardware.h>
  16. #include <asm/irq.h>
  17. #include <asm/mach/irq.h>
  18. #include <asm/arch/irqs.h>
  19. #include "common.h"
  20. static void lh7a40x_ack_cpld_irq (u32 irq)
  21. {
  22. /* CPLD doesn't have ack capability */
  23. }
  24. static void lh7a40x_mask_cpld_irq (u32 irq)
  25. {
  26. switch (irq) {
  27. case IRQ_LPD7A40X_ETH_INT:
  28. CPLD_INTERRUPTS = CPLD_INTERRUPTS | 0x4;
  29. break;
  30. case IRQ_LPD7A400_TS:
  31. CPLD_INTERRUPTS = CPLD_INTERRUPTS | 0x8;
  32. break;
  33. }
  34. }
  35. static void lh7a40x_unmask_cpld_irq (u32 irq)
  36. {
  37. switch (irq) {
  38. case IRQ_LPD7A40X_ETH_INT:
  39. CPLD_INTERRUPTS = CPLD_INTERRUPTS & ~ 0x4;
  40. break;
  41. case IRQ_LPD7A400_TS:
  42. CPLD_INTERRUPTS = CPLD_INTERRUPTS & ~ 0x8;
  43. break;
  44. }
  45. }
  46. static struct irq_chip lh7a40x_cpld_chip = {
  47. .name = "CPLD",
  48. .ack = lh7a40x_ack_cpld_irq,
  49. .mask = lh7a40x_mask_cpld_irq,
  50. .unmask = lh7a40x_unmask_cpld_irq,
  51. };
  52. static void lh7a40x_cpld_handler (unsigned int irq, struct irqdesc *desc)
  53. {
  54. unsigned int mask = CPLD_INTERRUPTS;
  55. desc->chip->ack (irq);
  56. if ((mask & 0x1) == 0) /* WLAN */
  57. IRQ_DISPATCH (IRQ_LPD7A40X_ETH_INT);
  58. if ((mask & 0x2) == 0) /* Touch */
  59. IRQ_DISPATCH (IRQ_LPD7A400_TS);
  60. desc->chip->unmask (irq); /* Level-triggered need this */
  61. }
  62. /* IRQ initialization */
  63. void __init lh7a40x_init_board_irq (void)
  64. {
  65. int irq;
  66. /* Rev A (v2.8): PF0, PF1, PF2, and PF3 are available IRQs.
  67. PF7 supports the CPLD.
  68. Rev B (v3.4): PF0, PF1, and PF2 are available IRQs.
  69. PF3 supports the CPLD.
  70. (Some) LPD7A404 prerelease boards report a version
  71. number of 0x16, but we force an override since the
  72. hardware is of the newer variety.
  73. */
  74. unsigned char cpld_version = CPLD_REVISION;
  75. int pinCPLD;
  76. #if defined CONFIG_MACH_LPD7A404
  77. cpld_version = 0x34; /* Override, for now */
  78. #endif
  79. pinCPLD = (cpld_version == 0x28) ? 7 : 3;
  80. /* First, configure user controlled GPIOF interrupts */
  81. GPIO_PFDD &= ~0x0f; /* PF0-3 are inputs */
  82. GPIO_INTTYPE1 &= ~0x0f; /* PF0-3 are level triggered */
  83. GPIO_INTTYPE2 &= ~0x0f; /* PF0-3 are active low */
  84. barrier ();
  85. GPIO_GPIOFINTEN |= 0x0f; /* Enable PF0, PF1, PF2, and PF3 IRQs */
  86. /* Then, configure CPLD interrupt */
  87. CPLD_INTERRUPTS = 0x0c; /* Disable all CPLD interrupts */
  88. GPIO_PFDD &= ~(1 << pinCPLD); /* Make input */
  89. GPIO_INTTYPE1 |= (1 << pinCPLD); /* Edge triggered */
  90. GPIO_INTTYPE2 &= ~(1 << pinCPLD); /* Active low */
  91. barrier ();
  92. GPIO_GPIOFINTEN |= (1 << pinCPLD); /* Enable */
  93. /* Cascade CPLD interrupts */
  94. for (irq = IRQ_BOARD_START;
  95. irq < IRQ_BOARD_START + NR_IRQ_BOARD; ++irq) {
  96. set_irq_chip (irq, &lh7a40x_cpld_chip);
  97. set_irq_handler (irq, do_edge_IRQ);
  98. set_irq_flags (irq, IRQF_VALID);
  99. }
  100. set_irq_chained_handler ((cpld_version == 0x28)
  101. ? IRQ_CPLD_V28
  102. : IRQ_CPLD_V34,
  103. lh7a40x_cpld_handler);
  104. }