blob: fd576088e47edd0085ba8aa1f702a3c1b44dffd0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_IRQ_H
2#define __ASM_SH_IRQ_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/machvec.h>
5#include <asm/ptrace.h> /* for pt_regs */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007/* NR_IRQS is made from three components:
8 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules
9 * 2. PINT_NR_IRQS - number of PINT interrupts
10 * 3. OFFCHIP_NR_IRQS - numbe of IRQs from off-chip peripherial modules
11 */
12
13/* 1. ONCHIP_NR_IRQS */
Paul Mundtbf3a00f2006-01-16 22:14:14 -080014#if defined(CONFIG_CPU_SUBTYPE_SH7604)
15# define ONCHIP_NR_IRQS 24 // Actually 21
16#elif defined(CONFIG_CPU_SUBTYPE_SH7707)
17# define ONCHIP_NR_IRQS 64
18# define PINT_NR_IRQS 16
19#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
20# define ONCHIP_NR_IRQS 32
21#elif defined(CONFIG_CPU_SUBTYPE_SH7709) || \
Paul Mundte5723e02006-09-27 17:38:11 +090022 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
Paul Mundtbf3a00f2006-01-16 22:14:14 -080023 defined(CONFIG_CPU_SUBTYPE_SH7705)
24# define ONCHIP_NR_IRQS 64 // Actually 61
25# define PINT_NR_IRQS 16
Paul Mundte5723e02006-09-27 17:38:11 +090026#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
27# define ONCHIP_NR_IRQS 104
Paul Mundtbf3a00f2006-01-16 22:14:14 -080028#elif defined(CONFIG_CPU_SUBTYPE_SH7750)
29# define ONCHIP_NR_IRQS 48 // Actually 44
30#elif defined(CONFIG_CPU_SUBTYPE_SH7751)
31# define ONCHIP_NR_IRQS 72
32#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
33# define ONCHIP_NR_IRQS 112 /* XXX */
34#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
35# define ONCHIP_NR_IRQS 72
36#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037# define ONCHIP_NR_IRQS 144
Paul Mundt8d27e082006-02-01 03:06:04 -080038#elif defined(CONFIG_CPU_SUBTYPE_SH7300) || \
Paul Mundte5723e02006-09-27 17:38:11 +090039 defined(CONFIG_CPU_SUBTYPE_SH73180) || \
40 defined(CONFIG_CPU_SUBTYPE_SH7343)
Paul Mundtbf3a00f2006-01-16 22:14:14 -080041# define ONCHIP_NR_IRQS 109
Paul Mundt8d27e082006-02-01 03:06:04 -080042#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
43# define ONCHIP_NR_IRQS 111
Yoshinori Satob2296322006-11-05 16:18:08 +090044#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
45# define ONCHIP_NR_IRQS 256
46#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
47# define ONCHIP_NR_IRQS 128
Paul Mundtbf3a00f2006-01-16 22:14:14 -080048#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */
49# define ONCHIP_NR_IRQS 144
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#endif
51
52/* 2. PINT_NR_IRQS */
Paul Mundtbf3a00f2006-01-16 22:14:14 -080053#ifdef CONFIG_SH_UNKNOWN
Linus Torvalds1da177e2005-04-16 15:20:36 -070054# define PINT_NR_IRQS 16
55#else
56# ifndef PINT_NR_IRQS
57# define PINT_NR_IRQS 0
58# endif
59#endif
60
61#if PINT_NR_IRQS > 0
62# define PINT_IRQ_BASE ONCHIP_NR_IRQS
63#endif
64
65/* 3. OFFCHIP_NR_IRQS */
Paul Mundtbf3a00f2006-01-16 22:14:14 -080066#if defined(CONFIG_HD64461)
67# define OFFCHIP_NR_IRQS 18
68#elif defined (CONFIG_SH_BIGSUR) /* must be before CONFIG_HD64465 */
69# define OFFCHIP_NR_IRQS 48
70#elif defined(CONFIG_HD64465)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071# define OFFCHIP_NR_IRQS 16
Paul Mundtbf3a00f2006-01-16 22:14:14 -080072#elif defined (CONFIG_SH_EC3104)
73# define OFFCHIP_NR_IRQS 16
74#elif defined (CONFIG_SH_DREAMCAST)
75# define OFFCHIP_NR_IRQS 96
76#elif defined (CONFIG_SH_TITAN)
77# define OFFCHIP_NR_IRQS 4
Paul Mundt8d27e082006-02-01 03:06:04 -080078#elif defined(CONFIG_SH_R7780RP)
79# define OFFCHIP_NR_IRQS 16
Paul Mundtbc8fb5d2006-09-27 18:09:34 +090080#elif defined(CONFIG_SH_7343_SOLUTION_ENGINE)
81# define OFFCHIP_NR_IRQS 12
Paul Mundtbf3a00f2006-01-16 22:14:14 -080082#elif defined(CONFIG_SH_UNKNOWN)
83# define OFFCHIP_NR_IRQS 16 /* Must also be last */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#else
Paul Mundtbf3a00f2006-01-16 22:14:14 -080085# define OFFCHIP_NR_IRQS 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070086#endif
87
88#if OFFCHIP_NR_IRQS > 0
89# define OFFCHIP_IRQ_BASE (ONCHIP_NR_IRQS + PINT_NR_IRQS)
90#endif
91
92/* NR_IRQS. 1+2+3 */
93#define NR_IRQS (ONCHIP_NR_IRQS + PINT_NR_IRQS + OFFCHIP_NR_IRQS)
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095/*
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +090096 * Convert back and forth between INTEVT and IRQ values.
97 */
98#define evt2irq(evt) (((evt) >> 5) - 16)
99#define irq2evt(irq) (((irq) + 16) << 5)
100
101/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 * Simple Mask Register Support
103 */
104extern void make_maskreg_irq(unsigned int irq);
105extern unsigned short *irq_mask_register;
106
107/*
Paul Mundt0f08f332006-09-27 17:03:56 +0900108 * PINT IRQs
109 */
110void init_IRQ_pint(void);
111
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900112/*
113 * The shift value is now the number of bits to shift, not the number of
114 * bits/4. This is to make it easier to read the value directly from the
115 * datasheets. The IPR address, addr, will be set from ipr_idx via the
116 * map_ipridx_to_addr function.
117 */
Jamie Lenehanbd71ab82006-10-31 12:35:02 +0900118struct ipr_data {
119 unsigned int irq;
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900120 int ipr_idx; /* Index for the IPR registered */
121 int shift; /* Number of bits to shift the data */
Jamie Lenehanbd71ab82006-10-31 12:35:02 +0900122 int priority; /* The priority */
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900123 unsigned int addr; /* Address of Interrupt Priority Register */
Jamie Lenehanbd71ab82006-10-31 12:35:02 +0900124};
125
Paul Mundt0f08f332006-09-27 17:03:56 +0900126/*
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900127 * Given an IPR IDX, map the value to an IPR register address.
128 */
129unsigned int map_ipridx_to_addr(int idx);
130
131/*
132 * Enable individual interrupt mode for external IPR IRQs.
133 */
134void ipr_irq_enable_irlm(void);
135
136/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 * Function for "on chip support modules".
138 */
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900139void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs);
140void make_imask_irq(unsigned int irq);
141void init_IRQ_ipr(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Paul Mundt525ccc42006-10-06 17:35:48 +0900143struct intc2_data {
144 unsigned short irq;
145 unsigned char ipr_offset, ipr_shift;
146 unsigned char msk_offset, msk_shift;
147 unsigned char priority;
148};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Paul Mundt66a74052006-10-20 15:30:55 +0900150void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs);
Paul Mundt525ccc42006-10-06 17:35:48 +0900151void init_IRQ_intc2(void);
Paul Mundte5723e02006-09-27 17:38:11 +0900152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153static inline int generic_irq_demux(int irq)
154{
155 return irq;
156}
157
158#define irq_canonicalize(irq) (irq)
Paul Mundt9a7ef6d2006-11-20 13:55:34 +0900159#define irq_demux(irq) sh_mv.mv_irq_demux(irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Paul Mundta6a311392006-09-27 18:22:14 +0900161#ifdef CONFIG_4KSTACKS
162extern void irq_ctx_init(int cpu);
163extern void irq_ctx_exit(int cpu);
164# define __ARCH_HAS_DO_SOFTIRQ
165#else
166# define irq_ctx_init(cpu) do { } while (0)
167# define irq_ctx_exit(cpu) do { } while (0)
168#endif
169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170#endif /* __ASM_SH_IRQ_H */