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