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