Platform: Create platform service for pin functions
This patch creates new platform service API for
alternate functions, default input and pin mode setting.
The functions are implemented only for Musca B1,
not needed on Musca A, AN519 and AN521
Change-Id: Ic6d6dbeafe059aadc4f57a066513281afa8aa61b
Signed-off-by: Tamas Kaman <tamas.kaman@arm.com>
diff --git a/interface/src/tfm_platform_api.c b/interface/src/tfm_platform_api.c
index b4e1162..9b6f787 100644
--- a/interface/src/tfm_platform_api.c
+++ b/interface/src/tfm_platform_api.c
@@ -1,13 +1,16 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
+#include <stdbool.h>
#include "tfm_platform_api.h"
#include "tfm_platform_veneers.h"
#include "tfm_ns_lock.h"
+#include "tfm_platform_defs.h"
+#include "tfm_veneers.h"
enum tfm_platform_err_t tfm_platform_system_reset(void)
{
@@ -17,3 +20,95 @@
0,
0);
}
+
+enum tfm_platform_err_t
+tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
+ uint32_t *result)
+{
+ enum tfm_platform_err_t ret;
+ psa_invec in_vec;
+ psa_outvec out_vec;
+ struct tfm_pin_service_args_t args;
+
+ if (result == NULL) {
+ return TFM_PLATFORM_ERR_INVALID_PARAM;
+ }
+
+ args.type = TFM_PIN_SERVICE_TYPE_SET_ALTFUNC;
+ args.u.set_altfunc.alt_func = alt_func;
+ args.u.set_altfunc.pin_mask = pin_mask;
+
+ in_vec.base = (const void *)&args;
+ in_vec.len = sizeof(args);
+
+ out_vec.base = (void *)result;
+ out_vec.len = sizeof(*result);
+
+ ret = tfm_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
+ (uint32_t)&in_vec, 1,
+ (uint32_t)&out_vec, 1);
+
+ return ret;
+}
+
+enum tfm_platform_err_t
+tfm_platform_set_pin_default_in(uint32_t alt_func, uint32_t pin_value,
+ bool default_in_value, uint32_t *result)
+{
+ enum tfm_platform_err_t ret;
+ psa_invec in_vec;
+ psa_outvec out_vec;
+ struct tfm_pin_service_args_t args;
+
+ if (result == NULL) {
+ return TFM_PLATFORM_ERR_INVALID_PARAM;
+ }
+
+ args.type = TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN;
+ args.u.set_default_in.alt_func = alt_func;
+ args.u.set_default_in.pin_value = pin_value;
+ args.u.set_default_in.default_in_value = default_in_value;
+
+ in_vec.base = (const void *)&args;
+ in_vec.len = sizeof(args);
+
+ out_vec.base = (void *)result;
+ out_vec.len = sizeof(*result);
+
+ ret = tfm_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
+ (uint32_t)&in_vec, 1,
+ (uint32_t)&out_vec, 1);
+
+ return ret;
+}
+
+enum tfm_platform_err_t
+tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
+ uint32_t *result)
+{
+ enum tfm_platform_err_t ret;
+ psa_invec in_vec;
+ psa_outvec out_vec;
+ struct tfm_pin_service_args_t args;
+
+ if (result == NULL) {
+ return TFM_PLATFORM_ERR_INVALID_PARAM;
+ }
+
+ args.type = TFM_PIN_SERVICE_TYPE_SET_PIN_MODE;
+ args.u.set_pin_mode.pin_mask = pin_mask;
+ args.u.set_pin_mode.pin_mode = pin_mode;
+
+ in_vec.base = (const void *)&args;
+ in_vec.len = sizeof(args);
+
+ out_vec.base = (void *)result;
+ out_vec.len = sizeof(*result);
+
+ ret = tfm_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
+ (uint32_t)&in_vec, 1,
+ (uint32_t)&out_vec, 1);
+
+ return ret;
+}
+