i2c: meson: add detail calculation process for i2c duty cycle [1/1]

PD#SWPL-7197

Problem:
There is not detail calculation process for i2c duty cycle

Solution:
add detail calculation process for i2c duty cycle

Verify:
verified on x301

Change-Id: Ifc222acda3268f792f63e84c6dc3513d80568e19
Signed-off-by: Jian Hu <jian.hu@amlogic.com>
This commit is contained in:
Jian Hu
2019-04-15 16:32:04 +08:00
committed by Dongjin Kim
parent 6ad192c3c8
commit cf1f268b3d

View File

@@ -162,13 +162,31 @@ static void meson_i2c_write_tokens(struct meson_i2c *i2c)
/*
* Count = clk/freq = H + L
* Duty = H/(H + L) = 1/2 -- duty 50%
* 1. register desription
* in I2C_CONTROL_REG , n = [28:29][21:12], control the high level time
* n consists of 12bit, [21:12] is the low 10bit,
* [28:29] is the bit 11 and 12.
* in I2C_SLAVE_ADDRESS, m = [27:16], control the low level time,
* bit 28 enable the function
*
* 2.I2C controller internal characteristic
* H = n + delay
* L = 2m
* (H:high clock counts equals n + 15 clocks which
* cost by sampling and filtering
* L:low clock counts equals m multiply by 2)
*
* 3.high level and low level relationship:
* H/L = (n + 15)/2m = 1/1
* H+L = 2m + n +15 = Count
* Count = 166M/freq = 166M/100k
*
* =>
*
* n = Count/2 - delay
* m = Count/4
*
* n equals div_h, m equals div_l below
* Standard Mode : 100k
*/
static void meson_i2c_set_clk_div_std(struct meson_i2c *i2c)