Skip to main content
The Pinctrl subsystem in the Qualcomm® Linux kernel manages and configures pins used for general-purpose input/output (GPIO), interintegrated circuit (I2C), serial peripheral interface (SPI), and other hardware interfaces. Pinctrl configurations, such as pin muxing and pin groupings, are managed in the device-specific pinctrl drivers, where the drivers list all the available pins and functions. For example, the corresponding driver for QCS6490 is available in the kernel-src/drivers/pinctrl/qcom/pinctrl-sc7280.c file.
For more information about additional Qualcomm SoC pinctrl drivers, see Pinctrl Drivers.
The following are the pinctrl data objects: Table: Pinctrl data objects
For more information about the supported functions of the respective SoC pinctrl binding documentation for QCS6490, see pinctrl binding documentation.
Function selection For a sc7280_functions data object, one or multiple GPIO pins are used as a function and must be registered to the device tree and passed to the right device node. During system boot, the kernel pinctrl infrastructure registers the functions. The following example shows the kernel configuration infrastructure:

Configure the GPIO usage

GPIO pin configuration requires the following two settings. The settings define a GPIO pin state and make those pins available for any input/output activity.
  • Mux: The mux setting requires selecting the function name that is mapped from the set of available functions in the SoC-specific pinctrl driver. For more information about pinctrl, see Pinctrl configuration.
  • Configuration: The configuration aspect requires setting the drive strength and bias property.
The following examples show how the two settings define the GPIO pin using the following procedures:
  1. Define the pin configuration in the device tree:
  2. Configure the device node or intellectual property (IP) block in the device tree:
  3. The driver code must use generic APIs to select and register their GPIO configurations within the pinctrl configurations. The following is an example of available APIs:
GPIO as interrupt request (IRQ) To set the GPIO as an IRQ, use the following procedure:
  1. Configure the GPIO pin in the DTS file:
    1. Set the properties and the function for the GPIO pin.
    2. Set the pin to use GPIO 55 for the qup_se_l3() function with the following configurations:
  2. Create a DT entry like the previous configuration for the device node where you want set the GPIO as an IRQ. In the following example, the GPIO55 is configured as an IRQ with the parent as a top-level mode multiplexer (TLMM) and the level is set to high.
  3. The driver must read the value and register it as an interrupt to the generic interrupt controller (GIC) using the request_irq API specifying the interrupt service register (ISR) and IRQ flags.

Configure GPIOs to generate clock or pulse width modulation

Configure any GPIO with the GP_CLK as an alternate functionality to get clock or pulse width modulation (PWM).
The following procedure is applicable to QCS6490 SoCs.
For more information about how to find a GPIO with the GP_CLK function, see the Pin descriptions.
  1. Add GPIO configuration node in kernel/arch/arm64/boot/dts/qcom/sc7280.dtsi file.
  1. Define device tree node in kernel/arch/arm64/boot/dts/qcom/sc7280.dtsi file.
  2. Add the following code in the device driver:
  3. If you do not use clock or PWM, call clk_disable_unprepare() to disable the clock to save power. Note Ensure to call clk_prepare_enable() first before calling clk_disable_unprepare().
  4. To generate the required duty cycle, call clk_set_duty_cycle() API after clk_prepare_enable API.

Configure GPIOs from the user space

Use the libgpiod library from the user space to control the GPIOS for better performance.
  1. To compile and push libgpiod library from the host computer, do the following:
    1. To install Arm® (Arm64) toolchain, run the following commands:
    2. To download and extract the libgpiod source code from libgpiod 1.6.4.tar.xz, run the following commands:
    3. To configure the sources for static linking, run the following command:
    4. To compile the library, run the following command:
      Note Compiling creates linked binaries.
    5. To build statically linked binaries, run the following commands:
  2. To push the binaries to your device after compilation, run the scp command. For example:
After pushing the binaries to your device, run the following commands on the device to interact with the GPIOs:
  1. Use the gpiodetect and gpioinfo commands to list the GPIO chips and lines. The following example shows the GPIO chip information:
    The following example shows the GPIO lines:
  2. Use the gpioset command to set GPIO values. For example, to set GPIO line 0 on gpiochip4, do the following:
  3. Use the gpioget command to read GPIO values. For example, to read the value of GPIO line 0 on gpiochip4, do the following: