diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/Kconfig | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-bfin-twi.c | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index f1c6ca7e2852..c8460fa9cfac 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -298,7 +298,7 @@ config I2C_BLACKFIN_TWI | |||
298 | config I2C_BLACKFIN_TWI_CLK_KHZ | 298 | config I2C_BLACKFIN_TWI_CLK_KHZ |
299 | int "Blackfin TWI I2C clock (kHz)" | 299 | int "Blackfin TWI I2C clock (kHz)" |
300 | depends on I2C_BLACKFIN_TWI | 300 | depends on I2C_BLACKFIN_TWI |
301 | range 10 400 | 301 | range 21 400 |
302 | default 50 | 302 | default 50 |
303 | help | 303 | help |
304 | The unit of the TWI clock is kHz. | 304 | The unit of the TWI clock is kHz. |
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index fc548b3d002e..77cafb6ba923 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -614,6 +614,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) | |||
614 | struct i2c_adapter *p_adap; | 614 | struct i2c_adapter *p_adap; |
615 | struct resource *res; | 615 | struct resource *res; |
616 | int rc; | 616 | int rc; |
617 | unsigned int clkhilow; | ||
617 | 618 | ||
618 | iface = kzalloc(sizeof(struct bfin_twi_iface), GFP_KERNEL); | 619 | iface = kzalloc(sizeof(struct bfin_twi_iface), GFP_KERNEL); |
619 | if (!iface) { | 620 | if (!iface) { |
@@ -675,10 +676,14 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) | |||
675 | /* Set TWI internal clock as 10MHz */ | 676 | /* Set TWI internal clock as 10MHz */ |
676 | write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F); | 677 | write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F); |
677 | 678 | ||
679 | /* | ||
680 | * We will not end up with a CLKDIV=0 because no one will specify | ||
681 | * 20kHz SCL or less in Kconfig now. (5 * 1024 / 20 = 0x100) | ||
682 | */ | ||
683 | clkhilow = 5 * 1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ; | ||
684 | |||
678 | /* Set Twi interface clock as specified */ | 685 | /* Set Twi interface clock as specified */ |
679 | write_CLKDIV(iface, ((5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ) | 686 | write_CLKDIV(iface, (clkhilow << 8) | clkhilow); |
680 | << 8) | ((5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ) | ||
681 | & 0xFF)); | ||
682 | 687 | ||
683 | /* Enable TWI */ | 688 | /* Enable TWI */ |
684 | write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); | 689 | write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); |