blob: 4b2cf9220843f2a18bdcf2c3538e20114c32b70a [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 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-Hartman48123e02014-09-02 10:51:56 -070016#pragma pack(push, 1)
17
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070018enum greybus_descriptor_type {
Alex Elder72b0ffc2014-09-26 20:55:33 -050019 GREYBUS_TYPE_INVALID = 0x00,
20 GREYBUS_TYPE_MODULE = 0x01,
Alex Elder63cc9322014-10-02 12:30:02 -050021 GREYBUS_TYPE_STRING = 0x02,
22 GREYBUS_TYPE_INTERFACE = 0x03,
23 GREYBUS_TYPE_CPORT = 0x04,
24 GREYBUS_TYPE_CLASS = 0x05,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070025};
26
Alex Elder63cc9322014-10-02 12:30:02 -050027enum greybus_protocol {
28 GREYBUS_PROTOCOL_CONTROL = 0x00,
29 GREYBUS_PROTOCOL_AP = 0x01,
30 GREYBUS_PROTOCOL_GPIO = 0x02,
31 GREYBUS_PROTOCOL_I2C = 0x03,
32 GREYBUS_PROTOCOL_UART = 0x04,
33 GREYBUS_PROTOCOL_HID = 0x05,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080034 GREYBUS_PROTOCOL_USB = 0x06,
35 GREYBUS_PROTOCOL_SDIO = 0x07,
Greg Kroah-Hartman2bb7eae2014-10-20 15:24:57 +080036 GREYBUS_PROTOCOL_BATTERY = 0x08,
Matt Porter34c65072014-11-13 09:14:13 -050037 GREYBUS_PROTOCOL_PWM = 0x09,
Greg Kroah-Hartman68190672014-11-17 15:19:14 -080038 GREYBUS_PROTOCOL_I2S = 0x0a,
39 GREYBUS_PROTOCOL_SPI = 0x0b,
40 GREYBUS_PROTOCOL_DISPLAY = 0x0c,
41 GREYBUS_PROTOCOL_CAMERA = 0x0d,
42 GREYBUS_PROTOCOL_SENSOR = 0x0e,
43 GREYBUS_PROTOCOL_LED = 0x0f,
44 GREYBUS_PROTOCOL_VIBRATOR = 0x10,
Alexandre Bailon355a7052015-03-31 09:51:59 +020045 GREYBUS_PROTOCOL_LOOPBACK = 0x11,
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/*
70 * A module descriptor describes information about a module as a
71 * whole, *not* the functions within it.
72 */
Matt Porter6d63ff72014-09-26 20:49:48 -050073struct greybus_descriptor_module {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070074 __le16 vendor;
75 __le16 product;
Greg Kroah-Hartman5f474d42014-12-09 14:57:04 -050076 __le16 version; // TODO - remove after Dec demo.
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070077 __u8 vendor_stringid;
78 __u8 product_stringid;
Alex Elder63cc9322014-10-02 12:30:02 -050079 __le64 unique_id;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070080};
81
Alex Elderecf7d572014-10-01 21:54:10 -050082/*
Alex Elder63cc9322014-10-02 12:30:02 -050083 * The string in a string descriptor is not NUL-terminated. The
84 * size of the descriptor will be rounded up to a multiple of 4
85 * bytes, by padding the string with 0x00 bytes if necessary.
Alex Elderecf7d572014-10-01 21:54:10 -050086 */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070087struct greybus_descriptor_string {
Matt Portercbd0fd72014-09-26 20:49:51 -050088 __u8 length;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070089 __u8 id;
90 __u8 string[0];
91};
92
Alex Elder63cc9322014-10-02 12:30:02 -050093/*
94 * An interface descriptor simply defines a module-unique id for
95 * each interface present on a module. Its sole purpose is to allow
96 * CPort descriptors to specify which interface they are associated
97 * with. Normally there's only one interface, with id 0. The
98 * second one must have id 1, and so on consecutively.
99 *
100 * The largest CPort id associated with an interface (defined by a
101 * CPort descriptor in the manifest) is used to determine how to
102 * encode the device id and module number in UniPro packets
103 * that use the interface.
104 */
105struct greybus_descriptor_interface {
106 __u8 id; /* module-relative id (0..) */
107};
108
109/*
Greg Kroah-Hartman1db0a5f2014-12-12 17:10:17 -0500110 * A CPort descriptor indicates the id of the bundle within the
Alex Elder63cc9322014-10-02 12:30:02 -0500111 * module it's associated with, along with the CPort id used to
Alex Elder7fba0072014-10-28 19:35:59 -0500112 * address the CPort. The protocol id defines the format of messages
Alex Elder63cc9322014-10-02 12:30:02 -0500113 * exchanged using the CPort.
114 */
115struct greybus_descriptor_cport {
Greg Kroah-Hartman1db0a5f2014-12-12 17:10:17 -0500116 __u8 bundle;
Alex Elder63cc9322014-10-02 12:30:02 -0500117 __le16 id;
Alex Elder7fba0072014-10-28 19:35:59 -0500118 __u8 protocol_id; /* enum greybus_protocol */
Alex Elder63cc9322014-10-02 12:30:02 -0500119};
120
121/*
122 * A class descriptor defines functionality supplied by a module.
123 * Beyond that, not much else is defined yet...
124 */
125struct greybus_descriptor_class {
126 __u8 class; /* enum greybus_class_type */
127};
128
Alex Elderecf7d572014-10-01 21:54:10 -0500129struct greybus_descriptor_header {
130 __le16 size;
Alex Elder63cc9322014-10-02 12:30:02 -0500131 __u8 type; /* enum greybus_descriptor_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700132};
133
Greg Kroah-Hartman6dca7b92014-09-01 13:42:43 -0700134struct greybus_descriptor {
Alex Elder63cc9322014-10-02 12:30:02 -0500135 struct greybus_descriptor_header header;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700136 union {
Matt Porter6d63ff72014-09-26 20:49:48 -0500137 struct greybus_descriptor_module module;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700138 struct greybus_descriptor_string string;
Alex Elderecf7d572014-10-01 21:54:10 -0500139 struct greybus_descriptor_interface interface;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700140 struct greybus_descriptor_cport cport;
Alex Elder63cc9322014-10-02 12:30:02 -0500141 struct greybus_descriptor_class class;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700142 };
143};
144
Alex Elderecf7d572014-10-01 21:54:10 -0500145struct greybus_manifest_header {
146 __le16 size;
147 __u8 version_major;
148 __u8 version_minor;
149};
150
Alex Elderbadad682014-09-09 13:55:04 -0500151struct greybus_manifest {
152 struct greybus_manifest_header header;
153 struct greybus_descriptor descriptors[0];
154};
155
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700156#pragma pack(pop)
157
Alex Elder1dd7f582014-09-26 20:55:32 -0500158#endif /* __GREYBUS_MANIFEST_H */