[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / common / ti81xx / ti81xxducati / Dm8168DucatiMmu.c
1 /*
2 * @file Dm8168DucatiMmu.c
3 *
4 * @brief ducati mmu code
5 *
6 *
7 * ============================================================================
8 *
9 * Copyright (c) 2008-2012, Texas Instruments Incorporated
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * * Neither the name of Texas Instruments Incorporated nor the names of
23 * its contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
36 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * Contact information for paper mail:
38 * Texas Instruments
39 * Post Office Box 655303
40 * Dallas, Texas 75265
41 * Contact information:
42 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
43 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
44 * ============================================================================
45 *
46 */
50 #if defined(SYSLINK_BUILD_HLOS)
51 #include <ti/syslink/Std.h>
52 /* OSAL & Utils headers */
53 #include <OsalDelay.h>
54 #endif /* #if defined(SYSLINK_BUILD_HLOS) */
56 #if defined(SYSLINK_BUILD_RTOS)
57 #include <xdc/std.h>
58 #endif /* #if defined(SYSLINK_BUILD_RTOS) */
61 #include <ti/syslink/utils/Trace.h>
62 #include <OsalThread.h>
64 #include <PwrDefs.h>
65 #include <PwrMgr.h>
66 #include <Dm8168DucatiPwr.h>
67 #include <ti/syslink/inc/knl/Linux/Dm8168DucatiMmu.h>
68 #include <ti/syslink/inc/Bitops.h>
70 #define REG(x) *((volatile UInt32 *) (x))
73 #define RM_DEFAULT_RSTCTRL 0x00000B10
74 #define RM_DEFAULT_RSTST 0x00000B14
75 #define CM_DEFAULT_DUCATI_CLKSTCTRL 0x00000518
76 #define CM_DEFAULT_DUCATI_CLKCTRL 0x00000574
79 #if defined (__cplusplus)
80 extern "C" {
81 #endif
83 /* =============================================================================
84 * Macros and types
85 * =============================================================================
86 */
89 Void DM8168DUCATIMMU_enable(PwrMgr_Handle handle)
90 {
91 PwrMgr_Object * pwrMgrHandle = (PwrMgr_Object *) handle;
92 DM8168DUCATIPWR_Object * object = NULL;
94 GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIMMU_enable", handle);
96 GT_assert (curTrace, (handle != NULL));
98 #if !defined(SYSLINK_BUILD_OPTIMIZE)
99 if (handle == NULL) {
100 /*! @retval PWRMGR_E_HANDLE Invalid argument */
101 GT_setFailureReason (curTrace,
102 GT_4CLASS,
103 "DM8168DUCATIMMU_enable",
104 PWRMGR_E_FAIL,
105 "Invalid handle specified");
106 }
107 else {
108 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
109 object = (DM8168DUCATIPWR_Object *) pwrMgrHandle->object;
110 GT_assert (curTrace, (object != NULL));
112 /*Enable the Ducati Logic*/
113 CLEAR_BIT(REG(object->prcmVA + RM_DEFAULT_RSTCTRL), 0x4);
114 while((((REG(object->prcmVA + RM_DEFAULT_RSTST)&0x10))!=0x10));
115 #if defined(SYSLINK_VARIANT_TI814X) || \
116 defined(SYSLINK_VARIANT_TI813X) || \
117 defined(SYSLINK_VARIANT_TI811X)
118 /* This delay is required only in case of centaurus*/
119 // OsalDelay_udelay(2);
120 OsalThread_delay(2); //2ms sec delay
121 #endif
122 /* Write a while(1) so that even if m3 comes out of reset
123 * m3 wont crash */
124 REG(object->ducatibaseVA) = 0x10000;
125 REG(object->ducatibaseVA + 0x04) = 0x9;
126 REG(object->ducatibaseVA + 0x08) = 0xE7FEE7FE;
128 /* M3_0 and M3_1 should be taken out of reset after this
129 and that is done is reset code*/
131 #if !defined(SYSLINK_BUILD_OPTIMIZE)
133 }
134 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
135 GT_0trace (curTrace, GT_LEAVE, "DM8168DUCATIMMU_enable");
136 }
139 Void DM8168DUCATIMMU_disable(PwrMgr_Handle handle)
140 {
141 PwrMgr_Object * pwrMgrHandle = (PwrMgr_Object *) handle;
142 DM8168DUCATIPWR_Object * object = NULL;
144 GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIMMU_disable", handle);
146 GT_assert (curTrace, (handle != NULL));
148 #if !defined(SYSLINK_BUILD_OPTIMIZE)
149 if (handle == NULL) {
150 /*! @retval PWRMGR_E_HANDLE Invalid argument */
151 GT_setFailureReason (curTrace,
152 GT_4CLASS,
153 "DM8168DUCATIMMU_enable",
154 PWRMGR_E_FAIL,
155 "Invalid handle specified");
156 }
157 else {
158 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
159 object = (DM8168DUCATIPWR_Object *) pwrMgrHandle->object;
160 GT_assert (curTrace, (object != NULL));
162 /* This code is specific for apps to run */
163 REG(object->ducatibaseVA) = 0x10000;
164 REG(object->ducatibaseVA + 0x04) = 0x9;
165 REG(object->ducatibaseVA + 0x08) = 0xE7FEE7FE;
166 /* Flush the unicache so as to succeed in subsequent runs */
167 REG(object->ducatiMmuVA + 0x0CA8) = 0x400;
169 /* DO NOT Disable the Ducati Logic*/
171 #if !defined(SYSLINK_BUILD_OPTIMIZE)
173 }
174 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
175 GT_0trace (curTrace, GT_LEAVE, "DM8168DUCATIMMU_disable");
176 }
179 #if defined (__cplusplus)
180 }
181 #endif