[PATCH 00/10] Add TWL6030 power off and powerbutton support

STALE1452d

17 messages, 4 authors, 2022-09-12 · open the first message on its own page

[PATCH 00/10] Add TWL6030 power off and powerbutton support

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:17:19

Hello!

This patchset is based off on an earlier series of patches submitted
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1110053.html
It adds support for power off to the TWL6030 chipset, adds power button
support to the TWL6030 chipset, moves power driver to the correct
location, clean up in code from the original patch.

Thanks, Mithil

Mithil Bavishi (6):
  power: reset: Move TWL4030 power driver from mfd
  dt-bindings: power: reset: Move twl4030-power from mfd to power/reset
  dt-bindings: input: twl-pwrbutton: Add support for twl6030-pwrbutton
  dt-bindings: power: reset: Add bindings for twl6030-power
  input: misc: Rename twl4030_pwrbutton to twl_pwrbutton
  dt-bindings: input: Rename twl4030-pwrbutton to twl-pwrbutton

Paul Kocialkowski (4):
  power: reset: Add TWL6030 power driver, with minimal support for power
    off
  ARM: OMAP2+: Only select TWL4030_POWER for OMAP3
  ARM: OMAP2+: Select TWL6030_POWER for OMAP4
  input: misc: Add TWL6030 power button support to twl-pwrbutton

 ...wl4030-pwrbutton.txt => twl-pwrbutton.txt} |  5 +-
 .../{mfd => power/reset}/twl4030-power.txt    |  0
 .../bindings/power/reset/twl6030-power.txt    | 31 +++++++
 arch/arm/boot/dts/twl6030.dtsi                |  5 +
 arch/arm/configs/omap2plus_defconfig          |  2 +-
 arch/arm/mach-omap2/Kconfig                   |  3 +-
 drivers/input/misc/Kconfig                    |  8 +-
 drivers/input/misc/Makefile                   |  2 +-
 .../{twl4030-pwrbutton.c => twl-pwrbutton.c}  | 75 ++++++++++-----
 drivers/mfd/Kconfig                           | 13 ---
 drivers/mfd/Makefile                          |  1 -
 drivers/power/reset/Kconfig                   | 22 +++++
 drivers/power/reset/Makefile                  |  2 +
 drivers/{mfd => power/reset}/twl4030-power.c  |  0
 drivers/power/reset/twl6030-power.c           | 93 +++++++++++++++++++
 include/linux/mfd/twl.h                       |  1 +
 16 files changed, 217 insertions(+), 46 deletions(-)
 rename Documentation/devicetree/bindings/input/{twl4030-pwrbutton.txt => twl-pwrbutton.txt} (72%)
 rename Documentation/devicetree/bindings/{mfd => power/reset}/twl4030-power.txt (100%)
 create mode 100644 Documentation/devicetree/bindings/power/reset/twl6030-power.txt
 rename drivers/input/misc/{twl4030-pwrbutton.c => twl-pwrbutton.c} (55%)
 rename drivers/{mfd => power/reset}/twl4030-power.c (100%)
 create mode 100644 drivers/power/reset/twl6030-power.c

-- 
2.25.1

[PATCH 01/10] power: reset: Move TWL4030 power driver from mfd

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:17:25

The power/reset folder seems like a more appropriate place for
twl4030-power.c

Signed-off-by: Mithil Bavishi <redacted>
---
 drivers/mfd/Kconfig                          | 13 -------------
 drivers/mfd/Makefile                         |  1 -
 drivers/power/reset/Kconfig                  | 12 ++++++++++++
 drivers/power/reset/Makefile                 |  1 +
 drivers/{mfd => power/reset}/twl4030-power.c |  0
 5 files changed, 13 insertions(+), 14 deletions(-)
 rename drivers/{mfd => power/reset}/twl4030-power.c (100%)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index abb58ab1a..6a409bb2a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1643,19 +1643,6 @@ config TWL4030_CORE
 	  high speed USB OTG transceiver, an audio codec (on most
 	  versions) and many other features.
 
-config TWL4030_POWER
-	bool "TI TWL4030 power resources"
-	depends on TWL4030_CORE && ARM
-	help
-	  Say yes here if you want to use the power resources on the
-	  TWL4030 family chips.  Most of these resources are regulators,
-	  which have a separate driver; some are control signals, such
-	  as clock request handshaking.
-
-	  This driver uses board-specific data to initialize the resources
-	  and load scripts controlling which resources are switched off/on
-	  or reset when a sleep, wakeup or warm reset event occurs.
-
 config MFD_TWL4030_AUDIO
 	bool "TI TWL4030 Audio"
 	depends on TWL4030_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 858cacf65..bd7bf95e6 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -108,7 +108,6 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
 obj-$(CONFIG_MENELAUS)		+= menelaus.o
 
 obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
-obj-$(CONFIG_TWL4030_POWER)    += twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)	+= twl4030-audio.o
 obj-$(CONFIG_TWL6040_CORE)	+= twl6040.o
 
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index a8c46ba58..39117b697 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -303,4 +303,16 @@ config POWER_MLXBF
 	help
 	  This driver supports reset or low power mode handling for Mellanox BlueField.
 
+config TWL4030_POWER
+        bool "TI TWL4030 power resources"
+        depends on TWL4030_CORE && ARM
+        help
+          Say yes here if you want to use the power resources on the
+          TWL4030 family chips.  Most of these resources are regulators,
+          which have a separate driver; some are control signals, such
+          as clock request handshaking.
+
+          This driver uses board-specific data to initialize the resources
+          and load scripts controlling which resources are switched off/on
+          or reset when a sleep, wakeup or warm reset event occurs.
 endif
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 0a39424fc..e9db25b09 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -36,3 +36,4 @@ obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o
 obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o
 obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o
 obj-$(CONFIG_POWER_MLXBF) += pwr-mlxbf.o
+obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
diff --git a/drivers/mfd/twl4030-power.c b/drivers/power/reset/twl4030-power.c
similarity index 100%
rename from drivers/mfd/twl4030-power.c
rename to drivers/power/reset/twl4030-power.c
-- 
2.25.1

[PATCH 02/10] dt-bindings: power: reset: Move twl4030-power from mfd to power/reset

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:17:31

Move the documentation for twl4030-power from mfd to power/reset

Signed-off-by: Mithil Bavishi <redacted>
---
 .../devicetree/bindings/{mfd => power/reset}/twl4030-power.txt    | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{mfd => power/reset}/twl4030-power.txt (100%)
diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/power/reset/twl4030-power.txt
similarity index 100%
rename from Documentation/devicetree/bindings/mfd/twl4030-power.txt
rename to Documentation/devicetree/bindings/power/reset/twl4030-power.txt
-- 
2.25.1

[PATCH 03/10] power: reset: Add TWL6030 power driver, with minimal support for power off

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:17:38

From: Paul Kocialkowski <redacted>

This adds a TWL6030 power driver, that currently only supports powering
off the device when the TWL is used as system power controller.

This driver might be extended to support more power-related features of the
TWL6030.

Signed-off-by: Paul Kocialkowski <redacted>
Signed-off-by: Mithil Bavishi <redacted>
---
 drivers/power/reset/Kconfig         | 10 ++++
 drivers/power/reset/Makefile        |  1 +
 drivers/power/reset/twl6030-power.c | 93 +++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 drivers/power/reset/twl6030-power.c
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 39117b697..5156b1613 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -316,3 +316,13 @@ config TWL4030_POWER
           and load scripts controlling which resources are switched off/on
           or reset when a sleep, wakeup or warm reset event occurs.
 endif
+
+config TWL6030_POWER
+	bool "TI TWL6030 power resources"
+	depends on TWL4030_CORE && ARM
+	help
+	  Say yes here if you want to use the power resources on the
+	  TWL6030 family chips.
+
+	  When used as system power controller, this driver allows turning off
+	  the main power supply.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index e9db25b09..692d51cef 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -37,3 +37,4 @@ obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o
 obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o
 obj-$(CONFIG_POWER_MLXBF) += pwr-mlxbf.o
 obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
+obj-$(CONFIG_TWL6030_POWER) += twl6030-power.o
diff --git a/drivers/power/reset/twl6030-power.c b/drivers/power/reset/twl6030-power.c
new file mode 100644
index 000000000..78c8a02a3
--- /dev/null
+++ b/drivers/power/reset/twl6030-power.c
@@ -0,0 +1,93 @@
+/*
+ * TWL6030 power
+ *
+ * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/mfd/twl.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#define TWL6030_PHOENIX_DEV_ON		0x25
+
+#define TWL6030_PHOENIX_APP_DEVOFF	BIT(0)
+#define TWL6030_PHOENIX_CON_DEVOFF	BIT(1)
+#define TWL6030_PHOENIX_MOD_DEVOFF	BIT(2)
+
+void twl6030_power_off(void)
+{
+	int err;
+
+	err = twl_i2c_write_u8(TWL6030_MODULE_ID0, TWL6030_PHOENIX_APP_DEVOFF |
+		TWL6030_PHOENIX_CON_DEVOFF | TWL6030_PHOENIX_MOD_DEVOFF,
+		TWL6030_PHOENIX_DEV_ON);
+	if (err)
+		pr_err("TWL6030 Unable to power off\n");
+}
+
+static bool twl6030_power_use_poweroff(struct device_node *node)
+{
+	if (of_property_read_bool(node, "ti,system-power-controller"))
+		return true;
+
+	return false;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id twl6030_power_of_match[] = {
+	{
+		.compatible = "ti,twl6030-power",
+	},
+	{ },
+};
+
+MODULE_DEVICE_TABLE(of, twl6030_power_of_match);
+#endif	/* CONFIG_OF */
+
+static int twl6030_power_probe(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+
+	if (!node) {
+		dev_err(&pdev->dev, "Platform data is missing\n");
+		return -EINVAL;
+	}
+
+	/* Board has to be wired properly to use this feature */
+	if (twl6030_power_use_poweroff(node) && !pm_power_off)
+		pm_power_off = twl6030_power_off;
+
+	return 0;
+}
+
+static int twl6030_power_remove(struct platform_device *pdev)
+{
+	return 0;
+}
+
+static struct platform_driver twl6030_power_driver = {
+	.driver = {
+		.name	= "twl6030_power",
+		.of_match_table = of_match_ptr(twl6030_power_of_match),
+	},
+	.probe		= twl6030_power_probe,
+	.remove		= twl6030_power_remove,
+};
+
+module_platform_driver(twl6030_power_driver);
+
+MODULE_AUTHOR("Paul Kocialkowski <contact@paulk.fr>");
+MODULE_DESCRIPTION("Power management for TWL6030");
+MODULE_LICENSE("GPL");
-- 
2.25.1

[PATCH 04/10] dt-bindings: input: twl-pwrbutton: Add support for twl6030-pwrbutton

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:17:46

Adds documentation for the compatible string for twl6030 powerbutton
support.

Signed-off-by: Paul Kocialkowski <redacted>
Signed-off-by: Mithil Bavishi <redacted>
---
 Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt | 1 +
 1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt b/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
index f5021214e..9a0b765d3 100644
--- a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
@@ -8,6 +8,7 @@ This module provides a simple power button event via an Interrupt.
 Required properties:
 - compatible: should be one of the following
    - "ti,twl4030-pwrbutton": For controllers compatible with twl4030
+   - "ti,twl6030-pwrbutton": For controllers compatible with twl6030
 - interrupts: should be one of the following
    - <8>: For controllers compatible with twl4030
 
-- 
2.25.1

[PATCH 05/10] dt-bindings: power: reset: Add bindings for twl6030-power

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:18:01

Adds documentation for the twl6030 power driver.

Signed-off-by: Paul Kocialkowski <redacted>
Signed-off-by: Mithil Bavishi <redacted>
---
 .../bindings/power/reset/twl6030-power.txt    | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/twl6030-power.txt
diff --git a/Documentation/devicetree/bindings/power/reset/twl6030-power.txt b/Documentation/devicetree/bindings/power/reset/twl6030-power.txt
new file mode 100644
index 000000000..946bb3d9f
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/twl6030-power.txt
@@ -0,0 +1,31 @@
+Texas Instruments TWL family (twl6030) reset and power management module
+
+For now, the binding only supports the complete shutdown of the system after
+poweroff.
+
+Required properties:
+- compatible : must be
+       "ti,twl6030-power"
+
+Optional properties:
+
+- ti,system-power-controller: This indicates that TWL6030 is the
+  power supply master of the system. With this flag, the chip will
+  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
+  system poweroffs.
+
+Example:
+&i2c1 {
+       clock-frequency = <2600000>;
+
+       twl: twl@48 {
+               reg = <0x48>;
+               interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+               interrupt-parent = <&intc>;
+
+               twl_power: power {
+                       compatible = "ti,twl6030-power";
+                       ti,system-power-controller;
+               };
+       };
+};
-- 
2.25.1

[PATCH 06/10] ARM: OMAP2+: Only select TWL4030_POWER for OMAP3

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:18:04

From: Paul Kocialkowski <redacted>

The TWL4030 is generally used with the OMAP3, not with OMAP4.
The TWL6030 is generally used with the OMAP4 instead.

Signed-off-by: Paul Kocialkowski <redacted>
---
 arch/arm/mach-omap2/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 3b53dda9e..e4fea50c3 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -143,7 +143,7 @@ config ARCH_OMAP2PLUS_TYPICAL
 	select REGULATOR
 	select REGULATOR_FIXED_VOLTAGE
 	select TWL4030_CORE if ARCH_OMAP3 || ARCH_OMAP4
-	select TWL4030_POWER if ARCH_OMAP3 || ARCH_OMAP4
+	select TWL4030_POWER if ARCH_OMAP3
 	select VFP
 	help
 	  Compile a kernel suitable for booting most boards
-- 
2.25.1

[PATCH 07/10] ARM: OMAP2+: Select TWL6030_POWER for OMAP4

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:18:15

From: Paul Kocialkowski <redacted>

The TWL6030 is generally used with the OMAP4.

Signed-off-by: Paul Kocialkowski <redacted>
---
 arch/arm/mach-omap2/Kconfig | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index e4fea50c3..9af3bd488 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -144,6 +144,7 @@ config ARCH_OMAP2PLUS_TYPICAL
 	select REGULATOR_FIXED_VOLTAGE
 	select TWL4030_CORE if ARCH_OMAP3 || ARCH_OMAP4
 	select TWL4030_POWER if ARCH_OMAP3
+	select TWL6030_POWER if ARCH_OMAP4
 	select VFP
 	help
 	  Compile a kernel suitable for booting most boards
-- 
2.25.1

[PATCH 08/10] input: misc: Rename twl4030_pwrbutton to twl_pwrbutton

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:18:33

This renames the twl4030-pwrbutton driver to twl-pwrbutton,
since power button handling is very similar on most TWL chips.

Signed-off-by: Mithil Bavishi <redacted>
---
 arch/arm/configs/omap2plus_defconfig          |  2 +-
 drivers/input/misc/Kconfig                    |  8 ++---
 drivers/input/misc/Makefile                   |  2 +-
 .../{twl4030-pwrbutton.c => twl-pwrbutton.c}  | 32 +++++++++----------
 4 files changed, 22 insertions(+), 22 deletions(-)
 rename drivers/input/misc/{twl4030-pwrbutton.c => twl-pwrbutton.c} (76%)
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 99d015cf8..621fd8b7e 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -402,7 +402,7 @@ CONFIG_TOUCHSCREEN_TSC2007=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_CPCAP_PWRBUTTON=m
 CONFIG_INPUT_TPS65218_PWRBUTTON=m
-CONFIG_INPUT_TWL4030_PWRBUTTON=m
+CONFIG_INPUT_TWL_PWRBUTTON=m
 CONFIG_INPUT_UINPUT=m
 CONFIG_INPUT_PALMAS_PWRBUTTON=m
 CONFIG_INPUT_PWM_VIBRA=m
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index a18ab7358..2c50459c7 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -479,15 +479,15 @@ config INPUT_AXP20X_PEK
 	  be called axp20x-pek.
 
 
-config INPUT_TWL4030_PWRBUTTON
-	tristate "TWL4030 Power button Driver"
+config INPUT_TWL_PWRBUTTON
+	tristate "TWL Power button Driver"
 	depends on TWL4030_CORE
 	help
 	  Say Y here if you want to enable power key reporting via the
-	  TWL4030 family of chips.
+	  TWL family of chips.
 
 	  To compile this driver as a module, choose M here. The module will
-	  be called twl4030_pwrbutton.
+	  be called twl_pwrbutton.
 
 config INPUT_TWL4030_VIBRA
 	tristate "Support for TWL4030 Vibrator"
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 28dfc444f..3eddb8cbd 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -78,7 +78,7 @@ obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)	+= soc_button_array.o
 obj-$(CONFIG_INPUT_SPARCSPKR)		+= sparcspkr.o
 obj-$(CONFIG_INPUT_STPMIC1_ONKEY)  	+= stpmic1_onkey.o
 obj-$(CONFIG_INPUT_TPS65218_PWRBUTTON)	+= tps65218-pwrbutton.o
-obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON)	+= twl4030-pwrbutton.o
+obj-$(CONFIG_INPUT_TWL_PWRBUTTON)	+= twl-pwrbutton.o
 obj-$(CONFIG_INPUT_TWL4030_VIBRA)	+= twl4030-vibra.o
 obj-$(CONFIG_INPUT_TWL6040_VIBRA)	+= twl6040-vibra.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl-pwrbutton.c
similarity index 76%
rename from drivers/input/misc/twl4030-pwrbutton.c
rename to drivers/input/misc/twl-pwrbutton.c
index b307cca17..5614c5003 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl-pwrbutton.c
@@ -1,5 +1,5 @@
 /**
- * twl4030-pwrbutton.c - TWL4030 Power Button Input Driver
+ * twl-pwrbutton.c - TWL4030 Power Button Input Driver
  *
  * Copyright (C) 2008-2009 Nokia Corporation
  *
@@ -52,7 +52,7 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
 	return IRQ_HANDLED;
 }
 
-static int twl4030_pwrbutton_probe(struct platform_device *pdev)
+static int twl_pwrbutton_probe(struct platform_device *pdev)
 {
 	struct input_dev *pwr;
 	int irq = platform_get_irq(pdev, 0);
@@ -65,14 +65,14 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev)
 	}
 
 	input_set_capability(pwr, EV_KEY, KEY_POWER);
-	pwr->name = "twl4030_pwrbutton";
-	pwr->phys = "twl4030_pwrbutton/input0";
+	pwr->name = "twl_pwrbutton";
+	pwr->phys = "twl_pwrbutton/input0";
 	pwr->dev.parent = &pdev->dev;
 
 	err = devm_request_threaded_irq(&pdev->dev, irq, NULL, powerbutton_irq,
 			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
 			IRQF_ONESHOT,
-			"twl4030_pwrbutton", pwr);
+			"twl_pwrbutton", pwr);
 	if (err < 0) {
 		dev_err(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
 		return err;
@@ -90,24 +90,24 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_OF
-static const struct of_device_id twl4030_pwrbutton_dt_match_table[] = {
-       { .compatible = "ti,twl4030-pwrbutton" },
-       {},
+static const struct of_device_id twl_pwrbutton_dt_match_table[] = {
+	{ .compatible = "ti,twl4030-pwrbutton" },
+	{},
 };
-MODULE_DEVICE_TABLE(of, twl4030_pwrbutton_dt_match_table);
+MODULE_DEVICE_TABLE(of, twl_pwrbutton_dt_match_table);
 #endif
 
-static struct platform_driver twl4030_pwrbutton_driver = {
-	.probe		= twl4030_pwrbutton_probe,
+static struct platform_driver twl_pwrbutton_driver = {
+	.probe		= twl_pwrbutton_probe,
 	.driver		= {
-		.name	= "twl4030_pwrbutton",
-		.of_match_table = of_match_ptr(twl4030_pwrbutton_dt_match_table),
+		.name	= "twl_pwrbutton",
+		.of_match_table = of_match_ptr(twl_pwrbutton_dt_match_table),
 	},
 };
-module_platform_driver(twl4030_pwrbutton_driver);
+module_platform_driver(twl_pwrbutton_driver);
 
-MODULE_ALIAS("platform:twl4030_pwrbutton");
-MODULE_DESCRIPTION("Triton2 Power Button");
+MODULE_ALIAS("platform:twl_pwrbutton");
+MODULE_DESCRIPTION("TWL Power Button");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Peter De Schrijver <peter.de-schrijver@nokia.com>");
 MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
-- 
2.25.1

[PATCH 09/10] dt-bindings: input: Rename twl4030-pwrbutton to twl-pwrbutton

From: Mithil Bavishi <hidden>
Date: 2022-08-20 07:18:52

This changes the Documentation of the twl4030-pwrbutton to
make it more generic as it can support other chips than
twl4030 as well.

Signed-off-by: Mithil Bavishi <redacted>
---
 .../input/{twl4030-pwrbutton.txt => twl-pwrbutton.txt}        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
 rename Documentation/devicetree/bindings/input/{twl4030-pwrbutton.txt => twl-pwrbutton.txt} (81%)
diff --git a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt b/Documentation/devicetree/bindings/input/twl-pwrbutton.txt
similarity index 81%
rename from Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
rename to Documentation/devicetree/bindings/input/twl-pwrbutton.txt
index 9a0b765d3..43addc04d 100644
--- a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/twl-pwrbutton.txt
@@ -1,6 +1,6 @@
-Texas Instruments TWL family (twl4030) pwrbutton module
+Texas Instruments TWL family pwrbutton module
 
-This module is part of the TWL4030. For more details about the whole
+This module is part of a TWL chip. For more details about the whole
 chip see Documentation/devicetree/bindings/mfd/twl-family.txt.
 
 This module provides a simple power button event via an Interrupt.
-- 
2.25.1

Re: [PATCH 02/10] dt-bindings: power: reset: Move twl4030-power from mfd to power/reset

From: Rob Herring <robh@kernel.org>
Date: 2022-08-22 19:30:01

On Sat, 20 Aug 2022 12:46:52 +0530, Mithil Bavishi wrote:
Move the documentation for twl4030-power from mfd to power/reset

Signed-off-by: Mithil Bavishi <redacted>
---
 .../devicetree/bindings/{mfd => power/reset}/twl4030-power.txt    | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{mfd => power/reset}/twl4030-power.txt (100%)
Acked-by: Rob Herring <robh@kernel.org>

Re: [PATCH 04/10] dt-bindings: input: twl-pwrbutton: Add support for twl6030-pwrbutton

From: Rob Herring <robh@kernel.org>
Date: 2022-08-22 19:32:03

On Sat, 20 Aug 2022 12:46:54 +0530, Mithil Bavishi wrote:
Adds documentation for the compatible string for twl6030 powerbutton
support.

Signed-off-by: Paul Kocialkowski <redacted>
Signed-off-by: Mithil Bavishi <redacted>
---
 Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt | 1 +
 1 file changed, 1 insertion(+)
Acked-by: Rob Herring <robh@kernel.org>

Re: [PATCH 09/10] dt-bindings: input: Rename twl4030-pwrbutton to twl-pwrbutton

From: Rob Herring <robh@kernel.org>
Date: 2022-08-22 19:32:05

On Sat, Aug 20, 2022 at 12:46:59PM +0530, Mithil Bavishi wrote:
This changes the Documentation of the twl4030-pwrbutton to
make it more generic as it can support other chips than
twl4030 as well.
This should be part of patch 4.
quoted hunk
Signed-off-by: Mithil Bavishi <redacted>
---
 .../input/{twl4030-pwrbutton.txt => twl-pwrbutton.txt}        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
 rename Documentation/devicetree/bindings/input/{twl4030-pwrbutton.txt => twl-pwrbutton.txt} (81%)
diff --git a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt b/Documentation/devicetree/bindings/input/twl-pwrbutton.txt
similarity index 81%
rename from Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
rename to Documentation/devicetree/bindings/input/twl-pwrbutton.txt
index 9a0b765d3..43addc04d 100644
--- a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/twl-pwrbutton.txt
@@ -1,6 +1,6 @@
-Texas Instruments TWL family (twl4030) pwrbutton module
+Texas Instruments TWL family pwrbutton module
 
-This module is part of the TWL4030. For more details about the whole
+This module is part of a TWL chip. For more details about the whole
 chip see Documentation/devicetree/bindings/mfd/twl-family.txt.
 
 This module provides a simple power button event via an Interrupt.
-- 
2.25.1

Re: [PATCH 05/10] dt-bindings: power: reset: Add bindings for twl6030-power

From: Rob Herring <robh@kernel.org>
Date: 2022-08-22 19:32:12

On Sat, Aug 20, 2022 at 12:46:55PM +0530, Mithil Bavishi wrote:
Adds documentation for the twl6030 power driver.

Signed-off-by: Paul Kocialkowski <redacted>
Signed-off-by: Mithil Bavishi <redacted>
---
 .../bindings/power/reset/twl6030-power.txt    | 31 +++++++++++++++++++
New bindings must be DT schema format.
quoted hunk
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/twl6030-power.txt
diff --git a/Documentation/devicetree/bindings/power/reset/twl6030-power.txt b/Documentation/devicetree/bindings/power/reset/twl6030-power.txt
new file mode 100644
index 000000000..946bb3d9f
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/twl6030-power.txt
@@ -0,0 +1,31 @@
+Texas Instruments TWL family (twl6030) reset and power management module
+
+For now, the binding only supports the complete shutdown of the system after
+poweroff.
+
+Required properties:
+- compatible : must be
+       "ti,twl6030-power"
+
+Optional properties:
+
+- ti,system-power-controller: This indicates that TWL6030 is the
We have a generic property for this.
+  power supply master of the system. With this flag, the chip will
+  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
+  system poweroffs.
+
+Example:
+&i2c1 {
+       clock-frequency = <2600000>;
+
+       twl: twl@48 {
+               reg = <0x48>;
+               interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+               interrupt-parent = <&intc>;
+
+               twl_power: power {
+                       compatible = "ti,twl6030-power";
+                       ti,system-power-controller;
Why do you need a child node here? There aren't any resources for the 
sub-block.

Rob

Re: [PATCH 01/10] power: reset: Move TWL4030 power driver from mfd

From: Lee Jones <lee@kernel.org>
Date: 2022-09-06 15:56:10

On Sat, 20 Aug 2022, Mithil Bavishi wrote:
The power/reset folder seems like a more appropriate place for
twl4030-power.c

Signed-off-by: Mithil Bavishi <redacted>
---
 drivers/mfd/Kconfig                          | 13 -------------
 drivers/mfd/Makefile                         |  1 -
 drivers/power/reset/Kconfig                  | 12 ++++++++++++
 drivers/power/reset/Makefile                 |  1 +
 drivers/{mfd => power/reset}/twl4030-power.c |  0
 5 files changed, 13 insertions(+), 14 deletions(-)
 rename drivers/{mfd => power/reset}/twl4030-power.c (100%)
Acked-by: Lee Jones <lee@kernel.org>

-- 
Lee Jones [李琼斯]

Re: [PATCH 02/10] dt-bindings: power: reset: Move twl4030-power from mfd to power/reset

From: Lee Jones <lee@kernel.org>
Date: 2022-09-06 15:57:17

On Sat, 20 Aug 2022, Mithil Bavishi wrote:
quoted hunk
Move the documentation for twl4030-power from mfd to power/reset

Signed-off-by: Mithil Bavishi <redacted>
---
 .../devicetree/bindings/{mfd => power/reset}/twl4030-power.txt    | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{mfd => power/reset}/twl4030-power.txt (100%)
diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/power/reset/twl4030-power.txt
similarity index 100%
rename from Documentation/devicetree/bindings/mfd/twl4030-power.txt
rename to Documentation/devicetree/bindings/power/reset/twl4030-power.txt
Acked-by: Lee Jones <lee@kernel.org>

-- 
Lee Jones [李琼斯]

Re: [PATCH 03/10] power: reset: Add TWL6030 power driver, with minimal support for power off

From: Sebastian Reichel <hidden>
Date: 2022-09-12 10:28:51

Hi,

On Sat, Aug 20, 2022 at 12:46:53PM +0530, Mithil Bavishi wrote:
quoted hunk
From: Paul Kocialkowski <redacted>

This adds a TWL6030 power driver, that currently only supports powering
off the device when the TWL is used as system power controller.

This driver might be extended to support more power-related features of the
TWL6030.

Signed-off-by: Paul Kocialkowski <redacted>
Signed-off-by: Mithil Bavishi <redacted>
---
 drivers/power/reset/Kconfig         | 10 ++++
 drivers/power/reset/Makefile        |  1 +
 drivers/power/reset/twl6030-power.c | 93 +++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 drivers/power/reset/twl6030-power.c
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 39117b697..5156b1613 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -316,3 +316,13 @@ config TWL4030_POWER
           and load scripts controlling which resources are switched off/on
           or reset when a sleep, wakeup or warm reset event occurs.
 endif
+
+config TWL6030_POWER
+	bool "TI TWL6030 power resources"
+	depends on TWL4030_CORE && ARM
+	help
+	  Say yes here if you want to use the power resources on the
+	  TWL6030 family chips.
+
+	  When used as system power controller, this driver allows turning off
+	  the main power supply.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index e9db25b09..692d51cef 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -37,3 +37,4 @@ obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o
 obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o
 obj-$(CONFIG_POWER_MLXBF) += pwr-mlxbf.o
 obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
+obj-$(CONFIG_TWL6030_POWER) += twl6030-power.o
diff --git a/drivers/power/reset/twl6030-power.c b/drivers/power/reset/twl6030-power.c
new file mode 100644
index 000000000..78c8a02a3
--- /dev/null
+++ b/drivers/power/reset/twl6030-power.c
@@ -0,0 +1,93 @@
+/*
+ * TWL6030 power
+ *
+ * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
Please use SPDX format for license.
+
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/mfd/twl.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#define TWL6030_PHOENIX_DEV_ON		0x25
+
+#define TWL6030_PHOENIX_APP_DEVOFF	BIT(0)
+#define TWL6030_PHOENIX_CON_DEVOFF	BIT(1)
+#define TWL6030_PHOENIX_MOD_DEVOFF	BIT(2)
+
+void twl6030_power_off(void)
+{
+	int err;
+
+	err = twl_i2c_write_u8(TWL6030_MODULE_ID0, TWL6030_PHOENIX_APP_DEVOFF |
+		TWL6030_PHOENIX_CON_DEVOFF | TWL6030_PHOENIX_MOD_DEVOFF,
+		TWL6030_PHOENIX_DEV_ON);
+	if (err)
+		pr_err("TWL6030 Unable to power off\n");
+}
+
+static bool twl6030_power_use_poweroff(struct device_node *node)
+{
+	if (of_property_read_bool(node, "ti,system-power-controller"))
+		return true;
+
+	return false;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id twl6030_power_of_match[] = {
+	{
+		.compatible = "ti,twl6030-power",
+	},
+	{ },
+};
+
+MODULE_DEVICE_TABLE(of, twl6030_power_of_match);
+#endif	/* CONFIG_OF */
+
+static int twl6030_power_probe(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+
+	if (!node) {
+		dev_err(&pdev->dev, "Platform data is missing\n");
+		return -EINVAL;
+	}
+
+	/* Board has to be wired properly to use this feature */
+	if (twl6030_power_use_poweroff(node) && !pm_power_off)
+		pm_power_off = twl6030_power_off;
Please devm_register_sys_off_handler or devm_register_power_off_handler().
+
+	return 0;
+}
+
+static int twl6030_power_remove(struct platform_device *pdev)
+{
+	return 0;
+}
Empty remove function can be removed.
+
+static struct platform_driver twl6030_power_driver = {
+	.driver = {
+		.name	= "twl6030_power",
+		.of_match_table = of_match_ptr(twl6030_power_of_match),
The driver is not useful without CONFIG_OF, so you can just remove the
#ifdef around twl6030_power_of_match and drop of_match_ptr here.

-- Sebastian
+	},
+	.probe		= twl6030_power_probe,
+	.remove		= twl6030_power_remove,
+};
+
+module_platform_driver(twl6030_power_driver);
+
+MODULE_AUTHOR("Paul Kocialkowski [off-list ref]");
+MODULE_DESCRIPTION("Power management for TWL6030");
+MODULE_LICENSE("GPL");
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help