Linux Audio

Check our new training course

Loading...
v5.9
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * System Control and Management Interface (SCMI) Message Protocol
  4 * driver common header file containing some definitions, structures
  5 * and function prototypes used in all the different SCMI protocols.
  6 *
  7 * Copyright (C) 2018 ARM Ltd.
  8 */
  9#ifndef _SCMI_COMMON_H
 10#define _SCMI_COMMON_H
 11
 12#include <linux/bitfield.h>
 13#include <linux/completion.h>
 14#include <linux/device.h>
 15#include <linux/errno.h>
 16#include <linux/kernel.h>
 
 17#include <linux/scmi_protocol.h>
 18#include <linux/types.h>
 19
 20#include <asm/unaligned.h>
 21
 
 
 22#define PROTOCOL_REV_MINOR_MASK	GENMASK(15, 0)
 23#define PROTOCOL_REV_MAJOR_MASK	GENMASK(31, 16)
 24#define PROTOCOL_REV_MAJOR(x)	(u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))
 25#define PROTOCOL_REV_MINOR(x)	(u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x)))
 26#define MAX_PROTOCOLS_IMP	16
 27#define MAX_OPPS		16
 28
 29enum scmi_common_cmd {
 30	PROTOCOL_VERSION = 0x0,
 31	PROTOCOL_ATTRIBUTES = 0x1,
 32	PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
 33};
 34
 35/**
 36 * struct scmi_msg_resp_prot_version - Response for a message
 37 *
 38 * @minor_version: Minor version of the ABI that firmware supports
 39 * @major_version: Major version of the ABI that firmware supports
 40 *
 41 * In general, ABI version changes follow the rule that minor version increments
 42 * are backward compatible. Major revision changes in ABI may not be
 43 * backward compatible.
 44 *
 45 * Response to a generic message with message type SCMI_MSG_VERSION
 46 */
 47struct scmi_msg_resp_prot_version {
 48	__le16 minor_version;
 49	__le16 major_version;
 50};
 51
 52#define MSG_ID_MASK		GENMASK(7, 0)
 53#define MSG_XTRACT_ID(hdr)	FIELD_GET(MSG_ID_MASK, (hdr))
 54#define MSG_TYPE_MASK		GENMASK(9, 8)
 55#define MSG_XTRACT_TYPE(hdr)	FIELD_GET(MSG_TYPE_MASK, (hdr))
 56#define MSG_TYPE_COMMAND	0
 57#define MSG_TYPE_DELAYED_RESP	2
 58#define MSG_TYPE_NOTIFICATION	3
 59#define MSG_PROTOCOL_ID_MASK	GENMASK(17, 10)
 60#define MSG_XTRACT_PROT_ID(hdr)	FIELD_GET(MSG_PROTOCOL_ID_MASK, (hdr))
 61#define MSG_TOKEN_ID_MASK	GENMASK(27, 18)
 62#define MSG_XTRACT_TOKEN(hdr)	FIELD_GET(MSG_TOKEN_ID_MASK, (hdr))
 63#define MSG_TOKEN_MAX		(MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1)
 64
 65/**
 66 * struct scmi_msg_hdr - Message(Tx/Rx) header
 67 *
 68 * @id: The identifier of the message being sent
 69 * @protocol_id: The identifier of the protocol used to send @id message
 70 * @seq: The token to identify the message. When a message returns, the
 71 *	platform returns the whole message header unmodified including the
 72 *	token
 73 * @status: Status of the transfer once it's complete
 74 * @poll_completion: Indicate if the transfer needs to be polled for
 75 *	completion or interrupt mode is used
 76 */
 77struct scmi_msg_hdr {
 78	u8 id;
 79	u8 protocol_id;
 80	u16 seq;
 81	u32 status;
 82	bool poll_completion;
 83};
 84
 85/**
 86 * pack_scmi_header() - packs and returns 32-bit header
 87 *
 88 * @hdr: pointer to header containing all the information on message id,
 89 *	protocol id and sequence id.
 90 *
 91 * Return: 32-bit packed message header to be sent to the platform.
 92 */
 93static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr)
 94{
 95	return FIELD_PREP(MSG_ID_MASK, hdr->id) |
 96		FIELD_PREP(MSG_TOKEN_ID_MASK, hdr->seq) |
 97		FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id);
 98}
 99
100/**
101 * unpack_scmi_header() - unpacks and records message and protocol id
102 *
103 * @msg_hdr: 32-bit packed message header sent from the platform
104 * @hdr: pointer to header to fetch message and protocol id.
105 */
106static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr)
107{
108	hdr->id = MSG_XTRACT_ID(msg_hdr);
109	hdr->protocol_id = MSG_XTRACT_PROT_ID(msg_hdr);
110}
111
112/**
113 * struct scmi_msg - Message(Tx/Rx) structure
114 *
115 * @buf: Buffer pointer
116 * @len: Length of data in the Buffer
117 */
118struct scmi_msg {
119	void *buf;
120	size_t len;
121};
122
123/**
124 * struct scmi_xfer - Structure representing a message flow
125 *
126 * @transfer_id: Unique ID for debug & profiling purpose
127 * @hdr: Transmit message header
128 * @tx: Transmit message
129 * @rx: Receive message, the buffer should be pre-allocated to store
130 *	message. If request-ACK protocol is used, we can reuse the same
131 *	buffer for the rx path as we use for the tx path.
132 * @done: command message transmit completion event
133 * @async_done: pointer to delayed response message received event completion
134 */
135struct scmi_xfer {
136	int transfer_id;
137	struct scmi_msg_hdr hdr;
138	struct scmi_msg tx;
139	struct scmi_msg rx;
140	struct completion done;
141	struct completion *async_done;
142};
143
144void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
145int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
146int scmi_do_xfer_with_response(const struct scmi_handle *h,
147			       struct scmi_xfer *xfer);
148int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
149		       size_t tx_size, size_t rx_size, struct scmi_xfer **p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150int scmi_handle_put(const struct scmi_handle *handle);
151struct scmi_handle *scmi_handle_get(struct device *dev);
152void scmi_set_handle(struct scmi_device *scmi_dev);
153int scmi_version_get(const struct scmi_handle *h, u8 protocol, u32 *version);
154void scmi_setup_protocol_implemented(const struct scmi_handle *handle,
155				     u8 *prot_imp);
156
157int scmi_base_protocol_init(struct scmi_handle *h);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
159/* SCMI Transport */
160/**
161 * struct scmi_chan_info - Structure representing a SCMI channel information
162 *
163 * @dev: Reference to device in the SCMI hierarchy corresponding to this
164 *	 channel
165 * @handle: Pointer to SCMI entity handle
166 * @transport_info: Transport layer related information
167 */
168struct scmi_chan_info {
169	struct device *dev;
170	struct scmi_handle *handle;
171	void *transport_info;
172};
173
174/**
175 * struct scmi_transport_ops - Structure representing a SCMI transport ops
176 *
177 * @chan_available: Callback to check if channel is available or not
178 * @chan_setup: Callback to allocate and setup a channel
179 * @chan_free: Callback to free a channel
180 * @send_message: Callback to send a message
181 * @mark_txdone: Callback to mark tx as done
182 * @fetch_response: Callback to fetch response
183 * @fetch_notification: Callback to fetch notification
184 * @clear_channel: Callback to clear a channel
185 * @poll_done: Callback to poll transfer status
186 */
187struct scmi_transport_ops {
188	bool (*chan_available)(struct device *dev, int idx);
189	int (*chan_setup)(struct scmi_chan_info *cinfo, struct device *dev,
190			  bool tx);
191	int (*chan_free)(int id, void *p, void *data);
192	int (*send_message)(struct scmi_chan_info *cinfo,
193			    struct scmi_xfer *xfer);
194	void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
195	void (*fetch_response)(struct scmi_chan_info *cinfo,
196			       struct scmi_xfer *xfer);
197	void (*fetch_notification)(struct scmi_chan_info *cinfo,
198				   size_t max_len, struct scmi_xfer *xfer);
199	void (*clear_channel)(struct scmi_chan_info *cinfo);
200	bool (*poll_done)(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer);
201};
202
 
 
 
 
 
203/**
204 * struct scmi_desc - Description of SoC integration
205 *
206 * @ops: Pointer to the transport specific ops structure
207 * @max_rx_timeout_ms: Timeout for communication with SoC (in Milliseconds)
208 * @max_msg: Maximum number of messages that can be pending
209 *	simultaneously in the system
210 * @max_msg_size: Maximum size of data per message that can be handled.
211 */
212struct scmi_desc {
213	struct scmi_transport_ops *ops;
214	int max_rx_timeout_ms;
215	int max_msg;
216	int max_msg_size;
217};
218
219extern const struct scmi_desc scmi_mailbox_desc;
220#ifdef CONFIG_HAVE_ARM_SMCCC
221extern const struct scmi_desc scmi_smc_desc;
222#endif
223
224void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
225void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
226
227/* shmem related declarations */
228struct scmi_shared_mem;
229
230void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem,
231		      struct scmi_xfer *xfer);
232u32 shmem_read_header(struct scmi_shared_mem __iomem *shmem);
233void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
234			  struct scmi_xfer *xfer);
235void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
236			      size_t max_len, struct scmi_xfer *xfer);
237void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem);
238bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
239		     struct scmi_xfer *xfer);
 
 
 
 
240
241#endif /* _SCMI_COMMON_H */
v5.14.15
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * System Control and Management Interface (SCMI) Message Protocol
  4 * driver common header file containing some definitions, structures
  5 * and function prototypes used in all the different SCMI protocols.
  6 *
  7 * Copyright (C) 2018-2021 ARM Ltd.
  8 */
  9#ifndef _SCMI_COMMON_H
 10#define _SCMI_COMMON_H
 11
 12#include <linux/bitfield.h>
 13#include <linux/completion.h>
 14#include <linux/device.h>
 15#include <linux/errno.h>
 16#include <linux/kernel.h>
 17#include <linux/module.h>
 18#include <linux/scmi_protocol.h>
 19#include <linux/types.h>
 20
 21#include <asm/unaligned.h>
 22
 23#include "notify.h"
 24
 25#define PROTOCOL_REV_MINOR_MASK	GENMASK(15, 0)
 26#define PROTOCOL_REV_MAJOR_MASK	GENMASK(31, 16)
 27#define PROTOCOL_REV_MAJOR(x)	(u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))
 28#define PROTOCOL_REV_MINOR(x)	(u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x)))
 29#define MAX_PROTOCOLS_IMP	16
 30#define MAX_OPPS		16
 31
 32enum scmi_common_cmd {
 33	PROTOCOL_VERSION = 0x0,
 34	PROTOCOL_ATTRIBUTES = 0x1,
 35	PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
 36};
 37
 38/**
 39 * struct scmi_msg_resp_prot_version - Response for a message
 40 *
 41 * @minor_version: Minor version of the ABI that firmware supports
 42 * @major_version: Major version of the ABI that firmware supports
 43 *
 44 * In general, ABI version changes follow the rule that minor version increments
 45 * are backward compatible. Major revision changes in ABI may not be
 46 * backward compatible.
 47 *
 48 * Response to a generic message with message type SCMI_MSG_VERSION
 49 */
 50struct scmi_msg_resp_prot_version {
 51	__le16 minor_version;
 52	__le16 major_version;
 53};
 54
 55#define MSG_ID_MASK		GENMASK(7, 0)
 56#define MSG_XTRACT_ID(hdr)	FIELD_GET(MSG_ID_MASK, (hdr))
 57#define MSG_TYPE_MASK		GENMASK(9, 8)
 58#define MSG_XTRACT_TYPE(hdr)	FIELD_GET(MSG_TYPE_MASK, (hdr))
 59#define MSG_TYPE_COMMAND	0
 60#define MSG_TYPE_DELAYED_RESP	2
 61#define MSG_TYPE_NOTIFICATION	3
 62#define MSG_PROTOCOL_ID_MASK	GENMASK(17, 10)
 63#define MSG_XTRACT_PROT_ID(hdr)	FIELD_GET(MSG_PROTOCOL_ID_MASK, (hdr))
 64#define MSG_TOKEN_ID_MASK	GENMASK(27, 18)
 65#define MSG_XTRACT_TOKEN(hdr)	FIELD_GET(MSG_TOKEN_ID_MASK, (hdr))
 66#define MSG_TOKEN_MAX		(MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1)
 67
 68/**
 69 * struct scmi_msg_hdr - Message(Tx/Rx) header
 70 *
 71 * @id: The identifier of the message being sent
 72 * @protocol_id: The identifier of the protocol used to send @id message
 73 * @seq: The token to identify the message. When a message returns, the
 74 *	platform returns the whole message header unmodified including the
 75 *	token
 76 * @status: Status of the transfer once it's complete
 77 * @poll_completion: Indicate if the transfer needs to be polled for
 78 *	completion or interrupt mode is used
 79 */
 80struct scmi_msg_hdr {
 81	u8 id;
 82	u8 protocol_id;
 83	u16 seq;
 84	u32 status;
 85	bool poll_completion;
 86};
 87
 88/**
 89 * pack_scmi_header() - packs and returns 32-bit header
 90 *
 91 * @hdr: pointer to header containing all the information on message id,
 92 *	protocol id and sequence id.
 93 *
 94 * Return: 32-bit packed message header to be sent to the platform.
 95 */
 96static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr)
 97{
 98	return FIELD_PREP(MSG_ID_MASK, hdr->id) |
 99		FIELD_PREP(MSG_TOKEN_ID_MASK, hdr->seq) |
100		FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id);
101}
102
103/**
104 * unpack_scmi_header() - unpacks and records message and protocol id
105 *
106 * @msg_hdr: 32-bit packed message header sent from the platform
107 * @hdr: pointer to header to fetch message and protocol id.
108 */
109static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr)
110{
111	hdr->id = MSG_XTRACT_ID(msg_hdr);
112	hdr->protocol_id = MSG_XTRACT_PROT_ID(msg_hdr);
113}
114
115/**
116 * struct scmi_msg - Message(Tx/Rx) structure
117 *
118 * @buf: Buffer pointer
119 * @len: Length of data in the Buffer
120 */
121struct scmi_msg {
122	void *buf;
123	size_t len;
124};
125
126/**
127 * struct scmi_xfer - Structure representing a message flow
128 *
129 * @transfer_id: Unique ID for debug & profiling purpose
130 * @hdr: Transmit message header
131 * @tx: Transmit message
132 * @rx: Receive message, the buffer should be pre-allocated to store
133 *	message. If request-ACK protocol is used, we can reuse the same
134 *	buffer for the rx path as we use for the tx path.
135 * @done: command message transmit completion event
136 * @async_done: pointer to delayed response message received event completion
137 */
138struct scmi_xfer {
139	int transfer_id;
140	struct scmi_msg_hdr hdr;
141	struct scmi_msg tx;
142	struct scmi_msg rx;
143	struct completion done;
144	struct completion *async_done;
145};
146
147struct scmi_xfer_ops;
148
149/**
150 * struct scmi_protocol_handle  - Reference to an initialized protocol instance
151 *
152 * @dev: A reference to the associated SCMI instance device (handle->dev).
153 * @xops: A reference to a struct holding refs to the core xfer operations that
154 *	  can be used by the protocol implementation to generate SCMI messages.
155 * @set_priv: A method to set protocol private data for this instance.
156 * @get_priv: A method to get protocol private data previously set.
157 *
158 * This structure represents a protocol initialized against specific SCMI
159 * instance and it will be used as follows:
160 * - as a parameter fed from the core to the protocol initialization code so
161 *   that it can access the core xfer operations to build and generate SCMI
162 *   messages exclusively for the specific underlying protocol instance.
163 * - as an opaque handle fed by an SCMI driver user when it tries to access
164 *   this protocol through its own protocol operations.
165 *   In this case this handle will be returned as an opaque object together
166 *   with the related protocol operations when the SCMI driver tries to access
167 *   the protocol.
168 */
169struct scmi_protocol_handle {
170	struct device *dev;
171	const struct scmi_xfer_ops *xops;
172	int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv);
173	void *(*get_priv)(const struct scmi_protocol_handle *ph);
174};
175
176/**
177 * struct scmi_xfer_ops  - References to the core SCMI xfer operations.
178 * @version_get: Get this version protocol.
179 * @xfer_get_init: Initialize one struct xfer if any xfer slot is free.
180 * @reset_rx_to_maxsz: Reset rx size to max transport size.
181 * @do_xfer: Do the SCMI transfer.
182 * @do_xfer_with_response: Do the SCMI transfer waiting for a response.
183 * @xfer_put: Free the xfer slot.
184 *
185 * Note that all this operations expect a protocol handle as first parameter;
186 * they then internally use it to infer the underlying protocol number: this
187 * way is not possible for a protocol implementation to forge messages for
188 * another protocol.
189 */
190struct scmi_xfer_ops {
191	int (*version_get)(const struct scmi_protocol_handle *ph, u32 *version);
192	int (*xfer_get_init)(const struct scmi_protocol_handle *ph, u8 msg_id,
193			     size_t tx_size, size_t rx_size,
194			     struct scmi_xfer **p);
195	void (*reset_rx_to_maxsz)(const struct scmi_protocol_handle *ph,
196				  struct scmi_xfer *xfer);
197	int (*do_xfer)(const struct scmi_protocol_handle *ph,
198		       struct scmi_xfer *xfer);
199	int (*do_xfer_with_response)(const struct scmi_protocol_handle *ph,
200				     struct scmi_xfer *xfer);
201	void (*xfer_put)(const struct scmi_protocol_handle *ph,
202			 struct scmi_xfer *xfer);
203};
204
205struct scmi_revision_info *
206scmi_revision_area_get(const struct scmi_protocol_handle *ph);
207int scmi_handle_put(const struct scmi_handle *handle);
208struct scmi_handle *scmi_handle_get(struct device *dev);
209void scmi_set_handle(struct scmi_device *scmi_dev);
210void scmi_setup_protocol_implemented(const struct scmi_protocol_handle *ph,
 
211				     u8 *prot_imp);
212
213typedef int (*scmi_prot_init_ph_fn_t)(const struct scmi_protocol_handle *);
214
215/**
216 * struct scmi_protocol  - Protocol descriptor
217 * @id: Protocol ID.
218 * @owner: Module reference if any.
219 * @instance_init: Mandatory protocol initialization function.
220 * @instance_deinit: Optional protocol de-initialization function.
221 * @ops: Optional reference to the operations provided by the protocol and
222 *	 exposed in scmi_protocol.h.
223 * @events: An optional reference to the events supported by this protocol.
224 */
225struct scmi_protocol {
226	const u8				id;
227	struct module				*owner;
228	const scmi_prot_init_ph_fn_t		instance_init;
229	const scmi_prot_init_ph_fn_t		instance_deinit;
230	const void				*ops;
231	const struct scmi_protocol_events	*events;
232};
233
234int __init scmi_bus_init(void);
235void __exit scmi_bus_exit(void);
236
237#define DECLARE_SCMI_REGISTER_UNREGISTER(func)		\
238	int __init scmi_##func##_register(void);	\
239	void __exit scmi_##func##_unregister(void)
240DECLARE_SCMI_REGISTER_UNREGISTER(base);
241DECLARE_SCMI_REGISTER_UNREGISTER(clock);
242DECLARE_SCMI_REGISTER_UNREGISTER(perf);
243DECLARE_SCMI_REGISTER_UNREGISTER(power);
244DECLARE_SCMI_REGISTER_UNREGISTER(reset);
245DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
246DECLARE_SCMI_REGISTER_UNREGISTER(voltage);
247DECLARE_SCMI_REGISTER_UNREGISTER(system);
248
249#define DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(name, proto)	\
250static const struct scmi_protocol *__this_proto = &(proto);	\
251								\
252int __init scmi_##name##_register(void)				\
253{								\
254	return scmi_protocol_register(__this_proto);		\
255}								\
256								\
257void __exit scmi_##name##_unregister(void)			\
258{								\
259	scmi_protocol_unregister(__this_proto);			\
260}
261
262const struct scmi_protocol *scmi_protocol_get(int protocol_id);
263void scmi_protocol_put(int protocol_id);
264
265int scmi_protocol_acquire(const struct scmi_handle *handle, u8 protocol_id);
266void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
267
268/* SCMI Transport */
269/**
270 * struct scmi_chan_info - Structure representing a SCMI channel information
271 *
272 * @dev: Reference to device in the SCMI hierarchy corresponding to this
273 *	 channel
274 * @handle: Pointer to SCMI entity handle
275 * @transport_info: Transport layer related information
276 */
277struct scmi_chan_info {
278	struct device *dev;
279	struct scmi_handle *handle;
280	void *transport_info;
281};
282
283/**
284 * struct scmi_transport_ops - Structure representing a SCMI transport ops
285 *
286 * @chan_available: Callback to check if channel is available or not
287 * @chan_setup: Callback to allocate and setup a channel
288 * @chan_free: Callback to free a channel
289 * @send_message: Callback to send a message
290 * @mark_txdone: Callback to mark tx as done
291 * @fetch_response: Callback to fetch response
292 * @fetch_notification: Callback to fetch notification
293 * @clear_channel: Callback to clear a channel
294 * @poll_done: Callback to poll transfer status
295 */
296struct scmi_transport_ops {
297	bool (*chan_available)(struct device *dev, int idx);
298	int (*chan_setup)(struct scmi_chan_info *cinfo, struct device *dev,
299			  bool tx);
300	int (*chan_free)(int id, void *p, void *data);
301	int (*send_message)(struct scmi_chan_info *cinfo,
302			    struct scmi_xfer *xfer);
303	void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
304	void (*fetch_response)(struct scmi_chan_info *cinfo,
305			       struct scmi_xfer *xfer);
306	void (*fetch_notification)(struct scmi_chan_info *cinfo,
307				   size_t max_len, struct scmi_xfer *xfer);
308	void (*clear_channel)(struct scmi_chan_info *cinfo);
309	bool (*poll_done)(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer);
310};
311
312int scmi_protocol_device_request(const struct scmi_device_id *id_table);
313void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table);
314struct scmi_device *scmi_child_dev_find(struct device *parent,
315					int prot_id, const char *name);
316
317/**
318 * struct scmi_desc - Description of SoC integration
319 *
320 * @ops: Pointer to the transport specific ops structure
321 * @max_rx_timeout_ms: Timeout for communication with SoC (in Milliseconds)
322 * @max_msg: Maximum number of messages that can be pending
323 *	simultaneously in the system
324 * @max_msg_size: Maximum size of data per message that can be handled.
325 */
326struct scmi_desc {
327	const struct scmi_transport_ops *ops;
328	int max_rx_timeout_ms;
329	int max_msg;
330	int max_msg_size;
331};
332
333extern const struct scmi_desc scmi_mailbox_desc;
334#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
335extern const struct scmi_desc scmi_smc_desc;
336#endif
337
338void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
339void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
340
341/* shmem related declarations */
342struct scmi_shared_mem;
343
344void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem,
345		      struct scmi_xfer *xfer);
346u32 shmem_read_header(struct scmi_shared_mem __iomem *shmem);
347void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
348			  struct scmi_xfer *xfer);
349void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
350			      size_t max_len, struct scmi_xfer *xfer);
351void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem);
352bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
353		     struct scmi_xfer *xfer);
354
355void scmi_notification_instance_data_set(const struct scmi_handle *handle,
356					 void *priv);
357void *scmi_notification_instance_data_get(const struct scmi_handle *handle);
358
359#endif /* _SCMI_COMMON_H */