// Copyright (c) Qualcomm Technologies, Inc.
// All Rights Reserved.
// Qualcomm Technologies Proprietary and Confidential.

//----------------------------------------------------------
//  Corresponds to qsee_tlmm_config_t.
//----------------------------------------------------------

/** @cond */
struct ITLMM_Config
{
  uint32     GpioDirection;  /**< The direction of the GPIO (input/output). */
  uint32     GpioPull;  /**< The pull of the GPIO (pull-up/pull-down/no-pull). */
  uint32     GpioDrive;   /**< The drive strength in mA (2, 4, 6, 8, 10, 12, 14, 16). */
};
/** @endcond */

/** @cond */
interface ITLMM {
/** @endcond */

  /**
  * @addtogroup ITLMM
  * @{
  */

  /* Errors */
  error ERROR_ACCESS_DENIED;  /**< Failure on Access Control privileges
                               * (see \link CSecureGPIO \endlink). */

  //--------------------------------------------------------
  //  Corresponds to enum qsee_tlmm_gpio_direction_t.
  //--------------------------------------------------------

  /**
   * Specifies if the GPIO should be an input or an output.
   */

  const uint32 GPIO_INPUT   = 0;
  const uint32 GPIO_OUTPUT  = 1;

  //--------------------------------------------------------
  //  Corresponds to enum qsee_tlmm_gpio_pull_t.
  //--------------------------------------------------------

  /**
   * Specifies the weak pull of the GPIO when configured as
   * input GPIO or in some cases of alternate functions.
   */

  const uint32 GPIO_NO_PULL   = 0;
  const uint32 GPIO_PULL_DOWN = 1;
  const uint32 GPIO_KEEPER    = 2;
  const uint32 GPIO_PULL_UP   = 3;

  //--------------------------------------------------------
  //  Corresponds to enum qsee_tlmm_gpio_drive_t.
  //--------------------------------------------------------

  /**
   * In idle state whether the Chip Select is high or low.
   */

  const uint32 GPIO_2MA  = 0;
  const uint32 GPIO_4MA  = 1;
  const uint32 GPIO_6MA  = 2;
  const uint32 GPIO_8MA  = 3;
  const uint32 GPIO_10MA = 4;
  const uint32 GPIO_12MA = 5;
  const uint32 GPIO_14MA = 6;
  const uint32 GPIO_16MA = 7;

  //--------------------------------------------------------
  //  Corresponds to enum qsee_tlmm_gpio_value_t.
  //--------------------------------------------------------

  /**
   * The drive value for an output GPIO.
   */

  const uint32 GPIO_LOW  = 0;
  const uint32 GPIO_HIGH = 1;

  //--------------------------------------------------------
  //  Corresponds to enum qsee_tlmm_gpio_mode_t.
  //--------------------------------------------------------

  /**
   * Specifier to switch between primary and IO (bit-bang) mode.
   */

  const uint32 GPIO_MODE_IO      = 0;
  const uint32 GPIO_MODE_PRIMARY = 1;
  /** @endcond */

  /**
    - Retrieves the GPIO ID for a specific GPIO pin.
    - This function is required to perform operations on a GPIO.

    @param[in] gpioStr String name of GPIO signal.
    @param[out] gpioId GPIO key that allocates GPIO to a user.

    @return
    Object_OK on success.
    ITLMM_ERROR_ACCESS_DENIED when the client cannot use the GPIO.
   */
  method GetGpioId( in buffer gpioStr, out uint32 gpioId );

  /**
    - Releases GPIO and destroys GPIO ID key.
    - This function is optional in case a GPIO is no longer needed.

    @param[in] gpioId GPIO key that allocates a GPIO to a user.

    @return
    Object_OK on success.
   */
  method ReleaseGpioId( in uint32 gpioId );

  /**
    Configures a GPIO based on the GPIO ID.

    @param[in] gpioId GPIO key that allocates a GPIO to a user.
    @param[in] settings Configurable settings (pull, drive, direction).

    @return
    Object_OK on success.
   */
  method ConfigGpioId( in uint32 gpioId, in ITLMM_Config settings );

  /**
    Drives output value of a GPIO based on the GPIO ID.

    @param[in] gpioId GPIO key that allocates a GPIO to a user.
    @param[in] value Value (0 = LOW, 1 = HIGH) to drive an output.

    @return
    Object_OK on success.
   */
  method GpioIdOut( in uint32 gpioId, in uint32 value );

  /**
    Reads the input value of a GPIO based on the GPIO ID.

    @param[in] gpioId GPIO key that allocates GPIO to a user.
    @param[out] value Value (0 = LOW, 1 = HIGH) of the input signal.

    @return
    Object_OK on success.
   */
  method GpioIdIn( in uint32 gpioId, out uint32 value );

  /**
    - Selects the function select (either 0 or primary) of a GPIO based on the GPIO ID.
    - Optionally sets configuration parameters.

    @param[in] gpioId GPIO key that allocates GPIO to a user.
    @param[in] mode Mode IO (0) or PRIMARY (1) to set GPIO mux.

    @return
    Object_OK on success.
   */
  method SelectGpioIdMode( in uint32 gpioId, in uint32 mode );

  /** @} */ /* end_addtogroup ITLMM */
};

