2008-10-01 01:13:54 -06:00
|
|
|
#ifndef __SH_INTC_H
|
|
|
|
#define __SH_INTC_H
|
|
|
|
|
2010-03-19 01:48:01 -06:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
|
2012-01-17 12:10:25 -07:00
|
|
|
#ifdef CONFIG_SUPERH
|
|
|
|
#define INTC_NR_IRQS 512
|
|
|
|
#else
|
|
|
|
#define INTC_NR_IRQS 1024
|
|
|
|
#endif
|
|
|
|
|
2012-01-17 10:20:23 -07:00
|
|
|
/*
|
|
|
|
* Convert back and forth between INTEVT and IRQ values.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_CPU_HAS_INTEVT
|
|
|
|
#define evt2irq(evt) (((evt) >> 5) - 16)
|
|
|
|
#define irq2evt(irq) (((irq) + 16) << 5)
|
|
|
|
#else
|
|
|
|
#define evt2irq(evt) (evt)
|
|
|
|
#define irq2evt(irq) (irq)
|
|
|
|
#endif
|
|
|
|
|
2008-10-01 01:13:54 -06:00
|
|
|
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 } }
|
|
|
|
|
2010-10-04 13:47:03 -06:00
|
|
|
struct intc_subgroup {
|
|
|
|
unsigned long reg, reg_width;
|
|
|
|
intc_enum parent_id;
|
|
|
|
intc_enum enum_ids[32];
|
|
|
|
};
|
|
|
|
|
2008-10-01 01:13:54 -06:00
|
|
|
struct intc_mask_reg {
|
|
|
|
unsigned long set_reg, clr_reg, reg_width;
|
|
|
|
intc_enum enum_ids[32];
|
2010-04-14 22:13:52 -06:00
|
|
|
#ifdef CONFIG_INTC_BALANCING
|
|
|
|
unsigned long dist_reg;
|
|
|
|
#endif
|
2008-10-01 01:13:54 -06:00
|
|
|
#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];
|
|
|
|
};
|
|
|
|
|
2010-04-14 22:13:52 -06:00
|
|
|
#ifdef CONFIG_INTC_BALANCING
|
|
|
|
#define INTC_SMP_BALANCING(reg) .dist_reg = (reg)
|
|
|
|
#else
|
|
|
|
#define INTC_SMP_BALANCING(reg)
|
|
|
|
#endif
|
|
|
|
|
2008-10-01 01:13:54 -06:00
|
|
|
#ifdef CONFIG_SMP
|
2010-04-14 22:13:52 -06:00
|
|
|
#define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8)
|
2008-10-01 01:13:54 -06:00
|
|
|
#else
|
|
|
|
#define INTC_SMP(stride, nr)
|
|
|
|
#endif
|
|
|
|
|
2010-02-08 21:24:46 -07:00
|
|
|
struct intc_hw_desc {
|
2008-10-01 01:13:54 -06:00
|
|
|
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;
|
2010-10-04 13:47:03 -06:00
|
|
|
struct intc_subgroup *subgroups;
|
|
|
|
unsigned int nr_subgroups;
|
2008-10-01 01:13:54 -06:00
|
|
|
};
|
|
|
|
|
2010-11-08 01:02:26 -07:00
|
|
|
#define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
|
2010-10-04 13:47:03 -06:00
|
|
|
|
2010-02-08 21:24:46 -07:00
|
|
|
#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;
|
2010-03-19 01:48:01 -06:00
|
|
|
struct resource *resource;
|
|
|
|
unsigned int num_resources;
|
2010-02-08 21:29:22 -07:00
|
|
|
intc_enum force_enable;
|
2010-02-15 04:40:25 -07:00
|
|
|
intc_enum force_disable;
|
2011-12-22 17:23:30 -07:00
|
|
|
bool skip_syscore_suspend;
|
2010-02-08 21:24:46 -07:00
|
|
|
struct intc_hw_desc hw;
|
|
|
|
};
|
|
|
|
|
2008-10-01 01:13:54 -06:00
|
|
|
#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
|
|
|
|
mask_regs, prio_regs, sense_regs) \
|
|
|
|
struct intc_desc symbol __initdata = { \
|
2010-02-08 21:24:46 -07:00
|
|
|
.name = chipname, \
|
|
|
|
.hw = INTC_HW_DESC(vectors, groups, mask_regs, \
|
|
|
|
prio_regs, sense_regs, NULL), \
|
2008-10-01 01:13:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
|
|
|
|
mask_regs, prio_regs, sense_regs, ack_regs) \
|
|
|
|
struct intc_desc symbol __initdata = { \
|
2010-02-08 21:24:46 -07:00
|
|
|
.name = chipname, \
|
|
|
|
.hw = INTC_HW_DESC(vectors, groups, mask_regs, \
|
|
|
|
prio_regs, sense_regs, ack_regs), \
|
2008-10-01 01:13:54 -06:00
|
|
|
}
|
|
|
|
|
2010-10-05 07:10:30 -06:00
|
|
|
int register_intc_controller(struct intc_desc *desc);
|
2008-10-01 01:13:54 -06:00
|
|
|
int intc_set_priority(unsigned int irq, unsigned int prio);
|
2010-10-05 03:13:23 -06:00
|
|
|
int intc_irq_lookup(const char *chipname, intc_enum enum_id);
|
2010-10-04 13:47:03 -06:00
|
|
|
void intc_finalize(void);
|
2008-10-01 01:13:54 -06:00
|
|
|
|
2010-04-12 23:43:03 -06:00
|
|
|
#ifdef CONFIG_INTC_USERIMASK
|
|
|
|
int register_intc_userimask(unsigned long addr);
|
|
|
|
#else
|
|
|
|
static inline int register_intc_userimask(unsigned long addr)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-01 01:13:54 -06:00
|
|
|
#endif /* __SH_INTC_H */
|