1 /* 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * o Redistributions of source code must retain the above copyright notice, this list 9 * of conditions and the following disclaimer. 10 * 11 * o Redistributions in binary form must reproduce the above copyright notice, this 12 * list of conditions and the following disclaimer in the documentation and/or 13 * other materials provided with the distribution. 14 * 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from this 17 * software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef __RDC_SEMAPHORE_H__ 32 #define __RDC_SEMAPHORE_H__ 33 34 #include <stdint.h> 35 #include <stdbool.h> 36 #include "device_imx.h" 37 38 /*! 39 * @addtogroup rdc_semaphore_driver 40 * @{ 41 */ 42 43 /******************************************************************************* 44 * Definitions 45 ******************************************************************************/ 46 #define RDC_SEMAPHORE_MASTER_NONE (0xFF) 47 48 /*! @brief RDC Semaphore status return codes. */ 49 typedef enum _rdc_semaphore_status 50 { 51 statusRdcSemaphoreSuccess = 0U, /*!< Success. */ 52 statusRdcSemaphoreBusy = 1U, /*!< RDC semaphore has been locked by other processor. */ 53 } rdc_semaphore_status_t; 54 55 /******************************************************************************* 56 * API 57 ******************************************************************************/ 58 59 #if defined(__cplusplus) 60 extern "C" { 61 #endif 62 63 /*! 64 * @name RDC_SEMAPHORE State Control 65 * @{ 66 */ 67 68 /*! 69 * @brief Lock RDC semaphore for shared peripheral access 70 * 71 * @param pdap RDC peripheral assignment (see @ref _rdc_pdap in rdc_defs_<device>.h) 72 * @retval statusRdcSemaphoreSuccess Lock the semaphore successfully. 73 * @retval statusRdcSemaphoreBusy Semaphore has been locked by other processor. 74 */ 75 rdc_semaphore_status_t RDC_SEMAPHORE_TryLock(uint32_t pdap); 76 77 /*! 78 * @brief Lock RDC semaphore for shared peripheral access, polling until success. 79 * 80 * @param pdap RDC peripheral assignment (see @ref _rdc_pdap in rdc_defs_<device>.h) 81 */ 82 void RDC_SEMAPHORE_Lock(uint32_t pdap); 83 84 /*! 85 * @brief Unlock RDC semaphore 86 * 87 * @param pdap RDC peripheral assignment (see @ref _rdc_pdap in rdc_defs_<device>.h) 88 */ 89 void RDC_SEMAPHORE_Unlock(uint32_t pdap); 90 91 /*! 92 * @brief Get domain ID which locks the semaphore 93 * 94 * @param pdap RDC peripheral assignment (see @ref _rdc_pdap in rdc_defs_<device>.h) 95 * @return domain ID which locks the RDC semaphore 96 */ 97 uint32_t RDC_SEMAPHORE_GetLockDomainID(uint32_t pdap); 98 99 /*! 100 * @brief Get master index which locks the semaphore 101 * 102 * @param pdap RDC peripheral assignment (see @ref _rdc_pdap in rdc_defs_<device>.h) 103 * @return master index which locks the RDC semaphore, or RDC_SEMAPHORE_MASTER_NONE 104 * to indicate it is not locked. 105 */ 106 uint32_t RDC_SEMAPHORE_GetLockMaster(uint32_t pdap); 107 108 /*@}*/ 109 110 /*! 111 * @name RDC_SEMAPHORE Reset Control 112 * @{ 113 */ 114 115 /*! 116 * @brief Reset RDC semaphore to unlocked status 117 * 118 * @param pdap RDC peripheral assignment (see @ref _rdc_pdap in rdc_defs_<device>.h) 119 */ 120 void RDC_SEMAPHORE_Reset(uint32_t pdap); 121 122 /*! 123 * @brief Reset all RDC semaphore to unlocked status for certain RDC_SEMAPHORE instance 124 * 125 * @param base RDC semaphore base pointer. 126 */ 127 void RDC_SEMAPHORE_ResetAll(RDC_SEMAPHORE_Type *base); 128 129 /*@}*/ 130 131 #if defined(__cplusplus) 132 } 133 #endif 134 135 /*! @}*/ 136 137 #endif /* __RDC_SEMAPHORE_H__ */ 138 /******************************************************************************* 139 * EOF 140 ******************************************************************************/ 141