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