Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/buslogic/bt_pci.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#define BT_PCI_IOADDR PCIR_BAR(0) | #define BT_PCI_IOADDR PCIR_BAR(0) | ||||
#define BT_PCI_MEMADDR PCIR_BAR(1) | #define BT_PCI_MEMADDR PCIR_BAR(1) | ||||
#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040104Bul | #define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040104Bul | ||||
#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140104Bul | #define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140104Bul | ||||
#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130104Bul | #define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130104Bul | ||||
static struct bt_dev { | struct pci_device_table bt_devs[] = { | ||||
uint16_t vendorid; | {PCI_DEV(0x104B, 0x1040), | ||||
uint32_t deviceid; | PCI_DESCR("Buslogic Multi-Master SCSI Host Adapter")}, | ||||
const char *description; | {PCI_DEV(0x104B, 0x0140), | ||||
} bt_devs[] = { | PCI_DESCR("Buslogic Multi-Master SCSI Host Adapter")} | ||||
{0x104B, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, | |||||
"Buslogic Multi-Master SCSI Host Adapter"}, | |||||
{0x104B, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, | |||||
"Buslogic Multi-Master SCSI Host Adapter"}, | |||||
{0, 0, 0}, | |||||
}; | }; | ||||
static int | static int | ||||
bt_pci_alloc_resources(device_t dev) | bt_pci_alloc_resources(device_t dev) | ||||
{ | { | ||||
int type = 0, rid, zero; | int type = 0, rid, zero; | ||||
struct resource *regs = NULL; | struct resource *regs = NULL; | ||||
struct resource *irq = NULL; | struct resource *irq = NULL; | ||||
Show All 36 Lines | bt_pci_release_resources(device_t dev) | ||||
if (bt->irq) | if (bt->irq) | ||||
bus_release_resource(dev, SYS_RES_IRQ, 0, bt->irq); | bus_release_resource(dev, SYS_RES_IRQ, 0, bt->irq); | ||||
bt_free_softc(dev); | bt_free_softc(dev); | ||||
} | } | ||||
static int | static int | ||||
bt_pci_probe(device_t dev) | bt_pci_probe(device_t dev) | ||||
{ | { | ||||
const struct bt_dev *btd; | const struct pci_device_table *btd; | ||||
uint32_t did; | |||||
size_t i; | |||||
did = pci_get_devid(dev); | btd = PCI_MATCH(dev, bt_devs); | ||||
for (i = 0; i < nitems(bt_devs) - 1; i++) { | if (btd == NULL) | ||||
btd = &bt_devs[i]; | return (ENXIO); | ||||
if (btd->deviceid == did) { | |||||
struct bt_softc *bt = device_get_softc(dev); | struct bt_softc *bt = device_get_softc(dev); | ||||
pci_info_data_t pci_info; | pci_info_data_t pci_info; | ||||
int error; | int error; | ||||
error = bt_pci_alloc_resources(dev); | error = bt_pci_alloc_resources(dev); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
/* | /* | ||||
* Determine if an ISA compatible I/O port has been | * Determine if an ISA compatible I/O port has been | ||||
* enabled. If so, record the port so it will not | * enabled. If so, record the port so it will not | ||||
* be probed by our ISA probe. If the PCI I/O port | * be probed by our ISA probe. If the PCI I/O port | ||||
* was not set to the compatibility port, disable it. | * was not set to the compatibility port, disable it. | ||||
*/ | */ | ||||
error = bt_cmd(bt, BOP_INQUIRE_PCI_INFO, | error = bt_cmd(bt, BOP_INQUIRE_PCI_INFO, | ||||
/*param*/NULL, /*paramlen*/0, | /*param*/NULL, /*paramlen*/0, | ||||
(u_int8_t*)&pci_info, sizeof(pci_info), | (u_int8_t*)&pci_info, sizeof(pci_info), | ||||
DEFAULT_CMD_TIMEOUT); | DEFAULT_CMD_TIMEOUT); | ||||
if (error == 0 | if (error == 0 | ||||
&& pci_info.io_port < BIO_DISABLED) { | && pci_info.io_port < BIO_DISABLED) { | ||||
bt_mark_probed_bio(pci_info.io_port); | bt_mark_probed_bio(pci_info.io_port); | ||||
if (rman_get_start(bt->port) != | if (rman_get_start(bt->port) != | ||||
bt_iop_from_bio(pci_info.io_port)) { | bt_iop_from_bio(pci_info.io_port)) { | ||||
u_int8_t new_addr; | u_int8_t new_addr; | ||||
new_addr = BIO_DISABLED; | new_addr = BIO_DISABLED; | ||||
bt_cmd(bt, BOP_MODIFY_IO_ADDR, | bt_cmd(bt, BOP_MODIFY_IO_ADDR, | ||||
/*param*/&new_addr, | /*param*/&new_addr, | ||||
/*paramlen*/1, /*reply_buf*/NULL, | /*paramlen*/1, /*reply_buf*/NULL, | ||||
/*reply_len*/0, | /*reply_len*/0, | ||||
DEFAULT_CMD_TIMEOUT); | DEFAULT_CMD_TIMEOUT); | ||||
} | } | ||||
} | } | ||||
bt_pci_release_resources(dev); | bt_pci_release_resources(dev); | ||||
device_set_desc(dev, btd->description); | device_set_desc(dev, btd->descr); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
} | |||||
return (ENXIO); | |||||
} | |||||
static int | static int | ||||
bt_pci_attach(device_t dev) | bt_pci_attach(device_t dev) | ||||
{ | { | ||||
struct bt_softc *bt = device_get_softc(dev); | struct bt_softc *bt = device_get_softc(dev); | ||||
int error; | int error; | ||||
/* Initialize softc */ | /* Initialize softc */ | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | static driver_t bt_pci_driver = { | ||||
"bt", | "bt", | ||||
bt_pci_methods, | bt_pci_methods, | ||||
sizeof(struct bt_softc), | sizeof(struct bt_softc), | ||||
}; | }; | ||||
static devclass_t bt_devclass; | static devclass_t bt_devclass; | ||||
DRIVER_MODULE(bt, pci, bt_pci_driver, bt_devclass, 0, 0); | DRIVER_MODULE(bt, pci, bt_pci_driver, bt_devclass, 0, 0); | ||||
MODULE_PNP_INFO("U16:vendor;W32:vendor/device;D:#", pci, bt, bt_devs, | PCI_PNP_INFO(bt_devs); | ||||
sizeof(bt_devs[0]), nitems(bt_devs) - 1); | |||||
MODULE_DEPEND(bt, pci, 1, 1, 1); | MODULE_DEPEND(bt, pci, 1, 1, 1); |