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/AM3352: About I2C speed change dynamically

Part Number: AM3352

Tool/software: Linux

Hi Sir 

We used latest Linux SDK for development in AM3352 platform.

We would like to change i2c frequency at run time. And only saw the description in TRM but it is not clear about how to do in linux driver.

Does TI have any sample code or document how to modify linux driver to change i2c speed ? or any suggestion ?

please advise.

BR

Yimin

  • Hi Yimin,

    What is the current frequency of the i2c_scl pin you have? And what frequency you need to set there? Note that the maximum is 400KHz (fast mode). This frequency depends on the I2C module input clock (coming from device PRCM) and values in below registers:

    I2C_PSC
    I2C_SCLL
    I2C_SCLH

    Regards,
    Pavel
  • Hi Sir

    We need standard and high speed mode

    Q1. We only need to modify these three registers?

    Q2. Any steps or procedure to change it in Linux driver

            Can we modify it in run time or other method like insmod driver.   or directly modify the register to change frequency in Linux?

  • Yimin,

    The I2C speed (100K or 400K) is selected in kernel DTS file. Refer to AM335x TI EVM kernel DTS file for example.

    linux-kernel/arch/arm/boot/dts/am335x-evm.dts

    &i2c0 {
    status = "okay";
    clock-frequency = <400000>;
    }

    &i2c1 {
    status = "okay";
    clock-frequency = <100000>;
    }

    If you do not set up "clock-frequency" entry in DTS file, then 100K is used by default.

    If you need to switch between 100K and 400K in user space, you can directly write the needed values in I2C registers I2C_PSC, I2C_SCLL and I2C_SCLH. You can read/write registers values in user space with devmem2 or omapconf tools.

    You can dump the I2C_PSC, I2C_SCLL and I2C_SCLH registers values in both cases (100K and 400K) when set through the kernel DTS file, thus you will know what values to set there.

    "clock-frequency" DTS entry is parsed and I2C_PSC/I2C_SCLL/I2C_SCLH registers are setup in I2C kernel driver:

    linux-kernel/drivers/i2c/busses/i2c-omap.c

    Regards,
    Pavel
  • Hi Sir 

    thanks for your reply.

    Does it need any response time to change the frequency for CPU ? 

    If we often change the frequency of I2C dynamically, does it have any risk or side effect in Linux OS ?

    BR

    Yimin

  • Yimin,

    yimin bai34 said:
    Does it need any response time to change the frequency for CPU ? 

    I can not understand this question.

    yimin bai34 said:
    If we often change the frequency of I2C dynamically, does it have any risk or side effect in Linux OS ?

    I am not aware of such risk or side effect, I have not tested this on TI platform.

    Regards,
    Pavel