Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/uart/uart_cpu_fdt.c
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout", | const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout", | ||||
"stdin-path", "stdin", NULL}; | "stdin-path", "stdin", NULL}; | ||||
const char **name; | const char **name; | ||||
struct uart_class *class; | struct uart_class *class; | ||||
phandle_t node, chosen; | phandle_t node, chosen; | ||||
pcell_t shift, br, rclk; | pcell_t shift, br, rclk; | ||||
u_long start, size, pbase, psize; | u_long start, size, pbase, psize; | ||||
char *cp; | |||||
int err; | int err; | ||||
uart_bus_space_mem = fdtbus_bs_tag; | uart_bus_space_mem = fdtbus_bs_tag; | ||||
uart_bus_space_io = NULL; | uart_bus_space_io = NULL; | ||||
/* Allow overriding the FDT using the environment. */ | /* Allow overriding the FDT using the environment. */ | ||||
class = &uart_ns8250_class; | class = &uart_ns8250_class; | ||||
err = uart_getenv(devtype, di, class); | err = uart_getenv(devtype, di, class); | ||||
if (!err) | if (!err) | ||||
return (0); | return (0); | ||||
if (devtype != UART_DEV_CONSOLE) | if (devtype != UART_DEV_CONSOLE) | ||||
return (ENXIO); | return (ENXIO); | ||||
/* Has the user forced a specific device node? */ | |||||
cp = kern_getenv("hw.fdt.console"); | |||||
if (cp == NULL) { | |||||
/* | /* | ||||
* Retrieve /chosen/std{in,out}. | * Retrieve /chosen/std{in,out}. | ||||
*/ | */ | ||||
node = -1; | node = -1; | ||||
if ((chosen = OF_finddevice("/chosen")) != -1) { | if ((chosen = OF_finddevice("/chosen")) != -1) { | ||||
for (name = propnames; *name != NULL; name++) { | for (name = propnames; *name != NULL; name++) { | ||||
if (phandle_chosen_propdev(chosen, *name, &node) == 0) | if (phandle_chosen_propdev(chosen, *name, | ||||
&node) == 0) | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (chosen == -1 || *name == NULL) | if (chosen == -1 || *name == NULL) | ||||
node = OF_finddevice("serial0"); /* Last ditch */ | node = OF_finddevice("serial0"); /* Last ditch */ | ||||
} else { | |||||
node = OF_finddevice(cp); | |||||
} | |||||
if (node == -1) /* Can't find anything */ | if (node == -1) /* Can't find anything */ | ||||
return (ENXIO); | return (ENXIO); | ||||
/* | /* | ||||
* Check old style of UART definition first. Unfortunately, the common | * Check old style of UART definition first. Unfortunately, the common | ||||
* FDT processing is not possible if we have clock, power domains and | * FDT processing is not possible if we have clock, power domains and | ||||
* pinmux stuff. | * pinmux stuff. | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |