treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / powerpc / include / asm / xics.h
blob8e903b3f9c24902cf3548704cd5dda4af3687ba2
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Common definitions across all variants of ICP and ICS interrupt
4 * controllers.
5 */
7 #ifndef _XICS_H
8 #define _XICS_H
10 #include <linux/interrupt.h>
12 #define XICS_IPI 2
13 #define XICS_IRQ_SPURIOUS 0
15 /* Want a priority other than 0. Various HW issues require this. */
16 #define DEFAULT_PRIORITY 5
19 * Mark IPIs as higher priority so we can take them inside interrupts
20 * FIXME: still true now?
22 #define IPI_PRIORITY 4
24 /* The least favored priority */
25 #define LOWEST_PRIORITY 0xFF
27 /* The number of priorities defined above */
28 #define MAX_NUM_PRIORITIES 3
30 /* Native ICP */
31 #ifdef CONFIG_PPC_ICP_NATIVE
32 extern int icp_native_init(void);
33 extern void icp_native_flush_interrupt(void);
34 extern void icp_native_cause_ipi_rm(int cpu);
35 #else
36 static inline int icp_native_init(void) { return -ENODEV; }
37 #endif
39 /* PAPR ICP */
40 #ifdef CONFIG_PPC_ICP_HV
41 extern int icp_hv_init(void);
42 #else
43 static inline int icp_hv_init(void) { return -ENODEV; }
44 #endif
46 #ifdef CONFIG_PPC_POWERNV
47 extern int icp_opal_init(void);
48 extern void icp_opal_flush_interrupt(void);
49 #else
50 static inline int icp_opal_init(void) { return -ENODEV; }
51 #endif
53 /* ICP ops */
54 struct icp_ops {
55 unsigned int (*get_irq)(void);
56 void (*eoi)(struct irq_data *d);
57 void (*set_priority)(unsigned char prio);
58 void (*teardown_cpu)(void);
59 void (*flush_ipi)(void);
60 #ifdef CONFIG_SMP
61 void (*cause_ipi)(int cpu);
62 irq_handler_t ipi_action;
63 #endif
66 extern const struct icp_ops *icp_ops;
68 /* Native ICS */
69 extern int ics_native_init(void);
71 /* RTAS ICS */
72 #ifdef CONFIG_PPC_ICS_RTAS
73 extern int ics_rtas_init(void);
74 #else
75 static inline int ics_rtas_init(void) { return -ENODEV; }
76 #endif
78 /* HAL ICS */
79 #ifdef CONFIG_PPC_POWERNV
80 extern int ics_opal_init(void);
81 #else
82 static inline int ics_opal_init(void) { return -ENODEV; }
83 #endif
85 /* ICS instance, hooked up to chip_data of an irq */
86 struct ics {
87 struct list_head link;
88 int (*map)(struct ics *ics, unsigned int virq);
89 void (*mask_unknown)(struct ics *ics, unsigned long vec);
90 long (*get_server)(struct ics *ics, unsigned long vec);
91 int (*host_match)(struct ics *ics, struct device_node *node);
92 char data[];
95 /* Commons */
96 extern unsigned int xics_default_server;
97 extern unsigned int xics_default_distrib_server;
98 extern unsigned int xics_interrupt_server_size;
99 extern struct irq_domain *xics_host;
101 struct xics_cppr {
102 unsigned char stack[MAX_NUM_PRIORITIES];
103 int index;
106 DECLARE_PER_CPU(struct xics_cppr, xics_cppr);
108 static inline void xics_push_cppr(unsigned int vec)
110 struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
112 if (WARN_ON(os_cppr->index >= MAX_NUM_PRIORITIES - 1))
113 return;
115 if (vec == XICS_IPI)
116 os_cppr->stack[++os_cppr->index] = IPI_PRIORITY;
117 else
118 os_cppr->stack[++os_cppr->index] = DEFAULT_PRIORITY;
121 static inline unsigned char xics_pop_cppr(void)
123 struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
125 if (WARN_ON(os_cppr->index < 1))
126 return LOWEST_PRIORITY;
128 return os_cppr->stack[--os_cppr->index];
131 static inline void xics_set_base_cppr(unsigned char cppr)
133 struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
135 /* we only really want to set the priority when there's
136 * just one cppr value on the stack
138 WARN_ON(os_cppr->index != 0);
140 os_cppr->stack[0] = cppr;
143 static inline unsigned char xics_cppr_top(void)
145 struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
147 return os_cppr->stack[os_cppr->index];
150 DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, xics_ipi_message);
152 extern void xics_init(void);
153 extern void xics_setup_cpu(void);
154 extern void xics_update_irq_servers(void);
155 extern void xics_set_cpu_giq(unsigned int gserver, unsigned int join);
156 extern void xics_mask_unknown_vec(unsigned int vec);
157 extern irqreturn_t xics_ipi_dispatch(int cpu);
158 extern void xics_smp_probe(void);
159 extern void xics_register_ics(struct ics *ics);
160 extern void xics_teardown_cpu(void);
161 extern void xics_kexec_teardown_cpu(int secondary);
162 extern void xics_migrate_irqs_away(void);
163 extern void icp_native_eoi(struct irq_data *d);
164 extern int xics_set_irq_type(struct irq_data *d, unsigned int flow_type);
165 extern int xics_retrigger(struct irq_data *data);
166 #ifdef CONFIG_SMP
167 extern int xics_get_irq_server(unsigned int virq, const struct cpumask *cpumask,
168 unsigned int strict_check);
169 #else
170 #define xics_get_irq_server(virq, cpumask, strict_check) (xics_default_server)
171 #endif
174 #endif /* _XICS_H */