Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jul 2012 20:46:22 +0000 (UTC)
From:      Gavin Atkinson <gavin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238778 - head/sys/dev/usb/serial
Message-ID:  <201207252046.q6PKkMGD098019@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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");
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207252046.q6PKkMGD098019>