PERFORCE change 88574 for review
Olivier Houchard
cognet at FreeBSD.org
Thu Dec 22 09:26:01 PST 2005
http://perforce.freebsd.org/chv.cgi?CH=88574
Change 88574 by cognet at 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 <dev/uart/uart_bus.h>
#include <dev/uart/uart_cpu.h>
+#include <arm/at91/at91rm92reg.h>
+
#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)
More information about the p4-projects
mailing list