blob: 6f8c15ea39003c4db73ca56d8c165845a9964cdc [file] [log] [blame]
John Stultz453bbea2015-04-09 16:01:31 -07001/*
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
Alex Elder012d7d42015-05-27 14:45:58 -050052#ifndef __GREYBUS_PROTOCOLS_H
53#define __GREYBUS_PROTOCOLS_H
John Stultz453bbea2015-04-09 16:01:31 -070054
Viresh Kumarcdee4f72015-06-22 16:42:26 +053055/* 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*/
75struct gb_control_get_manifest_size_response {
76 __le16 size;
77};
78
79/* Control protocol manifest get request has no payload */
80struct gb_control_get_manifest_response {
81 __u8 data[0];
82};
83
84/* Control protocol [dis]connected request */
85struct gb_control_connected_request {
86 __le16 cport_id;
87};
88
89struct gb_control_disconnected_request {
90 __le16 cport_id;
91};
92/* Control protocol [dis]connected response has no payload */
93
John Stultz453bbea2015-04-09 16:01:31 -070094/* I2C */
95
96/* Version of the Greybus i2c protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +020097#define GB_I2C_VERSION_MAJOR 0x00
98#define GB_I2C_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -070099
100/* Greybus i2c request types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200101#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
John Stultz453bbea2015-04-09 16:01:31 -0700107
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200108#define GB_I2C_RETRIES_DEFAULT 3
109#define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
John Stultz453bbea2015-04-09 16:01:31 -0700110
111/* functionality request has no payload */
112struct gb_i2c_functionality_response {
113 __le32 functionality;
114};
115
116struct gb_i2c_timeout_request {
117 __le16 msec;
118};
119/* timeout response has no payload */
120
121struct 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 */
136struct gb_i2c_transfer_op {
137 __le16 addr;
138 __le16 flags;
139 __le16 size;
140};
141
142struct gb_i2c_transfer_request {
143 __le16 op_count;
144 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
145};
146struct 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 */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200154#define GB_GPIO_VERSION_MAJOR 0x00
155#define GB_GPIO_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700156
157/* Greybus GPIO request types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200158#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
John Stultz453bbea2015-04-09 16:01:31 -0700169#define GB_GPIO_TYPE_IRQ_TYPE 0x0b
Johan Hovold47bf0b42015-05-27 12:45:07 +0200170#define GB_GPIO_TYPE_IRQ_MASK 0x0c
171#define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
172#define GB_GPIO_TYPE_IRQ_EVENT 0x0e
John Stultz453bbea2015-04-09 16:01:31 -0700173
Johan Hovold7ba864a2015-05-28 19:03:34 +0200174#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
John Stultz453bbea2015-04-09 16:01:31 -0700181/* line count request has no payload */
182struct gb_gpio_line_count_response {
183 __u8 count;
184};
185
186struct gb_gpio_activate_request {
187 __u8 which;
188};
189/* activate response has no payload */
190
191struct gb_gpio_deactivate_request {
192 __u8 which;
193};
194/* deactivate response has no payload */
195
196struct gb_gpio_get_direction_request {
197 __u8 which;
198};
199struct gb_gpio_get_direction_response {
200 __u8 direction;
201};
202
203struct gb_gpio_direction_in_request {
204 __u8 which;
205};
206/* direction in response has no payload */
207
208struct gb_gpio_direction_out_request {
209 __u8 which;
210 __u8 value;
211};
212/* direction out response has no payload */
213
214struct gb_gpio_get_value_request {
215 __u8 which;
216};
217struct gb_gpio_get_value_response {
218 __u8 value;
219};
220
221struct gb_gpio_set_value_request {
222 __u8 which;
223 __u8 value;
224};
225/* set value response has no payload */
226
227struct gb_gpio_set_debounce_request {
228 __u8 which;
229 __le16 usec __packed;
230};
231/* debounce response has no payload */
232
233struct gb_gpio_irq_type_request {
234 __u8 which;
235 __u8 type;
236};
237/* irq type response has no payload */
238
239struct gb_gpio_irq_mask_request {
240 __u8 which;
241};
242/* irq mask response has no payload */
243
244struct gb_gpio_irq_unmask_request {
245 __u8 which;
246};
247/* irq unmask response has no payload */
248
John Stultz453bbea2015-04-09 16:01:31 -0700249/* irq event requests originate on another module and are handled on the AP */
250struct gb_gpio_irq_event_request {
251 __u8 which;
252};
Johan Hovold1409c4d2015-05-26 15:29:25 +0200253/* irq event has no response */
John Stultz453bbea2015-04-09 16:01:31 -0700254
255
256/* PWM */
257
258/* Version of the Greybus PWM protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200259#define GB_PWM_VERSION_MAJOR 0x00
260#define GB_PWM_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700261
Alex Elder6d653372015-05-07 13:03:52 -0500262/* Greybus PWM operation types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200263#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
John Stultz453bbea2015-04-09 16:01:31 -0700272
273/* pwm count request has no payload */
274struct gb_pwm_count_response {
275 __u8 count;
276};
277
278struct gb_pwm_activate_request {
279 __u8 which;
280};
281
282struct gb_pwm_deactivate_request {
283 __u8 which;
284};
285
286struct gb_pwm_config_request {
287 __u8 which;
288 __le32 duty __packed;
289 __le32 period __packed;
290};
291
292struct gb_pwm_polarity_request {
293 __u8 which;
294 __u8 polarity;
295};
296
297struct gb_pwm_enable_request {
298 __u8 which;
299};
300
301struct gb_pwm_disable_request {
302 __u8 which;
303};
304
305/* I2S */
John Stultz453bbea2015-04-09 16:01:31 -0700306
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
374struct 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;
John Stultza4749bb2015-05-08 12:57:36 -0700382 __u8 ll_mclk_role;
John Stultz453bbea2015-04-09 16:01:31 -0700383 __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;
John Stultz453bbea2015-04-09 16:01:31 -0700390};
391
392/* get supported configurations request has no payload */
393struct 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
399struct gb_i2s_mgmt_set_configuration_request {
400 struct gb_i2s_mgmt_configuration config;
401};
402/* set configuration response has no payload */
403
404struct 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 */
410struct gb_i2s_mgmt_get_processing_delay_response {
411 __le32 microseconds;
412};
413
414struct gb_i2s_mgmt_set_start_delay_request {
415 __le32 microseconds;
416};
417/* set start delay response has no payload */
418
419struct gb_i2s_mgmt_activate_cport_request {
420 __le16 cport;
421};
422/* activate cport response has no payload */
423
424struct gb_i2s_mgmt_deactivate_cport_request {
425 __le16 cport;
426};
427/* deactivate cport response has no payload */
428
429struct 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
437struct 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
Viresh Kumar4890f312015-05-20 16:33:57 +0530444
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 */
480struct gb_spi_mode_response {
481 __le16 mode;
482};
483
484/* flags request has no payload */
485struct gb_spi_flags_response {
486 __le16 flags;
487};
488
489/* bits-per-word request has no payload */
490struct gb_spi_bpw_response {
491 __le32 bits_per_word_mask;
492};
493
494/* num-chipselects request has no payload */
495struct 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 */
511struct 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
519struct 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
526struct gb_spi_transfer_response {
527 __u8 data[0]; /* inbound data */
528};
529
Alex Elder30c6d9d2015-05-22 13:02:08 -0500530/* 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
544struct gb_svc_intf_device_id_request {
545 __u8 intf_id;
546 __u8 device_id;
547};
548/* device id response has no payload */
549
550struct 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
561struct gb_svc_intf_hot_unplug_request {
562 __u8 intf_id;
563};
564/* hot unplug response has no payload */
565
566struct gb_svc_intf_reset_request {
567 __u8 intf_id;
568};
569/* interface reset response has no payload */
570
571struct 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
579struct 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
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100587/* 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_SET_BREAK 0x06
601#define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
602
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100603/* Represents data from AP -> Module */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100604struct gb_uart_send_data_request {
605 __le16 size;
606 __u8 data[0];
607};
608
Bryan O'Donoghue802362d2015-06-29 18:09:13 +0100609/* 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
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100615/* Represents data from Module -> AP */
616struct gb_uart_recv_data_request {
617 __le16 size;
Bryan O'Donoghue802362d2015-06-29 18:09:13 +0100618 __u8 flags;
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100619 __u8 data[0];
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100620};
621
622struct gb_uart_set_line_coding_request {
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100623 __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;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100637};
638
639/* output control lines */
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100640#define GB_UART_CTRL_DTR 0x01
641#define GB_UART_CTRL_RTS 0x02
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100642
643struct gb_uart_set_control_line_state_request {
Bryan O'Donoghueba4b0992015-06-29 18:09:15 +0100644 __u8 control;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100645};
646
647struct gb_uart_set_break_request {
648 __u8 state;
649};
650
651/* input control lines and line errors */
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100652#define GB_UART_CTRL_DCD 0x01
653#define GB_UART_CTRL_DSR 0x02
Bryan O'Donoghue802362d2015-06-29 18:09:13 +0100654#define GB_UART_CTRL_RI 0x04
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100655
656struct gb_uart_serial_state_request {
Bryan O'Donoghueba4b0992015-06-29 18:09:15 +0100657 __u8 control;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100658};
659
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +0100660/* SDIO */
661/* Version of the Greybus sdio protocol we support */
662#define GB_SDIO_VERSION_MAJOR 0x00
663#define GB_SDIO_VERSION_MINOR 0x01
664
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +0100665/* Greybus SDIO operation types */
666#define GB_SDIO_TYPE_INVALID 0x00
667#define GB_SDIO_TYPE_PROTOCOL_VERSION 0x01
668#define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
669#define GB_SDIO_TYPE_SET_IOS 0x03
670#define GB_SDIO_TYPE_COMMAND 0x04
671#define GB_SDIO_TYPE_TRANSFER 0x05
672#define GB_SDIO_TYPE_EVENT 0x06
673
674/* get caps response: request has no payload */
675struct gb_sdio_get_caps_response {
676 __le32 caps;
677#define GB_SDIO_CAP_NONREMOVABLE 0x00000001
678#define GB_SDIO_CAP_4_BIT_DATA 0x00000002
679#define GB_SDIO_CAP_8_BIT_DATA 0x00000004
680#define GB_SDIO_CAP_MMC_HS 0x00000008
681#define GB_SDIO_CAP_SD_HS 0x00000010
682#define GB_SDIO_CAP_ERASE 0x00000020
683#define GB_SDIO_CAP_1_2V_DDR 0x00000040
684#define GB_SDIO_CAP_1_8V_DDR 0x00000080
685#define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
686#define GB_SDIO_CAP_UHS_SDR12 0x00000200
687#define GB_SDIO_CAP_UHS_SDR25 0x00000400
688#define GB_SDIO_CAP_UHS_SDR50 0x00000800
689#define GB_SDIO_CAP_UHS_SDR104 0x00001000
690#define GB_SDIO_CAP_UHS_DDR50 0x00002000
691#define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
692#define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
693#define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
694#define GB_SDIO_CAP_HS200_1_2V 0x00020000
695#define GB_SDIO_CAP_HS200_1_8V 0x00040000
696#define GB_SDIO_CAP_HS400_1_2V 0x00080000
697#define GB_SDIO_CAP_HS400_1_8V 0x00100000
698
699 /* see possible values below at vdd */
700 __le32 ocr;
701 __le16 max_blk_count;
702 __le16 max_blk_size;
703};
704
705/* set ios request: response has no payload */
706struct gb_sdio_set_ios_request {
707 __le32 clock;
708 __le32 vdd;
709#define GB_SDIO_VDD_165_195 0x00000001
710#define GB_SDIO_VDD_20_21 0x00000002
711#define GB_SDIO_VDD_21_22 0x00000004
712#define GB_SDIO_VDD_22_23 0x00000008
713#define GB_SDIO_VDD_23_24 0x00000010
714#define GB_SDIO_VDD_24_25 0x00000020
715#define GB_SDIO_VDD_25_26 0x00000040
716#define GB_SDIO_VDD_26_27 0x00000080
717#define GB_SDIO_VDD_27_28 0x00000100
718#define GB_SDIO_VDD_28_29 0x00000200
719#define GB_SDIO_VDD_29_30 0x00000400
720#define GB_SDIO_VDD_30_31 0x00000800
721#define GB_SDIO_VDD_31_32 0x00001000
722#define GB_SDIO_VDD_32_33 0x00002000
723#define GB_SDIO_VDD_33_34 0x00004000
724#define GB_SDIO_VDD_34_35 0x00008000
725#define GB_SDIO_VDD_35_36 0x00010000
726
727 __u8 bus_mode;
728#define GB_SDIO_BUSMODE_OPENDRAIN 0x00
729#define GB_SDIO_BUSMODE_PUSHPULL 0x01
730
731 __u8 power_mode;
732#define GB_SDIO_POWER_OFF 0x00
733#define GB_SDIO_POWER_UP 0x01
734#define GB_SDIO_POWER_ON 0x02
735#define GB_SDIO_POWER_UNDEFINED 0x03
736
737 __u8 bus_width;
738#define GB_SDIO_BUS_WIDTH_1 0x00
739#define GB_SDIO_BUS_WIDTH_4 0x02
740#define GB_SDIO_BUS_WIDTH_8 0x03
741
742 __u8 timing;
743#define GB_SDIO_TIMING_LEGACY 0x00
744#define GB_SDIO_TIMING_MMC_HS 0x01
745#define GB_SDIO_TIMING_SD_HS 0x02
746#define GB_SDIO_TIMING_UHS_SDR12 0x03
747#define GB_SDIO_TIMING_UHS_SDR25 0x04
748#define GB_SDIO_TIMING_UHS_SDR50 0x05
749#define GB_SDIO_TIMING_UHS_SDR104 0x06
750#define GB_SDIO_TIMING_UHS_DDR50 0x07
751#define GB_SDIO_TIMING_MMC_DDR52 0x08
752#define GB_SDIO_TIMING_MMC_HS200 0x09
753#define GB_SDIO_TIMING_MMC_HS400 0x0A
754
755 __u8 signal_voltage;
756#define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
757#define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
758#define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
759
760 __u8 drv_type;
761#define GB_SDIO_SET_DRIVER_TYPE_B 0x00
762#define GB_SDIO_SET_DRIVER_TYPE_A 0x01
763#define GB_SDIO_SET_DRIVER_TYPE_C 0x02
764#define GB_SDIO_SET_DRIVER_TYPE_D 0x03
765};
766
767/* command request */
768struct gb_sdio_command_request {
769 __u8 cmd;
770 __u8 cmd_flags;
771#define GB_SDIO_RSP_NONE 0x00
772#define GB_SDIO_RSP_R1_R5_R6_R7 0x01
773#define GB_SDIO_RSP_R1B 0x02
774#define GB_SDIO_RSP_R2 0x03
775#define GB_SDIO_RSP_R3_R4 0x04
776
777 __u8 cmd_type;
778#define GB_SDIO_CMD_AC 0x00
779#define GB_SDIO_CMD_ADTC 0x01
780#define GB_SDIO_CMD_BCR 0x02
781#define GB_SDIO_CMD_BC 0x03
782
783 __le32 cmd_arg;
784};
785
786struct gb_sdio_command_response {
787 __le32 resp[4];
788};
789
790/* transfer request */
791struct gb_sdio_transfer_request {
792 __u8 data_flags;
793#define GB_SDIO_DATA_WRITE 0x01
794#define GB_SDIO_DATA_READ 0x02
795#define GB_SDIO_DATA_STREAM 0x04
796
797 __le16 data_blocks;
798 __le16 data_blksz;
799 __u8 data[0];
800};
801
802struct gb_sdio_transfer_response {
803 __le16 data_blocks;
804 __le16 data_blksz;
805 __u8 data[0];
806};
807
808/* event request: generated by module and is defined as unidirectional */
809struct gb_sdio_event_request {
810 __u8 event;
811#define GB_SDIO_CARD_INSERTED 0x01
812#define GB_SDIO_CARD_REMOVED 0x02
813#define GB_SDIO_WP 0x04
814};
815
Alex Elder012d7d42015-05-27 14:45:58 -0500816#endif /* __GREYBUS_PROTOCOLS_H */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100817