1 /* $DragonFly: src/sys/dev/usbmisc/umsm/Attic/umsm.c,v 1.8 2008/01/15 14:19:11 hasso Exp $ */
2 /* $OpenBSD: umsm.c,v 1.15 2007/06/14 10:11:16 mbalmer Exp $ */
5 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 /* Driver for Qualcomm MSM EVDO and UMTS communication devices */
22 #include <sys/param.h>
23 #include <sys/systm.h>
24 #include <sys/kernel.h>
25 #include <sys/device.h>
28 #include <sys/types.h>
30 #include <sys/module.h>
32 #include <bus/usb/usb.h>
33 #include <bus/usb/usbdi.h>
34 #include <bus/usb/usbdi_util.h>
35 #include <dev/usbmisc/ucom/ucomvar.h>
38 static int umsmdebug
= 1;
39 #define DPRINTFN(n, x) do { if (umsmdebug > (n)) kprintf x; } while (0)
41 #define DPRINTFN(n, x)
43 #define DPRINTF(x) DPRINTFN(0, x)
45 #define UMSMBUFSZ 4096
48 struct ucom_softc sc_ucom
;
51 struct ucom_callback umsm_callback
= {
62 static const struct usb_devno umsm_devs
[] = {
63 { USB_DEVICE(0x05c6, 0x6613) }, /* Qualcomm HSDPA MSM */
64 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera KPC650 */
65 { USB_DEVICE(0x0f3d, 0x0112) }, /* AirPrime PC5220 */
66 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
67 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
68 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
69 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
70 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */
71 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
72 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
73 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
74 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
75 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
76 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8755 */
77 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless Aircard 875 */
78 { USB_DEVICE(0x12d1, 0x1001) }, /* Huawei Mobile Connect */
79 { USB_DEVICE(0x1410, 0x1100) }, /* Novatel Wireless ExpressCard 3G */
80 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin V620 */
81 { USB_DEVICE(0x1410, 0x1130) }, /* Novatel Wireless S720 */
82 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Wireless XU870 */
83 { USB_DEVICE(0x1410, 0x2100) }, /* Novatel Wireless ES620 */
84 { USB_DEVICE(0x1410, 0x2110) }, /* Novatel Wireless U720 */
85 { USB_DEVICE(0x413c, 0x8115) }, /* Dell W5500 */
88 static device_probe_t umsm_match
;
89 static device_attach_t umsm_attach
;
90 static device_detach_t umsm_detach
;
92 static device_method_t umsm_methods
[] = {
93 /* Device interface */
94 DEVMETHOD(device_probe
, umsm_match
),
95 DEVMETHOD(device_attach
, umsm_attach
),
96 DEVMETHOD(device_detach
, umsm_detach
),
100 static driver_t umsm_driver
= {
103 sizeof (struct umsm_softc
)
106 DRIVER_MODULE(umsm
, uhub
, umsm_driver
, ucom_devclass
, usbd_driver_load
, 0);
107 MODULE_DEPEND(umsm
, usb
, 1, 1, 1);
108 MODULE_DEPEND(umsm
, ucom
, UCOM_MINVER
, UCOM_PREFVER
, UCOM_MAXVER
);
109 MODULE_VERSION(umsm
, 1);
112 umsm_match(device_t self
)
114 struct usb_attach_arg
*uaa
= device_get_ivars(self
);
116 if (uaa
->iface
== NULL
)
119 return (usb_lookup(umsm_devs
, uaa
->vendor
, uaa
->product
) != NULL
) ?
120 UMATCH_VENDOR_IFACESUBCLASS
: UMATCH_NONE
;
124 umsm_attach(device_t self
)
126 struct umsm_softc
*sc
= device_get_softc(self
);
127 struct usb_attach_arg
*uaa
= device_get_ivars(self
);
128 struct ucom_softc
*ucom
;
129 usb_interface_descriptor_t
*id
;
130 usb_endpoint_descriptor_t
*ed
;
134 bzero(sc
, sizeof (struct umsm_softc
));
137 ucom
->sc_udev
= uaa
->device
;
138 ucom
->sc_iface
= uaa
->iface
;
140 id
= usbd_get_interface_descriptor(ucom
->sc_iface
);
142 ucom
->sc_bulkin_no
= ucom
->sc_bulkout_no
= -1;
143 for (i
= 0; i
< id
->bNumEndpoints
; i
++) {
144 ed
= usbd_interface2endpoint_descriptor(ucom
->sc_iface
, i
);
146 device_printf(ucom
->sc_dev
, "no endpoint descriptor "
147 "found for %d\n", i
);
151 if (UE_GET_DIR(ed
->bEndpointAddress
) == UE_DIR_IN
&&
152 UE_GET_XFERTYPE(ed
->bmAttributes
) == UE_BULK
)
153 ucom
->sc_bulkin_no
= ed
->bEndpointAddress
;
154 else if (UE_GET_DIR(ed
->bEndpointAddress
) == UE_DIR_OUT
&&
155 UE_GET_XFERTYPE(ed
->bmAttributes
) == UE_BULK
)
156 ucom
->sc_bulkout_no
= ed
->bEndpointAddress
;
158 if (ucom
->sc_bulkin_no
== -1 || ucom
->sc_bulkout_no
== -1) {
159 device_printf(ucom
->sc_dev
, "missing endpoint\n");
163 ucom
->sc_parent
= sc
;
164 ucom
->sc_portno
= UCOM_UNK_PORTNO
;
165 ucom
->sc_ibufsize
= UMSMBUFSZ
;
166 ucom
->sc_obufsize
= UMSMBUFSZ
;
167 ucom
->sc_ibufsizepad
= UMSMBUFSZ
;
168 ucom
->sc_opkthdrlen
= 0;
169 ucom
->sc_callback
= &umsm_callback
;
171 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH
, ucom
->sc_udev
,
174 DPRINTF(("%s: in = 0x%x, out = 0x%x\n",
175 device_get_nameunit(ucom
->sc_dev
), ucom
->sc_bulkin_no
,
176 ucom
->sc_bulkout_no
));
178 ucom_attach(&sc
->sc_ucom
);
188 umsm_detach(device_t self
)
190 struct umsm_softc
*sc
= device_get_softc(self
);
193 DPRINTF(("umsm_detach: sc=%p\n", sc
));
194 sc
->sc_ucom
.sc_dying
= 1;
195 rv
= ucom_detach(&sc
->sc_ucom
);
196 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH
, sc
->sc_ucom
.sc_udev
,
204 umsm_activate(struct device
*self
, enum devact act
)
206 struct umsm_softc
*sc
= (struct umsm_softc
*)self
;
213 case DVACT_DEACTIVATE
:
214 if (sc
->sc_subdev
!= NULL
)
215 rv
= config_deactivate(sc
->sc_subdev
);