From patchwork Mon Feb 6 09:13:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9557305 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 81D9A60413 for ; Mon, 6 Feb 2017 09:23:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F44C2624A for ; Mon, 6 Feb 2017 09:23:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63DC627D5E; Mon, 6 Feb 2017 09:23:54 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00 autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D172C2624A for ; Mon, 6 Feb 2017 09:23:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cafWb-0001To-Il; Mon, 06 Feb 2017 09:23:53 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cafOa-00079Q-Vx for linux-arm-kernel@bombadil.infradead.org; Mon, 06 Feb 2017 09:15:37 +0000 Received: from mail-by2nam03on0078.outbound.protection.outlook.com ([104.47.42.78] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cafOZ-0002Tw-Ey for linux-arm-kernel@lists.infradead.org; Mon, 06 Feb 2017 09:15:36 +0000 Received: from DM5PR03CA0003.namprd03.prod.outlook.com (10.175.104.13) by BN6PR03MB2946.namprd03.prod.outlook.com (10.175.126.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Mon, 6 Feb 2017 09:15:26 +0000 Received: from BN1BFFO11FD021.protection.gbl (2a01:111:f400:7c10::1:196) by DM5PR03CA0003.outlook.office365.com (2603:10b6:3:118::13) 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; Mon, 6 Feb 2017 09:15:26 +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 BN1BFFO11FD021.mail.protection.outlook.com (10.58.144.84) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.888.7 via Frontend Transport; Mon, 6 Feb 2017 09:15:26 +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 v169Dq2U005959; Mon, 6 Feb 2017 02:15:17 -0700 From: Peter Chen To: , , , , , , , , Subject: [PATCH v12 9/9] usb: core: add power sequence handling for USB devices Date: Mon, 6 Feb 2017 17:13:41 +0800 Message-ID: <1486372421-29073-10-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486372421-29073-1-git-send-email-peter.chen@nxp.com> References: <1486372421-29073-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131308461266898249; (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)(39860400002)(39840400002)(39410400002)(39400400002)(39450400003)(39850400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(4326007)(356003)(2201001)(8936002)(86362001)(189998001)(68736007)(8676002)(47776003)(104016004)(626004)(50466002)(85426001)(48376002)(97736004)(5001770100001)(50226002)(81156014)(81166006)(105606002)(5660300001)(53936002)(106466001)(76176999)(5003940100001)(50986999)(92566002)(7416002)(2950100002)(7406005)(77096006)(39060400001)(38730400001)(2171002)(2906002)(33646002)(8656002)(6666003)(36756003)(305945005)(54906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2946; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD021; 1:qoj2s3dgOdHzGYTfZlwonL1hbOMWISJ4Q4H3gbKA8BRfSIWhhtDW7zgRitdY0cpFwEwv4hQc2ug3ZzFxOChtqFBFbsFFp5dXq6TGlv9+Np7ARICP1yOn0gNeLKD31rTXOZs5VWLEO6I+0jBNuqWGGRbxUL5qhbMDebWZ/51PM6nsGJmAcHo1OVlBiF5wU5dD6+YWlKJ437fDV1J26Mch5g+UAeu2NPB+XzyuBwgEGC1qW/ansIQDGL3Y+i1ymHg8L8ny+8F0j1xjs9hmYUFK6h8FtFFAer4uvtombyPN9JdrMxiwWJN+VGMYev1mKGrUcbGn/SQRANJnpg9P6DQ/SlM4MKiuBR6s3LMFNJ7ZyPmFXI4FnOGEupyWI4akaaHmO7rb7a+i0l0FwIxymuLaki3Tw+fdxD8pJhAnmEwI4P9Dt0L5f4+iz9QJoOOx6qE52QoGPJiz6UvaPVZeKnlngl2OPeKygHWpWKsOphQP3o2pTFl2N5ssd5aFrYujUoBjFjaI3hHfxVSP0h9O4oCxd0uJFr1rce85sfid2lzHTeYYfxyC5ztxbVGmG5vXvXHC1QgEQnN6bdWuYtQggmHVtRTRyNp60IdnGmcak93F2XBEdGnl8nFdw1a+S3HSZpg4H8S4qYkEph9PmlLghB+jwmyM1eeXtAzH5w4zB2aKjQaIkJazgM7joU9cZEDBE1kpsxRc0ZWKqAJgjFHSbOFnryxnsWIle+R3E7WASKJuoKA3MvsIBbXSTevAtpX0JqUD1xNOIu3h+jT/daRwEbMOfQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 16884337-6a17-4b25-abe8-08d44e70b045 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2946; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 3:ErpxsDL+FnEhFFxELi95BfJ1wqyGAqalBEE0CXIYYIO+ZiVK2jy6FoNm2HaMt9gGCvHbjsDNsxV7sU2wBvWCsyb/YrlbjyzDlydA+Ag9wIJ3UbXsCyVJ5IqAkLNzMWyZcFLsmUcx1jrJTluMsGqe0WTzKqRNcDDXbZUk745ckG+bfVa8pDWEMcIwmFI1zBxJeSXlduffYoUBEy+js065GrvJiVUxyMFx1b8WV/Hcv7DbgJNRCKW7PKfbhOXNQn/rrDvQ+pddMTkKtouzWdE2976DzuOjPi0okrTwmON+sNEf95v3dgKl7+L8mKm1SHyKtA/cA+KwsYr5UjvZw1IBqrBbuvebBnjW8RPwolNaoJrUaVLv1L/3/jpLtJDfnadb; 25:BQLNHvVqPsXfjqgZXdzXldpSwLZdO2YLVFlkojE5Gqw7HBeu3ZMs+a1m71cevBaUtvMQT+U89DJ5D9839sMF77Z3xJ46fDeESwBGE7G0TZdUCJLGnJCTwl3Yr1iMCMVJPz5lubkkQ0tckj5112kB8mtNpv05ec5UAvCPW5hSbZ85fUS5AriptMSwA4ixXQG+cdL+2As7dgh1h2S2hka9apeTPgdNQh+NCk+tuAVeg+218csAoXH3Bjt04UoO13BEWag8P2zYdHcH+n2oo442xix3+t82fhcLCMrn2PiwkK21+wGH2BgB9Zhx71qq+ANQQ4un/XRgQCe2L0lZrrjZMtU/BFyFhZOGS/SjF2fEAXB5s/r3IC1lrW48Z/zNbs5mMEb0CS3SDawBW8Lsbv7Eph/FG98nGfenmtnWAPCTT2Ii9tO+vjrSnwKB9tFwy3y13WpQbiKiVsy3dNcj6/tBTg== X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 31:VMc5agrWRuUyk4IrmjjtVBUcrW9CYT3OaGIPr2XqVtXQvMGI7QMlO4V7kpcVFH23N75kjUgh2YcsEpOebkwZzbk4QHmEN2j2dE8yE32kuOUAirgO/sXwqs6wawZTy8jMyIZX4G479b6zbln0WaFKEdHSOF27j6vC6aGRk+PcdvEdpRQwgLrIPhW+KJ4XPZh+d8ZGfx9DfiPpZp6RonT9N8teAraDNC6s1gOp/4wilj+RnO4jTcRLEyGDTph197IWKSj6jMyVbyaStPzwZ3n2GObz6Z0OuKDDekvpHYyd3Qo= 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)(13017025)(20170203043)(13024025)(13018025)(8121501046)(13023025)(13015025)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123565025)(20161123561025)(20161123556025)(20161123559025); SRVR:BN6PR03MB2946; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2946; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 4:LH2lyTXTtD4XQJ4dYuTsHlUAkcloByk1wBzqmzrRJ20uHSFBV7CAduzeYYFdrm1cZQP1lY6hvJ/x4VJmUgr51SzhUZ/Ozt3yEosubcuxHGbgj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hjc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 7:37nMSw3Xo29QkalwLUApcd+irAbWcEZzdKav0zd6yg9z80YoVT3Ocz6tHsj80aj6jWk8PvMfxgXxHYAeNMQCSSV1IE2ueMoJi7Lp0QBAh93D+NBvKr6z/sVIZmQMkd6bJp7wBzh627ERVrtRIkrQ9dkTCkCY+0/0Qdpdfl1gpwvzKBxlZHMAGuwrwKNkvdHhJfZwW36QpEeRvHBzvwwSaBvIkn/9cWoIH9G+yIqT9xLbCq2et+YWqHoT0N3uuvmsBM4rtHi8H7X/HA8Y28/0M8Gi0l6FQ+zjPUOM65d+Ns2RC++wR6TYxIDgIKFZPHF97aUQznAFNLWvcRIw3vWF/5OiXt6xH8S1GGPVdFSd4R0a0naiMx22A5aE9Ast6lyLHrRo7mtq/XEoeWxLIGhCxqgQsQV2SNaOXtwwEC8vyD9tZhtakQylb9/S+idHOaTRx0f0GlRgTnhsjvjblKvqFOlRt3YidUco5Q9iwQkluIMpkdNzoJ0MutmZMZqD5eyLMT3zrKyekXgMOu67LCRJEA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2017 09:15:26.2218 (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: BN6PR03MB2946 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170206_041535_671112_3D2694D0 X-CRM114-Status: GOOD ( 19.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 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 | 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 */ }; /**