blob: 9b6f78725d97429763c418ece788a1c75edc247c [file] [log] [blame]
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +01001/*
Tamas Kaman262dc7b2019-03-20 13:37:12 +01002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Tamas Kaman262dc7b2019-03-20 13:37:12 +01008#include <stdbool.h>
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +01009#include "tfm_platform_api.h"
10#include "tfm_platform_veneers.h"
11#include "tfm_ns_lock.h"
Tamas Kaman262dc7b2019-03-20 13:37:12 +010012#include "tfm_platform_defs.h"
13#include "tfm_veneers.h"
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010014
15enum tfm_platform_err_t tfm_platform_system_reset(void)
16{
17 return tfm_ns_lock_dispatch((veneer_fn)tfm_platform_veneer_system_reset,
18 0,
19 0,
20 0,
21 0);
22}
Tamas Kaman262dc7b2019-03-20 13:37:12 +010023
24enum tfm_platform_err_t
25tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
26 uint32_t *result)
27{
28 enum tfm_platform_err_t ret;
29 psa_invec in_vec;
30 psa_outvec out_vec;
31 struct tfm_pin_service_args_t args;
32
33 if (result == NULL) {
34 return TFM_PLATFORM_ERR_INVALID_PARAM;
35 }
36
37 args.type = TFM_PIN_SERVICE_TYPE_SET_ALTFUNC;
38 args.u.set_altfunc.alt_func = alt_func;
39 args.u.set_altfunc.pin_mask = pin_mask;
40
41 in_vec.base = (const void *)&args;
42 in_vec.len = sizeof(args);
43
44 out_vec.base = (void *)result;
45 out_vec.len = sizeof(*result);
46
47 ret = tfm_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
48 (uint32_t)&in_vec, 1,
49 (uint32_t)&out_vec, 1);
50
51 return ret;
52}
53
54enum tfm_platform_err_t
55tfm_platform_set_pin_default_in(uint32_t alt_func, uint32_t pin_value,
56 bool default_in_value, uint32_t *result)
57{
58 enum tfm_platform_err_t ret;
59 psa_invec in_vec;
60 psa_outvec out_vec;
61 struct tfm_pin_service_args_t args;
62
63 if (result == NULL) {
64 return TFM_PLATFORM_ERR_INVALID_PARAM;
65 }
66
67 args.type = TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN;
68 args.u.set_default_in.alt_func = alt_func;
69 args.u.set_default_in.pin_value = pin_value;
70 args.u.set_default_in.default_in_value = default_in_value;
71
72 in_vec.base = (const void *)&args;
73 in_vec.len = sizeof(args);
74
75 out_vec.base = (void *)result;
76 out_vec.len = sizeof(*result);
77
78 ret = tfm_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
79 (uint32_t)&in_vec, 1,
80 (uint32_t)&out_vec, 1);
81
82 return ret;
83}
84
85enum tfm_platform_err_t
86tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
87 uint32_t *result)
88{
89 enum tfm_platform_err_t ret;
90 psa_invec in_vec;
91 psa_outvec out_vec;
92 struct tfm_pin_service_args_t args;
93
94 if (result == NULL) {
95 return TFM_PLATFORM_ERR_INVALID_PARAM;
96 }
97
98 args.type = TFM_PIN_SERVICE_TYPE_SET_PIN_MODE;
99 args.u.set_pin_mode.pin_mask = pin_mask;
100 args.u.set_pin_mode.pin_mode = pin_mode;
101
102 in_vec.base = (const void *)&args;
103 in_vec.len = sizeof(args);
104
105 out_vec.base = (void *)result;
106 out_vec.len = sizeof(*result);
107
108 ret = tfm_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
109 (uint32_t)&in_vec, 1,
110 (uint32_t)&out_vec, 1);
111
112 return ret;
113}
114