|
@@ -614,6 +614,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
|
|
|
struct i2c_adapter *p_adap;
|
|
|
struct resource *res;
|
|
|
int rc;
|
|
|
+ unsigned int clkhilow;
|
|
|
|
|
|
iface = kzalloc(sizeof(struct bfin_twi_iface), GFP_KERNEL);
|
|
|
if (!iface) {
|
|
@@ -675,10 +676,14 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
|
|
|
/* Set TWI internal clock as 10MHz */
|
|
|
write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F);
|
|
|
|
|
|
+ /*
|
|
|
+ * We will not end up with a CLKDIV=0 because no one will specify
|
|
|
+ * 20kHz SCL or less in Kconfig now. (5 * 1024 / 20 = 0x100)
|
|
|
+ */
|
|
|
+ clkhilow = 5 * 1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ;
|
|
|
+
|
|
|
/* Set Twi interface clock as specified */
|
|
|
- write_CLKDIV(iface, ((5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ)
|
|
|
- << 8) | ((5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ)
|
|
|
- & 0xFF));
|
|
|
+ write_CLKDIV(iface, (clkhilow << 8) | clkhilow);
|
|
|
|
|
|
/* Enable TWI */
|
|
|
write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA);
|