From patchwork Mon Feb 6 09:13:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9557303 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 5547060413 for ; Mon, 6 Feb 2017 09:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 425EC2624A for ; Mon, 6 Feb 2017 09:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34DAF27D5E; Mon, 6 Feb 2017 09:23:52 +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 7AFB82624A for ; Mon, 6 Feb 2017 09:23:51 +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 1cafWU-0001HM-1C; Mon, 06 Feb 2017 09:23:46 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cafOZ-00078Y-P3 for linux-arm-kernel@bombadil.infradead.org; Mon, 06 Feb 2017 09:15:35 +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 1cafOX-0002Tw-3F for linux-arm-kernel@lists.infradead.org; Mon, 06 Feb 2017 09:15:35 +0000 Received: from BN6PR03CA0030.namprd03.prod.outlook.com (10.175.124.16) 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:01 +0000 Received: from BY2FFO11FD008.protection.gbl (2a01:111:f400:7c0c::106) by BN6PR03CA0030.outlook.office365.com (2603:10b6:404:10c::16) 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:01 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=fail action=none header.from=nxp.com; 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 BY2FFO11FD008.mail.protection.outlook.com (10.1.14.159) 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:00 +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 v169Dq2R005959; Mon, 6 Feb 2017 02:14:52 -0700 From: Peter Chen To: , , , , , , , , Subject: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration Date: Mon, 6 Feb 2017 17:13:38 +0800 Message-ID: <1486372421-29073-7-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: 131308461009513817; (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)(3190300001)(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; BY2FFO11FD008; 1:Y69PLIsD4F3mZF99AVelNwiN8AEATswKE4vK5wGXIbYhoEeKYCyWe6wo2loBFWSQ4U2RcdYE8Kk87+v9fD2+4h6YJyp44gRwJU3a1OPy2F+knmG0jxUga71Ir7Q8GcdPsIxhDj+1fDF96U7bfn7uPDFjg3I/mHkM5OdX50XswtBUCHVxgO1u7CKRHzWT0FiRitFPdOX7PE/BWXOzbhA9bxxUknTOG/3ncw++9ZMLEqI4aZL+VbAuWRS8ykxJcVllEMcTFZtJmhtUWe36U4RA7z132wZ4k0dr3DBJF8Uyepf3EiA23NHraG/dLbtOMLF0pd3eiGLTF5dVzSGFIn0UnNfapMGIf0rNMUDfVM5Mu/dOoIUt3VzY7wfxaVLvUq7XMNo5aeSeOgh5dgMARZwa1guYx/Dj9IYKfi0ahCz5BN9kep4xKmK/fBT5MOYrMabmJtIjcSMKlb/Sfan5FsjSrAtNrOmq5xvaS1sw4vH823T4iEgZ8iAp2bBAeJiAC5MU4ALaPlKFzVmofoz/ckQXczhwS60wmP688NWCfLRIhZsXnrbOqb4GgAd1g7kDhVSWNhJy0J+PYnhBBKHgPGoNzSkUP1TMtJPGSnaz6MW4TkFgMhtzdcrLE3U5OB7OAcNUpalVyM9keIhvIbKD6wp8EP+67gbfEWwdvZqqZ/Kqt1Vy/MxlwYTib/BS8ZRGEKIJ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 44e0e158-102d-45bf-ad59-08d44e70a0f0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2946; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 3:iJN/kHygB7t1zWbrvJsyoef/SKR+1eqEduBXhaLwfZ/oD6OEMJwYd+Lq0TM+ysrawGZg3FqarLZUByngkHfFM8dWzGn524VB46G8hbUmaQQ1Du7r8RDa5NvtMzrmI1PPm/91zb/PQmrH2U3Z3ZkRyMSoH/9/mYnO6mVNxq5Qa8U7C47W8f1mcit6yBtl22MSti0QYjH52OKSib0LLO+XrGAvUCfNGM5d7vozyi5A06bQ49YI8q2nQpXxm/9hJs5jAqymZR5nUrNwdWeBRbBw+JgBntWpq3lNdBFxEKRSkFH8Y8GiArWug1CkgxExq6nL5g7ZCY9yrQYeIrRIo5QFHV5ekWRn2uyDKTlH0U5KaWsFUhv6gzwkQB7gUQoJ53OS; 25:Opt46ZDcWuHuKCCC9qjzeVK3YjRuli/mih/Dd7sV3WIL6S2kN8GZ/FaUjHOBex1MIH2uxNWiwGImOyLo2VfTXwDGDXbHOnZP93KLoFq6ZrzM9aQbG44F68Sm/CPXyl70cNIvgJnreJ0wDlENKtYseQrws/A2DZNvGvpyciIfaGVVFe+NXh3ZzFUR9x6IBStc6Gz4MqzUPCYSEHG9v0vpP0yr33azrY5sVx/8DddMD7nFCBPSsT7LswN8+fFBTVfdExXEygs9KlFvfWqToMEKf4wE+lRvRHcilbHhujFDCQPfcofQTe+dwTIAKhwokt0Ql0I+vANEup308R1iOyXnk3PxrNF0eeNVr5BfCywGRqIFLsWOJZCW/R00Cs01VXNepibBhs4XJ5Y9SxZanVi44BQF1V8Vsyd35NSkhjAb0J4ZJcH9UeRVoTEuvnuccPnla6JJCGLyJvem6eAHd2bf6w== X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 31:bZGmHzidk/WlD45wUCkavKvzzyfp23IoOqTNEB8xqaC04DiMpT//u8D5gxYP4Udt1ZZwSbTVUrzlp9hNhR8Ii+zd6KtQ+FaCVKs/Ok2BJDF+X7LxcUi7Km6VfBp4/5yxODpbzOkIgQRUpRH0LdEjghCNXNYMHgvgoq6FIs6V60/lpD75P7ghoJiy1lGIv36E+VHagYZzb93tJnrdeX2Pl1OqWlOU6wQmx/lSOqJergqC3I0NrtHGwv2I53gu41CgMRKGaVZzh5weeBLPjIHbAw4nhVkZLAdZ504tPb47qn0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(82608151540597)(228905959029699); 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:hPIqFD3BEjlWcEaVbi6Z8N7oBJtVaz+iFKYpOyAMpXjuntOJWyu6BjOlpwszg7K+Gn2DNhRHdMNItLWn8QHbxJzrI0slJ9i7+oQsM8G5m6CAa+QfP2HC2IPvpMKN5k9VMGdyl+I0r6YCm9UHjj8/ptFXo1+x/mBRtqLCX+77uHW9emZ+ymSYxqPspDevI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g2qngsrqgeVc1STmbbGZ5Ye?= =?us-ascii?Q?mKukIimq9W3d5hCSLqBBNCa5xA86Vx0Siy0xMBSJOOL0ALN3godtdsU3P5LG?= =?us-ascii?Q?3sWsnUaZVi8FmIyMqolfSY+P0NvQAv0zjbDFUDr6AsJrRHXU/ClrRK/bGisP?= =?us-ascii?Q?Y8r7Ma+yKr/8tVR2El4G01UIOFufazm4sJO/vux4celC7a4C6XD1Q96zZkun?= =?us-ascii?Q?EfE6Ns+fcAjgy/GMAR0/LyDc+WaKva3KXScLJFc0CnxUZ48?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 6:amS5dCLeUJmg+EeCrQZ5nVCwVtihvwXA1AbbOJBz2hSqOewu+HltkVckXTfRFtXg0iIX8/QStlrUd4yWJ31O5TPNqmtmHf/xczgnL3FEsRt6U23NbY9DWFLQEEZbYX16AQ+RtxY8qblkIa6VnYC9pwzSHJ796MWla8w4G3GFxXTjJJwhqEBOX4kyTlqvBbYtojh3tvCbuhmF6QxoGZxUvsTmdpMu4raK4Au+iI19hO2eGJTFULcuA4JusaMI18sr0sTN/fCMOJ4Gig7DOtbADGTRxGohPpTcfVJDK3Q3UooOA8IHvVZ0eJ0aItTzqoM1/7UHBzfEThMYQfljMUn4UcCwLitkW8ykQoXienainJpubJUdtEtaxyckJTJF+AJcsyTCapAUne0gv+YwsEyHGDha9cdPCmA94neqmkq+0sc=; 5:NGa/jnDMu8+JKh2cib76yg1cckHJyYuRfh8mVw1reF+c3UlobNm3km1KKSPfmzJiQwHuL/2GqxmOumPPH3EulkP1OTStIbo1SCy1Qy68yftWyVNXgo05Uz5f3FafM9FjpO4lbqFVkxMyXtp1Me78CNUEuNTNdHKl8LflvjwyH7ED/44+efzG80ob0ESKfM0K; 24:nawYupJtsKIOEGQWovbaepXlO8G0PhpW5rgVeKy75yopju+dkRTT5LHQdN25cAyFiXNLuijXgwqXDQ4O5jlcN2r6AWnNS3s5MxCFdvOq6VY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2946; 7:mFNYy/xxGZBzVJnFb8r9y/Q6XwsqjqzquyY31jtDXjpsbmsPWmOBMIwv5bMvpUepiHb3oc+IsqgUU9okOpUOwUCfs/eTc8KHzRmMzzS+wkxdweMZTg9vxAVacGNduGaqcPIir+CeddH0eh9TBPvEt5pUXPLeELqSOUsnN2iO1xy1j8v8Y2CHCZDzUJc57Dx6b9lLdoBn3yt0/Ig3A4o/3W5rX5qIJFRzIdDqNtPzXClIS5hEeyPvB9U9lenF5lxc4sF4f330bwr6DNuCrGqMNXQKCd3SyBRwBAQRrFVORHxtIQUgfCnWYqIZxM2keLYVOVUvWi5jDoJAuyVchf/Ee5ds+PBn/XsExh9iWBEC0A5AIVMpXrXi6u1pM5SmqT72kvvEejDTNKHsXp4Ss9+pa9FLPSLKA5BMSZIxQ2Iz9u5EtAMiji9Yw0LJv0LEf8xBNQJOPA1I+0G9a18jKv0ccxA5qXSLXD/JALLqJjjNkcH8lFQCMOQmGryNLjWcIfCBj8ybTG1Wr9VcvAf5XGApVQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2017 09:15:00.5925 (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_041533_386578_434782E0 X-CRM114-Status: GOOD ( 19.68 ) 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, heiko@sntech.de, stephen.boyd@linaro.org, gary.bisson@boundarydevices.com, Sriram Dash , 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, Mathias Nyman , 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 From: Arnd Bergmann For xhci-hcd platform device, all the DMA parameters are not configured properly, notably dma ops for dwc3 devices. So, set the dma for xhci from sysdev. sysdev is pointing to device that is known to the system firmware or hardware. Signed-off-by: Arnd Bergmann Signed-off-by: Sriram Dash Tested-by: Baolin Wang Tested-by: Vivek Gautam Tested-by: Alexander Sverdlin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 12 ++++++------ drivers/usb/host/xhci-plat.c | 33 ++++++++++++++++++++++++++------- drivers/usb/host/xhci.c | 15 +++++++++++---- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index ba1853f4..032a702 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, unsigned int num_stream_ctxs, struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) { - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; if (size > MEDIUM_STREAM_ARRAY_SIZE) @@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, unsigned int num_stream_ctxs, dma_addr_t *dma, gfp_t mem_flags) { - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; if (size > MEDIUM_STREAM_ARRAY_SIZE) @@ -1686,7 +1686,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci, static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) { int i; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); xhci_dbg_trace(xhci, trace_xhci_dbg_init, @@ -1758,7 +1758,7 @@ static void scratchpad_free(struct xhci_hcd *xhci) { int num_sp; int i; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; if (!xhci->scratchpad) return; @@ -1831,7 +1831,7 @@ void xhci_free_command(struct xhci_hcd *xhci, void xhci_mem_cleanup(struct xhci_hcd *xhci) { - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; int size; int i, j, num_ports; @@ -2373,7 +2373,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) { dma_addr_t dma; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; unsigned int val, val2; u64 val_64; struct xhci_segment *seg; diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 6d33b42..7a9c860 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,7 @@ static int xhci_plat_probe(struct platform_device *pdev) { const struct of_device_id *match; const struct hc_driver *driver; + struct device *sysdev; struct xhci_hcd *xhci; struct resource *res; struct usb_hcd *hcd; @@ -164,22 +166,39 @@ static int xhci_plat_probe(struct platform_device *pdev) if (irq < 0) return -ENODEV; + /* + * sysdev must point to a device that is known to the system firmware + * or PCI hardware. We handle these three cases here: + * 1. xhci_plat comes from firmware + * 2. xhci_plat is child of a device from firmware (dwc3-plat) + * 3. xhci_plat is grandchild of a pci device (dwc3-pci) + */ + sysdev = &pdev->dev; + if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node) + sysdev = sysdev->parent; +#ifdef CONFIG_PCI + else if (sysdev->parent && sysdev->parent->parent && + sysdev->parent->parent->bus == &pci_bus_type) + sysdev = sysdev->parent->parent; +#endif + /* Try to set 64-bit DMA first */ - if (!pdev->dev.dma_mask) + if (WARN_ON(!sysdev->dma_mask)) /* Platform did not initialize dma_mask */ - ret = dma_coerce_mask_and_coherent(&pdev->dev, + ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64)); else - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(64)); /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */ if (ret) { - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(32)); if (ret) return ret; } - hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); + hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, + dev_name(&pdev->dev), NULL); if (!hcd) return -ENOMEM; @@ -229,13 +248,13 @@ static int xhci_plat_probe(struct platform_device *pdev) goto disable_clk; } - if (device_property_read_bool(&pdev->dev, "usb3-lpm-capable")) + if (device_property_read_bool(sysdev, "usb3-lpm-capable")) xhci->quirks |= XHCI_LPM_SUPPORT; if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; - hcd->usb_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0); + hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); if (IS_ERR(hcd->usb_phy)) { ret = PTR_ERR(hcd->usb_phy); if (ret == -EPROBE_DEFER) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6d6c460..ab0839c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -237,6 +237,9 @@ static int xhci_free_msi(struct xhci_hcd *xhci) static int xhci_setup_msi(struct xhci_hcd *xhci) { int ret; + /* + * TODO:Check with MSI Soc for sysdev + */ struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); ret = pci_enable_msi(pdev); @@ -263,7 +266,7 @@ static int xhci_setup_msi(struct xhci_hcd *xhci) */ static void xhci_free_irq(struct xhci_hcd *xhci) { - struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.sysdev); int ret; /* return if using legacy interrupt */ @@ -748,7 +751,7 @@ void xhci_shutdown(struct usb_hcd *hcd) struct xhci_hcd *xhci = hcd_to_xhci(hcd); if (xhci->quirks & XHCI_SPURIOUS_REBOOT) - usb_disable_xhci_ports(to_pci_dev(hcd->self.controller)); + usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev)); spin_lock_irq(&xhci->lock); xhci_halt(xhci); @@ -765,7 +768,7 @@ void xhci_shutdown(struct usb_hcd *hcd) /* Yet another workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot); + pci_set_power_state(to_pci_dev(hcd->self.sysdev), PCI_D3hot); } #ifdef CONFIG_PM @@ -4801,7 +4804,11 @@ int xhci_get_frame(struct usb_hcd *hcd) int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) { struct xhci_hcd *xhci; - struct device *dev = hcd->self.controller; + /* + * TODO: Check with DWC3 clients for sysdev according to + * quirks + */ + struct device *dev = hcd->self.sysdev; int retval; /* Accept arbitrarily long scatter-gather lists */