On Wed, Aug 17, 2016 at 04:05:05PM +0200, Mark Kettenis wrote:

> > Date: Wed, 17 Aug 2016 15:36:21 +0200
> > From: Marcus Glocker <mar...@nazgul.ch>
> > 
> > Enables FIFO for Synopsis DesignWare APB UART.
> > 
> > ok?
> 
> Apparently the FIFO is optional.  There is a register that tells you
> whether it is enabled or not.  Not sure we'll ever encounter an
> implementation that has that option turned off.  But we probably
> should check to be sure.

Ok.  This updated diff tries to find out about FIFO support by reading
the CPR registers FIFO_MODE field.  If it contains zero, no FIFO
support, otherwise it conains the supported FIFO depth.

Unfortunately on my allwinner,sun5i-r8 it returns zero which suprises
me a bit.  Therefore it would be interessting if it could be tested on
other sunxi boards as well to see whether it returns non-zero there and
hence you should find a com-line showing the FIFO size.

Thanks.


Index: com_fdt.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/dev/com_fdt.c,v
retrieving revision 1.6
diff -u -p -r1.6 com_fdt.c
--- com_fdt.c   17 Aug 2016 13:44:48 -0000      1.6
+++ com_fdt.c   18 Aug 2016 09:36:05 -0000
@@ -38,6 +38,8 @@
 #include <dev/ofw/ofw_pinctrl.h>
 
 #define com_usr 31     /* Synopsys DesignWare UART */
+#define com_cpr 61     /* Component Parameter Register */
+#define CPR_MASK_FIFO(val) ((val >> 16) & 0x00ff)      /* CPR FIFO_MODE */
 
 int    com_fdt_match(struct device *, void *, void *);
 void   com_fdt_attach(struct device *, struct device *, void *);
@@ -98,6 +100,7 @@ com_fdt_attach(struct device *parent, st
        struct fdt_attach_args *faa = aux;
        int (*intr)(void *) = comintr;
        int node;
+       uint32_t reg;
 
        if (faa->fa_nreg < 1)
                return;
@@ -115,11 +118,6 @@ com_fdt_attach(struct device *parent, st
        sc->sc.sc_frequency = 48000000;
        sc->sc.sc_uarttype = COM_UART_TI16750;
 
-       if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")) {
-               sc->sc.sc_uarttype = COM_UART_16550;
-               intr = com_fdt_intr_designware;
-       }
-
        if ((node = OF_finddevice("/")) != 0 &&
            (OF_is_compatible(node, "allwinner,sun4i-a10") ||
            OF_is_compatible(node, "allwinner,sun5i-a10s") ||
@@ -136,6 +134,15 @@ com_fdt_attach(struct device *parent, st
            faa->fa_reg[0].size, 0, &sc->sc.sc_ioh)) {
                printf("%s: bus_space_map failed\n", __func__);
                return;
+       }
+
+       if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")) {
+               reg = bus_space_read_4(sc->sc.sc_iot, sc->sc.sc_ioh, com_cpr);
+               if (CPR_MASK_FIFO(reg) > 0)
+                       sc->sc.sc_uarttype = COM_UART_16550A;
+               else
+                       sc->sc.sc_uarttype = COM_UART_16550;
+               intr = com_fdt_intr_designware;
        }
 
        pinctrl_byname(faa->fa_node, "default");

Reply via email to