From patchwork Mon Jun 8 07:10:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11592639 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 7DB161391 for ; Mon, 8 Jun 2020 07:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 596CE20774 for ; Mon, 8 Jun 2020 07:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ocJC0IaL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728964AbgFHHKr (ORCPT ); Mon, 8 Jun 2020 03:10:47 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728885AbgFHHKq (ORCPT ); Mon, 8 Jun 2020 03:10:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V32/bOxdYGY64oIDDg57IjKdlrc/vJ3b1Q2vKMr7Id9WkfT8JL/y6dAAyW2LmjloG+bbxREW6jPW36Tn2c54U7yK9+pC9D/o0cvOnK9nvzfOosJqjUZG96vY5yILn/EjlB7rji3zbaz6XKHlQ+m8YbHelKnVu8mx+qGXhOnsmtNWuKMu/6P47rX29sz0PCL0AW+WPGf7qCENd77kpAfTk5D50Ql7goZq9GV9GpsRKsdja65EzX6+LAVSvx5GFFtTmX05FzJC7y0ozXYbfnrT7s48Gjv9GZfCch/EDLdYKIoa1gtRjFf2raqc37MdZFu8rBXoCqjsLRkg+89SjMcnGg== 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=HaFJiI3+Q9pBtpHTIxLSHrAQ7K8hI4tH/jIKAdbKT253GlrJyryZhVwyzDkuj5s+w0CeF7hiNtL7zONxoUnblvar+UEpfoYZ/AFglBY+XWgilJfcK46KPbCeOPz+DM5SY4xgiMMC8niSr2i4r81ZDYQ7kiLA/CZBuQtn51yaEgCJYUAwnLOPoRSUEfoe98W83q4HxmRwMOI1t90MnIpjLC/Y6pBIAsmCJDtXLQE3SIuU3p5urv4v97YP/1HVnwYzHpbWZ7+M/D1sWRRGZ6HDXSpkkR1OSCnizRpmZGLKg+z3PgD+W2srSzKOEeQvZ4vWOlSXGgGMt2bJjsNr6ox8rA== 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=ocJC0IaLNl6J85SeJhGDP+ufJLt2XtHv4q0dDw19NDDODhe/0lNSykT50loc/7r5YhmGG0elK4yb/W1jcv+Kq4EcuFgxCDu8RcZxqAApbbJbKEZd/YKP5zlXgFx5hbtex9ogHU0e4IkcaRJZFxcJ/w9erpa0TGf1ubk3cOmr2HE= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:10:42 +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.3066.023; Mon, 8 Jun 2020 07:10:42 +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 v3 1/9] usb: cdns3: introduce cdns3_set_phy_power API Date: Mon, 8 Jun 2020 15:10:44 +0800 Message-Id: <20200608071052.8929-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:40 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d488a2ef-c7e8-4edf-ec1c-08d80b7b0e93 X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S5IYHUtVYrbPe3RLI01q7/yszbkKO06IgsY1LiEzlcy51DQmgGvQRuZTc3EQNQ3PDNSwucL94LPLiGIT3K4A7LlzBfAsEdwSjJhWSsWaNQbd4NtHI6lJP4JWWb0rX9pfDn9YKEbsQR4xH0mlMLgDha1fzK4SI5licJFqXLD+8Rk8Zj3aViLTp2S1NupBAXbaay5LIkLhD56ckr6A5cm3bARiGdTatCIPe99OQp4pY6kfLDRZe+78VqoUkTIWPTh6e7xf1XqNsWak8SuXkoQ2jFUqCXraLNhZbJssIEMqjR3C8Wadf96SBEVNp83c0Gi9/WGSkBN5+jyKFFduaXU5Rg== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sQLuIJ4+dA3ugzj90ghsokGNWBZSJFw/He/ejmuDN23e+zYSkmgDG3BFvAlYBXhroelIs7SSlAIJtssV/PonF7lxxxj5U9EXc21FU9vfJlh/JaD81oeuqT9DGRYyR0lT/1YBh0o5O8MwSHfHYGBd4DNkzMoLyPbUL0TwogaTcwpwsSAVwvFM0KOWt8XufWBRJJcsbqh7dRbFQSGeIcVgKqOQU4E6AfH6c2+AVXFv0UXcMFzyMXV3FWScIwNQzkPUObbKAis9LQkunPYxstbTR1uFrnVeFRH7cuwXN9r95YLzsntIsopRUPTYtXa/JK0AO69tdI8Flc1QUHyrumbUNW8zGb2o/JrfZgKloM68o8rX0u9GyNUwN553DBTtjaD9nDPldrMMWtSTe4ZELztgA3kCuETf3cWPwlORkRoMbmekfStnCO1wqYJyCJqZWlJPBii3egveJ7QZ7w1bUZcX+YGv/lL6f8+jQyCp7Rp21RY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d488a2ef-c7e8-4edf-ec1c-08d80b7b0e93 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:10:42.8723 (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: OTyX+uyWD1zU6n+sWqMZ/0UVnmYmFIm9SNw7Yr/145hbQCYn7AZyVVjNxd3qfOSc340519Q+5C7hIvOq0Vcm1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 Mon Jun 8 07:10: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: 11592641 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 2C91D13B1 for ; Mon, 8 Jun 2020 07:10:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 082E72076A for ; Mon, 8 Jun 2020 07:10:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="pG5ehIk4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728988AbgFHHKv (ORCPT ); Mon, 8 Jun 2020 03:10:51 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728953AbgFHHKv (ORCPT ); Mon, 8 Jun 2020 03:10:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X7o9sFzeg4XHmGsbs8efJhexzr1MhRgHponvfY/dRt4gNj953M6LKRg4BuxabQYa12zTdpmIPDYpGnhqZ1fE+CTO31JZ1gJcb6DBNpcd5IBEf2dUW08JJJmI84BeZFqpIqaiB8GpjyThg9k2nIynJFVnx+73aSSsasjqnJgmMoJc1C7x3Owl4sqsnOkaznjNmK0gzctCWCFRwN4anjai4d33PIpaPWaGTjj9gYX/V4ksufAmVxOFuwqhoWLT0DJz7n9dDaNILTMWyltsyTTnBPZZnQS7x9t4c8sIQ4XUHwgGqhDX18Yl3t7Mk/QmE02GoMpsHME+fI1FCJ9x+muaPQ== 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=RFsdOWC2RtuvlH+SmYxO0nQFscdERANrW+YKeb0rwNA=; b=Bg8mgHSIEiPBXLOWspoYlK4Cz9/knUM1B96+EH+stnt1rxAt42SAfOBTuxSnl2Ve0i1Ty8NdWBPBOS5iNCpnGoEzflivJjOg+4wrbL+FPkQg6tniTXz8gHfbFrT1W/RxI7VzRayB2Zno3PVEJQEsHqoUwJpeIdNIVG74Gq6RA7QtnPcjS1m7JoJpR9EypXYiFd9JIZWLEH+boLqP44AWn6Ch5pvnBQjUbRGFBbcWWEJaWYqoYUVYTOQIiEN3zVV9AnehoIDyu9keCKLmwGM0Gjzf1wEhXeFYD1M/KvGPSKIWbTHB+RBoCmFuBXB8qtWGZeEv5Eo3vq7ESLt7veeDOg== 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=RFsdOWC2RtuvlH+SmYxO0nQFscdERANrW+YKeb0rwNA=; b=pG5ehIk45JPmmjcrBJngn5KY9wC4Y21+Q/s4648ovMxsQlTjAAwimJrcuSnCGT8pTq9nH/s75SIi1VpgQgUcPt6kdwEOasOALJOqESAUfEnV2DjH2BTL9QoN5rOUvFnBbZlKns0z4SYY216sRPBJiAsqAlqsYPlq/ZEjjBNPpDI= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:10:46 +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.3066.023; Mon, 8 Jun 2020 07:10:46 +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 v3 2/9] usb: cdns3: add runtime PM support Date: Mon, 8 Jun 2020 15:10:45 +0800 Message-Id: <20200608071052.8929-3-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:43 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bab14727-106a-4e72-f47e-08d80b7b1070 X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9nHgMV/HK2E6d1FFCM47l2AZe5u/LfbMirjkSBgLRgLpWikJtIqzgCwO0YsVzUJcLxAZHSCqYQ+BXEkupTh2AcKvVD2zfelKWyAFPV1QcbBL6Us7CKC8HWfHfsutXEI3Lbc8cPSPpY9NEvvcRLS7wg4eYOUfLsNVQ8zT1lIJY4zKO4bfoB+RpDvdvCatQKmOAzIGeuIG/8BbZ/z8d5Ml8r7FuJajGEdpMgfLv2USYF3qawdH33JIV2A7qkXDRPaFq0wd0IoKmamMP0p4UqYYv5U+EpPXZRSXuNEBWL5SuHYKPl7YIrn7AwqLD5BO8uEOZo9RDZWGtl5BfJTeymrxpA== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(30864003)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: THaa9g5aFAvfoWfL029lX1jjfRL7fNwDU2zs0mSFEpvU/bCBzAGIr/UcExnXOTjNIy1UC0Gdf/eMi/UGq4XkmzwkHjVt2Q+uyo4lG3ZghOZaKMdRTa2WLbszh2Yrr3GUNt2Z0F2YYrWZUDvR6k0rPPiUD+gpet2O0Tq5ba077oDKcbGOzCrve79uV6fcHbgQ6QusQhvHpwWgloEe/EJGQ3oLpsx239SXx0Y6+9uLM8Nl3q7xuM7wEen4tH5z4J1BY8tI4C6hypExtFT6WZ2Qlc8A1lfnqWGIbSxoyNGD49cNzCua8HjUIv8KDq3tQs7PWvhfjNdjzdZsNo4UX4WByexj8ivEW51HZLLY22caity/59MNImgSibOkGytkjGeTUeEUFNu8a0JJ/w1thpBy3yicr7Mz6A9TMJGUgGdscUnxNQoiXO7In5fafwA1dvYieotQRfVgJw0GZYmNQtJstM2DtpJlmmMl2z/HyVhr7fk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bab14727-106a-4e72-f47e-08d80b7b1070 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:10:46.0603 (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: msf9u5AdoCz2rlZf1c1qogN2JQwP1z0gR0dgdqY9PJvDWWBZ0FjIq3+APxwdSj0fFIaULyKVkuPYJB3aS+qLFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 | 155 +++++++++++++++++++++++++++++++++---- 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, 168 insertions(+), 17 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index bfd09aa98c12..97fb082ed3b4 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_int = 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(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,124 @@ 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; + unsigned long flags; + + spin_lock_irqsave(&cdns->lock, flags); + if (cdns->pdata && cdns->pdata->platform_suspend) + ret = cdns->pdata->platform_suspend(dev, suspend, wakeup); + + spin_unlock_irqrestore(&cdns->lock, flags); + + 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); 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_int) { + cdns->wakeup_int = false; + enable_irq(cdns->otg_irq); } + 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..fdbcf557a61f 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 + * @dev_irq: irq number for wakeup event * @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_int: wakeup interrupt occurs + * @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_int; + 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 7babba9dd916..eac01b1a4958 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1765,9 +1765,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 Mon Jun 8 07:10: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: 11592643 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 8699B1391 for ; Mon, 8 Jun 2020 07:10:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EAD92076C for ; Mon, 8 Jun 2020 07:10:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Wkmc496x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729044AbgFHHKz (ORCPT ); Mon, 8 Jun 2020 03:10:55 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727966AbgFHHKy (ORCPT ); Mon, 8 Jun 2020 03:10:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ix4Lsr5R/0feKtl3QB0Z5efkROELBFLOKU6yhR/PI6Jy8IK5LeUodT8H9NdnwCyv9Hndypbp7tQRZqIkU0eTYDoekaIMHGTNP/loYY5Fw3DUDNAgaXu2c50QW/faXV3MObo93xcNz4hXtrVI1UjPcwnR1pJtySWi/S9RA55hvrdthTSHy0fgzCMQXqZPT45dcQ5S9ssAmqlzqO0A9gFVrkreOejNg4XXT1xmKQg91MqzcimCglpLGFqdXgkS+HokSaddoIGr4NUlfw6vwZ8t8syKXoJOg+66tsaLK5aNaJ6R97DN7IewKOI/IUWd0eP0HTAIaj1USnH6H8GGDgKBiw== 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=Pfopa1v1fnnUtpGsiG083yfjDSGs0U3uA4nA+vuXne4=; b=n4e9k+ncKy0AX4XZ165S9g2gJnb08zepBD4hc+lRgYzsHpwsTG5/UZnGQ4OBiPSaEb/zgxLxBUOMuITL6rFc0vYgEYbMWdPfm5ZSS+6UUpdEThhSkpQm+y+umYNZbTyaf+9GCxFR6fTNF8yGPKde6Tj0L6DjiUHcF+r6MgmGa+mK3NyqZPVxucLuX7nsrPePo0SbWt5/6KwKTH6ygc2Hkn+WOYRiuF+WzSuBRv/fddtEWsHLkLXVDn3UuUcw+yZOytSM5YBRtFjug7PgaAz905w04TIHQ1r+wtkOQ1iesTOsuWzYXoNGzbXaD7lUHra4WFhunuwEJ2xsdFMB9xteCA== 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=Pfopa1v1fnnUtpGsiG083yfjDSGs0U3uA4nA+vuXne4=; b=Wkmc496xPseHDib5166p0NqSTtzDFe0tr3+t2rnL2bNCreJNZL1d/mOD1EGWOLWjq7DhgwZH671PtqeHMZyMc50qLbKOoCZb1X7LxJsMBhbM76YR3g23sdLjNZC/1Elaamwo2Z5TLtLiG1G/fpwrKpQYujomZVMgNfAM+HngnBE= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:10:49 +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.3066.023; Mon, 8 Jun 2020 07:10:49 +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 v3 3/9] usb: cdns3: imx: add glue layer runtime pm implementation Date: Mon, 8 Jun 2020 15:10:46 +0800 Message-Id: <20200608071052.8929-4-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 21b4e3ad-69eb-4cc9-682b-08d80b7b1257 X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U0boCvMweCJiDCJ3CCkOmSb9W+NeICzprFhz0N2lRWIp7AYqs6ypHoT8R/rIzqIZ0GmOh40BoZ1+UJet7o4hX9qbjfcsDUoRRD+cBAVld24uVSN0vaVAzEwN3ziR6kJvlvLJHNwKuoZR5K/ua9BjuDQBXlju3H2/OZuCvvfh0ZdaXDhKe4rJKSgYcirMSejkFc/JlhshvIBXmeT7TZnI6eDRIM0I3LSF244SpDoiiTdasFj0nSPEyRr0kUVQs+86rwJtxmKh0OfLjXC3zQgytZhnyDdPS/oEMOMUHzA6xFPG94+BLH4ODJNxYS0+wLm7ggW9fuU/bm2KiuALrF3MYg== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 02Yv31RHl40Vxetbaa5kvSwpcEC+GKnCZuCR10KMvsnotn1ax6m2OeuaAacr1W4JFQ+7klno41jGceJ8wqWP69c3wwiOOlSroGG2gfZP/AXdBAvimVj3N/0IOzBCByAg66C2kLjysUNR8PU6MIj8FLsIC6HrcxY11+gtYngc5rL/m52jL/5a319hpC7HfPxDeHeXmlUeQbcvt5aYxBkRniaujr2vDbOl4WCEbtFat7OhZ8/XCoX+WVSkWv4Cbwd+UR8T2QIl/jfFArT1lBBydyVoThAAr8/MzfCdAFK5WRxNoAr9S9SH5AfApTZ/SDZeK8YLqP8smi4RS0NIGVBIgLM+q52BQPkseF6o4hQHRwgxBFC2V0Sx7Sq1r3is2rlfypP3HmU1CREQsPS+JBiBfimDYQH8fswJ5bN91Sm7Pyxb5wMv/0H0uvEpd1mjnZFZyuSRUgWuOJWSWkfx9/6OaL7TXiHxas/7dtUIHXEYkJk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21b4e3ad-69eb-4cc9-682b-08d80b7b1257 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:10:49.1457 (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: U/bgNRpnwUSL7clfcEdfECVqZenYs8DQN7vcU3sDG4ynUQrxXHFq2Zw3NZcNi81vqZRqJL1PvMiubMhT8KqRfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 --- 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..3a7e9bf7a294 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_atomic(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_atomic(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_atomic(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 { + /* wait CLK_125_REQ to be 1 */ + value = cdns_imx_readl(data, USB3_INT_REG); + ret = readl_poll_timeout_atomic(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"); + + 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 for mdctrl_clk_status is cleared */ + value = cdns_imx_readl(data, USB3_CORE_STATUS); + ret = readl_poll_timeout_atomic(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_atomic(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 Mon Jun 8 07:10: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: 11592645 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 2EFAA14E3 for ; Mon, 8 Jun 2020 07:11:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CCAE2076A for ; Mon, 8 Jun 2020 07:11:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="H9FlT2RS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729051AbgFHHK7 (ORCPT ); Mon, 8 Jun 2020 03:10:59 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729000AbgFHHK5 (ORCPT ); Mon, 8 Jun 2020 03:10:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n+zWNz4axgPgdcGBeTWWvYrQEw166RISlvB7VXBRSovLEyGYtgkJ+N8ty9DTDXafss19hFvwaMj6WW3qwC4BsSXbSjUUnvXBPd9B44o5furao9Be52jhnooMU15qWg/dnqEM7FouYZVI3ww7uhLVvSiaDBcNtVSPlB+TVNt0jVIRVIhw0wgSASF0+RbwCPxK5pzDjB3bUKlQQw6yFoOH9z/rRXKDWPh6Ugh+UnbrwYcIkpw10hCSwIEcPRl90vc30tlBfIlVwGDXu/rQapvkXrsIH0TzMVkBnG8ZEe/NJ6soZ+DfRTIvKq/S92vcgcGitjSjaIWnpdOsF2o2PO5lnQ== 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=msAFvKLNvfOe6TnVk946Y5HIWsKxo1gfV8VVdNp+aac=; b=kYgwpeLJOr5TCt3iRWOx2OwF/EzFnVJpXjeuEf68FuqtdUAU19eS6+WRelHyyU2p310LTyncx223w6molgEBFNxzRsUfyzB3vJWtrYF35LOWAZ8dCjCmdlojaC/BPYriPVeKlqPkP56jHlFX4DyFFX7Xi8ogHOD2NO8udDid/x6oFadpBB0pQ2axEAx5+g0Z0U4Hfr1zPbKi7aOBMs0AFqQN+74VpcoyOfCxULnUotSP9HQ2k5/haHYwbgHkQu83xg4Re2GJJ4NCYjTd5ci/0xzamhfVQv5fwgiRvbSCBwHjPiZfftzJz1r6oQ3tRaXfwmmbHpWoFpFqKAWRAV/Hng== 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=msAFvKLNvfOe6TnVk946Y5HIWsKxo1gfV8VVdNp+aac=; b=H9FlT2RSUNFSv3ZG+n8OjSMHFLXmvKpxoQ5HbLkAYy5R2NgEE0VOCJCXNCFvl1/xIpNNbzf0x0Cds6yzhAE/9y3fjwq3OAxY9mzK0sysg85qfgGdH+eo9REycS9Q9PmsEqniKj/Rzw0YpNfYFoQJCrT+5WRt/j5yTljaFpmv3dU= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:10:52 +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.3066.023; Mon, 8 Jun 2020 07:10:52 +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 v3 4/9] usb: host: xhci-plat: add platform data support Date: Mon, 8 Jun 2020 15:10:47 +0800 Message-Id: <20200608071052.8929-5-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:49 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1d0e4e6a-d9f8-4e6d-1f52-08d80b7b142f X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9hcwqzSpLia2QeoZMCxJxscpGlmbeElN9JJfHJQlt5inPe5OrS80cYHiNiSxoLY/A/I1arrl3UD33+6TsKkECV3FrBKf5rkQa0y/gZhF6J6ERaK56hUGbDIVOkZQSgbB6eULSq/rJYIZs78Ziuqg4v/qlI0XhtduT5vm0eUIgCx5+z7MFKTnnEW0807JLnYPoNvOpUgM73nQBuhhbSDbxO1617t0AX+4pnSz2GOtTDP/NVr0Npez/Rbu2vKMyWnPelQ2I3Krpw9sMJwYCs0xCBvNVMc/t9VOSGW55OXxH/FGupszJpwscFdF6Bm3xcRQOj4juLqisTR6cwNHwcQjDA== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(4744005)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 79FqZR4uiz5QyiuIYhvRdTSW0o0An81GwTGMk3kd+5h7gxk3L7KWgvO6BhGB/cDIH/UYF7L/iEQFisxFJiLXUadL+7eeL+aTHpl1Udf3vyClUmfS0E2FXRov49uNEzamuKuBy2B2p8bvAKB/v0HAhqj06xABBzZ8r4zWTouuP+laxAt927EkOmzpAYPzl1/9dnB6h1aNTDawpXmtLhLGLbSLwHfd8CvooLXl98GLPYERKiV6jxPx/4QV+mqbuEJ2IvZtRN2AsgUKFRWv0bNlUoD6SurecYN6KRuSYsQnMhyAOLLZsbrzA/xTRchXkO4c/JqZ5adUNqRfsy7XO+Av4soOUqn0hXtWfNTmnqKqxUgebP1JStQ3+Wz+dqYNzoEO8q4i2JlbYFeLpmoMyQpDDrLR0+2Ch8WGhgBZOHicO6t33kmlhfcpJPidOb6/0L3onOYxMRkeX+3pPnqEYaX+WeIXK+PTBOhV2/27m0caRaA= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d0e4e6a-d9f8-4e6d-1f52-08d80b7b142f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:10:52.3766 (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: Xp+MVoVoS710/m1COAwB7ee+clxT8Er6lElg6FCsguI0Bo2zG+oAMI3O4zmMJM7mIplr0p2UyYSOONhxW74OCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 0b4cdc5af130..e00efd84ea1a 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -255,7 +255,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 Mon Jun 8 07:10: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: 11592647 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 4FEE91391 for ; Mon, 8 Jun 2020 07:11:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E7A62076A for ; Mon, 8 Jun 2020 07:11:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="oQ0/b8in" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729027AbgFHHLC (ORCPT ); Mon, 8 Jun 2020 03:11:02 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728953AbgFHHK7 (ORCPT ); Mon, 8 Jun 2020 03:10:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AoErsFnpttPfxgFXCedaxpbIuOWv7kp3ruizkvzRMjwD2jsbcXwWlnILit+LRaq24iEh5wDDdYmZZ6c3t9XTUnwSHvIb15xh1rbP8aqvxtafoG8leW7+iqifHsCe9ROaYgVAM2UaVJzTqET/xDdR0fwbaIcVtxEyph/GHOR3gqRKocuUQKKEHq2lE2+mINl8M3XtuVDWFlJcVlYhoA7zS9INfvxirxg155xL5e0WyYqDldIzGm9X7Y9nvxqZAtvEfaeuTvu+6Vnojvlu+mKVpoq/9RRCLYepxSY0JjbdpRu4aGuuPdWG+iDn6OZ8Dms84UioGXdITFQg1Badc1YisQ== 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=RPegifVYigfyV9eq/X/+i3y5OBIGQwhBw/jxdrmMHjk=; b=Sg0Op22HODpmJ298rQomwN/mlVk22cBeYwr8v5UQbqww1j+CueZrmcTz08Vf629wk+8NzEfY/dOc+e9SM8KJVqmyWZVP2KKixhbCvCWKWIiCaMkLef/agc8DmdKzCJzOlKart6D78kKa7oMvUA0LMVLqwyh+zZoK3FhFNcTSRTNG1kBCDaWtDHRbD0qfOVEshcuyOrrqi47qhhL4x5PmBWvtimZ/34XXojyro7yPOBk61rKcWs5vCyx2Hgc7XbPsStQtlcu36ODX4dvvkFAz6X4aCyc+58SB6WNeQ1XeilInK5uMp3sIi8xRxtGAJBFGWMYiBWYpZn6tc3TtGb/srw== 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=RPegifVYigfyV9eq/X/+i3y5OBIGQwhBw/jxdrmMHjk=; b=oQ0/b8inD0UnDt2RT1JKlvYvXZ0CDvQ2Z74TxvJUbPAMU6EkFzersnNNgeF9BujXs5IULik34O2tJkn+BMRql9dgpT6JTsRlMk/Z7E73+8gUd/lmPhzRcAl5SP5ezMk23WYorPj0Cr231b0j1UUgaBH6S8EMJubT+mMhnkNOmoE= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:10:55 +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.3066.023; Mon, 8 Jun 2020 07:10:55 +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 v3 5/9] usb: host: xhci-plat: add .suspend_quirk for struct xhci_plat_priv Date: Mon, 8 Jun 2020 15:10:48 +0800 Message-Id: <20200608071052.8929-6-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:52 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4e461cf5-c463-464c-6f91-08d80b7b161a X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iLdWNfTMJGQUFNFrorjaKDpuaIqcbDY9yvpq2H2Iq8YQDMqKywyNYYKVi2uW5QV3MKNULabz6RnGSYae41Qq5sxvLMtOs5LWnD+k5S22PquRIhXZGg25gr7hNjoy91/ZZ8hLLiW65YeeuzBu403/3qdb7h2Ty90GCfAdP+FSPjdDpHKTcqcjtC2zpxlfEY4bkoG272OyAN3/bM6AQPI47cVK7HTez579dM8K6wBMYio+Ue/OtCSq/O/c+WXNjwRxS53VBkGwzBDNu2tucSa/f5RgInBW9beNlanxyDq8ZrfvNaBrjJFZzd/JLkSF8tmSW+mibUCmmt0CUXkyDUQFkFd7DTox2wdJXXiLrkWl5ixiZMsx41BuIEDcPAZXQaG0 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(15650500001)(4326008)(478600001)(36756003)(52116002)(6666004)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WBfUQvuvAW8znKqjiH3802YqRK5vgpTXjUlHX1rLVGaiPH5OOynQ7EyTH1VHACbcJE6GKkDt1mrb/kmyQwjfIxMsysEYYwRNN5/XGDgxV5YIxXuspZb7VrCt0lFwHCWVd9xCZdBSYyNNq4i8JPR/nilrcPU66zrvFXImd4gv+BgfqkOrEv017zIJNdONyAkQLt7E1LoGwvwKxA0amAnbQvAB5TVLf08RqUgJz1uuARwkaHdSrQR+LHN1lJ84Eys/oEOMYA0uWDDe+Nmf/wsaA4Hbd2Kyv4EhhBQ/KxWsJ6588q4BI5m9UDD8ToJYiuNkw/HZ40TFPcCZ1E35H2ZetAi+Gkq/v3Cza5hnKRgRwlN74OTiO3yzx20osY8CvBlUfjVdHe5+urE89ss3G0WBXGKWIiur6RF6owb3KzTfGD8S1M2UiKFoa+oK1BUjMxui3ho0RFFUJJE59fpnuE1hQhY7Mme+QJ09ZTyE0zy1zb0= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e461cf5-c463-464c-6f91-08d80b7b161a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:10:55.4899 (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: 7cg6yLsBOBlFobui5743GW0Rz5r4V7lE2/eN8spx4wH/dBd4szxMC6uTsY/Ah67cq4CRwoR03AC4gkhe0U8A3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 e00efd84ea1a..ca02e7f36238 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); @@ -396,7 +406,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 @@ -425,6 +439,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 5681723fc9cd..9338a4f946d0 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 Mon Jun 8 07:10: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: 11592649 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 EB7281391 for ; Mon, 8 Jun 2020 07:11:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D238820775 for ; Mon, 8 Jun 2020 07:11:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Puv+OCbc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729053AbgFHHLE (ORCPT ); Mon, 8 Jun 2020 03:11:04 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728961AbgFHHLD (ORCPT ); Mon, 8 Jun 2020 03:11:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OW1QTH1JgNqlJ/6QFNX2Jeyez11GmTLpzUQAowDCjKXvf2Jlc2DSUw4LUakzkcOfcy1bRwMQW9/tp7BXwOqYJctNQRZDNMCPMoNPEMMFSaIWEajQi8D0rxCObpBphgJRvvqmj61dkuJSyc7GYWOlzQ8ioGEr9CY7vH8xwbwC9CfWgoCu4ikuetsBGYJml5FK5sw5E2LR13Uhcdo/tskcuk10ZDQHA5SiyFeaZhxsoCE5CKFP4y8y4HOGroMuOTPHzr1q+xn/3sytS0uUjxhJBYF18BHRGBTOZvAJpKhaC/XwntJUqjL8KP6w85E3pBfYBFDPSfym5fl3846jIjvBNQ== 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=/9aRElE4Hx7j+1wgBbZbc4ByTd8mpJyjrvvHsaKY/9g=; b=NUK0iy/4vs58bwr1PTLwOITUI+eokb++V8ZV7gmr80wdbwC+L2d9AnFt/ZeTWG7AClsAr+PcmLfpn1XXyeCkhp7R6CNJcvqzHDjAhSGLmjKE7UPEQIgEb+RbvieLOfKe3UlVJpVwvt2YnjOzAayErKXmcCz3btekdnkBhwMtO9tdSt0JyC7gr6nPgcrwpA27bzJJKcj0YYwm+NoqUHDSZ60mY15ZhCEYgudR0moG1RH9HTzFpQh7PZVAktekntH0MdH9Quv/runnQcDU5plNWz4ER9H/Bcj9SqlKiFwG1ZPhs5Rb+BzPXZzaCzJVj7vUJfPmr1xHtl8AqIajLEHYXw== 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=/9aRElE4Hx7j+1wgBbZbc4ByTd8mpJyjrvvHsaKY/9g=; b=Puv+OCbcm6Kvsw2nPSRgAb5bFPZE8LiNbHDjFs2q8zhHVWy6APe3GBZPwVZ5p49Pc3lrSioFlHlpgVvXmlCkM/cElpCCqQS2CmBmK65D2jzJdtIwReYCQR6GcU5fSdw/pTj5p+VflUl877sRj85sijeF5kh4c0+vjmNpUmdM6HI= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:10:59 +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.3066.023; Mon, 8 Jun 2020 07:10:59 +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 v3 6/9] usb: host: xhci-plat: delete the unnecessary code Date: Mon, 8 Jun 2020 15:10:49 +0800 Message-Id: <20200608071052.8929-7-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:55 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c4f7f75f-219f-4665-00fe-08d80b7b1865 X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w74f43LnIh0LQNdoPHoRFm2sNvhnlojBRwPGYObsjKb2Rm9nXZEsNwqOT8WU62VRxgkBn35LTjwkzltrDiLUoX9z78teR+ibq23q2m+d32Di8/6pGRVnu+s2G0oJezKC6duYUh0IixsRgUNNB4Z0hps7O7S8+C3n6iSbhyg/6rlvXecsXPikDr8/YTxoJw25ta7KbsRbWvlsPlO/b/CNFK4+UuiCuV9Syki47SNiAg1tzLAfJ0NKqs3wjECeexOAM8PnM2A5prEuhYk3gQMYbtctLhXp0lLBYSnSyXUBoC8pdOUr/DdTsNMLAKv37lgkM1iqgW+e/gvy5eWJ592X3g== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(4744005)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: luOgGzpcUtZI6EVRDa7nroOhe1rgtKNC0ot9e/YiLMHAu7DHExNmA1x58vSI2sTLiHa5T0vY0LHGVhG8kSnSO9/24SmoizQUEbT5k6uh6n/g4Vnrm2eBWeCnkUs3TFJ5cShD3Jbc09uqbaDdfY4Vg4ClqC+1GhTwKD+BPRb0ZGRx9kqK/1yiQEK14tYNwS5+JpBpcBK5P72yLJ2QZVDhf2ZNzummH0POL/npWL0eBqZwmYghY7LxliJ7Qhv77HOdX4FpUs9J++92t3GdO3raNMtgdJI1+S3SEIl+m1tOb+mdI7CJsYAkE7kkvZVJ7z3Yj9l/L51s2d/QK+YXwVvYoQY5ROkdpThWqyiT+KLs2ljoCLMPJ0V4u236T8DZAdt3F2II1j/di1NFd3rx6ea501BRqz/6jE15EPH6A7JnDMpMcs8TbGT5HAnaJoe5uFPAu7tZWQ0QnSq7zarOoBkQO9mqRcBwCzjffNnPmX2nnAU= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4f7f75f-219f-4665-00fe-08d80b7b1865 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:10:59.4515 (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: AuTbEgO3dedw140/+lcv61dQh4vgHVcJtmBNxzNm52wH9XTYvz1Uz1x38hUWY4d+DiC8VEm7U+VK5PV1i+pD7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 ca02e7f36238..a45c7ec33ed6 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -274,8 +274,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 Mon Jun 8 07:10: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: 11592651 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 CAD7A13B1 for ; Mon, 8 Jun 2020 07:11:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B07942076C for ; Mon, 8 Jun 2020 07:11:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ZQNhTTAT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729005AbgFHHLI (ORCPT ); Mon, 8 Jun 2020 03:11:08 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728953AbgFHHLG (ORCPT ); Mon, 8 Jun 2020 03:11:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BzV/bOaS8BdUIxv2W8SK5JYYv/n4lct9sT5FdSbs5ObG0pv0SliLLMSjjfaLYy1bQUcXLJncuMfm1s12u7Z7l6S5bzN6RI1GYcr1t6WsI4SvoXOedLodVhi7HRkeJxEoEjwgSzkhi5Ty0rhYOuLHgkP2zv1ziem86mQ7BTMuuHtZYW3m6k11Naq8djpn7AWvo8twiMOWgLuXLa4ggSDPk/7wE8SiLhUZaT883e5MeJCzhS6pIwU/gHg3QVpJnlTPzdf18DFYn57NuybAagGutuQVFKp5NdCYbV61CRl2t3+HhvF0nnmH5OyZhyAKQjFGo0hhwyF/VY6ktjY69lQhFg== 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=iPlSGX8/gUtmNQA831z4sLaWRywj/xvNP/68gpsfqFk=; b=TbZEArsXdqFLXXdTWwxF8AyWE73soX6VOvCKNbIXBP3R/WlgFxpwUW7vPLtecMH6LfEHMtxDJaneMWJbzABuJLH+530BxNxLLOpTLg5HiWvkVt809T+JYq+6pZv84+JvwAgYtdZyfNPRqb9rB9MNMw6bvbZxnklypazzuoRg4Y9eQ+JTnPNeZc79w3OcNARhEseNSy2p44r9T1CoQHivF2x553bm5Jh2cfTs6FW8DT1L+W+ureh5pTF5BFXfWdI7LOMtiY3w3o0EZ0AJ0yYq7QE8a4623r6bf0Wa6UmRzjLHAkM1B2Yy1hGZD2wHANdyK7+2w6fvP8ASNynF/XaS0Q== 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=iPlSGX8/gUtmNQA831z4sLaWRywj/xvNP/68gpsfqFk=; b=ZQNhTTATzJ1m0juR9+BPdmKVsyQz/vVI8VD/+x2cF7uO/bpaXmvgrHJB41YjM9d23BVtEss9YnfhDs+WekrVQt3Zkh+3dU8pFHwsITat/qsAukt0/Z/lUg5901eFfdRh3kf/e0Q7Y1Z59LNUE4Au0av3e+h4E4NWG5jCwIQ2up8= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:11:02 +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.3066.023; Mon, 8 Jun 2020 07:11:02 +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 v3 7/9] usb: host: xhci-plat: add priv quirk for skip PHY initialization Date: Mon, 8 Jun 2020 15:10:50 +0800 Message-Id: <20200608071052.8929-8-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:10:59 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4831dc91-1360-4741-3430-08d80b7b1a53 X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CymmbohsjSVWt6yaVVeiHqF6UgpomsgDMcvT0PoGFucTkatdK6UwSGLDM8O2pUrvhU9BmSnY6KcoEApWIXi+gD3zJoZfN9EFY0eLeJtQ09r9DncnDF8nzMHdrmYrmLVHun4lAC6bG6uXErX81YBCtfBQG5g2qFpOo+yEuSqRJ6nAYxLdj8b0sMHpFqJtMSeos3XhR2ogpPloeKbyrq8jcvC1HYcEL/QEfsJXjqc6BkSHI/vj3inAPD0Co5s6VfNgVSRF4ekTw8dcAel4zT2aK976iBXW634mnVMT/oyimYZpPaJ5Iy4y5ywG5qWWd+IDp+ekGF+TFlNcqndMNwzH1w== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FsSdOhWxXgK+ZRBMMHkM7WYpwyj8sM8KkbhdDvu4pJhku3VgK33igsGGTlnjQdKAClDfpYgMywRkNMV+ypWjYcBWgQTa+vw6MHPynXd8FoXK/BCWbLvE5VZpkKvemX6UPPsN51M1z+v2sM9a5E619NXuxZNFpAfJNJsaj8toqJnql/ZU2SysmeT+12d4ni0M3qODDs2MDvS+KuEa+ijj1e5l/mdpnWwgwE7EGAfRioq5tb87eDkkGabtKcV3nQb3lj2aNeSoJjLnOsGHURF5S9N7oYZw7C7IyqnUgUbnpFRQK6em9huV0x6bBzP09kdBVoYy6ysCKSnQCyJcL5CzowM14HItnGpX9DklAtd2JuC1IBRbMRleULQ+t7q900EdjLiCqd51wi4GJUeowdS96wIsNt35PampZv3UltFjV2RKlWKjA42zP4BeQAmzCj2+ROnS75oLCPVc3P7DWif75hU/zqQ3quiHkEDAQFThbOY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4831dc91-1360-4741-3430-08d80b7b1a53 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:11:02.5559 (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: DDWkA9wA3YSeoz9uonoYIKycksCj9Uvgix5WLv7soyUEyMOqnjN+h9iRyeH3InZGsduQp29RjILXJyeCMfgRgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 a45c7ec33ed6..6b8a193bd012 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -173,6 +173,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; @@ -271,8 +273,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; } @@ -324,6 +325,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 54a08bd31e46..b19169fd8a85 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1873,6 +1873,7 @@ struct xhci_hcd { #define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34) #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) #define XHCI_CDNS_HOST BIT_ULL(36) +#define XHCI_SKIP_PHY_INIT BIT_ULL(37) unsigned int num_active_eps; unsigned int limit_active_eps; From patchwork Mon Jun 8 07:10: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: 11592653 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 D2D471391 for ; Mon, 8 Jun 2020 07:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0CDE2076C for ; Mon, 8 Jun 2020 07:11:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="IuuY1x64" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729056AbgFHHLL (ORCPT ); Mon, 8 Jun 2020 03:11:11 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728956AbgFHHLK (ORCPT ); Mon, 8 Jun 2020 03:11:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k16nFP5uBhgSi4tYft3YhVfMsNLvuyhFAzGi+VpdemKD6uMYg/z1+5+4cXT1YQBZ6w5xuLiazSVAbjci+yKDQWOMCQmRTz7lDa2PBrkFYNUZZynmVZcgIJ5srvYV6Dl9cRFC9+Ov/tYNFUHHbi7t2nxtnKzM5KbBohnB0nn9y1qCPgS+5zbBIXo87iv315hQBrmmGRbjlNdV+9AcjoftC9c0AI+k3rCk2dQbMs0xT7nrD4xF7+Pmzm70WcTSKPZvHT9v5oQ34bYBnW3CVXD0Rhyd3vpN7TkAMtr6X2T3UgcbiHULehxhSnkRPc/KBpoHkZz/Ks8KlXKFf9Z0zHFkqQ== 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=bq22+cBKG7kB9N3Usn7N+GDyhj5kstNUD+a61Hbph7KlRkIqU8mVmPvR5wKXfsTS868Be0PSw2CNUqcriUa8oY1sKpynKHAaQjJzHS2B2ZpYuollvdOiTPr0Y7Qlu4bhb3ADz2dmLnw8eQ5P9u55Id3QdKDUGxk/3K36lbTKnBS7ghhZkCkoHd+W/lDvHLt8UI32wZGCmosKXgiSaq01k5JYHQ4zyMc79QJht/JiQKuhtPPY/ujW2XLnaSuN5dDdDs+E0Y//eiDpNNltUSRMUdETTgDsPc02y5j/rbGowX29i3jyW1kS8vMYJPl7OgaV0AV0ynHA4Eyz1iGpN8t3nA== 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=IuuY1x64sIwTvS9Xo0kxWaT5jK/QiOJWY4ixK8gXJ8ewz0a3AfJuSi9jX/XNygqZAUgzgavzv9ogY8AGjisxbZuVnDh9ZpgvPUuweJGOQdaCY2f57BM8BtFLLjOXluOCIozrh7OnjKBG7zFKdf5gWqp0CjYfd1gt7qdDNJDpkR4= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:11:05 +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.3066.023; Mon, 8 Jun 2020 07:11:05 +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 v3 8/9] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Date: Mon, 8 Jun 2020 15:10:51 +0800 Message-Id: <20200608071052.8929-9-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:11:02 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3d591cec-e6de-4bda-69e5-08d80b7b1c2e X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TQylDQiE5LkG1UlgF5cBKRCI1sj73e/jukebDtqNMFJtAn3d2xPVRRfuJSZvhROz016s/+o3/ryAgELVqHfuBVgHlDqHVwixtNpS5MR+9WejxVdTwEXCQYVxWPnAlcp0gaEaccEF0RcYbJ+jyg4USzVENpozi9Ea4sJw4B1B+eNYulOQvXsE3kqGVMtUNYECWvgetvmySDMstoxpUv0T9VOa6PyfniXpmicdzuYkmcJBCRfa+Lh6D47pFpCE9Dgmeo0t793smTOVXRx+JYDWccDIJDral06D8BY26V0p8e4KFs9Y0IEZEwPCBdQlfyAX+8sE184wvQ8uzB4W5+fgAWsSP79AwGqtNJ4aqGli+Eu7La6a+14bY1Q6BXmN/6+O 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(15650500001)(4326008)(478600001)(36756003)(52116002)(6666004)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fQD/3CCiGcKH9u2HqvZc9YvB8/zki8uCMLSh9RyP3rIXx9jU2KnuYF2LQOjbv2JyBBWY4TMo+cFjyscJlFZqNpZd5y1MyHAjKNDzeIIk9y51ER/q1XVbWKDnl0Dn9aQynBorCYat7TBFHaLNBv13hkki1l9ByE3GhwSJ7QJUdMPKNIyxNlrETsRJ6aFDq6sRBNsibEgg6RSJ1hLhAmdpShezuCxq4bB6E0K4VTOnB1/HkmrsWxBgTUAhvi52mbBTzkpL8b39KJo55JwP4E3I1w8Rh6mboprqtne25hT16sPCrfZB4TIGbAG1QZfLshmo+1bYfIG3B6GeVrhEKcV2A9yc6HzpV3gEvvXtMPFRDWi82peEZgC/tzC8D88JNfXfwLEY/BNHM9EYBaMU+IPUMay3qlWD/RyVQRrj58SPp5ymUsPnP+C8YipAxxbb7M2ucjkdKnVvU+uwVGorhD6owudFYmTqsbMBWFxzcw9A5kI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d591cec-e6de-4bda-69e5-08d80b7b1c2e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:11:05.6702 (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: yI2D/wpZuqdyR1nULghIj+nv0nbR0T94mQC5Uczrs+a9fpeemXr0jRe2PY6xHNK/WGLLxFitEZM1Srb44KFUMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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 Mon Jun 8 07:10: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: 11592655 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 AF7C013B1 for ; Mon, 8 Jun 2020 07:11:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 968C22076C for ; Mon, 8 Jun 2020 07:11:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Skuf1tjw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729058AbgFHHLO (ORCPT ); Mon, 8 Jun 2020 03:11:14 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:14272 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728953AbgFHHLN (ORCPT ); Mon, 8 Jun 2020 03:11:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LGDi89MUR6RN9Th1JJAImQrqPO/PiHxzTAQ2fzMQKQnG4clC3UKfQDgG+xAiYJSWcvJtqUXvob8ZfTeiBktgd54CM5PFDuMqp0V7X+RcLK8P/8zrWo4anluhgF2Z9N6yIR8LV9f4aoslN66RoVZaGY5nKDiZR0FEpy9ecBhs9wJE+OUEqKRkzFYjVmoXhi2qLvcl7tZxu3KdLpdsGw30BVHciyBoc2flBFlz6QfTf6L2OnoKYPJ6JuH4vJK0gOh9mVZjIRtJNUZVDpfwwrA5A15Pb6hLxr0KMTHJVw5da1bLkqnWuOazd/c0/XZoGRpKS/WPWqTjSH0yNOUP+iHNIQ== 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=IOevk5X8ZwnFmU+WU0iPF7QzlidB8i6pcsIfsSEJRFG5CcAlCKBo/+UdpkOIrDBAILUQLTRO57MwZKF3GPw11kq6HuzvI+IS95eZhDr8ApXEAZb4qaFLAUj5Q/bqXVh+gb2bSTsW8GojE0rXHJQijGP/CFyNkHHi6e4h9acJr7Gz1Kie/HX74m6jkaRhH1MGybRcz6C/2aT5RRM5U4ueRImUiZYMw4Z6pyfPboz69GJj9vfB0uoDQej8zKgx3BLW+/nsvK2StEfNdsdTXgrIb7luCSeQNHeRTHkoL64K0rRZteu6V1W6dxQ5iRlIlmPSY5gY9B8ZuIqe6atJSLOrLQ== 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=Skuf1tjwI5fiZ33ZnRLd7WcL4b15lcUdT9lyacsfH4Dcy33LNYWiXU/nuhcX/G4O8ahG/KU+UpoZdMqGTj6ka+Bhptf2xrVgVzPwDSSF+eIDxe5KIXw4O7AgHZaZNK5ImoDfikpF53k3jHMHgoyTknQfvg9NnjiXcsioOu9ZDVo= 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 AM7PR04MB6870.eurprd04.prod.outlook.com (2603:10a6:20b:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 07:11:09 +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.3066.023; Mon, 8 Jun 2020 07:11:09 +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 v3 9/9] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Date: Mon, 8 Jun 2020 15:10:52 +0800 Message-Id: <20200608071052.8929-10-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608071052.8929-1-peter.chen@nxp.com> References: <20200608071052.8929-1-peter.chen@nxp.com> X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) 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.66) by SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 07:11:05 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e3f66d73-3cd4-4a53-1444-08d80b7b1e0a X-MS-TrafficTypeDiagnostic: AM7PR04MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HDovy9/1A3r/gx8MAVLUnFxB99npZINae2OMMSNa9NdtDuXGdrlsJPyQXscDbc4W0iXlIufvyANVFbHEgFM3VZ0+0nSsRQqT1drcKL7JBWONtdR6YKxgP/XMl73NJhjyiLIWjxoM1jwqsTaqOgXcZKnm21N1wu57t+ZDObj/7rB9tyL+zHPl9SS61mPjKnYa+iGIStDMY30sfvB8ok8WoHDWs1Yaw5BA3+ETGEWo56kK02AKJ2OIWSnxKndi1C58OnYQtnOlZnKUEFYXSHZf5Q7OHtizW+fHYhYzAoCkpiSEvzkY8LNmm/qgSpx+BorqjI0UEJUW7Bwb8736eMEHRg== 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)(366004)(396003)(39860400002)(136003)(346002)(376002)(1076003)(6512007)(4744005)(66946007)(44832011)(5660300002)(8936002)(66476007)(66556008)(8676002)(16526019)(186003)(956004)(2616005)(26005)(6506007)(86362001)(6486002)(316002)(2906002)(83380400001)(4326008)(478600001)(36756003)(52116002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: oK3IBMSK6gEC7x/cWEfj0Vo/Mn8zrzUcTelp4dTa9pGPUxcdRJwBW1RenbilikB4jVa3ka+8jJ4UKlr6I7OssUvVsteK4eatd/BM+AnFmDKnCQaBikd4dc/ch7jrGRs4/WlJfamcU8FPwLc6zk5OqR9eXe++U/ANnNEm1KjqOYgZ8xvMr3SkKCKL0VqFoNsZxoiDaHRaG4WkmQPQfPWe1W4QhDLGmR7zsV/2WICdrqhbojenIrydcpJ2rPHqUOy5urVy1vqqSUtyYddTCDwRcagtcT8nZvbI87jL3BvTZ4Ne23Q4mUAGtdDDcMw4NaT8MtDSTklL82AUze8wR6oo2OkGqpuENAhRVCXqH3juk86QMm0BFJlhcLDxDpbMOOA6/6CJnmxH+ZaPhxPs2t4AF4yri+2pVp0ROTc8JPsFkrr2nai7pmFZqNLeBXEQnpNM1G4/HxPgdSWvrujDr87wAMqjqj5ckEhtDwheuTctbmw= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3f66d73-3cd4-4a53-1444-08d80b7b1e0a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 07:11:08.9449 (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: d6h+uvg9EvqyUkvvmo5jtBzGJdwXUmicEmB+D3hR+GjBc1cE7WCIMPaOOWTrqrZre7A0+WtOUS2aVyd3+Y3fBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6870 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, };