1
0
Fork 0

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>
hifive-unleashed-5.1
Alex Elder 2014-10-01 21:54:14 -05:00 committed by Greg Kroah-Hartman
parent ef0d2ba201
commit c68adb2f2c
5 changed files with 90 additions and 0 deletions

View File

@ -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 \

View File

@ -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);
}

View File

@ -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 */

View File

@ -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;

View File

@ -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))));