blob: c6988ce2818a88f18286642e2e3c29e4c8f2a477 [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 *
Greg Kroah-Hartman9b60aa02014-10-06 20:37:53 -07009 * Released under the GPLv2 and BSD licenses.
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 Elder63cc9322014-10-02 12:30:02 -050020 GREYBUS_TYPE_STRING = 0x02,
21 GREYBUS_TYPE_INTERFACE = 0x03,
22 GREYBUS_TYPE_CPORT = 0x04,
23 GREYBUS_TYPE_CLASS = 0x05,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070024};
25
Alex Elder63cc9322014-10-02 12:30:02 -050026enum greybus_protocol {
27 GREYBUS_PROTOCOL_CONTROL = 0x00,
28 GREYBUS_PROTOCOL_AP = 0x01,
29 GREYBUS_PROTOCOL_GPIO = 0x02,
30 GREYBUS_PROTOCOL_I2C = 0x03,
31 GREYBUS_PROTOCOL_UART = 0x04,
32 GREYBUS_PROTOCOL_HID = 0x05,
Greg Kroah-Hartman2bb7eae2014-10-20 15:24:57 +080033 GREYBUS_PROTOCOL_BATTERY = 0x08,
Greg Kroah-Hartman42d4a222014-10-20 16:02:56 +080034 GREYBUS_PROTOCOL_LED = 0x0e,
Alex Elder63cc9322014-10-02 12:30:02 -050035 /* ... */
36 GREYBUS_PROTOCOL_VENDOR = 0xff,
37};
38
39enum greybus_class_type {
Alex Elder063e6ec2014-10-03 14:14:23 -050040 GREYBUS_CLASS_CONTROL = 0x00,
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080041 GREYBUS_CLASS_AP = 0x01,
Alex Elder063e6ec2014-10-03 14:14:23 -050042 GREYBUS_CLASS_GPIO = 0x02,
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080043 GREYBUS_CLASS_I2C = 0x03,
Alex Elder063e6ec2014-10-03 14:14:23 -050044 GREYBUS_CLASS_UART = 0x04,
Greg Kroah-Hartman6ce3e032014-10-20 13:27:42 +080045 GREYBUS_CLASS_HID = 0x05,
46 GREYBUS_CLASS_USB = 0x06,
47 GREYBUS_CLASS_SDIO = 0x07,
48 GREYBUS_CLASS_BATTERY = 0x08,
49 GREYBUS_CLASS_PWM = 0x09,
50 GREYBUS_CLASS_I2S = 0x0a,
51 GREYBUS_CLASS_SPI = 0x0b,
52 GREYBUS_CLASS_DISPLAY = 0x0c,
53 GREYBUS_CLASS_CAMERA = 0x0d,
54 GREYBUS_CLASS_SENSOR = 0x0e,
Alex Elder063e6ec2014-10-03 14:14:23 -050055 GREYBUS_CLASS_VENDOR = 0xff,
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070056};
57
Alex Elderecf7d572014-10-01 21:54:10 -050058/*
59 * A module descriptor describes information about a module as a
60 * whole, *not* the functions within it.
61 */
Matt Porter6d63ff72014-09-26 20:49:48 -050062struct greybus_descriptor_module {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070063 __le16 vendor;
64 __le16 product;
65 __le16 version;
66 __u8 vendor_stringid;
67 __u8 product_stringid;
Alex Elder63cc9322014-10-02 12:30:02 -050068 __le64 unique_id;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070069};
70
Alex Elderecf7d572014-10-01 21:54:10 -050071/*
Alex Elder63cc9322014-10-02 12:30:02 -050072 * The string in a string descriptor is not NUL-terminated. The
73 * size of the descriptor will be rounded up to a multiple of 4
74 * bytes, by padding the string with 0x00 bytes if necessary.
Alex Elderecf7d572014-10-01 21:54:10 -050075 */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070076struct greybus_descriptor_string {
Matt Portercbd0fd72014-09-26 20:49:51 -050077 __u8 length;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070078 __u8 id;
79 __u8 string[0];
80};
81
Alex Elder63cc9322014-10-02 12:30:02 -050082/*
83 * An interface descriptor simply defines a module-unique id for
84 * each interface present on a module. Its sole purpose is to allow
85 * CPort descriptors to specify which interface they are associated
86 * with. Normally there's only one interface, with id 0. The
87 * second one must have id 1, and so on consecutively.
88 *
89 * The largest CPort id associated with an interface (defined by a
90 * CPort descriptor in the manifest) is used to determine how to
91 * encode the device id and module number in UniPro packets
92 * that use the interface.
93 */
94struct greybus_descriptor_interface {
95 __u8 id; /* module-relative id (0..) */
96};
97
98/*
99 * A CPort descriptor indicates the id of the interface within the
100 * module it's associated with, along with the CPort id used to
Alex Elder7fba0072014-10-28 19:35:59 -0500101 * address the CPort. The protocol id defines the format of messages
Alex Elder63cc9322014-10-02 12:30:02 -0500102 * exchanged using the CPort.
103 */
104struct greybus_descriptor_cport {
105 __u8 interface;
106 __le16 id;
Alex Elder7fba0072014-10-28 19:35:59 -0500107 __u8 protocol_id; /* enum greybus_protocol */
Alex Elder63cc9322014-10-02 12:30:02 -0500108};
109
110/*
111 * A class descriptor defines functionality supplied by a module.
112 * Beyond that, not much else is defined yet...
113 */
114struct greybus_descriptor_class {
115 __u8 class; /* enum greybus_class_type */
116};
117
Alex Elderecf7d572014-10-01 21:54:10 -0500118struct greybus_descriptor_header {
119 __le16 size;
Alex Elder63cc9322014-10-02 12:30:02 -0500120 __u8 type; /* enum greybus_descriptor_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700121};
122
Greg Kroah-Hartman6dca7b92014-09-01 13:42:43 -0700123struct greybus_descriptor {
Alex Elder63cc9322014-10-02 12:30:02 -0500124 struct greybus_descriptor_header header;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700125 union {
Matt Porter6d63ff72014-09-26 20:49:48 -0500126 struct greybus_descriptor_module module;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700127 struct greybus_descriptor_string string;
Alex Elderecf7d572014-10-01 21:54:10 -0500128 struct greybus_descriptor_interface interface;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700129 struct greybus_descriptor_cport cport;
Alex Elder63cc9322014-10-02 12:30:02 -0500130 struct greybus_descriptor_class class;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700131 };
132};
133
Alex Elderecf7d572014-10-01 21:54:10 -0500134struct greybus_manifest_header {
135 __le16 size;
136 __u8 version_major;
137 __u8 version_minor;
138};
139
Alex Elderbadad682014-09-09 13:55:04 -0500140struct greybus_manifest {
141 struct greybus_manifest_header header;
142 struct greybus_descriptor descriptors[0];
143};
144
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700145#pragma pack(pop)
146
Alex Elder1dd7f582014-09-26 20:55:32 -0500147#endif /* __GREYBUS_MANIFEST_H */