Add support for Partial-IO poweroff. In Partial-IO pins of a few
hardware units can generate system wakeups while DDR memory is not
powered resulting in a fresh boot of the system. These hardware units in
the SoC are always powered so that some logic can detect pin activity.
If the system supports Partial-IO as described in the fw capabilities, a
sys_off handler is added. This sys_off handler decides if the poweroff
is executed by entering normal poweroff or Partial-IO instead. The
decision is made by checking if wakeup is enabled on all devices that
may wake up the SoC from Partial-IO.
The possible wakeup devices are found by checking which devices
reference a "Partial-IO" system state in the list of wakeup-source
system states. Only devices that are actually enabled by the user will
be considered as an active wakeup source. If none of the wakeup sources
is enabled the system will do a normal poweroff. If at least one wakeup
source is enabled it will instead send a TI_SCI_MSG_PREPARE_SLEEP
message from the sys_off handler. Sending this message will result in an
immediate shutdown of the system. No execution is expected after this
point. The code will wait for 5s and do an emergency_restart afterwards
if Partial-IO wasn't entered at that point.
A short documentation about Partial-IO can be found in section 6.2.4.5
of the TRM at
https://www.ti.com/lit/pdf/spruiv7
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
drivers/firmware/ti_sci.c | 132 +++++++++++++++++++++++++++++++++++++++++++++-
drivers/firmware/ti_sci.h | 5 ++
2 files changed, 136 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 4db84a92a517b0aa7bb8d47e809d9848a16e2cc4..f2922fccfbe748a436cb9aa0a8c8e5f48db02ef9 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -6,6 +6,7 @@
* Nishanth Menon
*/
+#include "linux/dev_printk.h"
#define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/bitmap.h>
@@ -3663,6 +3664,116 @@ devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
}
EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource);
+/*
+ * Enter Partial-IO, which disables everything including DDR with only a small
+ * logic being active for wakeup.
+ */
+static int ti_sci_enter_partial_io(struct ti_sci_info *info)
+{
+ struct ti_sci_msg_req_prepare_sleep *req;
+ struct ti_sci_xfer *xfer;
+ struct device *dev = info->dev;
+ int ret = 0;
+
+ xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PREPARE_SLEEP,
+ TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
+ sizeof(*req), sizeof(struct ti_sci_msg_hdr));
+ if (IS_ERR(xfer)) {
+ ret = PTR_ERR(xfer);
+ dev_err(dev, "Message alloc failed(%d)\n", ret);
+ return ret;
+ }
+
+ req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf;
+ req->mode = TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO;
+ req->ctx_lo = 0;
+ req->ctx_hi = 0;
+ req->debug_flags = 0;
+
+ ret = ti_sci_do_xfer(info, xfer);
+ if (ret) {
+ dev_err(dev, "Mbox send fail %d\n", ret);
+ goto fail;
+ }
+
+fail:
+ ti_sci_put_one_xfer(&info->minfo, xfer);
+
+ return ret;
+}
+
+/*
+ * Iterate all device nodes that have a wakeup-source property and check if one
+ * of the possible phandles points to a Partial-IO system state. If it
+ * does resolve the device node to an actual device and check if wakeup is
+ * enabled.
+ */
+static bool ti_sci_partial_io_wakeup_enabled(struct ti_sci_info *info)
+{
+ struct device_node *wakeup_node = NULL;
+
+ for_each_node_with_property(wakeup_node, "wakeup-source") {
+ struct of_phandle_iterator it;
+ int err;
+
+ of_for_each_phandle(&it, err, wakeup_node, "wakeup-source", NULL, 0) {
+ struct platform_device *pdev;
+ bool may_wakeup;
+
+ /*
+ * Continue if idle-state-name is not off-wake. Return
+ * value is the index of the string which should be 0 if
+ * off-wake is present.
+ */
+ if (of_property_match_string(it.node, "idle-state-name", "off-wake"))
+ continue;
+
+ pdev = of_find_device_by_node(wakeup_node);
+ if (!pdev)
+ continue;
+
+ may_wakeup = device_may_wakeup(&pdev->dev);
+ put_device(&pdev->dev);
+
+ if (may_wakeup) {
+ dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n",
+ wakeup_node);
+ of_node_put(it.node);
+ of_node_put(wakeup_node);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+static int ti_sci_sys_off_handler(struct sys_off_data *data)
+{
+ struct ti_sci_info *info = data->cb_data;
+ bool enter_partial_io = ti_sci_partial_io_wakeup_enabled(info);
+ int ret;
+
+ if (!enter_partial_io)
+ return NOTIFY_DONE;
+
+ dev_info(info->dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
+
+ ret = ti_sci_enter_partial_io(info);
+
+ if (ret) {
+ dev_err(info->dev,
+ "Failed to enter Partial-IO %pe, trying to do an emergency restart\n",
+ ERR_PTR(ret));
+ emergency_restart();
+ }
+
+ mdelay(5000);
+ emergency_restart();
+
+ return NOTIFY_DONE;
+}
+
static int tisci_reboot_handler(struct sys_off_data *data)
{
struct ti_sci_info *info = data->cb_data;
@@ -3941,6 +4052,19 @@ static int ti_sci_probe(struct platform_device *pdev)
goto out;
}
+ if (info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO) {
+ ret = devm_register_sys_off_handler(dev,
+ SYS_OFF_MODE_POWER_OFF,
+ SYS_OFF_PRIO_FIRMWARE,
+ ti_sci_sys_off_handler,
+ info);
+ if (ret) {
+ dev_err(dev, "Failed to register sys_off_handler %pe\n",
+ ERR_PTR(ret));
+ goto out;
+ }
+ }
+
dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n",
info->handle.version.abi_major, info->handle.version.abi_minor,
info->handle.version.firmware_revision,
@@ -3950,7 +4074,13 @@ static int ti_sci_probe(struct platform_device *pdev)
list_add_tail(&info->node, &ti_sci_list);
mutex_unlock(&ti_sci_list_mutex);
- return of_platform_populate(dev->of_node, NULL, NULL, dev);
+ ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
+ if (ret) {
+ dev_err(dev, "platform_populate failed %pe\n", ERR_PTR(ret));
+ goto out;
+ }
+ return 0;
+
out:
if (!IS_ERR(info->chan_tx))
mbox_free_channel(info->chan_tx);
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index 701c416b2e78f8ef20ce6741a88ffa6fd4853b2d..09eaea54dd5cabce72dd1652c9603e3ab446b60c 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -595,6 +595,11 @@ struct ti_sci_msg_resp_get_clock_freq {
struct ti_sci_msg_req_prepare_sleep {
struct ti_sci_msg_hdr hdr;
+/*
+ * When sending prepare_sleep with MODE_PARTIAL_IO no response will be sent,
+ * no further steps are required.
+ */
+#define TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO 0x03
#define TISCI_MSG_VALUE_SLEEP_MODE_DM_MANAGED 0xfd
u8 mode;
u32 ctx_lo;
--
2.51.0
Hi Markus,
kernel test robot noticed the following build warnings:
[auto build test WARNING on c9a389ffad27e7847c69f4d2b67ba56b77190209]
url: https://github.com/intel-lab-lkp/linux/commits/Markus-Schneider-Pargmann-TI-com/firmware-ti_sci-Remove-constant-0-function-arguments/20251030-173054
base: c9a389ffad27e7847c69f4d2b67ba56b77190209
patch link: https://lore.kernel.org/r/20251030-topic-am62-partialio-v6-12-b4-v9-3-074f55d9c16b%40baylibre.com
patch subject: [PATCH v9 3/3] firmware: ti_sci: Partial-IO support
config: arm-randconfig-002-20251101 (https://download.01.org/0day-ci/archive/20251102/202511020037.8sAseAYs-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project d2625a438020ad35330cda29c3def102c1687b1b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251102/202511020037.8sAseAYs-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511020037.8sAseAYs-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/firmware/ti_sci.c:10:9: warning: 'pr_fmt' macro redefined [-Wmacro-redefined]
10 | #define pr_fmt(fmt) "%s: " fmt, __func__
| ^
include/linux/printk.h:402:9: note: previous definition is here
402 | #define pr_fmt(fmt) fmt
| ^
1 warning generated.
vim +/pr_fmt +10 drivers/firmware/ti_sci.c
aa276781a64a5f Nishanth Menon 2016-10-18 @10 #define pr_fmt(fmt) "%s: " fmt, __func__
aa276781a64a5f Nishanth Menon 2016-10-18 11
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 10/30/25 4:26 AM, Markus Schneider-Pargmann (TI.com) wrote:
> Add support for Partial-IO poweroff. In Partial-IO pins of a few
> hardware units can generate system wakeups while DDR memory is not
> powered resulting in a fresh boot of the system. These hardware units in
> the SoC are always powered so that some logic can detect pin activity.
>
> If the system supports Partial-IO as described in the fw capabilities, a
> sys_off handler is added. This sys_off handler decides if the poweroff
> is executed by entering normal poweroff or Partial-IO instead. The
> decision is made by checking if wakeup is enabled on all devices that
> may wake up the SoC from Partial-IO.
>
> The possible wakeup devices are found by checking which devices
> reference a "Partial-IO" system state in the list of wakeup-source
> system states. Only devices that are actually enabled by the user will
> be considered as an active wakeup source. If none of the wakeup sources
> is enabled the system will do a normal poweroff. If at least one wakeup
> source is enabled it will instead send a TI_SCI_MSG_PREPARE_SLEEP
> message from the sys_off handler. Sending this message will result in an
> immediate shutdown of the system. No execution is expected after this
> point. The code will wait for 5s and do an emergency_restart afterwards
> if Partial-IO wasn't entered at that point.
>
> A short documentation about Partial-IO can be found in section 6.2.4.5
> of the TRM at
> https://www.ti.com/lit/pdf/spruiv7
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
> drivers/firmware/ti_sci.c | 132 +++++++++++++++++++++++++++++++++++++++++++++-
> drivers/firmware/ti_sci.h | 5 ++
> 2 files changed, 136 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index 4db84a92a517b0aa7bb8d47e809d9848a16e2cc4..f2922fccfbe748a436cb9aa0a8c8e5f48db02ef9 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -6,6 +6,7 @@
> * Nishanth Menon
> */
>
> +#include "linux/dev_printk.h"
> #define pr_fmt(fmt) "%s: " fmt, __func__
>
> #include <linux/bitmap.h>
> @@ -3663,6 +3664,116 @@ devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
> }
> EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource);
>
> +/*
> + * Enter Partial-IO, which disables everything including DDR with only a small
> + * logic being active for wakeup.
> + */
> +static int ti_sci_enter_partial_io(struct ti_sci_info *info)
> +{
> + struct ti_sci_msg_req_prepare_sleep *req;
> + struct ti_sci_xfer *xfer;
> + struct device *dev = info->dev;
> + int ret = 0;
> +
> + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PREPARE_SLEEP,
> + TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
> + sizeof(*req), sizeof(struct ti_sci_msg_hdr));
> + if (IS_ERR(xfer)) {
> + ret = PTR_ERR(xfer);
> + dev_err(dev, "Message alloc failed(%d)\n", ret);
> + return ret;
> + }
> +
> + req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf;
> + req->mode = TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO;
This whole function is almost identical to ti_sci_cmd_prepare_sleep() other
than you use a different mode here, which this different mode can be passed
into ti_sci_cmd_prepare_sleep() just the same. Only other difference would
be the NORESPONSE flag which you could just check "mode" passed in and
use the right flag for the mode.
> + req->ctx_lo = 0;
> + req->ctx_hi = 0;
> + req->debug_flags = 0;
> +
> + ret = ti_sci_do_xfer(info, xfer);
> + if (ret) {
> + dev_err(dev, "Mbox send fail %d\n", ret);
> + goto fail;
> + }
> +
> +fail:
> + ti_sci_put_one_xfer(&info->minfo, xfer);
> +
> + return ret;
> +}
> +
> +/*
> + * Iterate all device nodes that have a wakeup-source property and check if one
> + * of the possible phandles points to a Partial-IO system state. If it
> + * does resolve the device node to an actual device and check if wakeup is
> + * enabled.
> + */
> +static bool ti_sci_partial_io_wakeup_enabled(struct ti_sci_info *info)
> +{
> + struct device_node *wakeup_node = NULL;
> +
> + for_each_node_with_property(wakeup_node, "wakeup-source") {
> + struct of_phandle_iterator it;
> + int err;
> +
> + of_for_each_phandle(&it, err, wakeup_node, "wakeup-source", NULL, 0) {
> + struct platform_device *pdev;
> + bool may_wakeup;
> +
> + /*
> + * Continue if idle-state-name is not off-wake. Return
> + * value is the index of the string which should be 0 if
> + * off-wake is present.
> + */
> + if (of_property_match_string(it.node, "idle-state-name", "off-wake"))
> + continue;
> +
> + pdev = of_find_device_by_node(wakeup_node);
> + if (!pdev)
> + continue;
> +
> + may_wakeup = device_may_wakeup(&pdev->dev);
> + put_device(&pdev->dev);
> +
> + if (may_wakeup) {
> + dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n",
> + wakeup_node);
> + of_node_put(it.node);
> + of_node_put(wakeup_node);
> + return true;
> + }
> + }
> + }
> +
> + return false;
> +}
> +
> +static int ti_sci_sys_off_handler(struct sys_off_data *data)
> +{
> + struct ti_sci_info *info = data->cb_data;
> + bool enter_partial_io = ti_sci_partial_io_wakeup_enabled(info);
> + int ret;
> +
> + if (!enter_partial_io)
> + return NOTIFY_DONE;
> +
> + dev_info(info->dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
> +
> + ret = ti_sci_enter_partial_io(info);
> +
No need for newline here.
> + if (ret) {
> + dev_err(info->dev,
> + "Failed to enter Partial-IO %pe, trying to do an emergency restart\n",
> + ERR_PTR(ret));
Why cast this int to a pointer before printing it out?
Andrew
> + emergency_restart();
> + }
> +
> + mdelay(5000);
> + emergency_restart();
> +
> + return NOTIFY_DONE;
> +}
> +
> static int tisci_reboot_handler(struct sys_off_data *data)
> {
> struct ti_sci_info *info = data->cb_data;
> @@ -3941,6 +4052,19 @@ static int ti_sci_probe(struct platform_device *pdev)
> goto out;
> }
>
> + if (info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO) {
> + ret = devm_register_sys_off_handler(dev,
> + SYS_OFF_MODE_POWER_OFF,
> + SYS_OFF_PRIO_FIRMWARE,
> + ti_sci_sys_off_handler,
> + info);
> + if (ret) {
> + dev_err(dev, "Failed to register sys_off_handler %pe\n",
> + ERR_PTR(ret));
> + goto out;
> + }
> + }
> +
> dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n",
> info->handle.version.abi_major, info->handle.version.abi_minor,
> info->handle.version.firmware_revision,
> @@ -3950,7 +4074,13 @@ static int ti_sci_probe(struct platform_device *pdev)
> list_add_tail(&info->node, &ti_sci_list);
> mutex_unlock(&ti_sci_list_mutex);
>
> - return of_platform_populate(dev->of_node, NULL, NULL, dev);
> + ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
> + if (ret) {
> + dev_err(dev, "platform_populate failed %pe\n", ERR_PTR(ret));
> + goto out;
> + }
> + return 0;
> +
> out:
> if (!IS_ERR(info->chan_tx))
> mbox_free_channel(info->chan_tx);
> diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
> index 701c416b2e78f8ef20ce6741a88ffa6fd4853b2d..09eaea54dd5cabce72dd1652c9603e3ab446b60c 100644
> --- a/drivers/firmware/ti_sci.h
> +++ b/drivers/firmware/ti_sci.h
> @@ -595,6 +595,11 @@ struct ti_sci_msg_resp_get_clock_freq {
> struct ti_sci_msg_req_prepare_sleep {
> struct ti_sci_msg_hdr hdr;
>
> +/*
> + * When sending prepare_sleep with MODE_PARTIAL_IO no response will be sent,
> + * no further steps are required.
> + */
> +#define TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO 0x03
> #define TISCI_MSG_VALUE_SLEEP_MODE_DM_MANAGED 0xfd
> u8 mode;
> u32 ctx_lo;
>
On Thu Oct 30, 2025 at 3:24 PM CET, Andrew Davis wrote:
> On 10/30/25 4:26 AM, Markus Schneider-Pargmann (TI.com) wrote:
>> Add support for Partial-IO poweroff. In Partial-IO pins of a few
>> hardware units can generate system wakeups while DDR memory is not
>> powered resulting in a fresh boot of the system. These hardware units in
>> the SoC are always powered so that some logic can detect pin activity.
>>
>> If the system supports Partial-IO as described in the fw capabilities, a
>> sys_off handler is added. This sys_off handler decides if the poweroff
>> is executed by entering normal poweroff or Partial-IO instead. The
>> decision is made by checking if wakeup is enabled on all devices that
>> may wake up the SoC from Partial-IO.
>>
>> The possible wakeup devices are found by checking which devices
>> reference a "Partial-IO" system state in the list of wakeup-source
>> system states. Only devices that are actually enabled by the user will
>> be considered as an active wakeup source. If none of the wakeup sources
>> is enabled the system will do a normal poweroff. If at least one wakeup
>> source is enabled it will instead send a TI_SCI_MSG_PREPARE_SLEEP
>> message from the sys_off handler. Sending this message will result in an
>> immediate shutdown of the system. No execution is expected after this
>> point. The code will wait for 5s and do an emergency_restart afterwards
>> if Partial-IO wasn't entered at that point.
>>
>> A short documentation about Partial-IO can be found in section 6.2.4.5
>> of the TRM at
>> https://www.ti.com/lit/pdf/spruiv7
>>
>> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
>> ---
>> drivers/firmware/ti_sci.c | 132 +++++++++++++++++++++++++++++++++++++++++++++-
>> drivers/firmware/ti_sci.h | 5 ++
>> 2 files changed, 136 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
>> index 4db84a92a517b0aa7bb8d47e809d9848a16e2cc4..f2922fccfbe748a436cb9aa0a8c8e5f48db02ef9 100644
>> --- a/drivers/firmware/ti_sci.c
>> +++ b/drivers/firmware/ti_sci.c
>> @@ -6,6 +6,7 @@
>> * Nishanth Menon
>> */
>>
>> +#include "linux/dev_printk.h"
>> #define pr_fmt(fmt) "%s: " fmt, __func__
>>
>> #include <linux/bitmap.h>
>> @@ -3663,6 +3664,116 @@ devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
>> }
>> EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource);
>>
>> +/*
>> + * Enter Partial-IO, which disables everything including DDR with only a small
>> + * logic being active for wakeup.
>> + */
>> +static int ti_sci_enter_partial_io(struct ti_sci_info *info)
>> +{
>> + struct ti_sci_msg_req_prepare_sleep *req;
>> + struct ti_sci_xfer *xfer;
>> + struct device *dev = info->dev;
>> + int ret = 0;
>> +
>> + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PREPARE_SLEEP,
>> + TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
>> + sizeof(*req), sizeof(struct ti_sci_msg_hdr));
>> + if (IS_ERR(xfer)) {
>> + ret = PTR_ERR(xfer);
>> + dev_err(dev, "Message alloc failed(%d)\n", ret);
>> + return ret;
>> + }
>> +
>> + req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf;
>> + req->mode = TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO;
>
> This whole function is almost identical to ti_sci_cmd_prepare_sleep() other
> than you use a different mode here, which this different mode can be passed
> into ti_sci_cmd_prepare_sleep() just the same. Only other difference would
> be the NORESPONSE flag which you could just check "mode" passed in and
> use the right flag for the mode.
I thought this to be nicer as it avoided ifs, but as Kendall and you
both requested this, I changed it for the next version.
>
>> + req->ctx_lo = 0;
>> + req->ctx_hi = 0;
>> + req->debug_flags = 0;
>> +
>> + ret = ti_sci_do_xfer(info, xfer);
>> + if (ret) {
>> + dev_err(dev, "Mbox send fail %d\n", ret);
>> + goto fail;
>> + }
>> +
>> +fail:
>> + ti_sci_put_one_xfer(&info->minfo, xfer);
>> +
>> + return ret;
>> +}
>> +
>> +/*
>> + * Iterate all device nodes that have a wakeup-source property and check if one
>> + * of the possible phandles points to a Partial-IO system state. If it
>> + * does resolve the device node to an actual device and check if wakeup is
>> + * enabled.
>> + */
>> +static bool ti_sci_partial_io_wakeup_enabled(struct ti_sci_info *info)
>> +{
>> + struct device_node *wakeup_node = NULL;
>> +
>> + for_each_node_with_property(wakeup_node, "wakeup-source") {
>> + struct of_phandle_iterator it;
>> + int err;
>> +
>> + of_for_each_phandle(&it, err, wakeup_node, "wakeup-source", NULL, 0) {
>> + struct platform_device *pdev;
>> + bool may_wakeup;
>> +
>> + /*
>> + * Continue if idle-state-name is not off-wake. Return
>> + * value is the index of the string which should be 0 if
>> + * off-wake is present.
>> + */
>> + if (of_property_match_string(it.node, "idle-state-name", "off-wake"))
>> + continue;
>> +
>> + pdev = of_find_device_by_node(wakeup_node);
>> + if (!pdev)
>> + continue;
>> +
>> + may_wakeup = device_may_wakeup(&pdev->dev);
>> + put_device(&pdev->dev);
>> +
>> + if (may_wakeup) {
>> + dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n",
>> + wakeup_node);
>> + of_node_put(it.node);
>> + of_node_put(wakeup_node);
>> + return true;
>> + }
>> + }
>> + }
>> +
>> + return false;
>> +}
>> +
>> +static int ti_sci_sys_off_handler(struct sys_off_data *data)
>> +{
>> + struct ti_sci_info *info = data->cb_data;
>> + bool enter_partial_io = ti_sci_partial_io_wakeup_enabled(info);
>> + int ret;
>> +
>> + if (!enter_partial_io)
>> + return NOTIFY_DONE;
>> +
>> + dev_info(info->dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
>> +
>> + ret = ti_sci_enter_partial_io(info);
>> +
>
> No need for newline here.
>
>> + if (ret) {
>> + dev_err(info->dev,
>> + "Failed to enter Partial-IO %pe, trying to do an emergency restart\n",
>> + ERR_PTR(ret));
>
> Why cast this int to a pointer before printing it out?
I am casting this to an error pointer to get the resolution of the error
value to a symbolic name with %pe. This will print 'EBUSY' etc.
Thanks!
Best
Markus
On 11/3/25 4:31 AM, Markus Schneider-Pargmann wrote:
> On Thu Oct 30, 2025 at 3:24 PM CET, Andrew Davis wrote:
>> On 10/30/25 4:26 AM, Markus Schneider-Pargmann (TI.com) wrote:
>>> Add support for Partial-IO poweroff. In Partial-IO pins of a few
>>> hardware units can generate system wakeups while DDR memory is not
>>> powered resulting in a fresh boot of the system. These hardware units in
>>> the SoC are always powered so that some logic can detect pin activity.
>>>
>>> If the system supports Partial-IO as described in the fw capabilities, a
>>> sys_off handler is added. This sys_off handler decides if the poweroff
>>> is executed by entering normal poweroff or Partial-IO instead. The
>>> decision is made by checking if wakeup is enabled on all devices that
>>> may wake up the SoC from Partial-IO.
>>>
>>> The possible wakeup devices are found by checking which devices
>>> reference a "Partial-IO" system state in the list of wakeup-source
>>> system states. Only devices that are actually enabled by the user will
>>> be considered as an active wakeup source. If none of the wakeup sources
>>> is enabled the system will do a normal poweroff. If at least one wakeup
>>> source is enabled it will instead send a TI_SCI_MSG_PREPARE_SLEEP
>>> message from the sys_off handler. Sending this message will result in an
>>> immediate shutdown of the system. No execution is expected after this
>>> point. The code will wait for 5s and do an emergency_restart afterwards
>>> if Partial-IO wasn't entered at that point.
>>>
>>> A short documentation about Partial-IO can be found in section 6.2.4.5
>>> of the TRM at
>>> https://www.ti.com/lit/pdf/spruiv7
>>>
>>> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
>>> ---
>>> drivers/firmware/ti_sci.c | 132 +++++++++++++++++++++++++++++++++++++++++++++-
>>> drivers/firmware/ti_sci.h | 5 ++
>>> 2 files changed, 136 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
>>> index 4db84a92a517b0aa7bb8d47e809d9848a16e2cc4..f2922fccfbe748a436cb9aa0a8c8e5f48db02ef9 100644
>>> --- a/drivers/firmware/ti_sci.c
>>> +++ b/drivers/firmware/ti_sci.c
>>> @@ -6,6 +6,7 @@
>>> * Nishanth Menon
>>> */
>>>
>>> +#include "linux/dev_printk.h"
>>> #define pr_fmt(fmt) "%s: " fmt, __func__
>>>
>>> #include <linux/bitmap.h>
>>> @@ -3663,6 +3664,116 @@ devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
>>> }
>>> EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource);
>>>
>>> +/*
>>> + * Enter Partial-IO, which disables everything including DDR with only a small
>>> + * logic being active for wakeup.
>>> + */
>>> +static int ti_sci_enter_partial_io(struct ti_sci_info *info)
>>> +{
>>> + struct ti_sci_msg_req_prepare_sleep *req;
>>> + struct ti_sci_xfer *xfer;
>>> + struct device *dev = info->dev;
>>> + int ret = 0;
>>> +
>>> + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_PREPARE_SLEEP,
>>> + TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
>>> + sizeof(*req), sizeof(struct ti_sci_msg_hdr));
>>> + if (IS_ERR(xfer)) {
>>> + ret = PTR_ERR(xfer);
>>> + dev_err(dev, "Message alloc failed(%d)\n", ret);
>>> + return ret;
>>> + }
>>> +
>>> + req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf;
>>> + req->mode = TISCI_MSG_VALUE_SLEEP_MODE_PARTIAL_IO;
>>
>> This whole function is almost identical to ti_sci_cmd_prepare_sleep() other
>> than you use a different mode here, which this different mode can be passed
>> into ti_sci_cmd_prepare_sleep() just the same. Only other difference would
>> be the NORESPONSE flag which you could just check "mode" passed in and
>> use the right flag for the mode.
>
> I thought this to be nicer as it avoided ifs, but as Kendall and you
> both requested this, I changed it for the next version.
>
>>
>>> + req->ctx_lo = 0;
>>> + req->ctx_hi = 0;
>>> + req->debug_flags = 0;
>>> +
>>> + ret = ti_sci_do_xfer(info, xfer);
>>> + if (ret) {
>>> + dev_err(dev, "Mbox send fail %d\n", ret);
>>> + goto fail;
>>> + }
>>> +
>>> +fail:
>>> + ti_sci_put_one_xfer(&info->minfo, xfer);
>>> +
>>> + return ret;
>>> +}
>>> +
>>> +/*
>>> + * Iterate all device nodes that have a wakeup-source property and check if one
>>> + * of the possible phandles points to a Partial-IO system state. If it
>>> + * does resolve the device node to an actual device and check if wakeup is
>>> + * enabled.
>>> + */
>>> +static bool ti_sci_partial_io_wakeup_enabled(struct ti_sci_info *info)
>>> +{
>>> + struct device_node *wakeup_node = NULL;
>>> +
>>> + for_each_node_with_property(wakeup_node, "wakeup-source") {
>>> + struct of_phandle_iterator it;
>>> + int err;
>>> +
>>> + of_for_each_phandle(&it, err, wakeup_node, "wakeup-source", NULL, 0) {
>>> + struct platform_device *pdev;
>>> + bool may_wakeup;
>>> +
>>> + /*
>>> + * Continue if idle-state-name is not off-wake. Return
>>> + * value is the index of the string which should be 0 if
>>> + * off-wake is present.
>>> + */
>>> + if (of_property_match_string(it.node, "idle-state-name", "off-wake"))
>>> + continue;
>>> +
>>> + pdev = of_find_device_by_node(wakeup_node);
>>> + if (!pdev)
>>> + continue;
>>> +
>>> + may_wakeup = device_may_wakeup(&pdev->dev);
>>> + put_device(&pdev->dev);
>>> +
>>> + if (may_wakeup) {
>>> + dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n",
>>> + wakeup_node);
>>> + of_node_put(it.node);
>>> + of_node_put(wakeup_node);
>>> + return true;
>>> + }
>>> + }
>>> + }
>>> +
>>> + return false;
>>> +}
>>> +
>>> +static int ti_sci_sys_off_handler(struct sys_off_data *data)
>>> +{
>>> + struct ti_sci_info *info = data->cb_data;
>>> + bool enter_partial_io = ti_sci_partial_io_wakeup_enabled(info);
>>> + int ret;
>>> +
>>> + if (!enter_partial_io)
>>> + return NOTIFY_DONE;
>>> +
>>> + dev_info(info->dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
>>> +
>>> + ret = ti_sci_enter_partial_io(info);
>>> +
>>
>> No need for newline here.
>>
>>> + if (ret) {
>>> + dev_err(info->dev,
>>> + "Failed to enter Partial-IO %pe, trying to do an emergency restart\n",
>>> + ERR_PTR(ret));
>>
>> Why cast this int to a pointer before printing it out?
>
> I am casting this to an error pointer to get the resolution of the error
> value to a symbolic name with %pe. This will print 'EBUSY' etc.
>
Ah I see, but why not use errname() directly? I see dev_err_probe() also goes though
a ERR_PTR() cast, so maybe there is some reason I'm not seeing, so I'm fine either way.
Thanks,
Andrew
> Thanks!
>
> Best
> Markus
© 2016 - 2026 Red Hat, Inc.