Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optee: phytium: Add Phytium optee driver support #186

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions drivers/tee/optee/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,33 @@ config OPTEE_INSECURE_LOAD_IMAGE

Additional documentation on kernel security risks are at
Documentation/staging/tee.rst.

if OPTEE

choice
prompt "Default conduit method"
default OPTEE_DEFAULT_METHOD_NONE
help
This option sets the default conduit method for OP-TEE in case
firmware misses "method" property. If in doubt, select "none"
which depends on firmware to provide the value.

config OPTEE_DEFAULT_METHOD_NONE
bool "none"
help
There is no default conduit method used by the driver. Require
firmware to provide the method explicitly.

config OPTEE_DEFAULT_METHOD_HVC
bool "hvc"
help
Use the "hvc" as default conduit method.

config OPTEE_DEFAULT_METHOD_SMC
bool "smc"
help
Use the "smc" as default conduit method.

endchoice

endif
20 changes: 19 additions & 1 deletion drivers/tee/optee/smc_abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/acpi.h>
#include <linux/arm-smccc.h>
#include <linux/cpuhotplug.h>
#include <linux/errno.h>
Expand Down Expand Up @@ -1424,6 +1425,14 @@ static void optee_smccc_hvc(unsigned long a0, unsigned long a1,
arm_smccc_hvc(a0, a1, a2, a3, a4, a5, a6, a7, res);
}

#if defined(CONFIG_OPTEE_DEFAULT_METHOD_HVC)
#define DEFAULT_CONDUIT_METHOD optee_smccc_hvc
#elif defined(CONFIG_OPTEE_DEFAULT_METHOD_SMC)
#define DEFAULT_CONDUIT_METHOD optee_smccc_smc
#else
#define DEFAULT_CONDUIT_METHOD ERR_PTR(-ENXIO)
#endif

static optee_invoke_fn *get_invoke_func(struct device *dev)
{
const char *method;
Expand All @@ -1432,7 +1441,7 @@ static optee_invoke_fn *get_invoke_func(struct device *dev)

if (device_property_read_string(dev, "method", &method)) {
pr_warn("missing \"method\" property\n");
return ERR_PTR(-ENXIO);
return DEFAULT_CONDUIT_METHOD;
}

if (!strcmp("hvc", method))
Expand Down Expand Up @@ -1820,13 +1829,22 @@ static const struct of_device_id optee_dt_match[] = {
};
MODULE_DEVICE_TABLE(of, optee_dt_match);

#ifdef CONFIG_ACPI
static const struct acpi_device_id optee_acpi_match[] = {
{ "PHYT8003" },
{ }
};
MODULE_DEVICE_TABLE(acpi, optee_acpi_match);
#endif

static struct platform_driver optee_driver = {
.probe = optee_probe,
.remove = optee_smc_remove,
.shutdown = optee_shutdown,
.driver = {
.name = "optee",
.of_match_table = optee_dt_match,
.acpi_match_table = ACPI_PTR(optee_acpi_match),
},
};

Expand Down