From 7b5466e0bf7b77a4c32daf7eeab3b43255f8b413 Mon Sep 17 00:00:00 2001 From: Stanley Chi Date: Tue, 16 Jan 2018 16:11:57 +0800 Subject: [PATCH] 1. Fix the wrong display value of PSU. 2. Modify psui.c for PSU status. 3. Modify ledi.c for fan tray led. Signed-off-by: Stanley Chi --- .../modules/builds/dni_ag9032v1_psu.c | 55 ++++++++++++------- .../onlp/builds/src/module/src/ledi.c | 52 ++++++++++++------ .../onlp/builds/src/module/src/psui.c | 50 ++++++++--------- 3 files changed, 93 insertions(+), 64 deletions(-) mode change 100644 => 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c mode change 100644 => 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c index 8a0da3c7..8a63c372 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c @@ -290,7 +290,6 @@ static int dps_800ab_16_d_write_word(struct i2c_client *client, u8 reg, \ client->flags |= I2C_CLIENT_PEC, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, &data); - } static int dps_800ab_16_d_read_block(struct i2c_client *client, u8 command, \ @@ -344,8 +343,8 @@ static struct dps_800ab_16_d_data *dps_800ab_16_d_update_device( \ {0x8b, &data->v_out}, {0x89, &data->i_in}, {0x8c, &data->i_out}, - {0x96, &data->p_out}, {0x97, &data->p_in}, + {0x96, &data->p_out}, {0x8d, &(data->temp_input[0])}, {0x8e, &(data->temp_input[1])}, {0x3b, &(data->fan_duty_cycle[0])}, @@ -357,6 +356,37 @@ static struct dps_800ab_16_d_data *dps_800ab_16_d_update_device( \ /* one milliseconds from now */ data->last_updated = jiffies + HZ / 1000; + data->v_in = 0; + data->v_out = 0; + data->i_in = 0; + data->i_out = 0; + data->p_in = 0; + data->p_out = 0; + data->temp_input[0] = 0; + data->temp_input[1] = 0; + data->fan_duty_cycle[0] = 0; + data->fan_speed[0] = 0; + data->mfr_model[0] = '\0'; + data->mfr_serial[0] = '\0'; + + command = 0x9a; /* PSU mfr_model */ + status = dps_800ab_16_d_read_block(client, command, + data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); + data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; + if (status < 0) { + dev_dbg(&client->dev, "reg %d, err %d\n", command, + status); + } + + command = 0x9e; /* PSU mfr_serial */ + status = dps_800ab_16_d_read_block(client, command, + data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); + data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; + if (status < 0) { + dev_dbg(&client->dev, "reg %d, err %d\n", command, + status); + } + for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { status = dps_800ab_16_d_read_byte(client, regs_byte[i].reg); @@ -377,26 +407,9 @@ static struct dps_800ab_16_d_data *dps_800ab_16_d_update_device( \ } else { *(regs_word[i].value) = status; } - } + } + - command = 0x9a; /* PSU mfr_model */ - status = dps_800ab_16_d_read_block(client, command, - data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); - data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, - status); - } - - command = 0x9e; /* PSU mfr_serial */ - status = dps_800ab_16_d_read_block(client, command, - data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); - data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, - status); - } - data->valid = 1; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c old mode 100644 new mode 100755 index e72f9ab5..4163b7de --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c @@ -48,7 +48,7 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, @@ -173,11 +173,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x80) == 0x80) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_2: /* Select fan tray 2 */ @@ -189,11 +191,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x10) == 0x10) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x20) == 0x20) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_3: /* Select fan tray 3 */ @@ -205,11 +209,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x04) == 0x04) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x08) == 0x08) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_4: /* Select fan tray 4 */ @@ -221,11 +227,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x01) == 0x01) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x02) == 0x02) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_5: /* Select fan tray 5 */ @@ -237,11 +245,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x80) == 0x80) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; default: break; @@ -389,11 +399,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x40; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + else if(mode == ONLP_LED_MODE_RED) {/* Red light */ fan_tray_led_reg_value |= 0x80; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_2: fan_tray_led_reg_value &= ~0x30; @@ -402,11 +414,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x10; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + else if(mode == ONLP_LED_MODE_RED) {/* Red light */ fan_tray_led_reg_value |= 0x20; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_3: fan_tray_led_reg_value &= ~0x0c; @@ -415,11 +429,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x04; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + else if(mode == ONLP_LED_MODE_RED) {/* Red light */ fan_tray_led_reg_value |= 0x08; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_4: fan_tray_led_reg_value &= ~0x03; @@ -428,11 +444,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x01; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + else if(mode == ONLP_LED_MODE_RED) {/* Red light */ fan_tray_led_reg_value |= 0x02; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_5: fan_tray_led_reg_2_value &= ~0xC0; @@ -441,11 +459,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_2_value |= 0x40; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value); } - else + else if(mode == ONLP_LED_MODE_RED) {/* Red light */ fan_tray_led_reg_2_value |= 0x80; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; } return ONLP_STATUS_OK; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c old mode 100644 new mode 100755 index 9ab696b0..56fb5eda --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c @@ -76,13 +76,8 @@ dni_psu_info_get(onlp_psu_info_t* info) char val_char[16] = {'\0'}; char node_path[PSU_NODE_MAX_PATH_LEN] = {'\0'}; - /* Set capability - */ + /* Set capability */ info->caps |= ONLP_PSU_CAPS_AC; - - if (info->status & ONLP_PSU_STATUS_FAILED) { - return ONLP_STATUS_OK; - } /* Set the associated oid_table * Set PSU's fan and thermal to child OID @@ -170,7 +165,7 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) channel = PSU_I2C_SEL_PSU1_EEPROM; break; case PSU2_ID: - channel = PSU_I2C_SEL_PSU2_EEPROM; + channel = PSU_I2C_SEL_PSU2_EEPROM; break; default: break; @@ -185,32 +180,34 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) dev_info.offset = 0x00; /* In EEPROM address 0x00 */ dev_info.flags = DEFAULT_FLAG; - /* Check PSU is PRESENT or not - * Read PSU EEPROM 1 byte from adress 0x00 - * if not present, return Negative value. - */ - if(dni_i2c_lock_read(&mux_info, &dev_info) < 0) - { - /* Unable to read PSU(%d) node(psu_present) */ - return ONLP_STATUS_OK; - } else { - info->status |= ONLP_PSU_STATUS_PRESENT; - } - - /* Select PSU member */ + /* Select PSU member(channel) */ sprintf(channel_data, "%x", channel); dni_i2c_lock_write_attribute(NULL, channel_data, PSU_SELECT_MEMBER_PATH); + /* Check PSU have voltage input or not */ dni_psu_pmbus_info_get(index, "psu_v_in", &val); - if (val == 0) { - /* Unable to read PSU(%d) node(psu_power_good) */ - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; + + /* Check PSU is PRESENT or not + * Read PSU EEPROM 1 byte from adress 0x00 + * if not present, return Negative value. + */ + if(val == 0 && dni_i2c_lock_read(&mux_info, &dev_info) < 0) + { + /* Unable to read PSU EEPROM */ + /* Able to read PSU VIN(psu_power_not_good) */ + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + else if(val == 0){ + /* Unable to read PSU VIN(psu_power_good) */ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + } + else { + info->status |= ONLP_PSU_STATUS_PRESENT; } ret = dni_psu_info_get(info); - return ret; } @@ -218,5 +215,4 @@ int onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) { return ONLP_STATUS_E_UNSUPPORTED; -} - +} \ No newline at end of file