1 /* $DragonFly: src/sys/dev/usbmisc/umsm/Attic/umsm.c,v 1.6 2008/01/11 12:25:30 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 2048
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, 0x6820) }, /* Sierra Wireless Aircard 875 */
77 { USB_DEVICE(0x12d1, 0x1001) }, /* Huawei Mobile Connect */
78 { USB_DEVICE(0x1410, 0x1100) }, /* Novatel Wireless ExpressCard 3G */
79 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin V620 */
80 { USB_DEVICE(0x1410, 0x1130) }, /* Novatel Wireless S720 */
81 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Wireless XU870 */
82 { USB_DEVICE(0x1410, 0x2100) }, /* Novatel Wireless ES620 */
83 { USB_DEVICE(0x1410, 0x2110) }, /* Novatel Wireless U720 */
84 { USB_DEVICE(0x413c, 0x8115) }, /* Dell W5500 */
87 static device_probe_t umsm_match
;
88 static device_attach_t umsm_attach
;
89 static device_detach_t umsm_detach
;
91 static device_method_t umsm_methods
[] = {
92 /* Device interface */
93 DEVMETHOD(device_probe
, umsm_match
),
94 DEVMETHOD(device_attach
, umsm_attach
),
95 DEVMETHOD(device_detach
, umsm_detach
),
99 static driver_t umsm_driver
= {
102 sizeof (struct umsm_softc
)
105 DRIVER_MODULE(umsm
, uhub
, umsm_driver
, ucom_devclass
, usbd_driver_load
, 0);
106 MODULE_DEPEND(umsm
, usb
, 1, 1, 1);
107 MODULE_DEPEND(umsm
, ucom
, UCOM_MINVER
, UCOM_PREFVER
, UCOM_MAXVER
);
108 MODULE_VERSION(umsm
, 1);
111 umsm_match(device_t self
)
113 struct usb_attach_arg
*uaa
= device_get_ivars(self
);
115 if (uaa
->iface
== NULL
)
118 return (usb_lookup(umsm_devs
, uaa
->vendor
, uaa
->product
) != NULL
) ?
119 UMATCH_VENDOR_IFACESUBCLASS
: UMATCH_NONE
;
123 umsm_attach(device_t self
)
125 struct umsm_softc
*sc
= device_get_softc(self
);
126 struct usb_attach_arg
*uaa
= device_get_ivars(self
);
127 struct ucom_softc
*ucom
;
128 usb_interface_descriptor_t
*id
;
129 usb_endpoint_descriptor_t
*ed
;
133 bzero(sc
, sizeof (struct umsm_softc
));
136 ucom
->sc_udev
= uaa
->device
;
137 ucom
->sc_iface
= uaa
->iface
;
139 id
= usbd_get_interface_descriptor(ucom
->sc_iface
);
141 ucom
->sc_bulkin_no
= ucom
->sc_bulkout_no
= -1;
142 for (i
= 0; i
< id
->bNumEndpoints
; i
++) {
143 ed
= usbd_interface2endpoint_descriptor(ucom
->sc_iface
, i
);
145 device_printf(ucom
->sc_dev
, "no endpoint descriptor "
146 "found for %d\n", i
);
150 if (UE_GET_DIR(ed
->bEndpointAddress
) == UE_DIR_IN
&&
151 UE_GET_XFERTYPE(ed
->bmAttributes
) == UE_BULK
)
152 ucom
->sc_bulkin_no
= ed
->bEndpointAddress
;
153 else if (UE_GET_DIR(ed
->bEndpointAddress
) == UE_DIR_OUT
&&
154 UE_GET_XFERTYPE(ed
->bmAttributes
) == UE_BULK
)
155 ucom
->sc_bulkout_no
= ed
->bEndpointAddress
;
157 if (ucom
->sc_bulkin_no
== -1 || ucom
->sc_bulkout_no
== -1) {
158 device_printf(ucom
->sc_dev
, "missing endpoint\n");
162 ucom
->sc_parent
= sc
;
163 ucom
->sc_portno
= UCOM_UNK_PORTNO
;
164 ucom
->sc_ibufsize
= UMSMBUFSZ
;
165 ucom
->sc_obufsize
= UMSMBUFSZ
;
166 ucom
->sc_ibufsizepad
= UMSMBUFSZ
;
167 ucom
->sc_opkthdrlen
= 0;
168 ucom
->sc_callback
= &umsm_callback
;
170 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH
, ucom
->sc_udev
,
173 DPRINTF(("%s: in = 0x%x, out = 0x%x\n",
174 device_get_nameunit(ucom
->sc_dev
), ucom
->sc_bulkin_no
,
175 ucom
->sc_bulkout_no
));
177 ucom_attach(&sc
->sc_ucom
);
187 umsm_detach(device_t self
)
189 struct umsm_softc
*sc
= device_get_softc(self
);
192 DPRINTF(("umsm_detach: sc=%p\n", sc
));
193 sc
->sc_ucom
.sc_dying
= 1;
194 rv
= ucom_detach(&sc
->sc_ucom
);
195 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH
, sc
->sc_ucom
.sc_udev
,
203 umsm_activate(struct device
*self
, enum devact act
)
205 struct umsm_softc
*sc
= (struct umsm_softc
*)self
;
212 case DVACT_DEACTIVATE
:
213 if (sc
->sc_subdev
!= NULL
)
214 rv
= config_deactivate(sc
->sc_subdev
);