]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - qnx/src/ipc3x_dev/ti/syslink/family/vayu/Platform.c
Enable gptimers in PD_IPU domain
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / vayu / Platform.c
index 370e6561d99c0350bd2048f406efd3eb63be8632..946d91a6b7176085f7f00fe10b3494ac0a7c47bd 100644 (file)
@@ -6,7 +6,7 @@
  *
  *  ============================================================================
  *
- *  Copyright (c) 2013, Texas Instruments Incorporated
+ *  Copyright (c) 2013-2014, Texas Instruments Incorporated
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
 
 #include <ti/ipc/Ipc.h>
 #include <_Ipc.h>
+#include <_MultiProc.h>
 #include <IpcKnl.h>
 #include <sys/mman.h>
+#include <GateHWSpinlock.h>
+#include <gptimers.h>
 
 #if defined (__cplusplus)
 extern "C" {
@@ -92,6 +95,10 @@ extern "C" {
  *  Macros.
  *  ============================================================================
  */
+/* Hardware spinlocks info */
+#define HWSPINLOCK_BASE             0x4A0F6000
+#define HWSPINLOCK_SIZE             0x1000
+#define HWSPINLOCK_OFFSET           0x800
 
 /** ============================================================================
  *  Application specific configuration, please change these value according to
@@ -113,6 +120,9 @@ typedef struct Platform_Config {
 
     ElfLoader_Config                elfLoaderConfig;
     /*!< Elf loader config parameter */
+
+    GateHWSpinlock_Config           gateHWSpinlockConfig;
+    /*!< GateHWSpinlock config parameter */
 } Platform_Config;
 
 /*! @brief structure for platform instance */
@@ -136,7 +146,7 @@ typedef struct Platform_Object {
             /*!< Handle to the PwrMgr instance used */
             ElfLoader_Handle        ldrHandle;
             /*!< Handle to the Loader instance used */
-        } ipu1;
+        } ipu;
     } sHandles;
     /*!< Slave specific handles */
 } Platform_Object, *Platform_Handle;
@@ -156,6 +166,10 @@ typedef struct Platform_Module_State {
     /*!< IpcInt Initialize flag */
     Bool              platformInitFlag;
     /*!< Flag to indicate platform initialization status */
+    Bool              gateHWSpinlockInitFlag;
+    /*!< GateHWSpinlock Initialize flag */
+    Ptr               gateHWSpinlockVAddr;
+    /*!< GateHWSpinlock Virtual Address */
 } Platform_Module_State;
 
 
@@ -175,6 +189,9 @@ extern String ProcMgr_sysLinkCfgParams;
 String Syslink_Override_Params = "ProcMgr.proc[DSP1].mmuEnable=TRUE;"
                                  "ProcMgr.proc[DSP1].carveoutAddr0=0xBA300000;"
                                  "ProcMgr.proc[DSP1].carveoutSize0=0x5A00000;"
+                                 "ProcMgr.proc[IPU1].mmuEnable=TRUE;"
+                                 "ProcMgr.proc[IPU1].carveoutAddr0=0xBA300000;"
+                                 "ProcMgr.proc[IPU1].carveoutSize0=0x5A00000;"
                                  "ProcMgr.proc[IPU2].mmuEnable=TRUE;"
                                  "ProcMgr.proc[IPU2].carveoutAddr0=0xBA300000;"
                                  "ProcMgr.proc[IPU2].carveoutSize0=0x5A00000;";
@@ -228,6 +245,9 @@ Platform_getConfig (Platform_Config * config)
 
         /* Get the ElfLoader default config */
         ElfLoader_getConfig (&config->elfLoaderConfig);
+
+        /* Get the HWSpinlock default config */
+        GateHWSpinlock_getConfig (&config->gateHWSpinlockConfig);
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
     }
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
@@ -286,23 +306,13 @@ Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
 
         _ProcMgr_saveParams(cfg->params, String_len(cfg->params));
 
-        /* Override the MultiProc default config */
-        config->multiProcConfig.numProcessors = 5;
-        config->multiProcConfig.id            = 0;
-        String_cpy (config->multiProcConfig.nameList [0],
-                    "HOST");
-        String_cpy (config->multiProcConfig.nameList [1],
-                    "IPU2");
-        String_cpy (config->multiProcConfig.nameList [2],
-                    "IPU1");
-        String_cpy (config->multiProcConfig.nameList [3],
-                    "DSP2");
-        String_cpy (config->multiProcConfig.nameList [4],
-                    "DSP1");
+        /* Set the MultiProc config as defined in SystemCfg.c */
+        config->multiProcConfig = _MultiProc_cfg;
 
         /* Override the MESSAGEQCOPY default config */
-        config->MQCopyConfig.intId[1] = 116; // 84 + 32
-        config->MQCopyConfig.intId[4] = 115; // 83 + 32
+        config->MQCopyConfig.intId[1] = 173; // 141 + 32
+        config->MQCopyConfig.intId[2] = 168; // 136 + 32
+        config->MQCopyConfig.intId[4] = 168; // 136 + 32
 
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
     }
@@ -325,6 +335,7 @@ Platform_setup (Ipc_Config * cfg)
     Platform_Config   _config;
     Platform_Config * config;
     VAYUIpcInt_Config VAYUcfg;
+    Memory_MapInfo    minfo;
 
     Platform_getConfig (&_config);
     config = &_config;
@@ -436,6 +447,58 @@ Platform_setup (Ipc_Config * cfg)
         }
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
     }
+    if (status >= 0) {
+        minfo.src  = HWSPINLOCK_BASE;
+        minfo.size = HWSPINLOCK_SIZE;
+        minfo.isCached = FALSE;
+        status = Memory_map (&minfo);
+        if (status < 0) {
+           GT_setFailureReason (curTrace,
+                                GT_4CLASS,
+                                "Platform_setup",
+                                status,
+                                "Memory_map failed!");
+        }
+        else {
+            Platform_module->gateHWSpinlockVAddr = (Ptr)minfo.dst;
+            config->gateHWSpinlockConfig.numLocks = 32;
+            config->gateHWSpinlockConfig.baseAddr = minfo.dst  + HWSPINLOCK_OFFSET;
+            status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            if (status < 0) {
+                GT_setFailureReason (curTrace,
+                                     GT_4CLASS,
+                                     "Platform_setup",
+                                     status,
+                                     "GateHWSpinlock_setup failed!");
+            }
+            else {
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+                status = GateHWSpinlock_start();
+                if (status < 0) {
+                    GT_setFailureReason (curTrace,
+                                     GT_4CLASS,
+                                     "Platform_setup",
+                                     status,
+                                     "GateHWSpinlock_start failed!");
+                }
+                else {
+                    Platform_module->gateHWSpinlockInitFlag = TRUE;
+                }
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+        }
+    }
+
+    /* Enable GP timers */
+    if (status >= 0) {
+        status = gpt_setup();
+        if (status < 0) {
+            GT_setFailureReason(curTrace, GT_4CLASS, "Platform_setup",
+                    status, "gpt_setup failed!");
+        }
+    }
 
     if (status < 0) {
         Platform_destroy();
@@ -453,6 +516,7 @@ Int32
 Platform_destroy (void)
 {
     Int32  status = Platform_S_SUCCESS;
+    Memory_UnmapInfo minfo;
 
     GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
 
@@ -475,6 +539,9 @@ Platform_destroy (void)
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
     }
 
+    /* disable GP timers */
+    gpt_destroy();
+
     /* Finalize elf loader */
     if (Platform_module->elfLoaderInitFlag == TRUE) {
         status = ElfLoader_destroy ();
@@ -563,6 +630,51 @@ Platform_destroy (void)
                     (sizeof (Platform_Object) * MultiProc_getNumProcessors()));
     }
 
+    if (Platform_module->gateHWSpinlockInitFlag == TRUE) {
+        status = GateHWSpinlock_stop();
+        if (status < 0) {
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "Platform_destroy",
+                                 status,
+                                 "GateHWSpinlock_stop failed!");
+        }
+        else {
+            status = GateHWSpinlock_destroy();
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            if (status < 0) {
+                GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "Platform_destroy",
+                                 status,
+                                 "GateHWSpinlock_destroy failed!");
+            }
+            else {
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+                Platform_module->gateHWSpinlockInitFlag = FALSE;
+            }
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+        }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+    }
+
+    if (Platform_module->gateHWSpinlockVAddr) {
+        minfo.addr = (UInt32)Platform_module->gateHWSpinlockVAddr;
+        minfo.size = HWSPINLOCK_SIZE;
+        minfo.isCached = FALSE;
+        status = Memory_unmap(&minfo);
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+        if (status < 0) {
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "Platform_destroy",
+                                 status,
+                                 "Memory_unmap failed!");
+        }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+        Platform_module->gateHWSpinlockVAddr = NULL;
+    }
+
     GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
 
     /*! @retval Platform_S_SUCCESS Operation successful */
@@ -579,17 +691,13 @@ Platform_destroy (void)
 typedef union _Platform_setup_Local {
     ProcMgr_Params          params;
     VAYUDSPPROC_Config      dspProcConfig;
-    VAYUIPUCORE1PROC_Config videoProcConfig;
-    VAYUIPUCORE0PROC_Config vpssProcConfig;
+    VAYUIPUCORE0PROC_Config ipuProcConfig;
     VAYUDSPPWR_Config       dspPwrConfig;
-    VAYUIPUPWR_Config       videoPwrConfig;
-    VAYUIPUPWR_Config       vpssPwrConfig;
+    VAYUIPUPWR_Config       ipuPwrConfig;
     VAYUDSPPROC_Params      dspProcParams;
-    VAYUIPUCORE1PROC_Params videoProcParams;
-    VAYUIPUCORE0PROC_Params vpssProcParams;
+    VAYUIPUCORE0PROC_Params ipuProcParams;
     VAYUDSPPWR_Params       dspPwrParams;
-    VAYUIPUPWR_Params       videoPwrParams;
-    VAYUIPUPWR_Params       vpssPwrParams;
+    VAYUIPUPWR_Params       ipuPwrParams;
     ElfLoader_Params        elfLoaderParams;
 } _Platform_setup_Local;
 
@@ -620,11 +728,11 @@ _Platform_setup (Ipc_Config * cfg)
     }
     if (status >= 0) {
         /* Get MultiProc ID by name. */
-        procId = MultiProc_getId ("IPU2");
+        procId = MultiProc_getId ("IPU1");
 
         handle = &Platform_objects [procId];
-        VAYUIPUCORE0PROC_getConfig (&lv->vpssProcConfig);
-        status = VAYUIPUCORE0PROC_setup (&lv->vpssProcConfig);
+        VAYUIPUCORE0PROC_getConfig (&lv->ipuProcConfig);
+        status = VAYUIPUCORE0PROC_setup (&lv->ipuProcConfig);
         if (status < 0) {
             GT_setFailureReason (curTrace,
                                  GT_4CLASS,
@@ -633,8 +741,8 @@ _Platform_setup (Ipc_Config * cfg)
                                  "VAYUIPUCORE0PROC_setup failed!");
         }
         else {
-            VAYUIPUPWR_getConfig (&lv->vpssPwrConfig);
-            status = VAYUIPUPWR_setup (&lv->vpssPwrConfig);
+            VAYUIPUPWR_getConfig (&lv->ipuPwrConfig);
+            status = VAYUIPUPWR_setup (&lv->ipuPwrConfig);
             if (status < 0) {
                 GT_setFailureReason (curTrace,
                                      GT_4CLASS,
@@ -647,22 +755,89 @@ _Platform_setup (Ipc_Config * cfg)
         if (status >= 0) {
             /* Create an instance of the Processor object for
              * VAYUIPUCORE0 */
-            VAYUIPUCORE0PROC_Params_init (NULL, &lv->vpssProcParams);
-            handle->sHandles.ipu1.pHandle = VAYUIPUCORE0PROC_create (procId,
-                                                         &lv->vpssProcParams);
+            VAYUIPUCORE0PROC_Params_init (NULL, &lv->ipuProcParams);
+            handle->sHandles.ipu.pHandle = VAYUIPUCORE0PROC_create (procId,
+                                                         &lv->ipuProcParams);
+
+            /* Create an instance of the ELF Loader object */
+            ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
+            handle->sHandles.ipu.ldrHandle = ElfLoader_create (procId,
+                                                        &lv->elfLoaderParams);
+
+            /* Create an instance of the PwrMgr object for VAYUIPUCORE0 */
+            VAYUIPUPWR_Params_init (&lv->ipuPwrParams);
+            handle->sHandles.ipu.pwrHandle = VAYUIPUPWR_create (
+                                                           procId,
+                                                           &lv->ipuPwrParams);
+
+            if (handle->sHandles.ipu.pHandle == NULL) {
+                status = Platform_E_FAIL;
+                GT_setFailureReason (curTrace,
+                                     GT_4CLASS,
+                                     "_Platform_setup",
+                                     status,
+                                     "VAYUIPUCORE0PROC_create failed!");
+            }
+            else if (handle->sHandles.ipu.ldrHandle ==  NULL) {
+                status = Platform_E_FAIL;
+                GT_setFailureReason (curTrace,
+                                     GT_4CLASS,
+                                     "_Platform_setup",
+                                     status,
+                                     "Failed to create loader instance!");
+            }
+            else if (handle->sHandles.ipu.pwrHandle ==  NULL) {
+                status = Platform_E_FAIL;
+                GT_setFailureReason (curTrace,
+                                     GT_4CLASS,
+                                     "_Platform_setup",
+                                     status,
+                                     "VAYUIPUPWR_create failed!");
+            }
+            else {
+                /* Initialize parameters */
+                ProcMgr_Params_init (NULL, &lv->params);
+                lv->params.procHandle = handle->sHandles.ipu.pHandle;
+                lv->params.loaderHandle = handle->sHandles.ipu.ldrHandle;
+                lv->params.pwrHandle = handle->sHandles.ipu.pwrHandle;
+                handle->pmHandle = ProcMgr_create (procId, &lv->params);
+                if (handle->pmHandle == NULL) {
+                    status = Platform_E_FAIL;
+                    GT_setFailureReason (curTrace,
+                                         GT_4CLASS,
+                                         "_Platform_setup",
+                                         status,
+                                         "ProcMgr_create failed!");
+                }
+            }
+        }
+    }
+
+    if (status >= 0) {
+        /* Get MultiProc ID by name. */
+        procId = MultiProc_getId ("IPU2");
+
+        handle = &Platform_objects [procId];
+
+        if (status >= 0) {
+            /* Create an instance of the Processor object for
+             * VAYUIPUCORE0 */
+            VAYUIPUCORE0PROC_Params_init (NULL, &lv->ipuProcParams);
+            handle->sHandles.ipu.pHandle = VAYUIPUCORE0PROC_create (procId,
+                                                         &lv->ipuProcParams);
 
             /* Create an instance of the ELF Loader object */
             ElfLoader_Params_init (NULL, &lv->elfLoaderParams);
-            handle->sHandles.ipu1.ldrHandle = ElfLoader_create (procId,
+            handle->sHandles.ipu.ldrHandle = ElfLoader_create (procId,
                                                         &lv->elfLoaderParams);
 
             /* Create an instance of the PwrMgr object for VAYUIPUCORE0 */
-            VAYUIPUPWR_Params_init (&lv->vpssPwrParams);
-            handle->sHandles.ipu1.pwrHandle = VAYUIPUPWR_create (
+            VAYUIPUPWR_Params_init (&lv->ipuPwrParams);
+            handle->sHandles.ipu.pwrHandle = VAYUIPUPWR_create (
                                                            procId,
-                                                           &lv->vpssPwrParams);
+                                                           &lv->ipuPwrParams);
 
-            if (handle->sHandles.ipu1.pHandle == NULL) {
+            if (handle->sHandles.ipu.pHandle == NULL) {
                 status = Platform_E_FAIL;
                 GT_setFailureReason (curTrace,
                                      GT_4CLASS,
@@ -670,7 +845,7 @@ _Platform_setup (Ipc_Config * cfg)
                                      status,
                                      "VAYUIPUCORE0PROC_create failed!");
             }
-            else if (handle->sHandles.ipu1.ldrHandle ==  NULL) {
+            else if (handle->sHandles.ipu.ldrHandle ==  NULL) {
                 status = Platform_E_FAIL;
                 GT_setFailureReason (curTrace,
                                      GT_4CLASS,
@@ -678,7 +853,7 @@ _Platform_setup (Ipc_Config * cfg)
                                      status,
                                      "Failed to create loader instance!");
             }
-            else if (handle->sHandles.ipu1.pwrHandle ==  NULL) {
+            else if (handle->sHandles.ipu.pwrHandle ==  NULL) {
                 status = Platform_E_FAIL;
                 GT_setFailureReason (curTrace,
                                      GT_4CLASS,
@@ -689,9 +864,9 @@ _Platform_setup (Ipc_Config * cfg)
             else {
                 /* Initialize parameters */
                 ProcMgr_Params_init (NULL, &lv->params);
-                lv->params.procHandle = handle->sHandles.ipu1.pHandle;
-                lv->params.loaderHandle = handle->sHandles.ipu1.ldrHandle;
-                lv->params.pwrHandle = handle->sHandles.ipu1.pwrHandle;
+                lv->params.procHandle = handle->sHandles.ipu.pHandle;
+                lv->params.loaderHandle = handle->sHandles.ipu.ldrHandle;
+                lv->params.pwrHandle = handle->sHandles.ipu.pwrHandle;
                 handle->pmHandle = ProcMgr_create (procId, &lv->params);
                 if (handle->pmHandle == NULL) {
                     status = Platform_E_FAIL;
@@ -903,6 +1078,69 @@ _Platform_destroy (void)
     }
 
     /* ------------------------- IPU1 cleanup ------------------------------- */
+    handle = &Platform_objects [MultiProc_getId ("IPU1")];
+    if (handle->pmHandle != NULL) {
+        tmpStatus = ProcMgr_delete (&handle->pmHandle);
+        GT_assert (curTrace, (tmpStatus >= 0));
+        if ((status >= 0) && (tmpStatus < 0)) {
+            status = tmpStatus;
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "_Platform_destroy",
+                                 status,
+                                 "ProcMgr_delete failed!");
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+        }
+    }
+
+    /* Delete the Processor, Loader and PwrMgr instances */
+    if (handle->sHandles.ipu.pwrHandle != NULL) {
+        tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu.pwrHandle);
+        GT_assert (curTrace, (tmpStatus >= 0));
+        if ((status >= 0) && (tmpStatus < 0)) {
+            status = tmpStatus;
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "_Platform_destroy",
+                                 status,
+                                 "VAYUIPUPWR_delete failed!");
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+        }
+    }
+
+    if (handle->sHandles.ipu.ldrHandle != NULL) {
+        tmpStatus = ElfLoader_delete (&handle->sHandles.ipu.ldrHandle);
+        GT_assert (curTrace, (tmpStatus >= 0));
+        if ((status >= 0) && (tmpStatus < 0)) {
+            status = tmpStatus;
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "_Platform_destroy",
+                                 status,
+                                 "Failed to delete loader instance!");
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+        }
+    }
+
+    if (handle->sHandles.ipu.pHandle != NULL) {
+        tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu.pHandle);
+        GT_assert (curTrace, (tmpStatus >= 0));
+        if ((status >= 0) && (tmpStatus < 0)) {
+            status = tmpStatus;
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "_Platform_destroy",
+                                 status,
+                                 "VAYUIPUCORE0PROC_delete failed!");
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+        }
+    }
+
+    /* ------------------------- IPU2 cleanup ------------------------------- */
     handle = &Platform_objects [MultiProc_getId ("IPU2")];
     if (handle->pmHandle != NULL) {
         tmpStatus = ProcMgr_delete (&handle->pmHandle);
@@ -920,8 +1158,8 @@ _Platform_destroy (void)
     }
 
     /* Delete the Processor, Loader and PwrMgr instances */
-    if (handle->sHandles.ipu1.pwrHandle != NULL) {
-        tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu1.pwrHandle);
+    if (handle->sHandles.ipu.pwrHandle != NULL) {
+        tmpStatus = VAYUIPUPWR_delete (&handle->sHandles.ipu.pwrHandle);
         GT_assert (curTrace, (tmpStatus >= 0));
         if ((status >= 0) && (tmpStatus < 0)) {
             status = tmpStatus;
@@ -935,8 +1173,8 @@ _Platform_destroy (void)
         }
     }
 
-    if (handle->sHandles.ipu1.ldrHandle != NULL) {
-        tmpStatus = ElfLoader_delete (&handle->sHandles.ipu1.ldrHandle);
+    if (handle->sHandles.ipu.ldrHandle != NULL) {
+        tmpStatus = ElfLoader_delete (&handle->sHandles.ipu.ldrHandle);
         GT_assert (curTrace, (tmpStatus >= 0));
         if ((status >= 0) && (tmpStatus < 0)) {
             status = tmpStatus;
@@ -950,8 +1188,8 @@ _Platform_destroy (void)
         }
     }
 
-    if (handle->sHandles.ipu1.pHandle != NULL) {
-        tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu1.pHandle);
+    if (handle->sHandles.ipu.pHandle != NULL) {
+        tmpStatus = VAYUIPUCORE0PROC_delete (&handle->sHandles.ipu.pHandle);
         GT_assert (curTrace, (tmpStatus >= 0));
         if ((status >= 0) && (tmpStatus < 0)) {
             status = tmpStatus;