Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 1 | /* |
Viresh Kumar | a93db2d | 2015-04-01 20:32:02 +0530 | [diff] [blame] | 2 | * Greybus 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 | * |
Alex Elder | 4441f47 | 2015-05-22 12:59:16 -0500 | [diff] [blame] | 7 | * Copyright 2014-2015 Google Inc. |
| 8 | * Copyright 2014-2015 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 | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 16 | enum greybus_descriptor_type { |
Alex Elder | 72b0ffc | 2014-09-26 20:55:33 -0500 | [diff] [blame] | 17 | GREYBUS_TYPE_INVALID = 0x00, |
Viresh Kumar | 83a0cb5 | 2015-04-01 20:31:59 +0530 | [diff] [blame] | 18 | GREYBUS_TYPE_INTERFACE = 0x01, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 19 | GREYBUS_TYPE_STRING = 0x02, |
Viresh Kumar | 83a0cb5 | 2015-04-01 20:31:59 +0530 | [diff] [blame] | 20 | GREYBUS_TYPE_BUNDLE = 0x03, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 21 | GREYBUS_TYPE_CPORT = 0x04, |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 22 | }; |
| 23 | |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 24 | enum greybus_protocol { |
| 25 | GREYBUS_PROTOCOL_CONTROL = 0x00, |
Johan Hovold | 9230e29 | 2016-03-08 16:50:43 +0100 | [diff] [blame] | 26 | /* 0x01 is unused */ |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 27 | GREYBUS_PROTOCOL_GPIO = 0x02, |
| 28 | GREYBUS_PROTOCOL_I2C = 0x03, |
| 29 | GREYBUS_PROTOCOL_UART = 0x04, |
| 30 | GREYBUS_PROTOCOL_HID = 0x05, |
Greg Kroah-Hartman | 6819067 | 2014-11-17 15:19:14 -0800 | [diff] [blame] | 31 | GREYBUS_PROTOCOL_USB = 0x06, |
| 32 | GREYBUS_PROTOCOL_SDIO = 0x07, |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 33 | GREYBUS_PROTOCOL_POWER_SUPPLY = 0x08, |
Matt Porter | 34c6507 | 2014-11-13 09:14:13 -0500 | [diff] [blame] | 34 | GREYBUS_PROTOCOL_PWM = 0x09, |
Mark Greer | 357499d | 2015-11-04 09:47:22 -0700 | [diff] [blame] | 35 | /* 0x0a is unused */ |
Greg Kroah-Hartman | 6819067 | 2014-11-17 15:19:14 -0800 | [diff] [blame] | 36 | GREYBUS_PROTOCOL_SPI = 0x0b, |
| 37 | GREYBUS_PROTOCOL_DISPLAY = 0x0c, |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 38 | GREYBUS_PROTOCOL_CAMERA_MGMT = 0x0d, |
Greg Kroah-Hartman | 6819067 | 2014-11-17 15:19:14 -0800 | [diff] [blame] | 39 | GREYBUS_PROTOCOL_SENSOR = 0x0e, |
Rui Miguel Silva | 563e6b9 | 2015-05-11 19:22:03 +0100 | [diff] [blame] | 40 | GREYBUS_PROTOCOL_LIGHTS = 0x0f, |
Greg Kroah-Hartman | 6819067 | 2014-11-17 15:19:14 -0800 | [diff] [blame] | 41 | GREYBUS_PROTOCOL_VIBRATOR = 0x10, |
Alexandre Bailon | 355a705 | 2015-03-31 09:51:59 +0200 | [diff] [blame] | 42 | GREYBUS_PROTOCOL_LOOPBACK = 0x11, |
Mark Greer | 80ee842 | 2015-11-13 14:44:13 -0700 | [diff] [blame] | 43 | GREYBUS_PROTOCOL_AUDIO_MGMT = 0x12, |
| 44 | GREYBUS_PROTOCOL_AUDIO_DATA = 0x13, |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 45 | GREYBUS_PROTOCOL_SVC = 0x14, |
Viresh Kumar | 5a53e02 | 2016-04-03 12:18:35 +0530 | [diff] [blame] | 46 | GREYBUS_PROTOCOL_BOOTROM = 0x15, |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 47 | GREYBUS_PROTOCOL_CAMERA_DATA = 0x16, |
Viresh Kumar | 9e04fb7 | 2016-04-26 10:20:49 +0530 | [diff] [blame] | 48 | GREYBUS_PROTOCOL_FW_DOWNLOAD = 0x17, |
| 49 | GREYBUS_PROTOCOL_FW_MANAGEMENT = 0x18, |
Viresh Kumar | e3eda54 | 2016-06-30 10:54:00 -0500 | [diff] [blame] | 50 | GREYBUS_PROTOCOL_AUTHENTICATION = 0x19, |
Joel Porquet | c0e65d0 | 2016-06-24 14:41:36 -0700 | [diff] [blame] | 51 | GREYBUS_PROTOCOL_LOG = 0x1a, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 52 | /* ... */ |
Greg Kroah-Hartman | e806c7f | 2015-05-08 15:50:17 +0200 | [diff] [blame] | 53 | GREYBUS_PROTOCOL_RAW = 0xfe, |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 54 | GREYBUS_PROTOCOL_VENDOR = 0xff, |
| 55 | }; |
| 56 | |
| 57 | enum greybus_class_type { |
Alex Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 58 | GREYBUS_CLASS_CONTROL = 0x00, |
Johan Hovold | 9230e29 | 2016-03-08 16:50:43 +0100 | [diff] [blame] | 59 | /* 0x01 is unused */ |
Viresh Kumar | dc07540 | 2016-05-10 08:50:13 +0530 | [diff] [blame] | 60 | /* 0x02 is unused */ |
| 61 | /* 0x03 is unused */ |
| 62 | /* 0x04 is unused */ |
Greg Kroah-Hartman | 6ce3e03 | 2014-10-20 13:27:42 +0800 | [diff] [blame] | 63 | GREYBUS_CLASS_HID = 0x05, |
Viresh Kumar | dc07540 | 2016-05-10 08:50:13 +0530 | [diff] [blame] | 64 | /* 0x06 is unused */ |
| 65 | /* 0x07 is unused */ |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 66 | GREYBUS_CLASS_POWER_SUPPLY = 0x08, |
Viresh Kumar | dc07540 | 2016-05-10 08:50:13 +0530 | [diff] [blame] | 67 | /* 0x09 is unused */ |
Greg Kroah-Hartman | d6fefbe | 2016-02-28 14:13:27 -0800 | [diff] [blame] | 68 | GREYBUS_CLASS_BRIDGED_PHY = 0x0a, |
Viresh Kumar | dc07540 | 2016-05-10 08:50:13 +0530 | [diff] [blame] | 69 | /* 0x0b is unused */ |
Greg Kroah-Hartman | 6ce3e03 | 2014-10-20 13:27:42 +0800 | [diff] [blame] | 70 | GREYBUS_CLASS_DISPLAY = 0x0c, |
| 71 | GREYBUS_CLASS_CAMERA = 0x0d, |
| 72 | GREYBUS_CLASS_SENSOR = 0x0e, |
Viresh Kumar | dccbe40 | 2015-06-30 11:40:18 +0530 | [diff] [blame] | 73 | GREYBUS_CLASS_LIGHTS = 0x0f, |
| 74 | GREYBUS_CLASS_VIBRATOR = 0x10, |
| 75 | GREYBUS_CLASS_LOOPBACK = 0x11, |
Viresh Kumar | 3b710ec | 2016-01-27 11:17:00 +0530 | [diff] [blame] | 76 | GREYBUS_CLASS_AUDIO = 0x12, |
| 77 | /* 0x13 is unused */ |
Johan Hovold | a23aa56 | 2016-03-09 16:13:55 +0100 | [diff] [blame] | 78 | /* 0x14 is unused */ |
Viresh Kumar | 5a53e02 | 2016-04-03 12:18:35 +0530 | [diff] [blame] | 79 | GREYBUS_CLASS_BOOTROM = 0x15, |
Viresh Kumar | 9e04fb7 | 2016-04-26 10:20:49 +0530 | [diff] [blame] | 80 | GREYBUS_CLASS_FW_MANAGEMENT = 0x16, |
Joel Porquet | c0e65d0 | 2016-06-24 14:41:36 -0700 | [diff] [blame] | 81 | GREYBUS_CLASS_LOG = 0x17, |
Viresh Kumar | 948b3bd5 | 2015-07-21 17:44:10 +0530 | [diff] [blame] | 82 | /* ... */ |
| 83 | GREYBUS_CLASS_RAW = 0xfe, |
Alex Elder | 063e6ec | 2014-10-03 14:14:23 -0500 | [diff] [blame] | 84 | GREYBUS_CLASS_VENDOR = 0xff, |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
Bryan O'Donoghue | 8c81d46 | 2016-05-15 19:37:49 +0100 | [diff] [blame] | 87 | enum { |
| 88 | GREYBUS_INTERFACE_FEATURE_TIMESYNC = BIT(0), |
| 89 | }; |
| 90 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 91 | /* |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 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. |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 95 | */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 96 | struct greybus_descriptor_string { |
Matt Porter | cbd0fd7 | 2014-09-26 20:49:51 -0500 | [diff] [blame] | 97 | __u8 length; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 98 | __u8 id; |
| 99 | __u8 string[0]; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 100 | } __packed; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 101 | |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 102 | /* |
Viresh Kumar | a93db2d | 2015-04-01 20:32:02 +0530 | [diff] [blame] | 103 | * An interface descriptor describes information about an interface as a whole, |
| 104 | * *not* the functions within it. |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 105 | */ |
| 106 | struct greybus_descriptor_interface { |
Viresh Kumar | a93db2d | 2015-04-01 20:32:02 +0530 | [diff] [blame] | 107 | __u8 vendor_stringid; |
| 108 | __u8 product_stringid; |
Bryan O'Donoghue | 8c81d46 | 2016-05-15 19:37:49 +0100 | [diff] [blame] | 109 | __u8 features; |
| 110 | __u8 pad; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 111 | } __packed; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 112 | |
| 113 | /* |
Viresh Kumar | 88e6d37 | 2015-04-06 15:49:36 +0530 | [diff] [blame] | 114 | * An bundle descriptor defines an identification number and a class for |
Viresh Kumar | 83a0cb5 | 2015-04-01 20:31:59 +0530 | [diff] [blame] | 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 | * |
Viresh Kumar | 88e6d37 | 2015-04-06 15:49:36 +0530 | [diff] [blame] | 126 | * @class: It is used by kernel to know the functionality provided by the |
Viresh Kumar | 83a0cb5 | 2015-04-01 20:31:59 +0530 | [diff] [blame] | 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..) */ |
Viresh Kumar | 88e6d37 | 2015-04-06 15:49:36 +0530 | [diff] [blame] | 134 | __u8 class; |
Viresh Kumar | 499ee95 | 2015-04-28 19:51:40 +0530 | [diff] [blame] | 135 | __u8 pad[2]; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 136 | } __packed; |
Viresh Kumar | 83a0cb5 | 2015-04-01 20:31:59 +0530 | [diff] [blame] | 137 | |
| 138 | /* |
Greg Kroah-Hartman | 1db0a5f | 2014-12-12 17:10:17 -0500 | [diff] [blame] | 139 | * A CPort descriptor indicates the id of the bundle within the |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 140 | * module it's associated with, along with the CPort id used to |
Alex Elder | 7fba007 | 2014-10-28 19:35:59 -0500 | [diff] [blame] | 141 | * address the CPort. The protocol id defines the format of messages |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 142 | * exchanged using the CPort. |
| 143 | */ |
| 144 | struct greybus_descriptor_cport { |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 145 | __le16 id; |
Viresh Kumar | f03eec8 | 2015-04-28 19:51:41 +0530 | [diff] [blame] | 146 | __u8 bundle; |
Alex Elder | 7fba007 | 2014-10-28 19:35:59 -0500 | [diff] [blame] | 147 | __u8 protocol_id; /* enum greybus_protocol */ |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 148 | } __packed; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 149 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 150 | struct greybus_descriptor_header { |
| 151 | __le16 size; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 152 | __u8 type; /* enum greybus_descriptor_type */ |
Viresh Kumar | 499ee95 | 2015-04-28 19:51:40 +0530 | [diff] [blame] | 153 | __u8 pad; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 154 | } __packed; |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 155 | |
Greg Kroah-Hartman | 6dca7b9 | 2014-09-01 13:42:43 -0700 | [diff] [blame] | 156 | struct greybus_descriptor { |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 157 | struct greybus_descriptor_header header; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 158 | union { |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 159 | struct greybus_descriptor_string string; |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 160 | struct greybus_descriptor_interface interface; |
Viresh Kumar | 83a0cb5 | 2015-04-01 20:31:59 +0530 | [diff] [blame] | 161 | struct greybus_descriptor_bundle bundle; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 162 | struct greybus_descriptor_cport cport; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 163 | }; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 164 | } __packed; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 165 | |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 166 | struct greybus_manifest_header { |
| 167 | __le16 size; |
| 168 | __u8 version_major; |
| 169 | __u8 version_minor; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 170 | } __packed; |
Alex Elder | ecf7d57 | 2014-10-01 21:54:10 -0500 | [diff] [blame] | 171 | |
Alex Elder | badad68 | 2014-09-09 13:55:04 -0500 | [diff] [blame] | 172 | struct greybus_manifest { |
| 173 | struct greybus_manifest_header header; |
| 174 | struct greybus_descriptor descriptors[0]; |
Viresh Kumar | af6e8b4 | 2015-04-28 19:51:34 +0530 | [diff] [blame] | 175 | } __packed; |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 176 | |
Alex Elder | 1dd7f58 | 2014-09-26 20:55:32 -0500 | [diff] [blame] | 177 | #endif /* __GREYBUS_MANIFEST_H */ |