From patchwork Sat Feb 11 01:27:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9567765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1877560572 for ; Sat, 11 Feb 2017 01:52:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04DD02853B for ; Sat, 11 Feb 2017 01:52:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAE28285BF; Sat, 11 Feb 2017 01:52:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AEC62853B for ; Sat, 11 Feb 2017 01:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932115AbdBKBuv (ORCPT ); Fri, 10 Feb 2017 20:50:51 -0500 Received: from mail-co1nam03on0056.outbound.protection.outlook.com ([104.47.40.56]:35521 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751504AbdBKBt3 (ORCPT ); Fri, 10 Feb 2017 20:49:29 -0500 Received: from BN6PR03CA0061.namprd03.prod.outlook.com (10.173.137.23) by DM2PR0301MB0733.namprd03.prod.outlook.com (10.160.97.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Sat, 11 Feb 2017 01:48:10 +0000 Received: from BL2FFO11OLC002.protection.gbl (2a01:111:f400:7c09::158) by BN6PR03CA0061.outlook.office365.com (2603:10b6:404:4c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Sat, 11 Feb 2017 01:48:09 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC002.mail.protection.outlook.com (10.173.161.186) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.904.16 via Frontend Transport; Sat, 11 Feb 2017 01:48:09 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v1B1kZwS001095; Fri, 10 Feb 2017 18:48:01 -0700 From: Peter Chen To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Peter Chen Subject: [PATCH v13 09/12] usb: core: add power sequence handling for USB devices Date: Sat, 11 Feb 2017 09:27:20 +0800 Message-ID: <1486776443-2280-10-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486776443-2280-1-git-send-email-peter.chen@nxp.com> References: <1486776443-2280-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131312512899426654; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7916002)(39450400003)(39400400002)(39860400002)(39840400002)(39380400002)(39410400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(5003940100001)(68736007)(36756003)(2906002)(4326007)(86362001)(53936002)(5660300001)(76176999)(85426001)(6666003)(2201001)(7416002)(38730400002)(50986999)(7406005)(2171002)(2950100002)(356003)(305945005)(626004)(50226002)(48376002)(81166006)(97736004)(8656002)(92566002)(81156014)(189998001)(50466002)(8936002)(39060400001)(105606002)(104016004)(77096006)(8676002)(47776003)(33646002)(106466001)(54906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0733; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC002; 1:dWwfeBW+Pu8Z3M6zknF6hm0iuM0vpaxPLakkgpklcRY1A1wB/nbbiitG492/7jSK/SyjU9nsndIOev1Kyk/eSMUs4C19XdEcAqN01fYSk/tDEYxXF4EDGxeX27tQFaVXiUUVBVmla0TqEAnllwh+p+V9xfTHBxnpTPwYRLVfaabLus4oP0EkHOY0WH5ApPeunqHCHzZJZoKLdpgWHHobgbxEZFHyfFNoOcpBgndxceMgzClOtJbv/73xfKm4mBMYtg7KPc3bjODuk9tPfVOy/JzKK4CLfa69BjEtNtW54KQMN9WPIDlidIuGc86cSeUAaY3MUF2ffbzTwquIgOTDonUdtZIC9JuK8cFMmEhr/Rxn5Bgz3E2XAzBu3Ry/M70VzDBrWH1lYBnyNeT0NjgTvn+wMZWLGCQB/lwLZbbQud4e4qgALQZotBuCT9d9x/0LCnWfsep/tkewmH6lpXn5g+/GuAw4kxL1xvuUap165i3BzgWiU+DH32zJA7/AT+pksLNLqSm76aXTc0HDMh0pAThAccNqhDNRg0lJPKs0CZ1MLfjOe2DtDvzKlLm6FCWTCKRxxwCEjIg6YT816qPJsHSHK/G0RpBEACMaOp4/mSa6p2SU00lF9Ee3i+aOT4saLpqx1wRn0y1lz65LRIdfOW+3PtR8NXEtpohzjU6hB7hJgcfkTOe9mfGVPAyujiEkFQsCT4HIfLSYvfDSsHFvB4wDdCvY5BAgp3VHKjQGDMaWSgCpPx07Be4l05jcZPgj MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 78501894-8314-48ff-c7ff-08d452200863 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR0301MB0733; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0733; 3:bAnRGAK+X9ylDpKuxvMO/jcEkxwvog2tmOZ39NRt+Xu7pB3eswpWFuyxdaG4sGbuu264ksXFTxKBduTNFRnOq725o9EMFe0qw5erH50AGMHX0TBrBiZvY+ke+a0esKUWGU+TLGPJMUktLzzHwMwbVXspB3Rf1O7Enwy6RvDRFoI+5tYxZyMwrpfHfvR4hcS1PGW5WEIIpjKtGSWjWVQ1anTziT7LM6BF4Vbw2AaMqEODZHbUvgljTlTW45ERBjaPZDtpcqSH49o/+nI56FXo5HKGVJToe7I33sIAsqMzMJEZZc/oxX8E73WpzCGKsBYSeWXvuiAcwdOoezAtqZxjAYhuRUHsxcwIGGAcDnYXTtotHgdtgbcSf2HTesKlUCyi; 25:x57/Dln0VQ0ctg39xG9/B1rR5mXmelkWCnDuKHi7lbZ9P7bxZ0myl3AF5dVyKiRyldwPAKPP5wNWCKgO1ZvdBmEoo3j1Jou1zuU5NKlVitnuZw8Gna5TC+eqWDpxjEEL0CNSiik5Qi4I91TpiEr9q3IkBstxLFZha513hIcj/9hsrUNwWQ+v9kQ7pJPMyakN72c+Wze7oBuVPrYIHCaA4iE9psjyl0v8kP2WUQVuH5DRCjCXPyPebUViqPU29Ps/bmJHShOK5PO13fl/NL86f3Q9n8xGKKn3u6Vkt1mWZ7NdB6GO/JRfl9L6y+bK2ZJeQ33BvjpHVAT+lTX0X2IfEO6lrOZ3J2t+4mmhMlAJFNihrXoL8q4udGNG4Ghwbv5w2j9/ohdUL2Let0he1E5jP9jg9APldYokAxtGvvljmaAtfDYAySoakfjxKLvrlkrL0uZitQgGfUrYDrbEKlWPCg== X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0733; 31:ETIvVEvczf8NHrVpOZjvemM/ciyGyuG/YVIDwmFEVM3v9i/6qT4MLYlpd/EdcCivhvqb3eyjTMw6u+bhJ6Gva++xM7+MSO2aoifLZxrao44/I2obl5X2n2ax/YA3XShjfSZ9z7prbxM1QvyvIW8oOz/RnIy3V5QLMKXr2YgLPcWeM8bkdRTMMHd91mrSl/GSLrFAr4WHDgNmCKaFxZs/ebgERW2YHPnPFsFhzrYIbprrjPX2KgcXzef2l0B2tla5mYBVNcoy/xlACMrq1dKQhuYMeO1Enu9o8UKHfLtWaF4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13024025)(13018025)(5005006)(13023025)(8121501046)(13017025)(13015025)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123565025)(20161123559025)(20161123556025)(20161123561025); SRVR:DM2PR0301MB0733; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0733; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0733; 4:NcHrUSuhuWo4PZyVrIX6EsotoBBcnGLNEMMLeYSJZGvhjhGqlcT0kx2A4/LdnZAzwueUCf1A+vNfpIhLJMSvV+36MIJ30bMntKEiVLhl3KYN1PqaXAWkTD8tIWcsFCeQQzanydIvdzBPvlrKE1iWRcBBF0IdRE3Y+3LaaH/sXbIUG1MVWr373qBYTbGWQKpiydhhXibtl8F/sARGpLZvj1z+53qYEt6sF9OOa9iHGlZ9M/MBWPa/PZt7BlUxrdplvhOudIri4AFpom0xfqVWQHNak9ws0lmXJlSzSUdAC91o6IID4rp8qpvIWQdsgzN3r4dyBXDz0TaIKh4uj2ctkBctOj66XFt5mC0OA0NkW5OOFBJKjuWpauJcSul5eR0wIWh8VUozDdrm2AYqZ9Z2b1suOvrCkjWGmiJsn3e6Cz5xc+8o5fbySzrvGd6TVbzProDSJBF4JIqutgCHzeWltMpGdSSNOXkTlE8X1b1GgLCMKKupkKK2dq6UTLsk0/c65nGMZNaECiT/u10kRM0oNWdRHXzGODYk3Jd7PUHpISLCBuV/63nmFKwCwjftTG4NskDGeEmCfclzbRqepPbJtXhH9opM3SeJEzjugTvNq8e3dFrkhKNJbTE0fkV9PoQQL7BIUccZnMefpgn4EPrjZLJ/oChLl2jI5IAeiaG9EMB0NhkW3HdBlUPIwC3mKmdXiusNv2/L082b77vtUqm+9w9gx6lfDp1tk0ir+zBYsZ+kAYUj1/ltOrYMIllwsINj X-Forefront-PRVS: 0215D7173F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0733; 23:YeBbVkf8dxtV2ULLNqK5sQRnawJGUTr6Ro+oVkp?= =?us-ascii?Q?2Ouw31Nb6gz7DwbbQ8MFD65JoqifxGDUyjwsRff5NDTH9+F7tTCmRXyLWcW+?= =?us-ascii?Q?DNwyKsacNghoqJS3f9rgA5ST7XRPOeurY/C2yFB6DNIHPdq3T5jmnrSrpO0/?= =?us-ascii?Q?yoTy/DVgCj/cgHTmXINgUZfPDjeFlWioVUgB1P1P1go80OK/IYFUf5WiPCYZ?= =?us-ascii?Q?NKLyYWD+iOyFHuNHYv1pp+l6Peerh9GQyliHJCrvGMEAzHP57zMxfUa6yqY3?= =?us-ascii?Q?9ySN5a7ca4j1txdeBnsLP1BHfVPqKTJggGPZOCzyOraezyrAQPDoOPaoHS7S?= =?us-ascii?Q?RWkDyS+EVwLS7uFJIerwiANCRon08wBOsq0ytMCqaJmUJEesH3vTVBpw0WfU?= =?us-ascii?Q?9vAyEVhrpHZMcBIryuSyo4g/ZYqFFab0m3NFVwS9yFuIZ4TsDcB0LuXlp8iH?= =?us-ascii?Q?BACTOor5QgivE03mmTqonVV3yg/bJZs+UY3acdeAY0XYegpuh79eGxKMFEFl?= =?us-ascii?Q?3miWem4RT9avHgsjxYyEhDgXKQFvC34tv46iY3t5z0h5wM0rMokpU0LM/UEW?= =?us-ascii?Q?R8HVGG2K1xoe0VQ4/IXivRBaQn2+g6w7gomzJklebvWI9AkO0blIegxxmL40?= =?us-ascii?Q?of5sXUxHVaYzruPbBHoyIm0jQaJCZsd+BouZUY6fqa1EQxQrOHGCtNLzk5AI?= =?us-ascii?Q?IokK1UzUe0fLLKljziyublMpIy7FWfTB9Yu1nd8Zq6WTQOI67XgsfdhrrZhz?= =?us-ascii?Q?60sBDJOoGzw+kgWJqlQ5y8ulJZsg0/xtp++LGXbQ61R384PEqm0V7FZMWQLc?= =?us-ascii?Q?NBiRvqHI+iToV3lbsm7SH2ZQkUyuDCDH12Uyw3XitFGlE5P7c1gAxXiO7jRq?= =?us-ascii?Q?h/qX2VMLKp4Twg69oUg53rOCTrvm5Cp3mkOOqgCWyELvP3r+SCopiOMsg0la?= =?us-ascii?Q?u7ClVIPWSKm5QmbVVFVmH6urNVOMRc4dS41Y+ERjfstBTe2mVX14fmEX3bPH?= =?us-ascii?Q?Z6m7VagudP1h4wFIh4x2j8s6y3iZYyb9a/wHrAaNrluWK3b3PA1krjs+G1Vw?= =?us-ascii?Q?onGQVaNOSRr9jz57rQoIj8r6dEX67BaJmCT4drt+kAwh6EBtlEPS10olD90Q?= =?us-ascii?Q?LlleSxX0XqZpkVf56d3o1/dXsPVRkjuWTOUebiRTnA93A7Iapmu3eY3LxpA5?= =?us-ascii?Q?rCJ8A3gcawEvGP39+kP7w0ZsflxQ9uKgcjMlpkuz9OiRCyfOeH+5XgoQNTF3?= =?us-ascii?Q?fgvEfs2w5IQvSqKZO8difZuFcKluznwQ04UVIAw3OVhMX10ucI3YzDZuCRTn?= =?us-ascii?Q?OBcvZ78J+w3R8I+P3TjeH2LxCQINvoq8qjhn+dVkFaD0C+aRWXJolF3zo3p+?= =?us-ascii?Q?Gc1P2Pw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0733; 6:wjEs/Xv4mN6ty09djOv5PHE39Rf20yuVdRHbWQo575AYCeTXfWK3XmUiOzOSVJExS8TJ4vGWgoeCaUeQMIUh9QP0v41EFqOgCtpGuiukr9WRyiFOW9bzruy/qdjgbQwBvqnB8Fhc5y38T0gMd9MIs7oBcgWcepiMbgXsqo9ibJqLmsyHZm9KLJ1dcacuwizcfH/apt1xAumItfmFP+wf0LAYlzAUtI6pcny4OBwlD/eOp9yOhTp7HVKk0Apr6fFmlDYPcoTIIQ+eQX97MQ8NuAUXMxdTXGjTZOo1BNtE8H/Og3U/CoC4wrB+IEQlpPFM4suLKZimkPScsihz8dh+2DrkDySC59ajoXXezPZlPZm2LniN406rOcfYn1E76NczUK52y385GPuUVb4fYj6nZSZ+Ee9H6sAncI8t8XF/HBY=; 5:qI7ChKcmg0VwJrO9BqHn3FMvCXaTsQZFGBzGu3M0d2BVe8822mmW/Hx/KWKsDxfKPZDzErMxZn67UL7T+d7HL5RnwHTU46oRcXp7Koy9vLbrUzOhcrrQW30baCQjhJR5hDPRSjuqHTvtb4iwlbjSSaNvwPP79FRsYBRS0kUR6eSp81tZlmgAVnWt1V+8QDSc; 24:zL65DlkG0XvZtFw3P/Wpj8fdDqBf0XPPL6HUonc1q9sQsQbbolIdYgWGvZMG4FRn6QwZLFs9OPfwPKqcXuLVNGMrRUWSLGsSISRY40LPDB0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0733; 7:PqD9C77BfJ79oJe/xwoM2JpYZSS8xVruYusvL8aTT+y0xz9hzWC5N76kOwaozu95BMD5QNU6clhYm+ZtlIRjpYSs8iu/FYrhBRbaelQdi3kAZl+hXJrTUW6TROF8BVj8Kjcwl1GojwRSTZGOB8zqhxuxY3melEif2a6EA02GcYMP7TFNK6v1ddA0kuoLuMHcdlZoOxlqmjcSEjqqK59eqHldB63ygHNoaPkMBbraP7Cx+6OX1E5rwAb5KYmij9z8eAo033tcEjyAdWxfwB7xUx2m22NBzg954fhlZXHV8P1bA8janE2pP24AhQnobzpGMQ9RHi0TYhBDWgoP1Pf4jFiF3/IhgNCouq5a4XnIIGkWJySC7L4ZZNQMN/L+LNBXnxCaKCDykmsIjLTCNOA99S3eg8iGRZGbDFbJ3lOZHN5e58oZV0uhCEozEUKQsshL9u7qpPNrClXCJSHvP/DcuelK5smoid5j7o34xFOVMgWAnw2RxMRU6ACzxoGduCGMWNCei+EmxEx9A9TtPrnGUQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2017 01:48:09.6306 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0733 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some hard-wired USB devices need to do power sequence to let the device work normally, the typical power sequence like: enable USB PHY clock, toggle reset pin, etc. But current Linux USB driver lacks of such code to do it, it may cause some hard-wired USB devices works abnormal or can't be recognized by controller at all. In this patch, it calls power sequence library APIs to finish the power sequence events. It will do power on sequence at hub's probe for all devices under this hub (includes root hub). At hub_disconnect, it will do power off sequence which is at powered on list. Signed-off-by: Peter Chen Tested-by Joshua Clayton Tested-by: Maciej S. Szmigiero Reviewed-by: Vaibhav Hiremath --- drivers/usb/Kconfig | 1 + drivers/usb/core/hub.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- drivers/usb/core/hub.h | 1 + 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index fbe493d..706f261 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -40,6 +40,7 @@ config USB tristate "Support for Host-side USB" depends on USB_ARCH_HAS_HCD select USB_COMMON + select POWER_SEQUENCE select NLS # for UTF-8 strings ---help--- Universal Serial Bus (USB) is a specification for a serial bus diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a56c75e..5b40c48 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1616,6 +1617,7 @@ static void hub_disconnect(struct usb_interface *intf) hub->error = 0; hub_quiesce(hub, HUB_DISCONNECT); + of_pwrseq_off_list(&hub->pwrseq_on_list); mutex_lock(&usb_port_peer_mutex); /* Avoid races with recursively_mark_NOTATTACHED() */ @@ -1643,12 +1645,42 @@ static void hub_disconnect(struct usb_interface *intf) kref_put(&hub->kref, hub_release); } +#ifdef CONFIG_OF +static int hub_of_pwrseq_on(struct usb_hub *hub) +{ + struct device *parent; + struct usb_device *hdev = hub->hdev; + struct device_node *np; + int ret; + + if (hdev->parent) + parent = &hdev->dev; + else + parent = bus_to_hcd(hdev->bus)->self.sysdev; + + for_each_child_of_node(parent->of_node, np) { + ret = of_pwrseq_on_list(np, &hub->pwrseq_on_list); + /* Maybe no power sequence library is chosen */ + if (ret && ret != -ENOENT) + return ret; + } + + return 0; +} +#else +static int hub_of_pwrseq_on(struct usb_hub *hub) +{ + return 0; +} +#endif + static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_host_interface *desc; struct usb_endpoint_descriptor *endpoint; struct usb_device *hdev; struct usb_hub *hub; + int ret = -ENODEV; desc = intf->cur_altsetting; hdev = interface_to_usbdev(intf); @@ -1753,6 +1785,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) INIT_DELAYED_WORK(&hub->leds, led_work); INIT_DELAYED_WORK(&hub->init_work, NULL); INIT_WORK(&hub->events, hub_event); + INIT_LIST_HEAD(&hub->pwrseq_on_list); usb_get_intf(intf); usb_get_dev(hdev); @@ -1766,11 +1799,14 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND) hub->quirk_check_port_auto_suspend = 1; - if (hub_configure(hub, endpoint) >= 0) - return 0; + if (hub_configure(hub, endpoint) >= 0) { + ret = hub_of_pwrseq_on(hub); + if (!ret) + return 0; + } hub_disconnect(intf); - return -ENODEV; + return ret; } static int @@ -3584,14 +3620,19 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) /* stop hub_wq and related activity */ hub_quiesce(hub, HUB_SUSPEND); - return 0; + return pwrseq_suspend_list(&hub->pwrseq_on_list); } static int hub_resume(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); + int ret; dev_dbg(&intf->dev, "%s\n", __func__); + ret = pwrseq_resume_list(&hub->pwrseq_on_list); + if (ret) + return ret; + hub_activate(hub, HUB_RESUME); return 0; } diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 34c1a7e..cd86f91 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -78,6 +78,7 @@ struct usb_hub { struct delayed_work init_work; struct work_struct events; struct usb_port **ports; + struct list_head pwrseq_on_list; /* powered pwrseq node list */ }; /**