From patchwork Fri Jul 3 06:26:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A087A912 for ; Fri, 3 Jul 2020 06:27:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77CA720772 for ; Fri, 3 Jul 2020 06:27:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="WnETqRjv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726081AbgGCG1g (ORCPT ); Fri, 3 Jul 2020 02:27:36 -0400 Received: from mail-eopbgr00087.outbound.protection.outlook.com ([40.107.0.87]:65506 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725949AbgGCG1g (ORCPT ); Fri, 3 Jul 2020 02:27:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ft3zrkcJZxu6Cp2ijodfAp0Hdrr6/SCZXOj6j6sAK6Q5iGsCQ3vUJqure20Gbm0PidloUpIo45bsd+7IUTDFujrpu7MPrnyK+udSPG3MFJde5+8gkFimnt6QnaohFlfJqv+O1PSGBtTi4dz1KdJfvxIFwcSyh4CoLeY/UvAV19a8rxIH6XUqOBMMR1vo68pxjRH3pqMoZzrmxKToDAoUnRTCAS50s8d1tYAn/dkLNbFIP9CQ8grEESIplh7KhM31u56+CBU3JmvuvT8UC+qNWpzKRP+0gyejq0+gTqQ4EfcBk7Xg1kuG6ohzFCpVbN1kB8Jws5OabPAlKW2SjYcPYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8iBh9S1En+jgXFDcmC1n8n5luYN3vZHkUBV6VM5gTpg=; b=ZgYg3MYD7ZBR30XYrkTJzfgYg55CPxvBxNP3hJBl1pKCu/EvpYDng5LSJplEIghA6KPIYYuGrJ/v+9yjG9PhhT8xNrF7n9x0wa54uPqSMUCulS14/0YBrR3zH6BAZx9sYW0P32j1uTPTiXwHZMTK5nHRzJO6NgbBil9kH6edrml8sPLo/sCdg16puFZFQF1KwksdhLIWXqdgbqCitXLDNJIyXuhZenO5FTs6ixGwcuIXwh29mqIC+KiCpSHG6UgRnip86MV8jEptadoODAMToePqcUNVDM24zmzMA3Y1c0ij/by9AeKxMOSzbPoIzap/dokg+6ZTlMM9cxnZwutomQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8iBh9S1En+jgXFDcmC1n8n5luYN3vZHkUBV6VM5gTpg=; b=WnETqRjvrIZvaK3eYXidKhelYjTTadLCiLhETPv2YczLQrVksT7Nu7NFyW+EOHS+Pw2sSfOhj8AIkPs2KlZP3QlhgzFx3Jj41fBGtKSJv91PCl+kWk1GNIJwcqd+2XBNtcf3cyU0sWys7IWQp3w8AeImusOzwaE0YrJMQL16qm0= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4758.eurprd04.prod.outlook.com (2603:10a6:20b:f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21; Fri, 3 Jul 2020 06:26:58 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:26:58 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 1/9] usb: cdns3: introduce cdns3_set_phy_power API Date: Fri, 3 Jul 2020 14:26:45 +0800 Message-Id: <20200703062653.29159-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:26:55 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b50fb005-247e-4062-cb12-08d81f1a16ae X-MS-TrafficTypeDiagnostic: AM6PR04MB4758: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qeEZmwkKSnYUL25JKGacvZOydNBcKnGVzmh5Fkpn+wcxvhE0Ie+y98Z5cbBsPqyVBx6ngulmL5Mcq6ahgJji9tGv++9mx9uZqOOS+f3SKXixWAZOUafZtYb+CJJ3nJPyHL+0SgYzvT2241GkhkyaXMzFQGVBx2CYwS/LDPUnOhskhmCP33RcqMVlYJG2Wtazsf/sAaVPxD3I/9mJfWV6JpsYCgH/geDvZRCgQjQvavjc5RGvxUjkZB4+oERnFshaPjsju+1QQuHmREXk8IsKGFiTLYmHGD9MJ3ylCOLsLowyvhAzB8FfiK3UY4fl7wrojuj3NmEsa8pVN3n2CNAL/A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(376002)(39860400002)(396003)(366004)(316002)(4326008)(478600001)(6512007)(956004)(2616005)(5660300002)(6486002)(36756003)(66556008)(66476007)(44832011)(1076003)(6666004)(52116002)(66946007)(16526019)(186003)(86362001)(26005)(2906002)(6506007)(83380400001)(8936002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: o9x2Rb1i3kit3BcLDIdMG4dB7b0IEaowOg5Q83FvJ2gPYP4Y4FM0STvrPLHSy5mEgczSTb+bim2EeX2wd199kIA0PVyMHTbV2T7MrFwd2e9QJXMvOulQI/WaJZuLyqm+mMHFyFshFfRBUH7MqlFlI2yDcfyUtG2yYcU7k1Kmq9v6tEFB6+IwhgmS+OKB+EP9wkZCMRwPJpMesdt0zQeH43sF9M7RQtFhqG8n10mvM/hm3kOroVDOSUGb6psuBPXUI83xxS8Otv3MFVCrMPZhJo+fIBinB/FvrXt+dDg+SUr+FoJGUfHsLYrpBo4SxLsWgzw6hBTGDt9lfe9RiYAc/fBAcy16CbHVx84a7DeQPd5eObqBIhsjvBdIqFenC5yyWkyGmCpEoi/+GV5oej2MNzcHF3rRoCtx8qi1rk1sY/zOX8DOwmHfenSv8mdnuIt+y3gBJNEiZocvJzxuC8ls3hDWK8DxqfFCXJRYk767dFU= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b50fb005-247e-4062-cb12-08d81f1a16ae X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:26:58.4513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cqipCpZw5UKkuXts8vBHVPYXSy3HsJm++6esI+QNKD1F1BtRj+LEi7dGyQfKerBp8e12pXDVqZ0ILBpyFVrd6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4758 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since we have both USB2 and USB3 PHYs for cdns3 controller, it is better we have a unity API to handle both USB2 and USB3's power, it could simplify code for error handling and further power management implementation. Reviewed-by: Jun Li Signed-off-by: Peter Chen --- drivers/usb/cdns3/core.c | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 19bbb5b7e6b6..bfd09aa98c12 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -384,6 +384,28 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role) return ret; } +static int cdns3_set_phy_power(struct cdns3 *cdns, bool on) +{ + int ret = 0; + + if (on) { + ret = phy_power_on(cdns->usb2_phy); + if (ret) + return ret; + + ret = phy_power_on(cdns->usb3_phy); + if (ret) { + phy_power_off(cdns->usb2_phy); + return ret; + } + } else { + phy_power_off(cdns->usb3_phy); + phy_power_off(cdns->usb2_phy); + } + + return 0; +} + /** * cdns3_probe - probe for cdns3 core device * @pdev: Pointer to cdns3 core platform device @@ -477,14 +499,10 @@ static int cdns3_probe(struct platform_device *pdev) if (ret) goto err1; - ret = phy_power_on(cdns->usb2_phy); + ret = cdns3_set_phy_power(cdns, true); if (ret) goto err2; - ret = phy_power_on(cdns->usb3_phy); - if (ret) - goto err3; - sw_desc.set = cdns3_role_set; sw_desc.get = cdns3_role_get; sw_desc.allow_userspace_control = true; @@ -496,16 +514,16 @@ static int cdns3_probe(struct platform_device *pdev) if (IS_ERR(cdns->role_sw)) { ret = PTR_ERR(cdns->role_sw); dev_warn(dev, "Unable to register Role Switch\n"); - goto err4; + goto err3; } ret = cdns3_drd_init(cdns); if (ret) - goto err5; + goto err4; ret = cdns3_core_init_role(cdns); if (ret) - goto err5; + goto err4; device_set_wakeup_capable(dev, true); pm_runtime_set_active(dev); @@ -522,14 +540,11 @@ static int cdns3_probe(struct platform_device *pdev) dev_dbg(dev, "Cadence USB3 core: probe succeed\n"); return 0; -err5: +err4: cdns3_drd_exit(cdns); usb_role_switch_unregister(cdns->role_sw); -err4: - phy_power_off(cdns->usb3_phy); - err3: - phy_power_off(cdns->usb2_phy); + cdns3_set_phy_power(cdns, false); err2: phy_exit(cdns->usb3_phy); err1: @@ -553,8 +568,7 @@ static int cdns3_remove(struct platform_device *pdev) pm_runtime_put_noidle(&pdev->dev); cdns3_exit_roles(cdns); usb_role_switch_unregister(cdns->role_sw); - phy_power_off(cdns->usb2_phy); - phy_power_off(cdns->usb3_phy); + cdns3_set_phy_power(cdns, false); phy_exit(cdns->usb2_phy); phy_exit(cdns->usb3_phy); return 0; From patchwork Fri Jul 3 06:26:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53DFB912 for ; Fri, 3 Jul 2020 06:27:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30927204EA for ; Fri, 3 Jul 2020 06:27:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="PvhmLKnJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbgGCG1H (ORCPT ); Fri, 3 Jul 2020 02:27:07 -0400 Received: from mail-eopbgr150049.outbound.protection.outlook.com ([40.107.15.49]:37606 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbgGCG1H (ORCPT ); Fri, 3 Jul 2020 02:27:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ndMCHcb72uxzLLDA6t67PJ8EfbEKrSKZlIo1bF0B9ndkVIIIUMb3FnlHU4jurPBBgUD5gIJHDOZUpQQuxc2OTxuBXJM7ZHXbZ4KHcARQlyb1tOZddBXvQhkjWEFOaXcXhAQo4cz144mqQCMaWVZ9Y+airtHoB9CJckSWQZn3wE6iculujVag3jznIk6JsZsBs5zxZgyaYGq8ozmKI2uAfAD9/S5BSWYfAPFG7tSLt+Gw/SkaSuwmnfez27+alndCFQOqb02wmm3ssPXs0ja2A5F+MjFMVdMpeCAAxpnOmKiWk9WjGiw5DGKXl9As8wS4Be9CKyb1gF6fQn8kMKPolw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r9GYIe22OKl6mSqjFonDLm2mLpzCtfIAr1QSaRBCvEQ=; b=WHge1SVsgsefsf1Zq6FyvSnXAhsJdT3fC8oPcGbpilbYu6iK5G8E+uDnpcl5NrEywZFOgwxgE6I2eVuhe4yLa7ANIX6i+dh1hGw8F08WGhy1nfRofcTJjZeystgEZfDcXjskLOy2+IuWJfFpyej7cYHI9jmr+NQGtc/qJnkN0SeoglyJpIZDde4E9LX8ij9Jw4Kz3+dc38fzr45tibXacOGw10pFRuwSg94/3VGtOuG+CoMFFMy/3wdKtDf6PndKzD5MBXzRr39wdyd7M1m3EVQtYsWxSq3ziYGy+TQMSqOEBkv1GSaKcf84iyIrmwNzle9ikqbjGT5XasyzhKgOWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r9GYIe22OKl6mSqjFonDLm2mLpzCtfIAr1QSaRBCvEQ=; b=PvhmLKnJZef7jbk/DbQ97b3nFhA0tWXEIg6jMqcXf8RonCUkTfNvKlwKVdtI/u2HIzGqxxKt2/L7B6FNvfVmLGcZGUAq8ttIMgtKjKRXgaDFE+d95PoxKmScLpP69gduWTmDwv/zwJ573HCvPx/wZhUKuGgwE0SMlhWzN1zg2ws= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:01 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:01 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 2/9] usb: cdns3: add runtime PM support Date: Fri, 3 Jul 2020 14:26:46 +0800 Message-Id: <20200703062653.29159-3-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:26:58 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b0bf0096-0a4e-40ce-b7e4-08d81f1a187b X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KYs5HW1ZJF5wa/t4Wm7rpYN+S+ywikQawINbaSyO3J0LH2nhQXHlrGimc6EHc/zC7jOW4Zp4pQMF54e31TVFYip9MJNhHsW8xzkjtQg4OfMB5ntdHCODOKFkXPAT8pgcsyviuonPJUGB3GdzFYagiKMMXCcszM+Qxq+ARBexCCo+r5ldk8jcKevD5ZD2cx1D2etWnP4cLnYQlC60s1OJNMIN/e3+55AlZnKiUHXJ35Y0yogqvMbE8rSaFe0Yxgo/jtD6nDeN16EvYRKrKraiSNNvGU9d4uZpLyoH2I7ubSMIinuAY8xyAuHG5/KL4kqukjhGJQSmo3YaHSIY7mrZtg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(30864003)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5IvKuDzUsO04vOtS7y06IYWJK6WUsadg/dqxBhyGU+s8X7f9Akixl1z6C+tnKeBuyD628VdzbWuqhdjPreGQmF69sTMapNgid5Ay38FLJIuptogU4+/TRuHI7XfmI6pfw4Qck5/9J1imt2gBbuntOfrMIo20g45rHHbPFhjMpR+ebNq2yGV0R1kpdZjj1dRsCN2O2a3NoDEUP+WgVNvfumtvMsgkSuhQ2rnGRR8A0lbLGBWeanvrZlydSuv2xyfPcJzvr/vjj65ugMUM6KBVhXWacnurMBqFvwB+bRFUEy5gg7cxJRtnDz5xDv+91+QbgQQc7Xnez5ZYDV1K3ytCg+qgtO2scIxt6vWvKQqzDfMXDqBoJHaV227/555v0QkvpkWycHSbs4bWue5cuBfAnM0+eHGNKmF9YmYqIXOzkZ18pzbS2CsEupxifSzPpmaCXcM1q91rpNpj+Z9tFMjT1fpRQabKK8p+IRsDzv3TmFE= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0bf0096-0a4e-40ce-b7e4-08d81f1a187b X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:01.5905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tCGv3/HkfB9rypb2vBMncRo0BbldCKvs61tXQl19N6rBRyWjkJ4GMaFV5E/Y44NR4anpWIL5e2wcAyBic773oQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Introduce runtime PM and wakeup interrupt handler for cdns3, the runtime PM is default off since other cdns3 may not implement glue layer support for runtime PM. One typical wakeup event use case is xHCI runtime suspend will clear USBCMD.RS bit, after that the xHCI will not trigger any interrupts, so its parent (cdns core device) needs to resume xHCI device when any (wakeup) events occurs at host port. When the controller is in low power mode, the lpm flag will be set. The interrupt triggered later than lpm flag is set considers as wakeup interrupt and handled at cdns_wakeup_irq. Once the wakeup occurs, it first disables interrupt to avoid later interrupt occurrence since the controller is in low power mode at that time, and access registers may be invalid at that time. At wakeup handler, it will call pm_request_resume to wakeup xHCI device, and at runtime resume handler, it will enable interrupt again. The API platform_suspend is introduced for glue layer to implement platform specific PM sequence. Signed-off-by: Peter Chen --- drivers/usb/cdns3/core.c | 153 ++++++++++++++++++++++++++++++++----- drivers/usb/cdns3/core.h | 16 ++++ drivers/usb/cdns3/drd.c | 3 + drivers/usb/cdns3/gadget.c | 4 + drivers/usb/cdns3/host.c | 7 ++ 5 files changed, 166 insertions(+), 17 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index bfd09aa98c12..2fedb8044d8f 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -406,6 +406,30 @@ static int cdns3_set_phy_power(struct cdns3 *cdns, bool on) return 0; } +/** + * cdns3_wakeup_irq - interrupt handler for wakeup events + * + * @irq: irq number for cdns3 core device + * @data: structure of cdns3 + * + * Returns IRQ_HANDLED or IRQ_NONE + */ +static irqreturn_t cdns3_wakeup_irq(int irq, void *data) +{ + struct cdns3 *cdns = data; + + if (cdns->in_lpm) { + disable_irq_nosync(irq); + cdns->wakeup_pending = true; + if ((cdns->role == USB_ROLE_HOST) && cdns->host_dev) + pm_request_resume(&cdns->host_dev->dev); + + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + /** * cdns3_probe - probe for cdns3 core device * @pdev: Pointer to cdns3 core platform device @@ -432,6 +456,7 @@ static int cdns3_probe(struct platform_device *pdev) return -ENOMEM; cdns->dev = dev; + cdns->pdata = dev_get_platdata(dev); platform_set_drvdata(pdev, cdns); @@ -481,6 +506,15 @@ static int cdns3_probe(struct platform_device *pdev) cdns->otg_res = *res; + cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup"); + if (cdns->wakeup_irq == -EPROBE_DEFER) + return cdns->wakeup_irq; + + if (cdns->wakeup_irq < 0) { + dev_dbg(dev, "couldn't get wakeup irq\n"); + cdns->wakeup_irq = 0x0; + } + mutex_init(&cdns->mutex); cdns->usb2_phy = devm_phy_optional_get(dev, "cdns3,usb2-phy"); @@ -517,6 +551,19 @@ static int cdns3_probe(struct platform_device *pdev) goto err3; } + if (cdns->wakeup_irq) { + ret = devm_request_threaded_irq(cdns->dev, cdns->wakeup_irq, + cdns3_wakeup_irq, + NULL, + IRQF_SHARED, + dev_name(cdns->dev), cdns); + + if (ret) { + dev_err(cdns->dev, "couldn't register wakeup irq handler\n"); + goto err3; + } + } + ret = cdns3_drd_init(cdns); if (ret) goto err4; @@ -525,9 +572,11 @@ static int cdns3_probe(struct platform_device *pdev) if (ret) goto err4; + spin_lock_init(&cdns->lock); device_set_wakeup_capable(dev, true); pm_runtime_set_active(dev); pm_runtime_enable(dev); + pm_runtime_forbid(dev); /* * The controller needs less time between bus and controller suspend, @@ -574,52 +623,122 @@ static int cdns3_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_PM -static int cdns3_suspend(struct device *dev) +static int cdns3_set_platform_suspend(struct device *dev, + bool suspend, bool wakeup) +{ + struct cdns3 *cdns = dev_get_drvdata(dev); + int ret = 0; + + if (cdns->pdata && cdns->pdata->platform_suspend) + ret = cdns->pdata->platform_suspend(dev, suspend, wakeup); + + return ret; +} + +static int cdns3_controller_suspend(struct device *dev, pm_message_t msg) { struct cdns3 *cdns = dev_get_drvdata(dev); + bool wakeup; unsigned long flags; - if (cdns->role == USB_ROLE_HOST) + if (cdns->in_lpm) return 0; - if (pm_runtime_status_suspended(dev)) - pm_runtime_resume(dev); + if (PMSG_IS_AUTO(msg)) + wakeup = true; + else + wakeup = device_may_wakeup(dev); - if (cdns->roles[cdns->role]->suspend) { - spin_lock_irqsave(&cdns->gadget_dev->lock, flags); - cdns->roles[cdns->role]->suspend(cdns, false); - spin_unlock_irqrestore(&cdns->gadget_dev->lock, flags); - } + cdns3_set_platform_suspend(cdns->dev, true, wakeup); + cdns3_set_phy_power(cdns, false); + spin_lock_irqsave(&cdns->lock, flags); + cdns->in_lpm = true; + spin_unlock_irqrestore(&cdns->lock, flags); + dev_dbg(cdns->dev, "%s ends\n", __func__); return 0; } -static int cdns3_resume(struct device *dev) +static int cdns3_controller_resume(struct device *dev, pm_message_t msg) { struct cdns3 *cdns = dev_get_drvdata(dev); + int ret; unsigned long flags; - if (cdns->role == USB_ROLE_HOST) + if (!cdns->in_lpm) return 0; - if (cdns->roles[cdns->role]->resume) { - spin_lock_irqsave(&cdns->gadget_dev->lock, flags); + ret = cdns3_set_phy_power(cdns, true); + if (ret) + return ret; + + cdns3_set_platform_suspend(cdns->dev, false, false); + + spin_lock_irqsave(&cdns->lock, flags); + if (cdns->roles[cdns->role]->resume && !PMSG_IS_AUTO(msg)) cdns->roles[cdns->role]->resume(cdns, false); - spin_unlock_irqrestore(&cdns->gadget_dev->lock, flags); + + cdns->in_lpm = false; + spin_unlock_irqrestore(&cdns->lock, flags); + if (cdns->wakeup_pending) { + cdns->wakeup_pending = false; + enable_irq(cdns->wakeup_irq); + } + dev_dbg(cdns->dev, "%s ends\n", __func__); + + return ret; +} + +static int cdns3_runtime_suspend(struct device *dev) +{ + return cdns3_controller_suspend(dev, PMSG_AUTO_SUSPEND); +} + +static int cdns3_runtime_resume(struct device *dev) +{ + return cdns3_controller_resume(dev, PMSG_AUTO_RESUME); +} +#ifdef CONFIG_PM_SLEEP + +static int cdns3_suspend(struct device *dev) +{ + struct cdns3 *cdns = dev_get_drvdata(dev); + unsigned long flags; + + if (pm_runtime_status_suspended(dev)) + pm_runtime_resume(dev); + + if (cdns->roles[cdns->role]->suspend) { + spin_lock_irqsave(&cdns->lock, flags); + cdns->roles[cdns->role]->suspend(cdns, false); + spin_unlock_irqrestore(&cdns->lock, flags); } + return cdns3_controller_suspend(dev, PMSG_SUSPEND); +} + +static int cdns3_resume(struct device *dev) +{ + int ret; + + ret = cdns3_controller_resume(dev, PMSG_RESUME); + if (ret) + return ret; + pm_runtime_disable(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); - return 0; + return ret; } -#endif +#endif /* CONFIG_PM_SLEEP */ +#endif /* CONFIG_PM */ static const struct dev_pm_ops cdns3_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(cdns3_suspend, cdns3_resume) + SET_RUNTIME_PM_OPS(cdns3_runtime_suspend, cdns3_runtime_resume, NULL) }; #ifdef CONFIG_OF diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h index 1ad1f1fe61e9..1b1707796db2 100644 --- a/drivers/usb/cdns3/core.h +++ b/drivers/usb/cdns3/core.h @@ -38,6 +38,12 @@ struct cdns3_role_driver { }; #define CDNS3_XHCI_RESOURCES_NUM 2 + +struct cdns3_platform_data { + int (*platform_suspend)(struct device *dev, + bool suspend, bool wakeup); +}; + /** * struct cdns3 - Representation of Cadence USB3 DRD controller. * @dev: pointer to Cadence device struct @@ -50,6 +56,7 @@ struct cdns3_role_driver { * @otg_regs: pointer to base of otg registers * @otg_irq: irq number for otg controller * @dev_irq: irq number for device controller + * @wakeup_irq: irq number for wakeup event, it is optional * @roles: array of supported roles for this controller * @role: current role * @host_dev: the child host device pointer for cdns3 core @@ -62,6 +69,10 @@ struct cdns3_role_driver { * This field based on firmware setting, kernel configuration * and hardware configuration. * @role_sw: pointer to role switch object. + * @in_lpm: indicate the controller is in low power mode + * @wakeup_pending: wakeup interrupt pending + * @pdata: platform data from glue layer + * @lock: spinlock structure */ struct cdns3 { struct device *dev; @@ -79,6 +90,7 @@ struct cdns3 { int otg_irq; int dev_irq; + int wakeup_irq; struct cdns3_role_driver *roles[USB_ROLE_DEVICE + 1]; enum usb_role role; struct platform_device *host_dev; @@ -89,6 +101,10 @@ struct cdns3 { struct mutex mutex; enum usb_dr_mode dr_mode; struct usb_role_switch *role_sw; + bool in_lpm; + bool wakeup_pending; + struct cdns3_platform_data *pdata; + spinlock_t lock; }; int cdns3_hw_role_switch(struct cdns3 *cdns); diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 58089841ed52..ac90a484e63c 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -281,6 +281,9 @@ static irqreturn_t cdns3_drd_irq(int irq, void *data) if (cdns->dr_mode != USB_DR_MODE_OTG) return ret; + if (cdns->in_lpm) + return ret; + reg = readl(&cdns->otg_regs->ivect); if (!reg) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 7c2913bc8bd7..0111fba95797 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1766,9 +1766,13 @@ static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev, static irqreturn_t cdns3_device_irq_handler(int irq, void *data) { struct cdns3_device *priv_dev = data; + struct cdns3 *cdns = dev_get_drvdata(priv_dev->dev); irqreturn_t ret = IRQ_NONE; u32 reg; + if (cdns->in_lpm) + return ret; + /* check USB device interrupt */ reg = readl(&priv_dev->regs->usb_ists); if (reg) { diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index ad788bf3fe4f..b579ef15f4e0 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -13,11 +13,13 @@ #include "core.h" #include "drd.h" #include "host-export.h" +#include static int __cdns3_host_init(struct cdns3 *cdns) { struct platform_device *xhci; int ret; + struct usb_hcd *hcd; cdns3_drd_switch_host(cdns, 1); @@ -43,6 +45,11 @@ static int __cdns3_host_init(struct cdns3 *cdns) goto err1; } + /* Glue needs to access xHCI region register for Power management */ + hcd = platform_get_drvdata(xhci); + if (hcd) + cdns->xhci_regs = hcd->regs; + return 0; err1: platform_device_put(xhci); From patchwork Fri Jul 3 06:26:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39512912 for ; Fri, 3 Jul 2020 06:27:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D51D208FE for ; Fri, 3 Jul 2020 06:27:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="cCg/fsKO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726228AbgGCG1J (ORCPT ); Fri, 3 Jul 2020 02:27:09 -0400 Received: from mail-eopbgr150049.outbound.protection.outlook.com ([40.107.15.49]:37606 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726111AbgGCG1J (ORCPT ); Fri, 3 Jul 2020 02:27:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h1BJZ1/LmkbfbjBu275Nzay00gNUWtyW05/MrVsEvCHvDOUcm+bPHBcl9SLejO8l84hQtGOumq2tnPhRdO5IHsQU8iFBKxuriIStBKUqUeKL7eBTC3975FLZEpE0HSerwfFn03hjuQG8T3DbaIIMp7+hzaiZu17354Q84ArPmEJaWsIwx5kcDq/0GfoTQSzXHGVY19qv32PWEvzuVk2FlX6bwabAyvzDVgH155B4lGtjdRev9CSSC1/7aj1UWMn3GFiAWrJADl+oeVfubGchHmhxt8uwEho3VMzM7Nmmhr0wfyswvNXO651+RoSKlLvPiJczFBZ0dln0NGnYTbYZMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zaAsMoFJYOA/tMdj6A0S+P9vqeVgHiJ7RbbQ+LUABW8=; b=Xo7aRVkBmQX/Y5LPMUDM9TUGXOH4fU1eheLwKzZTxFVy9xcQ1NN/6fRnHvquTWAezr9PLSR5llpyMEN0EN79nbPK8s20nbP38oMXe/Qyz8+BY4ukSeVNUVnyK42cDBerk9s84ZXMRWp7s4YF1pVwt5glNw3RorjzSMba7DVabdMFqx2YCBVTk3nl69vcD9QYZunxOzeb7ZDxf1azQYYg71Ri4WMDgI2yyOVMDTDP5r9xJCZJvgZVacjAKoTwLDN/DywxHROOr41cdILZB84DqgYRPKPZROgn125yYb9we4vef6P4TIyH58nbesLkDXspBwZ/8YKj40/9oH3cbqzXYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zaAsMoFJYOA/tMdj6A0S+P9vqeVgHiJ7RbbQ+LUABW8=; b=cCg/fsKOONhHvvOvjUZL3BRrLaY0iTjHBu/cwwS7BktGj4CIJ4e4ZkkTJg6iV/ic++cqdve5d4p4n8ze4AQctCb99NkcMdYtAC9KO6xQkhkumwdiSygBxwkH24VklRU2ZvoqGTc7JJvhB+ah3mZmMmyfej37idRTd5I1WC3Wr8I= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:04 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:04 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 3/9] usb: cdns3: imx: add glue layer runtime pm implementation Date: Fri, 3 Jul 2020 14:26:47 +0800 Message-Id: <20200703062653.29159-4-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:01 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7d6c9af9-1ed8-4bd7-dfc4-08d81f1a1a5a X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tW8gJlC77nuygGZYFnW3dVw2ydkRIy1vHHI23quqCfpDAW8ZWd8O/2I+YziL2V/+T9vPhzeoaLsyLjiZSya8UwRKuRvFLJ7KoA8ZPkuAr23PZJAMwnIyI1g3W2fhNBFkhRUlHHWd6abiBeFCO8tpnlGJopO3Wjh4Bm71SyvQkCtD5EbgBq38A9hM1Hkx3AeW+pq8U0IZSPBwl1o8xx7M9TFS9AUB1ugxBwXjzttqNKZ+m2KwSDm0O3fiCsQcdtoPX8YqezjwLvF2LyEmVkbp6Eqai5ymigufW/+WFWtrxP7bWQU3mN1J5uiz4LVBdHTshwwgfpdYjO55IYuvtUOrhw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: x9ha6PWtgOLXxSSVkzJhpQ/DULwyxNfvwJIguKSaymGEF9WKuhZJHpfxjHFGar8H3/0RoSLHwST+i2GAK2WuvR1/Llw2/yPjpOarfOPpu4KfvYVOlwRr1YsOwHS9DTFqzZXVStJHMGpK9CTQDdsk6xsf1M12xqXhgpDDkx8O1n7C6w7tBUxaHi4a5kYeVPuaIHA94eAQL4PSfF1WfvDCn9IOZdntnSoDJqo380rtJ4mcMIGEEU7WCqK7pgTYHSt358/xmZmIwY20mRe/j76wILvIT+waqb2L9Y7pUhw6idSaG1+iza4tJCQylgyiCMQAm3XjzmYT3P4QvQ61WhP9glQNKUVN7tkFhQenzIO8AaDHRsKb84mqlXko7SJ+mg4bWH9cdIHERzcDd7DtPHZAdnHs8IBo5+UnOoaHTPdONtp0lDhW2aBOvkRFuB6sQxALMQKXycUOwr6FVQ+m1CXDHxg/wn3riboJJhKVyiLlwbY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d6c9af9-1ed8-4bd7-dfc4-08d81f1a1a5a X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:04.6401 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IOGSVDstyAieDO/BxK5N0ZbxIGNpwiiWqf3UH3pb4BcfL6bKgeQKnOfvtQC1OZmivGps8ZDtdmcLGuUjPJIYcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add imx glue layer runtime pm implementation, and the runtime pm is default off. Signed-off-by: Peter Chen Reported-by: kernel test robot --- drivers/usb/cdns3/cdns3-imx.c | 203 ++++++++++++++++++++++++++++++++-- 1 file changed, 192 insertions(+), 11 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-imx.c b/drivers/usb/cdns3/cdns3-imx.c index aba988e71958..b0254ecd9867 100644 --- a/drivers/usb/cdns3/cdns3-imx.c +++ b/drivers/usb/cdns3/cdns3-imx.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include "core.h" #define USB3_CORE_CTRL1 0x00 #define USB3_CORE_CTRL2 0x04 @@ -32,7 +34,7 @@ /* Register bits definition */ /* USB3_CORE_CTRL1 */ -#define SW_RESET_MASK (0x3f << 26) +#define SW_RESET_MASK GENMASK(31, 26) #define PWR_SW_RESET BIT(31) #define APB_SW_RESET BIT(30) #define AXI_SW_RESET BIT(29) @@ -44,17 +46,17 @@ #define OC_DISABLE BIT(9) #define MDCTRL_CLK_SEL BIT(7) #define MODE_STRAP_MASK (0x7) -#define DEV_MODE (1 << 2) -#define HOST_MODE (1 << 1) -#define OTG_MODE (1 << 0) +#define DEV_MODE BIT(2) +#define HOST_MODE BIT(1) +#define OTG_MODE BIT(0) /* USB3_INT_REG */ #define CLK_125_REQ BIT(29) #define LPM_CLK_REQ BIT(28) #define DEVU3_WAEKUP_EN BIT(14) #define OTG_WAKEUP_EN BIT(12) -#define DEV_INT_EN (3 << 8) /* DEV INT b9:8 */ -#define HOST_INT1_EN (1 << 0) /* HOST INT b7:0 */ +#define DEV_INT_EN GENMASK(9, 8) /* DEV INT b9:8 */ +#define HOST_INT1_EN BIT(0) /* HOST INT b7:0 */ /* USB3_CORE_STATUS */ #define MDCTRL_CLK_STATUS BIT(15) @@ -62,15 +64,34 @@ #define HOST_POWER_ON_READY BIT(12) /* USB3_SSPHY_STATUS */ -#define CLK_VALID_MASK (0x3f << 26) -#define CLK_VALID_COMPARE_BITS (0xf << 28) -#define PHY_REFCLK_REQ (1 << 0) +#define CLK_VALID_MASK GENMASK(31, 26) +#define CLK_VALID_COMPARE_BITS GENMASK(31, 28) +#define PHY_REFCLK_REQ BIT(0) + +/* OTG registers definition */ +#define OTGSTS 0x4 +/* OTGSTS */ +#define OTG_NRDY BIT(11) + +/* xHCI registers definition */ +#define XECP_PM_PMCSR 0x8018 +#define XECP_AUX_CTRL_REG1 0x8120 + +/* Register bits definition */ +/* XECP_AUX_CTRL_REG1 */ +#define CFG_RXDET_P3_EN BIT(15) + +/* XECP_PM_PMCSR */ +#define PS_MASK GENMASK(1, 0) +#define PS_D0 0 +#define PS_D1 1 struct cdns_imx { struct device *dev; void __iomem *noncore; struct clk_bulk_data *clks; int num_clks; + struct platform_device *cdns3_pdev; }; static inline u32 cdns_imx_readl(struct cdns_imx *data, u32 offset) @@ -126,6 +147,20 @@ static int cdns_imx_noncore_init(struct cdns_imx *data) return ret; } +static int cdns_imx_platform_suspend(struct device *dev, + bool suspend, bool wakeup); +static struct cdns3_platform_data cdns_imx_pdata = { + .platform_suspend = cdns_imx_platform_suspend, +}; + +static struct of_dev_auxdata cdns_imx_auxdata[] = { + { + .compatible = "cdns,usb3", + .platform_data = &cdns_imx_pdata, + }, + {}, +}; + static int cdns_imx_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -162,14 +197,18 @@ static int cdns_imx_probe(struct platform_device *pdev) if (ret) goto err; - ret = of_platform_populate(node, NULL, NULL, dev); + ret = of_platform_populate(node, NULL, cdns_imx_auxdata, dev); if (ret) { dev_err(dev, "failed to create children: %d\n", ret); goto err; } - return ret; + device_set_wakeup_capable(dev, true); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_forbid(dev); + return ret; err: clk_bulk_disable_unprepare(data->num_clks, data->clks); return ret; @@ -194,6 +233,147 @@ static int cdns_imx_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static void cdns3_set_wakeup(struct cdns_imx *data, bool enable) +{ + u32 value; + + value = cdns_imx_readl(data, USB3_INT_REG); + if (enable) + value |= OTG_WAKEUP_EN | DEVU3_WAEKUP_EN; + else + value &= ~(OTG_WAKEUP_EN | DEVU3_WAEKUP_EN); + + cdns_imx_writel(data, USB3_INT_REG, value); +} + +static int cdns_imx_platform_suspend(struct device *dev, + bool suspend, bool wakeup) +{ + struct cdns3 *cdns = dev_get_drvdata(dev); + struct device *parent = dev->parent; + struct cdns_imx *data = dev_get_drvdata(parent); + void __iomem *otg_regs = cdns->otg_regs; + void __iomem *xhci_regs = cdns->xhci_regs; + u32 value; + int ret = 0; + + if (cdns->role != USB_ROLE_HOST) + return 0; + + if (suspend) { + /* SW request low power when all usb ports allow to it ??? */ + value = readl(xhci_regs + XECP_PM_PMCSR); + value &= ~PS_MASK; + value |= PS_D1; + writel(value, xhci_regs + XECP_PM_PMCSR); + + /* mdctrl_clk_sel */ + value = cdns_imx_readl(data, USB3_CORE_CTRL1); + value |= MDCTRL_CLK_SEL; + cdns_imx_writel(data, USB3_CORE_CTRL1, value); + + /* wait for mdctrl_clk_status */ + value = cdns_imx_readl(data, USB3_CORE_STATUS); + ret = readl_poll_timeout(data->noncore + USB3_CORE_STATUS, value, + (value & MDCTRL_CLK_STATUS) == MDCTRL_CLK_STATUS, + 10, 100000); + if (ret) + dev_warn(parent, "wait mdctrl_clk_status timeout\n"); + + /* wait lpm_clk_req to be 0 */ + value = cdns_imx_readl(data, USB3_INT_REG); + ret = readl_poll_timeout(data->noncore + USB3_INT_REG, value, + (value & LPM_CLK_REQ) != LPM_CLK_REQ, + 10, 100000); + if (ret) + dev_warn(parent, "wait lpm_clk_req timeout\n"); + + /* wait phy_refclk_req to be 0 */ + value = cdns_imx_readl(data, USB3_SSPHY_STATUS); + ret = readl_poll_timeout(data->noncore + USB3_SSPHY_STATUS, value, + (value & PHY_REFCLK_REQ) != PHY_REFCLK_REQ, + 10, 100000); + if (ret) + dev_warn(parent, "wait phy_refclk_req timeout\n"); + + cdns3_set_wakeup(data, wakeup); + } else { + cdns3_set_wakeup(data, false); + + /* SW request D0 */ + value = readl(xhci_regs + XECP_PM_PMCSR); + value &= ~PS_MASK; + value |= PS_D0; + writel(value, xhci_regs + XECP_PM_PMCSR); + + /* clr CFG_RXDET_P3_EN */ + value = readl(xhci_regs + XECP_AUX_CTRL_REG1); + value &= ~CFG_RXDET_P3_EN; + writel(value, xhci_regs + XECP_AUX_CTRL_REG1); + + /* clear mdctrl_clk_sel */ + value = cdns_imx_readl(data, USB3_CORE_CTRL1); + value &= ~MDCTRL_CLK_SEL; + cdns_imx_writel(data, USB3_CORE_CTRL1, value); + + /* wait CLK_125_REQ to be 1 */ + value = cdns_imx_readl(data, USB3_INT_REG); + ret = readl_poll_timeout(data->noncore + USB3_INT_REG, value, + (value & CLK_125_REQ) == CLK_125_REQ, + 10, 100000); + if (ret) + dev_warn(parent, "wait CLK_125_REQ timeout\n"); + + /* wait for mdctrl_clk_status is cleared */ + value = cdns_imx_readl(data, USB3_CORE_STATUS); + ret = readl_poll_timeout(data->noncore + USB3_CORE_STATUS, value, + (value & MDCTRL_CLK_STATUS) != MDCTRL_CLK_STATUS, + 10, 100000); + if (ret) + dev_warn(parent, "wait mdctrl_clk_status cleared timeout\n"); + + /* Wait until OTG_NRDY is 0 */ + value = readl(otg_regs + OTGSTS); + ret = readl_poll_timeout(otg_regs + OTGSTS, value, + (value & OTG_NRDY) != OTG_NRDY, + 10, 100000); + if (ret) + dev_warn(parent, "wait OTG ready timeout\n"); + } + + return ret; + +} + +static int cdns_imx_resume(struct device *dev) +{ + struct cdns_imx *data = dev_get_drvdata(dev); + + return clk_bulk_prepare_enable(data->num_clks, data->clks); +} + +static int cdns_imx_suspend(struct device *dev) +{ + struct cdns_imx *data = dev_get_drvdata(dev); + + clk_bulk_disable_unprepare(data->num_clks, data->clks); + + return 0; +} +#else +static int cdns_imx_platform_suspend(struct device *dev, + bool suspend, bool wakeup) +{ + return 0; +} + +#endif /* CONFIG_PM */ + +static const struct dev_pm_ops cdns_imx_pm_ops = { + SET_RUNTIME_PM_OPS(cdns_imx_suspend, cdns_imx_resume, NULL) +}; + static const struct of_device_id cdns_imx_of_match[] = { { .compatible = "fsl,imx8qm-usb3", }, {}, @@ -206,6 +386,7 @@ static struct platform_driver cdns_imx_driver = { .driver = { .name = "cdns3-imx", .of_match_table = cdns_imx_of_match, + .pm = &cdns_imx_pm_ops, }, }; module_platform_driver(cdns_imx_driver); From patchwork Fri Jul 3 06:26:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA200912 for ; Fri, 3 Jul 2020 06:27:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C955204EA for ; Fri, 3 Jul 2020 06:27:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="rRFKNw13" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726257AbgGCG1L (ORCPT ); Fri, 3 Jul 2020 02:27:11 -0400 Received: from mail-eopbgr150049.outbound.protection.outlook.com ([40.107.15.49]:37606 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbgGCG1K (ORCPT ); Fri, 3 Jul 2020 02:27:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WrfttDjw6v03CJJOWzHi9faQvtu4CthZD/iQraUV8GdoOhqozfeeuuLrs5Am97WW/mmPHJF4QkwcugNZ7S0fjebcmXEoHDPk4N/x1o3v9zBuEUBQ56jy1LbDF0tujNtZ+WgajVWL/5D/6J+9OCEwwh7Clrxzy8YfGz+4ykBLV6HN118J/r1YICRd/uDYSaZf3mm+YBmLCDhCIADmnCfCBfRCn0fEq5m1wSYR+KZLI/qs49I+LaBmrCxxauOUsHH34jgG/pLuaDTO8Xy1LGasrJOC6jh7DM03S6mVs46xZ41PFEMgIo6tmNLyDdg2zAIrDM7bZ97KmgOxiqzxDwUl6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kYBwFIPI1hjH7xN7LE8t80TTpuQEDF4qeg1U9pJXluA=; b=GB4e57YOGvN08u4VrEV9UGHPQVlZPAzN6aX/6YTbldRafo4T8wzUfkhEZgZJQU+LF+NFZkx234PGm8uukyPj1t8/G4jI/jHEgZBb4ytUD2mM1u+PhCkB3FbJFCebu/XeZ6l0+fM1EXLoUjL1XAfR78Kyb/VSLAkd5krOlNQ6t/WCZT4tcO2ezgBE6lbX35BwvoiQeB7dJ30H2nsgWtRG4J3kc7QvAELiavguWsw0FMLuVCnByf+BgGCsMOvxi3jFoGmo3lcjhTzq42/fIVqqpW0bkrDOR/w9AqcPWeKHcZYWU6XHzQoKYhTwxOzoO9IjjgcBbOVBW2rDDgRTomHEnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kYBwFIPI1hjH7xN7LE8t80TTpuQEDF4qeg1U9pJXluA=; b=rRFKNw13yjVSbee6xj77kgNsYk7I4xVKFF3kYtmaYWj56oKMmEkaTZmzDeXMZrQgQdnOZWkmAtY3xY8Eng0CgTixWURX/jKFp09D2q6NJPkR+RznoIublL1Lol0t9hbsRoP7zy/OxHQiJSscB1LG9d9EYH/PjN/4yriXCHrdjgY= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:07 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:07 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 4/9] usb: host: xhci-plat: add platform data support Date: Fri, 3 Jul 2020 14:26:48 +0800 Message-Id: <20200703062653.29159-5-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:04 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 79e4a0d7-05b6-4cc6-0a9c-08d81f1a1c33 X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fA2JN9W47ZB4eGYi40rK62f87VD/wIDezzBxHrIu05ikZMal+zt9U6JHoM1NVRYcLTUy166XlO6ae/VfHm7fyjPEHrrI7TqCuwAnbs5LdwP0QDC53F0r0XK4sfbGEFmxmEmu44Q+ELuU5tR9yGuG9NOfVo3zjAtrMy3Ug2mJ//cgGXTvDhkXngi3dCwlHFUrCdoqjDCEpkD2aoLHjnOLV8zBl2yzvnNRnybc4z+5UY2nbCKVQxwCnTYNAQJUZFyj3T21fqajXfb2DBn/jMWlTpsQpY+OymwCC4hrRVEb93N4s/VMfBJhOxKDgV84JyMV+/OljPswTV8Vryzs7lQ2YQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(4744005)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: NsJvh+2ugWuLPpaS2miqI4hxwXMnI0MvB63GuqMDcC1iaOP0UZkdpB/8wijAhX2xyMIDAgG71N76hNWlu9KOqr/01LY9NTj8FXuSPtlNKq8F2Xdj899N5q9M3s9PZZZ4l4Kxok0ecb5Ymf8AquDD1gaYMKdUqP2F+B4mbnUImCctKZ4MU+SowUd8/CO7ho9gllJlNCXFXFxlApQxjF207nwmTmPQT6nSrrbkmYWZAx/BvZHIhbeyX9XT2tcfJ8ytmJQwu+9YxXAzo/Uv78TIXLDJh13fYuwoyp1amMQXhrEsKkG+lem2oHs+RgjP0boMgEZ9sX7CFpT1MUnMMR4rm082ctUtqfZjksdNt9/IvZ00nLlccmYtAw8+R4BSiQ99/6RPCfGEJ96MJ2sBnYQN+cfTuumPYrLDmYjXk75KPBrnx7jGkYpEl9Od7r3ChpDoJ8dBRdf88dHLJ3APUYxt9uAuquk3rKc8r6seewPoEgk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79e4a0d7-05b6-4cc6-0a9c-08d81f1a1c33 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:07.8480 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xQ5VYlD73NyNiPnQFSJhzTXFielu53ZOf2n2ynlwSvtGgMfy9SqxAvQGW3GMLcRtbPECmkxk0KO+SMJYoW5UGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some xhci hosts (eg dwc3 and cdns3) do not use OF to create platform device, they create xhci-plat platform device runtime. And these platforms may also have quirks, and the quirks could be supplied by their parent device through platform data. Acked-by: Mathias Nyman Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index f6b4089bfc4a..38bea2b6a17d 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -264,7 +264,11 @@ static int xhci_plat_probe(struct platform_device *pdev) if (ret) goto disable_reg_clk; - priv_match = of_device_get_match_data(&pdev->dev); + if (pdev->dev.of_node) + priv_match = of_device_get_match_data(&pdev->dev); + else + priv_match = dev_get_platdata(&pdev->dev); + if (priv_match) { struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); From patchwork Fri Jul 3 06:26:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D66C0912 for ; Fri, 3 Jul 2020 06:27:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA179204EA for ; Fri, 3 Jul 2020 06:27:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Zck11C0G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726305AbgGCG1P (ORCPT ); Fri, 3 Jul 2020 02:27:15 -0400 Received: from mail-eopbgr150088.outbound.protection.outlook.com ([40.107.15.88]:48441 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbgGCG1O (ORCPT ); Fri, 3 Jul 2020 02:27:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FOoXu2HHfgRiqKlXc7OCvTAbhalo7dUlUoIjDZwima6jmSS7UQnZcJ5UkidESG/mGdHYp068S+S/HWBpA58UZUipMi60kOGhvt2nWLUEIV7vg2ODzI/hsbMiQd7iJNdZ2r3YghVu51PeY73rMZRzp/i7UkFOf8CsJs9Rq6DIc2eeVvZH/8XMT7JN9MFMv5kr5x/FkfDnETDlVkS08hGZfAxK80QN22CL7HYpqggUXym39rCILiuCIyJ5ItBtex0Q2EeCXgcLI5E2fEeYCi8g0Mmk/xJnTcPSuGBqk26VxLpeFIKu2tx5z8q6vc9EPMlxsTz27pX9aGiQPpJmsasTrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dMQLfBPyXbpDrAKzqHD/p2xqgDbJ7+uoe7MLUV+kjNw=; b=XPEaC8A9YpLYB+FX1N8IFdiZ5howzf9OqwXPquT5GIKkO3hoRwmliY1qMisczK7TH2RReg8rBH2qB378/qL0vTXXpOlODu+Cjkh+U+MWURv1lik4yzG/5VQmRIaf5eAHEUPM4vGFK0PZC/t6wGH4wwV0WtCRzVENrOgp5X/bEpmrXWWP6vPpzIXoHMBxt6GAg3W+DemOfVf2+2DfPxv2NaOeRO4cvL9PIwV8pYlS4ctOdSznxkr6vqW0H3BpWhdXzbMSOyw9mCJUnwp5P0T2UChvi4N/lIUxCNLxtngHy/iUxhZ55Q9fpHFJklO7MxRNRbmCKxpJRMWIPSFh/6wz3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dMQLfBPyXbpDrAKzqHD/p2xqgDbJ7+uoe7MLUV+kjNw=; b=Zck11C0GuJ21lga9MVMw6/I8+9zVGumu1Ybkns0UFr8srZW2sb62c53Jyevay/AE5mFTCdh3Hbfdr3IqyQ+ZWPA8GASjpIrn/165c197gdry/L8FgBgBWUFyQ2iCIxHsnPv1YVpXPx9JNc9vEKjTgASmyFSG+aI1BKJuUOcmpT8= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:10 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:10 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 5/9] usb: host: xhci-plat: add .suspend_quirk for struct xhci_plat_priv Date: Fri, 3 Jul 2020 14:26:49 +0800 Message-Id: <20200703062653.29159-6-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:08 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8d0111dc-9fc5-4e0d-462c-08d81f1a1e18 X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YJytynxvIYbSJ0o8SpcsTA+iT1ZkYBTcNPEUL9Efp1IL0WlK+XNPuykJPVoMOw/FyTDzlKndaU0ND+4P/U+n6ZI1sGDdqUNWcraMeqMQ3vphP9Nx2IJOxZmT3d461tNyt6kfm6eTrMYmn8XY/Z10kDIp0kdelfmytcGqtinKn4cO/sO4xev/RdQ493TFta6oJD7l8W4LblRE73tnkL/Khma2EGZr3mjUAsNDxBN8f3VrhozBRTIZ7nEXK3DJI4Dh6MyVRFJp1WjOl8JccWXSj7DFY1DbNX65j8T4BFrnYXdkjmsTQzRfI2u0NlhsSrOGe1qyXFXr+xDuhivDs/nIc7e2Q9fG7u/eHeM6TmtmIfI13cUV8xSRy/ysRQRqIMY4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(15650500001)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 97tn5f3EDMvtb+HhMBrK+jHxYwFzaNuQUNT1RSwx8DwpeawYR0O9cyGI+BfYnhBq++75qOYUM4RDVUQ2TEYmZGV1CrvItnSDqq3Ovd5hXIqNHB7NJVAuH/lWoaioyjceTjvzRWAxEZZ08ODd8YAc2PHOY533+B1kRwX4cM6sngd1CffseT6BpnRgIhA3/3lUYRt8m0P0FJsoTocCvw8wjM+Ow3K7fMj1YXPKtmE8BhDOwDVNu0PwFy/uXY0op9tebn9R2wO/u2f93hjw7F8kouxMjds3HIwqW8HpCqvVua1bdzc+dzzaf3mtUixMrXPPtHxZhHgBdQO82XRr2IN55MvygCnPE9D61odIoYtWrq29BUgjx39VJxr1OG3BP9X7jK5vXt3RdeVcXQkumCMsLZqkacctbzMyv/cKv+JbkBEQYl/yzPfjakRPAqwaUqdy8v82Q6O1t19RlQvirw2PX2dqzooJbej0Q4YeCdOPtbk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d0111dc-9fc5-4e0d-462c-08d81f1a1e18 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:10.8986 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cQZrHUtxWyPu2Xel5wCrcPBs5c+kAV2AwcUA87TY7NAZ7BqTSF08cvQKO04jaijNat93rf1ouscU8K8u38J6/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some platforms (eg cdns3) may have special sequences between xhci_bus_suspend and xhci_suspend, add .suspend_quick for it. Acked-by: Mathias Nyman Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 19 +++++++++++++++++++ drivers/usb/host/xhci-plat.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 38bea2b6a17d..51e20464fe0a 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -54,6 +54,16 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd) return priv->init_quirk(hcd); } +static int xhci_priv_suspend_quirk(struct usb_hcd *hcd) +{ + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); + + if (!priv->suspend_quirk) + return 0; + + return priv->suspend_quirk(hcd); +} + static int xhci_priv_resume_quirk(struct usb_hcd *hcd) { struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); @@ -401,7 +411,11 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + ret = xhci_priv_suspend_quirk(hcd); + if (ret) + return ret; /* * xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. Since xhci_plat_suspend is currently @@ -438,6 +452,11 @@ static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + + ret = xhci_priv_suspend_quirk(hcd); + if (ret) + return ret; return xhci_suspend(xhci, true); } diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h index b49f6447bd3a..1fb149d1fbce 100644 --- a/drivers/usb/host/xhci-plat.h +++ b/drivers/usb/host/xhci-plat.h @@ -15,6 +15,7 @@ struct xhci_plat_priv { unsigned long long quirks; void (*plat_start)(struct usb_hcd *); int (*init_quirk)(struct usb_hcd *); + int (*suspend_quirk)(struct usb_hcd *); int (*resume_quirk)(struct usb_hcd *); }; From patchwork Fri Jul 3 06:26:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B084912 for ; Fri, 3 Jul 2020 06:27:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6205F20A8B for ; Fri, 3 Jul 2020 06:27:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="aR+PDAJa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726310AbgGCG1S (ORCPT ); Fri, 3 Jul 2020 02:27:18 -0400 Received: from mail-eopbgr150088.outbound.protection.outlook.com ([40.107.15.88]:48441 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726262AbgGCG1Q (ORCPT ); Fri, 3 Jul 2020 02:27:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+6h+evn183dTOOJ52U2CultYOW7WBXEz+XztrXJEwjwd/jO+/X/1gm5P+6vaOpvq6p6NJ+tt9hPOpiq3wNtcRJB9uHZQHmnEqhG7amk5fqlQoaD3DqGhGYyf2wl9h9WLTYY2a0Ukskxxw4HMxBeFb64peDC9LqrL2TDk+TGYYUVQqMyF01nb1dzheDL2nHbmpPLcGywEdtTAQXG5IEqN4Nlg1NDzC6A38vqE/umtDS4LhqLvt0/EDCrhpwGL3cNIWEhM3kUy/cICgkdZhWlFNZkZljLTwivPrYBcOk2Ekojoi02rehJ29zGzM8eyOX35Qa8EmGKfYr48vfCyZiZVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lELQYUlix2zOqpaJNgCC/fvRggI5eFM8GAUeI85aeuQ=; b=FXeN682kDIL7Z0HHhSZbnyxTvcHdurpkiLBgoZZIdgguZy1B5eZQ3lOxl2tljAX0Fm1HODqD1LaP4LGJdimerBC8J9L4J1GK1d4gnle1ZTaftf+66YdbXCuQCx3QHp362SBUSut/N5PCzln4PV81wPErp5TB8tnMJq6DY/K/3Yc5CV9uI48o7Uo19DbX+YaYxUZGsIPb5SR7Q79qO9eduh9jxaZFH88PDgTfjwddxUOHO5ubftUA1I4FWrS2q2yCUhjhxF7Te39lmV07kltcqNgYpbfLbp1miGCC74c0Q3YB6Ux6EzDr+IclXPny4xtLl4fuUPUhTqYwVGbs6tgLbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lELQYUlix2zOqpaJNgCC/fvRggI5eFM8GAUeI85aeuQ=; b=aR+PDAJa9YAn3qY0ZMdd7W5t9Jn2eTZjZlgD1p+i7DPcRQbQEHczjoEY5ptqmcjViduk0y2tIWQydZNL0Kk5Q26YxU9fqKFdyDQBQQKE2npK2QJvHaAz50kqCYA21HvQGhurYYOYnTSRHPcXBAbrXCeAloMhl6MZlH266zJrPU4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:14 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:14 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 6/9] usb: host: xhci-plat: delete the unnecessary code Date: Fri, 3 Jul 2020 14:26:50 +0800 Message-Id: <20200703062653.29159-7-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:11 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8aa8039e-6543-4b64-ae2f-08d81f1a1fe3 X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S46YsD4icO/+aCQTDa224q9z1VulOVjPCJAijxOPAtHM9HCqN9Bu5h4fGWw9kaM6Vjxam9Dmzlc7vAufYyGx/DLekDuLTSrcPbaUj+xftgjsO4xgeqkx+q/9Jr1v0UvKmfj33N95yoe6xf1NOOWFy/TPL7X+XY20rfm7cHADcrlKapkoOh7/NTAXz1wZveKyn1JNp++I0Jxj3lrDJ3wXJA1YfIwPia7fgwj752CkoVv+cMIbdf6Nk2v2T/O3Fmy77aiPsxCDrJ4J+zyJERNPn+4eYumiZVeJ4jKDNQtfUSJLlnT0GzvbGSkDRIfwoca/LFhaA9uFE5IYJWWctagA/g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(4744005)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: USnxyEfNC9hoVNMLAthgtnSBSKx8oeZkFkfyjK9ME/WaIbYp/kf9lc6IvSo96+Lr0Nn52cuhsNZ6aSjS+foAXY2zHVi02aRZQuT1pUTcAp2b3yy+FlqYH/xFQlqI+etdxpdgJhPiLtxwnSNPxEhddmTtUXLtOqhJb1Hk2yrVANmP4Sgd5thly3xPSeSiMc/ewVFHuA7mFxHcnPhjTnvzIA7+2g73eL9eaqUR1bksi3rXg2lSbud8PCNZPONlGRIVF/kxRylXnLVZP3cIU0NYtoQuVzhO/bCNw5Zxf1vCCSTdQEFTCSQmmJrQR9HXfbXwcsk6XiFc8hjqi+XTqDV0Ri2Rxtivn40w0Rs+53Wg+jqVKOzGCgdC3g9Jzttb7aLds3rA2aXmmq02DCTH6bxOLz3NxR5DskSalenV/QahMEt/i9luCix6Wv6i27rT0/wOV6/1VkYZlWOuzx0Qy3XhovrOPuHtVz0shd6ErbHYEVd0Gaz/FBjg1hIgue61bmn5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8aa8039e-6543-4b64-ae2f-08d81f1a1fe3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:14.0478 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qz3JH3bp0cW4aepTIfxp2iUP/Mm/NRwKxia6M8vDe+CutYp9UZWsUY7sdo/Smju3Mc3WBldDu76GgqfOEgYmuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The if {} condition is duplicated with outer if {} condition. Reviewed-by: Jun Li Acked-by: Mathias Nyman Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 51e20464fe0a..03d6bbe51919 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -283,8 +283,7 @@ static int xhci_plat_probe(struct platform_device *pdev) struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); /* Just copy data for now */ - if (priv_match) - *priv = *priv_match; + *priv = *priv_match; } device_wakeup_enable(hcd->self.controller); From patchwork Fri Jul 3 06:26:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6467D912 for ; Fri, 3 Jul 2020 06:27:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C1F420772 for ; Fri, 3 Jul 2020 06:27:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="gUVkYGhq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726311AbgGCG1U (ORCPT ); Fri, 3 Jul 2020 02:27:20 -0400 Received: from mail-eopbgr150052.outbound.protection.outlook.com ([40.107.15.52]:62390 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbgGCG1U (ORCPT ); Fri, 3 Jul 2020 02:27:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wo7dK/fE/A3/kmGvfaKO9TN/w8Rzn7ZizwFE2V2I/xNT0m1uCV682p27FCxAGKJNZguBmomf8/9UOd8E+lII5OY2NwM2kbGO2cB8gLz9DOSX9/ZtJ8sS+OTpr9L7cwdSldCwgbTpJHUcasnYld+V1xxLjXItEBN5B2NxfBVyVT+RJESjDrmGCnZvTrFCXCkA/906/6yt4P1Hzi95GkCoJSEOlXDRB/M0D7k3xxMqzpj7V+OA5wkaZhN/+ivnbSGamQBNU2ggOt/Qp5ME850oyoSCltTQtIc3dVG/r1dFzRYomC1eUa4HSXEyUv7HkDiLrWzv9/o6BpbUy7k75avpiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dhqiqvdaFCt1c+T6UW3GBMwC2+QBPcfHNhVRZlPTY3M=; b=G2VnbNYY60bBzFgDuYmQIxAOS7YQ0ShXdiAtZpNsSCY6rGTVBM8Kf9qFPaWBdkSuKx2XzjXJp2RMGoqq5ynlKQ+rhaG/7INVeA/9YBxiDpm2PQ/Q+wPpaiSrwuUv0MhOT9txVTcnXlvYKEt7J74uH+9Y5kQfbwpP5A5qbJbZNDwAKX+C3dWQjZyuFwm76nCQ8AKC+HDe5a/oG0+eqkHIp/L0sIUc2klHXGgfZA89Yzy2QZznzIVlih2QOGTGvmAdx1LfqXsCay7FguVBfv4OESn8MfeCKy48s96D5pbo+T/S+5nCXHzonKXuLhTaSBLRrHf9qG3hYU71/FGKAizZiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dhqiqvdaFCt1c+T6UW3GBMwC2+QBPcfHNhVRZlPTY3M=; b=gUVkYGhqu2t71VkqzkhYETGXFs5P+7ZYRBS5uv+9Oq+CXKrVc0hO0Y0e6CXPQ9ME7vv0y/4RVybzAA4WoboUQkusU3FQHNPdFDL9jOhYpEcIfwPgfqmYC4oEMBoSbOXLsR32UR1ysBKZfEfCKDmZ+lbi3WNCRPbjbQZlKYyrKy0= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:17 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:17 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 7/9] usb: host: xhci-plat: add priv quirk for skip PHY initialization Date: Fri, 3 Jul 2020 14:26:51 +0800 Message-Id: <20200703062653.29159-8-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:14 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 09cbd118-f9dd-4d1a-fa09-08d81f1a21c9 X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5y8fXwWmmQdv0IE6/5MzsCPQUioVurAHoL7HjUpGHop7DDpYfAkrt4YCxbL7VoPfdTgJRQnD+Hd6IUGcy6/tQJiHZtw0WyWleTy5vu5BK601S7ZJFAWpNfjOgxDYOMcaqAWblQxvUIUGLOmwwcLY2toQL9BemBe/64jciPWkQcSIDvwP2UpRGdcOCbzhhvfz7n0gNl1h0NQ1H+HVwHvsrNfbFhESzgV4OhLMsHPq387SBAdAJX5QEWQ4ERUXru02KtS266My0CQbIanE5mA7KlSw/8V+leNvSVm2BVfWiDbCRiHozNztijqiLiNyDG0o3vdzkFY5/y3L4kuJC+MGzw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vNGt+DkOVvZmoOnaGZcVKYJHsM9PB3RIMe8VmVMx3Z8kff8PD0WnyT0SBLDyKKx04gtXemI/Nm7eqh8LxjCi3b6SYV+z/xDPWVdv6O/2C1VEKD4r+E9uHGgIVBEVZg2LpMC7b4+KnD3MtmIeHb4+q2s/BwVPBl7Sqpy8FAr7Ab1j2V4W1RinbAtTO9e38oNw67nGDZfLFFbrTHlqklW5EU5acFaMNZvXcPiZAil7JRsGuMh+GjqaNtN18hQiBZ+qRf+BmJ2UNfQacL1TZzzhth7XWAN3IX1k3C1e+VwWGU1gIRb3pLFaUV8TpJYqS4FlbS4O1Fk3B2Q3BNyoP6Rw5xnlA7UtsVjOTnkHKyN7E4uDAAgIUalKt1oRtUdqMMbvdNWPEIs/e48KfF9VuNsTL86oluJpc07OK+kmkL9wobtRdWrx2IWbRgkP3+X0Dd5T5eqw3IbmQUcMgrD2qBUK2QX0oghI5Gh4wV6pnL1LoHk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09cbd118-f9dd-4d1a-fa09-08d81f1a21c9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:17.1551 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HhcwA3YBWoNs80JbESEtHTi62sQPg5boSjbJ2RUD85kMHYM5q9Uyk7wI6Lc241VSD5DGWckAeEgJvOrnV5YM/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some DRD controllers (eg, dwc3 & cdns3) have PHY management at their own driver to cover both device and host mode, so add one priv quirk for such users to skip PHY management from HCD core. Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 8 ++++++-- drivers/usb/host/xhci.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 03d6bbe51919..cebe24ec80a5 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -183,6 +183,8 @@ static int xhci_plat_probe(struct platform_device *pdev) struct usb_hcd *hcd; int ret; int irq; + struct xhci_plat_priv *priv = NULL; + if (usb_disabled()) return -ENODEV; @@ -280,8 +282,7 @@ static int xhci_plat_probe(struct platform_device *pdev) priv_match = dev_get_platdata(&pdev->dev); if (priv_match) { - struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); - + priv = hcd_to_xhci_priv(hcd); /* Just copy data for now */ *priv = *priv_match; } @@ -329,6 +330,9 @@ static int xhci_plat_probe(struct platform_device *pdev) hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); xhci->shared_hcd->tpl_support = hcd->tpl_support; + if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT)) + hcd->skip_phy_initialization = 1; + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) goto disable_usb_phy; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index c295e8a7f5ae..07d71fec18d5 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1874,6 +1874,7 @@ struct xhci_hcd { #define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34) #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) #define XHCI_RENESAS_FW_QUIRK BIT_ULL(36) +#define XHCI_SKIP_PHY_INIT BIT_ULL(37) unsigned int num_active_eps; unsigned int limit_active_eps; From patchwork Fri Jul 3 06:26:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE0D6913 for ; Fri, 3 Jul 2020 06:27:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B13A620772 for ; Fri, 3 Jul 2020 06:27:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="BG2hPIVr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726323AbgGCG1Y (ORCPT ); Fri, 3 Jul 2020 02:27:24 -0400 Received: from mail-eopbgr150052.outbound.protection.outlook.com ([40.107.15.52]:26597 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbgGCG1X (ORCPT ); Fri, 3 Jul 2020 02:27:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=myDptRRhvtG7vVr2F9QaKbRmXCYJpxSrXrblY8tlbINTSDbTSzSE9FZxBLKlsa4FzuMTWKxZ0S+NDaa7pHcsUnr/Kwp04o+XKWOt896VZERW+X77fRxblY3tcRF0eJo8Lqg+yA2wGjnSx7Y4scrkJR8pA/aK1vCrdUeZHhYwTkI9yoMfEHHrx/pgggz+wmUFGYPp97Jd4CP1H3uQEFGFsiybbXsLrYgu4Jt7Mc1VfMFrt0DWyCQ3suG857W4mSx4E8Xpys4J0D/VIHyL0ZoxiT4k9nTVN33fhvKGPjPCmx3+aXDd3apWtFi88++Kk2PLkAcyWlxGyDz/eXhBwhHAQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=awe7nqB8eZwjtrkIA9n1ZMYGeDJNbopX+R1gbb340Bw=; b=IlOUUEW7tY8U9IOHFduOQf4obrUWf08y/mrnVyMeLnGR77iyjoCgrS0IrhhSY+me0jh+LQh34xkl/Xl5oXQWBavy7tFcle9ijmXIZCFe+LaHHeJ3iIeuYg9KWdjRpItb9/eTkzAMrIS6zFeUSGNjwRC6TME2d6ug2epz9YSl6rmnv5k6eNHk9ZSRVc2PkyROe9Rn2Ixs959984awcmyGiBTNpFwK6m6f0gMFoWV6Zv9zxaF1FLBYLB25fi0MsVJX1EyL5g55PK1k31BKqSXnOQA0+Km+u8Dw62bVpUn55sd/lJqL02+6KGSirbVhWMekZfRbFt2pFxZxi3IbpfvluA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=awe7nqB8eZwjtrkIA9n1ZMYGeDJNbopX+R1gbb340Bw=; b=BG2hPIVr0dy4N9m7VeNAJ/oCAOhcJDZ5DBhi357xcnNQQWahD+2KSWFCIZ+e9tfLTG547Pl4kj+UgLZR3t6U5JXitvZStCN6MlmpCWo/WBxGubukL/Osu6HIWpJyUXPEBihUL+AJOVR82T2DFpM2sd7X2KwVN8P90UKFi6PX8lw= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:20 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:20 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 8/9] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Date: Fri, 3 Jul 2020 14:26:52 +0800 Message-Id: <20200703062653.29159-9-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:17 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 41abe3d4-024d-44a3-2b57-08d81f1a23a0 X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZQf0E9Oz9RGakElzHGVHyz2w0fiT7Bp2x2aSRIy/xIk3HTRch88p3vovCSKSCq10Huvh0JGOG07VQhDQwlUFHFG2jhQ6OIadCRFrc/lIqAsbqC8JmHYJSprcrJEGwy9vmIUjCS+JhPsP6F3S6NtfeCbzKJKe3vjcJsOKxN3wCfitkuzbPSOgUVwEULJ/DaKOpqw7vlABcnPOrgBBBQCzEOEhXk1QETj2a0BUXTFd02nMDJE3aGdN/oQ5ZSFbpk8O+deDcTSX48xxxT7qtVGmUHgAyXSQ/isInDuCSO8pqTEJTtVUAj8OGW+vJNRdxKzHgMom5Qs7tfS0ZVJ7BqMQx4d6eGXQnI6cD1YCpmTLwvUBR2LXxKWhEkpodOxe0aR3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(15650500001)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: x/VnTHkqQxzjlfYg9sYFhIHwH6y9BpNyhjF8e2AgMkypAtNHA20FvUuGONngJ95XZBdAG7uW8uVjnKb3jln2xbjpA3qOxtkrDefO6MqINXWSQ66GzUixB/FC5DEry7XbiSTpWkZTsnX+WzabnMpZ3Vn4eSDQcGl8bYISxje1/svhS1UsCkSK3LmspNBAsJyqDK2opelKkchws8DwzLMyNX5MeMacRpRnCnvNsKJJz3RWxsLmMZwtxSaFA/UQ4hqcqq4cwuXE3XWvND4rUCANBzSbf7RhGbauxr+zsFY+ZpWoGEsO8W2szpWDJVWhYuPhquaPvHAy/szMX35FtxWhHuhrbCgr7nfMxHysWKifmyuptf6mDsmEt1gahz8el9os3ebO1fT2sYg6kJLZ37I1yC0PjuL2xv5+A8ez+VXUPdDQnlTiZTBynd4zBWM496i+DjZX8InC0RlDUBRq90BPad8xzDTWz9hnRvTRWajmeFI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41abe3d4-024d-44a3-2b57-08d81f1a23a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:20.1947 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NUYgnMN8YHt6P1ZM+xKXLc5rEIoh6gEmfpMXL63GkHNearQVkj169Clz3NI+oMmc2418tMdojAyxlbLcXgJb6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org cdns3 has some special PM sequence between xhci_bus_suspend and xhci_suspend, add quirk to implement it. Signed-off-by: Peter Chen --- drivers/usb/cdns3/host-export.h | 6 +++++ drivers/usb/cdns3/host.c | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/usb/cdns3/host-export.h b/drivers/usb/cdns3/host-export.h index ae11810f8826..26041718a086 100644 --- a/drivers/usb/cdns3/host-export.h +++ b/drivers/usb/cdns3/host-export.h @@ -9,9 +9,11 @@ #ifndef __LINUX_CDNS3_HOST_EXPORT #define __LINUX_CDNS3_HOST_EXPORT +struct usb_hcd; #ifdef CONFIG_USB_CDNS3_HOST int cdns3_host_init(struct cdns3 *cdns); +int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd); #else @@ -21,6 +23,10 @@ static inline int cdns3_host_init(struct cdns3 *cdns) } static inline void cdns3_host_exit(struct cdns3 *cdns) { } +static inline int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd) +{ + return 0; +} #endif /* CONFIG_USB_CDNS3_HOST */ diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index b579ef15f4e0..030d6421abd3 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -14,6 +14,18 @@ #include "drd.h" #include "host-export.h" #include +#include "../host/xhci.h" +#include "../host/xhci-plat.h" + +#define XECP_PORT_CAP_REG 0x8000 +#define XECP_AUX_CTRL_REG1 0x8120 + +#define CFG_RXDET_P3_EN (1 << 15) +#define LPM_2_STB_SWITCH_EN (1 << 25) + +static const struct xhci_plat_priv xhci_plat_cdns3_xhci = { + .suspend_quirk = xhci_cdns3_suspend_quirk, +}; static int __cdns3_host_init(struct cdns3 *cdns) { @@ -39,6 +51,11 @@ static int __cdns3_host_init(struct cdns3 *cdns) goto err1; } + ret = platform_device_add_data(xhci, &xhci_plat_cdns3_xhci, + sizeof(struct xhci_plat_priv)); + if (ret) + goto err1; + ret = platform_device_add(xhci); if (ret) { dev_err(cdns->dev, "failed to register xHCI device\n"); @@ -56,6 +73,29 @@ static int __cdns3_host_init(struct cdns3 *cdns) return ret; } +int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + u32 value; + + /* set usbcmd.EU3S */ + value = readl(&xhci->op_regs->command); + value |= CMD_PM_INDEX; + writel(value, &xhci->op_regs->command); + + if (hcd->regs) { + value = readl(hcd->regs + XECP_AUX_CTRL_REG1); + value |= CFG_RXDET_P3_EN; + writel(value, hcd->regs + XECP_AUX_CTRL_REG1); + + value = readl(hcd->regs + XECP_PORT_CAP_REG); + value |= LPM_2_STB_SWITCH_EN; + writel(value, hcd->regs + XECP_PORT_CAP_REG); + } + + return 0; +} + static void cdns3_host_exit(struct cdns3 *cdns) { platform_device_unregister(cdns->host_dev); From patchwork Fri Jul 3 06:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11640955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1E3D913 for ; Fri, 3 Jul 2020 06:27:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82957204EA for ; Fri, 3 Jul 2020 06:27:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="fwaRDuqZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbgGCG11 (ORCPT ); Fri, 3 Jul 2020 02:27:27 -0400 Received: from mail-eopbgr40054.outbound.protection.outlook.com ([40.107.4.54]:7493 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbgGCG10 (ORCPT ); Fri, 3 Jul 2020 02:27:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJa3kPIGdyWDtuLCZ+PYMQoTaGc0kg+ial0E7rF9DLc79731MIcfgN99L79OlCCjAdNXDcJ4MJuvxrAiflhEsw3Kaf3Cqxy6ZYOrFh6ojEAdOjV9rkVxWnux/3GR8/3O5WtC48wR9CPbWOu240HGNrQvbaC8m4/6HvuFL8M+X1dXxcQT2s+BYVJ/aCdDrBORk8FzeR74G1nlKihTdXzi5WsWZ+Y/h15f23YY5DNbzvE1UjwTHwDkenJjGPGlzfCbts4w0dEgme90EhX4Z41qdoe5SxQVPGK0ovw7+vG1UHDlpU0R7BXakor7ThPDS14yaBS7pGwgcX1VezWQVLUSqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PSSvEBE+KCAkB94M/t9GdktCL2AaLc3cRFmrEspB10s=; b=m4fC67hJTifXb25O3Mbo6aYh4JL+RSxDmS74QCmNSubCAOlL0FiAGDFjzhebIRNE1mozcI6K9x5sq9dZHPyiASJfe+N+/GdA4imBYYRmAH9xqvbQ9pevkoTsqNsImlvEAUOuvoRjKub1XtM/cHLhg1MMi2cHDCWVrEAo/57bI8Xz+HMEib8q1kJQQ/R1OWsthwFJ8G9WFIEwvdUx9P2F9Juh90xQQ1BZ5YQvteP5kyTBnfjuf9Awfinqj2YmMjHysDvRTVDA1qlF65V/djFUx8JjYN5Tre899MmvjiUDFdA7gB9ttJsxyyy7JtOOE7DHCSW9hXM/tZ6+zPpYnoSp6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PSSvEBE+KCAkB94M/t9GdktCL2AaLc3cRFmrEspB10s=; b=fwaRDuqZhXQPdgT0LkdPllcT/zq50ssVDyc9Un7oopIYS568KVD+TGbH/K76kMneoIMZPkI2aV3V8DII6gRouFZeeu3v3HGp4KUHzIKFVl9ZNxyFo1n67CJg0rLpg9omTUHkoeDLftnNSOUcf2a4pCPVV4MKcY24/aK/5YgisLQ= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4166.eurprd04.prod.outlook.com (2603:10a6:209:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Fri, 3 Jul 2020 06:27:23 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3153.023; Fri, 3 Jul 2020 06:27:23 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH v4 9/9] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Date: Fri, 3 Jul 2020 14:26:53 +0800 Message-Id: <20200703062653.29159-10-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703062653.29159-1-peter.chen@nxp.com> References: <20200703062653.29159-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR03CA0107.apcprd03.prod.outlook.com (2603:1096:4:7c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.12 via Frontend Transport; Fri, 3 Jul 2020 06:27:20 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d7d8ced8-e7a3-4544-c120-08d81f1a2575 X-MS-TrafficTypeDiagnostic: AM6PR04MB4166: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J0KHXi3KZ5pwBRxvCpzFq2buG8mgK4a1InTSjdQjgx7sHnbo745Yoksiex7yqFFiIg/8fj6KpgcNlUxIXbEf2d/+eZ+LwLvShhO3/td6Md03OIvNEl3yE0Y0pVpPZAtuG/HwYc8wcs4y2AaMF0rkOAoVWWntuVt+st1qc5KxxS+VbGAf4vFs9FDd5128MlsJLRwba0zMqRpW1btRdnSjcLGoxuFNDIE+Xa45LLeY653EgLR8dHvVhX9ujvmi9p8s59+slj/G/NwbVUjj6JmBIFGcSy9qR0ZOvPti6wXbN5uBgcTGtJH//sCTnLlyTWJQ0pNH/lp3Pcuwn73VB5Mnvw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(52116002)(4744005)(6486002)(1076003)(8676002)(5660300002)(2906002)(8936002)(86362001)(186003)(6506007)(16526019)(44832011)(26005)(36756003)(316002)(478600001)(66476007)(956004)(6666004)(2616005)(66946007)(83380400001)(66556008)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5VbMV/yhR8OETyEwlhSG0vqlRKaBgS6QBWHwaPzuilM3fhWhRjpfWZqUsRifB9L+faFHpICVBoqDkLzgkd9LcOQx0fPDFVBf+ec/ydcR+THaUFd1I+NZdn9oSaK8nUrgLzLCWvaBYUhljFoPZxYSLTI6kqR7rvc7f1nrRra+VzqrfCli9iRciuIxiLxq0IBbouGGvSIzV84CghIA/YHdprtNbfr1+wHH6F52r3ET8qGOg8fTczyAuy/J7bEdED/mwodNlKAPIkm51lVdsAHf/zfu39lb6SluIkelLZ0E3uL0sdcFU2WNZcRBv0z7KxNLWmcJf0msbY7aQTB9KV1EGmdjdkWop5M89sL8eP4QCLgeyF+tQjlyNwX27SHzwoq5xWSZjWBGXtpOZwim6YOfQh52F3PYrUO8CZvjTyG4LXh5LfzldUxpo2lvonAQ2JOUnR+apuCp0NRdegvafMWMeyx6C4VF+5VuWBlS912qe4M= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7d8ced8-e7a3-4544-c120-08d81f1a2575 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 06:27:23.3897 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BLrOt/s3UjqGOouqzN6sSTEe0PlTEF1sWf31B99V+/bz4AYYO7d6jSIJS5/4kpCUyKKx+gPfqs9S+zxLg4aZsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4166 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org cdns3 manages PHY by own DRD driver, so skip the management by HCD core. Signed-off-by: Peter Chen --- drivers/usb/cdns3/host.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index 030d6421abd3..1dfbe23fa089 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -24,6 +24,7 @@ #define LPM_2_STB_SWITCH_EN (1 << 25) static const struct xhci_plat_priv xhci_plat_cdns3_xhci = { + .quirks = XHCI_SKIP_PHY_INIT, .suspend_quirk = xhci_cdns3_suspend_quirk, };