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