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 /* Control Protocol */
108 /* version request has no payload */
109 struct gb_protocol_version_response {
114 /* Control Protocol */
116 /* Version of the Greybus control protocol we support */
117 #define GB_CONTROL_VERSION_MAJOR 0x00
118 #define GB_CONTROL_VERSION_MINOR 0x01
120 /* Greybus control request types */
121 #define GB_CONTROL_TYPE_PROBE_AP 0x02
122 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
123 #define GB_CONTROL_TYPE_GET_MANIFEST 0x04
124 #define GB_CONTROL_TYPE_CONNECTED 0x05
125 #define GB_CONTROL_TYPE_DISCONNECTED 0x06
127 /* Control protocol manifest get size request has no payload*/
128 struct gb_control_get_manifest_size_response {
132 /* Control protocol manifest get request has no payload */
133 struct gb_control_get_manifest_response {
137 /* Control protocol [dis]connected request */
138 struct gb_control_connected_request {
142 struct gb_control_disconnected_request {
145 /* Control protocol [dis]connected response has no payload */
148 /* Firmware Protocol */
150 /* Version of the Greybus firmware protocol we support */
151 #define GB_FIRMWARE_VERSION_MAJOR 0x00
152 #define GB_FIRMWARE_VERSION_MINOR 0x01
154 /* Greybus firmware request types */
155 #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02
156 #define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03
157 #define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04
159 /* Greybus firmware boot stages */
160 #define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
161 #define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */
162 #define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
164 /* Greybus firmware ready to boot status */
165 #define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
166 #define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
167 #define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
169 /* Max firmware data fetch size in bytes */
170 #define GB_FIRMWARE_FETCH_MAX 2000
172 /* Firmware protocol firmware size request/response */
173 struct gb_firmware_size_request {
177 struct gb_firmware_size_response {
181 /* Firmware protocol get firmware request/response */
182 struct gb_firmware_get_firmware_request {
187 struct gb_firmware_get_firmware_response {
191 /* Firmware protocol Ready to boot request */
192 struct gb_firmware_ready_to_boot_request {
196 /* Firmware protocol Ready to boot response has no payload */
201 /* Version of the Greybus battery protocol we support */
202 #define GB_BATTERY_VERSION_MAJOR 0x00
203 #define GB_BATTERY_VERSION_MINOR 0x01
205 /* Greybus battery request types */
206 #define GB_BATTERY_TYPE_TECHNOLOGY 0x02
207 #define GB_BATTERY_TYPE_STATUS 0x03
208 #define GB_BATTERY_TYPE_MAX_VOLTAGE 0x04
209 #define GB_BATTERY_TYPE_PERCENT_CAPACITY 0x05
210 #define GB_BATTERY_TYPE_TEMPERATURE 0x06
211 #define GB_BATTERY_TYPE_VOLTAGE 0x07
212 #define GB_BATTERY_TYPE_CURRENT 0x08
213 #define GB_BATTERY_TYPE_CAPACITY 0x09 // TODO - POWER_SUPPLY_PROP_CURRENT_MAX
214 #define GB_BATTERY_TYPE_SHUTDOWN_TEMP 0x0a // TODO - POWER_SUPPLY_PROP_TEMP_ALERT_MAX
216 /* Should match up with battery types in linux/power_supply.h */
217 #define GB_BATTERY_TECH_UNKNOWN 0x0000
218 #define GB_BATTERY_TECH_NiMH 0x0001
219 #define GB_BATTERY_TECH_LION 0x0002
220 #define GB_BATTERY_TECH_LIPO 0x0003
221 #define GB_BATTERY_TECH_LiFe 0x0004
222 #define GB_BATTERY_TECH_NiCd 0x0005
223 #define GB_BATTERY_TECH_LiMn 0x0006
225 struct gb_battery_technology_response {
229 /* Should match up with battery status in linux/power_supply.h */
230 #define GB_BATTERY_STATUS_UNKNOWN 0x0000
231 #define GB_BATTERY_STATUS_CHARGING 0x0001
232 #define GB_BATTERY_STATUS_DISCHARGING 0x0002
233 #define GB_BATTERY_STATUS_NOT_CHARGING 0x0003
234 #define GB_BATTERY_STATUS_FULL 0x0004
236 struct gb_battery_status_response {
237 __le16 battery_status;
240 struct gb_battery_max_voltage_response {
244 struct gb_battery_capacity_response {
248 struct gb_battery_temperature_response {
252 struct gb_battery_voltage_response {
259 /* Version of the Greybus hid protocol we support */
260 #define GB_HID_VERSION_MAJOR 0x00
261 #define GB_HID_VERSION_MINOR 0x01
263 /* Greybus HID operation types */
264 #define GB_HID_TYPE_GET_DESC 0x02
265 #define GB_HID_TYPE_GET_REPORT_DESC 0x03
266 #define GB_HID_TYPE_PWR_ON 0x04
267 #define GB_HID_TYPE_PWR_OFF 0x05
268 #define GB_HID_TYPE_GET_REPORT 0x06
269 #define GB_HID_TYPE_SET_REPORT 0x07
270 #define GB_HID_TYPE_IRQ_EVENT 0x08
273 #define GB_HID_INPUT_REPORT 0
274 #define GB_HID_OUTPUT_REPORT 1
275 #define GB_HID_FEATURE_REPORT 2
277 /* Different request/response structures */
278 /* HID get descriptor response */
279 struct gb_hid_desc_response {
281 __le16 wReportDescLength;
288 /* HID get report request/response */
289 struct gb_hid_get_report_request {
294 /* HID set report request */
295 struct gb_hid_set_report_request {
301 /* HID input report request, via interrupt pipe */
302 struct gb_hid_input_report_request {
309 /* Version of the Greybus i2c protocol we support */
310 #define GB_I2C_VERSION_MAJOR 0x00
311 #define GB_I2C_VERSION_MINOR 0x01
313 /* Greybus i2c request types */
314 #define GB_I2C_TYPE_FUNCTIONALITY 0x02
315 #define GB_I2C_TYPE_TIMEOUT 0x03
316 #define GB_I2C_TYPE_RETRIES 0x04
317 #define GB_I2C_TYPE_TRANSFER 0x05
319 #define GB_I2C_RETRIES_DEFAULT 3
320 #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
322 /* functionality request has no payload */
323 struct gb_i2c_functionality_response {
324 __le32 functionality;
327 struct gb_i2c_timeout_request {
330 /* timeout response has no payload */
332 struct gb_i2c_retries_request {
335 /* retries response has no payload */
338 * Outgoing data immediately follows the op count and ops array.
339 * The data for each write (master -> slave) op in the array is sent
340 * in order, with no (e.g. pad) bytes separating them.
342 * Short reads cause the entire transfer request to fail So response
343 * payload consists only of bytes read, and the number of bytes is
344 * exactly what was specified in the corresponding op. Like
345 * outgoing data, the incoming data is in order and contiguous.
347 struct gb_i2c_transfer_op {
353 struct gb_i2c_transfer_request {
355 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
357 struct gb_i2c_transfer_response {
358 __u8 data[0]; /* inbound data */
364 /* Version of the Greybus GPIO protocol we support */
365 #define GB_GPIO_VERSION_MAJOR 0x00
366 #define GB_GPIO_VERSION_MINOR 0x01
368 /* Greybus GPIO request types */
369 #define GB_GPIO_TYPE_LINE_COUNT 0x02
370 #define GB_GPIO_TYPE_ACTIVATE 0x03
371 #define GB_GPIO_TYPE_DEACTIVATE 0x04
372 #define GB_GPIO_TYPE_GET_DIRECTION 0x05
373 #define GB_GPIO_TYPE_DIRECTION_IN 0x06
374 #define GB_GPIO_TYPE_DIRECTION_OUT 0x07
375 #define GB_GPIO_TYPE_GET_VALUE 0x08
376 #define GB_GPIO_TYPE_SET_VALUE 0x09
377 #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
378 #define GB_GPIO_TYPE_IRQ_TYPE 0x0b
379 #define GB_GPIO_TYPE_IRQ_MASK 0x0c
380 #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
381 #define GB_GPIO_TYPE_IRQ_EVENT 0x0e
383 #define GB_GPIO_IRQ_TYPE_NONE 0x00
384 #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
385 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
386 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
387 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
388 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
390 /* line count request has no payload */
391 struct gb_gpio_line_count_response {
395 struct gb_gpio_activate_request {
398 /* activate response has no payload */
400 struct gb_gpio_deactivate_request {
403 /* deactivate response has no payload */
405 struct gb_gpio_get_direction_request {
408 struct gb_gpio_get_direction_response {
412 struct gb_gpio_direction_in_request {
415 /* direction in response has no payload */
417 struct gb_gpio_direction_out_request {
421 /* direction out response has no payload */
423 struct gb_gpio_get_value_request {
426 struct gb_gpio_get_value_response {
430 struct gb_gpio_set_value_request {
434 /* set value response has no payload */
436 struct gb_gpio_set_debounce_request {
440 /* debounce response has no payload */
442 struct gb_gpio_irq_type_request {
446 /* irq type response has no payload */
448 struct gb_gpio_irq_mask_request {
451 /* irq mask response has no payload */
453 struct gb_gpio_irq_unmask_request {
456 /* irq unmask response has no payload */
458 /* irq event requests originate on another module and are handled on the AP */
459 struct gb_gpio_irq_event_request {
462 /* irq event has no response */
467 /* Version of the Greybus PWM protocol we support */
468 #define GB_PWM_VERSION_MAJOR 0x00
469 #define GB_PWM_VERSION_MINOR 0x01
471 /* Greybus PWM operation types */
472 #define GB_PWM_TYPE_PWM_COUNT 0x02
473 #define GB_PWM_TYPE_ACTIVATE 0x03
474 #define GB_PWM_TYPE_DEACTIVATE 0x04
475 #define GB_PWM_TYPE_CONFIG 0x05
476 #define GB_PWM_TYPE_POLARITY 0x06
477 #define GB_PWM_TYPE_ENABLE 0x07
478 #define GB_PWM_TYPE_DISABLE 0x08
480 /* pwm count request has no payload */
481 struct gb_pwm_count_response {
485 struct gb_pwm_activate_request {
489 struct gb_pwm_deactivate_request {
493 struct gb_pwm_config_request {
499 struct gb_pwm_polarity_request {
504 struct gb_pwm_enable_request {
508 struct gb_pwm_disable_request {
514 #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS 0x02
515 #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION 0x03
516 #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE 0x04
517 #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY 0x05
518 #define GB_I2S_MGMT_TYPE_SET_START_DELAY 0x06
519 #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT 0x07
520 #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08
521 #define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09
523 #define GB_I2S_MGMT_BYTE_ORDER_NA BIT(0)
524 #define GB_I2S_MGMT_BYTE_ORDER_BE BIT(1)
525 #define GB_I2S_MGMT_BYTE_ORDER_LE BIT(2)
527 #define GB_I2S_MGMT_SPATIAL_LOCATION_FL BIT(0)
528 #define GB_I2S_MGMT_SPATIAL_LOCATION_FR BIT(1)
529 #define GB_I2S_MGMT_SPATIAL_LOCATION_FC BIT(2)
530 #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE BIT(3)
531 #define GB_I2S_MGMT_SPATIAL_LOCATION_BL BIT(4)
532 #define GB_I2S_MGMT_SPATIAL_LOCATION_BR BIT(5)
533 #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC BIT(6)
534 #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC BIT(7)
535 #define GB_I2S_MGMT_SPATIAL_LOCATION_C BIT(8) /* BC in USB */
536 #define GB_I2S_MGMT_SPATIAL_LOCATION_SL BIT(9)
537 #define GB_I2S_MGMT_SPATIAL_LOCATION_SR BIT(10)
538 #define GB_I2S_MGMT_SPATIAL_LOCATION_TC BIT(11)
539 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL BIT(12)
540 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC BIT(13)
541 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR BIT(14)
542 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL BIT(15)
543 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC BIT(16)
544 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR BIT(17)
545 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC BIT(18)
546 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC BIT(19)
547 #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE BIT(20)
548 #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE BIT(21)
549 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL BIT(22)
550 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR BIT(23)
551 #define GB_I2S_MGMT_SPATIAL_LOCATION_BC BIT(24)
552 #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC BIT(25)
553 #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC BIT(26)
554 #define GB_I2S_MGMT_SPATIAL_LOCATION_RD BIT(31)
556 #define GB_I2S_MGMT_PROTOCOL_PCM BIT(0)
557 #define GB_I2S_MGMT_PROTOCOL_I2S BIT(1)
558 #define GB_I2S_MGMT_PROTOCOL_LR_STEREO BIT(2)
560 #define GB_I2S_MGMT_ROLE_MASTER BIT(0)
561 #define GB_I2S_MGMT_ROLE_SLAVE BIT(1)
563 #define GB_I2S_MGMT_POLARITY_NORMAL BIT(0)
564 #define GB_I2S_MGMT_POLARITY_REVERSED BIT(1)
566 #define GB_I2S_MGMT_EDGE_RISING BIT(0)
567 #define GB_I2S_MGMT_EDGE_FALLING BIT(1)
569 #define GB_I2S_MGMT_EVENT_UNSPECIFIED 0x1
570 #define GB_I2S_MGMT_EVENT_HALT 0x2
571 #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR 0x3
572 #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR 0x4
573 #define GB_I2S_MGMT_EVENT_FAILURE 0x5
574 #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE 0x6
575 #define GB_I2S_MGMT_EVENT_UNDERRUN 0x7
576 #define GB_I2S_MGMT_EVENT_OVERRUN 0x8
577 #define GB_I2S_MGMT_EVENT_CLOCKING 0x9
578 #define GB_I2S_MGMT_EVENT_DATA_LEN 0xa
580 struct gb_i2s_mgmt_configuration {
581 __le32 sample_frequency;
583 __u8 bytes_per_channel;
586 __le32 spatial_locations;
591 __u8 ll_wclk_polarity;
592 __u8 ll_wclk_change_edge;
593 __u8 ll_wclk_tx_edge;
594 __u8 ll_wclk_rx_edge;
598 /* get supported configurations request has no payload */
599 struct gb_i2s_mgmt_get_supported_configurations_response {
602 struct gb_i2s_mgmt_configuration config[0];
605 struct gb_i2s_mgmt_set_configuration_request {
606 struct gb_i2s_mgmt_configuration config;
608 /* set configuration response has no payload */
610 struct gb_i2s_mgmt_set_samples_per_message_request {
611 __le16 samples_per_message;
613 /* set samples per message response has no payload */
615 /* get processing request delay has no payload */
616 struct gb_i2s_mgmt_get_processing_delay_response {
620 struct gb_i2s_mgmt_set_start_delay_request {
623 /* set start delay response has no payload */
625 struct gb_i2s_mgmt_activate_cport_request {
628 /* activate cport response has no payload */
630 struct gb_i2s_mgmt_deactivate_cport_request {
633 /* deactivate cport response has no payload */
635 struct gb_i2s_mgmt_report_event_request {
638 /* report event response has no payload */
640 #define GB_I2S_DATA_TYPE_SEND_DATA 0x02
642 struct gb_i2s_send_data_request {
643 __le32 sample_number;
647 /* send data has no response at all */
652 /* Version of the Greybus spi protocol we support */
653 #define GB_SPI_VERSION_MAJOR 0x00
654 #define GB_SPI_VERSION_MINOR 0x01
656 /* Should match up with modes in linux/spi/spi.h */
657 #define GB_SPI_MODE_CPHA 0x01 /* clock phase */
658 #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
659 #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
660 #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
661 #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
662 #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
663 #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
664 #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
665 #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
666 #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
667 #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
668 #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
670 /* Should match up with flags in linux/spi/spi.h */
671 #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
672 #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
673 #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
675 /* Greybus spi operation types */
676 #define GB_SPI_TYPE_MODE 0x02
677 #define GB_SPI_TYPE_FLAGS 0x03
678 #define GB_SPI_TYPE_BITS_PER_WORD_MASK 0x04
679 #define GB_SPI_TYPE_NUM_CHIPSELECT 0x05
680 #define GB_SPI_TYPE_TRANSFER 0x06
682 /* mode request has no payload */
683 struct gb_spi_mode_response {
687 /* flags request has no payload */
688 struct gb_spi_flags_response {
692 /* bits-per-word request has no payload */
693 struct gb_spi_bpw_response {
694 __le32 bits_per_word_mask;
697 /* num-chipselects request has no payload */
698 struct gb_spi_chipselect_response {
699 __le16 num_chipselect;
703 * struct gb_spi_transfer - a read/write buffer pair
704 * @speed_hz: Select a speed other than the device default for this transfer. If
705 * 0 the default (from @spi_device) is used.
706 * @len: size of rx and tx buffers (in bytes)
707 * @delay_usecs: microseconds to delay after this transfer before (optionally)
708 * changing the chipselect status, then starting the next transfer or
709 * completing this spi_message.
710 * @cs_change: affects chipselect after this transfer completes
711 * @bits_per_word: select a bits_per_word other than the device default for this
712 * transfer. If 0 the default (from @spi_device) is used.
714 struct gb_spi_transfer {
722 struct gb_spi_transfer_request {
723 __u8 chip_select; /* of the spi device */
724 __u8 mode; /* of the spi device */
726 struct gb_spi_transfer transfers[0]; /* count of these */
729 struct gb_spi_transfer_response {
730 __u8 data[0]; /* inbound data */
733 /* Version of the Greybus SVC protocol we support */
734 #define GB_SVC_VERSION_MAJOR 0x00
735 #define GB_SVC_VERSION_MINOR 0x01
737 /* Greybus SVC request types */
738 #define GB_SVC_TYPE_SVC_HELLO 0x02
739 #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
740 #define GB_SVC_TYPE_INTF_HOTPLUG 0x04
741 #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
742 #define GB_SVC_TYPE_INTF_RESET 0x06
743 #define GB_SVC_TYPE_CONN_CREATE 0x07
744 #define GB_SVC_TYPE_CONN_DESTROY 0x08
745 #define GB_SVC_TYPE_ROUTE_CREATE 0x0b
747 /* SVC version request/response have same payload as gb_protocol_version_response */
749 /* SVC protocol hello request */
750 struct gb_svc_hello_request {
754 /* hello response has no payload */
756 struct gb_svc_intf_device_id_request {
760 /* device id response has no payload */
762 struct gb_svc_intf_hotplug_request {
765 __le32 unipro_mfg_id;
766 __le32 unipro_prod_id;
771 /* hotplug response has no payload */
773 struct gb_svc_intf_hot_unplug_request {
776 /* hot unplug response has no payload */
778 struct gb_svc_intf_reset_request {
781 /* interface reset response has no payload */
783 struct gb_svc_conn_create_request {
791 /* connection create response has no payload */
793 struct gb_svc_conn_destroy_request {
799 /* connection destroy response has no payload */
801 struct gb_svc_route_create_request {
811 /* Version of the Greybus raw protocol we support */
812 #define GB_RAW_VERSION_MAJOR 0x00
813 #define GB_RAW_VERSION_MINOR 0x01
815 /* Greybus raw request types */
816 #define GB_RAW_TYPE_SEND 0x02
818 struct gb_raw_send_request {
826 /* Version of the Greybus UART protocol we support */
827 #define GB_UART_VERSION_MAJOR 0x00
828 #define GB_UART_VERSION_MINOR 0x01
830 /* Greybus UART operation types */
831 #define GB_UART_TYPE_SEND_DATA 0x02
832 #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
833 #define GB_UART_TYPE_SET_LINE_CODING 0x04
834 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
835 #define GB_UART_TYPE_SEND_BREAK 0x06
836 #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
838 /* Represents data from AP -> Module */
839 struct gb_uart_send_data_request {
844 /* recv-data-request flags */
845 #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
846 #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
847 #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
848 #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
850 /* Represents data from Module -> AP */
851 struct gb_uart_recv_data_request {
857 struct gb_uart_set_line_coding_request {
860 #define GB_SERIAL_1_STOP_BITS 0
861 #define GB_SERIAL_1_5_STOP_BITS 1
862 #define GB_SERIAL_2_STOP_BITS 2
865 #define GB_SERIAL_NO_PARITY 0
866 #define GB_SERIAL_ODD_PARITY 1
867 #define GB_SERIAL_EVEN_PARITY 2
868 #define GB_SERIAL_MARK_PARITY 3
869 #define GB_SERIAL_SPACE_PARITY 4
874 /* output control lines */
875 #define GB_UART_CTRL_DTR 0x01
876 #define GB_UART_CTRL_RTS 0x02
878 struct gb_uart_set_control_line_state_request {
882 struct gb_uart_set_break_request {
886 /* input control lines and line errors */
887 #define GB_UART_CTRL_DCD 0x01
888 #define GB_UART_CTRL_DSR 0x02
889 #define GB_UART_CTRL_RI 0x04
891 struct gb_uart_serial_state_request {
897 /* Version of the Greybus loopback protocol we support */
898 #define GB_LOOPBACK_VERSION_MAJOR 0x00
899 #define GB_LOOPBACK_VERSION_MINOR 0x01
901 /* Greybus loopback request types */
902 #define GB_LOOPBACK_TYPE_PING 0x02
903 #define GB_LOOPBACK_TYPE_TRANSFER 0x03
904 #define GB_LOOPBACK_TYPE_SINK 0x04
906 struct gb_loopback_transfer_request {
911 struct gb_loopback_transfer_response {
916 /* Version of the Greybus sdio protocol we support */
917 #define GB_SDIO_VERSION_MAJOR 0x00
918 #define GB_SDIO_VERSION_MINOR 0x01
920 /* Greybus SDIO operation types */
921 #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
922 #define GB_SDIO_TYPE_SET_IOS 0x03
923 #define GB_SDIO_TYPE_COMMAND 0x04
924 #define GB_SDIO_TYPE_TRANSFER 0x05
925 #define GB_SDIO_TYPE_EVENT 0x06
927 /* get caps response: request has no payload */
928 struct gb_sdio_get_caps_response {
930 #define GB_SDIO_CAP_NONREMOVABLE 0x00000001
931 #define GB_SDIO_CAP_4_BIT_DATA 0x00000002
932 #define GB_SDIO_CAP_8_BIT_DATA 0x00000004
933 #define GB_SDIO_CAP_MMC_HS 0x00000008
934 #define GB_SDIO_CAP_SD_HS 0x00000010
935 #define GB_SDIO_CAP_ERASE 0x00000020
936 #define GB_SDIO_CAP_1_2V_DDR 0x00000040
937 #define GB_SDIO_CAP_1_8V_DDR 0x00000080
938 #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
939 #define GB_SDIO_CAP_UHS_SDR12 0x00000200
940 #define GB_SDIO_CAP_UHS_SDR25 0x00000400
941 #define GB_SDIO_CAP_UHS_SDR50 0x00000800
942 #define GB_SDIO_CAP_UHS_SDR104 0x00001000
943 #define GB_SDIO_CAP_UHS_DDR50 0x00002000
944 #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
945 #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
946 #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
947 #define GB_SDIO_CAP_HS200_1_2V 0x00020000
948 #define GB_SDIO_CAP_HS200_1_8V 0x00040000
949 #define GB_SDIO_CAP_HS400_1_2V 0x00080000
950 #define GB_SDIO_CAP_HS400_1_8V 0x00100000
952 /* see possible values below at vdd */
954 __le16 max_blk_count;
958 /* set ios request: response has no payload */
959 struct gb_sdio_set_ios_request {
962 #define GB_SDIO_VDD_165_195 0x00000001
963 #define GB_SDIO_VDD_20_21 0x00000002
964 #define GB_SDIO_VDD_21_22 0x00000004
965 #define GB_SDIO_VDD_22_23 0x00000008
966 #define GB_SDIO_VDD_23_24 0x00000010
967 #define GB_SDIO_VDD_24_25 0x00000020
968 #define GB_SDIO_VDD_25_26 0x00000040
969 #define GB_SDIO_VDD_26_27 0x00000080
970 #define GB_SDIO_VDD_27_28 0x00000100
971 #define GB_SDIO_VDD_28_29 0x00000200
972 #define GB_SDIO_VDD_29_30 0x00000400
973 #define GB_SDIO_VDD_30_31 0x00000800
974 #define GB_SDIO_VDD_31_32 0x00001000
975 #define GB_SDIO_VDD_32_33 0x00002000
976 #define GB_SDIO_VDD_33_34 0x00004000
977 #define GB_SDIO_VDD_34_35 0x00008000
978 #define GB_SDIO_VDD_35_36 0x00010000
981 #define GB_SDIO_BUSMODE_OPENDRAIN 0x00
982 #define GB_SDIO_BUSMODE_PUSHPULL 0x01
985 #define GB_SDIO_POWER_OFF 0x00
986 #define GB_SDIO_POWER_UP 0x01
987 #define GB_SDIO_POWER_ON 0x02
988 #define GB_SDIO_POWER_UNDEFINED 0x03
991 #define GB_SDIO_BUS_WIDTH_1 0x00
992 #define GB_SDIO_BUS_WIDTH_4 0x02
993 #define GB_SDIO_BUS_WIDTH_8 0x03
996 #define GB_SDIO_TIMING_LEGACY 0x00
997 #define GB_SDIO_TIMING_MMC_HS 0x01
998 #define GB_SDIO_TIMING_SD_HS 0x02
999 #define GB_SDIO_TIMING_UHS_SDR12 0x03
1000 #define GB_SDIO_TIMING_UHS_SDR25 0x04
1001 #define GB_SDIO_TIMING_UHS_SDR50 0x05
1002 #define GB_SDIO_TIMING_UHS_SDR104 0x06
1003 #define GB_SDIO_TIMING_UHS_DDR50 0x07
1004 #define GB_SDIO_TIMING_MMC_DDR52 0x08
1005 #define GB_SDIO_TIMING_MMC_HS200 0x09
1006 #define GB_SDIO_TIMING_MMC_HS400 0x0A
1008 __u8 signal_voltage;
1009 #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
1010 #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
1011 #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
1014 #define GB_SDIO_SET_DRIVER_TYPE_B 0x00
1015 #define GB_SDIO_SET_DRIVER_TYPE_A 0x01
1016 #define GB_SDIO_SET_DRIVER_TYPE_C 0x02
1017 #define GB_SDIO_SET_DRIVER_TYPE_D 0x03
1020 /* command request */
1021 struct gb_sdio_command_request {
1024 #define GB_SDIO_RSP_NONE 0x00
1025 #define GB_SDIO_RSP_PRESENT 0x01
1026 #define GB_SDIO_RSP_136 0x02
1027 #define GB_SDIO_RSP_CRC 0x04
1028 #define GB_SDIO_RSP_BUSY 0x08
1029 #define GB_SDIO_RSP_OPCODE 0x10
1032 #define GB_SDIO_CMD_AC 0x00
1033 #define GB_SDIO_CMD_ADTC 0x01
1034 #define GB_SDIO_CMD_BCR 0x02
1035 #define GB_SDIO_CMD_BC 0x03
1040 struct gb_sdio_command_response {
1044 /* transfer request */
1045 struct gb_sdio_transfer_request {
1047 #define GB_SDIO_DATA_WRITE 0x01
1048 #define GB_SDIO_DATA_READ 0x02
1049 #define GB_SDIO_DATA_STREAM 0x04
1056 struct gb_sdio_transfer_response {
1062 /* event request: generated by module and is defined as unidirectional */
1063 struct gb_sdio_event_request {
1065 #define GB_SDIO_CARD_INSERTED 0x01
1066 #define GB_SDIO_CARD_REMOVED 0x02
1067 #define GB_SDIO_WP 0x04
1072 #define GB_LIGHTS_VERSION_MAJOR 0x00
1073 #define GB_LIGHTS_VERSION_MINOR 0x01
1075 /* Greybus Lights request types */
1076 #define GB_LIGHTS_TYPE_INVALID 0x00
1077 #define GB_LIGHTS_TYPE_PROTOCOL_VERSION 0x01
1078 #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02
1079 #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03
1080 #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04
1081 #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1082 #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06
1083 #define GB_LIGHTS_TYPE_SET_BLINK 0x07
1084 #define GB_LIGHTS_TYPE_SET_COLOR 0x08
1085 #define GB_LIGHTS_TYPE_SET_FADE 0x09
1086 #define GB_LIGHTS_TYPE_EVENT 0x0A
1087 #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B
1088 #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C
1089 #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D
1090 #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E
1092 /* Greybus Light modes */
1095 * if you add any specific mode below, update also the
1096 * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1098 #define GB_CHANNEL_MODE_NONE 0x00000000
1099 #define GB_CHANNEL_MODE_BATTERY 0x00000001
1100 #define GB_CHANNEL_MODE_POWER 0x00000002
1101 #define GB_CHANNEL_MODE_WIRELESS 0x00000004
1102 #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008
1103 #define GB_CHANNEL_MODE_KEYBOARD 0x00000010
1104 #define GB_CHANNEL_MODE_BUTTONS 0x00000020
1105 #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040
1106 #define GB_CHANNEL_MODE_ATTENTION 0x00000080
1107 #define GB_CHANNEL_MODE_FLASH 0x00000100
1108 #define GB_CHANNEL_MODE_TORCH 0x00000200
1109 #define GB_CHANNEL_MODE_INDICATOR 0x00000400
1111 /* Lights Mode valid bit values */
1112 #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF
1113 #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000
1115 /* Greybus Light Channels Flags */
1116 #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001
1117 #define GB_LIGHT_CHANNEL_FADER 0x00000002
1118 #define GB_LIGHT_CHANNEL_BLINK 0x00000004
1120 /* get count of lights in module */
1121 struct gb_lights_get_lights_response {
1125 /* light config request payload */
1126 struct gb_lights_get_light_config_request {
1130 /* light config response payload */
1131 struct gb_lights_get_light_config_response {
1136 /* channel config request payload */
1137 struct gb_lights_get_channel_config_request {
1142 /* channel flash config request payload */
1143 struct gb_lights_get_channel_flash_config_request {
1148 /* channel config response payload */
1149 struct gb_lights_get_channel_config_response {
1150 __u8 max_brightness;
1153 __u8 color_name[32];
1158 /* channel flash config response payload */
1159 struct gb_lights_get_channel_flash_config_response {
1160 __le32 intensity_min_uA;
1161 __le32 intensity_max_uA;
1162 __le32 intensity_step_uA;
1163 __le32 timeout_min_us;
1164 __le32 timeout_max_us;
1165 __le32 timeout_step_us;
1168 /* blink request payload: response have no payload */
1169 struct gb_lights_blink_request {
1176 /* set brightness request payload: response have no payload */
1177 struct gb_lights_set_brightness_request {
1183 /* set color request payload: response have no payload */
1184 struct gb_lights_set_color_request {
1190 /* set fade request payload: response have no payload */
1191 struct gb_lights_set_fade_request {
1198 /* event request: generated by module */
1199 struct gb_lights_event_request {
1202 #define GB_LIGHTS_LIGHT_CONFIG 0x01
1205 /* set flash intensity request payload: response have no payload */
1206 struct gb_lights_set_flash_intensity_request {
1209 __le32 intensity_uA;
1212 /* set flash strobe state request payload: response have no payload */
1213 struct gb_lights_set_flash_strobe_request {
1219 /* set flash timeout request payload: response have no payload */
1220 struct gb_lights_set_flash_timeout_request {
1226 /* get flash fault request payload */
1227 struct gb_lights_get_flash_fault_request {
1232 /* get flash fault response payload */
1233 struct gb_lights_get_flash_fault_response {
1235 #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000
1236 #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001
1237 #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002
1238 #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004
1239 #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008
1240 #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010
1241 #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020
1242 #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040
1243 #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080
1246 #endif /* __GREYBUS_PROTOCOLS_H */