From patchwork Mon Oct 22 05:43:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10651733 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 3DF08109C for ; Mon, 22 Oct 2018 05:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DA502875E for ; Mon, 22 Oct 2018 05:43:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FCED287E7; Mon, 22 Oct 2018 05:43:50 +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 A28FC2875E for ; Mon, 22 Oct 2018 05:43:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727498AbeJVOAs (ORCPT ); Mon, 22 Oct 2018 10:00:48 -0400 Received: from mail-eopbgr40044.outbound.protection.outlook.com ([40.107.4.44]:47008 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727269AbeJVOAs (ORCPT ); Mon, 22 Oct 2018 10:00:48 -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=Ey0DhF+J1eqPOOfN5sR49VGnty9757pwhvHK7L0OBYxz/1hRHgrsMq3m33na66bpbqU1SJ7nkiUnrHBBPM7xLdqBkJIDD3Ogn75r5fIB72U73dX0jHk7HKvrGHW6/FR6eRMuDA0K3WIbUuFrkCV1+WC84eQbeCVj95dT2VwMsiM= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB5056.eurprd04.prod.outlook.com (20.177.50.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.29; Mon, 22 Oct 2018 05:43:04 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::e046:4971:4e49:7e97]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::e046:4971:4e49:7e97%3]) with mapi id 15.20.1250.028; Mon, 22 Oct 2018 05:43:04 +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 v2 3/4] usb: chipidea: host: override ehci->hub_control Thread-Topic: [PATCH v2 3/4] usb: chipidea: host: override ehci->hub_control Thread-Index: AQHUacoa5rUVJKwNv02LfUsQ233YWw== Date: Mon, 22 Oct 2018 05:43:04 +0000 Message-ID: <20181022054031.14027-4-peter.chen@nxp.com> References: <20181022054031.14027-1-peter.chen@nxp.com> In-Reply-To: <20181022054031.14027-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: HK0P153CA0036.APCP153.PROD.OUTLOOK.COM (2603:1096:203:17::24) 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;VI1PR04MB5056;6:OVRUHjInKnwNsrgqkgWfgoyUImKck3cDxpUKiEUajmFz78Ew0Rxtpn8oIm+HG/i9UT8eDECc6DPb8HyXntaxgKHUdINCY9R444YThNOMSptDjObSKLZ4fJo0A5gJRHvRan6KCIb1OtPyv9fVhk+JHaJUWtNR+nfEwfJyOEwMhqjkhG/yYO39rnGQxZAi1eb+lZfeTe5nd66fvJrvaw/GF5lwHpWAl/pClXuo/3ctO53UGpyiT4J+UuGP4QbBU4tn6M34K5Arvy5tTOyDGmZ7VfzX6llTAIU1iWfC8k3XF5Nv3O+NCuqlbEBm5PcCFgst9VDQw5lgUTZ4hxRQ76tiNNMWsb0fLzgaWdKFMKfm8/HK0293tXu9Ea0+xpm4N8kdGTYX+gJ80icpSRB7erZEUqoxFQZUfo/eniz64eAkCiwJcB5JnHI8wxYAYZ+WxtHmmnsBDOImSj4G7LXNkoMi/w==;5:OKkn2V7HZAdbano83n+DCtFdQePBzHejvPza1pszoy8rqctExucyZD1TAn9o3GUtnEcGX7T2GMqrEQzYwOZusic2aeY4/Sf6YqyE0Y8JnIYTt8q9HvlwIoD0B0mV3AP7NMiWQjsoTpphFo7U5pHmmC/B0wFSgeJtx5rOayLlpdM=;7:m2tKtSt9U/2TAEdGjO4is1+B50kmcXtiMmpyHTAY4/3EABYUjuEqChnmZKBQMv78M4oZLCUNj3+ZcDZLOlca+rE9ffACwp1lQJel2rs4uUel6tg7lgeEBpyOQxzpNDzqDHt4JU6mkHgvDcI8V57ofcCSWUTsnIyvp1bThIU6n88U9JxW0jynWo0X5+1vLE+9tAvPAQm9yvuiBSL9KEHNcPUtxWpLVJfWZdJUPywM2weELLwp2UTou8DHSCO6/nde x-ms-office365-filtering-correlation-id: 2fd0091f-7f98-4112-38de-08d637e13ca3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB5056; x-ms-traffictypediagnostic: VI1PR04MB5056: 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)(10201501046)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:VI1PR04MB5056;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB5056; x-forefront-prvs: 08331F819E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(39860400002)(396003)(346002)(366004)(376002)(189003)(199004)(39060400002)(478600001)(2906002)(5660300001)(6436002)(2501003)(8676002)(86362001)(7736002)(36756003)(486006)(305945005)(386003)(2351001)(2900100001)(8936002)(68736007)(102836004)(81166006)(81156014)(26005)(186003)(76176011)(52116002)(6512007)(25786009)(99286004)(6916009)(2616005)(5640700003)(14454004)(53936002)(14444005)(476003)(97736004)(6506007)(105586002)(106356001)(71200400001)(44832011)(446003)(3846002)(50226002)(316002)(6116002)(256004)(54906003)(6486002)(4326008)(551934003)(66066001)(11346002)(1076002)(5250100002)(71190400001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB5056;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: 2CivDs0QrVhvI+2jZJFNton2beZBDST+BDYi32Q120b+qPsrtUJ9dZtK1hcuk4LMtrJZP+i/6zV4iCtJ9e4B5hfPehBH2hZ/bQfDLhtjm8di/tfkcggLH5gjNumWxIhZBjXRI3Z5Q3l2kyplCvV1Kq8MHuNf5mV13ztno6man5pbrsuJAbW/ypc7YX88af7UPj8amPO+IeWHrevaglzQe84ttcJvnLDUPW7i7b1GqdWrlkzIq9HDtzFN7/TA1nN+0lMLgwQiT6l2uv89VITv2VJT4PcrHMgS5Wb3daLLc3RgJ1ht1kFep/I67Kr3kIK05/VOvlsdnKa0ZyBYMR7+twbQYGEtIggQcrc6gP3yQBc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fd0091f-7f98-4112-38de-08d637e13ca3 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2018 05:43:04.7440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5056 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; }