diff options
Diffstat (limited to 'drivers/usb/core/hub.h')
-rw-r--r-- | drivers/usb/core/hub.h | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 33bcb2c6f90a..0a7cdc0ef0a9 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h | |||
@@ -45,12 +45,13 @@ struct usb_hub { | |||
45 | unsigned long event_bits[1]; /* status change bitmask */ | 45 | unsigned long event_bits[1]; /* status change bitmask */ |
46 | unsigned long change_bits[1]; /* ports with logical connect | 46 | unsigned long change_bits[1]; /* ports with logical connect |
47 | status change */ | 47 | status change */ |
48 | unsigned long busy_bits[1]; /* ports being reset or | ||
49 | resumed */ | ||
50 | unsigned long removed_bits[1]; /* ports with a "removed" | 48 | unsigned long removed_bits[1]; /* ports with a "removed" |
51 | device present */ | 49 | device present */ |
52 | unsigned long wakeup_bits[1]; /* ports that have signaled | 50 | unsigned long wakeup_bits[1]; /* ports that have signaled |
53 | remote wakeup */ | 51 | remote wakeup */ |
52 | unsigned long power_bits[1]; /* ports that are powered */ | ||
53 | unsigned long child_usage_bits[1]; /* ports powered on for | ||
54 | children */ | ||
54 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ | 55 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ |
55 | #error event_bits[] is too short! | 56 | #error event_bits[] is too short! |
56 | #endif | 57 | #endif |
@@ -66,6 +67,7 @@ struct usb_hub { | |||
66 | unsigned limited_power:1; | 67 | unsigned limited_power:1; |
67 | unsigned quiescing:1; | 68 | unsigned quiescing:1; |
68 | unsigned disconnected:1; | 69 | unsigned disconnected:1; |
70 | unsigned in_reset:1; | ||
69 | 71 | ||
70 | unsigned quirk_check_port_auto_suspend:1; | 72 | unsigned quirk_check_port_auto_suspend:1; |
71 | 73 | ||
@@ -81,19 +83,23 @@ struct usb_hub { | |||
81 | * @child: usb device attached to the port | 83 | * @child: usb device attached to the port |
82 | * @dev: generic device interface | 84 | * @dev: generic device interface |
83 | * @port_owner: port's owner | 85 | * @port_owner: port's owner |
86 | * @peer: related usb2 and usb3 ports (share the same connector) | ||
84 | * @connect_type: port's connect type | 87 | * @connect_type: port's connect type |
88 | * @location: opaque representation of platform connector location | ||
89 | * @status_lock: synchronize port_event() vs usb_port_{suspend|resume} | ||
85 | * @portnum: port index num based one | 90 | * @portnum: port index num based one |
86 | * @power_is_on: port's power state | 91 | * @is_superspeed cache super-speed status |
87 | * @did_runtime_put: port has done pm_runtime_put(). | ||
88 | */ | 92 | */ |
89 | struct usb_port { | 93 | struct usb_port { |
90 | struct usb_device *child; | 94 | struct usb_device *child; |
91 | struct device dev; | 95 | struct device dev; |
92 | struct usb_dev_state *port_owner; | 96 | struct usb_dev_state *port_owner; |
97 | struct usb_port *peer; | ||
93 | enum usb_port_connect_type connect_type; | 98 | enum usb_port_connect_type connect_type; |
99 | usb_port_location_t location; | ||
100 | struct mutex status_lock; | ||
94 | u8 portnum; | 101 | u8 portnum; |
95 | unsigned power_is_on:1; | 102 | unsigned int is_superspeed:1; |
96 | unsigned did_runtime_put:1; | ||
97 | }; | 103 | }; |
98 | 104 | ||
99 | #define to_usb_port(_dev) \ | 105 | #define to_usb_port(_dev) \ |
@@ -111,6 +117,29 @@ extern int hub_port_debounce(struct usb_hub *hub, int port1, | |||
111 | extern int usb_clear_port_feature(struct usb_device *hdev, | 117 | extern int usb_clear_port_feature(struct usb_device *hdev, |
112 | int port1, int feature); | 118 | int port1, int feature); |
113 | 119 | ||
120 | static inline bool hub_is_port_power_switchable(struct usb_hub *hub) | ||
121 | { | ||
122 | __le16 hcs; | ||
123 | |||
124 | if (!hub) | ||
125 | return false; | ||
126 | hcs = hub->descriptor->wHubCharacteristics; | ||
127 | return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM; | ||
128 | } | ||
129 | |||
130 | static inline int hub_is_superspeed(struct usb_device *hdev) | ||
131 | { | ||
132 | return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS; | ||
133 | } | ||
134 | |||
135 | static inline unsigned hub_power_on_good_delay(struct usb_hub *hub) | ||
136 | { | ||
137 | unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2; | ||
138 | |||
139 | /* Wait at least 100 msec for power to become stable */ | ||
140 | return max(delay, 100U); | ||
141 | } | ||
142 | |||
114 | static inline int hub_port_debounce_be_connected(struct usb_hub *hub, | 143 | static inline int hub_port_debounce_be_connected(struct usb_hub *hub, |
115 | int port1) | 144 | int port1) |
116 | { | 145 | { |