From patchwork Tue Jan 3 06:33:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9494445 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 83F0260414 for ; Tue, 3 Jan 2017 06:35:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76FE22015F for ; Tue, 3 Jan 2017 06:35:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BB752679B; Tue, 3 Jan 2017 06:35:26 +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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E49B72015F for ; Tue, 3 Jan 2017 06:35:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cOIfT-0004bs-SM; Tue, 03 Jan 2017 06:33:55 +0000 Received: from mail-bn3nam01on0050.outbound.protection.outlook.com ([104.47.33.50] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cOIfH-0004R5-RV for linux-arm-kernel@lists.infradead.org; Tue, 03 Jan 2017 06:33:45 +0000 Received: from BLUPR0301CA0024.namprd03.prod.outlook.com (10.162.113.162) by BN1PR0301MB0738.namprd03.prod.outlook.com (10.160.78.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10; Tue, 3 Jan 2017 06:33:32 +0000 Received: from BN1AFFO11FD046.protection.gbl (2a01:111:f400:7c10::158) by BLUPR0301CA0024.outlook.office365.com (2a01:111:e400:5259::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10 via Frontend Transport; Tue, 3 Jan 2017 06:33:31 +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 BN1AFFO11FD046.mail.protection.outlook.com (10.58.53.61) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Tue, 3 Jan 2017 06:33:30 +0000 Received: from b29397-desktop.ap.freescale.net (b29397-desktop.ap.freescale.net [10.192.242.114]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v036WhRE011369; Mon, 2 Jan 2017 23:33:22 -0700 From: Peter Chen To: , , , , , , , , Subject: [PATCH 4/8] usb: core: add power sequence handling for USB devices Date: Tue, 3 Jan 2017 14:33:27 +0800 Message-ID: <1483425211-14473-5-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483425211-14473-1-git-send-email-peter.chen@nxp.com> References: <1483425211-14473-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131278988109525308; (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)(7916002)(336005)(39840400002)(39860400002)(39380400002)(39850400002)(39400400002)(39410400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(105606002)(54906002)(8676002)(104016004)(2171001)(575784001)(81166006)(5660300001)(5003940100001)(50986999)(68736007)(36756003)(85426001)(47776003)(305945005)(626004)(2906002)(76176999)(33646002)(92566002)(81156014)(8936002)(2950100002)(8656002)(356003)(86362001)(7416002)(50226002)(4326007)(106466001)(39060400001)(38730400001)(2201001)(7406005)(77096006)(97736004)(48376002)(5001770100001)(50466002)(189998001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0738; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD046; 1:tbq53Cu9sYhY+X6Rv0vHC6AjYAN4y7JLrtzWPSffaYwu1um+Ty8icP37HJod197k6A4SKhQg25spYNlEukXJrLdl6N3Ht8liGkDjr1/wKBRmsodqW3jUKQlYN+ZCV6chs6BC0/jdekAn3WmNuA9erfAhM6jbpno181CLUvYNrjgPS1TpDg6Fwbe+jlp5OztBdpC1GWv+cgt9L9RMCwWolJdpe2Xd+HHL2Jto7rZjQIW4Yz3coBMBlVPK1XV7sMYlOuKZ7pUV1an9DK2VaviUj7hclnBPqNtytNj92+W2hQIzGo1zD/mxSmOSx90pkCFeQcC+o26QlSth7joK1EiSHLZY/hMIwQW60tDfODTiMVMkT9W7ehCSMfglCcLgN+mGoFbDJ39tsasWdqwzOEhNdT3mJl8/wpLnxzSX259N7CpdVBzvebpQHyza4ZDitCulMtpTq3qsTiP7neIx++cdilLS86OCU42KZK9BOifmUBeM3FFEetwb6J2AKiBY55Lx3O18CzJwTjHLvj9iAexRxvospOF8jNpwy2iCSamKDHK2vB199SvgEGBYXT9L5ATzm+va2nkVsFdkSFZIAnGB555Kj03PveG0vauBu+vFrBGfvSKDMVyrVPTMkG6Myb8OgFLDW8PjXxpmKNpmjdXY23yHSMPB+i6egqEN0rHGf7GBIDAkoyJV69FWZAICTF/Nl7+AVsJMe1H3+CgYuawvU6qUfTndyIyJB3JJBbvCheSKqgkRv/xlOF7B4xMNNl6oF26J279hAX5oJZUKJdRLjw== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 06366d79-2665-4f3f-4fe2-08d433a26f32 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN1PR0301MB0738; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0738; 3:aetFQbdf3aKeqE8XtW/tdf1v+kZrPQJCTpMVo3fbiUiJMo67nob33uUIscvUjq8dwgQY453ilMlXkO5oEg3DdOVbtHGtDNUPxVP4w/HHKjQvuL/mTRZzc9UFcj8hMLPYPSaQegt/49UaQqsU+D6KjWd3WnMaTUKNBb+fkJTBjRL5fq8u2qMPZYNFoxNMCRBKrOgpIUf/yy3i+ltkzmHhXg7SVYN7Ay/uMwMTPsPSObMtsc3iiUYTX0y42BYXCr/6+hKAealR41qbnSAbc7yzzPxcyI4gDB23Z//PvTyF8gHm5UwAn3gTGN/QA32aYGOYzDwL+gJCFqfQMEFk1nbFGNeFhdQcQttqewRmND49AgiO5j2e0biVJZI6hrUytXmC; 25:helrgSTCqY7sAbPzJfGfgsuAEMT0tuqG1dxbwLQQpD2j2kM9VgMbF67O9Ja+5QdeJmlF1Qcy1yhKEPpxU4/j+Ax4D7vMDLihAj0WIQGZyYL5VPf28LYvR+SQt34pPGrOXdzvD+rAjeJwpX72H4TL5DQxwxJXewAtimSjldXmDDp7c9SHUQtJN1Z/DxurNC/VTM3P6ik1SZWLYqhzRsQNjOFEy6nMzP/3AYV8zZcMvohCVz2cB8yijPZd33juocrVogMEJD5VzecPY/ol9ZZZXB2lX9Oi54sJeiOFbVr/tpv+lKkOqgDaMTTtC6az6M0zPGMWa5GYJrHOXrJQX7Zegr7ylLlmkZD6LNqP4kGj2fx/xkM7jr8m1smIhAq5ejVDDTBhzumtPfR16ifl75XZrcE4lStltXIzlxKRyXE5Off/5tP58xZxnFm2SckVqWKCVhLZ3o1kl63EWDcgfgTbSQ== X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0738; 31:uTliS4iJgBwWRM6zL1K/4rzGSmQA1LSxO8FufY4nu4m5xy5mKKFPTMb/pADMMdWH4Z62DeUBwtoBYYzhJ7OX6NwRZA355EoJWYwWCTkd4wniZoxaH5HtVYwQobjMDFHTtGWsdtDZH9PS2sXb38pn8G3xrVGD2TttTa8XZBtiP0+t17myGCtilB9lMLt7YxiKEfCY2jUgci2Tf9pFygvW5hdl+T6Uy0OR3WkcCWRO60e/lKDnz21uYxm/WBDzgwtKkj/xGsmydYEDvxOWYlktSQ== 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)(13023025)(13015025)(13017025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123565025)(20161123563025); SRVR:BN1PR0301MB0738; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0738; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0738; 4:+u/2RVAMZsfwIdQn/Y8Hh10V/74gIzq0lkOOG/TF4rxpn3yqBjDCIP8tOpgo+GMLcOm+OfBtUWmQ3wg4dMwD9TM2tQYB42uDZEmKrS6PrzcScZOiG29TPjmHLWBqL/agRsVZIb77O0U4kxIWiqUoGd5Lf3ouPUydOOsatvgasHFngtBqzRVCjGXwdQl28LmxoEAx7YeI1hsgXwnZ+EE9AE3WxclKXpHhISK3tzqwqtfY2fV4gpsD+IeGZKp1NVLvmqcY8k/Ee20YeD22b0OQZQ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N5sady?= =?us-ascii?Q?sdvNQSLpk1yqkALtiYt1I4/R1g3y8iOLV5xCuYpVQ5wnmuj+ipj0IvNa4IMD?= =?us-ascii?Q?a8x5ZTNJnTBLwXvQ2yB7zvWHuikw=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0738; 6:DMfx2ryjxoyOCY1LusrIULMzMPqUSZVXQvsKPXWDvoiEmUk4uK7J6v6i9VqOKMwZOpZijFQGahh48TK1/UXlmiEnmQrN0FFhZ0Td5g21utnq3LvLea8RpyHVtKhYMCAZevCg0pfXW02fwbjMQccvJPLcMTYlvK4qsiBINe/ZULyBhwx9vw/F8eF8SunLQQzdUDbDdNXLN7Us98H/J4zOmL7akT7uRva51o4IpQA9PwNlPyUpYJdA5kLFrDMRL76+mlRcKL7UTg+VRx5u/RfSvvas3DcPkvSBqGTMMbjclPPR9IbaZnFJqzwiocA6FiDL7DFgkznDr0OAJKQiJDdSlZ4gjnHOwEpf3cnjfv5xbL8JruDUXadDmLuq5in3IzHj9Q+8RqfFQjLbaFnpYzw7JAM+ukISGa9p44tFONNIXWLRtWiVmnviBexK2vNqLD31; 5:XanGWKCkExuTYi7GGPDtMYSmvUfAldQjMZ7wnGwSCahJ5q9myieyiWvrOpHTr1qpuHKRm/0jFqNSsnDOHHVsdhyVV9ajKIOV+eSR0+iet7aTSdHaZSBPpCAlDezYDKcQcsA1kgBBPxhZgIs9y+blxOEgXYMsbguX3qNWL0fN0CTImKQMDbsIa+wwdTSQN31O; 24:d3iA0mRop/3ctKZNz0XBnN+qXfsVUa3XlFCFYd3JbGWn7sizV2jA1Ce5i9MLgRF5Wfr6NlYO5o/pHhncmOyWjFbnOVOEqefrmCqBi3QZSOU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0738; 7:JG9laFY9vTj/DmY9/qRaLDifaN5VK3cdWqs54a/udU4UPcGcVWgXExzgF/ID2R7cwE/C6sQ1yQZE1xOxDK34ZNc/jZqXb2KZNdgDGcIaC0/T5HySK0My6vdkH/zCpTmwhZBlv+WZiZ3AvttzN1n9VNEbZ95yHCprlN9mUkkMcStipWhDiV0sGxDWWx0v5zTxCnBPacGKdpA3oI42eByg8o2SATviGpida3s9EdeJYxKWB6ZnbfsLtg7SUdtaXyChBfwEr0lro5fa4ozy71VE4OvYXAH9yPKIwKvxy306D7rhRwPvDazsinFTlsrvbs743p/6VoOoACqea/aCv5Ltj1ZW6pzr73cY83yBIgHNY97wNInRfORMFyNXadf5JQTAoHbhJIn8dPldLcRDexYHxSV1ZfaTMguDUiXLT9ggHn2jIOlsydGHRmAesUN/BZSYfFMkufP1srRL6MhWnWILNQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2017 06:33:30.6405 (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: BN1PR0301MB0738 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170102_223344_038983_918BEF21 X-CRM114-Status: GOOD ( 19.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Peter Chen , heiko@sntech.de, stephen.boyd@linaro.org, gary.bisson@boundarydevices.com, festevam@gmail.com, stillcompiling@gmail.com, arnd@arndb.de, vaibhav.hiremath@linaro.org, krzk@kernel.org, mka@chromium.org, devicetree@vger.kernel.org, mail@maciej.szmigiero.name, pawel.moll@arm.com, linux-pm@vger.kernel.org, s.hauer@pengutronix.de, troy.kisky@boundarydevices.com, linux-arm-kernel@lists.infradead.org, hverkuil@xs4all.nl, oscar@naiandei.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, p.zabel@pengutronix.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 | 48 ++++++++++++++++++++++++++++++++++++++++++++---- drivers/usb/core/hub.h | 1 + 3 files changed, 46 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 1fa5c0f..cec2fad 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1645,6 +1646,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() */ @@ -1672,12 +1674,41 @@ 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.controller; + + for_each_child_of_node(parent->of_node, np) { + ret = of_pwrseq_on_list(np, &hub->pwrseq_on_list); + if (ret) + 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); @@ -1782,6 +1813,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); @@ -1795,11 +1827,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 @@ -3613,14 +3648,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 */ }; /**