[as6812-32x] Add thermal sensor for YM2401 PSU

This commit is contained in:
brandonchuang
2017-06-15 17:48:51 +08:00
parent ee1a53237d
commit a558d7576e

View File

@@ -24,10 +24,8 @@
*
***********************************************************/
#include <unistd.h>
#include <onlplib/mmap.h>
#include <onlplib/file.h>
#include <onlp/platformi/thermali.h>
#include <fcntl.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
@@ -112,6 +110,9 @@ int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
int local_id;
int psu_id;
psu_type_t psu_type;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
@@ -124,5 +125,13 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
return rv;
}
psu_id = local_id - THERMAL_1_ON_PSU1 + 1;
psu_type = get_psu_type(psu_id, NULL, 0);
if (psu_type == PSU_TYPE_AC_3YPOWER_F2B || psu_type == PSU_TYPE_AC_3YPOWER_B2F ) {
int rv = psu_ym2401_pmbus_info_get(psu_id, "psu_temp1_input", &info->mcelsius);
return rv;
}
return onlp_file_read_int(&info->mcelsius, devfiles[local_id]);
}