blob: 7cc57ab1870a4c878fe3bb423ce5ffa7d1d4b406 [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
8#ifndef __TFM_PLATFORM_API__
9#define __TFM_PLATFORM_API__
10
11#include <limits.h>
Tamas Kaman262dc7b2019-03-20 13:37:12 +010012#include <stdbool.h>
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010013#include "tfm_api.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
20 * \brief TFM secure partition platform API version
21 */
22#define TFM_PLATFORM_API_VERSION_MAJOR (0)
Tamas Kaman262dc7b2019-03-20 13:37:12 +010023#define TFM_PLATFORM_API_VERSION_MINOR (2)
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010024
25/* The return value is shared with the TF-M partition status value.
26 * The Platform return codes shouldn't overlap with predefined TFM status
27 * values.
28 */
29#define TFM_PLATFORM_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
30
31/*!
32 * \enum tfm_platform_err_t
33 *
34 * \brief Platform service error types
35 *
36 */
37enum tfm_platform_err_t {
38 TFM_PLATFORM_ERR_SUCCESS = 0,
39 TFM_PLATFORM_ERR_SYSTEM_ERROR = TFM_PLATFORM_ERR_OFFSET,
Tamas Kaman262dc7b2019-03-20 13:37:12 +010040 TFM_PLATFORM_ERR_INVALID_PARAM,
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010041
42 /* Following entry is only to ensure the error code of int size */
43 TFM_PLATFORM_ERR_FORCE_INT_SIZE = INT_MAX
44};
45
46/*!
47 * \brief Resets the system.
48 *
49 * \return Returns values as specified by the \ref tfm_platform_err_t
50 */
51enum tfm_platform_err_t tfm_platform_system_reset(void);
52
Tamas Kaman262dc7b2019-03-20 13:37:12 +010053/*!
54 * \brief Sets pin alternate function for the given pins
55 *
56 * \param[in] alt_func Alternate function to set (allowed values vary
57 * based on the platform)
58 * \param[in] pin_mask Pin mask of the selected pins
59 * \param[out] result Return error value
60 *
61 * \return Returns values as specified by the \ref tfm_platform_err_t
62 */
63enum tfm_platform_err_t
64tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
65 uint32_t *result);
66
67/*!
68 * \brief Sets default in value to use when the alternate function is not
69 * selected for the pin
70 *
71 * \param[in] alt_func Alternate function to use (allowed values vary
72 * based on the platform)
73 * \param[in] pin_value Pin value to use
74 * \param[in] default_in_value Default in value to set
75 * \param[out] result Return error value
76 *
77 * \return Returns values as specified by the \ref tfm_platform_err_t
78 */
79enum tfm_platform_err_t
80tfm_platform_set_pin_default_in(uint32_t alt_func, uint32_t pin_value,
81 bool default_in_value, uint32_t *result);
82
83/*!
84 * \brief Sets pin mode for the selected pins
85 *
86 * \param[in] pin_mask Pin mask of the selected pins
87 * \param[in] pin_mode Pin mode to set for the selected pins
88 * \param[out] result Return error value
89 *
90 * \return Returns values as specified by the \ref tfm_platform_err_t
91 */
92enum tfm_platform_err_t
93tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
94 uint32_t *result);
95
96
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010097#ifdef __cplusplus
98}
99#endif
100
101#endif /* __TFM_PLATFORM_API__ */