Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ struct cpld_client_node {
enum cpld_type {
as7726_32x_cpld1,
as7726_32x_cpld2,
as7726_32x_cpld3
as7726_32x_cpld3,
as7726_32x_cpu_cpld
};

struct as7726_32x_cpld_data {
Expand All @@ -61,6 +62,7 @@ static const struct i2c_device_id as7726_32x_cpld_id[] = {
{ "as7726_32x_cpld1", as7726_32x_cpld1 },
{ "as7726_32x_cpld2", as7726_32x_cpld2 },
{ "as7726_32x_cpld3", as7726_32x_cpld3 },
{ "as7726_32x_cpu_cpld", as7726_32x_cpu_cpld },
{ }
};
MODULE_DEVICE_TABLE(i2c, as7726_32x_cpld_id);
Expand Down Expand Up @@ -258,6 +260,16 @@ static const struct attribute_group as7726_32x_cpld3_group = {
.attrs = as7726_32x_cpld3_attributes,
};

static struct attribute *as7726_32x_cpu_cpld_attributes[] = {
&sensor_dev_attr_version.dev_attr.attr,
&sensor_dev_attr_access.dev_attr.attr,
NULL
};

static const struct attribute_group as7726_32x_cpu_cpld_group = {
.attrs = as7726_32x_cpu_cpld_attributes,
};

static ssize_t show_present_all(struct device *dev, struct device_attribute *da,
char *buf)
{
Expand Down Expand Up @@ -300,7 +312,7 @@ static ssize_t show_present_all(struct device *dev, struct device_attribute *da,
static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da,
char *buf)
{
int i, status;
int status;
u8 value=0;
u8 reg = 0x50;
struct i2c_client *client = to_i2c_client(dev);
Expand Down Expand Up @@ -575,6 +587,9 @@ static int as7726_32x_cpld_probe(struct i2c_client *client,
case as7726_32x_cpld3:
group = &as7726_32x_cpld3_group;
break;
case as7726_32x_cpu_cpld:
group = &as7726_32x_cpu_cpld_group;
break;
default:
break;
}
Expand Down Expand Up @@ -613,6 +628,9 @@ static int as7726_32x_cpld_remove(struct i2c_client *client)
case as7726_32x_cpld3:
group = &as7726_32x_cpld3_group;
break;
case as7726_32x_cpu_cpld:
group = &as7726_32x_cpu_cpld_group;
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static ssize_t set_wdt_max_pwm(struct device *dev, struct device_attribute *da,
/* fan related data, the index should match sysfs_fan_attributes
*/
static const u8 fan_reg[] = {
0x01, /* fan cpld version */
0x0F, /* fan 1-6 present status */
0x10, /* fan 1-6 direction(0:F2B 1:B2F) */
0x11, /* fan PWM(for all fan) */
Expand Down Expand Up @@ -85,6 +86,7 @@ enum fan_id {
};

enum sysfs_fan_attributes {
FAN_VERSION,
FAN_PRESENT_REG,
FAN_DIRECTION_REG,
FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */
Expand Down Expand Up @@ -125,6 +127,10 @@ enum sysfs_fan_attributes {

/* Define attributes
*/
#define DECLARE_FAN_VERSION_SENSOR_DEV_ATTR() \
static SENSOR_DEVICE_ATTR(version, S_IRUGO, fan_show_value, NULL, FAN_VERSION)
#define DECLARE_FAN_VERSION_ATTR() &sensor_dev_attr_version.dev_attr.attr

#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \
static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT)
#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr
Expand Down Expand Up @@ -187,6 +193,7 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6);
DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR();
/* 3 fan wdt attribute in this platform */
DECLARE_FAN_WDT_SENSOR_DEV_ATTR();
DECLARE_FAN_VERSION_SENSOR_DEV_ATTR();

static struct attribute *as7726_32x_fan_attributes[] = {
/* fan related attributes */
Expand Down Expand Up @@ -218,6 +225,7 @@ static struct attribute *as7726_32x_fan_attributes[] = {
DECLARE_FAN_WDT_TIMER_ATTR(),
DECLARE_FAN_WDT_MAX_PWM_ATTR(),
DECLARE_FAN_WDT_STATUS_ATTR(),
DECLARE_FAN_VERSION_ATTR(),
NULL
};

Expand Down Expand Up @@ -492,6 +500,9 @@ static ssize_t fan_show_value(struct device *dev, struct device_attribute *da,
case FAN_WDT_STATUS:
ret = sprintf(buf, "%u\n", data->reg_val[attr->index]);
break;
case FAN_VERSION:
ret = sprintf(buf, "%u\n", data->reg_val[attr->index]);
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@

#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom"

#define BIOS_VER_PATH "/sys/devices/virtual/dmi/id/bios_version"
#define MFU_VER_PATH "/var/tmp/last_updated_MFU_version"

int onlp_file_write_integer(char *filename, int value);
int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len);
int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len);
Expand Down Expand Up @@ -95,5 +98,14 @@ int psu_acbel_serial_number_get(int id, char *serial, int serial_len);
#define DEBUG_PRINT(format, ...)
#endif

#define AIM_FREE_IF_PTR(p) \
do \
{ \
if (p) { \
aim_free(p); \
p = NULL; \
} \
} while (0)

#endif /* __PLATFORM_LIB_H__ */

Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@

#define NUM_OF_FAN_ON_MAIN_BROAD 6
#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/"
#define NUM_OF_CPLD 3
#define NUM_OF_CPLD 5
#define FAN_DUTY_CYCLE_MAX (100)
#define FAN_DUTY_CYCLE_DEFAULT (38)


static char arr_cplddev_name[NUM_OF_CPLD][10] =
{
"0-0065",
"11-0060",
"12-0062",
"13-0064"
"13-0064",
"54-0066"
};

const char*
Expand Down Expand Up @@ -108,15 +110,42 @@ int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
int i, v[NUM_OF_CPLD]={0};
onlp_onie_info_t onie;
char *bios_ver = NULL;
char *mfu_ver = NULL;
const char *bios = "";
const char *mfu = "";

onlp_onie_decode_file(&onie, IDPROM_PATH);

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;
}
onlp_file_read_int(v+i, "%s%s/version", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]);

}
pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]);

pi->cpld_versions = aim_fstrdup("\r\n\t CPU CPLD(0x65): %02X"
"\r\n\t Main CPLD(0x60): %02X"
"\r\n\t Main CPLD(0x62): %02X"
"\r\n\t Main CPLD(0x64): %02X"
"\r\n\t Fan CPLD(0x66): %02X\r\n",
v[0], v[1], v[2], v[3], v[4]);

if (onlp_file_read_str(&bios_ver, BIOS_VER_PATH) > 0) {
bios = bios_ver;
}
if (onlp_file_read_str(&mfu_ver, MFU_VER_PATH) > 0) {
mfu = mfu_ver;
}

pi->other_versions = aim_fstrdup("\r\n\t BIOS: %s\r\n\t ONIE: %s"
"\r\n\t MFU: %s",
bios, onie.onie_version, mfu);

onlp_onie_info_free(&onie);
AIM_FREE_IF_PTR(bios_ver);
AIM_FREE_IF_PTR(mfu_ver);

return 0;
}
Expand All @@ -125,6 +154,7 @@ void
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
{
aim_free(pi->cpld_versions);
aim_free(pi->other_versions);
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
from onl.platform.base import *
from onl.platform.accton import *
import os.path

def get_mfu_ver_file():
cmd_list = [
"mkdir -p /mnt/onie-boot",
"blkid | grep 'ONIE-BOOT'",
"mount -L ONIE-BOOT /mnt/onie-boot",
"cp -a /mnt/onie-boot/onie/update/last_updated_MFU_version /var/tmp",
"umount /mnt/onie-boot"
]

for cmd in cmd_list:
if "cp -a" in cmd:
if not os.path.isfile("/mnt/onie-boot/onie/update/last_updated_MFU_version"):
print("last_updated_MFU_version file does not exist !")
continue

process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.communicate()

if process.returncode != 0:
if "blkid" in cmd and process.returncode == 1:
print("ONIE-BOOT label does not exist !")
else:
print("'" + cmd + "'" + " runs with error return code: " + str(process.returncode))

if "cp -a" in cmd:
continue

return False

return True

import commands

Expand Down Expand Up @@ -82,6 +114,7 @@ def baseconfig(self):
('as7726_32x_cpld1', 0x60, 11),
('as7726_32x_cpld2', 0x62, 12),
('as7726_32x_cpld3', 0x64, 13),
('as7726_32x_cpld3', 0x65, 0),
])
self.new_i2c_devices([
# initiate fan
Expand Down Expand Up @@ -149,5 +182,6 @@ def baseconfig(self):

ir3570_check()
_8v89307_init()
get_mfu_ver_file()

return True