From owner-freebsd-arm@FreeBSD.ORG Mon May 28 14:19:33 2007 Return-Path: X-Original-To: freebsd-arm@freebsd.org Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F04F216A476 for ; Mon, 28 May 2007 14:19:33 +0000 (UTC) (envelope-from jhay@meraka.csir.co.za) Received: from zibbi.meraka.csir.co.za (zibbi.meraka.csir.co.za [146.64.24.58]) by mx1.freebsd.org (Postfix) with ESMTP id D482C13C469 for ; Mon, 28 May 2007 14:19:32 +0000 (UTC) (envelope-from jhay@meraka.csir.co.za) Received: by zibbi.meraka.csir.co.za (Postfix, from userid 3973) id D461233CCF; Mon, 28 May 2007 15:46:07 +0200 (SAST) Date: Mon, 28 May 2007 15:46:07 +0200 From: John Hay To: freebsd-arm@freebsd.org Message-ID: <20070528134607.GA67826@zibbi.meraka.csir.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: removing hardcoded uart vbase X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 May 2007 14:19:34 -0000 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;