1 /* 2 * Copyright 2021-2023 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef CLOCK_IP_SPECIFIC_H 8 #define CLOCK_IP_SPECIFIC_H 9 10 /** 11 * @file Clock_Ip_Specific.h 12 * @version 1.0.0 13 * 14 * @brief CLOCK IP specific header file. 15 * @details CLOCK IP specific header file. 16 * 17 * @addtogroup CLOCK_DRIVER Clock Ip Driver 18 * @{ 19 */ 20 21 #ifdef __cplusplus 22 extern "C"{ 23 #endif 24 25 26 /*================================================================================================== 27 * INCLUDE FILES 28 * 1) system and project includes 29 * 2) needed interfaces from external units 30 * 3) internal and external interfaces from this unit 31 ==================================================================================================*/ 32 #include "Clock_Ip_Cfg_Defines.h" 33 #include "Mcal.h" 34 35 #if defined(CLOCK_IP_DERIVATIVE_001) 36 #include "Clock_Ip_Derivative_001.h" 37 #endif 38 #if defined(CLOCK_IP_DERIVATIVE_002) 39 #include "Clock_Ip_Derivative_002.h" 40 #endif 41 42 43 44 /*================================================================================================== 45 SOURCE FILE VERSION INFORMATION 46 ==================================================================================================*/ 47 #define CLOCK_IP_SPECIFIC_VENDOR_ID 43 48 #define CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION 4 49 #define CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION 7 50 #define CLOCK_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION 0 51 #define CLOCK_IP_SPECIFIC_SW_MAJOR_VERSION 1 52 #define CLOCK_IP_SPECIFIC_SW_MINOR_VERSION 0 53 #define CLOCK_IP_SPECIFIC_SW_PATCH_VERSION 0 54 55 /*================================================================================================== 56 FILE VERSION CHECKS 57 ==================================================================================================*/ 58 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Cfg_Defines.h file have same versions */ 59 #if (CLOCK_IP_SPECIFIC_VENDOR_ID != CLOCK_IP_CFG_DEFINES_VENDOR_ID) 60 #error "Clock_Ip_Specific.h and Clock_Ip_Cfg_Defines.h have different vendor IDs" 61 #endif 62 63 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Cfg_Defines.h file are of the same Autosar version */ 64 #if ((CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_CFG_DEFINES_AR_RELEASE_MAJOR_VERSION) || \ 65 (CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION != CLOCK_IP_CFG_DEFINES_AR_RELEASE_MINOR_VERSION) || \ 66 (CLOCK_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION != CLOCK_IP_CFG_DEFINES_AR_RELEASE_REVISION_VERSION)) 67 #error "AutoSar Version Numbers of Clock_Ip_Specific.h and Clock_Ip_Cfg_Defines.h are different" 68 #endif 69 70 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Cfg_Defines.h file are of the same Software version */ 71 #if ((CLOCK_IP_SPECIFIC_SW_MAJOR_VERSION != CLOCK_IP_CFG_DEFINES_SW_MAJOR_VERSION) || \ 72 (CLOCK_IP_SPECIFIC_SW_MINOR_VERSION != CLOCK_IP_CFG_DEFINES_SW_MINOR_VERSION) || \ 73 (CLOCK_IP_SPECIFIC_SW_PATCH_VERSION != CLOCK_IP_CFG_DEFINES_SW_PATCH_VERSION)) 74 #error "Software Version Numbers of Clock_Ip_Specific.h and Clock_Ip_Cfg_Defines.h are different" 75 #endif 76 77 #if defined(CLOCK_IP_DERIVATIVE_001) 78 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Derivative_001.h file have same versions */ 79 #if (CLOCK_IP_SPECIFIC_VENDOR_ID != CLOCK_IP_DERIVATIVE_001_VENDOR_ID) 80 #error "Clock_Ip_Specific.h and Clock_Ip_Derivative_001.h have different vendor IDs" 81 #endif 82 83 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Derivative_001.h file are of the same Autosar version */ 84 #if ((CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_DERIVATIVE_001_AR_RELEASE_MAJOR_VERSION) || \ 85 (CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION != CLOCK_IP_DERIVATIVE_001_AR_RELEASE_MINOR_VERSION) || \ 86 (CLOCK_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION != CLOCK_IP_DERIVATIVE_001_AR_RELEASE_REVISION_VERSION)) 87 #error "AutoSar Version Numbers of Clock_Ip_Specific.h and Clock_Ip_Derivative_001.h are different" 88 #endif 89 90 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Derivative_001.h file are of the same Software version */ 91 #if ((CLOCK_IP_SPECIFIC_SW_MAJOR_VERSION != CLOCK_IP_DERIVATIVE_001_SW_MAJOR_VERSION) || \ 92 (CLOCK_IP_SPECIFIC_SW_MINOR_VERSION != CLOCK_IP_DERIVATIVE_001_SW_MINOR_VERSION) || \ 93 (CLOCK_IP_SPECIFIC_SW_PATCH_VERSION != CLOCK_IP_DERIVATIVE_001_SW_PATCH_VERSION)) 94 #error "Software Version Numbers of Clock_Ip_Specific.h and Clock_Ip_Derivative_001.h are different" 95 #endif 96 #endif 97 98 #if defined(CLOCK_IP_DERIVATIVE_002) 99 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Derivative_002.h file have same versions */ 100 #if (CLOCK_IP_SPECIFIC_VENDOR_ID != CLOCK_IP_DERIVATIVE_002_VENDOR_ID) 101 #error "Clock_Ip_Specific.h and Clock_Ip_Derivative_002.h have different vendor IDs" 102 #endif 103 104 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Derivative_002.h file are of the same Autosar version */ 105 #if ((CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_DERIVATIVE_002_AR_RELEASE_MAJOR_VERSION) || \ 106 (CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION != CLOCK_IP_DERIVATIVE_002_AR_RELEASE_MINOR_VERSION) || \ 107 (CLOCK_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION != CLOCK_IP_DERIVATIVE_002_AR_RELEASE_REVISION_VERSION)) 108 #error "AutoSar Version Numbers of Clock_Ip_Specific.h and Clock_Ip_Derivative_002.h are different" 109 #endif 110 111 /* Check if Clock_Ip_Specific.h file and Clock_Ip_Derivative_002.h file are of the same Software version */ 112 #if ((CLOCK_IP_SPECIFIC_SW_MAJOR_VERSION != CLOCK_IP_DERIVATIVE_002_SW_MAJOR_VERSION) || \ 113 (CLOCK_IP_SPECIFIC_SW_MINOR_VERSION != CLOCK_IP_DERIVATIVE_002_SW_MINOR_VERSION) || \ 114 (CLOCK_IP_SPECIFIC_SW_PATCH_VERSION != CLOCK_IP_DERIVATIVE_002_SW_PATCH_VERSION)) 115 #error "Software Version Numbers of Clock_Ip_Specific.h and Clock_Ip_Derivative_002.h are different" 116 #endif 117 #endif 118 119 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 120 /* Check if Clock_Ip_Specific.h file and Mcal.h file are of the same Autosar version */ 121 #if ((CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \ 122 (CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION)) 123 #error "AutoSar Version Numbers of Clock_Ip_Specific.h and Mcal.h are different" 124 #endif 125 #endif 126 /*================================================================================================== 127 * CONSTANTS 128 ==================================================================================================*/ 129 130 /*================================================================================================== 131 * DEFINES AND MACROS 132 ==================================================================================================*/ 133 134 #define CLOCK_IP_ALL_CALLBACKS_COUNT 11U 135 #define CLOCK_IP_TRIGGER_VALUE 0xFFFFFFFFU /* Trigger value. */ 136 137 #define CLOCK_IP_NUMBER_OF_HARDWARE_DFS 12U 138 #define CLOCK_IP_NUMBER_OF_HARDWARE_PLL 5U 139 140 #define DFS_PORTSR_PORTSTAT_MASK (DFS_PORTSR_PORTSTAT5_MASK | DFS_PORTSR_PORTSTAT4_MASK | DFS_PORTSR_PORTSTAT3_MASK | DFS_PORTSR_PORTSTAT2_MASK | DFS_PORTSR_PORTSTAT1_MASK | DFS_PORTSR_PORTSTAT0_MASK) 141 #define DFS_PORTSR_PORTSTAT_SHIFT (DFS_PORTSR_PORTSTAT0_SHIFT) 142 143 #define MC_ME_AE_TRANSITION_IS_ON_GOING MC_ME_AE_GS_S_MTRANS_MASK 144 145 #define CLOCK_IP_MC_CGM_MUX_MUX_DIV_COUNT 11u 146 #define CLOCK_IP_MC_CGM_PCFS_COUNT 64u 147 #define CLOCK_IP_PERIPHERALS_NO 64u 148 149 #define CLOCK_IP_MC_CGM_INSTANCES_COUNT 10U 150 #define CLOCK_IP_MC_CGM_MUXS_COUNT 15U 151 #define CLOCK_IP_XOSC_INSTANCES_ARRAY_SIZE 1U 152 #define CLOCK_IP_PLL_INSTANCES_ARRAY_SIZE 3U 153 #define CLOCK_IP_LFASTPLL_INSTANCES_ARRAY_SIZE 2U 154 #define CLOCK_IP_DFS_INSTANCES_ARRAY_SIZE 2U 155 #define CLOCK_IP_PERIPHERAL_GROUPS_COUNT 7U 156 #define CLOCK_IP_CMU_INFO_SIZE 28U 157 #define CLOCK_IP_GATE_INFO_SIZE 101U 158 #define CLOCK_IP_EXTENSIONS_SIZE 132U 159 #define CLOCK_IP_GPR_INSTANCES_COUNT 6U 160 #define CLOCK_IP_CLKOUTS_COUNT 5U 161 162 #define MC_CGM_MUX_DC_DE_MASK MC_CGM_MUX_0_DC_0_DE_MASK 163 #define MC_CGM_MUX_DC_DE_SHIFT MC_CGM_MUX_0_DC_0_DE_SHIFT 164 #define MC_CGM_MUX_CSC_SAFE_SW_MASK MC_CGM_MUX_0_CSS_SAFE_SW_MASK 165 #define MC_CGM_MUX_CSC_CLK_SW_MASK MC_CGM_MUX_0_CSC_CLK_SW_MASK 166 #define MC_CGM_MUX_CSC_RAMPUP_MASK MC_CGM_MUX_0_CSC_RAMPUP_MASK 167 #define MC_CGM_MUX_CSC_RAMPDOWN_MASK MC_CGM_MUX_0_CSC_RAMPDOWN_MASK 168 #define MC_CGM_MUX_CSS_SWIP_MASK MC_CGM_MUX_0_CSS_SWIP_MASK 169 #define MC_CGM_MUX_CSS_SWIP_IN_PROGRESS MC_CGM_MUX_CSS_SWIP_MASK 170 #define MC_CGM_MUX_CSS_SWTRG_MASK MC_CGM_MUX_0_CSS_SWTRG_MASK 171 #define MC_CGM_MUX_CSS_SWTRG_SHIFT MC_CGM_MUX_0_CSS_SWTRG_SHIFT 172 #define CLOCK_IP_MC_CGM_MUX_CSS_SWTRG_SUCCEEDED 1U 173 #define MC_CGM_MUX_CSS_CLK_SW_MASK MC_CGM_MUX_0_CSS_CLK_SW_MASK 174 #define CLOCK_IP_MC_CGM_MUX_CSS_CLK_SW_NOT_REQUESTED 0U 175 176 #define MC_CGM_MUX_CSC_CG_MASK MC_CGM_MUX_4_CSC_CG_MASK 177 #define MC_CGM_MUX_CSC_FCG_MASK MC_CGM_MUX_4_CSC_FCG_MASK 178 #define MC_CGM_MUX_CSS_CS_MASK MC_CGM_MUX_4_CSS_CS_MASK 179 #define MC_CGM_MUX_CSS_CS_TRANSPARENT MC_CGM_MUX_CSS_CS_MASK 180 181 #define MC_CGM_MUX_DIV_UPD_STAT_DIV_STAT_MASK MC_CGM_MUX_0_DIV_UPD_STAT_DIV_STAT_MASK 182 #define MC_CGM_MUX_DIV_UPD_STAT_DIV_STAT_PENDING MC_CGM_MUX_DIV_UPD_STAT_DIV_STAT_MASK 183 #define MC_CGM_MUX_DIV_TRIG_CTRL_TCTL_MASK MC_CGM_MUX_7_DIV_TRIG_CTRL_TCTL_MASK 184 #define MC_CGM_MUX_DIV_TRIG_TRIGGER(x) MC_CGM_MUX_7_DIV_TRIG_CTRL_TCTL(x) 185 #define MC_CGM_MUX_DIV_TRIG_CTRL_COMMON_TRIGGER_DIVIDER_UPDATE MC_CGM_MUX_DIV_TRIG_CTRL_TCTL_MASK 186 187 188 #define MC_CGM_PCFS_DIVC_INIT(x) MC_CGM_PCFS_DIVC12_INIT(x) 189 #define MC_CGM_PCFS_DIVC_RATE(x) MC_CGM_PCFS_DIVC12_RATE(x) 190 #define MC_CGM_PCFS_DIVE_DIVE(x) MC_CGM_PCFS_DIVE12_DIVE(x) 191 #define MC_CGM_PCFS_DIVS_DIVS(x) MC_CGM_PCFS_DIVS12_DIVS(x) 192 193 #define CLOCK_IP_CMU_FREQUENCY_CHECK_ENABLED CMU_FC_GCR_FCE_MASK 194 #define CLOCK_IP_CMU_FREQUENCY_CHECK_STOPPED 0U 195 #define CLOCK_IP_CMU_ISR_MASK 3U 196 197 #define GPR_PCTL_MASK GPR3_PCTL_EDMACEPCTL_PCTL_MASK 198 199 #define CLOCK_IP_DIVIDER_HAVE_DIV_FMT STD_ON 200 #define CLOCK_IP_FXOSC_ALC_SUPPORTED (STD_ON) 201 /*================================================================================================== 202 * ENUMS 203 ==================================================================================================*/ 204 205 /*================================================================================================== 206 * STRUCTURES AND OTHER TYPEDEFS 207 ==================================================================================================*/ 208 typedef struct { 209 uint32 CSC; /**< Clock Mux Select Control Register */ 210 const uint32 CSS; /**< Clock Mux Select Status Register */ 211 uint32 Divider[CLOCK_IP_MC_CGM_MUX_MUX_DIV_COUNT]; /**< Clock Divider Control Register */ 212 uint32 MUX_DIV_TRIG_CTRL; /**< Clock Divider trigger Control Register */ 213 uint32 MUX_DIV_TRIG; /**< Clock Divider trigger Register */ 214 const uint32 MUX_DIV_UPD_STAT; /**< Clock Divider Update Status Register */ 215 216 }volatile Clock_Ip_CgmMuxType; 217 218 typedef struct { 219 220 uint32 PCFS_SDUR; /**< PCFS Step Duration, offset: 0x0 */ 221 struct { /* offset: 0x4, array step: 0xC */ 222 uint32 DIVC; /**< PCFS Divider Change 12 Register, array offset: 0x4, array step: 0xC */ 223 uint32 DIVE; /**< PCFS Divider End 12 Register, array offset: 0x8, array step: 0xC */ 224 uint32 DIVS; /**< PCFS Divider Start 12 Register, array offset: 0xC, array step: 0xC */ 225 } PCFS[CLOCK_IP_MC_CGM_PCFS_COUNT]; 226 227 }Clock_Ip_CgmPcfsType; 228 229 typedef struct { 230 volatile uint32 PCTL[CLOCK_IP_PERIPHERALS_NO]; 231 }Clock_Ip_GprClockControlEnable_Type; 232 233 #if defined(CLOCK_IP_HAS_SYSTEM_CLK) 234 /** MC_ME_AE - Register Layout Typedef */ 235 typedef struct { 236 uint32 POWER_MODE_CONFIG[3u]; /**< Power Mode Configuration, offset: 0x28, 0x2C and 0x30 */ 237 }volatile Clock_Ip_SystemClockType; 238 #endif 239 240 /** XOSC - Register Layout Typedef */ 241 typedef struct { 242 uint32 CTRL; /**< XOSC Control Register, offset: 0x0 */ 243 const uint32 STAT; /**< Oscillator Status Register, offset: 0x4 */ 244 }volatile Clock_Ip_ExtOSCType; 245 246 /** CMU - Register Layout Typedef */ 247 typedef struct { 248 uint8 GCR; /**< Global Configuration Register, offset: 0x0 */ 249 uint8 RESEDVED[3]; /**< Reserved Register, offset: 0x1 */ 250 uint32 RCCR; /**< Reference Count Configuration Register, offset: 0x4 */ 251 uint32 HTCR; /**< High Threshold Configuration Register, offset: 0x8 */ 252 uint32 LTCR; /**< Low Threshold Configuration Register, offset: 0xC */ 253 volatile uint32 SR; /**< Status Register, offset: 0x10 */ 254 uint32 IER; /**< Interrupt Enable Register, offset: 0x14 */ 255 256 }Clock_Ip_ClockMonitorType; 257 258 typedef struct{ 259 260 Clock_Ip_NameType Name; /* Name of the clock that can be monitored/supports cmu (clock monitor) */ 261 Clock_Ip_NameType Reference; /* Name of the reference clock */ 262 Clock_Ip_NameType Bus; /* Name of the bus clock */ 263 264 Clock_Ip_ClockMonitorType* CmuInstance; 265 266 }Clock_Ip_CmuInfoType; 267 268 typedef struct 269 { 270 uint8 GroupIndex; 271 uint8 GateIndex; 272 uint8 GateBitField; 273 274 }Clock_Ip_GateInfoType; 275 276 typedef struct 277 { 278 uint32 SelectorValueMask; 279 uint32 SelectorValueShift; 280 uint32 DividerValueMask; 281 uint32 DividerValueShift; 282 283 }Clock_Ip_ClockExtensionType; 284 285 typedef struct 286 { 287 PLLDIG_Type* PllInstance; 288 uint8 DivsNo; 289 290 }Clock_Ip_PllType; 291 292 typedef struct 293 { 294 LFAST_Type* PllInstance; 295 296 }Clock_Ip_LfastPllType; 297 /*================================================================================================== 298 * GLOBAL VARIABLE DECLARATIONS 299 ==================================================================================================*/ 300 301 /* Clock start constant section data */ 302 #define MCU_START_SEC_CONST_UNSPECIFIED 303 #include "Mcu_MemMap.h" 304 305 extern Clock_Ip_CgmMuxType* const Clock_Ip_apxCgm[CLOCK_IP_MC_CGM_INSTANCES_COUNT][CLOCK_IP_MC_CGM_MUXS_COUNT]; 306 extern volatile Clock_Ip_CgmPcfsType* const Clock_Ip_apxCgmPcfs[CLOCK_IP_MC_CGM_INSTANCES_COUNT]; 307 extern Clock_Ip_ExtOSCType* const Clock_Ip_apxXosc[CLOCK_IP_XOSC_INSTANCES_ARRAY_SIZE]; 308 extern Clock_Ip_PllType const Clock_Ip_apxPll[CLOCK_IP_PLL_INSTANCES_ARRAY_SIZE]; 309 extern Clock_Ip_LfastPllType const Clock_Ip_apxLfastPll[CLOCK_IP_LFASTPLL_INSTANCES_ARRAY_SIZE]; 310 extern DFS_Type* const Clock_Ip_apxDfs[CLOCK_IP_DFS_INSTANCES_ARRAY_SIZE]; 311 extern Clock_Ip_ClockMonitorType * const Clock_Ip_apxCmu[CLOCK_IP_CMU_INSTANCES_ARRAY_SIZE]; 312 extern Clock_Ip_NameType const Clock_Ip_aeCmuNames[CLOCK_IP_CMU_INSTANCES_ARRAY_SIZE]; 313 314 extern Clock_Ip_GprClockControlEnable_Type* const Clock_Ip_apxGprClockControlEnable[CLOCK_IP_PERIPHERAL_GROUPS_COUNT]; 315 316 extern const Clock_Ip_CmuInfoType Clock_Ip_axCmuInfo[CLOCK_IP_CMU_INFO_SIZE]; 317 318 extern const Clock_Ip_GateInfoType Clock_Ip_axGateInfo[CLOCK_IP_GATE_INFO_SIZE]; 319 320 extern const Clock_Ip_ClockExtensionType Clock_Ip_axFeatureExtensions[CLOCK_IP_EXTENSIONS_SIZE]; 321 322 #if defined(CLOCK_IP_HAS_SYSTEM_CLK) 323 extern Clock_Ip_SystemClockType* const Clock_Ip_apxSystemClock; 324 #endif 325 326 extern volatile uint32* const Clock_Ip_apxGprClkout[CLOCK_IP_GPR_INSTANCES_COUNT][CLOCK_IP_CLKOUTS_COUNT]; 327 328 /* Clock stop constant section data */ 329 #define MCU_STOP_SEC_CONST_UNSPECIFIED 330 #include "Mcu_MemMap.h" 331 332 /* Clock start constant section data */ 333 #define MCU_START_SEC_CONST_8 334 #include "Mcu_MemMap.h" 335 336 extern const uint8 Clock_Ip_au8SoftwareMuxResetValue[CLOCK_IP_FEATURE_NAMES_NO]; 337 338 /* Clock stop constant section data */ 339 #define MCU_STOP_SEC_CONST_8 340 #include "Mcu_MemMap.h" 341 342 343 /* Clock start constant section data */ 344 #define MCU_START_SEC_CONST_16 345 #include "Mcu_MemMap.h" 346 347 extern const uint16 Clock_Ip_au16SelectorEntryHardwareValue[CLOCK_IP_FEATURE_NAMES_NO]; 348 extern const uint16 Clock_Ip_au16SelectorEntryClkoutHardwareValue[CLOCK_IP_FEATURE_NAMES_NO]; 349 #ifdef CLOCK_IP_MC_ME_AE_GS_S_SYSCLK 350 extern const uint16 Clock_Ip_au16SelectorEntryAeHardwareValue[CLOCK_IP_FEATURE_NAMES_NO]; 351 #endif 352 /* Clock stop constant section data */ 353 #define MCU_STOP_SEC_CONST_16 354 #include "Mcu_MemMap.h" 355 356 357 358 /*================================================================================================== 359 * FUNCTION PROTOTYPES 360 ==================================================================================================*/ 361 362 /* Clock start section code */ 363 #define MCU_START_SEC_CODE 364 365 #include "Mcu_MemMap.h" 366 367 void Clock_Ip_McMeEnterKey(void); 368 369 /* Clock stop section code */ 370 #define MCU_STOP_SEC_CODE 371 372 #include "Mcu_MemMap.h" 373 374 #ifdef __cplusplus 375 } 376 #endif 377 378 /** @} */ 379 380 #endif /* CLOCK_IP_SPECIFIC_H */ 381 382