]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: connection: generalise CPortFlags handling
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 3 Mar 2016 12:34:38 +0000 (13:34 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 5 Mar 2016 02:26:08 +0000 (18:26 -0800)
Generalise the svc connection-create helper to accept a cport-flags
argument and handle the flags in the connection code instead.

Note that the camera driver currently manages its data connection
directly. We keep E2EFC enabled for now even though it will soon need
to be disabled due to some pending firmware updates.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/camera.c
drivers/staging/greybus/connection.c
drivers/staging/greybus/svc.c
drivers/staging/greybus/svc.h

index 444e218e15ab224d978e7879da2c1b23f3260933..3ca585f08b85fa59e68d5b3e1addaab82a859b94 100644 (file)
@@ -817,6 +817,7 @@ static int gb_camera_connection_init(struct gb_connection *connection)
 {
        struct gb_svc *svc = connection->hd->svc;
        struct gb_camera *gcam;
+       u8 cport_flags;
        int ret;
 
        gcam = kzalloc(sizeof(*gcam), GFP_KERNEL);
@@ -830,9 +831,12 @@ static int gb_camera_connection_init(struct gb_connection *connection)
         * Create the data connection between camera module CDSI0 and APB CDS1.
         * The CPort IDs are hardcoded by the ES2 bridges.
         */
+       /* FIXME: remove E2EFC */
+       cport_flags = GB_SVC_CPORT_FLAG_E2EFC | GB_SVC_CPORT_FLAG_CSD_N |
+                       GB_SVC_CPORT_FLAG_CSV_N;
        ret = gb_svc_connection_create(svc, connection->intf->interface_id,
                                       ES2_APB_CDSI0_CPORT, svc->ap_intf_id,
-                                      ES2_APB_CDSI1_CPORT, false);
+                                      ES2_APB_CDSI1_CPORT, cport_flags);
        if (ret < 0)
                goto error;
 
index eaceafc4f8dd896b1bd83bd37956d27dca740454..01d31f66b28e58a708ae916e2a286d240795afab 100644 (file)
@@ -327,18 +327,29 @@ gb_connection_svc_connection_create(struct gb_connection *connection)
 {
        struct gb_host_device *hd = connection->hd;
        struct gb_interface *intf;
+       u8 cport_flags;
        int ret;
 
        if (gb_connection_is_static(connection))
                return gb_connection_hd_fct_flow_enable(connection);
 
        intf = connection->intf;
+
+       /* The ES2/ES3 bootrom requires E2EFC, CSD and CSV to be disabled. */
+       cport_flags = GB_SVC_CPORT_FLAG_CSV_N;
+       if (intf->boot_over_unipro) {
+               cport_flags |= GB_SVC_CPORT_FLAG_CSD_N;
+       } else {
+               cport_flags |= GB_SVC_CPORT_FLAG_CSD_N |
+                               GB_SVC_CPORT_FLAG_E2EFC;
+       }
+
        ret = gb_svc_connection_create(hd->svc,
                        hd->svc->ap_intf_id,
                        connection->hd_cport_id,
                        intf->interface_id,
                        connection->intf_cport_id,
-                       intf->boot_over_unipro);
+                       cport_flags);
        if (ret) {
                dev_err(&connection->hd->dev,
                        "%s: failed to create svc connection: %d\n",
index 65c6d8ee1c51d85c85f0d4c7c3f8a5b2e2e01ee5..69c37d4ca30c640322cf7aa78bfd6c9ea060a518 100644 (file)
 
 #include "greybus.h"
 
-#define CPORT_FLAGS_E2EFC       BIT(0)
-#define CPORT_FLAGS_CSD_N       BIT(1)
-#define CPORT_FLAGS_CSV_N       BIT(2)
-
 #define SVC_KEY_ARA_BUTTON     KEY_A
 
 struct gb_svc_deferred_request {
@@ -283,7 +279,7 @@ static int gb_svc_read_and_clear_module_boot_status(struct gb_interface *intf)
 int gb_svc_connection_create(struct gb_svc *svc,
                                u8 intf1_id, u16 cport1_id,
                                u8 intf2_id, u16 cport2_id,
-                               bool boot_over_unipro)
+                               u8 cport_flags)
 {
        struct gb_svc_conn_create_request request;
 
@@ -292,13 +288,7 @@ int gb_svc_connection_create(struct gb_svc *svc,
        request.intf2_id = intf2_id;
        request.cport2_id = cpu_to_le16(cport2_id);
        request.tc = 0;         /* TC0 */
-
-       /* The ES2/ES3 bootrom requires E2EFC, CSD and CSV to be disabled. */
-       request.flags = CPORT_FLAGS_CSV_N;
-       if (boot_over_unipro)
-               request.flags |= CPORT_FLAGS_CSD_N;
-       else
-               request.flags |= CPORT_FLAGS_CSD_N | CPORT_FLAGS_E2EFC;
+       request.flags = cport_flags;
 
        return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE,
                                 &request, sizeof(request), NULL, 0);
index b9fb93ea56beff63393fded20e451cdeae74ff7e..0436f49ef8fa2ba45841e8fe84d716352908ab14 100644 (file)
 #ifndef __SVC_H
 #define __SVC_H
 
+#define GB_SVC_CPORT_FLAG_E2EFC       BIT(0)
+#define GB_SVC_CPORT_FLAG_CSD_N       BIT(1)
+#define GB_SVC_CPORT_FLAG_CSV_N       BIT(2)
+
 enum gb_svc_state {
        GB_SVC_STATE_RESET,
        GB_SVC_STATE_PROTOCOL_VERSION,
@@ -46,7 +50,7 @@ void gb_svc_put(struct gb_svc *svc);
 
 int gb_svc_intf_reset(struct gb_svc *svc, u8 intf_id);
 int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
-                            u8 intf2_id, u16 cport2_id, bool boot_over_unipro);
+                            u8 intf2_id, u16 cport2_id, u8 cport_flags);
 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
                               u8 intf2_id, u16 cport2_id);
 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id);