From patchwork Tue Oct 16 05:01:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10643097 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 A67051057 for ; Tue, 16 Oct 2018 05:02:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E1F29C1D for ; Tue, 16 Oct 2018 05:02:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D78029C36; Tue, 16 Oct 2018 05:02:11 +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 1FE1129C1D for ; Tue, 16 Oct 2018 05:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727567AbeJPMuo (ORCPT ); Tue, 16 Oct 2018 08:50:44 -0400 Received: from mail-ve1eur01on0048.outbound.protection.outlook.com ([104.47.1.48]:46544 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726990AbeJPMun (ORCPT ); Tue, 16 Oct 2018 08:50:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hWeIemQJ+uHzUcsTuhR+PWzXooglmgxBI1xJRlex8E8=; b=wwVYsIL1tU9KeLjSWOx/X87OUsTZtr4sKIPjYCEDt7HMV0qVj3aQcaQ/7cwaOPoGKODJvsoZD+oR+zae69NKTNtvrK1vnrW7+VZxhXHoYURGxBVMd58qK8yJ0Fgc1NQbc0ULG8BPrr1wKU2p8n5qcTqYzzN/9Jfnj1n0bcVkV+c= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4976.eurprd04.prod.outlook.com (20.177.49.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Tue, 16 Oct 2018 05:01:19 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9%4]) with mapi id 15.20.1228.027; Tue, 16 Oct 2018 05:01:19 +0000 From: Peter Chen To: "linux-usb@vger.kernel.org" , "frieder.schrempf@exceet.de" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , Peter Chen Subject: [PATCH 1/4] usb: chipidea: add flag for imx hsic implementation Thread-Topic: [PATCH 1/4] usb: chipidea: add flag for imx hsic implementation Thread-Index: AQHUZQ1GQt3j0WYTh0Woz4dxLZdXFQ== Date: Tue, 16 Oct 2018 05:01:19 +0000 Message-ID: <20181016045846.2345-2-peter.chen@nxp.com> References: <20181016045846.2345-1-peter.chen@nxp.com> In-Reply-To: <20181016045846.2345-1-peter.chen@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.14.1 x-clientproxiedby: HK0PR03CA0027.apcprd03.prod.outlook.com (2603:1096:203:2f::15) To VI1PR04MB5327.eurprd04.prod.outlook.com (2603:10a6:803:60::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peter.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB4976;6:lY+a1xfJgZSi8jU5NDH5Aeqj4ckgWmGxz3v/zfJ2GTEnPPp4RM4P42iBMjnIN3TaFO/32ShGp+qd/GBj5vb5kdcZjROtRCzKApiPxIoT32pKlhqBmxpZuVHtXsSWazzeGp+B33kupdiB0Xhuq2xzFqSwCWiKWK7DOb+Uqul+QhMyvaPcAcNDZIomix21NJtP8sh3g9MBNXp6YyLeezUHA/s4BkEN0dBMoEYr2mjNKJmMucRLsYMUH/p6bFio9BbbuF4WMNeUmksZYGxg0FxGqowGtypnu8LGuZi+zeqMUsPs7ttIAlD3EU0Pr5OqTa53ZpyIDJfEYLkNrZE5tw1p/0X0Gv7IupPH53yY0gOecbI5AEPtpqrLjilppqXsX+PrsfEJIjDqeTxlCdA4+cn9S+K3MACaUiNafQuLLGB10Ww3s6GSvYb5Qqy6/XSLNRKWuagMD5W2kkmH9tcawvSrJQ==;5:YpacYqQU6rX18DN1d0mDo790ZdgKl/cHVJnX/HNLWx6CMMafMr66ejgLng+N3/J5Ctf/zYx3OBLXVXepIRsmKP0n6FsZxNaIjhUT3zCfFS4uEuzQ/Aw5xu3caermQaNTV8dUEMF0zmF1exhkAfRnHQIz49tzY4nW88pg2yPxgMU=;7:vMgaIzqVzPcYrYDbeC1m3i6twZuKS+YFMcm+MEu8VwZygsDCl0k19IoRS2MxKPLQ2nJhw1u9lrn2pdr457WUkaZTX2IxANzEwMMBLc5N8JigrptWXlN05uVpj25OejziXctyRXPIcHpwbr7gjbtOdan/hegTZdriva98Uks62K5iUEZM/E72jL2AkldyeJmspcP77X7UPJahJnDWaoHbahFgLy6AUWka3Kpl4GsiWDk9VsWPLzrRGDTpsFHRFSHF x-ms-office365-filtering-correlation-id: 33cbdd19-6cca-4b27-a522-08d6332468b3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4976; x-ms-traffictypediagnostic: VI1PR04MB4976: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:VI1PR04MB4976;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4976; x-forefront-prvs: 0827D7ACB9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(136003)(346002)(376002)(396003)(189003)(199004)(14444005)(25786009)(11346002)(476003)(6512007)(2616005)(2906002)(478600001)(6486002)(4326008)(110136005)(446003)(6506007)(54906003)(386003)(6436002)(76176011)(71190400001)(71200400001)(102836004)(2900100001)(486006)(53936002)(52116002)(186003)(99286004)(44832011)(66066001)(26005)(2501003)(5250100002)(305945005)(14454004)(97736004)(316002)(6116002)(8676002)(7736002)(1076002)(8936002)(3846002)(5660300001)(256004)(36756003)(86362001)(106356001)(81156014)(105586002)(81166006)(68736007)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4976;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: gyVbiUHnRgExuXbu/NmK6f0/pczkkMIhUFIAncJ0e2vLnpAxodvUBmuKVj1aNnjO3/bCdYsF7YKm5Mj3rMoL/NQa6TYqP8ycQoO4tIRvwh/gPAqCXdAdqI973oOPpjjtgM/RQR4rmr3jwSdlQhRcnwvTaKInxbzD0Eb6C75GXTQP5fXXkgkFATIHG6HiSWpWKfyRZJpJDtlZAvrl+1HKuDcfK1qVX7XvFZbG+e+WPbo1ySlysf4pEIdE9DxsNMx2arqY63M3QES5fGftlPs9rRYNU9SfbSEEqGQsebehE6tEPtOAVu5YizObTayzxj9yXzXKkmfANqV7k496TpqUV+gjmUV8fxxo3EBMDBxrir4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33cbdd19-6cca-4b27-a522-08d6332468b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2018 05:01:19.3040 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4976 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 NXP (Freecale) imx HSIC design has some special requirements, add some flags at host code to handle them. Signed-off-by: Peter Chen --- drivers/usb/chipidea/host.c | 24 ++++++++++++++++++++++++ include/linux/usb/chipidea.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index d858a82c4f44..d74a13d7c21c 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -28,6 +28,20 @@ struct ehci_ci_priv { struct regulator *reg_vbus; }; +/* This function is used to override WKCN, WKDN, and WKOC */ +static void ci_ehci_override_wakeup_flag(struct ehci_hcd *ehci, + u32 __iomem *reg, u32 flags, bool set) +{ + u32 val = ehci_readl(ehci, reg); + + if (set) + val |= flags; + else + val &= ~flags; + + ehci_writel(ehci, val, reg); +} + static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -170,6 +184,11 @@ static int host_start(struct ci_hdrc *ci) otg->host = &hcd->self; hcd->self.otg_port = 1; } + + if (ci->platdata->notify_event && + (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC)) + ci->platdata->notify_event + (ci, CI_HDRC_IMX_HSIC_ACTIVE_EVENT); } return ret; @@ -218,6 +237,8 @@ void ci_hdrc_host_destroy(struct ci_hdrc *ci) static int ci_ehci_bus_suspend(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); + struct device *dev = hcd->self.controller; + struct ci_hdrc *ci = dev_get_drvdata(dev); int port; u32 tmp; @@ -249,6 +270,9 @@ static int ci_ehci_bus_suspend(struct usb_hcd *hcd) * It needs a short delay between set RS bit and PHCD. */ usleep_range(150, 200); + if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) + ci_ehci_override_wakeup_flag(ehci, reg, + PORT_WKDISC_E | PORT_WKCONN_E, false); break; } } diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 63758c399e4e..911e05af671e 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -60,9 +60,12 @@ struct ci_hdrc_platform_data { #define CI_HDRC_OVERRIDE_RX_BURST BIT(11) #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */ #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13) +#define CI_HDRC_IMX_IS_HSIC BIT(14) enum usb_dr_mode dr_mode; #define CI_HDRC_CONTROLLER_RESET_EVENT 0 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 +#define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2 +#define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3 int (*notify_event) (struct ci_hdrc *ci, unsigned event); struct regulator *reg_vbus; struct usb_otg_caps ci_otg_caps; From patchwork Tue Oct 16 05:01:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10643091 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 D79761057 for ; Tue, 16 Oct 2018 05:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C345929BCF for ; Tue, 16 Oct 2018 05:02:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3FFF29C1D; Tue, 16 Oct 2018 05:02:04 +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 AEE5E29BCF for ; Tue, 16 Oct 2018 05:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeJPMuh (ORCPT ); Tue, 16 Oct 2018 08:50:37 -0400 Received: from mail-ve1eur01on0074.outbound.protection.outlook.com ([104.47.1.74]:41568 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727008AbeJPMuh (ORCPT ); Tue, 16 Oct 2018 08:50:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fhG95nNWPniBGy6p89S46SH/eg5HY/LP913EJh8mQuU=; b=sa4iBKqmau7z9MbtDA2FTaR5qhnIQbv3Z0YJ0k1oB0OoK1B2EgfQfLZjR0G/+AT/LqBXM0ELFjN+W1lA5A97/8qZinDRFWT3yNiQM59YZbKjdbqi6cGzid8h+LL76JeNAB5JJ/RLzCX+vJ2hIGyKk73cCfnW9btCq7EDdR98X68= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4976.eurprd04.prod.outlook.com (20.177.49.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Tue, 16 Oct 2018 05:01:23 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9%4]) with mapi id 15.20.1228.027; Tue, 16 Oct 2018 05:01:23 +0000 From: Peter Chen To: "linux-usb@vger.kernel.org" , "frieder.schrempf@exceet.de" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , Peter Chen Subject: [PATCH 2/4] usb: chipidea: imx: add HSIC support Thread-Topic: [PATCH 2/4] usb: chipidea: imx: add HSIC support Thread-Index: AQHUZQ1I+VkkZR+Q7kycgoib4CbYZQ== Date: Tue, 16 Oct 2018 05:01:22 +0000 Message-ID: <20181016045846.2345-3-peter.chen@nxp.com> References: <20181016045846.2345-1-peter.chen@nxp.com> In-Reply-To: <20181016045846.2345-1-peter.chen@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.14.1 x-clientproxiedby: HK0PR03CA0027.apcprd03.prod.outlook.com (2603:1096:203:2f::15) To VI1PR04MB5327.eurprd04.prod.outlook.com (2603:10a6:803:60::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peter.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB4976;6:o+OKm58A7VUmzgfm1Ln5Fc8Fa/Ex9yXR43vbHklECSzxClmAHf0nOfmXleEEJ9hEnUCqJSDSN6EzoJLJ26OjcOGsDN67voDf0NWRvGpCNDMVasmodl1ZKUSY4Zl3D0TxTVmhXPel313AycJ7GVgpR+RhEfJpPnXiUi7XM2dSaRt5RdgLwz/4OGO+pMDuATZ4IDrwxttZ8xUh75xztULJUAzLLZvnQOXmc2Q0Qw0buCSXdfRP1RQwKt38jYNjg5TWiuc6IYIQtsvE/p3bf4Hz47uB/bah4Fvwk2y1PfmyQGNOio8Kza8uSDPDla4eeBarJVWr7gXLTt3qDzwvg66bVSn9vUiUf1fHzu8abiIZKIqt8jMeZUSvRsYC9dQsv3x91nw51+JTqmoxL3DTfcpfalTg0zawnq21TXBB0wNfvR3Ob4IcvHcOSkzDBj3TwOrF3MC2bDGKolfeTiwgdYd5wg==;5:HvzMV2EXBihI9u9S3VCJXFEktU7YFj+5ULP0GcfKXkJprYmNRxhP0yWRVtdiYmHYNbEtx4RNuKCZZPXuKiVJT87FPel4Bk1W+fwF5FT/jq/PQXvi83umYv2k54CRMdJQsyDfezCf22C3UWtP0gtA/+zuADNf2xiAix3PMT2KqNk=;7:ZcfNw+9cJ4B+UwwPA+G7YthfH/t2X4Qtc/U5uX8sKwf7CBrDFIuZQ9GmIhJiDLHIbdVQ3H5agT+no1o0a7jE6IHWQq43mnK61QMWXVlKttTCUm4BcGpTXY1Y6u/NAmXeQAZFS4JnUxoQld/HkyRYmygSts9r7hoH7GxDM4nKX+sP1cFUwPZbXOSAWyu7d2r5gzfqdKoJyO0VKhOC77M7H+fKkdsusrETDHWXpH72resQTGI7HWFUZT0TpwDwlKj2 x-ms-office365-filtering-correlation-id: 771533df-11e3-4112-e38f-08d633246a72 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4976; x-ms-traffictypediagnostic: VI1PR04MB4976: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:VI1PR04MB4976;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4976; x-forefront-prvs: 0827D7ACB9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(136003)(346002)(376002)(396003)(189003)(199004)(14444005)(25786009)(53946003)(11346002)(476003)(6512007)(2616005)(2906002)(478600001)(6486002)(4326008)(110136005)(446003)(6506007)(54906003)(386003)(6436002)(76176011)(71190400001)(71200400001)(102836004)(2900100001)(486006)(53936002)(52116002)(186003)(99286004)(44832011)(66066001)(26005)(2501003)(5250100002)(305945005)(14454004)(97736004)(316002)(6116002)(8676002)(7736002)(1076002)(8936002)(3846002)(5660300001)(256004)(36756003)(86362001)(106356001)(81156014)(105586002)(81166006)(68736007)(4744004)(50226002)(575784001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4976;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: h9BWmkg3xQgGEen4UC0vlXCZBgkzOWmWTuyaCX5OhlFAHInjXvKqmyle+/rdxgl5wM9+dm7qyClVLt6d5XbfvpyhVlP9cwE6SX2Za3gR9bRg5GwkCUdy8zPXluZGnBKFuXso1xBFipBNy0ym9ACevzMl0AQn1aPaCJvZ8ZrbOZF1QIkR871KrtzZpDbJrQQotmhVx4uxjdDWdalfJSIy9UBaqa33Julrz1enlgg/6e3UwzahVWj9EyJqlfrNxNoewf1idcAFYjrVQoWqKw9q9vgXvS05CABRXMIcNZFdUNsPAXtlb292HJOPRui+/bNVBY0k4XzzG1IfoCnAvoGJp6ecy3LJSkKGhWFj2HJ5+sc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 771533df-11e3-4112-e38f-08d633246a72 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2018 05:01:22.1910 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4976 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 To support imx HSIC, there are some special requirement: - The HSIC pad is 1.2v, it may need to supply from external - The data/strobe pin needs to be pulled down first, and after host mode is initialized, the strobe pin needs to be pulled up - During the USB suspend/resume, special setting is needed Signed-off-by: Peter Chen --- drivers/usb/chipidea/ci_hdrc_imx.c | 153 +++++++++++++++++++++++++++++++++---- drivers/usb/chipidea/ci_hdrc_imx.h | 9 ++- drivers/usb/chipidea/usbmisc_imx.c | 131 +++++++++++++++++++++++++++++++ 3 files changed, 274 insertions(+), 19 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 09b37c0d075d..d566771fc77a 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -85,6 +85,9 @@ struct ci_hdrc_imx_data { bool supports_runtime_pm; bool override_phy_control; bool in_lpm; + struct pinctrl *pinctrl; + struct pinctrl_state *pinctrl_hsic_active; + struct regulator *hsic_pad_regulator; /* SoC before i.mx6 (except imx23/imx28) needs three clks */ bool need_three_clks; struct clk *clk_ipg; @@ -245,19 +248,58 @@ static void imx_disable_unprepare_clks(struct device *dev) } } +static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event) +{ + struct device *dev = ci->dev->parent; + struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); + int ret = 0; + + switch (event) { + case CI_HDRC_IMX_HSIC_ACTIVE_EVENT: + if (!IS_ERR(data->pinctrl) && + !IS_ERR(data->pinctrl_hsic_active)) { + ret = pinctrl_select_state(data->pinctrl, + data->pinctrl_hsic_active); + if (ret) + dev_err(dev, + "hsic_active select failed, err=%d\n", + ret); + return ret; + } + break; + case CI_HDRC_IMX_HSIC_SUSPEND_EVENT: + if (data->usbmisc_data) { + ret = imx_usbmisc_hsic_set_connect(data->usbmisc_data); + if (ret) + dev_err(dev, + "hsic_set_connect failed, err=%d\n", + ret); + return ret; + } + break; + default: + break; + } + + return ret; +} + static int ci_hdrc_imx_probe(struct platform_device *pdev) { struct ci_hdrc_imx_data *data; struct ci_hdrc_platform_data pdata = { .name = dev_name(&pdev->dev), .capoffset = DEF_CAPOFFSET, + .notify_event = ci_hdrc_imx_notify_event, }; int ret; const struct of_device_id *of_id; const struct ci_hdrc_imx_platform_flag *imx_platform_flag; struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct pinctrl_state *pinctrl_hsic_idle; - of_id = of_match_device(ci_hdrc_imx_dt_ids, &pdev->dev); + of_id = of_match_device(ci_hdrc_imx_dt_ids, dev); if (!of_id) return -ENODEV; @@ -268,19 +310,48 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, data); - data->usbmisc_data = usbmisc_get_init_data(&pdev->dev); + data->usbmisc_data = usbmisc_get_init_data(dev); if (IS_ERR(data->usbmisc_data)) return PTR_ERR(data->usbmisc_data); - ret = imx_get_clks(&pdev->dev); + data->pinctrl = devm_pinctrl_get(dev); + if (IS_ERR(data->pinctrl)) { + dev_dbg(dev, "pinctrl get failed, err=%ld\n", + PTR_ERR(data->pinctrl)); + } else { + pinctrl_hsic_idle = pinctrl_lookup_state(data->pinctrl, "idle"); + if (IS_ERR(pinctrl_hsic_idle)) { + dev_dbg(dev, + "pinctrl_hsic_idle lookup failed, err=%ld\n", + PTR_ERR(pinctrl_hsic_idle)); + } else { + ret = pinctrl_select_state(data->pinctrl, + pinctrl_hsic_idle); + if (ret) { + dev_err(dev, + "hsic_idle select failed, err=%d\n", + ret); + return ret; + } + } + + data->pinctrl_hsic_active = pinctrl_lookup_state(data->pinctrl, + "active"); + if (IS_ERR(data->pinctrl_hsic_active)) + dev_dbg(dev, + "pinctrl_hsic_active lookup failed, err=%ld\n", + PTR_ERR(data->pinctrl_hsic_active)); + } + + ret = imx_get_clks(dev); if (ret) return ret; - ret = imx_prepare_enable_clks(&pdev->dev); + ret = imx_prepare_enable_clks(dev); if (ret) return ret; - data->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0); + data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0); if (IS_ERR(data->phy)) { ret = PTR_ERR(data->phy); /* Return -EINVAL if no usbphy is available */ @@ -303,42 +374,72 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM) data->supports_runtime_pm = true; + if (of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) { + pdata.flags |= CI_HDRC_IMX_IS_HSIC; + data->usbmisc_data->hsic = 1; + data->hsic_pad_regulator = devm_regulator_get(dev, "hsic"); + if (PTR_ERR(data->hsic_pad_regulator) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto err_clk; + } else if (PTR_ERR(data->hsic_pad_regulator) == -ENODEV) { + /* no pad regualator is needed */ + data->hsic_pad_regulator = NULL; + } else if (IS_ERR(data->hsic_pad_regulator)) { + dev_err(dev, "Get hsic pad regulator error: %ld\n", + PTR_ERR(data->hsic_pad_regulator)); + ret = PTR_ERR(data->hsic_pad_regulator); + goto err_clk; + } + + if (data->hsic_pad_regulator) { + ret = regulator_enable(data->hsic_pad_regulator); + if (ret) { + dev_err(dev, + "Fail to enable hsic pad regulator\n"); + goto err_clk; + } + } + } + ret = imx_usbmisc_init(data->usbmisc_data); if (ret) { - dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); - goto err_clk; + dev_err(dev, "usbmisc init failed, ret=%d\n", ret); + goto disable_hsic_regulator; } - data->ci_pdev = ci_hdrc_add_device(&pdev->dev, + data->ci_pdev = ci_hdrc_add_device(dev, pdev->resource, pdev->num_resources, &pdata); if (IS_ERR(data->ci_pdev)) { ret = PTR_ERR(data->ci_pdev); if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, - "ci_hdrc_add_device failed, err=%d\n", ret); - goto err_clk; + dev_err(dev, "ci_hdrc_add_device failed, err=%d\n", + ret); + goto disable_hsic_regulator; } ret = imx_usbmisc_init_post(data->usbmisc_data); if (ret) { - dev_err(&pdev->dev, "usbmisc post failed, ret=%d\n", ret); + dev_err(dev, "usbmisc post failed, ret=%d\n", ret); goto disable_device; } if (data->supports_runtime_pm) { - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); } - device_set_wakeup_capable(&pdev->dev, true); + device_set_wakeup_capable(dev, true); return 0; disable_device: ci_hdrc_remove_device(data->ci_pdev); +disable_hsic_regulator: + if (data->hsic_pad_regulator) + ret = regulator_disable(data->hsic_pad_regulator); err_clk: - imx_disable_unprepare_clks(&pdev->dev); + imx_disable_unprepare_clks(dev); return ret; } @@ -355,6 +456,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev) if (data->override_phy_control) usb_phy_shutdown(data->phy); imx_disable_unprepare_clks(&pdev->dev); + if (data->hsic_pad_regulator) + regulator_disable(data->hsic_pad_regulator); return 0; } @@ -367,9 +470,19 @@ static void ci_hdrc_imx_shutdown(struct platform_device *pdev) static int __maybe_unused imx_controller_suspend(struct device *dev) { struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); + int ret = 0; dev_dbg(dev, "at %s\n", __func__); + if (data->usbmisc_data) { + ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, false); + if (ret) { + dev_err(dev, + "usbmisc hsic_set_clk failed, ret=%d\n", ret); + return ret; + } + } + imx_disable_unprepare_clks(dev); data->in_lpm = true; @@ -400,8 +513,16 @@ static int __maybe_unused imx_controller_resume(struct device *dev) goto clk_disable; } + ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, true); + if (ret) { + dev_err(dev, "usbmisc hsic_set_clk failed, ret=%d\n", ret); + goto hsic_set_clk_fail; + } + return 0; +hsic_set_clk_fail: + imx_usbmisc_set_wakeup(data->usbmisc_data, true); clk_disable: imx_disable_unprepare_clks(dev); return ret; diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 204275f47573..fcecab478934 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -14,10 +14,13 @@ struct imx_usbmisc_data { unsigned int oc_polarity:1; /* over current polarity if oc enabled */ unsigned int evdo:1; /* set external vbus divider option */ unsigned int ulpi:1; /* connected to an ULPI phy */ + unsigned int hsic:1; /* HSIC controlller */ }; -int imx_usbmisc_init(struct imx_usbmisc_data *); -int imx_usbmisc_init_post(struct imx_usbmisc_data *); -int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *, bool); +int imx_usbmisc_init(struct imx_usbmisc_data *data); +int imx_usbmisc_init_post(struct imx_usbmisc_data *data); +int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled); +int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data); +int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on); #endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */ diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index def80ff547e4..a66a15075200 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -64,10 +64,22 @@ #define MX6_BM_OVER_CUR_DIS BIT(7) #define MX6_BM_OVER_CUR_POLARITY BIT(8) #define MX6_BM_WAKEUP_ENABLE BIT(10) +#define MX6_BM_UTMI_ON_CLOCK BIT(13) #define MX6_BM_ID_WAKEUP BIT(16) #define MX6_BM_VBUS_WAKEUP BIT(17) #define MX6SX_BM_DPDM_WAKEUP_EN BIT(29) #define MX6_BM_WAKEUP_INTR BIT(31) + +#define MX6_USB_HSIC_CTRL_OFFSET 0x10 +/* Send resume signal without 480Mhz PHY clock */ +#define MX6SX_BM_HSIC_AUTO_RESUME BIT(23) +/* set before portsc.suspendM = 1 */ +#define MX6_BM_HSIC_DEV_CONN BIT(21) +/* HSIC enable */ +#define MX6_BM_HSIC_EN BIT(12) +/* Force HSIC module 480M clock on, even when in Host is in suspend mode */ +#define MX6_BM_HSIC_CLK_ON BIT(11) + #define MX6_USB_OTG1_PHY_CTRL 0x18 /* For imx6dql, it is host-only controller, for later imx6, it is otg's */ #define MX6_USB_OTG2_PHY_CTRL 0x1c @@ -94,6 +106,10 @@ struct usbmisc_ops { int (*post)(struct imx_usbmisc_data *data); /* It's called when we need to enable/disable usb wakeup */ int (*set_wakeup)(struct imx_usbmisc_data *data, bool enabled); + /* It's called before setting portsc.suspendM */ + int (*hsic_set_connect)(struct imx_usbmisc_data *data); + /* It's called during suspend/resume */ + int (*hsic_set_clk)(struct imx_usbmisc_data *data, bool enabled); }; struct imx_usbmisc { @@ -353,6 +369,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) writel(reg | MX6_BM_NON_BURST_SETTING, usbmisc->base + data->index * 4); + /* For HSIC controller */ + if (data->hsic) { + reg = readl(usbmisc->base + data->index * 4); + writel(reg | MX6_BM_UTMI_ON_CLOCK, + usbmisc->base + data->index * 4); + reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + + (data->index - 2) * 4); + reg |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON; + writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + + (data->index - 2) * 4); + } + spin_unlock_irqrestore(&usbmisc->lock, flags); usbmisc_imx6q_set_wakeup(data, false); @@ -360,6 +388,70 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) return 0; } +static int usbmisc_imx6_hsic_set_connect(struct imx_usbmisc_data *data) +{ + unsigned long flags; + u32 val, offset; + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); + int ret = 0; + + spin_lock_irqsave(&usbmisc->lock, flags); + if (data->index == 2 || data->index == 3) { + offset = (data->index - 2) * 4; + } else if (data->index == 0) { + /* + * For controllers later than imx7d (imx7d is included), + * each controller has its own non core register region. + * And the controllers before than imx7d, the 1st controller + * is not HSIC controller. + */ + offset = 0; + } else { + dev_err(data->dev, "index is error for usbmisc\n"); + offset = 0; + ret = -EINVAL; + } + + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); + if (!(val & MX6_BM_HSIC_DEV_CONN)) + writel(val | MX6_BM_HSIC_DEV_CONN, + usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); + spin_unlock_irqrestore(&usbmisc->lock, flags); + + return ret; +} + +static int usbmisc_imx6_hsic_set_clk(struct imx_usbmisc_data *data, bool on) +{ + unsigned long flags; + u32 val, offset; + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); + int ret = 0; + + spin_lock_irqsave(&usbmisc->lock, flags); + if (data->index == 2 || data->index == 3) { + offset = (data->index - 2) * 4; + } else if (data->index == 0) { + offset = 0; + } else { + dev_err(data->dev, "index is error for usbmisc\n"); + offset = 0; + ret = -EINVAL; + } + + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); + val |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON; + if (on) + val |= MX6_BM_HSIC_CLK_ON; + else + val &= ~MX6_BM_HSIC_CLK_ON; + writel(val, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); + spin_unlock_irqrestore(&usbmisc->lock, flags); + + return 0; +} + + static int usbmisc_imx6sx_init(struct imx_usbmisc_data *data) { void __iomem *reg = NULL; @@ -385,6 +477,13 @@ static int usbmisc_imx6sx_init(struct imx_usbmisc_data *data) spin_unlock_irqrestore(&usbmisc->lock, flags); } + /* For HSIC controller */ + if (data->hsic) { + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); + val |= MX6SX_BM_HSIC_AUTO_RESUME; + writel(val, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); + } + return 0; } @@ -454,6 +553,7 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK; writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID, usbmisc->base + MX7D_USBNC_USB_CTRL2); + spin_unlock_irqrestore(&usbmisc->lock, flags); usbmisc_imx7d_set_wakeup(data, false); @@ -481,6 +581,8 @@ static const struct usbmisc_ops imx53_usbmisc_ops = { static const struct usbmisc_ops imx6q_usbmisc_ops = { .set_wakeup = usbmisc_imx6q_set_wakeup, .init = usbmisc_imx6q_init, + .hsic_set_connect = usbmisc_imx6_hsic_set_connect, + .hsic_set_clk = usbmisc_imx6_hsic_set_clk, }; static const struct usbmisc_ops vf610_usbmisc_ops = { @@ -490,6 +592,8 @@ static const struct usbmisc_ops vf610_usbmisc_ops = { static const struct usbmisc_ops imx6sx_usbmisc_ops = { .set_wakeup = usbmisc_imx6q_set_wakeup, .init = usbmisc_imx6sx_init, + .hsic_set_connect = usbmisc_imx6_hsic_set_connect, + .hsic_set_clk = usbmisc_imx6_hsic_set_clk, }; static const struct usbmisc_ops imx7d_usbmisc_ops = { @@ -546,6 +650,33 @@ int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled) } EXPORT_SYMBOL_GPL(imx_usbmisc_set_wakeup); +int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data) +{ + struct imx_usbmisc *usbmisc; + + if (!data) + return 0; + + usbmisc = dev_get_drvdata(data->dev); + if (!usbmisc->ops->hsic_set_connect || !data->hsic) + return 0; + return usbmisc->ops->hsic_set_connect(data); +} +EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_connect); + +int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on) +{ + struct imx_usbmisc *usbmisc; + + if (!data) + return 0; + + usbmisc = dev_get_drvdata(data->dev); + if (!usbmisc->ops->hsic_set_clk || !data->hsic) + return 0; + return usbmisc->ops->hsic_set_clk(data, on); +} +EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_clk); static const struct of_device_id usbmisc_imx_dt_ids[] = { { .compatible = "fsl,imx25-usbmisc", From patchwork Tue Oct 16 05:01:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10643093 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 1D7AA14E2 for ; Tue, 16 Oct 2018 05:02:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E8CA29BCF for ; Tue, 16 Oct 2018 05:02:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0212929C1D; Tue, 16 Oct 2018 05:02:05 +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 87A7429BCF for ; Tue, 16 Oct 2018 05:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727516AbeJPMui (ORCPT ); Tue, 16 Oct 2018 08:50:38 -0400 Received: from mail-ve1eur01on0074.outbound.protection.outlook.com ([104.47.1.74]:41568 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727178AbeJPMui (ORCPT ); Tue, 16 Oct 2018 08:50:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C1cEsZjb06IK+4NhNz+vvITU4YhMk5NjmpnRzrLp7qQ=; b=ADT0fx295Kme4nFDwKKh08ps7+vHAten5vyXpQDedqUT+O5rBYXlA47cwro8xBRn9dSDU729Avo7wbEZiapP0jsJwwLRKomAnSEBElXlCc6vwxoyUiY4v6MkdGVTemtCL/z+QzZGLUaC8VNPGrMrBtvqj0EF0cfttsnE+W4BY+k= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4976.eurprd04.prod.outlook.com (20.177.49.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Tue, 16 Oct 2018 05:01:25 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9%4]) with mapi id 15.20.1228.027; Tue, 16 Oct 2018 05:01:25 +0000 From: Peter Chen To: "linux-usb@vger.kernel.org" , "frieder.schrempf@exceet.de" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , Peter Chen Subject: [PATCH 3/4] usb: chipidea: host: override ehci->hub_control Thread-Topic: [PATCH 3/4] usb: chipidea: host: override ehci->hub_control Thread-Index: AQHUZQ1JMc2LYV3jnke4p55ZCBkjHg== Date: Tue, 16 Oct 2018 05:01:25 +0000 Message-ID: <20181016045846.2345-4-peter.chen@nxp.com> References: <20181016045846.2345-1-peter.chen@nxp.com> In-Reply-To: <20181016045846.2345-1-peter.chen@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.14.1 x-clientproxiedby: HK0PR03CA0027.apcprd03.prod.outlook.com (2603:1096:203:2f::15) To VI1PR04MB5327.eurprd04.prod.outlook.com (2603:10a6:803:60::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peter.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB4976;6:UX0Y1pi0nsll95zqEzjbO630aKQvzXyPhKNyOoFq4H1mrhEatX3fIPkWza2QmCynDzlOpGss2O8SUzxwzl0rZIaJ6pw64aNX+M1mRMi0Uo6mNewzKOZZLXZs/TtPdhKJ5mzVFq5r8OowQ1woOVk71ErNxPRW3fG3gra1zqmC3V5PxkCUpswec7VKC+hNiCuqnS4OgsrR3dCqDAm9hSaNO9tjz1A7uMR488lZYhsXtCMdY6vzEdfsEy3Trq8gsdDu8vrGZx0P1kv2/DmkDpNSDvZ5OH4+SGTFgbGUa+4xOAgHBc6khsBQaGImbmjczF2lV7Xtl69ujRUkRED82RFjAy9Wtk17J56R+SUi0cJ32tkWsfhF/R973DfOu63hYGqyphtTM/hwQ3wkTrhL9RaqVbq31LBjfLG4CwHU2K5NV7ECtZl1g03m+v27V+xHiCwLFrT3up504B+OzgBAidAhog==;5:QDXAu3nmtiTAjZaDVee6fqipnjx72WO/4Uzg2pnRZR0CS5kjTDOOjN0HJKxPLN93k1BBSOcGMsB62zX6YVXGIEkAziPAHcesdx7BvUUrm9aAI8WWNDGSx9riDh2trNhBkEuyNm3/0xcOdQiinmUJ+fvpZzLCfB3FTrUNljouhgg=;7:cKTZdfdAZ4CZEewYH8goHKQxmWTUPNlCA1Wq9UPkGhqb4WZrblKMp57/cuTWBicEtIwuhQFrjCB7y8SK6k6Z8guYb0VfkmUhGIIFkB9XpNkIrlVISguV3QZyet1itTLvwIhtptVrnBI7TxoIMLBkkk+PpZ9TYerbHF/G0EHNEcpxq2XPixorN36UWt7CZ2VqT2kTSIgoPrO8f7QoA5h1CNLIfehDSpqOB+ySf3chncBdXIJ7ia/KJAZduaW2dWPP x-ms-office365-filtering-correlation-id: 6f9448d8-f4dd-40a6-79d1-08d633246c37 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4976; x-ms-traffictypediagnostic: VI1PR04MB4976: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:VI1PR04MB4976;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4976; x-forefront-prvs: 0827D7ACB9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(136003)(346002)(376002)(396003)(189003)(199004)(14444005)(25786009)(11346002)(476003)(6512007)(2616005)(2906002)(478600001)(6486002)(4326008)(110136005)(446003)(6506007)(54906003)(386003)(6436002)(76176011)(551934003)(71190400001)(71200400001)(102836004)(2900100001)(486006)(53936002)(52116002)(186003)(99286004)(44832011)(66066001)(26005)(2501003)(5250100002)(305945005)(14454004)(97736004)(316002)(6116002)(8676002)(7736002)(1076002)(8936002)(3846002)(5660300001)(256004)(36756003)(86362001)(106356001)(81156014)(105586002)(81166006)(68736007)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4976;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: P/AmyvBUPDDQBOioCmb5TuNYlydJTvxnJ3UEBRGw7LWRYWwAt/T2wl5oS2fHgj0ujh3aMF8HqlFyzHBW+x7UMCPXhByK1rE8arLPDcZ6h4irHTCP5b+XsFHwnFEzGj12A/Tm03ZYgcph0YSDc3yp1y5/PkAEDgKPTXYE81lX1QBPfloWVih+3nMAAjoC3/hU/Pr7sRl9odlWKtbq7VV3LNb791wtQorryT0rlGzJNQh0bgfE68+KAcfrClCTahd9/95LbVusZ/mKNDbwGIgA/t6lK63gYr6w2Y+hmiPdAzWTKDkPzAWWMgLris/NvZqpc1VItCT7f0z3Cu5JCv2fc6mHTYtWJimWFZISB3BJtDw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f9448d8-f4dd-40a6-79d1-08d633246c37 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2018 05:01:25.0280 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4976 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 The chipidea controller has some special requirements during suspend/resume, override common ehci->hub_control to implement it. Signed-off-by: Peter Chen --- drivers/usb/chipidea/host.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index d74a13d7c21c..b8e7d7fe3d53 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -234,6 +234,79 @@ void ci_hdrc_host_destroy(struct ci_hdrc *ci) host_stop(ci); } +/* The below code is based on tegra ehci driver */ +static int ci_ehci_hub_control( + struct usb_hcd *hcd, + u16 typeReq, + u16 wValue, + u16 wIndex, + char *buf, + u16 wLength +) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + u32 __iomem *status_reg; + u32 temp; + unsigned long flags; + int retval = 0; + struct device *dev = hcd->self.controller; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; + + spin_lock_irqsave(&ehci->lock, flags); + + if (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_SUSPEND) { + temp = ehci_readl(ehci, status_reg); + if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) { + retval = -EPIPE; + goto done; + } + + temp &= ~(PORT_RWC_BITS | PORT_WKCONN_E); + temp |= PORT_WKDISC_E | PORT_WKOC_E; + ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); + + /* + * If a transaction is in progress, there may be a delay in + * suspending the port. Poll until the port is suspended. + */ + if (ehci_handshake(ehci, status_reg, PORT_SUSPEND, + PORT_SUSPEND, 5000)) + ehci_err(ehci, "timeout waiting for SUSPEND\n"); + + if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { + if (ci->platdata->notify_event) + ci->platdata->notify_event + (ci, CI_HDRC_IMX_HSIC_SUSPEND_EVENT); + ci_ehci_override_wakeup_flag(ehci, status_reg, + PORT_WKDISC_E | PORT_WKCONN_E, false); + } + + set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports); + goto done; + } + + /* + * After resume has finished, it needs do some post resume + * operation for some SoCs. + */ + else if (typeReq == ClearPortFeature && + wValue == USB_PORT_FEAT_C_SUSPEND) { + + /* Make sure the resume has finished, it should be finished */ + if (ehci_handshake(ehci, status_reg, PORT_RESUME, 0, 25000)) + ehci_err(ehci, "timeout waiting for resume\n"); + } + + spin_unlock_irqrestore(&ehci->lock, flags); + + /* Handle the hub control events here */ + return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); +done: + spin_unlock_irqrestore(&ehci->lock, flags); + return retval; +} static int ci_ehci_bus_suspend(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -305,4 +378,5 @@ void ci_hdrc_host_driver_init(void) ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides); orig_bus_suspend = ci_ehci_hc_driver.bus_suspend; ci_ehci_hc_driver.bus_suspend = ci_ehci_bus_suspend; + ci_ehci_hc_driver.hub_control = ci_ehci_hub_control; } From patchwork Tue Oct 16 05:01:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10643095 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 E7FA514E2 for ; Tue, 16 Oct 2018 05:02:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D910329C1D for ; Tue, 16 Oct 2018 05:02:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC38A29C36; Tue, 16 Oct 2018 05:02:09 +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 4C3FA29C1D for ; Tue, 16 Oct 2018 05:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbeJPMum (ORCPT ); Tue, 16 Oct 2018 08:50:42 -0400 Received: from mail-ve1eur01on0074.outbound.protection.outlook.com ([104.47.1.74]:41568 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727528AbeJPMul (ORCPT ); Tue, 16 Oct 2018 08:50:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qqx4dNvvPGfEauXir6exJRKdi+394NZM1vwTOLqfQh8=; b=SYmjJYUmtxNPvZT05mz4dhB9cOtDf8hjPn4cKqhvEyvlsMKAAfgOlWW8X7++i90e8FH2ffFdoe0TPfai6lgtm1cNKIP5gO+91Ar44GWjw4Q4sxxfzSsQa+JV92Zc7FN2HO/IRkHYZRsVUJJzwj1Ns5/6DOZw8yNvxGnaKpVi6QM= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4976.eurprd04.prod.outlook.com (20.177.49.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Tue, 16 Oct 2018 05:01:28 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::5c50:30f3:3805:71f9%4]) with mapi id 15.20.1228.027; Tue, 16 Oct 2018 05:01:28 +0000 From: Peter Chen To: "linux-usb@vger.kernel.org" , "frieder.schrempf@exceet.de" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , Peter Chen Subject: [PATCH 4/4] doc: usb: ci-hdrc-usb2: Add pinctrl properties for HSIC pin groups Thread-Topic: [PATCH 4/4] doc: usb: ci-hdrc-usb2: Add pinctrl properties for HSIC pin groups Thread-Index: AQHUZQ1LiL+TmEkaf0+xf29M17GSzw== Date: Tue, 16 Oct 2018 05:01:28 +0000 Message-ID: <20181016045846.2345-5-peter.chen@nxp.com> References: <20181016045846.2345-1-peter.chen@nxp.com> In-Reply-To: <20181016045846.2345-1-peter.chen@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.14.1 x-clientproxiedby: HK0PR03CA0027.apcprd03.prod.outlook.com (2603:1096:203:2f::15) To VI1PR04MB5327.eurprd04.prod.outlook.com (2603:10a6:803:60::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peter.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB4976;6:NyyRormOpToehFsmO9UvcVzuo92cQlh0WgbiyEULUxgeec83XoIm+hOTZAE/qHGc+nSZolKP3W2a2fpVYOLWvwD0LCINOvr4xv04UBT10GH4EyFRbNv8xh5IRnr+1pM+XXoH4yPw3ictPBNgnc1LmMuDJOYuCEWKcthG1Lhrgu8XDXH/vgmgr6kAcKH7HshSfZdSAVQAvFjaQoqx9jU1Ou5z6ExZlTp0mv7UBSSUN4YolurXwgf0b+AEDcnmZtvf7HADd2Jc2OIj7ZtbMgQkX/0C60xdhUqJ2Mke4ySfkLnOGDDjSyMVlqBBT4g19EmyO7AuKJ0zkhbu8x8k11hDt4KUuRbX99bZ2AZNtOpWl7BzdDRX8Sj7zYaPZB2QMwu4q8GnC0dnfzslbxC0zyELAo55WvGDpz97w4K6NsjD6QJhYUmQbDkB1WtVHW5FgnFoOz62Zkq92QHAP/rGD+Ja5g==;5:yOyWJxaiNiE67ZVz3s35qTSwSfoqKCphPIvA4B5hgD3KP+XlCXymk+K10ezg6iZmiqjQoNZPQEIQCFJPoqn5BbWUDqH9hc24wP4tplLT/Hgujm9zegMKhWpLM0ZnWJmNzE2ZgRlK8RBkH4Ynb6ES+OzEcLZ/YYd88bzLlypcYZk=;7:pF23NXOY1tWFTkZg3BGXSvDC6MtGnQ43pvuGEDiQt8w1zvzGLw0AwkzJz0QdJFeNn3tqy77egyzGsjhRP0DWJOUNZYAsQWEdR84xpeudJzyKBpKosVKAB+h1KktgkZMKKeN58WmQykTgE7uxfKCuS9WyZK3Kw02Ix/VhqMvV2iY/5nHPKNnBWDHqYAdX8Y9XcJYPq0Tbntc7svhzHe3dSUYBmbpk5G1vTbcdQXyJGH49Nfx9G+4iFXFOWvL02QSe x-ms-office365-filtering-correlation-id: 501ef52d-6196-466c-b203-08d633246e22 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4976; x-ms-traffictypediagnostic: VI1PR04MB4976: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:VI1PR04MB4976;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4976; x-forefront-prvs: 0827D7ACB9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(136003)(346002)(376002)(396003)(189003)(199004)(25786009)(11346002)(476003)(6512007)(2616005)(2906002)(478600001)(6486002)(4326008)(110136005)(446003)(6506007)(54906003)(386003)(6436002)(76176011)(71190400001)(71200400001)(102836004)(2900100001)(486006)(53936002)(52116002)(186003)(99286004)(44832011)(66066001)(26005)(2501003)(5250100002)(305945005)(14454004)(97736004)(316002)(6116002)(8676002)(7736002)(1076002)(8936002)(3846002)(5660300001)(256004)(36756003)(86362001)(106356001)(81156014)(105586002)(81166006)(68736007)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4976;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: zvJ77Vo+lqWuVJnC7+ChmTNvYHk4D5SZ27KfYQ/DRQ5piLb58xRF6Gvz5GmfhiKltqt7UsfrJ948ti7OwcEPtWMdA3LhuQY7Ln5Kitwg6fDqVSwcvRLiiYrjNeDbaX1Bq7iIbe3i+u4oPYeX+EJQyH0hq03E8bUSNMazVejxhPPNVatYzxBNuQtiAv3JIrl1Hfl19ggDjXk5RXmoTZBoULxmN2lV1N4SusQ+ptgGpBaeQQCeAYPuhsG8j9/NyuiAVcjGhR4XyDCmf2FZHjXg6pWUiI9UOCC9qQI1G6RPryMBM3/PRApJw56qAHbwtG191WHQACURgIeJgyPuLC8BQKYuZE0dUF6p7t2dAgaX3Zs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 501ef52d-6196-466c-b203-08d633246e22 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2018 05:01:28.4114 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4976 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 For USB HSIC, the data and strobe pin needs to be pulled down at default, we consider it as "idle" state. When the USB host is ready to be used, the strobe pin needs to be pulled up, we consider it as "active" state. Signed-off-by: Peter Chen --- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt index 529e51879fb2..10c8d793ea49 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt @@ -81,6 +81,7 @@ Optional properties: mux state of 1 indicates host mode. - mux-control-names: Shall be "usb_switch" if mux-controls is specified. - pinctrl-names: Names for optional pin modes in "default", "host", "device" + Or names for HSIC "idle" and "active" pin modes. - pinctrl-n: alternate pin modes i.mx specific properties