From: Sudeep Holla <sudeep.holla@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla <sudeep.holla@arm.com>, arve@google.com, Andrew Walbran <qwandor@google.com>, David Hartley <dhh@qti.qualcomm.com>, Achin Gupta <Achin.Gupta@arm.com>, Jens Wiklander <jens.wiklander@linaro.org>, Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>, Marc Bonnici <marc.bonnici@arm.com> Subject: [PATCH v7 3/5] firmware: arm_ffa: Add support for SMCCC as transport to FFA driver Date: Fri, 21 May 2021 16:10:31 +0100 [thread overview] Message-ID: <20210521151033.181846-4-sudeep.holla@arm.com> (raw) In-Reply-To: <20210521151033.181846-1-sudeep.holla@arm.com> There are requests to keep the transport separate in order to allow other possible transports like virtio. So let us keep the SMCCC transport specific routines abstracted. It is kept simple for now. Once we add another transport, we can develop better abstraction. Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- drivers/firmware/arm_ffa/Kconfig | 5 ++++ drivers/firmware/arm_ffa/Makefile | 3 ++- drivers/firmware/arm_ffa/common.h | 4 ++++ drivers/firmware/arm_ffa/smccc.c | 39 +++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/arm_ffa/smccc.c diff --git a/drivers/firmware/arm_ffa/Kconfig b/drivers/firmware/arm_ffa/Kconfig index 261a3660650a..5e3ae5cf82e8 100644 --- a/drivers/firmware/arm_ffa/Kconfig +++ b/drivers/firmware/arm_ffa/Kconfig @@ -14,3 +14,8 @@ config ARM_FFA_TRANSPORT This driver provides interface for all the client drivers making use of the features offered by ARM FF-A. + +config ARM_FFA_SMCCC + bool + default ARM_FFA_TRANSPORT + depends on ARM64 && HAVE_ARM_SMCCC_DISCOVERY diff --git a/drivers/firmware/arm_ffa/Makefile b/drivers/firmware/arm_ffa/Makefile index 82d0d35c5324..9d9f37523200 100644 --- a/drivers/firmware/arm_ffa/Makefile +++ b/drivers/firmware/arm_ffa/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only ffa-bus-y = bus.o ffa-driver-y = driver.o -ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y) +ffa-transport-$(CONFIG_ARM_FFA_SMCCC) += smccc.o +ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y) $(ffa-transport-y) obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-module.o diff --git a/drivers/firmware/arm_ffa/common.h b/drivers/firmware/arm_ffa/common.h index 2d3a32f67d5d..f24754a59f47 100644 --- a/drivers/firmware/arm_ffa/common.h +++ b/drivers/firmware/arm_ffa/common.h @@ -16,9 +16,13 @@ typedef void (ffa_fn)(ffa_value_t, ffa_value_t *); int arm_ffa_bus_init(void); void arm_ffa_bus_exit(void); +#ifdef CONFIG_ARM_FFA_SMCCC +int __init ffa_transport_init(ffa_fn **invoke_ffa_fn); +#else static inline int __init ffa_transport_init(ffa_fn **invoke_ffa_fn) { return -EOPNOTSUPP; } +#endif #endif /* _FFA_COMMON_H */ diff --git a/drivers/firmware/arm_ffa/smccc.c b/drivers/firmware/arm_ffa/smccc.c new file mode 100644 index 000000000000..4d85bfff0a4e --- /dev/null +++ b/drivers/firmware/arm_ffa/smccc.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2021 ARM Ltd. + */ + +#include <linux/printk.h> + +#include "common.h" + +static void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res) +{ + arm_smccc_1_2_smc(&args, res); +} + +static void __arm_ffa_fn_hvc(ffa_value_t args, ffa_value_t *res) +{ + arm_smccc_1_2_hvc(&args, res); +} + +int __init ffa_transport_init(ffa_fn **invoke_ffa_fn) +{ + enum arm_smccc_conduit conduit; + + if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) + return -EOPNOTSUPP; + + conduit = arm_smccc_1_1_get_conduit(); + if (conduit == SMCCC_CONDUIT_NONE) { + pr_err("%s: invalid SMCCC conduit\n", __func__); + return -EOPNOTSUPP; + } + + if (conduit == SMCCC_CONDUIT_SMC) + *invoke_ffa_fn = __arm_ffa_fn_smc; + else + *invoke_ffa_fn = __arm_ffa_fn_hvc; + + return 0; +} -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-05-21 15:31 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-21 15:10 [PATCH v7 0/5] firmware: Add initial support for Arm FF-A Sudeep Holla 2021-05-21 15:10 ` [PATCH v7 1/5] firmware: arm_ffa: Add initial FFA bus support for device enumeration Sudeep Holla 2021-05-21 15:10 ` [PATCH v7 2/5] firmware: arm_ffa: Add initial Arm FFA driver support Sudeep Holla 2021-05-21 15:10 ` Sudeep Holla [this message] 2021-05-21 15:10 ` [PATCH v7 4/5] firmware: arm_ffa: Setup in-kernel users of FFA partitions Sudeep Holla 2021-05-25 6:29 ` Jens Wiklander 2021-05-25 9:02 ` Sudeep Holla 2021-05-21 15:10 ` [PATCH v7 5/5] firmware: arm_ffa: Add support for MEM_* interfaces Sudeep Holla 2021-06-01 16:23 ` [PATCH v7 0/5] firmware: Add initial support for Arm FF-A Sudeep Holla
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210521151033.181846-4-sudeep.holla@arm.com \ --to=sudeep.holla@arm.com \ --cc=Achin.Gupta@arm.com \ --cc=arunachalam.ganapathy@arm.com \ --cc=arve@google.com \ --cc=dhh@qti.qualcomm.com \ --cc=jens.wiklander@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=marc.bonnici@arm.com \ --cc=qwandor@google.com \ --subject='Re: [PATCH v7 3/5] firmware: arm_ffa: Add support for SMCCC as transport to FFA driver' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).