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.
7 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
8 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
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.
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.
21 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
22 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
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
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
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.
52 #ifndef __GREYBUS_PROTOCOLS_H
53 #define __GREYBUS_PROTOCOLS_H
55 /* Fixed IDs for control/svc protocols */
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
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.
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
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).
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.
89 * The wire format for all numeric fields in the header is little
90 * endian. Any operation-specific data begins immediately after the
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) */
102 /* Generic request numbers supported by all modules */
103 #define GB_REQUEST_TYPE_INVALID 0x00
104 #define GB_REQUEST_TYPE_PROTOCOL_VERSION 0x01
106 struct gb_protocol_version_request {
111 struct gb_protocol_version_response {
116 /* Control Protocol */
118 /* Greybus control request types */
119 #define GB_CONTROL_TYPE_VERSION 0x01
120 #define GB_CONTROL_TYPE_PROBE_AP 0x02
121 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
122 #define GB_CONTROL_TYPE_GET_MANIFEST 0x04
123 #define GB_CONTROL_TYPE_CONNECTED 0x05
124 #define GB_CONTROL_TYPE_DISCONNECTED 0x06
125 #define GB_CONTROL_TYPE_INTERFACE_VERSION 0x0a
126 #define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b
128 struct gb_control_version_request {
133 struct gb_control_version_response {
138 struct gb_control_bundle_version_request {
142 struct gb_control_bundle_version_response {
147 /* Control protocol manifest get size request has no payload*/
148 struct gb_control_get_manifest_size_response {
152 /* Control protocol manifest get request has no payload */
153 struct gb_control_get_manifest_response {
157 /* Control protocol [dis]connected request */
158 struct gb_control_connected_request {
162 struct gb_control_disconnected_request {
165 /* Control protocol [dis]connected response has no payload */
167 /* Control protocol interface version request has no payload */
168 struct gb_control_interface_version_response {
174 /* APBridge protocol */
176 /* request APB1 log */
177 #define GB_APB_REQUEST_LOG 0x02
179 /* request to map a cport to bulk in and bulk out endpoints */
180 #define GB_APB_REQUEST_EP_MAPPING 0x03
182 /* request to get the number of cports available */
183 #define GB_APB_REQUEST_CPORT_COUNT 0x04
185 /* request to reset a cport state */
186 #define GB_APB_REQUEST_RESET_CPORT 0x05
188 /* request to time the latency of messages on a given cport */
189 #define GB_APB_REQUEST_LATENCY_TAG_EN 0x06
190 #define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07
192 /* request to control the CSI transmitter */
193 #define GB_APB_REQUEST_CSI_TX_CONTROL 0x08
195 /* request to control the CSI transmitter */
196 #define GB_APB_REQUEST_AUDIO_CONTROL 0x09
199 /* Firmware Protocol */
201 /* Version of the Greybus firmware protocol we support */
202 #define GB_FIRMWARE_VERSION_MAJOR 0x00
203 #define GB_FIRMWARE_VERSION_MINOR 0x01
205 /* Greybus firmware request types */
206 #define GB_FIRMWARE_TYPE_VERSION 0x01
207 #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02
208 #define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03
209 #define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04
210 #define GB_FIRMWARE_TYPE_AP_READY 0x05 /* Request with no-payload */
211 #define GB_FIRMWARE_TYPE_GET_VID_PID 0x06 /* Request with no-payload */
213 /* FIXME: remove all ES2-specific identifiers from the kernel */
214 #define ES2_DDBL1_MFR_ID 0x00000126
215 #define ES2_DDBL1_PROD_ID 0x00001000
217 /* Greybus firmware boot stages */
218 #define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
219 #define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */
220 #define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
222 /* Greybus firmware ready to boot status */
223 #define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
224 #define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
225 #define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
227 /* Max firmware data fetch size in bytes */
228 #define GB_FIRMWARE_FETCH_MAX 2000
230 struct gb_firmware_version_request {
235 struct gb_firmware_version_response {
240 /* Firmware protocol firmware size request/response */
241 struct gb_firmware_size_request {
245 struct gb_firmware_size_response {
249 /* Firmware protocol get firmware request/response */
250 struct gb_firmware_get_firmware_request {
255 struct gb_firmware_get_firmware_response {
259 /* Firmware protocol Ready to boot request */
260 struct gb_firmware_ready_to_boot_request {
263 /* Firmware protocol Ready to boot response has no payload */
265 /* Firmware protocol get VID/PID request has no payload */
266 struct gb_firmware_get_vid_pid_response {
274 /* Version of the Greybus power supply protocol we support */
275 #define GB_POWER_SUPPLY_VERSION_MAJOR 0x00
276 #define GB_POWER_SUPPLY_VERSION_MINOR 0x01
278 /* Greybus power supply request types */
279 #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02
280 #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03
281 #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04
282 #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05
283 #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06
284 #define GB_POWER_SUPPLY_TYPE_EVENT 0x07
286 /* Should match up with battery technologies in linux/power_supply.h */
287 #define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000
288 #define GB_POWER_SUPPLY_TECH_NiMH 0x0001
289 #define GB_POWER_SUPPLY_TECH_LION 0x0002
290 #define GB_POWER_SUPPLY_TECH_LIPO 0x0003
291 #define GB_POWER_SUPPLY_TECH_LiFe 0x0004
292 #define GB_POWER_SUPPLY_TECH_NiCd 0x0005
293 #define GB_POWER_SUPPLY_TECH_LiMn 0x0006
295 /* Should match up with power supply types in linux/power_supply.h */
296 #define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000
297 #define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001
298 #define GB_POWER_SUPPLY_UPS_TYPE 0x0002
299 #define GB_POWER_SUPPLY_MAINS_TYPE 0x0003
300 #define GB_POWER_SUPPLY_USB_TYPE 0x0004
301 #define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005
302 #define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006
303 #define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007
305 /* Should match up with power supply health in linux/power_supply.h */
306 #define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000
307 #define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001
308 #define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002
309 #define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003
310 #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004
311 #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005
312 #define GB_POWER_SUPPLY_HEALTH_COLD 0x0006
313 #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007
314 #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008
316 /* Should match up with battery status in linux/power_supply.h */
317 #define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000
318 #define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001
319 #define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002
320 #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003
321 #define GB_POWER_SUPPLY_STATUS_FULL 0x0004
323 struct gb_power_supply_get_supplies_response {
327 struct gb_power_supply_get_description_request {
331 struct gb_power_supply_get_description_response {
332 __u8 manufacturer[32];
334 __u8 serial_number[32];
336 __u8 properties_count;
339 struct gb_power_supply_props_desc {
341 #define GB_POWER_SUPPLY_PROP_STATUS 0x00
342 #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01
343 #define GB_POWER_SUPPLY_PROP_HEALTH 0x02
344 #define GB_POWER_SUPPLY_PROP_PRESENT 0x03
345 #define GB_POWER_SUPPLY_PROP_ONLINE 0x04
346 #define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05
347 #define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06
348 #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07
349 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08
350 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09
351 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A
352 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B
353 #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C
354 #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D
355 #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E
356 #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F
357 #define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10
358 #define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11
359 #define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12
360 #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13
361 #define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14
362 #define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15
363 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16
364 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17
365 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18
366 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19
367 #define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A
368 #define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B
369 #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C
370 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D
371 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E
372 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F
373 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20
374 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21
375 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22
376 #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23
377 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24
378 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25
379 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26
380 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27
381 #define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28
382 #define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29
383 #define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A
384 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B
385 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C
386 #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D
387 #define GB_POWER_SUPPLY_PROP_TEMP 0x2E
388 #define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F
389 #define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30
390 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31
391 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32
392 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33
393 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34
394 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35
395 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36
396 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37
397 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38
398 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39
399 #define GB_POWER_SUPPLY_PROP_TYPE 0x3A
400 #define GB_POWER_SUPPLY_PROP_SCOPE 0x3B
401 #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C
402 #define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D
406 struct gb_power_supply_get_property_descriptors_request {
410 struct gb_power_supply_get_property_descriptors_response {
411 __u8 properties_count;
412 struct gb_power_supply_props_desc props[];
415 struct gb_power_supply_get_property_request {
420 struct gb_power_supply_get_property_response {
424 struct gb_power_supply_set_property_request {
430 struct gb_power_supply_event_request {
433 #define GB_POWER_SUPPLY_UPDATE 0x01
439 /* Version of the Greybus hid protocol we support */
440 #define GB_HID_VERSION_MAJOR 0x00
441 #define GB_HID_VERSION_MINOR 0x01
443 /* Greybus HID operation types */
444 #define GB_HID_TYPE_GET_DESC 0x02
445 #define GB_HID_TYPE_GET_REPORT_DESC 0x03
446 #define GB_HID_TYPE_PWR_ON 0x04
447 #define GB_HID_TYPE_PWR_OFF 0x05
448 #define GB_HID_TYPE_GET_REPORT 0x06
449 #define GB_HID_TYPE_SET_REPORT 0x07
450 #define GB_HID_TYPE_IRQ_EVENT 0x08
453 #define GB_HID_INPUT_REPORT 0
454 #define GB_HID_OUTPUT_REPORT 1
455 #define GB_HID_FEATURE_REPORT 2
457 /* Different request/response structures */
458 /* HID get descriptor response */
459 struct gb_hid_desc_response {
461 __le16 wReportDescLength;
468 /* HID get report request/response */
469 struct gb_hid_get_report_request {
474 /* HID set report request */
475 struct gb_hid_set_report_request {
481 /* HID input report request, via interrupt pipe */
482 struct gb_hid_input_report_request {
489 /* Version of the Greybus i2c protocol we support */
490 #define GB_I2C_VERSION_MAJOR 0x00
491 #define GB_I2C_VERSION_MINOR 0x01
493 /* Greybus i2c request types */
494 #define GB_I2C_TYPE_FUNCTIONALITY 0x02
495 #define GB_I2C_TYPE_TIMEOUT 0x03
496 #define GB_I2C_TYPE_RETRIES 0x04
497 #define GB_I2C_TYPE_TRANSFER 0x05
499 #define GB_I2C_RETRIES_DEFAULT 3
500 #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
502 /* functionality request has no payload */
503 struct gb_i2c_functionality_response {
504 __le32 functionality;
507 struct gb_i2c_timeout_request {
510 /* timeout response has no payload */
512 struct gb_i2c_retries_request {
515 /* retries response has no payload */
518 * Outgoing data immediately follows the op count and ops array.
519 * The data for each write (master -> slave) op in the array is sent
520 * in order, with no (e.g. pad) bytes separating them.
522 * Short reads cause the entire transfer request to fail So response
523 * payload consists only of bytes read, and the number of bytes is
524 * exactly what was specified in the corresponding op. Like
525 * outgoing data, the incoming data is in order and contiguous.
527 struct gb_i2c_transfer_op {
533 struct gb_i2c_transfer_request {
535 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
537 struct gb_i2c_transfer_response {
538 __u8 data[0]; /* inbound data */
544 /* Version of the Greybus GPIO protocol we support */
545 #define GB_GPIO_VERSION_MAJOR 0x00
546 #define GB_GPIO_VERSION_MINOR 0x01
548 /* Greybus GPIO request types */
549 #define GB_GPIO_TYPE_LINE_COUNT 0x02
550 #define GB_GPIO_TYPE_ACTIVATE 0x03
551 #define GB_GPIO_TYPE_DEACTIVATE 0x04
552 #define GB_GPIO_TYPE_GET_DIRECTION 0x05
553 #define GB_GPIO_TYPE_DIRECTION_IN 0x06
554 #define GB_GPIO_TYPE_DIRECTION_OUT 0x07
555 #define GB_GPIO_TYPE_GET_VALUE 0x08
556 #define GB_GPIO_TYPE_SET_VALUE 0x09
557 #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
558 #define GB_GPIO_TYPE_IRQ_TYPE 0x0b
559 #define GB_GPIO_TYPE_IRQ_MASK 0x0c
560 #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
561 #define GB_GPIO_TYPE_IRQ_EVENT 0x0e
563 #define GB_GPIO_IRQ_TYPE_NONE 0x00
564 #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
565 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
566 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
567 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
568 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
570 /* line count request has no payload */
571 struct gb_gpio_line_count_response {
575 struct gb_gpio_activate_request {
578 /* activate response has no payload */
580 struct gb_gpio_deactivate_request {
583 /* deactivate response has no payload */
585 struct gb_gpio_get_direction_request {
588 struct gb_gpio_get_direction_response {
592 struct gb_gpio_direction_in_request {
595 /* direction in response has no payload */
597 struct gb_gpio_direction_out_request {
601 /* direction out response has no payload */
603 struct gb_gpio_get_value_request {
606 struct gb_gpio_get_value_response {
610 struct gb_gpio_set_value_request {
614 /* set value response has no payload */
616 struct gb_gpio_set_debounce_request {
620 /* debounce response has no payload */
622 struct gb_gpio_irq_type_request {
626 /* irq type response has no payload */
628 struct gb_gpio_irq_mask_request {
631 /* irq mask response has no payload */
633 struct gb_gpio_irq_unmask_request {
636 /* irq unmask response has no payload */
638 /* irq event requests originate on another module and are handled on the AP */
639 struct gb_gpio_irq_event_request {
642 /* irq event has no response */
647 /* Version of the Greybus PWM protocol we support */
648 #define GB_PWM_VERSION_MAJOR 0x00
649 #define GB_PWM_VERSION_MINOR 0x01
651 /* Greybus PWM operation types */
652 #define GB_PWM_TYPE_PWM_COUNT 0x02
653 #define GB_PWM_TYPE_ACTIVATE 0x03
654 #define GB_PWM_TYPE_DEACTIVATE 0x04
655 #define GB_PWM_TYPE_CONFIG 0x05
656 #define GB_PWM_TYPE_POLARITY 0x06
657 #define GB_PWM_TYPE_ENABLE 0x07
658 #define GB_PWM_TYPE_DISABLE 0x08
660 /* pwm count request has no payload */
661 struct gb_pwm_count_response {
665 struct gb_pwm_activate_request {
669 struct gb_pwm_deactivate_request {
673 struct gb_pwm_config_request {
679 struct gb_pwm_polarity_request {
684 struct gb_pwm_enable_request {
688 struct gb_pwm_disable_request {
694 /* Version of the Greybus spi protocol we support */
695 #define GB_SPI_VERSION_MAJOR 0x00
696 #define GB_SPI_VERSION_MINOR 0x01
698 /* Should match up with modes in linux/spi/spi.h */
699 #define GB_SPI_MODE_CPHA 0x01 /* clock phase */
700 #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
701 #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
702 #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
703 #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
704 #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
705 #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
706 #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
707 #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
708 #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
709 #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
710 #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
712 /* Should match up with flags in linux/spi/spi.h */
713 #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
714 #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
715 #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
717 /* Greybus spi operation types */
718 #define GB_SPI_TYPE_MASTER_CONFIG 0x02
719 #define GB_SPI_TYPE_DEVICE_CONFIG 0x03
720 #define GB_SPI_TYPE_TRANSFER 0x04
722 /* mode request has no payload */
723 struct gb_spi_master_config_response {
724 __le32 bits_per_word_mask;
732 struct gb_spi_device_config_request {
736 struct gb_spi_device_config_response {
741 #define GB_SPI_SPI_DEV 0x00
742 #define GB_SPI_SPI_NOR 0x01
743 #define GB_SPI_SPI_MODALIAS 0x02
748 * struct gb_spi_transfer - a read/write buffer pair
749 * @speed_hz: Select a speed other than the device default for this transfer. If
750 * 0 the default (from @spi_device) is used.
751 * @len: size of rx and tx buffers (in bytes)
752 * @delay_usecs: microseconds to delay after this transfer before (optionally)
753 * changing the chipselect status, then starting the next transfer or
754 * completing this spi_message.
755 * @cs_change: affects chipselect after this transfer completes
756 * @bits_per_word: select a bits_per_word other than the device default for this
757 * transfer. If 0 the default (from @spi_device) is used.
759 struct gb_spi_transfer {
766 #define GB_SPI_XFER_READ 0x01
767 #define GB_SPI_XFER_WRITE 0x02
770 struct gb_spi_transfer_request {
771 __u8 chip_select; /* of the spi device */
772 __u8 mode; /* of the spi device */
774 struct gb_spi_transfer transfers[0]; /* count of these */
777 struct gb_spi_transfer_response {
778 __u8 data[0]; /* inbound data */
781 /* Version of the Greybus SVC protocol we support */
782 #define GB_SVC_VERSION_MAJOR 0x00
783 #define GB_SVC_VERSION_MINOR 0x01
785 /* Greybus SVC request types */
786 #define GB_SVC_TYPE_SVC_HELLO 0x02
787 #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
788 #define GB_SVC_TYPE_INTF_HOTPLUG 0x04
789 #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
790 #define GB_SVC_TYPE_INTF_RESET 0x06
791 #define GB_SVC_TYPE_CONN_CREATE 0x07
792 #define GB_SVC_TYPE_CONN_DESTROY 0x08
793 #define GB_SVC_TYPE_DME_PEER_GET 0x09
794 #define GB_SVC_TYPE_DME_PEER_SET 0x0a
795 #define GB_SVC_TYPE_ROUTE_CREATE 0x0b
796 #define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
797 #define GB_SVC_TYPE_INTF_SET_PWRM 0x10
798 #define GB_SVC_TYPE_INTF_EJECT 0x11
799 #define GB_SVC_TYPE_KEY_EVENT 0x12
800 #define GB_SVC_TYPE_PING 0x13
803 * SVC version request/response has the same payload as
804 * gb_protocol_version_request/response.
807 /* SVC protocol hello request */
808 struct gb_svc_hello_request {
812 /* hello response has no payload */
814 struct gb_svc_intf_device_id_request {
818 /* device id response has no payload */
820 struct gb_svc_intf_hotplug_request {
824 __le32 ddbl1_prod_id;
827 __le64 serial_number;
830 /* hotplug response has no payload */
832 struct gb_svc_intf_hot_unplug_request {
835 /* hot unplug response has no payload */
837 struct gb_svc_intf_reset_request {
840 /* interface reset response has no payload */
842 #define GB_SVC_EJECT_TIME 9000
843 struct gb_svc_intf_eject_request {
846 /* interface eject response has no payload */
848 struct gb_svc_conn_create_request {
856 /* connection create response has no payload */
858 struct gb_svc_conn_destroy_request {
864 /* connection destroy response has no payload */
866 struct gb_svc_dme_peer_get_request {
872 struct gb_svc_dme_peer_get_response {
877 struct gb_svc_dme_peer_set_request {
884 struct gb_svc_dme_peer_set_response {
888 /* Attributes for peer get/set operations */
889 #define DME_ATTR_SELECTOR_INDEX 0
890 /* FIXME: remove ES2 support and DME_ATTR_T_TST_SRC_INCREMENT */
891 #define DME_ATTR_T_TST_SRC_INCREMENT 0x4083
892 #define DME_ATTR_ES3_INIT_STATUS 0x6101
894 /* Return value from init-status attributes listed above */
895 #define DME_DIS_SPI_BOOT_STARTED 0x02
896 #define DME_DIS_TRUSTED_SPI_BOOT_FINISHED 0x03
897 #define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED 0x04
898 #define DME_DIS_UNIPRO_BOOT_STARTED 0x06
899 #define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED 0x09
901 struct gb_svc_route_create_request {
907 /* route create response has no payload */
909 struct gb_svc_route_destroy_request {
913 /* route destroy response has no payload */
915 #define GB_SVC_UNIPRO_FAST_MODE 0x01
916 #define GB_SVC_UNIPRO_SLOW_MODE 0x02
917 #define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04
918 #define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05
919 #define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07
920 #define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11
921 #define GB_SVC_UNIPRO_OFF_MODE 0x12
923 #define GB_SVC_PWRM_RXTERMINATION 0x01
924 #define GB_SVC_PWRM_TXTERMINATION 0x02
925 #define GB_SVC_PWRM_LINE_RESET 0x04
926 #define GB_SVC_PWRM_SCRAMBLING 0x20
928 #define GB_SVC_PWRM_QUIRK_HSSER 0x00000001
930 #define GB_SVC_UNIPRO_HS_SERIES_A 0x01
931 #define GB_SVC_UNIPRO_HS_SERIES_B 0x02
933 struct gb_svc_intf_set_pwrm_request {
946 struct gb_svc_intf_set_pwrm_response {
950 struct gb_svc_key_event_request {
952 #define GB_KEYCODE_ARA 0x00
955 #define GB_SVC_KEY_RELEASED 0x00
956 #define GB_SVC_KEY_PRESSED 0x01
961 /* Version of the Greybus raw protocol we support */
962 #define GB_RAW_VERSION_MAJOR 0x00
963 #define GB_RAW_VERSION_MINOR 0x01
965 /* Greybus raw request types */
966 #define GB_RAW_TYPE_SEND 0x02
968 struct gb_raw_send_request {
976 /* Version of the Greybus UART protocol we support */
977 #define GB_UART_VERSION_MAJOR 0x00
978 #define GB_UART_VERSION_MINOR 0x01
980 /* Greybus UART operation types */
981 #define GB_UART_TYPE_SEND_DATA 0x02
982 #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
983 #define GB_UART_TYPE_SET_LINE_CODING 0x04
984 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
985 #define GB_UART_TYPE_SEND_BREAK 0x06
986 #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
988 /* Represents data from AP -> Module */
989 struct gb_uart_send_data_request {
994 /* recv-data-request flags */
995 #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
996 #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
997 #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
998 #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
1000 /* Represents data from Module -> AP */
1001 struct gb_uart_recv_data_request {
1007 struct gb_uart_set_line_coding_request {
1010 #define GB_SERIAL_1_STOP_BITS 0
1011 #define GB_SERIAL_1_5_STOP_BITS 1
1012 #define GB_SERIAL_2_STOP_BITS 2
1015 #define GB_SERIAL_NO_PARITY 0
1016 #define GB_SERIAL_ODD_PARITY 1
1017 #define GB_SERIAL_EVEN_PARITY 2
1018 #define GB_SERIAL_MARK_PARITY 3
1019 #define GB_SERIAL_SPACE_PARITY 4
1024 /* output control lines */
1025 #define GB_UART_CTRL_DTR 0x01
1026 #define GB_UART_CTRL_RTS 0x02
1028 struct gb_uart_set_control_line_state_request {
1032 struct gb_uart_set_break_request {
1036 /* input control lines and line errors */
1037 #define GB_UART_CTRL_DCD 0x01
1038 #define GB_UART_CTRL_DSR 0x02
1039 #define GB_UART_CTRL_RI 0x04
1041 struct gb_uart_serial_state_request {
1047 /* Version of the Greybus loopback protocol we support */
1048 #define GB_LOOPBACK_VERSION_MAJOR 0x00
1049 #define GB_LOOPBACK_VERSION_MINOR 0x01
1051 /* Greybus loopback request types */
1052 #define GB_LOOPBACK_TYPE_PING 0x02
1053 #define GB_LOOPBACK_TYPE_TRANSFER 0x03
1054 #define GB_LOOPBACK_TYPE_SINK 0x04
1057 * Loopback request/response header format should be identical
1058 * to simplify bandwidth and data movement analysis.
1060 struct gb_loopback_transfer_request {
1067 struct gb_loopback_transfer_response {
1075 /* Version of the Greybus sdio protocol we support */
1076 #define GB_SDIO_VERSION_MAJOR 0x00
1077 #define GB_SDIO_VERSION_MINOR 0x01
1079 /* Greybus SDIO operation types */
1080 #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
1081 #define GB_SDIO_TYPE_SET_IOS 0x03
1082 #define GB_SDIO_TYPE_COMMAND 0x04
1083 #define GB_SDIO_TYPE_TRANSFER 0x05
1084 #define GB_SDIO_TYPE_EVENT 0x06
1086 /* get caps response: request has no payload */
1087 struct gb_sdio_get_caps_response {
1089 #define GB_SDIO_CAP_NONREMOVABLE 0x00000001
1090 #define GB_SDIO_CAP_4_BIT_DATA 0x00000002
1091 #define GB_SDIO_CAP_8_BIT_DATA 0x00000004
1092 #define GB_SDIO_CAP_MMC_HS 0x00000008
1093 #define GB_SDIO_CAP_SD_HS 0x00000010
1094 #define GB_SDIO_CAP_ERASE 0x00000020
1095 #define GB_SDIO_CAP_1_2V_DDR 0x00000040
1096 #define GB_SDIO_CAP_1_8V_DDR 0x00000080
1097 #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
1098 #define GB_SDIO_CAP_UHS_SDR12 0x00000200
1099 #define GB_SDIO_CAP_UHS_SDR25 0x00000400
1100 #define GB_SDIO_CAP_UHS_SDR50 0x00000800
1101 #define GB_SDIO_CAP_UHS_SDR104 0x00001000
1102 #define GB_SDIO_CAP_UHS_DDR50 0x00002000
1103 #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
1104 #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
1105 #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
1106 #define GB_SDIO_CAP_HS200_1_2V 0x00020000
1107 #define GB_SDIO_CAP_HS200_1_8V 0x00040000
1108 #define GB_SDIO_CAP_HS400_1_2V 0x00080000
1109 #define GB_SDIO_CAP_HS400_1_8V 0x00100000
1111 /* see possible values below at vdd */
1113 __le16 max_blk_count;
1114 __le16 max_blk_size;
1119 /* set ios request: response has no payload */
1120 struct gb_sdio_set_ios_request {
1123 #define GB_SDIO_VDD_165_195 0x00000001
1124 #define GB_SDIO_VDD_20_21 0x00000002
1125 #define GB_SDIO_VDD_21_22 0x00000004
1126 #define GB_SDIO_VDD_22_23 0x00000008
1127 #define GB_SDIO_VDD_23_24 0x00000010
1128 #define GB_SDIO_VDD_24_25 0x00000020
1129 #define GB_SDIO_VDD_25_26 0x00000040
1130 #define GB_SDIO_VDD_26_27 0x00000080
1131 #define GB_SDIO_VDD_27_28 0x00000100
1132 #define GB_SDIO_VDD_28_29 0x00000200
1133 #define GB_SDIO_VDD_29_30 0x00000400
1134 #define GB_SDIO_VDD_30_31 0x00000800
1135 #define GB_SDIO_VDD_31_32 0x00001000
1136 #define GB_SDIO_VDD_32_33 0x00002000
1137 #define GB_SDIO_VDD_33_34 0x00004000
1138 #define GB_SDIO_VDD_34_35 0x00008000
1139 #define GB_SDIO_VDD_35_36 0x00010000
1142 #define GB_SDIO_BUSMODE_OPENDRAIN 0x00
1143 #define GB_SDIO_BUSMODE_PUSHPULL 0x01
1146 #define GB_SDIO_POWER_OFF 0x00
1147 #define GB_SDIO_POWER_UP 0x01
1148 #define GB_SDIO_POWER_ON 0x02
1149 #define GB_SDIO_POWER_UNDEFINED 0x03
1152 #define GB_SDIO_BUS_WIDTH_1 0x00
1153 #define GB_SDIO_BUS_WIDTH_4 0x02
1154 #define GB_SDIO_BUS_WIDTH_8 0x03
1157 #define GB_SDIO_TIMING_LEGACY 0x00
1158 #define GB_SDIO_TIMING_MMC_HS 0x01
1159 #define GB_SDIO_TIMING_SD_HS 0x02
1160 #define GB_SDIO_TIMING_UHS_SDR12 0x03
1161 #define GB_SDIO_TIMING_UHS_SDR25 0x04
1162 #define GB_SDIO_TIMING_UHS_SDR50 0x05
1163 #define GB_SDIO_TIMING_UHS_SDR104 0x06
1164 #define GB_SDIO_TIMING_UHS_DDR50 0x07
1165 #define GB_SDIO_TIMING_MMC_DDR52 0x08
1166 #define GB_SDIO_TIMING_MMC_HS200 0x09
1167 #define GB_SDIO_TIMING_MMC_HS400 0x0A
1169 __u8 signal_voltage;
1170 #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
1171 #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
1172 #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
1175 #define GB_SDIO_SET_DRIVER_TYPE_B 0x00
1176 #define GB_SDIO_SET_DRIVER_TYPE_A 0x01
1177 #define GB_SDIO_SET_DRIVER_TYPE_C 0x02
1178 #define GB_SDIO_SET_DRIVER_TYPE_D 0x03
1181 /* command request */
1182 struct gb_sdio_command_request {
1185 #define GB_SDIO_RSP_NONE 0x00
1186 #define GB_SDIO_RSP_PRESENT 0x01
1187 #define GB_SDIO_RSP_136 0x02
1188 #define GB_SDIO_RSP_CRC 0x04
1189 #define GB_SDIO_RSP_BUSY 0x08
1190 #define GB_SDIO_RSP_OPCODE 0x10
1193 #define GB_SDIO_CMD_AC 0x00
1194 #define GB_SDIO_CMD_ADTC 0x01
1195 #define GB_SDIO_CMD_BC 0x02
1196 #define GB_SDIO_CMD_BCR 0x03
1203 struct gb_sdio_command_response {
1207 /* transfer request */
1208 struct gb_sdio_transfer_request {
1210 #define GB_SDIO_DATA_WRITE 0x01
1211 #define GB_SDIO_DATA_READ 0x02
1212 #define GB_SDIO_DATA_STREAM 0x04
1219 struct gb_sdio_transfer_response {
1225 /* event request: generated by module and is defined as unidirectional */
1226 struct gb_sdio_event_request {
1228 #define GB_SDIO_CARD_INSERTED 0x01
1229 #define GB_SDIO_CARD_REMOVED 0x02
1230 #define GB_SDIO_WP 0x04
1235 #define GB_CAMERA_VERSION_MAJOR 0x00
1236 #define GB_CAMERA_VERSION_MINOR 0x01
1238 /* Greybus Camera request types */
1239 #define GB_CAMERA_TYPE_CAPABILITIES 0x02
1240 #define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03
1241 #define GB_CAMERA_TYPE_CAPTURE 0x04
1242 #define GB_CAMERA_TYPE_FLUSH 0x05
1243 #define GB_CAMERA_TYPE_METADATA 0x06
1245 #define GB_CAMERA_MAX_STREAMS 4
1246 #define GB_CAMERA_MAX_SETTINGS_SIZE 8192
1248 /* Greybus Camera Configure Streams request payload */
1249 struct gb_camera_stream_config_request {
1256 struct gb_camera_configure_streams_request {
1259 #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01
1261 struct gb_camera_stream_config_request config[0];
1264 /* Greybus Camera Configure Streams response payload */
1265 struct gb_camera_stream_config_response {
1269 __u8 virtual_channel;
1275 struct gb_camera_configure_streams_response {
1278 #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
1282 __le32 lines_per_second;
1283 struct gb_camera_stream_config_response config[0];
1286 /* Greybus Camera Capture request payload - response has no payload */
1287 struct gb_camera_capture_request {
1295 /* Greybus Camera Flush response payload - request has no payload */
1296 struct gb_camera_flush_response {
1300 /* Greybus Camera Metadata request payload - operation has no response */
1301 struct gb_camera_metadata_request {
1303 __le16 frame_number;
1311 #define GB_LIGHTS_VERSION_MAJOR 0x00
1312 #define GB_LIGHTS_VERSION_MINOR 0x01
1314 /* Greybus Lights request types */
1315 #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02
1316 #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03
1317 #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04
1318 #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1319 #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06
1320 #define GB_LIGHTS_TYPE_SET_BLINK 0x07
1321 #define GB_LIGHTS_TYPE_SET_COLOR 0x08
1322 #define GB_LIGHTS_TYPE_SET_FADE 0x09
1323 #define GB_LIGHTS_TYPE_EVENT 0x0A
1324 #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B
1325 #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C
1326 #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D
1327 #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E
1329 /* Greybus Light modes */
1332 * if you add any specific mode below, update also the
1333 * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1335 #define GB_CHANNEL_MODE_NONE 0x00000000
1336 #define GB_CHANNEL_MODE_BATTERY 0x00000001
1337 #define GB_CHANNEL_MODE_POWER 0x00000002
1338 #define GB_CHANNEL_MODE_WIRELESS 0x00000004
1339 #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008
1340 #define GB_CHANNEL_MODE_KEYBOARD 0x00000010
1341 #define GB_CHANNEL_MODE_BUTTONS 0x00000020
1342 #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040
1343 #define GB_CHANNEL_MODE_ATTENTION 0x00000080
1344 #define GB_CHANNEL_MODE_FLASH 0x00000100
1345 #define GB_CHANNEL_MODE_TORCH 0x00000200
1346 #define GB_CHANNEL_MODE_INDICATOR 0x00000400
1348 /* Lights Mode valid bit values */
1349 #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF
1350 #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000
1352 /* Greybus Light Channels Flags */
1353 #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001
1354 #define GB_LIGHT_CHANNEL_FADER 0x00000002
1355 #define GB_LIGHT_CHANNEL_BLINK 0x00000004
1357 /* get count of lights in module */
1358 struct gb_lights_get_lights_response {
1362 /* light config request payload */
1363 struct gb_lights_get_light_config_request {
1367 /* light config response payload */
1368 struct gb_lights_get_light_config_response {
1373 /* channel config request payload */
1374 struct gb_lights_get_channel_config_request {
1379 /* channel flash config request payload */
1380 struct gb_lights_get_channel_flash_config_request {
1385 /* channel config response payload */
1386 struct gb_lights_get_channel_config_response {
1387 __u8 max_brightness;
1390 __u8 color_name[32];
1395 /* channel flash config response payload */
1396 struct gb_lights_get_channel_flash_config_response {
1397 __le32 intensity_min_uA;
1398 __le32 intensity_max_uA;
1399 __le32 intensity_step_uA;
1400 __le32 timeout_min_us;
1401 __le32 timeout_max_us;
1402 __le32 timeout_step_us;
1405 /* blink request payload: response have no payload */
1406 struct gb_lights_blink_request {
1413 /* set brightness request payload: response have no payload */
1414 struct gb_lights_set_brightness_request {
1420 /* set color request payload: response have no payload */
1421 struct gb_lights_set_color_request {
1427 /* set fade request payload: response have no payload */
1428 struct gb_lights_set_fade_request {
1435 /* event request: generated by module */
1436 struct gb_lights_event_request {
1439 #define GB_LIGHTS_LIGHT_CONFIG 0x01
1442 /* set flash intensity request payload: response have no payload */
1443 struct gb_lights_set_flash_intensity_request {
1446 __le32 intensity_uA;
1449 /* set flash strobe state request payload: response have no payload */
1450 struct gb_lights_set_flash_strobe_request {
1456 /* set flash timeout request payload: response have no payload */
1457 struct gb_lights_set_flash_timeout_request {
1463 /* get flash fault request payload */
1464 struct gb_lights_get_flash_fault_request {
1469 /* get flash fault response payload */
1470 struct gb_lights_get_flash_fault_response {
1472 #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000
1473 #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001
1474 #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002
1475 #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004
1476 #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008
1477 #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010
1478 #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020
1479 #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040
1480 #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080
1485 /* Version of the Greybus audio protocol we support */
1486 #define GB_AUDIO_VERSION_MAJOR 0x00
1487 #define GB_AUDIO_VERSION_MINOR 0x01
1489 #define GB_AUDIO_TYPE_PROTOCOL_VERSION 0x01
1490 #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02
1491 #define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03
1492 #define GB_AUDIO_TYPE_GET_CONTROL 0x04
1493 #define GB_AUDIO_TYPE_SET_CONTROL 0x05
1494 #define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06
1495 #define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07
1496 #define GB_AUDIO_TYPE_GET_PCM 0x08
1497 #define GB_AUDIO_TYPE_SET_PCM 0x09
1498 #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a
1499 #define GB_AUDIO_TYPE_GET_TX_DELAY 0x0b
1500 #define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c
1501 #define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d
1502 #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e
1503 #define GB_AUDIO_TYPE_GET_RX_DELAY 0x0f
1504 #define GB_AUDIO_TYPE_ACTIVATE_RX 0x10
1505 #define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11
1506 #define GB_AUDIO_TYPE_JACK_EVENT 0x12
1507 #define GB_AUDIO_TYPE_BUTTON_EVENT 0x13
1508 #define GB_AUDIO_TYPE_STREAMING_EVENT 0x14
1509 #define GB_AUDIO_TYPE_SEND_DATA 0x15
1511 /* Module must be able to buffer 10ms of audio data, minimum */
1512 #define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000
1514 #define GB_AUDIO_PCM_NAME_MAX 32
1515 #define AUDIO_DAI_NAME_MAX 32
1516 #define AUDIO_CONTROL_NAME_MAX 32
1517 #define AUDIO_CTL_ELEM_NAME_MAX 44
1518 #define AUDIO_ENUM_NAME_MAX 64
1519 #define AUDIO_WIDGET_NAME_MAX 32
1521 /* See SNDRV_PCM_FMTBIT_* in Linux source */
1522 #define GB_AUDIO_PCM_FMT_S8 BIT(0)
1523 #define GB_AUDIO_PCM_FMT_U8 BIT(1)
1524 #define GB_AUDIO_PCM_FMT_S16_LE BIT(2)
1525 #define GB_AUDIO_PCM_FMT_S16_BE BIT(3)
1526 #define GB_AUDIO_PCM_FMT_U16_LE BIT(4)
1527 #define GB_AUDIO_PCM_FMT_U16_BE BIT(5)
1528 #define GB_AUDIO_PCM_FMT_S24_LE BIT(6)
1529 #define GB_AUDIO_PCM_FMT_S24_BE BIT(7)
1530 #define GB_AUDIO_PCM_FMT_U24_LE BIT(8)
1531 #define GB_AUDIO_PCM_FMT_U24_BE BIT(9)
1532 #define GB_AUDIO_PCM_FMT_S32_LE BIT(10)
1533 #define GB_AUDIO_PCM_FMT_S32_BE BIT(11)
1534 #define GB_AUDIO_PCM_FMT_U32_LE BIT(12)
1535 #define GB_AUDIO_PCM_FMT_U32_BE BIT(13)
1537 /* See SNDRV_PCM_RATE_* in Linux source */
1538 #define GB_AUDIO_PCM_RATE_5512 BIT(0)
1539 #define GB_AUDIO_PCM_RATE_8000 BIT(1)
1540 #define GB_AUDIO_PCM_RATE_11025 BIT(2)
1541 #define GB_AUDIO_PCM_RATE_16000 BIT(3)
1542 #define GB_AUDIO_PCM_RATE_22050 BIT(4)
1543 #define GB_AUDIO_PCM_RATE_32000 BIT(5)
1544 #define GB_AUDIO_PCM_RATE_44100 BIT(6)
1545 #define GB_AUDIO_PCM_RATE_48000 BIT(7)
1546 #define GB_AUDIO_PCM_RATE_64000 BIT(8)
1547 #define GB_AUDIO_PCM_RATE_88200 BIT(9)
1548 #define GB_AUDIO_PCM_RATE_96000 BIT(10)
1549 #define GB_AUDIO_PCM_RATE_176400 BIT(11)
1550 #define GB_AUDIO_PCM_RATE_192000 BIT(12)
1552 #define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1
1553 #define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2
1555 #define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0)
1556 #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1)
1558 /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
1559 #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01
1560 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02
1561 #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03
1562 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06
1564 /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
1565 #define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00
1566 #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01
1567 #define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02
1568 #define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03
1569 #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04
1570 #define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05
1571 #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06
1573 /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
1574 #define GB_AUDIO_ACCESS_READ BIT(0)
1575 #define GB_AUDIO_ACCESS_WRITE BIT(1)
1576 #define GB_AUDIO_ACCESS_VOLATILE BIT(2)
1577 #define GB_AUDIO_ACCESS_TIMESTAMP BIT(3)
1578 #define GB_AUDIO_ACCESS_TLV_READ BIT(4)
1579 #define GB_AUDIO_ACCESS_TLV_WRITE BIT(5)
1580 #define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6)
1581 #define GB_AUDIO_ACCESS_INACTIVE BIT(7)
1582 #define GB_AUDIO_ACCESS_LOCK BIT(8)
1583 #define GB_AUDIO_ACCESS_OWNER BIT(9)
1585 /* enum snd_soc_dapm_type */
1586 #define GB_AUDIO_WIDGET_TYPE_INPUT 0x0
1587 #define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1
1588 #define GB_AUDIO_WIDGET_TYPE_MUX 0x2
1589 #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3
1590 #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4
1591 #define GB_AUDIO_WIDGET_TYPE_MIXER 0x5
1592 #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6
1593 #define GB_AUDIO_WIDGET_TYPE_PGA 0x7
1594 #define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8
1595 #define GB_AUDIO_WIDGET_TYPE_ADC 0x9
1596 #define GB_AUDIO_WIDGET_TYPE_DAC 0xa
1597 #define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb
1598 #define GB_AUDIO_WIDGET_TYPE_MIC 0xc
1599 #define GB_AUDIO_WIDGET_TYPE_HP 0xd
1600 #define GB_AUDIO_WIDGET_TYPE_SPK 0xe
1601 #define GB_AUDIO_WIDGET_TYPE_LINE 0xf
1602 #define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10
1603 #define GB_AUDIO_WIDGET_TYPE_VMID 0x11
1604 #define GB_AUDIO_WIDGET_TYPE_PRE 0x12
1605 #define GB_AUDIO_WIDGET_TYPE_POST 0x13
1606 #define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14
1607 #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15
1608 #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16
1609 #define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17
1610 #define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18
1611 #define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19
1612 #define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a
1613 #define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b
1614 #define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c
1616 #define GB_AUDIO_WIDGET_STATE_DISABLED 0x01
1617 #define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02
1619 #define GB_AUDIO_JACK_EVENT_INSERTION 0x1
1620 #define GB_AUDIO_JACK_EVENT_REMOVAL 0x2
1622 #define GB_AUDIO_BUTTON_EVENT_PRESS 0x1
1623 #define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2
1625 #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1
1626 #define GB_AUDIO_STREAMING_EVENT_HALT 0x2
1627 #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3
1628 #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4
1629 #define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5
1630 #define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6
1631 #define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7
1632 #define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8
1633 #define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9
1635 #define GB_AUDIO_INVALID_INDEX 0xff
1637 struct gb_audio_pcm {
1638 __u8 stream_name[GB_AUDIO_PCM_NAME_MAX];
1639 __le32 formats; /* GB_AUDIO_PCM_FMT_* */
1640 __le32 rates; /* GB_AUDIO_PCM_RATE_* */
1643 __u8 sig_bits; /* number of bits of content */
1646 struct gb_audio_dai {
1647 __u8 name[AUDIO_DAI_NAME_MAX];
1649 struct gb_audio_pcm capture;
1650 struct gb_audio_pcm playback;
1653 struct gb_audio_integer {
1659 struct gb_audio_integer64 {
1665 struct gb_audio_enumerated {
1667 __le16 names_length;
1671 struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
1672 __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
1675 struct gb_audio_integer integer;
1676 struct gb_audio_integer64 integer64;
1677 struct gb_audio_enumerated enumerated;
1681 struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
1682 __le64 timestamp; /* XXX needed? */
1684 __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */
1685 __le64 integer64_value[2];
1686 __le32 enumerated_item[2];
1690 struct gb_audio_control {
1691 __u8 name[AUDIO_CONTROL_NAME_MAX];
1693 __u8 iface; /* GB_AUDIO_IFACE_* */
1695 __le32 access; /* GB_AUDIO_ACCESS_* */
1696 __u8 count; /* count of same elements */
1697 __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */
1698 struct gb_audio_ctl_elem_info info;
1701 struct gb_audio_widget {
1702 __u8 name[AUDIO_WIDGET_NAME_MAX];
1703 __u8 sname[AUDIO_WIDGET_NAME_MAX];
1705 __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */
1706 __u8 state; /* GB_AUDIO_WIDGET_STATE_* */
1708 struct gb_audio_control ctl[0]; /* 'ncontrols' entries */
1711 struct gb_audio_route {
1712 __u8 source_id; /* widget id */
1713 __u8 destination_id; /* widget id */
1714 __u8 control_id; /* 0-63 */
1715 __u8 index; /* Selection within the control */
1718 struct gb_audio_topology {
1724 __u32 size_controls;
1728 * struct gb_audio_dai dai[num_dais];
1729 * struct gb_audio_control controls[num_controls];
1730 * struct gb_audio_widget widgets[num_widgets];
1731 * struct gb_audio_route routes[num_routes];
1736 struct gb_audio_get_topology_size_response {
1740 struct gb_audio_get_topology_response {
1741 struct gb_audio_topology topology;
1744 struct gb_audio_get_control_request {
1749 struct gb_audio_get_control_response {
1750 struct gb_audio_ctl_elem_value value;
1753 struct gb_audio_set_control_request {
1756 struct gb_audio_ctl_elem_value value;
1759 struct gb_audio_enable_widget_request {
1763 struct gb_audio_disable_widget_request {
1767 struct gb_audio_get_pcm_request {
1771 struct gb_audio_get_pcm_response {
1778 struct gb_audio_set_pcm_request {
1786 struct gb_audio_set_tx_data_size_request {
1791 struct gb_audio_get_tx_delay_request {
1795 struct gb_audio_get_tx_delay_response {
1799 struct gb_audio_activate_tx_request {
1803 struct gb_audio_deactivate_tx_request {
1807 struct gb_audio_set_rx_data_size_request {
1812 struct gb_audio_get_rx_delay_request {
1816 struct gb_audio_get_rx_delay_response {
1820 struct gb_audio_activate_rx_request {
1824 struct gb_audio_deactivate_rx_request {
1828 struct gb_audio_jack_event_request {
1834 struct gb_audio_button_event_request {
1840 struct gb_audio_streaming_event_request {
1845 struct gb_audio_send_data_request {
1850 #endif /* __GREYBUS_PROTOCOLS_H */