From: Andreas Kemnade <andreas@kemnade.info>
To: lee@kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
bcousson@baylibre.com, tony@atomide.com, andreas@kemnade.info,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-omap@vger.kernel.org
Subject: [PATCH 2/6] twl-core: add power off implementation for twl603x
Date: Sat, 25 Nov 2023 10:29:34 +0100 [thread overview]
Message-ID: <20231125092938.16535-3-andreas@kemnade.info> (raw)
In-Reply-To: <20231125092938.16535-1-andreas@kemnade.info>
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 | 34 ++++++++++++++++++++++++++++++++++
include/linux/mfd/twl.h | 1 +
2 files changed, 35 insertions(+)
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 6e384a79e3418..3eef285eac535 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -687,6 +687,31 @@ static void twl_remove(struct i2c_client *client)
twl_priv->ready = false;
}
+void twl6030_power_off(void)
+{
+#define APP_DEVOFF (1<<0)
+#define CON_DEVOFF (1<<1)
+#define MOD_DEVOFF (1<<2)
+
+ int err;
+ u8 val;
+
+ err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
+ TWL6030_PHOENIX_DEV_ON);
+ if (err) {
+ pr_err("I2C error %d reading PHOENIX_DEV_ON\n", err);
+ return;
+ }
+
+ val |= APP_DEVOFF | CON_DEVOFF | MOD_DEVOFF;
+
+ err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val,
+ TWL6030_PHOENIX_DEV_ON);
+ if (err)
+ pr_err("TWL6030 Unable to power off\n");
+}
+
+
static struct of_dev_auxdata twl_auxdata_lookup[] = {
OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL),
{ /* sentinel */ },
@@ -852,6 +877,15 @@ twl_probe(struct i2c_client *client)
goto free;
}
+ if (twl_class_is_6030()) {
+ if (of_device_is_system_power_controller(client->dev.of_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
next prev parent reply other threads:[~2023-11-25 9:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-25 9:29 [PATCH 0/6] mfd: twl: system-power-controller Andreas Kemnade
2023-11-25 9:29 ` [PATCH 1/6] dt-bindings: mfd: ti,twl: Document system-power-controller Andreas Kemnade
2023-11-25 11:46 ` Conor Dooley
2023-11-25 9:29 ` Andreas Kemnade [this message]
2023-11-25 15:13 ` [PATCH 2/6] twl-core: add power off implementation for twl603x kernel test robot
2023-11-25 20:00 ` kernel test robot
2023-11-26 23:32 ` kernel test robot
2023-11-25 9:29 ` [PATCH 3/6] ARM: dts: omap-embt2ws: system-power-controller for bt200 Andreas Kemnade
2023-11-25 9:29 ` [PATCH 4/6] ARM: dts: omap4-panda-common: Enable powering off the device Andreas Kemnade
2023-11-25 9:29 ` [PATCH 5/6] mfd: twl4030-power: accept standard property for power controller Andreas Kemnade
2023-11-25 9:29 ` [PATCH 6/6] ARM: dts: omap: gta04: standardize system-power-controller Andreas Kemnade
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231125092938.16535-3-andreas@kemnade.info \
--to=andreas@kemnade.info \
--cc=bcousson@baylibre.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).