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 56c7181fcSsl147100 * Common Development and Distribution License (the "License"). 66c7181fcSsl147100 * 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 */ 25*e5815e7aSJosef 'Jeff' Sipek /* 26*e5815e7aSJosef 'Jeff' Sipek * Copyright 2014 Nexenta Systems, Inc. All rights reserved. 27*e5815e7aSJosef 'Jeff' Sipek */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_HUBDVAR_H 307c478bd9Sstevel@tonic-gate #define _SYS_USB_HUBDVAR_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/sunndi.h> 387c478bd9Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 397c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_types.h> 407c478bd9Sstevel@tonic-gate #include <sys/callb.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * HUB USB device state management : 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * CHILD PWRLVL---1>--------+ 467c478bd9Sstevel@tonic-gate * ^ | 477c478bd9Sstevel@tonic-gate * 8 | 487c478bd9Sstevel@tonic-gate * | | 497c478bd9Sstevel@tonic-gate * 9 | 507c478bd9Sstevel@tonic-gate * v | 517c478bd9Sstevel@tonic-gate * PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED 527c478bd9Sstevel@tonic-gate * | | ^ | | 537c478bd9Sstevel@tonic-gate * | | 10 | | 547c478bd9Sstevel@tonic-gate * | | | | | 557c478bd9Sstevel@tonic-gate * | | RECOVER-<2-------+ | 567c478bd9Sstevel@tonic-gate * | | ^ | 577c478bd9Sstevel@tonic-gate * | 5 6 | 587c478bd9Sstevel@tonic-gate * | | | | 597c478bd9Sstevel@tonic-gate * | v | | 607c478bd9Sstevel@tonic-gate * +----5>----------SUSPENDED----<5----7>----+ 617c478bd9Sstevel@tonic-gate * 627c478bd9Sstevel@tonic-gate * 1 = Device Unplug 637c478bd9Sstevel@tonic-gate * 2 = Original Device reconnected and after hub driver restores its own 647c478bd9Sstevel@tonic-gate * device state. 657c478bd9Sstevel@tonic-gate * 3 = Device idles for time T & transitions to low power state 667c478bd9Sstevel@tonic-gate * 4 = Remote wakeup by device OR Application kicking off IO to device 677c478bd9Sstevel@tonic-gate * 5 = Notification to save state prior to DDI_SUSPEND 687c478bd9Sstevel@tonic-gate * 6 = Notification to restore state after DDI_RESUME with correct device 697c478bd9Sstevel@tonic-gate * and after hub driver restores its own device state. 707c478bd9Sstevel@tonic-gate * 7 = Notification to restore state after DDI_RESUME with device 717c478bd9Sstevel@tonic-gate * disconnected or a wrong device 727c478bd9Sstevel@tonic-gate * 8 = Hub detect child doing remote wakeup and request the PM 737c478bd9Sstevel@tonic-gate * framework to bring it to full power 747c478bd9Sstevel@tonic-gate * 9 = PM framework has compeleted call power entry point of the child 757c478bd9Sstevel@tonic-gate * and bus ctls of hub 767c478bd9Sstevel@tonic-gate * 10 = Restoring states of its children i.e. set addrs & config. 777c478bd9Sstevel@tonic-gate * 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define HUBD_INITIAL_SOFT_SPACE 4 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate typedef struct hub_power_struct { 837c478bd9Sstevel@tonic-gate void *hubp_hubd; /* points back to hubd_t */ 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate uint8_t hubp_wakeup_enabled; /* remote wakeup enabled? */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* this is the bit mask of the power states that device has */ 887c478bd9Sstevel@tonic-gate uint8_t hubp_pwr_states; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate int hubp_busy_pm; /* device busy accounting */ 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* wakeup and power transition capabilities of an interface */ 937c478bd9Sstevel@tonic-gate uint8_t hubp_pm_capabilities; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate uint8_t hubp_current_power; /* current power level */ 967c478bd9Sstevel@tonic-gate 97*e5815e7aSJosef 'Jeff' Sipek hrtime_t hubp_time_at_full_power; /* timestamp 0->3 */ 987c478bd9Sstevel@tonic-gate 99*e5815e7aSJosef 'Jeff' Sipek hrtime_t hubp_min_pm_threshold; /* in nanoseconds */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* power state of all children are tracked here */ 1027c478bd9Sstevel@tonic-gate uint8_t *hubp_child_pwrstate; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* pm-components properties are stored here */ 1057c478bd9Sstevel@tonic-gate char *hubp_pmcomp[5]; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate usba_cfg_pwr_descr_t hubp_confpwr_descr; /* config pwr descr */ 1087c478bd9Sstevel@tonic-gate } hub_power_t; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* warlock directives, stable data */ 1117c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_hubd)) 1127c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_wakeup_enabled)) 1137c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pwr_states)) 1147c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_time_at_full_power)) 1157c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_min_pm_threshold)) 1167c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pm_capabilities)) 1177c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pmcomp)) 1187c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_confpwr_descr)) 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define HUBD_APID_NAMELEN 32 /* max len in cfgadm display */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * hubd cpr data structure used for callback before kernel threads are 1257c478bd9Sstevel@tonic-gate * suspended 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate typedef struct hubd_cpr { 1287c478bd9Sstevel@tonic-gate callb_cpr_t cpr; /* for cpr related info */ 1297c478bd9Sstevel@tonic-gate struct hubd *statep; /* ohci soft state struct */ 1307c478bd9Sstevel@tonic-gate kmutex_t lockp; 1317c478bd9Sstevel@tonic-gate } hubd_cpr_t; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd_cpr_t::cpr)) 1347c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd_cpr_t::statep)) 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * soft state information for this hubd 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate typedef struct hubd { 1417c478bd9Sstevel@tonic-gate int h_instance; 1427c478bd9Sstevel@tonic-gate uint_t h_init_state; 1437c478bd9Sstevel@tonic-gate uint_t h_dev_state; 1447c478bd9Sstevel@tonic-gate int8_t h_bus_ctls; 1457c478bd9Sstevel@tonic-gate int8_t h_bus_pwr; 1467c478bd9Sstevel@tonic-gate hub_power_t *h_hubpm; /* pointer to power struct */ 1477c478bd9Sstevel@tonic-gate dev_info_t *h_dip; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * mutex to protect softstate and hw regs 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate kmutex_t h_mutex; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * save the usba_device pointer 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate usba_device_t *h_usba_device; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate int h_softstate; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * default pipe handle 1637c478bd9Sstevel@tonic-gate */ 1647c478bd9Sstevel@tonic-gate usb_pipe_handle_t h_default_pipe; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate /* 1677c478bd9Sstevel@tonic-gate * pipe handle for ep1 1687c478bd9Sstevel@tonic-gate */ 1697c478bd9Sstevel@tonic-gate usb_pipe_handle_t h_ep1_ph; 1707c478bd9Sstevel@tonic-gate usb_ep_descr_t h_ep1_descr; 1717c478bd9Sstevel@tonic-gate usb_pipe_policy_t h_pipe_policy; 1727c478bd9Sstevel@tonic-gate uint_t h_intr_pipe_state; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* 1757c478bd9Sstevel@tonic-gate * root hub descriptor 1767c478bd9Sstevel@tonic-gate */ 1777c478bd9Sstevel@tonic-gate struct usb_hub_descr h_hub_descr; 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* 1807c478bd9Sstevel@tonic-gate * hotplug handling 1817c478bd9Sstevel@tonic-gate */ 1827c478bd9Sstevel@tonic-gate uint_t h_hotplug_thread; 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* 1857c478bd9Sstevel@tonic-gate * h_children_dips is a array for holding 1867c478bd9Sstevel@tonic-gate * each child dip indexed by port 1877c478bd9Sstevel@tonic-gate * h_usba_devices is the corresponding usba_device 1887c478bd9Sstevel@tonic-gate */ 1897c478bd9Sstevel@tonic-gate dev_info_t **h_children_dips; 1907c478bd9Sstevel@tonic-gate size_t h_cd_list_length; 1917c478bd9Sstevel@tonic-gate usba_device_t **h_usba_devices; 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate /* change reported by hub, limited to 31 ports */ 1947c478bd9Sstevel@tonic-gate usb_port_mask_t h_port_change; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* waiting for reset completion callback */ 1977c478bd9Sstevel@tonic-gate usb_port_mask_t h_port_reset_wait; 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate /* track transitions of child on each port */ 2007c478bd9Sstevel@tonic-gate uint16_t h_port_state[MAX_PORTS + 1]; 2017c478bd9Sstevel@tonic-gate 202ffcd51f3Slg150142 /* track reset state of each port */ 203ffcd51f3Slg150142 boolean_t h_reset_port[MAX_PORTS + 1]; 204ffcd51f3Slg150142 2057c478bd9Sstevel@tonic-gate /* track event registration of children */ 2067c478bd9Sstevel@tonic-gate uint8_t h_child_events[MAX_PORTS + 1]; 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate kcondvar_t h_cv_reset_port; 209ffcd51f3Slg150142 kcondvar_t h_cv_hotplug_dev; 2107c478bd9Sstevel@tonic-gate uint_t h_intr_completion_reason; 2117c478bd9Sstevel@tonic-gate usb_log_handle_t h_log_handle; /* for logging msgs */ 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate ndi_event_hdl_t h_ndi_event_hdl; 2147c478bd9Sstevel@tonic-gate hubd_cpr_t *h_cpr_cb; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate /* 2177c478bd9Sstevel@tonic-gate * Hotplug event statistics since hub was attached 2187c478bd9Sstevel@tonic-gate */ 2197c478bd9Sstevel@tonic-gate ulong_t h_total_hotplug_success; 2207c478bd9Sstevel@tonic-gate ulong_t h_total_hotplug_failure; 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate /* for minor node */ 2237c478bd9Sstevel@tonic-gate char *h_ancestry_str; 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate /* registration data */ 2267c478bd9Sstevel@tonic-gate usb_client_dev_data_t *h_dev_data; 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate /* for deathrow implementation */ 2297c478bd9Sstevel@tonic-gate boolean_t h_cleanup_enabled; 2307c478bd9Sstevel@tonic-gate boolean_t h_cleanup_needed; 2317c478bd9Sstevel@tonic-gate boolean_t h_cleanup_active; 23235f36846Ssl147100 23335f36846Ssl147100 /* 23435f36846Ssl147100 * for power budget support 23535f36846Ssl147100 * h_pwr_limit and h_pwr_left are expressed 23635f36846Ssl147100 * in 2mA units 23735f36846Ssl147100 */ 23835f36846Ssl147100 boolean_t h_local_pwr_capable; 23935f36846Ssl147100 boolean_t h_local_pwr_on; 24035f36846Ssl147100 uint16_t h_pwr_limit; /* per port pwr limit */ 24135f36846Ssl147100 int16_t h_pwr_left; /* limit on the whole hub */ 24235f36846Ssl147100 24335f36846Ssl147100 /* 24435f36846Ssl147100 * conf file override to power budget property 24535f36846Ssl147100 * if 1, power budget is disabled 24635f36846Ssl147100 */ 24735f36846Ssl147100 boolean_t h_ignore_pwr_budget; 248ff0e937bSRaymond Chen 249ff0e937bSRaymond Chen /* for HWA to cleanup child, NULL for normal hubs */ 250ff0e937bSRaymond Chen int (*h_cleanup_child)(dev_info_t *); 2517c478bd9Sstevel@tonic-gate } hubd_t; 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(hubd::h_mutex, hubd)) 2547c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(hubd::h_mutex, hub_power_t)) 2557c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd::h_default_pipe 2567c478bd9Sstevel@tonic-gate hubd::h_usba_device 2577c478bd9Sstevel@tonic-gate hubd::h_dev_data 2587c478bd9Sstevel@tonic-gate hubd::h_ndi_event_hdl 2597c478bd9Sstevel@tonic-gate hubd::h_cpr_cb 2607c478bd9Sstevel@tonic-gate hubd::h_log_handle 2617c478bd9Sstevel@tonic-gate hubd::h_ep1_ph 2627c478bd9Sstevel@tonic-gate hubd::h_instance 2637c478bd9Sstevel@tonic-gate hubd::h_hubpm 2647c478bd9Sstevel@tonic-gate hubd::h_dip 26535f36846Ssl147100 hubd::h_ignore_pwr_budget 266489b7c4aSRaymond Chen hubd::h_hub_descr 267489b7c4aSRaymond Chen hubd::h_cleanup_child 2687c478bd9Sstevel@tonic-gate )) 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", usb_ep_descr)) 2717c478bd9Sstevel@tonic-gate 2726c7181fcSsl147100 /* 2736c7181fcSsl147100 * hubd hotplug thread argument data structure 2746c7181fcSsl147100 */ 2756c7181fcSsl147100 typedef struct hubd_hotplug_arg { 2766c7181fcSsl147100 hubd_t *hubd; 2776c7181fcSsl147100 2786c7181fcSsl147100 /* 2796c7181fcSsl147100 * flag to indicate if a hotplug thread is started 2806c7181fcSsl147100 * during hubd attach time, if true, it means the 2816c7181fcSsl147100 * connected devices need to be enumerated regardless 2826c7181fcSsl147100 * of the connect status change bit 2836c7181fcSsl147100 */ 2846c7181fcSsl147100 boolean_t hotplug_during_attach; 2856c7181fcSsl147100 } hubd_hotplug_arg_t; 2866c7181fcSsl147100 287ffcd51f3Slg150142 /* 288ffcd51f3Slg150142 * hubd reset thread argument data structure 289ffcd51f3Slg150142 */ 290ffcd51f3Slg150142 typedef struct hubd_reset_arg { 291ffcd51f3Slg150142 hubd_t *hubd; 292ffcd51f3Slg150142 /* The port needs to be reset */ 293ffcd51f3Slg150142 uint16_t reset_port; 294ffcd51f3Slg150142 } hubd_reset_arg_t; 295ffcd51f3Slg150142 2966c7181fcSsl147100 _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_hotplug_arg)) 297ffcd51f3Slg150142 _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_reset_arg)) 2986c7181fcSsl147100 2997c478bd9Sstevel@tonic-gate #define HUBD_UNIT(dev) (getminor((dev))) 3007c478bd9Sstevel@tonic-gate #define HUBD_MUTEX(hubd) (&((hubd)->h_mutex)) 3017c478bd9Sstevel@tonic-gate #define HUBD_SS_ISOPEN 0x0001 3027c478bd9Sstevel@tonic-gate #define HUBD_ACK_ALL_CHANGES PORT_CHANGE_MASK 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate /* init state */ 3057c478bd9Sstevel@tonic-gate #define HUBD_LOCKS_DONE 0x0001 3067c478bd9Sstevel@tonic-gate #define HUBD_HUBDI_REGISTERED 0x0002 3077c478bd9Sstevel@tonic-gate #define HUBD_MINOR_NODE_CREATED 0x0004 30835f36846Ssl147100 #define HUBD_CHILDREN_CREATED 0x0008 3097c478bd9Sstevel@tonic-gate #define HUBD_EVENTS_REGISTERED 0x0020 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate /* 3127c478bd9Sstevel@tonic-gate * port flags : These are essentially extensions of Port Status Field Bits 3137c478bd9Sstevel@tonic-gate * as in USB 2.0 spec Table 11-21 and #defined in hubd.h file. We make use 3147c478bd9Sstevel@tonic-gate * of the unused bits (5-7,13-15) here to track states of the hub's child. 3157c478bd9Sstevel@tonic-gate */ 3167c478bd9Sstevel@tonic-gate #define HUBD_CHILD_ATTACHING 0x0020 3177c478bd9Sstevel@tonic-gate #define HUBD_CHILD_DETACHING 0x0040 3187c478bd9Sstevel@tonic-gate #define HUBD_CHILD_PWRLVL_CHNG 0x0080 3197c478bd9Sstevel@tonic-gate #define HUBD_CHILD_RAISE_POWER 0x2000 3207c478bd9Sstevel@tonic-gate #define HUBD_CHILD_ZAP 0x4000 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate /* Tracking events registered by children */ 3237c478bd9Sstevel@tonic-gate #define HUBD_CHILD_EVENT_DISCONNECT 0x01 3247c478bd9Sstevel@tonic-gate #define HUBD_CHILD_EVENT_PRESUSPEND 0x02 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* This dev state is used exclusively by hub to change port suspend/resume */ 3277c478bd9Sstevel@tonic-gate #define USB_DEV_HUB_CHILD_PWRLVL 0x80 3287c478bd9Sstevel@tonic-gate #define USB_DEV_HUB_STATE_RECOVER 0x81 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate /* 3317c478bd9Sstevel@tonic-gate * hubd interrupt pipe management : 3327c478bd9Sstevel@tonic-gate * 3337c478bd9Sstevel@tonic-gate * Following are the states of the interrupt pipe 3347c478bd9Sstevel@tonic-gate * 3357c478bd9Sstevel@tonic-gate * IDLE: 3367c478bd9Sstevel@tonic-gate * initial state and after closing of the interrupt pipe 3377c478bd9Sstevel@tonic-gate * 3387c478bd9Sstevel@tonic-gate * OPENING: 3397c478bd9Sstevel@tonic-gate * Set when the pipe is being opened 3407c478bd9Sstevel@tonic-gate * 3417c478bd9Sstevel@tonic-gate * ACTIVE: 3427c478bd9Sstevel@tonic-gate * Set when the pipe has been opened in hubd_open_intr_pipe. This is 3437c478bd9Sstevel@tonic-gate * typically after a hub has got enumerated and initialized. 3447c478bd9Sstevel@tonic-gate * 3457c478bd9Sstevel@tonic-gate * CLOSING : 3467c478bd9Sstevel@tonic-gate * Set when the pipe is closed by calling hubd_close_intr_pipe(). This is 3477c478bd9Sstevel@tonic-gate * typically called on hub disconnect via hubd_cleanup. 3487c478bd9Sstevel@tonic-gate */ 3497c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_IDLE 0 3507c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_OPENING 1 3517c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_ACTIVE 2 3527c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_STOPPED 3 3537c478bd9Sstevel@tonic-gate #define HUBD_INTR_PIPE_CLOSING 4 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate /* request structure for putting dips on deathrow list */ 3577c478bd9Sstevel@tonic-gate typedef struct hubd_offline_req { 3587c478bd9Sstevel@tonic-gate usba_list_entry_t or_queue; /* DO NOT MOVE! */ 3597c478bd9Sstevel@tonic-gate hubd_t *or_hubd; 3607c478bd9Sstevel@tonic-gate usb_port_t or_port; 3617c478bd9Sstevel@tonic-gate dev_info_t *or_dip; 3627c478bd9Sstevel@tonic-gate uint_t or_flag; 3637c478bd9Sstevel@tonic-gate } hubd_offline_req_t; 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_offline_req)) 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* 3697c478bd9Sstevel@tonic-gate * cfgadm state values 3707c478bd9Sstevel@tonic-gate */ 3717c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_NORMAL 0 /* normal state */ 3727c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_DISCONNECTED 1 /* logically disconnected */ 3737c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_UNCONFIGURED 2 /* port is unconfigured */ 3747c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_EMPTY 3 /* port is empty */ 3757c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_STILL_REFERENCED 4 /* ndi_devi_offline failed */ 3767c478bd9Sstevel@tonic-gate #define HUBD_CFGADM_CONFIGURED 5 /* port is configured */ 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate /* 3797c478bd9Sstevel@tonic-gate * Debug printing 3807c478bd9Sstevel@tonic-gate * Masks 3817c478bd9Sstevel@tonic-gate */ 3827c478bd9Sstevel@tonic-gate #define DPRINT_MASK_ATTA 0x00000001 3837c478bd9Sstevel@tonic-gate #define DPRINT_MASK_CBOPS 0x00000002 3847c478bd9Sstevel@tonic-gate #define DPRINT_MASK_CALLBACK 0x00000004 3857c478bd9Sstevel@tonic-gate #define DPRINT_MASK_PORT 0x00000008 3867c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HUB 0x00000010 3877c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HOTPLUG 0x00000020 3887c478bd9Sstevel@tonic-gate #define DPRINT_MASK_EVENTS 0x00000040 3897c478bd9Sstevel@tonic-gate #define DPRINT_MASK_PM 0x00000080 3907c478bd9Sstevel@tonic-gate #define DPRINT_MASK_ALL 0xFFFFFFFF 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate /* status length used in getting hub status */ 3947c478bd9Sstevel@tonic-gate #define GET_STATUS_LENGTH 0x04 /* length of get status req */ 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate /* flag for hubd_start_polling */ 3977c478bd9Sstevel@tonic-gate #define HUBD_ALWAYS_START_POLLING 1 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate /* enumeration timeout */ 4007c478bd9Sstevel@tonic-gate #define HUBDI_ENUM_TIMEOUT 1 /* 1 second */ 4017c478bd9Sstevel@tonic-gate 40235f36846Ssl147100 /* power budget unit in mA */ 40335f36846Ssl147100 #define USB_PWR_UNIT_LOAD 100 40435f36846Ssl147100 40535f36846Ssl147100 /* power values in 100mA units */ 40635f36846Ssl147100 #define USB_HIGH_PWR_VALUE 5 40735f36846Ssl147100 #define USB_LOW_PWR_VALUE 1 40835f36846Ssl147100 40935f36846Ssl147100 /* 41035f36846Ssl147100 * According to section 9.6.3 of USB 2.0 spec, 41135f36846Ssl147100 * bMaxPower in the device configuration descriptor 41235f36846Ssl147100 * is expressed in 2mA units 41335f36846Ssl147100 */ 41435f36846Ssl147100 #define USB_CFG_DESCR_PWR_UNIT 2 41535f36846Ssl147100 416ff0e937bSRaymond Chen /* variables shared with wire adapter class drivers */ 417ff0e937bSRaymond Chen extern uint_t hubd_errlevel; 418ff0e937bSRaymond Chen extern uint_t hubd_errmask; 419ff0e937bSRaymond Chen extern uint_t hubd_instance_debug; 420ff0e937bSRaymond Chen 421ff0e937bSRaymond Chen /* common interfaces for hub and wire adapter class devices */ 422ff0e937bSRaymond Chen hubd_t *hubd_get_soft_state(dev_info_t *); 423ff0e937bSRaymond Chen void hubd_get_ancestry_str(hubd_t *); 424ff0e937bSRaymond Chen int hubd_get_all_device_config_cloud(hubd_t *, dev_info_t *, 425ff0e937bSRaymond Chen usba_device_t *); 426ff0e937bSRaymond Chen int hubd_select_device_configuration(hubd_t *, usb_port_t, 427ff0e937bSRaymond Chen dev_info_t *, usba_device_t *); 428ff0e937bSRaymond Chen dev_info_t *hubd_ready_device(hubd_t *, dev_info_t *, usba_device_t *, 429ff0e937bSRaymond Chen uint_t); 430ff0e937bSRaymond Chen void hubd_schedule_cleanup(dev_info_t *); 431ff0e937bSRaymond Chen 4327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4337c478bd9Sstevel@tonic-gate } 4347c478bd9Sstevel@tonic-gate #endif 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_HUBDVAR_H */ 437