diff --git a/packages/base/any/kernels/modules/ym2651y.c b/packages/base/any/kernels/modules/ym2651y.c index 5ac4ca77b..cf8d02af7 100755 --- a/packages/base/any/kernels/modules/ym2651y.c +++ b/packages/base/any/kernels/modules/ym2651y.c @@ -312,7 +312,8 @@ static ssize_t show_linear(struct device *dev, struct device_attribute *da, (strncmp(ptr, "FSF019", strlen("FSF019")) == 0)|| (strncmp(ptr, "FSF045", strlen("FSF045")) == 0)|| (strncmp(ptr, "SPAACTN-04", strlen("SPAACTN-04")) == 0)|| - (strncmp(ptr, "SPAACTN-03", strlen("SPAACTN-03")) == 0)) { + (strncmp(ptr, "SPAACTN-03", strlen("SPAACTN-03")) == 0)|| + (strncmp(ptr, "G1441-0850WNB", strlen("G1441-0850WNB")) == 0)) { value = data->v_in; } break; @@ -323,7 +324,8 @@ static ssize_t show_linear(struct device *dev, struct device_attribute *da, (strncmp(ptr, "FSF019", strlen("FSF019")) == 0)|| (strncmp(ptr, "FSF045", strlen("FSF045")) == 0)|| (strncmp(ptr, "SPAACTN-04", strlen("SPAACTN-04")) == 0)|| - (strncmp(ptr, "SPAACTN-03", strlen("SPAACTN-03")) == 0)) { + (strncmp(ptr, "SPAACTN-03", strlen("SPAACTN-03")) == 0)|| + (strncmp(ptr, "G1441-0850WNB", strlen("G1441-0850WNB")) == 0)) { value = data->i_in; } break; @@ -334,7 +336,8 @@ static ssize_t show_linear(struct device *dev, struct device_attribute *da, (strncmp(ptr, "FSF019", strlen("FSF019")) == 0)|| (strncmp(ptr, "FSF045", strlen("FSF045")) == 0)|| (strncmp(ptr, "SPAACTN-04", strlen("SPAACTN-04")) == 0)|| - (strncmp(ptr, "SPAACTN-03", strlen("SPAACTN-03")) == 0)) { + (strncmp(ptr, "SPAACTN-03", strlen("SPAACTN-03")) == 0)|| + (strncmp(ptr, "G1441-0850WNB", strlen("G1441-0850WNB")) == 0)) { value = data->p_in; } break; @@ -520,7 +523,8 @@ static ssize_t show_vout(struct device *dev, struct device_attribute *da, else if ((strncmp(ptr, "DPS-850A", strlen("DPS-850A")) == 0)|| (strncmp(ptr, "YM-2851J", strlen("YM-2851J")) == 0) || (strncmp(ptr, "UPD1501SA-1190G", strlen("UPD1501SA-1190G")) == 0) || - (strncmp(ptr, "UPD1501SA-1290G", strlen("UPD1501SA-1290G")) == 0)) { + (strncmp(ptr, "UPD1501SA-1290G", strlen("UPD1501SA-1290G")) == 0) || + (strncmp(ptr, "G1441-0850WNB", strlen("G1441-0850WNB")) == 0) ) { return show_vout_by_mode(dev, da, buf); } @@ -869,6 +873,7 @@ static struct ym2651y_data *ym2651y_update_device(struct device *dev) } if ((strncmp((data->mfr_model+1), "YM-2851J", strlen("YM-2851J")) == 0)|| + (strncmp((data->mfr_model+1), "YM-2851F", strlen("YM-2851F")) == 0)|| (strncmp((data->mfr_model+1), "YM-2651Y", strlen("YM-2651Y")) == 0)|| (strncmp((data->mfr_model+1), "YPEB1200AM", strlen("YPEB1200AM")) == 0)) { diff --git a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/fani.c b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/fani.c index 62cec4a48..9e754a592 100755 --- a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/fani.c +++ b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/fani.c @@ -165,6 +165,7 @@ _onlp_get_fan_direction_on_psu(void) case PSU_TYPE_AC_DPS850_F2B: case PSU_TYPE_AC_YM2851FCR_F2B: case PSU_TYPE_DC_YM2851JER_F2B: + case PSU_TYPE_DC_G1441_0850WNB_F2B: return ONLP_FAN_STATUS_F2B; case PSU_TYPE_AC_DPS850_B2F: case PSU_TYPE_AC_YM2851FDR_B2F: @@ -202,12 +203,22 @@ _onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) { if (psu_dps850_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { - info->rpm = val; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0; + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0; + } } + + if (psu_type == PSU_TYPE_DC_G1441_0850WNB_F2B) + { + if (psu_g1441_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) + { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0; + } } - + if (psu_type == PSU_TYPE_AC_YM2851FCR_F2B || psu_type == PSU_TYPE_AC_YM2851FDR_B2F || psu_type == PSU_TYPE_DC_YM2851JER_F2B || psu_type == PSU_TYPE_DC_YM2851JFR_B2F) { diff --git a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.c b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.c index e186159d2..b0a8a7670 100644 --- a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.c @@ -95,10 +95,11 @@ int psu_serial_number_get(int id, char *serial, int serial_len) psu_type_t psu_type_get(int id, char* modelname, int modelname_len) { int value = 0; - int ret = ONLP_STATUS_OK; - char model[PSU_MODEL_NAME_LEN + 1] = {0}; + int ret = ONLP_STATUS_OK; char *prefix = psu_pmbus_path(id); char fan_dir[PSU_FAN_DIR_LEN + 1] = {0}; + char *model_string = NULL; + int len = 0; if (modelname && modelname_len < PSU_MODEL_NAME_LEN) { return PSU_TYPE_UNKNOWN; @@ -114,73 +115,120 @@ psu_type_t psu_type_get(int id, char* modelname, int modelname_len) if (!value) { return PSU_TYPE_UNKNOWN; } - - /* Read mode name */ - ret = onlp_file_read((uint8_t*)model, PSU_MODEL_NAME_LEN, &value, "%s%s", prefix, "psu_mfr_model"); - if (ret != ONLP_STATUS_OK || value != PSU_MODEL_NAME_LEN) { - return PSU_TYPE_UNKNOWN; - + /* Read full model name */ + len = onlp_file_read_str(&model_string, "%spsu_mfr_model", prefix); + if (!model_string || len <= 0) + { + AIM_FREE_IF_PTR(model_string); + return PSU_TYPE_UNKNOWN; } - - if (modelname) { - memcpy(modelname, model, sizeof(model)); - } - - if (strncmp(model, "DPS-850A", strlen("DPS-850A")) == 0) { + if (modelname) + strcpy(modelname, model_string); + if ((strstr(model_string, "DPS-850AB-5") != NULL)){ ret = onlp_file_read((uint8_t*)fan_dir, PSU_FAN_DIR_LEN, &value, "%s%s", prefix, "psu_fan_dir"); - if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + if (ret != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read psu fan dir\r\n"); + AIM_FREE_IF_PTR(model_string); + return ONLP_STATUS_E_INTERNAL; + } + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) + { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_AC_DPS850_B2F; } - return PSU_TYPE_AC_DPS850_F2B; + else + { + AIM_FREE_IF_PTR(model_string); + return PSU_TYPE_AC_DPS850_F2B; + } + }else if(strncmp(model_string, "G1441-0850WNB", strlen("G1441-0850WNB")) == 0){ + ret = onlp_file_read((uint8_t*)fan_dir, PSU_FAN_DIR_LEN, &value, "%s%s", prefix, "psu_fan_dir"); + if (ret != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read psu fan dir\r\n"); + AIM_FREE_IF_PTR(model_string); + return ONLP_STATUS_E_INTERNAL; + } + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) + { + AIM_FREE_IF_PTR(model_string); + return PSU_TYPE_DC_G1441_0850WNB_B2F; + } + else + { + AIM_FREE_IF_PTR(model_string); + return PSU_TYPE_DC_G1441_0850WNB_F2B; + } } - - if (strncmp(model, "YM-2851F", strlen("YM-2851F")) == 0) { + /* Access length 8 data for 3Y PSU model compare */ + if (modelname) { + memcpy(modelname, model_string, PSU_MODEL_NAME_LEN); + } + if (strncmp(model_string, "YM-2851F", strlen("YM-2851F")) == 0) { char model_opt[PSU_MODEL_NAME_LEN + 1] = {0}; ret = onlp_file_read((uint8_t*)model_opt, PSU_MODEL_NAME_LEN, &value, "%s%s", prefix, "psu_mfr_model_opt"); + if (ret != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read psu model opt\r\n"); + AIM_FREE_IF_PTR(model_string); + return ONLP_STATUS_E_INTERNAL; + } if (modelname && value) { memcpy(modelname + PSU_MODEL_NAME_LEN, model_opt, strlen(model_opt)-1); } if ((strncmp(model_opt, "DR", strlen("DR")) == 0) || (strncmp(model_opt, "D01R", strlen("D01R")) == 0)) { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_AC_YM2851FDR_B2F; /* YM-2851FDR or YM-2851FD01R */ } else if ((strncmp(model_opt, "CR", strlen("CR")) == 0) || (strncmp(model_opt, "C01R", strlen("C01R")) == 0)) { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_AC_YM2851FCR_F2B; /* YM-2851FDR or YM-2851FD01R */ } ret = onlp_file_read((uint8_t*)fan_dir, PSU_FAN_DIR_LEN, &value, "%s%s", prefix, "psu_fan_dir"); if ((strncmp(fan_dir, "B2F", strlen("B2F")) == 0) || (strncmp(fan_dir, "AFI", strlen("AFI")) == 0)) { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_AC_YM2851FDR_B2F; } - + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_AC_YM2851FCR_F2B; } - if (strncmp(model, "YM-2851J", strlen("YM-2851J")) == 0) { + if (strncmp(model_string, "YM-2851J", strlen("YM-2851J")) == 0) { char model_opt[PSU_MODEL_NAME_LEN + 1] = {0}; ret = onlp_file_read((uint8_t*)model_opt, PSU_MODEL_NAME_LEN, &value, "%s%s", prefix, "psu_mfr_model_opt"); + if (ret != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read psu model opt\r\n"); + AIM_FREE_IF_PTR(model_string); + return ONLP_STATUS_E_INTERNAL; + } if (modelname && value) { memcpy(modelname + PSU_MODEL_NAME_LEN, model_opt, strlen(model_opt)-1); } if (strncmp(model_opt, "FR", strlen("FR")) == 0) { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_DC_YM2851JFR_B2F; } else if (strncmp(model_opt, "ER", strlen("ER")) == 0) { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_DC_YM2851JER_F2B; } ret = onlp_file_read((uint8_t*)fan_dir, PSU_FAN_DIR_LEN, &value, "%s%s", prefix, "psu_fan_dir"); if ((strncmp(fan_dir, "B2F", strlen("B2F")) == 0) || (strncmp(fan_dir, "AFI", strlen("AFI")) == 0)) { + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_DC_YM2851JFR_B2F; } - - + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_DC_YM2851JER_F2B; /* YM-2851JER */ } - + AIM_FREE_IF_PTR(model_string); return PSU_TYPE_UNKNOWN; } @@ -222,6 +270,19 @@ int psu_dps850_pmbus_info_get(int id, char *node, int *value) return ONLP_STATUS_OK; } +int psu_g1441_pmbus_info_get(int id, char *node, int *value) +{ + char *prefix = psu_pmbus_path(id); + *value = 0; + + if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + enum onlp_fan_dir onlp_get_fan_dir(void) { int value = FAN_DIR_F2B; diff --git a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.h b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.h index 76f8d37db..3e730502a 100644 --- a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/platform_lib.h @@ -83,6 +83,8 @@ typedef enum psu_type { PSU_TYPE_AC_DPS850_B2F, PSU_TYPE_DC_YM2851JER_F2B, PSU_TYPE_DC_YM2851JFR_B2F, + PSU_TYPE_DC_G1441_0850WNB_F2B, + PSU_TYPE_DC_G1441_0850WNB_B2F } psu_type_t; enum onlp_fan_dir { @@ -98,8 +100,18 @@ int psu_serial_number_get(int id, char *serial, int serial_len); int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); int psu_ym2651y_pmbus_info_set(int id, char *node, int value); int psu_dps850_pmbus_info_get(int id, char *node, int *value); +int psu_g1441_pmbus_info_get(int id, char *node, int *value); char* psu_pmbus_path(int pid); +#define AIM_FREE_IF_PTR(p) \ + do \ + { \ + if (p) { \ + aim_free(p); \ + p = NULL; \ + } \ + } while (0) + #define DEBUG_MODE 0 #if (DEBUG_MODE == 1) diff --git a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/psui.c b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/psui.c index 28ea31c72..fb88a7d25 100755 --- a/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/psui.c +++ b/packages/platforms/accton/x86-64/as7816-64x/onlp/builds/x86_64_accton_as7816_64x/module/src/psui.c @@ -167,6 +167,59 @@ psu_dps850_info_get(onlp_psu_info_t* info) return ONLP_STATUS_OK; } +static int +psu_g1441_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_g1441_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_g1441_pmbus_info_get(index, "psu_v_in", &val) == 0) { + info->mvin = val; + info->caps |= ONLP_PSU_CAPS_VIN; + } + + if (psu_g1441_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_g1441_pmbus_info_get(index, "psu_i_in", &val) == 0) { + info->miin = val; + info->caps |= ONLP_PSU_CAPS_IIN; + } + + if (psu_g1441_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + if (psu_g1441_pmbus_info_get(index, "psu_p_in", &val) == 0) { + info->mpin = val; + info->caps |= ONLP_PSU_CAPS_PIN; + } + + psu_serial_number_get(index, info->serial, sizeof(info->serial)); + + return ONLP_STATUS_OK; +} + /* * Get all information about the given PSU oid. @@ -226,6 +279,9 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) case PSU_TYPE_AC_DPS850_B2F: ret = psu_dps850_info_get(info); break; + case PSU_TYPE_DC_G1441_0850WNB_F2B: + ret = psu_g1441_info_get(info); + break; case PSU_TYPE_AC_YM2851FCR_F2B: case PSU_TYPE_AC_YM2851FDR_B2F: info->caps = ONLP_PSU_CAPS_AC; /* Set capability */