1 /*
2  * Copyright  2019 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_SYSCTL_H_
10 #define _FSL_SYSCTL_H_
11 
12 #include "fsl_common.h"
13 /*******************************************************************************
14  * Definitions
15  ******************************************************************************/
16 
17 /*!
18  * @addtogroup sysctl
19  * @{
20  */
21 
22 /*! @file */
23 /*! @file fsl_sysctl.h */
24 
25 /*******************************************************************************
26  * Definitions
27  ******************************************************************************/
28 
29 /*! @name Driver version */
30 /*@{*/
31 /*! @brief Group sysctl driver version for SDK */
32 #define FSL_SYSCTL_DRIVER_VERSION (MAKE_VERSION(2, 0, 5)) /*!< Version 2.0.5. */
33 /*@}*/
34 
35 /*! @brief SYSCTL share set*/
36 enum _sysctl_share_set_index
37 {
38     kSYSCTL_ShareSet0 = 0, /*!< share set 0 */
39     kSYSCTL_ShareSet1 = 1, /*!< share set 1 */
40 };
41 
42 /*! @brief SYSCTL flexcomm signal */
43 typedef enum _sysctl_fcctrlsel_signal
44 {
45     kSYSCTL_FlexcommSignalSCK     = SYSCTL_FCCTRLSEL_SCKINSEL_SHIFT,   /*!< SCK signal */
46     kSYSCTL_FlexcommSignalWS      = SYSCTL_FCCTRLSEL_WSINSEL_SHIFT,    /*!< WS signal */
47     kSYSCTL_FlexcommSignalDataIn  = SYSCTL_FCCTRLSEL_DATAINSEL_SHIFT,  /*!< Data in signal */
48     kSYSCTL_FlexcommSignalDataOut = SYSCTL_FCCTRLSEL_DATAOUTSEL_SHIFT, /*!< Data out signal */
49 } sysctl_fcctrlsel_signal_t;
50 
51 /*! @brief SYSCTL flexcomm index*/
52 enum _sysctl_share_src
53 {
54     kSYSCTL_Flexcomm0 = 0, /*!< share set 0 */
55     kSYSCTL_Flexcomm1 = 1, /*!< share set 1 */
56     kSYSCTL_Flexcomm2 = 2, /*!< share set 2 */
57     kSYSCTL_Flexcomm4 = 4, /*!< share set 4 */
58     kSYSCTL_Flexcomm5 = 5, /*!< share set 5 */
59     kSYSCTL_Flexcomm6 = 6, /*!< share set 6 */
60     kSYSCTL_Flexcomm7 = 7, /*!< share set 7 */
61 };
62 
63 /*! @brief SYSCTL shared data out mask */
64 enum _sysctl_dataout_mask
65 {
66     kSYSCTL_Flexcomm0DataOut = SYSCTL_SHAREDCTRLSET_FC0DATAOUTEN_MASK, /*!< share set 0 */
67     kSYSCTL_Flexcomm1DataOut = SYSCTL_SHAREDCTRLSET_FC1DATAOUTEN_MASK, /*!< share set 1 */
68     kSYSCTL_Flexcomm2DataOut = SYSCTL_SHAREDCTRLSET_FC2DATAOUTEN_MASK, /*!< share set 2 */
69     kSYSCTL_Flexcomm4DataOut = SYSCTL_SHAREDCTRLSET_FC4DATAOUTEN_MASK, /*!< share set 4 */
70     kSYSCTL_Flexcomm5DataOut = SYSCTL_SHAREDCTRLSET_FC5DATAOUTEN_MASK, /*!< share set 5 */
71     kSYSCTL_Flexcomm6DataOut = SYSCTL_SHAREDCTRLSET_FC6DATAOUTEN_MASK, /*!< share set 6 */
72     kSYSCTL_Flexcomm7DataOut = SYSCTL_SHAREDCTRLSET_FC7DATAOUTEN_MASK, /*!< share set 7 */
73 };
74 
75 /*! @brief SYSCTL flexcomm signal */
76 typedef enum _sysctl_sharedctrlset_signal
77 {
78     kSYSCTL_SharedCtrlSignalSCK     = SYSCTL_SHAREDCTRLSET_SHAREDSCKSEL_SHIFT,  /*!< SCK signal */
79     kSYSCTL_SharedCtrlSignalWS      = SYSCTL_SHAREDCTRLSET_SHAREDWSSEL_SHIFT,   /*!< WS signal */
80     kSYSCTL_SharedCtrlSignalDataIn  = SYSCTL_SHAREDCTRLSET_SHAREDDATASEL_SHIFT, /*!< Data in signal */
81     kSYSCTL_SharedCtrlSignalDataOut = SYSCTL_SHAREDCTRLSET_FC0DATAOUTEN_SHIFT,  /*!< Data out signal */
82 } sysctl_sharedctrlset_signal_t;
83 /*******************************************************************************
84  * API
85  ******************************************************************************/
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
91 /*!
92  * @name Initialization and deinitialization
93  * @{
94  */
95 
96 /*!
97  * @brief SYSCTL initial
98  *
99  * @param base Base address of the SYSCTL peripheral.
100  */
101 void SYSCTL_Init(SYSCTL_Type *base);
102 
103 /*!
104  * @brief SYSCTL deinit
105  *
106  * @param base Base address of the SYSCTL peripheral.
107  */
108 void SYSCTL_Deinit(SYSCTL_Type *base);
109 
110 /* @} */
111 
112 /*!
113  * @name SYSCTL share signal configure
114  * @{
115  */
116 
117 /*!
118  * @brief SYSCTL share set configure for flexcomm
119  *
120  * @param base Base address of the SYSCTL peripheral.
121  * @param flexCommIndex index of flexcomm, reference _sysctl_share_src
122  * @param sckSet share set for sck,reference _sysctl_share_set_index
123  * @param wsSet share set for ws, reference _sysctl_share_set_index
124  * @param dataInSet share set for data in, reference _sysctl_share_set_index
125  * @param dataOutSet share set for data out, reference _sysctl_dataout_mask
126  *
127  */
128 void SYSCTL_SetFlexcommShareSet(SYSCTL_Type *base,
129                                 uint32_t flexCommIndex,
130                                 uint32_t sckSet,
131                                 uint32_t wsSet,
132                                 uint32_t dataInSet,
133                                 uint32_t dataOutSet);
134 
135 /*!
136  * @brief SYSCTL share set configure for separate signal
137  *
138  * @param base Base address of the SYSCTL peripheral
139  * @param flexCommIndex index of flexcomm,reference _sysctl_share_src
140  * @param signal FCCTRLSEL signal shift
141  * @param set share set for sck, reference _sysctl_share_set_index
142  *
143  */
144 void SYSCTL_SetShareSet(SYSCTL_Type *base, uint32_t flexCommIndex, sysctl_fcctrlsel_signal_t signal, uint32_t set);
145 
146 /*!
147  * @brief SYSCTL share set source configure
148  *
149  * @param base Base address of the SYSCTL peripheral
150  * @param setIndex index of share set, reference _sysctl_share_set_index
151  * @param sckShareSrc sck source for this share set,reference _sysctl_share_src
152  * @param wsShareSrc ws source for this share set,reference _sysctl_share_src
153  * @param dataInShareSrc data in source for this share set,reference _sysctl_share_src
154  * @param dataOutShareSrc data out source for this share set,reference _sysctl_dataout_mask
155  *
156  */
157 void SYSCTL_SetShareSetSrc(SYSCTL_Type *base,
158                            uint32_t setIndex,
159                            uint32_t sckShareSrc,
160                            uint32_t wsShareSrc,
161                            uint32_t dataInShareSrc,
162                            uint32_t dataOutShareSrc);
163 
164 /*!
165  * @brief SYSCTL sck source configure
166  *
167  * @param base Base address of the SYSCTL peripheral
168  * @param setIndex index of share set, reference _sysctl_share_set_index
169  * @param signal FCCTRLSEL signal shift
170  * @param shareSrc sck source fro this share set,reference _sysctl_share_src
171  *
172  */
173 void SYSCTL_SetShareSignalSrc(SYSCTL_Type *base,
174                               uint32_t setIndex,
175                               sysctl_sharedctrlset_signal_t signal,
176                               uint32_t shareSrc);
177 
178 /* @} */
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 /*@}*/
185 
186 #endif /* _FSL_SYSCTL_H_ */
187