Allow us to set the console device tree node. This is needed as not all

vendor supplied device trees contain the needed properties for us to select
the correct uart to use as the kernel console.

An example of this would be to add the following to loader.conf.
hw.fdt.console="/smb/uart@f7113000"

The intention of this is slightly different than the existing
hw.uart.console option. The new option will mean the boot serial
configuration will be derived from the device node, while the existing
option expects the user to configure all this themselves.

Further work is planned to allow the uart configuration to be set based on
the stdout-path property devicetree bindings.

Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D3559
This commit is contained in:
Andrew Turner 2015-09-08 16:06:04 +00:00
parent 854c31980e
commit d5ad1d0d6d

View File

@ -134,6 +134,7 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
phandle_t node, chosen;
pcell_t shift, br, rclk;
u_long start, size, pbase, psize;
char *cp;
int err;
uart_bus_space_mem = fdtbus_bs_tag;
@ -148,18 +149,25 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
if (devtype != UART_DEV_CONSOLE)
return (ENXIO);
/*
* Retrieve /chosen/std{in,out}.
*/
node = -1;
if ((chosen = OF_finddevice("/chosen")) != -1) {
for (name = propnames; *name != NULL; name++) {
if (phandle_chosen_propdev(chosen, *name, &node) == 0)
break;
/* Has the user forced a specific device node? */
cp = kern_getenv("hw.fdt.console");
if (cp == NULL) {
/*
* Retrieve /chosen/std{in,out}.
*/
node = -1;
if ((chosen = OF_finddevice("/chosen")) != -1) {
for (name = propnames; *name != NULL; name++) {
if (phandle_chosen_propdev(chosen, *name,
&node) == 0)
break;
}
}
if (chosen == -1 || *name == NULL)
node = OF_finddevice("serial0"); /* Last ditch */
} else {
node = OF_finddevice(cp);
}
if (chosen == -1 || *name == NULL)
node = OF_finddevice("serial0"); /* Last ditch */
if (node == -1) /* Can't find anything */
return (ENXIO);