14 #include <linux/types.h>
15 #include <linux/kernel.h>
27 #include <asm/machdep.h>
29 #include <asm/errno.h>
34 static int ics_opal_mangle_server(
int server)
40 static int ics_opal_unmangle_server(
int server)
46 static void ics_opal_unmask_irq(
struct irq_data *
d)
48 unsigned int hw_irq = (
unsigned int)irqd_to_hwirq(d);
52 pr_devel(
"ics-hal: unmask virq %d [hw 0x%x]\n", d->
irq, hw_irq);
58 server = ics_opal_mangle_server(server);
62 pr_err(
"%s: opal_set_xive(irq=%d [hw 0x%x] server=%x)"
64 __func__, d->
irq, hw_irq, server, rc);
67 static unsigned int ics_opal_startup(
struct irq_data *d)
80 ics_opal_unmask_irq(d);
84 static void ics_opal_mask_real_irq(
unsigned int hw_irq)
95 pr_err(
"%s: opal_set_xive(0xff) irq=%u returned %lld\n",
96 __func__, hw_irq, rc);
99 static void ics_opal_mask_irq(
struct irq_data *d)
101 unsigned int hw_irq = (
unsigned int)irqd_to_hwirq(d);
103 pr_devel(
"ics-hal: mask virq %d [hw 0x%x]\n", d->
irq, hw_irq);
107 ics_opal_mask_real_irq(hw_irq);
110 static int ics_opal_set_affinity(
struct irq_data *d,
114 unsigned int hw_irq = (
unsigned int)irqd_to_hwirq(d);
125 pr_err(
"%s: opal_set_xive(irq=%d [hw 0x%x] server=%x)"
127 __func__, d->
irq, hw_irq, server, rc);
132 if (wanted_server < 0) {
134 cpumask_scnprintf(cpulist,
sizeof(cpulist), cpumask);
135 pr_warning(
"%s: No online cpus in the mask %s for irq %d\n",
136 __func__, cpulist, d->
irq);
139 server = ics_opal_mangle_server(wanted_server);
141 pr_devel(
"ics-hal: set-affinity irq %d [hw 0x%x] server: 0x%x/0x%x\n",
142 d->
irq, hw_irq, wanted_server, server);
146 pr_err(
"%s: opal_set_xive(irq=%d [hw 0x%x] server=%x)"
148 __func__, d->
irq, hw_irq, server, rc);
154 static struct irq_chip ics_opal_irq_chip = {
156 .irq_startup = ics_opal_startup,
157 .irq_mask = ics_opal_mask_irq,
158 .irq_unmask = ics_opal_unmask_irq,
160 .irq_set_affinity = ics_opal_set_affinity
163 static int ics_opal_map(
struct ics *
ics,
unsigned int virq);
164 static void ics_opal_mask_unknown(
struct ics *
ics,
unsigned long vec);
165 static long ics_opal_get_server(
struct ics *
ics,
unsigned long vec);
173 static struct ics ics_hal = {
175 .mask_unknown = ics_opal_mask_unknown,
176 .get_server = ics_opal_get_server,
177 .host_match = ics_opal_host_match,
180 static int ics_opal_map(
struct ics *
ics,
unsigned int virq)
201 static void ics_opal_mask_unknown(
struct ics *ics,
unsigned long vec)
212 ics_opal_mask_real_irq(vec);
215 static long ics_opal_get_server(
struct ics *ics,
unsigned long vec)
225 return ics_opal_unmangle_server(server);
230 if (!firmware_has_feature(FW_FEATURE_OPAL))
241 pr_info(
"ICS OPAL backend registered\n");