irq.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* $Id: irq.h,v 1.21 2002/01/23 11:27:36 davem Exp $
  2. * irq.h: IRQ registers on the 64-bit Sparc.
  3. *
  4. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
  6. */
  7. #ifndef _SPARC64_IRQ_H
  8. #define _SPARC64_IRQ_H
  9. #include <linux/config.h>
  10. #include <linux/linkage.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/interrupt.h>
  14. #include <asm/pil.h>
  15. #include <asm/ptrace.h>
  16. /* You should not mess with this directly. That's the job of irq.c.
  17. *
  18. * If you make changes here, please update hand coded assembler of
  19. * SBUS/floppy interrupt handler in entry.S -DaveM
  20. *
  21. * This is currently one DCACHE line, two buckets per L2 cache
  22. * line. Keep this in mind please.
  23. */
  24. struct ino_bucket {
  25. /* Next handler in per-CPU PIL worklist. We know that
  26. * bucket pointers have the high 32-bits clear, so to
  27. * save space we only store the bits we need.
  28. */
  29. /*0x00*/unsigned int irq_chain;
  30. /* PIL to schedule this IVEC at. */
  31. /*0x04*/unsigned char pil;
  32. /* If an IVEC arrives while irq_info is NULL, we
  33. * set this to notify request_irq() about the event.
  34. */
  35. /*0x05*/unsigned char pending;
  36. /* Miscellaneous flags. */
  37. /*0x06*/unsigned char flags;
  38. /* This is used to deal with IBF_DMA_SYNC on
  39. * Sabre systems.
  40. */
  41. /*0x07*/unsigned char synctab_ent;
  42. /* Reference to handler for this IRQ. If this is
  43. * non-NULL this means it is active and should be
  44. * serviced. Else the pending member is set to one
  45. * and later registry of the interrupt checks for
  46. * this condition.
  47. *
  48. * Normally this is just an irq_action structure.
  49. * But, on PCI, if multiple interrupt sources behind
  50. * a bridge have multiple interrupt sources that share
  51. * the same INO bucket, this points to an array of
  52. * pointers to four IRQ action structures.
  53. */
  54. /*0x08*/void *irq_info;
  55. /* Sun5 Interrupt Clear Register. */
  56. /*0x10*/unsigned long iclr;
  57. /* Sun5 Interrupt Mapping Register. */
  58. /*0x18*/unsigned long imap;
  59. };
  60. #ifdef CONFIG_PCI
  61. extern unsigned long pci_dma_wsync;
  62. extern unsigned long dma_sync_reg_table[256];
  63. extern unsigned char dma_sync_reg_table_entry;
  64. #endif
  65. /* IMAP/ICLR register defines */
  66. #define IMAP_VALID 0x80000000 /* IRQ Enabled */
  67. #define IMAP_TID_UPA 0x7c000000 /* UPA TargetID */
  68. #define IMAP_TID_JBUS 0x7c000000 /* JBUS TargetID */
  69. #define IMAP_AID_SAFARI 0x7c000000 /* Safari AgentID */
  70. #define IMAP_NID_SAFARI 0x03e00000 /* Safari NodeID */
  71. #define IMAP_IGN 0x000007c0 /* IRQ Group Number */
  72. #define IMAP_INO 0x0000003f /* IRQ Number */
  73. #define IMAP_INR 0x000007ff /* Full interrupt number*/
  74. #define ICLR_IDLE 0x00000000 /* Idle state */
  75. #define ICLR_TRANSMIT 0x00000001 /* Transmit state */
  76. #define ICLR_PENDING 0x00000003 /* Pending state */
  77. /* Only 8-bits are available, be careful. -DaveM */
  78. #define IBF_DMA_SYNC 0x01 /* DMA synchronization behind PCI bridge needed. */
  79. #define IBF_PCI 0x02 /* Indicates PSYCHO/SABRE/SCHIZO PCI interrupt. */
  80. #define IBF_ACTIVE 0x04 /* This interrupt is active and has a handler. */
  81. #define IBF_MULTI 0x08 /* On PCI, indicates shared bucket. */
  82. #define IBF_INPROGRESS 0x10 /* IRQ is being serviced. */
  83. #define NUM_IVECS (IMAP_INR + 1)
  84. extern struct ino_bucket ivector_table[NUM_IVECS];
  85. #define __irq_ino(irq) \
  86. (((struct ino_bucket *)(unsigned long)(irq)) - &ivector_table[0])
  87. #define __irq_pil(irq) ((struct ino_bucket *)(unsigned long)(irq))->pil
  88. #define __bucket(irq) ((struct ino_bucket *)(unsigned long)(irq))
  89. #define __irq(bucket) ((unsigned int)(unsigned long)(bucket))
  90. static __inline__ char *__irq_itoa(unsigned int irq)
  91. {
  92. static char buff[16];
  93. sprintf(buff, "%d,%x", __irq_pil(irq), (unsigned int)__irq_ino(irq));
  94. return buff;
  95. }
  96. #define NR_IRQS 16
  97. #define irq_canonicalize(irq) (irq)
  98. extern void disable_irq(unsigned int);
  99. #define disable_irq_nosync disable_irq
  100. extern void enable_irq(unsigned int);
  101. extern unsigned int build_irq(int pil, int inofixup, unsigned long iclr, unsigned long imap);
  102. extern unsigned int sbus_build_irq(void *sbus, unsigned int ino);
  103. extern int request_fast_irq(unsigned int irq,
  104. irqreturn_t (*handler)(int, void *, struct pt_regs *),
  105. unsigned long flags, __const__ char *devname,
  106. void *dev_id);
  107. static __inline__ void set_softint(unsigned long bits)
  108. {
  109. __asm__ __volatile__("wr %0, 0x0, %%set_softint"
  110. : /* No outputs */
  111. : "r" (bits));
  112. }
  113. static __inline__ void clear_softint(unsigned long bits)
  114. {
  115. __asm__ __volatile__("wr %0, 0x0, %%clear_softint"
  116. : /* No outputs */
  117. : "r" (bits));
  118. }
  119. static __inline__ unsigned long get_softint(void)
  120. {
  121. unsigned long retval;
  122. __asm__ __volatile__("rd %%softint, %0"
  123. : "=r" (retval));
  124. return retval;
  125. }
  126. struct irqaction;
  127. struct pt_regs;
  128. int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
  129. #endif