From patchwork Tue Nov 27 09:30:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10699899 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 B5C5C14BD for ; Tue, 27 Nov 2018 09:31:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A67F52AAFD for ; Tue, 27 Nov 2018 09:31:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A6F02AB21; Tue, 27 Nov 2018 09:31:00 +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 2F6192AB37 for ; Tue, 27 Nov 2018 09:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729815AbeK0U2Q (ORCPT ); Tue, 27 Nov 2018 15:28:16 -0500 Received: from mail-eopbgr60054.outbound.protection.outlook.com ([40.107.6.54]:26834 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeK0U2Q (ORCPT ); Tue, 27 Nov 2018 15:28:16 -0500 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=R+cx55gSopHc3WUzn9PXX1xq/0Eipp5KPIjYyL2Y0zQ=; b=tmRv/HOGdJulpJtdlcOQcpWuA9UsbpyWzqFjMU3HDasPzJ0iZ2mAgo5Fxf03PJOGq885oY9wSh+uR4RZxmMnUabXC5PA2slLlYf2PZlhv8CzZJW+KT50Rzjt/Vh6diFDYa/Vwdj8LQI48RI4FTyR9VHsWGv2vxl2IXNumg88/wA= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4158.eurprd04.prod.outlook.com (52.133.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 09:30:53 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f%4]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 09:30:53 +0000 From: PETER CHEN To: "linux-usb@vger.kernel.org" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , "frieder.schrempf@exceet.de" , "festevam@gmail.com" , PETER CHEN Subject: [PATCH v3 1/4] usb: chipidea: add flag for imx hsic implementation Thread-Topic: [PATCH v3 1/4] usb: chipidea: add flag for imx hsic implementation Thread-Index: AQHUhjPkvOLr3Bf/mka8F+Eqo1Omig== Date: Tue, 27 Nov 2018 09:30:53 +0000 Message-ID: <20181127092824.22756-2-peter.chen@nxp.com> References: <20181127092824.22756-1-peter.chen@nxp.com> In-Reply-To: <20181127092824.22756-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: HK2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:202:2e::23) 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;VI1PR04MB4158;6:CPU1Ga0NyHj4DPlZZXpa/iGXwx7Yt36Is5WwwV5SGxxLb8ob1HMY776Pt/4qtfMbC//J3iTX2OIWJmpqtqgwOvkdlPFNehRYoXcGc+v1jqZkNTBl1JM+UW5bVtiMbEQ8LmVw06tLIOAtdQGfrUndn1zEB51DMPzi+ergPcgVWTIl722x2Tekk4hp4vte0xREl7lYKernasUrlyNl/9oKbTug8GoFj6z0weX4SW0M3nWaacWNuu99Cwz0jdI2tVAkFvrXHT9dummMZ8Dn9XUX4m5KEqV+WsViMhyTYt+lqFRY0KPVVjhOLCkS9PrvRcuqsVqhl1Zn4fH2hqxEE0br+Pje7EXjl5YE1ZnBgsWJML8o69gvfhw0bmdrQVsgK6XinBEgMdVWeR5YDUhQaZXD1rpBWzcy5CxVFIzbeyxttIU913VBawM4KeKM+NnVNf5Twe7k6Vo521rF/qY5aMbNOQ==;5:2hSu435/klKFPWMhMIBtcpfvQXuJrbKSm/+CvaEoiPI6IgIbsmsyWtUCVlt/EoJo9E2fbxuB1UA2Oo/J/bm1G2ssDbF1eKSZDSD3r/AeZpio8vOl0sPh4ZpxnqUTyExXXTI0ikW2sAMgRtVvKC5Jn9ZTG3VQqpxGVUGpxYn34/0=;7:Gbp/9tMtgx/VDf91wos7lIq3UpOKqRURSME8Jq9NJRO8z9VJwK01F/uruX4ZQoyjHvO+PCYOX5X5bf73pFFZgv5Ez2If7nT+DQ/Jh5o1wzxpgT6H21ZLiwuH+QtE78Wbk2z+/j4biR9a/4Iu6ymLVg== x-ms-office365-filtering-correlation-id: d1da8db6-57ab-4b99-b1fd-08d6544b06e1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4158; x-ms-traffictypediagnostic: VI1PR04MB4158: 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)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:VI1PR04MB4158;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4158; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(136003)(366004)(376002)(346002)(396003)(199004)(189003)(71200400001)(25786009)(14454004)(476003)(97736004)(99286004)(11346002)(446003)(2616005)(4326008)(66066001)(39060400002)(6916009)(102836004)(86362001)(71190400001)(26005)(14444005)(6506007)(8936002)(68736007)(36756003)(8676002)(256004)(386003)(81156014)(81166006)(486006)(50226002)(52116002)(76176011)(186003)(2906002)(6486002)(6436002)(5640700003)(316002)(53936002)(3846002)(6116002)(1076002)(5660300001)(305945005)(54906003)(6512007)(7736002)(478600001)(53346004)(105586002)(106356001)(2351001)(2501003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4158;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Z46+bjbY6rtUUScoJ93NuEo1ASx2tSiCAMVFsrjy220kVatDwd0BsuwmsAwR6edAbmPKdz0LF0byKp124XV1RhtieJwdsLbt4yqt+ntEk4Yy5qnhvwcVCL5b4Ta/ZvM4dLcwqFY+p8rzwyUFdqigpni2DpMDuqBkM/rnJ3YoR6cAW+8GyQL7fK+664g7ULdmUHwg4l38jFiHaa3MApPlh4/OQGyyvAXRcIntx2pxOsDYOhmsPSRZ7X33Lqu2ryO9OTpq9BuuUuerFzGEcMjDfaoNs+jg3d+5NhqcKe75C09pNuJTFMTvVbx6ir8uaKHeSVEd5EruygN8zQAeVsH6B6H+njfjEAEBs8fHYxBnE0Y= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1da8db6-57ab-4b99-b1fd-08d6544b06e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 09:30:53.6894 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4158 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 Reviewed-by: Frieder Schrempf Tested-by: Frieder Schrempf --- drivers/usb/chipidea/host.c | 17 +++++++++++++++++ include/linux/usb/chipidea.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index d858a82c4f44..028a3574266a 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -170,6 +170,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 +223,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 +256,16 @@ 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); + /* + * Need to clear WKCN and WKOC for imx HSIC, + * otherwise, there will be wakeup event. + */ + if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { + tmp = ehci_readl(ehci, reg); + tmp &= ~(PORT_WKDISC_E | PORT_WKCONN_E); + ehci_writel(ehci, tmp, reg); + } + 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 Nov 27 09:30:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10699901 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 C9D1914D6 for ; Tue, 27 Nov 2018 09:31:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E342AAAF for ; Tue, 27 Nov 2018 09:31:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD2772AB19; Tue, 27 Nov 2018 09:31: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 8F6612AAAF for ; Tue, 27 Nov 2018 09:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729950AbeK0U2T (ORCPT ); Tue, 27 Nov 2018 15:28:19 -0500 Received: from mail-eopbgr60054.outbound.protection.outlook.com ([40.107.6.54]:26834 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeK0U2T (ORCPT ); Tue, 27 Nov 2018 15:28:19 -0500 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=gd25wUpowCvS3Ndjh1Ko0tz9putqxHRp0yx0wdNKL7Y=; b=UzPA8nC73a91LS77nC4eOwoS2BhfyMMF5b58/O9yrdLzkIQHM+J2INPdNXaR4oq/5CATaMkvTLJZzKZh6Gcp9wpiHUa2flFRJK0QVnOgaDcV+MFVR5kjOtyfmDicobyTdMhG5HnaCVkOMRJyZIL+s1U3C3Vlk77Th9qFzPmIcZQ= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4158.eurprd04.prod.outlook.com (52.133.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 09:30:56 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f%4]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 09:30:56 +0000 From: PETER CHEN To: "linux-usb@vger.kernel.org" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , "frieder.schrempf@exceet.de" , "festevam@gmail.com" , PETER CHEN Subject: [PATCH v3 2/4] usb: chipidea: imx: add HSIC support Thread-Topic: [PATCH v3 2/4] usb: chipidea: imx: add HSIC support Thread-Index: AQHUhjPm8KqiAJAcdUqU5fOQlxWuKQ== Date: Tue, 27 Nov 2018 09:30:56 +0000 Message-ID: <20181127092824.22756-3-peter.chen@nxp.com> References: <20181127092824.22756-1-peter.chen@nxp.com> In-Reply-To: <20181127092824.22756-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: HK2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:202:2e::23) 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;VI1PR04MB4158;6:0ndYAWK1xa7koNSA8ESkrQjLiU//s/0x05yw64SI7LwbT8Yq7Ylu52DXNbtOnpyw90d+TMFSwK+R0HYTXrUfZOMKWQkoVuhQg0x+Jtz6emj3ymVPWtgBHwMOCoQxwV8PCinp5hdmJkuELBM/A2EeDJ5ay26216w5YBecLAnqZu3NOwcpDGngI1ALs6y8fPlJQP1M90eEHfb4ufh0N7AnXopdoBybl/d/OtusbEOhEqoqSuQI4tW4y8e48PvOeHrlTHIQVj1MJK6xDIlvmscmlRyENLuJm3TC2ZYwopZwP9/KZo10V2AdaasLiztQKtkwsavVvgbhebjBFHyAu17SGDgNDE10+Ll45ayhqLHfmAuL+gmXyEuS74sB029BDlqxd09mPVjDNSYmzy1mwxpRamxMb0ldv5jBgSywboR12xqY22/r0oPD7PXixPTZz3r3LozpUiJlkH1bcIOpyrUeoQ==;5:K2xDA1hKuaMrsfKHpFw36WUnX2uU19oroxFbOAGO0bxk82Envqvd/ADPFOOFZm71KUvzqZ5umd/VseBx0mFo6dezLM9r3fMXHoljISEqiRXTQiIl8Dn+sDksiwxfSZj/bg3baEAGM5Wi5bho2vsQZjQ0IYwxWOGYGRoRSzmm7U8=;7:9IutY8xO9vlRy6QIRSJYnhevwUBIHxiai50/MDgLYCEMP77CYwnDKHZO7gPnubY43YZ72zP8/vDaR3BieGoJdTZ7vms9WmAvaVD5fka03pPqfRYyhJr55pg9R7sEGvUPu0V3gE1D/Q2xFKwtgWi/ZQ== x-ms-office365-filtering-correlation-id: 59ef312e-3b55-4b1c-754c-08d6544b08ab x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4158; x-ms-traffictypediagnostic: VI1PR04MB4158: 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)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:VI1PR04MB4158;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4158; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(136003)(366004)(376002)(346002)(396003)(199004)(189003)(71200400001)(25786009)(14454004)(476003)(97736004)(99286004)(11346002)(446003)(2616005)(4326008)(66066001)(39060400002)(6916009)(102836004)(86362001)(71190400001)(575784001)(26005)(14444005)(6506007)(8936002)(68736007)(36756003)(8676002)(256004)(386003)(4744004)(81156014)(81166006)(486006)(50226002)(52116002)(76176011)(186003)(2906002)(6486002)(53946003)(6436002)(5640700003)(316002)(53936002)(3846002)(6116002)(1076002)(5660300001)(305945005)(54906003)(6512007)(7736002)(478600001)(53346004)(105586002)(106356001)(2351001)(2501003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4158;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: W4DC7YNYBT+ba2YbTimlSghDe0EqJOmjziEWAObUlXlA/Hcc3oxyDEyr7URBoAcRMSRJxcMu7lgjXdUkNxiSWNNYuTgDQTVe61HpjZX3D5MtdCXh9EHbF3ldtonLa/Ni5dxl+Bb4PAXWd2teetEZtNg24IK6yBqOWf6zO0dUfPrUWqdRAiV834JExudhrjaCUVA4DxRKIhORMn+RtUDxbmysVDuQQRBgQ2TmA0DW5NBf0xdmsNWTmRlb3LKiI1xHYwJjTHH3S43bxxoCNwO2cFyDpiTuegdCR0+/JVKroJzmxQwIt1qwCOsvn6R1KZUR5vWiTaqKpoV1ZYQ2U/CRoj/bDVHAEUEXjE2BEzuuvM4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59ef312e-3b55-4b1c-754c-08d6544b08ab X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 09:30:56.7207 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4158 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 Reviewed-by: Frieder Schrempf Tested-by: Frieder Schrempf --- drivers/usb/chipidea/ci_hdrc_imx.c | 140 ++++++++++++++++++++++++++++++++----- drivers/usb/chipidea/ci_hdrc_imx.h | 9 ++- drivers/usb/chipidea/usbmisc_imx.c | 140 +++++++++++++++++++++++++++++++++++++ 3 files changed, 270 insertions(+), 19 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 09b37c0d075d..56781c329db0 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "ci.h" #include "ci_hdrc_imx.h" @@ -85,6 +86,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 +249,49 @@ 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: + ret = pinctrl_select_state(data->pinctrl, + data->pinctrl_hsic_active); + if (ret) + dev_err(dev, "hsic_active select failed, err=%d\n", + ret); + break; + case CI_HDRC_IMX_HSIC_SUSPEND_EVENT: + ret = imx_usbmisc_hsic_set_connect(data->usbmisc_data); + if (ret) + dev_err(dev, + "hsic_set_connect failed, err=%d\n", 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 +302,73 @@ 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); + 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->pinctrl = devm_pinctrl_get(dev); + if (IS_ERR(data->pinctrl)) { + dev_err(dev, "pinctrl get failed, err=%ld\n", + PTR_ERR(data->pinctrl)); + return PTR_ERR(data->pinctrl); + } + + pinctrl_hsic_idle = pinctrl_lookup_state(data->pinctrl, "idle"); + if (IS_ERR(pinctrl_hsic_idle)) { + dev_err(dev, + "pinctrl_hsic_idle lookup failed, err=%ld\n", + PTR_ERR(pinctrl_hsic_idle)); + return PTR_ERR(pinctrl_hsic_idle); + } + + 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_err(dev, + "pinctrl_hsic_active lookup failed, err=%ld\n", + PTR_ERR(data->pinctrl_hsic_active)); + return PTR_ERR(data->pinctrl_hsic_active); + } + + data->hsic_pad_regulator = devm_regulator_get(dev, "hsic"); + if (PTR_ERR(data->hsic_pad_regulator) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } 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)); + return PTR_ERR(data->hsic_pad_regulator); + } + + if (data->hsic_pad_regulator) { + ret = regulator_enable(data->hsic_pad_regulator); + if (ret) { + dev_err(dev, + "Failed to enable HSIC pad regulator\n"); + return ret; + } + } + } + ret = imx_get_clks(dev); if (ret) - return ret; + goto disable_hsic_regulator; - ret = imx_prepare_enable_clks(&pdev->dev); + ret = imx_prepare_enable_clks(dev); if (ret) - return ret; + goto disable_hsic_regulator; - 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 */ @@ -305,40 +393,43 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) ret = imx_usbmisc_init(data->usbmisc_data); if (ret) { - dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); + dev_err(dev, "usbmisc init failed, ret=%d\n", ret); goto err_clk; } - 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); + dev_err(dev, "ci_hdrc_add_device failed, err=%d\n", + ret); goto err_clk; } 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); err_clk: - imx_disable_unprepare_clks(&pdev->dev); + imx_disable_unprepare_clks(dev); +disable_hsic_regulator: + if (data->hsic_pad_regulator) + ret = regulator_disable(data->hsic_pad_regulator); return ret; } @@ -355,6 +446,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 +460,16 @@ 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__); + 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 +500,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..43a15a6e86f5 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,79 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) return 0; } +static int usbmisc_imx6_hsic_get_reg_offset(struct imx_usbmisc_data *data) +{ + int offset, ret = 0; + + if (data->index == 2 || data->index == 3) { + offset = (data->index - 2) * 4; + } else if (data->index == 0) { + /* + * For SoCs like i.MX7D and later, each USB controller has + * its own non-core register region. For SoCs before i.MX7D, + * the first two USB controllers are non-HSIC controllers. + */ + offset = 0; + } else { + dev_err(data->dev, "index is error for usbmisc\n"); + ret = -EINVAL; + } + + return ret ? ret : offset; +} + +static int usbmisc_imx6_hsic_set_connect(struct imx_usbmisc_data *data) +{ + unsigned long flags; + u32 val; + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); + int offset; + + spin_lock_irqsave(&usbmisc->lock, flags); + offset = usbmisc_imx6_hsic_get_reg_offset(data); + if (offset < 0) { + spin_unlock_irqrestore(&usbmisc->lock, flags); + return offset; + } + + 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 0; +} + +static int usbmisc_imx6_hsic_set_clk(struct imx_usbmisc_data *data, bool on) +{ + unsigned long flags; + u32 val; + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); + int offset; + + spin_lock_irqsave(&usbmisc->lock, flags); + offset = usbmisc_imx6_hsic_get_reg_offset(data); + if (offset < 0) { + spin_unlock_irqrestore(&usbmisc->lock, flags); + return offset; + } + + 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 +486,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 +562,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 +590,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 +601,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 +659,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 Nov 27 09:30:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10699903 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 9D60614D6 for ; Tue, 27 Nov 2018 09:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CE2E2AAD5 for ; Tue, 27 Nov 2018 09:31:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B7B2AAF7; Tue, 27 Nov 2018 09:31:06 +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 0CC652AAD5 for ; Tue, 27 Nov 2018 09:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730014AbeK0U2W (ORCPT ); Tue, 27 Nov 2018 15:28:22 -0500 Received: from mail-eopbgr60054.outbound.protection.outlook.com ([40.107.6.54]:26834 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeK0U2V (ORCPT ); Tue, 27 Nov 2018 15:28:21 -0500 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=OJibCUNQ4AeSSrHa8aNEbtVT9MNwDDoEOZcQtgwdKBI=; b=dPkWxAgaMocIZji1XJT45T8yULVTmlPb34uFZI9vbRIDgdwVGbpjSR7C8v56vfgNwXGiJRBrFPNbQETfmB2kC/SqPh63U2n7F03PBPKIKSnozFCwK71ZdeHqxppz4mJggcnjsQxIt/AS2EDFV8+B9WUG5CmsfLldHYsJmlkSxSY= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB4158.eurprd04.prod.outlook.com (52.133.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 09:30:59 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f%4]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 09:30:59 +0000 From: PETER CHEN To: "linux-usb@vger.kernel.org" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , "frieder.schrempf@exceet.de" , "festevam@gmail.com" , PETER CHEN Subject: [PATCH v3 3/4] usb: chipidea: host: override ehci->hub_control Thread-Topic: [PATCH v3 3/4] usb: chipidea: host: override ehci->hub_control Thread-Index: AQHUhjPoYonp63xdyEmetyeasQ1JDw== Date: Tue, 27 Nov 2018 09:30:59 +0000 Message-ID: <20181127092824.22756-4-peter.chen@nxp.com> References: <20181127092824.22756-1-peter.chen@nxp.com> In-Reply-To: <20181127092824.22756-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: HK2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:202:2e::23) 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;VI1PR04MB4158;6:AXVSFMQRt2cAZaOStiyzEJeAttkI+7Rs3VLPeDdn3rnROMogVkFaRCOLxoWYM5iqd83oIGAWBDmXULS1aqHJbCDWLnuFZvFlLpsFaLkVDm3d15sv9A+Ri/uVS4XR99ncII95xzq+6BRb+iF+8JkUoFbFoRVTc/k2bKQvZ9OekDSzzDTQRUI/1siRKQx6C/m4CK3k3yQA8OOmKzRTV2AdrLrSCv9WtpCWiVxUFA0j5CyugYK2Sn+fOTrxndqpdr9l0G5u2qVANu04N70JMK+qaZIBzAhr5qtIG62jKvoI5Z3XvINVyRICusf4XhN4XRb+k1Yec0HRjQUEDej/zygHCBZwA9la5ufNwTP95vH2dudwjAIaWJV8jFmPOSoZ8KNVeFQIxqUWxPF6nZhZ49DX9NnSI4V+yM/3YaJEOv4h3liIAK0dSBVwWlnlBcRUnyogJva0E3aoe5bh9/EfxgfCEg==;5:EoZyO2XZbvGECUarNCN3AbFRyc30ZQw5uLoyCAdZ6p3SllLYOP59/QevmkVmContcnFUrktA8PYkMSPoa2+gB/vzR9ZvP25lbE+CwPYDX6aaegv3705u5K0ijEEZVgy6V3/ixy5l5tM2Od9Pg45dUUCpMz3QyaoMMh1o+KH5kus=;7:kn4jLwSBxrERRClcS0DEQiXAwN0bv9+ThuLBHqb1JUTMB35HyYCcG41ga0tktkJWH3OKb6qmhozVow/unZ5Ryt8ZwS3xUo4Jq4uzrZ+Xd0mghBG+s5pNk2dPFq2n8Nq5DklDLJ+xVBDdSUpI+WTXWw== x-ms-office365-filtering-correlation-id: 3b7df6b2-9f9e-4c03-5f8f-08d6544b0a7c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4158; x-ms-traffictypediagnostic: VI1PR04MB4158: 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)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:VI1PR04MB4158;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB4158; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(136003)(366004)(376002)(346002)(396003)(199004)(189003)(71200400001)(25786009)(14454004)(476003)(97736004)(99286004)(11346002)(446003)(2616005)(4326008)(66066001)(39060400002)(6916009)(102836004)(86362001)(71190400001)(26005)(14444005)(6506007)(8936002)(68736007)(36756003)(8676002)(256004)(386003)(81156014)(81166006)(486006)(50226002)(52116002)(76176011)(186003)(2906002)(6486002)(6436002)(5640700003)(316002)(53936002)(3846002)(6116002)(1076002)(5660300001)(305945005)(54906003)(551934003)(6512007)(7736002)(478600001)(53346004)(105586002)(106356001)(2351001)(2501003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4158;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Py3dB5zS30IoFq4Qri3nMkLrqiATWUP1bXP1RCM+mmCKceIlyIgt195C7HYVQQTUEVi5Cjg3OoZ2V2dvnRiiI34rTL4xx2NQsQ6SMjC3QUzKNofMLV800JHXGPufDzkdcdODRXpp/MwZ0LgoSnWlf4JpYW/auL4H5pS1iBFTVmlszl7Z+lx25xUu3DAEt6dc5Hs7PBT52VXKTqpMXpnLTYmgBbllVqWm+34sqvArFm7obXHddYBLwJEUKB4G6YaBp2VMdeEH/dy6OqykpDLwKN+KXyUPhnOrhUNyROPCsHkfcbqZ3hzh9Xka9aw/ffuWWNyC33/4QJBkM3MWoiuVlMavzy79Z1Y3QsnnZ3c+NTs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b7df6b2-9f9e-4c03-5f8f-08d6544b0a7c X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 09:30:59.7207 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4158 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 Reviewed-by: Frieder Schrempf Tested-by: Frieder Schrempf --- drivers/usb/chipidea/host.c | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 028a3574266a..aa4756dab487 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -220,6 +220,81 @@ 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); + + temp = ehci_readl(ehci, status_reg); + temp &= ~(PORT_WKDISC_E | PORT_WKCONN_E); + ehci_writel(ehci, temp, status_reg); + } + + 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); @@ -298,4 +373,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 Nov 27 09:31:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10699905 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 84D1614BD for ; Tue, 27 Nov 2018 09:31:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 762D22AA99 for ; Tue, 27 Nov 2018 09:31:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AC792AB29; Tue, 27 Nov 2018 09:31:10 +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 005A22AA99 for ; Tue, 27 Nov 2018 09:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730095AbeK0U2Z (ORCPT ); Tue, 27 Nov 2018 15:28:25 -0500 Received: from mail-eopbgr00069.outbound.protection.outlook.com ([40.107.0.69]:54038 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeK0U2Z (ORCPT ); Tue, 27 Nov 2018 15:28:25 -0500 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=gED5o7gSH+mXkenJEO7qEdswxOAYHwPnXP4eoXea+5g=; b=Trvhd1a8PKHcr/ZosjflPwLNmcDXIBYo2kWtzapKK8sD5qmIzsKww3XJkp4sKL4O7xA5rb+J9tN4eKcAeURUdMSpYscScBl6gJcNkpS0KKSoxUx5VyrTHF1k52QV7mRJvtcwotNrxZxkUG1xEHdrkxgOg5sTY8jvN5Afoa9eQLU= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB3102.eurprd04.prod.outlook.com (10.170.229.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 09:31:02 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::811d:1992:9a6a:bb3f%4]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 09:31:02 +0000 From: PETER CHEN To: "linux-usb@vger.kernel.org" CC: dl-linux-imx , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , "frieder.schrempf@exceet.de" , "festevam@gmail.com" , PETER CHEN Subject: [PATCH v3 4/4] doc: usb: ci-hdrc-usb2: Add pinctrl properties for HSIC pin groups Thread-Topic: [PATCH v3 4/4] doc: usb: ci-hdrc-usb2: Add pinctrl properties for HSIC pin groups Thread-Index: AQHUhjPp9zcP+WWZkk6DbHv+3RCIuQ== Date: Tue, 27 Nov 2018 09:31:02 +0000 Message-ID: <20181127092824.22756-5-peter.chen@nxp.com> References: <20181127092824.22756-1-peter.chen@nxp.com> In-Reply-To: <20181127092824.22756-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: HK2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:202:2e::23) 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;VI1PR04MB3102;6:1M+9J2QtJXKFhx0JqP5coBo8MJqKceS4tr5PaMYUruH9YTelFgedlMU9OFYtlgCs/65J2QRHALKFzGHmiq532KvxBi9ICOEBvfe7cLw9kEn/xpZl/kJJzHRy05AQxCsEgl1CwvoZ3ARhQ8vWeshDjPdlD09W54li1+wqRP+MDRYR8DhVlRiZ81jiGtWNSycD509m0fXrpRTjcbERhwskZPne57juP/8BfjYi8bxuATuc2BwF4mQMJzSCLomgVylB1GqP/TdrITmIModp5AJGA7VyTbWWwpkVkp6HnN5pjjSdPH9EPXQC9wcGhhCA7nMBie2owICXVgTJ8hWI6IAtuoVsnzltmo4zgf55bI20mpvNOn7erXutz+7M2NZIUWaH7P4AjrXR7EyA0qEoqPeL4QNpRK8bQUijGsFpNaZ+Ka/dNQt+SzacSfrD1PL3c7P5eTphhZ3a7PkJA6yDPm53wg==;5:I6fq36go+Pt0Au4180wC9hsi1wQDXmc1iYXlEM2oh5Wz/+bxExMcVGYjAMlGxOWL/1ZCIrwqvthu6zwEUGl3BVycc+J9Yf/a4/kFoqGOyEN1GjxIsuYG/9KW9viGXaLG2OK2JD0TZ83KO91Dw5wKKWGOSOd6hNc5QR/AewCYulU=;7:Jc9HY1rUtX6X3eUEm6WcsR1V5yK6SU2rMbaxZ/kiS+IEvZgRtDf7cu+9Ysgaj1rtFLdw9/6XCY+gE2NTm+3TvtXNHqmlBSDgo4SsAMS5xSZnD5ZLiwQ5r7rPFkL780NKj4hjuHF9xFq0wyUJ1yCWsg== x-ms-office365-filtering-correlation-id: 7127a67f-2379-469f-fbf3-08d6544b0c3e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB3102; x-ms-traffictypediagnostic: VI1PR04MB3102: 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)(10201501046)(3002001)(3231443)(944501410)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:VI1PR04MB3102;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB3102; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(366004)(346002)(396003)(136003)(39860400002)(189003)(199004)(6486002)(50226002)(8936002)(81166006)(81156014)(6436002)(486006)(86362001)(8676002)(476003)(54906003)(105586002)(2351001)(99286004)(446003)(2616005)(52116002)(106356001)(11346002)(76176011)(2906002)(386003)(6506007)(102836004)(26005)(186003)(316002)(6916009)(256004)(14444005)(6116002)(1076002)(3846002)(71190400001)(71200400001)(36756003)(2501003)(478600001)(5660300001)(5640700003)(6512007)(4326008)(39060400002)(66066001)(53936002)(25786009)(53346004)(14454004)(68736007)(305945005)(7736002)(97736004);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3102;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: nSCqvKje4OREhkTr7HakJcnWZm7ouv9kQyb7HAzvMNyWixi39+eRodjrmjRDvMXTk607jkVXIsjtjww6knNiWhvPEruZmRMPKjwV9PyriEGkxuZHyE7uncxlmfmjiWNTcm/wpZIzhrauRa9jkuK/yTjQo1Ln7GOINRm8BcWcF80+mNC73hJ/FvNGBNgHS+2UUwAsrxSgfPaYkY+RkKFaOsKS+XjqqTAN+vwx70yBIPLXBdkW9HgzJUTmDCwppI8b9r5FOntVfyaYZoGu2vaPw5FAgowM6F0FLG2U+QZiKb1yIoUsSO6iAO+P0YWrLMLxDaPZu9kDud8k6tiAIGQi+C6/0h3STlAc+CH1Rh1hy+A= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7127a67f-2379-469f-fbf3-08d6544b0c3e X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 09:31:02.6582 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3102 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt index 529e51879fb2..1e5e7ddfb1a5 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt @@ -80,7 +80,10 @@ Optional properties: controller. It's expected that a mux state of 0 indicates device mode and a 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" +- pinctrl-names: Names for optional pin modes in "default", "host", "device". + In case of HSIC-mode, "idle" and "active" pin modes are mandatory. In this + case, the "idle" state needs to pull down the data and strobe pin + and the "active" state needs to pull up the strobe pin. - pinctrl-n: alternate pin modes i.mx specific properties @@ -110,4 +113,7 @@ Example: phy-clkgate-delay-us = <400>; mux-controls = <&usb_switch>; mux-control-names = "usb_switch"; + pinctrl-names = "idle", "active"; + pinctrl-0 = <&pinctrl_usbh2_1>; + pinctrl-1 = <&pinctrl_usbh2_2>; };