usb_hub.h revision 193045
119370Spst/* $FreeBSD: head/sys/dev/usb/usb_hub.h 193045 2009-05-29 18:46:57Z thompsa $ */
298944Sobrien/*-
398944Sobrien * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
419370Spst *
519370Spst * Redistribution and use in source and binary forms, with or without
619370Spst * modification, are permitted provided that the following conditions
798944Sobrien * are met:
819370Spst * 1. Redistributions of source code must retain the above copyright
998944Sobrien *    notice, this list of conditions and the following disclaimer.
1098944Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1198944Sobrien *    notice, this list of conditions and the following disclaimer in the
1298944Sobrien *    documentation and/or other materials provided with the distribution.
1319370Spst *
1498944Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1598944Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1698944Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1798944Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1819370Spst * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1998944Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2098944Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2198944Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2298944Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2319370Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2498944Sobrien * SUCH DAMAGE.
2519370Spst */
2698944Sobrien
2719370Spst#ifndef _USB2_HUB_H_
2898944Sobrien#define	_USB2_HUB_H_
2998944Sobrien
3019370Spst/*
3198944Sobrien * The following structure defines an USB port.
3298944Sobrien */
3398944Sobrienstruct usb_port {
3419370Spst	uint8_t	restartcnt;
3598944Sobrien#define	USB_RESTART_MAX 5
3619370Spst	uint8_t	device_index;		/* zero means not valid */
3719370Spst	enum usb_hc_mode usb_mode;	/* host or device mode */
3898944Sobrien};
3998944Sobrien
4098944Sobrien/*
4198944Sobrien * The following structure defines how many bytes are
4298944Sobrien * left in an 1ms USB time slot.
4319370Spst */
4419370Spststruct usb_fs_isoc_schedule {
4598944Sobrien	uint16_t total_bytes;
4698944Sobrien	uint8_t	frame_bytes;
4798944Sobrien	uint8_t	frame_slot;
4898944Sobrien};
4998944Sobrien
5098944Sobrien/*
5198944Sobrien * The following structure defines an USB HUB.
5298944Sobrien */
5398944Sobrienstruct usb_hub {
5498944Sobrien#if USB_HAVE_TT_SUPPORT
5519370Spst	struct usb_fs_isoc_schedule fs_isoc_schedule[USB_ISOC_TIME_MAX];
5698944Sobrien#endif
5719370Spst	struct usb_device *hubudev;	/* the HUB device */
5898944Sobrien	usb_error_t (*explore) (struct usb_device *hub);
5919370Spst	void   *hubsoftc;
6098944Sobrien	size_t uframe_usage[USB_HS_MICRO_FRAMES_MAX];
6198944Sobrien	uint16_t portpower;		/* mA per USB port */
6298944Sobrien	uint8_t	isoc_last_time;
6319370Spst	uint8_t	nports;
6498944Sobrien	struct usb_port ports[0];
6519370Spst};
6698944Sobrien
6719370Spst/* function prototypes */
6819370Spst
6998944Sobrienuint8_t	usb2_intr_schedule_adjust(struct usb_device *udev, int16_t len,
7098944Sobrien	    uint8_t slot);
7198944Sobrienvoid	usb2_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss);
7219370Spstvoid	usb2_bus_port_set_device(struct usb_bus *bus, struct usb_port *up,
7319370Spst	    struct usb_device *udev, uint8_t device_index);
7419370Spststruct usb_device *usb2_bus_port_get_device(struct usb_bus *bus,
7519370Spst	    struct usb_port *up);
7619370Spstvoid	usb2_needs_explore(struct usb_bus *bus, uint8_t do_probe);
7798944Sobrienvoid	usb2_needs_explore_all(void);
7898944Sobrienvoid	usb2_bus_power_update(struct usb_bus *bus);
7998944Sobrienvoid	usb2_bus_powerd(struct usb_bus *bus);
8019370Spstvoid	uhub_root_intr(struct usb_bus *, const uint8_t *, uint8_t);
8119370Spst
8219370Spst#endif					/* _USB2_HUB_H_ */
8319370Spst