* [PATCH v2 1/3] dt-bindings: mfd: twl: enable power button also for twl603x
2025-10-30 19:10 [PATCH v2 0/3] mfd: twl603x: add power button akemnade
@ 2025-10-30 19:10 ` akemnade
2025-10-30 19:59 ` Conor Dooley
2025-10-30 19:10 ` [PATCH v2 2/3] Input: twl4030 - add TWL603x power button akemnade
2025-10-30 19:10 ` [PATCH v2 3/3] ARM: dts: ti/omap: omap4-epson-embt2ws: add powerbutton akemnade
2 siblings, 1 reply; 6+ messages in thread
From: akemnade @ 2025-10-30 19:10 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andreas Kemnade, Dmitry Torokhov, Tony Lindgren, Kevin Hilman
Cc: devicetree, linux-kernel, linux-input, linux-omap,
Andreas Kemnade
From: Andreas Kemnade <andreas@kemnade.info>
TWL603x has also a power button function, so add the corresponding subnode.
As not in all cases there is a power button connected to the corresponding
pad of the TWL603x, the functionality can be disabled by
status = "disabled" or simply not adding the subnode.
To keep things simple, follow the established design pattern of using const
interrupts as used also by the other subdevices.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
Documentation/devicetree/bindings/mfd/ti,twl.yaml | 40 ++++++++++++++++++-----
1 file changed, 32 insertions(+), 8 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/ti,twl.yaml b/Documentation/devicetree/bindings/mfd/ti,twl.yaml
index 776b04e182cb..3527fee32cb0 100644
--- a/Documentation/devicetree/bindings/mfd/ti,twl.yaml
+++ b/Documentation/devicetree/bindings/mfd/ti,twl.yaml
@@ -55,6 +55,15 @@ allOf:
gpadc: false
+ pwrbutton:
+ properties:
+ compatible:
+ const: ti,twl4030-pwrbutton
+ interrupts:
+ items:
+ - items:
+ const: 8
+
usb-comparator: false
- if:
@@ -95,7 +104,14 @@ allOf:
compatible:
const: ti,twl6030-gpadc
- pwrbutton: false
+ pwrbutton:
+ properties:
+ compatible:
+ const: ti,twl6030-pwrbutton
+ interrupts:
+ items:
+ - items:
+ const: 0
madc: false
@@ -146,7 +162,14 @@ allOf:
compatible:
const: ti,twl6032-gpadc
- pwrbutton: false
+ pwrbutton:
+ properties:
+ compatible:
+ const: ti,twl6030-pwrbutton
+ interrupts:
+ items:
+ - items:
+ const: 0
madc: false
@@ -225,12 +248,8 @@ properties:
additionalProperties: false
properties:
- compatible:
- const: ti,twl4030-pwrbutton
- interrupts:
- items:
- - items:
- const: 8
+ compatible: true
+ interrupts: true
watchdog:
type: object
@@ -459,6 +478,11 @@ examples:
#io-channel-cells = <1>;
};
+ pwrbutton {
+ compatible = "ti,twl6030-pwrbutton";
+ interrupts = <0>;
+ };
+
rtc {
compatible = "ti,twl4030-rtc";
interrupts = <8>;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v2 2/3] Input: twl4030 - add TWL603x power button
2025-10-30 19:10 [PATCH v2 0/3] mfd: twl603x: add power button akemnade
2025-10-30 19:10 ` [PATCH v2 1/3] dt-bindings: mfd: twl: enable power button also for twl603x akemnade
@ 2025-10-30 19:10 ` akemnade
2025-10-31 17:02 ` kernel test robot
2025-10-30 19:10 ` [PATCH v2 3/3] ARM: dts: ti/omap: omap4-epson-embt2ws: add powerbutton akemnade
2 siblings, 1 reply; 6+ messages in thread
From: akemnade @ 2025-10-30 19:10 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andreas Kemnade, Dmitry Torokhov, Tony Lindgren, Kevin Hilman
Cc: devicetree, linux-kernel, linux-input, linux-omap,
Andreas Kemnade
From: Andreas Kemnade <andreas@kemnade.info>
Like the TWL4030, these PMICs also have a power button feature, so extend
the TWL4030 power button driver. As the irqchip of the TWL6030 mfd driver
does not provide mask, unmask finctions, do it manually.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
drivers/input/misc/twl4030-pwrbutton.c | 61 +++++++++++++++++++++++++++++++---
1 file changed, 57 insertions(+), 4 deletions(-)
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index f85cc289c053..f8c337f62393 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -25,22 +25,40 @@
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/input.h>
+#include <linux/bits.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/mfd/twl.h>
-#define PWR_PWRON_IRQ (1 << 0)
+#define PWR_PWRON_IRQ BIT(0)
-#define STS_HW_CONDITIONS 0xf
+#define STS_HW_CONDITIONS_4030 0xf
+#define STS_HW_CONDITIONS_6030 0x2
+
+struct twl_pwrbutton_chipdata {
+ u8 status_reg;
+ bool need_manual_irq;
+};
+
+struct twl_pwrbutton_chipdata twl4030_chipdata = {
+ STS_HW_CONDITIONS_4030,
+ false,
+};
+
+struct twl_pwrbutton_chipdata twl6030_chipdata = {
+ STS_HW_CONDITIONS_6030,
+ true,
+};
static irqreturn_t powerbutton_irq(int irq, void *_pwr)
{
struct input_dev *pwr = _pwr;
+ const struct twl_pwrbutton_chipdata *pdata = dev_get_drvdata(pwr->dev.parent);
int err;
u8 value;
- err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &value, STS_HW_CONDITIONS);
+ err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &value, pdata->status_reg);
if (!err) {
pm_wakeup_event(pwr->dev.parent, 0);
input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
@@ -55,10 +73,17 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
static int twl4030_pwrbutton_probe(struct platform_device *pdev)
{
+ const struct twl_pwrbutton_chipdata *pdata;
struct input_dev *pwr;
int irq = platform_get_irq(pdev, 0);
int err;
+ pdata = device_get_match_data(&pdev->dev);
+ if (!pdata)
+ return -EINVAL;
+
+ platform_set_drvdata(pdev, (void *)pdata);
+
pwr = devm_input_allocate_device(&pdev->dev);
if (!pwr) {
dev_err(&pdev->dev, "Can't allocate power button\n");
@@ -85,14 +110,41 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev)
return err;
}
+ if (pdata->need_manual_irq) {
+ err = twl6030_interrupt_unmask(0x01, REG_INT_MSK_LINE_A);
+ if (err < 0)
+ return err;
+
+ err = twl6030_interrupt_unmask(0x01, REG_INT_MSK_STS_A);
+ if (err < 0)
+ return err;
+ }
+
device_init_wakeup(&pdev->dev, true);
return 0;
}
+static void twl4030_pwrbutton_remove(struct platform_device *pdev)
+{
+ const struct twl_pwrbutton_chipdata *pdata = platform_get_drvdata(pdev);
+
+ if (pdata->need_manual_irq) {
+ twl6030_interrupt_mask(0x01, REG_INT_MSK_LINE_A);
+ twl6030_interrupt_mask(0x01, REG_INT_MSK_STS_A);
+ }
+}
+
#ifdef CONFIG_OF
static const struct of_device_id twl4030_pwrbutton_dt_match_table[] = {
- { .compatible = "ti,twl4030-pwrbutton" },
+ {
+ .compatible = "ti,twl4030-pwrbutton",
+ .data = &twl4030_chipdata,
+ },
+ {
+ .compatible = "ti,twl6030-pwrbutton",
+ .data = &twl6030_chipdata,
+ },
{},
};
MODULE_DEVICE_TABLE(of, twl4030_pwrbutton_dt_match_table);
@@ -100,6 +152,7 @@ MODULE_DEVICE_TABLE(of, twl4030_pwrbutton_dt_match_table);
static struct platform_driver twl4030_pwrbutton_driver = {
.probe = twl4030_pwrbutton_probe,
+ .remove = twl4030_pwrbutton_remove,
.driver = {
.name = "twl4030_pwrbutton",
.of_match_table = of_match_ptr(twl4030_pwrbutton_dt_match_table),
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v2 3/3] ARM: dts: ti/omap: omap4-epson-embt2ws: add powerbutton
2025-10-30 19:10 [PATCH v2 0/3] mfd: twl603x: add power button akemnade
2025-10-30 19:10 ` [PATCH v2 1/3] dt-bindings: mfd: twl: enable power button also for twl603x akemnade
2025-10-30 19:10 ` [PATCH v2 2/3] Input: twl4030 - add TWL603x power button akemnade
@ 2025-10-30 19:10 ` akemnade
2 siblings, 0 replies; 6+ messages in thread
From: akemnade @ 2025-10-30 19:10 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andreas Kemnade, Dmitry Torokhov, Tony Lindgren, Kevin Hilman
Cc: devicetree, linux-kernel, linux-input, linux-omap,
Andreas Kemnade
From: Andreas Kemnade <andreas@kemnade.info>
There is a power button connected to the PMIC, so describe it to be able
to power off the device in a convenient manner.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts b/arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts
index c90f43cc2fae..673df1b693f2 100644
--- a/arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts
+++ b/arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts
@@ -229,6 +229,11 @@ rtc {
interrupts = <11>;
};
+ pwrbutton {
+ compatible = "ti,twl6030-pwrbutton";
+ interrupts = <0>;
+ };
+
ldo2: regulator-ldo2 {
compatible = "ti,twl6032-ldo2";
regulator-min-microvolt = <1000000>;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread