From patchwork Tue Jul 16 20:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 813291 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 1400A6F2F8; Tue, 16 Jul 2024 20:56:38 +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=1721163400; cv=fail; b=ASnzPixMyoKZG3yrkQC+jfnXF+HrTT11ynqMGf0ZP7IVw8MYtRNsogOEs/QwAbhdMT2C1teSmybeyH5W0sM6tJRPlqErUHcWvmvBZ7eyLgJ1JQfxDl8v7gFosWYi+Pe6GItfmmV/pxzZZCvCo8wqWh9EB/DJAf1SNoit8uNufuE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721163400; c=relaxed/simple; bh=ov4trNR7VXvrjCFS0kYJBivo2i/RdhsAa4eeqDGlD84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rjPMSstLRyLsYwzbR7fxc/Pa+IIq9iN36f/pqdXDaISbeGdHreTWpMz3bTM3gi2V+uoj43yHFmTdAI/GrulcUlncRRpWW0j11aQyhXBMhaIZMve3u9gqpRfpG0FVEybfSEFeta827m2/sop96CHGUIIfHP8iMe5a89bYsU+H2JQ= 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=Zq57KNQ5; 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="Zq57KNQ5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DTdvZsyu11Iw6XjyloV3sjzJ853l9PonbboO4h4g9ORnLHOZo27+T3Nc0PdwCcioChu+1aCoj4QtyTovI0OjUJ97m2/WJPihQlYYFWAIGD5rBxp8TqcEJt2Amz/0+Scry4qShpfQb/01sF74SdNpy1tHJfijRpshTJOszG++OGjIYErkHBs6fhE+FXlH77xbgPoQ5AP0J7+trSN/Ugxsi7VtBj/g1MG3j18g4dnSs3sdSN354yVJW1XgrQ4A4aOq+Cu+x3VUib31X1ZqvPXb/9K3fESsEgN4yJ48TCgR6vl5SRRYdeDJaBBAe7wC7gxhv7SisYNB8KenatiIGDdb+A== 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=WjoSvhD6AqsnyHc38w0x01CZHPmVleRrB7rzLrkpw8M=; b=CS3HiuPfhaI90367zfBPKiaGLoXcQU8nVlNyiWDn4IO9sLapmRArsFYBCAXJaFnTqX2YaSrIhEYVHUah6APknDluZsrcqWvPd0er2fkOo4f4gJ8FW/OwXF0H3YXhwT9IUqBKN40aEkEjrbwc/pbZoQX+DPTI3xBGWORhUoN97QDAmOr8VQzmFG7QGQv/29XZi7HZqhFBAAMIdqajAy4x1AA8cr1sYF+Mc4pXTkWZIRr3GcQ5e5DS96kyKhtVqCSBCYzDhukLWpu8YAFBcqGtfBtAI/3bk3XoEhkQc2ggh9iw+HuDjSt07I0OZeitJWuPOFDd+GzOknTKn4uA48JL+g== 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=WjoSvhD6AqsnyHc38w0x01CZHPmVleRrB7rzLrkpw8M=; b=Zq57KNQ59sBZvrHfOswuzkWbvtUpfY5gIGppOS0blf44iUK+cIr2t7uSh4CMXp1JmjfH5fuhns1lEQr5mw/VzkK7EQzOwb+Sl2G1IiAjUg7e3sgryYZUWUseh5ANQkUd7LTAdtmEt0z4x2I/KpqelN/NL0b3/5CPE3FJ50chnUI= 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:36 +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:36 +0000 From: Frank Li To: Dmitry Torokhov , Jason Liu , Jacky Bai , Peng Fan , 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 v2 1/1] input: bbnsm_pwrkey: Fix missed key press after suspend Date: Tue, 16 Jul 2024 16:56:11 -0400 Message-Id: <20240716205612.1502608-3-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: c08fb610-03ce-45ba-ed86-08dca5d9c7fd 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: UT6QqFT1+mhyyhakzZUNrBt6w/Vz5N4KwNn4uIQ9m0YcOt/1sRFqJH9SIx/XMi3eCsnk1x8JF4y4bDu3aYvxtIyDoNG5Wf5lL+Z6hefrF7flcLyKqDCj5bXP8OkdcKNJ89Ss4R6hE+h5mvbIi9n6bYkTGIUvOpFSUi6iIMyipybtWcaw162K3TxgQJ+MvT4XEctQhO0Z0LE9VMIbzcbh2nDkXyVZ/ORH2pPFYWqzOZqYZFWfIC902DwYDsQF/TBNGthJAgaB8yqv68jEpWg2q01sh+AaXMgZEx3fBoW9VDRzQ6xCKwvbXX75G4MuZZ8VIRm7Qlt9UM3b6Y+1wA7dULLuAvybvGo+gjXJKJ8lRhmN0yR+Vvlxm52ciDUbA5rCMlh5f0+3FR/WufgEKEhmAibi2m/6HvmTWsYHOrVj+yF+6+A/ZlzreBuPHjtooA2z8DagTiIB2QacDEg1Q2oFIVsGTDZI/XkSsrqgi5IaEhHTGoFiyGEMlOIRM94bByXo00muGRIwECdqLoKEpoUoIFM8yuPifV8I0hpxjx70v4hriqpSrXO7dAHfIkxKrlWYQ7DRGPtL01LNH9BsyXnl7PiuIh7Mkvo1CyFzTqzINFlAmXoYXUYDYcBdDjEL/w42QN8K6GLikj57jBxma5WaKZjvm2tomIjZnGOyAgf36j2DhvNJ49KXLOectKdgQjOgCt6vxqmGGOTxi9fLpLcxS2OQvOcyxngtP2JkhU4NeytR4B9XgKAgWsUlCsf+R3+WtRol/B0C8q9Mn+IIA/VMIDdHw8X6IsP/0Thg5eIoe5syh7d7oYep05Vx7nzkWJbqN/yDfW4zGNUBTNTw7NbOFX15bDHk6cGu8CTJRYg/7x3lihg7mqImZaqC8CZqbDZTWyUCXFXN8pZRs5DHtx64XxIUkKl2qI/MGukMhH66cEqweiJzosteA7yR3kMTNkzeddO1kxyldxXLofCDcCrn62dRWjaeGh50FoPbu7QVBhIRCsbv+6gJ96TeeJfRizu0Q97IIMhIUb9lQ16peJ/Ov0aH3MEfdIuz5FKAuWEIL8PbzVP808n3OClQG81oQwvYP0D0RE1Rkelhn0LYpbq3mGRW/SH5p7MeGfhJ1g1f/EeFw7/LmeKtXMjQNKr+O5lwtvGPeRrQo5KjAohrL4Lk8rj8xfdZwAQ2oy8TthVlYnxivaZUGtfS6akwcy50pfOn4d1DiXGHfiilIZ36vIAUCttEe2mVD4XRdQhxvIU8iTpJ4yjs/zfWIIiiHHa2F98Y+qqDLDsNVKr+ksZlIkhaBoDaUasxOnm2plZ+RQJ0yLjsMq/q6HCSbYOyR6qcyXj6URJh15923NTcVhtgvVE+S50Ja/BPoza06VpvYt7M601TmvDI8UJQfhRGxa3ezME8kEV9GRqh1F9/n5ThEbUyxg== 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: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xmRktLZodG9nEw4Z0kywYUF0dXoQfQ0cF8IEd/O/u/MFMnfHwBbh517cyaGwCN2s3B2A7f3MVjXOBYFaq5OUGptYYeSPZfMyZlY/USz7tku7bAxP4kCLSrbDqo6Tk968OYDVNYAuNxiqmxQigF8wraOowidflcwtPL73stvJppag3vxoPQH5h9fIpa8u1nv9Ye9nSD3hLQrLi6ZkxZWDFIKwPm1mXbDDotfbIvhgmI6MTa1R2qqWOPrCPfoGsy1FbK17LxYRvbdaDQ+s8RGjwEtjKyn438To1um7NRpP8LjMYk8b8DZTu62DFZcNTrwYP0MuOLL+YRcixeCfUED56iXdzjmcRkL/hvzjOmi+9nhfYLgHVdXCaKA1NF0S5YRT86KwWs4Gn1NOjDranP82MuUjy1Y9OxWmnSaevWp/WzxSu0L0nUdycTc5Xf9N3ypMt6z++X9053BeZxrBf3IMGnwKeER2bk1Tgn50MVKvXlezRWmO4YhynRu5asPCfi5UxOS2b X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c08fb610-03ce-45ba-ed86-08dca5d9c7fd 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:36.3075 (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: pFVVFqwq3kSOrB9rVmTFO8EpWyhZewR/enzTaDKrVCDesrurxcdbFFRZhliw03lLvnK/Yl1H8Q/UFrdwUME3qA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8321 From: Jacky Bai Report input event directly on wakeup to ensure no press event is missed when resuming from suspend. Signed-off-by: Jacky Bai Reviewed-by: Peng Fan Acked-by: Jason Liu Signed-off-by: Frank Li --- Change from v1 to v2 - move before mod_time - clean suspend flag to make sure only fire once --- drivers/input/misc/nxp-bbnsm-pwrkey.c | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/input/misc/nxp-bbnsm-pwrkey.c b/drivers/input/misc/nxp-bbnsm-pwrkey.c index 1d99206dd3a8b..eb4173f9c8204 100644 --- a/drivers/input/misc/nxp-bbnsm-pwrkey.c +++ b/drivers/input/misc/nxp-bbnsm-pwrkey.c @@ -38,6 +38,7 @@ struct bbnsm_pwrkey { int irq; int keycode; int keystate; /* 1:pressed */ + bool suspended; struct timer_list check_timer; struct input_dev *input; }; @@ -70,6 +71,7 @@ static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id) { struct platform_device *pdev = dev_id; struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev); + struct input_dev *input = bbnsm->input; u32 event; regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event); @@ -78,6 +80,18 @@ static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id) pm_wakeup_event(bbnsm->input->dev.parent, 0); + /* + * Directly report key event after resume to make sure key press + * event is never missed. + */ + if (bbnsm->suspended) { + bbnsm->keystate = 1; + input_event(input, EV_KEY, bbnsm->keycode, 1); + input_sync(input); + /* Fire at most once per suspend/resume cycle */ + bbnsm->suspended = false; + } + mod_timer(&bbnsm->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); @@ -173,6 +187,29 @@ static int bbnsm_pwrkey_probe(struct platform_device *pdev) return 0; } +static int __maybe_unused bbnsm_pwrkey_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev); + + bbnsm->suspended = true; + + return 0; +} + +static int __maybe_unused bbnsm_pwrkey_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev); + + bbnsm->suspended = false; + + return 0; +} + +static SIMPLE_DEV_PM_OPS(bbnsm_pwrkey_pm_ops, bbnsm_pwrkey_suspend, + bbnsm_pwrkey_resume); + static const struct of_device_id bbnsm_pwrkey_ids[] = { { .compatible = "nxp,imx93-bbnsm-pwrkey" }, { /* sentinel */ } @@ -182,6 +219,7 @@ MODULE_DEVICE_TABLE(of, bbnsm_pwrkey_ids); static struct platform_driver bbnsm_pwrkey_driver = { .driver = { .name = "bbnsm_pwrkey", + .pm = &bbnsm_pwrkey_pm_ops, .of_match_table = bbnsm_pwrkey_ids, }, .probe = bbnsm_pwrkey_probe, 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: 812910 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+5v5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sD8zxGbMwTI/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+v47O1uJQEtJ75ypYdrxNuKlU1vxDjFUeWHvsfPY3O4AQakg5e3Uz6VYVs7dFhfj2L8ULnep2Trg9gYxONpxUKp0fXc508DuR15vfy92UjE4HPZb8cTGWixlRRB97FWUbrxhP8wGh0MULp2V4XbSMHhgJK3Y/Am8FqYoRBLwC47VYMCfhySAPzL7xVao7ten4eTBNLYkHxQnxrTCkieu1zw4BSCWOfG6lGRwTuIT2ijrnXO/Oz6oJeZvQjUmxx3WVpaHXjBMOK//N3rDjv4YWeVq85NG15ElxQgIOt8PqHzhkVqqfSG3TeRf8Bd1UGQ3O/kz1zHKr65qBK36II4lMem/NcPCgH1vgNV05DFG+DVSNrivrv7n1uL+9w4lye6j4sW42Om8hZWgFJEjSUNGtmh+MIHwQfgS3t2OZgT6II3x7LS5E+bpfBPSJ+IEMSV1qj+RQRgrpnEtOwpMYLFUnNxcLE+P6MP5Vi2P3uSdocEbm94WOuyxMlT3RWFB+2mDVH3wmW0CtulCXHi6DgWvnSy7mlXcFqNFEAlceK4UI1vfEvSE95qkEx4WnJWXqllMlOsgFPUNZ1p4Dh4Ih6R3p5qGRa2ZJdyqFmhQbJ4/0/MnGR5VIZ89aKFC6xG27GGiKu10D1CGPAdMVr6cWkWYcZdysPw0bsNTfJohXPLsapG23zIfIFrG7bMTdghoOMmiP16/mEmtK34OGVEaYaOimTg5updeVPjlctNlzO/etgVtVqa3oDwPlhnqpslSKvpvL9iszlT/1A1ab4xT/q0AJBRw3USYzcQ5ZDgVGTgs+jXpSVmczLtrF8waiFplYJbaMWk4CnVX5wM5cWjY8nHFuj5bR7aa+3NQ3blIlXEMr8Z6dQv75dSyY7iT2KjGMbNUIVu/dW0BRSPJjjXAinkYe+UEErtMZd+tnSZLLljWuHL3c3C2Ah6VxgwXPKnz/mpS5WYOZcl9sZ8vJK8RI9XX/8cPcKJVaqv5wapcCJmY0F3iF8fAZKzdHYxfWHTVjzFHbULwegethzxZi0iDvNM9CuJ5JlpXGWJUi5HImrVrmtXKz/LssXcjMa6qcgT5iun7lk3eqgyPmMGZBkXswUKkHi1oi4NIWH3i7iyQAO9Xhd7cYL+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,