diff --git a/Makefile b/Makefile index c183f82e..cbfe14b5 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ endif include $(ONL)/make/config.mk # All available architectures. -ALL_ARCHES := amd64 powerpc armel arm64 +ALL_ARCHES := amd64 armel # Build rule for each architecture. define build_arch_template diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h index 3981c47f..45fc4106 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h @@ -33,7 +33,7 @@ #define PSU2_ID 2 #define CHASSIS_FAN_COUNT 6 -#define CHASSIS_THERMAL_COUNT 4 +#define CHASSIS_THERMAL_COUNT 6 #define CHASSIS_PSU_COUNT 2 @@ -145,4 +145,5 @@ typedef enum platform_id_e { } platform_id_t; extern platform_id_t platform_id; +extern int psu_status_info_get(int id, char *node); #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c index cdde1a5e..fda9d5ae 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c @@ -34,7 +34,7 @@ #define CPLD_PSU_NAME "MASTERCPLD" #define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 +#define PSU_STATUS_POWER_GOOD 0 #define PSU_STATUS_REG (0X03) #define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1)) #define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1)) @@ -79,7 +79,7 @@ static long psu_data_convert_16(unsigned int d, int mult) } -static int +int psu_status_info_get(int id, char *node) { int ret; @@ -246,6 +246,7 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) if (val != PSU_STATUS_POWER_GOOD) { info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; } /* Get PSU type diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c index c11239ff..fd3b9602 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c @@ -31,6 +31,7 @@ #include "platform_lib.h" #include "x86_64_delta_ag7648_log.h" #include +#include "x86_64_delta_i2c.h" #define prefix_path "/sys/bus/i2c/devices/" #define LOCAL_DEBUG 0 @@ -59,8 +60,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */ "3-004c/hwmon/hwmon2/temp1_input", "3-004d/hwmon/hwmon3/temp1_input", "3-004e/hwmon/hwmon4/temp1_input", - "4-0058/psu_temp1_input", - "5-0058/psu_temp1_input", }; /* Static values */ @@ -83,15 +82,30 @@ static onlp_thermal_info_t linfo[] = { ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, - ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, - ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS } }; +/*thermali val to real tempeture*/ +static int +_onlp_psu_thermali_val_to_temperature (int v,int mult) +{ + long X, Y, N, n; + Y = v & 0x07FF; + N = (v >> 11) & 0x0f; + n = v & 0x8000 ? 1 : 0; + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = Y * mult * (N=(1<<(N&0xf))); + return X; +} + /* * This will be called to intiialize the thermali subsystem. */ @@ -112,17 +126,15 @@ onlp_thermali_init(void) * structure even if the sensor described by the OID is not present. */ int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +_onlp_thermali_info_get(int id, onlp_thermal_info_t* info) { int len, nbytes = 10, temp_base=1, local_id; uint8_t r_data[10]={0}; char fullpath[50] = {0}; - VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); + local_id = id; DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); - /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[local_id]; /* get fullpath */ @@ -138,3 +150,79 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) return ONLP_STATUS_OK; } +/*psu temperture info get*/ +static int +_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info) +{ + int psu_present,psu_good; + int psu_id,local_id; + int r_data,temperature_v; + enum ag7648_product_id pid; + + local_id=id; + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + + psu_id=(local_id-THERMAL_1_ON_PSU1)+1; + pid=get_product_id(); + //if the psu is not, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + if(psu_present != 1){ + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + psu_good= psu_status_info_get(psu_id,"good"); + if(psu_good != 0){ + info->status |= ONLP_THERMAL_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + //read the pus temperture register value + if(pid == PID_AG7648){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); + } + else{ + DEBUG_PRINT("\n[Debug][%s][%d][unsupported board:%d]", __FUNCTION__, __LINE__, pid); + return ONLP_STATUS_E_UNSUPPORTED; + } + if(r_data<0) + return ONLP_STATUS_E_INVALID; + //get the real temperture value + temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000); + + info->mcelsius=temperature_v; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; + +} + +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rc; + int local_id; + + VALIDATE(id); + + local_id=ONLP_OID_ID_GET(id); + + if((local_id > THERMAL_1_ON_PSU2) || (local_id < THERMAL_1_CLOSE_TO_CPU)){ + DEBUG_PRINT("\n[Debug][%s][%d][outside addr:%d]", __FUNCTION__, __LINE__, local_id); + return ONLP_STATUS_E_INVALID; + } + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2)) + rc= _onlp_thermali_psu_info_get(local_id,info); + else + rc= _onlp_thermali_info_get(local_id,info); + + return rc; +}