This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Tristating i2c0 bus in am335x BBB

Dear Ti E2E community,

I need to tristate the i2c0 bus, could you please let me know how this can be done in uboot & kernel source code am using ti sdk 7

Could you please let me know how i2c-tools can be used for veirfying i2c transcation after it is configured in device tree

Kindly do the needful as early as possible

Thanks in adavnce

  • Hi Srini,

    Why do you want to tristate the i2c bus ?

    http://processors.wiki.ti.com/index.php/I2C_Tips

    http://elinux.org/Interfacing_with_I2C_Devices#i2c-tools

  • Thanks a lot Titus for your quick replies,

    1) In my custom board PMIC TPS65217C is connected to i2c-1 bus, so now in beaglebone black it is connected to i2c-0 bus & now provision is made to connect the same i2c-1 bus in beaglebone black but since both buses are connected to same PMIC so verification can't be done inorder to verify i2c-1 bus to PMIC, so I need to tristate this i2c-0 bus could you please let me know how this can be done

    as am searching fro this from yesterday no clues yet in uboot source code or kernel source code can be this be modified in dts hope it should be easier , if this is the case could you please let me know how this can be done in dts

    2) I downloaded i2c-tools & cross compiled (http://www.lm-sensors.org/wiki/I2CTools) & modified the makefile  also to CC ?= arm-linux-gnueabihf- of  i2c-tools-3.1.1.tar.bz2,

    srinivasan@tata-HP-Elite-7100-Microtower-PC:~/TUNSTALL/board-support/i2c-tools-3.1.1$ sudo make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm

    I copied the exes in the rootfs/usr/bin/, but when I am using the i2c utiliites am facing the below errors

    root@beaglebone:~# i2cdetect 0
    -sh: /usr/bin/i2cdetect: cannot execute binary file: Exec format error
    root@beaglebone:~#

    Kindly do the needful as early as possible

    Many Thanks once gaian for your quick responses

  • I think, you have to change the below code for i2c1.

    board/ti/am335x/mux.c

    board/ti/am335x/board.c

    enable_i2c1_pin_mux();
    
    void enable_i2c1_pin_mux(void)
    {
        configure_module_pin_mux(i2c1_pin_mux);
    }

    1780.board.c

    3806.mux.c

  • Hi TiTus,

    Thanks for your timley support, as you suggested

    1) I have commented i2c0 pin configuration & have enabled i2c1 configuration,
    since this u-boot source for this platform, before booting it is trying to read the board id & other am335x header information from eeprom via i2c0 & then proceeds for further booting
    In my custom board eeprom is configured to I2C1 bus, could you please let me know some where else also we need to change the bus num from 0 to 1 towards eeprom side ie., in core driver file, could you please let me know the path of i2c driver related files in uboot for am335x platform(beaglebone black) where the bus num needs to be changed

    U-Boot SPL 2013.10-00189-g78d8ebd-dirty (Nov 28 2014 - 18:02:09)
    i2c_probe: pads on bus 0 probably not configured (status=0x10)
    Could not probe the EEPROM; something fundamentally wrong on the I2C bus.
    Could not get board ID.
    i2c_probe: pads on bus 0 probably not configured (status=0x10)
    Could not probe the EEPROM; something fundamentally wrong on the I2C bus.
    Could not get board ID.
    Unknown board, cannot configure pinmux.### ERROR ### Please RESET the board ###

    2) As since my custom board is under fabrication, Hardware changes for I2C1 (ie., i2c1 scl& sda lines are shorted to i2c0 sda & scl)is done in beaglebone black only as of now, And as per my understanding even after commenting out i2c0 configuration, I Hope by default the i2c0 mode would be changed to gpio by default(since am not sure how this is in am335x processor, could you please confirm whether this is true or not in case of Am335x, if this is the case then could you please let me know whether by default this gpio pin is in high impedance state or not, if not could you please let me know how & where to configure this gpio pin to high impedance state) in uboot source code 

    3)Could you please let me know as before booting it is trying to read the board id & other am335x header information from eeprom, where this board id & other am335x header information are being written to eeprom before trying to read the source code path, if it is being written to eeprom via i2c0 then this also needs to be changed to i2c1 (please also let me know which i2c driver code path needs to be changed for this as well)

    Kindly do the needful as early as possible, if I get this i2c1 bus up then I feel I would get uboot up & running in my custom board as well

    Many Many Thanks a lot in advance for all your support so far & henceforth

  • Hi Srini,

    Have you modified the BBB hardware for I2C1 ?

    Then, how did you this ?

    Confirm that EEPROM & PMIC IC are connected to the I2C bus 1.

    http://processors.wiki.ti.com/index.php/AM335x_General_Purpose_EVM_HW_User_Guide#Configuration.2FSetup

    U-Boot SPL 2013.10-00189-g78d8ebd-dirty (Nov 28 2014 - 18:02:09)
    i2c_probe: pads on bus 0 probably not configured (status=0x10)
    Could not probe the EEPROM; something fundamentally wrong on the I2C bus.
    Could not get board ID.
    i2c_probe: pads on bus 0 probably not configured (status=0x10)
    Could not probe the EEPROM; something fundamentally wrong on the I2C bus.
    Could not get board ID.
    Unknown board, cannot configure pinmux.### ERROR ### Please RESET the board ###

    I think, the above error is due to the following lines of code snippet.

    Please ensure that CPLD had connected with I2C bus 1.

    /* CPLD registers */
    #define I2C_CPLD_ADDR	0x35
    #define CFG_REG		0x10
    
    static unsigned short detect_daughter_board_profile(void)
    {
    	unsigned short val;
    
    	if (i2c_probe(I2C_CPLD_ADDR))
    		return PROFILE_NONE;
    
    	if (i2c_read(I2C_CPLD_ADDR, CFG_REG, 1, (unsigned char *)(&val), 2))
    		return PROFILE_NONE;
    
    	return (1 << (val & PROFILE_MASK));
    }
    

  • Hi Srini,

    I think, the I2C bus no is configured to '1' by default.

    We can change this i2c bus through "i2c_set_bus_num"

    If you interchanged the i2c 0 to i2c 1 in hardware then it should work.

    Try to use the following lines.

    board/ti/am335x/board.c

    	/* Initalize the board header */
    //	enable_i2c0_pin_mux();
    	enable_i2c1_pin_mux();
    	i2c_set_bus_num(1);
    	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
    #ifndef CONFIG_NOR_BOOT
    	if (read_eeprom() < 0)
    		puts("Could not get board ID.\n");
    #endif
    
    	/* Check if baseboard eeprom is available */
    	if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
    		puts("Could not probe the EEPROM; something fundamentally "
    			"wrong on the I2C bus.\n");
    	}
    
    	/* read the eeprom using i2c */
    	if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)&header,
    							sizeof(header))) {
    		puts("Could not read the EEPROM; something fundamentally"
    			" wrong on the I2C bus.\n");
    	}
  • Thanks a lot for your quick replies & updates Titus,

    1) The hardware changes is we have just shorted i2c0 scl & sda lines to i2c1 scl & sda lines in begalebone black

    2) As you suggested I did the following changes, in ti/am335x/board.c

    const struct dpll_params *get_dpll_ddr_params(void)
    {
    struct am335x_baseboard_id header;

    //enable_i2c0_pin_mux();

    enable_i2c1_pin_mux();

    i2c_set_bus_num(1);

    // i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
    if (read_eeprom(&header) < 0)
    puts("Could not get board ID.\n");

    if (board_is_evm_sk(&header))
    return &dpll_ddr_evm_sk;
    else if (board_is_bone_lt(&header))
    return &dpll_ddr_bone_black;
    else if (board_is_evm_15_or_later(&header))
    return &dpll_ddr_evm_sk;
    else
    return &dpll_ddr;
    }

    U-Boot SPL 2013.10-00189-g78d8ebd-dirty (Dec 01 2014 - 15:53:53)
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the slaveadd is 1
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the CURRENT BUS is 1
    EOFFFFFFFFFFFFFFFFFFFF i2c_inttttttttttttttttt function, the slaveadd is 1
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    Timed out in wait_for_bb: status=1000
    Could not probe the EEPROM; something fundamentally wrong on the I2C bus.
    Could not get board ID.
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    Timed out in wait_for_bb: status=1000
    Could not probe the EEPROM; something fundamentally wrong on the I2C bus.
    Could not get board ID.
    Unknown board, cannot configure pinmux.### ERROR ### Please RESET the board ###

    I donnu why I'm getting this timeout error, could you please do the needful in resolving this issue as early as possible

    Could you please correct me if am progressing in any wrong direction

    Many Thanks in advance

  • Hi Srini,

    The problem could be from hw side, so you can try to use AM335x starterware i2c example code through CCS with JTAG.

    http://software-dl.ti.com/dsps/dsps_public_sw/am_bu/starterware/latest/index_FDS.html

  • Is there any ways to bypass eeprom reading & get the u-boot prompt

    If so, could you please let me know the appropriate code changes that needs to be done??

    awaiting for your replies,

    Kindly do the needful as early as possible

  • Hi TiTus,

    Thanks a lot for your support, finally I got working.. & finally got all my answers for this issue, it was hardware issue the i2c0 scl was connected to i2c1 sda & i2c1 scl connected to i2c0 sda ;)

    My code changes finally as below

    1) arch/arm/include/asm/arch-am335x/i2c.h 

    //#define I2C_DEFAULT_BASE I2C_BASE1 // commented by srini
    #define I2C_DEFAULT_BASE I2C_BASE2

    2)/u-boot-2013.10-ti2013.12.01/drivers/i2c/omap24xx_i2c.c
    static unsigned int __attribute__((section (".data"))) current_bus = 1;

    3) board/ti/am335x/board.c

    const struct dpll_params *get_dpll_ddr_params(void)
    {
    struct am335x_baseboard_id header;

    //enable_i2c0_pin_mux();

    enable_i2c1_pin_mux();

    // i2c_set_bus_num(1);

    i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);

    4)board/ti/am335x/mux.c
    /*ADDED BY SRINI*/
    void enable_i2c1_pin_mux(void)
    {
    configure_module_pin_mux(i2c1_pin_mux);
    }

    U-Boot SPL 2013.10-00189-g78d8ebd-dirty (Dec 01 2014 - 19:10:36)
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the I2C_BASE_ADDRESSS = 4802a0a4
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the speed = 100000, slaveadd = 1
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the CURRENT BUS is 1
    EOFFFFFFFFFFFFFFFFFFFF i2c_inttttttttttttttttt function, the slaveadd is 1
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    INISDEEEEEEEEEEEEEEEEEEE i2c_writeeeeeeeeee function
    reading args
    spl: error reading image args, err - -1
    reading u-boot.img
    reading u-boot.img


    U-Boot 2013.10-00189-g78d8ebd-dirty (Dec 01 2014 - 19:10:36)

    I2C: INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the I2C_BASE_ADDRESSS = 4802a0a4
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the speed = 100000, slaveadd = 1
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the CURRENT BUS is 1
    EOFFFFFFFFFFFFFFFFFFFF i2c_inttttttttttttttttt function, the slaveadd is 1
    ready
    DRAM: 512 MiB
    NAND: 0 MiB
    MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
    *** Error - No Valid Environment Area found
    *** Warning - bad CRC, using default environment

    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the I2C_BASE_ADDRESSS = 4802a0a4
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the speed = 100000, slaveadd = 1
    INSIDEEEEEEEEEEE i2c_inttttttttttttttttt function, the CURRENT BUS is 1
    EOFFFFFFFFFFFFFFFFFFFF i2c_inttttttttttttttttt function, the slaveadd is 1
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    Net: <ethaddr> not set. Validating first E-fuse MAC
    INSIDE read_eeprom functionnnnnnnnnnnnnnnnnn
    INSIDEEEEEEEEEEEEEEEEE I2C_PROBEEEEEEEEEEEEEE FUNCTION
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    Could not get PHY for cpsw: addr 0
    cpsw, usb_ether
    Hit any key to stop autoboot: 0
    U-Boot#
    U-Boot# i2c help
    i2c - I2C sub-system

    Usage:
    i2c crc32 chip address[.0, .1, .2] count - compute CRC32 checksum
    i2c dev [dev] - show or set current I2C bus
    i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device
    i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device
    i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)
    i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)
    i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)
    i2c probe [address] - test for and show device(s) on the I2C bus
    i2c read chip address[.0, .1, .2] length memaddress - read to memory
    i2c write memaddress chip address[.0, .1, .2] length - write memory to i2c
    i2c reset - re-init the I2C Controller
    i2c speed [speed] - show or set I2C bus speed
    U-Boot# i2c dev
    Current bus is 1
    U-Boot# i2c md 0x50 0.2 0x10
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    0000: aa 55 33 ee 41 33 33 35 42 4e 4c 54 30 30 43 30 .U3.A335BNLT00C0
    U-Boot# i2c md 0x24 0.1 0x1
    INSIDEEEEEEEEEEE i2c_readddddddddddddddddddddddddddddd function
    0000: e2 .
    U-Boot#

    Many Thanks in advance

  • Sounds good.

    Thanks for your update.