ResMgr: Add i2c resource

Add i2c resource to IpcResource module, so that Ducati can
request it.

Signed-off-by: Fernando Guzman Lugo <fernando.lugo@ti.com>
Resources: Add 1D IO buffers to resource table and fix addresses

The 1D IO carveout buffers need to be mapped into the L2MMU, as
they won't be mapped into the TILER. This is added to the resource
table, so that it can be mapped into the MMU at the time of loading
and starting the ducati processors.

All the carveouts have been relocated to match the A9-side locations
for different sections (defined in the board files) to account for
the 1D IO carveout. The ducati image's code and ipc regions are now
assigned fixed physical addresses. The data section is immediately
before the 1D IO carveout area, and the IPC and code sections precede
the data section.

Signed-off-by: Suman Anna <s-anna@ti.com>
IPC: Label the VirtQueue ids properly

The VirtQueue ids have been defined using names that are
contradictory to what they mean. The code is functional
since the vrings are already created correctly in reverse
order. The names are corrected for proper code readability.

Signed-off-by: Suman Anna <s-anna@ti.com>
Configs: Set Non-Posted policy for IPC & Peripheral regions

The IPC and Peripheral regions' policy has been marked to the
default NON_POSTED policy. This is done to ensure that all
r/w(s) within the IPC and peripheral registers reach the
destination and in the same order as intended/issued by the
CPU. This policy avoids the CPU getting any stray interrupts
from peripherals as the order is now guaranteed.

Signed-off-by: Suman Anna <s-anna@ti.com>
Platform: Increase the EXT_CODE size for Core1

The EXT_CODE region used for .text & .cinit sections needs to
be increased to accomodate additional codecs. This size is
increased from 3MB to 5MB.

Signed-off-by: Suman Anna <s-anna@ti.com>
Resources: Adjust memory map for increased code size

The Resource table has been updated with the new static carveout
addresses, to reflect the 2MB increase in memory of the Core1
code region.

Signed-off-by: Suman Anna <s-anna@ti.com>
Configs: Use GPT3 and GPT4 as src clk for BIOS tick in Ducati

BIOS tick is currently sourced by the SysTick timer internal to
the M3 subsystem. This timer will run continuously only as long
as the Ducati functional clock, MPU_M3_CLK is running.

In order to save power, MPU_M3_CLK needs to be gated, and this
happens when the deep sleep mode configuration is set, and both
M3 cores execute WFI.

The SysTick timer stops counting when the MPU_M3_CLK is gated,
and result in all the BIOS timer-based functions like Task_sleep,
Semaphore_pend, Event_pend to never finish and wake up the
subsystem. This is avoided by choosing external gptimers as the
BIOS tick sources instead of the SysTick internal timer.

SysTick internal M3 timer is overridden with GPT3 in Core0.
SysTick internal M3 timer is overridden with GPT4 in Core1.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
PM: Enable GPT3 and GPT4 interrupts as wakeup sources

Currently GPT3 and GPT4 are selected by the configuration files as
the source of the BIOS tick. This requires that these interrupts
also be configured as wakeup sources for the M3 subsytem. Changes
have been added to enable these interrupts in the WUGEN mask.

Note that configuring different gptimers as the source clock will
require similar changes to enable those interrupts in the WUGEN
mask.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Samples: Request GPT9 instead of GPT3 in resmgr sample

Since GPT3 and GPT4 are now used to provide BIOS tick, the
sample is returning an error when trying to request GPT3.
This has been changed to request another timer, GPT9, instead.

Watchdog may utilize the GPT9 in the future, and if so it
may need to be disabled for testing this.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Trace: Add a custom SysMin module for traces

Added module ti.trace.SysMin that replaces xdc.runtime.SysMin.
The new modules allows flexibility and replaces SysMin_putchar()
and SysMin_flush() functions. The flush() function is not used
since we implement the traces in a circular buffer. The circular
buffers warps around when it reaches the end of the buffer

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Trace: Relocate trace buffer and add dump support

Relocated the trace buffers into the IPC Memory area with
the name TRACE_BUF.

Added support for keeping track of how many characters have
been written into the trace buffer and how many have been
read by an external observer (kernel or userspace).

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Resources: Increase the size of 1D IO buffer area

The 1D IO carveout buffers' size has been increased from 30MB to
90MB and is adjusted accordingly in the resource table. All the
other carveouts have also been moved down by 60MB respectively
to match this increased size.

Signed-Off-By: Sarthak Aggarwal <sarthak@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Utils: Update resources table for trace buffer size

Removed the fixed size of trace buffer from
src/ti/resources/rsc_table.h. Instead the size is
extracted from image and patched into resource table

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
IPC: Modify postCrashToMailbox() API signature

The postCrashToMailbox() function in VirtQueue module has been
renamed appropriately to VirtQueue_postCrashToMailbox() to allow
DEH (Device Exception Handler) module to invoke this function.
The function signature has also been modified.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
DEH: Add a Device Exception Handler (DEH) module

Added a new module ti.deh that notifies host of an error/exception
or unrecoverable error such as no-heap-memory, etc. It saves the
error/exception data in an error buffer.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
DEH: Add watchdog timer for M3 cores

Added watchdog timer to M3 cores. GP timers
are used as watchdog timers. The timer is set
up by host and kicked by ducati periodically.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
PM: Add wake lock/unlock APIs to control deep sleep mode

DeepSleep mode is used to gate the CPU clock when the M3 core
hits WFI. However, some internal resources like CTM and SysTick
timers are sourced from the CPU clock. So, when the CPU clk is
gated, these resources are also gated and stop working as soon
as the M3 Core idles.

The following API are provided to control the deep sleep mode.
Users must call these API in pairs.
    Void IpcPower_wakeLock();
    Void IpcPower_wakeUnlock();

The IpcPower_wakeLock() disables the deep sleep mode, and when
invoked, allows the internal resources to be functional as the
core is never gated. The IpcPower_wakeUnlock() restores the deep
sleep mode.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Utils: Add error/crash-dump buffer

Added a new buffer to shared list of buffers for
storing all crash related data. The buffer is
similar to the trace buffer except that it stores
information regarding crashes or exceptions.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
DEH: Save raw exception registers into exception buffer

A subset of the SYS/BIOS Exception context data is saved in
raw binary form into the the exception buffer. This exception
buffer is accessible to the HLOS-side, and can be used as part
of a slave processor core dump. The exception buffer previously
had only a textual information regarding the exception type.

Signed-off-by: Shahid Akhtar <sakhtar@ti.com>
SrvMgr: Add support for invoking a disconnect hook function

The OMX_DISCONNECT message currently is completely processed within
the Service Manager module. There is no infrastructure support to
call a user-provided function so that the client can execute some
additional custom operations.

This patch adds the support for registering a user hook function with
the ServiceMgr module, which will be invoked upon a OMX_DISCONNECT
message. This hook function will be used to trigger resource cleanup
in case of abnormal or premature termination of a corresponding HLOS
process.

Signed-off-by: Abhishek Ranka <asranka@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>