From patchwork Thu Oct 13 15:14:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13005703 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 3D8D8C433FE for ; Thu, 13 Oct 2022 07:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbiJMHNH (ORCPT ); Thu, 13 Oct 2022 03:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiJMHNB (ORCPT ); Thu, 13 Oct 2022 03:13:01 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80049.outbound.protection.outlook.com [40.107.8.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEB4D11C274 for ; Thu, 13 Oct 2022 00:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlnnC07k4xiZS7BoH/HkHOuaUt4WumeHrh8KP/ECFPv/mqjx8iRuXJUZ0h9cffLkfqiLYqiNov3GhiThMEnNUlZXYy+gHhJvmhIyFqZgyjWoWydvE6dtCinY3BvVUGRJdlfQsw6liqc/uzUXn54B0rcVg1cVz270HKJHaS1LINP0uI4Oeq9V4XiyZj4txeNUfzTILRM58Wwzlb8bmYAdOabtE8kl6l2EXdbiJz20GBKyvX2d2dFCCiUYgBvBmtYpYLpfoWRWH2ZEhERt69YHGNZiKP8sAARQN5jRerY6KDG1NCG56/UERhTW7JirbFeNSn+bB7GNygYIFW+QhyToLQ== 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=TN+cvx+ULURZUHbvw5XloGjbk95OmrA50HDYsX2lD/o=; b=C/NxQHa3f+BuuO0fjRs/INbLIqz5YksRZt46dCXO40avVUxfKNb46ybrC4Eo3T08RAnquljUBCmv1C9yCRTEvCjG+Kga50x55ZMDv3emUY+i8nzDs6tosAIZENEU+Fb1MdGqnRc8UkShVe9TVeBjzhRirXqqIWfNDvrEXsgEYdZP3QQoAuCkfCnkzdseZe/P9runsF5qXAZxt3gM2UZ9ctMM8y92eiFMEQaiPGHihNgqSiC3qUxy1CSGbTIaMjd4QYE58V2XoGHc51Ey0Ag7ioEfGhQRTv6OAuJyIb5bmzCNU+GW4AosrG8LmpxoSSkBBBer/PGKZxFHs6SSVLkQUg== 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=TN+cvx+ULURZUHbvw5XloGjbk95OmrA50HDYsX2lD/o=; b=V5BTmi6oVLKC7OgnRrkkUMbleJnNSLMbszF0wE4UhmNwVqH9wnbG6PL2GfhcZy2TrJ1vaobLEQINdqqKJOxMVp5F61irCl7JEsUCQRw+wIYViP3Cc6TswiSY/Avkb5yAWFaM023GABUisaUBZ0lwwCR4zdcub1SsBbClrLcgutI= 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 GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.21; Thu, 13 Oct 2022 07:12:55 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::855c:7884:639:f875]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::855c:7884:639:f875%7]) with mapi id 15.20.5723.026; Thu, 13 Oct 2022 07:12:55 +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 v2 7/8] usb: chipidea: usbmisc: add power lost check for imx7d Date: Thu, 13 Oct 2022 23:14:41 +0800 Message-Id: <20221013151442.3262951-8-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013151442.3262951-1-xu.yang_2@nxp.com> References: <20221013151442.3262951-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SG2PR02CA0091.apcprd02.prod.outlook.com (2603:1096:4:90::31) To AM9PR04MB8777.eurprd04.prod.outlook.com (2603:10a6:20b:408::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8784:EE_|GV1PR04MB9151:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ea8a55f-d50b-4fb5-717f-08daacea59b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cda7+kTjpfGIMw7sZnRMpEcm6TOa8gga5nhOFFO4zv2J4LbLb+PqoCSsPZgxsIPUaVrKLFQCGu68T4uDVjyXQLQJnoxw3pC3vA05rzC1Pqb86qP+X7XqrHCg83uFz3e7L794Om2Qg6uK9ygZ7HvrTb4Vf9YWT4WUVEXv5qP9YxqkltnXhQ2FbPb0pGLSPdBu1rLRHHZpDHpCYLAG7/GWDMkA+eTA1hl4f980KF/6mQAJhqNlsNc+faB7xeCrmJtWrsdS9tyP7YQ2Owbv9IaAw9Q3bbQdlWO6QmkdTLB00AtMuc2H+d6lGKA75Cf4qavtuzWWHPrItI2tTuRwkJF7h/ZWQYYjIuGnoL92zFI+ESx00fp4/ereRVwoFJAznzzpKTkZotOnU5WsE3KanydhMM2LZperTSLFbb6Ip50eXc90X45x5/OefFiJAdLPuoqPLiWPycQ4vXXrC1ReUusIlIN20ubFPDLfAnU0UScLub8kNdfeHp7BSwhwJKUST/lV3w4lEG2m9AKpYmoCcb2U5fLpAjkNhYDFWwt+cbpHD0xYV18NFIdeG5AC3ECTaGLNh4s2Cy5Gl8xFUYu0OQ7w23JZH9ttcwG6jxFsZZxnWfzxtuRdLP9aujJzocBZcM0RJcMog9FvZ6oFRa+qmrCJiho9GqvbhCh1QJA1CZpxOUC6VGo5rglgpqAaWXXN0Xvoa0MrrXICY/608c6Fh+OqzEV4dcQL0fgYpfc1rYCRsNxFpbiLL2QksDZf+3qKojj37HwmvJ3bxHzdU/Mu1B05kQ== 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)(396003)(39860400002)(366004)(136003)(346002)(376002)(451199015)(6636002)(316002)(38350700002)(66946007)(8936002)(38100700002)(2906002)(41300700001)(4326008)(66476007)(66556008)(8676002)(5660300002)(6512007)(186003)(6506007)(52116002)(6666004)(26005)(1076003)(2616005)(83380400001)(478600001)(6486002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GrtiCTIgvxXJuM8BxaP5eNIuuVX2gBT2VGPPqscZNtscOMO3qMUB1O0vr8ugfM+7ngNLFd+wbaxDIs3eMAYa83qfeLMes1uZm8+4/qG6u+z1j4c4c9pv9mRjACbj3kZY8js6bSS4unjyFLJZe+5NgV6UXHosLs7XX1H1h6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4P9UGhS+g87IMDoWhkng9q8nYfolFPLKnJ7jkqh/d5jLbcYv2OxbXQC7bH38QHNgOOUizdfCB3cEzqB/1fUUydJ12Z6EKHWlXRnTMukHnBGtdCJ6RCUaE1AQOtx679mFbAO8UlnhkmCQfWEgXfbot/fKhc5E8tLsaSyv+XXD4yHdZNPHZQNlH3W2sRWaF0X2mzX/Uax+EXZtQfqXc23mVlZpzaX47UuWOkuZM2oTibYe61vqkMUZCRAzD+R6N9VEImquBImtmfNXR+v4Xv9F2hm5aazKRc8kvSnc3iI96eqLFazKPNZZ90a49CjBSlk8IKI6kPKQs1waDdjIRQXlUeZun0US8r+ysuw+CoxIS5i X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ea8a55f-d50b-4fb5-717f-08daacea59b3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8777.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 07:12:55.7221 (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: MaC/jx+mqEA649Uq54/XNQsx8jOVBrOEzqD7QdLipsQOsd8I6csg5Eun0SX7OnSHMSw6PAcZAeuE1a5UTs/iRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9151 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 --- Changes since v1: - No changes. --- 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 = {