blob: 9c628cc5f8e683f73a94a30de3cf69421f19e0ec [file] [log] [blame]
John Stultz453bbea2015-04-09 16:01:31 -07001/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
8 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License version 2 for more details.
18 *
19 * BSD LICENSE
20 *
21 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
22 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 *
28 * * Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 * * Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in
32 * the documentation and/or other materials provided with the
33 * distribution.
34 * * Neither the name of Google Inc. or Linaro Ltd. nor the names of
35 * its contributors may be used to endorse or promote products
36 * derived from this software without specific prior written
37 * permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
43 * LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
45 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
47 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 */
51
Alex Elder012d7d42015-05-27 14:45:58 -050052#ifndef __GREYBUS_PROTOCOLS_H
53#define __GREYBUS_PROTOCOLS_H
John Stultz453bbea2015-04-09 16:01:31 -070054
Viresh Kumarc8dd60d2015-07-21 17:44:12 +053055/* 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 Kumarcdee4f72015-06-22 16:42:26 +053061
Viresh Kumarec320622015-07-21 17:44:13 +053062/*
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 Kumaref5d9492015-07-24 15:32:24 +053067#define GB_SVC_CPORT_ID 0
Viresh Kumarcdee4f72015-06-22 16:42:26 +053068#define GB_CONTROL_BUNDLE_ID 0
Viresh Kumaref5d9492015-07-24 15:32:24 +053069#define GB_CONTROL_CPORT_ID 0
Viresh Kumarcdee4f72015-06-22 16:42:26 +053070
Viresh Kumar6366d732015-07-21 17:44:11 +053071
Viresh Kumare34fae52015-07-29 11:42:54 +053072/*
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 */
93struct 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 Kumarb7016862015-08-31 17:21:04 +053099} __packed;
Viresh Kumarec320622015-07-21 17:44:13 +0530100
101
Viresh Kumar2b11a452015-08-11 07:35:57 +0530102/* Generic request numbers supported by all modules */
103#define GB_REQUEST_TYPE_INVALID 0x00
104#define GB_REQUEST_TYPE_PROTOCOL_VERSION 0x01
105
Johan Hovoldcfb16902015-09-15 10:48:01 +0200106struct gb_protocol_version_request {
107 __u8 major;
108 __u8 minor;
109} __packed;
Viresh Kumare34fae52015-07-29 11:42:54 +0530110
Viresh Kumar6366d732015-07-21 17:44:11 +0530111struct gb_protocol_version_response {
112 __u8 major;
113 __u8 minor;
Viresh Kumarb7016862015-08-31 17:21:04 +0530114} __packed;
Viresh Kumar6366d732015-07-21 17:44:11 +0530115
116/* Control Protocol */
117
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530118/* Greybus control request types */
Johan Hovolde217ae72016-01-19 12:51:14 +0100119#define GB_CONTROL_TYPE_VERSION 0x01
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530120#define GB_CONTROL_TYPE_PROBE_AP 0x02
121#define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
122#define GB_CONTROL_TYPE_GET_MANIFEST 0x04
123#define GB_CONTROL_TYPE_CONNECTED 0x05
124#define GB_CONTROL_TYPE_DISCONNECTED 0x06
Bryan O'Donoghue0bd39ca2016-03-02 16:51:09 +0000125#define GB_CONTROL_TYPE_TIMESYNC_ENABLE 0x07
126#define GB_CONTROL_TYPE_TIMESYNC_DISABLE 0x08
127#define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE 0x09
Viresh Kumard39bf702015-12-28 11:59:01 +0530128#define GB_CONTROL_TYPE_INTERFACE_VERSION 0x0a
Johan Hovoldb807aa72016-01-19 12:51:21 +0100129#define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530130
Johan Hovolde217ae72016-01-19 12:51:14 +0100131struct gb_control_version_request {
132 __u8 major;
133 __u8 minor;
134} __packed;
135
136struct gb_control_version_response {
137 __u8 major;
138 __u8 minor;
139} __packed;
140
Johan Hovoldb807aa72016-01-19 12:51:21 +0100141struct gb_control_bundle_version_request {
142 __u8 bundle_id;
143} __packed;
144
145struct gb_control_bundle_version_response {
146 __u8 major;
147 __u8 minor;
148} __packed;
149
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530150/* Control protocol manifest get size request has no payload*/
151struct gb_control_get_manifest_size_response {
152 __le16 size;
Viresh Kumarb7016862015-08-31 17:21:04 +0530153} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530154
155/* Control protocol manifest get request has no payload */
156struct gb_control_get_manifest_response {
157 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530158} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530159
160/* Control protocol [dis]connected request */
161struct gb_control_connected_request {
162 __le16 cport_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530163} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530164
165struct gb_control_disconnected_request {
166 __le16 cport_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530167} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530168/* Control protocol [dis]connected response has no payload */
169
Viresh Kumard39bf702015-12-28 11:59:01 +0530170/* Control protocol interface version request has no payload */
171struct gb_control_interface_version_response {
172 __le16 major;
173 __le16 minor;
174} __packed;
175
Bryan O'Donoghue177d4a42016-03-02 16:51:08 +0000176#define GB_TIMESYNC_MAX_STROBES 0x04
177
178struct gb_control_timesync_enable_request {
179 __u8 count;
Greg Kroah-Hartman9fa3a9b2016-03-04 18:40:02 -0800180 __le64 frame_time;
181 __le32 strobe_delay;
182 __le32 refclk;
Bryan O'Donoghue177d4a42016-03-02 16:51:08 +0000183} __packed;
184/* timesync enable response has no payload */
185
186struct gb_control_timesync_authoritative_request {
187 __u64 frame_time[GB_TIMESYNC_MAX_STROBES];
188} __packed;
189/* timesync authoritative response has no payload */
Viresh Kumar90f1b612015-08-12 09:19:33 +0530190
Greg Kroah-Hartmane5273382015-12-31 11:14:33 -0800191/* APBridge protocol */
192
193/* request APB1 log */
194#define GB_APB_REQUEST_LOG 0x02
195
196/* request to map a cport to bulk in and bulk out endpoints */
197#define GB_APB_REQUEST_EP_MAPPING 0x03
198
199/* request to get the number of cports available */
200#define GB_APB_REQUEST_CPORT_COUNT 0x04
201
202/* request to reset a cport state */
203#define GB_APB_REQUEST_RESET_CPORT 0x05
204
205/* request to time the latency of messages on a given cport */
206#define GB_APB_REQUEST_LATENCY_TAG_EN 0x06
207#define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07
208
209/* request to control the CSI transmitter */
210#define GB_APB_REQUEST_CSI_TX_CONTROL 0x08
211
Mark Greer4dbf5052016-01-13 14:07:47 -0700212/* request to control the CSI transmitter */
213#define GB_APB_REQUEST_AUDIO_CONTROL 0x09
214
Johan Hovoldaa2a5452016-03-03 13:34:40 +0100215/* vendor requests to enable/disable CPort features */
216#define GB_APB_REQUEST_CPORT_FEAT_EN 0x0b
217#define GB_APB_REQUEST_CPORT_FEAT_DIS 0x0c
Greg Kroah-Hartmane5273382015-12-31 11:14:33 -0800218
Viresh Kumar90f1b612015-08-12 09:19:33 +0530219/* Firmware Protocol */
220
221/* Version of the Greybus firmware protocol we support */
222#define GB_FIRMWARE_VERSION_MAJOR 0x00
223#define GB_FIRMWARE_VERSION_MINOR 0x01
224
225/* Greybus firmware request types */
Johan Hovold8ec589b2016-01-29 15:42:31 +0100226#define GB_FIRMWARE_TYPE_VERSION 0x01
Viresh Kumar90f1b612015-08-12 09:19:33 +0530227#define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02
228#define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03
229#define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04
Viresh Kumar4c9e2282015-09-09 21:08:33 +0530230#define GB_FIRMWARE_TYPE_AP_READY 0x05 /* Request with no-payload */
Viresh Kumarf1e941a2015-11-26 15:33:46 +0530231#define GB_FIRMWARE_TYPE_GET_VID_PID 0x06 /* Request with no-payload */
Viresh Kumar90f1b612015-08-12 09:19:33 +0530232
Eli Sennesh3563ff82015-12-22 17:26:57 -0500233/* FIXME: remove all ES2-specific identifiers from the kernel */
234#define ES2_DDBL1_MFR_ID 0x00000126
235#define ES2_DDBL1_PROD_ID 0x00001000
236
Viresh Kumar90f1b612015-08-12 09:19:33 +0530237/* Greybus firmware boot stages */
238#define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
239#define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */
240#define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
241
242/* Greybus firmware ready to boot status */
243#define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
244#define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
245#define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
246
247/* Max firmware data fetch size in bytes */
248#define GB_FIRMWARE_FETCH_MAX 2000
249
Johan Hovold8ec589b2016-01-29 15:42:31 +0100250struct gb_firmware_version_request {
251 __u8 major;
252 __u8 minor;
253} __packed;
254
255struct gb_firmware_version_response {
256 __u8 major;
257 __u8 minor;
258} __packed;
259
Viresh Kumar90f1b612015-08-12 09:19:33 +0530260/* Firmware protocol firmware size request/response */
261struct gb_firmware_size_request {
262 __u8 stage;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530263} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530264
265struct gb_firmware_size_response {
266 __le32 size;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530267} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530268
269/* Firmware protocol get firmware request/response */
270struct gb_firmware_get_firmware_request {
271 __le32 offset;
272 __le32 size;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530273} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530274
275struct gb_firmware_get_firmware_response {
276 __u8 data[0];
Viresh Kumar829a91e2015-08-31 17:21:03 +0530277} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530278
279/* Firmware protocol Ready to boot request */
280struct gb_firmware_ready_to_boot_request {
Viresh Kumar90f1b612015-08-12 09:19:33 +0530281 __u8 status;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530282} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530283/* Firmware protocol Ready to boot response has no payload */
284
Viresh Kumarf1e941a2015-11-26 15:33:46 +0530285/* Firmware protocol get VID/PID request has no payload */
286struct gb_firmware_get_vid_pid_response {
287 __le32 vendor_id;
288 __le32 product_id;
289} __packed;
290
Viresh Kumar90f1b612015-08-12 09:19:33 +0530291
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000292/* Power Supply */
Viresh Kumarce832942015-08-12 11:51:10 +0530293
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000294/* Version of the Greybus power supply protocol we support */
295#define GB_POWER_SUPPLY_VERSION_MAJOR 0x00
296#define GB_POWER_SUPPLY_VERSION_MINOR 0x01
Viresh Kumarce832942015-08-12 11:51:10 +0530297
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000298/* Greybus power supply request types */
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000299#define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02
300#define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03
301#define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04
302#define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05
303#define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06
304#define GB_POWER_SUPPLY_TYPE_EVENT 0x07
Viresh Kumarce832942015-08-12 11:51:10 +0530305
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000306/* Should match up with battery technologies in linux/power_supply.h */
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000307#define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000
308#define GB_POWER_SUPPLY_TECH_NiMH 0x0001
309#define GB_POWER_SUPPLY_TECH_LION 0x0002
310#define GB_POWER_SUPPLY_TECH_LIPO 0x0003
311#define GB_POWER_SUPPLY_TECH_LiFe 0x0004
312#define GB_POWER_SUPPLY_TECH_NiCd 0x0005
313#define GB_POWER_SUPPLY_TECH_LiMn 0x0006
Viresh Kumarce832942015-08-12 11:51:10 +0530314
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000315/* Should match up with power supply types in linux/power_supply.h */
316#define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000
317#define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001
318#define GB_POWER_SUPPLY_UPS_TYPE 0x0002
319#define GB_POWER_SUPPLY_MAINS_TYPE 0x0003
320#define GB_POWER_SUPPLY_USB_TYPE 0x0004
321#define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005
322#define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006
323#define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007
324
325/* Should match up with power supply health in linux/power_supply.h */
326#define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000
327#define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001
328#define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002
329#define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003
330#define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004
331#define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005
332#define GB_POWER_SUPPLY_HEALTH_COLD 0x0006
333#define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007
334#define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008
335
336/* Should match up with battery status in linux/power_supply.h */
337#define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000
338#define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001
339#define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002
340#define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003
341#define GB_POWER_SUPPLY_STATUS_FULL 0x0004
342
343struct gb_power_supply_get_supplies_response {
344 __u8 supplies_count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530345} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530346
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000347struct gb_power_supply_get_description_request {
348 __u8 psy_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530349} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530350
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000351struct gb_power_supply_get_description_response {
352 __u8 manufacturer[32];
353 __u8 model[32];
354 __u8 serial_number[32];
355 __le16 type;
356 __u8 properties_count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530357} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530358
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000359struct gb_power_supply_props_desc {
360 __u8 property;
361#define GB_POWER_SUPPLY_PROP_STATUS 0x00
362#define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01
363#define GB_POWER_SUPPLY_PROP_HEALTH 0x02
364#define GB_POWER_SUPPLY_PROP_PRESENT 0x03
365#define GB_POWER_SUPPLY_PROP_ONLINE 0x04
366#define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05
367#define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06
368#define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07
369#define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08
370#define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09
371#define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A
372#define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B
373#define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C
374#define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D
375#define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E
376#define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F
377#define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10
378#define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11
379#define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12
380#define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13
381#define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14
382#define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15
383#define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16
384#define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17
385#define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18
386#define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19
387#define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A
388#define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B
389#define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C
390#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D
391#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E
392#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F
393#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20
394#define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21
395#define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22
396#define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23
397#define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24
398#define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25
399#define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26
400#define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27
401#define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28
402#define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29
403#define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A
404#define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B
405#define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C
406#define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D
407#define GB_POWER_SUPPLY_PROP_TEMP 0x2E
408#define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F
409#define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30
410#define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31
411#define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32
412#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33
413#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34
414#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35
415#define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36
416#define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37
417#define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38
418#define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39
419#define GB_POWER_SUPPLY_PROP_TYPE 0x3A
420#define GB_POWER_SUPPLY_PROP_SCOPE 0x3B
421#define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C
422#define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D
423 __u8 is_writeable;
Viresh Kumarb7016862015-08-31 17:21:04 +0530424} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530425
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000426struct gb_power_supply_get_property_descriptors_request {
427 __u8 psy_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530428} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530429
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000430struct gb_power_supply_get_property_descriptors_response {
431 __u8 properties_count;
432 struct gb_power_supply_props_desc props[];
433} __packed;
434
435struct gb_power_supply_get_property_request {
436 __u8 psy_id;
437 __u8 property;
438} __packed;
439
440struct gb_power_supply_get_property_response {
441 __le32 prop_val;
442};
443
444struct gb_power_supply_set_property_request {
445 __u8 psy_id;
446 __u8 property;
447 __le32 prop_val;
448} __packed;
449
450struct gb_power_supply_event_request {
451 __u8 psy_id;
452 __u8 event;
453#define GB_POWER_SUPPLY_UPDATE 0x01
Viresh Kumarb7016862015-08-31 17:21:04 +0530454} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530455
456
Viresh Kumar51aee042015-08-12 11:51:11 +0530457/* HID */
458
459/* Version of the Greybus hid protocol we support */
460#define GB_HID_VERSION_MAJOR 0x00
461#define GB_HID_VERSION_MINOR 0x01
462
463/* Greybus HID operation types */
Viresh Kumar51aee042015-08-12 11:51:11 +0530464#define GB_HID_TYPE_GET_DESC 0x02
465#define GB_HID_TYPE_GET_REPORT_DESC 0x03
466#define GB_HID_TYPE_PWR_ON 0x04
467#define GB_HID_TYPE_PWR_OFF 0x05
468#define GB_HID_TYPE_GET_REPORT 0x06
469#define GB_HID_TYPE_SET_REPORT 0x07
470#define GB_HID_TYPE_IRQ_EVENT 0x08
471
472/* Report type */
473#define GB_HID_INPUT_REPORT 0
474#define GB_HID_OUTPUT_REPORT 1
475#define GB_HID_FEATURE_REPORT 2
476
477/* Different request/response structures */
478/* HID get descriptor response */
479struct gb_hid_desc_response {
480 __u8 bLength;
481 __le16 wReportDescLength;
482 __le16 bcdHID;
483 __le16 wProductID;
484 __le16 wVendorID;
485 __u8 bCountryCode;
486} __packed;
487
488/* HID get report request/response */
489struct gb_hid_get_report_request {
490 __u8 report_type;
491 __u8 report_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530492} __packed;
Viresh Kumar51aee042015-08-12 11:51:11 +0530493
494/* HID set report request */
495struct gb_hid_set_report_request {
496 __u8 report_type;
497 __u8 report_id;
498 __u8 report[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530499} __packed;
Viresh Kumar51aee042015-08-12 11:51:11 +0530500
501/* HID input report request, via interrupt pipe */
502struct gb_hid_input_report_request {
503 __u8 report[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530504} __packed;
Viresh Kumar51aee042015-08-12 11:51:11 +0530505
506
John Stultz453bbea2015-04-09 16:01:31 -0700507/* I2C */
508
509/* Version of the Greybus i2c protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200510#define GB_I2C_VERSION_MAJOR 0x00
511#define GB_I2C_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700512
513/* Greybus i2c request types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200514#define GB_I2C_TYPE_FUNCTIONALITY 0x02
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200515#define GB_I2C_TYPE_TRANSFER 0x05
John Stultz453bbea2015-04-09 16:01:31 -0700516
John Stultz453bbea2015-04-09 16:01:31 -0700517/* functionality request has no payload */
518struct gb_i2c_functionality_response {
519 __le32 functionality;
Viresh Kumarb7016862015-08-31 17:21:04 +0530520} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700521
John Stultz453bbea2015-04-09 16:01:31 -0700522/*
523 * Outgoing data immediately follows the op count and ops array.
524 * The data for each write (master -> slave) op in the array is sent
525 * in order, with no (e.g. pad) bytes separating them.
526 *
527 * Short reads cause the entire transfer request to fail So response
528 * payload consists only of bytes read, and the number of bytes is
529 * exactly what was specified in the corresponding op. Like
530 * outgoing data, the incoming data is in order and contiguous.
531 */
532struct gb_i2c_transfer_op {
533 __le16 addr;
534 __le16 flags;
535 __le16 size;
Viresh Kumarb7016862015-08-31 17:21:04 +0530536} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700537
538struct gb_i2c_transfer_request {
539 __le16 op_count;
540 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
Viresh Kumarb7016862015-08-31 17:21:04 +0530541} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700542struct gb_i2c_transfer_response {
543 __u8 data[0]; /* inbound data */
Viresh Kumarb7016862015-08-31 17:21:04 +0530544} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700545
546
547/* GPIO */
548
549/* Version of the Greybus GPIO protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200550#define GB_GPIO_VERSION_MAJOR 0x00
551#define GB_GPIO_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700552
553/* Greybus GPIO request types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200554#define GB_GPIO_TYPE_LINE_COUNT 0x02
555#define GB_GPIO_TYPE_ACTIVATE 0x03
556#define GB_GPIO_TYPE_DEACTIVATE 0x04
557#define GB_GPIO_TYPE_GET_DIRECTION 0x05
558#define GB_GPIO_TYPE_DIRECTION_IN 0x06
559#define GB_GPIO_TYPE_DIRECTION_OUT 0x07
560#define GB_GPIO_TYPE_GET_VALUE 0x08
561#define GB_GPIO_TYPE_SET_VALUE 0x09
562#define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
John Stultz453bbea2015-04-09 16:01:31 -0700563#define GB_GPIO_TYPE_IRQ_TYPE 0x0b
Johan Hovold47bf0b42015-05-27 12:45:07 +0200564#define GB_GPIO_TYPE_IRQ_MASK 0x0c
565#define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
566#define GB_GPIO_TYPE_IRQ_EVENT 0x0e
John Stultz453bbea2015-04-09 16:01:31 -0700567
Johan Hovold7ba864a2015-05-28 19:03:34 +0200568#define GB_GPIO_IRQ_TYPE_NONE 0x00
569#define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
570#define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
571#define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
572#define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
573#define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
574
John Stultz453bbea2015-04-09 16:01:31 -0700575/* line count request has no payload */
576struct gb_gpio_line_count_response {
577 __u8 count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530578} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700579
580struct gb_gpio_activate_request {
581 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530582} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700583/* activate response has no payload */
584
585struct gb_gpio_deactivate_request {
586 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530587} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700588/* deactivate response has no payload */
589
590struct gb_gpio_get_direction_request {
591 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530592} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700593struct gb_gpio_get_direction_response {
594 __u8 direction;
Viresh Kumarb7016862015-08-31 17:21:04 +0530595} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700596
597struct gb_gpio_direction_in_request {
598 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530599} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700600/* direction in response has no payload */
601
602struct gb_gpio_direction_out_request {
603 __u8 which;
604 __u8 value;
Viresh Kumarb7016862015-08-31 17:21:04 +0530605} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700606/* direction out response has no payload */
607
608struct gb_gpio_get_value_request {
609 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530610} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700611struct gb_gpio_get_value_response {
612 __u8 value;
Viresh Kumarb7016862015-08-31 17:21:04 +0530613} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700614
615struct gb_gpio_set_value_request {
616 __u8 which;
617 __u8 value;
Viresh Kumarb7016862015-08-31 17:21:04 +0530618} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700619/* set value response has no payload */
620
621struct gb_gpio_set_debounce_request {
622 __u8 which;
Johan Hovold5b559e62015-08-01 11:50:41 +0200623 __le16 usec;
624} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700625/* debounce response has no payload */
626
627struct gb_gpio_irq_type_request {
628 __u8 which;
629 __u8 type;
Viresh Kumarb7016862015-08-31 17:21:04 +0530630} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700631/* irq type response has no payload */
632
633struct gb_gpio_irq_mask_request {
634 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530635} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700636/* irq mask response has no payload */
637
638struct gb_gpio_irq_unmask_request {
639 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530640} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700641/* irq unmask response has no payload */
642
John Stultz453bbea2015-04-09 16:01:31 -0700643/* irq event requests originate on another module and are handled on the AP */
644struct gb_gpio_irq_event_request {
645 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530646} __packed;
Johan Hovold1409c4d2015-05-26 15:29:25 +0200647/* irq event has no response */
John Stultz453bbea2015-04-09 16:01:31 -0700648
649
650/* PWM */
651
652/* Version of the Greybus PWM protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200653#define GB_PWM_VERSION_MAJOR 0x00
654#define GB_PWM_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700655
Alex Elder6d653372015-05-07 13:03:52 -0500656/* Greybus PWM operation types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200657#define GB_PWM_TYPE_PWM_COUNT 0x02
658#define GB_PWM_TYPE_ACTIVATE 0x03
659#define GB_PWM_TYPE_DEACTIVATE 0x04
660#define GB_PWM_TYPE_CONFIG 0x05
661#define GB_PWM_TYPE_POLARITY 0x06
662#define GB_PWM_TYPE_ENABLE 0x07
663#define GB_PWM_TYPE_DISABLE 0x08
John Stultz453bbea2015-04-09 16:01:31 -0700664
665/* pwm count request has no payload */
666struct gb_pwm_count_response {
667 __u8 count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530668} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700669
670struct gb_pwm_activate_request {
671 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530672} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700673
674struct gb_pwm_deactivate_request {
675 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530676} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700677
678struct gb_pwm_config_request {
679 __u8 which;
Johan Hovold5b559e62015-08-01 11:50:41 +0200680 __le32 duty;
681 __le32 period;
682} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700683
684struct gb_pwm_polarity_request {
685 __u8 which;
686 __u8 polarity;
Viresh Kumarb7016862015-08-31 17:21:04 +0530687} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700688
689struct gb_pwm_enable_request {
690 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530691} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700692
693struct gb_pwm_disable_request {
694 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530695} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700696
Viresh Kumar4890f312015-05-20 16:33:57 +0530697/* SPI */
698
699/* Version of the Greybus spi protocol we support */
700#define GB_SPI_VERSION_MAJOR 0x00
701#define GB_SPI_VERSION_MINOR 0x01
702
703/* Should match up with modes in linux/spi/spi.h */
704#define GB_SPI_MODE_CPHA 0x01 /* clock phase */
705#define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
706#define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
707#define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
708#define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
709#define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
710#define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
711#define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
712#define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
713#define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
714#define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
715#define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
716
717/* Should match up with flags in linux/spi/spi.h */
718#define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
719#define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
720#define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
721
722/* Greybus spi operation types */
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000723#define GB_SPI_TYPE_MASTER_CONFIG 0x02
724#define GB_SPI_TYPE_DEVICE_CONFIG 0x03
725#define GB_SPI_TYPE_TRANSFER 0x04
Viresh Kumar4890f312015-05-20 16:33:57 +0530726
727/* mode request has no payload */
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000728struct gb_spi_master_config_response {
Viresh Kumar4890f312015-05-20 16:33:57 +0530729 __le32 bits_per_word_mask;
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000730 __le32 min_speed_hz;
731 __le32 max_speed_hz;
732 __le16 mode;
733 __le16 flags;
Rui Miguel Silva50014e02015-12-10 14:24:58 +0000734 __u8 num_chipselect;
Viresh Kumarb7016862015-08-31 17:21:04 +0530735} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530736
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000737struct gb_spi_device_config_request {
Rui Miguel Silva50014e02015-12-10 14:24:58 +0000738 __u8 chip_select;
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000739} __packed;
740
741struct gb_spi_device_config_response {
742 __le16 mode;
743 __u8 bits_per_word;
744 __le32 max_speed_hz;
Rui Miguel Silva02730382016-02-02 14:23:16 +0000745 __u8 device_type;
746#define GB_SPI_SPI_DEV 0x00
747#define GB_SPI_SPI_NOR 0x01
748#define GB_SPI_SPI_MODALIAS 0x02
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000749 __u8 name[32];
Viresh Kumarb7016862015-08-31 17:21:04 +0530750} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530751
752/**
753 * struct gb_spi_transfer - a read/write buffer pair
754 * @speed_hz: Select a speed other than the device default for this transfer. If
755 * 0 the default (from @spi_device) is used.
756 * @len: size of rx and tx buffers (in bytes)
757 * @delay_usecs: microseconds to delay after this transfer before (optionally)
758 * changing the chipselect status, then starting the next transfer or
759 * completing this spi_message.
760 * @cs_change: affects chipselect after this transfer completes
761 * @bits_per_word: select a bits_per_word other than the device default for this
762 * transfer. If 0 the default (from @spi_device) is used.
763 */
764struct gb_spi_transfer {
765 __le32 speed_hz;
766 __le32 len;
767 __le16 delay_usecs;
768 __u8 cs_change;
769 __u8 bits_per_word;
Rui Miguel Silvab455c842015-12-02 11:12:27 +0000770 __u8 rdwr;
771#define GB_SPI_XFER_READ 0x01
772#define GB_SPI_XFER_WRITE 0x02
Viresh Kumarb7016862015-08-31 17:21:04 +0530773} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530774
775struct gb_spi_transfer_request {
776 __u8 chip_select; /* of the spi device */
777 __u8 mode; /* of the spi device */
778 __le16 count;
Johan Hovold46d26c52015-08-01 11:50:37 +0200779 struct gb_spi_transfer transfers[0]; /* count of these */
Viresh Kumarb7016862015-08-31 17:21:04 +0530780} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530781
782struct gb_spi_transfer_response {
783 __u8 data[0]; /* inbound data */
Viresh Kumarb7016862015-08-31 17:21:04 +0530784} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530785
Alex Elder30c6d9d2015-05-22 13:02:08 -0500786/* Version of the Greybus SVC protocol we support */
787#define GB_SVC_VERSION_MAJOR 0x00
788#define GB_SVC_VERSION_MINOR 0x01
789
790/* Greybus SVC request types */
Bryan O'Donoghue0bd39ca2016-03-02 16:51:09 +0000791#define GB_SVC_TYPE_SVC_HELLO 0x02
792#define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
793#define GB_SVC_TYPE_INTF_HOTPLUG 0x04
794#define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
795#define GB_SVC_TYPE_INTF_RESET 0x06
796#define GB_SVC_TYPE_CONN_CREATE 0x07
797#define GB_SVC_TYPE_CONN_DESTROY 0x08
798#define GB_SVC_TYPE_DME_PEER_GET 0x09
799#define GB_SVC_TYPE_DME_PEER_SET 0x0a
800#define GB_SVC_TYPE_ROUTE_CREATE 0x0b
801#define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
802#define GB_SVC_TYPE_TIMESYNC_ENABLE 0x0d
803#define GB_SVC_TYPE_TIMESYNC_DISABLE 0x0e
804#define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE 0x0f
805#define GB_SVC_TYPE_INTF_SET_PWRM 0x10
806#define GB_SVC_TYPE_INTF_EJECT 0x11
807#define GB_SVC_TYPE_KEY_EVENT 0x12
808#define GB_SVC_TYPE_PING 0x13
Viresh Kumaread35462015-07-21 17:44:19 +0530809
Johan Hovoldcfb16902015-09-15 10:48:01 +0200810/*
811 * SVC version request/response has the same payload as
812 * gb_protocol_version_request/response.
813 */
Viresh Kumaread35462015-07-21 17:44:19 +0530814
815/* SVC protocol hello request */
816struct gb_svc_hello_request {
817 __le16 endo_id;
818 __u8 interface_id;
Johan Hovold2130f092015-08-01 11:50:38 +0200819} __packed;
Viresh Kumaread35462015-07-21 17:44:19 +0530820/* hello response has no payload */
Alex Elder30c6d9d2015-05-22 13:02:08 -0500821
822struct gb_svc_intf_device_id_request {
823 __u8 intf_id;
824 __u8 device_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530825} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500826/* device id response has no payload */
827
828struct gb_svc_intf_hotplug_request {
829 __u8 intf_id;
830 struct {
Viresh Kumarb32a5c52015-12-22 22:04:33 +0530831 __le32 ddbl1_mfr_id;
832 __le32 ddbl1_prod_id;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500833 __le32 ara_vend_id;
834 __le32 ara_prod_id;
Viresh Kumar57c6bcc2015-12-28 11:59:00 +0530835 __le64 serial_number;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500836 } data;
Johan Hovold2130f092015-08-01 11:50:38 +0200837} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500838/* hotplug response has no payload */
839
840struct gb_svc_intf_hot_unplug_request {
841 __u8 intf_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530842} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500843/* hot unplug response has no payload */
844
845struct gb_svc_intf_reset_request {
846 __u8 intf_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530847} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500848/* interface reset response has no payload */
849
Rui Miguel Silvac5d55fb2016-01-11 13:46:31 +0000850struct gb_svc_intf_eject_request {
851 __u8 intf_id;
852} __packed;
853/* interface eject response has no payload */
854
Alex Elder30c6d9d2015-05-22 13:02:08 -0500855struct gb_svc_conn_create_request {
856 __u8 intf1_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100857 __le16 cport1_id;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500858 __u8 intf2_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100859 __le16 cport2_id;
Perry Hung0b226492015-07-24 19:02:34 -0400860 __u8 tc;
861 __u8 flags;
Johan Hovold2130f092015-08-01 11:50:38 +0200862} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500863/* connection create response has no payload */
864
865struct gb_svc_conn_destroy_request {
866 __u8 intf1_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100867 __le16 cport1_id;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500868 __u8 intf2_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100869 __le16 cport2_id;
Johan Hovold2130f092015-08-01 11:50:38 +0200870} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500871/* connection destroy response has no payload */
872
Viresh Kumar19151c32015-09-09 21:08:29 +0530873struct gb_svc_dme_peer_get_request {
874 __u8 intf_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100875 __le16 attr;
876 __le16 selector;
Viresh Kumar19151c32015-09-09 21:08:29 +0530877} __packed;
878
879struct gb_svc_dme_peer_get_response {
Rui Miguel Silva24980502015-09-15 15:33:51 +0100880 __le16 result_code;
881 __le32 attr_value;
Viresh Kumar19151c32015-09-09 21:08:29 +0530882} __packed;
883
884struct gb_svc_dme_peer_set_request {
885 __u8 intf_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100886 __le16 attr;
887 __le16 selector;
888 __le32 value;
Viresh Kumar19151c32015-09-09 21:08:29 +0530889} __packed;
890
891struct gb_svc_dme_peer_set_response {
Rui Miguel Silva24980502015-09-15 15:33:51 +0100892 __le16 result_code;
Viresh Kumar19151c32015-09-09 21:08:29 +0530893} __packed;
894
Viresh Kumar6bec5c72015-09-24 14:40:29 -0700895/* Attributes for peer get/set operations */
896#define DME_ATTR_SELECTOR_INDEX 0
Eli Sennesh3563ff82015-12-22 17:26:57 -0500897/* FIXME: remove ES2 support and DME_ATTR_T_TST_SRC_INCREMENT */
Viresh Kumar6bec5c72015-09-24 14:40:29 -0700898#define DME_ATTR_T_TST_SRC_INCREMENT 0x4083
Eli Sennesh3563ff82015-12-22 17:26:57 -0500899#define DME_ATTR_ES3_INIT_STATUS 0x6101
Viresh Kumar6bec5c72015-09-24 14:40:29 -0700900
Eli Sennesh3563ff82015-12-22 17:26:57 -0500901/* Return value from init-status attributes listed above */
902#define DME_DIS_SPI_BOOT_STARTED 0x02
903#define DME_DIS_TRUSTED_SPI_BOOT_FINISHED 0x03
904#define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED 0x04
905#define DME_DIS_UNIPRO_BOOT_STARTED 0x06
906#define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED 0x09
Viresh Kumar1575ef12015-10-07 15:40:24 -0400907
Perry Hunge08aaa42015-07-24 19:02:31 -0400908struct gb_svc_route_create_request {
909 __u8 intf1_id;
910 __u8 dev1_id;
911 __u8 intf2_id;
912 __u8 dev2_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530913} __packed;
Viresh Kumard6ec7872015-08-31 17:21:02 +0530914/* route create response has no payload */
Perry Hunge08aaa42015-07-24 19:02:31 -0400915
Viresh Kumar0a020572015-09-07 18:05:26 +0530916struct gb_svc_route_destroy_request {
917 __u8 intf1_id;
918 __u8 intf2_id;
919} __packed;
920/* route destroy response has no payload */
921
Bryan O'Donoghue177d4a42016-03-02 16:51:08 +0000922struct gb_svc_timesync_enable_request {
923 __u8 count;
924 __u64 frame_time;
925 __u32 strobe_delay;
926 __u32 strobe_mask;
927 __u32 refclk;
928} __packed;
929/* timesync enable response has no payload */
930
931/* timesync authoritative request has no payload */
932struct gb_svc_timesync_authoritative_response {
933 __u64 frame_time[GB_TIMESYNC_MAX_STROBES];
934};
935
Laurent Pinchartaab4a1a2016-01-06 16:16:46 +0200936#define GB_SVC_UNIPRO_FAST_MODE 0x01
937#define GB_SVC_UNIPRO_SLOW_MODE 0x02
938#define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04
939#define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05
940#define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07
941#define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11
942#define GB_SVC_UNIPRO_OFF_MODE 0x12
943
944#define GB_SVC_PWRM_RXTERMINATION 0x01
945#define GB_SVC_PWRM_TXTERMINATION 0x02
946#define GB_SVC_PWRM_LINE_RESET 0x04
947#define GB_SVC_PWRM_SCRAMBLING 0x20
948
949#define GB_SVC_PWRM_QUIRK_HSSER 0x00000001
950
951#define GB_SVC_UNIPRO_HS_SERIES_A 0x01
952#define GB_SVC_UNIPRO_HS_SERIES_B 0x02
953
954struct gb_svc_intf_set_pwrm_request {
955 __u8 intf_id;
956 __u8 hs_series;
957 __u8 tx_mode;
958 __u8 tx_gear;
959 __u8 tx_nlanes;
960 __u8 rx_mode;
961 __u8 rx_gear;
962 __u8 rx_nlanes;
963 __u8 flags;
964 __le32 quirks;
965} __packed;
966
967struct gb_svc_intf_set_pwrm_response {
968 __le16 result_code;
969} __packed;
Viresh Kumard65e3a22015-08-13 10:04:45 +0530970
Rui Miguel Silvaebe99d62016-01-21 01:42:17 +0000971struct gb_svc_key_event_request {
972 __le16 key_code;
973#define GB_KEYCODE_ARA 0x00
974
975 __u8 key_event;
976#define GB_SVC_KEY_RELEASED 0x00
977#define GB_SVC_KEY_PRESSED 0x01
978} __packed;
979
Viresh Kumard65e3a22015-08-13 10:04:45 +0530980/* RAW */
981
982/* Version of the Greybus raw protocol we support */
983#define GB_RAW_VERSION_MAJOR 0x00
984#define GB_RAW_VERSION_MINOR 0x01
985
986/* Greybus raw request types */
987#define GB_RAW_TYPE_SEND 0x02
988
989struct gb_raw_send_request {
990 __le32 len;
991 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530992} __packed;
Viresh Kumard65e3a22015-08-13 10:04:45 +0530993
994
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100995/* UART */
996
997/* Version of the Greybus UART protocol we support */
998#define GB_UART_VERSION_MAJOR 0x00
999#define GB_UART_VERSION_MINOR 0x01
1000
1001/* Greybus UART operation types */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001002#define GB_UART_TYPE_SEND_DATA 0x02
1003#define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
1004#define GB_UART_TYPE_SET_LINE_CODING 0x04
1005#define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
Bryan O'Donoghuea5192032015-07-14 02:10:18 +01001006#define GB_UART_TYPE_SEND_BREAK 0x06
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001007#define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
1008
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001009/* Represents data from AP -> Module */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001010struct gb_uart_send_data_request {
1011 __le16 size;
1012 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301013} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001014
Bryan O'Donoghue802362d2015-06-29 18:09:13 +01001015/* recv-data-request flags */
1016#define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
1017#define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
1018#define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
1019#define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
1020
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001021/* Represents data from Module -> AP */
1022struct gb_uart_recv_data_request {
1023 __le16 size;
Bryan O'Donoghue802362d2015-06-29 18:09:13 +01001024 __u8 flags;
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001025 __u8 data[0];
Johan Hovoldcfc5f2c2015-08-01 11:50:39 +02001026} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001027
1028struct gb_uart_set_line_coding_request {
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001029 __le32 rate;
1030 __u8 format;
1031#define GB_SERIAL_1_STOP_BITS 0
1032#define GB_SERIAL_1_5_STOP_BITS 1
1033#define GB_SERIAL_2_STOP_BITS 2
1034
1035 __u8 parity;
1036#define GB_SERIAL_NO_PARITY 0
1037#define GB_SERIAL_ODD_PARITY 1
1038#define GB_SERIAL_EVEN_PARITY 2
1039#define GB_SERIAL_MARK_PARITY 3
1040#define GB_SERIAL_SPACE_PARITY 4
1041
1042 __u8 data_bits;
Johan Hovoldcfc5f2c2015-08-01 11:50:39 +02001043} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001044
1045/* output control lines */
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001046#define GB_UART_CTRL_DTR 0x01
1047#define GB_UART_CTRL_RTS 0x02
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001048
1049struct gb_uart_set_control_line_state_request {
Bryan O'Donoghueba4b0992015-06-29 18:09:15 +01001050 __u8 control;
Viresh Kumarb7016862015-08-31 17:21:04 +05301051} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001052
1053struct gb_uart_set_break_request {
1054 __u8 state;
Viresh Kumarb7016862015-08-31 17:21:04 +05301055} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001056
1057/* input control lines and line errors */
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001058#define GB_UART_CTRL_DCD 0x01
1059#define GB_UART_CTRL_DSR 0x02
Bryan O'Donoghue802362d2015-06-29 18:09:13 +01001060#define GB_UART_CTRL_RI 0x04
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001061
1062struct gb_uart_serial_state_request {
Bryan O'Donoghueba4b0992015-06-29 18:09:15 +01001063 __u8 control;
Viresh Kumarb7016862015-08-31 17:21:04 +05301064} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001065
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001066/* Loopback */
1067
1068/* Version of the Greybus loopback protocol we support */
Bryan O'Donoghue52af1412015-07-14 00:53:12 +01001069#define GB_LOOPBACK_VERSION_MAJOR 0x00
1070#define GB_LOOPBACK_VERSION_MINOR 0x01
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001071
1072/* Greybus loopback request types */
Bryan O'Donoghue52af1412015-07-14 00:53:12 +01001073#define GB_LOOPBACK_TYPE_PING 0x02
1074#define GB_LOOPBACK_TYPE_TRANSFER 0x03
Bryan O'Donoghue384a7a32015-07-13 20:20:49 +01001075#define GB_LOOPBACK_TYPE_SINK 0x04
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001076
Axel Haslamb59281a2016-02-10 14:19:29 +01001077/*
1078 * Loopback request/response header format should be identical
1079 * to simplify bandwidth and data movement analysis.
1080 */
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001081struct gb_loopback_transfer_request {
1082 __le32 len;
Axel Haslamb59281a2016-02-10 14:19:29 +01001083 __le32 reserved0;
1084 __le32 reserved1;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001085 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301086} __packed;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001087
1088struct gb_loopback_transfer_response {
Bryan O'Donoghue4a655ad2015-09-14 10:48:45 +01001089 __le32 len;
Bryan O'Donoghue04db3342015-10-12 15:45:05 +01001090 __le32 reserved0;
1091 __le32 reserved1;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001092 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301093} __packed;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001094
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001095/* SDIO */
1096/* Version of the Greybus sdio protocol we support */
1097#define GB_SDIO_VERSION_MAJOR 0x00
1098#define GB_SDIO_VERSION_MINOR 0x01
1099
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001100/* Greybus SDIO operation types */
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001101#define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
1102#define GB_SDIO_TYPE_SET_IOS 0x03
1103#define GB_SDIO_TYPE_COMMAND 0x04
1104#define GB_SDIO_TYPE_TRANSFER 0x05
1105#define GB_SDIO_TYPE_EVENT 0x06
1106
1107/* get caps response: request has no payload */
1108struct gb_sdio_get_caps_response {
1109 __le32 caps;
1110#define GB_SDIO_CAP_NONREMOVABLE 0x00000001
1111#define GB_SDIO_CAP_4_BIT_DATA 0x00000002
1112#define GB_SDIO_CAP_8_BIT_DATA 0x00000004
1113#define GB_SDIO_CAP_MMC_HS 0x00000008
1114#define GB_SDIO_CAP_SD_HS 0x00000010
1115#define GB_SDIO_CAP_ERASE 0x00000020
1116#define GB_SDIO_CAP_1_2V_DDR 0x00000040
1117#define GB_SDIO_CAP_1_8V_DDR 0x00000080
1118#define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
1119#define GB_SDIO_CAP_UHS_SDR12 0x00000200
1120#define GB_SDIO_CAP_UHS_SDR25 0x00000400
1121#define GB_SDIO_CAP_UHS_SDR50 0x00000800
1122#define GB_SDIO_CAP_UHS_SDR104 0x00001000
1123#define GB_SDIO_CAP_UHS_DDR50 0x00002000
1124#define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
1125#define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
1126#define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
1127#define GB_SDIO_CAP_HS200_1_2V 0x00020000
1128#define GB_SDIO_CAP_HS200_1_8V 0x00040000
1129#define GB_SDIO_CAP_HS400_1_2V 0x00080000
1130#define GB_SDIO_CAP_HS400_1_8V 0x00100000
1131
1132 /* see possible values below at vdd */
1133 __le32 ocr;
1134 __le16 max_blk_count;
1135 __le16 max_blk_size;
Rui Miguel Silvae0f875c2015-10-08 12:10:51 +01001136 __le32 f_min;
1137 __le32 f_max;
Viresh Kumarb7016862015-08-31 17:21:04 +05301138} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001139
1140/* set ios request: response has no payload */
1141struct gb_sdio_set_ios_request {
1142 __le32 clock;
1143 __le32 vdd;
1144#define GB_SDIO_VDD_165_195 0x00000001
1145#define GB_SDIO_VDD_20_21 0x00000002
1146#define GB_SDIO_VDD_21_22 0x00000004
1147#define GB_SDIO_VDD_22_23 0x00000008
1148#define GB_SDIO_VDD_23_24 0x00000010
1149#define GB_SDIO_VDD_24_25 0x00000020
1150#define GB_SDIO_VDD_25_26 0x00000040
1151#define GB_SDIO_VDD_26_27 0x00000080
1152#define GB_SDIO_VDD_27_28 0x00000100
1153#define GB_SDIO_VDD_28_29 0x00000200
1154#define GB_SDIO_VDD_29_30 0x00000400
1155#define GB_SDIO_VDD_30_31 0x00000800
1156#define GB_SDIO_VDD_31_32 0x00001000
1157#define GB_SDIO_VDD_32_33 0x00002000
1158#define GB_SDIO_VDD_33_34 0x00004000
1159#define GB_SDIO_VDD_34_35 0x00008000
1160#define GB_SDIO_VDD_35_36 0x00010000
1161
1162 __u8 bus_mode;
1163#define GB_SDIO_BUSMODE_OPENDRAIN 0x00
1164#define GB_SDIO_BUSMODE_PUSHPULL 0x01
1165
1166 __u8 power_mode;
1167#define GB_SDIO_POWER_OFF 0x00
1168#define GB_SDIO_POWER_UP 0x01
1169#define GB_SDIO_POWER_ON 0x02
1170#define GB_SDIO_POWER_UNDEFINED 0x03
1171
1172 __u8 bus_width;
1173#define GB_SDIO_BUS_WIDTH_1 0x00
1174#define GB_SDIO_BUS_WIDTH_4 0x02
1175#define GB_SDIO_BUS_WIDTH_8 0x03
1176
1177 __u8 timing;
1178#define GB_SDIO_TIMING_LEGACY 0x00
1179#define GB_SDIO_TIMING_MMC_HS 0x01
1180#define GB_SDIO_TIMING_SD_HS 0x02
1181#define GB_SDIO_TIMING_UHS_SDR12 0x03
1182#define GB_SDIO_TIMING_UHS_SDR25 0x04
1183#define GB_SDIO_TIMING_UHS_SDR50 0x05
1184#define GB_SDIO_TIMING_UHS_SDR104 0x06
1185#define GB_SDIO_TIMING_UHS_DDR50 0x07
1186#define GB_SDIO_TIMING_MMC_DDR52 0x08
1187#define GB_SDIO_TIMING_MMC_HS200 0x09
1188#define GB_SDIO_TIMING_MMC_HS400 0x0A
1189
1190 __u8 signal_voltage;
1191#define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
1192#define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
1193#define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
1194
1195 __u8 drv_type;
1196#define GB_SDIO_SET_DRIVER_TYPE_B 0x00
1197#define GB_SDIO_SET_DRIVER_TYPE_A 0x01
1198#define GB_SDIO_SET_DRIVER_TYPE_C 0x02
1199#define GB_SDIO_SET_DRIVER_TYPE_D 0x03
Johan Hovold8bbd9ed2015-08-01 11:50:40 +02001200} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001201
1202/* command request */
1203struct gb_sdio_command_request {
1204 __u8 cmd;
1205 __u8 cmd_flags;
1206#define GB_SDIO_RSP_NONE 0x00
Rui Miguel Silvaef0cc0e2015-07-02 19:11:30 +01001207#define GB_SDIO_RSP_PRESENT 0x01
1208#define GB_SDIO_RSP_136 0x02
1209#define GB_SDIO_RSP_CRC 0x04
1210#define GB_SDIO_RSP_BUSY 0x08
1211#define GB_SDIO_RSP_OPCODE 0x10
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001212
1213 __u8 cmd_type;
1214#define GB_SDIO_CMD_AC 0x00
1215#define GB_SDIO_CMD_ADTC 0x01
Rui Miguel Silva2d465d52015-08-20 15:20:17 +01001216#define GB_SDIO_CMD_BC 0x02
1217#define GB_SDIO_CMD_BCR 0x03
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001218
1219 __le32 cmd_arg;
Rui Miguel Silva10ed1932015-10-15 23:56:51 +01001220 __le16 data_blocks;
1221 __le16 data_blksz;
Johan Hovold8bbd9ed2015-08-01 11:50:40 +02001222} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001223
1224struct gb_sdio_command_response {
1225 __le32 resp[4];
Viresh Kumarb7016862015-08-31 17:21:04 +05301226} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001227
1228/* transfer request */
1229struct gb_sdio_transfer_request {
1230 __u8 data_flags;
1231#define GB_SDIO_DATA_WRITE 0x01
1232#define GB_SDIO_DATA_READ 0x02
1233#define GB_SDIO_DATA_STREAM 0x04
1234
1235 __le16 data_blocks;
1236 __le16 data_blksz;
1237 __u8 data[0];
Johan Hovold8bbd9ed2015-08-01 11:50:40 +02001238} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001239
1240struct gb_sdio_transfer_response {
1241 __le16 data_blocks;
1242 __le16 data_blksz;
1243 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301244} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001245
1246/* event request: generated by module and is defined as unidirectional */
1247struct gb_sdio_event_request {
1248 __u8 event;
1249#define GB_SDIO_CARD_INSERTED 0x01
1250#define GB_SDIO_CARD_REMOVED 0x02
1251#define GB_SDIO_WP 0x04
Viresh Kumarb7016862015-08-31 17:21:04 +05301252} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001253
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001254/* Camera */
1255
1256#define GB_CAMERA_VERSION_MAJOR 0x00
1257#define GB_CAMERA_VERSION_MINOR 0x01
1258
1259/* Greybus Camera request types */
1260#define GB_CAMERA_TYPE_CAPABILITIES 0x02
1261#define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03
1262#define GB_CAMERA_TYPE_CAPTURE 0x04
1263#define GB_CAMERA_TYPE_FLUSH 0x05
1264#define GB_CAMERA_TYPE_METADATA 0x06
1265
1266#define GB_CAMERA_MAX_STREAMS 4
1267#define GB_CAMERA_MAX_SETTINGS_SIZE 8192
1268
1269/* Greybus Camera Configure Streams request payload */
1270struct gb_camera_stream_config_request {
1271 __le16 width;
1272 __le16 height;
1273 __le16 format;
1274 __le16 padding;
1275} __packed;
1276
1277struct gb_camera_configure_streams_request {
Jacopo Mondib787d412016-01-08 18:13:20 +02001278 __u8 num_streams;
1279 __u8 flags;
1280#define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001281 __le16 padding;
1282 struct gb_camera_stream_config_request config[0];
1283} __packed;
1284
1285/* Greybus Camera Configure Streams response payload */
1286struct gb_camera_stream_config_response {
1287 __le16 width;
1288 __le16 height;
1289 __le16 format;
1290 __u8 virtual_channel;
1291 __u8 data_type[2];
1292 __u8 padding[3];
1293 __le32 max_size;
1294} __packed;
1295
1296struct gb_camera_configure_streams_response {
Jacopo Mondib787d412016-01-08 18:13:20 +02001297 __u8 num_streams;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001298 __u8 flags;
Jacopo Mondib787d412016-01-08 18:13:20 +02001299#define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
Jacopo Mondi446091c2016-02-23 11:22:48 +01001300 __u8 num_lanes;
1301 __u8 padding;
1302 __le32 bus_freq;
1303 __le32 lines_per_second;
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001304 struct gb_camera_stream_config_response config[0];
1305} __packed;
1306
1307/* Greybus Camera Capture request payload - response has no payload */
1308struct gb_camera_capture_request {
1309 __le32 request_id;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001310 __u8 streams;
1311 __u8 padding;
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001312 __le16 num_frames;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001313 __u8 settings[0];
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001314} __packed;
1315
1316/* Greybus Camera Flush response payload - request has no payload */
1317struct gb_camera_flush_response {
1318 __le32 request_id;
1319} __packed;
1320
1321/* Greybus Camera Metadata request payload - operation has no response */
1322struct gb_camera_metadata_request {
1323 __le32 request_id;
1324 __le16 frame_number;
1325 __u8 stream;
1326 __u8 padding;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001327 __u8 metadata[0];
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001328} __packed;
1329
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001330/* Lights */
1331
1332#define GB_LIGHTS_VERSION_MAJOR 0x00
1333#define GB_LIGHTS_VERSION_MINOR 0x01
1334
1335/* Greybus Lights request types */
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001336#define GB_LIGHTS_TYPE_GET_LIGHTS 0x02
1337#define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03
1338#define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04
1339#define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1340#define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06
1341#define GB_LIGHTS_TYPE_SET_BLINK 0x07
1342#define GB_LIGHTS_TYPE_SET_COLOR 0x08
1343#define GB_LIGHTS_TYPE_SET_FADE 0x09
1344#define GB_LIGHTS_TYPE_EVENT 0x0A
1345#define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B
1346#define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C
1347#define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D
1348#define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E
1349
1350/* Greybus Light modes */
1351
1352/*
1353 * if you add any specific mode below, update also the
1354 * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1355 */
1356#define GB_CHANNEL_MODE_NONE 0x00000000
1357#define GB_CHANNEL_MODE_BATTERY 0x00000001
1358#define GB_CHANNEL_MODE_POWER 0x00000002
1359#define GB_CHANNEL_MODE_WIRELESS 0x00000004
1360#define GB_CHANNEL_MODE_BLUETOOTH 0x00000008
1361#define GB_CHANNEL_MODE_KEYBOARD 0x00000010
1362#define GB_CHANNEL_MODE_BUTTONS 0x00000020
1363#define GB_CHANNEL_MODE_NOTIFICATION 0x00000040
1364#define GB_CHANNEL_MODE_ATTENTION 0x00000080
1365#define GB_CHANNEL_MODE_FLASH 0x00000100
1366#define GB_CHANNEL_MODE_TORCH 0x00000200
1367#define GB_CHANNEL_MODE_INDICATOR 0x00000400
1368
1369/* Lights Mode valid bit values */
1370#define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF
1371#define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000
1372
1373/* Greybus Light Channels Flags */
1374#define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001
1375#define GB_LIGHT_CHANNEL_FADER 0x00000002
1376#define GB_LIGHT_CHANNEL_BLINK 0x00000004
1377
1378/* get count of lights in module */
1379struct gb_lights_get_lights_response {
1380 __u8 lights_count;
Viresh Kumarb7016862015-08-31 17:21:04 +05301381} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001382
1383/* light config request payload */
1384struct gb_lights_get_light_config_request {
1385 __u8 id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301386} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001387
1388/* light config response payload */
1389struct gb_lights_get_light_config_response {
1390 __u8 channel_count;
1391 __u8 name[32];
Viresh Kumarb7016862015-08-31 17:21:04 +05301392} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001393
1394/* channel config request payload */
1395struct gb_lights_get_channel_config_request {
1396 __u8 light_id;
1397 __u8 channel_id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301398} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001399
1400/* channel flash config request payload */
1401struct gb_lights_get_channel_flash_config_request {
1402 __u8 light_id;
1403 __u8 channel_id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301404} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001405
1406/* channel config response payload */
1407struct gb_lights_get_channel_config_response {
1408 __u8 max_brightness;
1409 __le32 flags;
1410 __le32 color;
1411 __u8 color_name[32];
1412 __le32 mode;
1413 __u8 mode_name[32];
1414} __packed;
1415
1416/* channel flash config response payload */
1417struct gb_lights_get_channel_flash_config_response {
1418 __le32 intensity_min_uA;
1419 __le32 intensity_max_uA;
1420 __le32 intensity_step_uA;
1421 __le32 timeout_min_us;
1422 __le32 timeout_max_us;
1423 __le32 timeout_step_us;
Viresh Kumarb7016862015-08-31 17:21:04 +05301424} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001425
1426/* blink request payload: response have no payload */
1427struct gb_lights_blink_request {
1428 __u8 light_id;
1429 __u8 channel_id;
1430 __le16 time_on_ms;
1431 __le16 time_off_ms;
Viresh Kumarb7016862015-08-31 17:21:04 +05301432} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001433
1434/* set brightness request payload: response have no payload */
1435struct gb_lights_set_brightness_request {
1436 __u8 light_id;
1437 __u8 channel_id;
1438 __u8 brightness;
Viresh Kumarb7016862015-08-31 17:21:04 +05301439} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001440
1441/* set color request payload: response have no payload */
1442struct gb_lights_set_color_request {
1443 __u8 light_id;
1444 __u8 channel_id;
1445 __le32 color;
1446} __packed;
1447
1448/* set fade request payload: response have no payload */
1449struct gb_lights_set_fade_request {
1450 __u8 light_id;
1451 __u8 channel_id;
1452 __u8 fade_in;
1453 __u8 fade_out;
Viresh Kumarb7016862015-08-31 17:21:04 +05301454} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001455
1456/* event request: generated by module */
1457struct gb_lights_event_request {
1458 __u8 light_id;
1459 __u8 event;
1460#define GB_LIGHTS_LIGHT_CONFIG 0x01
Viresh Kumarb7016862015-08-31 17:21:04 +05301461} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001462
1463/* set flash intensity request payload: response have no payload */
1464struct gb_lights_set_flash_intensity_request {
1465 __u8 light_id;
1466 __u8 channel_id;
1467 __le32 intensity_uA;
1468} __packed;
1469
1470/* set flash strobe state request payload: response have no payload */
1471struct gb_lights_set_flash_strobe_request {
1472 __u8 light_id;
1473 __u8 channel_id;
1474 __u8 state;
Viresh Kumarb7016862015-08-31 17:21:04 +05301475} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001476
1477/* set flash timeout request payload: response have no payload */
1478struct gb_lights_set_flash_timeout_request {
1479 __u8 light_id;
1480 __u8 channel_id;
1481 __le32 timeout_us;
1482} __packed;
1483
1484/* get flash fault request payload */
1485struct gb_lights_get_flash_fault_request {
1486 __u8 light_id;
1487 __u8 channel_id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301488} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001489
1490/* get flash fault response payload */
1491struct gb_lights_get_flash_fault_response {
1492 __le32 fault;
1493#define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000
1494#define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001
1495#define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002
1496#define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004
1497#define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008
1498#define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010
1499#define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020
1500#define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040
1501#define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080
Viresh Kumarb7016862015-08-31 17:21:04 +05301502} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001503
Mark Greerba4144a2016-01-13 14:07:45 -07001504/* Audio */
1505
1506/* Version of the Greybus audio protocol we support */
1507#define GB_AUDIO_VERSION_MAJOR 0x00
1508#define GB_AUDIO_VERSION_MINOR 0x01
1509
1510#define GB_AUDIO_TYPE_PROTOCOL_VERSION 0x01
1511#define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02
1512#define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03
1513#define GB_AUDIO_TYPE_GET_CONTROL 0x04
1514#define GB_AUDIO_TYPE_SET_CONTROL 0x05
1515#define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06
1516#define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07
1517#define GB_AUDIO_TYPE_GET_PCM 0x08
1518#define GB_AUDIO_TYPE_SET_PCM 0x09
1519#define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a
1520#define GB_AUDIO_TYPE_GET_TX_DELAY 0x0b
1521#define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c
1522#define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d
1523#define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e
1524#define GB_AUDIO_TYPE_GET_RX_DELAY 0x0f
1525#define GB_AUDIO_TYPE_ACTIVATE_RX 0x10
1526#define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11
1527#define GB_AUDIO_TYPE_JACK_EVENT 0x12
1528#define GB_AUDIO_TYPE_BUTTON_EVENT 0x13
1529#define GB_AUDIO_TYPE_STREAMING_EVENT 0x14
1530#define GB_AUDIO_TYPE_SEND_DATA 0x15
1531
1532/* Module must be able to buffer 10ms of audio data, minimum */
1533#define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000
1534
1535#define GB_AUDIO_PCM_NAME_MAX 32
1536#define AUDIO_DAI_NAME_MAX 32
1537#define AUDIO_CONTROL_NAME_MAX 32
1538#define AUDIO_CTL_ELEM_NAME_MAX 44
1539#define AUDIO_ENUM_NAME_MAX 64
1540#define AUDIO_WIDGET_NAME_MAX 32
1541
1542/* See SNDRV_PCM_FMTBIT_* in Linux source */
1543#define GB_AUDIO_PCM_FMT_S8 BIT(0)
1544#define GB_AUDIO_PCM_FMT_U8 BIT(1)
1545#define GB_AUDIO_PCM_FMT_S16_LE BIT(2)
1546#define GB_AUDIO_PCM_FMT_S16_BE BIT(3)
1547#define GB_AUDIO_PCM_FMT_U16_LE BIT(4)
1548#define GB_AUDIO_PCM_FMT_U16_BE BIT(5)
1549#define GB_AUDIO_PCM_FMT_S24_LE BIT(6)
1550#define GB_AUDIO_PCM_FMT_S24_BE BIT(7)
1551#define GB_AUDIO_PCM_FMT_U24_LE BIT(8)
1552#define GB_AUDIO_PCM_FMT_U24_BE BIT(9)
1553#define GB_AUDIO_PCM_FMT_S32_LE BIT(10)
1554#define GB_AUDIO_PCM_FMT_S32_BE BIT(11)
1555#define GB_AUDIO_PCM_FMT_U32_LE BIT(12)
1556#define GB_AUDIO_PCM_FMT_U32_BE BIT(13)
1557
1558/* See SNDRV_PCM_RATE_* in Linux source */
1559#define GB_AUDIO_PCM_RATE_5512 BIT(0)
1560#define GB_AUDIO_PCM_RATE_8000 BIT(1)
1561#define GB_AUDIO_PCM_RATE_11025 BIT(2)
1562#define GB_AUDIO_PCM_RATE_16000 BIT(3)
1563#define GB_AUDIO_PCM_RATE_22050 BIT(4)
1564#define GB_AUDIO_PCM_RATE_32000 BIT(5)
1565#define GB_AUDIO_PCM_RATE_44100 BIT(6)
1566#define GB_AUDIO_PCM_RATE_48000 BIT(7)
1567#define GB_AUDIO_PCM_RATE_64000 BIT(8)
1568#define GB_AUDIO_PCM_RATE_88200 BIT(9)
1569#define GB_AUDIO_PCM_RATE_96000 BIT(10)
1570#define GB_AUDIO_PCM_RATE_176400 BIT(11)
1571#define GB_AUDIO_PCM_RATE_192000 BIT(12)
1572
1573#define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1
1574#define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2
1575
1576#define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0)
1577#define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1)
1578
1579/* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
1580#define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01
1581#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02
1582#define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03
1583#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06
1584
1585/* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
1586#define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00
1587#define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01
1588#define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02
1589#define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03
1590#define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04
1591#define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05
1592#define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06
1593
1594/* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
1595#define GB_AUDIO_ACCESS_READ BIT(0)
1596#define GB_AUDIO_ACCESS_WRITE BIT(1)
1597#define GB_AUDIO_ACCESS_VOLATILE BIT(2)
1598#define GB_AUDIO_ACCESS_TIMESTAMP BIT(3)
1599#define GB_AUDIO_ACCESS_TLV_READ BIT(4)
1600#define GB_AUDIO_ACCESS_TLV_WRITE BIT(5)
1601#define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6)
1602#define GB_AUDIO_ACCESS_INACTIVE BIT(7)
1603#define GB_AUDIO_ACCESS_LOCK BIT(8)
1604#define GB_AUDIO_ACCESS_OWNER BIT(9)
1605
1606/* enum snd_soc_dapm_type */
1607#define GB_AUDIO_WIDGET_TYPE_INPUT 0x0
1608#define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1
1609#define GB_AUDIO_WIDGET_TYPE_MUX 0x2
1610#define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3
1611#define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4
1612#define GB_AUDIO_WIDGET_TYPE_MIXER 0x5
1613#define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6
1614#define GB_AUDIO_WIDGET_TYPE_PGA 0x7
1615#define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8
1616#define GB_AUDIO_WIDGET_TYPE_ADC 0x9
1617#define GB_AUDIO_WIDGET_TYPE_DAC 0xa
1618#define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb
1619#define GB_AUDIO_WIDGET_TYPE_MIC 0xc
1620#define GB_AUDIO_WIDGET_TYPE_HP 0xd
1621#define GB_AUDIO_WIDGET_TYPE_SPK 0xe
1622#define GB_AUDIO_WIDGET_TYPE_LINE 0xf
1623#define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10
1624#define GB_AUDIO_WIDGET_TYPE_VMID 0x11
1625#define GB_AUDIO_WIDGET_TYPE_PRE 0x12
1626#define GB_AUDIO_WIDGET_TYPE_POST 0x13
1627#define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14
1628#define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15
1629#define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16
1630#define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17
1631#define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18
1632#define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19
1633#define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a
1634#define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b
1635#define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c
1636
1637#define GB_AUDIO_WIDGET_STATE_DISABLED 0x01
1638#define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02
1639
1640#define GB_AUDIO_JACK_EVENT_INSERTION 0x1
1641#define GB_AUDIO_JACK_EVENT_REMOVAL 0x2
1642
1643#define GB_AUDIO_BUTTON_EVENT_PRESS 0x1
1644#define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2
1645
1646#define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1
1647#define GB_AUDIO_STREAMING_EVENT_HALT 0x2
1648#define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3
1649#define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4
1650#define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5
1651#define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6
1652#define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7
1653#define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8
1654#define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9
1655
1656#define GB_AUDIO_INVALID_INDEX 0xff
1657
1658struct gb_audio_pcm {
1659 __u8 stream_name[GB_AUDIO_PCM_NAME_MAX];
1660 __le32 formats; /* GB_AUDIO_PCM_FMT_* */
1661 __le32 rates; /* GB_AUDIO_PCM_RATE_* */
1662 __u8 chan_min;
1663 __u8 chan_max;
1664 __u8 sig_bits; /* number of bits of content */
1665} __packed;
1666
1667struct gb_audio_dai {
1668 __u8 name[AUDIO_DAI_NAME_MAX];
1669 __le16 data_cport;
1670 struct gb_audio_pcm capture;
1671 struct gb_audio_pcm playback;
1672} __packed;
1673
1674struct gb_audio_integer {
1675 __le32 min;
1676 __le32 max;
1677 __le32 step;
1678} __packed;
1679
1680struct gb_audio_integer64 {
1681 __le64 min;
1682 __le64 max;
1683 __le64 step;
1684} __packed;
1685
1686struct gb_audio_enumerated {
1687 __le32 items;
1688 __le16 names_length;
1689 __u8 names[0];
1690} __packed;
1691
1692struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
1693 __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
1694 __le16 dimen[4];
1695 union {
1696 struct gb_audio_integer integer;
1697 struct gb_audio_integer64 integer64;
1698 struct gb_audio_enumerated enumerated;
1699 } value;
1700} __packed;
1701
1702struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
1703 __le64 timestamp; /* XXX needed? */
1704 union {
1705 __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */
1706 __le64 integer64_value[2];
1707 __le32 enumerated_item[2];
1708 } value;
1709} __packed;
1710
1711struct gb_audio_control {
1712 __u8 name[AUDIO_CONTROL_NAME_MAX];
1713 __u8 id; /* 0-63 */
1714 __u8 iface; /* GB_AUDIO_IFACE_* */
1715 __le16 data_cport;
1716 __le32 access; /* GB_AUDIO_ACCESS_* */
1717 __u8 count; /* count of same elements */
1718 __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */
1719 struct gb_audio_ctl_elem_info info;
1720} __packed;
1721
1722struct gb_audio_widget {
1723 __u8 name[AUDIO_WIDGET_NAME_MAX];
1724 __u8 sname[AUDIO_WIDGET_NAME_MAX];
1725 __u8 id;
1726 __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */
1727 __u8 state; /* GB_AUDIO_WIDGET_STATE_* */
1728 __u8 ncontrols;
1729 struct gb_audio_control ctl[0]; /* 'ncontrols' entries */
1730} __packed;
1731
1732struct gb_audio_route {
1733 __u8 source_id; /* widget id */
1734 __u8 destination_id; /* widget id */
1735 __u8 control_id; /* 0-63 */
1736 __u8 index; /* Selection within the control */
1737} __packed;
1738
1739struct gb_audio_topology {
1740 __u8 num_dais;
1741 __u8 num_controls;
1742 __u8 num_widgets;
1743 __u8 num_routes;
1744 __u32 size_dais;
1745 __u32 size_controls;
1746 __u32 size_widgets;
1747 __u32 size_routes;
1748 /*
1749 * struct gb_audio_dai dai[num_dais];
1750 * struct gb_audio_control controls[num_controls];
1751 * struct gb_audio_widget widgets[num_widgets];
1752 * struct gb_audio_route routes[num_routes];
1753 */
1754 __u8 data[0];
1755} __packed;
1756
1757struct gb_audio_get_topology_size_response {
1758 __le16 size;
1759} __packed;
1760
1761struct gb_audio_get_topology_response {
1762 struct gb_audio_topology topology;
1763} __packed;
1764
1765struct gb_audio_get_control_request {
1766 __u8 control_id;
1767 __u8 index;
1768} __packed;
1769
1770struct gb_audio_get_control_response {
1771 struct gb_audio_ctl_elem_value value;
1772} __packed;
1773
1774struct gb_audio_set_control_request {
1775 __u8 control_id;
1776 __u8 index;
1777 struct gb_audio_ctl_elem_value value;
1778} __packed;
1779
1780struct gb_audio_enable_widget_request {
1781 __u8 widget_id;
1782} __packed;
1783
1784struct gb_audio_disable_widget_request {
1785 __u8 widget_id;
1786} __packed;
1787
1788struct gb_audio_get_pcm_request {
1789 __le16 data_cport;
1790} __packed;
1791
1792struct gb_audio_get_pcm_response {
1793 __le32 format;
1794 __le32 rate;
1795 __u8 channels;
1796 __u8 sig_bits;
1797} __packed;
1798
1799struct gb_audio_set_pcm_request {
1800 __le16 data_cport;
1801 __le32 format;
1802 __le32 rate;
1803 __u8 channels;
1804 __u8 sig_bits;
1805} __packed;
1806
1807struct gb_audio_set_tx_data_size_request {
1808 __le16 data_cport;
1809 __le16 size;
1810} __packed;
1811
1812struct gb_audio_get_tx_delay_request {
1813 __le16 data_cport;
1814} __packed;
1815
1816struct gb_audio_get_tx_delay_response {
1817 __le32 delay;
1818} __packed;
1819
1820struct gb_audio_activate_tx_request {
1821 __le16 data_cport;
1822} __packed;
1823
1824struct gb_audio_deactivate_tx_request {
1825 __le16 data_cport;
1826} __packed;
1827
1828struct gb_audio_set_rx_data_size_request {
1829 __le16 data_cport;
1830 __le16 size;
1831} __packed;
1832
1833struct gb_audio_get_rx_delay_request {
1834 __le16 data_cport;
1835} __packed;
1836
1837struct gb_audio_get_rx_delay_response {
1838 __le32 delay;
1839} __packed;
1840
1841struct gb_audio_activate_rx_request {
1842 __le16 data_cport;
1843} __packed;
1844
1845struct gb_audio_deactivate_rx_request {
1846 __le16 data_cport;
1847} __packed;
1848
1849struct gb_audio_jack_event_request {
1850 __u8 widget_id;
1851 __u8 widget_type;
1852 __u8 event;
1853} __packed;
1854
1855struct gb_audio_button_event_request {
1856 __u8 widget_id;
1857 __u8 button_id;
1858 __u8 event;
1859} __packed;
1860
1861struct gb_audio_streaming_event_request {
1862 __le16 data_cport;
1863 __u8 event;
1864} __packed;
1865
1866struct gb_audio_send_data_request {
1867 __le64 timestamp;
1868 __u8 data[0];
1869} __packed;
1870
Alex Elder012d7d42015-05-27 14:45:58 -05001871#endif /* __GREYBUS_PROTOCOLS_H */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001872