#ifndef _SCMI_COMMON_H
#define _SCMI_COMMON_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>
#include "protocols.h"
#include "notify.h"
#define SCMI_MAX_CHANNELS …
#define SCMI_MAX_RESPONSE_TIMEOUT …
enum scmi_error_codes { … };
static const int scmi_linux_errmap[] = …;
static inline int scmi_to_linux_errno(int errno)
{ … }
#define MSG_ID_MASK …
#define MSG_XTRACT_ID(hdr) …
#define MSG_TYPE_MASK …
#define MSG_XTRACT_TYPE(hdr) …
#define MSG_TYPE_COMMAND …
#define MSG_TYPE_DELAYED_RESP …
#define MSG_TYPE_NOTIFICATION …
#define MSG_PROTOCOL_ID_MASK …
#define MSG_XTRACT_PROT_ID(hdr) …
#define MSG_TOKEN_ID_MASK …
#define MSG_XTRACT_TOKEN(hdr) …
#define MSG_TOKEN_MAX …
#define SCMI_PENDING_XFERS_HT_ORDER_SZ …
static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr)
{ … }
static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr)
{ … }
#define XFER_FIND(__ht, __k) …
struct scmi_revision_info *
scmi_revision_area_get(const struct scmi_protocol_handle *ph);
void scmi_setup_protocol_implemented(const struct scmi_protocol_handle *ph,
u8 *prot_imp);
extern const struct bus_type scmi_bus_type;
#define SCMI_BUS_NOTIFY_DEVICE_REQUEST …
#define SCMI_BUS_NOTIFY_DEVICE_UNREQUEST …
extern struct blocking_notifier_head scmi_requested_devices_nh;
struct scmi_device *scmi_device_create(struct device_node *np,
struct device *parent, int protocol,
const char *name);
void scmi_device_destroy(struct device *parent, int protocol, const char *name);
int scmi_protocol_acquire(const struct scmi_handle *handle, u8 protocol_id);
void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
struct scmi_chan_info { … };
struct scmi_transport_ops { … };
struct scmi_desc { … };
static inline bool is_polling_required(struct scmi_chan_info *cinfo,
const struct scmi_desc *desc)
{ … }
static inline bool is_transport_polling_capable(const struct scmi_desc *desc)
{ … }
static inline bool is_polling_enabled(struct scmi_chan_info *cinfo,
const struct scmi_desc *desc)
{ … }
void scmi_xfer_raw_put(const struct scmi_handle *handle,
struct scmi_xfer *xfer);
struct scmi_xfer *scmi_xfer_raw_get(const struct scmi_handle *handle);
struct scmi_chan_info *
scmi_xfer_raw_channel_get(const struct scmi_handle *handle, u8 protocol_id);
int scmi_xfer_raw_inflight_register(const struct scmi_handle *handle,
struct scmi_xfer *xfer);
int scmi_xfer_raw_wait_for_message_response(struct scmi_chan_info *cinfo,
struct scmi_xfer *xfer,
unsigned int timeout_ms);
#ifdef CONFIG_ARM_SCMI_TRANSPORT_MAILBOX
extern const struct scmi_desc scmi_mailbox_desc;
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
extern const struct scmi_desc scmi_smc_desc;
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
extern const struct scmi_desc scmi_virtio_desc;
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_OPTEE
extern const struct scmi_desc scmi_optee_desc;
#endif
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
enum scmi_bad_msg { … };
void scmi_bad_message_trace(struct scmi_chan_info *cinfo, u32 msg_hdr,
enum scmi_bad_msg err);
struct scmi_shared_mem;
void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem,
struct scmi_xfer *xfer, struct scmi_chan_info *cinfo);
u32 shmem_read_header(struct scmi_shared_mem __iomem *shmem);
void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
struct scmi_xfer *xfer);
void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
size_t max_len, struct scmi_xfer *xfer);
void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem);
bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
struct scmi_xfer *xfer);
bool shmem_channel_free(struct scmi_shared_mem __iomem *shmem);
bool shmem_channel_intr_enabled(struct scmi_shared_mem __iomem *shmem);
struct scmi_msg_payld;
#define SCMI_MSG_MAX_PROT_OVERHEAD …
size_t msg_response_size(struct scmi_xfer *xfer);
size_t msg_command_size(struct scmi_xfer *xfer);
void msg_tx_prepare(struct scmi_msg_payld *msg, struct scmi_xfer *xfer);
u32 msg_read_header(struct scmi_msg_payld *msg);
void msg_fetch_response(struct scmi_msg_payld *msg, size_t len,
struct scmi_xfer *xfer);
void msg_fetch_notification(struct scmi_msg_payld *msg, size_t len,
size_t max_len, struct scmi_xfer *xfer);
void scmi_notification_instance_data_set(const struct scmi_handle *handle,
void *priv);
void *scmi_notification_instance_data_get(const struct scmi_handle *handle);
#endif