1 /* 2 * Greybus manifest definition 3 * 4 * See "Greybus Application Protocol" document (version 0.1) for 5 * details on these values and structures. 6 * 7 * Copyright 2014-2015 Google Inc. 8 * Copyright 2014-2015 Linaro Ltd. 9 * 10 * Released under the GPLv2 and BSD licenses. 11 */ 12 13 #ifndef __GREYBUS_MANIFEST_H 14 #define __GREYBUS_MANIFEST_H 15 16 enum greybus_descriptor_type { 17 GREYBUS_TYPE_INVALID = 0x00, 18 GREYBUS_TYPE_INTERFACE = 0x01, 19 GREYBUS_TYPE_STRING = 0x02, 20 GREYBUS_TYPE_BUNDLE = 0x03, 21 GREYBUS_TYPE_CPORT = 0x04, 22 }; 23 24 enum greybus_protocol { 25 GREYBUS_PROTOCOL_CONTROL = 0x00, 26 /* 0x01 is unused */ 27 GREYBUS_PROTOCOL_GPIO = 0x02, 28 GREYBUS_PROTOCOL_I2C = 0x03, 29 GREYBUS_PROTOCOL_UART = 0x04, 30 GREYBUS_PROTOCOL_HID = 0x05, 31 GREYBUS_PROTOCOL_USB = 0x06, 32 GREYBUS_PROTOCOL_SDIO = 0x07, 33 GREYBUS_PROTOCOL_POWER_SUPPLY = 0x08, 34 GREYBUS_PROTOCOL_PWM = 0x09, 35 /* 0x0a is unused */ 36 GREYBUS_PROTOCOL_SPI = 0x0b, 37 GREYBUS_PROTOCOL_DISPLAY = 0x0c, 38 GREYBUS_PROTOCOL_CAMERA_MGMT = 0x0d, 39 GREYBUS_PROTOCOL_SENSOR = 0x0e, 40 GREYBUS_PROTOCOL_LIGHTS = 0x0f, 41 GREYBUS_PROTOCOL_VIBRATOR = 0x10, 42 GREYBUS_PROTOCOL_LOOPBACK = 0x11, 43 GREYBUS_PROTOCOL_AUDIO_MGMT = 0x12, 44 GREYBUS_PROTOCOL_AUDIO_DATA = 0x13, 45 GREYBUS_PROTOCOL_SVC = 0x14, 46 GREYBUS_PROTOCOL_BOOTROM = 0x15, 47 GREYBUS_PROTOCOL_CAMERA_DATA = 0x16, 48 GREYBUS_PROTOCOL_FW_DOWNLOAD = 0x17, 49 GREYBUS_PROTOCOL_FW_MANAGEMENT = 0x18, 50 GREYBUS_PROTOCOL_AUTHENTICATION = 0x19, 51 GREYBUS_PROTOCOL_LOG = 0x1a, 52 /* ... */ 53 GREYBUS_PROTOCOL_RAW = 0xfe, 54 GREYBUS_PROTOCOL_VENDOR = 0xff, 55 }; 56 57 enum greybus_class_type { 58 GREYBUS_CLASS_CONTROL = 0x00, 59 /* 0x01 is unused */ 60 /* 0x02 is unused */ 61 /* 0x03 is unused */ 62 /* 0x04 is unused */ 63 GREYBUS_CLASS_HID = 0x05, 64 /* 0x06 is unused */ 65 /* 0x07 is unused */ 66 GREYBUS_CLASS_POWER_SUPPLY = 0x08, 67 /* 0x09 is unused */ 68 GREYBUS_CLASS_BRIDGED_PHY = 0x0a, 69 /* 0x0b is unused */ 70 GREYBUS_CLASS_DISPLAY = 0x0c, 71 GREYBUS_CLASS_CAMERA = 0x0d, 72 GREYBUS_CLASS_SENSOR = 0x0e, 73 GREYBUS_CLASS_LIGHTS = 0x0f, 74 GREYBUS_CLASS_VIBRATOR = 0x10, 75 GREYBUS_CLASS_LOOPBACK = 0x11, 76 GREYBUS_CLASS_AUDIO = 0x12, 77 /* 0x13 is unused */ 78 /* 0x14 is unused */ 79 GREYBUS_CLASS_BOOTROM = 0x15, 80 GREYBUS_CLASS_FW_MANAGEMENT = 0x16, 81 GREYBUS_CLASS_LOG = 0x17, 82 /* ... */ 83 GREYBUS_CLASS_RAW = 0xfe, 84 GREYBUS_CLASS_VENDOR = 0xff, 85 }; 86 87 enum { 88 GREYBUS_INTERFACE_FEATURE_TIMESYNC = BIT(0), 89 }; 90 91 /* 92 * 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. 95 */ 96 struct greybus_descriptor_string { 97 __u8 length; 98 __u8 id; 99 __u8 string[0]; 100 } __packed; 101 102 /* 103 * An interface descriptor describes information about an interface as a whole, 104 * *not* the functions within it. 105 */ 106 struct greybus_descriptor_interface { 107 __u8 vendor_stringid; 108 __u8 product_stringid; 109 __u8 features; 110 __u8 pad; 111 } __packed; 112 113 /* 114 * An bundle descriptor defines an identification number and a class for 115 * 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 * 126 * @class: It is used by kernel to know the functionality provided by the 127 * 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 */ 132 struct greybus_descriptor_bundle { 133 __u8 id; /* interface-relative id (0..) */ 134 __u8 class; 135 __u8 pad[2]; 136 } __packed; 137 138 /* 139 * A CPort descriptor indicates the id of the bundle within the 140 * module it's associated with, along with the CPort id used to 141 * address the CPort. The protocol id defines the format of messages 142 * exchanged using the CPort. 143 */ 144 struct greybus_descriptor_cport { 145 __le16 id; 146 __u8 bundle; 147 __u8 protocol_id; /* enum greybus_protocol */ 148 } __packed; 149 150 struct greybus_descriptor_header { 151 __le16 size; 152 __u8 type; /* enum greybus_descriptor_type */ 153 __u8 pad; 154 } __packed; 155 156 struct greybus_descriptor { 157 struct greybus_descriptor_header header; 158 union { 159 struct greybus_descriptor_string string; 160 struct greybus_descriptor_interface interface; 161 struct greybus_descriptor_bundle bundle; 162 struct greybus_descriptor_cport cport; 163 }; 164 } __packed; 165 166 struct greybus_manifest_header { 167 __le16 size; 168 __u8 version_major; 169 __u8 version_minor; 170 } __packed; 171 172 struct greybus_manifest { 173 struct greybus_manifest_header header; 174 struct greybus_descriptor descriptors[0]; 175 } __packed; 176 177 #endif /* __GREYBUS_MANIFEST_H */ 178