Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_bus_pci.c
Show All 37 Lines | |||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#include <dev/uart/uart.h> | #include <dev/uart/uart.h> | ||||
#include <dev/uart/uart_bus.h> | #include <dev/uart/uart_bus.h> | ||||
#include <dev/uart/uart_cpu.h> | |||||
#define DEFAULT_RCLK 1843200 | #define DEFAULT_RCLK 1843200 | ||||
static int uart_pci_probe(device_t dev); | static int uart_pci_probe(device_t dev); | ||||
static int uart_pci_attach(device_t dev); | static int uart_pci_attach(device_t dev); | ||||
static int uart_pci_detach(device_t dev); | static int uart_pci_detach(device_t dev); | ||||
static device_method_t uart_pci_methods[] = { | static device_method_t uart_pci_methods[] = { | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | uart_pci_match(device_t dev, const struct pci_id *id) | ||||
subven = pci_get_subvendor(dev); | subven = pci_get_subvendor(dev); | ||||
subdev = pci_get_subdevice(dev); | subdev = pci_get_subdevice(dev); | ||||
while (id->vendor == vendor && id->device == device && | while (id->vendor == vendor && id->device == device && | ||||
(id->subven != subven || id->subdev != subdev)) | (id->subven != subven || id->subdev != subdev)) | ||||
id++; | id++; | ||||
return ((id->vendor == vendor && id->device == device) ? id : NULL); | return ((id->vendor == vendor && id->device == device) ? id : NULL); | ||||
} | } | ||||
extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; | |||||
static int | static int | ||||
uart_pci_probe(device_t dev) | uart_pci_probe(device_t dev) | ||||
{ | { | ||||
struct uart_softc *sc; | struct uart_softc *sc; | ||||
struct uart_devinfo *sysdev; | |||||
const struct pci_id *id; | const struct pci_id *id; | ||||
int result; | int result; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
id = uart_pci_match(dev, pci_ns8250_ids); | id = uart_pci_match(dev, pci_ns8250_ids); | ||||
if (id != NULL) { | if (id != NULL) { | ||||
sc->sc_class = &uart_ns8250_class; | sc->sc_class = &uart_ns8250_class; | ||||
goto match; | goto match; | ||||
} | } | ||||
/* Add checks for non-ns8250 IDs here. */ | /* Add checks for non-ns8250 IDs here. */ | ||||
return (ENXIO); | return (ENXIO); | ||||
match: | match: | ||||
SLIST_FOREACH(sysdev, &uart_sysdevs, next) { | |||||
if (sysdev->pci_info.vendor == pci_get_vendor(dev) | |||||
&& sysdev->pci_info.device == pci_get_device(dev) | |||||
&& sysdev->pci_info.bus == pci_get_bus(dev) | |||||
&& sysdev->pci_info.slot == pci_get_slot(dev)) { | |||||
sc->sc_sysdev = sysdev; | |||||
sysdev->bas.rclk = sc->sc_bas.rclk; | |||||
} | |||||
} | |||||
result = uart_bus_probe(dev, id->regshft, 0, id->rclk, id->rid, 0, 0); | result = uart_bus_probe(dev, id->regshft, 0, id->rclk, id->rid, 0, 0); | ||||
/* Bail out on error. */ | /* Bail out on error. */ | ||||
if (result > 0) | if (result > 0) | ||||
return (result); | return (result); | ||||
/* Set/override the device description. */ | /* Set/override the device description. */ | ||||
if (id->desc) | if (id->desc) | ||||
device_set_desc(dev, id->desc); | device_set_desc(dev, id->desc); | ||||
return (result); | return (result); | ||||
Show All 39 Lines |