tisci: Add support for querying resource range
authorNikhil Devshatwar <nikhil.nd@ti.com>
Wed, 4 Nov 2020 07:08:29 +0000 (12:38 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Wed, 4 Nov 2020 09:44:38 +0000 (15:14 +0530)
Add support for command ti_sci_cmd_get_range which returns
the assigned range of resources for a certain host.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
common/tisci/tisci_core.c
include/tisci.h
include/tisci_protocol.h

index de401da027546996516573c4c8f0f35ceaab536c..529e9655659b34812e57257da232b0e71cc5855b 100644 (file)
@@ -100,3 +100,35 @@ int ti_sci_init(void)
 
        return 0;
 }
+
+int ti_sci_cmd_get_range(uint16_t type, uint16_t subtype, uint16_t host_id,
+                               struct ti_sci_rm_desc *desc)
+{
+       struct ti_sci_msg_resp_get_resource_range *resp;
+       struct ti_sci_msg_req_get_resource_range *req;
+       uint8_t buf[SEC_PROXY_MAX_MSG_SIZE];
+       struct k3_sec_proxy_msg msg;
+       int ret = 0;
+
+       memset(buf, 0, sizeof(buf));
+       ti_sci_setup_header((struct ti_sci_msg_hdr *)buf,
+                           TI_SCI_MSG_GET_RESOURCE_RANGE, 0);
+       req = (struct ti_sci_msg_req_get_resource_range *)buf;
+       req->type = type;
+       req->subtype = subtype;
+       req->secondary_host = host_id;
+
+       msg.len = sizeof(*req);
+       msg.buf = buf;
+       ret = ti_sci_xfer_msg(&msg);
+       if (ret)
+               return ret;
+
+       resp = (struct ti_sci_msg_resp_get_resource_range *)buf;
+       desc->start = resp->range_start;
+       desc->num = resp->range_num;
+       desc->start_sec = resp->range_start_sec;
+       desc->num_sec = resp->range_num_sec;
+
+       return 0;
+}
index e0b72f627d8d66603d38c8f86cd26f990df821e1..c23ac9bc588fe28c5e786642daeaeb590593238e 100644 (file)
@@ -82,6 +82,11 @@ struct ti_sci_clocks_info {
        char clk_function[100];
 };
 
+struct ti_sci_rm_info {
+       uint32_t utype;
+       char subtype_name[100];
+};
+
 struct ti_sci_info {
        uint8_t host_id;
        struct ti_sci_version_info version;
@@ -95,6 +100,15 @@ struct ti_sci_info {
        uint32_t num_devices;
        struct ti_sci_clocks_info *clocks_info;
        uint32_t num_clocks;
+       struct ti_sci_rm_info *rm_info;
+       uint32_t num_res;
+};
+
+struct ti_sci_rm_desc {
+       uint16_t start;
+       uint16_t num;
+       uint16_t start_sec;
+       uint16_t num_sec;
 };
 
 #define MAX_DEVICE_STATE_LENGTH                25
@@ -110,4 +124,6 @@ int ti_sci_cmd_put_clk(uint32_t dev_id, uint32_t clk_id);
 const char *ti_sci_cmd_get_clk_state(uint32_t dev_id, uint32_t clk_id);
 int ti_sci_cmd_set_clk_freq(uint32_t dev_id, uint32_t clk_id, uint64_t freq);
 int ti_sci_cmd_get_clk_freq(uint32_t dev_id, uint32_t clk_id, uint64_t *freq);
+int ti_sci_cmd_get_range(uint16_t type, uint16_t subtype, uint16_t host_id,
+                               struct ti_sci_rm_desc *desc);
 #endif
index 6d28bbbfd70cac6a056169c6f6fc51aa16da07f0..7451e3c17ae5e516439a1956c8796ff4d33b751c 100644 (file)
@@ -49,6 +49,8 @@
 #define TI_SCI_MSG_SET_CLOCK_FREQ      0x010c
 #define TI_SCI_MSG_QUERY_CLOCK_FREQ    0x010d
 #define TI_SCI_MSG_GET_CLOCK_FREQ      0x010e
+/* Resource Management Requests */
+#define TI_SCI_MSG_GET_RESOURCE_RANGE  0x1500
 
 #define TI_SCI_MSG_FLAG(val)                   (1 << (val))
 #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE     0x0
@@ -108,6 +110,23 @@ struct ti_sci_msg_resp_get_device_state {
        uint8_t current_state;
 } __attribute__ ((__packed__));
 
+struct ti_sci_msg_req_get_resource_range {
+       struct ti_sci_msg_hdr hdr;
+#define MSG_RM_RESOURCE_TYPE_MASK      0x3ff
+#define MSG_RM_RESOURCE_SUBTYPE_MASK   0x3f
+       uint16_t type;
+       uint8_t subtype;
+       uint8_t secondary_host;
+} __attribute__ ((__packed__));
+
+struct ti_sci_msg_resp_get_resource_range {
+       struct ti_sci_msg_hdr hdr;
+       uint16_t range_start;
+       uint16_t range_num;
+       uint16_t range_start_sec;
+       uint16_t range_num_sec;
+} __attribute__ ((__packed__));
+
 struct ti_sci_msg_req_set_clock_state {
        /* Additional hdr->flags options */
 #define MSG_FLAG_CLOCK_ALLOW_SSC               TI_SCI_MSG_FLAG(8)