svn commit: r205362 - projects/altix/sys/dev/uart

Marcel Moolenaar marcel at FreeBSD.org
Sat Mar 20 05:11:56 UTC 2010


Author: marcel
Date: Sat Mar 20 05:11:56 2010
New Revision: 205362
URL: http://svn.freebsd.org/changeset/base/205362

Log:
  Allow specifications that lack an I/O port or memory mapped I/O
  address when the UART class doesn't need it. A class doesn't need
  it when the I/O range is 0.
  
  This makes the L1 console work with the following specification:
  	set hw.uart.console="dt:sgisn"

Modified:
  projects/altix/sys/dev/uart/uart_dev_sgisn.c
  projects/altix/sys/dev/uart/uart_subr.c

Modified: projects/altix/sys/dev/uart/uart_dev_sgisn.c
==============================================================================
--- projects/altix/sys/dev/uart/uart_dev_sgisn.c	Sat Mar 20 05:10:44 2010	(r205361)
+++ projects/altix/sys/dev/uart/uart_dev_sgisn.c	Sat Mar 20 05:11:56 2010	(r205362)
@@ -148,7 +148,7 @@ struct uart_class uart_sgisn_class = {
 	sgisn_methods,
 	sizeof(struct sgisn_softc),
 	.uc_ops = &uart_sgisn_ops,
-	.uc_range = 2,
+	.uc_range = 0,
 	.uc_rclk = 0
 };
 

Modified: projects/altix/sys/dev/uart/uart_subr.c
==============================================================================
--- projects/altix/sys/dev/uart/uart_subr.c	Sat Mar 20 05:10:44 2010	(r205361)
+++ projects/altix/sys/dev/uart/uart_subr.c	Sat Mar 20 05:11:56 2010	(r205362)
@@ -195,7 +195,7 @@ uart_getenv(int devtype, struct uart_dev
 {
 	__const char *spec;
 	bus_addr_t addr = ~0U;
-	int error;
+	int error, range;
 
 	/*
 	 * All uart_class references are weak. Make sure the default
@@ -273,13 +273,25 @@ uart_getenv(int devtype, struct uart_dev
 		spec++;
 	}
 
+	di->ops = uart_getops(class);
+	range = uart_getrange(class);
+
 	/*
 	 * If we still have an invalid address, the specification must be
-	 * missing an I/O port or memory address. We don't like that.
+	 * missing an I/O port or memory address. We don't like that if
+	 * the class expects an I/O port or memory range.
 	 */
-	if (addr == ~0U)
+	if (addr == ~0U && range != 0)
 		return (EINVAL);
 
+	/* Create a bus space handle if applicable. */
+	if (addr != ~0U && range != 0) {
+		error = bus_space_map(di->bas.bst, addr, range, 0,
+		    &di->bas.bsh);
+		if (error)
+			return (error);
+	}
+
 	/*
 	 * Accept only the well-known baudrates. Any invalid baudrate
 	 * is silently replaced with a 0-valued baudrate. The 0 baudrate
@@ -299,9 +311,5 @@ uart_getenv(int devtype, struct uart_dev
 	} else
 		di->baudrate = 0;
 
-	/* Set the ops and create a bus space handle. */
-	di->ops = uart_getops(class);
-	error = bus_space_map(di->bas.bst, addr, uart_getrange(class), 0,
-	    &di->bas.bsh);
-	return (error);
+	return (0);
 }


More information about the svn-src-projects mailing list