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 /* SVC switch-port device ids */
58 #define GB_SVC_DEVICE_ID_SVC 0
59 #define GB_SVC_DEVICE_ID_AP 1
60 #define GB_SVC_DEVICE_ID_MIN 2
61 #define GB_SVC_DEVICE_ID_MAX 31
63 #define GB_SVC_CPORT_ID 0
64 #define GB_CONTROL_BUNDLE_ID 0
65 #define GB_CONTROL_CPORT_ID 0
69 * All operation messages (both requests and responses) begin with
70 * a header that encodes the size of the message (header included).
71 * This header also contains a unique identifier, that associates a
72 * response message with its operation. The header contains an
73 * operation type field, whose interpretation is dependent on what
74 * type of protocol is used over the connection. The high bit
75 * (0x80) of the operation type field is used to indicate whether
76 * the message is a request (clear) or a response (set).
78 * Response messages include an additional result byte, which
79 * communicates the result of the corresponding request. A zero
80 * result value means the operation completed successfully. Any
81 * other value indicates an error; in this case, the payload of the
82 * response message (if any) is ignored. The result byte must be
83 * zero in the header for a request message.
85 * The wire format for all numeric fields in the header is little
86 * endian. Any operation-specific data begins immediately after the
89 struct gb_operation_msg_hdr {
90 __le16 size; /* Size in bytes of header + payload */
91 __le16 operation_id; /* Operation unique id */
92 __u8 type; /* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
93 __u8 result; /* Result of request (in responses only) */
94 __u8 pad[2]; /* must be zero (ignore when read) */
98 /* Generic request numbers supported by all modules */
99 #define GB_REQUEST_TYPE_INVALID 0x00
100 #define GB_REQUEST_TYPE_PROTOCOL_VERSION 0x01
102 struct gb_protocol_version_request {
107 struct gb_protocol_version_response {
112 /* Control Protocol */
114 /* Greybus control request types */
115 #define GB_CONTROL_TYPE_VERSION 0x01
116 #define GB_CONTROL_TYPE_PROBE_AP 0x02
117 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
118 #define GB_CONTROL_TYPE_GET_MANIFEST 0x04
119 #define GB_CONTROL_TYPE_CONNECTED 0x05
120 #define GB_CONTROL_TYPE_DISCONNECTED 0x06
121 #define GB_CONTROL_TYPE_TIMESYNC_ENABLE 0x07
122 #define GB_CONTROL_TYPE_TIMESYNC_DISABLE 0x08
123 #define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE 0x09
124 #define GB_CONTROL_TYPE_INTERFACE_VERSION 0x0a
125 #define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b
127 struct gb_control_version_request {
132 struct gb_control_version_response {
137 struct gb_control_bundle_version_request {
141 struct gb_control_bundle_version_response {
146 /* Control protocol manifest get size request has no payload*/
147 struct gb_control_get_manifest_size_response {
151 /* Control protocol manifest get request has no payload */
152 struct gb_control_get_manifest_response {
156 /* Control protocol [dis]connected request */
157 struct gb_control_connected_request {
161 struct gb_control_disconnected_request {
164 /* Control protocol [dis]connected response has no payload */
166 /* Control protocol interface version request has no payload */
167 struct gb_control_interface_version_response {
172 #define GB_TIMESYNC_MAX_STROBES 0x04
174 struct gb_control_timesync_enable_request {
180 /* timesync enable response has no payload */
182 struct gb_control_timesync_authoritative_request {
183 __le64 frame_time[GB_TIMESYNC_MAX_STROBES];
185 /* timesync authoritative response has no payload */
187 /* APBridge protocol */
189 /* request APB1 log */
190 #define GB_APB_REQUEST_LOG 0x02
192 /* request to map a cport to bulk in and bulk out endpoints */
193 #define GB_APB_REQUEST_EP_MAPPING 0x03
195 /* request to get the number of cports available */
196 #define GB_APB_REQUEST_CPORT_COUNT 0x04
198 /* request to reset a cport state */
199 #define GB_APB_REQUEST_RESET_CPORT 0x05
201 /* request to time the latency of messages on a given cport */
202 #define GB_APB_REQUEST_LATENCY_TAG_EN 0x06
203 #define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07
205 /* request to control the CSI transmitter */
206 #define GB_APB_REQUEST_CSI_TX_CONTROL 0x08
208 /* request to control the CSI transmitter */
209 #define GB_APB_REQUEST_AUDIO_CONTROL 0x09
211 /* vendor requests to enable/disable CPort features */
212 #define GB_APB_REQUEST_CPORT_FEAT_EN 0x0b
213 #define GB_APB_REQUEST_CPORT_FEAT_DIS 0x0c
215 /* Bootrom Protocol */
217 /* Version of the Greybus bootrom protocol we support */
218 #define GB_BOOTROM_VERSION_MAJOR 0x00
219 #define GB_BOOTROM_VERSION_MINOR 0x01
221 /* Greybus bootrom request types */
222 #define GB_BOOTROM_TYPE_VERSION 0x01
223 #define GB_BOOTROM_TYPE_FIRMWARE_SIZE 0x02
224 #define GB_BOOTROM_TYPE_GET_FIRMWARE 0x03
225 #define GB_BOOTROM_TYPE_READY_TO_BOOT 0x04
226 #define GB_BOOTROM_TYPE_AP_READY 0x05 /* Request with no-payload */
227 #define GB_BOOTROM_TYPE_GET_VID_PID 0x06 /* Request with no-payload */
229 /* Greybus bootrom boot stages */
230 #define GB_BOOTROM_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
231 #define GB_BOOTROM_BOOT_STAGE_TWO 0x02 /* Bootrom package to be loaded by the boot ROM */
232 #define GB_BOOTROM_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
234 /* Greybus bootrom ready to boot status */
235 #define GB_BOOTROM_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
236 #define GB_BOOTROM_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
237 #define GB_BOOTROM_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
239 /* Max bootrom data fetch size in bytes */
240 #define GB_BOOTROM_FETCH_MAX 2000
242 struct gb_bootrom_version_request {
247 struct gb_bootrom_version_response {
252 /* Bootrom protocol firmware size request/response */
253 struct gb_bootrom_firmware_size_request {
257 struct gb_bootrom_firmware_size_response {
261 /* Bootrom protocol get firmware request/response */
262 struct gb_bootrom_get_firmware_request {
267 struct gb_bootrom_get_firmware_response {
271 /* Bootrom protocol Ready to boot request */
272 struct gb_bootrom_ready_to_boot_request {
275 /* Bootrom protocol Ready to boot response has no payload */
277 /* Bootrom protocol get VID/PID request has no payload */
278 struct gb_bootrom_get_vid_pid_response {
286 /* Version of the Greybus power supply protocol we support */
287 #define GB_POWER_SUPPLY_VERSION_MAJOR 0x00
288 #define GB_POWER_SUPPLY_VERSION_MINOR 0x01
290 /* Greybus power supply request types */
291 #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02
292 #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03
293 #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04
294 #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05
295 #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06
296 #define GB_POWER_SUPPLY_TYPE_EVENT 0x07
298 /* Should match up with battery technologies in linux/power_supply.h */
299 #define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000
300 #define GB_POWER_SUPPLY_TECH_NiMH 0x0001
301 #define GB_POWER_SUPPLY_TECH_LION 0x0002
302 #define GB_POWER_SUPPLY_TECH_LIPO 0x0003
303 #define GB_POWER_SUPPLY_TECH_LiFe 0x0004
304 #define GB_POWER_SUPPLY_TECH_NiCd 0x0005
305 #define GB_POWER_SUPPLY_TECH_LiMn 0x0006
307 /* Should match up with power supply types in linux/power_supply.h */
308 #define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000
309 #define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001
310 #define GB_POWER_SUPPLY_UPS_TYPE 0x0002
311 #define GB_POWER_SUPPLY_MAINS_TYPE 0x0003
312 #define GB_POWER_SUPPLY_USB_TYPE 0x0004
313 #define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005
314 #define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006
315 #define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007
317 /* Should match up with power supply health in linux/power_supply.h */
318 #define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000
319 #define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001
320 #define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002
321 #define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003
322 #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004
323 #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005
324 #define GB_POWER_SUPPLY_HEALTH_COLD 0x0006
325 #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007
326 #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008
328 /* Should match up with battery status in linux/power_supply.h */
329 #define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000
330 #define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001
331 #define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002
332 #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003
333 #define GB_POWER_SUPPLY_STATUS_FULL 0x0004
335 struct gb_power_supply_get_supplies_response {
339 struct gb_power_supply_get_description_request {
343 struct gb_power_supply_get_description_response {
344 __u8 manufacturer[32];
346 __u8 serial_number[32];
348 __u8 properties_count;
351 struct gb_power_supply_props_desc {
353 #define GB_POWER_SUPPLY_PROP_STATUS 0x00
354 #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01
355 #define GB_POWER_SUPPLY_PROP_HEALTH 0x02
356 #define GB_POWER_SUPPLY_PROP_PRESENT 0x03
357 #define GB_POWER_SUPPLY_PROP_ONLINE 0x04
358 #define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05
359 #define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06
360 #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07
361 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08
362 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09
363 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A
364 #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B
365 #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C
366 #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D
367 #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E
368 #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F
369 #define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10
370 #define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11
371 #define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12
372 #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13
373 #define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14
374 #define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15
375 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16
376 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17
377 #define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18
378 #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19
379 #define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A
380 #define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B
381 #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C
382 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D
383 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E
384 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F
385 #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20
386 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21
387 #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22
388 #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23
389 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24
390 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25
391 #define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26
392 #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27
393 #define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28
394 #define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29
395 #define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A
396 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B
397 #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C
398 #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D
399 #define GB_POWER_SUPPLY_PROP_TEMP 0x2E
400 #define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F
401 #define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30
402 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31
403 #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32
404 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33
405 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34
406 #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35
407 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36
408 #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37
409 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38
410 #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39
411 #define GB_POWER_SUPPLY_PROP_TYPE 0x3A
412 #define GB_POWER_SUPPLY_PROP_SCOPE 0x3B
413 #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C
414 #define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D
418 struct gb_power_supply_get_property_descriptors_request {
422 struct gb_power_supply_get_property_descriptors_response {
423 __u8 properties_count;
424 struct gb_power_supply_props_desc props[];
427 struct gb_power_supply_get_property_request {
432 struct gb_power_supply_get_property_response {
436 struct gb_power_supply_set_property_request {
442 struct gb_power_supply_event_request {
445 #define GB_POWER_SUPPLY_UPDATE 0x01
451 /* Version of the Greybus hid protocol we support */
452 #define GB_HID_VERSION_MAJOR 0x00
453 #define GB_HID_VERSION_MINOR 0x01
455 /* Greybus HID operation types */
456 #define GB_HID_TYPE_GET_DESC 0x02
457 #define GB_HID_TYPE_GET_REPORT_DESC 0x03
458 #define GB_HID_TYPE_PWR_ON 0x04
459 #define GB_HID_TYPE_PWR_OFF 0x05
460 #define GB_HID_TYPE_GET_REPORT 0x06
461 #define GB_HID_TYPE_SET_REPORT 0x07
462 #define GB_HID_TYPE_IRQ_EVENT 0x08
465 #define GB_HID_INPUT_REPORT 0
466 #define GB_HID_OUTPUT_REPORT 1
467 #define GB_HID_FEATURE_REPORT 2
469 /* Different request/response structures */
470 /* HID get descriptor response */
471 struct gb_hid_desc_response {
473 __le16 wReportDescLength;
480 /* HID get report request/response */
481 struct gb_hid_get_report_request {
486 /* HID set report request */
487 struct gb_hid_set_report_request {
493 /* HID input report request, via interrupt pipe */
494 struct gb_hid_input_report_request {
501 /* Version of the Greybus i2c protocol we support */
502 #define GB_I2C_VERSION_MAJOR 0x00
503 #define GB_I2C_VERSION_MINOR 0x01
505 /* Greybus i2c request types */
506 #define GB_I2C_TYPE_FUNCTIONALITY 0x02
507 #define GB_I2C_TYPE_TRANSFER 0x05
509 /* functionality request has no payload */
510 struct gb_i2c_functionality_response {
511 __le32 functionality;
515 * Outgoing data immediately follows the op count and ops array.
516 * The data for each write (master -> slave) op in the array is sent
517 * in order, with no (e.g. pad) bytes separating them.
519 * Short reads cause the entire transfer request to fail So response
520 * payload consists only of bytes read, and the number of bytes is
521 * exactly what was specified in the corresponding op. Like
522 * outgoing data, the incoming data is in order and contiguous.
524 struct gb_i2c_transfer_op {
530 struct gb_i2c_transfer_request {
532 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
534 struct gb_i2c_transfer_response {
535 __u8 data[0]; /* inbound data */
541 /* Version of the Greybus GPIO protocol we support */
542 #define GB_GPIO_VERSION_MAJOR 0x00
543 #define GB_GPIO_VERSION_MINOR 0x01
545 /* Greybus GPIO request types */
546 #define GB_GPIO_TYPE_LINE_COUNT 0x02
547 #define GB_GPIO_TYPE_ACTIVATE 0x03
548 #define GB_GPIO_TYPE_DEACTIVATE 0x04
549 #define GB_GPIO_TYPE_GET_DIRECTION 0x05
550 #define GB_GPIO_TYPE_DIRECTION_IN 0x06
551 #define GB_GPIO_TYPE_DIRECTION_OUT 0x07
552 #define GB_GPIO_TYPE_GET_VALUE 0x08
553 #define GB_GPIO_TYPE_SET_VALUE 0x09
554 #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
555 #define GB_GPIO_TYPE_IRQ_TYPE 0x0b
556 #define GB_GPIO_TYPE_IRQ_MASK 0x0c
557 #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
558 #define GB_GPIO_TYPE_IRQ_EVENT 0x0e
560 #define GB_GPIO_IRQ_TYPE_NONE 0x00
561 #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
562 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
563 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
564 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
565 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
567 /* line count request has no payload */
568 struct gb_gpio_line_count_response {
572 struct gb_gpio_activate_request {
575 /* activate response has no payload */
577 struct gb_gpio_deactivate_request {
580 /* deactivate response has no payload */
582 struct gb_gpio_get_direction_request {
585 struct gb_gpio_get_direction_response {
589 struct gb_gpio_direction_in_request {
592 /* direction in response has no payload */
594 struct gb_gpio_direction_out_request {
598 /* direction out response has no payload */
600 struct gb_gpio_get_value_request {
603 struct gb_gpio_get_value_response {
607 struct gb_gpio_set_value_request {
611 /* set value response has no payload */
613 struct gb_gpio_set_debounce_request {
617 /* debounce response has no payload */
619 struct gb_gpio_irq_type_request {
623 /* irq type response has no payload */
625 struct gb_gpio_irq_mask_request {
628 /* irq mask response has no payload */
630 struct gb_gpio_irq_unmask_request {
633 /* irq unmask response has no payload */
635 /* irq event requests originate on another module and are handled on the AP */
636 struct gb_gpio_irq_event_request {
639 /* irq event has no response */
644 /* Version of the Greybus PWM protocol we support */
645 #define GB_PWM_VERSION_MAJOR 0x00
646 #define GB_PWM_VERSION_MINOR 0x01
648 /* Greybus PWM operation types */
649 #define GB_PWM_TYPE_PWM_COUNT 0x02
650 #define GB_PWM_TYPE_ACTIVATE 0x03
651 #define GB_PWM_TYPE_DEACTIVATE 0x04
652 #define GB_PWM_TYPE_CONFIG 0x05
653 #define GB_PWM_TYPE_POLARITY 0x06
654 #define GB_PWM_TYPE_ENABLE 0x07
655 #define GB_PWM_TYPE_DISABLE 0x08
657 /* pwm count request has no payload */
658 struct gb_pwm_count_response {
662 struct gb_pwm_activate_request {
666 struct gb_pwm_deactivate_request {
670 struct gb_pwm_config_request {
676 struct gb_pwm_polarity_request {
681 struct gb_pwm_enable_request {
685 struct gb_pwm_disable_request {
691 /* Version of the Greybus spi protocol we support */
692 #define GB_SPI_VERSION_MAJOR 0x00
693 #define GB_SPI_VERSION_MINOR 0x01
695 /* Should match up with modes in linux/spi/spi.h */
696 #define GB_SPI_MODE_CPHA 0x01 /* clock phase */
697 #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
698 #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
699 #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
700 #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
701 #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
702 #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
703 #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
704 #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
705 #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
706 #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
707 #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
709 /* Should match up with flags in linux/spi/spi.h */
710 #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
711 #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
712 #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
714 /* Greybus spi operation types */
715 #define GB_SPI_TYPE_MASTER_CONFIG 0x02
716 #define GB_SPI_TYPE_DEVICE_CONFIG 0x03
717 #define GB_SPI_TYPE_TRANSFER 0x04
719 /* mode request has no payload */
720 struct gb_spi_master_config_response {
721 __le32 bits_per_word_mask;
729 struct gb_spi_device_config_request {
733 struct gb_spi_device_config_response {
738 #define GB_SPI_SPI_DEV 0x00
739 #define GB_SPI_SPI_NOR 0x01
740 #define GB_SPI_SPI_MODALIAS 0x02
745 * struct gb_spi_transfer - a read/write buffer pair
746 * @speed_hz: Select a speed other than the device default for this transfer. If
747 * 0 the default (from @spi_device) is used.
748 * @len: size of rx and tx buffers (in bytes)
749 * @delay_usecs: microseconds to delay after this transfer before (optionally)
750 * changing the chipselect status, then starting the next transfer or
751 * completing this spi_message.
752 * @cs_change: affects chipselect after this transfer completes
753 * @bits_per_word: select a bits_per_word other than the device default for this
754 * transfer. If 0 the default (from @spi_device) is used.
756 struct gb_spi_transfer {
763 #define GB_SPI_XFER_READ 0x01
764 #define GB_SPI_XFER_WRITE 0x02
767 struct gb_spi_transfer_request {
768 __u8 chip_select; /* of the spi device */
769 __u8 mode; /* of the spi device */
771 struct gb_spi_transfer transfers[0]; /* count of these */
774 struct gb_spi_transfer_response {
775 __u8 data[0]; /* inbound data */
778 /* Version of the Greybus SVC protocol we support */
779 #define GB_SVC_VERSION_MAJOR 0x00
780 #define GB_SVC_VERSION_MINOR 0x01
782 /* Greybus SVC request types */
783 #define GB_SVC_TYPE_SVC_HELLO 0x02
784 #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
785 #define GB_SVC_TYPE_INTF_HOTPLUG 0x04
786 #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
787 #define GB_SVC_TYPE_INTF_RESET 0x06
788 #define GB_SVC_TYPE_CONN_CREATE 0x07
789 #define GB_SVC_TYPE_CONN_DESTROY 0x08
790 #define GB_SVC_TYPE_DME_PEER_GET 0x09
791 #define GB_SVC_TYPE_DME_PEER_SET 0x0a
792 #define GB_SVC_TYPE_ROUTE_CREATE 0x0b
793 #define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
794 #define GB_SVC_TYPE_TIMESYNC_ENABLE 0x0d
795 #define GB_SVC_TYPE_TIMESYNC_DISABLE 0x0e
796 #define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE 0x0f
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
801 #define GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET 0x14
802 #define GB_SVC_TYPE_PWRMON_RAIL_NAMES_GET 0x15
803 #define GB_SVC_TYPE_PWRMON_SAMPLE_GET 0x16
804 #define GB_SVC_TYPE_PWRMON_INTF_SAMPLE_GET 0x17
807 * SVC version request/response has the same payload as
808 * gb_protocol_version_request/response.
811 /* SVC protocol hello request */
812 struct gb_svc_hello_request {
816 /* hello response has no payload */
818 struct gb_svc_intf_device_id_request {
822 /* device id response has no payload */
824 struct gb_svc_intf_hotplug_request {
828 __le32 ddbl1_prod_id;
831 __le64 serial_number;
834 /* hotplug response has no payload */
836 struct gb_svc_intf_hot_unplug_request {
839 /* hot unplug response has no payload */
841 struct gb_svc_intf_reset_request {
844 /* interface reset response has no payload */
846 struct gb_svc_intf_eject_request {
849 /* interface eject response has no payload */
851 struct gb_svc_conn_create_request {
859 /* connection create response has no payload */
861 struct gb_svc_conn_destroy_request {
867 /* connection destroy response has no payload */
869 struct gb_svc_dme_peer_get_request {
875 struct gb_svc_dme_peer_get_response {
880 struct gb_svc_dme_peer_set_request {
887 struct gb_svc_dme_peer_set_response {
891 /* Greybus init-status values, currently retrieved using DME peer gets. */
892 #define GB_INIT_SPI_BOOT_STARTED 0x02
893 #define GB_INIT_TRUSTED_SPI_BOOT_FINISHED 0x03
894 #define GB_INIT_UNTRUSTED_SPI_BOOT_FINISHED 0x04
895 #define GB_INIT_BOOTROM_UNIPRO_BOOT_STARTED 0x06
896 #define GB_INIT_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED 0x09
898 struct gb_svc_route_create_request {
904 /* route create response has no payload */
906 struct gb_svc_route_destroy_request {
910 /* route destroy response has no payload */
912 struct gb_svc_timesync_enable_request {
919 /* timesync enable response has no payload */
921 /* timesync authoritative request has no payload */
922 struct gb_svc_timesync_authoritative_response {
923 __le64 frame_time[GB_TIMESYNC_MAX_STROBES];
926 #define GB_SVC_UNIPRO_FAST_MODE 0x01
927 #define GB_SVC_UNIPRO_SLOW_MODE 0x02
928 #define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04
929 #define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05
930 #define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07
931 #define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11
932 #define GB_SVC_UNIPRO_OFF_MODE 0x12
934 #define GB_SVC_PWRM_RXTERMINATION 0x01
935 #define GB_SVC_PWRM_TXTERMINATION 0x02
936 #define GB_SVC_PWRM_LINE_RESET 0x04
937 #define GB_SVC_PWRM_SCRAMBLING 0x20
939 #define GB_SVC_PWRM_QUIRK_HSSER 0x00000001
941 #define GB_SVC_UNIPRO_HS_SERIES_A 0x01
942 #define GB_SVC_UNIPRO_HS_SERIES_B 0x02
944 struct gb_svc_intf_set_pwrm_request {
957 struct gb_svc_intf_set_pwrm_response {
961 struct gb_svc_key_event_request {
963 #define GB_KEYCODE_ARA 0x00
966 #define GB_SVC_KEY_RELEASED 0x00
967 #define GB_SVC_KEY_PRESSED 0x01
970 #define GB_SVC_PWRMON_TYPE_CURR 0x01
971 #define GB_SVC_PWRMON_TYPE_VOL 0x02
972 #define GB_SVC_PWRMON_TYPE_PWR 0x03
974 #define GB_SVC_PWRMON_GET_SAMPLE_OK 0x00
975 #define GB_SVC_PWRMON_GET_SAMPLE_INVAL 0x01
976 #define GB_SVC_PWRMON_GET_SAMPLE_NOSUPP 0x02
977 #define GB_SVC_PWRMON_GET_SAMPLE_HWERR 0x03
979 struct gb_svc_pwrmon_intf_sample_get_request {
981 __u8 measurement_type;
984 struct gb_svc_pwrmon_intf_sample_get_response {
991 /* Version of the Greybus raw protocol we support */
992 #define GB_RAW_VERSION_MAJOR 0x00
993 #define GB_RAW_VERSION_MINOR 0x01
995 /* Greybus raw request types */
996 #define GB_RAW_TYPE_SEND 0x02
998 struct gb_raw_send_request {
1006 /* Version of the Greybus UART protocol we support */
1007 #define GB_UART_VERSION_MAJOR 0x00
1008 #define GB_UART_VERSION_MINOR 0x01
1010 /* Greybus UART operation types */
1011 #define GB_UART_TYPE_SEND_DATA 0x02
1012 #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
1013 #define GB_UART_TYPE_SET_LINE_CODING 0x04
1014 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
1015 #define GB_UART_TYPE_SEND_BREAK 0x06
1016 #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
1018 /* Represents data from AP -> Module */
1019 struct gb_uart_send_data_request {
1024 /* recv-data-request flags */
1025 #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
1026 #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
1027 #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
1028 #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
1030 /* Represents data from Module -> AP */
1031 struct gb_uart_recv_data_request {
1037 struct gb_uart_set_line_coding_request {
1040 #define GB_SERIAL_1_STOP_BITS 0
1041 #define GB_SERIAL_1_5_STOP_BITS 1
1042 #define GB_SERIAL_2_STOP_BITS 2
1045 #define GB_SERIAL_NO_PARITY 0
1046 #define GB_SERIAL_ODD_PARITY 1
1047 #define GB_SERIAL_EVEN_PARITY 2
1048 #define GB_SERIAL_MARK_PARITY 3
1049 #define GB_SERIAL_SPACE_PARITY 4
1054 /* output control lines */
1055 #define GB_UART_CTRL_DTR 0x01
1056 #define GB_UART_CTRL_RTS 0x02
1058 struct gb_uart_set_control_line_state_request {
1062 struct gb_uart_set_break_request {
1066 /* input control lines and line errors */
1067 #define GB_UART_CTRL_DCD 0x01
1068 #define GB_UART_CTRL_DSR 0x02
1069 #define GB_UART_CTRL_RI 0x04
1071 struct gb_uart_serial_state_request {
1077 /* Version of the Greybus loopback protocol we support */
1078 #define GB_LOOPBACK_VERSION_MAJOR 0x00
1079 #define GB_LOOPBACK_VERSION_MINOR 0x01
1081 /* Greybus loopback request types */
1082 #define GB_LOOPBACK_TYPE_PING 0x02
1083 #define GB_LOOPBACK_TYPE_TRANSFER 0x03
1084 #define GB_LOOPBACK_TYPE_SINK 0x04
1087 * Loopback request/response header format should be identical
1088 * to simplify bandwidth and data movement analysis.
1090 struct gb_loopback_transfer_request {
1097 struct gb_loopback_transfer_response {
1105 /* Version of the Greybus sdio protocol we support */
1106 #define GB_SDIO_VERSION_MAJOR 0x00
1107 #define GB_SDIO_VERSION_MINOR 0x01
1109 /* Greybus SDIO operation types */
1110 #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
1111 #define GB_SDIO_TYPE_SET_IOS 0x03
1112 #define GB_SDIO_TYPE_COMMAND 0x04
1113 #define GB_SDIO_TYPE_TRANSFER 0x05
1114 #define GB_SDIO_TYPE_EVENT 0x06
1116 /* get caps response: request has no payload */
1117 struct gb_sdio_get_caps_response {
1119 #define GB_SDIO_CAP_NONREMOVABLE 0x00000001
1120 #define GB_SDIO_CAP_4_BIT_DATA 0x00000002
1121 #define GB_SDIO_CAP_8_BIT_DATA 0x00000004
1122 #define GB_SDIO_CAP_MMC_HS 0x00000008
1123 #define GB_SDIO_CAP_SD_HS 0x00000010
1124 #define GB_SDIO_CAP_ERASE 0x00000020
1125 #define GB_SDIO_CAP_1_2V_DDR 0x00000040
1126 #define GB_SDIO_CAP_1_8V_DDR 0x00000080
1127 #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
1128 #define GB_SDIO_CAP_UHS_SDR12 0x00000200
1129 #define GB_SDIO_CAP_UHS_SDR25 0x00000400
1130 #define GB_SDIO_CAP_UHS_SDR50 0x00000800
1131 #define GB_SDIO_CAP_UHS_SDR104 0x00001000
1132 #define GB_SDIO_CAP_UHS_DDR50 0x00002000
1133 #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
1134 #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
1135 #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
1136 #define GB_SDIO_CAP_HS200_1_2V 0x00020000
1137 #define GB_SDIO_CAP_HS200_1_8V 0x00040000
1138 #define GB_SDIO_CAP_HS400_1_2V 0x00080000
1139 #define GB_SDIO_CAP_HS400_1_8V 0x00100000
1141 /* see possible values below at vdd */
1143 __le16 max_blk_count;
1144 __le16 max_blk_size;
1149 /* set ios request: response has no payload */
1150 struct gb_sdio_set_ios_request {
1153 #define GB_SDIO_VDD_165_195 0x00000001
1154 #define GB_SDIO_VDD_20_21 0x00000002
1155 #define GB_SDIO_VDD_21_22 0x00000004
1156 #define GB_SDIO_VDD_22_23 0x00000008
1157 #define GB_SDIO_VDD_23_24 0x00000010
1158 #define GB_SDIO_VDD_24_25 0x00000020
1159 #define GB_SDIO_VDD_25_26 0x00000040
1160 #define GB_SDIO_VDD_26_27 0x00000080
1161 #define GB_SDIO_VDD_27_28 0x00000100
1162 #define GB_SDIO_VDD_28_29 0x00000200
1163 #define GB_SDIO_VDD_29_30 0x00000400
1164 #define GB_SDIO_VDD_30_31 0x00000800
1165 #define GB_SDIO_VDD_31_32 0x00001000
1166 #define GB_SDIO_VDD_32_33 0x00002000
1167 #define GB_SDIO_VDD_33_34 0x00004000
1168 #define GB_SDIO_VDD_34_35 0x00008000
1169 #define GB_SDIO_VDD_35_36 0x00010000
1172 #define GB_SDIO_BUSMODE_OPENDRAIN 0x00
1173 #define GB_SDIO_BUSMODE_PUSHPULL 0x01
1176 #define GB_SDIO_POWER_OFF 0x00
1177 #define GB_SDIO_POWER_UP 0x01
1178 #define GB_SDIO_POWER_ON 0x02
1179 #define GB_SDIO_POWER_UNDEFINED 0x03
1182 #define GB_SDIO_BUS_WIDTH_1 0x00
1183 #define GB_SDIO_BUS_WIDTH_4 0x02
1184 #define GB_SDIO_BUS_WIDTH_8 0x03
1187 #define GB_SDIO_TIMING_LEGACY 0x00
1188 #define GB_SDIO_TIMING_MMC_HS 0x01
1189 #define GB_SDIO_TIMING_SD_HS 0x02
1190 #define GB_SDIO_TIMING_UHS_SDR12 0x03
1191 #define GB_SDIO_TIMING_UHS_SDR25 0x04
1192 #define GB_SDIO_TIMING_UHS_SDR50 0x05
1193 #define GB_SDIO_TIMING_UHS_SDR104 0x06
1194 #define GB_SDIO_TIMING_UHS_DDR50 0x07
1195 #define GB_SDIO_TIMING_MMC_DDR52 0x08
1196 #define GB_SDIO_TIMING_MMC_HS200 0x09
1197 #define GB_SDIO_TIMING_MMC_HS400 0x0A
1199 __u8 signal_voltage;
1200 #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
1201 #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
1202 #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
1205 #define GB_SDIO_SET_DRIVER_TYPE_B 0x00
1206 #define GB_SDIO_SET_DRIVER_TYPE_A 0x01
1207 #define GB_SDIO_SET_DRIVER_TYPE_C 0x02
1208 #define GB_SDIO_SET_DRIVER_TYPE_D 0x03
1211 /* command request */
1212 struct gb_sdio_command_request {
1215 #define GB_SDIO_RSP_NONE 0x00
1216 #define GB_SDIO_RSP_PRESENT 0x01
1217 #define GB_SDIO_RSP_136 0x02
1218 #define GB_SDIO_RSP_CRC 0x04
1219 #define GB_SDIO_RSP_BUSY 0x08
1220 #define GB_SDIO_RSP_OPCODE 0x10
1223 #define GB_SDIO_CMD_AC 0x00
1224 #define GB_SDIO_CMD_ADTC 0x01
1225 #define GB_SDIO_CMD_BC 0x02
1226 #define GB_SDIO_CMD_BCR 0x03
1233 struct gb_sdio_command_response {
1237 /* transfer request */
1238 struct gb_sdio_transfer_request {
1240 #define GB_SDIO_DATA_WRITE 0x01
1241 #define GB_SDIO_DATA_READ 0x02
1242 #define GB_SDIO_DATA_STREAM 0x04
1249 struct gb_sdio_transfer_response {
1255 /* event request: generated by module and is defined as unidirectional */
1256 struct gb_sdio_event_request {
1258 #define GB_SDIO_CARD_INSERTED 0x01
1259 #define GB_SDIO_CARD_REMOVED 0x02
1260 #define GB_SDIO_WP 0x04
1265 #define GB_CAMERA_VERSION_MAJOR 0x00
1266 #define GB_CAMERA_VERSION_MINOR 0x01
1268 /* Greybus Camera request types */
1269 #define GB_CAMERA_TYPE_CAPABILITIES 0x02
1270 #define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03
1271 #define GB_CAMERA_TYPE_CAPTURE 0x04
1272 #define GB_CAMERA_TYPE_FLUSH 0x05
1273 #define GB_CAMERA_TYPE_METADATA 0x06
1275 #define GB_CAMERA_MAX_STREAMS 4
1276 #define GB_CAMERA_MAX_SETTINGS_SIZE 8192
1278 /* Greybus Camera Configure Streams request payload */
1279 struct gb_camera_stream_config_request {
1286 struct gb_camera_configure_streams_request {
1289 #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01
1291 struct gb_camera_stream_config_request config[0];
1294 /* Greybus Camera Configure Streams response payload */
1295 struct gb_camera_stream_config_response {
1299 __u8 virtual_channel;
1305 struct gb_camera_configure_streams_response {
1308 #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
1312 __le32 lines_per_second;
1313 struct gb_camera_stream_config_response config[0];
1316 /* Greybus Camera Capture request payload - response has no payload */
1317 struct gb_camera_capture_request {
1325 /* Greybus Camera Flush response payload - request has no payload */
1326 struct gb_camera_flush_response {
1330 /* Greybus Camera Metadata request payload - operation has no response */
1331 struct gb_camera_metadata_request {
1333 __le16 frame_number;
1341 #define GB_LIGHTS_VERSION_MAJOR 0x00
1342 #define GB_LIGHTS_VERSION_MINOR 0x01
1344 /* Greybus Lights request types */
1345 #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02
1346 #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03
1347 #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04
1348 #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1349 #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06
1350 #define GB_LIGHTS_TYPE_SET_BLINK 0x07
1351 #define GB_LIGHTS_TYPE_SET_COLOR 0x08
1352 #define GB_LIGHTS_TYPE_SET_FADE 0x09
1353 #define GB_LIGHTS_TYPE_EVENT 0x0A
1354 #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B
1355 #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C
1356 #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D
1357 #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E
1359 /* Greybus Light modes */
1362 * if you add any specific mode below, update also the
1363 * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1365 #define GB_CHANNEL_MODE_NONE 0x00000000
1366 #define GB_CHANNEL_MODE_BATTERY 0x00000001
1367 #define GB_CHANNEL_MODE_POWER 0x00000002
1368 #define GB_CHANNEL_MODE_WIRELESS 0x00000004
1369 #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008
1370 #define GB_CHANNEL_MODE_KEYBOARD 0x00000010
1371 #define GB_CHANNEL_MODE_BUTTONS 0x00000020
1372 #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040
1373 #define GB_CHANNEL_MODE_ATTENTION 0x00000080
1374 #define GB_CHANNEL_MODE_FLASH 0x00000100
1375 #define GB_CHANNEL_MODE_TORCH 0x00000200
1376 #define GB_CHANNEL_MODE_INDICATOR 0x00000400
1378 /* Lights Mode valid bit values */
1379 #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF
1380 #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000
1382 /* Greybus Light Channels Flags */
1383 #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001
1384 #define GB_LIGHT_CHANNEL_FADER 0x00000002
1385 #define GB_LIGHT_CHANNEL_BLINK 0x00000004
1387 /* get count of lights in module */
1388 struct gb_lights_get_lights_response {
1392 /* light config request payload */
1393 struct gb_lights_get_light_config_request {
1397 /* light config response payload */
1398 struct gb_lights_get_light_config_response {
1403 /* channel config request payload */
1404 struct gb_lights_get_channel_config_request {
1409 /* channel flash config request payload */
1410 struct gb_lights_get_channel_flash_config_request {
1415 /* channel config response payload */
1416 struct gb_lights_get_channel_config_response {
1417 __u8 max_brightness;
1420 __u8 color_name[32];
1425 /* channel flash config response payload */
1426 struct gb_lights_get_channel_flash_config_response {
1427 __le32 intensity_min_uA;
1428 __le32 intensity_max_uA;
1429 __le32 intensity_step_uA;
1430 __le32 timeout_min_us;
1431 __le32 timeout_max_us;
1432 __le32 timeout_step_us;
1435 /* blink request payload: response have no payload */
1436 struct gb_lights_blink_request {
1443 /* set brightness request payload: response have no payload */
1444 struct gb_lights_set_brightness_request {
1450 /* set color request payload: response have no payload */
1451 struct gb_lights_set_color_request {
1457 /* set fade request payload: response have no payload */
1458 struct gb_lights_set_fade_request {
1465 /* event request: generated by module */
1466 struct gb_lights_event_request {
1469 #define GB_LIGHTS_LIGHT_CONFIG 0x01
1472 /* set flash intensity request payload: response have no payload */
1473 struct gb_lights_set_flash_intensity_request {
1476 __le32 intensity_uA;
1479 /* set flash strobe state request payload: response have no payload */
1480 struct gb_lights_set_flash_strobe_request {
1486 /* set flash timeout request payload: response have no payload */
1487 struct gb_lights_set_flash_timeout_request {
1493 /* get flash fault request payload */
1494 struct gb_lights_get_flash_fault_request {
1499 /* get flash fault response payload */
1500 struct gb_lights_get_flash_fault_response {
1502 #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000
1503 #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001
1504 #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002
1505 #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004
1506 #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008
1507 #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010
1508 #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020
1509 #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040
1510 #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080
1515 /* Version of the Greybus audio protocol we support */
1516 #define GB_AUDIO_VERSION_MAJOR 0x00
1517 #define GB_AUDIO_VERSION_MINOR 0x01
1519 #define GB_AUDIO_TYPE_PROTOCOL_VERSION 0x01
1520 #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02
1521 #define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03
1522 #define GB_AUDIO_TYPE_GET_CONTROL 0x04
1523 #define GB_AUDIO_TYPE_SET_CONTROL 0x05
1524 #define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06
1525 #define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07
1526 #define GB_AUDIO_TYPE_GET_PCM 0x08
1527 #define GB_AUDIO_TYPE_SET_PCM 0x09
1528 #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a
1529 #define GB_AUDIO_TYPE_GET_TX_DELAY 0x0b
1530 #define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c
1531 #define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d
1532 #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e
1533 #define GB_AUDIO_TYPE_GET_RX_DELAY 0x0f
1534 #define GB_AUDIO_TYPE_ACTIVATE_RX 0x10
1535 #define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11
1536 #define GB_AUDIO_TYPE_JACK_EVENT 0x12
1537 #define GB_AUDIO_TYPE_BUTTON_EVENT 0x13
1538 #define GB_AUDIO_TYPE_STREAMING_EVENT 0x14
1539 #define GB_AUDIO_TYPE_SEND_DATA 0x15
1541 /* Module must be able to buffer 10ms of audio data, minimum */
1542 #define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000
1544 #define GB_AUDIO_PCM_NAME_MAX 32
1545 #define AUDIO_DAI_NAME_MAX 32
1546 #define AUDIO_CONTROL_NAME_MAX 32
1547 #define AUDIO_CTL_ELEM_NAME_MAX 44
1548 #define AUDIO_ENUM_NAME_MAX 64
1549 #define AUDIO_WIDGET_NAME_MAX 32
1551 /* See SNDRV_PCM_FMTBIT_* in Linux source */
1552 #define GB_AUDIO_PCM_FMT_S8 BIT(0)
1553 #define GB_AUDIO_PCM_FMT_U8 BIT(1)
1554 #define GB_AUDIO_PCM_FMT_S16_LE BIT(2)
1555 #define GB_AUDIO_PCM_FMT_S16_BE BIT(3)
1556 #define GB_AUDIO_PCM_FMT_U16_LE BIT(4)
1557 #define GB_AUDIO_PCM_FMT_U16_BE BIT(5)
1558 #define GB_AUDIO_PCM_FMT_S24_LE BIT(6)
1559 #define GB_AUDIO_PCM_FMT_S24_BE BIT(7)
1560 #define GB_AUDIO_PCM_FMT_U24_LE BIT(8)
1561 #define GB_AUDIO_PCM_FMT_U24_BE BIT(9)
1562 #define GB_AUDIO_PCM_FMT_S32_LE BIT(10)
1563 #define GB_AUDIO_PCM_FMT_S32_BE BIT(11)
1564 #define GB_AUDIO_PCM_FMT_U32_LE BIT(12)
1565 #define GB_AUDIO_PCM_FMT_U32_BE BIT(13)
1567 /* See SNDRV_PCM_RATE_* in Linux source */
1568 #define GB_AUDIO_PCM_RATE_5512 BIT(0)
1569 #define GB_AUDIO_PCM_RATE_8000 BIT(1)
1570 #define GB_AUDIO_PCM_RATE_11025 BIT(2)
1571 #define GB_AUDIO_PCM_RATE_16000 BIT(3)
1572 #define GB_AUDIO_PCM_RATE_22050 BIT(4)
1573 #define GB_AUDIO_PCM_RATE_32000 BIT(5)
1574 #define GB_AUDIO_PCM_RATE_44100 BIT(6)
1575 #define GB_AUDIO_PCM_RATE_48000 BIT(7)
1576 #define GB_AUDIO_PCM_RATE_64000 BIT(8)
1577 #define GB_AUDIO_PCM_RATE_88200 BIT(9)
1578 #define GB_AUDIO_PCM_RATE_96000 BIT(10)
1579 #define GB_AUDIO_PCM_RATE_176400 BIT(11)
1580 #define GB_AUDIO_PCM_RATE_192000 BIT(12)
1582 #define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1
1583 #define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2
1585 #define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0)
1586 #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1)
1588 /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
1589 #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01
1590 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02
1591 #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03
1592 #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06
1594 /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
1595 #define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00
1596 #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01
1597 #define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02
1598 #define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03
1599 #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04
1600 #define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05
1601 #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06
1603 /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
1604 #define GB_AUDIO_ACCESS_READ BIT(0)
1605 #define GB_AUDIO_ACCESS_WRITE BIT(1)
1606 #define GB_AUDIO_ACCESS_VOLATILE BIT(2)
1607 #define GB_AUDIO_ACCESS_TIMESTAMP BIT(3)
1608 #define GB_AUDIO_ACCESS_TLV_READ BIT(4)
1609 #define GB_AUDIO_ACCESS_TLV_WRITE BIT(5)
1610 #define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6)
1611 #define GB_AUDIO_ACCESS_INACTIVE BIT(7)
1612 #define GB_AUDIO_ACCESS_LOCK BIT(8)
1613 #define GB_AUDIO_ACCESS_OWNER BIT(9)
1615 /* enum snd_soc_dapm_type */
1616 #define GB_AUDIO_WIDGET_TYPE_INPUT 0x0
1617 #define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1
1618 #define GB_AUDIO_WIDGET_TYPE_MUX 0x2
1619 #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3
1620 #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4
1621 #define GB_AUDIO_WIDGET_TYPE_MIXER 0x5
1622 #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6
1623 #define GB_AUDIO_WIDGET_TYPE_PGA 0x7
1624 #define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8
1625 #define GB_AUDIO_WIDGET_TYPE_ADC 0x9
1626 #define GB_AUDIO_WIDGET_TYPE_DAC 0xa
1627 #define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb
1628 #define GB_AUDIO_WIDGET_TYPE_MIC 0xc
1629 #define GB_AUDIO_WIDGET_TYPE_HP 0xd
1630 #define GB_AUDIO_WIDGET_TYPE_SPK 0xe
1631 #define GB_AUDIO_WIDGET_TYPE_LINE 0xf
1632 #define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10
1633 #define GB_AUDIO_WIDGET_TYPE_VMID 0x11
1634 #define GB_AUDIO_WIDGET_TYPE_PRE 0x12
1635 #define GB_AUDIO_WIDGET_TYPE_POST 0x13
1636 #define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14
1637 #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15
1638 #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16
1639 #define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17
1640 #define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18
1641 #define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19
1642 #define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a
1643 #define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b
1644 #define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c
1646 #define GB_AUDIO_WIDGET_STATE_DISABLED 0x01
1647 #define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02
1649 #define GB_AUDIO_JACK_EVENT_INSERTION 0x1
1650 #define GB_AUDIO_JACK_EVENT_REMOVAL 0x2
1652 #define GB_AUDIO_BUTTON_EVENT_PRESS 0x1
1653 #define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2
1655 #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1
1656 #define GB_AUDIO_STREAMING_EVENT_HALT 0x2
1657 #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3
1658 #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4
1659 #define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5
1660 #define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6
1661 #define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7
1662 #define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8
1663 #define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9
1665 #define GB_AUDIO_INVALID_INDEX 0xff
1667 struct gb_audio_pcm {
1668 __u8 stream_name[GB_AUDIO_PCM_NAME_MAX];
1669 __le32 formats; /* GB_AUDIO_PCM_FMT_* */
1670 __le32 rates; /* GB_AUDIO_PCM_RATE_* */
1673 __u8 sig_bits; /* number of bits of content */
1676 struct gb_audio_dai {
1677 __u8 name[AUDIO_DAI_NAME_MAX];
1679 struct gb_audio_pcm capture;
1680 struct gb_audio_pcm playback;
1683 struct gb_audio_integer {
1689 struct gb_audio_integer64 {
1695 struct gb_audio_enumerated {
1697 __le16 names_length;
1701 struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
1702 __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
1705 struct gb_audio_integer integer;
1706 struct gb_audio_integer64 integer64;
1707 struct gb_audio_enumerated enumerated;
1711 struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
1712 __le64 timestamp; /* XXX needed? */
1714 __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */
1715 __le64 integer64_value[2];
1716 __le32 enumerated_item[2];
1720 struct gb_audio_control {
1721 __u8 name[AUDIO_CONTROL_NAME_MAX];
1723 __u8 iface; /* GB_AUDIO_IFACE_* */
1725 __le32 access; /* GB_AUDIO_ACCESS_* */
1726 __u8 count; /* count of same elements */
1727 __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */
1728 struct gb_audio_ctl_elem_info info;
1731 struct gb_audio_widget {
1732 __u8 name[AUDIO_WIDGET_NAME_MAX];
1733 __u8 sname[AUDIO_WIDGET_NAME_MAX];
1735 __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */
1736 __u8 state; /* GB_AUDIO_WIDGET_STATE_* */
1738 struct gb_audio_control ctl[0]; /* 'ncontrols' entries */
1741 struct gb_audio_route {
1742 __u8 source_id; /* widget id */
1743 __u8 destination_id; /* widget id */
1744 __u8 control_id; /* 0-63 */
1745 __u8 index; /* Selection within the control */
1748 struct gb_audio_topology {
1754 __u32 size_controls;
1758 * struct gb_audio_dai dai[num_dais];
1759 * struct gb_audio_control controls[num_controls];
1760 * struct gb_audio_widget widgets[num_widgets];
1761 * struct gb_audio_route routes[num_routes];
1766 struct gb_audio_get_topology_size_response {
1770 struct gb_audio_get_topology_response {
1771 struct gb_audio_topology topology;
1774 struct gb_audio_get_control_request {
1779 struct gb_audio_get_control_response {
1780 struct gb_audio_ctl_elem_value value;
1783 struct gb_audio_set_control_request {
1786 struct gb_audio_ctl_elem_value value;
1789 struct gb_audio_enable_widget_request {
1793 struct gb_audio_disable_widget_request {
1797 struct gb_audio_get_pcm_request {
1801 struct gb_audio_get_pcm_response {
1808 struct gb_audio_set_pcm_request {
1816 struct gb_audio_set_tx_data_size_request {
1821 struct gb_audio_get_tx_delay_request {
1825 struct gb_audio_get_tx_delay_response {
1829 struct gb_audio_activate_tx_request {
1833 struct gb_audio_deactivate_tx_request {
1837 struct gb_audio_set_rx_data_size_request {
1842 struct gb_audio_get_rx_delay_request {
1846 struct gb_audio_get_rx_delay_response {
1850 struct gb_audio_activate_rx_request {
1854 struct gb_audio_deactivate_rx_request {
1858 struct gb_audio_jack_event_request {
1864 struct gb_audio_button_event_request {
1870 struct gb_audio_streaming_event_request {
1875 struct gb_audio_send_data_request {
1880 #endif /* __GREYBUS_PROTOCOLS_H */