--- /dev/null
+
+#ifndef _IMX_SNVS_H_
+#define _IMX_SNVS_H_
+#include <trusty/trusty_ipc.h>
+
+uint32_t trusty_snvs_read(uint32_t target);
+void trusty_snvs_write(uint32_t target, uint32_t value);
+void trusty_snvs_update_lpcr(uint32_t target, uint32_t enable);
+int imx_snvs_init(struct trusty_ipc_dev *dev);
+
+#endif
#include <trusty/keymaster.h>
#include <trusty/sysdeps.h>
#include <trusty/hwcrypto.h>
+#include <trusty/imx_snvs.h>
/*
* Initialize TIPC library
int trusty_dev_shutdown_ipc(struct trusty_dev *dev,
struct ns_mem_page_info *buf, uint32_t buf_size);
+/*
+ * Export Trusty fastcall API
+ */
+int32_t trusty_simple_fast_call32(uint32_t smcnr,
+ uint32_t a0, uint32_t a1, uint32_t a2);
+
#endif /* TRUSTY_TRUSTY_DEV_H_ */
$(QL_TIPC)/libtipc.o \
$(QL_TIPC)/rpmb_proxy.o \
$(QL_TIPC)/util.o \
+ $(QL_TIPC)/imx_snvs.o \
sysdeps/sysdeps_uboot.o \
sysdeps/storage_ops_uboot.o
return _r0;
}
+int32_t trusty_simple_fast_call32(uint32_t smcnr,
+ uint32_t a0, uint32_t a1, uint32_t a2)
+{
+ trusty_assert(SMC_IS_FASTCALL(smcnr));
+
+ return smc(smcnr, a0, a1, a2);
+}
+
static int32_t trusty_fast_call32(struct trusty_dev *dev, uint32_t smcnr,
uint32_t a0, uint32_t a1, uint32_t a2)
{
--- /dev/null
+#include <trusty/trusty_ipc.h>
+#include <trusty/util.h>
+#include <trusty/imx_snvs.h>
+#include <trusty/trusty_dev.h>
+#include "arch/arm/smcall.h"
+
+#define SMC_ENTITY_SNVS_RTC 53
+#define SMC_SNVS_PROBE SMC_FASTCALL_NR(SMC_ENTITY_SNVS_RTC, 0)
+#define SMC_SNVS_REGS_OP SMC_FASTCALL_NR(SMC_ENTITY_SNVS_RTC, 1)
+#define SMC_SNVS_LPCR_OP SMC_FASTCALL_NR(SMC_ENTITY_SNVS_RTC, 2)
+
+#define OPT_READ 0x1
+#define OPT_WRITE 0x2
+
+static struct trusty_ipc_dev *_dev = NULL;
+
+uint32_t trusty_snvs_read(uint32_t target) {
+ if (!_dev) {
+ trusty_error("trusty imx snvs driver is not initialized!\n");
+ return 0;
+ }
+ return trusty_simple_fast_call32(SMC_SNVS_REGS_OP, target, OPT_READ, 0);
+}
+
+void trusty_snvs_write(uint32_t target, uint32_t value) {
+ if (!_dev) {
+ trusty_error("trusty imx snvs driver is not initialized!\n");
+ return;
+ }
+ trusty_simple_fast_call32(SMC_SNVS_REGS_OP, target, OPT_WRITE, value);
+}
+
+void trusty_snvs_update_lpcr(uint32_t target, uint32_t enable) {
+ if (!_dev) {
+ trusty_error("trusty imx snvs driver is not initialized!\n");
+ return;
+ }
+ trusty_simple_fast_call32(SMC_SNVS_LPCR_OP, target, enable, 0);
+}
+
+int imx_snvs_init(struct trusty_ipc_dev *dev)
+{
+ trusty_assert(dev);
+ int error;
+ error = trusty_simple_fast_call32(SMC_SNVS_PROBE, 0, 0, 0);
+ if (error < 0) {
+ trusty_error("trusty imx snvs driver initialize failed! error=%d\n", error);
+ return error;
+ }
+ _dev = dev;
+ return 0;
+
+}
#include <trusty/util.h>
#include <hang.h>
#include <env.h>
+#include <trusty/imx_snvs.h>
#define LOCAL_LOG 0
trusty_info("Initializing Trusty Hardware Crypto client\n");
rc = hwcrypto_tipc_init(_ipc_dev);
if (rc != 0) {
- trusty_error("Initlializing Trusty Keymaster client failed (%d)\n", rc);
+ trusty_error("Initlializing Trusty hwcrypto client failed (%d)\n", rc);
+ return rc;
+ }
+#endif
+
+#ifdef CONFIG_IMX8M
+ trusty_info("Initializing Trusty SNVS driver\n");
+ rc = imx_snvs_init(_ipc_dev);
+ if (rc != 0) {
+ trusty_error("Initlializing Trusty SNVS driver failed (%d)\n", rc);
return rc;
}
#endif