forked from vaishnavachath/mikrobus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mikrobus_manifest.h
executable file
·128 lines (110 loc) · 2.38 KB
/
mikrobus_manifest.h
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
/*
* mikroBUS manifest definition
* based on Greybus Manifest
*
*/
#ifndef __MIKROBUS_MANIFEST_H
#define __MIKROBUS_MANIFEST_H
#include <linux/bits.h>
#include <linux/types.h>
#include <linux/property.h>
#include "mikrobus_core.h"
#define MIKROBUS_VERSION_MAJOR 0
#define MIKROBUS_VERSION_MINOR 2
enum mikrobus_descriptor_type
{
MIKROBUS_TYPE_INVALID = 0x00,
GREYBUS_TYPE_INTERFACE = 0x01,
GREYBUS_TYPE_STRING = 0x02,
GREYBUS_TYPE_BUNDLE = 0x03,
GREYBUS_TYPE_CPORT = 0x04,
MIKROBUS_TYPE_MIKROBUS = 0x05,
MIKROBUS_TYPE_PROPERTY = 0x06,
MIKROBUS_TYPE_DEVICE = 0x07,
};
struct mikrobus_descriptor_string
{
__u8 length;
__u8 id;
__u8 string[0];
} __packed;
struct mikrobus_descriptor_property
{
__u8 length;
__u8 id;
__u8 propname_stringid;
__u8 type;
__u8 value[0];
} __packed;
struct mikrobus_descriptor_device
{
__u8 id;
__u8 driver_stringid;
__u8 num_properties;
__u8 protocol;
__le32 max_speed_hz;
__u8 reg;
__u8 mode;
__u8 num_gpio_resources;
__u8 cs_gpio;
__u8 irq;
__u8 irq_type;
__u8 prop_link;
__u8 gpio_link;
} __packed;
struct mikrobus_descriptor_mikrobus
{
__u8 num_devices;
__u8 rst_gpio_state;
__u8 pwm_gpio_state;
__u8 int_gpio_state;
} __packed;
struct greybus_descriptor_interface {
__u8 vendor_stringid;
__u8 product_stringid;
__u8 features;
__u8 pad;
} __packed;
struct greybus_descriptor_bundle {
__u8 id;
__u8 class;
__u8 pad[2];
} __packed;
struct greybus_descriptor_cport {
__le16 id;
__u8 bundle;
__u8 protocol_id;
} __packed;
struct mikrobus_descriptor_header
{
__le16 size;
__u8 type;
__u8 pad;
} __packed;
struct mikrobus_descriptor
{
struct mikrobus_descriptor_header header;
union {
struct mikrobus_descriptor_string string;
struct mikrobus_descriptor_device device;
struct mikrobus_descriptor_property property;
struct mikrobus_descriptor_mikrobus mikrobus;
struct greybus_descriptor_interface interface;
struct greybus_descriptor_bundle bundle;
struct greybus_descriptor_cport cport;
};
} __packed;
struct mikrobus_manifest_header
{
__le16 size;
__u8 version_major;
__u8 version_minor;
} __packed;
struct mikrobus_manifest
{
struct mikrobus_manifest_header header;
struct mikrobus_descriptor descriptors[0];
} __packed;
bool mikrobus_manifest_parse(struct click_board_info *info, void *data, size_t size);
size_t mikrobus_manifest_header_validate(void *data, size_t size);
#endif /* __MIKROBUS_MANIFEST_H */