svn commit: r238304 - user/jceel/soc2012_armv6/sys/dev/fdt

Jakub Wojciech Klama jceel at FreeBSD.org
Mon Jul 9 17:34:04 UTC 2012


Author: jceel
Date: Mon Jul  9 17:34:03 2012
New Revision: 238304
URL: http://svn.freebsd.org/changeset/base/238304

Log:
  Add shorthand function for finding FDT node of UART selected
  for console (in "chosen" section).

Modified:
  user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.c
  user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.h

Modified: user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.c
==============================================================================
--- user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.c	Mon Jul  9 17:28:26 2012	(r238303)
+++ user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.c	Mon Jul  9 17:34:03 2012	(r238304)
@@ -129,6 +129,30 @@ moveon:
 	return (0);
 }
 
+phandle_t
+fdt_lookup_console_uart(void)
+{
+	char buf[64];
+	phandle_t node, chosen;
+
+	/*
+	 * Retrieve /chosen/std{in,out}.
+	 */
+	if ((chosen = OF_finddevice("/chosen")) == -1)
+		return (-1);
+	if (OF_getprop(chosen, "stdin", buf, sizeof(buf)) <= 0)
+		return (-1);
+	if ((node = OF_finddevice(buf)) == -1)
+		return (-1);
+	if (OF_getprop(chosen, "stdout", buf, sizeof(buf)) <= 0)
+		return (-1);
+	if (OF_finddevice(buf) != node)
+		/* Only stdin == stdout is supported. */
+		return (-1);
+
+	return (node);
+}
+
 int
 fdt_read_ranges(phandle_t node, struct fdt_range **ranges, int addr_cells,
     int par_addr_cells, int size_cells)

Modified: user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.h
==============================================================================
--- user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.h	Mon Jul  9 17:28:26 2012	(r238303)
+++ user/jceel/soc2012_armv6/sys/dev/fdt/fdt_common.h	Mon Jul  9 17:34:03 2012	(r238304)
@@ -97,6 +97,7 @@ phandle_t fdt_find_compatible(phandle_t,
 int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
 int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
 int fdt_immr_addr(vm_offset_t);
+phandle_t fdt_lookup_console_uart(void);
 int fdt_read_ranges(phandle_t node, struct fdt_range **ranges, int addr_cells,
     int par_addr_cells, int size_cels);
 u_long fdt_ranges_lookup(struct fdt_range *ranges, int nranges, u_long addr,


More information about the svn-src-user mailing list