Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic com(4): fix FIFO for DW_APB on Allwinner A20 (got...



details:   https://anonhg.NetBSD.org/src/rev/9b1a5b3295df
branches:  trunk
changeset: 984902:9b1a5b3295df
user:      tnn <tnn%NetBSD.org@localhost>
date:      Fri Jul 30 12:46:46 2021 +0000

description:
com(4): fix FIFO for DW_APB on Allwinner A20 (got broken by com.c 1.360)

Older DesignWare UARTs do not advertise their FIFO length so we must
provide it via device properties.

diffstat:

 sys/arch/arm/sunxi/sunxi_platform.c |  13 +++++++++++--
 sys/dev/ic/com.c                    |   7 ++++---
 2 files changed, 15 insertions(+), 5 deletions(-)

diffs (62 lines):

diff -r 62b99a7c754c -r 9b1a5b3295df sys/arch/arm/sunxi/sunxi_platform.c
--- a/sys/arch/arm/sunxi/sunxi_platform.c       Thu Jul 29 14:58:35 2021 +0000
+++ b/sys/arch/arm/sunxi/sunxi_platform.c       Fri Jul 30 12:46:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.43 2021/04/24 23:36:28 thorpej Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #include "opt_console.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.43 2021/04/24 23:36:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -238,6 +238,15 @@
                        if (val)
                                prop_dictionary_set_bool(prop, "nomodeset", true);
        }
+
+       if (device_is_a(self, "com")) {
+               static const struct device_compatible_entry compat_data[] = {
+                       { .compat = "allwinner,sun7i-a20" },
+                       DEVICE_COMPAT_EOL
+               };
+               if (of_compatible_match(OF_finddevice("/"), compat_data))
+                       prop_dictionary_set_uint(prop, "fifolen", 64);
+       }
 }
 
 static u_int
diff -r 62b99a7c754c -r 9b1a5b3295df sys/dev/ic/com.c
--- a/sys/dev/ic/com.c  Thu Jul 29 14:58:35 2021 +0000
+++ b/sys/dev/ic/com.c  Fri Jul 30 12:46:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.363 2021/03/25 05:34:49 rin Exp $ */
+/* $NetBSD: com.c,v 1.364 2021/07/30 12:46:46 tnn Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.363 2021/03/25 05:34:49 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.364 2021/07/30 12:46:46 tnn Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -541,7 +541,8 @@
        case COM_TYPE_DW_APB:
                cpr = bus_space_read_4(sc->sc_regs.cr_iot, sc->sc_regs.cr_ioh,
                    DW_APB_UART_CPR);
-               sc->sc_fifolen = __SHIFTOUT(cpr, UART_CPR_FIFO_MODE) * 16;
+               if (!prop_dictionary_get_uint(dict, "fifolen", &sc->sc_fifolen))
+                       sc->sc_fifolen = __SHIFTOUT(cpr, UART_CPR_FIFO_MODE) * 16;
                if (sc->sc_fifolen == 0) {
                        sc->sc_fifolen = 1;
                        fifo_msg = "DesignWare APB UART, no fifo";



Home | Main Index | Thread Index | Old Index