From owner-svn-src-all@FreeBSD.ORG Wed Jul 25 20:46:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CFB81106566C; Wed, 25 Jul 2012 20:46:22 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0FF48FC08; Wed, 25 Jul 2012 20:46:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6PKkMxM098021; Wed, 25 Jul 2012 20:46:22 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6PKkMGD098019; Wed, 25 Jul 2012 20:46:22 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201207252046.q6PKkMGD098019@svn.freebsd.org> From: Gavin Atkinson Date: Wed, 25 Jul 2012 20:46:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238778 - head/sys/dev/usb/serial X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2012 20:46:22 -0000 Author: gavin Date: Wed Jul 25 20:46:22 2012 New Revision: 238778 URL: http://svn.freebsd.org/changeset/base/238778 Log: The baud rate on CP1201/2/3 devices can be set in one of two ways: - The USLCOM_SET_BAUD_DIV command (0x01) - The USLCOM_SET_BAUD_RATE command (0x13) Devices based on the CP1204 will only accept the latter command, and ignore the former. As the latter command works on all chips that this driver supports, switch to always using it. A slight confusion here is that the previously used command was incorrectly named USLCOM_BAUD_RATE - even though we no longer use it, rename it to USLCOM_SET_BAUD_DIV to closer match the name used in the datasheet. This change reflects a similar change made in the Linux driver, which was submitted by preston.fick at silabs.com, and has been tested on all of the uslcom(4) devices I have to hand. MFC after: 2 weeks Modified: head/sys/dev/usb/serial/uslcom.c Modified: head/sys/dev/usb/serial/uslcom.c ============================================================================== --- head/sys/dev/usb/serial/uslcom.c Wed Jul 25 19:18:28 2012 (r238777) +++ head/sys/dev/usb/serial/uslcom.c Wed Jul 25 20:46:22 2012 (r238778) @@ -70,12 +70,13 @@ SYSCTL_INT(_hw_usb_uslcom, OID_AUTO, deb /* Request codes */ #define USLCOM_UART 0x00 -#define USLCOM_BAUD_RATE 0x01 +#define USLCOM_SET_BAUD_DIV 0x01 #define USLCOM_DATA 0x03 #define USLCOM_BREAK 0x05 #define USLCOM_CTRL 0x07 #define USLCOM_RCTRL 0x08 #define USLCOM_SET_FLOWCTRL 0x13 +#define USLCOM_SET_BAUD_RATE 0x1e #define USLCOM_VENDOR_SPECIFIC 0xff /* USLCOM_UART values */ @@ -92,8 +93,8 @@ SYSCTL_INT(_hw_usb_uslcom, OID_AUTO, deb #define USLCOM_CTRL_RI 0x0040 #define USLCOM_CTRL_DCD 0x0080 -/* USLCOM_BAUD_RATE values */ -#define USLCOM_BAUD_REF 0x384000 +/* USLCOM_SET_BAUD_DIV values */ +#define USLCOM_BAUD_REF 3686400 /* 3.6864 MHz */ /* USLCOM_DATA values */ #define USLCOM_STOP_BITS_1 0x00 @@ -511,19 +512,20 @@ uslcom_param(struct ucom_softc *ucom, st { struct uslcom_softc *sc = ucom->sc_parent; struct usb_device_request req; - uint32_t flowctrl[4]; + uint32_t baudrate, flowctrl[4]; uint16_t data; DPRINTF("\n"); + baudrate = t->c_ospeed; req.bmRequestType = USLCOM_WRITE; - req.bRequest = USLCOM_BAUD_RATE; - USETW(req.wValue, USLCOM_BAUD_REF / t->c_ospeed); + req.bRequest = USLCOM_SET_BAUD_RATE; + USETW(req.wValue, 0); USETW(req.wIndex, USLCOM_PORT_NO); - USETW(req.wLength, 0); + USETW(req.wLength, sizeof(baudrate)); - if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, - &req, NULL, 0, 1000)) { + if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, + &req, &baudrate, 0, 1000)) { DPRINTF("Set baudrate failed (ignored)\n"); }