blob: f2839127955535556d9be32c4903c1db2a4071fe [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
Viresh Kumard39bf702015-12-28 11:59:01 +0530125#define GB_CONTROL_TYPE_INTERFACE_VERSION 0x0a
Johan Hovoldb807aa72016-01-19 12:51:21 +0100126#define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530127
Johan Hovolde217ae72016-01-19 12:51:14 +0100128struct gb_control_version_request {
129 __u8 major;
130 __u8 minor;
131} __packed;
132
133struct gb_control_version_response {
134 __u8 major;
135 __u8 minor;
136} __packed;
137
Johan Hovoldb807aa72016-01-19 12:51:21 +0100138struct gb_control_bundle_version_request {
139 __u8 bundle_id;
140} __packed;
141
142struct gb_control_bundle_version_response {
143 __u8 major;
144 __u8 minor;
145} __packed;
146
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530147/* Control protocol manifest get size request has no payload*/
148struct gb_control_get_manifest_size_response {
149 __le16 size;
Viresh Kumarb7016862015-08-31 17:21:04 +0530150} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530151
152/* Control protocol manifest get request has no payload */
153struct gb_control_get_manifest_response {
154 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530155} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530156
157/* Control protocol [dis]connected request */
158struct gb_control_connected_request {
159 __le16 cport_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530160} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530161
162struct gb_control_disconnected_request {
163 __le16 cport_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530164} __packed;
Viresh Kumarcdee4f72015-06-22 16:42:26 +0530165/* Control protocol [dis]connected response has no payload */
166
Viresh Kumard39bf702015-12-28 11:59:01 +0530167/* Control protocol interface version request has no payload */
168struct gb_control_interface_version_response {
169 __le16 major;
170 __le16 minor;
171} __packed;
172
Viresh Kumar90f1b612015-08-12 09:19:33 +0530173
Greg Kroah-Hartmane5273382015-12-31 11:14:33 -0800174/* APBridge protocol */
175
176/* request APB1 log */
177#define GB_APB_REQUEST_LOG 0x02
178
179/* request to map a cport to bulk in and bulk out endpoints */
180#define GB_APB_REQUEST_EP_MAPPING 0x03
181
182/* request to get the number of cports available */
183#define GB_APB_REQUEST_CPORT_COUNT 0x04
184
185/* request to reset a cport state */
186#define GB_APB_REQUEST_RESET_CPORT 0x05
187
188/* request to time the latency of messages on a given cport */
189#define GB_APB_REQUEST_LATENCY_TAG_EN 0x06
190#define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07
191
192/* request to control the CSI transmitter */
193#define GB_APB_REQUEST_CSI_TX_CONTROL 0x08
194
Mark Greer4dbf5052016-01-13 14:07:47 -0700195/* request to control the CSI transmitter */
196#define GB_APB_REQUEST_AUDIO_CONTROL 0x09
197
Fabien Parent48a17302016-02-23 18:46:09 +0100198/* vendor requests to enable/disable FCT tokens flow */
199#define GB_APB_REQUEST_FCT_FLOW_EN 0x0b
200#define GB_APB_REQUEST_FCT_FLOW_DIS 0x0c
Greg Kroah-Hartmane5273382015-12-31 11:14:33 -0800201
Viresh Kumar90f1b612015-08-12 09:19:33 +0530202/* Firmware Protocol */
203
204/* Version of the Greybus firmware protocol we support */
205#define GB_FIRMWARE_VERSION_MAJOR 0x00
206#define GB_FIRMWARE_VERSION_MINOR 0x01
207
208/* Greybus firmware request types */
Johan Hovold8ec589b2016-01-29 15:42:31 +0100209#define GB_FIRMWARE_TYPE_VERSION 0x01
Viresh Kumar90f1b612015-08-12 09:19:33 +0530210#define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02
211#define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03
212#define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04
Viresh Kumar4c9e2282015-09-09 21:08:33 +0530213#define GB_FIRMWARE_TYPE_AP_READY 0x05 /* Request with no-payload */
Viresh Kumarf1e941a2015-11-26 15:33:46 +0530214#define GB_FIRMWARE_TYPE_GET_VID_PID 0x06 /* Request with no-payload */
Viresh Kumar90f1b612015-08-12 09:19:33 +0530215
Eli Sennesh3563ff82015-12-22 17:26:57 -0500216/* FIXME: remove all ES2-specific identifiers from the kernel */
217#define ES2_DDBL1_MFR_ID 0x00000126
218#define ES2_DDBL1_PROD_ID 0x00001000
219
Viresh Kumar90f1b612015-08-12 09:19:33 +0530220/* Greybus firmware boot stages */
221#define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
222#define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */
223#define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
224
225/* Greybus firmware ready to boot status */
226#define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
227#define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
228#define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
229
230/* Max firmware data fetch size in bytes */
231#define GB_FIRMWARE_FETCH_MAX 2000
232
Johan Hovold8ec589b2016-01-29 15:42:31 +0100233struct gb_firmware_version_request {
234 __u8 major;
235 __u8 minor;
236} __packed;
237
238struct gb_firmware_version_response {
239 __u8 major;
240 __u8 minor;
241} __packed;
242
Viresh Kumar90f1b612015-08-12 09:19:33 +0530243/* Firmware protocol firmware size request/response */
244struct gb_firmware_size_request {
245 __u8 stage;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530246} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530247
248struct gb_firmware_size_response {
249 __le32 size;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530250} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530251
252/* Firmware protocol get firmware request/response */
253struct gb_firmware_get_firmware_request {
254 __le32 offset;
255 __le32 size;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530256} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530257
258struct gb_firmware_get_firmware_response {
259 __u8 data[0];
Viresh Kumar829a91e2015-08-31 17:21:03 +0530260} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530261
262/* Firmware protocol Ready to boot request */
263struct gb_firmware_ready_to_boot_request {
Viresh Kumar90f1b612015-08-12 09:19:33 +0530264 __u8 status;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530265} __packed;
Viresh Kumar90f1b612015-08-12 09:19:33 +0530266/* Firmware protocol Ready to boot response has no payload */
267
Viresh Kumarf1e941a2015-11-26 15:33:46 +0530268/* Firmware protocol get VID/PID request has no payload */
269struct gb_firmware_get_vid_pid_response {
270 __le32 vendor_id;
271 __le32 product_id;
272} __packed;
273
Viresh Kumar90f1b612015-08-12 09:19:33 +0530274
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000275/* Power Supply */
Viresh Kumarce832942015-08-12 11:51:10 +0530276
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000277/* Version of the Greybus power supply protocol we support */
278#define GB_POWER_SUPPLY_VERSION_MAJOR 0x00
279#define GB_POWER_SUPPLY_VERSION_MINOR 0x01
Viresh Kumarce832942015-08-12 11:51:10 +0530280
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000281/* Greybus power supply request types */
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000282#define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02
283#define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03
284#define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04
285#define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05
286#define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06
287#define GB_POWER_SUPPLY_TYPE_EVENT 0x07
Viresh Kumarce832942015-08-12 11:51:10 +0530288
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000289/* Should match up with battery technologies in linux/power_supply.h */
Rui Miguel Silva2724be02015-11-12 15:36:00 +0000290#define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000
291#define GB_POWER_SUPPLY_TECH_NiMH 0x0001
292#define GB_POWER_SUPPLY_TECH_LION 0x0002
293#define GB_POWER_SUPPLY_TECH_LIPO 0x0003
294#define GB_POWER_SUPPLY_TECH_LiFe 0x0004
295#define GB_POWER_SUPPLY_TECH_NiCd 0x0005
296#define GB_POWER_SUPPLY_TECH_LiMn 0x0006
Viresh Kumarce832942015-08-12 11:51:10 +0530297
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000298/* Should match up with power supply types in linux/power_supply.h */
299#define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000
300#define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001
301#define GB_POWER_SUPPLY_UPS_TYPE 0x0002
302#define GB_POWER_SUPPLY_MAINS_TYPE 0x0003
303#define GB_POWER_SUPPLY_USB_TYPE 0x0004
304#define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005
305#define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006
306#define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007
307
308/* Should match up with power supply health in linux/power_supply.h */
309#define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000
310#define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001
311#define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002
312#define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003
313#define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004
314#define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005
315#define GB_POWER_SUPPLY_HEALTH_COLD 0x0006
316#define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007
317#define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008
318
319/* Should match up with battery status in linux/power_supply.h */
320#define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000
321#define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001
322#define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002
323#define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003
324#define GB_POWER_SUPPLY_STATUS_FULL 0x0004
325
326struct gb_power_supply_get_supplies_response {
327 __u8 supplies_count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530328} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530329
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000330struct gb_power_supply_get_description_request {
331 __u8 psy_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530332} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530333
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000334struct gb_power_supply_get_description_response {
335 __u8 manufacturer[32];
336 __u8 model[32];
337 __u8 serial_number[32];
338 __le16 type;
339 __u8 properties_count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530340} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530341
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000342struct gb_power_supply_props_desc {
343 __u8 property;
344#define GB_POWER_SUPPLY_PROP_STATUS 0x00
345#define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01
346#define GB_POWER_SUPPLY_PROP_HEALTH 0x02
347#define GB_POWER_SUPPLY_PROP_PRESENT 0x03
348#define GB_POWER_SUPPLY_PROP_ONLINE 0x04
349#define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05
350#define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06
351#define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07
352#define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08
353#define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09
354#define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A
355#define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B
356#define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C
357#define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D
358#define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E
359#define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F
360#define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10
361#define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11
362#define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12
363#define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13
364#define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14
365#define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15
366#define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16
367#define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17
368#define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18
369#define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19
370#define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A
371#define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B
372#define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C
373#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D
374#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E
375#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F
376#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20
377#define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21
378#define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22
379#define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23
380#define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24
381#define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25
382#define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26
383#define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27
384#define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28
385#define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29
386#define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A
387#define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B
388#define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C
389#define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D
390#define GB_POWER_SUPPLY_PROP_TEMP 0x2E
391#define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F
392#define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30
393#define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31
394#define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32
395#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33
396#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34
397#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35
398#define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36
399#define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37
400#define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38
401#define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39
402#define GB_POWER_SUPPLY_PROP_TYPE 0x3A
403#define GB_POWER_SUPPLY_PROP_SCOPE 0x3B
404#define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C
405#define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D
406 __u8 is_writeable;
Viresh Kumarb7016862015-08-31 17:21:04 +0530407} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530408
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000409struct gb_power_supply_get_property_descriptors_request {
410 __u8 psy_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530411} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530412
Rui Miguel Silvaffe2e242015-11-12 15:36:02 +0000413struct gb_power_supply_get_property_descriptors_response {
414 __u8 properties_count;
415 struct gb_power_supply_props_desc props[];
416} __packed;
417
418struct gb_power_supply_get_property_request {
419 __u8 psy_id;
420 __u8 property;
421} __packed;
422
423struct gb_power_supply_get_property_response {
424 __le32 prop_val;
425};
426
427struct gb_power_supply_set_property_request {
428 __u8 psy_id;
429 __u8 property;
430 __le32 prop_val;
431} __packed;
432
433struct gb_power_supply_event_request {
434 __u8 psy_id;
435 __u8 event;
436#define GB_POWER_SUPPLY_UPDATE 0x01
Viresh Kumarb7016862015-08-31 17:21:04 +0530437} __packed;
Viresh Kumarce832942015-08-12 11:51:10 +0530438
439
Viresh Kumar51aee042015-08-12 11:51:11 +0530440/* HID */
441
442/* Version of the Greybus hid protocol we support */
443#define GB_HID_VERSION_MAJOR 0x00
444#define GB_HID_VERSION_MINOR 0x01
445
446/* Greybus HID operation types */
Viresh Kumar51aee042015-08-12 11:51:11 +0530447#define GB_HID_TYPE_GET_DESC 0x02
448#define GB_HID_TYPE_GET_REPORT_DESC 0x03
449#define GB_HID_TYPE_PWR_ON 0x04
450#define GB_HID_TYPE_PWR_OFF 0x05
451#define GB_HID_TYPE_GET_REPORT 0x06
452#define GB_HID_TYPE_SET_REPORT 0x07
453#define GB_HID_TYPE_IRQ_EVENT 0x08
454
455/* Report type */
456#define GB_HID_INPUT_REPORT 0
457#define GB_HID_OUTPUT_REPORT 1
458#define GB_HID_FEATURE_REPORT 2
459
460/* Different request/response structures */
461/* HID get descriptor response */
462struct gb_hid_desc_response {
463 __u8 bLength;
464 __le16 wReportDescLength;
465 __le16 bcdHID;
466 __le16 wProductID;
467 __le16 wVendorID;
468 __u8 bCountryCode;
469} __packed;
470
471/* HID get report request/response */
472struct gb_hid_get_report_request {
473 __u8 report_type;
474 __u8 report_id;
Viresh Kumarb7016862015-08-31 17:21:04 +0530475} __packed;
Viresh Kumar51aee042015-08-12 11:51:11 +0530476
477/* HID set report request */
478struct gb_hid_set_report_request {
479 __u8 report_type;
480 __u8 report_id;
481 __u8 report[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530482} __packed;
Viresh Kumar51aee042015-08-12 11:51:11 +0530483
484/* HID input report request, via interrupt pipe */
485struct gb_hid_input_report_request {
486 __u8 report[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530487} __packed;
Viresh Kumar51aee042015-08-12 11:51:11 +0530488
489
John Stultz453bbea2015-04-09 16:01:31 -0700490/* I2C */
491
492/* Version of the Greybus i2c protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200493#define GB_I2C_VERSION_MAJOR 0x00
494#define GB_I2C_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700495
496/* Greybus i2c request types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200497#define GB_I2C_TYPE_FUNCTIONALITY 0x02
498#define GB_I2C_TYPE_TIMEOUT 0x03
499#define GB_I2C_TYPE_RETRIES 0x04
500#define GB_I2C_TYPE_TRANSFER 0x05
John Stultz453bbea2015-04-09 16:01:31 -0700501
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200502#define GB_I2C_RETRIES_DEFAULT 3
503#define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
John Stultz453bbea2015-04-09 16:01:31 -0700504
505/* functionality request has no payload */
506struct gb_i2c_functionality_response {
507 __le32 functionality;
Viresh Kumarb7016862015-08-31 17:21:04 +0530508} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700509
510struct gb_i2c_timeout_request {
511 __le16 msec;
Viresh Kumarb7016862015-08-31 17:21:04 +0530512} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700513/* timeout response has no payload */
514
515struct gb_i2c_retries_request {
516 __u8 retries;
Viresh Kumarb7016862015-08-31 17:21:04 +0530517} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700518/* retries response has no payload */
519
520/*
521 * Outgoing data immediately follows the op count and ops array.
522 * The data for each write (master -> slave) op in the array is sent
523 * in order, with no (e.g. pad) bytes separating them.
524 *
525 * Short reads cause the entire transfer request to fail So response
526 * payload consists only of bytes read, and the number of bytes is
527 * exactly what was specified in the corresponding op. Like
528 * outgoing data, the incoming data is in order and contiguous.
529 */
530struct gb_i2c_transfer_op {
531 __le16 addr;
532 __le16 flags;
533 __le16 size;
Viresh Kumarb7016862015-08-31 17:21:04 +0530534} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700535
536struct gb_i2c_transfer_request {
537 __le16 op_count;
538 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
Viresh Kumarb7016862015-08-31 17:21:04 +0530539} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700540struct gb_i2c_transfer_response {
541 __u8 data[0]; /* inbound data */
Viresh Kumarb7016862015-08-31 17:21:04 +0530542} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700543
544
545/* GPIO */
546
547/* Version of the Greybus GPIO protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200548#define GB_GPIO_VERSION_MAJOR 0x00
549#define GB_GPIO_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700550
551/* Greybus GPIO request types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200552#define GB_GPIO_TYPE_LINE_COUNT 0x02
553#define GB_GPIO_TYPE_ACTIVATE 0x03
554#define GB_GPIO_TYPE_DEACTIVATE 0x04
555#define GB_GPIO_TYPE_GET_DIRECTION 0x05
556#define GB_GPIO_TYPE_DIRECTION_IN 0x06
557#define GB_GPIO_TYPE_DIRECTION_OUT 0x07
558#define GB_GPIO_TYPE_GET_VALUE 0x08
559#define GB_GPIO_TYPE_SET_VALUE 0x09
560#define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
John Stultz453bbea2015-04-09 16:01:31 -0700561#define GB_GPIO_TYPE_IRQ_TYPE 0x0b
Johan Hovold47bf0b42015-05-27 12:45:07 +0200562#define GB_GPIO_TYPE_IRQ_MASK 0x0c
563#define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
564#define GB_GPIO_TYPE_IRQ_EVENT 0x0e
John Stultz453bbea2015-04-09 16:01:31 -0700565
Johan Hovold7ba864a2015-05-28 19:03:34 +0200566#define GB_GPIO_IRQ_TYPE_NONE 0x00
567#define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
568#define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
569#define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
570#define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
571#define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
572
John Stultz453bbea2015-04-09 16:01:31 -0700573/* line count request has no payload */
574struct gb_gpio_line_count_response {
575 __u8 count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530576} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700577
578struct gb_gpio_activate_request {
579 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530580} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700581/* activate response has no payload */
582
583struct gb_gpio_deactivate_request {
584 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530585} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700586/* deactivate response has no payload */
587
588struct gb_gpio_get_direction_request {
589 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530590} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700591struct gb_gpio_get_direction_response {
592 __u8 direction;
Viresh Kumarb7016862015-08-31 17:21:04 +0530593} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700594
595struct gb_gpio_direction_in_request {
596 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530597} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700598/* direction in response has no payload */
599
600struct gb_gpio_direction_out_request {
601 __u8 which;
602 __u8 value;
Viresh Kumarb7016862015-08-31 17:21:04 +0530603} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700604/* direction out response has no payload */
605
606struct gb_gpio_get_value_request {
607 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530608} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700609struct gb_gpio_get_value_response {
610 __u8 value;
Viresh Kumarb7016862015-08-31 17:21:04 +0530611} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700612
613struct gb_gpio_set_value_request {
614 __u8 which;
615 __u8 value;
Viresh Kumarb7016862015-08-31 17:21:04 +0530616} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700617/* set value response has no payload */
618
619struct gb_gpio_set_debounce_request {
620 __u8 which;
Johan Hovold5b559e62015-08-01 11:50:41 +0200621 __le16 usec;
622} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700623/* debounce response has no payload */
624
625struct gb_gpio_irq_type_request {
626 __u8 which;
627 __u8 type;
Viresh Kumarb7016862015-08-31 17:21:04 +0530628} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700629/* irq type response has no payload */
630
631struct gb_gpio_irq_mask_request {
632 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530633} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700634/* irq mask response has no payload */
635
636struct gb_gpio_irq_unmask_request {
637 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530638} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700639/* irq unmask response has no payload */
640
John Stultz453bbea2015-04-09 16:01:31 -0700641/* irq event requests originate on another module and are handled on the AP */
642struct gb_gpio_irq_event_request {
643 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530644} __packed;
Johan Hovold1409c4d2015-05-26 15:29:25 +0200645/* irq event has no response */
John Stultz453bbea2015-04-09 16:01:31 -0700646
647
648/* PWM */
649
650/* Version of the Greybus PWM protocol we support */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200651#define GB_PWM_VERSION_MAJOR 0x00
652#define GB_PWM_VERSION_MINOR 0x01
John Stultz453bbea2015-04-09 16:01:31 -0700653
Alex Elder6d653372015-05-07 13:03:52 -0500654/* Greybus PWM operation types */
Greg Kroah-Hartman67c920b2015-04-10 11:18:49 +0200655#define GB_PWM_TYPE_PWM_COUNT 0x02
656#define GB_PWM_TYPE_ACTIVATE 0x03
657#define GB_PWM_TYPE_DEACTIVATE 0x04
658#define GB_PWM_TYPE_CONFIG 0x05
659#define GB_PWM_TYPE_POLARITY 0x06
660#define GB_PWM_TYPE_ENABLE 0x07
661#define GB_PWM_TYPE_DISABLE 0x08
John Stultz453bbea2015-04-09 16:01:31 -0700662
663/* pwm count request has no payload */
664struct gb_pwm_count_response {
665 __u8 count;
Viresh Kumarb7016862015-08-31 17:21:04 +0530666} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700667
668struct gb_pwm_activate_request {
669 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530670} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700671
672struct gb_pwm_deactivate_request {
673 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530674} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700675
676struct gb_pwm_config_request {
677 __u8 which;
Johan Hovold5b559e62015-08-01 11:50:41 +0200678 __le32 duty;
679 __le32 period;
680} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700681
682struct gb_pwm_polarity_request {
683 __u8 which;
684 __u8 polarity;
Viresh Kumarb7016862015-08-31 17:21:04 +0530685} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700686
687struct gb_pwm_enable_request {
688 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530689} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700690
691struct gb_pwm_disable_request {
692 __u8 which;
Viresh Kumarb7016862015-08-31 17:21:04 +0530693} __packed;
John Stultz453bbea2015-04-09 16:01:31 -0700694
Viresh Kumar4890f312015-05-20 16:33:57 +0530695/* SPI */
696
697/* Version of the Greybus spi protocol we support */
698#define GB_SPI_VERSION_MAJOR 0x00
699#define GB_SPI_VERSION_MINOR 0x01
700
701/* Should match up with modes in linux/spi/spi.h */
702#define GB_SPI_MODE_CPHA 0x01 /* clock phase */
703#define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
704#define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
705#define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
706#define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
707#define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
708#define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
709#define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
710#define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
711#define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
712#define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
713#define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
714
715/* Should match up with flags in linux/spi/spi.h */
716#define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
717#define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
718#define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
719
720/* Greybus spi operation types */
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000721#define GB_SPI_TYPE_MASTER_CONFIG 0x02
722#define GB_SPI_TYPE_DEVICE_CONFIG 0x03
723#define GB_SPI_TYPE_TRANSFER 0x04
Viresh Kumar4890f312015-05-20 16:33:57 +0530724
725/* mode request has no payload */
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000726struct gb_spi_master_config_response {
Viresh Kumar4890f312015-05-20 16:33:57 +0530727 __le32 bits_per_word_mask;
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000728 __le32 min_speed_hz;
729 __le32 max_speed_hz;
730 __le16 mode;
731 __le16 flags;
Rui Miguel Silva50014e02015-12-10 14:24:58 +0000732 __u8 num_chipselect;
Viresh Kumarb7016862015-08-31 17:21:04 +0530733} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530734
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000735struct gb_spi_device_config_request {
Rui Miguel Silva50014e02015-12-10 14:24:58 +0000736 __u8 chip_select;
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000737} __packed;
738
739struct gb_spi_device_config_response {
740 __le16 mode;
741 __u8 bits_per_word;
742 __le32 max_speed_hz;
Rui Miguel Silva02730382016-02-02 14:23:16 +0000743 __u8 device_type;
744#define GB_SPI_SPI_DEV 0x00
745#define GB_SPI_SPI_NOR 0x01
746#define GB_SPI_SPI_MODALIAS 0x02
Rui Miguel Silvab343f6a2015-12-02 11:12:28 +0000747 __u8 name[32];
Viresh Kumarb7016862015-08-31 17:21:04 +0530748} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530749
750/**
751 * struct gb_spi_transfer - a read/write buffer pair
752 * @speed_hz: Select a speed other than the device default for this transfer. If
753 * 0 the default (from @spi_device) is used.
754 * @len: size of rx and tx buffers (in bytes)
755 * @delay_usecs: microseconds to delay after this transfer before (optionally)
756 * changing the chipselect status, then starting the next transfer or
757 * completing this spi_message.
758 * @cs_change: affects chipselect after this transfer completes
759 * @bits_per_word: select a bits_per_word other than the device default for this
760 * transfer. If 0 the default (from @spi_device) is used.
761 */
762struct gb_spi_transfer {
763 __le32 speed_hz;
764 __le32 len;
765 __le16 delay_usecs;
766 __u8 cs_change;
767 __u8 bits_per_word;
Rui Miguel Silvab455c842015-12-02 11:12:27 +0000768 __u8 rdwr;
769#define GB_SPI_XFER_READ 0x01
770#define GB_SPI_XFER_WRITE 0x02
Viresh Kumarb7016862015-08-31 17:21:04 +0530771} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530772
773struct gb_spi_transfer_request {
774 __u8 chip_select; /* of the spi device */
775 __u8 mode; /* of the spi device */
776 __le16 count;
Johan Hovold46d26c52015-08-01 11:50:37 +0200777 struct gb_spi_transfer transfers[0]; /* count of these */
Viresh Kumarb7016862015-08-31 17:21:04 +0530778} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530779
780struct gb_spi_transfer_response {
781 __u8 data[0]; /* inbound data */
Viresh Kumarb7016862015-08-31 17:21:04 +0530782} __packed;
Viresh Kumar4890f312015-05-20 16:33:57 +0530783
Alex Elder30c6d9d2015-05-22 13:02:08 -0500784/* Version of the Greybus SVC protocol we support */
785#define GB_SVC_VERSION_MAJOR 0x00
786#define GB_SVC_VERSION_MINOR 0x01
787
788/* Greybus SVC request types */
Viresh Kumaread35462015-07-21 17:44:19 +0530789#define GB_SVC_TYPE_SVC_HELLO 0x02
790#define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
791#define GB_SVC_TYPE_INTF_HOTPLUG 0x04
792#define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
793#define GB_SVC_TYPE_INTF_RESET 0x06
794#define GB_SVC_TYPE_CONN_CREATE 0x07
795#define GB_SVC_TYPE_CONN_DESTROY 0x08
Viresh Kumar19151c32015-09-09 21:08:29 +0530796#define GB_SVC_TYPE_DME_PEER_GET 0x09
797#define GB_SVC_TYPE_DME_PEER_SET 0x0a
Perry Hunge08aaa42015-07-24 19:02:31 -0400798#define GB_SVC_TYPE_ROUTE_CREATE 0x0b
Viresh Kumar0a020572015-09-07 18:05:26 +0530799#define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
Laurent Pinchartaab4a1a2016-01-06 16:16:46 +0200800#define GB_SVC_TYPE_INTF_SET_PWRM 0x10
Rui Miguel Silvac5d55fb2016-01-11 13:46:31 +0000801#define GB_SVC_TYPE_INTF_EJECT 0x11
Rui Miguel Silvaebe99d62016-01-21 01:42:17 +0000802#define GB_SVC_TYPE_KEY_EVENT 0x12
Greg Kroah-Hartman55ec09e2016-01-19 23:30:42 -0800803#define GB_SVC_TYPE_PING 0x13
Viresh Kumaread35462015-07-21 17:44:19 +0530804
Johan Hovoldcfb16902015-09-15 10:48:01 +0200805/*
806 * SVC version request/response has the same payload as
807 * gb_protocol_version_request/response.
808 */
Viresh Kumaread35462015-07-21 17:44:19 +0530809
810/* SVC protocol hello request */
811struct gb_svc_hello_request {
812 __le16 endo_id;
813 __u8 interface_id;
Johan Hovold2130f092015-08-01 11:50:38 +0200814} __packed;
Viresh Kumaread35462015-07-21 17:44:19 +0530815/* hello response has no payload */
Alex Elder30c6d9d2015-05-22 13:02:08 -0500816
817struct gb_svc_intf_device_id_request {
818 __u8 intf_id;
819 __u8 device_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530820} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500821/* device id response has no payload */
822
823struct gb_svc_intf_hotplug_request {
824 __u8 intf_id;
825 struct {
Viresh Kumarb32a5c52015-12-22 22:04:33 +0530826 __le32 ddbl1_mfr_id;
827 __le32 ddbl1_prod_id;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500828 __le32 ara_vend_id;
829 __le32 ara_prod_id;
Viresh Kumar57c6bcc2015-12-28 11:59:00 +0530830 __le64 serial_number;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500831 } data;
Johan Hovold2130f092015-08-01 11:50:38 +0200832} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500833/* hotplug response has no payload */
834
835struct gb_svc_intf_hot_unplug_request {
836 __u8 intf_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530837} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500838/* hot unplug response has no payload */
839
840struct gb_svc_intf_reset_request {
841 __u8 intf_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530842} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500843/* interface reset response has no payload */
844
Rui Miguel Silvac5d55fb2016-01-11 13:46:31 +0000845#define GB_SVC_EJECT_TIME 9000
846struct gb_svc_intf_eject_request {
847 __u8 intf_id;
848} __packed;
849/* interface eject response has no payload */
850
Alex Elder30c6d9d2015-05-22 13:02:08 -0500851struct gb_svc_conn_create_request {
852 __u8 intf1_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100853 __le16 cport1_id;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500854 __u8 intf2_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100855 __le16 cport2_id;
Perry Hung0b226492015-07-24 19:02:34 -0400856 __u8 tc;
857 __u8 flags;
Johan Hovold2130f092015-08-01 11:50:38 +0200858} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500859/* connection create response has no payload */
860
861struct gb_svc_conn_destroy_request {
862 __u8 intf1_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100863 __le16 cport1_id;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500864 __u8 intf2_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100865 __le16 cport2_id;
Johan Hovold2130f092015-08-01 11:50:38 +0200866} __packed;
Alex Elder30c6d9d2015-05-22 13:02:08 -0500867/* connection destroy response has no payload */
868
Viresh Kumar19151c32015-09-09 21:08:29 +0530869struct gb_svc_dme_peer_get_request {
870 __u8 intf_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100871 __le16 attr;
872 __le16 selector;
Viresh Kumar19151c32015-09-09 21:08:29 +0530873} __packed;
874
875struct gb_svc_dme_peer_get_response {
Rui Miguel Silva24980502015-09-15 15:33:51 +0100876 __le16 result_code;
877 __le32 attr_value;
Viresh Kumar19151c32015-09-09 21:08:29 +0530878} __packed;
879
880struct gb_svc_dme_peer_set_request {
881 __u8 intf_id;
Rui Miguel Silva24980502015-09-15 15:33:51 +0100882 __le16 attr;
883 __le16 selector;
884 __le32 value;
Viresh Kumar19151c32015-09-09 21:08:29 +0530885} __packed;
886
887struct gb_svc_dme_peer_set_response {
Rui Miguel Silva24980502015-09-15 15:33:51 +0100888 __le16 result_code;
Viresh Kumar19151c32015-09-09 21:08:29 +0530889} __packed;
890
Viresh Kumar6bec5c72015-09-24 14:40:29 -0700891/* Attributes for peer get/set operations */
892#define DME_ATTR_SELECTOR_INDEX 0
Eli Sennesh3563ff82015-12-22 17:26:57 -0500893/* FIXME: remove ES2 support and DME_ATTR_T_TST_SRC_INCREMENT */
Viresh Kumar6bec5c72015-09-24 14:40:29 -0700894#define DME_ATTR_T_TST_SRC_INCREMENT 0x4083
Eli Sennesh3563ff82015-12-22 17:26:57 -0500895#define DME_ATTR_ES3_INIT_STATUS 0x6101
Viresh Kumar6bec5c72015-09-24 14:40:29 -0700896
Eli Sennesh3563ff82015-12-22 17:26:57 -0500897/* Return value from init-status attributes listed above */
898#define DME_DIS_SPI_BOOT_STARTED 0x02
899#define DME_DIS_TRUSTED_SPI_BOOT_FINISHED 0x03
900#define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED 0x04
901#define DME_DIS_UNIPRO_BOOT_STARTED 0x06
902#define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED 0x09
Viresh Kumar1575ef12015-10-07 15:40:24 -0400903
Perry Hunge08aaa42015-07-24 19:02:31 -0400904struct gb_svc_route_create_request {
905 __u8 intf1_id;
906 __u8 dev1_id;
907 __u8 intf2_id;
908 __u8 dev2_id;
Viresh Kumar829a91e2015-08-31 17:21:03 +0530909} __packed;
Viresh Kumard6ec7872015-08-31 17:21:02 +0530910/* route create response has no payload */
Perry Hunge08aaa42015-07-24 19:02:31 -0400911
Viresh Kumar0a020572015-09-07 18:05:26 +0530912struct gb_svc_route_destroy_request {
913 __u8 intf1_id;
914 __u8 intf2_id;
915} __packed;
916/* route destroy response has no payload */
917
Laurent Pinchartaab4a1a2016-01-06 16:16:46 +0200918#define GB_SVC_UNIPRO_FAST_MODE 0x01
919#define GB_SVC_UNIPRO_SLOW_MODE 0x02
920#define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04
921#define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05
922#define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07
923#define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11
924#define GB_SVC_UNIPRO_OFF_MODE 0x12
925
926#define GB_SVC_PWRM_RXTERMINATION 0x01
927#define GB_SVC_PWRM_TXTERMINATION 0x02
928#define GB_SVC_PWRM_LINE_RESET 0x04
929#define GB_SVC_PWRM_SCRAMBLING 0x20
930
931#define GB_SVC_PWRM_QUIRK_HSSER 0x00000001
932
933#define GB_SVC_UNIPRO_HS_SERIES_A 0x01
934#define GB_SVC_UNIPRO_HS_SERIES_B 0x02
935
936struct gb_svc_intf_set_pwrm_request {
937 __u8 intf_id;
938 __u8 hs_series;
939 __u8 tx_mode;
940 __u8 tx_gear;
941 __u8 tx_nlanes;
942 __u8 rx_mode;
943 __u8 rx_gear;
944 __u8 rx_nlanes;
945 __u8 flags;
946 __le32 quirks;
947} __packed;
948
949struct gb_svc_intf_set_pwrm_response {
950 __le16 result_code;
951} __packed;
Viresh Kumard65e3a22015-08-13 10:04:45 +0530952
Rui Miguel Silvaebe99d62016-01-21 01:42:17 +0000953struct gb_svc_key_event_request {
954 __le16 key_code;
955#define GB_KEYCODE_ARA 0x00
956
957 __u8 key_event;
958#define GB_SVC_KEY_RELEASED 0x00
959#define GB_SVC_KEY_PRESSED 0x01
960} __packed;
961
Viresh Kumard65e3a22015-08-13 10:04:45 +0530962/* RAW */
963
964/* Version of the Greybus raw protocol we support */
965#define GB_RAW_VERSION_MAJOR 0x00
966#define GB_RAW_VERSION_MINOR 0x01
967
968/* Greybus raw request types */
969#define GB_RAW_TYPE_SEND 0x02
970
971struct gb_raw_send_request {
972 __le32 len;
973 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530974} __packed;
Viresh Kumard65e3a22015-08-13 10:04:45 +0530975
976
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100977/* UART */
978
979/* Version of the Greybus UART protocol we support */
980#define GB_UART_VERSION_MAJOR 0x00
981#define GB_UART_VERSION_MINOR 0x01
982
983/* Greybus UART operation types */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100984#define GB_UART_TYPE_SEND_DATA 0x02
985#define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
986#define GB_UART_TYPE_SET_LINE_CODING 0x04
987#define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
Bryan O'Donoghuea5192032015-07-14 02:10:18 +0100988#define GB_UART_TYPE_SEND_BREAK 0x06
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100989#define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
990
Bryan O'Donoghue11fca142015-06-02 13:40:45 +0100991/* Represents data from AP -> Module */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100992struct gb_uart_send_data_request {
993 __le16 size;
994 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +0530995} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +0100996
Bryan O'Donoghue802362d2015-06-29 18:09:13 +0100997/* recv-data-request flags */
998#define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
999#define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
1000#define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
1001#define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
1002
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001003/* Represents data from Module -> AP */
1004struct gb_uart_recv_data_request {
1005 __le16 size;
Bryan O'Donoghue802362d2015-06-29 18:09:13 +01001006 __u8 flags;
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001007 __u8 data[0];
Johan Hovoldcfc5f2c2015-08-01 11:50:39 +02001008} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001009
1010struct gb_uart_set_line_coding_request {
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001011 __le32 rate;
1012 __u8 format;
1013#define GB_SERIAL_1_STOP_BITS 0
1014#define GB_SERIAL_1_5_STOP_BITS 1
1015#define GB_SERIAL_2_STOP_BITS 2
1016
1017 __u8 parity;
1018#define GB_SERIAL_NO_PARITY 0
1019#define GB_SERIAL_ODD_PARITY 1
1020#define GB_SERIAL_EVEN_PARITY 2
1021#define GB_SERIAL_MARK_PARITY 3
1022#define GB_SERIAL_SPACE_PARITY 4
1023
1024 __u8 data_bits;
Johan Hovoldcfc5f2c2015-08-01 11:50:39 +02001025} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001026
1027/* output control lines */
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001028#define GB_UART_CTRL_DTR 0x01
1029#define GB_UART_CTRL_RTS 0x02
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001030
1031struct gb_uart_set_control_line_state_request {
Bryan O'Donoghueba4b0992015-06-29 18:09:15 +01001032 __u8 control;
Viresh Kumarb7016862015-08-31 17:21:04 +05301033} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001034
1035struct gb_uart_set_break_request {
1036 __u8 state;
Viresh Kumarb7016862015-08-31 17:21:04 +05301037} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001038
1039/* input control lines and line errors */
Bryan O'Donoghue11fca142015-06-02 13:40:45 +01001040#define GB_UART_CTRL_DCD 0x01
1041#define GB_UART_CTRL_DSR 0x02
Bryan O'Donoghue802362d2015-06-29 18:09:13 +01001042#define GB_UART_CTRL_RI 0x04
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001043
1044struct gb_uart_serial_state_request {
Bryan O'Donoghueba4b0992015-06-29 18:09:15 +01001045 __u8 control;
Viresh Kumarb7016862015-08-31 17:21:04 +05301046} __packed;
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001047
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001048/* Loopback */
1049
1050/* Version of the Greybus loopback protocol we support */
Bryan O'Donoghue52af1412015-07-14 00:53:12 +01001051#define GB_LOOPBACK_VERSION_MAJOR 0x00
1052#define GB_LOOPBACK_VERSION_MINOR 0x01
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001053
1054/* Greybus loopback request types */
Bryan O'Donoghue52af1412015-07-14 00:53:12 +01001055#define GB_LOOPBACK_TYPE_PING 0x02
1056#define GB_LOOPBACK_TYPE_TRANSFER 0x03
Bryan O'Donoghue384a7a32015-07-13 20:20:49 +01001057#define GB_LOOPBACK_TYPE_SINK 0x04
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001058
Axel Haslamb59281a2016-02-10 14:19:29 +01001059/*
1060 * Loopback request/response header format should be identical
1061 * to simplify bandwidth and data movement analysis.
1062 */
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001063struct gb_loopback_transfer_request {
1064 __le32 len;
Axel Haslamb59281a2016-02-10 14:19:29 +01001065 __le32 reserved0;
1066 __le32 reserved1;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001067 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301068} __packed;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001069
1070struct gb_loopback_transfer_response {
Bryan O'Donoghue4a655ad2015-09-14 10:48:45 +01001071 __le32 len;
Bryan O'Donoghue04db3342015-10-12 15:45:05 +01001072 __le32 reserved0;
1073 __le32 reserved1;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001074 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301075} __packed;
Bryan O'Donoghuef9f971a2015-07-13 20:20:45 +01001076
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001077/* SDIO */
1078/* Version of the Greybus sdio protocol we support */
1079#define GB_SDIO_VERSION_MAJOR 0x00
1080#define GB_SDIO_VERSION_MINOR 0x01
1081
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001082/* Greybus SDIO operation types */
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001083#define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
1084#define GB_SDIO_TYPE_SET_IOS 0x03
1085#define GB_SDIO_TYPE_COMMAND 0x04
1086#define GB_SDIO_TYPE_TRANSFER 0x05
1087#define GB_SDIO_TYPE_EVENT 0x06
1088
1089/* get caps response: request has no payload */
1090struct gb_sdio_get_caps_response {
1091 __le32 caps;
1092#define GB_SDIO_CAP_NONREMOVABLE 0x00000001
1093#define GB_SDIO_CAP_4_BIT_DATA 0x00000002
1094#define GB_SDIO_CAP_8_BIT_DATA 0x00000004
1095#define GB_SDIO_CAP_MMC_HS 0x00000008
1096#define GB_SDIO_CAP_SD_HS 0x00000010
1097#define GB_SDIO_CAP_ERASE 0x00000020
1098#define GB_SDIO_CAP_1_2V_DDR 0x00000040
1099#define GB_SDIO_CAP_1_8V_DDR 0x00000080
1100#define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
1101#define GB_SDIO_CAP_UHS_SDR12 0x00000200
1102#define GB_SDIO_CAP_UHS_SDR25 0x00000400
1103#define GB_SDIO_CAP_UHS_SDR50 0x00000800
1104#define GB_SDIO_CAP_UHS_SDR104 0x00001000
1105#define GB_SDIO_CAP_UHS_DDR50 0x00002000
1106#define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
1107#define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
1108#define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
1109#define GB_SDIO_CAP_HS200_1_2V 0x00020000
1110#define GB_SDIO_CAP_HS200_1_8V 0x00040000
1111#define GB_SDIO_CAP_HS400_1_2V 0x00080000
1112#define GB_SDIO_CAP_HS400_1_8V 0x00100000
1113
1114 /* see possible values below at vdd */
1115 __le32 ocr;
1116 __le16 max_blk_count;
1117 __le16 max_blk_size;
Rui Miguel Silvae0f875c2015-10-08 12:10:51 +01001118 __le32 f_min;
1119 __le32 f_max;
Viresh Kumarb7016862015-08-31 17:21:04 +05301120} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001121
1122/* set ios request: response has no payload */
1123struct gb_sdio_set_ios_request {
1124 __le32 clock;
1125 __le32 vdd;
1126#define GB_SDIO_VDD_165_195 0x00000001
1127#define GB_SDIO_VDD_20_21 0x00000002
1128#define GB_SDIO_VDD_21_22 0x00000004
1129#define GB_SDIO_VDD_22_23 0x00000008
1130#define GB_SDIO_VDD_23_24 0x00000010
1131#define GB_SDIO_VDD_24_25 0x00000020
1132#define GB_SDIO_VDD_25_26 0x00000040
1133#define GB_SDIO_VDD_26_27 0x00000080
1134#define GB_SDIO_VDD_27_28 0x00000100
1135#define GB_SDIO_VDD_28_29 0x00000200
1136#define GB_SDIO_VDD_29_30 0x00000400
1137#define GB_SDIO_VDD_30_31 0x00000800
1138#define GB_SDIO_VDD_31_32 0x00001000
1139#define GB_SDIO_VDD_32_33 0x00002000
1140#define GB_SDIO_VDD_33_34 0x00004000
1141#define GB_SDIO_VDD_34_35 0x00008000
1142#define GB_SDIO_VDD_35_36 0x00010000
1143
1144 __u8 bus_mode;
1145#define GB_SDIO_BUSMODE_OPENDRAIN 0x00
1146#define GB_SDIO_BUSMODE_PUSHPULL 0x01
1147
1148 __u8 power_mode;
1149#define GB_SDIO_POWER_OFF 0x00
1150#define GB_SDIO_POWER_UP 0x01
1151#define GB_SDIO_POWER_ON 0x02
1152#define GB_SDIO_POWER_UNDEFINED 0x03
1153
1154 __u8 bus_width;
1155#define GB_SDIO_BUS_WIDTH_1 0x00
1156#define GB_SDIO_BUS_WIDTH_4 0x02
1157#define GB_SDIO_BUS_WIDTH_8 0x03
1158
1159 __u8 timing;
1160#define GB_SDIO_TIMING_LEGACY 0x00
1161#define GB_SDIO_TIMING_MMC_HS 0x01
1162#define GB_SDIO_TIMING_SD_HS 0x02
1163#define GB_SDIO_TIMING_UHS_SDR12 0x03
1164#define GB_SDIO_TIMING_UHS_SDR25 0x04
1165#define GB_SDIO_TIMING_UHS_SDR50 0x05
1166#define GB_SDIO_TIMING_UHS_SDR104 0x06
1167#define GB_SDIO_TIMING_UHS_DDR50 0x07
1168#define GB_SDIO_TIMING_MMC_DDR52 0x08
1169#define GB_SDIO_TIMING_MMC_HS200 0x09
1170#define GB_SDIO_TIMING_MMC_HS400 0x0A
1171
1172 __u8 signal_voltage;
1173#define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
1174#define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
1175#define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
1176
1177 __u8 drv_type;
1178#define GB_SDIO_SET_DRIVER_TYPE_B 0x00
1179#define GB_SDIO_SET_DRIVER_TYPE_A 0x01
1180#define GB_SDIO_SET_DRIVER_TYPE_C 0x02
1181#define GB_SDIO_SET_DRIVER_TYPE_D 0x03
Johan Hovold8bbd9ed2015-08-01 11:50:40 +02001182} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001183
1184/* command request */
1185struct gb_sdio_command_request {
1186 __u8 cmd;
1187 __u8 cmd_flags;
1188#define GB_SDIO_RSP_NONE 0x00
Rui Miguel Silvaef0cc0e2015-07-02 19:11:30 +01001189#define GB_SDIO_RSP_PRESENT 0x01
1190#define GB_SDIO_RSP_136 0x02
1191#define GB_SDIO_RSP_CRC 0x04
1192#define GB_SDIO_RSP_BUSY 0x08
1193#define GB_SDIO_RSP_OPCODE 0x10
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001194
1195 __u8 cmd_type;
1196#define GB_SDIO_CMD_AC 0x00
1197#define GB_SDIO_CMD_ADTC 0x01
Rui Miguel Silva2d465d52015-08-20 15:20:17 +01001198#define GB_SDIO_CMD_BC 0x02
1199#define GB_SDIO_CMD_BCR 0x03
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001200
1201 __le32 cmd_arg;
Rui Miguel Silva10ed1932015-10-15 23:56:51 +01001202 __le16 data_blocks;
1203 __le16 data_blksz;
Johan Hovold8bbd9ed2015-08-01 11:50:40 +02001204} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001205
1206struct gb_sdio_command_response {
1207 __le32 resp[4];
Viresh Kumarb7016862015-08-31 17:21:04 +05301208} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001209
1210/* transfer request */
1211struct gb_sdio_transfer_request {
1212 __u8 data_flags;
1213#define GB_SDIO_DATA_WRITE 0x01
1214#define GB_SDIO_DATA_READ 0x02
1215#define GB_SDIO_DATA_STREAM 0x04
1216
1217 __le16 data_blocks;
1218 __le16 data_blksz;
1219 __u8 data[0];
Johan Hovold8bbd9ed2015-08-01 11:50:40 +02001220} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001221
1222struct gb_sdio_transfer_response {
1223 __le16 data_blocks;
1224 __le16 data_blksz;
1225 __u8 data[0];
Viresh Kumarb7016862015-08-31 17:21:04 +05301226} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001227
1228/* event request: generated by module and is defined as unidirectional */
1229struct gb_sdio_event_request {
1230 __u8 event;
1231#define GB_SDIO_CARD_INSERTED 0x01
1232#define GB_SDIO_CARD_REMOVED 0x02
1233#define GB_SDIO_WP 0x04
Viresh Kumarb7016862015-08-31 17:21:04 +05301234} __packed;
Rui Miguel Silva3b6ecd62015-06-22 14:03:52 +01001235
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001236/* Camera */
1237
1238#define GB_CAMERA_VERSION_MAJOR 0x00
1239#define GB_CAMERA_VERSION_MINOR 0x01
1240
1241/* Greybus Camera request types */
1242#define GB_CAMERA_TYPE_CAPABILITIES 0x02
1243#define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03
1244#define GB_CAMERA_TYPE_CAPTURE 0x04
1245#define GB_CAMERA_TYPE_FLUSH 0x05
1246#define GB_CAMERA_TYPE_METADATA 0x06
1247
1248#define GB_CAMERA_MAX_STREAMS 4
1249#define GB_CAMERA_MAX_SETTINGS_SIZE 8192
1250
1251/* Greybus Camera Configure Streams request payload */
1252struct gb_camera_stream_config_request {
1253 __le16 width;
1254 __le16 height;
1255 __le16 format;
1256 __le16 padding;
1257} __packed;
1258
1259struct gb_camera_configure_streams_request {
Jacopo Mondib787d412016-01-08 18:13:20 +02001260 __u8 num_streams;
1261 __u8 flags;
1262#define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001263 __le16 padding;
1264 struct gb_camera_stream_config_request config[0];
1265} __packed;
1266
1267/* Greybus Camera Configure Streams response payload */
1268struct gb_camera_stream_config_response {
1269 __le16 width;
1270 __le16 height;
1271 __le16 format;
1272 __u8 virtual_channel;
1273 __u8 data_type[2];
1274 __u8 padding[3];
1275 __le32 max_size;
1276} __packed;
1277
1278struct gb_camera_configure_streams_response {
Jacopo Mondib787d412016-01-08 18:13:20 +02001279 __u8 num_streams;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001280 __u8 flags;
Jacopo Mondib787d412016-01-08 18:13:20 +02001281#define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
Jacopo Mondi446091c2016-02-23 11:22:48 +01001282 __u8 num_lanes;
1283 __u8 padding;
1284 __le32 bus_freq;
1285 __le32 lines_per_second;
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001286 struct gb_camera_stream_config_response config[0];
1287} __packed;
1288
1289/* Greybus Camera Capture request payload - response has no payload */
1290struct gb_camera_capture_request {
1291 __le32 request_id;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001292 __u8 streams;
1293 __u8 padding;
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001294 __le16 num_frames;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001295 __u8 settings[0];
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001296} __packed;
1297
1298/* Greybus Camera Flush response payload - request has no payload */
1299struct gb_camera_flush_response {
1300 __le32 request_id;
1301} __packed;
1302
1303/* Greybus Camera Metadata request payload - operation has no response */
1304struct gb_camera_metadata_request {
1305 __le32 request_id;
1306 __le16 frame_number;
1307 __u8 stream;
1308 __u8 padding;
Rui Miguel Silva8e77c832015-12-17 19:56:23 +00001309 __u8 metadata[0];
Laurent Pincharte61a2a72015-12-15 03:18:05 +02001310} __packed;
1311
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001312/* Lights */
1313
1314#define GB_LIGHTS_VERSION_MAJOR 0x00
1315#define GB_LIGHTS_VERSION_MINOR 0x01
1316
1317/* Greybus Lights request types */
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001318#define GB_LIGHTS_TYPE_GET_LIGHTS 0x02
1319#define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03
1320#define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04
1321#define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
1322#define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06
1323#define GB_LIGHTS_TYPE_SET_BLINK 0x07
1324#define GB_LIGHTS_TYPE_SET_COLOR 0x08
1325#define GB_LIGHTS_TYPE_SET_FADE 0x09
1326#define GB_LIGHTS_TYPE_EVENT 0x0A
1327#define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B
1328#define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C
1329#define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D
1330#define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E
1331
1332/* Greybus Light modes */
1333
1334/*
1335 * if you add any specific mode below, update also the
1336 * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
1337 */
1338#define GB_CHANNEL_MODE_NONE 0x00000000
1339#define GB_CHANNEL_MODE_BATTERY 0x00000001
1340#define GB_CHANNEL_MODE_POWER 0x00000002
1341#define GB_CHANNEL_MODE_WIRELESS 0x00000004
1342#define GB_CHANNEL_MODE_BLUETOOTH 0x00000008
1343#define GB_CHANNEL_MODE_KEYBOARD 0x00000010
1344#define GB_CHANNEL_MODE_BUTTONS 0x00000020
1345#define GB_CHANNEL_MODE_NOTIFICATION 0x00000040
1346#define GB_CHANNEL_MODE_ATTENTION 0x00000080
1347#define GB_CHANNEL_MODE_FLASH 0x00000100
1348#define GB_CHANNEL_MODE_TORCH 0x00000200
1349#define GB_CHANNEL_MODE_INDICATOR 0x00000400
1350
1351/* Lights Mode valid bit values */
1352#define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF
1353#define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000
1354
1355/* Greybus Light Channels Flags */
1356#define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001
1357#define GB_LIGHT_CHANNEL_FADER 0x00000002
1358#define GB_LIGHT_CHANNEL_BLINK 0x00000004
1359
1360/* get count of lights in module */
1361struct gb_lights_get_lights_response {
1362 __u8 lights_count;
Viresh Kumarb7016862015-08-31 17:21:04 +05301363} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001364
1365/* light config request payload */
1366struct gb_lights_get_light_config_request {
1367 __u8 id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301368} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001369
1370/* light config response payload */
1371struct gb_lights_get_light_config_response {
1372 __u8 channel_count;
1373 __u8 name[32];
Viresh Kumarb7016862015-08-31 17:21:04 +05301374} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001375
1376/* channel config request payload */
1377struct gb_lights_get_channel_config_request {
1378 __u8 light_id;
1379 __u8 channel_id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301380} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001381
1382/* channel flash config request payload */
1383struct gb_lights_get_channel_flash_config_request {
1384 __u8 light_id;
1385 __u8 channel_id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301386} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001387
1388/* channel config response payload */
1389struct gb_lights_get_channel_config_response {
1390 __u8 max_brightness;
1391 __le32 flags;
1392 __le32 color;
1393 __u8 color_name[32];
1394 __le32 mode;
1395 __u8 mode_name[32];
1396} __packed;
1397
1398/* channel flash config response payload */
1399struct gb_lights_get_channel_flash_config_response {
1400 __le32 intensity_min_uA;
1401 __le32 intensity_max_uA;
1402 __le32 intensity_step_uA;
1403 __le32 timeout_min_us;
1404 __le32 timeout_max_us;
1405 __le32 timeout_step_us;
Viresh Kumarb7016862015-08-31 17:21:04 +05301406} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001407
1408/* blink request payload: response have no payload */
1409struct gb_lights_blink_request {
1410 __u8 light_id;
1411 __u8 channel_id;
1412 __le16 time_on_ms;
1413 __le16 time_off_ms;
Viresh Kumarb7016862015-08-31 17:21:04 +05301414} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001415
1416/* set brightness request payload: response have no payload */
1417struct gb_lights_set_brightness_request {
1418 __u8 light_id;
1419 __u8 channel_id;
1420 __u8 brightness;
Viresh Kumarb7016862015-08-31 17:21:04 +05301421} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001422
1423/* set color request payload: response have no payload */
1424struct gb_lights_set_color_request {
1425 __u8 light_id;
1426 __u8 channel_id;
1427 __le32 color;
1428} __packed;
1429
1430/* set fade request payload: response have no payload */
1431struct gb_lights_set_fade_request {
1432 __u8 light_id;
1433 __u8 channel_id;
1434 __u8 fade_in;
1435 __u8 fade_out;
Viresh Kumarb7016862015-08-31 17:21:04 +05301436} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001437
1438/* event request: generated by module */
1439struct gb_lights_event_request {
1440 __u8 light_id;
1441 __u8 event;
1442#define GB_LIGHTS_LIGHT_CONFIG 0x01
Viresh Kumarb7016862015-08-31 17:21:04 +05301443} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001444
1445/* set flash intensity request payload: response have no payload */
1446struct gb_lights_set_flash_intensity_request {
1447 __u8 light_id;
1448 __u8 channel_id;
1449 __le32 intensity_uA;
1450} __packed;
1451
1452/* set flash strobe state request payload: response have no payload */
1453struct gb_lights_set_flash_strobe_request {
1454 __u8 light_id;
1455 __u8 channel_id;
1456 __u8 state;
Viresh Kumarb7016862015-08-31 17:21:04 +05301457} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001458
1459/* set flash timeout request payload: response have no payload */
1460struct gb_lights_set_flash_timeout_request {
1461 __u8 light_id;
1462 __u8 channel_id;
1463 __le32 timeout_us;
1464} __packed;
1465
1466/* get flash fault request payload */
1467struct gb_lights_get_flash_fault_request {
1468 __u8 light_id;
1469 __u8 channel_id;
Viresh Kumarb7016862015-08-31 17:21:04 +05301470} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001471
1472/* get flash fault response payload */
1473struct gb_lights_get_flash_fault_response {
1474 __le32 fault;
1475#define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000
1476#define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001
1477#define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002
1478#define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004
1479#define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008
1480#define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010
1481#define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020
1482#define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040
1483#define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080
Viresh Kumarb7016862015-08-31 17:21:04 +05301484} __packed;
Rui Miguel Silva2870b522015-08-14 13:58:19 +01001485
Mark Greerba4144a2016-01-13 14:07:45 -07001486/* Audio */
1487
1488/* Version of the Greybus audio protocol we support */
1489#define GB_AUDIO_VERSION_MAJOR 0x00
1490#define GB_AUDIO_VERSION_MINOR 0x01
1491
1492#define GB_AUDIO_TYPE_PROTOCOL_VERSION 0x01
1493#define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02
1494#define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03
1495#define GB_AUDIO_TYPE_GET_CONTROL 0x04
1496#define GB_AUDIO_TYPE_SET_CONTROL 0x05
1497#define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06
1498#define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07
1499#define GB_AUDIO_TYPE_GET_PCM 0x08
1500#define GB_AUDIO_TYPE_SET_PCM 0x09
1501#define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a
1502#define GB_AUDIO_TYPE_GET_TX_DELAY 0x0b
1503#define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c
1504#define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d
1505#define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e
1506#define GB_AUDIO_TYPE_GET_RX_DELAY 0x0f
1507#define GB_AUDIO_TYPE_ACTIVATE_RX 0x10
1508#define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11
1509#define GB_AUDIO_TYPE_JACK_EVENT 0x12
1510#define GB_AUDIO_TYPE_BUTTON_EVENT 0x13
1511#define GB_AUDIO_TYPE_STREAMING_EVENT 0x14
1512#define GB_AUDIO_TYPE_SEND_DATA 0x15
1513
1514/* Module must be able to buffer 10ms of audio data, minimum */
1515#define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000
1516
1517#define GB_AUDIO_PCM_NAME_MAX 32
1518#define AUDIO_DAI_NAME_MAX 32
1519#define AUDIO_CONTROL_NAME_MAX 32
1520#define AUDIO_CTL_ELEM_NAME_MAX 44
1521#define AUDIO_ENUM_NAME_MAX 64
1522#define AUDIO_WIDGET_NAME_MAX 32
1523
1524/* See SNDRV_PCM_FMTBIT_* in Linux source */
1525#define GB_AUDIO_PCM_FMT_S8 BIT(0)
1526#define GB_AUDIO_PCM_FMT_U8 BIT(1)
1527#define GB_AUDIO_PCM_FMT_S16_LE BIT(2)
1528#define GB_AUDIO_PCM_FMT_S16_BE BIT(3)
1529#define GB_AUDIO_PCM_FMT_U16_LE BIT(4)
1530#define GB_AUDIO_PCM_FMT_U16_BE BIT(5)
1531#define GB_AUDIO_PCM_FMT_S24_LE BIT(6)
1532#define GB_AUDIO_PCM_FMT_S24_BE BIT(7)
1533#define GB_AUDIO_PCM_FMT_U24_LE BIT(8)
1534#define GB_AUDIO_PCM_FMT_U24_BE BIT(9)
1535#define GB_AUDIO_PCM_FMT_S32_LE BIT(10)
1536#define GB_AUDIO_PCM_FMT_S32_BE BIT(11)
1537#define GB_AUDIO_PCM_FMT_U32_LE BIT(12)
1538#define GB_AUDIO_PCM_FMT_U32_BE BIT(13)
1539
1540/* See SNDRV_PCM_RATE_* in Linux source */
1541#define GB_AUDIO_PCM_RATE_5512 BIT(0)
1542#define GB_AUDIO_PCM_RATE_8000 BIT(1)
1543#define GB_AUDIO_PCM_RATE_11025 BIT(2)
1544#define GB_AUDIO_PCM_RATE_16000 BIT(3)
1545#define GB_AUDIO_PCM_RATE_22050 BIT(4)
1546#define GB_AUDIO_PCM_RATE_32000 BIT(5)
1547#define GB_AUDIO_PCM_RATE_44100 BIT(6)
1548#define GB_AUDIO_PCM_RATE_48000 BIT(7)
1549#define GB_AUDIO_PCM_RATE_64000 BIT(8)
1550#define GB_AUDIO_PCM_RATE_88200 BIT(9)
1551#define GB_AUDIO_PCM_RATE_96000 BIT(10)
1552#define GB_AUDIO_PCM_RATE_176400 BIT(11)
1553#define GB_AUDIO_PCM_RATE_192000 BIT(12)
1554
1555#define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1
1556#define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2
1557
1558#define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0)
1559#define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1)
1560
1561/* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
1562#define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01
1563#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02
1564#define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03
1565#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06
1566
1567/* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
1568#define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00
1569#define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01
1570#define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02
1571#define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03
1572#define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04
1573#define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05
1574#define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06
1575
1576/* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
1577#define GB_AUDIO_ACCESS_READ BIT(0)
1578#define GB_AUDIO_ACCESS_WRITE BIT(1)
1579#define GB_AUDIO_ACCESS_VOLATILE BIT(2)
1580#define GB_AUDIO_ACCESS_TIMESTAMP BIT(3)
1581#define GB_AUDIO_ACCESS_TLV_READ BIT(4)
1582#define GB_AUDIO_ACCESS_TLV_WRITE BIT(5)
1583#define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6)
1584#define GB_AUDIO_ACCESS_INACTIVE BIT(7)
1585#define GB_AUDIO_ACCESS_LOCK BIT(8)
1586#define GB_AUDIO_ACCESS_OWNER BIT(9)
1587
1588/* enum snd_soc_dapm_type */
1589#define GB_AUDIO_WIDGET_TYPE_INPUT 0x0
1590#define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1
1591#define GB_AUDIO_WIDGET_TYPE_MUX 0x2
1592#define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3
1593#define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4
1594#define GB_AUDIO_WIDGET_TYPE_MIXER 0x5
1595#define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6
1596#define GB_AUDIO_WIDGET_TYPE_PGA 0x7
1597#define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8
1598#define GB_AUDIO_WIDGET_TYPE_ADC 0x9
1599#define GB_AUDIO_WIDGET_TYPE_DAC 0xa
1600#define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb
1601#define GB_AUDIO_WIDGET_TYPE_MIC 0xc
1602#define GB_AUDIO_WIDGET_TYPE_HP 0xd
1603#define GB_AUDIO_WIDGET_TYPE_SPK 0xe
1604#define GB_AUDIO_WIDGET_TYPE_LINE 0xf
1605#define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10
1606#define GB_AUDIO_WIDGET_TYPE_VMID 0x11
1607#define GB_AUDIO_WIDGET_TYPE_PRE 0x12
1608#define GB_AUDIO_WIDGET_TYPE_POST 0x13
1609#define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14
1610#define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15
1611#define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16
1612#define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17
1613#define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18
1614#define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19
1615#define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a
1616#define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b
1617#define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c
1618
1619#define GB_AUDIO_WIDGET_STATE_DISABLED 0x01
1620#define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02
1621
1622#define GB_AUDIO_JACK_EVENT_INSERTION 0x1
1623#define GB_AUDIO_JACK_EVENT_REMOVAL 0x2
1624
1625#define GB_AUDIO_BUTTON_EVENT_PRESS 0x1
1626#define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2
1627
1628#define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1
1629#define GB_AUDIO_STREAMING_EVENT_HALT 0x2
1630#define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3
1631#define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4
1632#define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5
1633#define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6
1634#define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7
1635#define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8
1636#define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9
1637
1638#define GB_AUDIO_INVALID_INDEX 0xff
1639
1640struct gb_audio_pcm {
1641 __u8 stream_name[GB_AUDIO_PCM_NAME_MAX];
1642 __le32 formats; /* GB_AUDIO_PCM_FMT_* */
1643 __le32 rates; /* GB_AUDIO_PCM_RATE_* */
1644 __u8 chan_min;
1645 __u8 chan_max;
1646 __u8 sig_bits; /* number of bits of content */
1647} __packed;
1648
1649struct gb_audio_dai {
1650 __u8 name[AUDIO_DAI_NAME_MAX];
1651 __le16 data_cport;
1652 struct gb_audio_pcm capture;
1653 struct gb_audio_pcm playback;
1654} __packed;
1655
1656struct gb_audio_integer {
1657 __le32 min;
1658 __le32 max;
1659 __le32 step;
1660} __packed;
1661
1662struct gb_audio_integer64 {
1663 __le64 min;
1664 __le64 max;
1665 __le64 step;
1666} __packed;
1667
1668struct gb_audio_enumerated {
1669 __le32 items;
1670 __le16 names_length;
1671 __u8 names[0];
1672} __packed;
1673
1674struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
1675 __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
1676 __le16 dimen[4];
1677 union {
1678 struct gb_audio_integer integer;
1679 struct gb_audio_integer64 integer64;
1680 struct gb_audio_enumerated enumerated;
1681 } value;
1682} __packed;
1683
1684struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
1685 __le64 timestamp; /* XXX needed? */
1686 union {
1687 __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */
1688 __le64 integer64_value[2];
1689 __le32 enumerated_item[2];
1690 } value;
1691} __packed;
1692
1693struct gb_audio_control {
1694 __u8 name[AUDIO_CONTROL_NAME_MAX];
1695 __u8 id; /* 0-63 */
1696 __u8 iface; /* GB_AUDIO_IFACE_* */
1697 __le16 data_cport;
1698 __le32 access; /* GB_AUDIO_ACCESS_* */
1699 __u8 count; /* count of same elements */
1700 __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */
1701 struct gb_audio_ctl_elem_info info;
1702} __packed;
1703
1704struct gb_audio_widget {
1705 __u8 name[AUDIO_WIDGET_NAME_MAX];
1706 __u8 sname[AUDIO_WIDGET_NAME_MAX];
1707 __u8 id;
1708 __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */
1709 __u8 state; /* GB_AUDIO_WIDGET_STATE_* */
1710 __u8 ncontrols;
1711 struct gb_audio_control ctl[0]; /* 'ncontrols' entries */
1712} __packed;
1713
1714struct gb_audio_route {
1715 __u8 source_id; /* widget id */
1716 __u8 destination_id; /* widget id */
1717 __u8 control_id; /* 0-63 */
1718 __u8 index; /* Selection within the control */
1719} __packed;
1720
1721struct gb_audio_topology {
1722 __u8 num_dais;
1723 __u8 num_controls;
1724 __u8 num_widgets;
1725 __u8 num_routes;
1726 __u32 size_dais;
1727 __u32 size_controls;
1728 __u32 size_widgets;
1729 __u32 size_routes;
1730 /*
1731 * struct gb_audio_dai dai[num_dais];
1732 * struct gb_audio_control controls[num_controls];
1733 * struct gb_audio_widget widgets[num_widgets];
1734 * struct gb_audio_route routes[num_routes];
1735 */
1736 __u8 data[0];
1737} __packed;
1738
1739struct gb_audio_get_topology_size_response {
1740 __le16 size;
1741} __packed;
1742
1743struct gb_audio_get_topology_response {
1744 struct gb_audio_topology topology;
1745} __packed;
1746
1747struct gb_audio_get_control_request {
1748 __u8 control_id;
1749 __u8 index;
1750} __packed;
1751
1752struct gb_audio_get_control_response {
1753 struct gb_audio_ctl_elem_value value;
1754} __packed;
1755
1756struct gb_audio_set_control_request {
1757 __u8 control_id;
1758 __u8 index;
1759 struct gb_audio_ctl_elem_value value;
1760} __packed;
1761
1762struct gb_audio_enable_widget_request {
1763 __u8 widget_id;
1764} __packed;
1765
1766struct gb_audio_disable_widget_request {
1767 __u8 widget_id;
1768} __packed;
1769
1770struct gb_audio_get_pcm_request {
1771 __le16 data_cport;
1772} __packed;
1773
1774struct gb_audio_get_pcm_response {
1775 __le32 format;
1776 __le32 rate;
1777 __u8 channels;
1778 __u8 sig_bits;
1779} __packed;
1780
1781struct gb_audio_set_pcm_request {
1782 __le16 data_cport;
1783 __le32 format;
1784 __le32 rate;
1785 __u8 channels;
1786 __u8 sig_bits;
1787} __packed;
1788
1789struct gb_audio_set_tx_data_size_request {
1790 __le16 data_cport;
1791 __le16 size;
1792} __packed;
1793
1794struct gb_audio_get_tx_delay_request {
1795 __le16 data_cport;
1796} __packed;
1797
1798struct gb_audio_get_tx_delay_response {
1799 __le32 delay;
1800} __packed;
1801
1802struct gb_audio_activate_tx_request {
1803 __le16 data_cport;
1804} __packed;
1805
1806struct gb_audio_deactivate_tx_request {
1807 __le16 data_cport;
1808} __packed;
1809
1810struct gb_audio_set_rx_data_size_request {
1811 __le16 data_cport;
1812 __le16 size;
1813} __packed;
1814
1815struct gb_audio_get_rx_delay_request {
1816 __le16 data_cport;
1817} __packed;
1818
1819struct gb_audio_get_rx_delay_response {
1820 __le32 delay;
1821} __packed;
1822
1823struct gb_audio_activate_rx_request {
1824 __le16 data_cport;
1825} __packed;
1826
1827struct gb_audio_deactivate_rx_request {
1828 __le16 data_cport;
1829} __packed;
1830
1831struct gb_audio_jack_event_request {
1832 __u8 widget_id;
1833 __u8 widget_type;
1834 __u8 event;
1835} __packed;
1836
1837struct gb_audio_button_event_request {
1838 __u8 widget_id;
1839 __u8 button_id;
1840 __u8 event;
1841} __packed;
1842
1843struct gb_audio_streaming_event_request {
1844 __le16 data_cport;
1845 __u8 event;
1846} __packed;
1847
1848struct gb_audio_send_data_request {
1849 __le64 timestamp;
1850 __u8 data[0];
1851} __packed;
1852
Alex Elder012d7d42015-05-27 14:45:58 -05001853#endif /* __GREYBUS_PROTOCOLS_H */
Bryan O'Donoghue4ef53482015-06-02 13:40:44 +01001854