]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/greybus/greybus_protocols.h
greybus: timesync: Add Control and SVC TimeSync command/response data definitions
[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 /* Device ID of SVC and AP */
58 #define GB_DEVICE_ID_SVC                        0
59 #define GB_DEVICE_ID_AP                         1
60 #define GB_DEVICE_ID_MODULES_START              2
61
62 /*
63  * Bundle/cport for control/svc cport: The same bundle/cport is shared by both
64  * CONTROL and SVC protocols for communication between AP and SVC.
65  */
66 #define GB_SVC_BUNDLE_ID                        0
67 #define GB_SVC_CPORT_ID                         0
68 #define GB_CONTROL_BUNDLE_ID                    0
69 #define GB_CONTROL_CPORT_ID                     0
70
71
72 /*
73  * All operation messages (both requests and responses) begin with
74  * a header that encodes the size of the message (header included).
75  * This header also contains a unique identifier, that associates a
76  * response message with its operation.  The header contains an
77  * operation type field, whose interpretation is dependent on what
78  * type of protocol is used over the connection.  The high bit
79  * (0x80) of the operation type field is used to indicate whether
80  * the message is a request (clear) or a response (set).
81  *
82  * Response messages include an additional result byte, which
83  * communicates the result of the corresponding request.  A zero
84  * result value means the operation completed successfully.  Any
85  * other value indicates an error; in this case, the payload of the
86  * response message (if any) is ignored.  The result byte must be
87  * zero in the header for a request message.
88  *
89  * The wire format for all numeric fields in the header is little
90  * endian.  Any operation-specific data begins immediately after the
91  * header.
92  */
93 struct gb_operation_msg_hdr {
94         __le16  size;           /* Size in bytes of header + payload */
95         __le16  operation_id;   /* Operation unique id */
96         __u8    type;           /* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
97         __u8    result;         /* Result of request (in responses only) */
98         __u8    pad[2];         /* must be zero (ignore when read) */
99 } __packed;
100
101
102 /* Generic request numbers supported by all modules */
103 #define GB_REQUEST_TYPE_INVALID                 0x00
104 #define GB_REQUEST_TYPE_PROTOCOL_VERSION        0x01
105
106 struct gb_protocol_version_request {
107         __u8    major;
108         __u8    minor;
109 } __packed;
110
111 struct gb_protocol_version_response {
112         __u8    major;
113         __u8    minor;
114 } __packed;
115
116 /* Control Protocol */
117
118 /* Greybus control request types */
119 #define GB_CONTROL_TYPE_VERSION                 0x01
120 #define GB_CONTROL_TYPE_PROBE_AP                0x02
121 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE       0x03
122 #define GB_CONTROL_TYPE_GET_MANIFEST            0x04
123 #define GB_CONTROL_TYPE_CONNECTED               0x05
124 #define GB_CONTROL_TYPE_DISCONNECTED            0x06
125 #define GB_CONTROL_TYPE_INTERFACE_VERSION       0x0a
126 #define GB_CONTROL_TYPE_BUNDLE_VERSION          0x0b
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_disconnected_request {
163         __le16                  cport_id;
164 } __packed;
165 /* Control protocol [dis]connected response has no payload */
166
167 /* Control protocol interface version request has no payload */
168 struct gb_control_interface_version_response {
169         __le16                  major;
170         __le16                  minor;
171 } __packed;
172
173 #define GB_TIMESYNC_MAX_STROBES                 0x04
174
175 struct gb_control_timesync_enable_request {
176         __u8    count;
177         __u64   frame_time;
178         __u32   strobe_delay;
179         __u32   refclk;
180 } __packed;
181 /* timesync enable response has no payload */
182
183 struct gb_control_timesync_authoritative_request {
184         __u64   frame_time[GB_TIMESYNC_MAX_STROBES];
185 } __packed;
186 /* timesync authoritative response has no payload */
187
188 /* APBridge protocol */
189
190 /* request APB1 log */
191 #define GB_APB_REQUEST_LOG              0x02
192
193 /* request to map a cport to bulk in and bulk out endpoints */
194 #define GB_APB_REQUEST_EP_MAPPING       0x03
195
196 /* request to get the number of cports available */
197 #define GB_APB_REQUEST_CPORT_COUNT      0x04
198
199 /* request to reset a cport state */
200 #define GB_APB_REQUEST_RESET_CPORT      0x05
201
202 /* request to time the latency of messages on a given cport */
203 #define GB_APB_REQUEST_LATENCY_TAG_EN   0x06
204 #define GB_APB_REQUEST_LATENCY_TAG_DIS  0x07
205
206 /* request to control the CSI transmitter */
207 #define GB_APB_REQUEST_CSI_TX_CONTROL   0x08
208
209 /* request to control the CSI transmitter */
210 #define GB_APB_REQUEST_AUDIO_CONTROL    0x09
211
212 /* vendor requests to enable/disable FCT tokens flow */
213 #define GB_APB_REQUEST_FCT_FLOW_EN      0x0b
214 #define GB_APB_REQUEST_FCT_FLOW_DIS     0x0c
215
216 /* Firmware Protocol */
217
218 /* Version of the Greybus firmware protocol we support */
219 #define GB_FIRMWARE_VERSION_MAJOR               0x00
220 #define GB_FIRMWARE_VERSION_MINOR               0x01
221
222 /* Greybus firmware request types */
223 #define GB_FIRMWARE_TYPE_VERSION                0x01
224 #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE          0x02
225 #define GB_FIRMWARE_TYPE_GET_FIRMWARE           0x03
226 #define GB_FIRMWARE_TYPE_READY_TO_BOOT          0x04
227 #define GB_FIRMWARE_TYPE_AP_READY               0x05    /* Request with no-payload */
228 #define GB_FIRMWARE_TYPE_GET_VID_PID            0x06    /* Request with no-payload */
229
230 /* FIXME: remove all ES2-specific identifiers from the kernel */
231 #define ES2_DDBL1_MFR_ID        0x00000126
232 #define ES2_DDBL1_PROD_ID       0x00001000
233
234 /* Greybus firmware boot stages */
235 #define GB_FIRMWARE_BOOT_STAGE_ONE              0x01 /* Reserved for the boot ROM */
236 #define GB_FIRMWARE_BOOT_STAGE_TWO              0x02 /* Firmware package to be loaded by the boot ROM */
237 #define GB_FIRMWARE_BOOT_STAGE_THREE            0x03 /* Module personality package loaded by Stage 2 firmware */
238
239 /* Greybus firmware ready to boot status */
240 #define GB_FIRMWARE_BOOT_STATUS_INVALID         0x00 /* Firmware blob could not be validated */
241 #define GB_FIRMWARE_BOOT_STATUS_INSECURE        0x01 /* Firmware blob is valid but insecure */
242 #define GB_FIRMWARE_BOOT_STATUS_SECURE          0x02 /* Firmware blob is valid and secure */
243
244 /* Max firmware data fetch size in bytes */
245 #define GB_FIRMWARE_FETCH_MAX                   2000
246
247 struct gb_firmware_version_request {
248         __u8    major;
249         __u8    minor;
250 } __packed;
251
252 struct gb_firmware_version_response {
253         __u8    major;
254         __u8    minor;
255 } __packed;
256
257 /* Firmware protocol firmware size request/response */
258 struct gb_firmware_size_request {
259         __u8                    stage;
260 } __packed;
261
262 struct gb_firmware_size_response {
263         __le32                  size;
264 } __packed;
265
266 /* Firmware protocol get firmware request/response */
267 struct gb_firmware_get_firmware_request {
268         __le32                  offset;
269         __le32                  size;
270 } __packed;
271
272 struct gb_firmware_get_firmware_response {
273         __u8                    data[0];
274 } __packed;
275
276 /* Firmware protocol Ready to boot request */
277 struct gb_firmware_ready_to_boot_request {
278         __u8                    status;
279 } __packed;
280 /* Firmware protocol Ready to boot response has no payload */
281
282 /* Firmware protocol get VID/PID request has no payload */
283 struct gb_firmware_get_vid_pid_response {
284         __le32                  vendor_id;
285         __le32                  product_id;
286 } __packed;
287
288
289 /* Power Supply */
290
291 /* Version of the Greybus power supply protocol we support */
292 #define GB_POWER_SUPPLY_VERSION_MAJOR           0x00
293 #define GB_POWER_SUPPLY_VERSION_MINOR           0x01
294
295 /* Greybus power supply request types */
296 #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES               0x02
297 #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION            0x03
298 #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS       0x04
299 #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY               0x05
300 #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY               0x06
301 #define GB_POWER_SUPPLY_TYPE_EVENT                      0x07
302
303 /* Should match up with battery technologies in linux/power_supply.h */
304 #define GB_POWER_SUPPLY_TECH_UNKNOWN                    0x0000
305 #define GB_POWER_SUPPLY_TECH_NiMH                       0x0001
306 #define GB_POWER_SUPPLY_TECH_LION                       0x0002
307 #define GB_POWER_SUPPLY_TECH_LIPO                       0x0003
308 #define GB_POWER_SUPPLY_TECH_LiFe                       0x0004
309 #define GB_POWER_SUPPLY_TECH_NiCd                       0x0005
310 #define GB_POWER_SUPPLY_TECH_LiMn                       0x0006
311
312 /* Should match up with power supply types in linux/power_supply.h */
313 #define GB_POWER_SUPPLY_UNKNOWN_TYPE                    0x0000
314 #define GB_POWER_SUPPLY_BATTERY_TYPE                    0x0001
315 #define GB_POWER_SUPPLY_UPS_TYPE                        0x0002
316 #define GB_POWER_SUPPLY_MAINS_TYPE                      0x0003
317 #define GB_POWER_SUPPLY_USB_TYPE                        0x0004
318 #define GB_POWER_SUPPLY_USB_DCP_TYPE                    0x0005
319 #define GB_POWER_SUPPLY_USB_CDP_TYPE                    0x0006
320 #define GB_POWER_SUPPLY_USB_ACA_TYPE                    0x0007
321
322 /* Should match up with power supply health in linux/power_supply.h */
323 #define GB_POWER_SUPPLY_HEALTH_UNKNOWN                  0x0000
324 #define GB_POWER_SUPPLY_HEALTH_GOOD                     0x0001
325 #define GB_POWER_SUPPLY_HEALTH_OVERHEAT                 0x0002
326 #define GB_POWER_SUPPLY_HEALTH_DEAD                     0x0003
327 #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE              0x0004
328 #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE           0x0005
329 #define GB_POWER_SUPPLY_HEALTH_COLD                     0x0006
330 #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE    0x0007
331 #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE      0x0008
332
333 /* Should match up with battery status in linux/power_supply.h */
334 #define GB_POWER_SUPPLY_STATUS_UNKNOWN          0x0000
335 #define GB_POWER_SUPPLY_STATUS_CHARGING         0x0001
336 #define GB_POWER_SUPPLY_STATUS_DISCHARGING      0x0002
337 #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING     0x0003
338 #define GB_POWER_SUPPLY_STATUS_FULL             0x0004
339
340 struct gb_power_supply_get_supplies_response {
341         __u8    supplies_count;
342 } __packed;
343
344 struct gb_power_supply_get_description_request {
345         __u8    psy_id;
346 } __packed;
347
348 struct gb_power_supply_get_description_response {
349         __u8    manufacturer[32];
350         __u8    model[32];
351         __u8    serial_number[32];
352         __le16  type;
353         __u8    properties_count;
354 } __packed;
355
356 struct gb_power_supply_props_desc {
357         __u8    property;
358 #define GB_POWER_SUPPLY_PROP_STATUS                             0x00
359 #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE                        0x01
360 #define GB_POWER_SUPPLY_PROP_HEALTH                             0x02
361 #define GB_POWER_SUPPLY_PROP_PRESENT                            0x03
362 #define GB_POWER_SUPPLY_PROP_ONLINE                             0x04
363 #define GB_POWER_SUPPLY_PROP_AUTHENTIC                          0x05
364 #define GB_POWER_SUPPLY_PROP_TECHNOLOGY                         0x06
365 #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT                        0x07
366 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX                        0x08
367 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN                        0x09
368 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN                 0x0A
369 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN                 0x0B
370 #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW                        0x0C
371 #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG                        0x0D
372 #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV                        0x0E
373 #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT                       0x0F
374 #define GB_POWER_SUPPLY_PROP_CURRENT_MAX                        0x10
375 #define GB_POWER_SUPPLY_PROP_CURRENT_NOW                        0x11
376 #define GB_POWER_SUPPLY_PROP_CURRENT_AVG                        0x12
377 #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT                       0x13
378 #define GB_POWER_SUPPLY_PROP_POWER_NOW                          0x14
379 #define GB_POWER_SUPPLY_PROP_POWER_AVG                          0x15
380 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN                 0x16
381 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN                0x17
382 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL                        0x18
383 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY                       0x19
384 #define GB_POWER_SUPPLY_PROP_CHARGE_NOW                         0x1A
385 #define GB_POWER_SUPPLY_PROP_CHARGE_AVG                         0x1B
386 #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER                     0x1C
387 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT            0x1D
388 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX        0x1E
389 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE            0x1F
390 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX        0x20
391 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT               0x21
392 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX           0x22
393 #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT                0x23
394 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN                 0x24
395 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN                0x25
396 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL                        0x26
397 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY                       0x27
398 #define GB_POWER_SUPPLY_PROP_ENERGY_NOW                         0x28
399 #define GB_POWER_SUPPLY_PROP_ENERGY_AVG                         0x29
400 #define GB_POWER_SUPPLY_PROP_CAPACITY                           0x2A
401 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN                 0x2B
402 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX                 0x2C
403 #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL                     0x2D
404 #define GB_POWER_SUPPLY_PROP_TEMP                               0x2E
405 #define GB_POWER_SUPPLY_PROP_TEMP_MAX                           0x2F
406 #define GB_POWER_SUPPLY_PROP_TEMP_MIN                           0x30
407 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN                     0x31
408 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX                     0x32
409 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT                       0x33
410 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN             0x34
411 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX             0x35
412 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW                  0x36
413 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG                  0x37
414 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW                   0x38
415 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG                   0x39
416 #define GB_POWER_SUPPLY_PROP_TYPE                               0x3A
417 #define GB_POWER_SUPPLY_PROP_SCOPE                              0x3B
418 #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT                0x3C
419 #define GB_POWER_SUPPLY_PROP_CALIBRATE                          0x3D
420         __u8    is_writeable;
421 } __packed;
422
423 struct gb_power_supply_get_property_descriptors_request {
424         __u8    psy_id;
425 } __packed;
426
427 struct gb_power_supply_get_property_descriptors_response {
428         __u8    properties_count;
429         struct gb_power_supply_props_desc props[];
430 } __packed;
431
432 struct gb_power_supply_get_property_request {
433         __u8    psy_id;
434         __u8    property;
435 } __packed;
436
437 struct gb_power_supply_get_property_response {
438         __le32  prop_val;
439 };
440
441 struct gb_power_supply_set_property_request {
442         __u8    psy_id;
443         __u8    property;
444         __le32  prop_val;
445 } __packed;
446
447 struct gb_power_supply_event_request {
448         __u8    psy_id;
449         __u8    event;
450 #define GB_POWER_SUPPLY_UPDATE          0x01
451 } __packed;
452
453
454 /* HID */
455
456 /* Version of the Greybus hid protocol we support */
457 #define GB_HID_VERSION_MAJOR            0x00
458 #define GB_HID_VERSION_MINOR            0x01
459
460 /* Greybus HID operation types */
461 #define GB_HID_TYPE_GET_DESC            0x02
462 #define GB_HID_TYPE_GET_REPORT_DESC     0x03
463 #define GB_HID_TYPE_PWR_ON              0x04
464 #define GB_HID_TYPE_PWR_OFF             0x05
465 #define GB_HID_TYPE_GET_REPORT          0x06
466 #define GB_HID_TYPE_SET_REPORT          0x07
467 #define GB_HID_TYPE_IRQ_EVENT           0x08
468
469 /* Report type */
470 #define GB_HID_INPUT_REPORT             0
471 #define GB_HID_OUTPUT_REPORT            1
472 #define GB_HID_FEATURE_REPORT           2
473
474 /* Different request/response structures */
475 /* HID get descriptor response */
476 struct gb_hid_desc_response {
477         __u8                            bLength;
478         __le16                          wReportDescLength;
479         __le16                          bcdHID;
480         __le16                          wProductID;
481         __le16                          wVendorID;
482         __u8                            bCountryCode;
483 } __packed;
484
485 /* HID get report request/response */
486 struct gb_hid_get_report_request {
487         __u8                            report_type;
488         __u8                            report_id;
489 } __packed;
490
491 /* HID set report request */
492 struct gb_hid_set_report_request {
493         __u8                            report_type;
494         __u8                            report_id;
495         __u8                            report[0];
496 } __packed;
497
498 /* HID input report request, via interrupt pipe */
499 struct gb_hid_input_report_request {
500         __u8                            report[0];
501 } __packed;
502
503
504 /* I2C */
505
506 /* Version of the Greybus i2c protocol we support */
507 #define GB_I2C_VERSION_MAJOR            0x00
508 #define GB_I2C_VERSION_MINOR            0x01
509
510 /* Greybus i2c request types */
511 #define GB_I2C_TYPE_FUNCTIONALITY       0x02
512 #define GB_I2C_TYPE_TRANSFER            0x05
513
514 /* functionality request has no payload */
515 struct gb_i2c_functionality_response {
516         __le32  functionality;
517 } __packed;
518
519 /*
520  * Outgoing data immediately follows the op count and ops array.
521  * The data for each write (master -> slave) op in the array is sent
522  * in order, with no (e.g. pad) bytes separating them.
523  *
524  * Short reads cause the entire transfer request to fail So response
525  * payload consists only of bytes read, and the number of bytes is
526  * exactly what was specified in the corresponding op.  Like
527  * outgoing data, the incoming data is in order and contiguous.
528  */
529 struct gb_i2c_transfer_op {
530         __le16  addr;
531         __le16  flags;
532         __le16  size;
533 } __packed;
534
535 struct gb_i2c_transfer_request {
536         __le16                          op_count;
537         struct gb_i2c_transfer_op       ops[0];         /* op_count of these */
538 } __packed;
539 struct gb_i2c_transfer_response {
540         __u8                            data[0];        /* inbound data */
541 } __packed;
542
543
544 /* GPIO */
545
546 /* Version of the Greybus GPIO protocol we support */
547 #define GB_GPIO_VERSION_MAJOR           0x00
548 #define GB_GPIO_VERSION_MINOR           0x01
549
550 /* Greybus GPIO request types */
551 #define GB_GPIO_TYPE_LINE_COUNT         0x02
552 #define GB_GPIO_TYPE_ACTIVATE           0x03
553 #define GB_GPIO_TYPE_DEACTIVATE         0x04
554 #define GB_GPIO_TYPE_GET_DIRECTION      0x05
555 #define GB_GPIO_TYPE_DIRECTION_IN       0x06
556 #define GB_GPIO_TYPE_DIRECTION_OUT      0x07
557 #define GB_GPIO_TYPE_GET_VALUE          0x08
558 #define GB_GPIO_TYPE_SET_VALUE          0x09
559 #define GB_GPIO_TYPE_SET_DEBOUNCE       0x0a
560 #define GB_GPIO_TYPE_IRQ_TYPE           0x0b
561 #define GB_GPIO_TYPE_IRQ_MASK           0x0c
562 #define GB_GPIO_TYPE_IRQ_UNMASK         0x0d
563 #define GB_GPIO_TYPE_IRQ_EVENT          0x0e
564
565 #define GB_GPIO_IRQ_TYPE_NONE           0x00
566 #define GB_GPIO_IRQ_TYPE_EDGE_RISING    0x01
567 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING   0x02
568 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH      0x03
569 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH     0x04
570 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW      0x08
571
572 /* line count request has no payload */
573 struct gb_gpio_line_count_response {
574         __u8    count;
575 } __packed;
576
577 struct gb_gpio_activate_request {
578         __u8    which;
579 } __packed;
580 /* activate response has no payload */
581
582 struct gb_gpio_deactivate_request {
583         __u8    which;
584 } __packed;
585 /* deactivate response has no payload */
586
587 struct gb_gpio_get_direction_request {
588         __u8    which;
589 } __packed;
590 struct gb_gpio_get_direction_response {
591         __u8    direction;
592 } __packed;
593
594 struct gb_gpio_direction_in_request {
595         __u8    which;
596 } __packed;
597 /* direction in response has no payload */
598
599 struct gb_gpio_direction_out_request {
600         __u8    which;
601         __u8    value;
602 } __packed;
603 /* direction out response has no payload */
604
605 struct gb_gpio_get_value_request {
606         __u8    which;
607 } __packed;
608 struct gb_gpio_get_value_response {
609         __u8    value;
610 } __packed;
611
612 struct gb_gpio_set_value_request {
613         __u8    which;
614         __u8    value;
615 } __packed;
616 /* set value response has no payload */
617
618 struct gb_gpio_set_debounce_request {
619         __u8    which;
620         __le16  usec;
621 } __packed;
622 /* debounce response has no payload */
623
624 struct gb_gpio_irq_type_request {
625         __u8    which;
626         __u8    type;
627 } __packed;
628 /* irq type response has no payload */
629
630 struct gb_gpio_irq_mask_request {
631         __u8    which;
632 } __packed;
633 /* irq mask response has no payload */
634
635 struct gb_gpio_irq_unmask_request {
636         __u8    which;
637 } __packed;
638 /* irq unmask response has no payload */
639
640 /* irq event requests originate on another module and are handled on the AP */
641 struct gb_gpio_irq_event_request {
642         __u8    which;
643 } __packed;
644 /* irq event has no response */
645
646
647 /* PWM */
648
649 /* Version of the Greybus PWM protocol we support */
650 #define GB_PWM_VERSION_MAJOR            0x00
651 #define GB_PWM_VERSION_MINOR            0x01
652
653 /* Greybus PWM operation types */
654 #define GB_PWM_TYPE_PWM_COUNT           0x02
655 #define GB_PWM_TYPE_ACTIVATE            0x03
656 #define GB_PWM_TYPE_DEACTIVATE          0x04
657 #define GB_PWM_TYPE_CONFIG              0x05
658 #define GB_PWM_TYPE_POLARITY            0x06
659 #define GB_PWM_TYPE_ENABLE              0x07
660 #define GB_PWM_TYPE_DISABLE             0x08
661
662 /* pwm count request has no payload */
663 struct gb_pwm_count_response {
664         __u8    count;
665 } __packed;
666
667 struct gb_pwm_activate_request {
668         __u8    which;
669 } __packed;
670
671 struct gb_pwm_deactivate_request {
672         __u8    which;
673 } __packed;
674
675 struct gb_pwm_config_request {
676         __u8    which;
677         __le32  duty;
678         __le32  period;
679 } __packed;
680
681 struct gb_pwm_polarity_request {
682         __u8    which;
683         __u8    polarity;
684 } __packed;
685
686 struct gb_pwm_enable_request {
687         __u8    which;
688 } __packed;
689
690 struct gb_pwm_disable_request {
691         __u8    which;
692 } __packed;
693
694 /* SPI */
695
696 /* Version of the Greybus spi protocol we support */
697 #define GB_SPI_VERSION_MAJOR            0x00
698 #define GB_SPI_VERSION_MINOR            0x01
699
700 /* Should match up with modes in linux/spi/spi.h */
701 #define GB_SPI_MODE_CPHA                0x01            /* clock phase */
702 #define GB_SPI_MODE_CPOL                0x02            /* clock polarity */
703 #define GB_SPI_MODE_MODE_0              (0|0)           /* (original MicroWire) */
704 #define GB_SPI_MODE_MODE_1              (0|GB_SPI_MODE_CPHA)
705 #define GB_SPI_MODE_MODE_2              (GB_SPI_MODE_CPOL|0)
706 #define GB_SPI_MODE_MODE_3              (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
707 #define GB_SPI_MODE_CS_HIGH             0x04            /* chipselect active high? */
708 #define GB_SPI_MODE_LSB_FIRST           0x08            /* per-word bits-on-wire */
709 #define GB_SPI_MODE_3WIRE               0x10            /* SI/SO signals shared */
710 #define GB_SPI_MODE_LOOP                0x20            /* loopback mode */
711 #define GB_SPI_MODE_NO_CS               0x40            /* 1 dev/bus, no chipselect */
712 #define GB_SPI_MODE_READY               0x80            /* slave pulls low to pause */
713
714 /* Should match up with flags in linux/spi/spi.h */
715 #define GB_SPI_FLAG_HALF_DUPLEX         BIT(0)          /* can't do full duplex */
716 #define GB_SPI_FLAG_NO_RX               BIT(1)          /* can't do buffer read */
717 #define GB_SPI_FLAG_NO_TX               BIT(2)          /* can't do buffer write */
718
719 /* Greybus spi operation types */
720 #define GB_SPI_TYPE_MASTER_CONFIG       0x02
721 #define GB_SPI_TYPE_DEVICE_CONFIG       0x03
722 #define GB_SPI_TYPE_TRANSFER            0x04
723
724 /* mode request has no payload */
725 struct gb_spi_master_config_response {
726         __le32  bits_per_word_mask;
727         __le32  min_speed_hz;
728         __le32  max_speed_hz;
729         __le16  mode;
730         __le16  flags;
731         __u8    num_chipselect;
732 } __packed;
733
734 struct gb_spi_device_config_request {
735         __u8    chip_select;
736 } __packed;
737
738 struct gb_spi_device_config_response {
739         __le16  mode;
740         __u8    bits_per_word;
741         __le32  max_speed_hz;
742         __u8    device_type;
743 #define GB_SPI_SPI_DEV          0x00
744 #define GB_SPI_SPI_NOR          0x01
745 #define GB_SPI_SPI_MODALIAS     0x02
746         __u8    name[32];
747 } __packed;
748
749 /**
750  * struct gb_spi_transfer - a read/write buffer pair
751  * @speed_hz: Select a speed other than the device default for this transfer. If
752  *      0 the default (from @spi_device) is used.
753  * @len: size of rx and tx buffers (in bytes)
754  * @delay_usecs: microseconds to delay after this transfer before (optionally)
755  *      changing the chipselect status, then starting the next transfer or
756  *      completing this spi_message.
757  * @cs_change: affects chipselect after this transfer completes
758  * @bits_per_word: select a bits_per_word other than the device default for this
759  *      transfer. If 0 the default (from @spi_device) is used.
760  */
761 struct gb_spi_transfer {
762         __le32          speed_hz;
763         __le32          len;
764         __le16          delay_usecs;
765         __u8            cs_change;
766         __u8            bits_per_word;
767         __u8            rdwr;
768 #define GB_SPI_XFER_READ        0x01
769 #define GB_SPI_XFER_WRITE       0x02
770 } __packed;
771
772 struct gb_spi_transfer_request {
773         __u8                    chip_select;    /* of the spi device */
774         __u8                    mode;           /* of the spi device */
775         __le16                  count;
776         struct gb_spi_transfer  transfers[0];   /* count of these */
777 } __packed;
778
779 struct gb_spi_transfer_response {
780         __u8                    data[0];        /* inbound data */
781 } __packed;
782
783 /* Version of the Greybus SVC protocol we support */
784 #define GB_SVC_VERSION_MAJOR            0x00
785 #define GB_SVC_VERSION_MINOR            0x01
786
787 /* Greybus SVC request types */
788 #define GB_SVC_TYPE_SVC_HELLO           0x02
789 #define GB_SVC_TYPE_INTF_DEVICE_ID      0x03
790 #define GB_SVC_TYPE_INTF_HOTPLUG        0x04
791 #define GB_SVC_TYPE_INTF_HOT_UNPLUG     0x05
792 #define GB_SVC_TYPE_INTF_RESET          0x06
793 #define GB_SVC_TYPE_CONN_CREATE         0x07
794 #define GB_SVC_TYPE_CONN_DESTROY        0x08
795 #define GB_SVC_TYPE_DME_PEER_GET        0x09
796 #define GB_SVC_TYPE_DME_PEER_SET        0x0a
797 #define GB_SVC_TYPE_ROUTE_CREATE        0x0b
798 #define GB_SVC_TYPE_ROUTE_DESTROY       0x0c
799 #define GB_SVC_TYPE_INTF_SET_PWRM       0x10
800 #define GB_SVC_TYPE_INTF_EJECT          0x11
801 #define GB_SVC_TYPE_KEY_EVENT           0x12
802 #define GB_SVC_TYPE_PING                0x13
803
804 /*
805  * SVC version request/response has the same payload as
806  * gb_protocol_version_request/response.
807  */
808
809 /* SVC protocol hello request */
810 struct gb_svc_hello_request {
811         __le16                  endo_id;
812         __u8                    interface_id;
813 } __packed;
814 /* hello response has no payload */
815
816 struct gb_svc_intf_device_id_request {
817         __u8    intf_id;
818         __u8    device_id;
819 } __packed;
820 /* device id response has no payload */
821
822 struct gb_svc_intf_hotplug_request {
823         __u8    intf_id;
824         struct {
825                 __le32  ddbl1_mfr_id;
826                 __le32  ddbl1_prod_id;
827                 __le32  ara_vend_id;
828                 __le32  ara_prod_id;
829                 __le64  serial_number;
830         } data;
831 } __packed;
832 /* hotplug response has no payload */
833
834 struct gb_svc_intf_hot_unplug_request {
835         __u8    intf_id;
836 } __packed;
837 /* hot unplug response has no payload */
838
839 struct gb_svc_intf_reset_request {
840         __u8    intf_id;
841 } __packed;
842 /* interface reset response has no payload */
843
844 #define GB_SVC_EJECT_TIME       9000
845 struct gb_svc_intf_eject_request {
846         __u8    intf_id;
847 } __packed;
848 /* interface eject response has no payload */
849
850 struct gb_svc_conn_create_request {
851         __u8    intf1_id;
852         __le16  cport1_id;
853         __u8    intf2_id;
854         __le16  cport2_id;
855         __u8    tc;
856         __u8    flags;
857 } __packed;
858 /* connection create response has no payload */
859
860 struct gb_svc_conn_destroy_request {
861         __u8    intf1_id;
862         __le16  cport1_id;
863         __u8    intf2_id;
864         __le16  cport2_id;
865 } __packed;
866 /* connection destroy response has no payload */
867
868 struct gb_svc_dme_peer_get_request {
869         __u8    intf_id;
870         __le16  attr;
871         __le16  selector;
872 } __packed;
873
874 struct gb_svc_dme_peer_get_response {
875         __le16  result_code;
876         __le32  attr_value;
877 } __packed;
878
879 struct gb_svc_dme_peer_set_request {
880         __u8    intf_id;
881         __le16  attr;
882         __le16  selector;
883         __le32  value;
884 } __packed;
885
886 struct gb_svc_dme_peer_set_response {
887         __le16  result_code;
888 } __packed;
889
890 /* Attributes for peer get/set operations */
891 #define DME_ATTR_SELECTOR_INDEX         0
892 /* FIXME: remove ES2 support and DME_ATTR_T_TST_SRC_INCREMENT */
893 #define DME_ATTR_T_TST_SRC_INCREMENT    0x4083
894 #define DME_ATTR_ES3_INIT_STATUS                0x6101
895
896 /* Return value from init-status attributes listed above */
897 #define DME_DIS_SPI_BOOT_STARTED                0x02
898 #define DME_DIS_TRUSTED_SPI_BOOT_FINISHED       0x03
899 #define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED     0x04
900 #define DME_DIS_UNIPRO_BOOT_STARTED             0x06
901 #define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED    0x09
902
903 struct gb_svc_route_create_request {
904         __u8    intf1_id;
905         __u8    dev1_id;
906         __u8    intf2_id;
907         __u8    dev2_id;
908 } __packed;
909 /* route create response has no payload */
910
911 struct gb_svc_route_destroy_request {
912         __u8    intf1_id;
913         __u8    intf2_id;
914 } __packed;
915 /* route destroy response has no payload */
916
917 struct gb_svc_timesync_enable_request {
918         __u8    count;
919         __u64   frame_time;
920         __u32   strobe_delay;
921         __u32   strobe_mask;
922         __u32   refclk;
923 } __packed;
924 /* timesync enable response has no payload */
925
926 /* timesync authoritative request has no payload */
927 struct gb_svc_timesync_authoritative_response {
928         __u64   frame_time[GB_TIMESYNC_MAX_STROBES];
929 };
930
931 #define GB_SVC_UNIPRO_FAST_MODE                 0x01
932 #define GB_SVC_UNIPRO_SLOW_MODE                 0x02
933 #define GB_SVC_UNIPRO_FAST_AUTO_MODE            0x04
934 #define GB_SVC_UNIPRO_SLOW_AUTO_MODE            0x05
935 #define GB_SVC_UNIPRO_MODE_UNCHANGED            0x07
936 #define GB_SVC_UNIPRO_HIBERNATE_MODE            0x11
937 #define GB_SVC_UNIPRO_OFF_MODE                  0x12
938
939 #define GB_SVC_PWRM_RXTERMINATION               0x01
940 #define GB_SVC_PWRM_TXTERMINATION               0x02
941 #define GB_SVC_PWRM_LINE_RESET                  0x04
942 #define GB_SVC_PWRM_SCRAMBLING                  0x20
943
944 #define GB_SVC_PWRM_QUIRK_HSSER                 0x00000001
945
946 #define GB_SVC_UNIPRO_HS_SERIES_A               0x01
947 #define GB_SVC_UNIPRO_HS_SERIES_B               0x02
948
949 struct gb_svc_intf_set_pwrm_request {
950         __u8    intf_id;
951         __u8    hs_series;
952         __u8    tx_mode;
953         __u8    tx_gear;
954         __u8    tx_nlanes;
955         __u8    rx_mode;
956         __u8    rx_gear;
957         __u8    rx_nlanes;
958         __u8    flags;
959         __le32  quirks;
960 } __packed;
961
962 struct gb_svc_intf_set_pwrm_response {
963         __le16  result_code;
964 } __packed;
965
966 struct gb_svc_key_event_request {
967         __le16  key_code;
968 #define GB_KEYCODE_ARA         0x00
969
970         __u8    key_event;
971 #define GB_SVC_KEY_RELEASED    0x00
972 #define GB_SVC_KEY_PRESSED     0x01
973 } __packed;
974
975 /* RAW */
976
977 /* Version of the Greybus raw protocol we support */
978 #define GB_RAW_VERSION_MAJOR                    0x00
979 #define GB_RAW_VERSION_MINOR                    0x01
980
981 /* Greybus raw request types */
982 #define GB_RAW_TYPE_SEND                        0x02
983
984 struct gb_raw_send_request {
985         __le32  len;
986         __u8    data[0];
987 } __packed;
988
989
990 /* UART */
991
992 /* Version of the Greybus UART protocol we support */
993 #define GB_UART_VERSION_MAJOR           0x00
994 #define GB_UART_VERSION_MINOR           0x01
995
996 /* Greybus UART operation types */
997 #define GB_UART_TYPE_SEND_DATA                  0x02
998 #define GB_UART_TYPE_RECEIVE_DATA               0x03    /* Unsolicited data */
999 #define GB_UART_TYPE_SET_LINE_CODING            0x04
1000 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE     0x05
1001 #define GB_UART_TYPE_SEND_BREAK                 0x06
1002 #define GB_UART_TYPE_SERIAL_STATE               0x07    /* Unsolicited data */
1003
1004 /* Represents data from AP -> Module */
1005 struct gb_uart_send_data_request {
1006         __le16  size;
1007         __u8    data[0];
1008 } __packed;
1009
1010 /* recv-data-request flags */
1011 #define GB_UART_RECV_FLAG_FRAMING               0x01    /* Framing error */
1012 #define GB_UART_RECV_FLAG_PARITY                0x02    /* Parity error */
1013 #define GB_UART_RECV_FLAG_OVERRUN               0x04    /* Overrun error */
1014 #define GB_UART_RECV_FLAG_BREAK                 0x08    /* Break */
1015
1016 /* Represents data from Module -> AP */
1017 struct gb_uart_recv_data_request {
1018         __le16  size;
1019         __u8    flags;
1020         __u8    data[0];
1021 } __packed;
1022
1023 struct gb_uart_set_line_coding_request {
1024         __le32  rate;
1025         __u8    format;
1026 #define GB_SERIAL_1_STOP_BITS                   0
1027 #define GB_SERIAL_1_5_STOP_BITS                 1
1028 #define GB_SERIAL_2_STOP_BITS                   2
1029
1030         __u8    parity;
1031 #define GB_SERIAL_NO_PARITY                     0
1032 #define GB_SERIAL_ODD_PARITY                    1
1033 #define GB_SERIAL_EVEN_PARITY                   2
1034 #define GB_SERIAL_MARK_PARITY                   3
1035 #define GB_SERIAL_SPACE_PARITY                  4
1036
1037         __u8    data_bits;
1038 } __packed;
1039
1040 /* output control lines */
1041 #define GB_UART_CTRL_DTR                        0x01
1042 #define GB_UART_CTRL_RTS                        0x02
1043
1044 struct gb_uart_set_control_line_state_request {
1045         __u8    control;
1046 } __packed;
1047
1048 struct gb_uart_set_break_request {
1049         __u8    state;
1050 } __packed;
1051
1052 /* input control lines and line errors */
1053 #define GB_UART_CTRL_DCD                        0x01
1054 #define GB_UART_CTRL_DSR                        0x02
1055 #define GB_UART_CTRL_RI                         0x04
1056
1057 struct gb_uart_serial_state_request {
1058         __u8    control;
1059 } __packed;
1060
1061 /* Loopback */
1062
1063 /* Version of the Greybus loopback protocol we support */
1064 #define GB_LOOPBACK_VERSION_MAJOR               0x00
1065 #define GB_LOOPBACK_VERSION_MINOR               0x01
1066
1067 /* Greybus loopback request types */
1068 #define GB_LOOPBACK_TYPE_PING                   0x02
1069 #define GB_LOOPBACK_TYPE_TRANSFER               0x03
1070 #define GB_LOOPBACK_TYPE_SINK                   0x04
1071
1072 /*
1073  * Loopback request/response header format should be identical
1074  * to simplify bandwidth and data movement analysis.
1075  */
1076 struct gb_loopback_transfer_request {
1077         __le32  len;
1078         __le32  reserved0;
1079         __le32  reserved1;
1080         __u8    data[0];
1081 } __packed;
1082
1083 struct gb_loopback_transfer_response {
1084         __le32  len;
1085         __le32  reserved0;
1086         __le32  reserved1;
1087         __u8    data[0];
1088 } __packed;
1089
1090 /* SDIO */
1091 /* Version of the Greybus sdio protocol we support */
1092 #define GB_SDIO_VERSION_MAJOR           0x00
1093 #define GB_SDIO_VERSION_MINOR           0x01
1094
1095 /* Greybus SDIO operation types */
1096 #define GB_SDIO_TYPE_GET_CAPABILITIES           0x02
1097 #define GB_SDIO_TYPE_SET_IOS                    0x03
1098 #define GB_SDIO_TYPE_COMMAND                    0x04
1099 #define GB_SDIO_TYPE_TRANSFER                   0x05
1100 #define GB_SDIO_TYPE_EVENT                      0x06
1101
1102 /* get caps response: request has no payload */
1103 struct gb_sdio_get_caps_response {
1104         __le32  caps;
1105 #define GB_SDIO_CAP_NONREMOVABLE        0x00000001
1106 #define GB_SDIO_CAP_4_BIT_DATA          0x00000002
1107 #define GB_SDIO_CAP_8_BIT_DATA          0x00000004
1108 #define GB_SDIO_CAP_MMC_HS              0x00000008
1109 #define GB_SDIO_CAP_SD_HS               0x00000010
1110 #define GB_SDIO_CAP_ERASE               0x00000020
1111 #define GB_SDIO_CAP_1_2V_DDR            0x00000040
1112 #define GB_SDIO_CAP_1_8V_DDR            0x00000080
1113 #define GB_SDIO_CAP_POWER_OFF_CARD      0x00000100
1114 #define GB_SDIO_CAP_UHS_SDR12           0x00000200
1115 #define GB_SDIO_CAP_UHS_SDR25           0x00000400
1116 #define GB_SDIO_CAP_UHS_SDR50           0x00000800
1117 #define GB_SDIO_CAP_UHS_SDR104          0x00001000
1118 #define GB_SDIO_CAP_UHS_DDR50           0x00002000
1119 #define GB_SDIO_CAP_DRIVER_TYPE_A       0x00004000
1120 #define GB_SDIO_CAP_DRIVER_TYPE_C       0x00008000
1121 #define GB_SDIO_CAP_DRIVER_TYPE_D       0x00010000
1122 #define GB_SDIO_CAP_HS200_1_2V          0x00020000
1123 #define GB_SDIO_CAP_HS200_1_8V          0x00040000
1124 #define GB_SDIO_CAP_HS400_1_2V          0x00080000
1125 #define GB_SDIO_CAP_HS400_1_8V          0x00100000
1126
1127         /* see possible values below at vdd */
1128         __le32 ocr;
1129         __le16 max_blk_count;
1130         __le16 max_blk_size;
1131         __le32 f_min;
1132         __le32 f_max;
1133 } __packed;
1134
1135 /* set ios request: response has no payload */
1136 struct gb_sdio_set_ios_request {
1137         __le32  clock;
1138         __le32  vdd;
1139 #define GB_SDIO_VDD_165_195     0x00000001
1140 #define GB_SDIO_VDD_20_21       0x00000002
1141 #define GB_SDIO_VDD_21_22       0x00000004
1142 #define GB_SDIO_VDD_22_23       0x00000008
1143 #define GB_SDIO_VDD_23_24       0x00000010
1144 #define GB_SDIO_VDD_24_25       0x00000020
1145 #define GB_SDIO_VDD_25_26       0x00000040
1146 #define GB_SDIO_VDD_26_27       0x00000080
1147 #define GB_SDIO_VDD_27_28       0x00000100
1148 #define GB_SDIO_VDD_28_29       0x00000200
1149 #define GB_SDIO_VDD_29_30       0x00000400
1150 #define GB_SDIO_VDD_30_31       0x00000800
1151 #define GB_SDIO_VDD_31_32       0x00001000
1152 #define GB_SDIO_VDD_32_33       0x00002000
1153 #define GB_SDIO_VDD_33_34       0x00004000
1154 #define GB_SDIO_VDD_34_35       0x00008000
1155 #define GB_SDIO_VDD_35_36       0x00010000
1156
1157         __u8    bus_mode;
1158 #define GB_SDIO_BUSMODE_OPENDRAIN       0x00
1159 #define GB_SDIO_BUSMODE_PUSHPULL        0x01
1160
1161         __u8    power_mode;
1162 #define GB_SDIO_POWER_OFF       0x00
1163 #define GB_SDIO_POWER_UP        0x01
1164 #define GB_SDIO_POWER_ON        0x02
1165 #define GB_SDIO_POWER_UNDEFINED 0x03
1166
1167         __u8    bus_width;
1168 #define GB_SDIO_BUS_WIDTH_1     0x00
1169 #define GB_SDIO_BUS_WIDTH_4     0x02
1170 #define GB_SDIO_BUS_WIDTH_8     0x03
1171
1172         __u8    timing;
1173 #define GB_SDIO_TIMING_LEGACY           0x00
1174 #define GB_SDIO_TIMING_MMC_HS           0x01
1175 #define GB_SDIO_TIMING_SD_HS            0x02
1176 #define GB_SDIO_TIMING_UHS_SDR12        0x03
1177 #define GB_SDIO_TIMING_UHS_SDR25        0x04
1178 #define GB_SDIO_TIMING_UHS_SDR50        0x05
1179 #define GB_SDIO_TIMING_UHS_SDR104       0x06
1180 #define GB_SDIO_TIMING_UHS_DDR50        0x07
1181 #define GB_SDIO_TIMING_MMC_DDR52        0x08
1182 #define GB_SDIO_TIMING_MMC_HS200        0x09
1183 #define GB_SDIO_TIMING_MMC_HS400        0x0A
1184
1185         __u8    signal_voltage;
1186 #define GB_SDIO_SIGNAL_VOLTAGE_330      0x00
1187 #define GB_SDIO_SIGNAL_VOLTAGE_180      0x01
1188 #define GB_SDIO_SIGNAL_VOLTAGE_120      0x02
1189
1190         __u8    drv_type;
1191 #define GB_SDIO_SET_DRIVER_TYPE_B       0x00
1192 #define GB_SDIO_SET_DRIVER_TYPE_A       0x01
1193 #define GB_SDIO_SET_DRIVER_TYPE_C       0x02
1194 #define GB_SDIO_SET_DRIVER_TYPE_D       0x03
1195 } __packed;
1196
1197 /* command request */
1198 struct gb_sdio_command_request {
1199         __u8    cmd;
1200         __u8    cmd_flags;
1201 #define GB_SDIO_RSP_NONE                0x00
1202 #define GB_SDIO_RSP_PRESENT             0x01
1203 #define GB_SDIO_RSP_136                 0x02
1204 #define GB_SDIO_RSP_CRC                 0x04
1205 #define GB_SDIO_RSP_BUSY                0x08
1206 #define GB_SDIO_RSP_OPCODE              0x10
1207
1208         __u8    cmd_type;
1209 #define GB_SDIO_CMD_AC          0x00
1210 #define GB_SDIO_CMD_ADTC        0x01
1211 #define GB_SDIO_CMD_BC          0x02
1212 #define GB_SDIO_CMD_BCR         0x03
1213
1214         __le32  cmd_arg;
1215         __le16  data_blocks;
1216         __le16  data_blksz;
1217 } __packed;
1218
1219 struct gb_sdio_command_response {
1220         __le32  resp[4];
1221 } __packed;
1222
1223 /* transfer request */
1224 struct gb_sdio_transfer_request {
1225         __u8    data_flags;
1226 #define GB_SDIO_DATA_WRITE      0x01
1227 #define GB_SDIO_DATA_READ       0x02
1228 #define GB_SDIO_DATA_STREAM     0x04
1229
1230         __le16  data_blocks;
1231         __le16  data_blksz;
1232         __u8    data[0];
1233 } __packed;
1234
1235 struct gb_sdio_transfer_response {
1236         __le16  data_blocks;
1237         __le16  data_blksz;
1238         __u8    data[0];
1239 } __packed;
1240
1241 /* event request: generated by module and is defined as unidirectional */
1242 struct gb_sdio_event_request {
1243         __u8    event;
1244 #define GB_SDIO_CARD_INSERTED   0x01
1245 #define GB_SDIO_CARD_REMOVED    0x02
1246 #define GB_SDIO_WP              0x04
1247 } __packed;
1248
1249 /* Camera */
1250
1251 #define GB_CAMERA_VERSION_MAJOR                 0x00
1252 #define GB_CAMERA_VERSION_MINOR                 0x01
1253
1254 /* Greybus Camera request types */
1255 #define GB_CAMERA_TYPE_CAPABILITIES             0x02
1256 #define GB_CAMERA_TYPE_CONFIGURE_STREAMS        0x03
1257 #define GB_CAMERA_TYPE_CAPTURE                  0x04
1258 #define GB_CAMERA_TYPE_FLUSH                    0x05
1259 #define GB_CAMERA_TYPE_METADATA                 0x06
1260
1261 #define GB_CAMERA_MAX_STREAMS                   4
1262 #define GB_CAMERA_MAX_SETTINGS_SIZE             8192
1263
1264 /* Greybus Camera Configure Streams request payload */
1265 struct gb_camera_stream_config_request {
1266         __le16 width;
1267         __le16 height;
1268         __le16 format;
1269         __le16 padding;
1270 } __packed;
1271
1272 struct gb_camera_configure_streams_request {
1273         __u8 num_streams;
1274         __u8 flags;
1275 #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY   0x01
1276         __le16 padding;
1277         struct gb_camera_stream_config_request config[0];
1278 } __packed;
1279
1280 /* Greybus Camera Configure Streams response payload */
1281 struct gb_camera_stream_config_response {
1282         __le16 width;
1283         __le16 height;
1284         __le16 format;
1285         __u8 virtual_channel;
1286         __u8 data_type[2];
1287         __u8 padding[3];
1288         __le32 max_size;
1289 } __packed;
1290
1291 struct gb_camera_configure_streams_response {
1292         __u8 num_streams;
1293         __u8 flags;
1294 #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED    0x01
1295         __u8 num_lanes;
1296         __u8 padding;
1297         __le32 bus_freq;
1298         __le32 lines_per_second;
1299         struct gb_camera_stream_config_response config[0];
1300 } __packed;
1301
1302 /* Greybus Camera Capture request payload - response has no payload */
1303 struct gb_camera_capture_request {
1304         __le32 request_id;
1305         __u8 streams;
1306         __u8 padding;
1307         __le16 num_frames;
1308         __u8 settings[0];
1309 } __packed;
1310
1311 /* Greybus Camera Flush response payload - request has no payload */
1312 struct gb_camera_flush_response {
1313         __le32 request_id;
1314 } __packed;
1315
1316 /* Greybus Camera Metadata request payload - operation has no response */
1317 struct gb_camera_metadata_request {
1318         __le32 request_id;
1319         __le16 frame_number;
1320         __u8 stream;
1321         __u8 padding;
1322         __u8 metadata[0];
1323 } __packed;
1324
1325 /* Lights */
1326
1327 #define GB_LIGHTS_VERSION_MAJOR 0x00
1328 #define GB_LIGHTS_VERSION_MINOR 0x01
1329
1330 /* Greybus Lights request types */
1331 #define GB_LIGHTS_TYPE_GET_LIGHTS               0x02
1332 #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG         0x03
1333 #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG       0x04
1334 #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1335 #define GB_LIGHTS_TYPE_SET_BRIGHTNESS           0x06
1336 #define GB_LIGHTS_TYPE_SET_BLINK                0x07
1337 #define GB_LIGHTS_TYPE_SET_COLOR                0x08
1338 #define GB_LIGHTS_TYPE_SET_FADE                 0x09
1339 #define GB_LIGHTS_TYPE_EVENT                    0x0A
1340 #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY      0x0B
1341 #define GB_LIGHTS_TYPE_SET_FLASH_STROBE         0x0C
1342 #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT        0x0D
1343 #define GB_LIGHTS_TYPE_GET_FLASH_FAULT          0x0E
1344
1345 /* Greybus Light modes */
1346
1347 /*
1348  * if you add any specific mode below, update also the
1349  * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1350  */
1351 #define GB_CHANNEL_MODE_NONE            0x00000000
1352 #define GB_CHANNEL_MODE_BATTERY         0x00000001
1353 #define GB_CHANNEL_MODE_POWER           0x00000002
1354 #define GB_CHANNEL_MODE_WIRELESS        0x00000004
1355 #define GB_CHANNEL_MODE_BLUETOOTH       0x00000008
1356 #define GB_CHANNEL_MODE_KEYBOARD        0x00000010
1357 #define GB_CHANNEL_MODE_BUTTONS         0x00000020
1358 #define GB_CHANNEL_MODE_NOTIFICATION    0x00000040
1359 #define GB_CHANNEL_MODE_ATTENTION       0x00000080
1360 #define GB_CHANNEL_MODE_FLASH           0x00000100
1361 #define GB_CHANNEL_MODE_TORCH           0x00000200
1362 #define GB_CHANNEL_MODE_INDICATOR       0x00000400
1363
1364 /* Lights Mode valid bit values */
1365 #define GB_CHANNEL_MODE_DEFINED_RANGE   0x000004FF
1366 #define GB_CHANNEL_MODE_VENDOR_RANGE    0x00F00000
1367
1368 /* Greybus Light Channels Flags */
1369 #define GB_LIGHT_CHANNEL_MULTICOLOR     0x00000001
1370 #define GB_LIGHT_CHANNEL_FADER          0x00000002
1371 #define GB_LIGHT_CHANNEL_BLINK          0x00000004
1372
1373 /* get count of lights in module */
1374 struct gb_lights_get_lights_response {
1375         __u8    lights_count;
1376 } __packed;
1377
1378 /* light config request payload */
1379 struct gb_lights_get_light_config_request {
1380         __u8    id;
1381 } __packed;
1382
1383 /* light config response payload */
1384 struct gb_lights_get_light_config_response {
1385         __u8    channel_count;
1386         __u8    name[32];
1387 } __packed;
1388
1389 /* channel config request payload */
1390 struct gb_lights_get_channel_config_request {
1391         __u8    light_id;
1392         __u8    channel_id;
1393 } __packed;
1394
1395 /* channel flash config request payload */
1396 struct gb_lights_get_channel_flash_config_request {
1397         __u8    light_id;
1398         __u8    channel_id;
1399 } __packed;
1400
1401 /* channel config response payload */
1402 struct gb_lights_get_channel_config_response {
1403         __u8    max_brightness;
1404         __le32  flags;
1405         __le32  color;
1406         __u8    color_name[32];
1407         __le32  mode;
1408         __u8    mode_name[32];
1409 } __packed;
1410
1411 /* channel flash config response payload */
1412 struct gb_lights_get_channel_flash_config_response {
1413         __le32  intensity_min_uA;
1414         __le32  intensity_max_uA;
1415         __le32  intensity_step_uA;
1416         __le32  timeout_min_us;
1417         __le32  timeout_max_us;
1418         __le32  timeout_step_us;
1419 } __packed;
1420
1421 /* blink request payload: response have no payload */
1422 struct gb_lights_blink_request {
1423         __u8    light_id;
1424         __u8    channel_id;
1425         __le16  time_on_ms;
1426         __le16  time_off_ms;
1427 } __packed;
1428
1429 /* set brightness request payload: response have no payload */
1430 struct gb_lights_set_brightness_request {
1431         __u8    light_id;
1432         __u8    channel_id;
1433         __u8    brightness;
1434 } __packed;
1435
1436 /* set color request payload: response have no payload */
1437 struct gb_lights_set_color_request {
1438         __u8    light_id;
1439         __u8    channel_id;
1440         __le32  color;
1441 } __packed;
1442
1443 /* set fade request payload: response have no payload */
1444 struct gb_lights_set_fade_request {
1445         __u8    light_id;
1446         __u8    channel_id;
1447         __u8    fade_in;
1448         __u8    fade_out;
1449 } __packed;
1450
1451 /* event request: generated by module */
1452 struct gb_lights_event_request {
1453         __u8    light_id;
1454         __u8    event;
1455 #define GB_LIGHTS_LIGHT_CONFIG          0x01
1456 } __packed;
1457
1458 /* set flash intensity request payload: response have no payload */
1459 struct gb_lights_set_flash_intensity_request {
1460         __u8    light_id;
1461         __u8    channel_id;
1462         __le32  intensity_uA;
1463 } __packed;
1464
1465 /* set flash strobe state request payload: response have no payload */
1466 struct gb_lights_set_flash_strobe_request {
1467         __u8    light_id;
1468         __u8    channel_id;
1469         __u8    state;
1470 } __packed;
1471
1472 /* set flash timeout request payload: response have no payload */
1473 struct gb_lights_set_flash_timeout_request {
1474         __u8    light_id;
1475         __u8    channel_id;
1476         __le32  timeout_us;
1477 } __packed;
1478
1479 /* get flash fault request payload */
1480 struct gb_lights_get_flash_fault_request {
1481         __u8    light_id;
1482         __u8    channel_id;
1483 } __packed;
1484
1485 /* get flash fault response payload */
1486 struct gb_lights_get_flash_fault_response {
1487         __le32  fault;
1488 #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE              0x00000000
1489 #define GB_LIGHTS_FLASH_FAULT_TIMEOUT                   0x00000001
1490 #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE          0x00000002
1491 #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT             0x00000004
1492 #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT              0x00000008
1493 #define GB_LIGHTS_FLASH_FAULT_INDICATOR                 0x00000010
1494 #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE             0x00000020
1495 #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE             0x00000040
1496 #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE      0x00000080
1497 } __packed;
1498
1499 /* Audio */
1500
1501 /* Version of the Greybus audio protocol we support */
1502 #define GB_AUDIO_VERSION_MAJOR                  0x00
1503 #define GB_AUDIO_VERSION_MINOR                  0x01
1504
1505 #define GB_AUDIO_TYPE_PROTOCOL_VERSION          0x01
1506 #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE         0x02
1507 #define GB_AUDIO_TYPE_GET_TOPOLOGY              0x03
1508 #define GB_AUDIO_TYPE_GET_CONTROL               0x04
1509 #define GB_AUDIO_TYPE_SET_CONTROL               0x05
1510 #define GB_AUDIO_TYPE_ENABLE_WIDGET             0x06
1511 #define GB_AUDIO_TYPE_DISABLE_WIDGET            0x07
1512 #define GB_AUDIO_TYPE_GET_PCM                   0x08
1513 #define GB_AUDIO_TYPE_SET_PCM                   0x09
1514 #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE          0x0a
1515 #define GB_AUDIO_TYPE_GET_TX_DELAY              0x0b
1516 #define GB_AUDIO_TYPE_ACTIVATE_TX               0x0c
1517 #define GB_AUDIO_TYPE_DEACTIVATE_TX             0x0d
1518 #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE          0x0e
1519 #define GB_AUDIO_TYPE_GET_RX_DELAY              0x0f
1520 #define GB_AUDIO_TYPE_ACTIVATE_RX               0x10
1521 #define GB_AUDIO_TYPE_DEACTIVATE_RX             0x11
1522 #define GB_AUDIO_TYPE_JACK_EVENT                0x12
1523 #define GB_AUDIO_TYPE_BUTTON_EVENT              0x13
1524 #define GB_AUDIO_TYPE_STREAMING_EVENT           0x14
1525 #define GB_AUDIO_TYPE_SEND_DATA                 0x15
1526
1527 /* Module must be able to buffer 10ms of audio data, minimum */
1528 #define GB_AUDIO_SAMPLE_BUFFER_MIN_US           10000
1529
1530 #define GB_AUDIO_PCM_NAME_MAX                   32
1531 #define AUDIO_DAI_NAME_MAX                      32
1532 #define AUDIO_CONTROL_NAME_MAX                  32
1533 #define AUDIO_CTL_ELEM_NAME_MAX                 44
1534 #define AUDIO_ENUM_NAME_MAX                     64
1535 #define AUDIO_WIDGET_NAME_MAX                   32
1536
1537 /* See SNDRV_PCM_FMTBIT_* in Linux source */
1538 #define GB_AUDIO_PCM_FMT_S8                     BIT(0)
1539 #define GB_AUDIO_PCM_FMT_U8                     BIT(1)
1540 #define GB_AUDIO_PCM_FMT_S16_LE                 BIT(2)
1541 #define GB_AUDIO_PCM_FMT_S16_BE                 BIT(3)
1542 #define GB_AUDIO_PCM_FMT_U16_LE                 BIT(4)
1543 #define GB_AUDIO_PCM_FMT_U16_BE                 BIT(5)
1544 #define GB_AUDIO_PCM_FMT_S24_LE                 BIT(6)
1545 #define GB_AUDIO_PCM_FMT_S24_BE                 BIT(7)
1546 #define GB_AUDIO_PCM_FMT_U24_LE                 BIT(8)
1547 #define GB_AUDIO_PCM_FMT_U24_BE                 BIT(9)
1548 #define GB_AUDIO_PCM_FMT_S32_LE                 BIT(10)
1549 #define GB_AUDIO_PCM_FMT_S32_BE                 BIT(11)
1550 #define GB_AUDIO_PCM_FMT_U32_LE                 BIT(12)
1551 #define GB_AUDIO_PCM_FMT_U32_BE                 BIT(13)
1552
1553 /* See SNDRV_PCM_RATE_* in Linux source */
1554 #define GB_AUDIO_PCM_RATE_5512                  BIT(0)
1555 #define GB_AUDIO_PCM_RATE_8000                  BIT(1)
1556 #define GB_AUDIO_PCM_RATE_11025                 BIT(2)
1557 #define GB_AUDIO_PCM_RATE_16000                 BIT(3)
1558 #define GB_AUDIO_PCM_RATE_22050                 BIT(4)
1559 #define GB_AUDIO_PCM_RATE_32000                 BIT(5)
1560 #define GB_AUDIO_PCM_RATE_44100                 BIT(6)
1561 #define GB_AUDIO_PCM_RATE_48000                 BIT(7)
1562 #define GB_AUDIO_PCM_RATE_64000                 BIT(8)
1563 #define GB_AUDIO_PCM_RATE_88200                 BIT(9)
1564 #define GB_AUDIO_PCM_RATE_96000                 BIT(10)
1565 #define GB_AUDIO_PCM_RATE_176400                BIT(11)
1566 #define GB_AUDIO_PCM_RATE_192000                BIT(12)
1567
1568 #define GB_AUDIO_STREAM_TYPE_CAPTURE            0x1
1569 #define GB_AUDIO_STREAM_TYPE_PLAYBACK           0x2
1570
1571 #define GB_AUDIO_CTL_ELEM_ACCESS_READ           BIT(0)
1572 #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE          BIT(1)
1573
1574 /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
1575 #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN          0x01
1576 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER          0x02
1577 #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED       0x03
1578 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64        0x06
1579
1580 /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
1581 #define GB_AUDIO_CTL_ELEM_IFACE_CARD            0x00
1582 #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP           0x01
1583 #define GB_AUDIO_CTL_ELEM_IFACE_MIXER           0x02
1584 #define GB_AUDIO_CTL_ELEM_IFACE_PCM             0x03
1585 #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI         0x04
1586 #define GB_AUDIO_CTL_ELEM_IFACE_TIMER           0x05
1587 #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER       0x06
1588
1589 /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
1590 #define GB_AUDIO_ACCESS_READ                    BIT(0)
1591 #define GB_AUDIO_ACCESS_WRITE                   BIT(1)
1592 #define GB_AUDIO_ACCESS_VOLATILE                BIT(2)
1593 #define GB_AUDIO_ACCESS_TIMESTAMP               BIT(3)
1594 #define GB_AUDIO_ACCESS_TLV_READ                BIT(4)
1595 #define GB_AUDIO_ACCESS_TLV_WRITE               BIT(5)
1596 #define GB_AUDIO_ACCESS_TLV_COMMAND             BIT(6)
1597 #define GB_AUDIO_ACCESS_INACTIVE                BIT(7)
1598 #define GB_AUDIO_ACCESS_LOCK                    BIT(8)
1599 #define GB_AUDIO_ACCESS_OWNER                   BIT(9)
1600
1601 /* enum snd_soc_dapm_type */
1602 #define GB_AUDIO_WIDGET_TYPE_INPUT              0x0
1603 #define GB_AUDIO_WIDGET_TYPE_OUTPUT             0x1
1604 #define GB_AUDIO_WIDGET_TYPE_MUX                0x2
1605 #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX           0x3
1606 #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX          0x4
1607 #define GB_AUDIO_WIDGET_TYPE_MIXER              0x5
1608 #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL    0x6
1609 #define GB_AUDIO_WIDGET_TYPE_PGA                0x7
1610 #define GB_AUDIO_WIDGET_TYPE_OUT_DRV            0x8
1611 #define GB_AUDIO_WIDGET_TYPE_ADC                0x9
1612 #define GB_AUDIO_WIDGET_TYPE_DAC                0xa
1613 #define GB_AUDIO_WIDGET_TYPE_MICBIAS            0xb
1614 #define GB_AUDIO_WIDGET_TYPE_MIC                0xc
1615 #define GB_AUDIO_WIDGET_TYPE_HP                 0xd
1616 #define GB_AUDIO_WIDGET_TYPE_SPK                0xe
1617 #define GB_AUDIO_WIDGET_TYPE_LINE               0xf
1618 #define GB_AUDIO_WIDGET_TYPE_SWITCH             0x10
1619 #define GB_AUDIO_WIDGET_TYPE_VMID               0x11
1620 #define GB_AUDIO_WIDGET_TYPE_PRE                0x12
1621 #define GB_AUDIO_WIDGET_TYPE_POST               0x13
1622 #define GB_AUDIO_WIDGET_TYPE_SUPPLY             0x14
1623 #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY   0x15
1624 #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY       0x16
1625 #define GB_AUDIO_WIDGET_TYPE_AIF_IN             0x17
1626 #define GB_AUDIO_WIDGET_TYPE_AIF_OUT            0x18
1627 #define GB_AUDIO_WIDGET_TYPE_SIGGEN             0x19
1628 #define GB_AUDIO_WIDGET_TYPE_DAI_IN             0x1a
1629 #define GB_AUDIO_WIDGET_TYPE_DAI_OUT            0x1b
1630 #define GB_AUDIO_WIDGET_TYPE_DAI_LINK           0x1c
1631
1632 #define GB_AUDIO_WIDGET_STATE_DISABLED          0x01
1633 #define GB_AUDIO_WIDGET_STATE_ENAABLED          0x02
1634
1635 #define GB_AUDIO_JACK_EVENT_INSERTION           0x1
1636 #define GB_AUDIO_JACK_EVENT_REMOVAL             0x2
1637
1638 #define GB_AUDIO_BUTTON_EVENT_PRESS             0x1
1639 #define GB_AUDIO_BUTTON_EVENT_RELEASE           0x2
1640
1641 #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED    0x1
1642 #define GB_AUDIO_STREAMING_EVENT_HALT           0x2
1643 #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3
1644 #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4
1645 #define GB_AUDIO_STREAMING_EVENT_FAILURE        0x5
1646 #define GB_AUDIO_STREAMING_EVENT_UNDERRUN       0x6
1647 #define GB_AUDIO_STREAMING_EVENT_OVERRUN        0x7
1648 #define GB_AUDIO_STREAMING_EVENT_CLOCKING       0x8
1649 #define GB_AUDIO_STREAMING_EVENT_DATA_LEN       0x9
1650
1651 #define GB_AUDIO_INVALID_INDEX                  0xff
1652
1653 struct gb_audio_pcm {
1654         __u8    stream_name[GB_AUDIO_PCM_NAME_MAX];
1655         __le32  formats;        /* GB_AUDIO_PCM_FMT_* */
1656         __le32  rates;          /* GB_AUDIO_PCM_RATE_* */
1657         __u8    chan_min;
1658         __u8    chan_max;
1659         __u8    sig_bits;       /* number of bits of content */
1660 } __packed;
1661
1662 struct gb_audio_dai {
1663         __u8                    name[AUDIO_DAI_NAME_MAX];
1664         __le16                  data_cport;
1665         struct gb_audio_pcm     capture;
1666         struct gb_audio_pcm     playback;
1667 } __packed;
1668
1669 struct gb_audio_integer {
1670         __le32  min;
1671         __le32  max;
1672         __le32  step;
1673 } __packed;
1674
1675 struct gb_audio_integer64 {
1676         __le64  min;
1677         __le64  max;
1678         __le64  step;
1679 } __packed;
1680
1681 struct gb_audio_enumerated {
1682         __le32  items;
1683         __le16  names_length;
1684         __u8    names[0];
1685 } __packed;
1686
1687 struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
1688         __u8            type;           /* GB_AUDIO_CTL_ELEM_TYPE_* */
1689         __le16          dimen[4];
1690         union {
1691                 struct gb_audio_integer         integer;
1692                 struct gb_audio_integer64       integer64;
1693                 struct gb_audio_enumerated      enumerated;
1694         } value;
1695 } __packed;
1696
1697 struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
1698         __le64                          timestamp; /* XXX needed? */
1699         union {
1700                 __le32  integer_value[2];       /* consider CTL_DOUBLE_xxx */
1701                 __le64  integer64_value[2];
1702                 __le32  enumerated_item[2];
1703         } value;
1704 } __packed;
1705
1706 struct gb_audio_control {
1707         __u8    name[AUDIO_CONTROL_NAME_MAX];
1708         __u8    id;             /* 0-63 */
1709         __u8    iface;          /* GB_AUDIO_IFACE_* */
1710         __le16  data_cport;
1711         __le32  access;         /* GB_AUDIO_ACCESS_* */
1712         __u8    count;          /* count of same elements */
1713         __u8    count_values;   /* count of values, max=2 for CTL_DOUBLE_xxx */
1714         struct gb_audio_ctl_elem_info   info;
1715 } __packed;
1716
1717 struct gb_audio_widget {
1718         __u8    name[AUDIO_WIDGET_NAME_MAX];
1719         __u8    sname[AUDIO_WIDGET_NAME_MAX];
1720         __u8    id;
1721         __u8    type;           /* GB_AUDIO_WIDGET_TYPE_* */
1722         __u8    state;          /* GB_AUDIO_WIDGET_STATE_* */
1723         __u8    ncontrols;
1724         struct gb_audio_control ctl[0]; /* 'ncontrols' entries */
1725 } __packed;
1726
1727 struct gb_audio_route {
1728         __u8    source_id;      /* widget id */
1729         __u8    destination_id; /* widget id */
1730         __u8    control_id;     /* 0-63 */
1731         __u8    index;          /* Selection within the control */
1732 } __packed;
1733
1734 struct gb_audio_topology {
1735         __u8    num_dais;
1736         __u8    num_controls;
1737         __u8    num_widgets;
1738         __u8    num_routes;
1739         __u32   size_dais;
1740         __u32   size_controls;
1741         __u32   size_widgets;
1742         __u32   size_routes;
1743         /*
1744          * struct gb_audio_dai          dai[num_dais];
1745          * struct gb_audio_control      controls[num_controls];
1746          * struct gb_audio_widget       widgets[num_widgets];
1747          * struct gb_audio_route        routes[num_routes];
1748          */
1749         __u8    data[0];
1750 } __packed;
1751
1752 struct gb_audio_get_topology_size_response {
1753         __le16  size;
1754 } __packed;
1755
1756 struct gb_audio_get_topology_response {
1757         struct gb_audio_topology        topology;
1758 } __packed;
1759
1760 struct gb_audio_get_control_request {
1761         __u8    control_id;
1762         __u8    index;
1763 } __packed;
1764
1765 struct gb_audio_get_control_response {
1766         struct gb_audio_ctl_elem_value  value;
1767 } __packed;
1768
1769 struct gb_audio_set_control_request {
1770         __u8    control_id;
1771         __u8    index;
1772         struct gb_audio_ctl_elem_value  value;
1773 } __packed;
1774
1775 struct gb_audio_enable_widget_request {
1776         __u8    widget_id;
1777 } __packed;
1778
1779 struct gb_audio_disable_widget_request {
1780         __u8    widget_id;
1781 } __packed;
1782
1783 struct gb_audio_get_pcm_request {
1784         __le16  data_cport;
1785 } __packed;
1786
1787 struct gb_audio_get_pcm_response {
1788         __le32  format;
1789         __le32  rate;
1790         __u8    channels;
1791         __u8    sig_bits;
1792 } __packed;
1793
1794 struct gb_audio_set_pcm_request {
1795         __le16  data_cport;
1796         __le32  format;
1797         __le32  rate;
1798         __u8    channels;
1799         __u8    sig_bits;
1800 } __packed;
1801
1802 struct gb_audio_set_tx_data_size_request {
1803         __le16  data_cport;
1804         __le16  size;
1805 } __packed;
1806
1807 struct gb_audio_get_tx_delay_request {
1808         __le16  data_cport;
1809 } __packed;
1810
1811 struct gb_audio_get_tx_delay_response {
1812         __le32  delay;
1813 } __packed;
1814
1815 struct gb_audio_activate_tx_request {
1816         __le16  data_cport;
1817 } __packed;
1818
1819 struct gb_audio_deactivate_tx_request {
1820         __le16  data_cport;
1821 } __packed;
1822
1823 struct gb_audio_set_rx_data_size_request {
1824         __le16  data_cport;
1825         __le16  size;
1826 } __packed;
1827
1828 struct gb_audio_get_rx_delay_request {
1829         __le16  data_cport;
1830 } __packed;
1831
1832 struct gb_audio_get_rx_delay_response {
1833         __le32  delay;
1834 } __packed;
1835
1836 struct gb_audio_activate_rx_request {
1837         __le16  data_cport;
1838 } __packed;
1839
1840 struct gb_audio_deactivate_rx_request {
1841         __le16  data_cport;
1842 } __packed;
1843
1844 struct gb_audio_jack_event_request {
1845         __u8    widget_id;
1846         __u8    widget_type;
1847         __u8    event;
1848 } __packed;
1849
1850 struct gb_audio_button_event_request {
1851         __u8    widget_id;
1852         __u8    button_id;
1853         __u8    event;
1854 } __packed;
1855
1856 struct gb_audio_streaming_event_request {
1857         __le16  data_cport;
1858         __u8    event;
1859 } __packed;
1860
1861 struct gb_audio_send_data_request {
1862         __le64  timestamp;
1863         __u8    data[0];
1864 } __packed;
1865
1866 #endif /* __GREYBUS_PROTOCOLS_H */
1867