hubdvar.h revision ff0e937b36dcde1a47ff7b00aa76a491c0dc07a8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_USB_HUBDVAR_H
#define _SYS_USB_HUBDVAR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ndi_impldefs.h>
/*
* HUB USB device state management :
*
* CHILD PWRLVL---1>--------+
* ^ |
* 8 |
* | |
* 9 |
* v |
* PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED
* | | ^ | |
* | | 10 | |
* | | | | |
* | | RECOVER-<2-------+ |
* | | ^ |
* | 5 6 |
* | | | |
* | v | |
* +----5>----------SUSPENDED----<5----7>----+
*
* 1 = Device Unplug
* 2 = Original Device reconnected and after hub driver restores its own
* device state.
* 3 = Device idles for time T & transitions to low power state
* 4 = Remote wakeup by device OR Application kicking off IO to device
* 5 = Notification to save state prior to DDI_SUSPEND
* 6 = Notification to restore state after DDI_RESUME with correct device
* and after hub driver restores its own device state.
* 7 = Notification to restore state after DDI_RESUME with device
* disconnected or a wrong device
* 8 = Hub detect child doing remote wakeup and request the PM
* framework to bring it to full power
* 9 = PM framework has compeleted call power entry point of the child
* and bus ctls of hub
* 10 = Restoring states of its children i.e. set addrs & config.
*
*/
#define HUBD_INITIAL_SOFT_SPACE 4
typedef struct hub_power_struct {
void *hubp_hubd; /* points back to hubd_t */
/* this is the bit mask of the power states that device has */
int hubp_busy_pm; /* device busy accounting */
/* wakeup and power transition capabilities of an interface */
/* power state of all children are tracked here */
/* pm-components properties are stored here */
char *hubp_pmcomp[5];
} hub_power_t;
/* warlock directives, stable data */
/*
* hubd cpr data structure used for callback before kernel threads are
* suspended
*/
typedef struct hubd_cpr {
} hubd_cpr_t;
/*
* soft state information for this hubd
*/
typedef struct hubd {
int h_instance;
/*
* mutex to protect softstate and hw regs
*/
/*
* save the usba_device pointer
*/
int h_softstate;
/*
* default pipe handle
*/
/*
* pipe handle for ep1
*/
/*
* root hub descriptor
*/
struct usb_hub_descr h_hub_descr;
/*
* hotplug handling
*/
/*
* h_children_dips is a array for holding
* each child dip indexed by port
* h_usba_devices is the corresponding usba_device
*/
/* change reported by hub, limited to 31 ports */
/* waiting for reset completion callback */
/* track transitions of child on each port */
/* track reset state of each port */
/* track event registration of children */
/*
* Hotplug event statistics since hub was attached
*/
/* for minor node */
char *h_ancestry_str;
/* registration data */
/* for deathrow implementation */
/*
* for power budget support
* h_pwr_limit and h_pwr_left are expressed
* in 2mA units
*/
/*
* conf file override to power budget property
* if 1, power budget is disabled
*/
/* for HWA to cleanup child, NULL for normal hubs */
int (*h_cleanup_child)(dev_info_t *);
} hubd_t;
))
/*
* hubd hotplug thread argument data structure
*/
typedef struct hubd_hotplug_arg {
/*
* flag to indicate if a hotplug thread is started
* during hubd attach time, if true, it means the
* connected devices need to be enumerated regardless
* of the connect status change bit
*/
/*
* hubd reset thread argument data structure
*/
typedef struct hubd_reset_arg {
/* The port needs to be reset */
#define HUBD_SS_ISOPEN 0x0001
#define HUBD_ACK_ALL_CHANGES PORT_CHANGE_MASK
/* init state */
#define HUBD_LOCKS_DONE 0x0001
#define HUBD_HUBDI_REGISTERED 0x0002
#define HUBD_MINOR_NODE_CREATED 0x0004
#define HUBD_CHILDREN_CREATED 0x0008
#define HUBD_EVENTS_REGISTERED 0x0020
/*
* port flags : These are essentially extensions of Port Status Field Bits
* as in USB 2.0 spec Table 11-21 and #defined in hubd.h file. We make use
* of the unused bits (5-7,13-15) here to track states of the hub's child.
*/
#define HUBD_CHILD_ATTACHING 0x0020
#define HUBD_CHILD_DETACHING 0x0040
#define HUBD_CHILD_PWRLVL_CHNG 0x0080
#define HUBD_CHILD_RAISE_POWER 0x2000
#define HUBD_CHILD_ZAP 0x4000
/* Tracking events registered by children */
#define HUBD_CHILD_EVENT_DISCONNECT 0x01
#define HUBD_CHILD_EVENT_PRESUSPEND 0x02
#define USB_DEV_HUB_CHILD_PWRLVL 0x80
#define USB_DEV_HUB_STATE_RECOVER 0x81
/*
* hubd interrupt pipe management :
*
* Following are the states of the interrupt pipe
*
* IDLE:
* initial state and after closing of the interrupt pipe
*
* OPENING:
* Set when the pipe is being opened
*
* ACTIVE:
* Set when the pipe has been opened in hubd_open_intr_pipe. This is
* typically after a hub has got enumerated and initialized.
*
* CLOSING :
* Set when the pipe is closed by calling hubd_close_intr_pipe(). This is
* typically called on hub disconnect via hubd_cleanup.
*/
#define HUBD_INTR_PIPE_IDLE 0
#define HUBD_INTR_PIPE_OPENING 1
#define HUBD_INTR_PIPE_ACTIVE 2
#define HUBD_INTR_PIPE_STOPPED 3
#define HUBD_INTR_PIPE_CLOSING 4
/* request structure for putting dips on deathrow list */
typedef struct hubd_offline_req {
/*
* cfgadm state values
*/
#define HUBD_CFGADM_NORMAL 0 /* normal state */
/*
* Debug printing
* Masks
*/
#define DPRINT_MASK_ATTA 0x00000001
#define DPRINT_MASK_CBOPS 0x00000002
#define DPRINT_MASK_CALLBACK 0x00000004
#define DPRINT_MASK_PORT 0x00000008
#define DPRINT_MASK_HUB 0x00000010
#define DPRINT_MASK_HOTPLUG 0x00000020
#define DPRINT_MASK_EVENTS 0x00000040
#define DPRINT_MASK_PM 0x00000080
#define DPRINT_MASK_ALL 0xFFFFFFFF
/* status length used in getting hub status */
/* flag for hubd_start_polling */
#define HUBD_ALWAYS_START_POLLING 1
/* enumeration timeout */
/* power budget unit in mA */
#define USB_PWR_UNIT_LOAD 100
/* power values in 100mA units */
#define USB_HIGH_PWR_VALUE 5
#define USB_LOW_PWR_VALUE 1
/*
* According to section 9.6.3 of USB 2.0 spec,
* bMaxPower in the device configuration descriptor
* is expressed in 2mA units
*/
#define USB_CFG_DESCR_PWR_UNIT 2
/* variables shared with wire adapter class drivers */
extern uint_t hubd_errlevel;
extern uint_t hubd_errmask;
extern uint_t hubd_instance_debug;
/* common interfaces for hub and wire adapter class devices */
void hubd_get_ancestry_str(hubd_t *);
usba_device_t *);
dev_info_t *, usba_device_t *);
uint_t);
void hubd_schedule_cleanup(dev_info_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_USB_HUBDVAR_H */