1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
6 * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
12 #include <linux/printk.h>
15 * This header is public. It can be used by clients to access
16 * data structures and definitions they need
20 * struct ffa_partition_info - Partition information descriptor
22 * @exec_ctxt: Execution context count
23 * @properties: Partition properties
25 * Data structure containing information about partitions instantiated in the system
26 * This structure is filled with the data queried by FFA_PARTITION_INFO_GET
28 struct ffa_partition_info
{
31 /* partition supports receipt of direct requests */
32 #define FFA_PARTITION_DIRECT_RECV BIT(0)
33 /* partition can send direct requests. */
34 #define FFA_PARTITION_DIRECT_SEND BIT(1)
35 /* partition can send and receive indirect messages. */
36 #define FFA_PARTITION_INDIRECT_MSG BIT(2)
41 * struct ffa_partition_uuid - 16 bytes UUID transmitted by FFA_PARTITION_INFO_GET
42 * @a1-4: 32-bit words access to the UUID data
45 struct ffa_partition_uuid
{
53 * struct ffa_partition_desc - the secure partition descriptor
54 * @info: partition information
55 * @sp_uuid: the secure partition UUID
57 * Each partition has its descriptor containing the partitions information and the UUID
59 struct ffa_partition_desc
{
60 struct ffa_partition_info info
;
61 struct ffa_partition_uuid sp_uuid
;
65 * struct ffa_send_direct_data - Data structure hosting the data
66 * used by FFA_MSG_SEND_DIRECT_{REQ,RESP}
67 * @data0-4: Data read/written from/to x3-x7 registers
69 * Data structure containing the data to be sent by FFA_MSG_SEND_DIRECT_REQ
70 * or read from FFA_MSG_SEND_DIRECT_RESP
73 /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
74 struct ffa_send_direct_data
{
75 ulong data0
; /* w3/x3 */
76 ulong data1
; /* w4/x4 */
77 ulong data2
; /* w5/x5 */
78 ulong data3
; /* w6/x6 */
79 ulong data4
; /* w7/x7 */
85 * struct ffa_bus_ops - Operations for FF-A
86 * @partition_info_get: callback for the FFA_PARTITION_INFO_GET
87 * @sync_send_receive: callback for the FFA_MSG_SEND_DIRECT_REQ
88 * @rxtx_unmap: callback for the FFA_RXTX_UNMAP
90 * The data structure providing all the operations supported by the driver.
91 * This structure is EFI runtime resident.
94 int (*partition_info_get
)(struct udevice
*dev
, const char *uuid_str
,
95 u32
*sp_count
, struct ffa_partition_desc
**sp_descs
);
96 int (*sync_send_receive
)(struct udevice
*dev
, u16 dst_part_id
,
97 struct ffa_send_direct_data
*msg
,
99 int (*rxtx_unmap
)(struct udevice
*dev
);
102 #define ffa_get_ops(dev) ((struct ffa_bus_ops *)(dev)->driver->ops)
105 * ffa_rxtx_unmap() - FFA_RXTX_UNMAP driver operation
106 * Please see ffa_unmap_rxtx_buffers_hdlr() description for more details.
108 int ffa_rxtx_unmap(struct udevice
*dev
);
111 * ffa_unmap_rxtx_buffers_hdlr() - FFA_RXTX_UNMAP handler function
112 * @dev: The arm_ffa bus device
114 * This function implements FFA_RXTX_UNMAP FF-A function
115 * to unmap the RX/TX buffers
119 * 0 on success. Otherwise, failure
121 int ffa_unmap_rxtx_buffers_hdlr(struct udevice
*dev
);
124 * ffa_sync_send_receive() - FFA_MSG_SEND_DIRECT_{REQ,RESP} driver operation
125 * Please see ffa_msg_send_direct_req_hdlr() description for more details.
127 int ffa_sync_send_receive(struct udevice
*dev
, u16 dst_part_id
,
128 struct ffa_send_direct_data
*msg
, bool is_smc64
);
131 * ffa_msg_send_direct_req_hdlr() - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function
132 * @dev: The arm_ffa bus device
133 * @dst_part_id: destination partition ID
134 * @msg: pointer to the message data preallocated by the client (in/out)
135 * @is_smc64: select 64-bit or 32-bit FF-A ABI
137 * This function implements FFA_MSG_SEND_DIRECT_{REQ,RESP}
140 * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition.
141 * The response from the secure partition is handled by reading the
142 * FFA_MSG_SEND_DIRECT_RESP arguments.
144 * The maximum size of the data that can be exchanged is 40 bytes which is
145 * sizeof(struct ffa_send_direct_data) as defined by the FF-A specification 1.0
146 * in the section relevant to FFA_MSG_SEND_DIRECT_{REQ,RESP}
150 * 0 on success. Otherwise, failure
152 int ffa_msg_send_direct_req_hdlr(struct udevice
*dev
, u16 dst_part_id
,
153 struct ffa_send_direct_data
*msg
, bool is_smc64
);
156 * ffa_partition_info_get() - FFA_PARTITION_INFO_GET driver operation
157 * Please see ffa_get_partitions_info_hdlr() description for more details.
159 int ffa_partition_info_get(struct udevice
*dev
, const char *uuid_str
,
160 u32
*sp_count
, struct ffa_partition_desc
**sp_descs
);
163 * ffa_get_partitions_info_hdlr() - FFA_PARTITION_INFO_GET handler function
164 * @uuid_str: pointer to the UUID string
165 * @sp_count: address of the variable containing the number of partitions matching the UUID
166 * The variable is set by the driver
167 * @sp_descs: address of the descriptors of the partitions matching the UUID
168 * The address is set by the driver
170 * Return the number of partitions and their descriptors matching the UUID
172 * Query the secure partition data from uc_priv.
173 * If not found, invoke FFA_PARTITION_INFO_GET
174 * FF-A function to query the partition information from secure world.
176 * A client of the FF-A driver should know the UUID of the service it wants to
177 * access. It should use the UUID to request the FF-A driver to provide the
178 * partition(s) information of the service. The FF-A driver uses
179 * PARTITION_INFO_GET to obtain this information. This is implemented through
180 * ffa_get_partitions_info_hdlr() function.
181 * A new FFA_PARTITION_INFO_GET call is issued (first one performed through
182 * ffa_cache_partitions_info) allowing to retrieve the partition(s) information.
183 * They are not saved (already done). We only update the UUID in the cached area.
184 * This assumes that partitions data does not change in the secure world.
185 * Otherwise u-boot will have an outdated partition data. The benefit of caching
186 * the information in the FF-A driver is to accommodate discovery after
187 * ExitBootServices().
191 * @sp_count: the number of partitions
192 * @sp_descs: address of the partitions descriptors
194 * On success 0 is returned. Otherwise, failure
196 int ffa_get_partitions_info_hdlr(struct udevice
*dev
, const char *uuid_str
,
197 u32
*sp_count
, struct ffa_partition_desc
**sp_descs
);
202 * ffa_set_smc_conduit() - Set the SMC conduit
203 * @dev: The FF-A bus device
205 * Selects the SMC conduit by setting the FF-A ABI invoke function.
209 * 0 on success. Otherwise, failure
211 int ffa_set_smc_conduit(struct udevice
*dev
);