Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Remove UCHCOM_REG_BPS_MOD and UCHCOM_REG_BPS_PAD...



details:   https://anonhg.NetBSD.org/src/rev/9c04e84c575e
branches:  trunk
changeset: 995180:9c04e84c575e
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Tue Dec 11 01:07:29 2018 +0000

description:
Remove UCHCOM_REG_BPS_MOD and UCHCOM_REG_BPS_PAD usage.

There is no clear indication doing these calculations and setting the
resulting register bits results in improved functionality.  Contrary
to hints in the code, short-term precision of the UART clock doesn't
appear to improve when these bits are adjusted.

Neither the vendor's Linux driver nor the mainline Linux driver
currently touch these bits.

Tested with CH341A and a logic analyzer.

diffstat:

 sys/dev/usb/uchcom.c |  41 +++++++++++------------------------------
 1 files changed, 11 insertions(+), 30 deletions(-)

diffs (125 lines):

diff -r 5be958b149ea -r 9c04e84c575e sys/dev/usb/uchcom.c
--- a/sys/dev/usb/uchcom.c      Mon Dec 10 21:19:33 2018 +0000
+++ b/sys/dev/usb/uchcom.c      Tue Dec 11 01:07:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uchcom.c,v 1.22 2018/12/10 14:32:04 jakllsch Exp $     */
+/*     $NetBSD: uchcom.c,v 1.23 2018/12/11 01:07:29 jakllsch Exp $     */
 
 /*
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uchcom.c,v 1.22 2018/12/10 14:32:04 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uchcom.c,v 1.23 2018/12/11 01:07:29 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -86,8 +86,6 @@
 #define UCHCOM_REG_STAT2       0x07
 #define UCHCOM_REG_BPS_PRE     0x12
 #define UCHCOM_REG_BPS_DIV     0x13
-#define UCHCOM_REG_BPS_MOD     0x14
-#define UCHCOM_REG_BPS_PAD     0x0F
 #define UCHCOM_REG_BREAK1      0x05
 #define UCHCOM_REG_BREAK2      0x18
 #define UCHCOM_REG_LCR1                0x18
@@ -100,9 +98,6 @@
 
 #define UCHCOM_BPS_PRE_IMM     0x80    /* CH341: immediate RX forwarding */
 
-#define UCHCOM_BPS_MOD_BASE    20000000
-#define UCHCOM_BPS_MOD_BASE_OFS        1100
-
 #define UCHCOM_DTR_MASK                0x20
 #define UCHCOM_RTS_MASK                0x40
 
@@ -158,7 +153,6 @@
 {
        uint8_t         dv_prescaler;
        uint8_t         dv_div;
-       uint8_t         dv_mod;
 };
 
 struct uchcom_divider_record
@@ -171,12 +165,12 @@
 
 static const struct uchcom_divider_record dividers[] =
 {
-       {  307200, 307200, UCHCOM_BASE_UNKNOWN, { 7, 0xD9, 0 } },
-       {  921600, 921600, UCHCOM_BASE_UNKNOWN, { 7, 0xF3, 0 } },
-       { 2999999,  23530,             6000000, { 3,    0, 0 } },
-       {   23529,   2942,              750000, { 2,    0, 0 } },
-       {    2941,    368,               93750, { 1,    0, 0 } },
-       {     367,      1,               11719, { 0,    0, 0 } },
+       {  307200, 307200, UCHCOM_BASE_UNKNOWN, { 7, 0xD9 } },
+       {  921600, 921600, UCHCOM_BASE_UNKNOWN, { 7, 0xF3 } },
+       { 2999999,  23530,             6000000, { 3,    0 } },
+       {   23529,   2942,              750000, { 2,    0 } },
+       {    2941,    368,               93750, { 1,    0 } },
+       {     367,      1,               11719, { 0,    0 } },
 };
 #define NUM_DIVIDERS   (sizeof (dividers) / sizeof (dividers[0]))
 
@@ -655,7 +649,7 @@
 {
        int i;
        const struct uchcom_divider_record *rp;
-       uint32_t div, rem, mod;
+       uint32_t div, rem;
 
        /* find record */
        for (i=0; i<NUM_DIVIDERS; i++) {
@@ -681,11 +675,6 @@
                dp->dv_div = (uint8_t)-div;
        }
 
-       mod = UCHCOM_BPS_MOD_BASE/rate + UCHCOM_BPS_MOD_BASE_OFS;
-       mod = mod + mod/2;
-
-       dp->dv_mod = mod / 0x100;
-
        return 0;
 }
 
@@ -701,10 +690,7 @@
        if ((err = write_reg(sc,
                             UCHCOM_REG_BPS_PRE,
                             dv.dv_prescaler | UCHCOM_BPS_PRE_IMM,
-                            UCHCOM_REG_BPS_DIV, dv.dv_div)) ||
-           (err = write_reg(sc,
-                            UCHCOM_REG_BPS_MOD, dv.dv_mod,
-                            UCHCOM_REG_BPS_PAD, 0))) {
+                            UCHCOM_REG_BPS_DIV, dv.dv_div))) {
                device_printf(sc->sc_dev, "cannot set DTE rate: %s\n",
                    usbd_errstr(err));
                return EIO;
@@ -787,7 +773,7 @@
 reset_chip(struct uchcom_softc *sc)
 {
        usbd_status err;
-       uint8_t lcr1val, lcr2val, pre, div, mod;
+       uint8_t lcr1val, lcr2val, pre, div;
        uint16_t val=0, idx=0;
 
        err = read_reg(sc, UCHCOM_REG_LCR1, &lcr1val, UCHCOM_REG_LCR2, &lcr2val);
@@ -798,10 +784,6 @@
        if (err)
                goto failed;
 
-       err = read_reg(sc, UCHCOM_REG_BPS_MOD, &mod, UCHCOM_REG_BPS_PAD, NULL);
-       if (err)
-               goto failed;
-
        val |= (uint16_t)(lcr1val&0xF0) << 8;
        val |= 0x01;
        val |= (uint16_t)(lcr2val&0x0F) << 8;
@@ -810,7 +792,6 @@
        val |= 0x04;
        idx |= (uint16_t)div << 8;
        val |= 0x08;
-       idx |= mod & 0xF8;
        val |= 0x10;
 
        DPRINTF(("%s: reset v=0x%04X, i=0x%04X\n",



Home | Main Index | Thread Index | Old Index