1 /*
2  * Copyright  2018 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include "fsl_syscon.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.syscon"
18 #endif
19 
20 /*******************************************************************************
21  * Prototypes
22  ******************************************************************************/
23 
24 /*******************************************************************************
25  * Code
26  ******************************************************************************/
27 
28 /*!
29  * brief Attaches a signal
30  *
31  * This function gates the SYSCON clock.
32  *
33  * param base Base address of the SYSCON peripheral.
34  * param index Destination peripheral to attach the signal to.
35  * param connection Selects connection.
36  *
37  * retval None.
38  */
SYSCON_AttachSignal(SYSCON_Type * base,uint32_t index,syscon_connection_t connection)39 void SYSCON_AttachSignal(SYSCON_Type *base, uint32_t index, syscon_connection_t connection)
40 {
41     uint32_t syscon_id;
42     uint32_t output_id;
43 
44     /* extract syscon to be used */
45     syscon_id = ((uint32_t)(connection)) >> SYSCON_SHIFT;
46     /*  extract function number */
47     output_id = ((uint32_t)(connection)) & 0xffffU;
48     /* programm signal */
49     *(volatile uint32_t *)(((uint32_t)base) + syscon_id + (index * 4u)) = output_id;
50 }
51