1. Read psu present by attribute instead of i2c access.

2. Add a platform device number for FAN_IO_CTRL.
This commit is contained in:
Jeff Chen
2018-12-10 09:33:01 +08:00
parent 316de4d518
commit 35328a2a96
5 changed files with 21 additions and 42 deletions

View File

@@ -1220,6 +1220,7 @@ static struct platform_device agc7648sv1_i2c_device[] = {
agc7648sv1_i2c_device_num(64),
agc7648sv1_i2c_device_num(65),
agc7648sv1_i2c_device_num(66),
agc7648sv1_i2c_device_num(67),
};
/* ---------------- I2C device - end ------------- */

View File

@@ -249,29 +249,19 @@ static int dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, cha
}
else
{
dev_info_t dev_info;
dev_info.addr = PSU_EEPROM;
dev_info.offset = 0x00; /* In EEPROM address 0x00 */
dev_info.flags = DEFAULT_FLAG;
switch(local_id)
{
switch(local_id) {
case FAN_1_ON_PSU1:
dev_info.bus = I2C_BUS_31;
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].status);
psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH);
break;
case FAN_1_ON_PSU2:
dev_info.bus = I2C_BUS_32;
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].status);
psu_present = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH);
break;
default:
break;
}
if(dni_i2c_lock_read(NULL, &dev_info) >= 0)
if(psu_present == 0)
info->status |= ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F;
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].status);
r_data = dni_i2c_lock_read_attribute(NULL, fullpath);
if (r_data == 1)
else if(psu_present == 1)
info->status |= ONLP_FAN_STATUS_FAILED;
/* Read PSU FAN speed from psu_fan1_speed_rpm */

View File

@@ -87,6 +87,8 @@ typedef unsigned int UINT4;
#define FAN2_PRESENT_PATH "/sys/class/gpio/gpio498/value"
#define FAN3_PRESENT_PATH "/sys/class/gpio/gpio497/value"
#define FAN4_PRESENT_PATH "/sys/class/gpio/gpio496/value"
#define PSU1_PRESENT_PATH "/sys/devices/platform/delta-agc7648sv1-swpld1.0/psu1_present"
#define PSU2_PRESENT_PATH "/sys/devices/platform/delta-agc7648sv1-swpld1.0/psu2_present"
/* REG define */
#define SWPLD_1_ADDR (0x6A)

View File

@@ -244,10 +244,10 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
int val = 0;
int ret = ONLP_STATUS_OK;
int index = ONLP_OID_ID_GET(id);
dev_info_t dev_info;
char device_name[10] = {0};
UINT4 u4Data = 0;
UINT4 multiplier = 1000;
int psu_present = -1;
VALIDATE(id);
@@ -257,10 +257,10 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
switch (index) {
case PSU1_ID:
dev_info.bus = I2C_BUS_31;
psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH);
break;
case PSU2_ID:
dev_info.bus = I2C_BUS_32;
psu_present = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH);
break;
default:
break;
@@ -284,30 +284,24 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
}
else
{
dev_info.addr = PSU_EEPROM;
dev_info.offset = 0x00; /* In EEPROM address 0x00 */
dev_info.flags = DEFAULT_FLAG;
/* Check PSU have voltage input or not */
dni_psu_pmbus_info_get(index, "psu_v_in", &val);
/* Check PSU is PRESENT or not
* Read PSU EEPROM 1 byte from adress 0x00
* if not present, return negative value. */
if(val == 0 && dni_i2c_lock_read(NULL, &dev_info) < 0)
/* Check PSU is PRESENT or not */
if(psu_present == 0)
info->status |= ONLP_PSU_STATUS_PRESENT;
else if(val == 0 && psu_present == 1)
{
/* Unable to read PSU EEPROM */
/* PSU is not PRESENT */
/* Able to read PSU VIN(psu_power_not_good) */
info->status |= ONLP_PSU_STATUS_FAILED;
return ret;
}
else if(val == 0)
else
{
/* Unable to read PSU VIN(psu_power_good) */
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
}
else
info->status |= ONLP_PSU_STATUS_PRESENT;
}
ret = dni_psu_info_get(id, info);

View File

@@ -208,7 +208,6 @@ int onlp_sysi_platform_manage_leds(void)
uint8_t psu_state;
int psu_pwr_status = 0;
int psu_pwr_int = 0;
dev_info_t dev_info;
int fantray_present = -1;
char fullpath[50] = {'\0'};
@@ -217,10 +216,6 @@ int onlp_sysi_platform_manage_leds(void)
rv = ONLP_STATUS_OK;
}
else {
dev_info.offset = 0x00;
dev_info.flags = DEFAULT_FLAG;
dev_info.size = 1;
/* Fan tray 1 */
fantray_present = dni_i2c_lock_read_attribute(NULL, FAN1_PRESENT_PATH);
rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT);
@@ -319,13 +314,11 @@ int onlp_sysi_platform_manage_leds(void)
}
/* Set front light of PWR */
dev_info.bus = I2C_BUS_31; // PSU1
dev_info.addr = PSU_EEPROM;
psu_state = dni_i2c_lock_read(NULL, &dev_info);
psu_state = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH);
psu_pwr_status = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_STATUS_REGISTER);
psu_pwr_int = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_INT_REGISTER);
if(psu_state == 1 && (psu_pwr_status & 0x80) == 0x80 && (psu_pwr_int & 0x10) == 0x10)
if(psu_state == 0 && (psu_pwr_status & 0x80) == 0x80 && (psu_pwr_int & 0x10) == 0x10)
{
/* Green */
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)
@@ -338,10 +331,9 @@ int onlp_sysi_platform_manage_leds(void)
rv = ONLP_STATUS_E_INTERNAL;
}
dev_info.bus = I2C_BUS_32; // PSU2
psu_state = dni_i2c_lock_read(NULL, &dev_info);
psu_state = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH);
if(psu_state == 1 && (psu_pwr_status & 0x40) == 0x40 && (psu_pwr_int & 0x20) == 0x20)
if(psu_state == 0 && (psu_pwr_status & 0x40) == 0x40 && (psu_pwr_int & 0x20) == 0x20)
{
/* Green */
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)