blob: d135945cefe1cada6643e6d305d02ccbc524fa17 [file] [log] [blame]
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -07001/*
Viresh Kumara93db2d2015-04-01 20:32:02 +05302 * Greybus 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 *
Alex Elder4441f472015-05-22 12:59:16 -05007 * Copyright 2014-2015 Google Inc.
8 * Copyright 2014-2015 Linaro Ltd.
Alex Elder908a85d2014-09-24 05:16:16 -05009 *
Greg Kroah-Hartman9b60aa02014-10-06 20:37:53 -070010 * Released under the GPLv2 and BSD licenses.
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070011 */
12
Alex Elder1dd7f582014-09-26 20:55:32 -050013#ifndef __GREYBUS_MANIFEST_H
14#define __GREYBUS_MANIFEST_H
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070015
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070016enum greybus_descriptor_type {
Alex Elder72b0ffc2014-09-26 20:55:33 -050017 GREYBUS_TYPE_INVALID = 0x00,
Viresh Kumar83a0cb52015-04-01 20:31:59 +053018 GREYBUS_TYPE_INTERFACE = 0x01,
Alex Elder63cc9322014-10-02 12:30:02 -050019 GREYBUS_TYPE_STRING = 0x02,
Viresh Kumar83a0cb52015-04-01 20:31:59 +053020 GREYBUS_TYPE_BUNDLE = 0x03,
Alex Elder63cc9322014-10-02 12:30:02 -050021 GREYBUS_TYPE_CPORT = 0x04,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070022};
23
Alex Elder63cc9322014-10-02 12:30:02 -050024enum greybus_protocol {
25 GREYBUS_PROTOCOL_CONTROL = 0x00,
Johan Hovold9230e292016-03-08 16:50:43 +010026 /* 0x01 is unused */
Alex Elder63cc9322014-10-02 12:30:02 -050027 GREYBUS_PROTOCOL_GPIO = 0x02,
28 GREYBUS_PROTOCOL_I2C = 0x03,
29 GREYBUS_PROTOCOL_UART = 0x04,
30 GREYBUS_PROTOCOL_HID = 0x05,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080031 GREYBUS_PROTOCOL_USB = 0x06,
32 GREYBUS_PROTOCOL_SDIO = 0x07,
Rui Miguel Silva2724be02015-11-12 15:36:00 +000033 GREYBUS_PROTOCOL_POWER_SUPPLY = 0x08,
Matt Porter34c65072014-11-13 09:14:13 -050034 GREYBUS_PROTOCOL_PWM = 0x09,
Mark Greer357499d2015-11-04 09:47:22 -070035 /* 0x0a is unused */
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080036 GREYBUS_PROTOCOL_SPI = 0x0b,
37 GREYBUS_PROTOCOL_DISPLAY = 0x0c,
Laurent Pincharte61a2a72015-12-15 03:18:05 +020038 GREYBUS_PROTOCOL_CAMERA_MGMT = 0x0d,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080039 GREYBUS_PROTOCOL_SENSOR = 0x0e,
Rui Miguel Silva563e6b92015-05-11 19:22:03 +010040 GREYBUS_PROTOCOL_LIGHTS = 0x0f,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080041 GREYBUS_PROTOCOL_VIBRATOR = 0x10,
Alexandre Bailon355a7052015-03-31 09:51:59 +020042 GREYBUS_PROTOCOL_LOOPBACK = 0x11,
Mark Greer80ee8422015-11-13 14:44:13 -070043 GREYBUS_PROTOCOL_AUDIO_MGMT = 0x12,
44 GREYBUS_PROTOCOL_AUDIO_DATA = 0x13,
Alex Elder30c6d9d2015-05-22 13:02:08 -050045 GREYBUS_PROTOCOL_SVC = 0x14,
Viresh Kumar5a53e022016-04-03 12:18:35 +053046 GREYBUS_PROTOCOL_BOOTROM = 0x15,
Laurent Pincharte61a2a72015-12-15 03:18:05 +020047 GREYBUS_PROTOCOL_CAMERA_DATA = 0x16,
Viresh Kumar9e04fb72016-04-26 10:20:49 +053048 GREYBUS_PROTOCOL_FW_DOWNLOAD = 0x17,
49 GREYBUS_PROTOCOL_FW_MANAGEMENT = 0x18,
Viresh Kumare3eda542016-06-30 10:54:00 -050050 GREYBUS_PROTOCOL_AUTHENTICATION = 0x19,
Joel Porquetc0e65d02016-06-24 14:41:36 -070051 GREYBUS_PROTOCOL_LOG = 0x1a,
Alex Elder63cc9322014-10-02 12:30:02 -050052 /* ... */
Greg Kroah-Hartmane806c7f2015-05-08 15:50:17 +020053 GREYBUS_PROTOCOL_RAW = 0xfe,
Alex Elder63cc9322014-10-02 12:30:02 -050054 GREYBUS_PROTOCOL_VENDOR = 0xff,
55};
56
57enum greybus_class_type {
Alex Elder063e6ec2014-10-03 14:14:23 -050058 GREYBUS_CLASS_CONTROL = 0x00,
Johan Hovold9230e292016-03-08 16:50:43 +010059 /* 0x01 is unused */
Viresh Kumardc075402016-05-10 08:50:13 +053060 /* 0x02 is unused */
61 /* 0x03 is unused */
62 /* 0x04 is unused */
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080063 GREYBUS_CLASS_HID = 0x05,
Viresh Kumardc075402016-05-10 08:50:13 +053064 /* 0x06 is unused */
65 /* 0x07 is unused */
Rui Miguel Silva2724be02015-11-12 15:36:00 +000066 GREYBUS_CLASS_POWER_SUPPLY = 0x08,
Viresh Kumardc075402016-05-10 08:50:13 +053067 /* 0x09 is unused */
Greg Kroah-Hartmand6fefbe2016-02-28 14:13:27 -080068 GREYBUS_CLASS_BRIDGED_PHY = 0x0a,
Viresh Kumardc075402016-05-10 08:50:13 +053069 /* 0x0b is unused */
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080070 GREYBUS_CLASS_DISPLAY = 0x0c,
71 GREYBUS_CLASS_CAMERA = 0x0d,
72 GREYBUS_CLASS_SENSOR = 0x0e,
Viresh Kumardccbe402015-06-30 11:40:18 +053073 GREYBUS_CLASS_LIGHTS = 0x0f,
74 GREYBUS_CLASS_VIBRATOR = 0x10,
75 GREYBUS_CLASS_LOOPBACK = 0x11,
Viresh Kumar3b710ec2016-01-27 11:17:00 +053076 GREYBUS_CLASS_AUDIO = 0x12,
77 /* 0x13 is unused */
Johan Hovolda23aa562016-03-09 16:13:55 +010078 /* 0x14 is unused */
Viresh Kumar5a53e022016-04-03 12:18:35 +053079 GREYBUS_CLASS_BOOTROM = 0x15,
Viresh Kumar9e04fb72016-04-26 10:20:49 +053080 GREYBUS_CLASS_FW_MANAGEMENT = 0x16,
Joel Porquetc0e65d02016-06-24 14:41:36 -070081 GREYBUS_CLASS_LOG = 0x17,
Viresh Kumar948b3bd52015-07-21 17:44:10 +053082 /* ... */
83 GREYBUS_CLASS_RAW = 0xfe,
Alex Elder063e6ec2014-10-03 14:14:23 -050084 GREYBUS_CLASS_VENDOR = 0xff,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070085};
86
Bryan O'Donoghue8c81d462016-05-15 19:37:49 +010087enum {
88 GREYBUS_INTERFACE_FEATURE_TIMESYNC = BIT(0),
89};
90
Alex Elderecf7d572014-10-01 21:54:10 -050091/*
Alex Elder63cc9322014-10-02 12:30:02 -050092 * The string in a string descriptor is not NUL-terminated. The
93 * size of the descriptor will be rounded up to a multiple of 4
94 * bytes, by padding the string with 0x00 bytes if necessary.
Alex Elderecf7d572014-10-01 21:54:10 -050095 */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070096struct greybus_descriptor_string {
Matt Portercbd0fd72014-09-26 20:49:51 -050097 __u8 length;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070098 __u8 id;
99 __u8 string[0];
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530100} __packed;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700101
Alex Elder63cc9322014-10-02 12:30:02 -0500102/*
Viresh Kumara93db2d2015-04-01 20:32:02 +0530103 * An interface descriptor describes information about an interface as a whole,
104 * *not* the functions within it.
Alex Elder63cc9322014-10-02 12:30:02 -0500105 */
106struct greybus_descriptor_interface {
Viresh Kumara93db2d2015-04-01 20:32:02 +0530107 __u8 vendor_stringid;
108 __u8 product_stringid;
Bryan O'Donoghue8c81d462016-05-15 19:37:49 +0100109 __u8 features;
110 __u8 pad;
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530111} __packed;
Alex Elder63cc9322014-10-02 12:30:02 -0500112
113/*
Viresh Kumar88e6d372015-04-06 15:49:36 +0530114 * An bundle descriptor defines an identification number and a class for
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530115 * each bundle.
116 *
117 * @id: Uniquely identifies a bundle within a interface, its sole purpose is to
118 * allow CPort descriptors to specify which bundle they are associated with.
119 * The first bundle will have id 0, second will have 1 and so on.
120 *
121 * The largest CPort id associated with an bundle (defined by a
122 * CPort descriptor in the manifest) is used to determine how to
123 * encode the device id and module number in UniPro packets
124 * that use the bundle.
125 *
Viresh Kumar88e6d372015-04-06 15:49:36 +0530126 * @class: It is used by kernel to know the functionality provided by the
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530127 * bundle and will be matched against drivers functinality while probing greybus
128 * driver. It should contain one of the values defined in
129 * 'enum greybus_class_type'.
130 *
131 */
132struct greybus_descriptor_bundle {
133 __u8 id; /* interface-relative id (0..) */
Viresh Kumar88e6d372015-04-06 15:49:36 +0530134 __u8 class;
Viresh Kumar499ee952015-04-28 19:51:40 +0530135 __u8 pad[2];
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530136} __packed;
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530137
138/*
Greg Kroah-Hartman1db0a5f2014-12-12 17:10:17 -0500139 * A CPort descriptor indicates the id of the bundle within the
Alex Elder63cc9322014-10-02 12:30:02 -0500140 * module it's associated with, along with the CPort id used to
Alex Elder7fba0072014-10-28 19:35:59 -0500141 * address the CPort. The protocol id defines the format of messages
Alex Elder63cc9322014-10-02 12:30:02 -0500142 * exchanged using the CPort.
143 */
144struct greybus_descriptor_cport {
Alex Elder63cc9322014-10-02 12:30:02 -0500145 __le16 id;
Viresh Kumarf03eec82015-04-28 19:51:41 +0530146 __u8 bundle;
Alex Elder7fba0072014-10-28 19:35:59 -0500147 __u8 protocol_id; /* enum greybus_protocol */
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530148} __packed;
Alex Elder63cc9322014-10-02 12:30:02 -0500149
Alex Elderecf7d572014-10-01 21:54:10 -0500150struct greybus_descriptor_header {
151 __le16 size;
Alex Elder63cc9322014-10-02 12:30:02 -0500152 __u8 type; /* enum greybus_descriptor_type */
Viresh Kumar499ee952015-04-28 19:51:40 +0530153 __u8 pad;
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530154} __packed;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700155
Greg Kroah-Hartman6dca7b92014-09-01 13:42:43 -0700156struct greybus_descriptor {
Alex Elder63cc9322014-10-02 12:30:02 -0500157 struct greybus_descriptor_header header;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700158 union {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700159 struct greybus_descriptor_string string;
Alex Elderecf7d572014-10-01 21:54:10 -0500160 struct greybus_descriptor_interface interface;
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530161 struct greybus_descriptor_bundle bundle;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700162 struct greybus_descriptor_cport cport;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700163 };
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530164} __packed;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700165
Alex Elderecf7d572014-10-01 21:54:10 -0500166struct greybus_manifest_header {
167 __le16 size;
168 __u8 version_major;
169 __u8 version_minor;
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530170} __packed;
Alex Elderecf7d572014-10-01 21:54:10 -0500171
Alex Elderbadad682014-09-09 13:55:04 -0500172struct greybus_manifest {
173 struct greybus_manifest_header header;
174 struct greybus_descriptor descriptors[0];
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530175} __packed;
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700176
Alex Elder1dd7f582014-09-26 20:55:32 -0500177#endif /* __GREYBUS_MANIFEST_H */