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 | |
| 23 | struct intc_mask_reg { |
| 24 | unsigned long set_reg, clr_reg, reg_width; |
| 25 | intc_enum enum_ids[32]; |
Paul Mundt | dc825b1 | 2010-04-15 13:13:52 +0900 | [diff] [blame] | 26 | #ifdef CONFIG_INTC_BALANCING |
| 27 | unsigned long dist_reg; |
| 28 | #endif |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 29 | #ifdef CONFIG_SMP |
| 30 | unsigned long smp; |
| 31 | #endif |
| 32 | }; |
| 33 | |
| 34 | struct intc_prio_reg { |
| 35 | unsigned long set_reg, clr_reg, reg_width, field_width; |
| 36 | intc_enum enum_ids[16]; |
| 37 | #ifdef CONFIG_SMP |
| 38 | unsigned long smp; |
| 39 | #endif |
| 40 | }; |
| 41 | |
| 42 | struct intc_sense_reg { |
| 43 | unsigned long reg, reg_width, field_width; |
| 44 | intc_enum enum_ids[16]; |
| 45 | }; |
| 46 | |
Paul Mundt | dc825b1 | 2010-04-15 13:13:52 +0900 | [diff] [blame] | 47 | #ifdef CONFIG_INTC_BALANCING |
| 48 | #define INTC_SMP_BALANCING(reg) .dist_reg = (reg) |
| 49 | #else |
| 50 | #define INTC_SMP_BALANCING(reg) |
| 51 | #endif |
| 52 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 53 | #ifdef CONFIG_SMP |
Paul Mundt | dc825b1 | 2010-04-15 13:13:52 +0900 | [diff] [blame] | 54 | #define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8) |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 55 | #else |
| 56 | #define INTC_SMP(stride, nr) |
| 57 | #endif |
| 58 | |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 59 | struct intc_hw_desc { |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 60 | struct intc_vect *vectors; |
| 61 | unsigned int nr_vectors; |
| 62 | struct intc_group *groups; |
| 63 | unsigned int nr_groups; |
| 64 | struct intc_mask_reg *mask_regs; |
| 65 | unsigned int nr_mask_regs; |
| 66 | struct intc_prio_reg *prio_regs; |
| 67 | unsigned int nr_prio_regs; |
| 68 | struct intc_sense_reg *sense_regs; |
| 69 | unsigned int nr_sense_regs; |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 70 | struct intc_mask_reg *ack_regs; |
| 71 | unsigned int nr_ack_regs; |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | #define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a) |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 75 | #define INTC_HW_DESC(vectors, groups, mask_regs, \ |
| 76 | prio_regs, sense_regs, ack_regs) \ |
| 77 | { \ |
| 78 | _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ |
| 79 | _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ |
| 80 | _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \ |
| 81 | } |
| 82 | |
| 83 | struct intc_desc { |
| 84 | char *name; |
Magnus Damm | dec710b | 2010-03-19 16:48:01 +0900 | [diff] [blame] | 85 | struct resource *resource; |
| 86 | unsigned int num_resources; |
Magnus Damm | d519095 | 2010-02-09 04:29:22 +0000 | [diff] [blame] | 87 | intc_enum force_enable; |
Magnus Damm | d85429a | 2010-02-15 11:40:25 +0000 | [diff] [blame] | 88 | intc_enum force_disable; |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 89 | struct intc_hw_desc hw; |
| 90 | }; |
| 91 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 92 | #define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \ |
| 93 | mask_regs, prio_regs, sense_regs) \ |
| 94 | struct intc_desc symbol __initdata = { \ |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 95 | .name = chipname, \ |
| 96 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ |
| 97 | prio_regs, sense_regs, NULL), \ |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 98 | } |
| 99 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 100 | #define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \ |
| 101 | mask_regs, prio_regs, sense_regs, ack_regs) \ |
| 102 | struct intc_desc symbol __initdata = { \ |
Magnus Damm | 577cd75 | 2010-02-09 04:24:46 +0000 | [diff] [blame] | 103 | .name = chipname, \ |
| 104 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ |
| 105 | prio_regs, sense_regs, ack_regs), \ |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 106 | } |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 107 | |
Magnus Damm | 01e9651 | 2010-03-10 09:31:01 +0000 | [diff] [blame] | 108 | int __init register_intc_controller(struct intc_desc *desc); |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 109 | int intc_set_priority(unsigned int irq, unsigned int prio); |
| 110 | |
Paul Mundt | 43b8774 | 2010-04-13 14:43:03 +0900 | [diff] [blame] | 111 | #ifdef CONFIG_INTC_USERIMASK |
| 112 | int register_intc_userimask(unsigned long addr); |
| 113 | #else |
| 114 | static inline int register_intc_userimask(unsigned long addr) |
| 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | #endif |
| 119 | |
Paul Mundt | 45b9dea | 2009-11-02 15:43:20 +0900 | [diff] [blame] | 120 | int reserve_irq_vector(unsigned int irq); |
| 121 | void reserve_irq_legacy(void); |
| 122 | |
Paul Mundt | bbfbd8b | 2008-10-01 16:13:54 +0900 | [diff] [blame] | 123 | #endif /* __SH_INTC_H */ |