Using GPIO as an IRQ in a Device Driver Print


As an example of using a GPIO as an IRQ in a Linux kernel device driver, see how the Goodix touchscreen interrupts are configured in rootfs.dts.STM32F7:

goodix14: touch@14 { compatible = "goodix,gt911"; reg = <0x14>; irq-gpios = <&gpioi 10 GPIO_ACTIVE_HIGH>; reset-gpios = <&gpioh 8 GPIO_ACTIVE_LOW>; power-off-suspend; no-probe-reset; };

Refer to the kernel device driver in drivers/input/touchscreen/goodix.c for illustration of how
ts->gpiod_int is used.

As a related topic, refer to drivers/usb/dwc3/dwc3-pci.c for an example of how a GPIO is used from a device driver:

/* These GPIOs will turn on the USB2 PHY */ gpio = gpiod_get(&pdev->dev, "cs"); if (!IS_ERR(gpio)) { gpiod_direction_output(gpio, 0); gpiod_set_value_cansleep(gpio, 1); gpiod_put(gpio); }

The example above works with the cs-gpios node in the DTS. Refer to the description of the for gpiod_*() functions in linux/Documentation/gpio/consumer.txt.