1 /*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2019 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #include "fsl_aipstz.h"
10
11 /*******************************************************************************
12 * Definitions
13 ******************************************************************************/
14
15 /* Component ID definition, used by tools. */
16 #ifndef FSL_COMPONENT_ID
17 #define FSL_COMPONENT_ID "platform.drivers.aipstz"
18 #endif
19
20 /*******************************************************************************
21 * Prototypes
22 ******************************************************************************/
23 /*!
24 * brief Configure the privilege level for master.
25 *
26 * param base AIPSTZ peripheral base pointer
27 * param master Masters for AIPSTZ.
28 * param privilegeConfig Configuration is ORed from aipstz_master_privilege_level_t.
29 */
AIPSTZ_SetMasterPriviledgeLevel(AIPSTZ_Type * base,aipstz_master_t master,uint32_t privilegeConfig)30 void AIPSTZ_SetMasterPriviledgeLevel(AIPSTZ_Type *base, aipstz_master_t master, uint32_t privilegeConfig)
31 {
32 uint32_t mask = ((uint32_t)master >> 8U) - 1U;
33 uint32_t shift = (uint32_t)master & 0xFFU;
34 base->MPR = (base->MPR & (~(mask << shift))) | (privilegeConfig << shift);
35 }
36
37 /*!
38 * brief Configure the access for peripheral.
39 *
40 * param base AIPSTZ peripheral base pointer
41 * param master Peripheral for AIPSTZ.
42 * param accessControl Configuration is ORed from aipstz_peripheral_access_control_t.
43 */
AIPSTZ_SetPeripheralAccessControl(AIPSTZ_Type * base,aipstz_peripheral_t peripheral,uint32_t accessControl)44 void AIPSTZ_SetPeripheralAccessControl(AIPSTZ_Type *base, aipstz_peripheral_t peripheral, uint32_t accessControl)
45 {
46 volatile uint32_t *reg = (uint32_t *)((uint32_t)base + ((uint32_t)peripheral >> 16U));
47 uint32_t mask = (((uint32_t)peripheral & 0xFF00U) >> 8U) - 1U;
48 uint32_t shift = (uint32_t)peripheral & 0xFFU;
49
50 *reg = (*reg & (~(mask << shift))) | ((accessControl & mask) << shift);
51 }
52