summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/greybus_manifest.h
blob: 398630ce8ac49ec036deedd145f54c77203e4764 (plain) (blame)
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
/*
 * Greybus module manifest definition
 *
 * See "Greybus Application Protocol" document (version 0.1) for
 * details on these values and structures.
 *
 * Copyright 2014 Google Inc.
 * Copyright 2014 Linaro Ltd.
 *
 * Released under the GPLv2 and BSD licenses.
 */

#ifndef __GREYBUS_MANIFEST_H
#define __GREYBUS_MANIFEST_H

#pragma pack(push, 1)

enum greybus_descriptor_type {
	GREYBUS_TYPE_INVALID		= 0x00,
	GREYBUS_TYPE_MODULE		= 0x01,
	GREYBUS_TYPE_STRING		= 0x02,
	GREYBUS_TYPE_INTERFACE		= 0x03,
	GREYBUS_TYPE_CPORT		= 0x04,
	GREYBUS_TYPE_CLASS		= 0x05,
};

enum greybus_protocol {
	GREYBUS_PROTOCOL_CONTROL	= 0x00,
	GREYBUS_PROTOCOL_AP		= 0x01,
	GREYBUS_PROTOCOL_GPIO		= 0x02,
	GREYBUS_PROTOCOL_I2C		= 0x03,
	GREYBUS_PROTOCOL_UART		= 0x04,
	GREYBUS_PROTOCOL_HID		= 0x05,
	GREYBUS_PROTOCOL_USB		= 0x06,
	GREYBUS_PROTOCOL_SDIO		= 0x07,
	GREYBUS_PROTOCOL_BATTERY	= 0x08,
	GREYBUS_PROTOCOL_PWM		= 0x09,
	GREYBUS_PROTOCOL_I2S		= 0x0a,
	GREYBUS_PROTOCOL_SPI		= 0x0b,
	GREYBUS_PROTOCOL_DISPLAY	= 0x0c,
	GREYBUS_PROTOCOL_CAMERA		= 0x0d,
	GREYBUS_PROTOCOL_SENSOR		= 0x0e,
	GREYBUS_PROTOCOL_LED		= 0x0f,
	GREYBUS_PROTOCOL_VIBRATOR	= 0x10,
		/* ... */
	GREYBUS_PROTOCOL_VENDOR		= 0xff,
};

enum greybus_class_type {
	GREYBUS_CLASS_CONTROL		= 0x00,
	GREYBUS_CLASS_AP		= 0x01,
	GREYBUS_CLASS_GPIO		= 0x02,
	GREYBUS_CLASS_I2C		= 0x03,
	GREYBUS_CLASS_UART		= 0x04,
	GREYBUS_CLASS_HID		= 0x05,
	GREYBUS_CLASS_USB		= 0x06,
	GREYBUS_CLASS_SDIO		= 0x07,
	GREYBUS_CLASS_BATTERY		= 0x08,
	GREYBUS_CLASS_PWM		= 0x09,
	GREYBUS_CLASS_I2S		= 0x0a,
	GREYBUS_CLASS_SPI		= 0x0b,
	GREYBUS_CLASS_DISPLAY		= 0x0c,
	GREYBUS_CLASS_CAMERA		= 0x0d,
	GREYBUS_CLASS_SENSOR		= 0x0e,
	GREYBUS_CLASS_VENDOR		= 0xff,
};

/*
 * A module descriptor describes information about a module as a
 * whole, *not* the functions within it.
 */
struct greybus_descriptor_module {
	__le16	vendor;
	__le16	product;
	__le16	version;	// TODO - remove after Dec demo.
	__u8	vendor_stringid;
	__u8	product_stringid;
	__le64	unique_id;
};

/*
 * The string in a string descriptor is not NUL-terminated.  The
 * size of the descriptor will be rounded up to a multiple of 4
 * bytes, by padding the string with 0x00 bytes if necessary.
 */
struct greybus_descriptor_string {
	__u8	length;
	__u8	id;
	__u8	string[0];
};

/*
 * An interface descriptor simply defines a module-unique id for
 * each interface present on a module.  Its sole purpose is to allow
 * CPort descriptors to specify which interface they are associated
 * with.  Normally there's only one interface, with id 0.  The
 * second one must have id 1, and so on consecutively.
 *
 * The largest CPort id associated with an interface (defined by a
 * CPort descriptor in the manifest) is used to determine how to
 * encode the device id and module number in UniPro packets
 * that use the interface.
 */
struct greybus_descriptor_interface {
	__u8	id;	/* module-relative id (0..) */
};

/*
 * A CPort descriptor indicates the id of the bundle within the
 * module it's associated with, along with the CPort id used to
 * address the CPort.  The protocol id defines the format of messages
 * exchanged using the CPort.
 */
struct greybus_descriptor_cport {
	__u8	bundle;
	__le16	id;
	__u8	protocol_id;	/* enum greybus_protocol */
};

/*
 * A class descriptor defines functionality supplied by a module.
 * Beyond that, not much else is defined yet...
 */
struct greybus_descriptor_class {
	__u8	class;		/* enum greybus_class_type */
};

struct greybus_descriptor_header {
	__le16	size;
	__u8	type;		/* enum greybus_descriptor_type */
};

struct greybus_descriptor {
	struct greybus_descriptor_header		header;
	union {
		struct greybus_descriptor_module	module;
		struct greybus_descriptor_string	string;
		struct greybus_descriptor_interface	interface;
		struct greybus_descriptor_cport		cport;
		struct greybus_descriptor_class		class;
	};
};

struct greybus_manifest_header {
	__le16	size;
	__u8	version_major;
	__u8	version_minor;
};

struct greybus_manifest {
	struct greybus_manifest_header		header;
	struct greybus_descriptor		descriptors[0];
};

#pragma pack(pop)

#endif /* __GREYBUS_MANIFEST_H */