17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 56c7181fcSsl * Common Development and Distribution License (the "License"). 66c7181fcSsl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22ff0e937bSRaymond Chen * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 25e5815e7aSJosef 'Jeff' Sipek /* 26e5815e7aSJosef 'Jeff' Sipek * Copyright 2014 Nexenta Systems, Inc. All rights reserved. 27*993e3fafSRobert Mustacchi * Copyright 2016 Joyent, Inc. 28e5815e7aSJosef 'Jeff' Sipek */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_HUBDVAR_H 317c478bd9Sstevel@tonic-gate #define _SYS_USB_HUBDVAR_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #include <sys/sunndi.h> 397c478bd9Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 407c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_types.h> 417c478bd9Sstevel@tonic-gate #include <sys/callb.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * HUB USB device state management : 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * CHILD PWRLVL---1>--------+ 477c478bd9Sstevel@tonic-gate * ^ | 487c478bd9Sstevel@tonic-gate * 8 | 497c478bd9Sstevel@tonic-gate * | | 507c478bd9Sstevel@tonic-gate * 9 | 517c478bd9Sstevel@tonic-gate * v | 527c478bd9Sstevel@tonic-gate * PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED 537c478bd9Sstevel@tonic-gate * | | ^ | | 547c478bd9Sstevel@tonic-gate * | | 10 | | 557c478bd9Sstevel@tonic-gate * | | | | | 567c478bd9Sstevel@tonic-gate * | | RECOVER-<2-------+ | 577c478bd9Sstevel@tonic-gate * | | ^ | 587c478bd9Sstevel@tonic-gate * | 5 6 | 597c478bd9Sstevel@tonic-gate * | | | | 607c478bd9Sstevel@tonic-gate * | v | | 617c478bd9Sstevel@tonic-gate * +----5>----------SUSPENDED----<5----7>----+ 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate * 1 = Device Unplug 647c478bd9Sstevel@tonic-gate * 2 = Original Device reconnected and after hub driver restores its own 657c478bd9Sstevel@tonic-gate * device state. 667c478bd9Sstevel@tonic-gate * 3 = Device idles for time T & transitions to low power state 677c478bd9Sstevel@tonic-gate * 4 = Remote wakeup by device OR Application kicking off IO to device 687c478bd9Sstevel@tonic-gate * 5 = Notification to save state prior to DDI_SUSPEND 697c478bd9Sstevel@tonic-gate * 6 = Notification to restore state after DDI_RESUME with correct device 707c478bd9Sstevel@tonic-gate * and after hub driver restores its own device state. 717c478bd9Sstevel@tonic-gate * 7 = Notification to restore state after DDI_RESUME with device 727c478bd9Sstevel@tonic-gate * disconnected or a wrong device 737c478bd9Sstevel@tonic-gate * 8 = Hub detect child doing remote wakeup and request the PM 747c478bd9Sstevel@tonic-gate * framework to bring it to full power 757c478bd9Sstevel@tonic-gate * 9 = PM framework has compeleted call power entry point of the child 767c478bd9Sstevel@tonic-gate * and bus ctls of hub 777c478bd9Sstevel@tonic-gate * 10 = Restoring states of its children i.e. set addrs & config. 787c478bd9Sstevel@tonic-gate * 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate #define HUBD_INITIAL_SOFT_SPACE 4 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate typedef struct hub_power_struct { 847c478bd9Sstevel@tonic-gate void *hubp_hubd; /* points back to hubd_t */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate uint8_t hubp_wakeup_enabled; /* remote wakeup enabled? */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* this is the bit mask of the power states that device has */ 897c478bd9Sstevel@tonic-gate uint8_t hubp_pwr_states; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate int hubp_busy_pm; /* device busy accounting */ 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* wakeup and power transition capabilities of an interface */ 947c478bd9Sstevel@tonic-gate uint8_t hubp_pm_capabilities; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate uint8_t hubp_current_power; /* current power level */ 977c478bd9Sstevel@tonic-gate 98e5815e7aSJosef 'Jeff' Sipek hrtime_t hubp_time_at_full_power; /* timestamp 0->3 */ 997c478bd9Sstevel@tonic-gate 100e5815e7aSJosef 'Jeff' Sipek hrtime_t hubp_min_pm_threshold; /* in nanoseconds */ 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* power state of all children are tracked here */ 1037c478bd9Sstevel@tonic-gate uint8_t *hubp_child_pwrstate; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* pm-components properties are stored here */ 1067c478bd9Sstevel@tonic-gate char *hubp_pmcomp[5]; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate usba_cfg_pwr_descr_t hubp_confpwr_descr; /* config pwr descr */ 1097c478bd9Sstevel@tonic-gate } hub_power_t; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* warlock directives, stable data */ 1127c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_hubd)) 1137c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_wakeup_enabled)) 1147c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pwr_states)) 1157c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_time_at_full_power)) 1167c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_min_pm_threshold)) 1177c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pm_capabilities)) 1187c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pmcomp)) 1197c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_confpwr_descr)) 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #define HUBD_APID_NAMELEN 32 /* max len in cfgadm display */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * hubd cpr data structure used for callback before kernel threads are 1267c478bd9Sstevel@tonic-gate * suspended 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate typedef struct hubd_cpr { 1297c478bd9Sstevel@tonic-gate callb_cpr_t cpr; /* for cpr related info */ 1307c478bd9Sstevel@tonic-gate struct hubd *statep; /* ohci soft state struct */ 1317c478bd9Sstevel@tonic-gate kmutex_t lockp; 1327c478bd9Sstevel@tonic-gate } hubd_cpr_t; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd_cpr_t::cpr)) 1357c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd_cpr_t::statep)) 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * soft state information for this hubd 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate typedef struct hubd { 1427c478bd9Sstevel@tonic-gate int h_instance; 1437c478bd9Sstevel@tonic-gate uint_t h_init_state; 1447c478bd9Sstevel@tonic-gate uint_t h_dev_state; 1457c478bd9Sstevel@tonic-gate int8_t h_bus_ctls; 1467c478bd9Sstevel@tonic-gate int8_t h_bus_pwr; 1477c478bd9Sstevel@tonic-gate hub_power_t *h_hubpm; /* pointer to power struct */ 1487c478bd9Sstevel@tonic-gate dev_info_t *h_dip; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate /* 1517c478bd9Sstevel@tonic-gate * mutex to protect softstate and hw regs 1527c478bd9Sstevel@tonic-gate */ 1537c478bd9Sstevel@tonic-gate kmutex_t h_mutex; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* 1567c478bd9Sstevel@tonic-gate * save the usba_device pointer 1577c478bd9Sstevel@tonic-gate */ 1587c478bd9Sstevel@tonic-gate usba_device_t *h_usba_device; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate int h_softstate; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* 1637c478bd9Sstevel@tonic-gate * default pipe handle 1647c478bd9Sstevel@tonic-gate */ 1657c478bd9Sstevel@tonic-gate usb_pipe_handle_t h_default_pipe; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * pipe handle for ep1 1697c478bd9Sstevel@tonic-gate */ 1707c478bd9Sstevel@tonic-gate usb_pipe_handle_t h_ep1_ph; 171*993e3fafSRobert Mustacchi usb_ep_xdescr_t h_ep1_xdescr; 1727c478bd9Sstevel@tonic-gate usb_pipe_policy_t h_pipe_policy; 1737c478bd9Sstevel@tonic-gate uint_t h_intr_pipe_state; 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate /* 176*993e3fafSRobert Mustacchi * hub characteristics (normalized across various USB versions) from the 177*993e3fafSRobert Mustacchi * Hub class description. 1787c478bd9Sstevel@tonic-gate */ 179*993e3fafSRobert Mustacchi uint8_t h_nports; /* from bNbrPorts */ 180*993e3fafSRobert Mustacchi uint16_t h_hub_chars; /* from wHubCharacteristics */ 181*993e3fafSRobert Mustacchi uint_t h_power_good; /* from bPwrOn2PwrGood */ 182*993e3fafSRobert Mustacchi uint_t h_current; /* from bHubContrCurrent */ 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* 1857c478bd9Sstevel@tonic-gate * hotplug handling 1867c478bd9Sstevel@tonic-gate */ 1877c478bd9Sstevel@tonic-gate uint_t h_hotplug_thread; 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate /* 1907c478bd9Sstevel@tonic-gate * h_children_dips is a array for holding 1917c478bd9Sstevel@tonic-gate * each child dip indexed by port 1927c478bd9Sstevel@tonic-gate * h_usba_devices is the corresponding usba_device 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate dev_info_t **h_children_dips; 1957c478bd9Sstevel@tonic-gate size_t h_cd_list_length; 1967c478bd9Sstevel@tonic-gate usba_device_t **h_usba_devices; 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* change reported by hub, limited to 31 ports */ 1997c478bd9Sstevel@tonic-gate usb_port_mask_t h_port_change; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* waiting for reset completion callback */ 2027c478bd9Sstevel@tonic-gate usb_port_mask_t h_port_reset_wait; 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* track transitions of child on each port */ 2057c478bd9Sstevel@tonic-gate uint16_t h_port_state[MAX_PORTS + 1]; 2067c478bd9Sstevel@tonic-gate 207ffcd51f3Slg /* track reset state of each port */ 208ffcd51f3Slg boolean_t h_reset_port[MAX_PORTS + 1]; 209ffcd51f3Slg 2107c478bd9Sstevel@tonic-gate /* track event registration of children */ 2117c478bd9Sstevel@tonic-gate uint8_t h_child_events[MAX_PORTS + 1]; 2127c478bd9Sstevel@tonic-gate 213*993e3fafSRobert Mustacchi /* track the raw port state for debugging purposes */ 214*993e3fafSRobert Mustacchi uint16_t h_port_raw[MAX_PORTS + 1]; 215*993e3fafSRobert Mustacchi 2167c478bd9Sstevel@tonic-gate kcondvar_t h_cv_reset_port; 217ffcd51f3Slg kcondvar_t h_cv_hotplug_dev; 2187c478bd9Sstevel@tonic-gate uint_t h_intr_completion_reason; 2197c478bd9Sstevel@tonic-gate usb_log_handle_t h_log_handle; /* for logging msgs */ 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate ndi_event_hdl_t h_ndi_event_hdl; 2227c478bd9Sstevel@tonic-gate hubd_cpr_t *h_cpr_cb; 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* 2257c478bd9Sstevel@tonic-gate * Hotplug event statistics since hub was attached 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate ulong_t h_total_hotplug_success; 2287c478bd9Sstevel@tonic-gate ulong_t h_total_hotplug_failure; 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate /* for minor node */ 2317c478bd9Sstevel@tonic-gate char *h_ancestry_str; 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate /* registration data */ 2347c478bd9Sstevel@tonic-gate usb_client_dev_data_t *h_dev_data; 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate /* for deathrow implementation */ 2377c478bd9Sstevel@tonic-gate boolean_t h_cleanup_enabled; 2387c478bd9Sstevel@tonic-gate boolean_t h_cleanup_needed; 2397c478bd9Sstevel@tonic-gate boolean_t h_cleanup_active; 24035f36846Ssl 24135f36846Ssl /* 24235f36846Ssl * for power budget support 24335f36846Ssl * h_pwr_limit and h_pwr_left are expressed 24435f36846Ssl * in 2mA units 24535f36846Ssl */ 24635f36846Ssl boolean_t h_local_pwr_capable; 24735f36846Ssl boolean_t h_local_pwr_on; 24835f36846Ssl uint16_t h_pwr_limit; /* per port pwr limit */ 24935f36846Ssl int16_t h_pwr_left; /* limit on the whole hub */ 25035f36846Ssl 25135f36846Ssl /* 25235f36846Ssl * conf file override to power budget property 25335f36846Ssl * if 1, power budget is disabled 25435f36846Ssl */ 25535f36846Ssl boolean_t h_ignore_pwr_budget; 256ff0e937bSRaymond Chen 257ff0e937bSRaymond Chen /* for HWA to cleanup child, NULL for normal hubs */ 258ff0e937bSRaymond Chen int (*h_cleanup_child)(dev_info_t *); 2597c478bd9Sstevel@tonic-gate } hubd_t; 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(hubd::h_mutex, hubd)) 2627c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(hubd::h_mutex, hub_power_t)) 2637c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd::h_default_pipe 2647c478bd9Sstevel@tonic-gate hubd::h_usba_device 2657c478bd9Sstevel@tonic-gate hubd::h_dev_data 2667c478bd9Sstevel@tonic-gate hubd::h_ndi_event_hdl 2677c478bd9Sstevel@tonic-gate hubd::h_cpr_cb 2687c478bd9Sstevel@tonic-gate hubd::h_log_handle 2697c478bd9Sstevel@tonic-gate hubd::h_ep1_ph 2707c478bd9Sstevel@tonic-gate hubd::h_instance 2717c478bd9Sstevel@tonic-gate hubd::h_hubpm 2727c478bd9Sstevel@tonic-gate hubd::h_dip 27335f36846Ssl hubd::h_ignore_pwr_budget 274489b7c4aSRaymond Chen hubd::h_hub_descr 275489b7c4aSRaymond Chen hubd::h_cleanup_child 2767c478bd9Sstevel@tonic-gate )) 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", usb_ep_descr)) 2797c478bd9Sstevel@tonic-gate 2806c7181fcSsl /* 2816c7181fcSsl * hubd hotplug thread argument data structure 2826c7181fcSsl */ 2836c7181fcSsl typedef struct hubd_hotplug_arg { 2846c7181fcSsl hubd_t *hubd; 2856c7181fcSsl 2866c7181fcSsl /* 2876c7181fcSsl * flag to indicate if a hotplug thread is started 2886c7181fcSsl * during hubd attach time, if true, it means the 2896c7181fcSsl * connected devices need to be enumerated regardless 2906c7181fcSsl * of the connect status change bit 2916c7181fcSsl */ 2926c7181fcSsl boolean_t hotplug_during_attach; 2936c7181fcSsl } hubd_hotplug_arg_t; 2946c7181fcSsl 295ffcd51f3Slg /* 296ffcd51f3Slg * hubd reset thread argument data structure 297ffcd51f3Slg */ 298ffcd51f3Slg typedef struct hubd_reset_arg { 299ffcd51f3Slg hubd_t *hubd; 300ffcd51f3Slg /* The port needs to be reset */ 301ffcd51f3Slg uint16_t reset_port; 302ffcd51f3Slg } hubd_reset_arg_t; 303ffcd51f3Slg 3046c7181fcSsl _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_hotplug_arg)) 305ffcd51f3Slg _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_reset_arg)) 3066c7181fcSsl 3077c478bd9Sstevel@tonic-gate #define HUBD_UNIT(dev) (getminor((dev))) 3087c478bd9Sstevel@tonic-gate #define HUBD_MUTEX(hubd) (&((hubd)->h_mutex)) 3097c478bd9Sstevel@tonic-gate #define HUBD_SS_ISOPEN 0x0001 3107c478bd9Sstevel@tonic-gate #define HUBD_ACK_ALL_CHANGES PORT_CHANGE_MASK 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate /* init state */ 3137c478bd9Sstevel@tonic-gate #define HUBD_LOCKS_DONE 0x0001 3147c478bd9Sstevel@tonic-gate #define HUBD_HUBDI_REGISTERED 0x0002 3157c478bd9Sstevel@tonic-gate #define HUBD_MINOR_NODE_CREATED 0x0004 31635f36846Ssl #define HUBD_CHILDREN_CREATED 0x0008 3177c478bd9Sstevel@tonic-gate #define HUBD_EVENTS_REGISTERED 0x0020 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate /* 3207c478bd9Sstevel@tonic-gate * port flags : These are essentially extensions of Port Status Field Bits 3217c478bd9Sstevel@tonic-gate * as in USB 2.0 spec Table 11-21 and #defined in hubd.h file. We make use 3227c478bd9Sstevel@tonic-gate * of the unused bits (5-7,13-15) here to track states of the hub's child. 3237c478bd9Sstevel@tonic-gate */ 3247c478bd9Sstevel@tonic-gate #define HUBD_CHILD_ATTACHING 0x0020 3257c478bd9Sstevel@tonic-gate #define HUBD_CHILD_DETACHING 0x0040 3267c478bd9Sstevel@tonic-gate #define HUBD_CHILD_PWRLVL_CHNG 0x0080 3277c478bd9Sstevel@tonic-gate #define HUBD_CHILD_RAISE_POWER 0x2000 3287c478bd9Sstevel@tonic-gate #define HUBD_CHILD_ZAP 0x4000 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate /* Tracking events registered by children */ 3317c478bd9Sstevel@tonic-gate #define HUBD_CHILD_EVENT_DISCONNECT 0x01 3327c478bd9Sstevel@tonic-gate #define HUBD_CHILD_EVENT_PRESUSPEND 0x02 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate /* This dev state is used exclusively by hub to change port suspend/resume */ 3357c478bd9Sstevel@tonic-gate #define USB_DEV_HUB_CHILD_PWRLVL 0x80 3367c478bd9Sstevel@tonic-gate #define USB_DEV_HUB_STATE_RECOVER 0x81 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* 3397c478bd9Sstevel@tonic-gate * hubd interrupt pipe management : 3407c478bd9Sstevel@tonic-gate * 3417c478bd9Sstevel@tonic-gate * Following are the states of the interrupt pipe 3427c478bd9Sstevel@tonic-gate * 3437c478bd9Sstevel@tonic-gate * IDLE: 3447c478bd9Sstevel@tonic-gate * initial state and after closing of the interrupt pipe 3457c478bd9Sstevel@tonic-gate * 3467c478bd9Sstevel@tonic-gate * OPENING: 3477c478bd9Sstevel@tonic-gate * Set when the pipe is being opened 3487c478bd9Sstevel@tonic-gate * 3497c478bd9Sstevel@tonic-gate * ACTIVE: 3507c478bd9Sstevel@tonic-gate * Set when the pipe has been opened in hubd_open_intr_pipe. This is 3517c478bd9Sstevel@tonic-gate * typically after a hub has got enumerated and initialized. 3527c478bd9Sstevel@tonic-gate * 3537c478bd9Sstevel@tonic-gate * CLOSING : 3547c478bd9Sstevel@tonic-gate * Set when the pipe is closed by calling hubd_close_intr_pipe(). This is 3557c478bd9Sstevel@tonic-gate * typically called on hub disconnect via hubd_cleanup. 3567c478bd9Sstevel@tonic-gate */ 3577c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_IDLE 0 3587c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_OPENING 1 3597c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_ACTIVE 2 3607c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_STOPPED 3 3617c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_CLOSING 4 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate /* request structure for putting dips on deathrow list */ 3657c478bd9Sstevel@tonic-gate typedef struct hubd_offline_req { 3667c478bd9Sstevel@tonic-gate usba_list_entry_t or_queue; /* DO NOT MOVE! */ 3677c478bd9Sstevel@tonic-gate hubd_t *or_hubd; 3687c478bd9Sstevel@tonic-gate usb_port_t or_port; 3697c478bd9Sstevel@tonic-gate dev_info_t *or_dip; 3707c478bd9Sstevel@tonic-gate uint_t or_flag; 3717c478bd9Sstevel@tonic-gate } hubd_offline_req_t; 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_offline_req)) 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate /* 3777c478bd9Sstevel@tonic-gate * cfgadm state values 3787c478bd9Sstevel@tonic-gate */ 3797c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_NORMAL 0 /* normal state */ 3807c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_DISCONNECTED 1 /* logically disconnected */ 3817c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_UNCONFIGURED 2 /* port is unconfigured */ 3827c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_EMPTY 3 /* port is empty */ 3837c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_STILL_REFERENCED 4 /* ndi_devi_offline failed */ 3847c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_CONFIGURED 5 /* port is configured */ 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* 3877c478bd9Sstevel@tonic-gate * Debug printing 3887c478bd9Sstevel@tonic-gate * Masks 3897c478bd9Sstevel@tonic-gate */ 3907c478bd9Sstevel@tonic-gate #define DPRINT_MASK_ATTA 0x00000001 3917c478bd9Sstevel@tonic-gate #define DPRINT_MASK_CBOPS 0x00000002 3927c478bd9Sstevel@tonic-gate #define DPRINT_MASK_CALLBACK 0x00000004 3937c478bd9Sstevel@tonic-gate #define DPRINT_MASK_PORT 0x00000008 3947c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HUB 0x00000010 3957c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HOTPLUG 0x00000020 3967c478bd9Sstevel@tonic-gate #define DPRINT_MASK_EVENTS 0x00000040 3977c478bd9Sstevel@tonic-gate #define DPRINT_MASK_PM 0x00000080 3987c478bd9Sstevel@tonic-gate #define DPRINT_MASK_ALL 0xFFFFFFFF 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate /* status length used in getting hub status */ 4027c478bd9Sstevel@tonic-gate #define GET_STATUS_LENGTH 0x04 /* length of get status req */ 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate /* flag for hubd_start_polling */ 4057c478bd9Sstevel@tonic-gate #define HUBD_ALWAYS_START_POLLING 1 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate /* enumeration timeout */ 4087c478bd9Sstevel@tonic-gate #define HUBDI_ENUM_TIMEOUT 1 /* 1 second */ 4097c478bd9Sstevel@tonic-gate 41035f36846Ssl /* power budget unit in mA */ 41135f36846Ssl #define USB_PWR_UNIT_LOAD 100 41235f36846Ssl 41335f36846Ssl /* power values in 100mA units */ 41435f36846Ssl #define USB_HIGH_PWR_VALUE 5 41535f36846Ssl #define USB_LOW_PWR_VALUE 1 41635f36846Ssl 41735f36846Ssl /* 41835f36846Ssl * According to section 9.6.3 of USB 2.0 spec, 41935f36846Ssl * bMaxPower in the device configuration descriptor 42035f36846Ssl * is expressed in 2mA units 42135f36846Ssl */ 42235f36846Ssl #define USB_CFG_DESCR_PWR_UNIT 2 42335f36846Ssl 424*993e3fafSRobert Mustacchi /* 425*993e3fafSRobert Mustacchi * USB 3.x devices have the notion of a 'route' which describes the series of 426*993e3fafSRobert Mustacchi * hubs which must be passed through to reach a given device. The route string 427*993e3fafSRobert Mustacchi * has support for a fixed number of nested hubs. Each USB 3.x hub has to be 428*993e3fafSRobert Mustacchi * told what its depth in the route string is, effectively it's 4-bit index into 429*993e3fafSRobert Mustacchi * the route string. The maximum number of nested hubs, in other words a hub's 430*993e3fafSRobert Mustacchi * depth, is defined in USB 3.1 / 10.16.2.9. 431*993e3fafSRobert Mustacchi */ 432*993e3fafSRobert Mustacchi #define HUBD_SS_MAX_DEPTH 5 433*993e3fafSRobert Mustacchi 434ff0e937bSRaymond Chen /* variables shared with wire adapter class drivers */ 435ff0e937bSRaymond Chen extern uint_t hubd_errlevel; 436ff0e937bSRaymond Chen extern uint_t hubd_errmask; 437ff0e937bSRaymond Chen extern uint_t hubd_instance_debug; 438ff0e937bSRaymond Chen 439ff0e937bSRaymond Chen /* common interfaces for hub and wire adapter class devices */ 440ff0e937bSRaymond Chen hubd_t *hubd_get_soft_state(dev_info_t *); 441ff0e937bSRaymond Chen void hubd_get_ancestry_str(hubd_t *); 442ff0e937bSRaymond Chen int hubd_get_all_device_config_cloud(hubd_t *, dev_info_t *, 443ff0e937bSRaymond Chen usba_device_t *); 444ff0e937bSRaymond Chen int hubd_select_device_configuration(hubd_t *, usb_port_t, 445ff0e937bSRaymond Chen dev_info_t *, usba_device_t *); 446ff0e937bSRaymond Chen dev_info_t *hubd_ready_device(hubd_t *, dev_info_t *, usba_device_t *, 447ff0e937bSRaymond Chen uint_t); 448ff0e937bSRaymond Chen void hubd_schedule_cleanup(dev_info_t *); 449ff0e937bSRaymond Chen 4507c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4517c478bd9Sstevel@tonic-gate } 4527c478bd9Sstevel@tonic-gate #endif 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_HUBDVAR_H */ 455