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 */
151 /* Version of the Greybus i2c protocol we support */
152 #define GB_I2C_VERSION_MAJOR 0x00
153 #define GB_I2C_VERSION_MINOR 0x01
155 /* Greybus i2c request types */
156 #define GB_I2C_TYPE_INVALID 0x00
157 #define GB_I2C_TYPE_PROTOCOL_VERSION 0x01
158 #define GB_I2C_TYPE_FUNCTIONALITY 0x02
159 #define GB_I2C_TYPE_TIMEOUT 0x03
160 #define GB_I2C_TYPE_RETRIES 0x04
161 #define GB_I2C_TYPE_TRANSFER 0x05
163 #define GB_I2C_RETRIES_DEFAULT 3
164 #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
166 /* functionality request has no payload */
167 struct gb_i2c_functionality_response {
168 __le32 functionality;
171 struct gb_i2c_timeout_request {
174 /* timeout response has no payload */
176 struct gb_i2c_retries_request {
179 /* retries response has no payload */
182 * Outgoing data immediately follows the op count and ops array.
183 * The data for each write (master -> slave) op in the array is sent
184 * in order, with no (e.g. pad) bytes separating them.
186 * Short reads cause the entire transfer request to fail So response
187 * payload consists only of bytes read, and the number of bytes is
188 * exactly what was specified in the corresponding op. Like
189 * outgoing data, the incoming data is in order and contiguous.
191 struct gb_i2c_transfer_op {
197 struct gb_i2c_transfer_request {
199 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
201 struct gb_i2c_transfer_response {
202 __u8 data[0]; /* inbound data */
208 /* Version of the Greybus GPIO protocol we support */
209 #define GB_GPIO_VERSION_MAJOR 0x00
210 #define GB_GPIO_VERSION_MINOR 0x01
212 /* Greybus GPIO request types */
213 #define GB_GPIO_TYPE_INVALID 0x00
214 #define GB_GPIO_TYPE_PROTOCOL_VERSION 0x01
215 #define GB_GPIO_TYPE_LINE_COUNT 0x02
216 #define GB_GPIO_TYPE_ACTIVATE 0x03
217 #define GB_GPIO_TYPE_DEACTIVATE 0x04
218 #define GB_GPIO_TYPE_GET_DIRECTION 0x05
219 #define GB_GPIO_TYPE_DIRECTION_IN 0x06
220 #define GB_GPIO_TYPE_DIRECTION_OUT 0x07
221 #define GB_GPIO_TYPE_GET_VALUE 0x08
222 #define GB_GPIO_TYPE_SET_VALUE 0x09
223 #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
224 #define GB_GPIO_TYPE_IRQ_TYPE 0x0b
225 #define GB_GPIO_TYPE_IRQ_MASK 0x0c
226 #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
227 #define GB_GPIO_TYPE_IRQ_EVENT 0x0e
229 #define GB_GPIO_IRQ_TYPE_NONE 0x00
230 #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
231 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
232 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
233 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
234 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
236 /* line count request has no payload */
237 struct gb_gpio_line_count_response {
241 struct gb_gpio_activate_request {
244 /* activate response has no payload */
246 struct gb_gpio_deactivate_request {
249 /* deactivate response has no payload */
251 struct gb_gpio_get_direction_request {
254 struct gb_gpio_get_direction_response {
258 struct gb_gpio_direction_in_request {
261 /* direction in response has no payload */
263 struct gb_gpio_direction_out_request {
267 /* direction out response has no payload */
269 struct gb_gpio_get_value_request {
272 struct gb_gpio_get_value_response {
276 struct gb_gpio_set_value_request {
280 /* set value response has no payload */
282 struct gb_gpio_set_debounce_request {
286 /* debounce response has no payload */
288 struct gb_gpio_irq_type_request {
292 /* irq type response has no payload */
294 struct gb_gpio_irq_mask_request {
297 /* irq mask response has no payload */
299 struct gb_gpio_irq_unmask_request {
302 /* irq unmask response has no payload */
304 /* irq event requests originate on another module and are handled on the AP */
305 struct gb_gpio_irq_event_request {
308 /* irq event has no response */
313 /* Version of the Greybus PWM protocol we support */
314 #define GB_PWM_VERSION_MAJOR 0x00
315 #define GB_PWM_VERSION_MINOR 0x01
317 /* Greybus PWM operation types */
318 #define GB_PWM_TYPE_INVALID 0x00
319 #define GB_PWM_TYPE_PROTOCOL_VERSION 0x01
320 #define GB_PWM_TYPE_PWM_COUNT 0x02
321 #define GB_PWM_TYPE_ACTIVATE 0x03
322 #define GB_PWM_TYPE_DEACTIVATE 0x04
323 #define GB_PWM_TYPE_CONFIG 0x05
324 #define GB_PWM_TYPE_POLARITY 0x06
325 #define GB_PWM_TYPE_ENABLE 0x07
326 #define GB_PWM_TYPE_DISABLE 0x08
328 /* pwm count request has no payload */
329 struct gb_pwm_count_response {
333 struct gb_pwm_activate_request {
337 struct gb_pwm_deactivate_request {
341 struct gb_pwm_config_request {
347 struct gb_pwm_polarity_request {
352 struct gb_pwm_enable_request {
356 struct gb_pwm_disable_request {
362 #define GB_I2S_MGMT_TYPE_PROTOCOL_VERSION 0x01
363 #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS 0x02
364 #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION 0x03
365 #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE 0x04
366 #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY 0x05
367 #define GB_I2S_MGMT_TYPE_SET_START_DELAY 0x06
368 #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT 0x07
369 #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08
370 #define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09
372 #define GB_I2S_MGMT_BYTE_ORDER_NA BIT(0)
373 #define GB_I2S_MGMT_BYTE_ORDER_BE BIT(1)
374 #define GB_I2S_MGMT_BYTE_ORDER_LE BIT(2)
376 #define GB_I2S_MGMT_SPATIAL_LOCATION_FL BIT(0)
377 #define GB_I2S_MGMT_SPATIAL_LOCATION_FR BIT(1)
378 #define GB_I2S_MGMT_SPATIAL_LOCATION_FC BIT(2)
379 #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE BIT(3)
380 #define GB_I2S_MGMT_SPATIAL_LOCATION_BL BIT(4)
381 #define GB_I2S_MGMT_SPATIAL_LOCATION_BR BIT(5)
382 #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC BIT(6)
383 #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC BIT(7)
384 #define GB_I2S_MGMT_SPATIAL_LOCATION_C BIT(8) /* BC in USB */
385 #define GB_I2S_MGMT_SPATIAL_LOCATION_SL BIT(9)
386 #define GB_I2S_MGMT_SPATIAL_LOCATION_SR BIT(10)
387 #define GB_I2S_MGMT_SPATIAL_LOCATION_TC BIT(11)
388 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL BIT(12)
389 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC BIT(13)
390 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR BIT(14)
391 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL BIT(15)
392 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC BIT(16)
393 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR BIT(17)
394 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC BIT(18)
395 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC BIT(19)
396 #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE BIT(20)
397 #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE BIT(21)
398 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL BIT(22)
399 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR BIT(23)
400 #define GB_I2S_MGMT_SPATIAL_LOCATION_BC BIT(24)
401 #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC BIT(25)
402 #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC BIT(26)
403 #define GB_I2S_MGMT_SPATIAL_LOCATION_RD BIT(31)
405 #define GB_I2S_MGMT_PROTOCOL_PCM BIT(0)
406 #define GB_I2S_MGMT_PROTOCOL_I2S BIT(1)
407 #define GB_I2S_MGMT_PROTOCOL_LR_STEREO BIT(2)
409 #define GB_I2S_MGMT_ROLE_MASTER BIT(0)
410 #define GB_I2S_MGMT_ROLE_SLAVE BIT(1)
412 #define GB_I2S_MGMT_POLARITY_NORMAL BIT(0)
413 #define GB_I2S_MGMT_POLARITY_REVERSED BIT(1)
415 #define GB_I2S_MGMT_EDGE_RISING BIT(0)
416 #define GB_I2S_MGMT_EDGE_FALLING BIT(1)
418 #define GB_I2S_MGMT_EVENT_UNSPECIFIED 0x1
419 #define GB_I2S_MGMT_EVENT_HALT 0x2
420 #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR 0x3
421 #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR 0x4
422 #define GB_I2S_MGMT_EVENT_FAILURE 0x5
423 #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE 0x6
424 #define GB_I2S_MGMT_EVENT_UNDERRUN 0x7
425 #define GB_I2S_MGMT_EVENT_OVERRUN 0x8
426 #define GB_I2S_MGMT_EVENT_CLOCKING 0x9
427 #define GB_I2S_MGMT_EVENT_DATA_LEN 0xa
429 struct gb_i2s_mgmt_configuration {
430 __le32 sample_frequency;
432 __u8 bytes_per_channel;
435 __le32 spatial_locations;
440 __u8 ll_wclk_polarity;
441 __u8 ll_wclk_change_edge;
442 __u8 ll_wclk_tx_edge;
443 __u8 ll_wclk_rx_edge;
447 /* get supported configurations request has no payload */
448 struct gb_i2s_mgmt_get_supported_configurations_response {
451 struct gb_i2s_mgmt_configuration config[0];
454 struct gb_i2s_mgmt_set_configuration_request {
455 struct gb_i2s_mgmt_configuration config;
457 /* set configuration response has no payload */
459 struct gb_i2s_mgmt_set_samples_per_message_request {
460 __le16 samples_per_message;
462 /* set samples per message response has no payload */
464 /* get processing request delay has no payload */
465 struct gb_i2s_mgmt_get_processing_delay_response {
469 struct gb_i2s_mgmt_set_start_delay_request {
472 /* set start delay response has no payload */
474 struct gb_i2s_mgmt_activate_cport_request {
477 /* activate cport response has no payload */
479 struct gb_i2s_mgmt_deactivate_cport_request {
482 /* deactivate cport response has no payload */
484 struct gb_i2s_mgmt_report_event_request {
487 /* report event response has no payload */
489 #define GB_I2S_DATA_TYPE_PROTOCOL_VERSION 0x01
490 #define GB_I2S_DATA_TYPE_SEND_DATA 0x02
492 struct gb_i2s_send_data_request {
493 __le32 sample_number;
497 /* send data has no response at all */
502 /* Version of the Greybus spi protocol we support */
503 #define GB_SPI_VERSION_MAJOR 0x00
504 #define GB_SPI_VERSION_MINOR 0x01
506 /* Should match up with modes in linux/spi/spi.h */
507 #define GB_SPI_MODE_CPHA 0x01 /* clock phase */
508 #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
509 #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
510 #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
511 #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
512 #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
513 #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
514 #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
515 #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
516 #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
517 #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
518 #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
520 /* Should match up with flags in linux/spi/spi.h */
521 #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
522 #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
523 #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
525 /* Greybus spi operation types */
526 #define GB_SPI_TYPE_INVALID 0x00
527 #define GB_SPI_TYPE_PROTOCOL_VERSION 0x01
528 #define GB_SPI_TYPE_MODE 0x02
529 #define GB_SPI_TYPE_FLAGS 0x03
530 #define GB_SPI_TYPE_BITS_PER_WORD_MASK 0x04
531 #define GB_SPI_TYPE_NUM_CHIPSELECT 0x05
532 #define GB_SPI_TYPE_TRANSFER 0x06
534 /* mode request has no payload */
535 struct gb_spi_mode_response {
539 /* flags request has no payload */
540 struct gb_spi_flags_response {
544 /* bits-per-word request has no payload */
545 struct gb_spi_bpw_response {
546 __le32 bits_per_word_mask;
549 /* num-chipselects request has no payload */
550 struct gb_spi_chipselect_response {
551 __le16 num_chipselect;
555 * struct gb_spi_transfer - a read/write buffer pair
556 * @speed_hz: Select a speed other than the device default for this transfer. If
557 * 0 the default (from @spi_device) is used.
558 * @len: size of rx and tx buffers (in bytes)
559 * @delay_usecs: microseconds to delay after this transfer before (optionally)
560 * changing the chipselect status, then starting the next transfer or
561 * completing this spi_message.
562 * @cs_change: affects chipselect after this transfer completes
563 * @bits_per_word: select a bits_per_word other than the device default for this
564 * transfer. If 0 the default (from @spi_device) is used.
566 struct gb_spi_transfer {
574 struct gb_spi_transfer_request {
575 __u8 chip_select; /* of the spi device */
576 __u8 mode; /* of the spi device */
578 struct gb_spi_transfer transfers[0]; /* count of these */
581 struct gb_spi_transfer_response {
582 __u8 data[0]; /* inbound data */
585 /* Version of the Greybus SVC protocol we support */
586 #define GB_SVC_VERSION_MAJOR 0x00
587 #define GB_SVC_VERSION_MINOR 0x01
589 /* Greybus SVC request types */
590 #define GB_SVC_TYPE_INVALID 0x00
591 #define GB_SVC_TYPE_PROTOCOL_VERSION 0x01
592 #define GB_SVC_TYPE_SVC_HELLO 0x02
593 #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
594 #define GB_SVC_TYPE_INTF_HOTPLUG 0x04
595 #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
596 #define GB_SVC_TYPE_INTF_RESET 0x06
597 #define GB_SVC_TYPE_CONN_CREATE 0x07
598 #define GB_SVC_TYPE_CONN_DESTROY 0x08
599 #define GB_SVC_TYPE_ROUTE_CREATE 0x0b
601 /* SVC version request/response have same payload as gb_protocol_version_response */
603 /* SVC protocol hello request */
604 struct gb_svc_hello_request {
608 /* hello response has no payload */
610 struct gb_svc_intf_device_id_request {
614 /* device id response has no payload */
616 struct gb_svc_intf_hotplug_request {
619 __le32 unipro_mfg_id;
620 __le32 unipro_prod_id;
625 /* hotplug response has no payload */
627 struct gb_svc_intf_hot_unplug_request {
630 /* hot unplug response has no payload */
632 struct gb_svc_intf_reset_request {
635 /* interface reset response has no payload */
637 struct gb_svc_conn_create_request {
645 /* connection create response has no payload */
647 struct gb_svc_conn_destroy_request {
653 /* connection destroy response has no payload */
655 struct gb_svc_route_create_request {
664 /* Version of the Greybus UART protocol we support */
665 #define GB_UART_VERSION_MAJOR 0x00
666 #define GB_UART_VERSION_MINOR 0x01
668 /* Greybus UART operation types */
669 #define GB_UART_TYPE_INVALID 0x00
670 #define GB_UART_TYPE_PROTOCOL_VERSION 0x01
671 #define GB_UART_TYPE_SEND_DATA 0x02
672 #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
673 #define GB_UART_TYPE_SET_LINE_CODING 0x04
674 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
675 #define GB_UART_TYPE_SEND_BREAK 0x06
676 #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
678 /* Represents data from AP -> Module */
679 struct gb_uart_send_data_request {
684 /* recv-data-request flags */
685 #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
686 #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
687 #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
688 #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
690 /* Represents data from Module -> AP */
691 struct gb_uart_recv_data_request {
697 struct gb_uart_set_line_coding_request {
700 #define GB_SERIAL_1_STOP_BITS 0
701 #define GB_SERIAL_1_5_STOP_BITS 1
702 #define GB_SERIAL_2_STOP_BITS 2
705 #define GB_SERIAL_NO_PARITY 0
706 #define GB_SERIAL_ODD_PARITY 1
707 #define GB_SERIAL_EVEN_PARITY 2
708 #define GB_SERIAL_MARK_PARITY 3
709 #define GB_SERIAL_SPACE_PARITY 4
714 /* output control lines */
715 #define GB_UART_CTRL_DTR 0x01
716 #define GB_UART_CTRL_RTS 0x02
718 struct gb_uart_set_control_line_state_request {
722 struct gb_uart_set_break_request {
726 /* input control lines and line errors */
727 #define GB_UART_CTRL_DCD 0x01
728 #define GB_UART_CTRL_DSR 0x02
729 #define GB_UART_CTRL_RI 0x04
731 struct gb_uart_serial_state_request {
737 /* Version of the Greybus loopback protocol we support */
738 #define GB_LOOPBACK_VERSION_MAJOR 0x00
739 #define GB_LOOPBACK_VERSION_MINOR 0x01
741 /* Greybus loopback request types */
742 #define GB_LOOPBACK_TYPE_INVALID 0x00
743 #define GB_LOOPBACK_TYPE_PROTOCOL_VERSION 0x01
744 #define GB_LOOPBACK_TYPE_PING 0x02
745 #define GB_LOOPBACK_TYPE_TRANSFER 0x03
746 #define GB_LOOPBACK_TYPE_SINK 0x04
748 struct gb_loopback_transfer_request {
753 struct gb_loopback_transfer_response {
758 /* Version of the Greybus sdio protocol we support */
759 #define GB_SDIO_VERSION_MAJOR 0x00
760 #define GB_SDIO_VERSION_MINOR 0x01
762 /* Greybus SDIO operation types */
763 #define GB_SDIO_TYPE_INVALID 0x00
764 #define GB_SDIO_TYPE_PROTOCOL_VERSION 0x01
765 #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
766 #define GB_SDIO_TYPE_SET_IOS 0x03
767 #define GB_SDIO_TYPE_COMMAND 0x04
768 #define GB_SDIO_TYPE_TRANSFER 0x05
769 #define GB_SDIO_TYPE_EVENT 0x06
771 /* get caps response: request has no payload */
772 struct gb_sdio_get_caps_response {
774 #define GB_SDIO_CAP_NONREMOVABLE 0x00000001
775 #define GB_SDIO_CAP_4_BIT_DATA 0x00000002
776 #define GB_SDIO_CAP_8_BIT_DATA 0x00000004
777 #define GB_SDIO_CAP_MMC_HS 0x00000008
778 #define GB_SDIO_CAP_SD_HS 0x00000010
779 #define GB_SDIO_CAP_ERASE 0x00000020
780 #define GB_SDIO_CAP_1_2V_DDR 0x00000040
781 #define GB_SDIO_CAP_1_8V_DDR 0x00000080
782 #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
783 #define GB_SDIO_CAP_UHS_SDR12 0x00000200
784 #define GB_SDIO_CAP_UHS_SDR25 0x00000400
785 #define GB_SDIO_CAP_UHS_SDR50 0x00000800
786 #define GB_SDIO_CAP_UHS_SDR104 0x00001000
787 #define GB_SDIO_CAP_UHS_DDR50 0x00002000
788 #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
789 #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
790 #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
791 #define GB_SDIO_CAP_HS200_1_2V 0x00020000
792 #define GB_SDIO_CAP_HS200_1_8V 0x00040000
793 #define GB_SDIO_CAP_HS400_1_2V 0x00080000
794 #define GB_SDIO_CAP_HS400_1_8V 0x00100000
796 /* see possible values below at vdd */
798 __le16 max_blk_count;
802 /* set ios request: response has no payload */
803 struct gb_sdio_set_ios_request {
806 #define GB_SDIO_VDD_165_195 0x00000001
807 #define GB_SDIO_VDD_20_21 0x00000002
808 #define GB_SDIO_VDD_21_22 0x00000004
809 #define GB_SDIO_VDD_22_23 0x00000008
810 #define GB_SDIO_VDD_23_24 0x00000010
811 #define GB_SDIO_VDD_24_25 0x00000020
812 #define GB_SDIO_VDD_25_26 0x00000040
813 #define GB_SDIO_VDD_26_27 0x00000080
814 #define GB_SDIO_VDD_27_28 0x00000100
815 #define GB_SDIO_VDD_28_29 0x00000200
816 #define GB_SDIO_VDD_29_30 0x00000400
817 #define GB_SDIO_VDD_30_31 0x00000800
818 #define GB_SDIO_VDD_31_32 0x00001000
819 #define GB_SDIO_VDD_32_33 0x00002000
820 #define GB_SDIO_VDD_33_34 0x00004000
821 #define GB_SDIO_VDD_34_35 0x00008000
822 #define GB_SDIO_VDD_35_36 0x00010000
825 #define GB_SDIO_BUSMODE_OPENDRAIN 0x00
826 #define GB_SDIO_BUSMODE_PUSHPULL 0x01
829 #define GB_SDIO_POWER_OFF 0x00
830 #define GB_SDIO_POWER_UP 0x01
831 #define GB_SDIO_POWER_ON 0x02
832 #define GB_SDIO_POWER_UNDEFINED 0x03
835 #define GB_SDIO_BUS_WIDTH_1 0x00
836 #define GB_SDIO_BUS_WIDTH_4 0x02
837 #define GB_SDIO_BUS_WIDTH_8 0x03
840 #define GB_SDIO_TIMING_LEGACY 0x00
841 #define GB_SDIO_TIMING_MMC_HS 0x01
842 #define GB_SDIO_TIMING_SD_HS 0x02
843 #define GB_SDIO_TIMING_UHS_SDR12 0x03
844 #define GB_SDIO_TIMING_UHS_SDR25 0x04
845 #define GB_SDIO_TIMING_UHS_SDR50 0x05
846 #define GB_SDIO_TIMING_UHS_SDR104 0x06
847 #define GB_SDIO_TIMING_UHS_DDR50 0x07
848 #define GB_SDIO_TIMING_MMC_DDR52 0x08
849 #define GB_SDIO_TIMING_MMC_HS200 0x09
850 #define GB_SDIO_TIMING_MMC_HS400 0x0A
853 #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
854 #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
855 #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
858 #define GB_SDIO_SET_DRIVER_TYPE_B 0x00
859 #define GB_SDIO_SET_DRIVER_TYPE_A 0x01
860 #define GB_SDIO_SET_DRIVER_TYPE_C 0x02
861 #define GB_SDIO_SET_DRIVER_TYPE_D 0x03
864 /* command request */
865 struct gb_sdio_command_request {
868 #define GB_SDIO_RSP_NONE 0x00
869 #define GB_SDIO_RSP_PRESENT 0x01
870 #define GB_SDIO_RSP_136 0x02
871 #define GB_SDIO_RSP_CRC 0x04
872 #define GB_SDIO_RSP_BUSY 0x08
873 #define GB_SDIO_RSP_OPCODE 0x10
876 #define GB_SDIO_CMD_AC 0x00
877 #define GB_SDIO_CMD_ADTC 0x01
878 #define GB_SDIO_CMD_BCR 0x02
879 #define GB_SDIO_CMD_BC 0x03
884 struct gb_sdio_command_response {
888 /* transfer request */
889 struct gb_sdio_transfer_request {
891 #define GB_SDIO_DATA_WRITE 0x01
892 #define GB_SDIO_DATA_READ 0x02
893 #define GB_SDIO_DATA_STREAM 0x04
900 struct gb_sdio_transfer_response {
906 /* event request: generated by module and is defined as unidirectional */
907 struct gb_sdio_event_request {
909 #define GB_SDIO_CARD_INSERTED 0x01
910 #define GB_SDIO_CARD_REMOVED 0x02
911 #define GB_SDIO_WP 0x04
914 #endif /* __GREYBUS_PROTOCOLS_H */