根据您的评论,您希望将 GPIO 注册为中断。您发布的设备树节点是中断控制器节点,它与我们手头的任务无关。
要将 gpio 注册为中断,您首先需要找到一个可以配置为中断的 GPIO(在大多数现代处理器中,所有 GPIO 都支持它),然后您必须通过多路复用来确保它不被其他设备使用(如果它被 SPI 或 UART 等使用,如果您不使用该实体,则可以从设备树中禁用它们)。
现在您有了一个可以使用的 GPIO 引脚。在内核上找到该引脚对应的 GPIO 编号(这取决于您的处理器及其载板的架构)。
当您拥有它时,您可以编写一个简单的模块来导出您的 GPIO 并将其用作中断。
以下是来自http://derekmolloy.ie的片段
gpio_request(gpioButton, "sysfs"); // Set up the gpioButton
gpio_direction_input(gpioButton); // Set the button GPIO to be an input
gpio_set_debounce(gpioButton, 200); // Debounce the button with a delay of 200ms
gpio_export(gpioButton, false); // Causes gpio115 to appear in /sys/class/gpio
// the bool argument prevents the direction from being changed
// Perform a quick test to see that the button is working as expected on LKM load
printk(KERN_INFO "GPIO_TEST: The button state is currently: %d\n", gpio_get_value(gpioButton));
// GPIO numbers and IRQ numbers are not the same! This function performs the mapping for us
irqNumber = gpio_to_irq(gpioButton);
printk(KERN_INFO "GPIO_TEST: The button is mapped to IRQ: %d\n", irqNumber);
// This next call requests an interrupt line
result = request_irq(irqNumber, // The interrupt number requested
(irq_handler_t) ebbgpio_irq_handler, // The pointer to the handler function below
IRQF_TRIGGER_RISING, // Interrupt on rising edge (button press, not release)
"ebb_gpio_handler", // Used in /proc/interrupts to identify the owner
NULL); // The *dev_id for shared interrupt lines, NULL is okay
链接到完整的代码。