From owner-freebsd-hackers@FreeBSD.ORG Tue May 30 08:12:21 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BEF3616A421 for ; Tue, 30 May 2006 08:12:21 +0000 (UTC) (envelope-from ticso@cicely12.cicely.de) Received: from raven.bwct.de (raven.bwct.de [85.159.14.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id E46E343D5A for ; Tue, 30 May 2006 08:12:20 +0000 (GMT) (envelope-from ticso@cicely12.cicely.de) Received: from cicely5.cicely.de ([10.1.1.7]) by raven.bwct.de (8.13.4/8.13.4) with ESMTP id k4U8CItR038297; Tue, 30 May 2006 10:12:18 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (cicely12.cicely.de [10.1.1.14]) by cicely5.cicely.de (8.13.4/8.13.4) with ESMTP id k4U8CEBs045209 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 May 2006 10:12:15 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (localhost [127.0.0.1]) by cicely12.cicely.de (8.13.4/8.13.3) with ESMTP id k4U8CEl7011265; Tue, 30 May 2006 10:12:14 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: (from ticso@localhost) by cicely12.cicely.de (8.13.4/8.13.3/Submit) id k4U8CEHP011264; Tue, 30 May 2006 10:12:14 +0200 (CEST) (envelope-from ticso) Date: Tue, 30 May 2006 10:12:14 +0200 From: Bernd Walter To: Volker Message-ID: <20060530081213.GZ2409@cicely12.cicely.de> References: <447B0CD3.1080309@vwsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <447B0CD3.1080309@vwsoft.com> X-Operating-System: FreeBSD cicely12.cicely.de 5.4-STABLE alpha User-Agent: Mutt/1.5.9i X-Spam-Status: No, score=-5.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.0.4 X-Spam-Report: * -3.3 ALL_TRUSTED Did not pass through any untrusted hosts * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on cicely12.cicely.de Cc: hackers@freebsd.org Subject: Re: USB device with multiple interfaces, sample code anyone? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ticso@cicely.de List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 May 2006 08:12:22 -0000 On Mon, May 29, 2006 at 05:01:39PM +0200, Volker wrote: > Hi hackers, > > I'm trying to correctly implement a driver for an USB device which > has multiple (serial) interfaces (at least 3). Each interface should > be seen by the kernel as a tty device entry /dev(/cuaU* or /dev/ttyU*). You either build a device driver managing the whole device and create multiple ttys in a single device instance. uftdi(4) is an example for this, which supports single and twin channel USB-devices. Or you build a driver matching a single interface which attaches in multiple instances. ubser is a single interface driver, it creates multiple ttys on a single interface however. Although real hardware don't exist with multiple interfaces the driver would allow it. http://www.bwct.de/modbus/ubmb-0.3.tgz is a very simple interface level driver which was already used for multiple interfaces. It attaches once for each device and create a single device for each instance. But it is not a tty driver. > After reading the usb kernel sources I'm not quite sure how to deal > with that. As the device entry is being created in ucom.c > (ucom_attach calls ttycreate) I'm not quite sure which code is > responsible for scanning (enumerating) and correctly attaching to > the usb device interfaces or if there's just a wrong enumeration > return code. This is done in usbd_probe_and_attach(). Forst the whole device is offered and if no driver claims it each single interface is offered. > I haven't found any usb code which deals with more than 1 interface > per usb device (except sound/pcm/uaudio but while doing a quick read > of that code I do not understand much of uaudio). Normaly a driver only handles a single instance and attaches multiple times. -- B.Walter http://www.bwct.de http://www.fizon.de bernd@bwct.de info@bwct.de support@fizon.de