Skip to contentSkip to conversation

i2c: (algo-pca) Fix mode selection for PCA9665

PATCH Applied Guenter Roeck 2 participants 2 messages Sep 13, 2012 – Sep 14, 2012 1 message not in the archive I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i2c: (algo-pca) Fix mode selection for PCA9665

From: Thomas Kavanagh <[email protected]>

The code currently always selects turbo mode for PCA9665, no matter which clock frequency is configured. This is because it compares the clock frequency against constants reflecting (boundary / 100). Compare against real boundary frequencies to fix the problem.

---
v2: Instead of changing the variable to compare against, change the clock values
to compare against.

 drivers/i2c/algos/i2c-algo-pca.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/algos/i2c-algo-pca.c +3 -3
index 07ccbef..f892a42 100644
@@ -477,17 +477,17 @@ static int pca_init(struct i2c_adapter *adap)
 		/* To avoid integer overflow, use clock/100 for calculations */
 		clock = pca_clock(pca_data) / 100;
 
-		if (pca_data->i2c_clock > 10000) {
+		if (pca_data->i2c_clock > 1000000) {
 			mode = I2C_PCA_MODE_TURBO;
 			min_tlow = 14;
 			min_thi  = 5;
 			raise_fall_time = 22; /* Raise 11e-8s, Fall 11e-8s */
-		} else if (pca_data->i2c_clock > 4000) {
+		} else if (pca_data->i2c_clock > 400000) {
 			mode = I2C_PCA_MODE_FASTP;
 			min_tlow = 17;
 			min_thi  = 9;
 			raise_fall_time = 22; /* Raise 11e-8s, Fall 11e-8s */
-		} else if (pca_data->i2c_clock > 1000) {
+		} else if (pca_data->i2c_clock > 100000) {
 			mode = I2C_PCA_MODE_FAST;
 			min_tlow = 44;
 			min_thi  = 20;
Signature · 1 line
1.7.9.7
Applied
#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Guenter Roeck

From: Thomas Kavanagh <[email protected]>

The code currently always selects turbo mode for PCA9665, no matter which clock frequency is configured. This is because it compares the clock frequency against constants reflecting (boundary / 100). Compare against real boundary frequencies to fix the problem.

Quoted 6 lines

---
v2: Instead of changing the variable to compare against, change the clock values
to compare against.

Applied to -current, thanks!

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |