irq.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. struct ino_bucket;
  17. #define MAX_IRQ_DESC_ACTION 4
  18. struct irq_desc {
  19. void (*pre_handler)(struct ino_bucket *, void *, void *);
  20. void *pre_handler_arg1;
  21. void *pre_handler_arg2;
  22. u32 action_active_mask;
  23. struct irqaction action[MAX_IRQ_DESC_ACTION];
  24. };
  25. /* You should not mess with this directly. That's the job of irq.c.
  26. *
  27. * If you make changes here, please update hand coded assembler of
  28. * the vectored interrupt trap handler in entry.S -DaveM
  29. *
  30. * This is currently one DCACHE line, two buckets per L2 cache
  31. * line. Keep this in mind please.
  32. */
  33. struct ino_bucket {
  34. /* Next handler in per-CPU IRQ worklist. We know that
  35. * bucket pointers have the high 32-bits clear, so to
  36. * save space we only store the bits we need.
  37. */
  38. /*0x00*/unsigned int irq_chain;
  39. /* Virtual interrupt number assigned to this INO. */
  40. /*0x04*/unsigned char virt_irq;
  41. /* If an IVEC arrives while irq_info is NULL, we
  42. * set this to notify request_irq() about the event.
  43. */
  44. /*0x05*/unsigned char pending;
  45. /* Miscellaneous flags. */
  46. /*0x06*/unsigned char flags;
  47. /* Currently unused. */
  48. /*0x07*/unsigned char __pad;
  49. /* Reference to IRQ descriptor for this bucket. */
  50. /*0x08*/struct irq_desc *irq_info;
  51. /* Sun5 Interrupt Clear Register. */
  52. /*0x10*/unsigned long iclr;
  53. /* Sun5 Interrupt Mapping Register. */
  54. /*0x18*/unsigned long imap;
  55. };
  56. /* IMAP/ICLR register defines */
  57. #define IMAP_VALID 0x80000000 /* IRQ Enabled */
  58. #define IMAP_TID_UPA 0x7c000000 /* UPA TargetID */
  59. #define IMAP_TID_JBUS 0x7c000000 /* JBUS TargetID */
  60. #define IMAP_TID_SHIFT 26
  61. #define IMAP_AID_SAFARI 0x7c000000 /* Safari AgentID */
  62. #define IMAP_AID_SHIFT 26
  63. #define IMAP_NID_SAFARI 0x03e00000 /* Safari NodeID */
  64. #define IMAP_NID_SHIFT 21
  65. #define IMAP_IGN 0x000007c0 /* IRQ Group Number */
  66. #define IMAP_INO 0x0000003f /* IRQ Number */
  67. #define IMAP_INR 0x000007ff /* Full interrupt number*/
  68. #define ICLR_IDLE 0x00000000 /* Idle state */
  69. #define ICLR_TRANSMIT 0x00000001 /* Transmit state */
  70. #define ICLR_PENDING 0x00000003 /* Pending state */
  71. /* Only 8-bits are available, be careful. -DaveM */
  72. #define IBF_PCI 0x02 /* PSYCHO/SABRE/SCHIZO PCI interrupt. */
  73. #define IBF_ACTIVE 0x04 /* Interrupt is active and has a handler.*/
  74. #define IBF_INPROGRESS 0x10 /* IRQ is being serviced. */
  75. #define NUM_IVECS (IMAP_INR + 1)
  76. extern struct ino_bucket ivector_table[NUM_IVECS];
  77. #define __irq_ino(irq) \
  78. (((struct ino_bucket *)(unsigned long)(irq)) - &ivector_table[0])
  79. #define __bucket(irq) ((struct ino_bucket *)(unsigned long)(irq))
  80. #define __irq(bucket) ((unsigned int)(unsigned long)(bucket))
  81. /* The largest number of unique interrupt sources we support.
  82. * If this needs to ever be larger than 255, you need to change
  83. * the type of ino_bucket->virt_irq as appropriate.
  84. *
  85. * ino_bucket->virt_irq allocation is made during {sun4v_,}build_irq().
  86. */
  87. #define NR_IRQS 255
  88. extern void irq_install_pre_handler(int virt_irq,
  89. void (*func)(struct ino_bucket *, void *, void *),
  90. void *arg1, void *arg2);
  91. #define irq_canonicalize(irq) (irq)
  92. extern void disable_irq(unsigned int);
  93. #define disable_irq_nosync disable_irq
  94. extern void enable_irq(unsigned int);
  95. extern unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap, unsigned char flags);
  96. extern unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, unsigned char flags);
  97. extern unsigned int sbus_build_irq(void *sbus, unsigned int ino);
  98. static __inline__ void set_softint(unsigned long bits)
  99. {
  100. __asm__ __volatile__("wr %0, 0x0, %%set_softint"
  101. : /* No outputs */
  102. : "r" (bits));
  103. }
  104. static __inline__ void clear_softint(unsigned long bits)
  105. {
  106. __asm__ __volatile__("wr %0, 0x0, %%clear_softint"
  107. : /* No outputs */
  108. : "r" (bits));
  109. }
  110. static __inline__ unsigned long get_softint(void)
  111. {
  112. unsigned long retval;
  113. __asm__ __volatile__("rd %%softint, %0"
  114. : "=r" (retval));
  115. return retval;
  116. }
  117. struct irqaction;
  118. struct pt_regs;
  119. int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
  120. #endif