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.

Linux/TMS320DM8148: i2c #1 works in Linux - but not in u-boot ?

Guru 20755 points

Part Number: TMS320DM8148

Tool/software: Linux

Hello,

I have some issue in u-boot trying to access bus #1.

The function i2c_set_bus_num get stuck , I don't understand why.

Is anyone familiar with this ?

ret = i2c_set_bus_num(1);

<<------- never gets here .........
 if (ret)
     printf("Failure changing bus number (%d)\n", ret);

It hangs in i2c_set_bus_num->i2c_init->

......

    printf("i2c_init 8\n");

bus_initialized[current_bus] = 1;
if (readw (I2C_CON) & I2C_CON_EN) {
writew (0, I2C_CON);
udelay (50000);
}

writew(psc, I2C_PSC);
writew(scll, I2C_SCLL);
writew(sclh, I2C_SCLH);

/* own address */
writew (slaveadd, I2C_OA);
writew (I2C_CON_EN, I2C_CON);

    printf("i2c_init 9\n");  <<------ never get printed ..................

Regards,

Ran

  • Ran,

    Did you try to access I2C1 from Kernel? Is that working ?

    You might want to reset I2C module using I2C_SYSC and check once (just for testing).

    Thanks
  • Hi,

    Yes. It works from Linux, but not from u-boot.

    Maybe it is related to configuration in u-boot config file ?
    I tried some variations, but nothing helped yet.

    # define CONFIG_CMD_I2C
    # define CONFIG_HARD_I2C 1
    # define CONFIG_SYS_I2C_SPEED 100000
    # define CONFIG_SYS_I2C_SLAVE 1
    # define CONFIG_SYS_I2C_BUS 0
    # define CONFIG_SYS_I2C_BUS_SELECT 1
    # define CONFIG_DRIVER_TI81XX_I2C 1
    # define CONFIG_I2C_MULTI_BUS 1
    //CONFIG_I2C_MUX
    //CONFIG_I2C_MULTI_BUS

    Regards,
    Ran
  • Ran,

    Just a guess, this could be issue with not configuring I2C base address properly for your platform.

    Can you please check the PSC base & verify ?

    Thanks

  • Hi,

    from DM8148 datasheet:

    0x4802_8000 0x4802_8FFF 0x0802_8000 0x0802_8FFF 4KB I2C0 Peripheral Registers

    0x4802_9000 0x4802_9FFF 0x0802_9000 0x0802_9FFF 4KB I2C0 Support Registers

    0x4802_A000 0x4802_AFFF 0x0802_A000 0x0802_AFFF 4KB I2C1 Peripheral Registers

    0x4802_B000 0x4802_BFFF 0x0802_B000 0x0802_BFFF 4KB I2C1 Support Registers

    in /asm/arch-ti81xx/ i2c.h

    #define I2C_BASE1   0x48028000

    #define I2C_BASE2   0x4802A000

    #define I2C_BASE3   0x4819C000

    #define I2C_BUS_MAX 3

    u32 i2c_base = I2C_BASE1;

    #define I2C_DEFAULT_BASE    i2c_base

    So, it seems to match the datasheet offsets.

    I also re-checked pinmux, and can't find any problems in it:

    MUX_VAL(PINCNTL78, (IEN | IPU | FCN1 )) /* I2C[1]_SCL */\

    MUX_VAL(PINCNTL79, (IEN | IPU | FCN1 )) /* I2C[1]_SDA */\

    MUX_VAL(PINCNTL263, (IEN | IPU | FCN1 )) /* I2C[0]_SCL */\

    MUX_VAL(PINCNTL264, (IEN | IPU | FCN1 )) /* I2C[0]_SDA */\

    I also rechecked configuration file for ti814x:

    # define CONFIG_CMD_I2C

    # define CONFIG_HARD_I2C            1

    # define CONFIG_SYS_I2C_SPEED       100000

    # define CONFIG_SYS_I2C_SLAVE       1

    # define CONFIG_SYS_I2C_BUS     0

    # define CONFIG_SYS_I2C_BUS_SELECT  1

    # define CONFIG_DRIVER_TI81XX_I2C   1

    # define CONFIG_I2C_MULTI_BUS          1

     

    Maybe it's related to eeprom (but eeprom is in bus #0)

    #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
    #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
    #define CONFIG_SYS_I2C_MULTI_EEPROMS

    #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 7
    #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 20

    #define CONFIG_CMD_EEPROM

    Thank you for any idea.

    Ran

     

  • Hi,

    And one more ,

    After adding

    # define CONFIG_I2C_MULTI_BUS          1

    I can do from u-boot prompt:

    >i2c dev 0

    >i2c dev 2

    but on trying

    >i2c dev 1

    u-boot hangs...

    Can anyone try to see if getting the same issue with dm814x ?

    Regards,

    Ran

  • Hi Ran,

    Which software you are using? EZSDK/IPNC RDK etc? What is the u-boot version?

    Thanks
  • Hi,

    I am using RDK.

    I have issue with cpu that I can't use i2c 1, but can use i2c 0,2:

    These are the relevant modifications in my code for i2c1:

    /ti8148/evm.v


    __raw_writel(0x2, CM_ALWON_I2C_0_CLKCTRL);
    while(__raw_readl(CM_ALWON_I2C_0_CLKCTRL) != 0x2);

    + __raw_writel(0x2, CM_ALWON_I2C_1_CLKCTRL);
    + while(__raw_readl(CM_ALWON_I2C_1_CLKCTRL) != 0x2);
    +

    /include/configs/ti8148_evm.h


    # define CONFIG_SYS_I2C_BUS 0
    # define CONFIG_SYS_I2C_BUS_SELECT 1
    # define CONFIG_DRIVER_TI81XX_I2C 1
    +# define CONFIG_I2C_MULTI_BUS 1
    #endif

    But then on doing:
    #i2c dev 1

    It get stuck....

    I remember that it once worked. Is it some newer dm814x revision that is responsible for it ?

    In Linux it works fine.

    Regards,
    Ran
  • Ran Shalit said:

    I can do from u-boot prompt:

    >i2c dev 0

    >i2c dev 2

    but on trying

    >i2c dev 1

    u-boot hangs...

    Ran,

    We have i2c0 (0x48028000) and i2c2 (0x4819C000) enabled in u-boot by default. Regarding i2c1 (0x4802A000) you should enable it.

    Regards,
    Pavel

  • Hi Pavel

    I have enabled it as described in above message.

    Are there any more changes required for enabling  i2c1

    ?

    Regards

    Ran

  • pinmux, base address

    Also "i2c dev" is not available in ti81xx u-boot. Check the options available with i2c -h

    Regards,
    Pavel
  • Hi,

    I have solved this issue by forcing i2c before using it.
    The strange thing is that i2c is enabled at the startup in u-boot:

    void per_clocks_enable(void)
    {
    ....
    __raw_writel(0x2, CM_ALWON_I2C_1_CLKCTRL);
    while(__raw_readl(CM_ALWON_I2C_1_CLKCTRL) != 0x2);
    }

    Why is it get disabled in between before calling the routine from u-boot prompt (of u-boot) ? Not sure.

    But with this workaround it works.

    Thank you,
    Ran