1 /*
2 * Copyright (c) 2012-2014, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the 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 "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /*
34 * ======== Watchdog.xs ========
35 *
36 */
38 var Watchdog = null;
39 var Core = null;
40 var MultiProc = null;
41 var Task = null;
42 var Swi = null;
43 var taskHook = null;
44 var swiHook = null;
45 var catalogName = null;
47 if (xdc.om.$name == "cfg" || typeof(genCdoc) != "undefined") {
48 var deviceTable = {
49 "ti.catalog.c6000": {
50 "OMAP5430": {
51 wdtimer: [
52 {
53 name: "WdTimerDsp", /* GpTimer 6 */
54 baseAddr: 0x01d3A000,
55 clkCtrl: 0x4A004570, /* Virtual address */
56 intNum: 15,
57 eventId: 52,
58 },
59 ]
60 },
61 "DRA7XX": {
62 wdtimer: [
63 {
64 name: "WdTimerDsp", /* GpTimer 10 */
65 baseAddr: 0x48086000, /* Virtual address */
66 clkCtrl: 0x4A009728, /* Virtual address */
67 intNum: 15,
68 eventId: 72,
69 },
70 ]
71 },
72 },
73 "ti.catalog.arm.cortexm4": {
74 "OMAP5430": {
75 wdtimer: [
76 {
77 name: "WdTimerCore0", /* GpTimer 9 */
78 baseAddr: 0xA803E000, /* Virtual address */
79 clkCtrl: 0xAA009450, /* Virtual address */
80 intNum: 55,
81 eventId: -1,
82 },
83 {
84 name: "WdTimerCore1", /* GpTimer 11 */
85 baseAddr: 0xA8088000, /* Virtual address */
86 clkCtrl: 0xAA009430, /* Virtual address */
87 intNum: 56,
88 eventId: -1,
89 },
90 ]
91 },
92 "DRA7XX": {
93 wdtimer: [
94 {
95 name: "WdTimerCore0", /* GpTimer 9 */
96 baseAddr: 0x6803E000, /* Virtual address */
97 clkCtrl: 0x6A009750, /* Virtual address */
98 intNum: 55,
99 eventId: -1,
100 },
101 {
102 name: "WdTimerCore1", /* GpTimer 4 */
103 baseAddr: 0x68036000, /* Virtual address */
104 clkCtrl: 0x6A009748, /* Virtual address */
105 intNum: 54,
106 eventId: -1,
107 },
108 ]
109 },
110 },
111 };
112 }
114 /*
115 * ======== module$meta$init ========
116 */
117 function module$meta$init()
118 {
119 /* Only process during "cfg" phase */
120 if (xdc.om.$name != "cfg") {
121 return;
122 }
124 Watchdog = this;
126 catalogName = Program.cpu.catalogName;
128 /* Loop through the device table */
129 /* TODO: This lookup table can be replaced to use the dmTimer module
130 * later on, and eliminate the need for this device table */
131 for (deviceName in deviceTable[catalogName]) {
132 if (deviceName == Program.cpu.deviceName) {
133 var device = deviceTable[catalogName][deviceName].wdtimer;
135 Watchdog.timerSettings.length = device.length;
136 for (var i = 0; i < device.length; i++) {
137 Watchdog.timerSettings[i].baseAddr = null;
138 Watchdog.timerSettings[i].clkCtrl = null;
139 Watchdog.timerSettings[i].intNum = device[i].intNum;
140 Watchdog.timerSettings[i].eventId = device[i].eventId;
141 }
143 return;
144 }
145 }
147 /* Falls through on failure */
148 print("Watchdog Timer configuration is not found for the specified device ("
149 + Program.cpu.deviceName + ").");
151 for (device in deviceTable[catalogName]) {
152 print("\t" + device);
153 }
155 throw new Error ("Watchdog Timer unsupported on device!");
156 }
158 /*
159 * ======== module$use ========
160 */
161 function module$use()
162 {
163 var Settings = xdc.module("ti.sysbios.family.Settings");
164 var Hwi = xdc.useModule(Settings.getDefaultHwiDelegate());
166 xdc.useModule('xdc.runtime.System');
168 if (Program.platformName.match(/IPU/) ||
169 Program.platformName.match(/ipu/)) {
170 Core = xdc.module("ti.sysbios.hal.Core");
171 }
172 else {
173 MultiProc = xdc.module('ti.sdo.utils.MultiProc');
174 if (Program.platformName.match(/DSP/)) {
175 xdc.useModule('ti.sysbios.family.c64p.tesla.Wugen');
176 }
177 }
179 Task = xdc.useModule('ti.sysbios.knl.Task');
180 taskHook = new Task.HookSet;
182 Swi = xdc.useModule('ti.sysbios.knl.Swi');
183 swiHook = new Swi.HookSet;
184 }
186 /*
187 * ======== module$static$init ========
188 */
189 function module$static$init(mod, params)
190 {
191 var device = deviceTable[catalogName][Program.cpu.deviceName].wdtimer;
193 swiHook.beginFxn = this.swiPrehook;
194 Swi.addHookSet(swiHook);
196 taskHook.switchFxn = this.taskSwitch;
197 Task.addHookSet(taskHook);
199 /* Assign default values if not supplied through configuration */
200 for (var i = 0; i < device.length; i++) {
201 if (Watchdog.timerSettings[i].baseAddr == null) {
202 Watchdog.timerSettings[i].baseAddr = $addr(device[i].baseAddr);
203 }
204 if (Watchdog.timerSettings[i].clkCtrl == null) {
205 Watchdog.timerSettings[i].clkCtrl = $addr(device[i].clkCtrl);
206 }
207 }
209 mod.device.length = 1;
210 mod.status.length = 1;
211 mod.wdtCores = 1;
212 if (Program.build.target.name.match(/C64T/) ||
213 Program.build.target.name.match(/C66/)) {
214 mod.device[0].baseAddr = Watchdog.timerSettings[0].baseAddr;
215 mod.device[0].clkCtrl = Watchdog.timerSettings[0].clkCtrl;
216 mod.device[0].intNum = Watchdog.timerSettings[0].intNum;
217 mod.device[0].eventId = Watchdog.timerSettings[0].eventId;
218 mod.status[0] = Watchdog.Mode_DISABLED;
219 }
220 else {
221 if (Program.platformName.match(/IPU/) ||
222 Program.platformName.match(/ipu/)) {
223 mod.device.length = Core.numCores;
224 mod.status.length = Core.numCores;
225 mod.wdtCores = Core.numCores;
227 mod.device[0].baseAddr = Watchdog.timerSettings[0].baseAddr;
228 mod.device[0].clkCtrl = Watchdog.timerSettings[0].clkCtrl;
229 mod.device[0].intNum = Watchdog.timerSettings[0].intNum;
230 mod.device[0].eventId = Watchdog.timerSettings[0].eventId;
231 mod.status[0] = Watchdog.Mode_DISABLED;
233 mod.device[1].baseAddr = Watchdog.timerSettings[1].baseAddr;
234 mod.device[1].clkCtrl = Watchdog.timerSettings[1].clkCtrl;
235 mod.device[1].intNum = Watchdog.timerSettings[1].intNum;
236 mod.device[1].eventId = Watchdog.timerSettings[1].eventId;
237 mod.status[1] = Watchdog.Mode_DISABLED;
238 }
239 else {
240 if (MultiProc.id == MultiProc.getIdMeta("CORE0")) {
241 mod.device[0].baseAddr = Watchdog.timerSettings[0].baseAddr;
242 mod.device[0].clkCtrl = Watchdog.timerSettings[0].clkCtrl;
243 mod.device[0].intNum = Watchdog.timerSettings[0].intNum;
244 mod.device[0].eventId = Watchdog.timerSettings[0].eventId;
245 }
246 else {
247 mod.device[0].baseAddr = Watchdog.timerSettings[1].baseAddr;
248 mod.device[0].clkCtrl = Watchdog.timerSettings[1].clkCtrl;
249 mod.device[0].intNum = Watchdog.timerSettings[1].intNum;
250 mod.device[0].eventId = Watchdog.timerSettings[1].eventId;
251 }
252 mod.status[0] = Watchdog.Mode_DISABLED;
253 }
254 }
255 }