Merge tag 'v4.4-rc5'
[firefly-linux-kernel-4.4.55.git] / drivers / usb / core / hub.h
index f608b39beaf090c531cb3f244a3aed482fd0ee1a..688817fb3246cd6509242aac247b0f779273e86b 100644 (file)
@@ -41,16 +41,18 @@ struct usb_hub {
        int                     error;          /* last reported error */
        int                     nerrors;        /* track consecutive errors */
 
-       struct list_head        event_list;     /* hubs w/data or errs ready */
        unsigned long           event_bits[1];  /* status change bitmask */
        unsigned long           change_bits[1]; /* ports with logical connect
                                                        status change */
-       unsigned long           busy_bits[1];   /* ports being reset or
-                                                       resumed */
        unsigned long           removed_bits[1]; /* ports with a "removed"
                                                        device present */
        unsigned long           wakeup_bits[1]; /* ports that have signaled
                                                        remote wakeup */
+       unsigned long           power_bits[1]; /* ports that are powered */
+       unsigned long           child_usage_bits[1]; /* ports powered on for
+                                                       children */
+       unsigned long           warm_reset_bits[1]; /* ports requesting warm
+                                                       reset recovery */
 #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
 #error event_bits[] is too short!
 #endif
@@ -66,6 +68,7 @@ struct usb_hub {
        unsigned                limited_power:1;
        unsigned                quiescing:1;
        unsigned                disconnected:1;
+       unsigned                in_reset:1;
 
        unsigned                quirk_check_port_auto_suspend:1;
 
@@ -73,27 +76,34 @@ struct usb_hub {
        u8                      indicator[USB_MAXCHILDREN];
        struct delayed_work     leds;
        struct delayed_work     init_work;
+       struct work_struct      events;
        struct usb_port         **ports;
 };
 
 /**
  * struct usb port - kernel's representation of a usb port
- * @child: usb device attatched to the port
+ * @child: usb device attached to the port
  * @dev: generic device interface
  * @port_owner: port's owner
+ * @peer: related usb2 and usb3 ports (share the same connector)
+ * @req: default pm qos request for hubs without port power control
  * @connect_type: port's connect type
+ * @location: opaque representation of platform connector location
+ * @status_lock: synchronize port_event() vs usb_port_{suspend|resume}
  * @portnum: port index num based one
- * @power_is_on: port's power state
- * @did_runtime_put: port has done pm_runtime_put().
+ * @is_superspeed cache super-speed status
  */
 struct usb_port {
        struct usb_device *child;
        struct device dev;
-       struct dev_state *port_owner;
+       struct usb_dev_state *port_owner;
+       struct usb_port *peer;
+       struct dev_pm_qos_request *req;
        enum usb_port_connect_type connect_type;
+       usb_port_location_t location;
+       struct mutex status_lock;
        u8 portnum;
-       unsigned power_is_on:1;
-       unsigned did_runtime_put:1;
+       unsigned int is_superspeed:1;
 };
 
 #define to_usb_port(_dev) \
@@ -103,7 +113,7 @@ extern int usb_hub_create_port_device(struct usb_hub *hub,
                int port1);
 extern void usb_hub_remove_port_device(struct usb_hub *hub,
                int port1);
-extern int usb_hub_set_port_power(struct usb_device *hdev,
+extern int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub,
                int port1, bool set);
 extern struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev);
 extern int hub_port_debounce(struct usb_hub *hub, int port1,
@@ -111,6 +121,29 @@ extern int hub_port_debounce(struct usb_hub *hub, int port1,
 extern int usb_clear_port_feature(struct usb_device *hdev,
                int port1, int feature);
 
+static inline bool hub_is_port_power_switchable(struct usb_hub *hub)
+{
+       __le16 hcs;
+
+       if (!hub)
+               return false;
+       hcs = hub->descriptor->wHubCharacteristics;
+       return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM;
+}
+
+static inline int hub_is_superspeed(struct usb_device *hdev)
+{
+       return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS;
+}
+
+static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)
+{
+       unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
+
+       /* Wait at least 100 msec for power to become stable */
+       return max(delay, 100U);
+}
+
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
                int port1)
 {