Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:59

0001 /*
0002  * Copyright 2020-2021, NXP
0003  * All rights reserved.
0004  *
0005  * SPDX-License-Identifier: BSD-3-Clause
0006  */
0007 
0008 #ifndef _FSL_KEYMGR_H_
0009 #define _FSL_KEYMGR_H_
0010 
0011 #include "fsl_common.h"
0012 
0013 /*!
0014  * @addtogroup key_manager
0015  * @{
0016  */
0017 
0018 /*******************************************************************************
0019  * Definitions
0020  ******************************************************************************/
0021 
0022 /*! @name Driver version */
0023 /*@{*/
0024 /*! @brief Key Manager driver version. Version 2.0.2.
0025  *
0026  * Current version: 2.0.2
0027  *
0028  * Change log:
0029  *
0030  * - Version 2.0.2
0031  *   - Fix MISRA-2012 issues
0032  *
0033  * - Version 2.0.1
0034  *   - Fix MISRA-2012 issues
0035  *
0036  * - Version 2.0.0
0037  *   - Initial version
0038  */
0039 #define FSL_KEYMGR_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
0040 /*@}*/
0041 
0042 typedef enum _keymgr_lock
0043 {
0044     kKEYMGR_Unlock = 0u,
0045     kKEYMGR_Lock   = 1u,
0046 } keymgr_lock_t;
0047 
0048 typedef enum _keymgr_allow
0049 {
0050     kKEYMGR_Disallow = 0u,
0051     kKEYMGR_Allow    = 1u,
0052 } keymgr_allow_t;
0053 
0054 typedef enum _keymgr_slot
0055 {
0056     kKEYMGR_Slot0 = 0u,
0057     kKEYMGR_Slot1 = 1u,
0058     kKEYMGR_Slot2 = 2u,
0059     kKEYMGR_Slot3 = 3u,
0060     kKEYMGR_Slot4 = 4u,
0061 } keymgr_slot_t;
0062 
0063 #define KEYMGR_IEE_RELOAD 1u
0064 #define KEYMGR_SEL_OCOTP  0u
0065 #define KEYMGR_SEL_UDF    0u
0066 #define KEYMGR_SEL_PUF    1u
0067 
0068 #define keymgr_select_t uint8_t
0069 
0070 /*! @brief Key Manager slot configuration structure. */
0071 typedef struct _domain_slot_config
0072 {
0073     keymgr_lock_t lockControl;     /*!< Lock control register of slot. */
0074     keymgr_allow_t allowUser;      /*!< Allow user write access to domain control register or domain register. */
0075     keymgr_allow_t allowNonSecure; /*!< Allow non-secure write access to domain control register or domain register. */
0076     keymgr_lock_t lockList;        /*!< Lock whitelist. SLOTx_CTRL[WHITE_LIST] cannot be changed. */
0077     uint8_t whiteList;             /*!< Domains that on the Whitelist can change given slot. */
0078     /*!< Each field represents one domain. Bit0~Bit3 represent DOMAIN0~DOMAIN3 respectively. */
0079 } domain_slot_config_t;
0080 
0081 /*******************************************************************************
0082  * API
0083  ******************************************************************************/
0084 #if defined(__cplusplus)
0085 extern "C" {
0086 #endif
0087 
0088 /*!
0089  * @brief Configures Master key settings.
0090  *
0091  * This function configures Key Manager's setting for Master key.
0092  *
0093  * @param base Key Manager peripheral address.
0094  * @param select select source for Master key.
0095  * @param lock setting for lock Master key.
0096  * @return  status of Master key control operation
0097  */
0098 status_t KEYMGR_MasterKeyControll(KEY_MANAGER_Type *base, keymgr_select_t select, keymgr_lock_t lock);
0099 
0100 /*!
0101  * @brief Configures OTFAD1 key settings.
0102  *
0103  * This function configures Key Manager's setting for OTFAD1 key.
0104  *
0105  * @param base Key Manager peripheral address.
0106  * @param select select source for OTFAD1 key.
0107  * @param lock setting for lock OTFAD1 key.
0108  * @return  status of OTFAD1 key control operation
0109  */
0110 status_t KEYMGR_OTFAD1KeyControll(KEY_MANAGER_Type *base, keymgr_select_t select, keymgr_lock_t lock);
0111 
0112 /*!
0113  * @brief Configures OTFAD2 key settings.
0114  *
0115  * This function configures Key Manager's setting for OTFAD2 key.
0116  *
0117  * @param base Key Manager peripheral address.
0118  * @param select select source for OTFAD2 key.
0119  * @param lock setting for lock OTFAD2 key.
0120  * @return  status of OTFAD2 key control operation
0121  */
0122 status_t KEYMGR_OTFAD2KeyControll(KEY_MANAGER_Type *base, keymgr_select_t select, keymgr_lock_t lock);
0123 
0124 /*!
0125  * @brief Restart load key signal for IEE.
0126  *
0127  * This function genrates Key Manager's restart signal for IEE key.
0128  *
0129  * @param base Key Manager peripheral address.
0130  */
0131 void KEYMGR_IEEKeyReload(KEY_MANAGER_Type *base);
0132 
0133 /*!
0134  * @brief Lock the key select from PUF.
0135  *
0136  * This function locks selection of key for PUF.
0137  *
0138  * @param base Key Manager peripheral address.
0139  * @param lock Setting for selection of key for PUF.
0140  */
0141 void KEYMGR_PUFKeyLock(KEY_MANAGER_Type *base, keymgr_lock_t lock);
0142 
0143 /*!
0144  * @brief Configures Slot Domain control.
0145  *
0146  * This function configures domain slot control which locks and allows writes.
0147  *
0148  * @param base Key Manager peripheral address.
0149  * @param config Pointer to slot configuration structure.
0150  * @param slot Select slot to be configured.
0151  * @return  status of slot control operation
0152  */
0153 status_t KEYMGR_SlotControl(KEY_MANAGER_Type *base, domain_slot_config_t *config, keymgr_slot_t slot);
0154 
0155 /*!
0156  * @brief Resets Key Manager module to factory default values.
0157  *
0158  * This function performs hardware reset of Key Manager module.
0159  *
0160  * @param base Key Manager peripheral address.
0161  */
0162 void KEYMGR_Init(KEY_MANAGER_Type *base);
0163 
0164 /*!
0165  * @brief Sets the default configuration of Key manager slot.
0166  *
0167  * This function initialize Key Manager slot config structure to default values.
0168  *
0169  * @param config Pointer to slot configuration structure.
0170  */
0171 status_t KEYMGR_GetDefaultConfig(domain_slot_config_t *config);
0172 
0173 #if defined(__cplusplus)
0174 }
0175 #endif
0176 
0177 /*!
0178  *@}
0179  */
0180 
0181 #endif /* _FSL_IEE_H_ */