So apparently it is a pretty simple process.:
1. map the address at i2c-1 either manually or using overlay. I used manually for now:
echo pcf8574 0x39 > /sys/class/i2c-adapter/i2c-1/new_device
now when we do dmesg | tail we sould see the following:
[ 7249.401502] pcf857x 1-0039: probed
[ 7249.401581] i2c i2c-1: new_device: Instantiated device pcf8574 at 0x39
Also it will show with the following command:
cat /sys/kernel/debug/gpio
GPIOs 0-31, platform/44e07000.gpio, gpio:
gpio-6 ( |cd ) in hi IRQ
gpio-12 ( |P9_20 ) in lo
gpio-13 ( |P9_19 ) in lo
GPIOs 32-63, platform/4804c000.gpio, gpio:
gpio-53 ( |? ) out lo
gpio-54 ( |? ) out lo
gpio-55 ( |? ) out lo
gpio-56 ( |? ) out lo
gpio-59 ( |clk_mcasp0 ) out lo
GPIOs 64-95, platform/481ac000.gpio, gpio:
GPIOs 96-127, platform/481ae000.gpio, gpio:
GPIOs 496-503, i2c/1-0039, pcf8574, can sleep: <===
GPIOs 504-511, i2c/1-0038, pcf8574, can sleep:
It should also appear as U now:
# i2cdetect -y -r 1
70: -- -- -- -- -- -- 76 --
2. Set up the gpio needed:
echo 497 > /sys/class/gpio/export
then cd into it and we should be able to do usual gpio stuff in there