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,
struct greybus_descriptor_module *module,
size_t desc_size)
data_size = (size_t)desc_size - sizeof(desc->header);
switch (le16_to_cpu(desc->header.type)) {
- case GREYBUS_TYPE_FUNCTION:
- retval = create_function(gmod, &desc->function,
- data_size);
+ case GREYBUS_TYPE_DEVICE:
break;
case GREYBUS_TYPE_MODULE:
struct greybus_module {
struct device dev;
u16 module_number;
- struct greybus_descriptor_function function;
struct greybus_descriptor_module module;
int num_cports;
int num_strings;
};
#define to_greybus_module(d) container_of(d, struct greybus_module, dev)
-struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod,
- u16 cport_id,
- gbuf_complete_t complete,
- unsigned int size,
- gfp_t gfp_mask,
- void *context);
+struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod, u16 cport_id,
+ gbuf_complete_t complete, unsigned int size,
+ gfp_t gfp_mask, void *context);
void greybus_free_gbuf(struct gbuf *gbuf);
struct gbuf *greybus_get_gbuf(struct gbuf *gbuf);
#define greybus_put_gbuf greybus_free_gbuf
#pragma pack(push, 1)
-struct greybus_manifest_header {
- __le16 size;
- __u8 version_major;
- __u8 version_minor;
-};
-
enum greybus_descriptor_type {
GREYBUS_TYPE_INVALID = 0x00,
GREYBUS_TYPE_MODULE = 0x01,
- GREYBUS_TYPE_FUNCTION = 0x02,
+ GREYBUS_TYPE_DEVICE = 0x02,
GREYBUS_TYPE_CLASS = 0x03,
GREYBUS_TYPE_STRING = 0x04,
GREYBUS_TYPE_CPORT = 0x05,
};
-struct greybus_descriptor_header {
- __le16 size;
- __u8 type; /* enum greybus_descriptor_type */
-};
-
enum greybus_function_type {
GREYBUS_FUNCTION_CONTROL = 0x00,
GREYBUS_FUNCTION_USB = 0x01,
GREYBUS_FUNCTION_VENDOR = 0xff,
};
-struct greybus_descriptor_function {
- __le16 cport;
- __u8 function_type; /* enum greybus_function_type */
-};
-
+/*
+ * A module descriptor describes information about a module as a
+ * whole, *not* the functions within it.
+ */
struct greybus_descriptor_module {
__le16 vendor;
__le16 product;
__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 {
__u8 length;
__u8 id;
__u8 string[0];
};
-struct greybus_descriptor_cport {
- __le16 id;
+struct greybus_descriptor_header {
+ __le16 size;
+ __u8 type; /* enum greybus_descriptor_type */
};
struct greybus_descriptor {
struct greybus_descriptor_header header;
union {
- struct greybus_descriptor_function function;
struct greybus_descriptor_module module;
struct greybus_descriptor_string string;
+ struct greybus_descriptor_interface interface;
struct greybus_descriptor_cport cport;
};
};
+struct greybus_manifest_header {
+ __le16 size;
+ __u8 version_major;
+ __u8 version_minor;
+};
+
struct greybus_manifest {
struct greybus_manifest_header header;
struct greybus_descriptor descriptors[0];
#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 */
#define greybus_module_attr(field) \
static ssize_t module_##field##_show(struct device *dev, \
const struct attribute_group *greybus_module_groups[] = {
- &function_attr_grp,
&module_attr_grp,
NULL,
};