Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 1 | /* |
Alex Elder | 908a85d | 2014-09-24 05:16:16 -0500 | [diff] [blame] | 2 | * Greybus module manifest definition |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 3 | * |
Alex Elder | cb705e0 | 2014-09-24 05:16:17 -0500 | [diff] [blame] | 4 | * See "Greybus Application Protocol" document (version 0.1) for |
Alex Elder | 908a85d | 2014-09-24 05:16:16 -0500 | [diff] [blame] | 5 | * details on these values and structures. |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 6 | * |
| 7 | * Copyright 2014 Google Inc. |
Alex Elder | a46e967 | 2014-12-12 12:08:42 -0600 | [diff] [blame] | 8 | * Copyright 2014 Linaro Ltd. |
Alex Elder | 908a85d | 2014-09-24 05:16:16 -0500 | [diff] [blame] | 9 | * |
Greg Kroah-Hartman | 9b60aa0 | 2014-10-06 20:37:53 -0700 | [diff] [blame] | 10 | * Released under the GPLv2 and BSD licenses. |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
Alex Elder | 1dd7f58 | 2014-09-26 20:55:32 -0500 | [diff] [blame] | 13 | #ifndef __GREYBUS_MANIFEST_H |
| 14 | #define __GREYBUS_MANIFEST_H |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 15 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 16 | #pragma pack(push, 1) |
| 17 | |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 18 | enum greybus_descriptor_type { |
Alex Elder | 72b0ffc | 2014-09-26 20:55:33 -0500 | [diff] [blame] | 19 | GREYBUS_TYPE_INVALID = 0x00, |
| 20 | GREYBUS_TYPE_MODULE = 0x01, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 21 | GREYBUS_TYPE_STRING = 0x02, |
| 22 | GREYBUS_TYPE_INTERFACE = 0x03, |
| 23 | GREYBUS_TYPE_CPORT = 0x04, |
| 24 | GREYBUS_TYPE_CLASS = 0x05, |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 27 | enum 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-Hartman | 6819067 | 2014-11-17 15:19:14 -0800 | [diff] [blame] | 34 | GREYBUS_PROTOCOL_USB = 0x06, |
| 35 | GREYBUS_PROTOCOL_SDIO = 0x07, |
Greg Kroah-Hartman | 2bb7eae | 2014-10-20 15:24:57 +0800 | [diff] [blame] | 36 | GREYBUS_PROTOCOL_BATTERY = 0x08, |
Matt Porter | 34c6507 | 2014-11-13 09:14:13 -0500 | [diff] [blame] | 37 | GREYBUS_PROTOCOL_PWM = 0x09, |
Greg Kroah-Hartman | 6819067 | 2014-11-17 15:19:14 -0800 | [diff] [blame] | 38 | 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 Bailon | 355a705 | 2015-03-31 09:51:59 +0200 | [diff] [blame^] | 45 | GREYBUS_PROTOCOL_LOOPBACK = 0x11, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 46 | /* ... */ |
| 47 | GREYBUS_PROTOCOL_VENDOR = 0xff, |
| 48 | }; |
| 49 | |
| 50 | enum greybus_class_type { |
Alex Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 51 | GREYBUS_CLASS_CONTROL = 0x00, |
Greg Kroah-Hartman | 6ce3e03 | 2014-10-20 13:27:42 +0800 | [diff] [blame] | 52 | GREYBUS_CLASS_AP = 0x01, |
Alex Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 53 | GREYBUS_CLASS_GPIO = 0x02, |
Greg Kroah-Hartman | 6ce3e03 | 2014-10-20 13:27:42 +0800 | [diff] [blame] | 54 | GREYBUS_CLASS_I2C = 0x03, |
Alex Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 55 | GREYBUS_CLASS_UART = 0x04, |
Greg Kroah-Hartman | 6ce3e03 | 2014-10-20 13:27:42 +0800 | [diff] [blame] | 56 | 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 Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 66 | GREYBUS_CLASS_VENDOR = 0xff, |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 69 | /* |
| 70 | * A module descriptor describes information about a module as a |
| 71 | * whole, *not* the functions within it. |
| 72 | */ |
Matt Porter | 6d63ff7 | 2014-09-26 20:49:48 -0500 | [diff] [blame] | 73 | struct greybus_descriptor_module { |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 74 | __le16 vendor; |
| 75 | __le16 product; |
Greg Kroah-Hartman | 5f474d4 | 2014-12-09 14:57:04 -0500 | [diff] [blame] | 76 | __le16 version; // TODO - remove after Dec demo. |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 77 | __u8 vendor_stringid; |
| 78 | __u8 product_stringid; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 79 | __le64 unique_id; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 82 | /* |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 83 | * 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 Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 86 | */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 87 | struct greybus_descriptor_string { |
Matt Porter | cbd0fd7 | 2014-09-26 20:49:51 -0500 | [diff] [blame] | 88 | __u8 length; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 89 | __u8 id; |
| 90 | __u8 string[0]; |
| 91 | }; |
| 92 | |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 93 | /* |
| 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 | */ |
| 105 | struct greybus_descriptor_interface { |
| 106 | __u8 id; /* module-relative id (0..) */ |
| 107 | }; |
| 108 | |
| 109 | /* |
Greg Kroah-Hartman | 1db0a5f | 2014-12-12 17:10:17 -0500 | [diff] [blame] | 110 | * A CPort descriptor indicates the id of the bundle within the |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 111 | * module it's associated with, along with the CPort id used to |
Alex Elder | 7fba007 | 2014-10-28 19:35:59 -0500 | [diff] [blame] | 112 | * address the CPort. The protocol id defines the format of messages |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 113 | * exchanged using the CPort. |
| 114 | */ |
| 115 | struct greybus_descriptor_cport { |
Greg Kroah-Hartman | 1db0a5f | 2014-12-12 17:10:17 -0500 | [diff] [blame] | 116 | __u8 bundle; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 117 | __le16 id; |
Alex Elder | 7fba007 | 2014-10-28 19:35:59 -0500 | [diff] [blame] | 118 | __u8 protocol_id; /* enum greybus_protocol */ |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | /* |
| 122 | * A class descriptor defines functionality supplied by a module. |
| 123 | * Beyond that, not much else is defined yet... |
| 124 | */ |
| 125 | struct greybus_descriptor_class { |
| 126 | __u8 class; /* enum greybus_class_type */ |
| 127 | }; |
| 128 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 129 | struct greybus_descriptor_header { |
| 130 | __le16 size; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 131 | __u8 type; /* enum greybus_descriptor_type */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
Greg Kroah-Hartman | 6dca7b9 | 2014-09-01 13:42:43 -0700 | [diff] [blame] | 134 | struct greybus_descriptor { |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 135 | struct greybus_descriptor_header header; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 136 | union { |
Matt Porter | 6d63ff7 | 2014-09-26 20:49:48 -0500 | [diff] [blame] | 137 | struct greybus_descriptor_module module; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 138 | struct greybus_descriptor_string string; |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 139 | struct greybus_descriptor_interface interface; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 140 | struct greybus_descriptor_cport cport; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 141 | struct greybus_descriptor_class class; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 142 | }; |
| 143 | }; |
| 144 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 145 | struct greybus_manifest_header { |
| 146 | __le16 size; |
| 147 | __u8 version_major; |
| 148 | __u8 version_minor; |
| 149 | }; |
| 150 | |
Alex Elder | badad68 | 2014-09-09 13:55:04 -0500 | [diff] [blame] | 151 | struct greybus_manifest { |
| 152 | struct greybus_manifest_header header; |
| 153 | struct greybus_descriptor descriptors[0]; |
| 154 | }; |
| 155 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 156 | #pragma pack(pop) |
| 157 | |
Alex Elder | 1dd7f58 | 2014-09-26 20:55:32 -0500 | [diff] [blame] | 158 | #endif /* __GREYBUS_MANIFEST_H */ |