svn commit: r287565 - head/sys/dev/uart

Andrew Turner andrew at FreeBSD.org
Tue Sep 8 16:06:05 UTC 2015


Author: andrew
Date: Tue Sep  8 16:06:04 2015
New Revision: 287565
URL: https://svnweb.freebsd.org/changeset/base/287565

Log:
  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 at 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

Modified:
  head/sys/dev/uart/uart_cpu_fdt.c

Modified: head/sys/dev/uart/uart_cpu_fdt.c
==============================================================================
--- head/sys/dev/uart/uart_cpu_fdt.c	Tue Sep  8 16:05:18 2015	(r287564)
+++ head/sys/dev/uart/uart_cpu_fdt.c	Tue Sep  8 16:06:04 2015	(r287565)
@@ -134,6 +134,7 @@ uart_cpu_getdev(int devtype, struct uart
 	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
 	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);


More information about the svn-src-all mailing list