firmware: ti_sci: Allow for device shared and exclusive requests
authorLokesh Vutla <lokeshvutla@ti.com>
Fri, 7 Jun 2019 13:54:39 +0000 (19:24 +0530)
committerTom Rini <trini@konsulko.com>
Sat, 27 Jul 2019 01:49:21 +0000 (21:49 -0400)
Sysfw provides an option for requesting exclusive access for a
device using the flags MSG_FLAG_DEVICE_EXCLUSIVE. If this flag is
not used, the device is meant to be shared across hosts. Once a device
is requested from a host with this flag set, any request to this
device from a different host will be nacked by sysfw. Current tisci
driver enables this flag for every device requests. But this may not
be true for all the devices. So provide a separate commands in driver
for exclusive and shared device requests.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
drivers/firmware/ti_sci.c
include/linux/soc/ti/ti_sci_protocol.h

index 303aa6a631147168b260428bceba294c1417c160..eadb91e1076beea8cfcdd136cdc711c4d1cf5cf0 100644 (file)
@@ -547,8 +547,14 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
  */
 static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
 {
-       return ti_sci_set_device_state(handle, id,
-                                      MSG_FLAG_DEVICE_EXCLUSIVE,
+       return ti_sci_set_device_state(handle, id, 0,
+                                      MSG_DEVICE_SW_STATE_ON);
+}
+
+static int ti_sci_cmd_get_device_exclusive(const struct ti_sci_handle *handle,
+                                          u32 id)
+{
+       return ti_sci_set_device_state(handle, id, MSG_FLAG_DEVICE_EXCLUSIVE,
                                       MSG_DEVICE_SW_STATE_ON);
 }
 
@@ -566,7 +572,14 @@ static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
 static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id)
 {
        return ti_sci_set_device_state(handle, id,
-                                      MSG_FLAG_DEVICE_EXCLUSIVE,
+                                      0,
+                                      MSG_DEVICE_SW_STATE_RETENTION);
+}
+
+static int ti_sci_cmd_idle_device_exclusive(const struct ti_sci_handle *handle,
+                                           u32 id)
+{
+       return ti_sci_set_device_state(handle, id, MSG_FLAG_DEVICE_EXCLUSIVE,
                                       MSG_DEVICE_SW_STATE_RETENTION);
 }
 
@@ -583,8 +596,8 @@ static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id)
  */
 static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id)
 {
-       return ti_sci_set_device_state(handle, id,
-                                      0, MSG_DEVICE_SW_STATE_AUTO_OFF);
+       return ti_sci_set_device_state(handle, id, 0,
+                                      MSG_DEVICE_SW_STATE_AUTO_OFF);
 }
 
 /**
@@ -2632,7 +2645,9 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
        bops->board_config_pm = ti_sci_cmd_set_board_config_pm;
 
        dops->get_device = ti_sci_cmd_get_device;
+       dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive;
        dops->idle_device = ti_sci_cmd_idle_device;
+       dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive;
        dops->put_device = ti_sci_cmd_put_device;
        dops->is_valid = ti_sci_cmd_dev_is_valid;
        dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt;
index c57802f2934500cf2f63a29076cc2903c7b26b67..842fb596f70938d16cd9326026da43ced00982e8 100644 (file)
@@ -117,7 +117,10 @@ struct ti_sci_board_ops {
  */
 struct ti_sci_dev_ops {
        int (*get_device)(const struct ti_sci_handle *handle, u32 id);
+       int (*get_device_exclusive)(const struct ti_sci_handle *handle, u32 id);
        int (*idle_device)(const struct ti_sci_handle *handle, u32 id);
+       int (*idle_device_exclusive)(const struct ti_sci_handle *handle,
+                                    u32 id);
        int (*put_device)(const struct ti_sci_handle *handle, u32 id);
        int (*is_valid)(const struct ti_sci_handle *handle, u32 id);
        int (*get_context_loss_count)(const struct ti_sci_handle *handle,