Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
util.h File Reference

ARM SCMI utility header. More...

Go to the source code of this file.

Macros

#define SCMI_PROTOCOL_NAME(proto)
 Build protocol name from its ID.
 
#define DT_SCMI_TRANSPORT_CHANNELS_DECLARE(node_id)
 
#define DT_SCMI_PROTOCOL_DATA_DEFINE(node_id, proto, pdata)
 
#define DT_INST_SCMI_TRANSPORT_DEFINE(inst, pm, data, config, level, prio, api)
 Define an SCMI transport driver.
 
#define DT_SCMI_PROTOCOL_DEFINE(node_id, init_fn, pm, data, config, level, prio, api)
 Define an SCMI protocol.
 
#define DT_INST_SCMI_PROTOCOL_DEFINE(inst, init_fn, pm, data, config, level, prio, api)
 Just like DT_SCMI_PROTOCOL_DEFINE(), but uses an instance of a DT_DRV_COMPAT compatible instead of a node identifier.
 
#define DT_SCMI_PROTOCOL_DEFINE_NODEV(node_id, data)
 Define an SCMI protocol with no device.
 
#define SCMI_FIELD_MAKE(x, mask, shift)
 Create an SCMI message field.
 
#define SCMI_PROTOCOL_BASE   16
 SCMI protocol IDs.
 
#define SCMI_PROTOCOL_POWER_DOMAIN   17
 
#define SCMI_PROTOCOL_SYSTEM   18
 
#define SCMI_PROTOCOL_PERF   19
 
#define SCMI_PROTOCOL_CLOCK   20
 
#define SCMI_PROTOCOL_SENSOR   21
 
#define SCMI_PROTOCOL_RESET_DOMAIN   22
 
#define SCMI_PROTOCOL_VOLTAGE_DOMAIN   23
 
#define SCMI_PROTOCOL_PCAP_MONITOR   24
 
#define SCMI_PROTOCOL_PINCTRL   25
 

Detailed Description

ARM SCMI utility header.

Contains various utility macros and macros used for protocol and transport "registration".

Macro Definition Documentation

◆ DT_INST_SCMI_PROTOCOL_DEFINE

#define DT_INST_SCMI_PROTOCOL_DEFINE ( inst,
init_fn,
pm,
data,
config,
level,
prio,
api )
Value:
DT_SCMI_PROTOCOL_DEFINE(DT_INST(inst, DT_DRV_COMPAT), init_fn, pm, \
data, config, level, prio, api)
#define DT_SCMI_PROTOCOL_DEFINE(node_id, init_fn, pm, data, config, level, prio, api)
Define an SCMI protocol.
Definition util.h:211
#define DT_INST(inst, compat)
Get a node identifier for an instance of a compatible.
Definition devicetree.h:332

Just like DT_SCMI_PROTOCOL_DEFINE(), but uses an instance of a DT_DRV_COMPAT compatible instead of a node identifier.

Parameters
instinstance number
init_fnpointer to protocol's initialization function
apipointer to protocol's subsystem API
pmpointer to the protocol's power management resources
datapointer to protocol's private data
configpointer to protocol's private constant data
levelprotocol initialization level
prioprotocol's priority within its initialization level

◆ DT_INST_SCMI_TRANSPORT_DEFINE

#define DT_INST_SCMI_TRANSPORT_DEFINE ( inst,
pm,
data,
config,
level,
prio,
api )
Value:
pm, data, config, level, prio, api)
#define DEVICE_DT_INST_DEFINE(inst,...)
Like DEVICE_DT_DEFINE(), but uses an instance of a DT_DRV_COMPAT compatible instead of a node identif...
Definition device.h:221
int scmi_core_transport_init(const struct device *transport)
Perfrom SCMI core initialization.

Define an SCMI transport driver.

This is merely a wrapper over DEVICE_DT_INST_DEFINE(), but is required since transport layer drivers are not allowed to place their own init() function in the init section. Instead, transport layer drivers place the scmi_core_transport_init() function in the init section, which, in turn, will call the transport layer driver init() function. This is required because the SCMI core needs to perform channel binding and setup during the transport layer driver's initialization.

◆ DT_SCMI_PROTOCOL_DATA_DEFINE

#define DT_SCMI_PROTOCOL_DATA_DEFINE ( node_id,
proto,
pdata )
Value:
{ \
.id = proto, \
.data = pdata, \
}
#define SCMI_PROTOCOL_NAME(proto)
Build protocol name from its ID.
Definition util.h:29
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition iterable_sections.h:216
SCMI protocol structure.
Definition protocol.h:74

◆ DT_SCMI_PROTOCOL_DEFINE

#define DT_SCMI_PROTOCOL_DEFINE ( node_id,
init_fn,
pm,
data,
config,
level,
prio,
api )
Value:
DT_SCMI_PROTOCOL_DATA_DEFINE(node_id, DT_REG_ADDR_RAW(node_id), data); \
DEVICE_DT_DEFINE(node_id, init_fn, pm, \
config, level, prio, api)
#define DT_SCMI_TRANSPORT_CHANNELS_DECLARE(node_id)
Definition util.h:159
#define DT_REG_ADDR_RAW(node_id)
Get a node's (only) register block raw address.
Definition devicetree.h:2400

Define an SCMI protocol.

This macro performs three important functions: 1) It defines a struct scmi_protocol, which is needed by all protocol drivers to work with the SCMI API.

2) It declares the static channels bound to the protocol. This is only applicable if the transport layer driver supports static channels.

3) It creates a struct device a sets the data field to the newly defined struct scmi_protocol. This is needed because the protocol driver needs to work with the SCMI API and the subsystem API.

Parameters
node_idprotocol node identifier
init_fnpointer to protocol's initialization function
apipointer to protocol's subsystem API
pmpointer to the protocol's power management resources
datapointer to protocol's private data
configpointer to protocol's private constant data
levelprotocol initialization level
prioprotocol's priority within its initialization level

◆ DT_SCMI_PROTOCOL_DEFINE_NODEV

#define DT_SCMI_PROTOCOL_DEFINE_NODEV ( node_id,
data )
Value:
DT_SCMI_PROTOCOL_DATA_DEFINE(node_id, DT_REG_ADDR_RAW(node_id), data)

Define an SCMI protocol with no device.

Variant of DT_SCMI_PROTOCOL_DEFINE(), but no struct device is created and no initialization function is called during system initialization. This is useful for protocols that are not really part of a subsystem with an API (e.g: pinctrl).

Parameters
node_idprotocol node identifier
dataprotocol private data

◆ DT_SCMI_TRANSPORT_CHANNELS_DECLARE

#define DT_SCMI_TRANSPORT_CHANNELS_DECLARE ( node_id)

◆ SCMI_FIELD_MAKE

#define SCMI_FIELD_MAKE ( x,
mask,
shift )
Value:
(((uint32_t)(x) & (mask)) << (shift))
__UINT32_TYPE__ uint32_t
Definition stdint.h:90

Create an SCMI message field.

Data might not necessarily be encoded in the first x bits of an SCMI message parameter/return value. This comes in handy when building said parameters/ return values.

Parameters
xvalue to encode
maskvalue to perform bitwise-and with x
shiftvalue to left-shift masked x

◆ SCMI_PROTOCOL_BASE

#define SCMI_PROTOCOL_BASE   16

SCMI protocol IDs.

Each SCMI protocol is identified by an ID. Each of these IDs needs to be in decimal since they might be used to build protocol and static channel names.

◆ SCMI_PROTOCOL_CLOCK

#define SCMI_PROTOCOL_CLOCK   20

◆ SCMI_PROTOCOL_NAME

#define SCMI_PROTOCOL_NAME ( proto)
Value:
CONCAT(scmi_protocol_, proto)
#define CONCAT(...)
Concatenate input arguments.
Definition util.h:311

Build protocol name from its ID.

Given a protocol ID, this macro builds the protocol name. This is done by concatenating the scmi_protocol_ construct with the given protocol ID.

Parameters
protoprotocol ID in decimal format
Returns
protocol name

◆ SCMI_PROTOCOL_PCAP_MONITOR

#define SCMI_PROTOCOL_PCAP_MONITOR   24

◆ SCMI_PROTOCOL_PERF

#define SCMI_PROTOCOL_PERF   19

◆ SCMI_PROTOCOL_PINCTRL

#define SCMI_PROTOCOL_PINCTRL   25

◆ SCMI_PROTOCOL_POWER_DOMAIN

#define SCMI_PROTOCOL_POWER_DOMAIN   17

◆ SCMI_PROTOCOL_RESET_DOMAIN

#define SCMI_PROTOCOL_RESET_DOMAIN   22

◆ SCMI_PROTOCOL_SENSOR

#define SCMI_PROTOCOL_SENSOR   21

◆ SCMI_PROTOCOL_SYSTEM

#define SCMI_PROTOCOL_SYSTEM   18

◆ SCMI_PROTOCOL_VOLTAGE_DOMAIN

#define SCMI_PROTOCOL_VOLTAGE_DOMAIN   23