From patchwork Sun Jan 29 07:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 13120038 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5FBEC05027 for ; Sun, 29 Jan 2023 07:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tnSlohjyUJBrQ/TlsemWZLBtYdMGEmhonyzRbndKwgc=; b=yosW8ubiCE2LC4 HHncdkNDpXr8k3LpEYbU0Pc6ZXJl1DSl4MFxC7MY+wgu4bmSH56G3GpTI2l+raViUH9RPhMdZPiJx CJdbExOF/01RBFi4IE//sCBEN9iFJgjfKh9g5juCNUL8e3QQUtNVGwuF7SkjFdMzOMZ5Dbk0K4oqr IrqnoCrcJPkhsddSj2HbEYHfr4zGUClOFRuiu6llXcXRbWdPPzo2Whs6+kbJdQi1dQiTZk1/wl4A/ GaUrvTUIlQIV3j6MvgrjiULHC9B1vdelXkF0EaDlpHav58XGVUPUyMOpQz6cTyABBg+1v+JDGm57A jclDTNJS+ZalLnF50nXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pM225-00191T-K2; Sun, 29 Jan 2023 07:23:21 +0000 Received: from mail-am7eur03on2089.outbound.protection.outlook.com ([40.107.105.89] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pM222-00190Z-92 for linux-arm-kernel@lists.infradead.org; Sun, 29 Jan 2023 07:23:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P13v+8yt9M1LwAZmfPGHoizPM4/We663qw6SWu6Qn//pYKbYVkCybHArZJqoeS6MVgjoVoIrwpG3Bmd9Oh8JwoInjzNy3XzS3mX65II2RZ9sYLYt2Y1A4t10nrQTuSIerV2MDoSspTaNTZQ3CwCAACojrCZjpE5hgA2KGaoODXvmhLTMPXwRaguGP/acvgX7zMEkf3IRkOXygZ6wOa7ucib4aK2hs1l8Jv1XaJLa6l/+St3K/Sc9qXLBm9CtKRZB2jMxE/P25f21XId4nPdDEHf+61N8/2bwB9MnQaOGKdlserK/GI8ojgh28oSNVPaSy+A6BtGL6s+lZokOWuaQ2g== 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=LNQEKSD0SwfvFR4Ud8oMe8N5uEOdIUC9x5hYLNrBhUU=; b=nz6JVfPxjAM8kKNRMEyjx6Edh/TYsKb61CKqiTSKNqqdhjwHj84w8KR7xuYCpwOzl8vPWVfuaLcDt4XWCKzgpq2rHcBPSt3+I4p4MOYulTEqMlBzineCxvmGuBnKHzsD6WIkmgQaDap0h6WZhfYIkLQ6N45KqB/chf17pcFifrND46XVg7eM9rI7MvzsoClxnL0MMAoT9rVfVuswQW7BbSqCcCZWMH3Id/Tn5mCe5kwgDvXE7q5V5gJCtr99NDrn8FRplAxLbINMTfB+W3cmMe23qzh1VaklWRFIw6cTTtIebZx8TQbaXY5LZsiJxNVKxW0d9P6JbwRZpvrfRCY6ig== 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=LNQEKSD0SwfvFR4Ud8oMe8N5uEOdIUC9x5hYLNrBhUU=; b=BosaOF6FGHAhFAeBWGBC9y7YWtWIY2rSRDJQ0UIpOsu6uW96mhXgAAf+HMQ3W4fWGyKGNmAVazpp0Vx+4gnXYoXI5Iix4U040syGLUpO41ynLltgmuVT2OYO0zY/XthwGkqJ61TYLOV3WOXX7mq+lRbaggtuNr38hzgzgxVodO4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8650.eurprd04.prod.outlook.com (2603:10a6:20b:43d::18) by PAXPR04MB8815.eurprd04.prod.outlook.com (2603:10a6:102:20e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Sun, 29 Jan 2023 07:07:22 +0000 Received: from AM9PR04MB8650.eurprd04.prod.outlook.com ([fe80::4ca4:bfde:62dc:4b2c]) by AM9PR04MB8650.eurprd04.prod.outlook.com ([fe80::4ca4:bfde:62dc:4b2c%3]) with mapi id 15.20.6043.033; Sun, 29 Jan 2023 07:07:22 +0000 From: Jacky Bai To: lee@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, dmitry.torokhov@gmail.com, a.zummo@towertech.it, alexandre.belloni@bootlin.com Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org, linux-rtc@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com, festevam@gmail.com Subject: [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support Date: Sun, 29 Jan 2023 15:08:21 +0800 Message-Id: <20230129070823.1945489-3-ping.bai@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230129070823.1945489-1-ping.bai@nxp.com> References: <20230129070823.1945489-1-ping.bai@nxp.com> X-ClientProxiedBy: SG2PR01CA0170.apcprd01.prod.exchangelabs.com (2603:1096:4:28::26) To AM9PR04MB8650.eurprd04.prod.outlook.com (2603:10a6:20b:43d::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8650:EE_|PAXPR04MB8815:EE_ X-MS-Office365-Filtering-Correlation-Id: 41d01fba-adb8-43cc-1809-08db01c7778d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tTDx2U4Yn9cyj8JLh3/hNOM6ocxhimp9toxB1UknUaMV4V2My89fTgi2ehn16jTa4sDCD0NhiRSmiBmvA1UiCWF+KDnTc3jnLMmoF+Kua0KjKHf/cwjM4Sz4ZUz6rIkeDW4RlfFBIvVVLaf4jAwhIUaqH7+WeQIa/zD6iYI2kinXD1gdsIoa5pmM+g90v0/6SHv9Bx5e8QHjdTH8jei71m9r1bj3mrEEM6nGp3TUKZ+Xbw30qOJ+KfhAXdngbc6Fx2O9yUxcP38eQx1Gt6d5GyZD0J4xoPT9FWRANuYeKsKtD2632sxxodGKc49NMLz2m5Pb1T0K7ZrkuufI8PbYGJ+EmIxlqHr9yD1HKUTcGEdOnLo4UvbbGc2nvNddQ6GsvuOJgbrNvo3KRNHdVusuNoEX8kAqTt94kw18iG54IZHa2HZYfDi85TR8AZc9a6WcUMd8+5r98pP+YhN3GEHg89ezaR9NTx3y6dhL/HmtwF0yQYq4x4ZH9LCn4nzOhkpT7BuhvIK5OFSmxEoWdD/WFow+DzSsSTcOk7pPJt8StHu3nXcC9mIPauXNpYQ7BbwAf15AdYJT5e27fjDHn3R4XcPm8W57pBuFdHOOFzfZD23EY1S3hbhtycxtWN6JLIvdLff1QJ6j4og2ZOhK83BE5YJFnTg/yyI4TQzmnizXweJ670USAp65/a9P3yoWpUdy05HCEeFKNGm+J0TnShpDVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8650.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(366004)(396003)(346002)(376002)(39860400002)(451199018)(2906002)(36756003)(52116002)(7416002)(478600001)(6486002)(38350700002)(86362001)(38100700002)(41300700001)(2616005)(1076003)(6506007)(66476007)(8676002)(66556008)(4326008)(66946007)(316002)(8936002)(5660300002)(26005)(186003)(6512007)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rZV6u3/UAcHwTDnDwf8keKYgS4tZOOlD4BFy9Ibe3aKcfwKmSqk+VPeZziC7YIno0k9HkD6ZuDyvxgWBiXefkdJhMgOqNFPLesH/IZ8YJhFZDIAL+5hBg3EF13EHTkaTEsP1OOwVLFEoNn6monP+nkhh7JLI+p6Fx184UG++T3Ld4E7+BCKwtjHQRoaVrV741p+QWWWeEsw9KQgpbbAXuUG6iuXStUtfoRMR1RvA6zXiJuF/6B32zraFTGc/kuP87+P4V3SOa5yFL+Ubi+OmCSR4FSubVcLOZnlT9ZHZ7WRFuf/LYCpUGT8ViBh8yoWH3A2v7s3vfobQoq0yrrONgpfYrhjy3tZgMv5W3CS53TuhOnJjJsWNiJOkQSPpN5q0PwfwZaDhbXBV5EK49RCTPv30jkfYLud5/2/Jsk+mUL8D/9utvO6qHKllDaA8bVx/fvyGuO4POnPIZH6Cid7Rpw/V+m8yQnyO7ZNCn1uFiT9VjxohVqdr4lePAJ8aC4enrjSZluhtdrrNdlbIzZe9tIiSMDYfxIYGNLMym8d8/DB/+dHzoyegU4zGOc3asACxhrbrEkGHV2syjpJfaaDDIE9IkE4/hkT+YKKO11pj3ZWnscmY2WO7Eb83e2/sr8DWzokcSiy/Lq4/hAehKnaibPkVAbfBVnJDQnGnkGN1GHC2Fim00VAWCw/9kSDbA1iQCVWvs6k+jg2EHqeMlXLMwDHpwJL7452ESAoJ26un2dcFtZuXcF+qbvXgpAe2w0Nfo7DhvVqlzqX2w6hAPSUQQmPEyhYeBp0TYIjdTB4m3XfyJUcUf4hdduLzkpBtwEO1ma40dmgRrtaDSozj6JparRrVPWL/gBOkAaDs+UyLbqVkwhdn6Ysx/+Bmj4T0LVu/G/CB6Y5+mHQHttXrypyMoNN4WuC3ASRhFwKyE+60mMGnhYCWcB1qYgEsSWADo7yjg0p5k5lR1v4VYzkPMWZ71PWRWbvkCxXTvFjKYaia2xVWYtzbKJIGu4FdrTNYnwAExde8ol97B4+KdjOKSj/cEcnaFR51WI7zrzracyMhpI/jXnDV98TtLABXOWc9nGkckn82ZXY5NqQwl7KWfKJW8pZePxrauu/skDyX7WFLQErqt3B4zpnA/R4S5nINvIRPTyoottA7U4MRuuXSI9iN7Xt6KKi+MLqKYqpqH066SdWS1IO1uuTHwaSG1f83+cF9eb5W9uOI2QluW/b0C+tLheE7NSEyos/Eri1kQpzP1RzkwGyVSA86UdUznta4VjZP5MnxzJ6y1ibHMJ7T8yYQOyXGHVkQrVMUI36cPlla/iIuEjdymqtaI3Ihnmhgwq7vFjvkgNPaEWvO+xEUc3tf63m6dH5H30LJSo8E7oDdLYqOWExk/NeOunIonO00ZY6FWbOcZpveAT0W6R6nan6WTLYvoC65hQiykY8CDUI1DCCQTk4uGBkgK3Sc27XbkwGXSoR2qHqvungSzGs2SMBZTJI7srWq8aS4ps+IvEOUULyRanM0tKHTGYCazR1jieJ7qEZd2IsWO7U83pxz0FPWs+TYssMyXxGzsRn4rB7ApLjPjBECGqR1vUfhdXSbPlQP X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41d01fba-adb8-43cc-1809-08db01c7778d X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8650.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 07:07:22.0944 (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: ADEnG6cmfW7/1CMZ3PvWQyIbkbEwGxO7MuGFue3VQeXEHZ9mfNtZGK9EDKGqL83d2Oo6g6KNkdNIbrT1Jz8awQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8815 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230128_232318_469279_BE51EC1A X-CRM114-Status: GOOD ( 31.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ON/OFF logic inside the BBNSM allows for connecting directly into a PMIC or other voltage regulator device. The module has an button input signal and a wakeup request input signal. It also has two interrupts (set_pwr_off_irq and set_pwr_on_irq) and an active-low PMIC enable (pmic_en_b) output. Add the power key support for the ON/OFF button function found in BBNSM module. Signed-off-by: Jacky Bai Reviewed-by: Peng Fan Reviewed-by: Mattijs Korpershoek --- - v2 changes: - use device_property_read_u32() to read the property - clean up the goto return, return directly - sort the header file alphabetically - rename the file to add 'nxp' prefix - v3 changes: - get the regmap directly from the parent node - v4 changes: - update the compatible string to align with binding file - fix the device_property_read_u32 as stated in v2. - add back the 'dev_warn' for 'dev_pm_set_wake_irq' return fail. --- drivers/input/keyboard/Kconfig | 11 ++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/nxp-bbnsm-pwrkey.c | 192 ++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 drivers/input/keyboard/nxp-bbnsm-pwrkey.c diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 84490915ae4d..43827e34f276 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -456,6 +456,17 @@ config KEYBOARD_SNVS_PWRKEY To compile this driver as a module, choose M here; the module will be called snvs_pwrkey. +config KEYBOARD_BBNSM_PWRKEY + tristate "NXP BBNSM Power Key Driver" + depends on ARCH_MXC || COMPILE_TEST + depends on OF + help + This is the bbnsm powerkey driver for the NXP i.MX application + processors. + + To compile this driver as a module, choose M here; the + module will be called bbnsm_pwrkey. + config KEYBOARD_IMX tristate "IMX keypad support" depends on ARCH_MXC || COMPILE_TEST diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 5f67196bb2c1..e34dd65a34c3 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o obj-$(CONFIG_KEYBOARD_APPLESPI) += applespi.o obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o +obj-$(CONFIG_KEYBOARD_BBNSM_PWRKEY) += nxp-bbnsm-pwrkey.o obj-$(CONFIG_KEYBOARD_BCM) += bcm-keypad.o obj-$(CONFIG_KEYBOARD_CAP11XX) += cap11xx.o obj-$(CONFIG_KEYBOARD_CLPS711X) += clps711x-keypad.o diff --git a/drivers/input/keyboard/nxp-bbnsm-pwrkey.c b/drivers/input/keyboard/nxp-bbnsm-pwrkey.c new file mode 100644 index 000000000000..154ce58b9d5a --- /dev/null +++ b/drivers/input/keyboard/nxp-bbnsm-pwrkey.c @@ -0,0 +1,192 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Copyright 2022 NXP. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BBNSM_CTRL 0x8 +#define BBNSM_INT_EN 0x10 +#define BBNSM_EVENTS 0x14 +#define BBNSM_PAD_CTRL 0x24 + +#define BBNSM_BTN_PRESSED BIT(7) +#define BBNSM_PWR_ON BIT(6) +#define BBNSM_BTN_OFF BIT(5) +#define BBNSM_EMG_OFF BIT(4) +#define BBNSM_PWRKEY_EVENTS (BBNSM_PWR_ON | BBNSM_BTN_OFF | BBNSM_EMG_OFF) +#define BBNSM_DP_EN BIT(24) + +#define DEBOUNCE_TIME 30 +#define REPEAT_INTERVAL 60 + +struct bbnsm_pwrkey { + struct regmap *regmap; + int irq; + int keycode; + int keystate; /* 1:pressed */ + struct timer_list check_timer; + struct input_dev *input; +}; + +static void bbnsm_pwrkey_check_for_events(struct timer_list *t) +{ + struct bbnsm_pwrkey *bbnsm = from_timer(bbnsm, t, check_timer); + struct input_dev *input = bbnsm->input; + u32 state; + + regmap_read(bbnsm->regmap, BBNSM_EVENTS, &state); + + state = state & BBNSM_BTN_PRESSED ? 1 : 0; + + /* only report new event if status changed */ + if (state ^ bbnsm->keystate) { + bbnsm->keystate = state; + input_event(input, EV_KEY, bbnsm->keycode, state); + input_sync(input); + pm_relax(bbnsm->input->dev.parent); + } + + /* repeat check if pressed long */ + if (state) { + mod_timer(&bbnsm->check_timer, + jiffies + msecs_to_jiffies(REPEAT_INTERVAL)); + } +} + +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); + if (event & BBNSM_BTN_OFF) + mod_timer(&bbnsm->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); + else + return IRQ_NONE; + + pm_wakeup_event(input->dev.parent, 0); + + /* clear PWR OFF */ + regmap_write(bbnsm->regmap, BBNSM_EVENTS, BBNSM_BTN_OFF); + + return IRQ_HANDLED; +} + +static void bbnsm_pwrkey_act(void *pdata) +{ + struct bbnsm_pwrkey *bbnsm = pdata; + + del_timer_sync(&bbnsm->check_timer); +} + +static int bbnsm_pwrkey_probe(struct platform_device *pdev) +{ + struct bbnsm_pwrkey *bbnsm; + struct input_dev *input; + struct device_node *np = pdev->dev.of_node; + int error; + + bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->regmap = syscon_node_to_regmap(np->parent); + if (IS_ERR(bbnsm->regmap)) { + dev_err(&pdev->dev, "bbnsm pwerkey get regmap failed\n"); + return PTR_ERR(bbnsm->regmap); + } + + if (device_property_read_u32(&pdev->dev, "linux,code", &bbnsm->keycode)) { + bbnsm->keycode = KEY_POWER; + dev_warn(&pdev->dev, "KEY_POWER without setting in dts\n"); + } + + bbnsm->irq = platform_get_irq(pdev, 0); + if (bbnsm->irq < 0) + return -EINVAL; + + /* config the BBNSM power related register */ + regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, BBNSM_DP_EN, BBNSM_DP_EN); + + /* clear the unexpected interrupt before driver ready */ + regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, BBNSM_PWRKEY_EVENTS, BBNSM_PWRKEY_EVENTS); + + timer_setup(&bbnsm->check_timer, bbnsm_pwrkey_check_for_events, 0); + + input = devm_input_allocate_device(&pdev->dev); + if (!input) { + dev_err(&pdev->dev, "failed to allocate the input device\n"); + return -ENOMEM; + } + + input->name = pdev->name; + input->phys = "bbnsm-pwrkey/input0"; + input->id.bustype = BUS_HOST; + + input_set_capability(input, EV_KEY, bbnsm->keycode); + + /* input customer action to cancel release timer */ + error = devm_add_action(&pdev->dev, bbnsm_pwrkey_act, bbnsm); + if (error) { + dev_err(&pdev->dev, "failed to register remove action\n"); + return error; + } + + bbnsm->input = input; + platform_set_drvdata(pdev, bbnsm); + + error = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_pwrkey_interrupt, + IRQF_SHARED, pdev->name, pdev); + if (error) { + dev_err(&pdev->dev, "interrupt not available.\n"); + return error; + } + + error = input_register_device(input); + if (error < 0) { + dev_err(&pdev->dev, "failed to register input device\n"); + return error; + } + + device_init_wakeup(&pdev->dev, true); + error = dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq); + if (error) + dev_warn(&pdev->dev, "irq wake enable failed.\n"); + + return 0; +} + +static const struct of_device_id bbnsm_pwrkey_ids[] = { + { .compatible = "nxp,imx93-bbnsm-pwrkey" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, bbnsm_pwrkey_ids); + +static struct platform_driver bbnsm_pwrkey_driver = { + .driver = { + .name = "bbnsm_pwrkey", + .of_match_table = bbnsm_pwrkey_ids, + }, + .probe = bbnsm_pwrkey_probe, +}; +module_platform_driver(bbnsm_pwrkey_driver); + +MODULE_AUTHOR("Jacky Bai "); +MODULE_DESCRIPTION("NXP bbnsm power key Driver"); +MODULE_LICENSE("GPL");