Date: Mon, 28 May 2007 15:46:07 +0200 From: John Hay <jhay@meraka.org.za> To: freebsd-arm@freebsd.org Subject: removing hardcoded uart vbase Message-ID: <20070528134607.GA67826@zibbi.meraka.csir.co.za>
next in thread | raw e-mail | index | archive | help
Hi, This patch removes the hardcoded IXP425_UART?_VBASE values from uart_cpu_ixp425.c and uart_bus_ixp425.c. I have two questions: I had to make getvbase() global and Sam sounded ok with that. Should we maybe rename it to something like ixp425_getvbase() or is ok as it is? To find the console, I just check for uart 0 in the hints. Is that good enough or should one also check for flags 0x10 like on sio devices? For me uart 0 is good enough because I just configure uart 0 addr and irq to the one I want as the console. Anyway is the patch ok? John -- John Hay -- John.Hay@meraka.csir.co.za / jhay@FreeBSD.org Index: uart_cpu_ixp425.c =================================================================== RCS file: /home/ncvs/src/sys/arm/xscale/ixp425/uart_cpu_ixp425.c,v retrieving revision 1.2 diff -u -r1.2 uart_cpu_ixp425.c --- uart_cpu_ixp425.c 2 Apr 2007 22:00:22 -0000 1.2 +++ uart_cpu_ixp425.c 26 May 2007 20:19:04 -0000 @@ -51,6 +51,8 @@ int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { + uint32_t addr, vaddr; + di->ops = uart_getops(&uart_ns8250_class); di->bas.chan = 0; di->bas.bst = &ixp425_a4x_bs_tag; @@ -62,6 +64,8 @@ di->parity = UART_PARITY_NONE; uart_bus_space_io = &ixp425_a4x_bs_tag; uart_bus_space_mem = NULL; - di->bas.bsh = IXP425_UART0_VBASE; + resource_int_value("uart", 0, "addr", &addr); + getvbase(addr, IXP425_REG_SIZE, &vaddr); + di->bas.bsh = vaddr; return (0); } Index: uart_bus_ixp425.c =================================================================== RCS file: /home/ncvs/src/sys/arm/xscale/ixp425/uart_bus_ixp425.c,v retrieving revision 1.2 diff -u -r1.2 uart_bus_ixp425.c --- uart_bus_ixp425.c 24 May 2007 16:17:51 -0000 1.2 +++ uart_bus_ixp425.c 26 May 2007 12:35:48 -0000 @@ -71,6 +71,15 @@ 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_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); } Index: ixp425var.h =================================================================== RCS file: /home/ncvs/src/sys/arm/xscale/ixp425/ixp425var.h,v retrieving revision 1.3 diff -u -r1.3 ixp425var.h --- ixp425var.h 24 May 2007 16:25:49 -0000 1.3 +++ ixp425var.h 26 May 2007 19:00:00 -0000 @@ -98,6 +100,8 @@ 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; Index: ixp425.c =================================================================== RCS file: /home/ncvs/src/sys/arm/xscale/ixp425/ixp425.c,v retrieving revision 1.6 diff -u -r1.6 ixp425.c --- ixp425.c 24 May 2007 16:25:49 -0000 1.6 +++ ixp425.c 26 May 2007 09:11:07 -0000 @@ -95,7 +95,7 @@ IXP425_EXP_BUS_CS4_VBASE }, }; -static int +int getvbase(uint32_t hwbase, uint32_t size, uint32_t *vbase) { int i;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070528134607.GA67826>