blob: d992f3cebcefb74882bc2fdaf0fcf67a844a4fb5 [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-Hartmanb9b2a462014-08-31 17:43:38 -070013enum svc_function_type {
14 SVC_FUNCTION_HANDSHAKE = 0x00,
15 SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT = 0x01,
16 SVC_FUNCTION_HOTPLUG = 0x02,
17 SVC_FUNCTION_DDB = 0x03,
18 SVC_FUNCTION_POWER = 0x04,
19 SVC_FUNCTION_EPM = 0x05,
20 SVC_FUNCTION_SUSPEND = 0x06,
21};
22
23struct svc_msg_header {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070024 __u8 function;
25 __u8 type; /* enum svc_function_type */
26 __u8 version_major;
27 __u8 version_minor;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070028 __le16 payload_length;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070029};
30
31enum svc_function_handshake_type {
32 SVC_HANDSHAKE_SVC_HELLO = 0x00,
33 SVC_HANDSHAKE_AP_HELLO = 0x01,
34 SVC_HANDSHAKE_MODULE_HELLO = 0x02,
35};
36
37struct svc_function_handshake {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070038 __u8 handshake_type; /* enum svc_function_handshake_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070039};
40
41struct svc_function_unipro_set_route {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070042 __u8 source_module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070043 __u8 source_cport_id;
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070044 __u8 destination_module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070045 __u8 destination_cport_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070046};
47
48struct svc_function_unipro_link_up {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070049 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070050};
51
52enum svc_function_management_event {
53 SVC_MANAGEMENT_SET_ROUTE = 0x00,
54 SVC_MANAGEMENT_LINK_UP = 0x01,
55};
56
57struct svc_function_unipro_management {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070058 __u8 management_packet_type; /* enum svc_function_management_event */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070059 union {
60 struct svc_function_unipro_set_route set_route;
61 struct svc_function_unipro_link_up link_up;
62 };
63};
64
65enum svc_function_hotplug_event {
66 SVC_HOTPLUG_EVENT = 0x00,
67 SVC_HOTUNPLUG_EVENT = 0x01,
68};
69
70struct svc_function_hotplug {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070071 __u8 hotplug_event; /* enum svc_function_hotplug_event */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070072 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070073};
74
75enum svc_function_ddb_type {
76 SVC_DDB_GET = 0x00,
77 SVC_DDB_RESPONSE = 0x01,
78};
79
80struct svc_function_ddb_get {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070081 __u8 module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070082 __u8 message_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070083};
84
85struct svc_function_ddb_response {
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -070086 __u8 module_id;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070087 __u8 message_id;
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -070088 __le16 descriptor_length;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070089 __u8 ddb[0];
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070090};
91
92struct svc_function_ddb {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070093 __u8 ddb_type; /* enum svc_function_ddb_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070094 union {
95 struct svc_function_ddb_get ddb_get;
96 struct svc_function_ddb_response ddb_response;
97 };
98};
99
100enum svc_function_power_type {
101 SVC_POWER_BATTERY_STATUS = 0x00,
102 SVC_POWER_BATTERY_STATUS_REQUEST = 0x01,
103};
104
105enum svc_function_battery_status {
106 SVC_BATTERY_UNKNOWN = 0x00,
107 SVC_BATTERY_CHARGING = 0x01,
108 SVC_BATTERY_DISCHARGING = 0x02,
109 SVC_BATTERY_NOT_CHARGING = 0x03,
110 SVC_BATTERY_FULL = 0x04,
111};
112
113struct svc_function_power_battery_status {
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700114 __le16 charge_full;
115 __le16 charge_now;
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700116 __u8 status; /* enum svc_function_battery_status */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700117};
118
119struct svc_function_power_battery_status_request {
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700120};
121
122struct svc_function_power {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700123 __u8 power_type; /* enum svc_function_power_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700124 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700125 union {
126 struct svc_function_power_battery_status status;
127 struct svc_function_power_battery_status_request request;
128 };
129};
130
131enum svc_function_epm_command_type {
132 SVC_EPM_ENABLE = 0x00,
133 SVC_EPM_DISABLE = 0x01,
134};
135
136struct svc_function_epm {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700137 __u8 epm_command_type; /* enum svc_function_epm_command_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700138 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700139};
140
141enum svc_function_suspend_command_type {
142 SVC_SUSPEND_FIXME_1 = 0x00, // FIXME
143 SVC_SUSPEND_FIXME_2 = 0x01,
144};
145
146struct svc_function_suspend {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700147 __u8 suspend_command_type; /* enum function_suspend_command_type */
Greg Kroah-Hartmand5877802014-09-01 10:59:08 -0700148 __u8 module_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700149};
150
151struct svc_msg {
152 struct svc_msg_header header;
153 union {
154 struct svc_function_handshake handshake;
155 struct svc_function_unipro_management management;
156 struct svc_function_hotplug hotplug;
157 struct svc_function_ddb ddb;
158 struct svc_function_power power;
159 struct svc_function_epm epm;
160 struct svc_function_suspend suspend;
161 };
162};
163
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700164#endif /* __SVC_MSG_H */