Commit ecf7d579 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: descriptor type updates

Some more updates to the definition of a manifest descriptor.
    - We get rid of function descriptors.  The type of function is
      easily specified with the CPort it uses.
    - Add a new interface descriptor type.
    - Clean up the CPort descriptor structure, eliminating fields
      that serve no purpose and adding the function id field

The sysfs stuff will be updated a little later to add entries
for the Greybus interfaces associated with modules.

Rearrange the order of a few things in "greybus_manifest.h".
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 513c54cb
...@@ -232,19 +232,6 @@ static const struct greybus_module_id fake_gb_id = { ...@@ -232,19 +232,6 @@ static const struct greybus_module_id fake_gb_id = {
GREYBUS_DEVICE(0x42, 0x42) GREYBUS_DEVICE(0x42, 0x42)
}; };
static int create_function(struct greybus_module *gmod,
struct greybus_descriptor_function *function,
size_t desc_size)
{
if (desc_size != sizeof(*function)) {
dev_err(gmod->dev.parent, "invalid function header size %zu\n",
desc_size);
return -EINVAL;
}
memcpy(&gmod->function, function, desc_size);
return 0;
}
static int create_module(struct greybus_module *gmod, static int create_module(struct greybus_module *gmod,
struct greybus_descriptor_module *module, struct greybus_descriptor_module *module,
size_t desc_size) size_t desc_size)
...@@ -385,9 +372,7 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, ...@@ -385,9 +372,7 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
data_size = (size_t)desc_size - sizeof(desc->header); data_size = (size_t)desc_size - sizeof(desc->header);
switch (le16_to_cpu(desc->header.type)) { switch (le16_to_cpu(desc->header.type)) {
case GREYBUS_TYPE_FUNCTION: case GREYBUS_TYPE_DEVICE:
retval = create_function(gmod, &desc->function,
data_size);
break; break;
case GREYBUS_TYPE_MODULE: case GREYBUS_TYPE_MODULE:
......
...@@ -192,7 +192,6 @@ void greybus_gbuf_finished(struct gbuf *gbuf); ...@@ -192,7 +192,6 @@ void greybus_gbuf_finished(struct gbuf *gbuf);
struct greybus_module { struct greybus_module {
struct device dev; struct device dev;
u16 module_number; u16 module_number;
struct greybus_descriptor_function function;
struct greybus_descriptor_module module; struct greybus_descriptor_module module;
int num_cports; int num_cports;
int num_strings; int num_strings;
...@@ -210,12 +209,9 @@ struct greybus_module { ...@@ -210,12 +209,9 @@ struct greybus_module {
}; };
#define to_greybus_module(d) container_of(d, struct greybus_module, dev) #define to_greybus_module(d) container_of(d, struct greybus_module, dev)
struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod, struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod, u16 cport_id,
u16 cport_id, gbuf_complete_t complete, unsigned int size,
gbuf_complete_t complete, gfp_t gfp_mask, void *context);
unsigned int size,
gfp_t gfp_mask,
void *context);
void greybus_free_gbuf(struct gbuf *gbuf); void greybus_free_gbuf(struct gbuf *gbuf);
struct gbuf *greybus_get_gbuf(struct gbuf *gbuf); struct gbuf *greybus_get_gbuf(struct gbuf *gbuf);
#define greybus_put_gbuf greybus_free_gbuf #define greybus_put_gbuf greybus_free_gbuf
......
...@@ -14,26 +14,15 @@ ...@@ -14,26 +14,15 @@
#pragma pack(push, 1) #pragma pack(push, 1)
struct greybus_manifest_header {
__le16 size;
__u8 version_major;
__u8 version_minor;
};
enum greybus_descriptor_type { enum greybus_descriptor_type {
GREYBUS_TYPE_INVALID = 0x00, GREYBUS_TYPE_INVALID = 0x00,
GREYBUS_TYPE_MODULE = 0x01, GREYBUS_TYPE_MODULE = 0x01,
GREYBUS_TYPE_FUNCTION = 0x02, GREYBUS_TYPE_DEVICE = 0x02,
GREYBUS_TYPE_CLASS = 0x03, GREYBUS_TYPE_CLASS = 0x03,
GREYBUS_TYPE_STRING = 0x04, GREYBUS_TYPE_STRING = 0x04,
GREYBUS_TYPE_CPORT = 0x05, GREYBUS_TYPE_CPORT = 0x05,
}; };
struct greybus_descriptor_header {
__le16 size;
__u8 type; /* enum greybus_descriptor_type */
};
enum greybus_function_type { enum greybus_function_type {
GREYBUS_FUNCTION_CONTROL = 0x00, GREYBUS_FUNCTION_CONTROL = 0x00,
GREYBUS_FUNCTION_USB = 0x01, GREYBUS_FUNCTION_USB = 0x01,
...@@ -51,11 +40,10 @@ enum greybus_function_type { ...@@ -51,11 +40,10 @@ enum greybus_function_type {
GREYBUS_FUNCTION_VENDOR = 0xff, GREYBUS_FUNCTION_VENDOR = 0xff,
}; };
struct greybus_descriptor_function { /*
__le16 cport; * A module descriptor describes information about a module as a
__u8 function_type; /* enum greybus_function_type */ * whole, *not* the functions within it.
}; */
struct greybus_descriptor_module { struct greybus_descriptor_module {
__le16 vendor; __le16 vendor;
__le16 product; __le16 product;
...@@ -65,26 +53,61 @@ struct greybus_descriptor_module { ...@@ -65,26 +53,61 @@ struct greybus_descriptor_module {
__u8 product_stringid; __u8 product_stringid;
}; };
/*
* A UniPro device normally supports a range of 32 CPorts (0..31).
* It is possible to support more than this by having a UniPro
* switch treat one device as if it were more than one. E.g.,
* allocate 3 device ids (rather than the normal--1) to physical
* device 5, and configure the switch to route all packets destined
* for "encoded" device ids 5, 6, and 7 to physical device 5.
* Device 5 uses the encoded device id in incoming UniPro packets to
* determine which bank of 32 CPorts should receive the UniPro
* segment.
*
* The "scale" field in this structure is used to define the number
* of encoded device ids should be allocated for this physical
* device. Scale is normally 1, to represent 32 available CPorts.
* A scale value 2 represents up to 64 CPorts; scale value 3
* represents up to 96 CPorts, and so on.
*/
struct greybus_descriptor_interface {
__u8 id; /* module-relative id (0..) */
__u8 scale; /* indicates range of of CPorts supported */
/* UniPro gear, number of in/out lanes */
};
struct greybus_descriptor_cport {
__le16 id;
__u8 function_type; /* enum greybus_function_type */
};
struct greybus_descriptor_string { struct greybus_descriptor_string {
__u8 length; __u8 length;
__u8 id; __u8 id;
__u8 string[0]; __u8 string[0];
}; };
struct greybus_descriptor_cport { struct greybus_descriptor_header {
__le16 id; __le16 size;
__u8 type; /* enum greybus_descriptor_type */
}; };
struct greybus_descriptor { struct greybus_descriptor {
struct greybus_descriptor_header header; struct greybus_descriptor_header header;
union { union {
struct greybus_descriptor_function function;
struct greybus_descriptor_module module; struct greybus_descriptor_module module;
struct greybus_descriptor_string string; struct greybus_descriptor_string string;
struct greybus_descriptor_interface interface;
struct greybus_descriptor_cport cport; struct greybus_descriptor_cport cport;
}; };
}; };
struct greybus_manifest_header {
__le16 size;
__u8 version_major;
__u8 version_minor;
};
struct greybus_manifest { struct greybus_manifest {
struct greybus_manifest_header header; struct greybus_manifest_header header;
struct greybus_descriptor descriptors[0]; struct greybus_descriptor descriptors[0];
......
...@@ -20,44 +20,6 @@ ...@@ -20,44 +20,6 @@
#include "kernel_ver.h" #include "kernel_ver.h"
/* Function fields */
#define greybus_function_attr(field) \
static ssize_t function_##field##_show(struct device *dev, \
struct device_attribute *attr, \
char *buf) \
{ \
struct greybus_module *gmod = to_greybus_module(dev); \
return sprintf(buf, "%d\n", gmod->function.field); \
} \
static DEVICE_ATTR_RO(function_##field)
greybus_function_attr(cport);
greybus_function_attr(function_type);
static struct attribute *function_attrs[] = {
&dev_attr_function_cport.attr,
&dev_attr_function_function_type.attr,
NULL,
};
static umode_t function_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
struct greybus_module *gmod = to_greybus_module(kobj_to_dev(kobj));
// FIXME - make this a dynamic structure to "know" if it really is here
// or not easier?
if (gmod->function.cport ||
gmod->function.function_type)
return a->mode;
return 0;
}
static struct attribute_group function_attr_grp = {
.attrs = function_attrs,
.is_visible = function_attrs_are_visible,
};
/* Module fields */ /* Module fields */
#define greybus_module_attr(field) \ #define greybus_module_attr(field) \
static ssize_t module_##field##_show(struct device *dev, \ static ssize_t module_##field##_show(struct device *dev, \
...@@ -147,7 +109,6 @@ static struct attribute_group module_attr_grp = { ...@@ -147,7 +109,6 @@ static struct attribute_group module_attr_grp = {
const struct attribute_group *greybus_module_groups[] = { const struct attribute_group *greybus_module_groups[] = {
&function_attr_grp,
&module_attr_grp, &module_attr_grp,
NULL, NULL,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment