From patchwork Sun Nov 18 10:09:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Laszczak X-Patchwork-Id: 10687721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24D4B13BB for ; Sun, 18 Nov 2018 10:12:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1313029D31 for ; Sun, 18 Nov 2018 10:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0713F29D3E; Sun, 18 Nov 2018 10:12:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 20D2329D31 for ; Sun, 18 Nov 2018 10:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727601AbeKRUbv (ORCPT ); Sun, 18 Nov 2018 15:31:51 -0500 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:36344 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbeKRUaz (ORCPT ); Sun, 18 Nov 2018 15:30:55 -0500 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wAIA6m2T016126; Sun, 18 Nov 2018 02:10:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=HLqWJ82NMnJk1pCLtj8tgQyR/RsmqhSbhukHMirKJbA=; b=RMs4Pqfk0b+IdZo0y3HmNuYZuIow3ysqtE+EZvMUx9FtVagKFprZqCO6ry19tL1r5hOR NbC4rx4HMYwFzFqkb95kKBsklNJ3uMApxN4DOv8Ru53cj9D7S9Id1NCZxyOC0Jjxu9M6 3W4zuIDcGkypZiAbAAIjRrYSjE9D7sDiSk1dlj7qlmkZi6Ma6L7YU4Wt2wc16MxPLtHC oNZc6R/uUf7BankyQVGwqUM9mQvSVJlf1Xrcr1o1fzVMdIR8eNOdJBfUZrT05kQO0ccA wDq3UFqsIFrKp0v5EAxyW0tCDnfCGEavRNb14xj7wD+JqPiHhRTLI8PV9I0VNwpQNo3e hQ== Authentication-Results: cadence.com; spf=pass smtp.mailfrom=pawell@cadence.com Received: from nam01-bn3-obe.outbound.protection.outlook.com (mail-bn3nam01lp0180.outbound.protection.outlook.com [216.32.180.180]) by mx0a-0014ca01.pphosted.com with ESMTP id 2ntge14vga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 18 Nov 2018 02:10:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HLqWJ82NMnJk1pCLtj8tgQyR/RsmqhSbhukHMirKJbA=; b=sUNoUOBCOqLbSuEiqZPqndxuD+92YD25TcnWXMh85oI8FcH+UOdNs2Ft2o7/wJzNExVFvH2nhLlP5gFAjsB91LeOVGi0hAhv+qn5CdD7Ec9oT5c55OWHiJ0wbxkYouegh7EG+vzgin1cfYuVHo0TpEEwSkpnPMV0iNw8GyckA9M= Received: from CY1PR07CA0017.namprd07.prod.outlook.com (2a01:111:e400:c60a::27) by SN1PR07MB4111.namprd07.prod.outlook.com (2603:10b6:802:30::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Sun, 18 Nov 2018 10:10:47 +0000 Received: from CO1NAM05FT010.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::208) by CY1PR07CA0017.outlook.office365.com (2a01:111:e400:c60a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.20 via Frontend Transport; Sun, 18 Nov 2018 10:10:47 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning cadence.com discourages use of 158.140.1.28 as permitted sender) Received: from sjmaillnx2.cadence.com (158.140.1.28) by CO1NAM05FT010.mail.protection.outlook.com (10.152.96.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.3 via Frontend Transport; Sun, 18 Nov 2018 10:10:43 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx2.cadence.com (8.14.4/8.14.4) with ESMTP id wAIAAb5O029622 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Sun, 18 Nov 2018 02:10:42 -0800 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 18 Nov 2018 11:10:42 +0100 Received: from lvlogina.cadence.com (10.165.176.102) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Sun, 18 Nov 2018 11:10:42 +0100 Received: from lvlogina.cadence.com (localhost.localdomain [127.0.0.1]) by lvlogina.cadence.com (8.14.4/8.14.4) with ESMTP id wAIAAcOt031155; Sun, 18 Nov 2018 10:10:38 GMT Received: (from pawell@localhost) by lvlogina.cadence.com (8.14.4/8.14.4/Submit) id wAIAAcvX031111; Sun, 18 Nov 2018 10:10:38 GMT From: Pawel Laszczak To: CC: , , , , , , , , , , , , "Pawel Laszczak" Subject: [RFC PATCH v2 06/15] usb:cdns3: Adds Host support Date: Sun, 18 Nov 2018 10:09:02 +0000 Message-ID: <1542535751-16079-7-git-send-email-pawell@cadence.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1542535751-16079-1-git-send-email-pawell@cadence.com> References: <1542535751-16079-1-git-send-email-pawell@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.28;IPV:CAL;SCL:-1;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(346002)(376002)(136003)(396003)(2980300002)(36092001)(199004)(189003)(2616005)(126002)(476003)(26826003)(478600001)(47776003)(36756003)(51416003)(2351001)(8936002)(87636003)(217873002)(11346002)(16586007)(316002)(42186006)(486006)(246002)(8676002)(86362001)(446003)(50226002)(4720700003)(6916009)(6666004)(54906003)(356004)(2906002)(426003)(50466002)(5660300001)(186003)(26005)(48376002)(6346003)(14444005)(336012)(105596002)(106466001)(305945005)(4326008)(7636002)(76176011)(107886003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB4111;H:sjmaillnx2.cadence.com;FPR:;SPF:SoftFail;LANG:en;PTR:corp.cadence.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM05FT010;1:cFhnbc3uqYDz0USn8kGfBhyWZ6but+5kKuZpHNaGjm6bVrCWr5Scsla+VQXSoWigc0pFydtrELIoMeXmzl/U6KrVdh4VEgeR/lr1s1wiWRH+WONaFW6x+rIyMaGQauMu X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fdd9f0f-1bbe-465d-d0ca-08d64d3e1b99 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060);SRVR:SN1PR07MB4111; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4111;3:Rdks9An4qZl7cDwNZwgIsXPElD8kt7AbnyfGKYYhVU3LQRkoWCwUpWxJbkfrAPqVglyIpNav/Jt51eO5JepyobGpIfCvYtefI9uOD3snPI+vzjJKkkOozQuIV6v6kbqohIQe/mHQOLJ5gj2sS4JO69+g02APP4WDTAsFSJDIBSYifGSancVlX8Rj7M3owszKYB4oWiIihCzR2iA0Eed3ps38NHw8iO4b+kC9YXHCC0+BdTzRAIcCPO0Oztol8tes6/wXN/0HZ1lbJPIqlqsAJq/aHFq7txkXyNb3k2zvO3hwidkDzlMcdJslHgJsWdK/okH091txpuz8kHUx6thg+QxItgkXPm5RWIoDekCUtAM=;25:MS8s/f4axwKEjOlm39sVo2ynk0Tql/T/UdVOK11Ix5Kd6hfMPevTBycGG5o9KxJQXAlKWmkm8DQzyY0M5B0XNuSBJfylQ8NS/FxjGxhKVJ8QgJadH7TINsB3uemIyA6WsU9b/lx8YpvB14nuTXD44pe8xzKDSDzalHhQNY5xCVrQ99yJpjTgV2oe0znXaI++9oxWUuQXMr+CUzBGvAsZ2/+5Ge8jPVwTdBVk0QaCTd9+WBDnoHiWqpUpRX0tkmTSKlWv0gr2ANvV9M1w2BrXmbvOENEzOm5QJzmOKYL7+DQCLAsWot3SsnQgT4DR5JY8KJYFeZpjF69zV3mMfkSPoQ== X-MS-TrafficTypeDiagnostic: SN1PR07MB4111: X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4111;31:uGXsOK8zvi2hRmC+w7c64RKcWuTT1SuXAF8Sg5NWouQurSA4/U959OT4Oov1GCG+eHlYA6CJROz94FuICKNJBTAfs0e+PWm1w0DlwqtrmdYfMBXQ5qavdh1bpxSM6M2fNp1b0EvqJydvWgLbLcnsHM/2Dz2vNEREvdaDsasf8y3YLtMRdrZJMjhFa7g/iGPla4Tnm4ccJz2S+ryIAZdanHnAHhkGzDvxGXE413SbBew=;20:XIi9EpFeLuTv5iSqTDIv0kriCJe+wVlZtDL6O/tY4fcPDtD7uoVAnKvDSM/AXhvqKisIUICrgQOTbTC8isQSIp2z0ilVXSaqBen6P9rIOmKJIFNoRGRGyv+ni7gUKfGlY48Za/lvi5ELYp7YlbnQa6YTxMrsNW4GWa7Eu3yy3b1P5grLJHH843+8y9XMvKkLkKhkwnQBRvh0aHGtI8pCN1baZv49S6LQfxsreq2O+MNfRNcsDDpl8hCj0AeATplSsbDg1teVbkBirF3mWG2uUi7wuqztq988VmBDZxkv5lKWi3GlnV9j3dhTk3Eu0E4bykoG/rFMn/VfjKAvwwOC3ZN/7Y11Xj9Njsdbz+xHs5EIXY4DFOYy3zQnuwit6JskArKXouhtTR8SItpGPqbmnvCg+1+tPko+8HHcRkvYThi+ot1lBcGXuNPDB9qqUqo0N1LEYQacBiDNr/M00BtA1nRTiANyq06ZgxKCg0z5hbXb+cGjaN/urrTGMXkidj6p X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93003095)(3231431)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:SN1PR07MB4111;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB4111; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4111;4:ULdkWdyP5qkY9W5ZcRIvHS+bppwmY8uOm5Y+OS5HqU6CahAndjCGIt2dLv7OBhN2TQUvzc7oL3vrgpYTTDYCfomiAHkKEpSCoOGP5Pp+XVDPXeTgoTbuXw6SfGc5mF7Cs6Nro4iwXI6wLpCtklyM2CAGOC0/+jXjSG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NKzC6BlIJsKevAGhoq60/83XHp5jByzvmQVJ6GulryjRKqOz/qDecyhnaRQBMfEfkfM23YdI0n7eM5mYC/kKwnkCAQR8BOKuU2oH+awFGEMGXw==;5:shYQgXD2y4Kik7A8cnPIDics6LSnSdGtevVvA9DAl9/wkRd8P2OioAU2NWvz+HoU5nPu2dzBpIFAfiDlWB8cIDCTVAK64TU19MKAs8xWIbLF2b4TXLs2M3vWsKJMsDeltFXBmjwmmDWsonfEz09GfZIebs+uxVCrxqtnbwsUcGA=;7:IYV1s4Uax/E6zvMZf+u0yqhlHezUQC1IdC+u1Ijr2Cgx8xKvv4928P5CjQzikYOHbdx9vEtEGhKMWZzk+b8osviWvtcIxZrJ5B6oi2xc2cDPKtTkg4YwMKb9XxpqL/h1DsB1SKm8yKVAFoKlbifZ7Q== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4111;20:nFFqVqsLGD+K7IoSA6PdhGNe4cTjY8jkQbnet3n3Mr/DUz4ItqjNVLmInKFPvZhG+6y5cSvUijAJ80LZm7HeH1qM3wr2jbopJXN+xGzcnmkqopxpmw8vl7w6HfrlI4PldNXcy2Gx0AVFWbazCP8V1MtmDHXJZnMxDNF5455A6LN34DRQ2AyvWUaRrf0Nw9FRvxY3N+ageI62z1wN3oyhH4+XL6+M/WYv04lO7vyAwr9IwoyOl6w/lVJdYNsnnpGk X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2018 10:10:43.2754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fdd9f0f-1bbe-465d-d0ca-08d64d3e1b99 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[158.140.1.28];Helo=[sjmaillnx2.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB4111 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 a:mx-sanjose2.Cadence.COM a:mx-sanjose4.Cadence.COM a:mx-sanjose5.Cadence.COM include:mktomail.com include:spf-0014ca01.pphosted.com include:spf.protection.outlook.com include:auth.msgapp.com include:spf.mandrillapp.com ~all X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-18_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=913 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811180096 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch adds host-export.h and host.c file and mplements functions that allow to initialize, start and stop XHCI host driver. Signed-off-by: Pawel Laszczak --- drivers/usb/cdns3/Kconfig | 10 ++ drivers/usb/cdns3/Makefile | 1 + drivers/usb/cdns3/core.c | 7 +- drivers/usb/cdns3/host-export.h | 30 ++++ drivers/usb/cdns3/host.c | 256 ++++++++++++++++++++++++++++++++ 5 files changed, 302 insertions(+), 2 deletions(-) create mode 100644 drivers/usb/cdns3/host-export.h create mode 100644 drivers/usb/cdns3/host.c diff --git a/drivers/usb/cdns3/Kconfig b/drivers/usb/cdns3/Kconfig index eb22a8692991..d92bc3d68eb0 100644 --- a/drivers/usb/cdns3/Kconfig +++ b/drivers/usb/cdns3/Kconfig @@ -10,6 +10,16 @@ config USB_CDNS3 if USB_CDNS3 +config USB_CDNS3_HOST + bool "Cadence USB3 host controller" + depends on USB_XHCI_HCD + help + Say Y here to enable host controller functionality of the + cadence driver. + + Host controller is compliance with XHCI so it will use + standard XHCI driver. + config USB_CDNS3_PCI_WRAP tristate "PCIe-based Platforms" depends on USB_PCI && ACPI diff --git a/drivers/usb/cdns3/Makefile b/drivers/usb/cdns3/Makefile index e779b2a2f8eb..976117ba67ff 100644 --- a/drivers/usb/cdns3/Makefile +++ b/drivers/usb/cdns3/Makefile @@ -2,4 +2,5 @@ obj-$(CONFIG_USB_CDNS3) += cdns3.o obj-$(CONFIG_USB_CDNS3_PCI_WRAP) += cdns3-pci.o cdns3-y := core.o drd.o +cdns3-$(CONFIG_USB_CDNS3_HOST) += host.o cdns3-pci-y := cdns3-pci-wrap.o diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index dbee4325da7f..4cb820be9ff3 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -17,6 +17,7 @@ #include "gadget.h" #include "core.h" +#include "host-export.h" #include "drd.h" static inline struct cdns3_role_driver *cdns3_get_current_role_driver(struct cdns3 *cdns) @@ -98,7 +99,8 @@ static int cdns3_core_init_role(struct cdns3 *cdns) } if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) { - //TODO: implements host initialization + if (cdns3_host_init(cdns)) + dev_info(dev, "doesn't support host\n"); } if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) { @@ -142,7 +144,7 @@ static irqreturn_t cdns3_irq(int irq, void *data) static void cdns3_remove_roles(struct cdns3 *cdns) { - //TODO: implements this function + cdns3_host_remove(cdns); } static int cdns3_do_role_switch(struct cdns3 *cdns, enum cdns3_roles role) @@ -410,6 +412,7 @@ static struct platform_driver cdns3_driver = { static int __init cdns3_driver_platform_register(void) { + cdns3_host_driver_init(); return platform_driver_register(&cdns3_driver); } module_init(cdns3_driver_platform_register); diff --git a/drivers/usb/cdns3/host-export.h b/drivers/usb/cdns3/host-export.h new file mode 100644 index 000000000000..f8f3b230b472 --- /dev/null +++ b/drivers/usb/cdns3/host-export.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Cadence USBSS DRD Driver -Host Export APIs + * + * Copyright (C) 2017 NXP + * + * Authors: Peter Chen + */ +#ifndef __LINUX_CDNS3_HOST_EXPORT +#define __LINUX_CDNS3_HOST_EXPORT + +#ifdef CONFIG_USB_CDNS3_HOST + +int cdns3_host_init(struct cdns3 *cdns); +void cdns3_host_remove(struct cdns3 *cdns); +void cdns3_host_driver_init(void); + +#else + +static inline int cdns3_host_init(struct cdns3 *cdns) +{ + return -ENXIO; +} + +static inline void cdns3_host_remove(struct cdns3 *cdns) { } +static inline void cdns3_host_driver_init(void) {} + +#endif /* CONFIG_USB_CDNS3_HOST */ + +#endif /* __LINUX_CDNS3_HOST_EXPORT */ diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c new file mode 100644 index 000000000000..0dd47976cb28 --- /dev/null +++ b/drivers/usb/cdns3/host.c @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Cadence USBSS DRD Driver - host side + * + * Copyright (C) 2018 Cadence Design Systems. + * Copyright (C) 2018 NXP + * + * Authors: Peter Chen + * Pawel Laszczak + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../host/xhci.h" +#include "core.h" +#include "host-export.h" + +static struct hc_driver __read_mostly xhci_cdns3_hc_driver; + +static void xhci_cdns3_quirks(struct device *dev, struct xhci_hcd *xhci) +{ + /* + * As of now platform drivers don't provide MSI support so we ensure + * here that the generic code does not try to make a pci_dev from our + * dev struct in order to setup MSI + */ + xhci->quirks |= XHCI_PLAT; +} + +static int xhci_cdns3_setup(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + u32 command; + int ret; + + ret = xhci_gen_setup(hcd, xhci_cdns3_quirks); + if (ret) + return ret; + + /* set usbcmd.EU3S */ + command = readl(&xhci->op_regs->command); + command |= CMD_PM_INDEX; + writel(command, &xhci->op_regs->command); + + return 0; +} + +static const struct xhci_driver_overrides xhci_cdns3_overrides __initconst = { + .extra_priv_size = sizeof(struct xhci_hcd), + .reset = xhci_cdns3_setup, +}; + +struct cdns3_host { + struct device dev; + struct usb_hcd *hcd; +}; + +static irqreturn_t cdns3_host_irq(struct cdns3 *cdns) +{ + struct device *dev = cdns->host_dev; + struct usb_hcd *hcd; + + if (dev) + hcd = dev_get_drvdata(dev); + else + return IRQ_NONE; + + if (hcd) + return usb_hcd_irq(cdns->irq, hcd); + else + return IRQ_NONE; +} + +static void cdns3_host_release(struct device *dev) +{ + struct cdns3_host *host = container_of(dev, struct cdns3_host, dev); + + kfree(host); +} + +static int cdns3_host_start(struct cdns3 *cdns) +{ + struct cdns3_host *host; + struct device *dev; + struct device *sysdev; + struct xhci_hcd *xhci; + int ret; + + host = kzalloc(sizeof(*host), GFP_KERNEL); + if (!host) + return -ENOMEM; + + dev = &host->dev; + dev->release = cdns3_host_release; + dev->parent = cdns->dev; + dev_set_name(dev, "xhci-cdns3"); + cdns->host_dev = dev; + ret = device_register(dev); + if (ret) + goto err1; + + sysdev = cdns->dev; + /* Try to set 64-bit DMA first */ + if (WARN_ON(!sysdev->dma_mask)) + /* Platform did not initialize dma_mask */ + ret = dma_coerce_mask_and_coherent(sysdev, + DMA_BIT_MASK(64)); + else + ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(64)); + + /* If setting 64-bit DMA mask fails, fall back to 32-bit DMA mask */ + if (ret) { + ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(32)); + if (ret) + return ret; + } + + pm_runtime_set_active(dev); + pm_runtime_no_callbacks(dev); + pm_runtime_enable(dev); + host->hcd = __usb_create_hcd(&xhci_cdns3_hc_driver, sysdev, dev, + dev_name(dev), NULL); + if (!host->hcd) { + ret = -ENOMEM; + goto err2; + } + + host->hcd->regs = cdns->xhci_regs; + host->hcd->rsrc_start = cdns->xhci_res->start; + host->hcd->rsrc_len = resource_size(cdns->xhci_res); + + device_wakeup_enable(host->hcd->self.controller); + xhci = hcd_to_xhci(host->hcd); + + xhci->main_hcd = host->hcd; + xhci->shared_hcd = __usb_create_hcd(&xhci_cdns3_hc_driver, sysdev, dev, + dev_name(dev), host->hcd); + if (!xhci->shared_hcd) { + ret = -ENOMEM; + goto err3; + } + + host->hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); + xhci->shared_hcd->tpl_support = host->hcd->tpl_support; + ret = usb_add_hcd(host->hcd, 0, IRQF_SHARED); + if (ret) + goto err4; + + ret = usb_add_hcd(xhci->shared_hcd, 0, IRQF_SHARED); + if (ret) + goto err5; + + device_set_wakeup_capable(dev, true); + + return 0; + +err5: + usb_remove_hcd(host->hcd); +err4: + usb_put_hcd(xhci->shared_hcd); +err3: + usb_put_hcd(host->hcd); +err2: + device_del(dev); +err1: + put_device(dev); + cdns->host_dev = NULL; + return ret; +} + +static void cdns3_host_stop(struct cdns3 *cdns) +{ + struct device *dev = cdns->host_dev; + struct xhci_hcd *xhci; + struct usb_hcd *hcd; + + if (dev) { + hcd = dev_get_drvdata(dev); + xhci = hcd_to_xhci(hcd); + usb_remove_hcd(xhci->shared_hcd); + usb_remove_hcd(hcd); + synchronize_irq(cdns->irq); + usb_put_hcd(xhci->shared_hcd); + usb_put_hcd(hcd); + cdns->host_dev = NULL; + pm_runtime_set_suspended(dev); + pm_runtime_disable(dev); + device_del(dev); + put_device(dev); + } +} + +#if CONFIG_PM +static int cdns3_host_suspend(struct cdns3 *cdns, bool do_wakeup) +{ + struct device *dev = cdns->host_dev; + struct xhci_hcd *xhci; + + if (!dev) + return 0; + + xhci = hcd_to_xhci(dev_get_drvdata(dev)); + return xhci_suspend(xhci, do_wakeup); +} + +static int cdns3_host_resume(struct cdns3 *cdns, bool hibernated) +{ + struct device *dev = cdns->host_dev; + struct xhci_hcd *xhci; + + if (!dev) + return 0; + + xhci = hcd_to_xhci(dev_get_drvdata(dev)); + return xhci_resume(xhci, hibernated); +} +#endif /* CONFIG_PM */ + +int cdns3_host_init(struct cdns3 *cdns) +{ + struct cdns3_role_driver *rdrv; + + rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL); + if (!rdrv) + return -ENOMEM; + + rdrv->start = cdns3_host_start; + rdrv->stop = cdns3_host_stop; + rdrv->irq = cdns3_host_irq; +#if CONFIG_PM + rdrv->suspend = cdns3_host_suspend; + rdrv->resume = cdns3_host_resume; +#endif /* CONFIG_PM */ + rdrv->name = "host"; + cdns->roles[CDNS3_ROLE_HOST] = rdrv; + + return 0; +} + +void cdns3_host_remove(struct cdns3 *cdns) +{ + cdns3_host_stop(cdns); +} + +void __init cdns3_host_driver_init(void) +{ + xhci_init_driver(&xhci_cdns3_hc_driver, &xhci_cdns3_overrides); +}