On 11/20/2025 9:33 PM, Markus Schneider-Pargmann (TI.com) wrote:
This patch adds code to be able to call TI_SCI_MSG_MIN_CONTEXT_RESTORE.
The context needs to be restored after booting SPL when resuming from
IO+DDR.

Tested-by: Anshul Dalal <[email protected]>
Reviewed-by: Dhruva Gole <[email protected]>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <[email protected]>
---
  drivers/firmware/ti_sci.c              | 38 ++++++++++++++++++++++++++++++++++
  drivers/firmware/ti_sci.h              | 16 ++++++++++++++
  include/linux/soc/ti/ti_sci_protocol.h |  9 ++++++++
  3 files changed, 63 insertions(+)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 
6f57dcfe8de8f874318cd53372c798d182faae73..f1cb871e8f45013097f6f8188222770ffe3653dc
 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2710,6 +2710,41 @@ static int ti_sci_cmd_change_fwl_owner(const struct 
ti_sci_handle *handle,
        return ret;
  }
+static int ti_sci_cmd_restore_context(const struct ti_sci_handle *handle, u64 ctx_addr)
+{
+       struct ti_sci_msg_min_restore_context_req req;
+       struct ti_sci_msg_hdr *resp;
+       struct ti_sci_info *info;
+       struct ti_sci_xfer *xfer;
+       int ret = 0;
+
+       if (IS_ERR(handle))
+               return PTR_ERR(handle);
+       if (!handle)
+               return -EINVAL;
+
+       info = handle_to_ti_sci_info(handle);
+
+       xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_MIN_CONTEXT_RESTORE,

function name should be ti_sci_cmd_restore_min_context or change TI_SCI_MSG_MIN_CONTEXT_RESTORE


+                                    TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+                                    (u32 *)&req, sizeof(req), sizeof(*resp));
+       if (IS_ERR(xfer)) {
+               ret = PTR_ERR(xfer);
+               return ret;
+       }
+
+       req.ctx_lo = (u32)(ctx_addr & 0xffffffff);
+       req.ctx_hi = (u32)(ctx_addr >> 32);
+
+       ret = ti_sci_do_xfer(info, xfer);
+       if (ret) {
+               dev_err(info->dev, "Failed restoring context %d\n", ret);
+               return ret;
+       }
+
+       return ret;
+}
+
  /*
   * ti_sci_setup_ops() - Setup the operations structures
   * @info:     pointer to TISCI pointer
@@ -2728,6 +2763,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
        struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops;
        struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops;
        struct ti_sci_fwl_ops *fwl_ops = &ops->fwl_ops;
+       struct ti_sci_lpm_ops *lpm_ops = &ops->lpm_ops;
bops->board_config = ti_sci_cmd_set_board_config;
        bops->board_config_rm = ti_sci_cmd_set_board_config_rm;
@@ -2795,6 +2831,8 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
fw_ops->get_dm_version = ti_sci_cmd_get_dm_version;
        fw_ops->query_dm_cap = ti_sci_cmd_query_dm_cap;
+
+       lpm_ops->restore_context = ti_sci_cmd_restore_context;
  }
/**
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index 
ce50bf6800eb1fee70a872d8ae648b1a9582b681..3f8c27c7d8c5b35cc55c18ed33225e7b5262b3da
 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -45,6 +45,9 @@
  #define TI_SCI_MSG_QUERY_CLOCK_FREQ   0x010d
  #define TI_SCI_MSG_GET_CLOCK_FREQ     0x010e
+/* Low Power Mode Requests */
+#define TI_SCI_MSG_MIN_CONTEXT_RESTORE 0x0308
+
  /* Processor Control Messages */
  #define TISCI_MSG_PROC_REQUEST                0xc000
  #define TISCI_MSG_PROC_RELEASE                0xc001
@@ -1572,4 +1575,17 @@ struct ti_sci_msg_fwl_change_owner_info_resp {
        u16                     owner_permission_bits;
  } __packed;
+/**
+ * struct ti_sci_msg_min_restore_context_req - Request to restore context from 
DDR
+ *
+ * @hdr:               Generic Header
+ * @ctx_lo             Low 32-bits of physical pointer to address to use for 
context save.
+ * @ctx_hi             High 32-bits of physical pointer to address to use for 
context save.
+ */
+struct ti_sci_msg_min_restore_context_req {
+       struct ti_sci_msg_hdr   hdr;
+       u32                     ctx_lo;
+       u32                     ctx_hi;
+} __packed;
+
  #endif /* __TI_SCI_H */
diff --git a/include/linux/soc/ti/ti_sci_protocol.h 
b/include/linux/soc/ti/ti_sci_protocol.h
index 
52696763ecf6bc2336e796978e1cc02896db13ab..cb9798c8546617bcea9cc0f49f19c70e1e2c16f1
 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -632,6 +632,14 @@ struct ti_sci_fwl_ops {
        int (*change_fwl_owner)(const struct ti_sci_handle *handle, struct 
ti_sci_msg_fwl_owner *owner);
  };
+/**
+ * struct ti_sci_lpm_ops - Low Power Mode operations
+ * @restore_context: Request restoring context from DDR.
+ */
+struct ti_sci_lpm_ops {
+       int (*restore_context)(const struct ti_sci_handle *handle, u64 
ctx_addr);
+};
+
  /**
   * struct ti_sci_ops - Function support for TI SCI
   * @board_ops:        Miscellaneous operations
@@ -654,6 +662,7 @@ struct ti_sci_ops {
        struct ti_sci_rm_psil_ops rm_psil_ops;
        struct ti_sci_rm_udmap_ops rm_udmap_ops;
        struct ti_sci_fwl_ops fwl_ops;
+       struct ti_sci_lpm_ops lpm_ops;
  };
/**

Reply via email to