2019-07-23 21:00:09 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2017-03-28 18:36:07 +08:00
|
|
|
/*
|
|
|
|
* SCMI Message Protocol driver header
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 ARM Ltd.
|
|
|
|
*/
|
2020-04-04 01:10:17 +08:00
|
|
|
|
|
|
|
#ifndef _LINUX_SCMI_PROTOCOL_H
|
|
|
|
#define _LINUX_SCMI_PROTOCOL_H
|
|
|
|
|
2020-11-20 01:49:02 +08:00
|
|
|
#include <linux/bitfield.h>
|
2017-10-31 02:33:30 +08:00
|
|
|
#include <linux/device.h>
|
2020-07-01 23:53:41 +08:00
|
|
|
#include <linux/notifier.h>
|
2017-03-28 18:36:07 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2017-06-06 18:16:15 +08:00
|
|
|
#define SCMI_MAX_STR_SIZE 16
|
2017-06-06 18:27:57 +08:00
|
|
|
#define SCMI_MAX_NUM_RATES 16
|
2017-06-06 18:16:15 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct scmi_revision_info - version information structure
|
|
|
|
*
|
|
|
|
* @major_ver: Major ABI version. Change here implies risk of backward
|
|
|
|
* compatibility break.
|
|
|
|
* @minor_ver: Minor ABI version. Change here implies new feature addition,
|
|
|
|
* or compatible change in ABI.
|
|
|
|
* @num_protocols: Number of protocols that are implemented, excluding the
|
|
|
|
* base protocol.
|
|
|
|
* @num_agents: Number of agents in the system.
|
|
|
|
* @impl_ver: A vendor-specific implementation version.
|
|
|
|
* @vendor_id: A vendor identifier(Null terminated ASCII string)
|
|
|
|
* @sub_vendor_id: A sub-vendor identifier(Null terminated ASCII string)
|
|
|
|
*/
|
|
|
|
struct scmi_revision_info {
|
|
|
|
u16 major_ver;
|
|
|
|
u16 minor_ver;
|
|
|
|
u8 num_protocols;
|
|
|
|
u8 num_agents;
|
|
|
|
u32 impl_ver;
|
|
|
|
char vendor_id[SCMI_MAX_STR_SIZE];
|
|
|
|
char sub_vendor_id[SCMI_MAX_STR_SIZE];
|
|
|
|
};
|
|
|
|
|
2017-06-06 18:27:57 +08:00
|
|
|
struct scmi_clock_info {
|
|
|
|
char name[SCMI_MAX_STR_SIZE];
|
|
|
|
bool rate_discrete;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int num_rates;
|
|
|
|
u64 rates[SCMI_MAX_NUM_RATES];
|
|
|
|
} list;
|
|
|
|
struct {
|
|
|
|
u64 min_rate;
|
|
|
|
u64 max_rate;
|
|
|
|
u64 step_size;
|
|
|
|
} range;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-06-06 18:22:51 +08:00
|
|
|
struct scmi_handle;
|
|
|
|
|
2017-06-06 18:27:57 +08:00
|
|
|
/**
|
|
|
|
* struct scmi_clk_ops - represents the various operations provided
|
|
|
|
* by SCMI Clock Protocol
|
|
|
|
*
|
|
|
|
* @count_get: get the count of clocks provided by SCMI
|
|
|
|
* @info_get: get the information of the specified clock
|
|
|
|
* @rate_get: request the current clock rate of a clock
|
|
|
|
* @rate_set: set the clock rate of a clock
|
|
|
|
* @enable: enables the specified clock
|
|
|
|
* @disable: disables the specified clock
|
|
|
|
*/
|
|
|
|
struct scmi_clk_ops {
|
|
|
|
int (*count_get)(const struct scmi_handle *handle);
|
|
|
|
|
|
|
|
const struct scmi_clock_info *(*info_get)
|
|
|
|
(const struct scmi_handle *handle, u32 clk_id);
|
|
|
|
int (*rate_get)(const struct scmi_handle *handle, u32 clk_id,
|
|
|
|
u64 *rate);
|
|
|
|
int (*rate_set)(const struct scmi_handle *handle, u32 clk_id,
|
2019-07-08 16:42:22 +08:00
|
|
|
u64 rate);
|
2017-06-06 18:27:57 +08:00
|
|
|
int (*enable)(const struct scmi_handle *handle, u32 clk_id);
|
|
|
|
int (*disable)(const struct scmi_handle *handle, u32 clk_id);
|
|
|
|
};
|
|
|
|
|
2017-06-06 18:22:51 +08:00
|
|
|
/**
|
|
|
|
* struct scmi_perf_ops - represents the various operations provided
|
|
|
|
* by SCMI Performance Protocol
|
|
|
|
*
|
|
|
|
* @limits_set: sets limits on the performance level of a domain
|
|
|
|
* @limits_get: gets limits on the performance level of a domain
|
|
|
|
* @level_set: sets the performance level of a domain
|
|
|
|
* @level_get: gets the performance level of a domain
|
|
|
|
* @device_domain_id: gets the scmi domain id for a given device
|
2018-05-10 00:52:06 +08:00
|
|
|
* @transition_latency_get: gets the DVFS transition latency for a given device
|
|
|
|
* @device_opps_add: adds all the OPPs for a given device
|
2017-06-06 18:22:51 +08:00
|
|
|
* @freq_set: sets the frequency for a given device using sustained frequency
|
|
|
|
* to sustained performance level mapping
|
|
|
|
* @freq_get: gets the frequency for a given device using sustained frequency
|
|
|
|
* to sustained performance level mapping
|
2018-09-11 00:28:10 +08:00
|
|
|
* @est_power_get: gets the estimated power cost for a given performance domain
|
|
|
|
* at a given frequency
|
2017-06-06 18:22:51 +08:00
|
|
|
*/
|
|
|
|
struct scmi_perf_ops {
|
|
|
|
int (*limits_set)(const struct scmi_handle *handle, u32 domain,
|
|
|
|
u32 max_perf, u32 min_perf);
|
|
|
|
int (*limits_get)(const struct scmi_handle *handle, u32 domain,
|
|
|
|
u32 *max_perf, u32 *min_perf);
|
|
|
|
int (*level_set)(const struct scmi_handle *handle, u32 domain,
|
2017-07-21 18:42:24 +08:00
|
|
|
u32 level, bool poll);
|
2017-06-06 18:22:51 +08:00
|
|
|
int (*level_get)(const struct scmi_handle *handle, u32 domain,
|
2017-07-21 18:42:24 +08:00
|
|
|
u32 *level, bool poll);
|
2017-06-06 18:22:51 +08:00
|
|
|
int (*device_domain_id)(struct device *dev);
|
2018-05-10 00:52:06 +08:00
|
|
|
int (*transition_latency_get)(const struct scmi_handle *handle,
|
2017-06-06 18:22:51 +08:00
|
|
|
struct device *dev);
|
2018-05-10 00:52:06 +08:00
|
|
|
int (*device_opps_add)(const struct scmi_handle *handle,
|
|
|
|
struct device *dev);
|
2017-06-06 18:22:51 +08:00
|
|
|
int (*freq_set)(const struct scmi_handle *handle, u32 domain,
|
2017-07-21 18:42:24 +08:00
|
|
|
unsigned long rate, bool poll);
|
2017-06-06 18:22:51 +08:00
|
|
|
int (*freq_get)(const struct scmi_handle *handle, u32 domain,
|
2017-07-21 18:42:24 +08:00
|
|
|
unsigned long *rate, bool poll);
|
2018-09-11 00:28:10 +08:00
|
|
|
int (*est_power_get)(const struct scmi_handle *handle, u32 domain,
|
|
|
|
unsigned long *rate, unsigned long *power);
|
2020-06-17 17:43:31 +08:00
|
|
|
bool (*fast_switch_possible)(const struct scmi_handle *handle,
|
|
|
|
struct device *dev);
|
2017-06-06 18:22:51 +08:00
|
|
|
};
|
|
|
|
|
2017-06-06 18:32:24 +08:00
|
|
|
/**
|
|
|
|
* struct scmi_power_ops - represents the various operations provided
|
|
|
|
* by SCMI Power Protocol
|
|
|
|
*
|
|
|
|
* @num_domains_get: get the count of power domains provided by SCMI
|
|
|
|
* @name_get: gets the name of a power domain
|
|
|
|
* @state_set: sets the power state of a power domain
|
|
|
|
* @state_get: gets the power state of a power domain
|
|
|
|
*/
|
|
|
|
struct scmi_power_ops {
|
|
|
|
int (*num_domains_get)(const struct scmi_handle *handle);
|
|
|
|
char *(*name_get)(const struct scmi_handle *handle, u32 domain);
|
|
|
|
#define SCMI_POWER_STATE_TYPE_SHIFT 30
|
|
|
|
#define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1)
|
|
|
|
#define SCMI_POWER_STATE_PARAM(type, id) \
|
|
|
|
((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \
|
|
|
|
((id) & SCMI_POWER_STATE_ID_MASK))
|
|
|
|
#define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0)
|
|
|
|
#define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0)
|
|
|
|
int (*state_set)(const struct scmi_handle *handle, u32 domain,
|
|
|
|
u32 state);
|
|
|
|
int (*state_get)(const struct scmi_handle *handle, u32 domain,
|
|
|
|
u32 *state);
|
|
|
|
};
|
|
|
|
|
2020-11-20 01:49:04 +08:00
|
|
|
/**
|
|
|
|
* scmi_sensor_reading - represent a timestamped read
|
|
|
|
*
|
|
|
|
* Used by @reading_get_timestamped method.
|
|
|
|
*
|
|
|
|
* @value: The signed value sensor read.
|
|
|
|
* @timestamp: An unsigned timestamp for the sensor read, as provided by
|
|
|
|
* SCMI platform. Set to zero when not available.
|
|
|
|
*/
|
|
|
|
struct scmi_sensor_reading {
|
|
|
|
long long value;
|
|
|
|
unsigned long long timestamp;
|
|
|
|
};
|
|
|
|
|
2020-11-20 01:49:02 +08:00
|
|
|
/**
|
|
|
|
* scmi_range_attrs - specifies a sensor or axis values' range
|
|
|
|
* @min_range: The minimum value which can be represented by the sensor/axis.
|
|
|
|
* @max_range: The maximum value which can be represented by the sensor/axis.
|
|
|
|
*/
|
|
|
|
struct scmi_range_attrs {
|
|
|
|
long long min_range;
|
|
|
|
long long max_range;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scmi_sensor_axis_info - describes one sensor axes
|
|
|
|
* @id: The axes ID.
|
|
|
|
* @type: Axes type. Chosen amongst one of @enum scmi_sensor_class.
|
|
|
|
* @scale: Power-of-10 multiplier applied to the axis unit.
|
|
|
|
* @name: NULL-terminated string representing axes name as advertised by
|
|
|
|
* SCMI platform.
|
|
|
|
* @extended_attrs: Flag to indicate the presence of additional extended
|
|
|
|
* attributes for this axes.
|
|
|
|
* @resolution: Extended attribute representing the resolution of the axes.
|
|
|
|
* Set to 0 if not reported by this axes.
|
|
|
|
* @exponent: Extended attribute representing the power-of-10 multiplier that
|
|
|
|
* is applied to the resolution field. Set to 0 if not reported by
|
|
|
|
* this axes.
|
|
|
|
* @attrs: Extended attributes representing minimum and maximum values
|
|
|
|
* measurable by this axes. Set to 0 if not reported by this sensor.
|
|
|
|
*/
|
|
|
|
struct scmi_sensor_axis_info {
|
|
|
|
unsigned int id;
|
|
|
|
unsigned int type;
|
|
|
|
int scale;
|
|
|
|
char name[SCMI_MAX_STR_SIZE];
|
|
|
|
bool extended_attrs;
|
|
|
|
unsigned int resolution;
|
|
|
|
int exponent;
|
|
|
|
struct scmi_range_attrs attrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scmi_sensor_intervals_info - describes number and type of available update
|
|
|
|
* intervals
|
|
|
|
* @segmented: Flag for segmented intervals' representation. When True there
|
|
|
|
* will be exactly 3 intervals in @desc, with each entry
|
|
|
|
* representing a member of a segment in this order:
|
|
|
|
* {lowest update interval, highest update interval, step size}
|
|
|
|
* @count: Number of intervals described in @desc.
|
|
|
|
* @desc: Array of @count interval descriptor bitmask represented as detailed in
|
|
|
|
* the SCMI specification: it can be accessed using the accompanying
|
|
|
|
* macros.
|
|
|
|
* @prealloc_pool: A minimal preallocated pool of desc entries used to avoid
|
|
|
|
* lesser-than-64-bytes dynamic allocation for small @count
|
|
|
|
* values.
|
|
|
|
*/
|
|
|
|
struct scmi_sensor_intervals_info {
|
|
|
|
bool segmented;
|
|
|
|
unsigned int count;
|
|
|
|
#define SCMI_SENS_INTVL_SEGMENT_LOW 0
|
|
|
|
#define SCMI_SENS_INTVL_SEGMENT_HIGH 1
|
|
|
|
#define SCMI_SENS_INTVL_SEGMENT_STEP 2
|
|
|
|
unsigned int *desc;
|
|
|
|
#define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x))
|
|
|
|
#define SCMI_SENS_INTVL_GET_EXP(x) \
|
|
|
|
({ \
|
|
|
|
int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \
|
|
|
|
\
|
|
|
|
if (__signed_exp & BIT(4)) \
|
|
|
|
__signed_exp |= GENMASK(31, 5); \
|
|
|
|
__signed_exp; \
|
|
|
|
})
|
|
|
|
#define SCMI_MAX_PREALLOC_POOL 16
|
|
|
|
unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct scmi_sensor_info - represents information related to one of the
|
|
|
|
* available sensors.
|
|
|
|
* @id: Sensor ID.
|
|
|
|
* @type: Sensor type. Chosen amongst one of @enum scmi_sensor_class.
|
|
|
|
* @scale: Power-of-10 multiplier applied to the sensor unit.
|
|
|
|
* @num_trip_points: Number of maximum configurable trip points.
|
|
|
|
* @async: Flag for asynchronous read support.
|
|
|
|
* @update: Flag for continuouos update notification support.
|
|
|
|
* @timestamped: Flag for timestamped read support.
|
|
|
|
* @tstamp_scale: Power-of-10 multiplier applied to the sensor timestamps to
|
|
|
|
* represent it in seconds.
|
|
|
|
* @num_axis: Number of supported axis if any. Reported as 0 for scalar sensors.
|
|
|
|
* @axis: Pointer to an array of @num_axis descriptors.
|
|
|
|
* @intervals: Descriptor of available update intervals.
|
|
|
|
* @sensor_config: A bitmask reporting the current sensor configuration as
|
|
|
|
* detailed in the SCMI specification: it can accessed and
|
|
|
|
* modified through the accompanying macros.
|
|
|
|
* @name: NULL-terminated string representing sensor name as advertised by
|
|
|
|
* SCMI platform.
|
|
|
|
* @extended_scalar_attrs: Flag to indicate the presence of additional extended
|
|
|
|
* attributes for this sensor.
|
|
|
|
* @sensor_power: Extended attribute representing the average power
|
|
|
|
* consumed by the sensor in microwatts (uW) when it is active.
|
|
|
|
* Reported here only for scalar sensors.
|
|
|
|
* Set to 0 if not reported by this sensor.
|
|
|
|
* @resolution: Extended attribute representing the resolution of the sensor.
|
|
|
|
* Reported here only for scalar sensors.
|
|
|
|
* Set to 0 if not reported by this sensor.
|
|
|
|
* @exponent: Extended attribute representing the power-of-10 multiplier that is
|
|
|
|
* applied to the resolution field.
|
|
|
|
* Reported here only for scalar sensors.
|
|
|
|
* Set to 0 if not reported by this sensor.
|
|
|
|
* @scalar_attrs: Extended attributes representing minimum and maximum
|
|
|
|
* measurable values by this sensor.
|
|
|
|
* Reported here only for scalar sensors.
|
|
|
|
* Set to 0 if not reported by this sensor.
|
|
|
|
*/
|
2017-06-06 18:38:10 +08:00
|
|
|
struct scmi_sensor_info {
|
2020-11-20 01:49:02 +08:00
|
|
|
unsigned int id;
|
|
|
|
unsigned int type;
|
|
|
|
int scale;
|
|
|
|
unsigned int num_trip_points;
|
2019-07-08 16:41:01 +08:00
|
|
|
bool async;
|
2020-11-20 01:49:02 +08:00
|
|
|
bool update;
|
|
|
|
bool timestamped;
|
|
|
|
int tstamp_scale;
|
|
|
|
unsigned int num_axis;
|
|
|
|
struct scmi_sensor_axis_info *axis;
|
|
|
|
struct scmi_sensor_intervals_info intervals;
|
2017-06-06 18:38:10 +08:00
|
|
|
char name[SCMI_MAX_STR_SIZE];
|
2020-11-20 01:49:02 +08:00
|
|
|
bool extended_scalar_attrs;
|
|
|
|
unsigned int sensor_power;
|
|
|
|
unsigned int resolution;
|
|
|
|
int exponent;
|
|
|
|
struct scmi_range_attrs scalar_attrs;
|
2017-06-06 18:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Partial list from Distributed Management Task Force (DMTF) specification:
|
|
|
|
* DSP0249 (Platform Level Data Model specification)
|
|
|
|
*/
|
|
|
|
enum scmi_sensor_class {
|
|
|
|
NONE = 0x0,
|
2020-11-20 18:55:17 +08:00
|
|
|
UNSPEC = 0x1,
|
2017-06-06 18:38:10 +08:00
|
|
|
TEMPERATURE_C = 0x2,
|
2020-11-20 18:55:17 +08:00
|
|
|
TEMPERATURE_F = 0x3,
|
|
|
|
TEMPERATURE_K = 0x4,
|
2017-06-06 18:38:10 +08:00
|
|
|
VOLTAGE = 0x5,
|
|
|
|
CURRENT = 0x6,
|
|
|
|
POWER = 0x7,
|
|
|
|
ENERGY = 0x8,
|
2020-11-20 18:55:17 +08:00
|
|
|
CHARGE = 0x9,
|
|
|
|
VOLTAMPERE = 0xA,
|
|
|
|
NITS = 0xB,
|
|
|
|
LUMENS = 0xC,
|
|
|
|
LUX = 0xD,
|
|
|
|
CANDELAS = 0xE,
|
|
|
|
KPA = 0xF,
|
|
|
|
PSI = 0x10,
|
|
|
|
NEWTON = 0x11,
|
|
|
|
CFM = 0x12,
|
|
|
|
RPM = 0x13,
|
|
|
|
HERTZ = 0x14,
|
|
|
|
SECS = 0x15,
|
|
|
|
MINS = 0x16,
|
|
|
|
HOURS = 0x17,
|
|
|
|
DAYS = 0x18,
|
|
|
|
WEEKS = 0x19,
|
|
|
|
MILS = 0x1A,
|
|
|
|
INCHES = 0x1B,
|
|
|
|
FEET = 0x1C,
|
|
|
|
CUBIC_INCHES = 0x1D,
|
|
|
|
CUBIC_FEET = 0x1E,
|
|
|
|
METERS = 0x1F,
|
|
|
|
CUBIC_CM = 0x20,
|
|
|
|
CUBIC_METERS = 0x21,
|
|
|
|
LITERS = 0x22,
|
|
|
|
FLUID_OUNCES = 0x23,
|
|
|
|
RADIANS = 0x24,
|
|
|
|
STERADIANS = 0x25,
|
|
|
|
REVOLUTIONS = 0x26,
|
|
|
|
CYCLES = 0x27,
|
|
|
|
GRAVITIES = 0x28,
|
|
|
|
OUNCES = 0x29,
|
|
|
|
POUNDS = 0x2A,
|
|
|
|
FOOT_POUNDS = 0x2B,
|
|
|
|
OUNCE_INCHES = 0x2C,
|
|
|
|
GAUSS = 0x2D,
|
|
|
|
GILBERTS = 0x2E,
|
|
|
|
HENRIES = 0x2F,
|
|
|
|
FARADS = 0x30,
|
|
|
|
OHMS = 0x31,
|
|
|
|
SIEMENS = 0x32,
|
|
|
|
MOLES = 0x33,
|
|
|
|
BECQUERELS = 0x34,
|
|
|
|
PPM = 0x35,
|
|
|
|
DECIBELS = 0x36,
|
|
|
|
DBA = 0x37,
|
|
|
|
DBC = 0x38,
|
|
|
|
GRAYS = 0x39,
|
|
|
|
SIEVERTS = 0x3A,
|
|
|
|
COLOR_TEMP_K = 0x3B,
|
|
|
|
BITS = 0x3C,
|
|
|
|
BYTES = 0x3D,
|
|
|
|
WORDS = 0x3E,
|
|
|
|
DWORDS = 0x3F,
|
|
|
|
QWORDS = 0x40,
|
|
|
|
PERCENTAGE = 0x41,
|
|
|
|
PASCALS = 0x42,
|
|
|
|
COUNTS = 0x43,
|
|
|
|
GRAMS = 0x44,
|
|
|
|
NEWTON_METERS = 0x45,
|
|
|
|
HITS = 0x46,
|
|
|
|
MISSES = 0x47,
|
|
|
|
RETRIES = 0x48,
|
|
|
|
OVERRUNS = 0x49,
|
|
|
|
UNDERRUNS = 0x4A,
|
|
|
|
COLLISIONS = 0x4B,
|
|
|
|
PACKETS = 0x4C,
|
|
|
|
MESSAGES = 0x4D,
|
|
|
|
CHARS = 0x4E,
|
|
|
|
ERRORS = 0x4F,
|
|
|
|
CORRECTED_ERRS = 0x50,
|
|
|
|
UNCORRECTABLE_ERRS = 0x51,
|
|
|
|
SQ_MILS = 0x52,
|
|
|
|
SQ_INCHES = 0x53,
|
|
|
|
SQ_FEET = 0x54,
|
|
|
|
SQ_CM = 0x55,
|
|
|
|
SQ_METERS = 0x56,
|
2020-11-20 01:49:02 +08:00
|
|
|
RADIANS_SEC = 0x57,
|
|
|
|
BPM = 0x58,
|
|
|
|
METERS_SEC_SQUARED = 0x59,
|
|
|
|
METERS_SEC = 0x5A,
|
|
|
|
CUBIC_METERS_SEC = 0x5B,
|
|
|
|
MM_MERCURY = 0x5C,
|
|
|
|
RADIANS_SEC_SQUARED = 0x5D,
|
|
|
|
OEM_UNIT = 0xFF
|
2017-06-06 18:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct scmi_sensor_ops - represents the various operations provided
|
|
|
|
* by SCMI Sensor Protocol
|
|
|
|
*
|
|
|
|
* @count_get: get the count of sensors provided by SCMI
|
|
|
|
* @info_get: get the information of the specified sensor
|
2019-07-08 16:40:33 +08:00
|
|
|
* @trip_point_config: selects and configures a trip-point of interest
|
2017-06-06 18:38:10 +08:00
|
|
|
* @reading_get: gets the current value of the sensor
|
2020-11-20 01:49:04 +08:00
|
|
|
* @reading_get_timestamped: gets the current value and timestamp, when
|
|
|
|
* available, of the sensor. (as of v3.0 spec)
|
|
|
|
* Supports multi-axis sensors for sensors which
|
|
|
|
* supports it and if the @reading array size of
|
|
|
|
* @count entry equals the sensor num_axis
|
2017-06-06 18:38:10 +08:00
|
|
|
*/
|
|
|
|
struct scmi_sensor_ops {
|
|
|
|
int (*count_get)(const struct scmi_handle *handle);
|
|
|
|
const struct scmi_sensor_info *(*info_get)
|
|
|
|
(const struct scmi_handle *handle, u32 sensor_id);
|
2019-07-08 16:40:33 +08:00
|
|
|
int (*trip_point_config)(const struct scmi_handle *handle,
|
|
|
|
u32 sensor_id, u8 trip_id, u64 trip_value);
|
2017-06-06 18:38:10 +08:00
|
|
|
int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id,
|
2019-07-08 16:40:57 +08:00
|
|
|
u64 *value);
|
2020-11-20 01:49:04 +08:00
|
|
|
int (*reading_get_timestamped)(const struct scmi_handle *handle,
|
|
|
|
u32 sensor_id, u8 count,
|
|
|
|
struct scmi_sensor_reading *readings);
|
2017-06-06 18:38:10 +08:00
|
|
|
};
|
|
|
|
|
2019-07-08 16:41:06 +08:00
|
|
|
/**
|
|
|
|
* struct scmi_reset_ops - represents the various operations provided
|
|
|
|
* by SCMI Reset Protocol
|
|
|
|
*
|
|
|
|
* @num_domains_get: get the count of reset domains provided by SCMI
|
|
|
|
* @name_get: gets the name of a reset domain
|
|
|
|
* @latency_get: gets the reset latency for the specified reset domain
|
|
|
|
* @reset: resets the specified reset domain
|
|
|
|
* @assert: explicitly assert reset signal of the specified reset domain
|
|
|
|
* @deassert: explicitly deassert reset signal of the specified reset domain
|
|
|
|
*/
|
|
|
|
struct scmi_reset_ops {
|
|
|
|
int (*num_domains_get)(const struct scmi_handle *handle);
|
|
|
|
char *(*name_get)(const struct scmi_handle *handle, u32 domain);
|
|
|
|
int (*latency_get)(const struct scmi_handle *handle, u32 domain);
|
|
|
|
int (*reset)(const struct scmi_handle *handle, u32 domain);
|
|
|
|
int (*assert)(const struct scmi_handle *handle, u32 domain);
|
|
|
|
int (*deassert)(const struct scmi_handle *handle, u32 domain);
|
|
|
|
};
|
|
|
|
|
2020-07-01 23:53:41 +08:00
|
|
|
/**
|
|
|
|
* struct scmi_notify_ops - represents notifications' operations provided by
|
|
|
|
* SCMI core
|
|
|
|
* @register_event_notifier: Register a notifier_block for the requested event
|
|
|
|
* @unregister_event_notifier: Unregister a notifier_block for the requested
|
|
|
|
* event
|
|
|
|
*
|
|
|
|
* A user can register/unregister its own notifier_block against the wanted
|
|
|
|
* platform instance regarding the desired event identified by the
|
|
|
|
* tuple: (proto_id, evt_id, src_id) using the provided register/unregister
|
|
|
|
* interface where:
|
|
|
|
*
|
|
|
|
* @handle: The handle identifying the platform instance to use
|
|
|
|
* @proto_id: The protocol ID as in SCMI Specification
|
|
|
|
* @evt_id: The message ID of the desired event as in SCMI Specification
|
|
|
|
* @src_id: A pointer to the desired source ID if different sources are
|
|
|
|
* possible for the protocol (like domain_id, sensor_id...etc)
|
|
|
|
*
|
|
|
|
* @src_id can be provided as NULL if it simply does NOT make sense for
|
|
|
|
* the protocol at hand, OR if the user is explicitly interested in
|
|
|
|
* receiving notifications from ANY existent source associated to the
|
|
|
|
* specified proto_id / evt_id.
|
|
|
|
*
|
|
|
|
* Received notifications are finally delivered to the registered users,
|
|
|
|
* invoking the callback provided with the notifier_block *nb as follows:
|
|
|
|
*
|
|
|
|
* int user_cb(nb, evt_id, report)
|
|
|
|
*
|
|
|
|
* with:
|
|
|
|
*
|
|
|
|
* @nb: The notifier block provided by the user
|
|
|
|
* @evt_id: The message ID of the delivered event
|
|
|
|
* @report: A custom struct describing the specific event delivered
|
|
|
|
*/
|
|
|
|
struct scmi_notify_ops {
|
|
|
|
int (*register_event_notifier)(const struct scmi_handle *handle,
|
|
|
|
u8 proto_id, u8 evt_id, u32 *src_id,
|
|
|
|
struct notifier_block *nb);
|
|
|
|
int (*unregister_event_notifier)(const struct scmi_handle *handle,
|
|
|
|
u8 proto_id, u8 evt_id, u32 *src_id,
|
|
|
|
struct notifier_block *nb);
|
|
|
|
};
|
|
|
|
|
2017-03-28 18:36:07 +08:00
|
|
|
/**
|
|
|
|
* struct scmi_handle - Handle returned to ARM SCMI clients for usage.
|
|
|
|
*
|
|
|
|
* @dev: pointer to the SCMI device
|
2017-06-06 18:16:15 +08:00
|
|
|
* @version: pointer to the structure containing SCMI version information
|
2017-06-06 18:32:24 +08:00
|
|
|
* @power_ops: pointer to set of power protocol operations
|
2017-06-06 18:22:51 +08:00
|
|
|
* @perf_ops: pointer to set of performance protocol operations
|
2017-06-06 18:27:57 +08:00
|
|
|
* @clk_ops: pointer to set of clock protocol operations
|
2017-06-06 18:38:10 +08:00
|
|
|
* @sensor_ops: pointer to set of sensor protocol operations
|
2019-07-08 16:41:06 +08:00
|
|
|
* @reset_ops: pointer to set of reset protocol operations
|
2020-07-01 23:53:41 +08:00
|
|
|
* @notify_ops: pointer to set of notifications related operations
|
2018-05-10 00:52:06 +08:00
|
|
|
* @perf_priv: pointer to private data structure specific to performance
|
|
|
|
* protocol(for internal use only)
|
|
|
|
* @clk_priv: pointer to private data structure specific to clock
|
|
|
|
* protocol(for internal use only)
|
|
|
|
* @power_priv: pointer to private data structure specific to power
|
|
|
|
* protocol(for internal use only)
|
|
|
|
* @sensor_priv: pointer to private data structure specific to sensors
|
|
|
|
* protocol(for internal use only)
|
2019-07-08 16:41:06 +08:00
|
|
|
* @reset_priv: pointer to private data structure specific to reset
|
|
|
|
* protocol(for internal use only)
|
2020-07-01 23:53:40 +08:00
|
|
|
* @notify_priv: pointer to private data structure specific to notifications
|
|
|
|
* (for internal use only)
|
2017-03-28 18:36:07 +08:00
|
|
|
*/
|
|
|
|
struct scmi_handle {
|
|
|
|
struct device *dev;
|
2017-06-06 18:16:15 +08:00
|
|
|
struct scmi_revision_info *version;
|
2020-09-07 07:04:51 +08:00
|
|
|
const struct scmi_perf_ops *perf_ops;
|
|
|
|
const struct scmi_clk_ops *clk_ops;
|
|
|
|
const struct scmi_power_ops *power_ops;
|
|
|
|
const struct scmi_sensor_ops *sensor_ops;
|
|
|
|
const struct scmi_reset_ops *reset_ops;
|
|
|
|
const struct scmi_notify_ops *notify_ops;
|
2017-06-06 18:22:51 +08:00
|
|
|
/* for protocol internal use */
|
|
|
|
void *perf_priv;
|
2017-06-06 18:27:57 +08:00
|
|
|
void *clk_priv;
|
2017-06-06 18:32:24 +08:00
|
|
|
void *power_priv;
|
2017-06-06 18:38:10 +08:00
|
|
|
void *sensor_priv;
|
2019-07-08 16:41:06 +08:00
|
|
|
void *reset_priv;
|
2020-07-01 23:53:40 +08:00
|
|
|
void *notify_priv;
|
2020-09-08 01:46:55 +08:00
|
|
|
void *system_priv;
|
2017-06-06 18:16:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum scmi_std_protocol {
|
|
|
|
SCMI_PROTOCOL_BASE = 0x10,
|
|
|
|
SCMI_PROTOCOL_POWER = 0x11,
|
|
|
|
SCMI_PROTOCOL_SYSTEM = 0x12,
|
|
|
|
SCMI_PROTOCOL_PERF = 0x13,
|
|
|
|
SCMI_PROTOCOL_CLOCK = 0x14,
|
|
|
|
SCMI_PROTOCOL_SENSOR = 0x15,
|
2019-07-08 16:41:06 +08:00
|
|
|
SCMI_PROTOCOL_RESET = 0x16,
|
2017-03-28 18:36:07 +08:00
|
|
|
};
|
2017-10-31 02:33:30 +08:00
|
|
|
|
2020-09-08 01:46:55 +08:00
|
|
|
enum scmi_system_events {
|
|
|
|
SCMI_SYSTEM_SHUTDOWN,
|
|
|
|
SCMI_SYSTEM_COLDRESET,
|
|
|
|
SCMI_SYSTEM_WARMRESET,
|
|
|
|
SCMI_SYSTEM_POWERUP,
|
|
|
|
SCMI_SYSTEM_SUSPEND,
|
|
|
|
SCMI_SYSTEM_MAX
|
|
|
|
};
|
|
|
|
|
2017-10-31 02:33:30 +08:00
|
|
|
struct scmi_device {
|
|
|
|
u32 id;
|
|
|
|
u8 protocol_id;
|
2018-12-22 02:08:08 +08:00
|
|
|
const char *name;
|
2017-10-31 02:33:30 +08:00
|
|
|
struct device dev;
|
|
|
|
struct scmi_handle *handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
|
|
|
|
|
|
|
|
struct scmi_device *
|
2018-12-22 02:08:08 +08:00
|
|
|
scmi_device_create(struct device_node *np, struct device *parent, int protocol,
|
|
|
|
const char *name);
|
2017-10-31 02:33:30 +08:00
|
|
|
void scmi_device_destroy(struct scmi_device *scmi_dev);
|
|
|
|
|
|
|
|
struct scmi_device_id {
|
|
|
|
u8 protocol_id;
|
2018-12-22 02:08:08 +08:00
|
|
|
const char *name;
|
2017-10-31 02:33:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct scmi_driver {
|
|
|
|
const char *name;
|
|
|
|
int (*probe)(struct scmi_device *sdev);
|
|
|
|
void (*remove)(struct scmi_device *sdev);
|
|
|
|
const struct scmi_device_id *id_table;
|
|
|
|
|
|
|
|
struct device_driver driver;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
|
|
|
|
|
2020-09-07 19:09:23 +08:00
|
|
|
#if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
|
2017-10-31 02:33:30 +08:00
|
|
|
int scmi_driver_register(struct scmi_driver *driver,
|
|
|
|
struct module *owner, const char *mod_name);
|
|
|
|
void scmi_driver_unregister(struct scmi_driver *driver);
|
|
|
|
#else
|
|
|
|
static inline int
|
|
|
|
scmi_driver_register(struct scmi_driver *driver, struct module *owner,
|
|
|
|
const char *mod_name)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void scmi_driver_unregister(struct scmi_driver *driver) {}
|
|
|
|
#endif /* CONFIG_ARM_SCMI_PROTOCOL */
|
|
|
|
|
|
|
|
#define scmi_register(driver) \
|
|
|
|
scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
|
|
|
|
#define scmi_unregister(driver) \
|
|
|
|
scmi_driver_unregister(driver)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* module_scmi_driver() - Helper macro for registering a scmi driver
|
|
|
|
* @__scmi_driver: scmi_driver structure
|
|
|
|
*
|
|
|
|
* Helper macro for scmi drivers to set up proper module init / exit
|
|
|
|
* functions. Replaces module_init() and module_exit() and keeps people from
|
|
|
|
* printing pointless things to the kernel log when their driver is loaded.
|
|
|
|
*/
|
|
|
|
#define module_scmi_driver(__scmi_driver) \
|
|
|
|
module_driver(__scmi_driver, scmi_register, scmi_unregister)
|
|
|
|
|
|
|
|
typedef int (*scmi_prot_init_fn_t)(struct scmi_handle *);
|
|
|
|
int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn);
|
|
|
|
void scmi_protocol_unregister(int protocol_id);
|
2020-04-04 01:10:17 +08:00
|
|
|
|
2020-07-01 23:53:44 +08:00
|
|
|
/* SCMI Notification API - Custom Event Reports */
|
|
|
|
enum scmi_notification_events {
|
|
|
|
SCMI_EVENT_POWER_STATE_CHANGED = 0x0,
|
2020-07-01 23:53:45 +08:00
|
|
|
SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0,
|
|
|
|
SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1,
|
2020-07-01 23:53:46 +08:00
|
|
|
SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0,
|
2020-07-01 23:53:47 +08:00
|
|
|
SCMI_EVENT_RESET_ISSUED = 0x0,
|
2020-07-01 23:53:48 +08:00
|
|
|
SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
|
2020-09-08 01:46:55 +08:00
|
|
|
SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
|
2020-07-01 23:53:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct scmi_power_state_changed_report {
|
2020-07-10 21:39:19 +08:00
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
unsigned int domain_id;
|
|
|
|
unsigned int power_state;
|
2020-07-01 23:53:44 +08:00
|
|
|
};
|
|
|
|
|
2020-09-08 01:46:55 +08:00
|
|
|
struct scmi_system_power_state_notifier_report {
|
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int system_state;
|
|
|
|
};
|
|
|
|
|
2020-07-01 23:53:45 +08:00
|
|
|
struct scmi_perf_limits_report {
|
2020-07-10 21:39:19 +08:00
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
unsigned int domain_id;
|
|
|
|
unsigned int range_max;
|
|
|
|
unsigned int range_min;
|
2020-07-01 23:53:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct scmi_perf_level_report {
|
2020-07-10 21:39:19 +08:00
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
unsigned int domain_id;
|
|
|
|
unsigned int performance_level;
|
2020-07-01 23:53:45 +08:00
|
|
|
};
|
|
|
|
|
2020-07-01 23:53:46 +08:00
|
|
|
struct scmi_sensor_trip_point_report {
|
2020-07-10 21:39:19 +08:00
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
unsigned int sensor_id;
|
|
|
|
unsigned int trip_point_desc;
|
2020-07-01 23:53:46 +08:00
|
|
|
};
|
|
|
|
|
2020-07-01 23:53:47 +08:00
|
|
|
struct scmi_reset_issued_report {
|
2020-07-10 21:39:19 +08:00
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
unsigned int domain_id;
|
|
|
|
unsigned int reset_state;
|
2020-07-01 23:53:47 +08:00
|
|
|
};
|
|
|
|
|
2020-07-01 23:53:48 +08:00
|
|
|
struct scmi_base_error_report {
|
2020-07-10 21:39:19 +08:00
|
|
|
ktime_t timestamp;
|
|
|
|
unsigned int agent_id;
|
|
|
|
bool fatal;
|
|
|
|
unsigned int cmd_count;
|
|
|
|
unsigned long long reports[];
|
2020-07-01 23:53:48 +08:00
|
|
|
};
|
|
|
|
|
2020-04-04 01:10:17 +08:00
|
|
|
#endif /* _LINUX_SCMI_PROTOCOL_H */
|