10 #include <linux/types.h>
11 #include <linux/kernel.h>
21 #include <asm/errno.h>
26 static inline unsigned int icp_hv_get_xirr(
unsigned char cppr)
28 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
32 rc = plpar_hcall(H_XIRR, retbuf, cppr);
33 if (rc == H_SUCCESS) {
34 ret = (
unsigned int)retbuf[0];
36 pr_err(
"%s: bad return code xirr cppr=0x%x returned %ld\n",
44 static inline void icp_hv_set_cppr(
u8 value)
46 long rc = plpar_hcall_norets(H_CPPR, value);
47 if (rc != H_SUCCESS) {
48 pr_err(
"%s: bad return code cppr cppr=0x%x returned %ld\n",
54 static inline void icp_hv_set_xirr(
unsigned int value)
56 long rc = plpar_hcall_norets(H_EOI, value);
57 if (rc != H_SUCCESS) {
58 pr_err(
"%s: bad return code eoi xirr=0x%x returned %ld\n",
61 icp_hv_set_cppr(value >> 24);
65 static inline void icp_hv_set_qirr(
int n_cpu ,
u8 value)
67 int hw_cpu = get_hard_smp_processor_id(n_cpu);
72 rc = plpar_hcall_norets(H_IPI, hw_cpu, value);
73 if (rc != H_SUCCESS) {
74 pr_err(
"%s: bad return code qirr cpu=%d hw_cpu=%d mfrr=0x%x "
75 "returned %ld\n", __func__, n_cpu, hw_cpu, value, rc);
80 static void icp_hv_eoi(
struct irq_data *
d)
82 unsigned int hw_irq = (
unsigned int)irqd_to_hwirq(d);
85 icp_hv_set_xirr((xics_pop_cppr() << 24) | hw_irq);
88 static void icp_hv_teardown_cpu(
void)
93 icp_hv_set_qirr(cpu, 0xff);
96 static void icp_hv_flush_ipi(
void)
106 icp_hv_set_xirr((0x00 << 24) |
XICS_IPI);
109 static unsigned int icp_hv_get_irq(
void)
111 unsigned int xirr = icp_hv_get_xirr(xics_cppr_top());
112 unsigned int vec = xirr & 0x00ffffff;
128 icp_hv_set_xirr(xirr);
133 static void icp_hv_set_cpu_priority(
unsigned char cppr)
135 xics_set_base_cppr(cppr);
136 icp_hv_set_cppr(cppr);
142 static void icp_hv_cause_ipi(
int cpu,
unsigned long data)
151 icp_hv_set_qirr(cpu, 0xff);
153 return smp_ipi_demux();
158 static const struct icp_ops icp_hv_ops = {
159 .get_irq = icp_hv_get_irq,
161 .set_priority = icp_hv_set_cpu_priority,
162 .teardown_cpu = icp_hv_teardown_cpu,
163 .flush_ipi = icp_hv_flush_ipi,
165 .ipi_action = icp_hv_ipi_action,
166 .cause_ipi = icp_hv_cause_ipi,
177 "PowerPC-External-Interrupt-Presentation");