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