irq-lpd7a40x.c 3.1 KB

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