]>
Commit | Line | Data |
---|---|---|
358599ef EC |
1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
2 | /* | |
3 | * Copyright (C) 2019-2020 Linaro Limited. | |
4 | */ | |
5 | #ifndef _SCMI_AGENT_UCLASS_H | |
6 | #define _SCMI_AGENT_UCLASS_H | |
7 | ||
7eb4eb54 | 8 | #include <scmi_protocols.h> |
55de62ba AT |
9 | #include <dm/device.h> |
10 | ||
358599ef | 11 | struct scmi_msg; |
85dc5828 | 12 | struct scmi_channel; |
358599ef | 13 | |
55de62ba AT |
14 | /** |
15 | * struct scmi_agent_priv - private data maintained by agent instance | |
7eb4eb54 AT |
16 | * @version: Version |
17 | * @num_agents: Number of agents | |
18 | * @num_protocols: Number of protocols | |
19 | * @impl_version: Implementation version | |
20 | * @protocols: Array of protocol IDs | |
21 | * @vendor: Vendor name | |
22 | * @sub_vendor: Sub-vendor name | |
23 | * @agent_name: Agent name | |
24 | * @agent_id: Identifier of agent | |
25 | * @base_dev: SCMI base protocol device | |
c1d2ed0c | 26 | * @pwdom_dev: SCMI power domain management protocol device |
55de62ba AT |
27 | * @clock_dev: SCMI clock protocol device |
28 | * @resetdom_dev: SCMI reset domain protocol device | |
29 | * @voltagedom_dev: SCMI voltage domain protocol device | |
30 | */ | |
31 | struct scmi_agent_priv { | |
7eb4eb54 AT |
32 | u32 version; |
33 | u32 num_agents; | |
34 | u32 num_protocols; | |
35 | u32 impl_version; | |
36 | u8 *protocols; | |
37 | u8 *vendor; | |
38 | u8 *sub_vendor; | |
39 | u8 *agent_name; | |
40 | u32 agent_id; | |
41 | struct udevice *base_dev; | |
c1d2ed0c | 42 | struct udevice *pwdom_dev; |
55de62ba AT |
43 | struct udevice *clock_dev; |
44 | struct udevice *resetdom_dev; | |
45 | struct udevice *voltagedom_dev; | |
46 | }; | |
47 | ||
7eb4eb54 AT |
48 | static inline u32 scmi_version(struct udevice *dev) |
49 | { | |
50 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->version; | |
51 | } | |
52 | ||
53 | static inline u32 scmi_num_agents(struct udevice *dev) | |
54 | { | |
55 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_agents; | |
56 | } | |
57 | ||
58 | static inline u32 scmi_num_protocols(struct udevice *dev) | |
59 | { | |
60 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_protocols; | |
61 | } | |
62 | ||
63 | static inline u32 scmi_impl_version(struct udevice *dev) | |
64 | { | |
65 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->impl_version; | |
66 | } | |
67 | ||
68 | static inline u8 *scmi_protocols(struct udevice *dev) | |
69 | { | |
70 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->protocols; | |
71 | } | |
72 | ||
73 | static inline u8 *scmi_vendor(struct udevice *dev) | |
74 | { | |
75 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->vendor; | |
76 | } | |
77 | ||
78 | static inline u8 *scmi_sub_vendor(struct udevice *dev) | |
79 | { | |
80 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->sub_vendor; | |
81 | } | |
82 | ||
83 | static inline u8 *scmi_agent_name(struct udevice *dev) | |
84 | { | |
85 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_name; | |
86 | } | |
87 | ||
88 | static inline u32 scmi_agent_id(struct udevice *dev) | |
89 | { | |
90 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_id; | |
91 | } | |
92 | ||
358599ef EC |
93 | /** |
94 | * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. | |
95 | */ | |
96 | struct scmi_agent_ops { | |
8e96801a EC |
97 | /* |
98 | * of_get_channel - Get SCMI channel from SCMI agent device tree node | |
99 | * | |
689204be AT |
100 | * @dev: SCMI agent device using the transport |
101 | * @protocol: SCMI protocol device using the transport | |
8e96801a EC |
102 | * @channel: Output reference to SCMI channel upon success |
103 | * Return 0 upon success and a negative errno on failure | |
104 | */ | |
689204be AT |
105 | int (*of_get_channel)(struct udevice *dev, struct udevice *protocol, |
106 | struct scmi_channel **channel); | |
8e96801a | 107 | |
358599ef EC |
108 | /* |
109 | * process_msg - Request transport to get the SCMI message processed | |
110 | * | |
689204be | 111 | * @dev: SCMI agent device using the transport |
358599ef EC |
112 | * @msg: SCMI message to be transmitted |
113 | */ | |
85dc5828 EC |
114 | int (*process_msg)(struct udevice *dev, struct scmi_channel *channel, |
115 | struct scmi_msg *msg); | |
358599ef EC |
116 | }; |
117 | ||
118 | #endif /* _SCMI_TRANSPORT_UCLASS_H */ |