Changeset View
Changeset View
Standalone View
Standalone View
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}. | ||||
imp: There are other things than /chose/stdin /chosen/stdout. Perhaps you should limit things… | |||||
andrewAuthorUnsubmitted Not Done Inline ActionsThis is just changing the indentation of existing code, there is extra data in some of these, but that is out of the scope for this change. andrew: This is just changing the indentation of existing code, there is extra data in some of these… | |||||
*/ | */ | ||||
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 */ | ||||
impUnsubmitted Not Done Inline ActionsI'm torn. Is there some reason we don't do this when the user has specified a node that doesn't exist (eg node == -1 when cp != NULL) imp: I'm torn. Is there some reason we don't do this when the user has specified a node that doesn't… | |||||
andrewAuthorUnsubmitted Not Done Inline ActionsThe user could disable the fdt console with this by setting it to an invalid node, e.g. hw.fdt.console="none" andrew: The user could disable the fdt console with this by setting it to an invalid node, e.g. hw.fdt. | |||||
} 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 |
There are other things than /chose/stdin /chosen/stdout. Perhaps you should limit things explicitly to those?