summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeta Zur <neta@marvell.com>2017-06-18 14:04:24 +0300
committerKostya Porotchkin <kostap@marvell.com>2017-06-18 14:55:58 +0300
commit44114c6c36b85cba804301cc8b90034f55324c0d (patch)
tree57ecd3564f3045f3252e3b4e4bfb1e199a265de5
parentcb4972fbbbd9fdc65ea02f8602457084a70f757e (diff)
i2c: a8k: add comment which describes baudrate settings
Change-Id: I6b62e8ff3089542bd9d1c49ff7f85eab98533deb Signed-off-by: Grzegorz Jaszczyk <jaz@semihalf.com> Signed-off-by: Neta Zur <neta@marvell.com> Reviewed-on: http://vgitil04.il.marvell.com:8080/40574 Tested-by: iSoC Platform CI <ykjenk@marvell.com> Reviewed-by: Kostya Porotchkin <kostap@marvell.com>
-rw-r--r--drivers/marvell/i2c/a8k_i2c.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/marvell/i2c/a8k_i2c.c b/drivers/marvell/i2c/a8k_i2c.c
index 1356fc07..c4ef1441 100644
--- a/drivers/marvell/i2c/a8k_i2c.c
+++ b/drivers/marvell/i2c/a8k_i2c.c
@@ -248,6 +248,20 @@ static int marvell_i2c_address_set(uint8_t chain, int command)
return 0;
}
+/*
+ * The I2C module contains a clock divider to generate the SCL clock.
+ * This function calculates and sets the <N> and <M> fields in the I2C Baud
+ * Rate Register (t=01) to obtain given 'requested_speed'.
+ * The requested_speed will be equal to:
+ * CONFIG_SYS_TCLK / (10 * (M + 1) * (2 << N))
+ * Where M is the value represented by bits[6:3] and N is the value represented
+ * by bits[2:0] of "I2C Baud Rate Register".
+ * Therefore max M which can be set is 16 (2^4) and max N is 8 (2^3). So the
+ * lowest possible baudrate is:
+ * CONFIG_SYS_TCLK/(10 * (16 +1) * (2 << 8), which equals to:
+ * CONFIG_SYS_TCLK/87040. Assuming that CONFIG_SYS_TCLK=250MHz, the lowest
+ * possible frequency is ~2,872KHz.
+ */
static unsigned int marvell_i2c_bus_speed_set(unsigned int requested_speed)
{
unsigned int n, m, freq, margin, min_margin = 0xffffffff;