USB device with multiple interfaces, sample code anyone?
ticso at cicely12.cicely.de
Tue May 30 01:12:22 PDT 2006
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
Or you build a driver matching a single interface which attaches in
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
B.Walter http://www.bwct.de http://www.fizon.de
bernd at bwct.de info at bwct.de support at fizon.de
More information about the freebsd-hackers