14752544aSSudeep Holla /* SPDX-License-Identifier: GPL-2.0-only */
2aa4f886fSSudeep Holla /*
3aa4f886fSSudeep Holla * SCMI Message Protocol driver header
4aa4f886fSSudeep Holla *
548dc16e2SCristian Marussi * Copyright (C) 2018-2021 ARM Ltd.
6aa4f886fSSudeep Holla */
770771c69SSudeep Holla
870771c69SSudeep Holla #ifndef _LINUX_SCMI_PROTOCOL_H
970771c69SSudeep Holla #define _LINUX_SCMI_PROTOCOL_H
1070771c69SSudeep Holla
111fe00b8bSCristian Marussi #include <linux/bitfield.h>
12933c5044SSudeep Holla #include <linux/device.h>
13e7c215f3SCristian Marussi #include <linux/notifier.h>
14aa4f886fSSudeep Holla #include <linux/types.h>
15aa4f886fSSudeep Holla
16b260fccaSCristian Marussi #define SCMI_MAX_STR_SIZE 64
174314f9f4SCristian Marussi #define SCMI_SHORT_NAME_MAX_SIZE 16
185f6c6430SSudeep Holla #define SCMI_MAX_NUM_RATES 16
19b6f20ff8SSudeep Holla
20b6f20ff8SSudeep Holla /**
21b6f20ff8SSudeep Holla * struct scmi_revision_info - version information structure
22b6f20ff8SSudeep Holla *
23b6f20ff8SSudeep Holla * @major_ver: Major ABI version. Change here implies risk of backward
24b6f20ff8SSudeep Holla * compatibility break.
25b6f20ff8SSudeep Holla * @minor_ver: Minor ABI version. Change here implies new feature addition,
26b6f20ff8SSudeep Holla * or compatible change in ABI.
27b6f20ff8SSudeep Holla * @num_protocols: Number of protocols that are implemented, excluding the
28b6f20ff8SSudeep Holla * base protocol.
29b6f20ff8SSudeep Holla * @num_agents: Number of agents in the system.
30b6f20ff8SSudeep Holla * @impl_ver: A vendor-specific implementation version.
31b6f20ff8SSudeep Holla * @vendor_id: A vendor identifier(Null terminated ASCII string)
32b6f20ff8SSudeep Holla * @sub_vendor_id: A sub-vendor identifier(Null terminated ASCII string)
33b6f20ff8SSudeep Holla */
34b6f20ff8SSudeep Holla struct scmi_revision_info {
35b6f20ff8SSudeep Holla u16 major_ver;
36b6f20ff8SSudeep Holla u16 minor_ver;
37b6f20ff8SSudeep Holla u8 num_protocols;
38b6f20ff8SSudeep Holla u8 num_agents;
39b6f20ff8SSudeep Holla u32 impl_ver;
404314f9f4SCristian Marussi char vendor_id[SCMI_SHORT_NAME_MAX_SIZE];
414314f9f4SCristian Marussi char sub_vendor_id[SCMI_SHORT_NAME_MAX_SIZE];
42b6f20ff8SSudeep Holla };
43b6f20ff8SSudeep Holla
445f6c6430SSudeep Holla struct scmi_clock_info {
455f6c6430SSudeep Holla char name[SCMI_MAX_STR_SIZE];
4618f295b7SCristian Marussi unsigned int enable_latency;
475f6c6430SSudeep Holla bool rate_discrete;
487aa75496SCristian Marussi bool rate_changed_notifications;
497aa75496SCristian Marussi bool rate_change_requested_notifications;
50dc36561eSPeng Fan bool state_ctrl_forbidden;
51dc36561eSPeng Fan bool rate_ctrl_forbidden;
52dc36561eSPeng Fan bool parent_ctrl_forbidden;
53e4ad2b01SCristian Marussi bool extended_config;
545f6c6430SSudeep Holla union {
555f6c6430SSudeep Holla struct {
565f6c6430SSudeep Holla int num_rates;
575f6c6430SSudeep Holla u64 rates[SCMI_MAX_NUM_RATES];
585f6c6430SSudeep Holla } list;
595f6c6430SSudeep Holla struct {
605f6c6430SSudeep Holla u64 min_rate;
615f6c6430SSudeep Holla u64 max_rate;
625f6c6430SSudeep Holla u64 step_size;
635f6c6430SSudeep Holla } range;
645f6c6430SSudeep Holla };
6577bbfe60SPeng Fan int num_parents;
6677bbfe60SPeng Fan u32 *parents;
675f6c6430SSudeep Holla };
685f6c6430SSudeep Holla
695e0fd202SLukasz Luba enum scmi_power_scale {
705e0fd202SLukasz Luba SCMI_POWER_BOGOWATTS,
715e0fd202SLukasz Luba SCMI_POWER_MILLIWATTS,
725e0fd202SLukasz Luba SCMI_POWER_MICROWATTS
735e0fd202SLukasz Luba };
745e0fd202SLukasz Luba
75a9e3fbfaSSudeep Holla struct scmi_handle;
7623934efeSCristian Marussi struct scmi_device;
7723934efeSCristian Marussi struct scmi_protocol_handle;
78a9e3fbfaSSudeep Holla
7962092c42SCristian Marussi enum scmi_clock_oem_config {
8062092c42SCristian Marussi SCMI_CLOCK_CFG_DUTY_CYCLE = 0x1,
8162092c42SCristian Marussi SCMI_CLOCK_CFG_PHASE,
8262092c42SCristian Marussi SCMI_CLOCK_CFG_OEM_START = 0x80,
8362092c42SCristian Marussi SCMI_CLOCK_CFG_OEM_END = 0xFF,
8462092c42SCristian Marussi };
8562092c42SCristian Marussi
86a9e3fbfaSSudeep Holla /**
87887281c7SCristian Marussi * struct scmi_clk_proto_ops - represents the various operations provided
885f6c6430SSudeep Holla * by SCMI Clock Protocol
895f6c6430SSudeep Holla *
905f6c6430SSudeep Holla * @count_get: get the count of clocks provided by SCMI
915f6c6430SSudeep Holla * @info_get: get the information of the specified clock
925f6c6430SSudeep Holla * @rate_get: request the current clock rate of a clock
935f6c6430SSudeep Holla * @rate_set: set the clock rate of a clock
945f6c6430SSudeep Holla * @enable: enables the specified clock
955f6c6430SSudeep Holla * @disable: disables the specified clock
9634592bf0SCristian Marussi * @state_get: get the status of the specified clock
97141b4fa0SCristian Marussi * @config_oem_get: get the value of an OEM specific clock config
98141b4fa0SCristian Marussi * @config_oem_set: set the value of an OEM specific clock config
9977bbfe60SPeng Fan * @parent_get: get the parent id of a clk
10077bbfe60SPeng Fan * @parent_set: set the parent of a clock
1015f6c6430SSudeep Holla */
102887281c7SCristian Marussi struct scmi_clk_proto_ops {
103887281c7SCristian Marussi int (*count_get)(const struct scmi_protocol_handle *ph);
104887281c7SCristian Marussi
1051ecb7d27SCristian Marussi const struct scmi_clock_info __must_check *(*info_get)
106887281c7SCristian Marussi (const struct scmi_protocol_handle *ph, u32 clk_id);
107887281c7SCristian Marussi int (*rate_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
108887281c7SCristian Marussi u64 *rate);
109887281c7SCristian Marussi int (*rate_set)(const struct scmi_protocol_handle *ph, u32 clk_id,
110887281c7SCristian Marussi u64 rate);
11103a95cf2SCristian Marussi int (*enable)(const struct scmi_protocol_handle *ph, u32 clk_id,
11203a95cf2SCristian Marussi bool atomic);
11303a95cf2SCristian Marussi int (*disable)(const struct scmi_protocol_handle *ph, u32 clk_id,
11403a95cf2SCristian Marussi bool atomic);
11534592bf0SCristian Marussi int (*state_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
11634592bf0SCristian Marussi bool *enabled, bool atomic);
117141b4fa0SCristian Marussi int (*config_oem_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
11862092c42SCristian Marussi enum scmi_clock_oem_config oem_type,
11962092c42SCristian Marussi u32 *oem_val, u32 *attributes, bool atomic);
120141b4fa0SCristian Marussi int (*config_oem_set)(const struct scmi_protocol_handle *ph, u32 clk_id,
12162092c42SCristian Marussi enum scmi_clock_oem_config oem_type,
12262092c42SCristian Marussi u32 oem_val, bool atomic);
12377bbfe60SPeng Fan int (*parent_get)(const struct scmi_protocol_handle *ph, u32 clk_id, u32 *parent_id);
12477bbfe60SPeng Fan int (*parent_set)(const struct scmi_protocol_handle *ph, u32 clk_id, u32 parent_id);
125887281c7SCristian Marussi };
126887281c7SCristian Marussi
1273d99ed60SUlf Hansson struct scmi_perf_domain_info {
1283d99ed60SUlf Hansson char name[SCMI_MAX_STR_SIZE];
1293d99ed60SUlf Hansson bool set_perf;
1303d99ed60SUlf Hansson };
1313d99ed60SUlf Hansson
1325f6c6430SSudeep Holla /**
1331fec5e6bSCristian Marussi * struct scmi_perf_proto_ops - represents the various operations provided
134a9e3fbfaSSudeep Holla * by SCMI Performance Protocol
135a9e3fbfaSSudeep Holla *
136e9090e70SUlf Hansson * @num_domains_get: gets the number of supported performance domains
1373d99ed60SUlf Hansson * @info_get: get the information of a performance domain
138a9e3fbfaSSudeep Holla * @limits_set: sets limits on the performance level of a domain
139a9e3fbfaSSudeep Holla * @limits_get: gets limits on the performance level of a domain
140a9e3fbfaSSudeep Holla * @level_set: sets the performance level of a domain
141a9e3fbfaSSudeep Holla * @level_get: gets the performance level of a domain
1427859e08cSSudeep Holla * @transition_latency_get: gets the DVFS transition latency for a given device
143ad86f7e9SPierre Gondois * @rate_limit_get: gets the minimum time (us) required between successive
144ad86f7e9SPierre Gondois * requests
1457859e08cSSudeep Holla * @device_opps_add: adds all the OPPs for a given device
146a9e3fbfaSSudeep Holla * @freq_set: sets the frequency for a given device using sustained frequency
147a9e3fbfaSSudeep Holla * to sustained performance level mapping
148a9e3fbfaSSudeep Holla * @freq_get: gets the frequency for a given device using sustained frequency
149a9e3fbfaSSudeep Holla * to sustained performance level mapping
1501a63fe9aSQuentin Perret * @est_power_get: gets the estimated power cost for a given performance domain
1511a63fe9aSQuentin Perret * at a given frequency
15252f83955SSudeep Holla * @fast_switch_possible: indicates if fast DVFS switching is possible or not
15352f83955SSudeep Holla * for a given device
1542441caa8SPierre Gondois * @fast_switch_rate_limit: gets the minimum time (us) required between
1552441caa8SPierre Gondois * successive fast_switching requests
15652f83955SSudeep Holla * @power_scale_mw_get: indicates if the power values provided are in milliWatts
15752f83955SSudeep Holla * or in some other (abstract) scale
158a9e3fbfaSSudeep Holla */
1591fec5e6bSCristian Marussi struct scmi_perf_proto_ops {
160e9090e70SUlf Hansson int (*num_domains_get)(const struct scmi_protocol_handle *ph);
1613d99ed60SUlf Hansson const struct scmi_perf_domain_info __must_check *(*info_get)
1623d99ed60SUlf Hansson (const struct scmi_protocol_handle *ph, u32 domain);
1631fec5e6bSCristian Marussi int (*limits_set)(const struct scmi_protocol_handle *ph, u32 domain,
1641fec5e6bSCristian Marussi u32 max_perf, u32 min_perf);
1651fec5e6bSCristian Marussi int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain,
1661fec5e6bSCristian Marussi u32 *max_perf, u32 *min_perf);
1671fec5e6bSCristian Marussi int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain,
1681fec5e6bSCristian Marussi u32 level, bool poll);
1691fec5e6bSCristian Marussi int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain,
1701fec5e6bSCristian Marussi u32 *level, bool poll);
1711fec5e6bSCristian Marussi int (*transition_latency_get)(const struct scmi_protocol_handle *ph,
17239dfa5b9SUlf Hansson u32 domain);
173ad86f7e9SPierre Gondois int (*rate_limit_get)(const struct scmi_protocol_handle *ph,
174ad86f7e9SPierre Gondois u32 domain, u32 *rate_limit);
1751fec5e6bSCristian Marussi int (*device_opps_add)(const struct scmi_protocol_handle *ph,
17639dfa5b9SUlf Hansson struct device *dev, u32 domain);
1771fec5e6bSCristian Marussi int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain,
1781fec5e6bSCristian Marussi unsigned long rate, bool poll);
1791fec5e6bSCristian Marussi int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain,
1801fec5e6bSCristian Marussi unsigned long *rate, bool poll);
1811fec5e6bSCristian Marussi int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain,
1821fec5e6bSCristian Marussi unsigned long *rate, unsigned long *power);
1831fec5e6bSCristian Marussi bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph,
18439dfa5b9SUlf Hansson u32 domain);
1852441caa8SPierre Gondois int (*fast_switch_rate_limit)(const struct scmi_protocol_handle *ph,
1862441caa8SPierre Gondois u32 domain, u32 *rate_limit);
1875e0fd202SLukasz Luba enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph);
1881fec5e6bSCristian Marussi };
1891fec5e6bSCristian Marussi
190aa4f886fSSudeep Holla /**
1919bc8069cSCristian Marussi * struct scmi_power_proto_ops - represents the various operations provided
19276a65509SSudeep Holla * by SCMI Power Protocol
19376a65509SSudeep Holla *
19476a65509SSudeep Holla * @num_domains_get: get the count of power domains provided by SCMI
19576a65509SSudeep Holla * @name_get: gets the name of a power domain
19676a65509SSudeep Holla * @state_set: sets the power state of a power domain
19776a65509SSudeep Holla * @state_get: gets the power state of a power domain
19876a65509SSudeep Holla */
1999bc8069cSCristian Marussi struct scmi_power_proto_ops {
2009bc8069cSCristian Marussi int (*num_domains_get)(const struct scmi_protocol_handle *ph);
201992be5d3SCristian Marussi const char *(*name_get)(const struct scmi_protocol_handle *ph,
202992be5d3SCristian Marussi u32 domain);
20376a65509SSudeep Holla #define SCMI_POWER_STATE_TYPE_SHIFT 30
20476a65509SSudeep Holla #define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1)
20576a65509SSudeep Holla #define SCMI_POWER_STATE_PARAM(type, id) \
20676a65509SSudeep Holla ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \
20776a65509SSudeep Holla ((id) & SCMI_POWER_STATE_ID_MASK))
20876a65509SSudeep Holla #define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0)
20976a65509SSudeep Holla #define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0)
2109bc8069cSCristian Marussi int (*state_set)(const struct scmi_protocol_handle *ph, u32 domain,
2119bc8069cSCristian Marussi u32 state);
2129bc8069cSCristian Marussi int (*state_get)(const struct scmi_protocol_handle *ph, u32 domain,
2139bc8069cSCristian Marussi u32 *state);
2149bc8069cSCristian Marussi };
2159bc8069cSCristian Marussi
2161fe00b8bSCristian Marussi /**
21752f83955SSudeep Holla * struct scmi_sensor_reading - represent a timestamped read
218e2083d36SCristian Marussi *
219e2083d36SCristian Marussi * Used by @reading_get_timestamped method.
220e2083d36SCristian Marussi *
221e2083d36SCristian Marussi * @value: The signed value sensor read.
222e2083d36SCristian Marussi * @timestamp: An unsigned timestamp for the sensor read, as provided by
223e2083d36SCristian Marussi * SCMI platform. Set to zero when not available.
224e2083d36SCristian Marussi */
225e2083d36SCristian Marussi struct scmi_sensor_reading {
226e2083d36SCristian Marussi long long value;
227e2083d36SCristian Marussi unsigned long long timestamp;
228e2083d36SCristian Marussi };
229e2083d36SCristian Marussi
230e2083d36SCristian Marussi /**
23152f83955SSudeep Holla * struct scmi_range_attrs - specifies a sensor or axis values' range
2321fe00b8bSCristian Marussi * @min_range: The minimum value which can be represented by the sensor/axis.
2331fe00b8bSCristian Marussi * @max_range: The maximum value which can be represented by the sensor/axis.
2341fe00b8bSCristian Marussi */
2351fe00b8bSCristian Marussi struct scmi_range_attrs {
2361fe00b8bSCristian Marussi long long min_range;
2371fe00b8bSCristian Marussi long long max_range;
2381fe00b8bSCristian Marussi };
2391fe00b8bSCristian Marussi
2401fe00b8bSCristian Marussi /**
24152f83955SSudeep Holla * struct scmi_sensor_axis_info - describes one sensor axes
2421fe00b8bSCristian Marussi * @id: The axes ID.
2431fe00b8bSCristian Marussi * @type: Axes type. Chosen amongst one of @enum scmi_sensor_class.
2441fe00b8bSCristian Marussi * @scale: Power-of-10 multiplier applied to the axis unit.
2451fe00b8bSCristian Marussi * @name: NULL-terminated string representing axes name as advertised by
2461fe00b8bSCristian Marussi * SCMI platform.
2471fe00b8bSCristian Marussi * @extended_attrs: Flag to indicate the presence of additional extended
2481fe00b8bSCristian Marussi * attributes for this axes.
2491fe00b8bSCristian Marussi * @resolution: Extended attribute representing the resolution of the axes.
2501fe00b8bSCristian Marussi * Set to 0 if not reported by this axes.
2511fe00b8bSCristian Marussi * @exponent: Extended attribute representing the power-of-10 multiplier that
2521fe00b8bSCristian Marussi * is applied to the resolution field. Set to 0 if not reported by
2531fe00b8bSCristian Marussi * this axes.
2541fe00b8bSCristian Marussi * @attrs: Extended attributes representing minimum and maximum values
2551fe00b8bSCristian Marussi * measurable by this axes. Set to 0 if not reported by this sensor.
2561fe00b8bSCristian Marussi */
2571fe00b8bSCristian Marussi struct scmi_sensor_axis_info {
2581fe00b8bSCristian Marussi unsigned int id;
2591fe00b8bSCristian Marussi unsigned int type;
2601fe00b8bSCristian Marussi int scale;
2615179c523SSudeep Holla char name[SCMI_MAX_STR_SIZE];
2621fe00b8bSCristian Marussi bool extended_attrs;
2631fe00b8bSCristian Marussi unsigned int resolution;
2641fe00b8bSCristian Marussi int exponent;
2651fe00b8bSCristian Marussi struct scmi_range_attrs attrs;
2661fe00b8bSCristian Marussi };
2671fe00b8bSCristian Marussi
2681fe00b8bSCristian Marussi /**
26952f83955SSudeep Holla * struct scmi_sensor_intervals_info - describes number and type of available
27052f83955SSudeep Holla * update intervals
2711fe00b8bSCristian Marussi * @segmented: Flag for segmented intervals' representation. When True there
2721fe00b8bSCristian Marussi * will be exactly 3 intervals in @desc, with each entry
2731fe00b8bSCristian Marussi * representing a member of a segment in this order:
2741fe00b8bSCristian Marussi * {lowest update interval, highest update interval, step size}
2751fe00b8bSCristian Marussi * @count: Number of intervals described in @desc.
2761fe00b8bSCristian Marussi * @desc: Array of @count interval descriptor bitmask represented as detailed in
2771fe00b8bSCristian Marussi * the SCMI specification: it can be accessed using the accompanying
2781fe00b8bSCristian Marussi * macros.
2791fe00b8bSCristian Marussi * @prealloc_pool: A minimal preallocated pool of desc entries used to avoid
2801fe00b8bSCristian Marussi * lesser-than-64-bytes dynamic allocation for small @count
2811fe00b8bSCristian Marussi * values.
2821fe00b8bSCristian Marussi */
2831fe00b8bSCristian Marussi struct scmi_sensor_intervals_info {
2841fe00b8bSCristian Marussi bool segmented;
2851fe00b8bSCristian Marussi unsigned int count;
2861fe00b8bSCristian Marussi #define SCMI_SENS_INTVL_SEGMENT_LOW 0
2871fe00b8bSCristian Marussi #define SCMI_SENS_INTVL_SEGMENT_HIGH 1
2881fe00b8bSCristian Marussi #define SCMI_SENS_INTVL_SEGMENT_STEP 2
2891fe00b8bSCristian Marussi unsigned int *desc;
2901fe00b8bSCristian Marussi #define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x))
2911fe00b8bSCristian Marussi #define SCMI_SENS_INTVL_GET_EXP(x) \
2921fe00b8bSCristian Marussi ({ \
2931fe00b8bSCristian Marussi int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \
2941fe00b8bSCristian Marussi \
2951fe00b8bSCristian Marussi if (__signed_exp & BIT(4)) \
2961fe00b8bSCristian Marussi __signed_exp |= GENMASK(31, 5); \
2971fe00b8bSCristian Marussi __signed_exp; \
2981fe00b8bSCristian Marussi })
2991fe00b8bSCristian Marussi #define SCMI_MAX_PREALLOC_POOL 16
3001fe00b8bSCristian Marussi unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL];
3011fe00b8bSCristian Marussi };
3021fe00b8bSCristian Marussi
3031fe00b8bSCristian Marussi /**
3041fe00b8bSCristian Marussi * struct scmi_sensor_info - represents information related to one of the
3051fe00b8bSCristian Marussi * available sensors.
3061fe00b8bSCristian Marussi * @id: Sensor ID.
3071fe00b8bSCristian Marussi * @type: Sensor type. Chosen amongst one of @enum scmi_sensor_class.
3081fe00b8bSCristian Marussi * @scale: Power-of-10 multiplier applied to the sensor unit.
3091fe00b8bSCristian Marussi * @num_trip_points: Number of maximum configurable trip points.
3101fe00b8bSCristian Marussi * @async: Flag for asynchronous read support.
3111fe00b8bSCristian Marussi * @update: Flag for continuouos update notification support.
3121fe00b8bSCristian Marussi * @timestamped: Flag for timestamped read support.
3131fe00b8bSCristian Marussi * @tstamp_scale: Power-of-10 multiplier applied to the sensor timestamps to
3141fe00b8bSCristian Marussi * represent it in seconds.
3151fe00b8bSCristian Marussi * @num_axis: Number of supported axis if any. Reported as 0 for scalar sensors.
3161fe00b8bSCristian Marussi * @axis: Pointer to an array of @num_axis descriptors.
3171fe00b8bSCristian Marussi * @intervals: Descriptor of available update intervals.
3181fe00b8bSCristian Marussi * @sensor_config: A bitmask reporting the current sensor configuration as
3191fe00b8bSCristian Marussi * detailed in the SCMI specification: it can accessed and
3201fe00b8bSCristian Marussi * modified through the accompanying macros.
3211fe00b8bSCristian Marussi * @name: NULL-terminated string representing sensor name as advertised by
3221fe00b8bSCristian Marussi * SCMI platform.
3231fe00b8bSCristian Marussi * @extended_scalar_attrs: Flag to indicate the presence of additional extended
3241fe00b8bSCristian Marussi * attributes for this sensor.
3251fe00b8bSCristian Marussi * @sensor_power: Extended attribute representing the average power
3261fe00b8bSCristian Marussi * consumed by the sensor in microwatts (uW) when it is active.
3271fe00b8bSCristian Marussi * Reported here only for scalar sensors.
3281fe00b8bSCristian Marussi * Set to 0 if not reported by this sensor.
3291fe00b8bSCristian Marussi * @resolution: Extended attribute representing the resolution of the sensor.
3301fe00b8bSCristian Marussi * Reported here only for scalar sensors.
3311fe00b8bSCristian Marussi * Set to 0 if not reported by this sensor.
3321fe00b8bSCristian Marussi * @exponent: Extended attribute representing the power-of-10 multiplier that is
3331fe00b8bSCristian Marussi * applied to the resolution field.
3341fe00b8bSCristian Marussi * Reported here only for scalar sensors.
3351fe00b8bSCristian Marussi * Set to 0 if not reported by this sensor.
3361fe00b8bSCristian Marussi * @scalar_attrs: Extended attributes representing minimum and maximum
3371fe00b8bSCristian Marussi * measurable values by this sensor.
3381fe00b8bSCristian Marussi * Reported here only for scalar sensors.
3391fe00b8bSCristian Marussi * Set to 0 if not reported by this sensor.
3401fe00b8bSCristian Marussi */
3411fe00b8bSCristian Marussi struct scmi_sensor_info {
3421fe00b8bSCristian Marussi unsigned int id;
3431fe00b8bSCristian Marussi unsigned int type;
3441fe00b8bSCristian Marussi int scale;
3451fe00b8bSCristian Marussi unsigned int num_trip_points;
3461fe00b8bSCristian Marussi bool async;
3471fe00b8bSCristian Marussi bool update;
3481fe00b8bSCristian Marussi bool timestamped;
3491fe00b8bSCristian Marussi int tstamp_scale;
3501fe00b8bSCristian Marussi unsigned int num_axis;
3511fe00b8bSCristian Marussi struct scmi_sensor_axis_info *axis;
3521fe00b8bSCristian Marussi struct scmi_sensor_intervals_info intervals;
3537b83c5f4SCristian Marussi unsigned int sensor_config;
3547b83c5f4SCristian Marussi #define SCMI_SENS_CFG_UPDATE_SECS_MASK GENMASK(31, 16)
3557b83c5f4SCristian Marussi #define SCMI_SENS_CFG_GET_UPDATE_SECS(x) \
3567b83c5f4SCristian Marussi FIELD_GET(SCMI_SENS_CFG_UPDATE_SECS_MASK, (x))
3577b83c5f4SCristian Marussi
3587b83c5f4SCristian Marussi #define SCMI_SENS_CFG_UPDATE_EXP_MASK GENMASK(15, 11)
3597b83c5f4SCristian Marussi #define SCMI_SENS_CFG_GET_UPDATE_EXP(x) \
3607b83c5f4SCristian Marussi ({ \
3617b83c5f4SCristian Marussi int __signed_exp = \
3627b83c5f4SCristian Marussi FIELD_GET(SCMI_SENS_CFG_UPDATE_EXP_MASK, (x)); \
3637b83c5f4SCristian Marussi \
3647b83c5f4SCristian Marussi if (__signed_exp & BIT(4)) \
3657b83c5f4SCristian Marussi __signed_exp |= GENMASK(31, 5); \
3667b83c5f4SCristian Marussi __signed_exp; \
3677b83c5f4SCristian Marussi })
3687b83c5f4SCristian Marussi
3697b83c5f4SCristian Marussi #define SCMI_SENS_CFG_ROUND_MASK GENMASK(10, 9)
3707b83c5f4SCristian Marussi #define SCMI_SENS_CFG_ROUND_AUTO 2
3717b83c5f4SCristian Marussi #define SCMI_SENS_CFG_ROUND_UP 1
3727b83c5f4SCristian Marussi #define SCMI_SENS_CFG_ROUND_DOWN 0
3737b83c5f4SCristian Marussi
3747b83c5f4SCristian Marussi #define SCMI_SENS_CFG_TSTAMP_ENABLED_MASK BIT(1)
3757b83c5f4SCristian Marussi #define SCMI_SENS_CFG_TSTAMP_ENABLE 1
3767b83c5f4SCristian Marussi #define SCMI_SENS_CFG_TSTAMP_DISABLE 0
3777b83c5f4SCristian Marussi #define SCMI_SENS_CFG_IS_TSTAMP_ENABLED(x) \
3787b83c5f4SCristian Marussi FIELD_GET(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK, (x))
3797b83c5f4SCristian Marussi
3807b83c5f4SCristian Marussi #define SCMI_SENS_CFG_SENSOR_ENABLED_MASK BIT(0)
3817b83c5f4SCristian Marussi #define SCMI_SENS_CFG_SENSOR_ENABLE 1
3827b83c5f4SCristian Marussi #define SCMI_SENS_CFG_SENSOR_DISABLE 0
3831fe00b8bSCristian Marussi char name[SCMI_MAX_STR_SIZE];
3847b83c5f4SCristian Marussi #define SCMI_SENS_CFG_IS_ENABLED(x) FIELD_GET(BIT(0), (x))
3851fe00b8bSCristian Marussi bool extended_scalar_attrs;
3861fe00b8bSCristian Marussi unsigned int sensor_power;
3871fe00b8bSCristian Marussi unsigned int resolution;
3881fe00b8bSCristian Marussi int exponent;
3891fe00b8bSCristian Marussi struct scmi_range_attrs scalar_attrs;
3905179c523SSudeep Holla };
3915179c523SSudeep Holla
3925179c523SSudeep Holla /*
3935179c523SSudeep Holla * Partial list from Distributed Management Task Force (DMTF) specification:
3945179c523SSudeep Holla * DSP0249 (Platform Level Data Model specification)
3955179c523SSudeep Holla */
3965179c523SSudeep Holla enum scmi_sensor_class {
3975179c523SSudeep Holla NONE = 0x0,
398607a4672SSudeep Holla UNSPEC = 0x1,
3995179c523SSudeep Holla TEMPERATURE_C = 0x2,
400607a4672SSudeep Holla TEMPERATURE_F = 0x3,
401607a4672SSudeep Holla TEMPERATURE_K = 0x4,
4025179c523SSudeep Holla VOLTAGE = 0x5,
4035179c523SSudeep Holla CURRENT = 0x6,
4045179c523SSudeep Holla POWER = 0x7,
4055179c523SSudeep Holla ENERGY = 0x8,
406607a4672SSudeep Holla CHARGE = 0x9,
407607a4672SSudeep Holla VOLTAMPERE = 0xA,
408607a4672SSudeep Holla NITS = 0xB,
409607a4672SSudeep Holla LUMENS = 0xC,
410607a4672SSudeep Holla LUX = 0xD,
411607a4672SSudeep Holla CANDELAS = 0xE,
412607a4672SSudeep Holla KPA = 0xF,
413607a4672SSudeep Holla PSI = 0x10,
414607a4672SSudeep Holla NEWTON = 0x11,
415607a4672SSudeep Holla CFM = 0x12,
416607a4672SSudeep Holla RPM = 0x13,
417607a4672SSudeep Holla HERTZ = 0x14,
418607a4672SSudeep Holla SECS = 0x15,
419607a4672SSudeep Holla MINS = 0x16,
420607a4672SSudeep Holla HOURS = 0x17,
421607a4672SSudeep Holla DAYS = 0x18,
422607a4672SSudeep Holla WEEKS = 0x19,
423607a4672SSudeep Holla MILS = 0x1A,
424607a4672SSudeep Holla INCHES = 0x1B,
425607a4672SSudeep Holla FEET = 0x1C,
426607a4672SSudeep Holla CUBIC_INCHES = 0x1D,
427607a4672SSudeep Holla CUBIC_FEET = 0x1E,
428607a4672SSudeep Holla METERS = 0x1F,
429607a4672SSudeep Holla CUBIC_CM = 0x20,
430607a4672SSudeep Holla CUBIC_METERS = 0x21,
431607a4672SSudeep Holla LITERS = 0x22,
432607a4672SSudeep Holla FLUID_OUNCES = 0x23,
433607a4672SSudeep Holla RADIANS = 0x24,
434607a4672SSudeep Holla STERADIANS = 0x25,
435607a4672SSudeep Holla REVOLUTIONS = 0x26,
436607a4672SSudeep Holla CYCLES = 0x27,
437607a4672SSudeep Holla GRAVITIES = 0x28,
438607a4672SSudeep Holla OUNCES = 0x29,
439607a4672SSudeep Holla POUNDS = 0x2A,
440607a4672SSudeep Holla FOOT_POUNDS = 0x2B,
441607a4672SSudeep Holla OUNCE_INCHES = 0x2C,
442607a4672SSudeep Holla GAUSS = 0x2D,
443607a4672SSudeep Holla GILBERTS = 0x2E,
444607a4672SSudeep Holla HENRIES = 0x2F,
445607a4672SSudeep Holla FARADS = 0x30,
446607a4672SSudeep Holla OHMS = 0x31,
447607a4672SSudeep Holla SIEMENS = 0x32,
448607a4672SSudeep Holla MOLES = 0x33,
449607a4672SSudeep Holla BECQUERELS = 0x34,
450607a4672SSudeep Holla PPM = 0x35,
451607a4672SSudeep Holla DECIBELS = 0x36,
452607a4672SSudeep Holla DBA = 0x37,
453607a4672SSudeep Holla DBC = 0x38,
454607a4672SSudeep Holla GRAYS = 0x39,
455607a4672SSudeep Holla SIEVERTS = 0x3A,
456607a4672SSudeep Holla COLOR_TEMP_K = 0x3B,
457607a4672SSudeep Holla BITS = 0x3C,
458607a4672SSudeep Holla BYTES = 0x3D,
459607a4672SSudeep Holla WORDS = 0x3E,
460607a4672SSudeep Holla DWORDS = 0x3F,
461607a4672SSudeep Holla QWORDS = 0x40,
462607a4672SSudeep Holla PERCENTAGE = 0x41,
463607a4672SSudeep Holla PASCALS = 0x42,
464607a4672SSudeep Holla COUNTS = 0x43,
465607a4672SSudeep Holla GRAMS = 0x44,
466607a4672SSudeep Holla NEWTON_METERS = 0x45,
467607a4672SSudeep Holla HITS = 0x46,
468607a4672SSudeep Holla MISSES = 0x47,
469607a4672SSudeep Holla RETRIES = 0x48,
470607a4672SSudeep Holla OVERRUNS = 0x49,
471607a4672SSudeep Holla UNDERRUNS = 0x4A,
472607a4672SSudeep Holla COLLISIONS = 0x4B,
473607a4672SSudeep Holla PACKETS = 0x4C,
474607a4672SSudeep Holla MESSAGES = 0x4D,
475607a4672SSudeep Holla CHARS = 0x4E,
476607a4672SSudeep Holla ERRORS = 0x4F,
477607a4672SSudeep Holla CORRECTED_ERRS = 0x50,
478607a4672SSudeep Holla UNCORRECTABLE_ERRS = 0x51,
479607a4672SSudeep Holla SQ_MILS = 0x52,
480607a4672SSudeep Holla SQ_INCHES = 0x53,
481607a4672SSudeep Holla SQ_FEET = 0x54,
482607a4672SSudeep Holla SQ_CM = 0x55,
483607a4672SSudeep Holla SQ_METERS = 0x56,
4841fe00b8bSCristian Marussi RADIANS_SEC = 0x57,
4851fe00b8bSCristian Marussi BPM = 0x58,
4861fe00b8bSCristian Marussi METERS_SEC_SQUARED = 0x59,
4871fe00b8bSCristian Marussi METERS_SEC = 0x5A,
4881fe00b8bSCristian Marussi CUBIC_METERS_SEC = 0x5B,
4891fe00b8bSCristian Marussi MM_MERCURY = 0x5C,
4901fe00b8bSCristian Marussi RADIANS_SEC_SQUARED = 0x5D,
4911fe00b8bSCristian Marussi OEM_UNIT = 0xFF
4925179c523SSudeep Holla };
4935179c523SSudeep Holla
4945179c523SSudeep Holla /**
4959694a7f6SCristian Marussi * struct scmi_sensor_proto_ops - represents the various operations provided
4965179c523SSudeep Holla * by SCMI Sensor Protocol
4975179c523SSudeep Holla *
4985179c523SSudeep Holla * @count_get: get the count of sensors provided by SCMI
4995179c523SSudeep Holla * @info_get: get the information of the specified sensor
5009eefa43aSSudeep Holla * @trip_point_config: selects and configures a trip-point of interest
5015179c523SSudeep Holla * @reading_get: gets the current value of the sensor
502e2083d36SCristian Marussi * @reading_get_timestamped: gets the current value and timestamp, when
503e2083d36SCristian Marussi * available, of the sensor. (as of v3.0 spec)
504e2083d36SCristian Marussi * Supports multi-axis sensors for sensors which
505e2083d36SCristian Marussi * supports it and if the @reading array size of
506e2083d36SCristian Marussi * @count entry equals the sensor num_axis
5077b83c5f4SCristian Marussi * @config_get: Get sensor current configuration
5087b83c5f4SCristian Marussi * @config_set: Set sensor current configuration
5095179c523SSudeep Holla */
5109694a7f6SCristian Marussi struct scmi_sensor_proto_ops {
5119694a7f6SCristian Marussi int (*count_get)(const struct scmi_protocol_handle *ph);
5121ecb7d27SCristian Marussi const struct scmi_sensor_info __must_check *(*info_get)
5139694a7f6SCristian Marussi (const struct scmi_protocol_handle *ph, u32 sensor_id);
5149694a7f6SCristian Marussi int (*trip_point_config)(const struct scmi_protocol_handle *ph,
5159694a7f6SCristian Marussi u32 sensor_id, u8 trip_id, u64 trip_value);
5169694a7f6SCristian Marussi int (*reading_get)(const struct scmi_protocol_handle *ph, u32 sensor_id,
5179694a7f6SCristian Marussi u64 *value);
5189694a7f6SCristian Marussi int (*reading_get_timestamped)(const struct scmi_protocol_handle *ph,
5199694a7f6SCristian Marussi u32 sensor_id, u8 count,
5209694a7f6SCristian Marussi struct scmi_sensor_reading *readings);
5219694a7f6SCristian Marussi int (*config_get)(const struct scmi_protocol_handle *ph,
5229694a7f6SCristian Marussi u32 sensor_id, u32 *sensor_config);
5239694a7f6SCristian Marussi int (*config_set)(const struct scmi_protocol_handle *ph,
5249694a7f6SCristian Marussi u32 sensor_id, u32 sensor_config);
5259694a7f6SCristian Marussi };
5269694a7f6SCristian Marussi
52776a65509SSudeep Holla /**
5287e029344SCristian Marussi * struct scmi_reset_proto_ops - represents the various operations provided
52995a15d80SSudeep Holla * by SCMI Reset Protocol
53095a15d80SSudeep Holla *
53195a15d80SSudeep Holla * @num_domains_get: get the count of reset domains provided by SCMI
53295a15d80SSudeep Holla * @name_get: gets the name of a reset domain
53395a15d80SSudeep Holla * @latency_get: gets the reset latency for the specified reset domain
53495a15d80SSudeep Holla * @reset: resets the specified reset domain
53595a15d80SSudeep Holla * @assert: explicitly assert reset signal of the specified reset domain
53695a15d80SSudeep Holla * @deassert: explicitly deassert reset signal of the specified reset domain
53795a15d80SSudeep Holla */
5387e029344SCristian Marussi struct scmi_reset_proto_ops {
5397e029344SCristian Marussi int (*num_domains_get)(const struct scmi_protocol_handle *ph);
540992be5d3SCristian Marussi const char *(*name_get)(const struct scmi_protocol_handle *ph,
541992be5d3SCristian Marussi u32 domain);
5427e029344SCristian Marussi int (*latency_get)(const struct scmi_protocol_handle *ph, u32 domain);
5437e029344SCristian Marussi int (*reset)(const struct scmi_protocol_handle *ph, u32 domain);
5447e029344SCristian Marussi int (*assert)(const struct scmi_protocol_handle *ph, u32 domain);
5457e029344SCristian Marussi int (*deassert)(const struct scmi_protocol_handle *ph, u32 domain);
5467e029344SCristian Marussi };
5477e029344SCristian Marussi
5484c74701bSCristian Marussi enum scmi_voltage_level_mode {
5494c74701bSCristian Marussi SCMI_VOLTAGE_LEVEL_SET_AUTO,
5504c74701bSCristian Marussi SCMI_VOLTAGE_LEVEL_SET_SYNC,
5514c74701bSCristian Marussi };
5524c74701bSCristian Marussi
55395a15d80SSudeep Holla /**
5542add5cacSCristian Marussi * struct scmi_voltage_info - describe one available SCMI Voltage Domain
5552add5cacSCristian Marussi *
5562add5cacSCristian Marussi * @id: the domain ID as advertised by the platform
5572add5cacSCristian Marussi * @segmented: defines the layout of the entries of array @levels_uv.
5582add5cacSCristian Marussi * - when True the entries are to be interpreted as triplets,
5592add5cacSCristian Marussi * each defining a segment representing a range of equally
5602add5cacSCristian Marussi * space voltages: <lowest_volts>, <highest_volt>, <step_uV>
5612add5cacSCristian Marussi * - when False the entries simply represent a single discrete
5622add5cacSCristian Marussi * supported voltage level
5632add5cacSCristian Marussi * @negative_volts_allowed: True if any of the entries of @levels_uv represent
5642add5cacSCristian Marussi * a negative voltage.
5654c74701bSCristian Marussi * @async_level_set: True when the voltage domain supports asynchronous level
5664c74701bSCristian Marussi * set commands.
5672add5cacSCristian Marussi * @name: name assigned to the Voltage Domain by platform
5682add5cacSCristian Marussi * @num_levels: number of total entries in @levels_uv.
5692add5cacSCristian Marussi * @levels_uv: array of entries describing the available voltage levels for
5702add5cacSCristian Marussi * this domain.
5712add5cacSCristian Marussi */
5722add5cacSCristian Marussi struct scmi_voltage_info {
5732add5cacSCristian Marussi unsigned int id;
5742add5cacSCristian Marussi bool segmented;
5752add5cacSCristian Marussi bool negative_volts_allowed;
5764c74701bSCristian Marussi bool async_level_set;
5772add5cacSCristian Marussi char name[SCMI_MAX_STR_SIZE];
5782add5cacSCristian Marussi unsigned int num_levels;
5792add5cacSCristian Marussi #define SCMI_VOLTAGE_SEGMENT_LOW 0
5802add5cacSCristian Marussi #define SCMI_VOLTAGE_SEGMENT_HIGH 1
5812add5cacSCristian Marussi #define SCMI_VOLTAGE_SEGMENT_STEP 2
5822add5cacSCristian Marussi int *levels_uv;
5832add5cacSCristian Marussi };
5842add5cacSCristian Marussi
5852add5cacSCristian Marussi /**
586fe4894d9SCristian Marussi * struct scmi_voltage_proto_ops - represents the various operations provided
5872add5cacSCristian Marussi * by SCMI Voltage Protocol
5882add5cacSCristian Marussi *
5892add5cacSCristian Marussi * @num_domains_get: get the count of voltage domains provided by SCMI
5902add5cacSCristian Marussi * @info_get: get the information of the specified domain
5912add5cacSCristian Marussi * @config_set: set the config for the specified domain
5922add5cacSCristian Marussi * @config_get: get the config of the specified domain
5932add5cacSCristian Marussi * @level_set: set the voltage level for the specified domain
5942add5cacSCristian Marussi * @level_get: get the voltage level of the specified domain
5952add5cacSCristian Marussi */
596fe4894d9SCristian Marussi struct scmi_voltage_proto_ops {
597fe4894d9SCristian Marussi int (*num_domains_get)(const struct scmi_protocol_handle *ph);
598fe4894d9SCristian Marussi const struct scmi_voltage_info __must_check *(*info_get)
599fe4894d9SCristian Marussi (const struct scmi_protocol_handle *ph, u32 domain_id);
600fe4894d9SCristian Marussi int (*config_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
601fe4894d9SCristian Marussi u32 config);
602fe4894d9SCristian Marussi #define SCMI_VOLTAGE_ARCH_STATE_OFF 0x0
603fe4894d9SCristian Marussi #define SCMI_VOLTAGE_ARCH_STATE_ON 0x7
604fe4894d9SCristian Marussi int (*config_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
605fe4894d9SCristian Marussi u32 *config);
606fe4894d9SCristian Marussi int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
6074c74701bSCristian Marussi enum scmi_voltage_level_mode mode, s32 volt_uV);
608fe4894d9SCristian Marussi int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
609fe4894d9SCristian Marussi s32 *volt_uV);
610fe4894d9SCristian Marussi };
611fe4894d9SCristian Marussi
6122add5cacSCristian Marussi /**
6130316f99cSCristian Marussi * struct scmi_powercap_info - Describe one available Powercap domain
6140316f99cSCristian Marussi *
6150316f99cSCristian Marussi * @id: Domain ID as advertised by the platform.
6160316f99cSCristian Marussi * @notify_powercap_cap_change: CAP change notification support.
6170316f99cSCristian Marussi * @notify_powercap_measurement_change: MEASUREMENTS change notifications
6180316f99cSCristian Marussi * support.
6190316f99cSCristian Marussi * @async_powercap_cap_set: Asynchronous CAP set support.
6200316f99cSCristian Marussi * @powercap_cap_config: CAP configuration support.
6210316f99cSCristian Marussi * @powercap_monitoring: Monitoring (measurements) support.
6220316f99cSCristian Marussi * @powercap_pai_config: PAI configuration support.
6230316f99cSCristian Marussi * @powercap_scale_mw: Domain reports power data in milliwatt units.
6240316f99cSCristian Marussi * @powercap_scale_uw: Domain reports power data in microwatt units.
6250316f99cSCristian Marussi * Note that, when both @powercap_scale_mw and
6260316f99cSCristian Marussi * @powercap_scale_uw are set to false, the domain
6270316f99cSCristian Marussi * reports power data on an abstract linear scale.
6280316f99cSCristian Marussi * @name: name assigned to the Powercap Domain by platform.
6290316f99cSCristian Marussi * @min_pai: Minimum configurable PAI.
6300316f99cSCristian Marussi * @max_pai: Maximum configurable PAI.
6310316f99cSCristian Marussi * @pai_step: Step size between two consecutive PAI values.
6320316f99cSCristian Marussi * @min_power_cap: Minimum configurable CAP.
6330316f99cSCristian Marussi * @max_power_cap: Maximum configurable CAP.
6340316f99cSCristian Marussi * @power_cap_step: Step size between two consecutive CAP values.
6350316f99cSCristian Marussi * @sustainable_power: Maximum sustainable power consumption for this domain
6360316f99cSCristian Marussi * under normal conditions.
6370316f99cSCristian Marussi * @accuracy: The accuracy with which the power is measured and reported in
6380316f99cSCristian Marussi * integral multiples of 0.001 percent.
6390316f99cSCristian Marussi * @parent_id: Identifier of the containing parent power capping domain, or the
6400316f99cSCristian Marussi * value 0xFFFFFFFF if this powercap domain is a root domain not
6410316f99cSCristian Marussi * contained in any other domain.
6420316f99cSCristian Marussi */
6430316f99cSCristian Marussi struct scmi_powercap_info {
6440316f99cSCristian Marussi unsigned int id;
6450316f99cSCristian Marussi bool notify_powercap_cap_change;
6460316f99cSCristian Marussi bool notify_powercap_measurement_change;
6470316f99cSCristian Marussi bool async_powercap_cap_set;
6480316f99cSCristian Marussi bool powercap_cap_config;
6490316f99cSCristian Marussi bool powercap_monitoring;
6500316f99cSCristian Marussi bool powercap_pai_config;
6510316f99cSCristian Marussi bool powercap_scale_mw;
6520316f99cSCristian Marussi bool powercap_scale_uw;
653855aa26eSCristian Marussi bool fastchannels;
6540316f99cSCristian Marussi char name[SCMI_MAX_STR_SIZE];
6550316f99cSCristian Marussi unsigned int min_pai;
6560316f99cSCristian Marussi unsigned int max_pai;
6570316f99cSCristian Marussi unsigned int pai_step;
6580316f99cSCristian Marussi unsigned int min_power_cap;
6590316f99cSCristian Marussi unsigned int max_power_cap;
6600316f99cSCristian Marussi unsigned int power_cap_step;
6610316f99cSCristian Marussi unsigned int sustainable_power;
6620316f99cSCristian Marussi unsigned int accuracy;
6630316f99cSCristian Marussi #define SCMI_POWERCAP_ROOT_ZONE_ID 0xFFFFFFFFUL
6640316f99cSCristian Marussi unsigned int parent_id;
665855aa26eSCristian Marussi struct scmi_fc_info *fc_info;
6660316f99cSCristian Marussi };
6670316f99cSCristian Marussi
6680316f99cSCristian Marussi /**
6690316f99cSCristian Marussi * struct scmi_powercap_proto_ops - represents the various operations provided
6700316f99cSCristian Marussi * by SCMI Powercap Protocol
6710316f99cSCristian Marussi *
6720316f99cSCristian Marussi * @num_domains_get: get the count of powercap domains provided by SCMI.
6730316f99cSCristian Marussi * @info_get: get the information for the specified domain.
6740316f99cSCristian Marussi * @cap_get: get the current CAP value for the specified domain.
675758cd5fcSCristian Marussi * On SCMI platforms supporting powercap zone disabling, this could
676758cd5fcSCristian Marussi * report a zero value for a zone where powercapping is disabled.
6770316f99cSCristian Marussi * @cap_set: set the CAP value for the specified domain to the provided value;
6780316f99cSCristian Marussi * if the domain supports setting the CAP with an asynchronous command
6790316f99cSCristian Marussi * this request will finally trigger an asynchronous transfer, but, if
6800316f99cSCristian Marussi * @ignore_dresp here is set to true, this call will anyway return
6810316f99cSCristian Marussi * immediately without waiting for the related delayed response.
682758cd5fcSCristian Marussi * Note that the powercap requested value must NOT be zero, even if
683758cd5fcSCristian Marussi * the platform supports disabling a powercap by setting its cap to
684758cd5fcSCristian Marussi * zero (since SCMI v3.2): there are dedicated operations that should
685758cd5fcSCristian Marussi * be used for that. (@cap_enable_set/get)
686758cd5fcSCristian Marussi * @cap_enable_set: enable or disable the powercapping on the specified domain,
687758cd5fcSCristian Marussi * if supported by the SCMI platform implementation.
688758cd5fcSCristian Marussi * Note that, by the SCMI specification, the platform can
689758cd5fcSCristian Marussi * silently ignore our disable request and decide to enforce
690758cd5fcSCristian Marussi * anyway some other powercap value requested by another agent
691758cd5fcSCristian Marussi * on the system: for this reason @cap_get and @cap_enable_get
692758cd5fcSCristian Marussi * will always report the final platform view of the powercaps.
693758cd5fcSCristian Marussi * @cap_enable_get: get the current CAP enable status for the specified domain.
6940316f99cSCristian Marussi * @pai_get: get the current PAI value for the specified domain.
6950316f99cSCristian Marussi * @pai_set: set the PAI value for the specified domain to the provided value.
6960316f99cSCristian Marussi * @measurements_get: retrieve the current average power measurements for the
6970316f99cSCristian Marussi * specified domain and the related PAI upon which is
6980316f99cSCristian Marussi * calculated.
6990316f99cSCristian Marussi * @measurements_threshold_set: set the desired low and high power thresholds
7000316f99cSCristian Marussi * to be used when registering for notification
7010316f99cSCristian Marussi * of type POWERCAP_MEASUREMENTS_NOTIFY with this
7020316f99cSCristian Marussi * powercap domain.
7030316f99cSCristian Marussi * Note that this must be called at least once
7040316f99cSCristian Marussi * before registering any callback with the usual
7050316f99cSCristian Marussi * @scmi_notify_ops; moreover, in case this method
7060316f99cSCristian Marussi * is called with measurement notifications already
7070316f99cSCristian Marussi * enabled it will also trigger, transparently, a
7080316f99cSCristian Marussi * proper update of the power thresholds configured
7090316f99cSCristian Marussi * in the SCMI backend server.
7100316f99cSCristian Marussi * @measurements_threshold_get: get the currently configured low and high power
7110316f99cSCristian Marussi * thresholds used when registering callbacks for
7120316f99cSCristian Marussi * notification POWERCAP_MEASUREMENTS_NOTIFY.
7130316f99cSCristian Marussi */
7140316f99cSCristian Marussi struct scmi_powercap_proto_ops {
7150316f99cSCristian Marussi int (*num_domains_get)(const struct scmi_protocol_handle *ph);
7160316f99cSCristian Marussi const struct scmi_powercap_info __must_check *(*info_get)
7170316f99cSCristian Marussi (const struct scmi_protocol_handle *ph, u32 domain_id);
7180316f99cSCristian Marussi int (*cap_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
7190316f99cSCristian Marussi u32 *power_cap);
7200316f99cSCristian Marussi int (*cap_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
7210316f99cSCristian Marussi u32 power_cap, bool ignore_dresp);
722758cd5fcSCristian Marussi int (*cap_enable_set)(const struct scmi_protocol_handle *ph,
723758cd5fcSCristian Marussi u32 domain_id, bool enable);
724758cd5fcSCristian Marussi int (*cap_enable_get)(const struct scmi_protocol_handle *ph,
725758cd5fcSCristian Marussi u32 domain_id, bool *enable);
7260316f99cSCristian Marussi int (*pai_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
7270316f99cSCristian Marussi u32 *pai);
7280316f99cSCristian Marussi int (*pai_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
7290316f99cSCristian Marussi u32 pai);
7300316f99cSCristian Marussi int (*measurements_get)(const struct scmi_protocol_handle *ph,
7310316f99cSCristian Marussi u32 domain_id, u32 *average_power, u32 *pai);
7320316f99cSCristian Marussi int (*measurements_threshold_set)(const struct scmi_protocol_handle *ph,
7330316f99cSCristian Marussi u32 domain_id, u32 power_thresh_low,
7340316f99cSCristian Marussi u32 power_thresh_high);
7350316f99cSCristian Marussi int (*measurements_threshold_get)(const struct scmi_protocol_handle *ph,
7360316f99cSCristian Marussi u32 domain_id, u32 *power_thresh_low,
7370316f99cSCristian Marussi u32 *power_thresh_high);
7380316f99cSCristian Marussi };
7390316f99cSCristian Marussi
7402145af01SPeng Fan enum scmi_pinctrl_selector_type {
7412145af01SPeng Fan PIN_TYPE = 0,
7422145af01SPeng Fan GROUP_TYPE,
7432145af01SPeng Fan FUNCTION_TYPE,
7442145af01SPeng Fan };
7452145af01SPeng Fan
7462145af01SPeng Fan enum scmi_pinctrl_conf_type {
7472145af01SPeng Fan SCMI_PIN_DEFAULT = 0,
7482145af01SPeng Fan SCMI_PIN_BIAS_BUS_HOLD = 1,
7492145af01SPeng Fan SCMI_PIN_BIAS_DISABLE = 2,
7502145af01SPeng Fan SCMI_PIN_BIAS_HIGH_IMPEDANCE = 3,
7512145af01SPeng Fan SCMI_PIN_BIAS_PULL_UP = 4,
7522145af01SPeng Fan SCMI_PIN_BIAS_PULL_DEFAULT = 5,
7532145af01SPeng Fan SCMI_PIN_BIAS_PULL_DOWN = 6,
7542145af01SPeng Fan SCMI_PIN_DRIVE_OPEN_DRAIN = 7,
7552145af01SPeng Fan SCMI_PIN_DRIVE_OPEN_SOURCE = 8,
7562145af01SPeng Fan SCMI_PIN_DRIVE_PUSH_PULL = 9,
7572145af01SPeng Fan SCMI_PIN_DRIVE_STRENGTH = 10,
7582145af01SPeng Fan SCMI_PIN_INPUT_DEBOUNCE = 11,
7592145af01SPeng Fan SCMI_PIN_INPUT_MODE = 12,
7602145af01SPeng Fan SCMI_PIN_PULL_MODE = 13,
7612145af01SPeng Fan SCMI_PIN_INPUT_VALUE = 14,
7622145af01SPeng Fan SCMI_PIN_INPUT_SCHMITT = 15,
7632145af01SPeng Fan SCMI_PIN_LOW_POWER_MODE = 16,
7642145af01SPeng Fan SCMI_PIN_OUTPUT_MODE = 17,
7652145af01SPeng Fan SCMI_PIN_OUTPUT_VALUE = 18,
7662145af01SPeng Fan SCMI_PIN_POWER_SOURCE = 19,
7672145af01SPeng Fan SCMI_PIN_SLEW_RATE = 20,
7682145af01SPeng Fan SCMI_PIN_OEM_START = 192,
7692145af01SPeng Fan SCMI_PIN_OEM_END = 255,
7702145af01SPeng Fan };
7712145af01SPeng Fan
7722145af01SPeng Fan /**
7732145af01SPeng Fan * struct scmi_pinctrl_proto_ops - represents the various operations provided
7742145af01SPeng Fan * by SCMI Pinctrl Protocol
7752145af01SPeng Fan *
7762145af01SPeng Fan * @count_get: returns count of the registered elements in given type
7772145af01SPeng Fan * @name_get: returns name by index of given type
7782145af01SPeng Fan * @group_pins_get: returns the set of pins, assigned to the specified group
7792145af01SPeng Fan * @function_groups_get: returns the set of groups, assigned to the specified
7802145af01SPeng Fan * function
7812145af01SPeng Fan * @mux_set: set muxing function for groups of pins
7822145af01SPeng Fan * @settings_get_one: returns one configuration parameter for pin or group
7832145af01SPeng Fan * specified by config_type
7842145af01SPeng Fan * @settings_get_all: returns all configuration parameters for pin or group
7852145af01SPeng Fan * @settings_conf: sets the configuration parameter for pin or group
7862145af01SPeng Fan * @pin_request: aquire pin before selecting mux setting
7872145af01SPeng Fan * @pin_free: frees pin, acquired by request_pin call
7882145af01SPeng Fan */
7892145af01SPeng Fan struct scmi_pinctrl_proto_ops {
7902145af01SPeng Fan int (*count_get)(const struct scmi_protocol_handle *ph,
7912145af01SPeng Fan enum scmi_pinctrl_selector_type type);
7922145af01SPeng Fan int (*name_get)(const struct scmi_protocol_handle *ph, u32 selector,
7932145af01SPeng Fan enum scmi_pinctrl_selector_type type,
7942145af01SPeng Fan const char **name);
7952145af01SPeng Fan int (*group_pins_get)(const struct scmi_protocol_handle *ph,
7962145af01SPeng Fan u32 selector, const unsigned int **pins,
7972145af01SPeng Fan unsigned int *nr_pins);
7982145af01SPeng Fan int (*function_groups_get)(const struct scmi_protocol_handle *ph,
7992145af01SPeng Fan u32 selector, unsigned int *nr_groups,
8002145af01SPeng Fan const unsigned int **groups);
8012145af01SPeng Fan int (*mux_set)(const struct scmi_protocol_handle *ph, u32 selector,
8022145af01SPeng Fan u32 group);
8032145af01SPeng Fan int (*settings_get_one)(const struct scmi_protocol_handle *ph,
8042145af01SPeng Fan u32 selector,
8052145af01SPeng Fan enum scmi_pinctrl_selector_type type,
8062145af01SPeng Fan enum scmi_pinctrl_conf_type config_type,
8072145af01SPeng Fan u32 *config_value);
8082145af01SPeng Fan int (*settings_get_all)(const struct scmi_protocol_handle *ph,
8092145af01SPeng Fan u32 selector,
8102145af01SPeng Fan enum scmi_pinctrl_selector_type type,
8112145af01SPeng Fan unsigned int *nr_configs,
8122145af01SPeng Fan enum scmi_pinctrl_conf_type *config_types,
8132145af01SPeng Fan u32 *config_values);
8142145af01SPeng Fan int (*settings_conf)(const struct scmi_protocol_handle *ph,
8152145af01SPeng Fan u32 selector, enum scmi_pinctrl_selector_type type,
8162145af01SPeng Fan unsigned int nr_configs,
8172145af01SPeng Fan enum scmi_pinctrl_conf_type *config_type,
8182145af01SPeng Fan u32 *config_value);
8192145af01SPeng Fan int (*pin_request)(const struct scmi_protocol_handle *ph, u32 pin);
8202145af01SPeng Fan int (*pin_free)(const struct scmi_protocol_handle *ph, u32 pin);
8212145af01SPeng Fan };
8222145af01SPeng Fan
8230316f99cSCristian Marussi /**
824e7c215f3SCristian Marussi * struct scmi_notify_ops - represents notifications' operations provided by
825e7c215f3SCristian Marussi * SCMI core
8265ad3d1cfSCristian Marussi * @devm_event_notifier_register: Managed registration of a notifier_block for
8275ad3d1cfSCristian Marussi * the requested event
8285ad3d1cfSCristian Marussi * @devm_event_notifier_unregister: Managed unregistration of a notifier_block
8295ad3d1cfSCristian Marussi * for the requested event
830aa1fd3e4SCristian Marussi * @event_notifier_register: Register a notifier_block for the requested event
831aa1fd3e4SCristian Marussi * @event_notifier_unregister: Unregister a notifier_block for the requested
832e7c215f3SCristian Marussi * event
833e7c215f3SCristian Marussi *
834e7c215f3SCristian Marussi * A user can register/unregister its own notifier_block against the wanted
835e7c215f3SCristian Marussi * platform instance regarding the desired event identified by the
836e7c215f3SCristian Marussi * tuple: (proto_id, evt_id, src_id) using the provided register/unregister
837e7c215f3SCristian Marussi * interface where:
838e7c215f3SCristian Marussi *
8395ad3d1cfSCristian Marussi * @sdev: The scmi_device to use when calling the devres managed ops devm_
8405ad3d1cfSCristian Marussi * @handle: The handle identifying the platform instance to use, when not
8415ad3d1cfSCristian Marussi * calling the managed ops devm_
842e7c215f3SCristian Marussi * @proto_id: The protocol ID as in SCMI Specification
843e7c215f3SCristian Marussi * @evt_id: The message ID of the desired event as in SCMI Specification
844e7c215f3SCristian Marussi * @src_id: A pointer to the desired source ID if different sources are
845e7c215f3SCristian Marussi * possible for the protocol (like domain_id, sensor_id...etc)
846e7c215f3SCristian Marussi *
847e7c215f3SCristian Marussi * @src_id can be provided as NULL if it simply does NOT make sense for
848e7c215f3SCristian Marussi * the protocol at hand, OR if the user is explicitly interested in
849e7c215f3SCristian Marussi * receiving notifications from ANY existent source associated to the
850e7c215f3SCristian Marussi * specified proto_id / evt_id.
851e7c215f3SCristian Marussi *
852e7c215f3SCristian Marussi * Received notifications are finally delivered to the registered users,
853e7c215f3SCristian Marussi * invoking the callback provided with the notifier_block *nb as follows:
854e7c215f3SCristian Marussi *
855e7c215f3SCristian Marussi * int user_cb(nb, evt_id, report)
856e7c215f3SCristian Marussi *
857e7c215f3SCristian Marussi * with:
858e7c215f3SCristian Marussi *
859e7c215f3SCristian Marussi * @nb: The notifier block provided by the user
860e7c215f3SCristian Marussi * @evt_id: The message ID of the delivered event
861e7c215f3SCristian Marussi * @report: A custom struct describing the specific event delivered
862e7c215f3SCristian Marussi */
863e7c215f3SCristian Marussi struct scmi_notify_ops {
8645ad3d1cfSCristian Marussi int (*devm_event_notifier_register)(struct scmi_device *sdev,
8655ad3d1cfSCristian Marussi u8 proto_id, u8 evt_id,
8665ad3d1cfSCristian Marussi const u32 *src_id,
8675ad3d1cfSCristian Marussi struct notifier_block *nb);
8685ad3d1cfSCristian Marussi int (*devm_event_notifier_unregister)(struct scmi_device *sdev,
8695ad3d1cfSCristian Marussi struct notifier_block *nb);
870aa1fd3e4SCristian Marussi int (*event_notifier_register)(const struct scmi_handle *handle,
8715ad3d1cfSCristian Marussi u8 proto_id, u8 evt_id,
8725ad3d1cfSCristian Marussi const u32 *src_id,
873e7c215f3SCristian Marussi struct notifier_block *nb);
874aa1fd3e4SCristian Marussi int (*event_notifier_unregister)(const struct scmi_handle *handle,
8755ad3d1cfSCristian Marussi u8 proto_id, u8 evt_id,
8765ad3d1cfSCristian Marussi const u32 *src_id,
877e7c215f3SCristian Marussi struct notifier_block *nb);
878e7c215f3SCristian Marussi };
879e7c215f3SCristian Marussi
880e7c215f3SCristian Marussi /**
881aa4f886fSSudeep Holla * struct scmi_handle - Handle returned to ARM SCMI clients for usage.
882aa4f886fSSudeep Holla *
883aa4f886fSSudeep Holla * @dev: pointer to the SCMI device
884b6f20ff8SSudeep Holla * @version: pointer to the structure containing SCMI version information
885d9107999SCristian Marussi * @devm_protocol_acquire: devres managed method to get hold of a protocol,
886d9107999SCristian Marussi * causing its initialization and related resource
887d9107999SCristian Marussi * accounting
88823934efeSCristian Marussi * @devm_protocol_get: devres managed method to acquire a protocol and get specific
88923934efeSCristian Marussi * operations and a dedicated protocol handler
89023934efeSCristian Marussi * @devm_protocol_put: devres managed method to release a protocol
89169255e74SCristian Marussi * @is_transport_atomic: method to check if the underlying transport for this
89269255e74SCristian Marussi * instance handle is configured to support atomic
89369255e74SCristian Marussi * transactions for commands.
89469255e74SCristian Marussi * Some users of the SCMI stack in the upper layers could
89569255e74SCristian Marussi * be interested to know if they can assume SCMI
89669255e74SCristian Marussi * command transactions associated to this handle will
89769255e74SCristian Marussi * never sleep and act accordingly.
89805976c5fSCristian Marussi * An optional atomic threshold value could be returned
89905976c5fSCristian Marussi * where configured.
900e7c215f3SCristian Marussi * @notify_ops: pointer to set of notifications related operations
901aa4f886fSSudeep Holla */
902aa4f886fSSudeep Holla struct scmi_handle {
903aa4f886fSSudeep Holla struct device *dev;
904b6f20ff8SSudeep Holla struct scmi_revision_info *version;
90523934efeSCristian Marussi
906d9107999SCristian Marussi int __must_check (*devm_protocol_acquire)(struct scmi_device *sdev,
907d9107999SCristian Marussi u8 proto);
90823934efeSCristian Marussi const void __must_check *
90923934efeSCristian Marussi (*devm_protocol_get)(struct scmi_device *sdev, u8 proto,
91023934efeSCristian Marussi struct scmi_protocol_handle **ph);
91123934efeSCristian Marussi void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto);
91205976c5fSCristian Marussi bool (*is_transport_atomic)(const struct scmi_handle *handle,
91305976c5fSCristian Marussi unsigned int *atomic_threshold);
91423934efeSCristian Marussi
91582894c1dSRikard Falkeborn const struct scmi_notify_ops *notify_ops;
916b6f20ff8SSudeep Holla };
917b6f20ff8SSudeep Holla
918b6f20ff8SSudeep Holla enum scmi_std_protocol {
919b6f20ff8SSudeep Holla SCMI_PROTOCOL_BASE = 0x10,
920b6f20ff8SSudeep Holla SCMI_PROTOCOL_POWER = 0x11,
921b6f20ff8SSudeep Holla SCMI_PROTOCOL_SYSTEM = 0x12,
922b6f20ff8SSudeep Holla SCMI_PROTOCOL_PERF = 0x13,
923b6f20ff8SSudeep Holla SCMI_PROTOCOL_CLOCK = 0x14,
924b6f20ff8SSudeep Holla SCMI_PROTOCOL_SENSOR = 0x15,
92595a15d80SSudeep Holla SCMI_PROTOCOL_RESET = 0x16,
9262add5cacSCristian Marussi SCMI_PROTOCOL_VOLTAGE = 0x17,
9270316f99cSCristian Marussi SCMI_PROTOCOL_POWERCAP = 0x18,
9282145af01SPeng Fan SCMI_PROTOCOL_PINCTRL = 0x19,
929aa4f886fSSudeep Holla };
930933c5044SSudeep Holla
931a8803055SCristian Marussi enum scmi_system_events {
932a8803055SCristian Marussi SCMI_SYSTEM_SHUTDOWN,
933a8803055SCristian Marussi SCMI_SYSTEM_COLDRESET,
934a8803055SCristian Marussi SCMI_SYSTEM_WARMRESET,
935a8803055SCristian Marussi SCMI_SYSTEM_POWERUP,
936a8803055SCristian Marussi SCMI_SYSTEM_SUSPEND,
937a8803055SCristian Marussi SCMI_SYSTEM_MAX
938a8803055SCristian Marussi };
939a8803055SCristian Marussi
940933c5044SSudeep Holla struct scmi_device {
941933c5044SSudeep Holla u32 id;
942933c5044SSudeep Holla u8 protocol_id;
943ee7a9c9fSSudeep Holla const char *name;
944933c5044SSudeep Holla struct device dev;
945933c5044SSudeep Holla struct scmi_handle *handle;
946933c5044SSudeep Holla };
947933c5044SSudeep Holla
948*d69d8048SGreg Kroah-Hartman #define to_scmi_dev(d) container_of_const(d, struct scmi_device, dev)
949933c5044SSudeep Holla
950933c5044SSudeep Holla struct scmi_device_id {
951933c5044SSudeep Holla u8 protocol_id;
952ee7a9c9fSSudeep Holla const char *name;
953933c5044SSudeep Holla };
954933c5044SSudeep Holla
955933c5044SSudeep Holla struct scmi_driver {
956933c5044SSudeep Holla const char *name;
957933c5044SSudeep Holla int (*probe)(struct scmi_device *sdev);
958933c5044SSudeep Holla void (*remove)(struct scmi_device *sdev);
959933c5044SSudeep Holla const struct scmi_device_id *id_table;
960933c5044SSudeep Holla
961933c5044SSudeep Holla struct device_driver driver;
962933c5044SSudeep Holla };
963933c5044SSudeep Holla
964933c5044SSudeep Holla #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
965933c5044SSudeep Holla
96666d90f6eSSudeep Holla #if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
967933c5044SSudeep Holla int scmi_driver_register(struct scmi_driver *driver,
968933c5044SSudeep Holla struct module *owner, const char *mod_name);
969933c5044SSudeep Holla void scmi_driver_unregister(struct scmi_driver *driver);
970933c5044SSudeep Holla #else
971933c5044SSudeep Holla static inline int
scmi_driver_register(struct scmi_driver * driver,struct module * owner,const char * mod_name)972933c5044SSudeep Holla scmi_driver_register(struct scmi_driver *driver, struct module *owner,
973933c5044SSudeep Holla const char *mod_name)
974933c5044SSudeep Holla {
975933c5044SSudeep Holla return -EINVAL;
976933c5044SSudeep Holla }
977933c5044SSudeep Holla
scmi_driver_unregister(struct scmi_driver * driver)978933c5044SSudeep Holla static inline void scmi_driver_unregister(struct scmi_driver *driver) {}
979933c5044SSudeep Holla #endif /* CONFIG_ARM_SCMI_PROTOCOL */
980933c5044SSudeep Holla
981933c5044SSudeep Holla #define scmi_register(driver) \
982933c5044SSudeep Holla scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
983933c5044SSudeep Holla #define scmi_unregister(driver) \
984933c5044SSudeep Holla scmi_driver_unregister(driver)
985933c5044SSudeep Holla
986933c5044SSudeep Holla /**
987933c5044SSudeep Holla * module_scmi_driver() - Helper macro for registering a scmi driver
988933c5044SSudeep Holla * @__scmi_driver: scmi_driver structure
989933c5044SSudeep Holla *
990933c5044SSudeep Holla * Helper macro for scmi drivers to set up proper module init / exit
991933c5044SSudeep Holla * functions. Replaces module_init() and module_exit() and keeps people from
992933c5044SSudeep Holla * printing pointless things to the kernel log when their driver is loaded.
993933c5044SSudeep Holla */
994933c5044SSudeep Holla #define module_scmi_driver(__scmi_driver) \
995933c5044SSudeep Holla module_driver(__scmi_driver, scmi_register, scmi_unregister)
996933c5044SSudeep Holla
997f5800e0bSCristian Marussi /**
998f5800e0bSCristian Marussi * module_scmi_protocol() - Helper macro for registering a scmi protocol
999f5800e0bSCristian Marussi * @__scmi_protocol: scmi_protocol structure
1000f5800e0bSCristian Marussi *
1001f5800e0bSCristian Marussi * Helper macro for scmi drivers to set up proper module init / exit
1002f5800e0bSCristian Marussi * functions. Replaces module_init() and module_exit() and keeps people from
1003f5800e0bSCristian Marussi * printing pointless things to the kernel log when their driver is loaded.
1004f5800e0bSCristian Marussi */
1005f5800e0bSCristian Marussi #define module_scmi_protocol(__scmi_protocol) \
1006f5800e0bSCristian Marussi module_driver(__scmi_protocol, \
1007f5800e0bSCristian Marussi scmi_protocol_register, scmi_protocol_unregister)
1008f5800e0bSCristian Marussi
100948dc16e2SCristian Marussi struct scmi_protocol;
101048dc16e2SCristian Marussi int scmi_protocol_register(const struct scmi_protocol *proto);
101148dc16e2SCristian Marussi void scmi_protocol_unregister(const struct scmi_protocol *proto);
101270771c69SSudeep Holla
1013e27077bcSCristian Marussi /* SCMI Notification API - Custom Event Reports */
1014e27077bcSCristian Marussi enum scmi_notification_events {
1015e27077bcSCristian Marussi SCMI_EVENT_POWER_STATE_CHANGED = 0x0,
10167aa75496SCristian Marussi SCMI_EVENT_CLOCK_RATE_CHANGED = 0x0,
10177aa75496SCristian Marussi SCMI_EVENT_CLOCK_RATE_CHANGE_REQUESTED = 0x1,
1018fb5086dcSCristian Marussi SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0,
1019fb5086dcSCristian Marussi SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1,
1020128e3e93SCristian Marussi SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0,
1021e3811190SCristian Marussi SCMI_EVENT_SENSOR_UPDATE = 0x1,
1022469ca182SCristian Marussi SCMI_EVENT_RESET_ISSUED = 0x0,
1023585dfab3SCristian Marussi SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
1024a8803055SCristian Marussi SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
10250316f99cSCristian Marussi SCMI_EVENT_POWERCAP_CAP_CHANGED = 0x0,
10260316f99cSCristian Marussi SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED = 0x1,
1027e27077bcSCristian Marussi };
1028e27077bcSCristian Marussi
1029e27077bcSCristian Marussi struct scmi_power_state_changed_report {
103072a5eb9dSCristian Marussi ktime_t timestamp;
103172a5eb9dSCristian Marussi unsigned int agent_id;
103272a5eb9dSCristian Marussi unsigned int domain_id;
103372a5eb9dSCristian Marussi unsigned int power_state;
1034e27077bcSCristian Marussi };
1035e27077bcSCristian Marussi
10367aa75496SCristian Marussi struct scmi_clock_rate_notif_report {
10377aa75496SCristian Marussi ktime_t timestamp;
10387aa75496SCristian Marussi unsigned int agent_id;
10397aa75496SCristian Marussi unsigned int clock_id;
10407aa75496SCristian Marussi unsigned long long rate;
10417aa75496SCristian Marussi };
10427aa75496SCristian Marussi
1043a8803055SCristian Marussi struct scmi_system_power_state_notifier_report {
1044a8803055SCristian Marussi ktime_t timestamp;
1045a8803055SCristian Marussi unsigned int agent_id;
10467097f298SCristian Marussi #define SCMI_SYSPOWER_IS_REQUEST_GRACEFUL(flags) ((flags) & BIT(0))
1047a8803055SCristian Marussi unsigned int flags;
1048a8803055SCristian Marussi unsigned int system_state;
10497097f298SCristian Marussi unsigned int timeout;
1050a8803055SCristian Marussi };
1051a8803055SCristian Marussi
1052fb5086dcSCristian Marussi struct scmi_perf_limits_report {
105372a5eb9dSCristian Marussi ktime_t timestamp;
105472a5eb9dSCristian Marussi unsigned int agent_id;
105572a5eb9dSCristian Marussi unsigned int domain_id;
105672a5eb9dSCristian Marussi unsigned int range_max;
105772a5eb9dSCristian Marussi unsigned int range_min;
105822ffc748SCristian Marussi unsigned long range_max_freq;
105922ffc748SCristian Marussi unsigned long range_min_freq;
1060fb5086dcSCristian Marussi };
1061fb5086dcSCristian Marussi
1062fb5086dcSCristian Marussi struct scmi_perf_level_report {
106372a5eb9dSCristian Marussi ktime_t timestamp;
106472a5eb9dSCristian Marussi unsigned int agent_id;
106572a5eb9dSCristian Marussi unsigned int domain_id;
106672a5eb9dSCristian Marussi unsigned int performance_level;
106722ffc748SCristian Marussi unsigned long performance_level_freq;
1068fb5086dcSCristian Marussi };
1069fb5086dcSCristian Marussi
1070128e3e93SCristian Marussi struct scmi_sensor_trip_point_report {
107172a5eb9dSCristian Marussi ktime_t timestamp;
107272a5eb9dSCristian Marussi unsigned int agent_id;
107372a5eb9dSCristian Marussi unsigned int sensor_id;
107472a5eb9dSCristian Marussi unsigned int trip_point_desc;
1075128e3e93SCristian Marussi };
1076128e3e93SCristian Marussi
1077e3811190SCristian Marussi struct scmi_sensor_update_report {
1078e3811190SCristian Marussi ktime_t timestamp;
1079e3811190SCristian Marussi unsigned int agent_id;
1080e3811190SCristian Marussi unsigned int sensor_id;
1081e3811190SCristian Marussi unsigned int readings_count;
1082e3811190SCristian Marussi struct scmi_sensor_reading readings[];
1083e3811190SCristian Marussi };
1084e3811190SCristian Marussi
1085469ca182SCristian Marussi struct scmi_reset_issued_report {
108672a5eb9dSCristian Marussi ktime_t timestamp;
108772a5eb9dSCristian Marussi unsigned int agent_id;
108872a5eb9dSCristian Marussi unsigned int domain_id;
108972a5eb9dSCristian Marussi unsigned int reset_state;
1090469ca182SCristian Marussi };
1091469ca182SCristian Marussi
1092585dfab3SCristian Marussi struct scmi_base_error_report {
109372a5eb9dSCristian Marussi ktime_t timestamp;
109472a5eb9dSCristian Marussi unsigned int agent_id;
1095585dfab3SCristian Marussi bool fatal;
109672a5eb9dSCristian Marussi unsigned int cmd_count;
109772a5eb9dSCristian Marussi unsigned long long reports[];
1098585dfab3SCristian Marussi };
1099585dfab3SCristian Marussi
11000316f99cSCristian Marussi struct scmi_powercap_cap_changed_report {
11010316f99cSCristian Marussi ktime_t timestamp;
11020316f99cSCristian Marussi unsigned int agent_id;
11030316f99cSCristian Marussi unsigned int domain_id;
11040316f99cSCristian Marussi unsigned int power_cap;
11050316f99cSCristian Marussi unsigned int pai;
11060316f99cSCristian Marussi };
11070316f99cSCristian Marussi
11080316f99cSCristian Marussi struct scmi_powercap_meas_changed_report {
11090316f99cSCristian Marussi ktime_t timestamp;
11100316f99cSCristian Marussi unsigned int agent_id;
11110316f99cSCristian Marussi unsigned int domain_id;
11120316f99cSCristian Marussi unsigned int power;
11130316f99cSCristian Marussi };
111470771c69SSudeep Holla #endif /* _LINUX_SCMI_PROTOCOL_H */
1115