intr/powerpc: create openpic_class kobj
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run

Using kobj allows implementing most PIC functions merely by inheriting
from the parent class.  As there are multiple OpenPIC implementations,
this ensures all common hooks go through by default.

Note, this adds the suspend/resume functions to other PICs.  This should
be harmless as suspend/resume isn't working on the devices anyway.

Reviewed by:	jhibbits
MFC after:	2 weeks
This commit is contained in:
Elliott Mitchell 2025-01-02 11:03:40 -08:00 committed by Justin Hibbits
parent 319a1dbcf4
commit 8fb1789612
5 changed files with 38 additions and 52 deletions

View file

@ -28,6 +28,8 @@
#ifndef _POWERPC_OPENPICVAR_H_
#define _POWERPC_OPENPICVAR_H_
#include <sys/kobj.h>
#define OPENPIC_DEVSTR "OpenPIC Interrupt Controller"
#define OPENPIC_IRQMAX 256 /* h/w allows more */
@ -75,16 +77,11 @@ int openpic_common_attach(device_t, uint32_t);
/*
* PIC interface.
*/
void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **);
void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity);
void openpic_dispatch(device_t, struct trapframe *);
void openpic_enable(device_t, u_int, u_int, void **);
void openpic_eoi(device_t, u_int, void *);
void openpic_ipi(device_t, u_int);
void openpic_mask(device_t, u_int, void *);
void openpic_unmask(device_t, u_int, void *);
int openpic_suspend(device_t dev);
int openpic_resume(device_t dev);
DECLARE_CLASS(openpic_class);
#endif /* _POWERPC_OPENPICVAR_H_ */

View file

@ -68,29 +68,15 @@ static device_method_t openpic_ofw_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, openpic_ofw_probe),
DEVMETHOD(device_attach, openpic_ofw_attach),
DEVMETHOD(device_suspend, openpic_suspend),
DEVMETHOD(device_resume, openpic_resume),
/* PIC interface */
DEVMETHOD(pic_bind, openpic_bind),
DEVMETHOD(pic_config, openpic_config),
DEVMETHOD(pic_dispatch, openpic_dispatch),
DEVMETHOD(pic_enable, openpic_enable),
DEVMETHOD(pic_eoi, openpic_eoi),
DEVMETHOD(pic_ipi, openpic_ipi),
DEVMETHOD(pic_mask, openpic_mask),
DEVMETHOD(pic_unmask, openpic_unmask),
DEVMETHOD(pic_translate_code, openpic_ofw_translate_code),
DEVMETHOD_END
};
static driver_t openpic_ofw_driver = {
"openpic",
openpic_ofw_methods,
sizeof(struct openpic_softc),
};
DEFINE_CLASS_1(openpic, openpic_ofw_driver, openpic_ofw_methods,
sizeof(struct openpic_softc), openpic_class);
EARLY_DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, 0, 0,
BUS_PASS_INTERRUPT);

View file

@ -520,16 +520,12 @@ static device_method_t openpic_cpcht_methods[] = {
DEVMETHOD(device_attach, openpic_cpcht_attach),
/* PIC interface */
DEVMETHOD(pic_bind, openpic_bind),
DEVMETHOD(pic_config, openpic_cpcht_config),
DEVMETHOD(pic_dispatch, openpic_dispatch),
DEVMETHOD(pic_enable, openpic_cpcht_enable),
DEVMETHOD(pic_eoi, openpic_cpcht_eoi),
DEVMETHOD(pic_ipi, openpic_ipi),
DEVMETHOD(pic_mask, openpic_mask),
DEVMETHOD(pic_unmask, openpic_cpcht_unmask),
{ 0, 0 },
DEVMETHOD_END
};
struct openpic_cpcht_softc {
@ -538,11 +534,8 @@ struct openpic_cpcht_softc {
struct mtx sc_ht_mtx;
};
static driver_t openpic_cpcht_driver = {
"htpic",
openpic_cpcht_methods,
sizeof(struct openpic_cpcht_softc),
};
DEFINE_CLASS_1(htpic, openpic_cpcht_driver, openpic_cpcht_methods,
sizeof(struct openpic_cpcht_softc), openpic_class);
EARLY_DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, 0, 0,
BUS_PASS_INTERRUPT);

View file

@ -225,7 +225,7 @@ openpic_common_attach(device_t dev, uint32_t node)
* PIC I/F methods
*/
void
static void
openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv __unused)
{
struct openpic_softc *sc;
@ -291,7 +291,7 @@ openpic_intr(void *arg)
return (FILTER_HANDLED);
}
void
static void
openpic_dispatch(device_t dev, struct trapframe *tf)
{
struct openpic_softc *sc;
@ -343,7 +343,7 @@ openpic_eoi(device_t dev, u_int irq __unused, void *priv __unused)
openpic_write(sc, OPENPIC_PCPU_EOI(cpuid), 0);
}
void
static void
openpic_ipi(device_t dev, u_int cpu)
{
struct openpic_softc *sc;
@ -357,7 +357,7 @@ openpic_ipi(device_t dev, u_int cpu)
sched_unpin();
}
void
static void
openpic_mask(device_t dev, u_int irq, void *priv __unused)
{
struct openpic_softc *sc;
@ -393,7 +393,7 @@ openpic_unmask(device_t dev, u_int irq, void *priv __unused)
}
}
int
static int
openpic_suspend(device_t dev)
{
struct openpic_softc *sc;
@ -424,7 +424,7 @@ openpic_suspend(device_t dev)
return (0);
}
int
static int
openpic_resume(device_t dev)
{
struct openpic_softc *sc;
@ -453,3 +453,24 @@ openpic_resume(device_t dev)
return (0);
}
static device_method_t openpic_methods[] = {
/* Device interface */
DEVMETHOD(device_suspend, openpic_suspend),
DEVMETHOD(device_resume, openpic_resume),
/* PIC interface */
DEVMETHOD(pic_bind, openpic_bind),
DEVMETHOD(pic_config, openpic_config),
DEVMETHOD(pic_dispatch, openpic_dispatch),
DEVMETHOD(pic_enable, openpic_enable),
DEVMETHOD(pic_eoi, openpic_eoi),
DEVMETHOD(pic_ipi, openpic_ipi),
DEVMETHOD(pic_mask, openpic_mask),
DEVMETHOD(pic_unmask, openpic_unmask),
DEVMETHOD_END
};
DEFINE_CLASS_0(openpic, openpic_class, openpic_methods,
sizeof(struct openpic_softc));

View file

@ -69,22 +69,11 @@ static device_method_t openpic_iobus_methods[] = {
DEVMETHOD(device_probe, openpic_iobus_probe),
DEVMETHOD(device_attach, openpic_iobus_attach),
/* PIC interface */
DEVMETHOD(pic_config, openpic_config),
DEVMETHOD(pic_dispatch, openpic_dispatch),
DEVMETHOD(pic_enable, openpic_enable),
DEVMETHOD(pic_eoi, openpic_eoi),
DEVMETHOD(pic_ipi, openpic_ipi),
DEVMETHOD(pic_mask, openpic_mask),
DEVMETHOD(pic_unmask, openpic_unmask),
{ 0, 0 }
DEVMETHOD_END
};
static driver_t openpic_iobus_driver = {
"openpic",
openpic_iobus_methods,
sizeof(struct openpic_softc)
};
DEFINE_CLASS_1(openpic, openpic_iobus_driver, openpic_iobus_methods,
sizeof(struct openpic_softc), openpic_class);
DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0);