GPIO interrupt problem

I have a problem with a maxim fuel gauge IC connected to GPIO-G aka SOC GPIO_023 aka Linux gpio495. The pin is connected to the (open drain, active low) fuel gauge interrupt line and pulled up to 1.8V. First of all, to make any interrupts happening at all, I have to export it to /sys/class/gpio/gpio495 by calling export from init.rc. I don know why this is needed, but it fixed half of the issue, namely the thing not generating any interrupts at all. The other half of the problem is the following:

To make the next interrupt possible, you have manually clear the fuel gauge status register after an interrupt has happened. This works. But if the fuel gauge has been completely powered down, the status registers already contains some interrupt flags at power up. I can detect and also clear these in the kernel probe, but doing this at this point does not release the physical interrupt line (monitoring with a scope probe). It just stays low. When I do the same thing using i2cset after boot up, the pin goes high and new interrupts can occur.

I don’t have this behaviour when rebooting with the battery still connected to the fuel gauge, because in this event, the interrupt flag register is completely clear at boot up and the line stays high.

I think that if I can find a better way to make gpio-g ‘active’ before the driver is loaded than doing this export in init.rc, the problem should disappear, but I don’t know where and how to do this. I have another IC peripheral on an interrupt line at gpio-J which just works right out of the box.

Hacked my way around it deferring the probe when it is called after a power cycle. That doesn’t even make sense in the context of the assumptions made above but hey who cares :slight_smile: