hi TI friends,
I need to modify the frequency.(400KHz ->100KHz or 384KHz)
I find the following info, but I still have no idea about the modification.
http://www.cnblogs.com/cslunatic/archive/2013/06/14/3135265.html and sprugx8.pdf
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.
hi TI friends,
I need to modify the frequency.(400KHz ->100KHz or 384KHz)
I find the following info, but I still have no idea about the modification.
http://www.cnblogs.com/cslunatic/archive/2013/06/14/3135265.html and sprugx8.pdf
Are you using Linux PSP? if yes, you can set the i2c frequency from bootargs after booting u-boot using i2c_bus=<instance_id>,<frequency> e.g. i2c_bus=3,400
hi Yogesh,
thanks for your reply...
I have two more question
1. if I want to change that in kernel, how could I do that...
2. what is the step between each frequency? the previous value of 400 is 393 or 382?
For #1, It is done when i2c interface is registered through board specific file, value in bold below can be modified e.g.
static int __init ti816x_evm_i2c_init(void)
{
omap_register_i2c_bus(1, 100, ti816x_i2c_boardinfo0,
ARRAY_SIZE(ti816x_i2c_boardinfo0));
omap_register_i2c_bus(2, 100, ti816x_i2c_boardinfo1,
ARRAY_SIZE(ti816x_i2c_boardinfo1));
return 0;
}
For #2, I dont know the exact step between each frequncy but what I understand is the i2c frequency value depends on I2C_PSC, I2C_SCLL and I2C_SCLH you can refer this section of TRM "11.2.14 How to Program I2C" for details.
hi Yogosh,
thanks for your reply.
I have one more question.
1. how do I know the current value of I2C_PSC, I2C_SCLL and I2C_SCLH? which file fill the value?
Address offsets are mentioned in TRM section "11.3 I2C Registers". Map I2C register space to Linux user space or kernel space as per your requirement and access them to read the values.
If you are using DVR RDK you may use dvr_rdk/bin/ti816x/bin/mem_rdwr.out which should help you to read write these registers from Linux user space.
hello Yogesh,
I found that the driver calculated these value like I2C_PSC, I2C_SCLL and I2C_SCLH automatically by some rules as below
11.2.14.1 Module Configuration Before Enabling the Module
1. Program the prescaler to obtain an approximately 12-MHz I2C module clock (I2C_PSC = x; this
value is to be calculated and is dependent on the System clock frequency).
2. Program the I2C clock to obtain 100 Kbps or 400 Kbps (SCLL = x and SCLH = x; these values are
to be calculated and are dependent on the System clock frequency).
3. Configure its own address (I2C_OA = x) - only in case of I2C operating mode (F/S mode).
4. Take the I2C module out of reset (I2C_CON:I2C_EN = 1).
So we try to modify as following
static int __init ti816x_evm_i2c_init(void)
{
omap_register_i2c_bus(1, 284, ti816x_i2c_boardinfo0,
ARRAY_SIZE(ti816x_i2c_boardinfo0));
omap_register_i2c_bus(2, 284, ti816x_i2c_boardinfo1,
ARRAY_SIZE(ti816x_i2c_boardinfo1));
return 0;
}
and we really got the 284Mhz.
My question is
"we can directly modify the value to our desired value", right?
Yes you can set it to desired value, provided all devices connected to this i2c instance can support that frequqncy.