Add capability to specify specific Watchdog timer for Deh
authorRobert Tivy <rtivy@ti.com>
Thu, 2 Apr 2015 21:34:02 +0000 (14:34 -0700)
committerRobert Tivy <rtivy@ti.com>
Tue, 14 Apr 2015 00:02:23 +0000 (17:02 -0700)
Previous to this change the user was basically stuck using the GPTimer
that was hardcoded to their device (although they could change the
timer by changing the device's timer settings, which was cumbersome).

The user can now specify a particular GPTimer by setting it in the .cfg
file.  For DRA7XX's IPU2, the Watchdog timers (one for each SMP core)
can be set with:
    Watchdog.timerIds.length = 2;
    Watchdog.timerIds[0] = "GPTimer9";
    Watchdog.timerIds[1] = "GPTimer4";

Each supported device has default GPTimer settings appropriate to that
device (the snippet above actually assigns the current defaults for
Vayu, so it is actually a no-op).

The "GPTimer<n>" specification encapsulates timer settings such as
intNum and eventId.  Many GPTimer specifications in Watchdog.xs have
-1 in these fields if they don't have a hardcoded wirings for them, yet
they can still be used if the user explicitly defines the value in the
.cfg file and somehow sets up the hardware to generate that intNum or
eventId (e.g., through the crossbar on Vayu).

packages/ti/deh/Watchdog.c
packages/ti/deh/Watchdog.xdc
packages/ti/deh/Watchdog.xs

index 53b5c502df3d2522e19eada86715bd3f98c248b3..b06e8c2f4637c7a8b28fd1ad9abd2602b061dd71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -185,8 +185,21 @@ Void Watchdog_init( Void (*timerFxn)(Void) )
         }
 
         if (Watchdog_module->status[i] != Watchdog_Mode_ENABLED) {
-            /* Configure the timer */
-            initTimer(timer, TRUE);
+            if (Watchdog_module->device[i].intNum == -1) {
+                System_printf("Watchdog timer @TimerBase = 0x%x does not have"
+                              " a valid intNum setting (it is -1). This"
+                              " timer's intNum must be set in the .cfg file\n",
+                              timer);
+                continue;
+            }
+#if defined(DSP)
+            if (Watchdog_module->device[i].eventId == -1) {
+                System_printf("Watchdog timer @TimerBase = 0x%x does not have"
+                              " a valid eventId setting (it is -1).  This"
+                              " timer's eventId must be set in the .cfg file\n",                              timer);
+                continue;
+            }
+#endif
 
             /* Enable interrupt in BIOS */
             Hwi_Params_init(&hwiParams);
@@ -195,8 +208,12 @@ Void Watchdog_init( Void (*timerFxn)(Void) )
             hwiParams.maskSetting = Hwi_MaskingOption_LOWER;
             hwiParams.arg = 1;     /* Exception_handler(abortFlag) */
             key = Hwi_disable();
-            Hwi_create(Watchdog_module->device[i].intNum, (Hwi_FuncPtr) timerFxn,
-                                                            &hwiParams, NULL);
+            Hwi_create(Watchdog_module->device[i].intNum,
+                       (Hwi_FuncPtr)timerFxn, &hwiParams, NULL);
+
+            /* Configure the timer */
+            initTimer(timer, TRUE);
+
             Hwi_enableInterrupt(Watchdog_module->device[i].intNum);
 #if defined(DSP) && defined(OMAP5)
             Wugen_enableEvent(Watchdog_module->device[i].eventId);
index 37f18e84f8718ea6b767036aa200e88d0843a0b7..efff471535210c52314742bb97f67b6bba103155 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -88,7 +88,7 @@ module Watchdog {
     struct TimerDevice {
         Ptr     baseAddr;
         Ptr     clkCtrl;
-        UInt32  intNum;
+        Int32   intNum;
         Int     eventId;
     };
 
@@ -114,6 +114,8 @@ module Watchdog {
      */
     metaonly config TimerDevice timerSettings[] = [];
 
+    metaonly config String timerIds[] = [];
+
     /*!
      *  ======== init ========
      *  Initialize the Watchdog module
index df10f74d8720551130d021c8b74c28b49c80b9af..bf7c69d80d3584c5e7fe3ce8f4a6bbd83361a608 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,68 +43,313 @@ var Swi  = null;
 var taskHook = null;
 var swiHook  = null;
 var catalogName = null;
+var timerIds = [];
 
 if (xdc.om.$name == "cfg" || typeof(genCdoc) != "undefined") {
     var deviceTable = {
         "ti.catalog.c6000": {
             "OMAP5430": {
-                wdtimer: [
-                   {
-                        name: "WdTimerDsp",     /* GpTimer 6 */
-                        baseAddr: 0x01d3A000,
-                        clkCtrl: 0x4A004570,    /* Virtual address */
-                        intNum:  15,
-                        eventId: 52,
-                    },
+                "GPTimer5": {
+                    name: "WdTimer5Dsp",    /* GpTimer 5 */
+                    baseAddr: 0x01D38000,
+                    clkCtrl: 0x4A004568,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 51,
+                },
+                "GPTimer6": {
+                    name: "WdTimer6Dsp",    /* GpTimer 6 */
+                    baseAddr: 0x01D3A000,
+                    clkCtrl: 0x4A004570,    /* Virtual address */
+                    intNum:  15,
+                    eventId: 52,
+                },
+                "GPTimer7": {
+                    name: "WdTimer7Dsp",    /* GpTimer 7 */
+                    baseAddr: 0x01D3C000,
+                    clkCtrl: 0x4A004578,    /* Virtual address */
+                    intNum:  4,
+                    eventId: 53,
+                },
+                "GPTimer8": {
+                    name: "WdTimer8Dsp",    /* GpTimer 8 */
+                    baseAddr: 0x01D3E000,
+                    clkCtrl: 0x4A004580,    /* Virtual address */
+                    intNum:  5,
+                    eventId: 54,
+                },
+                "Default": [
+                    { name: "GPTimer6" },
                 ]
             },
             "DRA7XX": {
-                wdtimer: [
-                    {
-                        name: "WdTimerDsp",     /* GpTimer 10 */
-                        baseAddr: 0x48086000,   /* Virtual address */
-                        clkCtrl: 0x4A009728,    /* Virtual address */
-                        intNum:  15,
-                        eventId: 72,
-                    },
+                "GPTimer1": {
+                    name: "WdTimer1Dsp",    /* GpTimer 1 */
+                    baseAddr: 0x4AE18000,   /* Virtual address */
+                    clkCtrl: 0x4AE07840,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 63,
+                },
+                "GPTimer2": {
+                    name: "WdTimer2Dsp",    /* GpTimer 2 */
+                    baseAddr: 0x48032000,   /* Virtual address */
+                    clkCtrl: 0x4A009738,    /* Virtual address */
+                    intNum:  15,
+                    eventId: 64,
+                },
+                "GPTimer3": {
+                    name: "WdTimer3Dsp",    /* GpTimer 3 */
+                    baseAddr: 0x48034000,   /* Virtual address */
+                    clkCtrl: 0x4A009740,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 65,
+                },
+                "GPTimer4": {
+                    name: "WdTimer4Dsp",    /* GpTimer 4 */
+                    baseAddr: 0x48036000,   /* Virtual address */
+                    clkCtrl: 0x4A009748,    /* Virtual address */
+                    intNum:  15,
+                    eventId: 66,
+                },
+                "GPTimer5": {
+                    name: "WdTimer5Dsp",    /* GpTimer 5 */
+                    baseAddr: 0x48820000,   /* Virtual address */
+                    clkCtrl: 0x4a005558,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 67,
+                },
+                "GPTimer6": {
+                    name: "WdTimer6Dsp",    /* GpTimer 6 */
+                    baseAddr: 0x48822000,   /* Virtual address */
+                    clkCtrl: 0x4A005560,    /* Virtual address */
+                    intNum:  15,
+                    eventId: 68,
+                },
+                "GPTimer7": {
+                    name: "WdTimer7Dsp",    /* GpTimer 7 */
+                    baseAddr: 0x48824000,   /* Virtual address */
+                    clkCtrl: 0x4A005568,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 69,
+                },
+                "GPTimer8": {
+                    name: "WdTimer8Dsp",    /* GpTimer 8 */
+                    baseAddr: 0x48826000,   /* Virtual address */
+                    clkCtrl: 0x4A005570,    /* Virtual address */
+                    intNum:  15,
+                    eventId: 70,
+                },
+                "GPTimer9": {
+                    name: "WdTimer9Dsp",    /* GpTimer 9 */
+                    baseAddr: 0x4803E000,   /* Virtual address */
+                    clkCtrl: 0x4A009750,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 71,
+                },
+                "GPTimer10": {
+                    name: "WdTimer10Dsp",   /* GpTimer 10 */
+                    baseAddr: 0x48086000,   /* Virtual address */
+                    clkCtrl: 0x4A009728,    /* Virtual address */
+                    intNum:  15,
+                    eventId: 72,
+                },
+                "GPTimer11": {
+                    name: "WdTimer11Dsp",   /* GpTimer 11 */
+                    baseAddr: 0x48088000,   /* Virtual address */
+                    clkCtrl: 0x4A009730,    /* Virtual address */
+                    intNum:  14,
+                    eventId: 73,
+                },
+                "GPTimer12": {
+                    name: "WdTimer12Dsp",   /* GpTimer 12 */
+                    baseAddr: 0x4AE20000,   /* Virtual address */
+                    clkCtrl: 0x4AE07848,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: 75,
+                },
+                "GPTimer13": {
+                    name: "WdTimer13Dsp",   /* GpTimer 13 */
+                    baseAddr: 0x48822000,   /* Virtual address */
+                    clkCtrl: 0x4A0097C8,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: 76,
+                },
+                "GPTimer14": {
+                    name: "WdTimer14Dsp",   /* GpTimer 14 */
+                    baseAddr: 0x4882A000,   /* Virtual address */
+                    clkCtrl: 0x4A0097D0,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: 77,
+                },
+                "GPTimer15": {
+                    name: "WdTimer15Dsp",   /* GpTimer 15 */
+                    baseAddr: 0x4882C000,   /* Virtual address */
+                    clkCtrl: 0x4A0097D8,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: 78,
+                },
+                "GPTimer16": {
+                    name: "WdTimer16Dsp",   /* GpTimer 16 */
+                    baseAddr: 0x4882E000,   /* Virtual address */
+                    clkCtrl: 0x4A009830,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: 81,
+                },
+                "Default": [
+                    { name: "GPTimer10" },
                 ]
             },
         },
         "ti.catalog.arm.cortexm4": {
             "OMAP5430": {
-                wdtimer: [
-                    {
-                        name: "WdTimerCore0",   /* GpTimer 9 */
-                        baseAddr: 0xA803E000,   /* Virtual address */
-                        clkCtrl: 0xAA009450,    /* Virtual address */
-                        intNum:  55,
-                        eventId: -1,
-                    },
-                    {
-                        name: "WdTimerCore1",   /* GpTimer 11 */
-                        baseAddr: 0xA8088000,   /* Virtual address */
-                        clkCtrl: 0xAA009430,    /* Virtual address */
-                        intNum:  56,
-                        eventId: -1,
-                    },
+                "GPTimer3": {
+                    name: "WdTimer3Ipu",    /* GpTimer 3 */
+                    baseAddr: 0xA8034000,   /* Virtual address */
+                    clkCtrl: 0xAA009040,    /* Virtual address */
+                    intNum:  53,
+                    eventId: -1,
+                },
+                "GPTimer4": {
+                    name: "WdTimer4Ipu",    /* GpTimer 4 */
+                    baseAddr: 0xA8036000,   /* Virtual address */
+                    clkCtrl: 0xAA009048,    /* Virtual address */
+                    intNum:  54,
+                    eventId: -1,
+                },
+                "GPTimer9": {
+                    name: "WdTimer9Ipu",    /* GpTimer 9 */
+                    baseAddr: 0xA803E000,   /* Virtual address */
+                    clkCtrl: 0xAA009050,    /* Virtual address */
+                    intNum:  55,
+                    eventId: -1,
+                },
+                "GPTimer11": {
+                    name: "WdTimer11Ipu",   /* GpTimer 11 */
+                    baseAddr: 0xA8088000,   /* Virtual address */
+                    clkCtrl: 0xAA009030,    /* Virtual address */
+                    intNum:  56,
+                    eventId: -1,
+                },
+                "Default": [
+                    { name: "GPTimer9" },
+                    { name: "GPTimer11" },
                 ]
             },
             "DRA7XX": {
-                wdtimer: [
-                    {
-                        name: "WdTimerCore0",   /* GpTimer 9 */
-                        baseAddr: 0x6803E000,   /* Virtual address */
-                        clkCtrl: 0x6A009750,    /* Virtual address */
-                        intNum:  55,
-                        eventId: -1,
-                    },
-                    {
-                        name: "WdTimerCore1",   /* GpTimer 4 */
-                        baseAddr: 0x68036000,   /* Virtual address */
-                        clkCtrl: 0x6A009748,    /* Virtual address */
-                        intNum:  54,
-                        eventId: -1,
-                    },
+                "GPTimer1": {
+                    name: "WdTimer1Ipu",    /* GpTimer 1 */
+                    baseAddr: 0x6AE18000,   /* Virtual address */
+                    clkCtrl: 0x6AE07840,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer2": {
+                    name: "WdTimer2Ipu",    /* GpTimer 2 */
+                    baseAddr: 0x68032000,   /* Virtual address */
+                    clkCtrl: 0x6A009738,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer3": {
+                    name: "WdTimer3Ipu",    /* GpTimer 3 */
+                    baseAddr: 0x68034000,   /* Virtual address */
+                    clkCtrl: 0x6A009740,    /* Virtual address */
+                    intNum:  53,
+                    eventId: -1,
+                },
+                "GPTimer4": {
+                    name: "WdTimer4Ipu",    /* GpTimer 4 */
+                    baseAddr: 0x68036000,   /* Virtual address */
+                    clkCtrl: 0x6A009748,    /* Virtual address */
+                    intNum:  54,
+                    eventId: -1,
+                },
+                "GPTimer5": {
+                    name: "WdTimer5Ipu",    /* GpTimer 5 */
+                    baseAddr: 0x68820000,   /* Virtual address */
+                    clkCtrl: 0x6a005558,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer6": {
+                    name: "WdTimer6Ipu",    /* GpTimer 6 */
+                    baseAddr: 0x68822000,   /* Virtual address */
+                    clkCtrl: 0x6A005560,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer7": {
+                    name: "WdTimer7Ipu",    /* GpTimer 7 */
+                    baseAddr: 0x68824000,   /* Virtual address */
+                    clkCtrl: 0x6A005568,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer8": {
+                    name: "WdTimer8Ipu",    /* GpTimer 8 */
+                    baseAddr: 0x68826000,   /* Virtual address */
+                    clkCtrl: 0x6A005570,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer9": {
+                    name: "WdTimer9Ipu",    /* GpTimer 9 */
+                    baseAddr: 0x6803E000,   /* Virtual address */
+                    clkCtrl: 0x6A009750,    /* Virtual address */
+                    intNum:  55,
+                    eventId: -1,
+                },
+                "GPTimer10": {
+                    name: "WdTimer10Ipu",   /* GpTimer 10 */
+                    baseAddr: 0x68086000,   /* Virtual address */
+                    clkCtrl: 0x6A009728,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer11": {
+                    name: "WdTimer11Ipu",   /* GpTimer 11 */
+                    baseAddr: 0x68088000,   /* Virtual address */
+                    clkCtrl: 0x6A009730,    /* Virtual address */
+                    intNum:  56,
+                    eventId: -1,
+                },
+                "GPTimer12": {
+                    name: "WdTimer12Ipu",   /* GpTimer 12 */
+                    baseAddr: 0x6AE20000,   /* Virtual address */
+                    clkCtrl: 0x6AE07848,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer13": {
+                    name: "WdTimer13Ipu",   /* GpTimer 13 */
+                    baseAddr: 0x68828000,   /* Virtual address */
+                    clkCtrl: 0x6A0097C8,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer14": {
+                    name: "WdTimer14Ipu",   /* GpTimer 14 */
+                    baseAddr: 0x6882A000,   /* Virtual address */
+                    clkCtrl: 0x6A0097D0,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer15": {
+                    name: "WdTimer15Ipu",   /* GpTimer 15 */
+                    baseAddr: 0x6882C000,   /* Virtual address */
+                    clkCtrl: 0x6A0097D8,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "GPTimer16": {
+                    name: "WdTimer16Ipu",   /* GpTimer 16 */
+                    baseAddr: 0x6882E000,   /* Virtual address */
+                    clkCtrl: 0x6A009830,    /* Virtual address */
+                    intNum:  -1,
+                    eventId: -1,
+                },
+                "Default": [
+                    { name: "GPTimer9" },
+                    { name: "GPTimer4" },
                 ]
             },
         },
@@ -116,7 +361,7 @@ if (xdc.om.$name == "cfg" || typeof(genCdoc) != "undefined") {
  */
 function module$use()
 {
-    var found = false;
+    var device;
 
     /* Only process during "cfg" phase */
     if (xdc.om.$name != "cfg") {
@@ -125,38 +370,43 @@ function module$use()
 
     Watchdog = this;
 
+    timerIds = Watchdog.timerIds;
+
     catalogName = Program.cpu.catalogName;
 
     /* Loop through the device table */
-    /* TODO: This lookup table can be replaced to use the dmTimer module
-     *       later on, and eliminate the need for this device table */
     for (deviceName in deviceTable[catalogName]) {
         if (deviceName == Program.cpu.deviceName) {
-            var device = deviceTable[catalogName][deviceName].wdtimer;
-
-            Watchdog.timerSettings.length = device.length;
-            for (var i = 0; i < device.length; i++) {
-                Watchdog.timerSettings[i].baseAddr = null;
-                Watchdog.timerSettings[i].clkCtrl = null;
-                Watchdog.timerSettings[i].intNum = device[i].intNum;
-                Watchdog.timerSettings[i].eventId = device[i].eventId;
-            }
+            dflts = deviceTable[catalogName][deviceName]["Default"];
+            timerIds.length = dflts.length;
+            for (var id in dflts) {
+                if (timerIds[id] == undefined) {
+                    timerIds[id] = dflts[id].name;
+                }
+                device = deviceTable[catalogName][deviceName][timerIds[id]];
+                if (device != undefined) {
+                    var i = Watchdog.timerSettings.length++;
 
-            found = true;
+                    Watchdog.timerSettings[i].baseAddr = null;
+                    Watchdog.timerSettings[i].clkCtrl = null;
+                    Watchdog.timerSettings[i].intNum = device.intNum;
+                    Watchdog.timerSettings[i].eventId = device.eventId;
+                }
+                else {
+                    print("Watchdog Timer configuration is not found for " +
+                      "timer " + timerIds[id] + " for the specified device (" +
+                      Program.cpu.deviceName + ").");
 
-           break;
-        }
-    }
+                    for (device in deviceTable[catalogName]) {
+                        print("\t" + device);
+                    }
 
-    if (!found) {
-        print("Watchdog Timer configuration is not found for the " +
-              "specified device (" + Program.cpu.deviceName + ").");
+                    throw new Error ("Watchdog Timer unsupported on device!");
+                }
+            }
 
-        for (device in deviceTable[catalogName]) {
-            print("\t" + device);
+            break;
         }
-
-        throw new Error ("Watchdog Timer unsupported on device!");
     }
 
     var Settings = xdc.module("ti.sysbios.family.Settings");
@@ -187,8 +437,6 @@ function module$use()
  */
 function module$static$init(mod, params)
 {
-    var device = deviceTable[catalogName][Program.cpu.deviceName].wdtimer;
-
     swiHook.beginFxn = this.swiPrehook;
     Swi.addHookSet(swiHook);
 
@@ -196,12 +444,13 @@ function module$static$init(mod, params)
     Task.addHookSet(taskHook);
 
     /* Assign default values if not supplied through configuration */
-    for (var i = 0; i < device.length; i++) {
-        if (Watchdog.timerSettings[i].baseAddr == null) {
-            Watchdog.timerSettings[i].baseAddr = $addr(device[i].baseAddr);
+    for (var id = 0; id < timerIds.length; id++) {
+        device = deviceTable[catalogName][deviceName][timerIds[id]];
+        if (Watchdog.timerSettings[id].baseAddr == null) {
+            Watchdog.timerSettings[id].baseAddr = $addr(device.baseAddr);
         }
-        if (Watchdog.timerSettings[i].clkCtrl == null) {
-            Watchdog.timerSettings[i].clkCtrl = $addr(device[i].clkCtrl);
+        if (Watchdog.timerSettings[id].clkCtrl == null) {
+            Watchdog.timerSettings[id].clkCtrl = $addr(device.clkCtrl);
         }
     }