[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / family / common / ti81xx / ti81xxdsp / Dm8168DspPwr.c
1 /*
2 * @file Dm8168DspPwr.c
3 *
4 * @brief PwrMgr implementation for DM8168DSP.
5 *
6 * This module is responsible for handling power requests for
7 * the ProcMgr. The implementation is specific to DM8168DSP.
8 *
9 *
10 * ============================================================================
11 *
12 * Copyright (c) 2008-2012, Texas Instruments Incorporated
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
31 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
33 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
36 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
37 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
38 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
39 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 * Contact information for paper mail:
41 * Texas Instruments
42 * Post Office Box 655303
43 * Dallas, Texas 75265
44 * Contact information:
45 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
46 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
47 * ============================================================================
48 *
49 */
53 /* Standard headers */
54 #if defined(SYSLINK_BUILD_RTOS)
55 #include <xdc/std.h>
56 #include <string.h>
57 #include <xdc/runtime/Error.h>
58 #include <xdc/runtime/Memory.h>
59 #include <xdc/runtime/System.h>
60 #include <xdc/runtime/IGateProvider.h>
61 #include <ti/sysbios/gates/GateMutex.h>
62 #include <ti/syslink/utils/_Memory.h>
63 #include <ti/syslink/inc/Dm8168Clock.h>
64 #endif /* #if defined(SYSLINK_BUILD_RTOS) */
66 #if defined(SYSLINK_BUILD_HLOS)
67 #include <ti/syslink/Std.h>
68 /* OSAL & Utils headers */
69 #include <ti/syslink/utils/String.h>
70 #include <ti/syslink/utils/IGateProvider.h>
71 #include <ti/syslink/utils/GateMutex.h>
72 #include <ti/syslink/utils/Memory.h>
73 #include <_MultiProc.h>
74 #if defined(__KERNEL__)
75 #include <linux/string.h>
76 #else
77 #include <string.h>
78 #endif
79 #if defined (SYSLINK_BUILDOS_LINUX)
80 #include <ti/syslink/inc/knl/Linux/LinuxClock.h>
81 #endif /* #if defined(SYSLINK_BUILDOS_LINUX) */
82 #endif /* #if defined(SYSLINK_BUILD_HLOS) */
83 #include <ti/syslink/utils/Trace.h>
84 #include <Bitops.h>
86 /* Module level headers */
87 #include <ti/ipc/MultiProc.h>
88 #include <ti/syslink/inc/_MultiProc.h>
89 #include <ti/syslink/inc/knl/PwrDefs.h>
90 #include <ti/syslink/inc/knl/PwrMgr.h>
91 #include <ti/syslink/inc/knl/Dm8168DspPwr.h>
92 #include <ti/syslink/inc/knl/_Dm8168DspPwr.h>
93 #include <ti/syslink/inc/ClockOps.h>
97 #if defined (__cplusplus)
98 extern "C" {
99 #endif
102 /* =============================================================================
103 * Macros and types
104 * =============================================================================
105 */
106 /*!
107 * @brief DM8168DSP module and mmr addresses (physical)
108 */
109 #define PRCM_BASE_ADDR 0x48180000
110 #define PRCM_SIZE 0x00003000
111 #define PM_ACTIVE_PWRSTST 0x00000A04
112 #define CM_ACTIVE_GEM_CLKCTRL 0x00000420
115 #define CM_MMU_CLKSTCTRL 0x0000140C
116 #define CM_ALWON_MMUDATA_CLKCTRL 0x0000159C
117 #define CM_MMUCFG_CLKSTCTRL 0x00001410
118 #define CM_ALWON_MMUCFG_CLKCTRL 0x000015A8
121 #define RM_ACTIVE_RSTCTRL 0x00000A10
122 #define RM_ACTIVE_RSTST 0x00000A14
124 #define GEM_L2RAM_BASE_ADDR 0x40800000
125 #define GEM_L2RAM_SIZE 0x00040000
127 #define CTRL_MODULE_BASE_ADDR 0x48140000
128 #define CTRL_MODULE_SIZE 0x00020000
129 #define DSPMEM_SLEEP 0x00000650
131 #define DSP_IDLE_CFG 0x0000061c
133 #define REG(x) *((volatile UInt32 *) (x))
134 #define MEM(x) *((volatile UInt32 *) (x))
136 /*!
137 * @brief DM8168DSPPWR Module state object
138 */
139 typedef struct DM8168DSPPWR_ModuleObject_tag {
140 UInt32 configSize;
141 /*!< Size of configuration structure */
142 DM8168DSPPWR_Config cfg;
143 /*!< DM8168DSPPWR configuration structure */
144 DM8168DSPPWR_Config defCfg;
145 /*!< Default module configuration */
146 Bool isSetup;
147 /*!< Indicates whether the DM8168DSPPWR module is setup. */
148 DM8168DSPPWR_Handle pwrHandles [MultiProc_MAXPROCESSORS];
149 /*!< PwrMgr handle array. */
150 IGateProvider_Handle gateHandle;
151 /*!< Handle of gate to be used for local thread safety */
152 } DM8168DSPPWR_ModuleObject;
154 /*!
155 * @brief DM8168DSPPWR instance object.
156 */
157 struct DM8168DSPPWR_Object_tag {
158 DM8168DSPPWR_Params params;
159 /*!< Instance parameters (configuration values) */
160 UInt32 prcmVA;
161 /*!< Virtual address for prcm module */
162 UInt32 controlVA;
163 /*!< Virtual address for control module */
164 UInt32 l2baseVA;
165 /*!< Virtual address for control module */
166 Ptr dspClkHandle;
167 /*!< dsp clk handle */
168 Ptr dspMmuClkHandle;
169 /*!< dsp clk handle */
170 Ptr dspMmuCfgClkHandle;
171 /*!< dsp clk handle */
172 Ptr dspSpinlockHandle;
173 /*!< dsp Spinlock handle */
174 Ptr dspMailboxHandle;
175 /*!< dsp Mailbox handle */
176 #if defined(SYSLINK_VARIANT_TI814X) || defined(SYSLINK_VARIANT_TI811X)
177 Ptr dspTimerIclkHandle;
178 /*!< dsp Timer4 handle */
179 Ptr dspTimerFclkHandle;
180 /*!< dsp Timer4 handle */
181 #else
182 Ptr dspTimerIclkHandle1;
183 /*!< dsp Timer4 handle */
184 Ptr dspTimerFclkHandle1;
185 /*!< dsp Timer4 handle */
186 Ptr dspTimerIclkHandle2;
187 /*!< dsp Timer4 handle */
188 Ptr dspTimerFclkHandle2;
189 /*!< dsp Timer4 handle */
190 #endif
191 ClockOps_Handle clockHandle;
192 /*!< Pointer to the Clock object. */
194 };
196 /* Defines the DM8168DSPPWR object type. */
197 typedef struct DM8168DSPPWR_Object_tag DM8168DSPPWR_Object;
200 /* =============================================================================
201 * Globals
202 * =============================================================================
203 */
204 /*!
205 * @var DM8168DSPPWR_state
206 *
207 * @brief DM8168DSPPWR state object variable
208 */
209 #if !defined(SYSLINK_BUILD_DEBUG)
210 static
211 #endif /* if !defined(SYSLINK_BUILD_DEBUG) */
212 DM8168DSPPWR_ModuleObject DM8168DSPPWR_state =
213 {
214 .isSetup = FALSE,
215 .configSize = sizeof (DM8168DSPPWR_Config),
216 .defCfg.reserved = 0,
217 .gateHandle = NULL,
218 };
221 /* =============================================================================
222 * APIs directly called by applications
223 * =============================================================================
224 */
225 /*!
226 * @brief Function to get the default configuration for the DM8168DSPPWR
227 * module.
228 *
229 * This function can be called by the application to get their
230 * configuration parameter to DM8168DSPPWR_setup filled in by the
231 * DM8168DSPPWR module with the default parameters. If the user does
232 * not wish to make any change in the default parameters, this API
233 * is not required to be called.
234 *
235 * @param cfg Pointer to the DM8168DSPPWR module configuration
236 * structure in which the default config is to be
237 * returned.
238 *
239 * @sa DM8168DSPPWR_setup
240 */
241 Void
242 DM8168DSPPWR_getConfig (DM8168DSPPWR_Config * cfg)
243 {
244 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_getConfig", cfg);
246 GT_assert (curTrace, (cfg != NULL));
248 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
249 if (cfg == NULL) {
250 GT_setFailureReason (curTrace,
251 GT_4CLASS,
252 "DM8168DSPPWR_getConfig",
253 PWRMGR_E_INVALIDARG,
254 "Argument of type (DM8168DSPPWR_Config *) passed "
255 "is null!");
256 }
257 else {
258 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
259 memcpy (cfg,
260 &DM8168DSPPWR_state.defCfg,
261 sizeof (DM8168DSPPWR_Config));
262 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
263 }
264 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
266 GT_0trace (curTrace, GT_LEAVE, "DM8168DSPPWR_getConfig");
267 }
270 /*!
271 * @brief Function to setup the DM8168DSPPWR module.
272 *
273 * This function sets up the DM8168DSPPWR module. This function must
274 * be called before any other instance-level APIs can be invoked.
275 * Module-level configuration needs to be provided to this
276 * function. If the user wishes to change some specific config
277 * parameters, then DM8168DSPPWR_getConfig can be called to get the
278 * configuration filled with the default values. After this, only
279 * the required configuration values can be changed. If the user
280 * does not wish to make any change in the default parameters, the
281 * application can simply call DM8168DSPPWR_setup with NULL
282 * parameters. The default parameters would get automatically used.
283 *
284 * @param cfg Optional DM8168DSPPWR module configuration. If provided as
285 * NULL, default configuration is used.
286 *
287 * @sa DM8168DSPPWR_destroy
288 * GateMutex_create
289 */
290 Int
291 DM8168DSPPWR_setup (DM8168DSPPWR_Config * cfg)
292 {
293 Int status = PWRMGR_SUCCESS;
294 DM8168DSPPWR_Config tmpCfg;
295 Error_Block eb;
297 Error_init(&eb);
299 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_setup", cfg);
301 if (cfg == NULL) {
302 DM8168DSPPWR_getConfig (&tmpCfg);
303 cfg = &tmpCfg;
304 }
306 /* Create a default gate handle for local module protection. */
307 DM8168DSPPWR_state.gateHandle = (IGateProvider_Handle)
308 GateMutex_create ((GateMutex_Params*)NULL, &eb);
309 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
310 if (DM8168DSPPWR_state.gateHandle == NULL) {
311 /*! @retval PWRMGR_E_FAIL Failed to create GateMutex! */
312 status = PWRMGR_E_FAIL;
313 GT_setFailureReason (curTrace,
314 GT_4CLASS,
315 "DM8168DSPPWR_setup",
316 status,
317 "Failed to create GateMutex!");
318 }
319 else {
320 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
321 /* Copy the user provided values into the state object. */
322 memcpy (&DM8168DSPPWR_state.cfg,
323 cfg,
324 sizeof (DM8168DSPPWR_Config));
326 /* Initialize the name to handles mapping array. */
327 memset (&DM8168DSPPWR_state.pwrHandles,
328 0,
329 (sizeof (DM8168DSPPWR_Handle) * MultiProc_MAXPROCESSORS));
330 DM8168DSPPWR_state.isSetup = TRUE;
331 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
332 }
333 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
335 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_setup", status);
337 /*! @retval PWRMGR_SUCCESS Operation successful */
338 return (status);
339 }
342 /*!
343 * @brief Function to destroy the DM8168DSPPWR module.
344 *
345 * Once this function is called, other DM8168DSPPWR module APIs, except
346 * for the DM8168DSPPWR_getConfig API cannot be called anymore.
347 *
348 * @sa DM8168DSPPWR_setup
349 * GateMutex_delete
350 */
351 Int
352 DM8168DSPPWR_destroy (Void)
353 {
354 Int status = PWRMGR_SUCCESS;
355 UInt16 i;
357 GT_0trace (curTrace, GT_ENTER, "DM8168DSPPWR_destroy");
359 /* Check if any DM8168DSPPWR instances have not been deleted so far. If not,
360 * delete them.
361 */
362 for (i = 0 ; i < MultiProc_MAXPROCESSORS ; i++) {
363 GT_assert (curTrace, (DM8168DSPPWR_state.pwrHandles [i] == NULL));
364 if (DM8168DSPPWR_state.pwrHandles [i] != NULL) {
365 DM8168DSPPWR_delete (&(DM8168DSPPWR_state.pwrHandles [i]));
366 }
367 }
369 if (DM8168DSPPWR_state.gateHandle != NULL) {
370 GateMutex_delete ((GateMutex_Handle *)
371 &(DM8168DSPPWR_state.gateHandle));
372 }
374 DM8168DSPPWR_state.isSetup = FALSE;
376 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_destroy", status);
378 /*! @retval PWRMGR_SUCCESS Operation successful */
379 return (status);
380 }
383 /*!
384 * @brief Function to initialize the parameters for this PwrMgr instance.
385 *
386 * @param params Configuration parameters.
387 *
388 * @sa DM8168DSPPWR_create
389 */
390 Void
391 DM8168DSPPWR_Params_init (DM8168DSPPWR_Params * params)
392 {
393 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_Params_init",params);
395 GT_assert (curTrace, (params != NULL));
397 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
398 if (params == NULL) {
399 GT_setFailureReason (curTrace,
400 GT_4CLASS,
401 "DM8168DSPPWR_Params_init",
402 PWRMGR_E_INVALIDARG,
403 "Argument of type (DM8168DSPPWR_Params *) "
404 "passed is null!");
405 }
406 else {
407 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
408 /* Return updated DM8168DSPPWR instance specific parameters. */
409 params->reserved = 0;
410 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
411 }
412 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
414 GT_0trace (curTrace, GT_LEAVE, "DM8168DSPPWR_Params_init");
415 }
417 /*!
418 * @brief Function to create an instance of this PwrMgr.
419 *
420 * @param procId Processor ID addressed by this PwrMgr instance.
421 * @param params Configuration parameters.
422 *
423 * @sa DM8168DSPPWR_delete
424 */
425 DM8168DSPPWR_Handle
426 DM8168DSPPWR_create ( UInt16 procId,
427 const DM8168DSPPWR_Params * params)
428 {
429 Int status = PWRMGR_SUCCESS;
430 PwrMgr_Object * handle = NULL;
431 IArg key;
433 GT_2trace (curTrace, GT_ENTER, "DM8168DSPPWR_create", procId, params);
435 GT_assert (curTrace, IS_VALID_PROCID (procId));
436 GT_assert (curTrace, (params != NULL));
438 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
439 if (!IS_VALID_PROCID (procId)) {
440 status = PWRMGR_E_INVALIDARG;
441 GT_setFailureReason (curTrace,
442 GT_4CLASS,
443 "DM8168DSPPWR_create",
444 status,
445 "Invalid procId specified");
446 }
447 else if (params == NULL) {
448 status = PWRMGR_E_INVALIDARG;
449 GT_setFailureReason (curTrace,
450 GT_4CLASS,
451 "DM8168DSPPWR_create",
452 status,
453 "params passed is null!");
454 }
455 else {
456 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
457 /* Enter critical section protection. */
458 key = IGateProvider_enter (DM8168DSPPWR_state.gateHandle);
459 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
460 /* Check if the PwrMgr already exists for specified procId. */
461 if (DM8168DSPPWR_state.pwrHandles [procId] != NULL) {
462 status = PWRMGR_E_ALREADYEXIST;
463 GT_setFailureReason (curTrace,
464 GT_4CLASS,
465 "DM8168DSPPWR_create",
466 status,
467 "PwrMgr already exists for specified procId!");
468 }
469 else {
470 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
471 /* Allocate memory for the handle */
472 handle = (PwrMgr_Object *) Memory_calloc (NULL,
473 sizeof (PwrMgr_Object),
474 0,
475 NULL);
476 if (handle == NULL) {
477 status = PWRMGR_E_MEMORY;
478 GT_setFailureReason (curTrace,
479 GT_4CLASS,
480 "DM8168DSPPWR_create",
481 status,
482 "Memory allocation failed for handle!");
483 }
484 else {
485 /* Populate the handle fields */
486 handle->pwrFxnTable.attach = &DM8168DSPPWR_attach;
487 handle->pwrFxnTable.detach = &DM8168DSPPWR_detach;
488 handle->pwrFxnTable.on = &DM8168DSPPWR_on;
489 handle->pwrFxnTable.off = &DM8168DSPPWR_off;
490 /* TBD: Other functions */
492 /* Allocate memory for the DM8168DSPPWR handle */
493 handle->object = Memory_calloc (NULL,
494 sizeof (DM8168DSPPWR_Object),
495 0,
496 NULL);
497 if (handle->object == NULL) {
498 status = PWRMGR_E_MEMORY;
499 GT_setFailureReason (curTrace,
500 GT_4CLASS,
501 "DM8168DSPPWR_create",
502 status,
503 "Memory allocation failed for handle!");
504 }
505 else {
506 #if defined (SYSLINK_BUILDOS_LINUX)
507 ((DM8168DSPPWR_Object *)(handle->object))->clockHandle
508 = (ClockOps_Handle) LinuxClock_create();
509 #endif/* #if defined (SYSLINK_BUILDOS_LINUX) */
510 #if defined (SYSLINK_BUILD_RTOS)
511 ((DM8168DSPPWR_Object *)(handle->object))->clockHandle
512 = (ClockOps_Handle) DM8168CLOCK_create();
513 #endif/* #if defined (SYSLINK_BUILD_RTOS) */
514 handle->procId = procId;
515 DM8168DSPPWR_state.pwrHandles [procId] =
516 (DM8168DSPPWR_Handle) handle;
517 }
518 }
519 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
520 }
521 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
522 /* Leave critical section protection. */
523 IGateProvider_leave (DM8168DSPPWR_state.gateHandle, key);
524 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
525 }
526 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
528 if (status < 0) {
529 if (handle != NULL) {
530 if (handle->object != NULL) {
531 Memory_free (NULL, handle->object, sizeof (DM8168DSPPWR_Object));
532 }
533 Memory_free (NULL, handle, sizeof (PwrMgr_Object));
534 }
535 /*! @retval NULL Function failed */
536 handle = NULL;
537 }
539 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_create", handle);
541 /*! @retval Valid-Handle Operation successful */
542 return (DM8168DSPPWR_Handle) handle;
543 }
546 /*!
547 * @brief Function to delete an instance of this PwrMgr.
548 *
549 * The user provided pointer to the handle is reset after
550 * successful completion of this function.
551 *
552 * @param handlePtr Pointer to Handle to the PwrMgr instance
553 *
554 * @sa DM8168DSPPWR_create
555 */
556 Int
557 DM8168DSPPWR_delete (DM8168DSPPWR_Handle * handlePtr)
558 {
559 Int status = PWRMGR_SUCCESS;
560 DM8168DSPPWR_Object * object = NULL;
561 PwrMgr_Object * handle;
562 IArg key;
564 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_delete", handlePtr);
566 GT_assert (curTrace, (handlePtr != NULL));
567 GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != NULL)));
569 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
570 if (handlePtr == NULL) {
571 /*! @retval PWRMGR_E_INVALIDARG Invalid NULL handlePtr specified*/
572 status = PWRMGR_E_INVALIDARG;
573 GT_setFailureReason (curTrace,
574 GT_4CLASS,
575 "DM8168DSPPWR_delete",
576 status,
577 "Invalid NULL handlePtr specified");
578 }
579 else if (*handlePtr == NULL) {
580 /*! @retval PWRMGR_E_HANDLE Invalid NULL *handlePtr specified */
581 status = PWRMGR_E_HANDLE;
582 GT_setFailureReason (curTrace,
583 GT_4CLASS,
584 "DM8168DSPPWR_delete",
585 status,
586 "Invalid NULL *handlePtr specified");
587 }
588 else {
589 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
590 handle = (PwrMgr_Object *) (*handlePtr);
591 /* Enter critical section protection. */
592 key = IGateProvider_enter (DM8168DSPPWR_state.gateHandle);
594 /* Reset handle in PwrMgr handle array. */
595 GT_assert (curTrace, IS_VALID_PROCID (handle->procId));
596 DM8168DSPPWR_state.pwrHandles [handle->procId] = NULL;
598 object = (DM8168DSPPWR_Object *) handle->object;
599 /* Free memory used for the DM8168DSPPWR object. */
600 if (handle->object != NULL) {
601 /* Free memory used for the clock handle */
602 #if defined (SYSLINK_BUILDOS_LINUX)
603 LinuxClock_delete(((DM8168DSPPWR_Object *)(handle->object))->clockHandle);
604 #endif /* #if defined (SYSLINK_BUILDOS_LINUX) */
605 #if defined (SYSLINK_BUILD_RTOS)
606 DM8168CLOCK_delete(((DM8168DSPPWR_Object *)(handle->object))->clockHandle);
607 #endif /* #if defined (SYSLINK_BUILD_RTOS) */
608 Memory_free (NULL,
609 object,
610 sizeof (DM8168DSPPWR_Object));
611 handle->object = NULL;
612 }
614 /* Free memory used for the PwrMgr object. */
615 Memory_free (NULL, handle, sizeof (PwrMgr_Object));
616 *handlePtr = NULL;
618 /* Leave critical section protection. */
619 IGateProvider_leave (DM8168DSPPWR_state.gateHandle, key);
620 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
621 }
622 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
624 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_delete", status);
626 /*! @retval PWRMGR_SUCCESS Operation successful */
627 return (status);
628 }
631 /*!
632 * @brief Function to open a handle to an instance of this PwrMgr. This
633 * function is called when access to the PwrMgr is required from
634 * a different process.
635 *
636 * @param handlePtr Handle to the PwrMgr instance
637 * @param procId Processor ID addressed by this PwrMgr instance.
638 *
639 * @sa DM8168DSPPWR_close
640 */
641 Int
642 DM8168DSPPWR_open (DM8168DSPPWR_Handle * handlePtr, UInt16 procId)
643 {
644 Int status = PWRMGR_SUCCESS;
646 GT_2trace (curTrace, GT_ENTER, "DM8168DSPPWR_open", handlePtr, procId);
648 GT_assert (curTrace, (handlePtr != NULL));
649 GT_assert (curTrace, IS_VALID_PROCID (procId));
651 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
652 if (handlePtr == NULL) {
653 /*! @retval PWRMGR_E_HANDLE Invalid NULL handlePtr specified */
654 status = PWRMGR_E_HANDLE;
655 GT_setFailureReason (curTrace,
656 GT_4CLASS,
657 "DM8168DSPPWR_open",
658 status,
659 "Invalid NULL handlePtr specified");
660 }
661 else if (!IS_VALID_PROCID (procId)) {
662 /*! @retval PWRMGR_E_INVALIDARG Invalid procId specified */
663 status = PWRMGR_E_INVALIDARG;
664 GT_setFailureReason (curTrace,
665 GT_4CLASS,
666 "DM8168DSPPWR_open",
667 status,
668 "Invalid procId specified");
669 }
670 else {
671 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
672 /* Initialize return parameter handle. */
673 *handlePtr = NULL;
675 /* Check if the PwrMgr exists and return the handle if found. */
676 if (DM8168DSPPWR_state.pwrHandles [procId] == NULL) {
677 /*! @retval PWRMGR_E_NOTFOUND Specified instance not found */
678 status = PWRMGR_E_NOTFOUND;
679 GT_setFailureReason (curTrace,
680 GT_4CLASS,
681 "DM8168DSPPWR_open",
682 status,
683 "Specified DM8168DSPPWR instance does not exist!");
684 }
685 else {
686 *handlePtr = DM8168DSPPWR_state.pwrHandles [procId];
687 }
688 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
689 }
690 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
692 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_open", status);
694 /*! @retval PWRMGR_SUCCESS Operation successful */
695 return status;
696 }
699 /*!
700 * @brief Function to close a handle to an instance of this PwrMgr.
701 *
702 * @param handlePtr Pointer to Handle to the PwrMgr instance
703 *
704 * @sa DM8168DSPPWR_open
705 */
706 Int
707 DM8168DSPPWR_close (DM8168DSPPWR_Handle * handlePtr)
708 {
709 Int status = PWRMGR_SUCCESS;
711 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_close", handlePtr);
713 GT_assert (curTrace, (handlePtr != NULL));
714 GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != NULL)));
716 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
717 if (handlePtr == NULL) {
718 /*! @retval PWRMGR_E_INVALIDARG Invalid NULL handlePtr pointer
719 specified*/
720 status = PWRMGR_E_INVALIDARG;
721 GT_setFailureReason (curTrace,
722 GT_4CLASS,
723 "DM8168DSPPWR_close",
724 status,
725 "Invalid NULL handlePtr pointer specified");
726 }
727 else if (*handlePtr == NULL) {
728 /*! @retval PWRMGR_E_HANDLE Invalid NULL *handlePtr specified */
729 status = PWRMGR_E_HANDLE;
730 GT_setFailureReason (curTrace,
731 GT_4CLASS,
732 "DM8168DSPPWR_close",
733 status,
734 "Invalid NULL *handlePtr specified");
735 }
736 else {
737 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
738 /* Nothing to be done for close. */
739 *handlePtr = NULL;
740 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
741 }
742 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
744 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_close", status);
746 /*! @retval PWRMGR_SUCCESS Operation successful */
747 return status;
748 }
751 /* =============================================================================
752 * APIs called by PwrMgr module (part of function table interface)
753 * =============================================================================
754 */
755 /*!
756 * @brief Function to attach to the PwrMgr.
757 *
758 * @param handle Handle to the PwrMgr instance
759 * @param params Attach parameters
760 *
761 * @sa DM8168DSPPWR_detach
762 */
763 Int
764 DM8168DSPPWR_attach (PwrMgr_Handle handle, PwrMgr_AttachParams * params)
765 {
766 Int status = PWRMGR_SUCCESS;
767 PwrMgr_Object * pwrMgrHandle = (PwrMgr_Object *) handle;
768 DM8168DSPPWR_Object * object = NULL;
769 Memory_MapInfo mapInfo;
770 /* Mapping for prcm base is done in DM8168VIDEOM3_phyShmemInit */
772 GT_2trace (curTrace, GT_ENTER, "DM8168DSPPWR_attach", handle, params);
774 GT_assert (curTrace, (handle != NULL));
775 GT_assert (curTrace, (params != NULL));
777 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
778 if (handle == NULL) {
779 /*! @retval PWRMGR_E_HANDLE Invalid argument */
780 status = PWRMGR_E_HANDLE;
781 GT_setFailureReason (curTrace,
782 GT_4CLASS,
783 "DM8168DSPPWR_attach",
784 status,
785 "Invalid handle specified");
786 }
787 else {
788 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
789 object = (DM8168DSPPWR_Object *) pwrMgrHandle->object;
790 GT_assert (curTrace, (object != NULL));
791 /* Map and get the virtual address for system control module */
792 mapInfo.src = PRCM_BASE_ADDR;
793 mapInfo.size = PRCM_SIZE;
794 mapInfo.isCached = FALSE;
795 status = Memory_map (&mapInfo);
796 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
797 if (status < 0) {
798 status = DM8168DSPPWR_E_FAIL;
799 GT_setFailureReason (curTrace,
800 GT_4CLASS,
801 "DM8168DSPPWR_attach",
802 status,
803 "Failure in mapping prcm module");
804 }
805 else {
806 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
807 object->prcmVA = mapInfo.dst;
809 /* Map and get the virtual address for system control module */
810 mapInfo.src = CTRL_MODULE_BASE_ADDR;
811 mapInfo.size = CTRL_MODULE_SIZE;
812 mapInfo.isCached = FALSE;
813 status = Memory_map (&mapInfo);
814 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
815 if (status < 0) {
816 status = DM8168DSPPWR_E_FAIL;
817 GT_setFailureReason (curTrace,
818 GT_4CLASS,
819 "DM8168DSPPWR_attach",
820 status,
821 "Failure in mapping prcm module");
822 }
823 else {
824 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
825 object->controlVA = mapInfo.dst;
827 /* Map and get the virtual address for system l2 ram */
828 mapInfo.src = GEM_L2RAM_BASE_ADDR;
829 mapInfo.size = GEM_L2RAM_SIZE;
830 mapInfo.isCached = FALSE;
831 status = Memory_map (&mapInfo);
832 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
833 if (status < 0) {
834 status = DM8168DSPPWR_E_FAIL;
835 GT_setFailureReason (curTrace,
836 GT_4CLASS,
837 "DM8168DSPPWR_attach",
838 status,
839 "Failure in mapping prcm module");
840 }
841 else {
842 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
843 object->l2baseVA = mapInfo.dst;
844 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
845 }
846 }
847 }
848 }
849 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
850 /*! @retval PWRMGR_SUCCESS Operation successful */
851 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_attach", status);
852 return (status);
854 }
857 /*!
858 * @brief Function to detach from the PwrMgr.
859 *
860 * @param handle Handle to the PwrMgr instance
861 *
862 * @sa DM8168DSPPWR_attach
863 */
864 Int
865 DM8168DSPPWR_detach (PwrMgr_Handle handle)
866 {
868 Int status = PWRMGR_SUCCESS;
869 PwrMgr_Object * pwrMgrHandle = (PwrMgr_Object *) handle;
870 DM8168DSPPWR_Object * object = NULL;
871 Memory_UnmapInfo unmapInfo;
874 /* Mapping for prcm base is done in DM8168VIDEOM3_phyShmemInit */
876 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_detach", handle);
878 GT_assert (curTrace, (handle != NULL));
880 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
881 if (handle == NULL) {
882 /*! @retval PWRMGR_E_HANDLE Invalid argument */
883 status = PWRMGR_E_HANDLE;
884 GT_setFailureReason (curTrace,
885 GT_4CLASS,
886 "DM8168DSPPWR_detach",
887 status,
888 "Invalid handle specified");
889 }
890 else {
891 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
892 object = (DM8168DSPPWR_Object *) pwrMgrHandle->object;
893 GT_assert (curTrace, (object != NULL));
895 if (object->controlVA != 0x0) {
896 /* Unmap the virtual address for control module */
897 unmapInfo.addr = object->controlVA;
898 unmapInfo.size = CTRL_MODULE_SIZE;
899 unmapInfo.isCached = FALSE;
900 if (unmapInfo.addr != 0) {
901 status = Memory_unmap (&unmapInfo);
902 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
903 if (status < 0) {
904 status = DM8168DSPPWR_E_FAIL;
905 GT_setFailureReason (curTrace,
906 GT_4CLASS,
907 "DM8168DSPPWR_detach",
908 status,
909 "Failure in mapping prcm module");
910 }
911 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
912 }
913 }
914 if (object->prcmVA != 0x0) {
915 /* Unmap the virtual address for prcm module */
916 unmapInfo.addr = object->prcmVA;
917 unmapInfo.size = PRCM_SIZE;
918 unmapInfo.isCached = FALSE;
919 if (unmapInfo.addr != 0) {
920 status = Memory_unmap (&unmapInfo);
921 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
922 if (status < 0) {
923 status = DM8168DSPPWR_E_FAIL;
924 GT_setFailureReason (curTrace,
925 GT_4CLASS,
926 "DM8168DSPPWR_detach",
927 status,
928 "Failure in mapping prcm module");
929 }
930 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
931 }
932 }
933 if (object->l2baseVA != 0x0) {
934 /* Unmap the virtual address for prcm module */
935 unmapInfo.addr = object->l2baseVA;
936 unmapInfo.size = GEM_L2RAM_SIZE;
937 unmapInfo.isCached = FALSE;
938 if (unmapInfo.addr != 0) {
939 status = Memory_unmap (&unmapInfo);
940 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
941 if (status < 0) {
942 status = DM8168DSPPWR_E_FAIL;
943 GT_setFailureReason (curTrace,
944 GT_4CLASS,
945 "DM8168DSPPWR_detach",
946 status,
947 "Failure in mapping prcm module");
948 }
949 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
950 }
951 }
952 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
953 }
954 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
956 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_detach", status);
957 /*! @retval PWRMGR_SUCCESS Operation successful */
958 return (status);
960 }
963 /*!
964 * @brief Function to power on the slave processor.
965 *
966 * Power on the IVA subsystem, hold the DSP and SEQ in reset, and
967 * release IVA2_RST. This is a hostile reset of the IVA. If the IVA
968 * is already powered on, then it must be powered off in order to
969 * terminate all current activity and initiate a power-on-reset
970 * transition to bring the IVA to a know good state.
971 *
972 * @param handle Handle to the PwrMgr instance
973 *
974 * @sa DM8168DSPPWR_off
975 */
976 Int
977 DM8168DSPPWR_on (PwrMgr_Handle handle)
978 {
980 Int status = PWRMGR_SUCCESS ;
982 #if !defined (NETRA_SIMULATOR) /* Commented for simulator */
983 PwrMgr_Object * pwrMgrHandle = (PwrMgr_Object *) handle;
984 DM8168DSPPWR_Object * object = NULL;
986 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_on", handle);
988 GT_assert (curTrace, (handle != NULL));
990 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
991 if (handle == NULL) {
992 /*! @retval PWRMGR_E_HANDLE Invalid argument */
993 status = PWRMGR_E_HANDLE;
994 GT_setFailureReason (curTrace,
995 GT_4CLASS,
996 "DM8168DSPPWR_on",
997 status,
998 "Invalid handle specified");
999 }
1000 else {
1001 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
1002 object = (DM8168DSPPWR_Object *) pwrMgrHandle->object;
1003 GT_assert (curTrace, (object != NULL));
1005 /* Enable spinlocks, mailbox and timers before powering on dsp */
1006 object->dspSpinlockHandle = ClockOps_get(object->clockHandle, "spinbox_ick");
1008 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1009 GT_assert (curTrace, (object->dspSpinlockHandle != NULL));
1010 status = ClockOps_enable(object->clockHandle, object->dspSpinlockHandle);
1011 if (status < 0) {
1012 /*! @retval PWRMGR_E_HANDLE Invalid argument */
1013 status = PWRMGR_E_FAIL;
1014 GT_setFailureReason (curTrace,
1015 GT_4CLASS,
1016 "DM8168DSPPWR_on",
1017 status,
1018 "ClockOps_enable failed");
1019 }
1020 object->dspMailboxHandle = ClockOps_get(object->clockHandle, "mailbox_ick");
1021 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1022 GT_assert (curTrace, (object->dspMailboxHandle != NULL));
1023 status = ClockOps_enable(object->clockHandle, object->dspMailboxHandle);
1024 GT_assert (curTrace, (status >= 0));
1026 #if defined(SYSLINK_VARIANT_TI814X) || defined(SYSLINK_VARIANT_TI811X)
1027 /* GP timer4 is actually timer 3 for bios it will be enabled from bios
1028 * Here we are enabling the gptimer 4 clk module
1029 */
1031 object->dspTimerIclkHandle = ClockOps_get(object->clockHandle, "gpt4_ick");
1032 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1033 GT_assert (curTrace, (object->dspTimerIclkHandle != NULL));
1034 status = ClockOps_enable(object->clockHandle, object->dspTimerIclkHandle);
1035 GT_assert (curTrace, (status >= 0));
1037 object->dspTimerFclkHandle = ClockOps_get(object->clockHandle, "gpt4_fck");
1038 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1039 GT_assert (curTrace, (object->dspTimerFclkHandle != NULL));
1040 status = ClockOps_enable(object->clockHandle, object->dspTimerFclkHandle);
1041 GT_assert (curTrace, (status >= 0));
1042 #else
1043 /* GP timer3 is actually timer 2 for bios it will be enabled from bios
1044 * Here we are enabling the gptimer 3 clk module
1045 */
1046 /*
1047 * TISB update: I don't know what the above comment is trying to say.
1048 * We enable both gpt3 and gpt4 here for Netra because "older" BIOS
1049 * needs gpt3 and "newer" BIOS needs gpt4.
1050 */
1052 object->dspTimerIclkHandle1 = ClockOps_get(object->clockHandle, "gpt3_ick");
1053 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1054 GT_assert (curTrace, (object->dspTimerIclkHandle1 != NULL));
1055 status = ClockOps_enable(object->clockHandle, object->dspTimerIclkHandle1);
1056 GT_assert (curTrace, (status >= 0));
1058 object->dspTimerFclkHandle1 = ClockOps_get(object->clockHandle, "gpt3_fck");
1059 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1060 GT_assert (curTrace, (object->dspTimerFclkHandle1 != NULL));
1061 status = ClockOps_enable(object->clockHandle, object->dspTimerFclkHandle1);
1062 GT_assert (curTrace, (status >= 0));
1064 object->dspTimerIclkHandle2 = ClockOps_get(object->clockHandle, "gpt4_ick");
1065 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1066 GT_assert (curTrace, (object->dspTimerIclkHandle2 != NULL));
1067 status = ClockOps_enable(object->clockHandle, object->dspTimerIclkHandle2);
1068 GT_assert (curTrace, (status >= 0));
1070 object->dspTimerFclkHandle2 = ClockOps_get(object->clockHandle, "gpt4_fck");
1071 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1072 GT_assert (curTrace, (object->dspTimerFclkHandle2 != NULL));
1073 status = ClockOps_enable(object->clockHandle, object->dspTimerFclkHandle2);
1074 GT_assert (curTrace, (status >= 0));
1076 /* Bring GEM L2RAM out of Power down Mode */
1077 REG(object->controlVA + DSPMEM_SLEEP) = 0x0;
1078 #endif
1080 /* Enable Dsp MMU clocks */
1082 object->dspMmuCfgClkHandle = ClockOps_get(object->clockHandle, "mmu_cfg_ick");
1083 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1084 GT_assert (curTrace, (object->dspMmuCfgClkHandle != NULL));
1085 status = ClockOps_enable(object->clockHandle, object->dspMmuCfgClkHandle);
1086 GT_assert (curTrace, (status >= 0));
1088 object->dspMmuClkHandle = ClockOps_get(object->clockHandle, "mmu_ick");
1089 /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
1090 GT_assert (curTrace, (object->dspMmuClkHandle != NULL));
1091 status = ClockOps_enable(object->clockHandle, object->dspMmuClkHandle);
1092 GT_assert (curTrace, (status >= 0));
1093 object->dspClkHandle = ClockOps_get(object->clockHandle, "gem_ick");
1095 GT_assert (curTrace, (object->dspClkHandle != NULL));
1096 status = ClockOps_enable(object->clockHandle, object->dspClkHandle);
1097 GT_assert (curTrace, (status >= 0));
1099 /* Warm Reset to access Internal RAM of DSP - to access internal RAM */
1100 // REG((object->prcmVA) + RM_ACTIVE_RSTCTRL) = 0x01;
1102 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
1103 }
1104 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
1105 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_on", status);
1106 /*! @retval PWRMGR_SUCCESS Operation successful */
1107 #endif /*#if !defined (NETRA_SIMULATOR)*/
1108 return (status);
1109 }
1112 /*!
1113 * @brief Function to power off the slave processor.
1114 *
1115 * Turn the IVA power domain off. To ensure a clean power-off
1116 * transition, the IVA subsystem must first be turned on so that
1117 * the DSP can initiate an autonomous power-off transition.
1118 *
1119 * @param handle Handle to the PwrMgr instance
1120 * @param force Indicates whether power-off is to be forced
1121 *
1122 * @sa DM8168DSPPWR_on
1123 */
1124 Int
1125 DM8168DSPPWR_off (PwrMgr_Handle handle, Bool force)
1126 {
1127 Int status = PWRMGR_SUCCESS ;
1128 PwrMgr_Object * pwrMgrHandle = (PwrMgr_Object *) handle;
1129 DM8168DSPPWR_Object * object = NULL;
1131 GT_1trace (curTrace, GT_ENTER, "DM8168DSPPWR_off", handle);
1133 GT_assert (curTrace, (handle != NULL));
1135 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
1136 if (handle == NULL) {
1137 /*! @retval PWRMGR_E_HANDLE Invalid argument */
1138 status = PWRMGR_E_HANDLE;
1139 GT_setFailureReason (curTrace,
1140 GT_4CLASS,
1141 "DM8168DSPPWR_off",
1142 status,
1143 "Invalid handle specified");
1144 }
1145 else {
1146 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
1147 object = (DM8168DSPPWR_Object *) pwrMgrHandle->object;
1148 GT_assert (curTrace, (object != NULL));
1151 /* Disable Dsp mmu clocks */
1152 if(object->dspMmuClkHandle) {
1153 ClockOps_disable(object->clockHandle, object->dspMmuClkHandle);
1154 ClockOps_put(object->clockHandle, object->dspMmuClkHandle);
1155 }
1156 /* Disable Dsp mmu cfg clocks */
1157 if(object->dspMmuCfgClkHandle) {
1158 ClockOps_disable(object->clockHandle, object->dspMmuCfgClkHandle);
1159 ClockOps_put(object->clockHandle, object->dspMmuCfgClkHandle);
1160 }
1162 /* assert DSP standby, removed to fix DSP internal memory load, -rams */
1163 // REG(object->controlVA + DSP_IDLE_CFG) |= 0x8000;
1165 /* Disable GEM clocks */
1166 if(object->dspClkHandle) {
1167 ClockOps_disable(object->clockHandle, object->dspClkHandle);
1168 ClockOps_put(object->clockHandle, object->dspClkHandle);
1169 }
1171 #if defined(SYSLINK_VARIANT_TI814X) || defined(SYSLINK_VARIANT_TI811X)
1172 /* Disable Timer4 functional clocks */
1173 if(object->dspTimerFclkHandle) {
1174 ClockOps_disable(object->clockHandle, object->dspTimerFclkHandle);
1175 ClockOps_put(object->clockHandle, object->dspTimerFclkHandle);
1176 }
1177 /* Disable Timer4 interface clocks */
1178 if(object->dspTimerIclkHandle) {
1179 ClockOps_disable(object->clockHandle, object->dspTimerIclkHandle);
1180 ClockOps_put(object->clockHandle, object->dspTimerIclkHandle);
1181 }
1182 #else
1183 /* Bring GEM L2RAM in to Power down Mode */
1184 REG(object->controlVA + DSPMEM_SLEEP) = 0x04;
1186 /* Disable Timer4 functional clocks */
1187 if(object->dspTimerFclkHandle2) {
1188 ClockOps_disable(object->clockHandle, object->dspTimerFclkHandle2);
1189 ClockOps_put(object->clockHandle, object->dspTimerFclkHandle2);
1190 }
1191 /* Disable Timer4 interface clocks */
1192 if(object->dspTimerIclkHandle2) {
1193 ClockOps_disable(object->clockHandle, object->dspTimerIclkHandle2);
1194 ClockOps_put(object->clockHandle, object->dspTimerIclkHandle2);
1195 }
1196 /* Disable Timer3 functional clocks */
1197 if(object->dspTimerFclkHandle1) {
1198 ClockOps_disable(object->clockHandle, object->dspTimerFclkHandle1);
1199 ClockOps_put(object->clockHandle, object->dspTimerFclkHandle1);
1200 }
1201 /* Disable Timer3 interface clocks */
1202 if(object->dspTimerIclkHandle1) {
1203 ClockOps_disable(object->clockHandle, object->dspTimerIclkHandle1);
1204 ClockOps_put(object->clockHandle, object->dspTimerIclkHandle1);
1205 }
1206 #endif
1207 /* Disable Mailbox clocks */
1208 if(object->dspMailboxHandle) {
1209 ClockOps_disable(object->clockHandle, object->dspMailboxHandle);
1210 ClockOps_put(object->clockHandle, object->dspMailboxHandle);
1211 }
1212 /* Disable Spinlock clocks */
1213 if(object->dspSpinlockHandle) {
1214 ClockOps_disable(object->clockHandle, object->dspSpinlockHandle);
1215 ClockOps_put(object->clockHandle, object->dspSpinlockHandle);
1216 }
1218 #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
1219 }
1220 #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
1221 GT_1trace (curTrace, GT_LEAVE, "DM8168DSPPWR_off", status);
1222 /*! @retval PWRMGR_SUCCESS Operation successful */
1223 return (status);
1224 }
1227 #if defined (__cplusplus)
1228 }
1229 #endif /* defined (__cplusplus) */