Watchdog: DRA7XX: Fix Watchdog Timer13 BaseAddr
[ipc/ipcdev.git] / packages / ti / deh / Watchdog.xs
1 /*
2  * Copyright (c) 2012-2015, 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;
46 var timerIds = [];
48 if (xdc.om.$name == "cfg" || typeof(genCdoc) != "undefined") {
49     var deviceTable = {
50         "ti.catalog.c6000": {
51             "OMAP5430": {
52                 "GPTimer5": {
53                     name: "WdTimer5Dsp",    /* GpTimer 5 */
54                     baseAddr: 0x01D38000,
55                     clkCtrl: 0x4A004568,    /* Virtual address */
56                     intNum:  14,
57                     eventId: 51,
58                 },
59                 "GPTimer6": {
60                     name: "WdTimer6Dsp",    /* GpTimer 6 */
61                     baseAddr: 0x01D3A000,
62                     clkCtrl: 0x4A004570,    /* Virtual address */
63                     intNum:  15,
64                     eventId: 52,
65                 },
66                 "GPTimer7": {
67                     name: "WdTimer7Dsp",    /* GpTimer 7 */
68                     baseAddr: 0x01D3C000,
69                     clkCtrl: 0x4A004578,    /* Virtual address */
70                     intNum:  4,
71                     eventId: 53,
72                 },
73                 "GPTimer8": {
74                     name: "WdTimer8Dsp",    /* GpTimer 8 */
75                     baseAddr: 0x01D3E000,
76                     clkCtrl: 0x4A004580,    /* Virtual address */
77                     intNum:  5,
78                     eventId: 54,
79                 },
80                 "Default": [
81                     { name: "GPTimer6" },
82                 ]
83             },
84             "DRA7XX": {
85                 "GPTimer1": {
86                     name: "WdTimer1Dsp",    /* GpTimer 1 */
87                     baseAddr: 0x4AE18000,   /* Virtual address */
88                     clkCtrl: 0x4AE07840,    /* Virtual address */
89                     intNum:  14,
90                     eventId: 63,
91                 },
92                 "GPTimer2": {
93                     name: "WdTimer2Dsp",    /* GpTimer 2 */
94                     baseAddr: 0x48032000,   /* Virtual address */
95                     clkCtrl: 0x4A009738,    /* Virtual address */
96                     intNum:  15,
97                     eventId: 64,
98                 },
99                 "GPTimer3": {
100                     name: "WdTimer3Dsp",    /* GpTimer 3 */
101                     baseAddr: 0x48034000,   /* Virtual address */
102                     clkCtrl: 0x4A009740,    /* Virtual address */
103                     intNum:  14,
104                     eventId: 65,
105                 },
106                 "GPTimer4": {
107                     name: "WdTimer4Dsp",    /* GpTimer 4 */
108                     baseAddr: 0x48036000,   /* Virtual address */
109                     clkCtrl: 0x4A009748,    /* Virtual address */
110                     intNum:  15,
111                     eventId: 66,
112                 },
113                 "GPTimer5": {
114                     name: "WdTimer5Dsp",    /* GpTimer 5 */
115                     baseAddr: 0x48820000,   /* Virtual address */
116                     clkCtrl: 0x4a005558,    /* Virtual address */
117                     intNum:  14,
118                     eventId: 67,
119                 },
120                 "GPTimer6": {
121                     name: "WdTimer6Dsp",    /* GpTimer 6 */
122                     baseAddr: 0x48822000,   /* Virtual address */
123                     clkCtrl: 0x4A005560,    /* Virtual address */
124                     intNum:  15,
125                     eventId: 68,
126                 },
127                 "GPTimer7": {
128                     name: "WdTimer7Dsp",    /* GpTimer 7 */
129                     baseAddr: 0x48824000,   /* Virtual address */
130                     clkCtrl: 0x4A005568,    /* Virtual address */
131                     intNum:  14,
132                     eventId: 69,
133                 },
134                 "GPTimer8": {
135                     name: "WdTimer8Dsp",    /* GpTimer 8 */
136                     baseAddr: 0x48826000,   /* Virtual address */
137                     clkCtrl: 0x4A005570,    /* Virtual address */
138                     intNum:  15,
139                     eventId: 70,
140                 },
141                 "GPTimer9": {
142                     name: "WdTimer9Dsp",    /* GpTimer 9 */
143                     baseAddr: 0x4803E000,   /* Virtual address */
144                     clkCtrl: 0x4A009750,    /* Virtual address */
145                     intNum:  14,
146                     eventId: 71,
147                 },
148                 "GPTimer10": {
149                     name: "WdTimer10Dsp",   /* GpTimer 10 */
150                     baseAddr: 0x48086000,   /* Virtual address */
151                     clkCtrl: 0x4A009728,    /* Virtual address */
152                     intNum:  15,
153                     eventId: 72,
154                 },
155                 "GPTimer11": {
156                     name: "WdTimer11Dsp",   /* GpTimer 11 */
157                     baseAddr: 0x48088000,   /* Virtual address */
158                     clkCtrl: 0x4A009730,    /* Virtual address */
159                     intNum:  14,
160                     eventId: 73,
161                 },
162                 "GPTimer12": {
163                     name: "WdTimer12Dsp",   /* GpTimer 12 */
164                     baseAddr: 0x4AE20000,   /* Virtual address */
165                     clkCtrl: 0x4AE07848,    /* Virtual address */
166                     intNum:  -1,
167                     eventId: 75,
168                 },
169                 "GPTimer13": {
170                     name: "WdTimer13Dsp",   /* GpTimer 13 */
171                     baseAddr: 0x48828000,   /* Virtual address */
172                     clkCtrl: 0x4A0097C8,    /* Virtual address */
173                     intNum:  -1,
174                     eventId: 76,
175                 },
176                 "GPTimer14": {
177                     name: "WdTimer14Dsp",   /* GpTimer 14 */
178                     baseAddr: 0x4882A000,   /* Virtual address */
179                     clkCtrl: 0x4A0097D0,    /* Virtual address */
180                     intNum:  -1,
181                     eventId: 77,
182                 },
183                 "GPTimer15": {
184                     name: "WdTimer15Dsp",   /* GpTimer 15 */
185                     baseAddr: 0x4882C000,   /* Virtual address */
186                     clkCtrl: 0x4A0097D8,    /* Virtual address */
187                     intNum:  -1,
188                     eventId: 78,
189                 },
190                 "GPTimer16": {
191                     name: "WdTimer16Dsp",   /* GpTimer 16 */
192                     baseAddr: 0x4882E000,   /* Virtual address */
193                     clkCtrl: 0x4A009830,    /* Virtual address */
194                     intNum:  -1,
195                     eventId: 81,
196                 },
197                 "Default": [
198                     { name: "GPTimer10" },
199                 ]
200             },
201         },
202         "ti.catalog.arm.cortexm4": {
203             "OMAP5430": {
204                 "GPTimer3": {
205                     name: "WdTimer3Ipu",    /* GpTimer 3 */
206                     baseAddr: 0xA8034000,   /* Virtual address */
207                     clkCtrl: 0xAA009040,    /* Virtual address */
208                     intNum:  53,
209                     eventId: -1,
210                 },
211                 "GPTimer4": {
212                     name: "WdTimer4Ipu",    /* GpTimer 4 */
213                     baseAddr: 0xA8036000,   /* Virtual address */
214                     clkCtrl: 0xAA009048,    /* Virtual address */
215                     intNum:  54,
216                     eventId: -1,
217                 },
218                 "GPTimer9": {
219                     name: "WdTimer9Ipu",    /* GpTimer 9 */
220                     baseAddr: 0xA803E000,   /* Virtual address */
221                     clkCtrl: 0xAA009050,    /* Virtual address */
222                     intNum:  55,
223                     eventId: -1,
224                 },
225                 "GPTimer11": {
226                     name: "WdTimer11Ipu",   /* GpTimer 11 */
227                     baseAddr: 0xA8088000,   /* Virtual address */
228                     clkCtrl: 0xAA009030,    /* Virtual address */
229                     intNum:  56,
230                     eventId: -1,
231                 },
232                 "Default": [
233                     { name: "GPTimer9" },
234                     { name: "GPTimer11" },
235                 ]
236             },
237             "DRA7XX": {
238                 "GPTimer1": {
239                     name: "WdTimer1Ipu",    /* GpTimer 1 */
240                     baseAddr: 0x6AE18000,   /* Virtual address */
241                     clkCtrl: 0x6AE07840,    /* Virtual address */
242                     intNum:  -1,
243                     eventId: -1,
244                 },
245                 "GPTimer2": {
246                     name: "WdTimer2Ipu",    /* GpTimer 2 */
247                     baseAddr: 0x68032000,   /* Virtual address */
248                     clkCtrl: 0x6A009738,    /* Virtual address */
249                     intNum:  -1,
250                     eventId: -1,
251                 },
252                 "GPTimer3": {
253                     name: "WdTimer3Ipu",    /* GpTimer 3 */
254                     baseAddr: 0x68034000,   /* Virtual address */
255                     clkCtrl: 0x6A009740,    /* Virtual address */
256                     intNum:  53,
257                     eventId: -1,
258                 },
259                 "GPTimer4": {
260                     name: "WdTimer4Ipu",    /* GpTimer 4 */
261                     baseAddr: 0x68036000,   /* Virtual address */
262                     clkCtrl: 0x6A009748,    /* Virtual address */
263                     intNum:  54,
264                     eventId: -1,
265                 },
266                 "GPTimer5": {
267                     name: "WdTimer5Ipu",    /* GpTimer 5 */
268                     baseAddr: 0x68820000,   /* Virtual address */
269                     clkCtrl: 0x6a005558,    /* Virtual address */
270                     intNum:  -1,
271                     eventId: -1,
272                 },
273                 "GPTimer6": {
274                     name: "WdTimer6Ipu",    /* GpTimer 6 */
275                     baseAddr: 0x68822000,   /* Virtual address */
276                     clkCtrl: 0x6A005560,    /* Virtual address */
277                     intNum:  -1,
278                     eventId: -1,
279                 },
280                 "GPTimer7": {
281                     name: "WdTimer7Ipu",    /* GpTimer 7 */
282                     baseAddr: 0x68824000,   /* Virtual address */
283                     clkCtrl: 0x6A005568,    /* Virtual address */
284                     intNum:  -1,
285                     eventId: -1,
286                 },
287                 "GPTimer8": {
288                     name: "WdTimer8Ipu",    /* GpTimer 8 */
289                     baseAddr: 0x68826000,   /* Virtual address */
290                     clkCtrl: 0x6A005570,    /* Virtual address */
291                     intNum:  -1,
292                     eventId: -1,
293                 },
294                 "GPTimer9": {
295                     name: "WdTimer9Ipu",    /* GpTimer 9 */
296                     baseAddr: 0x6803E000,   /* Virtual address */
297                     clkCtrl: 0x6A009750,    /* Virtual address */
298                     intNum:  55,
299                     eventId: -1,
300                 },
301                 "GPTimer10": {
302                     name: "WdTimer10Ipu",   /* GpTimer 10 */
303                     baseAddr: 0x68086000,   /* Virtual address */
304                     clkCtrl: 0x6A009728,    /* Virtual address */
305                     intNum:  -1,
306                     eventId: -1,
307                 },
308                 "GPTimer11": {
309                     name: "WdTimer11Ipu",   /* GpTimer 11 */
310                     baseAddr: 0x68088000,   /* Virtual address */
311                     clkCtrl: 0x6A009730,    /* Virtual address */
312                     intNum:  56,
313                     eventId: -1,
314                 },
315                 "GPTimer12": {
316                     name: "WdTimer12Ipu",   /* GpTimer 12 */
317                     baseAddr: 0x6AE20000,   /* Virtual address */
318                     clkCtrl: 0x6AE07848,    /* Virtual address */
319                     intNum:  -1,
320                     eventId: -1,
321                 },
322                 "GPTimer13": {
323                     name: "WdTimer13Ipu",   /* GpTimer 13 */
324                     baseAddr: 0x68828000,   /* Virtual address */
325                     clkCtrl: 0x6A0097C8,    /* Virtual address */
326                     intNum:  -1,
327                     eventId: -1,
328                 },
329                 "GPTimer14": {
330                     name: "WdTimer14Ipu",   /* GpTimer 14 */
331                     baseAddr: 0x6882A000,   /* Virtual address */
332                     clkCtrl: 0x6A0097D0,    /* Virtual address */
333                     intNum:  -1,
334                     eventId: -1,
335                 },
336                 "GPTimer15": {
337                     name: "WdTimer15Ipu",   /* GpTimer 15 */
338                     baseAddr: 0x6882C000,   /* Virtual address */
339                     clkCtrl: 0x6A0097D8,    /* Virtual address */
340                     intNum:  -1,
341                     eventId: -1,
342                 },
343                 "GPTimer16": {
344                     name: "WdTimer16Ipu",   /* GpTimer 16 */
345                     baseAddr: 0x6882E000,   /* Virtual address */
346                     clkCtrl: 0x6A009830,    /* Virtual address */
347                     intNum:  -1,
348                     eventId: -1,
349                 },
350                 "Default": [
351                     { name: "GPTimer9" },
352                     { name: "GPTimer4" },
353                 ]
354             },
355         },
356     };
359 /*
360  *  ======== module$use ========
361  */
362 function module$use()
364     var device;
365     var found = false;
367     /* Only process during "cfg" phase */
368     if (xdc.om.$name != "cfg") {
369         return;
370     }
372     Watchdog = this;
374     timerIds = Watchdog.timerIds;
376     catalogName = Program.cpu.catalogName;
378     /* Loop through the device table */
379     for (deviceName in deviceTable[catalogName]) {
380         if (deviceName == Program.cpu.deviceName) {
381             dflts = deviceTable[catalogName][deviceName]["Default"];
382             timerIds.length = dflts.length;
383             for (var id in dflts) {
384                 if (timerIds[id] == undefined) {
385                     timerIds[id] = dflts[id].name;
386                 }
387                 device = deviceTable[catalogName][deviceName][timerIds[id]];
388                 if (device != undefined) {
389                     var i = Watchdog.timerSettings.length++;
391                     Watchdog.timerSettings[i].baseAddr = null;
392                     Watchdog.timerSettings[i].clkCtrl = null;
393                     Watchdog.timerSettings[i].intNum = device.intNum;
394                     Watchdog.timerSettings[i].eventId = device.eventId;
396                     found = true;
397                 }
398                 else {
399                     print("Watchdog Timer configuration is not found for " +
400                       "timer " + timerIds[id] + " for the specified device (" +
401                       Program.cpu.deviceName + ").  Supported devices:");
403                     for (device in deviceTable[catalogName]) {
404                         print("\t" + device);
405                     }
407                     throw new Error ("Watchdog Timer unsupported on device!");
408                 }
409             }
411             break;
412         }
413     }
415     if (!found) {
416         print("Watchdog Timer configuration is not found for the specified " +
417           "device (" + Program.cpu.deviceName + ").  Supported devices:");
419         for (device in deviceTable[catalogName]) {
420             print("\t" + device);
421         }
423         throw new Error ("Watchdog Timer unsupported on device!");
424     }
426     var Settings = xdc.module("ti.sysbios.family.Settings");
427     var Hwi = xdc.useModule(Settings.getDefaultHwiDelegate());
429     xdc.useModule('xdc.runtime.System');
431     if (Program.platformName.match(/IPU/) ||
432         Program.platformName.match(/ipu/)) {
433         Core = xdc.module("ti.sysbios.hal.Core");
434     }
435     else {
436         MultiProc = xdc.module('ti.sdo.utils.MultiProc');
437         if (Program.platformName.match(/DSP/)) {
438             xdc.useModule('ti.sysbios.family.c64p.tesla.Wugen');
439         }
440     }
442     Task = xdc.useModule('ti.sysbios.knl.Task');
443     taskHook = new Task.HookSet;
445     Swi  = xdc.useModule('ti.sysbios.knl.Swi');
446     swiHook  = new Swi.HookSet;
449 /*
450  *  ======== module$static$init ========
451  */
452 function module$static$init(mod, params)
454     swiHook.beginFxn = this.swiPrehook;
455     Swi.addHookSet(swiHook);
457     taskHook.switchFxn = this.taskSwitch;
458     Task.addHookSet(taskHook);
460     /* Assign default values if not supplied through configuration */
461     for (var id = 0; id < timerIds.length; id++) {
462         device = deviceTable[catalogName][deviceName][timerIds[id]];
463         if (Watchdog.timerSettings[id].baseAddr == null) {
464             Watchdog.timerSettings[id].baseAddr = $addr(device.baseAddr);
465         }
466         if (Watchdog.timerSettings[id].clkCtrl == null) {
467             Watchdog.timerSettings[id].clkCtrl = $addr(device.clkCtrl);
468         }
469     }
471     mod.device.length = 1;
472     mod.status.length   = 1;
473     mod.wdtCores      = 1;
474     if (Program.build.target.name.match(/C64T/) ||
475         Program.build.target.name.match(/C66/)) {
476         mod.device[0].baseAddr = Watchdog.timerSettings[0].baseAddr;
477         mod.device[0].clkCtrl  = Watchdog.timerSettings[0].clkCtrl;
478         mod.device[0].intNum   = Watchdog.timerSettings[0].intNum;
479         mod.device[0].eventId  = Watchdog.timerSettings[0].eventId;
480         mod.status[0]          = Watchdog.Mode_DISABLED;
481     }
482     else {
483         if (Program.platformName.match(/IPU/) ||
484             Program.platformName.match(/ipu/)) {
485             mod.device.length       = Core.numCores;
486             mod.status.length       = Core.numCores;
487             mod.wdtCores            = Core.numCores;
489             mod.device[0].baseAddr  = Watchdog.timerSettings[0].baseAddr;
490             mod.device[0].clkCtrl   = Watchdog.timerSettings[0].clkCtrl;
491             mod.device[0].intNum    = Watchdog.timerSettings[0].intNum;
492             mod.device[0].eventId   = Watchdog.timerSettings[0].eventId;
493             mod.status[0]           = Watchdog.Mode_DISABLED;
495             mod.device[1].baseAddr  = Watchdog.timerSettings[1].baseAddr;
496             mod.device[1].clkCtrl   = Watchdog.timerSettings[1].clkCtrl;
497             mod.device[1].intNum    = Watchdog.timerSettings[1].intNum;
498             mod.device[1].eventId   = Watchdog.timerSettings[1].eventId;
499             mod.status[1]           = Watchdog.Mode_DISABLED;
500         }
501         else {
502             if (MultiProc.id == MultiProc.getIdMeta("CORE0")) {
503                 mod.device[0].baseAddr  = Watchdog.timerSettings[0].baseAddr;
504                 mod.device[0].clkCtrl   = Watchdog.timerSettings[0].clkCtrl;
505                 mod.device[0].intNum    = Watchdog.timerSettings[0].intNum;
506                 mod.device[0].eventId   = Watchdog.timerSettings[0].eventId;
507             }
508             else {
509                 mod.device[0].baseAddr  = Watchdog.timerSettings[1].baseAddr;
510                 mod.device[0].clkCtrl   = Watchdog.timerSettings[1].clkCtrl;
511                 mod.device[0].intNum    = Watchdog.timerSettings[1].intNum;
512                 mod.device[0].eventId   = Watchdog.timerSettings[1].eventId;
513             }
514             mod.status[0]               = Watchdog.Mode_DISABLED;
515         }
516     }