diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-rk3x.c')
-rw-r--r-- | drivers/i2c/busses/i2c-rk3x.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index e637c32ae517..b38b0529946a 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c | |||
@@ -238,7 +238,7 @@ static void rk3x_i2c_fill_transmit_buf(struct rk3x_i2c *i2c) | |||
238 | for (i = 0; i < 8; ++i) { | 238 | for (i = 0; i < 8; ++i) { |
239 | val = 0; | 239 | val = 0; |
240 | for (j = 0; j < 4; ++j) { | 240 | for (j = 0; j < 4; ++j) { |
241 | if (i2c->processed == i2c->msg->len) | 241 | if ((i2c->processed == i2c->msg->len) && (cnt != 0)) |
242 | break; | 242 | break; |
243 | 243 | ||
244 | if (i2c->processed == 0 && cnt == 0) | 244 | if (i2c->processed == 0 && cnt == 0) |
@@ -433,12 +433,11 @@ static void rk3x_i2c_set_scl_rate(struct rk3x_i2c *i2c, unsigned long scl_rate) | |||
433 | unsigned long i2c_rate = clk_get_rate(i2c->clk); | 433 | unsigned long i2c_rate = clk_get_rate(i2c->clk); |
434 | unsigned int div; | 434 | unsigned int div; |
435 | 435 | ||
436 | /* SCL rate = (clk rate) / (8 * DIV) */ | 436 | /* set DIV = DIVH = DIVL |
437 | div = DIV_ROUND_UP(i2c_rate, scl_rate * 8); | 437 | * SCL rate = (clk rate) / (8 * (DIVH + 1 + DIVL + 1)) |
438 | 438 | * = (clk rate) / (16 * (DIV + 1)) | |
439 | /* The lower and upper half of the CLKDIV reg describe the length of | 439 | */ |
440 | * SCL low & high periods. */ | 440 | div = DIV_ROUND_UP(i2c_rate, scl_rate * 16) - 1; |
441 | div = DIV_ROUND_UP(div, 2); | ||
442 | 441 | ||
443 | i2c_writel(i2c, (div << 16) | (div & 0xffff), REG_CLKDIV); | 442 | i2c_writel(i2c, (div << 16) | (div & 0xffff), REG_CLKDIV); |
444 | } | 443 | } |