1 /**************************************************************************//**
3 * @brief Implementation of pl310 functions
9 ******************************************************************************/
10 /* Copyright (c) 2011 - 2013 ARM LIMITED
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 - Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 - Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 - Neither the name of ARM nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 ---------------------------------------------------------------------------*/
38 //Cache Sync operation
41 PL310->CACHE_SYNC = 0x0;
44 //return Cache controller cache ID
45 int PL310_GetID (void)
47 return PL310->CACHE_ID;
50 //return Cache controller cache Type
51 int PL310_GetType (void)
53 return PL310->CACHE_TYPE;
56 //Invalidate all cache by way
57 void PL310_InvAllByWay (void)
61 if (PL310->AUX_CNT & (1<<16))
66 PL310->INV_WAY = (1 << assoc) - 1;
67 while(PL310->INV_WAY & ((1 << assoc) - 1)); //poll invalidate
72 //Clean and Invalidate all cache by way
73 void PL310_CleanInvAllByWay (void)
77 if (PL310->AUX_CNT & (1<<16))
82 PL310->CLEAN_INV_WAY = (1 << assoc) - 1;
83 while(PL310->CLEAN_INV_WAY && ((1 << assoc) - 1)); //poll invalidate
89 void PL310_Enable(void)
92 PL310->INTERRUPT_CLEAR = 0x000001FFuL;
93 PL310->DEBUG_CONTROL = 0;
94 PL310->DATA_LOCK_0_WAY = 0;
95 PL310->CACHE_SYNC = 0;
97 PL310->CONTROL = 0x01;
101 void PL310_Disable(void)
103 PL310->CONTROL = 0x00;
107 //Invalidate cache by physical address
108 void PL310_InvPa (void *pa)
110 PL310->INV_LINE_PA = (unsigned int)pa;
114 //Clean cache by physical address
115 void PL310_CleanPa (void *pa)
117 PL310->CLEAN_LINE_PA = (unsigned int)pa;
121 //Clean and invalidate cache by physical address
122 void PL310_CleanInvPa (void *pa)
124 PL310->CLEAN_INV_LINE_PA = (unsigned int)pa;