Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 1 | /* |
Tamas Kaman | 262dc7b | 2019-03-20 13:37:12 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 3 | * |
| 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 Kaman | 262dc7b | 2019-03-20 13:37:12 +0100 | [diff] [blame^] | 12 | #include <stdbool.h> |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 13 | #include "tfm_api.h" |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | /** |
| 20 | * \brief TFM secure partition platform API version |
| 21 | */ |
| 22 | #define TFM_PLATFORM_API_VERSION_MAJOR (0) |
Tamas Kaman | 262dc7b | 2019-03-20 13:37:12 +0100 | [diff] [blame^] | 23 | #define TFM_PLATFORM_API_VERSION_MINOR (2) |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 24 | |
| 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 | */ |
| 37 | enum tfm_platform_err_t { |
| 38 | TFM_PLATFORM_ERR_SUCCESS = 0, |
| 39 | TFM_PLATFORM_ERR_SYSTEM_ERROR = TFM_PLATFORM_ERR_OFFSET, |
Tamas Kaman | 262dc7b | 2019-03-20 13:37:12 +0100 | [diff] [blame^] | 40 | TFM_PLATFORM_ERR_INVALID_PARAM, |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 41 | |
| 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 | */ |
| 51 | enum tfm_platform_err_t tfm_platform_system_reset(void); |
| 52 | |
Tamas Kaman | 262dc7b | 2019-03-20 13:37:12 +0100 | [diff] [blame^] | 53 | /*! |
| 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 | */ |
| 63 | enum tfm_platform_err_t |
| 64 | tfm_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 | */ |
| 79 | enum tfm_platform_err_t |
| 80 | tfm_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 | */ |
| 92 | enum tfm_platform_err_t |
| 93 | tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode, |
| 94 | uint32_t *result); |
| 95 | |
| 96 | |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 97 | #ifdef __cplusplus |
| 98 | } |
| 99 | #endif |
| 100 | |
| 101 | #endif /* __TFM_PLATFORM_API__ */ |