summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Elder2014-10-02 04:54:14 +0200
committerGreg Kroah-Hartman2014-10-03 06:18:41 +0200
commitc68adb2f2c999886f8e18e98ad4e69aec14c9f32 (patch)
treefca422bc25269ef9251fce7eab6ddd8080b13b5b /drivers
parentgreybus: define greybus function abstraction (diff)
downloadkernel-qcow2-linux-c68adb2f2c999886f8e18e98ad4e69aec14c9f32.tar.gz
kernel-qcow2-linux-c68adb2f2c999886f8e18e98ad4e69aec14c9f32.tar.xz
kernel-qcow2-linux-c68adb2f2c999886f8e18e98ad4e69aec14c9f32.zip
greybus: introduce a connection abstraction
Within a UniPro network a pair of CPorts can be linked to form a UniPro Connection. This patch creates a new abstraction to represent an AP CPort that is connected with a CPort used by a function within a Greybus module. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/greybus/Makefile1
-rw-r--r--drivers/staging/greybus/connection.c48
-rw-r--r--drivers/staging/greybus/connection.h29
-rw-r--r--drivers/staging/greybus/core.c10
-rw-r--r--drivers/staging/greybus/greybus.h2
5 files changed, 90 insertions, 0 deletions
diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile
index 0efb6958322d..ed39a5c6b6fd 100644
--- a/drivers/staging/greybus/Makefile
+++ b/drivers/staging/greybus/Makefile
@@ -6,6 +6,7 @@ greybus-y := core.o \
module.o \
interface.o \
function.o \
+ connection.o \
i2c-gb.o \
gpio-gb.o \
sdio-gb.o \
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
new file mode 100644
index 000000000000..113c98542858
--- /dev/null
+++ b/drivers/staging/greybus/connection.c
@@ -0,0 +1,48 @@
+/*
+ * Greybus connections
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#include "greybus.h"
+
+/*
+ * Set up a Greybus connection, representing the bidirectional link
+ * between a CPort on a (local) Greybus host device and a CPort on
+ * another Greybus module.
+ *
+ * Returns a pointer to the new connection if successful, or a null
+ * pointer otherwise.
+ */
+struct gb_connection *gb_connection_create(struct greybus_host_device *hd,
+ u16 cport_id, struct gb_function *function)
+{
+ struct gb_connection *connection;
+
+ connection = kzalloc(sizeof(*connection), GFP_KERNEL);
+ if (!connection)
+ return NULL;
+
+ connection->hd = hd; /* XXX refcount? */
+ connection->cport_id = cport_id;
+ connection->function = function; /* XXX refcount? */
+
+ return connection;
+}
+
+/*
+ * Tear down a previously set up connection.
+ */
+void gb_connection_destroy(struct gb_connection *connection)
+{
+ if (WARN_ON(!connection))
+ return;
+
+ /* XXX Need to wait for any outstanding requests to complete */
+
+ /* kref_put(function); */
+ /* kref_put(hd); */
+ kfree(connection);
+}
diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h
new file mode 100644
index 000000000000..79b3b07f94c4
--- /dev/null
+++ b/drivers/staging/greybus/connection.h
@@ -0,0 +1,29 @@
+/*
+ * Greybus connections
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#ifndef __CONNECTION_H
+#define __CONNECTION_H
+
+#include <linux/list.h>
+
+#include "greybus.h"
+#include "function.h"
+
+struct gb_connection {
+ struct gb_function *function;
+ struct greybus_host_device *hd;
+ u16 cport_id; /* Host side */
+
+ struct list_head host_links;
+};
+
+bool gb_connection_setup(struct greybus_host_device *hd, u16 cport_id,
+ struct gb_function *function);
+void gb_connection_teardown(struct gb_connection *connection);
+
+#endif /* __CONNECTION_H */
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c
index 934bdebe039c..eb8f8e522e5b 100644
--- a/drivers/staging/greybus/core.c
+++ b/drivers/staging/greybus/core.c
@@ -147,12 +147,22 @@ static struct device_type greybus_module_type = {
.release = greybus_module_release,
};
+/* XXX
+ * This needs to be driven by the list of functions that the
+ * manifest says are present.
+ */
static int gb_init_subdevs(struct gb_module *gmod,
const struct greybus_module_id *id)
{
int retval;
/* Allocate all of the different "sub device types" for this device */
+
+ /* XXX
+ * Decide what exactly we should get supplied for the i2c
+ * probe, and then work that back to what should be present
+ * in the manifest.
+ */
retval = gb_i2c_probe(gmod, id);
if (retval)
goto error_i2c;
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index 4eb70af9e006..732cc5e51dc4 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -23,6 +23,7 @@
#include "module.h"
#include "interface.h"
#include "function.h"
+#include "connection.h"
/* Matches up with the Greybus Protocol specification document */
@@ -180,6 +181,7 @@ struct greybus_host_device {
const struct greybus_host_driver *driver;
struct list_head modules;
+ struct list_head connections;
/* Private data for the host driver */
unsigned long hd_priv[0] __attribute__ ((aligned(sizeof(s64))));