Hi, I have a problem on configure GPIOA_1 to irq mode
I tested on AOSP main, kernel 6.1
I want to use GPIOA_1 for irq, but gpio_to_irq return -6
So I can’t request irq by irq num.
I had read the A311D DS, it seems gpio num cannot simply map to irq num.
A311D has 8 gpio irq channels, user should configure gpio lines into irq controller.
Maybe we should do this mapping instead of gpio_to_irq for getting the target irq num.
Is there any sample code for gpio irq configuration?
Here is my config and code for GPIOA_1
gpio work fine but only irq is not working
DTS:
irq-gpio = <&gpio GPIOA_1 0>; // GPIOA_1-I2SB_SCLK
code:
hw_res.irq_gpio = of_get_named_gpio(np, "irq-gpio", 0);
client->irq = gpio_to_irq(hw_res.irq_gpio);
if (client->irq < 0) {
// client->irq got -6
return;
}
devm_request_irq(i2c_dev, client->irq, irq_handler,
IRQF_TRIGGER_HIGH, name, NULL);
@xiong.zhang
Is there easy way to make the irq working?
Maybe we can just configure these regs for the GPIOA_1 by physical address, and find the irq num in kernel
include/linux/amlogic/aml_gpio_consumer.h
AML_GPIO_IRQ marco in doc for AndroidP is not found in kernel 6.1
Hello, we do not maintain AOSP. This is the trial version. If you want to use it, please use the Android 9.0 system. Sorry
irq driver is already in android common kernel 6.1 => common/drivers/irqchip/irq-meson-gpio.c
gpio driver for A311D does not impl the “to_irq” func, so we cannot use gpio_to_irq in our device driver.
GPIO irq related code is update in linux mainline, we can get those update from mainline:
1、get the amlogic,meson-g12a-gpio-intc.h file from github and place into common/include/dt-bindings/interrupt-controller/
include/dt-bindings/interrupt-controller/amlogic,meson-g12a-gpio-intc.h
2、include the header in your dts
e.g. common/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
#include <include/dt-bindings/interrupt-controller/amlogic,meson-g12a-gpio-intc.h>
3、add gpio irq conf into your dts node
&i2c_AO {
status = "okay";
pinctrl-0 = <&i2c_ao_sck_pins>, <&i2c_ao_sda_pins>;
pinctrl-names = "default";
clock-frequency = <400000>;
nfc@28 {
status = "okay";
compatible = "tms,nfc";
reg = <0x28>;
tms,irq-gpio = <&gpio GPIOA_1 0>; // GPIOA_1-I2SB_SCLK
// add for GPIOA_1 irq
interrupt-parent = <&gpio_intc>;
interrupts = <IRQID_GPIOA_1 IRQ_TYPE_LEVEL_HIGH>;
};
};
4、get irq num in code and register irq handler
// client->irq = gpio_to_irq(irq_gpio); // not support gpio_to_irq, the irq num is already parse in i2c core from dts and store in client->irq
ret = devm_request_irq(i2c_dev, client->irq, nfc_irq_handler,
IRQF_TRIGGER_HIGH, name, NULL);