Subject: how to recognize a USB serial device? [was: Re: how to recognize a
To: None <tech-kern@NetBSD.org, martin@NetBSD.org>
From: Hubert Feyrer <hubert@feyrer.de>
List: tech-kern
Date: 03/07/2006 19:32:32
On Sat, 4 Mar 2006, Hubert Feyrer wrote:
> I have a E-Plus UMTS card here, that is not really recognized by NetBSD here, 
> see dmesg below. My line of thinking is that the device shouled be attached 
> as umodem instead of ugen, how do I do that?

Digging a bit deeper, the device seems to present a "normal" USB serial 
device under Linux, which can then be linked to /dev/modem, from 
/dev/ttyUSB0. dmesg under Linux looks like this:

;---snip----
Mar  5 18:25:15 localhost kernel: [4294750.981000] usbcore: registered new driver usbserial
Mar  5 18:25:15 localhost kernel: [4294750.982000] drivers/usb/serial/usb-serial.c: USB Serial support re gistered for Generic
Mar  5 18:25:15 localhost kernel: [4294750.983000] usbserial_generic 6-1:1.0: Generic converter detected
Mar  5 18:25:15 localhost kernel: [4294750.987000] usb 6-1: Generic converter now attached to ttyUSB0
Mar  5 18:25:15 localhost kernel: [4294750.987000] usbserial_generic 6-1:1.1: Generic converter detected
Mar  5 18:25:15 localhost kernel: [4294751.008000] usb 6-1: Generic converter now attached to ttyUSB1
Mar  5 18:25:15 localhost kernel: [4294751.008000] usbserial_generic 6-1:1.2: Generic converter detected
Mar  5 18:25:15 localhost kernel: [4294751.014000] usb 6-1: Generic converter now attached to ttyUSB2
Mar  5 18:25:15 localhost kernel: [4294751.014000] usbserial_generic 6-1:1.3: Generic converter detected
Mar  5 18:25:15 localhost kernel: [4294751.019000] usb 6-1: Generic converter now attached to ttyUSB3
Mar  5 18:25:15 localhost kernel: [4294751.020000] usbcore: registered new driver usbserial_generic
Mar  5 18:25:15 localhost kernel: [4294751.020000] drivers/usb/serial/usb-serial.c: USB Serial Driver cor e v2.0
;-----------

Looking at ucom.c's USB_MATCH() routine, the 'return 1' in there may be 
UMATCH_GENERIC, but I wonder how the ucom(4) driver actually gets 
attached?

And where is the mapping between the product and vendor ID that says that 
a device is either a modem or a serial device or whatever, which code 
determines that and calls into the appropriate driver (umodem, ucom, ...)?

And how can I talk our ucom(4) driver into trying to get that 
vendor/product pair to be recognized?

Does something like the patch below make sense? (I don't have the hardware 
to test, but some sanity check would be nice).

Thanks!


  - Hubert


Index: ucom.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/ucom.c,v
retrieving revision 1.61
diff -u -r1.61 ucom.c
--- ucom.c	20 Feb 2006 16:50:37 -0000	1.61
+++ ucom.c	7 Mar 2006 18:31:24 -0000
@@ -169,7 +169,14 @@

  USB_MATCH(ucom)
  {
-	return (1);
+	USB_MATCH_START(ucom, uaa);
+ 
+	if (uaa->vendor == USB_VENDOR_VODAFONE &&
+	    uaa->product == USB_PRODUCT_VODAFONE_QGPRS) {
+		return (UMATCH_VENDOR_PRODUCT); /* XXX ??? HF */
+	}
+ 
+	return (UMATCH_GENERIC);
  }

  USB_ATTACH(ucom)