mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00

- Allow the Energy Model to be updated dynamically (Lukasz Luba). - Add support for LZ4 compression algorithm to the hibernation image creation and loading code (Nikhil V). - Fix and clean up system suspend statistics collection (Rafael Wysocki). - Simplify device suspend and resume handling in the power management core code (Rafael Wysocki). - Fix PCI hibernation support description (Yiwei Lin). - Make hibernation take set_memory_ro() return values into account as appropriate (Christophe Leroy). - Set mem_sleep_current during kernel command line setup to avoid an ordering issue with handling it (Maulik Shah). - Fix wake IRQs handling when pm_runtime_force_suspend() is used as a driver's system suspend callback (Qingliang Li). - Simplify pm_runtime_get_if_active() usage and add a replacement for pm_runtime_put_autosuspend() (Sakari Ailus). - Add a tracepoint for runtime_status changes tracking (Vilas Bhat). - Fix section title markdown in the runtime PM documentation (Yiwei Lin). - Enable preferred core support in the amd-pstate cpufreq driver (Meng Li). - Fix min_perf assignment in amd_pstate_adjust_perf() and make the min/max limit perf values in amd-pstate always stay within the (highest perf, lowest perf) range (Tor Vic, Meng Li). - Allow intel_pstate to assign model-specific values to strings used in the EPP sysfs interface and make it do so on Meteor Lake (Srinivas Pandruvada). - Drop long-unused cpudata::prev_cummulative_iowait from the intel_pstate cpufreq driver (Jiri Slaby). - Prevent scaling_cur_freq from exceeding scaling_max_freq when the latter is an inefficient frequency (Shivnandan Kumar). - Change default transition delay in cpufreq to 2ms (Qais Yousef). - Remove references to 10ms minimum sampling rate from comments in the cpufreq code (Pierre Gondois). - Honour transition_latency over transition_delay_us in cpufreq (Qais Yousef). - Stop unregistering cpufreq cooling on CPU hot-remove (Viresh Kumar). - General enhancements / cleanups to ARM cpufreq drivers (tianyu2, Nícolas F. R. A. Prado, Erick Archer, Arnd Bergmann, Anastasia Belova). - Update cpufreq-dt-platdev to block/approve devices (Richard Acayan). - Make the SCMI cpufreq driver get a transition delay value from firmware (Pierre Gondois). - Prevent the haltpoll cpuidle governor from shrinking guest poll_limit_ns below grow_start (Parshuram Sangle). - Avoid potential overflow in integer multiplication when computing cpuidle state parameters (C Cheng). - Adjust MWAIT hint target C-state computation in the ACPI cpuidle driver and in intel_idle to return a correct value for C0 (He Rongguang). - Address multiple issues in the TPMI RAPL driver and add support for new platforms (Lunar Lake-M, Arrow Lake) to Intel RAPL (Zhang Rui). - Fix freq_qos_add_request() return value check in dtpm_cpu (Daniel Lezcano). - Fix kernel-doc for dtpm_create_hierarchy() (Yang Li). - Fix file leak in get_pkg_num() in x86_energy_perf_policy (Samasth Norway Ananda). - Fix cpupower-frequency-info.1 man page typo (Jan Kratochvil). - Fix a couple of warnings in the OPP core code related to W=1 builds (Viresh Kumar). - Move dev_pm_opp_{init|free}_cpufreq_table() to pm_opp.h (Viresh Kumar). - Extend dev_pm_opp_data with turbo support (Sibi Sankar). - dt-bindings: drop maxItems from inner items (David Heidelberg). -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmXvI/ISHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRx24sP/jxg6fOGme8raHQvpTXG3/H56wlGzQ4P YUvvKUXnfD3yf1zNISsUl7VQebZqDt8rygkwSdymXlUVZX1eubN0RpCFc0F8GZuc THG/YQhYQr/9zro3FpKhfDj5evk21PCQzjf+dGvfQF9qVMxNPG1JzEFK6PnolT5X 2BvkonY1XFWZjCMbZ83B/jt35lTDb0cmeNbCpfD5UJgcnxmMOtZYpORdyfPWTJpG GVCwmAFVVXxXlust/AIpt3mmOpKzSA9GnrtJkhtQe5GN+Y4OjnJiFJmTC7EfCctj JlWgVUA716mtFMUrjXgjfI54firF2oQpqaSa2HG/V/A96JWQqjarGz5dAV1IrPEt ZmYpvMe4E90S411wF1OWyrEqjXUuDnH1OWUvUdWSt4E7DhFw3esDi/jLW2tyVKAT hIy+/O4wzbDSTX/h9Cgt1Qjhew6lKUIwvhEXclB3fuJ+JoviWNkC9lnK93e2H0A3 VYfkd/lpUD74035l0FrCJ/49MjX9kqrsn+TipHsIlSXAi8ZRdKbVvxOTD8RYudcI GvCiDDrkMgNwGlyedgbtTBUepCvSg93b+vVmRj7YMPtBhioOUo3qCn6wpqhxfnth 9BCnPW7JxqUw/NJdlk9hKumaUZq+MK8G+kdYcIDg6xmAkWSUVP2QKlWavfMCxqRP +dN6T2iHsKFe =UePT -----END PGP SIGNATURE----- Merge tag 'pm-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull power management updates from Rafael Wysocki: "From the functional perspective, the most significant change here is the addition of support for Energy Models that can be updated dynamically at run time. There is also the addition of LZ4 compression support for hibernation, the new preferred core support in amd-pstate, new platforms support in the Intel RAPL driver, new model-specific EPP handling in intel_pstate and more. Apart from that, the cpufreq default transition delay is reduced from 10 ms to 2 ms (along with some related adjustments), the system suspend statistics code undergoes a significant rework and there is a usual bunch of fixes and code cleanups all over. Specifics: - Allow the Energy Model to be updated dynamically (Lukasz Luba) - Add support for LZ4 compression algorithm to the hibernation image creation and loading code (Nikhil V) - Fix and clean up system suspend statistics collection (Rafael Wysocki) - Simplify device suspend and resume handling in the power management core code (Rafael Wysocki) - Fix PCI hibernation support description (Yiwei Lin) - Make hibernation take set_memory_ro() return values into account as appropriate (Christophe Leroy) - Set mem_sleep_current during kernel command line setup to avoid an ordering issue with handling it (Maulik Shah) - Fix wake IRQs handling when pm_runtime_force_suspend() is used as a driver's system suspend callback (Qingliang Li) - Simplify pm_runtime_get_if_active() usage and add a replacement for pm_runtime_put_autosuspend() (Sakari Ailus) - Add a tracepoint for runtime_status changes tracking (Vilas Bhat) - Fix section title markdown in the runtime PM documentation (Yiwei Lin) - Enable preferred core support in the amd-pstate cpufreq driver (Meng Li) - Fix min_perf assignment in amd_pstate_adjust_perf() and make the min/max limit perf values in amd-pstate always stay within the (highest perf, lowest perf) range (Tor Vic, Meng Li) - Allow intel_pstate to assign model-specific values to strings used in the EPP sysfs interface and make it do so on Meteor Lake (Srinivas Pandruvada) - Drop long-unused cpudata::prev_cummulative_iowait from the intel_pstate cpufreq driver (Jiri Slaby) - Prevent scaling_cur_freq from exceeding scaling_max_freq when the latter is an inefficient frequency (Shivnandan Kumar) - Change default transition delay in cpufreq to 2ms (Qais Yousef) - Remove references to 10ms minimum sampling rate from comments in the cpufreq code (Pierre Gondois) - Honour transition_latency over transition_delay_us in cpufreq (Qais Yousef) - Stop unregistering cpufreq cooling on CPU hot-remove (Viresh Kumar) - General enhancements / cleanups to ARM cpufreq drivers (tianyu2, Nícolas F. R. A. Prado, Erick Archer, Arnd Bergmann, Anastasia Belova) - Update cpufreq-dt-platdev to block/approve devices (Richard Acayan) - Make the SCMI cpufreq driver get a transition delay value from firmware (Pierre Gondois) - Prevent the haltpoll cpuidle governor from shrinking guest poll_limit_ns below grow_start (Parshuram Sangle) - Avoid potential overflow in integer multiplication when computing cpuidle state parameters (C Cheng) - Adjust MWAIT hint target C-state computation in the ACPI cpuidle driver and in intel_idle to return a correct value for C0 (He Rongguang) - Address multiple issues in the TPMI RAPL driver and add support for new platforms (Lunar Lake-M, Arrow Lake) to Intel RAPL (Zhang Rui) - Fix freq_qos_add_request() return value check in dtpm_cpu (Daniel Lezcano) - Fix kernel-doc for dtpm_create_hierarchy() (Yang Li) - Fix file leak in get_pkg_num() in x86_energy_perf_policy (Samasth Norway Ananda) - Fix cpupower-frequency-info.1 man page typo (Jan Kratochvil) - Fix a couple of warnings in the OPP core code related to W=1 builds (Viresh Kumar) - Move dev_pm_opp_{init|free}_cpufreq_table() to pm_opp.h (Viresh Kumar) - Extend dev_pm_opp_data with turbo support (Sibi Sankar) - dt-bindings: drop maxItems from inner items (David Heidelberg)" * tag 'pm-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (95 commits) dt-bindings: opp: drop maxItems from inner items OPP: debugfs: Fix warning around icc_get_name() OPP: debugfs: Fix warning with W=1 builds cpufreq: Move dev_pm_opp_{init|free}_cpufreq_table() to pm_opp.h OPP: Extend dev_pm_opp_data with turbo support Fix cpupower-frequency-info.1 man page typo cpufreq: scmi: Set transition_delay_us firmware: arm_scmi: Populate fast channel rate_limit firmware: arm_scmi: Populate perf commands rate_limit cpuidle: ACPI/intel: fix MWAIT hint target C-state computation PM: sleep: wakeirq: fix wake irq warning in system suspend powercap: dtpm: Fix kernel-doc for dtpm_create_hierarchy() function cpufreq: Don't unregister cpufreq cooling on CPU hotplug PM: suspend: Set mem_sleep_current during kernel command line setup cpufreq: Honour transition_latency over transition_delay_us cpufreq: Limit resolving a frequency to policy min/max Documentation: PM: Fix runtime_pm.rst markdown syntax cpufreq: amd-pstate: adjust min/max limit perf cpufreq: Remove references to 10ms min sampling rate cpufreq: intel_pstate: Update default EPPs for Meteor Lake ...
363 lines
13 KiB
C
363 lines
13 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* System Control and Management Interface (SCMI) Message Protocol
|
|
* protocols common header file containing some definitions, structures
|
|
* and function prototypes used in all the different SCMI protocols.
|
|
*
|
|
* Copyright (C) 2022 ARM Ltd.
|
|
*/
|
|
#ifndef _SCMI_PROTOCOLS_H
|
|
#define _SCMI_PROTOCOLS_H
|
|
|
|
#include <linux/bitfield.h>
|
|
#include <linux/completion.h>
|
|
#include <linux/device.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/hashtable.h>
|
|
#include <linux/list.h>
|
|
#include <linux/module.h>
|
|
#include <linux/refcount.h>
|
|
#include <linux/scmi_protocol.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
#define PROTOCOL_REV_MINOR_MASK GENMASK(15, 0)
|
|
#define PROTOCOL_REV_MAJOR_MASK GENMASK(31, 16)
|
|
#define PROTOCOL_REV_MAJOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x))))
|
|
#define PROTOCOL_REV_MINOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x))))
|
|
|
|
enum scmi_common_cmd {
|
|
PROTOCOL_VERSION = 0x0,
|
|
PROTOCOL_ATTRIBUTES = 0x1,
|
|
PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
|
|
NEGOTIATE_PROTOCOL_VERSION = 0x10,
|
|
};
|
|
|
|
/**
|
|
* struct scmi_msg_resp_prot_version - Response for a message
|
|
*
|
|
* @minor_version: Minor version of the ABI that firmware supports
|
|
* @major_version: Major version of the ABI that firmware supports
|
|
*
|
|
* In general, ABI version changes follow the rule that minor version increments
|
|
* are backward compatible. Major revision changes in ABI may not be
|
|
* backward compatible.
|
|
*
|
|
* Response to a generic message with message type SCMI_MSG_VERSION
|
|
*/
|
|
struct scmi_msg_resp_prot_version {
|
|
__le16 minor_version;
|
|
__le16 major_version;
|
|
};
|
|
|
|
/**
|
|
* struct scmi_msg - Message(Tx/Rx) structure
|
|
*
|
|
* @buf: Buffer pointer
|
|
* @len: Length of data in the Buffer
|
|
*/
|
|
struct scmi_msg {
|
|
void *buf;
|
|
size_t len;
|
|
};
|
|
|
|
/**
|
|
* struct scmi_msg_hdr - Message(Tx/Rx) header
|
|
*
|
|
* @id: The identifier of the message being sent
|
|
* @protocol_id: The identifier of the protocol used to send @id message
|
|
* @type: The SCMI type for this message
|
|
* @seq: The token to identify the message. When a message returns, the
|
|
* platform returns the whole message header unmodified including the
|
|
* token
|
|
* @status: Status of the transfer once it's complete
|
|
* @poll_completion: Indicate if the transfer needs to be polled for
|
|
* completion or interrupt mode is used
|
|
*/
|
|
struct scmi_msg_hdr {
|
|
u8 id;
|
|
u8 protocol_id;
|
|
u8 type;
|
|
u16 seq;
|
|
u32 status;
|
|
bool poll_completion;
|
|
};
|
|
|
|
/**
|
|
* struct scmi_xfer - Structure representing a message flow
|
|
*
|
|
* @transfer_id: Unique ID for debug & profiling purpose
|
|
* @hdr: Transmit message header
|
|
* @tx: Transmit message
|
|
* @rx: Receive message, the buffer should be pre-allocated to store
|
|
* message. If request-ACK protocol is used, we can reuse the same
|
|
* buffer for the rx path as we use for the tx path.
|
|
* @done: command message transmit completion event
|
|
* @async_done: pointer to delayed response message received event completion
|
|
* @pending: True for xfers added to @pending_xfers hashtable
|
|
* @node: An hlist_node reference used to store this xfer, alternatively, on
|
|
* the free list @free_xfers or in the @pending_xfers hashtable
|
|
* @users: A refcount to track the active users for this xfer.
|
|
* This is meant to protect against the possibility that, when a command
|
|
* transaction times out concurrently with the reception of a valid
|
|
* response message, the xfer could be finally put on the TX path, and
|
|
* so vanish, while on the RX path scmi_rx_callback() is still
|
|
* processing it: in such a case this refcounting will ensure that, even
|
|
* though the timed-out transaction will anyway cause the command
|
|
* request to be reported as failed by time-out, the underlying xfer
|
|
* cannot be discarded and possibly reused until the last one user on
|
|
* the RX path has released it.
|
|
* @busy: An atomic flag to ensure exclusive write access to this xfer
|
|
* @state: The current state of this transfer, with states transitions deemed
|
|
* valid being:
|
|
* - SCMI_XFER_SENT_OK -> SCMI_XFER_RESP_OK [ -> SCMI_XFER_DRESP_OK ]
|
|
* - SCMI_XFER_SENT_OK -> SCMI_XFER_DRESP_OK
|
|
* (Missing synchronous response is assumed OK and ignored)
|
|
* @flags: Optional flags associated to this xfer.
|
|
* @lock: A spinlock to protect state and busy fields.
|
|
* @priv: A pointer for transport private usage.
|
|
*/
|
|
struct scmi_xfer {
|
|
int transfer_id;
|
|
struct scmi_msg_hdr hdr;
|
|
struct scmi_msg tx;
|
|
struct scmi_msg rx;
|
|
struct completion done;
|
|
struct completion *async_done;
|
|
bool pending;
|
|
struct hlist_node node;
|
|
refcount_t users;
|
|
#define SCMI_XFER_FREE 0
|
|
#define SCMI_XFER_BUSY 1
|
|
atomic_t busy;
|
|
#define SCMI_XFER_SENT_OK 0
|
|
#define SCMI_XFER_RESP_OK 1
|
|
#define SCMI_XFER_DRESP_OK 2
|
|
int state;
|
|
#define SCMI_XFER_FLAG_IS_RAW BIT(0)
|
|
#define SCMI_XFER_IS_RAW(x) ((x)->flags & SCMI_XFER_FLAG_IS_RAW)
|
|
#define SCMI_XFER_FLAG_CHAN_SET BIT(1)
|
|
#define SCMI_XFER_IS_CHAN_SET(x) \
|
|
((x)->flags & SCMI_XFER_FLAG_CHAN_SET)
|
|
int flags;
|
|
/* A lock to protect state and busy fields */
|
|
spinlock_t lock;
|
|
void *priv;
|
|
};
|
|
|
|
struct scmi_xfer_ops;
|
|
struct scmi_proto_helpers_ops;
|
|
|
|
/**
|
|
* struct scmi_protocol_handle - Reference to an initialized protocol instance
|
|
*
|
|
* @dev: A reference to the associated SCMI instance device (handle->dev).
|
|
* @xops: A reference to a struct holding refs to the core xfer operations that
|
|
* can be used by the protocol implementation to generate SCMI messages.
|
|
* @set_priv: A method to set protocol private data for this instance.
|
|
* @get_priv: A method to get protocol private data previously set.
|
|
*
|
|
* This structure represents a protocol initialized against specific SCMI
|
|
* instance and it will be used as follows:
|
|
* - as a parameter fed from the core to the protocol initialization code so
|
|
* that it can access the core xfer operations to build and generate SCMI
|
|
* messages exclusively for the specific underlying protocol instance.
|
|
* - as an opaque handle fed by an SCMI driver user when it tries to access
|
|
* this protocol through its own protocol operations.
|
|
* In this case this handle will be returned as an opaque object together
|
|
* with the related protocol operations when the SCMI driver tries to access
|
|
* the protocol.
|
|
*/
|
|
struct scmi_protocol_handle {
|
|
struct device *dev;
|
|
const struct scmi_xfer_ops *xops;
|
|
const struct scmi_proto_helpers_ops *hops;
|
|
int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv,
|
|
u32 version);
|
|
void *(*get_priv)(const struct scmi_protocol_handle *ph);
|
|
};
|
|
|
|
/**
|
|
* struct scmi_iterator_state - Iterator current state descriptor
|
|
* @desc_index: Starting index for the current mulit-part request.
|
|
* @num_returned: Number of returned items in the last multi-part reply.
|
|
* @num_remaining: Number of remaining items in the multi-part message.
|
|
* @max_resources: Maximum acceptable number of items, configured by the caller
|
|
* depending on the underlying resources that it is querying.
|
|
* @loop_idx: The iterator loop index in the current multi-part reply.
|
|
* @rx_len: Size in bytes of the currenly processed message; it can be used by
|
|
* the user of the iterator to verify a reply size.
|
|
* @priv: Optional pointer to some additional state-related private data setup
|
|
* by the caller during the iterations.
|
|
*/
|
|
struct scmi_iterator_state {
|
|
unsigned int desc_index;
|
|
unsigned int num_returned;
|
|
unsigned int num_remaining;
|
|
unsigned int max_resources;
|
|
unsigned int loop_idx;
|
|
size_t rx_len;
|
|
void *priv;
|
|
};
|
|
|
|
/**
|
|
* struct scmi_iterator_ops - Custom iterator operations
|
|
* @prepare_message: An operation to provide the custom logic to fill in the
|
|
* SCMI command request pointed by @message. @desc_index is
|
|
* a reference to the next index to use in the multi-part
|
|
* request.
|
|
* @update_state: An operation to provide the custom logic to update the
|
|
* iterator state from the actual message response.
|
|
* @process_response: An operation to provide the custom logic needed to process
|
|
* each chunk of the multi-part message.
|
|
*/
|
|
struct scmi_iterator_ops {
|
|
void (*prepare_message)(void *message, unsigned int desc_index,
|
|
const void *priv);
|
|
int (*update_state)(struct scmi_iterator_state *st,
|
|
const void *response, void *priv);
|
|
int (*process_response)(const struct scmi_protocol_handle *ph,
|
|
const void *response,
|
|
struct scmi_iterator_state *st, void *priv);
|
|
};
|
|
|
|
struct scmi_fc_db_info {
|
|
int width;
|
|
u64 set;
|
|
u64 mask;
|
|
void __iomem *addr;
|
|
};
|
|
|
|
struct scmi_fc_info {
|
|
void __iomem *set_addr;
|
|
void __iomem *get_addr;
|
|
struct scmi_fc_db_info *set_db;
|
|
u32 rate_limit;
|
|
};
|
|
|
|
/**
|
|
* struct scmi_proto_helpers_ops - References to common protocol helpers
|
|
* @extended_name_get: A common helper function to retrieve extended naming
|
|
* for the specified resource using the specified command.
|
|
* Result is returned as a NULL terminated string in the
|
|
* pre-allocated area pointed to by @name with maximum
|
|
* capacity of @len bytes.
|
|
* @iter_response_init: A common helper to initialize a generic iterator to
|
|
* parse multi-message responses: when run the iterator
|
|
* will take care to send the initial command request as
|
|
* specified by @msg_id and @tx_size and then to parse the
|
|
* multi-part responses using the custom operations
|
|
* provided in @ops.
|
|
* @iter_response_run: A common helper to trigger the run of a previously
|
|
* initialized iterator.
|
|
* @protocol_msg_check: A common helper to check is a specific protocol message
|
|
* is supported.
|
|
* @fastchannel_init: A common helper used to initialize FC descriptors by
|
|
* gathering FC descriptions from the SCMI platform server.
|
|
* @fastchannel_db_ring: A common helper to ring a FC doorbell.
|
|
*/
|
|
struct scmi_proto_helpers_ops {
|
|
int (*extended_name_get)(const struct scmi_protocol_handle *ph,
|
|
u8 cmd_id, u32 res_id, u32 *flags, char *name,
|
|
size_t len);
|
|
void *(*iter_response_init)(const struct scmi_protocol_handle *ph,
|
|
struct scmi_iterator_ops *ops,
|
|
unsigned int max_resources, u8 msg_id,
|
|
size_t tx_size, void *priv);
|
|
int (*iter_response_run)(void *iter);
|
|
int (*protocol_msg_check)(const struct scmi_protocol_handle *ph,
|
|
u32 message_id, u32 *attributes);
|
|
void (*fastchannel_init)(const struct scmi_protocol_handle *ph,
|
|
u8 describe_id, u32 message_id,
|
|
u32 valid_size, u32 domain,
|
|
void __iomem **p_addr,
|
|
struct scmi_fc_db_info **p_db,
|
|
u32 *rate_limit);
|
|
void (*fastchannel_db_ring)(struct scmi_fc_db_info *db);
|
|
};
|
|
|
|
/**
|
|
* struct scmi_xfer_ops - References to the core SCMI xfer operations.
|
|
* @version_get: Get this version protocol.
|
|
* @xfer_get_init: Initialize one struct xfer if any xfer slot is free.
|
|
* @reset_rx_to_maxsz: Reset rx size to max transport size.
|
|
* @do_xfer: Do the SCMI transfer.
|
|
* @do_xfer_with_response: Do the SCMI transfer waiting for a response.
|
|
* @xfer_put: Free the xfer slot.
|
|
*
|
|
* Note that all this operations expect a protocol handle as first parameter;
|
|
* they then internally use it to infer the underlying protocol number: this
|
|
* way is not possible for a protocol implementation to forge messages for
|
|
* another protocol.
|
|
*/
|
|
struct scmi_xfer_ops {
|
|
int (*version_get)(const struct scmi_protocol_handle *ph, u32 *version);
|
|
int (*xfer_get_init)(const struct scmi_protocol_handle *ph, u8 msg_id,
|
|
size_t tx_size, size_t rx_size,
|
|
struct scmi_xfer **p);
|
|
void (*reset_rx_to_maxsz)(const struct scmi_protocol_handle *ph,
|
|
struct scmi_xfer *xfer);
|
|
int (*do_xfer)(const struct scmi_protocol_handle *ph,
|
|
struct scmi_xfer *xfer);
|
|
int (*do_xfer_with_response)(const struct scmi_protocol_handle *ph,
|
|
struct scmi_xfer *xfer);
|
|
void (*xfer_put)(const struct scmi_protocol_handle *ph,
|
|
struct scmi_xfer *xfer);
|
|
};
|
|
|
|
typedef int (*scmi_prot_init_ph_fn_t)(const struct scmi_protocol_handle *);
|
|
|
|
/**
|
|
* struct scmi_protocol - Protocol descriptor
|
|
* @id: Protocol ID.
|
|
* @owner: Module reference if any.
|
|
* @instance_init: Mandatory protocol initialization function.
|
|
* @instance_deinit: Optional protocol de-initialization function.
|
|
* @ops: Optional reference to the operations provided by the protocol and
|
|
* exposed in scmi_protocol.h.
|
|
* @events: An optional reference to the events supported by this protocol.
|
|
* @supported_version: The highest version currently supported for this
|
|
* protocol by the agent. Each protocol implementation
|
|
* in the agent is supposed to downgrade to match the
|
|
* protocol version supported by the platform.
|
|
*/
|
|
struct scmi_protocol {
|
|
const u8 id;
|
|
struct module *owner;
|
|
const scmi_prot_init_ph_fn_t instance_init;
|
|
const scmi_prot_init_ph_fn_t instance_deinit;
|
|
const void *ops;
|
|
const struct scmi_protocol_events *events;
|
|
unsigned int supported_version;
|
|
};
|
|
|
|
#define DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(name, proto) \
|
|
static const struct scmi_protocol *__this_proto = &(proto); \
|
|
\
|
|
int __init scmi_##name##_register(void) \
|
|
{ \
|
|
return scmi_protocol_register(__this_proto); \
|
|
} \
|
|
\
|
|
void __exit scmi_##name##_unregister(void) \
|
|
{ \
|
|
scmi_protocol_unregister(__this_proto); \
|
|
}
|
|
|
|
#define DECLARE_SCMI_REGISTER_UNREGISTER(func) \
|
|
int __init scmi_##func##_register(void); \
|
|
void __exit scmi_##func##_unregister(void)
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(base);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(clock);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(perf);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(power);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(reset);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(voltage);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(system);
|
|
DECLARE_SCMI_REGISTER_UNREGISTER(powercap);
|
|
|
|
#endif /* _SCMI_PROTOCOLS_H */
|