mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
[as5812-54x] Support serial number for YM-2401J PSU in psui.c
This commit is contained in:
@@ -253,22 +253,38 @@ int psu_ym2401_pmbus_info_set(int id, char *node, int value)
|
||||
|
||||
#define PSU_SERIAL_NUMBER_LEN 18
|
||||
|
||||
int psu_serial_number_get(int id, int is_ac, char *serial, int serial_len)
|
||||
int psu_serial_number_get(int id, psu_type_t psu_type, char *serial, int serial_len)
|
||||
{
|
||||
int size = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
char *prefix = NULL;
|
||||
char *filename = NULL;
|
||||
|
||||
if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
memset((void *)serial, 0x0, serial_len);
|
||||
if(is_ac)
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX;
|
||||
else
|
||||
prefix = (id == PSU1_ID) ? PSU1_DC_EEPROM_PREFIX : PSU2_DC_EEPROM_PREFIX;
|
||||
ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_serial");
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_COMPUWARE_F2B:
|
||||
case PSU_TYPE_AC_COMPUWARE_B2F:
|
||||
filename = "psu_serial";
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX;
|
||||
break;
|
||||
case PSU_TYPE_AC_3YPOWER_F2B:
|
||||
case PSU_TYPE_AC_3YPOWER_B2F:
|
||||
filename = "psu_mfr_serial";
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_3YPOWER_PMBUS_PREFIX : PSU2_AC_3YPOWER_PMBUS_PREFIX;
|
||||
break;
|
||||
case PSU_TYPE_DC_48V_F2B:
|
||||
case PSU_TYPE_DC_48V_B2F:
|
||||
/* fall through */
|
||||
default:
|
||||
serial[0] = '\0';
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, filename);
|
||||
if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ typedef enum psu_type {
|
||||
} psu_type_t;
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
|
||||
int psu_serial_number_get(int id, int is_ac, char *serial, int serial_len);
|
||||
int psu_serial_number_get(int id, psu_type_t psu_type, char *serial, int serial_len);
|
||||
int psu_ym2401_pmbus_info_get(int id, char *node, int *value);
|
||||
int psu_ym2401_pmbus_info_set(int id, char *node, int value);
|
||||
|
||||
|
||||
@@ -225,7 +225,6 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
int val = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
int is_ac=1;
|
||||
psu_type_t psu_type;
|
||||
|
||||
VALIDATE(id);
|
||||
@@ -271,14 +270,13 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
break;
|
||||
case PSU_TYPE_DC_48V_F2B:
|
||||
case PSU_TYPE_DC_48V_B2F:
|
||||
is_ac=0;
|
||||
ret = psu_um400d_info_get(info);
|
||||
break;
|
||||
default:
|
||||
ret = ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
psu_serial_number_get(index, is_ac, info->serial, sizeof(info->serial));
|
||||
psu_serial_number_get(index, psu_type, info->serial, sizeof(info->serial));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user