blob: 3b4fd0d31c14ed6089350d7c6717a202fe6c55ea [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-Hartman3772f162014-09-01 09:51:33 -070042 __u8 source_device_id;
43 __u8 source_cport_id;
44 __u8 destination_device_id;
45 __u8 destination_cport_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070046};
47
48struct svc_function_unipro_link_up {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070049 __u8 device_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 */
72 __u8 device_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-Hartman3772f162014-09-01 09:51:33 -070081 __u8 device_id;
82 __u8 message_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -070083};
84
85struct svc_function_ddb_response {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -070086 __u8 device_id;
87 __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-Hartman3772f162014-09-01 09:51:33 -0700120 __u8 epm_command_type; /* enum svc_function_epm_command_type */
121 __u8 device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700122};
123
124struct svc_function_power {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700125 __u8 power_type; /* enum svc_function_power_type */
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700126 union {
127 struct svc_function_power_battery_status status;
128 struct svc_function_power_battery_status_request request;
129 };
130};
131
132enum svc_function_epm_command_type {
133 SVC_EPM_ENABLE = 0x00,
134 SVC_EPM_DISABLE = 0x01,
135};
136
137struct svc_function_epm {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700138 __u8 epm_command_type; /* enum svc_function_epm_command_type */
139 __u8 device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700140};
141
142enum svc_function_suspend_command_type {
143 SVC_SUSPEND_FIXME_1 = 0x00, // FIXME
144 SVC_SUSPEND_FIXME_2 = 0x01,
145};
146
147struct svc_function_suspend {
Greg Kroah-Hartman3772f162014-09-01 09:51:33 -0700148 __u8 suspend_command_type; /* enum function_suspend_command_type */
149 __u8 device_id;
Greg Kroah-Hartmanb9b2a462014-08-31 17:43:38 -0700150};
151
152struct svc_msg {
153 struct svc_msg_header header;
154 union {
155 struct svc_function_handshake handshake;
156 struct svc_function_unipro_management management;
157 struct svc_function_hotplug hotplug;
158 struct svc_function_ddb ddb;
159 struct svc_function_power power;
160 struct svc_function_epm epm;
161 struct svc_function_suspend suspend;
162 };
163};
164
Greg Kroah-Hartman80ebe8a2014-08-31 18:08:52 -0700165#endif /* __SVC_MSG_H */