mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-26 01:37:04 +00:00
modified for the platform delta ag6248c
This commit is contained in:
@@ -29,9 +29,9 @@
|
||||
#include "platform_lib.h"
|
||||
#include "arm_delta_ag6248c_int.h"
|
||||
#include "arm_delta_i2c.h"
|
||||
#include <onlp/platformi/psui.h>
|
||||
|
||||
|
||||
#define MAX_FAN_SPEED 16000
|
||||
#define MAX_FAN_SPEED 12000
|
||||
#define MAX_PSU_FAN_SPEED 23000
|
||||
|
||||
#define FILE_NAME_LEN 80
|
||||
@@ -176,7 +176,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
|
||||
}
|
||||
else{
|
||||
info->status &= ~ONLP_FAN_STATUS_PRESENT;
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* get fan speed */
|
||||
@@ -213,10 +213,11 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int psu_id;
|
||||
int r_data,fan_rpm;
|
||||
|
||||
int psu_present;
|
||||
int psu_good;
|
||||
psu_type_t psu_type;
|
||||
|
||||
enum ag6248c_product_id pid = get_product_id();
|
||||
enum ag6248c_product_id pid = get_product_id();
|
||||
/* get fan fault status
|
||||
*/
|
||||
psu_id = (local_id - FAN_1_ON_PSU1) + 1;
|
||||
@@ -224,6 +225,12 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
|
||||
|
||||
psu_type = get_psu_type(psu_id); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */
|
||||
DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type);
|
||||
psu_present=psu_status_info_get(psu_id, "present");
|
||||
psu_good=psu_status_info_get(psu_id, "good");
|
||||
if((psu_present<=0)||(psu_good<=0)){
|
||||
info->status &= ~ONLP_FAN_STATUS_PRESENT;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_F2B:
|
||||
@@ -408,13 +415,13 @@ onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
rpm_val=p* MAX_PSU_FAN_SPEED/100;
|
||||
rpm_val=p*(MAX_FAN_SPEED/100);
|
||||
|
||||
/*get ret value for the speed set*/
|
||||
fan_set_rpm_cont=FAN_FROM_REG(rpm_val);
|
||||
|
||||
/*set the rpm speed */
|
||||
rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(id), fan_set_rpm_cont);
|
||||
rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont);
|
||||
|
||||
if(rc<0)
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "arm_delta_ag6248c_log.h"
|
||||
|
||||
#define CHASSIS_THERMAL_COUNT 2
|
||||
#define CHASSIS_THERMAL_COUNT 4
|
||||
#define CHASSIS_PSU_COUNT 2
|
||||
|
||||
#define PSU1_ID 1
|
||||
@@ -53,7 +53,7 @@ psu_type_t get_psu_type(int id);
|
||||
|
||||
enum onlp_fan_duty_cycle_percentage
|
||||
{
|
||||
FAN_IDLE_RPM = 5500,
|
||||
FAN_IDLE_RPM = 5500,
|
||||
FAN_LEVEL1_RPM = 7000,
|
||||
FAN_LEVEL2_RPM = 9000,
|
||||
FAN_LEVEL3_RPM = 12000,
|
||||
@@ -130,5 +130,6 @@ typedef enum platform_id_e {
|
||||
|
||||
extern platform_id_t platform_id;
|
||||
|
||||
extern int psu_status_info_get(int id, char *node);
|
||||
#endif /* __PLATFORM_LIB_H__ */
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -234,9 +234,9 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
psu_type_t psu_type;
|
||||
int r_data;
|
||||
char sn_data[15]={0};
|
||||
char model_data[17]={0};
|
||||
int r_data;
|
||||
char sn_data[15]={0};
|
||||
char model_data[17]={0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
@@ -245,29 +245,30 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
/* Get the present state */
|
||||
val=psu_status_info_get(index, "present");
|
||||
val=psu_status_info_get(index, "present");
|
||||
|
||||
if (val<0) {
|
||||
AIM_LOG_INFO("Unable to read PSU %d present value)\r\n", index);
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
AIM_LOG_INFO("Unable to read PSU %d present value)\r\n", index);
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_PRESENT) {
|
||||
if (val != PSU_STATUS_PRESENT) {
|
||||
info->status &= ~ONLP_PSU_STATUS_PRESENT;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
/* Get power good status */
|
||||
val=psu_status_info_get(index,"good");
|
||||
val=psu_status_info_get(index,"good");
|
||||
|
||||
if (val<0) {
|
||||
AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index);
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
if (val<0) {
|
||||
AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index);
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_POWER_GOOD) {
|
||||
info->status |= ONLP_PSU_STATUS_FAILED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Get PSU type
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "platform_lib.h"
|
||||
#include "arm_delta_ag6248c_log.h"
|
||||
#include <stdio.h>
|
||||
#include "arm_delta_i2c.h"
|
||||
#define prefix_path "/sys/bus/i2c/devices/"
|
||||
#define LOCAL_DEBUG 0
|
||||
|
||||
@@ -46,7 +47,7 @@ enum onlp_thermal_id
|
||||
{
|
||||
THERMAL_RESERVED = 0,
|
||||
THERMAL_1_CLOSE_TO_MAC,
|
||||
THERMAL_2_CLOSE_TO_PHY,
|
||||
THERMAL_2_CLOSE_TO_PHY,
|
||||
THERMAL_1_ON_PSU1,
|
||||
THERMAL_1_ON_PSU2,
|
||||
};
|
||||
@@ -56,8 +57,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */
|
||||
"reserved",
|
||||
"0-0049/temp1_input",
|
||||
"0-004a/temp1_input",
|
||||
"4-0058/psu_temp1_input",
|
||||
"5-0058/psu_temp1_input",
|
||||
};
|
||||
|
||||
/* Static values */
|
||||
@@ -80,7 +79,19 @@ static onlp_thermal_info_t linfo[] = {
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
}
|
||||
};
|
||||
|
||||
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.
|
||||
*/
|
||||
@@ -100,20 +111,17 @@ onlp_thermali_init(void)
|
||||
* Note -- it is expected that you fill out the information
|
||||
* 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)
|
||||
static int
|
||||
_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 */
|
||||
sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);
|
||||
|
||||
@@ -126,3 +134,75 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
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 ag6248c_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");
|
||||
psu_good=psu_status_info_get(psu_id, "good");
|
||||
if((psu_present<=0)||(psu_good<=0)){
|
||||
info->status &= ~ONLP_THERMAL_STATUS_PRESENT;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
//read the pus temperture register value
|
||||
if(pid == PID_AG6248C_48){
|
||||
if(psu_id==1)
|
||||
r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d);
|
||||
else
|
||||
r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d);
|
||||
}
|
||||
else{
|
||||
if(psu_id==1)
|
||||
r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x8d);
|
||||
else
|
||||
r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x8d);
|
||||
}
|
||||
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);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[local_id];
|
||||
|
||||
if((local_id==THERMAL_1_CLOSE_TO_MAC) || (local_id==THERMAL_2_CLOSE_TO_PHY))
|
||||
rc= _onlp_thermali_info_get(local_id,info);
|
||||
else 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_STATUS_E_INVALID;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user