Linux-libre 4.15.7-gnu
[librecmc/linux-libre.git] / drivers / staging / greybus / greybus_manifest.h
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Greybus manifest definition
4  *
5  * See "Greybus Application Protocol" document (version 0.1) for
6  * details on these values and structures.
7  *
8  * Copyright 2014-2015 Google Inc.
9  * Copyright 2014-2015 Linaro Ltd.
10  *
11  * Released under the GPLv2 and BSD licenses.
12  */
13
14 #ifndef __GREYBUS_MANIFEST_H
15 #define __GREYBUS_MANIFEST_H
16
17 enum greybus_descriptor_type {
18         GREYBUS_TYPE_INVALID            = 0x00,
19         GREYBUS_TYPE_INTERFACE          = 0x01,
20         GREYBUS_TYPE_STRING             = 0x02,
21         GREYBUS_TYPE_BUNDLE             = 0x03,
22         GREYBUS_TYPE_CPORT              = 0x04,
23 };
24
25 enum greybus_protocol {
26         GREYBUS_PROTOCOL_CONTROL        = 0x00,
27         /* 0x01 is unused */
28         GREYBUS_PROTOCOL_GPIO           = 0x02,
29         GREYBUS_PROTOCOL_I2C            = 0x03,
30         GREYBUS_PROTOCOL_UART           = 0x04,
31         GREYBUS_PROTOCOL_HID            = 0x05,
32         GREYBUS_PROTOCOL_USB            = 0x06,
33         GREYBUS_PROTOCOL_SDIO           = 0x07,
34         GREYBUS_PROTOCOL_POWER_SUPPLY   = 0x08,
35         GREYBUS_PROTOCOL_PWM            = 0x09,
36         /* 0x0a is unused */
37         GREYBUS_PROTOCOL_SPI            = 0x0b,
38         GREYBUS_PROTOCOL_DISPLAY        = 0x0c,
39         GREYBUS_PROTOCOL_CAMERA_MGMT    = 0x0d,
40         GREYBUS_PROTOCOL_SENSOR         = 0x0e,
41         GREYBUS_PROTOCOL_LIGHTS         = 0x0f,
42         GREYBUS_PROTOCOL_VIBRATOR       = 0x10,
43         GREYBUS_PROTOCOL_LOOPBACK       = 0x11,
44         GREYBUS_PROTOCOL_AUDIO_MGMT     = 0x12,
45         GREYBUS_PROTOCOL_AUDIO_DATA     = 0x13,
46         GREYBUS_PROTOCOL_SVC            = 0x14,
47         GREYBUS_PROTOCOL_BOOTROM        = 0x15,
48         GREYBUS_PROTOCOL_CAMERA_DATA    = 0x16,
49         GREYBUS_PROTOCOL_FW_DOWNLOAD    = 0x17,
50         GREYBUS_PROTOCOL_FW_MANAGEMENT  = 0x18,
51         GREYBUS_PROTOCOL_AUTHENTICATION = 0x19,
52         GREYBUS_PROTOCOL_LOG            = 0x1a,
53                 /* ... */
54         GREYBUS_PROTOCOL_RAW            = 0xfe,
55         GREYBUS_PROTOCOL_VENDOR         = 0xff,
56 };
57
58 enum greybus_class_type {
59         GREYBUS_CLASS_CONTROL           = 0x00,
60         /* 0x01 is unused */
61         /* 0x02 is unused */
62         /* 0x03 is unused */
63         /* 0x04 is unused */
64         GREYBUS_CLASS_HID               = 0x05,
65         /* 0x06 is unused */
66         /* 0x07 is unused */
67         GREYBUS_CLASS_POWER_SUPPLY      = 0x08,
68         /* 0x09 is unused */
69         GREYBUS_CLASS_BRIDGED_PHY       = 0x0a,
70         /* 0x0b is unused */
71         GREYBUS_CLASS_DISPLAY           = 0x0c,
72         GREYBUS_CLASS_CAMERA            = 0x0d,
73         GREYBUS_CLASS_SENSOR            = 0x0e,
74         GREYBUS_CLASS_LIGHTS            = 0x0f,
75         GREYBUS_CLASS_VIBRATOR          = 0x10,
76         GREYBUS_CLASS_LOOPBACK          = 0x11,
77         GREYBUS_CLASS_AUDIO             = 0x12,
78         /* 0x13 is unused */
79         /* 0x14 is unused */
80         GREYBUS_CLASS_BOOTROM           = 0x15,
81         GREYBUS_CLASS_FW_MANAGEMENT     = 0x16,
82         GREYBUS_CLASS_LOG               = 0x17,
83                 /* ... */
84         GREYBUS_CLASS_RAW               = 0xfe,
85         GREYBUS_CLASS_VENDOR            = 0xff,
86 };
87
88 enum {
89         GREYBUS_INTERFACE_FEATURE_TIMESYNC = BIT(0),
90 };
91
92 /*
93  * The string in a string descriptor is not NUL-terminated.  The
94  * size of the descriptor will be rounded up to a multiple of 4
95  * bytes, by padding the string with 0x00 bytes if necessary.
96  */
97 struct greybus_descriptor_string {
98         __u8    length;
99         __u8    id;
100         __u8    string[0];
101 } __packed;
102
103 /*
104  * An interface descriptor describes information about an interface as a whole,
105  * *not* the functions within it.
106  */
107 struct greybus_descriptor_interface {
108         __u8    vendor_stringid;
109         __u8    product_stringid;
110         __u8    features;
111         __u8    pad;
112 } __packed;
113
114 /*
115  * An bundle descriptor defines an identification number and a class for
116  * each bundle.
117  *
118  * @id: Uniquely identifies a bundle within a interface, its sole purpose is to
119  * allow CPort descriptors to specify which bundle they are associated with.
120  * The first bundle will have id 0, second will have 1 and so on.
121  *
122  * The largest CPort id associated with an bundle (defined by a
123  * CPort descriptor in the manifest) is used to determine how to
124  * encode the device id and module number in UniPro packets
125  * that use the bundle.
126  *
127  * @class: It is used by kernel to know the functionality provided by the
128  * bundle and will be matched against drivers functinality while probing greybus
129  * driver. It should contain one of the values defined in
130  * 'enum greybus_class_type'.
131  *
132  */
133 struct greybus_descriptor_bundle {
134         __u8    id;     /* interface-relative id (0..) */
135         __u8    class;
136         __u8    pad[2];
137 } __packed;
138
139 /*
140  * A CPort descriptor indicates the id of the bundle within the
141  * module it's associated with, along with the CPort id used to
142  * address the CPort.  The protocol id defines the format of messages
143  * exchanged using the CPort.
144  */
145 struct greybus_descriptor_cport {
146         __le16  id;
147         __u8    bundle;
148         __u8    protocol_id;    /* enum greybus_protocol */
149 } __packed;
150
151 struct greybus_descriptor_header {
152         __le16  size;
153         __u8    type;           /* enum greybus_descriptor_type */
154         __u8    pad;
155 } __packed;
156
157 struct greybus_descriptor {
158         struct greybus_descriptor_header                header;
159         union {
160                 struct greybus_descriptor_string        string;
161                 struct greybus_descriptor_interface     interface;
162                 struct greybus_descriptor_bundle        bundle;
163                 struct greybus_descriptor_cport         cport;
164         };
165 } __packed;
166
167 struct greybus_manifest_header {
168         __le16  size;
169         __u8    version_major;
170         __u8    version_minor;
171 } __packed;
172
173 struct greybus_manifest {
174         struct greybus_manifest_header          header;
175         struct greybus_descriptor               descriptors[0];
176 } __packed;
177
178 #endif /* __GREYBUS_MANIFEST_H */