Skip to contentSkip to conversation

Add nxp bbnsm module support

PATCH Applied Jacky Bai 5 participants 12 messages Feb 15, 2023 – Mar 14, 2023

Subsystems (5)
lore
Share & tools
lore

Jacky Bai

author
#0 lore raw

v5 cover Add nxp bbnsm module support

NXP BBNSM (Battery-Backed Non-Secure Module) serves as non-volatile logic and storage for the system. it provides some similar functions like RTC and ON/OFF support as previous SNVS module found on legacy i.MX SoCs. The BBNSM is replacement of previous SNVS module, and more likely it will be used on all the future i.MX SoC or other SoCs from NXP.

This patchset add the basic support for BBNSM that found on i.MX93.

Jacky Bai (3):
input: bbnsm_pwrkey: Add bbnsm power key support
rtc: bbnsm: Add the bbnsm rtc support
arm64: dts: imx93: Add the bbnsm dts node

 arch/arm64/boot/dts/freescale/imx93.dtsi |  16 ++
 drivers/input/misc/Kconfig               |  11 ++
 drivers/input/misc/Makefile              |   1 +
 drivers/input/misc/nxp-bbnsm-pwrkey.c    | 192 +++++++++++++++++++
 drivers/rtc/Kconfig                      |  12 ++
 drivers/rtc/Makefile                     |   1 +
 drivers/rtc/rtc-nxp-bbnsm.c              | 226 +++++++++++++++++++++++
 7 files changed, 459 insertions(+)
 create mode 100644 drivers/input/misc/nxp-bbnsm-pwrkey.c
 create mode 100644 drivers/rtc/rtc-nxp-bbnsm.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v5 1/3 input: bbnsm_pwrkey: Add bbnsm power key support

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.

---
- 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
drivers/input/misc/Kconfig +11 -0
index 5c2d0c06d2a5..81a54a59e13c 100644
@@ -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
drivers/input/misc/Makefile +1 -0
index 61949263300d..04296a4abe8e 100644
@@ -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
drivers/input/misc/nxp-bbnsm-pwrkey.c new file +192 -0

192 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH v5 1/3] input: bbnsm_pwrkey: Add bbnsm power key support

Quoted 11 lines · Jacky Bai

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.

Applied with a few cosmetic changes, thank you.

Signature · 1 line
Dmitry
author
#3 lore raw

PATCH v5 2/3 rtc: bbnsm: Add the bbnsm rtc support

In reply to Jacky Bai

The BBNSM module includes a real time counter with alarm. Add a RTC driver for this function.

---
- 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
drivers/rtc/Kconfig +12 -0
index 2ba72de0fa47..13c9c57aab73 100644
@@ -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
drivers/rtc/Makefile +1 -0
index 59eb30289335..ea445d1ebb17 100644
@@ -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
drivers/rtc/rtc-nxp-bbnsm.c new file +226 -0

226 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Acked-by on v5 2/3
#4 lore raw

Re: [PATCH v5 2/3] rtc: bbnsm: Add the bbnsm rtc support

Quoted 5 lines · Jacky Bai

The BBNSM module includes a real time counter with alarm. Add a RTC driver for this function.

Quoted 24 lines
drivers/rtc/rtc-nxp-bbnsm.c new file +24 -0
+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;
+

drivers/rtc/rtc-nxp-bbnsm.c line 196

Quoted 10 lines
drivers/rtc/rtc-nxp-bbnsm.c new file +10 -0
+	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);

This is not properly aligned, you can fix that if you ever have to resend.

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

Re: [PATCH v5 2/3] rtc: bbnsm: Add the bbnsm rtc support

Quoted 8 lines · Alexandre Belloni
Quoted 5 lines · Jacky Bai

The BBNSM module includes a real time counter with alarm. Add a RTC driver for this function.

Actually, as there is no dependency anymore, I'm going to apply that directly.

Quoted 44 lines
Quoted 24 lines
drivers/rtc/rtc-nxp-bbnsm.c new file +24 -0
+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;
+

drivers/rtc/rtc-nxp-bbnsm.c line 196

Quoted 10 lines
drivers/rtc/rtc-nxp-bbnsm.c new file +10 -0
+	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);

This is not properly aligned, you can fix that if you ever have to resend.

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#6 lore raw

RE: [PATCH v5 2/3] rtc: bbnsm: Add the bbnsm rtc support

Hi Alexandre,

Quoted 7 lines

Subject: Re: [PATCH v5 2/3] rtc: bbnsm: Add the bbnsm rtc support

Quoted 4 lines · Alexandre Belloni
Quoted 3 lines · Jacky Bai

The BBNSM module includes a real time counter with alarm. Add a RTC driver for this function.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Actually, as there is no dependency anymore, I'm going to apply that directly.

Do I need to resend or you will directly apply this V5 patch?

BR

Quoted 41 lines
Quoted 24 lines
Quoted 24 lines
drivers/rtc/rtc-nxp-bbnsm.c new file +24 -0
+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);
Quoted 8 lines

drivers/rtc/rtc-nxp-bbnsm.c

Quoted 8 lines
drivers/rtc/rtc-nxp-bbnsm.c new file +8 -0
+
+	/* 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,

Quoted 8 lines

drivers/rtc/rtc-nxp-bbnsm.c line 196

Quoted 1 line
drivers/rtc/rtc-nxp-bbnsm.c new file +1 -0
+			IRQF_SHARED, "rtc alarm", &pdev->dev);

This is not properly aligned, you can fix that if you ever have to resend.

--

maintainer Applied
#7 lore raw

Re: (subset) [PATCH v5 2/3] rtc: bbnsm: Add the bbnsm rtc support

In reply to Jacky Bai
Quoted 4 lines · Jacky Bai

The BBNSM module includes a real time counter with alarm. Add a RTC driver for this function.

Applied, thanks!

[2/3] rtc: bbnsm: Add the bbnsm rtc support

      commit: eb7b85853c3866236f9cb378fc68ce5f76efbf9c

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#8 lore raw

PATCH v5 3/3 arm64: dts: imx93: Add the bbnsm dts node

In reply to Jacky Bai

Add the bbnsm node for RTC & ON/OFF button support

---
- 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(+)
arch/arm64/boot/dts/freescale/imx93.dtsi +16 -0
index 2076f9c9983a..e772c136e895 100644
@@ -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 = <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>;
Signature · 1 line
2.34.1
author
#9 lore raw

RE: [PATCH v5 3/3] arm64: dts: imx93: Add the bbnsm dts node

Hi Shawn,

Can you help pick this patch?

BR

Quoted 50 lines

Subject: [PATCH v5 3/3] arm64: dts: imx93: Add the bbnsm dts node

Add the bbnsm node for RTC & ON/OFF button support

---
- 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(+)
arch/arm64/boot/dts/freescale/imx93.dtsi +16 -1
index 2076f9c9983a..e772c136e895 100644
@@ -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 = <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.34.1

Tested-by
#10 lore raw

RE: [PATCH v5 3/3] arm64: dts: imx93: Add the bbnsm dts node

Hi,

Am Mittwoch, 8. März 2023, 10:58:00 CET schrieb Jacky Bai:

Quoted 3 lines

Hi Shawn,

Can you help pick this patch?

Just for completeness:

on TQMa93xx

Best regards,
Alexander

Quoted 32 lines

BR

Quoted 30 lines

Subject: [PATCH v5 3/3] arm64: dts: imx93: Add the bbnsm dts node

Add the bbnsm node for RTC & ON/OFF button support

---

- 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(+)
arch/arm64/boot/dts/freescale/imx93.dtsi +0 -0
index 2076f9c9983a..e772c136e895 100644
@@ -243,6 +243,22 @@ iomuxc: pinctrl@443c0000 {
 
Quoted 6 lines

arch/arm64/boot/dts/freescale/imx93.dtsi iomuxc: pinctrl@443c0000 {

Quoted 6 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +2 -0
 				status = "okay";
 
 			};
 
+			bbnsm: bbnsm@44440000 {
+				compatible = "nxp,imx93-bbnsm", 

"syscon", "simple-mfd";

Quoted 4 lines

arch/arm64/boot/dts/freescale/imx93.dtsi iomuxc: pinctrl@443c0000 {

Quoted 4 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +4 -0
+				reg = <0x44440000 0x10000>;
+
+				bbnsm_rtc: rtc {
+					compatible = "nxp,imx93-

bbnsm-rtc";

Quoted 1 line

arch/arm64/boot/dts/freescale/imx93.dtsi iomuxc: pinctrl@443c0000 { · line 254

Quoted 1 line
arch/arm64/boot/dts/freescale/imx93.dtsi +1 -0
+					interrupts = <GIC_SPI 73 

IRQ_TYPE_LEVEL_HIGH>;

Quoted 4 lines

arch/arm64/boot/dts/freescale/imx93.dtsi iomuxc: pinctrl@443c0000 {

Quoted 4 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +4 -0
+				};
+
+				bbnsm_pwrkey: pwrkey {
+					compatible = "nxp,imx93-

bbnsm-pwrkey";

Quoted 1 line

arch/arm64/boot/dts/freescale/imx93.dtsi iomuxc: pinctrl@443c0000 { · line 259

Quoted 1 line
arch/arm64/boot/dts/freescale/imx93.dtsi +1 -0
+					interrupts = <GIC_SPI 73 

IRQ_TYPE_LEVEL_HIGH>;

Quoted 17 lines
Quoted 11 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +4 -0
+					linux,code = <KEY_POWER>;
+				};
+			};
+
 
arch/arm64/boot/dts/freescale/imx93.dtsi +0 -1
 			clk: clock-controller@44450000 {
 
 				compatible = "fsl,imx93-ccm";
 				reg = <0x44450000 0x10000>;
 
--
Quoted 1 line

2.34.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/