2 * arch/sh/kernel/cpu/irq/pint.c - Interrupt handling for PINT-based IRQs.
4 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
5 * Copyright (C) 2000 Kazumoto Kojima
6 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/init.h>
14 #include <linux/irq.h>
15 #include <linux/module.h>
17 #include <asm/system.h>
19 #include <asm/machvec.h>
21 static unsigned char pint_map
[256];
22 static unsigned long portcr_mask
;
24 static void enable_pint_irq(unsigned int irq
);
25 static void disable_pint_irq(unsigned int irq
);
27 /* shutdown is same as "disable" */
28 #define shutdown_pint_irq disable_pint_irq
30 static void mask_and_ack_pint(unsigned int);
31 static void end_pint_irq(unsigned int irq
);
33 static unsigned int startup_pint_irq(unsigned int irq
)
36 return 0; /* never anything pending */
39 static struct hw_interrupt_type pint_irq_type
= {
40 .typename
= "PINT-IRQ",
41 .startup
= startup_pint_irq
,
42 .shutdown
= shutdown_pint_irq
,
43 .enable
= enable_pint_irq
,
44 .disable
= disable_pint_irq
,
45 .ack
= mask_and_ack_pint
,
49 static void disable_pint_irq(unsigned int irq
)
53 val
= ctrl_inw(INTC_INTER
);
54 val
&= ~(1 << (irq
- PINT_IRQ_BASE
));
55 ctrl_outw(val
, INTC_INTER
); /* disable PINTn */
56 portcr_mask
&= ~(3 << (irq
- PINT_IRQ_BASE
)*2);
59 static void enable_pint_irq(unsigned int irq
)
63 val
= ctrl_inw(INTC_INTER
);
64 val
|= 1 << (irq
- PINT_IRQ_BASE
);
65 ctrl_outw(val
, INTC_INTER
); /* enable PINTn */
66 portcr_mask
|= 3 << (irq
- PINT_IRQ_BASE
)*2;
69 static void mask_and_ack_pint(unsigned int irq
)
71 disable_pint_irq(irq
);
74 static void end_pint_irq(unsigned int irq
)
76 if (!(irq_desc
[irq
].status
& (IRQ_DISABLED
|IRQ_INPROGRESS
)))
80 void make_pint_irq(unsigned int irq
)
82 disable_irq_nosync(irq
);
83 irq_desc
[irq
].chip
= &pint_irq_type
;
84 disable_pint_irq(irq
);
87 static struct ipr_data pint_ipr_map
[] = {
88 { PINT0_IRQ
, PINT0_IPR_ADDR
, PINT0_IPR_POS
, PINT0_PRIORITY
},
89 { PINT8_IRQ
, PINT8_IPR_ADDR
, PINT8_IPR_POS
, PINT8_PRIORITY
},
92 void __init
init_IRQ_pint(void)
96 make_ipr_irq(pint_ipr_map
, ARRAY_SIZE(pint_ipr_map
));
98 enable_irq(PINT0_IRQ
);
99 enable_irq(PINT8_IRQ
);
101 for(i
= 0; i
< 16; i
++)
102 make_pint_irq(PINT_IRQ_BASE
+ i
);
104 for(i
= 0; i
< 256; i
++) {
124 int ipr_irq_demux(int irq
)
126 unsigned long creg
, dreg
, d
, sav
;
128 if (irq
== PINT0_IRQ
) {
129 #if defined(CONFIG_CPU_SUBTYPE_SH7707)
136 sav
= ctrl_inw(creg
);
137 ctrl_outw(sav
| portcr_mask
, creg
);
138 d
= (~ctrl_inb(dreg
) ^ ctrl_inw(INTC_ICR2
)) &
139 ctrl_inw(INTC_INTER
) & 0xff;
140 ctrl_outw(sav
, creg
);
145 return PINT_IRQ_BASE
+ pint_map
[d
];
146 } else if (irq
== PINT8_IRQ
) {
147 #if defined(CONFIG_CPU_SUBTYPE_SH7707)
154 sav
= ctrl_inw(creg
);
155 ctrl_outw(sav
| (portcr_mask
>> 16), creg
);
156 d
= (~ctrl_inb(dreg
) ^ (ctrl_inw(INTC_ICR2
) >> 8)) &
157 (ctrl_inw(INTC_INTER
) >> 8) & 0xff;
158 ctrl_outw(sav
, creg
);
163 return PINT_IRQ_BASE
+ 8 + pint_map
[d
];