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