Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_dev_snps.c
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
static int | static int | ||||
snps_probe(device_t dev) | snps_probe(device_t dev) | ||||
{ | { | ||||
struct snps_softc *sc; | struct snps_softc *sc; | ||||
struct uart_class *uart_class; | struct uart_class *uart_class; | ||||
phandle_t node; | phandle_t node; | ||||
uint32_t shift, clock; | uint32_t shift, iowidth, clock; | ||||
uint64_t freq; | uint64_t freq; | ||||
int error; | int error; | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
clk_t baudclk, apb_pclk; | clk_t baudclk, apb_pclk; | ||||
hwreset_t reset; | hwreset_t reset; | ||||
#endif | #endif | ||||
if (!ofw_bus_status_okay(dev)) | if (!ofw_bus_status_okay(dev)) | ||||
return (ENXIO); | return (ENXIO); | ||||
uart_class = (struct uart_class *)ofw_bus_search_compatible(dev, | uart_class = (struct uart_class *)ofw_bus_search_compatible(dev, | ||||
compat_data)->ocd_data; | compat_data)->ocd_data; | ||||
if (uart_class == NULL) | if (uart_class == NULL) | ||||
return (ENXIO); | return (ENXIO); | ||||
freq = 0; | freq = 0; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
sc->ns8250.base.sc_class = uart_class; | sc->ns8250.base.sc_class = uart_class; | ||||
node = ofw_bus_get_node(dev); | node = ofw_bus_get_node(dev); | ||||
if (OF_getencprop(node, "reg-shift", &shift, sizeof(shift)) <= 0) | if (OF_getencprop(node, "reg-shift", &shift, sizeof(shift)) <= 0) | ||||
shift = 0; | shift = 0; | ||||
if (OF_getencprop(node, "reg-io-width", &iowidth, sizeof(iowidth)) <= 0) | |||||
iowidth = 1; | |||||
if (OF_getencprop(node, "clock-frequency", &clock, sizeof(clock)) <= 0) | if (OF_getencprop(node, "clock-frequency", &clock, sizeof(clock)) <= 0) | ||||
clock = 0; | clock = 0; | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
if (hwreset_get_by_ofw_idx(dev, 0, 0, &reset) == 0) { | if (hwreset_get_by_ofw_idx(dev, 0, 0, &reset) == 0) { | ||||
error = hwreset_deassert(reset); | error = hwreset_deassert(reset); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(dev, "cannot de-assert reset\n"); | device_printf(dev, "cannot de-assert reset\n"); | ||||
Show All 25 Lines | if (clock == 0) { | ||||
clock = (uint32_t)freq; | clock = (uint32_t)freq; | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
if (bootverbose && clock == 0) | if (bootverbose && clock == 0) | ||||
device_printf(dev, "could not determine frequency\n"); | device_printf(dev, "could not determine frequency\n"); | ||||
error = uart_bus_probe(dev, (int)shift, (int)clock, 0, 0); | error = uart_bus_probe(dev, (int)shift, (int)iowidth, (int)clock, 0, 0); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
/* XXX uart_bus_probe has changed the softc, so refresh it */ | /* XXX uart_bus_probe has changed the softc, so refresh it */ | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
/* Store clock and reset handles for detach */ | /* Store clock and reset handles for detach */ | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |