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