summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0d58cf2)
raw | patch | inline | side by side (parent: 0d58cf2)
author | vwan@ti.com <vwan@ti.com> | |
Fri, 31 May 2013 17:02:55 +0000 (10:02 -0700) | ||
committer | Chris Ring <cring@ti.com> | |
Fri, 31 May 2013 17:55:45 +0000 (10:55 -0700) |
OMAP5 power management code in this directory is moved to qnx/src/ipc3x_dev/ti/syslink/family/omap5430, and the power management code itself was modified to remove checks with rpmsg-resmgr.
Signed-off-by: VW <vwan@ti.com>
Signed-off-by: VW <vwan@ti.com>
12 files changed:
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/common.mk b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/common.mk
index 03aee5419a09e99354d0a0503410139722bac727..adf6cd8fe7742a056941fd23f7e49e77a92a659a 100644 (file)
$(SYSLINK_ROOT)/tiler/usr/memmgr/public \
$(SYSLINK_ROOT)/tiler/resmgr/tiler/public \
$(SYSLINK_ROOT)/ti/syslink/resources \
+ $(SYSLINK_ROOT)/ti/syslink/family/common \
$(IPC_REPO)/qnx/include \
$(IPC_REPO)/hlos_common/include \
$(IPC_REPO)/packages \
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_main.c b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_main.c
index 7269814b719e32fd9882641df349c399b719f81c..b2cfd0afcee93f67bddbb93691826bd1b01a959e 100644 (file)
pthread_mutex_t syslink_hib_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t syslink_hib_cond = PTHREAD_COND_INITIALIZER;
-extern int rpmsg_resmgr_setup (void);
-extern void rpmsg_resmgr_destroy (void);
extern Int rpmsg_rpc_setup (Void);
extern Void rpmsg_rpc_destroy (Void);
extern Void GateHWSpinlock_LeaveLockForPID(int pid);
int init_syslink_device(syslink_dev_t *dev)
{
iofunc_attr_t * attr;
- syslink_attr_t * trace_attr;
resmgr_attr_t resmgr_attr;
- int i;
- char trace_name[_POSIX_PATH_MAX];
int status = 0;
pthread_mutex_init(&dev->lock, NULL);
}
if (status < 0)
- goto resmgrsetup_fail;
-
- /* Set up the resmgr */
- status = rpmsg_resmgr_setup();
- if (status < 0)
- goto resmgrsetup_fail;
+ goto tiipcsetup_fail;
/* Set up rpmsg_mq */
status = ti_ipc_setup();
rpcsetup_fail:
ti_ipc_destroy(recover);
tiipcsetup_fail:
- rpmsg_resmgr_destroy();
-resmgrsetup_fail:
for (i-=1; i >= 0; i--) {
procId = firmware[i].proc_id;
ProcMgr_unregisterNotify(procH[procId], syslink_error_cb,
ti_ipc_destroy(recover);
- rpmsg_resmgr_destroy();
-
for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
if (procH[i]) {
ProcMgr_unregisterNotify (procH[i], syslink_error_cb, (Ptr)dev,
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/ipu_pm.h b/qnx/src/ipc3x_dev/ti/syslink/family/common/ipu_pm.h
similarity index 99%
rename from qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/ipu_pm.h
rename to qnx/src/ipc3x_dev/ti/syslink/family/common/ipu_pm.h
index 56ff8e4d5e7cc5118d913fe60bdf3787782e601b..49c273838da722799bc37477d41ba3fd90394667 100644 (file)
rename from qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/ipu_pm.h
rename to qnx/src/ipc3x_dev/ti/syslink/family/common/ipu_pm.h
index 56ff8e4d5e7cc5118d913fe60bdf3787782e601b..49c273838da722799bc37477d41ba3fd90394667 100644 (file)
#include <_MultiProc.h>
#include <stdint.h>
#include <stdbool.h>
-#include "rpmsg_resmgr.h"
#ifndef _IPU_PM_H
#define _IPU_PM_H
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap5430/_ipu_pm.h b/qnx/src/ipc3x_dev/ti/syslink/family/omap5430/ipu/_ipu_pm.h
similarity index 100%
rename from qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap5430/_ipu_pm.h
rename to qnx/src/ipc3x_dev/ti/syslink/family/omap5430/ipu/_ipu_pm.h
rename from qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap5430/_ipu_pm.h
rename to qnx/src/ipc3x_dev/ti/syslink/family/omap5430/ipu/_ipu_pm.h
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap5430/ipu_pm.c b/qnx/src/ipc3x_dev/ti/syslink/family/omap5430/ipu/ipu_pm.c
similarity index 99%
rename from qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap5430/ipu_pm.c
rename to qnx/src/ipc3x_dev/ti/syslink/family/omap5430/ipu/ipu_pm.c
index ac59fd8e8c38095accfa7da85dffe3fa96ba67b2..0a7ac1ca1b69507566cfa8ef51adffe0ee9490b4 100644 (file)
rename from qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap5430/ipu_pm.c
rename to qnx/src/ipc3x_dev/ti/syslink/family/omap5430/ipu/ipu_pm.c
index ac59fd8e8c38095accfa7da85dffe3fa96ba67b2..0a7ac1ca1b69507566cfa8ef51adffe0ee9490b4 100644 (file)
#include <OMAP5430BenelliProc.h>
#include <ArchIpcInt.h>
#include <_Omap5430IpcInt.h>
-#include <rpmsg-resmgrdrv.h>
#include <OMAP5430BenelliHalReset.h>
@@ -319,6 +318,27 @@ static reply_getListOfDomainOPPs_t cpudll_iva_opp = { {0} }; /* for result of g
static reply_getListOfDomainOPPs_t cpudll_core_opp = { {0} }; /* for result of getDomainOPP (CORE)*/
#endif
+enum {
+ RPRM_GPTIMER = 0,
+ RPRM_IVAHD = 1,
+ RPRM_IVASEQ0 = 2,
+ RPRM_IVASEQ1 = 3,
+ RPRM_L3BUS = 4,
+ RPRM_ISS = 5,
+ RPRM_FDIF = 6,
+ RPRM_SL2IF = 7,
+ RPRM_AUXCLK = 8,
+ RPRM_REGULATOR = 9,
+ RPRM_GPIO = 10,
+ RPRM_SDMA = 11,
+ RPRM_IPU = 12,
+ RPRM_DSP = 13,
+ RPRM_I2C = 14,
+ RPRM_CAMERA = 15,
+ RPRM_LED = 16,
+ RPRM_MAX
+};
+
enum processor_version get_omap_version (void)
{
uintptr_t id_code_base = NULL;
goto exit;
}
- if (rpmsg_resmgr_allow_hib(core0_id) &&
- rpmsg_resmgr_allow_hib(core1_id) &&
- !TESTBITREG32((uintptr_t)m3_clkstctrl,
- CM_MPU_M3_CLKSTCTRL_CLKACTIVITY_BIT)) {
- retval = ArchIpcInt_sendInterrupt(core0_id,
- ipu_pm_state.cfg.int_id,
- RP_MBOX_HIBERNATION);
- }
- else {
- /* restart timer */
- configure_timer(syslink_hib_timeout / 1000, 0);
- goto exit;
- }
+ !TESTBITREG32((uintptr_t)m3_clkstctrl,
+ CM_MPU_M3_CLKSTCTRL_CLKACTIVITY_BIT)) {
+ retval = ArchIpcInt_sendInterrupt(core0_id,
+ ipu_pm_state.cfg.int_id,
+ RP_MBOX_HIBERNATION);
num_loaded_cores = core1_loaded + core0_loaded;
flag = 1;
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/SysLinkMemUtils.c b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/SysLinkMemUtils.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/*
- * Syslink-IPC for TI OMAP Processors
- *
- * Copyright (c) 2008-2010, Texas Instruments Incorporated
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*============================================================================
- * @file SysLinkMemUtils.c
- *
- * @brief This modules provides syslink Mem utils functionality
- * ============================================================================
- */
-
-
-/* Linux specific header files */
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdint.h>
-/* Standard headers */
-#include <ti/syslink/Std.h>
-#include <std_qnx.h>
-
-/* OSAL & Utils headers */
-#include <ti/syslink/utils/Memory.h>
-#include <ti/syslink/utils/Trace.h>
-#include <ti/syslink/utils/List.h>
-#include <OsalSemaphore.h>
-
-/* Module level headers */
-#include <ti/ipc/MultiProc.h>
-#include <ti/syslink/ProcMgr.h>
-#include <SysLinkMemUtils.h>
-#include <memmgr/memmgr.h>
-#include <memmgr/tilermem.h>
-#include <memmgr/tilermgr.h>
-
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-
-/* =============================================================================
- * Macros and types
- * =============================================================================
- */
-/*! @brief Page size */
-#define Page_SIZE_4K 4096
-/*! @brief Page Mask */
-#define Page_MASK(pg_size) (~((pg_size)-1))
-/*! @brief Align to lower Page */
-#define Page_ALIGN_LOW(addr, pg_size) ((addr) & Page_MASK(pg_size))
-/*! @brief Start address of Tiler region */
-#define TILER_ADDRESS_START 0x60000000
-/*! @brief End address of Tiler region */
-#define TILER_ADDRESS_END 0x80000000
-
-/*!
- * @brief Alloc parameter structure
- */
-typedef struct {
- UInt pixelFormat;
- /*!< Pixel format */
- UInt width;
- /*!< Width of the buffer */
- UInt height;
- /*!< Height of the buffer */
- UInt length;
- /*!< Length of the buffer */
- UInt stride;
- /*!< stride */
- Ptr ptr;
- /*!< Buffer pointer */
- UInt * reserved;
- /*!< Reserved */
-} AllocParams;
-
-/*!
- * @brief Parameter for remote MemMgr_alloc
- */
-typedef struct {
- UInt numBuffers;
- /*!< Number of buffer */
- AllocParams params [1];
- /*!< Alloc param struct */
-} AllocArgs;
-
-/*!
- * @brief Parameter for remote MemMgr_free
- */
-typedef struct {
- Ptr bufPtr;
- /*!< Buffer pointer */
-} FreeArgs;
-
-/*!
- * @brief Structure element used to store a mapped buffer
- */
-typedef struct {
- List_Elem elem;
- /*!< List element */
- Ptr da;
- /*!< Device address */
- Ptr ua;
- /*!< User address */
- UInt32 size;
- /*!< Size of the mapping */
-} AddrNode;
-
-/*!
- * @brief SysLinkMemUtils Module state object
- */
-typedef struct SysLinkMemUtils_ModuleObject_tag {
- List_Handle addrTable;
- /*!< Table where the device address and A9 address will be stored. */
- OsalSemaphore_Handle semList;
- /*!< Semaphore to protect the table */
-} SysLinkMemUtils_ModuleObject;
-
-/* =============================================================================
- * Globals
- * =============================================================================
- */
-/*!
- * @var SysLinkMemUtils_state
- *
- * @brief SysLinkMemUtils state object variable
- */
-#if !defined(SYSLINK_BUILD_DEBUG)
-static
-#endif /* if !defined(SYSLINK_BUILD_DEBUG) */
-SysLinkMemUtils_ModuleObject SysLinkMemUtils_state =
-{
- .addrTable = NULL,
- .semList = NULL,
-};
-
-/*!
- * @var SysLinkMemUtils_module
- *
- * @brief Pointer to the SysLinkMemUtils module state
- */
-#if !defined(SYSLINK_BUILD_DEBUG)
-static
-#endif /* if !defined(SYSLINK_BUILD_DEBUG) */
-SysLinkMemUtils_ModuleObject * SysLinkMemUtils_module = &SysLinkMemUtils_state;
-
-
-/* =============================================================================
- * APIs
- * =============================================================================
- */
-
-static Void _SysLinkMemUtils_init (Void) __attribute__((constructor));
-/*!
- * @brief Setup SysLinkMemUtils module.
- *
- * @sa _SysLinkMemUtils_exit
- */
-static Void
-_SysLinkMemUtils_init (Void)
-{
- List_Params listParams;
-
- GT_0trace (curTrace, GT_ENTER, "_SysLinkMemUtils_init");
-
- MemoryOS_setup();
-
- List_Params_init (&listParams);
- SysLinkMemUtils_module->addrTable = List_create (&listParams);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- if (!SysLinkMemUtils_module->addrTable) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- ProcMgr_E_MEMORY,
- "Translation list could not be created!");
- }
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
-
- SysLinkMemUtils_module->semList = OsalSemaphore_create (
- OsalSemaphore_Type_Binary);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- if (!SysLinkMemUtils_module->semList) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- ProcMgr_E_MEMORY,
- "List semaphore could not be created!");
- }
- else {
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- OsalSemaphore_post(SysLinkMemUtils_module->semList);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- }
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
-
- GT_0trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_init");
-}
-
-
-static Void _SysLinkMemUtils_exit (Void) __attribute__((destructor));
-/*!
- * @brief Free resources allocated in setup part
- *
- * @sa _SysLinkMemUtils_init
- */
-static Void
-_SysLinkMemUtils_exit (Void)
-{
- GT_0trace (curTrace, GT_ENTER, "_SysLinkMemUtils_exit");
-
- List_delete (&SysLinkMemUtils_module->addrTable);
- OsalSemaphore_delete (&SysLinkMemUtils_module->semList);
-
- MemoryOS_destroy();
-
- GT_0trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_exit");
-}
-
-
-/*!
- * @brief Find a node inside the Translation Table which da matches
- *
- * @params da Device address
- *
- * @sa _SysLinkMemUtils_insertMapElement, _SysLinkMemUtils_removeMapElement
- */
-static AddrNode *
-_SysLinkMemUtils_findNode (Ptr da)
-{
- AddrNode * node;
-
- GT_1trace (curTrace, GT_ENTER, "_SysLinkMemUtils_findNode", da);
-
- for (node = List_next (SysLinkMemUtils_module->addrTable, NULL);
- node != NULL; node = List_next (SysLinkMemUtils_module->addrTable,
- &node->elem)) {
- if (da >= node->da && da < node->da + node->size) {
- break;
- }
- }
-
- GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_findNode", node);
-
- return node;
-}
-
-
-/*!
- * @brief Insert an entry into the Translation Table
- *
- * @param da Device address
- * @param ua User address
- * @param size Buffer size
- *
- * @sa _SysLinkMemUtils_removeMapElement
- */
-static Int32
-_SysLinkMemUtils_insertMapElement (Ptr da, Ptr ua, UInt32 size)
-{
- AddrNode * node;
- Int32 status = ProcMgr_S_SUCCESS;
-
- GT_3trace (curTrace, GT_ENTER, "_SysLinkMemUtils_insertMapElement", da, ua,
- size);
-
- node = Memory_alloc (NULL, sizeof (AddrNode), 0, NULL);
- if (!node) {
- status = ProcMgr_E_MEMORY;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "Error allocating node memory!");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else {
- node->ua = ua;
- node->da = da;
- node->size = size;
- OsalSemaphore_pend (SysLinkMemUtils_module->semList,
- OSALSEMAPHORE_WAIT_FOREVER);
- List_put (SysLinkMemUtils_module->addrTable, &node->elem);
- OsalSemaphore_post (SysLinkMemUtils_module->semList);
- }
-
- GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_insertMapElement", status);
-
- return status;
-}
-
-
-/*!
- * @brief Remove and delete entry from the Translation Table
- *
- * @param da Device address
- *
- * @sa _SysLinkMemUtils_insertMapElement
- */
-static Ptr
-_SysLinkMemUtils_removeMapElement (Ptr da)
-{
- AddrNode * node;
- Ptr addr = NULL;
-
- GT_1trace (curTrace, GT_ENTER, "_SysLinkMemUtils_removeMapElement", da);
-
- OsalSemaphore_pend (SysLinkMemUtils_module->semList,
- OSALSEMAPHORE_WAIT_FOREVER);
- node = _SysLinkMemUtils_findNode (da);
- if (!node || node->da != da) {
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- ProcMgr_E_FAIL,
- "Entry not found!");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else {
- addr = node->ua;
- List_remove (SysLinkMemUtils_module->addrTable, &node->elem);
- Memory_free (NULL, node, sizeof (AddrNode));
- }
- OsalSemaphore_post (SysLinkMemUtils_module->semList);
-
- GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_removeMapElement", addr);
-
- return addr;
-}
-
-
-/*!
- * @brief Get the size of a MemAllocBlock array
- *
- * @param memBlock Pointer to a mem block array
- * @param numBuffers Number of mem blocks
- *
- * @sa SysLinkMemUtils_alloc
- */
-static UInt32
-_SysLinkMemUtils_bufferSize (MemAllocBlock * memBlock, UInt numBlocks)
-{
- UInt32 i;
- UInt32 size = 0;
-
- GT_2trace (curTrace, GT_ENTER, "_SysLinkMemUtils_bufferSize", memBlock,
- numBlocks);
-
- for (i = 0; i < numBlocks; i++, memBlock++) {
- if (memBlock->pixelFormat == PIXEL_FMT_PAGE) {
- size += memBlock->dim.len;
- }
- else {
- size += memBlock->dim.area.height * memBlock->stride;
- }
- }
-
- GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_bufferSize", size);
-
- return size;
-}
-
-
-/*!
- * @brief Get a valid A9 address from a remote proc address
- *
- * This function can be called by an app running
- * in A9 to access a buffer allocated from remote processor.
- *
- * @param da Device address
- *
- * @sa SysLinkMemUtils_alloc, SysLinkMemUtils_free
- */
-Ptr
-SysLinkMemUtils_DAtoVA (Ptr da)
-{
- AddrNode * node;
- Ptr addr = NULL;
-
- GT_1trace (curTrace, GT_ENTER, "SysLinkMemUtils_DAtoVA", da);
-
- OsalSemaphore_pend (SysLinkMemUtils_module->semList,
- OSALSEMAPHORE_WAIT_FOREVER);
- node = _SysLinkMemUtils_findNode (da);
- OsalSemaphore_post (SysLinkMemUtils_module->semList);
- if (node) {
- addr = node->ua + (da - node->da);
- }
-
- GT_1trace (curTrace, GT_LEAVE, "SysLinkMemUtils_DAtoVA", addr);
-
- return addr;
-}
-
-
-/*!
- * @brief Allocate memory for remote processor application
- *
- * This function is called by remote processor application to
- * Allocate a buffer.
- *
- * @param dataSize Size of the marshalled data packet
- * @param data Marshalled data packet
- *
- * @sa SysLinkMemUtils_free
- */
-Int32
-SysLinkMemUtils_alloc (UInt32 dataSize, UInt32 * data)
-{
-
- AllocArgs * args = (AllocArgs *)data;
- Int i;
- MemAllocBlock * memBlock = NULL;
- Ptr allocedPtr = NULL;
- UInt32 retAddr = 0;
- UInt32 size = 0;
- Int32 status = ProcMgr_S_SUCCESS;
- SyslinkMemUtils_MpuAddrToMap mpuAddrList [1];
-
- GT_2trace (curTrace, GT_ENTER, "SysLinkMemUtils_alloc", dataSize, data);
-
- memBlock = Memory_calloc (NULL, sizeof (MemAllocBlock) * args->numBuffers,
- 0, NULL);
- if (!memBlock) {
- status = ProcMgr_E_MEMORY;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "Error allocating memBlock");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else {
- /* Validate the data size */
- if (dataSize < sizeof(AllocArgs)) {
- status = ProcMgr_E_INVALIDARG;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "dataSize is not large enough");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else if (dataSize < sizeof(AllocArgs) + sizeof(AllocParams) * (args->numBuffers - 1)) {
- status = ProcMgr_E_INVALIDARG;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "dataSize is not large enough");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else {
- for (i = 0; i < args->numBuffers; i++) {
- memBlock [i].pixelFormat = args->params [i].pixelFormat;
- memBlock [i].dim.area.width = args->params [i].width;
- memBlock [i].dim.area.height = args->params [i].height;
- memBlock [i].dim.len = args->params [i].length;
- }
- }
- }
-
- if (status == ProcMgr_S_SUCCESS) {
- /* Allocation */
- allocedPtr = MemMgr_Alloc (memBlock, args->numBuffers);
- if (!allocedPtr) {
- status = ProcMgr_E_MEMORY;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "Error MemMgr buffer");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- }
-
- if (status == ProcMgr_S_SUCCESS) {
- for (i = 0; i < args->numBuffers; i++) {
- args->params [i].stride = memBlock [i].stride;
- args->params [i].ptr = memBlock [i].ptr;
- }
- size = _SysLinkMemUtils_bufferSize (memBlock, args->numBuffers);
- mpuAddrList [0].mpuAddr = (UInt32)allocedPtr;
- mpuAddrList [0].size = size;
- status = SysLinkMemUtils_map (mpuAddrList, 1, &retAddr,
- ProcMgr_TILER, PROC_CORE0);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- if (status != ProcMgr_S_SUCCESS) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "Error in SysLinkMemUtils_map");
- }
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
-
- if (status == ProcMgr_S_SUCCESS) {
- status = _SysLinkMemUtils_insertMapElement ((Ptr)retAddr,
- allocedPtr, size);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- if (status != ProcMgr_S_SUCCESS) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "Error in SysLinkMemUtils_InsertMapElement");
- }
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
-
- if (status != ProcMgr_S_SUCCESS) {
- if (retAddr) {
- SysLinkMemUtils_unmap (retAddr, PROC_CORE0, ProcMgr_TILER);
- }
- if (allocedPtr) {
- MemMgr_Free (allocedPtr);
- }
- }
-
- if (memBlock)
- Memory_free (NULL, memBlock, 1);
-
- GT_1trace (curTrace, GT_LEAVE, "SysLinkMemUtils_alloc", retAddr);
-
- return retAddr;
-}
-
-
-/*!
- * @brief Free memory allocated by SysLinkMemUtils_alloc
- *
- * This function is called by remote processor application to
- * Free a previous allocated userspace buffer.
- *
- * @param dataSize Size of the marshalled data packet
- * @param data Marshalled data packet
- *
- * @sa SysLinkMemUtils_alloc
- */
-Int32
-SysLinkMemUtils_free (UInt32 dataSize, UInt32 * data)
-{
- FreeArgs * args = (FreeArgs *)data;
- Ptr ua;
- Int32 status;
-
- GT_2trace (curTrace, GT_ENTER, "SysLinkMemUtils_free", dataSize, data);
-
- /* Validate the data size */
- if (dataSize < sizeof(FreeArgs)) {
- status = ProcMgr_E_INVALIDARG;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "dataSize is not large enough");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else {
- ua = _SysLinkMemUtils_removeMapElement (args->bufPtr);
- if (!ua) {
- status = ProcMgr_E_INVALIDARG;
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "Not valid address");
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- }
- else {
- status = SysLinkMemUtils_unmap ((UInt32)ua, PROC_CORE0, ProcMgr_TILER);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- (Char *)__func__,
- status,
- "SysLinkMemUtils_unmap failed!");
- }
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- status = MemMgr_Free (ua);
- }
- }
-
- GT_1trace (curTrace, GT_LEAVE, "SysLinkMemUtils_free", status);
-
- return !!status;
-}
-
-
-/*!
- * @brief Function to Map Host processor to Remote processors
- * module.
- *
- * This function can be called by the application to map their
- * address space to remote slave's address space.
- *
- * @param MpuAddr
- *
- * @sa SysLinkMemUtils_unmap
- */
-Int
-SysLinkMemUtils_map (SyslinkMemUtils_MpuAddrToMap mpuAddrList[],
- UInt32 numOfBuffers,
- UInt32 * mappedAddr,
- ProcMgr_MapMask memType,
- ProcMgr_ProcId procId)
-{
- ProcMgr_Handle procMgrHandle;
- Int32 status = ProcMgr_S_SUCCESS;
- ProcMgr_AddrInfo addrInfo;
-
- if (numOfBuffers > 1) {
- status = ProcMgr_E_INVALIDARG;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_map",
- ProcMgr_E_INVALIDARG,
- "numBufError!");
- return status;
- }
-
- if (procId == PROC_CORE1) {
- procId = PROC_CORE0;
- }
- if (memType == ProcMgr_TILER) {
- /* TILER addresses are pre-mapped, so just return the TILER ssPtr */
- *mappedAddr = TilerMem_VirtToPhys ((void *)mpuAddrList[0].mpuAddr);
- return status;
- }
-
- /* Open a handle to the ProcMgr instance. */
- status = ProcMgr_open (&procMgrHandle, procId);
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_map",
- status,
- "Error in ProcMgr_open!");
- }
- else {
- addrInfo.addr[ProcMgr_AddrType_MasterPhys]= mpuAddrList[0].mpuAddr;
- addrInfo.size = mpuAddrList[0].size;
- addrInfo.isCached = FALSE;
- status = ProcMgr_map(procMgrHandle, memType,&addrInfo, ProcMgr_AddrType_MasterUsrVirt);
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_map",
- status,
- "Error in ProcMgr_map!");
- }
- else {
- status = ProcMgr_close (&procMgrHandle);
- }
- }
- return status;
-}
-
-
-/*!
- * @brief Function to unmap
- *
- *
- * @param mappedAddr The remote address to unmap
- * @param procId The remote Processor ID
- *
- * @sa SysLinkMemUtils_map
- */
-Int
-SysLinkMemUtils_unmap (UInt32 mappedAddr, ProcMgr_ProcId procId, ProcMgr_MapMask memType)
-{
- ProcMgr_Handle procMgrHandle;
- Int32 status = ProcMgr_S_SUCCESS;
- ProcMgr_MapMask mapType = ProcMgr_MASTERUSRVIRT;
- ProcMgr_AddrInfo addrInfo;
- ProcMgr_AddrType srcAddrType = ProcMgr_AddrType_SlaveVirt;
-
-
- /* Open a handle to the ProcMgr instance. */
- if (procId == PROC_CORE1) {
- procId = PROC_CORE0;
- }
-
- if (memType == ProcMgr_TILER) {
- /*TBD: Need to check if the unmapping is required*/
- return status;
- }
- /* Open a handle to the ProcMgr instance. */
- status = ProcMgr_open (&procMgrHandle, procId);
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_unmap",
- status,
- "Error in ProcMgr_open!");
- }
- else {
- addrInfo.addr[ProcMgr_MASTERUSRVIRT] = mappedAddr;
- addrInfo.isCached = FALSE;
- status = ProcMgr_unmap(procMgrHandle, mapType, &addrInfo, srcAddrType);
- /* FIX ME: Add Proc unreserve call */
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_unmap",
- status,
- "Error in ProcMgr_unmap!");
- }
- else {
- status = ProcMgr_close (&procMgrHandle);
- }
- }
-
- return status;
-}
-
-
-/*!
- * @brief Function to retrieve physical entries given a remote
- * Processor's virtual address.
- *
- * This function returns success state of this function
- *
- * @param remoteAddr The slave's address
- * @param size size of buffer
- * @param physEntries Translated physical addresses of each Page.
- * @param procId Remote Processor Id.
- * @param flags Used to pass any custom information for optimization.
- *
- * @sa SysLinkMemUtils_virtToPhys
- */
-Int
-SysLinkMemUtils_virtToPhysPages (UInt32 remoteAddr,
- UInt32 numOfPages,
- UInt32 physEntries[],
- ProcMgr_ProcId procId)
-{
- Int i;
- Int32 status = ProcMgr_S_SUCCESS;
- ProcMgr_Handle procMgrHandle;
-
- GT_1trace (curTrace, GT_ENTER, "SysLinkMemUtils_virtToPhys: remote Addr",
- remoteAddr);
-
- if (physEntries == NULL || (numOfPages == 0)) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_virtToPhysPages",
- ProcMgr_E_FAIL,
- "Input arguments invalid!");
- return ProcMgr_E_FAIL;
- }
-
- if (procId == PROC_CORE1) {
- procId = PROC_CORE0;
- }
-
- GT_0trace (curTrace, GT_1CLASS, "testing with ProcMgr_virtToPhysPages");
-
- /* Open a handle to the ProcMgr instance. */
- status = ProcMgr_open (&procMgrHandle, procId);
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_virtToPhysPages",
- ProcMgr_E_FAIL,
- "Error in ProcMgr_open!");
- return ProcMgr_E_FAIL;
- }
- /* TODO: Hack for tiler */
- if(remoteAddr >= TILER_ADDRESS_START && remoteAddr < TILER_ADDRESS_END) {
- for(i = 0; i < numOfPages; i++) {
- physEntries[i] = Page_ALIGN_LOW(remoteAddr, Page_SIZE_4K) + (4096 * i);
- }
- }
- else {
-#if 0
- status = ProcMgr_virtToPhysPages (procMgrHandle, remoteAddr,
- numOfPages, physEntries, procId);
-#endif
- }
-
- if (status < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_virtToPhysPages",
- status,
- "Error in ProcMgr_virtToPhysPages!");
- }
- else {
- for (i = 0; i < numOfPages; i++) {
- GT_2trace (curTrace, GT_1CLASS, "physEntries[%d] = 0x%x", i, physEntries[i]);
- }
- }
-
- status = ProcMgr_close (&procMgrHandle);
-
- return status;
-}
-
-
-/*!
- * @brief Function to retrieve physical address of given a remote
- * Processor's virtual address.
- *
- * Return value of less than or equal to zero
- * indicates the translation failure
- *
- * @param remoteAddr The slave's address
- * @param physAddr Translated physical address.
- * @param procId Remote Processor Id.
- *
- * @sa SysLinkMemUtils_virtToPhysPages
- */
-Int
-SysLinkMemUtils_virtToPhys (UInt32 remoteAddr,
- UInt32 * physAddr,
- ProcMgr_ProcId procId)
-{
- /* FIX ME: Hack for Tiler */
- if (remoteAddr >= TILER_ADDRESS_START && remoteAddr <= TILER_ADDRESS_END) {
- *physAddr = remoteAddr;
- GT_1trace (curTrace, GT_1CLASS, "Translated Address = 0x%x", remoteAddr);
- return ProcMgr_S_SUCCESS;
- }
- else {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "SysLinkMemUtils_virtToPhys",
- ProcMgr_E_FAIL,
- "NON-TILER ADDRESS TRANSLATIONS NOT SUPPORTED!");
- return ProcMgr_E_FAIL;
- }
-}
-
-#if defined (__cplusplus)
-}
-#endif /* defined (__cplusplus) */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/SysLinkMemUtils.h b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/SysLinkMemUtils.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Syslink-IPC for TI OMAP Processors
- *
- * Copyright (c) 2008-2010, Texas Instruments Incorporated
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** ============================================================================
- * @file SysLinkMemUtils.h
- *
- *
- *
- * ============================================================================
- */
-
-
-#ifndef SYSLINKMEMUTILS_H_0xf2ba
-#define SYSLINKMEMUTILS_H_0xf2ba
-
-
-/* Standard headers */
-#include <ti/syslink/Std.h>
-#include <ti/syslink/ProcMgr.h>
-
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-/* =============================================================================
- * Structures & Enums
- * =============================================================================
- */
-/*!
- * @brief Structure defining the MPU address to map to Remote Address
- */
-typedef struct {
- UInt32 mpuAddr;
- /*!< Host Address to Map*/
- UInt32 size;
- /*!< Size of the Buffer to Map */
-} SyslinkMemUtils_MpuAddrToMap;
-
-/* =============================================================================
- * APIs
- * =============================================================================
- */
-
-Ptr
-SysLinkMemUtils_DAtoVA (Ptr da);
-
-Int32
-SysLinkMemUtils_alloc (UInt32 dataSize, UInt32 *data);
-
-Int32
-SysLinkMemUtils_free (UInt32 dataSize, UInt32 *data);
-
-Int
-SysLinkMemUtils_map (SyslinkMemUtils_MpuAddrToMap mpuAddrList[],
- UInt32 numOfBuffers,
- UInt32 * mappedAddr,
- ProcMgr_MapMask memType,
- ProcMgr_ProcId procId);
-
-Int
-SysLinkMemUtils_unmap (UInt32 mappedAddr, ProcMgr_ProcId procId, ProcMgr_MapMask memType);
-
-Int
-SysLinkMemUtils_virtToPhysPages (UInt32 remoteAddr,
- UInt32 numOfPages,
- UInt32 physEntries[],
- ProcMgr_ProcId procId);
-
-Int
-SysLinkMemUtils_virtToPhys (UInt32 remoteAddr,
- UInt32 * physAddr,
- ProcMgr_ProcId procId);
-
-#if defined (__cplusplus)
-}
-#endif /* defined (__cplusplus) */
-
-#endif /* SYSLINKMEMUTILS_H_0xf2ba */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap4430/_ipu_pm.h b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap4430/_ipu_pm.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Remote processor power management
- *
- * Copyright (c) 2011-2013 Texas Instruments. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Texas Instruments nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __IPU_PM_H
-#define __IPU_PM_H
-
-typedef enum {
- GPTIMER_3 = 0,
- GPTIMER_4,
- GPTIMER_9,
- GPTIMER_11,
- GPTIMER_MAX
-} GPTIMER_NUM;
-
-enum pm_hib_timer_event{
- PM_HIB_TIMER_RESET,
- PM_HIB_TIMER_OFF,
- PM_HIB_TIMER_ON,
- PM_HIB_TIMER_DELETE,
- PM_HIB_TIMER_WDRESET,
- PM_HIB_TIMER_EXPIRE
-};
-
-typedef enum {
- CPUDLL_IVA_OPPNONE = 0,
- CPUDLL_IVA_OPP50 = CPUDLL_IVA_OPPNONE,
- CPUDLL_IVA_OPP100,
- CPUDLL_IVA_OPPTURBO
-} cpudll_iva_opp_t;
-
-#define WAIT_FOR_IDLE_TIMEOUT 1000u
-
-#define PM_HIB_DEFAULT_TIME 5000 /* 5 SEC */
-
-#endif /* __IPU_PM_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap4430/ipu_pm.c b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/family/omap4430/ipu_pm.c
+++ /dev/null
@@ -1,2114 +0,0 @@
-/*
- * @file ipu_pm.c
- *
- * @brief power management for remote processors.
- *
- * ============================================================================
- *
- * Copyright (c) 2011, Texas Instruments Incorporated
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * Contact information for paper mail:
- * Texas Instruments
- * Post Office Box 655303
- * Dallas, Texas 75265
- * Contact information:
- * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
- * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
- * ============================================================================
- *
- */
-
-/* Standard headers */
-#include <ti/syslink/Std.h>
-
-/*QNX specific header include */
-#include <errno.h>
-#include <unistd.h>
-#include <sys/iofunc.h>
-#include <sys/dispatch.h>
-#include <sys/netmgr.h>
-#include <sys/rsrcdbmgr.h>
-#include <sys/rsrcdbmsg.h>
-#define QNX_PM_ENABLE
-#ifdef QNX_PM_ENABLE
-#include <sys/powman.h>
-#include <cpu_dll_msg.h>
-#endif
-
-/* Module headers */
-#include <ipu_pm.h>
-#include <_ipu_pm.h>
-#include <sys/mman.h>
-#include <hw/inout.h>
-#include <time.h>
-#include <sys/siginfo.h>
-#include <stdbool.h>
-#include <ti/ipc/MultiProc.h>
-#include <ti/syslink/ProcMgr.h>
-#include <OMAP4430DucatiProc.h>
-#include <ArchIpcInt.h>
-#include <_Omap4430IpcInt.h>
-#include <rpmsg-resmgrdrv.h>
-
-#include <OMAP4430DucatiHalReset.h>
-#include <OMAP4430DucatiEnabler.h>
-
-#include <camera/camdrv.h>
-#include <Omap4430IpcInt.h>
-#include <ti/syslink/utils/OsalPrint.h>
-#include <rprcfmt.h>
-#include <Bitops.h>
-#include <_rpmsg.h>
-
-/* Defines the ipu_pm state object, which contains all the module
- * specific information. */
-struct ipu_pm_module_object {
- atomic_t ref_count;
- /* Reference count */
- ipu_pm_config cfg;
- /* Module configuration */
- pthread_mutex_t mtx;
- /* Handle of gate to be used for local thread safety */
- int ivahd_use_cnt;
- /* Count of ivahd users */
- int ivaseq0_use_cnt;
- /* Count of ivaseq0 users */
- int ivaseq1_use_cnt;
- /* Count of ivaseq1 users */
- ProcMgr_Handle proc_handles[MultiProc_MAXPROCESSORS];
- /* Array of processor handles */
- uint32_t loaded_procs;
- /* Info on which procs are loaded */
- uint32_t proc_state;
- /* Current state of the remote procs */
- timer_t hibernation_timer;
- /* Timer used for hibernation */
- int hib_timer_state;
- /* State of the hibernation timer */
- OsalIsr_Handle gpt9IsrObject;
- /* ISR handle for gpt9 WDT */
- OsalIsr_Handle gpt11IsrObject;
- /* ISR handle for gpt11 WDT */
- bool attached[MultiProc_MAXPROCESSORS];
- /* Indicates whether the ipu_pm module is attached. */
- bool is_setup;
- /* Indicates whether the ipu_pm module is setup. */
-};
-
-static struct ipu_pm_module_object ipu_pm_state = {
- .ivahd_use_cnt = 0,
- .loaded_procs = 0,
- .proc_state = 0,
-} ;
-
-/*******************************************************************************
-* Lenth of Boot code
-*******************************************************************************/
-#define LENGTH_BOOT_CODE1 14
-
-/*******************************************************************************
-* Hex code to set for Stack setting, Interrupt vector setting
-* and instruction to put ICONT in WFI mode.
-* This shall be placed at TCM_BASE_ADDRESS of given IVAHD, which is
-* 0x0000 locally after reset.
-*******************************************************************************/
-
-const unsigned int IVAHD_memory_wfi1[LENGTH_BOOT_CODE1] = {
-0xEA000006,
-0xEAFFFFFE,
-0xEAFFFFFE,
-0xEAFFFFFE,
-0xEAFFFFFE,
-0xEAFFFFFE,
-0xEAFFFFFE,
-0xEAFFFFFE,
-0xE3A00000,
-0xEE070F9A,
-0xEE070F90,
-0xE3A00000,
-0xEAFFFFFE,
-0xEAFFFFF1
-};
-
-enum processor_version {
- OMAP_4430 = 0,
- OMAP_4460,
- OMAP_4470,
- ERROR_CONTROL_ID = -1,
- INVALID_SI_VERSION = -2
-};
-
-extern Bool syslink_hib_enable;
-extern uint32_t syslink_hib_timeout;
-extern Bool syslink_hib_hibernating;
-extern pthread_mutex_t syslink_hib_mutex;
-extern pthread_cond_t syslink_hib_cond;
-
-#define DUCATI_SELF_HIBERNATION
-#define DUCATI_WATCHDOG_TIMER
-
-/* A9 state flag 0000 | 0000 Ducati internal use*/
-#define CORE0_PROC_DOWN 0x00010000
-#define CORE1_PROC_DOWN 0x00020000
-
-#define CORE0_LOADED 0x1
-#define CORE1_LOADED 0x2
-#define DSP_LOADED 0x4
-
-#ifdef DUCATI_SELF_HIBERNATION
-/* A9-M3 mbox status */
-#define A9_M3_MBOX 0x4A0F4000
-#define MBOX_MESSAGE_STATUS 0x000000CC
-
-/* Flag provided by BIOS */
-#define IDLE_FLAG_DUCATI_ADDR_MAP_BASE 0x9F0F0000
-#define IDLE_FLAG_PHY_ADDR_OFFSET 0x2D8
-
-/* BIOS flags states for each core in IPU */
-static void *core0Idle = NULL;
-static void *core1Idle = NULL;
-static void *a9_m3_mbox = NULL;
-static void *m3_clkstctrl = NULL;
-
-#define NUM_IDLE_CORES ((in32((uintptr_t)core1Idle) << 1) + \
- (in32((uintptr_t)core0Idle)))
-#define PENDING_MBOX_MSG in32((uintptr_t)a9_m3_mbox + MBOX_MESSAGE_STATUS)
-
-extern Bool rpmsg_resmgr_allow_hib (UInt16 proc_id);
-#endif
-
-#ifdef QNX_PM_ENABLE
-static struct powauth *syslink_auth_active = NULL;
-static struct powauth *syslink_auth_oswr = NULL;
-
-enum {core_active, core_inactive, core_off};
-static int ipu_pm_powman_init(void);
-static void tell_powman_auth_oswr(int need);
-static BOOL oswr_prevent = FALSE;
-
-#endif
-
-typedef struct GPTIMER_REGS {
- uint32_t tidr;
- uint32_t space[3];
- uint32_t tiocp_cfg;
- uint32_t space1[3];
- uint32_t reserved;
- uint32_t irqstatus_raw;
- uint32_t irqstatus;
- uint32_t irqenable_set;
- uint32_t irqenable_clr;
- uint32_t irqwakeen;
- uint32_t tclr;
- uint32_t tcrr;
- uint32_t tldr;
- uint32_t ttgr;
- uint32_t twps;
- uint32_t tmar;
- uint32_t tcar1;
- uint32_t tsicr;
- uint32_t tcar2;
-} GPTIMER_REGS;
-
-#define OMAP44XX_IRQ_GPT9 77
-#define OMAP44XX_IRQ_GPT11 79
-
-#define GPTIMER3_BASE 0x48034000
-#define GPTIMER4_BASE 0x48036000
-#define GPTIMER9_BASE 0x4803E000
-#define GPTIMER11_BASE 0x48088000
-
-static void *GPT3Base = 0;
-static void *GPT3ClkCtrl =0;
-static bool GPT3Saved = FALSE;
-static bool GPT3InUse = FALSE;
-static void *GPT4Base = 0;
-static void *GPT4ClkCtrl =0;
-static bool GPT4Saved = FALSE;
-static bool GPT4InUse = FALSE;
-static void *GPT9Base = 0;
-static void *GPT9ClkCtrl =0;
-static bool GPT9Saved = FALSE;
-static bool GPT9InUse = FALSE;
-static void *GPT11Base = 0;
-static void *GPT11ClkCtrl =0;
-static bool GPT11Saved = FALSE;
-static bool GPT11InUse = FALSE;
-
-static GPTIMER_REGS GPT3Reg_saved;
-static GPTIMER_REGS GPT4Reg_saved;
-static GPTIMER_REGS GPT9Reg_saved;
-static GPTIMER_REGS GPT11Reg_saved;
-
-static void *prm_base_va = NULL;
-static void *cm2_base_va = NULL;
-
-#define MAX_DUCATI_CHANNELS 4
-#define DUCATI_CHANNEL_START 25
-#define DUCATI_CHANNEL_END 28
-static bool DMAAllocation = false;
-static rsrc_request_t sdma_req;
-
-// Note, the number of camera modes is tied to enum campower_mode_t, which can
-// be found in camera/camdrv.h
-#define NUM_CAM_MODES 3
-static unsigned last_camera_req[NUM_CAM_MODES];
-static unsigned last_led_req = 0;
-
-#define PRM_SIZE 0x2000
-#define PRM_BASE 0x4A306000
-#define PRM_CM_SYS_CLKSEL_OFFSET 0x110
-#define PM_IVAHD_PWRSTCTRL_OFFSET 0xF00
-#define PM_IVAHD_PWRST_OFFSET 0xF04
-#define RM_IVAHD_RSTCTRL_OFFSET 0xF10
-#define RM_IVAHD_IVAHD_CONTEXT_OFFSET 0xF24
-
-#define CM2_SIZE 0x2000
-#define CM2_BASE 0x4A008000
-#define CM_L3_2_L3_2_CLKCTRL_OFFSET 0x820
-#define CM_MPU_M3_CLKCTRL_OFFSET 0x900
-#define CM_IVAHD_CLKSTCTRL_OFFSET 0xF00
-#define CM_IVAHD_IVAHD_CLKCTRL_OFFSET 0xF20
-#define CM_IVAHD_SL2_CLKCTRL_OFFSET 0xF28
-#define CM_L4PER_GPTIMER3_CLKCTRL_OFFSET 0x1440
-#define CM_L4PER_GPTIMER4_CLKCTRL_OFFSET 0x1448
-#define CM_L4PER_GPTIMER9_CLKCTRL_OFFSET 0x1450
-#define CM_L4PER_GPTIMER11_CLKCTRL_OFFSET 0x1430
-
-#define ID_CODE_BASE 0x4A002000
-#define ID_CODE_OFFSET 0x204
-
-#define OMAP4430_ES1_2 0xB852
-#define OMAP4430_ES21_22 0xB95C
-#define OMAP4460_ES1_11 0xB94E
-#define OMAP4470_ES1 0xB975
-#define COREOPP100 1000000
-
-static dvfsMsg_t dvfsMessage;
-static int cpudll_coid = -1;
-static reply_getListOfDomainOPPs_t cpudll_iva_opp = { {0} }; /* for result of getDomainOPP (IVA)*/
-static reply_getListOfDomainOPPs_t cpudll_core_opp = { {0} }; /* for result of getDomainOPP (CORE)*/
-
-enum processor_version get_omap_version (void)
-{
- uintptr_t id_code_base = NULL;
- enum processor_version omap_rev;
- uint32_t reg;
-
- id_code_base = mmap_device_io(0x1000, ID_CODE_BASE);
- if (id_code_base == MAP_DEVICE_FAILED){
- GT_setFailureReason (curTrace, GT_4CLASS, "get_omap_version",
- ERROR_CONTROL_ID,
- "Unable to map ID_CODE register");
- return ERROR_CONTROL_ID;
- }
-
- reg = in32(id_code_base + ID_CODE_OFFSET);
- reg &= 0x0FFFF000;
- reg = reg >> 12;
-
- switch (reg) {
- case OMAP4430_ES1_2:
- case OMAP4430_ES21_22:
- omap_rev = OMAP_4430;
- break;
-
- case OMAP4460_ES1_11:
- omap_rev = OMAP_4460;
- break;
-
- case OMAP4470_ES1:
- omap_rev = OMAP_4470;
- break;
-
- default:
- omap_rev = INVALID_SI_VERSION;
- break;
- }
-
- if (id_code_base)
- munmap_device_io(id_code_base, 0x1000);
-
- return omap_rev;
-}
-
-/* Function to Map the required registers for
-* GPT configuration
-*/
-int map_gpt_regs(void)
-{
- int retval = 0;
-
- GPT3ClkCtrl = cm2_base_va + CM_L4PER_GPTIMER3_CLKCTRL_OFFSET;
-
- GPT3Base = (void *)mmap_device_io(0x1000, GPTIMER3_BASE);
- if ((uintptr_t)GPT3Base == MAP_DEVICE_FAILED) {
- retval = -ENOMEM;
- GPT3Base = NULL;
- goto exit;
- }
-
- GPT4ClkCtrl = cm2_base_va + CM_L4PER_GPTIMER4_CLKCTRL_OFFSET;
-
- GPT4Base = (void *)mmap_device_io(0x1000, GPTIMER4_BASE);
- if ((uintptr_t)GPT4Base == MAP_DEVICE_FAILED) {
- retval = -ENOMEM;
- GPT4Base = NULL;
- goto exit;
- }
-
- GPT9ClkCtrl = cm2_base_va + CM_L4PER_GPTIMER9_CLKCTRL_OFFSET;
-
- GPT9Base = (void *)mmap_device_io(0x1000, GPTIMER9_BASE);
- if ((uintptr_t)GPT9Base == MAP_DEVICE_FAILED) {
- retval = -ENOMEM;
- GPT9Base = NULL;
- goto exit;
- }
-
- GPT11ClkCtrl = cm2_base_va + CM_L4PER_GPTIMER11_CLKCTRL_OFFSET;
-
- GPT11Base = (void *)mmap_device_io(0x1000, GPTIMER11_BASE);
- if ((uintptr_t)GPT11Base == MAP_DEVICE_FAILED) {
- retval = -ENOMEM;
- GPT11Base = NULL;
- goto exit;
- }
- return EOK;
-
-exit:
- GPT11ClkCtrl = NULL;
- if (GPT9Base) {
- munmap(GPT9Base, 0x1000);
- GPT9Base = NULL;
- }
- GPT9ClkCtrl = NULL;
- if (GPT4Base) {
- munmap(GPT4Base, 0x1000);
- GPT4Base = NULL;
- }
- GPT4ClkCtrl = NULL;
- if (GPT3Base) {
- munmap(GPT3Base, 0x1000);
- GPT3Base = NULL;
- }
- GPT3ClkCtrl = NULL;
- return retval;
-}
-
-void unmap_gpt_regs(void)
-{
- if(GPT11Base != NULL)
- munmap(GPT11Base, 0x1000);
-
- GPT11Base = NULL;
-
- GPT11ClkCtrl = NULL;
-
- if(GPT9Base != NULL)
- munmap(GPT9Base, 0x1000);
-
- GPT9Base = NULL;
-
- GPT9ClkCtrl = NULL;
-
- if(GPT4Base != NULL)
- munmap(GPT4Base, 0x1000);
-
- GPT4Base = NULL;
-
- GPT4ClkCtrl = NULL;
-
- if(GPT3Base != NULL)
- munmap(GPT3Base, 0x1000);
-
- GPT3Base = NULL;
-
- GPT3ClkCtrl = NULL;
-}
-
-#ifdef DUCATI_WATCHDOG_TIMER
-
-/* Interrupt clear function*/
-static Bool ipu_pm_clr_gptimer_interrupt(Ptr fxnArgs)
-{
- UINT32 reg;
- uint32_t num = (uint32_t)fxnArgs;
- GPTIMER_REGS *GPTRegs = NULL;
-
- if (num == GPTIMER_3) {
- GPTRegs = GPT3Base;
- }
- else if (num == GPTIMER_4) {
- GPTRegs = GPT4Base;
- }
- else if (num == GPTIMER_9) {
- GPTRegs = GPT9Base;
- }
- else if (num == GPTIMER_11) {
- GPTRegs = GPT11Base;
- }
- else {
- return TRUE;
- }
-
- reg = in32((uintptr_t)&GPTRegs->irqstatus);
- reg |= 0x2;
-
- /*Clear Overflow event */
- out32((uintptr_t)&GPTRegs->irqstatus, reg);
- reg = in32((uintptr_t)&GPTRegs->irqstatus);
-
- /*Always return TRUE for ISR*/
- return TRUE;
-}
-
-/* ISR for GP Timer*/
-static Bool ipu_pm_gptimer_interrupt(Ptr fxnArgs)
-{
- int num;
- uint16_t core0_id = MultiProc_getId("CORE0");
- uint16_t core1_id = MultiProc_getId("CORE1");
-
- switch ((uint32_t)fxnArgs) {
- case GPTIMER_9:
- num = 9;
- ProcMgr_setState(ipu_pm_state.proc_handles[core0_id],
- ProcMgr_State_Watchdog);
- break;
- case GPTIMER_11:
- num = 11;
- ProcMgr_setState(ipu_pm_state.proc_handles[core1_id],
- ProcMgr_State_Watchdog);
- break;
- default:
- num = 0;
- break;
- }
- // what to do here?
- GT_1trace(curTrace, GT_4CLASS,
- "ipu_pm_gptimer_interrupt: GPTimer %d expired!", num);
-
- return 0;
-}
-#endif
-
-int ipu_pm_gpt_enable(int num)
-{
- GPTIMER_REGS * GPTRegs = NULL;
- uintptr_t GPTClkCtrl = NULL;
- int max_tries = 100;
-
- if (num == GPTIMER_3) {
- GPTClkCtrl = (uintptr_t)GPT3ClkCtrl;
- GPTRegs = GPT3Base;
- GPT3InUse = TRUE;
- }
- else if (num == GPTIMER_4) {
- GPTClkCtrl = (uintptr_t)GPT4ClkCtrl;
- GPTRegs = GPT4Base;
- GPT4InUse = TRUE;
- }
- else if (num == GPTIMER_9) {
- GPTClkCtrl = (uintptr_t)GPT9ClkCtrl;
- GPTRegs = GPT9Base;
- GPT9InUse = TRUE;
- }
- else if (num == GPTIMER_11) {
- GPTClkCtrl = (uintptr_t)GPT11ClkCtrl;
- GPTRegs = GPT11Base;
- GPT11InUse = TRUE;
- }
- else {
- return -EINVAL;
- }
-
- /* Enable GPT MODULEMODE and set CLKSEL to SYS_CLK*/
- out32(GPTClkCtrl, 0x2);
- do {
- if (!(in32(GPTClkCtrl) & 0x30000))
- break;
- } while (--max_tries);
- if (max_tries == 0) {
- ipu_pm_gpt_disable(num);
- return -EIO;
- }
-
- /* Set Smart-idle wake-up-capable */
- out32((uintptr_t)&GPTRegs->tiocp_cfg, 0xC);
-
- return EOK;
-}
-
-int ipu_pm_gpt_disable(int num)
-{
- uintptr_t GPTClkCtrl = NULL;
- GPTIMER_REGS *GPTRegs = NULL;
- UINT32 reg = 0;
-
- if (num == GPTIMER_3) {
- GPTClkCtrl = (uintptr_t)GPT3ClkCtrl;
- GPTRegs = GPT3Base;
- GPT3InUse = FALSE;
- }
- else if (num == GPTIMER_4) {
- GPTClkCtrl = (uintptr_t)GPT4ClkCtrl;
- GPTRegs = GPT4Base;
- GPT4InUse = FALSE;
- }
- else if (num == GPTIMER_9) {
- GPTClkCtrl = (uintptr_t)GPT9ClkCtrl;
- GPTRegs = GPT9Base;
- GPT9InUse = FALSE;
- }
- else if (num == GPTIMER_11) {
- GPTClkCtrl = (uintptr_t)GPT11ClkCtrl;
- GPTRegs = GPT11Base;
- GPT11InUse = FALSE;
- }
- else {
- return -EINVAL;
- }
-
- /*Check if Clock is Enabled*/
- reg = in32(GPTClkCtrl);
- if ((reg & 0x3) == 0x2) {
- /* Clear any pending interrupt to allow idle */
- reg = in32((uintptr_t)&GPTRegs->irqstatus);
- if (reg) {
- out32((uintptr_t)&GPTRegs->irqstatus, reg);
- }
-
- /*Disable the Timer*/
- reg = in32(GPTClkCtrl);
- reg &= 0xFFFFFFFC;
- out32(GPTClkCtrl, reg);
- }
- else {
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_gpt_disable", -EINVAL,
- "gpt clock is not enabled!");
- return -EINVAL;
- }
- return EOK;
-}
-
-int ipu_pm_gpt_start (int num)
-{
- GPTIMER_REGS * GPTRegs = NULL;
- uint32_t reg = 0;
-
- if (num == GPTIMER_3) {
- GPTRegs = GPT3Base;
- }
- else if (num == GPTIMER_4) {
- GPTRegs = GPT4Base;
- }
- else if (num == GPTIMER_9) {
- GPTRegs = GPT9Base;
- }
- else if (num == GPTIMER_11) {
- GPTRegs = GPT11Base;
- }
- else {
- return -EINVAL;
- }
-
- /*Start the Timer*/
- reg = in32((uintptr_t)&GPTRegs->tclr);
- reg |=0x1;
- out32((uintptr_t)&GPTRegs->tclr, reg);
-
- return EOK;
-}
-
-int ipu_pm_gpt_stop(int num)
-{
- uintptr_t GPTClkCtrl = NULL;
- GPTIMER_REGS * GPTRegs = NULL;
- uint32_t reg = 0;
-
- if (num == GPTIMER_3) {
- GPTClkCtrl = (uintptr_t)GPT3ClkCtrl;
- GPTRegs = GPT3Base;
- }
- else if (num == GPTIMER_4) {
- GPTClkCtrl = (uintptr_t)GPT4ClkCtrl;
- GPTRegs = GPT4Base;
- }
- else if (num == GPTIMER_9) {
- GPTClkCtrl = (uintptr_t)GPT9ClkCtrl;
- GPTRegs = GPT9Base;
- }
- else if (num == GPTIMER_11) {
- GPTClkCtrl = (uintptr_t)GPT11ClkCtrl;
- GPTRegs = GPT11Base;
- }
- else {
- return -EINVAL;
- }
-
- /*Check if Clock is Enabled*/
- reg = in32(GPTClkCtrl);
- if ((reg & 0x3) == 0x2) {
-
- /*Stop the Timer*/
- reg = in32((uintptr_t)&GPTRegs->tclr);
- reg &=0xFFFFFFFE;
- out32((uintptr_t)&GPTRegs->tclr, reg);
- }
- else {
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_gpt_stop", -EINVAL,
- "gpt clock is not enabled!");
- return -EINVAL;
- };
-
- return EOK;
-}
-
-void save_gpt_context(int num)
-{
- GPTIMER_REGS *GPTRegs = NULL;
- GPTIMER_REGS *GPTSaved = NULL;
- bool *GPTRestore = NULL;
-
- if (num == GPTIMER_3) {
- GPTRegs = GPT3Base;
- GPTSaved = &GPT3Reg_saved;
- GPTRestore = &GPT3Saved;
- }
- else if (num == GPTIMER_4) {
- GPTRegs = GPT4Base;
- GPTSaved = &GPT4Reg_saved;
- GPTRestore = &GPT4Saved;
- }
- else if (num == GPTIMER_9) {
- GPTRegs = GPT9Base;
- GPTSaved = &GPT9Reg_saved;
- GPTRestore = &GPT9Saved;
- }
- else if (num == GPTIMER_11) {
- GPTRegs = GPT11Base;
- GPTSaved = &GPT11Reg_saved;
- GPTRestore = &GPT11Saved;
- }
- else {
- return;
- }
-
- GPTSaved->tiocp_cfg = in32((uintptr_t)&GPTRegs->tiocp_cfg);
- GPTSaved->tcrr = in32((uintptr_t)&GPTRegs->tcrr);
- GPTSaved->irqenable_set = in32((uintptr_t)&GPTRegs->irqenable_set);
- GPTSaved->irqstatus_raw = in32((uintptr_t)&GPTRegs->irqstatus_raw);
- GPTSaved->irqstatus = in32((uintptr_t)&GPTRegs->irqstatus);
- GPTSaved->irqwakeen = in32((uintptr_t)&GPTRegs->irqwakeen);
- GPTSaved->tclr = in32((uintptr_t)&GPTRegs->tclr);
- GPTSaved->tldr = in32((uintptr_t)&GPTRegs->tldr);
- GPTSaved->ttgr = in32((uintptr_t)&GPTRegs->ttgr);
- GPTSaved->tmar = in32((uintptr_t)&GPTRegs->tmar);
- GPTSaved->tsicr = in32((uintptr_t)&GPTRegs->tsicr);
- *GPTRestore = TRUE;
-}
-
-void restore_gpt_context(int num)
-{
- GPTIMER_REGS *GPTRegs = NULL;
- GPTIMER_REGS *GPTSaved = NULL;
- bool *GPTRestore = NULL;
-
- if (num == GPTIMER_3) {
- GPTRegs = GPT3Base;
- GPTSaved = &GPT3Reg_saved;
- GPTRestore = &GPT3Saved;
- }
- else if (num == GPTIMER_4) {
- GPTRegs = GPT4Base;
- GPTSaved = &GPT4Reg_saved;
- GPTRestore = &GPT4Saved;
- }
- else if (num == GPTIMER_9) {
- GPTRegs = GPT9Base;
- GPTSaved = &GPT9Reg_saved;
- GPTRestore = &GPT9Saved;
- }
- else if (num == GPTIMER_11) {
- GPTRegs = GPT11Base;
- GPTSaved = &GPT11Reg_saved;
- GPTRestore = &GPT11Saved;
- }
- else {
- return;
- }
-
- if (*GPTRestore) {
- *GPTRestore = FALSE;
- out32((uintptr_t)&GPTRegs->tiocp_cfg, GPTSaved->tiocp_cfg);
- out32((uintptr_t)&GPTRegs->irqenable_set, GPTSaved->irqenable_set);
- out32((uintptr_t)&GPTRegs->tcrr, GPTSaved->tcrr);
- out32((uintptr_t)&GPTRegs->irqstatus_raw, GPTSaved->irqstatus_raw);
- out32((uintptr_t)&GPTRegs->irqstatus, GPTSaved->irqstatus);
- out32((uintptr_t)&GPTRegs->irqwakeen, GPTSaved->irqwakeen);
- out32((uintptr_t)&GPTRegs->tclr, GPTSaved->tclr);
- out32((uintptr_t)&GPTRegs->tldr, GPTSaved->tldr);
- out32((uintptr_t)&GPTRegs->ttgr, GPTSaved->ttgr);
- out32((uintptr_t)&GPTRegs->tmar, GPTSaved->tmar);
- out32((uintptr_t)&GPTRegs->tsicr, GPTSaved->tsicr);
- }
-}
-
-int ipu_pm_ivahd_standby_power_on_uboot()
-{
- unsigned int length =0;
- volatile unsigned int *icont1_itcm_base_addr = NULL;
- volatile unsigned int *icont2_itcm_base_addr = NULL;
- /*--------------------------------------------------------------------------*/
- /* Assigment of pointers */
- /* A generic code shall take all address as input parameters */
- /*--------------------------------------------------------------------------*/
- icont1_itcm_base_addr = (unsigned int *)mmap_device_io(0x1000, (L3_IVAHD_CONFIG+0x08000));
- GT_1trace(curTrace, GT_4CLASS, "###icont1_itcm_base_addr= %u", icont1_itcm_base_addr);
- icont2_itcm_base_addr = (unsigned int *)mmap_device_io(0x1000, (L3_IVAHD_CONFIG+0x18000));
- GT_1trace(curTrace, GT_4CLASS, "###icont1_itcm_base_addr= %u", icont2_itcm_base_addr);
- if((uintptr_t)icont1_itcm_base_addr == MAP_DEVICE_FAILED ||
- (uintptr_t)icont2_itcm_base_addr == MAP_DEVICE_FAILED){
- GT_0trace(curTrace, GT_4CLASS, "mapping l3 ivahdconfig failed");
- if((uintptr_t)icont1_itcm_base_addr != MAP_DEVICE_FAILED )
- munmap((void *)icont1_itcm_base_addr, 0x1000);
- if((uintptr_t)icont2_itcm_base_addr != MAP_DEVICE_FAILED )
- munmap((void *)icont2_itcm_base_addr, 0x1000);
- return -1;
- }
-
- /*--------------------------------------------------------------------------*/
- /* Copy boot code to ICONT1 & INCOT2 memory */
- /*--------------------------------------------------------------------------*/
- GT_0trace(curTrace, GT_4CLASS, "###LOAD BOOT CODE");
-
- for (length=0; length<LENGTH_BOOT_CODE1; length++) {
- icont1_itcm_base_addr[length] = IVAHD_memory_wfi1[length];
- icont2_itcm_base_addr[length] = IVAHD_memory_wfi1[length];
- }
-
- /*--------------------------------------------------------------------------*/
- /* As ICONT goes in WFI and there are no pending VDMA transction */
- /* entire IVAHD will be go in standby mode and PRCM will fully control */
- /* further managment of IVAHD power state */
- /*--------------------------------------------------------------------------*/
- munmap((void *)icont1_itcm_base_addr, 0x1000);
- munmap((void *)icont2_itcm_base_addr, 0x1000);
-
- return 0;
-}
-
-int ipu_pm_ivaseq0_disable()
-{
- return EOK;
-}
-
-int ipu_pm_ivaseq0_enable()
-{
- return EOK;
-}
-
-int ipu_pm_ivaseq1_disable()
-{
- return EOK;
-}
-
-int ipu_pm_ivaseq1_enable()
-{
- return EOK;
-}
-
-int ipu_pm_ivahd_disable()
-{
- uintptr_t pm_base = 0;
- uintptr_t cm_base = 0;
- uint32_t reg = 0;
- int max_tries = 100;
-
- pthread_mutex_lock(&ipu_pm_state.mtx);
-
- if (ipu_pm_state.ivahd_use_cnt-- == 1) {
- pm_base = (uintptr_t)prm_base_va;
- cm_base = (uintptr_t)cm2_base_va;
-
- reg = in32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET);
- reg &= 0xFFFFFFFC;
- reg |= 0x00000002;
- out32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET, reg);
-
- /* Ensure that the wake up mode is set to SW_WAKEUP */
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, 0x00000002);
-
- /* Check the standby status */
- do {
- if (((in32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET) & 0x00040000) != 0x0))
- break;
- } while (--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** Error in IVAHD standby status");
- }
-
- // IVAHD_CM2:CM_IVAHD_IVAHD_CLKCTRL
- out32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET, 0x00000000);
- max_tries = 100;
- do {
- if((in32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET) & 0x00030000) == 0x30000)
- break;
- } while (--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** Error in IVAHD standby status");
- }
-
- // IVAHD_CM2:CM_IVAHD_SL2_CLKCTRL
- out32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET, 0x00000000);
- max_tries = 100;
- do {
- if((in32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET) & 0x00030000) == 0x30000);
- break;
- } while (--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** Error in SL2 CLKCTRL");
- }
-
- /* put IVA into HW Auto mode */
- reg = in32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET);
- reg |= 0x00000003;
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, reg);
-
- max_tries = 100;
- /* Check CLK ACTIVITY bit */
- while(((in32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET) & 0x00000100) != 0x0) && --max_tries);
- if (max_tries == 0)
- GT_0trace(curTrace, GT_4CLASS, "SYSLINK: ivahd_disable: WARNING - CLK ACTIVITY bit did not go off");
-
- /* Modifying the previous reset sequence - the new reset sequence asserts reset on
- * SL2/IVAHD first, wait for 1 usec and then assert reset for ICONT1 and
- * then for ICONT2 */
- reg = in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET);
- reg |= 0x4;
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, reg);
- usleep(1);
- reg = in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET);
- reg |= 0x1;
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, reg);
- usleep(1);
- reg = in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET);
- reg |= 0x2;
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, reg);
- }
- else {
- GT_0trace(curTrace, GT_3CLASS, "ivahd still in use");
- }
-
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- return EOK;
-}
-
-int ipu_pm_ivahd_enable()
-{
- uintptr_t pm_base = 0;
- uintptr_t cm_base = 0;
- uint32_t reg = 0;
- unsigned int pwrst = 0;
- int max_tries = 0;
- int flag = 0;
-
- pthread_mutex_lock(&ipu_pm_state.mtx);
-
- if (++ipu_pm_state.ivahd_use_cnt == 1) {
- pm_base = (uintptr_t)prm_base_va;
- cm_base = (uintptr_t)cm2_base_va;
-
- /* Read the IVAHD Context register to check if the memory content has been lost */
- reg = in32(pm_base + RM_IVAHD_IVAHD_CONTEXT_OFFSET);
- /* Clear the context register by writing 1 to bit 8,9 and 10 */
- out32(pm_base + RM_IVAHD_IVAHD_CONTEXT_OFFSET, 0x700);
-
- /*Display power state*/
- pwrst = in32(pm_base + PM_IVAHD_PWRST_OFFSET);
- GT_1trace(curTrace, GT_4CLASS, "###: off state reg bit = 0x%x\n", (pwrst & 0x03000003));
- /*Clear the pwer status reg by writting 1'a into the requred bits*/
- out32(pm_base + PM_IVAHD_PWRST_OFFSET, 0x03000000);
-
- /* Ensure power state is set to ON */
- reg = in32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET);
- reg &= 0xFFFFFFFC;
- reg |= 0x00000003;
- out32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET, reg);
-
- // IVAHD_CM2:CM_IVAHD_IVAHD_CLKCTRL
- out32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET, 0x00000001);
-
- // IVAHD_CM2:CM_IVAHD_SL2_CLKCTRL
- out32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET, 0x00000001);
-
- /* Ensure that the wake up mode is set to SW_WAKEUP */
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, 0x00000002);
- if((pwrst & 0x03000000) == 0x00000000){
- /* Wait until the CLK_ACTIVITY bit is set */
- max_tries = 3;
- while(max_tries--){
- if(((in32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET)) & 0x00000100) != 0x0){
- flag = 1;
- break;
- }
- usleep(100);
- }
- }
-
- /* Release ICONT1 and SL2/IVAHD first, wait for few usec then release ICONT2 */
- reg = in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET);
- reg &= 0xFFFFFFFB;
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, reg);
- if(flag){
- GT_0trace(curTrace, GT_4CLASS, "@@@ - CLK_ACTIVITY set");
- GT_0trace(curTrace, GT_4CLASS, "$$ call LOAD CODE");
- if(-1 == ipu_pm_ivahd_standby_power_on_uboot())
- GT_0trace(curTrace, GT_4CLASS, "$$ LOAD CODE FAILED");
- }
- else
- GT_0trace(curTrace, GT_4CLASS, "@@@ - CLK_ACTIVITY Not set");
-
- reg = in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET);
- reg &= 0xFFFFFFFE;
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, reg);
- usleep(200);
- reg = in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET);
- reg &= 0xFFFFFFFD;
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, reg);
- max_tries = 100;
- do {
- if((in32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET) & 0x00030000) == 0x0)
- break;
- } while(--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** Error in IVAHD clk control");
- return -EIO;
- }
-
- max_tries = 100;
- do {
- if((in32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET) & 0x00030000) == 0x00000)
- break;
- } while(--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** Error in SL2 clk control");
- return -EIO;
- }
-
- max_tries = 100;
- do {
- if((in32(cm_base + CM_L3_2_L3_2_CLKCTRL_OFFSET) & 0x30001) == 0x00001)
- break;
- } while(--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** Error in L3 clk control");
- return -EIO;
- }
-
- /* Ensure IVAHD and SL2 is functional */
- max_tries = 100;
- do {
- if((in32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET) & 0x00030001) == 0x00001)
- break;
- } while(--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** IVAHD is not functional");
- return -EIO;
- }
-
- max_tries = 100;
- do {
- if((in32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET) & 0x00030001) == 0x00001)
- break;
- } while(--max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS," ** SL2 is not functional");
- return -EIO;
- }
- } else {
- GT_0trace(curTrace, GT_3CLASS, "ivahd already acquired");
- }
-
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- return EOK;
-}
-
-int ipu_pm_ivahd_off()
-{
- uintptr_t pm_base = 0;
- uintptr_t cm_base = 0;
- uint32_t reg = 0;
- int32_t max_tries = 0;
- bool ivahd_enabled = false;
- bool sl2_enabled = false;
- enum processor_version omap_rev;
-
- pm_base = (uintptr_t)prm_base_va;
- cm_base = (uintptr_t)cm2_base_va;
-
- omap_rev = get_omap_version();
- if (omap_rev < 0) {
- GT_setFailureReason (curTrace, GT_4CLASS, "ipu_pm_ivahd_off",
- omap_rev, "Error while reading the OMAP REVISION");
- return EIO;
- }
- else if (omap_rev != OMAP_4430) {
- reg = in32(pm_base + PM_IVAHD_PWRST_OFFSET);
- reg = reg & 0x00000007;
-
- if (reg != 0x00000000) {
- /* set IVAHD to SW_WKUP */
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, 0x2);
- max_tries = 100;
- /* Check for ivahd module and disable if it is enabled */
- if ((in32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET) & 0x1) != 0) {
- out32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET, 0x0);
- ivahd_enabled = 1;
- }
- /* Check for sl2 module and disable if it is enabled */
- if ((in32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET) & 0x1) != 0) {
- out32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET, 0x0);
- sl2_enabled = 1;
- }
- if (ivahd_enabled || sl2_enabled) {
- while (((in32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET) & 0x00000100) == 0x0) && --max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS,"IPU_PM:IVAHD DOMAIN is Not Enabled after retries");
- }
- }
-
- /* Set IVAHD PD to OFF */
- reg = in32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET);
- reg = (reg & 0xFFFFFFFC) | 0x0;
- out32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET, reg);
- max_tries = 100;
- while (((in32(pm_base + PM_IVAHD_PWRST_OFFSET) & 0x00100000) != 0) && --max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS,"IPU_PM: IVAHD Power Domain is in transition after retries");
- }
-
- if (ivahd_enabled) {
- max_tries = 100;
- while (((in32(cm_base + CM_IVAHD_IVAHD_CLKCTRL_OFFSET) & 0x00030000) != 0x30000) && --max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS,"IPU_PM: Stuck up in the IVAHD Module after retries");
- }
- }
- if (sl2_enabled) {
- max_tries = 100;
- while (((in32(cm_base + CM_IVAHD_SL2_CLKCTRL_OFFSET) & 0x00030000) != 0x30000) && --max_tries);
- if (max_tries == 0) {
- GT_0trace(curTrace, GT_4CLASS,"IPU_PM: Stuck up in the SL2 Module after retries");
- }
- }
- /* Set IVAHD to HW_AUTO */
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, 0x3);
- /* Check the reset states and assert resets */
- if (in32(pm_base + RM_IVAHD_RSTCTRL_OFFSET) != 0x7) {
- out32(pm_base + RM_IVAHD_RSTCTRL_OFFSET, 0x7);
- }
- }
- }
-
- return EOK;
-}
-
-int ipu_pm_ivahd_on()
-{
- uintptr_t pm_base = 0;
- uintptr_t cm_base = 0;
- uint32_t reg = 0;
-
- pm_base = (uintptr_t)prm_base_va;
- cm_base = (uintptr_t)cm2_base_va;
-
- /* Set the power state to ON */
- reg = in32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET);
- reg &= 0xFFFFFFFC;
- reg |= 0x00000002;
- out32(pm_base + PM_IVAHD_PWRSTCTRL_OFFSET, reg);
-
- /* Ensure that the wake up mode is set to SW_WAKEUP */
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, 0x00000002);
-
- /* put IVA into HW Auto mode */
- reg = in32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET);
- reg |= 0x00000003;
- out32(cm_base + CM_IVAHD_CLKSTCTRL_OFFSET, reg);
-
- return EOK;
-}
-
-int ipu_pm_led_enable(unsigned int mode, unsigned int intensity)
-{
- int ret = 0;
-
- ret = camflash_config(mode, intensity);
-
- if (ret != -1)
- last_led_req = mode;
-
- return ret;
-}
-
-int ipu_pm_alloc_sdma(int num_chs, int* channels)
-{
- GT_0trace(curTrace, GT_3CLASS, "ipu_pm_alloc_sdma++");
-
- if(DMAAllocation == false) {
- GT_0trace(curTrace, GT_4CLASS, "Channel pool empty");
- return -1;
- }
- GT_0trace(curTrace, GT_3CLASS, "ipu_pm_alloc_sdma--");
- return 0;
-}
-
-int ipu_pm_free_sdma(int num_chs, int* channels)
-{
- GT_0trace(curTrace, GT_3CLASS, "ipu_pm_free_sdma++");
-
- if(DMAAllocation == false) {
- GT_0trace(curTrace, GT_4CLASS, "Channel pool empty");
- return -1;
- }
- GT_0trace(curTrace, GT_3CLASS, "ipu_pm_free_sdma--");
- return 0;
-}
-
-int ipu_pm_camera_enable(unsigned int mode, unsigned int on)
-{
- int ret = 0;
-
- ret = campower_config(mode, on);
-
- if (mode < NUM_CAM_MODES && ret == 0)
- last_camera_req[mode] = on;
-
- return ret;
-}
-
-int ipu_pm_get_max_freq(unsigned int proc, unsigned int * freq)
-{
- int status = EOK;
-
- switch (proc) {
-#if 0 // TODO: need a way to return the max freq
- case RPRM_IPU:
- *freq = IPU_FREQ_MAX;
- break;
- case RPRM_DSP:
- *freq = DSP_FREQ_MAX;
- break;
-#endif
- default:
- status = -ENOENT;
- break;
- }
-
- return status;
-}
-
-#ifdef QNX_PM_ENABLE
-static int ipu_pm_power_init(void)
-{
- /*Allocate SDMA channels*/
- memset(&sdma_req, 0, sizeof(sdma_req));
- sdma_req.length = MAX_DUCATI_CHANNELS;
- sdma_req.flags = RSRCDBMGR_DMA_CHANNEL | RSRCDBMGR_FLAG_RANGE;
- sdma_req.start = DUCATI_CHANNEL_START;
- sdma_req.end = DUCATI_CHANNEL_END;
- if (rsrcdbmgr_attach(&sdma_req, 1) == -1) {
- DMAAllocation = false;
- GT_1trace(curTrace, GT_4CLASS,
- "ipu_pm_power_init: DMA channel allocation FAILED: %s", strerror(errno));
- }
- else {
- GT_0trace(curTrace, GT_3CLASS,
- "ipu_pm_power_init: DMA channels ALLOCATED");
- DMAAllocation = true;
- }
-
- return EOK;
-}
-
-static void ipu_pm_power_deinit(void)
-{
- if(DMAAllocation){
- if (rsrcdbmgr_detach(&sdma_req, 1) == -1) {
- GT_1trace(curTrace, GT_4CLASS,
- "ipu_pm_power_deinit: DMA channel deallocation FAILED!!%s",
- strerror(errno));
- }
- DMAAllocation = false;
- }
- return;
-}
-
-static int ipu_pm_powman_init(void)
-{
- int status = EOK;
-
- syslink_auth_active = powman_auth_create("SYSLINK_NEEDS_CORE_ACTIVE");
- if(!syslink_auth_active) {
- GT_setFailureReason(curTrace, GT_4CLASS, "powman_init", ENOMEM,
- "syslink_auth_active create failure");
- return -ENOMEM;
-
- }
-
- syslink_auth_oswr = powman_auth_create("SYSLINK_NEEDS_PREVENT_OSWR");
- if(!syslink_auth_oswr) {
- GT_setFailureReason(curTrace, GT_4CLASS, "powman_init", ENOMEM,
- "syslink_auth_oswr create failure");
- return -ENOMEM;
- }
-
- int retry = 100;
-
- /* look for server */
- cpudll_coid = name_open( CPUDLL_RECV_NAME, 0);
- while (cpudll_coid == -1 && retry-- > 0) {
- sleep(1);
- cpudll_coid = name_open (CPUDLL_RECV_NAME, 0);
- }
-
- if (cpudll_coid == -1) {
- GT_setFailureReason (curTrace, GT_4CLASS, "connect to cpudll", EINVAL,
- "Couldn't connect to CPU DLL!");
- return EINVAL;
- }
-
- /* get IVA OPPs */
- dvfsMessage.dvfs.type = getListOfDomainOPPs;
- dvfsMessage.dvfs.domain = CPUDLL_OMAP_IVA;
- if (MsgSend( cpudll_coid, &dvfsMessage, sizeof( dvfsMessage ), &cpudll_iva_opp, sizeof(cpudll_iva_opp) ) == -1) {
- GT_setFailureReason(curTrace, GT_4CLASS, "powman_init", ENOMEM,
- "Could not get list of IVA OPPs.");
- return -ENOMEM;
- }
-
- /* get CORE OPPs */
- dvfsMessage.dvfs.type = getListOfDomainOPPs;
- dvfsMessage.dvfs.domain = CPUDLL_OMAP_CORE;
- if (MsgSend( cpudll_coid, &dvfsMessage, sizeof( dvfsMessage ), &cpudll_core_opp, sizeof(cpudll_core_opp) ) == -1) {
- GT_setFailureReason(curTrace, GT_4CLASS, "powman_init", ENOMEM,
- "Could not get list of Core OPPs.");
- return -ENOMEM;
- }
- return status;
-}
-
-static void ipu_pm_powman_deinit(void)
-{
- int status = EOK;
-
- if (syslink_auth_active) {
- status = powman_auth_destroy(syslink_auth_active);
- if (status < 0) {
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_powman_deinit",
- status,
- "powman_auth_destroy syslink_auth_active failure");
- }
- syslink_auth_active = NULL;
- }
- if (syslink_auth_oswr) {
- status = powman_auth_destroy(syslink_auth_oswr);
- if (status < 0) {
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_powman_deinit",
- status,
- "powman_auth_destroy syslink_auth_oswr failure");
- }
- syslink_auth_oswr = NULL;
- }
-
- // close the channel
- dvfsMessage.dvfs.type = (cpudll_type_e)closeClient;
- if (MsgSend( cpudll_coid, &dvfsMessage, sizeof( dvfsMessage ), NULL, 0 ) == -1) {
- GT_setFailureReason(curTrace, GT_4CLASS, "powman_deinit", ENOMEM,
- "Could not close client connection to server.");
- }
-
- name_close(cpudll_coid);
- cpudll_coid = -1;
-}
-
-//no special callback needed in our case so define the default.
-int powman_delayed_callback(unsigned ns, void (*func) (void *), void *data)
-{
- return (powman_delayed_callback_default(ns, func, data));
-}
-
-static void tell_powman_auth_oswr(int need)
-{
- int r;
- r = powman_auth_state(syslink_auth_oswr, need);
- if(r != 0) {
- GT_setFailureReason(curTrace, GT_4CLASS, "tell_powman_auth_oswr", r,
- "powerman authority :cannot set state");
- }
-}
-
-int ipu_pm_set_bandwidth(unsigned int bandwidth)
-{
- int err;
- int oppIndex = CPUDLL_MAX_OPP_STATES-1;
-
- /* Camera needs OPPOV (highest OPP) which will be moving from index 1 to 2.
- * Find the greatest non-zero element to find the highest OPP and select it.
- */
- while ( (cpudll_core_opp.states[oppIndex] == 0) && (oppIndex > 0) ){
- oppIndex--;
- }
-
- dvfsMessage.dvfs.type = setDomainOPP;
- dvfsMessage.dvfs.domain = CPUDLL_OMAP_CORE;
-
- dvfsMessage.dvfs.req_opp = cpudll_core_opp.states[ bandwidth>=COREOPP100?oppIndex:0 ];
- err = MsgSend( cpudll_coid, &dvfsMessage, sizeof( dvfsMessage ), NULL, 0 );
- if(err != EOK) {
- GT_1trace(curTrace, GT_4CLASS," ** Error setting CORE OPP: %s", strerror(errno));
- }
- return EOK;
-}
-
-int ipu_pm_set_rate(struct ipu_pm_const_req * request)
-{
- int err = EOK;
- cpudll_iva_opp_t req = 0;
-
- if (request->target_rsrc == RPRM_IVAHD) {
- if (request->rate > FREQ_266Mhz)
- req = CPUDLL_IVA_OPPTURBO;
- else if ((request->rate > FREQ_133Mhz) &&
- (request->rate <= FREQ_266Mhz))
- req = CPUDLL_IVA_OPP100;
- else if ((request->rate > NO_FREQ_CONSTRAINT) &&
- (request->rate <= FREQ_133Mhz))
- req = CPUDLL_IVA_OPP50;
- else if (request->rate == NO_FREQ_CONSTRAINT)
- req = CPUDLL_IVA_OPPNONE;
-
- dvfsMessage.dvfs.req_opp = cpudll_iva_opp.states[req];
- dvfsMessage.dvfs.type = setDomainOPP;
- dvfsMessage.dvfs.domain = CPUDLL_OMAP_IVA;
-
- err = MsgSend( cpudll_coid, &dvfsMessage, sizeof( dvfsMessage ), NULL, 0 );
- if(err != EOK) {
- GT_2trace(curTrace, GT_4CLASS," ** Error setting IVA OPP %d: %s", req, strerror(err));
- }
- }
- return err;
-}
-#else
-int ipu_pm_set_rate(struct ipu_pm_const_req * request)
-{
- return EOK;
-}
-#endif
-
-#ifdef DUCATI_SELF_HIBERNATION
-
-static int configure_timer (int val, int reload)
-{
- int status = 0;
- struct itimerspec timeout;
- timeout.it_value.tv_sec = val;
- timeout.it_value.tv_nsec = 0;
- timeout.it_interval.tv_sec = reload;
- timeout.it_interval.tv_nsec = 0;
- status = timer_settime(ipu_pm_state.hibernation_timer, 0, &timeout, NULL);
- if (status != 0) {
- status = -errno;
- }
- return status;
-}
-
-/* Function implements hibernation and watch dog timer
- * The functionality is based on following states
- * RESET: Timer is disabed
- * OFF: Timer is OFF
- * ON: Timer running
- * HIBERNATE: Waking up for ducati cores to hibernate
- * WD_RESET: Waiting for Ducati cores to complete hibernation
- */
-int ipu_pm_timer_state(int event)
-{
- int retval = 0;
-
- if (!ipu_pm_state.attached)
- goto exit;
-
- switch (event) {
- case PM_HIB_TIMER_RESET:
- /* disable timer and remove irq handler */
- //Stop the timer
- configure_timer(0, 0);
- ipu_pm_state.hib_timer_state = PM_HIB_TIMER_RESET;
- break;
-
- case PM_HIB_TIMER_DELETE:
- if (ipu_pm_state.hib_timer_state == PM_HIB_TIMER_OFF) {
- /*Stop the Timer*/
- configure_timer(0, 0);
- /* Delete the timer */
- retval = timer_delete(ipu_pm_state.hibernation_timer);
- }
- break;
-
- case PM_HIB_TIMER_OFF:
- if (ipu_pm_state.hib_timer_state == PM_HIB_TIMER_ON) {
- /*Stop the Timer*/
- configure_timer(0, 0);
- ipu_pm_state.hib_timer_state = PM_HIB_TIMER_OFF;
- }
- break;
-
- case PM_HIB_TIMER_ON:
- if (ipu_pm_state.hib_timer_state == PM_HIB_TIMER_RESET||
- ipu_pm_state.hib_timer_state == PM_HIB_TIMER_OFF||
- ipu_pm_state.hib_timer_state == PM_HIB_TIMER_DELETE||
- ipu_pm_state.hib_timer_state == PM_HIB_TIMER_ON) {
-
- /*Enable the timer*/
- /*Start the Timer*/
- configure_timer(syslink_hib_timeout / 1000, 0);
- ipu_pm_state.hib_timer_state = PM_HIB_TIMER_ON;
- }
- break;
- }
-
-exit:
- if (retval < 0) {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "ipu_pm_timer_state",
- retval,
- "ipu_pm_timer_state failed");
- }
-
- return retval;
-}
-
-/*
- Function to save the MMU, Mailbox context before going to hibernation
- *
- */
-int ipu_pm_save_ctx(int proc_id)
-{
- int retval = 0;
- int flag;
- int num_loaded_cores = 0;
- int core0_loaded;
- int core1_loaded;
- unsigned long timeout;
- unsigned short core0_id = MultiProc_getId("CORE0");
- unsigned short core1_id = MultiProc_getId("CORE1");
- unsigned short dsp_id = MultiProc_getId("DSP");
- struct itimerspec value;
- uint64_t pa = 0, da = 0;
- u32 len = 0;
-
- /* get M3's load flag */
- core0_loaded = (ipu_pm_state.loaded_procs & CORE0_LOADED);
- core1_loaded = (ipu_pm_state.loaded_procs & CORE1_LOADED);
-
- /* Because of the current scheme, we need to check
- * if CORE1 is enabled and we need to shut it down too
- * CORE0 is the only one sending the hibernate message
- */
- pthread_mutex_lock(&ipu_pm_state.mtx);
-
- if (core0Idle == NULL) {
- if (proc_id == core0_id) {
- retval = get_resource_info(RSC_SUSPENDADDR, "0", &da, &pa, &len);
- if (retval == 0) {
- /* BIOS flags to know the state of IPU cores */
- core0Idle = (void *)mmap_device_io(0x1000, ROUND_DOWN(pa, 0x1000));
- if ((uintptr_t)core0Idle == MAP_DEVICE_FAILED) {
- core0Idle = NULL;
- retval = -ENOMEM;
- goto exit;
- }
-
- core0Idle = (void *)((uint32_t)core0Idle + ((uint32_t)pa - ROUND_DOWN((uint32_t)pa, 0x1000)));
- core1Idle = (void *)core0Idle + sizeof(void *);
- }
- else {
- goto exit;
- }
- }
- }
-
- if (proc_id == core0_id || proc_id == core1_id) {
- timer_gettime(ipu_pm_state.hibernation_timer, &value);
- if (value.it_value.tv_sec || value.it_value.tv_nsec)
- goto exit;
-
- if (!core0_loaded)
- goto exit;
-
- /* If already down don't kill it twice */
- if (ipu_pm_state.proc_state & CORE0_PROC_DOWN) {
- GT_0trace(curTrace, GT_4CLASS, "ipu already hibernated");
- goto exit;
- }
-
- if (rpmsg_resmgr_allow_hib(core0_id) &&
- rpmsg_resmgr_allow_hib(core1_id) &&
- !TESTBITREG32((uintptr_t)m3_clkstctrl,
- CM_MPU_M3_CLKSTCTRL_CLKACTIVITY_BIT)) {
- retval = ArchIpcInt_sendInterrupt(core0_id,
- ipu_pm_state.cfg.int_id,
- RP_MBOX_HIBERNATION);
- }
- else {
- /* restart timer */
- configure_timer(syslink_hib_timeout / 1000, 0);
- goto exit;
- }
-
- num_loaded_cores = core1_loaded + core0_loaded;
- flag = 1;
- timeout = WAIT_FOR_IDLE_TIMEOUT;
- /* Wait fot Ducati to hibernate */
- do {
- /* Checking if IPU is really in idle */
- if (NUM_IDLE_CORES == num_loaded_cores) {
- flag = 0;
- break;
- } else {
- usleep(1000);
- }
- } while ( --timeout != 0);
-
- if (flag) {
- GT_0trace(curTrace, GT_4CLASS, "Ducati Cores are NOT really Idle");
- goto error;
- }
-
- ipu_pm_timer_state(PM_HIB_TIMER_OFF);
- retval = Omap4430IpcInt_mboxSaveCtxt(core0_id);
- if(retval != OMAP4430IPCINT_SUCCESS){
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_save_ctx",
- retval,
- "Error while saving the MailBox context");
- goto error;
- }
-
- if (core1_loaded) {
-#ifdef DUCATI_WATCHDOG_TIMER
- save_gpt_context(GPTIMER_11);
- ipu_pm_gpt_stop(GPTIMER_11);
- ipu_pm_gpt_disable(GPTIMER_11);
-#endif
- if (GPT4InUse == TRUE)
- save_gpt_context(GPTIMER_4);
-
- retval = ProcMgr_control(ipu_pm_state.proc_handles[core1_id],
- Omap4430DucatiProc_CtrlCmd_Suspend, NULL);
- if (retval < 0) {
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_save_ctx",
- retval, "Error while suspending CORE1");
- goto error;
- }
- GT_0trace(curTrace, GT_4CLASS, "Sleep CORE1");
- }
-
-#ifdef DUCATI_WATCHDOG_TIMER
- save_gpt_context(GPTIMER_9);
- ipu_pm_gpt_stop(GPTIMER_9);
- ipu_pm_gpt_disable(GPTIMER_9);
-#endif
- if (GPT3InUse == TRUE)
- save_gpt_context(GPTIMER_3);
-
- ipu_pm_state.proc_state |= CORE1_PROC_DOWN;
- retval = ProcMgr_control(ipu_pm_state.proc_handles[core0_id],
- Omap4430DucatiProc_CtrlCmd_Suspend, NULL);
- if (retval < 0) {
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_save_ctx", retval,
- "Error while suspending CORE0");
- goto error;
- }
- GT_0trace(curTrace, GT_4CLASS, "Sleep CORE0");
- ipu_pm_state.proc_state |= CORE0_PROC_DOWN;
-
- ipu_pm_ivahd_off();
-
- // Advise that Ducati is hibernating
- pthread_mutex_lock(&syslink_hib_mutex);
- syslink_hib_hibernating = TRUE;
- pthread_mutex_unlock(&syslink_hib_mutex);
- }
- else if (proc_id == dsp_id) {
- //TODO: Add support for DSP.
- }
- else
- goto error;
-
-#ifdef QNX_PM_ENABLE
- if (oswr_prevent == 1) {
- tell_powman_auth_oswr(0); // Passing 1 prevents OSWR and 0 allows OSWR
- oswr_prevent = 0;
- }
-#endif
- /* If there is a message in the mbox restore
- * immediately after save.
- */
- if (PENDING_MBOX_MSG)
- goto restore;
-
-exit:
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- return 0;
-error:
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_save_ctx", retval,
- "Aborting hibernation process");
- ipu_pm_timer_state(PM_HIB_TIMER_ON);
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- return retval;
-restore:
- GT_0trace(curTrace, GT_4CLASS,
- "Starting restore_ctx since messages pending in mbox");
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- ipu_pm_restore_ctx(proc_id);
-
- return retval;
-}
-
-
-/* Function to check if a processor is shutdown
- * if shutdown then restore context else return.
- */
-int ipu_pm_restore_ctx(int proc_id)
-{
- int retval = 0;
- int core0_loaded;
- int core1_loaded;
- unsigned short core0_id = MultiProc_getId("CORE0");
- unsigned short core1_id = MultiProc_getId("CORE1");
- unsigned short dsp_id = MultiProc_getId("DSP");
-
- /*If feature not supported by proc, return*/
- if (proc_id == dsp_id)
- return 0;
-
- /* Check if the M3 was loaded */
- core0_loaded = (ipu_pm_state.loaded_procs & CORE0_LOADED);
- core1_loaded = (ipu_pm_state.loaded_procs & CORE1_LOADED);
-
- /* Because of the current scheme, we need to check
- * if CORE1 is enable and we need to enable it too
- * In both cases we should check if for both cores
- * and enable them if they were loaded.
- */
- pthread_mutex_lock(&ipu_pm_state.mtx);
-
- /* Restart the hib timer */
- if (syslink_hib_enable) {
- ipu_pm_timer_state(PM_HIB_TIMER_ON);
- }
-#ifdef QNX_PM_ENABLE
- if(oswr_prevent == 0) {
- tell_powman_auth_oswr(1); // Passing 1 prevents OSWR and 0 allows OSWR
- oswr_prevent = 1;
- }
-#endif
- if (proc_id == core0_id || proc_id == core1_id) {
- if (!(ipu_pm_state.proc_state & CORE0_PROC_DOWN) || !core0_loaded) {
- goto exit;
- }
-
- if (ProcMgr_getState(ipu_pm_state.proc_handles[core0_id]) != ProcMgr_State_Suspended) {
- goto exit;
- }
-
- retval = Omap4430IpcInt_mboxRestoreCtxt(core0_id);
- if(retval != OMAP4430IPCINT_SUCCESS){
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_restore_ctx",
- retval,
- "Not able to restore Mail Box context");
- goto error;
- }
-
-#ifdef DUCATI_WATCHDOG_TIMER
- ipu_pm_gpt_enable(GPTIMER_9);
- restore_gpt_context(GPTIMER_9);
- ipu_pm_gpt_start(GPTIMER_9);
-#endif
- if (GPT3InUse == TRUE) {
- ipu_pm_gpt_enable(GPTIMER_3);
- restore_gpt_context(GPTIMER_3);
- }
-
- GT_0trace(curTrace, GT_4CLASS, "Wakeup CORE0");
- ipu_pm_state.proc_state &= ~CORE0_PROC_DOWN;
- retval = ProcMgr_control(ipu_pm_state.proc_handles[core0_id],
- Omap4430DucatiProc_CtrlCmd_Resume, NULL);
- if (retval < 0){
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_restore_ctx",
- retval, "Not able to resume CORE0");
- goto error;
- }
-
- if (core1_loaded) {
-#ifdef DUCATI_WATCHDOG_TIMER
- ipu_pm_gpt_enable(GPTIMER_11);
- restore_gpt_context(GPTIMER_11);
- ipu_pm_gpt_start(GPTIMER_11);
-#endif
- if (GPT4InUse == TRUE) {
- ipu_pm_gpt_enable(GPTIMER_4);
- restore_gpt_context(GPTIMER_4);
- }
-
- GT_0trace(curTrace, GT_4CLASS, "Wakeup CORE1");
- ipu_pm_state.proc_state &= ~CORE1_PROC_DOWN;
- retval = ProcMgr_control(ipu_pm_state.proc_handles[core1_id],
- Omap4430DucatiProc_CtrlCmd_Resume, NULL);
- if (retval < 0){
- GT_setFailureReason(curTrace, GT_4CLASS, "ipu_pm_restore_ctx",
- retval, "Not able to resume CORE1");
- goto error;
- }
- }
- pthread_mutex_lock(&syslink_hib_mutex);
- // Once we are active, signal any thread waiting for end of hibernation
- syslink_hib_hibernating = FALSE;
- pthread_cond_broadcast(&syslink_hib_cond);
- pthread_mutex_unlock(&syslink_hib_mutex);
- }
- else
- goto error;
-exit:
- /* turn on ducati hibernation timer */
- if (ipu_pm_state.hib_timer_state == PM_HIB_TIMER_OFF ||
- ipu_pm_state.hib_timer_state == PM_HIB_TIMER_RESET) {
- ipu_pm_timer_state(PM_HIB_TIMER_ON);
- }
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- return retval;
-error:
- pthread_mutex_unlock(&ipu_pm_state.mtx);
- return -EINVAL;
-}
-
-/* ISR for Timer*/
-static void ipu_pm_timer_interrupt (union sigval val)
-{
- ipu_pm_save_ctx(MultiProc_getId("CORE0"));
- return;
-}
-#else // DUCATI_SELF_HIBERNATION
-
-int ipu_pm_restore_ctx(int proc_id)
-{
- return 0;
-}
-#endif //DUCATI_SELF_HIBERNATION
-
-int ipu_pm_attach(int proc_id)
-{
- int retval = EOK;
-#ifdef DUCATI_WATCHDOG_TIMER
- OsalIsr_Params isrParams;
-#endif
-
- if (proc_id > MultiProc_MAXPROCESSORS) {
- return -EINVAL;
- }
-
- if (proc_id == MultiProc_getId("CORE0")) {
- ipu_pm_state.loaded_procs |= CORE0_LOADED;
-#ifdef DUCATI_WATCHDOG_TIMER
- ipu_pm_gpt_enable(GPTIMER_9);
- isrParams.checkAndClearFxn = ipu_pm_clr_gptimer_interrupt;
- isrParams.fxnArgs = (Ptr)GPTIMER_9;
- isrParams.intId = OMAP44XX_IRQ_GPT9;
- isrParams.sharedInt = FALSE;
- ipu_pm_state.gpt9IsrObject =
- OsalIsr_create(&ipu_pm_gptimer_interrupt,
- isrParams.fxnArgs, &isrParams);
- if(ipu_pm_state.gpt9IsrObject != NULL) {
- if (OsalIsr_install(ipu_pm_state.gpt9IsrObject) < 0) {
- retval = -ENOMEM;
- }
- }
- else {
- retval = -ENOMEM;
- }
-#endif
- }
- else if (proc_id == MultiProc_getId("CORE1")) {
- ipu_pm_state.loaded_procs |= CORE1_LOADED;
-#ifdef DUCATI_WATCHDOG_TIMER
- ipu_pm_gpt_enable(GPTIMER_11);
- isrParams.checkAndClearFxn = ipu_pm_clr_gptimer_interrupt;
- isrParams.fxnArgs = (Ptr)GPTIMER_11;
- isrParams.intId = OMAP44XX_IRQ_GPT11;
- isrParams.sharedInt = FALSE;
- ipu_pm_state.gpt11IsrObject =
- OsalIsr_create(&ipu_pm_gptimer_interrupt,
- isrParams.fxnArgs, &isrParams);
- if(ipu_pm_state.gpt11IsrObject != NULL) {
- if (OsalIsr_install(ipu_pm_state.gpt11IsrObject) < 0) {
- retval = -ENOMEM;
- }
- }
- else {
- retval = -ENOMEM;
- }
-#endif
- }
-
- if (retval >= 0)
- retval = ProcMgr_open(&ipu_pm_state.proc_handles[proc_id], proc_id);
-
- if (retval < 0) {
-#ifdef DUCATI_WATCHDOG_TIMER
- if (proc_id == MultiProc_getId("CORE0")) {
- if (ipu_pm_state.gpt9IsrObject) {
- OsalIsr_uninstall(ipu_pm_state.gpt9IsrObject);
- OsalIsr_delete(&ipu_pm_state.gpt9IsrObject);
- ipu_pm_state.gpt9IsrObject = NULL;
- }
- ipu_pm_gpt_stop(GPTIMER_9);
- ipu_pm_gpt_disable(GPTIMER_9);
- }
- else if (proc_id == MultiProc_getId("CORE1")) {
- if (ipu_pm_state.gpt11IsrObject) {
- OsalIsr_delete(&ipu_pm_state.gpt11IsrObject);
- ipu_pm_state.gpt11IsrObject = NULL;
- }
- ipu_pm_gpt_stop(GPTIMER_11);
- ipu_pm_gpt_disable(GPTIMER_11);
- }
-#endif
- }
- else {
- ipu_pm_state.attached[proc_id] = TRUE;
- }
-
- return retval;
-}
-
-int ipu_pm_detach(int proc_id)
-{
- int retval = EOK;
-
- if (proc_id > MultiProc_MAXPROCESSORS) {
- return -EINVAL;
- }
-
- ipu_pm_state.attached[proc_id] = FALSE;
-
-#ifdef DUCATI_SELF_HIBERNATION
- if (core0Idle != NULL) {
- munmap_device_io(ROUND_DOWN((uint32_t)core0Idle, 0x1000),
- 0x1000);
- core0Idle = NULL;
- core1Idle = NULL;
- }
-#endif
-
- if (proc_id == MultiProc_getId("CORE0")) {
-#ifdef DUCATI_WATCHDOG_TIMER
- OsalIsr_uninstall(ipu_pm_state.gpt9IsrObject);
- OsalIsr_delete(&ipu_pm_state.gpt9IsrObject);
- ipu_pm_state.gpt9IsrObject = NULL;
- ipu_pm_gpt_stop(GPTIMER_9);
- ipu_pm_gpt_disable(GPTIMER_9);
-#endif
- ipu_pm_state.loaded_procs &= ~CORE0_LOADED;
- }
- else if (proc_id == MultiProc_getId("CORE1")) {
-#ifdef DUCATI_WATCHDOG_TIMER
- OsalIsr_uninstall(ipu_pm_state.gpt11IsrObject);
- OsalIsr_delete(&ipu_pm_state.gpt11IsrObject);
- ipu_pm_state.gpt11IsrObject = NULL;
- ipu_pm_gpt_stop(GPTIMER_11);
- ipu_pm_gpt_disable(GPTIMER_11);
-#endif
- ipu_pm_state.loaded_procs &= ~CORE1_LOADED;
- }
-
- if (ipu_pm_state.proc_handles[proc_id]) {
- ProcMgr_close(&ipu_pm_state.proc_handles[proc_id]);
- ipu_pm_state.proc_handles[proc_id] = NULL;
- }
-
- return retval;
-}
-
-int ipu_pm_setup(ipu_pm_config *cfg)
-{
- int retval = EOK;
- int i = 0;
-#ifdef DUCATI_SELF_HIBERNATION
- struct sigevent signal_event;
-#endif
-
- if (ipu_pm_state.is_setup == false) {
- pthread_mutex_init(&ipu_pm_state.mtx, NULL);
-
- if (cfg == NULL) {
- retval = -EINVAL;
- goto exit;
- }
- if (cfg->num_procs > MultiProc_MAXPROCESSORS) {
- retval = -EINVAL;
- goto exit;
- }
-
- memcpy(&ipu_pm_state.cfg, cfg, sizeof(ipu_pm_config));
-
-#ifdef DUCATI_SELF_HIBERNATION
- /* MBOX flag to check if there are pending messages */
- a9_m3_mbox = (void *)mmap_device_io(0x1000, A9_M3_MBOX);
- if ((uintptr_t)a9_m3_mbox == MAP_DEVICE_FAILED) {
- a9_m3_mbox = NULL;
- retval = -ENOMEM;
- goto exit;
- }
-
- if (syslink_hib_enable) {
- SIGEV_THREAD_INIT (&signal_event, ipu_pm_timer_interrupt, NULL,
- NULL);
- retval = timer_create(CLOCK_REALTIME, &signal_event,
- &ipu_pm_state.hibernation_timer);
- if (retval < 0) {
- retval = -errno;
- goto exit;
- }
- }
-#endif
-
- cm2_base_va = (void *)mmap_device_io(CM2_SIZE, CM2_BASE);
- if ((uintptr_t)cm2_base_va == MAP_DEVICE_FAILED) {
- cm2_base_va = NULL;
- retval = -errno;
- goto exit;
- }
-#ifdef DUCATI_SELF_HIBERNATION
- m3_clkstctrl = cm2_base_va + CM_MPU_M3_CLKCTRL_OFFSET;
-#endif
-
- prm_base_va = (void *)mmap_device_io(PRM_SIZE, PRM_BASE);
- if ((uintptr_t)prm_base_va == MAP_DEVICE_FAILED) {
- prm_base_va = NULL;
- retval = -errno;
- goto exit;
- }
-
- map_gpt_regs();
-#ifdef QNX_PM_ENABLE
- ipu_pm_powman_init();
- ipu_pm_power_init();
-#endif
- for (i = 0; i < NUM_CAM_MODES; i++)
- last_camera_req[i] = 0;
- last_led_req = 0;
-
- ipu_pm_state.is_setup = true;
- }
-
-exit:
- if (retval != EOK) {
- unmap_gpt_regs();
- if (prm_base_va) {
- munmap(prm_base_va, PRM_SIZE);
- prm_base_va = NULL;
- }
- if (cm2_base_va) {
- munmap(cm2_base_va, CM2_SIZE);
- cm2_base_va = NULL;
- }
-#ifdef DUCATI_SELF_HIBERNATION
- m3_clkstctrl = NULL;
-
- if (a9_m3_mbox) {
- munmap(a9_m3_mbox, 0x1000);
- a9_m3_mbox = NULL;
- }
-#endif
- ipu_pm_state.loaded_procs = 0;
- pthread_mutex_destroy(&ipu_pm_state.mtx);
- }
- return retval;
-}
-
-int ipu_pm_destroy()
-{
- int i = 0;
-
- if (ipu_pm_state.is_setup) {
- for (i = 0; i < NUM_CAM_MODES; i++) {
- if (last_camera_req[i])
- ipu_pm_camera_enable(i, 0);
- }
- if (last_led_req)
- ipu_pm_led_enable(0, 0);
-
-#ifdef QNX_PM_ENABLE
- ipu_pm_power_deinit();
- ipu_pm_powman_deinit();
-#endif
-
- unmap_gpt_regs();
-#ifdef DUCATI_SELF_HIBERNATION
- if (syslink_hib_enable) {
- /*Stop the Timer*/
- configure_timer(0, 0);
- /* Delete the timer */
- timer_delete(ipu_pm_state.hibernation_timer);
- }
- if (a9_m3_mbox) {
- munmap(a9_m3_mbox, 0x1000);
- a9_m3_mbox = NULL;
- }
- m3_clkstctrl = NULL;
-#endif
- if (cm2_base_va) {
- munmap(cm2_base_va, CM2_SIZE);
- cm2_base_va = NULL;
- }
- if (prm_base_va) {
- munmap(prm_base_va, PRM_SIZE);
- prm_base_va = NULL;
- }
- pthread_mutex_destroy(&ipu_pm_state.mtx);
- ipu_pm_state.proc_state = 0;
- ipu_pm_state.loaded_procs = 0;
- ipu_pm_state.ivahd_use_cnt = 0;
- ipu_pm_state.is_setup = false;
- }
- return EOK;
-}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/rpmsg-resmgrdrv.c b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/rpmsg-resmgrdrv.c
+++ /dev/null
@@ -1,1446 +0,0 @@
-/*
- * @file rpmsg-resmgrdrv.c
- *
- * @brief driver for resmgr component.
- *
- * ============================================================================
- *
- * Copyright (c) 2011, Texas Instruments Incorporated
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * Contact information for paper mail:
- * Texas Instruments
- * Post Office Box 655303
- * Dallas, Texas 75265
- * Contact information:
- * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
- * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
- * ============================================================================
- *
- */
-
-
-/* Standard headers */
-#include <ti/syslink/Std.h>
-
-/* OSAL & Utils headers */
-#include <ti/syslink/utils/List.h>
-#include <ti/syslink/utils/String.h>
-#include <ti/syslink/utils/Trace.h>
-#include <ti/syslink/utils/Memory.h>
-#include <ti/syslink/utils/IGateProvider.h>
-#include <ti/syslink/utils/GateSpinlock.h>
-#include <ti/ipc/MultiProc.h>
-#include <_MultiProc.h>
-
-/*QNX specific header include */
-#include <errno.h>
-#include <unistd.h>
-#include <sys/iofunc.h>
-#include <sys/dispatch.h>
-#include <sys/netmgr.h>
-
-/* Module headers */
-#include <ti/ipc/MessageQCopy.h>
-#include <_MessageQCopy.h>
-#include <_MessageQCopyDefs.h>
-#include "OsalSemaphore.h"
-#include "std_qnx.h"
-#include <pthread.h>
-
-#include "rpmsg_resmgr.h"
-#if defined(SYSLINK_USE_IPU_PM)
-#include "ipu_pm.h"
-#endif
-#include <SysLinkMemUtils.h>
-
-#define MAX_PROCESSES 32u
-
-/*!
- * @brief Remote connection object
- */
-typedef struct rpmsg_resmgr_conn_object {
- UInt32 addr;
- /*!< Address of this remote connection */
- UInt16 procId;
- /*!< Remote procId */
- List_Handle clients;
- /*!< List of clients on this connection/remote proc */
- UInt32 resRefCount;
- /*!< Reference count for requested resources */
-#if defined(USE_MEMMGR)
- List_Handle tilerBufs;
- /*!< List of tiler buffers allocated on behalf of remote proc */
-#endif
-} rpmsg_resmgr_conn_object;
-
-
-/*!
- * @brief rpmsg-resmgr Module state object
- */
-typedef struct rpmsg_resmgr_ModuleObject_tag {
- Bool isSetup;
- /*!< Indicates whether the module has been already setup */
- IGateProvider_Handle gateHandle;
- /*!< Handle of gate to be used for local thread safety */
- rpmsg_resmgr_conn_object * objects [MultiProc_MAXPROCESSORS];
- /*!< List of all remote connections. */
- MessageQCopy_Handle mqHandle;
- /*!< Local mq handle associated with this module */
- UInt32 endpoint;
-#if defined(USE_MEMMGR)
- /*!< Local endpoint associated with the mq handle */
- MessageQCopy_Handle mqMemHandle;
- /*!< Local mq handle associated with this module */
- UInt32 memEndpoint;
- /*!< Local memMgr endpoint associated with the mq handle */
-#endif
-} rpmsg_resmgr_ModuleObject;
-
-/*!
- * @brief Structure of resource manager client information.
- */
-typedef struct rpmsg_resmgr_client_tag {
- List_Elem element;
- /*!< List element header */
- UInt32 addr;
- /*!< Remote addr for the client */
- List_Handle resources;
- /*!< List of acquired resources */
-} rpmsg_resmgr_client ;
-
-/*!
- * @brief Structure of resource information.
- */
-typedef struct rpmsg_resmgr_res_tag {
- List_Elem element;
- /*!< List element header */
- UInt32 res_type;
- /* Type of resource */
- Char data[];
- /* Resource-specific request info */
-} rpmsg_resmgr_res ;
-
-/*!
- * @brief Structure of resource information.
- */
-typedef struct rpmsg_resmgr_tiler_res_tag {
- List_Elem element;
- /*!< List element header */
- UInt32 buf;
- /* Allocated tiler address */
-} rpmsg_resmgr_tiler_res ;
-
-#if defined(SYSLINK_USE_IPU_PM)
-#define IPU_PM_SELF 100
-#define IPU_PM_MPU 101
-#define IPU_PM_CORE 102
-#endif
-
-int rpmsg_resmgr_free(rpmsg_resmgr_conn_object * resmgr, UInt32 addr, struct rprm_request * request);
-
-/** ============================================================================
- * Globals
- * ============================================================================
- */
-/*!
- * @var rpmsg_resmgr_state
- *
- * @brief rpmsg-resmgr state object variable
- */
-static rpmsg_resmgr_ModuleObject rpmsg_resmgr_state =
-{
- .gateHandle = NULL,
- .isSetup = FALSE,
-};
-
-extern dispatch_t * syslink_dpp;
-
-rpmsg_resmgr_res * find_resource(rpmsg_resmgr_client * client, UInt32 handle)
-{
- List_Elem * elem = NULL;
- rpmsg_resmgr_res * res = NULL;
-
- /* Search the client list for this addr */
- List_traverse(elem, client->resources) {
- if ((UInt32)elem == handle) {
- res = (rpmsg_resmgr_res *)elem;
- break;
- }
- }
-
- return res;
-}
-
-rpmsg_resmgr_client * find_client(List_Handle client_list, UInt32 addr)
-{
- List_Elem * elem = NULL;
- rpmsg_resmgr_client * client = NULL;
-
- /* Search the client list for this addr */
- List_traverse(elem, client_list) {
- if (((rpmsg_resmgr_client *)elem)->addr == addr) {
- client = (rpmsg_resmgr_client *)elem;
- break;
- }
- }
-
- return client;
-}
-
-int rpmsg_resmgr_disconnect(rpmsg_resmgr_conn_object * resmgr, UInt32 addr)
-{
- int status = EOK;
- IArg key = NULL;
- rpmsg_resmgr_client * client = NULL;
-
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- /* Check if this addr already connected */
- client = find_client(resmgr->clients, addr);
-
- /* If found, remove from the list */
- if (client) {
- List_Elem * elem = NULL, * temp = NULL;
- rpmsg_resmgr_res * res = NULL;
- char msg[MessageQCopy_BUFSIZE];
- struct rprm_request * req = (struct rprm_request *)msg;
- struct rprm_free_data * fdata = (struct rprm_free_data *)req->data;
-
- /* Free up resources that weren't properly freed */
- List_traverse_safe(elem, temp, client->resources) {
- res = (rpmsg_resmgr_res *)elem;
- fdata->res_id = (uint32_t)res;
- rpmsg_resmgr_free(resmgr, addr, req);
- }
-
- /* Delete the resource list */
- List_delete(&client->resources);
- List_remove(resmgr->clients, (List_Elem *)client);
- Memory_free (NULL, client, sizeof(*client));
- status = 0;
- }
- else {
- status = -ENOTCONN;
- }
-
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
-
- return status;
-}
-
-int rpmsg_resmgr_constraints_rel(rpmsg_resmgr_conn_object * resmgr, UInt32 addr, struct rprm_request * request)
-{
- int status = EOK;
- IArg key = NULL;
- UInt32 tmp_rsrc;
- rpmsg_resmgr_client * client = NULL;
- struct rprm_constraint * cdata = (struct rprm_constraint *)(request->data);
-#if defined(SYSLINK_USE_IPU_PM)
- struct ipu_pm_const_req req;
-#endif
-
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- /* Check if this client is connected */
- client = find_client(resmgr->clients, addr);
-
- /* If client found, handle the request */
- if (client) {
- /* Find this resource in the resource list */
- rpmsg_resmgr_res * resource = find_resource(client, cdata->res_id);
- if (resource) {
- if (cdata->data.mask & RPRM_SCALE) {
- /* This is a frequency request */
- switch (resource->res_type) {
- case RPRM_IPU:
- case RPRM_ISS:
- case RPRM_FDIF:
-#if defined(SYSLINK_USE_IPU_PM)
- tmp_rsrc = IPU_PM_CORE;
-#endif
- break;
- default:
- tmp_rsrc = resource->res_type;
- break;
- }
-#if defined(SYSLINK_USE_IPU_PM)
- req.rsrc = resource->res_type;
- req.target_rsrc = tmp_rsrc;
- req.rate = NO_FREQ_CONSTRAINT;
- status = ipu_pm_set_rate(&req);
-#endif
- }
- if (cdata->data.mask & RPRM_LATENCY) {
- /* This is a latency request */
- /* TODO: handle the latency request */
- }
- if (cdata->data.mask & RPRM_BANDWIDTH) {
- /* This is a bandwidth request */
- if(resource->res_type == RPRM_IPU) {
- GT_1trace(curTrace, GT_3CLASS, "###L3 BANDWIDTH CONSTRAINTS release(%d)", cdata->data.bandwidth);
-#if defined(SYSLINK_USE_IPU_PM)
- ipu_pm_set_bandwidth(0);
-#endif
- }
- }
- }
- else {
- status = -ENOENT;
- }
- }
- else {
- status = -ENOTCONN;
- }
-
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
- return status;
-}
-
-int rpmsg_resmgr_constraints_req(rpmsg_resmgr_conn_object * resmgr, UInt32 addr, struct rprm_request * request)
-{
- int status = EOK;
- IArg key = NULL;
- UInt32 tmp_rsrc;
- rpmsg_resmgr_client * client = NULL;
- struct rprm_constraint * cdata = (struct rprm_constraint *)(request->data);
-#if defined(SYSLINK_USE_IPU_PM)
- struct ipu_pm_const_req req;
-#endif
-
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- /* Check if this client is connected */
- client = find_client(resmgr->clients, addr);
-
- /* If client found, handle the request */
- if (client) {
- /* Find this resource in the resource list */
- rpmsg_resmgr_res * resource = find_resource(client, cdata->res_id);
- if (resource) {
- if (cdata->data.mask & RPRM_SCALE) {
- /* This is a frequency request */
- switch (resource->res_type) {
- case RPRM_IPU:
- case RPRM_ISS:
- case RPRM_FDIF:
-#if defined(SYSLINK_USE_IPU_PM)
- tmp_rsrc = IPU_PM_CORE;
-#endif
- break;
- default:
- tmp_rsrc = resource->res_type;
- break;
- }
-#if defined(SYSLINK_USE_IPU_PM)
- req.rsrc = resource->res_type;
- req.target_rsrc = tmp_rsrc;
- req.rate = cdata->data.frequency;
- status = ipu_pm_set_rate(&req);
-#endif
- }
- if (cdata->data.mask & RPRM_LATENCY) {
- /* This is a latency request */
- /* TODO: handle the latency request */
- }
- if (cdata->data.mask & RPRM_BANDWIDTH) {
- /* This is a bandwidth request */
- if(resource->res_type == RPRM_IPU) {
- GT_1trace(curTrace, GT_3CLASS, "###L3 BANDWIDTH CONSTRAINTS req(%d)", cdata->data.bandwidth);
-#if defined(SYSLINK_USE_IPU_PM)
- ipu_pm_set_bandwidth(cdata->data.bandwidth);
-#endif
- }
- }
- }
- else {
- status = -ENOENT;
- }
- }
- else {
- status = -ENOTCONN;
- }
-
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
- return status;
-}
-
-
-
-int rpmsg_resmgr_req_data(rpmsg_resmgr_conn_object * resmgr, UInt32 addr, struct rprm_request * request)
-{
- int status = EOK;
- IArg key = NULL;
- rpmsg_resmgr_client * client = NULL;
- struct rprm_reqdata * rdata = (struct rprm_reqdata *)request->data;
-
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- /* Check if this client is connected */
- client = find_client(resmgr->clients, addr);
-
- /* If client found, alloc the resource */
- if (client) {
- rpmsg_resmgr_res * resource = find_resource(client, rdata->res_id);
- if (resource) {
- switch (rdata->type) {
- case RPRM_REQTYPE_MAXFREQ:
- {
-#if defined(SYSLINK_USE_IPU_PM)
- struct rprm_freq * fdata = (struct rprm_freq *)rdata->data;
- status = ipu_pm_get_max_freq(resource->res_type, &fdata->value);
-#else
- status = -ENOENT;
-#endif
- }
- break;
- default:
- status = -ENOENT;
- break;
- }
- }
- else {
- status = -ENOENT;
- }
- }
- else {
- status = -ENOTCONN;
- }
-
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
- return status;
-}
-
-/* Must be holding gate when calling this function */
-int rpmsg_resmgr_free(rpmsg_resmgr_conn_object * resmgr, UInt32 addr, struct rprm_request * request)
-{
- int status = EOK;
- struct rprm_free_data * fdata = (struct rprm_free_data *)request->data;
- rpmsg_resmgr_client * client = NULL;
-
- /* Check if this client is connected */
- client = find_client(resmgr->clients, addr);
-
- /* If client found, free the resource */
- if (client) {
- /* Find this resource in the resource list */
- rpmsg_resmgr_res * resource = find_resource(client, fdata->res_id);
- if (resource) {
- /* Remove resource from list and free memory */
- List_remove(client->resources, &resource->element);
- switch (resource->res_type) {
- case RPRM_IVAHD:
-#if defined(SYSLINK_USE_IPU_PM)
- status = ipu_pm_ivahd_disable();
-#endif
- break;
- case RPRM_IVASEQ0:
-#if defined(SYSLINK_USE_IPU_PM)
- status = ipu_pm_ivaseq0_disable();
-#endif
- break;
- case RPRM_IVASEQ1:
-#if defined(SYSLINK_USE_IPU_PM)
- status = ipu_pm_ivaseq1_disable();
-#endif
- break;
- case RPRM_L3BUS:
- /* TODO: handle RPRM_L3BUS free request */
- break;
- case RPRM_SL2IF:
- /* TODO: handle SL2IF free request */
- break;
- case RPRM_IPU:
- /* TODO: handle IPU free request */
- break;
- case RPRM_DSP:
- /* TODO: handle DSP free request */
- break;
- case RPRM_SDMA:
- {
-#if defined(SYSLINK_USE_IPU_PM)
- struct rprm_sdma * sdma = (struct rprm_sdma *)resource->data;
- status = ipu_pm_free_sdma(sdma->num_chs, sdma->channels);
- if (status < 0) {
- status = -1;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_free",
- status,
- "Failed to free DMA!");
- }
-#endif
- }
- break;
- case RPRM_CAMERA:
- /* Nothing to do. Always passes. */
- break;
- case RPRM_LED:
- /* Nothing to do. Always passes. */
- break;
- default:
- break;
- }
- /* Free the resource */
- Memory_free(NULL, resource, sizeof(*resource));
- fdata->res_id = 0;
- }
- else {
- status = -ENOENT;
- }
- }
- else {
- status = -ENOTCONN;
- }
-
- if (status >= 0) {
- resmgr->resRefCount--;
- }
-
- return status;
-}
-
-int rpmsg_resmgr_alloc(rpmsg_resmgr_conn_object * resmgr, UInt32 addr, struct rprm_request * request, uint32_t res_type)
-{
- int status = EOK;
- IArg key = NULL;
- rpmsg_resmgr_client * client = NULL;
-#if defined(SYSLINK_USE_IPU_PM)
- struct rprm_alloc_data * adata = (struct rprm_alloc_data *)request->data;
-#endif
-
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- /* Check if this client is connected */
- client = find_client(resmgr->clients, addr);
-
- /* If client found, alloc the resource */
- if (client) {
- /* TODO: alloc the resource */
- switch (res_type) {
- case RPRM_IVAHD:
-#if defined(SYSLINK_USE_IPU_PM)
- status = ipu_pm_ivahd_enable();
- if (status < 0) {
- status = -1;
- ipu_pm_ivahd_disable();
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_alloc",
- status,
- "Failed to enable IVAHD!");
- }
-#endif
- break;
- case RPRM_IVASEQ0:
-#if defined(SYSLINK_USE_IPU_PM)
- status = ipu_pm_ivaseq0_enable();
-#endif
- break;
- case RPRM_IVASEQ1:
-#if defined(SYSLINK_USE_IPU_PM)
- status = ipu_pm_ivaseq1_enable();
-#endif
- break;
- case RPRM_L3BUS:
- /* TODO: handle RPRM_L3BUS alloc request */
- break;
- case RPRM_SL2IF:
- /* TODO: handle SL2IF alloc request */
- break;
- case RPRM_IPU:
- /* TODO: handle IPU alloc request */
- break;
- case RPRM_DSP:
- /* TODO: handle DSP alloc request */
- break;
- case RPRM_SDMA:
- {
-#if defined(SYSLINK_USE_IPU_PM)
- struct rprm_sdma * sdma = (struct rprm_sdma *)adata->data;
- status = ipu_pm_alloc_sdma(sdma->num_chs, sdma->channels);
- if (status < 0) {
- status = -1;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_alloc",
- status,
- "Failed to alloc DMA!");
- }
-#endif
- }
- break;
-
- case RPRM_CAMERA:
- {
-#if defined(SYSLINK_USE_IPU_PM)
- struct rprm_camera * cam = (struct rprm_camera *)adata->data;
- status = ipu_pm_camera_enable(cam->mode, cam->on);
- if (status < 0) {
- status = -1;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_alloc",
- status,
- "Failed to enable camera!");
- }
-#endif
- }
- break;
- case RPRM_LED:
- {
-#if defined(SYSLINK_USE_IPU_PM)
- struct rprm_led * led = (struct rprm_led *)adata->data;
- led->intensity = ipu_pm_led_enable(led->mode, led->intensity);
- if (led->intensity == -1) {
- status = -1;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_alloc",
- status,
- "Failed to enable led!");
- }
-#endif
- }
- break;
- default:
- status = -ENOENT;
- break;
- }
- if (status >= 0) {
- rpmsg_resmgr_res * resource = NULL;
- /* store the resource per-client for tracking */
- resource = Memory_alloc(NULL, sizeof (rpmsg_resmgr_res), 0x0, NULL);
- if (resource) {
- resource->res_type = res_type;
- List_put(client->resources, &resource->element);
- }
- else {
- status = -ENOMEM;
- }
- /* give the resource id back to the requester */
- status = (int)resource;
- }
- }
- else {
- status = -ENOTCONN;
- }
-
- if (status >= 0) {
- resmgr->resRefCount++;
- }
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
- return status;
-}
-
-int rpmsg_resmgr_connect(rpmsg_resmgr_conn_object * resmgr, UInt32 addr)
-{
- int status = EOK;
- IArg key = NULL;
- rpmsg_resmgr_client * client = NULL;
- List_Params listParams;
-
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- /* Check if this addr already connected */
- client = find_client(resmgr->clients, addr);
-
- /* Otherwise, add to the list */
- if (!client) {
- client = Memory_alloc (NULL, sizeof(*client), 0x0, NULL);
- if (client) {
- client->addr = addr;
- /* create a list to store resources used by this client */
- List_Params_init(&listParams);
- client->resources = List_create(&listParams);
- if (client->resources) {
- List_put (resmgr->clients, &(client->element));
- }
- else {
- Memory_free (NULL, client, sizeof(*client));
- client = NULL;
- status = -ENOMEM;
- }
- }
- else {
- status = -ENOMEM;
- }
- }
- else {
- status = -EISCONN;
- }
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
- return status;
-}
-
-uint32_t rpmsg_resmgr_get_resp_len(uint32_t res_type)
-{
- uint32_t len = 0;
-
- switch (res_type) {
- case RPRM_GPTIMER:
- len = sizeof(struct rprm_gpt);
- break;
- case RPRM_AUXCLK:
- len = sizeof(struct rprm_auxclk);
- break;
- case RPRM_REGULATOR:
- len = sizeof(struct rprm_regulator);
- break;
- case RPRM_GPIO:
- len = sizeof(struct rprm_gpio);
- break;
- case RPRM_SDMA:
- len = sizeof(struct rprm_sdma);
- break;
- case RPRM_IPU:
- case RPRM_DSP:
- len = sizeof(struct rprm_proc);
- break;
- case RPRM_I2C:
- len = sizeof(struct rprm_i2c);
- break;
- case RPRM_CAMERA:
- len = sizeof(struct rprm_camera);
- break;
- case RPRM_LED:
- len = sizeof(struct rprm_led);
- break;
- default:
- len = 0;
- break;
- }
-
- return len;
-}
-
-uint32_t rpmsg_resmgr_get_req_data_len(uint32_t res_type)
-{
- uint32_t len = 0;
-
- switch (res_type) {
- case RPRM_REQTYPE_MAXFREQ:
- len = sizeof(struct rprm_freq);
- break;
- default:
- len = 0;
- break;
- }
-
- return len;
-}
-
-uint32_t rpmsg_resmgr_get_req_len(uint32_t acquire)
-{
- uint32_t len = 0;
-
- switch (acquire) {
- case RPRM_REQ_ALLOC:
- len = sizeof(struct rprm_alloc_data);
- break;
- case RPRM_REQ_FREE:
- len = sizeof(struct rprm_free_data);
- break;
- case RPRM_REQ_CONSTRAINTS:
- len = sizeof(struct rprm_constraint);
- break;
- case RPRM_REQ_DATA:
- len = sizeof(struct rprm_reqdata);
- break;
- default:
- break;
- }
-
- return len;
-}
-
-uint32_t rpmsg_resmgr_get_alloc_data_len(uint32_t res_type)
-{
- uint32_t len = 0;
-
- switch (res_type) {
- case RPRM_GPTIMER:
- len = sizeof(struct rprm_gpt);
- break;
- case RPRM_AUXCLK:
- len = sizeof(struct rprm_auxclk);
- break;
- case RPRM_REGULATOR:
- len = sizeof(struct rprm_regulator);
- break;
- case RPRM_GPIO:
- len = sizeof(struct rprm_gpio);
- break;
- case RPRM_SDMA:
- len = sizeof(struct rprm_sdma);
- break;
- case RPRM_IPU:
- case RPRM_DSP:
- len = sizeof(struct rprm_proc);
- break;
- case RPRM_I2C:
- len = sizeof(struct rprm_i2c);
- break;
- case RPRM_CAMERA:
- len = sizeof(struct rprm_camera);
- break;
- case RPRM_LED:
- len = sizeof(struct rprm_led);
- break;
- default:
- break;
- }
-
- return len;
-}
-
-/*!
- * @brief This function implements the callback registered with IPS. Here
- * to pass event no. back to user function (so that it can do
- * another level of demultiplexing of callbacks)
- *
- * @param procId processor Id from which interrupt is received
- * @param lineId Interrupt line ID to be used
- * @param eventId eventId registered
- * @param arg argument to call back
- * @param payload payload received
- *
- * @sa
- */
-Void
-_rpmsg_resmgr_cb (MessageQCopy_Handle handle, void * data, int len, void * priv, UInt32 src, UInt16 srcProc)
-{
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- Int32 status = 0;
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- int err = EOK;
- int i = 0;
- rpmsg_resmgr_conn_object * resmgr_conn = NULL;
- struct rprm_request * request = (struct rprm_request *)data;
- char msg[MessageQCopy_BUFSIZE];
- struct rprm_ack * response = (struct rprm_ack *)msg;
- int resp_len = 0;
- int req_len = 0;
- IArg key = NULL;
- Int res_type = -1;
- struct rprm_alloc_data * adata = NULL;
- struct rprm_ack_data *ack_data = (struct rprm_ack_data *)response->data;
- struct rprm_reqdata * rdata = NULL;
-
- GT_6trace (curTrace,
- GT_ENTER,
- "_rpmsg_resmgr_cb",
- handle,
- data,
- len,
- priv,
- src,
- srcProc);
-
- if (len < sizeof(struct rprm_request)) {
- /* Message is not large enough */
- /* TODO: handle error */
- return;
- }
-
- req_len = rpmsg_resmgr_get_req_len(request->acquire);
- if (len < sizeof(struct rprm_request) + req_len) {
- /* Message is not large enough */
- /* TODO: handle error */
- err = -EINVAL;
- goto exit;
- }
- if (request->acquire == RPRM_REQ_ALLOC) {
- adata = (struct rprm_alloc_data *)request->data;
- res_type = rpmsg_resmgr_to_type(adata->res_name);
- if (res_type != -1) {
- if (res_type == -2) {
- struct rprm_proc * proc = (struct rprm_proc *)adata->data;
- if (len < sizeof(struct rprm_request) +
- sizeof(struct rprm_proc) + req_len) {
- /* Message is not large enough */
- err = -EINVAL;
- goto exit;
- }
- res_type = rpmsg_resmgr_to_type(proc->name);
- }
- req_len += rpmsg_resmgr_get_alloc_data_len(res_type);
- if (len < sizeof(struct rprm_request) + req_len) {
- /* Message is not large enough */
- err = -EINVAL;
- goto exit;
- }
- }
- else {
- err = -EINVAL;
- goto exit;
- }
- }
- else if (request->acquire == RPRM_REQ_DATA) {
- rdata = (struct rprm_reqdata *)request->data;
- res_type = rdata->type;
- req_len += rpmsg_resmgr_get_req_data_len(res_type);
- if (len < sizeof(struct rprm_request) + req_len) {
- /* Message is not large enough */
- err = -EINVAL;
- goto exit;
- }
- }
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i] != NULL) {
- if (rpmsg_resmgr_state.objects[i]->procId == srcProc)
- break;
- }
- }
- if (i == MultiProc_MAXPROCESSORS) {
- err = -EINVAL;
- goto exit;
- }
- resmgr_conn = (rpmsg_resmgr_conn_object *) rpmsg_resmgr_state.objects[i];
-
- switch (request->acquire) {
- case RPRM_REQ_ALLOC:
- err = rpmsg_resmgr_alloc(resmgr_conn, src, request, res_type);
- if (err > EOK) {
- resp_len = rpmsg_resmgr_get_resp_len(res_type);
- ack_data->res_id = err;
- Memory_copy(ack_data->data, adata->data, resp_len);
- resp_len += sizeof(*ack_data);
- err = EOK;
- }
- break;
- case RPRM_REQ_FREE:
- /* Grab the gate */
- key = IGateProvider_enter (rpmsg_resmgr_state.gateHandle);
- err = rpmsg_resmgr_free(resmgr_conn, src, request);
- /* Release the gate */
- IGateProvider_leave (rpmsg_resmgr_state.gateHandle, key);
- /* don't send a response in this case */
- return;
- case RPRM_REQ_CONSTRAINTS:
- resp_len = sizeof(struct rprm_constraint);
- err = rpmsg_resmgr_constraints_req(resmgr_conn, src, request);
- break;
- case RPRM_REL_CONSTRAINTS:
- err = rpmsg_resmgr_constraints_rel(resmgr_conn, src, request);
- /* don't send a response in this case */
- return;
- case RPRM_REQ_DATA:
- resp_len = rpmsg_resmgr_get_req_data_len(rdata->type);
- err = rpmsg_resmgr_req_data(resmgr_conn, src, request);
- break;
- default:
- err = -EINVAL;
- break;
- }
-
-exit:
- /* Populate the response */
- response->acquire = request->acquire;
- response->ret = err;
-
- /* Send the response to the remote core */
- status = MessageQCopy_send(srcProc, MultiProc_self(), src,
- rpmsg_resmgr_state.endpoint, response,
- sizeof(*response) + resp_len,
- TRUE);
- if (status < 0) {
- /* TODO: handle error */
- }
-
- GT_0trace (curTrace, GT_LEAVE, "_rpmsg_resmgr_cb");
-}
-
-#if defined(USE_MEMMGR)
-/*
- * MemMgr request sent to MemMgr server
- */
-
-typedef struct {
- UInt32 reqType;
- char args[];
-} MemMgr_Req;
-
-/*
- * MemMgr response received from MemMgr server
- */
-
-typedef struct {
- UInt32 result;
-} MemMgr_Resp;
-
-typedef enum {
- MemMgr_Function_ALLOC,
- MemMgr_Function_FREE
-} MemMgr_ReqType;
-
-/*!
- * @brief This function implements the callback registered with IPC. Here
- * to pass event no. back to user function (so that it can do
- * another level of demultiplexing of callbacks)
- *
- * @param procId processor Id from which interrupt is received
- * @param lineId Interrupt line ID to be used
- * @param eventId eventId registered
- * @param arg argument to call back
- * @param payload payload received
- *
- * @sa
- */
-Void
-_rpmsg_memmgr_cb (MessageQCopy_Handle handle, void * data, int len, void * priv, UInt32 src, UInt16 srcProc)
-{
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- Int32 status = 0;
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- int err = EOK;
- int i = 0;
- rpmsg_resmgr_conn_object * resmgr_conn = NULL;
- MemMgr_Req * request = (MemMgr_Req *)data;
- char msg[MessageQCopy_BUFSIZE];
- MemMgr_Resp * response = (MemMgr_Resp *)msg;
- List_Elem * elem = NULL;
- rpmsg_resmgr_tiler_res * res = NULL;
-
- GT_6trace (curTrace,
- GT_ENTER,
- "_rpmsg_memmgr_cb",
- handle,
- data,
- len,
- priv,
- src,
- srcProc);
-
- if (len < sizeof(MemMgr_Req)) {
- /* Message is not large enough */
- /* TODO: handle error */
- return;
- }
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i] != NULL) {
- if (rpmsg_resmgr_state.objects[i]->procId == srcProc)
- break;
- }
- }
- if (i == MultiProc_MAXPROCESSORS) {
- /* TODO: handle error */
- return;
- }
- resmgr_conn = (rpmsg_resmgr_conn_object *) rpmsg_resmgr_state.objects[i];
-
- switch (request->reqType) {
- case MemMgr_Function_ALLOC:
- err = SysLinkMemUtils_alloc(len, (UInt32 *)request->args);
- if (err != 0) {
- res = Memory_alloc(NULL, sizeof (rpmsg_resmgr_tiler_res), 0x0, NULL);
- if (res) {
- res->buf = err;
- List_put(resmgr_conn->tilerBufs, &res->element);
- }
- else {
- err = 0;
- SysLinkMemUtils_free(len, (UInt32 *)&err);
- }
- }
- break;
- case MemMgr_Function_FREE:
- err = SysLinkMemUtils_free(len, (UInt32 *)request->args);
- /* Search the client list for this addr */
- List_traverse(elem, resmgr_conn->tilerBufs) {
- res = (rpmsg_resmgr_tiler_res *)elem;
- if (res->buf == *(UInt32 *)(request->args)) {
- break;
- }
- }
- if (res) {
- List_remove(resmgr_conn->tilerBufs, &res->element);
- }
- break;
- default:
- err = -EINVAL;
- break;
- }
-
- /* Populate the response */
- response->result = err;
-
- /* Send the response to the remote core */
- status = MessageQCopy_send(srcProc, MultiProc_self(), src, rpmsg_resmgr_state.memEndpoint, response, sizeof(*response), TRUE);
- if (status < 0) {
- /* TODO: handle error */
- }
-
- GT_0trace (curTrace, GT_LEAVE, "_rpmsg_memmgr_cb");
-}
-#endif
-
-static
-Void
-_rpmsg_resmgr_create_conn (UInt16 procId, UInt32 endpoint)
-{
- Int i = 0;
- Bool found = FALSE;
- rpmsg_resmgr_conn_object * obj = NULL;
- List_Params listParams;
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i] == NULL) {
- found = TRUE;
- break;
- }
- }
-
- if (found) {
- /* found a space to save this mq handle, allocate memory */
- obj = Memory_calloc (NULL, sizeof (rpmsg_resmgr_conn_object), 0x0, NULL);
- if (obj) {
- /* store the object in the module info */
- rpmsg_resmgr_state.objects[i] = obj;
-
- /* store the mq info in the object */
- obj->procId = procId;
- obj->addr = endpoint;
-
- /* create a list to store remote proc connections */
- List_Params_init(&listParams);
- obj->clients = List_create(&listParams);
- if (obj->clients == NULL) {
- rpmsg_resmgr_state.objects[i] = NULL;
- Memory_free (NULL, obj, sizeof (rpmsg_resmgr_conn_object));
- }
- else {
- /* create a list to store remote proc connections */
- List_Params_init(&listParams);
-#if defined(USE_MEMMGR)
- obj->tilerBufs = List_create(&listParams);
- if (obj->tilerBufs == NULL) {
- List_delete(&obj->clients);
- obj->clients = NULL;
- rpmsg_resmgr_state.objects[i] = NULL;
- Memory_free (NULL, obj, sizeof (rpmsg_resmgr_conn_object));
- }
-#endif
- }
- }
- }
-}
-
-
-static
- Void
- _rpmsg_resmgr_delete_conn (rpmsg_resmgr_conn_object * obj)
-{
- Int i = 0;
- Bool found = FALSE;
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i] == obj) {
- found = TRUE;
- break;
- }
- }
-
- if (found) {
- if (obj) {
-#if defined(USE_MEMMGR)
- if (obj->tilerBufs) {
- UInt32 buf = NULL;
- List_Elem * elem = NULL, * temp = NULL;
- /* Free up resources that weren't properly freed */
- List_traverse_safe(elem, temp, obj->tilerBufs) {
- buf = ((rpmsg_resmgr_tiler_res *)elem)->buf;
- SysLinkMemUtils_free(sizeof(Ptr), &buf);
- }
- List_delete(&obj->tilerBufs);
- }
-#endif
- if (obj->clients) {
- /* Check if there are still registered clients and
- disconnect them, thereby freeing the resources. */
- List_Elem * elem = NULL, * temp = NULL;
- rpmsg_resmgr_client * client = NULL;
-
- List_traverse_safe(elem, temp, obj->clients) {
- client = (rpmsg_resmgr_client *)elem;
- rpmsg_resmgr_disconnect(obj, client->addr);
- }
-
- List_delete(&obj->clients);
- }
- rpmsg_resmgr_state.objects[i] = NULL;
- Memory_free(NULL, obj, sizeof(rpmsg_resmgr_conn_object));
- }
- }
-}
-
-/**
- * Callback passed to MessageQCopy_registerNotify.
- *
- * This callback is called when a remote processor creates a MessageQCopy
- * handle with the same name as the local MessageQCopy handle and then
- * calls NameMap_register to notify the HOST of the handle.
- *
- * \param handle The remote handle.
- * \param procId The remote proc ID of the remote handle.
- * \param endpoint The endpoint address of the remote handle.
- * \param create The endpoint is created or deleted
- *
- * \return None.
- */
-
-static
-Void
-_rpmsg_resmgr_notify_cb (MessageQCopy_Handle handle, UInt16 procId,
- UInt32 endpoint, Char * desc, Bool create)
-{
- int status = EOK;
- Int i = 0;
- Bool found = FALSE;
- rpmsg_resmgr_conn_object * resmgr_conn = NULL;
- Char msg[MessageQCopy_BUFSIZE];
- struct rprm_ack * response = (struct rprm_ack *)msg;
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i] != NULL) {
- if (rpmsg_resmgr_state.objects[i]->procId == procId) {
- found = TRUE;
- break;
- }
- }
- }
-
- if (found) {
- resmgr_conn = (rpmsg_resmgr_conn_object *) rpmsg_resmgr_state.objects[i];
-
- if (create)
- status = rpmsg_resmgr_connect(resmgr_conn, endpoint);
- else {
- status = rpmsg_resmgr_disconnect(resmgr_conn, endpoint);
- // don't send a response in this case
- return;
- }
- }
- else {
- status = -EINVAL;
- }
-
- /* Populate the response */
- response->ret = status;
-
- /* Send the response to the remote core */
- status = MessageQCopy_send(procId, MultiProc_self(), endpoint,
- rpmsg_resmgr_state.endpoint, response,
- sizeof(*response), TRUE);
- if (status < 0) {
- /* TODO: handle error */
- }
-}
-
-Bool
-rpmsg_resmgr_allow_hib (UInt16 proc_id)
-{
- Bool allow = FALSE;
- int i = 0;
- rpmsg_resmgr_conn_object * resmgr_conn = NULL;
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i] != NULL) {
- if (rpmsg_resmgr_state.objects[i]->procId == proc_id)
- break;
- }
- }
- if (i < MultiProc_MAXPROCESSORS) {
- resmgr_conn = (rpmsg_resmgr_conn_object *) rpmsg_resmgr_state.objects[i];
-
- if (!resmgr_conn->resRefCount)
- allow = TRUE;
- }
-
- return allow;
-}
-
-/*!
- * @brief Module setup function.
- *
- * @sa rpmsg_resmgr_destroy
- */
-Int
-rpmsg_resmgr_setup (Void)
-{
- Int status = 0;
- UInt32 i = 0;
- Error_Block eb;
-
- GT_0trace (curTrace, GT_ENTER, "rpmsg_resmgr_setup");
-
- Error_init(&eb);
-
- rpmsg_resmgr_state.gateHandle = (IGateProvider_Handle)
- GateSpinlock_create ((GateSpinlock_Handle) NULL, &eb);
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- if (rpmsg_resmgr_state.gateHandle == NULL) {
- status = -ENOMEM;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "_rpmsg_resmgr_setup",
- status,
- "Failed to create spinlock gate!");
- }
- else {
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
- rpmsg_resmgr_state.mqHandle = MessageQCopy_create (
- MessageQCopy_ADDRANY,
- "rpmsg-resmgr",
- _rpmsg_resmgr_cb,
- NULL,
- &rpmsg_resmgr_state.endpoint);
- if (rpmsg_resmgr_state.mqHandle == NULL) {
- /*! @retval ENOMEM Failed to register MQCopy handle! */
- status = -ENOMEM;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_setup",
- status,
- "Failed to create MessageQCopy handle!");
- }
- else {
- status = MessageQCopy_registerNotify(rpmsg_resmgr_state.mqHandle,
- _rpmsg_resmgr_notify_cb);
- if (status >= 0) {
-#if defined(USE_MEMMGR)
- rpmsg_resmgr_state.mqMemHandle = MessageQCopy_create (
- 90,
- "rpmsg-memmgr",
- _rpmsg_memmgr_cb,
- NULL,
- &rpmsg_resmgr_state.memEndpoint);
- if (rpmsg_resmgr_state.mqMemHandle == NULL) {
- MessageQCopy_delete (&rpmsg_resmgr_state.mqHandle);
- /*! @retval ENOMEM Failed to register MQCopy handle! */
- status = -ENOMEM;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_setup",
- status,
- "Failed to create MessageQCopy handle!");
- }
- else {
-#endif
- for (i = 0; i < MultiProc_getNumProcessors(); i++) {
- if (i != MultiProc_self())
- _rpmsg_resmgr_create_conn(i,
- rpmsg_resmgr_state.endpoint);
- }
- if (status < 0) {
-#if defined(USE_MEMMGR)
- MessageQCopy_delete (&rpmsg_resmgr_state.mqMemHandle);
-#endif
- MessageQCopy_delete (&rpmsg_resmgr_state.mqHandle);
- /*! @retval ENOMEM Failed to register MQCopy handle! */
- status = -ENOMEM;
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "rpmsg_resmgr_setup",
- status,
- "Failed to register MQCopy handle!");
- }
- if (status >= 0) {
- rpmsg_resmgr_state.isSetup = TRUE;
- }
-#if defined (USE_MEMMGR)
- }
-#endif
- }
- else {
- GT_setFailureReason (curTrace,
- GT_4CLASS,
- "_rpmsg_resmgr_setup",
- status,
- "Failed to register callback!");
- }
- }
-#if !defined(SYSLINK_BUILD_OPTIMIZE)
- }
-#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
-
- GT_0trace (curTrace, GT_LEAVE, "rpmsg_resmgr_setup");
- return status;
-}
-
-
-/*!
- * @brief Module destroy function.
- *
- * @sa rpmsg_resmgr_setup
- */
-Void
-rpmsg_resmgr_destroy (Void)
-{
- int i = 0;
-
- GT_0trace (curTrace, GT_ENTER, "_rpmsg_resmgr_destroy");
-
- for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
- if (rpmsg_resmgr_state.objects[i])
- _rpmsg_resmgr_delete_conn(rpmsg_resmgr_state.objects[i]);
- }
-#if defined(USE_MEMMGR)
- MessageQCopy_delete(&rpmsg_resmgr_state.mqMemHandle);
-#endif
- MessageQCopy_delete(&rpmsg_resmgr_state.mqHandle);
-
- if (rpmsg_resmgr_state.gateHandle != NULL) {
- GateSpinlock_delete ((GateSpinlock_Handle *)
- &(rpmsg_resmgr_state.gateHandle));
- }
-
-#if defined(SYSLINK_USE_IPU_PM)
- ipu_pm_ivahd_off();
-#endif
-
- rpmsg_resmgr_state.isSetup = FALSE ;
-
- GT_0trace (curTrace, GT_LEAVE, "_rpmsgDrv_destroy");
-}
-
-
-/** ============================================================================
- * Internal functions
- * ============================================================================
- */
-
-
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/rpmsg-resmgrdrv.h b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/rpmsg-resmgrdrv.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * @file rpmsg-resmgrdrv.h
- *
- * @brief header for resmgrdrv component.
- *
- * ============================================================================
- *
- * Copyright (c) 2011, Texas Instruments Incorporated
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * Contact information for paper mail:
- * Texas Instruments
- * Post Office Box 655303
- * Dallas, Texas 75265
- * Contact information:
- * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
- * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
- * ============================================================================
- *
- */
-
-#ifndef _RPMSG_RESMGRDRV_H
-#define _RPMSG_RESMGRDRV_H
-
-#include <ipu_pm.h>
-
-void rpmsg_resmgr_constraints_resp(struct ipu_pm_const_req * req);
-
-#endif /* _RPMSG_RESMGRDRV_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/rpmsg_resmgr.h b/qnx/src/ipc3x_dev/ti/syslink/rpmsg-resmgr/hlos/knl/Qnx/rpmsg_resmgr.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Remote processor messaging
- *
- * Copyright (c) 2011-2013 Texas Instruments. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Texas Instruments nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _LINUX_RPMSG_RESMGR_H
-#define _LINUX_RPMSG_RESMGR_H
-
-#include <stdint.h>
-
-#define __packed __attribute__ ((packed))
-
-#define MAX_NUM_SDMA_CHANNELS 16
-
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
-
-/* Names should match the IpcResource_Type definitions */
-static char * rpmsg_resmgr_names[] = {
- "omap-gptimer",
- "iva",
- "iva_seq0",
- "iva_seq1",
- "l3bus",
- "omap-iss",
- "omap-fdif",
- "omap-sl2if",
- "omap-auxclk",
- "regulator",
- "gpio",
- "omap-sdma",
- "ipu_c0",
- "dsp_c0",
- "i2c",
- "camera",
- "led"
-};
-
-static inline int32_t rpmsg_resmgr_to_type(char * name)
-{
- int i = 0;
- /* check for NULL-terminated string */
- for (i = 0; i < 16; i++) {
- if (name[i] == '\0')
- break;
- }
- if (i == 16) return -1;
- for (i = 0; i < ARRAY_SIZE(rpmsg_resmgr_names); i++) {
- if (!strcmp(rpmsg_resmgr_names[i], name))
- return i;
- }
- if (!strcmp("rproc", name)) {
- return -2;
- }
- return -1;
-}
-
-enum {
- RPRM_GPTIMER = 0,
- RPRM_IVAHD = 1,
- RPRM_IVASEQ0 = 2,
- RPRM_IVASEQ1 = 3,
- RPRM_L3BUS = 4,
- RPRM_ISS = 5,
- RPRM_FDIF = 6,
- RPRM_SL2IF = 7,
- RPRM_AUXCLK = 8,
- RPRM_REGULATOR = 9,
- RPRM_GPIO = 10,
- RPRM_SDMA = 11,
- RPRM_IPU = 12,
- RPRM_DSP = 13,
- RPRM_I2C = 14,
- RPRM_CAMERA = 15,
- RPRM_LED = 16,
- RPRM_MAX
-};
-
-enum {
- RPRM_CONNECT = 0,
- RPRM_DISCONNECT = 1,
- RPRM_REQ_ALLOC = 2,
- RPRM_REQ_FREE = 3,
- RPRM_REQ_CONSTRAINTS = 4,
- RPRM_REL_CONSTRAINTS = 5,
- RPRM_REQ_DATA = 6,
-};
-
-enum {
- RPRM_SCALE = 0x1,
- RPRM_LATENCY = 0x2,
- RPRM_BANDWIDTH = 0x4,
-};
-
-struct rprm_alloc_data {
- char res_name[16];
- char data[];
-} __packed;
-
-struct rprm_free_data {
- uint32_t res_id;
-} __packed;
-
-struct rprm_constraints_data {
- uint32_t mask;
- long frequency;
- long bandwidth;
- long latency;
-};
-
-struct rprm_constraint {
- uint32_t res_id;
- struct rprm_constraints_data data;
-} __packed;
-
-struct rprm_request {
- uint32_t acquire;
- char data[];
-} __packed;
-
-struct rprm_ack_data {
- uint32_t res_id;
- uint32_t base;
- char data[];
-} __packed;
-
-struct rprm_ack {
- uint32_t acquire;
- uint32_t ret;
- char data[];
-} __packed;
-
-struct rprm_proc {
- char name[16];
-} __packed;
-
-struct rprm_reqdata {
- uint32_t res_id;
- uint32_t type;
- char data[];
-} __packed;
-
-enum {
- RPRM_REQTYPE_MAXFREQ = 0
-};
-
-struct rprm_gpt {
- uint32_t id;
- uint32_t src_clk;
-};
-
-struct rprm_auxclk {
- uint32_t id;
- uint32_t clk_rate;
- uint32_t parent_src_clk;
- uint32_t parent_src_clk_rate;
-};
-
-struct rprm_regulator {
- uint32_t id;
- uint32_t min_uv;
- uint32_t max_uv;
-};
-
-struct rprm_gpio {
- uint32_t id;
-};
-
-/**
- * struct rprm_i2c - resource i2c
- * @id: i2c id
- *
- * meant to store the i2c related information
- */
-struct rprm_i2c {
- uint32_t id;
-};
-
-struct rprm_sdma {
- uint32_t num_chs;
- int32_t channels[MAX_NUM_SDMA_CHANNELS];
-};
-
-struct rprm_camera {
- uint32_t mode;
- uint32_t on;
-};
-
-struct rprm_led {
- uint32_t mode;
- uint32_t intensity;
-};
-
-struct rprm_freq {
- uint32_t value;
-};
-
-#endif /* _LINUX_RPMSG_RESMGR_H */