linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/5] mfd: twl: system-power-controller
@ 2024-02-17  8:20 Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 1/5] dt-bindings: mfd: ti,twl: Document system-power-controller Andreas Kemnade
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-02-17  8:20 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	andreas, devicetree, linux-kernel, linux-omap

Add system-power-controller property in the bindings and
the corresponding implementation and use it where
appropriate.
Not all cases are hit yet, there has probably to be a
separate series after going through with a brush.

Changes in v4:
- fix spelling/grammar
- drop twl4030 dts cleanup, it would need an IB
  or be postponed till next release 

Changes in v3:
- twl-core: 
   - remove repetitive verbose error messages
   - placed constants at top part of function
   - minor cleanups

Changes in v2:
- add A-By
- fix compiler warning

Andreas Kemnade (5):
  dt-bindings: mfd: ti,twl: Document system-power-controller
  twl-core: add power off implementation for twl603x
  ARM: dts: omap-embt2ws: system-power-controller for bt200
  ARM: dts: omap4-panda-common: Enable powering off the device
  mfd: twl4030-power: accept standard property for power controller

 .../devicetree/bindings/mfd/ti,twl.yaml       |  2 ++
 .../boot/dts/ti/omap/omap4-epson-embt2ws.dts  |  1 +
 .../boot/dts/ti/omap/omap4-panda-common.dtsi  |  1 +
 drivers/mfd/twl-core.c                        | 28 +++++++++++++++++++
 drivers/mfd/twl4030-power.c                   |  3 ++
 include/linux/mfd/twl.h                       |  1 +
 6 files changed, 36 insertions(+)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 1/5] dt-bindings: mfd: ti,twl: Document system-power-controller
  2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
@ 2024-02-17  8:20 ` Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 2/5] twl-core: add power off implementation for twl603x Andreas Kemnade
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-02-17  8:20 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	andreas, devicetree, linux-kernel, linux-omap
  Cc: Conor Dooley

Add system-power-controller property because these chips
can power off the device.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 Documentation/devicetree/bindings/mfd/ti,twl.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/ti,twl.yaml b/Documentation/devicetree/bindings/mfd/ti,twl.yaml
index c04d57ba22b49..52ed228fb1e7e 100644
--- a/Documentation/devicetree/bindings/mfd/ti,twl.yaml
+++ b/Documentation/devicetree/bindings/mfd/ti,twl.yaml
@@ -34,6 +34,8 @@ properties:
 
   interrupt-controller: true
 
+  system-power-controller: true
+
   "#interrupt-cells":
     const: 1
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 2/5] twl-core: add power off implementation for twl603x
  2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 1/5] dt-bindings: mfd: ti,twl: Document system-power-controller Andreas Kemnade
@ 2024-02-17  8:20 ` Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 3/5] ARM: dts: omap-embt2ws: system-power-controller for bt200 Andreas Kemnade
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-02-17  8:20 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	andreas, devicetree, linux-kernel, linux-omap

If the system-power-controller property is there, enable power off.
Implementation is based on a Linux v3.0 vendor kernel.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/mfd/twl-core.c  | 28 ++++++++++++++++++++++++++++
 include/linux/mfd/twl.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 6e384a79e3418..c130ffef182f1 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -124,6 +124,11 @@
 #define TWL6030_BASEADD_RSV		0x0000
 #define TWL6030_BASEADD_ZERO		0x0000
 
+/* Some fields in TWL6030_PHOENIX_DEV_ON */
+#define TWL6030_APP_DEVOFF		BIT(0)
+#define TWL6030_CON_DEVOFF		BIT(1)
+#define TWL6030_MOD_DEVOFF		BIT(2)
+
 /* Few power values */
 #define R_CFG_BOOT			0x05
 
@@ -687,6 +692,20 @@ static void twl_remove(struct i2c_client *client)
 	twl_priv->ready = false;
 }
 
+static void twl6030_power_off(void)
+{
+	int err;
+	u8 val;
+
+	err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, TWL6030_PHOENIX_DEV_ON);
+	if (err)
+		return;
+
+	val |= TWL6030_APP_DEVOFF | TWL6030_CON_DEVOFF | TWL6030_MOD_DEVOFF;
+	twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val, TWL6030_PHOENIX_DEV_ON);
+}
+
+
 static struct of_dev_auxdata twl_auxdata_lookup[] = {
 	OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL),
 	{ /* sentinel */ },
@@ -852,6 +871,15 @@ twl_probe(struct i2c_client *client)
 			goto free;
 	}
 
+	if (twl_class_is_6030()) {
+		if (of_device_is_system_power_controller(node)) {
+			if (!pm_power_off)
+				pm_power_off = twl6030_power_off;
+			else
+				dev_warn(&client->dev, "Poweroff callback already assigned\n");
+		}
+	}
+
 	status = of_platform_populate(node, NULL, twl_auxdata_lookup,
 				      &client->dev);
 
diff --git a/include/linux/mfd/twl.h b/include/linux/mfd/twl.h
index c062d91a67d92..85dc406173dba 100644
--- a/include/linux/mfd/twl.h
+++ b/include/linux/mfd/twl.h
@@ -461,6 +461,7 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
 
 #define TWL4030_PM_MASTER_GLOBAL_TST		0xb6
 
+#define TWL6030_PHOENIX_DEV_ON                  0x06
 /*----------------------------------------------------------------------*/
 
 /* Power bus message definitions */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 3/5] ARM: dts: omap-embt2ws: system-power-controller for bt200
  2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 1/5] dt-bindings: mfd: ti,twl: Document system-power-controller Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 2/5] twl-core: add power off implementation for twl603x Andreas Kemnade
@ 2024-02-17  8:20 ` Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 4/5] ARM: dts: omap4-panda-common: Enable powering off the device Andreas Kemnade
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-02-17  8:20 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	andreas, devicetree, linux-kernel, linux-omap

Configure the TWL6032 as system power controller to let the device
power off.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts | 1 +
 1 file changed, 1 insertion(+)

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 24f7d0285f799..339e52ba3614b 100644
--- a/arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts
+++ b/arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts
@@ -85,6 +85,7 @@ twl: pmic@48 {
 		interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* IRQ_SYS_1N cascaded to gic */
 		interrupt-controller;
 		#interrupt-cells = <1>;
+		system-power-controller;
 
 		rtc {
 			compatible = "ti,twl4030-rtc";
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 4/5] ARM: dts: omap4-panda-common: Enable powering off the device
  2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
                   ` (2 preceding siblings ...)
  2024-02-17  8:20 ` [PATCH v4 3/5] ARM: dts: omap-embt2ws: system-power-controller for bt200 Andreas Kemnade
@ 2024-02-17  8:20 ` Andreas Kemnade
  2024-02-17  8:20 ` [PATCH v4 5/5] mfd: twl4030-power: accept standard property for power controller Andreas Kemnade
  2024-02-23 16:12 ` (subset) [PATCH v4 0/5] mfd: twl: system-power-controller Lee Jones
  5 siblings, 0 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-02-17  8:20 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	andreas, devicetree, linux-kernel, linux-omap

As the TWL6030 chip is the main power controller here, declare
it as system-power-controller

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 arch/arm/boot/dts/ti/omap/omap4-panda-common.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/ti/omap/omap4-panda-common.dtsi b/arch/arm/boot/dts/ti/omap/omap4-panda-common.dtsi
index f528511c2537b..97706d6296a68 100644
--- a/arch/arm/boot/dts/ti/omap/omap4-panda-common.dtsi
+++ b/arch/arm/boot/dts/ti/omap/omap4-panda-common.dtsi
@@ -408,6 +408,7 @@ twl: twl@48 {
 		reg = <0x48>;
 		/* IRQ# = 7 */
 		interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* IRQ_SYS_1N cascaded to gic */
+		system-power-controller;
 	};
 
 	twl6040: twl@4b {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 5/5] mfd: twl4030-power: accept standard property for power controller
  2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
                   ` (3 preceding siblings ...)
  2024-02-17  8:20 ` [PATCH v4 4/5] ARM: dts: omap4-panda-common: Enable powering off the device Andreas Kemnade
@ 2024-02-17  8:20 ` Andreas Kemnade
  2024-02-23 16:12 ` (subset) [PATCH v4 0/5] mfd: twl: system-power-controller Lee Jones
  5 siblings, 0 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-02-17  8:20 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	andreas, devicetree, linux-kernel, linux-omap

Instead of only accepting the ti specific properties accept also
the standard property. For uniformity, search in the parent node
for the tag. The code for powering off is also isolated from the
rest in this file. So it is a pure Linux design decision to put it
here.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/mfd/twl4030-power.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 1595e9c76132d..0bca948ab6bae 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -686,6 +686,9 @@ static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
 	if (of_property_read_bool(node, "ti,use_poweroff"))
 		return true;
 
+	if (of_device_is_system_power_controller(node->parent))
+		return true;
+
 	return false;
 }
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: (subset) [PATCH v4 0/5] mfd: twl: system-power-controller
  2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
                   ` (4 preceding siblings ...)
  2024-02-17  8:20 ` [PATCH v4 5/5] mfd: twl4030-power: accept standard property for power controller Andreas Kemnade
@ 2024-02-23 16:12 ` Lee Jones
  2024-02-26 12:11   ` Tony Lindgren
  5 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2024-02-23 16:12 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, tony,
	devicetree, linux-kernel, linux-omap, Andreas Kemnade

On Sat, 17 Feb 2024 09:20:02 +0100, Andreas Kemnade wrote:
> Add system-power-controller property in the bindings and
> the corresponding implementation and use it where
> appropriate.
> Not all cases are hit yet, there has probably to be a
> separate series after going through with a brush.
> 
> Changes in v4:
> - fix spelling/grammar
> - drop twl4030 dts cleanup, it would need an IB
>   or be postponed till next release
> 
> [...]

Applied, thanks!

[1/5] dt-bindings: mfd: ti,twl: Document system-power-controller
      commit: 0c7cc7497f6f62a65037e94cf0d885ab0af3c0d3
[2/5] twl-core: add power off implementation for twl603x
      commit: ca9414a1d08756c8392f9219caee607e1b7bade1
[5/5] mfd: twl4030-power: accept standard property for power controller
      commit: 8ba560ec14267af1169e1f5407fbce514fd4f6f6

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: (subset) [PATCH v4 0/5] mfd: twl: system-power-controller
  2024-02-23 16:12 ` (subset) [PATCH v4 0/5] mfd: twl: system-power-controller Lee Jones
@ 2024-02-26 12:11   ` Tony Lindgren
  0 siblings, 0 replies; 8+ messages in thread
From: Tony Lindgren @ 2024-02-26 12:11 UTC (permalink / raw)
  To: Lee Jones
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, bcousson, devicetree,
	linux-kernel, linux-omap, Andreas Kemnade

* Lee Jones <lee@kernel.org> [240223 16:12]:
> On Sat, 17 Feb 2024 09:20:02 +0100, Andreas Kemnade wrote:
> > Add system-power-controller property in the bindings and
> > the corresponding implementation and use it where
> > appropriate.
> > Not all cases are hit yet, there has probably to be a
> > separate series after going through with a brush.
> > 
> > Changes in v4:
> > - fix spelling/grammar
> > - drop twl4030 dts cleanup, it would need an IB
> >   or be postponed till next release
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/5] dt-bindings: mfd: ti,twl: Document system-power-controller
>       commit: 0c7cc7497f6f62a65037e94cf0d885ab0af3c0d3
> [2/5] twl-core: add power off implementation for twl603x
>       commit: ca9414a1d08756c8392f9219caee607e1b7bade1
> [5/5] mfd: twl4030-power: accept standard property for power controller
>       commit: 8ba560ec14267af1169e1f5407fbce514fd4f6f6

Applying the two dts changes into omap-for-v6.9/dt thanks.

Tony

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-02-26 12:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-17  8:20 [PATCH v4 0/5] mfd: twl: system-power-controller Andreas Kemnade
2024-02-17  8:20 ` [PATCH v4 1/5] dt-bindings: mfd: ti,twl: Document system-power-controller Andreas Kemnade
2024-02-17  8:20 ` [PATCH v4 2/5] twl-core: add power off implementation for twl603x Andreas Kemnade
2024-02-17  8:20 ` [PATCH v4 3/5] ARM: dts: omap-embt2ws: system-power-controller for bt200 Andreas Kemnade
2024-02-17  8:20 ` [PATCH v4 4/5] ARM: dts: omap4-panda-common: Enable powering off the device Andreas Kemnade
2024-02-17  8:20 ` [PATCH v4 5/5] mfd: twl4030-power: accept standard property for power controller Andreas Kemnade
2024-02-23 16:12 ` (subset) [PATCH v4 0/5] mfd: twl: system-power-controller Lee Jones
2024-02-26 12:11   ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).