irq.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * linux/arch/arm/mach-shark/irq.c
  3. *
  4. * by Alexander Schulz
  5. *
  6. * derived from linux/arch/ppc/kernel/i8259.c and:
  7. * arch/arm/mach-ebsa110/include/mach/irq.h
  8. * Copyright (C) 1996-1998 Russell King
  9. */
  10. #include <linux/init.h>
  11. #include <linux/fs.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/io.h>
  14. #include <asm/irq.h>
  15. #include <asm/mach/irq.h>
  16. /*
  17. * 8259A PIC functions to handle ISA devices:
  18. */
  19. /*
  20. * This contains the irq mask for both 8259A irq controllers,
  21. * Let through the cascade-interrupt no. 2 (ff-(1<<2)==fb)
  22. */
  23. static unsigned char cached_irq_mask[2] = { 0xfb, 0xff };
  24. /*
  25. * These have to be protected by the irq controller spinlock
  26. * before being called.
  27. */
  28. static void shark_disable_8259A_irq(struct irq_data *d)
  29. {
  30. unsigned int mask;
  31. if (d->irq<8) {
  32. mask = 1 << d->irq;
  33. cached_irq_mask[0] |= mask;
  34. outb(cached_irq_mask[1],0xA1);
  35. } else {
  36. mask = 1 << (d->irq-8);
  37. cached_irq_mask[1] |= mask;
  38. outb(cached_irq_mask[0],0x21);
  39. }
  40. }
  41. static void shark_enable_8259A_irq(struct irq_data *d)
  42. {
  43. unsigned int mask;
  44. if (d->irq<8) {
  45. mask = ~(1 << d->irq);
  46. cached_irq_mask[0] &= mask;
  47. outb(cached_irq_mask[0],0x21);
  48. } else {
  49. mask = ~(1 << (d->irq-8));
  50. cached_irq_mask[1] &= mask;
  51. outb(cached_irq_mask[1],0xA1);
  52. }
  53. }
  54. static void shark_ack_8259A_irq(struct irq_data *d){}
  55. static irqreturn_t bogus_int(int irq, void *dev_id)
  56. {
  57. printk("Got interrupt %i!\n",irq);
  58. return IRQ_NONE;
  59. }
  60. static struct irqaction cascade;
  61. static struct irq_chip fb_chip = {
  62. .name = "XT-PIC",
  63. .irq_ack = shark_ack_8259A_irq,
  64. .irq_mask = shark_disable_8259A_irq,
  65. .irq_unmask = shark_enable_8259A_irq,
  66. };
  67. void __init shark_init_irq(void)
  68. {
  69. int irq;
  70. for (irq = 0; irq < NR_IRQS; irq++) {
  71. irq_set_chip_and_handler(irq, &fb_chip, handle_edge_irq);
  72. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  73. }
  74. /* init master interrupt controller */
  75. outb(0x11, 0x20); /* Start init sequence, edge triggered (level: 0x19)*/
  76. outb(0x00, 0x21); /* Vector base */
  77. outb(0x04, 0x21); /* Cascade (slave) on IRQ2 */
  78. outb(0x03, 0x21); /* Select 8086 mode , auto eoi*/
  79. outb(0x0A, 0x20);
  80. /* init slave interrupt controller */
  81. outb(0x11, 0xA0); /* Start init sequence, edge triggered */
  82. outb(0x08, 0xA1); /* Vector base */
  83. outb(0x02, 0xA1); /* Cascade (slave) on IRQ2 */
  84. outb(0x03, 0xA1); /* Select 8086 mode, auto eoi */
  85. outb(0x0A, 0xA0);
  86. outb(cached_irq_mask[1],0xA1);
  87. outb(cached_irq_mask[0],0x21);
  88. //request_region(0x20,0x2,"pic1");
  89. //request_region(0xA0,0x2,"pic2");
  90. cascade.handler = bogus_int;
  91. cascade.name = "cascade";
  92. setup_irq(2,&cascade);
  93. }