Changeset View
Changeset View
Standalone View
Standalone View
sys/sparc64/ebus/ebus.c
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | |||||
* NB: we rely on the interrupt controllers of the accompanying PCI-Express | * NB: we rely on the interrupt controllers of the accompanying PCI-Express | ||||
* bridge to be registered as the nexus variant of the EBus bridges doesn't | * bridge to be registered as the nexus variant of the EBus bridges doesn't | ||||
* employ its own one. | * employ its own one. | ||||
*/ | */ | ||||
EARLY_DRIVER_MODULE(ebus, nexus, ebus_nexus_driver, ebus_devclass, 0, 0, | EARLY_DRIVER_MODULE(ebus, nexus, ebus_nexus_driver, ebus_devclass, 0, 0, | ||||
BUS_PASS_BUS + 1); | BUS_PASS_BUS + 1); | ||||
MODULE_DEPEND(ebus, nexus, 1, 1, 1); | MODULE_DEPEND(ebus, nexus, 1, 1, 1); | ||||
static struct ebus_pci_dev { | struct pci_device_table ebus_pci_devs[] = { | ||||
uint16_t vendorid; | {PCI_DEV(0x108e, 0x1000), | ||||
uint16_t deviceid; | PCI_DESCR("PCI-EBus2 bridge")}, | ||||
const char *description; | {PCI_DEV(0x108e, 0x1100), | ||||
} ebus_pci_devs[] = { | PCI_DESCR("PCI-EBus3 bridge")} | ||||
{0x108e, 0x1000, "PCI-EBus2 bridge"}, | |||||
{0x108e, 0x1100, "PCI-EBus3 bridge"}, | |||||
{0, 0, 0}, | |||||
} | } | ||||
static device_method_t ebus_pci_methods[] = { | static device_method_t ebus_pci_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, ebus_pci_probe), | DEVMETHOD(device_probe, ebus_pci_probe), | ||||
DEVMETHOD(device_attach, ebus_pci_attach), | DEVMETHOD(device_attach, ebus_pci_attach), | ||||
DEVMETHOD(device_shutdown, bus_generic_shutdown), | DEVMETHOD(device_shutdown, bus_generic_shutdown), | ||||
DEVMETHOD(device_suspend, bus_generic_suspend), | DEVMETHOD(device_suspend, bus_generic_suspend), | ||||
Show All 26 Lines | |||||
static driver_t ebus_pci_driver = { | static driver_t ebus_pci_driver = { | ||||
"ebus", | "ebus", | ||||
ebus_pci_methods, | ebus_pci_methods, | ||||
sizeof(struct ebus_softc), | sizeof(struct ebus_softc), | ||||
}; | }; | ||||
EARLY_DRIVER_MODULE(ebus, pci, ebus_pci_driver, ebus_devclass, 0, 0, | EARLY_DRIVER_MODULE(ebus, pci, ebus_pci_driver, ebus_devclass, 0, 0, | ||||
BUS_PASS_BUS); | BUS_PASS_BUS); | ||||
MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, ebus, ebus_pci_devs, | PCI_PNP_INFO(ebus_pci_devs); | ||||
sizeof(ebus_pci_devs[0]), nitems(ebus_pci_devs) - 1); | |||||
MODULE_DEPEND(ebus, pci, 1, 1, 1); | MODULE_DEPEND(ebus, pci, 1, 1, 1); | ||||
MODULE_VERSION(ebus, 1); | MODULE_VERSION(ebus, 1); | ||||
static int | static int | ||||
ebus_nexus_probe(device_t dev) | ebus_nexus_probe(device_t dev) | ||||
{ | { | ||||
const char* compat; | const char* compat; | ||||
compat = ofw_bus_get_compat(dev); | compat = ofw_bus_get_compat(dev); | ||||
if (compat != NULL && strcmp(ofw_bus_get_name(dev), "ebus") == 0 && | if (compat != NULL && strcmp(ofw_bus_get_name(dev), "ebus") == 0 && | ||||
strcmp(compat, "jbus-ebus") == 0) { | strcmp(compat, "jbus-ebus") == 0) { | ||||
device_set_desc(dev, "JBus-EBus bridge"); | device_set_desc(dev, "JBus-EBus bridge"); | ||||
return (BUS_PROBE_GENERIC); | return (BUS_PROBE_GENERIC); | ||||
} | } | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
static int | static int | ||||
ebus_pci_probe(device_t dev) | ebus_pci_probe(device_t dev) | ||||
{ | { | ||||
const struct ebus_pci_dev *ebd; | const struct pci_device_table *ebd; | ||||
uint16_t did; | uint16_t did; | ||||
size_t i; | |||||
did = pci_get_device(dev); | did = pci_get_device(dev); | ||||
if (pci_get_class(dev) != PCIC_BRIDGE || | if (pci_get_class(dev) != PCIC_BRIDGE || | ||||
pci_get_vendor(dev) != 0x108e || | pci_get_vendor(dev) != 0x108e || | ||||
strcmp(ofw_bus_get_name(dev), "ebus") != 0) | strcmp(ofw_bus_get_name(dev), "ebus") != 0) | ||||
return (ENXIO); | return (ENXIO); | ||||
for (i = 0; i < nitems(ebus_pci_devs) - 1; i++) { | |||||
ebd = &ebus_pci_devs[i]; | ebd = PCI_MATCH(dev, ebus_pci_devs); | ||||
if (did == ebd->deviceid) { | if (ebd == NULL) | ||||
device_set_desc(dev, ebd->description); | |||||
return (BUS_PROBE_GENERIC); | |||||
} | |||||
} | |||||
return (ENXIO); | return (ENXIO); | ||||
device_set_desc(dev, ebd->descr); | |||||
return (BUS_PROBE_GENERIC); | |||||
} | } | ||||
static int | static int | ||||
ebus_nexus_attach(device_t dev) | ebus_nexus_attach(device_t dev) | ||||
{ | { | ||||
struct ebus_softc *sc; | struct ebus_softc *sc; | ||||
phandle_t node; | phandle_t node; | ||||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |