From 110df547c4b21dde12f4ec30d92d4b0fd6b43c9a Mon Sep 17 00:00:00 2001 From: Jian Hu Date: Mon, 15 Apr 2019 16:32:04 +0800 Subject: [PATCH] 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 --- drivers/amlogic/i2c/i2c-meson-master.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/amlogic/i2c/i2c-meson-master.c b/drivers/amlogic/i2c/i2c-meson-master.c index fa19739..7ae90e0 100644 --- a/drivers/amlogic/i2c/i2c-meson-master.c +++ b/drivers/amlogic/i2c/i2c-meson-master.c @@ -156,13 +156,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) -- 2.7.4