blob: c290547305ac7499872e13eac30b71fb34e52e3f [file] [log] [blame]
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -07001/*
2 * Greybus AP <-> SVC message structure format.
3 *
4 * Defined in the "Greybus Application Protocol" document.
5 * See that document for any details on these values and structures.
6 *
7 * Copyright 2014 Google Inc.
8 */
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -07009
10#ifndef __SVC_MSG_H
11#define __SVC_MSG_H
12
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -070013#pragma pack(push, 1)
14
Matt Porter710ecb02014-09-18 15:25:41 -040015enum svc_function_id {
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070016 SVC_FUNCTION_HANDSHAKE = 0x00,
17 SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT = 0x01,
18 SVC_FUNCTION_HOTPLUG = 0x02,
19 SVC_FUNCTION_DDB = 0x03,
20 SVC_FUNCTION_POWER = 0x04,
21 SVC_FUNCTION_EPM = 0x05,
22 SVC_FUNCTION_SUSPEND = 0x06,
23};
24
Matt Porter710ecb02014-09-18 15:25:41 -040025enum svc_msg_type {
26 SVC_MSG_DATA = 0x00,
27 SVC_MSG_ERROR = 0xff,
28};
29
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070030struct svc_msg_header {
Matt Porter710ecb02014-09-18 15:25:41 -040031 __u8 function_id; /* enum svc_function_id */
32 __u8 message_type;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070033 __le16 payload_length;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070034};
35
36enum svc_function_handshake_type {
37 SVC_HANDSHAKE_SVC_HELLO = 0x00,
38 SVC_HANDSHAKE_AP_HELLO = 0x01,
39 SVC_HANDSHAKE_MODULE_HELLO = 0x02,
40};
41
42struct svc_function_handshake {
Matt Portere94e1712014-09-18 15:25:42 -040043 __u8 version_major;
44 __u8 version_minor;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070045 __u8 handshake_type; /* enum svc_function_handshake_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070046};
47
48struct svc_function_unipro_set_route {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070049 __u8 source_module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070050 __u8 source_cport_id;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070051 __u8 destination_module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070052 __u8 destination_cport_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070053};
54
55struct svc_function_unipro_link_up {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070056 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070057};
58
59enum svc_function_management_event {
60 SVC_MANAGEMENT_SET_ROUTE = 0x00,
61 SVC_MANAGEMENT_LINK_UP = 0x01,
62};
63
64struct svc_function_unipro_management {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070065 __u8 management_packet_type; /* enum svc_function_management_event */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070066 union {
67 struct svc_function_unipro_set_route set_route;
68 struct svc_function_unipro_link_up link_up;
69 };
70};
71
72enum svc_function_hotplug_event {
73 SVC_HOTPLUG_EVENT = 0x00,
74 SVC_HOTUNPLUG_EVENT = 0x01,
75};
76
77struct svc_function_hotplug {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070078 __u8 hotplug_event; /* enum svc_function_hotplug_event */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070079 __u8 module_id;
Greg Kroah-Hartman798ea882014-09-21 18:16:41 -070080 __u8 data[0];
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070081};
82
83enum svc_function_ddb_type {
84 SVC_DDB_GET = 0x00,
85 SVC_DDB_RESPONSE = 0x01,
86};
87
88struct svc_function_ddb_get {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070089 __u8 module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070090 __u8 message_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070091};
92
93struct svc_function_ddb_response {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070094 __u8 module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070095 __u8 message_id;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070096 __le16 descriptor_length;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070097 __u8 ddb[0];
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070098};
99
100struct svc_function_ddb {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700101 __u8 ddb_type; /* enum svc_function_ddb_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700102 union {
103 struct svc_function_ddb_get ddb_get;
104 struct svc_function_ddb_response ddb_response;
105 };
106};
107
108enum svc_function_power_type {
109 SVC_POWER_BATTERY_STATUS = 0x00,
110 SVC_POWER_BATTERY_STATUS_REQUEST = 0x01,
111};
112
113enum svc_function_battery_status {
114 SVC_BATTERY_UNKNOWN = 0x00,
115 SVC_BATTERY_CHARGING = 0x01,
116 SVC_BATTERY_DISCHARGING = 0x02,
117 SVC_BATTERY_NOT_CHARGING = 0x03,
118 SVC_BATTERY_FULL = 0x04,
119};
120
121struct svc_function_power_battery_status {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700122 __le16 charge_full;
123 __le16 charge_now;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700124 __u8 status; /* enum svc_function_battery_status */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700125};
126
127struct svc_function_power_battery_status_request {
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700128};
129
130struct svc_function_power {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700131 __u8 power_type; /* enum svc_function_power_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700132 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700133 union {
134 struct svc_function_power_battery_status status;
135 struct svc_function_power_battery_status_request request;
136 };
137};
138
139enum svc_function_epm_command_type {
140 SVC_EPM_ENABLE = 0x00,
141 SVC_EPM_DISABLE = 0x01,
142};
143
144struct svc_function_epm {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700145 __u8 epm_command_type; /* enum svc_function_epm_command_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700146 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700147};
148
149enum svc_function_suspend_command_type {
150 SVC_SUSPEND_FIXME_1 = 0x00, // FIXME
151 SVC_SUSPEND_FIXME_2 = 0x01,
152};
153
154struct svc_function_suspend {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700155 __u8 suspend_command_type; /* enum function_suspend_command_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700156 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700157};
158
159struct svc_msg {
160 struct svc_msg_header header;
161 union {
162 struct svc_function_handshake handshake;
163 struct svc_function_unipro_management management;
164 struct svc_function_hotplug hotplug;
165 struct svc_function_ddb ddb;
166 struct svc_function_power power;
167 struct svc_function_epm epm;
168 struct svc_function_suspend suspend;
169 };
170};
171
Greg Kroah-Hartman48123e02014-09-02 10:51:56 -0700172#pragma pack(pop)
173
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700174#endif /* __SVC_MSG_H */