diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2010-12-17 21:02:59 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2010-12-17 21:02:59 +0000 |
commit | d7cf17489beb3b4a1d7c64cce7bff5b0d21cb540 (patch) | |
tree | f16c9305e24058554d16c9960a8a70900ab821ea /sys/dev/usb | |
parent | 036c54925f70badb4c69652cb3ca6e14a802d91e (diff) |
- attach to abbott stereo plug and fix it's firmware loading
from aschrijver@
ok deraadt@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/uticom.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/sys/dev/usb/uticom.c b/sys/dev/usb/uticom.c index 5b7f6da60a6..2bf7f5f6bed 100644 --- a/sys/dev/usb/uticom.c +++ b/sys/dev/usb/uticom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uticom.c,v 1.11 2010/12/17 14:53:43 jasper Exp $ */ +/* $OpenBSD: uticom.c,v 1.12 2010/12/17 21:02:58 jasper Exp $ */ /* * Copyright (c) 2005 Dmitry Komissaroff <dxi@mail.ru>. * @@ -119,7 +119,7 @@ struct uticom_buf { }; struct uticom_softc { - struct device sc_dev; /* base device */ + struct device sc_dev; /* base device */ usbd_device_handle sc_udev; /* device */ usbd_interface_handle sc_iface; /* interface */ @@ -158,6 +158,8 @@ static int uticom_param(void *, int, struct termios *); static int uticom_open(void *, int); static void uticom_close(void *, int); +void uticom_attach_hook(void *arg); + static int uticom_download_fw(struct uticom_softc *sc, int pipeno, usbd_device_handle dev); @@ -192,7 +194,8 @@ const struct cfattach uticom_ca = { static const struct usb_devno uticom_devs[] = { { USB_VENDOR_TI, USB_PRODUCT_TI_TUSB3410 }, { USB_VENDOR_STARTECH, USB_PRODUCT_STARTECH_ICUSB232X }, - { USB_VENDOR_MOXA, USB_PRODUCT_MOXA_UPORT1110 } + { USB_VENDOR_MOXA, USB_PRODUCT_MOXA_UPORT1110 }, + { USB_VENDOR_ABBOTT, USB_PRODUCT_ABBOTT_STEREO_PLUG } }; int @@ -210,26 +213,37 @@ uticom_match(struct device *parent, void *match, void *aux) void uticom_attach(struct device *parent, struct device *self, void *aux) { - struct uticom_softc *sc = (struct uticom_softc *)self; - struct usb_attach_arg *uaa = aux; - usbd_device_handle dev = uaa->device; - usb_config_descriptor_t *cdesc; - usb_interface_descriptor_t *id; - usb_endpoint_descriptor_t *ed; - usbd_status err; - int status, i; - usb_device_descriptor_t *dd; - struct ucom_attach_args uca; + struct uticom_softc *sc = (struct uticom_softc *)self; + struct usb_attach_arg *uaa = aux; + usbd_device_handle dev = uaa->device; sc->sc_udev = dev; sc->sc_iface = uaa->iface; + if (rootvp == NULL) + mountroothook_establish(uticom_attach_hook, sc); + else + uticom_attach_hook(sc); +} + +void +uticom_attach_hook(void *arg) +{ + struct uticom_softc *sc = arg; + usb_config_descriptor_t *cdesc; + usb_interface_descriptor_t *id; + usb_endpoint_descriptor_t *ed; + usbd_status err; + int status, i; + usb_device_descriptor_t *dd; + struct ucom_attach_args uca; + /* Initialize endpoints. */ uca.bulkin = uca.bulkout = -1; sc->sc_intr_number = -1; sc->sc_intr_pipe = NULL; - dd = usbd_get_device_descriptor(dev); + dd = usbd_get_device_descriptor(sc->sc_udev); DPRINTF(("%s: uticom_attach: num of configurations %d\n", sc->sc_dev.dv_xname, dd->bNumConfigurations)); @@ -242,7 +256,7 @@ uticom_attach(struct device *parent, struct device *self, void *aux) DPRINTF(("%s: uticom_attach: starting loading firmware\n", sc->sc_dev.dv_xname)); - err = usbd_set_config_index(dev, UTICOM_CONFIG_INDEX, 1); + err = usbd_set_config_index(sc->sc_udev, UTICOM_CONFIG_INDEX, 1); if (err) { printf("%s: failed to set configuration: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); @@ -260,7 +274,7 @@ uticom_attach(struct device *parent, struct device *self, void *aux) return; } - err = usbd_device2interface_handle(dev, UTICOM_IFACE_INDEX, + err = usbd_device2interface_handle(sc->sc_udev, UTICOM_IFACE_INDEX, &sc->sc_iface); if (err) { printf("%s: failed to get interface: %s\n", @@ -297,7 +311,7 @@ uticom_attach(struct device *parent, struct device *self, void *aux) } } - status = uticom_download_fw(sc, uca.bulkout, dev); + status = uticom_download_fw(sc, uca.bulkout, sc->sc_udev); if (status) { printf("%s: firmware download failed\n", @@ -309,7 +323,7 @@ uticom_attach(struct device *parent, struct device *self, void *aux) sc->sc_dev.dv_xname)); } - status = usbd_reload_device_desc(dev); + status = usbd_reload_device_desc(sc->sc_udev); if (status) { printf("%s: error reloading device descriptor\n", sc->sc_dev.dv_xname); @@ -318,11 +332,11 @@ uticom_attach(struct device *parent, struct device *self, void *aux) } fwload_done: - dd = usbd_get_device_descriptor(dev); + dd = usbd_get_device_descriptor(sc->sc_udev); DPRINTF(("%s: uticom_attach: num of configurations %d\n", sc->sc_dev.dv_xname, dd->bNumConfigurations)); - err = usbd_set_config_index(dev, UTICOM_ACTIVE_INDEX, 1); + err = usbd_set_config_index(sc->sc_udev, UTICOM_ACTIVE_INDEX, 1); if (err) { printf("%s: failed to set configuration: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); @@ -340,7 +354,7 @@ fwload_done: } /* Get the interface (XXX: multiport chips are not supported yet). */ - err = usbd_device2interface_handle(dev, UTICOM_IFACE_INDEX, + err = usbd_device2interface_handle(sc->sc_udev, UTICOM_IFACE_INDEX, &sc->sc_iface); if (err) { printf("failed to get interface: %s\n", @@ -366,6 +380,7 @@ fwload_done: UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) { sc->sc_intr_number = ed->bEndpointAddress; sc->sc_isize = UGETW(ed->wMaxPacketSize); + } } @@ -421,7 +436,7 @@ fwload_done: uca.ibufsize = UTICOM_IBUFSZ; uca.obufsize = UTICOM_OBUFSZ; uca.ibufsizepad = UTICOM_IBUFSZ; - uca.device = dev; + uca.device = sc->sc_udev; uca.iface = sc->sc_iface; uca.opkthdrlen = 0; uca.methods = &uticom_methods; @@ -440,7 +455,7 @@ fwload_done: sc->sc_dev.dv_xname, uca.bulkin, uca.bulkout, sc->sc_intr_number)); - sc->sc_subdev = config_found_sm(self, &uca, ucomprint, ucomsubmatch); + sc->sc_subdev = config_found_sm((struct device *)sc, &uca, ucomprint, ucomsubmatch); } int |