[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1_0_eng / packages / ti / board / src / idkAM571x / idkAM571x.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(OPP_NOM);
90 else if(cfg & BOARD_INIT_PLL_OPP_HIGH)
91 ret = Board_PLLInit(OPP_HIGH);
92 else if(cfg & BOARD_INIT_PLL_OPP_OD)
93 ret = Board_PLLInit(OPP_OD);
94 else if(cfg & BOARD_INIT_PLL_OPP_NOM)
95 ret = Board_PLLInit(OPP_NOM);
96 if (ret != BOARD_SOK)
97 return ret;
99 if (cfg & BOARD_INIT_MODULE_CLOCK)
100 ret = Board_moduleClockInit();
101 if (ret != BOARD_SOK)
102 return ret;
104 if (cfg & BOARD_INIT_DDR)
105 ret = Board_DDR3Init();
106 if (ret != BOARD_SOK)
107 return ret;
109 if (cfg & BOARD_INIT_WATCHDOG_DISABLE)
110 ret = Board_watchdogDisable();
111 if (ret != BOARD_SOK)
112 return ret;
114 if (cfg & BOARD_INIT_PINMUX_CONFIG)
115 ret = Board_pinmuxConfig();
116 if (ret != BOARD_SOK)
117 return ret;
119 if (cfg & BOARD_INIT_UART_STDIO)
120 ret = Board_uartStdioInit();
121 if (ret != BOARD_SOK)
122 return ret;
124 return ret;
125 }