blob: 61189995f7d90f19d18d15076eaecf894456f61d [file] [log] [blame]
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -07001/*
Alex Elder908a85d2014-09-24 05:16:16 -05002 * Greybus module manifest definition
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -07003 *
Alex Eldercb705e02014-09-24 05:16:17 -05004 * See "Greybus Application Protocol" document (version 0.1) for
Alex Elder908a85d2014-09-24 05:16:16 -05005 * details on these values and structures.
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -07006 *
7 * Copyright 2014 Google Inc.
Alex Elder908a85d2014-09-24 05:16:16 -05008 *
9 * Released under the GPLv2 only.
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070010 */
11
Alex Elder1dd7f582014-09-26 20:55:32 -050012#ifndef __GREYBUS_MANIFEST_H
13#define __GREYBUS_MANIFEST_H
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070014
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -070015#pragma pack(push, 1)
16
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070017enum greybus_descriptor_type {
Alex Elder72b0ffc2014-09-26 20:55:33 -050018 GREYBUS_TYPE_INVALID = 0x00,
19 GREYBUS_TYPE_MODULE = 0x01,
Alex Elderecf7d572014-10-01 21:54:10 -050020 GREYBUS_TYPE_DEVICE = 0x02,
Alex Elder72b0ffc2014-09-26 20:55:33 -050021 GREYBUS_TYPE_CLASS = 0x03,
22 GREYBUS_TYPE_STRING = 0x04,
23 GREYBUS_TYPE_CPORT = 0x05,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070024};
25
Matt Porter097724c2014-09-26 20:49:50 -050026enum greybus_function_type {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070027 GREYBUS_FUNCTION_CONTROL = 0x00,
28 GREYBUS_FUNCTION_USB = 0x01,
29 GREYBUS_FUNCTION_GPIO = 0x02,
30 GREYBUS_FUNCTION_SPI = 0x03,
31 GREYBUS_FUNCTION_UART = 0x04,
32 GREYBUS_FUNCTION_PWM = 0x05,
33 GREYBUS_FUNCTION_I2S = 0x06,
34 GREYBUS_FUNCTION_I2C = 0x07,
35 GREYBUS_FUNCTION_SDIO = 0x08,
36 GREYBUS_FUNCTION_HID = 0x09,
37 GREYBUS_FUNCTION_DISPLAY = 0x0a,
38 GREYBUS_FUNCTION_CAMERA = 0x0b,
39 GREYBUS_FUNCTION_SENSOR = 0x0c,
40 GREYBUS_FUNCTION_VENDOR = 0xff,
41};
42
Alex Elderecf7d572014-10-01 21:54:10 -050043/*
44 * A module descriptor describes information about a module as a
45 * whole, *not* the functions within it.
46 */
Matt Porter6d63ff72014-09-26 20:49:48 -050047struct greybus_descriptor_module {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070048 __le16 vendor;
49 __le16 product;
50 __le16 version;
Matt Porter4fc64542014-09-26 20:49:49 -050051 __le64 serial_number;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070052 __u8 vendor_stringid;
53 __u8 product_stringid;
54};
55
Alex Elderecf7d572014-10-01 21:54:10 -050056/*
57 * A UniPro device normally supports a range of 32 CPorts (0..31).
58 * It is possible to support more than this by having a UniPro
59 * switch treat one device as if it were more than one. E.g.,
60 * allocate 3 device ids (rather than the normal--1) to physical
61 * device 5, and configure the switch to route all packets destined
62 * for "encoded" device ids 5, 6, and 7 to physical device 5.
63 * Device 5 uses the encoded device id in incoming UniPro packets to
64 * determine which bank of 32 CPorts should receive the UniPro
65 * segment.
66 *
67 * The "scale" field in this structure is used to define the number
68 * of encoded device ids should be allocated for this physical
69 * device. Scale is normally 1, to represent 32 available CPorts.
70 * A scale value 2 represents up to 64 CPorts; scale value 3
71 * represents up to 96 CPorts, and so on.
72 */
73struct greybus_descriptor_interface {
74 __u8 id; /* module-relative id (0..) */
75 __u8 scale; /* indicates range of of CPorts supported */
76 /* UniPro gear, number of in/out lanes */
77};
78
79struct greybus_descriptor_cport {
80 __le16 id;
81 __u8 function_type; /* enum greybus_function_type */
82};
83
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070084struct greybus_descriptor_string {
Matt Portercbd0fd72014-09-26 20:49:51 -050085 __u8 length;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070086 __u8 id;
87 __u8 string[0];
88};
89
Alex Elderecf7d572014-10-01 21:54:10 -050090struct greybus_descriptor_header {
91 __le16 size;
92 __u8 type; /* enum greybus_descriptor_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070093};
94
Greg Kroah-Hartman6dca7b92014-09-01 13:42:43 -070095struct greybus_descriptor {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070096 struct greybus_descriptor_header header;
97 union {
Matt Porter6d63ff72014-09-26 20:49:48 -050098 struct greybus_descriptor_module module;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070099 struct greybus_descriptor_string string;
Alex Elderecf7d572014-10-01 21:54:10 -0500100 struct greybus_descriptor_interface interface;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700101 struct greybus_descriptor_cport cport;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700102 };
103};
104
Alex Elderecf7d572014-10-01 21:54:10 -0500105struct greybus_manifest_header {
106 __le16 size;
107 __u8 version_major;
108 __u8 version_minor;
109};
110
Alex Elderbadad682014-09-09 13:55:04 -0500111struct greybus_manifest {
112 struct greybus_manifest_header header;
113 struct greybus_descriptor descriptors[0];
114};
115
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700116#pragma pack(pop)
117
Alex Elder1dd7f582014-09-26 20:55:32 -0500118#endif /* __GREYBUS_MANIFEST_H */