PM: Add callback functions for suspend & resume events

Two new APIs have been added to allow users to register
callback functions for notification of the suspend and
resume power events on the slave processor. Two events
are currently supported (IpcPower_Event_SUSPEND and
IpcPower_Event_RESUME) and allow users/drivers to take
action to save and restore their context on either side
of a slave processor suspend.

The new register/unregister callback APIs are:
- Int IpcPower_registerCallback(
         Int event, IpcPower_CallbackFuncPtr cb, Ptr data);
- Int IpcPower_unregisterCallback(
         Int event, IpcPower_CallbackFuncPtr cb);

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
PM: Execute PM suspend/resume callbacks in a task

A new PM task has been added in a regular SYS/BIOS environment
to execute the various user registered suspend & resume callback
functions. This allows the users to use semaphores in the callback
functions.

The new task is not required for SMP/BIOS because the SMP/BIOS
already executes all the Power Suspend functionality within a
dedicated task on each of the IPU cores. The BIOS Power_suspend
calls the callback functions in these task contexts.

NOTE: The callback functions are ONLY called by CORE0 in SMP/BIOS.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
PM: Add debug counters for different PM events

Three debug counters have been added to count the number of
transitions for Idle, Suspend and Resume power events. These
can be looked up using a memory inspection/dump tool.

Signed-off-by: Paul Hunt <hunt@ti.com>
Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
PM: Restore Tick timer context to support Device OFF mode

During OFF mode suspend, the states of most IP blocks in the SOC
are lost when the IP is powered off. Without software action to
restore the lost state, the modules will be left in their reset
states and will not be able to resume where they left off.

The GPTimer driver code on the host-side was saving and restoring
the context previously. This may not be guaranteed always, and so
it is better to save and restore the context on the BIOS-side.

This is done in conjunction with a new SMP/BIOS API to reprogram
the timer registers to their configured settings upon a resume
from hibernation or system suspend. The API is not yet available
in SYS/BIOS, and requires the host-side to preserve the context.

The IpcPower module retrieves and stores the BIOS Tick timer
handle (for using with new API) by checking against known BIOS
timer tick functions. Provision has also been added for
publishing a tick function (if different from standard-ones)
through an exported global variable. The image would abort if
no timer handle can be retrieved.

Signed-off-by: Paul Hunt <hunt@ti.com>
Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
HDMIWA: Publish custom tick function to IpcPower module

The IpcPower module needs a handle to the BIOS Tick timer
handle inorder to restore its context. The IpcPower module
retrieves this handle by searching for standard clock tick
functions among the configured timers on the target.

The HDMIWA uses a custom tick function and internally calls
the Clock_tick function, and so needs to publish this custom
function to the IpcPower module. This will allow the IpcPower
module to cross-check against this custom function as well
in finding the tick timer handle.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
DEH: Restore watchdog timer context to support Device OFF mode

During OFF mode suspend, the states of most IP blocks in the SOC
are lost when the IP is powered off. Without software action to
restore the lost state, the modules will be left in their reset
states and will not be able to resume where they left off.

The timers will need to be reinitialized after Device OFF. A new
Watchdog_restore function is registered as a resume callback hook
with the IpcPower module and reinitializes the watchdog timer by
reprogramming the timer registers. The timer registers are
reconfigured with the same set of values as during the initial
boot except for the counter register, which is programmed with
the regular watchdog timeout value.

Signed-off-by: Paul Hunt <hunt@ti.com>
Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Update to CGT 7.2.9 compiler for DSP

The compiler for DSP is updated to the latest version in the 7.2
release stream, 7.2.9. Only the README is updated as the compiler
version used is solely dictated by the C6000CGTOOLPATH environment
variable value.

The newer version is recommended to be used so that various compiler
fixes can be picked up. Please look up "DefectHistory.txt" file in
the compiler installation directory for a summary of fixes.

Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Update to newer BIOS 6.33.06.50 version

The build system is updated to use newer BIOS, BIOS 6.33.06.50.
Its recommended XDC (XDC 3.23.03.53) and IPC (IPC 1.24.02.27),
tools have already been adopted.

This newer version is the latest available on this particular
release stream, and is being adopted in preparation for doing
a native M4 build and enabling custom BIOS.libType while
building DSP. The new BIOS version also includes an important
fix for reducing the hibernation boot time for Core1.

The README has also been updated with the corresponding download
links.

Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Update to newer SMP/BIOS 1.00.00.25_eng

The build system is updated to use the current latest SMP-mode
BIOS version, SMP/BIOS 1.00.00.25_eng.

The newer SMP/BIOS version provides an important fix for a race
condition in the GateMutexPri module. This upgrade also picks up
the improvement in TimeStamp module since the last SMP/BIOS version.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
PM: Enable mbox interrupt in wugen for DSP before suspending

The DSP is not resuming properly for some reason with the latest
host-side code. The hard-reset is being effective only after the
DSP is specifically woken up. This is currently being achieved by
enabling the mailbox interrupt in the DSP Wakeup Generator (wugen)
before suspending. A mailbox message always triggers the resume on
the host processor side, and this message will wake up the DSP and
cause the resume to complete successfully.

Signed-off-by: Fernando Guzman Lugo <fernando.lugo@ti.com>
Configs: Skip timer frequency check configuration

The upgrade to new BIOS 6.33.06.50 adds a check for the timer
frequency by measuring it using a TimeStamp module whose own
timer is derived from the processor clock. The processor may
not always be clocked at OPP100, and so may be at a different
frequency than nominal one. The timer check for the BIOS tick
timer fails in this case, and throws an abort right during the
initial image boot.

This is avoided by programming a configuration option with the
dmTimer module to skip this check, and thereby have the image
booted always just as with the previous BIOS version.

Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Update the default installation folder

The default installation location for all the new tools
is /opt/ti (installed as root). The build system has been
updated to reflect this location as the default value for
the BIOSTOOLSROOT variable. This environment variable need
not be defined if all tools are installed using the default
location.

The only exception at present is the ARM Code Generation
Tools whose installation location is /opt/TI. This has been
corrected in newer versions of the ARM CGT, but for now
requires the installation location to be changed manually
to /opt/ti.

Signed-off-by: Suman Anna <s-anna@ti.com>
ResMgr: Add new API to request resource data

A new API, IpcResource_requestData, is added to request data
associated with a particular resource.

This API currently supports to request data about the maximum
frequency on a processor device. The checking for the proper
device type is performed on the host-side.

The interface is as follows:
  typedef enum {
      IpcResource_ReqDataType_MAX_FREQ
  } IpcResource_ReqDataType;

  Int IpcResource_requestData(IpcResource_Handle handle,
                              IpcResource_ResHandle resHandle,
                              IpcResource_ReqDataType dataType,
                              Void *data);

User is supposed to pass in a structure large enough (based on
dataType) to get back the requested information.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Paul Hunt <hunt@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Update to newer SMP/BIOS 1.00.00.27_eng

The build system is updated to use the current latest SMP-mode
BIOS version, SMP/BIOS 1.00.00.27_eng.

The newer SMP/BIOS version provides critical fixes for couple of
race conditions in the Task module. These improve the robustness
of SMP/BIOS scheduler tremendously.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
SrvMgr: Add service deletion notification support to omaprpc

Add a callback mechanism to omaprpc to notify clients when a
service instance will be deleted so that clients can teardown
cleanly even if the remote host did not follow the proper
shutdown sequence (for example when a crash occurs).

Signed-off-by: Alberto Aguirre <a-aguirre@ti.com>
Configs: Fix incorrect AMMU configuration of DSP small page #1

The new SYS/BIOS version 6.33.06.50 is incorrectly programming
the small page entry #1 of DSP AMMU to values that are pertinent
to ARM M3/M4 targets. The work around for this SYS/BIOS bug is to
reprogram this entry to valid values for DSP.

This change is added to both the OMAP4 and OMAP5 DSP AMMU config
files, and can be reverted once the bug is fixed in SYS/BIOS.

Signed-off-by: Alan DeMars <ademars@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Configs: Configure default heap size using XDC Memory module

The default heap size is defined using the BIOS.heapSize property
from BIOS module. This is changed to use the Memory.defaultHeapSize
property from the XDC Memory module.

This change removes any chance for a warning thrown by BIOS code
if both properties are set, or if a default Memory heap instance
is defined. The BIOS module is automatically configured to use
the Memory.defaultHeapSize internally, so this change is backward
compatible and removes possible warning messages due to external
default heap configurations.

Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Check for proper tool installations before build

The Makefile has been enhanced to verify that the requested tools
have been installed properly. This verification is done before
proceeding with any build or clean step.

Signed-off-by: Suman Anna <s-anna@ti.com>
Utils: Add a new Version module

A new module, Version, is added to retrieve and present the
version and tools information associated with the ELF base
images. The information is retrieved during link phase and
stored in a non-loadable section named ".version".

The version information comprises of the git tag, branch and
top most commit information (only when the image is built
from source code stored on a git repository).

The information is retrieved automatically when the module
is included in the base-image configuration file.
    var Version = xdc.useModule('ti.utils.Version');

The version information can be read using the standard ELF
utility, as
    readelf -p .version <base_image>

The version information can also be completely overridden by
the user to add his own generated details.
  Eg:
    Version.custom = "My custom version";

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Configs: Include the Version module

Pull in the Version module that automatically retrieves the
tools and source tree information for both sysbios-rpmsg and
the destination base image tree, and stores in a special
".version" memory section.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>