irq-fpga.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* ASB2364 FPGA interrupt multiplexing
  2. *
  3. * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/interrupt.h>
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <unit/fpga-regs.h>
  15. /*
  16. * FPGA PIC operations
  17. */
  18. static void asb2364_fpga_mask(struct irq_data *d)
  19. {
  20. ASB2364_FPGA_REG_MASK(d->irq - NR_CPU_IRQS) = 0x0001;
  21. SyncExBus();
  22. }
  23. static void asb2364_fpga_ack(struct irq_data *d)
  24. {
  25. ASB2364_FPGA_REG_IRQ(d->irq - NR_CPU_IRQS) = 0x0001;
  26. SyncExBus();
  27. }
  28. static void asb2364_fpga_mask_ack(struct irq_data *d)
  29. {
  30. ASB2364_FPGA_REG_MASK(d->irq - NR_CPU_IRQS) = 0x0001;
  31. SyncExBus();
  32. ASB2364_FPGA_REG_IRQ(d->irq - NR_CPU_IRQS) = 0x0001;
  33. SyncExBus();
  34. }
  35. static void asb2364_fpga_unmask(struct irq_data *d)
  36. {
  37. ASB2364_FPGA_REG_MASK(d->irq - NR_CPU_IRQS) = 0x0000;
  38. SyncExBus();
  39. }
  40. static struct irq_chip asb2364_fpga_pic = {
  41. .name = "fpga",
  42. .irq_ack = asb2364_fpga_ack,
  43. .irq_mask = asb2364_fpga_mask,
  44. .irq_mask_ack = asb2364_fpga_mask_ack,
  45. .irq_unmask = asb2364_fpga_unmask,
  46. };
  47. /*
  48. * FPGA PIC interrupt handler
  49. */
  50. static irqreturn_t fpga_interrupt(int irq, void *_mask)
  51. {
  52. if ((ASB2364_FPGA_REG_IRQ_LAN & 0x0001) != 0x0001)
  53. generic_handle_irq(FPGA_LAN_IRQ);
  54. if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) != 0x0001)
  55. generic_handle_irq(FPGA_UART_IRQ);
  56. if ((ASB2364_FPGA_REG_IRQ_I2C & 0x0001) != 0x0001)
  57. generic_handle_irq(FPGA_I2C_IRQ);
  58. if ((ASB2364_FPGA_REG_IRQ_USB & 0x0001) != 0x0001)
  59. generic_handle_irq(FPGA_USB_IRQ);
  60. if ((ASB2364_FPGA_REG_IRQ_FPGA & 0x0001) != 0x0001)
  61. generic_handle_irq(FPGA_FPGA_IRQ);
  62. return IRQ_HANDLED;
  63. }
  64. /*
  65. * Define an interrupt action for each FPGA PIC output
  66. */
  67. static struct irqaction fpga_irq[] = {
  68. [0] = {
  69. .handler = fpga_interrupt,
  70. .flags = IRQF_SHARED,
  71. .name = "fpga",
  72. },
  73. };
  74. /*
  75. * Initialise the FPGA's PIC
  76. */
  77. void __init irq_fpga_init(void)
  78. {
  79. int irq;
  80. ASB2364_FPGA_REG_MASK_LAN = 0x0001;
  81. SyncExBus();
  82. ASB2364_FPGA_REG_MASK_UART = 0x0001;
  83. SyncExBus();
  84. ASB2364_FPGA_REG_MASK_I2C = 0x0001;
  85. SyncExBus();
  86. ASB2364_FPGA_REG_MASK_USB = 0x0001;
  87. SyncExBus();
  88. ASB2364_FPGA_REG_MASK_FPGA = 0x0001;
  89. SyncExBus();
  90. for (irq = NR_CPU_IRQS; irq < NR_IRQS; irq++)
  91. irq_set_chip_and_handler(irq, &asb2364_fpga_pic,
  92. handle_level_irq);
  93. /* the FPGA drives the XIRQ1 input on the CPU PIC */
  94. setup_irq(XIRQ1, &fpga_irq[0]);
  95. }