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.

TDA4VM: TDA4: I2C clock frequency is inaccurate

Part Number: TDA4VM


Hi TI support team,

     Our TDA4 is on a custom board and the current SDK version is 7.2.
     When I set the clock frequency to 100K in the MCU_I2C0 device tree, the oscilloscope shows the frequency of MUC_I2C0_SCL is 554.3K.
     It does not meet my expectations.
     However, The clock frequency works fine in SDK 6.2.


     The following code is the partial code in function omap_i2c_init(struct omap_i2c_dev *omap) in i2c-omap.c
     

     if (!(omap->flags & OMAP_I2C_FLAG_SIMPLE_CLOCK)) {
 
         /*
          * HSI2C controller internal clk rate should be 19.2 Mhz for
          * HS and for all modes on 2430. On 34xx we can use lower rate
          * to get longer filter period for better noise suppression.
          * The filter is iclk (fclk for HS) period.
          */
         if (omap->speed > 400 ||
                    omap->flags & OMAP_I2C_FLAG_FORCE_19200_INT_CLK)
             internal_clk = 19200;
         else if (omap->speed > 100)
             internal_clk = 9600;
         else
             internal_clk = 4000;
         fclk = clk_get(omap->dev, "fck");
         if (IS_ERR(fclk)) {
             error = PTR_ERR(fclk);
             dev_err(omap->dev, "could not get fck: %i\n", error);
 
             return error;
         }
         fclk_rate = clk_get_rate(fclk) / 1000;
         clk_put(fclk);
 
         /* Compute prescaler divisor */
         psc = fclk_rate / internal_clk;
         psc = psc - 1;

     I think the SYS_CLK frequency is wrong.
     On the line 23,  fclk_rate = clk_get_rate(fclk) / 1000;
     I found clk_get_rate(fclk) returns 16,000,000 instead of 96,000,000, which makes the caculation of psc incorrect.
     psc = fclk_rate / internal_clk - 1 = 16000 / 4000 -1 = 3

     The following table is the I2C register value table.
      

   The following code is the device tree we set for MCU_I2C0.
   

&mcu_i2c0 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&mcu_i2c0_pmic_pins_default>;
    clock-frequency = <100000>;
};

mcu_i2c0: i2c@40b00000 {
    compatible = "ti,j721e-i2c", "ti,omap4-i2c";
    reg = <0x0 0x40b00000 0x0 0x100>;
    interrupts = <GIC_SPI 852 IRQ_TYPE_LEVEL_HIGH>;
    #address-cells = <1>;
    #size-cells = <0>;
    clock-names = "fck";
    clocks = <&k3_clks 194 0>;
    power-domains = <&k3_pds 194 TI_SCI_PD_EXCLUSIVE>;
};

   BTW, We also checked the SOC_I2C.
   Its frequency is correct.

Best regards,

Elsun Liu

  • BTW, We also checked the SOC_I2C.
       Its frequency is correct.

    Which instance is this? Sorry i did not understand that above? Do you mean main_i2c0?

    Have you tried the same on TDA4VM TI Board? Is that showing the same behavior as seen on your custom board?

    - Keerthy

  • Hi Keerthy,
        Yes, the SOC_i2c0 means MAIN_I2C0.
         I also measured the MCU_I2C0 and MAIN_I2C0 on TDA4VM TI Board and it shows the same behavior as the custom board.
        The following pictures are the boot log and the screenshots of the oscilloscope on TDA4VM TI Board.
         I measured MCU_i2c0 (bus0) for 100 KHZ and MAIN_I2C0(bus 3)  for 400 KHZ.
         
         The MCU_i2c0(bus 0) screenshot on the oscilloscope.
          
          The MAIN_I2C0(bus 3) screenshots on the oscilloscope.
          
    Best regards,
    Elsun Liu

  • Hi Elsun Liu,

    I have reproduced the issue.

    You can check that clock frequency is at 16MHz instead of 96 MHz. You can check it by using k3conf tool:

    k3conf dump clock 194

    root@j7-evm:/opt/vision_apps# k3conf dump clocks 194
    |--------------------------------------------------------------------------------|
    | VERSION INFO |
    |--------------------------------------------------------------------------------|
    | K3CONF | (version v0.1-45-g79f007c built Sat Apr 10 00:45:34 UTC 2021) |
    | SoC | J721E SR1.0 |
    | SYSFW | ABI: 3.1 (firmware version 0x0015 '21.1.1--v2021.01a (Terrific Lla)') |
    |--------------------------------------------------------------------------------|

    |-----------------------------------------------------------------------------------|
    | Device ID | Clock ID | Clock Name | Status | Clock Frequency |
    |-----------------------------------------------------------------------------------|
    | 194 | 0 | DEV_MCU_I2C0_PISYS_CLK | CLK_STATE_READY | 16000000 |
    | 194 | 1 | DEV_MCU_I2C0_PISCL | CLK_STATE_READY | 0 |
    | 194 | 2 | DEV_MCU_I2C0_CLK | CLK_STATE_READY | 166666666 |
    | 194 | 3 | DEV_MCU_I2C0_PORSCL | CLK_STATE_READY | 0 |
    |-----------------------------------------------------------------------------------|

    If we check the main_i2c0 that is correctly at 96MHz.

    root@j7-evm:/opt/vision_apps# k3conf dump clocks 187
    |--------------------------------------------------------------------------------|
    | VERSION INFO |
    |--------------------------------------------------------------------------------|
    | K3CONF | (version v0.1-45-g79f007c built Sat Apr 10 00:45:34 UTC 2021) |
    | SoC | J721E SR1.0 |
    | SYSFW | ABI: 3.1 (firmware version 0x0015 '21.1.1--v2021.01a (Terrific Lla)') |
    |--------------------------------------------------------------------------------|

    |-------------------------------------------------------------------------------|
    | Device ID | Clock ID | Clock Name | Status | Clock Frequency |
    |-------------------------------------------------------------------------------|
    | 187 | 0 | DEV_I2C0_PISYS_CLK | CLK_STATE_READY | 96000000 |
    | 187 | 1 | DEV_I2C0_PISCL | CLK_STATE_READY | 0 |
    | 187 | 2 | DEV_I2C0_CLK | CLK_STATE_READY | 125000000 |
    |-------------------------------------------------------------------------------|


    Thanks for bringing this to up. I am raising a bug internally & will follow up.

    Best Regards,
    Keerthy

  • Hi Elsun Liu,

    With 8.0 SDK this problem is no longer observed. Could you please check that?

    - Keerthy

  • Hi Keerthy,

         Can you give the patch for resolving i2c frequency problem? 

    Best regards,
    Elsun Liu

  • Hi Elsun Liu,

    I do not have a patch but could you use this attached tispl.bin? Just replace the tispl.bin with 7.3 based tispl.bin
    & let me know if that helps. The fix is most likely in the DM firmware binary.

    I am attaching the DM firmware binary as well. You could replace that binary in the $PSDKLA_PATH/board-support/prebuilt-images

    Then you can build 7.3 SDK tispl.bin using the attached DM firmware binary.

    Let me know if that works for you.

    8.0-bin.zip
    - Keerthy


  • Hi Keerthy,

         Do you mean that only tispl.bin based on 7.3 is used to replace tispl.bin on the TDA4VM TI board while other files are still based on 7.2?

    Best regards,

    Elsun Liu

  • Do you mean that only tispl.bin based on 7.3 is used to replace tispl.bin on the TDA4VM TI board while other files are still based on 7.2?

    Okay. So 8.0 SDK has the issue fixed. The fix is most likely in the DM firmware binary contained in the tispl.bin.

    So I am requesting you to keep all the binaries same as your SDK 7.2 & change the tispl.bin attached in the previous reply zip folder
    & check if the mcu_i2c clock is fixed.

    - Keerthy

  • Hi Keerthy,

        I tried the solution you mentioned and it worked.
        Thank you for your help.

    Best regards,

    Elsun Liu