1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /*
3  * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
4  * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
5  */
6 
7 #ifndef __GREYBUS_PROTOCOLS_H
8 #define __GREYBUS_PROTOCOLS_H
9 
10 #include <linux/types.h>
11 
12 /* Fixed IDs for control/svc protocols */
13 
14 /* SVC switch-port device ids */
15 #define GB_SVC_DEVICE_ID_SVC			0
16 #define GB_SVC_DEVICE_ID_AP			1
17 #define GB_SVC_DEVICE_ID_MIN			2
18 #define GB_SVC_DEVICE_ID_MAX			31
19 
20 #define GB_SVC_CPORT_ID				0
21 #define GB_CONTROL_BUNDLE_ID			0
22 #define GB_CONTROL_CPORT_ID			0
23 
24 
25 /*
26  * All operation messages (both requests and responses) begin with
27  * a header that encodes the size of the message (header included).
28  * This header also contains a unique identifier, that associates a
29  * response message with its operation.  The header contains an
30  * operation type field, whose interpretation is dependent on what
31  * type of protocol is used over the connection.  The high bit
32  * (0x80) of the operation type field is used to indicate whether
33  * the message is a request (clear) or a response (set).
34  *
35  * Response messages include an additional result byte, which
36  * communicates the result of the corresponding request.  A zero
37  * result value means the operation completed successfully.  Any
38  * other value indicates an error; in this case, the payload of the
39  * response message (if any) is ignored.  The result byte must be
40  * zero in the header for a request message.
41  *
42  * The wire format for all numeric fields in the header is little
43  * endian.  Any operation-specific data begins immediately after the
44  * header.
45  */
46 struct gb_operation_msg_hdr {
47 	__le16	size;		/* Size in bytes of header + payload */
48 	__le16	operation_id;	/* Operation unique id */
49 	__u8	type;		/* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
50 	__u8	result;		/* Result of request (in responses only) */
51 	__u8	pad[2];		/* must be zero (ignore when read) */
52 } __packed;
53 
54 
55 /* Generic request types */
56 #define GB_REQUEST_TYPE_CPORT_SHUTDOWN		0x00
57 #define GB_REQUEST_TYPE_INVALID			0x7f
58 
59 struct gb_cport_shutdown_request {
60 	__u8 phase;
61 } __packed;
62 
63 
64 /* Control Protocol */
65 
66 /* Greybus control request types */
67 #define GB_CONTROL_TYPE_VERSION			0x01
68 #define GB_CONTROL_TYPE_PROBE_AP		0x02
69 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE	0x03
70 #define GB_CONTROL_TYPE_GET_MANIFEST		0x04
71 #define GB_CONTROL_TYPE_CONNECTED		0x05
72 #define GB_CONTROL_TYPE_DISCONNECTED		0x06
73 #define GB_CONTROL_TYPE_TIMESYNC_ENABLE		0x07
74 #define GB_CONTROL_TYPE_TIMESYNC_DISABLE	0x08
75 #define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE	0x09
76 /*	Unused					0x0a */
77 #define GB_CONTROL_TYPE_BUNDLE_VERSION		0x0b
78 #define GB_CONTROL_TYPE_DISCONNECTING		0x0c
79 #define GB_CONTROL_TYPE_TIMESYNC_GET_LAST_EVENT	0x0d
80 #define GB_CONTROL_TYPE_MODE_SWITCH		0x0e
81 #define GB_CONTROL_TYPE_BUNDLE_SUSPEND		0x0f
82 #define GB_CONTROL_TYPE_BUNDLE_RESUME		0x10
83 #define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE	0x11
84 #define GB_CONTROL_TYPE_BUNDLE_ACTIVATE		0x12
85 #define GB_CONTROL_TYPE_INTF_SUSPEND_PREPARE		0x13
86 #define GB_CONTROL_TYPE_INTF_DEACTIVATE_PREPARE	0x14
87 #define GB_CONTROL_TYPE_INTF_HIBERNATE_ABORT	0x15
88 
89 struct gb_control_version_request {
90 	__u8	major;
91 	__u8	minor;
92 } __packed;
93 
94 struct gb_control_version_response {
95 	__u8	major;
96 	__u8	minor;
97 } __packed;
98 
99 struct gb_control_bundle_version_request {
100 	__u8	bundle_id;
101 } __packed;
102 
103 struct gb_control_bundle_version_response {
104 	__u8	major;
105 	__u8	minor;
106 } __packed;
107 
108 /* Control protocol manifest get size request has no payload*/
109 struct gb_control_get_manifest_size_response {
110 	__le16			size;
111 } __packed;
112 
113 /* Control protocol manifest get request has no payload */
114 struct gb_control_get_manifest_response {
115 	__u8			data[0];
116 } __packed;
117 
118 /* Control protocol [dis]connected request */
119 struct gb_control_connected_request {
120 	__le16			cport_id;
121 } __packed;
122 
123 struct gb_control_disconnecting_request {
124 	__le16			cport_id;
125 } __packed;
126 /* disconnecting response has no payload */
127 
128 struct gb_control_disconnected_request {
129 	__le16			cport_id;
130 } __packed;
131 /* Control protocol [dis]connected response has no payload */
132 
133 /*
134  * All Bundle power management operations use the same request and response
135  * layout and status codes.
136  */
137 
138 #define GB_CONTROL_BUNDLE_PM_OK		0x00
139 #define GB_CONTROL_BUNDLE_PM_INVAL	0x01
140 #define GB_CONTROL_BUNDLE_PM_BUSY	0x02
141 #define GB_CONTROL_BUNDLE_PM_FAIL	0x03
142 #define GB_CONTROL_BUNDLE_PM_NA		0x04
143 
144 struct gb_control_bundle_pm_request {
145 	__u8	bundle_id;
146 } __packed;
147 
148 struct gb_control_bundle_pm_response {
149 	__u8	status;
150 } __packed;
151 
152 /*
153  * Interface Suspend Prepare and Deactivate Prepare operations use the same
154  * response layout and error codes. Define a single response structure and reuse
155  * it. Both operations have no payload.
156  */
157 
158 #define GB_CONTROL_INTF_PM_OK		0x00
159 #define GB_CONTROL_INTF_PM_BUSY		0x01
160 #define GB_CONTROL_INTF_PM_NA		0x02
161 
162 struct gb_control_intf_pm_response {
163 	__u8	status;
164 } __packed;
165 
166 /* APBridge protocol */
167 
168 /* request APB1 log */
169 #define GB_APB_REQUEST_LOG			0x02
170 
171 /* request to map a cport to bulk in and bulk out endpoints */
172 #define GB_APB_REQUEST_EP_MAPPING		0x03
173 
174 /* request to get the number of cports available */
175 #define GB_APB_REQUEST_CPORT_COUNT		0x04
176 
177 /* request to reset a cport state */
178 #define GB_APB_REQUEST_RESET_CPORT		0x05
179 
180 /* request to time the latency of messages on a given cport */
181 #define GB_APB_REQUEST_LATENCY_TAG_EN		0x06
182 #define GB_APB_REQUEST_LATENCY_TAG_DIS		0x07
183 
184 /* request to control the CSI transmitter */
185 #define GB_APB_REQUEST_CSI_TX_CONTROL		0x08
186 
187 /* request to control audio streaming */
188 #define GB_APB_REQUEST_AUDIO_CONTROL		0x09
189 
190 /* TimeSync requests */
191 #define GB_APB_REQUEST_TIMESYNC_ENABLE		0x0d
192 #define GB_APB_REQUEST_TIMESYNC_DISABLE		0x0e
193 #define GB_APB_REQUEST_TIMESYNC_AUTHORITATIVE	0x0f
194 #define GB_APB_REQUEST_TIMESYNC_GET_LAST_EVENT	0x10
195 
196 /* requests to set Greybus CPort flags */
197 #define GB_APB_REQUEST_CPORT_FLAGS		0x11
198 
199 /* ARPC request */
200 #define GB_APB_REQUEST_ARPC_RUN			0x12
201 
202 struct gb_apb_request_cport_flags {
203 	__le32	flags;
204 #define GB_APB_CPORT_FLAG_CONTROL		0x01
205 #define GB_APB_CPORT_FLAG_HIGH_PRIO		0x02
206 } __packed;
207 
208 
209 /* Firmware Download Protocol */
210 
211 /* Request Types */
212 #define GB_FW_DOWNLOAD_TYPE_FIND_FIRMWARE	0x01
213 #define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE	0x02
214 #define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE	0x03
215 
216 #define GB_FIRMWARE_TAG_MAX_SIZE		10
217 
218 /* firmware download find firmware request/response */
219 struct gb_fw_download_find_firmware_request {
220 	__u8			firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
221 } __packed;
222 
223 struct gb_fw_download_find_firmware_response {
224 	__u8			firmware_id;
225 	__le32			size;
226 } __packed;
227 
228 /* firmware download fetch firmware request/response */
229 struct gb_fw_download_fetch_firmware_request {
230 	__u8			firmware_id;
231 	__le32			offset;
232 	__le32			size;
233 } __packed;
234 
235 /* gb_fw_download_fetch_firmware_response contains no other data */
236 
237 /* firmware download release firmware request */
238 struct gb_fw_download_release_firmware_request {
239 	__u8			firmware_id;
240 } __packed;
241 /* firmware download release firmware response has no payload */
242 
243 
244 /* Firmware Management Protocol */
245 
246 /* Request Types */
247 #define GB_FW_MGMT_TYPE_INTERFACE_FW_VERSION	0x01
248 #define GB_FW_MGMT_TYPE_LOAD_AND_VALIDATE_FW	0x02
249 #define GB_FW_MGMT_TYPE_LOADED_FW		0x03
250 #define GB_FW_MGMT_TYPE_BACKEND_FW_VERSION	0x04
251 #define GB_FW_MGMT_TYPE_BACKEND_FW_UPDATE	0x05
252 #define GB_FW_MGMT_TYPE_BACKEND_FW_UPDATED	0x06
253 
254 #define GB_FW_LOAD_METHOD_UNIPRO		0x01
255 #define GB_FW_LOAD_METHOD_INTERNAL		0x02
256 
257 #define GB_FW_LOAD_STATUS_FAILED		0x00
258 #define GB_FW_LOAD_STATUS_UNVALIDATED		0x01
259 #define GB_FW_LOAD_STATUS_VALIDATED		0x02
260 #define GB_FW_LOAD_STATUS_VALIDATION_FAILED	0x03
261 
262 #define GB_FW_BACKEND_FW_STATUS_SUCCESS		0x01
263 #define GB_FW_BACKEND_FW_STATUS_FAIL_FIND	0x02
264 #define GB_FW_BACKEND_FW_STATUS_FAIL_FETCH	0x03
265 #define GB_FW_BACKEND_FW_STATUS_FAIL_WRITE	0x04
266 #define GB_FW_BACKEND_FW_STATUS_INT		0x05
267 #define GB_FW_BACKEND_FW_STATUS_RETRY		0x06
268 #define GB_FW_BACKEND_FW_STATUS_NOT_SUPPORTED	0x07
269 
270 #define GB_FW_BACKEND_VERSION_STATUS_SUCCESS		0x01
271 #define GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE	0x02
272 #define GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED	0x03
273 #define GB_FW_BACKEND_VERSION_STATUS_RETRY		0x04
274 #define GB_FW_BACKEND_VERSION_STATUS_FAIL_INT		0x05
275 
276 /* firmware management interface firmware version request has no payload */
277 struct gb_fw_mgmt_interface_fw_version_response {
278 	__u8			firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
279 	__le16			major;
280 	__le16			minor;
281 } __packed;
282 
283 /* firmware management load and validate firmware request/response */
284 struct gb_fw_mgmt_load_and_validate_fw_request {
285 	__u8			request_id;
286 	__u8			load_method;
287 	__u8			firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
288 } __packed;
289 /* firmware management load and validate firmware response has no payload*/
290 
291 /* firmware management loaded firmware request */
292 struct gb_fw_mgmt_loaded_fw_request {
293 	__u8			request_id;
294 	__u8			status;
295 	__le16			major;
296 	__le16			minor;
297 } __packed;
298 /* firmware management loaded firmware response has no payload */
299 
300 /* firmware management backend firmware version request/response */
301 struct gb_fw_mgmt_backend_fw_version_request {
302 	__u8			firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
303 } __packed;
304 
305 struct gb_fw_mgmt_backend_fw_version_response {
306 	__le16			major;
307 	__le16			minor;
308 	__u8			status;
309 } __packed;
310 
311 /* firmware management backend firmware update request */
312 struct gb_fw_mgmt_backend_fw_update_request {
313 	__u8			request_id;
314 	__u8			firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
315 } __packed;
316 /* firmware management backend firmware update response has no payload */
317 
318 /* firmware management backend firmware updated request */
319 struct gb_fw_mgmt_backend_fw_updated_request {
320 	__u8			request_id;
321 	__u8			status;
322 } __packed;
323 /* firmware management backend firmware updated response has no payload */
324 
325 
326 /* Component Authentication Protocol (CAP) */
327 
328 /* Request Types */
329 #define GB_CAP_TYPE_GET_ENDPOINT_UID	0x01
330 #define GB_CAP_TYPE_GET_IMS_CERTIFICATE	0x02
331 #define GB_CAP_TYPE_AUTHENTICATE	0x03
332 
333 /* CAP get endpoint uid request has no payload */
334 struct gb_cap_get_endpoint_uid_response {
335 	__u8			uid[8];
336 } __packed;
337 
338 /* CAP get endpoint ims certificate request/response */
339 struct gb_cap_get_ims_certificate_request {
340 	__le32			certificate_class;
341 	__le32			certificate_id;
342 } __packed;
343 
344 struct gb_cap_get_ims_certificate_response {
345 	__u8			result_code;
346 	__u8			certificate[];
347 } __packed;
348 
349 /* CAP authenticate request/response */
350 struct gb_cap_authenticate_request {
351 	__le32			auth_type;
352 	__u8			uid[8];
353 	__u8			challenge[32];
354 } __packed;
355 
356 struct gb_cap_authenticate_response {
357 	__u8			result_code;
358 	__u8			response[64];
359 	__u8			signature[];
360 } __packed;
361 
362 
363 /* Bootrom Protocol */
364 
365 /* Version of the Greybus bootrom protocol we support */
366 #define GB_BOOTROM_VERSION_MAJOR		0x00
367 #define GB_BOOTROM_VERSION_MINOR		0x01
368 
369 /* Greybus bootrom request types */
370 #define GB_BOOTROM_TYPE_VERSION			0x01
371 #define GB_BOOTROM_TYPE_FIRMWARE_SIZE		0x02
372 #define GB_BOOTROM_TYPE_GET_FIRMWARE		0x03
373 #define GB_BOOTROM_TYPE_READY_TO_BOOT		0x04
374 #define GB_BOOTROM_TYPE_AP_READY		0x05	/* Request with no-payload */
375 #define GB_BOOTROM_TYPE_GET_VID_PID		0x06	/* Request with no-payload */
376 
377 /* Greybus bootrom boot stages */
378 #define GB_BOOTROM_BOOT_STAGE_ONE		0x01 /* Reserved for the boot ROM */
379 #define GB_BOOTROM_BOOT_STAGE_TWO		0x02 /* Bootrom package to be loaded by the boot ROM */
380 #define GB_BOOTROM_BOOT_STAGE_THREE		0x03 /* Module personality package loaded by Stage 2 firmware */
381 
382 /* Greybus bootrom ready to boot status */
383 #define GB_BOOTROM_BOOT_STATUS_INVALID		0x00 /* Firmware blob could not be validated */
384 #define GB_BOOTROM_BOOT_STATUS_INSECURE		0x01 /* Firmware blob is valid but insecure */
385 #define GB_BOOTROM_BOOT_STATUS_SECURE		0x02 /* Firmware blob is valid and secure */
386 
387 /* Max bootrom data fetch size in bytes */
388 #define GB_BOOTROM_FETCH_MAX			2000
389 
390 struct gb_bootrom_version_request {
391 	__u8	major;
392 	__u8	minor;
393 } __packed;
394 
395 struct gb_bootrom_version_response {
396 	__u8	major;
397 	__u8	minor;
398 } __packed;
399 
400 /* Bootrom protocol firmware size request/response */
401 struct gb_bootrom_firmware_size_request {
402 	__u8			stage;
403 } __packed;
404 
405 struct gb_bootrom_firmware_size_response {
406 	__le32			size;
407 } __packed;
408 
409 /* Bootrom protocol get firmware request/response */
410 struct gb_bootrom_get_firmware_request {
411 	__le32			offset;
412 	__le32			size;
413 } __packed;
414 
415 /* gb_bootrom_get_firmware_response contains no other data */
416 
417 /* Bootrom protocol Ready to boot request */
418 struct gb_bootrom_ready_to_boot_request {
419 	__u8			status;
420 } __packed;
421 /* Bootrom protocol Ready to boot response has no payload */
422 
423 /* Bootrom protocol get VID/PID request has no payload */
424 struct gb_bootrom_get_vid_pid_response {
425 	__le32			vendor_id;
426 	__le32			product_id;
427 } __packed;
428 
429 
430 /* Power Supply */
431 
432 /* Greybus power supply request types */
433 #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES		0x02
434 #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION		0x03
435 #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS	0x04
436 #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY		0x05
437 #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY		0x06
438 #define GB_POWER_SUPPLY_TYPE_EVENT			0x07
439 
440 /* Greybus power supply battery technologies types */
441 #define GB_POWER_SUPPLY_TECH_UNKNOWN			0x0000
442 #define GB_POWER_SUPPLY_TECH_NiMH			0x0001
443 #define GB_POWER_SUPPLY_TECH_LION			0x0002
444 #define GB_POWER_SUPPLY_TECH_LIPO			0x0003
445 #define GB_POWER_SUPPLY_TECH_LiFe			0x0004
446 #define GB_POWER_SUPPLY_TECH_NiCd			0x0005
447 #define GB_POWER_SUPPLY_TECH_LiMn			0x0006
448 
449 /* Greybus power supply types */
450 #define GB_POWER_SUPPLY_UNKNOWN_TYPE			0x0000
451 #define GB_POWER_SUPPLY_BATTERY_TYPE			0x0001
452 #define GB_POWER_SUPPLY_UPS_TYPE			0x0002
453 #define GB_POWER_SUPPLY_MAINS_TYPE			0x0003
454 #define GB_POWER_SUPPLY_USB_TYPE			0x0004
455 #define GB_POWER_SUPPLY_USB_DCP_TYPE			0x0005
456 #define GB_POWER_SUPPLY_USB_CDP_TYPE			0x0006
457 #define GB_POWER_SUPPLY_USB_ACA_TYPE			0x0007
458 
459 /* Greybus power supply health values */
460 #define GB_POWER_SUPPLY_HEALTH_UNKNOWN			0x0000
461 #define GB_POWER_SUPPLY_HEALTH_GOOD			0x0001
462 #define GB_POWER_SUPPLY_HEALTH_OVERHEAT			0x0002
463 #define GB_POWER_SUPPLY_HEALTH_DEAD			0x0003
464 #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE		0x0004
465 #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE		0x0005
466 #define GB_POWER_SUPPLY_HEALTH_COLD			0x0006
467 #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE	0x0007
468 #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE	0x0008
469 
470 /* Greybus power supply status values */
471 #define GB_POWER_SUPPLY_STATUS_UNKNOWN			0x0000
472 #define GB_POWER_SUPPLY_STATUS_CHARGING			0x0001
473 #define GB_POWER_SUPPLY_STATUS_DISCHARGING		0x0002
474 #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING		0x0003
475 #define GB_POWER_SUPPLY_STATUS_FULL			0x0004
476 
477 /* Greybus power supply capacity level values */
478 #define GB_POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN		0x0000
479 #define GB_POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL		0x0001
480 #define GB_POWER_SUPPLY_CAPACITY_LEVEL_LOW		0x0002
481 #define GB_POWER_SUPPLY_CAPACITY_LEVEL_NORMAL		0x0003
482 #define GB_POWER_SUPPLY_CAPACITY_LEVEL_HIGH		0x0004
483 #define GB_POWER_SUPPLY_CAPACITY_LEVEL_FULL		0x0005
484 
485 /* Greybus power supply scope values */
486 #define GB_POWER_SUPPLY_SCOPE_UNKNOWN			0x0000
487 #define GB_POWER_SUPPLY_SCOPE_SYSTEM			0x0001
488 #define GB_POWER_SUPPLY_SCOPE_DEVICE			0x0002
489 
490 struct gb_power_supply_get_supplies_response {
491 	__u8	supplies_count;
492 } __packed;
493 
494 struct gb_power_supply_get_description_request {
495 	__u8	psy_id;
496 } __packed;
497 
498 struct gb_power_supply_get_description_response {
499 	__u8	manufacturer[32];
500 	__u8	model[32];
501 	__u8	serial_number[32];
502 	__le16	type;
503 	__u8	properties_count;
504 } __packed;
505 
506 struct gb_power_supply_props_desc {
507 	__u8	property;
508 #define GB_POWER_SUPPLY_PROP_STATUS				0x00
509 #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE			0x01
510 #define GB_POWER_SUPPLY_PROP_HEALTH				0x02
511 #define GB_POWER_SUPPLY_PROP_PRESENT				0x03
512 #define GB_POWER_SUPPLY_PROP_ONLINE				0x04
513 #define GB_POWER_SUPPLY_PROP_AUTHENTIC				0x05
514 #define GB_POWER_SUPPLY_PROP_TECHNOLOGY				0x06
515 #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT			0x07
516 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX			0x08
517 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN			0x09
518 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN			0x0A
519 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN			0x0B
520 #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW			0x0C
521 #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG			0x0D
522 #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV			0x0E
523 #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT			0x0F
524 #define GB_POWER_SUPPLY_PROP_CURRENT_MAX			0x10
525 #define GB_POWER_SUPPLY_PROP_CURRENT_NOW			0x11
526 #define GB_POWER_SUPPLY_PROP_CURRENT_AVG			0x12
527 #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT			0x13
528 #define GB_POWER_SUPPLY_PROP_POWER_NOW				0x14
529 #define GB_POWER_SUPPLY_PROP_POWER_AVG				0x15
530 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN			0x16
531 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN		0x17
532 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL			0x18
533 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY			0x19
534 #define GB_POWER_SUPPLY_PROP_CHARGE_NOW				0x1A
535 #define GB_POWER_SUPPLY_PROP_CHARGE_AVG				0x1B
536 #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER			0x1C
537 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT		0x1D
538 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX	0x1E
539 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE		0x1F
540 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX	0x20
541 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT		0x21
542 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX		0x22
543 #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT		0x23
544 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN			0x24
545 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN		0x25
546 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL			0x26
547 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY			0x27
548 #define GB_POWER_SUPPLY_PROP_ENERGY_NOW				0x28
549 #define GB_POWER_SUPPLY_PROP_ENERGY_AVG				0x29
550 #define GB_POWER_SUPPLY_PROP_CAPACITY				0x2A
551 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN			0x2B
552 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX			0x2C
553 #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL			0x2D
554 #define GB_POWER_SUPPLY_PROP_TEMP				0x2E
555 #define GB_POWER_SUPPLY_PROP_TEMP_MAX				0x2F
556 #define GB_POWER_SUPPLY_PROP_TEMP_MIN				0x30
557 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN			0x31
558 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX			0x32
559 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT			0x33
560 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN		0x34
561 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX		0x35
562 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW			0x36
563 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG			0x37
564 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW			0x38
565 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG			0x39
566 #define GB_POWER_SUPPLY_PROP_TYPE				0x3A
567 #define GB_POWER_SUPPLY_PROP_SCOPE				0x3B
568 #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT		0x3C
569 #define GB_POWER_SUPPLY_PROP_CALIBRATE				0x3D
570 	__u8	is_writeable;
571 } __packed;
572 
573 struct gb_power_supply_get_property_descriptors_request {
574 	__u8	psy_id;
575 } __packed;
576 
577 struct gb_power_supply_get_property_descriptors_response {
578 	__u8	properties_count;
579 	struct gb_power_supply_props_desc props[];
580 } __packed;
581 
582 struct gb_power_supply_get_property_request {
583 	__u8	psy_id;
584 	__u8	property;
585 } __packed;
586 
587 struct gb_power_supply_get_property_response {
588 	__le32	prop_val;
589 };
590 
591 struct gb_power_supply_set_property_request {
592 	__u8	psy_id;
593 	__u8	property;
594 	__le32	prop_val;
595 } __packed;
596 
597 struct gb_power_supply_event_request {
598 	__u8	psy_id;
599 	__u8	event;
600 #define GB_POWER_SUPPLY_UPDATE		0x01
601 } __packed;
602 
603 
604 /* HID */
605 
606 /* Greybus HID operation types */
607 #define GB_HID_TYPE_GET_DESC		0x02
608 #define GB_HID_TYPE_GET_REPORT_DESC	0x03
609 #define GB_HID_TYPE_PWR_ON		0x04
610 #define GB_HID_TYPE_PWR_OFF		0x05
611 #define GB_HID_TYPE_GET_REPORT		0x06
612 #define GB_HID_TYPE_SET_REPORT		0x07
613 #define GB_HID_TYPE_IRQ_EVENT		0x08
614 
615 /* Report type */
616 #define GB_HID_INPUT_REPORT		0
617 #define GB_HID_OUTPUT_REPORT		1
618 #define GB_HID_FEATURE_REPORT		2
619 
620 /* Different request/response structures */
621 /* HID get descriptor response */
622 struct gb_hid_desc_response {
623 	__u8				bLength;
624 	__le16				wReportDescLength;
625 	__le16				bcdHID;
626 	__le16				wProductID;
627 	__le16				wVendorID;
628 	__u8				bCountryCode;
629 } __packed;
630 
631 /* HID get report request/response */
632 struct gb_hid_get_report_request {
633 	__u8				report_type;
634 	__u8				report_id;
635 } __packed;
636 
637 /* HID set report request */
638 struct gb_hid_set_report_request {
639 	__u8				report_type;
640 	__u8				report_id;
641 	__u8				report[];
642 } __packed;
643 
644 /* HID input report request, via interrupt pipe */
645 struct gb_hid_input_report_request {
646 	__u8				report[0];
647 } __packed;
648 
649 
650 /* I2C */
651 
652 /* Greybus i2c request types */
653 #define GB_I2C_TYPE_FUNCTIONALITY	0x02
654 #define GB_I2C_TYPE_TRANSFER		0x05
655 
656 /* functionality request has no payload */
657 struct gb_i2c_functionality_response {
658 	__le32	functionality;
659 } __packed;
660 
661 /*
662  * Outgoing data immediately follows the op count and ops array.
663  * The data for each write (master -> slave) op in the array is sent
664  * in order, with no (e.g. pad) bytes separating them.
665  *
666  * Short reads cause the entire transfer request to fail So response
667  * payload consists only of bytes read, and the number of bytes is
668  * exactly what was specified in the corresponding op.  Like
669  * outgoing data, the incoming data is in order and contiguous.
670  */
671 struct gb_i2c_transfer_op {
672 	__le16	addr;
673 	__le16	flags;
674 	__le16	size;
675 } __packed;
676 
677 struct gb_i2c_transfer_request {
678 	__le16				op_count;
679 	struct gb_i2c_transfer_op	ops[];		/* op_count of these */
680 } __packed;
681 struct gb_i2c_transfer_response {
682 	__u8				data[0];	/* inbound data */
683 } __packed;
684 
685 
686 /* GPIO */
687 
688 /* Greybus GPIO request types */
689 #define GB_GPIO_TYPE_LINE_COUNT		0x02
690 #define GB_GPIO_TYPE_ACTIVATE		0x03
691 #define GB_GPIO_TYPE_DEACTIVATE		0x04
692 #define GB_GPIO_TYPE_GET_DIRECTION	0x05
693 #define GB_GPIO_TYPE_DIRECTION_IN	0x06
694 #define GB_GPIO_TYPE_DIRECTION_OUT	0x07
695 #define GB_GPIO_TYPE_GET_VALUE		0x08
696 #define GB_GPIO_TYPE_SET_VALUE		0x09
697 #define GB_GPIO_TYPE_SET_DEBOUNCE	0x0a
698 #define GB_GPIO_TYPE_IRQ_TYPE		0x0b
699 #define GB_GPIO_TYPE_IRQ_MASK		0x0c
700 #define GB_GPIO_TYPE_IRQ_UNMASK		0x0d
701 #define GB_GPIO_TYPE_IRQ_EVENT		0x0e
702 
703 #define GB_GPIO_IRQ_TYPE_NONE		0x00
704 #define GB_GPIO_IRQ_TYPE_EDGE_RISING	0x01
705 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING	0x02
706 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH	0x03
707 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH	0x04
708 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW	0x08
709 
710 /* line count request has no payload */
711 struct gb_gpio_line_count_response {
712 	__u8	count;
713 } __packed;
714 
715 struct gb_gpio_activate_request {
716 	__u8	which;
717 } __packed;
718 /* activate response has no payload */
719 
720 struct gb_gpio_deactivate_request {
721 	__u8	which;
722 } __packed;
723 /* deactivate response has no payload */
724 
725 struct gb_gpio_get_direction_request {
726 	__u8	which;
727 } __packed;
728 struct gb_gpio_get_direction_response {
729 	__u8	direction;
730 } __packed;
731 
732 struct gb_gpio_direction_in_request {
733 	__u8	which;
734 } __packed;
735 /* direction in response has no payload */
736 
737 struct gb_gpio_direction_out_request {
738 	__u8	which;
739 	__u8	value;
740 } __packed;
741 /* direction out response has no payload */
742 
743 struct gb_gpio_get_value_request {
744 	__u8	which;
745 } __packed;
746 struct gb_gpio_get_value_response {
747 	__u8	value;
748 } __packed;
749 
750 struct gb_gpio_set_value_request {
751 	__u8	which;
752 	__u8	value;
753 } __packed;
754 /* set value response has no payload */
755 
756 struct gb_gpio_set_debounce_request {
757 	__u8	which;
758 	__le16	usec;
759 } __packed;
760 /* debounce response has no payload */
761 
762 struct gb_gpio_irq_type_request {
763 	__u8	which;
764 	__u8	type;
765 } __packed;
766 /* irq type response has no payload */
767 
768 struct gb_gpio_irq_mask_request {
769 	__u8	which;
770 } __packed;
771 /* irq mask response has no payload */
772 
773 struct gb_gpio_irq_unmask_request {
774 	__u8	which;
775 } __packed;
776 /* irq unmask response has no payload */
777 
778 /* irq event requests originate on another module and are handled on the AP */
779 struct gb_gpio_irq_event_request {
780 	__u8	which;
781 } __packed;
782 /* irq event has no response */
783 
784 
785 /* PWM */
786 
787 /* Greybus PWM operation types */
788 #define GB_PWM_TYPE_PWM_COUNT		0x02
789 #define GB_PWM_TYPE_ACTIVATE		0x03
790 #define GB_PWM_TYPE_DEACTIVATE		0x04
791 #define GB_PWM_TYPE_CONFIG		0x05
792 #define GB_PWM_TYPE_POLARITY		0x06
793 #define GB_PWM_TYPE_ENABLE		0x07
794 #define GB_PWM_TYPE_DISABLE		0x08
795 
796 /* pwm count request has no payload */
797 struct gb_pwm_count_response {
798 	__u8	count;
799 } __packed;
800 
801 struct gb_pwm_activate_request {
802 	__u8	which;
803 } __packed;
804 
805 struct gb_pwm_deactivate_request {
806 	__u8	which;
807 } __packed;
808 
809 struct gb_pwm_config_request {
810 	__u8	which;
811 	__le32	duty;
812 	__le32	period;
813 } __packed;
814 
815 struct gb_pwm_polarity_request {
816 	__u8	which;
817 	__u8	polarity;
818 } __packed;
819 
820 struct gb_pwm_enable_request {
821 	__u8	which;
822 } __packed;
823 
824 struct gb_pwm_disable_request {
825 	__u8	which;
826 } __packed;
827 
828 /* SPI */
829 
830 /* Should match up with modes in linux/spi/spi.h */
831 #define GB_SPI_MODE_CPHA		0x01		/* clock phase */
832 #define GB_SPI_MODE_CPOL		0x02		/* clock polarity */
833 #define GB_SPI_MODE_MODE_0		(0 | 0)		/* (original MicroWire) */
834 #define GB_SPI_MODE_MODE_1		(0 | GB_SPI_MODE_CPHA)
835 #define GB_SPI_MODE_MODE_2		(GB_SPI_MODE_CPOL | 0)
836 #define GB_SPI_MODE_MODE_3		(GB_SPI_MODE_CPOL | GB_SPI_MODE_CPHA)
837 #define GB_SPI_MODE_CS_HIGH		0x04		/* chipselect active high? */
838 #define GB_SPI_MODE_LSB_FIRST		0x08		/* per-word bits-on-wire */
839 #define GB_SPI_MODE_3WIRE		0x10		/* SI/SO signals shared */
840 #define GB_SPI_MODE_LOOP		0x20		/* loopback mode */
841 #define GB_SPI_MODE_NO_CS		0x40		/* 1 dev/bus, no chipselect */
842 #define GB_SPI_MODE_READY		0x80		/* slave pulls low to pause */
843 
844 /* Should match up with flags in linux/spi/spi.h */
845 #define GB_SPI_FLAG_HALF_DUPLEX		BIT(0)		/* can't do full duplex */
846 #define GB_SPI_FLAG_NO_RX		BIT(1)		/* can't do buffer read */
847 #define GB_SPI_FLAG_NO_TX		BIT(2)		/* can't do buffer write */
848 
849 /* Greybus spi operation types */
850 #define GB_SPI_TYPE_MASTER_CONFIG	0x02
851 #define GB_SPI_TYPE_DEVICE_CONFIG	0x03
852 #define GB_SPI_TYPE_TRANSFER		0x04
853 
854 /* mode request has no payload */
855 struct gb_spi_master_config_response {
856 	__le32	bits_per_word_mask;
857 	__le32	min_speed_hz;
858 	__le32	max_speed_hz;
859 	__le16	mode;
860 	__le16	flags;
861 	__u8	num_chipselect;
862 } __packed;
863 
864 struct gb_spi_device_config_request {
865 	__u8	chip_select;
866 } __packed;
867 
868 struct gb_spi_device_config_response {
869 	__le16	mode;
870 	__u8	bits_per_word;
871 	__le32	max_speed_hz;
872 	__u8	device_type;
873 #define GB_SPI_SPI_DEV		0x00
874 #define GB_SPI_SPI_NOR		0x01
875 #define GB_SPI_SPI_MODALIAS	0x02
876 	__u8	name[32];
877 } __packed;
878 
879 /**
880  * struct gb_spi_transfer - a read/write buffer pair
881  * @speed_hz: Select a speed other than the device default for this transfer. If
882  *	0 the default (from @spi_device) is used.
883  * @len: size of rx and tx buffers (in bytes)
884  * @delay_usecs: microseconds to delay after this transfer before (optionally)
885  * 	changing the chipselect status, then starting the next transfer or
886  * 	completing this spi_message.
887  * @cs_change: affects chipselect after this transfer completes
888  * @bits_per_word: select a bits_per_word other than the device default for this
889  *	transfer. If 0 the default (from @spi_device) is used.
890  */
891 struct gb_spi_transfer {
892 	__le32		speed_hz;
893 	__le32		len;
894 	__le16		delay_usecs;
895 	__u8		cs_change;
896 	__u8		bits_per_word;
897 	__u8		xfer_flags;
898 #define GB_SPI_XFER_READ	0x01
899 #define GB_SPI_XFER_WRITE	0x02
900 #define GB_SPI_XFER_INPROGRESS	0x04
901 } __packed;
902 
903 struct gb_spi_transfer_request {
904 	__u8			chip_select;	/* of the spi device */
905 	__u8			mode;		/* of the spi device */
906 	__le16			count;
907 	struct gb_spi_transfer	transfers[];	/* count of these */
908 } __packed;
909 
910 struct gb_spi_transfer_response {
911 	__u8			data[0];	/* inbound data */
912 } __packed;
913 
914 /* Version of the Greybus SVC protocol we support */
915 #define GB_SVC_VERSION_MAJOR		0x00
916 #define GB_SVC_VERSION_MINOR		0x01
917 
918 /* Greybus SVC request types */
919 #define GB_SVC_TYPE_PROTOCOL_VERSION		0x01
920 #define GB_SVC_TYPE_SVC_HELLO			0x02
921 #define GB_SVC_TYPE_INTF_DEVICE_ID		0x03
922 #define GB_SVC_TYPE_INTF_RESET			0x06
923 #define GB_SVC_TYPE_CONN_CREATE			0x07
924 #define GB_SVC_TYPE_CONN_DESTROY		0x08
925 #define GB_SVC_TYPE_DME_PEER_GET		0x09
926 #define GB_SVC_TYPE_DME_PEER_SET		0x0a
927 #define GB_SVC_TYPE_ROUTE_CREATE		0x0b
928 #define GB_SVC_TYPE_ROUTE_DESTROY		0x0c
929 #define GB_SVC_TYPE_TIMESYNC_ENABLE		0x0d
930 #define GB_SVC_TYPE_TIMESYNC_DISABLE		0x0e
931 #define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE	0x0f
932 #define GB_SVC_TYPE_INTF_SET_PWRM		0x10
933 #define GB_SVC_TYPE_INTF_EJECT			0x11
934 #define GB_SVC_TYPE_PING			0x13
935 #define GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET	0x14
936 #define GB_SVC_TYPE_PWRMON_RAIL_NAMES_GET	0x15
937 #define GB_SVC_TYPE_PWRMON_SAMPLE_GET		0x16
938 #define GB_SVC_TYPE_PWRMON_INTF_SAMPLE_GET	0x17
939 #define GB_SVC_TYPE_TIMESYNC_WAKE_PINS_ACQUIRE	0x18
940 #define GB_SVC_TYPE_TIMESYNC_WAKE_PINS_RELEASE	0x19
941 #define GB_SVC_TYPE_TIMESYNC_PING		0x1a
942 #define GB_SVC_TYPE_MODULE_INSERTED		0x1f
943 #define GB_SVC_TYPE_MODULE_REMOVED		0x20
944 #define GB_SVC_TYPE_INTF_VSYS_ENABLE		0x21
945 #define GB_SVC_TYPE_INTF_VSYS_DISABLE		0x22
946 #define GB_SVC_TYPE_INTF_REFCLK_ENABLE		0x23
947 #define GB_SVC_TYPE_INTF_REFCLK_DISABLE		0x24
948 #define GB_SVC_TYPE_INTF_UNIPRO_ENABLE		0x25
949 #define GB_SVC_TYPE_INTF_UNIPRO_DISABLE		0x26
950 #define GB_SVC_TYPE_INTF_ACTIVATE		0x27
951 #define GB_SVC_TYPE_INTF_RESUME			0x28
952 #define GB_SVC_TYPE_INTF_MAILBOX_EVENT		0x29
953 #define GB_SVC_TYPE_INTF_OOPS			0x2a
954 
955 /* Greybus SVC protocol status values */
956 #define GB_SVC_OP_SUCCESS			0x00
957 #define GB_SVC_OP_UNKNOWN_ERROR			0x01
958 #define GB_SVC_INTF_NOT_DETECTED		0x02
959 #define GB_SVC_INTF_NO_UPRO_LINK		0x03
960 #define GB_SVC_INTF_UPRO_NOT_DOWN		0x04
961 #define GB_SVC_INTF_UPRO_NOT_HIBERNATED		0x05
962 #define GB_SVC_INTF_NO_V_SYS			0x06
963 #define GB_SVC_INTF_V_CHG			0x07
964 #define GB_SVC_INTF_WAKE_BUSY			0x08
965 #define GB_SVC_INTF_NO_REFCLK			0x09
966 #define GB_SVC_INTF_RELEASING			0x0a
967 #define GB_SVC_INTF_NO_ORDER			0x0b
968 #define GB_SVC_INTF_MBOX_SET			0x0c
969 #define GB_SVC_INTF_BAD_MBOX			0x0d
970 #define GB_SVC_INTF_OP_TIMEOUT			0x0e
971 #define GB_SVC_PWRMON_OP_NOT_PRESENT		0x0f
972 
973 struct gb_svc_version_request {
974 	__u8	major;
975 	__u8	minor;
976 } __packed;
977 
978 struct gb_svc_version_response {
979 	__u8	major;
980 	__u8	minor;
981 } __packed;
982 
983 /* SVC protocol hello request */
984 struct gb_svc_hello_request {
985 	__le16			endo_id;
986 	__u8			interface_id;
987 } __packed;
988 /* hello response has no payload */
989 
990 struct gb_svc_intf_device_id_request {
991 	__u8	intf_id;
992 	__u8	device_id;
993 } __packed;
994 /* device id response has no payload */
995 
996 struct gb_svc_intf_reset_request {
997 	__u8	intf_id;
998 } __packed;
999 /* interface reset response has no payload */
1000 
1001 struct gb_svc_intf_eject_request {
1002 	__u8	intf_id;
1003 } __packed;
1004 /* interface eject response has no payload */
1005 
1006 struct gb_svc_conn_create_request {
1007 	__u8	intf1_id;
1008 	__le16	cport1_id;
1009 	__u8	intf2_id;
1010 	__le16	cport2_id;
1011 	__u8	tc;
1012 	__u8	flags;
1013 } __packed;
1014 /* connection create response has no payload */
1015 
1016 struct gb_svc_conn_destroy_request {
1017 	__u8	intf1_id;
1018 	__le16	cport1_id;
1019 	__u8	intf2_id;
1020 	__le16	cport2_id;
1021 } __packed;
1022 /* connection destroy response has no payload */
1023 
1024 struct gb_svc_dme_peer_get_request {
1025 	__u8	intf_id;
1026 	__le16	attr;
1027 	__le16	selector;
1028 } __packed;
1029 
1030 struct gb_svc_dme_peer_get_response {
1031 	__le16	result_code;
1032 	__le32	attr_value;
1033 } __packed;
1034 
1035 struct gb_svc_dme_peer_set_request {
1036 	__u8	intf_id;
1037 	__le16	attr;
1038 	__le16	selector;
1039 	__le32	value;
1040 } __packed;
1041 
1042 struct gb_svc_dme_peer_set_response {
1043 	__le16	result_code;
1044 } __packed;
1045 
1046 /* Greybus init-status values, currently retrieved using DME peer gets. */
1047 #define GB_INIT_SPI_BOOT_STARTED			0x02
1048 #define GB_INIT_TRUSTED_SPI_BOOT_FINISHED		0x03
1049 #define GB_INIT_UNTRUSTED_SPI_BOOT_FINISHED		0x04
1050 #define GB_INIT_BOOTROM_UNIPRO_BOOT_STARTED		0x06
1051 #define GB_INIT_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED	0x09
1052 #define GB_INIT_S2_LOADER_BOOT_STARTED			0x0D
1053 
1054 struct gb_svc_route_create_request {
1055 	__u8	intf1_id;
1056 	__u8	dev1_id;
1057 	__u8	intf2_id;
1058 	__u8	dev2_id;
1059 } __packed;
1060 /* route create response has no payload */
1061 
1062 struct gb_svc_route_destroy_request {
1063 	__u8	intf1_id;
1064 	__u8	intf2_id;
1065 } __packed;
1066 /* route destroy response has no payload */
1067 
1068 /* used for svc_intf_vsys_{enable,disable} */
1069 struct gb_svc_intf_vsys_request {
1070 	__u8	intf_id;
1071 } __packed;
1072 
1073 struct gb_svc_intf_vsys_response {
1074 	__u8	result_code;
1075 #define GB_SVC_INTF_VSYS_OK				0x00
1076 	/* 0x01 is reserved */
1077 #define GB_SVC_INTF_VSYS_FAIL				0x02
1078 } __packed;
1079 
1080 /* used for svc_intf_refclk_{enable,disable} */
1081 struct gb_svc_intf_refclk_request {
1082 	__u8	intf_id;
1083 } __packed;
1084 
1085 struct gb_svc_intf_refclk_response {
1086 	__u8	result_code;
1087 #define GB_SVC_INTF_REFCLK_OK				0x00
1088 	/* 0x01 is reserved */
1089 #define GB_SVC_INTF_REFCLK_FAIL				0x02
1090 } __packed;
1091 
1092 /* used for svc_intf_unipro_{enable,disable} */
1093 struct gb_svc_intf_unipro_request {
1094 	__u8	intf_id;
1095 } __packed;
1096 
1097 struct gb_svc_intf_unipro_response {
1098 	__u8	result_code;
1099 #define GB_SVC_INTF_UNIPRO_OK				0x00
1100 	/* 0x01 is reserved */
1101 #define GB_SVC_INTF_UNIPRO_FAIL				0x02
1102 #define GB_SVC_INTF_UNIPRO_NOT_OFF			0x03
1103 } __packed;
1104 
1105 #define GB_SVC_UNIPRO_FAST_MODE			0x01
1106 #define GB_SVC_UNIPRO_SLOW_MODE			0x02
1107 #define GB_SVC_UNIPRO_FAST_AUTO_MODE		0x04
1108 #define GB_SVC_UNIPRO_SLOW_AUTO_MODE		0x05
1109 #define GB_SVC_UNIPRO_MODE_UNCHANGED		0x07
1110 #define GB_SVC_UNIPRO_HIBERNATE_MODE		0x11
1111 #define GB_SVC_UNIPRO_OFF_MODE			0x12
1112 
1113 #define GB_SVC_SMALL_AMPLITUDE          0x01
1114 #define GB_SVC_LARGE_AMPLITUDE          0x02
1115 
1116 #define GB_SVC_NO_DE_EMPHASIS           0x00
1117 #define GB_SVC_SMALL_DE_EMPHASIS        0x01
1118 #define GB_SVC_LARGE_DE_EMPHASIS        0x02
1119 
1120 #define GB_SVC_PWRM_RXTERMINATION		0x01
1121 #define GB_SVC_PWRM_TXTERMINATION		0x02
1122 #define GB_SVC_PWRM_LINE_RESET			0x04
1123 #define GB_SVC_PWRM_SCRAMBLING			0x20
1124 
1125 #define GB_SVC_PWRM_QUIRK_HSSER			0x00000001
1126 
1127 #define GB_SVC_UNIPRO_HS_SERIES_A		0x01
1128 #define GB_SVC_UNIPRO_HS_SERIES_B		0x02
1129 
1130 #define GB_SVC_SETPWRM_PWR_OK           0x00
1131 #define GB_SVC_SETPWRM_PWR_LOCAL        0x01
1132 #define GB_SVC_SETPWRM_PWR_REMOTE       0x02
1133 #define GB_SVC_SETPWRM_PWR_BUSY         0x03
1134 #define GB_SVC_SETPWRM_PWR_ERROR_CAP    0x04
1135 #define GB_SVC_SETPWRM_PWR_FATAL_ERROR  0x05
1136 
1137 struct gb_svc_l2_timer_cfg {
1138 	__le16 tsb_fc0_protection_timeout;
1139 	__le16 tsb_tc0_replay_timeout;
1140 	__le16 tsb_afc0_req_timeout;
1141 	__le16 tsb_fc1_protection_timeout;
1142 	__le16 tsb_tc1_replay_timeout;
1143 	__le16 tsb_afc1_req_timeout;
1144 	__le16 reserved_for_tc2[3];
1145 	__le16 reserved_for_tc3[3];
1146 } __packed;
1147 
1148 struct gb_svc_intf_set_pwrm_request {
1149 	__u8	intf_id;
1150 	__u8	hs_series;
1151 	__u8	tx_mode;
1152 	__u8	tx_gear;
1153 	__u8	tx_nlanes;
1154 	__u8	tx_amplitude;
1155 	__u8	tx_hs_equalizer;
1156 	__u8	rx_mode;
1157 	__u8	rx_gear;
1158 	__u8	rx_nlanes;
1159 	__u8	flags;
1160 	__le32	quirks;
1161 	struct gb_svc_l2_timer_cfg local_l2timerdata, remote_l2timerdata;
1162 } __packed;
1163 
1164 struct gb_svc_intf_set_pwrm_response {
1165 	__u8	result_code;
1166 } __packed;
1167 
1168 struct gb_svc_key_event_request {
1169 	__le16  key_code;
1170 #define GB_KEYCODE_ARA         0x00
1171 
1172 	__u8    key_event;
1173 #define GB_SVC_KEY_RELEASED    0x00
1174 #define GB_SVC_KEY_PRESSED     0x01
1175 } __packed;
1176 
1177 #define GB_SVC_PWRMON_MAX_RAIL_COUNT		254
1178 
1179 struct gb_svc_pwrmon_rail_count_get_response {
1180 	__u8	rail_count;
1181 } __packed;
1182 
1183 #define GB_SVC_PWRMON_RAIL_NAME_BUFSIZE		32
1184 
1185 struct gb_svc_pwrmon_rail_names_get_response {
1186 	__u8	status;
1187 	__u8	name[][GB_SVC_PWRMON_RAIL_NAME_BUFSIZE];
1188 } __packed;
1189 
1190 #define GB_SVC_PWRMON_TYPE_CURR			0x01
1191 #define GB_SVC_PWRMON_TYPE_VOL			0x02
1192 #define GB_SVC_PWRMON_TYPE_PWR			0x03
1193 
1194 #define GB_SVC_PWRMON_GET_SAMPLE_OK		0x00
1195 #define GB_SVC_PWRMON_GET_SAMPLE_INVAL		0x01
1196 #define GB_SVC_PWRMON_GET_SAMPLE_NOSUPP		0x02
1197 #define GB_SVC_PWRMON_GET_SAMPLE_HWERR		0x03
1198 
1199 struct gb_svc_pwrmon_sample_get_request {
1200 	__u8	rail_id;
1201 	__u8	measurement_type;
1202 } __packed;
1203 
1204 struct gb_svc_pwrmon_sample_get_response {
1205 	__u8	result;
1206 	__le32	measurement;
1207 } __packed;
1208 
1209 struct gb_svc_pwrmon_intf_sample_get_request {
1210 	__u8	intf_id;
1211 	__u8	measurement_type;
1212 } __packed;
1213 
1214 struct gb_svc_pwrmon_intf_sample_get_response {
1215 	__u8	result;
1216 	__le32	measurement;
1217 } __packed;
1218 
1219 #define GB_SVC_MODULE_INSERTED_FLAG_NO_PRIMARY	0x0001
1220 
1221 struct gb_svc_module_inserted_request {
1222 	__u8	primary_intf_id;
1223 	__u8	intf_count;
1224 	__le16	flags;
1225 } __packed;
1226 /* module_inserted response has no payload */
1227 
1228 struct gb_svc_module_removed_request {
1229 	__u8	primary_intf_id;
1230 } __packed;
1231 /* module_removed response has no payload */
1232 
1233 struct gb_svc_intf_activate_request {
1234 	__u8	intf_id;
1235 } __packed;
1236 
1237 #define GB_SVC_INTF_TYPE_UNKNOWN		0x00
1238 #define GB_SVC_INTF_TYPE_DUMMY			0x01
1239 #define GB_SVC_INTF_TYPE_UNIPRO			0x02
1240 #define GB_SVC_INTF_TYPE_GREYBUS		0x03
1241 
1242 struct gb_svc_intf_activate_response {
1243 	__u8	status;
1244 	__u8	intf_type;
1245 } __packed;
1246 
1247 struct gb_svc_intf_resume_request {
1248 	__u8	intf_id;
1249 } __packed;
1250 
1251 struct gb_svc_intf_resume_response {
1252 	__u8	status;
1253 } __packed;
1254 
1255 #define GB_SVC_INTF_MAILBOX_NONE		0x00
1256 #define GB_SVC_INTF_MAILBOX_AP			0x01
1257 #define GB_SVC_INTF_MAILBOX_GREYBUS		0x02
1258 
1259 struct gb_svc_intf_mailbox_event_request {
1260 	__u8	intf_id;
1261 	__le16	result_code;
1262 	__le32	mailbox;
1263 } __packed;
1264 /* intf_mailbox_event response has no payload */
1265 
1266 struct gb_svc_intf_oops_request {
1267 	__u8	intf_id;
1268 	__u8	reason;
1269 } __packed;
1270 /* intf_oops response has no payload */
1271 
1272 
1273 /* RAW */
1274 
1275 /* Greybus raw request types */
1276 #define	GB_RAW_TYPE_SEND			0x02
1277 
1278 struct gb_raw_send_request {
1279 	__le32	len;
1280 	__u8	data[];
1281 } __packed;
1282 
1283 
1284 /* UART */
1285 
1286 /* Greybus UART operation types */
1287 #define GB_UART_TYPE_SEND_DATA			0x02
1288 #define GB_UART_TYPE_RECEIVE_DATA		0x03	/* Unsolicited data */
1289 #define GB_UART_TYPE_SET_LINE_CODING		0x04
1290 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE	0x05
1291 #define GB_UART_TYPE_SEND_BREAK			0x06
1292 #define GB_UART_TYPE_SERIAL_STATE		0x07	/* Unsolicited data */
1293 #define GB_UART_TYPE_RECEIVE_CREDITS		0x08
1294 #define GB_UART_TYPE_FLUSH_FIFOS		0x09
1295 
1296 /* Represents data from AP -> Module */
1297 struct gb_uart_send_data_request {
1298 	__le16	size;
1299 	__u8	data[];
1300 } __packed;
1301 
1302 /* recv-data-request flags */
1303 #define GB_UART_RECV_FLAG_FRAMING		0x01	/* Framing error */
1304 #define GB_UART_RECV_FLAG_PARITY		0x02	/* Parity error */
1305 #define GB_UART_RECV_FLAG_OVERRUN		0x04	/* Overrun error */
1306 #define GB_UART_RECV_FLAG_BREAK			0x08	/* Break */
1307 
1308 /* Represents data from Module -> AP */
1309 struct gb_uart_recv_data_request {
1310 	__le16	size;
1311 	__u8	flags;
1312 	__u8	data[];
1313 } __packed;
1314 
1315 struct gb_uart_receive_credits_request {
1316 	__le16  count;
1317 } __packed;
1318 
1319 struct gb_uart_set_line_coding_request {
1320 	__le32	rate;
1321 	__u8	format;
1322 #define GB_SERIAL_1_STOP_BITS			0
1323 #define GB_SERIAL_1_5_STOP_BITS			1
1324 #define GB_SERIAL_2_STOP_BITS			2
1325 
1326 	__u8	parity;
1327 #define GB_SERIAL_NO_PARITY			0
1328 #define GB_SERIAL_ODD_PARITY			1
1329 #define GB_SERIAL_EVEN_PARITY			2
1330 #define GB_SERIAL_MARK_PARITY			3
1331 #define GB_SERIAL_SPACE_PARITY			4
1332 
1333 	__u8	data_bits;
1334 
1335 	__u8	flow_control;
1336 #define GB_SERIAL_AUTO_RTSCTS_EN		0x1
1337 } __packed;
1338 
1339 /* output control lines */
1340 #define GB_UART_CTRL_DTR			0x01
1341 #define GB_UART_CTRL_RTS			0x02
1342 
1343 struct gb_uart_set_control_line_state_request {
1344 	__u8	control;
1345 } __packed;
1346 
1347 struct gb_uart_set_break_request {
1348 	__u8	state;
1349 } __packed;
1350 
1351 /* input control lines and line errors */
1352 #define GB_UART_CTRL_DCD			0x01
1353 #define GB_UART_CTRL_DSR			0x02
1354 #define GB_UART_CTRL_RI				0x04
1355 
1356 struct gb_uart_serial_state_request {
1357 	__u8	control;
1358 } __packed;
1359 
1360 struct gb_uart_serial_flush_request {
1361 	__u8    flags;
1362 #define GB_SERIAL_FLAG_FLUSH_TRANSMITTER	0x01
1363 #define GB_SERIAL_FLAG_FLUSH_RECEIVER		0x02
1364 } __packed;
1365 
1366 /* Loopback */
1367 
1368 /* Greybus loopback request types */
1369 #define GB_LOOPBACK_TYPE_PING			0x02
1370 #define GB_LOOPBACK_TYPE_TRANSFER		0x03
1371 #define GB_LOOPBACK_TYPE_SINK			0x04
1372 
1373 /*
1374  * Loopback request/response header format should be identical
1375  * to simplify bandwidth and data movement analysis.
1376  */
1377 struct gb_loopback_transfer_request {
1378 	__le32	len;
1379 	__le32  reserved0;
1380 	__le32  reserved1;
1381 	__u8	data[];
1382 } __packed;
1383 
1384 struct gb_loopback_transfer_response {
1385 	__le32	len;
1386 	__le32	reserved0;
1387 	__le32	reserved1;
1388 	__u8	data[];
1389 } __packed;
1390 
1391 /* SDIO */
1392 /* Greybus SDIO operation types */
1393 #define GB_SDIO_TYPE_GET_CAPABILITIES		0x02
1394 #define GB_SDIO_TYPE_SET_IOS			0x03
1395 #define GB_SDIO_TYPE_COMMAND			0x04
1396 #define GB_SDIO_TYPE_TRANSFER			0x05
1397 #define GB_SDIO_TYPE_EVENT			0x06
1398 
1399 /* get caps response: request has no payload */
1400 struct gb_sdio_get_caps_response {
1401 	__le32	caps;
1402 #define GB_SDIO_CAP_NONREMOVABLE	0x00000001
1403 #define GB_SDIO_CAP_4_BIT_DATA		0x00000002
1404 #define GB_SDIO_CAP_8_BIT_DATA		0x00000004
1405 #define GB_SDIO_CAP_MMC_HS		0x00000008
1406 #define GB_SDIO_CAP_SD_HS		0x00000010
1407 #define GB_SDIO_CAP_ERASE		0x00000020
1408 #define GB_SDIO_CAP_1_2V_DDR		0x00000040
1409 #define GB_SDIO_CAP_1_8V_DDR		0x00000080
1410 #define GB_SDIO_CAP_POWER_OFF_CARD	0x00000100
1411 #define GB_SDIO_CAP_UHS_SDR12		0x00000200
1412 #define GB_SDIO_CAP_UHS_SDR25		0x00000400
1413 #define GB_SDIO_CAP_UHS_SDR50		0x00000800
1414 #define GB_SDIO_CAP_UHS_SDR104		0x00001000
1415 #define GB_SDIO_CAP_UHS_DDR50		0x00002000
1416 #define GB_SDIO_CAP_DRIVER_TYPE_A	0x00004000
1417 #define GB_SDIO_CAP_DRIVER_TYPE_C	0x00008000
1418 #define GB_SDIO_CAP_DRIVER_TYPE_D	0x00010000
1419 #define GB_SDIO_CAP_HS200_1_2V		0x00020000
1420 #define GB_SDIO_CAP_HS200_1_8V		0x00040000
1421 #define GB_SDIO_CAP_HS400_1_2V		0x00080000
1422 #define GB_SDIO_CAP_HS400_1_8V		0x00100000
1423 
1424 	/* see possible values below at vdd */
1425 	__le32 ocr;
1426 	__le32 f_min;
1427 	__le32 f_max;
1428 	__le16 max_blk_count;
1429 	__le16 max_blk_size;
1430 } __packed;
1431 
1432 /* set ios request: response has no payload */
1433 struct gb_sdio_set_ios_request {
1434 	__le32	clock;
1435 	__le32	vdd;
1436 #define GB_SDIO_VDD_165_195	0x00000001
1437 #define GB_SDIO_VDD_20_21	0x00000002
1438 #define GB_SDIO_VDD_21_22	0x00000004
1439 #define GB_SDIO_VDD_22_23	0x00000008
1440 #define GB_SDIO_VDD_23_24	0x00000010
1441 #define GB_SDIO_VDD_24_25	0x00000020
1442 #define GB_SDIO_VDD_25_26	0x00000040
1443 #define GB_SDIO_VDD_26_27	0x00000080
1444 #define GB_SDIO_VDD_27_28	0x00000100
1445 #define GB_SDIO_VDD_28_29	0x00000200
1446 #define GB_SDIO_VDD_29_30	0x00000400
1447 #define GB_SDIO_VDD_30_31	0x00000800
1448 #define GB_SDIO_VDD_31_32	0x00001000
1449 #define GB_SDIO_VDD_32_33	0x00002000
1450 #define GB_SDIO_VDD_33_34	0x00004000
1451 #define GB_SDIO_VDD_34_35	0x00008000
1452 #define GB_SDIO_VDD_35_36	0x00010000
1453 
1454 	__u8	bus_mode;
1455 #define GB_SDIO_BUSMODE_OPENDRAIN	0x00
1456 #define GB_SDIO_BUSMODE_PUSHPULL	0x01
1457 
1458 	__u8	power_mode;
1459 #define GB_SDIO_POWER_OFF	0x00
1460 #define GB_SDIO_POWER_UP	0x01
1461 #define GB_SDIO_POWER_ON	0x02
1462 #define GB_SDIO_POWER_UNDEFINED	0x03
1463 
1464 	__u8	bus_width;
1465 #define GB_SDIO_BUS_WIDTH_1	0x00
1466 #define GB_SDIO_BUS_WIDTH_4	0x02
1467 #define GB_SDIO_BUS_WIDTH_8	0x03
1468 
1469 	__u8	timing;
1470 #define GB_SDIO_TIMING_LEGACY		0x00
1471 #define GB_SDIO_TIMING_MMC_HS		0x01
1472 #define GB_SDIO_TIMING_SD_HS		0x02
1473 #define GB_SDIO_TIMING_UHS_SDR12	0x03
1474 #define GB_SDIO_TIMING_UHS_SDR25	0x04
1475 #define GB_SDIO_TIMING_UHS_SDR50	0x05
1476 #define GB_SDIO_TIMING_UHS_SDR104	0x06
1477 #define GB_SDIO_TIMING_UHS_DDR50	0x07
1478 #define GB_SDIO_TIMING_MMC_DDR52	0x08
1479 #define GB_SDIO_TIMING_MMC_HS200	0x09
1480 #define GB_SDIO_TIMING_MMC_HS400	0x0A
1481 
1482 	__u8	signal_voltage;
1483 #define GB_SDIO_SIGNAL_VOLTAGE_330	0x00
1484 #define GB_SDIO_SIGNAL_VOLTAGE_180	0x01
1485 #define GB_SDIO_SIGNAL_VOLTAGE_120	0x02
1486 
1487 	__u8	drv_type;
1488 #define GB_SDIO_SET_DRIVER_TYPE_B	0x00
1489 #define GB_SDIO_SET_DRIVER_TYPE_A	0x01
1490 #define GB_SDIO_SET_DRIVER_TYPE_C	0x02
1491 #define GB_SDIO_SET_DRIVER_TYPE_D	0x03
1492 } __packed;
1493 
1494 /* command request */
1495 struct gb_sdio_command_request {
1496 	__u8	cmd;
1497 	__u8	cmd_flags;
1498 #define GB_SDIO_RSP_NONE		0x00
1499 #define GB_SDIO_RSP_PRESENT		0x01
1500 #define GB_SDIO_RSP_136			0x02
1501 #define GB_SDIO_RSP_CRC			0x04
1502 #define GB_SDIO_RSP_BUSY		0x08
1503 #define GB_SDIO_RSP_OPCODE		0x10
1504 
1505 	__u8	cmd_type;
1506 #define GB_SDIO_CMD_AC		0x00
1507 #define GB_SDIO_CMD_ADTC	0x01
1508 #define GB_SDIO_CMD_BC		0x02
1509 #define GB_SDIO_CMD_BCR		0x03
1510 
1511 	__le32	cmd_arg;
1512 	__le16	data_blocks;
1513 	__le16	data_blksz;
1514 } __packed;
1515 
1516 struct gb_sdio_command_response {
1517 	__le32	resp[4];
1518 } __packed;
1519 
1520 /* transfer request */
1521 struct gb_sdio_transfer_request {
1522 	__u8	data_flags;
1523 #define GB_SDIO_DATA_WRITE	0x01
1524 #define GB_SDIO_DATA_READ	0x02
1525 #define GB_SDIO_DATA_STREAM	0x04
1526 
1527 	__le16	data_blocks;
1528 	__le16	data_blksz;
1529 	__u8	data[];
1530 } __packed;
1531 
1532 struct gb_sdio_transfer_response {
1533 	__le16	data_blocks;
1534 	__le16	data_blksz;
1535 	__u8	data[];
1536 } __packed;
1537 
1538 /* event request: generated by module and is defined as unidirectional */
1539 struct gb_sdio_event_request {
1540 	__u8	event;
1541 #define GB_SDIO_CARD_INSERTED	0x01
1542 #define GB_SDIO_CARD_REMOVED	0x02
1543 #define GB_SDIO_WP		0x04
1544 } __packed;
1545 
1546 /* Camera */
1547 
1548 /* Greybus Camera request types */
1549 #define GB_CAMERA_TYPE_CAPABILITIES		0x02
1550 #define GB_CAMERA_TYPE_CONFIGURE_STREAMS	0x03
1551 #define GB_CAMERA_TYPE_CAPTURE			0x04
1552 #define GB_CAMERA_TYPE_FLUSH			0x05
1553 #define GB_CAMERA_TYPE_METADATA			0x06
1554 
1555 #define GB_CAMERA_MAX_STREAMS			4
1556 #define GB_CAMERA_MAX_SETTINGS_SIZE		8192
1557 
1558 /* Greybus Camera Configure Streams request payload */
1559 struct gb_camera_stream_config_request {
1560 	__le16 width;
1561 	__le16 height;
1562 	__le16 format;
1563 	__le16 padding;
1564 } __packed;
1565 
1566 struct gb_camera_configure_streams_request {
1567 	__u8 num_streams;
1568 	__u8 flags;
1569 #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY	0x01
1570 	__le16 padding;
1571 	struct gb_camera_stream_config_request config[];
1572 } __packed;
1573 
1574 /* Greybus Camera Configure Streams response payload */
1575 struct gb_camera_stream_config_response {
1576 	__le16 width;
1577 	__le16 height;
1578 	__le16 format;
1579 	__u8 virtual_channel;
1580 	__u8 data_type[2];
1581 	__le16 max_pkt_size;
1582 	__u8 padding;
1583 	__le32 max_size;
1584 } __packed;
1585 
1586 struct gb_camera_configure_streams_response {
1587 	__u8 num_streams;
1588 #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED	0x01
1589 	__u8 flags;
1590 	__u8 padding[2];
1591 	__le32 data_rate;
1592 	struct gb_camera_stream_config_response config[];
1593 };
1594 
1595 /* Greybus Camera Capture request payload - response has no payload */
1596 struct gb_camera_capture_request {
1597 	__le32 request_id;
1598 	__u8 streams;
1599 	__u8 padding;
1600 	__le16 num_frames;
1601 	__u8 settings[];
1602 } __packed;
1603 
1604 /* Greybus Camera Flush response payload - request has no payload */
1605 struct gb_camera_flush_response {
1606 	__le32 request_id;
1607 } __packed;
1608 
1609 /* Greybus Camera Metadata request payload - operation has no response */
1610 struct gb_camera_metadata_request {
1611 	__le32 request_id;
1612 	__le16 frame_number;
1613 	__u8 stream;
1614 	__u8 padding;
1615 	__u8 metadata[];
1616 } __packed;
1617 
1618 /* Lights */
1619 
1620 /* Greybus Lights request types */
1621 #define GB_LIGHTS_TYPE_GET_LIGHTS		0x02
1622 #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG		0x03
1623 #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG	0x04
1624 #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG	0x05
1625 #define GB_LIGHTS_TYPE_SET_BRIGHTNESS		0x06
1626 #define GB_LIGHTS_TYPE_SET_BLINK		0x07
1627 #define GB_LIGHTS_TYPE_SET_COLOR		0x08
1628 #define GB_LIGHTS_TYPE_SET_FADE			0x09
1629 #define GB_LIGHTS_TYPE_EVENT			0x0A
1630 #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY	0x0B
1631 #define GB_LIGHTS_TYPE_SET_FLASH_STROBE		0x0C
1632 #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT	0x0D
1633 #define GB_LIGHTS_TYPE_GET_FLASH_FAULT		0x0E
1634 
1635 /* Greybus Light modes */
1636 
1637 /*
1638  * if you add any specific mode below, update also the
1639  * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1640  */
1641 #define GB_CHANNEL_MODE_NONE		0x00000000
1642 #define GB_CHANNEL_MODE_BATTERY		0x00000001
1643 #define GB_CHANNEL_MODE_POWER		0x00000002
1644 #define GB_CHANNEL_MODE_WIRELESS	0x00000004
1645 #define GB_CHANNEL_MODE_BLUETOOTH	0x00000008
1646 #define GB_CHANNEL_MODE_KEYBOARD	0x00000010
1647 #define GB_CHANNEL_MODE_BUTTONS		0x00000020
1648 #define GB_CHANNEL_MODE_NOTIFICATION	0x00000040
1649 #define GB_CHANNEL_MODE_ATTENTION	0x00000080
1650 #define GB_CHANNEL_MODE_FLASH		0x00000100
1651 #define GB_CHANNEL_MODE_TORCH		0x00000200
1652 #define GB_CHANNEL_MODE_INDICATOR	0x00000400
1653 
1654 /* Lights Mode valid bit values */
1655 #define GB_CHANNEL_MODE_DEFINED_RANGE	0x000004FF
1656 #define GB_CHANNEL_MODE_VENDOR_RANGE	0x00F00000
1657 
1658 /* Greybus Light Channels Flags */
1659 #define GB_LIGHT_CHANNEL_MULTICOLOR	0x00000001
1660 #define GB_LIGHT_CHANNEL_FADER		0x00000002
1661 #define GB_LIGHT_CHANNEL_BLINK		0x00000004
1662 
1663 /* get count of lights in module */
1664 struct gb_lights_get_lights_response {
1665 	__u8	lights_count;
1666 } __packed;
1667 
1668 /* light config request payload */
1669 struct gb_lights_get_light_config_request {
1670 	__u8	id;
1671 } __packed;
1672 
1673 /* light config response payload */
1674 struct gb_lights_get_light_config_response {
1675 	__u8	channel_count;
1676 	__u8	name[32];
1677 } __packed;
1678 
1679 /* channel config request payload */
1680 struct gb_lights_get_channel_config_request {
1681 	__u8	light_id;
1682 	__u8	channel_id;
1683 } __packed;
1684 
1685 /* channel flash config request payload */
1686 struct gb_lights_get_channel_flash_config_request {
1687 	__u8	light_id;
1688 	__u8	channel_id;
1689 } __packed;
1690 
1691 /* channel config response payload */
1692 struct gb_lights_get_channel_config_response {
1693 	__u8	max_brightness;
1694 	__le32	flags;
1695 	__le32	color;
1696 	__u8	color_name[32];
1697 	__le32	mode;
1698 	__u8	mode_name[32];
1699 } __packed;
1700 
1701 /* channel flash config response payload */
1702 struct gb_lights_get_channel_flash_config_response {
1703 	__le32	intensity_min_uA;
1704 	__le32	intensity_max_uA;
1705 	__le32	intensity_step_uA;
1706 	__le32	timeout_min_us;
1707 	__le32	timeout_max_us;
1708 	__le32	timeout_step_us;
1709 } __packed;
1710 
1711 /* blink request payload: response have no payload */
1712 struct gb_lights_blink_request {
1713 	__u8	light_id;
1714 	__u8	channel_id;
1715 	__le16	time_on_ms;
1716 	__le16	time_off_ms;
1717 } __packed;
1718 
1719 /* set brightness request payload: response have no payload */
1720 struct gb_lights_set_brightness_request {
1721 	__u8	light_id;
1722 	__u8	channel_id;
1723 	__u8	brightness;
1724 } __packed;
1725 
1726 /* set color request payload: response have no payload */
1727 struct gb_lights_set_color_request {
1728 	__u8	light_id;
1729 	__u8	channel_id;
1730 	__le32	color;
1731 } __packed;
1732 
1733 /* set fade request payload: response have no payload */
1734 struct gb_lights_set_fade_request {
1735 	__u8	light_id;
1736 	__u8	channel_id;
1737 	__u8	fade_in;
1738 	__u8	fade_out;
1739 } __packed;
1740 
1741 /* event request: generated by module */
1742 struct gb_lights_event_request {
1743 	__u8	light_id;
1744 	__u8	event;
1745 #define GB_LIGHTS_LIGHT_CONFIG		0x01
1746 } __packed;
1747 
1748 /* set flash intensity request payload: response have no payload */
1749 struct gb_lights_set_flash_intensity_request {
1750 	__u8	light_id;
1751 	__u8	channel_id;
1752 	__le32	intensity_uA;
1753 } __packed;
1754 
1755 /* set flash strobe state request payload: response have no payload */
1756 struct gb_lights_set_flash_strobe_request {
1757 	__u8	light_id;
1758 	__u8	channel_id;
1759 	__u8	state;
1760 } __packed;
1761 
1762 /* set flash timeout request payload: response have no payload */
1763 struct gb_lights_set_flash_timeout_request {
1764 	__u8	light_id;
1765 	__u8	channel_id;
1766 	__le32	timeout_us;
1767 } __packed;
1768 
1769 /* get flash fault request payload */
1770 struct gb_lights_get_flash_fault_request {
1771 	__u8	light_id;
1772 	__u8	channel_id;
1773 } __packed;
1774 
1775 /* get flash fault response payload */
1776 struct gb_lights_get_flash_fault_response {
1777 	__le32	fault;
1778 #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE		0x00000000
1779 #define GB_LIGHTS_FLASH_FAULT_TIMEOUT			0x00000001
1780 #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE		0x00000002
1781 #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT		0x00000004
1782 #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT		0x00000008
1783 #define GB_LIGHTS_FLASH_FAULT_INDICATOR			0x00000010
1784 #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE		0x00000020
1785 #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE		0x00000040
1786 #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE	0x00000080
1787 } __packed;
1788 
1789 /* Audio */
1790 
1791 #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE		0x02
1792 #define GB_AUDIO_TYPE_GET_TOPOLOGY		0x03
1793 #define GB_AUDIO_TYPE_GET_CONTROL		0x04
1794 #define GB_AUDIO_TYPE_SET_CONTROL		0x05
1795 #define GB_AUDIO_TYPE_ENABLE_WIDGET		0x06
1796 #define GB_AUDIO_TYPE_DISABLE_WIDGET		0x07
1797 #define GB_AUDIO_TYPE_GET_PCM			0x08
1798 #define GB_AUDIO_TYPE_SET_PCM			0x09
1799 #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE		0x0a
1800 						/* 0x0b unused */
1801 #define GB_AUDIO_TYPE_ACTIVATE_TX		0x0c
1802 #define GB_AUDIO_TYPE_DEACTIVATE_TX		0x0d
1803 #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE		0x0e
1804 						/* 0x0f unused */
1805 #define GB_AUDIO_TYPE_ACTIVATE_RX		0x10
1806 #define GB_AUDIO_TYPE_DEACTIVATE_RX		0x11
1807 #define GB_AUDIO_TYPE_JACK_EVENT		0x12
1808 #define GB_AUDIO_TYPE_BUTTON_EVENT		0x13
1809 #define GB_AUDIO_TYPE_STREAMING_EVENT		0x14
1810 #define GB_AUDIO_TYPE_SEND_DATA			0x15
1811 
1812 /* Module must be able to buffer 10ms of audio data, minimum */
1813 #define GB_AUDIO_SAMPLE_BUFFER_MIN_US		10000
1814 
1815 #define GB_AUDIO_PCM_NAME_MAX			32
1816 #define AUDIO_DAI_NAME_MAX			32
1817 #define AUDIO_CONTROL_NAME_MAX			32
1818 #define AUDIO_CTL_ELEM_NAME_MAX			44
1819 #define AUDIO_ENUM_NAME_MAX			64
1820 #define AUDIO_WIDGET_NAME_MAX			32
1821 
1822 /* See SNDRV_PCM_FMTBIT_* in Linux source */
1823 #define GB_AUDIO_PCM_FMT_S8			BIT(0)
1824 #define GB_AUDIO_PCM_FMT_U8			BIT(1)
1825 #define GB_AUDIO_PCM_FMT_S16_LE			BIT(2)
1826 #define GB_AUDIO_PCM_FMT_S16_BE			BIT(3)
1827 #define GB_AUDIO_PCM_FMT_U16_LE			BIT(4)
1828 #define GB_AUDIO_PCM_FMT_U16_BE			BIT(5)
1829 #define GB_AUDIO_PCM_FMT_S24_LE			BIT(6)
1830 #define GB_AUDIO_PCM_FMT_S24_BE			BIT(7)
1831 #define GB_AUDIO_PCM_FMT_U24_LE			BIT(8)
1832 #define GB_AUDIO_PCM_FMT_U24_BE			BIT(9)
1833 #define GB_AUDIO_PCM_FMT_S32_LE			BIT(10)
1834 #define GB_AUDIO_PCM_FMT_S32_BE			BIT(11)
1835 #define GB_AUDIO_PCM_FMT_U32_LE			BIT(12)
1836 #define GB_AUDIO_PCM_FMT_U32_BE			BIT(13)
1837 
1838 /* See SNDRV_PCM_RATE_* in Linux source */
1839 #define GB_AUDIO_PCM_RATE_5512			BIT(0)
1840 #define GB_AUDIO_PCM_RATE_8000			BIT(1)
1841 #define GB_AUDIO_PCM_RATE_11025			BIT(2)
1842 #define GB_AUDIO_PCM_RATE_16000			BIT(3)
1843 #define GB_AUDIO_PCM_RATE_22050			BIT(4)
1844 #define GB_AUDIO_PCM_RATE_32000			BIT(5)
1845 #define GB_AUDIO_PCM_RATE_44100			BIT(6)
1846 #define GB_AUDIO_PCM_RATE_48000			BIT(7)
1847 #define GB_AUDIO_PCM_RATE_64000			BIT(8)
1848 #define GB_AUDIO_PCM_RATE_88200			BIT(9)
1849 #define GB_AUDIO_PCM_RATE_96000			BIT(10)
1850 #define GB_AUDIO_PCM_RATE_176400		BIT(11)
1851 #define GB_AUDIO_PCM_RATE_192000		BIT(12)
1852 
1853 #define GB_AUDIO_STREAM_TYPE_CAPTURE		0x1
1854 #define GB_AUDIO_STREAM_TYPE_PLAYBACK		0x2
1855 
1856 #define GB_AUDIO_CTL_ELEM_ACCESS_READ		BIT(0)
1857 #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE		BIT(1)
1858 
1859 /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
1860 #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN		0x01
1861 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER		0x02
1862 #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED	0x03
1863 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64	0x06
1864 
1865 /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
1866 #define GB_AUDIO_CTL_ELEM_IFACE_CARD		0x00
1867 #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP		0x01
1868 #define GB_AUDIO_CTL_ELEM_IFACE_MIXER		0x02
1869 #define GB_AUDIO_CTL_ELEM_IFACE_PCM		0x03
1870 #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI		0x04
1871 #define GB_AUDIO_CTL_ELEM_IFACE_TIMER		0x05
1872 #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER	0x06
1873 
1874 /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
1875 #define GB_AUDIO_ACCESS_READ			BIT(0)
1876 #define GB_AUDIO_ACCESS_WRITE			BIT(1)
1877 #define GB_AUDIO_ACCESS_VOLATILE		BIT(2)
1878 #define GB_AUDIO_ACCESS_TIMESTAMP		BIT(3)
1879 #define GB_AUDIO_ACCESS_TLV_READ		BIT(4)
1880 #define GB_AUDIO_ACCESS_TLV_WRITE		BIT(5)
1881 #define GB_AUDIO_ACCESS_TLV_COMMAND		BIT(6)
1882 #define GB_AUDIO_ACCESS_INACTIVE		BIT(7)
1883 #define GB_AUDIO_ACCESS_LOCK			BIT(8)
1884 #define GB_AUDIO_ACCESS_OWNER			BIT(9)
1885 
1886 /* enum snd_soc_dapm_type */
1887 #define GB_AUDIO_WIDGET_TYPE_INPUT		0x0
1888 #define GB_AUDIO_WIDGET_TYPE_OUTPUT		0x1
1889 #define GB_AUDIO_WIDGET_TYPE_MUX		0x2
1890 #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX		0x3
1891 #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX		0x4
1892 #define GB_AUDIO_WIDGET_TYPE_MIXER		0x5
1893 #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL	0x6
1894 #define GB_AUDIO_WIDGET_TYPE_PGA		0x7
1895 #define GB_AUDIO_WIDGET_TYPE_OUT_DRV		0x8
1896 #define GB_AUDIO_WIDGET_TYPE_ADC		0x9
1897 #define GB_AUDIO_WIDGET_TYPE_DAC		0xa
1898 #define GB_AUDIO_WIDGET_TYPE_MICBIAS		0xb
1899 #define GB_AUDIO_WIDGET_TYPE_MIC		0xc
1900 #define GB_AUDIO_WIDGET_TYPE_HP			0xd
1901 #define GB_AUDIO_WIDGET_TYPE_SPK		0xe
1902 #define GB_AUDIO_WIDGET_TYPE_LINE		0xf
1903 #define GB_AUDIO_WIDGET_TYPE_SWITCH		0x10
1904 #define GB_AUDIO_WIDGET_TYPE_VMID		0x11
1905 #define GB_AUDIO_WIDGET_TYPE_PRE		0x12
1906 #define GB_AUDIO_WIDGET_TYPE_POST		0x13
1907 #define GB_AUDIO_WIDGET_TYPE_SUPPLY		0x14
1908 #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY	0x15
1909 #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY	0x16
1910 #define GB_AUDIO_WIDGET_TYPE_AIF_IN		0x17
1911 #define GB_AUDIO_WIDGET_TYPE_AIF_OUT		0x18
1912 #define GB_AUDIO_WIDGET_TYPE_SIGGEN		0x19
1913 #define GB_AUDIO_WIDGET_TYPE_DAI_IN		0x1a
1914 #define GB_AUDIO_WIDGET_TYPE_DAI_OUT		0x1b
1915 #define GB_AUDIO_WIDGET_TYPE_DAI_LINK		0x1c
1916 
1917 #define GB_AUDIO_WIDGET_STATE_DISABLED		0x01
1918 #define GB_AUDIO_WIDGET_STATE_ENAABLED		0x02
1919 
1920 #define GB_AUDIO_JACK_EVENT_INSERTION		0x1
1921 #define GB_AUDIO_JACK_EVENT_REMOVAL		0x2
1922 
1923 #define GB_AUDIO_BUTTON_EVENT_PRESS		0x1
1924 #define GB_AUDIO_BUTTON_EVENT_RELEASE		0x2
1925 
1926 #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED	0x1
1927 #define GB_AUDIO_STREAMING_EVENT_HALT		0x2
1928 #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR	0x3
1929 #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR	0x4
1930 #define GB_AUDIO_STREAMING_EVENT_FAILURE	0x5
1931 #define GB_AUDIO_STREAMING_EVENT_UNDERRUN	0x6
1932 #define GB_AUDIO_STREAMING_EVENT_OVERRUN	0x7
1933 #define GB_AUDIO_STREAMING_EVENT_CLOCKING	0x8
1934 #define GB_AUDIO_STREAMING_EVENT_DATA_LEN	0x9
1935 
1936 #define GB_AUDIO_INVALID_INDEX			0xff
1937 
1938 /* enum snd_jack_types */
1939 #define GB_AUDIO_JACK_HEADPHONE			0x0000001
1940 #define GB_AUDIO_JACK_MICROPHONE		0x0000002
1941 #define GB_AUDIO_JACK_HEADSET			(GB_AUDIO_JACK_HEADPHONE | \
1942 						 GB_AUDIO_JACK_MICROPHONE)
1943 #define GB_AUDIO_JACK_LINEOUT			0x0000004
1944 #define GB_AUDIO_JACK_MECHANICAL		0x0000008
1945 #define GB_AUDIO_JACK_VIDEOOUT			0x0000010
1946 #define GB_AUDIO_JACK_AVOUT			(GB_AUDIO_JACK_LINEOUT | \
1947 						 GB_AUDIO_JACK_VIDEOOUT)
1948 #define GB_AUDIO_JACK_LINEIN			0x0000020
1949 #define GB_AUDIO_JACK_OC_HPHL			0x0000040
1950 #define GB_AUDIO_JACK_OC_HPHR			0x0000080
1951 #define GB_AUDIO_JACK_MICROPHONE2		0x0000200
1952 #define GB_AUDIO_JACK_ANC_HEADPHONE		(GB_AUDIO_JACK_HEADPHONE | \
1953 						 GB_AUDIO_JACK_MICROPHONE | \
1954 						 GB_AUDIO_JACK_MICROPHONE2)
1955 /* Kept separate from switches to facilitate implementation */
1956 #define GB_AUDIO_JACK_BTN_0			0x4000000
1957 #define GB_AUDIO_JACK_BTN_1			0x2000000
1958 #define GB_AUDIO_JACK_BTN_2			0x1000000
1959 #define GB_AUDIO_JACK_BTN_3			0x0800000
1960 
1961 struct gb_audio_pcm {
1962 	__u8	stream_name[GB_AUDIO_PCM_NAME_MAX];
1963 	__le32	formats;	/* GB_AUDIO_PCM_FMT_* */
1964 	__le32	rates;		/* GB_AUDIO_PCM_RATE_* */
1965 	__u8	chan_min;
1966 	__u8	chan_max;
1967 	__u8	sig_bits;	/* number of bits of content */
1968 } __packed;
1969 
1970 struct gb_audio_dai {
1971 	__u8			name[AUDIO_DAI_NAME_MAX];
1972 	__le16			data_cport;
1973 	struct gb_audio_pcm	capture;
1974 	struct gb_audio_pcm	playback;
1975 } __packed;
1976 
1977 struct gb_audio_integer {
1978 	__le32	min;
1979 	__le32	max;
1980 	__le32	step;
1981 } __packed;
1982 
1983 struct gb_audio_integer64 {
1984 	__le64	min;
1985 	__le64	max;
1986 	__le64	step;
1987 } __packed;
1988 
1989 struct gb_audio_enumerated {
1990 	__le32	items;
1991 	__le16	names_length;
1992 	__u8	names[];
1993 } __packed;
1994 
1995 struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
1996 	__u8		type;		/* GB_AUDIO_CTL_ELEM_TYPE_* */
1997 	__le16		dimen[4];
1998 	union {
1999 		struct gb_audio_integer		integer;
2000 		struct gb_audio_integer64	integer64;
2001 		struct gb_audio_enumerated	enumerated;
2002 	} value;
2003 } __packed;
2004 
2005 struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
2006 	__le64				timestamp; /* XXX needed? */
2007 	union {
2008 		__le32	integer_value[2];	/* consider CTL_DOUBLE_xxx */
2009 		__le64	integer64_value[2];
2010 		__le32	enumerated_item[2];
2011 	} value;
2012 } __packed;
2013 
2014 struct gb_audio_control {
2015 	__u8	name[AUDIO_CONTROL_NAME_MAX];
2016 	__u8	id;		/* 0-63 */
2017 	__u8	iface;		/* GB_AUDIO_IFACE_* */
2018 	__le16	data_cport;
2019 	__le32	access;		/* GB_AUDIO_ACCESS_* */
2020 	__u8    count;		/* count of same elements */
2021 	__u8	count_values;	/* count of values, max=2 for CTL_DOUBLE_xxx */
2022 	struct gb_audio_ctl_elem_info	info;
2023 } __packed;
2024 
2025 struct gb_audio_widget {
2026 	__u8	name[AUDIO_WIDGET_NAME_MAX];
2027 	__u8	sname[AUDIO_WIDGET_NAME_MAX];
2028 	__u8	id;
2029 	__u8	type;		/* GB_AUDIO_WIDGET_TYPE_* */
2030 	__u8	state;		/* GB_AUDIO_WIDGET_STATE_* */
2031 	__u8	ncontrols;
2032 	struct gb_audio_control	ctl[];	/* 'ncontrols' entries */
2033 } __packed;
2034 
2035 struct gb_audio_route {
2036 	__u8	source_id;	/* widget id */
2037 	__u8	destination_id;	/* widget id */
2038 	__u8	control_id;	/* 0-63 */
2039 	__u8	index;		/* Selection within the control */
2040 } __packed;
2041 
2042 struct gb_audio_topology {
2043 	__u8	num_dais;
2044 	__u8	num_controls;
2045 	__u8	num_widgets;
2046 	__u8	num_routes;
2047 	__le32	size_dais;
2048 	__le32	size_controls;
2049 	__le32	size_widgets;
2050 	__le32	size_routes;
2051 	__le32	jack_type;
2052 	/*
2053 	 * struct gb_audio_dai		dai[num_dais];
2054 	 * struct gb_audio_control	controls[num_controls];
2055 	 * struct gb_audio_widget	widgets[num_widgets];
2056 	 * struct gb_audio_route	routes[num_routes];
2057 	 */
2058 	__u8	data[];
2059 } __packed;
2060 
2061 struct gb_audio_get_topology_size_response {
2062 	__le16	size;
2063 } __packed;
2064 
2065 struct gb_audio_get_topology_response {
2066 	struct gb_audio_topology	topology;
2067 } __packed;
2068 
2069 struct gb_audio_get_control_request {
2070 	__u8	control_id;
2071 	__u8	index;
2072 } __packed;
2073 
2074 struct gb_audio_get_control_response {
2075 	struct gb_audio_ctl_elem_value	value;
2076 } __packed;
2077 
2078 struct gb_audio_set_control_request {
2079 	__u8	control_id;
2080 	__u8	index;
2081 	struct gb_audio_ctl_elem_value	value;
2082 } __packed;
2083 
2084 struct gb_audio_enable_widget_request {
2085 	__u8	widget_id;
2086 } __packed;
2087 
2088 struct gb_audio_disable_widget_request {
2089 	__u8	widget_id;
2090 } __packed;
2091 
2092 struct gb_audio_get_pcm_request {
2093 	__le16	data_cport;
2094 } __packed;
2095 
2096 struct gb_audio_get_pcm_response {
2097 	__le32	format;
2098 	__le32	rate;
2099 	__u8	channels;
2100 	__u8	sig_bits;
2101 } __packed;
2102 
2103 struct gb_audio_set_pcm_request {
2104 	__le16	data_cport;
2105 	__le32	format;
2106 	__le32	rate;
2107 	__u8	channels;
2108 	__u8	sig_bits;
2109 } __packed;
2110 
2111 struct gb_audio_set_tx_data_size_request {
2112 	__le16	data_cport;
2113 	__le16	size;
2114 } __packed;
2115 
2116 struct gb_audio_activate_tx_request {
2117 	__le16	data_cport;
2118 } __packed;
2119 
2120 struct gb_audio_deactivate_tx_request {
2121 	__le16	data_cport;
2122 } __packed;
2123 
2124 struct gb_audio_set_rx_data_size_request {
2125 	__le16	data_cport;
2126 	__le16	size;
2127 } __packed;
2128 
2129 struct gb_audio_activate_rx_request {
2130 	__le16	data_cport;
2131 } __packed;
2132 
2133 struct gb_audio_deactivate_rx_request {
2134 	__le16	data_cport;
2135 } __packed;
2136 
2137 struct gb_audio_jack_event_request {
2138 	__u8	widget_id;
2139 	__u8	jack_attribute;
2140 	__u8	event;
2141 } __packed;
2142 
2143 struct gb_audio_button_event_request {
2144 	__u8	widget_id;
2145 	__u8	button_id;
2146 	__u8	event;
2147 } __packed;
2148 
2149 struct gb_audio_streaming_event_request {
2150 	__le16	data_cport;
2151 	__u8	event;
2152 } __packed;
2153 
2154 struct gb_audio_send_data_request {
2155 	__le64	timestamp;
2156 	__u8	data[];
2157 } __packed;
2158 
2159 
2160 /* Log */
2161 
2162 /* operations */
2163 #define GB_LOG_TYPE_SEND_LOG	0x02
2164 
2165 /* length */
2166 #define GB_LOG_MAX_LEN		1024
2167 
2168 struct gb_log_send_log_request {
2169 	__le16	len;
2170 	__u8    msg[];
2171 } __packed;
2172 
2173 #endif /* __GREYBUS_PROTOCOLS_H */
2174 
2175