Hi Matthijs,

Am 16.02.2017 um 04:43 schrieb Matthijs van Duin <matthijsvanduin@gmail.com>:

This might help :)


I have looked in the patch - but I am not sure if I understand it completely.

tca642x_reg_write():

http://git.goldelico.com/?p=gta04-uboot.git;a=blob;f=drivers/gpio/tca642x.c;h=fec5b834e2027cae3a65b5d7d703db00cf6d22ee;hb=refs/heads/letux-2016.11#l43

hence,
old code does:
write ((read() & ~ 0xff ) | configuration_reg) = write (configuration_reg)

new code does:
write ((read() & ~ 0 ) | configuration_reg) = write (read() | configuration_reg)
write (configuration_reg)

So you leave the existing inputs as inputs while changing the other settings and
only make them outputs *after* this sequence. Pins already configured as output
are left as they are. And new inputs are set up before changing anything.

Ok, this avoids glitches while switching the output polarity and value.

Is this interpretation right?

BTW: line 161 seems to be redundant.

And while I look at it, we could suggest to optimize out the i2c_read() if mask = 0xff in tca642x_reg_write()...

BR and thanks,
Nikolaus