John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 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 | |
Alex Elder | 012d7d4 | 2015-05-27 14:45:58 -0500 | [diff] [blame] | 52 | #ifndef __GREYBUS_PROTOCOLS_H |
| 53 | #define __GREYBUS_PROTOCOLS_H |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 54 | |
| 55 | /* I2C */ |
| 56 | |
| 57 | /* Version of the Greybus i2c protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 58 | #define GB_I2C_VERSION_MAJOR 0x00 |
| 59 | #define GB_I2C_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 60 | |
| 61 | /* Greybus i2c request types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 62 | #define GB_I2C_TYPE_INVALID 0x00 |
| 63 | #define GB_I2C_TYPE_PROTOCOL_VERSION 0x01 |
| 64 | #define GB_I2C_TYPE_FUNCTIONALITY 0x02 |
| 65 | #define GB_I2C_TYPE_TIMEOUT 0x03 |
| 66 | #define GB_I2C_TYPE_RETRIES 0x04 |
| 67 | #define GB_I2C_TYPE_TRANSFER 0x05 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 68 | |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 69 | #define GB_I2C_RETRIES_DEFAULT 3 |
| 70 | #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */ |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 71 | |
| 72 | /* functionality request has no payload */ |
| 73 | struct gb_i2c_functionality_response { |
| 74 | __le32 functionality; |
| 75 | }; |
| 76 | |
| 77 | struct gb_i2c_timeout_request { |
| 78 | __le16 msec; |
| 79 | }; |
| 80 | /* timeout response has no payload */ |
| 81 | |
| 82 | struct gb_i2c_retries_request { |
| 83 | __u8 retries; |
| 84 | }; |
| 85 | /* retries response has no payload */ |
| 86 | |
| 87 | /* |
| 88 | * Outgoing data immediately follows the op count and ops array. |
| 89 | * The data for each write (master -> slave) op in the array is sent |
| 90 | * in order, with no (e.g. pad) bytes separating them. |
| 91 | * |
| 92 | * Short reads cause the entire transfer request to fail So response |
| 93 | * payload consists only of bytes read, and the number of bytes is |
| 94 | * exactly what was specified in the corresponding op. Like |
| 95 | * outgoing data, the incoming data is in order and contiguous. |
| 96 | */ |
| 97 | struct gb_i2c_transfer_op { |
| 98 | __le16 addr; |
| 99 | __le16 flags; |
| 100 | __le16 size; |
| 101 | }; |
| 102 | |
| 103 | struct gb_i2c_transfer_request { |
| 104 | __le16 op_count; |
| 105 | struct gb_i2c_transfer_op ops[0]; /* op_count of these */ |
| 106 | }; |
| 107 | struct gb_i2c_transfer_response { |
| 108 | __u8 data[0]; /* inbound data */ |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | /* GPIO */ |
| 113 | |
| 114 | /* Version of the Greybus GPIO protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 115 | #define GB_GPIO_VERSION_MAJOR 0x00 |
| 116 | #define GB_GPIO_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 117 | |
| 118 | /* Greybus GPIO request types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 119 | #define GB_GPIO_TYPE_INVALID 0x00 |
| 120 | #define GB_GPIO_TYPE_PROTOCOL_VERSION 0x01 |
| 121 | #define GB_GPIO_TYPE_LINE_COUNT 0x02 |
| 122 | #define GB_GPIO_TYPE_ACTIVATE 0x03 |
| 123 | #define GB_GPIO_TYPE_DEACTIVATE 0x04 |
| 124 | #define GB_GPIO_TYPE_GET_DIRECTION 0x05 |
| 125 | #define GB_GPIO_TYPE_DIRECTION_IN 0x06 |
| 126 | #define GB_GPIO_TYPE_DIRECTION_OUT 0x07 |
| 127 | #define GB_GPIO_TYPE_GET_VALUE 0x08 |
| 128 | #define GB_GPIO_TYPE_SET_VALUE 0x09 |
| 129 | #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 130 | #define GB_GPIO_TYPE_IRQ_TYPE 0x0b |
Johan Hovold | 47bf0b4 | 2015-05-27 12:45:07 +0200 | [diff] [blame] | 131 | #define GB_GPIO_TYPE_IRQ_MASK 0x0c |
| 132 | #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d |
| 133 | #define GB_GPIO_TYPE_IRQ_EVENT 0x0e |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 134 | |
Johan Hovold | 7ba864a | 2015-05-28 19:03:34 +0200 | [diff] [blame] | 135 | #define GB_GPIO_IRQ_TYPE_NONE 0x00 |
| 136 | #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01 |
| 137 | #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02 |
| 138 | #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03 |
| 139 | #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04 |
| 140 | #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08 |
| 141 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 142 | /* line count request has no payload */ |
| 143 | struct gb_gpio_line_count_response { |
| 144 | __u8 count; |
| 145 | }; |
| 146 | |
| 147 | struct gb_gpio_activate_request { |
| 148 | __u8 which; |
| 149 | }; |
| 150 | /* activate response has no payload */ |
| 151 | |
| 152 | struct gb_gpio_deactivate_request { |
| 153 | __u8 which; |
| 154 | }; |
| 155 | /* deactivate response has no payload */ |
| 156 | |
| 157 | struct gb_gpio_get_direction_request { |
| 158 | __u8 which; |
| 159 | }; |
| 160 | struct gb_gpio_get_direction_response { |
| 161 | __u8 direction; |
| 162 | }; |
| 163 | |
| 164 | struct gb_gpio_direction_in_request { |
| 165 | __u8 which; |
| 166 | }; |
| 167 | /* direction in response has no payload */ |
| 168 | |
| 169 | struct gb_gpio_direction_out_request { |
| 170 | __u8 which; |
| 171 | __u8 value; |
| 172 | }; |
| 173 | /* direction out response has no payload */ |
| 174 | |
| 175 | struct gb_gpio_get_value_request { |
| 176 | __u8 which; |
| 177 | }; |
| 178 | struct gb_gpio_get_value_response { |
| 179 | __u8 value; |
| 180 | }; |
| 181 | |
| 182 | struct gb_gpio_set_value_request { |
| 183 | __u8 which; |
| 184 | __u8 value; |
| 185 | }; |
| 186 | /* set value response has no payload */ |
| 187 | |
| 188 | struct gb_gpio_set_debounce_request { |
| 189 | __u8 which; |
| 190 | __le16 usec __packed; |
| 191 | }; |
| 192 | /* debounce response has no payload */ |
| 193 | |
| 194 | struct gb_gpio_irq_type_request { |
| 195 | __u8 which; |
| 196 | __u8 type; |
| 197 | }; |
| 198 | /* irq type response has no payload */ |
| 199 | |
| 200 | struct gb_gpio_irq_mask_request { |
| 201 | __u8 which; |
| 202 | }; |
| 203 | /* irq mask response has no payload */ |
| 204 | |
| 205 | struct gb_gpio_irq_unmask_request { |
| 206 | __u8 which; |
| 207 | }; |
| 208 | /* irq unmask response has no payload */ |
| 209 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 210 | /* irq event requests originate on another module and are handled on the AP */ |
| 211 | struct gb_gpio_irq_event_request { |
| 212 | __u8 which; |
| 213 | }; |
Johan Hovold | 1409c4d | 2015-05-26 15:29:25 +0200 | [diff] [blame] | 214 | /* irq event has no response */ |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 215 | |
| 216 | |
| 217 | /* PWM */ |
| 218 | |
| 219 | /* Version of the Greybus PWM protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 220 | #define GB_PWM_VERSION_MAJOR 0x00 |
| 221 | #define GB_PWM_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 222 | |
Alex Elder | 6d65337 | 2015-05-07 13:03:52 -0500 | [diff] [blame] | 223 | /* Greybus PWM operation types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 224 | #define GB_PWM_TYPE_INVALID 0x00 |
| 225 | #define GB_PWM_TYPE_PROTOCOL_VERSION 0x01 |
| 226 | #define GB_PWM_TYPE_PWM_COUNT 0x02 |
| 227 | #define GB_PWM_TYPE_ACTIVATE 0x03 |
| 228 | #define GB_PWM_TYPE_DEACTIVATE 0x04 |
| 229 | #define GB_PWM_TYPE_CONFIG 0x05 |
| 230 | #define GB_PWM_TYPE_POLARITY 0x06 |
| 231 | #define GB_PWM_TYPE_ENABLE 0x07 |
| 232 | #define GB_PWM_TYPE_DISABLE 0x08 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 233 | |
| 234 | /* pwm count request has no payload */ |
| 235 | struct gb_pwm_count_response { |
| 236 | __u8 count; |
| 237 | }; |
| 238 | |
| 239 | struct gb_pwm_activate_request { |
| 240 | __u8 which; |
| 241 | }; |
| 242 | |
| 243 | struct gb_pwm_deactivate_request { |
| 244 | __u8 which; |
| 245 | }; |
| 246 | |
| 247 | struct gb_pwm_config_request { |
| 248 | __u8 which; |
| 249 | __le32 duty __packed; |
| 250 | __le32 period __packed; |
| 251 | }; |
| 252 | |
| 253 | struct gb_pwm_polarity_request { |
| 254 | __u8 which; |
| 255 | __u8 polarity; |
| 256 | }; |
| 257 | |
| 258 | struct gb_pwm_enable_request { |
| 259 | __u8 which; |
| 260 | }; |
| 261 | |
| 262 | struct gb_pwm_disable_request { |
| 263 | __u8 which; |
| 264 | }; |
| 265 | |
| 266 | /* I2S */ |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 267 | |
| 268 | #define GB_I2S_MGMT_TYPE_PROTOCOL_VERSION 0x01 |
| 269 | #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS 0x02 |
| 270 | #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION 0x03 |
| 271 | #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE 0x04 |
| 272 | #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY 0x05 |
| 273 | #define GB_I2S_MGMT_TYPE_SET_START_DELAY 0x06 |
| 274 | #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT 0x07 |
| 275 | #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08 |
| 276 | #define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09 |
| 277 | |
| 278 | #define GB_I2S_MGMT_BYTE_ORDER_NA BIT(0) |
| 279 | #define GB_I2S_MGMT_BYTE_ORDER_BE BIT(1) |
| 280 | #define GB_I2S_MGMT_BYTE_ORDER_LE BIT(2) |
| 281 | |
| 282 | #define GB_I2S_MGMT_SPATIAL_LOCATION_FL BIT(0) |
| 283 | #define GB_I2S_MGMT_SPATIAL_LOCATION_FR BIT(1) |
| 284 | #define GB_I2S_MGMT_SPATIAL_LOCATION_FC BIT(2) |
| 285 | #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE BIT(3) |
| 286 | #define GB_I2S_MGMT_SPATIAL_LOCATION_BL BIT(4) |
| 287 | #define GB_I2S_MGMT_SPATIAL_LOCATION_BR BIT(5) |
| 288 | #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC BIT(6) |
| 289 | #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC BIT(7) |
| 290 | #define GB_I2S_MGMT_SPATIAL_LOCATION_C BIT(8) /* BC in USB */ |
| 291 | #define GB_I2S_MGMT_SPATIAL_LOCATION_SL BIT(9) |
| 292 | #define GB_I2S_MGMT_SPATIAL_LOCATION_SR BIT(10) |
| 293 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TC BIT(11) |
| 294 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL BIT(12) |
| 295 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC BIT(13) |
| 296 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR BIT(14) |
| 297 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL BIT(15) |
| 298 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC BIT(16) |
| 299 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR BIT(17) |
| 300 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC BIT(18) |
| 301 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC BIT(19) |
| 302 | #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE BIT(20) |
| 303 | #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE BIT(21) |
| 304 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL BIT(22) |
| 305 | #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR BIT(23) |
| 306 | #define GB_I2S_MGMT_SPATIAL_LOCATION_BC BIT(24) |
| 307 | #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC BIT(25) |
| 308 | #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC BIT(26) |
| 309 | #define GB_I2S_MGMT_SPATIAL_LOCATION_RD BIT(31) |
| 310 | |
| 311 | #define GB_I2S_MGMT_PROTOCOL_PCM BIT(0) |
| 312 | #define GB_I2S_MGMT_PROTOCOL_I2S BIT(1) |
| 313 | #define GB_I2S_MGMT_PROTOCOL_LR_STEREO BIT(2) |
| 314 | |
| 315 | #define GB_I2S_MGMT_ROLE_MASTER BIT(0) |
| 316 | #define GB_I2S_MGMT_ROLE_SLAVE BIT(1) |
| 317 | |
| 318 | #define GB_I2S_MGMT_POLARITY_NORMAL BIT(0) |
| 319 | #define GB_I2S_MGMT_POLARITY_REVERSED BIT(1) |
| 320 | |
| 321 | #define GB_I2S_MGMT_EDGE_RISING BIT(0) |
| 322 | #define GB_I2S_MGMT_EDGE_FALLING BIT(1) |
| 323 | |
| 324 | #define GB_I2S_MGMT_EVENT_UNSPECIFIED 0x1 |
| 325 | #define GB_I2S_MGMT_EVENT_HALT 0x2 |
| 326 | #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR 0x3 |
| 327 | #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR 0x4 |
| 328 | #define GB_I2S_MGMT_EVENT_FAILURE 0x5 |
| 329 | #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE 0x6 |
| 330 | #define GB_I2S_MGMT_EVENT_UNDERRUN 0x7 |
| 331 | #define GB_I2S_MGMT_EVENT_OVERRUN 0x8 |
| 332 | #define GB_I2S_MGMT_EVENT_CLOCKING 0x9 |
| 333 | #define GB_I2S_MGMT_EVENT_DATA_LEN 0xa |
| 334 | |
| 335 | struct gb_i2s_mgmt_configuration { |
| 336 | __le32 sample_frequency; |
| 337 | __u8 num_channels; |
| 338 | __u8 bytes_per_channel; |
| 339 | __u8 byte_order; |
| 340 | __u8 pad; |
| 341 | __le32 spatial_locations; |
| 342 | __le32 ll_protocol; |
John Stultz | a4749bb | 2015-05-08 12:57:36 -0700 | [diff] [blame] | 343 | __u8 ll_mclk_role; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 344 | __u8 ll_bclk_role; |
| 345 | __u8 ll_wclk_role; |
| 346 | __u8 ll_wclk_polarity; |
| 347 | __u8 ll_wclk_change_edge; |
| 348 | __u8 ll_wclk_tx_edge; |
| 349 | __u8 ll_wclk_rx_edge; |
| 350 | __u8 ll_data_offset; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 351 | }; |
| 352 | |
| 353 | /* get supported configurations request has no payload */ |
| 354 | struct gb_i2s_mgmt_get_supported_configurations_response { |
| 355 | __u8 config_count; |
| 356 | __u8 pad[3]; |
| 357 | struct gb_i2s_mgmt_configuration config[0]; |
| 358 | }; |
| 359 | |
| 360 | struct gb_i2s_mgmt_set_configuration_request { |
| 361 | struct gb_i2s_mgmt_configuration config; |
| 362 | }; |
| 363 | /* set configuration response has no payload */ |
| 364 | |
| 365 | struct gb_i2s_mgmt_set_samples_per_message_request { |
| 366 | __le16 samples_per_message; |
| 367 | }; |
| 368 | /* set samples per message response has no payload */ |
| 369 | |
| 370 | /* get processing request delay has no payload */ |
| 371 | struct gb_i2s_mgmt_get_processing_delay_response { |
| 372 | __le32 microseconds; |
| 373 | }; |
| 374 | |
| 375 | struct gb_i2s_mgmt_set_start_delay_request { |
| 376 | __le32 microseconds; |
| 377 | }; |
| 378 | /* set start delay response has no payload */ |
| 379 | |
| 380 | struct gb_i2s_mgmt_activate_cport_request { |
| 381 | __le16 cport; |
| 382 | }; |
| 383 | /* activate cport response has no payload */ |
| 384 | |
| 385 | struct gb_i2s_mgmt_deactivate_cport_request { |
| 386 | __le16 cport; |
| 387 | }; |
| 388 | /* deactivate cport response has no payload */ |
| 389 | |
| 390 | struct gb_i2s_mgmt_report_event_request { |
| 391 | __u8 event; |
| 392 | }; |
| 393 | /* report event response has no payload */ |
| 394 | |
| 395 | #define GB_I2S_DATA_TYPE_PROTOCOL_VERSION 0x01 |
| 396 | #define GB_I2S_DATA_TYPE_SEND_DATA 0x02 |
| 397 | |
| 398 | struct gb_i2s_send_data_request { |
| 399 | __le32 sample_number; |
| 400 | __le32 size; |
| 401 | __u8 data[0]; |
| 402 | }; |
| 403 | /* send data has no response at all */ |
| 404 | |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 405 | |
| 406 | /* SPI */ |
| 407 | |
| 408 | /* Version of the Greybus spi protocol we support */ |
| 409 | #define GB_SPI_VERSION_MAJOR 0x00 |
| 410 | #define GB_SPI_VERSION_MINOR 0x01 |
| 411 | |
| 412 | /* Should match up with modes in linux/spi/spi.h */ |
| 413 | #define GB_SPI_MODE_CPHA 0x01 /* clock phase */ |
| 414 | #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */ |
| 415 | #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */ |
| 416 | #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA) |
| 417 | #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0) |
| 418 | #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA) |
| 419 | #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */ |
| 420 | #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */ |
| 421 | #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */ |
| 422 | #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */ |
| 423 | #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */ |
| 424 | #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */ |
| 425 | |
| 426 | /* Should match up with flags in linux/spi/spi.h */ |
| 427 | #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */ |
| 428 | #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */ |
| 429 | #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */ |
| 430 | |
| 431 | /* Greybus spi operation types */ |
| 432 | #define GB_SPI_TYPE_INVALID 0x00 |
| 433 | #define GB_SPI_TYPE_PROTOCOL_VERSION 0x01 |
| 434 | #define GB_SPI_TYPE_MODE 0x02 |
| 435 | #define GB_SPI_TYPE_FLAGS 0x03 |
| 436 | #define GB_SPI_TYPE_BITS_PER_WORD_MASK 0x04 |
| 437 | #define GB_SPI_TYPE_NUM_CHIPSELECT 0x05 |
| 438 | #define GB_SPI_TYPE_TRANSFER 0x06 |
| 439 | |
| 440 | /* mode request has no payload */ |
| 441 | struct gb_spi_mode_response { |
| 442 | __le16 mode; |
| 443 | }; |
| 444 | |
| 445 | /* flags request has no payload */ |
| 446 | struct gb_spi_flags_response { |
| 447 | __le16 flags; |
| 448 | }; |
| 449 | |
| 450 | /* bits-per-word request has no payload */ |
| 451 | struct gb_spi_bpw_response { |
| 452 | __le32 bits_per_word_mask; |
| 453 | }; |
| 454 | |
| 455 | /* num-chipselects request has no payload */ |
| 456 | struct gb_spi_chipselect_response { |
| 457 | __le16 num_chipselect; |
| 458 | }; |
| 459 | |
| 460 | /** |
| 461 | * struct gb_spi_transfer - a read/write buffer pair |
| 462 | * @speed_hz: Select a speed other than the device default for this transfer. If |
| 463 | * 0 the default (from @spi_device) is used. |
| 464 | * @len: size of rx and tx buffers (in bytes) |
| 465 | * @delay_usecs: microseconds to delay after this transfer before (optionally) |
| 466 | * changing the chipselect status, then starting the next transfer or |
| 467 | * completing this spi_message. |
| 468 | * @cs_change: affects chipselect after this transfer completes |
| 469 | * @bits_per_word: select a bits_per_word other than the device default for this |
| 470 | * transfer. If 0 the default (from @spi_device) is used. |
| 471 | */ |
| 472 | struct gb_spi_transfer { |
| 473 | __le32 speed_hz; |
| 474 | __le32 len; |
| 475 | __le16 delay_usecs; |
| 476 | __u8 cs_change; |
| 477 | __u8 bits_per_word; |
| 478 | }; |
| 479 | |
| 480 | struct gb_spi_transfer_request { |
| 481 | __u8 chip_select; /* of the spi device */ |
| 482 | __u8 mode; /* of the spi device */ |
| 483 | __le16 count; |
| 484 | struct gb_spi_transfer transfers[0]; /* trnasfer_count of these */ |
| 485 | }; |
| 486 | |
| 487 | struct gb_spi_transfer_response { |
| 488 | __u8 data[0]; /* inbound data */ |
| 489 | }; |
| 490 | |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 491 | /* Version of the Greybus SVC protocol we support */ |
| 492 | #define GB_SVC_VERSION_MAJOR 0x00 |
| 493 | #define GB_SVC_VERSION_MINOR 0x01 |
| 494 | |
| 495 | /* Greybus SVC request types */ |
| 496 | #define GB_SVC_TYPE_INVALID 0x00 |
| 497 | #define GB_SVC_TYPE_PROTOCOL_VERSION 0x01 |
| 498 | #define GB_SVC_TYPE_INTF_DEVICE_ID 0x02 |
| 499 | #define GB_SVC_TYPE_INTF_HOTPLUG 0x03 |
| 500 | #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x04 |
| 501 | #define GB_SVC_TYPE_INTF_RESET 0x05 |
| 502 | #define GB_SVC_TYPE_CONN_CREATE 0x06 |
| 503 | #define GB_SVC_TYPE_CONN_DESTROY 0x07 |
| 504 | |
| 505 | struct gb_svc_intf_device_id_request { |
| 506 | __u8 intf_id; |
| 507 | __u8 device_id; |
| 508 | }; |
| 509 | /* device id response has no payload */ |
| 510 | |
| 511 | struct gb_svc_intf_hotplug_request { |
| 512 | __u8 intf_id; |
| 513 | struct { |
| 514 | __le32 unipro_mfg_id; |
| 515 | __le32 unipro_prod_id; |
| 516 | __le32 ara_vend_id; |
| 517 | __le32 ara_prod_id; |
| 518 | } data; |
| 519 | }; |
| 520 | /* hotplug response has no payload */ |
| 521 | |
| 522 | struct gb_svc_intf_hot_unplug_request { |
| 523 | __u8 intf_id; |
| 524 | }; |
| 525 | /* hot unplug response has no payload */ |
| 526 | |
| 527 | struct gb_svc_intf_reset_request { |
| 528 | __u8 intf_id; |
| 529 | }; |
| 530 | /* interface reset response has no payload */ |
| 531 | |
| 532 | struct gb_svc_conn_create_request { |
| 533 | __u8 intf1_id; |
| 534 | __u16 cport1_id; |
| 535 | __u8 intf2_id; |
| 536 | __u16 cport2_id; |
| 537 | }; |
| 538 | /* connection create response has no payload */ |
| 539 | |
| 540 | struct gb_svc_conn_destroy_request { |
| 541 | __u8 intf1_id; |
| 542 | __u16 cport1_id; |
| 543 | __u8 intf2_id; |
| 544 | __u16 cport2_id; |
| 545 | }; |
| 546 | /* connection destroy response has no payload */ |
| 547 | |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame^] | 548 | /* UART */ |
| 549 | |
| 550 | /* Version of the Greybus UART protocol we support */ |
| 551 | #define GB_UART_VERSION_MAJOR 0x00 |
| 552 | #define GB_UART_VERSION_MINOR 0x01 |
| 553 | |
| 554 | /* Greybus UART operation types */ |
| 555 | #define GB_UART_TYPE_INVALID 0x00 |
| 556 | #define GB_UART_TYPE_PROTOCOL_VERSION 0x01 |
| 557 | #define GB_UART_TYPE_SEND_DATA 0x02 |
| 558 | #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */ |
| 559 | #define GB_UART_TYPE_SET_LINE_CODING 0x04 |
| 560 | #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05 |
| 561 | #define GB_UART_TYPE_SET_BREAK 0x06 |
| 562 | #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */ |
| 563 | |
| 564 | struct gb_uart_send_data_request { |
| 565 | __le16 size; |
| 566 | __u8 data[0]; |
| 567 | }; |
| 568 | |
| 569 | struct gb_serial_line_coding { |
| 570 | __le32 rate; |
| 571 | __u8 format; |
| 572 | #define GB_SERIAL_1_STOP_BITS 0 |
| 573 | #define GB_SERIAL_1_5_STOP_BITS 1 |
| 574 | #define GB_SERIAL_2_STOP_BITS 2 |
| 575 | |
| 576 | __u8 parity; |
| 577 | #define GB_SERIAL_NO_PARITY 0 |
| 578 | #define GB_SERIAL_ODD_PARITY 1 |
| 579 | #define GB_SERIAL_EVEN_PARITY 2 |
| 580 | #define GB_SERIAL_MARK_PARITY 3 |
| 581 | #define GB_SERIAL_SPACE_PARITY 4 |
| 582 | |
| 583 | __u8 data; |
| 584 | }; |
| 585 | |
| 586 | struct gb_uart_set_line_coding_request { |
| 587 | struct gb_serial_line_coding line_coding; |
| 588 | }; |
| 589 | |
| 590 | /* output control lines */ |
| 591 | #define GB_UART_CTRL_DTR 0x01 |
| 592 | #define GB_UART_CTRL_RTS 0x02 |
| 593 | |
| 594 | struct gb_uart_set_control_line_state_request { |
| 595 | __le16 control; |
| 596 | }; |
| 597 | |
| 598 | struct gb_uart_set_break_request { |
| 599 | __u8 state; |
| 600 | }; |
| 601 | |
| 602 | /* input control lines and line errors */ |
| 603 | #define GB_UART_CTRL_DCD 0x01 |
| 604 | #define GB_UART_CTRL_DSR 0x02 |
| 605 | #define GB_UART_CTRL_BRK 0x04 |
| 606 | #define GB_UART_CTRL_RI 0x08 |
| 607 | |
| 608 | #define GB_UART_CTRL_FRAMING 0x10 |
| 609 | #define GB_UART_CTRL_PARITY 0x20 |
| 610 | #define GB_UART_CTRL_OVERRUN 0x40 |
| 611 | |
| 612 | struct gb_uart_serial_state_request { |
| 613 | __u16 control; |
| 614 | }; |
| 615 | |
Alex Elder | 012d7d4 | 2015-05-27 14:45:58 -0500 | [diff] [blame] | 616 | #endif /* __GREYBUS_PROTOCOLS_H */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame^] | 617 | |