summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/svc_msg.h
blob: 4b696040b4e1632d422a9587c29a80ba5870caaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * Greybus AP <-> SVC message structure format.
 *
 * See "Greybus Application Protocol" document (version 0.1) for
 * details on these values and structures.
 *
 * Copyright 2014 Google Inc.
 *
 * Released under the GPLv2 only.
 */

#ifndef __SVC_MSG_H
#define __SVC_MSG_H

#pragma pack(push, 1)

enum svc_function_id {
	SVC_FUNCTION_HANDSHAKE			= 0x00,
	SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT	= 0x01,
	SVC_FUNCTION_HOTPLUG			= 0x02,
	SVC_FUNCTION_DDB			= 0x03,
	SVC_FUNCTION_POWER			= 0x04,
	SVC_FUNCTION_EPM			= 0x05,
	SVC_FUNCTION_SUSPEND			= 0x06,
};

enum svc_msg_type {
	SVC_MSG_DATA				= 0x00,
	SVC_MSG_ERROR				= 0xff,
};

struct svc_msg_header {
	__u8	function_id;	/* enum svc_function_id */
	__u8	message_type;
	__le16	payload_length;
};

enum svc_function_handshake_type {
	SVC_HANDSHAKE_SVC_HELLO		= 0x00,
	SVC_HANDSHAKE_AP_HELLO		= 0x01,
	SVC_HANDSHAKE_MODULE_HELLO	= 0x02,
};

struct svc_function_handshake {
	__u8	version_major;
	__u8	version_minor;
	__u8	handshake_type;	/* enum svc_function_handshake_type */
};

struct svc_function_unipro_set_route {
	__u8	source_module_id;
	__u8	source_cport_id;
	__u8	destination_module_id;
	__u8	destination_cport_id;
};

struct svc_function_unipro_link_up {
	__u8	module_id;
};

enum svc_function_management_event {
	SVC_MANAGEMENT_SET_ROUTE	= 0x00,
	SVC_MANAGEMENT_LINK_UP		= 0x01,
};

struct svc_function_unipro_management {
	__u8	management_packet_type;	/* enum svc_function_management_event */
	union {
		struct svc_function_unipro_set_route	set_route;
		struct svc_function_unipro_link_up	link_up;
	};
};

enum svc_function_hotplug_event {
	SVC_HOTPLUG_EVENT	= 0x00,
	SVC_HOTUNPLUG_EVENT	= 0x01,
};

struct svc_function_hotplug {
	__u8	hotplug_event;	/* enum svc_function_hotplug_event */
	__u8	module_id;
	__u8	data[0];
};

enum svc_function_ddb_type {
	SVC_DDB_GET		= 0x00,
	SVC_DDB_RESPONSE	= 0x01,
};

struct svc_function_ddb_get {
	__u8	module_id;
	__u8	message_id;
};

struct svc_function_ddb_response {
	__u8	module_id;
	__u8	message_id;
	__le16	descriptor_length;
	__u8	ddb[0];
};

struct svc_function_ddb {
	__u8	ddb_type;	/* enum svc_function_ddb_type */
	union {
		struct svc_function_ddb_get		ddb_get;
		struct svc_function_ddb_response	ddb_response;
	};
};

enum svc_function_power_type {
	SVC_POWER_BATTERY_STATUS		= 0x00,
	SVC_POWER_BATTERY_STATUS_REQUEST	= 0x01,
};

enum svc_function_battery_status {
	SVC_BATTERY_UNKNOWN		= 0x00,
	SVC_BATTERY_CHARGING		= 0x01,
	SVC_BATTERY_DISCHARGING		= 0x02,
	SVC_BATTERY_NOT_CHARGING	= 0x03,
	SVC_BATTERY_FULL		= 0x04,
};

struct svc_function_power_battery_status {
	__le16	charge_full;
	__le16	charge_now;
	__u8	status;	/* enum svc_function_battery_status */
};

struct svc_function_power_battery_status_request {
};

struct svc_function_power {
	__u8	power_type;	/* enum svc_function_power_type */
	__u8	module_id;
	union {
		struct svc_function_power_battery_status		status;
		struct svc_function_power_battery_status_request	request;
	};
};

enum svc_function_epm_command_type {
	SVC_EPM_ENABLE	= 0x00,
	SVC_EPM_DISABLE	= 0x01,
};

struct svc_function_epm {
	__u8	epm_command_type;	/* enum svc_function_epm_command_type */
	__u8	module_id;
};

enum svc_function_suspend_command_type {
	SVC_SUSPEND_FIXME_1	= 0x00,	// FIXME
	SVC_SUSPEND_FIXME_2	= 0x01,
};

struct svc_function_suspend {
	__u8	suspend_command_type;	/* enum function_suspend_command_type */
	__u8	module_id;
};

struct svc_msg {
	struct svc_msg_header	header;
	union {
		struct svc_function_handshake		handshake;
		struct svc_function_unipro_management	management;
		struct svc_function_hotplug		hotplug;
		struct svc_function_ddb			ddb;
		struct svc_function_power		power;
		struct svc_function_epm			epm;
		struct svc_function_suspend		suspend;
	};
};

#pragma pack(pop)

#endif /* __SVC_MSG_H */
OpenPOWER on IntegriCloud