AM3358: u-boot to detect gpio-expander pcf8575 and mcp23017

Part Number: AM3358
Other Parts Discussed in Thread: PCF8575

Tool/software:

I need to drive some outputs which are connected on gpio-expander. i have PCF8575 and MCP23017 which works pretty well when linux is booted. i need to have ability to drive some of these pins on gpio-expander at bootup.

I am using following u-boot version

U-Boot SPL 2023.04-dirty (Oct 02 2024 - 17:58:22 +0530)
Trying to boot from MMC1


U-Boot 2023.04-dirty (Oct 02 2024 - 17:58:22 +0530)

CPU  : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black-pcf-mcp-r1
DRAM:  512 MiB
Core:  163 devices, 18 uclasses, devicetree: separate
WDT:   Started wdt@44e35000 with servicing every 1000ms (60s timeout)
NAND:  0 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... 
<ethaddr> not set. Validating first E-fuse MAC
Net:   eth2: ethernet@4a100000, eth3: usb_ether
Hit any key to stop autoboot:  0 

I have updated the device tree as below

       i2c1_pins: pinmux_i2c1_pins {
                pinctrl-single,pins = <
                        AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_INPUT_PULLUP, MUX_MODE2)   /*A16 - I2C1_SCLK*/
                        AM33XX_PADCONF(AM335X_PIN_SPI0_D1, PIN_INPUT_PULLUP, MUX_MODE2)    /*B16 - SPI1_SDA*/
                >;
        };


&i2c1 {
        pinctrl-names = "default";
        pinctrl-0 = <&i2c1_pins>;
        status = "okay";
        clock-frequency = <100000>;
        gpio@27 {
            //compatible = "microchip,mcp23017";
            compatible = "microchip,mcp23017";
            gpio-controller;
            #gpio-cells = <2>;
            reg = <0x27>;
        };
        pcf8575: gpio@20 {
            compatible = "nxp,pcf8575";
            reg = <0x20>;
            gpio-controller;
            #gpio-cells = <2>;
        };
};


I have enabled pcf8575 and mcp23017 from menuconfig

# CONFIG_HSDK_CREG_GPIO is not set
# CONFIG_KIRKWOOD_GPIO is not set
# CONFIG_LPC32XX_GPIO is not set
# CONFIG_MAX7320_GPIO is not set
CONFIG_MCP230XX_GPIO=y
# CONFIG_MSM_GPIO is not set
# CONFIG_MXC_GPIO is not set
# CONFIG_MXS_GPIO is not set
# CONFIG_NPCM_GPIO is not set
CONFIG_OMAP_GPIO=y
# CONFIG_CMD_PCA953X is not set
CONFIG_PCF8575_GPIO=y

when i probe i2c1 i expect it detects mcp and pcf which are at address 0x27 and 0x20, but i keep getting probe fail, please find what i see as below

=>  i2c dev 1
Setting bus to 1
=> i2c probe
Valid chip addresses:Timed out in wait_for_event: status=0000
Check if pads/pull-ups of bus are properly configured
Timed out in wait_for_event: status=0000
Check if pads/pull-ups of bus are properly configured
Timed out in wait_for_event: status=0000

the => dm tree commands shows

=> dm tree
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 rsa_mod_ex    0  [   ]   mod_exp_sw            |-- mod_exp_sw
 simple_bus    0  [ + ]   simple_bus            |-- ocp
 simple_bus    1  [ + ]   simple_bus            |   |-- l4_wkup@44c00000
 simple_bus    2  [   ]   simple_bus            |   |   |-- segment@0
 simple_bus    3  [   ]   simple_bus            |   |   |-- segment@100000
 simple_bus    4  [ + ]   simple_bus            |   |   `-- segment@200000
 simple_bus    5  [ + ]   ti_sysc               |   |       |-- target-module@0
 simple_bus    6  [ + ]   simple_bus            |   |       |   `-- prcm@0
 simple_bus    7  [   ]   simple_bus            |   |       |       |-- clocks
 clk           0  [   ]   fixed_clock           |   |       |       |   |-- clock-clk-32768
 clk           1  [   ]   fixed_clock           |   |       |       |   |-- clock-clk-rc32k
 clk           2  [   ]   fixed_clock           |   |       |       |   |-- clock-virt-19200000
 clk           3  [   ]   fixed_clock           |   |       |       |   |-- clock-virt-24000000
 clk           4  [   ]   fixed_clock           |   |       |       |   |-- clock-virt-25000000
 clk           5  [   ]   fixed_clock           |   |       |       |   |-- clock-virt-26000000
 clk           6  [   ]   fixed_clock           |   |       |       |   |-- clock-tclkin
 clk           7  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-dpll-ddr-m2-div2
 clk           8  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-dpll-per-m2-div4-wkupdm
 clk           9  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-dpll-per-m2-div4
 clk          10  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-clk-24mhz
 clk          11  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-clkdiv32k
 clk          12  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-l3-gclk
 clk          13  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-dpll-core-m4-div2
 clk          14  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-l4-rtc-gclk
 clk          15  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-l4hs-gclk
 clk          16  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-l3s-gclk
 clk          17  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-l4fw-gclk
 clk          18  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-l4ls-gclk
 clk          19  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-sysclk-div
 clk          20  [   ]   fixed_factor_clock    |   |       |       |   |-- clock-cpsw-125mhz-gclk
 clk          21  [   ]   fixed_factor_clock    |   |       |       |   `-- clock-mmc
 simple_bus    8  [   ]   ti_omap4_cm           |   |       |       |-- clock@0
 clk          22  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@38
 clk          23  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@1c
 clk          24  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@24
 clk          25  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@120
 clk          26  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@e8
 clk          27  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          28  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@18
 clk          29  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@14c
 clk          30  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@38
 clk          31  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@1c
 clk          32  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@24
 clk          33  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@120
 clk          34  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@e8
 clk          35  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          36  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@18
 clk          37  [   ]   ti_ctrl_clk           |   |       |       |   `-- clock@14c
 simple_bus    9  [ + ]   ti_omap4_cm           |   |       |       |-- clock@400
 clk          38  [ + ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          39  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@14
 clk          40  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@b0
 clk          41  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          42  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@14
 clk          43  [   ]   ti_ctrl_clk           |   |       |       |   `-- clock@b0
 simple_bus   10  [   ]   ti_omap4_cm           |   |       |       |-- clock@600
 clk          44  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          45  [   ]   ti_ctrl_clk           |   |       |       |   `-- clock@0
 simple_bus   11  [   ]   ti_omap4_cm           |   |       |       |-- clock@800
 clk          46  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          47  [   ]   ti_ctrl_clk           |   |       |       |   `-- clock@0
 simple_bus   12  [   ]   ti_omap4_cm           |   |       |       |-- clock@900
 clk          48  [   ]   ti_ctrl_clk           |   |       |       |   |-- clock@0
 clk          49  [   ]   ti_ctrl_clk           |   |       |       |   `-- clock@0
 simple_bus   13  [   ]   ti_omap4_cm           |   |       |       `-- clock@a00
 clk          50  [   ]   ti_ctrl_clk           |   |       |           |-- clock@0
 clk          51  [   ]   ti_ctrl_clk           |   |       |           `-- clock@0
 simple_bus   14  [ + ]   ti_sysc               |   |       |-- target-module@7000
 gpio          0  [ + ]   gpio_omap             |   |       |   `-- gpio@0
 simple_bus   15  [ + ]   ti_sysc               |   |       |-- target-module@9000
 serial        0  [ + ]   omap_serial           |   |       |   `-- serial@0
 simple_bus   16  [   ]   ti_sysc               |   |       |-- target-module@b000
 simple_bus   17  [   ]   ti_sysc               |   |       |-- target-module@d000
 simple_bus   18  [   ]   ti_sysc               |   |       |-- target-module@10000
 simple_bus   19  [   ]   simple_bus            |   |       |   `-- scm@0
 simple_bus   20  [   ]   simple_bus            |   |       |       `-- scm_conf@0
 simple_bus   21  [   ]   simple_bus            |   |       |           `-- clocks
 clk          52  [   ]   fixed_factor_clock    |   |       |               |-- clock-adc-tsc-fck
 clk          53  [   ]   fixed_factor_clock    |   |       |               |-- clock-dcan0-fck
 clk          54  [   ]   fixed_factor_clock    |   |       |               |-- clock-dcan1-fck
 clk          55  [   ]   fixed_factor_clock    |   |       |               |-- clock-mcasp0-fck
 clk          56  [   ]   fixed_factor_clock    |   |       |               |-- clock-mcasp1-fck
 clk          57  [   ]   fixed_factor_clock    |   |       |               |-- clock-smartreflex0-fck
 clk          58  [   ]   fixed_factor_clock    |   |       |               |-- clock-smartreflex1-fck
 clk          59  [   ]   fixed_factor_clock    |   |       |               |-- clock-sha0-fck
 clk          60  [   ]   fixed_factor_clock    |   |       |               |-- clock-aes0-fck
 clk          61  [   ]   fixed_factor_clock    |   |       |               `-- clock-rng-fck
 simple_bus   22  [   ]   ti_sysc               |   |       |-- target-module@35000
 simple_bus   23  [   ]   ti_sysc               |   |       `-- target-module@3e000
 simple_bus   24  [   ]   simple_bus            |   |-- interconnect@48000000
 simple_bus   25  [   ]   simple_bus            |   |   |-- segment@0
 simple_bus   26  [   ]   ti_sysc               |   |   |   |-- target-module@22000
 simple_bus   27  [   ]   ti_sysc               |   |   |   |-- target-module@24000
 simple_bus   28  [   ]   ti_sysc               |   |   |   |-- target-module@2a000
 simple_bus   29  [   ]   ti_sysc               |   |   |   |-- target-module@30000
 simple_bus   30  [   ]   ti_sysc               |   |   |   |-- target-module@38000
 simple_bus   31  [   ]   ti_sysc               |   |   |   |-- target-module@3c000
 simple_bus   32  [   ]   ti_sysc               |   |   |   |-- target-module@4c000
 gpio          1  [   ]   gpio_omap             |   |   |   |   `-- gpio@0
 simple_bus   33  [   ]   ti_sysc               |   |   |   |-- target-module@60000
 simple_bus   34  [   ]   ti_sysc               |   |   |   |-- target-module@80000
 simple_bus   35  [   ]   ti_sysc               |   |   |   |-- target-module@c8000
 simple_bus   36  [   ]   ti_sysc               |   |   |   `-- target-module@ca000
 simple_bus   37  [   ]   simple_bus            |   |   |-- segment@100000
 simple_bus   38  [   ]   ti_sysc               |   |   |   |-- target-module@9c000
 simple_bus   39  [   ]   ti_sysc               |   |   |   |-- target-module@a0000
 simple_bus   40  [   ]   ti_sysc               |   |   |   |-- target-module@a6000
 simple_bus   41  [   ]   ti_sysc               |   |   |   |-- target-module@a8000
 simple_bus   42  [   ]   ti_sysc               |   |   |   |-- target-module@aa000
 simple_bus   43  [   ]   ti_sysc               |   |   |   |-- target-module@ac000
 gpio          2  [   ]   gpio_omap             |   |   |   |   `-- gpio@0
 simple_bus   44  [   ]   ti_sysc               |   |   |   |-- target-module@ae000
 gpio          3  [   ]   gpio_omap             |   |   |   |   `-- gpio@0
 simple_bus   45  [   ]   ti_sysc               |   |   |   |-- target-module@cc000
 simple_bus   46  [   ]   ti_sysc               |   |   |   |-- target-module@d0000
 simple_bus   47  [   ]   ti_sysc               |   |   |   `-- target-module@d8000
 simple_bus   48  [   ]   simple_bus            |   |   |-- segment@200000
 simple_bus   49  [   ]   simple_bus            |   |   `-- segment@300000
 simple_bus   50  [   ]   ti_sysc               |   |       |-- target-module@0
 simple_bus   51  [   ]   ti_sysc               |   |       |-- target-module@2000
 simple_bus   52  [   ]   ti_sysc               |   |       |-- target-module@4000
 simple_bus   53  [   ]   ti_sysc               |   |       |-- target-module@e000
 simple_bus   54  [   ]   ti_sysc               |   |       `-- target-module@10000
 simple_bus   55  [   ]   simple_bus            |   |-- interconnect@47c00000
 simple_bus   56  [   ]   simple_bus            |   |   `-- segment@0
 simple_bus   57  [   ]   simple_bus            |   |-- interconnect@4a000000
 simple_bus   58  [   ]   simple_bus            |   |   `-- segment@0
 simple_bus   59  [   ]   ti_sysc               |   |       `-- target-module@100000
 simple_bus   60  [   ]   simple_bus            |   |-- interconnect@4b140000
 simple_bus   61  [   ]   simple_bus            |   |   `-- segment@0
 simple_bus   62  [   ]   ti_sysc               |   |-- target-module@49000000
 simple_bus   63  [   ]   ti_sysc               |   |-- target-module@49800000
 simple_bus   64  [   ]   ti_sysc               |   |-- target-module@49900000
 simple_bus   65  [   ]   ti_sysc               |   |-- target-module@49a00000
 simple_bus   66  [   ]   ti_sysc               |   |-- target-module@47810000
 i2c           0  [   ]   i2c_omap              |   |-- i2c@44e0b000
 pmic          0  [   ]   tps65217 pmic         |   |   `-- tps@24
 i2c           1  [ + ]   i2c_omap              |   |-- i2c@4802a000
 gpio          4  [   ]   mcp230xx              |   |   |-- gpio@27
 gpio          5  [   ]   gpio_pcf8575          |   |   `-- gpio@20
 i2c           2  [   ]   i2c_omap              |   |-- i2c@4819c000
 mmc           0  [ + ]   omap_hsmmc            |   |-- mmc@48060000
 blk           0  [ + ]   mmc_blk               |   |   |-- mmc@48060000.blk
 partition     0  [ + ]   blk_partition         |   |   |   |-- mmc@48060000.blk:1
 partition     1  [ + ]   blk_partition         |   |   |   `-- mmc@48060000.blk:2
 bootdev       0  [   ]   mmc_bootdev           |   |   `-- mmc@48060000.bootdev
 mmc           1  [ + ]   omap_hsmmc            |   |-- mmc@481d8000
 blk           1  [   ]   mmc_blk               |   |   |-- mmc@481d8000.blk
 bootdev       1  [   ]   mmc_bootdev           |   |   `-- mmc@481d8000.bootdev
 watchdog      0  [ + ]   omap3_wdt             |   |-- wdt@44e35000
 misc          0  [ + ]   ti-musb-wrapper       |   |-- usb@47400000
 usb           0  [ + ]   ti-musb-peripheral    |   |   |-- usb@47401000
 ethernet      1  [ + ]   usb_ether             |   |   |   `-- usb_ether
 bootdev       3  [   ]   eth_bootdev           |   |   |       `-- usb_ether.bootdev
 usb           0  [   ]   ti-musb-host          |   |   `-- usb@47401800
 ethernet      0  [ + ]   eth_cpsw              |   |-- ethernet@4a100000
 bootdev       2  [   ]   eth_bootdev           |   |   `-- ethernet@4a100000.bootdev
 simple_bus   67  [   ]   ti_sysc               |   |-- target-module@53100000
 simple_bus   68  [   ]   ti_sysc               |   |-- target-module@53500000
 simple_bus   69  [   ]   ti_sysc               |   `-- target-module@56000000
 clk          62  [   ]   fixed_clock           |-- clk_mcasp0_fixed
 bootstd       0  [   ]   bootstd_drv           |-- bootstd
 bootmeth      0  [   ]   bootmeth_distro       |   |-- distro
 bootmeth      1  [   ]   bootmeth_efi          |   |-- efi
 bootmeth      2  [   ]   bootmeth_pxe          |   |-- pxe
 bootmeth      3  [   ]   vbe_simple            |   `-- vbe_simple
 timer         0  [ + ]   omap_timer            `-- timer@0

I have read the registers to check if i2c1 clock is enabled and it is, plus i have tried with different versions of u-boot (2020.1 and with that update dtsi to have 0x158 and 0x15C as address for i2c1 pins)

Is there something i am missing, i assumed this would be seamless but seems something i dont follow.

on same setup i2c dev 0 and i2c probe gives me right data

=> i2c dev 0
Setting bus to 0
=> i2c probe
Valid chip addresses: 24 34 50

would appreciate some help here

-maheshG

  • Hi Mahesh,

    Can you confirm "DM_I2C" and "SYS_I2C_OMAP24XX" are enabled in the U-Boot config?

    Thanks,

    Anshu

  • yes its enabled

    #
    # I2C support
    #
    CONFIG_DM_I2C=y
    # CONFIG_DM_I2C_COMPAT is not set
    # CONFIG_I2C_SET_DEFAULT_BUS_NUM is not set
    # CONFIG_DM_I2C_GPIO is not set
    # CONFIG_SYS_I2C_FSL is not set
    # CONFIG_SYS_I2C_DW is not set
    # CONFIG_SYS_I2C_INTEL is not set
    # CONFIG_SYS_I2C_IMX_LPI2C is not set
    CONFIG_SYS_I2C_OMAP24XX=y
    # CONFIG_SYS_I2C_ROCKCHIP is not set
    # CONFIG_SYS_I2C_MVTWSI is not set
    CONFIG_SYS_I2C_BUS_MAX=3
    # CONFIG_I2C_MUX is not set

  • tapped SDA and SCLK of i2c0 and connected PCF8575 and MCP23017

    I was able to detect both of the added i2c GPIO expander on i2c0 probe

    => i2c probe                                                                                                          
    Valid chip addresses: 20 24 27 34 50

    20 being address for PCF8575 and 27 being that of MCP23017

    So this does mean there is something else on i2c1 which needs to be enabled, but i am not sure what that could be other than having i2c1 enabled from device tree

    Please advice

  • Hi Mahesh,

    I'm confused by the query. Are you asking what the other devices on the I2C1 bus are besides 0x20 and 0x27? What is the i2c probe output from this post?

    Looking at the original error message: https://git.ti.com/cgit/ti-u-boot/ti-u-boot/tree/drivers/i2c/omap24xx_i2c.c?h=ti-u-boot-2023.04#n250

    The while loop will decrement timeout until the loop breaks. Within the error message status = 0, see the issue below:

            /*
    		 * If status is still 0 here, probably the bus pads have
    		 * not been configured for I2C, and/or pull-ups are missing.
    		 */

    From the device tree, the Pull-Up resistors are enabled.

    Is the GPIO expander supplied power when the AM335x SoC is at U-Boot?

    You can debug this driver to check the values  of I2C_STAT_ROVR, I2C_STAT_XUDF, I2C_STAT_XRDY, I2C_STAT_RRDY, I2C_STAT_ARDY, I2C_STAT_NACK, and I2C_STAT_AL using printf.

    Best Regards,

    Anshu

  • Hello Anshu, Thanks for supporting on this.

    Answering few of your questions

    1. i2c1 probe returns error , see the messages i see

    =>  i2c dev 1
    Setting bus to 1
    => i2c probe
    Valid chip addresses:Timed out in wait_for_event: status=0000
    Check if pads/pull-ups of bus are properly configured
    Timed out in wait_for_event: status=0000
    Check if pads/pull-ups of bus are properly configured
    Timed out in wait_for_event: status=0000

    I have verified pulls-ups and they indeed exist (i have put device tree in my starting question)

    Since I2C1 probe were detecting the PCF8575, i move that on i2c0 (tapped i2c0 lines) and was able to detect PCF8575 at address 0x20, which does indicate the pcf8575 hardware is fine. (I have verified pcf 8575 also has pullups of 10K on them)

    I will check driver values stated and revert with that data

    Let me know if you need more info, thanks much! appreciate it!

    Thanks

  • Hi Mahesh,

    I'm not able to replicate the issue on my end since I don't have these IO expanders.

    Does Linux device tree and U-Boot device tree have the same definitions for the IO expanders?

    You could try removing just one (or both) IO expander to see if this I2C probe error still occurs. This may indicate the issue is independent of the IO expander itself.


    Additionally, you can add print statements in supporting U-Boot drivers to see how these macros values are being defined and changing.

    Feel free to provide an update when needed.

    Best Regards,

    Anshu