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