Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 1 | #ifndef __SH_INTC_H |
| 2 | #define __SH_INTC_H |
| 3 | |
Magnus Damm | dec710b | 2010-03-19 16:48:01 +0900 | [diff] [blame] | 4 | #include <linux/ioport.h> |
| 5 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 6 | typedef unsigned char intc_enum; |
| 7 | |
| 8 | struct intc_vect { |
| 9 | intc_enum enum_id; |
| 10 | unsigned short vect; |
| 11 | }; |
| 12 | |
| 13 | #define INTC_VECT(enum_id, vect) { enum_id, vect } |
| 14 | #define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq)) |
| 15 | |
| 16 | struct intc_group { |
| 17 | intc_enum enum_id; |
| 18 | intc_enum enum_ids[32]; |
| 19 | }; |
| 20 | |
| 21 | #define INTC_GROUP(enum_id, ids...) { enum_id, { ids } } |
| 22 | |
Paul Mundt | c1e30ad | 2010-10-05 04:47:03 +0900 | [diff] [blame] | 23 | struct intc_subgroup { |
| 24 | unsigned long reg, reg_width; |
| 25 | intc_enum parent_id; |
| 26 | intc_enum enum_ids[32]; |
| 27 | }; |
| 28 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 29 | struct intc_mask_reg { |
| 30 | unsigned long set_reg, clr_reg, reg_width; |
| 31 | intc_enum enum_ids[32]; |
Paul Mundt | dc825b1 | 2010-04-15 13:13:52 +0900 | [diff] [blame] | 32 | #ifdef CONFIG_INTC_BALANCING |
| 33 | unsigned long dist_reg; |
| 34 | #endif |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 35 | #ifdef CONFIG_SMP |
| 36 | unsigned long smp; |
| 37 | #endif |
| 38 | }; |
| 39 | |
| 40 | struct intc_prio_reg { |
| 41 | unsigned long set_reg, clr_reg, reg_width, field_width; |
| 42 | intc_enum enum_ids[16]; |
| 43 | #ifdef CONFIG_SMP |
| 44 | unsigned long smp; |
| 45 | #endif |
| 46 | }; |
| 47 | |
| 48 | struct intc_sense_reg { |
| 49 | unsigned long reg, reg_width, field_width; |
| 50 | intc_enum enum_ids[16]; |
| 51 | }; |
| 52 | |
Paul Mundt | dc825b1 | 2010-04-15 13:13:52 +0900 | [diff] [blame] | 53 | #ifdef CONFIG_INTC_BALANCING |
| 54 | #define INTC_SMP_BALANCING(reg) .dist_reg = (reg) |
| 55 | #else |
| 56 | #define INTC_SMP_BALANCING(reg) |
| 57 | #endif |
| 58 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 59 | #ifdef CONFIG_SMP |
Paul Mundt | dc825b1 | 2010-04-15 13:13:52 +0900 | [diff] [blame] | 60 | #define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8) |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 61 | #else |
| 62 | #define INTC_SMP(stride, nr) |
| 63 | #endif |
| 64 | |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 65 | struct intc_hw_desc { |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 66 | struct intc_vect *vectors; |
| 67 | unsigned int nr_vectors; |
| 68 | struct intc_group *groups; |
| 69 | unsigned int nr_groups; |
| 70 | struct intc_mask_reg *mask_regs; |
| 71 | unsigned int nr_mask_regs; |
| 72 | struct intc_prio_reg *prio_regs; |
| 73 | unsigned int nr_prio_regs; |
| 74 | struct intc_sense_reg *sense_regs; |
| 75 | unsigned int nr_sense_regs; |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 76 | struct intc_mask_reg *ack_regs; |
| 77 | unsigned int nr_ack_regs; |
Paul Mundt | c1e30ad | 2010-10-05 04:47:03 +0900 | [diff] [blame] | 78 | struct intc_subgroup *subgroups; |
| 79 | unsigned int nr_subgroups; |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 80 | }; |
| 81 | |
Paul Mundt | 99870bd | 2010-11-08 17:02:26 +0900 | [diff] [blame] | 82 | #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a) |
Paul Mundt | c1e30ad | 2010-10-05 04:47:03 +0900 | [diff] [blame] | 83 | |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 84 | #define INTC_HW_DESC(vectors, groups, mask_regs, \ |
| 85 | prio_regs, sense_regs, ack_regs) \ |
| 86 | { \ |
| 87 | _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ |
| 88 | _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ |
| 89 | _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \ |
| 90 | } |
| 91 | |
| 92 | struct intc_desc { |
| 93 | char *name; |
Magnus Damm | dec710b | 2010-03-19 16:48:01 +0900 | [diff] [blame] | 94 | struct resource *resource; |
| 95 | unsigned int num_resources; |
Magnus Damm | d519095 | 2010-02-09 04:29:22 +0000 | [diff] [blame] | 96 | intc_enum force_enable; |
Magnus Damm | d85429a | 2010-02-15 11:40:25 +0000 | [diff] [blame] | 97 | intc_enum force_disable; |
Rafael J. Wysocki | 0f966d7 | 2011-12-23 01:23:30 +0100 | [diff] [blame] | 98 | bool skip_syscore_suspend; |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 99 | struct intc_hw_desc hw; |
| 100 | }; |
| 101 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 102 | #define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \ |
| 103 | mask_regs, prio_regs, sense_regs) \ |
| 104 | struct intc_desc symbol __initdata = { \ |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 105 | .name = chipname, \ |
| 106 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ |
| 107 | prio_regs, sense_regs, NULL), \ |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 108 | } |
| 109 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 110 | #define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \ |
| 111 | mask_regs, prio_regs, sense_regs, ack_regs) \ |
| 112 | struct intc_desc symbol __initdata = { \ |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 113 | .name = chipname, \ |
| 114 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ |
| 115 | prio_regs, sense_regs, ack_regs), \ |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 116 | } |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 117 | |
Paul Mundt | 2be6bb0 | 2010-10-05 22:10:30 +0900 | [diff] [blame] | 118 | int register_intc_controller(struct intc_desc *desc); |
Paul Mundt | 4bacd79 | 2010-10-02 22:02:07 +0900 | [diff] [blame] | 119 | void reserve_intc_vectors(struct intc_vect *vectors, unsigned int nr_vecs); |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 120 | int intc_set_priority(unsigned int irq, unsigned int prio); |
Paul Mundt | d74310d | 2010-10-05 18:13:23 +0900 | [diff] [blame] | 121 | int intc_irq_lookup(const char *chipname, intc_enum enum_id); |
Paul Mundt | c1e30ad | 2010-10-05 04:47:03 +0900 | [diff] [blame] | 122 | void intc_finalize(void); |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 123 | |
Paul Mundt | 43b8774 | 2010-04-13 14:43:03 +0900 | [diff] [blame] | 124 | #ifdef CONFIG_INTC_USERIMASK |
| 125 | int register_intc_userimask(unsigned long addr); |
| 126 | #else |
| 127 | static inline int register_intc_userimask(unsigned long addr) |
| 128 | { |
| 129 | return 0; |
| 130 | } |
| 131 | #endif |
| 132 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 133 | #endif /* __SH_INTC_H */ |