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_INVALID 0x00
122 #define GB_CONTROL_TYPE_PROTOCOL_VERSION 0x01
123 #define GB_CONTROL_TYPE_PROBE_AP 0x02
124 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
125 #define GB_CONTROL_TYPE_GET_MANIFEST 0x04
126 #define GB_CONTROL_TYPE_CONNECTED 0x05
127 #define GB_CONTROL_TYPE_DISCONNECTED 0x06
129 /* Control protocol manifest get size request has no payload*/
130 struct gb_control_get_manifest_size_response {
134 /* Control protocol manifest get request has no payload */
135 struct gb_control_get_manifest_response {
139 /* Control protocol [dis]connected request */
140 struct gb_control_connected_request {
144 struct gb_control_disconnected_request {
147 /* Control protocol [dis]connected response has no payload */
150 /* Firmware Protocol */
152 /* Version of the Greybus firmware protocol we support */
153 #define GB_FIRMWARE_VERSION_MAJOR 0x00
154 #define GB_FIRMWARE_VERSION_MINOR 0x01
156 /* Greybus firmware request types */
157 #define GB_FIRMWARE_TYPE_INVALID 0x00
158 #define GB_FIRMWARE_TYPE_PROTOCOL_VERSION 0x01
159 #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02
160 #define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03
161 #define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04
163 /* Greybus firmware boot stages */
164 #define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
165 #define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */
166 #define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
168 /* Greybus firmware ready to boot status */
169 #define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
170 #define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
171 #define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
173 /* Max firmware data fetch size in bytes */
174 #define GB_FIRMWARE_FETCH_MAX 2000
176 /* Firmware protocol firmware size request/response */
177 struct gb_firmware_size_request {
181 struct gb_firmware_size_response {
185 /* Firmware protocol get firmware request/response */
186 struct gb_firmware_get_firmware_request {
191 struct gb_firmware_get_firmware_response {
195 /* Firmware protocol Ready to boot request */
196 struct gb_firmware_ready_to_boot_request {
200 /* Firmware protocol Ready to boot response has no payload */
205 /* Version of the Greybus battery protocol we support */
206 #define GB_BATTERY_VERSION_MAJOR 0x00
207 #define GB_BATTERY_VERSION_MINOR 0x01
209 /* Greybus battery request types */
210 #define GB_BATTERY_TYPE_TECHNOLOGY 0x02
211 #define GB_BATTERY_TYPE_STATUS 0x03
212 #define GB_BATTERY_TYPE_MAX_VOLTAGE 0x04
213 #define GB_BATTERY_TYPE_PERCENT_CAPACITY 0x05
214 #define GB_BATTERY_TYPE_TEMPERATURE 0x06
215 #define GB_BATTERY_TYPE_VOLTAGE 0x07
216 #define GB_BATTERY_TYPE_CURRENT 0x08
217 #define GB_BATTERY_TYPE_CAPACITY 0x09 // TODO - POWER_SUPPLY_PROP_CURRENT_MAX
218 #define GB_BATTERY_TYPE_SHUTDOWN_TEMP 0x0a // TODO - POWER_SUPPLY_PROP_TEMP_ALERT_MAX
220 /* Should match up with battery types in linux/power_supply.h */
221 #define GB_BATTERY_TECH_UNKNOWN 0x0000
222 #define GB_BATTERY_TECH_NiMH 0x0001
223 #define GB_BATTERY_TECH_LION 0x0002
224 #define GB_BATTERY_TECH_LIPO 0x0003
225 #define GB_BATTERY_TECH_LiFe 0x0004
226 #define GB_BATTERY_TECH_NiCd 0x0005
227 #define GB_BATTERY_TECH_LiMn 0x0006
229 struct gb_battery_technology_response {
233 /* Should match up with battery status in linux/power_supply.h */
234 #define GB_BATTERY_STATUS_UNKNOWN 0x0000
235 #define GB_BATTERY_STATUS_CHARGING 0x0001
236 #define GB_BATTERY_STATUS_DISCHARGING 0x0002
237 #define GB_BATTERY_STATUS_NOT_CHARGING 0x0003
238 #define GB_BATTERY_STATUS_FULL 0x0004
240 struct gb_battery_status_response {
241 __le16 battery_status;
244 struct gb_battery_max_voltage_response {
248 struct gb_battery_capacity_response {
252 struct gb_battery_temperature_response {
256 struct gb_battery_voltage_response {
263 /* Version of the Greybus hid protocol we support */
264 #define GB_HID_VERSION_MAJOR 0x00
265 #define GB_HID_VERSION_MINOR 0x01
267 /* Greybus HID operation types */
268 #define GB_HID_TYPE_INVALID 0x00
269 #define GB_HID_TYPE_PROTOCOL_VERSION 0x01
270 #define GB_HID_TYPE_GET_DESC 0x02
271 #define GB_HID_TYPE_GET_REPORT_DESC 0x03
272 #define GB_HID_TYPE_PWR_ON 0x04
273 #define GB_HID_TYPE_PWR_OFF 0x05
274 #define GB_HID_TYPE_GET_REPORT 0x06
275 #define GB_HID_TYPE_SET_REPORT 0x07
276 #define GB_HID_TYPE_IRQ_EVENT 0x08
279 #define GB_HID_INPUT_REPORT 0
280 #define GB_HID_OUTPUT_REPORT 1
281 #define GB_HID_FEATURE_REPORT 2
283 /* Different request/response structures */
284 /* HID get descriptor response */
285 struct gb_hid_desc_response {
287 __le16 wReportDescLength;
294 /* HID get report request/response */
295 struct gb_hid_get_report_request {
300 /* HID set report request */
301 struct gb_hid_set_report_request {
307 /* HID input report request, via interrupt pipe */
308 struct gb_hid_input_report_request {
315 /* Version of the Greybus i2c protocol we support */
316 #define GB_I2C_VERSION_MAJOR 0x00
317 #define GB_I2C_VERSION_MINOR 0x01
319 /* Greybus i2c request types */
320 #define GB_I2C_TYPE_INVALID 0x00
321 #define GB_I2C_TYPE_PROTOCOL_VERSION 0x01
322 #define GB_I2C_TYPE_FUNCTIONALITY 0x02
323 #define GB_I2C_TYPE_TIMEOUT 0x03
324 #define GB_I2C_TYPE_RETRIES 0x04
325 #define GB_I2C_TYPE_TRANSFER 0x05
327 #define GB_I2C_RETRIES_DEFAULT 3
328 #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
330 /* functionality request has no payload */
331 struct gb_i2c_functionality_response {
332 __le32 functionality;
335 struct gb_i2c_timeout_request {
338 /* timeout response has no payload */
340 struct gb_i2c_retries_request {
343 /* retries response has no payload */
346 * Outgoing data immediately follows the op count and ops array.
347 * The data for each write (master -> slave) op in the array is sent
348 * in order, with no (e.g. pad) bytes separating them.
350 * Short reads cause the entire transfer request to fail So response
351 * payload consists only of bytes read, and the number of bytes is
352 * exactly what was specified in the corresponding op. Like
353 * outgoing data, the incoming data is in order and contiguous.
355 struct gb_i2c_transfer_op {
361 struct gb_i2c_transfer_request {
363 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
365 struct gb_i2c_transfer_response {
366 __u8 data[0]; /* inbound data */
372 /* Version of the Greybus GPIO protocol we support */
373 #define GB_GPIO_VERSION_MAJOR 0x00
374 #define GB_GPIO_VERSION_MINOR 0x01
376 /* Greybus GPIO request types */
377 #define GB_GPIO_TYPE_INVALID 0x00
378 #define GB_GPIO_TYPE_PROTOCOL_VERSION 0x01
379 #define GB_GPIO_TYPE_LINE_COUNT 0x02
380 #define GB_GPIO_TYPE_ACTIVATE 0x03
381 #define GB_GPIO_TYPE_DEACTIVATE 0x04
382 #define GB_GPIO_TYPE_GET_DIRECTION 0x05
383 #define GB_GPIO_TYPE_DIRECTION_IN 0x06
384 #define GB_GPIO_TYPE_DIRECTION_OUT 0x07
385 #define GB_GPIO_TYPE_GET_VALUE 0x08
386 #define GB_GPIO_TYPE_SET_VALUE 0x09
387 #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
388 #define GB_GPIO_TYPE_IRQ_TYPE 0x0b
389 #define GB_GPIO_TYPE_IRQ_MASK 0x0c
390 #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
391 #define GB_GPIO_TYPE_IRQ_EVENT 0x0e
393 #define GB_GPIO_IRQ_TYPE_NONE 0x00
394 #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
395 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
396 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
397 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
398 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
400 /* line count request has no payload */
401 struct gb_gpio_line_count_response {
405 struct gb_gpio_activate_request {
408 /* activate response has no payload */
410 struct gb_gpio_deactivate_request {
413 /* deactivate response has no payload */
415 struct gb_gpio_get_direction_request {
418 struct gb_gpio_get_direction_response {
422 struct gb_gpio_direction_in_request {
425 /* direction in response has no payload */
427 struct gb_gpio_direction_out_request {
431 /* direction out response has no payload */
433 struct gb_gpio_get_value_request {
436 struct gb_gpio_get_value_response {
440 struct gb_gpio_set_value_request {
444 /* set value response has no payload */
446 struct gb_gpio_set_debounce_request {
450 /* debounce response has no payload */
452 struct gb_gpio_irq_type_request {
456 /* irq type response has no payload */
458 struct gb_gpio_irq_mask_request {
461 /* irq mask response has no payload */
463 struct gb_gpio_irq_unmask_request {
466 /* irq unmask response has no payload */
468 /* irq event requests originate on another module and are handled on the AP */
469 struct gb_gpio_irq_event_request {
472 /* irq event has no response */
477 /* Version of the Greybus PWM protocol we support */
478 #define GB_PWM_VERSION_MAJOR 0x00
479 #define GB_PWM_VERSION_MINOR 0x01
481 /* Greybus PWM operation types */
482 #define GB_PWM_TYPE_INVALID 0x00
483 #define GB_PWM_TYPE_PROTOCOL_VERSION 0x01
484 #define GB_PWM_TYPE_PWM_COUNT 0x02
485 #define GB_PWM_TYPE_ACTIVATE 0x03
486 #define GB_PWM_TYPE_DEACTIVATE 0x04
487 #define GB_PWM_TYPE_CONFIG 0x05
488 #define GB_PWM_TYPE_POLARITY 0x06
489 #define GB_PWM_TYPE_ENABLE 0x07
490 #define GB_PWM_TYPE_DISABLE 0x08
492 /* pwm count request has no payload */
493 struct gb_pwm_count_response {
497 struct gb_pwm_activate_request {
501 struct gb_pwm_deactivate_request {
505 struct gb_pwm_config_request {
511 struct gb_pwm_polarity_request {
516 struct gb_pwm_enable_request {
520 struct gb_pwm_disable_request {
526 #define GB_I2S_MGMT_TYPE_PROTOCOL_VERSION 0x01
527 #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS 0x02
528 #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION 0x03
529 #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE 0x04
530 #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY 0x05
531 #define GB_I2S_MGMT_TYPE_SET_START_DELAY 0x06
532 #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT 0x07
533 #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08
534 #define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09
536 #define GB_I2S_MGMT_BYTE_ORDER_NA BIT(0)
537 #define GB_I2S_MGMT_BYTE_ORDER_BE BIT(1)
538 #define GB_I2S_MGMT_BYTE_ORDER_LE BIT(2)
540 #define GB_I2S_MGMT_SPATIAL_LOCATION_FL BIT(0)
541 #define GB_I2S_MGMT_SPATIAL_LOCATION_FR BIT(1)
542 #define GB_I2S_MGMT_SPATIAL_LOCATION_FC BIT(2)
543 #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE BIT(3)
544 #define GB_I2S_MGMT_SPATIAL_LOCATION_BL BIT(4)
545 #define GB_I2S_MGMT_SPATIAL_LOCATION_BR BIT(5)
546 #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC BIT(6)
547 #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC BIT(7)
548 #define GB_I2S_MGMT_SPATIAL_LOCATION_C BIT(8) /* BC in USB */
549 #define GB_I2S_MGMT_SPATIAL_LOCATION_SL BIT(9)
550 #define GB_I2S_MGMT_SPATIAL_LOCATION_SR BIT(10)
551 #define GB_I2S_MGMT_SPATIAL_LOCATION_TC BIT(11)
552 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL BIT(12)
553 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC BIT(13)
554 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR BIT(14)
555 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL BIT(15)
556 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC BIT(16)
557 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR BIT(17)
558 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC BIT(18)
559 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC BIT(19)
560 #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE BIT(20)
561 #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE BIT(21)
562 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL BIT(22)
563 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR BIT(23)
564 #define GB_I2S_MGMT_SPATIAL_LOCATION_BC BIT(24)
565 #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC BIT(25)
566 #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC BIT(26)
567 #define GB_I2S_MGMT_SPATIAL_LOCATION_RD BIT(31)
569 #define GB_I2S_MGMT_PROTOCOL_PCM BIT(0)
570 #define GB_I2S_MGMT_PROTOCOL_I2S BIT(1)
571 #define GB_I2S_MGMT_PROTOCOL_LR_STEREO BIT(2)
573 #define GB_I2S_MGMT_ROLE_MASTER BIT(0)
574 #define GB_I2S_MGMT_ROLE_SLAVE BIT(1)
576 #define GB_I2S_MGMT_POLARITY_NORMAL BIT(0)
577 #define GB_I2S_MGMT_POLARITY_REVERSED BIT(1)
579 #define GB_I2S_MGMT_EDGE_RISING BIT(0)
580 #define GB_I2S_MGMT_EDGE_FALLING BIT(1)
582 #define GB_I2S_MGMT_EVENT_UNSPECIFIED 0x1
583 #define GB_I2S_MGMT_EVENT_HALT 0x2
584 #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR 0x3
585 #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR 0x4
586 #define GB_I2S_MGMT_EVENT_FAILURE 0x5
587 #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE 0x6
588 #define GB_I2S_MGMT_EVENT_UNDERRUN 0x7
589 #define GB_I2S_MGMT_EVENT_OVERRUN 0x8
590 #define GB_I2S_MGMT_EVENT_CLOCKING 0x9
591 #define GB_I2S_MGMT_EVENT_DATA_LEN 0xa
593 struct gb_i2s_mgmt_configuration {
594 __le32 sample_frequency;
596 __u8 bytes_per_channel;
599 __le32 spatial_locations;
604 __u8 ll_wclk_polarity;
605 __u8 ll_wclk_change_edge;
606 __u8 ll_wclk_tx_edge;
607 __u8 ll_wclk_rx_edge;
611 /* get supported configurations request has no payload */
612 struct gb_i2s_mgmt_get_supported_configurations_response {
615 struct gb_i2s_mgmt_configuration config[0];
618 struct gb_i2s_mgmt_set_configuration_request {
619 struct gb_i2s_mgmt_configuration config;
621 /* set configuration response has no payload */
623 struct gb_i2s_mgmt_set_samples_per_message_request {
624 __le16 samples_per_message;
626 /* set samples per message response has no payload */
628 /* get processing request delay has no payload */
629 struct gb_i2s_mgmt_get_processing_delay_response {
633 struct gb_i2s_mgmt_set_start_delay_request {
636 /* set start delay response has no payload */
638 struct gb_i2s_mgmt_activate_cport_request {
641 /* activate cport response has no payload */
643 struct gb_i2s_mgmt_deactivate_cport_request {
646 /* deactivate cport response has no payload */
648 struct gb_i2s_mgmt_report_event_request {
651 /* report event response has no payload */
653 #define GB_I2S_DATA_TYPE_PROTOCOL_VERSION 0x01
654 #define GB_I2S_DATA_TYPE_SEND_DATA 0x02
656 struct gb_i2s_send_data_request {
657 __le32 sample_number;
661 /* send data has no response at all */
666 /* Version of the Greybus spi protocol we support */
667 #define GB_SPI_VERSION_MAJOR 0x00
668 #define GB_SPI_VERSION_MINOR 0x01
670 /* Should match up with modes in linux/spi/spi.h */
671 #define GB_SPI_MODE_CPHA 0x01 /* clock phase */
672 #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
673 #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
674 #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
675 #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
676 #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
677 #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
678 #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
679 #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
680 #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
681 #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
682 #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
684 /* Should match up with flags in linux/spi/spi.h */
685 #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
686 #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
687 #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
689 /* Greybus spi operation types */
690 #define GB_SPI_TYPE_INVALID 0x00
691 #define GB_SPI_TYPE_PROTOCOL_VERSION 0x01
692 #define GB_SPI_TYPE_MODE 0x02
693 #define GB_SPI_TYPE_FLAGS 0x03
694 #define GB_SPI_TYPE_BITS_PER_WORD_MASK 0x04
695 #define GB_SPI_TYPE_NUM_CHIPSELECT 0x05
696 #define GB_SPI_TYPE_TRANSFER 0x06
698 /* mode request has no payload */
699 struct gb_spi_mode_response {
703 /* flags request has no payload */
704 struct gb_spi_flags_response {
708 /* bits-per-word request has no payload */
709 struct gb_spi_bpw_response {
710 __le32 bits_per_word_mask;
713 /* num-chipselects request has no payload */
714 struct gb_spi_chipselect_response {
715 __le16 num_chipselect;
719 * struct gb_spi_transfer - a read/write buffer pair
720 * @speed_hz: Select a speed other than the device default for this transfer. If
721 * 0 the default (from @spi_device) is used.
722 * @len: size of rx and tx buffers (in bytes)
723 * @delay_usecs: microseconds to delay after this transfer before (optionally)
724 * changing the chipselect status, then starting the next transfer or
725 * completing this spi_message.
726 * @cs_change: affects chipselect after this transfer completes
727 * @bits_per_word: select a bits_per_word other than the device default for this
728 * transfer. If 0 the default (from @spi_device) is used.
730 struct gb_spi_transfer {
738 struct gb_spi_transfer_request {
739 __u8 chip_select; /* of the spi device */
740 __u8 mode; /* of the spi device */
742 struct gb_spi_transfer transfers[0]; /* count of these */
745 struct gb_spi_transfer_response {
746 __u8 data[0]; /* inbound data */
749 /* Version of the Greybus SVC protocol we support */
750 #define GB_SVC_VERSION_MAJOR 0x00
751 #define GB_SVC_VERSION_MINOR 0x01
753 /* Greybus SVC request types */
754 #define GB_SVC_TYPE_INVALID 0x00
755 #define GB_SVC_TYPE_PROTOCOL_VERSION 0x01
756 #define GB_SVC_TYPE_SVC_HELLO 0x02
757 #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
758 #define GB_SVC_TYPE_INTF_HOTPLUG 0x04
759 #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
760 #define GB_SVC_TYPE_INTF_RESET 0x06
761 #define GB_SVC_TYPE_CONN_CREATE 0x07
762 #define GB_SVC_TYPE_CONN_DESTROY 0x08
763 #define GB_SVC_TYPE_ROUTE_CREATE 0x0b
765 /* SVC version request/response have same payload as gb_protocol_version_response */
767 /* SVC protocol hello request */
768 struct gb_svc_hello_request {
772 /* hello response has no payload */
774 struct gb_svc_intf_device_id_request {
778 /* device id response has no payload */
780 struct gb_svc_intf_hotplug_request {
783 __le32 unipro_mfg_id;
784 __le32 unipro_prod_id;
789 /* hotplug response has no payload */
791 struct gb_svc_intf_hot_unplug_request {
794 /* hot unplug response has no payload */
796 struct gb_svc_intf_reset_request {
799 /* interface reset response has no payload */
801 struct gb_svc_conn_create_request {
809 /* connection create response has no payload */
811 struct gb_svc_conn_destroy_request {
817 /* connection destroy response has no payload */
819 struct gb_svc_route_create_request {
828 /* Version of the Greybus UART protocol we support */
829 #define GB_UART_VERSION_MAJOR 0x00
830 #define GB_UART_VERSION_MINOR 0x01
832 /* Greybus UART operation types */
833 #define GB_UART_TYPE_INVALID 0x00
834 #define GB_UART_TYPE_PROTOCOL_VERSION 0x01
835 #define GB_UART_TYPE_SEND_DATA 0x02
836 #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
837 #define GB_UART_TYPE_SET_LINE_CODING 0x04
838 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
839 #define GB_UART_TYPE_SEND_BREAK 0x06
840 #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
842 /* Represents data from AP -> Module */
843 struct gb_uart_send_data_request {
848 /* recv-data-request flags */
849 #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
850 #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
851 #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
852 #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
854 /* Represents data from Module -> AP */
855 struct gb_uart_recv_data_request {
861 struct gb_uart_set_line_coding_request {
864 #define GB_SERIAL_1_STOP_BITS 0
865 #define GB_SERIAL_1_5_STOP_BITS 1
866 #define GB_SERIAL_2_STOP_BITS 2
869 #define GB_SERIAL_NO_PARITY 0
870 #define GB_SERIAL_ODD_PARITY 1
871 #define GB_SERIAL_EVEN_PARITY 2
872 #define GB_SERIAL_MARK_PARITY 3
873 #define GB_SERIAL_SPACE_PARITY 4
878 /* output control lines */
879 #define GB_UART_CTRL_DTR 0x01
880 #define GB_UART_CTRL_RTS 0x02
882 struct gb_uart_set_control_line_state_request {
886 struct gb_uart_set_break_request {
890 /* input control lines and line errors */
891 #define GB_UART_CTRL_DCD 0x01
892 #define GB_UART_CTRL_DSR 0x02
893 #define GB_UART_CTRL_RI 0x04
895 struct gb_uart_serial_state_request {
901 /* Version of the Greybus loopback protocol we support */
902 #define GB_LOOPBACK_VERSION_MAJOR 0x00
903 #define GB_LOOPBACK_VERSION_MINOR 0x01
905 /* Greybus loopback request types */
906 #define GB_LOOPBACK_TYPE_INVALID 0x00
907 #define GB_LOOPBACK_TYPE_PROTOCOL_VERSION 0x01
908 #define GB_LOOPBACK_TYPE_PING 0x02
909 #define GB_LOOPBACK_TYPE_TRANSFER 0x03
910 #define GB_LOOPBACK_TYPE_SINK 0x04
912 struct gb_loopback_transfer_request {
917 struct gb_loopback_transfer_response {
922 /* Version of the Greybus sdio protocol we support */
923 #define GB_SDIO_VERSION_MAJOR 0x00
924 #define GB_SDIO_VERSION_MINOR 0x01
926 /* Greybus SDIO operation types */
927 #define GB_SDIO_TYPE_INVALID 0x00
928 #define GB_SDIO_TYPE_PROTOCOL_VERSION 0x01
929 #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
930 #define GB_SDIO_TYPE_SET_IOS 0x03
931 #define GB_SDIO_TYPE_COMMAND 0x04
932 #define GB_SDIO_TYPE_TRANSFER 0x05
933 #define GB_SDIO_TYPE_EVENT 0x06
935 /* get caps response: request has no payload */
936 struct gb_sdio_get_caps_response {
938 #define GB_SDIO_CAP_NONREMOVABLE 0x00000001
939 #define GB_SDIO_CAP_4_BIT_DATA 0x00000002
940 #define GB_SDIO_CAP_8_BIT_DATA 0x00000004
941 #define GB_SDIO_CAP_MMC_HS 0x00000008
942 #define GB_SDIO_CAP_SD_HS 0x00000010
943 #define GB_SDIO_CAP_ERASE 0x00000020
944 #define GB_SDIO_CAP_1_2V_DDR 0x00000040
945 #define GB_SDIO_CAP_1_8V_DDR 0x00000080
946 #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
947 #define GB_SDIO_CAP_UHS_SDR12 0x00000200
948 #define GB_SDIO_CAP_UHS_SDR25 0x00000400
949 #define GB_SDIO_CAP_UHS_SDR50 0x00000800
950 #define GB_SDIO_CAP_UHS_SDR104 0x00001000
951 #define GB_SDIO_CAP_UHS_DDR50 0x00002000
952 #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
953 #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
954 #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
955 #define GB_SDIO_CAP_HS200_1_2V 0x00020000
956 #define GB_SDIO_CAP_HS200_1_8V 0x00040000
957 #define GB_SDIO_CAP_HS400_1_2V 0x00080000
958 #define GB_SDIO_CAP_HS400_1_8V 0x00100000
960 /* see possible values below at vdd */
962 __le16 max_blk_count;
966 /* set ios request: response has no payload */
967 struct gb_sdio_set_ios_request {
970 #define GB_SDIO_VDD_165_195 0x00000001
971 #define GB_SDIO_VDD_20_21 0x00000002
972 #define GB_SDIO_VDD_21_22 0x00000004
973 #define GB_SDIO_VDD_22_23 0x00000008
974 #define GB_SDIO_VDD_23_24 0x00000010
975 #define GB_SDIO_VDD_24_25 0x00000020
976 #define GB_SDIO_VDD_25_26 0x00000040
977 #define GB_SDIO_VDD_26_27 0x00000080
978 #define GB_SDIO_VDD_27_28 0x00000100
979 #define GB_SDIO_VDD_28_29 0x00000200
980 #define GB_SDIO_VDD_29_30 0x00000400
981 #define GB_SDIO_VDD_30_31 0x00000800
982 #define GB_SDIO_VDD_31_32 0x00001000
983 #define GB_SDIO_VDD_32_33 0x00002000
984 #define GB_SDIO_VDD_33_34 0x00004000
985 #define GB_SDIO_VDD_34_35 0x00008000
986 #define GB_SDIO_VDD_35_36 0x00010000
989 #define GB_SDIO_BUSMODE_OPENDRAIN 0x00
990 #define GB_SDIO_BUSMODE_PUSHPULL 0x01
993 #define GB_SDIO_POWER_OFF 0x00
994 #define GB_SDIO_POWER_UP 0x01
995 #define GB_SDIO_POWER_ON 0x02
996 #define GB_SDIO_POWER_UNDEFINED 0x03
999 #define GB_SDIO_BUS_WIDTH_1 0x00
1000 #define GB_SDIO_BUS_WIDTH_4 0x02
1001 #define GB_SDIO_BUS_WIDTH_8 0x03
1004 #define GB_SDIO_TIMING_LEGACY 0x00
1005 #define GB_SDIO_TIMING_MMC_HS 0x01
1006 #define GB_SDIO_TIMING_SD_HS 0x02
1007 #define GB_SDIO_TIMING_UHS_SDR12 0x03
1008 #define GB_SDIO_TIMING_UHS_SDR25 0x04
1009 #define GB_SDIO_TIMING_UHS_SDR50 0x05
1010 #define GB_SDIO_TIMING_UHS_SDR104 0x06
1011 #define GB_SDIO_TIMING_UHS_DDR50 0x07
1012 #define GB_SDIO_TIMING_MMC_DDR52 0x08
1013 #define GB_SDIO_TIMING_MMC_HS200 0x09
1014 #define GB_SDIO_TIMING_MMC_HS400 0x0A
1016 __u8 signal_voltage;
1017 #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
1018 #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
1019 #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
1022 #define GB_SDIO_SET_DRIVER_TYPE_B 0x00
1023 #define GB_SDIO_SET_DRIVER_TYPE_A 0x01
1024 #define GB_SDIO_SET_DRIVER_TYPE_C 0x02
1025 #define GB_SDIO_SET_DRIVER_TYPE_D 0x03
1028 /* command request */
1029 struct gb_sdio_command_request {
1032 #define GB_SDIO_RSP_NONE 0x00
1033 #define GB_SDIO_RSP_PRESENT 0x01
1034 #define GB_SDIO_RSP_136 0x02
1035 #define GB_SDIO_RSP_CRC 0x04
1036 #define GB_SDIO_RSP_BUSY 0x08
1037 #define GB_SDIO_RSP_OPCODE 0x10
1040 #define GB_SDIO_CMD_AC 0x00
1041 #define GB_SDIO_CMD_ADTC 0x01
1042 #define GB_SDIO_CMD_BCR 0x02
1043 #define GB_SDIO_CMD_BC 0x03
1048 struct gb_sdio_command_response {
1052 /* transfer request */
1053 struct gb_sdio_transfer_request {
1055 #define GB_SDIO_DATA_WRITE 0x01
1056 #define GB_SDIO_DATA_READ 0x02
1057 #define GB_SDIO_DATA_STREAM 0x04
1064 struct gb_sdio_transfer_response {
1070 /* event request: generated by module and is defined as unidirectional */
1071 struct gb_sdio_event_request {
1073 #define GB_SDIO_CARD_INSERTED 0x01
1074 #define GB_SDIO_CARD_REMOVED 0x02
1075 #define GB_SDIO_WP 0x04
1078 #endif /* __GREYBUS_PROTOCOLS_H */