Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH_HW_IRQ_H |
| 2 | #define __ASM_SH_HW_IRQ_H |
| 3 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 4 | #include <linux/init.h> |
Paul Mundt | 35f3c51 | 2006-10-06 15:31:16 +0900 | [diff] [blame] | 5 | #include <asm/atomic.h> |
| 6 | |
| 7 | extern atomic_t irq_err_count; |
| 8 | |
Magnus Damm | 68abdbb | 2007-06-15 18:56:19 +0900 | [diff] [blame] | 9 | struct ipr_data { |
| 10 | unsigned char irq; |
| 11 | unsigned char ipr_idx; /* Index for the IPR registered */ |
| 12 | unsigned char shift; /* Number of bits to shift the data */ |
| 13 | unsigned char priority; /* The priority */ |
| 14 | }; |
| 15 | |
| 16 | struct ipr_desc { |
| 17 | unsigned long *ipr_offsets; |
| 18 | unsigned int nr_offsets; |
| 19 | struct ipr_data *ipr_data; |
| 20 | unsigned int nr_irqs; |
| 21 | struct irq_chip chip; |
| 22 | }; |
| 23 | |
| 24 | void register_ipr_controller(struct ipr_desc *); |
Magnus Damm | 68abdbb | 2007-06-15 18:56:19 +0900 | [diff] [blame] | 25 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 26 | typedef unsigned char intc_enum; |
| 27 | |
| 28 | struct intc_vect { |
| 29 | intc_enum enum_id; |
| 30 | unsigned short vect; |
| 31 | }; |
| 32 | |
| 33 | #define INTC_VECT(enum_id, vect) { enum_id, vect } |
Magnus Damm | 51da642 | 2007-08-03 14:25:32 +0900 | [diff] [blame] | 34 | #define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq)) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 35 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 36 | struct intc_group { |
| 37 | intc_enum enum_id; |
Magnus Damm | 5c37e02 | 2007-08-17 00:45:35 +0900 | [diff] [blame] | 38 | intc_enum enum_ids[32]; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 39 | }; |
| 40 | |
Magnus Damm | 5c37e02 | 2007-08-17 00:45:35 +0900 | [diff] [blame] | 41 | #define INTC_GROUP(enum_id, ids...) { enum_id, { ids } } |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 42 | |
| 43 | struct intc_mask_reg { |
| 44 | unsigned long set_reg, clr_reg, reg_width; |
| 45 | intc_enum enum_ids[32]; |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 46 | #ifdef CONFIG_SMP |
| 47 | unsigned long smp; |
| 48 | #endif |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct intc_prio_reg { |
Magnus Damm | 6ef5fb2 | 2007-08-12 15:22:02 +0900 | [diff] [blame] | 52 | unsigned long set_reg, clr_reg, reg_width, field_width; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 53 | intc_enum enum_ids[16]; |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 54 | #ifdef CONFIG_SMP |
| 55 | unsigned long smp; |
| 56 | #endif |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct intc_sense_reg { |
| 60 | unsigned long reg, reg_width, field_width; |
| 61 | intc_enum enum_ids[16]; |
| 62 | }; |
| 63 | |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 64 | #ifdef CONFIG_SMP |
| 65 | #define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8) |
| 66 | #else |
| 67 | #define INTC_SMP(stride, nr) |
| 68 | #endif |
| 69 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 70 | struct intc_desc { |
| 71 | struct intc_vect *vectors; |
| 72 | unsigned int nr_vectors; |
| 73 | struct intc_group *groups; |
| 74 | unsigned int nr_groups; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 75 | struct intc_mask_reg *mask_regs; |
| 76 | unsigned int nr_mask_regs; |
| 77 | struct intc_prio_reg *prio_regs; |
| 78 | unsigned int nr_prio_regs; |
| 79 | struct intc_sense_reg *sense_regs; |
| 80 | unsigned int nr_sense_regs; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 81 | char *name; |
Yoshihiro Shimoda | 6bdfb22 | 2008-07-04 12:37:12 +0900 | [diff] [blame] | 82 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame] | 83 | struct intc_mask_reg *ack_regs; |
| 84 | unsigned int nr_ack_regs; |
| 85 | #endif |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | #define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a) |
| 89 | #define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \ |
Magnus Damm | 7f3edee | 2008-01-10 14:08:55 +0900 | [diff] [blame] | 90 | mask_regs, prio_regs, sense_regs) \ |
Magnus Damm | 5c37e02 | 2007-08-17 00:45:35 +0900 | [diff] [blame] | 91 | struct intc_desc symbol __initdata = { \ |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 92 | _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 93 | _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ |
| 94 | _INTC_ARRAY(sense_regs), \ |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 95 | chipname, \ |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 96 | } |
| 97 | |
Yoshihiro Shimoda | 6bdfb22 | 2008-07-04 12:37:12 +0900 | [diff] [blame] | 98 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame] | 99 | #define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \ |
| 100 | mask_regs, prio_regs, sense_regs, ack_regs) \ |
| 101 | struct intc_desc symbol __initdata = { \ |
| 102 | _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ |
| 103 | _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ |
| 104 | _INTC_ARRAY(sense_regs), \ |
| 105 | chipname, \ |
| 106 | _INTC_ARRAY(ack_regs), \ |
| 107 | } |
| 108 | #endif |
| 109 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 110 | void __init register_intc_controller(struct intc_desc *desc); |
Magnus Damm | 3d37d94 | 2007-08-17 00:50:44 +0900 | [diff] [blame] | 111 | int intc_set_priority(unsigned int irq, unsigned int prio); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 112 | |
Magnus Damm | 90015c8 | 2007-07-18 17:57:34 +0900 | [diff] [blame] | 113 | void __init plat_irq_setup(void); |
Magnus Damm | a276e58 | 2008-04-24 21:30:09 +0900 | [diff] [blame] | 114 | #ifdef CONFIG_CPU_SH3 |
| 115 | void __init plat_irq_setup_sh3(void); |
| 116 | #endif |
Magnus Damm | 90015c8 | 2007-07-18 17:57:34 +0900 | [diff] [blame] | 117 | |
Magnus Damm | a0e2326 | 2007-07-31 17:11:21 +0900 | [diff] [blame] | 118 | enum { IRQ_MODE_IRQ, IRQ_MODE_IRQ7654, IRQ_MODE_IRQ3210, |
Magnus Damm | 953c8ef | 2007-09-10 12:03:50 +0900 | [diff] [blame] | 119 | IRQ_MODE_IRL7654_MASK, IRQ_MODE_IRL3210_MASK, |
Magnus Damm | a0e2326 | 2007-07-31 17:11:21 +0900 | [diff] [blame] | 120 | IRQ_MODE_IRL7654, IRQ_MODE_IRL3210 }; |
Magnus Damm | 39c7aa9 | 2007-07-20 12:10:29 +0900 | [diff] [blame] | 121 | void __init plat_irq_setup_pins(int mode); |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | #endif /* __ASM_SH_HW_IRQ_H */ |