From patchwork Tue Jul 7 07:49:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647969 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 221D692A for ; Tue, 7 Jul 2020 07:49:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 041F820720 for ; Tue, 7 Jul 2020 07:49:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HW6W86AK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728330AbgGGHtw (ORCPT ); Tue, 7 Jul 2020 03:49:52 -0400 Received: from mail-eopbgr60060.outbound.protection.outlook.com ([40.107.6.60]:36064 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726540AbgGGHtw (ORCPT ); Tue, 7 Jul 2020 03:49:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XEn78LDMgRl3328V5UC6g8sQY0+x1UumobI0iW/Qhbry5Zg5Tjv+/43wF8EbZHqfdUJiYwKxMcPOmDiYUkTBJm24cHFwZ4PFOqrEx0pM3pt58KIiqfX+33/6qvNILw/cVLaaon/MFf8RjXbi1Dvq3Dz/xlK4TyVuuNVPOC1UqpBe+FfOSWPZDZ9LwhJNghd5NSf+fVRR8sdhfC96TOHz0er1fpn/ZK/D7hkh8YsdnAI0tDsvuyb0Wnnmt+Yd/pi2o6RERx0o/GoKGRoHQNGg9mjOpAc/I6n9iXzsIG15OamdRPF0Ff8h8ILTyoutRIJ1NeJfRIOcrnAxt0UnSu2mmQ== 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=OH+pOBGrIC5plEvwcGHMbeA9goPd2/eIaV/sIYxdKSE=; b=LMmhpt2X2cNqKqYp7OXEIfXbMgL0il84Y9RD1nVWgnlbfh02DEwy3upnqFNFs0sBT1rfrtYLVa2PBkPiE0Epo2Y4CjfpW/Te0t/fBAVVH2SZz8C42PZWW4IBR7SWV4YT1eEZBJ0FnNqexrygTTFnI97LzjbbRLyeAjnXBA2sXGx0QzOfXEun1Hdq4iT+d3LjSx1L1eYben6rekzHuJUaXt9nIuq5fSjt5B0h9R+n9BhvJreLejjEOU+NsvhT4R70lAfeWMAMU6LH3i7fxosmOgPjO42cRxFxXtp2yaLz40Q38SggPgmsdmRZS3TfLT31FKG7vHIOVw3phb/jA5eoMA== 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=OH+pOBGrIC5plEvwcGHMbeA9goPd2/eIaV/sIYxdKSE=; b=HW6W86AKIdcFJgU5VQcNMWMoF3zaLkAmeaIllqqT+w7OJcSlGXDSxaXdxLLI+xW2auFBxwsuoPrATDeMx9V+eOb/37gEq3+mglaVTjUV4K3nOKAAGGAcPQ6ga32qQeUbOEe8W5cZpUt1mNdANEv0LSpeml4lqkjcv6Mu1VM9kto= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:49:47 +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.029; Tue, 7 Jul 2020 07:49:47 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 1/9] usb: cdns3: introduce set_phy_power_on{off} APIs Date: Tue, 7 Jul 2020 15:49:33 +0800 Message-Id: <20200707074941.28078-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:49:44 +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: dc9e87bd-e034-45e1-b752-08d8224a51e0 X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jI+nLtbughrJMd4h3obF0702KYQoOCgXAJ4hdy+4Hh03MIm7lYf506PKyTpVkpKOv/RAuqLDbviV72Eu+w8QIQRbLud60D5VTJ8cmuipaNXx7Txfz+j7qa57nesVcsn7SjHdCUB06UAg97V68q0hLsN0C5gD3p1Oh9dao0RaaVusFeMJDDkIAc3FdDy4VWwDHy/M1i7kHDy4jDGixsD+Qg1dUqLOOTsCgDm3c2IDN+Ye8JcW4tWA6XbhNziTlRXfm6JrUVVWfT2yAIOHbjjz7am7KJCIiau8kFaoOnn6Uy5DuK1lzifmNl5Bq5jy6bMcjHl9KhsBB9U72MqWdTVeMA== 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(44832011)(5660300002)(36756003)(66556008)(86362001)(66476007)(956004)(2616005)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HstLcLsYS3w6QAzEijLBzYpIaGxWiGLwWjlCb/3CHUH3yNV3jP4h+78czUbUz/q6is05RsgBJoBkFroeSx2s70LA4KqnIuT3OwKmAgjamWNlZ8YpZFmXA/tgHtZlR6g4lQrukuWjLFd7YatoMP9DwgeK3lP6PbzcOOHkgpzuNgyMECm2pqktBmgyJUdf/9l86SbbB4Q3rVxGepkFV5xztzYvanGQ9HqCBOSohgJ5Uu8D5CjRCV+1yfCTskn2c65pTWo/ghzQ6Eh82GRE8+wesfWIZf4zvW3Rk+6IZJdk1yH8qIztpEJW03pdQzIZlLUHXEqqWZOQ4Xz3TIzu+9kXvYvVBuwV9N2yEai3nCR47JhA0ZpznKmKm40orkuMSkvdMkftWHop0bjj77byjkoJH761Z8l/Or0UQ/Qu2jcyEZE8EyVR0lZ6mWp09gObD0pJzCC+o/N7otlrA5Ej4NofxDkK0R03j0YQ9+/qZyJOJ5nFU0yAXRP+wsPNX87oNeff X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc9e87bd-e034-45e1-b752-08d8224a51e0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:49:47.2936 (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: xRcBj+bQ398fPqzfA+f9n9U0pyDYxmlAiA3TW0AbUAbMR0e21yFwhsk7sBlrNUg27V7pKS33D22xFtpC70TI/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 unity APIs 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 Reviewed-by: Pawel Laszczak --- drivers/usb/cdns3/core.c | 43 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 19bbb5b7e6b6..8818935d157b 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -384,6 +384,27 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role) return ret; } +static int set_phy_power_on(struct cdns3 *cdns) +{ + int ret; + + 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; +} + +static void set_phy_power_off(struct cdns3 *cdns) +{ + phy_power_off(cdns->usb3_phy); + phy_power_off(cdns->usb2_phy); +} + /** * cdns3_probe - probe for cdns3 core device * @pdev: Pointer to cdns3 core platform device @@ -477,14 +498,10 @@ static int cdns3_probe(struct platform_device *pdev) if (ret) goto err1; - ret = phy_power_on(cdns->usb2_phy); + ret = set_phy_power_on(cdns); 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 +513,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 +539,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); + set_phy_power_off(cdns); err2: phy_exit(cdns->usb3_phy); err1: @@ -553,8 +567,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); + set_phy_power_off(cdns); phy_exit(cdns->usb2_phy); phy_exit(cdns->usb3_phy); return 0; From patchwork Tue Jul 7 07:49:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647971 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 1DBCF13B6 for ; Tue, 7 Jul 2020 07:49:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF47120702 for ; Tue, 7 Jul 2020 07:49:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Pr0+RbB9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728346AbgGGHtz (ORCPT ); Tue, 7 Jul 2020 03:49:55 -0400 Received: from mail-eopbgr60060.outbound.protection.outlook.com ([40.107.6.60]:36064 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728125AbgGGHty (ORCPT ); Tue, 7 Jul 2020 03:49:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wt5mAm+SqmvVp/Ntdf05ck5i7ipawhGs3Cf2FfcxUbjny1K6FxVZ9aHEsQt9zJzbR0Cbaq4tm+wilrGBINdIK2ilwn1RQyf0O7Dy4SEt0dzeFEohIxA2gY1b3UNttI9+Vuxrgc77wUdKyqMc6vcZL3KZrYr7k7UbUzdZJqS4mMny5y97+lliwf/PUqeupTM3+C6EuISxwClZfVpYBYZjjMsLXUdtzNumvCHIe5Lv+DjXX2N1b/HdMewLtDu2jOz9AaMtFWgFfB8M/zkHkqIgkAZUFMgp9odZVd5KkIaMTQMc12+oG4o/myNWsrRotmvfodgsBtDadxfmesmLGpz2LQ== 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=ApXsb0MtkkiPYdTG8cVDMsjsOMKWGpa+ezkXlrfV8sQ=; b=DPCGZCTztuB2sWc3QsPiBL39eG/FIb1WcZXRX+TaldG06N4ZscxPvKJgBhXgkL1cmIwiXCR3A/57Y5uVCmmRvkwE3kGfaghD8RU7nn7pB3uvzPbXgr9iD3ZLh+TZeR1kswUmVP3tJWGAv8nR5z51JLbyDOxcfKvECK3fqp3/jBLbFCIWCKwHGfSqhgo+Ii9N2/+Up8G6JVORPMYrlsezahBr8TlVcy0YM3YNvJJjc0h3z7aazogYVEXYIGqRbtb/KoglhFlj7saV6ZCAkeTaXChmi/TSnDhGBazDVMSwTdqChPdxCBuhJjhGH/ll1vMRH8mN0TYJNKRtC7VbDfKfRw== 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=ApXsb0MtkkiPYdTG8cVDMsjsOMKWGpa+ezkXlrfV8sQ=; b=Pr0+RbB9WjfBj7q5wCyRR+oAmPNOLKTnULGD8+h3pMqnzpoeb/3wTxl81c/18ScslcCF2iCC+RTzsgp/6Y6R7mQigiA2hwy/I6VekEx9D1Z8gfwvr+R0HKqeOFdkemEWO9DDB86/K5saBCEQmq0JlDhX0x7WZ6df9isv/mXVSm4= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:49:50 +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.029; Tue, 7 Jul 2020 07:49:50 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 2/9] usb: cdns3: add runtime PM support Date: Tue, 7 Jul 2020 15:49:34 +0800 Message-Id: <20200707074941.28078-3-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:49:47 +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: d1486df5-d116-48a1-ae44-08d8224a53db X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7y5TDDKwROxRTn3YvGtvlC4p9rz7nx0RzYk1+bL0gmztGvH6NSFepTCTBqct5gyovHbwwz56ffMQrqvRXCMrp/6o4HX5VXgBxNp0/kBwMtkgGpSTqa7QCMjKZS6+BdKh/kiWq6wuoUj/4Ns3f+LNP4nh2nLqLQgk75gESg7D5fofe6ibfguHJDTiY2hcvPSwl+lAVCovTkoqIwOBrb5yQzH2mZj5pHax1PsZABLErdBHqUc9O5AclH5SJ1HlVv8D6HDEtWLqen9A7J2sbFVt4/QhbuKIzjG4mU6rMsgEdbP28qzgIcGcSIH/X1780Plw/kl5kF/z6xrvP1A0TEiyaA== 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(44832011)(5660300002)(36756003)(30864003)(66556008)(86362001)(66476007)(956004)(2616005)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bzvtSufA+4KgMGjq2/ymkt8AmpGSKUwaiHM4j1Vcx0M+7Xh1bYKWu4WCvyl3qnqAFQtX9SKvSDgfnnX5ImQaoZ5nIV7cRgTJIZblE1SUhO1LUlo/Go6fjeZ86mOmS686BzUstQf0hRm/HFlEGGaVVyxE5pw0Am/PylRbmWQkswXHaPnX49eRU9c4AmZwZjw9nna2Loie3vvj1c/gWotA+QdFz3Pf6cI8kZMdSzg+/Nrlm4RM5Kd/c/kGv5HuzFs6V25pXRUGewN3mL9SwEtHVEZo9q5LiS+lvWScsvIeDIMCATTTv4NcC1UjMyzgQA/5fsjilHROG+IAPEoXtMqWvXnXwq1SyY1/MDdOp0YDzTv5qOpUJBRSEDfVUH/EayTLco/d9UYTtAll6jGmTWWQ87jl6ggHs8oqoC7PAoZIU14H7pccDg2msEWrFZS8zi7P9UmH9guwsU1iGnGkIl3Apo73+PqbUsRP0e0D2ZD3qwHY0h3MbGNd+f33FWZF+HZe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1486df5-d116-48a1-ae44-08d8224a53db X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:49:50.5931 (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: 6YPucdR3ld2CVPBJppUIP22jFzkb9toY/7DktfZpn6P3l/fIbzG2mKukaO9RJ777gYVmeaMNU5z5czsQBiPMXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 Reviewed-by: Pawel Laszczak --- 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 8818935d157b..f98c3c1a6b26 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -405,6 +405,30 @@ static void set_phy_power_off(struct cdns3 *cdns) phy_power_off(cdns->usb2_phy); } +/** + * 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 @@ -431,6 +455,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); @@ -480,6 +505,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"); @@ -516,6 +550,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; @@ -524,9 +571,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, @@ -573,52 +622,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); + set_phy_power_off(cdns); + 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 = set_phy_power_on(cdns); + 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 Tue Jul 7 07:49:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647973 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 E2F3313B6 for ; Tue, 7 Jul 2020 07:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C16A720708 for ; Tue, 7 Jul 2020 07:50:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="CCXuDQwa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbgGGHuB (ORCPT ); Tue, 7 Jul 2020 03:50:01 -0400 Received: from mail-eopbgr60055.outbound.protection.outlook.com ([40.107.6.55]:9880 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728125AbgGGHuA (ORCPT ); Tue, 7 Jul 2020 03:50:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GHK6ZRo+5InDtRgmQfkB6RYPvqjYeyv8bSn/P3HBO8tENhmNvXKKs+DRcRrH4xPhuq4MIDkPbq4PvV/VozBnK6n6acTUEPbJs0xFKCE0aRWwbE1pJ77lne+4hSVmCNwanxVpBRrcqnjbyXz0joXI15LGNGSOOdxzGcMxWack41I3lQhddQRcD6oFKj+PVKnorvrExlQt/yp9+kDdL3594vVfO1/fU4ejnnCDvRgP4QqOSIzri9jm+lbzscAnQ+grU7/WLcu3bARXUAczMqkZQHycjUzf4HOT65b7lmU28MTsjbvUDxKzAcikT01vyApLR2gyGXXnU2KbURj/HHwICg== 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=FUQ2A4//B2YHG6EGtEdRnoqpXFoBaTQoSXWelyBGgoU=; b=ipqXZNxGmcWi166M3v4AN/Q3Iw1xy07KO92meLepnH77P/CJljM1cSdWVny0eXOFE+dSfD0iODVfmxVRtjeiIIhkwVfaz2HoPDyiyoOZWAQPCWnRf2vc5QaGVe7ommRB1eQqiJn7U3r6G9IaR0t8miTJ+Kx90mfMgNaQz/cMrWpNVhD4XfUhlQESlVhLf3pMhOR0BLt789cXh7qB0v1X4Ep4k8SVaDN+G2c3T4FbDifeRNWVZ3LhF2QO32YKAjNW4TbSSYgH2+nOd3t8vw9R+C5AFbKcplsYPESAActMwG6dFuOOrMJEnpO7fNfw028+NnW+E5EtxUx64J27IfPV0Q== 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=FUQ2A4//B2YHG6EGtEdRnoqpXFoBaTQoSXWelyBGgoU=; b=CCXuDQwao3R17GDR2lCT8PsQiOAP0aC8BxvYZIfhKKnpuFifz+9ddmvlRF479RIiU7xHhbaCt3PIR0dkDOdNgCrwdoW9zlGg5JMYmDBOA+qUaG5Sx9NF/7XJJzDyRHwTkxtSN5g3mkQKHGEKmKBf8SQAAumrxHDH15mzSVXTMQ4= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:49: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.3153.029; Tue, 7 Jul 2020 07:49:53 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 3/9] usb: cdns3: imx: add glue layer runtime pm implementation Date: Tue, 7 Jul 2020 15:49:35 +0800 Message-Id: <20200707074941.28078-4-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:49:50 +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: 07c3721e-3e4e-45c3-b86a-08d8224a55d0 X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lPiSID0RlQJl3xT79DlWA+7kJvXKn1rC2yOMzuHRo2XefQW2PxMrU4mu4EqtQMcHWRIM4CZJOKVzO1lzS3GAr8vcHf397bdIU6f9bb2+v1791gnY55wxIavQs+BsM4CwTn1OA8SrIcvSNRFzfQ0LR6G2deluoOTx1Sm/I8OFl8AG7cssMo00XgmHHZjZy/CEKGRKcA11GAN08iMPqf3SRIZg9oNco9xaMlWyeY8KMX8lj+pkP3z4t+Gax95++KULTy5mn+sYKK1mw7jR6MliVVfPxqj+O3UViRw7WyviX0DIZ7UA5gbiPRH74e1x/td7AOh9sKOB9B7AKuYnrnZsYw== 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(44832011)(5660300002)(36756003)(66556008)(86362001)(66476007)(956004)(2616005)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dJh0IIarIk4MMzcmzhJt5muVmjN++32RjbLRpxee6IYXRtr8mOmoQUdDHu+IqWEaZczCr9jgwIe7UOL7u96YFvvTX4U0DCn6U2CXYr9UHi5JSQOy6OYTBdU3BFHBFRqkJJHbdWZUMHI/n4Ux0oOhWgKCqT4nf2LlYW+w57/yjTkRFk5R7HY901aSg3shf1Na4pqtxbXATKrDoIgptJNAt5uWsffpqZgLK0Ef6q3fs1xJ0YsifbEY++NUISbaWw3u3++hfLnaMZ0o9L3AFjrAGIYoz0dypl1zIO1IsCDZK84XBgfVYdCWisTpaOd4ACFYoOrFGUy7VWzbnCHmDEwInC1iTHhjo7J9nT4MVD01wLz83L9PE/EvmgTalsG+GUavItKQGk5jqiFrZK99uq7z+r84041NaKU1D9UzdNAfT8CK0dWDnOSjVGcFHv8Isz4jZXC9esK9F7+7QYDJl1bOS/TOp9CdVTdSU5owdWDfvBiXrb+nvUiyOqDYv8G5rkv+ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07c3721e-3e4e-45c3-b86a-08d8224a55d0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:49:53.8777 (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: XfS9UvGNIvOwhBcrMUubIeUahlBunO+DuHjt2nsPBvWA14B8eUyzWatmdEm8RfhXkmbouGtK3qIR5mxDQ5PiCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 Reviewed-by: Pawel Laszczak --- 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..5d2a4e19fa83 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 = (void *)(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 Tue Jul 7 07:49:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647975 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 6753A13B6 for ; Tue, 7 Jul 2020 07:50:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E6B020708 for ; Tue, 7 Jul 2020 07:50:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="K+1WG2tU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728372AbgGGHuD (ORCPT ); Tue, 7 Jul 2020 03:50:03 -0400 Received: from mail-eopbgr60055.outbound.protection.outlook.com ([40.107.6.55]:9880 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727116AbgGGHuD (ORCPT ); Tue, 7 Jul 2020 03:50:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z82geetulWA8h0fDv31sXECIIys6pTqnOiYSHQ9grK9B7UWw+Jma+AZVwNSdLoZbcrwafwPH2Q1EPeTD4EiCWu8x/xqaHmq0Zkor6x0n71riYXMB3AXnfwuaVy2TiuHRc+sY9pvCf3bPJcIfxzv/kPdb13qqdG/l8vRjJjgvU5FKDaLs9MsdPytDmePD/SuCZd2oTk49elsiINIh5XoNwVIG6yR2XIFr33cyYXA81ShQ6jVg5n+UzxfZ2Zc/JVlcILJksSgTTwTgWpiFbKKhgpUGHkOifTgfmKxu2PQ5oeIzZUSPBl8Xa5GT63Vq9e+laxSWaz03GVIYtfg8/92QjQ== 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=Bd4gk5xai3Z1ekhzkzbcQ5RZcs8PWqc9HwyUG9U6D3niAPjSzH6RadSKODS7jnpOFHoRiaBu0q2SLUTVMbIxsOyVc7sLud5K3/YHhW+txi7aNx5KfR4K2A+B1dgrjzd2OCEJBZ/EvsBdlrCr1rf+d1nMUpVLX5WzB17Vl/c/H8tZwPqiyC1sBFcCWexlvLCL1jPquQSGxpqFerVpRcY/iyLH/pI5XNrO+/zcg8j62plsMPK4gfJLPPngP1Ljarc/bw1UrJxycUJ7QdgCJbumBELjaqAK4k2LUEwo9q4qnTfDoB3L2ikBzUwyDNK/ReZ376sgT48v/C/As5bgMhnDhw== 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=K+1WG2tUa+tWg5DnLR9vPIF0lKYeYodaMWep71BQiqiRsqz7IknpyfyL6MolbZi2hhSADGo/uWb4Lh+fwW4v9mXDIB1TUzvdv7Jeab5IrSq1BkFOBnK62XC/F5RHu3iY1/RRF0UmPRjLJyU8mvYKn7gZlsKr3DVYdoUC8o/54EI= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:49:57 +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.029; Tue, 7 Jul 2020 07:49:57 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 4/9] usb: host: xhci-plat: add platform data support Date: Tue, 7 Jul 2020 15:49:36 +0800 Message-Id: <20200707074941.28078-5-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:49:54 +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: a60e6901-6ac2-4b8a-3443-08d8224a57cd X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ooNKsxXPvwGT+BuSM+poS8Gi97/DJzU0ijPxmFVTqNaXet+a2M+1FHgxzFVmA/BbwCO3klwUh+A2jNQqjc6YJPOMeg/zD7BqkQ/CyoTutTgQBtB9pFycCg4lU0seU4X1voOws6aYZBHqWQLAC86viEPs0Np6uHKC2zJ3wGMjYjU/IH4sER0XhAKp+AbRUrYLKUwCb+9meUVNa/2DwEJcRodYlqz9npPEkxYfEa3YbYRN6/dIKNrupwHTbtfk7yEDP7wPDQa5e/n6FZ0i8H28SO8Od1qR7wsnIHscgTQ1X0XYsqCBWv1tVbufeyqKdkNPcad7QoSQr733TZ/F5H2xhA== 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(44832011)(5660300002)(36756003)(66556008)(4744005)(86362001)(66476007)(956004)(2616005)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hxp4SA5IdkV2kgVqDH6EefBnVioZ4PO0Io5k5Xn/8k7k0bBU16s6WX1/aKo+H1uiwf6zKBPxuOD35yqllQrXwnLkr32dx6TiC58fzlD7LiD3SPbPnt7EPZHH5ajZPaF6zrLur0Nn+cSjqugfu/Vy1nsgyEWuP72C4Nzm2dviO9hDWLgXBG4fGlU8g5SalQ67Afgt7SFCmtTR843UCGozV5cdn+IC9Sb5m2iqsZ3FMajOJr2quJzJX3gHu/lAYi/R4V4vcAPr2aQP0bdhKii4GcYmy50jthq+6+NSwb/2l6NzYXIjMfLypKtovtIdi15U6gnNDpOEwsCFllD5M5wg59vibyHU/Fv2FYCLOKU1/d1DcsXM8ChQs1UmsZNHo9qg66KDtWEKjjqGEE7pafUURcYkExHyXZ4ztKTFU5tPqn7M1qTHC3+C++6LyQUFXrZEBYkIG4bY4GF1d6p9r79BAMKk+YMLDBnWrJwWRqqkfH939Hc5t1vrIWQpCxm8j29L X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a60e6901-6ac2-4b8a-3443-08d8224a57cd X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:49:57.2091 (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: 53uLXbhQlpHYfd8UObDP4+/k2Xqf3dZbrR5cDMkbD6IVluu78gNotMM1WblATVdpk+eSfn4dcwRAsnLFjCdUHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 Tue Jul 7 07:49:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647977 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 52BA713BD for ; Tue, 7 Jul 2020 07:50:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F22F206F6 for ; Tue, 7 Jul 2020 07:50:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="FKcWZWtZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728379AbgGGHuG (ORCPT ); Tue, 7 Jul 2020 03:50:06 -0400 Received: from mail-eopbgr60055.outbound.protection.outlook.com ([40.107.6.55]:9880 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728125AbgGGHuG (ORCPT ); Tue, 7 Jul 2020 03:50:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mWiFUVebEtP/13RFXGQPhyQRRjbiK1sG++CQ3h0yN1h/8GE/ibzrFTWVq4lN5e2TL/DafF2BXp2xZ5NKxPF//l/5yrmOtX/89pGF2tMzCGZrdK2Wktx7bUoLZRRDN3eV86a4fT3LjewnhXcZMXSh5M4Z23BWtSqnKO8+FqwElnrcPJoSdBfLaBA10bxxczjGCPY3zLmJyTJk703a4r/sJvt4fJWIJcFHPORZ5DwCflFKtPotvwFnE5m5IqQljlbIzmn8Ge9nnoqL+iXKz4URce5GWFoqdUC4GwOJVNIrmm5Spl/WXBxHlKrQdbiR0Hut8GpMtsKQ+zmMxIzzOblviQ== 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=nYwPOXcmyMMx/r6wmfh9jw/VcGLOXKA4FLY5shZypu7JxTGiwMdtFyICSjs/y3drcUJyxSwtayi+ejdishXivI1qY+txmTr3lJd8SYSbJ9vTQGrJ+LuRoaCZHzC2VbTDCBFHIOGTHRdtA7rYjvrv41ilDe5lezhHB9KBNfYo37PixHxofQfWXOA7L35NF4wZ2tN4oTbRUck4Xaz03UBjxxxTE3wiI39/cCPg43z2mzSU7mJTWs11VET+SrrZIyLijT4ukITjX0MfcP9kaYTcpr4Gfzx7xGC3meDeWiAfa7KnVxCkdwdOr8PZYGC529CcjRQG0D9WmmPPFl5ht6GvPg== 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=FKcWZWtZYH/xEVEXjdz7wgvM8urZc/ST8iLwfBwCjyJAPgDxQsxOD/a0R0MCCkCeXM8DUWOVqBwU7Gnyg3y/05w62eYaXQsBhyGg80QXrK1IHeAR/P+Nn+qWf04wWFZ0FfUoKBBfPJrdK4Dpqm9pa/9+8RASOctLBoBJDiQ31hU= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:50:00 +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.029; Tue, 7 Jul 2020 07:50:00 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 5/9] usb: host: xhci-plat: add .suspend_quirk for struct xhci_plat_priv Date: Tue, 7 Jul 2020 15:49:37 +0800 Message-Id: <20200707074941.28078-6-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:49:57 +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: 0243efb0-9186-4e81-21d0-08d8224a59d1 X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2w3qzT+nWnd6nOx+mw3wHEcdcoCZZimj9kkTz1HRD9jiPMugf672+ZT3oR9O9cW5L076B3lFZnJPuGBG+Dv5WxZGhaTIOFBjsQi0uuvQ3byt9q8lI6szadzH3lCu2/KWl9hv5B38yv4aAGnnXZ+5HzkPD3ej5vNbGW5mj7oIQtrKK7iXO54+JOy5mymdHk/BLl+0hbDSj8nqkn1FqW4nWSH5vAcmAiMjVvfG9N4JDi8nlbghFL+Wx/8DSybdCz463CRhuk1IG96TI3WtGQwcxDQDVWTUnSHhz2dCsOHXVmU1eWComgOfh50Oy3/V7LQ3brshp1NDESDB0oiNsC6KBM6W52UdA6FEAGnhpzF6b/3BPdPs3HLsiiFDJ+omynCK 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(15650500001)(44832011)(5660300002)(36756003)(66556008)(86362001)(66476007)(956004)(2616005)(316002)(66946007)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dFQQlym22hBNwnNaOG8v/SBRc2/aVxIQXrwio95c3Q8fpXLruQz2EIXTYsYHQD5gsjy2k6Xiw6tRMBB+g0xeSHIrukVujh7IwoEKZrPEdtnbPsk5iHWamhTsnky8mxumyIxidAB5B5I3nB06EM2XBPagJ7L2N8/Ss3Cl7d4P9OUTvvn/28OWHvVCY8WMIflfZrcTfxxfSboOpQt3fgC5BTNmoOvp6ddKYHPW823bmFclRf/iRLAtOa7ID6yAEyml0nCtwONVGFA0yaIuvnyTWkQ8aioQg9EWe7/wZvNW02Lno5wAvimBknzbHqONf4B3CkTSSFHNlNlTM/8tD6C1lRalpSL+iD+XG2+n7Yxjqs1QnC5fkYhKwAfWmCcQoVL4xzc3+gwaRRxG1zWUJMOnuEiaKUnIT2Jv2D2zgxsfoIp5o7ngd1VmWEgCNjXmoFKGBya8QxlRY4ERhMoN2BuWxgGOO8EpZIXryOhXOvzsO130uX+7BbxVqbaIOM0aGvFT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0243efb0-9186-4e81-21d0-08d8224a59d1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:50:00.4838 (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: fQRrw0wKOn99tUM6K4jwHYkgBgspf1mfYRgWq+UxAeJ/fPlLqpaerWxXqe6oqYwPz4vfK2L00KfXk/rRFRA1Qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 Tue Jul 7 07:49:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647979 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 3CC1013B6 for ; Tue, 7 Jul 2020 07:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 258A220738 for ; Tue, 7 Jul 2020 07:50:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="K4EyLozb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728393AbgGGHuJ (ORCPT ); Tue, 7 Jul 2020 03:50:09 -0400 Received: from mail-eopbgr40046.outbound.protection.outlook.com ([40.107.4.46]:44708 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728125AbgGGHuJ (ORCPT ); Tue, 7 Jul 2020 03:50:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5hATuDMP1qgNfPBAsQIbpCtNC74UurM9UIl8AsKbQpqcQleufa3m01Wu/d1b+Qu5J12S8fEh0+bAaXs8bN0vY/CPs3D/lFAskwbRtsamb6CZI+vnRQhTl87UX8oKLymSVOitDMPbmbxc1tWl4Lxqo9DQnCqGS1aXy7f0Lh/orlzH2FEmtAi8UdnFPiPdvWQGhnIxS5z+c8cOq3pbOQES06ZvkIahkxl84m0bErIciga11GhOthhM+J7CWsGBS+iWjaRvlmZHbbzfF7OzrhLwqydph+8UWH+Ws06kr8m/2Whfyc7hJb8kFLEV2H6K4EMgaS/3NnYvDHMbB7s/YKDeg== 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=UrK3f4bk0AKJhC/PPgys4mHHnAI81BGHsFL0H1xeDwMLvjjGfxjCnhByYGJp7lNTrBAJOvEbS0utVAk9niA0wrzLFLy8gWWELvEoN544R4L72vP1eFTVXt94IDe4FS3WOst7zbWLJWy5mDZugjo1Z0CVlcvAzpQ8dggGiSS0uJJQa2oDmjTdEROCrY2uWtx9aVwPMzcm9DF2zwJ66PRnctr0+oCrFrANFM7MwPl7tXYrStzmSn+46C617mxekIaHbay/Cc8/Od3A46D18FHmRTg/ao2F+OfftQDHyL4rbdVFRaQsFwZEHLOBgcMIegSMAC1CPYsDM57HNwxrP630Kg== 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=K4EyLozbvT89e9zgToc9tJ/YQSfBFTiGhqHY3Vxu8V0nrgqe+bdv+t4WQ6dMQsBQpAOp2UnTm9BiKcPb0zJL/Bk0vsIxrqWYqilHIxIMsM6giMhr3vW4y62QirOWIRmGsJ3DepQijSv4jm3XYs8oA2S6w53DA5uXERkVvKahcyY= 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 AM5PR04MB3138.eurprd04.prod.outlook.com (2603:10a6:206:7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Tue, 7 Jul 2020 07:50: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.029; Tue, 7 Jul 2020 07:50:04 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 6/9] usb: host: xhci-plat: delete the unnecessary code Date: Tue, 7 Jul 2020 15:49:38 +0800 Message-Id: <20200707074941.28078-7-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:50:00 +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: 0aa31a53-78b4-47a8-faca-08d8224a5bb6 X-MS-TrafficTypeDiagnostic: AM5PR04MB3138: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WPA1Etp3a71zlSr6hs11ryXlgZrP54/ZQ38YaapNIDMfvSn5pMbnqMoix4t1/mcei5wmwOqVoN6A4ZIq4kscUI5EiwkcukLviagL2e4X/+/EFEBdhFpRLuKItHOU3TfYbHIct7fopyAlbvYFhPBXxscg0j0SkXcb8EsYvkzbcxfplL3+GhybkWmNNsrEEqjQ8RRW9CMq78h0MPHHyive8fWfW4RLEietzX63YJj20CR0XEfDcI6ERJEE8elbjqKjIpotnpMXKP+TyYQMww9P46Pcj2/4tUu5qwCr9+j0bU0I+ao1ppuOkxNQbHk0VmcgyLvqbigSt82RVFm4y8+ZsA== 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)(39860400002)(366004)(346002)(396003)(316002)(6512007)(2616005)(956004)(44832011)(1076003)(4744005)(6486002)(6666004)(2906002)(5660300002)(8676002)(26005)(16526019)(478600001)(52116002)(4326008)(83380400001)(66476007)(66556008)(66946007)(36756003)(186003)(86362001)(8936002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Sjic56Nv6kPnNmH/y9+A0Aft0bepRupV01skYHEbGydDCOW0vKME+UV17BkZl/NvA1sfVAYIFy93+eHkuj82wz8/yxJml4dSMbxzwQ5eP/c90HXF70J6E1C7PayrbVq83OCrxixjNT3bLI+dhVuRsFBucnMywfLDXSb3YX78Q6dD+I4z4sU39iHFeHhkDCWHTpVgsVZctQFudL1ygYhjIbx4RE4kEdtPdaZY+Ff1EVQe7WEjjijSdcqRWF7BYMjlkL8xrUoPEObx/DyiTdAcnwU+opv0ecNkfhrQg2DT7jTgNr/8vgezj2Vtm6r/SgnsZqB6c8jKWNJfF+NxQoVTRH0DXSagylCjQP/nQSM/oMGaJYEGkW9uIeHRu9OP7/tOM/4tJiOns8ieb38qvGrmrmyWazxYX+4j0AMOaQHAUueq4U9IZfjnWRCdl07IrO+DRqTcoYga6QwzwO1wrCb143WCteZwtHcVbF/dZeSzth54wdWk9tD5/w1ZhyUOy1Zy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0aa31a53-78b4-47a8-faca-08d8224a5bb6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:50:03.7992 (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: EwPaBY5X92NxN6Lz1EqV/yu8ibLv3o01ax2aOrKR+zb0NFniFazG0KflXOe6Qtva7osYQOMB4l4mfnlI5JzU7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR04MB3138 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 Tue Jul 7 07:49:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647981 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 0BE4B13B6 for ; Tue, 7 Jul 2020 07:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E97ED20708 for ; Tue, 7 Jul 2020 07:50:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="pbuVlrLa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbgGGHuK (ORCPT ); Tue, 7 Jul 2020 03:50:10 -0400 Received: from mail-eopbgr60089.outbound.protection.outlook.com ([40.107.6.89]:56576 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728381AbgGGHuK (ORCPT ); Tue, 7 Jul 2020 03:50:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Va48UUooVRsV9jwcPonzoRuQdFlFcL3SvQP/4V/YpyEb1M/zNnoU1l9OXw17aQgD9eXSPZ0Zmcat3/J5SJ9Zz06WjSbyS5Jpp/6mfgIbyKcIv+6hgqifKJMuwrz/qQat45jvpeWE6Puwyya1MY0ECBGjnpzsmPib3IsspesFn0Uvrzly4EH+edQSuRGSl78IHEaXE3ml3ImK5Hytrp3OG90uZjClM11nMrWjd8dZmpFxOGyUzIFLz/Kl2s5GJ6Y9mr55E177IRd/P8FByfv+qhmo1D+gRlTVKmA2elW6K6/SeFXAjzLoF6st71FFyQgALFS6JYvwnEiMYvtK+fo/DQ== 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=gZP/+Y094+bVqmKBYUZlMuOksAhjPOjgRKlQ64WlGM3lGd2Pq0vb9CLBAVDYqiQyvkxkcICnMYPiEZpabxCvR2KqLQxQvYnUC0IMJwm2GP+BdDLDV7+vQmQCpf2WPJ8/vNx1xSoVIRE6o7noWMCkFNnxJaKjhkNNrpysrEz/fyBHZePWSvhonYsPyq3CRAAycFC1O22dcdP3FgiCwDJ40WgY8cxq3PMLlc1WTJkE94dMrkQX7zYnCcAfs0JApyxIq5S+PDP9Ey0zuePVjvbnVx5i9DK2nteIafUu3i/f8F1wDF8ti46tZWNpjpjuSdWNjJP2rG3CMLE9Fs9CUl9S4g== 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=pbuVlrLa3ZgsySvYio3ZcH73a39ZuQnydl0g/gOjO07mDFchWveXVFHSibDK//vfevnl1WytMP7P3fpLsxumRGuZHr7eTHbLLP18fUI+7+qm8NWjXcxY6W6kGECPBkCVconUzmFEZbacXveeUFvglNnDwCI3p9ZB3Ddvj16vECI= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:50: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.029; Tue, 7 Jul 2020 07:50:07 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 7/9] usb: host: xhci-plat: add priv quirk for skip PHY initialization Date: Tue, 7 Jul 2020 15:49:39 +0800 Message-Id: <20200707074941.28078-8-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:50: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: 52987de5-ee97-43a4-3238-08d8224a5daa X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1dtJnANnTCWHyNylfpT5y74EHYldnTw+kqhrmn5ycE9PYe/AuF2GW0/87hJZlJ62srXhcte7waOXbuSxNCUfEuhMoJYSQBpEDUOE7tUeFnZwqWLQ9YbaBfmFgoYHm8ETx5Y5gSp39spM/GzsdPvuKiMgl7B+fZMMBbPT42YPHZ23Z7QxaljMhHWpbnXkb5qSRVFGtpAjCMnivwn821SHCCF60V/1uB+UZBAU9UT9JzXkfm8GXNvGvAbP3xlPPSD15dDrF1VDYhIzLwUhEBgLXNK8yGGKe5DEodTti55J176EKMTsja19gll3GptuUIxwlD5HjuAoNJyoEqZlHDenUQ== 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(44832011)(5660300002)(36756003)(66556008)(86362001)(66476007)(956004)(2616005)(316002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pR7U1JXyTz75DsZ2FvC6NI9qEPz451EBIHH/Qb5TD0vhxnR7ncvMTcgS983DSBkdj361Ht9qgzMrFpi0zKQ6cYEe2lSEyt/mFP+y19yguwuJDKSJRe/h3EldIfadiD4eCrrL8XAcMQ4v6pkNhWALSEnLFqqBV56Ij+g8SOg8GVZS67ekrNoAeuj9Yvy7833ASqcvcO5NZmvOowMp3trtRM9is0sYmX0FZuX5QIjMHMG6tHnyCD3QS1x4A4YWk0l5ieDU3FcMaH2kIJHQU1Qu+HhK7tgrdNmJ7laqreFVKP2Y4ZgH1ggGYt7ZHRFQeV750rIDfde0DnQ83CQYf0mtzU5+7HMv5bNL6rb62XPQnt1Rc8HcSHnvi6ttYwgNgAvwanx2/84kYfj/x0UXx3Ty7g9DBB5yT5HpC91BOmETIJw6IvTI5/PUF8ZUt1Blf7H5wghz5/AV/8CfC+rI+Lfywe3gseNfWtQQMsdfLAKhwnc+gRs+HL/VEkUOd8zYSaVe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52987de5-ee97-43a4-3238-08d8224a5daa X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:50:06.9385 (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: XL0Pzp+ZiGc3UMTKtyMItl1HYlMYC4tHh5/uVcezQPTPjlMJHaUQ6H+qnmgrmc+AuDy2Ftu8IQ3XDIGStCZAcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 Tue Jul 7 07:49:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647983 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 70B4013B6 for ; Tue, 7 Jul 2020 07:50:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CE9A206F6 for ; Tue, 7 Jul 2020 07:50:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="DZremkSa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbgGGHuO (ORCPT ); Tue, 7 Jul 2020 03:50:14 -0400 Received: from mail-eopbgr60079.outbound.protection.outlook.com ([40.107.6.79]:1351 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728374AbgGGHuO (ORCPT ); Tue, 7 Jul 2020 03:50:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f0SprZkSf43ulVj6xM/LjqW005JPTyx5YKIX+1Tqw9GzG83kFAQwqUYXvzNxChfPfDdNWCUqfzC85wTvCxZuY8O6PYTy7cPcMzmqjcijhsPx9Usgc5VHFjze32N1Dxi2EP9beqB1Ay4o/qzFcxHjYGnMb4xZng1DD4ZprCbGdxhP/bkKO7ILdyvy5nLkXfuJwN/lOhrlzW9xEAt0zg0KHkQnYSzmBWV2Q9PT7d0rduJi5CtNYXPutdMd3GsWaotgNqNboQ2Ccw769SCtgNpdalPsReeiVijDDOFxm99EEDjsfCSLIN7rkMTX9uVCRIOiMdIl8/uaxnNcf+iBF1rckA== 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=YGxbw42m/BMjre4xB9EV6R8fpH9bS3qR9HfcitJNqpHsDfYQDF+vpU0fhdxO8aewFRnZRvWeeF/EaeAzt2lS5Vgck0sP+Z2FR1h4OUZo9bo2fwwYNpCUf7uVVoyRyPd81ONt4WPkf9XQs5FBwMvGLJi7LLiPy2hM30vPCcN5743IUxfVRpLxpEnLcebs7nk9CIQO1r7fSdZEqnJIzCqI9+zKOce99HSKvUClvDAjtiIkXAP77gfZ/0Z7Dp4RBJcD9/GlxKth4pz+4NI/vKVoMIRfMfdhpUcC3iQBbcjozqkoTY12qqgekLFyrFU/5avMG6SKc3th0nBR9P2xn6j2Qw== 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=DZremkSaP1zmKGud/iWhWWhp89pfW2zJaimpwQXO3k7T5DDuRyHZJEw1Qk5g75lYnFdA2hxEhjkU3v9gKd0J6rh9kBqxZpLp9ON9AKiOXGiNKPOZhhgsTXQNnpyc6RuBX79aHTBfvnsa+S+7CpG0+x0Ca87FrOnazlW6lalscM0= 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 AM6PR04MB5608.eurprd04.prod.outlook.com (2603:10a6:20b:a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:50: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.029; Tue, 7 Jul 2020 07:50:10 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 8/9] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Date: Tue, 7 Jul 2020 15:49:40 +0800 Message-Id: <20200707074941.28078-9-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:50:07 +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: 3a8dd5df-c68d-4848-b378-08d8224a5f8c X-MS-TrafficTypeDiagnostic: AM6PR04MB5608: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ich5cFTVW53wmlBOo1WBLHwjSVwYGfontSfK+Typ+0ZXq8CrG7qGzJaELi+zRh+Q4ttNUJNN+rDz5u8HoDvLbOgKu5ND/SNIAo3TDu7ZfAL2LpSRvQYtrrRObsTnaL6xyfMjyTQEulTHDEEf30mlVUcPXs2Vd2KwBv4LpDUpNIThJCepzwoHJWlBEqRvnA7gbXKgVBICzVW9K6L0yn8bhB4gjxYKjo+45H6tiGJI63pfIvebF/8JKVoQ6x5A08Oa921TaIy/jWHnLRTQOK078G45HfTV3D9PeIN6lfjm6qQxUFoVhE9v69wjyaSL1sDEo9lJX9VMtz8zM8Lez7plDJF4dBoNM63zhhIBqBbyHQxNA5VXI+H08YEpuQpygJt 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)(366004)(376002)(346002)(39860400002)(396003)(1076003)(6512007)(2906002)(8676002)(478600001)(16526019)(6486002)(186003)(26005)(52116002)(4326008)(6666004)(6506007)(83380400001)(8936002)(15650500001)(44832011)(5660300002)(36756003)(66556008)(86362001)(66476007)(956004)(2616005)(316002)(66946007)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: RAI5l/FHBB91zFgnkqfO1HLIuQ34wXnWpbSknNj9TaxqN7pwD3xdTI6NwY+tEnui54uh/bdf0921JqBtWCtMpS42lNxkf3XTRZveG+InfVPs+XvpPLSqG+tnqe59qvAhC16b/yviFPZiUeUb0NuAJNl25aHBPVBg82CrHQXQdav8r54yFY3ItQ9zYhqQ/lPmCE32pRgoKlpFGuMT92G/W/JjQYV9UaOhYoZ1DCHv5F4jxQ8NsTDy8OOfObQ+C/KljUitl32NhdU8F3GEaXzxN39gzm6xSrZacXiTmrKojQGP/WYSv7GYe/pe+GVNsEpDw5FivMPmJua2GPnCKDgg05JLf7n2uu3TzvpLcZKpig/wfmmzU0YPD9i8EJ4IvBpsVPCyqa2ZNeWsuWOXew1qYAbgfdjjVLBIE4iYLZjwuhi9khPOWzWO4rFOgo8VeaixWxb9R3lL3z7iz/7NAhYAWiKIbhT01RBH6yC7BfnudRKsJ1SCROgsCL+v4LFYA8Ku X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a8dd5df-c68d-4848-b378-08d8224a5f8c X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:50:10.1086 (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: MUGRR7iNFzOlFtQP/hX1d/q732mumKVaNFYqT12d/j3Fn5uEcc06lkHcHCf9GQ3C0x6IE1SM4mW/KjnMLWYh8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5608 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 Reviewed-by: Pawel Laszczak --- 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 Tue Jul 7 07:49:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11647985 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 6B16B13B6 for ; Tue, 7 Jul 2020 07:50:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52B25206F6 for ; Tue, 7 Jul 2020 07:50:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="jqnsXZLl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728421AbgGGHuR (ORCPT ); Tue, 7 Jul 2020 03:50:17 -0400 Received: from mail-eopbgr10075.outbound.protection.outlook.com ([40.107.1.75]:13280 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728374AbgGGHuR (ORCPT ); Tue, 7 Jul 2020 03:50:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJM+nc08HdQRwvTVJIJvt8ULGDlg1Jo7RJf8JgQDb6excZGoWuXqEKMYSx+h+UUkefqwxJ9IEnAlNKFApKLxCc1dCy6hPAD2YP+dGoyuOYWsDj4/Gd8iqwNtEpl1bjUHeb9WWlbNmvLCvUA0ILOhPw6rifOhMYkUaSjeWMwP8xlygxe06lEk/v6d87kYRMHrx+cMRI9b6633sHmzj/zMJvQYjQVD41QcvzvqYU+QoIHn3URIB2NjJZYv1GrWRubOcTXBUMVfiXAKT56U4svkHAfAksQtVvDGA26Lw5xk76MDMiHY+NszL52vvwA4EhVJAHppt2DkH+4CzXpWMZK0zA== 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=dDrw+dat0KEOQL7mAxjwWCqRh7U7Wo63ym/mOs0Ktqxw62jBVueQowzzxHSAZNNfkth1r0Hv+wkNdE7m9T8zoXxKQAoUhG5qjQFXx12qkCCB9svsV1pXKxl6K9Jn88j66rVHLJCzCIpZbowVEO1Icl13yA2zr3VNly+Zjs2S066/+8PTEAk2Q35/89zuXmcOmv7M5X9bGfMjyuogNyR/YFFG3j40c7K17WZkkqSVbvhUpCi73mldykFee+uyMct/WGcU8NnhId3tBesFvOeeErbnYjVgtOOIBFfiW6YPB7NokGjU6l4ALgmIMX0ieW0cSb4JAZMTZYBSOPd+QO/WOg== 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=jqnsXZLlGXUWqxSAO1/wOecpwJy/wWGVaFKGnMIJK1TdZpHbV1JCpNWkMyw7NzZIpqIq95Z0iBrO6gP7ALsHd1qEuyOuWkCx/cQ5GgQ3AH+KJ7/RvJmoH8QXm3zGoEBGZBbVD2UIEQEMG+Y2oZO3+U5MvRcwVE+/X0b02tuWRPE= 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 AM6PR04MB6279.eurprd04.prod.outlook.com (2603:10a6:20b:b7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Tue, 7 Jul 2020 07:50:13 +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.029; Tue, 7 Jul 2020 07:50:13 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, jun.li@nxp.com, Peter Chen Subject: [PATCH v5 9/9] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Date: Tue, 7 Jul 2020 15:49:41 +0800 Message-Id: <20200707074941.28078-10-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707074941.28078-1-peter.chen@nxp.com> References: <20200707074941.28078-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) 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 SG2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:3:17::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 07:50:10 +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: 8b82cf34-616f-4947-12c4-08d8224a6198 X-MS-TrafficTypeDiagnostic: AM6PR04MB6279: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8qZeRMqDTh2Kcuw7O/pXr6ed5EjsVttrZ+PHZdRstmJPIOyJrT1BEi3lAaEghMw8kSYSiY3zeGjtTMJ9lR50zb/4XVcpTZlxwxV1PwPL6VItf57g5YUd9BCJbaixmU9yrchpM8R+Bk/RGeY3GPnzWCbaBP2zJmujyoPgpgoD1dCMHSYwrnBPap+1Ms8rC1mPYrtdRis7nUxVOP4L5hEjvqi9LlU+iQmup5uE9C2dAgdccEeDToikUwFKxIH2M8505G/YhYcULchhNEVzQUV0NAV1MyHW7Eut4j55fr5054hdNNksWXQTNo/mVIaTUQQWvpzMPMVyZ9U+HLOnLItbdQ== 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)(366004)(376002)(396003)(39860400002)(44832011)(26005)(4326008)(6506007)(6666004)(6512007)(36756003)(52116002)(8676002)(2906002)(86362001)(66556008)(66476007)(4744005)(16526019)(8936002)(186003)(478600001)(1076003)(83380400001)(956004)(6486002)(2616005)(66946007)(316002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: swtkO/2idpzgYGP2tdDQZqM9wvmhjrzNPwNjfCZq9BgP6gRS6YmqB7eIlV7ITh5xGipXJuFDVQMIeB7WwqqQGtk3S8jUFAE9uYcqS+DWnCsqaFBcjMbDQGEB4mh7Dfu1OLBZQ0//b8NFVm94P1K88F2VM9804b4pQXttBaJYXM2m8ZxsPpcyIQxBgCYat/wKfHNGNQy/MLuKidbpAXBmRdWi+OjNqzJFHkvqQWz7cn/yL58F0S15Z/273/8Zm/4foYCPYF90tIRSmQDxSCRrkmH0h+nDR0EWXxMr+e6LHlSkEoNIao+8J362zipwK433ZM1NoeNByOdylW4p4YojuCs7pKUxa2IIQ+kTZVJwGRHV2lMiMaVsNRBKaU5ll/cyRzTbqdgsuOnFlPgErarPZJPNptQxz2/NUcxuH/ZiEmlqsF1uudFH2QqZyStdyA2xWm/CsK/+nmjsX8xL7gc4UXVv3DhKW/+W+hGlaR4agIU= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b82cf34-616f-4947-12c4-08d8224a6198 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 07:50:13.4539 (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: 8q16GCXUpd5O8+9p9UI1Hd4bcW+GZllVCs286sN2LZ/LukBBXr0WHHU6H7Zc64DqkcDHBk2DD2LOyeL3CMGAxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB6279 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 Reviewed-by: Pawel Laszczak --- 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, };