Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Jul 2003 22:29:07 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 34228 for review
Message-ID:  <200307090529.h695T7np071332@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=34228

Change 34228 by marcel@marcel_nfs on 2003/07/08 22:28:10

	Add address decoding so that we can actually access the UART.
	While here, use the device name instead of probing() to
	determine the UART type. It's much safer.
	Also, don't compare the bus tag when we compare the bas.
	Low-level consoles have a fake tag, so they will not match.
	Comparing only the handle is not sufficient in general, but
	will do for now.

Affected files ...

.. //depot/projects/uart/dev/uart/uart_cpu_sparc64.c#2 edit

Differences ...

==== //depot/projects/uart/dev/uart/uart_cpu_sparc64.c#2 (text+ko) ====

@@ -32,23 +32,24 @@
 
 #include <machine/bus.h>
 #include <machine/bus_private.h>
-#include <machine/ofw_upa.h>
 
 #include <dev/ofw/openfirm.h>
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
 
+int OF_decode_addr(phandle_t node, int *space, bus_addr_t *addr);
+
 static struct bus_space_tag bst_store[2];
 
 int
 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
 {
 	char buffer[8];
-	struct upa_regs regs;
 	phandle_t chosen, consin, consout;
 	ihandle_t stdin, stdout;
-	int space;
+	bus_addr_t addr;
+	int error, space;
 
 	/*
 	 * Get the address of the UART that is selected as the console, if
@@ -72,18 +73,14 @@
 		return (ENXIO);
 	if (strcmp(buffer, "serial"))
 		return (ENXIO);
-	if (OF_getprop(consout, "reg", &regs, sizeof(regs)) == -1)
-		return (ENXIO);
 
-	/*
-	 * Figure out which of the spaces is most appropriate.
-	 */
-	space = UPA_BUS_SPACE;		/* XXX yeah, right... */
+	error = OF_decode_addr(consout, &space, &addr);
+	if (error)
+		return (error);
 
 	/* Fill in the device info. */
 	di->bas.bst = &bst_store[devtype];
-	di->bas.bsh = sparc64_fake_bustag(space, UPA_REG_PHYS(&regs),
-	    di->bas.bst);
+	di->bas.bsh = sparc64_fake_bustag(space, addr, di->bas.bst);
 	di->bas.regshft = 0;
 	di->bas.rclk = 0;
 	di->baudrate = 9600;
@@ -91,22 +88,22 @@
 	di->stopbits = 1;
 	di->parity = UART_PARITY_NONE;
 
-	/*
-	 * Figure out what kind of UART we have.
-	 */
-	di->ops = uart_ns8250_ops;
-	if (uart_probe(di) == 0)
+	if (OF_getprop(consout, "name", buffer, sizeof(buffer)) == -1)
+		return (ENXIO);
+	if (!strcmp(buffer, "se")) {
+		di->ops = uart_sab82532_ops;
 		return (0);
-	di->ops = uart_sab82532_ops;
-	if (uart_probe(di) == 0)
+	}
+	if (!strcmp(buffer, "su")) {
+		di->ops = uart_ns8250_ops;
 		return (0);
-
+	}
 	return (ENXIO);
 }
 
 int
 uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
 {
- 
-        return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0);
+
+	return ((b1->bsh == b2->bsh) ? 1 : 0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307090529.h695T7np071332>