Implementation requirements of usb_needs_reattach(), from OpenBSD and required

for atu(4) to do a USB reconnect after firmware upload.
This commit is contained in:
joff 2005-01-24 01:30:38 +00:00
parent 988043649e
commit 9a12dd0ebe
3 changed files with 21 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhub.c,v 1.71 2004/10/26 05:00:59 augustss Exp $ */
/* $NetBSD: uhub.c,v 1.72 2005/01/24 01:30:38 joff Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
/*
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.71 2004/10/26 05:00:59 augustss Exp $");
__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.72 2005/01/24 01:30:38 joff Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -310,6 +310,7 @@ USB_ATTACH(uhub)
else
up->power = USB_MIN_POWER;
up->restartcnt = 0;
up->reattach = 0;
if (UHUB_IS_HIGH_SPEED(sc)) {
up->tt = &tts[UHUB_IS_SINGLE_TT(sc) ? 0 : p];
up->tt->hub = hub;
@ -356,7 +357,7 @@ uhub_explore(usbd_device_handle dev)
usbd_status err;
int speed;
int port;
int change, status;
int change, status, reconnect;
DPRINTFN(10, ("uhub_explore dev=%p addr=%d\n", dev, dev->address));
@ -377,6 +378,8 @@ uhub_explore(usbd_device_handle dev)
}
status = UGETW(up->status.wPortStatus);
change = UGETW(up->status.wPortChange);
reconnect = up->reattach;
up->reattach = 0;
DPRINTFN(3,("uhub_explore: %s port %d status 0x%04x 0x%04x\n",
USBDEVNAME(sc->sc_dev), port, status, change));
if (change & UPS_C_PORT_ENABLED) {
@ -403,7 +406,7 @@ uhub_explore(usbd_device_handle dev)
USBDEVNAME(sc->sc_dev), port);
}
}
if (!(change & UPS_C_CONNECT_STATUS)) {
if (!reconnect && !(change & UPS_C_CONNECT_STATUS)) {
DPRINTFN(3,("uhub_explore: port=%d !C_CONNECT_"
"STATUS\n", port));
/* No status change, just do recursive explore. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: usb.c,v 1.80 2003/11/07 17:03:25 wiz Exp $ */
/* $NetBSD: usb.c,v 1.81 2005/01/24 01:30:38 joff Exp $ */
/*
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.80 2003/11/07 17:03:25 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.81 2005/01/24 01:30:38 joff Exp $");
#include "ohci.h"
#include "uhci.h"
@ -678,6 +678,15 @@ usb_needs_explore(usbd_device_handle dev)
wakeup(&dev->bus->needs_explore);
}
void
usb_needs_reattach(usbd_device_handle dev)
{
DPRINTFN(2,("usb_needs_reattach\n"));
dev->powersrc->reattach = 1;
dev->bus->needs_explore = 1;
wakeup(&dev->bus->needs_explore);
}
/* Called at splusb() */
int
usb_get_next_event(struct usb_event *ue)

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbdivar.h,v 1.72 2004/10/23 16:17:56 augustss Exp $ */
/* $NetBSD: usbdivar.h,v 1.73 2005/01/24 01:30:38 joff Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@ -83,6 +83,7 @@ struct usbd_port {
u_int8_t portno;
u_int8_t restartcnt;
#define USBD_RESTART_MAX 5
u_int8_t reattach;
struct usbd_device *device; /* Connected device */
struct usbd_device *parent; /* The ports hub */
struct usbd_tt *tt; /* Transaction translator (if any) */
@ -260,6 +261,7 @@ void usb_disconnect_port(struct usbd_port *, device_ptr_t);
/* Routines from usb.c */
void usb_needs_explore(usbd_device_handle);
void usb_needs_reattach(usbd_device_handle);
void usb_schedsoftintr(struct usbd_bus *);
/*