]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/commitdiff
Watchdog: Add Config to disable Watchdog
authorAngela Stegmaier <angelabaker@ti.com>
Tue, 17 Jan 2017 22:45:38 +0000 (16:45 -0600)
committerAngela Stegmaier <angelabaker@ti.com>
Fri, 20 Jan 2017 21:24:20 +0000 (15:24 -0600)
Add a new module config to the Watchdog module that
allows to disable the module. The Watchdog
module is automatically included when Deh module is
included in an image. This parameter allows the user
to disable the watchdog while still using the Deh
module and allows this to be done from a config param
at the application level on the BIOS-side application.

The following can be added to the application config
file to disable Watchdog module (if desired) when including
Deh module.

    WD = xdc.useModule('ti.deh.Watchdog');
    WD.disableWatchdog = true;

There are other ways to disable the watchdog from Linux/Android
that already exist. This method just provides additional
flexibility to the user.

The default value is false if this parameter is not set.
So, if this parameter is not set, the behavior is the same as
before this patch.

Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
packages/ti/deh/Watchdog.c
packages/ti/deh/Watchdog.xdc

index 74075133682be048e4599418c4ce3d486598d4f5..4b84391e98f08af87931dcf5a2c8d928cfbd021d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015, Texas Instruments Incorporated
+ * Copyright (c) 2012-2016, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -164,86 +164,93 @@ Void Watchdog_init( Void (*timerFxn)(Void) )
     Int                          i;
     static __FAR__ Bool          first = TRUE;
 
-    tHandle = Timer_Object_get(NULL, 0);
-    Timer_getFreq(tHandle, &tFreq);  /* get timer frequency */
-
-#if defined(IPU) && defined(OMAP5)
-    if (first) {
-        adjustGptClkCtrlAddr();
+    if (Watchdog_disableWatchdog == TRUE) {
+        System_printf("Watchdog.disableWatchdog set to true. " \
+                      "Set to false in config file to enable Watchdog.\n");
     }
-#endif
-    for (i = 0; i < Watchdog_module->wdtCores; i++) {  /* loop for SMP cores */
-        timer = (volatile Watchdog_TimerRegs *) Watchdog_module->device[i].baseAddr;
+    else {
+        tHandle = Timer_Object_get(NULL, 0);
+        Timer_getFreq(tHandle, &tFreq);  /* get timer frequency */
 
-        /* Check if timer is enabled by host-side */
-        if ((REG32(Watchdog_module->device[i].clkCtrl) &
-            WATCHDOG_WDT_CLKCTRL_IDLEST_MASK) ==
-                                    WATCHDOG_WDT_CLKCTRL_IDLEST_MASK) {
-            System_printf("Watchdog disabled: TimerBase = 0x%x ClkCtrl = 0x%x\n",
-                                    timer, Watchdog_module->device[i].clkCtrl);
-            continue;  /* for next core */
+#if defined(IPU) && defined(OMAP5)
+        if (first) {
+            adjustGptClkCtrlAddr();
         }
-
-        if (Watchdog_module->status[i] != Watchdog_Mode_ENABLED) {
-            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;
+#endif
+        for (i = 0; i < Watchdog_module->wdtCores; i++) {  /* loop for SMP cores */
+            timer = (volatile Watchdog_TimerRegs *) Watchdog_module->device[i].baseAddr;
+
+            /* Check if timer is enabled by host-side */
+            if ((REG32(Watchdog_module->device[i].clkCtrl) &
+                WATCHDOG_WDT_CLKCTRL_IDLEST_MASK) ==
+                                        WATCHDOG_WDT_CLKCTRL_IDLEST_MASK) {
+                System_printf("Watchdog disabled: TimerBase = 0x%x ClkCtrl = 0x%x\n",
+                                        timer, Watchdog_module->device[i].clkCtrl);
+                continue;  /* for next core */
             }
+
+            if (Watchdog_module->status[i] != Watchdog_Mode_ENABLED) {
+                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;
-            }
+                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);
-            hwiParams.priority = 1;
-            hwiParams.eventId = Watchdog_module->device[i].eventId;
-            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);
+                /* Enable interrupt in BIOS */
+                Hwi_Params_init(&hwiParams);
+                hwiParams.priority = 1;
+                hwiParams.eventId = Watchdog_module->device[i].eventId;
+                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);
 
-            /* Configure the timer */
-            initTimer(timer, TRUE);
+                /* Configure the timer */
+                initTimer(timer, TRUE);
 
-            Hwi_enableInterrupt(Watchdog_module->device[i].intNum);
+                Hwi_enableInterrupt(Watchdog_module->device[i].intNum);
 #if defined(DSP) && defined(OMAP5)
-            Wugen_enableEvent(Watchdog_module->device[i].eventId);
+                Wugen_enableEvent(Watchdog_module->device[i].eventId);
 #endif
-            Hwi_restore(key);
+                Hwi_restore(key);
 
-            /* Enable timer */
-            while (timer->twps & WATCHDOG_TIMER_TWPS_W_PEND_TCLR);
-            timer->tclr |= 1;
-            Watchdog_module->status[i] = Watchdog_Mode_ENABLED;
+                /* Enable timer */
+                while (timer->twps & WATCHDOG_TIMER_TWPS_W_PEND_TCLR);
+                timer->tclr |= 1;
+                Watchdog_module->status[i] = Watchdog_Mode_ENABLED;
 
 #ifdef SMP
-            System_printf("Watchdog enabled: TimerBase = 0x%x SMP-Core = %d "
+                System_printf("Watchdog enabled: TimerBase = 0x%x SMP-Core = %d "
                                             "Freq = %d\n", timer, i, tFreq.lo);
 #else
-            System_printf("Watchdog enabled: TimerBase = 0x%x Freq = %d\n",
+                System_printf("Watchdog enabled: TimerBase = 0x%x Freq = %d\n",
                                                             timer, tFreq.lo);
 #endif
+            }
         }
-    }
 
 #if defined(OMAP5) || defined(IPU)
-    if (first) {
-        /* Register callback function */
-        if (!IpcPower_registerCallback(IpcPower_Event_RESUME, Watchdog_restore,
-                                    NULL)) {
-            System_printf("Watchdog_restore registered as a resume callback\n");
+        if (first) {
+            /* Register callback function */
+            if (!IpcPower_registerCallback(IpcPower_Event_RESUME, Watchdog_restore,
+                                        NULL)) {
+                System_printf("Watchdog_restore registered as a resume callback\n");
+            }
         }
-    }
 #endif
+    }
 
     if (first) {
         first = FALSE;
index efff471535210c52314742bb97f67b6bba103155..8eccb6dc81aa7ace27057bf7c088683eb9d02898 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015, Texas Instruments Incorporated
+ * Copyright (c) 2012-2016, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,12 @@ module Watchdog {
 
     metaonly config String timerIds[] = [];
 
+    /*!
+     *  ======== disableWatchdog ========
+     *  Configuration that allows disabling the watchdog.
+     */
+    config Bool disableWatchdog = false;
+
     /*!
      *  ======== init ========
      *  Initialize the Watchdog module