drivers: introduce Secure Monitor uclass
At the moment, we don't have a common API for working with SM, only the smc_call() function. This approach is not generic and difficult to configure and maintain. This patch adds UCLASS_SM with the generic API: - sm_call() - sm_call_write() - sm_call_read() These functions operate with struct pt_regs, which describes Secure Monitor arguments. Signed-off-by: Alexey Romanov <avromanov@salutedevices.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/20230921081346.22157-2-avromanov@salutedevices.com Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
This commit is contained in:
committed by
Neil Armstrong
parent
a92345610e
commit
c52cd07407
2
drivers/sm/Kconfig
Normal file
2
drivers/sm/Kconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
config SM
|
||||
bool "Enable Secure Monitor driver support"
|
||||
3
drivers/sm/Makefile
Normal file
3
drivers/sm/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
obj-y += sm-uclass.o
|
||||
55
drivers/sm/sm-uclass.c
Normal file
55
drivers/sm/sm-uclass.c
Normal file
@@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (c) 2023 SberDevices, Inc.
|
||||
*
|
||||
* Author: Alexey Romanov <avromanov@salutedevices.com>
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <sm-uclass.h>
|
||||
|
||||
static const struct sm_ops *get_sm_ops(struct udevice *dev)
|
||||
{
|
||||
return (const struct sm_ops *)dev->driver->ops;
|
||||
}
|
||||
|
||||
int sm_call(struct udevice *dev, u32 cmd, s32 *ret, struct pt_regs *args)
|
||||
{
|
||||
const struct sm_ops *ops = get_sm_ops(dev);
|
||||
|
||||
if (ops->sm_call)
|
||||
return ops->sm_call(dev, cmd, ret, args);
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int sm_call_read(struct udevice *dev, void *buffer, size_t size,
|
||||
u32 cmd, struct pt_regs *args)
|
||||
{
|
||||
const struct sm_ops *ops = get_sm_ops(dev);
|
||||
|
||||
if (ops->sm_call_read)
|
||||
return ops->sm_call_read(dev, buffer, size, cmd,
|
||||
args);
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int sm_call_write(struct udevice *dev, void *buffer, size_t size,
|
||||
u32 cmd, struct pt_regs *args)
|
||||
{
|
||||
const struct sm_ops *ops = get_sm_ops(dev);
|
||||
|
||||
if (ops->sm_call_write)
|
||||
return ops->sm_call_write(dev, buffer, size, cmd,
|
||||
args);
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(sm) = {
|
||||
.name = "sm",
|
||||
.id = UCLASS_SM,
|
||||
};
|
||||
Reference in New Issue
Block a user