summaryrefslogtreecommitdiffstats
path: root/sys/arm
diff options
context:
space:
mode:
authorjhay <jhay@FreeBSD.org>2007-05-29 18:10:42 +0000
committerjhay <jhay@FreeBSD.org>2007-05-29 18:10:42 +0000
commit410f244e4f5e3ce03031bdfbe54f9e567619511a (patch)
tree931786b8299b1d10ad77fbbb3b9a905bc3b4397d /sys/arm
parent6ae57e405ef5b193c862338e74a44b1027f32d86 (diff)
downloadFreeBSD-src-410f244e4f5e3ce03031bdfbe54f9e567619511a.zip
FreeBSD-src-410f244e4f5e3ce03031bdfbe54f9e567619511a.tar.gz
Remove the hardcoded IXP425_UART?_VBASE values in the
uart_ixp425_probe() and uart_cpu_getdev(). Change uart_cpu_getdev() to use hints to find the console. Reviewed by: marcel
Diffstat (limited to 'sys/arm')
-rw-r--r--sys/arm/conf/AVILA.hints2
-rw-r--r--sys/arm/xscale/ixp425/ixp425.c2
-rw-r--r--sys/arm/xscale/ixp425/ixp425var.h2
-rw-r--r--sys/arm/xscale/ixp425/uart_bus_ixp425.c15
-rw-r--r--sys/arm/xscale/ixp425/uart_cpu_ixp425.c55
5 files changed, 58 insertions, 18 deletions
diff --git a/sys/arm/conf/AVILA.hints b/sys/arm/conf/AVILA.hints
index aafd564..86ed3fc 100644
--- a/sys/arm/conf/AVILA.hints
+++ b/sys/arm/conf/AVILA.hints
@@ -8,7 +8,7 @@
hint.uart.0.at="ixp0"
hint.uart.0.addr=0xc8000000
hint.uart.0.irq=15
-#hint.uart.0.flags=0x10
+hint.uart.0.flags=0x10
# USART0 is unit 1
hint.uart.1.at="ixp0"
hint.uart.1.addr=0xc8001000
diff --git a/sys/arm/xscale/ixp425/ixp425.c b/sys/arm/xscale/ixp425/ixp425.c
index d49babc..afac228 100644
--- a/sys/arm/xscale/ixp425/ixp425.c
+++ b/sys/arm/xscale/ixp425/ixp425.c
@@ -95,7 +95,7 @@ static struct {
IXP425_EXP_BUS_CS4_VBASE },
};
-static int
+int
getvbase(uint32_t hwbase, uint32_t size, uint32_t *vbase)
{
int i;
diff --git a/sys/arm/xscale/ixp425/ixp425var.h b/sys/arm/xscale/ixp425/ixp425var.h
index 0a8b725..7503741 100644
--- a/sys/arm/xscale/ixp425/ixp425var.h
+++ b/sys/arm/xscale/ixp425/ixp425var.h
@@ -98,6 +98,8 @@ uint32_t ixp425_sdram_size(void);
int ixp425_md_route_interrupt(device_t, device_t, int);
void ixp425_md_attach(device_t);
+int getvbase(uint32_t, uint32_t, uint32_t *);
+
struct ixp425_ivar {
uint32_t addr;
int irq;
diff --git a/sys/arm/xscale/ixp425/uart_bus_ixp425.c b/sys/arm/xscale/ixp425/uart_bus_ixp425.c
index b694e9bd..2204f44 100644
--- a/sys/arm/xscale/ixp425/uart_bus_ixp425.c
+++ b/sys/arm/xscale/ixp425/uart_bus_ixp425.c
@@ -71,6 +71,15 @@ uart_ixp425_probe(device_t dev)
sc = device_get_softc(dev);
sc->sc_class = &uart_ns8250_class;
+ sc->sc_rrid = 0;
+ sc->sc_rtype = SYS_RES_MEMORY;
+ sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
+ 0, ~0, uart_getrange(sc->sc_class), RF_ACTIVE);
+ if (sc->sc_rres == NULL) {
+ return (ENXIO);
+ }
+ sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
+ sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
/*
* XXX set UART Unit Enable (0x40) AND
* receiver timeout int enable (0x10).
@@ -79,9 +88,9 @@ uart_ixp425_probe(device_t dev)
* uart_ns8250 carefully avoids touching these bits so we can
* just set them here and proceed. But this is fragile...
*/
- bus_space_write_4(&ixp425_a4x_bs_tag,
- device_get_unit(dev) == 0 ? IXP425_UART0_VBASE : IXP425_UART1_VBASE,
- IXP425_UART_IER, IXP425_UART_IER_UUE | IXP425_UART_IER_RTOIE);
+ bus_space_write_4(sc->sc_bas.bst, sc->sc_bas.bsh, IXP425_UART_IER,
+ IXP425_UART_IER_UUE | IXP425_UART_IER_RTOIE);
+ bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
return uart_bus_probe(dev, 0, IXP425_UART_FREQ, 0, 0);
}
diff --git a/sys/arm/xscale/ixp425/uart_cpu_ixp425.c b/sys/arm/xscale/ixp425/uart_cpu_ixp425.c
index 837e271..a375d56 100644
--- a/sys/arm/xscale/ixp425/uart_cpu_ixp425.c
+++ b/sys/arm/xscale/ixp425/uart_cpu_ixp425.c
@@ -51,17 +51,46 @@ uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
int
uart_cpu_getdev(int devtype, struct uart_devinfo *di)
{
- di->ops = uart_getops(&uart_ns8250_class);
- di->bas.chan = 0;
- di->bas.bst = &ixp425_a4x_bs_tag;
- di->bas.regshft = 0;
- di->bas.rclk = IXP425_UART_FREQ;
- di->baudrate = 115200;
- di->databits = 8;
- di->stopbits = 1;
- di->parity = UART_PARITY_NONE;
- uart_bus_space_io = &ixp425_a4x_bs_tag;
- uart_bus_space_mem = NULL;
- di->bas.bsh = IXP425_UART0_VBASE;
- return (0);
+ uint32_t i, ivar, vaddr;
+
+ /*
+ * Scan the hints. The IXP425 only have 2 serial ports, so only
+ * scan them.
+ */
+ for (i = 0; i < 2; i++) {
+ if (resource_int_value("uart", i, "flags", &ivar))
+ continue;
+ if (devtype == UART_DEV_CONSOLE && !UART_FLAGS_CONSOLE(ivar))
+ continue;
+ if (devtype == UART_DEV_DBGPORT && !UART_FLAGS_DBGPORT(ivar))
+ continue;
+ /*
+ * We have a possible device. Make sure it's enabled and
+ * that we have an I/O port.
+ */
+ if (resource_int_value("uart", i, "disabled", &ivar) == 0 &&
+ ivar != 0)
+ continue;
+ if (resource_int_value("uart", i, "addr", &ivar) != 0 ||
+ ivar == 0)
+ continue;
+ /* Got it. Fill in the instance and return it. */
+ di->ops = uart_getops(&uart_ns8250_class);
+ di->bas.chan = 0;
+ di->bas.bst = &ixp425_a4x_bs_tag;
+ di->bas.regshft = 0;
+ di->bas.rclk = IXP425_UART_FREQ;
+ di->baudrate = 115200;
+ di->databits = 8;
+ di->stopbits = 1;
+ di->parity = UART_PARITY_NONE;
+ uart_bus_space_io = NULL;
+ uart_bus_space_mem = &ixp425_a4x_bs_tag;
+
+ getvbase(ivar, IXP425_REG_SIZE, &vaddr);
+ di->bas.bsh = vaddr;
+ return (0);
+ }
+
+ return (ENXIO);
}
OpenPOWER on IntegriCloud