* [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm
2023-01-29 7:08 [PATCH v4 0/4] Add nxp bbnsm module support Jacky Bai
@ 2023-01-29 7:08 ` Jacky Bai
2023-01-30 22:09 ` Rob Herring
2023-01-31 9:15 ` Lee Jones
2023-01-29 7:08 ` [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support Jacky Bai
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Jacky Bai @ 2023-01-29 7:08 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
Add binding for NXP BBNSM(Battery-Backed Non-Secure Module).
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
---
- v2 changes:
- remove the redundant 'bindings' string
- add ref to rtc.yaml
- add start-year property
- rename 'regmap' to 'nxp,bbnsm-regmap' and add description & type define
- add header files including in the example and correct the indentation
-v3 changes:
- remove the 'nxp,bbnsm-regmap' property, get the regmap directly from the
parent node in rtc/pwrkey driver
- v4 changes:
- update the compatible string to include the soc id as Rob suggested
---
.../devicetree/bindings/mfd/nxp,bbnsm.yaml | 101 ++++++++++++++++++
1 file changed, 101 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mfd/nxp,bbnsm.yaml
diff --git a/Documentation/devicetree/bindings/mfd/nxp,bbnsm.yaml b/Documentation/devicetree/bindings/mfd/nxp,bbnsm.yaml
new file mode 100644
index 000000000000..b1ade64a1554
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/nxp,bbnsm.yaml
@@ -0,0 +1,101 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/nxp,bbnsm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP Battery-Backed Non-Secure Module
+
+maintainers:
+ - Jacky Bai <ping.bai@nxp.com>
+
+description: |
+ NXP BBNSM serves as non-volatile logic and storage for the system.
+ it Intergrates RTC & ON/OFF control.
+ The RTC can retain its state and continues counting even when the
+ main chip is power down. A time alarm is generated once the most
+ significant 32 bits of the real-time counter match the value in the
+ Time Alarm register.
+ The ON/OFF logic inside the BBNSM allows for connecting directly to
+ a PMIC or other voltage regulator device. both smart PMIC mode and
+ Dumb PMIC mode supported.
+
+properties:
+ compatible:
+ items:
+ - enum:
+ - nxp,imx93-bbnsm
+ - const: syscon
+ - const: simple-mfd
+
+ reg:
+ maxItems: 1
+
+ rtc:
+ type: object
+ $ref: /schemas/rtc/rtc.yaml#
+
+ properties:
+ compatible:
+ enum:
+ - nxp,imx93-bbnsm-rtc
+
+ interrupts:
+ maxItems: 1
+
+ start-year: true
+
+ required:
+ - compatible
+ - interrupts
+
+ additionalProperties: false
+
+ pwrkey:
+ type: object
+ $ref: /schemas/input/input.yaml#
+
+ properties:
+ compatible:
+ enum:
+ - nxp,imx93-bbnsm-pwrkey
+
+ interrupts:
+ maxItems: 1
+
+ linux,code: true
+
+ required:
+ - compatible
+ - interrupts
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - rtc
+ - pwrkey
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/input/linux-event-codes.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ bbnsm: bbnsm@44440000 {
+ compatible = "nxp,imx93-bbnsm", "syscon", "simple-mfd";
+ reg = <0x44440000 0x10000>;
+
+ bbnsm_rtc: rtc {
+ compatible = "nxp,imx93-bbnsm-rtc";
+ interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+ };
+
+ bbnsm_pwrkey: pwrkey {
+ compatible = "nxp,imx93-bbnsm-pwrkey";
+ interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+ linux,code = <KEY_POWER>;
+ };
+ };
--
2.37.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm
2023-01-29 7:08 ` [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm Jacky Bai
@ 2023-01-30 22:09 ` Rob Herring
2023-01-31 9:15 ` Lee Jones
1 sibling, 0 replies; 10+ messages in thread
From: Rob Herring @ 2023-01-30 22:09 UTC (permalink / raw)
To: Jacky Bai
Cc: shawnguo, a.zummo, lee, alexandre.belloni, linux-input,
linux-rtc, festevam, dmitry.torokhov, linux-arm-kernel,
devicetree, linux-imx, s.hauer, krzysztof.kozlowski+dt, kernel,
robh+dt
On Sun, 29 Jan 2023 15:08:20 +0800, Jacky Bai wrote:
> Add binding for NXP BBNSM(Battery-Backed Non-Secure Module).
>
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> ---
> - v2 changes:
> - remove the redundant 'bindings' string
> - add ref to rtc.yaml
> - add start-year property
> - rename 'regmap' to 'nxp,bbnsm-regmap' and add description & type define
> - add header files including in the example and correct the indentation
>
> -v3 changes:
> - remove the 'nxp,bbnsm-regmap' property, get the regmap directly from the
> parent node in rtc/pwrkey driver
>
> - v4 changes:
> - update the compatible string to include the soc id as Rob suggested
> ---
> .../devicetree/bindings/mfd/nxp,bbnsm.yaml | 101 ++++++++++++++++++
> 1 file changed, 101 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/mfd/nxp,bbnsm.yaml
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm
2023-01-29 7:08 ` [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm Jacky Bai
2023-01-30 22:09 ` Rob Herring
@ 2023-01-31 9:15 ` Lee Jones
1 sibling, 0 replies; 10+ messages in thread
From: Lee Jones @ 2023-01-31 9:15 UTC (permalink / raw)
To: Jacky Bai
Cc: robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni, devicetree,
linux-arm-kernel, linux-input, linux-rtc, kernel, linux-imx,
festevam
On Sun, 29 Jan 2023, Jacky Bai wrote:
> Add binding for NXP BBNSM(Battery-Backed Non-Secure Module).
>
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> ---
> - v2 changes:
> - remove the redundant 'bindings' string
> - add ref to rtc.yaml
> - add start-year property
> - rename 'regmap' to 'nxp,bbnsm-regmap' and add description & type define
> - add header files including in the example and correct the indentation
>
> -v3 changes:
> - remove the 'nxp,bbnsm-regmap' property, get the regmap directly from the
> parent node in rtc/pwrkey driver
>
> - v4 changes:
> - update the compatible string to include the soc id as Rob suggested
> ---
> .../devicetree/bindings/mfd/nxp,bbnsm.yaml | 101 ++++++++++++++++++
> 1 file changed, 101 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/mfd/nxp,bbnsm.yaml
Applied, thanks
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support
2023-01-29 7:08 [PATCH v4 0/4] Add nxp bbnsm module support Jacky Bai
2023-01-29 7:08 ` [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm Jacky Bai
@ 2023-01-29 7:08 ` Jacky Bai
2023-02-03 15:03 ` Mattijs Korpershoek
2023-02-03 20:11 ` Dmitry Torokhov
2023-01-29 7:08 ` [PATCH v4 3/4] rtc: bbnsm: Add the bbnsm rtc support Jacky Bai
2023-01-29 7:08 ` [PATCH v4 4/4] arm64: dts: imx93: Add the bbnsm dts node Jacky Bai
3 siblings, 2 replies; 10+ messages in thread
From: Jacky Bai @ 2023-01-29 7:08 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
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 <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
- 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 <linux/device.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/regmap.h>
+
+#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 <ping.bai@nxp.com>");
+MODULE_DESCRIPTION("NXP bbnsm power key Driver");
+MODULE_LICENSE("GPL");
--
2.37.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support
2023-01-29 7:08 ` [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support Jacky Bai
@ 2023-02-03 15:03 ` Mattijs Korpershoek
2023-02-03 20:11 ` Dmitry Torokhov
1 sibling, 0 replies; 10+ messages in thread
From: Mattijs Korpershoek @ 2023-02-03 15:03 UTC (permalink / raw)
To: Jacky Bai, lee, robh+dt, krzysztof.kozlowski+dt, shawnguo,
s.hauer, dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
On Sun, Jan 29, 2023 at 15:08, Jacky Bai <ping.bai@nxp.com> wrote:
> 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 <ping.bai@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> - 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 <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/jiffies.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
> +#include <linux/regmap.h>
> +
> +#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 <ping.bai@nxp.com>");
> +MODULE_DESCRIPTION("NXP bbnsm power key Driver");
> +MODULE_LICENSE("GPL");
> --
> 2.37.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support
2023-01-29 7:08 ` [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support Jacky Bai
2023-02-03 15:03 ` Mattijs Korpershoek
@ 2023-02-03 20:11 ` Dmitry Torokhov
2023-02-10 7:11 ` Jacky Bai
1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-03 20:11 UTC (permalink / raw)
To: Jacky Bai
Cc: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer, a.zummo,
alexandre.belloni, devicetree, linux-arm-kernel, linux-input,
linux-rtc, kernel, linux-imx, festevam
Hi Jacky,
On Sun, Jan 29, 2023 at 03:08:21PM +0800, Jacky Bai wrote:
> 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 <ping.bai@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> ---
> - 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 ++++++++++++++++++++++
Majority of pwrkey drivers reside in dribers/input/misc, which
drivers/input/keyboard intended for more traditional/full keyboards.
Could you please move this driver there?
We should move snvs_pwrkey too...
> 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 <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/jiffies.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
> +#include <linux/regmap.h>
> +
> +#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);
del_timer()/del_timer_sync() are deprecated. Please use
timer_shutdown_sync() here.
> +}
> +
> +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");
This is a pretty cryptic message IMO. Maybe say "key code is not
specified, using default KEY_POWER"?
> + }
> +
> + 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);
Is this really a shared interrupt?
> + 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 <ping.bai@nxp.com>");
> +MODULE_DESCRIPTION("NXP bbnsm power key Driver");
> +MODULE_LICENSE("GPL");
> --
> 2.37.1
>
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support
2023-02-03 20:11 ` Dmitry Torokhov
@ 2023-02-10 7:11 ` Jacky Bai
0 siblings, 0 replies; 10+ messages in thread
From: Jacky Bai @ 2023-02-10 7:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer, a.zummo,
alexandre.belloni, devicetree, linux-arm-kernel, linux-input,
linux-rtc, kernel, dl-linux-imx, festevam
> Subject: Re: [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key
> support
>
> Hi Jacky,
>
> On Sun, Jan 29, 2023 at 03:08:21PM +0800, Jacky Bai wrote:
> > 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 <ping.bai@nxp.com>
> > Reviewed-by: Peng Fan <peng.fan@nxp.com>
> > ---
> > - 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
> > ++++++++++++++++++++++
>
> Majority of pwrkey drivers reside in dribers/input/misc, which
> drivers/input/keyboard intended for more traditional/full keyboards.
> Could you please move this driver there?
>
Sure, I will move it into misc.
> We should move snvs_pwrkey too...
Will do it in a separate patch.
>
>
> > 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 <linux/device.h>
> > +#include <linux/err.h>
> > +#include <linux/init.h>
> > +#include <linux/input.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/io.h>
> > +#include <linux/jiffies.h>
> > +#include <linux/kernel.h>
> > +#include <linux/mfd/syscon.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/of_address.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/pm_wakeirq.h>
> > +#include <linux/regmap.h>
> > +
> > +#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);
>
> del_timer()/del_timer_sync() are deprecated. Please use
> timer_shutdown_sync() here.
Ok, will do it in V5.
>
> > +}
> > +
> > +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");
>
> This is a pretty cryptic message IMO. Maybe say "key code is not specified,
> using default KEY_POWER"?
Ok, will refine this log as you suggested.
>
> > + }
> > +
> > + 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);
>
> Is this really a shared interrupt?
For current SoC integration, the ON/OFF power key IRQ signal are ORed together with RTC IRQ signal.
So these two functions share the same IRQ line to GIC. I think the IRQF_SHARED flag is necessary, right? ^_^
BR
>
> > + 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 <ping.bai@nxp.com>");
> > +MODULE_DESCRIPTION("NXP bbnsm power key Driver");
> > +MODULE_LICENSE("GPL");
> > --
> > 2.37.1
> >
>
> Thanks.
>
> --
> Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 3/4] rtc: bbnsm: Add the bbnsm rtc support
2023-01-29 7:08 [PATCH v4 0/4] Add nxp bbnsm module support Jacky Bai
2023-01-29 7:08 ` [PATCH v4 1/4] dt-bindings: mfd: Add nxp bbnsm Jacky Bai
2023-01-29 7:08 ` [PATCH v4 2/4] input: bbnsm_pwrkey: Add bbnsm power key support Jacky Bai
@ 2023-01-29 7:08 ` Jacky Bai
2023-01-29 7:08 ` [PATCH v4 4/4] arm64: dts: imx93: Add the bbnsm dts node Jacky Bai
3 siblings, 0 replies; 10+ messages in thread
From: Jacky Bai @ 2023-01-29 7:08 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
The BBNSM module includes a real time counter with alarm.
Add a RTC driver for this function.
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
- 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
- v3 changes:
- get the regmap directly from parent node
- remove unnecessary dev_err log print
- v4 changes:
- update the compatible string to align with binding file
---
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 677d2601d305..1b9e8395d118 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1786,6 +1786,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 d3c042dcbc73..0f11027a7388 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 <linux/init.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/regmap.h>
+#include <linux/rtc.h>
+
+#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 <ping.bai@nxp.com>");
+MODULE_DESCRIPTION("NXP BBNSM RTC Driver");
+MODULE_LICENSE("GPL");
--
2.37.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 4/4] arm64: dts: imx93: Add the bbnsm dts node
2023-01-29 7:08 [PATCH v4 0/4] Add nxp bbnsm module support Jacky Bai
` (2 preceding siblings ...)
2023-01-29 7:08 ` [PATCH v4 3/4] rtc: bbnsm: Add the bbnsm rtc support Jacky Bai
@ 2023-01-29 7:08 ` Jacky Bai
3 siblings, 0 replies; 10+ messages in thread
From: Jacky Bai @ 2023-01-29 7:08 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
Add the bbnsm node for RTC & ON/OFF button support
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
---
- v2 changes:
- update the regmap property to align with binding doc
- v3 changes:
- remove 'nxp,bbnsm-regmap' property to align with binding doc
- v4 changes:
- update the compatible string to align with binding file
---
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 5d79663b3b84..36be18165d4b 100644
--- a/arch/arm64/boot/dts/freescale/imx93.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx93.dtsi
@@ -229,6 +229,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 = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+ };
+
+ bbnsm_pwrkey: pwrkey {
+ compatible = "nxp,imx93-bbnsm-pwrkey";
+ interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+ linux,code = <KEY_POWER>;
+ };
+ };
+
clk: clock-controller@44450000 {
compatible = "fsl,imx93-ccm";
reg = <0x44450000 0x10000>;
--
2.37.1
^ permalink raw reply related [flat|nested] 10+ messages in thread