Merge pull request #186 from pkarashchenko/fix_as7512_32x_operation

Fix as7512 32x operation
This commit is contained in:
Jeffrey Townsend
2017-04-11 09:35:40 -07:00
committed by GitHub
8 changed files with 68 additions and 47 deletions

View File

@@ -106,7 +106,10 @@ class SubprocessMixin:
sys.stderr.write(fd.read())
os.unlink(v2Out)
else:
return subprocess.check_output(cmd, *args, cwd=cwd, **kwargs)
try:
return subprocess.check_output(cmd, *args, cwd=cwd, **kwargs)
except subprocess.CalledProcessError:
return ''
def rmdir(self, path):
self.log.debug("+ /bin/rmdir %s", path)

View File

@@ -38,7 +38,7 @@ struct cpld_client_node {
/* Addresses scanned for accton_i2c_cpld
*/
static const unsigned short normal_i2c[] = { 0x31, 0x35, 0x60, 0x61, 0x62, I2C_CLIENT_END };
static const unsigned short normal_i2c[] = { 0x31, 0x35, 0x60, 0x61, 0x62, 0x64, I2C_CLIENT_END };
static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf)
{

View File

@@ -82,6 +82,10 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da,
struct as7512_32x_psu_data *data = as7512_32x_psu_update_device(dev);
u8 status = 0;
if (!data->valid) {
return -EIO;
}
if (attr->index == PSU_PRESENT) {
status = !(data->status >> ((2 - data->index) + 2) & 0x1);
}
@@ -230,6 +234,7 @@ static struct as7512_32x_psu_data *as7512_32x_psu_update_device(struct device *d
int status;
int power_good = 0;
data->valid = 0;
dev_dbg(&client->dev, "Starting as7512_32x update\n");
/* Read psu status */
@@ -237,6 +242,7 @@ static struct as7512_32x_psu_data *as7512_32x_psu_update_device(struct device *d
if (status < 0) {
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
goto exit;
}
else {
data->status = status;
@@ -253,6 +259,7 @@ static struct as7512_32x_psu_data *as7512_32x_psu_update_device(struct device *d
if (status < 0) {
data->model_name[0] = '\0';
dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr);
goto exit;
}
else {
data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0';
@@ -263,6 +270,7 @@ static struct as7512_32x_psu_data *as7512_32x_psu_update_device(struct device *d
data->valid = 1;
}
exit:
mutex_unlock(&data->update_lock);
return data;

View File

@@ -57,7 +57,7 @@ typedef struct fan_path_S
#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \
{ #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \
#prj"fan"#id"_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" }
#prj"fan_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" }
#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id)
@@ -173,6 +173,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
if (atoi(r_data) > 0) {
info->status |= ONLP_FAN_STATUS_FAILED;
return ONLP_STATUS_OK;
}
/* get fan direction (both : the same)

View File

@@ -66,7 +66,7 @@ int deviceNodeWriteInt(char *filename, int value, int data_len)
char buf[8] = {0};
sprintf(buf, "%d", value);
return deviceNodeWrite(filename, buf, sizeof(buf)-1, data_len);
return deviceNodeWrite(filename, buf, (int)strlen(buf), data_len);
}
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len)

View File

@@ -26,6 +26,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <onlplib/file.h>
#include <onlp/platformi/sysi.h>
#include <onlp/platformi/ledi.h>
#include <onlp/platformi/thermali.h>
@@ -34,14 +35,23 @@
#include "x86_64_accton_as7512_32x_int.h"
#include "x86_64_accton_as7512_32x_log.h"
#include "platform_lib.h"
#include <onlplib/file.h>
#define NUM_OF_THERMAL_ON_MAIN_BROAD 5
#define NUM_OF_FAN_ON_MAIN_BROAD 6
#include "platform_lib.h"
#define NUM_OF_THERMAL_ON_MAIN_BROAD CHASSIS_THERMAL_COUNT
#define NUM_OF_FAN_ON_MAIN_BROAD CHASSIS_FAN_COUNT
#define NUM_OF_PSU_ON_MAIN_BROAD 2
#define NUM_OF_LED_ON_MAIN_BROAD 5
#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/"
#define NUM_OF_CPLD 3
static char arr_cplddev_name[NUM_OF_CPLD][10] =
{
"4-0060",
"5-0062",
"6-0064"
};
const char*
onlp_sysi_platform_get(void)
{
@@ -58,11 +68,33 @@ onlp_sysi_onie_data_get(uint8_t** data, int* size)
return ONLP_STATUS_OK;
}
}
aim_free(rdata);
*size = 0;
return ONLP_STATUS_E_INTERNAL;
}
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
int i, v[NUM_OF_CPLD]={0};
for (i=0; i < NUM_OF_CPLD; i++) {
v[i] = 0;
if(onlp_file_read_int(v+i, "%s%s/version", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) {
return ONLP_STATUS_E_INTERNAL;
}
}
pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]);
return 0;
}
void
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
{
aim_free(pi->cpld_versions);
}
int
onlp_sysi_oids_get(onlp_oid_t* table, int max)
{

View File

@@ -25,12 +25,11 @@
***********************************************************/
#include <unistd.h>
#include <onlplib/mmap.h>
#include <onlplib/file.h>
#include <onlp/platformi/thermali.h>
#include <fcntl.h>
#include "platform_lib.h"
#define prefix_path "/sys/bus/i2c/devices/"
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_THERMAL(_id)) { \
@@ -38,17 +37,6 @@
} \
} while(0)
#define OPEN_READ_FILE(fd,fullpath,data,nbytes,len) \
DEBUG_PRINT("[Debug][%s][%d][openfile: %s]\n", __FUNCTION__, __LINE__, fullpath); \
if ((fd = open(fullpath, O_RDONLY)) == -1) \
return ONLP_STATUS_E_INTERNAL; \
if ((len = read(fd, r_data, nbytes)) <= 0){ \
close(fd); \
return ONLP_STATUS_E_INTERNAL;} \
DEBUG_PRINT("[Debug][%s][%d][read data: %s]\n", __FUNCTION__, __LINE__, r_data); \
if (close(fd) == -1) \
return ONLP_STATUS_E_INTERNAL
enum onlp_thermal_id
{
THERMAL_RESERVED = 0,
@@ -61,16 +49,16 @@ enum onlp_thermal_id
THERMAL_1_ON_PSU2,
};
static char last_path[][30] = /* must map with onlp_thermal_id */
static char* devfiles__[] = /* must map with onlp_thermal_id */
{
"reserved",
"3-0048/temp1_input",
"3-0049/temp1_input",
"3-004a/temp1_input",
"15-004c/temp1_input",
"15-004c/temp2_input",
"10-0058/psu_temp1_input",
"11-005b/psu_temp1_input",
"/sys/bus/i2c/devices/3-0048*temp1_input",
"/sys/bus/i2c/devices/3-0049*temp1_input",
"/sys/bus/i2c/devices/3-004a*temp1_input",
"/sys/bus/i2c/devices/15-004c*temp1_input",
"/sys/bus/i2c/devices/15-004c*temp2_input",
"/sys/bus/i2c/devices/10-0058*psu_temp1_input",
"/sys/bus/i2c/devices/11-005b*psu_temp1_input",
};
/* Static values */
@@ -128,24 +116,13 @@ onlp_thermali_init(void)
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
int fd, len, nbytes = 10, temp_base=1, local_id;
char r_data[10] = {0};
char fullpath[50] = {0};
int local_id;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id);
/* get fullpath */
sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[local_id];
OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len);
info->mcelsius = atoi(r_data) / temp_base;
DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius);
return ONLP_STATUS_OK;
return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]);
}

View File

@@ -31,9 +31,9 @@ class OnlPlatform_x86_64_accton_as7512_32x_r0(OnlPlatformAccton,
# initialize CPLD
self.new_i2c_devices(
[
('accton_i2c_cpld', 0x60, 0),
('accton_i2c_cpld', 0x62, 0),
('accton_i2c_cpld', 0x64, 0),
('accton_i2c_cpld', 0x60, 4),
('accton_i2c_cpld', 0x62, 5),
('accton_i2c_cpld', 0x64, 6),
]
)
########### initialize I2C bus 1 ###########
@@ -46,11 +46,11 @@ class OnlPlatform_x86_64_accton_as7512_32x_r0(OnlPlatformAccton,
('pca9548', 0x71, 1),
# initiate PSU-1
('as7512_32x_psu1', 0x50, 10),
('as7512_32x_psu', 0x50, 10),
('ym2651', 0x58, 10),
# initiate PSU-2
('as7512_32x_psu2', 0x53, 11),
('as7512_32x_psu', 0x53, 11),
('ym2651', 0x5b, 11),
#initiate max6657 thermal sensor