[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1_0_eng / packages / ti / board / src / evmAM571x / evmAM571x.c
1 /******************************************************************************
2 * Copyright (c) 2010-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 Board_gblObj Board_obj;
38 Board_STATUS Board_unlockMMR(void)
39 {
40 CSL_control_coreRegs *ctrlCoreReg =
41 (CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS;
43 /* unlock MMR1 space for region 0x0100 to 0x079F */
44 ctrlCoreReg->MMR_LOCK_1 = 804367403U;
45 /* unlock MMR2 space for region 0x07A0 to 0x0D9F */
46 ctrlCoreReg->MMR_LOCK_2 = 4149738944U;
47 /* unlock MMR3 space for region 0x0DA0 to 0x0FFF */
48 ctrlCoreReg->MMR_LOCK_3 = 3803986541U;
49 /* unlock MMR4 space for region 0x1000 to 0x13FF */
50 ctrlCoreReg->MMR_LOCK_4 = 515838749U;
51 /* unlock MMR5 space for region 0x1400 to 0x1FFF */
52 ctrlCoreReg->MMR_LOCK_5 = 1865817605U;
54 return BOARD_SOK;
55 }
57 Board_STATUS Board_watchdogDisable()
58 {
59 CSL_watchdogocp2Regs *watchdogRegs = (CSL_watchdogocp2Regs *) CSL_MPU_WD_TIMER2_REGS;
61 /* Wait until reset complete */
62 while(CSL_WATCHDOGOCP2_WDST_RESETVAL !=
63 CSL_FEXT(watchdogRegs->WDST, WATCHDOGOCP2_WDST_RESETDONE));
65 /* Disable watchdog timer */
66 CSL_FINS(watchdogRegs->WSPR, WATCHDOGOCP2_WSPR_WSPR_VALUE, 0xAAAAU);
68 while(CSL_WATCHDOGOCP2_WWPS_W_PEND_WSPR_RESETVAL !=
69 CSL_FEXT(watchdogRegs->WWPS,WATCHDOGOCP2_WWPS_W_PEND_WSPR));
71 /* Disable 32Khz watchdog timer */
72 CSL_FINS(watchdogRegs->WSPR, WATCHDOGOCP2_WSPR_WSPR_VALUE, 0x5555U);
74 while(CSL_WATCHDOGOCP2_WWPS_W_PEND_WSPR_RESETVAL !=
75 CSL_FEXT(watchdogRegs->WWPS,WATCHDOGOCP2_WWPS_W_PEND_WSPR));
77 return BOARD_SOK;
78 }
80 Board_STATUS Board_init(Board_initCfg cfg)
81 {
82 Board_STATUS ret = BOARD_SOK;
83 if (cfg & BOARD_INIT_UNLOCK_MMR)
84 ret = Board_unlockMMR();
85 if (ret != BOARD_SOK)
86 return ret;
88 if (cfg & BOARD_INIT_PLL)
89 ret = Board_PLLInit();
90 if (ret != BOARD_SOK)
91 return ret;
93 if (cfg & BOARD_INIT_MODULE_CLOCK)
94 ret = Board_moduleClockInit();
95 if (ret != BOARD_SOK)
96 return ret;
98 if (cfg & BOARD_INIT_DDR)
99 ret = Board_DDR3Init();
100 if (ret != BOARD_SOK)
101 return ret;
103 if (cfg & BOARD_INIT_WATCHDOG_DISABLE)
104 ret = Board_watchdogDisable();
105 if (ret != BOARD_SOK)
106 return ret;
108 if (cfg & BOARD_INIT_PINMUX_CONFIG)
109 ret = Board_pinmuxConfig();
110 if (ret != BOARD_SOK)
111 return ret;
113 if (cfg & BOARD_INIT_UART_STDIO)
114 ret = Board_uartStdioInit();
115 if (ret != BOARD_SOK)
116 return ret;
118 return ret;
119 }