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