Hi
I have a kernel driver that I need to be able to respond to an interrupt generated by a positive edge on a GPIO input (GPIO7_TOUCH_RST). From my research so far I think this is TX1 module pin B23 (TOUCH_RST).
From the Jetson TX1 Customer Config spreadsheet this is GPIO3_PV.06 which I have translated to GPIO number 174 using gpio-names.h
My driver code looks like this
...
#define DATA_READY_PIN 174
...
irqreturn_t Data_Ready_IRQHandler(int irq, void *dev_id)
{
printk(KERN_ERR "Data Ready IRQ\n");
return IRQ_HANDLED;
}
...
static int XPCIe_init(void)
{
// Grab gpio pins
int data_ready_irq_number;
...
if(0 == gpio_request(DATA_READY_PIN,"ZYNQ Read data available"))
{
gpio_direction_input(DATA_READY_PIN);
gpio_export(DATA_READY_PIN,false);
data_ready_irq_number = gpio_to_irq(DATA_READY_PIN);
if (0 > request_irq(data_ready_irq_number,
&Data_Ready_IRQHandler,
IRQF_SHARED | IRQF_TRIGGER_RISING,
gDrvrName, gDev))
{
printk(KERN_WARNING"%s: Init: Unable to allocate Data Ready IRQ",gDrvrName);
return (CRIT_ERR);
}
else
{
printk(KERN_ERR "GPIO: %d IRQ: %d\n",DATA_READY_PIN, data_ready_irq_number);
}
}
else
{
printk(KERN_ERR "Couldnt get DATA READY GPIO\n");
}
...
}
...
// Driver Entry Point
module_init(XPCIe_init);
So when the code runs all the GPIO related calls succeed and the following is output to the dmesg log
[ 41.719347] GPIO: 174 IRQ: <b>447</b>
However I get no interrupts when I toggle this pin :-(
Dumping the contents of /proc/interrupts
# cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
29: 0 0 0 0 GIC arch_timer
30: 0 0 0 0 GIC arch_timer
34: 0 0 0 0 GIC tegra_rtc
36: 0 0 0 0 GIC bpmp
37: 0 0 0 0 GIC bpmp
39: 0 0 0 0 GIC bpmp
46: 0 0 0 0 GIC mmc2
47: 750 0 0 0 GIC mmc1
49: 0 0 0 0 GIC 546c0000.i2c
50: 0 0 0 0 GIC bpmp
52: 0 0 0 0 GIC tegra-otg, tegra-udc
53: 0 0 0 0 GIC pmc_usb_phy_wake_isr
63: 3925 0 0 0 GIC mmc0
68: 1781 0 0 0 GIC serial
...
256: 0 0 0 0 GIC adma.8
257: 0 0 0 0 GIC adma.9
271: 0 0 0 0 GIC adsp watchdog
274: 0 0 0 0 GIC AMC error int
276: 0 0 0 0 GIC adsp wfi
279: 0 0 0 0 GIC adsp_cpu
334: 1 0 0 0 GPIO <b>bluetooth hostwake</b>
461: 0 0 0 0 GPIO <b>nct72</b>
462: 0 0 0 0 GPIO <b>Power</b>
463: 0 0 0 0 GPIO <b>Volume Up</b>
465: 0 0 0 0 GPIO <b>Volume Down</b>
473: 0 0 0 0 GPIO <b>1.extcon</b>
474: 0 0 0 0 GPIO <b>mmc2</b>
532: 0 0 0 0 max77620-top max77620-gpio
533: 0 0 0 0 max77620-top max77620-rtc
536: 0 0 0 0 max77620-top 4-003c
537: 0 0 0 0 max77620-top max77620-thermal.6
538: 0 0 0 0 max77620-top max77620-thermal.6
539: 0 0 0 0 max77620-gpio 1.extcon
547: 0 0 0 0 soc_therm_oc voltmon_oc1
548: 0 0 0 0 soc_therm_oc batmon_oc3
IPI0: 1080 1647 739 773 Rescheduling interrupts
IPI1: 23 117 137 138 Function call interrupts
IPI2: 1 5 0 4 Single function call interrupts
IPI3: 0 0 0 0 CPU stop interrupts
IPI4: 0 0 0 0 CPU wakeup interrupts
IPI5: 0 0 0 0 Timer broadcast interrupts
Firstly I see that there is no entry for interrupt 447 but I do see entries for other gpios :-(
Secondly if I cat /sys/kernel/debug/tegra_gpio (I’ve reformatted this to make it more decipherable)
Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
A: 0:0 24 00 00 04 00 00 000000
B: 0:1 0f 00 00 00 00 00 000000
C: 0:2 00 00 00 00 00 00 000000
D: 0:3 10 10 00 00 00 00 000000
E: 1:0 70 00 00 00 00 00 000000
F: 1:1 00 00 00 00 00 00 000000
G: 1:2 00 00 00 00 00 00 000000
H: 1:3 ff 1b 0a 64 00 20 002024
I: 2:0 0f 0d 01 02 00 00 000000
J: 2:1 00 00 00 00 00 00 000000
K: 2:2 f0 20 00 d0 00 00 000000
L: 2:3 02 00 00 02 00 00 000000
M: 3:0 00 00 00 00 00 00 000000
N: 3:1 00 00 00 00 00 00 000000
O: 3:2 00 00 00 00 00 00 000000
P: 3:3 00 00 00 00 00 00 000000
Q: 4:0 00 00 00 00 00 00 000000
R: 4:1 00 00 00 00 00 00 000000
S: 4:2 f0 f0 00 00 00 00 000000
T: 4:3 03 03 00 00 00 00 000000
U: 5:0 0c 00 00 00 00 00 000000
<b><u>V: 5:1 6e 66 00 00 00 00 000000</u></b>
W: 5:2 00 00 00 00 00 00 000000
X: 5:3 ff 00 00 f4 00 70 606000
Y: 6:0 03 00 00 02 00 01 010100
Z: 6:1 1f 08 00 17 00 03 030300
AA: 6:2 00 00 00 00 00 00 000000
BB: 6:3 0d 04 00 09 00 00 000000
CC: 7:0 32 30 20 20 00 00 000000
DD: 7:1 00 00 00 00 00 00 000000
EE: 7:2 00 00 00 00 00 00 000000
FF: 7:3 00 00 00 00 00 00 000000
So looking at port V (underlined above) using section 9.13 from TRM
--------------------7<u>6</u>543210 Bit 6
CNF 0x6e 0<u>1</u>101110 1 - GPIO
OE 0x66 0<u>1</u>100110 1 - DRIVEN
OUT 0x00 0<u>0</u>000000 0 - LOW
IN 0x00 0<u>0</u>000000 0 - LOW
INT_STA 0x00 0<u>0</u>000000 0 - IN_ACTIVE
INT_ENB 0x00 0<u>0</u>000000 0 - DISABLE
INT_LVL 0x000000 - NO_DELTA LEVEL LOW
Given the status of this I guess it is no wonder I’m not getting any interrupts on the PIN as the interrupts are not enabled :-(
So, what is the correct way to go about this? Is it in the device tree or in code? Looking at gpio-tegra.c there doesn’t seem to be an obvious way to enable the interrupt. Only the resume method seems to write the enable register and only writes it from a previous save?
Help!
Robert