blob: 8ccf7ae593efaf871b0d8e7ec04e2625ae91eb72 [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) || \
Paul Mundt41504c32006-12-11 20:28:03 +090040 defined(CONFIG_CPU_SUBTYPE_SH7343) || \
41 defined(CONFIG_CPU_SUBTYPE_SH7722)
Paul Mundtbf3a00f2006-01-16 22:14:14 -080042# define ONCHIP_NR_IRQS 109
Paul Mundt8d27e082006-02-01 03:06:04 -080043#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
44# define ONCHIP_NR_IRQS 111
Yoshinori Satob2296322006-11-05 16:18:08 +090045#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
46# define ONCHIP_NR_IRQS 256
47#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
48# define ONCHIP_NR_IRQS 128
Paul Mundtbf3a00f2006-01-16 22:14:14 -080049#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */
50# define ONCHIP_NR_IRQS 144
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#endif
52
53/* 2. PINT_NR_IRQS */
Paul Mundtbf3a00f2006-01-16 22:14:14 -080054#ifdef CONFIG_SH_UNKNOWN
Linus Torvalds1da177e2005-04-16 15:20:36 -070055# define PINT_NR_IRQS 16
56#else
57# ifndef PINT_NR_IRQS
58# define PINT_NR_IRQS 0
59# endif
60#endif
61
62#if PINT_NR_IRQS > 0
63# define PINT_IRQ_BASE ONCHIP_NR_IRQS
64#endif
65
66/* 3. OFFCHIP_NR_IRQS */
Paul Mundtbf3a00f2006-01-16 22:14:14 -080067#if defined(CONFIG_HD64461)
68# define OFFCHIP_NR_IRQS 18
Paul Mundtbf3a00f2006-01-16 22:14:14 -080069#elif defined(CONFIG_HD64465)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070# define OFFCHIP_NR_IRQS 16
Paul Mundtbf3a00f2006-01-16 22:14:14 -080071#elif defined (CONFIG_SH_DREAMCAST)
72# define OFFCHIP_NR_IRQS 96
73#elif defined (CONFIG_SH_TITAN)
74# define OFFCHIP_NR_IRQS 4
Paul Mundt8d27e082006-02-01 03:06:04 -080075#elif defined(CONFIG_SH_R7780RP)
76# define OFFCHIP_NR_IRQS 16
Paul Mundtbc8fb5d2006-09-27 18:09:34 +090077#elif defined(CONFIG_SH_7343_SOLUTION_ENGINE)
78# define OFFCHIP_NR_IRQS 12
Paul Mundt41504c32006-12-11 20:28:03 +090079#elif defined(CONFIG_SH_7722_SOLUTION_ENGINE)
80# define OFFCHIP_NR_IRQS 14
Paul Mundtbf3a00f2006-01-16 22:14:14 -080081#elif defined(CONFIG_SH_UNKNOWN)
82# define OFFCHIP_NR_IRQS 16 /* Must also be last */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#else
Paul Mundtbf3a00f2006-01-16 22:14:14 -080084# define OFFCHIP_NR_IRQS 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070085#endif
86
87#if OFFCHIP_NR_IRQS > 0
88# define OFFCHIP_IRQ_BASE (ONCHIP_NR_IRQS + PINT_NR_IRQS)
89#endif
90
91/* NR_IRQS. 1+2+3 */
92#define NR_IRQS (ONCHIP_NR_IRQS + PINT_NR_IRQS + OFFCHIP_NR_IRQS)
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +090095 * Convert back and forth between INTEVT and IRQ values.
96 */
97#define evt2irq(evt) (((evt) >> 5) - 16)
98#define irq2evt(irq) (((irq) + 16) << 5)
99
100/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 * Simple Mask Register Support
102 */
103extern void make_maskreg_irq(unsigned int irq);
104extern unsigned short *irq_mask_register;
105
106/*
Paul Mundt0f08f332006-09-27 17:03:56 +0900107 * PINT IRQs
108 */
109void init_IRQ_pint(void);
110
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900111/*
112 * The shift value is now the number of bits to shift, not the number of
113 * bits/4. This is to make it easier to read the value directly from the
114 * datasheets. The IPR address, addr, will be set from ipr_idx via the
115 * map_ipridx_to_addr function.
116 */
Jamie Lenehanbd71ab82006-10-31 12:35:02 +0900117struct ipr_data {
118 unsigned int irq;
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900119 int ipr_idx; /* Index for the IPR registered */
120 int shift; /* Number of bits to shift the data */
Jamie Lenehanbd71ab82006-10-31 12:35:02 +0900121 int priority; /* The priority */
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900122 unsigned int addr; /* Address of Interrupt Priority Register */
Jamie Lenehanbd71ab82006-10-31 12:35:02 +0900123};
124
Paul Mundt0f08f332006-09-27 17:03:56 +0900125/*
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900126 * Given an IPR IDX, map the value to an IPR register address.
127 */
128unsigned int map_ipridx_to_addr(int idx);
129
130/*
131 * Enable individual interrupt mode for external IPR IRQs.
132 */
133void ipr_irq_enable_irlm(void);
134
135/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 * Function for "on chip support modules".
137 */
Jamie Lenehanea0f8fe2006-12-06 12:05:02 +0900138void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs);
139void make_imask_irq(unsigned int irq);
140void init_IRQ_ipr(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
Paul Mundt525ccc42006-10-06 17:35:48 +0900142struct intc2_data {
143 unsigned short irq;
144 unsigned char ipr_offset, ipr_shift;
145 unsigned char msk_offset, msk_shift;
146 unsigned char priority;
147};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Paul Mundt66a74052006-10-20 15:30:55 +0900149void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs);
Paul Mundt525ccc42006-10-06 17:35:48 +0900150void init_IRQ_intc2(void);
Paul Mundte5723e02006-09-27 17:38:11 +0900151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152static inline int generic_irq_demux(int irq)
153{
154 return irq;
155}
156
157#define irq_canonicalize(irq) (irq)
Paul Mundt9a7ef6d2006-11-20 13:55:34 +0900158#define irq_demux(irq) sh_mv.mv_irq_demux(irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Paul Mundta6a311392006-09-27 18:22:14 +0900160#ifdef CONFIG_4KSTACKS
161extern void irq_ctx_init(int cpu);
162extern void irq_ctx_exit(int cpu);
163# define __ARCH_HAS_DO_SOFTIRQ
164#else
165# define irq_ctx_init(cpu) do { } while (0)
166# define irq_ctx_exit(cpu) do { } while (0)
167#endif
168
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169#endif /* __ASM_SH_IRQ_H */