mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-26 17:57:01 +00:00
Merge pull request #256 from DeltaProducts/master3
bugfix for Delta's AG5648, AG9032v1, AGC7648a
This commit is contained in:
@@ -201,10 +201,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \
|
||||
|
||||
exponent = two_complement_to_int(data->vout_mode, 5, 0x1f);
|
||||
mantissa = data->v_out;
|
||||
|
||||
return (exponent > 0) ? sprintf(buf, "%d\n", \
|
||||
(mantissa << exponent) * multiplier) : \
|
||||
sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent));
|
||||
return (exponent > 0) ? sprintf(buf, "%d\n", \
|
||||
mantissa * (1 << exponent)) : \
|
||||
sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define dni_onlp_thermal_threshold(WARNING_DEFAULT, ERROR_DEFAULT, SHUTDOWN_DEFAULT){ \
|
||||
WARNING_DEFAULT, \
|
||||
ERROR_DEFAULT, \
|
||||
SHUTDOWN_DEFAULT, \
|
||||
}
|
||||
|
||||
static char* last_path[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
@@ -70,27 +76,27 @@ static onlp_thermal_info_t linfo[] = {
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(70000,80000,85000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BOARD), "Thermal sensor near DC fan (U334, Middle)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
|
||||
@@ -48,6 +48,21 @@ class OnlPlatform_x86_64_delta_ag5648_r0(OnlPlatformDelta,
|
||||
os.system("echo 0x04 > /sys/bus/i2c/devices/2-0039/addr")
|
||||
os.system("echo 0x10 > /sys/bus/i2c/devices/2-0039/data")
|
||||
|
||||
#set thermal Thigh & Tlow
|
||||
os.system("echo 80000 > /sys/class/hwmon/hwmon5/temp1_max")
|
||||
os.system("echo 70000 > /sys/class/hwmon/hwmon6/temp1_max")
|
||||
os.system("echo 60000 > /sys/class/hwmon/hwmon7/temp1_max")
|
||||
os.system("echo 85000 > /sys/class/hwmon/hwmon8/temp1_max")
|
||||
os.system("echo 65000 > /sys/class/hwmon/hwmon9/temp1_max")
|
||||
os.system("echo 60000 > /sys/class/hwmon/hwmon10/temp1_max")
|
||||
|
||||
os.system("echo 75000 > /sys/class/hwmon/hwmon5/temp1_max_hyst")
|
||||
os.system("echo 65000 > /sys/class/hwmon/hwmon6/temp1_max_hyst")
|
||||
os.system("echo 55000 > /sys/class/hwmon/hwmon7/temp1_max_hyst")
|
||||
os.system("echo 80000 > /sys/class/hwmon/hwmon8/temp1_max_hyst")
|
||||
os.system("echo 60000 > /sys/class/hwmon/hwmon9/temp1_max_hyst")
|
||||
os.system("echo 55000 > /sys/class/hwmon/hwmon10/temp1_max_hyst")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
7
packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c
Normal file → Executable file
7
packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c
Normal file → Executable file
@@ -243,10 +243,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \
|
||||
|
||||
exponent = two_complement_to_int(data->vout_mode, 5, 0x1f);
|
||||
mantissa = data->v_out;
|
||||
|
||||
return (exponent > 0) ? sprintf(buf, "%d\n", \
|
||||
(mantissa << exponent) * multiplier) : \
|
||||
sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent));
|
||||
return (exponent > 0) ? sprintf(buf, "%d\n", \
|
||||
mantissa * (1 << exponent)) : \
|
||||
sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr,
|
||||
char *buf);
|
||||
static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
|
||||
char *buf);
|
||||
static ssize_t show_fan_percentage(struct device *dev, struct device_attribute *devattr,
|
||||
char *buf);
|
||||
static ssize_t set_fan(struct device *dev, struct device_attribute *devattr,
|
||||
const char *buf, size_t count);
|
||||
static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *devattr,
|
||||
@@ -98,11 +100,11 @@ static SENSOR_DEVICE_ATTR(fan2_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 1);
|
||||
static SENSOR_DEVICE_ATTR(fan3_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 2);
|
||||
static SENSOR_DEVICE_ATTR(fan4_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 3);
|
||||
static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4);
|
||||
static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 0);
|
||||
static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 1);
|
||||
static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 2);
|
||||
static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 3);
|
||||
static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 4);
|
||||
static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 0);
|
||||
static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 1);
|
||||
static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 2);
|
||||
static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 3);
|
||||
static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 4);
|
||||
static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0);
|
||||
static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1);
|
||||
static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2);
|
||||
@@ -172,6 +174,29 @@ static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *d
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_fan_percentage(struct device *dev, struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct emc2305_data *data = i2c_get_clientdata(client);
|
||||
int val;
|
||||
int rpm;
|
||||
int rpm_percentage;
|
||||
|
||||
MUX_SELECT;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
val = i2c_smbus_read_word_swapped(client,
|
||||
EMC2305_REG_FAN_TACH(attr->index));
|
||||
mutex_unlock(&data->lock);
|
||||
/* Left shift 3 bits for showing correct RPM */
|
||||
val = val >> 3;
|
||||
rpm = 3932160 * 2 / (val > 0 ? val : 1);
|
||||
rpm_percentage = rpm / 230;
|
||||
return sprintf(buf, "%d\n", rpm_percentage);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
|
||||
char *buf)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <onlplib/i2c.h>
|
||||
|
||||
#define MAX_FAN_SPEED 23000
|
||||
#define MAX_PSU_FAN_SPEED 19328
|
||||
#define MAX_PSU_FAN_SPEED 18380
|
||||
|
||||
typedef struct fan_path_S
|
||||
{
|
||||
@@ -60,7 +60,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##id##_ON_FAN_BOARD), "Chassis Fan "#id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \
|
||||
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
@@ -70,7 +70,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \
|
||||
( ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
@@ -316,7 +316,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm)
|
||||
case FAN_8_ON_FAN_BOARD:
|
||||
case FAN_9_ON_FAN_BOARD:
|
||||
case FAN_10_ON_FAN_BOARD:
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed);
|
||||
break;
|
||||
default:
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
|
||||
@@ -53,17 +53,17 @@ static onlp_led_info_t linfo[] =
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_RED,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FRONT_PWR1), "FRONT LED (PWR1 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FRONT_PWR2), "FRONT LED (PWR2 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 },
|
||||
@@ -92,34 +92,6 @@ static onlp_led_info_t linfo[] =
|
||||
},
|
||||
};
|
||||
|
||||
/* Function to check fan 1-10 speed normally*/
|
||||
static int dni_fan_speed_good()
|
||||
{
|
||||
int rpm = 0, rpm1 = 0, speed_good = 0;
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN5_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN5_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
return speed_good;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
@@ -141,6 +113,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
/* Set front panel's mode of leds */
|
||||
r_data = dni_lock_swpld_read_attribute(LED_REG);
|
||||
int local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
dev_info_t dev_info;
|
||||
dev_info.bus = I2C_BUS_3;
|
||||
dev_info.offset = 0x00;
|
||||
@@ -149,22 +122,29 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
mux_info_t mux_info;
|
||||
mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG;
|
||||
mux_info.flags = DEFAULT_FLAG;
|
||||
|
||||
switch(local_id)
|
||||
{
|
||||
case LED_FRONT_FAN:
|
||||
if((r_data & 0x01) == 0x01)
|
||||
if((r_data & 0x03) == 0x01)
|
||||
info->mode = ONLP_LED_MODE_GREEN;
|
||||
else if((r_data & 0x02) == 0x02)
|
||||
else if((r_data & 0x03) == 0x02)
|
||||
info->mode = ONLP_LED_MODE_ORANGE;
|
||||
else if((r_data & 0x03) == 0x03 || (r_data & 0x03) == 0x00)
|
||||
info->mode = ONLP_LED_MODE_OFF;
|
||||
else
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
break;
|
||||
case LED_FRONT_SYS:
|
||||
if((r_data & 0x04) == 0x04)
|
||||
if((r_data & 0x0C) == 0x04)
|
||||
info->mode = ONLP_LED_MODE_GREEN;
|
||||
else if((r_data & 0x0C) == 0x0C)
|
||||
info->mode = ONLP_LED_MODE_ORANGE;
|
||||
else if((r_data & 0x08) == 0x08)
|
||||
info->mode = ONLP_LED_MODE_RED;
|
||||
else if((r_data & 0x0C) == 0x08)
|
||||
info->mode = ONLP_LED_MODE_GREEN_BLINKING;
|
||||
else
|
||||
else if((r_data & 0x0C) == 0x00)
|
||||
info->mode = ONLP_LED_MODE_OFF;
|
||||
else
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
break;
|
||||
case LED_FRONT_PWR1:
|
||||
@@ -289,14 +269,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
VALIDATE(id);
|
||||
// int local_id = ONLP_OID_ID_GET(id);
|
||||
if(on_or_off == 0)
|
||||
onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
else
|
||||
onlp_ledi_mode_set(id,ONLP_LED_MODE_AUTO);
|
||||
if (!on_or_off)
|
||||
{
|
||||
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -310,210 +288,165 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
VALIDATE(id);
|
||||
int local_id = ONLP_OID_ID_GET(id);
|
||||
int i = 0, count = 0;
|
||||
int state = 0, fantray_present = -1, rpm = 0, rpm1 = 0;
|
||||
uint8_t front_panel_led_value, power_state,fan_tray_led_reg_value,fan_tray_led_reg_2_value;
|
||||
uint8_t front_panel_led_value, fan_tray_led_reg_value,fan_tray_led_reg_2_value;
|
||||
|
||||
mux_info_t mux_info;
|
||||
mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG;
|
||||
mux_info.flags = DEFAULT_FLAG;
|
||||
|
||||
dev_info_t dev_info;
|
||||
dev_info.bus = I2C_BUS_3;
|
||||
dev_info.offset = 0x00;
|
||||
dev_info.flags = DEFAULT_FLAG;
|
||||
|
||||
front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG);
|
||||
fan_tray_led_reg_value = dni_lock_swpld_read_attribute(FAN_TRAY_LED_REG);
|
||||
fan_tray_led_reg_2_value = dni_lock_swpld_read_attribute(FAN_TRAY_LED_REG_2);
|
||||
switch(local_id)
|
||||
{
|
||||
case LED_FRONT_FAN:
|
||||
fan_tray_led_reg_2_value = dni_lock_swpld_read_attribute(FAN_TRAY_LED_REG_2);
|
||||
switch(local_id)
|
||||
{
|
||||
case LED_FRONT_FAN:
|
||||
/* Clean the bit 1,0 */
|
||||
front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG);
|
||||
front_panel_led_value &= ~0x3;
|
||||
/* Read fan eeprom to check present. Fan tray 1-5 */
|
||||
for(i = 0; i < 5; i++)
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{
|
||||
mux_info.channel = i;
|
||||
dev_info.addr = FAN_TRAY_1 + i;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
if( fantray_present >= 0)
|
||||
count++;
|
||||
front_panel_led_value |= 0x01;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
/* Set front light of FAN */
|
||||
if(count == ALL_FAN_TRAY_EXIST && dni_fan_speed_good() == FAN_SPEED_NORMALLY)
|
||||
{
|
||||
front_panel_led_value |= 0x01;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else
|
||||
else if(mode == ONLP_LED_MODE_ORANGE)
|
||||
{
|
||||
front_panel_led_value |= 0x02;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
|
||||
break;
|
||||
case LED_FRONT_PWR1:
|
||||
/* Clean bit 7,6 */
|
||||
front_panel_led_value &= ~0xC0;
|
||||
/* switch CPLD to PSU 1 */
|
||||
dev_info.bus = I2C_BUS_4;
|
||||
dev_info.addr = PSU_EEPROM;
|
||||
mux_info.channel = 0x00;
|
||||
state = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
/* Check the state of PSU 1, "state = 1, PSU exists' */
|
||||
if(state == 1)
|
||||
{
|
||||
power_state = dni_lock_swpld_read_attribute(CTL_REG);
|
||||
/* Set the light of PSU */
|
||||
if((power_state&0x80) != 0x80)
|
||||
{
|
||||
/* Red */
|
||||
front_panel_led_value |= 0x80;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if((power_state & 0x80) == 0x80)
|
||||
{
|
||||
/* Green */
|
||||
front_panel_led_value |= 0x40;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
}
|
||||
else
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
break;
|
||||
case LED_FRONT_PWR1:
|
||||
/* Clean bit 7,6 */
|
||||
front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG);
|
||||
front_panel_led_value &= ~0xC0;
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{
|
||||
/* Green */
|
||||
front_panel_led_value |= 0x40;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING)
|
||||
{
|
||||
/* BLINKING ORANGE */
|
||||
front_panel_led_value |= 0x80;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if(mode == ONLP_LED_MODE_OFF)
|
||||
{
|
||||
front_panel_led_value &= ~0xC0;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
case LED_FRONT_PWR2:
|
||||
/* Set front light of PSU 2 */
|
||||
/* Clean bit 5,4 */
|
||||
front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG);
|
||||
front_panel_led_value &= ~0x30;
|
||||
/* switch CPLD to PSU 2 */
|
||||
dev_info.bus = I2C_BUS_4;
|
||||
dev_info.addr = PSU_EEPROM;
|
||||
mux_info.channel = 0x20;
|
||||
state = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
/* Check the state of PSU 2, "state = 1, PSU exists' */
|
||||
if(state == 1)
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{
|
||||
power_state = dni_lock_swpld_read_attribute(CTL_REG);
|
||||
if((power_state & 0x40) != 0x40)
|
||||
{
|
||||
/* Red */
|
||||
front_panel_led_value |= 0x20;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if((power_state & 0x40) == 0x40)
|
||||
{
|
||||
/* Green */
|
||||
front_panel_led_value |= 0x10;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
/* Green */
|
||||
front_panel_led_value |= 0x10;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING)
|
||||
{
|
||||
/* BLINKING ORANGE */
|
||||
front_panel_led_value |= 0x20;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if(mode == ONLP_LED_MODE_OFF)
|
||||
{
|
||||
front_panel_led_value &= ~0x30;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
|
||||
case LED_FRONT_SYS:
|
||||
front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG);
|
||||
front_panel_led_value &= ~0x0C;
|
||||
if(mode == ONLP_LED_MODE_GREEN_BLINKING)
|
||||
{
|
||||
front_panel_led_value |= 0x08;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if (mode == ONLP_LED_MODE_GREEN)
|
||||
{
|
||||
front_panel_led_value |= 0x04;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else if (mode == ONLP_LED_MODE_RED)
|
||||
{
|
||||
front_panel_led_value |= 0x0c;
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
}
|
||||
else
|
||||
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
|
||||
break;
|
||||
|
||||
case LED_REAR_FAN_TRAY_1:
|
||||
/* Select fan tray 1 */
|
||||
mux_info.channel = 0x00;
|
||||
dev_info.addr = FAN_TRAY_1;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
/* Clean bit 7,6 */
|
||||
fan_tray_led_reg_value &= ~0xC0;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN5_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN5_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{/* Green light */
|
||||
fan_tray_led_reg_value |= 0x40;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
fan_tray_led_reg_value &= ~0xC0;
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{/* Green light */
|
||||
fan_tray_led_reg_value |= 0x40;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
fan_tray_led_reg_value |= 0x80;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LED_REAR_FAN_TRAY_2:
|
||||
/* Select fan tray 2 */
|
||||
mux_info.channel = 0x01;
|
||||
dev_info.addr = FAN_TRAY_2;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
/* Clean bit 5,4 */
|
||||
fan_tray_led_reg_value &= ~0x30;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR);
|
||||
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{/* Green light */
|
||||
fan_tray_led_reg_value |= 0x10;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fan_tray_led_reg_value |= 0x20;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
{/* Red light */
|
||||
fan_tray_led_reg_value |= 0x20;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
break;
|
||||
case LED_REAR_FAN_TRAY_3:
|
||||
/* Select fan tray 3 */
|
||||
mux_info.channel = 0x02;
|
||||
dev_info.addr = FAN_TRAY_3;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
fan_tray_led_reg_value &= ~0x0c;
|
||||
/* Clean bit 3,2 */
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{/* Green light */
|
||||
fan_tray_led_reg_value |= 0x04;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fan_tray_led_reg_value |= 0x08;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
{/* Red light */
|
||||
fan_tray_led_reg_value |= 0x08;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
break;
|
||||
case LED_REAR_FAN_TRAY_4:
|
||||
/* Select fan tray 4 */
|
||||
mux_info.channel = 0x03;
|
||||
dev_info.addr = FAN_TRAY_4;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
/* Clean bit 1,0 */
|
||||
fan_tray_led_reg_value &= ~0x03;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm !=0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{/* Green light */
|
||||
fan_tray_led_reg_value |= 0x01;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
{/* Red light */
|
||||
fan_tray_led_reg_value |= 0x02;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
|
||||
}
|
||||
break;
|
||||
case LED_REAR_FAN_TRAY_5:
|
||||
/* Select fan tray 5 */
|
||||
mux_info.channel = 0x04;
|
||||
dev_info.addr = FAN_TRAY_5;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
/* Clean bit 7,6 */
|
||||
fan_tray_led_reg_2_value &= ~0xC0;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 !=0 )
|
||||
{
|
||||
case LED_REAR_FAN_TRAY_5:
|
||||
fan_tray_led_reg_2_value &= ~0xC0;
|
||||
if(mode == ONLP_LED_MODE_GREEN)
|
||||
{/* Green light */
|
||||
fan_tray_led_reg_2_value |= 0x40;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
fan_tray_led_reg_2_value |= 0x80;
|
||||
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
@@ -526,6 +459,3 @@ onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,33 @@
|
||||
#include <onlplib/mmap.h>
|
||||
#include <pthread.h>
|
||||
|
||||
int dni_fan_speed_good()
|
||||
{
|
||||
int rpm = 0, rpm1 = 0, speed_good = 0;
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN5_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN5_REAR);
|
||||
if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960)
|
||||
speed_good++;
|
||||
return speed_good;
|
||||
}
|
||||
|
||||
int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, int data_len)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -168,6 +168,8 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath);
|
||||
int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullpath);
|
||||
int dni_lock_swpld_read_attribute(int addr);
|
||||
int dni_lock_swpld_write_attribute(int addr, int addr1);
|
||||
int dni_fan_speed_good();
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -210,66 +210,174 @@ onlp_sysi_platform_manage_leds(void)
|
||||
{
|
||||
/* Set front lights: fan, power supply 1, 2
|
||||
*/
|
||||
uint8_t addr, present_bit = 0x00, bit = 0x00;
|
||||
|
||||
addr = dni_lock_swpld_read_attribute(LED_REG);
|
||||
/* Turn the fan led on or off */
|
||||
if((addr & 0x3) == 0 || (addr & 0x3) == 0x3 )
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON);
|
||||
|
||||
/* Set front light of PSU 1 */
|
||||
addr = dni_lock_swpld_read_attribute(LED_REG);
|
||||
|
||||
if((addr & 0xC0) == 0 || (addr & 0xC0) == 0xC0 )
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), TURN_ON);
|
||||
|
||||
/* Set front light of PSU 2 */
|
||||
addr = dni_lock_swpld_read_attribute(LED_REG);
|
||||
if((addr & 0x30) == 0 || (addr & 0x30) == 0x30 )
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), TURN_ON);
|
||||
|
||||
/* Rear light fan tray 1-5 */
|
||||
dev_info_t dev_info;
|
||||
dev_info.bus = I2C_BUS_3;
|
||||
dev_info.addr = FAN_IO_CTL;
|
||||
dev_info.offset = 0x00;
|
||||
dev_info.flags = DEFAULT_FLAG;
|
||||
|
||||
int fantray_present = -1, rpm, rpm1,i=0,count=0, state;
|
||||
uint8_t power_state;
|
||||
mux_info_t mux_info;
|
||||
mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG;
|
||||
mux_info.flags = DEFAULT_FLAG;
|
||||
mux_info.channel = 0x07;
|
||||
|
||||
/* Turn on or off the fan trays' leds */
|
||||
present_bit = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
if((present_bit & ((bit+1)<<4)) == 0)
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON);
|
||||
if((present_bit & ((bit+1)<<3)) == 0)
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON);
|
||||
if((present_bit & ((bit+1)<<2)) == 0)
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON);
|
||||
if((present_bit & ((bit+1)<<1)) == 0)
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF);
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON);
|
||||
|
||||
if((present_bit & ((bit+1)<<0)) == 0)
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5), TURN_OFF);
|
||||
dev_info_t dev_info;
|
||||
dev_info.bus = I2C_BUS_3;
|
||||
dev_info.offset = 0x00;
|
||||
dev_info.flags = DEFAULT_FLAG;
|
||||
|
||||
|
||||
/* Fan tray 1 */
|
||||
mux_info.channel = 0x00;
|
||||
dev_info.addr = FAN_TRAY_1;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN5_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN5_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{/* Green light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
else
|
||||
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5), TURN_ON);
|
||||
{/* Red light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED);
|
||||
}
|
||||
/* Fan tray 2 */
|
||||
mux_info.channel = 0x01;
|
||||
dev_info.addr = FAN_TRAY_2;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{/* Green light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED);
|
||||
}
|
||||
/* Fan tray 3 */
|
||||
mux_info.channel = 0x02;
|
||||
dev_info.addr = FAN_TRAY_3;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{/* Green light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED);
|
||||
}
|
||||
/* Fan tray 4 */
|
||||
mux_info.channel = 0x03;
|
||||
dev_info.addr = FAN_TRAY_4;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{/* Green light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED);
|
||||
}
|
||||
/* Fan tray 5 */
|
||||
mux_info.channel = 0x04;
|
||||
dev_info.addr = FAN_TRAY_5;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT);
|
||||
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR);
|
||||
if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 )
|
||||
{/* Green light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5),ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
else
|
||||
{/* Red light */
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5),ONLP_LED_MODE_RED);
|
||||
}
|
||||
|
||||
/* FRONT FAN LED & SYS */
|
||||
for(i = 0; i < 5; i++)
|
||||
{
|
||||
mux_info.channel = i;
|
||||
dev_info.addr = FAN_TRAY_1 + i;
|
||||
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
if( fantray_present >= 0)
|
||||
count++;
|
||||
}
|
||||
/* Set front light of FAN */
|
||||
if(count == ALL_FAN_TRAY_EXIST && dni_fan_speed_good() == FAN_SPEED_NORMALLY)
|
||||
{
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_GREEN);
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_ORANGE);
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), ONLP_LED_MODE_RED);
|
||||
}
|
||||
/* Set front light of PWR1 */
|
||||
dev_info.bus = I2C_BUS_4;
|
||||
dev_info.addr = PSU_EEPROM;
|
||||
mux_info.channel = 0x00;
|
||||
state = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
/* Check the state of PSU 1, "state = 1, PSU exists' */
|
||||
if(state == 1)
|
||||
{
|
||||
power_state = dni_lock_swpld_read_attribute(CTL_REG);
|
||||
/* Set the light of PSU */
|
||||
if((power_state&0x80) != 0x80)
|
||||
{
|
||||
/* Red */
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), ONLP_LED_MODE_ORANGE_BLINKING);
|
||||
}
|
||||
else if((power_state & 0x80) == 0x80)
|
||||
{
|
||||
/* Green */
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
}
|
||||
else
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), ONLP_LED_MODE_OFF);
|
||||
/* Set front light of PWR1 */
|
||||
dev_info.bus = I2C_BUS_4;
|
||||
dev_info.addr = PSU_EEPROM;
|
||||
mux_info.channel = 0x20;
|
||||
state = dni_i2c_lock_read(&mux_info, &dev_info);
|
||||
|
||||
/* Check the state of PSU 2, "state = 1, PSU exists' */
|
||||
if(state == 1)
|
||||
{
|
||||
power_state = dni_lock_swpld_read_attribute(CTL_REG);
|
||||
/* Set the light of PSU */
|
||||
if((power_state&0x40) != 0x40)
|
||||
{
|
||||
/* Red */
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), ONLP_LED_MODE_ORANGE_BLINKING);
|
||||
}
|
||||
else if((power_state & 0x40) == 0x40)
|
||||
{
|
||||
/* Green */
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), ONLP_LED_MODE_GREEN);
|
||||
}
|
||||
}
|
||||
else
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), ONLP_LED_MODE_OFF);
|
||||
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define dni_onlp_thermal_threshold(WARNING_DEFAULT, ERROR_DEFAULT, SHUTDOWN_DEFAULT){ \
|
||||
WARNING_DEFAULT, \
|
||||
ERROR_DEFAULT, \
|
||||
SHUTDOWN_DEFAULT, \
|
||||
}
|
||||
|
||||
static char* last_path[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
@@ -69,23 +75,23 @@ static onlp_thermal_info_t linfo[] = {
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "CPU below side thermal sensor (U57, Below of CPU)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Wind thermal sensor (U334, Near FAN)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_SW_BOARD), "MAC up side thermal sersor (U38, up side of MAC)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_SW_BOARD), "MAC down side thermal sensor (U40, down side of MAC)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(60000,70000,75000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_SW_BOARD), "Surroundings thermal sensor (U240, Near front panel)", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000)
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
|
||||
@@ -41,8 +41,20 @@ class OnlPlatform_x86_64_delta_ag9032v1_r0(OnlPlatformDelta,
|
||||
self.new_i2c_device('tmp75', 0x4f, 3)
|
||||
|
||||
#Insert sfp module
|
||||
self.insmod('dni_ag9032v1_sfp')
|
||||
self.new_i2c_device('dni_ag9032v1_sfp', 0x50, 5)
|
||||
self.insmod('dni_ag9032v1_sfp')
|
||||
self.new_i2c_device('dni_ag9032v1_sfp', 0x50, 5)
|
||||
|
||||
#set thermal Thigh & Tlow
|
||||
os.system("echo 60000 > /sys/class/hwmon/hwmon4/temp1_max")
|
||||
os.system("echo 65000 > /sys/class/hwmon/hwmon8/temp1_max")
|
||||
os.system("echo 80000 > /sys/class/hwmon/hwmon5/temp1_max")
|
||||
os.system("echo 75000 > /sys/class/hwmon/hwmon6/temp1_max")
|
||||
os.system("echo 65000 > /sys/class/hwmon/hwmon7/temp1_max")
|
||||
os.system("echo 55000 > /sys/class/hwmon/hwmon4/temp1_max_hyst")
|
||||
os.system("echo 60000 > /sys/class/hwmon/hwmon8/temp1_max_hyst")
|
||||
os.system("echo 75000 > /sys/class/hwmon/hwmon5/temp1_max_hyst")
|
||||
os.system("echo 70000 > /sys/class/hwmon/hwmon6/temp1_max_hyst")
|
||||
os.system("echo 60000 > /sys/class/hwmon/hwmon7/temp1_max_hyst")
|
||||
|
||||
#set front panel sys light "GREEN"
|
||||
os.system("echo 0x1C > /sys/bus/i2c/devices/6-0031/addr")
|
||||
|
||||
@@ -58,27 +58,27 @@ decide_percentage(int *percentage, int temper)
|
||||
{
|
||||
int level;
|
||||
|
||||
if(temper <= 25)
|
||||
if(temper < 65)
|
||||
{
|
||||
*percentage = 40;
|
||||
*percentage = 50;
|
||||
level = 0;
|
||||
}
|
||||
else if(temper > 25 && temper <= 40)
|
||||
else if(temper >= 65 && temper <= 70)
|
||||
{
|
||||
*percentage = 60;
|
||||
level = 1;
|
||||
}
|
||||
else if(temper > 40 && temper <= 55)
|
||||
else if(temper > 70 && temper <= 75)
|
||||
{
|
||||
*percentage = 80;
|
||||
*percentage = 70;
|
||||
level = 2;
|
||||
}
|
||||
else if(temper > 55 && temper <= 75)
|
||||
else if(temper > 75 && temper <= 80)
|
||||
{
|
||||
*percentage = 90;
|
||||
*percentage = 85;
|
||||
level = 3;
|
||||
}
|
||||
else if(temper > 75)
|
||||
else if(temper > 80)
|
||||
{
|
||||
*percentage = 100;
|
||||
level = 4;
|
||||
|
||||
Reference in New Issue
Block a user