[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_1_eng / packages / ti / board / src / evmC6678 / evmC6678_ecc.c
1 /******************************************************************************
2 * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *****************************************************************************/
34 #include "board_internal.h"
36 /* Registers to enable or disable memory ECC for L1, L2 and MSMC memories */
37 #define L1PEDSTAT 0x01846404
38 #define L1PEDCMD 0x01846408
39 #define L1PEDADDR 0x0184640C
40 #define L2EDSTAT 0x01846004
41 #define L2EDCMD 0x01846008
42 #define L2EDADDR 0x0184600C
43 #define L2EDCPEC 0x01846018
44 #define L2EDCNEC 0x0184601C
45 #define L2EDCEN 0x01846030
46 #define SMCERRAR 0x0BC00008
47 #define SMCERRXR 0x0BC0000C
48 #define SMEDCC 0x0BC00010
49 #define SMCEA 0x0BC00014
50 #define SMSECC 0x0BC00018
53 /*Enable EDC on MSMC*/
54 /* Note: Once MSMC EDC is enabled, error correction stays enabled until
55 * the MSMC is reset
56 */
57 static int MSMC_enableEDC ()
58 {
59 unsigned int status = 0;
61 *(unsigned int *)(SMEDCC) &= 0x7FFFFFFF; //Clear SEN(bit31)=0
62 *(unsigned int *)(SMEDCC) |= 0x40000000; //Set ECM(bit30)=1
64 /* Check the status */
65 status = *(unsigned int *)(SMEDCC);
68 if ((status>>30)==0x1)
69 /* Enabled */
70 return 1;
72 /* Failed */
73 return 0;
74 }
77 /*Enable EDC on L1P*/
78 static int enableL1PEDC ()
79 {
80 unsigned int status = 0;
82 *(unsigned int *)(L1PEDCMD) = 0x1; //Set EN(bit0)=1
84 /* Check the status */
85 status = *(unsigned int *)(L1PEDSTAT);
87 if ((status<<28) == 0x10000000)
88 /* Enabled */
89 return 1;
91 /* Failed */
92 return 0;
93 }
96 /*Enable EDC on L2*/
97 static int enableL2EDC ()
98 {
99 unsigned int status = 0;
101 *(unsigned int *)(L2EDCMD) = 0x1;
103 /* Check the status */
104 status = *(unsigned int *)(L2EDSTAT);
106 if ((status<<28) == 0x10000000)
107 /* Enabled */
108 return 1;
110 /* Failed */
111 return 0;
112 }
114 /*Enable all bits in L2EDCEN*/
115 static int enableEDCL2EDCEN ()
116 {
117 /* Set DL2CEN(bit0),PL2CEN(bit1),DL2SEN(bit2),PL2SEN(bit3),SDMAEN(bit4)=1 */
118 *(unsigned int *)(L2EDCEN) |= 0x1F;
119 return 1;
120 }
122 Board_STATUS Board_eccInit()
123 {
124 enableL1PEDC();
125 enableEDCL2EDCEN();
126 enableL2EDC();
127 MSMC_enableEDC();
128 return BOARD_SOK;
129 }