From owner-freebsd-usb@FreeBSD.ORG Sat Nov 13 11:40:25 2010 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1908106566B for ; Sat, 13 Nov 2010 11:40:25 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe06.swip.net [212.247.154.161]) by mx1.freebsd.org (Postfix) with ESMTP id 1210A8FC0A for ; Sat, 13 Nov 2010 11:40:24 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=5UXFHLfkiY5XrCDma5uYm2T9fyMGz6t0cyN4hLfZsqg= c=1 sm=1 a=eA1fqfAm1u4A:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=p_9mp_vllJTyLYVfUkoA:9 a=TVirbEPexRxRF3af0UdhByYt03kA:4 a=wPNLvfGTeEIA:10 a=tkKjvSjNmeTvWFhs82UA:9 a=Os7-G5k0E847Cya5Fk4A:7 a=8_VNcWoJRSvImxLZ5hlOes1gaeQA:4 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe06.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 47979896; Sat, 13 Nov 2010 12:40:23 +0100 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Sat, 13 Nov 2010 12:41:24 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.1-STABLE; KDE/4.4.5; amd64; ; ) References: <20101112145849.161e39a8@davenulle.org> <201011121525.13324.hselasky@c2i.net> In-Reply-To: <201011121525.13324.hselasky@c2i.net> X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'(; _IjlA: hGE..Ew, XAQ*o#\/M~SC=S1-f9{EzRfT'|Hhll5Q]ha5Bt-s|oTlKMusi:1e[wJl}kd}GR Z0adGx-x_0zGbZj'e(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_kln3MirHbDD469G" Message-Id: <201011131241.24671.hselasky@c2i.net> Cc: Subject: Re: uplcom(4) does not work on cuaU0 ? X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Nov 2010 11:40:25 -0000 --Boundary-00=_kln3MirHbDD469G Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Please try the attached patch. Others having UPLCOM devices should try this patch aswell and see if their device is still working. --HPS --Boundary-00=_kln3MirHbDD469G Content-Type: text/plain; charset="iso-8859-1"; name="uplcom_detect_patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="uplcom_detect_patch.txt" === uplcom.c ================================================================== --- uplcom.c (revision 215173) +++ uplcom.c (local) @@ -176,7 +176,7 @@ static usb_error_t uplcom_reset(struct uplcom_softc *, struct usb_device *); static usb_error_t uplcom_pl2303_do(struct usb_device *, int8_t, uint8_t, uint16_t, uint16_t, uint16_t); -static int uplcom_pl2303_init(struct usb_device *, uint8_t); +static int uplcom_pl2303_init(struct uplcom_softc *sc, struct usb_device *); static void uplcom_cfg_set_dtr(struct ucom_softc *, uint8_t); static void uplcom_cfg_set_rts(struct ucom_softc *, uint8_t); static void uplcom_cfg_set_break(struct ucom_softc *, uint8_t); @@ -355,7 +355,6 @@ struct uplcom_softc *sc = device_get_softc(dev); struct usb_interface *iface; struct usb_interface_descriptor *id; - struct usb_device_descriptor *dd; int error; DPRINTFN(11, "\n"); @@ -367,19 +366,6 @@ sc->sc_udev = uaa->device; - /* Determine the chip type. This algorithm is taken from Linux. */ - dd = usbd_get_device_descriptor(sc->sc_udev); - if (dd->bDeviceClass == 0x02) - sc->sc_chiptype = TYPE_PL2303; - else if (dd->bMaxPacketSize == 0x40) - sc->sc_chiptype = TYPE_PL2303HX; - else - sc->sc_chiptype = TYPE_PL2303; - - DPRINTF("chiptype: %s\n", - (sc->sc_chiptype == TYPE_PL2303HX) ? - "2303X" : "2303"); - /* * USB-RSAQ1 has two interface * @@ -432,19 +418,20 @@ usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]); mtx_unlock(&sc->sc_mtx); - error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uplcom_callback, &sc->sc_mtx); - if (error) { - goto detach; - } /* - * do the initialization during attach so that the system does not - * sleep during open: + * do the initialization during attach so that the system does + * not sleep during open: */ - if (uplcom_pl2303_init(uaa->device, sc->sc_chiptype)) { + if (uplcom_pl2303_init(sc, uaa->device)) { device_printf(dev, "init failed\n"); goto detach; } + + error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, + &uplcom_callback, &sc->sc_mtx); + if (error) { + goto detach; + } ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev); return (0); @@ -506,7 +493,7 @@ } static int -uplcom_pl2303_init(struct usb_device *udev, uint8_t chiptype) +uplcom_pl2303_init(struct uplcom_softc *sc, struct usb_device *udev) { int err; @@ -522,12 +509,22 @@ || uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 1, 0, 0)) return (EIO); - if (chiptype == TYPE_PL2303HX) - err = uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 2, 0x44, 0); - else + /* Determine chiptype by trial and error. */ + + err = uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 2, 0x44, 0); + if (err == 0) + sc->sc_chiptype = TYPE_PL2303HX; + else { err = uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 2, 0x24, 0); + if (err == 0) + sc->sc_chiptype = TYPE_PL2303; + } + if (err) return (EIO); + + DPRINTF("chiptype: %s\n", (sc->sc_chiptype == TYPE_PL2303HX) ? + "2303X" : "2303"); if (uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 8, 0, 0) || uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 9, 0, 0)) --Boundary-00=_kln3MirHbDD469G--