linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: davinci: Avoid zero value of CLKH
@ 2018-07-13 15:20 Alexander Sverdlin
  2018-07-17 11:57 ` Sekhar Nori
  2018-07-23 18:07 ` Wolfram Sang
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Sverdlin @ 2018-07-13 15:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: Sekhar Nori, Alexander Sverdlin, linux-arm-kernel, Kevin Hilman

If CLKH is set to 0 I2C clock is not generated at all, so avoid this value
and stretch the clock in this case.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
 drivers/i2c/busses/i2c-davinci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 75d6ab177055..7379043711df 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -237,12 +237,16 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
 	/*
 	 * It's not always possible to have 1 to 2 ratio when d=7, so fall back
 	 * to minimal possible clkh in this case.
+	 *
+	 * Note:
+	 * CLKH is not allowed to be 0, in this case I2C clock is not generated
+	 * at all
 	 */
-	if (clk >= clkl + d) {
+	if (clk > clkl + d) {
 		clkh = clk - clkl - d;
 		clkl -= d;
 	} else {
-		clkh = 0;
+		clkh = 1;
 		clkl = clk - (d << 1);
 	}
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-24  6:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-13 15:20 [PATCH] i2c: davinci: Avoid zero value of CLKH Alexander Sverdlin
2018-07-17 11:57 ` Sekhar Nori
2018-07-20 18:43   ` Grygorii Strashko
2018-07-20 22:18     ` Wolfram Sang
2018-07-23 18:07 ` Wolfram Sang
2018-07-24  6:17   ` Sekhar Nori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).