From patchwork Tue Jul 16 20:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13734922 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011041.outbound.protection.outlook.com [52.101.65.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 142A8208BA; Tue, 16 Jul 2024 20:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721163394; cv=fail; b=a08AZE3kPADzCLo/ybB/27057w7BL3QGKCa2NC4QBce6EiyCpoT3ZS06/kobKkgNqNMEUQDvoWzQgFBeKGV15ss8nqQPBX/Py6lQ+FeFvSmRAXKP7jqCKL1mTOoo6M+UpYsn4qyaviaStKi4qbbZxSXOew5BNs437TephSNDl2Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721163394; c=relaxed/simple; bh=9ivOHaghZuYXPCfXX6KDM57uoKVXmR0MYMGb9Y0mggM=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=I/A5fNHAKDzntp8ebCymdNuB7/dglP4w9Cmk5NeMp7SK22SyO8xjDW/PjcUVvk7xbwkPMv3I0uzUAywCIpy5/F3jrSJy+3TpjB2quKVKzURLkczrQZCHfOZVHbXXxY1NI3kLu1UmvKKaJZEoRpC3mBxUbP5PHpwvziCT2kf490Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=VnSh4r4S; arc=fail smtp.client-ip=52.101.65.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="VnSh4r4S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XuvTKNpLgPwEiKa4uoXO/9rf28ivdtr4tlhwuFIbqS9bTfdRnDEDfSaqkQGBH6ZinQyZzqkKdg1K9gzjX2CMPeYZzD4Rm2X2syUbnRqKBMGn4sWoxkya95S56nEos1Bqnzuw92vVbjGelT/57ZhQ4HTd/NprzSyIbZdAFYZIik5KoWkOUebylaRFiJYmrcI1gp7AoBH2namqhUEhiiGVXxYVOQrfW6iJZQw/fLsv/7T7+92Uxl1rG8mzlFP1rJ1EMKiik68uBUPDBpSIV+tzXP+BYlHEu4H8Qmpumj/R9BOt05Y17y2PbnhhLyUFriQn98BnImqZmAvYnBY4yFasog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=8ud62kA0JhDhjofH3ZLNS3imycfAhXeERPEH4QT7cyU=; b=flqz1RhnQ3xgmJTKakHFvdFX3s8frcRrn86SV92p966tJf7JsPxHnjnLYt+/XHqWuOC4Xh6WCH7byTVhHHuevOgI1yBq7C94nN7yHB6hw3ZAA0jtF4/s/Xb1RKY6o9cFuG88CkU7TwjTmFzI5XRPM4mi5BmHE5TXpUPZe1G6ejOfKLtjZfxAKdRuK1uqgqYFyB0iqO0nOG4RfnuNi4EY8PhMjYkleGvvgTkzyVg+gcxb5vodu/pLLmJXewXNV1xAywiag4jI6HFMa3z8TxdlQYkSZgjm9N9azv1GPptSs+aALOA8swgcToOdm67/8jjJ0WIWtcosnYBLvrZMyCvbMA== 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=8ud62kA0JhDhjofH3ZLNS3imycfAhXeERPEH4QT7cyU=; b=VnSh4r4SKQ3u+qwYQQmKwldM5PvBpp2qOkbNx6xzYDgYmbLyLOx3vF9QUHmUMA/7JVEmQx0Ue8rVrkVdsaudwVsCmvvON2goxm5NPTH2gkBQCp5osrGLgcAwwZnfr5wwwuweUqnqCzFD/iWdQt592wTM0Rmfp75toTKvhohXeeA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM9PR04MB8321.eurprd04.prod.outlook.com (2603:10a6:20b:3ed::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 20:56:29 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7762.027; Tue, 16 Jul 2024 20:56:29 +0000 From: Frank Li To: Dmitry Torokhov , Joy Zou , Dong Aisheng , Robin Gong , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...), linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 1/2] input: keyboard: snvs_pwrkey: Enable clock when accessing HP* registers Date: Tue, 16 Jul 2024 16:56:09 -0400 Message-Id: <20240716205612.1502608-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR05CA0027.namprd05.prod.outlook.com (2603:10b6:a03:33b::32) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8321:EE_ X-MS-Office365-Filtering-Correlation-Id: 382ff15c-4953-4f74-c301-08dca5d9c3a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: MT1RavRvQqw4CUPJ7YLYi3qVTzH1ubejF+4121XxUchAWAa6emC5h58tqCp6vKtS/+IHWBANdpyt6YL7JaR38x4Ogaq8oCMyeHZAlWoDjI10scucG/SRrxQP6TrK1fzmDPSVYx6AJ9tK0Aqk0honuFG2tHK7dRWC1GkHdagUB5nukraoyVQ4TH4KIHm0uj4vTXhc+tJHX408+SYmrHxWb8MY120+1B1B7YpENUxdrfo1gPILBsaAAk7fZ6+REFijB9bXxAEoEBROq0G19ILAVLWw7QFDx36JO99jg+GAoIV1APzlNdysfjBU32oZ4x/phvO0g1BvRjpazG8bZI8d8cNYfDqppP92ifSpkj07VmhrFIgZi2ex3U7iaYwoL3EgQGqHAhCZc1a9itU7Up5XuyeTWnhP0V61Lx9X+u909PgNaDyjiP4y/tvFue2cV6k973LolDDMLuMwvzhF/C4WQ7/Mmto+7zvDP1+AqlOZnJPtDpF5jOVQI5SwlXbHnXVPvS/T/RfGtjRW12zOUbDWWkrWxRU7xVyXzJP5e1vslTSRofXWASYBAD6J3GUm+F+uSzPk9QJ/VWzRbS+kLJnOFwZmg0c1TniW0psB4OpQ034aFYkSNXQZQRQG2/n8DQ/Bws3np5teXiN5zEthHaYnjAz43pjDIy4fH5C4TRZVVOodKF7nnJrWE3vNKykSfOVBtxXVf4zt8w6MIXFjAa8v4C1kfnxVlf1Ye7E/zT2GOYLB+yKzPYi1Dy/UUn6999La+GSr8ZZnjJ7h4OI+XsNvcbqCrJENnXv3NRm+drJRJ55wSoCb4SkMh8tiihkkJej+0EUkEnkZDQTI0ithPHutd0/f7aDsoQ5wecxLi5eR1kQg9NmylpYl7BEQTi8GgMh2CZdBqJJRSzuXz8Nubox7hQwp6PLZpgauECbkLNXk+v81eRPA9CkpZsTJHfS9K0UOwgaVmSr9l7mzGpS8q12PNn6A7OqeobiBsOS5EsXBHzjG9hDdHyMSG5dFl6iyMYY5kuOZ+BskuLS3BZqDABHpFwO63peh9hqVINRKDeK7eRNqol9V9t7BaTk+a/EPtoImWEhDioNhDRfAP3qeUvHQPKCpsnUxVuuK3XiGFt2ErR4DSuPKEKheode3DGCl2i0Cmfy/rfVptf2/acfqJlkCv9YVDF+4amIY/PoP18rAUPLLsOrnGsmfWs+r2BupecXFOZZ0UWIIwuVruClYVIi+fIjfsdlqHGT3SS2olw6LftlnAYAWefqwDIdFPyQU5trpGB38ZVs8KMGM0O74SbWtcOlvW4fIa/1K3mNOZ7xfH/tkq68wicsoSXOPGVZGADlJVrc1St3vQ3vMpHSc6QAsyTaCOHQIpKnF9egyvmT10Z1mb0RRTf7csa9s5L2WzuSIiqpUTcQcSFxMR1VmpegeDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W7XYpVMVEcytNrMxvFYwnYhTR68Ggo3HuS8CgnivQV1Ej5f4/cKux5kQTqR+VSucFOyMoxEDb7KOwj8L7ekxdYEeyR6q8qvE9aW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QJiwLsQAXYH3qmh0M6M3OiJJSo4YisbJkrovDqSWjs5EuG18x65M1hHd1nT1d20w8aGsjmeHDKqJOsS9zyxqEWiN6qcPP7+VnqdgrqdDUpdkX1f3rRiaQ99Z1fwKrj+D2q58YspuN3JAHN1Z0e2pi5KcrBXJqrRe5VAxH5bsgCZkeabOBUimAOsLR/yETL/tTPR0Pibug5z9UgPljRtpjIH0dNdp5Uf1fkPkvn9mjtCq3ijj+iTTVlv+hQdPGVmZaenM6K1oHjV6zibf0vwKcW5BeOjXn9n6VlvQ2aVzXt2TVxSEzFbYRLI5wJyDRZ0/INErocE910Joz0d31CBTaLXYg8SHPQRrPcKg1V/WPcfrPljriwFAhK+14vZGvOn3x0W1UXNA= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 382ff15c-4953-4f74-c301-08dca5d9c3a0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 20:56:28.9820 (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: ExNVyfw57GX5zCWFi2e37pvaWvTcfbjzF39nCMpUjF9jaj+j9znQyG+PxRYoQjiOAEWeCwH2FGNxKCserSJ9Ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8321 From: Robin Gong SNVS requires two clock sources: - LP (32k always on): All LP* registers need this clock. No management is needed as it is always on. - HP: All HP* registers require this clock to be enabled before accessing these registers. Some platforms (e.g., i.MX6SX/i.MX6UL) do not have a separate HP root clock and it is always on. Add an optional "snvs-pwrkey" clock for the HP clock and enable it only when accessing HP* registers. Signed-off-by: Robin Gong Signed-off-by: Joy Zou Signed-off-by: Dong Aisheng Signed-off-by: Frank Li --- - clock name snvs-pwrkey already documented at Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml --- drivers/input/keyboard/snvs_pwrkey.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c index ad8660be0127c..b352148a0cfb2 100644 --- a/drivers/input/keyboard/snvs_pwrkey.c +++ b/drivers/input/keyboard/snvs_pwrkey.c @@ -37,6 +37,7 @@ struct pwrkey_drv_data { int keycode; int keystate; /* 1:pressed */ int wakeup; + struct clk *clk; struct timer_list check_timer; struct input_dev *input; u8 minor_rev; @@ -48,7 +49,10 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t) struct input_dev *input = pdata->input; u32 state; + clk_prepare_enable(pdata->clk); regmap_read(pdata->snvs, SNVS_HPSR_REG, &state); + clk_disable_unprepare(pdata->clk); + state = state & SNVS_HPSR_BTN ? 1 : 0; /* only report new event if status changed */ @@ -169,7 +173,15 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev) if (pdata->irq < 0) return -EINVAL; + pdata->clk = devm_clk_get_optional(&pdev->dev, "snvs-pwrkey"); + if (IS_ERR(pdata->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(pdata->clk), + "Could not get the snvs-pwrkey clock"); + + clk_prepare_enable(pdata->clk); regmap_read(pdata->snvs, SNVS_HPVIDR1_REG, &vid); + clk_disable_unprepare(pdata->clk); + pdata->minor_rev = vid & 0xff; regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN); From patchwork Tue Jul 16 20:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13734923 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011041.outbound.protection.outlook.com [52.101.65.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C3DE55893; Tue, 16 Jul 2024 20:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721163397; cv=fail; b=pYL1duEdVReksKvZbBwsL7Ruhr/iNhePo2AN/9ufogpsSLRPjbVlziWoPmCe3N6RuDfxf0ufaSoWk/svDO4tkEOygot5Xtsb45xGU1/mJvq7W2lBBTuomM/+J3xPsGd+tZozut1XFoeem9zE72vzLy3f4CVW4uFYD2XhXXPNRnM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721163397; c=relaxed/simple; bh=kqjWbxk3HJouhZEcvIgJRJgGUMfAWdztWieC+Ygc4Cw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Zy72cMVFdPhaBlCgD1hoeRQsQdHTvKIyHDp2bkjOvh4WFmRBG2NYXogqWOiC40BIDoi0HKaKEa8+eOK7vmjqetl9SaLft/mRAf9GVfkiDMCCg61U/SDUDLGV2TU3NV/7DCEKCH4k4PHbyIfGrD4Siqb/Z1601bqU/wWBN5mxzA8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=X/Wn3zDh; arc=fail smtp.client-ip=52.101.65.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="X/Wn3zDh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I94dlDUmtEoP4AwXgNMbFggEblKgQyCd0YlUfJ5wHmm3t1beQwE8earkGP7MqJWmKQYROa8vPqSlShrgbjzCu6PgNW66lrYM7gKzFWXgPHb5g66drQAT7o76HGpNFRwjz8FZfRstXnVgqiU9YOUXT1ZG/3eoVEuR2Q0+u1+8gc0Ps7AyC+pIPMZ7l8rkZDyhkzPSJVeaSW/eVamIfDtdBYxqJaY54/7gQ3Ijfau44ssFObBY9vW6f6dA2gVTbhnDzr2aXtOC98pWQoA9I0gNs/Vbo+oJ8DIoKdKf3VJuLBBPfToRMFkVsoRTlrlYm53JdwQ01L7pMVqeiu3/121f9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=u06YBWKEUmICsR2R0IWtJBkOk/6VsgZ2sA4fmyAdXiI=; b=BtSKyBGLErT42AZtxKReU5S623D9V+Ci39MANRUuHhz06GadnHhfQZaPKpkUcvQ7dcZHc98Kmz9+ObRAuQXsz6hV/nzzTz34+4yysDkzkH4gQE0m7ePcitDYYbCDMK1EjrYqvgJ8QfGsp9x9HQTz4pnVad+dl4nMhGlQByfkq6PWujf5miK4FtUDr4bgG3mTUDw4bYegxk/7pddPBS4idX+gIMkvUbnXX2JQfSJl982TxNSq0fp6Mt9uc2FleUtF5vgRz5vS0ZCDnNFgqvjBtV2yXqD1CpdHZQjLUK2oDKNrVPpr9mE6DqrzS7aqdiDnNj9qofBJQBKeDD7goQE0Aw== 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=u06YBWKEUmICsR2R0IWtJBkOk/6VsgZ2sA4fmyAdXiI=; b=X/Wn3zDhTnE3bSUjyyovSh5ulIdl+fHLD3K+00VIjQNFr2c4zq0gQVTJmpoJegkXQV/A7mZSeD/lKjY+lvxIV3ypcin7j3uX+758r0CMf5pJ+26vEXQZmlLl44uTYbkmBxFJSyWxbQ/nOWW2zHdM2+s6FzQx54poKP2KcYmagU4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM9PR04MB8321.eurprd04.prod.outlook.com (2603:10a6:20b:3ed::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 20:56:32 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7762.027; Tue, 16 Jul 2024 20:56:32 +0000 From: Frank Li To: Dmitry Torokhov , Dong Aisheng , Joy Zou , Robin Gong , Shawn Guo , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...), linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 2/2] input: keyboard: snvs_pwrkey: Fix missed key press after suspend Date: Tue, 16 Jul 2024 16:56:10 -0400 Message-Id: <20240716205612.1502608-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716205612.1502608-1-Frank.Li@nxp.com> References: <20240716205612.1502608-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0027.namprd05.prod.outlook.com (2603:10b6:a03:33b::32) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8321:EE_ X-MS-Office365-Filtering-Correlation-Id: 02932e2e-9ba9-461c-f6b4-08dca5d9c5ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: JqyprvBrlD1LGNeRQhEOCQDdzxx8RV97cZ0pDqq6dSXHpp8lcq1+ThmTG8P+AIMOaRzy1jXLBxaTTwbwjU8QE+5OaBeRKUfmpqkO1XgHzM5x8hVLDZNCDLhrNflsngugURPhqHEZSkBOmsFGlviSUowoCQiMxrlPCHdhlIbyoJKE2S7Uj0OJWluw7n/kwH5+f/UB6jSKxnXF1IqLc/Yf0dmxNh7actGDW14vt4NEaNteH+5v5ZTn1zHs58ScT401VRb+Rf1pGkjKZgnuDO4ywAWh7jolj3vUYC6CrLPntbE/Fj+1zhw99hDabSnsVkTg98iZM1bn6bTUUSiJteo1AYPM9PSN3TBt3L8uuEqnnNWfn8EfpDby44wBsfE59PVaLbigNyBjru9sAFU1SfRcedYhbdEUm7I58fTMPtg+w11z5aPyGaN5C24mWdItBgS/u+71EfNaS0ZqpozczTlKCICV+waU5Df4W7jX2It3Ua5sSMHMn1Zr2UPzRPCJJDMZFwL0SVe84T6wu+HfYDpuuWUbs53GHepzgNOPQqIIhlrie9UXGWtkKmXA4WhLAz0hkR9vPbt9OaTVTJrhdPbar0o/q8cWbs5KJHIzSO2UjnTk+rE02yZoPahKHdqnzu9fXH6cDTc/8hTi71gsC2niJyPNxODptqMGJAN2fKEjZ3uNRHFU0icvQ3u5Zrd7QHlIAuWW3iWI9idOkv3+6w3aLz5VVE1Xf/1Axra5qEMoFC2GG6RZjBhaOrU2Ytt5yGEH4z2TYsHvXe2xBESl0LCe4Vllrz9pNKb/QW38YSz7JOWbEjD/GWQ/epqKsAls4xBTCcS4QlX+TOMQrUIkq94oqlGYLQnR1kkWdhrNUkYrGcVXonmwe/Qr4hUW+TIiA0A6z8/ST2STU7CPbmDxib0o714Rnud5D+2VRPTQIE/eJ++EEDsuDMhLpiJ+gPx+W6vnD3gDMC4l0ZOD67TxUcaaiqeInHbWuceZ0E3LVlhVZk3H/qS24fVRPzJ8uGWHM05lQHRt/JfguYg7pfRsXD27YaOR5dS/RujLRxj7Qm+TVC222goFb15k94PNsxtDAbCRB6ep6tfZU2WNAoCyQjBv0pfrZLsNCukVTTHvl3nFuMHg42iNphX/KFUksVDBx5l6naq83//wUUdRW59UadiYtdCFZ5t7uq45th1TxislWwtex/AqdM5uukIGJmGE1JFjnC4u5+0+Y4UpRxxphDDp62NJ51ci7GEaISxyatH1rQwabfJO/jRw4tgmOTHcBAIhyUMG8Ev0tjj6URJtC+JjeWpxvob+z2zbV/cHUREAcf/EE124qgN7sD8zxGbMwTI/3NN6KO4glgmo16L/eUJAQa/jhxOwATGsKmeq/hvO4F1ed9FcOnGBTs13oh0QHC9jwcezGB7DlbK+dCz9PAsJlRukjVBzwp6n/j09wuqyZak= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lOyaQydBI/Wa2y7NH6n6RtSRIWjJbTRCQE/eUTA/YcndTxox0SqUkHyPf8AAzPhQqo/CQUu/2jopqSkw360loqA1iySJ1L2aA4+p9g7ngh5+CVCiLGq37Rk76zjeTGztt8+v47O1uJQEtJ75ypYdrxNuKlU1v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GZBkXswUKkHi1oi4NIWH3i7iyQAO9Xhd7cYL+B63pEs2reePQzwV6iv5dnzsWoLPgM8o3s7BRoFo6RtTG8GMMtJZYJlzS9ZY7FU1gUGSyuGNkiJoSI0biPGrZBWwMpPeVrqJBeHdoCow4P/dvVv0AtKHvIKOX5aF/XeSTbPxTyKn7z5kA4wwIIyJ87AnE8LlVR6c5iu69MBlMr70H3Er+RET/t3ZPP1FCMvvk/6H3g0J1D/YtCSoYNDsJPU5tV2fvIIzqt/J6R69yPHxLK0ZxC8nZTFoaiCGoOBZ4+AM2XOgmmeKHByzR9Ilt+LSKkU0A8SgRhfdWnlOG/XgaRhQLhaXDsy5oRl2ufpCh5+Vtp9tk4A3SCJ2 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02932e2e-9ba9-461c-f6b4-08dca5d9c5ea X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 20:56:32.8472 (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: p1dSV0QPLm7f0mJw6l2h6+8ijjTIHX7voUSbT7SWM72f9oGcDQg/FfC9K0c8QvJVfBtGql6U7bSifJW/6ZGytw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8321 Report input event directly on wakeup to ensure no press event is missed when resuming from suspend. Fixes: d3dc6e232215 ("input: keyboard: imx: add snvs power key driver") Signed-off-by: Dong Aisheng Signed-off-by: Joy Zou Signed-off-by: Frank Li --- drivers/input/keyboard/snvs_pwrkey.c | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c index b352148a0cfb2..a1c04fe8fe05c 100644 --- a/drivers/input/keyboard/snvs_pwrkey.c +++ b/drivers/input/keyboard/snvs_pwrkey.c @@ -37,6 +37,7 @@ struct pwrkey_drv_data { int keycode; int keystate; /* 1:pressed */ int wakeup; + bool suspended; struct clk *clk; struct timer_list check_timer; struct input_dev *input; @@ -79,6 +80,18 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) pm_wakeup_event(input->dev.parent, 0); + /* + * Directly report press event in interrupt handler after suspend + * to ensure no press event miss. + */ + if (pdata->suspended) { + pdata->keystate = 1; + input_event(input, EV_KEY, pdata->keycode, 1); + input_sync(input); + /* Fire at most once per suspend/resume cycle */ + pdata->suspended = false; + } + regmap_read(pdata->snvs, SNVS_LPSR_REG, &lp_status); if (lp_status & SNVS_LPSR_SPO) { if (pdata->minor_rev == 0) { @@ -236,6 +249,29 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev) return 0; } +static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev); + + pdata->suspended = true; + + return 0; +} + +static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev); + + pdata->suspended = false; + + return 0; +} + +static SIMPLE_DEV_PM_OPS(imx_snvs_pwrkey_pm_ops, imx_snvs_pwrkey_suspend, + imx_snvs_pwrkey_resume); + static const struct of_device_id imx_snvs_pwrkey_ids[] = { { .compatible = "fsl,sec-v4.0-pwrkey" }, { /* sentinel */ } @@ -245,6 +281,7 @@ MODULE_DEVICE_TABLE(of, imx_snvs_pwrkey_ids); static struct platform_driver imx_snvs_pwrkey_driver = { .driver = { .name = "snvs_pwrkey", + .pm = &imx_snvs_pwrkey_pm_ops, .of_match_table = imx_snvs_pwrkey_ids, }, .probe = imx_snvs_pwrkey_probe,