2004-07-01 21:14:03 +00:00
|
|
|
/* $NetBSD: uhub.c,v 1.68 2004/06/29 06:30:05 mycroft Exp $ */
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
1998-11-26 23:13:13 +00:00
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1999-01-07 23:07:57 +00:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2000-05-14 16:43:10 +00:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
1999-01-07 23:07:57 +00:00
|
|
|
* Carlstedt Research & Technology.
|
1998-11-26 23:13:13 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1999-04-11 14:24:43 +00:00
|
|
|
/*
|
2003-07-14 18:14:15 +00:00
|
|
|
* USB spec: http://www.usb.org/developers/docs/usbspec.zip
|
1999-04-11 14:24:43 +00:00
|
|
|
*/
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
2005-05-11 15:21:22 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
2002-07-31 14:20:07 +00:00
|
|
|
#include <sys/sysctl.h>
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
#include <machine/bus.h>
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
#include <dev/usb/usb.h>
|
1998-11-26 23:13:13 +00:00
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include <dev/usb/usbdi_util.h>
|
|
|
|
#include <dev/usb/usbdivar.h>
|
|
|
|
|
2000-05-14 19:39:10 +00:00
|
|
|
#define UHUB_INTR_INTERVAL 255 /* ms */
|
|
|
|
|
2002-07-31 14:34:36 +00:00
|
|
|
#ifdef USB_DEBUG
|
2007-02-03 16:19:28 +00:00
|
|
|
#define DPRINTF(x) if (uhubdebug) printf x
|
|
|
|
#define DPRINTFN(n,x) if (uhubdebug > (n)) printf x
|
|
|
|
#define DEVPRINTF(x) if (uhubdebug) device_printf x
|
|
|
|
#define DEVPRINTFN(n, x)if (uhubdebug > (n)) device_printf x
|
2002-07-31 13:58:15 +00:00
|
|
|
int uhubdebug = 0;
|
2002-08-08 12:05:51 +00:00
|
|
|
SYSCTL_NODE(_hw_usb, OID_AUTO, uhub, CTLFLAG_RW, 0, "USB uhub");
|
|
|
|
SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RW,
|
2002-07-31 13:58:15 +00:00
|
|
|
&uhubdebug, 0, "uhub debug level");
|
1998-11-26 23:13:13 +00:00
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
2007-02-03 16:19:28 +00:00
|
|
|
#define DEVPRINTF(x)
|
|
|
|
#define DEVPRINTFN(n,x)
|
1998-11-26 23:13:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct uhub_softc {
|
2006-09-07 00:06:42 +00:00
|
|
|
device_t sc_dev; /* base device */
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_device_handle sc_hub; /* USB device */
|
|
|
|
usbd_pipe_handle sc_ipipe; /* interrupt pipe */
|
2007-06-29 20:34:42 +00:00
|
|
|
u_int8_t sc_status[32]; /* max 255 ports */
|
1998-11-26 23:13:13 +00:00
|
|
|
u_char sc_running;
|
|
|
|
};
|
2004-11-03 01:52:50 +00:00
|
|
|
#define UHUB_PROTO(sc) ((sc)->sc_hub->ddesc.bDeviceProtocol)
|
|
|
|
#define UHUB_IS_HIGH_SPEED(sc) (UHUB_PROTO(sc) != UDPROTO_FSHUB)
|
|
|
|
#define UHUB_IS_SINGLE_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBSTT)
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2006-09-06 23:44:25 +00:00
|
|
|
static usbd_status uhub_explore(usbd_device_handle hub);
|
|
|
|
static void uhub_intr(usbd_xfer_handle, usbd_private_handle,usbd_status);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2003-07-04 01:50:39 +00:00
|
|
|
/*
|
1999-11-17 22:33:51 +00:00
|
|
|
* We need two attachment points:
|
1999-10-07 19:26:38 +00:00
|
|
|
* hub to usb and hub to hub
|
|
|
|
* Every other driver only connects to hubs
|
|
|
|
*/
|
|
|
|
|
2007-06-21 14:42:34 +00:00
|
|
|
static device_probe_t uhub_match;
|
|
|
|
static device_attach_t uhub_attach;
|
|
|
|
static device_detach_t uhub_detach;
|
|
|
|
static bus_child_location_str_t uhub_child_location_str;
|
|
|
|
static bus_child_pnpinfo_str_t uhub_child_pnpinfo_str;
|
|
|
|
|
|
|
|
static device_method_t uhub_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, uhub_match),
|
|
|
|
DEVMETHOD(device_attach, uhub_attach),
|
|
|
|
DEVMETHOD(device_detach, uhub_detach),
|
|
|
|
DEVMETHOD(device_suspend, bus_generic_suspend),
|
|
|
|
DEVMETHOD(device_resume, bus_generic_resume),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
|
2004-08-14 22:10:26 +00:00
|
|
|
DEVMETHOD(bus_child_pnpinfo_str, uhub_child_pnpinfo_str),
|
|
|
|
DEVMETHOD(bus_child_location_str, uhub_child_location_str),
|
2007-06-21 14:42:34 +00:00
|
|
|
/* XXX driver_added needs special care */
|
|
|
|
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t uhub_driver = {
|
|
|
|
"uhub",
|
|
|
|
uhub_methods,
|
|
|
|
sizeof(struct uhub_softc)
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t uhub_devclass;
|
2003-07-04 01:50:39 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
/* Create the driver instance for the hub connected to usb case. */
|
1999-01-14 01:28:15 +00:00
|
|
|
devclass_t uhubroot_devclass;
|
|
|
|
|
2006-09-06 23:44:25 +00:00
|
|
|
static device_method_t uhubroot_methods[] = {
|
2007-06-21 14:42:34 +00:00
|
|
|
DEVMETHOD(device_probe, uhub_match),
|
|
|
|
DEVMETHOD(device_attach, uhub_attach),
|
|
|
|
DEVMETHOD(device_detach, uhub_detach),
|
|
|
|
DEVMETHOD(device_suspend, bus_generic_suspend),
|
|
|
|
DEVMETHOD(device_resume, bus_generic_resume),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
|
2004-06-30 02:56:24 +00:00
|
|
|
DEVMETHOD(bus_child_location_str, uhub_child_location_str),
|
2004-08-14 22:10:26 +00:00
|
|
|
DEVMETHOD(bus_child_pnpinfo_str, uhub_child_pnpinfo_str),
|
2007-06-21 14:42:34 +00:00
|
|
|
/* XXX driver_added needs special care */
|
|
|
|
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
{0,0}
|
1999-01-14 01:28:15 +00:00
|
|
|
};
|
|
|
|
|
2006-09-06 23:44:25 +00:00
|
|
|
static driver_t uhubroot_driver = {
|
1999-10-07 19:26:38 +00:00
|
|
|
"uhub",
|
|
|
|
uhubroot_methods,
|
|
|
|
sizeof(struct uhub_softc)
|
1999-01-14 01:28:15 +00:00
|
|
|
};
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2007-06-13 05:37:59 +00:00
|
|
|
static int
|
|
|
|
uhub_match(device_t self)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
2007-06-17 16:24:49 +00:00
|
|
|
struct usb_attach_arg *uaa = device_get_ivars(self);
|
1998-11-26 23:13:13 +00:00
|
|
|
usb_device_descriptor_t *dd = usbd_get_device_descriptor(uaa->device);
|
2003-07-04 01:50:39 +00:00
|
|
|
|
1998-12-09 23:36:15 +00:00
|
|
|
DPRINTFN(5,("uhub_match, dd=%p\n", dd));
|
2003-07-04 01:50:39 +00:00
|
|
|
/*
|
1998-11-26 23:13:13 +00:00
|
|
|
* The subclass for hubs seems to be 0 for some and 1 for others,
|
|
|
|
* so we just ignore the subclass.
|
|
|
|
*/
|
2002-01-02 18:28:45 +00:00
|
|
|
if (uaa->iface == NULL && dd->bDeviceClass == UDCLASS_HUB)
|
1998-11-26 23:13:13 +00:00
|
|
|
return (UMATCH_DEVCLASS_DEVSUBCLASS);
|
|
|
|
return (UMATCH_NONE);
|
|
|
|
}
|
|
|
|
|
2007-02-03 16:19:28 +00:00
|
|
|
int
|
|
|
|
uhub_attach(device_t self)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
2007-02-03 16:19:28 +00:00
|
|
|
struct uhub_softc *sc = device_get_softc(self);
|
|
|
|
struct usb_attach_arg *uaa = device_get_ivars(self);
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_device_handle dev = uaa->device;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
2004-11-03 01:52:50 +00:00
|
|
|
struct usbd_hub *hub = NULL;
|
1998-11-26 23:13:13 +00:00
|
|
|
usb_device_request_t req;
|
|
|
|
usb_hub_descriptor_t hubdesc;
|
2000-05-14 19:39:10 +00:00
|
|
|
int p, port, nports, nremov, pwrdly;
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_interface_handle iface;
|
|
|
|
usb_endpoint_descriptor_t *ed;
|
2004-11-03 01:52:50 +00:00
|
|
|
struct usbd_tt *tts = NULL;
|
2003-07-04 01:50:39 +00:00
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
DPRINTFN(1,("uhub_attach\n"));
|
1998-11-26 23:13:13 +00:00
|
|
|
sc->sc_hub = dev;
|
2007-02-03 16:19:28 +00:00
|
|
|
sc->sc_dev = self;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2005-03-20 23:45:00 +00:00
|
|
|
if (dev->depth > 0 && UHUB_IS_HIGH_SPEED(sc)) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "%s transaction translator%s\n",
|
2004-11-03 01:52:50 +00:00
|
|
|
UHUB_IS_SINGLE_TT(sc) ? "single" : "multiple",
|
|
|
|
UHUB_IS_SINGLE_TT(sc) ? "" : "s");
|
|
|
|
}
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_set_config_index(dev, 0, 1);
|
|
|
|
if (err) {
|
2007-02-03 21:11:11 +00:00
|
|
|
DEVPRINTF((sc->sc_dev, "configuration failed, error=%s\n",
|
2007-02-03 16:19:28 +00:00
|
|
|
usbd_errstr(err)));
|
|
|
|
return (ENXIO);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dev->depth > USB_HUB_MAX_DEPTH) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "hub depth (%d) exceeded, hub ignored\n",
|
|
|
|
USB_HUB_MAX_DEPTH);
|
|
|
|
return (ENXIO);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get hub descriptor. */
|
|
|
|
req.bmRequestType = UT_READ_CLASS_DEVICE;
|
|
|
|
req.bRequest = UR_GET_DESCRIPTOR;
|
2003-07-14 17:46:27 +00:00
|
|
|
USETW2(req.wValue, (dev->address > 1 ? UDESC_HUB : 0), 0);
|
1998-11-26 23:13:13 +00:00
|
|
|
USETW(req.wIndex, 0);
|
|
|
|
USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE);
|
|
|
|
DPRINTFN(1,("usb_init_hub: getting hub descriptor\n"));
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_do_request(dev, &req, &hubdesc);
|
1999-01-07 23:07:57 +00:00
|
|
|
nports = hubdesc.bNbrPorts;
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!err && nports > 7) {
|
1999-01-07 23:07:57 +00:00
|
|
|
USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE + (nports+1) / 8);
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_do_request(dev, &req, &hubdesc);
|
1999-01-07 23:07:57 +00:00
|
|
|
}
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err) {
|
2007-02-03 16:19:28 +00:00
|
|
|
DEVPRINTF((sc->sc_dev, "getting hub descriptor failed: %s\n",
|
|
|
|
usbd_errstr(err)));
|
|
|
|
return (ENXIO);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
for (nremov = 0, port = 1; port <= nports; port++)
|
|
|
|
if (!UHD_NOT_REMOV(&hubdesc, port))
|
|
|
|
nremov++;
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "%d port%s with %d removable, %s powered\n",
|
|
|
|
nports, nports != 1 ? "s" : "", nremov,
|
|
|
|
dev->self_powered ? "self" : "bus");
|
1999-01-07 23:07:57 +00:00
|
|
|
|
2004-11-03 01:52:50 +00:00
|
|
|
if (nports == 0) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "no ports, hub ignored\n");
|
2004-11-03 01:52:50 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
hub = malloc(sizeof(*hub) + (nports-1) * sizeof(struct usbd_port),
|
1999-10-07 19:26:38 +00:00
|
|
|
M_USBDEV, M_NOWAIT);
|
2001-08-10 17:32:11 +00:00
|
|
|
if (hub == NULL) {
|
2007-02-03 16:19:28 +00:00
|
|
|
return (ENXIO);
|
2001-08-10 17:32:11 +00:00
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
dev->hub = hub;
|
1999-01-07 23:07:57 +00:00
|
|
|
dev->hub->hubsoftc = sc;
|
1998-11-26 23:13:13 +00:00
|
|
|
hub->explore = uhub_explore;
|
|
|
|
hub->hubdesc = hubdesc;
|
2003-07-04 01:50:39 +00:00
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
DPRINTFN(1,("usbhub_init_hub: selfpowered=%d, parent=%p, "
|
|
|
|
"parent->selfpowered=%d\n",
|
1998-11-26 23:13:13 +00:00
|
|
|
dev->self_powered, dev->powersrc->parent,
|
2003-07-04 01:50:39 +00:00
|
|
|
dev->powersrc->parent ?
|
1998-11-26 23:13:13 +00:00
|
|
|
dev->powersrc->parent->self_powered : 0));
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!dev->self_powered && dev->powersrc->parent != NULL &&
|
1998-11-26 23:13:13 +00:00
|
|
|
!dev->powersrc->parent->self_powered) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "bus powered hub connected to bus "
|
|
|
|
"powered hub, ignored\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
goto bad;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up interrupt pipe. */
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_device2interface_handle(dev, 0, &iface);
|
|
|
|
if (err) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "no interface handle\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
goto bad;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
ed = usbd_interface2endpoint_descriptor(iface, 0);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (ed == NULL) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "no endpoint descriptor\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
goto bad;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
if ((ed->bmAttributes & UE_XFERTYPE) != UE_INTERRUPT) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "bad interrupt endpoint\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
goto bad;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_open_pipe_intr(iface, ed->bEndpointAddress,
|
2003-07-04 01:50:39 +00:00
|
|
|
USBD_SHORT_XFER_OK, &sc->sc_ipipe, sc, sc->sc_status,
|
2007-06-29 20:34:42 +00:00
|
|
|
(nports + 1 + 7) / 8, uhub_intr, UHUB_INTR_INTERVAL);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "cannot open interrupt pipe\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
goto bad;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
/* Wait with power off for a while. */
|
|
|
|
usbd_delay_ms(dev, USB_POWER_DOWN_TIME);
|
|
|
|
|
2007-06-12 16:52:07 +00:00
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, sc->sc_dev);
|
2002-01-28 01:03:19 +00:00
|
|
|
|
2000-05-14 19:39:10 +00:00
|
|
|
/*
|
|
|
|
* To have the best chance of success we do things in the exact same
|
|
|
|
* order as Windoze98. This should not be necessary, but some
|
|
|
|
* devices do not follow the USB specs to the letter.
|
|
|
|
*
|
|
|
|
* These are the events on the bus when a hub is attached:
|
|
|
|
* Get device and config descriptors (see attach code)
|
|
|
|
* Get hub descriptor (see above)
|
|
|
|
* For all ports
|
|
|
|
* turn on power
|
|
|
|
* wait for power to become stable
|
|
|
|
* (all below happens in explore code)
|
|
|
|
* For all ports
|
|
|
|
* clear C_PORT_CONNECTION
|
|
|
|
* For all ports
|
|
|
|
* get port status
|
|
|
|
* if device connected
|
2002-04-07 11:20:41 +00:00
|
|
|
* wait 100 ms
|
2000-05-14 19:39:10 +00:00
|
|
|
* turn on reset
|
|
|
|
* wait
|
|
|
|
* clear C_PORT_RESET
|
|
|
|
* get port status
|
|
|
|
* proceed with device attachment
|
|
|
|
*/
|
|
|
|
|
2004-11-03 01:52:50 +00:00
|
|
|
if (UHUB_IS_HIGH_SPEED(sc)) {
|
|
|
|
tts = malloc((UHUB_IS_SINGLE_TT(sc) ? 1 : nports) *
|
|
|
|
sizeof (struct usbd_tt), M_USBDEV, M_NOWAIT);
|
|
|
|
if (!tts)
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2000-05-14 19:39:10 +00:00
|
|
|
/* Set up data structures */
|
1999-01-07 23:07:57 +00:00
|
|
|
for (p = 0; p < nports; p++) {
|
|
|
|
struct usbd_port *up = &hub->ports[p];
|
2004-11-03 01:52:50 +00:00
|
|
|
up->device = NULL;
|
1999-01-07 23:07:57 +00:00
|
|
|
up->parent = dev;
|
|
|
|
up->portno = p+1;
|
2000-05-14 19:39:10 +00:00
|
|
|
if (dev->self_powered)
|
|
|
|
/* Self powered hub, give ports maximum current. */
|
|
|
|
up->power = USB_MAX_POWER;
|
|
|
|
else
|
|
|
|
up->power = USB_MIN_POWER;
|
2004-06-10 01:13:26 +00:00
|
|
|
up->restartcnt = 0;
|
2004-11-03 01:52:50 +00:00
|
|
|
if (UHUB_IS_HIGH_SPEED(sc)) {
|
|
|
|
up->tt = &tts[UHUB_IS_SINGLE_TT(sc) ? 0 : p];
|
|
|
|
up->tt->hub = hub;
|
|
|
|
} else {
|
|
|
|
up->tt = NULL;
|
|
|
|
}
|
2000-05-14 19:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX should check for none, individual, or ganged power? */
|
|
|
|
|
|
|
|
pwrdly = dev->hub->hubdesc.bPwrOn2PwrGood * UHD_PWRON_FACTOR
|
|
|
|
+ USB_EXTRA_POWER_UP_TIME;
|
|
|
|
for (port = 1; port <= nports; port++) {
|
|
|
|
/* Turn the power on. */
|
|
|
|
err = usbd_set_port_feature(dev, port, UHF_PORT_POWER);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err)
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"port %d power on failed, %s\n", port,
|
|
|
|
usbd_errstr(err));
|
2000-05-14 19:39:10 +00:00
|
|
|
DPRINTF(("usb_init_port: turn on port %d power\n", port));
|
|
|
|
/* Wait for stable power. */
|
|
|
|
usbd_delay_ms(dev, pwrdly);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
2000-05-14 19:39:10 +00:00
|
|
|
|
|
|
|
/* The usual exploration will finish the setup. */
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
sc->sc_running = 1;
|
2007-02-03 16:19:28 +00:00
|
|
|
return (0);
|
1999-11-17 22:33:51 +00:00
|
|
|
bad:
|
2004-11-03 01:52:50 +00:00
|
|
|
if (hub)
|
|
|
|
free(hub, M_USBDEV);
|
|
|
|
dev->hub = NULL;
|
2007-02-03 16:19:28 +00:00
|
|
|
return (ENXIO);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2000-10-16 17:40:59 +00:00
|
|
|
uhub_explore(usbd_device_handle dev)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
usb_hub_descriptor_t *hd = &dev->hub->hubdesc;
|
1999-01-07 23:07:57 +00:00
|
|
|
struct uhub_softc *sc = dev->hub->hubsoftc;
|
1998-11-26 23:13:13 +00:00
|
|
|
struct usbd_port *up;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
2002-02-19 02:00:27 +00:00
|
|
|
int speed;
|
1998-11-26 23:13:13 +00:00
|
|
|
int port;
|
|
|
|
int change, status;
|
|
|
|
|
|
|
|
DPRINTFN(10, ("uhub_explore dev=%p addr=%d\n", dev, dev->address));
|
|
|
|
|
|
|
|
if (!sc->sc_running)
|
|
|
|
return (USBD_NOT_STARTED);
|
|
|
|
|
|
|
|
/* Ignore hubs that are too deep. */
|
|
|
|
if (dev->depth > USB_HUB_MAX_DEPTH)
|
|
|
|
return (USBD_TOO_DEEP);
|
|
|
|
|
|
|
|
for(port = 1; port <= hd->bNbrPorts; port++) {
|
|
|
|
up = &dev->hub->ports[port-1];
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_get_port_status(dev, port, &up->status);
|
|
|
|
if (err) {
|
1999-10-07 19:26:38 +00:00
|
|
|
DPRINTF(("uhub_explore: get port status failed, "
|
1999-11-17 22:33:51 +00:00
|
|
|
"error=%s\n", usbd_errstr(err)));
|
1998-11-26 23:13:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
status = UGETW(up->status.wPortStatus);
|
|
|
|
change = UGETW(up->status.wPortChange);
|
2007-02-03 16:19:28 +00:00
|
|
|
DEVPRINTFN(3,(sc->sc_dev,
|
|
|
|
"uhub_explore: port %d status 0x%04x 0x%04x\n", port,
|
|
|
|
status, change));
|
1999-01-07 23:07:57 +00:00
|
|
|
if (change & UPS_C_PORT_ENABLED) {
|
2004-09-09 20:43:49 +00:00
|
|
|
DPRINTF(("uhub_explore: C_PORT_ENABLED 0x%x\n", change));
|
1999-01-07 23:07:57 +00:00
|
|
|
usbd_clear_port_feature(dev, port, UHF_C_PORT_ENABLE);
|
2004-07-01 21:14:03 +00:00
|
|
|
if (change & UPS_C_CONNECT_STATUS) {
|
|
|
|
/* Ignore the port error if the device
|
|
|
|
vanished. */
|
|
|
|
} else if (status & UPS_PORT_ENABLED) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"illegal enable change, port %d\n", port);
|
1999-01-07 23:07:57 +00:00
|
|
|
} else {
|
|
|
|
/* Port error condition. */
|
2000-10-16 17:40:59 +00:00
|
|
|
if (up->restartcnt) /* no message first time */
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"port error, restarting port %d\n",
|
|
|
|
port);
|
2000-10-16 17:40:59 +00:00
|
|
|
|
|
|
|
if (up->restartcnt++ < USBD_RESTART_MAX)
|
1999-01-07 23:07:57 +00:00
|
|
|
goto disco;
|
2000-10-16 17:40:59 +00:00
|
|
|
else
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"port error, giving up port %d\n",
|
|
|
|
port);
|
1999-01-07 23:07:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(change & UPS_C_CONNECT_STATUS)) {
|
1999-11-28 21:01:06 +00:00
|
|
|
DPRINTFN(3,("uhub_explore: port=%d !C_CONNECT_"
|
|
|
|
"STATUS\n", port));
|
1998-11-26 23:13:13 +00:00
|
|
|
/* No status change, just do recursive explore. */
|
2002-04-07 10:31:39 +00:00
|
|
|
if (up->device != NULL && up->device->hub != NULL)
|
1998-11-26 23:13:13 +00:00
|
|
|
up->device->hub->explore(up->device);
|
2002-04-07 10:31:39 +00:00
|
|
|
#if 0 && defined(DIAGNOSTIC)
|
2003-07-04 01:50:39 +00:00
|
|
|
if (up->device == NULL &&
|
2002-04-07 10:31:39 +00:00
|
|
|
(status & UPS_CURRENT_CONNECT_STATUS))
|
2007-02-03 16:19:28 +00:00
|
|
|
deivce_printf(sc->sc_dev,
|
|
|
|
"connected, no device\n");
|
2002-04-07 10:31:39 +00:00
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
2000-05-14 19:39:10 +00:00
|
|
|
|
|
|
|
/* We have a connect status change, handle it. */
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
DPRINTF(("uhub_explore: status change hub=%d port=%d\n",
|
|
|
|
dev->address, port));
|
|
|
|
usbd_clear_port_feature(dev, port, UHF_C_PORT_CONNECTION);
|
2000-05-14 19:39:10 +00:00
|
|
|
/*usbd_clear_port_feature(dev, port, UHF_C_PORT_ENABLE);*/
|
1998-11-26 23:13:13 +00:00
|
|
|
/*
|
|
|
|
* If there is already a device on the port the change status
|
|
|
|
* must mean that is has disconnected. Looking at the
|
|
|
|
* current connect status is not enough to figure this out
|
|
|
|
* since a new unit may have been connected before we handle
|
|
|
|
* the disconnect.
|
|
|
|
*/
|
1999-01-07 23:07:57 +00:00
|
|
|
disco:
|
1999-11-17 22:33:51 +00:00
|
|
|
if (up->device != NULL) {
|
1998-11-26 23:13:13 +00:00
|
|
|
/* Disconnected */
|
1999-11-28 21:01:06 +00:00
|
|
|
DPRINTF(("uhub_explore: device addr=%d disappeared "
|
1999-11-17 22:33:51 +00:00
|
|
|
"on port %d\n", up->device->address, port));
|
2007-06-12 16:52:07 +00:00
|
|
|
usb_disconnect_port(up, sc->sc_dev);
|
2003-07-04 01:50:39 +00:00
|
|
|
usbd_clear_port_feature(dev, port,
|
1998-11-26 23:13:13 +00:00
|
|
|
UHF_C_PORT_CONNECTION);
|
|
|
|
}
|
1999-11-28 21:01:06 +00:00
|
|
|
if (!(status & UPS_CURRENT_CONNECT_STATUS)) {
|
2000-05-14 19:39:10 +00:00
|
|
|
/* Nothing connected, just ignore it. */
|
1999-11-28 21:01:06 +00:00
|
|
|
DPRINTFN(3,("uhub_explore: port=%d !CURRENT_CONNECT"
|
|
|
|
"_STATUS\n", port));
|
1998-11-26 23:13:13 +00:00
|
|
|
continue;
|
1999-11-28 21:01:06 +00:00
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
|
|
|
|
/* Connected */
|
2000-05-14 19:39:10 +00:00
|
|
|
|
|
|
|
if (!(status & UPS_PORT_POWER))
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"strange, connected port %d has no power\n", port);
|
2000-05-14 19:39:10 +00:00
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
/* Wait for maximum device power up time. */
|
1999-01-07 23:07:57 +00:00
|
|
|
usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
/* Reset port, which implies enabling it. */
|
1999-11-28 21:01:06 +00:00
|
|
|
if (usbd_reset_port(dev, port, &up->status)) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev, "port %d reset failed\n",
|
|
|
|
port);
|
1998-11-26 23:13:13 +00:00
|
|
|
continue;
|
1999-11-28 21:01:06 +00:00
|
|
|
}
|
2002-04-07 10:57:42 +00:00
|
|
|
/* Get port status again, it might have changed during reset */
|
|
|
|
err = usbd_get_port_status(dev, port, &up->status);
|
|
|
|
if (err) {
|
|
|
|
DPRINTF(("uhub_explore: get port status failed, "
|
|
|
|
"error=%s\n", usbd_errstr(err)));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
status = UGETW(up->status.wPortStatus);
|
|
|
|
change = UGETW(up->status.wPortChange);
|
|
|
|
if (!(status & UPS_CURRENT_CONNECT_STATUS)) {
|
|
|
|
/* Nothing connected, just ignore it. */
|
|
|
|
#ifdef DIAGNOSTIC
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"port %d, device disappeared after reset\n", port);
|
2002-04-07 10:57:42 +00:00
|
|
|
#endif
|
|
|
|
continue;
|
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2004-11-03 01:52:50 +00:00
|
|
|
#if 0
|
|
|
|
if (UHUB_IS_HIGH_SPEED(sc) && !(status & UPS_HIGH_SPEED)) {
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"port %d, transaction translation not implemented,"
|
|
|
|
" low/full speed device ignored\n", port);
|
2004-11-03 01:52:50 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-02-19 02:00:27 +00:00
|
|
|
/* Figure out device speed */
|
|
|
|
if (status & UPS_HIGH_SPEED)
|
|
|
|
speed = USB_SPEED_HIGH;
|
|
|
|
else if (status & UPS_LOW_SPEED)
|
|
|
|
speed = USB_SPEED_LOW;
|
|
|
|
else
|
|
|
|
speed = USB_SPEED_FULL;
|
1998-11-26 23:13:13 +00:00
|
|
|
/* Get device info and set its address. */
|
2007-06-12 16:52:07 +00:00
|
|
|
err = usbd_new_device(sc->sc_dev, dev->bus,
|
2002-02-19 02:00:27 +00:00
|
|
|
dev->depth + 1, speed, port, up);
|
1998-11-26 23:13:13 +00:00
|
|
|
/* XXX retry a few times? */
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err) {
|
1999-10-07 19:26:38 +00:00
|
|
|
DPRINTFN(-1,("uhub_explore: usb_new_device failed, "
|
1999-11-17 22:33:51 +00:00
|
|
|
"error=%s\n", usbd_errstr(err)));
|
1998-11-26 23:13:13 +00:00
|
|
|
/* Avoid addressing problems by disabling. */
|
|
|
|
/* usbd_reset_port(dev, port, &up->status); */
|
1999-11-17 22:33:51 +00:00
|
|
|
|
2003-07-04 01:50:39 +00:00
|
|
|
/*
|
1999-11-17 22:33:51 +00:00
|
|
|
* The unit refused to accept a new address, or had
|
|
|
|
* some other serious problem. Since we cannot leave
|
|
|
|
* at 0 we have to disable the port instead.
|
|
|
|
*/
|
2007-02-03 16:19:28 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"device problem (%s), disabling port %d\n",
|
|
|
|
usbd_errstr(err), port);
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE);
|
1998-11-26 23:13:13 +00:00
|
|
|
} else {
|
2000-10-16 17:40:59 +00:00
|
|
|
/* The port set up succeeded, reset error count. */
|
|
|
|
up->restartcnt = 0;
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
if (up->device->hub)
|
|
|
|
up->device->hub->explore(up->device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
/*
|
|
|
|
* Called from process context when the hub is gone.
|
|
|
|
* Detach all devices on active ports.
|
|
|
|
*/
|
2007-06-13 05:37:59 +00:00
|
|
|
static int
|
|
|
|
uhub_detach(device_t self)
|
1999-10-07 19:26:38 +00:00
|
|
|
{
|
2007-06-21 14:42:34 +00:00
|
|
|
struct uhub_softc *sc = device_get_softc(self);
|
2002-04-07 11:29:31 +00:00
|
|
|
struct usbd_hub *hub = sc->sc_hub->hub;
|
1999-11-17 22:33:51 +00:00
|
|
|
struct usbd_port *rup;
|
1999-10-07 19:26:38 +00:00
|
|
|
int port, nports;
|
|
|
|
|
|
|
|
DPRINTF(("uhub_detach: sc=%port\n", sc));
|
2002-04-07 11:29:31 +00:00
|
|
|
if (hub == NULL) /* Must be partially working */
|
1999-10-07 19:26:38 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
usbd_abort_pipe(sc->sc_ipipe);
|
|
|
|
usbd_close_pipe(sc->sc_ipipe);
|
|
|
|
|
2002-04-07 11:29:31 +00:00
|
|
|
nports = hub->hubdesc.bNbrPorts;
|
1999-10-07 19:26:38 +00:00
|
|
|
for(port = 0; port < nports; port++) {
|
2002-04-07 11:29:31 +00:00
|
|
|
rup = &hub->ports[port];
|
1999-11-17 22:33:51 +00:00
|
|
|
if (rup->device)
|
|
|
|
usb_disconnect_port(rup, self);
|
1999-01-07 23:07:57 +00:00
|
|
|
}
|
2002-01-28 01:03:19 +00:00
|
|
|
|
2007-06-12 16:52:07 +00:00
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_hub, sc->sc_dev);
|
2000-05-14 19:39:10 +00:00
|
|
|
|
2004-11-03 01:52:50 +00:00
|
|
|
if (hub->ports[0].tt)
|
|
|
|
free(hub->ports[0].tt, M_USBDEV);
|
2002-04-07 11:29:31 +00:00
|
|
|
free(hub, M_USBDEV);
|
|
|
|
sc->sc_hub->hub = NULL;
|
1999-01-07 23:07:57 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
return (0);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
2004-06-30 02:56:24 +00:00
|
|
|
int
|
|
|
|
uhub_child_location_str(device_t cbdev, device_t child, char *buf,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
|
|
|
struct uhub_softc *sc = device_get_softc(cbdev);
|
|
|
|
usbd_device_handle devhub = sc->sc_hub;
|
|
|
|
usbd_device_handle dev;
|
|
|
|
int nports;
|
|
|
|
int port;
|
|
|
|
int i;
|
|
|
|
|
2005-05-11 15:21:22 +00:00
|
|
|
mtx_lock(&Giant);
|
2004-06-30 02:56:24 +00:00
|
|
|
nports = devhub->hub->hubdesc.bNbrPorts;
|
|
|
|
for (port = 0; port < nports; port++) {
|
|
|
|
dev = devhub->hub->ports[port].device;
|
|
|
|
if (dev && dev->subdevs) {
|
|
|
|
for (i = 0; dev->subdevs[i]; i++) {
|
|
|
|
if (dev->subdevs[i] == child) {
|
2005-05-11 15:21:22 +00:00
|
|
|
if (dev->ifacenums == NULL) {
|
|
|
|
snprintf(buf, buflen,
|
|
|
|
"port=%i", port);
|
|
|
|
} else {
|
|
|
|
snprintf(buf, buflen,
|
|
|
|
"port=%i interface=%i",
|
|
|
|
port, dev->ifacenums[i]);
|
|
|
|
}
|
2004-06-30 02:56:24 +00:00
|
|
|
goto found_dev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DPRINTFN(0,("uhub_child_location_str: device not on hub\n"));
|
|
|
|
buf[0] = '\0';
|
|
|
|
found_dev:
|
2005-05-11 15:21:22 +00:00
|
|
|
mtx_unlock(&Giant);
|
2004-06-30 02:56:24 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
uhub_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
|
|
|
struct uhub_softc *sc = device_get_softc(cbdev);
|
|
|
|
usbd_device_handle devhub = sc->sc_hub;
|
|
|
|
usbd_device_handle dev;
|
|
|
|
struct usbd_interface *iface;
|
|
|
|
char serial[128];
|
|
|
|
int nports;
|
|
|
|
int port;
|
2005-03-25 01:44:38 +00:00
|
|
|
int i;
|
2004-06-30 02:56:24 +00:00
|
|
|
|
2005-05-11 15:21:22 +00:00
|
|
|
mtx_lock(&Giant);
|
2004-06-30 02:56:24 +00:00
|
|
|
nports = devhub->hub->hubdesc.bNbrPorts;
|
|
|
|
for (port = 0; port < nports; port++) {
|
|
|
|
dev = devhub->hub->ports[port].device;
|
|
|
|
if (dev && dev->subdevs) {
|
|
|
|
for (i = 0; dev->subdevs[i]; i++) {
|
|
|
|
if (dev->subdevs[i] == child) {
|
|
|
|
goto found_dev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DPRINTFN(0,("uhub_child_pnpinfo_str: device not on hub\n"));
|
|
|
|
buf[0] = '\0';
|
2005-05-11 15:21:22 +00:00
|
|
|
mtx_unlock(&Giant);
|
2004-06-30 02:56:24 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
found_dev:
|
2005-05-11 15:21:22 +00:00
|
|
|
/* XXX can sleep */
|
2007-06-30 20:18:44 +00:00
|
|
|
(void)usbd_get_string(dev, dev->ddesc.iSerialNumber, serial,
|
|
|
|
sizeof(serial));
|
2004-06-30 02:56:24 +00:00
|
|
|
if (dev->ifacenums == NULL) {
|
|
|
|
snprintf(buf, buflen, "vendor=0x%04x product=0x%04x "
|
|
|
|
"devclass=0x%02x devsubclass=0x%02x "
|
2005-08-23 21:32:49 +00:00
|
|
|
"release=0x%04x sernum=\"%s\"",
|
2004-06-30 02:56:24 +00:00
|
|
|
UGETW(dev->ddesc.idVendor), UGETW(dev->ddesc.idProduct),
|
|
|
|
dev->ddesc.bDeviceClass, dev->ddesc.bDeviceSubClass,
|
2005-08-23 21:32:49 +00:00
|
|
|
UGETW(dev->ddesc.bcdDevice), serial);
|
2004-06-30 02:56:24 +00:00
|
|
|
} else {
|
|
|
|
iface = &dev->ifaces[dev->ifacenums[i]];
|
|
|
|
snprintf(buf, buflen, "vendor=0x%04x product=0x%04x "
|
|
|
|
"devclass=0x%02x devsubclass=0x%02x "
|
2005-08-23 21:32:49 +00:00
|
|
|
"release=0x%04x sernum=\"%s\" "
|
2004-06-30 02:56:24 +00:00
|
|
|
"intclass=0x%02x intsubclass=0x%02x",
|
|
|
|
UGETW(dev->ddesc.idVendor), UGETW(dev->ddesc.idProduct),
|
|
|
|
dev->ddesc.bDeviceClass, dev->ddesc.bDeviceSubClass,
|
2005-08-23 21:32:49 +00:00
|
|
|
UGETW(dev->ddesc.bcdDevice), serial,
|
2004-06-30 02:56:24 +00:00
|
|
|
iface->idesc->bInterfaceClass,
|
|
|
|
iface->idesc->bInterfaceSubClass);
|
|
|
|
}
|
2005-05-11 15:21:22 +00:00
|
|
|
mtx_unlock(&Giant);
|
2004-06-30 02:56:24 +00:00
|
|
|
return (0);
|
|
|
|
}
|
1999-11-17 22:33:51 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
/*
|
|
|
|
* Hub interrupt.
|
|
|
|
* This an indication that some port has changed status.
|
|
|
|
* Notify the bus event handler thread that we need
|
|
|
|
* to be explored again.
|
|
|
|
*/
|
1998-11-26 23:13:13 +00:00
|
|
|
void
|
2000-10-16 17:40:59 +00:00
|
|
|
uhub_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
struct uhub_softc *sc = addr;
|
|
|
|
|
|
|
|
DPRINTFN(5,("uhub_intr: sc=%p\n", sc));
|
2001-09-02 09:26:14 +00:00
|
|
|
if (status == USBD_STALLED)
|
1999-01-07 23:07:57 +00:00
|
|
|
usbd_clear_endpoint_stall_async(sc->sc_ipipe);
|
2001-09-02 09:26:14 +00:00
|
|
|
else if (status == USBD_NORMAL_COMPLETION)
|
2002-04-02 09:49:36 +00:00
|
|
|
usb_needs_explore(sc->sc_hub);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
2007-06-21 14:42:34 +00:00
|
|
|
MODULE_DEPEND(uhub, usb, 1, 1, 1);
|
1999-01-14 01:28:15 +00:00
|
|
|
DRIVER_MODULE(uhub, usb, uhubroot_driver, uhubroot_devclass, 0, 0);
|
|
|
|
DRIVER_MODULE(uhub, uhub, uhub_driver, uhub_devclass, usbd_driver_load, 0);
|