Back to home page

LXR

 
 

    


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

0001 /*
0002  * Copyright (c) 2015, Freescale Semiconductor, Inc.
0003  * Copyright 2016-2017 NXP
0004  * All rights reserved.
0005  *
0006  * SPDX-License-Identifier: BSD-3-Clause
0007  */
0008 
0009 #include "fsl_dmamux.h"
0010 
0011 /*******************************************************************************
0012  * Definitions
0013  ******************************************************************************/
0014 
0015 /* Component ID definition, used by tools. */
0016 #ifndef FSL_COMPONENT_ID
0017 #define FSL_COMPONENT_ID "platform.drivers.dmamux"
0018 #endif
0019 
0020 /*******************************************************************************
0021  * Prototypes
0022  ******************************************************************************/
0023 
0024 /*!
0025  * @brief Get instance number for DMAMUX.
0026  *
0027  * @param base DMAMUX peripheral base address.
0028  */
0029 static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base);
0030 
0031 /*******************************************************************************
0032  * Variables
0033  ******************************************************************************/
0034 
0035 /*! @brief Array to map DMAMUX instance number to base pointer. */
0036 static DMAMUX_Type *const s_dmamuxBases[] = DMAMUX_BASE_PTRS;
0037 
0038 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
0039 /*! @brief Array to map DMAMUX instance number to clock name. */
0040 static const clock_ip_name_t s_dmamuxClockName[] = DMAMUX_CLOCKS;
0041 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
0042 
0043 /*******************************************************************************
0044  * Code
0045  ******************************************************************************/
0046 static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base)
0047 {
0048     uint32_t instance;
0049 
0050     /* Find the instance index from base address mappings. */
0051     for (instance = 0; instance < ARRAY_SIZE(s_dmamuxBases); instance++)
0052     {
0053         if (s_dmamuxBases[instance] == base)
0054         {
0055             break;
0056         }
0057     }
0058 
0059     assert(instance < ARRAY_SIZE(s_dmamuxBases));
0060 
0061     return instance;
0062 }
0063 
0064 /*!
0065  * brief Initializes the DMAMUX peripheral.
0066  *
0067  * This function ungates the DMAMUX clock.
0068  *
0069  * param base DMAMUX peripheral base address.
0070  *
0071  */
0072 void DMAMUX_Init(DMAMUX_Type *base)
0073 {
0074 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
0075     CLOCK_EnableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]);
0076 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
0077 }
0078 
0079 /*!
0080  * brief Deinitializes the DMAMUX peripheral.
0081  *
0082  * This function gates the DMAMUX clock.
0083  *
0084  * param base DMAMUX peripheral base address.
0085  */
0086 void DMAMUX_Deinit(DMAMUX_Type *base)
0087 {
0088 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
0089     CLOCK_DisableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]);
0090 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
0091 }