greybus: uart: fix typo in defintion
[linux-2.6-microblaze.git] / drivers / staging / greybus / greybus_protocols.h
1 /*
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.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
8  * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
9  *
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.
13  *
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.
18  *
19  * BSD LICENSE
20  *
21  * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
22  * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
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
33  *    distribution.
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
37  *    permission.
38  *
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.
50  */
51
52 #ifndef __GREYBUS_PROTOCOLS_H
53 #define __GREYBUS_PROTOCOLS_H
54
55 /* Control Protocol */
56
57 /* Bundle-id and cport-id for control cport */
58 #define GB_CONTROL_BUNDLE_ID                    0
59 #define GB_CONTROL_CPORT_ID                     2
60
61 /* Version of the Greybus control protocol we support */
62 #define GB_CONTROL_VERSION_MAJOR                0x00
63 #define GB_CONTROL_VERSION_MINOR                0x01
64
65 /* Greybus control request types */
66 #define GB_CONTROL_TYPE_INVALID                 0x00
67 #define GB_CONTROL_TYPE_PROTOCOL_VERSION        0x01
68 #define GB_CONTROL_TYPE_PROBE_AP                0x02
69 #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE       0x03
70 #define GB_CONTROL_TYPE_GET_MANIFEST            0x04
71 #define GB_CONTROL_TYPE_CONNECTED               0x05
72 #define GB_CONTROL_TYPE_DISCONNECTED            0x06
73
74 /* Control protocol manifest get size request has no payload*/
75 struct gb_control_get_manifest_size_response {
76         __le16                  size;
77 };
78
79 /* Control protocol manifest get request has no payload */
80 struct gb_control_get_manifest_response {
81         __u8                    data[0];
82 };
83
84 /* Control protocol [dis]connected request */
85 struct gb_control_connected_request {
86         __le16                  cport_id;
87 };
88
89 struct gb_control_disconnected_request {
90         __le16                  cport_id;
91 };
92 /* Control protocol [dis]connected response has no payload */
93
94 /* I2C */
95
96 /* Version of the Greybus i2c protocol we support */
97 #define GB_I2C_VERSION_MAJOR            0x00
98 #define GB_I2C_VERSION_MINOR            0x01
99
100 /* Greybus i2c request types */
101 #define GB_I2C_TYPE_INVALID             0x00
102 #define GB_I2C_TYPE_PROTOCOL_VERSION    0x01
103 #define GB_I2C_TYPE_FUNCTIONALITY       0x02
104 #define GB_I2C_TYPE_TIMEOUT             0x03
105 #define GB_I2C_TYPE_RETRIES             0x04
106 #define GB_I2C_TYPE_TRANSFER            0x05
107
108 #define GB_I2C_RETRIES_DEFAULT          3
109 #define GB_I2C_TIMEOUT_DEFAULT          1000    /* milliseconds */
110
111 /* functionality request has no payload */
112 struct gb_i2c_functionality_response {
113         __le32  functionality;
114 };
115
116 struct gb_i2c_timeout_request {
117         __le16  msec;
118 };
119 /* timeout response has no payload */
120
121 struct gb_i2c_retries_request {
122         __u8    retries;
123 };
124 /* retries response has no payload */
125
126 /*
127  * Outgoing data immediately follows the op count and ops array.
128  * The data for each write (master -> slave) op in the array is sent
129  * in order, with no (e.g. pad) bytes separating them.
130  *
131  * Short reads cause the entire transfer request to fail So response
132  * payload consists only of bytes read, and the number of bytes is
133  * exactly what was specified in the corresponding op.  Like
134  * outgoing data, the incoming data is in order and contiguous.
135  */
136 struct gb_i2c_transfer_op {
137         __le16  addr;
138         __le16  flags;
139         __le16  size;
140 };
141
142 struct gb_i2c_transfer_request {
143         __le16                          op_count;
144         struct gb_i2c_transfer_op       ops[0];         /* op_count of these */
145 };
146 struct gb_i2c_transfer_response {
147         __u8                            data[0];        /* inbound data */
148 };
149
150
151 /* GPIO */
152
153 /* Version of the Greybus GPIO protocol we support */
154 #define GB_GPIO_VERSION_MAJOR           0x00
155 #define GB_GPIO_VERSION_MINOR           0x01
156
157 /* Greybus GPIO request types */
158 #define GB_GPIO_TYPE_INVALID            0x00
159 #define GB_GPIO_TYPE_PROTOCOL_VERSION   0x01
160 #define GB_GPIO_TYPE_LINE_COUNT         0x02
161 #define GB_GPIO_TYPE_ACTIVATE           0x03
162 #define GB_GPIO_TYPE_DEACTIVATE         0x04
163 #define GB_GPIO_TYPE_GET_DIRECTION      0x05
164 #define GB_GPIO_TYPE_DIRECTION_IN       0x06
165 #define GB_GPIO_TYPE_DIRECTION_OUT      0x07
166 #define GB_GPIO_TYPE_GET_VALUE          0x08
167 #define GB_GPIO_TYPE_SET_VALUE          0x09
168 #define GB_GPIO_TYPE_SET_DEBOUNCE       0x0a
169 #define GB_GPIO_TYPE_IRQ_TYPE           0x0b
170 #define GB_GPIO_TYPE_IRQ_MASK           0x0c
171 #define GB_GPIO_TYPE_IRQ_UNMASK         0x0d
172 #define GB_GPIO_TYPE_IRQ_EVENT          0x0e
173
174 #define GB_GPIO_IRQ_TYPE_NONE           0x00
175 #define GB_GPIO_IRQ_TYPE_EDGE_RISING    0x01
176 #define GB_GPIO_IRQ_TYPE_EDGE_FALLING   0x02
177 #define GB_GPIO_IRQ_TYPE_EDGE_BOTH      0x03
178 #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH     0x04
179 #define GB_GPIO_IRQ_TYPE_LEVEL_LOW      0x08
180
181 /* line count request has no payload */
182 struct gb_gpio_line_count_response {
183         __u8    count;
184 };
185
186 struct gb_gpio_activate_request {
187         __u8    which;
188 };
189 /* activate response has no payload */
190
191 struct gb_gpio_deactivate_request {
192         __u8    which;
193 };
194 /* deactivate response has no payload */
195
196 struct gb_gpio_get_direction_request {
197         __u8    which;
198 };
199 struct gb_gpio_get_direction_response {
200         __u8    direction;
201 };
202
203 struct gb_gpio_direction_in_request {
204         __u8    which;
205 };
206 /* direction in response has no payload */
207
208 struct gb_gpio_direction_out_request {
209         __u8    which;
210         __u8    value;
211 };
212 /* direction out response has no payload */
213
214 struct gb_gpio_get_value_request {
215         __u8    which;
216 };
217 struct gb_gpio_get_value_response {
218         __u8    value;
219 };
220
221 struct gb_gpio_set_value_request {
222         __u8    which;
223         __u8    value;
224 };
225 /* set value response has no payload */
226
227 struct gb_gpio_set_debounce_request {
228         __u8    which;
229         __le16  usec __packed;
230 };
231 /* debounce response has no payload */
232
233 struct gb_gpio_irq_type_request {
234         __u8    which;
235         __u8    type;
236 };
237 /* irq type response has no payload */
238
239 struct gb_gpio_irq_mask_request {
240         __u8    which;
241 };
242 /* irq mask response has no payload */
243
244 struct gb_gpio_irq_unmask_request {
245         __u8    which;
246 };
247 /* irq unmask response has no payload */
248
249 /* irq event requests originate on another module and are handled on the AP */
250 struct gb_gpio_irq_event_request {
251         __u8    which;
252 };
253 /* irq event has no response */
254
255
256 /* PWM */
257
258 /* Version of the Greybus PWM protocol we support */
259 #define GB_PWM_VERSION_MAJOR            0x00
260 #define GB_PWM_VERSION_MINOR            0x01
261
262 /* Greybus PWM operation types */
263 #define GB_PWM_TYPE_INVALID             0x00
264 #define GB_PWM_TYPE_PROTOCOL_VERSION    0x01
265 #define GB_PWM_TYPE_PWM_COUNT           0x02
266 #define GB_PWM_TYPE_ACTIVATE            0x03
267 #define GB_PWM_TYPE_DEACTIVATE          0x04
268 #define GB_PWM_TYPE_CONFIG              0x05
269 #define GB_PWM_TYPE_POLARITY            0x06
270 #define GB_PWM_TYPE_ENABLE              0x07
271 #define GB_PWM_TYPE_DISABLE             0x08
272
273 /* pwm count request has no payload */
274 struct gb_pwm_count_response {
275         __u8    count;
276 };
277
278 struct gb_pwm_activate_request {
279         __u8    which;
280 };
281
282 struct gb_pwm_deactivate_request {
283         __u8    which;
284 };
285
286 struct gb_pwm_config_request {
287         __u8    which;
288         __le32  duty __packed;
289         __le32  period __packed;
290 };
291
292 struct gb_pwm_polarity_request {
293         __u8    which;
294         __u8    polarity;
295 };
296
297 struct gb_pwm_enable_request {
298         __u8    which;
299 };
300
301 struct gb_pwm_disable_request {
302         __u8    which;
303 };
304
305 /* I2S */
306
307 #define GB_I2S_MGMT_TYPE_PROTOCOL_VERSION               0x01
308 #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS   0x02
309 #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION              0x03
310 #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE        0x04
311 #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY           0x05
312 #define GB_I2S_MGMT_TYPE_SET_START_DELAY                0x06
313 #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT                 0x07
314 #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT               0x08
315 #define GB_I2S_MGMT_TYPE_REPORT_EVENT                   0x09
316
317 #define GB_I2S_MGMT_BYTE_ORDER_NA                       BIT(0)
318 #define GB_I2S_MGMT_BYTE_ORDER_BE                       BIT(1)
319 #define GB_I2S_MGMT_BYTE_ORDER_LE                       BIT(2)
320
321 #define GB_I2S_MGMT_SPATIAL_LOCATION_FL                 BIT(0)
322 #define GB_I2S_MGMT_SPATIAL_LOCATION_FR                 BIT(1)
323 #define GB_I2S_MGMT_SPATIAL_LOCATION_FC                 BIT(2)
324 #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE                BIT(3)
325 #define GB_I2S_MGMT_SPATIAL_LOCATION_BL                 BIT(4)
326 #define GB_I2S_MGMT_SPATIAL_LOCATION_BR                 BIT(5)
327 #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC                BIT(6)
328 #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC                BIT(7)
329 #define GB_I2S_MGMT_SPATIAL_LOCATION_C                  BIT(8) /* BC in USB */
330 #define GB_I2S_MGMT_SPATIAL_LOCATION_SL                 BIT(9)
331 #define GB_I2S_MGMT_SPATIAL_LOCATION_SR                 BIT(10)
332 #define GB_I2S_MGMT_SPATIAL_LOCATION_TC                 BIT(11)
333 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL                BIT(12)
334 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC                BIT(13)
335 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR                BIT(14)
336 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL                BIT(15)
337 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC                BIT(16)
338 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR                BIT(17)
339 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC               BIT(18)
340 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC               BIT(19)
341 #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE               BIT(20)
342 #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE               BIT(21)
343 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL                BIT(22)
344 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR                BIT(23)
345 #define GB_I2S_MGMT_SPATIAL_LOCATION_BC                 BIT(24)
346 #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC                BIT(25)
347 #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC                BIT(26)
348 #define GB_I2S_MGMT_SPATIAL_LOCATION_RD                 BIT(31)
349
350 #define GB_I2S_MGMT_PROTOCOL_PCM                        BIT(0)
351 #define GB_I2S_MGMT_PROTOCOL_I2S                        BIT(1)
352 #define GB_I2S_MGMT_PROTOCOL_LR_STEREO                  BIT(2)
353
354 #define GB_I2S_MGMT_ROLE_MASTER                         BIT(0)
355 #define GB_I2S_MGMT_ROLE_SLAVE                          BIT(1)
356
357 #define GB_I2S_MGMT_POLARITY_NORMAL                     BIT(0)
358 #define GB_I2S_MGMT_POLARITY_REVERSED                   BIT(1)
359
360 #define GB_I2S_MGMT_EDGE_RISING                         BIT(0)
361 #define GB_I2S_MGMT_EDGE_FALLING                        BIT(1)
362
363 #define GB_I2S_MGMT_EVENT_UNSPECIFIED                   0x1
364 #define GB_I2S_MGMT_EVENT_HALT                          0x2
365 #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR                0x3
366 #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR                0x4
367 #define GB_I2S_MGMT_EVENT_FAILURE                       0x5
368 #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE               0x6
369 #define GB_I2S_MGMT_EVENT_UNDERRUN                      0x7
370 #define GB_I2S_MGMT_EVENT_OVERRUN                       0x8
371 #define GB_I2S_MGMT_EVENT_CLOCKING                      0x9
372 #define GB_I2S_MGMT_EVENT_DATA_LEN                      0xa
373
374 struct gb_i2s_mgmt_configuration {
375         __le32  sample_frequency;
376         __u8    num_channels;
377         __u8    bytes_per_channel;
378         __u8    byte_order;
379         __u8    pad;
380         __le32  spatial_locations;
381         __le32  ll_protocol;
382         __u8    ll_mclk_role;
383         __u8    ll_bclk_role;
384         __u8    ll_wclk_role;
385         __u8    ll_wclk_polarity;
386         __u8    ll_wclk_change_edge;
387         __u8    ll_wclk_tx_edge;
388         __u8    ll_wclk_rx_edge;
389         __u8    ll_data_offset;
390 };
391
392 /* get supported configurations request has no payload */
393 struct gb_i2s_mgmt_get_supported_configurations_response {
394         __u8                                    config_count;
395         __u8                                    pad[3];
396         struct gb_i2s_mgmt_configuration        config[0];
397 };
398
399 struct gb_i2s_mgmt_set_configuration_request {
400         struct gb_i2s_mgmt_configuration        config;
401 };
402 /* set configuration response has no payload */
403
404 struct gb_i2s_mgmt_set_samples_per_message_request {
405         __le16  samples_per_message;
406 };
407 /* set samples per message response has no payload */
408
409 /* get processing request delay has no payload */
410 struct gb_i2s_mgmt_get_processing_delay_response {
411         __le32  microseconds;
412 };
413
414 struct gb_i2s_mgmt_set_start_delay_request {
415         __le32  microseconds;
416 };
417 /* set start delay response has no payload */
418
419 struct gb_i2s_mgmt_activate_cport_request {
420         __le16  cport;
421 };
422 /* activate cport response has no payload */
423
424 struct gb_i2s_mgmt_deactivate_cport_request {
425         __le16  cport;
426 };
427 /* deactivate cport response has no payload */
428
429 struct gb_i2s_mgmt_report_event_request {
430         __u8    event;
431 };
432 /* report event response has no payload */
433
434 #define GB_I2S_DATA_TYPE_PROTOCOL_VERSION               0x01
435 #define GB_I2S_DATA_TYPE_SEND_DATA                      0x02
436
437 struct gb_i2s_send_data_request {
438         __le32  sample_number;
439         __le32  size;
440         __u8    data[0];
441 };
442 /* send data has no response at all */
443
444
445 /* SPI */
446
447 /* Version of the Greybus spi protocol we support */
448 #define GB_SPI_VERSION_MAJOR            0x00
449 #define GB_SPI_VERSION_MINOR            0x01
450
451 /* Should match up with modes in linux/spi/spi.h */
452 #define GB_SPI_MODE_CPHA                0x01            /* clock phase */
453 #define GB_SPI_MODE_CPOL                0x02            /* clock polarity */
454 #define GB_SPI_MODE_MODE_0              (0|0)           /* (original MicroWire) */
455 #define GB_SPI_MODE_MODE_1              (0|GB_SPI_MODE_CPHA)
456 #define GB_SPI_MODE_MODE_2              (GB_SPI_MODE_CPOL|0)
457 #define GB_SPI_MODE_MODE_3              (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
458 #define GB_SPI_MODE_CS_HIGH             0x04            /* chipselect active high? */
459 #define GB_SPI_MODE_LSB_FIRST           0x08            /* per-word bits-on-wire */
460 #define GB_SPI_MODE_3WIRE               0x10            /* SI/SO signals shared */
461 #define GB_SPI_MODE_LOOP                0x20            /* loopback mode */
462 #define GB_SPI_MODE_NO_CS               0x40            /* 1 dev/bus, no chipselect */
463 #define GB_SPI_MODE_READY               0x80            /* slave pulls low to pause */
464
465 /* Should match up with flags in linux/spi/spi.h */
466 #define GB_SPI_FLAG_HALF_DUPLEX         BIT(0)          /* can't do full duplex */
467 #define GB_SPI_FLAG_NO_RX               BIT(1)          /* can't do buffer read */
468 #define GB_SPI_FLAG_NO_TX               BIT(2)          /* can't do buffer write */
469
470 /* Greybus spi operation types */
471 #define GB_SPI_TYPE_INVALID             0x00
472 #define GB_SPI_TYPE_PROTOCOL_VERSION    0x01
473 #define GB_SPI_TYPE_MODE                0x02
474 #define GB_SPI_TYPE_FLAGS               0x03
475 #define GB_SPI_TYPE_BITS_PER_WORD_MASK  0x04
476 #define GB_SPI_TYPE_NUM_CHIPSELECT      0x05
477 #define GB_SPI_TYPE_TRANSFER            0x06
478
479 /* mode request has no payload */
480 struct gb_spi_mode_response {
481         __le16  mode;
482 };
483
484 /* flags request has no payload */
485 struct gb_spi_flags_response {
486         __le16  flags;
487 };
488
489 /* bits-per-word request has no payload */
490 struct gb_spi_bpw_response {
491         __le32  bits_per_word_mask;
492 };
493
494 /* num-chipselects request has no payload */
495 struct gb_spi_chipselect_response {
496         __le16  num_chipselect;
497 };
498
499 /**
500  * struct gb_spi_transfer - a read/write buffer pair
501  * @speed_hz: Select a speed other than the device default for this transfer. If
502  *      0 the default (from @spi_device) is used.
503  * @len: size of rx and tx buffers (in bytes)
504  * @delay_usecs: microseconds to delay after this transfer before (optionally)
505  *      changing the chipselect status, then starting the next transfer or
506  *      completing this spi_message.
507  * @cs_change: affects chipselect after this transfer completes
508  * @bits_per_word: select a bits_per_word other than the device default for this
509  *      transfer. If 0 the default (from @spi_device) is used.
510  */
511 struct gb_spi_transfer {
512         __le32          speed_hz;
513         __le32          len;
514         __le16          delay_usecs;
515         __u8            cs_change;
516         __u8            bits_per_word;
517 };
518
519 struct gb_spi_transfer_request {
520         __u8                    chip_select;    /* of the spi device */
521         __u8                    mode;           /* of the spi device */
522         __le16                  count;
523         struct gb_spi_transfer  transfers[0];   /* trnasfer_count of these */
524 };
525
526 struct gb_spi_transfer_response {
527         __u8                    data[0];        /* inbound data */
528 };
529
530 /* Version of the Greybus SVC protocol we support */
531 #define GB_SVC_VERSION_MAJOR            0x00
532 #define GB_SVC_VERSION_MINOR            0x01
533
534 /* Greybus SVC request types */
535 #define GB_SVC_TYPE_INVALID             0x00
536 #define GB_SVC_TYPE_PROTOCOL_VERSION    0x01
537 #define GB_SVC_TYPE_INTF_DEVICE_ID      0x02
538 #define GB_SVC_TYPE_INTF_HOTPLUG        0x03
539 #define GB_SVC_TYPE_INTF_HOT_UNPLUG     0x04
540 #define GB_SVC_TYPE_INTF_RESET          0x05
541 #define GB_SVC_TYPE_CONN_CREATE         0x06
542 #define GB_SVC_TYPE_CONN_DESTROY        0x07
543
544 struct gb_svc_intf_device_id_request {
545         __u8    intf_id;
546         __u8    device_id;
547 };
548 /* device id response has no payload */
549
550 struct gb_svc_intf_hotplug_request {
551         __u8    intf_id;
552         struct {
553                 __le32  unipro_mfg_id;
554                 __le32  unipro_prod_id;
555                 __le32  ara_vend_id;
556                 __le32  ara_prod_id;
557         } data;
558 };
559 /* hotplug response has no payload */
560
561 struct gb_svc_intf_hot_unplug_request {
562         __u8    intf_id;
563 };
564 /* hot unplug response has no payload */
565
566 struct gb_svc_intf_reset_request {
567         __u8    intf_id;
568 };
569 /* interface reset response has no payload */
570
571 struct gb_svc_conn_create_request {
572         __u8    intf1_id;
573         __u16   cport1_id;
574         __u8    intf2_id;
575         __u16   cport2_id;
576 };
577 /* connection create response has no payload */
578
579 struct gb_svc_conn_destroy_request {
580         __u8    intf1_id;
581         __u16   cport1_id;
582         __u8    intf2_id;
583         __u16   cport2_id;
584 };
585 /* connection destroy response has no payload */
586
587 /* UART */
588
589 /* Version of the Greybus UART protocol we support */
590 #define GB_UART_VERSION_MAJOR           0x00
591 #define GB_UART_VERSION_MINOR           0x01
592
593 /* Greybus UART operation types */
594 #define GB_UART_TYPE_INVALID                    0x00
595 #define GB_UART_TYPE_PROTOCOL_VERSION           0x01
596 #define GB_UART_TYPE_SEND_DATA                  0x02
597 #define GB_UART_TYPE_RECEIVE_DATA               0x03    /* Unsolicited data */
598 #define GB_UART_TYPE_SET_LINE_CODING            0x04
599 #define GB_UART_TYPE_SET_CONTROL_LINE_STATE     0x05
600 #define GB_UART_TYPE_SEND_BREAK                 0x06
601 #define GB_UART_TYPE_SERIAL_STATE               0x07    /* Unsolicited data */
602
603 /* Represents data from AP -> Module */
604 struct gb_uart_send_data_request {
605         __le16  size;
606         __u8    data[0];
607 };
608
609 /* recv-data-request flags */
610 #define GB_UART_RECV_FLAG_FRAMING               0x01    /* Framing error */
611 #define GB_UART_RECV_FLAG_PARITY                0x02    /* Parity error */
612 #define GB_UART_RECV_FLAG_OVERRUN               0x04    /* Overrun error */
613 #define GB_UART_RECV_FLAG_BREAK                 0x08    /* Break */
614
615 /* Represents data from Module -> AP */
616 struct gb_uart_recv_data_request {
617         __le16  size;
618         __u8    flags;
619         __u8    data[0];
620 };
621
622 struct gb_uart_set_line_coding_request {
623         __le32  rate;
624         __u8    format;
625 #define GB_SERIAL_1_STOP_BITS                   0
626 #define GB_SERIAL_1_5_STOP_BITS                 1
627 #define GB_SERIAL_2_STOP_BITS                   2
628
629         __u8    parity;
630 #define GB_SERIAL_NO_PARITY                     0
631 #define GB_SERIAL_ODD_PARITY                    1
632 #define GB_SERIAL_EVEN_PARITY                   2
633 #define GB_SERIAL_MARK_PARITY                   3
634 #define GB_SERIAL_SPACE_PARITY                  4
635
636         __u8    data_bits;
637 };
638
639 /* output control lines */
640 #define GB_UART_CTRL_DTR                        0x01
641 #define GB_UART_CTRL_RTS                        0x02
642
643 struct gb_uart_set_control_line_state_request {
644         __u8    control;
645 };
646
647 struct gb_uart_set_break_request {
648         __u8    state;
649 };
650
651 /* input control lines and line errors */
652 #define GB_UART_CTRL_DCD                        0x01
653 #define GB_UART_CTRL_DSR                        0x02
654 #define GB_UART_CTRL_RI                         0x04
655
656 struct gb_uart_serial_state_request {
657         __u8    control;
658 };
659
660 /* Loopback */
661
662 /* Version of the Greybus loopback protocol we support */
663 #define GB_LOOPBACK_VERSION_MAJOR               0x00
664 #define GB_LOOPBACK_VERSION_MINOR               0x01
665
666 /* Greybus loopback request types */
667 #define GB_LOOPBACK_TYPE_INVALID                0x00
668 #define GB_LOOPBACK_TYPE_PROTOCOL_VERSION       0x01
669 #define GB_LOOPBACK_TYPE_PING                   0x02
670 #define GB_LOOPBACK_TYPE_TRANSFER               0x03
671 #define GB_LOOPBACK_TYPE_SINK                   0x04
672
673 struct gb_loopback_transfer_request {
674         __le32  len;
675         __u8    data[0];
676 };
677
678 struct gb_loopback_transfer_response {
679         __u8    data[0];
680 };
681
682 /* SDIO */
683 /* Version of the Greybus sdio protocol we support */
684 #define GB_SDIO_VERSION_MAJOR           0x00
685 #define GB_SDIO_VERSION_MINOR           0x01
686
687 /* Greybus SDIO operation types */
688 #define GB_SDIO_TYPE_INVALID                    0x00
689 #define GB_SDIO_TYPE_PROTOCOL_VERSION           0x01
690 #define GB_SDIO_TYPE_GET_CAPABILITIES           0x02
691 #define GB_SDIO_TYPE_SET_IOS                    0x03
692 #define GB_SDIO_TYPE_COMMAND                    0x04
693 #define GB_SDIO_TYPE_TRANSFER                   0x05
694 #define GB_SDIO_TYPE_EVENT                      0x06
695
696 /* get caps response: request has no payload */
697 struct gb_sdio_get_caps_response {
698         __le32  caps;
699 #define GB_SDIO_CAP_NONREMOVABLE        0x00000001
700 #define GB_SDIO_CAP_4_BIT_DATA          0x00000002
701 #define GB_SDIO_CAP_8_BIT_DATA          0x00000004
702 #define GB_SDIO_CAP_MMC_HS              0x00000008
703 #define GB_SDIO_CAP_SD_HS               0x00000010
704 #define GB_SDIO_CAP_ERASE               0x00000020
705 #define GB_SDIO_CAP_1_2V_DDR            0x00000040
706 #define GB_SDIO_CAP_1_8V_DDR            0x00000080
707 #define GB_SDIO_CAP_POWER_OFF_CARD      0x00000100
708 #define GB_SDIO_CAP_UHS_SDR12           0x00000200
709 #define GB_SDIO_CAP_UHS_SDR25           0x00000400
710 #define GB_SDIO_CAP_UHS_SDR50           0x00000800
711 #define GB_SDIO_CAP_UHS_SDR104          0x00001000
712 #define GB_SDIO_CAP_UHS_DDR50           0x00002000
713 #define GB_SDIO_CAP_DRIVER_TYPE_A       0x00004000
714 #define GB_SDIO_CAP_DRIVER_TYPE_C       0x00008000
715 #define GB_SDIO_CAP_DRIVER_TYPE_D       0x00010000
716 #define GB_SDIO_CAP_HS200_1_2V          0x00020000
717 #define GB_SDIO_CAP_HS200_1_8V          0x00040000
718 #define GB_SDIO_CAP_HS400_1_2V          0x00080000
719 #define GB_SDIO_CAP_HS400_1_8V          0x00100000
720
721         /* see possible values below at vdd */
722         __le32 ocr;
723         __le16 max_blk_count;
724         __le16 max_blk_size;
725 };
726
727 /* set ios request: response has no payload */
728 struct gb_sdio_set_ios_request {
729         __le32  clock;
730         __le32  vdd;
731 #define GB_SDIO_VDD_165_195     0x00000001
732 #define GB_SDIO_VDD_20_21       0x00000002
733 #define GB_SDIO_VDD_21_22       0x00000004
734 #define GB_SDIO_VDD_22_23       0x00000008
735 #define GB_SDIO_VDD_23_24       0x00000010
736 #define GB_SDIO_VDD_24_25       0x00000020
737 #define GB_SDIO_VDD_25_26       0x00000040
738 #define GB_SDIO_VDD_26_27       0x00000080
739 #define GB_SDIO_VDD_27_28       0x00000100
740 #define GB_SDIO_VDD_28_29       0x00000200
741 #define GB_SDIO_VDD_29_30       0x00000400
742 #define GB_SDIO_VDD_30_31       0x00000800
743 #define GB_SDIO_VDD_31_32       0x00001000
744 #define GB_SDIO_VDD_32_33       0x00002000
745 #define GB_SDIO_VDD_33_34       0x00004000
746 #define GB_SDIO_VDD_34_35       0x00008000
747 #define GB_SDIO_VDD_35_36       0x00010000
748
749         __u8    bus_mode;
750 #define GB_SDIO_BUSMODE_OPENDRAIN       0x00
751 #define GB_SDIO_BUSMODE_PUSHPULL        0x01
752
753         __u8    power_mode;
754 #define GB_SDIO_POWER_OFF       0x00
755 #define GB_SDIO_POWER_UP        0x01
756 #define GB_SDIO_POWER_ON        0x02
757 #define GB_SDIO_POWER_UNDEFINED 0x03
758
759         __u8    bus_width;
760 #define GB_SDIO_BUS_WIDTH_1     0x00
761 #define GB_SDIO_BUS_WIDTH_4     0x02
762 #define GB_SDIO_BUS_WIDTH_8     0x03
763
764         __u8    timing;
765 #define GB_SDIO_TIMING_LEGACY           0x00
766 #define GB_SDIO_TIMING_MMC_HS           0x01
767 #define GB_SDIO_TIMING_SD_HS            0x02
768 #define GB_SDIO_TIMING_UHS_SDR12        0x03
769 #define GB_SDIO_TIMING_UHS_SDR25        0x04
770 #define GB_SDIO_TIMING_UHS_SDR50        0x05
771 #define GB_SDIO_TIMING_UHS_SDR104       0x06
772 #define GB_SDIO_TIMING_UHS_DDR50        0x07
773 #define GB_SDIO_TIMING_MMC_DDR52        0x08
774 #define GB_SDIO_TIMING_MMC_HS200        0x09
775 #define GB_SDIO_TIMING_MMC_HS400        0x0A
776
777         __u8    signal_voltage;
778 #define GB_SDIO_SIGNAL_VOLTAGE_330      0x00
779 #define GB_SDIO_SIGNAL_VOLTAGE_180      0x01
780 #define GB_SDIO_SIGNAL_VOLTAGE_120      0x02
781
782         __u8    drv_type;
783 #define GB_SDIO_SET_DRIVER_TYPE_B       0x00
784 #define GB_SDIO_SET_DRIVER_TYPE_A       0x01
785 #define GB_SDIO_SET_DRIVER_TYPE_C       0x02
786 #define GB_SDIO_SET_DRIVER_TYPE_D       0x03
787 };
788
789 /* command request */
790 struct gb_sdio_command_request {
791         __u8    cmd;
792         __u8    cmd_flags;
793 #define GB_SDIO_RSP_NONE                0x00
794 #define GB_SDIO_RSP_PRESENT             0x01
795 #define GB_SDIO_RSP_136                 0x02
796 #define GB_SDIO_RSP_CRC                 0x04
797 #define GB_SDIO_RSP_BUSY                0x08
798 #define GB_SDIO_RSP_OPCODE              0x10
799
800         __u8    cmd_type;
801 #define GB_SDIO_CMD_AC          0x00
802 #define GB_SDIO_CMD_ADTC        0x01
803 #define GB_SDIO_CMD_BCR         0x02
804 #define GB_SDIO_CMD_BC          0x03
805
806         __le32  cmd_arg;
807 };
808
809 struct gb_sdio_command_response {
810         __le32  resp[4];
811 };
812
813 /* transfer request */
814 struct gb_sdio_transfer_request {
815         __u8    data_flags;
816 #define GB_SDIO_DATA_WRITE      0x01
817 #define GB_SDIO_DATA_READ       0x02
818 #define GB_SDIO_DATA_STREAM     0x04
819
820         __le16  data_blocks;
821         __le16  data_blksz;
822         __u8    data[0];
823 };
824
825 struct gb_sdio_transfer_response {
826         __le16  data_blocks;
827         __le16  data_blksz;
828         __u8    data[0];
829 };
830
831 /* event request: generated by module and is defined as unidirectional */
832 struct gb_sdio_event_request {
833         __u8    event;
834 #define GB_SDIO_CARD_INSERTED   0x01
835 #define GB_SDIO_CARD_REMOVED    0x02
836 #define GB_SDIO_WP              0x04
837 };
838
839 #endif /* __GREYBUS_PROTOCOLS_H */
840