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.

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..74e4f162aaa2da8c3ecc1cf393ca11fa5108d83b
 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_min_context_restore(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,
+                                    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->min_context_restore = ti_sci_cmd_min_context_restore;
 }
 
 /**
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index 
ce50bf6800eb1fee70a872d8ae648b1a9582b681..68908c6c8c46ed2e3f0ed1ad4e764b14f0b5f465
 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 restore.
+ * @ctx_hi             High 32-bits of physical pointer to address to use for 
context restore.
+ */
+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..6b1dd801f5f8ec5f6bce3490401a71b24954a2ff
 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
+ * @min_context_restore: Request restoring context from DDR.
+ */
+struct ti_sci_lpm_ops {
+       int (*min_context_restore)(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;
 };
 
 /**

-- 
2.51.0

Reply via email to