1. Fixed bug: 1.1 shows the correct percentage speed display on fan
         2. modify the corresponding LED capability

Signed-off-by: johnson.lu <johnson.lu@deltaww.com>
This commit is contained in:
johnson.lu
2017-12-08 15:54:40 +08:00
parent 558bc2fe60
commit 91cec7c245
10 changed files with 422 additions and 325 deletions

View File

@@ -176,8 +176,8 @@ static ssize_t for_linear_data(struct device *dev, struct device_attribute \
exponent = two_complement_to_int(value >> 11, 5, 0x1f);
mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff);
return (exponent >= 0) ? sprintf(buf, "%d\n", \
(mantissa << exponent) * multiplier) : \
return (exponent >= 0) ? \
sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) : \
sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent));
}
@@ -201,9 +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 * (1 << exponent)) : \
sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier);
return (exponent > 0) ? \
sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \
sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent));
}

View File

@@ -199,7 +199,7 @@ static ssize_t for_r_port_data(struct device *dev, struct device_attribute *dev_
}
}
return sprintf(buf, "%d\n", sfp_port_data);
return sprintf(buf, "%d\n", (int)sfp_port_data);
}
static ssize_t set_w_lp_mode_data(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count)

View File

@@ -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_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,
@@ -57,6 +59,7 @@ static const unsigned short normal_i2c[] = { 0x2C, 0x2D, 0x2E, 0x2F, 0x4C,
#define EMC2305_DEVICE 0x34
#define EMC2305_VENDOR 0x5D
#define MAX_FAN_SPEED 23000
struct emc2305_data
{
@@ -95,17 +98,17 @@ static SENSOR_DEVICE_ATTR(fan1_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 0);
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(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4);
static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 0);
static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 1);
static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 2);
static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 3);
//static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_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);
static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3);
static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4);
//static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4);
static struct attribute *emc2305_attr[] =
{
@@ -113,17 +116,17 @@ static struct attribute *emc2305_attr[] =
&sensor_dev_attr_fan2_input.dev_attr.attr,
&sensor_dev_attr_fan3_input.dev_attr.attr,
&sensor_dev_attr_fan4_input.dev_attr.attr,
&sensor_dev_attr_fan5_input.dev_attr.attr,
// &sensor_dev_attr_fan5_input.dev_attr.attr,
&sensor_dev_attr_fan1_input_percentage.dev_attr.attr,
&sensor_dev_attr_fan2_input_percentage.dev_attr.attr,
&sensor_dev_attr_fan3_input_percentage.dev_attr.attr,
&sensor_dev_attr_fan4_input_percentage.dev_attr.attr,
&sensor_dev_attr_fan5_input_percentage.dev_attr.attr,
// &sensor_dev_attr_fan5_input_percentage.dev_attr.attr,
&sensor_dev_attr_pwm1.dev_attr.attr,
&sensor_dev_attr_pwm2.dev_attr.attr,
&sensor_dev_attr_pwm3.dev_attr.attr,
&sensor_dev_attr_pwm4.dev_attr.attr,
&sensor_dev_attr_pwm5.dev_attr.attr,
// &sensor_dev_attr_pwm5.dev_attr.attr,
NULL
};
@@ -169,6 +172,25 @@ static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *d
return count;
}
static ssize_t show_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;
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;
if ((int)(3932160 * 2 / (val > 0 ? val : 1) == 960))return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", (int)(3932160 * 2 / (val > 0 ? val : 1) * 100 / MAX_FAN_SPEED));
}
static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
char *buf)
@@ -332,7 +354,7 @@ static int emc2305_probe(struct i2c_client *client,
goto exit_remove;
}
for (i = 0; i < 5; i++)
for (i = 0; i < 4; i++)
{
/* set minimum drive to 0% */
i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_MIN_DRIVE(i), FAN_MINIMUN);

View File

@@ -39,14 +39,14 @@ typedef struct fan_path_S
static fan_path_T fan_path[] = /* must map with onlp_fan_id */
{
{ NULL, NULL, NULL },
{ "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input" },
{ "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input" },
{ "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input" },
{ "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input" },
{ "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input" },
{ "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input" },
{ "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input" },
{ "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input" },
{ "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input_percentage" },
{ "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input_percentage" },
{ "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input_percentage" },
{ "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input_percentage" },
{ "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input_percentage" },
{ "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input_percentage" },
{ "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input_percentage" },
{ "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input_percentage" },
{ "/6-0059/psu_fan1_fault", "/6-0059/psu_fan1_speed_rpm", "/6-0059/psu_fan1_duty_cycle_percentage" },
{ "/6-0058/psu_fan1_fault", "/6-0058/psu_fan1_speed_rpm", "/6-0058/psu_fan1_duty_cycle_percentage" }
};
@@ -55,7 +55,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, \
@@ -274,7 +274,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm)
case FAN_6_ON_FAN_BOARD:
case FAN_7_ON_FAN_BOARD:
case FAN_8_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;
@@ -303,13 +303,21 @@ onlp_fani_percentage_set(onlp_oid_t id, int percentage)
/* Select PSU member */
switch (local_id) {
case FAN_1_ON_PSU1:
case FAN_1_ON_PSU2:
break;
case FAN_1_ON_FAN_BOARD:
case FAN_2_ON_FAN_BOARD:
case FAN_3_ON_FAN_BOARD:
case FAN_4_ON_FAN_BOARD:
case FAN_5_ON_FAN_BOARD:
case FAN_6_ON_FAN_BOARD:
case FAN_7_ON_FAN_BOARD:
case FAN_8_ON_FAN_BOARD:
case FAN_1_ON_PSU1:
case FAN_1_ON_PSU2:
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed);
break;
default:
return ONLP_STATUS_E_INVALID;
}
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed);
/* Write percentage to psu_fan1_duty_cycle_percentage */
sprintf(data, "%d", percentage);

View File

@@ -2,7 +2,7 @@
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014 Big Switch Networks, Inc.
* Copyright (C) 2017 Delta Networks, Inc.
* Copyright (C) 2017 Delta Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
@@ -43,44 +43,44 @@
* Get the information for the given LED OID.
*/
static onlp_led_info_t linfo[] =
{
{ }, /* Not used */
{
{ }, /* Not used */
{
{ ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_AUTO,
},
{
{ 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_ORANGE | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO,
},
{
{ ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO,
},
};
{ ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
};
/*
* This function will be called prior to any other onlp_ledi_* functions.
*/
@@ -104,10 +104,10 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
dev_info.flags = DEFAULT_FLAG;
/* Set front panel's mode of leds */
r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG);
r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG);
int local_id = ONLP_OID_ID_GET(id);
switch(local_id)
{
{
case LED_FRONT_FAN:
if((r_data & 0xc0) == 0x80)
info->mode = ONLP_LED_MODE_GREEN;
@@ -118,6 +118,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
else
info->mode = ONLP_LED_MODE_OFF;
break;
case LED_FRONT_SYS:
if((r_data & 0x30) == 0x10)
info->mode = ONLP_LED_MODE_GREEN;
@@ -125,9 +126,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
info->mode = ONLP_LED_MODE_ORANGE;
else if((r_data & 0x30) == 0x00)
info->mode = ONLP_LED_MODE_GREEN_BLINKING;
else if((r_data & 0x30) == 0x30)
info->mode = ONLP_LED_MODE_ORANGE_BLINKING;
else
return ONLP_STATUS_E_INTERNAL;
break;
case LED_FRONT_PWR:
if((r_data & 0x06) == 0x04)
info->mode = ONLP_LED_MODE_GREEN;
@@ -138,67 +142,80 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
else
info->mode = ONLP_LED_MODE_OFF;
break;
case LED_REAR_FAN_TRAY_1:
dev_info.addr = FAN_TRAY_1;
r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG);
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
if(fantray_present >= 0)
{
if((r_data & 0x01) == 0x01)
info->mode = ONLP_LED_MODE_GREEN;
else
info->mode = ONLP_LED_MODE_ORANGE;
}
{
if((r_data & 0x01) == 0x01)
info->mode = ONLP_LED_MODE_GREEN;
else if((r_data & 0x02) == 0x02)
info->mode = ONLP_LED_MODE_RED;
else
info->mode = ONLP_LED_MODE_OFF;
}
else
info->mode = ONLP_LED_MODE_OFF;
info->status = ONLP_LED_STATUS_FAILED;
break;
case LED_REAR_FAN_TRAY_2:
dev_info.addr = FAN_TRAY_2;
r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG);
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
if(fantray_present >= 0)
{
if((r_data & 0x04) == 0x04)
info->mode = ONLP_LED_MODE_GREEN;
else
info->mode = ONLP_LED_MODE_ORANGE;
}
{
if((r_data & 0x04) == 0x04)
info->mode = ONLP_LED_MODE_GREEN;
else if((r_data & 0x08) == 0x08)
info->mode = ONLP_LED_MODE_RED;
else
info->mode = ONLP_LED_MODE_OFF;
}
else
info->mode = ONLP_LED_MODE_OFF;
info->status = ONLP_LED_STATUS_FAILED;
break;
case LED_REAR_FAN_TRAY_3:
dev_info.addr = FAN_TRAY_3;
r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG);
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
if(fantray_present >= 0)
{
if((r_data & 0x10) == 0x10)
info->mode = ONLP_LED_MODE_GREEN;
else
info->mode = ONLP_LED_MODE_ORANGE;
}
{
if((r_data & 0x10) == 0x10)
info->mode = ONLP_LED_MODE_GREEN;
else if((r_data & 0x20) == 0x20)
info->mode = ONLP_LED_MODE_RED;
else
info->mode = ONLP_LED_MODE_OFF;
}
else
info->mode = ONLP_LED_MODE_OFF;
info->status = ONLP_LED_STATUS_FAILED;
break;
case LED_REAR_FAN_TRAY_4:
dev_info.addr = FAN_TRAY_4;
r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG);
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
if(fantray_present >= 0)
{
if((r_data & 0x40) == 0x40)
info->mode = ONLP_LED_MODE_GREEN;
else
info->mode = ONLP_LED_MODE_ORANGE;
}
{
if((r_data & 0x40) == 0x40)
info->mode = ONLP_LED_MODE_GREEN;
else if((r_data & 0x80) == 0x80)
info->mode = ONLP_LED_MODE_RED;
else
info->mode = ONLP_LED_MODE_OFF;
}
else
info->mode = ONLP_LED_MODE_OFF;
info->status = ONLP_LED_STATUS_FAILED;
break;
default:
break;
}
}
/* Set the on/off status */
if (info->mode == ONLP_LED_MODE_OFF)
if (info->mode == ONLP_LED_MODE_OFF)
info->status |= ONLP_LED_STATUS_FAILED;
else
info->status |=ONLP_LED_STATUS_PRESENT;
@@ -236,186 +253,145 @@ 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 ,fan_board_not_present_count = 0 , fan_stat2_reg_mask = 0 , fan_stat1_reg_mask = 0 ;
int fantray_present = -1, rpm = 0, rpm1 = 0;
uint8_t front_panel_led_value, power_state,fan_tray_led_reg_value, fan_led_status_value, fan_tray_pres_value;
uint8_t psu1_state, psu2_state, alarm_reg_value, fan_tray_interface_detected_value;
dev_info_t dev_info;
dev_info.bus = I2C_BUS_3;
dev_info.offset = 0x00;
dev_info.flags = DEFAULT_FLAG;
uint8_t front_panel_led_value,fan_tray_led_reg_value;
front_panel_led_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG);
fan_tray_led_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG);
fan_led_status_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT1_REG);
fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG);
alarm_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,ALARM_REG);
switch(local_id)
{
{
case LED_FRONT_FAN:
/* Clean the bit 7,6 */
front_panel_led_value &= ~0xC0;
fan_board_not_present_count = 0;
/* Read cpld fan status to check present. Fan tray 1-4 */
for(i = 0; i < 4; i++)
{
fan_stat2_reg_mask = 0x01 << i;
fan_stat1_reg_mask = 0x01 << (i * 2);
if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask)
fan_board_not_present_count++;
else if((fan_led_status_value & fan_stat1_reg_mask) == fan_stat1_reg_mask)
count++;
}
/* Set front light of FAN */
if(count == ALL_FAN_TRAY_EXIST)
{
front_panel_led_value |= 0x80;/*Solid green, FAN operates normally.*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value);
}
else if (fan_board_not_present_count > 0)
{
front_panel_led_value |= 0xc0;/*Blinking Yellow , FAN is failed */
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value);
}
front_panel_led_value &= ~0xc0;
if(mode == ONLP_LED_MODE_GREEN)
{
front_panel_led_value |= 0x80;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
front_panel_led_value |= 0x40;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING)
{
front_panel_led_value |= 0xc0;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else
{
front_panel_led_value |= 0x40;/*Solid Amber FAN operating is NOT present */
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value);
}
break;
case LED_FRONT_PWR:
/* Clean bit 2,1 */
front_panel_led_value &= ~0x06;
/* switch CPLD to PSU 1 */
dev_info.bus = I2C_BUS_6;
dev_info.addr = PSU1_EEPROM;
psu1_state = dni_i2c_lock_read(NULL, &dev_info);
/* switch CPLD to PSU 2 */
dev_info.addr = PSU2_EEPROM;
psu2_state = dni_i2c_lock_read(NULL, &dev_info);
if(psu1_state == 1 && psu2_state == 1)
{
power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG);
if((power_state & 0x40) == 0x40 || (power_state & 0x04) == 0x04)
{
front_panel_led_value |= 0x06; /*Blinking Amber*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value);
}
else
{
front_panel_led_value |= 0x04; /*Solid Green*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value);
}
}
else
front_panel_led_value |= 0x02; /*Solid Amber*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value);
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
break;
case LED_FRONT_SYS:
/* Clean bit 4,5 */
front_panel_led_value &= ~0x30;
fan_board_not_present_count = 0;
/* Read fan eeprom to check present */
for(i = 0;i < 4; i++)
{
fan_stat2_reg_mask = 0x01 << i;
if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask)
fan_board_not_present_count++;
}
if(fan_board_not_present_count > 0 || (alarm_reg_value & 0xff) == 0xff)
{
fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG);
if(fan_tray_interface_detected_value == 0xfe || (alarm_reg_value & 0xff) == 0xff)
{
front_panel_led_value |= 0x20;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value);
}
}
if(mode == ONLP_LED_MODE_GREEN)
{
front_panel_led_value |= 0x10;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
front_panel_led_value |= 0x20;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_GREEN_BLINKING)
{
front_panel_led_value |= 0x00;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING)
{
front_panel_led_value |= 0x30;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else
{
front_panel_led_value |= 0x10;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value);
}
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
break;
case LED_FRONT_PWR:
front_panel_led_value &= ~0x06;
if(mode == ONLP_LED_MODE_GREEN)
{
front_panel_led_value |= 0x04;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
front_panel_led_value |= 0x02;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING)
{
front_panel_led_value |= 0x06;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
}
else
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value);
break;
case LED_REAR_FAN_TRAY_1:
dev_info.addr = FAN_TRAY_1;
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR);
fan_tray_led_reg_value &= ~0x03;
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
fan_tray_led_reg_value |= 0x01;/*Solid Green*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
if(mode == ONLP_LED_MODE_GREEN)
{
fan_tray_led_reg_value |= 0x01;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
fan_tray_led_reg_value |= 0x02;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
{
fan_tray_led_reg_value |= 0x02;/*Solid Amber*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
break;
case LED_REAR_FAN_TRAY_2:
dev_info.addr = FAN_TRAY_2;
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR);
fan_tray_led_reg_value &= ~0x0c;
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
fan_tray_led_reg_value |= 0x04;/*Solid Green*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
if(mode == ONLP_LED_MODE_GREEN)
{
fan_tray_led_reg_value |= 0x04;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
fan_tray_led_reg_value |= 0x08;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
{
fan_tray_led_reg_value |= 0x08;/*Solid Amber*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
break;
case LED_REAR_FAN_TRAY_3:
dev_info.addr = FAN_TRAY_3;
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
fan_tray_led_reg_value &= ~0x30;
rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR);
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
fan_tray_led_reg_value |= 0x10;/*Solid Green*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
if(mode == ONLP_LED_MODE_GREEN)
{
fan_tray_led_reg_value |= 0x10;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
fan_tray_led_reg_value |= 0x20;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
{
fan_tray_led_reg_value |= 0x20;/*Solid Amber*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
break;
case LED_REAR_FAN_TRAY_4:
dev_info.addr = FAN_TRAY_4;
fantray_present = dni_i2c_lock_read(NULL, &dev_info);
fan_tray_led_reg_value &= ~0xc0;
rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR);
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm !=0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
fan_tray_led_reg_value |= 0x40; /*Solid Green*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
if(mode == ONLP_LED_MODE_GREEN)
{
fan_tray_led_reg_value |= 0x40;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
fan_tray_led_reg_value |= 0x80;
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
{
fan_tray_led_reg_value |= 0x80;/*Solid Amber*/
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value);
}
}
dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
break;
}
return ONLP_STATUS_OK;
}

View File

@@ -41,24 +41,29 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in
int fd;
int len;
if ((buffer == NULL) || (buf_size < 0)) {
if ((buffer == NULL) || (buf_size < 0))
{
return -1;
}
if ((fd = open(filename, O_RDONLY)) == -1) {
if ((fd = open(filename, O_RDONLY)) == -1)
{
return -1;
}
if ((len = read(fd, buffer, buf_size)) < 0) {
if ((len = read(fd, buffer, buf_size)) < 0)
{
close(fd);
return -1;
}
if ((close(fd) == -1)) {
if ((close(fd) == -1))
{
return -1;
}
if ((len > buf_size) || (data_len != 0 && len != data_len)) {
if ((len > buf_size) || (data_len != 0 && len != data_len))
{
return -1;
}
@@ -278,3 +283,31 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data)
return -1;
}
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 != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM)
speed_good++;
rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR);
if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM)
speed_good++;
rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR);
if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM)
speed_good++;
rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT);
rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR);
if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM)
speed_good++;
return speed_good;
}

View File

@@ -39,7 +39,7 @@
#define MAX_REAR_FAN_SPEED 20500
#define MAX_FRONT_FAN_SPEED 23000
#define MAX_PSU_FAN_SPEED 19000
#define MAX_PSU_FAN_SPEED 20256
#define NUM_OF_SFP 48
#define NUM_OF_QSFP 6
@@ -94,6 +94,7 @@
#define TURN_OFF (0)
#define TURN_ON (1)
#define ALL_FAN_TRAY_EXIST (4)
#define FAN_SPEED_NORMALLY (4)
#define PSU_STATUS_PRESENT (1)
#define PSU_NODE_MAX_PATH_LEN (64)
#define FAN_ZERO_RPM (960)
@@ -133,7 +134,6 @@
#define FAN_STAT1_REG (0x05)
#define FAN_STAT2_REG (0x06)
#define PSU_STAT_REG (0x03)
#define ALARM_REG (0x06)
#define INTERRUPT_REG (0x02)
#define PORT_ADDR (0x50)
@@ -170,6 +170,7 @@ 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_cpld_write_attribute(char *cpld_path, int addr, int data);
int dni_lock_cpld_read_attribute(char *cpld_path, int addr);
int dni_fan_speed_good();
#define DEBUG_MODE 0

View File

@@ -172,10 +172,10 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max)
int
onlp_sysi_platform_manage_fans(void)
{
int i = 0;
int new_percentage;
int highest_temp = 0;
onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS];
int i = 0;
int new_percentage;
int highest_temp = 0;
onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS];
/* Get current temperature */
if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), &thermal[0]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), &thermal[1]) != ONLP_STATUS_OK ||
@@ -234,77 +234,136 @@ onlp_sysi_platform_manage_fans(void)
int
onlp_sysi_platform_manage_leds(void)
{
/* Set front lights: fan, power supply 1, 2*/
uint8_t addr, present_bit = 0x00;
int fantray_present = -1, rpm = 0, rpm1 = 0;
uint8_t psu1_state, psu2_state, power_state, fan_tray_interface_detected_value;
int fan_tray_pres_value, fan_board_not_present_count,i ,fan_stat_reg_mask;
addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG);
/* Turn the fan led on or off */
if((addr & 0xc0) == 0 )
dev_info_t dev_info;
dev_info.bus = I2C_BUS_3;
dev_info.offset = 0x00;
dev_info.flags = DEFAULT_FLAG;
/* Fan tray 1 */
dev_info.addr = FAN_TRAY_1;
fantray_present = dni_i2c_lock_read(NULL, &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 != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF);
/* Green */
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_FRONT_FAN), TURN_ON);
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED);
}
/* Set front light of SYS */
addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG);
if((addr & 0x30) == 0x30)
/* Fan tray 2 */
dev_info.addr = FAN_TRAY_2;
fantray_present = dni_i2c_lock_read(NULL, &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 != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_OFF);
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN);
}
else
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_ON);
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED);
}
/* Set front light of PSU */
addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG);
if((addr & 0x06) == 0x00)
/* Fan tray 3 */
dev_info.addr = FAN_TRAY_3;
fantray_present = dni_i2c_lock_read(NULL, &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 != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF);
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN);
}
else
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON);
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED);
}
/* Fan tray 4 */
dev_info.addr = FAN_TRAY_4;
fantray_present = dni_i2c_lock_read(NULL, &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 != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN);
}
else
{
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED);
}
/* FRONT FAN & SYS LED */
fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG);
fan_board_not_present_count = 0;
for(i = 0;i < 4; i++)
{
fan_stat_reg_mask = 0x01 << i;
if((fan_tray_pres_value & fan_stat_reg_mask) == fan_stat_reg_mask)
fan_board_not_present_count++;
}
if(fan_board_not_present_count == 0 && dni_fan_speed_good() == FAN_SPEED_NORMALLY)
{
/* Green FAN operates 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
{
/* Solid Amber FAN or more failed*/
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_ORANGE);
fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG);
if(fan_tray_interface_detected_value == 0xfe || (fan_tray_pres_value & 0x10) != 0x10)
{
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_ORANGE);
}
}
/* Set front light of PWR */
dev_info.bus = I2C_BUS_6;
dev_info.addr = PSU1_EEPROM;
psu1_state = dni_i2c_lock_read(NULL, &dev_info);
/* Turn on or off the FAN tray leds */
present_bit = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG);
if((present_bit & 0x01) == 0x00)
dev_info.addr = PSU2_EEPROM;
psu2_state = dni_i2c_lock_read(NULL, &dev_info);
power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG);
if( psu1_state == 1 && psu2_state == 1 && (power_state & 0x22) == 0x22 )
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF);
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN);
}
else if((power_state & 0x42) == 0x42 || (power_state & 0x24) == 0x24)
{
/* Blinking Amber */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE_BLINKING);
}
else
{
onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON);
}
if((present_bit & 0x02) == 0x00)
{
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 & 0x04) == 0x00)
{
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 & 0x08) == 0x00)
{
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);
else if ( ( power_state & 0x42 ) != 0x42 || ( power_state & 0x24 ) != 0x24 )
{
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE);
}
else
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF);
return ONLP_STATUS_OK;
}

View File

@@ -69,28 +69,28 @@ static char* cpu_coretemp_files[] =
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
{ }, /* Not used */
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0},
{ { 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, 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, 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_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, 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, 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_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0},
ONLP_THERMAL_STATUS_PRESENT,
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_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, dni_onlp_thermal_threshold(50000,60000,65000)
},
@@ -98,11 +98,11 @@ static onlp_thermal_info_t linfo[] = {
ONLP_THERMAL_STATUS_PRESENT,
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_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
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(PSU2_ID)},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
}
@@ -151,5 +151,4 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
info->mcelsius = r_data / temp_base;
return ONLP_STATUS_OK;
}
}

View File

@@ -62,7 +62,6 @@ class OnlPlatform_x86_64_delta_ag5648_r0(OnlPlatformDelta,
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