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/include/tfm_platform_api.h b/interface/include/tfm_platform_api.h
index 1c3069e..7cc57ab 100644
--- a/interface/include/tfm_platform_api.h
+++ b/interface/include/tfm_platform_api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -9,6 +9,7 @@
#define __TFM_PLATFORM_API__
#include <limits.h>
+#include <stdbool.h>
#include "tfm_api.h"
#ifdef __cplusplus
@@ -19,7 +20,7 @@
* \brief TFM secure partition platform API version
*/
#define TFM_PLATFORM_API_VERSION_MAJOR (0)
-#define TFM_PLATFORM_API_VERSION_MINOR (1)
+#define TFM_PLATFORM_API_VERSION_MINOR (2)
/* The return value is shared with the TF-M partition status value.
* The Platform return codes shouldn't overlap with predefined TFM status
@@ -36,6 +37,7 @@
enum tfm_platform_err_t {
TFM_PLATFORM_ERR_SUCCESS = 0,
TFM_PLATFORM_ERR_SYSTEM_ERROR = TFM_PLATFORM_ERR_OFFSET,
+ TFM_PLATFORM_ERR_INVALID_PARAM,
/* Following entry is only to ensure the error code of int size */
TFM_PLATFORM_ERR_FORCE_INT_SIZE = INT_MAX
@@ -48,6 +50,50 @@
*/
enum tfm_platform_err_t tfm_platform_system_reset(void);
+/*!
+ * \brief Sets pin alternate function for the given pins
+ *
+ * \param[in] alt_func Alternate function to set (allowed values vary
+ * based on the platform)
+ * \param[in] pin_mask Pin mask of the selected pins
+ * \param[out] result Return error value
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+enum tfm_platform_err_t
+tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
+ uint32_t *result);
+
+/*!
+ * \brief Sets default in value to use when the alternate function is not
+ * selected for the pin
+ *
+ * \param[in] alt_func Alternate function to use (allowed values vary
+ * based on the platform)
+ * \param[in] pin_value Pin value to use
+ * \param[in] default_in_value Default in value to set
+ * \param[out] result Return error value
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+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);
+
+/*!
+ * \brief Sets pin mode for the selected pins
+ *
+ * \param[in] pin_mask Pin mask of the selected pins
+ * \param[in] pin_mode Pin mode to set for the selected pins
+ * \param[out] result Return error value
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+enum tfm_platform_err_t
+tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
+ uint32_t *result);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/interface/include/tfm_platform_defs.h b/interface/include/tfm_platform_defs.h
new file mode 100644
index 0000000..23fe4e0
--- /dev/null
+++ b/interface/include/tfm_platform_defs.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_PLATFORM_DEFS__
+#define __TFM_PLATFORM_DEFS__
+
+#include <stdint.h>
+#include <limits.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ * \enum tfm_pin_service_type_t
+ *
+ * \brief Pin service types (supported types may vary based on the platform)
+ */
+enum tfm_pin_service_type_t {
+ TFM_PIN_SERVICE_TYPE_SET_ALTFUNC = 0, /*!< Set alternate function type */
+ TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN, /*!< Set default in function type */
+ TFM_PIN_SERVICE_TYPE_SET_PIN_MODE, /*!< Set pin mode function type */
+ TFM_PIN_SERVICE_TYPE_MAX = INT_MAX /*!< Max to force enum max size */
+};
+
+/*!
+ * \struct tfm_pin_service_args_t
+ *
+ * \brief Argument list for each platform pin service
+ */
+struct tfm_pin_service_args_t {
+ enum tfm_pin_service_type_t type;
+ union {
+ struct set_altfunc { /*!< TFM_PIN_SERVICE_TYPE_SET_ALTFUNC */
+ uint32_t alt_func;
+ uint64_t pin_mask;
+ } set_altfunc;
+ struct set_default_in { /*!< TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN */
+ uint32_t alt_func;
+ uint32_t pin_value;
+ bool default_in_value;
+ } set_default_in;
+ struct set_pin_mode { /*!< TFM_PIN_SERVICE_TYPE_SET_PIN_MODE */
+ uint64_t pin_mask;
+ uint32_t pin_mode;
+ } set_pin_mode;
+ } u;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_PLATFORM_DEFS__ */
diff --git a/interface/include/tfm_veneers.h b/interface/include/tfm_veneers.h
index 787aa87..69b0a76 100644
--- a/interface/include/tfm_veneers.h
+++ b/interface/include/tfm_veneers.h
@@ -65,6 +65,7 @@
/******** TFM_SP_PLATFORM ********/
psa_status_t tfm_platform_sp_system_reset_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_platform_sp_pin_service_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
/******** TFM_SP_INITIAL_ATTESTATION ********/
psa_status_t tfm_initial_attest_get_token_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);