summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2006-03-24 10:31:23 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2006-03-24 10:31:23 +0000
commit99f5f5fd692ef56a3537876641d93cecefb342aa (patch)
treecbee8c73684b6549632138f24c07b95dff16d1be /sys
parent2fc3deba3e2d08243b11715eeb6d8e850130aece (diff)
Driver for the serial interface to Qualcomm MSM EVDO modems.
Tested with Verizon Wireless by jolan@ ok dlg@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/files.usb7
-rw-r--r--sys/dev/usb/umsm.c190
2 files changed, 196 insertions, 1 deletions
diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb
index d5c5e9ef96a..d45f26d2bce 100644
--- a/sys/dev/usb/files.usb
+++ b/sys/dev/usb/files.usb
@@ -1,4 +1,4 @@
-# $OpenBSD: files.usb,v 1.50 2005/09/29 01:18:32 deraadt Exp $
+# $OpenBSD: files.usb,v 1.51 2006/03/24 10:31:22 jsg Exp $
# $NetBSD: files.usb,v 1.16 2000/02/14 20:29:54 augustss Exp $
#
# Config file and device description for machine-independent USB code.
@@ -202,6 +202,11 @@ device uipaq: ucombus
attach uipaq at uhub
file dev/usb/uipaq.c uipaq
+# Qualcomm MSM EVDO
+device umsm: ucombus
+attach umsm at uhub
+file dev/usb/umsm.c umsm
+
# Scanners
# Generic scanner support
device uscanner
diff --git a/sys/dev/usb/umsm.c b/sys/dev/usb/umsm.c
new file mode 100644
index 00000000000..c0d65e6e340
--- /dev/null
+++ b/sys/dev/usb/umsm.c
@@ -0,0 +1,190 @@
+/* $OpenBSD: umsm.c,v 1.1 2006/03/24 10:31:22 jsg Exp $ */
+
+/*
+ * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Driver for Qualcomm MSM EVDO devices */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/tty.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdevs.h>
+#include <dev/usb/ucomvar.h>
+
+#define UMSMBUFSZ 2048
+#define UMSM_CONFIG_NO 0
+#define UMSM_IFACE_NO 0
+
+struct umsm_softc {
+ USBBASEDEVICE sc_dev;
+ usbd_device_handle sc_udev;
+ usbd_interface_handle sc_iface;
+ device_ptr_t sc_subdev;
+ u_char sc_dying;
+};
+
+struct ucom_methods umsm_methods = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+};
+
+static const struct usb_devno umsm_devs[] = {
+ { USB_VENDOR_AUDIOVOX, USB_PRODUCT_AUDIOVOX_PC5740 },
+ { USB_VENDOR_AIRPRIME, USB_PRODUCT_AIRPRIME_PC5220 },
+ { USB_VENDOR_KYOCERA2, USB_PRODUCT_KYOCERA2_KPC650 },
+ { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MERLINV620 },
+ { USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD_580 },
+};
+
+USB_DECLARE_DRIVER(umsm);
+
+USB_MATCH(umsm)
+{
+ USB_MATCH_START(umsm, uaa);
+
+ if (uaa->iface != NULL)
+ return UMATCH_NONE;
+
+ return (usb_lookup(umsm_devs, uaa->vendor, uaa->product) != NULL) ?
+ UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
+}
+
+USB_ATTACH(umsm)
+{
+ USB_ATTACH_START(umsm, sc, uaa);
+ struct ucom_attach_args uca;
+ usb_interface_descriptor_t *id;
+ usb_endpoint_descriptor_t *ed;
+ usbd_status error;
+ char *devinfop;
+ int i;
+
+ bzero(&uca, sizeof(uca));
+ sc->sc_udev = uaa->device;
+ devinfop = usbd_devinfo_alloc(uaa->device, 0);
+ USB_ATTACH_SETUP;
+ printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfop);
+ usbd_devinfo_free(devinfop);
+
+ if (usbd_set_config_index(sc->sc_udev, UMSM_CONFIG_NO, 1) != 0) {
+ printf("%s: could not set configuration no\n",
+ USBDEVNAME(sc->sc_dev));
+ sc->sc_dying = 1;
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ /* get the first interface handle */
+ error = usbd_device2interface_handle(sc->sc_udev, UMSM_IFACE_NO,
+ &sc->sc_iface);
+ if (error != 0) {
+ printf("%s: could not get interface handle\n",
+ USBDEVNAME(sc->sc_dev));
+ sc->sc_dying = 1;
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ id = usbd_get_interface_descriptor(sc->sc_iface);
+
+ uca.bulkin = uca.bulkout = -1;
+ for (i = 0; i < id->bNumEndpoints; i++) {
+ ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
+ if (ed == NULL) {
+ printf("%s: no endpoint descriptor found for %d\n",
+ USBDEVNAME(sc->sc_dev), i);
+ sc->sc_dying = 1;
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
+ UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)
+ uca.bulkin = ed->bEndpointAddress;
+ else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
+ UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)
+ uca.bulkout = ed->bEndpointAddress;
+ }
+ if (uca.bulkin == -1 || uca.bulkout == -1) {
+ printf("%s: missing endpoint\n", USBDEVNAME(sc->sc_dev));
+ sc->sc_dying = 1;
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ /* We need to force size as some devices lie */
+ uca.ibufsize = UMSMBUFSZ;
+ uca.obufsize = UMSMBUFSZ;
+ uca.ibufsizepad = UMSMBUFSZ;
+ uca.opkthdrlen = 0;
+ uca.device = sc->sc_udev;
+ uca.iface = sc->sc_iface;
+ uca.methods = &umsm_methods;
+ uca.arg = sc;
+ uca.info = NULL;
+
+ usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+ USBDEV(sc->sc_dev));
+
+ sc->sc_subdev = config_found_sm(self, &uca, ucomprint, ucomsubmatch);
+
+ USB_ATTACH_SUCCESS_RETURN;
+}
+
+USB_DETACH(umsm)
+{
+ USB_DETACH_START(umsm, sc);
+ int rv = 0;
+
+ sc->sc_dying = 1;
+ if (sc->sc_subdev != NULL) {
+ rv = config_detach(sc->sc_subdev, flags);
+ sc->sc_subdev = NULL;
+ }
+
+ usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+ USBDEV(sc->sc_dev));
+
+ return (rv);
+}
+
+int
+umsm_activate(device_ptr_t self, enum devact act)
+{
+ struct umsm_softc *sc = (struct umsm_softc *)self;
+ int rv = 0;
+
+ switch (act) {
+ case DVACT_ACTIVATE:
+ return (EOPNOTSUPP);
+
+ case DVACT_DEACTIVATE:
+ if (sc->sc_subdev != NULL)
+ rv = config_deactivate(sc->sc_subdev);
+ sc->sc_dying = 1;
+ break;
+ }
+ return (rv);
+}