Using AXP209 GPIO ADC

Started by PaddleStroke, July 15, 2019, 04:36:36 PM

Previous topic - Next topic

PaddleStroke

Hello again,

Trying to use the AXP209 GPIO0 and GPIO1 as ADC. I checked the lime2 schematic and found they don't look to be much used currently. GPIO0 have a capacitor and GPIO1 some resistors which seems related to USB OTG, but as I'm not using OTG I guessed those resistors can be removed.

So I soldered a wire to the R67/R69 and one to C171 in order to get hardware access to the GPIO.

Now my issue is that I am trying to edit the values of AXP209 register with I2Cset (armbian mainline), but some values keep being rewriten after reboot...


#GPIO0 function is REG 90H (see page 40 datasheet)
#Defaut value for register : 07H, 7 hex is 0111 bin where 111 are the function. We need replace with 100 bin for ADC function so 04h
#GPIO1 function is REG 92H same.
# Also need to enable GPIO ADC in REG 83H too ! Default value 80H 1000 0000 replace with 8C 1000 1100
i2cset -y -f 0 0x34 0x83 0x8C
i2cset -y -f 0 0x34 0x90 0x04
i2cset -y -f 0 0x34 0x92 0x04


reg83 can be modified without issues.
The problem is with reg90 and 92. they keep reseting to 0x02.

Any idea why this can be?

soenke

have you tried to read the measurement registers 64-67? Does the input drain current (to check if it is set to input). Be aware that the input voltage range of the adc is quite small and can be damaged easily.

If it is switched to input check if applying 1V changes any of the ADC or IO-registers.

PaddleStroke

Finally found the reason. The uboot driver of AXP209 is reseting the GPIO status on every boot...
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/power/axp209.c