Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_bus_puc.c
Show All 40 Lines | |||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <dev/puc/puc_bus.h> | #include <dev/puc/puc_bus.h> | ||||
#include <dev/uart/uart.h> | #include <dev/uart/uart.h> | ||||
#include <dev/uart/uart_bus.h> | #include <dev/uart/uart_bus.h> | ||||
static int uart_puc_probe(device_t dev); | static int uart_puc_probe(device_t dev); | ||||
static void uart_puc_adjust_rclk(device_t dev, void *bptr); | |||||
static device_method_t uart_puc_methods[] = { | static device_method_t uart_puc_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, uart_puc_probe), | DEVMETHOD(device_probe, uart_puc_probe), | ||||
DEVMETHOD(device_attach, uart_bus_attach), | DEVMETHOD(device_attach, uart_bus_attach), | ||||
DEVMETHOD(device_detach, uart_bus_detach), | DEVMETHOD(device_detach, uart_bus_detach), | ||||
/* Serdev interface */ | /* Serdev interface */ | ||||
DEVMETHOD(serdev_ihand, uart_bus_ihand), | DEVMETHOD(serdev_ihand, uart_bus_ihand), | ||||
DEVMETHOD(serdev_ipend, uart_bus_ipend), | DEVMETHOD(serdev_ipend, uart_bus_ipend), | ||||
DEVMETHOD(serdev_adjust_rclk, uart_puc_adjust_rclk), | |||||
{ 0, 0 } | { 0, 0 } | ||||
}; | }; | ||||
static driver_t uart_puc_driver = { | static driver_t uart_puc_driver = { | ||||
uart_driver_name, | uart_driver_name, | ||||
uart_puc_methods, | uart_puc_methods, | ||||
sizeof(struct uart_softc), | sizeof(struct uart_softc), | ||||
}; | }; | ||||
Show All 13 Lines | uart_puc_probe(device_t dev) | ||||
if (type != PUC_TYPE_SERIAL) | if (type != PUC_TYPE_SERIAL) | ||||
return (ENXIO); | return (ENXIO); | ||||
sc->sc_class = &uart_ns8250_class; | sc->sc_class = &uart_ns8250_class; | ||||
if (BUS_READ_IVAR(parent, dev, PUC_IVAR_CLOCK, &rclk)) | if (BUS_READ_IVAR(parent, dev, PUC_IVAR_CLOCK, &rclk)) | ||||
rclk = 0; | rclk = 0; | ||||
return (uart_bus_probe(dev, 0, 0, rclk, 0, 0)); | return (uart_bus_probe(dev, 0, 0, rclk, 0, 0)); | ||||
} | |||||
static void | |||||
uart_puc_adjust_rclk(device_t dev, void *bptr) | |||||
{ | |||||
struct baud_fraction *baud = bptr; | |||||
struct uart_softc *sc = device_get_softc(dev); | |||||
device_t parent; | |||||
uintptr_t rclk; | |||||
parent = device_get_parent(sc->sc_dev); | |||||
BUS_WRITE_IVAR(parent, sc->sc_dev, PUC_IVAR_TARGETBAUD, (uintptr_t)baud); | |||||
if (BUS_READ_IVAR(parent, sc->sc_dev, PUC_IVAR_CLOCK, &rclk) == 0) | |||||
sc->sc_bas.rclk = rclk; | |||||
} | } | ||||
DRIVER_MODULE(uart, puc, uart_puc_driver, uart_devclass, 0, 0); | DRIVER_MODULE(uart, puc, uart_puc_driver, uart_devclass, 0, 0); |