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 <asm/global_data.h>
13 #include <asm/sandbox_arm_ffa_priv.h>
14 #include <dm/device-internal.h>
15 #include <linux/errno.h>
17 DECLARE_GLOBAL_DATA_PTR;
20 * sandbox_ffa_discover() - perform sandbox FF-A discovery
21 * @dev: The sandbox FF-A bus device
22 * Try to discover the FF-A framework. Discovery is performed by
23 * querying the FF-A framework version from secure world using the FFA_VERSION ABI.
26 * 0 on success. Otherwise, failure
28 static int sandbox_ffa_discover(struct udevice *dev)
33 log_info("Emulated FF-A framework discovery\n");
35 ret = ffa_emul_find(dev, &emul);
37 log_err("Cannot find FF-A emulator\n");
41 ret = ffa_get_version_hdlr(dev);
49 * sandbox_ffa_probe() - The sandbox FF-A driver probe function
50 * @dev: the sandbox-arm-ffa device
51 * Save the emulator device in uc_priv.
56 static int sandbox_ffa_probe(struct udevice *dev)
59 struct ffa_priv *uc_priv = dev_get_uclass_priv(dev);
61 ret = uclass_first_device_err(UCLASS_FFA_EMUL, &uc_priv->emul);
63 log_err("Cannot find FF-A emulator\n");
71 * sandbox_ffa_bind() - The sandbox FF-A driver bind function
72 * @dev: the sandbox-arm-ffa device
73 * Try to discover the emulated FF-A bus.
78 static int sandbox_ffa_bind(struct udevice *dev)
82 ret = sandbox_ffa_discover(dev);
89 /* Sandbox Arm FF-A emulator operations */
91 static const struct ffa_bus_ops sandbox_ffa_ops = {
92 .partition_info_get = ffa_get_partitions_info_hdlr,
93 .sync_send_receive = ffa_msg_send_direct_req_hdlr,
94 .rxtx_unmap = ffa_unmap_rxtx_buffers_hdlr,
97 static const struct udevice_id sandbox_ffa_id[] = {
98 { "sandbox,arm-ffa", 0 },
102 /* Declaring the sandbox FF-A driver under UCLASS_FFA */
103 U_BOOT_DRIVER(sandbox_arm_ffa) = {
104 .name = "sandbox_arm_ffa",
105 .of_match = sandbox_ffa_id,
107 .bind = sandbox_ffa_bind,
108 .probe = sandbox_ffa_probe,
109 .ops = &sandbox_ffa_ops,