blob: 90965766dceb4aaa5356574805e263e0e4297c2b [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 *
7 * Copyright 2014 Google Inc.
Alex Eldera46e9672014-12-12 12:08:42 -06008 * Copyright 2014 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,
22 GREYBUS_TYPE_CLASS = 0x05,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070023};
24
Alex Elder63cc9322014-10-02 12:30:02 -050025enum greybus_protocol {
26 GREYBUS_PROTOCOL_CONTROL = 0x00,
27 GREYBUS_PROTOCOL_AP = 0x01,
28 GREYBUS_PROTOCOL_GPIO = 0x02,
29 GREYBUS_PROTOCOL_I2C = 0x03,
30 GREYBUS_PROTOCOL_UART = 0x04,
31 GREYBUS_PROTOCOL_HID = 0x05,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080032 GREYBUS_PROTOCOL_USB = 0x06,
33 GREYBUS_PROTOCOL_SDIO = 0x07,
Greg Kroah-Hartman2bb7eae2014-10-20 15:24:57 +080034 GREYBUS_PROTOCOL_BATTERY = 0x08,
Matt Porter34c65072014-11-13 09:14:13 -050035 GREYBUS_PROTOCOL_PWM = 0x09,
Mark Greer045235f2015-03-31 16:49:56 -070036 GREYBUS_PROTOCOL_I2S_MGMT = 0x0a,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080037 GREYBUS_PROTOCOL_SPI = 0x0b,
38 GREYBUS_PROTOCOL_DISPLAY = 0x0c,
39 GREYBUS_PROTOCOL_CAMERA = 0x0d,
40 GREYBUS_PROTOCOL_SENSOR = 0x0e,
41 GREYBUS_PROTOCOL_LED = 0x0f,
42 GREYBUS_PROTOCOL_VIBRATOR = 0x10,
Alexandre Bailon355a7052015-03-31 09:51:59 +020043 GREYBUS_PROTOCOL_LOOPBACK = 0x11,
Mark Greer045235f2015-03-31 16:49:56 -070044 GREYBUS_PROTOCOL_I2S_RECEIVER = 0x12,
45 GREYBUS_PROTOCOL_I2S_TRANSMITTER = 0x13,
Alex Elder63cc9322014-10-02 12:30:02 -050046 /* ... */
47 GREYBUS_PROTOCOL_VENDOR = 0xff,
48};
49
50enum greybus_class_type {
Alex Elder063e6ec2014-10-03 14:14:23 -050051 GREYBUS_CLASS_CONTROL = 0x00,
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080052 GREYBUS_CLASS_AP = 0x01,
Alex Elder063e6ec2014-10-03 14:14:23 -050053 GREYBUS_CLASS_GPIO = 0x02,
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080054 GREYBUS_CLASS_I2C = 0x03,
Alex Elder063e6ec2014-10-03 14:14:23 -050055 GREYBUS_CLASS_UART = 0x04,
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080056 GREYBUS_CLASS_HID = 0x05,
57 GREYBUS_CLASS_USB = 0x06,
58 GREYBUS_CLASS_SDIO = 0x07,
59 GREYBUS_CLASS_BATTERY = 0x08,
60 GREYBUS_CLASS_PWM = 0x09,
61 GREYBUS_CLASS_I2S = 0x0a,
62 GREYBUS_CLASS_SPI = 0x0b,
63 GREYBUS_CLASS_DISPLAY = 0x0c,
64 GREYBUS_CLASS_CAMERA = 0x0d,
65 GREYBUS_CLASS_SENSOR = 0x0e,
Alex Elder063e6ec2014-10-03 14:14:23 -050066 GREYBUS_CLASS_VENDOR = 0xff,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070067};
68
Alex Elderecf7d572014-10-01 21:54:10 -050069/*
Alex Elder63cc9322014-10-02 12:30:02 -050070 * The string in a string descriptor is not NUL-terminated. The
71 * size of the descriptor will be rounded up to a multiple of 4
72 * bytes, by padding the string with 0x00 bytes if necessary.
Alex Elderecf7d572014-10-01 21:54:10 -050073 */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070074struct greybus_descriptor_string {
Matt Portercbd0fd72014-09-26 20:49:51 -050075 __u8 length;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070076 __u8 id;
77 __u8 string[0];
Viresh Kumaraf6e8b42015-04-28 19:51:34 +053078} __packed;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070079
Alex Elder63cc9322014-10-02 12:30:02 -050080/*
Viresh Kumara93db2d2015-04-01 20:32:02 +053081 * An interface descriptor describes information about an interface as a whole,
82 * *not* the functions within it.
Alex Elder63cc9322014-10-02 12:30:02 -050083 */
84struct greybus_descriptor_interface {
Viresh Kumara93db2d2015-04-01 20:32:02 +053085 __le16 vendor;
86 __le16 product;
87 __le16 version; // TODO - remove after Dec demo.
88 __u8 vendor_stringid;
89 __u8 product_stringid;
90 __le64 unique_id;
Viresh Kumaraf6e8b42015-04-28 19:51:34 +053091} __packed;
Alex Elder63cc9322014-10-02 12:30:02 -050092
93/*
Viresh Kumar88e6d372015-04-06 15:49:36 +053094 * An bundle descriptor defines an identification number and a class for
Viresh Kumar83a0cb52015-04-01 20:31:59 +053095 * each bundle.
96 *
97 * @id: Uniquely identifies a bundle within a interface, its sole purpose is to
98 * allow CPort descriptors to specify which bundle they are associated with.
99 * The first bundle will have id 0, second will have 1 and so on.
100 *
101 * The largest CPort id associated with an bundle (defined by a
102 * CPort descriptor in the manifest) is used to determine how to
103 * encode the device id and module number in UniPro packets
104 * that use the bundle.
105 *
Viresh Kumar88e6d372015-04-06 15:49:36 +0530106 * @class: It is used by kernel to know the functionality provided by the
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530107 * bundle and will be matched against drivers functinality while probing greybus
108 * driver. It should contain one of the values defined in
109 * 'enum greybus_class_type'.
110 *
111 */
112struct greybus_descriptor_bundle {
113 __u8 id; /* interface-relative id (0..) */
Viresh Kumar88e6d372015-04-06 15:49:36 +0530114 __u8 class;
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530115} __packed;
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530116
117/*
Greg Kroah-Hartman1db0a5f2014-12-12 17:10:17 -0500118 * A CPort descriptor indicates the id of the bundle within the
Alex Elder63cc9322014-10-02 12:30:02 -0500119 * module it's associated with, along with the CPort id used to
Alex Elder7fba0072014-10-28 19:35:59 -0500120 * address the CPort. The protocol id defines the format of messages
Alex Elder63cc9322014-10-02 12:30:02 -0500121 * exchanged using the CPort.
122 */
123struct greybus_descriptor_cport {
Greg Kroah-Hartman1db0a5f2014-12-12 17:10:17 -0500124 __u8 bundle;
Alex Elder63cc9322014-10-02 12:30:02 -0500125 __le16 id;
Alex Elder7fba0072014-10-28 19:35:59 -0500126 __u8 protocol_id; /* enum greybus_protocol */
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530127} __packed;
Alex Elder63cc9322014-10-02 12:30:02 -0500128
129/*
130 * A class descriptor defines functionality supplied by a module.
131 * Beyond that, not much else is defined yet...
132 */
133struct greybus_descriptor_class {
134 __u8 class; /* enum greybus_class_type */
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530135} __packed;
Alex Elder63cc9322014-10-02 12:30:02 -0500136
Alex Elderecf7d572014-10-01 21:54:10 -0500137struct greybus_descriptor_header {
138 __le16 size;
Alex Elder63cc9322014-10-02 12:30:02 -0500139 __u8 type; /* enum greybus_descriptor_type */
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530140} __packed;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700141
Greg Kroah-Hartman6dca7b92014-09-01 13:42:43 -0700142struct greybus_descriptor {
Alex Elder63cc9322014-10-02 12:30:02 -0500143 struct greybus_descriptor_header header;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700144 union {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700145 struct greybus_descriptor_string string;
Alex Elderecf7d572014-10-01 21:54:10 -0500146 struct greybus_descriptor_interface interface;
Viresh Kumar83a0cb52015-04-01 20:31:59 +0530147 struct greybus_descriptor_bundle bundle;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700148 struct greybus_descriptor_cport cport;
Alex Elder63cc9322014-10-02 12:30:02 -0500149 struct greybus_descriptor_class class;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700150 };
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530151} __packed;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700152
Alex Elderecf7d572014-10-01 21:54:10 -0500153struct greybus_manifest_header {
154 __le16 size;
155 __u8 version_major;
156 __u8 version_minor;
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530157} __packed;
Alex Elderecf7d572014-10-01 21:54:10 -0500158
Alex Elderbadad682014-09-09 13:55:04 -0500159struct greybus_manifest {
160 struct greybus_manifest_header header;
161 struct greybus_descriptor descriptors[0];
Viresh Kumaraf6e8b42015-04-28 19:51:34 +0530162} __packed;
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700163
Alex Elder1dd7f582014-09-26 20:55:32 -0500164#endif /* __GREYBUS_MANIFEST_H */