How to request a irq for imx6ul's gpio

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to request a irq for imx6ul's gpio

3,765 Views
tujianwu
Contributor I

I want to request a gpio interrupt with imx6ul. but it return -22 error.

the follow code is my config.

led_imr = ioremap(GPIO4_IMR, 32);
writel(readl(led_imr) | (0xff<<21), led_imr);

led_isr = ioremap(GPIO4_ISR, 32);
writel(readl(led_isr) | (0xff<<21), led_isr);

led_edge_sel = ioremap(GPIO4_EDGE_SEL, 32);
writel(readl(led_edge_sel) | (0xff<<21), led_edge_sel);

int ret = request_irq(105, encoder_irq, IRQF_SHARED, "encoder", &devno);
printk("data: %d\n", ret);

Had find data:
1. use gpio_to_irq (can't use, tips not found.)

2. is there had a GPIO_IRQ_START (offset?)

88 EPIT1 EPIT1 output compare interrupt.
89 EPIT2 EPIT2 output compare interrupt.
90 GPIO1 INT7 interrupt request.
91 GPIO1 INT6 interrupt request.
92 GPIO1 INT5 interrupt request.
93 GPIO1 INT4 interrupt request.
94 GPIO1 INT3 interrupt request.
95 GPIO1 INT2 interrupt request.
96 GPIO1 INT1 interrupt request.
97 GPIO1 INT0 interrupt request.
98 GPIO1 Combined interrupt indication for GPIO1 signals 0 - 15.
99 GPIO1 Combined interrupt indication for GPIO1 signals 16 - 31.
100 GPIO2 Combined interrupt indication for GPIO2 signals 0 - 15.
101 GPIO2 Combined interrupt indication for GPIO2 signals 16 - 31.
102 GPIO3 Combined interrupt indication for GPIO3 signals 0 - 15.
103 GPIO3 Combined interrupt indication for GPIO3 signals 16 - 31.
104 GPIO4 Combined interrupt indication for GPIO4 signals 0 - 15.
105 GPIO4 Combined interrupt indication for GPIO4 signals 16 - 31.

Here is the interrupts system had request.

/ # cat /proc/interrupts
CPU0
34: 0 GIC 34 sdma
36: 0 GIC 36 20cc000.snvs-pwrkey
37: 2 GIC 37 21c8000.lcdif
40: 0 GIC 40 pxp-dmaengine
45: 6434 GIC 45 mxs-dma
47: 0 GIC 47 bch
51: 0 GIC 51 rtc alarm
52: 0 GIC 52 snvs-secvio
54: 0 GIC 54 mmc0
58: 66 GIC 58 2020000.serial
68: 518 GIC 68 21a0000.i2c
69: 57 GIC 69 21a4000.i2c
74: 30 GIC 74 2184200.usb
75: 0 GIC 75 2184000.usb
78: 0 GIC 78 2143000.jr2
81: 0 GIC 81 imx_thermal
82: 0 GIC 82 asrc
87: 15575 GIC 87 i.MX Timer Tick
112: 0 GIC 112 20bc000.wdog
130: 0 GIC 130 sai
137: 14 GIC 137 2141000.jr0
138: 0 GIC 138 2142000.jr1
145: 0 GIC 145 mxc_sim_ipb
150: 0 GIC 150 2188000.ethernet
151: 0 GIC 151 2188000.ethernet
152: 9343 GIC 152 20b4000.ethernet
153: 0 GIC 153 20b4000.ethernet
179: 0 gpio-mxc 19 2190000.usdhc cd
289: 13 gpio-mxc 1 edt-ft5x06
292: 0 gpio-mxc 4 headset detect
IPI0: 0 CPU wakeup interrupts
IPI1: 0 Timer broadcast interrupts
IPI2: 0 Rescheduling interrupts
IPI3: 0 Function call interrupts
IPI4: 0 Single function call interrupts
IPI5: 0 CPU stop interrupts
IPI6: 0 IRQ work interrupts
IPI7: 0 completion interrupts

What should i do next? Thank you very much~

Labels (2)
Tags (2)
0 Kudos
Reply
2 Replies

1,705 Views
vinodmaverickr0
Contributor IV

Hi tu ji.

I don't know why use can't use the gpio_to_irq in your code. It is generic APIs (used by almost every architecture) so it should work. BTW how you came to know that  irq no is 105. One more thing you can check the return value of request_irq .

Thanks,

Vinod

0 Kudos
Reply

1,705 Views
igorpadykov
NXP Employee
NXP Employee

Hi tu

one can check gpio_to_irq description in

https://lwn.net/Articles/532714/

and examples in
https://community.nxp.com/thread/350524
linux/drivers/power/sabresd_battery.c
linux/drivers/gpio/gpio-mxc.c

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply