TOG : Time-Out Gasket
=====================

Introduction
------------

The Interconnect Isolation Gasket is a TI proprietary IP that is used to prevent a hang caused by slave, which can hold up the interconnect and terminate such a transaction safely. It tracks transactions, and times out if outstanding too long, and reports the error via interrupt that can be monitored.

The TOGs help to achieve Freedom From Interference by monitoring the various VBUS transactions and providing a way to detect any errors, and helping to avoid the bus to be locked up due to a transaction error.

These TOGs have the following functions, to avoid these concerns:

* Monitors various VBUS transaction and provide a way to detect errors
* Helps avoid the bus to be locked up due to a transaction in error.
* Tracks outstanding transactions and allows for timeout/recovery.

Each of the Timeout gaskets can be programmed to a specific timeout and any transaction exceeding the timeout will result in abort of the transaction. This will also result in an error event triggered through ESM, which will in turn can  be programmed to interrupt the CPU.

In addition the timeout gasket can be stopped, started and reset at anytime.

Safety diagnostics are provided for TOG module through API's

* Configure the TOG
* Read the static registers
* Verify the written configuration

.. ifconfig:: CONFIG_family in ('j721e')

    J721E supports only slave gaskets. There are 4 instances on the device.

.. ifconfig:: CONFIG_family in ('j7200')

    J7200 supports 13 instances on the device.

.. ifconfig:: CONFIG_family in ('j721s2')

    J7200 supports 18 instances on the device.

Example Usage
-------------

The following shows an example of SDL TOG API usage by the application to set up the TOG for monitoring for events. Events can be monitored by enabling the events in the associated ESM instance.

Configure a TOG instance with a timeout value

    .. code:: bash

        SDL_TOG_Inst instance;
        SDL_TOG_config cfg;
        int32_t status;

        cfg.timeoutVal = TOG_TEST_TIMEOUTVAL;

        status = SDL_TOG_init(instance, &cfg);
        if (status != SDL_PASS)
        {
            // init failed
        }

Enable the TOG interrupts

    .. code:: bash

        SDL_TOG_Inst instance;
        int32_t status;

        /* Enable interrupts */
        status = SDL_TOG_setIntrEnable(instance, SDL_TOG_INTRSRC_ALL, true);
        if (status != SDL_PASS)
        {
            // interrupt enable failed
        }

Start the TOG

    .. code:: bash

        /* Call SDL API to enable Timeout Gasket */
        status = SDL_TOG_start(instance);
        if (status != SDL_PASS)
        {
            // start failed
        }

Stop the TOG

    .. code:: bash

        SDL_TOG_Inst instance;

        SDL_TOG_stop(instance);

Reset the TOG

    .. code:: bash

        /* Reset the Timeout gasket */
        SDL_TOG_reset( instance );

Get the Error Information (can be called when an error occurs)

    .. code:: bash

       SDL_TOG_Inst instance;
       SDL_TOG_errInfo errInfo;

       /* Read error info */
       status = SDL_TOG_getErrInfo(instance, &errInfo)

Acknowledge the interrupts for an interrupt source

    .. code:: bash

        SDL_TOG_Inst instance;
        uint32_t intCount;

        /* Get Transaction timeout interrupt count */
        status = SDL_TOG_getIntrCount(instance, SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT, &intCount);

        /* Clear Transaction timeout interrupt events */
        if ((status == SDL_PASS) && (intCount != 0))
        {
            status = SDL_TOG_ackIntr(instance, SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT, intCount);
            TEST_ASSERT_EQUAL_INT32(SDL_PASS, status);
        }

Clear the pending interrupts for an interrupt source

    .. code:: bash

        SDL_TOG_Inst instance;

        status = SDL_TOG_clrIntrPending(instance, SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT);

        
Examples
--------

The TOG module provide a Safety Example to show how to use TOG with error injection and testing for error response, and also ESM application callback usage. Details regarding the TOG Safety Example can be found `here <../examples/tog.html>`_.

Test apps that are meant for verifying the functionality of the module are also provided.

+---------------------+--------------------------------------------------------+--------------------------------------+------------------------------------------+
| Test App Name       | Description                                            | Location                             | Build Command                            |
+=====================+========================================================+======================================+==========================================+
| tog_test_app        | - Configures the timeout                               |                                      |                                          |
|                     | - Triggers the error events                            | [sdl_install_dir]/test/tog           | make tog_test_app PROFILE=release        |
|                     | - Checks for error response                            |                                      |                                          |
+---------------------+--------------------------------------------------------+--------------------------------------+------------------------------------------+


API
---

|__TOG_API_LNK__|
