CC3XX: Add dedicated init and free functions

The PSA Unified Driver interface framework allows for two driver
entry points dedicated to driver init and de-init procedures. The
existing solution relies on calling the TF-M HAL (i.e. crypto_hw_*)
but in case the driver interface used is the PSA one, we should avoid
calling them and let the PSA subsystem perform the hardware initialisation.

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
Change-Id: Ie8155d5e039f75bba4c3f20dcac7eaabfd84016d
diff --git a/secure_fw/partitions/crypto/crypto_init.c b/secure_fw/partitions/crypto/crypto_init.c
index 1af64cc..9bc9ead 100644
--- a/secure_fw/partitions/crypto/crypto_init.c
+++ b/secure_fw/partitions/crypto/crypto_init.c
@@ -100,14 +100,6 @@
 }
 #else /* PSA_FRAMEWORK_HAS_MM_IOVEC == 1 */
 /**
- * \brief Default size of the internal scratch buffer used for IOVec allocations
- *        in bytes
- */
-#ifndef TFM_CRYPTO_IOVEC_BUFFER_SIZE
-#error TFM_CRYPTO_IOVEC_BUFFER_SIZE is not defined
-#endif
-
-/**
  * \brief Internal scratch used for IOVec allocations
  *
  */
@@ -281,14 +273,6 @@
 #endif /* TFM_PSA_API */
 
 /**
- * \brief Default value for the size of the static buffer used by Mbed
- *        Crypto for its dynamic allocations
- */
-#ifndef TFM_CRYPTO_ENGINE_BUF_SIZE
-#error TFM_CRYPTO_ENGINE_BUF_SIZE is not defined
-#endif
-
-/**
  * \brief Static buffer to be used by Mbed Crypto for memory allocations
  *
  */
@@ -322,8 +306,12 @@
     mbedtls_platform_set_printf(tfm_sp_log_printf);
 #endif
 
-    /* Initialise the crypto accelerator if one is enabled */
-#ifdef CRYPTO_HW_ACCELERATOR
+    /* Initialise the crypto accelerator if one is enabled. If the driver API is
+     * the one defined by the PSA Unified Driver interface, the initialisation is
+     * performed directly through psa_crypto_init() while the PSA subsystem is
+     * initialised
+     */
+#if defined(CRYPTO_HW_ACCELERATOR) && defined(CC312_LEGACY_DRIVER_API_ENABLED)
     LOG_INFFMT("[INF][Crypto] Initialising HW accelerator... ");
     if (crypto_hw_accelerator_init() != 0) {
         return PSA_ERROR_HARDWARE_FAILURE;
@@ -331,8 +319,9 @@
     LOG_INFFMT("\033[0;32mcomplete.\033[0m\r\n");
 #endif /* CRYPTO_HW_ACCELERATOR */
 
-    /* Previous function does not return any value, so just call the
-     * initialisation function of the Mbed Crypto layer
+    /* Perform the initialisation of the PSA subsystem in the Mbed Crypto
+     * library. If a driver is built using the PSA Driver interface, the function
+     * below will perform also the same operations as crypto_hw_accelerator_init()
      */
     return psa_crypto_init();
 }