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 #if defined(CONFIG_CPU_SUBTYPE_SH7705)
22 #define INTC_INTER 0xA4000014UL
23 #define INTC_IPRD 0xA4000018UL
24 #define INTC_ICR2 0xA4000012UL
27 #define PORT_PACR 0xA4000100UL
28 #define PORT_PBCR 0xA4000102UL
29 #define PORT_PCCR 0xA4000104UL
30 #define PORT_PDCR 0xA4000106UL
31 #define PORT_PECR 0xA4000108UL
32 #define PORT_PFCR 0xA400010AUL
33 #define PORT_PGCR 0xA400010CUL
34 #define PORT_PHCR 0xA400010EUL
35 #define PORT_PJCR 0xA4000110UL
36 #define PORT_PKCR 0xA4000112UL
37 #define PORT_PLCR 0xA4000114UL
38 #define PORT_PMCR 0xA4000118UL
39 #define PORT_PNCR 0xA400011AUL
40 #define PORT_PECR2 0xA4050148UL
41 #define PORT_PFCR2 0xA405014AUL
42 #define PORT_PNCR2 0xA405015AUL
45 #define PORT_PADR 0xA4000120UL
46 #define PORT_PBDR 0xA4000122UL
47 #define PORT_PCDR 0xA4000124UL
48 #define PORT_PDDR 0xA4000126UL
49 #define PORT_PEDR 0xA4000128UL
50 #define PORT_PFDR 0xA400012AUL
51 #define PORT_PGDR 0xA400012CUL
52 #define PORT_PHDR 0xA400012EUL
53 #define PORT_PJDR 0xA4000130UL
54 #define PORT_PKDR 0xA4000132UL
55 #define PORT_PLDR 0xA4000134UL
56 #define PORT_PMDR 0xA4000138UL
57 #define PORT_PNDR 0xA400013AUL
61 #define PINT_IRQ_BASE 86
63 #define PINT0_IPR_ADDR INTC_IPRD
64 #define PINT0_IPR_POS 3
65 #define PINT0_PRIORITY 2
67 #define PINT8_IPR_ADDR INTC_IPRD
68 #define PINT8_IPR_POS 2
69 #define PINT8_PRIORITY 2
71 #endif /* CONFIG_CPU_SUBTYPE_SH7705 */
73 static unsigned char pint_map
[256];
74 static unsigned long portcr_mask
;
76 static void enable_pint_irq(unsigned int irq
);
77 static void disable_pint_irq(unsigned int irq
);
79 /* shutdown is same as "disable" */
80 #define shutdown_pint_irq disable_pint_irq
82 static void mask_and_ack_pint(unsigned int);
83 static void end_pint_irq(unsigned int irq
);
85 static unsigned int startup_pint_irq(unsigned int irq
)
88 return 0; /* never anything pending */
91 static struct hw_interrupt_type pint_irq_type
= {
92 .typename
= "PINT-IRQ",
93 .startup
= startup_pint_irq
,
94 .shutdown
= shutdown_pint_irq
,
95 .enable
= enable_pint_irq
,
96 .disable
= disable_pint_irq
,
97 .ack
= mask_and_ack_pint
,
101 static void disable_pint_irq(unsigned int irq
)
105 val
= ctrl_inw(INTC_INTER
);
106 val
&= ~(1 << (irq
- PINT_IRQ_BASE
));
107 ctrl_outw(val
, INTC_INTER
); /* disable PINTn */
108 portcr_mask
&= ~(3 << (irq
- PINT_IRQ_BASE
)*2);
111 static void enable_pint_irq(unsigned int irq
)
115 val
= ctrl_inw(INTC_INTER
);
116 val
|= 1 << (irq
- PINT_IRQ_BASE
);
117 ctrl_outw(val
, INTC_INTER
); /* enable PINTn */
118 portcr_mask
|= 3 << (irq
- PINT_IRQ_BASE
)*2;
121 static void mask_and_ack_pint(unsigned int irq
)
123 disable_pint_irq(irq
);
126 static void end_pint_irq(unsigned int irq
)
128 if (!(irq_desc
[irq
].status
& (IRQ_DISABLED
|IRQ_INPROGRESS
)))
129 enable_pint_irq(irq
);
132 void make_pint_irq(unsigned int irq
)
134 disable_irq_nosync(irq
);
135 irq_desc
[irq
].chip
= &pint_irq_type
;
136 disable_pint_irq(irq
);
139 static struct ipr_data pint_ipr_map
[] = {
140 { PINT0_IRQ
, PINT0_IPR_ADDR
, PINT0_IPR_POS
, PINT0_PRIORITY
},
141 { PINT8_IRQ
, PINT8_IPR_ADDR
, PINT8_IPR_POS
, PINT8_PRIORITY
},
144 void __init
init_IRQ_pint(void)
148 make_ipr_irq(pint_ipr_map
, ARRAY_SIZE(pint_ipr_map
));
150 enable_irq(PINT0_IRQ
);
151 enable_irq(PINT8_IRQ
);
153 for(i
= 0; i
< 16; i
++)
154 make_pint_irq(PINT_IRQ_BASE
+ i
);
156 for(i
= 0; i
< 256; i
++) {
176 int ipr_irq_demux(int irq
)
178 unsigned long creg
, dreg
, d
, sav
;
180 if (irq
== PINT0_IRQ
) {
181 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || defined(CONFIG_CPU_SUBTYPE_SH7707)
188 sav
= ctrl_inw(creg
);
189 ctrl_outw(sav
| portcr_mask
, creg
);
190 d
= (~ctrl_inb(dreg
) ^ ctrl_inw(INTC_ICR2
)) &
191 ctrl_inw(INTC_INTER
) & 0xff;
192 ctrl_outw(sav
, creg
);
197 return PINT_IRQ_BASE
+ pint_map
[d
];
198 } else if (irq
== PINT8_IRQ
) {
199 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || defined(CONFIG_CPU_SUBTYPE_SH7707)
206 sav
= ctrl_inw(creg
);
207 ctrl_outw(sav
| (portcr_mask
>> 16), creg
);
208 d
= (~ctrl_inb(dreg
) ^ (ctrl_inw(INTC_ICR2
) >> 8)) &
209 (ctrl_inw(INTC_INTER
) >> 8) & 0xff;
210 ctrl_outw(sav
, creg
);
215 return PINT_IRQ_BASE
+ 8 + pint_map
[d
];