From patchwork Sun Oct 9 16:08:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 613713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 602D0C433F5 for ; Sun, 9 Oct 2022 08:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiJIIGM (ORCPT ); Sun, 9 Oct 2022 04:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbiJIIGL (ORCPT ); Sun, 9 Oct 2022 04:06:11 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FFAE2DA85 for ; Sun, 9 Oct 2022 01:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OG4h9a+/crtVxoctOCdS2tNxmdebCSoxnycesDnW6VSBL1oQ1gYk4xih4dJP8ZAy+NJ4BXrDa79jv/drCwnzvGMI0lYRb0zVIur/w6l/4urtklEZMUbDrjo+BXkQPVAWI/so3und0l+YjfIe9kmtlnsNW/zQTAbTwzq8A9i0YMb8jCdtbaoEflnnS2TmBeI3fgXdhbgxVasqh2H6PqVcqVOeZ0tWIgHZQ4CT7X/2diLRPQiTPx1ELVF/pH3yn+Ww0Cibp20OTzEc1C7fzlADoTFwhNkQZfj3+R5Lxvm9JBs5AihgcUHGyqs8hHWuGSkpuEZnTbtEtEbE3HHbfc30hg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0rA4n8dqhFUUYHiRzzHpNbhrYXEcDqPcdWPhRB5q0O0=; b=ZoskruVv/koPRwK/FhiO0zX5IJSEJykapmKssHbPs+VtCmCBX5IAJ+W+9YdhF5C13mewR1nkzoKxxx71kHgipduVqDZlKn6Q9pBBKdQM198Ru8OsptxTAYmu5cMgAdUGltYcF0KqYZXe5SM57vsi2G+MhB5CraTfqQS6WapiM7wNxE4YovZtPDXd2uYKYw2IJjtLE/YLZ5AUanUxO0iwbkdqg+29V7LkgfTIAkBJo3VmlXWI5mmc3nEmewXkGhYdAWh7dNphKgjuRr5UAV9hvOBhvAuya/Ow/QgyPbB7curAfELlliCpyb3yOAOHVLhRPnky4yRLrkfyuvNb3bfUlA== 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=0rA4n8dqhFUUYHiRzzHpNbhrYXEcDqPcdWPhRB5q0O0=; b=lZ5tJuiz9VX5JQMMIb+PHZcl2PfVg+iTa4uvWaoFCdqK9SuNNABHpGouMsfslRPqAXPZWF0z9CmPc4YfyHpuxRpyrbH3z02Flt1DbLHVynH3wBz63kcrDnd2i4s4T2MAjZdLYUOEqAv2TsFFtyThD8Nx5ZUdmVhLoc9WHzQIWg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by PAXPR04MB9230.eurprd04.prod.outlook.com (2603:10a6:102:2bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Sun, 9 Oct 2022 08:06:09 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be%5]) with mapi id 15.20.5676.038; Sun, 9 Oct 2022 08:06:09 +0000 From: Xu Yang To: peter.chen@kernel.org, jun.li@nxp.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH 1/8] usb: chipidea: core: add controller resume support when controller is powered off Date: Mon, 10 Oct 2022 00:08:06 +0800 Message-Id: <20221009160813.776829-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221009160813.776829-1-xu.yang_2@nxp.com> References: <20221009160813.776829-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8784:EE_|PAXPR04MB9230:EE_ X-MS-Office365-Filtering-Correlation-Id: 975aa26d-4659-43c1-ec0e-08daa9cd1fa7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4nT7fjzBqI547Hxr58POM6UgivzJtCA8kL8jzehIvhkKN/KASy1rcXDppx/UlhAiE4/Txqynfgd5IW5NGxqrZkTxwHd5XS9i8MKD64P0BsL77st65Vrv8bLBm1nRbZaQnBc6S25O29gleJtdly9FzmYBzc7HiPX8hWejfvxGW2gezZEN/1Dl1pXMFsSWf5ryuh1QlDx9nigh8A5kwn/2WPM9FGdKA3649ed7H8UboFSie0zBbEBtPbLAexD37Qtqq+dbf+4zt2DfXaBRWCb5fLE25ATtwbORUS1zi6VCr8pDBdBve/h0Vli7zJeBD3aAFW8iS1WZaXj1V812Ob4QReOPO1DnruFrNgLc8ythS5V0LgFE09RfBFeH1PS6jr3y7oFzqidpZHKIw7lK8/riIAxjOLK3kY/3GApfnWYV7qem9gIDdCnk++XaIOKOKQgUWucgfIQt0Qq51YCIuxF8X+hjyQ/fPFJf1V7M1Ot9TtsOf/N+FoUkfeSWuyeGSpYeJDgi3kuB7ooT6de+NoinJanL1LqmmRDx4WouEyU60VTgOS8a/JEnkp8NrqKvOQzGehselCN8Et19IQB91UHeCIf/ciIJhJ6hKnA2Kb1eDFhmXZgiHHKtAYqKg/JU5h3H10Gkq7GNzXSKt2kT8U18h4rsD5SBEdOshqIq/NifYoNorhAs4eNPUmTIraRHcG0tBQ1YCazIhgxdo+E6aSa55Ri77ReBi+fZOzAf8Bz5ab5BEvx81zLhLime3Dl0n5po1vueY7yOiJoO5XsZJBe2eQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(451199015)(6666004)(83380400001)(1076003)(186003)(2616005)(38100700002)(38350700002)(2906002)(8936002)(41300700001)(6486002)(6636002)(26005)(6506007)(52116002)(478600001)(8676002)(66946007)(66556008)(4326008)(5660300002)(316002)(66476007)(36756003)(6512007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LG3Qo6d6s0X9NbPL85/vWQ0jmD+kWAZAEaebfcw8i/cL1ggwQ45glOfRWdsAS/euTZV4R3Hx8S5Xuelodx2SStLZ/ckzr+h92UBq7INKw/IQnxn2b+5JuMoAEY4vBScB5fmhRCePd7Auqq+Ky4dOpPcn4BNdmxZgX5GXpqD9MjKxGf8w2xn1efZGFijVPV/ELPKV+FmwCaJ9aCmVRwpMxhWLMuz5iJAEf5Bv2GEZCJph51Gb4oxXIctIgATNrz9hPd0sSFYuZDSLmuF0J9+oDeu0ais/c3w33qwh+IzT/+DPD9os6cf0r0oXoIWlEMOYyqCEyD012OzsxU1rCzWDYCPaWyhV24iGbUYusaM5vnjHk4/FHXhKnWjYWnYt3m49K4genYiczBM78bQ4O6zZH4aIyVyhP8ZHvHJK7BFI8jxePhDArk/aOJjBzGj5oPjDF1nPloHalnSAO1U7VUK23n+hefQ0eg8jt5XBzqUKsdhaRnepeWLHH1XrtBC339ZBhwsvaXAwXWVUDg7/oWofQVlU34FL3ZKf2AyDoAoKgmbNuNMe380NqIYWxIO7k1w29i1qdjCRc9UVJPBoObsKzICiDtdGaTPfEYwZHMEvkq8hhxaZdSbrkw5zul91fyKyZLSHJy1fjBfraZVO0Ou/32B4WjR36DW6iPGUeApKNFQzRKITTtatBM57OrK79vbJ5IJpbmdOZA67QVnDv4nmopjT19UriBhzLWvX15KiJR5RRoxyesb01BH7YFEVctX66QnmxFsBLe0YNT/95Ped7jxdCWbeJO9R7Xz90SPq5MVhoqn4ahA4fkS5GF3nhsAnVUn6qTPqd/kZBD2m7J8oAWPU9Eu+/3Wg0VZUoclCFA+/hPKby8RoSJuh3AhvxkSdO/Vu5sqcYNX/yeIdrLeZhex4lY2UrV5ve9S/8j1kXb1sC05IlE9guVte9gyTmLy7y4yM0m1hhfDuUELS7e3X1MV1DM1JJQM4ZnalpaY8ZdaW4JsASzsdATUeFPOgnsyeNApzW0qmcuzB0WORCGsJmsjN3/lppP8ODMF9l7MzrlQnsuJ28UKmoe+8vGiVPcNV23q5OgcBshCyMZqekAJUh1BwH9+nbUv1yTF7CfZiPdzeObd0zUZKbewhk3O/8hQu1CzHXpbM2NKN3YscFzl3H1YceegTWZLeS86m/64lWicrpPqtRPLe1kE7Cgf1lNig9b1OBbwSy2CYpT7pIEyKcaWznMpy3ejCUHWG326xgsfhj0K4+mbQwOM90xIzljRo05EEB9Rtli3xUamP9gJCoaG3VVGTE7KFTsG+HKt1T9h2OzfKDmTNUL/H5glrFVofK8b3HENnFqw5p0pd9M2LAiOn5AuZPm1yDna/snFxUn1I4Sb0MfhKSqX6g0cqXWlrYCVvl6IWwwul0ASAsSWdmrK6YcUdrWFfbB1vcH6to1ntzYGijvWRn+Oi/gdh/0mWryuQfrf6Uf0IqWme1AkdwZMlNe+jHwkca459+TVEvziRQ+DHNjToc/tEMejSRsoZ26QbgKYnNwyLc0u5PDMWvicluJ2sV1TviuUt8b2D/mTompRDQmTJSa40et00swsS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 975aa26d-4659-43c1-ec0e-08daa9cd1fa7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2022 08:06:09.2397 (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: we2o86OhQ0nVwPXCX89Q63GYidxEPpJgV6xjrd5GXIRFjEP5bJ70Qk48BfIP4i0h383HWqrtUCm2WiPsM6382g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9230 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For some SoCs, the controler's power will be off during the system suspend, and it needs some recovery operation to let the system back to workable. We add this support in this patch. Signed-off-by: Xu Yang --- drivers/usb/chipidea/core.c | 80 ++++++++++++++++++++++++++++--------- drivers/usb/chipidea/otg.c | 2 +- drivers/usb/chipidea/otg.h | 1 + 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index ae90fee75a32..3a39eb5e7dca 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -637,6 +637,49 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw, return 0; } +static enum ci_role ci_get_role(struct ci_hdrc *ci) +{ + enum ci_role role; + + if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { + if (ci->is_otg) { + role = ci_otg_role(ci); + hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE); + } else { + /* + * If the controller is not OTG capable, but support + * role switch, the defalt role is gadget, and the + * user can switch it through debugfs. + */ + role = CI_ROLE_GADGET; + } + } else { + role = ci->roles[CI_ROLE_HOST] ? CI_ROLE_HOST + : CI_ROLE_GADGET; + } + + return role; +} + +void ci_handle_power_lost(struct ci_hdrc *ci) +{ + enum ci_role role; + + disable_irq_nosync(ci->irq); + if (!ci_otg_is_fsm_mode(ci)) { + role = ci_get_role(ci); + + if (ci->role != role) { + ci_handle_id_switch(ci); + } else if (role == CI_ROLE_GADGET) { + if (ci->is_otg && hw_read_otgsc(ci, OTGSC_BSV)) + usb_gadget_vbus_connect(&ci->gadget); + } + } + + enable_irq(ci->irq); +} + static struct usb_role_switch_desc ci_role_switch = { .set = ci_usb_role_switch_set, .get = ci_usb_role_switch_get, @@ -1134,25 +1177,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) } } - if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { - if (ci->is_otg) { - ci->role = ci_otg_role(ci); - /* Enable ID change irq */ - hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE); - } else { - /* - * If the controller is not OTG capable, but support - * role switch, the defalt role is gadget, and the - * user can switch it through debugfs. - */ - ci->role = CI_ROLE_GADGET; - } - } else { - ci->role = ci->roles[CI_ROLE_HOST] - ? CI_ROLE_HOST - : CI_ROLE_GADGET; - } - + ci->role = ci_get_role(ci); if (!ci_otg_is_fsm_mode(ci)) { /* only update vbus status for peripheral */ if (ci->role == CI_ROLE_GADGET) { @@ -1374,8 +1399,16 @@ static int ci_suspend(struct device *dev) static int ci_resume(struct device *dev) { struct ci_hdrc *ci = dev_get_drvdata(dev); + bool power_lost; int ret; + /* Since ASYNCLISTADDR (host mode) and ENDPTLISTADDR (device + * mode) share the same register address. We can check if + * controller resume from power lost based on this address + * due to this register will be reset after power lost. + */ + power_lost = !hw_read(ci, OP_ENDPTLISTADDR, ~0); + if (device_may_wakeup(dev)) disable_irq_wake(ci->irq); @@ -1383,6 +1416,15 @@ static int ci_resume(struct device *dev) if (ret) return ret; + if (power_lost) { + /* shutdown and re-init for phy */ + ci_usb_phy_exit(ci); + ci_usb_phy_init(ci); + } + + if (power_lost) + ci_handle_power_lost(ci); + if (ci->supports_runtime_pm) { pm_runtime_disable(dev); pm_runtime_set_active(dev); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 7b53274ef966..622c3b68aa1e 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -165,7 +165,7 @@ static int hw_wait_vbus_lower_bsv(struct ci_hdrc *ci) return 0; } -static void ci_handle_id_switch(struct ci_hdrc *ci) +void ci_handle_id_switch(struct ci_hdrc *ci) { enum ci_role role = ci_otg_role(ci); diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h index 5e7a6e571dd2..87629b81e03e 100644 --- a/drivers/usb/chipidea/otg.h +++ b/drivers/usb/chipidea/otg.h @@ -14,6 +14,7 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci); void ci_hdrc_otg_destroy(struct ci_hdrc *ci); enum ci_role ci_otg_role(struct ci_hdrc *ci); void ci_handle_vbus_change(struct ci_hdrc *ci); +void ci_handle_id_switch(struct ci_hdrc *ci); static inline void ci_otg_queue_work(struct ci_hdrc *ci) { disable_irq_nosync(ci->irq); From patchwork Sun Oct 9 16:08:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 613712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D26A7C433FE for ; Sun, 9 Oct 2022 08:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiJIIGS (ORCPT ); Sun, 9 Oct 2022 04:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiJIIGQ (ORCPT ); Sun, 9 Oct 2022 04:06:16 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2044.outbound.protection.outlook.com [40.107.22.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E19112DAB8 for ; Sun, 9 Oct 2022 01:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WKmaHgeifuN9AMzhZfu9NWgfQ9iO7Wbmp+p7w/RfIj54/Oka2NfAESgNgPd86krCln6L/C2x0tWOl7TcTFb3Aiy7k9SaLx6OVxlSef6n26ELOdPtl7KkZG8yRCnXzN8dZsdHsddFY7cJ0lCdkRM9PkzL6464/jTXtKZl+ByFVuSy9snNTt2+EIlgdVPiWpr91L6Z0cO4cIPbitkFAeTpzzOyCY74qFK52YXTfbt0pbNHnE2JqDSYZQfzXrlfriYtMHmGzlRrO9q5nycVo+5Y+oOxAziLbYxN3uQwjvuFkRUnaD2oIJ5gWYEnyDOyIhNzvUdqi76MdpQA6SK4hN+awQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kQecZ+QavLsvC2E9wmm4WoqEGk1erl6dZJFaCV3rQCY=; b=djstzdiwbkzgZA3+nQ1tLr3+htfBYK+Jc09I/6ekfGcswutgcEofzxDHmNoUb5sn3qDPO8Q3lboFQXvuIhsjhZi9eRRaZiW0Yuen+O183WckNUE9Jgr9UUw/73UtNFJmlU/0YzUYfhS5wMZoqfvEpuCTzomUvFheL8V4jCnZURYIE1PAfLcO4gpEB3+VJ4XvtHB6xdVWZKJdSsElcoQyjUqh7f4WT703q+kp1rbjznhsOBoxALb1T95d01CKUqqOzvCGmhLahXpYvQCVeIbvehiiGYdnTv2nv5F9XDopRujAUE6naelymHFl90YCSRaxhggQEuh6YWk0u3m3bzOC5A== 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=kQecZ+QavLsvC2E9wmm4WoqEGk1erl6dZJFaCV3rQCY=; b=I9fCRB+f5jQz4hNUDJSLtSiOXI+H8u0J+0lStlrUTcvXFiC1n9QyxGiYqX86a+dLHcuSI4D/T2eU85f/3b1O0/7qaqSrJJtMPjXq38T5v7UzOVbmEkfSMeaEvj00DnsiaAVBvSFwjNtmtPfUsdUuKCxyoPWe6cUd6Dkt3LDTYP4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by PAXPR04MB9230.eurprd04.prod.outlook.com (2603:10a6:102:2bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Sun, 9 Oct 2022 08:06:13 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be%5]) with mapi id 15.20.5676.038; Sun, 9 Oct 2022 08:06:13 +0000 From: Xu Yang To: peter.chen@kernel.org, jun.li@nxp.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH 3/8] usb: chipidea: host: add suspend/resume support for host controller Date: Mon, 10 Oct 2022 00:08:08 +0800 Message-Id: <20221009160813.776829-4-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221009160813.776829-1-xu.yang_2@nxp.com> References: <20221009160813.776829-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8784:EE_|PAXPR04MB9230:EE_ X-MS-Office365-Filtering-Correlation-Id: f9f141cb-9e52-4c8b-ed8b-08daa9cd220c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QHR2GphwroWfm280bMHaYL3MzJfMH1JCYJZQ18vOYPWval1lZWhrgF+sB7oFmsRLOTNpLDEqmnRJzkXzaqKmCV046a0sSEiaQmUxf2HVHRYYf9nzOwE49J+fdXj/xOP6Vzw0AmjZJK80wkgz8u0+k6yFV0Zx2qMLkrFa4oCZJ8rth9Xqbs/ZhALHB99caIqMeeP1ky5OO15TlM+Bx77qrkb/w8ncfVMSClzU7lOQ/+EY/Y6cfEIABmxtIdq1/HIv9vM7Cl8uKnkPrbdzzr7NT6jJzyJBv/Nxtq2SJRSZx9DvMLWvlOCUHiSM33AOjgadi26fMh3i8jlbH57oMxDzrzfYi/l7wA8jTT4NcvEqjeW6RjkbioRysHAemIPWl4uhWEOeukVPIPYzFFp5oQdEx+rdDoJaNyMwRNv/hPnj+Z8ZxVhPHC7BafNkDJ8ilFoumbbLmMX3fX87GQzpkshTG8vLWAHehAi3HCxE9hLaV51jBCBU+01uCHaTxjzYauP2G0nYFgnI20xvyl7a67fb06b/ew65VieS/5FlZG6gResHSV06Cf36It+6T6eUvg0tIzyJVuJZgo/ORLjAbRelKrN2RcLCK412VAl+VU3JgoKjuMRM6fVi2jr9O98NaRwflc/nmwqJt7PgILwwaKrGxhhZkXKZPCqxHuLdLPTn1d35nWmH7gLaHovjQeugqSErbdNyBfzicJCMcauvuB+doj6KN69umxIWXuMjtRDnBF0rNywKBoj8+Zo0lMZM2FHgUbT788Vo+M5BoDSByXawlA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(451199015)(6666004)(83380400001)(1076003)(186003)(2616005)(38100700002)(38350700002)(2906002)(8936002)(41300700001)(6486002)(6636002)(26005)(6506007)(52116002)(478600001)(8676002)(15650500001)(66946007)(66556008)(4326008)(5660300002)(316002)(66476007)(36756003)(6512007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qdk7b5ZtpM2fsqnLZ5YbKEKnczCS48yYXuiXY6yALRs3rFbxTQ5NJpE3G43kF59lKUA8486jyecW2plzETZS+hJ6E1WlWeQONxct2c+b8KxlBfWJZOKd5ZpXF3oqVf45DBoOBSGJQguMA2RXckKd2xnBhXx+Es2PCqn9JqMYyk4K1nLXYNwqjVEGY4PGDmBCp7puG6yPdysgQ4zhe+tH4idWQx4rh5j1XgD7HjM3HGA6P/xlpCgWX3RFCg/fekyTuYAirn6j2xhaWYm4nOknnajIakB/wfAXHGLb63gctky2xxXHYWOuNh/7o0r4ClJGZRU9c3MA69sqyIKm95L7W25zQJSEtJ1uorLgT30yQYDLEViE/joXBV+IUId7QX8Bve8qqSI++Ymq97/T3ODlWcnLj2RTNbdbXeF+Z2aVN63ie9yNLJOpMsQ9D1CSBJAJCDm22ymVkAKgx5tTe/5yWREhQUE+Obx8TVnJZnUSFvCcUjf6HzoyxZXHWXjXIY/bfTZKlSzMqRriieg8MUMEK9tkx77vNmgyTJsTf/dmPgYdsnDF9VHP7McyQPPKy/Tw+9CgBUFXV9v3R+fIaYWHfVGwYHnsuIkEXLoQj1V+8c4xctihhWP/3/FQvhiZxfJmSpywRJ+I2KwudfXpAZuiE9z1zAMSVHmDYG5I1XkiRZwilSUhA9QJdAiLu8K8h8EpaccBIdeULHZOP1Dezz4VS2YzUYcSBc+J7632Upv4nKOfNR1ta2bivBPd8zJCI44gf+BRtOuvOiddvamqGaVk3MQcOwyqNj3ugLIsv25g822wA2C1B9ucdQnHYiioAAIl0FT4bZ00no1BD51N1eZTj2xfAKocgCvZSLGkgRQVzpwwPMsA8j/oFjoCs9Hinh6tnQUaHS0lPx70iSUsKxniPzUaI2cMGWBzC0rGXbLJ/xmROuzE5GDxeQrd1nsGNwMyQ/ECq3xCubQ4FIKFU0QAn/AHuGu5oAD12LHxYMdNKqnRvJLbiiEgEC5S33ZUY0zdPUv6teT3tQ4UPIajdN9cOk5hK1/hDsuR0o+IsLfp7cn/8P6kgxpF/yNr7gMhU6bDS0vbNuqG9aYFvbbT2iYjD7pTKfJ+m96vHFpXEHplg4qZJEk29Ttd19tMjxkGxH4b4nWyggOF49TiLiNTk7ONPM3Wj+Ee74nYAHZ75xwxeUaHKbDqtA+OEJlKiDujEkgxr6RIB26rj29jYYctkbRGePqDxnelvTIoANelR233FahvqHlgefAJrF57bCvLgGS8Op9KKHYg8YaESprgWktsBY7RzJn2b6/7KLCl5cd+YsxlZYRTS8Hl1LaspBqWE17ZywIq+AfHM4etHb62ODC/Q19e1DSnxjDZx+rRNdpxtUeD1Qi5DnCcbff6wFpz4sG5vrtVJ9RLQuxrAeecuefvpa89bPO4g5+2a0CObQVgARWUoULI0o0UtqQAgkauPyRxumPS3dP5GnF2Be6H1Bxio9teDVjD61q+PVRYvszn1GO3+ElT8bqI7QE9g1uqrARPWqf7UGODJ/B5SIRqdPBIgbOmb1m/93+yqWjbJxEf874EE4et8FVz9AjvIYPcgQib X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9f141cb-9e52-4c8b-ed8b-08daa9cd220c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2022 08:06:13.3663 (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: 6hYvxtoRlnKa3wTdIqcpBr/DUqwAFQI2gwPwIJKxNEXNRH0MfW1BKs3jQDTN2OK/Ny91Qxppu7Ss3PKhg3TpIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9230 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The controller's power may be powered off during system suspend. This will add suspend/resume support when the controller suffers power lost. Signed-off-by: Xu Yang --- drivers/usb/chipidea/host.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index bc3634a54c6b..dc033272c31e 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -459,6 +459,16 @@ static void ci_hdrc_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) ci_hdrc_free_dma_aligned_buffer(urb); } +static void ci_hdrc_host_suspend(struct ci_hdrc *ci) +{ + ehci_suspend(ci->hcd, device_may_wakeup(ci->dev)); +} + +static void ci_hdrc_host_resume(struct ci_hdrc *ci, bool power_lost) +{ + ehci_resume(ci->hcd, power_lost); +} + int ci_hdrc_host_init(struct ci_hdrc *ci) { struct ci_role_driver *rdrv; @@ -472,6 +482,8 @@ int ci_hdrc_host_init(struct ci_hdrc *ci) rdrv->start = host_start; rdrv->stop = host_stop; + rdrv->suspend = ci_hdrc_host_suspend; + rdrv->resume = ci_hdrc_host_resume; rdrv->irq = host_irq; rdrv->name = "host"; ci->roles[CI_ROLE_HOST] = rdrv; From patchwork Sun Oct 9 16:08:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 613711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F77FC433FE for ; Sun, 9 Oct 2022 08:06:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbiJIIGX (ORCPT ); Sun, 9 Oct 2022 04:06:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbiJIIGV (ORCPT ); Sun, 9 Oct 2022 04:06:21 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130045.outbound.protection.outlook.com [40.107.13.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 129372DAB8 for ; Sun, 9 Oct 2022 01:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cv3+vHeXhZ/tO10O3MluCRksN/aRK7Y18NIArx/x7e1SSMos29ZYTHRot8kZZyhisuPdATLLakfsPeGSHSHIvlWNauWaXKLoqnXiWpSIrPViMlEhjo4SKGpNN8PU3NvgzfNg1+5MRzrsJPbylN0558otAjCtcg9HKwuoOvjFpT/znUnifjX2oLpqhViYPijogVUyWk19gH686LMxsJZeij31ELqmogWr7NA8+MCdxlzrrxIRr+aKbe0m0cHtkp33+Dy/aoIUaORxHCIRgVVgtO+4ssQKU//L09A4jHWmcqGlE6jVdyJDRhyfFeq0NfVO7jvg18hEr/DSRe7rKiN8vA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fe1+fzF2G0R1BSDzV2fQ4urwwMKeWjCV+6+VrDv45Ho=; b=DlFI9xs+ij4+2PRcjH1OqI1SwUi9h7dcK2ctr4I4nFop3Em+jYA2WzEw/Ib9y57CPTQsoUOKw1ya2WxuaZLtSUbHe32XHra/B0SoSE7LxjEXzr2JpDITWkSL2AhcbDk8Pv8NrN+yc4o0pLyntYpUfyGA26n0/To1ej8HIEpAn5axbHHaZpiMF4cD/x1zBU9g1iUkDKW/wAVIxXyFDkOxMFPSgEDci/6rc5DnH1DAlVyAuQmBQWNWezdqgraOjepMlEcy46Z1zlI/sOut7BzQ41qmLCgZPyreqBsXVUvwgGUwGLiJpd7PALYMUH1x+hl/iUlIni9RfBTCiD80DvppgA== 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=Fe1+fzF2G0R1BSDzV2fQ4urwwMKeWjCV+6+VrDv45Ho=; b=gbcslHcmrefrLFCkW0S+4frX9HAca4VX0wCC50koTaWFUcoA9WHQOWuD7S01t5cZwxLT0wJdYKZy9RwfMQp9zMK2DPwnFGi2MAfgv9sudZR7R6JsCMyt6UHTli80YIbhqtGZNx8dt+OQdvjOIP800dmBQooXhxmnM5ZM7JJ2Fds= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by PAXPR04MB9230.eurprd04.prod.outlook.com (2603:10a6:102:2bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Sun, 9 Oct 2022 08:06:17 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be%5]) with mapi id 15.20.5676.038; Sun, 9 Oct 2022 08:06:17 +0000 From: Xu Yang To: peter.chen@kernel.org, jun.li@nxp.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH 5/8] usb: chipidea: usbmisc: group usbmisc operations for PM Date: Mon, 10 Oct 2022 00:08:10 +0800 Message-Id: <20221009160813.776829-6-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221009160813.776829-1-xu.yang_2@nxp.com> References: <20221009160813.776829-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8784:EE_|PAXPR04MB9230:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c4690d5-9e89-4ed0-c3fb-08daa9cd2472 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F+IZy1uRJq98+2aiwKLybXkqGsl80IU0Vu33TnrCUm9h3at6opEwlMo/st95jbhCVELDzJxwgfNhmB2iUPAACBs231qa27UCr1aB9ZL5zFOrTeefBND2QpvELx7xxJXlcHfaq0NIydL5oVnpknVCT28j8yrA2YYhKplZchealK8g18l3dAKzfcv8j+pgdxvkrV8/wzZtE/QFzBxcxfkL9qj17bpSpzz/LCHoAW25F3wqPr19qjx7dEj/Wq3RLom9tlCdFwOwNvVLdf1cb4Cnl79l0DQJKo1ODkcFQvHHQ2Ld9yeAWk9IU9k1zl2wKzZQTWZjcDlogxiK5J1qyye84syoY5byNRJJkrY5PRNVe0aTEZRGJ8upnD2+fafBmSu74LAaN65Mhyb0/9b9BraeXkiT5qpQlS9ofAGFdZB6K4t9LY7nvMZhDUyJ0fs4BzqwK3APRSfjeL5g9uak/o2fdwLg6E0Ar/o9dLdjFEj5+86q9Al0AD8DcCMx0aOxIUmrXo59fW5xiO3QKCI65I6ovVSAsWF0jjA6G7h8W6+n4D+jv53rZRZecJVxn9qFOZzrZYrdrjtg6AuPhLI1lM/vCx8ie8VNlSGGINhSLkagY0+nDx9ntboCIi5UcTainF6A/bdFJ3n/JLE0MehL4CumisGFbLU9v0xNxU4/886CebeBclbj8c0s6uclOCTM1z1zrFl8u4F5kM7fA7JpLnE2W+5gbcg6CbW/6pwOjiKJ/Rtnx5fWc4MeZ2u+Zy3YvtMHTvu2Ve41apcO11mVeeIqVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(451199015)(6666004)(83380400001)(1076003)(186003)(2616005)(38100700002)(38350700002)(2906002)(8936002)(41300700001)(6486002)(6636002)(26005)(6506007)(52116002)(478600001)(8676002)(66946007)(66556008)(4326008)(5660300002)(316002)(66476007)(36756003)(6512007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zbFqlnp1izYTThv3+rl3FhQP2nCva/B0qBAGMQvHzxbY72LfHqMCn7vJgt7H2toV17thOLicjRurJZKwiAP5IlzpnrIVQ1zPejs2ZROqgLTgrSXSinoWtUw4P8am79EvFUsfEEN44YzR/HRoLR/4ejUWK+fvhIECJ2jCtcZTuHGmtVs7qK7F4fQSrryWddNhYkR4dcka8dRqWGfQVyPj640F1kpQarbF18JZQGOnQrqL7Q6SK1nPDoryJyk84jTkh16wZx7/Kh21Abx88PmrrRwrhj3WHlnVlIu7UV39GG1zP2FfPwXV6kL3za6nbC6w1H9MXBj8U5gVoeL94EBxj/jokVrQ3c75TfEcPYn1g548M5NPsx9Hd5YNqMRpYBx3f5TdUJtsQ5e8gLRyXijGnTdx8wbib3To9vS7S/KWhAS0brspoUoUKtpmNIFk7Yn/Wxc1SAZItybvHoeFcyhrXIrte6lKF9TnZoRKwrjpJ7bBgGXma/N9HJjNRF0ZN1dkXb9j23Gvjc8ovcK+xPdZYFiOlUnTKkRDNYMTNcJ/FeG9W6svb1Pjj/Oi67nyncDF7yeiI7/YN0Wspa+G1Ys19N6bQPhofTecTqRXbFMyyw2TvAFc5aay1Gn4zDgieVpNGwla4ZDFSeJlclyJUClX1PYgo7t5JCt08Da5CNIX0BNH28VBignUBjAo8V/mpIEnMmpGy5C3M5/qB1jzLQ3CKd5BzDJ8QUT9EXg9LDmIw8fhDM9V6YLKoWVfr4Z0p3+KDN5KnahkIGfR/+SfAhTAlXhBxoCDhh9WNHV5NhorY1yX6PLR+WnOu18UZ/oBB8kF0XUJDMK/AK34TBLyFJbBRWNsfGZMP6twhKUkdrcLW738J6sA6ynvTyJf/qpNdSw/OCqzvVavGoldwNS9+IopJjonKxDAziAeGrbj5zjFItZeN9KejAe9Fo4kLR5a69zk5YsC8HWeViRWJDUpb0pBzTw5UQ8Rk9u+G1smS++em/nVJp/a3lZ3n2p2MdiLQnoojouGoCiHmf2x69ys7794KCelfmt045Um+rLU/oewTRw67kSftyTTYLTxIhXsiB7A0ojhnL4QwPGcW0MTXfSGjrcYj5y1tqb2IREieHi+TjHyYPM7Vk3/K6fqXa9FGDJNJP3BAd2cOAkTb5L/Q2vfaR0O6Kz6If2/4YxtfyLWgDX4ihX0l9wS/Flq3xsb4yGBX5JCIohV5D0l9bwuQ2vGND1XbU4gPVA+iUr3qmYvXQmaxRJaIrPODMVmmrMXCtR+DhPTyjo1uuYMRVDBM3jOoIag/2TFhHX4Y6ytOD36pTDYOyKHnSxI/znzkMiK7LNaCm2iFIoHKfk1Ttp2PZQmwgBDzcwH9PXsPWNxKDd0QPRyakVM+OR13V4HPMMV8RSpGKnG2ElPYc9pFCBJ5nXz+TIn4ZmXyB/u/4Dmhgk8+cIkkeO1DmhsM058zuPbEisB05oEyz4XKYdC/TUANMxDXUQKltM9vvI57++Hq58D9RH7g+kudFKvU4Sy+wrB2Jbd1ZXTFyXmqpbfaTG1jfy3W5lootYLN3AqR/XSitRsyKqS1JitidUD7bDL3bUX6Pq9 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c4690d5-9e89-4ed0-c3fb-08daa9cd2472 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2022 08:06:17.4205 (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: yhexnnFHFr73YMqExBqTEDHQCbOoNkaBY3bkzz0XA0jUQWuSOl2z0PG3erx98yp3A3kw8JIGQ8Z3L7IZVKqBqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9230 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Li Jun As there maybe more APIs of usbmisc for suspend and resume, group them into imx_usbmisc_suspend/resume. Besides, introduced .power_lost_check API, so that proper resume operations can be performed in power lost case. Signed-off-by: Li Jun --- drivers/usb/chipidea/ci_hdrc_imx.c | 49 ++++-------- drivers/usb/chipidea/ci_hdrc_imx.h | 4 +- drivers/usb/chipidea/usbmisc_imx.c | 119 +++++++++++++++++++++-------- 3 files changed, 106 insertions(+), 66 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 9ffcecd3058c..923f5c00a1d9 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -527,16 +527,19 @@ static void ci_hdrc_imx_shutdown(struct platform_device *pdev) ci_hdrc_imx_remove(pdev); } -static int __maybe_unused imx_controller_suspend(struct device *dev) +static int __maybe_unused imx_controller_suspend(struct device *dev, + pm_message_t msg) { struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); int ret = 0; dev_dbg(dev, "at %s\n", __func__); - ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, false); + ret = imx_usbmisc_suspend(data->usbmisc_data, + PMSG_IS_AUTO(msg) || device_may_wakeup(dev)); if (ret) { - dev_err(dev, "usbmisc hsic_set_clk failed, ret=%d\n", ret); + dev_err(dev, + "usbmisc suspend failed, ret=%d\n", ret); return ret; } @@ -549,7 +552,8 @@ static int __maybe_unused imx_controller_suspend(struct device *dev) return 0; } -static int __maybe_unused imx_controller_resume(struct device *dev) +static int __maybe_unused imx_controller_resume(struct device *dev, + pm_message_t msg) { struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); int ret = 0; @@ -570,22 +574,15 @@ static int __maybe_unused imx_controller_resume(struct device *dev) data->in_lpm = false; - ret = imx_usbmisc_set_wakeup(data->usbmisc_data, false); + ret = imx_usbmisc_resume(data->usbmisc_data, + PMSG_IS_AUTO(msg) || device_may_wakeup(dev)); if (ret) { - dev_err(dev, "usbmisc set_wakeup failed, ret=%d\n", ret); + dev_err(dev, "usbmisc resume failed, ret=%d\n", ret); goto clk_disable; } - ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, true); - if (ret) { - dev_err(dev, "usbmisc hsic_set_clk failed, ret=%d\n", ret); - goto hsic_set_clk_fail; - } - return 0; -hsic_set_clk_fail: - imx_usbmisc_set_wakeup(data->usbmisc_data, true); clk_disable: imx_disable_unprepare_clks(dev); return ret; @@ -601,16 +598,7 @@ static int __maybe_unused ci_hdrc_imx_suspend(struct device *dev) /* The core's suspend doesn't run */ return 0; - if (device_may_wakeup(dev)) { - ret = imx_usbmisc_set_wakeup(data->usbmisc_data, true); - if (ret) { - dev_err(dev, "usbmisc set_wakeup failed, ret=%d\n", - ret); - return ret; - } - } - - ret = imx_controller_suspend(dev); + ret = imx_controller_suspend(dev, PMSG_SUSPEND); if (ret) return ret; @@ -624,7 +612,7 @@ static int __maybe_unused ci_hdrc_imx_resume(struct device *dev) int ret; pinctrl_pm_select_default_state(dev); - ret = imx_controller_resume(dev); + ret = imx_controller_resume(dev, PMSG_RESUME); if (!ret && data->supports_runtime_pm) { pm_runtime_disable(dev); pm_runtime_set_active(dev); @@ -637,25 +625,18 @@ static int __maybe_unused ci_hdrc_imx_resume(struct device *dev) static int __maybe_unused ci_hdrc_imx_runtime_suspend(struct device *dev) { struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); - int ret; if (data->in_lpm) { WARN_ON(1); return 0; } - ret = imx_usbmisc_set_wakeup(data->usbmisc_data, true); - if (ret) { - dev_err(dev, "usbmisc set_wakeup failed, ret=%d\n", ret); - return ret; - } - - return imx_controller_suspend(dev); + return imx_controller_suspend(dev, PMSG_AUTO_SUSPEND); } static int __maybe_unused ci_hdrc_imx_runtime_resume(struct device *dev) { - return imx_controller_resume(dev); + return imx_controller_resume(dev, PMSG_AUTO_RESUME); } static const struct dev_pm_ops ci_hdrc_imx_pm_ops = { diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 7daccb9c5006..7135b9a5d913 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -32,9 +32,9 @@ struct imx_usbmisc_data { int imx_usbmisc_init(struct imx_usbmisc_data *data); int imx_usbmisc_init_post(struct imx_usbmisc_data *data); -int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled); int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data); -int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on); int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect); +int imx_usbmisc_suspend(struct imx_usbmisc_data *data, bool wakeup); +int imx_usbmisc_resume(struct imx_usbmisc_data *data, bool wakeup); #endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */ diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index bac0f5458cab..aa815f6d3fe9 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -150,6 +150,8 @@ struct usbmisc_ops { int (*hsic_set_clk)(struct imx_usbmisc_data *data, bool enabled); /* usb charger detection */ int (*charger_detection)(struct imx_usbmisc_data *data); + /* It's called when system resume from usb power lost */ + int (*power_lost_check)(struct imx_usbmisc_data *data); }; struct imx_usbmisc { @@ -1009,30 +1011,29 @@ EXPORT_SYMBOL_GPL(imx_usbmisc_init); int imx_usbmisc_init_post(struct imx_usbmisc_data *data) { struct imx_usbmisc *usbmisc; + int ret = 0; if (!data) return 0; usbmisc = dev_get_drvdata(data->dev); - if (!usbmisc->ops->post) - return 0; - return usbmisc->ops->post(data); -} -EXPORT_SYMBOL_GPL(imx_usbmisc_init_post); - -int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled) -{ - struct imx_usbmisc *usbmisc; + if (usbmisc->ops->post) + ret = usbmisc->ops->post(data); + if (ret) { + dev_err(data->dev, "post init failed, ret=%d\n", ret); + return ret; + } - if (!data) - return 0; + if (usbmisc->ops->set_wakeup) + ret = usbmisc->ops->set_wakeup(data, false); + if (ret) { + dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); + return ret; + } - usbmisc = dev_get_drvdata(data->dev); - if (!usbmisc->ops->set_wakeup) - return 0; - return usbmisc->ops->set_wakeup(data, enabled); + return 0; } -EXPORT_SYMBOL_GPL(imx_usbmisc_set_wakeup); +EXPORT_SYMBOL_GPL(imx_usbmisc_init_post); int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data) { @@ -1048,20 +1049,6 @@ int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data) } EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_connect); -int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on) -{ - struct imx_usbmisc *usbmisc; - - if (!data) - return 0; - - usbmisc = dev_get_drvdata(data->dev); - if (!usbmisc->ops->hsic_set_clk || !data->hsic) - return 0; - return usbmisc->ops->hsic_set_clk(data, on); -} -EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_clk); - int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect) { struct imx_usbmisc *usbmisc; @@ -1094,6 +1081,78 @@ int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect) } EXPORT_SYMBOL_GPL(imx_usbmisc_charger_detection); +int imx_usbmisc_suspend(struct imx_usbmisc_data *data, bool wakeup) +{ + struct imx_usbmisc *usbmisc; + int ret = 0; + + if (!data) + return 0; + + usbmisc = dev_get_drvdata(data->dev); + + if (wakeup && usbmisc->ops->set_wakeup) + ret = usbmisc->ops->set_wakeup(data, true); + if (ret) { + dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); + return ret; + } + + if (usbmisc->ops->hsic_set_clk && data->hsic) + ret = usbmisc->ops->hsic_set_clk(data, false); + if (ret) { + dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); + return ret; + } + + return ret; +} +EXPORT_SYMBOL_GPL(imx_usbmisc_suspend); + +int imx_usbmisc_resume(struct imx_usbmisc_data *data, bool wakeup) +{ + struct imx_usbmisc *usbmisc; + int ret = 0; + + if (!data) + return 0; + + usbmisc = dev_get_drvdata(data->dev); + + if (usbmisc->ops->power_lost_check) + ret = usbmisc->ops->power_lost_check(data); + if (ret > 0) { + /* re-init if resume from power lost */ + ret = imx_usbmisc_init(data); + if (ret) { + dev_err(data->dev, "re-init failed, ret=%d\n", ret); + return ret; + } + } + + if (wakeup && usbmisc->ops->set_wakeup) + ret = usbmisc->ops->set_wakeup(data, false); + if (ret) { + dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); + return ret; + } + + if (usbmisc->ops->hsic_set_clk && data->hsic) + ret = usbmisc->ops->hsic_set_clk(data, true); + if (ret) { + dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); + goto hsic_set_clk_fail; + } + + return 0; + +hsic_set_clk_fail: + if (wakeup && usbmisc->ops->set_wakeup) + usbmisc->ops->set_wakeup(data, true); + return ret; +} +EXPORT_SYMBOL_GPL(imx_usbmisc_resume); + static const struct of_device_id usbmisc_imx_dt_ids[] = { { .compatible = "fsl,imx25-usbmisc", From patchwork Sun Oct 9 16:08:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 613710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E79DAC4332F for ; Sun, 9 Oct 2022 08:06:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbiJIIGZ (ORCPT ); Sun, 9 Oct 2022 04:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbiJIIGY (ORCPT ); Sun, 9 Oct 2022 04:06:24 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130045.outbound.protection.outlook.com [40.107.13.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E81462FFEB for ; Sun, 9 Oct 2022 01:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cXuxaHMFzUt9NoWe937D7a7xd14YxVVoDQZ0SBEmdFWD66Tdz/lz+lpFZLMAU+EX5gJ95ig/xN21FZA/btEGi7sjeb9nh3mlG/437yKdHM03gnA2KIJylyIGDxIHzXEwJZwYCsjYdsbQHsc8CUI7pr3qkbW1Ee74FyuZpJkNeRgzEEaRboNllghcVymaEPl5OhyNGgWbj/aB2MhGyX0uiCauj0KsCPdk44Fiz2QhLj4Eh+lRDSwNAJxhanXvhcQvrpyrunxubrl5/7yLjwGd4TsU9ZGsjeHGM6G9YpqBg3Y/fQWq1n0YyttuJ7rUg/sUp7KS2JeWw1gG7PALbvpQ3w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LvXeKr2ceXCzuvEixjECUy8mpp9kLD9jjrYqFaVY9PE=; b=M4/riFjuCBD91CeThYUszy1YPPevXcBfKMIt7I9UMhjWQPHZ1ZLfEs6jPZqAkEqPoiiwOw737vasAPvo9fuwSe1Ift5szVA3IL107joPDKs0sBzS/lWisLSHZCDko0c8rRM8Ygbucoa9Y2v3Cabv4jXzUKj8PMVLeextGtJyGWv0IWZ3AGQ5lCjEu5kRLq1B5xYyopXY41LjWaU+P0I0uSohaN2tBD3y/Blm7rD7wCbomGtpgw/SyhxfdTeUEVfD32FVj3gufwRb0sxIeVkOG/hzffAVKuGkQyaj/IfxnztjhOIS1vFiYyZFhE0ByymgZ59Kbsdgl2bWWgrTuZ9fGg== 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=LvXeKr2ceXCzuvEixjECUy8mpp9kLD9jjrYqFaVY9PE=; b=MpPxoqMs27izXfZZp7ButHON9aYVuS46sY1UYAOw/VXUPFaw587iu3sUZuHVIBVo72EYCM/pBuL2/y86syGk480OoIpKf5w5y66Ak1G1H+4FMWGGldR0v3RsBNEc50EKxH3/TAYjfHAJE+zetx6MQLZkrwYxWDTnXfhCiH1edP8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by PAXPR04MB9230.eurprd04.prod.outlook.com (2603:10a6:102:2bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Sun, 9 Oct 2022 08:06:21 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::e9a7:fdfd:e80e:c6be%5]) with mapi id 15.20.5676.038; Sun, 9 Oct 2022 08:06:21 +0000 From: Xu Yang To: peter.chen@kernel.org, jun.li@nxp.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH 7/8] usb: chipidea: usbmisc: add power lost check for imx7d Date: Mon, 10 Oct 2022 00:08:12 +0800 Message-Id: <20221009160813.776829-8-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221009160813.776829-1-xu.yang_2@nxp.com> References: <20221009160813.776829-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8784:EE_|PAXPR04MB9230:EE_ X-MS-Office365-Filtering-Correlation-Id: fe6b552d-12a0-48e7-2193-08daa9cd26e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NrWy9EQ15tuCG23ZQkmYusmoNAsRf8B5QdAS2/tHECt6UWEiiyXY3Nqt/FZtbiTn9za+uEsaWWjne17p+iPVx7Sad4RgFLUzcep00/FcuZpcTF7p+t2dUu6swMbcy++x9qltRvxxNdB1RcPgLIM6EbC4w8qft/85nsCnDOpNMBuW1FfJD19BS+o/xvdI6vyH+IXfmfnuw3Cn7WyLmb9N6xTrZ60cvhLbSmTJKmSVuAlTKxaKymcZ8z/xECzYYmLDIqJZadV1W6nUjNOJW8RsrRu1d4Aj9XpuFnosmK3BhzRhT2pX4pcdy8QOcammBght4pjxy06mToEKVWX6GlQYMxab4iEPoXCeOHFgk8EbZgFzEpa5dflVopy1+doLN5PnUMRiN4eXw5lM9zbkYwK21ZOYhBqkxc7m1c1ZmOBoT8u26m8xP7/RnwcHiJ35dEfzjZmKxA2yXZMqlCc7Bh8fU9i1+uxqFEH6mjydy/HqC788wIWz/No8/nqtuGgWktmXAbgmsL0edV5ZV6zRBdKd4KjK8OwN0rEUd3yNTgHSlR5uL0+/zfR7ff4eNEkSMS0n5p3Gn86IadW4lqb7EggzeMxUdGNzA0LP5E5FPEOMsngG/FElj5oSCBm8+x++VN1a0TxPtsPL7QWGZJuw0nuCDgLgBhGLiTGo2bivc4I12eu1U/oFE8DKtB/KBIFWUhYXddaxKT23glyMlcEBGpRPPuJBn1XKZ5ZtvljwsHMjjKK8EtzftgwFqOz4F/hE2gAjvxAl7m5D/r6L9F+6doDS+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(451199015)(6666004)(83380400001)(1076003)(186003)(2616005)(38100700002)(38350700002)(2906002)(8936002)(41300700001)(6486002)(6636002)(26005)(6506007)(52116002)(478600001)(8676002)(66946007)(66556008)(4326008)(5660300002)(316002)(66476007)(36756003)(6512007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fkYL4q+1BW30B4BBU1v4ik5QKQ8R8LpDk/NHJU5Lzk/1mnwVBgb6DXgcbuYFhpMEdLFpgH2onu2GTlygsE/gNzh9aWed/OhEYiSoddwnoWu/BCvWfOVKMzTL0SJ98qfJ7sUL71vLI6arAg4AzAtyKuWm69o5aPyK4uVLdb5t6TnwY/SB0kGII/RrVcRrO7EU8GL+EuPTHStpZz/fUrMnIiIlxhHiE53Xj21OOWfd9dxuChVdtvWBalXodHQV91B7vn3SRMoSBxOrugs6nEe/7kpgpHttJbV10bdPvGIXc4Zzo/voOhKCH3vRGiyLOtRlfRbP7/2O/MVFxW9pJIT3u2LsINn0dWa6erMjUur8NneLA+qNJ5WjKxaKzSf3xJflnti6+e5Pmw/5ZC0ykSgBDcSXc6fFLEgArJOhaHwCZAdKloJldVDyzUge+X+B0+IfGs8zpbXGC167UVQwhJzKO/AlnK431RNRR+EvQryigotOoTepPDm+Ivb+5z5oEFHtqTv+/MIk59M4G+xYmXk1srw5ogAylWkuU7qjHgLEs+jMYOfa5WhwTHBsI3bWTNFcdNekKV9ZG2Do8FIotT8cfBeC4iAMJfDFvd+RvONYTc28nSSnzIMLcuGRxZFLLYJX+5pVU8OOGE6GSnqEjpP89Yp2Xx6xg6aFuF082JyVzGKZ0g9Ih76y2jPzcI4b6hJWMsNGL0Rkx5LNIlyGqRu+ZB3cXdHumocQISa1V8CRGtI9qy60JdVylWzBW/vT/aGI06RQY9xB0n7fhoFCyh/fuVh3tSJZDXSd3baDxGxbRi/4idLJZlSWXieB3kAdSW390cOy8HLil+MjUQFTpCXDwHAyVEYWJj9VQy0SND/XmWBhyet+6CAdobN7Ce47/j7ZAU1Vq9qCfebOHRq4GydgwKzDAbkzWm6+ubrvbbuffFHF57ScqMpP5wIXikx7Zlubp9WxSkA9iTi2eLSH2a7T5Am/1RtwG9tluHl0sOdvT43TXKKrINKVhQTFXkrbLAvCR+39f9tN4QkUt6ctwKbrPkTWbpIrKn4iqNOMtuIPMAyGKGqtUYZYE4jKN7IkYzsZ0rtCur6TVHYyReKaGRN11xbvHh4GW1SCDRWbaP1eJ25JKB+jYn+sLbwuUwgkDD+b/UGzlGrJmPA0A+VOCzRsj/f/DBdHfAfe1CR247JYTrQQhNvYYr4ClG+pWZ0b77zUaLHqC4bM8s/x01xmd6TVHFKOcsd/6TIgLiQcyIvXBDbpzgDCIjgGAQBaH0KgYNRZKSQokYovbKcG8ILfdYaXBDy05IdMqdspW9M4pWIjRJ3mbcTgDaFAVcxQefC8f3gawGpsk3nPVdQF/Rb1F04IGECD39wK9AkeyY373XPTb3HTIosid1QvXCu6PYWm2CJk/3m8LQJYjH5MvKZvYr2w1yud6YXTwgXy7ErNfCw8DV96MtyaT+qRJ7fSgcp0u2YW9JW34WVteZ5wfSjBZhUY8h5mt8b9nlcCGbi0Et0mZsZ/AWTU3YFVsfh6dbzQriku/Ms0kOM3o6Y5sZI+BYBtx95Rhro+ktAVTIYjS5ktsd7HA/cMwUeuv0cbdHK+dij5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe6b552d-12a0-48e7-2193-08daa9cd26e8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2022 08:06:21.4045 (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: Wk6cplrPLmydI7hekfAdyl3LiDk/qmdM2MmhCdv5T4FEBgfYoryFJE8Vr5z2EOqUz0ITSQoMD0zMmIVsuPmjCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9230 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Li Jun imx7d can shutdown domain power supply if none of peripheral in this domain is registered as wakeup source, this patch add related codes to check if power is lost. Signed-off-by: Li Jun --- drivers/usb/chipidea/usbmisc_imx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 7bfbfc83cfe3..cc17dcd97856 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -939,6 +939,25 @@ static int usbmisc_imx7ulp_init(struct imx_usbmisc_data *data) return 0; } +static int usbmisc_imx7d_power_lost_check(struct imx_usbmisc_data *data) +{ + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); + unsigned long flags; + u32 val; + + spin_lock_irqsave(&usbmisc->lock, flags); + val = readl(usbmisc->base); + spin_unlock_irqrestore(&usbmisc->lock, flags); + /* + * Here use a power on reset value to judge + * if the controller experienced a power lost + */ + if (val == 0x30001000) + return 1; + else + return 0; +} + static int usbmisc_imx6sx_power_lost_check(struct imx_usbmisc_data *data) { struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); @@ -998,6 +1017,7 @@ static const struct usbmisc_ops imx7d_usbmisc_ops = { .init = usbmisc_imx7d_init, .set_wakeup = usbmisc_imx7d_set_wakeup, .charger_detection = imx7d_charger_detection, + .power_lost_check = usbmisc_imx7d_power_lost_check, }; static const struct usbmisc_ops imx7ulp_usbmisc_ops = {