Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d706ef8f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

greybus: Merge branch 'master' into branch 'svc'.



This drags in the firmware driver, and the start of some loopback
changes.

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parents 542f27a1 58dab0f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ greybus-y := core.o \
		protocol.o	\
		control.o	\
		svc.o		\
		firmware.o	\
		operation.o

gb-phy-y :=	gpbridge.o	\
+48 −2
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@

#include "greybus.h"

#define GB_CONNECTION_TS_KFIFO_ELEMENTS	2
#define GB_CONNECTION_TS_KFIFO_LEN \
	(GB_CONNECTION_TS_KFIFO_ELEMENTS * sizeof(struct timeval))

static DEFINE_SPINLOCK(gb_connections_lock);

/* This is only used at initialization time; no locking is required. */
@@ -63,6 +67,29 @@ void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
}
EXPORT_SYMBOL_GPL(greybus_data_rcvd);

void gb_connection_push_timestamp(struct gb_connection *connection)
{
	struct timeval tv;

	do_gettimeofday(&tv);
	kfifo_in_locked(&connection->ts_kfifo, (void *)&tv,
			sizeof(struct timeval), &connection->lock);
}
EXPORT_SYMBOL_GPL(gb_connection_push_timestamp);

int gb_connection_pop_timestamp(struct gb_connection *connection,
				struct timeval *tv)
{
	int retval;

	if (!kfifo_len(&connection->ts_kfifo))
		return -ENOMEM;
	retval = kfifo_out_locked(&connection->ts_kfifo, (void *)tv,
				  sizeof(*tv), &connection->lock);
	return retval;
}
EXPORT_SYMBOL_GPL(gb_connection_pop_timestamp);

static ssize_t state_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{
@@ -102,6 +129,7 @@ static void gb_connection_release(struct device *dev)
	struct gb_connection *connection = to_gb_connection(dev);

	destroy_workqueue(connection->wq);
	kfifo_free(&connection->ts_kfifo);
	kfree(connection);
}

@@ -222,6 +250,10 @@ gb_connection_create_range(struct greybus_host_device *hd,
	if (!connection->wq)
		goto err_free_connection;

	if (kfifo_alloc(&connection->ts_kfifo, GB_CONNECTION_TS_KFIFO_LEN,
			GFP_KERNEL))
		goto err_free_connection;

	connection->dev.parent = parent;
	connection->dev.bus = &greybus_bus_type;
	connection->dev.type = &greybus_connection_type;
@@ -238,7 +270,7 @@ gb_connection_create_range(struct greybus_host_device *hd,
		pr_err("failed to add connection device for cport 0x%04hx\n",
			cport_id);

		goto err_remove_ida;
		goto err_free_kfifo;
	}

	spin_lock_irq(&gb_connections_lock);
@@ -264,6 +296,8 @@ gb_connection_create_range(struct greybus_host_device *hd,

	return connection;

err_free_kfifo:
	kfifo_free(&connection->ts_kfifo);
err_free_connection:
	kfree(connection);
err_remove_ida:
@@ -394,7 +428,19 @@ int gb_connection_init(struct gb_connection *connection)
	 * this for SVC as that is initiated by the SVC.
	 */
	if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
		ret = gb_protocol_get_version(connection, NULL, 0);
		bool send_request = false;

		/*
		 * We need to send the protocol version of the firmware protocol
		 * supported by AP and so this special case.
		 */
		if (connection->protocol->id == GREYBUS_PROTOCOL_FIRMWARE)
			send_request = true;

		// FIXME: Should we always send the protocol version AP can
		// support ?

		ret = gb_protocol_get_version(connection, send_request);
		if (ret) {
			dev_err(&connection->dev,
				"Failed to get version CPort-%d (%d)\n",
+5 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#define __CONNECTION_H

#include <linux/list.h>
#include <linux/kfifo.h>

enum gb_connection_state {
	GB_CONNECTION_STATE_INVALID	= 0,
@@ -42,6 +43,7 @@ struct gb_connection {
	struct list_head		operations;

	struct workqueue_struct		*wq;
	struct kfifo			ts_kfifo;

	atomic_t			op_cycle;

@@ -65,6 +67,9 @@ void gb_hd_connections_exit(struct greybus_host_device *hd);

void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
			u8 *data, size_t length);
void gb_connection_push_timestamp(struct gb_connection *connection);
int gb_connection_pop_timestamp(struct gb_connection *connection,
				struct timeval *tv);

void gb_connection_bind_protocol(struct gb_connection *connection);

+9 −0
Original line number Diff line number Diff line
@@ -308,8 +308,16 @@ static int __init gb_init(void)
		goto error_svc;
	}

	retval = gb_firmware_protocol_init();
	if (retval) {
		pr_err("gb_firmware_protocol_init failed\n");
		goto error_firmware;
	}

	return 0;	/* Success */

error_firmware:
	gb_svc_protocol_exit();
error_svc:
	gb_control_protocol_exit();
error_control:
@@ -327,6 +335,7 @@ module_init(gb_init);

static void __exit gb_exit(void)
{
	gb_firmware_protocol_exit();
	gb_svc_protocol_exit();
	gb_control_protocol_exit();
	gb_endo_exit();
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@

#include "greybus.h"
#include "kernel_ver.h"
#include "connection.h"

/* Memory sizes for the buffers sent to/from the ES1 controller */
#define ES1_GBUF_MSG_SIZE_MAX	2048
@@ -215,6 +216,7 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id,
			  usb_sndbulkpipe(udev, es1->cport_out_endpoint),
			  message->buffer, buffer_size,
			  cport_out_callback, message);
	gb_connection_push_timestamp(message->operation->connection);
	retval = usb_submit_urb(urb, gfp_mask);
	if (retval) {
		pr_err("error %d submitting URB\n", retval);
Loading