kernel-src/drivers/pinctrl/qcom/pinctrl-sc7280.c file.
For more information about additional Qualcomm SoC pinctrl drivers, see Pinctrl Drivers.
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.
- Define the pin configuration in the device tree:
- Configure the device node or intellectual property (IP) block in the device tree:
- 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:
- Configure the GPIO pin in the DTS file:
- Set the properties and the function for the GPIO pin.
- Set the pin to use GPIO 55 for the
qup_se_l3()function with the following configurations:
- 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.
- The driver must read the value and register it as an interrupt to the generic interrupt controller (GIC) using the
request_irqAPI specifying the interrupt service register (ISR) and IRQ flags.
Configure GPIOs to generate clock or pulse width modulation
Configure any GPIO with theGP_CLK as an alternate functionality to get clock or pulse width modulation (PWM).
The following procedure is applicable to QCS6490 SoCs.
GP_CLK function, see the Pin descriptions.
- Add GPIO configuration node in
kernel/arch/arm64/boot/dts/qcom/sc7280.dtsifile.
- Define device tree node in
kernel/arch/arm64/boot/dts/qcom/sc7280.dtsifile. - Add the following code in the device driver:
- If you do not use clock or PWM, call
clk_disable_unprepare()to disable the clock to save power. Note Ensure to callclk_prepare_enable()first before callingclk_disable_unprepare(). - To generate the required duty cycle, call
clk_set_duty_cycle()API afterclk_prepare_enableAPI.
Configure GPIOs from the user space
Use thelibgpiod library from the user space to control the GPIOS for better performance.
- To compile and push
libgpiodlibrary from the host computer, do the following:- To install Arm® (Arm64) toolchain, run the following commands:
- To download and extract the libgpiod source code from libgpiod 1.6.4.tar.xz, run the following commands:
- To configure the sources for static linking, run the following command:
- To compile the library, run the following command:
Note Compiling creates linked binaries.
- To build statically linked binaries, run the following commands:
- To install Arm® (Arm64) toolchain, run the following commands:
- To push the binaries to your device after compilation, run the
scpcommand. For example:
- Use the
gpiodetectandgpioinfocommands to list the GPIO chips and lines. The following example shows the GPIO chip information:The following example shows the GPIO lines: - Use the
gpiosetcommand to set GPIO values. For example, to setGPIO line 0ongpiochip4, do the following: - Use the
gpiogetcommand to read GPIO values. For example, to read the value ofGPIO line 0ongpiochip4, do the following:

