sh_intc.h 3.1 KB
Newer Older
1 2 3
#ifndef __SH_INTC_H
#define __SH_INTC_H

M
Magnus Damm 已提交
4 5
#include <linux/ioport.h>

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
typedef unsigned char intc_enum;

struct intc_vect {
	intc_enum enum_id;
	unsigned short vect;
};

#define INTC_VECT(enum_id, vect) { enum_id, vect }
#define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))

struct intc_group {
	intc_enum enum_id;
	intc_enum enum_ids[32];
};

#define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }

23 24 25 26 27 28
struct intc_subgroup {
	unsigned long reg, reg_width;
	intc_enum parent_id;
	intc_enum enum_ids[32];
};

29 30 31
struct intc_mask_reg {
	unsigned long set_reg, clr_reg, reg_width;
	intc_enum enum_ids[32];
32 33 34
#ifdef CONFIG_INTC_BALANCING
	unsigned long dist_reg;
#endif
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#ifdef CONFIG_SMP
	unsigned long smp;
#endif
};

struct intc_prio_reg {
	unsigned long set_reg, clr_reg, reg_width, field_width;
	intc_enum enum_ids[16];
#ifdef CONFIG_SMP
	unsigned long smp;
#endif
};

struct intc_sense_reg {
	unsigned long reg, reg_width, field_width;
	intc_enum enum_ids[16];
};

53 54 55 56 57 58
#ifdef CONFIG_INTC_BALANCING
#define INTC_SMP_BALANCING(reg)	.dist_reg = (reg)
#else
#define INTC_SMP_BALANCING(reg)
#endif

59
#ifdef CONFIG_SMP
60
#define INTC_SMP(stride, nr)	.smp = (stride) | ((nr) << 8)
61 62 63 64
#else
#define INTC_SMP(stride, nr)
#endif

65
struct intc_hw_desc {
66 67 68 69 70 71 72 73 74 75 76 77
	struct intc_vect *vectors;
	unsigned int nr_vectors;
	struct intc_group *groups;
	unsigned int nr_groups;
	struct intc_mask_reg *mask_regs;
	unsigned int nr_mask_regs;
	struct intc_prio_reg *prio_regs;
	unsigned int nr_prio_regs;
	struct intc_sense_reg *sense_regs;
	unsigned int nr_sense_regs;
	struct intc_mask_reg *ack_regs;
	unsigned int nr_ack_regs;
78 79
	struct intc_subgroup *subgroups;
	unsigned int nr_subgroups;
80 81
};

82
#define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
83

84 85 86 87 88 89 90 91 92 93
#define INTC_HW_DESC(vectors, groups, mask_regs,	\
		     prio_regs,	sense_regs, ack_regs)	\
{							\
	_INTC_ARRAY(vectors), _INTC_ARRAY(groups),	\
	_INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs),	\
	_INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs),	\
}

struct intc_desc {
	char *name;
M
Magnus Damm 已提交
94 95
	struct resource *resource;
	unsigned int num_resources;
M
Magnus Damm 已提交
96
	intc_enum force_enable;
M
Magnus Damm 已提交
97
	intc_enum force_disable;
98
	bool skip_syscore_suspend;
99 100 101
	struct intc_hw_desc hw;
};

102 103 104
#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups,		\
	mask_regs, prio_regs, sense_regs)				\
struct intc_desc symbol __initdata = {					\
105 106 107
	.name = chipname,						\
	.hw = INTC_HW_DESC(vectors, groups, mask_regs,			\
			   prio_regs, sense_regs, NULL),		\
108 109 110 111 112
}

#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups,	\
	mask_regs, prio_regs, sense_regs, ack_regs)			\
struct intc_desc symbol __initdata = {					\
113 114 115
	.name = chipname,						\
	.hw = INTC_HW_DESC(vectors, groups, mask_regs,			\
			   prio_regs, sense_regs, ack_regs),		\
116 117
}

P
Paul Mundt 已提交
118
int register_intc_controller(struct intc_desc *desc);
119
void reserve_intc_vectors(struct intc_vect *vectors, unsigned int nr_vecs);
120
int intc_set_priority(unsigned int irq, unsigned int prio);
121
int intc_irq_lookup(const char *chipname, intc_enum enum_id);
122
void intc_finalize(void);
123

P
Paul Mundt 已提交
124 125 126 127 128 129 130 131 132
#ifdef CONFIG_INTC_USERIMASK
int register_intc_userimask(unsigned long addr);
#else
static inline int register_intc_userimask(unsigned long addr)
{
	return 0;
}
#endif

133
#endif /* __SH_INTC_H */