From owner-p4-projects@FreeBSD.ORG Thu Dec 22 17:26:00 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 50D0416A42C; Thu, 22 Dec 2005 17:26:00 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1056D16A42B for ; Thu, 22 Dec 2005 17:26:00 +0000 (GMT) (envelope-from cognet@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C049743D5A for ; Thu, 22 Dec 2005 17:25:59 +0000 (GMT) (envelope-from cognet@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jBMHPxKG034491 for ; Thu, 22 Dec 2005 17:25:59 GMT (envelope-from cognet@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jBMHPxnI034488 for perforce@freebsd.org; Thu, 22 Dec 2005 17:25:59 GMT (envelope-from cognet@freebsd.org) Date: Thu, 22 Dec 2005 17:25:59 GMT Message-Id: <200512221725.jBMHPxnI034488@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to cognet@freebsd.org using -f From: Olivier Houchard To: Perforce Change Reviews Cc: Subject: PERFORCE change 88574 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2005 17:26:01 -0000 http://perforce.freebsd.org/chv.cgi?CH=88574 Change 88574 by cognet@cognet on 2005/12/22 17:25:21 - Implement at91_usart_bus_receive and at91_usart_bus_ipend. - Don't use uart_barrier(), it's not needed and will panic the box because the corresponding entry for "bs_barrier" is NULL in the bus tag (XXX: we should do the same than NetBSD do, and use stubs instead of NULL). - Some hacks to support Skyeye : don't attempt to access the CSR register for any USART other than USART0, because skyeye doesn't emulate those, and will return -1 - In transmit, manually raise an IRQ once done, as Skyeye won't do it for us. Affected files ... .. //depot/projects/arm/src/sys/arm/at91/uart_bus_at91usart.c#4 edit .. //depot/projects/arm/src/sys/arm/at91/uart_cpu_at91rm9200usart.c#5 edit .. //depot/projects/arm/src/sys/arm/at91/uart_dev_at91usart.c#8 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/uart_bus_at91usart.c#4 (text+ko) ==== @@ -43,6 +43,8 @@ #include #include +#include + #include "uart_if.h" static int usart_at91rm92_probe(device_t dev); @@ -70,13 +72,26 @@ { struct uart_softc *sc; + sc = device_get_softc(dev); switch (device_get_unit(dev)) { case 0: device_set_desc(dev, "DBGU"); +#ifndef USART0_CONSOLE + /* + * Setting sc_sysdev makes this device a 'system device' and + * indirectly makes it the system console. + */ + sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); + bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); +#endif break; case 1: device_set_desc(dev, "USART0"); +#ifdef USART0_CONSOLE + sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); + bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); +#endif break; case 2: device_set_desc(dev, "USART1"); @@ -88,20 +103,8 @@ device_set_desc(dev, "USART3"); break; } - sc = device_get_softc(dev); - /* - * Setting sc_sysdev makes this device a 'system device' and - * indirectly makes it the system console. - */ -#ifdef USART0_CONSOLE - if (device_get_unit(dev) == 0) -#else - if (device_get_unit(dev) == 0) -#endif - sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); sc->sc_class = &at91_usart_class; - bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); - return (uart_bus_probe(dev, 0, 0, 0, 0, 0)); + return (uart_bus_probe(dev, 0, 0, 0, device_get_unit(dev), 0)); } ==== //depot/projects/arm/src/sys/arm/at91/uart_cpu_at91rm9200usart.c#5 (text+ko) ==== @@ -64,9 +64,11 @@ */ #ifdef USART0_CONSOLE di->bas.bsh = AT91RM92_BASE + AT91RM92_USART0_BASE; + di->bas.chan = 1; di->baudrate = 38400; #else di->bas.bsh = AT91RM92_BASE + AT91RM92_SYS_BASE + DBGU; + di->bas.chan = 0; di->baudrate = 115200; #endif di->bas.regshft = 0; ==== //depot/projects/arm/src/sys/arm/at91/uart_dev_at91usart.c#8 (text+ko) ==== @@ -183,9 +183,6 @@ uart_setreg(bas, USART_CR, USART_CR_RSTRX | USART_CR_RSTTX); uart_setreg(bas, USART_CR, USART_CR_RXEN | USART_CR_TXEN); uart_setreg(bas, USART_IER, USART_CSR_TXRDY | USART_CSR_RXRDY); -#if 0 - uart_barrier(bas); -#endif } /* @@ -273,8 +270,6 @@ static int at91_usart_bus_attach(struct uart_softc *sc) { - bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); - sc->sc_txfifosz = 1; sc->sc_rxfifosz = 1; sc->sc_hwiflow = 0; @@ -287,9 +282,17 @@ /* XXX VERY sub-optimial */ mtx_lock_spin(&sc->sc_hwmtx); + sc->sc_txbusy = 1; for (i = 0; i < sc->sc_txdatasz; i++) at91_usart_putc(&sc->sc_bas, sc->sc_txbuf[i]); mtx_unlock_spin(&sc->sc_hwmtx); +#ifdef USART0_CONSOLE + /* + * XXX: Gross hack : Skyeye doesn't raise an interrupt once the + * transfer is done, so simulate it. + */ + uart_setreg(&sc->sc_bas, USART_IER, USART_CSR_TXRDY); +#endif return (0); } static int @@ -320,7 +323,6 @@ else cr |= USART_CR_RTSDIS; uart_setreg(bas, USART_CR, cr); - uart_barrier(bas); mtx_unlock_spin(&sc->sc_hwmtx); return (0); } @@ -328,6 +330,9 @@ at91_usart_bus_receive(struct uart_softc *sc) { + mtx_lock_spin(&sc->sc_hwmtx); + uart_rx_put(sc, at91_usart_getc(&sc->sc_bas)); + mtx_unlock_spin(&sc->sc_hwmtx); return (0); } static int @@ -340,7 +345,25 @@ static int at91_usart_bus_ipend(struct uart_softc *sc) { - return (0); + int csr = uart_getreg(&sc->sc_bas, USART_CSR); + int ipend = 0; + +#ifdef USART0_CONSOLE + /* + * XXX: We have to cheat for skyeye, as it will return 0xff for all + * the devices it doesn't emulate. + */ + if (sc->sc_bas.chan != 1) + return (0); +#endif + + mtx_lock_spin(&sc->sc_hwmtx); + if (csr & USART_CSR_TXRDY && sc->sc_txbusy) + ipend |= UART_IPEND_TXIDLE; + if (csr & USART_CSR_RXRDY) + ipend |= UART_IPEND_RXREADY; + mtx_unlock_spin(&sc->sc_hwmtx); + return (ipend); } static int at91_usart_bus_flush(struct uart_softc *sc, int what)