1. read the fan's present bit from FANIO controller

2. improve the bus's access

Signed-off-by: hans <hans.tseng@deltaww.com>
This commit is contained in:
hans
2018-11-07 11:08:06 +08:00
parent a5ec39317e
commit 403a9d4b26
8 changed files with 149 additions and 106 deletions

View File

@@ -245,6 +245,7 @@ dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
int
onlp_fani_init(void)
{
lockinit();
return ONLP_STATUS_OK;
}

View File

@@ -99,6 +99,7 @@ static onlp_led_info_t linfo[] =
int
onlp_ledi_init(void)
{
lockinit();
return ONLP_STATUS_OK;
}
@@ -311,15 +312,15 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
if(mode == ONLP_LED_MODE_GREEN)
{
front_panel_led_value |= 0x01;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
front_panel_led_value |= 0x02;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
break;
case LED_FRONT_PWR1:
/* Clean bit 7,6 */
@@ -329,18 +330,18 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
{
/* Green */
front_panel_led_value |= 0x40;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
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);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_OFF)
{
front_panel_led_value &= ~0xC0;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else
return ONLP_STATUS_E_UNSUPPORTED;
@@ -353,18 +354,18 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
{
/* Green */
front_panel_led_value |= 0x10;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
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);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_OFF)
{
front_panel_led_value &= ~0x30;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else
return ONLP_STATUS_E_UNSUPPORTED;
@@ -376,20 +377,20 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
if(mode == ONLP_LED_MODE_GREEN_BLINKING)
{
front_panel_led_value |= 0x08;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else if (mode == ONLP_LED_MODE_GREEN)
{
front_panel_led_value |= 0x04;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else if (mode == ONLP_LED_MODE_RED)
{
front_panel_led_value |= 0x0c;
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value);
dni_swpld_write_attribute(LED_REG, front_panel_led_value,BUS_LOCK);
break;
case LED_REAR_FAN_TRAY_1:
@@ -397,75 +398,75 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
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);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_RED)
{/* Red light */
fan_tray_led_reg_value |= 0x80;
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
break;
case LED_REAR_FAN_TRAY_2:
fan_tray_led_reg_value &= ~0x30;
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);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_RED)
{/* Red light */
fan_tray_led_reg_value |= 0x20;
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
break;
case LED_REAR_FAN_TRAY_3:
fan_tray_led_reg_value &= ~0x0c;
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);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_RED)
{/* Red light */
fan_tray_led_reg_value |= 0x08;
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
break;
case LED_REAR_FAN_TRAY_4:
fan_tray_led_reg_value &= ~0x03;
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);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_RED)
{/* Red light */
fan_tray_led_reg_value |= 0x02;
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
break;
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);
dni_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value,BUS_LOCK);
}
else if(mode == ONLP_LED_MODE_RED)
{/* 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);
dni_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value,BUS_LOCK);
}
else
dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value);
dni_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value,BUS_LOCK);
break;
}
return ONLP_STATUS_OK;

View File

@@ -33,8 +33,30 @@
#include <AIM/aim.h>
#include "platform_lib.h"
#include <onlplib/i2c.h>
#include <onlplib/mmap.h>
#include <pthread.h>
static onlp_shlock_t* dni_lock = NULL;
#define DNI_BUS_LOCK() \
do{ \
onlp_shlock_take(dni_lock); \
}while(0)
#define DNI_BUS_UNLOCK() \
do{ \
onlp_shlock_give(dni_lock);\
}while(0)
#define DNILOCK_MAGIC 0xE3A0B4E6
void lockinit()
{
static int sem_inited =0;
if(!sem_inited)
{
onlp_shlock_create(DNILOCK_MAGIC, &dni_lock, "bus-lock");
sem_inited =1;
}
}
int dni_fan_speed_good()
{
@@ -65,31 +87,39 @@ int dni_fan_speed_good()
int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, int data_len)
{
int fd;
int fd,rv=0;
int len;
DNI_BUS_LOCK();
if ((buffer == NULL) || (buf_size < 0)) {
return -1;
rv=-1;
goto ERROR;
}
if ((fd = open(filename, O_RDONLY)) == -1) {
return -1;
rv=-1;
goto ERROR;
}
if ((len = read(fd, buffer, buf_size)) < 0) {
close(fd);
return -1;
rv= -1;
goto ERROR;
}
if ((close(fd) == -1)) {
return -1;
rv= -1;
goto ERROR;
}
if ((len > buf_size) || (data_len != 0 && len != data_len)) {
return -1;
rv= -1;
goto ERROR;
}
return 0;
ERROR:
DNI_BUS_UNLOCK();
return rv;
}
int dni_i2c_read_attribute_string(char *filename, char *buffer, int buf_size, int data_len)
@@ -113,31 +143,31 @@ int dni_i2c_read_attribute_string(char *filename, char *buffer, int buf_size, in
int dni_i2c_lock_read( mux_info_t * mux_info, dev_info_t * dev_info)
{
int r_data=0;
pthread_mutex_lock(&mutex);
DNI_BUS_LOCK();
if(mux_info != NULL)
dni_lock_swpld_write_attribute(mux_info->offset, mux_info->channel);
dni_swpld_write_attribute(mux_info->offset, mux_info->channel,BUS_LOCKED);
if(dev_info->size == 1)
r_data = onlp_i2c_readb(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags);
else
r_data = onlp_i2c_readw(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags);
pthread_mutex_unlock(&mutex);
DNI_BUS_UNLOCK();
return r_data;
}
int dni_i2c_lock_write( mux_info_t * mux_info, dev_info_t * dev_info)
{
pthread_mutex_lock(&mutex);
DNI_BUS_LOCK();
if(mux_info != NULL)
dni_lock_swpld_write_attribute(mux_info->offset, mux_info->channel);
dni_swpld_write_attribute(mux_info->offset, mux_info->channel,BUS_LOCKED);
/* Write size */
if(dev_info->size == 1)
onlp_i2c_write(dev_info->bus, dev_info->addr, dev_info->offset, 1, &dev_info->data_8, dev_info->flags);
else
onlp_i2c_writew(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->data_16, dev_info->flags);
pthread_mutex_unlock(&mutex);
DNI_BUS_UNLOCK();
return 0;
}
@@ -146,9 +176,9 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath)
int fd, len, nbytes = 10;
char r_data[10] = {0};
pthread_mutex_lock(&mutex);
DNI_BUS_LOCK();
if(mux_info != NULL)
dni_lock_swpld_write_attribute(mux_info->offset, mux_info->channel);
dni_swpld_write_attribute(mux_info->offset, mux_info->channel,BUS_LOCKED);
if ((fd = open(fullpath, O_RDONLY)) == -1)
{
goto ERROR;
@@ -158,20 +188,20 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath)
goto ERROR;
}
close(fd);
pthread_mutex_unlock(&mutex);
DNI_BUS_UNLOCK();
return atoi(r_data);
ERROR:
close(fd);
pthread_mutex_unlock(&mutex);
DNI_BUS_UNLOCK();
return -1;
}
int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullpath)
{
int fd, len, nbytes = 10;
pthread_mutex_lock(&mutex);
DNI_BUS_LOCK();
if(mux_info!=NULL)
dni_lock_swpld_write_attribute(mux_info->offset, mux_info->channel);
dni_swpld_write_attribute(mux_info->offset, mux_info->channel,BUS_LOCKED);
/* Create output file descriptor */
fd = open(fullpath, O_WRONLY, 0644);
if (fd == -1)
@@ -183,12 +213,13 @@ int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullp
{
goto ERROR;
}
fsync(fd);
close(fd);
pthread_mutex_unlock(&mutex);
DNI_BUS_UNLOCK();
return 0;
ERROR:
close(fd);
pthread_mutex_unlock(&mutex);
DNI_BUS_UNLOCK();
return -1;
}
@@ -201,7 +232,7 @@ int dni_lock_swpld_read_attribute(int addr)
char r_data[10] = {0};
char address[10] = {0};
sprintf(address, "%02x", addr);
pthread_mutex_lock(&mutex1);
DNI_BUS_LOCK();
/* Create output file descriptor */
fd = open(SWPLD_ADDR_PATH, O_WRONLY, 0644);
if (fd == -1)
@@ -224,23 +255,24 @@ int dni_lock_swpld_read_attribute(int addr)
}
sscanf( r_data, "%x", & data);
close(fd);
pthread_mutex_unlock(&mutex1);
DNI_BUS_UNLOCK();
return data;
ERROR:
close(fd);
pthread_mutex_unlock(&mutex1);
DNI_BUS_UNLOCK();
return -1;
}
/* SWPLD modulize in AG9032v1 platform at bus 6 on address 0x31.
Use this function to select address the & write the data. */
int dni_lock_swpld_write_attribute(int addr, int data)
int dni_swpld_write_attribute(int addr, int data,int bus_lock)
{
int fd, len;
char address[10] = {0};
sprintf(address, "%02x", addr);
pthread_mutex_lock(&mutex1);
if(bus_lock == BUS_LOCK)
DNI_BUS_LOCK();
/* Create output file descriptor */
fd = open(SWPLD_ADDR_PATH, O_WRONLY, 0644);
if (fd == -1)
@@ -252,6 +284,7 @@ int dni_lock_swpld_write_attribute(int addr, int data)
{
goto ERROR;
}
fsync(fd);
close(fd);
fd = open(SWPLD_DATA_PATH, O_WRONLY, 0644);
if (fd == -1)
@@ -264,13 +297,16 @@ int dni_lock_swpld_write_attribute(int addr, int data)
{
goto ERROR;
}
fsync(fd);
close(fd);
pthread_mutex_unlock(&mutex1);
if(bus_lock == BUS_LOCK)
DNI_BUS_UNLOCK();
return 0;
ERROR:
close(fd);
pthread_mutex_unlock(&mutex1);
if(bus_lock == BUS_LOCK)
DNI_BUS_UNLOCK();
return -1;
}

View File

@@ -27,6 +27,8 @@
#define __PLATFORM_LIB_H__
#include "x86_64_delta_ag9032v1_log.h"
#include <onlp/onlp.h>
#include <onlplib/shlocks.h>
/* CPLD numbrt & peripherals */
#define NUM_OF_THERMAL_ON_BOARDS 6
@@ -136,6 +138,8 @@
#define SFP_RESET_3 (0x3E)
#define SFP_RESET_4 (0x3F)
#define BUS_LOCK 1
#define BUS_LOCKED 0
int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, int data_len);
int dni_i2c_read_attribute_string(char *filename, char *buffer, int buf_size, int data_len);
@@ -160,16 +164,14 @@ typedef struct mux_info_s
}mux_info_t;
pthread_mutex_t mutex;
pthread_mutex_t mutex1;
int dni_i2c_lock_read(mux_info_t * mux_info, dev_info_t * dev_info);
int dni_i2c_lock_write(mux_info_t * mux_info, dev_info_t * dev_info);
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_swpld_write_attribute(int addr, int data,int bus_lock);
int dni_fan_speed_good();
void lockinit();
typedef enum
{

View File

@@ -65,6 +65,7 @@ dni_psu_pmbus_info_get(int id, char *node, int *value)
int
onlp_psui_init(void)
{
lockinit();
return ONLP_STATUS_OK;
}
@@ -215,4 +216,4 @@ int
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
}

View File

@@ -102,6 +102,7 @@ int
onlp_sfpi_init(void)
{
/* Called at initialization time */
lockinit();
return ONLP_STATUS_OK;
}
@@ -225,7 +226,7 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
/* Select qsfp port to response mode */
backup_response_data = dni_lock_swpld_read_attribute(sfp_response_reg);
backup_response_data &= ~(1 << (7 - (port % 8)));
dni_lock_swpld_write_attribute(sfp_response_reg, backup_response_data);
dni_swpld_write_attribute(sfp_response_reg, backup_response_data,BUS_LOCK);
/* Select QSFP port */
sprintf(port_data, "%d", port + 1);
@@ -272,7 +273,7 @@ int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
/* Select qsfp port to response mode */
backup_response_data = dni_lock_swpld_read_attribute(sfp_response_reg);
backup_response_data &= ~(1 << (7 - (port % 8)));
dni_lock_swpld_write_attribute(sfp_response_reg, backup_response_data);
dni_swpld_write_attribute(sfp_response_reg, backup_response_data,BUS_LOCK);
channel = port_sel_channel;
@@ -311,7 +312,7 @@ int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
/* Select qsfp port to response mode */
backup_response_data = dni_lock_swpld_read_attribute(sfp_response_reg);
backup_response_data &= ~(1 << (7 - (port % 8)));
dni_lock_swpld_write_attribute(sfp_response_reg, backup_response_data);
dni_swpld_write_attribute(sfp_response_reg, backup_response_data,BUS_LOCK);
channel = port_sel_channel;
@@ -352,7 +353,7 @@ int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
/* Select qsfp port to response mode */
backup_response_data = dni_lock_swpld_read_attribute(sfp_response_reg);
backup_response_data &= ~(1 << (7 - (port % 8)));
dni_lock_swpld_write_attribute(sfp_response_reg, backup_response_data);
dni_swpld_write_attribute(sfp_response_reg, backup_response_data,BUS_LOCK);
channel = port_sel_channel;
@@ -392,7 +393,7 @@ int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value
/* Select qsfp port to response mode */
backup_response_data = dni_lock_swpld_read_attribute(sfp_response_reg);
backup_response_data &= ~(1 << (7 - (port % 8)));
dni_lock_swpld_write_attribute(sfp_response_reg, backup_response_data);
dni_swpld_write_attribute(sfp_response_reg, backup_response_data,BUS_LOCK);
channel = port_sel_channel;

View File

@@ -47,6 +47,7 @@ onlp_sysi_platform_get(void)
int
onlp_sysi_init(void)
{
lockinit();
return ONLP_STATUS_OK;
}
@@ -210,26 +211,30 @@ onlp_sysi_platform_manage_leds(void)
{
/* Set front lights: fan, power supply 1, 2
*/
int fantray_present = -1, rpm, rpm1,i=0,count=0, state;
int rpm, rpm1,i=0,count=0, state;
uint8_t present_bit = 0x00, bit=0x00;
uint8_t power_state;
mux_info_t mux_info;
dev_info_t dev_info;
mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG;
mux_info.channel = 0x07;
mux_info.flags = DEFAULT_FLAG;
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;
dev_info.size = 1;
present_bit = dni_i2c_lock_read(&mux_info, &dev_info);
char echoDebug[50]={0};
sprintf(echoDebug, "echo \"[DEBUG ] present_bit=0x%x \" > /dev/console",present_bit);
system(echoDebug);
/* 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 )
if((present_bit & ((bit+1) << 4)) == 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);
@@ -239,14 +244,12 @@ onlp_sysi_platform_manage_leds(void)
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);
/* Fan tray 2 */
bit=0x00;
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((present_bit & ((bit+1) << 3)) == 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);
@@ -256,14 +259,12 @@ onlp_sysi_platform_manage_leds(void)
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);
/* Fan tray 3 */
bit=0x00;
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((present_bit & ((bit+1) << 2)) == 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);
@@ -273,14 +274,12 @@ onlp_sysi_platform_manage_leds(void)
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);
/* Fan tray 4 */
bit=0x00;
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((present_bit & ((bit+1) << 1)) == 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);
@@ -290,14 +289,12 @@ onlp_sysi_platform_manage_leds(void)
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);
/* Fan tray 5 */
bit=0x00;
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 )
if((present_bit & (bit+1)) == 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);
@@ -311,10 +308,13 @@ onlp_sysi_platform_manage_leds(void)
/* 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)
//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)
bit=0x00;
present_bit = dni_i2c_lock_read(&mux_info, &dev_info);
if( (present_bit & (bit+1) << i) == 0)
count++;
}
/* Set front light of FAN */
@@ -336,7 +336,7 @@ onlp_sysi_platform_manage_leds(void)
state = dni_i2c_lock_read(&mux_info, &dev_info);
/* Check the state of PSU 1, "state = 1, PSU exists' */
if(state == 1)
if(state > 0)
{
power_state = dni_lock_swpld_read_attribute(CTL_REG);
/* Set the light of PSU */
@@ -360,7 +360,7 @@ onlp_sysi_platform_manage_leds(void)
state = dni_i2c_lock_read(&mux_info, &dev_info);
/* Check the state of PSU 2, "state = 1, PSU exists' */
if(state == 1)
if(state > 0)
{
power_state = dni_lock_swpld_read_attribute(CTL_REG);
/* Set the light of PSU */

View File

@@ -109,6 +109,7 @@ static onlp_thermal_info_t linfo[] = {
int
onlp_thermali_init(void)
{
lockinit();
return ONLP_STATUS_OK;
}