1
2
3
4
5
6
7
8
9
10#include <linux/bitfield.h>
11#include <linux/completion.h>
12#include <linux/device.h>
13#include <linux/errno.h>
14#include <linux/kernel.h>
15#include <linux/scmi_protocol.h>
16#include <linux/types.h>
17
18#define PROTOCOL_REV_MINOR_MASK GENMASK(15, 0)
19#define PROTOCOL_REV_MAJOR_MASK GENMASK(31, 16)
20#define PROTOCOL_REV_MAJOR(x) (u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))
21#define PROTOCOL_REV_MINOR(x) (u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x)))
22#define MAX_PROTOCOLS_IMP 16
23#define MAX_OPPS 16
24
25enum scmi_common_cmd {
26 PROTOCOL_VERSION = 0x0,
27 PROTOCOL_ATTRIBUTES = 0x1,
28 PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
29};
30
31
32
33
34
35
36
37
38
39
40
41
42
43struct scmi_msg_resp_prot_version {
44 __le16 minor_version;
45 __le16 major_version;
46};
47
48
49
50
51
52
53
54
55
56
57
58
59
60struct scmi_msg_hdr {
61 u8 id;
62 u8 protocol_id;
63 u16 seq;
64 u32 status;
65 bool poll_completion;
66};
67
68
69
70
71
72
73
74struct scmi_msg {
75 void *buf;
76 size_t len;
77};
78
79
80
81
82
83
84
85
86
87
88
89struct scmi_xfer {
90 struct scmi_msg_hdr hdr;
91 struct scmi_msg tx;
92 struct scmi_msg rx;
93 struct completion done;
94};
95
96void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
97int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
98int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
99 size_t tx_size, size_t rx_size, struct scmi_xfer **p);
100int scmi_handle_put(const struct scmi_handle *handle);
101struct scmi_handle *scmi_handle_get(struct device *dev);
102void scmi_set_handle(struct scmi_device *scmi_dev);
103int scmi_version_get(const struct scmi_handle *h, u8 protocol, u32 *version);
104void scmi_setup_protocol_implemented(const struct scmi_handle *handle,
105 u8 *prot_imp);
106
107int scmi_base_protocol_init(struct scmi_handle *h);
108