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 | /* Version of the Greybus control protocol we support */ |
| 119 | #define GB_CONTROL_VERSION_MAJOR 0x00 |
| 120 | #define GB_CONTROL_VERSION_MINOR 0x01 |
| 121 | |
| 122 | /* Greybus control request types */ |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 123 | #define GB_CONTROL_TYPE_PROBE_AP 0x02 |
| 124 | #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03 |
| 125 | #define GB_CONTROL_TYPE_GET_MANIFEST 0x04 |
| 126 | #define GB_CONTROL_TYPE_CONNECTED 0x05 |
| 127 | #define GB_CONTROL_TYPE_DISCONNECTED 0x06 |
| 128 | |
| 129 | /* Control protocol manifest get size request has no payload*/ |
| 130 | struct gb_control_get_manifest_size_response { |
| 131 | __le16 size; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 132 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 133 | |
| 134 | /* Control protocol manifest get request has no payload */ |
| 135 | struct gb_control_get_manifest_response { |
| 136 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 137 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 138 | |
| 139 | /* Control protocol [dis]connected request */ |
| 140 | struct gb_control_connected_request { |
| 141 | __le16 cport_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 142 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 143 | |
| 144 | struct gb_control_disconnected_request { |
| 145 | __le16 cport_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 146 | } __packed; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 147 | /* Control protocol [dis]connected response has no payload */ |
| 148 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 149 | |
| 150 | /* Firmware Protocol */ |
| 151 | |
| 152 | /* Version of the Greybus firmware protocol we support */ |
| 153 | #define GB_FIRMWARE_VERSION_MAJOR 0x00 |
| 154 | #define GB_FIRMWARE_VERSION_MINOR 0x01 |
| 155 | |
| 156 | /* Greybus firmware request types */ |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 157 | #define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02 |
| 158 | #define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03 |
| 159 | #define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04 |
Viresh Kumar | 4c9e228 | 2015-09-09 21:08:33 +0530 | [diff] [blame] | 160 | #define GB_FIRMWARE_TYPE_AP_READY 0x05 /* Request with no-payload */ |
Viresh Kumar | f1e941a | 2015-11-26 15:33:46 +0530 | [diff] [blame] | 161 | #define GB_FIRMWARE_TYPE_GET_VID_PID 0x06 /* Request with no-payload */ |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 162 | |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 163 | /* FIXME: remove all ES2-specific identifiers from the kernel */ |
| 164 | #define ES2_DDBL1_MFR_ID 0x00000126 |
| 165 | #define ES2_DDBL1_PROD_ID 0x00001000 |
| 166 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 167 | /* Greybus firmware boot stages */ |
| 168 | #define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */ |
| 169 | #define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */ |
| 170 | #define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */ |
| 171 | |
| 172 | /* Greybus firmware ready to boot status */ |
| 173 | #define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */ |
| 174 | #define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */ |
| 175 | #define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */ |
| 176 | |
| 177 | /* Max firmware data fetch size in bytes */ |
| 178 | #define GB_FIRMWARE_FETCH_MAX 2000 |
| 179 | |
| 180 | /* Firmware protocol firmware size request/response */ |
| 181 | struct gb_firmware_size_request { |
| 182 | __u8 stage; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 183 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 184 | |
| 185 | struct gb_firmware_size_response { |
| 186 | __le32 size; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 187 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 188 | |
| 189 | /* Firmware protocol get firmware request/response */ |
| 190 | struct gb_firmware_get_firmware_request { |
| 191 | __le32 offset; |
| 192 | __le32 size; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 193 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 194 | |
| 195 | struct gb_firmware_get_firmware_response { |
| 196 | __u8 data[0]; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 197 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 198 | |
| 199 | /* Firmware protocol Ready to boot request */ |
| 200 | struct gb_firmware_ready_to_boot_request { |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 201 | __u8 status; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 202 | } __packed; |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 203 | /* Firmware protocol Ready to boot response has no payload */ |
| 204 | |
Viresh Kumar | f1e941a | 2015-11-26 15:33:46 +0530 | [diff] [blame] | 205 | /* Firmware protocol get VID/PID request has no payload */ |
| 206 | struct gb_firmware_get_vid_pid_response { |
| 207 | __le32 vendor_id; |
| 208 | __le32 product_id; |
| 209 | } __packed; |
| 210 | |
Viresh Kumar | 90f1b61 | 2015-08-12 09:19:33 +0530 | [diff] [blame] | 211 | |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 212 | /* Power Supply */ |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 213 | |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 214 | /* Version of the Greybus power supply protocol we support */ |
| 215 | #define GB_POWER_SUPPLY_VERSION_MAJOR 0x00 |
| 216 | #define GB_POWER_SUPPLY_VERSION_MINOR 0x01 |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 217 | |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 218 | /* Greybus power supply request types */ |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 219 | #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02 |
| 220 | #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03 |
| 221 | #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04 |
| 222 | #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05 |
| 223 | #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06 |
| 224 | #define GB_POWER_SUPPLY_TYPE_EVENT 0x07 |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 225 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 226 | /* Should match up with battery technologies in linux/power_supply.h */ |
Rui Miguel Silva | 2724be0 | 2015-11-12 15:36:00 +0000 | [diff] [blame] | 227 | #define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000 |
| 228 | #define GB_POWER_SUPPLY_TECH_NiMH 0x0001 |
| 229 | #define GB_POWER_SUPPLY_TECH_LION 0x0002 |
| 230 | #define GB_POWER_SUPPLY_TECH_LIPO 0x0003 |
| 231 | #define GB_POWER_SUPPLY_TECH_LiFe 0x0004 |
| 232 | #define GB_POWER_SUPPLY_TECH_NiCd 0x0005 |
| 233 | #define GB_POWER_SUPPLY_TECH_LiMn 0x0006 |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 234 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 235 | /* Should match up with power supply types in linux/power_supply.h */ |
| 236 | #define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000 |
| 237 | #define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001 |
| 238 | #define GB_POWER_SUPPLY_UPS_TYPE 0x0002 |
| 239 | #define GB_POWER_SUPPLY_MAINS_TYPE 0x0003 |
| 240 | #define GB_POWER_SUPPLY_USB_TYPE 0x0004 |
| 241 | #define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005 |
| 242 | #define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006 |
| 243 | #define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007 |
| 244 | |
| 245 | /* Should match up with power supply health in linux/power_supply.h */ |
| 246 | #define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000 |
| 247 | #define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001 |
| 248 | #define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002 |
| 249 | #define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003 |
| 250 | #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004 |
| 251 | #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005 |
| 252 | #define GB_POWER_SUPPLY_HEALTH_COLD 0x0006 |
| 253 | #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007 |
| 254 | #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008 |
| 255 | |
| 256 | /* Should match up with battery status in linux/power_supply.h */ |
| 257 | #define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000 |
| 258 | #define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001 |
| 259 | #define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002 |
| 260 | #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003 |
| 261 | #define GB_POWER_SUPPLY_STATUS_FULL 0x0004 |
| 262 | |
| 263 | struct gb_power_supply_get_supplies_response { |
| 264 | __u8 supplies_count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 265 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 266 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 267 | struct gb_power_supply_get_description_request { |
| 268 | __u8 psy_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 269 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 270 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 271 | struct gb_power_supply_get_description_response { |
| 272 | __u8 manufacturer[32]; |
| 273 | __u8 model[32]; |
| 274 | __u8 serial_number[32]; |
| 275 | __le16 type; |
| 276 | __u8 properties_count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 277 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 278 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 279 | struct gb_power_supply_props_desc { |
| 280 | __u8 property; |
| 281 | #define GB_POWER_SUPPLY_PROP_STATUS 0x00 |
| 282 | #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01 |
| 283 | #define GB_POWER_SUPPLY_PROP_HEALTH 0x02 |
| 284 | #define GB_POWER_SUPPLY_PROP_PRESENT 0x03 |
| 285 | #define GB_POWER_SUPPLY_PROP_ONLINE 0x04 |
| 286 | #define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05 |
| 287 | #define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06 |
| 288 | #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07 |
| 289 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08 |
| 290 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09 |
| 291 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A |
| 292 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B |
| 293 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C |
| 294 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D |
| 295 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E |
| 296 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F |
| 297 | #define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10 |
| 298 | #define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11 |
| 299 | #define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12 |
| 300 | #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13 |
| 301 | #define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14 |
| 302 | #define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15 |
| 303 | #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16 |
| 304 | #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17 |
| 305 | #define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18 |
| 306 | #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19 |
| 307 | #define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A |
| 308 | #define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B |
| 309 | #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C |
| 310 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D |
| 311 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E |
| 312 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F |
| 313 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20 |
| 314 | #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21 |
| 315 | #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22 |
| 316 | #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23 |
| 317 | #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24 |
| 318 | #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25 |
| 319 | #define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26 |
| 320 | #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27 |
| 321 | #define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28 |
| 322 | #define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29 |
| 323 | #define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A |
| 324 | #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B |
| 325 | #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C |
| 326 | #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D |
| 327 | #define GB_POWER_SUPPLY_PROP_TEMP 0x2E |
| 328 | #define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F |
| 329 | #define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30 |
| 330 | #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31 |
| 331 | #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32 |
| 332 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33 |
| 333 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34 |
| 334 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35 |
| 335 | #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36 |
| 336 | #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37 |
| 337 | #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38 |
| 338 | #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39 |
| 339 | #define GB_POWER_SUPPLY_PROP_TYPE 0x3A |
| 340 | #define GB_POWER_SUPPLY_PROP_SCOPE 0x3B |
| 341 | #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C |
| 342 | #define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D |
| 343 | __u8 is_writeable; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 344 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 345 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 346 | struct gb_power_supply_get_property_descriptors_request { |
| 347 | __u8 psy_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 348 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 349 | |
Rui Miguel Silva | ffe2e24 | 2015-11-12 15:36:02 +0000 | [diff] [blame] | 350 | struct gb_power_supply_get_property_descriptors_response { |
| 351 | __u8 properties_count; |
| 352 | struct gb_power_supply_props_desc props[]; |
| 353 | } __packed; |
| 354 | |
| 355 | struct gb_power_supply_get_property_request { |
| 356 | __u8 psy_id; |
| 357 | __u8 property; |
| 358 | } __packed; |
| 359 | |
| 360 | struct gb_power_supply_get_property_response { |
| 361 | __le32 prop_val; |
| 362 | }; |
| 363 | |
| 364 | struct gb_power_supply_set_property_request { |
| 365 | __u8 psy_id; |
| 366 | __u8 property; |
| 367 | __le32 prop_val; |
| 368 | } __packed; |
| 369 | |
| 370 | struct gb_power_supply_event_request { |
| 371 | __u8 psy_id; |
| 372 | __u8 event; |
| 373 | #define GB_POWER_SUPPLY_UPDATE 0x01 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 374 | } __packed; |
Viresh Kumar | ce83294 | 2015-08-12 11:51:10 +0530 | [diff] [blame] | 375 | |
| 376 | |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 377 | /* HID */ |
| 378 | |
| 379 | /* Version of the Greybus hid protocol we support */ |
| 380 | #define GB_HID_VERSION_MAJOR 0x00 |
| 381 | #define GB_HID_VERSION_MINOR 0x01 |
| 382 | |
| 383 | /* Greybus HID operation types */ |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 384 | #define GB_HID_TYPE_GET_DESC 0x02 |
| 385 | #define GB_HID_TYPE_GET_REPORT_DESC 0x03 |
| 386 | #define GB_HID_TYPE_PWR_ON 0x04 |
| 387 | #define GB_HID_TYPE_PWR_OFF 0x05 |
| 388 | #define GB_HID_TYPE_GET_REPORT 0x06 |
| 389 | #define GB_HID_TYPE_SET_REPORT 0x07 |
| 390 | #define GB_HID_TYPE_IRQ_EVENT 0x08 |
| 391 | |
| 392 | /* Report type */ |
| 393 | #define GB_HID_INPUT_REPORT 0 |
| 394 | #define GB_HID_OUTPUT_REPORT 1 |
| 395 | #define GB_HID_FEATURE_REPORT 2 |
| 396 | |
| 397 | /* Different request/response structures */ |
| 398 | /* HID get descriptor response */ |
| 399 | struct gb_hid_desc_response { |
| 400 | __u8 bLength; |
| 401 | __le16 wReportDescLength; |
| 402 | __le16 bcdHID; |
| 403 | __le16 wProductID; |
| 404 | __le16 wVendorID; |
| 405 | __u8 bCountryCode; |
| 406 | } __packed; |
| 407 | |
| 408 | /* HID get report request/response */ |
| 409 | struct gb_hid_get_report_request { |
| 410 | __u8 report_type; |
| 411 | __u8 report_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 412 | } __packed; |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 413 | |
| 414 | /* HID set report request */ |
| 415 | struct gb_hid_set_report_request { |
| 416 | __u8 report_type; |
| 417 | __u8 report_id; |
| 418 | __u8 report[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 419 | } __packed; |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 420 | |
| 421 | /* HID input report request, via interrupt pipe */ |
| 422 | struct gb_hid_input_report_request { |
| 423 | __u8 report[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 424 | } __packed; |
Viresh Kumar | 51aee04 | 2015-08-12 11:51:11 +0530 | [diff] [blame] | 425 | |
| 426 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 427 | /* I2C */ |
| 428 | |
| 429 | /* Version of the Greybus i2c protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 430 | #define GB_I2C_VERSION_MAJOR 0x00 |
| 431 | #define GB_I2C_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 432 | |
| 433 | /* Greybus i2c request types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 434 | #define GB_I2C_TYPE_FUNCTIONALITY 0x02 |
| 435 | #define GB_I2C_TYPE_TIMEOUT 0x03 |
| 436 | #define GB_I2C_TYPE_RETRIES 0x04 |
| 437 | #define GB_I2C_TYPE_TRANSFER 0x05 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 438 | |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 439 | #define GB_I2C_RETRIES_DEFAULT 3 |
| 440 | #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */ |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 441 | |
| 442 | /* functionality request has no payload */ |
| 443 | struct gb_i2c_functionality_response { |
| 444 | __le32 functionality; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 445 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 446 | |
| 447 | struct gb_i2c_timeout_request { |
| 448 | __le16 msec; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 449 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 450 | /* timeout response has no payload */ |
| 451 | |
| 452 | struct gb_i2c_retries_request { |
| 453 | __u8 retries; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 454 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 455 | /* retries response has no payload */ |
| 456 | |
| 457 | /* |
| 458 | * Outgoing data immediately follows the op count and ops array. |
| 459 | * The data for each write (master -> slave) op in the array is sent |
| 460 | * in order, with no (e.g. pad) bytes separating them. |
| 461 | * |
| 462 | * Short reads cause the entire transfer request to fail So response |
| 463 | * payload consists only of bytes read, and the number of bytes is |
| 464 | * exactly what was specified in the corresponding op. Like |
| 465 | * outgoing data, the incoming data is in order and contiguous. |
| 466 | */ |
| 467 | struct gb_i2c_transfer_op { |
| 468 | __le16 addr; |
| 469 | __le16 flags; |
| 470 | __le16 size; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 471 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 472 | |
| 473 | struct gb_i2c_transfer_request { |
| 474 | __le16 op_count; |
| 475 | struct gb_i2c_transfer_op ops[0]; /* op_count of these */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 476 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 477 | struct gb_i2c_transfer_response { |
| 478 | __u8 data[0]; /* inbound data */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 479 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 480 | |
| 481 | |
| 482 | /* GPIO */ |
| 483 | |
| 484 | /* Version of the Greybus GPIO protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 485 | #define GB_GPIO_VERSION_MAJOR 0x00 |
| 486 | #define GB_GPIO_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 487 | |
| 488 | /* Greybus GPIO request types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 489 | #define GB_GPIO_TYPE_LINE_COUNT 0x02 |
| 490 | #define GB_GPIO_TYPE_ACTIVATE 0x03 |
| 491 | #define GB_GPIO_TYPE_DEACTIVATE 0x04 |
| 492 | #define GB_GPIO_TYPE_GET_DIRECTION 0x05 |
| 493 | #define GB_GPIO_TYPE_DIRECTION_IN 0x06 |
| 494 | #define GB_GPIO_TYPE_DIRECTION_OUT 0x07 |
| 495 | #define GB_GPIO_TYPE_GET_VALUE 0x08 |
| 496 | #define GB_GPIO_TYPE_SET_VALUE 0x09 |
| 497 | #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 498 | #define GB_GPIO_TYPE_IRQ_TYPE 0x0b |
Johan Hovold | 47bf0b4 | 2015-05-27 12:45:07 +0200 | [diff] [blame] | 499 | #define GB_GPIO_TYPE_IRQ_MASK 0x0c |
| 500 | #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d |
| 501 | #define GB_GPIO_TYPE_IRQ_EVENT 0x0e |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 502 | |
Johan Hovold | 7ba864a | 2015-05-28 19:03:34 +0200 | [diff] [blame] | 503 | #define GB_GPIO_IRQ_TYPE_NONE 0x00 |
| 504 | #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01 |
| 505 | #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02 |
| 506 | #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03 |
| 507 | #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04 |
| 508 | #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08 |
| 509 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 510 | /* line count request has no payload */ |
| 511 | struct gb_gpio_line_count_response { |
| 512 | __u8 count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 513 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 514 | |
| 515 | struct gb_gpio_activate_request { |
| 516 | __u8 which; |
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 | /* activate response has no payload */ |
| 519 | |
| 520 | struct gb_gpio_deactivate_request { |
| 521 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 522 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 523 | /* deactivate response has no payload */ |
| 524 | |
| 525 | struct gb_gpio_get_direction_request { |
| 526 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 527 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 528 | struct gb_gpio_get_direction_response { |
| 529 | __u8 direction; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 530 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 531 | |
| 532 | struct gb_gpio_direction_in_request { |
| 533 | __u8 which; |
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 | /* direction in response has no payload */ |
| 536 | |
| 537 | struct gb_gpio_direction_out_request { |
| 538 | __u8 which; |
| 539 | __u8 value; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 540 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 541 | /* direction out response has no payload */ |
| 542 | |
| 543 | struct gb_gpio_get_value_request { |
| 544 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 545 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 546 | struct gb_gpio_get_value_response { |
| 547 | __u8 value; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 548 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 549 | |
| 550 | struct gb_gpio_set_value_request { |
| 551 | __u8 which; |
| 552 | __u8 value; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 553 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 554 | /* set value response has no payload */ |
| 555 | |
| 556 | struct gb_gpio_set_debounce_request { |
| 557 | __u8 which; |
Johan Hovold | 5b559e6 | 2015-08-01 11:50:41 +0200 | [diff] [blame] | 558 | __le16 usec; |
| 559 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 560 | /* debounce response has no payload */ |
| 561 | |
| 562 | struct gb_gpio_irq_type_request { |
| 563 | __u8 which; |
| 564 | __u8 type; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 565 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 566 | /* irq type response has no payload */ |
| 567 | |
| 568 | struct gb_gpio_irq_mask_request { |
| 569 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 570 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 571 | /* irq mask response has no payload */ |
| 572 | |
| 573 | struct gb_gpio_irq_unmask_request { |
| 574 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 575 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 576 | /* irq unmask response has no payload */ |
| 577 | |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 578 | /* irq event requests originate on another module and are handled on the AP */ |
| 579 | struct gb_gpio_irq_event_request { |
| 580 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 581 | } __packed; |
Johan Hovold | 1409c4d | 2015-05-26 15:29:25 +0200 | [diff] [blame] | 582 | /* irq event has no response */ |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 583 | |
| 584 | |
| 585 | /* PWM */ |
| 586 | |
| 587 | /* Version of the Greybus PWM protocol we support */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 588 | #define GB_PWM_VERSION_MAJOR 0x00 |
| 589 | #define GB_PWM_VERSION_MINOR 0x01 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 590 | |
Alex Elder | 6d65337 | 2015-05-07 13:03:52 -0500 | [diff] [blame] | 591 | /* Greybus PWM operation types */ |
Greg Kroah-Hartman | 67c920b | 2015-04-10 11:18:49 +0200 | [diff] [blame] | 592 | #define GB_PWM_TYPE_PWM_COUNT 0x02 |
| 593 | #define GB_PWM_TYPE_ACTIVATE 0x03 |
| 594 | #define GB_PWM_TYPE_DEACTIVATE 0x04 |
| 595 | #define GB_PWM_TYPE_CONFIG 0x05 |
| 596 | #define GB_PWM_TYPE_POLARITY 0x06 |
| 597 | #define GB_PWM_TYPE_ENABLE 0x07 |
| 598 | #define GB_PWM_TYPE_DISABLE 0x08 |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 599 | |
| 600 | /* pwm count request has no payload */ |
| 601 | struct gb_pwm_count_response { |
| 602 | __u8 count; |
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 | |
| 605 | struct gb_pwm_activate_request { |
| 606 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 607 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 608 | |
| 609 | struct gb_pwm_deactivate_request { |
| 610 | __u8 which; |
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_pwm_config_request { |
| 614 | __u8 which; |
Johan Hovold | 5b559e6 | 2015-08-01 11:50:41 +0200 | [diff] [blame] | 615 | __le32 duty; |
| 616 | __le32 period; |
| 617 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 618 | |
| 619 | struct gb_pwm_polarity_request { |
| 620 | __u8 which; |
| 621 | __u8 polarity; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 622 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 623 | |
| 624 | struct gb_pwm_enable_request { |
| 625 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 626 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 627 | |
| 628 | struct gb_pwm_disable_request { |
| 629 | __u8 which; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 630 | } __packed; |
John Stultz | 453bbea | 2015-04-09 16:01:31 -0700 | [diff] [blame] | 631 | |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 632 | /* SPI */ |
| 633 | |
| 634 | /* Version of the Greybus spi protocol we support */ |
| 635 | #define GB_SPI_VERSION_MAJOR 0x00 |
| 636 | #define GB_SPI_VERSION_MINOR 0x01 |
| 637 | |
| 638 | /* Should match up with modes in linux/spi/spi.h */ |
| 639 | #define GB_SPI_MODE_CPHA 0x01 /* clock phase */ |
| 640 | #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */ |
| 641 | #define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */ |
| 642 | #define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA) |
| 643 | #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0) |
| 644 | #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA) |
| 645 | #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */ |
| 646 | #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */ |
| 647 | #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */ |
| 648 | #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */ |
| 649 | #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */ |
| 650 | #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */ |
| 651 | |
| 652 | /* Should match up with flags in linux/spi/spi.h */ |
| 653 | #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */ |
| 654 | #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */ |
| 655 | #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */ |
| 656 | |
| 657 | /* Greybus spi operation types */ |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 658 | #define GB_SPI_TYPE_MASTER_CONFIG 0x02 |
| 659 | #define GB_SPI_TYPE_DEVICE_CONFIG 0x03 |
| 660 | #define GB_SPI_TYPE_TRANSFER 0x04 |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 661 | |
| 662 | /* mode request has no payload */ |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 663 | struct gb_spi_master_config_response { |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 664 | __le32 bits_per_word_mask; |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 665 | __le32 min_speed_hz; |
| 666 | __le32 max_speed_hz; |
| 667 | __le16 mode; |
| 668 | __le16 flags; |
Rui Miguel Silva | 50014e0 | 2015-12-10 14:24:58 +0000 | [diff] [blame] | 669 | __u8 num_chipselect; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 670 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 671 | |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 672 | struct gb_spi_device_config_request { |
Rui Miguel Silva | 50014e0 | 2015-12-10 14:24:58 +0000 | [diff] [blame] | 673 | __u8 chip_select; |
Rui Miguel Silva | b343f6a | 2015-12-02 11:12:28 +0000 | [diff] [blame] | 674 | } __packed; |
| 675 | |
| 676 | struct gb_spi_device_config_response { |
| 677 | __le16 mode; |
| 678 | __u8 bits_per_word; |
| 679 | __le32 max_speed_hz; |
| 680 | __u8 name[32]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 681 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 682 | |
| 683 | /** |
| 684 | * struct gb_spi_transfer - a read/write buffer pair |
| 685 | * @speed_hz: Select a speed other than the device default for this transfer. If |
| 686 | * 0 the default (from @spi_device) is used. |
| 687 | * @len: size of rx and tx buffers (in bytes) |
| 688 | * @delay_usecs: microseconds to delay after this transfer before (optionally) |
| 689 | * changing the chipselect status, then starting the next transfer or |
| 690 | * completing this spi_message. |
| 691 | * @cs_change: affects chipselect after this transfer completes |
| 692 | * @bits_per_word: select a bits_per_word other than the device default for this |
| 693 | * transfer. If 0 the default (from @spi_device) is used. |
| 694 | */ |
| 695 | struct gb_spi_transfer { |
| 696 | __le32 speed_hz; |
| 697 | __le32 len; |
| 698 | __le16 delay_usecs; |
| 699 | __u8 cs_change; |
| 700 | __u8 bits_per_word; |
Rui Miguel Silva | b455c84 | 2015-12-02 11:12:27 +0000 | [diff] [blame] | 701 | __u8 rdwr; |
| 702 | #define GB_SPI_XFER_READ 0x01 |
| 703 | #define GB_SPI_XFER_WRITE 0x02 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 704 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 705 | |
| 706 | struct gb_spi_transfer_request { |
| 707 | __u8 chip_select; /* of the spi device */ |
| 708 | __u8 mode; /* of the spi device */ |
| 709 | __le16 count; |
Johan Hovold | 46d26c5 | 2015-08-01 11:50:37 +0200 | [diff] [blame] | 710 | struct gb_spi_transfer transfers[0]; /* count of these */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 711 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 712 | |
| 713 | struct gb_spi_transfer_response { |
| 714 | __u8 data[0]; /* inbound data */ |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 715 | } __packed; |
Viresh Kumar | 4890f31 | 2015-05-20 16:33:57 +0530 | [diff] [blame] | 716 | |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 717 | /* Version of the Greybus SVC protocol we support */ |
| 718 | #define GB_SVC_VERSION_MAJOR 0x00 |
| 719 | #define GB_SVC_VERSION_MINOR 0x01 |
| 720 | |
| 721 | /* Greybus SVC request types */ |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 722 | #define GB_SVC_TYPE_SVC_HELLO 0x02 |
| 723 | #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03 |
| 724 | #define GB_SVC_TYPE_INTF_HOTPLUG 0x04 |
| 725 | #define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05 |
| 726 | #define GB_SVC_TYPE_INTF_RESET 0x06 |
| 727 | #define GB_SVC_TYPE_CONN_CREATE 0x07 |
| 728 | #define GB_SVC_TYPE_CONN_DESTROY 0x08 |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 729 | #define GB_SVC_TYPE_DME_PEER_GET 0x09 |
| 730 | #define GB_SVC_TYPE_DME_PEER_SET 0x0a |
Perry Hung | e08aaa4 | 2015-07-24 19:02:31 -0400 | [diff] [blame] | 731 | #define GB_SVC_TYPE_ROUTE_CREATE 0x0b |
Viresh Kumar | 0a02057 | 2015-09-07 18:05:26 +0530 | [diff] [blame] | 732 | #define GB_SVC_TYPE_ROUTE_DESTROY 0x0c |
Bryan O'Donoghue | 72e53ae | 2015-12-23 16:48:59 +0000 | [diff] [blame] | 733 | #define GB_SVC_TYPE_LINK_CONFIG 0x10 |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 734 | |
Johan Hovold | cfb1690 | 2015-09-15 10:48:01 +0200 | [diff] [blame] | 735 | /* |
| 736 | * SVC version request/response has the same payload as |
| 737 | * gb_protocol_version_request/response. |
| 738 | */ |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 739 | |
| 740 | /* SVC protocol hello request */ |
| 741 | struct gb_svc_hello_request { |
| 742 | __le16 endo_id; |
| 743 | __u8 interface_id; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 744 | } __packed; |
Viresh Kumar | ead3546 | 2015-07-21 17:44:19 +0530 | [diff] [blame] | 745 | /* hello response has no payload */ |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 746 | |
| 747 | struct gb_svc_intf_device_id_request { |
| 748 | __u8 intf_id; |
| 749 | __u8 device_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 750 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 751 | /* device id response has no payload */ |
| 752 | |
| 753 | struct gb_svc_intf_hotplug_request { |
| 754 | __u8 intf_id; |
| 755 | struct { |
Viresh Kumar | b32a5c5 | 2015-12-22 22:04:33 +0530 | [diff] [blame] | 756 | __le32 ddbl1_mfr_id; |
| 757 | __le32 ddbl1_prod_id; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 758 | __le32 ara_vend_id; |
| 759 | __le32 ara_prod_id; |
Viresh Kumar | 57c6bcc | 2015-12-28 11:59:00 +0530 | [diff] [blame^] | 760 | __le64 serial_number; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 761 | } data; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 762 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 763 | /* hotplug response has no payload */ |
| 764 | |
| 765 | struct gb_svc_intf_hot_unplug_request { |
| 766 | __u8 intf_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 767 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 768 | /* hot unplug response has no payload */ |
| 769 | |
| 770 | struct gb_svc_intf_reset_request { |
| 771 | __u8 intf_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 772 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 773 | /* interface reset response has no payload */ |
| 774 | |
| 775 | struct gb_svc_conn_create_request { |
| 776 | __u8 intf1_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 777 | __le16 cport1_id; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 778 | __u8 intf2_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 779 | __le16 cport2_id; |
Perry Hung | 0b22649 | 2015-07-24 19:02:34 -0400 | [diff] [blame] | 780 | __u8 tc; |
| 781 | __u8 flags; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 782 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 783 | /* connection create response has no payload */ |
| 784 | |
| 785 | struct gb_svc_conn_destroy_request { |
| 786 | __u8 intf1_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 787 | __le16 cport1_id; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 788 | __u8 intf2_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 789 | __le16 cport2_id; |
Johan Hovold | 2130f09 | 2015-08-01 11:50:38 +0200 | [diff] [blame] | 790 | } __packed; |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 791 | /* connection destroy response has no payload */ |
| 792 | |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 793 | struct gb_svc_dme_peer_get_request { |
| 794 | __u8 intf_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 795 | __le16 attr; |
| 796 | __le16 selector; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 797 | } __packed; |
| 798 | |
| 799 | struct gb_svc_dme_peer_get_response { |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 800 | __le16 result_code; |
| 801 | __le32 attr_value; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 802 | } __packed; |
| 803 | |
| 804 | struct gb_svc_dme_peer_set_request { |
| 805 | __u8 intf_id; |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 806 | __le16 attr; |
| 807 | __le16 selector; |
| 808 | __le32 value; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 809 | } __packed; |
| 810 | |
| 811 | struct gb_svc_dme_peer_set_response { |
Rui Miguel Silva | 2498050 | 2015-09-15 15:33:51 +0100 | [diff] [blame] | 812 | __le16 result_code; |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 813 | } __packed; |
| 814 | |
Laurent Pinchart | 784f876 | 2015-12-18 21:23:22 +0200 | [diff] [blame] | 815 | #define GB_SVC_LINK_CONFIG_BURST_PWM 0 |
| 816 | #define GB_SVC_LINK_CONFIG_BURST_HS_A 1 |
| 817 | #define GB_SVC_LINK_CONFIG_BURST_HS_B 2 |
| 818 | #define GB_SVC_LINK_CONFIG_FLAG_AUTO_SLEEP (1 << 0) |
| 819 | |
| 820 | struct gb_svc_link_config_request { |
| 821 | __u8 intf_id; |
| 822 | __u8 burst; |
| 823 | __u8 gear; |
| 824 | __u8 nlanes; |
| 825 | __u8 flags; |
| 826 | } __packed; |
| 827 | /* link config response has no payload */ |
| 828 | |
Viresh Kumar | 6bec5c7 | 2015-09-24 14:40:29 -0700 | [diff] [blame] | 829 | /* Attributes for peer get/set operations */ |
| 830 | #define DME_ATTR_SELECTOR_INDEX 0 |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 831 | /* FIXME: remove ES2 support and DME_ATTR_T_TST_SRC_INCREMENT */ |
Viresh Kumar | 6bec5c7 | 2015-09-24 14:40:29 -0700 | [diff] [blame] | 832 | #define DME_ATTR_T_TST_SRC_INCREMENT 0x4083 |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 833 | #define DME_ATTR_ES3_INIT_STATUS 0x6101 |
Viresh Kumar | 6bec5c7 | 2015-09-24 14:40:29 -0700 | [diff] [blame] | 834 | |
Eli Sennesh | 3563ff8 | 2015-12-22 17:26:57 -0500 | [diff] [blame] | 835 | /* Return value from init-status attributes listed above */ |
| 836 | #define DME_DIS_SPI_BOOT_STARTED 0x02 |
| 837 | #define DME_DIS_TRUSTED_SPI_BOOT_FINISHED 0x03 |
| 838 | #define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED 0x04 |
| 839 | #define DME_DIS_UNIPRO_BOOT_STARTED 0x06 |
| 840 | #define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED 0x09 |
Viresh Kumar | 1575ef1 | 2015-10-07 15:40:24 -0400 | [diff] [blame] | 841 | |
Perry Hung | e08aaa4 | 2015-07-24 19:02:31 -0400 | [diff] [blame] | 842 | struct gb_svc_route_create_request { |
| 843 | __u8 intf1_id; |
| 844 | __u8 dev1_id; |
| 845 | __u8 intf2_id; |
| 846 | __u8 dev2_id; |
Viresh Kumar | 829a91e | 2015-08-31 17:21:03 +0530 | [diff] [blame] | 847 | } __packed; |
Viresh Kumar | d6ec787 | 2015-08-31 17:21:02 +0530 | [diff] [blame] | 848 | /* route create response has no payload */ |
Perry Hung | e08aaa4 | 2015-07-24 19:02:31 -0400 | [diff] [blame] | 849 | |
Viresh Kumar | 0a02057 | 2015-09-07 18:05:26 +0530 | [diff] [blame] | 850 | struct gb_svc_route_destroy_request { |
| 851 | __u8 intf1_id; |
| 852 | __u8 intf2_id; |
| 853 | } __packed; |
| 854 | /* route destroy response has no payload */ |
| 855 | |
Viresh Kumar | d65e3a2 | 2015-08-13 10:04:45 +0530 | [diff] [blame] | 856 | |
| 857 | /* RAW */ |
| 858 | |
| 859 | /* Version of the Greybus raw protocol we support */ |
| 860 | #define GB_RAW_VERSION_MAJOR 0x00 |
| 861 | #define GB_RAW_VERSION_MINOR 0x01 |
| 862 | |
| 863 | /* Greybus raw request types */ |
| 864 | #define GB_RAW_TYPE_SEND 0x02 |
| 865 | |
| 866 | struct gb_raw_send_request { |
| 867 | __le32 len; |
| 868 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 869 | } __packed; |
Viresh Kumar | d65e3a2 | 2015-08-13 10:04:45 +0530 | [diff] [blame] | 870 | |
| 871 | |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 872 | /* UART */ |
| 873 | |
| 874 | /* Version of the Greybus UART protocol we support */ |
| 875 | #define GB_UART_VERSION_MAJOR 0x00 |
| 876 | #define GB_UART_VERSION_MINOR 0x01 |
| 877 | |
| 878 | /* Greybus UART operation types */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 879 | #define GB_UART_TYPE_SEND_DATA 0x02 |
| 880 | #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */ |
| 881 | #define GB_UART_TYPE_SET_LINE_CODING 0x04 |
| 882 | #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05 |
Bryan O'Donoghue | a519203 | 2015-07-14 02:10:18 +0100 | [diff] [blame] | 883 | #define GB_UART_TYPE_SEND_BREAK 0x06 |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 884 | #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */ |
| 885 | |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 886 | /* Represents data from AP -> Module */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 887 | struct gb_uart_send_data_request { |
| 888 | __le16 size; |
| 889 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 890 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 891 | |
Bryan O'Donoghue | 802362d | 2015-06-29 18:09:13 +0100 | [diff] [blame] | 892 | /* recv-data-request flags */ |
| 893 | #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */ |
| 894 | #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */ |
| 895 | #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */ |
| 896 | #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */ |
| 897 | |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 898 | /* Represents data from Module -> AP */ |
| 899 | struct gb_uart_recv_data_request { |
| 900 | __le16 size; |
Bryan O'Donoghue | 802362d | 2015-06-29 18:09:13 +0100 | [diff] [blame] | 901 | __u8 flags; |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 902 | __u8 data[0]; |
Johan Hovold | cfc5f2c | 2015-08-01 11:50:39 +0200 | [diff] [blame] | 903 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 904 | |
| 905 | struct gb_uart_set_line_coding_request { |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 906 | __le32 rate; |
| 907 | __u8 format; |
| 908 | #define GB_SERIAL_1_STOP_BITS 0 |
| 909 | #define GB_SERIAL_1_5_STOP_BITS 1 |
| 910 | #define GB_SERIAL_2_STOP_BITS 2 |
| 911 | |
| 912 | __u8 parity; |
| 913 | #define GB_SERIAL_NO_PARITY 0 |
| 914 | #define GB_SERIAL_ODD_PARITY 1 |
| 915 | #define GB_SERIAL_EVEN_PARITY 2 |
| 916 | #define GB_SERIAL_MARK_PARITY 3 |
| 917 | #define GB_SERIAL_SPACE_PARITY 4 |
| 918 | |
| 919 | __u8 data_bits; |
Johan Hovold | cfc5f2c | 2015-08-01 11:50:39 +0200 | [diff] [blame] | 920 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 921 | |
| 922 | /* output control lines */ |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 923 | #define GB_UART_CTRL_DTR 0x01 |
| 924 | #define GB_UART_CTRL_RTS 0x02 |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 925 | |
| 926 | struct gb_uart_set_control_line_state_request { |
Bryan O'Donoghue | ba4b099 | 2015-06-29 18:09:15 +0100 | [diff] [blame] | 927 | __u8 control; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 928 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 929 | |
| 930 | struct gb_uart_set_break_request { |
| 931 | __u8 state; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 932 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 933 | |
| 934 | /* input control lines and line errors */ |
Bryan O'Donoghue | 11fca14 | 2015-06-02 13:40:45 +0100 | [diff] [blame] | 935 | #define GB_UART_CTRL_DCD 0x01 |
| 936 | #define GB_UART_CTRL_DSR 0x02 |
Bryan O'Donoghue | 802362d | 2015-06-29 18:09:13 +0100 | [diff] [blame] | 937 | #define GB_UART_CTRL_RI 0x04 |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 938 | |
| 939 | struct gb_uart_serial_state_request { |
Bryan O'Donoghue | ba4b099 | 2015-06-29 18:09:15 +0100 | [diff] [blame] | 940 | __u8 control; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 941 | } __packed; |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 942 | |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 943 | /* Loopback */ |
| 944 | |
| 945 | /* Version of the Greybus loopback protocol we support */ |
Bryan O'Donoghue | 52af141 | 2015-07-14 00:53:12 +0100 | [diff] [blame] | 946 | #define GB_LOOPBACK_VERSION_MAJOR 0x00 |
| 947 | #define GB_LOOPBACK_VERSION_MINOR 0x01 |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 948 | |
| 949 | /* Greybus loopback request types */ |
Bryan O'Donoghue | 52af141 | 2015-07-14 00:53:12 +0100 | [diff] [blame] | 950 | #define GB_LOOPBACK_TYPE_PING 0x02 |
| 951 | #define GB_LOOPBACK_TYPE_TRANSFER 0x03 |
Bryan O'Donoghue | 384a7a3 | 2015-07-13 20:20:49 +0100 | [diff] [blame] | 952 | #define GB_LOOPBACK_TYPE_SINK 0x04 |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 953 | |
| 954 | struct gb_loopback_transfer_request { |
| 955 | __le32 len; |
| 956 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 957 | } __packed; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 958 | |
| 959 | struct gb_loopback_transfer_response { |
Bryan O'Donoghue | 4a655ad | 2015-09-14 10:48:45 +0100 | [diff] [blame] | 960 | __le32 len; |
Bryan O'Donoghue | 04db334 | 2015-10-12 15:45:05 +0100 | [diff] [blame] | 961 | __le32 reserved0; |
| 962 | __le32 reserved1; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 963 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 964 | } __packed; |
Bryan O'Donoghue | f9f971a | 2015-07-13 20:20:45 +0100 | [diff] [blame] | 965 | |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 966 | /* SDIO */ |
| 967 | /* Version of the Greybus sdio protocol we support */ |
| 968 | #define GB_SDIO_VERSION_MAJOR 0x00 |
| 969 | #define GB_SDIO_VERSION_MINOR 0x01 |
| 970 | |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 971 | /* Greybus SDIO operation types */ |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 972 | #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02 |
| 973 | #define GB_SDIO_TYPE_SET_IOS 0x03 |
| 974 | #define GB_SDIO_TYPE_COMMAND 0x04 |
| 975 | #define GB_SDIO_TYPE_TRANSFER 0x05 |
| 976 | #define GB_SDIO_TYPE_EVENT 0x06 |
| 977 | |
| 978 | /* get caps response: request has no payload */ |
| 979 | struct gb_sdio_get_caps_response { |
| 980 | __le32 caps; |
| 981 | #define GB_SDIO_CAP_NONREMOVABLE 0x00000001 |
| 982 | #define GB_SDIO_CAP_4_BIT_DATA 0x00000002 |
| 983 | #define GB_SDIO_CAP_8_BIT_DATA 0x00000004 |
| 984 | #define GB_SDIO_CAP_MMC_HS 0x00000008 |
| 985 | #define GB_SDIO_CAP_SD_HS 0x00000010 |
| 986 | #define GB_SDIO_CAP_ERASE 0x00000020 |
| 987 | #define GB_SDIO_CAP_1_2V_DDR 0x00000040 |
| 988 | #define GB_SDIO_CAP_1_8V_DDR 0x00000080 |
| 989 | #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100 |
| 990 | #define GB_SDIO_CAP_UHS_SDR12 0x00000200 |
| 991 | #define GB_SDIO_CAP_UHS_SDR25 0x00000400 |
| 992 | #define GB_SDIO_CAP_UHS_SDR50 0x00000800 |
| 993 | #define GB_SDIO_CAP_UHS_SDR104 0x00001000 |
| 994 | #define GB_SDIO_CAP_UHS_DDR50 0x00002000 |
| 995 | #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000 |
| 996 | #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000 |
| 997 | #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000 |
| 998 | #define GB_SDIO_CAP_HS200_1_2V 0x00020000 |
| 999 | #define GB_SDIO_CAP_HS200_1_8V 0x00040000 |
| 1000 | #define GB_SDIO_CAP_HS400_1_2V 0x00080000 |
| 1001 | #define GB_SDIO_CAP_HS400_1_8V 0x00100000 |
| 1002 | |
| 1003 | /* see possible values below at vdd */ |
| 1004 | __le32 ocr; |
| 1005 | __le16 max_blk_count; |
| 1006 | __le16 max_blk_size; |
Rui Miguel Silva | e0f875c | 2015-10-08 12:10:51 +0100 | [diff] [blame] | 1007 | __le32 f_min; |
| 1008 | __le32 f_max; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1009 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1010 | |
| 1011 | /* set ios request: response has no payload */ |
| 1012 | struct gb_sdio_set_ios_request { |
| 1013 | __le32 clock; |
| 1014 | __le32 vdd; |
| 1015 | #define GB_SDIO_VDD_165_195 0x00000001 |
| 1016 | #define GB_SDIO_VDD_20_21 0x00000002 |
| 1017 | #define GB_SDIO_VDD_21_22 0x00000004 |
| 1018 | #define GB_SDIO_VDD_22_23 0x00000008 |
| 1019 | #define GB_SDIO_VDD_23_24 0x00000010 |
| 1020 | #define GB_SDIO_VDD_24_25 0x00000020 |
| 1021 | #define GB_SDIO_VDD_25_26 0x00000040 |
| 1022 | #define GB_SDIO_VDD_26_27 0x00000080 |
| 1023 | #define GB_SDIO_VDD_27_28 0x00000100 |
| 1024 | #define GB_SDIO_VDD_28_29 0x00000200 |
| 1025 | #define GB_SDIO_VDD_29_30 0x00000400 |
| 1026 | #define GB_SDIO_VDD_30_31 0x00000800 |
| 1027 | #define GB_SDIO_VDD_31_32 0x00001000 |
| 1028 | #define GB_SDIO_VDD_32_33 0x00002000 |
| 1029 | #define GB_SDIO_VDD_33_34 0x00004000 |
| 1030 | #define GB_SDIO_VDD_34_35 0x00008000 |
| 1031 | #define GB_SDIO_VDD_35_36 0x00010000 |
| 1032 | |
| 1033 | __u8 bus_mode; |
| 1034 | #define GB_SDIO_BUSMODE_OPENDRAIN 0x00 |
| 1035 | #define GB_SDIO_BUSMODE_PUSHPULL 0x01 |
| 1036 | |
| 1037 | __u8 power_mode; |
| 1038 | #define GB_SDIO_POWER_OFF 0x00 |
| 1039 | #define GB_SDIO_POWER_UP 0x01 |
| 1040 | #define GB_SDIO_POWER_ON 0x02 |
| 1041 | #define GB_SDIO_POWER_UNDEFINED 0x03 |
| 1042 | |
| 1043 | __u8 bus_width; |
| 1044 | #define GB_SDIO_BUS_WIDTH_1 0x00 |
| 1045 | #define GB_SDIO_BUS_WIDTH_4 0x02 |
| 1046 | #define GB_SDIO_BUS_WIDTH_8 0x03 |
| 1047 | |
| 1048 | __u8 timing; |
| 1049 | #define GB_SDIO_TIMING_LEGACY 0x00 |
| 1050 | #define GB_SDIO_TIMING_MMC_HS 0x01 |
| 1051 | #define GB_SDIO_TIMING_SD_HS 0x02 |
| 1052 | #define GB_SDIO_TIMING_UHS_SDR12 0x03 |
| 1053 | #define GB_SDIO_TIMING_UHS_SDR25 0x04 |
| 1054 | #define GB_SDIO_TIMING_UHS_SDR50 0x05 |
| 1055 | #define GB_SDIO_TIMING_UHS_SDR104 0x06 |
| 1056 | #define GB_SDIO_TIMING_UHS_DDR50 0x07 |
| 1057 | #define GB_SDIO_TIMING_MMC_DDR52 0x08 |
| 1058 | #define GB_SDIO_TIMING_MMC_HS200 0x09 |
| 1059 | #define GB_SDIO_TIMING_MMC_HS400 0x0A |
| 1060 | |
| 1061 | __u8 signal_voltage; |
| 1062 | #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00 |
| 1063 | #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01 |
| 1064 | #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02 |
| 1065 | |
| 1066 | __u8 drv_type; |
| 1067 | #define GB_SDIO_SET_DRIVER_TYPE_B 0x00 |
| 1068 | #define GB_SDIO_SET_DRIVER_TYPE_A 0x01 |
| 1069 | #define GB_SDIO_SET_DRIVER_TYPE_C 0x02 |
| 1070 | #define GB_SDIO_SET_DRIVER_TYPE_D 0x03 |
Johan Hovold | 8bbd9ed | 2015-08-01 11:50:40 +0200 | [diff] [blame] | 1071 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1072 | |
| 1073 | /* command request */ |
| 1074 | struct gb_sdio_command_request { |
| 1075 | __u8 cmd; |
| 1076 | __u8 cmd_flags; |
| 1077 | #define GB_SDIO_RSP_NONE 0x00 |
Rui Miguel Silva | ef0cc0e | 2015-07-02 19:11:30 +0100 | [diff] [blame] | 1078 | #define GB_SDIO_RSP_PRESENT 0x01 |
| 1079 | #define GB_SDIO_RSP_136 0x02 |
| 1080 | #define GB_SDIO_RSP_CRC 0x04 |
| 1081 | #define GB_SDIO_RSP_BUSY 0x08 |
| 1082 | #define GB_SDIO_RSP_OPCODE 0x10 |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1083 | |
| 1084 | __u8 cmd_type; |
| 1085 | #define GB_SDIO_CMD_AC 0x00 |
| 1086 | #define GB_SDIO_CMD_ADTC 0x01 |
Rui Miguel Silva | 2d465d5 | 2015-08-20 15:20:17 +0100 | [diff] [blame] | 1087 | #define GB_SDIO_CMD_BC 0x02 |
| 1088 | #define GB_SDIO_CMD_BCR 0x03 |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1089 | |
| 1090 | __le32 cmd_arg; |
Rui Miguel Silva | 10ed193 | 2015-10-15 23:56:51 +0100 | [diff] [blame] | 1091 | __le16 data_blocks; |
| 1092 | __le16 data_blksz; |
Johan Hovold | 8bbd9ed | 2015-08-01 11:50:40 +0200 | [diff] [blame] | 1093 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1094 | |
| 1095 | struct gb_sdio_command_response { |
| 1096 | __le32 resp[4]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1097 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1098 | |
| 1099 | /* transfer request */ |
| 1100 | struct gb_sdio_transfer_request { |
| 1101 | __u8 data_flags; |
| 1102 | #define GB_SDIO_DATA_WRITE 0x01 |
| 1103 | #define GB_SDIO_DATA_READ 0x02 |
| 1104 | #define GB_SDIO_DATA_STREAM 0x04 |
| 1105 | |
| 1106 | __le16 data_blocks; |
| 1107 | __le16 data_blksz; |
| 1108 | __u8 data[0]; |
Johan Hovold | 8bbd9ed | 2015-08-01 11:50:40 +0200 | [diff] [blame] | 1109 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1110 | |
| 1111 | struct gb_sdio_transfer_response { |
| 1112 | __le16 data_blocks; |
| 1113 | __le16 data_blksz; |
| 1114 | __u8 data[0]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1115 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1116 | |
| 1117 | /* event request: generated by module and is defined as unidirectional */ |
| 1118 | struct gb_sdio_event_request { |
| 1119 | __u8 event; |
| 1120 | #define GB_SDIO_CARD_INSERTED 0x01 |
| 1121 | #define GB_SDIO_CARD_REMOVED 0x02 |
| 1122 | #define GB_SDIO_WP 0x04 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1123 | } __packed; |
Rui Miguel Silva | 3b6ecd6 | 2015-06-22 14:03:52 +0100 | [diff] [blame] | 1124 | |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1125 | /* Camera */ |
| 1126 | |
| 1127 | #define GB_CAMERA_VERSION_MAJOR 0x00 |
| 1128 | #define GB_CAMERA_VERSION_MINOR 0x01 |
| 1129 | |
| 1130 | /* Greybus Camera request types */ |
| 1131 | #define GB_CAMERA_TYPE_CAPABILITIES 0x02 |
| 1132 | #define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03 |
| 1133 | #define GB_CAMERA_TYPE_CAPTURE 0x04 |
| 1134 | #define GB_CAMERA_TYPE_FLUSH 0x05 |
| 1135 | #define GB_CAMERA_TYPE_METADATA 0x06 |
| 1136 | |
| 1137 | #define GB_CAMERA_MAX_STREAMS 4 |
| 1138 | #define GB_CAMERA_MAX_SETTINGS_SIZE 8192 |
| 1139 | |
| 1140 | /* Greybus Camera Configure Streams request payload */ |
| 1141 | struct gb_camera_stream_config_request { |
| 1142 | __le16 width; |
| 1143 | __le16 height; |
| 1144 | __le16 format; |
| 1145 | __le16 padding; |
| 1146 | } __packed; |
| 1147 | |
| 1148 | struct gb_camera_configure_streams_request { |
| 1149 | __le16 num_streams; |
| 1150 | __le16 padding; |
| 1151 | struct gb_camera_stream_config_request config[0]; |
| 1152 | } __packed; |
| 1153 | |
| 1154 | /* Greybus Camera Configure Streams response payload */ |
| 1155 | struct gb_camera_stream_config_response { |
| 1156 | __le16 width; |
| 1157 | __le16 height; |
| 1158 | __le16 format; |
| 1159 | __u8 virtual_channel; |
| 1160 | __u8 data_type[2]; |
| 1161 | __u8 padding[3]; |
| 1162 | __le32 max_size; |
| 1163 | } __packed; |
| 1164 | |
| 1165 | struct gb_camera_configure_streams_response { |
| 1166 | __le16 num_streams; |
| 1167 | #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01 |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1168 | __u8 flags; |
| 1169 | __u8 padding; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1170 | struct gb_camera_stream_config_response config[0]; |
| 1171 | } __packed; |
| 1172 | |
| 1173 | /* Greybus Camera Capture request payload - response has no payload */ |
| 1174 | struct gb_camera_capture_request { |
| 1175 | __le32 request_id; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1176 | __u8 streams; |
| 1177 | __u8 padding; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1178 | __le16 num_frames; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1179 | __u8 settings[0]; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1180 | } __packed; |
| 1181 | |
| 1182 | /* Greybus Camera Flush response payload - request has no payload */ |
| 1183 | struct gb_camera_flush_response { |
| 1184 | __le32 request_id; |
| 1185 | } __packed; |
| 1186 | |
| 1187 | /* Greybus Camera Metadata request payload - operation has no response */ |
| 1188 | struct gb_camera_metadata_request { |
| 1189 | __le32 request_id; |
| 1190 | __le16 frame_number; |
| 1191 | __u8 stream; |
| 1192 | __u8 padding; |
Rui Miguel Silva | 8e77c83 | 2015-12-17 19:56:23 +0000 | [diff] [blame] | 1193 | __u8 metadata[0]; |
Laurent Pinchart | e61a2a7 | 2015-12-15 03:18:05 +0200 | [diff] [blame] | 1194 | } __packed; |
| 1195 | |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1196 | /* Lights */ |
| 1197 | |
| 1198 | #define GB_LIGHTS_VERSION_MAJOR 0x00 |
| 1199 | #define GB_LIGHTS_VERSION_MINOR 0x01 |
| 1200 | |
| 1201 | /* Greybus Lights request types */ |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1202 | #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02 |
| 1203 | #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03 |
| 1204 | #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04 |
| 1205 | #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05 |
| 1206 | #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06 |
| 1207 | #define GB_LIGHTS_TYPE_SET_BLINK 0x07 |
| 1208 | #define GB_LIGHTS_TYPE_SET_COLOR 0x08 |
| 1209 | #define GB_LIGHTS_TYPE_SET_FADE 0x09 |
| 1210 | #define GB_LIGHTS_TYPE_EVENT 0x0A |
| 1211 | #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B |
| 1212 | #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C |
| 1213 | #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D |
| 1214 | #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E |
| 1215 | |
| 1216 | /* Greybus Light modes */ |
| 1217 | |
| 1218 | /* |
| 1219 | * if you add any specific mode below, update also the |
| 1220 | * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly |
| 1221 | */ |
| 1222 | #define GB_CHANNEL_MODE_NONE 0x00000000 |
| 1223 | #define GB_CHANNEL_MODE_BATTERY 0x00000001 |
| 1224 | #define GB_CHANNEL_MODE_POWER 0x00000002 |
| 1225 | #define GB_CHANNEL_MODE_WIRELESS 0x00000004 |
| 1226 | #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008 |
| 1227 | #define GB_CHANNEL_MODE_KEYBOARD 0x00000010 |
| 1228 | #define GB_CHANNEL_MODE_BUTTONS 0x00000020 |
| 1229 | #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040 |
| 1230 | #define GB_CHANNEL_MODE_ATTENTION 0x00000080 |
| 1231 | #define GB_CHANNEL_MODE_FLASH 0x00000100 |
| 1232 | #define GB_CHANNEL_MODE_TORCH 0x00000200 |
| 1233 | #define GB_CHANNEL_MODE_INDICATOR 0x00000400 |
| 1234 | |
| 1235 | /* Lights Mode valid bit values */ |
| 1236 | #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF |
| 1237 | #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000 |
| 1238 | |
| 1239 | /* Greybus Light Channels Flags */ |
| 1240 | #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001 |
| 1241 | #define GB_LIGHT_CHANNEL_FADER 0x00000002 |
| 1242 | #define GB_LIGHT_CHANNEL_BLINK 0x00000004 |
| 1243 | |
| 1244 | /* get count of lights in module */ |
| 1245 | struct gb_lights_get_lights_response { |
| 1246 | __u8 lights_count; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1247 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1248 | |
| 1249 | /* light config request payload */ |
| 1250 | struct gb_lights_get_light_config_request { |
| 1251 | __u8 id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1252 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1253 | |
| 1254 | /* light config response payload */ |
| 1255 | struct gb_lights_get_light_config_response { |
| 1256 | __u8 channel_count; |
| 1257 | __u8 name[32]; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1258 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1259 | |
| 1260 | /* channel config request payload */ |
| 1261 | struct gb_lights_get_channel_config_request { |
| 1262 | __u8 light_id; |
| 1263 | __u8 channel_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1264 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1265 | |
| 1266 | /* channel flash config request payload */ |
| 1267 | struct gb_lights_get_channel_flash_config_request { |
| 1268 | __u8 light_id; |
| 1269 | __u8 channel_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1270 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1271 | |
| 1272 | /* channel config response payload */ |
| 1273 | struct gb_lights_get_channel_config_response { |
| 1274 | __u8 max_brightness; |
| 1275 | __le32 flags; |
| 1276 | __le32 color; |
| 1277 | __u8 color_name[32]; |
| 1278 | __le32 mode; |
| 1279 | __u8 mode_name[32]; |
| 1280 | } __packed; |
| 1281 | |
| 1282 | /* channel flash config response payload */ |
| 1283 | struct gb_lights_get_channel_flash_config_response { |
| 1284 | __le32 intensity_min_uA; |
| 1285 | __le32 intensity_max_uA; |
| 1286 | __le32 intensity_step_uA; |
| 1287 | __le32 timeout_min_us; |
| 1288 | __le32 timeout_max_us; |
| 1289 | __le32 timeout_step_us; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1290 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1291 | |
| 1292 | /* blink request payload: response have no payload */ |
| 1293 | struct gb_lights_blink_request { |
| 1294 | __u8 light_id; |
| 1295 | __u8 channel_id; |
| 1296 | __le16 time_on_ms; |
| 1297 | __le16 time_off_ms; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1298 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1299 | |
| 1300 | /* set brightness request payload: response have no payload */ |
| 1301 | struct gb_lights_set_brightness_request { |
| 1302 | __u8 light_id; |
| 1303 | __u8 channel_id; |
| 1304 | __u8 brightness; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1305 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1306 | |
| 1307 | /* set color request payload: response have no payload */ |
| 1308 | struct gb_lights_set_color_request { |
| 1309 | __u8 light_id; |
| 1310 | __u8 channel_id; |
| 1311 | __le32 color; |
| 1312 | } __packed; |
| 1313 | |
| 1314 | /* set fade request payload: response have no payload */ |
| 1315 | struct gb_lights_set_fade_request { |
| 1316 | __u8 light_id; |
| 1317 | __u8 channel_id; |
| 1318 | __u8 fade_in; |
| 1319 | __u8 fade_out; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1320 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1321 | |
| 1322 | /* event request: generated by module */ |
| 1323 | struct gb_lights_event_request { |
| 1324 | __u8 light_id; |
| 1325 | __u8 event; |
| 1326 | #define GB_LIGHTS_LIGHT_CONFIG 0x01 |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1327 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1328 | |
| 1329 | /* set flash intensity request payload: response have no payload */ |
| 1330 | struct gb_lights_set_flash_intensity_request { |
| 1331 | __u8 light_id; |
| 1332 | __u8 channel_id; |
| 1333 | __le32 intensity_uA; |
| 1334 | } __packed; |
| 1335 | |
| 1336 | /* set flash strobe state request payload: response have no payload */ |
| 1337 | struct gb_lights_set_flash_strobe_request { |
| 1338 | __u8 light_id; |
| 1339 | __u8 channel_id; |
| 1340 | __u8 state; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1341 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1342 | |
| 1343 | /* set flash timeout request payload: response have no payload */ |
| 1344 | struct gb_lights_set_flash_timeout_request { |
| 1345 | __u8 light_id; |
| 1346 | __u8 channel_id; |
| 1347 | __le32 timeout_us; |
| 1348 | } __packed; |
| 1349 | |
| 1350 | /* get flash fault request payload */ |
| 1351 | struct gb_lights_get_flash_fault_request { |
| 1352 | __u8 light_id; |
| 1353 | __u8 channel_id; |
Viresh Kumar | b701686 | 2015-08-31 17:21:04 +0530 | [diff] [blame] | 1354 | } __packed; |
Rui Miguel Silva | 2870b52 | 2015-08-14 13:58:19 +0100 | [diff] [blame] | 1355 | |
| 1356 | /* get flash fault response payload */ |
| 1357 | struct gb_lights_get_flash_fault_response { |
| 1358 | __le32 fault; |
| 1359 | #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000 |
| 1360 | #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001 |
| 1361 | #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002 |
| 1362 | #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004 |
| 1363 | #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008 |
| 1364 | #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010 |
| 1365 | #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020 |
| 1366 | #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040 |
| 1367 | #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080 |
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 | |
Alex Elder | 012d7d4 | 2015-05-27 14:45:58 -0500 | [diff] [blame] | 1370 | #endif /* __GREYBUS_PROTOCOLS_H */ |
Bryan O'Donoghue | 4ef5348 | 2015-06-02 13:40:44 +0100 | [diff] [blame] | 1371 | |