| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092 |
- /*
- * Copyright (c) 2006-2022, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2022-11-26 GuEe-GUI first version
- */
- #ifndef __SCMI_H__
- #define __SCMI_H__
- #include <rtdef.h>
- #include <drivers/misc.h>
- #include <drivers/byteorder.h>
- #define SCMI_PROTOCOL_ID_BASE 0x10
- #define SCMI_PROTOCOL_ID_POWER 0x11
- #define SCMI_PROTOCOL_ID_SYSTEM 0x12
- #define SCMI_PROTOCOL_ID_PERF 0x13
- #define SCMI_PROTOCOL_ID_CLOCK 0x14
- #define SCMI_PROTOCOL_ID_SENSOR 0x15
- #define SCMI_PROTOCOL_ID_RESET 0x16
- #define SCMI_PROTOCOL_ID_VOLTAGE 0x17
- #define SCMI_PROTOCOL_ID_POWERCAP 0x18
- #define SCMI_PROTOCOL_ID_PINCTRL 0x19
- #define SCMI_SUCCESS 0 /* Success */
- #define SCMI_ERR_SUPPORT (-1) /* Not supported */
- #define SCMI_ERR_PARAMS (-2) /* Invalid Parameters */
- #define SCMI_ERR_ACCESS (-3) /* Invalid access/permission denied */
- #define SCMI_ERR_ENTRY (-4) /* Not found */
- #define SCMI_ERR_RANGE (-5) /* Value out of range */
- #define SCMI_ERR_BUSY (-6) /* Device busy */
- #define SCMI_ERR_COMMS (-7) /* Communication Error */
- #define SCMI_ERR_GENERIC (-8) /* Generic Error */
- #define SCMI_ERR_HARDWARE (-9) /* Hardware Error */
- #define SCMI_ERR_PROTOCOL (-10) /* Protocol Error */
- #define SCMI_MAX_STR_SIZE 64
- #define SCMI_SHORT_NAME_MAX_SIZE 16
- #define SCMI_MAX_NUM_RATES 16
- struct rt_scmi_device;
- typedef void (*rt_scmi_msg_callback)(struct rt_scmi_device *sdev, rt_uint8_t *msg, rt_size_t size);
- /*
- * struct rt_scmi_msg - Context of a SCMI message sent and the response received
- *
- */
- struct rt_scmi_msg
- {
- struct rt_scmi_device *sdev;
- rt_scmi_msg_callback rx_callback;
- rt_uint32_t message_id;
- rt_uint8_t *in_msg;
- rt_size_t in_msg_size;
- rt_uint8_t *out_msg;
- rt_size_t out_msg_size;
- };
- /* Helper macro to match a message on input/output array references */
- #define RT_SCMI_MSG_RAW(MSG_ID, IN, IN_SIZE, OUT, OUT_SIZE) \
- (struct rt_scmi_msg) { \
- .message_id = MSG_ID, \
- .in_msg = (rt_uint8_t *)(IN), \
- .in_msg_size = IN_SIZE, \
- .out_msg = (rt_uint8_t *)(OUT), \
- .out_msg_size = OUT_SIZE, \
- }
- #define RT_SCMI_MSG_IN_OUT(MSG_ID, IN, OUT) \
- RT_SCMI_MSG_RAW(MSG_ID, IN, sizeof(*(IN)), OUT, sizeof(*(OUT)))
- #define RT_SCMI_MSG_IN(MSG_ID, IN) \
- RT_SCMI_MSG_RAW(MSG_ID, IN, sizeof(*(IN)), RT_NULL, 0)
- #define RT_SCMI_MSG_OUT(MSG_ID, OUT) \
- RT_SCMI_MSG_RAW(MSG_ID, RT_NULL, 0, OUT, sizeof(*(OUT)))
- #define SCMI_HDR_TOKEN(token) (((token) << 18) & RT_GENMASK(31, 18))
- #define SCMI_HDR_PROTOCOL_ID(proto) (((proto) << 10) & RT_GENMASK(17, 10))
- #define SCMI_HDR_MESSAGE_TYPE(type) (((type) << 18) & RT_GENMASK(9, 8))
- #define SCMI_HDR_MESSAGE_ID(id) ((id) & RT_GENMASK(7, 0))
- rt_inline rt_uint32_t scmi_header(unsigned msg_id, unsigned msg_type,
- unsigned protocol_id, unsigned token)
- {
- return SCMI_HDR_TOKEN(token) |
- SCMI_HDR_MESSAGE_TYPE(msg_type) |
- SCMI_HDR_PROTOCOL_ID(protocol_id) |
- SCMI_HDR_MESSAGE_ID(msg_id);
- }
- enum scmi_common_message_id
- {
- SCMI_COM_MSG_VERSION = 0x0,
- SCMI_COM_MSG_ATTRIBUTES = 0x1,
- SCMI_COM_MSG_MESSAGE_ATTRIBUTES = 0x2,
- };
- /*
- * SCMI Power Protocol
- */
- enum scmi_power_protocol_cmd
- {
- SCMI_POWER_DOMAIN_ATTRIBUTES = 0x3,
- SCMI_POWER_STATE_SET = 0x4,
- SCMI_POWER_STATE_GET = 0x5,
- SCMI_POWER_STATE_NOTIFY = 0x6,
- SCMI_POWER_DOMAIN_NAME_GET = 0x8,
- };
- /**
- * struct scmi_power_attributes - Response payload for SCMI_COM_MSG_ATTRIBUTES command
- */
- struct scmi_power_attributes
- {
- rt_le32_t state;
- rt_le16_t num_domains;
- rt_le16_t reserved;
- rt_le32_t stats_addr_low;
- rt_le32_t stats_addr_high;
- rt_le32_t stats_size;
- };
- /**
- * struct scmi_power_state_set_in - Message payload for SCMI_POWER_STATE_SET command
- */
- struct scmi_power_state_set_in
- {
- rt_le32_t flags;
- rt_le32_t domain;
- #define SCMI_POWER_STATE_TYPE_SHIFT 30
- #define SCMI_POWER_STATE_ID_MASK (RT_BIT(28) - 1)
- #define SCMI_POWER_STATE_PARAM(type, id) ((((type) & RT_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)
- rt_le32_t state;
- };
- /**
- * struct scmi_power_state_set_out - Response payload for SCMI_POWER_STATE_SET command
- */
- struct scmi_power_state_set_out
- {
- rt_le32_t state;
- };
- /*
- * SCMI Clock Protocol
- */
- enum scmi_clock_message_id
- {
- SCMI_CLOCK_ATTRIBUTES = 0x3,
- SCMI_CLOCK_DESCRIBE_RATES = 0x4,
- SCMI_CLOCK_RATE_SET = 0x5,
- SCMI_CLOCK_RATE_GET = 0x6,
- SCMI_CLOCK_CONFIG_SET = 0x7,
- SCMI_CLOCK_NAME_GET = 0x8,
- };
- /**
- * struct scmi_clk_attributes - Response payload for SCMI_COM_MSG_ATTRIBUTES command
- */
- struct scmi_clk_attributes
- {
- rt_le32_t status;
- rt_le16_t num_clocks;
- rt_uint8_t max_async_req;
- rt_uint8_t reserved;
- };
- /**
- * struct scmi_clk_describe_attributes_in - Message payload for SCMI_CLOCK_ATTRIBUTES command
- */
- struct scmi_clk_describe_attributes_in
- {
- rt_le32_t clock_id;
- };
- /**
- * struct scmi_clk_describe_attributes_out - Response payload for SCMI_CLOCK_ATTRIBUTES command
- * clock in response to a clock enable request from an agent
- */
- struct scmi_clk_describe_attributes_out
- {
- rt_le32_t status;
- rt_le32_t attributes;
- #define CLOCK_ENABLE RT_BIT(0)
- #define SUPPORTS_RATE_CHANGED_NOTIF(x) ((x) & RT_BIT(31))
- #define SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(x) ((x) & RT_BIT(30))
- #define SUPPORTS_EXTENDED_NAMES(x) ((x) & RT_BIT(29))
- rt_uint8_t name[SCMI_SHORT_NAME_MAX_SIZE];
- rt_le32_t clock_enable_latency;
- };
- /**
- * struct scmi_clk_describe_rates_in - Message payload for SCMI_CLOCK_DESCRIBE_RATES command
- */
- struct scmi_clk_describe_rates_in
- {
- rt_le32_t id;
- rt_le32_t rate_index;
- };
- /**
- * struct scmi_clk_describe_rates_out - Response payload for SCMI_CLOCK_DESCRIBE_RATES command
- */
- struct scmi_clk_describe_rates_out
- {
- rt_le32_t status;
- rt_le32_t num_rates_flags;
- #define SCMI_NUM_RETURNED(x) ((x) & 0xfff)
- #define SCMI_RATE_DISCRETE(x) !((x) & RT_BIT(12))
- #define SCMI_NUM_REMAINING(x) ((x) >> 16)
- struct
- {
- rt_le32_t value_low;
- rt_le32_t value_high;
- } rate[];
- #define SCMI_RATE_TO_U64(X) \
- ({ \
- typeof(X) x = (X); \
- rt_le32_to_cpu((x).value_low) | (rt_uint64_t)rt_le32_to_cpu((x).value_high) << 32; \
- })
- };
- /**
- * struct scmi_clk_state_in - Message payload for SCMI_CLOCK_RATE_SET command
- */
- struct scmi_clk_rate_set_in
- {
- #define SCMI_CLK_RATE_ASYNC_NOTIFY RT_BIT(0)
- #define SCMI_CLK_RATE_ASYNC_NORESP (RT_BIT(0) | RT_BIT(1))
- #define SCMI_CLK_RATE_ROUND_DOWN 0
- #define SCMI_CLK_RATE_ROUND_UP RT_BIT(2)
- #define SCMI_CLK_RATE_ROUND_CLOSEST RT_BIT(3)
- rt_le32_t flags;
- rt_le32_t clock_id;
- rt_le32_t rate_lsb;
- rt_le32_t rate_msb;
- };
- /**
- * struct scmi_clk_rate_set_out - Response payload for SCMI_CLOCK_RATE_SET command
- */
- struct scmi_clk_rate_set_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_clk_state_in - Message payload for SCMI_CLOCK_RATE_GET command
- */
- struct scmi_clk_rate_get_in
- {
- rt_le32_t clock_id;
- };
- /**
- * struct scmi_clk_rate_get_out - Response payload for SCMI_CLOCK_RATE_GET command
- */
- struct scmi_clk_rate_get_out
- {
- rt_le32_t status;
- rt_le32_t rate_lsb;
- rt_le32_t rate_msb;
- };
- /**
- * struct scmi_clk_state_in - Message payload for SCMI_CLOCK_CONFIG_SET command
- */
- struct scmi_clk_state_in
- {
- rt_le32_t clock_id;
- rt_le32_t attributes;
- rt_le32_t ext_config_val;
- };
- /**
- * struct scmi_clk_state_out - Response payload for SCMI_CLOCK_CONFIG_SET command
- */
- struct scmi_clk_state_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_clk_name_in - Message payload for SCMI_CLOCK_NAME_GET command
- */
- struct scmi_clk_name_in
- {
- rt_le32_t clock_id;
- };
- /**
- * struct scmi_clk_name_out - Response payload for SCMI_CLOCK_NAME_GET command
- */
- struct scmi_clk_name_out
- {
- rt_le32_t status;
- rt_le32_t flags;
- rt_uint8_t name[SCMI_MAX_STR_SIZE];
- };
- /*
- * SCMI Sensor Domain Protocol
- */
- enum scmi_sensor_message_id
- {
- SCMI_SENSOR_DESCRIPTION_GET = 0x3,
- SCMI_SENSOR_TRIP_POINT_NOTIFY = 0x4,
- SCMI_SENSOR_TRIP_POINT_CONFIG = 0x5,
- SCMI_SENSOR_READING_GET = 0x6,
- SCMI_SENSOR_AXIS_DESCRIPTION_GET = 0x7,
- SCMI_SENSOR_LIST_UPDATE_INTERVALS = 0x8,
- SCMI_SENSOR_CONFIG_GET = 0x9,
- SCMI_SENSOR_CONFIG_SET = 0xa,
- SCMI_SENSOR_CONTINUOUS_UPDATE_NOTIFY = 0xb,
- SCMI_SENSOR_NAME_GET = 0xc,
- SCMI_SENSOR_AXIS_NAME_GET = 0xd,
- };
- enum scmi_sensor_type
- {
- SCMI_SENSOR_TYPE_NONE = 0x0,
- SCMI_SENSOR_TYPE_UNSPEC = 0x1,
- SCMI_SENSOR_TYPE_TEMPERATURE_C = 0x2,
- SCMI_SENSOR_TYPE_TEMPERATURE_F = 0x3,
- SCMI_SENSOR_TYPE_TEMPERATURE_K = 0x4,
- SCMI_SENSOR_TYPE_VOLTAGE = 0x5,
- SCMI_SENSOR_TYPE_CURRENT = 0x6,
- SCMI_SENSOR_TYPE_POWER = 0x7,
- SCMI_SENSOR_TYPE_ENERGY = 0x8,
- SCMI_SENSOR_TYPE_CHARGE = 0x9,
- SCMI_SENSOR_TYPE_VOLTAMPERE = 0xa,
- SCMI_SENSOR_TYPE_NITS = 0xb,
- SCMI_SENSOR_TYPE_LUMENS = 0xc,
- SCMI_SENSOR_TYPE_LUX = 0xd,
- SCMI_SENSOR_TYPE_CANDELAS = 0xe,
- SCMI_SENSOR_TYPE_KPA = 0xf,
- SCMI_SENSOR_TYPE_PSI = 0x10,
- SCMI_SENSOR_TYPE_NEWTON = 0x11,
- SCMI_SENSOR_TYPE_CFM = 0x12,
- SCMI_SENSOR_TYPE_RPM = 0x13,
- SCMI_SENSOR_TYPE_HERTZ = 0x14,
- SCMI_SENSOR_TYPE_SECS = 0x15,
- SCMI_SENSOR_TYPE_MINS = 0x16,
- SCMI_SENSOR_TYPE_HOURS = 0x17,
- SCMI_SENSOR_TYPE_DAYS = 0x18,
- SCMI_SENSOR_TYPE_WEEKS = 0x19,
- SCMI_SENSOR_TYPE_MILS = 0x1a,
- SCMI_SENSOR_TYPE_INCHES = 0x1b,
- SCMI_SENSOR_TYPE_FEET = 0x1c,
- SCMI_SENSOR_TYPE_CUBIC_INCHES = 0x1d,
- SCMI_SENSOR_TYPE_CUBIC_FEET = 0x1e,
- SCMI_SENSOR_TYPE_METERS = 0x1f,
- SCMI_SENSOR_TYPE_CUBIC_CM = 0x20,
- SCMI_SENSOR_TYPE_CUBIC_METERS = 0x21,
- SCMI_SENSOR_TYPE_LITERS = 0x22,
- SCMI_SENSOR_TYPE_FLUID_OUNCES = 0x23,
- SCMI_SENSOR_TYPE_RADIANS = 0x24,
- SCMI_SENSOR_TYPE_STERADIANS = 0x25,
- SCMI_SENSOR_TYPE_REVOLUTIONS = 0x26,
- SCMI_SENSOR_TYPE_CYCLES = 0x27,
- SCMI_SENSOR_TYPE_GRAVITIES = 0x28,
- SCMI_SENSOR_TYPE_OUNCES = 0x29,
- SCMI_SENSOR_TYPE_POUNDS = 0x2a,
- SCMI_SENSOR_TYPE_FOOT_POUNDS = 0x2b,
- SCMI_SENSOR_TYPE_OUNCE_INCHES = 0x2c,
- SCMI_SENSOR_TYPE_GAUSS = 0x2d,
- SCMI_SENSOR_TYPE_GILBERTS = 0x2e,
- SCMI_SENSOR_TYPE_HENRIES = 0x2f,
- SCMI_SENSOR_TYPE_FARADS = 0x30,
- SCMI_SENSOR_TYPE_OHMS = 0x31,
- SCMI_SENSOR_TYPE_SIEMENS = 0x32,
- SCMI_SENSOR_TYPE_MOLES = 0x33,
- SCMI_SENSOR_TYPE_BECQUERELS = 0x34,
- SCMI_SENSOR_TYPE_PPM = 0x35,
- SCMI_SENSOR_TYPE_DECIBELS = 0x36,
- SCMI_SENSOR_TYPE_DBA = 0x37,
- SCMI_SENSOR_TYPE_DBC = 0x38,
- SCMI_SENSOR_TYPE_GRAYS = 0x39,
- SCMI_SENSOR_TYPE_SIEVERTS = 0x3a,
- SCMI_SENSOR_TYPE_COLOR_TEMP_K = 0x3b,
- SCMI_SENSOR_TYPE_BITS = 0x3c,
- SCMI_SENSOR_TYPE_BYTES = 0x3d,
- SCMI_SENSOR_TYPE_WORDS = 0x3e,
- SCMI_SENSOR_TYPE_DWORDS = 0x3f,
- SCMI_SENSOR_TYPE_QWORDS = 0x40,
- SCMI_SENSOR_TYPE_PERCENTAGE = 0x41,
- SCMI_SENSOR_TYPE_PASCALS = 0x42,
- SCMI_SENSOR_TYPE_COUNTS = 0x43,
- SCMI_SENSOR_TYPE_GRAMS = 0x44,
- SCMI_SENSOR_TYPE_NEWTON_METERS = 0x45,
- SCMI_SENSOR_TYPE_HITS = 0x46,
- SCMI_SENSOR_TYPE_MISSES = 0x47,
- SCMI_SENSOR_TYPE_RETRIES = 0x48,
- SCMI_SENSOR_TYPE_OVERRUNS = 0x49,
- SCMI_SENSOR_TYPE_UNDERRUNS = 0x4a,
- SCMI_SENSOR_TYPE_COLLISIONS = 0x4b,
- SCMI_SENSOR_TYPE_PACKETS = 0x4c,
- SCMI_SENSOR_TYPE_MESSAGES = 0x4d,
- SCMI_SENSOR_TYPE_CHARS = 0x4e,
- SCMI_SENSOR_TYPE_ERRORS = 0x4f,
- SCMI_SENSOR_TYPE_CORRECTED_ERRS = 0x50,
- SCMI_SENSOR_TYPE_UNCORRECTABLE_ERRS = 0x51,
- SCMI_SENSOR_TYPE_SQ_MILS = 0x52,
- SCMI_SENSOR_TYPE_SQ_INCHES = 0x53,
- SCMI_SENSOR_TYPE_SQ_FEET = 0x54,
- SCMI_SENSOR_TYPE_SQ_CM = 0x55,
- SCMI_SENSOR_TYPE_SQ_METERS = 0x56,
- SCMI_SENSOR_TYPE_RADIANS_SEC = 0x57,
- SCMI_SENSOR_TYPE_BPM = 0x58,
- SCMI_SENSOR_TYPE_METERS_SEC_SQUARED = 0x59,
- SCMI_SENSOR_TYPE_METERS_SEC = 0x5a,
- SCMI_SENSOR_TYPE_CUBIC_METERS_SEC = 0x5b,
- SCMI_SENSOR_TYPE_MM_MERCURY = 0x5c,
- SCMI_SENSOR_TYPE_RADIANS_SEC_SQUARED = 0x5d,
- SCMI_SENSOR_TYPE_OEM_UNIT = 0xff
- };
- /**
- * struct scmi_sensor_attributes - Response payload for SCMI_COM_MSG_ATTRIBUTES command
- */
- struct scmi_sensor_attributes
- {
- rt_le16_t num_sensors;
- rt_uint8_t max_requests;
- rt_uint8_t reserved;
- rt_le32_t reg_addr_low;
- rt_le32_t reg_addr_high;
- rt_le32_t reg_size;
- };
- /**
- * struct scmi_sensor_description_get_in - Payload for SCMI_SENSOR_DESCRIPTION_GET command
- */
- struct scmi_sensor_description_get_in
- {
- rt_le32_t desc_index;
- };
- /**
- * struct scmi_sensor_description_get_out - Response payload for SCMI_SENSOR_DESCRIPTION_GET command
- */
- struct scmi_sensor_description_get_out
- {
- rt_le32_t status;
- #define SCMI_SENSOR_DESC_RETURNED_NR(x) RT_FIELD_GET(RT_GENMASK(11, 0), (x))
- #define SCMI_SENSOR_DESC_REMAINING_NR(x) RT_FIELD_GET(RT_GENMASK(31, 16), (x))
- rt_le32_t num_sensor_flags;
- struct
- {
- rt_le32_t id;
- #define SCMI_SENSOR_ASYNC_READ(x) RT_FIELD_GET(RT_BIT(31), (x))
- #define SCMI_SENSOR_EXT_NAMES(x) RT_FIELD_GET(RT_BIT(29), (x))
- #define SCMI_SENSOR_TRIP_POINTS_NR(x) RT_FIELD_GET(RT_GENMASK(7, 0), (x))
- rt_le32_t attributes_low;
- #define SCMI_SENSOR_SCALE(x) RT_FIELD_GET(RT_GENMASK(15, 11), (x))
- #define SCMI_SENSOR_SCALE_SIGN RT_BIT(4)
- #define SCMI_SENSOR_SCALE_EXTEND RT_GENMASK(31, 5)
- #define SCMI_SENSOR_TYPE(x) RT_FIELD_GET(RT_GENMASK(7, 0), (x))
- rt_le32_t attributes_high;
- rt_uint8_t name[SCMI_SHORT_NAME_MAX_SIZE];
- rt_le32_t power;
- rt_le32_t resolution;
- rt_le32_t min_range_low;
- rt_le32_t min_range_high;
- rt_le32_t max_range_low;
- rt_le32_t max_range_high;
- } desc[];
- };
- /**
- * struct scmi_scmi_sensor_axis_description_get_in - Payload for SCMI_SENSOR_AXIS_DESCRIPTION_GET command
- */
- struct scmi_scmi_sensor_axis_description_get_in
- {
- rt_le32_t id;
- rt_le32_t axis_desc_index;
- };
- /**
- * struct scmi_scmi_sensor_axis_description_get_out - Response payload for SCMI_SENSOR_AXIS_DESCRIPTION_GET command
- */
- struct scmi_scmi_sensor_axis_description_get_out
- {
- rt_le32_t status;
- #define SCMI_SENSOR_AXIS_RETURNED_NR(x) RT_FIELD_GET(RT_GENMASK(5, 0), (x))
- #define SCMI_SENSOR_AXIS_REMAINING_NR(x) RT_FIELD_GET(RT_GENMASK(31, 26), (x))
- rt_le32_t num_axis_flags;
- struct
- {
- rt_le32_t axis_id;
- #define SCMI_SENSOR_AXIS_EXT_AXIS_NAME(x) RT_FIELD_GET(RT_BIT(9), (x))
- rt_le32_t axis_attributes_low;
- #define SCMI_SENSOR_AXIS_SCALE(x) RT_FIELD_GET(RT_GENMASK(15, 11), (x))
- #define SCMI_SENSOR_AXIS_TYPE(x) RT_FIELD_GET(RT_GENMASK(7, 0), (x))
- rt_le32_t axis_attributes_high;
- rt_uint8_t name[SCMI_SHORT_NAME_MAX_SIZE];
- rt_le32_t axis_resolution;
- rt_le32_t axis_min_range_low;
- rt_le32_t axis_min_range_high;
- rt_le32_t axis_max_range_low;
- rt_le32_t axis_max_range_high;
- } desc[];
- };
- /**
- * struct scmi_sensor_list_update_intervals_in - Payload for SCMI_SENSOR_LIST_UPDATE_INTERVALS command
- */
- struct scmi_sensor_list_update_intervals_in
- {
- rt_le32_t id;
- rt_le32_t index;
- };
- /**
- * struct scmi_sensor_list_update_intervals_out - Response payload for SCMI_SENSOR_LIST_UPDATE_INTERVALS command
- */
- struct scmi_sensor_list_update_intervals_out
- {
- rt_le32_t status;
- rt_le32_t flags;
- rt_le32_t intervals[];
- };
- /**
- * struct scmi_sensor_trip_point_notify_in - Payload for SCMI_SENSOR_TRIP_POINT_NOTIFY command
- */
- struct scmi_sensor_trip_point_notify_in
- {
- rt_le32_t id;
- #define SCMI_SENSOR_NOTIFY_ALL RT_BIT(0)
- rt_le32_t event_control;
- };
- /**
- * struct scmi_sensor_trip_point_notify_out - Response payload for SCMI_SENSOR_TRIP_POINT_NOTIFY command
- */
- struct scmi_sensor_trip_point_notify_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_sensor_trip_point_config_in - Payload for SCMI_SENSOR_TRIP_POINT_CONFIG command
- */
- struct scmi_sensor_trip_point_config_in
- {
- rt_le32_t id;
- #define SCMI_SENSOR_TRIP_POINT_EVENT_MASK 0x3
- #define SCMI_SENSOR_TRIP_POINT_DISABLED 0x0
- #define SCMI_SENSOR_TRIP_POINT_POSITIVE 0x1
- #define SCMI_SENSOR_TRIP_POINT_NEGATIVE 0x2
- #define SCMI_SENSOR_TRIP_POINT_BOTH 0x3
- #define SCMI_SENSOR_TRIP_POINT_ID(x) (((x) & 0xff) << 4)
- rt_le32_t trip_point_ev_ctrl;
- rt_le32_t trip_point_val_low;
- rt_le32_t trip_point_val_high;
- };
- /**
- * struct scmi_sensor_trip_point_config_out - Response payload for SCMI_SENSOR_TRIP_POINT_CONFIG command
- */
- struct scmi_sensor_trip_point_config_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_sensor_config_get_in - Payload for SCMI_SENSOR_CONFIG_GET command
- */
- struct scmi_sensor_config_get_in
- {
- rt_le32_t id;
- };
- /**
- * struct scmi_sensor_config_get_out - Response payload for SCMI_SENSOR_CONFIG_GET command
- */
- struct scmi_sensor_config_get_out
- {
- rt_le32_t status;
- #define SCMI_SENSOR_INTERVALS_SEC(x) RT_FIELD_GET(RT_GENMASK(31, 16), (x))
- #define SCMI_SENSOR_INTERVALS_EXP(x) RT_FIELD_GET(RT_GENMASK(15, 11), (x)) /* SEC x (10 ^ EXP) */
- #define SCMI_SENSOR_TEMP_RP(x) RT_FIELD_GET(RT_BIT(1), (x))
- #define SCMI_SENSOR_STATUS_EN(x) RT_FIELD_GET(RT_BIT(0), (x))
- rt_le32_t config;
- };
- /**
- * struct scmi_sensor_config_set_in - Payload for SCMI_SENSOR_CONFIG_SET command
- */
- struct scmi_sensor_config_set_in
- {
- rt_le32_t id;
- rt_le32_t config;
- };
- /**
- * struct scmi_sensor_config_set_out - Response payload for SCMI_SENSOR_CONFIG_SET command
- */
- struct scmi_sensor_config_set_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_sensor_reading_in - Payload for SCMI_SENSOR_READING_GET command
- */
- struct scmi_sensor_reading_in
- {
- rt_le32_t id;
- #define SCMI_SENSOR_FLAG_ASYNC RT_BIT(0)
- rt_le32_t flags;
- };
- /**
- * struct scmi_sensor_reading_out - Response payload for SCMI_SENSOR_READING_GET command
- */
- struct scmi_sensor_reading_out
- {
- rt_le32_t status;
- struct
- {
- rt_le32_t value_low;
- rt_le32_t value_high;
- rt_le32_t timestamp_low;
- rt_le32_t timestamp_high;
- } readings[];
- };
- /**
- * struct scmi_sensor_continuous_update_notify_in - Payload for SCMI_SENSOR_CONTINUOUS_UPDATE_NOTIFY command
- */
- struct scmi_sensor_continuous_update_notify_in
- {
- rt_le32_t id;
- #define SCMI_SENSOR_FLAG_NOTIFY_ENABLE RT_BIT(0)
- rt_le32_t notify_enable;
- };
- /**
- * struct scmi_sensor_continuous_update_notify_out - Response payload for SCMI_SENSOR_CONTINUOUS_UPDATE_NOTIFY command
- */
- struct scmi_sensor_continuous_update_notify_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_sensor_name_in - Payload for SCMI_SENSOR_NAME_GET command
- */
- struct scmi_sensor_name_in
- {
- rt_le32_t id;
- };
- /**
- * struct scmi_sensor_name_out - Response payload for SCMI_SENSOR_NAME_GET command
- */
- struct scmi_sensor_name_out
- {
- rt_le32_t status;
- rt_le32_t flags;
- rt_uint8_t name[SCMI_MAX_STR_SIZE];
- };
- /**
- * struct scmi_sensor_axis_name_in - Payload for SCMI_SENSOR_AXIS_NAME_GET command
- */
- struct scmi_sensor_axis_name_in
- {
- rt_le32_t id;
- rt_le32_t axis_id;
- };
- /**
- * struct scmi_sensor_axis_name_out - Response payload for SCMI_SENSOR_AXIS_NAME_GET command
- */
- struct scmi_sensor_axis_name_out
- {
- rt_le32_t status;
- rt_le32_t flags;
- struct
- {
- rt_le32_t axis_id;
- rt_uint8_t name[SCMI_MAX_STR_SIZE];
- } desc[];
- };
- /*
- * SCMI Reset Domain Protocol
- */
- enum scmi_reset_message_id
- {
- SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
- SCMI_RESET_RESET = 0x4,
- };
- #define SCMI_RESET_ATTRIBUTES_FLAG_ASYNC RT_BIT(31)
- #define SCMI_RESET_ATTRIBUTES_FLAG_NOTIF RT_BIT(30)
- /**
- * struct scmi_reset_attr_in - Payload for SCMI_RESET_DOMAIN_ATTRIBUTES message
- */
- struct scmi_reset_attr_in
- {
- rt_le32_t domain_id;
- };
- /**
- * struct scmi_reset_attr_out - Payload for SCMI_RESET_DOMAIN_ATTRIBUTES response
- */
- struct scmi_reset_attr_out
- {
- rt_le32_t status;
- rt_le32_t attributes;
- rt_le32_t latency;
- rt_uint8_t name[SCMI_SHORT_NAME_MAX_SIZE];
- };
- /**
- * struct scmi_reset_in - Message payload for SCMI_RESET_RESET command
- */
- struct scmi_reset_in
- {
- rt_le32_t domain_id;
- #define SCMI_RESET_FLAG_RESET RT_BIT(0)
- #define SCMI_RESET_FLAG_ASSERT RT_BIT(1)
- #define SCMI_RESET_FLAG_ASYNC RT_BIT(2)
- rt_le32_t flags;
- #define SCMI_ARCH_COLD_RESET 0
- rt_le32_t reset_state;
- };
- /**
- * struct scmi_reset_out - Response payload for SCMI_RESET_RESET command
- */
- struct scmi_reset_out
- {
- rt_le32_t status;
- };
- /*
- * SCMI Voltage Domain Protocol
- */
- enum scmi_voltage_domain_message_id
- {
- SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
- SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
- SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
- SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
- SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
- };
- #define SCMI_VOLTAGE_CONFIG_MASK RT_GENMASK(3, 0)
- #define SCMI_VOLTAGE_CONFIG_OFF 0
- #define SCMI_VOLTAGE_CONFIG_ON 0x7
- /**
- * struct scmi_voltage_attributes - Response payload for SCMI_COM_MSG_ATTRIBUTES command
- */
- struct scmi_voltage_attributes
- {
- rt_le32_t status;
- rt_le16_t num_domains;
- rt_le16_t reserved;
- };
- /**
- * struct scmi_voltage_attr_in - Payload for SCMI_VOLTAGE_DOMAIN_ATTRIBUTES message
- */
- struct scmi_voltage_attr_in
- {
- rt_le32_t domain_id;
- };
- /**
- * struct scmi_voltage_attr_out - Payload for SCMI_VOLTAGE_DOMAIN_ATTRIBUTES response
- */
- struct scmi_voltage_attr_out
- {
- rt_le32_t status;
- rt_le32_t attributes;
- char name[SCMI_SHORT_NAME_MAX_SIZE];
- };
- /**
- * struct scmi_voltage_config_set_in - Message payload for SCMI_VOLTAGE_DOMAIN_CONFIG_SET cmd
- */
- struct scmi_voltage_config_set_in
- {
- rt_le32_t domain_id;
- rt_le32_t config;
- };
- /**
- * struct scmi_voltage_config_set_out - Response for SCMI_VOLTAGE_DOMAIN_CONFIG_SET command
- */
- struct scmi_voltage_config_set_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_voltage_config_get_in - Message payload for SCMI_VOLTAGE_CONFIG_GET cmd
- */
- struct scmi_voltage_config_get_in
- {
- rt_le32_t domain_id;
- };
- /**
- * struct scmi_voltage_config_get_out - Response for SCMI_VOLTAGE_CONFIG_GET command
- */
- struct scmi_voltage_config_get_out
- {
- rt_le32_t status;
- rt_le32_t config;
- };
- /**
- * struct scmi_voltage_level_set_in - Message payload for SCMI_VOLTAGE_DOMAIN_LEVEL_SET cmd
- */
- struct scmi_voltage_level_set_in
- {
- rt_le32_t domain_id;
- rt_le32_t flags;
- rt_le32_t voltage_level;
- };
- /**
- * struct scmi_voltage_level_set_out - Response for SCMI_VOLTAGE_DOMAIN_LEVEL_SET command
- */
- struct scmi_voltage_level_set_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_voltage_level_get_in - Message payload for SCMI_VOLTAGE_DOMAIN_LEVEL_GET cmd
- */
- struct scmi_voltage_level_get_in
- {
- rt_le32_t domain_id;
- };
- /**
- * struct scmi_voltage_level_get_out - Response for SCMI_VOLTAGE_DOMAIN_LEVEL_GET command
- */
- struct scmi_voltage_level_get_out
- {
- rt_le32_t status;
- rt_le32_t voltage_level;
- };
- /*
- * SCMI Pinctrl Protocol
- */
- enum scmi_pinctrl_message_id
- {
- SCMI_PINCTRL_ATTRIBUTES = 0x3,
- SCMI_PINCTRL_LIST_ASSOCIATIONS = 0x4,
- SCMI_PINCTRL_SETTINGS_GET = 0x5,
- SCMI_PINCTRL_SETTINGS_CONFIGURE = 0x6,
- SCMI_PINCTRL_REQUEST = 0x7,
- SCMI_PINCTRL_RELEASE = 0x8,
- SCMI_PINCTRL_NAME_GET = 0x9,
- SCMI_PINCTRL_SET_PERMISSIONS = 0xa,
- };
- enum scmi_pinctrl_selector_type
- {
- SCMI_PINCTRL_TYPE_PIN = 0,
- SCMI_PINCTRL_TYPE_GROUP,
- SCMI_PINCTRL_TYPE_FUNCTION,
- };
- enum scmi_pinctrl_conf_type
- {
- SCMI_PINCTRL_DEFAULT = 0,
- SCMI_PINCTRL_BIAS_BUS_HOLD = 1,
- SCMI_PINCTRL_BIAS_DISABLE = 2,
- SCMI_PINCTRL_BIAS_HIGH_IMPEDANCE = 3,
- SCMI_PINCTRL_BIAS_PULL_UP = 4,
- SCMI_PINCTRL_BIAS_PULL_DEFAULT = 5,
- SCMI_PINCTRL_BIAS_PULL_DOWN = 6,
- SCMI_PINCTRL_DRIVE_OPEN_DRAIN = 7,
- SCMI_PINCTRL_DRIVE_OPEN_SOURCE = 8,
- SCMI_PINCTRL_DRIVE_PUSH_PULL = 9,
- SCMI_PINCTRL_DRIVE_STRENGTH = 10,
- SCMI_PINCTRL_INPUT_DEBOUNCE = 11,
- SCMI_PINCTRL_INPUT_MODE = 12,
- SCMI_PINCTRL_PULL_MODE = 13,
- SCMI_PINCTRL_INPUT_VALUE = 14,
- SCMI_PINCTRL_INPUT_SCHMITT = 15,
- SCMI_PINCTRL_LOW_POWER_MODE = 16,
- SCMI_PINCTRL_OUTPUT_MODE = 17,
- SCMI_PINCTRL_OUTPUT_VALUE = 18,
- SCMI_PINCTRL_POWER_SOURCE = 19,
- SCMI_PINCTRL_SLEW_RATE = 20,
- SCMI_PINCTRL_OEM_START = 192,
- SCMI_PINCTRL_OEM_END = 255,
- };
- /**
- * struct scmi_pinctrl_protocol_attributes - Response payload for SCMI_COM_MSG_ATTRIBUTES command
- */
- struct scmi_pinctrl_protocol_attributes
- {
- rt_le32_t status;
- #define SCMI_PINCTRL_GROUPS_NR(x) RT_FIELD_GET(RT_GENMASK(31, 16), (x))
- #define SCMI_PINCTRL_PINS_NR(x) RT_FIELD_GET(RT_GENMASK(15, 0), (x))
- #define SCMI_PINCTRL_FUNCTIONS_NR(x) RT_FIELD_GET(RT_GENMASK(15, 0), (x))
- rt_le32_t attributes_low;
- rt_le32_t attributes_high;
- };
- /**
- * struct scmi_pinctrl_attributes_in - Message payload for SCMI_PINCTRL_ATTRIBUTES command
- */
- struct scmi_pinctrl_attributes_in
- {
- rt_le32_t identifier;
- rt_le32_t flags;
- };
- /**
- * struct scmi_pinctrl_attributes_out - Response payload for SCMI_PINCTRL_ATTRIBUTES command
- */
- struct scmi_pinctrl_attributes_out
- {
- #define SCMI_PINCTRL_EXT_NAME_FLAG(x) RT_FIELD_GET(RT_BIT(31), (x))
- #define SCMI_PINCTRL_NUM_ELEMS(x) RT_FIELD_GET(RT_GENMASK(15, 0), (x))
- rt_le32_t status;
- rt_le32_t attributes;
- rt_uint8_t name[SCMI_SHORT_NAME_MAX_SIZE];
- };
- /**
- * struct scmi_pinctrl_list_assoc_in - Message payload for SCMI_PINCTRL_LIST_ASSOCIATIONS command
- */
- struct scmi_pinctrl_list_assoc_in
- {
- rt_le32_t identifier;
- rt_le32_t flags;
- rt_le32_t index;
- };
- /**
- * struct scmi_pinctrl_list_assoc_out - Response payload for SCMI_PINCTRL_LIST_ASSOCIATIONS command
- */
- struct scmi_pinctrl_list_assoc_out
- {
- #define SCMI_PINCTRL_REMAINING(x) RT_FIELD_GET(RT_GENMASK(31, 16), (x))
- #define SCMI_PINCTRL_RETURNED(x) RT_FIELD_GET(RT_GENMASK(11, 0), (x))
- rt_le32_t status;
- rt_le32_t flags;
- rt_le16_t array[];
- };
- /**
- * struct scmi_pinctrl_settings_get_in - Message payload for SCMI_PINCTRL_SETTINGS_GET command
- */
- struct scmi_pinctrl_settings_get_in
- {
- #define SCMI_PINCTRL_CONFIG_FLAG_MASK RT_GENMASK(19, 18)
- #define SCMI_PINCTRL_SELECTOR_MASK RT_GENMASK(17, 16)
- #define SCMI_PINCTRL_SKIP_CONFIGS_MASK RT_GENMASK(15, 8)
- #define SCMI_PINCTRL_CONFIG_TYPE_MASK RT_GENMASK(7, 0)
- rt_le32_t identifier;
- rt_le32_t attributes;
- };
- /**
- * struct scmi_pinctrl_settings_get_out - Response payload for SCMI_PINCTRL_SETTINGS_GET command
- */
- struct scmi_pinctrl_settings_get_out
- {
- rt_le32_t status;
- rt_le32_t function_selected;
- rt_le32_t num_configs;
- rt_le32_t configs[];
- };
- /**
- * struct scmi_pinctrl_settings_conf_in - Message payload for SCMI_PINCTRL_SETTINGS_CONFIGURE command
- */
- struct scmi_pinctrl_settings_conf_in
- {
- rt_le32_t identifier;
- rt_le32_t function_id;
- rt_le32_t attributes;
- rt_le32_t configs[];
- };
- /**
- * struct scmi_pinctrl_settings_conf_out - Response payload for SCMI_PINCTRL_SETTINGS_CONFIGURE command
- */
- struct scmi_pinctrl_settings_conf_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_pinctrl_request_in - Message payload for SCMI_PINCTRL_REQUEST command
- */
- struct scmi_pinctrl_request_in
- {
- rt_le32_t identifier;
- rt_le32_t flags;
- };
- /**
- * struct scmi_pinctrl_request_out - Response payload for SCMI_PINCTRL_REQUEST command
- */
- struct scmi_pinctrl_request_out
- {
- rt_le32_t status;
- };
- /**
- * struct scmi_pinctrl_request_in - Message payload for SCMI_PINCTRL_NAME_GET command
- */
- struct scmi_pinctrl_name_get_in
- {
- rt_le32_t identifier;
- rt_le32_t flags;
- };
- /**
- * struct scmi_pinctrl_name_get_out - Response payload for SCMI_PINCTRL_NAME_GET command
- */
- struct scmi_pinctrl_name_get_out
- {
- rt_le32_t status;
- rt_le32_t flags;
- rt_uint8_t name[SCMI_MAX_STR_SIZE];
- };
- struct scmi_agent;
- struct rt_scmi_device_id
- {
- rt_uint8_t protocol_id;
- const char *name;
- };
- struct rt_scmi_device
- {
- struct rt_device parent;
- const char *name;
- rt_uint8_t protocol_id;
- struct scmi_agent *agent;
- };
- struct rt_scmi_driver
- {
- struct rt_driver parent;
- const char *name;
- const struct rt_scmi_device_id *ids;
- rt_err_t (*probe)(struct rt_scmi_device *sdev);
- rt_err_t (*remove)(struct rt_scmi_device *sdev);
- rt_err_t (*shutdown)(struct rt_scmi_device *sdev);
- };
- rt_err_t rt_scmi_driver_register(struct rt_scmi_driver *driver);
- rt_err_t rt_scmi_device_register(struct rt_scmi_device *device);
- #define RT_SCMI_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, scmi, BUILIN)
- rt_err_t rt_scmi_process_msg(struct rt_scmi_device *sdev, struct rt_scmi_msg *msg);
- const char *rt_scmi_strerror(rt_base_t err);
- #endif /* __SCMI_H__ */
|