xics.h 4.0 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * Common definitions accross all variants of ICP and ICS interrupt
 * controllers.
 */

#ifndef _XICS_H
#define _XICS_H

9 10
#include <linux/interrupt.h>

11 12 13 14 15 16 17
#define XICS_IPI		2
#define XICS_IRQ_SPURIOUS	0

/* Want a priority other than 0.  Various HW issues require this. */
#define	DEFAULT_PRIORITY	5

/*
Y
Yong Zhang 已提交
18 19
 * Mark IPIs as higher priority so we can take them inside interrupts
 * FIXME: still true now?
20 21 22 23 24 25 26 27 28 29
 */
#define IPI_PRIORITY		4

/* The least favored priority */
#define LOWEST_PRIORITY		0xFF

/* The number of priorities defined above */
#define MAX_NUM_PRIORITIES	3

/* Native ICP */
30
#ifdef CONFIG_PPC_ICP_NATIVE
31
extern int icp_native_init(void);
32
extern void icp_native_flush_interrupt(void);
33 34 35
#else
static inline int icp_native_init(void) { return -ENODEV; }
#endif
36 37

/* PAPR ICP */
38
#ifdef CONFIG_PPC_ICP_HV
39
extern int icp_hv_init(void);
40 41 42
#else
static inline int icp_hv_init(void) { return -ENODEV; }
#endif
43 44 45 46 47 48 49 50 51

/* ICP ops */
struct icp_ops {
	unsigned int (*get_irq)(void);
	void (*eoi)(struct irq_data *d);
	void (*set_priority)(unsigned char prio);
	void (*teardown_cpu)(void);
	void (*flush_ipi)(void);
#ifdef CONFIG_SMP
52
	void (*cause_ipi)(int cpu, unsigned long data);
53 54 55 56 57 58 59 60 61 62
	irq_handler_t ipi_action;
#endif
};

extern const struct icp_ops *icp_ops;

/* Native ICS */
extern int ics_native_init(void);

/* RTAS ICS */
63
#ifdef CONFIG_PPC_ICS_RTAS
64
extern int ics_rtas_init(void);
65 66 67 68 69 70 71 72 73 74
#else
static inline int ics_rtas_init(void) { return -ENODEV; }
#endif

/* HAL ICS */
#ifdef CONFIG_PPC_POWERNV
extern int ics_opal_init(void);
#else
static inline int ics_opal_init(void) { return -ENODEV; }
#endif
75 76 77 78 79 80 81

/* ICS instance, hooked up to chip_data of an irq */
struct ics {
	struct list_head link;
	int (*map)(struct ics *ics, unsigned int virq);
	void (*mask_unknown)(struct ics *ics, unsigned long vec);
	long (*get_server)(struct ics *ics, unsigned long vec);
82
	int (*host_match)(struct ics *ics, struct device_node *node);
83 84 85 86 87 88 89
	char data[];
};

/* Commons */
extern unsigned int xics_default_server;
extern unsigned int xics_default_distrib_server;
extern unsigned int xics_interrupt_server_size;
90
extern struct irq_domain *xics_host;
91 92 93 94 95 96 97 98 99 100

struct xics_cppr {
	unsigned char stack[MAX_NUM_PRIORITIES];
	int index;
};

DECLARE_PER_CPU(struct xics_cppr, xics_cppr);

static inline void xics_push_cppr(unsigned int vec)
{
101
	struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
102 103 104 105 106 107 108 109 110 111 112 113

	if (WARN_ON(os_cppr->index >= MAX_NUM_PRIORITIES - 1))
		return;

	if (vec == XICS_IPI)
		os_cppr->stack[++os_cppr->index] = IPI_PRIORITY;
	else
		os_cppr->stack[++os_cppr->index] = DEFAULT_PRIORITY;
}

static inline unsigned char xics_pop_cppr(void)
{
114
	struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
115 116 117 118 119 120 121 122 123

	if (WARN_ON(os_cppr->index < 1))
		return LOWEST_PRIORITY;

	return os_cppr->stack[--os_cppr->index];
}

static inline void xics_set_base_cppr(unsigned char cppr)
{
124
	struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
125 126 127 128 129 130 131 132 133 134 135

	/* we only really want to set the priority when there's
	 * just one cppr value on the stack
	 */
	WARN_ON(os_cppr->index != 0);

	os_cppr->stack[0] = cppr;
}

static inline unsigned char xics_cppr_top(void)
{
136
	struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
	
	return os_cppr->stack[os_cppr->index];
}

DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, xics_ipi_message);

extern void xics_init(void);
extern void xics_setup_cpu(void);
extern void xics_update_irq_servers(void);
extern void xics_set_cpu_giq(unsigned int gserver, unsigned int join);
extern void xics_mask_unknown_vec(unsigned int vec);
extern irqreturn_t xics_ipi_dispatch(int cpu);
extern int xics_smp_probe(void);
extern void xics_register_ics(struct ics *ics);
extern void xics_teardown_cpu(void);
extern void xics_kexec_teardown_cpu(int secondary);
extern void xics_migrate_irqs_away(void);
154
extern void icp_native_eoi(struct irq_data *d);
155 156 157 158 159 160 161 162 163
#ifdef CONFIG_SMP
extern int xics_get_irq_server(unsigned int virq, const struct cpumask *cpumask,
			       unsigned int strict_check);
#else
#define xics_get_irq_server(virq, cpumask, strict_check) (xics_default_server)
#endif


#endif /* _XICS_H */