From patchwork Thu Jan 5 06:01:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9498461 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 815F1606E0 for ; Thu, 5 Jan 2017 06:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F60E27FA3 for ; Thu, 5 Jan 2017 06:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63EC427FB6; Thu, 5 Jan 2017 06:09:30 +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 B011C27FA8 for ; Thu, 5 Jan 2017 06:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030664AbdAEGEH (ORCPT ); Thu, 5 Jan 2017 01:04:07 -0500 Received: from mail-cys01nam02on0088.outbound.protection.outlook.com ([104.47.37.88]:40518 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030646AbdAEGCm (ORCPT ); Thu, 5 Jan 2017 01:02:42 -0500 Received: from DM5PR03CA0022.namprd03.prod.outlook.com (10.175.104.32) by MWHPR03MB2478.namprd03.prod.outlook.com (10.169.200.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10; Thu, 5 Jan 2017 06:01:55 +0000 Received: from BN1AFFO11FD025.protection.gbl (2a01:111:f400:7c10::187) by DM5PR03CA0022.outlook.office365.com (2603:10b6:3:118::32) 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; Thu, 5 Jan 2017 06:01:55 +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 BN1AFFO11FD025.mail.protection.outlook.com (10.58.52.85) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Thu, 5 Jan 2017 06:01:54 +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 v05619tD025211; Wed, 4 Jan 2017 23:01:46 -0700 From: Peter Chen To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , Peter Chen Subject: [PATCH v11 4/8] usb: core: add power sequence handling for USB devices Date: Thu, 5 Jan 2017 14:01:55 +0800 Message-ID: <1483596119-27508-5-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483596119-27508-1-git-send-email-peter.chen@nxp.com> References: <1483596119-27508-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131280697149993092; (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)(39400400002)(39410400002)(39850400002)(39380400002)(39860400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(8676002)(97736004)(81166006)(36756003)(8936002)(81156014)(626004)(85426001)(5003940100001)(68736007)(2171001)(50466002)(4326007)(2201001)(305945005)(33646002)(50226002)(5660300001)(5001770100001)(48376002)(2906002)(86362001)(2950100002)(39060400001)(6666003)(189998001)(77096006)(38730400001)(575784001)(47776003)(356003)(7406005)(92566002)(104016004)(105606002)(76176999)(7416002)(106466001)(54906002)(8656002)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2478; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD025; 1:Tm5Ymv6fgc/9p4ocotJc3ixfDHvR5i644W4E3xq03dzFgmx/kPRwoupkrd/Xb7HsDDbtbFeFmX+JwG8UquN14tiaAdTGu3JyTYq2acdOO2Pn6laKa5AHb1S1n1dFSCjB8ddSM6iQpFRT1rFvIvt8sKqmlQ3Ma8ez/SI+fSbHa/lq20v5I64w4s1KfNA9oNlxfVJ/+FYHoKdDJkoLMVrVSLbsO+GfYqH6B3OVgp4E5qfxZ9KsE23fZEv0LxdwaSgRsE94DftWeJ9incH/nZPZBcW+V0udizUs54EKKJWUJuDm8jqsD9pjxHl5gRYWd/Y8o2anmAf4835THR19nLU0/uh1MaFseo0oxQ4GSWYP9IizlaDN29YF9unr27d4CY/jN/3lYL7TkJce04iCcz0CKQkpX6OvbPSXxIB72RpThpqXWZTzkMnOqZ0MsynmDtdYWKlb5XWyK+bsWcZ8+cVW5PcGYYy5qPFblsZmUjnIlONSos4pK4wYdMKoYmZIXqZHmPzMvw9eh7MVl6BnMVy4df8RZenja6gTE6VJflHDORK62oThsfrZcW0v/KK5GXaYSMCTv/86P5mo0+tYbZjt8ajsxPo13tdT0dwy7BzJZVfcMuPD1+rMFPJRdS6o5/sCm9nSArjqzFOmFq/h5BGkLrsc33yUuJ7trYgZeMFNDGK2bSVQHl3iE3x8yAmK4jqvEQSsQcmSj5XzO+8yUaB2llx/xyuMSdMhnmmrlwD38hJ56iLGv/l9djMgstm7cf9T MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 505d4199-2334-4f4b-a5a4-08d4353059e1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:MWHPR03MB2478; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2478; 3:YdLQYopBqvyI74TO+nJ1NnROUfaQMakus5RA2VNw9Aj1aY5PUlSvcanjz9t/LDJfCYPHohukj9U2NEgxR4y7a31w+S93WdIs2I5EVdotclw/xfjMPVO6JutuTrGMnIiEhKM3BbI62rhyadcXNG3MSinfDK3y+EKXB6u/9E7q9D2gsxPX5MTOri5xB9AGEMy4BS2GNiByrXPXn4yCcpcGvLR0ITcJEIaGulcXEBBkwgH2Ti8b9Y0xgH5TH6DrH3EZVg798xhHGQsdVVVhCwGpKzgyrS3/DV0eZQNtaFSC7tio/udvZ7159XK9v8xL7Tqqvj4g1pPfu3MWpmeQPPDn/GxzJBa4E1zumPWzqEAVhKiLdvKLxN3CVD30YRw7ZGNR; 25:wsYvv3KadjlbwRSLON+GDHSamwY0B7AdK4w+z/KkRtfMo0QCuaNK+FyA47xnLA3dPgqlOG0euj99/wJbdh2pbgLAlNotv4zX2Hz6IxC2MseBu4Ja/Bputil6CeFsKXU6QRNUuxLg+8kQRI41FqvlOkT30sa4XIh4pXYzuNTRm5thWMPXXRZstJj79p4v1jjXBitSCC1AAngJ7+sBuz5zWoEs69vSPhYevrATkf/TwjF+TfTXvDkztDdedpGoY6hv4htV19D4AWMCMk0IPIE+9Lz8L492uYtfssm8e7tKJm14GkOSYXmMlABr//EsVkWJbYnZt5HauCmMhLTYp8DTcswg55f0dJVDkLDX4Vqoxzwp/j63nhOjxhTePCHPXJj6g4JRnQdW9tpEo5uLQqEzx5nmayMs3vF8+94sKiCDL7+XjcEYooemlSiOVhj/kQd4MxeK8QRQ4wLcqxYN7aub4A== X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2478; 31:tQmlhnV2bEgmjA58IaXa9VgNE6wlaucaPxVFqdiU46FwjFHGJl4FsZ9Fw+CMuzZN8ZS9Exua6cKU5Kfx4COCpUhbyxAkuAjGPGYlcQvuR/RMtjaIQSDdCSAWUgNnY6XBGA2RWF7ptb9VEh0qV/DKItZyuuLVJhksYi9Ku0eRwSfHDhEhslzib+83U3QAwCwBa4/qccsA46V+bV8XLLc3gqnp/q2j6nswGN5YIsowCR6r/ovGMR5diklNESfJgRXPJwIi+aAd5nKZ9Q2VE0JV1A== 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)(5005006)(8121501046)(13024025)(13023025)(13015025)(13017025)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123556025)(20161123559025)(20161123561025)(20161123565025); SRVR:MWHPR03MB2478; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2478; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2478; 4:a3aRRKZyxDc4BgKbzhLTU0CWHZPvzmuJ5hqvgoYGZUMWpGk6smt2Gl5LYVLJQ3hek1pMIUUMltDaqz7Q1NjHk1ZVYaAQCNrlWgfo5oXpjzRbrNOaTBr5DIrkaOow23lrMiSpNCofPQsBEI3nFeGT36MziOzqhlfsaQYUcuieRjqJpjSfxQ1VSvkNS1LTGRoOVOfK4Ex4LYdc3pFxYwUPSlbX+/StGzO/zohEyVU3mdcVBLMiRqoSqza9+4LzYJXhgoejxp9wJ9KBJd2DUdgpRQ/tugIhb1maCACgCCDrmtbwmi8pHAnhkA7zy6e8cQNmjrxW4Ov1fhUcYJxK9/gXM+GR2xXvyHATpwe8HPd/3WjapNooKntpxEbWtR00G1O3tqFDg4llSkaDsGpD/Qs+wNdMKPG9u5Z1uANGwT9R5F+kU0uF5NRvrEa3PhcQmlfPMd7hFZX0JU9HEDHmx3NdUd4j1IYmXWslf75OXbCMAriOcCKXBhblpyEUukpAzXxOTIBs03pI2XfpDGs44Qf5g4jbjFcPxBNAJOUmn74btF9WMtJN9OrySgDSCKAJqcJzenG+g1Xn0vazxmNDRl1WOvCW3iUgKW8vDKhuhusANQ3S5Jh7roBzzHhBwyq5wZYjidFZ6ByWiNlydyxEGNO8o10f9SvdpQSnnGJTVDUK48yxTA6nl/FyVFWnwZ75jGfJyiNF2Y1BUKQqANY6cyyvriKh2F45fRjWzB5js4DYn48faoP3ekrMrZd6KqUKCteo X-Forefront-PRVS: 0178184651 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2478; 23:5vpUGkw/jp/twkCxyn70lS6QqaU4KtB1mx+4tfd3S?= =?us-ascii?Q?agoaq3kzunF+4fkRJT8Fk7+cyAXQJQLCd/9MiNV772SdaffHRUp1GVvxLjk2?= =?us-ascii?Q?Tr+Kf08fJFawtbJ3poJ1lXj2A9t9adefadVoeKGctpkFy32v4W/D/B2TQAo4?= =?us-ascii?Q?He3ZdJGQOSdHPgK//Oe2P0FiCl96GvmU+LCAjos1lcspdgVH2D38eb1I+iQc?= =?us-ascii?Q?5IEpSU10Rebb5oUrz/Hy202cxHmlKyDLLKAWMX+LB0Izdn6j5MAPgyiX6Est?= =?us-ascii?Q?m2wFkjbAVc59BHsicas438NSPKbCnED/ATFd5zDprLfjkL5xOYpX1HIRz2nZ?= =?us-ascii?Q?pteK+/hQnzAcW/mZ825O6UdC/5GRcw6kBC219cLAJ8C5IWmwdTnwbv6AfgVY?= =?us-ascii?Q?B3VXIKH0EEUop2UPSDjWkE0yKUNlxy/+qKziIIR31260B5NVOCYXmfoMJpP3?= =?us-ascii?Q?FKcx/QEKFug/Uz1TI8LsJStSwQUM6Z6GOW5VmFEa9EhYEt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DoQrjF3OBqbktvpkvVDJ+19vWmCiFNRmxZBCM2bkV1OvA8al4TwyP3d2oWUEP1Up9fqZDJuN8zhJTtyIpVf3YYdm1Q8rRLga3yTwBty+Yul4wCa5DV5QyVf3T9Bw+K7UyOebb2KvfitEHKSk4ZU4UT02DqDRFoy1s71Vsj5m+4ddNb0epqMCSXHwmDchKzl0nzstN9xIK7IB6npUPsT9ZUbNYPwEkbwKzLwDrmEPoXA1mOeSn24k+Rbr+LPjZM96h26LjjI4UzAOjBf8Q/priVypf4tHDmZllROBmiJ1CVw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2017 06:01:54.5937 (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: MWHPR03MB2478 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 Acked-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski --- 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 */ }; /**