Skip to content

Commit ba21cc4

Browse files
qnosmssonicbld
authored andcommitted
[celestica/e1031]: enable emc2305 fan controller timeout feature (sonic-net#14401)
Why I did it There is rare condition, emc2305 hold SMBus and cause SMBus completion wait timed out. How I did it Enable EMC2305 SMBus timeout feature, 30ms period of inactivity will reset the interface. How to verify it Use 'i2cget -y -f 23 0x4d 0x20 b' to read EMC2305 configuration register and check DIS_TO bit not set. Signed-off-by: Eric Zhu <[email protected]>
1 parent 417196f commit ba21cc4

File tree

1 file changed

+32
-0
lines changed
  • platform/broadcom/sonic-platform-modules-cel/haliburton/modules

1 file changed

+32
-0
lines changed

platform/broadcom/sonic-platform-modules-cel/haliburton/modules/emc2305.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,35 @@ emc2305_set_pwm(struct i2c_client *client, int fan_idx, long pwm)
407407
mutex_unlock(&data->update_lock);
408408
return status;
409409
}
410+
411+
static int
412+
emc2305_enable_timeout(struct i2c_client *client, bool enable)
413+
{
414+
struct emc2305_data *data = i2c_get_clientdata(client);
415+
int status = 0;
416+
u8 conf_val = 0;
417+
418+
mutex_lock(&data->update_lock);
419+
420+
status = read_u8_from_i2c(client, REG_CONFIGURATION, &conf_val);
421+
if (status < 0) {
422+
mutex_unlock(&data->update_lock);
423+
return status;
424+
}
425+
426+
// Section 6.2: CONFIG REGISTER DIS_TO bit(bit 6)
427+
if (enable) {
428+
conf_val &= ~(1 << 6);
429+
} else {
430+
conf_val |= (1 << 6);
431+
}
432+
433+
status = i2c_smbus_write_byte_data(client, REG_CONFIGURATION, conf_val);
434+
435+
mutex_unlock(&data->update_lock);
436+
return status;
437+
}
438+
410439
/*
411440
* sysfs callback functions
412441
*
@@ -744,6 +773,9 @@ emc2305_probe(struct i2c_client *client, const struct i2c_device_id *id)
744773
i2c_set_clientdata(client, data);
745774
mutex_init(&data->update_lock);
746775

776+
// Enable SMBus timeout feature
777+
emc2305_enable_timeout(client, true);
778+
747779
status = i2c_smbus_read_byte_data(client, REG_PRODUCT_ID);
748780
switch (status) {
749781
case 0x34: /* EMC2305 */

0 commit comments

Comments
 (0)