From patchwork Wed Feb 15 02:41:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 13141243 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 AFD54C05027 for ; Wed, 15 Feb 2023 02:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbjBOCkD (ORCPT ); Tue, 14 Feb 2023 21:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBOCkC (ORCPT ); Tue, 14 Feb 2023 21:40:02 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2066.outbound.protection.outlook.com [40.107.21.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A23631E3D; Tue, 14 Feb 2023 18:40:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K4YY1XtAPMD7UKNRzp8QG3eyPZPJp+S9dBfAfRloez8xE5LPjyArjANiUBRAcLCYLhj0KoUp0pCZDzZc4xYQIb4hNZYSLuroPGaSdztzt8SWUAegU5WQQHFBw21JEBuBEaXtz4g+Cn4PvczAUm3VD1poPvUXqNISPzqERHn+BGY/agPBTJ9DxtKqJVxhFBoy2P19H6tVKbQrlKp6CPmPlI+f1atGf5Zl64v8o291Ekoz4FZP6ufLsTY9c8CDWuR/R79S2SybppzUMv5AnAMePGuvSpR6RfNgphSKjbp1ApwX8GHZo/umxxsM/fV2dFfX1t1BThTsSxNj0NPuRG3LsA== 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=OSKnKHSLHsjfO8Wwj5ZDytRSX0ZESYsBYAc75v/z4Jo=; b=GJptRkCJsw/g4UvbTLz8LCXHjctetHFQRRXUUe6EAN30dtM8TBQb0pQJndCwapbrxeBqD4lYIcXtlIzEHLY1yn5LNsUTd8gQ2YmG8dYomHCGxu3NlY2sd/CwsnxM31agDQiXVWzvQkPC/RlrZ+clHOicVMQndpRVPwyHpI7IcXgnmyn9Nuxfj+LlxhDYtIOlma9id0rOeK6xwANnVfYdzgZW1uf0RYlAuXFPvOkQWnb8q8PHF7daqeQZlDbXfS9Jkj2vF2DPmHc2CkjIGNa6GDpFizE2fMrgKXjDBFD3+MO8okCqcpNFZwuYc8FRrfDTQdzoT7GT69Oc8dCslxSGOw== 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=OSKnKHSLHsjfO8Wwj5ZDytRSX0ZESYsBYAc75v/z4Jo=; b=qg6ZYk5IsF/ruzNAcc0X1EFA1XivOZ8L/UPBJX2K8wzE64+ap1LRbBcrWngkDkJccuSGi1YwxF3Jkv7lFGL2j2mbJCIuOR80tjf5xGz9Z42kc3syPCE6MiI8R+WDzSkjgBC0Y+a+MveqR4V/g/t7zpdWdCHTi6IAL3Kmk+vPyWs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8642.eurprd04.prod.outlook.com (2603:10a6:20b:429::24) by PAXPR04MB8975.eurprd04.prod.outlook.com (2603:10a6:102:20e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 02:39:57 +0000 Received: from AS8PR04MB8642.eurprd04.prod.outlook.com ([fe80::1793:79b4:2cb7:4db]) by AS8PR04MB8642.eurprd04.prod.outlook.com ([fe80::1793:79b4:2cb7:4db%9]) with mapi id 15.20.6086.026; Wed, 15 Feb 2023 02:39:57 +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 v5 1/3] input: bbnsm_pwrkey: Add bbnsm power key support Date: Wed, 15 Feb 2023 10:41:15 +0800 Message-Id: <20230215024117.3357341-2-ping.bai@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230215024117.3357341-1-ping.bai@nxp.com> References: <20230215024117.3357341-1-ping.bai@nxp.com> X-ClientProxiedBy: SG2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:3:18::19) To AS8PR04MB8642.eurprd04.prod.outlook.com (2603:10a6:20b:429::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8642:EE_|PAXPR04MB8975:EE_ X-MS-Office365-Filtering-Correlation-Id: 62c91766-37f4-495b-0f16-08db0efded72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: efw7kObRbuEpr2YKp6oO56mhSExllALJwggq07kwe2VMPChDXOkE9mu1ualh45cX5JrJOm+RD8AYRrz+UhH8870D8P8znky4pYgIFuDRZ66O6r3S/ZMBa/7M4VOOyVmEOBpUGBe7Z2+4uaHQf8I+VSoI3RyMXunM64tRr7/SX6tKPeM0g4RQUuspyTwpD77Fq1G2w7id/f41bPaHxta/xHNFhHn3+1v6w1nFggi7iFdhyLqgJmGnC3QhPd8RVXxrpGRoJ4tCLh5UM+6XTOE7CqU/gjTkck6rIl3xg1Tf8eSA3akwT47jY/bTww6yyd68dQUaBgwChTRQg8WCPVDPcSUDcCxvV7HAdKg0t4m8aCKSZ6LSwpR5rMhad5OqfVqzN6d6FSheARzDuDS09LBcwHoqs8NaBsnEkVy0MjIZxOXH8tqvyVBvPhNW511kwGVfk/IDF6S3koLZVxYwFi7PtGztq1Cir5YfGlX0tqStNImnZVez3jhKKL46IXhlIYqVu+ignTTPTdSS7ehuChqGGhB0y/4vZ2arMWPyKoOCS6VTg19Tn2+bU8xIRoNnguwG/8M3f0l/ys0u7LxIchKf/S3ZpLRQv3VbQHkjknxiZJisQ8mW0iaDeGdz47qLNuzl8LIj6kUHpcbfZDChHmINUONSx/6WjMVr5e2XSEFxHZ180DJWWIDv/9Dl94/2naxdoXr+5HIZmDXC6nHhNr8bSw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199018)(38100700002)(38350700002)(1076003)(6506007)(6666004)(36756003)(52116002)(316002)(7416002)(5660300002)(6486002)(478600001)(6512007)(26005)(186003)(83380400001)(2616005)(66556008)(66946007)(66476007)(8936002)(2906002)(8676002)(41300700001)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wFX9K5AEIKc1kNiZPak9GTnkuNsmKcxFZqBx2+eoZ6AUy8v+TQA8YC4QSlEmo9IkdrvM6G0WC5f2PDC/5Fm/iyj5De2dekHl3uMmNzMBb9dUjLCEjsCh7PsYfiJnKt3ILnxrY60YowxTjHb5NQa+omnun1R4KG1hUixmFQKlkvCDtHdFf3YxYwH3WaoJ6IbQmz8I7E4eQeoCoifxqEyT9Cr8aARoGQIA9IqkD7Z1OUJx3JMT10OuujwkIzoGgQxD1AG34fSBVj1CXuryEcdL9GuuO5OS7UIIqn3p9OET6zeM4FEeFE2+/y0uCkruwmqLiUQIKqXH3AWLgfQFoMY2yQ7u4gnPeddSEcjqoK8+qdv3U6KYER5HMA2m7AzlUhvHQEZDt3XIGK+an7BjYxfQjQVGqFDEZ5Mindg8S7w8RhN1r+NYLk1DH16OsmXJUV6Gq4oarJKMYDXfwlX0Q9evA6bsaCeGNC3z82uW3ELNtfQAYwLorTAnu11kUzgDQz50diAVRQWR+1FOJ86tTOrUv9j9GsSWhxhRpSY5Pb+LK5TPo6pOBSc3pO2sC1QinJb1HbWWeK2+BEkDH+2xP1Cc2jh53RoEJ6QF7Jd17SSOiHBbhruAqzFnuN2XeWWJc29y+qeSx70CDZOCpLX/vaUIjiL0ZoUlZEpg1DlDPx/+Rm/N7SB2OgaV30sw6rcagfKQf93+KkBo0d32z8GVv0H1/EUwdQbJ9F65H3eocQtrXXRSqXYh7baviDs+UC5WWKPs4E4/EotimsuMTbrEm0u4PEF58JmhGKjQUVXjFSvHjY8mksCznU153e3ula7gq7/wDPy1EqKZ2tQfUCGlXYKrQrQZx8zJ45RmaJ0z4blRgURI5Xp2MiiQQPCr+oxMIiqX//GwJBLFEWxcSwBWKbjT7fARvQdP9s8hylBhoUW8zZKwOKPizu4qPyrNkAUWdLBGYYT6xByvrkXbrG5cgdRXbAlOO1eGxQ05XI6dzQIJo3Ci5VQMxABlMiAo+tQI0iji4aqqpSl8upMHpe0UQb6rZ/uiv+pEnGY0g4lWeZB9W7Ju3h3+Zz0OY1jwRBd+eaZMs9X6wp1J2TyIlHJNZGcNvDVT1f7/340urljI09pxB1/0UlaNX6wph7cDNyXJvEBYFXTtQayeiSr4375gspWKHpy5vSuCKl6Ph+p3Per5L36AEMEYi1zex7VcT2vdG2tSgacAcRaIz0weW7W3YDNyR/AWa+5lXLlTtBf0VgdnWO4tO6X641jpBiowUNVwgfFnLodfPnY5L40NokvsF6LCWL27TUacPi3qexrKaJaFYjHXvuXu2myQ/kiMzs1X2CvMrQFzG74WYpEF/JzGDy7/uLDlBZQRd0tx3kON/++i3/TrsHLVfdGX94++3Dd8CfF4Xb92/xUYgBTkyJJZwzZ/F4r5Su7GVJycxHabfjN3FGuSWrd4YvjGxEs3YwnemytPitpz94/bpIMM8ECX9p3VPfIBZBbdZHOSXC5ClAsTX3SGQAam0Dj1F0EBjNH9GHw2q8mFRKM7LYD5XjpcDHJshJ36z1DQRX+LtlMiPT//JnnxuIKAmPHfNFwJ8+EcEyfs X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62c91766-37f4-495b-0f16-08db0efded72 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 02:39:57.8100 (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: haIVytBqmuta7kORlW5yDgfeCl1lmhrw1lco84R+jfljiiWxkbbBso5+LGnMqQU21qS7AtEZzKiHI/LKx5AdFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8975 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.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 --- - v5 changes: - move the bbnsm pwr key driver to input/misc as Dmitry suggested - replace del_timer_sync with timer_shutdown_sync() - minor refine for error log string - 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. - v3 changes: - get the regmap directly from the parent node - 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 --- drivers/input/misc/Kconfig | 11 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/nxp-bbnsm-pwrkey.c | 192 ++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 drivers/input/misc/nxp-bbnsm-pwrkey.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 5c2d0c06d2a5..81a54a59e13c 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -119,6 +119,17 @@ config INPUT_ATMEL_CAPTOUCH To compile this driver as a module, choose M here: the module will be called atmel_captouch. +config INPUT_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 INPUT_BMA150 tristate "BMA150/SMB380 acceleration sensor support" depends on I2C diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 61949263300d..04296a4abe8e 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_INPUT_ATC260X_ONKEY) += atc260x-onkey.o obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o obj-$(CONFIG_INPUT_ATMEL_CAPTOUCH) += atmel_captouch.o +obj-$(CONFIG_INPUT_BBNSM_PWRKEY) += nxp-bbnsm-pwrkey.o obj-$(CONFIG_INPUT_BMA150) += bma150.o obj-$(CONFIG_INPUT_CM109) += cm109.o obj-$(CONFIG_INPUT_CMA3000) += cma3000_d0x.o diff --git a/drivers/input/misc/nxp-bbnsm-pwrkey.c b/drivers/input/misc/nxp-bbnsm-pwrkey.c new file mode 100644 index 000000000000..737e202ec513 --- /dev/null +++ b/drivers/input/misc/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; + + timer_shutdown_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 code is not specified, using default KEY_POWER\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"); From patchwork Wed Feb 15 02:41:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 13141244 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 E0A6EC05027 for ; Wed, 15 Feb 2023 02:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232227AbjBOCkK (ORCPT ); Tue, 14 Feb 2023 21:40:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBOCkI (ORCPT ); Tue, 14 Feb 2023 21:40:08 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2047.outbound.protection.outlook.com [40.107.21.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D87527D7F; Tue, 14 Feb 2023 18:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h2MQGQib/WxsxMqvOh/itCuQReN3Jcpj12EWn1IAYepESVhtrgvfz1S1yM5whF+f4J69ZBGgqCluIYGORSRhuf2CtbmjfIvQ2UL3LfV4nhZYAHoOZd5n6z+jwu7xXpWLmIvTy7eBs/FYJRWcM5pnKSyuE3iZ3dMDl3EWYfEyxVbmnFCO6kdGdC2oAs2O6g/7Cqej24+vCdVWv1tsyc4hC1OgfwylKJwvUBqYk+P+hA55dSBhXm+IVBhQ71pRZi/FNCKBzqlWwhYJ5uU+8qBaV0jdQINaiVfbbPBv/gA3ls0wR2u6NKkUJpk5RSa0bU0QM46PVSgofKJu2MFlOtY8bg== 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=NHLnuvufeLEiR8ZNb/p3qZoiysEvRUMqO4eeZE3I8MM=; b=QXIh918xYQiAgbABB6vtpHAt0agdgsPMIO2nVd0vYpZEXYMsL/p1s/MJAdUTNTooe/S0b/TwQbS5UTy/vuIn4mWAiVfVtR/HdO0N6FA16x9uExT4PxBJjEhY7l7zODCzRkpfYG2CwuxNu8/GvFp7FTFlOv872OPwtxkXZYo+J0aUQqM3Z4eI6OV3cfEc/RjzRUfG9R2dUqPIiCaMQ3d/9KxaJjYkgM4el1qUdjWUK+2PTMN9kTHkureVZrexanPI5wDSVn6MD1VNxe+SFzdTUDvt/1VbgFeG2qgxjqndIqViVvkkidMXLx8nOEzw5Fp6lbpWeE4L5VDXzW7yWhcNCQ== 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=NHLnuvufeLEiR8ZNb/p3qZoiysEvRUMqO4eeZE3I8MM=; b=L3FunGHOHbXrhQvfOb4oshNzBuvgDse9NUc4E4HOcmrXbrFt8nFe/7+LXNhaSkg4Gg8NmDVW7zHQOX9VWVSr3D2EbKo976jRIHxV/WDn0rghj/l/YfdwBW225RkneJKYX25RNDew9QGhRCvLD+7WngxRacRQABw2OIFoIkezK1o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8642.eurprd04.prod.outlook.com (2603:10a6:20b:429::24) by PAXPR04MB8975.eurprd04.prod.outlook.com (2603:10a6:102:20e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 02:40:03 +0000 Received: from AS8PR04MB8642.eurprd04.prod.outlook.com ([fe80::1793:79b4:2cb7:4db]) by AS8PR04MB8642.eurprd04.prod.outlook.com ([fe80::1793:79b4:2cb7:4db%9]) with mapi id 15.20.6086.026; Wed, 15 Feb 2023 02:40:03 +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 v5 2/3] rtc: bbnsm: Add the bbnsm rtc support Date: Wed, 15 Feb 2023 10:41:16 +0800 Message-Id: <20230215024117.3357341-3-ping.bai@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230215024117.3357341-1-ping.bai@nxp.com> References: <20230215024117.3357341-1-ping.bai@nxp.com> X-ClientProxiedBy: SG2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:3:18::19) To AS8PR04MB8642.eurprd04.prod.outlook.com (2603:10a6:20b:429::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8642:EE_|PAXPR04MB8975:EE_ X-MS-Office365-Filtering-Correlation-Id: db59e998-c040-496a-6969-08db0efdf0c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6tboYd+VRLLTZufY35iGTy142+EngmEUuTrZrOogYUEjA4XDDuI16TkxL6sWPSdaBvq5Chn5J/KCGNvTsAiMyKfokQ6eunpoBK6oj11XD9vUJ7s7M2HZ/WV5VTPZcYVrmLo2crty9jk70Yb4XpaivX9gN/WefjvRlSTAID++8uCyUBORH6AIOH6WoVcGKSXVgF7bWRJygWTyps94OYApNYM9gCZaHw3f5sw2F/i2xMDUqhz/fPssqW3uL6ZAg17i5XvnMPqP6HxfOKpaztsi1cNMVX/6nAGYcfeNd6wvy6TrWzRo4kjs/9pEQlCNfZ/O91Em8q1VqK08oRyLzOmnGgI6eIHRyCtcDggFMvWSYtFGkpq7kl01TY5Vfrds6Nq6KLPw0rj8perVA8nHA0N9U2i2PejNpYSHqDsHGMEITu2qhPqaUJENhk3a7ySUv/osHtuYwnbBWOGacnc7vSo5HgyCb8BIEBmYz7c7mwszyFuA2QEeRwH2VllFygx1e+nhuJeblZbLx1du5wJIzJ0ItaQIMZorlgIsrHiXy1lb8v3tmPouJERCWCNHPomv8PinnS0854EtE0BC3jroY3QuvPqY08ODm3VdKNmXsJunUoM7LQ4wm32Ls++LopGySwIh032cCtRKU0AbhaQkLxyGPcBfmGG7gLUpjDR9K5lVQ/BRz/u9zDufzzvxRlVJl6z6S082Wxd4KpVoDH8wWzvTiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199018)(38100700002)(38350700002)(1076003)(6506007)(6666004)(36756003)(52116002)(316002)(7416002)(5660300002)(6486002)(478600001)(6512007)(26005)(186003)(83380400001)(2616005)(66556008)(66946007)(66476007)(8936002)(2906002)(8676002)(41300700001)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VbiHrZSQGqtWW4RIjxQF20tKzx+3rQZDwse75GCLbSK+xAYgQr0swK00RGKWLnaoYbWrzhBJAL8TXE1+FmP1Nu3N4XK1J3dur05yWIf4OsTQypIDOdmZjdTB+RA/2MLzHG8NYob5zbtafuiZMNk7HNJy0IgnggjJkJ0+pp1fl63XikMKQpnewqzQ80igUY/5wlzBTHLfqRxHYiDdYrlku5iLSkQnLZf/gfwbQwYiwPsgWRdNkowIqLfSujhErlHqcvbz0lPzLkltEH//xgplVxAsJg92ZVevLDV6UJoYo374AGBs5eRAfNAHbQ3aCsyi/l1kRy01ZhAtcBhxghVITbzTTijz0D0skGEJpg1oPBAqXQ1+MvNUfBc+b6GhVjBSU1LxX+/0iK9e0estxXCLwtM4VxepQdH82fCXHZF82llA7nOSN1yuKGPy3zIgw8jt3IBHApJYFgjZkomtTlGquFw/jJ+MSfUNh1sh4WBWk+Lk67AIbiLAnTukWWSHzI/cnuF/O0Ptt395MRisLW+wjW+pCqvFpjEoheof+Uk9o/TQnvnl2I5+/YbYy6a3MdoiQGzl3rYPZ6p7cNpLvRb17Vf/BR08vccGStjZWpgabdWawS5yt9x17SJ+ZqZdYfyHfLuUrfRfgG63i9580EHXVIpcCx7F10mF6T405iqkE7kCjoePAWahGo7P5WkOueT4pNBVJVnKMZRhceVou31nC0BTJmkMDeQvbLC6vTFR8ck1/8bh2HhDp/rb0+8sEit1MyO2Kpc+P7VAR5dEAgBnzgWsR/ccRbEspwNO9FhUQoMruXzUts6qEKRw/noEx8V0FjC3hxCwlV+TZJ61wFAdybImHs0PslCXBVR0Ynxq13AoRXCync9LiE27lwZZFPzEggMubiY9XjGGnY4vGHTBJpvM9yM/FQ+PQSH5XJ5ktIwPSmVIGMJ9bQ/godQrVbhGoIZ4jRU6mw6XCDaM7RFdffBPpvgV8fKhwxsFk1rVP/eX4SoNFVTjgDSYXRT9ggZebyxPiXJLffKIQ4jR5kRkW1NkiCHGR1FDioJP0KyfROWgFM39JjVU+NWbFomVVuTlt76cQ1gJ2tGcMi4XrAMOrVar9dP+txudNhP5BO735RM9VhvweEbt+vPPVDrtjzm6q3AXahkkgz/bBC4MM/8m/ImnbRjJFRACjG6+xRhj4l6YZlTEswMfxmX7/IxEkwCbGz+8gttL9Vc9XeWGFdHvA8ulHrPgAtlinL+9xg3skgnT/Y6LQKKE4BMucRYOxIwXB5TVsvIYNKV1CBZAvEYt+s9URNTQ/aOn6xDC7/B4EMa0u1YD0sdmQyRzoJUHhf/rHvqOeG4l6jcfOwsK+zdkxU7cl7cjZopjpb5R7cHpbNblC8qJmQwcOOMf9tYlTFc0An/6xVgY+ixL9n1cnkSROIkw514i1pHdhIu+KDjZQiseGvcpgpkV7RjXD4bSjDp3wFN4oqiy7XqbEpFIxMnvt/cahut6AWthU+ibrrsr/0aGvD3X90BCNA2kw9fOI+JcRXATODtLhP4ZW2VRdPni+YpMcHOL5D9X0sRx1YFG/bnTrtuAYXoUa/sXVX40fkbP X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: db59e998-c040-496a-6969-08db0efdf0c0 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 02:40:03.4681 (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: XuEDwdS07frAVSv/kA5LCtf3ih2u6QRJEzrCWDKQTfyK1Q7pkoy6vb49vgl4Sqz36IEHavj6Xkp/lGpy5rDvuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8975 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The BBNSM module includes a real time counter with alarm. Add a RTC driver for this function. Signed-off-by: Jacky Bai Reviewed-by: Peng Fan Acked-by: Alexandre Belloni --- - v5 changes: no - v4 changes: - update the compatible string to align with binding file - v3 changes: - get the regmap directly from parent node - remove unnecessary dev_err log print - v2 changes: - sort the header file alphabetically - rename the file to add 'nxp' prefix - refine bbnsm_rtc_irq_handler function, remove the unnecessary event variable - add rtc enable check in .read_time, remove rtc enable in probe function - remove unnecessary dev_err log in probe function --- drivers/rtc/Kconfig | 12 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-nxp-bbnsm.c | 226 ++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 drivers/rtc/rtc-nxp-bbnsm.c diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 2ba72de0fa47..13c9c57aab73 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1773,6 +1773,18 @@ config RTC_DRV_SNVS This driver can also be built as a module, if so, the module will be called "rtc-snvs". +config RTC_DRV_BBNSM + tristate "NXP BBNSM RTC support" + select REGMAP_MMIO + depends on ARCH_MXC || COMPILE_TEST + depends on HAS_IOMEM + depends on OF + help + If you say yes here you get support for the NXP BBNSM RTC module. + + This driver can also be built as a module, if so, the module + will be called "rtc-bbnsm". + config RTC_DRV_IMX_SC depends on IMX_SCU depends on HAVE_ARM_SMCCC diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 59eb30289335..ea445d1ebb17 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_RTC_DRV_ASPEED) += rtc-aspeed.o obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o +obj-$(CONFIG_RTC_DRV_BBNSM) += rtc-nxp-bbnsm.o obj-$(CONFIG_RTC_DRV_BD70528) += rtc-bd70528.o obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c new file mode 100644 index 000000000000..1009388b635e --- /dev/null +++ b/drivers/rtc/rtc-nxp-bbnsm.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Copyright 2022 NXP. + +#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_RTC_LS 0x40 +#define BBNSM_RTC_MS 0x44 +#define BBNSM_TA 0x50 + +#define RTC_EN 0x2 +#define RTC_EN_MSK 0x3 +#define TA_EN (0x2 << 2) +#define TA_DIS (0x1 << 2) +#define TA_EN_MSK (0x3 << 2) +#define RTC_INT_EN 0x2 +#define TA_INT_EN (0x2 << 2) + +#define BBNSM_EVENT_TA (0x2 << 2) + +#define CNTR_TO_SECS_SH 15 + +struct bbnsm_rtc { + struct rtc_device *rtc; + struct regmap *regmap; + int irq; + struct clk *clk; +}; + +static u32 bbnsm_read_counter(struct bbnsm_rtc *bbnsm) +{ + u32 rtc_msb, rtc_lsb; + unsigned int timeout = 100; + u32 time; + u32 tmp = 0; + + do { + time = tmp; + /* read the msb */ + regmap_read(bbnsm->regmap, BBNSM_RTC_MS, &rtc_msb); + /* read the lsb */ + regmap_read(bbnsm->regmap, BBNSM_RTC_LS, &rtc_lsb); + /* convert to seconds */ + tmp = (rtc_msb << 17) | (rtc_lsb >> 15); + } while (tmp != time && --timeout); + + return time; +} + +static int bbnsm_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); + unsigned long time; + u32 val; + + regmap_read(bbnsm->regmap, BBNSM_CTRL, &val); + if ((val & RTC_EN_MSK) != RTC_EN) + return -EINVAL; + + time = bbnsm_read_counter(bbnsm); + rtc_time64_to_tm(time, tm); + + return 0; +} + +static int bbnsm_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); + unsigned long time = rtc_tm_to_time64(tm); + + /* disable the RTC first */ + regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, 0); + + /* write the 32bit sec time to 47 bit timer counter, leaving 15 LSBs blank */ + regmap_write(bbnsm->regmap, BBNSM_RTC_LS, time << CNTR_TO_SECS_SH); + regmap_write(bbnsm->regmap, BBNSM_RTC_MS, time >> (32 - CNTR_TO_SECS_SH)); + + /* Enable the RTC again */ + regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN); + + return 0; +} + +static int bbnsm_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); + u32 bbnsm_events, bbnsm_ta; + + regmap_read(bbnsm->regmap, BBNSM_TA, &bbnsm_ta); + rtc_time64_to_tm(bbnsm_ta, &alrm->time); + + regmap_read(bbnsm->regmap, BBNSM_EVENTS, &bbnsm_events); + alrm->pending = (bbnsm_events & BBNSM_EVENT_TA) ? 1 : 0; + + return 0; +} + +static int bbnsm_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) +{ + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); + + /* enable the alarm event */ + regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, TA_EN_MSK, enable ? TA_EN : TA_DIS); + /* enable the alarm interrupt */ + regmap_update_bits(bbnsm->regmap, BBNSM_INT_EN, TA_EN_MSK, enable ? TA_EN : TA_DIS); + + return 0; +} + +static int bbnsm_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); + unsigned long time = rtc_tm_to_time64(&alrm->time); + + /* disable the alarm */ + regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, TA_EN, TA_EN); + + /* write the seconds to TA */ + regmap_write(bbnsm->regmap, BBNSM_TA, time); + + return bbnsm_rtc_alarm_irq_enable(dev, alrm->enabled); +} + +static const struct rtc_class_ops bbnsm_rtc_ops = { + .read_time = bbnsm_rtc_read_time, + .set_time = bbnsm_rtc_set_time, + .read_alarm = bbnsm_rtc_read_alarm, + .set_alarm = bbnsm_rtc_set_alarm, + .alarm_irq_enable = bbnsm_rtc_alarm_irq_enable, +}; + +static irqreturn_t bbnsm_rtc_irq_handler(int irq, void *dev_id) +{ + struct device *dev = dev_id; + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); + u32 val; + + regmap_read(bbnsm->regmap, BBNSM_EVENTS, &val); + if (val & BBNSM_EVENT_TA) { + bbnsm_rtc_alarm_irq_enable(dev, false); + /* clear the alarm event */ + regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, TA_EN_MSK, BBNSM_EVENT_TA); + rtc_update_irq(bbnsm->rtc, 1, RTC_AF | RTC_IRQF); + + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int bbnsm_rtc_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct bbnsm_rtc *bbnsm; + int ret; + + bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(bbnsm->rtc)) + return PTR_ERR(bbnsm->rtc); + + bbnsm->regmap = syscon_node_to_regmap(np->parent); + if (IS_ERR(bbnsm->regmap)) { + dev_dbg(&pdev->dev, "bbnsm get regmap failed\n"); + return PTR_ERR(bbnsm->regmap); + } + + bbnsm->irq = platform_get_irq(pdev, 0); + if (bbnsm->irq < 0) + return bbnsm->irq; + + platform_set_drvdata(pdev, bbnsm); + + /* clear all the pending events */ + regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A); + + device_init_wakeup(&pdev->dev, true); + dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq); + + ret = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_rtc_irq_handler, + IRQF_SHARED, "rtc alarm", &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "failed to request irq %d: %d\n", + bbnsm->irq, ret); + return ret; + } + + bbnsm->rtc->ops = &bbnsm_rtc_ops; + bbnsm->rtc->range_max = U32_MAX; + + return devm_rtc_register_device(bbnsm->rtc); +} + +static const struct of_device_id bbnsm_dt_ids[] = { + { .compatible = "nxp,imx93-bbnsm-rtc" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, bbnsm_dt_ids); + +static struct platform_driver bbnsm_rtc_driver = { + .driver = { + .name = "bbnsm_rtc", + .of_match_table = bbnsm_dt_ids, + }, + .probe = bbnsm_rtc_probe, +}; +module_platform_driver(bbnsm_rtc_driver); + +MODULE_AUTHOR("Jacky Bai "); +MODULE_DESCRIPTION("NXP BBNSM RTC Driver"); +MODULE_LICENSE("GPL"); From patchwork Wed Feb 15 02:41:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 13141245 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 48986C6379F for ; Wed, 15 Feb 2023 02:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232712AbjBOCkO (ORCPT ); Tue, 14 Feb 2023 21:40:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjBOCkO (ORCPT ); Tue, 14 Feb 2023 21:40:14 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2070.outbound.protection.outlook.com [40.107.21.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E949234D0; Tue, 14 Feb 2023 18:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gBRk19WhOZAL1XYcGvw1KQi4adJLTnIksU/aHq8QEtP88aFgZWZ2HZ+QgNGqcbFzT+hBAVnAbEJrsSdgFTDEUFuR0MpPk9jO/EPOc8CT4rsDFM1skTWOyBs+RE7ICQCRv3VPyx0BeLviu5dgxGrg2XymHWr/pTk8ujat2n96ieUYJZICn0swk+5GnwBccO25bALBEHV1pS1KFAy69ch9e8++X5PgJgsk6Urc+ZcWZdf0jtR8sfRrxS9EJML1SnXUUlIHTezPx+r/SzIycMdEO29b1NjJol/brDOu37fPSlQRlOFeJKFH6LffhdeT8wfZjPNFmHm1N36j82DI3KIsIw== 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=tKm85CkjahcjaLFmY87weixpk0tv2xQoGwV6r2lIZk8=; b=mwfP/zb0IAWCsdVmxqdXVQIGxy9aNhtf3UWACg+KauEJGg8NgDCOu/lpavN1eyGTeUZ4B+sqpQf+pf6coVrEE6qmUsv+/3dzR/X9qRY1BMw1PtFWUYvEBndn5ACSr4qm/wrN2QMqIoRlakounHw+AnsI56HGaFOBbUuvdC4Rf0hmAITwUH2a/e2EmHGWpsqyHyc7dmQkOT1nMCn0tVh4kj7V+XrPk1AXp562JIxmAxZ8bD6a0xbOUglPnV1P8c4LjfMk/Wt3fpnjCtpj48Q9ADZY6IyWJkCc+/8ji5NJ/8f4O1pAEhztRrRHmUCAaBwT1qnEsoFgMixeRm5h8cJj7w== 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=tKm85CkjahcjaLFmY87weixpk0tv2xQoGwV6r2lIZk8=; b=F2zAq0xf0jil33LtzyhLiaShQIu3EGpcz547NCE1ubhcyCQW9qQJSQcufIjSS5ISUdQTB56FSY0YNz3K2XlLPb+hK/VQ4uPBHuSBaFOZE6UYNzVCaFBi/4vJ4n+JMf0yGUTxbX1K+/5x8in6UoLRvRV6gsLOJNgz/e1Wu/VjNi4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8642.eurprd04.prod.outlook.com (2603:10a6:20b:429::24) by PAXPR04MB8975.eurprd04.prod.outlook.com (2603:10a6:102:20e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 02:40:09 +0000 Received: from AS8PR04MB8642.eurprd04.prod.outlook.com ([fe80::1793:79b4:2cb7:4db]) by AS8PR04MB8642.eurprd04.prod.outlook.com ([fe80::1793:79b4:2cb7:4db%9]) with mapi id 15.20.6086.026; Wed, 15 Feb 2023 02:40:09 +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 v5 3/3] arm64: dts: imx93: Add the bbnsm dts node Date: Wed, 15 Feb 2023 10:41:17 +0800 Message-Id: <20230215024117.3357341-4-ping.bai@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230215024117.3357341-1-ping.bai@nxp.com> References: <20230215024117.3357341-1-ping.bai@nxp.com> X-ClientProxiedBy: SG2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:3:18::19) To AS8PR04MB8642.eurprd04.prod.outlook.com (2603:10a6:20b:429::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8642:EE_|PAXPR04MB8975:EE_ X-MS-Office365-Filtering-Correlation-Id: 59b9b863-5b68-4b3a-bec7-08db0efdf464 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aUvQi5tSFUZQuxJTJG+PSb/I0GutX6Lm7C+NswKCP3eVqprGoeh1THqaQfuxucHGC9aPCy9GEqo2eilNM3IKgBTcHls3/35Mpui5m2e/Ma2R9+SsrDGwObxMpuIJrY/Ck7wXWm/VT24Jxo3FZCQWhINKJ/OOfxvMhONpw4RqeQIZOr47MRGfDwUq3Es5R+eysA7TfAKbRYlKGApzHVPC8TZN2SfX1TpZQMVEdD80PkA9VUrtMK1wo/1Nvi5zaaE5aAHC0zAwd3J5XBo2f0/MOFkcfifmoIqRwoi2CN8zvetwdiA88Txo3IviCnYAtnfs2ypfOKZ9gv49d86k0A09XEuC3Z6nOwdNJRwXMcIiM+0VdpY9P2GrzSXoUZcDRR0LvNxbKmm7LaDUhQqiTxYqmGkIEnEJR8hqdXapOvjmixR5s43MdLhvXW40iteOtVNAcVonb3mMhTrFSgVyUikMEV0GeCcIyWJADuv5szKLuzxOa/cvvORAG1GV8I6sK91++Hpwcfv9PQ2H60Bw8nTLCPcsc/I4Cr3D7mBNSNVPFsJxcQP+N03O84twFqj7qwB+CbQ8QlD2sexg/qjprB5j1waIqByVESfRLt0Uw8hJkCMwPZNaEUn0l2AW0+rl+B8C3FF1bb5fjp+92UbYFA5x9rQ+9Pe7MarvlSqylKyoZ3Vj4oHdi/DWKkEuxG8fg9l+ayWPbrLPH3jErh66u75H2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199018)(38100700002)(38350700002)(1076003)(6506007)(6666004)(36756003)(52116002)(316002)(7416002)(5660300002)(6486002)(478600001)(6512007)(26005)(186003)(83380400001)(2616005)(66556008)(66946007)(66476007)(8936002)(2906002)(8676002)(41300700001)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xFxK0z/USwxMMqR5HoEcX6ZkxRsogAG/6Qa399RQhG/8yUjlR0+f1Ld06ade3CCPJxJSek4+xl3aLK+2yUdCVt1wZp/LKM60HF66tjQvPkftdGkcHIUNWr/U9x6hu3nkm7qHIIVof2g0hPV5D7GFFWARSMhXitBxsCb/LvXWxXWn9OnsE1kIt1OjfuBQAfY5JJuv3jfjDl8mbo/G2vnZfTisvpBskgr86wIRTW6LAcxcKKASlttro0QNtaSYAEMKmtQfUrdcZUZ2y7tj+6l3HtK9x3lX5wJHmBivBRhR2R64WU2PPQC+kLCx9QiP2WfYHfWA+or8RC1/No+2WHsQmEiN1ey1oDE2f3Gx5hxVHxCBD+OJ5D+Dy6oiPlWsPuwueojW9PMdJnUURfDsj+Qq6pUQbnzym1nB4HVuq7dYb1rDXNbIPP+InfxM1LOnVYQaSA2KCCq8U9MkyGcMkfLy28/UZqSUU/TVNxccamCKeYjdeLk7khR6iUJ9qdSyeI2AflRB+7GC5wT9P+BZJIaoach6lAAZLDb6Rg4WH3JHyBLlB/bAYqFLDs8Bg4Fsnyzdal5j8hLVb3T2zCdPO9AptRp1u30N6QABHTnVudFLuHttWSAWL0QzrjV50kPImi0HRxw6AInOBWWhhQ/npaEmDgIzbgTB92cEMZ9mPSBwmWmmjJRs1rqrXU17n46tquqmwI2p//mOwQg4uw1R83RgKDcpjVYaZA77MXZ+rc31vs+sc3Hu7t9fC7OhbXJeU4IrAhlqFrhB2wCqJv1ddGKyWQDEGK/W0vGVjDM/4rKe0AOy6iZZnr9c3Kdm9B49EkMgnl3+FiegCa6B110marUAtzIBFsq6/3DR6Z4IgU/MYpMYOkiNnrUJFWxpZ/rOk9eU7pCAef3jhKktUccmQoWs1/e1mtGNcz64XZFwmo3qhUL35nKuUnnlNsaKhURrs4V1xFQOrnLKV6/J+cKDquoye0UkAS5C/ur1PPUgPc/eRxaw7wCtuG2b9FxK0Z2maUw3FXgQILv6/3m1jYblceAf46CH71eTHH0u8R7omJi2NlXM4VZbjxMA0Km7Y7Xfp8fyJ1ZWmH5g+NhcF7lwPbMPf8Xm/idAPtbxzmQDMf25upyBHbk2JPZc7TfspYZNRxLBxGQC28zZNLkepWN8FRmU0N1/QzigsSHVYO24b3z1O21YTcwhwVxqSE/EH0pTfZRMnfFFsuYPvVexh8E/LUyGBE3/Jzrlm2jqr8eWCL2fl1vVVpUDWrhMv97SOF9GlRzJkFYh7x78N8Ytr1JiW3FXD9bUzPG+ZA7IKHNbALh4m7u4bfFZnrSOw9Ya6zzc9DAFKK3MS6AXOtKEDLlGxJIGfStpApBwc6rV5hveOwzUvGAABeNvFv/Qhg9PrsG1sECP+jn1L6Nc6sMS2OJCPHIoDzHKr2EWuODWVUxYUdFT9ZIJ1a4/is5aoYzTpgVHWfpTiCP4fLRnH4GComQHBS2T8sjsgGp09Wr65frs4lpGrAXl4gpxzeGd0Nw/7QOlo8nfHmDAum+OjFkNvI00K64d7JA4Bnss7+/YAGeptBCo/Jk1gEv2XlKh/pe/xqRxqXJw X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59b9b863-5b68-4b3a-bec7-08db0efdf464 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 02:40:09.6251 (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: FISFfBoKG6il5xpPTJtajEqo4Rl0RqJCXhdkyZBLT8ADa56gudhcP/8Ih8MbM2jMYM0DfvQS/YPQ8PyRU0EgIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8975 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add the bbnsm node for RTC & ON/OFF button support Signed-off-by: Jacky Bai Tested-by: Alexander Stein --- - v5 changes: no - v4 changes: - update the compatible string to align with binding file - v3 changes: - remove 'nxp,bbnsm-regmap' property to align with binding doc - v2 changes: - update the regmap property to align with binding doc --- arch/arm64/boot/dts/freescale/imx93.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi index 2076f9c9983a..e772c136e895 100644 --- a/arch/arm64/boot/dts/freescale/imx93.dtsi +++ b/arch/arm64/boot/dts/freescale/imx93.dtsi @@ -243,6 +243,22 @@ iomuxc: pinctrl@443c0000 { status = "okay"; }; + bbnsm: bbnsm@44440000 { + compatible = "nxp,imx93-bbnsm", "syscon", "simple-mfd"; + reg = <0x44440000 0x10000>; + + bbnsm_rtc: rtc { + compatible = "nxp,imx93-bbnsm-rtc"; + interrupts = ; + }; + + bbnsm_pwrkey: pwrkey { + compatible = "nxp,imx93-bbnsm-pwrkey"; + interrupts = ; + linux,code = ; + }; + }; + clk: clock-controller@44450000 { compatible = "fsl,imx93-ccm"; reg = <0x44450000 0x10000>;