From fa210c5fdbe9b935ac31fe0be880a7978c47fe25 Mon Sep 17 00:00:00 2001 From: leo lin Date: Mon, 10 Dec 2018 03:21:11 +0800 Subject: [PATCH] [s9280-64x] add mac vdd init and update eeprom size --- .../builds/ingrasys_s9280_64x_i2c_cpld.c | 28 +++++++++++++++++++ .../builds/ingrasys_s9280_64x_i2c_cpld.h | 1 + .../module/src/platform_lib.h | 1 + .../module/src/sysi.c | 6 ++-- .../src/x86_64_ingrasys_s9280_64x_module.c | 2 +- .../x86_64_ingrasys_s9280_64x_r0/__init__.py | 25 +++++++++++++++++ 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c index 588e9473..5a487c5b 100644 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c @@ -112,6 +112,7 @@ enum LED_GREEN { #define CPLD_QSFP_LED_BASE_REG 0x80 #define CPLD_QSFP_LED_BLINK_BASE_REG 0x90 #define CPLD_RTMR_RESET_REG 0x4B +#define CPLD_ROV_STATUS_REG 0x4C /* bit definition for register value */ enum CPLD_QSFP_PORT_STATUS_BITS { @@ -453,6 +454,7 @@ enum s9280_64x_cpld_sysfs_attributes { CPLD_QSFP_LED_16, CPLD_QSFP_LED_BLINK, CPLD_RTMR_RESET, + CPLD_ROV_STATUS, }; @@ -527,6 +529,8 @@ static ssize_t read_rtmr_reset(struct device *dev, struct device_attribute *da, char *buf); static ssize_t write_rtmr_reset(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t read_rov_status(struct device *dev, + struct device_attribute *da, char *buf); static LIST_HEAD(cpld_client_list); /* client list for cpld */ static struct mutex list_lock; /* mutex for client list */ @@ -695,6 +699,8 @@ static SENSOR_DEVICE_ATTR(cpld_qsfp_led_blink, S_IWUSR | S_IRUGO, read_qsfp_led_blink, write_qsfp_led_blink, CPLD_QSFP_LED_BLINK); static SENSOR_DEVICE_ATTR(cpld_rtmr_reset, S_IWUSR | S_IRUGO, read_rtmr_reset, write_rtmr_reset, CPLD_RTMR_RESET); +static SENSOR_DEVICE_ATTR(cpld_rov_status, S_IRUGO, + read_rov_status, NULL, CPLD_ROV_STATUS); /* define support attributes of cpldx , total 5 */ /* cpld 1 */ @@ -742,6 +748,7 @@ static struct attribute *s9280_64x_cpld1_attributes[] = { &sensor_dev_attr_cpld_sfp_led.dev_attr.attr, &sensor_dev_attr_cpld_sfp_led_blink.dev_attr.attr, &sensor_dev_attr_cpld_rtmr_reset.dev_attr.attr, + &sensor_dev_attr_cpld_rov_status.dev_attr.attr, NULL }; @@ -1576,6 +1583,27 @@ static ssize_t write_rtmr_reset(struct device *dev, return count; } +/* get rov status register */ +static ssize_t read_rov_status(struct device *dev, + struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 reg; + int reg_val; + + if (attr->index == CPLD_ROV_STATUS) { + reg = CPLD_ROV_STATUS_REG; + I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); + if (reg_val < 0) + return -1; + return sprintf(buf, "0x%02x\n", reg_val); + } + return -1; +} + /* add valid cpld client to list */ static void ingrasys_i2c_cpld_add_client(struct i2c_client *client) { diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h index 08db7138..c118f0a7 100644 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h @@ -79,6 +79,7 @@ enum LED_GREEN { #define CPLD_QSFP_LED_BASE_REG 0x80 #define CPLD_QSFP_LED_BLINK_BASE_REG 0x90 #define CPLD_RTMR_RESET_REG 0x4B +#define CPLD_ROV_STATUS_REG 0x4C /* bit definition for register value */ enum CPLD_QSFP_PORT_STATUS_BITS { diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h index ed129e09..cc61a924 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h @@ -47,6 +47,7 @@ #define SYS_PSU1_PREFIX "/sys/bus/i2c/devices/i2c-18/18-0050/" #define SYS_PSU2_PREFIX "/sys/bus/i2c/devices/i2c-17/17-0050/" #define SYS_EEPROM_PATH "/sys/bus/i2c/devices/0-0051/eeprom" +#define SYS_EEPROM_SIZE 512 #define PSU1_EEPROM_PATH "/sys/bus/i2c/devices/18-0050/psu_eeprom" #define PSU2_EEPROM_PATH "/sys/bus/i2c/devices/17-0050/psu_eeprom" #define PSU_STATUS_PRESENT 1 diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/sysi.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/sysi.c index 0cd67513..a3ed3790 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/sysi.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/sysi.c @@ -51,9 +51,9 @@ onlp_sysi_init(void) int onlp_sysi_onie_data_get(uint8_t** data, int* size) { - uint8_t* rdata = aim_zmalloc(256); - if(onlp_file_read(rdata, 256, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { - if(*size == 256) { + uint8_t* rdata = aim_zmalloc(SYS_EEPROM_SIZE); + if(onlp_file_read(rdata, SYS_EEPROM_SIZE, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { + if(*size == SYS_EEPROM_SIZE) { *data = rdata; return ONLP_STATUS_OK; } diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_module.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_module.c index f5f9b814..33b294f2 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_module.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/onlp/builds/src/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_module.c @@ -30,7 +30,7 @@ static int datatypes_init__(void) { -#define INGRAYSYS_S9180_32X_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#define INGRAYSYS_S9280_64X_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); #include return 0; } diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py index 345fcbbd..6451e192 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py @@ -1,6 +1,13 @@ from onl.platform.base import * from onl.platform.ingrasys import * import os +import sys + +def msg(s, fatal=False): + sys.stderr.write(s) + sys.stderr.flush() + if fatal: + sys.exit(1) class OnlPlatform_x86_64_ingrasys_s9280_64x_r0(OnlPlatformIngrasys): PLATFORM='x86-64-ingrasys-s9280-64x-r0' @@ -20,6 +27,11 @@ class OnlPlatform_x86_64_ingrasys_s9280_64x_r0(OnlPlatformIngrasys): 3, 4, 7, 8, 11, 12, 15, 16, 3, 4, 7, 8, 11, 12, 15, 16, 3, 4, 7, 8, 11, 12, 15, 16, 3, 4, 7, 8, 11, 12, 15, 16) + # vid to mac vdd value mapping + vdd_val_array=( 0.85, 0.82, 0.77, 0.87, 0.74, 0.84, 0.79, 0.89 ) + # vid to rov reg value mapping + rov_reg_array=( 0x79, 0x73, 0x69, 0x7D, 0x63, 0x77, 0x6D, 0x81 ) + self.insmod("eeprom_mb") # init SYS EEPROM devices self.new_i2c_devices( @@ -176,6 +188,19 @@ class OnlPlatform_x86_64_ingrasys_s9280_64x_r0(OnlPlatformIngrasys): for i in range(1, 3): self.new_i2c_device('sff8436', 0x50, 28+i) + # _mac_vdd_init + rov_status_file = open("/sys/bus/i2c/devices/1-0033/cpld_rov_status", "r") + reg_val_str = rov_status_file.read() + rov_status_file.close() + + reg_val = int(reg_val_str, 16) + vid = reg_val & 0x7 + mac_vdd_val = vdd_val_array[vid] + rov_reg = rov_reg_array[vid] + + msg("Setting mac vdd %1.2f with rov register value 0x%x\n" % (mac_vdd_val, rov_reg) ) + os.system("i2cset -y -r 15 0x76 0x21 0x%x w" % rov_reg) + # _i2c_fan_speed_init os.system("echo 120 > /sys/class/hwmon/hwmon1/device/pwm2")