Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753515AbdFMCBt (ORCPT ); Mon, 12 Jun 2017 22:01:49 -0400 Received: from mail-cys01nam02on0044.outbound.protection.outlook.com ([104.47.37.44]:63808 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753287AbdFMCAt (ORCPT ); Mon, 12 Jun 2017 22:00:49 -0400 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; From: Peter Chen To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Peter Chen Subject: [PATCH v15 4/7] usb: core: add power sequence handling for USB devices Date: Tue, 13 Jun 2017 09:59:23 +0800 Message-ID: <1497319166-17287-5-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497319166-17287-1-git-send-email-peter.chen@nxp.com> References: <1497319166-17287-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131417928352767420;(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)(39860400002)(39450400003)(39840400002)(39410400002)(39400400002)(39850400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(76176999)(2950100002)(50986999)(2171002)(498600001)(2906002)(2201001)(86362001)(8676002)(5003940100001)(104016004)(33646002)(38730400002)(81166006)(50226002)(54906002)(8936002)(36756003)(189998001)(7416002)(7406005)(5660300001)(50466002)(8656002)(77096006)(4326008)(356003)(85426001)(48376002)(305945005)(106466001)(53936002)(47776003)(105606002)(39060400002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0301MB0901;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD016;1:lzaNZhsc9JrWV9hMHQ69UjE2D1R/JGF1g6yyZ/tef+4MzYb0BIyH1aF1oL7enPN3pObjNbGSdDImqbVigAKzc5n8BJp9Zsjrp/g6FL6T2HA8ekg+oq2wBzaYCSpxgxtuK11O7zQ0AHM833W5xobz0CUEHjPjMZu7xcAmNcs1bUBsSC553YqvEYfpUJIkKTLneOdn4Irc2c5vBxNqrV39jL0IOZHDH1elp0lNk1eamvBe/QjaohH06+BYwSdxp8YB+nzwpjC4TJUGnzOQiDRchqS3etcp4NVItDD1U2nY+4uerkMHDlRRgtfXU6BZGxeFoeOAhRAAh7CMfbjqG8Wk7mAknhtzpIF22x4EiUrwaaKzj1fvsEN0OHl9M1X/iFm7jA7cQi9j0yQQwjEZAysR6rb+Rimr22YPVHuaQ7R91cj5Tcpl3tGaF2cvpE7gmwwCFUPSAREjGpGmQr7bbUMHzMHdAVZUANiiyBDMKpmafZ2prAzJrILZ8txPzPUkVLAayiJwl7Xj8WBWRetCv1nBnCgSjCkr43Wcm9zBi+BBv7ECYdbkL+wadG97Zp+FHsJ67zwE3J3rSOAFxGAOfwfRhqx7ca/RHd/ZEiq2S/zOv4VER9kjVxFXYrVSbwLUAvg6Yb3/eY/ssLtk2GgiQUfBvTjfVuzzhiTxb96kykKPjjh4DuN0fyfj22fgA0L9EEIKjxgC3pJbYrET9e+0EHMoyT44HCuBQBL5QRbaHL9KZ6Q= MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0301MB0901: X-MS-Office365-Filtering-Correlation-Id: c0145006-bbb3-4208-3c5b-08d4b1fffb0a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:BY1PR0301MB0901; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301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ok6y4/kZlV/R62T3UOOgHjECiiIcr+WTzfaRXH64upgnCO96sla/iN0wzOrwIQELqD3DKVtNjD9oeRG4otMpcK/4rnjYiy6RDFtF70DxwWbsfo5H21hoUzKBiB0QNXODx5/W9CxIMO+OASWaAj31Q8Ykqe0Au/RBRJP+uAoRG82qiYr6ARIQj3Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(35762410373642); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(13018025)(8121501046)(5005006)(13016025)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6055026)(6096035)(20161123561025)(20161123565025)(20161123559100)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(20161123563025)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0301MB0901;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0301MB0901; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0301MB0901;4:Bc8w7mDPahHLy5QMpo7IiphfOshGB7+GidvFHwm+?= =?us-ascii?Q?nI0s1ar6F1qkjJCl3AntVauEU4cyrqdZ9ZrW4hRZWnNb+5yVu0q6ZMxu18kE?= =?us-ascii?Q?0EQcBtGJUznUdEIwW0PpW6sUkHJq1c+HhOZrAhl4Bl3TCgO2TKoDxD4eTr7l?= =?us-ascii?Q?PiYz0F0i1H72OGiX5rMoP0QH2FSD2zX/z7cVQxaY0j/JvpgaYDV/NygPJ16+?= =?us-ascii?Q?c538IBr6IhRMHSJC6SlaC/2Q/TPKN0psNXdBqyp84GilPZHyaB9QItQR6ADr?= =?us-ascii?Q?MZQEQIYnEBpI6ohAsIYewj4e2Sh1SO86+4tKGSlXqn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R8mkjBS2sCBch5K3fjLJC0Bl0FQ3ANOTlGbuhwICjw3HwyWAa3P1A6QnZHZXryj1ugEnHN2MG6BpOKglUnODgwDf/FDc+gL/c91si9FFSkW7lk+C9lLu7Bmwma2OXWPzmC210n6K07++hZ0Rhl+8+7NJtzP6ypHs/iiGewfXzD9eEPHLWRxb3nPE/fknTR6h25uPJcaadrFSd+DGabIJtzNqGu7xCtL85BOVlmVXAvzohoskmyg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2017 02:00:34.9959 (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: BY1PR0301MB0901 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4682 Lines: 159 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 Acked-by: Alan Stern --- 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 939a63b..b6f626e 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -39,6 +39,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 9dca59e..0439d4f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1619,6 +1620,7 @@ static void hub_disconnect(struct usb_interface *intf) hub->error = 0; hub_quiesce(hub, HUB_DISCONNECT); + of_pwrseq_off_list(&hub->pwrseq_list); mutex_lock(&usb_port_peer_mutex); /* Avoid races with recursively_mark_NOTATTACHED() */ @@ -1646,12 +1648,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_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); @@ -1756,6 +1788,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_list); usb_get_intf(intf); usb_get_dev(hdev); @@ -1769,11 +1802,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 @@ -3593,14 +3629,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_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_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..27f56a6 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_list; /* powered pwrseq node list */ }; /** -- 2.7.4