Sudeep Holla | 4752544 | 2019-07-23 14:00:09 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Sudeep Holla | aa4f886 | 2017-03-28 11:36:07 +0100 | [diff] [blame] | 2 | /* |
| 3 | * SCMI Message Protocol driver header |
| 4 | * |
| 5 | * Copyright (C) 2018 ARM Ltd. |
| 6 | */ |
Sudeep Holla | 70771c6 | 2020-04-03 18:10:17 +0100 | [diff] [blame] | 7 | |
| 8 | #ifndef _LINUX_SCMI_PROTOCOL_H |
| 9 | #define _LINUX_SCMI_PROTOCOL_H |
| 10 | |
Sudeep Holla | 933c504 | 2017-10-30 18:33:30 +0000 | [diff] [blame] | 11 | #include <linux/device.h> |
Cristian Marussi | e7c215f | 2020-07-01 16:53:41 +0100 | [diff] [blame] | 12 | #include <linux/notifier.h> |
Sudeep Holla | aa4f886 | 2017-03-28 11:36:07 +0100 | [diff] [blame] | 13 | #include <linux/types.h> |
| 14 | |
Sudeep Holla | b6f20ff | 2017-06-06 11:16:15 +0100 | [diff] [blame] | 15 | #define SCMI_MAX_STR_SIZE 16 |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 16 | #define SCMI_MAX_NUM_RATES 16 |
Sudeep Holla | b6f20ff | 2017-06-06 11:16:15 +0100 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * struct scmi_revision_info - version information structure |
| 20 | * |
| 21 | * @major_ver: Major ABI version. Change here implies risk of backward |
| 22 | * compatibility break. |
| 23 | * @minor_ver: Minor ABI version. Change here implies new feature addition, |
| 24 | * or compatible change in ABI. |
| 25 | * @num_protocols: Number of protocols that are implemented, excluding the |
| 26 | * base protocol. |
| 27 | * @num_agents: Number of agents in the system. |
| 28 | * @impl_ver: A vendor-specific implementation version. |
| 29 | * @vendor_id: A vendor identifier(Null terminated ASCII string) |
| 30 | * @sub_vendor_id: A sub-vendor identifier(Null terminated ASCII string) |
| 31 | */ |
| 32 | struct scmi_revision_info { |
| 33 | u16 major_ver; |
| 34 | u16 minor_ver; |
| 35 | u8 num_protocols; |
| 36 | u8 num_agents; |
| 37 | u32 impl_ver; |
| 38 | char vendor_id[SCMI_MAX_STR_SIZE]; |
| 39 | char sub_vendor_id[SCMI_MAX_STR_SIZE]; |
| 40 | }; |
| 41 | |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 42 | struct scmi_clock_info { |
| 43 | char name[SCMI_MAX_STR_SIZE]; |
| 44 | bool rate_discrete; |
| 45 | union { |
| 46 | struct { |
| 47 | int num_rates; |
| 48 | u64 rates[SCMI_MAX_NUM_RATES]; |
| 49 | } list; |
| 50 | struct { |
| 51 | u64 min_rate; |
| 52 | u64 max_rate; |
| 53 | u64 step_size; |
| 54 | } range; |
| 55 | }; |
| 56 | }; |
| 57 | |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 58 | struct scmi_handle; |
| 59 | |
| 60 | /** |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 61 | * struct scmi_clk_ops - represents the various operations provided |
| 62 | * by SCMI Clock Protocol |
| 63 | * |
| 64 | * @count_get: get the count of clocks provided by SCMI |
| 65 | * @info_get: get the information of the specified clock |
| 66 | * @rate_get: request the current clock rate of a clock |
| 67 | * @rate_set: set the clock rate of a clock |
| 68 | * @enable: enables the specified clock |
| 69 | * @disable: disables the specified clock |
| 70 | */ |
| 71 | struct scmi_clk_ops { |
| 72 | int (*count_get)(const struct scmi_handle *handle); |
| 73 | |
| 74 | const struct scmi_clock_info *(*info_get) |
| 75 | (const struct scmi_handle *handle, u32 clk_id); |
| 76 | int (*rate_get)(const struct scmi_handle *handle, u32 clk_id, |
| 77 | u64 *rate); |
| 78 | int (*rate_set)(const struct scmi_handle *handle, u32 clk_id, |
Sudeep Holla | d0aba11 | 2019-07-08 09:42:22 +0100 | [diff] [blame] | 79 | u64 rate); |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 80 | int (*enable)(const struct scmi_handle *handle, u32 clk_id); |
| 81 | int (*disable)(const struct scmi_handle *handle, u32 clk_id); |
| 82 | }; |
| 83 | |
| 84 | /** |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 85 | * struct scmi_perf_ops - represents the various operations provided |
| 86 | * by SCMI Performance Protocol |
| 87 | * |
| 88 | * @limits_set: sets limits on the performance level of a domain |
| 89 | * @limits_get: gets limits on the performance level of a domain |
| 90 | * @level_set: sets the performance level of a domain |
| 91 | * @level_get: gets the performance level of a domain |
| 92 | * @device_domain_id: gets the scmi domain id for a given device |
Sudeep Holla | 7859e08 | 2018-05-09 17:52:06 +0100 | [diff] [blame] | 93 | * @transition_latency_get: gets the DVFS transition latency for a given device |
| 94 | * @device_opps_add: adds all the OPPs for a given device |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 95 | * @freq_set: sets the frequency for a given device using sustained frequency |
| 96 | * to sustained performance level mapping |
| 97 | * @freq_get: gets the frequency for a given device using sustained frequency |
| 98 | * to sustained performance level mapping |
Quentin Perret | 1a63fe9 | 2018-09-10 17:28:10 +0100 | [diff] [blame] | 99 | * @est_power_get: gets the estimated power cost for a given performance domain |
| 100 | * at a given frequency |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 101 | */ |
| 102 | struct scmi_perf_ops { |
| 103 | int (*limits_set)(const struct scmi_handle *handle, u32 domain, |
| 104 | u32 max_perf, u32 min_perf); |
| 105 | int (*limits_get)(const struct scmi_handle *handle, u32 domain, |
| 106 | u32 *max_perf, u32 *min_perf); |
| 107 | int (*level_set)(const struct scmi_handle *handle, u32 domain, |
Sudeep Holla | 5c4ba3c | 2017-07-21 11:42:24 +0100 | [diff] [blame] | 108 | u32 level, bool poll); |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 109 | int (*level_get)(const struct scmi_handle *handle, u32 domain, |
Sudeep Holla | 5c4ba3c | 2017-07-21 11:42:24 +0100 | [diff] [blame] | 110 | u32 *level, bool poll); |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 111 | int (*device_domain_id)(struct device *dev); |
Sudeep Holla | 7859e08 | 2018-05-09 17:52:06 +0100 | [diff] [blame] | 112 | int (*transition_latency_get)(const struct scmi_handle *handle, |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 113 | struct device *dev); |
Sudeep Holla | 7859e08 | 2018-05-09 17:52:06 +0100 | [diff] [blame] | 114 | int (*device_opps_add)(const struct scmi_handle *handle, |
| 115 | struct device *dev); |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 116 | int (*freq_set)(const struct scmi_handle *handle, u32 domain, |
Sudeep Holla | 5c4ba3c | 2017-07-21 11:42:24 +0100 | [diff] [blame] | 117 | unsigned long rate, bool poll); |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 118 | int (*freq_get)(const struct scmi_handle *handle, u32 domain, |
Sudeep Holla | 5c4ba3c | 2017-07-21 11:42:24 +0100 | [diff] [blame] | 119 | unsigned long *rate, bool poll); |
Quentin Perret | 1a63fe9 | 2018-09-10 17:28:10 +0100 | [diff] [blame] | 120 | int (*est_power_get)(const struct scmi_handle *handle, u32 domain, |
| 121 | unsigned long *rate, unsigned long *power); |
Nicola Mazzucato | 1909872 | 2020-06-17 10:43:31 +0100 | [diff] [blame] | 122 | bool (*fast_switch_possible)(const struct scmi_handle *handle, |
| 123 | struct device *dev); |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 124 | }; |
| 125 | |
Sudeep Holla | aa4f886 | 2017-03-28 11:36:07 +0100 | [diff] [blame] | 126 | /** |
Sudeep Holla | 76a6550 | 2017-06-06 11:32:24 +0100 | [diff] [blame] | 127 | * struct scmi_power_ops - represents the various operations provided |
| 128 | * by SCMI Power Protocol |
| 129 | * |
| 130 | * @num_domains_get: get the count of power domains provided by SCMI |
| 131 | * @name_get: gets the name of a power domain |
| 132 | * @state_set: sets the power state of a power domain |
| 133 | * @state_get: gets the power state of a power domain |
| 134 | */ |
| 135 | struct scmi_power_ops { |
| 136 | int (*num_domains_get)(const struct scmi_handle *handle); |
| 137 | char *(*name_get)(const struct scmi_handle *handle, u32 domain); |
| 138 | #define SCMI_POWER_STATE_TYPE_SHIFT 30 |
| 139 | #define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1) |
| 140 | #define SCMI_POWER_STATE_PARAM(type, id) \ |
| 141 | ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \ |
| 142 | ((id) & SCMI_POWER_STATE_ID_MASK)) |
| 143 | #define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0) |
| 144 | #define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0) |
| 145 | int (*state_set)(const struct scmi_handle *handle, u32 domain, |
| 146 | u32 state); |
| 147 | int (*state_get)(const struct scmi_handle *handle, u32 domain, |
| 148 | u32 *state); |
| 149 | }; |
| 150 | |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 151 | struct scmi_sensor_info { |
| 152 | u32 id; |
| 153 | u8 type; |
Florian Fainelli | 0b673b6 | 2019-05-08 11:46:34 -0700 | [diff] [blame] | 154 | s8 scale; |
Sudeep Holla | d09aac0 | 2019-07-08 09:41:01 +0100 | [diff] [blame] | 155 | u8 num_trip_points; |
| 156 | bool async; |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 157 | char name[SCMI_MAX_STR_SIZE]; |
| 158 | }; |
| 159 | |
| 160 | /* |
| 161 | * Partial list from Distributed Management Task Force (DMTF) specification: |
| 162 | * DSP0249 (Platform Level Data Model specification) |
| 163 | */ |
| 164 | enum scmi_sensor_class { |
| 165 | NONE = 0x0, |
| 166 | TEMPERATURE_C = 0x2, |
| 167 | VOLTAGE = 0x5, |
| 168 | CURRENT = 0x6, |
| 169 | POWER = 0x7, |
| 170 | ENERGY = 0x8, |
| 171 | }; |
| 172 | |
| 173 | /** |
| 174 | * struct scmi_sensor_ops - represents the various operations provided |
| 175 | * by SCMI Sensor Protocol |
| 176 | * |
| 177 | * @count_get: get the count of sensors provided by SCMI |
| 178 | * @info_get: get the information of the specified sensor |
Sudeep Holla | 9eefa43 | 2019-07-08 09:40:33 +0100 | [diff] [blame] | 179 | * @trip_point_config: selects and configures a trip-point of interest |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 180 | * @reading_get: gets the current value of the sensor |
| 181 | */ |
| 182 | struct scmi_sensor_ops { |
| 183 | int (*count_get)(const struct scmi_handle *handle); |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 184 | const struct scmi_sensor_info *(*info_get) |
| 185 | (const struct scmi_handle *handle, u32 sensor_id); |
Sudeep Holla | 9eefa43 | 2019-07-08 09:40:33 +0100 | [diff] [blame] | 186 | int (*trip_point_config)(const struct scmi_handle *handle, |
| 187 | u32 sensor_id, u8 trip_id, u64 trip_value); |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 188 | int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id, |
Sudeep Holla | 6a55331 | 2019-07-08 09:40:57 +0100 | [diff] [blame] | 189 | u64 *value); |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 190 | }; |
| 191 | |
Sudeep Holla | 76a6550 | 2017-06-06 11:32:24 +0100 | [diff] [blame] | 192 | /** |
Sudeep Holla | 95a15d8 | 2019-07-08 09:41:06 +0100 | [diff] [blame] | 193 | * struct scmi_reset_ops - represents the various operations provided |
| 194 | * by SCMI Reset Protocol |
| 195 | * |
| 196 | * @num_domains_get: get the count of reset domains provided by SCMI |
| 197 | * @name_get: gets the name of a reset domain |
| 198 | * @latency_get: gets the reset latency for the specified reset domain |
| 199 | * @reset: resets the specified reset domain |
| 200 | * @assert: explicitly assert reset signal of the specified reset domain |
| 201 | * @deassert: explicitly deassert reset signal of the specified reset domain |
| 202 | */ |
| 203 | struct scmi_reset_ops { |
| 204 | int (*num_domains_get)(const struct scmi_handle *handle); |
| 205 | char *(*name_get)(const struct scmi_handle *handle, u32 domain); |
| 206 | int (*latency_get)(const struct scmi_handle *handle, u32 domain); |
| 207 | int (*reset)(const struct scmi_handle *handle, u32 domain); |
| 208 | int (*assert)(const struct scmi_handle *handle, u32 domain); |
| 209 | int (*deassert)(const struct scmi_handle *handle, u32 domain); |
| 210 | }; |
| 211 | |
| 212 | /** |
Cristian Marussi | e7c215f | 2020-07-01 16:53:41 +0100 | [diff] [blame] | 213 | * struct scmi_notify_ops - represents notifications' operations provided by |
| 214 | * SCMI core |
| 215 | * @register_event_notifier: Register a notifier_block for the requested event |
| 216 | * @unregister_event_notifier: Unregister a notifier_block for the requested |
| 217 | * event |
| 218 | * |
| 219 | * A user can register/unregister its own notifier_block against the wanted |
| 220 | * platform instance regarding the desired event identified by the |
| 221 | * tuple: (proto_id, evt_id, src_id) using the provided register/unregister |
| 222 | * interface where: |
| 223 | * |
| 224 | * @handle: The handle identifying the platform instance to use |
| 225 | * @proto_id: The protocol ID as in SCMI Specification |
| 226 | * @evt_id: The message ID of the desired event as in SCMI Specification |
| 227 | * @src_id: A pointer to the desired source ID if different sources are |
| 228 | * possible for the protocol (like domain_id, sensor_id...etc) |
| 229 | * |
| 230 | * @src_id can be provided as NULL if it simply does NOT make sense for |
| 231 | * the protocol at hand, OR if the user is explicitly interested in |
| 232 | * receiving notifications from ANY existent source associated to the |
| 233 | * specified proto_id / evt_id. |
| 234 | * |
| 235 | * Received notifications are finally delivered to the registered users, |
| 236 | * invoking the callback provided with the notifier_block *nb as follows: |
| 237 | * |
| 238 | * int user_cb(nb, evt_id, report) |
| 239 | * |
| 240 | * with: |
| 241 | * |
| 242 | * @nb: The notifier block provided by the user |
| 243 | * @evt_id: The message ID of the delivered event |
| 244 | * @report: A custom struct describing the specific event delivered |
| 245 | */ |
| 246 | struct scmi_notify_ops { |
| 247 | int (*register_event_notifier)(const struct scmi_handle *handle, |
| 248 | u8 proto_id, u8 evt_id, u32 *src_id, |
| 249 | struct notifier_block *nb); |
| 250 | int (*unregister_event_notifier)(const struct scmi_handle *handle, |
| 251 | u8 proto_id, u8 evt_id, u32 *src_id, |
| 252 | struct notifier_block *nb); |
| 253 | }; |
| 254 | |
| 255 | /** |
Sudeep Holla | aa4f886 | 2017-03-28 11:36:07 +0100 | [diff] [blame] | 256 | * struct scmi_handle - Handle returned to ARM SCMI clients for usage. |
| 257 | * |
| 258 | * @dev: pointer to the SCMI device |
Sudeep Holla | b6f20ff | 2017-06-06 11:16:15 +0100 | [diff] [blame] | 259 | * @version: pointer to the structure containing SCMI version information |
Sudeep Holla | 76a6550 | 2017-06-06 11:32:24 +0100 | [diff] [blame] | 260 | * @power_ops: pointer to set of power protocol operations |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 261 | * @perf_ops: pointer to set of performance protocol operations |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 262 | * @clk_ops: pointer to set of clock protocol operations |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 263 | * @sensor_ops: pointer to set of sensor protocol operations |
Sudeep Holla | 95a15d8 | 2019-07-08 09:41:06 +0100 | [diff] [blame] | 264 | * @reset_ops: pointer to set of reset protocol operations |
Cristian Marussi | e7c215f | 2020-07-01 16:53:41 +0100 | [diff] [blame] | 265 | * @notify_ops: pointer to set of notifications related operations |
Sudeep Holla | 1baf47c | 2018-05-09 17:52:06 +0100 | [diff] [blame] | 266 | * @perf_priv: pointer to private data structure specific to performance |
| 267 | * protocol(for internal use only) |
| 268 | * @clk_priv: pointer to private data structure specific to clock |
| 269 | * protocol(for internal use only) |
| 270 | * @power_priv: pointer to private data structure specific to power |
| 271 | * protocol(for internal use only) |
| 272 | * @sensor_priv: pointer to private data structure specific to sensors |
| 273 | * protocol(for internal use only) |
Sudeep Holla | 95a15d8 | 2019-07-08 09:41:06 +0100 | [diff] [blame] | 274 | * @reset_priv: pointer to private data structure specific to reset |
| 275 | * protocol(for internal use only) |
Cristian Marussi | 1fc2dd1 | 2020-07-01 16:53:40 +0100 | [diff] [blame] | 276 | * @notify_priv: pointer to private data structure specific to notifications |
| 277 | * (for internal use only) |
Sudeep Holla | aa4f886 | 2017-03-28 11:36:07 +0100 | [diff] [blame] | 278 | */ |
| 279 | struct scmi_handle { |
| 280 | struct device *dev; |
Sudeep Holla | b6f20ff | 2017-06-06 11:16:15 +0100 | [diff] [blame] | 281 | struct scmi_revision_info *version; |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 282 | struct scmi_perf_ops *perf_ops; |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 283 | struct scmi_clk_ops *clk_ops; |
Sudeep Holla | 76a6550 | 2017-06-06 11:32:24 +0100 | [diff] [blame] | 284 | struct scmi_power_ops *power_ops; |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 285 | struct scmi_sensor_ops *sensor_ops; |
Sudeep Holla | 95a15d8 | 2019-07-08 09:41:06 +0100 | [diff] [blame] | 286 | struct scmi_reset_ops *reset_ops; |
Cristian Marussi | e7c215f | 2020-07-01 16:53:41 +0100 | [diff] [blame] | 287 | struct scmi_notify_ops *notify_ops; |
Sudeep Holla | a9e3fbf | 2017-06-06 11:22:51 +0100 | [diff] [blame] | 288 | /* for protocol internal use */ |
| 289 | void *perf_priv; |
Sudeep Holla | 5f6c643 | 2017-06-06 11:27:57 +0100 | [diff] [blame] | 290 | void *clk_priv; |
Sudeep Holla | 76a6550 | 2017-06-06 11:32:24 +0100 | [diff] [blame] | 291 | void *power_priv; |
Sudeep Holla | 5179c52 | 2017-06-06 11:38:10 +0100 | [diff] [blame] | 292 | void *sensor_priv; |
Sudeep Holla | 95a15d8 | 2019-07-08 09:41:06 +0100 | [diff] [blame] | 293 | void *reset_priv; |
Cristian Marussi | 1fc2dd1 | 2020-07-01 16:53:40 +0100 | [diff] [blame] | 294 | void *notify_priv; |
Sudeep Holla | b6f20ff | 2017-06-06 11:16:15 +0100 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | enum scmi_std_protocol { |
| 298 | SCMI_PROTOCOL_BASE = 0x10, |
| 299 | SCMI_PROTOCOL_POWER = 0x11, |
| 300 | SCMI_PROTOCOL_SYSTEM = 0x12, |
| 301 | SCMI_PROTOCOL_PERF = 0x13, |
| 302 | SCMI_PROTOCOL_CLOCK = 0x14, |
| 303 | SCMI_PROTOCOL_SENSOR = 0x15, |
Sudeep Holla | 95a15d8 | 2019-07-08 09:41:06 +0100 | [diff] [blame] | 304 | SCMI_PROTOCOL_RESET = 0x16, |
Sudeep Holla | aa4f886 | 2017-03-28 11:36:07 +0100 | [diff] [blame] | 305 | }; |
Sudeep Holla | 933c504 | 2017-10-30 18:33:30 +0000 | [diff] [blame] | 306 | |
| 307 | struct scmi_device { |
| 308 | u32 id; |
| 309 | u8 protocol_id; |
Sudeep Holla | ee7a9c9 | 2018-12-21 18:08:08 +0000 | [diff] [blame] | 310 | const char *name; |
Sudeep Holla | 933c504 | 2017-10-30 18:33:30 +0000 | [diff] [blame] | 311 | struct device dev; |
| 312 | struct scmi_handle *handle; |
| 313 | }; |
| 314 | |
| 315 | #define to_scmi_dev(d) container_of(d, struct scmi_device, dev) |
| 316 | |
| 317 | struct scmi_device * |
Sudeep Holla | ee7a9c9 | 2018-12-21 18:08:08 +0000 | [diff] [blame] | 318 | scmi_device_create(struct device_node *np, struct device *parent, int protocol, |
| 319 | const char *name); |
Sudeep Holla | 933c504 | 2017-10-30 18:33:30 +0000 | [diff] [blame] | 320 | void scmi_device_destroy(struct scmi_device *scmi_dev); |
| 321 | |
| 322 | struct scmi_device_id { |
| 323 | u8 protocol_id; |
Sudeep Holla | ee7a9c9 | 2018-12-21 18:08:08 +0000 | [diff] [blame] | 324 | const char *name; |
Sudeep Holla | 933c504 | 2017-10-30 18:33:30 +0000 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | struct scmi_driver { |
| 328 | const char *name; |
| 329 | int (*probe)(struct scmi_device *sdev); |
| 330 | void (*remove)(struct scmi_device *sdev); |
| 331 | const struct scmi_device_id *id_table; |
| 332 | |
| 333 | struct device_driver driver; |
| 334 | }; |
| 335 | |
| 336 | #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver) |
| 337 | |
| 338 | #ifdef CONFIG_ARM_SCMI_PROTOCOL |
| 339 | int scmi_driver_register(struct scmi_driver *driver, |
| 340 | struct module *owner, const char *mod_name); |
| 341 | void scmi_driver_unregister(struct scmi_driver *driver); |
| 342 | #else |
| 343 | static inline int |
| 344 | scmi_driver_register(struct scmi_driver *driver, struct module *owner, |
| 345 | const char *mod_name) |
| 346 | { |
| 347 | return -EINVAL; |
| 348 | } |
| 349 | |
| 350 | static inline void scmi_driver_unregister(struct scmi_driver *driver) {} |
| 351 | #endif /* CONFIG_ARM_SCMI_PROTOCOL */ |
| 352 | |
| 353 | #define scmi_register(driver) \ |
| 354 | scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) |
| 355 | #define scmi_unregister(driver) \ |
| 356 | scmi_driver_unregister(driver) |
| 357 | |
| 358 | /** |
| 359 | * module_scmi_driver() - Helper macro for registering a scmi driver |
| 360 | * @__scmi_driver: scmi_driver structure |
| 361 | * |
| 362 | * Helper macro for scmi drivers to set up proper module init / exit |
| 363 | * functions. Replaces module_init() and module_exit() and keeps people from |
| 364 | * printing pointless things to the kernel log when their driver is loaded. |
| 365 | */ |
| 366 | #define module_scmi_driver(__scmi_driver) \ |
| 367 | module_driver(__scmi_driver, scmi_register, scmi_unregister) |
| 368 | |
| 369 | typedef int (*scmi_prot_init_fn_t)(struct scmi_handle *); |
| 370 | int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn); |
| 371 | void scmi_protocol_unregister(int protocol_id); |
Sudeep Holla | 70771c6 | 2020-04-03 18:10:17 +0100 | [diff] [blame] | 372 | |
Cristian Marussi | e27077b | 2020-07-01 16:53:44 +0100 | [diff] [blame] | 373 | /* SCMI Notification API - Custom Event Reports */ |
| 374 | enum scmi_notification_events { |
| 375 | SCMI_EVENT_POWER_STATE_CHANGED = 0x0, |
Cristian Marussi | fb5086d | 2020-07-01 16:53:45 +0100 | [diff] [blame] | 376 | SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0, |
| 377 | SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1, |
Cristian Marussi | 128e3e9 | 2020-07-01 16:53:46 +0100 | [diff] [blame] | 378 | SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0, |
Cristian Marussi | 469ca18 | 2020-07-01 16:53:47 +0100 | [diff] [blame] | 379 | SCMI_EVENT_RESET_ISSUED = 0x0, |
Cristian Marussi | 585dfab | 2020-07-01 16:53:48 +0100 | [diff] [blame] | 380 | SCMI_EVENT_BASE_ERROR_EVENT = 0x0, |
Cristian Marussi | e27077b | 2020-07-01 16:53:44 +0100 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | struct scmi_power_state_changed_report { |
Cristian Marussi | 72a5eb9 | 2020-07-10 14:39:19 +0100 | [diff] [blame^] | 384 | ktime_t timestamp; |
| 385 | unsigned int agent_id; |
| 386 | unsigned int domain_id; |
| 387 | unsigned int power_state; |
Cristian Marussi | e27077b | 2020-07-01 16:53:44 +0100 | [diff] [blame] | 388 | }; |
| 389 | |
Cristian Marussi | fb5086d | 2020-07-01 16:53:45 +0100 | [diff] [blame] | 390 | struct scmi_perf_limits_report { |
Cristian Marussi | 72a5eb9 | 2020-07-10 14:39:19 +0100 | [diff] [blame^] | 391 | ktime_t timestamp; |
| 392 | unsigned int agent_id; |
| 393 | unsigned int domain_id; |
| 394 | unsigned int range_max; |
| 395 | unsigned int range_min; |
Cristian Marussi | fb5086d | 2020-07-01 16:53:45 +0100 | [diff] [blame] | 396 | }; |
| 397 | |
| 398 | struct scmi_perf_level_report { |
Cristian Marussi | 72a5eb9 | 2020-07-10 14:39:19 +0100 | [diff] [blame^] | 399 | ktime_t timestamp; |
| 400 | unsigned int agent_id; |
| 401 | unsigned int domain_id; |
| 402 | unsigned int performance_level; |
Cristian Marussi | fb5086d | 2020-07-01 16:53:45 +0100 | [diff] [blame] | 403 | }; |
| 404 | |
Cristian Marussi | 128e3e9 | 2020-07-01 16:53:46 +0100 | [diff] [blame] | 405 | struct scmi_sensor_trip_point_report { |
Cristian Marussi | 72a5eb9 | 2020-07-10 14:39:19 +0100 | [diff] [blame^] | 406 | ktime_t timestamp; |
| 407 | unsigned int agent_id; |
| 408 | unsigned int sensor_id; |
| 409 | unsigned int trip_point_desc; |
Cristian Marussi | 128e3e9 | 2020-07-01 16:53:46 +0100 | [diff] [blame] | 410 | }; |
| 411 | |
Cristian Marussi | 469ca18 | 2020-07-01 16:53:47 +0100 | [diff] [blame] | 412 | struct scmi_reset_issued_report { |
Cristian Marussi | 72a5eb9 | 2020-07-10 14:39:19 +0100 | [diff] [blame^] | 413 | ktime_t timestamp; |
| 414 | unsigned int agent_id; |
| 415 | unsigned int domain_id; |
| 416 | unsigned int reset_state; |
Cristian Marussi | 469ca18 | 2020-07-01 16:53:47 +0100 | [diff] [blame] | 417 | }; |
| 418 | |
Cristian Marussi | 585dfab | 2020-07-01 16:53:48 +0100 | [diff] [blame] | 419 | struct scmi_base_error_report { |
Cristian Marussi | 72a5eb9 | 2020-07-10 14:39:19 +0100 | [diff] [blame^] | 420 | ktime_t timestamp; |
| 421 | unsigned int agent_id; |
| 422 | bool fatal; |
| 423 | unsigned int cmd_count; |
| 424 | unsigned long long reports[]; |
Cristian Marussi | 585dfab | 2020-07-01 16:53:48 +0100 | [diff] [blame] | 425 | }; |
| 426 | |
Sudeep Holla | 70771c6 | 2020-04-03 18:10:17 +0100 | [diff] [blame] | 427 | #endif /* _LINUX_SCMI_PROTOCOL_H */ |