From d5ad1d0d6d8da0dae7026b28466870bad87cbfae Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Tue, 8 Sep 2015 16:06:04 +0000 Subject: [PATCH] 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 --- sys/dev/uart/uart_cpu_fdt.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sys/dev/uart/uart_cpu_fdt.c b/sys/dev/uart/uart_cpu_fdt.c index 344aad576424..c70b4ca93347 100644 --- a/sys/dev/uart/uart_cpu_fdt.c +++ b/sys/dev/uart/uart_cpu_fdt.c @@ -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);