# GPIO configurations

Source: [https://docs.qualcomm.com/doc/80-88500-4/topic/26_GPIO_configurations.html](https://docs.qualcomm.com/doc/80-88500-4/topic/26_GPIO_configurations.html)

A GPIO has two types of configurations, runtime and sleep.

## Runtime configuration

The device does not rely on the TLMM driver to initialize the runtime configuration of GPIOs. It
        is the responsibility of the software module that owns the GPIO to configure it into the
        appropriate state. The XML files in the following directory define the GPIO IDs and the
        alternate function for each GPIO:

\modem\_proc\core\settings\systemdrivers\tlmm\config\sdm855\TLMMChipset.xmlcd

Each ID starts with a string name and corresponds to an appropriate GPIO and its alternate function. For example, the following line defines string “qup\_l0[0]” to be associated with GPIO 0 alternate function 1 that is {0, 1}.

      <props name=”qup_l0[0]” type=”TLMMGpioIdType”>{0, 1}</props> Copy to clipboard

These IDs are used when a driver requests and configures GPIOs with API
          DalTlmm\_ConfigGpioId (see [DALTLMM APIs](https://docs.qualcomm.com/doc/80-88500-4/topic/29_DALTLMM_interface_description.html)). When this API is used, the GPIO driver
        locks the GPIO in software and prevents other modules from accessing the GPIO without the
        correct GPIO ID.

## Sleep configuration

The sleep configuration is the configuration applied to a GPIO when the driver that owns the GPIO
        puts it into the Inactive or Sleep state. The sleep configuration depends on the peripheral
        connected to the device and the state of the peripheral during device sleep. The following
        are the guidelines for GPIO sleep configuration.

When the device goes to sleep, check for the following scenarios to avoid leakage current on the
        GPIO pad:

- Conflict between the device and the external device – Either the device or an
          external device should drive the GPIO
- Floating pin – The GPIO should have a definite state (either high or low) during sleep. If the
          GPIO is left floating around Vdd/2, the quiescent current in the IC circuit will be the
          highest

To avoid these scenarios, it is important to understand the GPIOs usage and peripheral behaviour
        during sleep. For example, if the external device drives the GPIO during sleep, the GPIO
        should be set to INPUT with the desirable pull direction. If the external device does not
        drive the pin during sleep, the GPIO can be set to OUTPUT with the appropriate logic
        state.

It is important to distinguish between the logic state and internal pull of a GPIO. The internal
        pull is weak (approximately 100 kΩ) and determines the GPIO state only when neither the
        device nor the external device drives the pin. A GPIO should not have a high state during
        sleep when PULL\_HIGH is defined for the pin.

The GPIO sleep configurations are stored in the TLMMChipset.xml file of the boot image:

boot\_images\QcomPkg\SocPkg\8250\Settings\TLMM\loader\TLMMChipset.xml

The settings in this file are loaded and written into the TLMM\_GPIO\_LP\_CFGn registers during boot
        by the  DALTLMMState\_Init API in the DALTLMMState.c file. The module that
        owns the GPIO must call the TLMM API to disable a GPIO or set it to inactive so that the
        sleep configuration stored in the TLMM\_GPIO\_LP\_CFGn registers is applied to the GPIO.
        Without this invocation, the TLMM driver does not apply the sleep configuration.

**Parent Topic:** [GPIO DAL driver](https://docs.qualcomm.com/doc/80-88500-4/topic/25_GPIO_DAL_driver.html)

Last Published: Aug 18, 2023

[Previous Topic
GPIO DAL driver](https://docs.qualcomm.com/bundle/publicresource/80-88500-4/topics/25_GPIO_DAL_driver.md) [Next Topic
GPIO configuration timeline](https://docs.qualcomm.com/bundle/publicresource/80-88500-4/topics/27_GPIO_configuration_timeline.md)