From owner-freebsd-stable@FreeBSD.ORG Sun Jul 3 01:03:06 2005 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1CD9F16B392; Sun, 3 Jul 2005 01:02:44 +0000 (GMT) (envelope-from ps@mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 650C144CD4; Sun, 3 Jul 2005 00:54:24 +0000 (GMT) (envelope-from ps@mu.org) Received: by elvis.mu.org (Postfix, from userid 1000) id 079AF61888; Sat, 2 Jul 2005 17:17:52 -0700 (PDT) X-Original-To: ps@mu.org Delivered-To: ps@mu.org Received: from mx2.freebsd.org (mx2.freebsd.org [216.136.204.119]) by elvis.mu.org (Postfix) with ESMTP id 7175E5C9C6 for ; Sat, 22 Jan 2005 06:52:53 -0800 (PST) Received: from hub.freebsd.org (hub.freebsd.org [216.136.204.18]) by mx2.freebsd.org (Postfix) with ESMTP id C10E8562FB; Sat, 22 Jan 2005 14:52:48 +0000 (GMT) (envelope-from owner-freebsd-current@freebsd.org) Received: from hub.freebsd.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 5278D16A4DD; Sat, 22 Jan 2005 14:52:46 +0000 (GMT) Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9C9B516A4CE; Sat, 22 Jan 2005 14:52:41 +0000 (GMT) Received: from castle.jp.FreeBSD.org (castle.jp.FreeBSD.org [210.226.20.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08E9043D45; Sat, 22 Jan 2005 14:52:41 +0000 (GMT) (envelope-from akiyama@jp.FreeBSD.org) Received: from localhost (castle.jp.FreeBSD.org [2001:218:422:1::15]) ESMTP/inet6 id j0MEqa866008; Sat, 22 Jan 2005 23:52:37 +0900 (JST) (envelope-from akiyama@jp.FreeBSD.org) From: Shunsuke Akiyama To: Michal Mertl In-Reply-To: <1106227110.716.11.camel@genius2.i.cz> References: <1106134006.1132.12.camel@genius2.i.cz> <1106227110.716.11.camel@genius2.i.cz> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 Emacs/21.3 (i386--freebsd) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Sat_Jan_22_23:52:33_2005-1" Message-Id: <20050122235234K.akiyama@jp.FreeBSD.org> X-Dispatcher: imput version 20040704(IM147) Lines: 216 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Sender: owner-freebsd-current@freebsd.org Errors-To: owner-freebsd-current@freebsd.org X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on elvis.mu.org X-Spam-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.0.1 X-Spam-Level: Cc: Emanuel Strobl , freebsd-current@freebsd.org, freebsd-stable@freebsd.org, bernd@bwct.de Subject: Re: strange ucom (uplcom) error X-BeenThere: freebsd-stable@freebsd.org List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 03 Jul 2005 01:03:07 -0000 X-Original-Date: Sat, 22 Jan 2005 23:52:33 +0900 X-List-Received-Date: Sun, 03 Jul 2005 01:03:07 -0000 --Multipart_Sat_Jan_22_23:52:33_2005-1 Content-Type: text/plain; charset=US-ASCII At Thu, 20 Jan 2005 14:18:30 +0100, Michal Mertl wrote: > > I wrote: > > Emanuel Strobl wrote: > > > Am Dienstag, 18. Januar 2005 16:17 schrieb Andrew L. Neporada: > > > > On Tue, Jan 18, 2005 at 01:06:43PM +0100, Emanuel Strobl wrote: > > > > > Dear experts, > > > > > > > > > > I have two USB-RS232 Adaptors, both with PL2303 chipset. One is working > > > > > the other one not (I hate to say it but both are working under win). > > > > > > > > > > The not working (more expensive) one gets recognized as ucom0 and I have > > > > > ucom0, also I can receive signal but not transmit. > > > > > > > > [skip] > > > > > > > > Take a look at http://gate.intercaf.ru/~lesha/6100/ and try patch > > > > http://gate.intercaf.ru/~lesha/6100/pl2303x.patch > > > > > > > > It can break old (working) PL2303 chip, but it works for me with newer > > > > > > Thanks a lot, this indeed fixes the revision 3.0 adaptor but unfortunately > > > also breakes the 2.02 version :( > > > > > > Perhaps there's a goog guy out there who can refurbish the uplcom driver with > > > this information (akiyama?)? > > > > > > Thanks a lot, > > > > I've just recently been looking into this too. I used the mentioned > > patch and also linux driver source and have come with the attached > > patch. It contains one more change but I don't know if it's correct. It > > works for both chips on CURRENT for serial console. It detects if the > > chip is rev 3.00 and aplies the patch only for it. > > > > The author of the patch mentions it isn't binary safe - sometimes the > > chip stops working. I planned to test it with binary transfers (ppp) > > today, check if it's working and submit it (with some cleanup) for > > inclusion in FreeBSD. > > > > Michal Mertl > > I tested my patch for binary safety on CURRENT yesterday (dialed with > ppp) and didn't notice any problem. > > I'm attaching my patch again because some recipients didn't probably > receive it yesterday. > > Michal Good work! I've updated your patch. If attached patch works correctly with new revision chip, I'll commit this. Please test attached patch, and tell me the result. Regards, -- Shunsuke Akiyama akiyama@jp.FreeBSD.org akiyama@FreeBSD.org --Multipart_Sat_Jan_22_23:52:33_2005-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="uplcom.c-diff" Content-Transfer-Encoding: 7bit Index: uplcom.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/uplcom.c,v retrieving revision 1.25 diff -u -r1.25 uplcom.c --- uplcom.c 6 Jan 2005 01:43:29 -0000 1.25 +++ uplcom.c 22 Jan 2005 14:39:45 -0000 @@ -97,10 +97,13 @@ #include #include +#include + #include #include #include +#include #include #include "usbdevs.h" #include @@ -138,6 +141,9 @@ #define RSAQ_STATUS_DSR 0x02 #define RSAQ_STATUS_DCD 0x01 +#define CHIPTYPE_PL2303 0 +#define CHIPTYPE_PL2303X 1 + struct uplcom_softc { struct ucom_softc sc_ucom; @@ -156,6 +162,8 @@ u_char sc_lsr; /* Local status register */ u_char sc_msr; /* uplcom status register */ + + int sc_chiptype; /* Type of chip */ }; /* @@ -293,6 +301,7 @@ USB_ATTACH_START(uplcom, sc, uaa); usbd_device_handle dev = uaa->device; struct ucom_softc *ucom; + usb_device_descriptor_t *udd; usb_config_descriptor_t *cdesc; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; @@ -320,6 +329,16 @@ DPRINTF(("uplcom attach: sc = %p\n", sc)); + /* determine chip type */ + udd = &dev->ddesc; + if (UGETW(udd->bcdDevice) >= 0x300) { + DPRINTF(("uplcom_attach: chiptype 2303X\n")); + sc->sc_chiptype = CHIPTYPE_PL2303X; + } else { + DPRINTF(("uplcom_attach: chiptype 2303\n")); + sc->sc_chiptype = CHIPTYPE_PL2303; + } + /* initialize endpoints */ ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1; sc->sc_intr_number = -1; @@ -521,6 +540,54 @@ return (0); } +struct pl2303x_init { + uint8_t req_type; + uint8_t request; + uint16_t value; + uint16_t index; + uint16_t length; +}; + +Static const struct pl2303x_init pl2303x[] = { + { UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8484, 0, 0 }, + { UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x0404, 0, 0 }, + { UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8484, 0, 0 }, + { UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8383, 0, 0 }, + { UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8484, 0, 0 }, + { UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x0404, 1, 0 }, + { UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8484, 0, 0 }, + { UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8383, 0, 0 }, + { UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0, 1, 0 }, + { UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 1, 0, 0 }, + { UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 2, 0x44, 0 } +}; + +Static usbd_status +uplcom_pl2303x_init(struct uplcom_softc *sc) +{ + usb_device_request_t req; + usbd_status err; + int i; + + for (i = 0; i < 11; i++) { + req.bmRequestType = pl2303x[i].req_type; + req.bRequest = pl2303x[i].request; + USETW(req.wValue, pl2303x[i].value); + USETW(req.wIndex, pl2303x[i].index); + USETW(req.wLength, pl2303x[i].length); + + err = usbd_do_request(sc->sc_ucom.sc_udev, &req, 0); + if (err) { + printf("%s: uplcom_pl2303x_init: %d: %s\n", + USBDEVNAME(sc->sc_ucom.sc_dev), i, + usbd_errstr(err)); + return (EIO); + } + } + + return (0); +} + Static void uplcom_set_line_state(struct uplcom_softc *sc) { @@ -617,7 +684,10 @@ req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = UPLCOM_SET_REQUEST; USETW(req.wValue, 0); - USETW(req.wIndex, UPLCOM_SET_CRTSCTS); + if (sc->sc_chiptype == CHIPTYPE_PL2303X) + USETW(req.wIndex, 0x61); + else + USETW(req.wIndex, UPLCOM_SET_CRTSCTS); USETW(req.wLength, 0); err = usbd_do_request(sc->sc_ucom.sc_udev, &req, 0); @@ -744,6 +814,9 @@ } } + if (sc->sc_chiptype == CHIPTYPE_PL2303X) + return (uplcom_pl2303x_init(sc)); + return (0); } --Multipart_Sat_Jan_22_23:52:33_2005-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" --Multipart_Sat_Jan_22_23:52:33_2005-1--