summaryrefslogtreecommitdiff
path: root/drivers/i2c/designware_i2c.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-01-23 11:48:09 -0700
committerHeiko Schocher <hs@denx.de>2020-01-27 07:20:27 +0100
commitdd3c1602cf25b0be89d41d99ff33ef6d7d51f9f4 (patch)
treec27f9d9f558b4ef17e86344fb3483fc91ef45405 /drivers/i2c/designware_i2c.h
parent65190d15efffc0c3700e59654ead4ef149981ad4 (diff)
i2c: designware_i2c: Use an accurate bus clock instead of MHz
At present the driver uses an approximation for the bus clock, e.g. 166MHz instead of 166 2/3 MHz. This can result in small errors in the resulting I2C speed, perhaps 0.5% or so. Adjust the existing code to start from the accurate figure, even if later rounding reduces this accuracy. Update the bus speed code to work in KHz instead of MHz, which removes most of the error. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/designware_i2c.h')
-rw-r--r--drivers/i2c/designware_i2c.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h
index 569cab6fd3..5b477830d4 100644
--- a/drivers/i2c/designware_i2c.h
+++ b/drivers/i2c/designware_i2c.h
@@ -60,8 +60,8 @@ struct i2c_regs {
u32 comp_type;
};
-#define IC_CLK 166
-#define NANO_TO_MICRO 1000
+#define IC_CLK 166666666
+#define NANO_TO_KILO 1000000
/* High and low times in different speed modes (in ns) */
#define MIN_SS_SCL_HIGHTIME 4000