linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] firmware: ti_sci: Partial-IO support
@ 2024-12-19 20:02 Markus Schneider-Pargmann
  2024-12-19 20:02 ` [PATCH v4 1/4] firmware: ti_sci: Support transfers without response Markus Schneider-Pargmann
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Markus Schneider-Pargmann @ 2024-12-19 20:02 UTC (permalink / raw)
  To: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar
  Cc: linux-arm-kernel, linux-kernel, devicetree, Vishal Mahaveer,
	Kevin Hilman, Dhruva Gole, Markus Schneider-Pargmann

Hi,

Series
------
Partial-IO is a poweroff SoC state with a few pingroups active for
wakeup. This state can be entered by sending a TI_SCI PREPARE_SLEEP
message.

The message is sent on poweroff if one of the potential wakeup sources
for this power state are wakeup enabled. The potential wakeup sources
are found by looking for devices that list "poweroff" in the
wakeup-source property in the devicetree. The wakeup sources can be
individually enabled/disabled by the user in the running system.

The series is based on v6.13-rc1.

Partial-IO
----------
This series is part of a bigger topic to support Partial-IO on am62,
am62a and am62p. Partial-IO is a poweroff state in which some pins are
able to wakeup the SoC. In detail MCU m_can and two serial port pins can
trigger the wakeup.
A documentation can also be found in section 6.2.4 in the TRM:
  https://www.ti.com/lit/pdf/spruiv7

This other series is relevant for the support of Partial-IO:

 - can: m_can: Add am62 wakeup support
   https://lore.kernel.org/r/20241219-topic-mcan-wakeup-source-v6-12-v6-0-1356c7f7cfda@baylibre.com
   https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-wakeup-source/v6.13?ref_type=heads

Testing
-------

A test branch is available here that includes all patches required to
test Partial-IO:

https://gitlab.baylibre.com/msp8/linux/-/tree/integration/am62-partialio/v6.13?ref_type=heads

After enabling Wake-on-LAN the system can be powered off and will enter
the Partial-IO state in which it can be woken up by activity on the
specific pins:
    ethtool -s can0 wol p
    ethtool -s can1 wol p
    poweroff

I tested these patches on am62-lp-sk.

Best,
Markus

Previous versions:
 v1: https://lore.kernel.org/lkml/20240523080225.1288617-1-msp@baylibre.com/
 v2: https://lore.kernel.org/lkml/20240729080101.3859701-1-msp@baylibre.com/
 v3: https://lore.kernel.org/r/20241012-topic-am62-partialio-v6-13-b4-v3-0-f7c6c2739681@baylibre.com

Changes in v4:
 - Rebased to v6.13-rc1
 - Removed all regulator related structures from patches and implemented
   the wakeup-source property use instead.

Changes in v3:
 - Remove other modes declared for PREPARE_SLEEP as they probably won't
   ever be used in upstream.
 - Replace the wait loop after sending PREPARE_SLEEP with msleep and do
   an emergency_restart if it exits
 - Remove uarts from DT wakeup sources
 - Split no response handling in ti_sci_do_xfer() into a separate patch
   and use goto instead of if ()
 - Remove DT binding parital-io-wakeup-sources. Instead I am modeling
   the devices that are in the relevant group that are powered during
   Partial-IO with the power supplies that are externally provided to
   the SoC. In this case they are provided through 'vddshv_canuart'. All
   devices using this regulator can be considered a potential wakeup
   source if they are wakeup capable and wakeup enabled.
 - Added devicetree patches adding vcc_3v3_sys regulator and
   vddshv_canuart for am62-lp-sk
 - Add pinctrl entries for am62-lp-sk to add WKUP_EN for mcu_mcan0 and
   mcu_mcan1

Changes in v2:
 - Rebase to v6.11-rc1
 - dt-binding:
    - Update commit message
    - Add more verbose description of the new binding for a better
      explanation.
 - ti_sci driver:
    - Combine ti_sci_do_send() into ti_sci_do_xfer and only wait on a
      response if a flag is set.
    - On failure to enter Partial-IO, do emergency_restart()
    - Add comments
    - Fix small things

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---
Markus Schneider-Pargmann (4):
      firmware: ti_sci: Support transfers without response
      firmware: ti_sci: Partial-IO support
      arm64: dts: ti: k3-pinctrl: Add WKUP_EN flag
      arm64: dts: ti: am62-lp-sk: Add wakeup mcu_mcan0/1 pinctrl

 arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts |  52 +++++++++++++
 arch/arm64/boot/dts/ti/k3-pinctrl.h      |   3 +
 drivers/firmware/ti_sci.c                | 122 ++++++++++++++++++++++++++++++-
 drivers/firmware/ti_sci.h                |   5 ++
 4 files changed, 181 insertions(+), 1 deletion(-)
---
base-commit: cbc4912199deab59fdbd830b115d81941d0add46
change-id: 20241008-topic-am62-partialio-v6-12-b4-c273fbac4447
prerequisite-change-id: 20241009-topic-mcan-wakeup-source-v6-12-8c1d69931bd8:6
prerequisite-patch-id: eba4f2096c69d9c734a4a4491e062bd8b01d26fd
prerequisite-patch-id: 830b339ea452edd750b04f719da91e721be630cb
prerequisite-patch-id: 56fd0aae20e82eb2dfb48f1b7088d62311a11f05
prerequisite-patch-id: 41f55b96c0428240d74d488e3c788c09842a1753
prerequisite-patch-id: 4ab7269193dbcfd449349ccd41b23914bbbdaa6b
prerequisite-patch-id: 24a735db927cbe2b1e0c6c5f3985b6676ce5528c
prerequisite-patch-id: 52dbbf390d3f7e4a3859e60e4f660bfe39b92cd9

Best regards,
-- 
Markus Schneider-Pargmann <msp@baylibre.com>



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

* [PATCH v4 1/4] firmware: ti_sci: Support transfers without response
  2024-12-19 20:02 [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
@ 2024-12-19 20:02 ` Markus Schneider-Pargmann
  2024-12-20 11:41   ` Dhruva Gole
  2024-12-19 20:02 ` [PATCH v4 2/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Markus Schneider-Pargmann @ 2024-12-19 20:02 UTC (permalink / raw)
  To: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar
  Cc: linux-arm-kernel, linux-kernel, devicetree, Vishal Mahaveer,
	Kevin Hilman, Dhruva Gole, Markus Schneider-Pargmann

Check the header flags if an response is expected or not. If it is not
expected skip the receive part of ti_sci_do_xfer(). This prepares the
driver for one-way messages as prepare_sleep for Partial-IO.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---
 drivers/firmware/ti_sci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 806a975fff22ae00ecb88587b2c47ba172120bc2..ec0c54935ac0d667323d98b86ac9d288b73be6aa 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -398,10 +398,13 @@ static void ti_sci_put_one_xfer(struct ti_sci_xfers_info *minfo,
 static inline int ti_sci_do_xfer(struct ti_sci_info *info,
 				 struct ti_sci_xfer *xfer)
 {
+	struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
 	int ret;
 	int timeout;
 	struct device *dev = info->dev;
 	bool done_state = true;
+	bool response_expected = !!(hdr->flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED |
+						  TI_SCI_FLAG_REQ_ACK_ON_RECEIVED));
 
 	ret = mbox_send_message(info->chan_tx, &xfer->tx_message);
 	if (ret < 0)
@@ -409,6 +412,9 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
 
 	ret = 0;
 
+	if (!response_expected)
+		goto no_response;
+
 	if (system_state <= SYSTEM_RUNNING) {
 		/* And we wait for the response. */
 		timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms);
@@ -429,6 +435,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
 		dev_err(dev, "Mbox timedout in resp(caller: %pS)\n",
 			(void *)_RET_IP_);
 
+no_response:
 	/*
 	 * NOTE: we might prefer not to need the mailbox ticker to manage the
 	 * transfer queueing since the protocol layer queues things by itself.

-- 
2.45.2



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

* [PATCH v4 2/4] firmware: ti_sci: Partial-IO support
  2024-12-19 20:02 [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
  2024-12-19 20:02 ` [PATCH v4 1/4] firmware: ti_sci: Support transfers without response Markus Schneider-Pargmann
@ 2024-12-19 20:02 ` Markus Schneider-Pargmann
  2024-12-20 11:50   ` Dhruva Gole
  2024-12-19 20:02 ` [PATCH v4 3/4] arm64: dts: ti: k3-pinctrl: Add WKUP_EN flag Markus Schneider-Pargmann
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Markus Schneider-Pargmann @ 2024-12-19 20:02 UTC (permalink / raw)
  To: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar
  Cc: linux-arm-kernel, linux-kernel, devicetree, Vishal Mahaveer,
	Kevin Hilman, Dhruva Gole, Markus Schneider-Pargmann

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 have the
"poweroff" in the list of wakeup-source power 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 <msp@baylibre.com>
---
 drivers/firmware/ti_sci.c | 115 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/firmware/ti_sci.h |   5 ++
 2 files changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index ec0c54935ac0d667323d98b86ac9d288b73be6aa..693ac816f8ba3941a9156bd39524099ca476d712 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -3746,6 +3746,100 @@ static const struct dev_pm_ops ti_sci_pm_ops = {
 #endif
 };
 
+/*
+ * Enter Partial-IO, which disables everything including DDR with only a small
+ * logic being active for wakeup.
+ */
+static int tisci_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;
+
+	dev_info(dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
+
+	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;
+}
+
+static bool tisci_canuart_wakeup_enabled(struct ti_sci_info *info)
+{
+	struct device_node *wakeup_node = NULL;
+
+	for (wakeup_node = of_find_node_with_property(NULL, "wakeup-source");
+	     wakeup_node;
+	     wakeup_node = of_find_node_with_property(wakeup_node, "wakeup-source")) {
+		struct platform_device *pdev;
+		int index;
+
+		index = of_property_match_string(wakeup_node, "wakeup-source", "poweroff");
+		if (index < 0)
+			continue;
+
+		pdev = of_find_device_by_node(wakeup_node);
+		if (!pdev)
+			break;
+
+		if (device_may_wakeup(&pdev->dev)) {
+			dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n",
+				wakeup_node);
+			put_device(&pdev->dev);
+			of_node_put(wakeup_node);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+static int tisci_sys_off_handler(struct sys_off_data *data)
+{
+	struct ti_sci_info *info = data->cb_data;
+	bool enter_partial_io = tisci_canuart_wakeup_enabled(info);
+	int ret;
+
+	if (!enter_partial_io)
+		return NOTIFY_DONE;
+
+	ret = tisci_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;
+}
+
 /* Description for K2G */
 static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
 	.default_host_id = 2,
@@ -3889,6 +3983,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,
+						    tisci_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,
@@ -3898,7 +4005,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 053387d7baa064498e6a208daa7f70040ef87281..dec9e20cbe5da8f6d9393d56bb9a1e73cb083a42 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -592,6 +592,11 @@ struct ti_sci_msg_resp_get_clock_freq {
 struct ti_sci_msg_req_prepare_sleep {
 	struct ti_sci_msg_hdr	hdr;
 
+/*
+ * When sending perpare_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.45.2



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

* [PATCH v4 3/4] arm64: dts: ti: k3-pinctrl: Add WKUP_EN flag
  2024-12-19 20:02 [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
  2024-12-19 20:02 ` [PATCH v4 1/4] firmware: ti_sci: Support transfers without response Markus Schneider-Pargmann
  2024-12-19 20:02 ` [PATCH v4 2/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
@ 2024-12-19 20:02 ` Markus Schneider-Pargmann
  2024-12-19 20:02 ` [PATCH v4 4/4] arm64: dts: ti: am62-lp-sk: Add wakeup mcu_mcan0/1 pinctrl Markus Schneider-Pargmann
  2024-12-23 12:52 ` [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Rob Herring (Arm)
  4 siblings, 0 replies; 9+ messages in thread
From: Markus Schneider-Pargmann @ 2024-12-19 20:02 UTC (permalink / raw)
  To: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar
  Cc: linux-arm-kernel, linux-kernel, devicetree, Vishal Mahaveer,
	Kevin Hilman, Dhruva Gole, Markus Schneider-Pargmann

WKUP_EN is a flag to enable pin wakeup. Any activity will wakeup the SoC
in that case.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---
 arch/arm64/boot/dts/ti/k3-pinctrl.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-pinctrl.h b/arch/arm64/boot/dts/ti/k3-pinctrl.h
index 22b8d73cfd3264735ddf91874e60a0c5fc7ade5b..dd4d53e8420a1d671e04a70d4af8b0ea1b75b2b2 100644
--- a/arch/arm64/boot/dts/ti/k3-pinctrl.h
+++ b/arch/arm64/boot/dts/ti/k3-pinctrl.h
@@ -12,6 +12,7 @@
 #define PULLTYPESEL_SHIFT	(17)
 #define RXACTIVE_SHIFT		(18)
 #define DEBOUNCE_SHIFT		(11)
+#define WKUP_EN_SHIFT		(29)
 
 #define PULL_DISABLE		(1 << PULLUDEN_SHIFT)
 #define PULL_ENABLE		(0 << PULLUDEN_SHIFT)
@@ -38,6 +39,8 @@
 #define PIN_DEBOUNCE_CONF5	(5 << DEBOUNCE_SHIFT)
 #define PIN_DEBOUNCE_CONF6	(6 << DEBOUNCE_SHIFT)
 
+#define WKUP_EN			(1 << WKUP_EN_SHIFT)
+
 /* Default mux configuration for gpio-ranges to use with pinctrl */
 #define PIN_GPIO_RANGE_IOPAD	(PIN_INPUT | 7)
 

-- 
2.45.2



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

* [PATCH v4 4/4] arm64: dts: ti: am62-lp-sk: Add wakeup mcu_mcan0/1 pinctrl
  2024-12-19 20:02 [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
                   ` (2 preceding siblings ...)
  2024-12-19 20:02 ` [PATCH v4 3/4] arm64: dts: ti: k3-pinctrl: Add WKUP_EN flag Markus Schneider-Pargmann
@ 2024-12-19 20:02 ` Markus Schneider-Pargmann
  2024-12-23 12:52 ` [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Rob Herring (Arm)
  4 siblings, 0 replies; 9+ messages in thread
From: Markus Schneider-Pargmann @ 2024-12-19 20:02 UTC (permalink / raw)
  To: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar
  Cc: linux-arm-kernel, linux-kernel, devicetree, Vishal Mahaveer,
	Kevin Hilman, Dhruva Gole, Markus Schneider-Pargmann

Add pincontrol definitions for mcu_mcan0 and mcu_mcan1 for wakeup from
Partial-IO. Add these as wakeup pinctrl entries for both devices.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---
 arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts | 52 ++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts b/arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts
index 8e9fc00a6b3c7459a360f9e1d6bbb60e68c460ab..22695715239644b1bfe209ba4f1c42fae4c59f70 100644
--- a/arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts
+++ b/arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts
@@ -232,3 +232,55 @@ &tlv320aic3106 {
 &gpmc0 {
 	ranges = <0 0 0x00 0x51000000 0x01000000>; /* CS0 space. Min partition = 16MB */
 };
+
+&mcu_mcan0 {
+	pinctrl-names = "default", "wakeup";
+	pinctrl-0 = <&mcu_mcan0_tx_pins_default>, <&mcu_mcan0_rx_pins_default>;
+	pinctrl-1 = <&mcu_mcan0_tx_pins_default>, <&mcu_mcan0_rx_pins_wakeup>;
+	status = "okay";
+};
+
+&mcu_mcan1 {
+	pinctrl-names = "default", "wakeup";
+	pinctrl-0 = <&mcu_mcan1_tx_pins_default>, <&mcu_mcan1_rx_pins_default>;
+	pinctrl-1 = <&mcu_mcan1_tx_pins_default>, <&mcu_mcan1_rx_pins_wakeup>;
+	status = "okay";
+};
+
+&mcu_pmx0 {
+	mcu_mcan0_tx_pins_default: mcu-mcan0-tx-default-pins {
+		pinctrl-single,pins = <
+			AM62X_IOPAD(0x034, PIN_OUTPUT, 0) /* (D6) MCU_MCAN0_TX */
+		>;
+	};
+
+	mcu_mcan0_rx_pins_default: mcu-mcan0-rx-default-pins {
+		pinctrl-single,pins = <
+			AM62X_IOPAD(0x038, PIN_INPUT, 0) /* (B3) MCU_MCAN0_RX */
+		>;
+	};
+
+	mcu_mcan0_rx_pins_wakeup: mcu-mcan0-rx-wakeup-pins {
+		pinctrl-single,pins = <
+			AM62X_IOPAD(0x038, PIN_INPUT | WKUP_EN, 0) /* (B3) MCU_MCAN0_RX */
+		>;
+	};
+
+	mcu_mcan1_tx_pins_default: mcu-mcan1-tx-default-pins {
+		pinctrl-single,pins = <
+			AM62X_IOPAD(0x03c, PIN_OUTPUT, 0) /* (E5) MCU_MCAN1_TX */
+		>;
+	};
+
+	mcu_mcan1_rx_pins_default: mcu-mcan1-rx-default-pins {
+		pinctrl-single,pins = <
+			AM62X_IOPAD(0x040, PIN_INPUT, 0) /* (D4) MCU_MCAN1_RX */
+		>;
+	};
+
+	mcu_mcan1_rx_pins_wakeup: mcu-mcan1-rx-wakeup-pins {
+		pinctrl-single,pins = <
+			AM62X_IOPAD(0x040, PIN_INPUT | WKUP_EN, 0) /* (D4) MCU_MCAN1_RX */
+		>;
+	};
+};

-- 
2.45.2



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

* Re: [PATCH v4 1/4] firmware: ti_sci: Support transfers without response
  2024-12-19 20:02 ` [PATCH v4 1/4] firmware: ti_sci: Support transfers without response Markus Schneider-Pargmann
@ 2024-12-20 11:41   ` Dhruva Gole
  0 siblings, 0 replies; 9+ messages in thread
From: Dhruva Gole @ 2024-12-20 11:41 UTC (permalink / raw)
  To: Markus Schneider-Pargmann
  Cc: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar, linux-arm-kernel, linux-kernel,
	devicetree, Vishal Mahaveer, Kevin Hilman

On Dec 19, 2024 at 21:02:12 +0100, Markus Schneider-Pargmann wrote:
> Check the header flags if an response is expected or not. If it is not
> expected skip the receive part of ti_sci_do_xfer(). This prepares the
> driver for one-way messages as prepare_sleep for Partial-IO.
> 
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
>  drivers/firmware/ti_sci.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index 806a975fff22ae00ecb88587b2c47ba172120bc2..ec0c54935ac0d667323d98b86ac9d288b73be6aa 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -398,10 +398,13 @@ static void ti_sci_put_one_xfer(struct ti_sci_xfers_info *minfo,
>  static inline int ti_sci_do_xfer(struct ti_sci_info *info,
>  				 struct ti_sci_xfer *xfer)
>  {
> +	struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;

I think it's best to sort this in order? so it will come below struct
device?

>  	int ret;
>  	int timeout;
>  	struct device *dev = info->dev;
>  	bool done_state = true;
> +	bool response_expected = !!(hdr->flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED |
> +						  TI_SCI_FLAG_REQ_ACK_ON_RECEIVED));
>  
>  	ret = mbox_send_message(info->chan_tx, &xfer->tx_message);
>  	if (ret < 0)
> @@ -409,6 +412,9 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
>  
>  	ret = 0;
>  
> +	if (!response_expected)
> +		goto no_response;
> +

I am not a very big fan of using goto here, it feels like we should be
more clear in our implementation and make the else part below more
specific by using `else if` and checking for more specific SYSTEM_XX
states. Then based on POWEROFF, skip any polling or whatever wait for
response.
Infact, with that we may not even need the response_expected part, but I
am okay keeping both checks in place just for the clarity in design.

>  	if (system_state <= SYSTEM_RUNNING) {
>  		/* And we wait for the response. */
>  		timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms);
> @@ -429,6 +435,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
>  		dev_err(dev, "Mbox timedout in resp(caller: %pS)\n",
>  			(void *)_RET_IP_);
>  

-- 
Best regards,
Dhruva Gole
Texas Instruments Incorporated


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

* Re: [PATCH v4 2/4] firmware: ti_sci: Partial-IO support
  2024-12-19 20:02 ` [PATCH v4 2/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
@ 2024-12-20 11:50   ` Dhruva Gole
  2025-01-03 10:11     ` Markus Schneider-Pargmann
  0 siblings, 1 reply; 9+ messages in thread
From: Dhruva Gole @ 2024-12-20 11:50 UTC (permalink / raw)
  To: Markus Schneider-Pargmann
  Cc: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar, linux-arm-kernel, linux-kernel,
	devicetree, Vishal Mahaveer, Kevin Hilman

Hi Markus,

On Dec 19, 2024 at 21:02:13 +0100, Markus Schneider-Pargmann wrote:
> Add support for Partial-IO poweroff. In Partial-IO pins of a few

Maybe add a comma after the In partial-IO, a few pins in this SOC can generate....

> 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 have the
> "poweroff" in the list of wakeup-source power 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 <msp@baylibre.com>
> ---
>  drivers/firmware/ti_sci.c | 115 +++++++++++++++++++++++++++++++++++++++++++++-
>  drivers/firmware/ti_sci.h |   5 ++
>  2 files changed, 119 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index ec0c54935ac0d667323d98b86ac9d288b73be6aa..693ac816f8ba3941a9156bd39524099ca476d712 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -3746,6 +3746,100 @@ static const struct dev_pm_ops ti_sci_pm_ops = {
>  #endif
>  };
>  
> +/*
> + * Enter Partial-IO, which disables everything including DDR with only a small
> + * logic being active for wakeup.
> + */
> +static int tisci_enter_partial_io(struct ti_sci_info *info)

Isn't the function naming style in the driver ti_sci_XXX ? You're
missing one `_` I guess

> +{
> +	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;
> +
> +	dev_info(dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
> +
> +	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;
> +}
> +
> +static bool tisci_canuart_wakeup_enabled(struct ti_sci_info *info)

Add some documentation around this please.

> +{
> +	struct device_node *wakeup_node = NULL;
> +
> +	for (wakeup_node = of_find_node_with_property(NULL, "wakeup-source");
> +	     wakeup_node;
> +	     wakeup_node = of_find_node_with_property(wakeup_node, "wakeup-source")) {
> +		struct platform_device *pdev;
> +		int index;
> +
> +		index = of_property_match_string(wakeup_node, "wakeup-source", "poweroff");
> +		if (index < 0)
> +			continue;

Doesn't the fact that we're inside the for loop already ensure this is > 0?

> +
> +		pdev = of_find_device_by_node(wakeup_node);
> +		if (!pdev)
> +			break;

Same here? Would we otherwise be in the loop?
Just having a quick look here, I could be wrong, please just check once.



-- 
Best regards,
Dhruva Gole
Texas Instruments Incorporated


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

* Re: [PATCH v4 0/4] firmware: ti_sci: Partial-IO support
  2024-12-19 20:02 [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
                   ` (3 preceding siblings ...)
  2024-12-19 20:02 ` [PATCH v4 4/4] arm64: dts: ti: am62-lp-sk: Add wakeup mcu_mcan0/1 pinctrl Markus Schneider-Pargmann
@ 2024-12-23 12:52 ` Rob Herring (Arm)
  4 siblings, 0 replies; 9+ messages in thread
From: Rob Herring (Arm) @ 2024-12-23 12:52 UTC (permalink / raw)
  To: Markus Schneider-Pargmann
  Cc: Kevin Hilman, Nishanth Menon, Santosh Shilimkar, Tero Kristo,
	linux-arm-kernel, Dhruva Gole, linux-kernel, Krzysztof Kozlowski,
	Vishal Mahaveer, Conor Dooley, devicetree, Vignesh Raghavendra,
	Anand Gadiyar


On Thu, 19 Dec 2024 21:02:11 +0100, Markus Schneider-Pargmann wrote:
> Hi,
> 
> Series
> ------
> Partial-IO is a poweroff SoC state with a few pingroups active for
> wakeup. This state can be entered by sending a TI_SCI PREPARE_SLEEP
> message.
> 
> The message is sent on poweroff if one of the potential wakeup sources
> for this power state are wakeup enabled. The potential wakeup sources
> are found by looking for devices that list "poweroff" in the
> wakeup-source property in the devicetree. The wakeup sources can be
> individually enabled/disabled by the user in the running system.
> 
> The series is based on v6.13-rc1.
> 
> Partial-IO
> ----------
> This series is part of a bigger topic to support Partial-IO on am62,
> am62a and am62p. Partial-IO is a poweroff state in which some pins are
> able to wakeup the SoC. In detail MCU m_can and two serial port pins can
> trigger the wakeup.
> A documentation can also be found in section 6.2.4 in the TRM:
>   https://www.ti.com/lit/pdf/spruiv7
> 
> This other series is relevant for the support of Partial-IO:
> 
>  - can: m_can: Add am62 wakeup support
>    https://lore.kernel.org/r/20241219-topic-mcan-wakeup-source-v6-12-v6-0-1356c7f7cfda@baylibre.com
>    https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-wakeup-source/v6.13?ref_type=heads
> 
> Testing
> -------
> 
> A test branch is available here that includes all patches required to
> test Partial-IO:
> 
> https://gitlab.baylibre.com/msp8/linux/-/tree/integration/am62-partialio/v6.13?ref_type=heads
> 
> After enabling Wake-on-LAN the system can be powered off and will enter
> the Partial-IO state in which it can be woken up by activity on the
> specific pins:
>     ethtool -s can0 wol p
>     ethtool -s can1 wol p
>     poweroff
> 
> I tested these patches on am62-lp-sk.
> 
> Best,
> Markus
> 
> Previous versions:
>  v1: https://lore.kernel.org/lkml/20240523080225.1288617-1-msp@baylibre.com/
>  v2: https://lore.kernel.org/lkml/20240729080101.3859701-1-msp@baylibre.com/
>  v3: https://lore.kernel.org/r/20241012-topic-am62-partialio-v6-13-b4-v3-0-f7c6c2739681@baylibre.com
> 
> Changes in v4:
>  - Rebased to v6.13-rc1
>  - Removed all regulator related structures from patches and implemented
>    the wakeup-source property use instead.
> 
> Changes in v3:
>  - Remove other modes declared for PREPARE_SLEEP as they probably won't
>    ever be used in upstream.
>  - Replace the wait loop after sending PREPARE_SLEEP with msleep and do
>    an emergency_restart if it exits
>  - Remove uarts from DT wakeup sources
>  - Split no response handling in ti_sci_do_xfer() into a separate patch
>    and use goto instead of if ()
>  - Remove DT binding parital-io-wakeup-sources. Instead I am modeling
>    the devices that are in the relevant group that are powered during
>    Partial-IO with the power supplies that are externally provided to
>    the SoC. In this case they are provided through 'vddshv_canuart'. All
>    devices using this regulator can be considered a potential wakeup
>    source if they are wakeup capable and wakeup enabled.
>  - Added devicetree patches adding vcc_3v3_sys regulator and
>    vddshv_canuart for am62-lp-sk
>  - Add pinctrl entries for am62-lp-sk to add WKUP_EN for mcu_mcan0 and
>    mcu_mcan1
> 
> Changes in v2:
>  - Rebase to v6.11-rc1
>  - dt-binding:
>     - Update commit message
>     - Add more verbose description of the new binding for a better
>       explanation.
>  - ti_sci driver:
>     - Combine ti_sci_do_send() into ti_sci_do_xfer and only wait on a
>       response if a flag is set.
>     - On failure to enter Partial-IO, do emergency_restart()
>     - Add comments
>     - Fix small things
> 
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
> Markus Schneider-Pargmann (4):
>       firmware: ti_sci: Support transfers without response
>       firmware: ti_sci: Partial-IO support
>       arm64: dts: ti: k3-pinctrl: Add WKUP_EN flag
>       arm64: dts: ti: am62-lp-sk: Add wakeup mcu_mcan0/1 pinctrl
> 
>  arch/arm64/boot/dts/ti/k3-am62-lp-sk.dts |  52 +++++++++++++
>  arch/arm64/boot/dts/ti/k3-pinctrl.h      |   3 +
>  drivers/firmware/ti_sci.c                | 122 ++++++++++++++++++++++++++++++-
>  drivers/firmware/ti_sci.h                |   5 ++
>  4 files changed, 181 insertions(+), 1 deletion(-)
> ---
> base-commit: cbc4912199deab59fdbd830b115d81941d0add46
> change-id: 20241008-topic-am62-partialio-v6-12-b4-c273fbac4447
> prerequisite-change-id: 20241009-topic-mcan-wakeup-source-v6-12-8c1d69931bd8:6
> prerequisite-patch-id: eba4f2096c69d9c734a4a4491e062bd8b01d26fd
> prerequisite-patch-id: 830b339ea452edd750b04f719da91e721be630cb
> prerequisite-patch-id: 56fd0aae20e82eb2dfb48f1b7088d62311a11f05
> prerequisite-patch-id: 41f55b96c0428240d74d488e3c788c09842a1753
> prerequisite-patch-id: 4ab7269193dbcfd449349ccd41b23914bbbdaa6b
> prerequisite-patch-id: 24a735db927cbe2b1e0c6c5f3985b6676ce5528c
> prerequisite-patch-id: 52dbbf390d3f7e4a3859e60e4f660bfe39b92cd9
> 
> Best regards,
> --
> Markus Schneider-Pargmann <msp@baylibre.com>
> 
> 
> 


My bot found new DTB warnings on the .dts files added or changed in this
series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings
are fixed by another series. Ultimately, it is up to the platform
maintainer whether these warnings are acceptable or not. No need to reply
unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then
make sure dt-schema is up to date:

  pip3 install dtschema --upgrade


New warnings running 'make CHECK_DTBS=y ti/k3-am62-lp-sk.dtb' for 20241219-topic-am62-partialio-v6-12-b4-v4-0-1cb8eabd407e@baylibre.com:

arch/arm64/boot/dts/ti/k3-am62-lp-sk.dtb: can@4e08000: wakeup-source: 'oneOf' conditional failed, one must be fixed:
	['suspend', 'poweroff'] is not of type 'boolean'
	['suspend', 'poweroff'] is too long
	from schema $id: http://devicetree.org/schemas/net/can/bosch,m_can.yaml#
arch/arm64/boot/dts/ti/k3-am62-lp-sk.dtb: can@4e08000: Unevaluated properties are not allowed ('wakeup-source' was unexpected)
	from schema $id: http://devicetree.org/schemas/net/can/bosch,m_can.yaml#
arch/arm64/boot/dts/ti/k3-am62-lp-sk.dtb: can@4e08000: wakeup-source: ['suspend', 'poweroff'] is not of type 'boolean'
	from schema $id: http://devicetree.org/schemas/wakeup-source.yaml#
arch/arm64/boot/dts/ti/k3-am62-lp-sk.dtb: can@4e18000: wakeup-source: 'oneOf' conditional failed, one must be fixed:
	['suspend', 'poweroff'] is not of type 'boolean'
	['suspend', 'poweroff'] is too long
	from schema $id: http://devicetree.org/schemas/net/can/bosch,m_can.yaml#
arch/arm64/boot/dts/ti/k3-am62-lp-sk.dtb: can@4e18000: Unevaluated properties are not allowed ('wakeup-source' was unexpected)
	from schema $id: http://devicetree.org/schemas/net/can/bosch,m_can.yaml#
arch/arm64/boot/dts/ti/k3-am62-lp-sk.dtb: can@4e18000: wakeup-source: ['suspend', 'poweroff'] is not of type 'boolean'
	from schema $id: http://devicetree.org/schemas/wakeup-source.yaml#







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

* Re: [PATCH v4 2/4] firmware: ti_sci: Partial-IO support
  2024-12-20 11:50   ` Dhruva Gole
@ 2025-01-03 10:11     ` Markus Schneider-Pargmann
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Schneider-Pargmann @ 2025-01-03 10:11 UTC (permalink / raw)
  To: Dhruva Gole
  Cc: Nishanth Menon, Tero Kristo, Santosh Shilimkar,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Anand Gadiyar, linux-arm-kernel, linux-kernel,
	devicetree, Vishal Mahaveer, Kevin Hilman

[-- Attachment #1: Type: text/plain, Size: 4964 bytes --]

Hi Dhruva,

On Fri, Dec 20, 2024 at 05:20:43PM +0530, Dhruva Gole wrote:
> Hi Markus,
> 
> On Dec 19, 2024 at 21:02:13 +0100, Markus Schneider-Pargmann wrote:
> > Add support for Partial-IO poweroff. In Partial-IO pins of a few
> 
> Maybe add a comma after the In partial-IO, a few pins in this SOC can generate....
> 
> > 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 have the
> > "poweroff" in the list of wakeup-source power 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 <msp@baylibre.com>
> > ---
> >  drivers/firmware/ti_sci.c | 115 +++++++++++++++++++++++++++++++++++++++++++++-
> >  drivers/firmware/ti_sci.h |   5 ++
> >  2 files changed, 119 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> > index ec0c54935ac0d667323d98b86ac9d288b73be6aa..693ac816f8ba3941a9156bd39524099ca476d712 100644
> > --- a/drivers/firmware/ti_sci.c
> > +++ b/drivers/firmware/ti_sci.c
> > @@ -3746,6 +3746,100 @@ static const struct dev_pm_ops ti_sci_pm_ops = {
> >  #endif
> >  };
> >  
> > +/*
> > + * Enter Partial-IO, which disables everything including DDR with only a small
> > + * logic being active for wakeup.
> > + */
> > +static int tisci_enter_partial_io(struct ti_sci_info *info)
> 
> Isn't the function naming style in the driver ti_sci_XXX ? You're
> missing one `_` I guess
> 
> > +{
> > +	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;
> > +
> > +	dev_info(dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n");
> > +
> > +	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;
> > +}
> > +
> > +static bool tisci_canuart_wakeup_enabled(struct ti_sci_info *info)
> 
> Add some documentation around this please.
> 
> > +{
> > +	struct device_node *wakeup_node = NULL;
> > +
> > +	for (wakeup_node = of_find_node_with_property(NULL, "wakeup-source");
> > +	     wakeup_node;
> > +	     wakeup_node = of_find_node_with_property(wakeup_node, "wakeup-source")) {
> > +		struct platform_device *pdev;
> > +		int index;
> > +
> > +		index = of_property_match_string(wakeup_node, "wakeup-source", "poweroff");
> > +		if (index < 0)
> > +			continue;
> 
> Doesn't the fact that we're inside the for loop already ensure this is > 0?

No, this can return several error codes if the property doesn't have a
value or the string is not found in the property array.

> 
> > +
> > +		pdev = of_find_device_by_node(wakeup_node);
> > +		if (!pdev)
> > +			break;
> 
> Same here? Would we otherwise be in the loop?
> Just having a quick look here, I could be wrong, please just check once.

The devicetree node doesn't necessarily have a device associated with
it. So I need to check if there is a device for this devicetree node.

I fixed the rest of your comments. Thanks for your review.

Best
Markus


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2025-01-03 10:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-19 20:02 [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
2024-12-19 20:02 ` [PATCH v4 1/4] firmware: ti_sci: Support transfers without response Markus Schneider-Pargmann
2024-12-20 11:41   ` Dhruva Gole
2024-12-19 20:02 ` [PATCH v4 2/4] firmware: ti_sci: Partial-IO support Markus Schneider-Pargmann
2024-12-20 11:50   ` Dhruva Gole
2025-01-03 10:11     ` Markus Schneider-Pargmann
2024-12-19 20:02 ` [PATCH v4 3/4] arm64: dts: ti: k3-pinctrl: Add WKUP_EN flag Markus Schneider-Pargmann
2024-12-19 20:02 ` [PATCH v4 4/4] arm64: dts: ti: am62-lp-sk: Add wakeup mcu_mcan0/1 pinctrl Markus Schneider-Pargmann
2024-12-23 12:52 ` [PATCH v4 0/4] firmware: ti_sci: Partial-IO support Rob Herring (Arm)

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).