mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Beleswar Padhi <b-padhi@ti.com>
To: <nm@ti.com>, <kristo@kernel.org>, <ssantosh@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <afd@ti.com>, <u-kumar1@ti.com>,
	<vigneshr@ti.com>, <b-padhi@ti.com>
Subject: [PATCH 3/6] firmware: ti: ti_sci_core: Add ABI5.0 Enhancements and TDA54 PDM SCI support
Date: Thu, 1 Oct 2026 01:11:28 +0530	[thread overview]
Message-ID: <20260930194131.117129-4-b-padhi@ti.com> (raw)
In-Reply-To: <20260930194131.117129-1-b-padhi@ti.com>

The previous TI K2G and K3 architectures were tightly coupled systems in
terms of Safety and Security. All the TI-SCI messages from HLOS (Linux)
were sent to a single sec proxy thread terminating at the core running
Safety service (DM). In K2G systems, DM handled both Safety & Security
requests by itself. Whereas in K3 systems, DM serviced the Safety
requests itself, and forwarded the Security requests to core running
Security service (TIFS) on the HLOS's behalf. This posed various
limitations:
   a. Increased latency: An extra forwarding hop through DM adds latency
      in requests and responses.
   b. Freedom From Interference (FFI) concerns: Having Safety service
      proxy Security's requests (& vice versa) undermines the isolation
      and FFI of the system.
   c. Potential Deadlock Scenario: Forwarding messages between Safety
      and Security cores can result in a deadlock if there are circular
      dependencies.

To eliminate all the above limitations, the TI TDA54 class of SoCs
introduce an architectural change: Isolation of Security and Safety
services. To realize this enhanced isolation in hardware, two
independent sec proxy threads are now provided for HLOS to communicate
separately with the Security and Safety cores respectively. And the
TI-SCI message forwarding has been eliminated in Software.

The System Firmware ABI5.0 version necessitates this improved isolation
and FFI change by splitting the TI-SCI message IDs into two distinct
address spaces differing in the MSB. As a result, the system reset
message has been re-assigned an ID from the Safety address space:
TI_SCI_MSG_SYS_RESET_ABI5_PDM.

Add support in the driver to probe PDM system controller and add new
ABI5 compliant APIs for Generic system control (Version, System reset).
Existing system controller's support remain unaffected with this change.

Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
---
Note:
This patch is dependent on the following 2 series
1. https://lore.kernel.org/all/20260930172948.2901336-1-b-padhi@ti.com/
2. https://lore.kernel.org/all/20260930160607.2674980-1-b-padhi@ti.com/

 drivers/firmware/ti/ti_sci.h      |  36 ++++++
 drivers/firmware/ti/ti_sci_core.c | 184 ++++++++++++++++++++++++------
 2 files changed, 185 insertions(+), 35 deletions(-)

diff --git a/drivers/firmware/ti/ti_sci.h b/drivers/firmware/ti/ti_sci.h
index 8f9f0b1aa767d..708cc95dfc48c 100644
--- a/drivers/firmware/ti/ti_sci.h
+++ b/drivers/firmware/ti/ti_sci.h
@@ -12,6 +12,7 @@
 #ifndef __TI_SCI_H
 #define __TI_SCI_H
 
+#include <linux/bits.h>
 #include <linux/compiler_types.h>
 #include <linux/completion.h>
 #include <linux/container_of.h>
@@ -63,12 +64,14 @@ struct ti_sci_xfers_info {
  * @max_msgs: Maximum number of messages that can be pending
  *		  simultaneously in the system
  * @max_msg_size: Maximum size of data per message that can be handled.
+ * @sci_services: bitmap representing services supported by SCI
  */
 struct ti_sci_desc {
 	u8 default_host_id;
 	int max_rx_timeout_ms;
 	int max_msgs;
 	int max_msg_size;
+	u8 sci_services;
 };
 
 /**
@@ -115,6 +118,9 @@ struct ti_sci_info {
 #define cl_to_ti_sci_info(c)	container_of(c, struct ti_sci_info, cl)
 #define handle_to_ti_sci_info(h) container_of(h, struct ti_sci_info, handle)
 
+#define TI_SCI_SUPPORTS_PDM_OPS	BIT(0)
+#define TI_SCI_SUPPORTS_SEC_OPS	BIT(1)
+
 /* Generic Messages */
 #define TI_SCI_MSG_ENABLE_WDT	0x0000
 #define TI_SCI_MSG_WAKE_RESET	0x0001
@@ -122,7 +128,11 @@ struct ti_sci_info {
 #define TI_SCI_MSG_WAKE_REASON	0x0003
 #define TI_SCI_MSG_GOODBYE	0x0004
 #define TI_SCI_MSG_SYS_RESET	0x0005
+/* ABI5.0 PDM Generic Message */
+#define TI_SCI_MSG_VERSION_ABI5_PDM	0x000F
 #define TI_SCI_MSG_QUERY_FW_CAPS	0x0022
+/* ABI5.0 PDM System Reset Message */
+#define TI_SCI_MSG_SYS_RESET_ABI5_PDM	0x0400
 
 /* Device requests */
 #define TI_SCI_MSG_SET_DEVICE_STATE	0x0200
@@ -233,6 +243,32 @@ struct ti_sci_msg_resp_version {
 	u8 abi_minor;
 } __packed;
 
+/**
+ * struct ti_sci_msg_resp_version_abi5_pdm - Response for a PDM get_version msg
+ * @hdr:		Generic header
+ * @version:		Version number of the PDM firmware
+ * @sub_version:	Sub-version number of the PDM firmware
+ * @patch_version:	Patch version number of the PDM firmware
+ * @abi_major:		Major version of the ABI that PDM firmware supports
+ * @abi_minor:		Minor version of the ABI that PDM firmware supports
+ * @sci_server_version:	String describing the PDM SCI server version
+ *
+ * In general, ABI version changes follow the rule that minor version increments
+ * are backward compatible. Major revision changes in ABI may not be
+ * backward compatible.
+ *
+ * Response to a message with message type TI_SCI_MSG_VERSION_ABI5_PDM
+ */
+struct ti_sci_msg_resp_version_abi5_pdm {
+	struct	ti_sci_msg_hdr hdr;
+	u16	version;
+	u8	sub_version;
+	u8	patch_version;
+	u8	abi_major;
+	u8	abi_minor;
+	char	sci_server_version[26];
+} __packed;
+
 /**
  * struct ti_sci_msg_req_reboot - Reboot the SoC
  * @hdr:	Generic Header
diff --git a/drivers/firmware/ti/ti_sci_core.c b/drivers/firmware/ti/ti_sci_core.c
index 1f7484b118375..00c43d699e64c 100644
--- a/drivers/firmware/ti/ti_sci_core.c
+++ b/drivers/firmware/ti/ti_sci_core.c
@@ -80,6 +80,8 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
 	/* Debug region is optional */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 					   "debug_messages");
+	if (!res)
+		return 0;
 	info->debug_region = devm_ioremap_resource(dev, res);
 	if (IS_ERR(info->debug_region))
 		return 0;
@@ -459,6 +461,36 @@ static int ti_sci_cmd_get_revision(struct ti_sci_info *info)
 	return 0;
 }
 
+/*
+ * ti_sci_cmd_get_revision_abi5_pdm() - command to get version of PDM SCI
+ * @info:	Pointer to SCI entity information
+ *
+ * Return: 0 if all went fine, else return appropriate error.
+ */
+static int ti_sci_cmd_get_revision_abi5_pdm(struct ti_sci_info *info)
+{
+	struct ti_sci_handle *handle = &info->handle;
+	struct ti_sci_version_info *ver = &handle->version;
+	struct ti_sci_msg_hdr req;
+	struct ti_sci_msg_resp_version_abi5_pdm resp;
+	int ret;
+
+	ret = ti_sci_do_xfer(handle, TI_SCI_MSG_VERSION_ABI5_PDM,
+			     TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+			     &req, sizeof(req),
+			     &resp, sizeof(resp));
+	if (ret)
+		return ret;
+
+	ver->abi_major = resp.abi_major;
+	ver->abi_minor = resp.abi_minor;
+	ver->firmware_revision = resp.version;
+	strscpy(ver->firmware_description, resp.sci_server_version,
+		sizeof(resp.sci_server_version));
+
+	return 0;
+}
+
 /**
  * ti_sci_cmd_prepare_sleep() - Prepare system for system suspend
  * @handle:		pointer to TI SCI handle
@@ -620,6 +652,28 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
 	return 0;
 }
 
+/**
+ * ti_sci_cmd_core_reboot_abi5() - Command to request system reset (ABI5)
+ * @handle:	Pointer to TI SCI handle
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_core_reboot_abi5(const struct ti_sci_handle *handle)
+{
+	struct ti_sci_msg_req_reboot req;
+	struct ti_sci_msg_hdr resp;
+	int ret = 0;
+
+	ret = ti_sci_do_xfer(handle, TI_SCI_MSG_SYS_RESET_ABI5_PDM,
+			     TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+			     &req, sizeof(req),
+			     &resp, sizeof(resp));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 /*
  * ti_sci_setup_ops() - Setup the operations structures
  * @info:	pointer to TISCI pointer
@@ -937,6 +991,24 @@ static int tisci_reboot_handler(struct sys_off_data *data)
 	return NOTIFY_BAD;
 }
 
+/**
+ * tisci_reboot_handler_abi5() - Restart handler for ABI5 system controllers
+ * @data:	sys-off data, with @data->cb_data pointing to the TISCI info
+ *
+ * Return: NOTIFY_BAD, as control is not expected to return here once the
+ * system reset request has been accepted.
+ */
+static int tisci_reboot_handler_abi5(struct sys_off_data *data)
+{
+	struct ti_sci_info *info = data->cb_data;
+	const struct ti_sci_handle *handle = &info->handle;
+
+	ti_sci_cmd_core_reboot_abi5(handle);
+
+	/* call fail OR pass, we should not be here in the first place */
+	return NOTIFY_BAD;
+}
+
 static int ti_sci_prepare_system_suspend(struct ti_sci_info *info)
 {
 	/*
@@ -1122,6 +1194,7 @@ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
 	/* Limited by MBOX_TX_QUEUE_LEN. K2G can handle up to 128 messages! */
 	.max_msgs = 20,
 	.max_msg_size = 64,
+	.sci_services = TI_SCI_SUPPORTS_PDM_OPS | TI_SCI_SUPPORTS_SEC_OPS,
 };
 
 /* Description for AM654 */
@@ -1132,11 +1205,24 @@ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = {
 	/* Limited by MBOX_TX_QUEUE_LEN. K2G can handle up to 128 messages! */
 	.max_msgs = 20,
 	.max_msg_size = 60,
+	.sci_services = TI_SCI_SUPPORTS_PDM_OPS | TI_SCI_SUPPORTS_SEC_OPS,
+};
+
+/* Description for TDA54 PDM System controller */
+static const struct ti_sci_desc ti_sci_pdm_tda54_desc = {
+	.default_host_id = 66,
+	/* Conservative duration */
+	.max_rx_timeout_ms = 10000,
+	/* Limited by MBOX_TX_QUEUE_LEN. TDA54 can handle up to 444 messages! */
+	.max_msgs = 20,
+	.max_msg_size = 60,
+	.sci_services = TI_SCI_SUPPORTS_PDM_OPS,
 };
 
 static const struct of_device_id ti_sci_of_match[] = {
 	{.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc},
 	{.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc},
+	{.compatible = "ti,tda54-sci-pdm", .data = &ti_sci_pdm_tda54_desc},
 	{ /* Sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, ti_sci_of_match);
@@ -1151,6 +1237,7 @@ static int ti_sci_probe(struct platform_device *pdev)
 	int ret = -EINVAL;
 	int i;
 	u32 h_id;
+	u64 fw_caps;
 
 	desc = device_get_match_data(dev);
 
@@ -1228,43 +1315,73 @@ static int ti_sci_probe(struct platform_device *pdev)
 		ret = PTR_ERR(info->chan_tx);
 		goto out;
 	}
-	ret = ti_sci_cmd_get_revision(info);
-	if (ret) {
-		dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret);
-		goto out;
-	}
 
-	ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps);
-	dev_dbg(dev, "Detected firmware capabilities: %s%s%s%s%s%s%s%s\n",
-		info->fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "",
-		info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "",
-		info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : "",
-		info->fw_caps & MSG_FLAG_CAPS_LPM_ABORT ? " LPM-Abort" : "",
-		info->fw_caps & MSG_FLAG_CAPS_IO_ISOLATION ? " IO-Isolation" : "",
-		info->fw_caps & MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED ? " BoardConfig-Managed" : "",
-		info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST ? " IRQ-Context-Lost" : "",
-		info->fw_caps & MSG_FLAG_CAPS_LPM_CLK_CONTEXT_LOST ? " Clk-Context-Lost" : ""
-	);
-
-	ti_sci_setup_ops(info);
-
-	ret = devm_register_restart_handler(dev, tisci_reboot_handler, info);
-	if (ret) {
-		dev_err(dev, "reboot registration fail(%d)\n", ret);
-		goto out;
-	}
+	/* Handle System Controller specific probe routine */
+	switch (info->desc->sci_services) {
+	case TI_SCI_SUPPORTS_PDM_OPS | TI_SCI_SUPPORTS_SEC_OPS:
+		ret = ti_sci_cmd_get_revision(info);
+		if (ret) {
+			dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret);
+			goto out;
+		}
+
+		ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps);
+		fw_caps = info->fw_caps;
+		dev_dbg(dev, "Detected firmware capabilities: %s%s%s%s%s%s%s%s\n",
+			fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "",
+			fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "",
+			fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : "",
+			fw_caps & MSG_FLAG_CAPS_LPM_ABORT ? " LPM-Abort" : "",
+			fw_caps & MSG_FLAG_CAPS_IO_ISOLATION ? " IO-Isolation" : "",
+			fw_caps & MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED ? " BoardConfig-Managed" : "",
+			fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST ? " IRQ-Context-Lost" : "",
+			fw_caps & MSG_FLAG_CAPS_LPM_CLK_CONTEXT_LOST ? " Clk-Context-Lost" : ""
+			);
+
+		ti_sci_setup_ops(info);
+
+		ret = devm_register_restart_handler(dev, tisci_reboot_handler, info);
+		if (ret) {
+			dev_err(dev, "reboot registration fail(%d)\n", ret);
+			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;
+			}
+		}
 
-	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 (info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST)
+			hash_init(info->irqs);
+		break;
+
+	case TI_SCI_SUPPORTS_PDM_OPS:
+		ret = ti_sci_cmd_get_revision_abi5_pdm(info);
+		if (ret) {
+			dev_err(dev, "Unable to communicate with PDM(%d)\n", ret);
+			goto out;
+		}
+
+		ret = devm_register_restart_handler(dev, tisci_reboot_handler_abi5, info);
 		if (ret) {
-			dev_err(dev, "Failed to register sys_off_handler %pe\n",
-				ERR_PTR(ret));
+			dev_err(dev, "reboot registration fail(%d)\n", ret);
 			goto out;
 		}
+		break;
+
+	default:
+		dev_err(dev, "Unsupported System Controller\n");
+		ret = -EINVAL;
+		goto out;
 	}
 
 	dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n",
@@ -1280,9 +1397,6 @@ static int ti_sci_probe(struct platform_device *pdev)
 	if (ret)
 		goto out;
 
-	if (info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST)
-		hash_init(info->irqs);
-
 	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
 	if (ret) {
 		dev_err(dev, "platform_populate failed %pe\n", ERR_PTR(ret));
-- 
2.34.1


  parent reply	other threads:[~2026-09-30 19:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 19:41 [PATCH 0/6] Enhance TI-SCI FFI with ABI5.0 support Beleswar Padhi
2026-09-30 19:41 ` [PATCH 1/6] dt-bindings: arm: keystone: ti,sci: Update nodename pattern Beleswar Padhi
2026-09-30 19:41 ` [PATCH 2/6] dt-bindings: arm: keystone: ti,sci: Add ti,tda54-sci-pdm compatible Beleswar Padhi
2026-09-30 19:41 ` Beleswar Padhi [this message]
2026-09-30 19:41 ` [PATCH 4/6] firmware: ti: ti_sci_device: Add ABI5.0 compliant Device and Reset APIs Beleswar Padhi
2026-09-30 19:41 ` [PATCH 5/6] firmware: ti: ti_sci_clock: Add ABI5.0 compliant Clock APIs Beleswar Padhi
2026-09-30 19:41 ` [PATCH 6/6] firmware: ti: ti_sci_rm: Add ABI5.0 compliant basic RM APIs Beleswar Padhi

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=20260930194131.117129-4-b-padhi@ti.com \
    --to=b-padhi@ti.com \
    --cc=afd@ti.com \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=ssantosh@kernel.org \
    --cc=u-kumar1@ti.com \
    --cc=vigneshr@ti.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

all inboxes | Powered by JetHome®