]> git.karo-electronics.de Git - linux-beck.git/commitdiff
greybus: hd/es2: add cport_connected callback and ARPC
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 10 Aug 2016 10:58:42 +0000 (12:58 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 11 Aug 2016 12:13:07 +0000 (14:13 +0200)
Add a host-device cport_connected callback, which will be called after a
connection has been created and that can be used by the host-device
driver to make sure its internal state is updated to match the CPort
attributes set by the SVC.

This callback will eventually replace the cport_features_enable
callback.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/arpc.h
drivers/staging/greybus/es2.c
drivers/staging/greybus/hd.h

index 1bfb7db8efe3def50b38775d9ba7cd8bb66f4fbe..8a9027101b37ca60e2f3cdb340226f37bca1f9c2 100644 (file)
@@ -77,9 +77,15 @@ struct arpc_response_message {
 
 /* ARPC requests */
 #define ARPC_TYPE_CPORT_RESET                  0x00
+#define ARPC_TYPE_CPORT_CONNECTED              0x01
 
 struct arpc_cport_reset_req {
        __le16 cport_id;
 } __packed;
 
+struct arpc_cport_connected_req {
+       __le16 cport_id;
+} __packed;
+
+
 #endif /* __ARPC_H */
index 955b37d0c4c66e9a8261add25026b1a7a3195ac5..9af9b73818f4cb3c4bd05a6b383777f6c4ada6dd 100644 (file)
@@ -746,6 +746,25 @@ static int cport_disable(struct gb_host_device *hd, u16 cport_id)
        return 0;
 }
 
+static int es2_cport_connected(struct gb_host_device *hd, u16 cport_id)
+{
+       struct es2_ap_dev *es2 = hd_to_es2(hd);
+       struct device *dev = &es2->usb_dev->dev;
+       struct arpc_cport_connected_req req;
+       int ret;
+
+       req.cport_id = cpu_to_le16(cport_id);
+       ret = arpc_sync(es2, ARPC_TYPE_CPORT_CONNECTED, &req, sizeof(req),
+                       NULL, ES2_ARPC_CPORT_TIMEOUT);
+       if (ret) {
+               dev_err(dev, "failed to set connected state for cport %u: %d\n",
+                               cport_id, ret);
+               return ret;
+       }
+
+       return 0;
+}
+
 static int latency_tag_enable(struct gb_host_device *hd, u16 cport_id)
 {
        int retval;
@@ -930,6 +949,7 @@ static struct gb_hd_driver es2_driver = {
        .cport_release                  = es2_cport_release,
        .cport_enable                   = cport_enable,
        .cport_disable                  = cport_disable,
+       .cport_connected                = es2_cport_connected,
        .latency_tag_enable             = latency_tag_enable,
        .latency_tag_disable            = latency_tag_disable,
        .output                         = output,
index 6ea5e28d9eb9d88f420e45574e40ce55661bf819..be818797d6c6edd2a8a3ccb33e2fb65a34383a36 100644 (file)
@@ -22,6 +22,7 @@ struct gb_hd_driver {
        int (*cport_enable)(struct gb_host_device *hd, u16 cport_id,
                                unsigned long flags);
        int (*cport_disable)(struct gb_host_device *hd, u16 cport_id);
+       int (*cport_connected)(struct gb_host_device *hd, u16 cport_id);
        int (*cport_flush)(struct gb_host_device *hd, u16 cport_id);
        int (*cport_ping)(struct gb_host_device *hd, u16 cport_id);
        int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,