blob: 661cbaeb159e09d6c597d5a5d920abc933614220 [file] [log] [blame]
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -07001/*
2 * Greybus AP <-> SVC message structure format.
3 *
Alex Eldercb705e02014-09-24 05:16:17 -05004 * See "Greybus Application Protocol" document (version 0.1) for
Alex Elder908a85d2014-09-24 05:16:16 -05005 * details on these values and structures.
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -07006 *
7 * Copyright 2014 Google Inc.
Alex Elder908a85d2014-09-24 05:16:16 -05008 *
Greg Kroah-Hartman62e120f2014-10-06 20:37:18 -07009 * Released under the GPLv2 and BSD license.
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070010 */
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070011
12#ifndef __SVC_MSG_H
13#define __SVC_MSG_H
14
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -070015#pragma pack(push, 1)
16
Matt Porter710ecb02014-09-18 15:25:41 -040017enum svc_function_id {
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070018 SVC_FUNCTION_HANDSHAKE = 0x00,
19 SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT = 0x01,
20 SVC_FUNCTION_HOTPLUG = 0x02,
21 SVC_FUNCTION_DDB = 0x03,
22 SVC_FUNCTION_POWER = 0x04,
23 SVC_FUNCTION_EPM = 0x05,
24 SVC_FUNCTION_SUSPEND = 0x06,
25};
26
Matt Porter710ecb02014-09-18 15:25:41 -040027enum svc_msg_type {
28 SVC_MSG_DATA = 0x00,
29 SVC_MSG_ERROR = 0xff,
30};
31
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070032struct svc_msg_header {
Matt Porter710ecb02014-09-18 15:25:41 -040033 __u8 function_id; /* enum svc_function_id */
34 __u8 message_type;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070035 __le16 payload_length;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070036};
37
38enum svc_function_handshake_type {
39 SVC_HANDSHAKE_SVC_HELLO = 0x00,
40 SVC_HANDSHAKE_AP_HELLO = 0x01,
41 SVC_HANDSHAKE_MODULE_HELLO = 0x02,
42};
43
44struct svc_function_handshake {
Matt Portere94e1712014-09-18 15:25:42 -040045 __u8 version_major;
46 __u8 version_minor;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070047 __u8 handshake_type; /* enum svc_function_handshake_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070048};
49
50struct svc_function_unipro_set_route {
Matt Portere390b192014-10-22 02:06:08 -040051 __u8 device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070052};
53
54struct svc_function_unipro_link_up {
Matt Porter6232b072014-10-21 22:43:31 -040055 __u8 module_id;
56 __u8 interface_id;
Alex Elder9c852d22014-09-30 19:25:22 -050057 __u8 device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070058};
59
Matt Porter98f4ab22014-10-21 01:52:27 -040060struct svc_function_ap_device_id {
61 __u8 device_id;
62};
63
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070064enum svc_function_management_event {
65 SVC_MANAGEMENT_SET_ROUTE = 0x00,
66 SVC_MANAGEMENT_LINK_UP = 0x01,
Matt Porter98f4ab22014-10-21 01:52:27 -040067 SVC_MANAGEMENT_AP_DEVICE_ID = 0x02,
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070068};
69
70struct svc_function_unipro_management {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070071 __u8 management_packet_type; /* enum svc_function_management_event */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070072 union {
73 struct svc_function_unipro_set_route set_route;
74 struct svc_function_unipro_link_up link_up;
Matt Porter98f4ab22014-10-21 01:52:27 -040075 struct svc_function_ap_device_id ap_device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070076 };
77};
78
79enum svc_function_hotplug_event {
80 SVC_HOTPLUG_EVENT = 0x00,
81 SVC_HOTUNPLUG_EVENT = 0x01,
82};
83
Alex Elder9c852d22014-09-30 19:25:22 -050084/* XXX
85 * Does a hotplug come from module insertion, or from detection
86 * of each interface block (UniPro device) in a module? Assume
87 * the former for now.
88 */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070089struct svc_function_hotplug {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070090 __u8 hotplug_event; /* enum svc_function_hotplug_event */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070091 __u8 module_id;
Greg Kroah-Hartman798ea882014-09-21 18:16:41 -070092 __u8 data[0];
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070093};
94
95enum svc_function_ddb_type {
96 SVC_DDB_GET = 0x00,
97 SVC_DDB_RESPONSE = 0x01,
98};
99
Alex Elder9c852d22014-09-30 19:25:22 -0500100/* XXX
101 * Will only the first interface block in a module be responsible
102 * for this? If a module has two interface blocks, will both supply
103 * the same information, or will it be partitioned? For now assume
104 * it's a per-module thing.
105 */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700106struct svc_function_ddb_get {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700107 __u8 module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700108 __u8 message_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700109};
110
111struct svc_function_ddb_response {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700112 __u8 module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700113 __u8 message_id;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700114 __le16 descriptor_length;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700115 __u8 ddb[0];
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700116};
117
118struct svc_function_ddb {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700119 __u8 ddb_type; /* enum svc_function_ddb_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700120 union {
121 struct svc_function_ddb_get ddb_get;
122 struct svc_function_ddb_response ddb_response;
123 };
124};
125
126enum svc_function_power_type {
127 SVC_POWER_BATTERY_STATUS = 0x00,
128 SVC_POWER_BATTERY_STATUS_REQUEST = 0x01,
129};
130
131enum svc_function_battery_status {
132 SVC_BATTERY_UNKNOWN = 0x00,
133 SVC_BATTERY_CHARGING = 0x01,
134 SVC_BATTERY_DISCHARGING = 0x02,
135 SVC_BATTERY_NOT_CHARGING = 0x03,
136 SVC_BATTERY_FULL = 0x04,
137};
138
139struct svc_function_power_battery_status {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700140 __le16 charge_full;
141 __le16 charge_now;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700142 __u8 status; /* enum svc_function_battery_status */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700143};
144
145struct svc_function_power_battery_status_request {
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700146};
147
Alex Elder9c852d22014-09-30 19:25:22 -0500148/* XXX
149 * Each interface block carries power, so it's possible these things
150 * are associated with each UniPro device and not just the module.
151 * For now it's safe to assume it's per-module.
152 */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700153struct svc_function_power {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700154 __u8 power_type; /* enum svc_function_power_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700155 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700156 union {
157 struct svc_function_power_battery_status status;
158 struct svc_function_power_battery_status_request request;
159 };
160};
161
162enum svc_function_epm_command_type {
163 SVC_EPM_ENABLE = 0x00,
164 SVC_EPM_DISABLE = 0x01,
165};
166
Alex Elder9c852d22014-09-30 19:25:22 -0500167/* EPM's are associated with the module */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700168struct svc_function_epm {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700169 __u8 epm_command_type; /* enum svc_function_epm_command_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700170 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700171};
172
173enum svc_function_suspend_command_type {
174 SVC_SUSPEND_FIXME_1 = 0x00, // FIXME
175 SVC_SUSPEND_FIXME_2 = 0x01,
176};
177
Alex Elder9c852d22014-09-30 19:25:22 -0500178/* We'll want independent control for multi-interface block modules */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700179struct svc_function_suspend {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700180 __u8 suspend_command_type; /* enum function_suspend_command_type */
Alex Elder9c852d22014-09-30 19:25:22 -0500181 __u8 device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700182};
183
184struct svc_msg {
185 struct svc_msg_header header;
186 union {
187 struct svc_function_handshake handshake;
188 struct svc_function_unipro_management management;
189 struct svc_function_hotplug hotplug;
190 struct svc_function_ddb ddb;
191 struct svc_function_power power;
192 struct svc_function_epm epm;
193 struct svc_function_suspend suspend;
194 };
195};
196
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700197#pragma pack(pop)
198
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700199#endif /* __SVC_MSG_H */