mbed library sources
Dependents: Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more
Superseded
This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/pl310.c@579:53297373a894, 2015-07-01 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Jul 01 09:45:11 2015 +0100
- Revision:
- 579:53297373a894
- Parent:
- 437:0b72c0f86db6
- Child:
- 626:ba773d547214
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081
Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/
Initial version of drivers for SAMR21
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 390:35c2c1cf29cd | 1 | /**************************************************************************//** |
mbed_official | 390:35c2c1cf29cd | 2 | * @file pl310.c |
mbed_official | 390:35c2c1cf29cd | 3 | * @brief Implementation of pl310 functions |
mbed_official | 390:35c2c1cf29cd | 4 | * @version |
mbed_official | 390:35c2c1cf29cd | 5 | * @date 11 June 2013 |
mbed_official | 390:35c2c1cf29cd | 6 | * |
mbed_official | 390:35c2c1cf29cd | 7 | * @note |
mbed_official | 390:35c2c1cf29cd | 8 | * |
mbed_official | 390:35c2c1cf29cd | 9 | ******************************************************************************/ |
mbed_official | 390:35c2c1cf29cd | 10 | /* Copyright (c) 2011 - 2013 ARM LIMITED |
mbed_official | 390:35c2c1cf29cd | 11 | |
mbed_official | 390:35c2c1cf29cd | 12 | All rights reserved. |
mbed_official | 390:35c2c1cf29cd | 13 | Redistribution and use in source and binary forms, with or without |
mbed_official | 390:35c2c1cf29cd | 14 | modification, are permitted provided that the following conditions are met: |
mbed_official | 390:35c2c1cf29cd | 15 | - Redistributions of source code must retain the above copyright |
mbed_official | 390:35c2c1cf29cd | 16 | notice, this list of conditions and the following disclaimer. |
mbed_official | 390:35c2c1cf29cd | 17 | - Redistributions in binary form must reproduce the above copyright |
mbed_official | 390:35c2c1cf29cd | 18 | notice, this list of conditions and the following disclaimer in the |
mbed_official | 390:35c2c1cf29cd | 19 | documentation and/or other materials provided with the distribution. |
mbed_official | 390:35c2c1cf29cd | 20 | - Neither the name of ARM nor the names of its contributors may be used |
mbed_official | 390:35c2c1cf29cd | 21 | to endorse or promote products derived from this software without |
mbed_official | 390:35c2c1cf29cd | 22 | specific prior written permission. |
mbed_official | 390:35c2c1cf29cd | 23 | * |
mbed_official | 390:35c2c1cf29cd | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 390:35c2c1cf29cd | 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 390:35c2c1cf29cd | 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 390:35c2c1cf29cd | 27 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbed_official | 390:35c2c1cf29cd | 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbed_official | 390:35c2c1cf29cd | 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbed_official | 390:35c2c1cf29cd | 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbed_official | 390:35c2c1cf29cd | 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbed_official | 390:35c2c1cf29cd | 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbed_official | 390:35c2c1cf29cd | 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 390:35c2c1cf29cd | 34 | POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 390:35c2c1cf29cd | 35 | ---------------------------------------------------------------------------*/ |
mbed_official | 390:35c2c1cf29cd | 36 | #include "MBRZA1H.h" |
mbed_official | 390:35c2c1cf29cd | 37 | |
mbed_official | 390:35c2c1cf29cd | 38 | //Cache Sync operation |
mbed_official | 390:35c2c1cf29cd | 39 | void PL310_Sync(void) |
mbed_official | 390:35c2c1cf29cd | 40 | { |
mbed_official | 390:35c2c1cf29cd | 41 | PL310->CACHE_SYNC = 0x0; |
mbed_official | 390:35c2c1cf29cd | 42 | } |
mbed_official | 390:35c2c1cf29cd | 43 | |
mbed_official | 390:35c2c1cf29cd | 44 | //return Cache controller cache ID |
mbed_official | 390:35c2c1cf29cd | 45 | int PL310_GetID (void) |
mbed_official | 390:35c2c1cf29cd | 46 | { |
mbed_official | 390:35c2c1cf29cd | 47 | return PL310->CACHE_ID; |
mbed_official | 390:35c2c1cf29cd | 48 | } |
mbed_official | 390:35c2c1cf29cd | 49 | |
mbed_official | 390:35c2c1cf29cd | 50 | //return Cache controller cache Type |
mbed_official | 390:35c2c1cf29cd | 51 | int PL310_GetType (void) |
mbed_official | 390:35c2c1cf29cd | 52 | { |
mbed_official | 390:35c2c1cf29cd | 53 | return PL310->CACHE_TYPE; |
mbed_official | 390:35c2c1cf29cd | 54 | } |
mbed_official | 390:35c2c1cf29cd | 55 | |
mbed_official | 390:35c2c1cf29cd | 56 | //Invalidate all cache by way |
mbed_official | 390:35c2c1cf29cd | 57 | void PL310_InvAllByWay (void) |
mbed_official | 390:35c2c1cf29cd | 58 | { |
mbed_official | 390:35c2c1cf29cd | 59 | unsigned int assoc; |
mbed_official | 390:35c2c1cf29cd | 60 | |
mbed_official | 390:35c2c1cf29cd | 61 | if (PL310->AUX_CNT & (1<<16)) |
mbed_official | 390:35c2c1cf29cd | 62 | assoc = 16; |
mbed_official | 390:35c2c1cf29cd | 63 | else |
mbed_official | 390:35c2c1cf29cd | 64 | assoc = 8; |
mbed_official | 390:35c2c1cf29cd | 65 | |
mbed_official | 390:35c2c1cf29cd | 66 | PL310->INV_WAY = (1 << assoc) - 1; |
mbed_official | 437:0b72c0f86db6 | 67 | while(PL310->INV_WAY & ((1 << assoc) - 1)); //poll invalidate |
mbed_official | 390:35c2c1cf29cd | 68 | |
mbed_official | 390:35c2c1cf29cd | 69 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 70 | } |
mbed_official | 390:35c2c1cf29cd | 71 | |
mbed_official | 390:35c2c1cf29cd | 72 | //Clean and Invalidate all cache by way |
mbed_official | 390:35c2c1cf29cd | 73 | void PL310_CleanInvAllByWay (void) |
mbed_official | 390:35c2c1cf29cd | 74 | { |
mbed_official | 390:35c2c1cf29cd | 75 | unsigned int assoc; |
mbed_official | 390:35c2c1cf29cd | 76 | |
mbed_official | 390:35c2c1cf29cd | 77 | if (PL310->AUX_CNT & (1<<16)) |
mbed_official | 390:35c2c1cf29cd | 78 | assoc = 16; |
mbed_official | 390:35c2c1cf29cd | 79 | else |
mbed_official | 390:35c2c1cf29cd | 80 | assoc = 8; |
mbed_official | 390:35c2c1cf29cd | 81 | |
mbed_official | 390:35c2c1cf29cd | 82 | PL310->CLEAN_INV_WAY = (1 << assoc) - 1; |
mbed_official | 390:35c2c1cf29cd | 83 | while(PL310->CLEAN_INV_WAY && ((1 << assoc) - 1)); //poll invalidate |
mbed_official | 390:35c2c1cf29cd | 84 | |
mbed_official | 390:35c2c1cf29cd | 85 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 86 | } |
mbed_official | 390:35c2c1cf29cd | 87 | |
mbed_official | 390:35c2c1cf29cd | 88 | //Enable Cache |
mbed_official | 390:35c2c1cf29cd | 89 | void PL310_Enable(void) |
mbed_official | 390:35c2c1cf29cd | 90 | { |
mbed_official | 390:35c2c1cf29cd | 91 | PL310->CONTROL = 0; |
mbed_official | 437:0b72c0f86db6 | 92 | PL310->INTERRUPT_CLEAR = 0x000001FFuL; |
mbed_official | 390:35c2c1cf29cd | 93 | PL310->DEBUG_CONTROL = 0; |
mbed_official | 390:35c2c1cf29cd | 94 | PL310->DATA_LOCK_0_WAY = 0; |
mbed_official | 390:35c2c1cf29cd | 95 | PL310->CACHE_SYNC = 0; |
mbed_official | 390:35c2c1cf29cd | 96 | |
mbed_official | 390:35c2c1cf29cd | 97 | PL310->CONTROL = 0x01; |
mbed_official | 390:35c2c1cf29cd | 98 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 99 | } |
mbed_official | 390:35c2c1cf29cd | 100 | //Disable Cache |
mbed_official | 390:35c2c1cf29cd | 101 | void PL310_Disable(void) |
mbed_official | 390:35c2c1cf29cd | 102 | { |
mbed_official | 390:35c2c1cf29cd | 103 | PL310->CONTROL = 0x00; |
mbed_official | 390:35c2c1cf29cd | 104 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 105 | } |
mbed_official | 390:35c2c1cf29cd | 106 | |
mbed_official | 390:35c2c1cf29cd | 107 | //Invalidate cache by physical address |
mbed_official | 390:35c2c1cf29cd | 108 | void PL310_InvPa (void *pa) |
mbed_official | 390:35c2c1cf29cd | 109 | { |
mbed_official | 390:35c2c1cf29cd | 110 | PL310->INV_LINE_PA = (unsigned int)pa; |
mbed_official | 390:35c2c1cf29cd | 111 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 112 | } |
mbed_official | 390:35c2c1cf29cd | 113 | |
mbed_official | 390:35c2c1cf29cd | 114 | //Clean cache by physical address |
mbed_official | 390:35c2c1cf29cd | 115 | void PL310_CleanPa (void *pa) |
mbed_official | 390:35c2c1cf29cd | 116 | { |
mbed_official | 390:35c2c1cf29cd | 117 | PL310->CLEAN_LINE_PA = (unsigned int)pa; |
mbed_official | 390:35c2c1cf29cd | 118 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 119 | } |
mbed_official | 390:35c2c1cf29cd | 120 | |
mbed_official | 390:35c2c1cf29cd | 121 | //Clean and invalidate cache by physical address |
mbed_official | 390:35c2c1cf29cd | 122 | void PL310_CleanInvPa (void *pa) |
mbed_official | 390:35c2c1cf29cd | 123 | { |
mbed_official | 390:35c2c1cf29cd | 124 | PL310->CLEAN_INV_LINE_PA = (unsigned int)pa; |
mbed_official | 390:35c2c1cf29cd | 125 | PL310_Sync(); |
mbed_official | 390:35c2c1cf29cd | 126 | } |
mbed_official | 390:35c2c1cf29cd | 127 | |
mbed_official | 390:35c2c1cf29cd | 128 |