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 | |
Viresh Kumar | c8dd60d | 2015-07-21 17:44:12 +0530 | [diff] [blame] | 55 | /* Fixed IDs for control/svc protocols */ |
| 56 | |
| 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 |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 61 | |
Viresh Kumar | ec32062 | 2015-07-21 17:44:13 +0530 | [diff] [blame] | 62 | /* |
| 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. |
| 65 | */ |
| 66 | #define GB_SVC_BUNDLE_ID 0 |
Viresh Kumar | ef5d949 | 2015-07-24 15:32:24 +0530 | [diff] [blame] | 67 | #define GB_SVC_CPORT_ID 0 |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 68 | #define GB_CONTROL_BUNDLE_ID 0 |
Viresh Kumar | ef5d949 | 2015-07-24 15:32:24 +0530 | [diff] [blame] | 69 | #define GB_CONTROL_CPORT_ID 0 |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 70 | |
Viresh Kumar | 6366d73 | 2015-07-21 17:44:11 +0530 | [diff] [blame] | 71 | |
Viresh Kumar | e34fae5 | 2015-07-29 11:42:54 +0530 | [diff] [blame] | 72 | /* |
| 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). |
| 81 | * |
| 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. |
| 88 | * |
| 89 | * The wire format for all numeric fields in the header is little |
| 90 | * endian. Any operation-specific data begins immediately after the |
| 91 | * header. |
| 92 | */ |
| 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) */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 99 | } __packed; |
Viresh Kumar | ec32062 | 2015-07-21 17:44:13 +0530 | [diff] [blame] | 100 | |
| 101 | |
Viresh Kumar | 2b11a45 | 2015-08-11 07:35:57 +0530 | [diff] [blame] | 102 | /* Generic request numbers supported by all modules */ |
| 103 | #define GB_REQUEST_TYPE_INVALID 0x00 |
| 104 | #define GB_REQUEST_TYPE_PROTOCOL_VERSION 0x01 |
| 105 | |
Johan Hovold | cfb1690 | 2015-09-15 10:48:01 +0200 | [diff] [blame] | 106 | struct gb_protocol_version_request { |
| 107 | __u8 major; |
| 108 | __u8 minor; |
| 109 | } __packed; |
Viresh Kumar | e34fae5 | 2015-07-29 11:42:54 +0530 | [diff] [blame] | 110 | |
Viresh Kumar | 6366d73 | 2015-07-21 17:44:11 +0530 | [diff] [blame] | 111 | struct gb_protocol_version_response { |
| 112 | __u8 major; |
| 113 | __u8 minor; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 114 | } __packed; |
Viresh Kumar | 6366d73 | 2015-07-21 17:44:11 +0530 | [diff] [blame] | 115 | |
| 116 | /* Control Protocol */ |
| 117 | |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 118 | /* Greybus control request types */ |
Johan Hovold | e217ae7 | 2016-01-19 12:51:14 +0100 | [diff] [blame] | 119 | #define GB_CONTROL_TYPE_VERSION 0x01 |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 120 | #define GB_CONTROL_TYPE_PROBE_AP 0x02 |
| 121 | #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03 |
| 122 | #define GB_CONTROL_TYPE_GET_MANIFEST 0x04 |
| 123 | #define GB_CONTROL_TYPE_CONNECTED 0x05 |
| 124 | #define GB_CONTROL_TYPE_DISCONNECTED 0x06 |
Bryan O'Donoghue | 0bd39ca | 2016-03-02 16:51:09 +0000 | [diff] [blame] | 125 | #define GB_CONTROL_TYPE_TIMESYNC_ENABLE 0x07 |
| 126 | #define GB_CONTROL_TYPE_TIMESYNC_DISABLE 0x08 |
| 127 | #define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE 0x09 |
Viresh Kumar | d39bf70 | 2015-12-28 11:59:01 +0530 | [diff] [blame] | 128 | #define GB_CONTROL_TYPE_INTERFACE_VERSION 0x0a |
Johan Hovold | b807aa7 | 2016-01-19 12:51:21 +0100 | [diff] [blame] | 129 | #define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 130 | |
Johan Hovold | e217ae7 | 2016-01-19 12:51:14 +0100 | [diff] [blame] | 131 | struct gb_control_version_request { |
| 132 | __u8 major; |
| 133 | __u8 minor; |
| 134 | } __packed; |
| 135 | |
| 136 | struct gb_control_version_response { |
| 137 | __u8 major; |
| 138 | __u8 minor; |
| 139 | } __packed; |
| 140 | |
Johan Hovold | b807aa7 | 2016-01-19 12:51:21 +0100 | [diff] [blame] | 141 | struct gb_control_bundle_version_request { |
| 142 | __u8 bundle_id; |
| 143 | } __packed; |
| 144 | |
| 145 | struct gb_control_bundle_version_response { |
| 146 | __u8 major; |
| 147 | __u8 minor; |
| 148 | } __packed; |
| 149 | |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 150 | /* Control protocol manifest get size request has no payload*/ |
| 151 | struct gb_control_get_manifest_size_response { |
| 152 | __le16 size; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 153 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 154 | |
| 155 | /* Control protocol manifest get request has no payload */ |
| 156 | struct gb_control_get_manifest_response { |
| 157 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 158 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 159 | |
| 160 | /* Control protocol [dis]connected request */ |
| 161 | struct gb_control_connected_request { |
| 162 | __le16 cport_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 163 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 164 | |
| 165 | struct gb_control_disconnected_request { |
| 166 | __le16 cport_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 167 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 168 | /* Control protocol [dis]connected response has no payload */ |
| 169 | |
Viresh Kumar | d39bf70 | 2015-12-28 11:59:01 +0530 | [diff] [blame] | 170 | /* Control protocol interface version request has no payload */ |
| 171 | struct gb_control_interface_version_response { |
| 172 | __le16 major; |
| 173 | __le16 minor; |
| 174 | } __packed; |
| 175 | |
Bryan O'Donoghue | 177d4a4 | 2016-03-02 16:51:08 +0000 | [diff] [blame] | 176 | #define GB_TIMESYNC_MAX_STROBES 0x04 |
| 177 | |
| 178 | struct gb_control_timesync_enable_request { |
| 179 | __u8 count; |
Greg Kroah-Hartman | 9fa3a9b | 2016-03-04 18:40:02 -0800 | [diff] [blame] | 180 | __le64 frame_time; |
| 181 | __le32 strobe_delay; |
| 182 | __le32 refclk; |
Bryan O'Donoghue | 177d4a4 | 2016-03-02 16:51:08 +0000 | [diff] [blame] | 183 | } __packed; |
| 184 | /* timesync enable response has no payload */ |
| 185 | |
| 186 | struct gb_control_timesync_authoritative_request { |
| 187 | __u64 frame_time[GB_TIMESYNC_MAX_STROBES]; |
| 188 | } __packed; |
| 189 | /* timesync authoritative response has no payload */ |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 190 | |
Greg Kroah-Hartman | e527338 | 2015-12-31 11:14:33 -0800 | [diff] [blame] | 191 | /* APBridge protocol */ |
| 192 | |
| 193 | /* request APB1 log */ |
| 194 | #define GB_APB_REQUEST_LOG 0x02 |
| 195 | |
| 196 | /* request to map a cport to bulk in and bulk out endpoints */ |
| 197 | #define GB_APB_REQUEST_EP_MAPPING 0x03 |
| 198 | |
| 199 | /* request to get the number of cports available */ |
| 200 | #define GB_APB_REQUEST_CPORT_COUNT 0x04 |
| 201 | |
| 202 | /* request to reset a cport state */ |
| 203 | #define GB_APB_REQUEST_RESET_CPORT 0x05 |
| 204 | |
| 205 | /* request to time the latency of messages on a given cport */ |
| 206 | #define GB_APB_REQUEST_LATENCY_TAG_EN 0x06 |
| 207 | #define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07 |
| 208 | |
| 209 | /* request to control the CSI transmitter */ |
| 210 | #define GB_APB_REQUEST_CSI_TX_CONTROL 0x08 |
| 211 | |
Mark Greer | 4dbf505 | 2016-01-13 14:07:47 -0700 | [diff] [blame] | 212 | /* request to control the CSI transmitter */ |
| 213 | #define GB_APB_REQUEST_AUDIO_CONTROL 0x09 |
| 214 | |
Johan Hovold | aa2a545 | 2016-03-03 13:34:40 +0100 | [diff] [blame] | 215 | /* vendor requests to enable/disable CPort features */ |
| 216 | #define GB_APB_REQUEST_CPORT_FEAT_EN 0x0b |
| 217 | #define GB_APB_REQUEST_CPORT_FEAT_DIS 0x0c |
Greg Kroah-Hartman | e527338 | 2015-12-31 11:14:33 -0800 | [diff] [blame] | 218 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 219 | /* Firmware Protocol */ |
| 220 | |
| 221 | /* Version of the Greybus firmware protocol we support */ |
| 222 | #define GB_FIRMWARE_VERSION_MAJOR 0x00 |
| 223 | #define GB_FIRMWARE_VERSION_MINOR 0x01 |
| 224 | |
| 225 | /* Greybus firmware request types */ |
Johan Hovold | 8ec589b | 2016-01-29 15:42:31 +0100 | [diff] [blame] | 226 | #define GB_FIRMWARE_TYPE_VERSION 0x01 |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 227 | #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02 |
| 228 | #define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03 |
| 229 | #define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04 |
Viresh Kumar | 4c9e228 | 2015-09-09 21:08:33 +0530 | [diff] [blame] | 230 | #define GB_FIRMWARE_TYPE_AP_READY 0x05 /* Request with no-payload */ |
Viresh Kumar | f1e941a | 2015-11-26 15:33:46 +0530 | [diff] [blame] | 231 | #define GB_FIRMWARE_TYPE_GET_VID_PID 0x06 /* Request with no-payload */ |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 232 | |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 233 | /* FIXME: remove all ES2-specific identifiers from the kernel */ |
| 234 | #define ES2_DDBL1_MFR_ID 0x00000126 |
| 235 | #define ES2_DDBL1_PROD_ID 0x00001000 |
| 236 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 237 | /* Greybus firmware boot stages */ |
| 238 | #define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */ |
| 239 | #define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */ |
| 240 | #define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */ |
| 241 | |
| 242 | /* Greybus firmware ready to boot status */ |
| 243 | #define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */ |
| 244 | #define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */ |
| 245 | #define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */ |
| 246 | |
| 247 | /* Max firmware data fetch size in bytes */ |
| 248 | #define GB_FIRMWARE_FETCH_MAX 2000 |
| 249 | |
Johan Hovold | 8ec589b | 2016-01-29 15:42:31 +0100 | [diff] [blame] | 250 | struct gb_firmware_version_request { |
| 251 | __u8 major; |
| 252 | __u8 minor; |
| 253 | } __packed; |
| 254 | |
| 255 | struct gb_firmware_version_response { |
| 256 | __u8 major; |
| 257 | __u8 minor; |
| 258 | } __packed; |
| 259 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 260 | /* Firmware protocol firmware size request/response */ |
| 261 | struct gb_firmware_size_request { |
| 262 | __u8 stage; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 263 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 264 | |
| 265 | struct gb_firmware_size_response { |
| 266 | __le32 size; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 267 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 268 | |
| 269 | /* Firmware protocol get firmware request/response */ |
| 270 | struct gb_firmware_get_firmware_request { |
| 271 | __le32 offset; |
| 272 | __le32 size; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 273 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 274 | |
| 275 | struct gb_firmware_get_firmware_response { |
| 276 | __u8 data[0]; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 277 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 278 | |
| 279 | /* Firmware protocol Ready to boot request */ |
| 280 | struct gb_firmware_ready_to_boot_request { |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 281 | __u8 status; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 282 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 283 | /* Firmware protocol Ready to boot response has no payload */ |
| 284 | |
Viresh Kumar | f1e941a | 2015-11-26 15:33:46 +0530 | [diff] [blame] | 285 | /* Firmware protocol get VID/PID request has no payload */ |
| 286 | struct gb_firmware_get_vid_pid_response { |
| 287 | __le32 vendor_id; |
| 288 | __le32 product_id; |
| 289 | } __packed; |
| 290 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 291 | |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 292 | /* Power Supply */ |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 293 | |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 294 | /* Version of the Greybus power supply protocol we support */ |
| 295 | #define GB_POWER_SUPPLY_VERSION_MAJOR 0x00 |
| 296 | #define GB_POWER_SUPPLY_VERSION_MINOR 0x01 |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 297 | |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 298 | /* Greybus power supply request types */ |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 299 | #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02 |
| 300 | #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03 |
| 301 | #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04 |
| 302 | #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05 |
| 303 | #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06 |
| 304 | #define GB_POWER_SUPPLY_TYPE_EVENT 0x07 |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 305 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 306 | /* Should match up with battery technologies in linux/power_supply.h */ |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 307 | #define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000 |
| 308 | #define GB_POWER_SUPPLY_TECH_NiMH 0x0001 |
| 309 | #define GB_POWER_SUPPLY_TECH_LION 0x0002 |
| 310 | #define GB_POWER_SUPPLY_TECH_LIPO 0x0003 |
| 311 | #define GB_POWER_SUPPLY_TECH_LiFe 0x0004 |
| 312 | #define GB_POWER_SUPPLY_TECH_NiCd 0x0005 |
| 313 | #define GB_POWER_SUPPLY_TECH_LiMn 0x0006 |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 314 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 315 | /* Should match up with power supply types in linux/power_supply.h */ |
| 316 | #define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000 |
| 317 | #define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001 |
| 318 | #define GB_POWER_SUPPLY_UPS_TYPE 0x0002 |
| 319 | #define GB_POWER_SUPPLY_MAINS_TYPE 0x0003 |
| 320 | #define GB_POWER_SUPPLY_USB_TYPE 0x0004 |
| 321 | #define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005 |
| 322 | #define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006 |
| 323 | #define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007 |
| 324 | |
| 325 | /* Should match up with power supply health in linux/power_supply.h */ |
| 326 | #define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000 |
| 327 | #define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001 |
| 328 | #define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002 |
| 329 | #define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003 |
| 330 | #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004 |
| 331 | #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005 |
| 332 | #define GB_POWER_SUPPLY_HEALTH_COLD 0x0006 |
| 333 | #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007 |
| 334 | #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008 |
| 335 | |
| 336 | /* Should match up with battery status in linux/power_supply.h */ |
| 337 | #define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000 |
| 338 | #define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001 |
| 339 | #define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002 |
| 340 | #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003 |
| 341 | #define GB_POWER_SUPPLY_STATUS_FULL 0x0004 |
| 342 | |
| 343 | struct gb_power_supply_get_supplies_response { |
| 344 | __u8 supplies_count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 345 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 346 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 347 | struct gb_power_supply_get_description_request { |
| 348 | __u8 psy_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 349 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 350 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 351 | struct gb_power_supply_get_description_response { |
| 352 | __u8 manufacturer[32]; |
| 353 | __u8 model[32]; |
| 354 | __u8 serial_number[32]; |
| 355 | __le16 type; |
| 356 | __u8 properties_count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 357 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 358 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 359 | struct gb_power_supply_props_desc { |
| 360 | __u8 property; |
| 361 | #define GB_POWER_SUPPLY_PROP_STATUS 0x00 |
| 362 | #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01 |
| 363 | #define GB_POWER_SUPPLY_PROP_HEALTH 0x02 |
| 364 | #define GB_POWER_SUPPLY_PROP_PRESENT 0x03 |
| 365 | #define GB_POWER_SUPPLY_PROP_ONLINE 0x04 |
| 366 | #define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05 |
| 367 | #define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06 |
| 368 | #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07 |
| 369 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08 |
| 370 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09 |
| 371 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A |
| 372 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B |
| 373 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C |
| 374 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D |
| 375 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E |
| 376 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F |
| 377 | #define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10 |
| 378 | #define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11 |
| 379 | #define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12 |
| 380 | #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13 |
| 381 | #define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14 |
| 382 | #define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15 |
| 383 | #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16 |
| 384 | #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17 |
| 385 | #define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18 |
| 386 | #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19 |
| 387 | #define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A |
| 388 | #define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B |
| 389 | #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C |
| 390 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D |
| 391 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E |
| 392 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F |
| 393 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20 |
| 394 | #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21 |
| 395 | #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22 |
| 396 | #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23 |
| 397 | #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24 |
| 398 | #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25 |
| 399 | #define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26 |
| 400 | #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27 |
| 401 | #define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28 |
| 402 | #define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29 |
| 403 | #define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A |
| 404 | #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B |
| 405 | #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C |
| 406 | #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D |
| 407 | #define GB_POWER_SUPPLY_PROP_TEMP 0x2E |
| 408 | #define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F |
| 409 | #define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30 |
| 410 | #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31 |
| 411 | #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32 |
| 412 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33 |
| 413 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34 |
| 414 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35 |
| 415 | #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36 |
| 416 | #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37 |
| 417 | #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38 |
| 418 | #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39 |
| 419 | #define GB_POWER_SUPPLY_PROP_TYPE 0x3A |
| 420 | #define GB_POWER_SUPPLY_PROP_SCOPE 0x3B |
| 421 | #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C |
| 422 | #define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D |
| 423 | __u8 is_writeable; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 424 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 425 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 426 | struct gb_power_supply_get_property_descriptors_request { |
| 427 | __u8 psy_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 428 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 429 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 430 | struct gb_power_supply_get_property_descriptors_response { |
| 431 | __u8 properties_count; |
| 432 | struct gb_power_supply_props_desc props[]; |
| 433 | } __packed; |
| 434 | |
| 435 | struct gb_power_supply_get_property_request { |
| 436 | __u8 psy_id; |
| 437 | __u8 property; |
| 438 | } __packed; |
| 439 | |
| 440 | struct gb_power_supply_get_property_response { |
| 441 | __le32 prop_val; |
| 442 | }; |
| 443 | |
| 444 | struct gb_power_supply_set_property_request { |
| 445 | __u8 psy_id; |
| 446 | __u8 property; |
| 447 | __le32 prop_val; |
| 448 | } __packed; |
| 449 | |
| 450 | struct gb_power_supply_event_request { |
| 451 | __u8 psy_id; |
| 452 | __u8 event; |
| 453 | #define GB_POWER_SUPPLY_UPDATE 0x01 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 454 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 455 | |
| 456 | |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 457 | /* HID */ |
| 458 | |
| 459 | /* Version of the Greybus hid protocol we support */ |
| 460 | #define GB_HID_VERSION_MAJOR 0x00 |
| 461 | #define GB_HID_VERSION_MINOR 0x01 |
| 462 | |
| 463 | /* Greybus HID operation types */ |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 464 | #define GB_HID_TYPE_GET_DESC 0x02 |
| 465 | #define GB_HID_TYPE_GET_REPORT_DESC 0x03 |
| 466 | #define GB_HID_TYPE_PWR_ON 0x04 |
| 467 | #define GB_HID_TYPE_PWR_OFF 0x05 |
| 468 | #define GB_HID_TYPE_GET_REPORT 0x06 |
| 469 | #define GB_HID_TYPE_SET_REPORT 0x07 |
| 470 | #define GB_HID_TYPE_IRQ_EVENT 0x08 |
| 471 | |
| 472 | /* Report type */ |
| 473 | #define GB_HID_INPUT_REPORT 0 |
| 474 | #define GB_HID_OUTPUT_REPORT 1 |
| 475 | #define GB_HID_FEATURE_REPORT 2 |
| 476 | |
| 477 | /* Different request/response structures */ |
| 478 | /* HID get descriptor response */ |
| 479 | struct gb_hid_desc_response { |
| 480 | __u8 bLength; |
| 481 | __le16 wReportDescLength; |
| 482 | __le16 bcdHID; |
| 483 | __le16 wProductID; |
| 484 | __le16 wVendorID; |
| 485 | __u8 bCountryCode; |
| 486 | } __packed; |
| 487 | |
| 488 | /* HID get report request/response */ |
| 489 | struct gb_hid_get_report_request { |
| 490 | __u8 report_type; |
| 491 | __u8 report_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 492 | } __packed; |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 493 | |
| 494 | /* HID set report request */ |
| 495 | struct gb_hid_set_report_request { |
| 496 | __u8 report_type; |
| 497 | __u8 report_id; |
| 498 | __u8 report[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 499 | } __packed; |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 500 | |
| 501 | /* HID input report request, via interrupt pipe */ |
| 502 | struct gb_hid_input_report_request { |
| 503 | __u8 report[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 504 | } __packed; |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 505 | |
| 506 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 507 | /* I2C */ |
| 508 | |
| 509 | /* Version of the Greybus i2c protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 510 | #define GB_I2C_VERSION_MAJOR 0x00 |
| 511 | #define GB_I2C_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 512 | |
| 513 | /* Greybus i2c request types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 514 | #define GB_I2C_TYPE_FUNCTIONALITY 0x02 |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 515 | #define GB_I2C_TYPE_TRANSFER 0x05 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 516 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 517 | /* functionality request has no payload */ |
| 518 | struct gb_i2c_functionality_response { |
| 519 | __le32 functionality; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 520 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 521 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 522 | /* |
| 523 | * Outgoing data immediately follows the op count and ops array. |
| 524 | * The data for each write (master -> slave) op in the array is sent |
| 525 | * in order, with no (e.g. pad) bytes separating them. |
| 526 | * |
| 527 | * Short reads cause the entire transfer request to fail So response |
| 528 | * payload consists only of bytes read, and the number of bytes is |
| 529 | * exactly what was specified in the corresponding op. Like |
| 530 | * outgoing data, the incoming data is in order and contiguous. |
| 531 | */ |
| 532 | struct gb_i2c_transfer_op { |
| 533 | __le16 addr; |
| 534 | __le16 flags; |
| 535 | __le16 size; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 536 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 537 | |
| 538 | struct gb_i2c_transfer_request { |
| 539 | __le16 op_count; |
| 540 | struct gb_i2c_transfer_op ops[0]; /* op_count of these */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 541 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 542 | struct gb_i2c_transfer_response { |
| 543 | __u8 data[0]; /* inbound data */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 544 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 545 | |
| 546 | |
| 547 | /* GPIO */ |
| 548 | |
| 549 | /* Version of the Greybus GPIO protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 550 | #define GB_GPIO_VERSION_MAJOR 0x00 |
| 551 | #define GB_GPIO_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 552 | |
| 553 | /* Greybus GPIO request types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 554 | #define GB_GPIO_TYPE_LINE_COUNT 0x02 |
| 555 | #define GB_GPIO_TYPE_ACTIVATE 0x03 |
| 556 | #define GB_GPIO_TYPE_DEACTIVATE 0x04 |
| 557 | #define GB_GPIO_TYPE_GET_DIRECTION 0x05 |
| 558 | #define GB_GPIO_TYPE_DIRECTION_IN 0x06 |
| 559 | #define GB_GPIO_TYPE_DIRECTION_OUT 0x07 |
| 560 | #define GB_GPIO_TYPE_GET_VALUE 0x08 |
| 561 | #define GB_GPIO_TYPE_SET_VALUE 0x09 |
| 562 | #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 563 | #define GB_GPIO_TYPE_IRQ_TYPE 0x0b |
Johan Hovold | 47bf0b4 | 2015-05-27 12:45:07 +0200 | [diff] [blame] | 564 | #define GB_GPIO_TYPE_IRQ_MASK 0x0c |
| 565 | #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d |
| 566 | #define GB_GPIO_TYPE_IRQ_EVENT 0x0e |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 567 | |
Johan Hovold | 7ba864a | 2015-05-28 19:03:34 +0200 | [diff] [blame] | 568 | #define GB_GPIO_IRQ_TYPE_NONE 0x00 |
| 569 | #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01 |
| 570 | #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02 |
| 571 | #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03 |
| 572 | #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04 |
| 573 | #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08 |
| 574 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 575 | /* line count request has no payload */ |
| 576 | struct gb_gpio_line_count_response { |
| 577 | __u8 count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 578 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 579 | |
| 580 | struct gb_gpio_activate_request { |
| 581 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 582 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 583 | /* activate response has no payload */ |
| 584 | |
| 585 | struct gb_gpio_deactivate_request { |
| 586 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 587 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 588 | /* deactivate response has no payload */ |
| 589 | |
| 590 | struct gb_gpio_get_direction_request { |
| 591 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 592 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 593 | struct gb_gpio_get_direction_response { |
| 594 | __u8 direction; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 595 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 596 | |
| 597 | struct gb_gpio_direction_in_request { |
| 598 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 599 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 600 | /* direction in response has no payload */ |
| 601 | |
| 602 | struct gb_gpio_direction_out_request { |
| 603 | __u8 which; |
| 604 | __u8 value; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 605 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 606 | /* direction out response has no payload */ |
| 607 | |
| 608 | struct gb_gpio_get_value_request { |
| 609 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 610 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 611 | struct gb_gpio_get_value_response { |
| 612 | __u8 value; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 613 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 614 | |
| 615 | struct gb_gpio_set_value_request { |
| 616 | __u8 which; |
| 617 | __u8 value; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 618 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 619 | /* set value response has no payload */ |
| 620 | |
| 621 | struct gb_gpio_set_debounce_request { |
| 622 | __u8 which; |
Johan Hovold | 5b559e6 | 2015-08-01 11:50:41 +0200 | [diff] [blame] | 623 | __le16 usec; |
| 624 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 625 | /* debounce response has no payload */ |
| 626 | |
| 627 | struct gb_gpio_irq_type_request { |
| 628 | __u8 which; |
| 629 | __u8 type; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 630 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 631 | /* irq type response has no payload */ |
| 632 | |
| 633 | struct gb_gpio_irq_mask_request { |
| 634 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 635 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 636 | /* irq mask response has no payload */ |
| 637 | |
| 638 | struct gb_gpio_irq_unmask_request { |
| 639 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 640 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 641 | /* irq unmask response has no payload */ |
| 642 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 643 | /* irq event requests originate on another module and are handled on the AP */ |
| 644 | struct gb_gpio_irq_event_request { |
| 645 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 646 | } __packed; |
Johan Hovold | 1409c4d | 2015-05-26 15:29:25 +0200 | [diff] [blame] | 647 | /* irq event has no response */ |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 648 | |
| 649 | |
| 650 | /* PWM */ |
| 651 | |
| 652 | /* Version of the Greybus PWM protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 653 | #define GB_PWM_VERSION_MAJOR 0x00 |
| 654 | #define GB_PWM_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 655 | |
Alex Elder | 6d65337 | 2015-05-07 13:03:52 -0500 | [diff] [blame] | 656 | /* Greybus PWM operation types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 657 | #define GB_PWM_TYPE_PWM_COUNT 0x02 |
| 658 | #define GB_PWM_TYPE_ACTIVATE 0x03 |
| 659 | #define GB_PWM_TYPE_DEACTIVATE 0x04 |
| 660 | #define GB_PWM_TYPE_CONFIG 0x05 |
| 661 | #define GB_PWM_TYPE_POLARITY 0x06 |
| 662 | #define GB_PWM_TYPE_ENABLE 0x07 |
| 663 | #define GB_PWM_TYPE_DISABLE 0x08 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 664 | |
| 665 | /* pwm count request has no payload */ |
| 666 | struct gb_pwm_count_response { |
| 667 | __u8 count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 668 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 669 | |
| 670 | struct gb_pwm_activate_request { |
| 671 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 672 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 673 | |
| 674 | struct gb_pwm_deactivate_request { |
| 675 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 676 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 677 | |
| 678 | struct gb_pwm_config_request { |
| 679 | __u8 which; |
Johan Hovold | 5b559e6 | 2015-08-01 11:50:41 +0200 | [diff] [blame] | 680 | __le32 duty; |
| 681 | __le32 period; |
| 682 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 683 | |
| 684 | struct gb_pwm_polarity_request { |
| 685 | __u8 which; |
| 686 | __u8 polarity; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 687 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 688 | |
| 689 | struct gb_pwm_enable_request { |
| 690 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 691 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 692 | |
| 693 | struct gb_pwm_disable_request { |
| 694 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 695 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 696 | |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 697 | /* SPI */ |
| 698 | |
| 699 | /* Version of the Greybus spi protocol we support */ |
| 700 | #define GB_SPI_VERSION_MAJOR 0x00 |
| 701 | #define GB_SPI_VERSION_MINOR 0x01 |
| 702 | |
| 703 | /* Should match up with modes in linux/spi/spi.h */ |
| 704 | #define GB_SPI_MODE_CPHA 0x01 /* clock phase */ |
| 705 | #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */ |
| 706 | #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */ |
| 707 | #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA) |
| 708 | #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0) |
| 709 | #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA) |
| 710 | #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */ |
| 711 | #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */ |
| 712 | #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */ |
| 713 | #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */ |
| 714 | #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */ |
| 715 | #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */ |
| 716 | |
| 717 | /* Should match up with flags in linux/spi/spi.h */ |
| 718 | #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */ |
| 719 | #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */ |
| 720 | #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */ |
| 721 | |
| 722 | /* Greybus spi operation types */ |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 723 | #define GB_SPI_TYPE_MASTER_CONFIG 0x02 |
| 724 | #define GB_SPI_TYPE_DEVICE_CONFIG 0x03 |
| 725 | #define GB_SPI_TYPE_TRANSFER 0x04 |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 726 | |
| 727 | /* mode request has no payload */ |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 728 | struct gb_spi_master_config_response { |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 729 | __le32 bits_per_word_mask; |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 730 | __le32 min_speed_hz; |
| 731 | __le32 max_speed_hz; |
| 732 | __le16 mode; |
| 733 | __le16 flags; |
Rui Miguel Silva | 50014e0 | 2015-12-10 14:24:58 +0000 | [diff] [blame] | 734 | __u8 num_chipselect; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 735 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 736 | |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 737 | struct gb_spi_device_config_request { |
Rui Miguel Silva | 50014e0 | 2015-12-10 14:24:58 +0000 | [diff] [blame] | 738 | __u8 chip_select; |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 739 | } __packed; |
| 740 | |
| 741 | struct gb_spi_device_config_response { |
| 742 | __le16 mode; |
| 743 | __u8 bits_per_word; |
| 744 | __le32 max_speed_hz; |
Rui Miguel Silva | 0273038 | 2016-02-02 14:23:16 +0000 | [diff] [blame] | 745 | __u8 device_type; |
| 746 | #define GB_SPI_SPI_DEV 0x00 |
| 747 | #define GB_SPI_SPI_NOR 0x01 |
| 748 | #define GB_SPI_SPI_MODALIAS 0x02 |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 749 | __u8 name[32]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 750 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 751 | |
| 752 | /** |
| 753 | * struct gb_spi_transfer - a read/write buffer pair |
| 754 | * @speed_hz: Select a speed other than the device default for this transfer. If |
| 755 | * 0 the default (from @spi_device) is used. |
| 756 | * @len: size of rx and tx buffers (in bytes) |
| 757 | * @delay_usecs: microseconds to delay after this transfer before (optionally) |
| 758 | * changing the chipselect status, then starting the next transfer or |
| 759 | * completing this spi_message. |
| 760 | * @cs_change: affects chipselect after this transfer completes |
| 761 | * @bits_per_word: select a bits_per_word other than the device default for this |
| 762 | * transfer. If 0 the default (from @spi_device) is used. |
| 763 | */ |
| 764 | struct gb_spi_transfer { |
| 765 | __le32 speed_hz; |
| 766 | __le32 len; |
| 767 | __le16 delay_usecs; |
| 768 | __u8 cs_change; |
| 769 | __u8 bits_per_word; |
Rui Miguel Silva | b455c84 | 2015-12-02 11:12:27 +0000 | [diff] [blame] | 770 | __u8 rdwr; |
| 771 | #define GB_SPI_XFER_READ 0x01 |
| 772 | #define GB_SPI_XFER_WRITE 0x02 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 773 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 774 | |
| 775 | struct gb_spi_transfer_request { |
| 776 | __u8 chip_select; /* of the spi device */ |
| 777 | __u8 mode; /* of the spi device */ |
| 778 | __le16 count; |
Johan Hovold | 46d26c5 | 2015-08-01 11:50:37 +0200 | [diff] [blame] | 779 | struct gb_spi_transfer transfers[0]; /* count of these */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 780 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 781 | |
| 782 | struct gb_spi_transfer_response { |
| 783 | __u8 data[0]; /* inbound data */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 784 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 785 | |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 786 | /* Version of the Greybus SVC protocol we support */ |
| 787 | #define GB_SVC_VERSION_MAJOR 0x00 |
| 788 | #define GB_SVC_VERSION_MINOR 0x01 |
| 789 | |
| 790 | /* Greybus SVC request types */ |
Bryan O'Donoghue | 0bd39ca | 2016-03-02 16:51:09 +0000 | [diff] [blame] | 791 | #define GB_SVC_TYPE_SVC_HELLO 0x02 |
| 792 | #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03 |
| 793 | #define GB_SVC_TYPE_INTF_HOTPLUG 0x04 |
| 794 | #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05 |
| 795 | #define GB_SVC_TYPE_INTF_RESET 0x06 |
| 796 | #define GB_SVC_TYPE_CONN_CREATE 0x07 |
| 797 | #define GB_SVC_TYPE_CONN_DESTROY 0x08 |
| 798 | #define GB_SVC_TYPE_DME_PEER_GET 0x09 |
| 799 | #define GB_SVC_TYPE_DME_PEER_SET 0x0a |
| 800 | #define GB_SVC_TYPE_ROUTE_CREATE 0x0b |
| 801 | #define GB_SVC_TYPE_ROUTE_DESTROY 0x0c |
| 802 | #define GB_SVC_TYPE_TIMESYNC_ENABLE 0x0d |
| 803 | #define GB_SVC_TYPE_TIMESYNC_DISABLE 0x0e |
| 804 | #define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE 0x0f |
| 805 | #define GB_SVC_TYPE_INTF_SET_PWRM 0x10 |
| 806 | #define GB_SVC_TYPE_INTF_EJECT 0x11 |
| 807 | #define GB_SVC_TYPE_KEY_EVENT 0x12 |
| 808 | #define GB_SVC_TYPE_PING 0x13 |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 809 | |
Johan Hovold | cfb1690 | 2015-09-15 10:48:01 +0200 | [diff] [blame] | 810 | /* |
| 811 | * SVC version request/response has the same payload as |
| 812 | * gb_protocol_version_request/response. |
| 813 | */ |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 814 | |
| 815 | /* SVC protocol hello request */ |
| 816 | struct gb_svc_hello_request { |
| 817 | __le16 endo_id; |
| 818 | __u8 interface_id; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 819 | } __packed; |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 820 | /* hello response has no payload */ |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 821 | |
| 822 | struct gb_svc_intf_device_id_request { |
| 823 | __u8 intf_id; |
| 824 | __u8 device_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 825 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 826 | /* device id response has no payload */ |
| 827 | |
| 828 | struct gb_svc_intf_hotplug_request { |
| 829 | __u8 intf_id; |
| 830 | struct { |
Viresh Kumar | b32a5c5 | 2015-12-22 22:04:33 +0530 | [diff] [blame] | 831 | __le32 ddbl1_mfr_id; |
| 832 | __le32 ddbl1_prod_id; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 833 | __le32 ara_vend_id; |
| 834 | __le32 ara_prod_id; |
Viresh Kumar | 57c6bcc | 2015-12-28 11:59:00 +0530 | [diff] [blame] | 835 | __le64 serial_number; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 836 | } data; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 837 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 838 | /* hotplug response has no payload */ |
| 839 | |
| 840 | struct gb_svc_intf_hot_unplug_request { |
| 841 | __u8 intf_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 842 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 843 | /* hot unplug response has no payload */ |
| 844 | |
| 845 | struct gb_svc_intf_reset_request { |
| 846 | __u8 intf_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 847 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 848 | /* interface reset response has no payload */ |
| 849 | |
Rui Miguel Silva | c5d55fb | 2016-01-11 13:46:31 +0000 | [diff] [blame] | 850 | struct gb_svc_intf_eject_request { |
| 851 | __u8 intf_id; |
| 852 | } __packed; |
| 853 | /* interface eject response has no payload */ |
| 854 | |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 855 | struct gb_svc_conn_create_request { |
| 856 | __u8 intf1_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 857 | __le16 cport1_id; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 858 | __u8 intf2_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 859 | __le16 cport2_id; |
Perry Hung | 0b22649 | 2015-07-24 19:02:34 -0400 | [diff] [blame] | 860 | __u8 tc; |
| 861 | __u8 flags; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 862 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 863 | /* connection create response has no payload */ |
| 864 | |
| 865 | struct gb_svc_conn_destroy_request { |
| 866 | __u8 intf1_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 867 | __le16 cport1_id; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 868 | __u8 intf2_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 869 | __le16 cport2_id; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 870 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 871 | /* connection destroy response has no payload */ |
| 872 | |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 873 | struct gb_svc_dme_peer_get_request { |
| 874 | __u8 intf_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 875 | __le16 attr; |
| 876 | __le16 selector; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 877 | } __packed; |
| 878 | |
| 879 | struct gb_svc_dme_peer_get_response { |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 880 | __le16 result_code; |
| 881 | __le32 attr_value; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 882 | } __packed; |
| 883 | |
| 884 | struct gb_svc_dme_peer_set_request { |
| 885 | __u8 intf_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 886 | __le16 attr; |
| 887 | __le16 selector; |
| 888 | __le32 value; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 889 | } __packed; |
| 890 | |
| 891 | struct gb_svc_dme_peer_set_response { |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 892 | __le16 result_code; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 893 | } __packed; |
| 894 | |
Viresh Kumar | 6bec5c7 | 2015-09-24 14:40:29 -0700 | [diff] [blame] | 895 | /* Attributes for peer get/set operations */ |
| 896 | #define DME_ATTR_SELECTOR_INDEX 0 |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 897 | /* FIXME: remove ES2 support and DME_ATTR_T_TST_SRC_INCREMENT */ |
Viresh Kumar | 6bec5c7 | 2015-09-24 14:40:29 -0700 | [diff] [blame] | 898 | #define DME_ATTR_T_TST_SRC_INCREMENT 0x4083 |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 899 | #define DME_ATTR_ES3_INIT_STATUS 0x6101 |
Viresh Kumar | 6bec5c7 | 2015-09-24 14:40:29 -0700 | [diff] [blame] | 900 | |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 901 | /* Return value from init-status attributes listed above */ |
| 902 | #define DME_DIS_SPI_BOOT_STARTED 0x02 |
| 903 | #define DME_DIS_TRUSTED_SPI_BOOT_FINISHED 0x03 |
| 904 | #define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED 0x04 |
| 905 | #define DME_DIS_UNIPRO_BOOT_STARTED 0x06 |
| 906 | #define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED 0x09 |
Viresh Kumar | 1575ef1 | 2015-10-07 15:40:24 -0400 | [diff] [blame] | 907 | |
Perry Hung | e08aaa4 | 2015-07-24 19:02:31 -0400 | [diff] [blame] | 908 | struct gb_svc_route_create_request { |
| 909 | __u8 intf1_id; |
| 910 | __u8 dev1_id; |
| 911 | __u8 intf2_id; |
| 912 | __u8 dev2_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 913 | } __packed; |
Viresh Kumar | d6ec787 | 2015-08-31 17:21:02 +0530 | [diff] [blame] | 914 | /* route create response has no payload */ |
Perry Hung | e08aaa4 | 2015-07-24 19:02:31 -0400 | [diff] [blame] | 915 | |
Viresh Kumar | 0a02057 | 2015-09-07 18:05:26 +0530 | [diff] [blame] | 916 | struct gb_svc_route_destroy_request { |
| 917 | __u8 intf1_id; |
| 918 | __u8 intf2_id; |
| 919 | } __packed; |
| 920 | /* route destroy response has no payload */ |
| 921 | |
Bryan O'Donoghue | 177d4a4 | 2016-03-02 16:51:08 +0000 | [diff] [blame] | 922 | struct gb_svc_timesync_enable_request { |
| 923 | __u8 count; |
| 924 | __u64 frame_time; |
| 925 | __u32 strobe_delay; |
| 926 | __u32 strobe_mask; |
| 927 | __u32 refclk; |
| 928 | } __packed; |
| 929 | /* timesync enable response has no payload */ |
| 930 | |
| 931 | /* timesync authoritative request has no payload */ |
| 932 | struct gb_svc_timesync_authoritative_response { |
| 933 | __u64 frame_time[GB_TIMESYNC_MAX_STROBES]; |
| 934 | }; |
| 935 | |
Laurent Pinchart | aab4a1a | 2016-01-06 16:16:46 +0200 | [diff] [blame] | 936 | #define GB_SVC_UNIPRO_FAST_MODE 0x01 |
| 937 | #define GB_SVC_UNIPRO_SLOW_MODE 0x02 |
| 938 | #define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04 |
| 939 | #define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05 |
| 940 | #define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07 |
| 941 | #define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11 |
| 942 | #define GB_SVC_UNIPRO_OFF_MODE 0x12 |
| 943 | |
| 944 | #define GB_SVC_PWRM_RXTERMINATION 0x01 |
| 945 | #define GB_SVC_PWRM_TXTERMINATION 0x02 |
| 946 | #define GB_SVC_PWRM_LINE_RESET 0x04 |
| 947 | #define GB_SVC_PWRM_SCRAMBLING 0x20 |
| 948 | |
| 949 | #define GB_SVC_PWRM_QUIRK_HSSER 0x00000001 |
| 950 | |
| 951 | #define GB_SVC_UNIPRO_HS_SERIES_A 0x01 |
| 952 | #define GB_SVC_UNIPRO_HS_SERIES_B 0x02 |
| 953 | |
| 954 | struct gb_svc_intf_set_pwrm_request { |
| 955 | __u8 intf_id; |
| 956 | __u8 hs_series; |
| 957 | __u8 tx_mode; |
| 958 | __u8 tx_gear; |
| 959 | __u8 tx_nlanes; |
| 960 | __u8 rx_mode; |
| 961 | __u8 rx_gear; |
| 962 | __u8 rx_nlanes; |
| 963 | __u8 flags; |
| 964 | __le32 quirks; |
| 965 | } __packed; |
| 966 | |
| 967 | struct gb_svc_intf_set_pwrm_response { |
| 968 | __le16 result_code; |
| 969 | } __packed; |
Viresh Kumar | d65e3a2 | 2015-08-13 10:04:45 +0530 | [diff] [blame] | 970 | |
Rui Miguel Silva | ebe99d6 | 2016-01-21 01:42:17 +0000 | [diff] [blame] | 971 | struct gb_svc_key_event_request { |
| 972 | __le16 key_code; |
| 973 | #define GB_KEYCODE_ARA 0x00 |
| 974 | |
| 975 | __u8 key_event; |
| 976 | #define GB_SVC_KEY_RELEASED 0x00 |
| 977 | #define GB_SVC_KEY_PRESSED 0x01 |
| 978 | } __packed; |
| 979 | |
Viresh Kumar | d65e3a2 | 2015-08-13 10:04:45 +0530 | [diff] [blame] | 980 | /* RAW */ |
| 981 | |
| 982 | /* Version of the Greybus raw protocol we support */ |
| 983 | #define GB_RAW_VERSION_MAJOR 0x00 |
| 984 | #define GB_RAW_VERSION_MINOR 0x01 |
| 985 | |
| 986 | /* Greybus raw request types */ |
| 987 | #define GB_RAW_TYPE_SEND 0x02 |
| 988 | |
| 989 | struct gb_raw_send_request { |
| 990 | __le32 len; |
| 991 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 992 | } __packed; |
Viresh Kumar | d65e3a2 | 2015-08-13 10:04:45 +0530 | [diff] [blame] | 993 | |
| 994 | |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 995 | /* UART */ |
| 996 | |
| 997 | /* Version of the Greybus UART protocol we support */ |
| 998 | #define GB_UART_VERSION_MAJOR 0x00 |
| 999 | #define GB_UART_VERSION_MINOR 0x01 |
| 1000 | |
| 1001 | /* Greybus UART operation types */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1002 | #define GB_UART_TYPE_SEND_DATA 0x02 |
| 1003 | #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */ |
| 1004 | #define GB_UART_TYPE_SET_LINE_CODING 0x04 |
| 1005 | #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05 |
Bryan O'Donoghue | a519203 | 2015-07-14 02:10:18 +0100 | [diff] [blame] | 1006 | #define GB_UART_TYPE_SEND_BREAK 0x06 |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1007 | #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */ |
| 1008 | |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 1009 | /* Represents data from AP -> Module */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1010 | struct gb_uart_send_data_request { |
| 1011 | __le16 size; |
| 1012 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1013 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1014 | |
Bryan O'Donoghue | 802362d | 2015-06-29 18:09:13 +0100 | [diff] [blame] | 1015 | /* recv-data-request flags */ |
| 1016 | #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */ |
| 1017 | #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */ |
| 1018 | #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */ |
| 1019 | #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */ |
| 1020 | |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 1021 | /* Represents data from Module -> AP */ |
| 1022 | struct gb_uart_recv_data_request { |
| 1023 | __le16 size; |
Bryan O'Donoghue | 802362d | 2015-06-29 18:09:13 +0100 | [diff] [blame] | 1024 | __u8 flags; |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 1025 | __u8 data[0]; |
Johan Hovold | cfc5f2c | 2015-08-01 11:50:39 +0200 | [diff] [blame] | 1026 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1027 | |
| 1028 | struct gb_uart_set_line_coding_request { |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 1029 | __le32 rate; |
| 1030 | __u8 format; |
| 1031 | #define GB_SERIAL_1_STOP_BITS 0 |
| 1032 | #define GB_SERIAL_1_5_STOP_BITS 1 |
| 1033 | #define GB_SERIAL_2_STOP_BITS 2 |
| 1034 | |
| 1035 | __u8 parity; |
| 1036 | #define GB_SERIAL_NO_PARITY 0 |
| 1037 | #define GB_SERIAL_ODD_PARITY 1 |
| 1038 | #define GB_SERIAL_EVEN_PARITY 2 |
| 1039 | #define GB_SERIAL_MARK_PARITY 3 |
| 1040 | #define GB_SERIAL_SPACE_PARITY 4 |
| 1041 | |
| 1042 | __u8 data_bits; |
Johan Hovold | cfc5f2c | 2015-08-01 11:50:39 +0200 | [diff] [blame] | 1043 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1044 | |
| 1045 | /* output control lines */ |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 1046 | #define GB_UART_CTRL_DTR 0x01 |
| 1047 | #define GB_UART_CTRL_RTS 0x02 |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1048 | |
| 1049 | struct gb_uart_set_control_line_state_request { |
Bryan O'Donoghue | ba4b099 | 2015-06-29 18:09:15 +0100 | [diff] [blame] | 1050 | __u8 control; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1051 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1052 | |
| 1053 | struct gb_uart_set_break_request { |
| 1054 | __u8 state; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1055 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1056 | |
| 1057 | /* input control lines and line errors */ |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 1058 | #define GB_UART_CTRL_DCD 0x01 |
| 1059 | #define GB_UART_CTRL_DSR 0x02 |
Bryan O'Donoghue | 802362d | 2015-06-29 18:09:13 +0100 | [diff] [blame] | 1060 | #define GB_UART_CTRL_RI 0x04 |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1061 | |
| 1062 | struct gb_uart_serial_state_request { |
Bryan O'Donoghue | ba4b099 | 2015-06-29 18:09:15 +0100 | [diff] [blame] | 1063 | __u8 control; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1064 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1065 | |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1066 | /* Loopback */ |
| 1067 | |
| 1068 | /* Version of the Greybus loopback protocol we support */ |
Bryan O'Donoghue | 52af141 | 2015-07-14 00:53:12 +0100 | [diff] [blame] | 1069 | #define GB_LOOPBACK_VERSION_MAJOR 0x00 |
| 1070 | #define GB_LOOPBACK_VERSION_MINOR 0x01 |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1071 | |
| 1072 | /* Greybus loopback request types */ |
Bryan O'Donoghue | 52af141 | 2015-07-14 00:53:12 +0100 | [diff] [blame] | 1073 | #define GB_LOOPBACK_TYPE_PING 0x02 |
| 1074 | #define GB_LOOPBACK_TYPE_TRANSFER 0x03 |
Bryan O'Donoghue | 384a7a3 | 2015-07-13 20:20:49 +0100 | [diff] [blame] | 1075 | #define GB_LOOPBACK_TYPE_SINK 0x04 |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1076 | |
Axel Haslam | b59281a | 2016-02-10 14:19:29 +0100 | [diff] [blame] | 1077 | /* |
| 1078 | * Loopback request/response header format should be identical |
| 1079 | * to simplify bandwidth and data movement analysis. |
| 1080 | */ |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1081 | struct gb_loopback_transfer_request { |
| 1082 | __le32 len; |
Axel Haslam | b59281a | 2016-02-10 14:19:29 +0100 | [diff] [blame] | 1083 | __le32 reserved0; |
| 1084 | __le32 reserved1; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1085 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1086 | } __packed; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1087 | |
| 1088 | struct gb_loopback_transfer_response { |
Bryan O'Donoghue | 4a655ad | 2015-09-14 10:48:45 +0100 | [diff] [blame] | 1089 | __le32 len; |
Bryan O'Donoghue | 04db334 | 2015-10-12 15:45:05 +0100 | [diff] [blame] | 1090 | __le32 reserved0; |
| 1091 | __le32 reserved1; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1092 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1093 | } __packed; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 1094 | |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1095 | /* SDIO */ |
| 1096 | /* Version of the Greybus sdio protocol we support */ |
| 1097 | #define GB_SDIO_VERSION_MAJOR 0x00 |
| 1098 | #define GB_SDIO_VERSION_MINOR 0x01 |
| 1099 | |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1100 | /* Greybus SDIO operation types */ |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1101 | #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02 |
| 1102 | #define GB_SDIO_TYPE_SET_IOS 0x03 |
| 1103 | #define GB_SDIO_TYPE_COMMAND 0x04 |
| 1104 | #define GB_SDIO_TYPE_TRANSFER 0x05 |
| 1105 | #define GB_SDIO_TYPE_EVENT 0x06 |
| 1106 | |
| 1107 | /* get caps response: request has no payload */ |
| 1108 | struct gb_sdio_get_caps_response { |
| 1109 | __le32 caps; |
| 1110 | #define GB_SDIO_CAP_NONREMOVABLE 0x00000001 |
| 1111 | #define GB_SDIO_CAP_4_BIT_DATA 0x00000002 |
| 1112 | #define GB_SDIO_CAP_8_BIT_DATA 0x00000004 |
| 1113 | #define GB_SDIO_CAP_MMC_HS 0x00000008 |
| 1114 | #define GB_SDIO_CAP_SD_HS 0x00000010 |
| 1115 | #define GB_SDIO_CAP_ERASE 0x00000020 |
| 1116 | #define GB_SDIO_CAP_1_2V_DDR 0x00000040 |
| 1117 | #define GB_SDIO_CAP_1_8V_DDR 0x00000080 |
| 1118 | #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100 |
| 1119 | #define GB_SDIO_CAP_UHS_SDR12 0x00000200 |
| 1120 | #define GB_SDIO_CAP_UHS_SDR25 0x00000400 |
| 1121 | #define GB_SDIO_CAP_UHS_SDR50 0x00000800 |
| 1122 | #define GB_SDIO_CAP_UHS_SDR104 0x00001000 |
| 1123 | #define GB_SDIO_CAP_UHS_DDR50 0x00002000 |
| 1124 | #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000 |
| 1125 | #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000 |
| 1126 | #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000 |
| 1127 | #define GB_SDIO_CAP_HS200_1_2V 0x00020000 |
| 1128 | #define GB_SDIO_CAP_HS200_1_8V 0x00040000 |
| 1129 | #define GB_SDIO_CAP_HS400_1_2V 0x00080000 |
| 1130 | #define GB_SDIO_CAP_HS400_1_8V 0x00100000 |
| 1131 | |
| 1132 | /* see possible values below at vdd */ |
| 1133 | __le32 ocr; |
| 1134 | __le16 max_blk_count; |
| 1135 | __le16 max_blk_size; |
Rui Miguel Silva | e0f875c | 2015-10-08 12:10:51 +0100 | [diff] [blame] | 1136 | __le32 f_min; |
| 1137 | __le32 f_max; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1138 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1139 | |
| 1140 | /* set ios request: response has no payload */ |
| 1141 | struct gb_sdio_set_ios_request { |
| 1142 | __le32 clock; |
| 1143 | __le32 vdd; |
| 1144 | #define GB_SDIO_VDD_165_195 0x00000001 |
| 1145 | #define GB_SDIO_VDD_20_21 0x00000002 |
| 1146 | #define GB_SDIO_VDD_21_22 0x00000004 |
| 1147 | #define GB_SDIO_VDD_22_23 0x00000008 |
| 1148 | #define GB_SDIO_VDD_23_24 0x00000010 |
| 1149 | #define GB_SDIO_VDD_24_25 0x00000020 |
| 1150 | #define GB_SDIO_VDD_25_26 0x00000040 |
| 1151 | #define GB_SDIO_VDD_26_27 0x00000080 |
| 1152 | #define GB_SDIO_VDD_27_28 0x00000100 |
| 1153 | #define GB_SDIO_VDD_28_29 0x00000200 |
| 1154 | #define GB_SDIO_VDD_29_30 0x00000400 |
| 1155 | #define GB_SDIO_VDD_30_31 0x00000800 |
| 1156 | #define GB_SDIO_VDD_31_32 0x00001000 |
| 1157 | #define GB_SDIO_VDD_32_33 0x00002000 |
| 1158 | #define GB_SDIO_VDD_33_34 0x00004000 |
| 1159 | #define GB_SDIO_VDD_34_35 0x00008000 |
| 1160 | #define GB_SDIO_VDD_35_36 0x00010000 |
| 1161 | |
| 1162 | __u8 bus_mode; |
| 1163 | #define GB_SDIO_BUSMODE_OPENDRAIN 0x00 |
| 1164 | #define GB_SDIO_BUSMODE_PUSHPULL 0x01 |
| 1165 | |
| 1166 | __u8 power_mode; |
| 1167 | #define GB_SDIO_POWER_OFF 0x00 |
| 1168 | #define GB_SDIO_POWER_UP 0x01 |
| 1169 | #define GB_SDIO_POWER_ON 0x02 |
| 1170 | #define GB_SDIO_POWER_UNDEFINED 0x03 |
| 1171 | |
| 1172 | __u8 bus_width; |
| 1173 | #define GB_SDIO_BUS_WIDTH_1 0x00 |
| 1174 | #define GB_SDIO_BUS_WIDTH_4 0x02 |
| 1175 | #define GB_SDIO_BUS_WIDTH_8 0x03 |
| 1176 | |
| 1177 | __u8 timing; |
| 1178 | #define GB_SDIO_TIMING_LEGACY 0x00 |
| 1179 | #define GB_SDIO_TIMING_MMC_HS 0x01 |
| 1180 | #define GB_SDIO_TIMING_SD_HS 0x02 |
| 1181 | #define GB_SDIO_TIMING_UHS_SDR12 0x03 |
| 1182 | #define GB_SDIO_TIMING_UHS_SDR25 0x04 |
| 1183 | #define GB_SDIO_TIMING_UHS_SDR50 0x05 |
| 1184 | #define GB_SDIO_TIMING_UHS_SDR104 0x06 |
| 1185 | #define GB_SDIO_TIMING_UHS_DDR50 0x07 |
| 1186 | #define GB_SDIO_TIMING_MMC_DDR52 0x08 |
| 1187 | #define GB_SDIO_TIMING_MMC_HS200 0x09 |
| 1188 | #define GB_SDIO_TIMING_MMC_HS400 0x0A |
| 1189 | |
| 1190 | __u8 signal_voltage; |
| 1191 | #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00 |
| 1192 | #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01 |
| 1193 | #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02 |
| 1194 | |
| 1195 | __u8 drv_type; |
| 1196 | #define GB_SDIO_SET_DRIVER_TYPE_B 0x00 |
| 1197 | #define GB_SDIO_SET_DRIVER_TYPE_A 0x01 |
| 1198 | #define GB_SDIO_SET_DRIVER_TYPE_C 0x02 |
| 1199 | #define GB_SDIO_SET_DRIVER_TYPE_D 0x03 |
Johan Hovold | 8bbd9ed | 2015-08-01 11:50:40 +0200 | [diff] [blame] | 1200 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1201 | |
| 1202 | /* command request */ |
| 1203 | struct gb_sdio_command_request { |
| 1204 | __u8 cmd; |
| 1205 | __u8 cmd_flags; |
| 1206 | #define GB_SDIO_RSP_NONE 0x00 |
Rui Miguel Silva | ef0cc0e | 2015-07-02 19:11:30 +0100 | [diff] [blame] | 1207 | #define GB_SDIO_RSP_PRESENT 0x01 |
| 1208 | #define GB_SDIO_RSP_136 0x02 |
| 1209 | #define GB_SDIO_RSP_CRC 0x04 |
| 1210 | #define GB_SDIO_RSP_BUSY 0x08 |
| 1211 | #define GB_SDIO_RSP_OPCODE 0x10 |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1212 | |
| 1213 | __u8 cmd_type; |
| 1214 | #define GB_SDIO_CMD_AC 0x00 |
| 1215 | #define GB_SDIO_CMD_ADTC 0x01 |
Rui Miguel Silva | 2d465d5 | 2015-08-20 15:20:17 +0100 | [diff] [blame] | 1216 | #define GB_SDIO_CMD_BC 0x02 |
| 1217 | #define GB_SDIO_CMD_BCR 0x03 |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1218 | |
| 1219 | __le32 cmd_arg; |
Rui Miguel Silva | 10ed193 | 2015-10-15 23:56:51 +0100 | [diff] [blame] | 1220 | __le16 data_blocks; |
| 1221 | __le16 data_blksz; |
Johan Hovold | 8bbd9ed | 2015-08-01 11:50:40 +0200 | [diff] [blame] | 1222 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1223 | |
| 1224 | struct gb_sdio_command_response { |
| 1225 | __le32 resp[4]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1226 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1227 | |
| 1228 | /* transfer request */ |
| 1229 | struct gb_sdio_transfer_request { |
| 1230 | __u8 data_flags; |
| 1231 | #define GB_SDIO_DATA_WRITE 0x01 |
| 1232 | #define GB_SDIO_DATA_READ 0x02 |
| 1233 | #define GB_SDIO_DATA_STREAM 0x04 |
| 1234 | |
| 1235 | __le16 data_blocks; |
| 1236 | __le16 data_blksz; |
| 1237 | __u8 data[0]; |
Johan Hovold | 8bbd9ed | 2015-08-01 11:50:40 +0200 | [diff] [blame] | 1238 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1239 | |
| 1240 | struct gb_sdio_transfer_response { |
| 1241 | __le16 data_blocks; |
| 1242 | __le16 data_blksz; |
| 1243 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1244 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1245 | |
| 1246 | /* event request: generated by module and is defined as unidirectional */ |
| 1247 | struct gb_sdio_event_request { |
| 1248 | __u8 event; |
| 1249 | #define GB_SDIO_CARD_INSERTED 0x01 |
| 1250 | #define GB_SDIO_CARD_REMOVED 0x02 |
| 1251 | #define GB_SDIO_WP 0x04 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1252 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1253 | |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1254 | /* Camera */ |
| 1255 | |
| 1256 | #define GB_CAMERA_VERSION_MAJOR 0x00 |
| 1257 | #define GB_CAMERA_VERSION_MINOR 0x01 |
| 1258 | |
| 1259 | /* Greybus Camera request types */ |
| 1260 | #define GB_CAMERA_TYPE_CAPABILITIES 0x02 |
| 1261 | #define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03 |
| 1262 | #define GB_CAMERA_TYPE_CAPTURE 0x04 |
| 1263 | #define GB_CAMERA_TYPE_FLUSH 0x05 |
| 1264 | #define GB_CAMERA_TYPE_METADATA 0x06 |
| 1265 | |
| 1266 | #define GB_CAMERA_MAX_STREAMS 4 |
| 1267 | #define GB_CAMERA_MAX_SETTINGS_SIZE 8192 |
| 1268 | |
| 1269 | /* Greybus Camera Configure Streams request payload */ |
| 1270 | struct gb_camera_stream_config_request { |
| 1271 | __le16 width; |
| 1272 | __le16 height; |
| 1273 | __le16 format; |
| 1274 | __le16 padding; |
| 1275 | } __packed; |
| 1276 | |
| 1277 | struct gb_camera_configure_streams_request { |
Jacopo Mondi | b787d41 | 2016-01-08 18:13:20 +0200 | [diff] [blame] | 1278 | __u8 num_streams; |
| 1279 | __u8 flags; |
| 1280 | #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01 |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1281 | __le16 padding; |
| 1282 | struct gb_camera_stream_config_request config[0]; |
| 1283 | } __packed; |
| 1284 | |
| 1285 | /* Greybus Camera Configure Streams response payload */ |
| 1286 | struct gb_camera_stream_config_response { |
| 1287 | __le16 width; |
| 1288 | __le16 height; |
| 1289 | __le16 format; |
| 1290 | __u8 virtual_channel; |
| 1291 | __u8 data_type[2]; |
| 1292 | __u8 padding[3]; |
| 1293 | __le32 max_size; |
| 1294 | } __packed; |
| 1295 | |
| 1296 | struct gb_camera_configure_streams_response { |
Jacopo Mondi | b787d41 | 2016-01-08 18:13:20 +0200 | [diff] [blame] | 1297 | __u8 num_streams; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1298 | __u8 flags; |
Jacopo Mondi | b787d41 | 2016-01-08 18:13:20 +0200 | [diff] [blame] | 1299 | #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01 |
Jacopo Mondi | 446091c | 2016-02-23 11:22:48 +0100 | [diff] [blame] | 1300 | __u8 num_lanes; |
| 1301 | __u8 padding; |
| 1302 | __le32 bus_freq; |
| 1303 | __le32 lines_per_second; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1304 | struct gb_camera_stream_config_response config[0]; |
| 1305 | } __packed; |
| 1306 | |
| 1307 | /* Greybus Camera Capture request payload - response has no payload */ |
| 1308 | struct gb_camera_capture_request { |
| 1309 | __le32 request_id; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1310 | __u8 streams; |
| 1311 | __u8 padding; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1312 | __le16 num_frames; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1313 | __u8 settings[0]; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1314 | } __packed; |
| 1315 | |
| 1316 | /* Greybus Camera Flush response payload - request has no payload */ |
| 1317 | struct gb_camera_flush_response { |
| 1318 | __le32 request_id; |
| 1319 | } __packed; |
| 1320 | |
| 1321 | /* Greybus Camera Metadata request payload - operation has no response */ |
| 1322 | struct gb_camera_metadata_request { |
| 1323 | __le32 request_id; |
| 1324 | __le16 frame_number; |
| 1325 | __u8 stream; |
| 1326 | __u8 padding; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1327 | __u8 metadata[0]; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1328 | } __packed; |
| 1329 | |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1330 | /* Lights */ |
| 1331 | |
| 1332 | #define GB_LIGHTS_VERSION_MAJOR 0x00 |
| 1333 | #define GB_LIGHTS_VERSION_MINOR 0x01 |
| 1334 | |
| 1335 | /* Greybus Lights request types */ |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1336 | #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02 |
| 1337 | #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03 |
| 1338 | #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04 |
| 1339 | #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05 |
| 1340 | #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06 |
| 1341 | #define GB_LIGHTS_TYPE_SET_BLINK 0x07 |
| 1342 | #define GB_LIGHTS_TYPE_SET_COLOR 0x08 |
| 1343 | #define GB_LIGHTS_TYPE_SET_FADE 0x09 |
| 1344 | #define GB_LIGHTS_TYPE_EVENT 0x0A |
| 1345 | #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B |
| 1346 | #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C |
| 1347 | #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D |
| 1348 | #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E |
| 1349 | |
| 1350 | /* Greybus Light modes */ |
| 1351 | |
| 1352 | /* |
| 1353 | * if you add any specific mode below, update also the |
| 1354 | * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly |
| 1355 | */ |
| 1356 | #define GB_CHANNEL_MODE_NONE 0x00000000 |
| 1357 | #define GB_CHANNEL_MODE_BATTERY 0x00000001 |
| 1358 | #define GB_CHANNEL_MODE_POWER 0x00000002 |
| 1359 | #define GB_CHANNEL_MODE_WIRELESS 0x00000004 |
| 1360 | #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008 |
| 1361 | #define GB_CHANNEL_MODE_KEYBOARD 0x00000010 |
| 1362 | #define GB_CHANNEL_MODE_BUTTONS 0x00000020 |
| 1363 | #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040 |
| 1364 | #define GB_CHANNEL_MODE_ATTENTION 0x00000080 |
| 1365 | #define GB_CHANNEL_MODE_FLASH 0x00000100 |
| 1366 | #define GB_CHANNEL_MODE_TORCH 0x00000200 |
| 1367 | #define GB_CHANNEL_MODE_INDICATOR 0x00000400 |
| 1368 | |
| 1369 | /* Lights Mode valid bit values */ |
| 1370 | #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF |
| 1371 | #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000 |
| 1372 | |
| 1373 | /* Greybus Light Channels Flags */ |
| 1374 | #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001 |
| 1375 | #define GB_LIGHT_CHANNEL_FADER 0x00000002 |
| 1376 | #define GB_LIGHT_CHANNEL_BLINK 0x00000004 |
| 1377 | |
| 1378 | /* get count of lights in module */ |
| 1379 | struct gb_lights_get_lights_response { |
| 1380 | __u8 lights_count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1381 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1382 | |
| 1383 | /* light config request payload */ |
| 1384 | struct gb_lights_get_light_config_request { |
| 1385 | __u8 id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1386 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1387 | |
| 1388 | /* light config response payload */ |
| 1389 | struct gb_lights_get_light_config_response { |
| 1390 | __u8 channel_count; |
| 1391 | __u8 name[32]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1392 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1393 | |
| 1394 | /* channel config request payload */ |
| 1395 | struct gb_lights_get_channel_config_request { |
| 1396 | __u8 light_id; |
| 1397 | __u8 channel_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1398 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1399 | |
| 1400 | /* channel flash config request payload */ |
| 1401 | struct gb_lights_get_channel_flash_config_request { |
| 1402 | __u8 light_id; |
| 1403 | __u8 channel_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1404 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1405 | |
| 1406 | /* channel config response payload */ |
| 1407 | struct gb_lights_get_channel_config_response { |
| 1408 | __u8 max_brightness; |
| 1409 | __le32 flags; |
| 1410 | __le32 color; |
| 1411 | __u8 color_name[32]; |
| 1412 | __le32 mode; |
| 1413 | __u8 mode_name[32]; |
| 1414 | } __packed; |
| 1415 | |
| 1416 | /* channel flash config response payload */ |
| 1417 | struct gb_lights_get_channel_flash_config_response { |
| 1418 | __le32 intensity_min_uA; |
| 1419 | __le32 intensity_max_uA; |
| 1420 | __le32 intensity_step_uA; |
| 1421 | __le32 timeout_min_us; |
| 1422 | __le32 timeout_max_us; |
| 1423 | __le32 timeout_step_us; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1424 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1425 | |
| 1426 | /* blink request payload: response have no payload */ |
| 1427 | struct gb_lights_blink_request { |
| 1428 | __u8 light_id; |
| 1429 | __u8 channel_id; |
| 1430 | __le16 time_on_ms; |
| 1431 | __le16 time_off_ms; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1432 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1433 | |
| 1434 | /* set brightness request payload: response have no payload */ |
| 1435 | struct gb_lights_set_brightness_request { |
| 1436 | __u8 light_id; |
| 1437 | __u8 channel_id; |
| 1438 | __u8 brightness; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1439 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1440 | |
| 1441 | /* set color request payload: response have no payload */ |
| 1442 | struct gb_lights_set_color_request { |
| 1443 | __u8 light_id; |
| 1444 | __u8 channel_id; |
| 1445 | __le32 color; |
| 1446 | } __packed; |
| 1447 | |
| 1448 | /* set fade request payload: response have no payload */ |
| 1449 | struct gb_lights_set_fade_request { |
| 1450 | __u8 light_id; |
| 1451 | __u8 channel_id; |
| 1452 | __u8 fade_in; |
| 1453 | __u8 fade_out; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1454 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1455 | |
| 1456 | /* event request: generated by module */ |
| 1457 | struct gb_lights_event_request { |
| 1458 | __u8 light_id; |
| 1459 | __u8 event; |
| 1460 | #define GB_LIGHTS_LIGHT_CONFIG 0x01 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1461 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1462 | |
| 1463 | /* set flash intensity request payload: response have no payload */ |
| 1464 | struct gb_lights_set_flash_intensity_request { |
| 1465 | __u8 light_id; |
| 1466 | __u8 channel_id; |
| 1467 | __le32 intensity_uA; |
| 1468 | } __packed; |
| 1469 | |
| 1470 | /* set flash strobe state request payload: response have no payload */ |
| 1471 | struct gb_lights_set_flash_strobe_request { |
| 1472 | __u8 light_id; |
| 1473 | __u8 channel_id; |
| 1474 | __u8 state; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1475 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1476 | |
| 1477 | /* set flash timeout request payload: response have no payload */ |
| 1478 | struct gb_lights_set_flash_timeout_request { |
| 1479 | __u8 light_id; |
| 1480 | __u8 channel_id; |
| 1481 | __le32 timeout_us; |
| 1482 | } __packed; |
| 1483 | |
| 1484 | /* get flash fault request payload */ |
| 1485 | struct gb_lights_get_flash_fault_request { |
| 1486 | __u8 light_id; |
| 1487 | __u8 channel_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1488 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1489 | |
| 1490 | /* get flash fault response payload */ |
| 1491 | struct gb_lights_get_flash_fault_response { |
| 1492 | __le32 fault; |
| 1493 | #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000 |
| 1494 | #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001 |
| 1495 | #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002 |
| 1496 | #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004 |
| 1497 | #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008 |
| 1498 | #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010 |
| 1499 | #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020 |
| 1500 | #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040 |
| 1501 | #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1502 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1503 | |
Mark Greer | ba4144a | 2016-01-13 14:07:45 -0700 | [diff] [blame] | 1504 | /* Audio */ |
| 1505 | |
| 1506 | /* Version of the Greybus audio protocol we support */ |
| 1507 | #define GB_AUDIO_VERSION_MAJOR 0x00 |
| 1508 | #define GB_AUDIO_VERSION_MINOR 0x01 |
| 1509 | |
| 1510 | #define GB_AUDIO_TYPE_PROTOCOL_VERSION 0x01 |
| 1511 | #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02 |
| 1512 | #define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03 |
| 1513 | #define GB_AUDIO_TYPE_GET_CONTROL 0x04 |
| 1514 | #define GB_AUDIO_TYPE_SET_CONTROL 0x05 |
| 1515 | #define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06 |
| 1516 | #define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07 |
| 1517 | #define GB_AUDIO_TYPE_GET_PCM 0x08 |
| 1518 | #define GB_AUDIO_TYPE_SET_PCM 0x09 |
| 1519 | #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a |
| 1520 | #define GB_AUDIO_TYPE_GET_TX_DELAY 0x0b |
| 1521 | #define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c |
| 1522 | #define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d |
| 1523 | #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e |
| 1524 | #define GB_AUDIO_TYPE_GET_RX_DELAY 0x0f |
| 1525 | #define GB_AUDIO_TYPE_ACTIVATE_RX 0x10 |
| 1526 | #define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11 |
| 1527 | #define GB_AUDIO_TYPE_JACK_EVENT 0x12 |
| 1528 | #define GB_AUDIO_TYPE_BUTTON_EVENT 0x13 |
| 1529 | #define GB_AUDIO_TYPE_STREAMING_EVENT 0x14 |
| 1530 | #define GB_AUDIO_TYPE_SEND_DATA 0x15 |
| 1531 | |
| 1532 | /* Module must be able to buffer 10ms of audio data, minimum */ |
| 1533 | #define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000 |
| 1534 | |
| 1535 | #define GB_AUDIO_PCM_NAME_MAX 32 |
| 1536 | #define AUDIO_DAI_NAME_MAX 32 |
| 1537 | #define AUDIO_CONTROL_NAME_MAX 32 |
| 1538 | #define AUDIO_CTL_ELEM_NAME_MAX 44 |
| 1539 | #define AUDIO_ENUM_NAME_MAX 64 |
| 1540 | #define AUDIO_WIDGET_NAME_MAX 32 |
| 1541 | |
| 1542 | /* See SNDRV_PCM_FMTBIT_* in Linux source */ |
| 1543 | #define GB_AUDIO_PCM_FMT_S8 BIT(0) |
| 1544 | #define GB_AUDIO_PCM_FMT_U8 BIT(1) |
| 1545 | #define GB_AUDIO_PCM_FMT_S16_LE BIT(2) |
| 1546 | #define GB_AUDIO_PCM_FMT_S16_BE BIT(3) |
| 1547 | #define GB_AUDIO_PCM_FMT_U16_LE BIT(4) |
| 1548 | #define GB_AUDIO_PCM_FMT_U16_BE BIT(5) |
| 1549 | #define GB_AUDIO_PCM_FMT_S24_LE BIT(6) |
| 1550 | #define GB_AUDIO_PCM_FMT_S24_BE BIT(7) |
| 1551 | #define GB_AUDIO_PCM_FMT_U24_LE BIT(8) |
| 1552 | #define GB_AUDIO_PCM_FMT_U24_BE BIT(9) |
| 1553 | #define GB_AUDIO_PCM_FMT_S32_LE BIT(10) |
| 1554 | #define GB_AUDIO_PCM_FMT_S32_BE BIT(11) |
| 1555 | #define GB_AUDIO_PCM_FMT_U32_LE BIT(12) |
| 1556 | #define GB_AUDIO_PCM_FMT_U32_BE BIT(13) |
| 1557 | |
| 1558 | /* See SNDRV_PCM_RATE_* in Linux source */ |
| 1559 | #define GB_AUDIO_PCM_RATE_5512 BIT(0) |
| 1560 | #define GB_AUDIO_PCM_RATE_8000 BIT(1) |
| 1561 | #define GB_AUDIO_PCM_RATE_11025 BIT(2) |
| 1562 | #define GB_AUDIO_PCM_RATE_16000 BIT(3) |
| 1563 | #define GB_AUDIO_PCM_RATE_22050 BIT(4) |
| 1564 | #define GB_AUDIO_PCM_RATE_32000 BIT(5) |
| 1565 | #define GB_AUDIO_PCM_RATE_44100 BIT(6) |
| 1566 | #define GB_AUDIO_PCM_RATE_48000 BIT(7) |
| 1567 | #define GB_AUDIO_PCM_RATE_64000 BIT(8) |
| 1568 | #define GB_AUDIO_PCM_RATE_88200 BIT(9) |
| 1569 | #define GB_AUDIO_PCM_RATE_96000 BIT(10) |
| 1570 | #define GB_AUDIO_PCM_RATE_176400 BIT(11) |
| 1571 | #define GB_AUDIO_PCM_RATE_192000 BIT(12) |
| 1572 | |
| 1573 | #define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1 |
| 1574 | #define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2 |
| 1575 | |
| 1576 | #define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0) |
| 1577 | #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1) |
| 1578 | |
| 1579 | /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */ |
| 1580 | #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01 |
| 1581 | #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02 |
| 1582 | #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03 |
| 1583 | #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06 |
| 1584 | |
| 1585 | /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */ |
| 1586 | #define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00 |
| 1587 | #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01 |
| 1588 | #define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02 |
| 1589 | #define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03 |
| 1590 | #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04 |
| 1591 | #define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05 |
| 1592 | #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06 |
| 1593 | |
| 1594 | /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */ |
| 1595 | #define GB_AUDIO_ACCESS_READ BIT(0) |
| 1596 | #define GB_AUDIO_ACCESS_WRITE BIT(1) |
| 1597 | #define GB_AUDIO_ACCESS_VOLATILE BIT(2) |
| 1598 | #define GB_AUDIO_ACCESS_TIMESTAMP BIT(3) |
| 1599 | #define GB_AUDIO_ACCESS_TLV_READ BIT(4) |
| 1600 | #define GB_AUDIO_ACCESS_TLV_WRITE BIT(5) |
| 1601 | #define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6) |
| 1602 | #define GB_AUDIO_ACCESS_INACTIVE BIT(7) |
| 1603 | #define GB_AUDIO_ACCESS_LOCK BIT(8) |
| 1604 | #define GB_AUDIO_ACCESS_OWNER BIT(9) |
| 1605 | |
| 1606 | /* enum snd_soc_dapm_type */ |
| 1607 | #define GB_AUDIO_WIDGET_TYPE_INPUT 0x0 |
| 1608 | #define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1 |
| 1609 | #define GB_AUDIO_WIDGET_TYPE_MUX 0x2 |
| 1610 | #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3 |
| 1611 | #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4 |
| 1612 | #define GB_AUDIO_WIDGET_TYPE_MIXER 0x5 |
| 1613 | #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6 |
| 1614 | #define GB_AUDIO_WIDGET_TYPE_PGA 0x7 |
| 1615 | #define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8 |
| 1616 | #define GB_AUDIO_WIDGET_TYPE_ADC 0x9 |
| 1617 | #define GB_AUDIO_WIDGET_TYPE_DAC 0xa |
| 1618 | #define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb |
| 1619 | #define GB_AUDIO_WIDGET_TYPE_MIC 0xc |
| 1620 | #define GB_AUDIO_WIDGET_TYPE_HP 0xd |
| 1621 | #define GB_AUDIO_WIDGET_TYPE_SPK 0xe |
| 1622 | #define GB_AUDIO_WIDGET_TYPE_LINE 0xf |
| 1623 | #define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10 |
| 1624 | #define GB_AUDIO_WIDGET_TYPE_VMID 0x11 |
| 1625 | #define GB_AUDIO_WIDGET_TYPE_PRE 0x12 |
| 1626 | #define GB_AUDIO_WIDGET_TYPE_POST 0x13 |
| 1627 | #define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14 |
| 1628 | #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15 |
| 1629 | #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16 |
| 1630 | #define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17 |
| 1631 | #define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18 |
| 1632 | #define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19 |
| 1633 | #define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a |
| 1634 | #define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b |
| 1635 | #define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c |
| 1636 | |
| 1637 | #define GB_AUDIO_WIDGET_STATE_DISABLED 0x01 |
| 1638 | #define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02 |
| 1639 | |
| 1640 | #define GB_AUDIO_JACK_EVENT_INSERTION 0x1 |
| 1641 | #define GB_AUDIO_JACK_EVENT_REMOVAL 0x2 |
| 1642 | |
| 1643 | #define GB_AUDIO_BUTTON_EVENT_PRESS 0x1 |
| 1644 | #define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2 |
| 1645 | |
| 1646 | #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1 |
| 1647 | #define GB_AUDIO_STREAMING_EVENT_HALT 0x2 |
| 1648 | #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3 |
| 1649 | #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4 |
| 1650 | #define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5 |
| 1651 | #define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6 |
| 1652 | #define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7 |
| 1653 | #define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8 |
| 1654 | #define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9 |
| 1655 | |
| 1656 | #define GB_AUDIO_INVALID_INDEX 0xff |
| 1657 | |
| 1658 | struct gb_audio_pcm { |
| 1659 | __u8 stream_name[GB_AUDIO_PCM_NAME_MAX]; |
| 1660 | __le32 formats; /* GB_AUDIO_PCM_FMT_* */ |
| 1661 | __le32 rates; /* GB_AUDIO_PCM_RATE_* */ |
| 1662 | __u8 chan_min; |
| 1663 | __u8 chan_max; |
| 1664 | __u8 sig_bits; /* number of bits of content */ |
| 1665 | } __packed; |
| 1666 | |
| 1667 | struct gb_audio_dai { |
| 1668 | __u8 name[AUDIO_DAI_NAME_MAX]; |
| 1669 | __le16 data_cport; |
| 1670 | struct gb_audio_pcm capture; |
| 1671 | struct gb_audio_pcm playback; |
| 1672 | } __packed; |
| 1673 | |
| 1674 | struct gb_audio_integer { |
| 1675 | __le32 min; |
| 1676 | __le32 max; |
| 1677 | __le32 step; |
| 1678 | } __packed; |
| 1679 | |
| 1680 | struct gb_audio_integer64 { |
| 1681 | __le64 min; |
| 1682 | __le64 max; |
| 1683 | __le64 step; |
| 1684 | } __packed; |
| 1685 | |
| 1686 | struct gb_audio_enumerated { |
| 1687 | __le32 items; |
| 1688 | __le16 names_length; |
| 1689 | __u8 names[0]; |
| 1690 | } __packed; |
| 1691 | |
| 1692 | struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */ |
| 1693 | __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */ |
| 1694 | __le16 dimen[4]; |
| 1695 | union { |
| 1696 | struct gb_audio_integer integer; |
| 1697 | struct gb_audio_integer64 integer64; |
| 1698 | struct gb_audio_enumerated enumerated; |
| 1699 | } value; |
| 1700 | } __packed; |
| 1701 | |
| 1702 | struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */ |
| 1703 | __le64 timestamp; /* XXX needed? */ |
| 1704 | union { |
| 1705 | __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */ |
| 1706 | __le64 integer64_value[2]; |
| 1707 | __le32 enumerated_item[2]; |
| 1708 | } value; |
| 1709 | } __packed; |
| 1710 | |
| 1711 | struct gb_audio_control { |
| 1712 | __u8 name[AUDIO_CONTROL_NAME_MAX]; |
| 1713 | __u8 id; /* 0-63 */ |
| 1714 | __u8 iface; /* GB_AUDIO_IFACE_* */ |
| 1715 | __le16 data_cport; |
| 1716 | __le32 access; /* GB_AUDIO_ACCESS_* */ |
| 1717 | __u8 count; /* count of same elements */ |
| 1718 | __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */ |
| 1719 | struct gb_audio_ctl_elem_info info; |
| 1720 | } __packed; |
| 1721 | |
| 1722 | struct gb_audio_widget { |
| 1723 | __u8 name[AUDIO_WIDGET_NAME_MAX]; |
| 1724 | __u8 sname[AUDIO_WIDGET_NAME_MAX]; |
| 1725 | __u8 id; |
| 1726 | __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */ |
| 1727 | __u8 state; /* GB_AUDIO_WIDGET_STATE_* */ |
| 1728 | __u8 ncontrols; |
| 1729 | struct gb_audio_control ctl[0]; /* 'ncontrols' entries */ |
| 1730 | } __packed; |
| 1731 | |
| 1732 | struct gb_audio_route { |
| 1733 | __u8 source_id; /* widget id */ |
| 1734 | __u8 destination_id; /* widget id */ |
| 1735 | __u8 control_id; /* 0-63 */ |
| 1736 | __u8 index; /* Selection within the control */ |
| 1737 | } __packed; |
| 1738 | |
| 1739 | struct gb_audio_topology { |
| 1740 | __u8 num_dais; |
| 1741 | __u8 num_controls; |
| 1742 | __u8 num_widgets; |
| 1743 | __u8 num_routes; |
| 1744 | __u32 size_dais; |
| 1745 | __u32 size_controls; |
| 1746 | __u32 size_widgets; |
| 1747 | __u32 size_routes; |
| 1748 | /* |
| 1749 | * struct gb_audio_dai dai[num_dais]; |
| 1750 | * struct gb_audio_control controls[num_controls]; |
| 1751 | * struct gb_audio_widget widgets[num_widgets]; |
| 1752 | * struct gb_audio_route routes[num_routes]; |
| 1753 | */ |
| 1754 | __u8 data[0]; |
| 1755 | } __packed; |
| 1756 | |
| 1757 | struct gb_audio_get_topology_size_response { |
| 1758 | __le16 size; |
| 1759 | } __packed; |
| 1760 | |
| 1761 | struct gb_audio_get_topology_response { |
| 1762 | struct gb_audio_topology topology; |
| 1763 | } __packed; |
| 1764 | |
| 1765 | struct gb_audio_get_control_request { |
| 1766 | __u8 control_id; |
| 1767 | __u8 index; |
| 1768 | } __packed; |
| 1769 | |
| 1770 | struct gb_audio_get_control_response { |
| 1771 | struct gb_audio_ctl_elem_value value; |
| 1772 | } __packed; |
| 1773 | |
| 1774 | struct gb_audio_set_control_request { |
| 1775 | __u8 control_id; |
| 1776 | __u8 index; |
| 1777 | struct gb_audio_ctl_elem_value value; |
| 1778 | } __packed; |
| 1779 | |
| 1780 | struct gb_audio_enable_widget_request { |
| 1781 | __u8 widget_id; |
| 1782 | } __packed; |
| 1783 | |
| 1784 | struct gb_audio_disable_widget_request { |
| 1785 | __u8 widget_id; |
| 1786 | } __packed; |
| 1787 | |
| 1788 | struct gb_audio_get_pcm_request { |
| 1789 | __le16 data_cport; |
| 1790 | } __packed; |
| 1791 | |
| 1792 | struct gb_audio_get_pcm_response { |
| 1793 | __le32 format; |
| 1794 | __le32 rate; |
| 1795 | __u8 channels; |
| 1796 | __u8 sig_bits; |
| 1797 | } __packed; |
| 1798 | |
| 1799 | struct gb_audio_set_pcm_request { |
| 1800 | __le16 data_cport; |
| 1801 | __le32 format; |
| 1802 | __le32 rate; |
| 1803 | __u8 channels; |
| 1804 | __u8 sig_bits; |
| 1805 | } __packed; |
| 1806 | |
| 1807 | struct gb_audio_set_tx_data_size_request { |
| 1808 | __le16 data_cport; |
| 1809 | __le16 size; |
| 1810 | } __packed; |
| 1811 | |
| 1812 | struct gb_audio_get_tx_delay_request { |
| 1813 | __le16 data_cport; |
| 1814 | } __packed; |
| 1815 | |
| 1816 | struct gb_audio_get_tx_delay_response { |
| 1817 | __le32 delay; |
| 1818 | } __packed; |
| 1819 | |
| 1820 | struct gb_audio_activate_tx_request { |
| 1821 | __le16 data_cport; |
| 1822 | } __packed; |
| 1823 | |
| 1824 | struct gb_audio_deactivate_tx_request { |
| 1825 | __le16 data_cport; |
| 1826 | } __packed; |
| 1827 | |
| 1828 | struct gb_audio_set_rx_data_size_request { |
| 1829 | __le16 data_cport; |
| 1830 | __le16 size; |
| 1831 | } __packed; |
| 1832 | |
| 1833 | struct gb_audio_get_rx_delay_request { |
| 1834 | __le16 data_cport; |
| 1835 | } __packed; |
| 1836 | |
| 1837 | struct gb_audio_get_rx_delay_response { |
| 1838 | __le32 delay; |
| 1839 | } __packed; |
| 1840 | |
| 1841 | struct gb_audio_activate_rx_request { |
| 1842 | __le16 data_cport; |
| 1843 | } __packed; |
| 1844 | |
| 1845 | struct gb_audio_deactivate_rx_request { |
| 1846 | __le16 data_cport; |
| 1847 | } __packed; |
| 1848 | |
| 1849 | struct gb_audio_jack_event_request { |
| 1850 | __u8 widget_id; |
| 1851 | __u8 widget_type; |
| 1852 | __u8 event; |
| 1853 | } __packed; |
| 1854 | |
| 1855 | struct gb_audio_button_event_request { |
| 1856 | __u8 widget_id; |
| 1857 | __u8 button_id; |
| 1858 | __u8 event; |
| 1859 | } __packed; |
| 1860 | |
| 1861 | struct gb_audio_streaming_event_request { |
| 1862 | __le16 data_cport; |
| 1863 | __u8 event; |
| 1864 | } __packed; |
| 1865 | |
| 1866 | struct gb_audio_send_data_request { |
| 1867 | __le64 timestamp; |
| 1868 | __u8 data[0]; |
| 1869 | } __packed; |
| 1870 | |
Alex Elder | 012d7d4 | 2015-05-27 14:45:58 -0500 | [diff] [blame] | 1871 | #endif /* __GREYBUS_PROTOCOLS_H */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1872 | |