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.

How to change I2C clock in kernel

Other Parts Discussed in Thread: DM385

Hi Pavel,

During the boot up ,we can see the I2C clock is 100kHz.But we want the clock more higher.

Do you tell me where to change the i2c clock?

Thank you .

"omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz"

BR

Bob

  • Bob,

    Have you tried to increase the frequency using the clock framework?

    http://processors.wiki.ti.com/index.php/TI81XX_PSP_PM_CLOCK_FRAMEWORK_User_Guide#Change_Clock_Rate

    BR
    Pavel
  • Hi Pavel,
    No,I haven't.Would you tell me how to do ?

    Thank you .
    BR
    Bob
  • Hi Pavel,
    Do like this?
    static inline void ti814x_enable_i2c2(void)
    {
     struct clk *fclk;
     unsigned long rate,rounded_rate;
     struct clk *clk;
     int ret;
     
     fclk = clk_get(NULL, "i2c3_fck");
     if (!IS_ERR(fclk))
      clk_enable(fclk);
     else
      printk(KERN_WARNING "clk get on i2c3 fck failed\n");

     rate = clk_get_rate(clk);
     rounded_rate = clk_round_rate(clk, 400000);
     ret = clk_set_rate(clk, rounded_rate);
    }


    BR
    Bob

  • Bob,

    bob lee said:
    "omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz"

    This is the clock frequency at the i2c2_scl pin. While i2c3_fck is 48MHz and i2c3_ick is 100MHz. So you need to change the frequency at the i2c2_scl pin from 100KHz to 400KHz?

    BR
    Pavel

  • Pavel Botev said:
    bob lee
    "omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz"

    In case this is what you want (400KHz on i2c-3 i2c2_scl pin), you can modify the linux kernel as below:

    linux-kernel/arch/arm/mach-omap2/board-ti8148evm.c

    static void __init ti814x_evm_i2c_init(void)
    {
        /* There are 4 instances of I2C in TI814X but currently only one
         * instance is being used on the TI8148 EVM
         */
        omap_register_i2c_bus(1, 100, ti814x_i2c_boardinfo,
                    ARRAY_SIZE(ti814x_i2c_boardinfo));
        omap_register_i2c_bus(3, 400, ti814x_i2c_boardinfo1,   -----> change second argument from 100 to 400
                    ARRAY_SIZE(ti814x_i2c_boardinfo1));

    }

    Thus during boot up I have:

    omap_i2c omap_i2c.3: bus 3 rev4.0 at 400 kHz

    For more information regarding how to calculate the frequency on the I2C SCL pin (100KHz for standard mode and 400KHz for fast mode) see the below resources:

    DM814x TRM, sections 15.2.8 Prescaler (SCLK/ICLK) and 15.2.14.1 Module Configuration Before Enabling the Module

    linux-kernel/arch/arm/plat-omap/i2c.c file, function omap_register_i2c_bus(int bus_id, u32 clkrate, struct i2c_board_info const *info, unsigned len)

    Regards,
    Pavel

  • Hi Pavel,

    I have set it sucCessfully according to your post.

    Thank you.

    BR

    Bob

  • bob lee said:
    I have set it sucCessfully according to your post.

    Then why you click on the "Suggest Answer" button instead of the "Verify Answer" button???

  • Hi Pavel,

    Sorry,I have changed "Suggest Answer" button to the "Verify Answer" button.

    BR
    Bob
  • Hi Pavel,

                 Can you please tell me i2c4 clock (i2c3 according to dm385 datasheet, i2c4 as per kernel).Thanks in advance.

    Regards

    Bhargav

  • Hi Bhargav,

    What exactly do you want to do with the i2c4 clock ?

    As Pavel pointed out, did you try playing around the below function in the board file ?

    omap_register_i2c_bus(3, 400, ti814x_i2c_boardinfo1, -----> change second argument from 100 to 400
    ARRAY_SIZE(ti814x_i2c_boardinfo1));
  • Hi Bhargav,

    For your i2c4 clock case, you need to try the following:
    omap_register_i2c_bus(4, 100/400, ti814x_i2c_boardinfo1, -----> 100/400
    ARRAY_SIZE(ti814x_i2c_boardinfo1)); -----> Make sure correct Board info is mentioned, in terms of i2c slaves connected to bus i2c4
  • Hi Dwarakesh,

    I am trying to enable i2c4. when i am doing. everything is fine but slave address not detected. cannot do read/write operations.

    root@dm814x-evm:~# i2cdetect -l
    i2c-4 i2c OMAP I2C adapter I2C adapter

    root@dm814x-evm:~i2cdetect -r -y 4
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

    omap_register_i2c_bus(4, 400, ti814x_i2c_boardinfo,
    ARRAY_SIZE(ti814x_i2c_boardinfo));

    in structure "ti814x_i2c_boardinfo" ,i added slave address properly.
    I changed the register value 0x48181568 from 0x00030000 to 0x00000002.

    Not detecting Slave address

    Regards
    Bhargav.
  • Hi Bhargav,

    1. Have you made sure i2c pinmux are taken care ? Configuring the GPIO pins to which i2c4 slave is connected as i2c clock and i2c data ?
    2. To which ball of pins of DM385 is your i2c4 connected ?