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 | 908a85d | 2014-09-24 05:16:16 -0500 | [diff] [blame] | 8 | * |
Greg Kroah-Hartman | 9b60aa0 | 2014-10-06 20:37:53 -0700 | [diff] [blame^] | 9 | * Released under the GPLv2 and BSD licenses. |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Alex Elder | 1dd7f58 | 2014-09-26 20:55:32 -0500 | [diff] [blame] | 12 | #ifndef __GREYBUS_MANIFEST_H |
| 13 | #define __GREYBUS_MANIFEST_H |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 14 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 15 | #pragma pack(push, 1) |
| 16 | |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 17 | enum greybus_descriptor_type { |
Alex Elder | 72b0ffc | 2014-09-26 20:55:33 -0500 | [diff] [blame] | 18 | GREYBUS_TYPE_INVALID = 0x00, |
| 19 | GREYBUS_TYPE_MODULE = 0x01, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 20 | GREYBUS_TYPE_STRING = 0x02, |
| 21 | GREYBUS_TYPE_INTERFACE = 0x03, |
| 22 | GREYBUS_TYPE_CPORT = 0x04, |
| 23 | GREYBUS_TYPE_CLASS = 0x05, |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 24 | }; |
| 25 | |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 26 | enum 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, |
| 33 | /* ... */ |
| 34 | GREYBUS_PROTOCOL_VENDOR = 0xff, |
| 35 | }; |
| 36 | |
| 37 | enum greybus_class_type { |
Alex Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 38 | GREYBUS_CLASS_CONTROL = 0x00, |
| 39 | GREYBUS_CLASS_USB = 0x01, |
| 40 | GREYBUS_CLASS_GPIO = 0x02, |
| 41 | GREYBUS_CLASS_SPI = 0x03, |
| 42 | GREYBUS_CLASS_UART = 0x04, |
| 43 | GREYBUS_CLASS_PWM = 0x05, |
| 44 | GREYBUS_CLASS_I2S = 0x06, |
| 45 | GREYBUS_CLASS_I2C = 0x07, |
| 46 | GREYBUS_CLASS_SDIO = 0x08, |
| 47 | GREYBUS_CLASS_HID = 0x09, |
| 48 | GREYBUS_CLASS_DISPLAY = 0x0a, |
| 49 | GREYBUS_CLASS_CAMERA = 0x0b, |
| 50 | GREYBUS_CLASS_SENSOR = 0x0c, |
| 51 | GREYBUS_CLASS_VENDOR = 0xff, |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 54 | /* |
| 55 | * A module descriptor describes information about a module as a |
| 56 | * whole, *not* the functions within it. |
| 57 | */ |
Matt Porter | 6d63ff7 | 2014-09-26 20:49:48 -0500 | [diff] [blame] | 58 | struct greybus_descriptor_module { |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 59 | __le16 vendor; |
| 60 | __le16 product; |
| 61 | __le16 version; |
| 62 | __u8 vendor_stringid; |
| 63 | __u8 product_stringid; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 64 | __le64 unique_id; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 67 | /* |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 68 | * The string in a string descriptor is not NUL-terminated. The |
| 69 | * size of the descriptor will be rounded up to a multiple of 4 |
| 70 | * bytes, by padding the string with 0x00 bytes if necessary. |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 71 | */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 72 | struct greybus_descriptor_string { |
Matt Porter | cbd0fd7 | 2014-09-26 20:49:51 -0500 | [diff] [blame] | 73 | __u8 length; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 74 | __u8 id; |
| 75 | __u8 string[0]; |
| 76 | }; |
| 77 | |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 78 | /* |
| 79 | * An interface descriptor simply defines a module-unique id for |
| 80 | * each interface present on a module. Its sole purpose is to allow |
| 81 | * CPort descriptors to specify which interface they are associated |
| 82 | * with. Normally there's only one interface, with id 0. The |
| 83 | * second one must have id 1, and so on consecutively. |
| 84 | * |
| 85 | * The largest CPort id associated with an interface (defined by a |
| 86 | * CPort descriptor in the manifest) is used to determine how to |
| 87 | * encode the device id and module number in UniPro packets |
| 88 | * that use the interface. |
| 89 | */ |
| 90 | struct greybus_descriptor_interface { |
| 91 | __u8 id; /* module-relative id (0..) */ |
| 92 | }; |
| 93 | |
| 94 | /* |
| 95 | * A CPort descriptor indicates the id of the interface within the |
| 96 | * module it's associated with, along with the CPort id used to |
| 97 | * address the CPort. The protocol defines the format of messages |
| 98 | * exchanged using the CPort. |
| 99 | */ |
| 100 | struct greybus_descriptor_cport { |
| 101 | __u8 interface; |
| 102 | __le16 id; |
| 103 | __u8 protocol; /* enum greybus_protocol */ |
| 104 | }; |
| 105 | |
| 106 | /* |
| 107 | * A class descriptor defines functionality supplied by a module. |
| 108 | * Beyond that, not much else is defined yet... |
| 109 | */ |
| 110 | struct greybus_descriptor_class { |
| 111 | __u8 class; /* enum greybus_class_type */ |
| 112 | }; |
| 113 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 114 | struct greybus_descriptor_header { |
| 115 | __le16 size; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 116 | __u8 type; /* enum greybus_descriptor_type */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
Greg Kroah-Hartman | 6dca7b9 | 2014-09-01 13:42:43 -0700 | [diff] [blame] | 119 | struct greybus_descriptor { |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 120 | struct greybus_descriptor_header header; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 121 | union { |
Matt Porter | 6d63ff7 | 2014-09-26 20:49:48 -0500 | [diff] [blame] | 122 | struct greybus_descriptor_module module; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 123 | struct greybus_descriptor_string string; |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 124 | struct greybus_descriptor_interface interface; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 125 | struct greybus_descriptor_cport cport; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 126 | struct greybus_descriptor_class class; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 127 | }; |
| 128 | }; |
| 129 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 130 | struct greybus_manifest_header { |
| 131 | __le16 size; |
| 132 | __u8 version_major; |
| 133 | __u8 version_minor; |
| 134 | }; |
| 135 | |
Alex Elder | badad68 | 2014-09-09 13:55:04 -0500 | [diff] [blame] | 136 | struct greybus_manifest { |
| 137 | struct greybus_manifest_header header; |
| 138 | struct greybus_descriptor descriptors[0]; |
| 139 | }; |
| 140 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 141 | #pragma pack(pop) |
| 142 | |
Alex Elder | 1dd7f58 | 2014-09-26 20:55:32 -0500 | [diff] [blame] | 143 | #endif /* __GREYBUS_MANIFEST_H */ |