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 __LMEM_H__
32 #define __LMEM_H__
33 
34 #include <stdint.h>
35 #include <assert.h>
36 #include "device_imx.h"
37 
38 /*!
39  * @addtogroup lmem_driver
40  * @{
41  */
42 
43 /*******************************************************************************
44  * API
45  ******************************************************************************/
46 
47 #if defined(__cplusplus)
48 extern "C" {
49 #endif
50 
51 /*!
52  * @name Processor System Cache control functions
53  * @{
54  */
55 
56 /*!
57  * @brief This function enable the System Cache.
58  *
59  * @param base LMEM base pointer.
60  */
61 void LMEM_EnableSystemCache(LMEM_Type *base);
62 
63 /*!
64  * @brief This function disable the System Cache.
65  *
66  * @param base LMEM base pointer.
67  */
68 void LMEM_DisableSystemCache(LMEM_Type *base);
69 
70 /*!
71  * @brief This function flush the System Cache.
72  *
73  * @param base LMEM base pointer.
74  */
75 void LMEM_FlushSystemCache(LMEM_Type *base);
76 
77 /*!
78  * @brief This function is called to flush the System Cache by performing cache copy-backs.
79  *        It must determine how many cache lines need to be copied back and then
80  *        perform the copy-backs.
81  *
82  * @param base LMEM base pointer.
83  * @param address The start address of cache line.
84  * @param length The length of flush address space.
85  */
86 void LMEM_FlushSystemCacheLines(LMEM_Type *base, void *address, uint32_t length);
87 
88 /*!
89  * @brief This function invalidate the System Cache.
90  *
91  * @param base LMEM base pointer.
92  */
93 void LMEM_InvalidateSystemCache(LMEM_Type *base);
94 
95 /*!
96  * @brief This function is responsible for performing an System Cache invalidate.
97  *        It must determine how many cache lines need to be invalidated and then
98  *        perform the invalidation.
99  *
100  * @param base LMEM base pointer.
101  * @param address The start address of cache line.
102  * @param length The length of invalidate address space.
103  */
104 void LMEM_InvalidateSystemCacheLines(LMEM_Type *base, void *address, uint32_t length);
105 
106 /*@}*/
107 
108 /*!
109  * @name Processor Code Cache control functions
110  * @{
111  */
112 
113 /*!
114  * @brief This function enable the Code Cache.
115  *
116  * @param base LMEM base pointer.
117  */
118 void LMEM_EnableCodeCache(LMEM_Type *base);
119 
120 /*!
121  * @brief This function disable the Code Cache.
122  *
123  * @param base LMEM base pointer.
124  */
125 void LMEM_DisableCodeCache(LMEM_Type *base);
126 
127 /*!
128  * @brief This function flush the Code Cache.
129  *
130  * @param base LMEM base pointer.
131  */
132 void LMEM_FlushCodeCache(LMEM_Type *base);
133 
134 /*!
135  * @brief This function is called to flush the Code Cache by performing cache copy-backs.
136  *        It must determine how many cache lines need to be copied back and then
137  *        perform the copy-backs.
138  *
139  * @param base LMEM base pointer.
140  * @param address The start address of cache line.
141  * @param length The length of flush address space.
142  */
143 void LMEM_FlushCodeCacheLines(LMEM_Type *base, void *address, uint32_t length);
144 
145 /*!
146  * @brief This function invalidate the Code Cache.
147  *
148  * @param base LMEM base pointer.
149  */
150 void LMEM_InvalidateCodeCache(LMEM_Type *base);
151 
152 /*!
153  * @brief This function is responsible for performing an Code Cache invalidate.
154  *        It must determine how many cache lines need to be invalidated and then
155  *        perform the invalidation.
156  *
157  * @param base LMEM base pointer.
158  * @param address The start address of cache line.
159  * @param length The length of invalidate address space.
160  */
161 void LMEM_InvalidateCodeCacheLines(LMEM_Type *base, void *address, uint32_t length);
162 
163 /*@}*/
164 
165 #if defined(__cplusplus)
166 }
167 #endif
168 
169 /*! @}*/
170 
171 #endif /* __LMEM_H__ */
172 /*******************************************************************************
173  * EOF
174  ******************************************************************************/
175