]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
greybus: control: add bundle deactivate and activate operation
authorDavid Lin <dtwlin@google.com>
Fri, 8 Jul 2016 03:07:00 +0000 (22:07 -0500)
committerAlex Elder <elder@linaro.org>
Fri, 8 Jul 2016 19:56:28 +0000 (14:56 -0500)
Add the AP implementation for the Greybus Control Bundle Deactivate
Operation. This operation requests a Bundle to enter the BUNDLE_OFF
state. All Connections associated with the Bundle must be closed prior
sending this operation.

Add the AP implementation for the Greybus Control Bundle Activate
Operation. This operation requests a specific Bundle to transition from
the BUNDLE_OFF state to the BUNDLE_ACTIVE state.

[elder@linaro.org: fixed a typo pointed out by Johan]

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/control.c
drivers/staging/greybus/control.h
drivers/staging/greybus/greybus_protocols.h

index a95c776f17a13aa41436c0e480d3866bc05eb114..a53fa3d68280de2886e7085983cd757790f1f455 100644 (file)
@@ -298,6 +298,56 @@ int gb_control_bundle_resume(struct gb_control *control, u8 bundle_id)
        return 0;
 }
 
+int gb_control_bundle_deactivate(struct gb_control *control, u8 bundle_id)
+{
+       struct gb_control_bundle_pm_request request;
+       struct gb_control_bundle_pm_response response;
+       int ret;
+
+       request.bundle_id = bundle_id;
+       ret = gb_operation_sync(control->connection,
+                               GB_CONTROL_TYPE_BUNDLE_DEACTIVATE, &request,
+                               sizeof(request), &response, sizeof(response));
+       if (ret) {
+               dev_err(&control->dev,
+                       "failed to send bundle deactivate: %d\n", ret);
+               return ret;
+       }
+
+       if (response.status != GB_CONTROL_BUNDLE_PM_OK) {
+               dev_err(&control->dev,
+                       "bundle error while deactivating: %d\n", response.status);
+               return gb_control_bundle_pm_status_map(response.status);
+       }
+
+       return 0;
+}
+
+int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id)
+{
+       struct gb_control_bundle_pm_request request;
+       struct gb_control_bundle_pm_response response;
+       int ret;
+
+       request.bundle_id = bundle_id;
+       ret = gb_operation_sync(control->connection,
+                               GB_CONTROL_TYPE_BUNDLE_ACTIVATE, &request,
+                               sizeof(request), &response, sizeof(response));
+       if (ret) {
+               dev_err(&control->dev,
+                       "failed to send bundle activate: %d\n", ret);
+               return ret;
+       }
+
+       if (response.status != GB_CONTROL_BUNDLE_PM_OK) {
+               dev_err(&control->dev,
+                       "bundle error while activating: %d\n", response.status);
+               return gb_control_bundle_pm_status_map(response.status);
+       }
+
+       return 0;
+}
+
 static ssize_t vendor_string_show(struct device *dev,
                        struct device_attribute *attr, char *buf)
 {
index c7f34635ea92b41a58dedf8b4ebe1d5fe8304e89..5ddf0138c6c5538895bd982c446f2b829c54baca 100644 (file)
@@ -54,4 +54,6 @@ int gb_control_timesync_authoritative(struct gb_control *control,
                                      u64 *frame_time);
 int gb_control_bundle_suspend(struct gb_control *control, u8 bundle_id);
 int gb_control_bundle_resume(struct gb_control *control, u8 bundle_id);
+int gb_control_bundle_deactivate(struct gb_control *control, u8 bundle_id);
+int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id);
 #endif /* __CONTROL_H */
index 3b6fd02685297314622f869eb745ce221e3f64d8..1ae335040139854c31aefc12e545476a4bbff8d4 100644 (file)
@@ -128,6 +128,8 @@ struct gb_protocol_version_response {
 #define GB_CONTROL_TYPE_MODE_SWITCH            0x0e
 #define GB_CONTROL_TYPE_BUNDLE_SUSPEND         0x0f
 #define GB_CONTROL_TYPE_BUNDLE_RESUME          0x10
+#define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE      0x11
+#define GB_CONTROL_TYPE_BUNDLE_ACTIVATE                0x12
 
 struct gb_control_version_request {
        __u8    major;