greybus: control: add interface deactivate prepare 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 Interface Deactivate
Prepare Operation. AP uses this Operation during the Power Down
transition to request the bridge to power down after it detects a
subsequent UniPro link hibernation.

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 252352ce366459300f83206ceda524b3a6d4038b..a1c78fc68509acc3f33e8c65b8931bbb818071c9 100644 (file)
@@ -383,6 +383,29 @@ int gb_control_interface_suspend_prepare(struct gb_control *control)
        return 0;
 }
 
+int gb_control_interface_deactivate_prepare(struct gb_control *control)
+{
+       struct gb_control_intf_pm_response response;
+       int ret;
+
+       ret = gb_operation_sync(control->connection,
+                               GB_CONTROL_TYPE_INTF_DEACTIVATE_PREPARE, NULL,
+                               0, &response, sizeof(response));
+       if (ret) {
+               dev_err(&control->dev, "failed to send interface deactivate prepare: %d\n",
+                       ret);
+               return ret;
+       }
+
+       if (response.status != GB_CONTROL_INTF_PM_OK) {
+               dev_err(&control->dev, "interface error while preparing deactivate: %d\n",
+                       response.status);
+               return gb_control_interface_pm_status_map(response.status);
+       }
+
+       return 0;
+}
+
 static ssize_t vendor_string_show(struct device *dev,
                        struct device_attribute *attr, char *buf)
 {
index bc32ca78d2256e7d33b62484abc72e963fb72a47..2f76ae48b2d80b04e48ee40ae9b2140dc2605ff1 100644 (file)
@@ -57,4 +57,5 @@ 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);
 int gb_control_interface_suspend_prepare(struct gb_control *control);
+int gb_control_interface_deactivate_prepare(struct gb_control *control);
 #endif /* __CONTROL_H */
index cd64a99debfa113d692be44dccedf93794a27a07..10209ae61e1b647537db55b6072bb68c726f6106 100644 (file)
@@ -131,6 +131,7 @@ struct gb_protocol_version_response {
 #define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE      0x11
 #define GB_CONTROL_TYPE_BUNDLE_ACTIVATE                0x12
 #define GB_CONTROL_TYPE_INTF_SUSPEND_PREPARE           0x13
+#define GB_CONTROL_TYPE_INTF_DEACTIVATE_PREPARE        0x14
 
 struct gb_control_version_request {
        __u8    major;