greybus: svc: revert svc changes to keep things working for a while.
[cascardo/linux.git] / drivers / staging / greybus / svc_msg.h
1 /*
2  * Greybus AP <-> SVC message structure format.
3  *
4  * See "Greybus Application Protocol" document (version 0.1) for
5  * details on these values and structures.
6  *
7  * Copyright 2014 Google Inc.
8  * Copyright 2014 Linaro Ltd.
9  *
10  * Released under the GPLv2 and BSD license.
11  */
12
13 #ifndef __SVC_MSG_H
14 #define __SVC_MSG_H
15
16 enum svc_function_id {
17         SVC_FUNCTION_HANDSHAKE                  = 0x00,
18         SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT  = 0x01,
19         SVC_FUNCTION_HOTPLUG                    = 0x02,
20         SVC_FUNCTION_POWER                      = 0x03,
21         SVC_FUNCTION_EPM                        = 0x04,
22         SVC_FUNCTION_SUSPEND                    = 0x05,
23 };
24
25 enum svc_msg_type {
26         SVC_MSG_DATA                            = 0x00,
27         SVC_MSG_ERROR                           = 0xff,
28 };
29
30 struct svc_msg_header {
31         __u8    function_id;    /* enum svc_function_id */
32         __u8    message_type;
33         __le16  payload_length;
34 } __packed;
35
36 enum svc_function_handshake_type {
37         SVC_HANDSHAKE_SVC_HELLO         = 0x00,
38         SVC_HANDSHAKE_AP_HELLO          = 0x01,
39         SVC_HANDSHAKE_MODULE_HELLO      = 0x02,
40 };
41
42 struct svc_function_handshake {
43         __u8    version_major;
44         __u8    version_minor;
45         __u8    handshake_type; /* enum svc_function_handshake_type */
46 } __packed;
47
48 struct svc_function_unipro_set_route {
49         __u8    device_id;
50 } __packed;
51
52 struct svc_function_unipro_link_up {
53         __u8    interface_id;   /* Interface id within the Endo */
54         __u8    device_id;
55 } __packed;
56
57 struct svc_function_ap_id {
58         __u8    interface_id;
59         __u8    device_id;
60 } __packed;
61
62 enum svc_function_management_event {
63         SVC_MANAGEMENT_AP_ID            = 0x00,
64         SVC_MANAGEMENT_LINK_UP          = 0x01,
65         SVC_MANAGEMENT_SET_ROUTE        = 0x02,
66 };
67
68 struct svc_function_unipro_management {
69         __u8    management_packet_type; /* enum svc_function_management_event */
70         union {
71                 struct svc_function_ap_id               ap_id;
72                 struct svc_function_unipro_link_up      link_up;
73                 struct svc_function_unipro_set_route    set_route;
74         };
75 } __packed;
76
77 enum svc_function_hotplug_event {
78         SVC_HOTPLUG_EVENT       = 0x00,
79         SVC_HOTUNPLUG_EVENT     = 0x01,
80 };
81
82 struct svc_function_hotplug {
83         __u8    hotplug_event;  /* enum svc_function_hotplug_event */
84         __u8    interface_id;   /* Interface id within the Endo */
85 } __packed;
86
87 enum svc_function_power_type {
88         SVC_POWER_BATTERY_STATUS                = 0x00,
89         SVC_POWER_BATTERY_STATUS_REQUEST        = 0x01,
90 };
91
92 enum svc_function_battery_status {
93         SVC_BATTERY_UNKNOWN             = 0x00,
94         SVC_BATTERY_CHARGING            = 0x01,
95         SVC_BATTERY_DISCHARGING         = 0x02,
96         SVC_BATTERY_NOT_CHARGING        = 0x03,
97         SVC_BATTERY_FULL                = 0x04,
98 };
99
100 struct svc_function_power_battery_status {
101         __le16  charge_full;
102         __le16  charge_now;
103         __u8    status; /* enum svc_function_battery_status */
104 } __packed;
105
106 struct svc_function_power_battery_status_request {
107 } __packed;
108
109 /* XXX
110  * Each interface carries power, so it's possible these things
111  * are associated with each UniPro device and not just the module.
112  * For now it's safe to assume it's per-module.
113  */
114 struct svc_function_power {
115         __u8    power_type;     /* enum svc_function_power_type */
116         __u8    interface_id;
117         union {
118                 struct svc_function_power_battery_status                status;
119                 struct svc_function_power_battery_status_request        request;
120         };
121 } __packed;
122
123 enum svc_function_epm_command_type {
124         SVC_EPM_ENABLE  = 0x00,
125         SVC_EPM_DISABLE = 0x01,
126 };
127
128 /* EPM's are associated with the module */
129 struct svc_function_epm {
130         __u8    epm_command_type;       /* enum svc_function_epm_command_type */
131         __u8    module_id;
132 } __packed;
133
134 enum svc_function_suspend_command_type {
135         SVC_SUSPEND_FIXME_1     = 0x00, // FIXME
136         SVC_SUSPEND_FIXME_2     = 0x01,
137 };
138
139 /* We'll want independent control for multi-interface modules */
140 struct svc_function_suspend {
141         __u8    suspend_command_type;   /* enum function_suspend_command_type */
142         __u8    device_id;
143 } __packed;
144
145 struct svc_msg {
146         struct svc_msg_header   header;
147         union {
148                 struct svc_function_handshake           handshake;
149                 struct svc_function_unipro_management   management;
150                 struct svc_function_hotplug             hotplug;
151                 struct svc_function_power               power;
152                 struct svc_function_epm                 epm;
153                 struct svc_function_suspend             suspend;
154         };
155 } __packed;
156
157 #endif /* __SVC_MSG_H */