diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2009-12-21 09:28:30 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2009-12-23 20:24:48 -0500 |
commit | ac07fb4dc1908d300f50fa711982c9d750eb59f7 (patch) | |
tree | 9a3e6149726b63a74d141bb4fe86b7fb3399435f /drivers/i2c | |
parent | c9f937e4a3f4ebf9924ec21d80632e5eb61d949c (diff) |
i2c-bfin-twi: fix CLKDIV calculation
Calculation of the CLKDIV speed setting should be done using base 10 math
rather than base 2. We also avoid exceeding the spec due to integer
truncation and a 50% duty cycle.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-bfin-twi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index b309ac2c3d5c..fe3fb567317d 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -693,13 +693,13 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) | |||
693 | } | 693 | } |
694 | 694 | ||
695 | /* Set TWI internal clock as 10MHz */ | 695 | /* Set TWI internal clock as 10MHz */ |
696 | write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F); | 696 | write_CONTROL(iface, ((get_sclk() / 1000 / 1000 + 5) / 10) & 0x7F); |
697 | 697 | ||
698 | /* | 698 | /* |
699 | * We will not end up with a CLKDIV=0 because no one will specify | 699 | * We will not end up with a CLKDIV=0 because no one will specify |
700 | * 20kHz SCL or less in Kconfig now. (5 * 1024 / 20 = 0x100) | 700 | * 20kHz SCL or less in Kconfig now. (5 * 1000 / 20 = 250) |
701 | */ | 701 | */ |
702 | clkhilow = 5 * 1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ; | 702 | clkhilow = ((10 * 1000 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ) + 1) / 2; |
703 | 703 | ||
704 | /* Set Twi interface clock as specified */ | 704 | /* Set Twi interface clock as specified */ |
705 | write_CLKDIV(iface, (clkhilow << 8) | clkhilow); | 705 | write_CLKDIV(iface, (clkhilow << 8) | clkhilow); |