]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/greybus/greybus_protocols.h
greybus: lights: add lights implementation
[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 };
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 /* Control Protocol */
107
108 /* version request has no payload */
109 struct gb_protocol_version_response {
110         __u8    major;
111         __u8    minor;
112 };
113
114 /* Control Protocol */
115
116 /* Version of the Greybus control protocol we support */
117 #define GB_CONTROL_VERSION_MAJOR                0x00
118 #define GB_CONTROL_VERSION_MINOR                0x01
119
120 /* Greybus control request types */
121 #define GB_CONTROL_TYPE_PROBE_AP                0x02
122 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE       0x03
123 #define GB_CONTROL_TYPE_GET_MANIFEST            0x04
124 #define GB_CONTROL_TYPE_CONNECTED               0x05
125 #define GB_CONTROL_TYPE_DISCONNECTED            0x06
126
127 /* Control protocol manifest get size request has no payload*/
128 struct gb_control_get_manifest_size_response {
129         __le16                  size;
130 };
131
132 /* Control protocol manifest get request has no payload */
133 struct gb_control_get_manifest_response {
134         __u8                    data[0];
135 };
136
137 /* Control protocol [dis]connected request */
138 struct gb_control_connected_request {
139         __le16                  cport_id;
140 };
141
142 struct gb_control_disconnected_request {
143         __le16                  cport_id;
144 };
145 /* Control protocol [dis]connected response has no payload */
146
147
148 /* Firmware Protocol */
149
150 /* Version of the Greybus firmware protocol we support */
151 #define GB_FIRMWARE_VERSION_MAJOR               0x00
152 #define GB_FIRMWARE_VERSION_MINOR               0x01
153
154 /* Greybus firmware request types */
155 #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE          0x02
156 #define GB_FIRMWARE_TYPE_GET_FIRMWARE           0x03
157 #define GB_FIRMWARE_TYPE_READY_TO_BOOT          0x04
158
159 /* Greybus firmware boot stages */
160 #define GB_FIRMWARE_BOOT_STAGE_ONE              0x01 /* Reserved for the boot ROM */
161 #define GB_FIRMWARE_BOOT_STAGE_TWO              0x02 /* Firmware package to be loaded by the boot ROM */
162 #define GB_FIRMWARE_BOOT_STAGE_THREE            0x03 /* Module personality package loaded by Stage 2 firmware */
163
164 /* Greybus firmware ready to boot status */
165 #define GB_FIRMWARE_BOOT_STATUS_INVALID         0x00 /* Firmware blob could not be validated */
166 #define GB_FIRMWARE_BOOT_STATUS_INSECURE        0x01 /* Firmware blob is valid but insecure */
167 #define GB_FIRMWARE_BOOT_STATUS_SECURE          0x02 /* Firmware blob is valid and secure */
168
169 /* Max firmware data fetch size in bytes */
170 #define GB_FIRMWARE_FETCH_MAX                   2000
171
172 /* Firmware protocol firmware size request/response */
173 struct gb_firmware_size_request {
174         __u8                    stage;
175 };
176
177 struct gb_firmware_size_response {
178         __le32                  size;
179 };
180
181 /* Firmware protocol get firmware request/response */
182 struct gb_firmware_get_firmware_request {
183         __le32                  offset;
184         __le32                  size;
185 };
186
187 struct gb_firmware_get_firmware_response {
188         __u8                    data[0];
189 };
190
191 /* Firmware protocol Ready to boot request */
192 struct gb_firmware_ready_to_boot_request {
193         __u8                    stage;
194         __u8                    status;
195 };
196 /* Firmware protocol Ready to boot response has no payload */
197
198
199 /* BATTERY */
200
201 /* Version of the Greybus battery protocol we support */
202 #define GB_BATTERY_VERSION_MAJOR                0x00
203 #define GB_BATTERY_VERSION_MINOR                0x01
204
205 /* Greybus battery request types */
206 #define GB_BATTERY_TYPE_TECHNOLOGY              0x02
207 #define GB_BATTERY_TYPE_STATUS                  0x03
208 #define GB_BATTERY_TYPE_MAX_VOLTAGE             0x04
209 #define GB_BATTERY_TYPE_PERCENT_CAPACITY        0x05
210 #define GB_BATTERY_TYPE_TEMPERATURE             0x06
211 #define GB_BATTERY_TYPE_VOLTAGE                 0x07
212 #define GB_BATTERY_TYPE_CURRENT                 0x08
213 #define GB_BATTERY_TYPE_CAPACITY                0x09    // TODO - POWER_SUPPLY_PROP_CURRENT_MAX
214 #define GB_BATTERY_TYPE_SHUTDOWN_TEMP           0x0a    // TODO - POWER_SUPPLY_PROP_TEMP_ALERT_MAX
215
216 /* Should match up with battery types in linux/power_supply.h */
217 #define GB_BATTERY_TECH_UNKNOWN                 0x0000
218 #define GB_BATTERY_TECH_NiMH                    0x0001
219 #define GB_BATTERY_TECH_LION                    0x0002
220 #define GB_BATTERY_TECH_LIPO                    0x0003
221 #define GB_BATTERY_TECH_LiFe                    0x0004
222 #define GB_BATTERY_TECH_NiCd                    0x0005
223 #define GB_BATTERY_TECH_LiMn                    0x0006
224
225 struct gb_battery_technology_response {
226         __le32  technology;
227 };
228
229 /* Should match up with battery status in linux/power_supply.h */
230 #define GB_BATTERY_STATUS_UNKNOWN               0x0000
231 #define GB_BATTERY_STATUS_CHARGING              0x0001
232 #define GB_BATTERY_STATUS_DISCHARGING           0x0002
233 #define GB_BATTERY_STATUS_NOT_CHARGING          0x0003
234 #define GB_BATTERY_STATUS_FULL                  0x0004
235
236 struct gb_battery_status_response {
237         __le16  battery_status;
238 };
239
240 struct gb_battery_max_voltage_response {
241         __le32  max_voltage;
242 };
243
244 struct gb_battery_capacity_response {
245         __le32  capacity;
246 };
247
248 struct gb_battery_temperature_response {
249         __le32  temperature;
250 };
251
252 struct gb_battery_voltage_response {
253         __le32  voltage;
254 };
255
256
257 /* HID */
258
259 /* Version of the Greybus hid protocol we support */
260 #define GB_HID_VERSION_MAJOR            0x00
261 #define GB_HID_VERSION_MINOR            0x01
262
263 /* Greybus HID operation types */
264 #define GB_HID_TYPE_GET_DESC            0x02
265 #define GB_HID_TYPE_GET_REPORT_DESC     0x03
266 #define GB_HID_TYPE_PWR_ON              0x04
267 #define GB_HID_TYPE_PWR_OFF             0x05
268 #define GB_HID_TYPE_GET_REPORT          0x06
269 #define GB_HID_TYPE_SET_REPORT          0x07
270 #define GB_HID_TYPE_IRQ_EVENT           0x08
271
272 /* Report type */
273 #define GB_HID_INPUT_REPORT             0
274 #define GB_HID_OUTPUT_REPORT            1
275 #define GB_HID_FEATURE_REPORT           2
276
277 /* Different request/response structures */
278 /* HID get descriptor response */
279 struct gb_hid_desc_response {
280         __u8                            bLength;
281         __le16                          wReportDescLength;
282         __le16                          bcdHID;
283         __le16                          wProductID;
284         __le16                          wVendorID;
285         __u8                            bCountryCode;
286 } __packed;
287
288 /* HID get report request/response */
289 struct gb_hid_get_report_request {
290         __u8                            report_type;
291         __u8                            report_id;
292 };
293
294 /* HID set report request */
295 struct gb_hid_set_report_request {
296         __u8                            report_type;
297         __u8                            report_id;
298         __u8                            report[0];
299 };
300
301 /* HID input report request, via interrupt pipe */
302 struct gb_hid_input_report_request {
303         __u8                            report[0];
304 };
305
306
307 /* I2C */
308
309 /* Version of the Greybus i2c protocol we support */
310 #define GB_I2C_VERSION_MAJOR            0x00
311 #define GB_I2C_VERSION_MINOR            0x01
312
313 /* Greybus i2c request types */
314 #define GB_I2C_TYPE_FUNCTIONALITY       0x02
315 #define GB_I2C_TYPE_TIMEOUT             0x03
316 #define GB_I2C_TYPE_RETRIES             0x04
317 #define GB_I2C_TYPE_TRANSFER            0x05
318
319 #define GB_I2C_RETRIES_DEFAULT          3
320 #define GB_I2C_TIMEOUT_DEFAULT          1000    /* milliseconds */
321
322 /* functionality request has no payload */
323 struct gb_i2c_functionality_response {
324         __le32  functionality;
325 };
326
327 struct gb_i2c_timeout_request {
328         __le16  msec;
329 };
330 /* timeout response has no payload */
331
332 struct gb_i2c_retries_request {
333         __u8    retries;
334 };
335 /* retries response has no payload */
336
337 /*
338  * Outgoing data immediately follows the op count and ops array.
339  * The data for each write (master -> slave) op in the array is sent
340  * in order, with no (e.g. pad) bytes separating them.
341  *
342  * Short reads cause the entire transfer request to fail So response
343  * payload consists only of bytes read, and the number of bytes is
344  * exactly what was specified in the corresponding op.  Like
345  * outgoing data, the incoming data is in order and contiguous.
346  */
347 struct gb_i2c_transfer_op {
348         __le16  addr;
349         __le16  flags;
350         __le16  size;
351 };
352
353 struct gb_i2c_transfer_request {
354         __le16                          op_count;
355         struct gb_i2c_transfer_op       ops[0];         /* op_count of these */
356 };
357 struct gb_i2c_transfer_response {
358         __u8                            data[0];        /* inbound data */
359 };
360
361
362 /* GPIO */
363
364 /* Version of the Greybus GPIO protocol we support */
365 #define GB_GPIO_VERSION_MAJOR           0x00
366 #define GB_GPIO_VERSION_MINOR           0x01
367
368 /* Greybus GPIO request types */
369 #define GB_GPIO_TYPE_LINE_COUNT         0x02
370 #define GB_GPIO_TYPE_ACTIVATE           0x03
371 #define GB_GPIO_TYPE_DEACTIVATE         0x04
372 #define GB_GPIO_TYPE_GET_DIRECTION      0x05
373 #define GB_GPIO_TYPE_DIRECTION_IN       0x06
374 #define GB_GPIO_TYPE_DIRECTION_OUT      0x07
375 #define GB_GPIO_TYPE_GET_VALUE          0x08
376 #define GB_GPIO_TYPE_SET_VALUE          0x09
377 #define GB_GPIO_TYPE_SET_DEBOUNCE       0x0a
378 #define GB_GPIO_TYPE_IRQ_TYPE           0x0b
379 #define GB_GPIO_TYPE_IRQ_MASK           0x0c
380 #define GB_GPIO_TYPE_IRQ_UNMASK         0x0d
381 #define GB_GPIO_TYPE_IRQ_EVENT          0x0e
382
383 #define GB_GPIO_IRQ_TYPE_NONE           0x00
384 #define GB_GPIO_IRQ_TYPE_EDGE_RISING    0x01
385 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING   0x02
386 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH      0x03
387 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH     0x04
388 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW      0x08
389
390 /* line count request has no payload */
391 struct gb_gpio_line_count_response {
392         __u8    count;
393 };
394
395 struct gb_gpio_activate_request {
396         __u8    which;
397 };
398 /* activate response has no payload */
399
400 struct gb_gpio_deactivate_request {
401         __u8    which;
402 };
403 /* deactivate response has no payload */
404
405 struct gb_gpio_get_direction_request {
406         __u8    which;
407 };
408 struct gb_gpio_get_direction_response {
409         __u8    direction;
410 };
411
412 struct gb_gpio_direction_in_request {
413         __u8    which;
414 };
415 /* direction in response has no payload */
416
417 struct gb_gpio_direction_out_request {
418         __u8    which;
419         __u8    value;
420 };
421 /* direction out response has no payload */
422
423 struct gb_gpio_get_value_request {
424         __u8    which;
425 };
426 struct gb_gpio_get_value_response {
427         __u8    value;
428 };
429
430 struct gb_gpio_set_value_request {
431         __u8    which;
432         __u8    value;
433 };
434 /* set value response has no payload */
435
436 struct gb_gpio_set_debounce_request {
437         __u8    which;
438         __le16  usec;
439 } __packed;
440 /* debounce response has no payload */
441
442 struct gb_gpio_irq_type_request {
443         __u8    which;
444         __u8    type;
445 };
446 /* irq type response has no payload */
447
448 struct gb_gpio_irq_mask_request {
449         __u8    which;
450 };
451 /* irq mask response has no payload */
452
453 struct gb_gpio_irq_unmask_request {
454         __u8    which;
455 };
456 /* irq unmask response has no payload */
457
458 /* irq event requests originate on another module and are handled on the AP */
459 struct gb_gpio_irq_event_request {
460         __u8    which;
461 };
462 /* irq event has no response */
463
464
465 /* PWM */
466
467 /* Version of the Greybus PWM protocol we support */
468 #define GB_PWM_VERSION_MAJOR            0x00
469 #define GB_PWM_VERSION_MINOR            0x01
470
471 /* Greybus PWM operation types */
472 #define GB_PWM_TYPE_PWM_COUNT           0x02
473 #define GB_PWM_TYPE_ACTIVATE            0x03
474 #define GB_PWM_TYPE_DEACTIVATE          0x04
475 #define GB_PWM_TYPE_CONFIG              0x05
476 #define GB_PWM_TYPE_POLARITY            0x06
477 #define GB_PWM_TYPE_ENABLE              0x07
478 #define GB_PWM_TYPE_DISABLE             0x08
479
480 /* pwm count request has no payload */
481 struct gb_pwm_count_response {
482         __u8    count;
483 };
484
485 struct gb_pwm_activate_request {
486         __u8    which;
487 };
488
489 struct gb_pwm_deactivate_request {
490         __u8    which;
491 };
492
493 struct gb_pwm_config_request {
494         __u8    which;
495         __le32  duty;
496         __le32  period;
497 } __packed;
498
499 struct gb_pwm_polarity_request {
500         __u8    which;
501         __u8    polarity;
502 };
503
504 struct gb_pwm_enable_request {
505         __u8    which;
506 };
507
508 struct gb_pwm_disable_request {
509         __u8    which;
510 };
511
512 /* I2S */
513
514 #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS   0x02
515 #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION              0x03
516 #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE        0x04
517 #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY           0x05
518 #define GB_I2S_MGMT_TYPE_SET_START_DELAY                0x06
519 #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT                 0x07
520 #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT               0x08
521 #define GB_I2S_MGMT_TYPE_REPORT_EVENT                   0x09
522
523 #define GB_I2S_MGMT_BYTE_ORDER_NA                       BIT(0)
524 #define GB_I2S_MGMT_BYTE_ORDER_BE                       BIT(1)
525 #define GB_I2S_MGMT_BYTE_ORDER_LE                       BIT(2)
526
527 #define GB_I2S_MGMT_SPATIAL_LOCATION_FL                 BIT(0)
528 #define GB_I2S_MGMT_SPATIAL_LOCATION_FR                 BIT(1)
529 #define GB_I2S_MGMT_SPATIAL_LOCATION_FC                 BIT(2)
530 #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE                BIT(3)
531 #define GB_I2S_MGMT_SPATIAL_LOCATION_BL                 BIT(4)
532 #define GB_I2S_MGMT_SPATIAL_LOCATION_BR                 BIT(5)
533 #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC                BIT(6)
534 #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC                BIT(7)
535 #define GB_I2S_MGMT_SPATIAL_LOCATION_C                  BIT(8) /* BC in USB */
536 #define GB_I2S_MGMT_SPATIAL_LOCATION_SL                 BIT(9)
537 #define GB_I2S_MGMT_SPATIAL_LOCATION_SR                 BIT(10)
538 #define GB_I2S_MGMT_SPATIAL_LOCATION_TC                 BIT(11)
539 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL                BIT(12)
540 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC                BIT(13)
541 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR                BIT(14)
542 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL                BIT(15)
543 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC                BIT(16)
544 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR                BIT(17)
545 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC               BIT(18)
546 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC               BIT(19)
547 #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE               BIT(20)
548 #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE               BIT(21)
549 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL                BIT(22)
550 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR                BIT(23)
551 #define GB_I2S_MGMT_SPATIAL_LOCATION_BC                 BIT(24)
552 #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC                BIT(25)
553 #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC                BIT(26)
554 #define GB_I2S_MGMT_SPATIAL_LOCATION_RD                 BIT(31)
555
556 #define GB_I2S_MGMT_PROTOCOL_PCM                        BIT(0)
557 #define GB_I2S_MGMT_PROTOCOL_I2S                        BIT(1)
558 #define GB_I2S_MGMT_PROTOCOL_LR_STEREO                  BIT(2)
559
560 #define GB_I2S_MGMT_ROLE_MASTER                         BIT(0)
561 #define GB_I2S_MGMT_ROLE_SLAVE                          BIT(1)
562
563 #define GB_I2S_MGMT_POLARITY_NORMAL                     BIT(0)
564 #define GB_I2S_MGMT_POLARITY_REVERSED                   BIT(1)
565
566 #define GB_I2S_MGMT_EDGE_RISING                         BIT(0)
567 #define GB_I2S_MGMT_EDGE_FALLING                        BIT(1)
568
569 #define GB_I2S_MGMT_EVENT_UNSPECIFIED                   0x1
570 #define GB_I2S_MGMT_EVENT_HALT                          0x2
571 #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR                0x3
572 #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR                0x4
573 #define GB_I2S_MGMT_EVENT_FAILURE                       0x5
574 #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE               0x6
575 #define GB_I2S_MGMT_EVENT_UNDERRUN                      0x7
576 #define GB_I2S_MGMT_EVENT_OVERRUN                       0x8
577 #define GB_I2S_MGMT_EVENT_CLOCKING                      0x9
578 #define GB_I2S_MGMT_EVENT_DATA_LEN                      0xa
579
580 struct gb_i2s_mgmt_configuration {
581         __le32  sample_frequency;
582         __u8    num_channels;
583         __u8    bytes_per_channel;
584         __u8    byte_order;
585         __u8    pad;
586         __le32  spatial_locations;
587         __le32  ll_protocol;
588         __u8    ll_mclk_role;
589         __u8    ll_bclk_role;
590         __u8    ll_wclk_role;
591         __u8    ll_wclk_polarity;
592         __u8    ll_wclk_change_edge;
593         __u8    ll_wclk_tx_edge;
594         __u8    ll_wclk_rx_edge;
595         __u8    ll_data_offset;
596 };
597
598 /* get supported configurations request has no payload */
599 struct gb_i2s_mgmt_get_supported_configurations_response {
600         __u8                                    config_count;
601         __u8                                    pad[3];
602         struct gb_i2s_mgmt_configuration        config[0];
603 };
604
605 struct gb_i2s_mgmt_set_configuration_request {
606         struct gb_i2s_mgmt_configuration        config;
607 };
608 /* set configuration response has no payload */
609
610 struct gb_i2s_mgmt_set_samples_per_message_request {
611         __le16  samples_per_message;
612 };
613 /* set samples per message response has no payload */
614
615 /* get processing request delay has no payload */
616 struct gb_i2s_mgmt_get_processing_delay_response {
617         __le32  microseconds;
618 };
619
620 struct gb_i2s_mgmt_set_start_delay_request {
621         __le32  microseconds;
622 };
623 /* set start delay response has no payload */
624
625 struct gb_i2s_mgmt_activate_cport_request {
626         __le16  cport;
627 };
628 /* activate cport response has no payload */
629
630 struct gb_i2s_mgmt_deactivate_cport_request {
631         __le16  cport;
632 };
633 /* deactivate cport response has no payload */
634
635 struct gb_i2s_mgmt_report_event_request {
636         __u8    event;
637 };
638 /* report event response has no payload */
639
640 #define GB_I2S_DATA_TYPE_SEND_DATA                      0x02
641
642 struct gb_i2s_send_data_request {
643         __le32  sample_number;
644         __le32  size;
645         __u8    data[0];
646 };
647 /* send data has no response at all */
648
649
650 /* SPI */
651
652 /* Version of the Greybus spi protocol we support */
653 #define GB_SPI_VERSION_MAJOR            0x00
654 #define GB_SPI_VERSION_MINOR            0x01
655
656 /* Should match up with modes in linux/spi/spi.h */
657 #define GB_SPI_MODE_CPHA                0x01            /* clock phase */
658 #define GB_SPI_MODE_CPOL                0x02            /* clock polarity */
659 #define GB_SPI_MODE_MODE_0              (0|0)           /* (original MicroWire) */
660 #define GB_SPI_MODE_MODE_1              (0|GB_SPI_MODE_CPHA)
661 #define GB_SPI_MODE_MODE_2              (GB_SPI_MODE_CPOL|0)
662 #define GB_SPI_MODE_MODE_3              (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
663 #define GB_SPI_MODE_CS_HIGH             0x04            /* chipselect active high? */
664 #define GB_SPI_MODE_LSB_FIRST           0x08            /* per-word bits-on-wire */
665 #define GB_SPI_MODE_3WIRE               0x10            /* SI/SO signals shared */
666 #define GB_SPI_MODE_LOOP                0x20            /* loopback mode */
667 #define GB_SPI_MODE_NO_CS               0x40            /* 1 dev/bus, no chipselect */
668 #define GB_SPI_MODE_READY               0x80            /* slave pulls low to pause */
669
670 /* Should match up with flags in linux/spi/spi.h */
671 #define GB_SPI_FLAG_HALF_DUPLEX         BIT(0)          /* can't do full duplex */
672 #define GB_SPI_FLAG_NO_RX               BIT(1)          /* can't do buffer read */
673 #define GB_SPI_FLAG_NO_TX               BIT(2)          /* can't do buffer write */
674
675 /* Greybus spi operation types */
676 #define GB_SPI_TYPE_MODE                0x02
677 #define GB_SPI_TYPE_FLAGS               0x03
678 #define GB_SPI_TYPE_BITS_PER_WORD_MASK  0x04
679 #define GB_SPI_TYPE_NUM_CHIPSELECT      0x05
680 #define GB_SPI_TYPE_TRANSFER            0x06
681
682 /* mode request has no payload */
683 struct gb_spi_mode_response {
684         __le16  mode;
685 };
686
687 /* flags request has no payload */
688 struct gb_spi_flags_response {
689         __le16  flags;
690 };
691
692 /* bits-per-word request has no payload */
693 struct gb_spi_bpw_response {
694         __le32  bits_per_word_mask;
695 };
696
697 /* num-chipselects request has no payload */
698 struct gb_spi_chipselect_response {
699         __le16  num_chipselect;
700 };
701
702 /**
703  * struct gb_spi_transfer - a read/write buffer pair
704  * @speed_hz: Select a speed other than the device default for this transfer. If
705  *      0 the default (from @spi_device) is used.
706  * @len: size of rx and tx buffers (in bytes)
707  * @delay_usecs: microseconds to delay after this transfer before (optionally)
708  *      changing the chipselect status, then starting the next transfer or
709  *      completing this spi_message.
710  * @cs_change: affects chipselect after this transfer completes
711  * @bits_per_word: select a bits_per_word other than the device default for this
712  *      transfer. If 0 the default (from @spi_device) is used.
713  */
714 struct gb_spi_transfer {
715         __le32          speed_hz;
716         __le32          len;
717         __le16          delay_usecs;
718         __u8            cs_change;
719         __u8            bits_per_word;
720 };
721
722 struct gb_spi_transfer_request {
723         __u8                    chip_select;    /* of the spi device */
724         __u8                    mode;           /* of the spi device */
725         __le16                  count;
726         struct gb_spi_transfer  transfers[0];   /* count of these */
727 };
728
729 struct gb_spi_transfer_response {
730         __u8                    data[0];        /* inbound data */
731 };
732
733 /* Version of the Greybus SVC protocol we support */
734 #define GB_SVC_VERSION_MAJOR            0x00
735 #define GB_SVC_VERSION_MINOR            0x01
736
737 /* Greybus SVC request types */
738 #define GB_SVC_TYPE_SVC_HELLO           0x02
739 #define GB_SVC_TYPE_INTF_DEVICE_ID      0x03
740 #define GB_SVC_TYPE_INTF_HOTPLUG        0x04
741 #define GB_SVC_TYPE_INTF_HOT_UNPLUG     0x05
742 #define GB_SVC_TYPE_INTF_RESET          0x06
743 #define GB_SVC_TYPE_CONN_CREATE         0x07
744 #define GB_SVC_TYPE_CONN_DESTROY        0x08
745 #define GB_SVC_TYPE_ROUTE_CREATE        0x0b
746
747 /* SVC version request/response have same payload as gb_protocol_version_response */
748
749 /* SVC protocol hello request */
750 struct gb_svc_hello_request {
751         __le16                  endo_id;
752         __u8                    interface_id;
753 } __packed;
754 /* hello response has no payload */
755
756 struct gb_svc_intf_device_id_request {
757         __u8    intf_id;
758         __u8    device_id;
759 };
760 /* device id response has no payload */
761
762 struct gb_svc_intf_hotplug_request {
763         __u8    intf_id;
764         struct {
765                 __le32  unipro_mfg_id;
766                 __le32  unipro_prod_id;
767                 __le32  ara_vend_id;
768                 __le32  ara_prod_id;
769         } data;
770 } __packed;
771 /* hotplug response has no payload */
772
773 struct gb_svc_intf_hot_unplug_request {
774         __u8    intf_id;
775 };
776 /* hot unplug response has no payload */
777
778 struct gb_svc_intf_reset_request {
779         __u8    intf_id;
780 };
781 /* interface reset response has no payload */
782
783 struct gb_svc_conn_create_request {
784         __u8    intf1_id;
785         __u16   cport1_id;
786         __u8    intf2_id;
787         __u16   cport2_id;
788         __u8    tc;
789         __u8    flags;
790 } __packed;
791 /* connection create response has no payload */
792
793 struct gb_svc_conn_destroy_request {
794         __u8    intf1_id;
795         __u16   cport1_id;
796         __u8    intf2_id;
797         __u16   cport2_id;
798 } __packed;
799 /* connection destroy response has no payload */
800
801 struct gb_svc_route_create_request {
802         __u8    intf1_id;
803         __u8    dev1_id;
804         __u8    intf2_id;
805         __u8    dev2_id;
806 };
807
808
809 /* RAW */
810
811 /* Version of the Greybus raw protocol we support */
812 #define GB_RAW_VERSION_MAJOR                    0x00
813 #define GB_RAW_VERSION_MINOR                    0x01
814
815 /* Greybus raw request types */
816 #define GB_RAW_TYPE_SEND                        0x02
817
818 struct gb_raw_send_request {
819         __le32  len;
820         __u8    data[0];
821 };
822
823
824 /* UART */
825
826 /* Version of the Greybus UART protocol we support */
827 #define GB_UART_VERSION_MAJOR           0x00
828 #define GB_UART_VERSION_MINOR           0x01
829
830 /* Greybus UART operation types */
831 #define GB_UART_TYPE_SEND_DATA                  0x02
832 #define GB_UART_TYPE_RECEIVE_DATA               0x03    /* Unsolicited data */
833 #define GB_UART_TYPE_SET_LINE_CODING            0x04
834 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE     0x05
835 #define GB_UART_TYPE_SEND_BREAK                 0x06
836 #define GB_UART_TYPE_SERIAL_STATE               0x07    /* Unsolicited data */
837
838 /* Represents data from AP -> Module */
839 struct gb_uart_send_data_request {
840         __le16  size;
841         __u8    data[0];
842 };
843
844 /* recv-data-request flags */
845 #define GB_UART_RECV_FLAG_FRAMING               0x01    /* Framing error */
846 #define GB_UART_RECV_FLAG_PARITY                0x02    /* Parity error */
847 #define GB_UART_RECV_FLAG_OVERRUN               0x04    /* Overrun error */
848 #define GB_UART_RECV_FLAG_BREAK                 0x08    /* Break */
849
850 /* Represents data from Module -> AP */
851 struct gb_uart_recv_data_request {
852         __le16  size;
853         __u8    flags;
854         __u8    data[0];
855 } __packed;
856
857 struct gb_uart_set_line_coding_request {
858         __le32  rate;
859         __u8    format;
860 #define GB_SERIAL_1_STOP_BITS                   0
861 #define GB_SERIAL_1_5_STOP_BITS                 1
862 #define GB_SERIAL_2_STOP_BITS                   2
863
864         __u8    parity;
865 #define GB_SERIAL_NO_PARITY                     0
866 #define GB_SERIAL_ODD_PARITY                    1
867 #define GB_SERIAL_EVEN_PARITY                   2
868 #define GB_SERIAL_MARK_PARITY                   3
869 #define GB_SERIAL_SPACE_PARITY                  4
870
871         __u8    data_bits;
872 } __packed;
873
874 /* output control lines */
875 #define GB_UART_CTRL_DTR                        0x01
876 #define GB_UART_CTRL_RTS                        0x02
877
878 struct gb_uart_set_control_line_state_request {
879         __u8    control;
880 };
881
882 struct gb_uart_set_break_request {
883         __u8    state;
884 };
885
886 /* input control lines and line errors */
887 #define GB_UART_CTRL_DCD                        0x01
888 #define GB_UART_CTRL_DSR                        0x02
889 #define GB_UART_CTRL_RI                         0x04
890
891 struct gb_uart_serial_state_request {
892         __u8    control;
893 };
894
895 /* Loopback */
896
897 /* Version of the Greybus loopback protocol we support */
898 #define GB_LOOPBACK_VERSION_MAJOR               0x00
899 #define GB_LOOPBACK_VERSION_MINOR               0x01
900
901 /* Greybus loopback request types */
902 #define GB_LOOPBACK_TYPE_PING                   0x02
903 #define GB_LOOPBACK_TYPE_TRANSFER               0x03
904 #define GB_LOOPBACK_TYPE_SINK                   0x04
905
906 struct gb_loopback_transfer_request {
907         __le32  len;
908         __u8    data[0];
909 };
910
911 struct gb_loopback_transfer_response {
912         __u8    data[0];
913 };
914
915 /* SDIO */
916 /* Version of the Greybus sdio protocol we support */
917 #define GB_SDIO_VERSION_MAJOR           0x00
918 #define GB_SDIO_VERSION_MINOR           0x01
919
920 /* Greybus SDIO operation types */
921 #define GB_SDIO_TYPE_GET_CAPABILITIES           0x02
922 #define GB_SDIO_TYPE_SET_IOS                    0x03
923 #define GB_SDIO_TYPE_COMMAND                    0x04
924 #define GB_SDIO_TYPE_TRANSFER                   0x05
925 #define GB_SDIO_TYPE_EVENT                      0x06
926
927 /* get caps response: request has no payload */
928 struct gb_sdio_get_caps_response {
929         __le32  caps;
930 #define GB_SDIO_CAP_NONREMOVABLE        0x00000001
931 #define GB_SDIO_CAP_4_BIT_DATA          0x00000002
932 #define GB_SDIO_CAP_8_BIT_DATA          0x00000004
933 #define GB_SDIO_CAP_MMC_HS              0x00000008
934 #define GB_SDIO_CAP_SD_HS               0x00000010
935 #define GB_SDIO_CAP_ERASE               0x00000020
936 #define GB_SDIO_CAP_1_2V_DDR            0x00000040
937 #define GB_SDIO_CAP_1_8V_DDR            0x00000080
938 #define GB_SDIO_CAP_POWER_OFF_CARD      0x00000100
939 #define GB_SDIO_CAP_UHS_SDR12           0x00000200
940 #define GB_SDIO_CAP_UHS_SDR25           0x00000400
941 #define GB_SDIO_CAP_UHS_SDR50           0x00000800
942 #define GB_SDIO_CAP_UHS_SDR104          0x00001000
943 #define GB_SDIO_CAP_UHS_DDR50           0x00002000
944 #define GB_SDIO_CAP_DRIVER_TYPE_A       0x00004000
945 #define GB_SDIO_CAP_DRIVER_TYPE_C       0x00008000
946 #define GB_SDIO_CAP_DRIVER_TYPE_D       0x00010000
947 #define GB_SDIO_CAP_HS200_1_2V          0x00020000
948 #define GB_SDIO_CAP_HS200_1_8V          0x00040000
949 #define GB_SDIO_CAP_HS400_1_2V          0x00080000
950 #define GB_SDIO_CAP_HS400_1_8V          0x00100000
951
952         /* see possible values below at vdd */
953         __le32 ocr;
954         __le16 max_blk_count;
955         __le16 max_blk_size;
956 };
957
958 /* set ios request: response has no payload */
959 struct gb_sdio_set_ios_request {
960         __le32  clock;
961         __le32  vdd;
962 #define GB_SDIO_VDD_165_195     0x00000001
963 #define GB_SDIO_VDD_20_21       0x00000002
964 #define GB_SDIO_VDD_21_22       0x00000004
965 #define GB_SDIO_VDD_22_23       0x00000008
966 #define GB_SDIO_VDD_23_24       0x00000010
967 #define GB_SDIO_VDD_24_25       0x00000020
968 #define GB_SDIO_VDD_25_26       0x00000040
969 #define GB_SDIO_VDD_26_27       0x00000080
970 #define GB_SDIO_VDD_27_28       0x00000100
971 #define GB_SDIO_VDD_28_29       0x00000200
972 #define GB_SDIO_VDD_29_30       0x00000400
973 #define GB_SDIO_VDD_30_31       0x00000800
974 #define GB_SDIO_VDD_31_32       0x00001000
975 #define GB_SDIO_VDD_32_33       0x00002000
976 #define GB_SDIO_VDD_33_34       0x00004000
977 #define GB_SDIO_VDD_34_35       0x00008000
978 #define GB_SDIO_VDD_35_36       0x00010000
979
980         __u8    bus_mode;
981 #define GB_SDIO_BUSMODE_OPENDRAIN       0x00
982 #define GB_SDIO_BUSMODE_PUSHPULL        0x01
983
984         __u8    power_mode;
985 #define GB_SDIO_POWER_OFF       0x00
986 #define GB_SDIO_POWER_UP        0x01
987 #define GB_SDIO_POWER_ON        0x02
988 #define GB_SDIO_POWER_UNDEFINED 0x03
989
990         __u8    bus_width;
991 #define GB_SDIO_BUS_WIDTH_1     0x00
992 #define GB_SDIO_BUS_WIDTH_4     0x02
993 #define GB_SDIO_BUS_WIDTH_8     0x03
994
995         __u8    timing;
996 #define GB_SDIO_TIMING_LEGACY           0x00
997 #define GB_SDIO_TIMING_MMC_HS           0x01
998 #define GB_SDIO_TIMING_SD_HS            0x02
999 #define GB_SDIO_TIMING_UHS_SDR12        0x03
1000 #define GB_SDIO_TIMING_UHS_SDR25        0x04
1001 #define GB_SDIO_TIMING_UHS_SDR50        0x05
1002 #define GB_SDIO_TIMING_UHS_SDR104       0x06
1003 #define GB_SDIO_TIMING_UHS_DDR50        0x07
1004 #define GB_SDIO_TIMING_MMC_DDR52        0x08
1005 #define GB_SDIO_TIMING_MMC_HS200        0x09
1006 #define GB_SDIO_TIMING_MMC_HS400        0x0A
1007
1008         __u8    signal_voltage;
1009 #define GB_SDIO_SIGNAL_VOLTAGE_330      0x00
1010 #define GB_SDIO_SIGNAL_VOLTAGE_180      0x01
1011 #define GB_SDIO_SIGNAL_VOLTAGE_120      0x02
1012
1013         __u8    drv_type;
1014 #define GB_SDIO_SET_DRIVER_TYPE_B       0x00
1015 #define GB_SDIO_SET_DRIVER_TYPE_A       0x01
1016 #define GB_SDIO_SET_DRIVER_TYPE_C       0x02
1017 #define GB_SDIO_SET_DRIVER_TYPE_D       0x03
1018 } __packed;
1019
1020 /* command request */
1021 struct gb_sdio_command_request {
1022         __u8    cmd;
1023         __u8    cmd_flags;
1024 #define GB_SDIO_RSP_NONE                0x00
1025 #define GB_SDIO_RSP_PRESENT             0x01
1026 #define GB_SDIO_RSP_136                 0x02
1027 #define GB_SDIO_RSP_CRC                 0x04
1028 #define GB_SDIO_RSP_BUSY                0x08
1029 #define GB_SDIO_RSP_OPCODE              0x10
1030
1031         __u8    cmd_type;
1032 #define GB_SDIO_CMD_AC          0x00
1033 #define GB_SDIO_CMD_ADTC        0x01
1034 #define GB_SDIO_CMD_BCR         0x02
1035 #define GB_SDIO_CMD_BC          0x03
1036
1037         __le32  cmd_arg;
1038 } __packed;
1039
1040 struct gb_sdio_command_response {
1041         __le32  resp[4];
1042 };
1043
1044 /* transfer request */
1045 struct gb_sdio_transfer_request {
1046         __u8    data_flags;
1047 #define GB_SDIO_DATA_WRITE      0x01
1048 #define GB_SDIO_DATA_READ       0x02
1049 #define GB_SDIO_DATA_STREAM     0x04
1050
1051         __le16  data_blocks;
1052         __le16  data_blksz;
1053         __u8    data[0];
1054 } __packed;
1055
1056 struct gb_sdio_transfer_response {
1057         __le16  data_blocks;
1058         __le16  data_blksz;
1059         __u8    data[0];
1060 };
1061
1062 /* event request: generated by module and is defined as unidirectional */
1063 struct gb_sdio_event_request {
1064         __u8    event;
1065 #define GB_SDIO_CARD_INSERTED   0x01
1066 #define GB_SDIO_CARD_REMOVED    0x02
1067 #define GB_SDIO_WP              0x04
1068 };
1069
1070 /* Lights */
1071
1072 #define GB_LIGHTS_VERSION_MAJOR 0x00
1073 #define GB_LIGHTS_VERSION_MINOR 0x01
1074
1075 /* Greybus Lights request types */
1076 #define GB_LIGHTS_TYPE_INVALID                  0x00
1077 #define GB_LIGHTS_TYPE_PROTOCOL_VERSION         0x01
1078 #define GB_LIGHTS_TYPE_GET_LIGHTS               0x02
1079 #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG         0x03
1080 #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG       0x04
1081 #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1082 #define GB_LIGHTS_TYPE_SET_BRIGHTNESS           0x06
1083 #define GB_LIGHTS_TYPE_SET_BLINK                0x07
1084 #define GB_LIGHTS_TYPE_SET_COLOR                0x08
1085 #define GB_LIGHTS_TYPE_SET_FADE                 0x09
1086 #define GB_LIGHTS_TYPE_EVENT                    0x0A
1087 #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY      0x0B
1088 #define GB_LIGHTS_TYPE_SET_FLASH_STROBE         0x0C
1089 #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT        0x0D
1090 #define GB_LIGHTS_TYPE_GET_FLASH_FAULT          0x0E
1091
1092 /* Greybus Light modes */
1093
1094 /*
1095  * if you add any specific mode below, update also the
1096  * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1097  */
1098 #define GB_CHANNEL_MODE_NONE            0x00000000
1099 #define GB_CHANNEL_MODE_BATTERY         0x00000001
1100 #define GB_CHANNEL_MODE_POWER           0x00000002
1101 #define GB_CHANNEL_MODE_WIRELESS        0x00000004
1102 #define GB_CHANNEL_MODE_BLUETOOTH       0x00000008
1103 #define GB_CHANNEL_MODE_KEYBOARD        0x00000010
1104 #define GB_CHANNEL_MODE_BUTTONS         0x00000020
1105 #define GB_CHANNEL_MODE_NOTIFICATION    0x00000040
1106 #define GB_CHANNEL_MODE_ATTENTION       0x00000080
1107 #define GB_CHANNEL_MODE_FLASH           0x00000100
1108 #define GB_CHANNEL_MODE_TORCH           0x00000200
1109 #define GB_CHANNEL_MODE_INDICATOR       0x00000400
1110
1111 /* Lights Mode valid bit values */
1112 #define GB_CHANNEL_MODE_DEFINED_RANGE   0x000004FF
1113 #define GB_CHANNEL_MODE_VENDOR_RANGE    0x00F00000
1114
1115 /* Greybus Light Channels Flags */
1116 #define GB_LIGHT_CHANNEL_MULTICOLOR     0x00000001
1117 #define GB_LIGHT_CHANNEL_FADER          0x00000002
1118 #define GB_LIGHT_CHANNEL_BLINK          0x00000004
1119
1120 /* get count of lights in module */
1121 struct gb_lights_get_lights_response {
1122         __u8    lights_count;
1123 };
1124
1125 /* light config request payload */
1126 struct gb_lights_get_light_config_request {
1127         __u8    id;
1128 };
1129
1130 /* light config response payload */
1131 struct gb_lights_get_light_config_response {
1132         __u8    channel_count;
1133         __u8    name[32];
1134 };
1135
1136 /* channel config request payload */
1137 struct gb_lights_get_channel_config_request {
1138         __u8    light_id;
1139         __u8    channel_id;
1140 };
1141
1142 /* channel flash config request payload */
1143 struct gb_lights_get_channel_flash_config_request {
1144         __u8    light_id;
1145         __u8    channel_id;
1146 };
1147
1148 /* channel config response payload */
1149 struct gb_lights_get_channel_config_response {
1150         __u8    max_brightness;
1151         __le32  flags;
1152         __le32  color;
1153         __u8    color_name[32];
1154         __le32  mode;
1155         __u8    mode_name[32];
1156 } __packed;
1157
1158 /* channel flash config response payload */
1159 struct gb_lights_get_channel_flash_config_response {
1160         __le32  intensity_min_uA;
1161         __le32  intensity_max_uA;
1162         __le32  intensity_step_uA;
1163         __le32  timeout_min_us;
1164         __le32  timeout_max_us;
1165         __le32  timeout_step_us;
1166 };
1167
1168 /* blink request payload: response have no payload */
1169 struct gb_lights_blink_request {
1170         __u8    light_id;
1171         __u8    channel_id;
1172         __le16  time_on_ms;
1173         __le16  time_off_ms;
1174 };
1175
1176 /* set brightness request payload: response have no payload */
1177 struct gb_lights_set_brightness_request {
1178         __u8    light_id;
1179         __u8    channel_id;
1180         __u8    brightness;
1181 };
1182
1183 /* set color request payload: response have no payload */
1184 struct gb_lights_set_color_request {
1185         __u8    light_id;
1186         __u8    channel_id;
1187         __le32  color;
1188 } __packed;
1189
1190 /* set fade request payload: response have no payload */
1191 struct gb_lights_set_fade_request {
1192         __u8    light_id;
1193         __u8    channel_id;
1194         __u8    fade_in;
1195         __u8    fade_out;
1196 };
1197
1198 /* event request: generated by module */
1199 struct gb_lights_event_request {
1200         __u8    light_id;
1201         __u8    event;
1202 #define GB_LIGHTS_LIGHT_CONFIG          0x01
1203 };
1204
1205 /* set flash intensity request payload: response have no payload */
1206 struct gb_lights_set_flash_intensity_request {
1207         __u8    light_id;
1208         __u8    channel_id;
1209         __le32  intensity_uA;
1210 } __packed;
1211
1212 /* set flash strobe state request payload: response have no payload */
1213 struct gb_lights_set_flash_strobe_request {
1214         __u8    light_id;
1215         __u8    channel_id;
1216         __u8    state;
1217 };
1218
1219 /* set flash timeout request payload: response have no payload */
1220 struct gb_lights_set_flash_timeout_request {
1221         __u8    light_id;
1222         __u8    channel_id;
1223         __le32  timeout_us;
1224 } __packed;
1225
1226 /* get flash fault request payload */
1227 struct gb_lights_get_flash_fault_request {
1228         __u8    light_id;
1229         __u8    channel_id;
1230 };
1231
1232 /* get flash fault response payload */
1233 struct gb_lights_get_flash_fault_response {
1234         __le32  fault;
1235 #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE              0x00000000
1236 #define GB_LIGHTS_FLASH_FAULT_TIMEOUT                   0x00000001
1237 #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE          0x00000002
1238 #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT             0x00000004
1239 #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT              0x00000008
1240 #define GB_LIGHTS_FLASH_FAULT_INDICATOR                 0x00000010
1241 #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE             0x00000020
1242 #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE             0x00000040
1243 #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE      0x00000080
1244 };
1245
1246 #endif /* __GREYBUS_PROTOCOLS_H */
1247